From 532559dc491d82c41de7f348b3c165d37356be73 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Tue, 31 Dec 2019 13:50:55 +0100 Subject: use just implemented basic memory section allocation for processes --- demo_functionality.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'demo_functionality.c') diff --git a/demo_functionality.c b/demo_functionality.c index 7a9139c..23a844e 100644 --- a/demo_functionality.c +++ b/demo_functionality.c @@ -4,6 +4,7 @@ #include "translation_table_descriptors.h" #include "ramfs.h" #include "strings.h" +#include "paging.h" void demo_paging_support(void) { @@ -74,27 +75,14 @@ void demo_setup_PL0(void) asm volatile ("wfi"); } - short_section_descriptor_t volatile *PL0_section_entry = - &TRANSLATION_TABLE[PL0_SECTION_NUMBER]; - - short_section_descriptor_t PL0_section = *PL0_section_entry; - - // set up address of PL0 section - PL0_section.SECTION_BASE_ADDRESS_31_20 = - UNPRIVILEGED_MEMORY_START >> 20; - - // make the selected section available for PL0 - PL0_section.ACCESS_PERMISSIONS_2 = - AP_2_0_MODEL_RW_ALL >> 2; - PL0_section.ACCESS_PERMISSIONS_1_0 = - AP_2_0_MODEL_RW_ALL & 0b011; - - *PL0_section_entry = PL0_section; + // dummy value 5 for now, as we haven't implemented processes yet + if (claim_and_map_section((void*) 5, PL0_SECTION_NUMBER, + AP_2_0_MODEL_RW_ALL) == CLAIM_FAILURE) + { + puts("Couldn't claim memory section for unprivileged code :("); + while(1); + } - // invalidate main Translation Lookup Buffer (just in case) - asm("mcr p15, 0, %0, c8, c7, 0\n\r" - "isb" :: "r" (0) : "memory"); - // check that translation works... by copying a string using one // mapping and reading it using other :D char message[] = "mapped sections for PL0 code"; -- cgit v1.2.3