Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @
- @ void uLipeFirstSwt(void)
- @
- .thumb_func
- SVC_Handler:
- ldr r0, =osMainStk @carrega variavel que vai guardar o stack principal
- tst lr, #4
- it EQ
- mrseq r1, msp @carrega o main stack pointer
- stmdb r1!,{r4 - r11} @salva registros que o hardware nao guarda
- str r1,[r0]
- movs r0, #0x02 @
- msr control, r0 @ uses psp for now.
- isb @ flushes the pipeline
- ldr r0, =highPrioTask @
- ldr r1, =currentTask @
- ldr r2, [r0] @
- ldr r2, [r2] @ takes the first task stack:
- ldmia r2!, {r4 - r11} @ pops the first sw context
- msr psp, r2 @ the remainning context is dealt by hardware
- ldr r0, [r0] @
- str r0, [r1] @ the current task is the high prio task
- ldr r0, =osRunning @
- movs r1, #1 @ os is running
- strb r1, [r0] @
- orr lr,lr, #0x04 @ensures the correct EXC_RETURN
- bx lr @
- @
- @ void uLipeCtxSwt(void)
- @
- .thumb_func
- PendSV_Handler:
- ldr r0, =highPrioTask @
- ldr r1, =currentTask @
- ldr r2, [r1] @ takes the current task stack:
- mrs r3, psp @ takes the current stack pointer
- stmdb r3!, {r4 - r11} @ save the software context
- str r3, [r2] @
- ldr r2,[r0] @
- ldr r2,[r2] @ takes the high prio task stk pointer
- ldmia r2!, {r4-r11} @ pops the new software saved context
- msr psp, r2 @ the hardware deals with remaining context
- ldr r2, [r0] @
- str r2, [r1] @ the high prio task is the current task
- orr lr,lr, #0x04 @
- bx lr @ the return depennds of current task stack contents
- @
- @ the systick handler, invoke kernel tick routine
- @
- .thumb_func
- SysTick_Handler:
- push {lr}
- ldr r3, =uLipeKernelRtosTick
- blx r3
- pop {pc}
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement