📄 os_core.s
字号:
cpi R24,1
brne L3
.dbline 290
.dbline 291
; if (OSIntNesting < 255u) {
lds R24,_OSIntNesting
cpi R24,255
brsh L5
.dbline 291
.dbline 292
; OSIntNesting++; /* Increment ISR nesting level */
subi R24,255 ; addi 1
sts _OSIntNesting,R24
.dbline 293
; }
L5:
.dbline 294
L3:
.dbline -2
L2:
.dbline 0 ; func end
ret
.dbend
.dbfunc e OSIntExit _OSIntExit fV
; cpu_sr -> R10
.even
_OSIntExit::
xcall push_gset3
.dbline -1
.dbline 317
; }
; }
; /*$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 319
; #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
; OS_CPU_SR cpu_sr = 0;
clr R10
.dbline 324
; #endif
;
;
;
; if (OSRunning == TRUE) {
lds R24,_OSRunning
cpi R24,1
breq X0
xjmp L8
X0:
.dbline 324
.dbline 325
; OS_ENTER_CRITICAL();
xcall _OS_CPU_SR_Save
mov R10,R16
.dbline 326
; if (OSIntNesting > 0) { /* Prevent OSIntNesting from wrapping */
clr R2
lds R3,_OSIntNesting
cp R2,R3
brsh L10
.dbline 326
.dbline 327
; OSIntNesting--;
mov R24,R3
subi R24,1
sts _OSIntNesting,R24
.dbline 328
; }
L10:
.dbline 329
; if (OSIntNesting == 0) { /* Reschedule only if all ISRs complete ... */
lds R2,_OSIntNesting
tst R2
brne L12
.dbline 329
.dbline 330
; if (OSLockNesting == 0) { /* ... and not locked. */
lds R2,_OSLockNesting
tst R2
brne L14
.dbline 330
.dbline 331
; OS_SchedNew();
xcall _OS_SchedNew
.dbline 332
; if (OSPrioHighRdy != OSPrioCur) { /* No Ctx Sw if current task is highest rdy */
lds R2,_OSPrioCur
lds R3,_OSPrioHighRdy
cp R3,R2
breq L16
.dbline 332
.dbline 333
; OSTCBHighRdy = OSTCBPrioTbl[OSPrioHighRdy];
mov R2,R3
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 337
; #if OS_TASK_PROFILE_EN > 0
; OSTCBHighRdy->OSTCBCtxSwCtr++; /* Inc. # of context switches to this task */
; #endif
; 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 338
; OSIntCtxSw(); /* Perform interrupt level ctx switch */
xcall _OSIntCtxSw
.dbline 339
; }
L16:
.dbline 340
; }
L14:
.dbline 341
; }
L12:
.dbline 342
mov R16,R10
xcall _OS_CPU_SR_Restore
.dbline 343
L8:
.dbline -2
L7:
xcall pop_gset3
.dbline 0 ; func end
ret
.dbsym r cpu_sr 10 c
.dbend
.dbfunc e OSSchedLock _OSSchedLock fV
; cpu_sr -> R20
.even
_OSSchedLock::
xcall push_gset1
.dbline -1
.dbline 364
; OS_EXIT_CRITICAL();
; }
; }
; /*$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 366
; #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
; OS_CPU_SR cpu_sr = 0;
clr R20
.dbline 371
; #endif
;
;
;
; if (OSRunning == TRUE) { /* Make sure multitasking is running */
lds R24,_OSRunning
cpi R24,1
brne L19
.dbline 371
.dbline 372
; OS_ENTER_CRITICAL();
xcall _OS_CPU_SR_Save
mov R20,R16
.dbline 373
; if (OSLockNesting < 255u) { /* Prevent OSLockNesting from wrapping back to 0 */
lds R24,_OSLockNesting
cpi R24,255
brsh L21
.dbline 373
.dbline 374
; OSLockNesting++; /* Increment lock nesting level */
subi R24,255 ; addi 1
sts _OSLockNesting,R24
.dbline 375
; }
L21:
.dbline 376
mov R16,R20
xcall _OS_CPU_SR_Restore
.dbline 377
L19:
.dbline -2
L18:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r cpu_sr 20 c
.dbend
.dbfunc e OSSchedUnlock _OSSchedUnlock fV
; cpu_sr -> R20
.even
_OSSchedUnlock::
xcall push_gset1
.dbline -1
.dbline 399
; OS_EXIT_CRITICAL();
; }
; }
; #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 401
; #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
; OS_CPU_SR cpu_sr = 0;
clr R20
.dbline 406
; #endif
;
;
;
; if (OSRunning == TRUE) { /* Make sure multitasking is running */
lds R24,_OSRunning
cpi R24,1
brne L24
.dbline 406
.dbline 407
; OS_ENTER_CRITICAL();
xcall _OS_CPU_SR_Save
mov R20,R16
.dbline 408
; if (OSLockNesting > 0) { /* Do not decrement if already 0 */
clr R2
lds R3,_OSLockNesting
cp R2,R3
brsh L26
.dbline 408
.dbline 409
; OSLockNesting--; /* Decrement lock nesting level */
mov R24,R3
subi R24,1
sts _OSLockNesting,R24
.dbline 410
; if (OSLockNesting == 0) { /* See if scheduler is enabled and ... */
tst R24
brne L28
.dbline 410
.dbline 411
; if (OSIntNesting == 0) { /* ... not in an ISR */
lds R2,_OSIntNesting
tst R2
brne L30
.dbline 411
.dbline 412
; OS_EXIT_CRITICAL();
xcall _OS_CPU_SR_Restore
.dbline 413
; OS_Sched(); /* See if a HPT is ready */
xcall _OS_Sched
.dbline 414
xjmp L27
L30:
.dbline 414
; } else {
.dbline 415
; OS_EXIT_CRITICAL();
mov R16,R20
xcall _OS_CPU_SR_Restore
.dbline 416
; }
.dbline 417
xjmp L27
L28:
.dbline 417
; } else {
.dbline 418
; OS_EXIT_CRITICAL();
mov R16,R20
xcall _OS_CPU_SR_Restore
.dbline 419
; }
.dbline 420
xjmp L27
L26:
.dbline 420
; } else {
.dbline 421
; OS_EXIT_CRITICAL();
mov R16,R20
xcall _OS_CPU_SR_Restore
.dbline 422
; }
L27:
.dbline 423
L24:
.dbline -2
L23:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r cpu_sr 20 c
.dbend
.dbfunc e OSStart _OSStart fV
.even
_OSStart::
.dbline -1
.dbline 449
.dbline 450
lds R2,_OSRunning
tst R2
brne L33
.dbline 450
.dbline 451
xcall _OS_SchedNew
.dbline 452
lds R2,_OSPrioHighRdy
sts _OSPrioCur,R2
.dbline 453
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 454
sts _OSTCBCur+1,R3
sts _OSTCBCur,R2
.dbline 455
xcall _OSStartHighRdy
.dbline 456
L33:
.dbline -2
L32:
.dbline 0 ; func end
ret
.dbend
.dbfunc e OSTimeTick _OSTimeTick fV
.dbstruct 0 8 os_event
.dbfield 0 OSEventType c
.dbfield 1 OSEventPtr pV
.dbfield 3 OSEventCnt i
.dbfield 5 OSEventGrp c
.dbfield 6 OSEventTbl A[2:2]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 OSTCBEventPtr pS[os_event]
.dbfield 8 OSTCBDly i
.dbfield 10 OSTCBStat c
.dbfield 11 OSTCBPendTO 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
; step -> R20
; cpu_sr -> R22
; ptcb -> R20,R21
.even
_OSTimeTick::
xcall push_gset2
.dbline -1
.dbline 515
; }
; }
; #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,
; * b) Set OSRunning to TRUE.
; * c) Load the context of the task pointed to by OSTCBHighRdy.
; * d_ Execute the task.
; *********************************************************************************************************
; */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -