📄 ucos_ii.s
字号:
; *********************************************************************************************************
; */
;
; void OSIntEnter (void)
; {
.dbline 296
; if (OSRunning == TRUE) {
lds R24,_OSRunning
cpi R24,1
brne L3
X0:
.dbline 296
.dbline 297
; if (OSIntNesting < 255u) {
lds R24,_OSIntNesting
cpi R24,255
brsh L5
X1:
.dbline 297
.dbline 298
; OSIntNesting++; /* Increment ISR nesting level */
subi R24,255 ; addi 1
sts _OSIntNesting,R24
.dbline 299
; }
L5:
.dbline 300
; }
L3:
.dbline -2
L2:
.dbline 0 ; func end
ret
.dbend
.dbfunc e OSIntExit _OSIntExit fV
; cpu_sr -> R10
.even
_OSIntExit::
xcall push_xgset300C
.dbline -1
.dbline 323
; }
; /*$PAGE*/
; /*
; *********************************************************************************************************
; * 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 OS_SchedLock())
; *********************************************************************************************************
; */
;
; void OSIntExit (void)
; {
.dbline 329
; #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
; OS_CPU_SR cpu_sr;
; #endif
;
;
; if (OSRunning == TRUE) {
lds R24,_OSRunning
cpi R24,1
breq X7
xjmp L8
X7:
X2:
.dbline 329
.dbline 330
; OS_ENTER_CRITICAL();
xcall _OS_CPU_SR_Save
mov R10,R16
.dbline 331
; if (OSIntNesting > 0) { /* Prevent OSIntNesting from wrapping */
ldi R24,0
lds R2,_OSIntNesting
cp R24,R2
brsh L10
X3:
.dbline 331
.dbline 332
; OSIntNesting--;
mov R24,R2
subi R24,1
sts _OSIntNesting,R24
.dbline 333
; }
L10:
.dbline 334
; if (OSIntNesting == 0) { /* Reschedule only if all ISRs complete ... */
lds R2,_OSIntNesting
tst R2
breq X8
xjmp L12
X8:
X4:
.dbline 334
.dbline 335
; if (OSLockNesting == 0) { /* ... and not locked. */
lds R2,_OSLockNesting
tst R2
breq X9
xjmp L14
X9:
X5:
.dbline 335
.dbline 336
; OSIntExitY = OSUnMapTbl[OSRdyGrp];
ldi R24,<_OSUnMapTbl
ldi R25,>_OSUnMapTbl
lds R30,_OSRdyGrp
clr R31
add R30,R24
adc R31,R25
elpm R2,Z
sts _OSIntExitY,R2
.dbline 337
; OSPrioHighRdy = (INT8U)((OSIntExitY << 3) + OSUnMapTbl[OSRdyTbl[OSIntExitY]]);
mov R4,R2
ldi R24,<_OSRdyTbl
ldi R25,>_OSRdyTbl
mov R30,R2
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
elpm R2,Z
clr R3
clr R5
lsl R4
rol R5
lsl R4
rol R5
lsl R4
rol R5
add R4,R2
adc R5,R3
sts _OSPrioHighRdy,R4
.dbline 338
; if (OSPrioHighRdy != OSPrioCur) { /* No Ctx Sw if current task is highest rdy */
lds R2,_OSPrioCur
mov R3,R4
cp R4,R2
brne X10
xjmp L16
X10:
X6:
.dbline 338
.dbline 339
; OSTCBHighRdy = OSTCBPrioTbl[OSPrioHighRdy];
ldi R24,<_OSTCBPrioTbl
ldi R25,>_OSTCBPrioTbl
mov R30,R4
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_TASK_PROFILE_EN > 0
; OSTCBHighRdy->OSTCBCtxSwCtr++; /* Inc. # of context switches to this task */
movw R20,R2
subi R20,240 ; offset = 16
sbci R21,255
ldi R24,1
ldi R25,0
ldi R26,0
ldi R27,0
movw R30,R20
ldd R2,z+0
ldd R3,z+1
ldd R4,z+2
ldd R5,z+3
add R2,R24
adc R3,R25
adc R4,R26
adc R5,R27
std z+0,R2
std z+1,R3
std z+2,R4
std z+3,R5
.dbline 343
; #endif
; OSCtxSwCtr++; /* Keep track of the number of ctx switches */
ldi R24,1
ldi R25,0
ldi R26,0
ldi R27,0
lds R4,_OSCtxSwCtr+2
lds R5,_OSCtxSwCtr+2+1
lds R2,_OSCtxSwCtr
lds R3,_OSCtxSwCtr+1
add R2,R24
adc R3,R25
adc R4,R26
adc R5,R27
sts _OSCtxSwCtr+1,R3
sts _OSCtxSwCtr,R2
sts _OSCtxSwCtr+2+1,R5
sts _OSCtxSwCtr+2,R4
.dbline 344
; OSIntCtxSw(); /* Perform interrupt level ctx switch */
xcall _OSIntCtxSw
.dbline 345
; }
L16:
.dbline 346
; }
L14:
.dbline 347
; }
L12:
.dbline 348
; OS_EXIT_CRITICAL();
mov R16,R10
xcall _OS_CPU_SR_Restore
.dbline 349
; }
L8:
.dbline -2
L7:
.dbline 0 ; func end
xjmp pop_xgset300C
.dbsym r cpu_sr 10 c
.dbend
.dbfunc e OSSchedLock _OSSchedLock fV
; cpu_sr -> R10
.even
_OSSchedLock::
st -y,R10
.dbline -1
.dbline 370
; }
; /*$PAGE*/
; /*
; *********************************************************************************************************
; * 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)
; {
.dbline 376
; #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 */
lds R24,_OSRunning
cpi R24,1
brne L19
X11:
.dbline 376
.dbline 377
; OS_ENTER_CRITICAL();
xcall _OS_CPU_SR_Save
mov R10,R16
.dbline 378
; if (OSLockNesting < 255u) { /* Prevent OSLockNesting from wrapping back to 0 */
lds R24,_OSLockNesting
cpi R24,255
brsh L21
X12:
.dbline 378
.dbline 379
; OSLockNesting++; /* Increment lock nesting level */
subi R24,255 ; addi 1
sts _OSLockNesting,R24
.dbline 380
; }
L21:
.dbline 381
; OS_EXIT_CRITICAL();
mov R16,R10
xcall _OS_CPU_SR_Restore
.dbline 382
; }
L19:
.dbline -2
L18:
.dbline 0 ; func end
ld R10,y+
ret
.dbsym r cpu_sr 10 c
.dbend
.dbfunc e OSSchedUnlock _OSSchedUnlock fV
; cpu_sr -> R10
.even
_OSSchedUnlock::
st -y,R10
.dbline -1
.dbline 404
; }
; #endif
;
; /*$PAGE*/
; /*
; *********************************************************************************************************
; * 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)
; {
.dbline 410
; #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 */
lds R24,_OSRunning
cpi R24,1
brne L24
X13:
.dbline 410
.dbline 411
; OS_ENTER_CRITICAL();
xcall _OS_CPU_SR_Save
mov R10,R16
.dbline 412
; if (OSLockNesting > 0) { /* Do not decrement if already 0 */
ldi R24,0
lds R2,_OSLockNesting
cp R24,R2
brsh L26
X14:
.dbline 412
.dbline 413
; OSLockNesting--; /* Decrement lock nesting level */
mov R24,R2
subi R24,1
sts _OSLockNesting,R24
.dbline 414
; if (OSLockNesting == 0) { /* See if scheduler is enabled and ... */
tst R24
brne L28
X15:
.dbline 414
.dbline 415
; if (OSIntNesting == 0) { /* ... not in an ISR */
lds R2,_OSIntNesting
tst R2
brne L30
X16:
.dbline 415
.dbline 416
; OS_EXIT_CRITICAL();
xcall _OS_CPU_SR_Restore
.dbline 417
; OS_Sched(); /* See if a HPT is ready */
xcall _OS_Sched
.dbline 418
; } else {
xjmp L27
L30:
.dbline 418
.dbline 419
; OS_EXIT_CRITICAL();
mov R16,R10
xcall _OS_CPU_SR_Restore
.dbline 420
; }
.dbline 421
; } else {
xjmp L27
L28:
.dbline 421
.dbline 422
; OS_EXIT_CRITICAL();
mov R16,R10
xcall _OS_CPU_SR_Restore
.dbline 423
; }
.dbline 424
; } else {
xjmp L27
L26:
.dbline 424
.dbline 425
; OS_EXIT_CRITICAL();
mov R16,R10
xcall _OS_CPU_SR_Restore
.dbline 426
; }
L27:
.dbline 427
; }
L24:
.dbline -2
L23:
.dbline 0 ; func end
ld R10,y+
ret
.dbsym r cpu_sr 10 c
.dbend
.dbfunc e OSStart _OSStart fV
; x -> R12
; y -> R10
.even
_OSStart::
st -y,R10
st -y,R12
.dbline -1
.dbline 453
; }
; #endif
;
; /*$PAGE*/
; /*
; *********************************************************************************************************
; * 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,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -