?? os-task-switch.s
字號:
?
+
lds R2,_OSRunning
tst R2
brne L34
.dbline 178
.dbline 179
; OSPrioHighRdy = 0;
clr R2
sts _OSPrioHighRdy,R2
.dbline 180
; OSPrioCur = 0;
sts _OSPrioCur,R2
.dbline 181
; OSTCBHighRdy = OSpTCBList[OSPrioHighRdy]; /* Point to highest priority task ready to run */
ldi R24,<_OSpTCBList
ldi R25,>_OSpTCBList
mov R30,R2
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 182
; OSTCBCur = OSTCBHighRdy;
sts _OSTCBCur+1,R3
sts _OSTCBCur,R2
.dbline 184
; #if OS_STRICT
; if(0==OSTCBCur)
tst R2
brne L36
tst R3
brne L36
X4:
.dbline 185
; OSError(0);
clr R16
rcall _OSError
L36:
.dbline 187
; #endif
; OSStartHighRdy(); /* Execute target specific code to start task */
rcall _OSStartHighRdy
.dbline 188
; }
rjmp L35
L34:
.dbline 190
clr R16
rcall _OSError
L35:
.dbline -2
.dbline 192
; #if OS_STRICT
; else OSError(0);
; #endif
; }
L33:
.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 L39
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
L39:
.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! */
; }
; }
L38:
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r ticks 20 i
.dbend
.dbfunc e OSGetPrioRdy _OSGetPrioRdy fc
; ret -> R20
; ptcb -> R10,R11
; i -> R22
.even
_OSGetPrioRdy::
rcall push_gset3
.dbline -1
.dbline 221
; /*return tcb's prio which OSTCBDly==0*/
; 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 L45
L42:
.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
brne X8
rjmp L46
X8:
X6:
.dbline 229
; {
.dbline 230
; if(0==ptcb->OSTCBDly)
mov R30,R10
mov R31,R11
ldd R2,z+2
ldd R3,z+3
tst R2
breq X9
rjmp L48
X9:
tst R3
breq X10
rjmp L48
X10:
X7:
.dbline 231
; {
.dbline 232
; if(OS_STAT_RDY==ptcb->OSTCBStat)
mov R30,R10
mov R31,R11
ldd R24,z+4
cpi R24,1
brne L50
.dbline 233
; {
.dbline 235
; #if OS_STRICT
; if(i!=ptcb->OSTCBPrio)
ldd R2,z+5
cp R22,R2
breq L52
.dbline 236
; OSError(0);
clr R16
rcall _OSError
L52:
.dbline 238
; #endif
; ret=ptcb->OSTCBPrio;
mov R30,R10
mov R31,R11
ldd R20,z+5
.dbline 240
; #if OS_STRICT
; if(ret>OS_LOWEST_PRIO)
ldi R24,2
cp R24,R20
brsh L44
.dbline 241
; OSError(0);
clr R16
rcall _OSError
.dbline 243
; #endif
; break;//for
rjmp L44
L50:
.dbline 246
; }//end OS_STAT_RDY==ptcb->OSTCBStat
; #if OS_SEM_EN
; else{
.dbline 247
; if(ptcb->OSTCBStat & OS_STAT_SEM)
mov R30,R10
mov R31,R11
ldd R2,z+4
sbrs R2,1
rjmp L56
.dbline 248
; {
.dbline 250
; #if OS_STRICT
; if(i!=ptcb->OSTCBPrio)
ldd R2,z+5
cp R22,R2
breq L58
.dbline 251
; OSError(0);
clr R16
rcall _OSError
L58:
.dbline 253
; #endif
; ret=ptcb->OSTCBPrio;
mov R30,R10
mov R31,R11
ldd R20,z+5
.dbline 255
; #if OS_STRICT
; if(ret>OS_LOWEST_PRIO)
ldi R24,2
cp R24,R20
brsh L44
.dbline 256
; OSError(0);
clr R16
rcall _OSError
.dbline 258
; #endif
; break;//for
rjmp L44
L56:
.dbline 260
; }
; }//end (ptcb->OSTCBStat & OS_STAT_SEM)
.dbline 262
; #endif//OS_SEM_EN
; }//end (0==ptcb->OSTCBDly)
L48:
.dbline 263
; }
L46:
.dbline 265
L43:
.dbline 224
inc R22
L45:
.dbline 224
cpi R22,3
brsh X11
rjmp L42
X11:
L44:
.dbline 266
; //OS_EXIT_CRITICAL();
; }
; return ret;
mov R16,R20
.dbline -2
L41:
rcall pop_gset3
.dbline 0 ; func end
ret
.dbsym r ret 20 c
.dbsym r ptcb 10 pX
.dbsym r i 22 c
.dbend
.dbfunc e OSTimeTick _OSTimeTick fV
; ret -> <dead>
; ptcb -> R16,R17
; i -> R18
.even
_OSTimeTick::
.dbline -1
.dbline 284
; }
;
; /*
; *********************************************************************************************************
; * 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 288
; 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 L66
L63:
.dbline 289
; {
.dbline 290
; 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 293
; // OS_ENTER_CRITICAL();
; //check ptcb != 0
; if(ptcb){ /* Go through all TCBs in TCB list */
cpi R16,0
cpc R16,R17
breq L67
X12:
.dbline 293
.dbline 294
; 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 X13
tst R3
breq L69
X13:
.dbline 294
.dbline 295
; 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 L71
X14:
.dbline 295
.dbline 302
; // 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 ... */
; // ptcb->OSTCBDly = 1; /* ... loosing the task when the ... */
; // } /* ... suspension is removed. */
; }//end (--ptcb->OSTCBDly==0)
L71:
.dbline 303
; }//end OSTCBDly!=0
L69:
.dbline 304
; }//end if(ptcb)
L67:
.dbline 306
L64:
.dbline 288
inc R18
L66:
.dbline 288
cpi R18,2
brlo L63
.dbline -2
.dbline 307
; // OS_EXIT_CRITICAL();
; }//end for
; }
L62:
.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 329
;
; /*
; *********************************************************************************************************
; * 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 330
; OS_ENTER_CRITICAL();
st -y,r16
in r16,0x3f
cli
push r16
ld r16,y+
.dbline 330
.dbline 331
; 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 X17
rjmp L74
X17:
.dbline 331
.dbline 332
; OSPrioHighRdy=OSGetPrioRdy();
rcall _OSGetPrioRdy
sts _OSPrioHighRdy,R16
.dbline 333
; if(OSPrioHighRdy>OS_LOWEST_PRIO)
ldi R24,2
cp R24,R16
brsh L76
.dbline 334
; {
.dbline 336
; #if OS_STRICT
; OSError(0);
clr R16
rcall _OSError
.dbline 338
rjmp L77
L76:
.dbline 338
; #endif
; }else if (OSPrioHighRdy != OSPrioCur) { /* No context switch if current task is highest ready */
lds R2,_OSPrioCur
lds R3,_OSPrioHighRdy
cp R3,R2
breq L78
.dbline 338
.dbline 339
; 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 341
; #if OS_STRICT
; if((0==OSTCBHighRdy)||(0==OSTCBCur)||
tst R2
brne X15
tst R3
breq L84
X15:
lds R2,_OSTCBCur
lds R3,_OSTCBCur+1
tst R2
brne X16
tst R3
breq L84
X16:
ldi R24,2
lds R2,_OSPrioCur
cp R24,R2
brlo L84
lds R2,_OSPrioHighRdy
cp R24,R2
brsh L80
L84:
.dbline 343
; (OSPrioCur>OS_LOWEST_PRIO)||(OSPrioHighRdy>OS_LOWEST_PRIO))
; OSError(0);
clr R16
rcall _OSError
L80:
.dbline 345
; #endif
; OSDebug();
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -