Advertisement
Guest User

Untitled

a guest
Feb 5th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ARM 2.35 KB | None | 0 0
  1.  
  2. @   void uLipeFirstSwt(void)
  3. @
  4.         .thumb_func
  5.  
  6. SVC_Handler:
  7.         ldr r0, =osMainStk      @carrega variavel que vai guardar o stack principal
  8.         movs r2, #4
  9.         mov  r1, lr
  10.         ands r1,r1,r2
  11.         bne ___already_msp
  12.         mrs r1, msp             @carrega o main stack pointer
  13. ___already_msp:
  14.         subs  r1, #32
  15.         str r1,[r0]
  16.         stmia r1!, {r4 - r7}    @ save the software context
  17.         mov  r4,r8
  18.         mov  r5,r9
  19.         mov  r6,r10
  20.         mov  r7,r11
  21.         stmia r1!, {r4 - r7}    @ save the software context
  22.  
  23.         movs r0, #0x02          @
  24.         msr  control, r0        @ uses psp for now.
  25.         isb                     @ flushes the pipeline
  26.         ldr r0, =highPrioTask   @
  27.         ldr r1, =currentTask    @
  28.         ldr r2, [r0]            @
  29.         ldr r2, [r2]            @ takes the first task stack:
  30.  
  31.         ldmia r2!, {r4 - r7}    @ pops the first sw context
  32.         mov  r8,r4
  33.         mov  r9,r5
  34.         mov  r10,r6
  35.         mov  r11,r7
  36.         ldmia r2!, {r4 - r7}
  37.         msr psp, r2             @ the hardware deals with remaining context
  38.  
  39.         ldr r0, [r0]            @
  40.         str r0, [r1]            @ the current task is the high prio task
  41.  
  42.         ldr   r0, =osRunning        @
  43.         movs  r1, #1            @ os is running
  44.         strb  r1, [r0]          @
  45.         movs r2, #4
  46.         mov r1, lr
  47.         orrs r1,r1, r2          @
  48.         mov lr, r1
  49.         bx  lr                  @
  50.  
  51. @
  52. @   void uLipeCtxSwt(void)
  53. @
  54.  
  55.         .thumb_func
  56. PendSV_Handler:
  57.         ldr r0, =highPrioTask   @
  58.         ldr r1, =currentTask    @
  59.         ldr r2, [r1]            @ takes the current task stack:
  60.         mrs r3, psp             @ takes the current stack pointer
  61.         subs r3, #32            @
  62.         str   r3, [r2]          @
  63.         stmia r3!, {r4 - r7}    @ save the software context
  64.         mov  r4,r8
  65.         mov  r5,r9
  66.         mov  r6,r10
  67.         mov  r7,r11
  68.         stmia r3!, {r4 - r7}    @ save the software context
  69.  
  70.         ldr r2,[r0]             @
  71.         ldr r2,[r2]             @ takes the high prio task stk pointer
  72.         adds r2, #16                @ takes first the high registers
  73.         ldmia r2!, {r4 - r7}    @ pops the  sw context
  74.         mov  r8,r4
  75.         mov  r9,r5
  76.         mov  r10,r6
  77.         mov  r11,r7
  78.         msr psp, r2             @ the hardware deals with remaining context
  79.         subs r2, #32                @ go back and restore the low registers
  80.         ldmia r2!, {r4 - r7}
  81.  
  82.         ldr r2, [r0]            @
  83.         str r2, [r1]            @ the high prio task is the current task
  84.         movs r2, #4
  85.         mov r1, lr
  86.         orrs r1,r1, r2           @
  87.         mov lr, r1
  88.         bx  lr                  @ the return depennds of current task stack contents
  89.  
  90. @
  91. @ the systick handler, invoke kernel tick routine
  92. @
  93.     .thumb_func
  94. SysTick_Handler:
  95.     push {lr}
  96.     ldr r3, =uLipeKernelRtosTick
  97.     blx r3
  98.     pop {pc}
  99. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement