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

📄 os_task.txt

📁 IARSOURCECODE是基于LPC2478嵌入式软件IAR EWARM V4.42的应用实例代码
💻 TXT
📖 第 1 页 / 共 5 页
字号:
;;;204        if (OSIntNesting > 0) {                  /* Make sure we don't create the task from within an ISR  */
;;;205            OS_EXIT_CRITICAL();
;;;206            return (OS_ERR_TASK_CREATE_ISR);
;;;207        }
;;;208        if (OSTCBPrioTbl[prio] == (OS_TCB *)0) { /* Make sure task doesn't already exist at this priority  */
;;;209            OSTCBPrioTbl[prio] = (OS_TCB *)1;    /* Reserve the priority to prevent others from doing ...  */
;;;210                                                 /* ... the same thing until task is created.              */
;;;211            OS_EXIT_CRITICAL();
;;;212            psp = OSTaskStkInit(task, p_arg, ptos, 0);              /* Initialize the task's stack         */
;;;213            err = OS_TCBInit(prio, psp, (OS_STK *)0, 0, 0, (void *)0, 0);
;;;214            if (err == OS_ERR_NONE) {
;;;215                if (OSRunning == OS_TRUE) {      /* Find highest priority task if multitasking has started */
;;;216                    OS_Sched();
;;;217                }
;;;218            } else {
;;;219                OS_ENTER_CRITICAL();
;;;220                OSTCBPrioTbl[prio] = (OS_TCB *)0;/* Make this priority available to others                 */
;;;221                OS_EXIT_CRITICAL();
;;;222            }
;;;223            return (err);
;;;224        }
;;;225        OS_EXIT_CRITICAL();
;;;226        return (OS_ERR_PRIO_EXIST);
;;;227    }
00023c  e12fff1e          BX       lr
                  |L1.576|
