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

📄 os_task.s

📁 将本站的UCOSFORAVR128V276版本升级到了280版
💻 S
📖 第 1 页 / 共 3 页
字号:
	mov R30,R14
	clr R31
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	tst R2
	brne L23
	.dbline 430
	.dbline 431
;             pevent->OSEventGrp &= ~ptcb->OSTCBBitY;             /* ... event ctrl block                */
	movw R24,R12
	adiw R24,5
	movw R30,R22
	ldd R4,z+16
	com R4
	movw R30,R24
	ldd R5,z+0
	and R5,R4
	std z+0,R5
	.dbline 432
;         }
L23:
	.dbline 433
;     }
L21:
	.dbline 441
; #endif
; #if (OS_VERSION >= 251) && (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
;     pnode = ptcb->OSTCBFlagNode;
;     if (pnode != (OS_FLAG_NODE *)0) {                           /* If task is waiting on event flag    */
;         OS_FlagUnlink(pnode);                                   /* Remove from wait list               */
;     }
; #endif
;     ptcb->OSTCBDly    = 0;                                      /* Prevent OSTimeTick() from updating  */
	clr R2
	clr R3
	movw R30,R22
	std z+9,R3
	std z+8,R2
	.dbline 442
;     ptcb->OSTCBStat   = OS_STAT_RDY;                            /* Prevent task from being resumed     */
	movw R30,R22
	std z+10,R2
	.dbline 443
;     ptcb->OSTCBPendTO = FALSE;
	movw R30,R22
	std z+11,R2
	.dbline 444
; 	if (OSLockNesting < 255u) {                                 /* Make sure we don't context switch   */
	lds R24,_OSLockNesting
	cpi R24,255
	brsh L25
	.dbline 444
	.dbline 445
;         OSLockNesting++;
	subi R24,255    ; addi 1
	sts _OSLockNesting,R24
	.dbline 446
; 	}
L25:
	.dbline 447
;     OS_EXIT_CRITICAL();                                         /* Enabling INT. ignores next instruc. */
	mov R16,R20
	xcall _OS_CPU_SR_Restore
	.dbline 448
;     OS_Dummy();                                                 /* ... Dummy ensures that INTs will be */
	xcall _OS_Dummy
	.dbline 449
;     OS_ENTER_CRITICAL();                                        /* ... disabled HERE!                  */
	xcall _OS_CPU_SR_Save
	mov R20,R16
	.dbline 450
; 	if (OSLockNesting > 0) {                                    /* Remove context switch lock          */
	clr R2
	lds R3,_OSLockNesting
	cp R2,R3
	brsh L27
	.dbline 450
	.dbline 451
;         OSLockNesting--;
	mov R24,R3
	subi R24,1
	sts _OSLockNesting,R24
	.dbline 452
; 	}
L27:
	.dbline 453
;     OSTaskDelHook(ptcb);                                        /* Call user defined hook              */
	movw R16,R22
	xcall _OSTaskDelHook
	.dbline 454
;     OSTaskCtr--;                                                /* One less task being managed         */
	lds R24,_OSTaskCtr
	subi R24,1
	sts _OSTaskCtr,R24
	.dbline 455
;     OSTCBPrioTbl[prio] = (OS_TCB *)0;                           /* Clear old priority entry            */
	ldi R24,2
	mul R24,R10
	movw R30,R0
	ldi R24,<_OSTCBPrioTbl
	ldi R25,>_OSTCBPrioTbl
	add R30,R24
	adc R31,R25
	clr R2
	clr R3
	std z+1,R3
	std z+0,R2
	.dbline 456
