硬汉嵌入式论坛

 找回密码
 立即注册
查看: 2876|回复: 4
收起左侧

[μCOS-III] uCOS-III最新版3.08.01又升级port文件了,从来没有停止过,一直在升级的路上

[复制链接]

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107049
QQ
发表于 2021-7-6 08:16:31 | 显示全部楼层 |阅读模式

不是在升级,就是在升级的路上

QQ截图20210706081609.png




新版:
  1. ;********************************************************************************************************
  2. ;                                              uC/OS-III
  3. ;                                        The Real-Time Kernel
  4. ;
  5. ;                    Copyright 2009-2021 Silicon Laboratories Inc. www.silabs.com
  6. ;
  7. ;                                 SPDX-License-Identifier: APACHE-2.0
  8. ;
  9. ;               This software is subject to an open source license and is distributed by
  10. ;                Silicon Laboratories Inc. pursuant to the terms of the Apache License,
  11. ;                    Version 2.0 available at www.apache.org/licenses/LICENSE-2.0.
  12. ;
  13. ;********************************************************************************************************

  14. ;********************************************************************************************************
  15. ;
  16. ;                                             ARMv7-M Port
  17. ;
  18. ; File      : os_cpu_a.asm
  19. ; Version   : V3.08.01
  20. ;********************************************************************************************************
  21. ; For       : ARMv7-M Cortex-M
  22. ; Mode      : Thumb-2 ISA
  23. ; Toolchain : ARM C Compiler
  24. ;********************************************************************************************************
  25. ; Note(s)   : (1) This port supports the ARM Cortex-M3, Cortex-M4 and Cortex-M7 architectures.
  26. ;             (2) It has been tested with the following Hardware Floating Point Unit.
  27. ;                 (a) Single-precision: FPv4-SP-D16-M and FPv5-SP-D16-M
  28. ;                 (b) Double-precision: FPv5-D16-M
  29. ;********************************************************************************************************
  30. ;

  31. ;********************************************************************************************************
  32. ;                                          PUBLIC FUNCTIONS
  33. ;********************************************************************************************************

  34.                                                                 ; External references.
  35.     IMPORT  OSPrioCur
  36.     IMPORT  OSPrioHighRdy
  37.     IMPORT  OSTCBCurPtr
  38.     IMPORT  OSTCBHighRdyPtr
  39.     IMPORT  OSIntExit
  40.     IMPORT  OSTaskSwHook
  41.     IMPORT  OS_CPU_ExceptStkBase
  42.     IMPORT  OS_KA_BASEPRI_Boundary


  43.     EXPORT  OSStartHighRdy                                      ; Functions declared in this file
  44.     EXPORT  OSCtxSw
  45.     EXPORT  OSIntCtxSw
  46.     EXPORT  OS_CPU_PendSVHandler


  47. ;********************************************************************************************************
  48. ;                                               EQUATES
  49. ;********************************************************************************************************

  50. NVIC_INT_CTRL   EQU     0xE000ED04                              ; Interrupt control state register.
  51. NVIC_SYSPRI14   EQU     0xE000ED22                              ; System priority register (priority 14).
  52. NVIC_PENDSV_PRI EQU           0xFF                              ; PendSV priority value (lowest).
  53. NVIC_PENDSVSET  EQU     0x10000000                              ; Value to trigger PendSV exception.


  54. ;********************************************************************************************************
  55. ;                                     CODE GENERATION DIRECTIVES
  56. ;********************************************************************************************************

  57.     PRESERVE8
  58.     THUMB

  59.     AREA CODE, CODE, READONLY



  60. ;********************************************************************************************************
  61. ;                                         START MULTITASKING
  62. ;                                      void OSStartHighRdy(void)
  63. ;
  64. ; Note(s) : 1) This function triggers a PendSV exception (essentially, causes a context switch) to cause
  65. ;              the first task to start.
  66. ;
  67. ;           2) During task execution, PSP is used as the stack pointer.
  68. ;              When an exception occurs, the core will switch to MSP until the exception return.
  69. ;
  70. ;           3) OSStartHighRdy() MUST:
  71. ;              a) Setup PendSV exception priority to lowest;
  72. ;              b) Set initial PSP to 0, to tell context switcher this is first run;
  73. ;              c) Set the main stack to OS_CPU_ExceptStkBase
  74. ;              d) Get current high priority, OSPrioCur = OSPrioHighRdy;
  75. ;              e) Get current ready thread TCB, OSTCBCurPtr = OSTCBHighRdyPtr;
  76. ;              f) Get new process SP from TCB, SP = OSTCBHighRdyPtr->StkPtr;
  77. ;              g) Restore R0-R11 and R14 from new process stack;
  78. ;              h) Enable interrupts (tasks will run with interrupts enabled).
  79. ;********************************************************************************************************

  80. OSStartHighRdy
  81.     CPSID   I                                                   ; Prevent interruption during context switch
  82.     MOV32   R0, NVIC_SYSPRI14                                   ; Set the PendSV exception priority
  83.     MOV32   R1, NVIC_PENDSV_PRI
  84.     STRB    R1, [R0]

  85.     MOVS    R0, #0                                              ; Set the PSP to 0 for initial context switch call
  86.     MSR     PSP, R0

  87.     MOV32   R0, OS_CPU_ExceptStkBase                            ; Initialize the MSP to the OS_CPU_ExceptStkBase
  88.     LDR     R1, [R0]
  89.     MSR     MSP, R1

  90.     BL      OSTaskSwHook                                        ; Call OSTaskSwHook() for FPU Push & Pop

  91.     MOV32   R0, OSPrioCur                                       ; OSPrioCur   = OSPrioHighRdy;
  92.     MOV32   R1, OSPrioHighRdy
  93.     LDRB    R2, [R1]
  94.     STRB    R2, [R0]

  95.     MOV32   R0, OSTCBCurPtr                                     ; OSTCBCurPtr = OSTCBHighRdyPtr;
  96.     MOV32   R1, OSTCBHighRdyPtr
  97.     LDR     R2, [R1]
  98.     STR     R2, [R0]

  99.     LDR     R0, [R2]                                            ; R0 is new process SP; SP = OSTCBHighRdyPtr->StkPtr;
  100.     MSR     PSP, R0                                             ; Load PSP with new process SP

  101.     MRS     R0, CONTROL
  102.     ORR     R0, R0, #2
  103.     BIC     R0, R0, #4                                          ; Clear FPCA bit to indicate FPU is not in use
  104.     MSR     CONTROL, R0
  105.     ISB                                                         ; Sync instruction stream

  106.     LDMFD    SP!, {R4-R11, LR}                                  ; Restore r4-11, lr from new process stack
  107.     LDMFD    SP!, {R0-R3}                                       ; Restore r0, r3
  108.     LDMFD    SP!, {R12, LR}                                     ; Load R12 and LR
  109.     LDMFD    SP!, {R1, R2}                                      ; Load PC and discard xPSR
  110.     CPSIE    I
  111.     BX       R1


  112. ;********************************************************************************************************
  113. ;                       PERFORM A CONTEXT SWITCH (From task level) - OSCtxSw()
  114. ;                   PERFORM A CONTEXT SWITCH (From interrupt level) - OSIntCtxSw()
  115. ;
  116. ; Note(s) : 1) OSCtxSw() is called when OS wants to perform a task context switch.  This function
  117. ;              triggers the PendSV exception which is where the real work is done.
  118. ;
  119. ;           2) OSIntCtxSw() is called by OSIntExit() when it determines a context switch is needed as
  120. ;              the result of an interrupt.  This function simply triggers a PendSV exception which will
  121. ;              be handled when there are no more interrupts active and interrupts are enabled.
  122. ;********************************************************************************************************

  123. OSCtxSw
  124. OSIntCtxSw
  125.     LDR     R0, =NVIC_INT_CTRL                                  ; Trigger the PendSV exception (causes context switch)
  126.     LDR     R1, =NVIC_PENDSVSET
  127.     STR     R1, [R0]
  128.     BX      LR


  129. ;********************************************************************************************************
  130. ;                                       HANDLE PendSV EXCEPTION
  131. ;                                   void OS_CPU_PendSVHandler(void)
  132. ;
  133. ; Note(s) : 1) PendSV is used to cause a context switch.  This is a recommended method for performing
  134. ;              context switches with Cortex-M.  This is because the Cortex-M auto-saves half of the
  135. ;              processor context on any exception, and restores same on return from exception.  So only
  136. ;              saving of R4-R11 & R14 is required and fixing up the stack pointers. Using the PendSV exception
  137. ;              this way means that context saving and restoring is identical whether it is initiated from
  138. ;              a thread or occurs due to an interrupt or exception.
  139. ;
  140. ;           2) Pseudo-code is:
  141. ;              a) Get the process SP
  142. ;              b) Save remaining regs r4-r11 & r14 on process stack;
  143. ;              c) Save the process SP in its TCB, OSTCBCurPtr->OSTCBStkPtr = SP;
  144. ;              d) Call OSTaskSwHook();
  145. ;              e) Get current high priority, OSPrioCur = OSPrioHighRdy;
  146. ;              f) Get current ready thread TCB, OSTCBCurPtr = OSTCBHighRdyPtr;
  147. ;              g) Get new process SP from TCB, SP = OSTCBHighRdyPtr->OSTCBStkPtr;
  148. ;              h) Restore R4-R11 and R14 from new process stack;
  149. ;              i) Perform exception return which will restore remaining context.
  150. ;
  151. ;           3) On entry into PendSV handler:
  152. ;              a) The following have been saved on the process stack (by processor):
  153. ;                 xPSR, PC, LR, R12, R0-R3
  154. ;              b) Processor mode is switched to Handler mode (from Thread mode)
  155. ;              c) Stack is Main stack (switched from Process stack)
  156. ;              d) OSTCBCurPtr      points to the OS_TCB of the task to suspend
  157. ;                 OSTCBHighRdyPtr  points to the OS_TCB of the task to resume
  158. ;
  159. ;           4) Since PendSV is set to lowest priority in the system (by OSStartHighRdy() above), we
  160. ;              know that it will only be run when no other exception or interrupt is active, and
  161. ;              therefore safe to assume that context being switched out was using the process stack (PSP).
  162. ;
  163. ;           5) Increasing priority using a write to BASEPRI does not take effect immediately.
  164. ;              (a) IMPLICATION  This erratum means that the instruction after an MSR to boost BASEPRI
  165. ;                  might incorrectly be preempted by an insufficient high priority exception.
  166. ;
  167. ;              (b) WORKAROUND  The MSR to boost BASEPRI can be replaced by the following code sequence:
  168. ;
  169. ;                  CPSID i
  170. ;                  MSR to BASEPRI
  171. ;                  DSB
  172. ;                  ISB
  173. ;                  CPSIE i
  174. ;********************************************************************************************************

  175. OS_CPU_PendSVHandler
  176.     CPSID   I                                                   ; Cortex-M7 errata notice. See Note #5
  177.     MOV32   R2, OS_KA_BASEPRI_Boundary                          ; Set BASEPRI priority level required for exception preemption
  178.     LDR     R1, [R2]
  179.     MSR     BASEPRI, R1
  180.     DSB
  181.     ISB
  182.     CPSIE   I

  183.     MRS     R0, PSP                                             ; PSP is process stack pointer
  184.     IF {FPU} != "SoftVFP"
  185.                                                                 ; Push high vfp registers if the task is using the FPU context
  186.     TST       R14, #0x10
  187.     IT        EQ
  188.     VSTMDBEQ  R0!, {S16-S31}
  189.     ENDIF

  190.     STMFD   R0!, {R4-R11, R14}                                  ; Save remaining regs r4-11, R14 on process stack

  191.     MOV32   R5, OSTCBCurPtr                                     ; OSTCBCurPtr->StkPtr = SP;
  192.     LDR     R1, [R5]
  193.     STR     R0, [R1]                                            ; R0 is SP of process being switched out

  194.                                                                 ; At this point, entire context of process has been saved
  195.     MOV     R4, LR                                              ; Save LR exc_return value
  196.     BL      OSTaskSwHook                                        ; Call OSTaskSwHook() for FPU Push & Pop

  197.     MOV32   R0, OSPrioCur                                       ; OSPrioCur   = OSPrioHighRdy;
  198.     MOV32   R1, OSPrioHighRdy
  199.     LDRB    R2, [R1]
  200.     STRB    R2, [R0]

  201.     MOV32   R1, OSTCBHighRdyPtr                                 ; OSTCBCurPtr = OSTCBHighRdyPtr;
  202.     LDR     R2, [R1]
  203.     STR     R2, [R5]

  204.     ORR     LR,  R4, #0x04                                      ; Ensure exception return uses process stack
  205.     LDR     R0,  [R2]                                           ; R0 is new process SP; SP = OSTCBHighRdyPtr->StkPtr;
  206.     LDMFD   R0!, {R4-R11, R14}                                  ; Restore r4-11, R14 from new process stack

  207.     IF {FPU} != "SoftVFP"
  208.                                                                 ; Pop the high vfp registers if the next task is using the FPU context
  209.     TST       R14, #0x10
  210.     IT        EQ
  211.     VLDMIAEQ  R0!, {S16-S31}
  212.     ENDIF

  213.     MSR     PSP, R0                                             ; Load PSP with new process SP

  214.     MOV32   R2, #0                                              ; Restore BASEPRI priority level to 0
  215.     CPSID   I                                                   ; Cortex-M7 errata notice. See Note #5
  216.     MSR     BASEPRI, R2
  217.     DSB
  218.     ISB
  219.     CPSIE   I
  220.     BX      LR                                                  ; Exception return will restore remaining context

  221.     ALIGN                                                       ; Removes warning[A1581W]: added <no_padbytes> of padding at <address>

  222.     END
