diff options
author | Wojtek Kosior <kwojtus@protonmail.com> | 2019-12-02 15:42:49 +0100 |
---|---|---|
committer | Wojtek Kosior <kwojtus@protonmail.com> | 2019-12-02 15:42:49 +0100 |
commit | 4b530611e8cd1a342a7e4461ac002cf715da26b3 (patch) | |
tree | 91cda94fd8e035981591cd7023a6289044f36f6f | |
parent | 0fa2fca6029d4d4c826efd10441946224822c354 (diff) | |
download | rpi-MMU-example-4b530611e8cd1a342a7e4461ac002cf715da26b3.tar.gz rpi-MMU-example-4b530611e8cd1a342a7e4461ac002cf715da26b3.zip |
read and write entire volatile struct at once, not it's single fields
-rw-r--r-- | demo_functionality.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/demo_functionality.c b/demo_functionality.c index 7bba6a6..eddb1d2 100644 --- a/demo_functionality.c +++ b/demo_functionality.c @@ -65,25 +65,31 @@ void demo_go_unprivileged(void) short_section_descriptor_t *translation_table = (short_section_descriptor_t*) TRANSLATION_TABLE_BASE; - volatile short_section_descriptor_t *PL0_section = + short_section_descriptor_t volatile *PL0_section_entry = &translation_table[PL0_SECTION_NUMBER]; - volatile short_section_descriptor_t *UART_memory_section = + short_section_descriptor_t volatile *UART_memory_section_entry = &translation_table[((uint32_t) GPIO_BASE) >> 20]; - PL0_section->SECTION_BASE_ADDRESS_31_20 = + short_section_descriptor_t + PL0_section = *PL0_section_entry, + UART_memory_section = *UART_memory_section_entry; + + PL0_section.SECTION_BASE_ADDRESS_31_20 = UNPRIVILEGED_MEMORY_START >> 20; // make the selected section and uart section available for PL0 - PL0_section->ACCESS_PERMISSIONS_2 = + PL0_section.ACCESS_PERMISSIONS_2 = AP_2_0_MODEL_RW_ALL >> 2; - PL0_section->ACCESS_PERMISSIONS_1_0 = + PL0_section.ACCESS_PERMISSIONS_1_0 = AP_2_0_MODEL_RW_ALL & 0b011; - UART_memory_section->ACCESS_PERMISSIONS_2 = + UART_memory_section.ACCESS_PERMISSIONS_2 = AP_2_0_MODEL_RW_ALL >> 2; - UART_memory_section->ACCESS_PERMISSIONS_1_0 = + UART_memory_section.ACCESS_PERMISSIONS_1_0 = AP_2_0_MODEL_RW_ALL & 0b011; - + + *PL0_section_entry = PL0_section; + *UART_memory_section_entry = UART_memory_section; // invalidate main Translation Lookup Buffer (just in case) asm("mcr p15, 0, %0, c8, c7, 0\n\r" |