ArvernOS
Loading...
Searching...
No Matches
memory.h File Reference
#include <stdint.h>
Include dependency graph for memory.h:
This graph shows which files directly or indirectly include this file:

Data Structures

struct  memory_region_t
struct  memory_regions_t
struct  memory_area_t
struct  memory_reserved_areas_t
struct  memory_framebuffer_t

Macros

#define KERNEL_LOAD_ADDRESS   0x00100000
#define MEMORY_AVAILABLE   1
 Usable RAM (E820 type 1).
#define MEMORY_RESERVED   2
 Memory reserved (E820 type 2).
#define MEMORY_AREA_NO_ALLOC   (1 << 0)
 The frame allocator must not hand out frames in this area.
#define MEMORY_AREA_IDENTITY   (1 << 1)
 This area must remain identity-mapped when paging is enabled.
#define MEMORY_SECTION_WRITABLE   0x1
 The kernel section is writable.
#define MEMORY_SECTION_EXECUTABLE   0x2
 The kernel section holds executable code.

Typedefs

typedef void(*) memory_section_map_fn(uint64_t addr, uint64_t size, uint32_t flags)

Functions

memory_regions_t memory_get_regions ()
memory_reserved_areas_t memory_get_reserved_areas ()
memory_framebuffer_t memory_get_framebuffer ()
void memory_map_kernel_sections (memory_section_map_fn map)

Detailed Description

Physical memory handoff between the board's bootloader and the MMU.

A board learns the physical memory layout from its bootloader and normalizes it here, so that the architecture's frame allocator and paging code stay board-agnostic.

  • memory_get_regions() returns the bootloader's E820-style memory map, i.e. what the machine says is RAM and what it says is not.
  • memory_get_reserved_areas() returns the ranges the bootloader has populated on top of plain RAM (kernel image, boot payloads, boot information), which the E820 memory map does not account for.

Macro Definition Documentation

◆ KERNEL_LOAD_ADDRESS

#define KERNEL_LOAD_ADDRESS   0x00100000

Address where the kernel image is loaded, i.e. the end of low memory. Must match the load address set by the board's linker script.

Typedef Documentation

◆ memory_section_map_fn

typedef void(*) memory_section_map_fn(uint64_t addr, uint64_t size, uint32_t flags)

Called by memory_map_kernel_sections() for every allocated section of the kernel image.

Parameters
addrthe section start address
sizethe section size in bytes
flagsa combination of MEMORY_SECTION_*

Function Documentation

◆ memory_get_framebuffer()

memory_framebuffer_t memory_get_framebuffer ( )

Returns the description of the linear framebuffer.

Returns
the framebuffer description

◆ memory_get_regions()

memory_regions_t memory_get_regions ( )

Returns the physical memory map reported by the bootloader.

Returns
the regions and their count

◆ memory_get_reserved_areas()

memory_reserved_areas_t memory_get_reserved_areas ( )

Returns the physical address ranges reserved by the bootloader: the kernel image and the areas populated on top of plain RAM around it.

The areas array is owned by the board and remains valid until the next call to this function.

Returns
the reserved address ranges

◆ memory_map_kernel_sections()

void memory_map_kernel_sections ( memory_section_map_fn map)

Invokes map for every allocated section of the kernel image, so that paging can identity map each section with the right permissions.

The implementation must report page-granular ranges and sections must not overlap each other.

Parameters
mapthe callback to invoke for each section