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

📄 os_core.s

📁 把UCOSII移植到AVR MEGA8上的程序 应用程序为驱动1602显示器,虽说有些简单,但可测试UCOS的运行
💻 S
📖 第 1 页 / 共 5 页
字号:
	clr R3
	movw R30,R14
	std z+3,R3
	std z+2,R2
	.dbline 124
;     OSTCBFreeList    = &OSTCBTbl[0];
	ldi R24,<_OSTCBTbl
	ldi R25,>_OSTCBTbl
	sts _OSTCBFreeList+1,R25
	sts _OSTCBFreeList,R24
	.dbline 132
; 
; #if (OS_EVENT_EN > 0) && (OS_MAX_EVENTS > 0)
;     #if OS_MAX_EVENTS == 1                                       
;     OSEventFreeList              = &OSEventTbl[0];               /* Only have ONE event control block        */
;     OSEventFreeList->OSEventType = OS_EVENT_TYPE_UNUSED;
;     OSEventFreeList->OSEventPtr  = (OS_EVENT *)0;
;     #else
;     pevent1 = &OSEventTbl[0];
	ldi R24,<_OSEventTbl
	ldi R25,>_OSEventTbl
	movw R10,R24
	.dbline 133
;     pevent2 = &OSEventTbl[1];
	ldi R24,<_OSEventTbl+9
	ldi R25,>_OSEventTbl+9
	movw R12,R24
	.dbline 134
	clr R4
	clr R5
	rjmp L21
L18:
	.dbline 134
	.dbline 135
	clr R2
	movw R30,R10
	std z+0,R2
	.dbline 136
	std z+5,R13
	std z+4,R12
	.dbline 137
	movw R24,R10
	adiw R24,9
	movw R10,R24
	.dbline 138
	movw R24,R12
	adiw R24,9
	movw R12,R24
	.dbline 139
L19:
	.dbline 134
	movw R24,R4
	adiw R24,1
	movw R4,R24
L21:
	.dbline 134
;     for (i = 0; i < (OS_MAX_EVENTS - 1); i++) {                  /* Init. list of free EVENT control blocks  */
	movw R24,R4
	cpi R24,3
	ldi R30,0
	cpc R25,R30
	brlo L18
	.dbline 140
;         pevent1->OSEventType = OS_EVENT_TYPE_UNUSED;
;         pevent1->OSEventPtr  = pevent2;
;         pevent1++;
;         pevent2++;
;     }
;     pevent1->OSEventType = OS_EVENT_TYPE_UNUSED;
	clr R2
	movw R30,R10
	std z+0,R2
	.dbline 141
;     pevent1->OSEventPtr  = (OS_EVENT *)0;
	clr R3
	std z+5,R3
	std z+4,R2
	.dbline 142
;     OSEventFreeList      = &OSEventTbl[0];
	ldi R24,<_OSEventTbl
	ldi R25,>_OSEventTbl
	sts _OSEventFreeList+1,R25
	sts _OSEventFreeList,R24
	.dbline 183
;     #endif
; #endif
; 
; #if (OS_VERSION >= 251) && (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
;     OS_FlagInit();                                               /* Initialize the event flag structures     */
; #endif
; 
; #if (OS_Q_EN > 0) && (OS_MAX_QS > 0)
;     OS_QInit();                                                  /* Initialize the message queue structures  */
; #endif
; 
; #if (OS_MEM_EN > 0) && (OS_MAX_MEM_PART > 0)
;     OS_MemInit();                                                /* Initialize the memory manager            */
; #endif
; 
;     /* ------------------------------------- CREATION OF 'IDLE' TASK --------------------------------------- */
; #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
	push R4
	push R5
	rcall _OSTaskCreate
	pop R5
	pop R4
	.dbline 235
