📄 os_task.s79
字号:
_BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
// 287 if (OSTCBPrioTbl[prio] == (OS_TCB *)0) { /* Make sure task doesn't already exist at this priority */
LSLS R5,R5,#+24 ;; ZeroExtS R5,R5,#+24,#+24
LSRS R5,R5,#+24
MOVS R1,#+4
MULS R1,R5,R1
LDR R2,??DataTable26 ;; OSTCBPrioTbl
LDR R1,[R2, R1]
CMP R1,#+0
BNE ??OSTaskCreateExt_2
// 288 OSTCBPrioTbl[prio] = (OS_TCB *)1; /* Reserve the priority to prevent others from doing ... */
LSLS R5,R5,#+24 ;; ZeroExtS R5,R5,#+24,#+24
LSRS R5,R5,#+24
MOVS R3,#+4
MULS R3,R5,R3
LDR R1,??DataTable26 ;; OSTCBPrioTbl
MOVS R2,#+1
STR R2,[R1, R3]
// 289 /* ... the same thing until task is created. */
// 290 OS_EXIT_CRITICAL();
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 291
// 292 OS_TaskStkClr(pbos, stk_size, opt); /* Clear the task stack (if needed) */
MOVS R2,R7
MOVS R1,R6
LDR R0,[SP, #+32]
BL OS_TaskStkClr
// 293
// 294 psp = (OS_STK *)OSTaskStkInit(task, p_arg, ptos, opt); /* Initialize the task's stack */
MOVS R3,R7
MOVS R2,R4
LDR R1,[SP, #+4]
LDR R0,[SP, #+0]
_BLF OSTaskStkInit,??OSTaskStkInit??rT
MOVS R4,R0
// 295 err = OS_TCBInit(prio, psp, pbos, id, stk_size, pext, opt);
MOVS R2,R7
LDR R1,[SP, #+40]
MOVS R0,R6
PUSH {R0-R2}
CFI CFA R13+40
ADD R0,SP,#+12
LDRH R3,[R0, #+28]
LDR R2,[SP, #+44]
MOVS R1,R4
MOVS R0,R5
_BLF OS_TCBInit,??OS_TCBInit??rT
ADD SP,SP,#+12
CFI CFA R13+28
MOVS R4,R0
// 296 if (err == OS_NO_ERR) {
CMP R4,#+0
BNE ??OSTaskCreateExt_3
// 297 OS_ENTER_CRITICAL();
_BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
// 298 OSTaskCtr++; /* Increment the #tasks counter */
LDR R1,??DataTable35 ;; OSTaskCtr
LDR R2,??DataTable35 ;; OSTaskCtr
LDRB R2,[R2, #+0]
ADDS R2,R2,#+1
STRB R2,[R1, #+0]
// 299 OS_EXIT_CRITICAL();
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 300 if (OSRunning == TRUE) { /* Find HPT if multitasking has started */
LDR R0,??DataTable25 ;; OSRunning
LDRB R0,[R0, #+0]
CMP R0,#+1
BNE ??OSTaskCreateExt_4
// 301 OS_Sched();
_BLF OS_Sched,??OS_Sched??rT
B ??OSTaskCreateExt_4
// 302 }
// 303 } else {
// 304 OS_ENTER_CRITICAL();
??OSTaskCreateExt_3:
_BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
// 305 OSTCBPrioTbl[prio] = (OS_TCB *)0; /* Make this priority avail. to others */
MOVS R1,#+4
MULS R5,R1,R5
LDR R1,??DataTable26 ;; OSTCBPrioTbl
MOVS R2,#+0
STR R2,[R1, R5]
// 306 OS_EXIT_CRITICAL();
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 307 }
// 308 return (err);
??OSTaskCreateExt_4:
MOVS R0,R4
B ??OSTaskCreateExt_1
// 309 }
// 310 OS_EXIT_CRITICAL();
??OSTaskCreateExt_2:
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 311 return (OS_PRIO_EXIST);
MOVS R0,#+40
??OSTaskCreateExt_1:
ADD SP,SP,#+8
CFI CFA R13+20
POP {R4-R7}
POP {R1}
BX R1 ;; return
CFI EndBlock cfiBlock5
// 312 }
RSEG CODE:CODE:NOROOT(2)
DATA
??DataTable25:
DC32 OSRunning
RSEG CODE:CODE:NOROOT(2)
DATA
??DataTable26:
DC32 OSTCBPrioTbl
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock6 Using cfiCommon0
CFI NoFunction
ARM
??OSTaskDel??rA:
ADD R12,PC,#+1
BX R12
CFI EndBlock cfiBlock6
REQUIRE OSTaskDel
// 313 #endif
// 314
// 315 /*
// 316 *********************************************************************************************************
// 317 * DELETE A TASK
// 318 *
// 319 * Description: This function allows you to delete a task. The calling task can delete itself by
// 320 * its own priority number. The deleted task is returned to the dormant state and can be
// 321 * re-activated by creating the deleted task again.
// 322 *
// 323 * Arguments : prio is the priority of the task to delete. Note that you can explicitely delete
// 324 * the current task without knowing its priority level by setting 'prio' to
// 325 * OS_PRIO_SELF.
// 326 *
// 327 * Returns : OS_NO_ERR if the call is successful
// 328 * OS_TASK_DEL_IDLE if you attempted to delete uC/OS-II's idle task
// 329 * OS_PRIO_INVALID if the priority you specify is higher that the maximum allowed
// 330 * (i.e. >= OS_LOWEST_PRIO) or, you have not specified OS_PRIO_SELF.
// 331 * OS_TASK_DEL_ERR if the task you want to delete does not exist
// 332 * OS_TASK_DEL_ISR if you tried to delete a task from an ISR
// 333 *
// 334 * Notes : 1) To reduce interrupt latency, OSTaskDel() 'disables' the task:
// 335 * a) by making it not ready
// 336 * b) by removing it from any wait lists
// 337 * c) by preventing OSTimeTick() from making the task ready to run.
// 338 * The task can then be 'unlinked' from the miscellaneous structures in uC/OS-II.
// 339 * 2) The function OS_Dummy() is called after OS_EXIT_CRITICAL() because, on most processors,
// 340 * the next instruction following the enable interrupt instruction is ignored.
// 341 * 3) An ISR cannot delete a task.
// 342 * 4) The lock nesting counter is incremented because, for a brief instant, if the current
// 343 * task is being deleted, the current task would not be able to be rescheduled because it
// 344 * is removed from the ready list. Incrementing the nesting counter prevents another task
// 345 * from being schedule. This means that an ISR would return to the current task which is
// 346 * being deleted. The rest of the deletion would thus be able to be completed.
// 347 *********************************************************************************************************
// 348 */
// 349
// 350 #if OS_TASK_DEL_EN > 0
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock7 Using cfiCommon1
CFI Function OSTaskDel
THUMB
// 351 INT8U OSTaskDel (INT8U prio)
// 352 {
OSTaskDel:
PUSH {R4-R7,LR}
CFI ?RET Frame(CFA, -4)
CFI R7 Frame(CFA, -8)
CFI R6 Frame(CFA, -12)
CFI R5 Frame(CFA, -16)
CFI R4 Frame(CFA, -20)
CFI CFA R13+20
MOVS R5,R0
// 353 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
// 354 OS_CPU_SR cpu_sr;
// 355 #endif
// 356
// 357 #if OS_EVENT_EN > 0
// 358 OS_EVENT *pevent;
// 359 #endif
// 360 #if (OS_VERSION >= 251) && (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
// 361 OS_FLAG_NODE *pnode;
// 362 #endif
// 363 OS_TCB *ptcb;
// 364 INT8U y;
// 365
// 366
// 367
// 368 if (OSIntNesting > 0) { /* See if trying to delete from ISR */
LDR R0,??OSTaskDel_0 ;; OSIntNesting
LDRB R0,[R0, #+0]
CMP R0,#+1
BCC ??OSTaskDel_1
// 369 return (OS_TASK_DEL_ISR);
MOVS R0,#+63
B ??OSTaskDel_2
// 370 }
// 371 #if OS_ARG_CHK_EN > 0
// 372 if (prio == OS_IDLE_PRIO) { /* Not allowed to delete idle task */
??OSTaskDel_1:
CMP R5,#+63
BNE ??OSTaskDel_3
// 373 return (OS_TASK_DEL_IDLE);
MOVS R0,#+61
B ??OSTaskDel_2
// 374 }
// 375 if (prio >= OS_LOWEST_PRIO && prio != OS_PRIO_SELF) { /* Task priority valid ? */
??OSTaskDel_3:
CMP R5,#+63
BCC ??OSTaskDel_4
CMP R5,#+255
BEQ ??OSTaskDel_4
// 376 return (OS_PRIO_INVALID);
MOVS R0,#+42
B ??OSTaskDel_2
// 377 }
// 378 #endif
// 379 OS_ENTER_CRITICAL();
??OSTaskDel_4:
_BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
MOVS R4,R0
// 380 if (prio == OS_PRIO_SELF) { /* See if requesting to delete self */
CMP R5,#+255
BNE ??OSTaskDel_5
// 381 prio = OSTCBCur->OSTCBPrio; /* Set priority to delete to current */
LDR R0,??DataTable41 ;; OSTCBCur
LDR R0,[R0, #+0]
ADDS R0,R0,#+45
LDRB R5,[R0, #+0]
// 382 }
// 383 ptcb = OSTCBPrioTbl[prio];
??OSTaskDel_5:
LSLS R5,R5,#+24 ;; ZeroExtS R5,R5,#+24,#+24
LSRS R5,R5,#+24
MOVS R0,#+4
MULS R0,R5,R0
LDR R1,??DataTable42 ;; OSTCBPrioTbl
LDR R6,[R1, R0]
// 384 if (ptcb != (OS_TCB *)0) { /* Task to delete must exist */
CMP R6,#+0
BNE .+5
B ??OSTaskDel_6
// 385 y = ptcb->OSTCBY;
MOVS R0,#+47
LDRB R1,[R6, R0]
// 386 OSRdyTbl[y] &= ~ptcb->OSTCBBitX;
LSLS R1,R1,#+24 ;; ZeroExtS R1,R1,#+24,#+24
LSRS R1,R1,#+24
LDR R0,??DataTable31 ;; OSRdyTbl
LSLS R1,R1,#+24 ;; ZeroExtS R1,R1,#+24,#+24
LSRS R1,R1,#+24
LDR R2,??DataTable31 ;; OSRdyTbl
LDRB R2,[R2, R1]
MOVS R3,#+48
LDRB R3,[R6, R3]
BICS R2,R2,R3
STRB R2,[R0, R1]
// 387 if (OSRdyTbl[y] == 0x00) { /* Make task not ready */
LSLS R1,R1,#+24 ;; ZeroExtS R1,R1,#+24,#+24
LSRS R1,R1,#+24
LDR R0,??DataTable31 ;; OSRdyTbl
LDRB R0,[R0, R1]
CMP R0,#+0
BNE ??OSTaskDel_7
// 388 OSRdyGrp &= ~ptcb->OSTCBBitY;
LDR R0,??DataTable45 ;; OSRdyGrp
LDR R2,??DataTable45 ;; OSRdyGrp
LDRB R2,[R2, #+0]
MOVS R3,#+49
LDRB R3,[R6, R3]
BICS R2,R2,R3
STRB R2,[R0, #+0]
// 389 }
// 390 #if OS_EVENT_EN > 0
// 391 pevent = ptcb->OSTCBEventPtr;
??OSTaskDel_7:
LDR R2,[R6, #+28]
// 392 if (pevent != (OS_EVENT *)0) { /* If task is waiting on event */
CMP R2,#+0
BEQ ??OSTaskDel_8
// 393 pevent->OSEventTbl[y] &= ~ptcb->OSTCBBitX;
LSLS R1,R1,#+24 ;; ZeroExtS R1,R1,#+24,#+24
LSRS R1,R1,#+24
ADDS R0,R2,R1
LSLS R1,R1,#+24 ;; ZeroExtS R1,R1,#+24,#+24
LSRS R1,R1,#+24
ADDS R3,R2,R1
LDRB R3,[R3, #+8]
MOVS R7,#+48
LDRB R7,[R6, R7]
BICS R3,R3,R7
STRB R3,[R0, #+8]
// 394 if (pevent->OSEventTbl[y] == 0) { /* ... remove task from ... */
ADDS R0,R2,R1
LDRB R0,[R0, #+8]
CMP R0,#+0
BNE ??OSTaskDel_8
// 395 pevent->OSEventGrp &= ~ptcb->OSTCBBitY; /* ... event ctrl block */
LDRB R0,[R2, #+1]
MOVS R1,#+49
LDRB R1,[R6, R1]
BICS R0,R0,R1
STRB R0,[R2, #+1]
// 396 }
// 397 }
// 398 #endif
// 399 #if (OS_VERSION >= 251) && (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
// 400 pnode = ptcb->OSTCBFlagNode;
??OSTaskDel_8:
LDR R0,[R6, #+36]
// 401 if (pnode != (OS_FLAG_NODE *)0) { /* If task is waiting on event flag */
CMP R0,#+0
BEQ ??OSTaskDel_9
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -