Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Function

allocatePages

Public Function
std.os.uefi.tables.boot_services.BootServices.allocatePages
pub fn allocatePages(
        self: *BootServices,
        location: AllocateLocation,
        mem_type: MemoryType,
        pages: usize,
    ) AllocatePagesError![]align(4096) Page

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.

Params

File

os/uefi/tables/boot_services.zig:370
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
    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),
        }
    }