⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 os_cpu_c.lst

📁 针对STM32F103的UCOS移植
💻 LST
📖 第 1 页 / 共 2 页
字号:
    163          *
    164          * Description: This function is called by either OSTaskCreate() or OSTaskCreateExt() to initialize the
    165          *              stack frame of the task being created.  This function is highly processor specific.
    166          *
    167          * Arguments  : task          is a pointer to the task code
    168          *
    169          *              p_arg         is a pointer to a user supplied data area that will be passed to the task
    170          *                            when the task first executes.
    171          *
    172          *              ptos          is a pointer to the top of stack.  It is assumed that 'ptos' points to
    173          *                            a 'free' entry on the task stack.  If OS_STK_GROWTH is set to 1 then
    174          *                            'ptos' will contain the HIGHEST valid address of the stack.  Similarly, if
    175          *                            OS_STK_GROWTH is set to 0, the 'ptos' will contains the LOWEST valid address
    176          *                            of the stack.
    177          *
    178          *              opt           specifies options that can be used to alter the behavior of OSTaskStkInit().
    179          *                            (see uCOS_II.H for OS_TASK_OPT_xxx).
    180          *
    181          * Returns    : Always returns the location of the new top-of-stack' once the processor registers have
    182          *              been placed on the stack in the proper order.
    183          *
    184          * Note(s)    : 1) Interrupts are enabled when your task starts executing.
    185          *              2) All tasks run in Thread mode, using process stack.
    186          *********************************************************************************************************
    187          */
    188          

   \                                 In segment CODE, align 4, keep-with-next
    189          OS_STK *OSTaskStkInit (void (*task)(void *p_arg), void *p_arg, OS_STK *ptos, INT16U opt)
    190          {
    191              OS_STK *stk;
    192          
    193          
    194              (void)opt;                                 /* 'opt' is not used, prevent warning                     */
    195              stk       = ptos;                          /* Load stack pointer                                     */
    196          
    197                                                         /* Registers stacked as if auto-saved on exception        */
    198              *(stk)    = (INT32U)0x01000000L;           /* xPSR                                                   */
   \                     OSTaskStkInit:
   \   00000000   5FF08073           MOVS     R3,#+16777216
   \   00000004   1360               STR      R3,[R2, #+0]
    199              *(--stk)  = (INT32U)task;                  /* Entry Point                                            */
   \   00000006   121F               SUBS     R2,R2,#+4
   \   00000008   1060               STR      R0,[R2, #+0]
    200              *(--stk)  = (INT32U)0xFFFFFFFEL;           /* R14 (LR) (init value will cause fault if ever used)    */
   \   0000000A   121F               SUBS     R2,R2,#+4
   \   0000000C   7FF00100           MVNS     R0,#+1
   \   00000010   1060               STR      R0,[R2, #+0]
    201              *(--stk)  = (INT32U)0x12121212L;           /* R12                                                    */
   \   00000012   121F               SUBS     R2,R2,#+4
   \   00000014   5FF01230           MOVS     R0,#+303174162
   \   00000018   1060               STR      R0,[R2, #+0]
    202              *(--stk)  = (INT32U)0x03030303L;           /* R3                                                     */
   \   0000001A   121F               SUBS     R2,R2,#+4
   \   0000001C   5FF00330           MOVS     R0,#+50529027
   \   00000020   1060               STR      R0,[R2, #+0]
    203              *(--stk)  = (INT32U)0x02020202L;           /* R2                                                     */
   \   00000022   121F               SUBS     R2,R2,#+4
   \   00000024   5FF00230           MOVS     R0,#+33686018
   \   00000028   1060               STR      R0,[R2, #+0]
    204              *(--stk)  = (INT32U)0x01010101L;           /* R1                                                     */
   \   0000002A   121F               SUBS     R2,R2,#+4
   \   0000002C   4008               LSRS     R0,R0,#+1
   \   0000002E   1060               STR      R0,[R2, #+0]
    205              *(--stk)  = (INT32U)p_arg;                 /* R0 : argument                                          */
   \   00000030   121F               SUBS     R2,R2,#+4
   \   00000032   1160               STR      R1,[R2, #+0]
    206          
    207                                                         /* Remaining registers saved on process stack             */
    208              *(--stk)  = (INT32U)0x11111111L;           /* R11                                                    */
   \   00000034   121F               SUBS     R2,R2,#+4
   \   00000036   5FF01130           MOVS     R0,#+286331153
   \   0000003A   1060               STR      R0,[R2, #+0]
    209              *(--stk)  = (INT32U)0x10101010L;           /* R10                                                    */
   \   0000003C   121F               SUBS     R2,R2,#+4
   \   0000003E   5FF01030           MOVS     R0,#+269488144
   \   00000042   1060               STR      R0,[R2, #+0]
    210              *(--stk)  = (INT32U)0x09090909L;           /* R9                                                     */
   \   00000044   121F               SUBS     R2,R2,#+4
   \   00000046   5FF00930           MOVS     R0,#+151587081
   \   0000004A   1060               STR      R0,[R2, #+0]
    211              *(--stk)  = (INT32U)0x08080808L;           /* R8                                                     */
   \   0000004C   121F               SUBS     R2,R2,#+4
   \   0000004E   5FF00830           MOVS     R0,#+134744072
   \   00000052   1060               STR      R0,[R2, #+0]
    212              *(--stk)  = (INT32U)0x07070707L;           /* R7                                                     */
   \   00000054   121F               SUBS     R2,R2,#+4
   \   00000056   5FF00730           MOVS     R0,#+117901063
   \   0000005A   1060               STR      R0,[R2, #+0]
    213              *(--stk)  = (INT32U)0x06060606L;           /* R6                                                     */
   \   0000005C   121F               SUBS     R2,R2,#+4
   \   0000005E   5FF00630           MOVS     R0,#+101058054
   \   00000062   1060               STR      R0,[R2, #+0]
    214              *(--stk)  = (INT32U)0x05050505L;           /* R5                                                     */
   \   00000064   121F               SUBS     R2,R2,#+4
   \   00000066   5FF00530           MOVS     R0,#+84215045
   \   0000006A   1060               STR      R0,[R2, #+0]
    215              *(--stk)  = (INT32U)0x04040404L;           /* R4                                                     */
   \   0000006C   121F               SUBS     R2,R2,#+4
   \   0000006E   5FF00430           MOVS     R0,#+67372036
   \   00000072   1060               STR      R0,[R2, #+0]
    216          
    217              return (stk);
   \   00000074   1000               MOVS     R0,R2
   \   00000076   7047               BX       LR               ;; return
    218          }
    219          
    220          /*
    221          *********************************************************************************************************
    222          *                                           TASK SWITCH HOOK
    223          *
    224          * Description: This function is called when a task switch is performed.  This allows you to perform other
    225          *              operations during a context switch.
    226          *
    227          * Arguments  : none
    228          *
    229          * Note(s)    : 1) Interrupts are disabled during this call.
    230          *              2) It is assumed that the global pointer 'OSTCBHighRdy' points to the TCB of the task that
    231          *                 will be 'switched in' (i.e. the highest priority task) and, 'OSTCBCur' points to the
    232          *                 task being switched out (i.e. the preempted task).
    233          *********************************************************************************************************
    234          */
    235          #if (OS_CPU_HOOKS_EN > 0) && (OS_TASK_SW_HOOK_EN > 0)

   \                                 In segment CODE, align 4, keep-with-next
    236          void  OSTaskSwHook (void)
    237          {
   \                     OSTaskSwHook:
   \   00000000   00B5               PUSH     {LR}
    238          #if OS_APP_HOOKS_EN > 0
    239              App_TaskSwHook();
   \   00000002   ........           _BLF     App_TaskSwHook,??App_TaskSwHook??rT
    240          #endif
    241          }
   \   00000006   00BD               POP      {PC}             ;; return
    242          #endif
    243          
    244          /*
    245          *********************************************************************************************************
    246          *                                           OS_TCBInit() HOOK
    247          *
    248          * Description: This function is called by OS_TCBInit() after setting up most of the TCB.
    249          *
    250          * Arguments  : ptcb    is a pointer to the TCB of the task being created.
    251          *
    252          * Note(s)    : 1) Interrupts may or may not be ENABLED during this call.
    253          *********************************************************************************************************
    254          */
    255          #if OS_CPU_HOOKS_EN > 0 && OS_VERSION > 203

   \                                 In segment CODE, align 4, keep-with-next
    256          void  OSTCBInitHook (OS_TCB *ptcb)
    257          {
   \                     OSTCBInitHook:
   \   00000000   00B5               PUSH     {LR}
    258          #if OS_APP_HOOKS_EN > 0
    259              App_TCBInitHook(ptcb);
   \   00000002   ........           _BLF     App_TCBInitHook,??App_TCBInitHook??rT
    260          #else
    261              (void)ptcb;                                                         /* Prevent compiler warning                                 */
    262          #endif
    263          }
   \   00000006   00BD               POP      {PC}             ;; return
    264          #endif
    265          
    266          
    267          /*
    268          *********************************************************************************************************
    269          *                                               TICK HOOK
    270          *
    271          * Description: This function is called every tick.
    272          *
    273          * Arguments  : none
    274          *
    275          * Note(s)    : 1) Interrupts may or may not be ENABLED during this call.
    276          *********************************************************************************************************
    277          */
    278          #if (OS_CPU_HOOKS_EN > 0) && (OS_TIME_TICK_HOOK_EN > 0)

   \                                 In segment CODE, align 4, keep-with-next
    279          void  OSTimeTickHook (void)
    280          {
   \                     OSTimeTickHook:
   \   00000000   00B5               PUSH     {LR}
    281          #if OS_APP_HOOKS_EN > 0
    282              App_TimeTickHook();
   \   00000002   ........           _BLF     App_TimeTickHook,??App_TimeTickHook??rT
    283          #endif
    284          
    285          #if OS_TMR_EN > 0
    286              OSTmrCtr++;
   \   00000006   ....               LDR.N    R0,??DataTable1  ;; OSTmrCtr
   \   00000008   0188               LDRH     R1,[R0, #+0]
   \   0000000A   491C               ADDS     R1,R1,#+1
   \   0000000C   0180               STRH     R1,[R0, #+0]
    287              if (OSTmrCtr >= (OS_TICKS_PER_SEC / OS_TMR_CFG_TICKS_PER_SEC)) {
   \   0000000E   89B2               UXTH     R1,R1
   \   00000010   0A29               CMP      R1,#+10
   \   00000012   03D3               BCC.N    ??OSTimeTickHook_0
    288                  OSTmrCtr = 0;
   \   00000014   0021               MOVS     R1,#+0
   \   00000016   0180               STRH     R1,[R0, #+0]
    289                  OSTmrSignal();
   \   00000018   ........           _BLF     OSTmrSignal,??OSTmrSignal??rT
    290              }
    291          #endif
    292          }
   \                     ??OSTimeTickHook_0:
   \   0000001C   00BD               POP      {PC}             ;; return

   \                                 In segment CODE, align 4, keep-with-next
   \                     ??DataTable1:
   \   00000000   ........           DC32     OSTmrCtr
    293          #endif

   Maximum stack usage in bytes:

     Function         CSTACK
     --------         ------
     OSInitHookBegin      0
     OSInitHookEnd        0
     OSTCBInitHook        4
     OSTaskCreateHook     4
     OSTaskDelHook        4
     OSTaskIdleHook       4
     OSTaskStatHook       4
     OSTaskStkInit        0
     OSTaskSwHook         4
     OSTimeTickHook       4


   Segment part sizes:

     Function/Label   Bytes
     --------------   -----
     OSTmrCtr            2
     OSInitHookBegin     8
     OSInitHookEnd       2
     OSTaskCreateHook    8
     OSTaskDelHook       8
     OSTaskIdleHook      8
     OSTaskStatHook      8
     OSTaskStkInit     120
     OSTaskSwHook        8
     OSTCBInitHook       8
     OSTimeTickHook     30
     ??DataTable1        4
      Others            76

 
 276 bytes in segment CODE
   2 bytes in segment DATA_Z
  12 bytes in segment INITTAB
 
 212 bytes of CODE memory (+ 76 bytes shared)
   2 bytes of DATA memory

Errors: none
Warnings: none

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -