Pip
Architecture-dependent parts of Pip: MAL, IAL and boot
|
Memory Abstraction Layer common interface. More...
#include <stdint.h>
#include "maldefines.h"
Go to the source code of this file.
Macros | |
#define | nbPage maxPages |
Functions | |
void | enable_paging () |
enables paging More... | |
void | disable_paging () |
disables paging 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 descriptor) |
Set root partition paddr. More... | |
uint32_t | getNbIndex () |
Get amount of indirection tables. More... | |
uint32_t | getIndexOfAddr (uint32_t addr, uint32_t index) |
Get index of indirection level given. More... | |
uint32_t | getOffsetOfAddr (uint32_t addr) |
Get offset from address. More... | |
uint32_t | readTableVirtual (uint32_t table, uint32_t index) |
FETCH address stored in indirection table. More... | |
uint32_t | readTableVirtualNoFlags (uint32_t table, uint32_t index) |
FETCH address stored in indirection table. More... | |
uint32_t | readArray (uint32_t table, uint32_t index) |
Read an array's contents. More... | |
void | writeTableVirtual (uint32_t table, uint32_t index, uint32_t addr) |
STORE an address in an indirection table. More... | |
void | writeTableVirtualNoFlags (uint32_t table, uint32_t index, uint32_t addr) |
STORE an address in an indirection table. 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) |
Writes the present flag. 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 | readPhysical (uint32_t table, uint32_t index) |
FETCH address stored in 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... | |
void | writePhysical (uint32_t table, uint32_t index, uint32_t addr) |
STORE an address in an indirection table, physical version. More... | |
void | writePhysicalNoFlags (uint32_t table, uint32_t index, uint32_t addr) |
TODO. More... | |
uint32_t | readIndex (uint32_t table, uint32_t index) |
FETCH index stored in indirection table, physical version. More... | |
void | writeIndex (uint32_t table, uint32_t index, uint32_t idx) |
STORE an index in an indirection table, physical version. More... | |
uint32_t | dereferenceVirtual (uint32_t addr) |
uint32_t | derivated (uint32_t table, uint32_t index) |
Returns 1 if the page is derivated, 0 else. More... | |
uint32_t | readPDflag (uint32_t table, uint32_t index) |
Reads the Page Directory flag into a shadow table. More... | |
void | writePDflag (uint32_t table, uint32_t index, uint32_t value) |
Writes the page directory flag contents. More... | |
uint32_t | get_pd () |
Returns the VIRTUAL ADDRESS of the current Page Directory. More... | |
void | cleanPageEntry (uint32_t table, uint32_t index) |
Cleans a page entry, setting its contents to 0x00000000. More... | |
uint32_t | defaultAddr (void) |
Default address, should be 0x00000000. More... | |
uint32_t | getTableSize (void) |
Table size. More... | |
uint32_t | getMaxIndex (void) |
Table size. More... | |
uint32_t | addressEquals (uint32_t addr, uint32_t addr2) |
Checks whether an address is equal to another. More... | |
void | cleanPage (uint32_t paddr) |
Cleans a given page, filling it with zero. 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 | applyRights (uint32_t table, uint32_t index, uint32_t read, uint32_t write, uint32_t execute) |
Apply the asked rights to the given entry. More... | |
uint32_t | toAddr (uint32_t input) |
Converts a given uint32_t to an address (only for Haskell FFI purposes) More... | |
int | geb (const uint32_t a, const uint32_t b) |
Greater or equal. More... | |
int | gtb (const uint32_t a, const uint32_t b) |
Greater than. More... | |
int | leb (const uint32_t a, const uint32_t b) |
Lower or equal. More... | |
int | ltb (const uint32_t a, const uint32_t b) |
Lower than. More... | |
int | eqb (const uint32_t a, const uint32_t b) |
Equals. More... | |
uint32_t | mul3 (uint32_t v) |
Multiply an integer with 3. More... | |
uint32_t | inc (uint32_t val) |
Increment an integer. More... | |
uint32_t | sub (uint32_t val) |
Decrement an integer. More... | |
uint32_t | zero () |
Zero. That's it. More... | |
uint32_t | indexPR (void) |
Partiton descriptor index into itself. More... | |
uint32_t | indexPD (void) |
Page directory index within partition descriptor. More... | |
uint32_t | indexSh1 (void) |
Shadow 1 index within partition descriptor. More... | |
uint32_t | indexSh2 (void) |
Shadow 2 index within partition descriptor. More... | |
uint32_t | indexSh3 (void) |
Configuration tables linked list index within partition descriptor. More... | |
uint32_t | PPRidx (void) |
Parent partition index within partition descriptor. More... | |
uint32_t | kernelIndex (void) |
Index of kernel's page directory entry. More... | |
void | writePhysicalWithLotsOfFlags (uint32_t table, uint32_t index, uint32_t addr, uint32_t present, uint32_t user, uint32_t read, uint32_t write, uint32_t execute) |
Write a physical entry with all the possible flags we might need. More... | |
void | writeKernelPhysicalEntry (uint32_t mmu_root_page, uint32_t kernel_index) |
Writes the kernel MMU configuration page at index 'kernel_index' in the MMU root page. More... | |
uint32_t | extractPreIndex (uint32_t vaddr, uint32_t index) |
uint32_t | prepareType (int b, uint32_t vaddr) |
Combines a boolean and a virtual address (boolean on the least significant bit) More... | |
void | updateMMURoot (page MMURoot) |
updates the virtual address space root page More... | |
interruptMask | getInterruptMaskFromCtx (contextAddr context) |
bool | noInterruptRequest (interruptMask flagsOnWake) |
bool | firstVAddrGreaterThanSecond (vaddr vaddr1, vaddr vaddr2) |
contextAddr | vaddrToContextAddr (vaddr contextVAddr) |
bool | checkIndexPropertyLTB (userValue userIndex) |
index | userValueToIndex (userValue userIndex) |
vaddr | getVidtVAddr () |
vaddr | getNthVAddrFrom (page base, uint32_t size) |
void | writeContext (contextAddr ctx, vaddr ctxSaveVAddr, interruptMask flagsOnWake) |
void | loadContext (contextAddr ctx, bool enforce_interrupts) |
Variables | |
const uint32_t | defaultVAddr |
Default address, should be 0x00000000. More... | |
const uint32_t | nbLevel |
uint32_t | maxPages |
The maximal amount of pages available. More... | |
Memory Abstraction Layer common interface.
#define nbPage maxPages |
uint32_t addressEquals | ( | uint32_t | addr, |
uint32_t | addr2 | ||
) |
Checks whether an address is equal to another.
Checks whether an address is equal to another.
addr | Address to check |
addr2 | Address to compare to |
uint32_t applyRights | ( | uint32_t | table, |
uint32_t | index, | ||
uint32_t | read, | ||
uint32_t | write, | ||
uint32_t | execute | ||
) |
Apply the asked rights to the given entry.
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 cleanPage | ( | uint32_t | paddr | ) |
Cleans a given page, filling it with zero.
Cleans a given page, filling it with zero.
paddr | The page's physical address |
void cleanPageEntry | ( | uint32_t | table, |
uint32_t | index | ||
) |
Cleans a page entry, setting its contents to 0x00000000.
uint32_t defaultAddr | ( | void | ) |
Default address, should be 0x00000000.
Default address, should be 0x00000000.
uint32_t dereferenceVirtual | ( | uint32_t | addr | ) |
addr | The virtual address to dereference |
uint32_t derivated | ( | uint32_t | table, |
uint32_t | index | ||
) |
Returns 1 if the page is derivated, 0 else.
void disable_paging | ( | ) |
disables paging
void enable_paging | ( | ) |
enables paging
int eqb | ( | const uint32_t | a, |
const uint32_t | b | ||
) |
Equals.
Equals.
uint32_t extractPreIndex | ( | uint32_t | vaddr, |
uint32_t | index | ||
) |
int geb | ( | const uint32_t | a, |
const uint32_t | b | ||
) |
Greater or equal.
Greater or equal.
uint32_t get_pd | ( | ) |
Returns the VIRTUAL ADDRESS of the current Page Directory.
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 | context | ) |
uint32_t getMaxIndex | ( | void | ) |
Table size.
Table size.
uint32_t getNbIndex | ( | void | ) |
Get amount of indirection tables.
Get amount of indirection tables.
uint32_t getOffsetOfAddr | ( | uint32_t | addr | ) |
Get offset from address.
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 | ( | ) |
int gtb | ( | const uint32_t | a, |
const uint32_t | b | ||
) |
Greater than.
Greater than.
uint32_t inc | ( | uint32_t | val | ) |
Increment an integer.
Increment an integer.
uint32_t indexPD | ( | void | ) |
Page directory index within partition descriptor.
Page directory index within partition descriptor.
uint32_t indexPR | ( | void | ) |
Partiton descriptor index into itself.
Partiton descriptor index into itself.
uint32_t indexSh1 | ( | void | ) |
Shadow 1 index within partition descriptor.
Shadow 1 index within partition descriptor.
uint32_t indexSh2 | ( | void | ) |
Shadow 2 index within partition descriptor.
Shadow 2 index within partition descriptor.
uint32_t indexSh3 | ( | void | ) |
Configuration tables linked list index within partition descriptor.
Configuration tables linked list index within partition descriptor.
uint32_t kernelIndex | ( | void | ) |
Index of kernel's page directory entry.
Index of kernel's page directory entry.
int leb | ( | const uint32_t | a, |
const uint32_t | b | ||
) |
Lower or equal.
Lower or equal.
void loadContext | ( | contextAddr | ctx, |
bool | enforce_interrupts | ||
) |
int ltb | ( | const uint32_t | a, |
const uint32_t | b | ||
) |
Lower than.
Lower than.
uint32_t mul3 | ( | uint32_t | v | ) |
Multiply an integer with 3.
Multiply an integer with 3.
bool noInterruptRequest | ( | interruptMask | flagsOnWake | ) |
uint32_t PPRidx | ( | void | ) |
Parent partition index within partition descriptor.
Parent partition index within partition descriptor.
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 readArray | ( | uint32_t | table, |
uint32_t | index | ||
) |
Read an array's contents.
uint32_t readIndex | ( | uint32_t | table, |
uint32_t | index | ||
) |
FETCH index stored in indirection table, physical version.
FETCH index stored in indirection table, physical version.
table | The table to read from |
index | The index in the 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 |
uint32_t readTableVirtualNoFlags | ( | uint32_t | table, |
uint32_t | index | ||
) |
FETCH address stored in indirection table.
uint32_t sub | ( | uint32_t | val | ) |
Decrement an integer.
Decrement an integer.
uint32_t toAddr | ( | uint32_t | input | ) |
Converts a given uint32_t to an address (only for Haskell FFI purposes)
Converts a given uint32_t to an address (only for Haskell FFI purposes)
input | The given integer |
void updateCurPartition | ( | uint32_t | descriptor | ) |
Set current partition paddr.
partition | Current partition paddr |
void updateMMURoot | ( | page | MMURoot | ) |
updates the virtual address space root page
dir | a page directory |
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 writeIndex | ( | uint32_t | table, |
uint32_t | index, | ||
uint32_t | idx | ||
) |
STORE an index in an indirection table, physical version.
STORE an index in an indirection table, physical version.
table | The table to store into |
index | The index in the table |
addr | The index to store |
void writeKernelPhysicalEntry | ( | uint32_t | child_mmu_root_page, |
uint32_t | kernel_index | ||
) |
Writes the kernel MMU configuration page at index 'kernel_index' in the MMU root page.
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 writePhysicalWithLotsOfFlags | ( | uint32_t | table, |
uint32_t | index, | ||
uint32_t | addr, | ||
uint32_t | present, | ||
uint32_t | user, | ||
uint32_t | read, | ||
uint32_t | write, | ||
uint32_t | execute | ||
) |
Write a physical entry with all the possible flags we might need.
Write a physical entry with all the possible flags we might need.
table | The indirection table in which we find the entry |
index | The index in this table, targeting the specified entry |
addr | The target address |
present | 1 if the page is mapped, 0 else |
user | 1 if the page is accessible in userland, 0 else |
read | The read right |
write | The write right |
execute | The execute right |
void writePresent | ( | uint32_t | table, |
uint32_t | index, | ||
uint32_t | value | ||
) |
Writes the present flag.
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.
void writeTableVirtualNoFlags | ( | uint32_t | table, |
uint32_t | index, | ||
uint32_t | addr | ||
) |
STORE an address in an indirection table.
uint32_t zero | ( | void | ) |
Zero. That's it.
Zero. That's it.
const uint32_t defaultVAddr |
Default address, should be 0x00000000.
uint32_t maxPages |
The maximal amount of pages available.
const uint32_t nbLevel |