This function is declared in the coresrv/vmm/vmm_api.h
file.
void *KnVmAllocate(void *addr, rtl_size_t size, int flags);
Reserves a range of physical pages defined by the addr
and size
parameters. If the VMM_FLAG_COMMIT flag is indicated, the function reserves and commits pages for one call.
Parameters:
addr
is the page-aligned base physical address; if addr
is set equal to 0, the system chooses a free area of physical memory. size
is the size of the memory area in bytes (must be a multiple of the page size).flags
refers to allocation flags.Returns the base virtual address of the reserved area. If it is not possible to reserve a memory area, the function returns RTL_NULL.
Allocation flags
In the flags
parameter, you can use the following flags (vmm/flags.h
):
KnVmAllocate()
call in so-called "lazy" mode.Permissible combinations of memory protection attributes:
Example
coredump->base = KnVmAllocate(RTL_NULL, vmaSize,
VMM_FLAG_READ | VMM_FLAG_RESERVE |
VMM_FLAG_WRITE | VMM_FLAG_COMMIT |
VMM_FLAG_LOCKED).
The KnVmProtect()
function can be used to modify the defined memory area protection attributes if necessary.