⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 os_core.s

📁 使用mega8和iccavr编译器的一段ucos操作系统程序
💻 S
📖 第 1 页 / 共 3 页
字号:
	.module OS_CORE.C
	.area lit(rom, con, rel)
_OSMapTbl::
	.byte 1,2
	.byte 4,8
	.byte 16,32
	.byte 64,128
	.dbfile G:\IccPro\ucos_m8_icc\source\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 G:\IccPro\ucos_m8_icc\source\OS_CORE.C
	.dbfunc e OSInit _OSInit fV
;              i -> R10,R11
	.even
_OSInit::
	rcall push_gset3x
	sbiw R28,3
	.dbline -1
	.dbline 77
; 
; #ifndef  OS_MASTER_FILE
; #define  OS_GLOBALS
; #include "includes.h"
; #endif
; 
; /*
; *********************************************************************************************************
; *                                         LOCAL GLOBAL VARIABLES
; *********************************************************************************************************
; */
;                                        
; static  INT8U        OSIntExitY;               /* Variable used by 'OSIntExit' to prevent using locals */
; static  OS_STK       OSTaskIdleStk[OS_TASK_IDLE_STK_SIZE];       /* Idle       task stack              */
; 
; #if     OS_TASK_STAT_EN
; static  OS_STK       OSTaskStatStk[OS_TASK_STAT_STK_SIZE];      /* Statistics task stack               */
; #endif
; 
; static  OS_TCB       OSTCBTbl[OS_MAX_TASKS + OS_N_SYS_TASKS];   /* Table of TCBs                       */
; 
; /*$PAGE*/
; /*
; *********************************************************************************************************
; *                              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 81
;     INT16U i;
; 
; 
;     OSTime        = 0L;                                    /* Clear the 32-bit system clock            */
	ldi R24,0
	ldi R25,0
	ldi R26,0
	ldi R27,0
	sts _OSTime+1,R25
	sts _OSTime,R24
	sts _OSTime+2+1,R27
	sts _OSTime+2,R26
	.dbline 82
;     OSIntNesting  = 0;                                     /* Clear the interrupt nesting counter      */
	clr R2
	sts _OSIntNesting,R2
	.dbline 83
;     OSLockNesting = 0;                                     /* Clear the scheduling lock counter        */
	sts _OSLockNesting,R2
	.dbline 85
; #if OS_TASK_CREATE_EN  || OS_TASK_CREATE_EXT_EN || OS_TASK_DEL_EN
;     OSTaskCtr     = 0;                                     /* Clear the number of tasks                */
	sts _OSTaskCtr,R2
	.dbline 87
; #endif
;     OSRunning     = FALSE;                                 /* Indicate that multitasking not started   */
	sts _OSRunning,R2
	.dbline 88
;     OSIdleCtr     = 0L;                                    /* Clear the 32-bit idle counter            */
	ldi R24,0
	ldi R25,0
	ldi R26,0
	ldi R27,0
	sts _OSIdleCtr+1,R25
	sts _OSIdleCtr,R24
	sts _OSIdleCtr+2+1,R27
	sts _OSIdleCtr+2,R26
	.dbline 90
; 
;     OSCtxSwCtr    = 0;                                     /* Clear the context switch counter         */
	ldi R24,0
	ldi R25,0
	ldi R26,0
	ldi R27,0
	sts _OSCtxSwCtr+1,R25
	sts _OSCtxSwCtr,R24
	sts _OSCtxSwCtr+2+1,R27
	sts _OSCtxSwCtr+2,R26
	.dbline 91
;     OSRdyGrp      = 0;                                     /* Clear the ready list                     */
	sts _OSRdyGrp,R2
	.dbline 92
	clr R10
	clr R11
	rjmp L6
L3:
	.dbline 92
	.dbline 93
	ldi R24,<_OSRdyTbl
	ldi R25,>_OSRdyTbl
	movw R30,R10
	add R30,R24
	adc R31,R25
	clr R2
	std z+0,R2
	.dbline 94
L4:
	.dbline 92
	movw R24,R10
	adiw R24,1
	movw R10,R24
L6:
	.dbline 92
;     for (i = 0; i < OS_RDY_TBL_SIZE; i++) {
	movw R24,R10
	cpi R24,2
	ldi R30,0
	cpc R25,R30
	brlo L3
	.dbline 96
;         OSRdyTbl[i] = 0;
;     }
;                 
;     OSPrioCur     = 0;
	clr R2
	sts _OSPrioCur,R2
	.dbline 97
;     OSPrioHighRdy = 0;                                           
	sts _OSPrioHighRdy,R2
	.dbline 98
;     OSTCBHighRdy  = (OS_TCB *)0;                                 /* TCB Initialization                 */
	clr R3
	sts _OSTCBHighRdy+1,R3
	sts _OSTCBHighRdy,R2
	.dbline 99
;     OSTCBCur      = (OS_TCB *)0;
	sts _OSTCBCur+1,R3
	sts _OSTCBCur,R2
	.dbline 100
;     OSTCBList     = (OS_TCB *)0;
	sts _OSTCBList+1,R3
	sts _OSTCBList,R2
	.dbline 101
	clr R10
	clr R11
	rjmp L10