;                        (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
; 
;     /* ------------------------------- CREATION OF 'STATISTIC' TASK ---------------------------------- */
; #if OS_TASK_STAT_EN > 0
;     #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
; 
; #if OS_VERSION >= 204
;     OSInitHookEnd();                                                       /* Call port specific init. code  */
	push R4
	push R5
	rcall _OSInitHookEnd
	pop R5
	pop R4
	.dbline -2
L3:
	adiw R28,7
	rcall pop_gset5
	.dbline 0 ; func end
	ret
	.dbsym l prdytbl 5 pc
	.dbsym r pevent2 12 pS[.1]
	.dbsym l ptcb2 3 pS[os_tcb]
	.dbsym r ptcb1 14 pS[os_tcb]
	.dbsym r pevent1 10 pS[.1]
	.dbsym r i 4 i
	.dbend
	.dbfunc e OSIntEnter _OSIntEnter fV
;         cpu_sr -> R20
	.even
_OSIntEnter::
	rcall push_gset1
	.dbline -1
	.dbline 263
; #endif
; }
; /*$PAGE*/
; /*
; *********************************************************************************************************
; *                                              ENTER ISR
; *
; * Description: This function is used to notify uC/OS-II that you are about to service an interrupt
; *              service routine (ISR).  This allows uC/OS-II to keep track of interrupt nesting and thus
; *              only perform rescheduling at the last nested ISR.
; *
; * Arguments  : none
; *
; * Returns    : none
; *
; * Notes      : 1) Your ISR can directly increment OSIntNesting without calling this function because
; *                 OSIntNesting has been declared 'global'.  You MUST, however, be sure that the increment
; *                 is performed 'indivisibly' by your processor to ensure proper access to this critical
; *                 resource.
; *              2) You MUST still call OSIntExit() even though you increment OSIntNesting directly.
; *              3) 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.
; *********************************************************************************************************
; */
; 
; void  OSIntEnter (void)
; {
	.dbline 269
; #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
;     OS_CPU_SR  cpu_sr;
; #endif    
;     
;     
;     OS_ENTER_CRITICAL();
	rcall _OS_CPU_SR_Save
	mov R20,R16
	.dbline 270
;     if (OSIntNesting < 255) {
	lds R24,_OSIntNesting
	cpi R24,255
	brsh L24
	.dbline 270
	.dbline 271
;         OSIntNesting++;                          /* Increment ISR nesting level                        */
	subi R24,255    ; addi 1
	sts _OSIntNesting,R24
	.dbline 272
;     }
L24:
	.dbline 273
;     OS_EXIT_CRITICAL();
	mov R16,R20
	rcall _OS_CPU_SR_Restore
	.dbline -2
L23:
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r cpu_sr 20 c
	.dbend
	.dbfunc e OSIntExit _OSIntExit fV
;         cpu_sr -> R10
	.even
_OSIntExit::
	rcall push_gset3
	.dbline -1
	.dbline 296
; }
; /*$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 OSSchedLock())
; *********************************************************************************************************
; */
; 
; void  OSIntExit (void)
; {
	.dbline 302
; #if OS_CRITICAL_METHOD == 3                            /* Allocate storage for CPU status register     */
;     OS_CPU_SR  cpu_sr;
; #endif
;     
;     
;     OS_ENTER_CRITICAL();
	rcall _OS_CPU_SR_Save
	mov R10,R16
	.dbline 303
;     if (OSIntNesting > 0) {                            /* Prevent OSIntNesting from wrapping           */
	clr R2
	lds R3,_OSIntNesting
	cp R2,R3
	brsh L27
	.dbline 303
	.dbline 304
;         OSIntNesting--;
	mov R24,R3
	subi R24,1
	sts _OSIntNesting,R24
	.dbline 305
;     }
L27:
	.dbline 306
;     if ((OSIntNesting == 0) && (OSLockNesting == 0)) { /* Reschedule only if all ISRs complete ...     */
	lds R2,_OSIntNesting
	tst R2
	breq X0
	rjmp L29
X0:
	lds R2,_OSLockNesting
	tst R2
	breq X1
	rjmp L29
X1:
	.dbline 306
	.dbline 307
;         OSIntExitY    = OSUnMapTbl[OSRdyGrp];          /* ... and not locked.                          */
	ldi R24,<_OSUnMapTbl
	ldi R25,>_OSUnMapTbl
	lds R30,_OSRdyGrp
	clr R31
	add R30,R24
	adc R31,R25
	lpm R30,Z
	sts _OSIntExitY,R30
	.dbline 308
;         OSPrioHighRdy = (INT8U)((OSIntExitY << 3) + OSUnMapTbl[OSRdyTbl[OSIntExitY]]);
	ldi R24,<_OSRdyTbl
	ldi R25,>_OSRdyTbl
	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
	lpm R2,Z
	clr R3
	lds R4,_OSIntExitY
	clr R5
	lsl R4
	rol R5
	lsl R4
	rol R5
	lsl R4
	rol R5
	add R4,R2
	adc R5,R3
	sts _OSPrioHighRdy,R4
	.dbline 309
;         if (OSPrioHighRdy != OSPrioCur) {              /* No Ctx Sw if current task is highest rdy     */
	lds R2,_OSPrioCur
	cp R4,R2
	breq L31
	.dbline 309
	.dbline 310
;             OSTCBHighRdy  = OSTCBPrioTbl[OSPrioHighRdy];
	mov R2,R4
	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 311
;             OSCtxSwCtr++;                              /* Keep track of the number of context 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 312
;             OSIntCtxSw();                              /* Perform interrupt level context switch       */
	rcall _OSIntCtxSw
	.dbline 313
;         }
L31:
	.dbline 314
;     }
L29:
	.dbline 315
;     OS_EXIT_CRITICAL();
	mov R16,R10
	rcall _OS_CPU_SR_Restore
	.dbline -2
L26:
	rcall pop_gset3
	.dbline 0 ; func end
	ret
	.dbsym r cpu_sr 10 c
	.dbend
	.dbfunc e OSStart _OSStart fV
;              x -> R22
;              y -> R20
	.even
_OSStart::
	rcall push_gset2
	.dbline -1
	.dbline 413
	.dbline 418
	lds R2,_OSRunning
	tst R2
	breq X2
	rjmp L34
X2:
	.dbline 418
	.dbline 419
	ldi R24,<_OSUnMapTbl
	ldi R25,>_OSUnMapTbl
	lds R30,_OSRdyGrp
	clr R31
	add R30,R24

⌨️ 快捷键说明

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