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

📄 os_task.lis

📁 ucos如何移植到单片机mega128
💻 LIS
📖 第 1 页 / 共 5 页
字号:
 01D8           ;         OS_ENTER_CRITICAL();                                    /* ... disabled HERE!                  */
 01D8 0A93              st -y,r16
 01DA 0FB7              in r16,0x3F
 01DC F894              cli
 01DE 0F93              push r16
 01E0 0991              ld r16,y+
 01E2                   .dbline 415
 01E2                   .dbline 416
 01E2           ;               if (OSLockNesting > 0) {
 01E2 2224              clr R2
 01E4 30900000          lds R3,_OSLockNesting
 01E8 2314              cp R2,R3
 01EA 20F4              brsh L29
 01EC                   .dbline 416
 01EC                   .dbline 417
 01EC           ;             OSLockNesting--;
 01EC 832D              mov R24,R3
 01EE 8150              subi R24,1
 01F0 80930000          sts _OSLockNesting,R24
 01F4                   .dbline 418
 01F4           ;               }
 01F4           L29:
 01F4                   .dbline 419
 01F4           ;         OSTaskDelHook(ptcb);                                    /* Call user defined hook              */
 01F4 8A01              movw R16,R20
 01F6 0E940000          xcall _OSTaskDelHook
 01FA                   .dbline 420
 01FA           ;         OSTaskCtr--;                                            /* One less task being managed         */
 01FA 80910000          lds R24,_OSTaskCtr
 01FE 8150              subi R24,1
 0200 80930000          sts _OSTaskCtr,R24
 0204                   .dbline 421
 0204           ;         OSTCBPrioTbl[prio] = (OS_TCB *)0;                       /* Clear old priority entry            */
 0204 82E0              ldi R24,2
 0206 869F              mul R24,R22
 0208 F001              movw R30,R0
 020A 80E0              ldi R24,<_OSTCBPrioTbl
 020C 90E0              ldi R25,>_OSTCBPrioTbl
 020E E80F              add R30,R24
 0210 F91F              adc R31,R25
 0212 2224              clr R2
 0214 3324              clr R3
 0216 3182              std z+1,R3
 0218 2082              std z+0,R2
 021A                   .dbline 422
 021A           ;         if (ptcb->OSTCBPrev == (OS_TCB *)0) {                   /* Remove from TCB chain               */
 021A FA01              movw R30,R20
 021C 2480              ldd R2,z+4
 021E 3580              ldd R3,z+5
 0220 2220              tst R2
 0222 91F4              brne L31
 0224 3320              tst R3
 0226 81F4              brne L31
 0228           X5:
 0228                   .dbline 422
 0228                   .dbline 423
 0228           ;             ptcb->OSTCBNext->OSTCBPrev = (OS_TCB *)0;
 0228 2224              clr R2
 022A 3324              clr R3
 022C FA01              movw R30,R20
 022E A281              ldd R26,z+2
 0230 B381              ldd R27,z+3
 0232 1496              adiw R26,4
 0234 2D92              st x+,R2
 0236 3C92              st x,R3
 0238                   .dbline 424
 0238           ;             OSTCBList                  = ptcb->OSTCBNext;
 0238 FA01              movw R30,R20
 023A 2280              ldd R2,z+2
 023C 3380              ldd R3,z+3
 023E 30920100          sts _OSTCBList+1,R3
 0242 20920000          sts _OSTCBList,R2
 0246                   .dbline 425
 0246 12C0              xjmp L32
 0248           L31:
 0248                   .dbline 425
 0248           ;         } else {
 0248                   .dbline 426
 0248           ;             ptcb->OSTCBPrev->OSTCBNext = ptcb->OSTCBNext;
 0248 FA01              movw R30,R20
 024A 2280              ldd R2,z+2
 024C 3380              ldd R3,z+3
 024E FA01              movw R30,R20
 0250 A481              ldd R26,z+4
 0252 B581              ldd R27,z+5
 0254 1296              adiw R26,2
 0256 2D92              st x+,R2
 0258 3C92              st x,R3
 025A                   .dbline 427
 025A           ;             ptcb->OSTCBNext->OSTCBPrev = ptcb->OSTCBPrev;
 025A FA01              movw R30,R20
 025C 2480              ldd R2,z+4
 025E 3580              ldd R3,z+5
 0260 FA01              movw R30,R20
 0262 A281              ldd R26,z+2
 0264 B381              ldd R27,z+3
 0266 1496              adiw R26,4
 0268 2D92              st x+,R2
 026A 3C92              st x,R3
 026C                   .dbline 428
 026C           ;         }
 026C           L32:
 026C                   .dbline 429
 026C           ;         ptcb->OSTCBNext = OSTCBFreeList;                        /* Return TCB to free TCB list         */
 026C 20900000          lds R2,_OSTCBFreeList
 0270 30900100          lds R3,_OSTCBFreeList+1
 0274 FA01              movw R30,R20
 0276 3382              std z+3,R3
 0278 2282              std z+2,R2
 027A                   .dbline 430
 027A           ;         OSTCBFreeList   = ptcb;
 027A 50930100          sts _OSTCBFreeList+1,R21
 027E 40930000          sts _OSTCBFreeList,R20
 0282                   .dbline 431
 0282           ;         OS_EXIT_CRITICAL();
 0282 0A93              st -y,r16
 0284 0F91              pop r16
 0286 0FBF              out 0x3F,r16
 0288 0991              ld r16,y+
 028A                   .dbline 431
 028A                   .dbline 432
 028A           ;         OS_Sched();                                             /* Find new highest priority task      */
 028A 0E940000          xcall _OS_Sched
 028E                   .dbline 433
 028E           ;         return (OS_NO_ERR);
 028E 0027              clr R16
 0290 05C0              xjmp L12
 0292           L21:
 0292                   .dbline 435
 0292           ;     }
 0292           ;     OS_EXIT_CRITICAL();
 0292 0A93              st -y,r16
 0294 0F91              pop r16
 0296 0FBF              out 0x3F,r16
 0298 0991              ld r16,y+
 029A                   .dbline 435
 029A                   .dbline 436
 029A           ;     return (OS_TASK_DEL_ERR);
 029A 0CE3              ldi R16,60
 029C                   .dbline -2
 029C           L12:
 029C 0E940000          xcall pop_gset3
 02A0                   .dbline 0 ; func end
 02A0 0895              ret
 02A2                   .dbsym l self 1 c
 02A2                   .dbsym r pnode 10 pS[.2]
 02A2                   .dbsym r ptcb 20 pS[os_tcb]
 02A2                   .dbsym r prio 22 c
 02A2                   .dbend
 02A2                   .dbfunc e OSTaskDelReq _OSTaskDelReq fc
 02A2           ;           stat -> R20
 02A2           ;            err -> R20
 02A2           ;           ptcb -> R20,R21
 02A2           ;           prio -> R16
                        .even
 02A2           _OSTaskDelReq::
 02A2 0E940000          xcall push_gset1
 02A6                   .dbline -1
 02A6                   .dbline 487
 02A6           ; }
 02A6           ; #endif
 02A6           ; /*$PAGE*/
 02A6           ; /*
 02A6           ; *********************************************************************************************************
 02A6           ; *                                    REQUEST THAT A TASK DELETE ITSELF
 02A6           ; *
 02A6           ; * Description: This function is used to:
 02A6           ; *                   a) notify a task to delete itself.
 02A6           ; *                   b) to see if a task requested that the current task delete itself.
 02A6           ; *              This function is a little tricky to understand.  Basically, you have a task that needs
 02A6           ; *              to be deleted however, this task has resources that it has allocated (memory buffers,
 02A6           ; *              semaphores, mailboxes, queues etc.).  The task cannot be deleted otherwise these
 02A6           ; *              resources would not be freed.  The requesting task calls OSTaskDelReq() to indicate that
 02A6           ; *              the task needs to be deleted.  Deleting of the task is however, deferred to the task to
 02A6           ; *              be deleted.  For example, suppose that task #10 needs to be deleted.  The requesting task
 02A6           ; *              example, task #5, would call OSTaskDelReq(10).  When task #10 gets to execute, it calls
 02A6           ; *              this function by specifying OS_PRIO_SELF and monitors the returned value.  If the return
 02A6           ; *              value is OS_TASK_DEL_REQ, another task requested a task delete.  Task #10 would look like
 02A6           ; *              this:
 02A6           ; *
 02A6           ; *                   void Task(void *data)
 02A6           ; *                   {
 02A6           ; *                       .
 02A6           ; *                       .
 02A6           ; *                       while (1) {
 02A6           ; *                           OSTimeDly(1);
 02A6           ; *                           if (OSTaskDelReq(OS_PRIO_SELF) == OS_TASK_DEL_REQ) {
 02A6           ; *                               Release any owned resources;
 02A6           ; *                               De-allocate any dynamic memory;
 02A6           ; *                               OSTaskDel(OS_PRIO_SELF);
 02A6           ; *                           }
 02A6           ; *                       }
 02A6           ; *                   }
 02A6           ; *
 02A6           ; * Arguments  : prio    is the priority of the task to request the delete from
 02A6           ; *
 02A6           ; * Returns    : OS_NO_ERR          if the task exist and the request has been registered
 02A6           ; *              OS_TASK_NOT_EXIST  if the task has been deleted.  This allows the caller to know whether
 02A6           ; *                                 the request has been executed.
 02A6           ; *              OS_TASK_DEL_IDLE   if you requested to delete uC/OS-II's idle task
 02A6           ; *              OS_PRIO_INVALID    if the priority you specify is higher that the maximum allowed
 02A6           ; *                                 (i.e. >= OS_LOWEST_PRIO) or, you have not specified OS_PRIO_SELF.
 02A6           ; *              OS_TASK_DEL_REQ    if a task (possibly another task) requested that the running task be
 02A6           ; *                                 deleted.
 02A6           ; *********************************************************************************************************
 02A6           ; */
 02A6           ; /*$PAGE*/
 02A6           ; #if OS_TASK_DEL_EN > 0
 02A6           ; INT8U  OSTaskDelReq (INT8U prio)
 02A6           ; {
 02A6                   .dbline 497
 02A6           ; #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
 02A6           ;     OS_CPU_SR  cpu_sr;
 02A6           ; #endif
 02A6           ;     BOOLEAN    stat;
 02A6           ;     INT8U      err;
 02A6           ;     OS_TCB    *ptcb;
 02A6           ; 
 02A6           ; 
 02A6           ; #if OS_ARG_CHK_EN > 0
 02A6           ;     if (prio == OS_IDLE_PRIO) {                                 /* Not allowed to delete idle task     */
 02A6 0431              cpi R16,20
 02A8 11F4              brne L34
 02AA                   .dbline 497
 02AA                   .dbline 498
 02AA           ;         return (OS_TASK_DEL_IDLE);
 02AA 0DE3              ldi R16,61
 02AC 34C0              xjmp L33
 02AE           L34:
 02AE                   .dbline 500
 02AE           ;     }
 02AE           ;     if (prio >= OS_LOWEST_PRIO && prio != OS_PRIO_SELF) {       /* Task priority valid ?               */
 02AE 0431              cpi R16,20
 02B0 20F0              brlo L36
 02B2 0F3F              cpi R16,255
 02B4 11F0              breq L36
 02B6                   .dbline 500
 02B6                   .dbline 501
 02B6           ;         return (OS_PRIO_INVALID);
 02B6 0AE2              ldi R16,42
 02B8 2EC0              xjmp L33
 02BA           L36:
 02BA                   .dbline 504
 02BA           ;     }
 02BA           ; #endif
 02BA           ;     if (prio == OS_PRIO_SELF) {                                 /* See if a task is requesting to ...  */
 02BA 0F3F              cpi R16,255
 02BC 81F4              brne L38
 02BE                   .dbline 504
 02BE                   .dbline 505
 02BE           ;         OS_ENTER_CRITICAL();                                    /* ... this task to delete itself      */
 02BE 0A93              st -y,r16
 02C0 0FB7              in r16,0x3F
 02C2 F894              cli
 02C4 0F93              push r16
 02C6 0991              ld r16,y+
 02C8                   .dbline 505
 02C8                   .dbline 506
 02C8           ;         stat = OSTCBCur->OSTCBDelReq;                           /* Return request status to caller     */

⌨️ 快捷键说明

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