[−][src]Module sunrise_kernel::frame_allocator::i386
Architecture specific-behaviour i386 implementation of the frame allocator.
It keeps tracks of the allocated frames by mean of a giant bitmap mapping every physical memory frame in the address space to a bit representing if it is free or not. This works because the address space in 32 bits is only 4GB, so ~1 million frames only
During init we initialize the bitmap by parsing the information that the bootloader gives us and marking some physical memory regions as reserved, either because of BIOS or MMIO.
We also reserve everything that is mapped in KernelLand, assuming the bootstrap mapped it there for us, and we don't want to overwrite it.
We do not distinguish between reserved and occupied frames.
Structs
FrameAllocator | The physical memory manager. |
FrameAllocatori386 | A frame allocator backed up by a giant bitmap. |
Constants
FRAMES_BITMAP_SIZE | For unit tests we use a much smaller array. |
FRAME_BASE_LOG | The right shift to perform to a Physical address to get its frame id. |
FRAME_BASE_MASK | The frame part in PhysicalAddress. |
FRAME_FREE | In the the bitmap, 1 means the frame is free. |
FRAME_OCCUPIED | In the the bitmap, 0 means the frame is occupied. |
FRAME_OFFSET_MASK | The offset part in a PhysicalAddress. |
Statics
FRAME_ALLOCATOR | A physical memory manger to allocate and free memory frames |
Functions
addr_to_frame | Gets the frame number from a physical address |
frame_to_addr | Gets the physical address from a frame number |
init | Initialize the FrameAllocator by parsing the multiboot information and marking some memory areas as unusable |
mark_area_free | Marks a physical memory area as free for frame allocation |
mark_area_reserved | Marks a physical memory area as reserved and will never give it when requesting a frame. This is used to mark where memory holes are, or where the kernel was mapped |
mark_frame_bootstrap_allocated | Marks a physical memory frame as already allocated Currently used during init when paging marks KernelLand frames as alloc'ed by bootstrap |