Function allocatePages [src]

Allocates pages of memory. This function scans the memory map to locate free pages. When it finds a physically contiguous block of pages that is large enough and also satisfies the allocation requirements of alloc_type, it changes the memory map to indicate that the pages are now of type mem_type. In general, UEFI OS loaders and UEFI applications should allocate memory (and pool) of type .loader_data. UEFI boot service drivers must allocate memory (and pool) of type .boot_services_data. UREFI runtime drivers should allocate memory (and pool) of type .runtime_services_data (although such allocation can only be made during boot services time). Allocation requests of .allocate_any_pages allocate any available range of pages that satisfies the request. Allocation requests of .allocate_max_address allocate any available range of pages whose uppermost address is less than or equal to the address pointed to by the input. Allocation requests of .allocate_address allocate pages at the address pointed to by the input.

Prototype

pub fn allocatePages( self: *BootServices, location: AllocateLocation, mem_type: MemoryType, pages: usize, ) AllocatePagesError![]align(4096) Page

Parameters

self: *BootServiceslocation: AllocateLocationmem_type: MemoryTypepages: usize

Possible Errors

InvalidParameter
NotFound
OutOfResources
Unexpected UnexpectedError

Source

pub fn allocatePages( self: *BootServices, location: AllocateLocation, mem_type: MemoryType, pages: usize, ) AllocatePagesError![]align(4096) Page { var ptr: [*]align(4096) Page = switch (location) { .any => undefined, .address, .max_address => |ptr| ptr, }; switch (self._allocatePages( std.meta.activeTag(location), mem_type, pages, &ptr, )) { .success => return ptr[0..pages], .out_of_resources => return error.OutOfResources, .invalid_parameter => return error.InvalidParameter, .not_found => return error.NotFound, else => |status| return uefi.unexpectedStatus(status), } }