Pip
Architecture-dependent parts of Pip: MAL, IAL and boot
|
#include <stdint.h>
#include "mal.h"
#include "maldefines.h"
#include "structures.h"
#include "debug.h"
#include "segment_selectors.h"
Functions | |
void | enable_paging () |
enables paging More... | |
void | disable_paging () |
disables paging More... | |
void | writePhysical (uint32_t table, uint32_t index, uint32_t val) |
STORE an address in an indirection table, physical version. More... | |
uint32_t | readPhysicalNoFlags (uint32_t table, uint32_t index) |
Reads the address stored into table table, at index index, using physical addresses. This function masks the least significant bits that are used by the kernel to store various flags (see readVirEntry and readPhyEntry in model) More... | |
uint32_t | getTableSize () |
Table size. More... | |
uint32_t | getIndexOfAddr (uint32_t addr, uint32_t index) |
Get index of indirection level given. More... | |
uint32_t | readAccessible (uint32_t table, uint32_t index) |
Reads the accessible flag. More... | |
void | writeAccessible (uint32_t table, uint32_t index, uint32_t value) |
Writes the accessible flag. More... | |
uint32_t | getCurPartition (void) |
Interface to get the current Page Directory. More... | |
void | updateCurPartition (uint32_t descriptor) |
Set current partition paddr. More... | |
uint32_t | getRootPartition (void) |
Interface to get the current Page Directory. More... | |
void | updateRootPartition (uint32_t partition) |
Set root partition paddr. More... | |
uint32_t | readPresent (uint32_t table, uint32_t index) |
Reads the present flag. More... | |
void | writePresent (uint32_t table, uint32_t index, uint32_t value) |
Marks a page as present or not. More... | |
void | writePDflag (uint32_t table, uint32_t index, uint32_t value) |
Writes the page directory flag contents. More... | |
uint32_t | readPDflag (uint32_t table, uint32_t index) |
Reads the Page Directory flag into a shadow table. More... | |
uint32_t | readPhysical (uint32_t table, uint32_t index) |
FETCH address stored in indirection table, physical version. More... | |
void | writePhysicalNoFlags (uint32_t table, uint32_t index, uint32_t addr) |
TODO. More... | |
uint32_t | getNbIndex (void) |
Get amount of indirection tables. More... | |
void | writeTableVirtual (uint32_t table, uint32_t index, uint32_t addr) |
STORE an address in an indirection table. More... | |
uint32_t | readTableVirtual (uint32_t table, uint32_t index) |
FETCH address stored in indirection table. More... | |
uint32_t | checkRights (uint32_t read, uint32_t write, uint32_t execute) |
Checks whether the asked rights are applicable to the architecture or not. More... | |
uint32_t | extractPreIndex (uint32_t addr, uint32_t index) |
void | writeKernelPhysicalEntry (uintptr_t child_mmu_root_page, uint32_t kernel_index) |
uint32_t | prepareType (int b, uint32_t vaddr) |
Combines a boolean and a virtual address (boolean on the least significant bit) More... | |
vaddr | getVidtVAddr () |
vaddr | getNthVAddrFrom (page base, uint32_t size) |
interruptMask | getInterruptMaskFromCtx (contextAddr targetContext) |
bool | noInterruptRequest (interruptMask flagsOnWake) |
bool | firstVAddrGreaterThanSecond (vaddr vaddr1, vaddr vaddr2) |
contextAddr | vaddrToContextAddr (vaddr contextVAddr) |
bool | checkIndexPropertyLTB (userValue userIndex) |
index | userValueToIndex (userValue userIndex) |
void | writeContext (contextAddr ctx, vaddr ctxSaveVAddr, interruptMask flagsOnWake) |
void | loadContext (contextAddr ctx, bool enforce_interrupts) |
Variables | |
uint32_t | current_partition |
uint32_t | root_partition |
uint32_t | next_pid = 1 |
uint32_t | pcid_enabled |
const uint32_t | nbLevel = 2 |
uint32_t checkRights | ( | uint32_t | read, |
uint32_t | write, | ||
uint32_t | execute | ||
) |
Checks whether the asked rights are applicable to the architecture or not.
Checks whether the asked rights are applicable to the architecture or not.
read | The read right |
write | The write right |
execute | The execute right |
void disable_paging | ( | ) |
disables paging
void enable_paging | ( | ) |
enables paging
uint32_t extractPreIndex | ( | uint32_t | addr, |
uint32_t | index | ||
) |
uint32_t getCurPartition | ( | void | ) |
Interface to get the current Page Directory.
Interface to get the current Page Directory.
uint32_t getIndexOfAddr | ( | uint32_t | addr, |
uint32_t | index | ||
) |
Get index of indirection level given.
Get index of indirection level given.
addr | The virtual address |
index | The indirection level address |
interruptMask getInterruptMaskFromCtx | ( | contextAddr | targetContext | ) |
uint32_t getNbIndex | ( | void | ) |
Get amount of indirection tables.
Get amount of indirection tables.
uint32_t getRootPartition | ( | void | ) |
Interface to get the current Page Directory.
Interface to get the current Page Directory.
uint32_t getTableSize | ( | void | ) |
Table size.
Table size.
vaddr getVidtVAddr | ( | void | ) |
void loadContext | ( | contextAddr | ctx, |
bool | enforce_interrupts | ||
) |
bool noInterruptRequest | ( | interruptMask | flagsOnWake | ) |
uint32_t prepareType | ( | int | b, |
uint32_t | vaddr | ||
) |
Combines a boolean and a virtual address (boolean on the least significant bit)
b | |
vaddr |
uint32_t readAccessible | ( | uint32_t | table, |
uint32_t | index | ||
) |
Reads the accessible flag.
Reads the accessible flag.
table | The table to read from |
index | The index in the given table |
uint32_t readPDflag | ( | uint32_t | table, |
uint32_t | index | ||
) |
Reads the Page Directory flag into a shadow table.
table | The shadow page's last indirection |
index | The index into the shadow table |
uint32_t readPhysical | ( | uint32_t | table, |
uint32_t | index | ||
) |
FETCH address stored in indirection table, physical version.
FETCH address stored in indirection table, physical version.
table | The shadow page's last indirection |
index | The index into the shadow table |
uint32_t readPhysicalNoFlags | ( | uint32_t | table, |
uint32_t | index | ||
) |
Reads the address stored into table table, at index index, using physical addresses. This function masks the least significant bits that are used by the kernel to store various flags (see readVirEntry
and readPhyEntry
in model)
Reads the address stored into table table, at index index, using physical addresses This function masks the least significant bits that are used by the kernel to store various flags (see readVirEntry
and readPhyEntry
in model)
table | The table to read from |
index | The index in the table |
uint32_t readPresent | ( | uint32_t | table, |
uint32_t | index | ||
) |
Reads the present flag.
Reads the present flag.
table | The table to read from |
index | The index in the given table |
uint32_t readTableVirtual | ( | uint32_t | table, |
uint32_t | index | ||
) |
FETCH address stored in indirection table.
FETCH address stored in indirection table.
table | The table to read from |
index | The index in the table |
void updateCurPartition | ( | uint32_t | descriptor | ) |
Set current partition paddr.
partition | Current partition paddr |
void updateRootPartition | ( | uint32_t | partition | ) |
Set root partition paddr.
partition | Root partition paddr |
contextAddr vaddrToContextAddr | ( | vaddr | contextVAddr | ) |
void writeAccessible | ( | uint32_t | table, |
uint32_t | index, | ||
uint32_t | value | ||
) |
Writes the accessible flag.
Writes the accessible flag.
Modify the user bit value.
table | The indirection table |
index | The index into this indirection table |
value | 0 if the page is kernel-only, 1 else (any other value should be forbidden...) |
pd | a page directory |
v | a virtual address |
access | the new value of the user bit |
void writeContext | ( | contextAddr | ctx, |
vaddr | ctxSaveVAddr, | ||
interruptMask | flagsOnWake | ||
) |
void writeKernelPhysicalEntry | ( | uintptr_t | child_mmu_root_page, |
uint32_t | kernel_index | ||
) |
This function is the real world version of the model's "mapKernel". We use the same MMU table page for every partition that is configured at boot time for the root partition. When creating a partition, that page is looked up in the MMU configuration pages of the parent partition and written at the same place.
void writePDflag | ( | uint32_t | table, |
uint32_t | index, | ||
uint32_t | value | ||
) |
Writes the page directory flag contents.
Writes the page directory flag contents.
table | The shadow page's last indirection |
index | The index into the shadow table |
value | The vamue of the PD flag |
void writePhysical | ( | uint32_t | table, |
uint32_t | index, | ||
uint32_t | val | ||
) |
STORE an address in an indirection table, physical version.
STORE an address in an indirection table, physical version.
table | The table to store into |
index | The index in the table |
addr | The address to store |
void writePhysicalNoFlags | ( | uint32_t | table, |
uint32_t | index, | ||
uint32_t | addr | ||
) |
TODO.
table | The shadow page's last indirection |
index | The index into the shadow table |
addr | The index to write |
void writePresent | ( | uint32_t | table, |
uint32_t | index, | ||
uint32_t | value | ||
) |
Marks a page as present or not.
Writes the present flag.
table | The indirection table |
index | The index into this indirection table |
value | 0 if the page is not present, 1 else (any other value should be forbidden...) |
void writeTableVirtual | ( | uint32_t | table, |
uint32_t | index, | ||
uint32_t | addr | ||
) |
STORE an address in an indirection table.
uint32_t current_partition |
const uint32_t nbLevel = 2 |
uint32_t next_pid = 1 |
uint32_t pcid_enabled |
uint32_t root_partition |