搜索
bottom↓
回复: 7

今天想把UC/OSIII移植到LPC4357上,现在有些问题不知道如何解

[复制链接]

出0入53汤圆

发表于 2014-4-19 10:42:05 | 显示全部楼层 |阅读模式
今天想把UC/OSIII移植到LPC4357上,现在有些问题不知道如何解,请大神们帮我看看
错误提示如下
..\uCOS-III\Ports\os_cpu_a.asm(120): error: A1167E: Invalid line start
..\uCOS-III\Ports\os_cpu_a.asm(138): error: A1108E: Multiply defined symbol 'OSStartHighRdy'
..\uCOS-III\Ports\os_cpu_a.asm(168): error: A1108E: Multiply defined symbol 'OSCtxSw'
..\uCOS-III\Ports\os_cpu_a.asm(184): error: A1108E: Multiply defined symbol 'OSIntCtxSw'
..\uCOS-III\Ports\os_cpu_a.asm(227): error: A1108E: Multiply defined symbol 'OS_CPU_PendSVHandler'

改动os_cpu_a.asm如下
  1. ;
  2. ;********************************************************************************************************
  3. ;                                                uC/OS-III
  4. ;                                          The Real-Time Kernel
  5. ;
  6. ;
  7. ;                              (c) Copyright 2010; Micrium, Inc.; Weston, FL
  8. ;                    All rights reserved.  Protected by international copyright laws.
  9. ;
  10. ;                                           ARM Cortex-M4 Port
  11. ;
  12. ; File      : OS_CPU_A.ASM
  13. ; Version   : V3.01.2
  14. ; By        : JJL
  15. ;             BAN
  16. ;
  17. ; For       : ARMv7 Cortex-M4
  18. ; Mode      : Thumb-2 ISA
  19. ; Toolchain : IAR EWARM
  20. ;********************************************************************************************************
  21. ;

  22. ;********************************************************************************************************
  23. ;                                          PUBLIC FUNCTIONS
  24. ;********************************************************************************************************

  25.     EXTERN  OSRunning                                           ; External references
  26.     EXTERN  OSPrioCur
  27.     EXTERN  OSPrioHighRdy
  28.     EXTERN  OSTCBCurPtr
  29.     EXTERN  OSTCBHighRdyPtr
  30.     EXTERN  OSIntExit
  31.     EXTERN  OSTaskSwHook
  32.     EXTERN  OS_CPU_ExceptStkBase


  33.     EXTERN  OSStartHighRdy                                      ; Functions declared in this file
  34.     EXTERN  OSCtxSw
  35.     EXTERN  OSIntCtxSw
  36.     EXTERN  OS_CPU_PendSVHandler

  37. ;IF {FPU} != "SoftVFP"
  38.     ;EXPORT  OS_CPU_FP_Reg_Push
  39.     ;EXPORT  OS_CPU_FP_Reg_Pop
  40.     ;ENDIF
  41. ;#ifdef __ARMVFP__
  42.     ;EXTERN  OS_CPU_FP_Reg_Push
  43.     ;EXTERN  OS_CPU_FP_Reg_Pop
  44. ;#endif

  45. ;PAGE
  46. ;********************************************************************************************************
  47. ;                                               EQUATES
  48. ;********************************************************************************************************

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


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

  56.         AREA |.text|, CODE, READONLY, ALIGN=2
  57.     THUMB
  58.     REQUIRE8
  59.     PRESERVE8

  60. ;#ifdef __ARMVFP__
  61. ;PAGE
  62. ;********************************************************************************************************
  63. ;                                   FLOATING POINT REGISTERS PUSH
  64. ;                             void  OS_CPU_FP_Reg_Push (CPU_STK  *stkPtr)
  65. ;
  66. ; Note(s) : 1) This function saves S0-S31, and FPSCR registers of the Floating Point Unit.
  67. ;
  68. ;           2) Pseudo-code is:
  69. ;              a) Get FPSCR register value;
  70. ;              b) Push value on process stack;
  71. ;              c) Push remaining regs S0-S31 on process stack;
  72. ;              d) Update OSTCBCurPtr->StkPtr;
  73. ;********************************************************************************************************

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

  77.     VMRS    R1, FPSCR
  78.     STR R1, [R0, #-4]!
  79.     VSTMDB  R0!, {S0-S31}
  80.     LDR     R1, =OSTCBCurPtr
  81.     LDR     R2, [R1]
  82.     STR     R0, [R2]
  83. OS_CPU_FP_nosave
  84.     BX      LR

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

  97. OS_CPU_FP_Reg_Pop
  98.     VLDMIA  R0!, {S0-S31}
  99.     LDMIA   R0!, {R1}
  100.     VMSR    FPSCR, R1
  101.     LDR     R1, =OSTCBHighRdyPtr
  102.     LDR     R2, [R1]
  103.     STR     R0, [R2]
  104.     BX      LR
  105. #endif

  106. ;PAGE
  107. ;********************************************************************************************************
  108. ;                                         START MULTITASKING
  109. ;                                      void OSStartHighRdy(void)
  110. ;
  111. ; Note(s) : 1) This function triggers a PendSV exception (essentially, causes a context switch) to cause
  112. ;              the first task to start.
  113. ;
  114. ;           2) OSStartHighRdy() MUST:
  115. ;              a) Setup PendSV exception priority to lowest;
  116. ;              b) Set initial PSP to 0, to tell context switcher this is first run;
  117. ;              c) Set the main stack to OS_CPU_ExceptStkBase
  118. ;              d) Trigger PendSV exception;
  119. ;              e) Enable interrupts (tasks will run with interrupts enabled).
  120. ;********************************************************************************************************

  121. OSStartHighRdy
  122.     LDR     R0, =NVIC_SYSPRI14                                  ; Set the PendSV exception priority
  123.     LDR     R1, =NVIC_PENDSV_PRI
  124.     STRB    R1, [R0]

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

  127.     LDR     R0, =OS_CPU_ExceptStkBase                           ; Initialize the MSP to the OS_CPU_ExceptStkBase
  128.     LDR     R1, [R0]
  129.     MSR     MSP, R1

  130.     LDR     R0, =NVIC_INT_CTRL                                  ; Trigger the PendSV exception (causes context switch)
  131.     LDR     R1, =NVIC_PENDSVSET
  132.     STR     R1, [R0]

  133.     CPSIE   I                                                   ; Enable interrupts at processor level

  134. OSStartHang
  135.     B       OSStartHang                                         ; Should never get here


  136. ;PAGE
  137. ;********************************************************************************************************
  138. ;                       PERFORM A CONTEXT SWITCH (From task level) - OSCtxSw()
  139. ;
  140. ; Note(s) : 1) OSCtxSw() is called when OS wants to perform a task context switch.  This function
  141. ;              triggers the PendSV exception which is where the real work is done.
  142. ;********************************************************************************************************

  143. OSCtxSw
  144.     LDR     R0, =NVIC_INT_CTRL                                  ; Trigger the PendSV exception (causes context switch)
  145.     LDR     R1, =NVIC_PENDSVSET
  146.     STR     R1, [R0]
  147.     BX      LR


  148. ;PAGE
  149. ;********************************************************************************************************
  150. ;                   PERFORM A CONTEXT SWITCH (From interrupt level) - OSIntCtxSw()
  151. ;
  152. ; Note(s) : 1) OSIntCtxSw() is called by OSIntExit() when it determines a context switch is needed as
  153. ;              the result of an interrupt.  This function simply triggers a PendSV exception which will
  154. ;              be handled when there are no more interrupts active and interrupts are enabled.
  155. ;********************************************************************************************************

  156. OSIntCtxSw
  157.     LDR     R0, =NVIC_INT_CTRL                                  ; Trigger the PendSV exception (causes context switch)
  158.     LDR     R1, =NVIC_PENDSVSET
  159.     STR     R1, [R0]
  160.     BX      LR


  161. ;PAGE
  162. ;********************************************************************************************************
  163. ;                                       HANDLE PendSV EXCEPTION
  164. ;                                   void OS_CPU_PendSVHandler(void)
  165. ;
  166. ; Note(s) : 1) PendSV is used to cause a context switch.  This is a recommended method for performing
  167. ;              context switches with Cortex-M3.  This is because the Cortex-M3 auto-saves half of the
  168. ;              processor context on any exception, and restores same on return from exception.  So only
  169. ;              saving of R4-R11 is required and fixing up the stack pointers.  Using the PendSV exception
  170. ;              this way means that context saving and restoring is identical whether it is initiated from
  171. ;              a thread or occurs due to an interrupt or exception.
  172. ;
  173. ;           2) Pseudo-code is:
  174. ;              a) Get the process SP, if 0 then skip (goto d) the saving part (first context switch);
  175. ;              b) Save remaining regs r4-r11 on process stack;
  176. ;              c) Save the process SP in its TCB, OSTCBCurPtr->OSTCBStkPtr = SP;
  177. ;              d) Call OSTaskSwHook();
  178. ;              e) Get current high priority, OSPrioCur = OSPrioHighRdy;
  179. ;              f) Get current ready thread TCB, OSTCBCurPtr = OSTCBHighRdyPtr;
  180. ;              g) Get new process SP from TCB, SP = OSTCBHighRdyPtr->OSTCBStkPtr;
  181. ;              h) Restore R4-R11 from new process stack;
  182. ;              i) Perform exception return which will restore remaining context.
  183. ;
  184. ;           3) On entry into PendSV handler:
  185. ;              a) The following have been saved on the process stack (by processor):
  186. ;                 xPSR, PC, LR, R12, R0-R3
  187. ;              b) Processor mode is switched to Handler mode (from Thread mode)
  188. ;              c) Stack is Main stack (switched from Process stack)
  189. ;              d) OSTCBCurPtr      points to the OS_TCB of the task to suspend
  190. ;                 OSTCBHighRdyPtr  points to the OS_TCB of the task to resume
  191. ;
  192. ;           4) Since PendSV is set to lowest priority in the system (by OSStartHighRdy() above), we
  193. ;              know that it will only be run when no other exception or interrupt is active, and
  194. ;              therefore safe to assume that context being switched out was using the process stack (PSP).
  195. ;********************************************************************************************************

  196. OS_CPU_PendSVHandler
  197.     CPSID   I                                                   ; Prevent interruption during context switch
  198.     MRS     R0, PSP                                             ; PSP is process stack pointer
  199.     CBZ     R0, OS_CPU_PendSVHandler_nosave                     ; Skip register save the first time

  200.     SUBS    R0, R0, #0x20                                       ; Save remaining regs r4-11 on process stack
  201.     STM     R0, {R4-R11}

  202.     LDR     R1, =OSTCBCurPtr                                    ; OSTCBCurPtr->OSTCBStkPtr = SP;
  203.     LDR     R1, [R1]
  204.     STR     R0, [R1]                                            ; R0 is SP of process being switched out

  205.                                                                 ; At this point, entire context of process has been saved
  206. OS_CPU_PendSVHandler_nosave
  207.     PUSH    {R14}                                               ; Save LR exc_return value
  208.     LDR     R0, =OSTaskSwHook                                   ; OSTaskSwHook();
  209.     BLX     R0
  210.     POP     {R14}

  211.     LDR     R0, =OSPrioCur                                      ; OSPrioCur   = OSPrioHighRdy;
  212.     LDR     R1, =OSPrioHighRdy
  213.     LDRB    R2, [R1]
  214.     STRB    R2, [R0]

  215.     LDR     R0, =OSTCBCurPtr                                    ; OSTCBCurPtr = OSTCBHighRdyPtr;
  216.     LDR     R1, =OSTCBHighRdyPtr
  217.     LDR     R2, [R1]
  218.     STR     R2, [R0]

  219.     LDR     R0, [R2]                                            ; R0 is new process SP; SP = OSTCBHighRdyPtr->StkPtr;
  220.     LDM     R0, {R4-R11}                                        ; Restore r4-11 from new process stack
  221.     ADDS    R0, R0, #0x20
  222.     MSR     PSP, R0                                             ; Load PSP with new process SP
  223.     ORR     LR, LR, #0x04                                       ; Ensure exception return uses process stack
  224.     CPSIE   I
  225.     BX      LR                                                  ; Exception return will restore remaining context

  226.     END
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

