📄 os_core.s
字号:
.module OS_CORE.c
.area lit(rom, con, rel)
_OSMapTbl::
.byte 1,2
.byte 4,8
.byte 16,32
.byte 64,128
.dbfile F:\AVRPRA~1\ucosii-port2-mega8\OS_CORE.c
.dbsym e OSMapTbl _OSMapTbl A[8:8]kc
_OSUnMapTbl::
.byte 0,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 3,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 4,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 3,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 5,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 3,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 4,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 3,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 6,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 3,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 4,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 3,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 5,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 3,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 4,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 3,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 7,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 3,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 4,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 3,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 5,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 3,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 4,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 3,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 6,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 3,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 4,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 3,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 5,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 3,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 4,0
.byte 1,0
.byte 2,0
.byte 1,0
.byte 3,0
.byte 1,0
.byte 2,0
.byte 1,0
.dbsym e OSUnMapTbl _OSUnMapTbl A[256:256]kc
.area text(rom, con, rel)
.dbfile F:\AVRPRA~1\ucosii-port2-mega8\OS_CORE.c
.dbfunc e OSInit _OSInit fV
.dbstruct 0 9 .1
.dbfield 0 OSEventType c
.dbfield 1 OSEventGrp c
.dbfield 2 OSEventCnt i
.dbfield 4 OSEventPtr pV
.dbfield 6 OSEventTbl A[3:3]c
.dbend
.dbstruct 0 16 os_tcb
.dbfield 0 OSTCBStkPtr pc
.dbfield 2 OSTCBNext pS[os_tcb]
.dbfield 4 OSTCBPrev pS[os_tcb]
.dbfield 6 OSTCBEventPtr pS[.1]
.dbfield 8 OSTCBDly i
.dbfield 10 OSTCBStat c
.dbfield 11 OSTCBPrio c
.dbfield 12 OSTCBX c
.dbfield 13 OSTCBY c
.dbfield 14 OSTCBBitX c
.dbfield 15 OSTCBBitY c
.dbend
; prdytbl -> y+5
; pevent2 -> R12,R13
; ptcb2 -> y+3
; ptcb1 -> R14,R15
; pevent1 -> R10,R11
; i -> R4,R5
.even
_OSInit::
rcall push_gset5
sbiw R28,7
.dbline -1
.dbline 73
; /*
; *********************************************************************************************************
; * uC/OS-II
; * The Real-Time Kernel
; * CORE FUNCTIONS
; *
; * (c) Copyright 1992-2001, Jean J. Labrosse, Weston, FL
; * All Rights Reserved
; *
; * File : OS_CORE.C
; * By : Jean J. Labrosse
; *********************************************************************************************************
; */
;
; #ifndef OS_MASTER_FILE
; #define OS_GLOBALS
; #include "includes.h"
; #endif
;
; /*
; *********************************************************************************************************
; * MAPPING TABLE TO MAP BIT POSITION TO BIT MASK
; *
; * Note: Index into table is desired bit position, 0..7
; * Indexed value corresponds to bit mask
; *********************************************************************************************************
; */
;
; INT8U const OSMapTbl[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
;
; /*
; *********************************************************************************************************
; * PRIORITY RESOLUTION TABLE
; *
; * Note: Index into table is bit pattern to resolve highest priority
; * Indexed value corresponds to highest priority bit position (i.e. 0..7)
; *********************************************************************************************************
; */
;
; INT8U const OSUnMapTbl[] = {
; 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
; 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
; 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
; 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
; 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
; 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
; 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
; 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
; 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
; 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
; 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
; 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
; 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
; 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
; 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
; 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
; };
; /*$PAGE*/
; /*
; *********************************************************************************************************
; * INITIALIZATION
; *
; * Description: This function is used to initialize the internals of uC/OS-II and MUST be called prior to
; * creating any uC/OS-II object and, prior to calling OSStart().
; *
; * Arguments : none
; *
; * Returns : none
; *********************************************************************************************************
; */
;
; void OSInit (void)
; {
.dbline 85
; INT16U i;
; INT8U *prdytbl;
; OS_TCB *ptcb1;
; OS_TCB *ptcb2;
; #if (OS_EVENT_EN > 0) && (OS_MAX_EVENTS > 1)
; OS_EVENT *pevent1;
; OS_EVENT *pevent2;
; #endif
;
;
; #if OS_VERSION >= 204
; OSInitHookBegin(); /* Call port specific initialization code */
rcall _OSInitHookBegin
.dbline 89
; #endif
;
; #if OS_TIME_GET_SET_EN > 0
; OSTime = 0L; /* Clear the 32-bit system clock */
ldi R20,0
ldi R21,0
ldi R22,0
ldi R23,0
sts _OSTime+1,R21
sts _OSTime,R20
sts _OSTime+2+1,R23
sts _OSTime+2,R22
.dbline 91
; #endif
; OSIntNesting = 0; /* Clear the interrupt nesting counter */
clr R2
sts _OSIntNesting,R2
.dbline 92
; OSLockNesting = 0; /* Clear the scheduling lock counter */
sts _OSLockNesting,R2
.dbline 93
; OSTaskCtr = 0; /* Clear the number of tasks */
sts _OSTaskCtr,R2
.dbline 94
; OSRunning = FALSE; /* Indicate that multitasking not started */
sts _OSRunning,R2
.dbline 95
; 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 101
; #if (OS_TASK_STAT_EN > 0) && (OS_TASK_CREATE_EXT_EN > 0)
; OSIdleCtrRun = 0L;
; OSIdleCtrMax = 0L;
; OSStatRdy = FALSE; /* Statistic task is not ready */
; #endif
; 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 102
; OSRdyGrp = 0x00; /* Clear the ready list */
sts _OSRdyGrp,R2
.dbline 103
; prdytbl = &OSRdyTbl[0];
ldi R24,<_OSRdyTbl
ldi R25,>_OSRdyTbl
std y+6,R25
std y+5,R24
.dbline 104
clr R4
clr R5
rjmp L7
L4:
.dbline 104
.dbline 105
clr R2
ldd R30,y+5
ldd R31,y+6
st Z+,R2
std y+6,R31
std y+5,R30
.dbline 106
L5:
.dbline 104
movw R24,R4
adiw R24,1
movw R4,R24
L7:
.dbline 104
; for (i = 0; i < OS_RDY_TBL_SIZE; i++) {
movw R24,R4
cpi R24,3
ldi R30,0
cpc R25,R30
brlo L4
.dbline 108
; *prdytbl++ = 0x00;
; }
;
; OSPrioCur = 0;
clr R2
sts _OSPrioCur,R2
.dbline 109
; OSPrioHighRdy = 0;
sts _OSPrioHighRdy,R2
.dbline 110
; OSTCBHighRdy = (OS_TCB *)0; /* TCB Initialization */
clr R3
sts _OSTCBHighRdy+1,R3
sts _OSTCBHighRdy,R2
.dbline 111
; OSTCBCur = (OS_TCB *)0;
sts _OSTCBCur+1,R3
sts _OSTCBCur,R2
.dbline 112
; OSTCBList = (OS_TCB *)0;
sts _OSTCBList+1,R3
sts _OSTCBList,R2
.dbline 113
clr R4
clr R5
rjmp L11
L8:
.dbline 113
.dbline 114
ldi R16,2
ldi R17,0
movw R18,R4
rcall empy16s
movw R30,R16
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 115
L9:
.dbline 113
movw R24,R4
adiw R24,1
movw R4,R24
L11:
.dbline 113
; for (i = 0; i < (OS_LOWEST_PRIO + 1); i++) { /* Clear the priority table */
movw R24,R4
cpi R24,21
ldi R30,0
cpc R25,R30
brlo L8
.dbline 116
; OSTCBPrioTbl[i] = (OS_TCB *)0;
; }
; ptcb1 = &OSTCBTbl[0];
ldi R24,<_OSTCBTbl
ldi R25,>_OSTCBTbl
movw R14,R24
.dbline 117
; ptcb2 = &OSTCBTbl[1];
ldi R24,<_OSTCBTbl+16
ldi R25,>_OSTCBTbl+16
std y+4,R25
std y+3,R24
.dbline 118
clr R4
clr R5
rjmp L16
L13:
.dbline 118
.dbline 119
movw R30,R14
ldd R0,y+3
ldd R1,y+4
std z+3,R1
std z+2,R0
.dbline 120
movw R24,R14
adiw R24,16
movw R14,R24
.dbline 121
movw R24,R0
adiw R24,16
std y+4,R25
std y+3,R24
.dbline 122
L14:
.dbline 118
movw R24,R4
adiw R24,1
movw R4,R24
L16:
.dbline 118
; for (i = 0; i < (OS_MAX_TASKS + OS_N_SYS_TASKS - 1); i++) { /* Init. list of free TCBs */
movw R24,R4
cpi R24,5
ldi R30,0
cpc R25,R30
brlo L13
.dbline 123
; ptcb1->OSTCBNext = ptcb2;
; ptcb1++;
; ptcb2++;
; }
; ptcb1->OSTCBNext = (OS_TCB *)0; /* Last OS_TCB */
clr R2
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -