summaryrefslogtreecommitdiffstats
path: root/arch/arm/cpu/mmu_64.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2023-05-10 14:04:47 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2023-05-22 12:38:17 +0200
commit2a16178a537ff6c25989c56a6ae3ddaa97ee6ce6 (patch)
tree10464c75a3ae59fa75150ba5dbf94f66adabded9 /arch/arm/cpu/mmu_64.c
parent29aff371086a39b42adc374a49b6ca1f002ae06e (diff)
downloadbarebox-2a16178a537ff6c25989c56a6ae3ddaa97ee6ce6.tar.gz
barebox-2a16178a537ff6c25989c56a6ae3ddaa97ee6ce6.tar.xz
ARM: mmu64: create alloc_pte()
This is a preparation for using two level page tables in the PBL. To do that we need a way to allocate page tables in PBL. As malloc is not available in PBL, implement a function to allocate a page table from the area we also place the TTB. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/cpu/mmu_64.c')
-rw-r--r--arch/arm/cpu/mmu_64.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/arch/arm/cpu/mmu_64.c b/arch/arm/cpu/mmu_64.c
index 55ada960c5..3cc5b14a46 100644
--- a/arch/arm/cpu/mmu_64.c
+++ b/arch/arm/cpu/mmu_64.c
@@ -32,7 +32,20 @@ static void set_table(uint64_t *pt, uint64_t *table_addr)
*pt = val;
}
-static uint64_t *create_table(void)
+#ifdef __PBL__
+static uint64_t *alloc_pte(void)
+{
+ static unsigned int idx;
+
+ idx++;
+
+ if (idx * GRANULE_SIZE >= ARM_EARLY_PAGETABLE_SIZE)
+ return NULL;
+
+ return (void *)ttb + idx * GRANULE_SIZE;
+}
+#else
+static uint64_t *alloc_pte(void)
{
uint64_t *new_table = xmemalign(GRANULE_SIZE, GRANULE_SIZE);
@@ -41,6 +54,7 @@ static uint64_t *create_table(void)
return new_table;
}
+#endif
static __maybe_unused uint64_t *find_pte(uint64_t addr)
{
@@ -81,7 +95,7 @@ static void split_block(uint64_t *pte, int level)
/* level describes the parent level, we need the child ones */
levelshift = level2shift(level + 1);
- new_table = create_table();
+ new_table = alloc_pte();
for (i = 0; i < MAX_PTE_ENTRIES; i++) {
new_table[i] = old_pte | (i << levelshift);
@@ -183,7 +197,7 @@ void __mmu_init(bool mmu_on)
if (mmu_on)
mmu_disable();
- ttb = create_table();
+ ttb = alloc_pte();
el = current_el();
set_ttbr_tcr_mair(el, (uint64_t)ttb, calc_tcr(el, BITS_PER_VA),
MEMORY_ATTRIBUTES);