阿莫论坛20周年了!感谢大家的支持与爱护!!

一只鸟敢站在脆弱的枝条上歇脚,它依仗的不是枝条不会断,而是自己有翅膀,会飞。

出0入53汤圆

 楼主| 发表于 2014-4-19 11:04:08 | 显示全部楼层
自己对照着屈环宇的方法都修改了,

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

出0入0汤圆

发表于 2014-4-19 11:46:44 | 显示全部楼层
提示重定义了,你看看是不是.h文件不要随便都加,应该是加多了。

出0入0汤圆

发表于 2014-4-19 18:07:25 | 显示全部楼层

    EXTERN  OSStartHighRdy                                      ; Functions declared in this file
    EXTERN  OSCtxSw
    EXTERN  OSIntCtxSw
    EXTERN  OS_CPU_PendSVHandler
上面这几个好像不能用external,这几个只要说明是在本文件内就可以好了,IAR是PUBLIC,Keil是EXPORT,你可以再确认下,如果说得不对,请指正

出0入54汤圆

发表于 2014-4-19 19:49:59 | 显示全部楼层
第一个多了个#endif

出0入53汤圆

 楼主| 发表于 2014-4-21 09:19:50 | 显示全部楼层
lusson 发表于 2014-4-19 19:49
第一个多了个#endif

