2
2
3
3
#include " drivers/driver_commands.hpp"
4
4
#include " nrf52833.h"
5
- #include " scheduler/pending_process_callbacks.hpp"
6
5
#include " scheduler/mpu.hpp"
6
+ #include " scheduler/pending_process_callbacks.hpp"
7
+ #include " userlib/system_call_type.hpp"
7
8
#include " util.hpp"
8
9
9
10
namespace edge {
@@ -22,6 +23,7 @@ void Scheduler::start_scheduler()
22
23
23
24
NVIC_SetPriority (PendSV_IRQn, 0x3 );
24
25
NVIC_SetPriority (SysTick_IRQn, 0x1 );
26
+
25
27
MpuController::get ().initialize_mpu ();
26
28
asm volatile (" CPSIE I" );
27
29
asm volatile (" SVC #0" );
@@ -115,24 +117,12 @@ __attribute__((used)) void SysTick_Handler()
115
117
// I don't think there's any way to make this cleaner lol
116
118
__attribute__ ((used, naked)) USER_CODE void restore_regs ()
117
119
{
118
- // Load fpscr first so we can avoid dirtying r0 after its popped
119
- asm volatile (" ldr r0, [sp, #96]\n "
120
- " vmsr fpscr, r0\n " );
121
-
122
- // Pop regs as usual
123
- asm volatile (" pop {r0, r1, r2, r3, r12, lr}" );
124
-
125
- // Skip SP and RETPSR. SP will be loaded last
126
- // RETPSR should be ignored because we already popped when returning from exception
127
- asm volatile (" add sp, #8" );
128
-
129
- // Pop caller saved FP registers
130
- asm volatile (" vpop {s0-s15}" );
131
-
132
- // Skip FPSCR and 2 reserved regs
133
- asm volatile (" add sp, #12" );
120
+ asm volatile (" svc %0" ::" I" (SystemCallType::RESTORE_REGS));
121
+ }
134
122
135
- asm volatile (" ldr pc, [sp, #-84]" );
123
+ void Scheduler::restore_current_task_regs (exception_stack_registers* regs)
124
+ {
125
+ __set_PSP (reinterpret_cast <unsigned >(®s[1 ]) + 4 );
136
126
}
137
127
138
128
void Scheduler::yield_current_task ()
0 commit comments