;     if (ptcb->OSTCBPrev == (OS_TCB *)0) {                       /* Remove from TCB chain               */
	movw R30,R22
	ldd R2,z+4
	ldd R3,z+5
	tst R2
	brne L29
	tst R3
	brne L29
X5:
	.dbline 456
	.dbline 457
;         ptcb->OSTCBNext->OSTCBPrev = (OS_TCB *)0;
	clr R2
	clr R3
	movw R30,R22
	ldd R26,z+2
	ldd R27,z+3
	adiw R26,4
	st x+,R2
	st x,R3
	.dbline 458
;         OSTCBList                  = ptcb->OSTCBNext;
	movw R30,R22
	ldd R2,z+2
	ldd R3,z+3
	sts _OSTCBList+1,R3
	sts _OSTCBList,R2
	.dbline 459
	xjmp L30
L29:
	.dbline 459
;     } else {
	.dbline 460
;         ptcb->OSTCBPrev->OSTCBNext = ptcb->OSTCBNext;
	movw R30,R22
	ldd R2,z+2
	ldd R3,z+3
	movw R30,R22
	ldd R26,z+4
	ldd R27,z+5
	adiw R26,2
	st x+,R2
	st x,R3
	.dbline 461
;         ptcb->OSTCBNext->OSTCBPrev = ptcb->OSTCBPrev;
	movw R30,R22
	ldd R2,z+4
	ldd R3,z+5
	movw R30,R22
	ldd R26,z+2
	ldd R27,z+3
	adiw R26,4
	st x+,R2
	st x,R3
	.dbline 462
;     }
L30:
	.dbline 463
;     ptcb->OSTCBNext   = OSTCBFreeList;                          /* Return TCB to free TCB list         */
	lds R2,_OSTCBFreeList
	lds R3,_OSTCBFreeList+1
	movw R30,R22
	std z+3,R3
	std z+2,R2
	.dbline 464
;     OSTCBFreeList     = ptcb;
	sts _OSTCBFreeList+1,R23
	sts _OSTCBFreeList,R22
	.dbline 469
; #if OS_TASK_NAME_SIZE > 1
;     ptcb->OSTCBTaskName[0] = '?';                               /* Unknown name                        */
;     ptcb->OSTCBTaskName[1] = OS_ASCII_NUL;
; #endif
;     OS_EXIT_CRITICAL();
	mov R16,R20
	xcall _OS_CPU_SR_Restore
	.dbline 470
;     OS_Sched();                                                 /* Find new highest priority task      */
	xcall _OS_Sched
	.dbline 471
;     return (OS_NO_ERR);
	clr R16
	.dbline -2
L10:
	xcall pop_gset5
	.dbline 0 ; func end
	ret
	.dbsym r pevent 12 pS[os_event]
	.dbsym r y 14 c
	.dbsym r cpu_sr 20 c
	.dbsym r ptcb 22 pS[os_tcb]
	.dbsym r prio 10 c
	.dbend
	.dbfunc e OSTaskDelReq _OSTaskDelReq fc
;           stat -> R10
;           ptcb -> R22,R23
;         cpu_sr -> R20
;           prio -> R22
	.even
_OSTaskDelReq::
	xcall push_gset3
	mov R22,R16
	.dbline -1
	.dbline 523