复制代码





老版:

  1. ;********************************************************************************************************
  2. ;                                              uC/OS-III
  3. ;                                        The Real-Time Kernel
  4. ;
  5. ;                    Copyright 2009-2020 Silicon Laboratories Inc. www.silabs.com
  6. ;
  7. ;                                 SPDX-License-Identifier: APACHE-2.0
  8. ;
  9. ;               This software is subject to an open source license and is distributed by
  10. ;                Silicon Laboratories Inc. pursuant to the terms of the Apache License,
  11. ;                    Version 2.0 available at www.apache.org/licenses/LICENSE-2.0.
  12. ;
  13. ;********************************************************************************************************

  14. ;********************************************************************************************************
  15. ;
  16. ;                                             ARMv7-M Port
  17. ;
  18. ; File      : os_cpu_a.asm
  19. ; Version   : V3.08.00
  20. ;********************************************************************************************************
  21. ; For       : ARMv7-M Cortex-M
  22. ; Mode      : Thumb-2 ISA
  23. ; Toolchain : ARM C Compiler
  24. ;********************************************************************************************************
  25. ; Note(s)   : (1) This port supports the ARM Cortex-M3, Cortex-M4 and Cortex-M7 architectures.
  26. ;             (2) It has been tested with the following Hardware Floating Point Unit.
  27. ;                 (a) Single-precision: FPv4-SP-D16-M and FPv5-SP-D16-M
  28. ;                 (b) Double-precision: FPv5-D16-M
  29. ;********************************************************************************************************
  30. ;

  31. ;********************************************************************************************************
  32. ;                                          PUBLIC FUNCTIONS
  33. ;********************************************************************************************************

  34.                                                                 ; External references.
  35.     IMPORT  OSPrioCur
  36.     IMPORT  OSPrioHighRdy
  37.     IMPORT  OSTCBCurPtr
  38.     IMPORT  OSTCBHighRdyPtr
  39.     IMPORT  OSIntExit
  40.     IMPORT  OSTaskSwHook
  41.     IMPORT  OS_CPU_ExceptStkBase
  42.     IMPORT  OS_KA_BASEPRI_Boundary


  43.     EXPORT  OSStartHighRdy                                      ; Functions declared in this file
  44.     EXPORT  OSCtxSw
  45.     EXPORT  OSIntCtxSw
  46.     EXPORT  OS_CPU_PendSVHandler

  47.     IF {FPU} != "SoftVFP"
  48.     EXPORT  OS_CPU_FP_Reg_Push
  49.     EXPORT  OS_CPU_FP_Reg_Pop
  50.     ENDIF


  51. ;********************************************************************************************************
  52. ;                                               EQUATES
  53. ;********************************************************************************************************

  54. NVIC_INT_CTRL   EQU     0xE000ED04                              ; Interrupt control state register.
  55. NVIC_SYSPRI14   EQU     0xE000ED22                              ; System priority register (priority 14).
  56. NVIC_PENDSV_PRI EQU           0xFF                              ; PendSV priority value (lowest).
  57. NVIC_PENDSVSET  EQU     0x10000000                              ; Value to trigger PendSV exception.


  58. ;********************************************************************************************************
  59. ;                                     CODE GENERATION DIRECTIVES
  60. ;********************************************************************************************************

  61.     PRESERVE8
  62.     THUMB

  63.     AREA CODE, CODE, READONLY


  64. ;********************************************************************************************************
  65. ;                                   FLOATING POINT REGISTERS PUSH
  66. ;                             void  OS_CPU_FP_Reg_Push (CPU_STK  *stkPtr)
  67. ;
  68. ; Note(s) : 1) This function saves S16-S31 registers of the Floating Point Unit.
  69. ;
  70. ;           2) Pseudo-code is:
  71. ;              a) Push remaining FPU regs S16-S31 on process stack;
  72. ;              b) Update OSTCBCurPtr->StkPtr;
  73. ;********************************************************************************************************

  74.     IF {FPU} != "SoftVFP"

  75. OS_CPU_FP_Reg_Push
  76.     MRS     R1, PSP                                             ; PSP is process stack pointer
  77.     CBZ     R1, OS_CPU_FP_nosave                                ; Skip FP register save the first time

  78.     VSTMDB  R0!, {S16-S31}
  79.     LDR     R1, =OSTCBCurPtr
  80.     LDR     R2, [R1]
  81.     STR     R0, [R2]
  82. OS_CPU_FP_nosave
  83.     BX      LR

  84.     ENDIF


  85. ;********************************************************************************************************
  86. ;                                   FLOATING POINT REGISTERS POP
  87. ;                             void  OS_CPU_FP_Reg_Pop (CPU_STK  *stkPtr)
  88. ;
  89. ; Note(s) : 1) This function restores S16-S31 of the Floating Point Unit.
  90. ;
  91. ;           2) Pseudo-code is:
  92. ;              a) Restore regs S16-S31 of new process stack;
  93. ;              b) Update OSTCBHighRdyPtr->StkPtr pointer of new proces stack;
  94. ;********************************************************************************************************

  95.     IF {FPU} != "SoftVFP"

  96. OS_CPU_FP_Reg_Pop
  97.     VLDMIA  R0!, {S16-S31}
  98.     LDR     R1, =OSTCBHighRdyPtr
  99.     LDR     R2, [R1]
  100.     STR     R0, [R2]
  101.     BX      LR

  102.     ENDIF


  103. ;********************************************************************************************************
  104. ;                                         START MULTITASKING
  105. ;                                      void OSStartHighRdy(void)
  106. ;
  107. ; Note(s) : 1) This function triggers a PendSV exception (essentially, causes a context switch) to cause
  108. ;              the first task to start.
  109. ;
  110. ;           2) During task execution, PSP is used as the stack pointer.
  111. ;              When an exception occurs, the core will switch to MSP until the exception return.
  112. ;
  113. ;           3) OSStartHighRdy() MUST:
  114. ;              a) Setup PendSV exception priority to lowest;
  115. ;              b) Set initial PSP to 0, to tell context switcher this is first run;
  116. ;              c) Set the main stack to OS_CPU_ExceptStkBase
  117. ;              d) Get current high priority, OSPrioCur = OSPrioHighRdy;
  118. ;              e) Get current ready thread TCB, OSTCBCurPtr = OSTCBHighRdyPtr;
  119. ;              f) Get new process SP from TCB, SP = OSTCBHighRdyPtr->StkPtr;
  120. ;              g) Restore R0-R11 and R14 from new process stack;
  121. ;              h) Enable interrupts (tasks will run with interrupts enabled).
  122. ;********************************************************************************************************

  123. OSStartHighRdy
  124.     CPSID   I                                                   ; Prevent interruption during context switch
  125.     MOV32   R0, NVIC_SYSPRI14                                   ; Set the PendSV exception priority
  126.     MOV32   R1, NVIC_PENDSV_PRI
  127.     STRB    R1, [R0]

  128.     MOVS    R0, #0                                              ; Set the PSP to 0 for initial context switch call
  129.     MSR     PSP, R0

  130.     MOV32   R0, OS_CPU_ExceptStkBase                            ; Initialize the MSP to the OS_CPU_ExceptStkBase
  131.     LDR     R1, [R0]
  132.     MSR     MSP, R1

  133.     BL      OSTaskSwHook                                        ; Call OSTaskSwHook() for FPU Push & Pop

  134.     MOV32   R0, OSPrioCur                                       ; OSPrioCur   = OSPrioHighRdy;
  135.     MOV32   R1, OSPrioHighRdy
  136.     LDRB    R2, [R1]
  137.     STRB    R2, [R0]

  138.     MOV32   R0, OSTCBCurPtr                                     ; OSTCBCurPtr = OSTCBHighRdyPtr;
  139.     MOV32   R1, OSTCBHighRdyPtr
  140.     LDR     R2, [R1]
  141.     STR     R2, [R0]

  142.     LDR     R0, [R2]                                            ; R0 is new process SP; SP = OSTCBHighRdyPtr->StkPtr;
  143.     MSR     PSP, R0                                             ; Load PSP with new process SP

  144.     MRS     R0, CONTROL
  145.     ORR     R0, R0, #2
  146.     MSR     CONTROL, R0
  147.     ISB                                                         ; Sync instruction stream

  148.     LDMFD    SP!, {R4-R11, LR}                                  ; Restore r4-11, lr from new process stack
  149.     LDMFD    SP!, {R0-R3}                                       ; Restore r0, r3
  150.     LDMFD    SP!, {R12, LR}                                     ; Load R12 and LR
  151.     LDMFD    SP!, {R1, R2}                                      ; Load PC and discard xPSR
  152.     CPSIE    I
  153.     BX       R1


  154. ;********************************************************************************************************
  155. ;                       PERFORM A CONTEXT SWITCH (From task level) - OSCtxSw()
  156. ;                   PERFORM A CONTEXT SWITCH (From interrupt level) - OSIntCtxSw()
  157. ;
  158. ; Note(s) : 1) OSCtxSw() is called when OS wants to perform a task context switch.  This function
  159. ;              triggers the PendSV exception which is where the real work is done.
  160. ;
  161. ;           2) OSIntCtxSw() is called by OSIntExit() when it determines a context switch is needed as
  162. ;              the result of an interrupt.  This function simply triggers a PendSV exception which will
  163. ;              be handled when there are no more interrupts active and interrupts are enabled.
  164. ;********************************************************************************************************

  165. OSCtxSw
  166. OSIntCtxSw
  167.     LDR     R0, =NVIC_INT_CTRL                                  ; Trigger the PendSV exception (causes context switch)
  168.     LDR     R1, =NVIC_PENDSVSET
  169.     STR     R1, [R0]
  170.     BX      LR


  171. ;********************************************************************************************************
  172. ;                                       HANDLE PendSV EXCEPTION
  173. ;                                   void OS_CPU_PendSVHandler(void)
  174. ;
  175. ; Note(s) : 1) PendSV is used to cause a context switch.  This is a recommended method for performing
  176. ;              context switches with Cortex-M.  This is because the Cortex-M auto-saves half of the
  177. ;              processor context on any exception, and restores same on return from exception.  So only
  178. ;              saving of R4-R11 & R14 is required and fixing up the stack pointers. Using the PendSV exception
  179. ;              this way means that context saving and restoring is identical whether it is initiated from
  180. ;              a thread or occurs due to an interrupt or exception.
  181. ;
  182. ;           2) Pseudo-code is:
  183. ;              a) Get the process SP
  184. ;              b) Save remaining regs r4-r11 & r14 on process stack;
  185. ;              c) Save the process SP in its TCB, OSTCBCurPtr->OSTCBStkPtr = SP;
  186. ;              d) Call OSTaskSwHook();
  187. ;              e) Get current high priority, OSPrioCur = OSPrioHighRdy;
  188. ;              f) Get current ready thread TCB, OSTCBCurPtr = OSTCBHighRdyPtr;
  189. ;              g) Get new process SP from TCB, SP = OSTCBHighRdyPtr->OSTCBStkPtr;
  190. ;              h) Restore R4-R11 and R14 from new process stack;
  191. ;              i) Perform exception return which will restore remaining context.
  192. ;
  193. ;           3) On entry into PendSV handler:
  194. ;              a) The following have been saved on the process stack (by processor):
  195. ;                 xPSR, PC, LR, R12, R0-R3
  196. ;              b) Processor mode is switched to Handler mode (from Thread mode)
  197. ;              c) Stack is Main stack (switched from Process stack)
  198. ;              d) OSTCBCurPtr      points to the OS_TCB of the task to suspend
  199. ;                 OSTCBHighRdyPtr  points to the OS_TCB of the task to resume
  200. ;
  201. ;           4) Since PendSV is set to lowest priority in the system (by OSStartHighRdy() above), we
  202. ;              know that it will only be run when no other exception or interrupt is active, and
  203. ;              therefore safe to assume that context being switched out was using the process stack (PSP).
  204. ;
  205. ;           5) Increasing priority using a write to BASEPRI does not take effect immediately.
  206. ;              (a) IMPLICATION  This erratum means that the instruction after an MSR to boost BASEPRI
  207. ;                  might incorrectly be preempted by an insufficient high priority exception.
  208. ;
  209. ;              (b) WORKAROUND  The MSR to boost BASEPRI can be replaced by the following code sequence:
  210. ;
  211. ;                  CPSID i
  212. ;                  MSR to BASEPRI
  213. ;                  DSB
  214. ;                  ISB
  215. ;                  CPSIE i
  216. ;********************************************************************************************************

  217. OS_CPU_PendSVHandler
  218.     CPSID   I                                                   ; Cortex-M7 errata notice. See Note #5
  219.     MOV32   R2, OS_KA_BASEPRI_Boundary                          ; Set BASEPRI priority level required for exception preemption
  220.     LDR     R1, [R2]
  221.     MSR     BASEPRI, R1
  222.     DSB
  223.     ISB
  224.     CPSIE   I

  225.     MRS     R0, PSP                                             ; PSP is process stack pointer
  226.     STMFD   R0!, {R4-R11, R14}                                  ; Save remaining regs r4-11, R14 on process stack

  227.     MOV32   R5, OSTCBCurPtr                                     ; OSTCBCurPtr->StkPtr = SP;
  228.     LDR     R1, [R5]
  229.     STR     R0, [R1]                                            ; R0 is SP of process being switched out

  230.                                                                 ; At this point, entire context of process has been saved
  231.     MOV     R4, LR                                              ; Save LR exc_return value
  232.     BL      OSTaskSwHook                                        ; Call OSTaskSwHook() for FPU Push & Pop

  233.     MOV32   R0, OSPrioCur                                       ; OSPrioCur   = OSPrioHighRdy;
  234.     MOV32   R1, OSPrioHighRdy
  235.     LDRB    R2, [R1]
  236.     STRB    R2, [R0]

  237.     MOV32   R1, OSTCBHighRdyPtr                                 ; OSTCBCurPtr = OSTCBHighRdyPtr;
  238.     LDR     R2, [R1]
  239.     STR     R2, [R5]

  240.     ORR     LR,  R4, #0x04                                      ; Ensure exception return uses process stack
  241.     LDR     R0,  [R2]                                           ; R0 is new process SP; SP = OSTCBHighRdyPtr->StkPtr;
  242.     LDMFD   R0!, {R4-R11, R14}                                  ; Restore r4-11, R14 from new process stack
  243.     MSR     PSP, R0                                             ; Load PSP with new process SP

  244.     MOV32   R2, #0                                              ; Restore BASEPRI priority level to 0
  245.     MSR     BASEPRI, R2
  246.     BX      LR                                                  ; Exception return will restore remaining context

  247.     ALIGN                                                       ; Removes warning[A1581W]: added <no_padbytes> of padding at <address>

  248.     END
复制代码
回复

使用道具 举报

1

主题

12

回帖

15

积分

新手上路

积分
15
发表于 2021-7-6 08:37:34 | 显示全部楼层
是不是可以这么理解,port文件一直有问题,一直升?
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107049
QQ
 楼主| 发表于 2021-7-6 08:52:14 | 显示全部楼层
gk112358 发表于 2021-7-6 08:37
是不是可以这么理解,port文件一直有问题,一直升?

之前的版本都能用,是他们觉得不完美
回复

使用道具 举报

6

主题

641

回帖

659

积分

金牌会员

积分
659
QQ
发表于 2021-7-6 21:10:33 | 显示全部楼层
出几个全家桶的范例就完美了,uc-TCPIP和uC-USBH都移植不成功,卡着好久了
回复

使用道具 举报

19

主题

373

回帖

430

积分

高级会员

积分
430
发表于 2021-7-6 22:28:39 | 显示全部楼层
精益求精呀值得学习
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2024-5-15 20:19 , Processed in 0.166528 second(s), 28 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表