Skip to main content

alloc_phys_pages

Function alloc_phys_pages 

Source
pub unsafe fn alloc_phys_pages(n: u64) -> u64
Expand description

Allocate n contiguous physical pages and return the physical addresses of the pages in question.

§Safety

Since this reads and writes specific allocator state addresses, it is only safe when the allocator has been set up properly. It may become less safe in the future.

§Panics

This function will panic if memory allocation fails

This is defined in an arch-specific module because it reads and writes the actual allocator state with inline assembly in order to access it atomically according to the architecture memory model rather than the Rust memory model: the stronger constraints of the latter cannot be perfectly satisfied due to the lack of per-byte atomic memcpy in the host.