DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
SVR5

kmem_alloc_physreq(D3)


kmem_alloc_physreq -- allocate memory with specified physical properties

Synopsis

   #include <sys/types.h>
   #include <sys/kmem.h>
   #include <sys/ddi.h>
   

void *kmem_alloc_physreq(size_t size, physreq_t *preqp, int flag)

Description

kmem_alloc_physreq allocates a specified amount of memory with the physical address alignment and contiguity properties specified by a physreq(D4) structure.

Arguments


size
Number of bytes to allocate.

preqp
Pointer to a physreq(D4) structure.

flag
Specifies whether the caller is willing to sleep waiting for memory. If flag is set to KM_SLEEP, the caller will sleep, if necessary, until the memory with the specified properties is available. If flag is set to KM_NOSLEEP, the caller will not sleep, but kmem_alloc_physreq will return NULL if suitable memory is not immediately available.

Return values

Upon successful completion, kmem_alloc_physreq returns a pointer to the allocated memory. If size is set to 0, kmem_alloc_physreq returns NULL regardless of the value of flag.

Usage

In DDI 8, the kmem_alloc_physreq( ) structure is mostly used to allocate page-aligned memory that is then passed to the mmap(D2) entry point routine or the kvtoppid(D3) function in special-purpose drivers. For setting up memory to use with scatter/gather operations, DDI 8 drivers should use the kmem_alloc_phys(D3) function or, for STREAMS drivers, the msgscgth(D3str) function.

The preqp argument points to a physreq structure, previously allocated by physreq_alloc(D3) and prepped with physreq_prep(D3). This structure is used to define physical address alignment requirements.

Drivers should call kmem_alloc_physreq( ) as early as possible if contiguous memory larger than one page is being requested, preferably during driver initialization. Due to randomization of the free page list, physically contiguous pages might not be available after the system has run at load for some time. This could cause kmem_alloc_physreq( ) to either fail (in the KM_NOSLEEP case) or possibly wait forever (in the KM_SLEEP case). is being requested.

Context and synchronization

If flag is set to KM_NOSLEEP, non-blockable, initialization, or interrupt context.

If flag is set to KM_SLEEP, user context.

This routine should not be called from driver strategy(D2) routines when contiguous memory larger than one page

Hardware applicability

All

Version applicability

ddi: 6, 6mp, 7, 7mp, 7.1, 7.1mp, 8, 8mp

Differences between versions

In DDI versions prior to version 8, kmem_alloc_physreq( ) is the preferred way to allocate memory with specified physical characteristics, especially when setting up scatter/gather operations. The virtual address it returns can be converted to a physical address with the vtop(D3) function. DDI 8 drivers should instead use the kmem_alloc_phys(D3) function when allocating memory for scatter/gather operations.

References

kmem_alloc(D3), kmem_alloc_phys(D3), kmem_free(D3), kmem_zalloc_physreq(D3), physreq(D4) physreq_alloc(D3), physreq_prep(D3), strategy(D2), vtop(D3)
19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 6 and UnixWare (SVR5) HDK - June 2005