MonkOS  v0.1
A simple 64-bit operating system (x86_64)
pmap.h File Reference

Physical memory map describing usable and reserved regions of physical memory. More...

#include <core.h>

Go to the source code of this file.

Data Structures

struct  pmapregion_t
 A memregion represents and describes a contiguous region of physical memory. More...
 
struct  pmap_t
 A memory map describing available and reserved regions of physical memory. More...
 

Enumerations

Functions

void pmap_init ()
 Initialize the physical memory map using data installed by the BIOS during boot loading. More...
 
void pmap_add (uint64_t addr, uint64_t size, enum pmemtype type)
 Add a region of memory to the physical memory map. More...
 
const pmap_t * pmap ()
 Return a pointer to the current physical memory map. More...
 

Detailed Description

Physical memory map describing usable and reserved regions of physical memory.

Most of the map is derived from data provided by the system BIOS at boot time.

Definition in file pmap.h.


Data Structure Documentation

struct pmapregion

A memregion represents and describes a contiguous region of physical memory.

Definition at line 37 of file pmap.h.

Data Fields
uint64_t addr base address
uint64_t size size of memory region
int32_t type Memory type (see memtype enum)
uint32_t flags flags (currently unused)
struct pmap

A memory map describing available and reserved regions of physical memory.

There are no gaps in a memory map.

Definition at line 52 of file pmap.h.

Data Fields
uint64_t count Memory regions in the memory map.
uint64_t last_usable End of last usable region.
pmapregion_t region[1] An array of 'count' memory regions.

Enumeration Type Documentation

enum pmemtype

The types of physical memory.

Enumerator
PMEMTYPE_USABLE 

Reported usable by the BIOS.

PMEMTYPE_RESERVED 

Reported (or inferred) to be reserved.

PMEMTYPE_ACPI 

Used for ACPI tables or code.

PMEMTYPE_ACPI_NVS 

Used for ACPI non-volatile storage.

PMEMTYPE_BAD 

Reported as bad memory.

PMEMTYPE_UNCACHED 

Marked as uncacheable, usually for I/O.

PMEMTYPE_UNMAPPED 

Marked as "do not map".

Definition at line 21 of file pmap.h.

Function Documentation

void pmap_init ( )

Initialize the physical memory map using data installed by the BIOS during boot loading.

Definition at line 292 of file pmap.c.

Referenced by kmain().

void pmap_add ( uint64_t  addr,
uint64_t  size,
enum pmemtype  type 
)

Add a region of memory to the physical memory map.

Parameters
[in]addrThe starting address of the region.
[in]sizeThe size of the region.
[in]typeThe type of memory to add.

Definition at line 322 of file pmap.c.

Referenced by acpi_init(), map_table(), and reserve_region().

const pmap_t* pmap ( )

Return a pointer to the current physical memory map.

Returns
A pointer to the physical memory map.

Definition at line 316 of file pmap.c.

Referenced by kmem_init(), and page_init().