aboutsummaryrefslogtreecommitdiff
path: root/demo_functionality.c
diff options
context:
space:
mode:
authorWojtek Kosior <kwojtus@protonmail.com>2019-12-31 13:50:55 +0100
committerWojtek Kosior <kwojtus@protonmail.com>2019-12-31 13:50:55 +0100
commit532559dc491d82c41de7f348b3c165d37356be73 (patch)
tree6ea8977830d1f5c3884e7a3a8161860ccae0f226 /demo_functionality.c
parent7dcea5fdafe66d8bcf1eeacbaf3f3f3b1c258dfc (diff)
downloadrpi-MMU-example-532559dc491d82c41de7f348b3c165d37356be73.tar.gz
rpi-MMU-example-532559dc491d82c41de7f348b3c165d37356be73.zip
use just implemented basic memory section allocation for processes
Diffstat (limited to 'demo_functionality.c')
-rw-r--r--demo_functionality.c28
1 files changed, 8 insertions, 20 deletions
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";