From d2bd31b4a05cf4fc36ed6c8eaafa61e41b28b9d1 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Tue, 31 Dec 2019 17:17:03 +0100 Subject: print information about mapping created for PL0 code --- demo_functionality.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'demo_functionality.c') 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 -- cgit v1.2.3