#include <oskit/com/mem.h>void *oskit_mem_alloc(oskit_mem_t *m, oskit_u32_t size, oskit_u32_t flags);
Allocate a chunk of memory of size bytes, subject to various options specified in flags. If successful, a pointer to the new chunk of memory is returned. Othersize a NULL pointer is returned. The new memory must be deallocated with the free method described below. The options that can be specifed with the flags parameter are:
- OSKIT_MEM_AUTO_SIZE
- The memory allocator must keep track of the size of allocated blocks allocated using this flag; in this case, the value size parameter passed in the corresponding free call is meaningless. For blocks allocated without this flag set, the caller promises to keep track of the size of the allocated block, and pass it back to free on deallocation.
- OSKIT_MEM_NONBLOCKING
- If set, this flag indicates that the memory allocator must not block during the allocation or deallocation operation. Any calls to the allocation functions from interrupt handlers must specify the OSKIT_MEM_NONBLOCKING flag.
- OSKIT_MEM_PHYS_WIRED
- Indicates that the must must be non-pageable. Accesses to the returned memory must not fault.
- OSKIT_MEM_PHYS_CONTIG
- Indicates the underlying physical memory must be contiguous.
- OSKIT_MEM_VIRT_EQ_PHYS
- Indicates the virtual address must exactly equal the physical address so the driver may use them interchangeably. The OSKIT_MEM_PHYS_CONTIG flag must also be set whenever this flag is set.
- OSKIT_MEM_ISADMA_MEM
- This flag applies only to machines with ISA busses or other busses that are software compatible with ISA, such as EISA, MCA, or PCI. It indicates that the memory allocated must be appropriate for DMA access using the system's built-in DMA controller. In particular, it means that the buffer must be physically contiguous, must be entirely contained in the low 16MB of physical memory, and must not cross a 64KB boundary. (By implication, this means that allocations using this flag are limited to at most 64KB in size.) The OSKIT_MEM_PHYS_CONTIG flag must also be set if this flag is set.
- m
- The memory object to operate on.
- size
- The size (in bytes) of the chunk to allocate.
- flags
- Allocation options and constraints.
Returns a pointer to the new chunk of memory on success, or NULL if the request could not be satisfied.