; }
; #endif
; /*$PAGE*/
; /*
; *********************************************************************************************************
; *                                    REQUEST THAT A TASK DELETE ITSELF
; *
; * Description: This function is used to:
; *                   a) notify a task to delete itself.
; *                   b) to see if a task requested that the current task delete itself.
; *              This function is a little tricky to understand.  Basically, you have a task that needs
; *              to be deleted however, this task has resources that it has allocated (memory buffers,
; *              semaphores, mailboxes, queues etc.).  The task cannot be deleted otherwise these
; *              resources would not be freed.  The requesting task calls OSTaskDelReq() to indicate that
; *              the task needs to be deleted.  Deleting of the task is however, deferred to the task to
; *              be deleted.  For example, suppose that task #10 needs to be deleted.  The requesting task
; *              example, task #5, would call OSTaskDelReq(10).  When task #10 gets to execute, it calls
; *              this function by specifying OS_PRIO_SELF and monitors the returned value.  If the return
; *              value is OS_TASK_DEL_REQ, another task requested a task delete.  Task #10 would look like
; *              this:
; *
; *                   void Task(void *p_arg)
; *                   {
; *                       .
; *                       .
; *                       while (1) {
; *                           OSTimeDly(1);
; *                           if (OSTaskDelReq(OS_PRIO_SELF) == OS_TASK_DEL_REQ) {
; *                               Release any owned resources;
; *                               De-allocate any dynamic memory;
; *                               OSTaskDel(OS_PRIO_SELF);
; *                           }
; *                       }
; *                   }
; *
; * Arguments  : prio    is the priority of the task to request the delete from
; *
; * Returns    : OS_NO_ERR          if the task exist and the request has been registered
; *              OS_TASK_NOT_EXIST  if the task has been deleted.  This allows the caller to know whether
; *                                 the request has been executed.
; *              OS_TASK_DEL_ERR    if the task is assigned to a Mutex.
; *              OS_TASK_DEL_IDLE   if you requested to delete uC/OS-II's idle task
; *              OS_PRIO_INVALID    if the priority you specify is higher that the maximum allowed
; *                                 (i.e. >= OS_LOWEST_PRIO) or, you have not specified OS_PRIO_SELF.
; *              OS_TASK_DEL_REQ    if a task (possibly another task) requested that the running task be
; *                                 deleted.
; *********************************************************************************************************
; */
; /*$PAGE*/
; #if OS_TASK_DEL_EN > 0
; INT8U  OSTaskDelReq (INT8U prio)
; {
	.dbline 527
;     INT8U      stat;
;     OS_TCB    *ptcb;
; #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
;     OS_CPU_SR  cpu_sr = 0;
	clr R20
	.dbline 542
; #endif
; 
; 
; 
; #if OS_ARG_CHK_EN > 0
;     if (prio == OS_IDLE_PRIO) {                                 /* Not allowed to delete idle task     */
;         return (OS_TASK_DEL_IDLE);
;     }
;     if (prio >= OS_LOWEST_PRIO) {						        /* Task priority valid ?               */
;         if (prio != OS_PRIO_SELF) {
;             return (OS_PRIO_INVALID);
; 		}
;     }
; #endif
;     if (prio == OS_PRIO_SELF) {                                 /* See if a task is requesting to ...  */
	cpi R22,255
	brne L32
	.dbline 542
	.dbline 543
;         OS_ENTER_CRITICAL();                                    /* ... this task to delete itself      */
	xcall _OS_CPU_SR_Save
	mov R20,R16
	.dbline 544
;         stat = OSTCBCur->OSTCBDelReq;                           /* Return request status to caller     */
	lds R30,_OSTCBCur
	lds R31,_OSTCBCur+1
	ldd R10,z+17
	.dbline 545
;         OS_EXIT_CRITICAL();
	xcall _OS_CPU_SR_Restore
	.dbline 546
;         return (stat);
	mov R16,R10
	xjmp L31
L32:
	.dbline 548
;     }
;     OS_ENTER_CRITICAL();
	xcall _OS_CPU_SR_Save
	mov R20,R16
	.dbline 549
;     ptcb = OSTCBPrioTbl[prio];
	ldi R24,2
	mul R24,R22
	movw R30,R0
	ldi R24,<_OSTCBPrioTbl
	ldi R25,>_OSTCBPrioTbl
	add R30,R24
	adc R31,R25
	ldd R22,z+0
	ldd R23,z+1
	.dbline 550
;     if (ptcb == (OS_TCB *)0) {                                  /* Task to delete must exist           */
	cpi R22,0
	cpc R22,R23
	brne L34
X7:
	.dbline 550
	.dbline 551
;         OS_EXIT_CRITICAL();
	mov R16,R20
	xcall _OS_CPU_SR_Restore
	.dbline 552
;         return (OS_TASK_NOT_EXIST);                             /* Task must already be deleted        */
	ldi R16,11
	xjmp L31
L34:
	.dbline 554
;     }
;     if (ptcb == (OS_TCB *)1) {                                  /* Must NOT be assigned to a Mutex     */
	cpi R22,1
	ldi R30,0
	cpc R23,R30
	brne L36
	.dbline 554
	.dbline 555
;         OS_EXIT_CRITICAL();
	mov R16,R20
	xcall _OS_CPU_SR_Restore
	.dbline 556
;         return (OS_TASK_DEL_ERR);
	ldi R16,60
	xjmp L31
L36:
	.dbline 558
;     }
;     ptcb->OSTCBDelReq = OS_TASK_DEL_REQ;                        /* Set flag indicating task to be DEL. */
	ldi R24,62
	movw R30,R22
	std z+17,R24
	.dbline 559
;     OS_EXIT_CRITICAL();
	mov R16,R20
	xcall _OS_CPU_SR_Restore
	.dbline 560
;     return (OS_NO_ERR);
	clr R16
	.dbline -2
L31:
	xcall pop_gset3
	.dbline 0 ; func end
	ret
	.dbsym r stat 10 c
	.dbsym r ptcb 22 pS[os_tcb]
	.dbsym r cpu_sr 20 c
	.dbsym r prio 22 c
	.dbend

⌨️ 快捷键说明

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