000240  ebfffffe          BL       OS_CPU_SR_Save
000244  e1a09000          MOV      r9,r0
000248  e59f0b18          LDR      r0,|L1.3432|
00024c  e5d00000          LDRB     r0,[r0,#0]  ; OSIntNesting
000250  e3500000          CMP      r0,#0
000254  da000003          BLE      |L1.616|
000258  e1a00009          MOV      r0,r9
00025c  ebfffffe          BL       OS_CPU_SR_Restore
000260  e3a0003c          MOV      r0,#0x3c
000264  eafffff3          B        |L1.568|
                  |L1.616|
000268  e59f0ae4          LDR      r0,|L1.3412|
00026c  e7900108          LDR      r0,[r0,r8,LSL #2]
000270  e3500000          CMP      r0,#0
000274  1a000024          BNE      |L1.780|
000278  e3a00001          MOV      r0,#1
00027c  e59f1ad0          LDR      r1,|L1.3412|
000280  e7810108          STR      r0,[r1,r8,LSL #2]
000284  e1a00009          MOV      r0,r9
000288  ebfffffe          BL       OS_CPU_SR_Restore
00028c  e3a03000          MOV      r3,#0
000290  e1a02006          MOV      r2,r6
000294  e1a01005          MOV      r1,r5
000298  e1a00004          MOV      r0,r4
00029c  ebfffffe          BL       OSTaskStkInit
0002a0  e1a0a000          MOV      r10,r0
0002a4  e3a03000          MOV      r3,#0
0002a8  e58d3000          STR      r3,[sp,#0]
0002ac  e58d3004          STR      r3,[sp,#4]
0002b0  e58d3008          STR      r3,[sp,#8]
0002b4  e1a02003          MOV      r2,r3
0002b8  e1a0100a          MOV      r1,r10
0002bc  e1a00008          MOV      r0,r8
0002c0  ebfffffe          BL       OS_TCBInit
0002c4  e1a07000          MOV      r7,r0
0002c8  e3570000          CMP      r7,#0
0002cc  1a000005          BNE      |L1.744|
0002d0  e59f0a8c          LDR      r0,|L1.3428|
0002d4  e5d00000          LDRB     r0,[r0,#0]  ; OSRunning
0002d8  e3500001          CMP      r0,#1
0002dc  1a000008          BNE      |L1.772|
0002e0  ebfffffe          BL       OS_Sched
0002e4  ea000006          B        |L1.772|
                  |L1.744|
0002e8  ebfffffe          BL       OS_CPU_SR_Save
0002ec  e1a09000          MOV      r9,r0
0002f0  e3a00000          MOV      r0,#0
0002f4  e59f1a58          LDR      r1,|L1.3412|
0002f8  e7810108          STR      r0,[r1,r8,LSL #2]
0002fc  e1a00009          MOV      r0,r9
000300  ebfffffe          BL       OS_CPU_SR_Restore
                  |L1.772|
000304  e1a00007          MOV      r0,r7
000308  eaffffca          B        |L1.568|
                  |L1.780|
00030c  e1a00009          MOV      r0,r9
000310  ebfffffe          BL       OS_CPU_SR_Restore
000314  e3a00028          MOV      r0,#0x28
000318  eaffffc6          B        |L1.568|
                          ENDP

                  OS_TaskStkClr PROC
;;;1039   {
;;;1040       if ((opt & OS_TASK_OPT_STK_CHK) != 0x0000) {       /* See if stack checking has been enabled       */
00031c  e3120001          TST      r2,#1
000320  0a000007          BEQ      |L1.836|
;;;1041           if ((opt & OS_TASK_OPT_STK_CLR) != 0x0000) {   /* See if stack needs to be cleared             */
000324  e3120002          TST      r2,#2
000328  0a000005          BEQ      |L1.836|
;;;1042   #if OS_STK_GROWTH == 1
;;;1043               while (size > 0) {                         /* Stack grows from HIGH to LOW memory          */
00032c  ea000002          B        |L1.828|
                  |L1.816|
;;;1044                   size--;
000330  e2411001          SUB      r1,r1,#1
;;;1045                   *pbos++ = (OS_STK)0;                   /* Clear from bottom of stack and up!           */
000334  e3a03000          MOV      r3,#0
000338  e4803004          STR      r3,[r0],#4
                  |L1.828|
00033c  e3510000          CMP      r1,#0
000340  1afffffa          BNE      |L1.816|
                  |L1.836|
;;;1046               }
;;;1047   #else
;;;1048               while (size > 0) {                         /* Stack grows from LOW to HIGH memory          */
;;;1049                   size--;
;;;1050                   *pbos-- = (OS_STK)0;                   /* Clear from bottom of stack and down          */
;;;1051               }
;;;1052   #endif
;;;1053           }
;;;1054       }
;;;1055   }
000344  e12fff1e          BX       lr
                          ENDP

                  OSTaskCreateExt PROC
;;;309                            INT16U   opt)
;;;310    {
000348  e92d4ff0          PUSH     {r4-r11,lr}
00034c  e24dd01c          SUB      sp,sp,#0x1c
000350  e1a04000          MOV      r4,r0
000354  e1a05001          MOV      r5,r1
000358  e1a06002          MOV      r6,r2
00035c  e1a07003          MOV      r7,r3
000360  e28db040          ADD      r11,sp,#0x40
000364  e89b0f00          LDM      r11,{r8-r11}
;;;311        OS_STK    *psp;
;;;312        INT8U      err;
;;;313    #if OS_CRITICAL_METHOD == 3                  /* Allocate storage for CPU status register               */
;;;314        OS_CPU_SR  cpu_sr = 0;
000368  e3a00000          MOV      r0,#0
00036c  e58d0010          STR      r0,[sp,#0x10]
;;;315    #endif
;;;316    
;;;317    
;;;318    
;;;319    #if OS_ARG_CHK_EN > 0
;;;320        if (prio > OS_LOWEST_PRIO) {             /* Make sure priority is within allowable range           */
000370  e357001f          CMP      r7,#0x1f
000374  da000003          BLE      |L1.904|
;;;321            return (OS_ERR_PRIO_INVALID);
000378  e3a0002a          MOV      r0,#0x2a
                  |L1.892|
00037c  e28dd01c          ADD      sp,sp,#0x1c
000380  e8bd4ff0          POP      {r4-r11,lr}
;;;322        }
;;;323    #endif
;;;324        OS_ENTER_CRITICAL();
;;;325        if (OSIntNesting > 0) {                  /* Make sure we don't create the task from within an ISR  */
;;;326            OS_EXIT_CRITICAL();
;;;327            return (OS_ERR_TASK_CREATE_ISR);
;;;328        }
;;;329        if (OSTCBPrioTbl[prio] == (OS_TCB *)0) { /* Make sure task doesn't already exist at this priority  */
;;;330            OSTCBPrioTbl[prio] = (OS_TCB *)1;    /* Reserve the priority to prevent others from doing ...  */
;;;331                                                 /* ... the same thing until task is created.              */
;;;332            OS_EXIT_CRITICAL();
;;;333    
;;;334            OS_TaskStkClr(pbos, stk_size, opt);                    /* Clear the task stack (if needed)     */
;;;335    
;;;336            psp = OSTaskStkInit(task, p_arg, ptos, opt);           /* Initialize the task's stack          */
;;;337            err = OS_TCBInit(prio, psp, pbos, id, stk_size, pext, opt);
;;;338            if (err == OS_ERR_NONE) {
;;;339                if (OSRunning == OS_TRUE) {                        /* Find HPT if multitasking has started */
;;;340                    OS_Sched();
;;;341                }
;;;342            } else {
;;;343                OS_ENTER_CRITICAL();
;;;344                OSTCBPrioTbl[prio] = (OS_TCB *)0;                  /* Make this priority avail. to others  */
;;;345                OS_EXIT_CRITICAL();
;;;346            }
;;;347            return (err);
;;;348        }
;;;349        OS_EXIT_CRITICAL();
;;;350        return (OS_ERR_PRIO_EXIST);
;;;351    }
000384  e12fff1e          BX       lr
                  |L1.904|
000388  ebfffffe          BL       OS_CPU_SR_Save
00038c  e58d0010          STR      r0,[sp,#0x10]
000390  e59f09d0          LDR      r0,|L1.3432|
000394  e5d00000          LDRB     r0,[r0,#0]  ; OSIntNesting
000398  e3500000          CMP      r0,#0
00039c  da000003          BLE      |L1.944|
0003a0  e59d0010          LDR      r0,[sp,#0x10]
0003a4  ebfffffe          BL       OS_CPU_SR_Restore
0003a8  e3a0003c          MOV      r0,#0x3c
0003ac  eafffff2          B        |L1.892|
                  |L1.944|
0003b0  e59f099c          LDR      r0,|L1.3412|
0003b4  e7900107          LDR      r0,[r0,r7,LSL #2]
0003b8  e3500000          CMP      r0,#0
0003bc  1a000029          BNE      |L1.1128|
0003c0  e3a00001          MOV      r0,#1
0003c4  e59f1988          LDR      r1,|L1.3412|
0003c8  e7810107          STR      r0,[r1,r7,LSL #2]
0003cc  e59d0010          LDR      r0,[sp,#0x10]
0003d0  ebfffffe          BL       OS_CPU_SR_Restore
0003d4  e1a0100a          MOV      r1,r10
0003d8  e1a00009          MOV      r0,r9
0003dc  e59d2050          LDR      r2,[sp,#0x50]
0003e0  ebfffffe          BL       OS_TaskStkClr
0003e4  e1a02006          MOV      r2,r6
0003e8  e1a01005          MOV      r1,r5
0003ec  e1a00004          MOV      r0,r4
0003f0  e59d3050          LDR      r3,[sp,#0x50]
0003f4  ebfffffe          BL       OSTaskStkInit
0003f8  e58d0018          STR      r0,[sp,#0x18]
0003fc  e59d3050          LDR      r3,[sp,#0x50]
000400  e58d3008          STR      r3,[sp,#8]
000404  e1a03008          MOV      r3,r8
000408  e1a02009          MOV      r2,r9
00040c  e88d0c00          STM      sp,{r10,r11}
000410  e1a00007          MOV      r0,r7
000414  e59d1018          LDR      r1,[sp,#0x18]
000418  ebfffffe          BL       OS_TCBInit
00041c  e58d0014          STR      r0,[sp,#0x14]
000420  e59d0014          LDR      r0,[sp,#0x14]
000424  e3500000          CMP      r0,#0
000428  1a000005          BNE      |L1.1092|
00042c  e59f0930          LDR      r0,|L1.3428|
000430  e5d00000          LDRB     r0,[r0,#0]  ; OSRunning
000434  e3500001          CMP      r0,#1
000438  1a000008          BNE      |L1.1120|
00043c  ebfffffe          BL       OS_Sched
000440  ea000006          B        |L1.1120|
                  |L1.1092|
000444  ebfffffe          BL       OS_CPU_SR_Save
000448  e58d0010          STR      r0,[sp,#0x10]
00044c  e3a00000          MOV      r0,#0
000450  e59f18fc          LDR      r1,|L1.3412|
000454  e7810107          STR      r0,[r1,r7,LSL #2]
000458  e59d0010          LDR      r0,[sp,#0x10]
00045c  ebfffffe          BL       OS_CPU_SR_Restore
                  |L1.1120|
000460  e59d0014          LDR      r0,[sp,#0x14]
000464  eaffffc4          B        |L1.892|
                  |L1.1128|
000468  e59d0010          LDR      r0,[sp,#0x10]
00046c  ebfffffe          BL       OS_CPU_SR_Restore
000470  e3a00028          MOV      r0,#0x28
000474  eaffffc0          B        |L1.892|
                          ENDP

                  OSTaskDel PROC
;;;391    INT8U  OSTaskDel (INT8U prio)
;;;392    {
000478  e92d47f0          PUSH     {r4-r10,lr}
00047c  e1a04000          MOV      r4,r0
;;;393    #if OS_EVENT_EN
;;;394        OS_EVENT     *pevent;
;;;395    #endif
;;;396    #if (OS_VERSION >= 251) && (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
;;;397        OS_FLAG_NODE *pnode;
;;;398    #endif
;;;399        OS_TCB       *ptcb;
;;;400        INT8U         y;
;;;401    #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
;;;402        OS_CPU_SR     cpu_sr = 0;
000480  e3a09000          MOV      r9,#0
;;;403    #endif
;;;404    
;;;405    
;;;406    
;;;407        if (OSIntNesting > 0) {                                     /* See if trying to delete from ISR    */
000484  e59f08dc          LDR      r0,|L1.3432|
000488  e5d00000          LDRB     r0,[r0,#0]  ; OSIntNesting
00048c  e3500000          CMP      r0,#0
000490  da000002          BLE      |L1.1184|
;;;408            return (OS_ERR_TASK_DEL_ISR);
000494  e3a00040          MOV      r0,#0x40

⌨️ 快捷键说明

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