Pip
Architecture-dependent parts of Pip: MAL, IAL and boot
Functions | Variables
armv7/MAL/mal.c File Reference
#include <stdint.h>
#include "structures.h"
#include "periph.h"
#include "maldefines.h"
#include "mal.h"
#include "coproc.h"

Functions

void ial_resume_ctx (user_ctx_t *context) __attribute__((noreturn))
 
void enable_paging ()
 enables paging More...
 
void disable_paging ()
 disables paging More...
 
void writePhysical (uint32_t table, uint32_t index, uint32_t val)
 Stores the given address into the given indirection table, at the given index, with physical addresses. 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 ()
 Gets size of indirection table. More...
 
uint32_t getIndexOfAddr (uint32_t addr, uint32_t index)
 Gets the index of this address into the given indirection table level. More...
 
uint32_t readAccessible (uint32_t table, uint32_t index)
 Gets the Accessible flag from the given entry. More...
 
void writeAccessible (uint32_t table, uint32_t index, uint32_t value)
 Marks a page as accessible or not. More...
 
uint32_t getCurPartition (void)
 get the current page directory More...
 
void updateCurPartition (uint32_t descriptor)
 Set current partition paddr. More...
 
uint32_t getRootPartition (void)
 get the root partition More...
 
void updateRootPartition (uint32_t partition)
 Set root partition paddr. More...
 
uint32_t readPresent (uint32_t table, uint32_t index)
 Gets the Present flag from the given entry. More...
 
void writePDflag (uint32_t table, uint32_t index, uint32_t value)
 Writes the Page Directory flag into a shadow table. 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)
 TODO. More...
 
void writePhysicalNoFlags (uint32_t table, uint32_t index, uint32_t addr)
 TODO. More...
 
uint32_t getNbIndex (void)
 Gets the amount of indirection tables. More...
 
uint32_t readTableVirtual (uint32_t table, uint32_t index)
 Reads the address stored into table Table, at index index. More...
 
uint32_t checkRights (uint32_t read, uint32_t write, uint32_t execute)
 Checks whether we can apply the given rights on the target architecture. More...
 
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. More...
 
uint32_t prepareType (int b, uint32_t vaddr)
 Combines a boolean and a virtual address (boolean on the least significant bit) More...
 
vaddr getVidtVAddr (void)
 
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 = 0
 
uint32_t root_partition = 0
 
const uint32_t nbLevel = 2
 

Function Documentation

◆ checkIndexPropertyLTB()

bool checkIndexPropertyLTB ( userValue  userIndex)

◆ checkRights()

uint32_t checkRights ( uint32_t  read,
uint32_t  write,
uint32_t  execute 
)

Checks whether we can apply the given rights on the target architecture.

Checks whether the asked rights are applicable to the architecture or not.

Parameters
readThe read right
writeThe write right
executeThe execute right
Returns
1 if we can, 0 if we can't

◆ disable_paging()

void disable_paging ( )

disables paging

Postcondition
paging mechanism is disabled

◆ enable_paging()

void enable_paging ( )

enables paging

Postcondition
paging mechanism is enabled

◆ firstVAddrGreaterThanSecond()

bool firstVAddrGreaterThanSecond ( vaddr  vaddr1,
vaddr  vaddr2 
)

◆ getCurPartition()

uint32_t getCurPartition ( void  )

get the current page directory

Interface to get the current Page Directory.

Returns
the current page directory

◆ getIndexOfAddr()

uint32_t getIndexOfAddr ( uint32_t  addr,
uint32_t  index 
)

Gets the index of this address into the given indirection table level.

Get index of indirection level given.

Parameters
addrThe virtual address
indexThe indirection level address
Returns
The desired index

◆ getInterruptMaskFromCtx()

interruptMask getInterruptMaskFromCtx ( contextAddr  targetContext)

◆ getNbIndex()

uint32_t getNbIndex ( void  )

Gets the amount of indirection tables.

Get amount of indirection tables.

Returns
Amount of maximal indirection tables

◆ getNthVAddrFrom()

vaddr getNthVAddrFrom ( page  base,
uint32_t  size 
)

◆ getRootPartition()

uint32_t getRootPartition ( void  )

get the root partition

Interface to get the current Page Directory.

Returns
the root partition

◆ getTableSize()

uint32_t getTableSize ( void  )

Gets size of indirection table.

Table size.

Returns
The amount of entries in a page table

