coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
mmu.c File Reference
#include <assert.h>
#include <stdint.h>
#include <string.h>
#include <symbols.h>
#include <console/console.h>
#include <arch/mmu.h>
#include <arch/lib_helpers.h>
#include <arch/cache.h>
Include dependency graph for mmu.c:

Go to the source code of this file.

Functions

static void print_tag (int level, uint64_t tag)
 
static uint64_t get_block_attr (unsigned long tag)
 
static uint64_tsetup_new_table (uint64_t desc, size_t xlat_size)
 
static uint64_tget_next_level_table (uint64_t *ptr, size_t xlat_size)
 
static uint64_t init_xlat_table (uint64_t base_addr, uint64_t size, uint64_t tag)
 
static void sanity_check (uint64_t addr, uint64_t size)
 
static uint64_t get_pte (void *addr)
 
static void assert_correct_ttb_mapping (void *addr)
 
void mmu_config_range (void *start, size_t size, uint64_t tag)
 
void mmu_init (void)
 
void mmu_save_context (struct mmu_context *mmu_context)
 
void mmu_restore_context (const struct mmu_context *mmu_context)
 
void mmu_enable (void)
 

Variables

static uint64_tnext_free_table = (void *)_ttb
 

Function Documentation

◆ assert_correct_ttb_mapping()

static void assert_correct_ttb_mapping ( void addr)
static

Definition at line 197 of file mmu.c.

References addr, assert, BLOCK_INDEX_MASK, BLOCK_INDEX_MEM_NORMAL, BLOCK_INDEX_SHIFT, BLOCK_NS, and get_pte().

Referenced by mmu_enable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_block_attr()

static uint64_t get_block_attr ( unsigned long  tag)
static

◆ get_next_level_table()

static uint64_t* get_next_level_table ( uint64_t ptr,
size_t  xlat_size 
)
static

Definition at line 93 of file mmu.c.

References DESC_MASK, setup_new_table(), TABLE_DESC, and XLAT_ADDR_MASK.

Referenced by init_xlat_table().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_pte()

static uint64_t get_pte ( void addr)
static

Definition at line 176 of file mmu.c.

References addr, BITS_RESOLVED_PER_LVL, DESC_MASK, GRANULE_SIZE_SHIFT, L0_ADDR_SHIFT, TABLE_DESC, and XLAT_ADDR_MASK.

Referenced by assert_correct_ttb_mapping().

Here is the caller graph for this function:

◆ init_xlat_table()

static uint64_t init_xlat_table ( uint64_t  base_addr,
uint64_t  size,
uint64_t  tag 
)
static

Definition at line 112 of file mmu.c.

References BLOCK_DESC, get_block_attr(), get_next_level_table(), IS_ALIGNED, L0_ADDR_MASK, L0_ADDR_SHIFT, L1_ADDR_MASK, L1_ADDR_SHIFT, L1_XLAT_SIZE, L2_ADDR_MASK, L2_ADDR_SHIFT, L2_XLAT_SIZE, L3_ADDR_MASK, L3_ADDR_SHIFT, L3_XLAT_SIZE, and PAGE_DESC.

Referenced by mmu_config_range().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mmu_config_range()

void mmu_config_range ( void start,
size_t  size,
uint64_t  tag 
)

Definition at line 210 of file mmu.c.

References BIOS_INFO, dsb, init_xlat_table(), isb, print_tag(), printk, sanity_check(), and tlbiall_el3().

Here is the call graph for this function:

◆ mmu_enable()

void mmu_enable ( void  )

Definition at line 293 of file mmu.c.

References assert_correct_ttb_mapping(), isb, SCTLR_C, SCTLR_I, and SCTLR_M.

Referenced by bootblock_mainboard_init(), decompressor_soc_init(), mtk_mmu_disable_l2c_sram(), mtk_mmu_init(), qclib_load_and_run(), qcs405_mmu_init(), sc7180_mmu_init(), sc7280_mmu_init(), soc_mmu_init(), and tegra210_mmu_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mmu_init()

void mmu_init ( void  )

◆ mmu_restore_context()

void mmu_restore_context ( const struct mmu_context mmu_context)

Definition at line 276 of file mmu.c.

References assert, mmu_context::mair, mmu_context::tcr, and tlb_invalidate_all().

Referenced by qclib_load_and_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mmu_save_context()

void mmu_save_context ( struct mmu_context mmu_context)

Definition at line 262 of file mmu.c.

References assert, mmu_context::mair, and mmu_context::tcr.

Referenced by qclib_load_and_run().

Here is the caller graph for this function:

◆ print_tag()

static void print_tag ( int  level,
uint64_t  tag 
)
static

Definition at line 18 of file mmu.c.

References MA_MEM, MA_MEM_NC, MA_NS, MA_RO, and printk.

Referenced by mmu_config_range().

Here is the caller graph for this function:

◆ sanity_check()

static void sanity_check ( uint64_t  addr,
uint64_t  size 
)
static

Definition at line 166 of file mmu.c.

References addr, assert, BITS_PER_VA, GRANULE_SIZE, and GRANULE_SIZE_MASK.

Referenced by mmu_config_range().

Here is the caller graph for this function:

◆ setup_new_table()

static uint64_t* setup_new_table ( uint64_t  desc,
size_t  xlat_size 
)
static

Definition at line 59 of file mmu.c.

References BIOS_DEBUG, BITS_RESOLVED_PER_LVL, die(), GRANULE_SIZE, L3_XLAT_SIZE, memset(), next_free_table, PAGE_DESC, printk, UNUSED_DESC, and XLAT_ADDR_MASK.

Referenced by get_next_level_table(), and mmu_init().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ next_free_table

uint64_t* next_free_table = (void *)_ttb
static

Definition at line 16 of file mmu.c.

Referenced by setup_new_table().