+/rtos
git clone https://git.julia.blue/+/rtos
b9fc7f5
master
1.cpu cortex - m4 2.fpu fpv4 - sp- d16 3.syntax unified 4.thumb 5.text 6 7.extern current_thread 8.extern mpu_swap_region 9// .extern context_switch_hook 10 11.thumb_func 12.global pendsv_handler 13pendsv_handler : 14CPSID I 15PUSH {R4 - R11 } 16 17// For debugging context switches in C 18// PUSH {LR} 19// BL context_switch_hook 20// POP {LR} 21 22LDR R0 , =current_thread // R0 = ¤t_thread 23LDR R1 , [ R0 ] // R1 = current_thread 24STR SP , [ R1 ] // SP = *current_thread aka current_thread->sp 25LDR R1 , [ R1 , #4 ] // R1 = current_thread->next_tcb; 26STR R1 , [ R0 ] // current_thread = current_thread->next_tcb; 27LDR SP , [ R1 ] // SP = current_thread->sp 28 29// Change MPU region to current thread's stack 30// TODO: make this faster by modifying the address register directly 31push {LR } 32BL mpu_swap_region 33POP {LR } 34 35POP {R4 - R11 } 36CPSIE I 37BX LR