◆ getVidtVAddr()

vaddr getVidtVAddr ( void  )

◆ ial_resume_ctx()

void ial_resume_ctx ( user_ctx_t context)

◆ loadContext()

void loadContext ( contextAddr  ctx,
bool  enforce_interrupts 
)

◆ noInterruptRequest()

bool noInterruptRequest ( interruptMask  flagsOnWake)

◆ prepareType()

uint32_t prepareType ( int  b,
uint32_t  vaddr 
)

Combines a boolean and a virtual address (boolean on the least significant bit)

Parameters
b
vaddr

◆ readAccessible()

uint32_t readAccessible ( uint32_t  table,
uint32_t  index 
)

Gets the Accessible flag from the given entry.

Reads the accessible flag.

Parameters
tableThe table to read from
indexThe index in the given table
Returns
1 if the page is user-mode accessible, 0 else

◆ readPDflag()

uint32_t readPDflag ( uint32_t  table,
uint32_t  index 
)

Reads the Page Directory flag into a shadow table.

Parameters
tableThe shadow page's last indirection
indexThe index into the shadow table
Returns
The value of the PD flag

◆ readPhysical()

uint32_t readPhysical ( uint32_t  table,
uint32_t  index 
)

TODO.

FETCH address stored in indirection table, physical version.

Parameters
tableThe shadow page's last indirection
indexThe index into the shadow table
Returns
The value of the PD flag

◆ readPhysicalNoFlags()

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)

Parameters
tableThe table to read from
indexThe index in the table
Returns
The address stored in the given slot, with its least significant bits cleared

◆ readPresent()

uint32_t readPresent ( uint32_t  table,
uint32_t  index 
)

Gets the Present flag from the given entry.

Reads the present flag.

Parameters
tableThe table to read from
indexThe index in the given table
Returns
1 if the page is present, 0 else

◆ readTableVirtual()

uint32_t readTableVirtual ( uint32_t  table,
uint32_t  index 
)

Reads the address stored into table Table, at index index.

FETCH address stored in indirection table.

Parameters
tableThe table to read from
indexThe index in the table
Returns
The address stored in the given slot

◆ updateCurPartition()

void updateCurPartition ( uint32_t  descriptor)

Set current partition paddr.

Parameters
partitionCurrent partition paddr

◆ updateRootPartition()

void updateRootPartition ( uint32_t  partition)

Set root partition paddr.

Parameters
partitionRoot partition paddr

◆ userValueToIndex()

index userValueToIndex ( userValue  userIndex)

◆ vaddrToContextAddr()

contextAddr vaddrToContextAddr ( vaddr  contextVAddr)

◆ writeAccessible()

void writeAccessible ( uint32_t  pd,
uint32_t  v,
uint32_t  access 
)

Marks a page as accessible or not.

Writes the accessible flag.

Modify the user bit value.

Parameters
tableThe indirection table
indexThe index into this indirection table
value0 if the page is kernel-only, 1 else (any other value should be forbidden...)
pda page directory
va virtual address
accessthe new value of the user bit
Postcondition
The accessible bit of the virtual address is equal to access

◆ writeContext()

void writeContext ( contextAddr  ctx,
vaddr  ctxSaveVAddr,
interruptMask  flagsOnWake 
)

◆ writeKernelPhysicalEntry()

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.

◆ writePDflag()

void writePDflag ( uint32_t  table,
uint32_t  index,
uint32_t  value 
)

Writes the Page Directory flag into a shadow table.

Writes the page directory flag contents.

Parameters
tableThe shadow page's last indirection
indexThe index into the shadow table
valueThe vamue of the PD flag

◆ writePhysical()

void writePhysical ( uint32_t  table,
uint32_t  index,
uint32_t  addr 
)

Stores the given address into the given indirection table, at the given index, with physical addresses.

STORE an address in an indirection table, physical version.

Parameters
tableThe table to store into
indexThe index in the table
addrThe address to store

◆ writePhysicalNoFlags()

void writePhysicalNoFlags ( uint32_t  table,
uint32_t  index,
uint32_t  addr 
)

TODO.

Parameters
tableThe shadow page's last indirection
indexThe index into the shadow table
addrThe index to write
Returns
The value of the PD flag

Variable Documentation

◆ current_partition

uint32_t current_partition = 0

◆ nbLevel

const uint32_t nbLevel = 2

◆ root_partition

uint32_t root_partition = 0