你好,游客 登录 注册 搜索
背景:
阅读新闻

UCOS_II的移植到S3C2440 ADS 1.2

[日期:2012-07-22] 来源:Linux社区  作者:k122769836 [字体:大 中 小]

对Os_cpu_c.c的修改:

  1. /*  
  2. *********************************************************************************************************  
  3. *                                               uC/OS-II  
  4. *                                        The Real-Time Kernel  
  5. *  
  6. *                           (c) Copyright 1992-2003, Micrium, Inc., Weston, FL  
  7. *                                          All Rights Reserved  
  8. *  
  9. *                                               ARM9 Port  
  10. *  
  11. * File : OS_CPU_C.C  
  12. *********************************************************************************************************  
  13. */  
  14.   
  15. //#define  OS_CPU_GLOBALS  
  16. #include "ucos_ii.h"  
  17.   
  18.   
  19. /*  
  20. *********************************************************************************************************  
  21. *                                        INITIALIZE A TASK'S STACK  
  22. *  
  23. * Description: This function is called by either OSTaskCreate() or OSTaskCreateExt() to initialize the  
  24. *              stack frame of the task being created.  This function is highly processor specific.  
  25. *  
  26. * Arguments  : task          is a pointer to the task code  
  27. *  
  28. *              p_arg         is a pointer to a user supplied data area that will be passed to the task  
  29. *                            when the task first executes.  
  30. *  
  31. *              ptos          is a pointer to the top of stack.  It is assumed that 'ptos' points to  
  32. *                            a 'free' entry on the task stack.  If OS_STK_GROWTH is set to 1 then   
  33. *                            'ptos' will contain the HIGHEST valid address of the stack.  Similarly, if  
  34. *                            OS_STK_GROWTH is set to 0, the 'ptos' will contains the LOWEST valid address  
  35. *                            of the stack.  
  36. *  
  37. *              opt           specifies options that can be used to alter the behavior of OSTaskStkInit().  
  38. *                            (see uCOS_II.H for OS_TASK_OPT_???).  
  39. *  
  40. * Returns    : Always returns the location of the new top-of-stack' once the processor registers have  
  41. *              been placed on the stack in the proper order.  
  42. *  
  43. * Note(s)    : 1) Interrupts are enabled when your task starts executing.   
  44. *              2) All tasks run in SVC mode.  
  45. *********************************************************************************************************  
  46. */  
  47.   
  48. OS_STK *OSTaskStkInit (void (*task)(void *pd), void *p_arg, OS_STK *ptos, INT16U opt)  
  49. {  
  50.     OS_STK *stk;  
  51.   
  52.     optopt      = opt;                 /* 'opt' is not used, prevent warning                      */  
  53.       
  54.     stk      = ptos;                /* Load stack pointer                                      */  
  55.       
  56.     *(stk)   = (OS_STK)task;        /* Entry Point                                             */  
  57.     *(--stk) = (INT32U)0;           /* LR                                                      */  
  58.     *(--stk) = (INT32U)0;           /* R12                                                     */  
  59.     *(--stk) = (INT32U)0;           /* R11                                                     */  
  60.     *(--stk) = (INT32U)0;           /* R10                                                     */  
  61.     *(--stk) = (INT32U)0;           /* R9                                                      */  
  62.     *(--stk) = (INT32U)0;           /* R8                                                      */  
  63.     *(--stk) = (INT32U)0;           /* R7                                                      */  
  64.     *(--stk) = (INT32U)0;           /* R6                                                      */  
  65.     *(--stk) = (INT32U)0;           /* R5                                                      */  
  66.     *(--stk) = (INT32U)0;           /* R4                                                      */  
  67.     *(--stk) = (INT32U)0;           /* R3                                                      */  
  68.     *(--stk) = (INT32U)0;           /* R2                                                      */  
  69.     *(--stk) = (INT32U)0;           /* R1                                                      */  
  70.     *(--stk) = (INT32U)p_arg;       /* R0 : argument                                           */  
  71.     *(--stk) = (INT32U)0x00000013L; /* CPSR  (SVC mode, Enable both IRQ and FIQ interrupts)    */  
  72.                                                
  73.     return (stk);  
  74. }  
  75.   
  76. #if OS_CPU_HOOKS_EN  
  77. /*  
  78. *********************************************************************************************************  
  79. *                                       OS INITIALIZATION HOOK  
  80. *                                            (BEGINNING)  
  81. *  
  82. * Description: This function is called by OSInit() at the beginning of OSInit().  
  83. *  
  84. * Arguments  : none  
  85. *  
  86. * Note(s)    : 1) Interrupts should be disabled during this call.  
  87. *********************************************************************************************************  
  88. */  
  89. #if OS_VERSION > 203  
  90. void OSInitHookBegin (void)  
  91. {  
  92. }  
  93. #endif  
  94.   
  95. /*  
  96. *********************************************************************************************************  
  97. *                                       OS INITIALIZATION HOOK  
  98. *                                               (END)  
  99. *  
  100. * Description: This function is called by OSInit() at the end of OSInit().  
  101. *  
  102. * Arguments  : none  
  103. *  
  104. * Note(s)    : 1) Interrupts should be disabled during this call.  
  105. *********************************************************************************************************  
  106. */  
  107. #if OS_VERSION > 203  
  108. void OSInitHookEnd (void)  
  109. {  
  110. }  
  111. #endif  
  112.   
  113.   
  114. /*  
  115. *********************************************************************************************************  
  116. *                                          TASK CREATION HOOK  
  117. *  
  118. * Description: This function is called when a task is created.  
  119. *  
  120. * Arguments  : ptcb   is a pointer to the task control block of the task being created.  
  121. *  
  122. * Note(s)    : 1) Interrupts are disabled during this call.  
  123. *********************************************************************************************************  
  124. */  
  125. void OSTaskCreateHook (OS_TCB *ptcb)  
  126. {  
  127.     ptcbptcb = ptcb;                       /* Prevent compiler warning                                     */  
  128. }  
  129.   
  130.   
  131. /*  
  132. *********************************************************************************************************  
  133. *                                           TASK DELETION HOOK  
  134. *  
  135. * Description: This function is called when a task is deleted.  
  136. *  
  137. * Arguments  : ptcb   is a pointer to the task control block of the task being deleted.  
  138. *  
  139. * Note(s)    : 1) Interrupts are disabled during this call.  
  140. *********************************************************************************************************  
  141. */  
  142. void OSTaskDelHook (OS_TCB *ptcb)  
  143. {  
  144.     ptcbptcb = ptcb;                       /* Prevent compiler warning                                     */  
  145. }  
  146.   
  147. /*  
  148. *********************************************************************************************************  
  149. *                                           TASK SWITCH HOOK  
  150. *  
  151. * Description: This function is called when a task switch is performed.  This allows you to perform other  
  152. *              operations during a context switch.  
  153. *  
  154. * Arguments  : none  
  155. *  
  156. * Note(s)    : 1) Interrupts are disabled during this call.  
  157. *              2) It is assumed that the global pointer 'OSTCBHighRdy' points to the TCB of the task that  
  158. *                 will be 'switched in' (i.e. the highest priority task) and, 'OSTCBCur' points to the   
  159. *                 task being switched out (i.e. the preempted task).  
  160. *********************************************************************************************************  
  161. */  
  162. void OSTaskSwHook (void)  
  163. {  
  164. }  
  165.   
  166. /*  
  167. *********************************************************************************************************  
  168. *                                           STATISTIC TASK HOOK  
  169. *  
  170. * Description: This function is called every second by uC/OS-II's statistics task.  This allows your   
  171. *              application to add functionality to the statistics task.  
  172. *  
  173. * Arguments  : none  
  174. *********************************************************************************************************  
  175. */  
  176. void OSTaskStatHook (void)  
  177. {  
  178. }  
  179.   
  180. /*  
  181. *********************************************************************************************************  
  182. *                                           OSTCBInit() HOOK  
  183. *  
  184. * Description: This function is called by OSTCBInit() after setting up most of the TCB.  
  185. *  
  186. * Arguments  : ptcb    is a pointer to the TCB of the task being created.  
  187. *  
  188. * Note(s)    : 1) Interrupts may or may not be ENABLED during this call.  
  189. *********************************************************************************************************  
  190. */  
  191. #if OS_VERSION > 203  
  192. void OSTCBInitHook (OS_TCB *ptcb)  
  193. {  
  194.     ptcbptcb = ptcb;                                           /* Prevent Compiler warning                 */  
  195. }  
  196. #endif  
  197.   
  198.   
  199. /*  
  200. *********************************************************************************************************  
  201. *                                               TICK HOOK  
  202. *  
  203. * Description: This function is called every tick.  
  204. *  
  205. * Arguments  : none  
  206. *  
  207. * Note(s)    : 1) Interrupts may or may not be ENABLED during this call.  
  208. *********************************************************************************************************  
  209. */  
  210. void OSTimeTickHook (void)  
  211. {  
  212. }  
  213.   
  214.   
  215. /*  
  216. *********************************************************************************************************  
  217. *                                             IDLE TASK HOOK  
  218. *  
  219. * Description: This function is called by the idle task.  This hook has been added to allow you to do    
  220. *              such things as STOP the CPU to conserve power.  
  221. *  
  222. * Arguments  : none  
  223. *  
  224. * Note(s)    : 1) Interrupts are enabled during this call.  
  225. *********************************************************************************************************  
  226. */  
  227. #if OS_VERSION >= 251  
  228. void OSTaskIdleHook (void)  
  229. {  
  230. }  
  231. #endif  
  232.   
  233. #endif  

 

 

  1. /*  
  2. *********************************************************************************************************  
  3. *                                               uC/OS-II  
  4. *                                        The Real-Time Kernel  
  5. *  
  6. *                           (c) Copyright 1992-2003, Micrium, Inc., Weston, FL  
  7. *                                          All Rights Reserved  
  8. *  
  9. *                                               ARM9 Port  
  10. *  
  11. * File : OS_CPU_C.C  
  12. *********************************************************************************************************  
  13. */  
  14.   
  15. //#define  OS_CPU_GLOBALS  
  16. #include "ucos_ii.h"  
  17.   
  18.   
  19. /*  
  20. *********************************************************************************************************  
  21. *                                        INITIALIZE A TASK'S STACK  
  22. *  
  23. * Description: This function is called by either OSTaskCreate() or OSTaskCreateExt() to initialize the  
  24. *              stack frame of the task being created.  This function is highly processor specific.  
  25. *  
  26. * Arguments  : task          is a pointer to the task code  
  27. *  
  28. *              p_arg         is a pointer to a user supplied data area that will be passed to the task  
  29. *                            when the task first executes.  
  30. *  
  31. *              ptos          is a pointer to the top of stack.  It is assumed that 'ptos' points to  
  32. *                            a 'free' entry on the task stack.  If OS_STK_GROWTH is set to 1 then   
  33. *                            'ptos' will contain the HIGHEST valid address of the stack.  Similarly, if  
  34. *                            OS_STK_GROWTH is set to 0, the 'ptos' will contains the LOWEST valid address  
  35. *                            of the stack.  
  36. *  
  37. *              opt           specifies options that can be used to alter the behavior of OSTaskStkInit().  
  38. *                            (see uCOS_II.H for OS_TASK_OPT_???).  
  39. *  
  40. * Returns    : Always returns the location of the new top-of-stack' once the processor registers have  
  41. *              been placed on the stack in the proper order.  
  42. *  
  43. * Note(s)    : 1) Interrupts are enabled when your task starts executing.   
  44. *              2) All tasks run in SVC mode.  
  45. *********************************************************************************************************  
  46. */  
  47.   
  48. OS_STK *OSTaskStkInit (void (*task)(void *pd), void *p_arg, OS_STK *ptos, INT16U opt)  
  49. {  
  50.     OS_STK *stk;  
  51.   
  52.     opt      = opt;                 /* 'opt' is not used, prevent warning                      */  
  53.       
  54.     stk      = ptos;                /* Load stack pointer                                      */  
  55.       
  56.     *(stk)   = (OS_STK)task;        /* Entry Point                                             */  
  57.     *(--stk) = (INT32U)0;           /* LR                                                      */  
  58.     *(--stk) = (INT32U)0;           /* R12                                                     */  
  59.     *(--stk) = (INT32U)0;           /* R11                                                     */  
  60.     *(--stk) = (INT32U)0;           /* R10                                                     */  
  61.     *(--stk) = (INT32U)0;           /* R9                                                      */  
  62.     *(--stk) = (INT32U)0;           /* R8                                                      */  
  63.     *(--stk) = (INT32U)0;           /* R7                                                      */  
  64.     *(--stk) = (INT32U)0;           /* R6                                                      */  
  65.     *(--stk) = (INT32U)0;           /* R5                                                      */  
  66.     *(--stk) = (INT32U)0;           /* R4                                                      */  
  67.     *(--stk) = (INT32U)0;           /* R3                                                      */  
  68.     *(--stk) = (INT32U)0;           /* R2                                                      */  
  69.     *(--stk) = (INT32U)0;           /* R1                                                      */  
  70.     *(--stk) = (INT32U)p_arg;       /* R0 : argument                                           */  
  71.     *(--stk) = (INT32U)0x00000013L; /* CPSR  (SVC mode, Enable both IRQ and FIQ interrupts)    */  
  72.                                                
  73.     return (stk);  
  74. }  
  75.   
  76. #if OS_CPU_HOOKS_EN  
  77. /*  
  78. *********************************************************************************************************  
  79. *                                       OS INITIALIZATION HOOK  
  80. *                                            (BEGINNING)  
  81. *  
  82. * Description: This function is called by OSInit() at the beginning of OSInit().  
  83. *  
  84. * Arguments  : none  
  85. *  
  86. * Note(s)    : 1) Interrupts should be disabled during this call.  
  87. *********************************************************************************************************  
  88. */  
  89. #if OS_VERSION > 203  
  90. void OSInitHookBegin (void)  
  91. {  
  92. }  
  93. #endif  
  94.   
  95. /*  
  96. *********************************************************************************************************  
  97. *                                       OS INITIALIZATION HOOK  
  98. *                                               (END)  
  99. *  
  100. * Description: This function is called by OSInit() at the end of OSInit().  
  101. *  
  102. * Arguments  : none  
  103. *  
  104. * Note(s)    : 1) Interrupts should be disabled during this call.  
  105. *********************************************************************************************************  
  106. */  
  107. #if OS_VERSION > 203  
  108. void OSInitHookEnd (void)  
  109. {  
  110. }  
  111. #endif  
  112.   
  113.   
  114. /*  
  115. *********************************************************************************************************  
  116. *                                          TASK CREATION HOOK  
  117. *  
  118. * Description: This function is called when a task is created.  
  119. *  
  120. * Arguments  : ptcb   is a pointer to the task control block of the task being created.  
  121. *  
  122. * Note(s)    : 1) Interrupts are disabled during this call.  
  123. *********************************************************************************************************  
  124. */  
  125. void OSTaskCreateHook (OS_TCB *ptcb)  
  126. {  
  127.     ptcb = ptcb;                       /* Prevent compiler warning                                     */  
  128. }  
  129.   
  130.   
  131. /*  
  132. *********************************************************************************************************  
  133. *                                           TASK DELETION HOOK  
  134. *  
  135. * Description: This function is called when a task is deleted.  
  136. *  
  137. * Arguments  : ptcb   is a pointer to the task control block of the task being deleted.  
  138. *  
  139. * Note(s)    : 1) Interrupts are disabled during this call.  
  140. *********************************************************************************************************  
  141. */  
  142. void OSTaskDelHook (OS_TCB *ptcb)  
  143. {  
  144.     ptcb = ptcb;                       /* Prevent compiler warning                                     */  
  145. }  
  146.   
  147. /*  
  148. *********************************************************************************************************  
  149. *                                           TASK SWITCH HOOK  
  150. *  
  151. * Description: This function is called when a task switch is performed.  This allows you to perform other  
  152. *              operations during a context switch.  
  153. *  
  154. * Arguments  : none  
  155. *  
  156. * Note(s)    : 1) Interrupts are disabled during this call.  
  157. *              2) It is assumed that the global pointer 'OSTCBHighRdy' points to the TCB of the task that  
  158. *                 will be 'switched in' (i.e. the highest priority task) and, 'OSTCBCur' points to the   
  159. *                 task being switched out (i.e. the preempted task).  
  160. *********************************************************************************************************  
  161. */  
  162. void OSTaskSwHook (void)  
  163. {  
  164. }  
  165.   
  166. /*  
  167. *********************************************************************************************************  
  168. *                                           STATISTIC TASK HOOK  
  169. *  
  170. * Description: This function is called every second by uC/OS-II's statistics task.  This allows your   
  171. *              application to add functionality to the statistics task.  
  172. *  
  173. * Arguments  : none  
  174. *********************************************************************************************************  
  175. */  
  176. void OSTaskStatHook (void)  
  177. {  
  178. }  
  179.   
  180. /*  
  181. *********************************************************************************************************  
  182. *                                           OSTCBInit() HOOK  
  183. *  
  184. * Description: This function is called by OSTCBInit() after setting up most of the TCB.  
  185. *  
  186. * Arguments  : ptcb    is a pointer to the TCB of the task being created.  
  187. *  
  188. * Note(s)    : 1) Interrupts may or may not be ENABLED during this call.  
  189. *********************************************************************************************************  
  190. */  
  191. #if OS_VERSION > 203  
  192. void OSTCBInitHook (OS_TCB *ptcb)  
  193. {  
  194.     ptcb = ptcb;                                           /* Prevent Compiler warning                 */  
  195. }  
  196. #endif  
  197.   
  198.   
  199. /*  
  200. *********************************************************************************************************  
  201. *                                               TICK HOOK  
  202. *  
  203. * Description: This function is called every tick.  
  204. *  
  205. * Arguments  : none  
  206. *  
  207. * Note(s)    : 1) Interrupts may or may not be ENABLED during this call.  
  208. *********************************************************************************************************  
  209. */  
  210. void OSTimeTickHook (void)  
  211. {  
  212. }  
  213.   
  214.   
  215. /*  
  216. *********************************************************************************************************  
  217. *                                             IDLE TASK HOOK  
  218. *  
  219. * Description: This function is called by the idle task.  This hook has been added to allow you to do    
  220. *              such things as STOP the CPU to conserve power.  
  221. *  
  222. * Arguments  : none  
  223. *  
  224. * Note(s)    : 1) Interrupts are enabled during this call.  
  225. *********************************************************************************************************  
  226. */  
  227. #if OS_VERSION >= 251  
  228. void OSTaskIdleHook (void)  
  229. {  
  230. }  
  231. #endif  
  232.   
  233. #endif  
linux
相关资讯       S3C2440  UCOS_II  UCOS 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款