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

kmem_alloc_phys(D3)


kmem_alloc_phys -- allocate DMA-addressable, driver-accessible memory

Synopsis

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

void *kmem_alloc_phys(size_t size, physreq_t *preqp, paddr32_t *paddrp, int flags);

Description

The kmem_alloc_phys( ) function allocates size bytes of physically-contiguous memory with the physical address alignment properties specified by the preqp structure and returns the base physical address of this memory in the array pointed to by the paddrp argument. The memory returned by kmem_alloc_phys( ) is always physically contiguous, even if the PREQ_PHYSCONTIG bit is not set.

Arguments


size
Number of bytes to allocate.

preqp
Pointer to a physreq(D4) structure. preqp->phys_dmasize must not be zero.

paddrp
Base physical address for the allocated memory. This can be an array of 32-bit numbers; the first element is the least-signficant 32 bits of the address, the next is the next 32 bits, and so forth. The number of array elements can be expressed as:
   (preqp->phys_dmasize + 31) / 32.
The value yielded is rounded.

flags
Valid values are:

0
Allocation can block to wait for resources.

KM_FAIL_OK
Return NULL if memory is not readily available, although the allocation may still block for a limited amount of time.

Return values

On success, kmem_alloc_phys( ) returns a pointer to the allocated memory and the base physical address (from the driver's point of view), in memory pointed to by the paddrp argument.

If flags is set to KM_FAIL_OK and memory is not available for the allocation, kmem_alloc_phys( ) returns NULL and does not allocate the memory.

Usage

DDI 8 restricts kmem_alloc_phys( ) allocations to the lower 4GB of memory. This is necessary because DDI 8 does not permit HBA drivers to specify a DMA width of 64 with a command width of 32.

Context and synchronization

User or blockable context.

Hardware applicability

All

Version applicability

ddi: 8, 8mp

Differences between versions

References

kmem_free(D3) msgscgth(D3str), scgth(D4), sdi_kmem_alloc_phys(D3sdi)

``Memory allocation'' in HDK Technical Reference


19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 6 and UnixWare (SVR5) HDK - June 2005