📄 os_core.s
字号:
; OSLockNesting = 0; /* Clear the scheduling lock counter */
sts _OSLockNesting,R2
.dbline 664
;
; OSTaskCtr = 0; /* Clear the number of tasks */
sts _OSTaskCtr,R2
.dbline 666
;
; OSRunning = FALSE; /* Indicate that multitasking not started */
sts _OSRunning,R2
.dbline 668
;
; OSCtxSwCtr = 0; /* Clear the context switch counter */
ldi R20,0
ldi R21,0
ldi R22,0
ldi R23,0
sts _OSCtxSwCtr+1,R21
sts _OSCtxSwCtr,R20
sts _OSCtxSwCtr+2+1,R23
sts _OSCtxSwCtr+2,R22
.dbline 669
; OSIdleCtr = 0L; /* Clear the 32-bit idle counter */
ldi R20,0
ldi R21,0
ldi R22,0
ldi R23,0
sts _OSIdleCtr+1,R21
sts _OSIdleCtr,R20
sts _OSIdleCtr+2+1,R23
sts _OSIdleCtr+2,R22
.dbline -2
L36:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbend
.dbfunc s OS_InitRdyList _OS_InitRdyList fV
; prdytbl -> R16,R17
; i -> R18,R19
.even
_OS_InitRdyList:
.dbline -1
.dbline 692
;
; #if (OS_TASK_STAT_EN > 0) && (OS_TASK_CREATE_EXT_EN > 0)
; OSIdleCtrRun = 0L;
; OSIdleCtrMax = 0L;
; OSStatRdy = FALSE; /* Statistic task is not ready */
; #endif
; }
;
; /*
; *********************************************************************************************************
; * INITIALIZATION
; * INITIALIZE THE READY LIST
; *
; * Description: This function is called by OSInit() to initialize the Ready List.
; *
; * Arguments : none
; *
; * Returns : none
; *********************************************************************************************************
; */
;
; static void OS_InitRdyList (void)
; {
.dbline 697
; INT16U i;
; INT8U *prdytbl;
;
;
; OSRdyGrp = 0x00; /* Clear the ready list */
clr R2
sts _OSRdyGrp,R2
.dbline 698
; prdytbl = &OSRdyTbl[0];
ldi R16,<_OSRdyTbl
ldi R17,>_OSRdyTbl
.dbline 699
clr R18
clr R19
xjmp L41
L38:
.dbline 699
.dbline 700
clr R2
movw R30,R16
st Z+,R2
movw R16,R30
.dbline 701
L39:
.dbline 699
subi R18,255 ; offset = 1
sbci R19,255
L41:
.dbline 699
; for (i = 0; i < OS_RDY_TBL_SIZE; i++) {
cpi R18,3
ldi R30,0
cpc R19,R30
brlo L38
.dbline 703
; *prdytbl++ = 0x00;
; }
;
; OSPrioCur = 0;
clr R2
sts _OSPrioCur,R2
.dbline 704
; OSPrioHighRdy = 0;
sts _OSPrioHighRdy,R2
.dbline 706
;
; OSTCBHighRdy = (OS_TCB *)0;
clr R3
sts _OSTCBHighRdy+1,R3
sts _OSTCBHighRdy,R2
.dbline 707
; OSTCBCur = (OS_TCB *)0;
sts _OSTCBCur+1,R3
sts _OSTCBCur,R2
.dbline -2
L37:
.dbline 0 ; func end
ret
.dbsym r prdytbl 16 pc
.dbsym r i 18 i
.dbend
.dbfunc s OS_InitTaskIdle _OS_InitTaskIdle fV
.even
_OS_InitTaskIdle:
sbiw R28,3
.dbline -1
.dbline 725
; }
;
;
; /*
; *********************************************************************************************************
; * INITIALIZATION
; * CREATING THE IDLE TASK
; *
; * Description: This function creates the Idle Task.
; *
; * Arguments : none
; *
; * Returns : none
; *********************************************************************************************************
; */
;
; static void OS_InitTaskIdle (void)
; {
.dbline 750
; #if OS_TASK_CREATE_EXT_EN > 0
; #if OS_STK_GROWTH == 1
; (void)OSTaskCreateExt(OS_TaskIdle,
; (void *)0, /* No arguments passed to OS_TaskIdle() */
; &OSTaskIdleStk[OS_TASK_IDLE_STK_SIZE - 1], /* Set Top-Of-Stack */
; OS_IDLE_PRIO, /* Lowest priority level */
; OS_TASK_IDLE_ID,
; &OSTaskIdleStk[0], /* Set Bottom-Of-Stack */
; OS_TASK_IDLE_STK_SIZE,
; (void *)0, /* No TCB extension */
; OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);/* Enable stack checking + clear stack */
; #else
; (void)OSTaskCreateExt(OS_TaskIdle,
; (void *)0, /* No arguments passed to OS_TaskIdle() */
; &OSTaskIdleStk[0], /* Set Top-Of-Stack */
; OS_IDLE_PRIO, /* Lowest priority level */
; OS_TASK_IDLE_ID,
; &OSTaskIdleStk[OS_TASK_IDLE_STK_SIZE - 1], /* Set Bottom-Of-Stack */
; OS_TASK_IDLE_STK_SIZE,
; (void *)0, /* No TCB extension */
; OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);/* Enable stack checking + clear stack */
; #endif
; #else
; #if OS_STK_GROWTH == 1
; (void)OSTaskCreate(OS_TaskIdle,
ldi R24,20
std y+2,R24
ldi R24,<_OSTaskIdleStk+127
ldi R25,>_OSTaskIdleStk+127
std y+1,R25
std y+0,R24
clr R18
clr R19
ldi R16,<PL_OS_TaskIdle
ldi R17,>PL_OS_TaskIdle
xcall _OSTaskCreate
.dbline -2
L42:
adiw R28,3
.dbline 0 ; func end
ret
.dbend
.dbfunc s OS_InitTCBList _OS_InitTCBList fV
; ptcb2 -> R16,R17
; ptcb1 -> R18,R19
; i -> R20
.even
_OS_InitTCBList:
xcall push_gset1
.dbline -1
.dbline 831
; (void *)0,
; &OSTaskIdleStk[OS_TASK_IDLE_STK_SIZE - 1],
; OS_IDLE_PRIO);
; #else
; (void)OSTaskCreate(OS_TaskIdle,
; (void *)0,
; &OSTaskIdleStk[0],
; OS_IDLE_PRIO);
; #endif
; #endif
; }
;
; /*
; *********************************************************************************************************
; * INITIALIZATION
; * CREATING THE STATISTIC TASK
; *
; * Description: This function creates the Statistic Task.
; *
; * Arguments : none
; *
; * Returns : none
; *********************************************************************************************************
; */
;
; #if OS_TASK_STAT_EN > 0
; static void OS_InitTaskStat (void)
; {
; #if OS_TASK_CREATE_EXT_EN > 0
; #if OS_STK_GROWTH == 1
; (void)OSTaskCreateExt(OS_TaskStat,
; (void *)0, /* No args passed to OS_TaskStat()*/
; &OSTaskStatStk[OS_TASK_STAT_STK_SIZE - 1], /* Set Top-Of-Stack */
; OS_STAT_PRIO, /* One higher than the idle task */
; OS_TASK_STAT_ID,
; &OSTaskStatStk[0], /* Set Bottom-Of-Stack */
; OS_TASK_STAT_STK_SIZE,
; (void *)0, /* No TCB extension */
; OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR); /* Enable stack checking + clear */
; #else
; (void)OSTaskCreateExt(OS_TaskStat,
; (void *)0, /* No args passed to OS_TaskStat()*/
; &OSTaskStatStk[0], /* Set Top-Of-Stack */
; OS_STAT_PRIO, /* One higher than the idle task */
; OS_TASK_STAT_ID,
; &OSTaskStatStk[OS_TASK_STAT_STK_SIZE - 1], /* Set Bottom-Of-Stack */
; OS_TASK_STAT_STK_SIZE,
; (void *)0, /* No TCB extension */
; OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR); /* Enable stack checking + clear */
; #endif
; #else
; #if OS_STK_GROWTH == 1
; (void)OSTaskCreate(OS_TaskStat,
; (void *)0, /* No args passed to OS_TaskStat()*/
; &OSTaskStatStk[OS_TASK_STAT_STK_SIZE - 1], /* Set Top-Of-Stack */
; OS_STAT_PRIO); /* One higher than the idle task */
; #else
; (void)OSTaskCreate(OS_TaskStat,
; (void *)0, /* No args passed to OS_TaskStat()*/
; &OSTaskStatStk[0], /* Set Top-Of-Stack */
; OS_STAT_PRIO); /* One higher than the idle task */
; #endif
; #endif
; }
; #endif
;
; /*
; *********************************************************************************************************
; * INITIALIZATION
; * INITIALIZE THE FREE LIST OF TASK CONTROL BLOCKS
; *
; * Description: This function is called by OSInit() to initialize the free list of OS_TCBs.
; *
; * Arguments : none
; *
; * Returns : none
; *********************************************************************************************************
; */
;
; static void OS_InitTCBList (void)
; {
.dbline 837
; INT8U i;
; OS_TCB *ptcb1;
; OS_TCB *ptcb2;
;
;
; OSTCBList = (OS_TCB *)0; /* TCB Initialization */
clr R2
clr R3
sts _OSTCBList+1,R3
sts _OSTCBList,R2
.dbline 838
clr R20
xjmp L48
L45:
.dbline 838
.dbline 839
ldi R24,2
mul R24,R20
movw R30,R0
ldi R24,<_OSTCBPrioTbl
ldi R25,>_OSTCBPrioTbl
add R30,R24
adc R31,R25
clr R2
clr R3
std z+1,R3
std z+0,R2
.dbline 840
L46:
.dbline 838
inc R20
L48:
.dbline 838
; for (i = 0; i < (OS_LOWEST_PRIO + 1); i++) { /* Clear the priority table */
cpi R20,21
brlo L45
.dbline 841
; OSTCBPrioTbl[i] = (OS_TCB *)0;
; }
; ptcb1 = &OSTCBTbl[0];
ldi R18,<_OSTCBTbl
ldi R19,>_OSTCBTbl
.dbline 842
; ptcb2 = &OSTCBTbl[1];
ldi R16,<_OSTCBTbl+18
ldi R17,>_OSTCBTbl+18
.dbline 843
clr R20
xjmp L53
L50:
.dbline 843
.dbline 844
movw R30,R18
std z+3,R17
std z+2,R16
.dbline 845
subi R18,238 ; offset = 18
sbci R19,255
.dbline 846
subi R16,238 ; offset = 18
sbci R17,255
.dbline 847
L51:
.dbline 843
inc R20
L53:
.dbline 843
; for (i = 0; i < (OS_MAX_TASKS + OS_N_SYS_TASKS - 1); i++) { /* Init. list of free TCBs */
cpi R20,5
brlo L50
.dbline 848
; ptcb1->OSTCBNext = ptcb2;
; ptcb1++;
; ptcb2++;
; }
; ptcb1->OSTCBNext = (OS_TCB *)0; /* Last OS_TCB */
clr R2
clr R3
movw R30,R18
std z+3,R3
std z+2,R2
.dbline 849
; OSTCBFreeList = &OSTCBTbl[0];
ldi R24,<_OSTCBTbl
ldi R25,>_OSTCBTbl
sts _OSTCBFreeList+1,R25
sts _OSTCBFreeList,R24
.dbline -2
L44:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r ptcb2 16 pS[os_tcb]
.dbsym r ptcb1 18 pS[os_tcb]
.dbsym r i 20 c
.dbend
.dbfunc e OS_Sched _OS_Sched fV
; y -> R10
.even
_OS_Sched::
xcall push_gset3
.dbline -1
.dbline 870
; }
; /*$PAGE*/
; /*
; *********************************************************************************************************
; * SCHEDULER
; *
; * Description: This function is called by other uC/OS-II services to determine whether a new, high
; * priority task has been made ready to run. This function is invoked by TASK level code
; * and is not used to reschedule tasks from ISRs (see OSIntExit() for ISR rescheduling).
; *
; * Arguments : none
; *
; * Returns : none
; *
; * Notes : 1) This function is INTERNAL to uC/OS-II and your application should not call it.
; * 2) Rescheduling is prevented when the scheduler is locked (see OS_SchedLock())
; *********************************************************************************************************
; */
;
; void OS_Sched (void)
; {
.dbline 877
; #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
; OS_CPU_SR cpu_sr;
; #endif
; INT8U y;
;
;
; OS_ENTER_CRITICAL();
st -y,r16
in r16,0x3F
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -