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

📄 os_core.s

📁 把UCOSII移植到AVR MEGA8上的程序 应用程序为驱动1602显示器,虽说有些简单,但可测试UCOS的运行
💻 S
📖 第 1 页 / 共 5 页
字号:
	adc R31,R25
	lpm R20,Z
	.dbline 420
	ldi R24,<_OSRdyTbl
	ldi R25,>_OSRdyTbl
	mov R30,R20
	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 R22,Z
	.dbline 421
	mov R2,R22
	clr R3
	mov R4,R20
	clr R5
	lsl R4
	rol R5
	lsl R4
	rol R5
	lsl R4
	rol R5
	add R4,R2
	adc R5,R3
	sts _OSPrioHighRdy,R4
	.dbline 422
	mov R2,R4
	sts _OSPrioCur,R2
	.dbline 423
	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 424
	sts _OSTCBCur+1,R3
	sts _OSTCBCur,R2
	.dbline 425
	rcall _OSStartHighRdy
	.dbline 426
L34:
	.dbline -2
L33:
	rcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r x 22 c
	.dbsym r y 20 c
	.dbend
	.dbfunc e OSTimeTick _OSTimeTick fV
;         cpu_sr -> R10
;           ptcb -> R12,R13
	.even
_OSTimeTick::
	rcall push_gset4
	.dbline -1
	.dbline 484
