Pip
Architecture-dependent parts of Pip: MAL, IAL and boot
Macros | Functions | Variables
x86_multiboot/boot/mmu.c File Reference
#include "mmu.h"
#include "multiboot.h"
#include <stdint.h>
#include "debug.h"
#include "mal.h"
#include "structures.h"
#include "fpinfo.h"
#include "hdef.h"
#include <libc.h>

Macros

#define GLOBAL_BIT   (1 << 8)
 

Functions

void mapPageC (uintptr_t pd, uintptr_t p, uintptr_t v, uint8_t user)
 
void prepareC (uintptr_t pd, uintptr_t v, uintptr_t *pageList)
 Prepares a Page Directory to receive a mapping by inserting the according Page Table. More...
 
uint32_t pageCountMapPageC (uintptr_t pd, uintptr_t vaddr)
 tests if there is a page table in pd at vaddr More...
 
void mapPageWrapper (page_directory_t *dir, uint32_t paddr, uint32_t vaddr, uint8_t user)
 
void initFreePageList (uintptr_t base, uintptr_t length)
 
uint32_t * allocPage ()
 Unsafe page allocator. Allocated a page. More...
 
void freePage (uint32_t *page)
 Frees a page in a really unsafe way. More...
 
void dumpMmap (uint32_t *mmap_ptr, uint32_t len)
 Despite its unexplicit name, this function initializes the physical memory, preparing the page allocator as well. More...
 
void mark_kernel_global ()
 Marks the whole kernel area as global, preventing TLB invalidations. More...
 
void initMmu ()
 Initializes the MMU, creating the kernel's page directory and switching to it. More...
 

Variables

page_directory_tkernelDirectory =0
 The kernel's page directory. More...
 
uint32_t maxPages = 0
 The maximal amount of pages available. More...
 
uint32_t allocatedPages = 0
 The current allocated amount of pages. More...
 
uint32_t ramEnd = 0
 End of memory. More...
 
uint32_t pageCount = 0
 
uint32_t * firstFreePage
 First free available page. More...
 
uint32_t placement_address
 Placement address, this should be unused. More...
 

Macro Definition Documentation

◆ GLOBAL_BIT

#define GLOBAL_BIT   (1 << 8)

Function Documentation

◆ allocPage()

uint32_t* allocPage ( )

Unsafe page allocator. Allocated a page.

Returns
Virtual address to a free page.

◆ dumpMmap()

void dumpMmap ( uint32_t *  mmap_ptr,
uint32_t  len 
)

Despite its unexplicit name, this function initializes the physical memory, preparing the page allocator as well.

Parameters
mmap_ptrPointer to a multiboot-compliant memory map
lenLength of the memory map structure

◆ freePage()

void freePage ( uint32_t *  page)

Frees a page in a really unsafe way.

Parameters
pageThe page to free.

◆ initFreePageList()

void initFreePageList ( uintptr_t  base,
uintptr_t  length 
)

◆ initMmu()

void initMmu ( )

Initializes the MMU, creating the kernel's page directory and switching to it.

◆ mapPageC()

void mapPageC ( uintptr_t  pd,
uintptr_t  p,
uintptr_t  v,
uint8_t  user 
)

◆ mapPageWrapper()

void mapPageWrapper ( page_directory_t dir,
uint32_t  paddr,
uint32_t  vaddr,
uint8_t  user 
)

◆ mark_kernel_global()

void mark_kernel_global ( )

Marks the whole kernel area as global, preventing TLB invalidations.

◆ pageCountMapPageC()

uintptr_t pageCountMapPageC ( uintptr_t  pd,
uintptr_t  vaddr 
)

tests if there is a page table in pd at vaddr

Parameters
pda page directory
uintptr_tvaddr
Returns
1 if there is no page table at position pd_idx, 0 else

◆ prepareC()

void prepareC ( uintptr_t  pd,
uintptr_t  v,
uintptr_t *  page_list 
)

Prepares a Page Directory to receive a mapping by inserting the according Page Table.

Parameters
pda page directory
va virtual address
page_list

Variable Documentation

◆ allocatedPages

uint32_t allocatedPages = 0

The current allocated amount of pages.

◆ firstFreePage

uint32_t* firstFreePage

First free available page.

◆ kernelDirectory

page_directory_t* kernelDirectory =0

The kernel's page directory.

◆ maxPages

uint32_t maxPages = 0

The maximal amount of pages available.

◆ pageCount

uint32_t pageCount = 0

◆ placement_address

uint32_t placement_address

Placement address, this should be unused.

◆ ramEnd

uint32_t ramEnd = 0

End of memory.