Pip
Architecture-dependent parts of Pip: MAL, IAL and boot
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Functions
x86_multiboot/MAL/boot_requirements.c File Reference
#include <stdint.h>
#include "structures.h"
#include "mal.h"
#include "debug.h"
#include "libc.h"

Functions

void updateMMURoot (uintptr_t dir)
 updates the virtual address space root page More...
 
uint32_t getOffsetOfAddr (uintptr_t addr)
 Gets the offset from an address. More...
 
uintptr_t readArray (uintptr_t array, uint32_t index)
 
uintptr_t readTableVirtualNoFlags (uintptr_t table, uint32_t index)
 
void writeTableVirtualNoFlags (uintptr_t table, uint32_t index, uintptr_t addr)
 
uint32_t derivated (uintptr_t table, uint32_t index)
 Returns 1 if the page is derivated. More...
 
void cleanPageEntry (uintptr_t table, uint32_t index)
 Cleans a page entry. More...
 
uint32_t readIndex (uintptr_t table, uint32_t index)
 Reads the index stored into table Table, at index index, using physical addresses. More...
 
void writeIndex (uintptr_t table, uint32_t index, uint32_t addr)
 Stores the given address into the given indirection table, at the given index, with physical addresses. More...
 
uintptr_t toAddr (uint32_t input)
 Converts a given uint32_t to an address (only for Haskell FFI purposes) More...
 
void cleanPage (uintptr_t paddr)
 Cleans a given page, filling it with zeroes. More...
 
uint32_t applyRights (uintptr_t table, uint32_t index, uint32_t read, uint32_t write, uint32_t execute)
 Applies the given rights on the given entry. More...
 
void writePhysicalWithLotsOfFlags (uintptr_t table, uint32_t index, uintptr_t addr, uint32_t present, uint32_t user, uint32_t read, uint32_t write, uint32_t execute)
 Applies the given rights on the given entry. More...
 
uint32_t dereferenceVirtual (uintptr_t addr)
 

Function Documentation

◆ applyRights()

uint32_t applyRights ( uintptr_t  table,
uint32_t  index,
uint32_t  read,
uint32_t  write,
uint32_t  execute 
)

Applies the given rights on the given entry.

Parameters
tableThe indirection table in which we find the entry
indexThe index in this table, targeting the specified entry
readThe read right
writeThe write right
executeThe execute right
Returns
1 if the rights were applied, 0 otherwise

◆ cleanPage()

void cleanPage ( uintptr_t  paddr)

Cleans a given page, filling it with zeroes.

Parameters
paddrThe page's physical address

◆ cleanPageEntry()

void cleanPageEntry ( uintptr_t  table,
uint32_t  index 
)

Cleans a page entry.

Parameters
tableThe table in which to find the entry
indexThe index of the entry

◆ dereferenceVirtual()

uint32_t dereferenceVirtual ( uintptr_t  addr)
Parameters
addrThe virtual address to dereference
Returns
The contents of the pointer
Warning
I don't think this is still used. Anyway, it should never be. Never. Removing this soon.

◆ derivated()

uint32_t derivated ( uintptr_t  table,
uint32_t  index 
)

Returns 1 if the page is derivated.

Parameters
tableThe shadow table's last indirection
indexThe index into this shadow table
Returns
1 if derivated, 0 else

◆ getOffsetOfAddr()

uint32_t getOffsetOfAddr ( uintptr_t  addr)

Gets the offset from an address.

Parameters
addrThe address
Returns
The offset calculated from this address

◆ readArray()

uintptr_t readArray ( uintptr_t  array,
uint32_t  index 
)

◆ readIndex()

uintptr_t readIndex ( uintptr_t  table,
uint32_t  index 
)

Reads the index stored into table Table, at index index, using physical addresses.

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

◆ readTableVirtualNoFlags()

uintptr_t readTableVirtualNoFlags ( uintptr_t  table,
uint32_t  index 
)

◆ toAddr()

uintptr_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)

Parameters
inputThe given integer
Returns
The same integer as an address
Note
This is only for Haskell. C doesn't need this!

◆ updateMMURoot()

void updateMMURoot ( uintptr_t  dir)

updates the virtual address space root page

Parameters
dira page directory
Postcondition
dir is the current virtual space

◆ writeIndex()

void writeIndex ( uintptr_t  table,
uint32_t  index,
uint32_t  idx 
)

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

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

◆ writePhysicalWithLotsOfFlags()

void writePhysicalWithLotsOfFlags ( uintptr_t  table,
uint32_t  index,
uintptr_t  addr,
uint32_t  present,
uint32_t  user,
uint32_t  read,
uint32_t  write,
uint32_t  execute 
)

Applies the given rights on the given entry.

Parameters
tableThe indirection table in which we find the entry
indexThe index in this table, targeting the specified entry
addrThe target address
present1 if the page is mapped, 0 else
user1 if the page is accessible in userland, 0 else
readThe read right
writeThe write right
executeThe execute right

◆ writeTableVirtualNoFlags()

void writeTableVirtualNoFlags ( uintptr_t  table,
uint32_t  index,
uintptr_t  addr 
)