IBNOS
Classes | Macros | Functions | Variables
physmem.c File Reference
#include <memory/physmem.h>
#include <memory/paging.h>
#include <console/console.h>
#include <util/util.h>
Include dependency graph for physmem.c:

Go to the source code of this file.

Classes

struct  physMemExtraInfo
 

Macros

#define PHYSMEMEXTRA_SIZE   0x1000 /* must match PAGE_SIZE for now */
 
#define PHYSMEMEXTRA_MASK   0x3FF
 
#define PHYSMEMEXTRA_BITS   10
 
#define PHYSMEMEXTRA_COUNT   0x400
 
#define LINKER_KERNEL_BEGIN   ((uint32_t)&__kernelBegin)
 
#define LINKER_KERNEL_SIZE   ((uint32_t)&__kernelEnd - (uint32_t)&__kernelBegin)
 

Functions

struct physMemExtraInfo __attribute__ ((packed))
 
uint32_t __getCR0 ()
 
 asm (".text\align 4\ "__getCR0:\" " movl %cr0, %eax\" " ret\")
 
void physMemInit (multiboot_info_t *bootInfo)
 Initializes the physical memory management. More...
 
uint32_t physMemRAMSize ()
 Query RAM size. More...
 
uint32_t physMemUsableMemory ()
 Query usable RAM size. More...
 
void physMemClearMemoryBits (bool reserved)
 Marks the full memory range as reserved or free. More...
 
void physMemProtectBootEntry (uint32_t addr, uint32_t length)
 Marks all pages within a memory range as reserved and adds them to the boot map. More...
 
void physMemReserveMemory (uint32_t addr, uint32_t length)
 Marks all pages within a memory range as reserved. More...
 
void physMemFreeMemory (uint32_t addr, uint32_t length)
 Marks all pages fully contained within the memory range as free. More...
 
void physMemSetMemoryBits (uint32_t startIndex, uint32_t length, bool reserved)
 Marks a specific range of pages as reserved or free. More...
 
uint32_t physMemAllocPage (bool lowmem)
 Allocates a page of physical memory. More...
 
uint32_t physMemReleasePage (uint32_t index)
 Releases a page of physical memory. More...
 
uint32_t physMemAddRefPage (uint32_t index)
 Increment the refcounter of a physical page. More...
 
uint32_t physMemMarkUnpageable (uint32_t index)
 Marks a physical page as unpageable. More...
 
bool physMemIsLastRef (uint32_t index)
 Checks if a physical page is only referenced exactly one time. More...
 
void physMemPageOut (UNUSED uint32_t length)
 Pages out some memory to the hard drive. More...
 
uint32_t physMemPageIn (UNUSED uint32_t hdd_index)
 Pages in some data from the hard drive. More...
 
void physMemDumpMemInfo ()
 Dumps information about the physical memory usage. More...
 

Variables

uint32_t ramSize = 0
 
uint32_t ramUsableSize = 0
 
union {
   struct {
      uint32_t   present: 1
 
      uint32_t   ref: 7
 
      uint32_t   unpageable: 1
 
      uint32_t   avail: 23
 
   } 
 
   uint32_t   value
 
}; 
 
uint32_t __kernelBegin
 
uint32_t __kernelEnd
 

Variable Documentation

◆ @36

union { ... }

◆ avail

uint32_t avail

Definition at line 48 of file physmem.c.

◆ present

uint32_t present

Definition at line 45 of file physmem.c.

◆ ref

uint32_t ref

Definition at line 46 of file physmem.c.

◆ unpageable

uint32_t unpageable

Definition at line 47 of file physmem.c.

◆ value

uint32_t value

Definition at line 50 of file physmem.c.