L7:
	.dbline 101
	.dbline 102
	ldi R16,2
	ldi R17,0
	movw R18,R10
	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 103
L8:
	.dbline 101
	movw R24,R10
	adiw R24,1
	movw R10,R24
L10:
	.dbline 101
;     for (i = 0; i < (OS_LOWEST_PRIO + 1); i++) {                 /* Clear the priority table           */
	movw R24,R10
	cpi R24,16
	ldi R30,0
	cpc R25,R30
	brlo L7
	.dbline 104
	clr R10
	clr R11
	rjmp L14
L11:
	.dbline 104
	.dbline 105
	movw R18,R10
	subi R18,255  ; offset = 1
	sbci R19,255
	ldi R16,14
	ldi R17,0
	rcall empy16s
	movw R2,R16
	ldi R24,<_OSTCBTbl
	ldi R25,>_OSTCBTbl
	add R2,R24
	adc R3,R25
	ldi R16,14
	ldi R17,0
	movw R18,R10
	rcall empy16s
	movw R30,R16
	ldi R24,<_OSTCBTbl+2
	ldi R25,>_OSTCBTbl+2
	add R30,R24
	adc R31,R25
	std z+1,R3
	std z+0,R2
	.dbline 106
L12:
	.dbline 104
	movw R24,R10
	adiw R24,1
	movw R10,R24
L14:
	.dbline 104
;         OSTCBPrioTbl[i] = (OS_TCB *)0;
;     }
;     for (i = 0; i < (OS_MAX_TASKS + OS_N_SYS_TASKS - 1); i++) {  /* Init. list of free TCBs            */
	movw R24,R10
	cpi R24,5
	ldi R30,0
	cpc R25,R30
	brlo L11
	.dbline 107
;         OSTCBTbl[i].OSTCBNext = &OSTCBTbl[i + 1];
;     }
;     OSTCBTbl[OS_MAX_TASKS + OS_N_SYS_TASKS - 1].OSTCBNext = (OS_TCB *)0;    /* Last OS_TCB             */
	clr R2
	clr R3
	sts _OSTCBTbl+70+2+1,R3
	sts _OSTCBTbl+70+2,R2
	.dbline 108
;     OSTCBFreeList                                         = &OSTCBTbl[0];
	ldi R24,<_OSTCBTbl
	ldi R25,>_OSTCBTbl
	sts _OSTCBFreeList+1,R25
	sts _OSTCBFreeList,R24
	.dbline 111
	clr R10
	clr R11
	rjmp L21
L18:
	.dbline 111
	.dbline 112
	movw R18,R10
	subi R18,255  ; offset = 1
	sbci R19,255
	ldi R16,8
	ldi R17,0
	rcall empy16s
	movw R2,R16
	ldi R24,<_OSEventTbl
	ldi R25,>_OSEventTbl
	add R2,R24
	adc R3,R25
	ldi R16,8
	ldi R17,0
	movw R18,R10
	rcall empy16s
	movw R30,R16
	ldi R24,<_OSEventTbl
	ldi R25,>_OSEventTbl
	add R30,R24
	adc R31,R25
	std z+1,R3
	std z+0,R2
	.dbline 113
L19:
	.dbline 111
	movw R24,R10
	adiw R24,1
	movw R10,R24
L21:
	.dbline 111
; 
; #if OS_MAX_EVENTS >= 2
;     for (i = 0; i < (OS_MAX_EVENTS - 1); i++) {            /* Init. list of free EVENT control blocks  */
	movw R24,R10
	cpi R24,1
	ldi R30,0
	cpc R25,R30
	brlo L18
	.dbline 114
;         OSEventTbl[i].OSEventPtr = (OS_EVENT *)&OSEventTbl[i + 1];
;     }
;     OSEventTbl[OS_MAX_EVENTS - 1].OSEventPtr = (OS_EVENT *)0;
	clr R2
	clr R3
	sts _OSEventTbl+8+1,R3
	sts _OSEventTbl+8,R2
	.dbline 115
;     OSEventFreeList                          = &OSEventTbl[0];    
	ldi R24,<_OSEventTbl
	ldi R25,>_OSEventTbl
	sts _OSEventFreeList+1,R25
	sts _OSEventFreeList,R24
	.dbline 119
; #endif
; 
; #if OS_STK_GROWTH == 1
;     OSTaskCreate(OSTaskIdle, (void *)0, &OSTaskIdleStk[OS_TASK_IDLE_STK_SIZE - 1], OS_IDLE_PRIO);
	ldi R24,15
	std y+2,R24
	ldi R24,<_OSTaskIdleStk+99
	ldi R25,>_OSTaskIdleStk+99
	std y+1,R25
	std y+0,R24
	clr R18
	clr R19
	ldi R16,<PL_OSTaskIdle
	ldi R17,>PL_OSTaskIdle
	rcall _OSTaskCreate
	.dbline -2
L2:
	adiw R28,3
	rcall pop_gset3x
	.dbline 0 ; func end
	ret
	.dbsym r i 10 i
	.dbend
	.dbfunc e OSIntExit _OSIntExit fV
	.even
_OSIntExit::
	.dbline -1
	.dbline 146

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -