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

📄 os_task.txt

📁 stm32 ucos 精简移殖版本 不需作任何修改直接便可运行。包含串口 定时器
💻 TXT
📖 第 1 页 / 共 5 页
字号:
                  OSTaskCreate PROC
;;;215    INT8U  OSTaskCreate (void (*task)(void *p_arg), void *p_arg, OS_STK *ptos, INT8U prio)
;;;216    {
000148  e92de92d          PUSH     {r1-r9,lr}
00014c  4605              MOV      r5,r0
00014e  460f              MOV      r7,r1
000150  4690              MOV      r8,r2
000152  461c              MOV      r4,r3
;;;217        OS_STK    *psp;
;;;218        INT8U      err;
;;;219    #if OS_CRITICAL_METHOD == 3                  /* Allocate storage for CPU status register               */
;;;220        OS_CPU_SR  cpu_sr = 0;
;;;221    #endif
;;;222    
;;;223    
;;;224    
;;;225    #if OS_ARG_CHK_EN > 0
;;;226        if (prio > OS_LOWEST_PRIO) {             /* Make sure priority is within allowable range           */
;;;227            return (OS_ERR_PRIO_INVALID);
;;;228        }
;;;229    #endif
;;;230        OS_ENTER_CRITICAL();
000154  f7fff7ff          BL       OS_CPU_SR_Save
;;;231        if (OSIntNesting > 0) {                  /* Make sure we don't create the task from within an ISR  */
000158  49ac              LDR      r1,|L1.1036|
00015a  7809              LDRB     r1,[r1,#0]  ; OSIntNesting
00015c  b121              CBZ      r1,|L1.360|
;;;232            OS_EXIT_CRITICAL();
00015e  f7fff7ff          BL       OS_CPU_SR_Restore
;;;233            return (OS_ERR_TASK_CREATE_ISR);
000162  203c              MOVS     r0,#0x3c
                  |L1.356|
;;;234        }
;;;235        if (OSTCBPrioTbl[prio] == (OS_TCB *)0) { /* Make sure task doesn't already exist at this priority  */
;;;236            OSTCBPrioTbl[prio] = OS_TCB_RESERVED;/* Reserve the priority to prevent others from doing ...  */
;;;237                                                 /* ... the same thing until task is created.              */
;;;238            OS_EXIT_CRITICAL();
;;;239            psp = OSTaskStkInit(task, p_arg, ptos, 0);              /* Initialize the task's stack         */
;;;240            err = OS_TCBInit(prio, psp, (OS_STK *)0, 0, 0, (void *)0, 0);
;;;241            if (err == OS_ERR_NONE) {
;;;242                if (OSRunning == OS_TRUE) {      /* Find highest priority task if multitasking has started */
;;;243                    OS_Sched();
;;;244                }
;;;245            } else {
;;;246                OS_ENTER_CRITICAL();
;;;247                OSTCBPrioTbl[prio] = (OS_TCB *)0;/* Make this priority available to others                 */
;;;248                OS_EXIT_CRITICAL();
;;;249            }
;;;250            return (err);
;;;251        }
;;;252        OS_EXIT_CRITICAL();
;;;253        return (OS_ERR_PRIO_EXIST);
;;;254    }
000164  e8bde8bd          POP      {r1-r9,pc}
                  |L1.360|
000168  4ea3              LDR      r6,|L1.1016|
00016a  f856f856          LDR      r1,[r6,r4,LSL #2]     ;235
00016e  bb29              CBNZ     r1,|L1.444|
000170  2101              MOVS     r1,#1                 ;236
000172  f846f846          STR      r1,[r6,r4,LSL #2]     ;236
000176  f7fff7ff          BL       OS_CPU_SR_Restore
00017a  2300              MOVS     r3,#0                 ;239
00017c  4642              MOV      r2,r8                 ;239
00017e  4639              MOV      r1,r7                 ;239
000180  4628              MOV      r0,r5                 ;239
000182  f7fff7ff          BL       OSTaskStkInit
000186  2300              MOVS     r3,#0                 ;240
000188  4601              MOV      r1,r0                 ;240
00018a  9300              STR      r3,[sp,#0]            ;240
00018c  9301              STR      r3,[sp,#4]            ;240
00018e  461a              MOV      r2,r3                 ;240
000190  4620              MOV      r0,r4                 ;240
000192  9302              STR      r3,[sp,#8]            ;240
000194  f7fff7ff          BL       OS_TCBInit
000198  4605              MOV      r5,r0                 ;240
00019a  b935              CBNZ     r5,|L1.426|
00019c  489a              LDR      r0,|L1.1032|
00019e  7800              LDRB     r0,[r0,#0]            ;242  ; OSRunning
0001a0  2801              CMP      r0,#1                 ;242
0001a2  d109              BNE      |L1.440|
0001a4  f7fff7ff          BL       OS_Sched
0001a8  e006              B        |L1.440|
                  |L1.426|
0001aa  f7fff7ff          BL       OS_CPU_SR_Save
0001ae  2100              MOVS     r1,#0                 ;247
0001b0  f846f846          STR      r1,[r6,r4,LSL #2]     ;247
0001b4  f7fff7ff          BL       OS_CPU_SR_Restore
                  |L1.440|
0001b8  4628              MOV      r0,r5                 ;250
0001ba  e7d3              B        |L1.356|
                  |L1.444|
0001bc  f7fff7ff          BL       OS_CPU_SR_Restore
0001c0  2028              MOVS     r0,#0x28              ;253
0001c2  e7cf              B        |L1.356|
;;;255    #endif
                          ENDP

                  OS_TaskStkClr PROC
;;;1077   {
;;;1078       if ((opt & OS_TASK_OPT_STK_CHK) != 0x0000) {       /* See if stack checking has been enabled       */
0001c4  07d3              LSLS     r3,r2,#31
0001c6  d007              BEQ      |L1.472|
;;;1079           if ((opt & OS_TASK_OPT_STK_CLR) != 0x0000) {   /* See if stack needs to be cleared             */
0001c8  0792              LSLS     r2,r2,#30
0001ca  d505              BPL      |L1.472|
0001cc  2200              MOVS     r2,#0
0001ce  e001              B        |L1.468|
                  |L1.464|
;;;1080   #if OS_STK_GROWTH == 1
;;;1081               while (size > 0) {                         /* Stack grows from HIGH to LOW memory          */
;;;1082                   size--;
0001d0  1e49              SUBS     r1,r1,#1
;;;1083                   *pbos++ = (OS_STK)0;                   /* Clear from bottom of stack and up!           */
0001d2  c004              STM      r0!,{r2}
                  |L1.468|
0001d4  2900              CMP      r1,#0                 ;1081
0001d6  d1fb              BNE      |L1.464|
                  |L1.472|
;;;1084               }
;;;1085   #else
;;;1086               while (size > 0) {                         /* Stack grows from LOW to HIGH memory          */
;;;1087                   size--;
;;;1088                   *pbos-- = (OS_STK)0;                   /* Clear from bottom of stack and down          */
;;;1089               }
;;;1090   #endif
;;;1091           }
;;;1092       }
;;;1093   }
0001d8  4770              BX       lr
;;;1094   
                          ENDP

                  OSTaskCreateExt PROC
;;;336                            INT16U   opt)
;;;337    {
0001da  e92de92d          PUSH     {r1-r11,lr}
0001de  e9dde9dd          LDRD     r10,r11,[sp,#0x34]
0001e2  4606              MOV      r6,r0
0001e4  460f              MOV      r7,r1
0001e6  4690              MOV      r8,r2
0001e8  461c              MOV      r4,r3
0001ea  f8ddf8dd          LDR      r9,[sp,#0x30]
;;;338        OS_STK    *psp;
;;;339        INT8U      err;
;;;340    #if OS_CRITICAL_METHOD == 3                  /* Allocate storage for CPU status register               */
;;;341        OS_CPU_SR  cpu_sr = 0;
;;;342    #endif
;;;343    
;;;344    
;;;345    
;;;346    #if OS_ARG_CHK_EN > 0
;;;347        if (prio > OS_LOWEST_PRIO) {             /* Make sure priority is within allowable range           */
;;;348            return (OS_ERR_PRIO_INVALID);
;;;349        }
;;;350    #endif
;;;351        OS_ENTER_CRITICAL();
0001ee  f7fff7ff          BL       OS_CPU_SR_Save
;;;352        if (OSIntNesting > 0) {                  /* Make sure we don't create the task from within an ISR  */
0001f2  4986              LDR      r1,|L1.1036|
0001f4  7809              LDRB     r1,[r1,#0]  ; OSIntNesting
0001f6  b121              CBZ      r1,|L1.514|
;;;353            OS_EXIT_CRITICAL();
0001f8  f7fff7ff          BL       OS_CPU_SR_Restore
;;;354            return (OS_ERR_TASK_CREATE_ISR);
0001fc  203c              MOVS     r0,#0x3c
                  |L1.510|
;;;355        }
;;;356        if (OSTCBPrioTbl[prio] == (OS_TCB *)0) { /* Make sure task doesn't already exist at this priority  */
;;;357            OSTCBPrioTbl[prio] = OS_TCB_RESERVED;/* Reserve the priority to prevent others from doing ...  */
;;;358                                                 /* ... the same thing until task is created.              */
;;;359            OS_EXIT_CRITICAL();
;;;360    
;;;361    #if (OS_TASK_STAT_STK_CHK_EN > 0)
;;;362            OS_TaskStkClr(pbos, stk_size, opt);                    /* Clear the task stack (if needed)     */
;;;363    #endif
;;;364    
;;;365            psp = OSTaskStkInit(task, p_arg, ptos, opt);           /* Initialize the task's stack          */
;;;366            err = OS_TCBInit(prio, psp, pbos, id, stk_size, pext, opt);
;;;367            if (err == OS_ERR_NONE) {
;;;368                if (OSRunning == OS_TRUE) {                        /* Find HPT if multitasking has started */
;;;369                    OS_Sched();
;;;370                }
;;;371            } else {
;;;372                OS_ENTER_CRITICAL();
;;;373                OSTCBPrioTbl[prio] = (OS_TCB *)0;                  /* Make this priority avail. to others  */
;;;374                OS_EXIT_CRITICAL();
;;;375            }
;;;376            return (err);
;;;377        }
;;;378        OS_EXIT_CRITICAL();
;;;379        return (OS_ERR_PRIO_EXIST);
;;;380    }
0001fe  e8bde8bd          POP      {r1-r11,pc}
                  |L1.514|
000202  4d7d              LDR      r5,|L1.1016|
000204  f855f855          LDR      r1,[r5,r4,LSL #2]     ;356
000208  bb61              CBNZ     r1,|L1.612|
00020a  2101              MOVS     r1,#1                 ;357
00020c  f845f845          STR      r1,[r5,r4,LSL #2]     ;357
000210  f7fff7ff          BL       OS_CPU_SR_Restore
000214  4659              MOV      r1,r11                ;362
000216  4650              MOV      r0,r10                ;362
000218  9a10              LDR      r2,[sp,#0x40]         ;362
00021a  f7fff7ff          BL       OS_TaskStkClr
00021e  4642              MOV      r2,r8                 ;365
000220  4639              MOV      r1,r7                 ;365
000222  4630              MOV      r0,r6                 ;365
000224  9b10              LDR      r3,[sp,#0x40]         ;365
000226  f7fff7ff          BL       OSTaskStkInit
00022a  e9dde9dd          LDRD     r2,r3,[sp,#0x3c]      ;366
00022e  e9cde9cd          STRD     r11,r2,[sp,#0]        ;366
000232  9302              STR      r3,[sp,#8]            ;366
000234  4601              MOV      r1,r0                 ;366
000236  464b              MOV      r3,r9                 ;366
000238  4652              MOV      r2,r10                ;366
00023a  4620              MOV      r0,r4                 ;366
00023c  f7fff7ff          BL       OS_TCBInit
000240  4606              MOV      r6,r0                 ;366
000242  b936              CBNZ     r6,|L1.594|
000244  4870              LDR      r0,|L1.1032|
000246  7800              LDRB     r0,[r0,#0]            ;368  ; OSRunning
000248  2801              CMP      r0,#1                 ;368
00024a  d109              BNE      |L1.608|
00024c  f7fff7ff          BL       OS_Sched
000250  e006              B        |L1.608|
                  |L1.594|
000252  f7fff7ff          BL       OS_CPU_SR_Save
000256  2100              MOVS     r1,#0                 ;373
000258  f845f845          STR      r1,[r5,r4,LSL #2]     ;373
00025c  f7fff7ff          BL       OS_CPU_SR_Restore
                  |L1.608|
000260  4630              MOV      r0,r6                 ;376
000262  e7cc              B        |L1.510|
                  |L1.612|
000264  f7fff7ff          BL       OS_CPU_SR_Restore
000268  2028              MOVS     r0,#0x28              ;379
00026a  e7c8              B        |L1.510|
;;;381    #endif
                          ENDP

                  OSTaskDel PROC
;;;420    INT8U  OSTaskDel (INT8U prio)
;;;421    {
00026c  e92de92d          PUSH     {r4-r10,lr}
000270  4605              MOV      r5,r0
;;;422    #if (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
;;;423        OS_FLAG_NODE *pnode;
;;;424    #endif
;;;425        OS_TCB       *ptcb;
;;;426    #if OS_CRITICAL_METHOD == 3                             /* Allocate storage for CPU status register    */
;;;427        OS_CPU_SR     cpu_sr = 0;
;;;428    #endif
;;;429    
;;;430    
;;;431    
;;;432        if (OSIntNesting > 0) {                             /* See if trying to delete from ISR            */

⌨️ 快捷键说明

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