aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojtek Kosior <kwojtus@protonmail.com>2019-12-31 17:17:03 +0100
committerWojtek Kosior <kwojtus@protonmail.com>2019-12-31 17:17:03 +0100
commitd2bd31b4a05cf4fc36ed6c8eaafa61e41b28b9d1 (patch)
tree0fba1eeae6f415018676c1b05f80724d89eba4e9
parent532559dc491d82c41de7f348b3c165d37356be73 (diff)
downloadrpi-MMU-example-d2bd31b4a05cf4fc36ed6c8eaafa61e41b28b9d1.tar.gz
rpi-MMU-example-d2bd31b4a05cf4fc36ed6c8eaafa61e41b28b9d1.zip
print information about mapping created for PL0 code
-rw-r--r--demo_functionality.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/demo_functionality.c b/demo_functionality.c
index 23a844e..366edd7 100644
--- a/demo_functionality.c
+++ b/demo_functionality.c
@@ -76,19 +76,34 @@ void demo_setup_PL0(void)
}
// 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)
+ uint16_t physical_section_number = claim_and_map_section
+ ((void*) 5, PL0_SECTION_NUMBER, AP_2_0_MODEL_RW_ALL);
+
+ if (physical_section_number == CLAIM_FAILURE)
{
puts("Couldn't claim memory section for unprivileged code :(");
while(1);
}
-
+
+ size_t physical_section_start =
+ (((size_t) physical_section_number) << 20);
+
// check that translation works... by copying a string using one
// mapping and reading it using other :D
- char message[] = "mapped sections for PL0 code";
+ char str_part1[] = "mapped section for PL0 code (0x";
+ char str_part2[] = " -> 0x";
+ char str_part3[] = ")";
+
+ char *string_end = (char*) physical_section_start;
+
+ memcpy(string_end, str_part1, sizeof(str_part1) - 1);
+ uint32_to_hex(VIRTUAL_PL0_MEMORY_START,
+ string_end += sizeof(str_part1) - 1);
+ memcpy(string_end += 8, str_part2, sizeof(str_part2) - 1);
+ uint32_to_hex(physical_section_start,
+ string_end += sizeof(str_part2) - 1);
+ memcpy(string_end += 8, str_part3, sizeof(str_part3));
- memcpy((void*) UNPRIVILEGED_MEMORY_START, message, sizeof(message));
-
puts((char*) VIRTUAL_PL0_MEMORY_START);
// now paste a userspace program to that section