Advertisement
Guest User

Untitled

a guest
Feb 5th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ARM 1.67 KB | None | 0 0
  1. @
  2. @   void uLipeFirstSwt(void)
  3. @
  4.         .thumb_func
  5. SVC_Handler:
  6.  
  7.         ldr r0, =osMainStk      @carrega variavel que vai guardar o stack principal
  8.         tst lr, #4
  9.         it  EQ
  10.         mrseq r1, msp           @carrega o main stack pointer
  11.         stmdb r1!,{r4 - r11}    @salva registros que o hardware nao guarda
  12.         str r1,[r0]
  13.  
  14.         movs r0, #0x02          @
  15.         msr  control, r0        @ uses psp for now.
  16.         isb                     @ flushes the pipeline
  17.         ldr r0, =highPrioTask   @
  18.         ldr r1, =currentTask    @
  19.         ldr r2, [r0]            @
  20.         ldr r2, [r2]            @ takes the first task stack:
  21.         ldmia r2!, {r4 - r11}   @ pops the first sw context
  22.         msr   psp, r2           @ the remainning context is dealt by hardware
  23.  
  24.         ldr r0, [r0]            @
  25.         str r0, [r1]            @ the current task is the high prio task
  26.  
  27.         ldr   r0, =osRunning        @
  28.         movs  r1, #1            @ os is running
  29.         strb  r1, [r0]          @
  30.         orr   lr,lr, #0x04      @ensures the correct EXC_RETURN
  31.  
  32.         bx  lr                  @
  33.  
  34. @
  35. @   void uLipeCtxSwt(void)
  36. @
  37.  
  38.         .thumb_func
  39. PendSV_Handler:
  40.         ldr r0, =highPrioTask   @
  41.         ldr r1, =currentTask    @
  42.         ldr r2, [r1]            @ takes the current task stack:
  43.         mrs r3, psp             @ takes the current stack pointer
  44.         stmdb r3!, {r4 - r11}   @ save the software context
  45.         str   r3, [r2]          @
  46.  
  47.         ldr r2,[r0]             @
  48.         ldr r2,[r2]             @ takes the high prio task stk pointer
  49.         ldmia r2!, {r4-r11}     @ pops  the new software saved context
  50.         msr psp, r2             @ the hardware deals with remaining context
  51.  
  52.         ldr r2, [r0]            @
  53.         str r2, [r1]            @ the high prio task is the current task
  54.         orr lr,lr, #0x04        @
  55.         bx  lr                  @ the return depennds of current task stack contents
  56.  
  57.  
  58. @
  59. @ the systick handler, invoke kernel tick routine
  60. @
  61.     .thumb_func
  62. SysTick_Handler:
  63.     push {lr}
  64.     ldr r3, =uLipeKernelRtosTick
  65.     blx r3
  66.     pop {pc}
  67.  
  68. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement