Allocates an area of memory from the real_heap heap.
#include <sys/types.h>
caddr_t rmalloc (size, align) int size int align
size | Specifies the number of bytes to allocate. |
align | Specifies alignment characteristics. |
The rmalloc kernel service allocates an area of memory from the contiguous real memory heap. This area is the number of bytes in length specified by the size parameter and is aligned on the byte boundary specified by the align parameter. The align parameter is actually the log base 2 of the desired address boundary. For example, an align value of 4 requests that the allocated area be aligned on a 16-byte boundary.
The contiguous real memory heap, real_heap, is a heap of contiguous real memory pages located in the low 16MB of real memory. This heap is virtually mapped into the kernel extension's address space. By nature, this heap is implicitly pinned, so no explicit pinning of allocated regions is necessary.
The real_heap heap is useful for devices that require DMA transfers greater than 4K but do not provide a scatter/gather capability. Such a device must be given contiguous bus addresses by its device driver. The device driver should pass the DMA_CONTIGUOUS flag on its d_map_init call in order to obtain contiguous mappings. On certain platforms it is possible that a d_map_init call using the DMA_CONTIGUOUS flag could fail. In this case, the device driver can make use of the real_heap heap (using rmalloc) to obtain contiguous bus addresses for its device driver. Because the real_heap heap is a limited resource, device drivers should always attempt to use the DMA_CONTIGUOUS flag first.
On unsupported platforms, the rmalloc service returns NULL if the requested memory cannot be allocated.
The rmfree kernel service should be called to free allocation from a previous rmalloc call. The rmalloc kernel service can be called from the process environment only.
Upon successful completion, the rmalloc kernel service returns the address of the allocated area. A NULL pointer is returned if the requested memory cannot be allocated.
The rmfree kernel service.