📄 os-task-switch.s
字号:
sts _OSTCBCur+1,R3
sts _OSTCBCur,R2
.dbline 184
; #if OS_STRICT
; if(0==OSTCBCur)
tst R2
brne L35
tst R3
brne L35
X4:
.dbline 185
; OSError(0);
clr R16
rcall _OSError
L35:
.dbline 187
; #endif
; OSStartHighRdy(); /* Execute target specific code to start task */
rcall _OSStartHighRdy
.dbline 188
; }
rjmp L34
L33:
.dbline 190
clr R16
rcall _OSError
L34:
.dbline -2
.dbline 192
; #if OS_STRICT
; else OSError(0);
; #endif
; }
L32:
.dbline 0 ; func end
ret
.dbend
.dbfunc e OSTimeDly _OSTimeDly fV
; ticks -> R20,R21
.even
_OSTimeDly::
rcall push_gset1
mov R20,R16
mov R21,R17
.dbline -1
.dbline 211
.dbline 212
cpi R20,0
cpc R20,R21
breq L38
X5:
.dbline 212
.dbline 213
st -y,r16
in r16,0x3f
cli
push r16
ld r16,y+
.dbline 213
.dbline 214
lds R30,_OSTCBCur
lds R31,_OSTCBCur+1
std z+2,R20
std z+3,R21
.dbline 215
st -y,r16
pop r16
out 0x3F,r16
ld r16,y+
.dbline 215
.dbline 216
rcall _OSSched
.dbline 217
L38:
.dbline -2
.dbline 218
;
; /*
; *********************************************************************************************************
; * DELAY TASK 'n' TICKS (n from 0 to 65535)
; *
; * Description: This function is called to delay execution of the currently running task until the
; * specified number of system ticks expires. This, of course, directly equates to delaying
; * the current task for some time to expire. No delay will result If the specified delay is
; * 0. If the specified delay is greater than 0 then, a context switch will result.
; *
; * Arguments : ticks is the time delay that the task will be suspended in number of clock 'ticks'.
; * Note that by specifying 0, the task will not be delayed.
; *
; * Returns : none
; *********************************************************************************************************
; */
;
; void OSTimeDly (INT16U ticks)
; {
; if (ticks > 0) { /* 0 means no delay! */
; OS_ENTER_CRITICAL();
; OSTCBCur->OSTCBDly = ticks; /* Load ticks in TCB */
; OS_EXIT_CRITICAL();
; OSSched(); /* Find next task to run! */
; }
; }
L37:
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r ticks 20 i
.dbend
.dbfunc e OSGetPrioRdy _OSGetPrioRdy fc
; ret -> R20
; i -> R22
; ptcb -> R10,R11
.even
_OSGetPrioRdy::
rcall push_gset3
.dbline -1
.dbline 221
;
; INT8U OSGetPrioRdy(void)
; {
.dbline 222
; INT8U i,ret=0xff;
ldi R20,255
.dbline 224
; OS_TCB *ptcb;
; for(i=0;i<OS_TASK_COUNT;i++)
clr R22
rjmp L44
L41:
.dbline 225
; {
.dbline 226
; ptcb=OSpTCBList[i];
ldi R24,<_OSpTCBList
ldi R25,>_OSpTCBList
mov R30,R22
clr R31
lsl R30
rol R31
add R30,R24
adc R31,R25
ldd R10,z+0
ldd R11,z+1
.dbline 228
; //OS_ENTER_CRITICAL();
; if(ptcb)
tst R10
brne X6
tst R11
breq L45
X6:
.dbline 229
; if((0==ptcb->OSTCBDly)&&
mov R30,R10
mov R31,R11
ldd R2,z+2
ldd R3,z+3
tst R2
brne L47
tst R3
brne L47
X7:
mov R30,R10
mov R31,R11
ldd R24,z+4
cpi R24,1
brne L47
.dbline 231
; (OS_STAT_RDY==ptcb->OSTCBStat))
; {
.dbline 233
; #if OS_STRICT
; if(i!=ptcb->OSTCBPrio)
ldd R2,z+5
cp R22,R2
breq L49
.dbline 234
; OSError(0);
clr R16
rcall _OSError
L49:
.dbline 236
; #endif
; ret=ptcb->OSTCBPrio;
mov R30,R10
mov R31,R11
ldd R20,z+5
.dbline 238
; #if OS_STRICT
; if(ret>OS_LOWEST_PRIO)
ldi R24,2
cp R24,R20
brsh L43
.dbline 239
; OSError(0);
clr R16
rcall _OSError
.dbline 241
; #endif
; break;//for
rjmp L43
L47:
L45:
.dbline 244
L42:
.dbline 224
inc R22
L44:
.dbline 224
cpi R22,3
brsh X8
rjmp L41
X8:
L43:
.dbline 245
; }
; //OS_EXIT_CRITICAL();
; }
; return ret;
mov R16,R20
.dbline -2
L40:
rcall pop_gset3
.dbline 0 ; func end
ret
.dbsym r ret 20 c
.dbsym r i 22 c
.dbsym r ptcb 10 pX
.dbend
.dbfunc e OSTimeTick _OSTimeTick fV
; ret -> <dead>
; ptcb -> R16,R17
; i -> R18
.even
_OSTimeTick::
.dbline -1
.dbline 263
; }
;
; /*
; *********************************************************************************************************
; * PROCESS SYSTEM TICK
; *
; * Description: This function is used to signal to uC/OS-II the occurrence of a 'system tick' (also known
; * as a 'clock tick'). This function should be called by the ticker ISR but, can also be
; * called by a high priority task.
; *
; * Arguments : none
; *
; * Returns : none
; *********************************************************************************************************
; */
;
; void OSTimeTick (void)
; {
.dbline 267
; INT8U i,ret;
; OS_TCB *ptcb;
; //skip last task,last task must be idle task
; for(i=0;i<OS_TASK_COUNT-1;i++)
clr R18
rjmp L57
L54:
.dbline 268
; {
.dbline 269
; ptcb=OSpTCBList[i];
ldi R24,<_OSpTCBList
ldi R25,>_OSpTCBList
mov R30,R18
clr R31
lsl R30
rol R31
add R30,R24
adc R31,R25
ldd R16,z+0
ldd R17,z+1
.dbline 272
; // OS_ENTER_CRITICAL();
; //check ptcb != 0
; if(ptcb){ /* Go through all TCBs in TCB list */
cpi R16,0
cpc R16,R17
breq L58
X9:
.dbline 272
.dbline 273
; if (ptcb->OSTCBDly != 0) { /* Delayed or waiting for event with TO */
mov R30,R16
mov R31,R17
ldd R2,z+2
ldd R3,z+3
tst R2
brne X10
tst R3
breq L60
X10:
.dbline 273
.dbline 274
; if (--ptcb->OSTCBDly == 0) { /* Decrement nbr of ticks to end of delay */
mov R24,R16
mov R25,R17
adiw R24,2
mov R30,R24
mov R31,R25
ldd R24,z+0
ldd R25,z+1
sbiw R24,1
mov R4,R24
mov R5,R25
std z+0,R4
std z+1,R5
cpi R24,0
cpc R24,R25
brne L62
X11:
.dbline 274
.dbline 278
rjmp L63
L62:
.dbline 278
; // if (!(ptcb->OSTCBStat & OS_STAT_SUSPEND)) { /* Is task suspended? */
; // OSRdyGrp |= ptcb->OSTCBBitY; /* No, Make task Rdy to Run (timed out)*/
; // OSRdyTbl[ptcb->OSTCBY] |= ptcb->OSTCBBitX;
; } else { /* Yes, Leave 1 tick to prevent ... */
.dbline 279
; ptcb->OSTCBDly = 1; /* ... loosing the task when the ... */
ldi R24,1
ldi R25,0
mov R30,R16
mov R31,R17
std z+2,R24
std z+3,R25
.dbline 280
; } /* ... suspension is removed. */
L63:
.dbline 281
; }//end OSTCBDly!=0
L60:
.dbline 282
; }//end if(ptcb)
L58:
.dbline 284
L55:
.dbline 267
inc R18
L57:
.dbline 267
cpi R18,2
brsh X12
rjmp L54
X12:
.dbline -2
.dbline 285
; // OS_EXIT_CRITICAL();
; }//end for
; }
L53:
.dbline 0 ; func end
ret
.dbsym l ret 1 c
.dbsym r ptcb 16 pX
.dbsym r i 18 c
.dbend
.dbfunc e OSIntExit _OSIntExit fV
.even
_OSIntExit::
.dbline -1
.dbline 307
;
; /*
; *********************************************************************************************************
; * EXIT ISR
; *
; * Description: This function is used to notify uC/OS-II that you have completed serviving an ISR. When
; * the last nested ISR has completed, uC/OS-II will call the scheduler to determine whether
; * a new, high-priority task, is ready to run.
; *
; * Arguments : none
; *
; * Returns : none
; *
; * Notes : 1) You MUST invoke OSIntEnter() and OSIntExit() in pair. In other words, for every call
; * to OSIntEnter() at the beginning of the ISR you MUST have a call to OSIntExit() at the
; * end of the ISR.
; * 2) Rescheduling is prevented when the scheduler is locked (see OSSchedLock())
; *********************************************************************************************************
; */
;
; void OSIntExit(void)
; {
.dbline 308
; OS_ENTER_CRITICAL();
st -y,r16
in r16,0x3f
cli
push r16
ld r16,y+
.dbline 308
.dbline 309
; if ((--OSIntNesting | OSLockNesting) == 0) { /* Reschedule only if all ISRs completed & not locked */
lds R24,_OSIntNesting
subi R24,1
mov R2,R24
sts _OSIntNesting,R2
lds R4,_OSLockNesting
or R2,R4
breq X15
rjmp L65
X15:
.dbline 309
.dbline 310
; OSPrioHighRdy=OSGetPrioRdy();
rcall _OSGetPrioRdy
sts _OSPrioHighRdy,R16
.dbline 311
; if(OSPrioHighRdy>OS_LOWEST_PRIO)
ldi R24,2
cp R24,R16
brsh L67
.dbline 312
; {
.dbline 314
; #if OS_STRICT
; OSError(0);
clr R16
rcall _OSError
.dbline 316
rjmp L68
L67:
.dbline 316
; #endif
; }else if (OSPrioHighRdy != OSPrioCur) { /* No context switch if current task is highest ready */
lds R2,_OSPrioCur
lds R3,_OSPrioHighRdy
cp R3,R2
breq L69
.dbline 316
.dbline 317
; OSTCBHighRdy = OSpTCBList[OSPrioHighRdy];
ldi R24,<_OSpTCBList
ldi R25,>_OSpTCBList
mov R30,R3
clr R31
lsl R30
rol R31
add R30,R24
adc R31,R25
ldd R2,z+0
ldd R3,z+1
sts _OSTCBHighRdy+1,R3
sts _OSTCBHighRdy,R2
.dbline 319
; #if OS_STRICT
; if((0==OSTCBHighRdy)||(0==OSTCBCur)||
tst R2
brne X13
tst R3
breq L75
X13:
lds R2,_OSTCBCur
lds R3,_OSTCBCur+1
tst R2
brne X14
tst R3
breq L75
X14:
ldi R24,2
lds R2,_OSPrioCur
cp R24,R2
brlo L75
lds R2,_OSPrioHighRdy
cp R24,R2
brsh L71
L75:
.dbline 321
; (OSPrioCur>OS_LOWEST_PRIO)||(OSPrioHighRdy>OS_LOWEST_PRIO))
; OSError(0);
clr R16
rcall _OSError
L71:
.dbline 323
; #endif
; OSDebug();
rcall _OSDebug
.dbline 324
; OSIntCtxSw(); /* Perform interrupt level context switch */
rcall _OSIntCtxSw
.dbline 325
; }//end OSPrioHighRdy != OSPrioCur
L69:
L68:
.dbline 326
; }//end nesting==0
L65:
.dbline 327
; OS_EXIT_CRITICAL();
st -y,r16
pop r16
out 0x3F,r16
ld r16,y+
.dbline 327
.dbline -2
.dbline 328
; }
L64:
.dbline 0 ; func end
ret
.dbend
.dbfunc e OSDebug _OSDebug fV
; port_a -> R16
.even
_OSDebug::
.dbline -1
.dbline 331
;
; void OSDebug(void)
; {
.dbline 334
; INT8U port_a;
; //debug
; DDRA=0;port_a=PORTA;
clr R2
out 0x1a,R2
.dbline 334
in R16,0x1b
.dbline 335
; DDRA=0xff;PORTA=~port_a;
ldi R24,255
out 0x1a,R24
.dbline 335
mov R2,R16
com R2
out 0x1b,R2
.dbline -2
.dbline 337
; //end debug
; }
L76:
.dbline 0 ; func end
ret
.dbsym r port_a 16 c
.dbend
.area bss(ram, con, rel)
.dbfile G:\编程2002-10-15-HOME\做过的项目\2002-10-22\home-c\software\ucos-ii-at90S-icc-avr\os-task-switch\os-task-switch.c
_stk_task3::
.blkb 128
.dbfile G:\编程2002-10-15-HOME\做过的项目\2002-10-22\home-c\software\ucos-ii-at90S-icc-avr\os-task-switch/includes.h
.dbsym e stk_task3 _stk_task3 A[128:128]c
_stk_task2::
.blkb 128
.dbsym e stk_task2 _stk_task2 A[128:128]c
_stk_task1::
.blkb 128
.dbsym e stk_task1 _stk_task1 A[128:128]c
_tcb_task3::
.blkb 6
.dbsym e tcb_task3 _tcb_task3 X
_tcb_task2::
.blkb 6
.dbsym e tcb_task2 _tcb_task2 X
_tcb_task1::
.blkb 6
.dbsym e tcb_task1 _tcb_task1 X
_OSTCBHighRdy::
.blkb 2
.dbfile G:\编程2002-10-15-HOME\做过的项目\2002-10-22\home-c\software\ucos-ii-at90S-icc-avr\os-task-switch/os-task-switch.h
.dbsym e OSTCBHighRdy _OSTCBHighRdy pX
_OSTCBCur::
.blkb 2
.dbsym e OSTCBCur _OSTCBCur pX
_OSPrioHighRdy::
.blkb 1
.dbsym e OSPrioHighRdy _OSPrioHighRdy c
_OSPrioCur::
.blkb 1
.dbsym e OSPrioCur _OSPrioCur c
_OSLockNesting::
.blkb 1
.dbsym e OSLockNesting _OSLockNesting c
_OSIntNesting::
.blkb 1
.dbsym e OSIntNesting _OSIntNesting c
_OSpTCBList::
.blkb 6
.dbsym e OSpTCBList _OSpTCBList A[6:3]pX
_OSRunning::
.blkb 1
.dbsym e OSRunning _OSRunning c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -