📄 os_core.s
字号:
.dbline 184
.dbline 185
; OSIntExitY = OSUnMapTbl[OSRdyGrp]; /* ... and not locked. */
ldi R24,<_OSUnMapTbl
ldi R25,>_OSUnMapTbl
lds R30,_OSRdyGrp
clr R31
add R30,R24
adc R31,R25
lpm R30,Z
sts _OSIntExitY,R30
.dbline 186
; OSPrioHighRdy = (INT8U)((OSIntExitY << 3) + OSUnMapTbl[OSRdyTbl[OSIntExitY]]);
ldi R24,<_OSRdyTbl
ldi R25,>_OSRdyTbl
clr R31
add R30,R24
adc R31,R25
ldd R30,z+0
clr R31
ldi R24,<_OSUnMapTbl
ldi R25,>_OSUnMapTbl
add R30,R24
adc R31,R25
lpm R2,Z
clr R3
lds R4,_OSIntExitY
clr R5
lsl R4
rol R5
lsl R4
rol R5
lsl R4
rol R5
add R4,R2
adc R5,R3
sts _OSPrioHighRdy,R4
.dbline 187
; if (OSPrioHighRdy != OSPrioCur) { /* No Ctx Sw if current task is highest rdy */
lds R2,_OSPrioCur
cp R4,R2
breq L16
.dbline 187
.dbline 188
; OSTCBHighRdy = OSTCBPrioTbl[OSPrioHighRdy];
mov R2,R4
ldi R24,2
mul R24,R2
movw R30,R0
ldi R24,<_OSTCBPrioTbl
ldi R25,>_OSTCBPrioTbl
add R30,R24
adc R31,R25
ldd R2,z+0
ldd R3,z+1
sts _OSTCBHighRdy+1,R3
sts _OSTCBHighRdy,R2
.dbline 189
; OSCtxSwCtr++; /* Keep track of the number of ctx switches */
ldi R20,1
ldi R21,0
ldi R22,0
ldi R23,0
lds R4,_OSCtxSwCtr+2
lds R5,_OSCtxSwCtr+2+1
lds R2,_OSCtxSwCtr
lds R3,_OSCtxSwCtr+1
add R2,R20
adc R3,R21
adc R4,R22
adc R5,R23
sts _OSCtxSwCtr+1,R3
sts _OSCtxSwCtr,R2
sts _OSCtxSwCtr+2+1,R5
sts _OSCtxSwCtr+2,R4
.dbline 190
; OSIntCtxSw(); /* Perform interrupt level ctx switch */
xcall _OSIntCtxSw
.dbline 191
; }
L16:
.dbline 192
; }
L14:
.dbline 193
st -y,r16
pop r16
out 0x3F,r16
ld r16,y+
.dbline 193
.dbline 194
L10:
.dbline -2
L9:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbend
.dbfunc e OSStart _OSStart fV
; x -> R22
; y -> R20
.even
_OSStart::
xcall push_gset2
.dbline -1
.dbline 294
.dbline 299
lds R2,_OSRunning
tst R2
breq X3
xjmp L19
X3:
.dbline 299
.dbline 300
ldi R24,<_OSUnMapTbl
ldi R25,>_OSUnMapTbl
lds R30,_OSRdyGrp
clr R31
add R30,R24
adc R31,R25
lpm R20,Z
.dbline 301
ldi R24,<_OSRdyTbl
ldi R25,>_OSRdyTbl
mov R30,R20
clr R31
add R30,R24
adc R31,R25
ldd R30,z+0
clr R31
ldi R24,<_OSUnMapTbl
ldi R25,>_OSUnMapTbl
add R30,R24
adc R31,R25
lpm R22,Z
.dbline 302
mov R2,R22
clr R3
mov R4,R20
clr R5
lsl R4
rol R5
lsl R4
rol R5
lsl R4
rol R5
add R4,R2
adc R5,R3
sts _OSPrioHighRdy,R4
.dbline 303
mov R2,R4
sts _OSPrioCur,R2
.dbline 304
ldi R24,2
mul R24,R2
movw R30,R0
ldi R24,<_OSTCBPrioTbl
ldi R25,>_OSTCBPrioTbl
add R30,R24
adc R31,R25
ldd R2,z+0
ldd R3,z+1
sts _OSTCBHighRdy+1,R3
sts _OSTCBHighRdy,R2
.dbline 305
sts _OSTCBCur+1,R3
sts _OSTCBCur,R2
.dbline 306
xcall _OSStartHighRdy
.dbline 307
L19:
.dbline -2
L18:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r x 22 c
.dbsym r y 20 c
.dbend
.dbfunc e OSTimeTick _OSTimeTick fV
.dbstruct 0 10 .2
.dbfield 0 OSFlagNodeNext pV
.dbfield 2 OSFlagNodePrev pV
.dbfield 4 OSFlagNodeTCB pV
.dbfield 6 OSFlagNodeFlagGrp pV
.dbfield 8 OSFlagNodeFlags c
.dbfield 9 OSFlagNodeWaitType c
.dbend
.dbstruct 0 18 os_tcb
.dbfield 0 OSTCBStkPtr pc
.dbfield 2 OSTCBNext pS[os_tcb]
.dbfield 4 OSTCBPrev pS[os_tcb]
.dbfield 6 OSTCBFlagNode pS[.2]
.dbfield 8 OSTCBFlagsRdy c
.dbfield 9 OSTCBDly i
.dbfield 11 OSTCBStat c
.dbfield 12 OSTCBPrio c
.dbfield 13 OSTCBX c
.dbfield 14 OSTCBY c
.dbfield 15 OSTCBBitX c
.dbfield 16 OSTCBBitY c
.dbfield 17 OSTCBDelReq c
.dbend
; ptcb -> R20,R21
.even
_OSTimeTick::
xcall push_gset1
.dbline -1
.dbline 365
; OS_EXIT_CRITICAL();
; }
; }
;
; /*
; *********************************************************************************************************
; * PREVENT SCHEDULING
; *
; * Description: This function is used to prevent rescheduling to take place. This allows your application
; * to prevent context switches until you are ready to permit context switching.
; *
; * Arguments : none
; *
; * Returns : none
; *
; * Notes : 1) You MUST invoke OSSchedLock() and OSSchedUnlock() in pair. In other words, for every
; * call to OSSchedLock() you MUST have a call to OSSchedUnlock().
; *********************************************************************************************************
; */
;
; #if OS_SCHED_LOCK_EN > 0
; void OSSchedLock (void)
; {
; #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
; OS_CPU_SR cpu_sr;
; #endif
;
;
; if (OSRunning == TRUE) { /* Make sure multitasking is running */
; OS_ENTER_CRITICAL();
; if (OSLockNesting < 255) { /* Prevent OSLockNesting from wrapping back to 0 */
; OSLockNesting++; /* Increment lock nesting level */
; }
; OS_EXIT_CRITICAL();
; }
; }
; #endif
;
;
; /*
; *********************************************************************************************************
; * ENABLE SCHEDULING
; *
; * Description: This function is used to re-allow rescheduling.
; *
; * Arguments : none
; *
; * Returns : none
; *
; * Notes : 1) You MUST invoke OSSchedLock() and OSSchedUnlock() in pair. In other words, for every
; * call to OSSchedLock() you MUST have a call to OSSchedUnlock().
; *********************************************************************************************************
; */
;
; #if OS_SCHED_LOCK_EN > 0
; void OSSchedUnlock (void)
; {
; #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
; OS_CPU_SR cpu_sr;
; #endif
;
;
; if (OSRunning == TRUE) { /* Make sure multitasking is running */
; OS_ENTER_CRITICAL();
; if (OSLockNesting > 0) { /* Do not decrement if already 0 */
; OSLockNesting--; /* Decrement lock nesting level */
; if ((OSLockNesting == 0) && (OSIntNesting == 0)) { /* See if sched. enabled and not an ISR */
; OS_EXIT_CRITICAL();
; OS_Sched(); /* See if a HPT is ready */
; } else {
; OS_EXIT_CRITICAL();
; }
; } else {
; OS_EXIT_CRITICAL();
; }
; }
; }
; #endif
;
;
; /*
; *********************************************************************************************************
; * START MULTITASKING
; *
; * Description: This function is used to start the multitasking process which lets uC/OS-II manages the
; * task that you have created. Before you can call OSStart(), you MUST have called OSInit()
; * and you MUST have created at least one task.
; *
; * Arguments : none
; *
; * Returns : none
; *
; * Note : OSStartHighRdy() MUST:
; * a) Call OSTaskSwHook() then,
; * b) Set OSRunning to TRUE.
; * c) Load the context of the task pointed to by OSTCBHighRdy.
; * d_ Execute the task.
; *********************************************************************************************************
; */
;
; void OSStart (void)
; {
; INT8U y;
; INT8U x;
;
;
; if (OSRunning == FALSE) {
; y = OSUnMapTbl[OSRdyGrp]; /* Find highest priority's task priority number */
; x = OSUnMapTbl[OSRdyTbl[y]];
; OSPrioHighRdy = (INT8U)((y << 3) + x);
; OSPrioCur = OSPrioHighRdy;
; OSTCBHighRdy = OSTCBPrioTbl[OSPrioHighRdy]; /* Point to highest priority task ready to run */
; OSTCBCur = OSTCBHighRdy;
; OSStartHighRdy(); /* Execute target specific code to start task */
; }
; }
;
; /*
; *********************************************************************************************************
; * STATISTICS INITIALIZATION
; *
; * Description: This function is called by your application to establish CPU usage by first determining
; * how high a 32-bit counter would count to in 1 second if no other tasks were to execute
; * during that time. CPU usage is then determined by a low priority task which keeps track
; * of this 32-bit counter every second but this time, with other tasks running. CPU usage is
; * determined by:
; *
; * OSIdleCtr
; * CPU Usage (%) = 100 * (1 - ------------)
; * OSIdleCtrMax
; *
; * Arguments : none
; *
; * Returns : none
; *********************************************************************************************************
; */
;
; #if OS_TASK_STAT_EN > 0
; void OSStatInit (void)
; {
; #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
; OS_CPU_SR cpu_sr;
; #endif
;
;
; OSTimeDly(2); /* Synchronize with clock tick */
; OS_ENTER_CRITICAL();
; OSIdleCtr = 0L; /* Clear idle counter */
; OS_EXIT_CRITICAL();
; OSTimeDly(OS_TICKS_PER_SEC); /* Determine MAX. idle counter value for 1 second */
; OS_ENTER_CRITICAL();
; OSIdleCtrMax = OSIdleCtr; /* Store maximum idle counter count in 1 second */
; OSStatRdy = TRUE;
; OS_EXIT_CRITICAL();
; }
; #endif
;
; /*
; *********************************************************************************************************
; * 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 372
; #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
; OS_CPU_SR cpu_sr;
; #endif
; OS_TCB *ptcb;
;
;
; OSTimeTickHook(); /* Call user definable hook */
xcall _OSTimeTickHook
.dbline 378
; #if OS_TIME_GET_SET_EN > 0
; OS_ENTER_CRITICAL(); /* Update the 32-bit tick counter */
; OSTime++;
; OS_EXIT_CRITICAL();
; #endif
; if (OSRunning == TRUE) {
lds R24,_OSRunning
cpi R24,1
breq X6
xjmp L22
X6:
.dbline 378
.dbline 379
; ptcb = OSTCBList; /* Point at first TCB in TCB list */
lds R20,_OSTCBList
lds R21,_OSTCBList+1
xjmp L25
L24:
.dbline 380
; while (ptcb->OSTCBPrio != OS_IDLE_PRIO) { /* Go through all TCBs in TCB list */
.dbline 381
; OS_ENTER_CRITICAL();
st -y,r16
in r16,0x3F
cli
push r16
ld r16,y+
.dbline 381
.dbline 382
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -