From ffb2c4adfb8e65e355b39abd39d994eebc649c98 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Fri, 3 Jan 2020 04:53:01 +0100 Subject: add (not yet fully working - it can only send through uart now) interrupt-driven uart together with "scheduler" --- demo_functionality.c | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) (limited to 'demo_functionality.c') diff --git a/demo_functionality.c b/demo_functionality.c index 1ef91a1..217a858 100644 --- a/demo_functionality.c +++ b/demo_functionality.c @@ -6,6 +6,7 @@ #include "strings.h" #include "paging.h" #include "armclock.h" +#include "scheduler.h" void demo_paging_support(void) { @@ -64,7 +65,7 @@ extern char _binary_ramfs_img_end, _binary_ramfs_img_size; -void demo_setup_PL0(void) +void __attribute__((noreturn)) demo_setup_PL0(void) { // find PL_0_test.img im ramfs struct ramfile PL_0_test_img; @@ -112,30 +113,9 @@ void demo_setup_PL0(void) PL_0_test_img.file_contents, PL_0_test_img.file_size); puts("copied PL0 code to it's section"); -} - -void demo_go_unprivileged(void) -{ - uint32_t PL0_regs[14] = {0}; - PL0_regs[13] = VIRTUAL_PL0_MEMORY_START; // the new pc - PSR_t new_SPSR = read_CPSR(); - new_SPSR.fields.PSR_MODE_4_0 = MODE_USER; - new_SPSR.fields.PSR_IRQ_MASK_BIT = 0; - write_SPSR(new_SPSR); + puts("All ready! scheduling!"); - puts("All ready, jumping to PL0 code"); - - armclk_irq_settimeout(0x00100000); - - asm volatile("cps %[sysmode]\n\r" - "mov sp, %[stackaddr]\n\r" - "cps %[supmode]\n\r" - "ldm %[contextaddr], {r0 - r12, pc} ^" :: - [sysmode]"I" (MODE_SYSTEM), - [supmode]"I" (MODE_SUPERVISOR), - [stackaddr]"r" ((PL0_SECTION_NUMBER + 1) << 20), - [contextaddr]"r" (PL0_regs) : "memory"); - - __builtin_unreachable(); + schedule_new(VIRTUAL_PL0_MEMORY_START, // the new pc + VIRTUAL_PL0_MEMORY_END); // the new sp } -- cgit v1.2.3