; }
; /*$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)
; {
; #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
;     OS_CPU_SR  cpu_sr;
; #endif    
;     
;     
;     if (OSRunning == TRUE) {                     /* Make sure multitasking is running                  */
;         OS_ENTER_CRITICAL();
;         if (OSLockNesting < 255) {               /* Prevent OSLockNesting from wrapping back to 0      */
;             OSLockNesting++;                     /* Increment lock nesting level                       */
;         }
;         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)
; {
; #if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
;     OS_CPU_SR  cpu_sr;
; #endif    
;     
;     
;     if (OSRunning == TRUE) {                                   /* Make sure multitasking is running    */
;         OS_ENTER_CRITICAL();
;         if (OSLockNesting > 0) {                               /* Do not decrement if already 0        */
;             OSLockNesting--;                                   /* Decrement lock nesting level         */
;             if ((OSLockNesting == 0) && (OSIntNesting == 0)) { /* See if sched. enabled and not an ISR */
;                 OS_EXIT_CRITICAL();
;                 OS_Sched();                                    /* See if a HPT is ready                */
;             } else {
;                 OS_EXIT_CRITICAL();
;             }
;         } else {
;             OS_EXIT_CRITICAL();
;         }
;     }
; }
; #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.
; *********************************************************************************************************
; */
; 
; void  OSStart (void)
; {
;     INT8U y;
;     INT8U x;
; 
; 
;     if (OSRunning == FALSE) {
;         y             = OSUnMapTbl[OSRdyGrp];        /* Find highest priority's task priority number   */
;         x             = OSUnMapTbl[OSRdyTbl[y]];
;         OSPrioHighRdy = (INT8U)((y << 3) + x);
;         OSPrioCur     = OSPrioHighRdy;
;         OSTCBHighRdy  = OSTCBPrioTbl[OSPrioHighRdy]; /* Point to highest priority task ready to run    */
;         OSTCBCur      = OSTCBHighRdy;
;         OSStartHighRdy();                            /* Execute target specific code to start task     */
;     }
; }
; /*$PAGE*/
; /*
; *********************************************************************************************************
; *                                        STATISTICS INITIALIZATION
; *
; * Description: This function is called by your application to establish CPU usage by first determining
; *              how high a 32-bit counter would count to in 1 second if no other tasks were to execute
; *              during that time.  CPU usage is then determined by a low priority task which keeps track
; *              of this 32-bit counter every second but this time, with other tasks running.  CPU usage is
; *              determined by:
; *
; *                                             OSIdleCtr
; *                 CPU Usage (%) = 100 * (1 - ------------)
; *                                            OSIdleCtrMax
; *
; * Arguments  : none
; *
; * Returns    : none
; *********************************************************************************************************
; */
; 
; #if OS_TASK_STAT_EN > 0
; void  OSStatInit (void)
; {
; #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
;     OS_CPU_SR  cpu_sr;
; #endif    
;     
;     
;     OSTimeDly(2);                                /* Synchronize with clock tick                        */
;     OS_ENTER_CRITICAL();
;     OSIdleCtr    = 0L;                           /* Clear idle counter                                 */
;     OS_EXIT_CRITICAL();
;     OSTimeDly(OS_TICKS_PER_SEC);                 /* Determine MAX. idle counter value for 1 second     */
;     OS_ENTER_CRITICAL();
;     OSIdleCtrMax = OSIdleCtr;                    /* Store maximum idle counter count in 1 second       */
;     OSStatRdy    = TRUE;
;     OS_EXIT_CRITICAL();
; }
; #endif
; /*$PAGE*/
; /*
; *********************************************************************************************************
; *                                         PROCESS SYSTEM TICK
; *
; * Description: This function is used to signal to uC/OS-II the occurrence of a 'system tick' (also known
; *              as a 'clock tick').  This function should be called by the ticker ISR but, can also be
; *              called by a high priority task.
; *
; * Arguments  : none
; *
; * Returns    : none
; *********************************************************************************************************
; */
; 
; void  OSTimeTick (void)
; {
	.dbline 491
; #if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
;     OS_CPU_SR  cpu_sr;
; #endif    
;     OS_TCB    *ptcb;
; 
; 
;     OSTimeTickHook();                                      /* Call user definable hook                 */
	rcall _OSTimeTickHook
	.dbline 493
; #if OS_TIME_GET_SET_EN > 0   
;     OS_ENTER_CRITICAL();                                   /* Update the 32-bit tick counter           */
	rcall _OS_CPU_SR_Save
	mov R10,R16
	.dbline 494
;     OSTime++;
	ldi R20,1
	ldi R21,0
	ldi R22,0
	ldi R23,0
	lds R4,_OSTime+2
	lds R5,_OSTime+2+1
	lds R2,_OSTime
	lds R3,_OSTime+1
	add R2,R20
	adc R3,R21
	adc R4,R22
	adc R5,R23
	sts _OSTime+1,R3
	sts _OSTime,R2
	sts _OSTime+2+1,R5
	sts _OSTime+2,R4
	.dbline 495
;     OS_EXIT_CRITICAL();
	rcall _OS_CPU_SR_Restore
	.dbline 497
; #endif    
;     ptcb = OSTCBList;                                      /* Point at first TCB in TCB list           */
	lds R12,_OSTCBList
	lds R13,_OSTCBList+1
	rjmp L38
L37:
	.dbline 498
;     while (ptcb->OSTCBPrio != OS_IDLE_PRIO) {              /* Go through all TCBs in TCB list          */
	.dbline 499
;         OS_ENTER_CRITICAL();
	rcall _OS_CPU_SR_Save
	mov R10,R16
	.dbline 500
;         if (ptcb->OSTCBDly != 0) {                         /* Delayed or waiting for event with TO     */
	movw R30,R12
	ldd R2,z+8
	ldd R3,z+9
	tst R2
	brne X3
	tst R3
	brne X5
	rjmp L40
X5:
X3:
	.dbline 500
	.dbline 501
;             if (--ptcb->OSTCBDly == 0) {                   /* Decrement nbr of ticks to end of delay   */
	movw R24,R12
	adiw R24,8
	movw R30,R24
	ldd R24,z+0
	ldd R25,z+1
	sbiw R24,1
	movw R4,R24
	std z+1,R5
	std z+0,R4
	cpi R24,0
	cpc R24,R25
	breq X6
	rjmp L42
X6:
X4:
	.dbline 501
	.dbline 502
;                 if ((ptcb->OSTCBStat & OS_STAT_SUSPEND) == 0x00) {   /* Is task suspended?             */
	movw R30,R12
	ldd R2,z+10
	sbrc R2,3
	rjmp L44
	.dbline 502
	.dbline 503
;                     OSRdyGrp               |= ptcb->OSTCBBitY; /* No,  Make task Rdy to Run (timed out)*/
	movw R30,R12
	ldd R2,z+15
	lds R3,_OSRdyGrp
	or R3,R2
	sts _OSRdyGrp,R3
	.dbline 504
;                     OSRdyTbl[ptcb->OSTCBY] |= ptcb->OSTCBBitX;
	ldi R24,<_OSRdyTbl
	ldi R25,>_OSRdyTbl
	movw R30,R12
	ldd R2,z+13
	clr R3
	add R2,R24
	adc R3,R25
	movw R30,R12
	ldd R4,z+14
	movw R30,R2
	ldd R5,z+0
	or R5,R4
	std z+0,R5
	.dbline 505
	rjmp L45
L44:
	.dbline 505
;                 } else {                                       /* Yes, Leave 1 tick to prevent ...     */
	.dbline 506
;                     ptcb->OSTCBDly = 1;                        /* ... loosing the task when the ...    */
	ldi R24,1
	ldi R25,0
	movw R30,R12
	std z+9,R25
	std z+8,R24
	.dbline 507
;                 }                                              /* ... suspension is removed.           */
L45:
	.dbline 508
;             }
L42:
	.dbline 509
;         }
L40:
	.dbline 510
	movw R30,R12
	ldd R12,z+2
	ldd R13,z+3
	.dbline 511
	mov R16,R10
	rcall _OS_CPU_SR_Restore
	.dbline 512
L38:
	.dbline 498
	movw R30,R12
	ldd R24,z+11
	cpi R24,20
	breq X7
	rjmp L37
X7:
	.dbline -2
L36:
	rcall pop_gset4
	.dbline 0 ; func end
	ret
	.dbsym r cpu_sr 10 c
	.dbsym r ptcb 12 pS[os_tcb]
	.dbend
	.dbfunc e OSVersion _OSVersion fi
	.even
_OSVersion::
	.dbline -1
	.dbline 530
;         ptcb = ptcb->OSTCBNext;                                /* Point at next TCB in TCB list        */
;         OS_EXIT_CRITICAL();
;     }
; }
; /*$PAGE*/
; /*
; *********************************************************************************************************
; *                                             GET VERSION
; *
; * Description: This function is used to return the version number of uC/OS-II.  The returned value
; *              corresponds to uC/OS-II's version number multiplied by 100.  In other words, version 2.00
; *              would be returned as 200.
; *
; * Arguments  : none
; *
; * Returns    : the version number of uC/OS-II multiplied by 100.
; *********************************************************************************************************
; */
; 
; INT16U  OSVersion (void)
; {
	.dbline 531
;     return (OS_VERSION);
	ldi R16,251
	ldi R17,0
	.dbline -2
L46:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e OS_EventTaskRdy _OS_EventTaskRdy fc
;           bity -> R12
;           bitx -> R22
;           prio -> R20
;              x -> R20
;           ptcb -> R14,R15
;              y -> R10
;            msk -> y+10
;            msg -> R18,R19
;         pevent -> R16,R17
	.even
_OS_EventTaskRdy::
	rcall push_gset5
	.dbline -1
	.dbline 577
; }
; 
; /*$PAGE*/
; /*
; *********************************************************************************************************
; *                                            DUMMY FUNCTION
; *
; * Description: This function doesn't do anything.  It is called by OSTaskDel().
; *
; * Arguments  : none
; *
; * Returns    : none
; *********************************************************************************************************
; */
; 
; #if OS_TASK_DEL_EN > 0
; void  OS_Dummy (void)
; {
; }
; #endif
; 

⌨️ 快捷键说明

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