aboutsummaryrefslogtreecommitdiff
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
parent7dcea5fdafe66d8bcf1eeacbaf3f3f3b1c258dfc (diff)
downloadrpi-MMU-example-532559dc491d82c41de7f348b3c165d37356be73.tar.gz
rpi-MMU-example-532559dc491d82c41de7f348b3c165d37356be73.zip
use just implemented basic memory section allocation for processes
-rw-r--r--demo_functionality.c28
-rw-r--r--setup.c8
2 files changed, 16 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";
diff --git a/setup.c b/setup.c
index 0fd3522..b7acf60 100644
--- a/setup.c
+++ b/setup.c
@@ -74,6 +74,12 @@ void setup(uint32_t r0, uint32_t machine_type,
puts("Couldn't determine available memory - assuming 192MB");
memory_size = 192 * POWER_OF_2(20);
}
+
+ if (memory_size < UNPRIVILEGED_MEMORY_END)
+ {
+ puts("Not enough memory to continue");
+ while (1);
+ }
// prints some info
demo_paging_support();
@@ -81,6 +87,8 @@ void setup(uint32_t r0, uint32_t machine_type,
// prints some info
demo_current_mode();
+ setup_pager_structures(memory_size);
+
// prints some info and sets upp translation table, turns on MMU
setup_flat_map();