改正了一下,还是提示错误 不明白他说的意思
.\Obj\Project.sct(7): error: L6236E: No section matches selector - no section to be FIRST/LAST.
Not enough information to list image symbols.
Not enough information to list the image map.
Finished: 2 information, 0 warning and 1 error messages.
".\Obj\Project.axf" - 1 Error(s), 0 Warning(s).

错误指向了
LR_IROM1 0x1A000000 0x00080000  {    ; load region size_region
  ER_IROM1 0x1A000000 0x00080000  {  ; load address = execution address
   *.o (RESET, +First)    //错误指向此处
   *(InRoot$$Sections)
   .ANY (+RO)
  }
  RW_IRAM1 0x10000000 0x00008000  {  ; RW data
   .ANY (+RW +ZI)
  }
}

改正代码如下
  1. ;
  2. ;********************************************************************************************************
  3. ;                                                uC/OS-III
  4. ;                                          The Real-Time Kernel
  5. ;
  6. ;
  7. ;                              (c) Copyright 2010; Micrium, Inc.; Weston, FL
  8. ;                    All rights reserved.  Protected by international copyright laws.
  9. ;
  10. ;                                           ARM Cortex-M4 Port
  11. ;
  12. ; File      : OS_CPU_A.ASM
  13. ; Version   : V3.01.2
  14. ; By        : JJL
  15. ;             BAN
  16. ;
  17. ; For       : ARMv7 Cortex-M4
  18. ; Mode      : Thumb-2 ISA
  19. ; Toolchain : IAR EWARM
  20. ;********************************************************************************************************
  21. ;

  22. ;********************************************************************************************************
  23. ;                                          PUBLIC FUNCTIONS
  24. ;********************************************************************************************************

  25.         EXTERN  OSRunning                                           ; External references
  26.     EXTERN  OSPrioCur
  27.     EXTERN  OSPrioHighRdy
  28.     EXTERN  OSTCBCurPtr
  29.     EXTERN  OSTCBHighRdyPtr
  30.     EXTERN  OSIntExit
  31.     EXTERN  OSTaskSwHook
  32.     EXTERN  OS_CPU_ExceptStkBase


  33.     EXPORT  OSStartHighRdy                                      ; Functions declared in this file
  34.     EXPORT  OSCtxSw
  35.     EXPORT  OSIntCtxSw
  36.     EXPORT  OS_CPU_PendSVHandler

  37. ;IF {FPU} != "SoftVFP"
  38.     ;EXPORT  OS_CPU_FP_Reg_Push
  39.     ;EXPORT  OS_CPU_FP_Reg_Pop
  40.     ;ENDIF
  41. ;#ifdef __ARMVFP__
  42.     ;EXTERN  OS_CPU_FP_Reg_Push
  43.     ;EXTERN  OS_CPU_FP_Reg_Pop
  44. ;#endif

  45. ;PAGE
  46. ;********************************************************************************************************
  47. ;                                               EQUATES
  48. ;********************************************************************************************************

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


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

  56.         AREA |.text|, CODE, READONLY, ALIGN=2
  57.     THUMB
  58.     REQUIRE8
  59.     PRESERVE8

  60. ;#ifdef __ARMVFP__
  61. ;PAGE
  62. ;********************************************************************************************************
  63. ;                                   FLOATING POINT REGISTERS PUSH
  64. ;                             void  OS_CPU_FP_Reg_Push (CPU_STK  *stkPtr)
  65. ;
  66. ; Note(s) : 1) This function saves S0-S31, and FPSCR registers of the Floating Point Unit.
  67. ;
  68. ;           2) Pseudo-code is:
  69. ;              a) Get FPSCR register value;
  70. ;              b) Push value on process stack;
  71. ;              c) Push remaining regs S0-S31 on process stack;
  72. ;              d) Update OSTCBCurPtr->StkPtr;
  73. ;********************************************************************************************************

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

  77.     VMRS    R1, FPSCR
  78.     STR R1, [R0, #-4]!
  79.     VSTMDB  R0!, {S0-S31}
  80.     LDR     R1, =OSTCBCurPtr
  81.     LDR     R2, [R1]
  82.     STR     R0, [R2]
  83. OS_CPU_FP_nosave
  84.     BX      LR

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

  97. OS_CPU_FP_Reg_Pop
  98.     VLDMIA  R0!, {S0-S31}
  99.     LDMIA   R0!, {R1}
  100.     VMSR    FPSCR, R1
  101.     LDR     R1, =OSTCBHighRdyPtr
  102.     LDR     R2, [R1]
  103.     STR     R0, [R2]
  104.     BX      LR
  105. ;#endif

  106. ;PAGE
  107. ;********************************************************************************************************
  108. ;                                         START MULTITASKING
  109. ;                                      void OSStartHighRdy(void)
  110. ;
  111. ; Note(s) : 1) This function triggers a PendSV exception (essentially, causes a context switch) to cause
  112. ;              the first task to start.
  113. ;
  114. ;           2) OSStartHighRdy() MUST:
  115. ;              a) Setup PendSV exception priority to lowest;
  116. ;              b) Set initial PSP to 0, to tell context switcher this is first run;
  117. ;              c) Set the main stack to OS_CPU_ExceptStkBase
  118. ;              d) Trigger PendSV exception;
  119. ;              e) Enable interrupts (tasks will run with interrupts enabled).
  120. ;********************************************************************************************************

  121. OSStartHighRdy
  122.     LDR     R0, =NVIC_SYSPRI14                                  ; Set the PendSV exception priority
  123.     LDR     R1, =NVIC_PENDSV_PRI
  124.     STRB    R1, [R0]

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

  127.     LDR     R0, =OS_CPU_ExceptStkBase                           ; Initialize the MSP to the OS_CPU_ExceptStkBase
  128.     LDR     R1, [R0]
  129.     MSR     MSP, R1

  130.     LDR     R0, =NVIC_INT_CTRL                                  ; Trigger the PendSV exception (causes context switch)
  131.     LDR     R1, =NVIC_PENDSVSET
  132.     STR     R1, [R0]

  133.     CPSIE   I                                                   ; Enable interrupts at processor level

  134. OSStartHang
  135.     B       OSStartHang                                         ; Should never get here


  136. ;PAGE
  137. ;********************************************************************************************************
  138. ;                       PERFORM A CONTEXT SWITCH (From task level) - OSCtxSw()
  139. ;
  140. ; Note(s) : 1) OSCtxSw() is called when OS wants to perform a task context switch.  This function
  141. ;              triggers the PendSV exception which is where the real work is done.
  142. ;********************************************************************************************************

  143. OSCtxSw
  144.     LDR     R0, =NVIC_INT_CTRL                                  ; Trigger the PendSV exception (causes context switch)
  145.     LDR     R1, =NVIC_PENDSVSET
  146.     STR     R1, [R0]
  147.     BX      LR


  148. ;PAGE
  149. ;********************************************************************************************************
  150. ;                   PERFORM A CONTEXT SWITCH (From interrupt level) - OSIntCtxSw()
  151. ;
  152. ; Note(s) : 1) OSIntCtxSw() is called by OSIntExit() when it determines a context switch is needed as
  153. ;              the result of an interrupt.  This function simply triggers a PendSV exception which will
  154. ;              be handled when there are no more interrupts active and interrupts are enabled.
  155. ;********************************************************************************************************

  156. OSIntCtxSw
  157.     LDR     R0, =NVIC_INT_CTRL                                  ; Trigger the PendSV exception (causes context switch)
  158.     LDR     R1, =NVIC_PENDSVSET
  159.     STR     R1, [R0]
  160.     BX      LR


  161. ;PAGE
  162. ;********************************************************************************************************
  163. ;                                       HANDLE PendSV EXCEPTION
  164. ;                                   void OS_CPU_PendSVHandler(void)
  165. ;
  166. ; Note(s) : 1) PendSV is used to cause a context switch.  This is a recommended method for performing
  167. ;              context switches with Cortex-M3.  This is because the Cortex-M3 auto-saves half of the
  168. ;              processor context on any exception, and restores same on return from exception.  So only
  169. ;              saving of R4-R11 is required and fixing up the stack pointers.  Using the PendSV exception
  170. ;              this way means that context saving and restoring is identical whether it is initiated from
  171. ;              a thread or occurs due to an interrupt or exception.
  172. ;
  173. ;           2) Pseudo-code is:
  174. ;              a) Get the process SP, if 0 then skip (goto d) the saving part (first context switch);
  175. ;              b) Save remaining regs r4-r11 on process stack;
  176. ;              c) Save the process SP in its TCB, OSTCBCurPtr->OSTCBStkPtr = SP;
  177. ;              d) Call OSTaskSwHook();
  178. ;              e) Get current high priority, OSPrioCur = OSPrioHighRdy;
  179. ;              f) Get current ready thread TCB, OSTCBCurPtr = OSTCBHighRdyPtr;
  180. ;              g) Get new process SP from TCB, SP = OSTCBHighRdyPtr->OSTCBStkPtr;
  181. ;              h) Restore R4-R11 from new process stack;
  182. ;              i) Perform exception return which will restore remaining context.
  183. ;
  184. ;           3) On entry into PendSV handler:
  185. ;              a) The following have been saved on the process stack (by processor):
  186. ;                 xPSR, PC, LR, R12, R0-R3
  187. ;              b) Processor mode is switched to Handler mode (from Thread mode)
  188. ;              c) Stack is Main stack (switched from Process stack)
  189. ;              d) OSTCBCurPtr      points to the OS_TCB of the task to suspend
  190. ;                 OSTCBHighRdyPtr  points to the OS_TCB of the task to resume
  191. ;
  192. ;           4) Since PendSV is set to lowest priority in the system (by OSStartHighRdy() above), we
  193. ;              know that it will only be run when no other exception or interrupt is active, and
  194. ;              therefore safe to assume that context being switched out was using the process stack (PSP).
  195. ;********************************************************************************************************

  196. OS_CPU_PendSVHandler
  197.     CPSID   I                                                   ; Prevent interruption during context switch
  198.     MRS     R0, PSP                                             ; PSP is process stack pointer
  199.     CBZ     R0, OS_CPU_PendSVHandler_nosave                     ; Skip register save the first time

  200.     SUBS    R0, R0, #0x20                                       ; Save remaining regs r4-11 on process stack
  201.     STM     R0, {R4-R11}

  202.     LDR     R1, =OSTCBCurPtr                                    ; OSTCBCurPtr->OSTCBStkPtr = SP;
  203.     LDR     R1, [R1]
  204.     STR     R0, [R1]                                            ; R0 is SP of process being switched out

  205.                                                                 ; At this point, entire context of process has been saved
  206. OS_CPU_PendSVHandler_nosave
  207.     PUSH    {R14}                                               ; Save LR exc_return value
  208.     LDR     R0, =OSTaskSwHook                                   ; OSTaskSwHook();
  209.     BLX     R0
  210.     POP     {R14}

  211.     LDR     R0, =OSPrioCur                                      ; OSPrioCur   = OSPrioHighRdy;
  212.     LDR     R1, =OSPrioHighRdy
  213.     LDRB    R2, [R1]
  214.     STRB    R2, [R0]

  215.     LDR     R0, =OSTCBCurPtr                                    ; OSTCBCurPtr = OSTCBHighRdyPtr;
  216.     LDR     R1, =OSTCBHighRdyPtr
  217.     LDR     R2, [R1]
  218.     STR     R2, [R0]

  219.     LDR     R0, [R2]                                            ; R0 is new process SP; SP = OSTCBHighRdyPtr->StkPtr;
  220.     LDM     R0, {R4-R11}                                        ; Restore r4-11 from new process stack
  221.     ADDS    R0, R0, #0x20
  222.     MSR     PSP, R0                                             ; Load PSP with new process SP
  223.     ORR     LR, LR, #0x04                                       ; Ensure exception return uses process stack
  224.     CPSIE   I
  225.     BX      LR                                                  ; Exception return will restore remaining context

  226.     END
复制代码

出0入53汤圆

 楼主| 发表于 2014-4-23 11:22:27 | 显示全部楼层
zhcj66 发表于 2014-4-21 09:19
改正了一下,还是提示错误 不明白他说的意思
.\Obj\Project.sct(7): error: L6236E: No section matches  ...

LPC4357-UCOS III 移植成功

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

出0入0汤圆

发表于 2019-6-13 11:49:42 | 显示全部楼层
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-3-29 16:24

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

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