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

📄 ucos_ii.s

📁 ucos在mage128上的应用
💻 S
📖 第 1 页 / 共 5 页
字号:
; *                 b) Set OSRunning to TRUE.
; *                 c) Load the context of the task pointed to by OSTCBHighRdy.
; *                 d_ Execute the task.
; *********************************************************************************************************
; */
; 
; void  OSStart (void)
; {
	.dbline 458
;     INT8U y;
;     INT8U x;
; 
; 
;     if (OSRunning == FALSE) {
	lds R2,_OSRunning
	tst R2
	breq X18
	xjmp L33
X18:
X17:
	.dbline 458
	.dbline 459
;         y             = OSUnMapTbl[OSRdyGrp];        /* Find highest priority's task priority number   */
	ldi R24,<_OSUnMapTbl
	ldi R25,>_OSUnMapTbl
	lds R30,_OSRdyGrp
	clr R31
	add R30,R24
	adc R31,R25
	elpm R10,Z
	.dbline 460
;         x             = OSUnMapTbl[OSRdyTbl[y]];
	ldi R24,<_OSRdyTbl
	ldi R25,>_OSRdyTbl
	mov R30,R10
	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
	elpm R12,Z
	.dbline 461
;         OSPrioHighRdy = (INT8U)((y << 3) + x);
	mov R2,R12
	clr R3
	mov R4,R10
	clr R5
	lsl R4
	rol R5
	lsl R4
	rol R5
	lsl R4
	rol R5
	add R4,R2
	adc R5,R3
	sts _OSPrioHighRdy,R4
	.dbline 462
;         OSPrioCur     = OSPrioHighRdy;
	mov R2,R4
	sts _OSPrioCur,R2
	.dbline 463
;         OSTCBHighRdy  = OSTCBPrioTbl[OSPrioHighRdy]; /* Point to highest priority task ready to run    */
	ldi R24,<_OSTCBPrioTbl
	ldi R25,>_OSTCBPrioTbl
	mov R30,R4
	clr R31
	lsl R30
	rol R31
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	ldd R3,z+1
	sts _OSTCBHighRdy+1,R3
	sts _OSTCBHighRdy,R2
	.dbline 464
;         OSTCBCur      = OSTCBHighRdy;
	sts _OSTCBCur+1,R3
	sts _OSTCBCur,R2
	.dbline 465
;         OSStartHighRdy();                            /* Execute target specific code to start task     */
	xcall _OSStartHighRdy
	.dbline 466
;     }
L33:
	.dbline -2
L32:
	.dbline 0 ; func end
	ld R12,y+
	ld R10,y+
	ret
	.dbsym r x 12 c
	.dbsym r y 10 c
	.dbend
	.dbfunc e OSTimeTick _OSTimeTick fV
	.dbstruct 0 14 os_event
	.dbfield 0 OSEventType c
	.dbfield 1 OSEventGrp c
	.dbfield 2 OSEventCnt i
	.dbfield 4 OSEventPtr pV
	.dbfield 6 OSEventTbl A[8:8]c
	.dbend
	.dbstruct 0 34 os_tcb
	.dbfield 0 OSTCBStkPtr pc
	.dbfield 2 OSTCBNext pS[os_tcb]
	.dbfield 4 OSTCBPrev pS[os_tcb]
	.dbfield 6 OSTCBEventPtr pS[os_event]
	.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
	.dbfield 16 OSTCBCtxSwCtr l
	.dbfield 20 OSTCBCyclesTot l
	.dbfield 24 OSTCBCyclesStart l
	.dbfield 28 OSTCBStkBase pc
	.dbfield 30 OSTCBStkUsed l
	.dbend
;           step -> R20
;         cpu_sr -> R10
;           ptcb -> R20,R21
	.even
_OSTimeTick::
	xcall push_xgsetF03C
	.dbline -1
	.dbline 524
; }
; /*$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 / 10);            /* Determine MAX. idle counter value for 1/10 second  */
;     OS_ENTER_CRITICAL();
;     OSIdleCtrMax = OSIdleCtr;                    /* Store maximum idle counter count in 1/10 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 533
; #if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register     */
;     OS_CPU_SR  cpu_sr;
; #endif    
;     OS_TCB    *ptcb;
;     BOOLEAN    step;
; 
; 
; #if OS_TIME_TICK_HOOK_EN > 0
;     OSTimeTickHook();                                      /* Call user definable hook                     */
	xcall _OSTimeTickHook
	.dbline 540
; #endif    
; #if OS_TIME_GET_SET_EN > 0   
;     OS_ENTER_CRITICAL();                                   /* Update the 32-bit tick counter               */
;     OSTime++;
;     OS_EXIT_CRITICAL();
; #endif
;     if (OSRunning == TRUE) {    
	lds R24,_OSRunning
	cpi R24,1
	breq X25
	xjmp L36
X25:
X19:
	.dbline 540
	.dbline 562
; #if OS_TICK_STEP_EN > 0
;         switch (OSTickStepState) {                         /* Determine whether we need to process a tick  */
;             case OS_TICK_STEP_DIS:                         /* Yes, stepping is disabled                    */
;                  step = TRUE;
;                  break;
;         
;             case OS_TICK_STEP_WAIT:                        /* No,  waiting for uC/OS-View to set ...       */
;                  step = FALSE;                             /*      .. OSTickStepState to OS_TICK_STEP_ONCE */
;                  break;
; 
;             case OS_TICK_STEP_ONCE:                        /* Yes, process tick once and wait for next ... */
;                  step            = TRUE;                   /*      ... step command from uC/OS-View        */
;                  OSTickStepState = OS_TICK_STEP_WAIT;
;                  break;  
; 
;             default:                                       /* Invalid case, correct situation              */
;                  step            = TRUE;
;                  OSTickStepState = OS_TICK_STEP_DIS;
;                  break;
;         }
; #else
;         step = TRUE;
	ldi R20,1
	.dbline 564
; #endif
;         if (step == TRUE) {
	cpi R20,1
	breq X26
	xjmp L38
X26:
X20:
	.dbline 564
	.dbline 565
;             ptcb = OSTCBList;                              /* Point at first TCB in TCB list               */
	lds R20,_OSTCBList
	lds R21,_OSTCBList+1
	xjmp L41
L40:
	.dbline 566
;             while (ptcb->OSTCBPrio != OS_IDLE_PRIO) {      /* Go through all TCBs in TCB list              */
	.dbline 567
;                 OS_ENTER_CRITICAL();
	xcall _OS_CPU_SR_Save
	mov R10,R16
	.dbline 568
;                 if (ptcb->OSTCBDly != 0) {                 /* Delayed or waiting for event with TO         */
	movw R30,R20
	ldd R2,z+8
	ldd R3,z+9
	tst R2
	brne X21
	tst R3
	brne X27
	xjmp L43
X27:
X21:
	.dbline 568
	.dbline 569
;                     if (--ptcb->OSTCBDly == 0) {           /* Decrement nbr of ticks to end of delay       */
	movw R24,R30
	adiw R24,8
	movw R30,R24
	ldd R22,z+0
	ldd R23,z+1
	subi R22,1
	sbci R23,0
	std z+1,R23
	std z+0,R22
	cpi R22,0
	cpc R22,R23
	brne L45
X22:
	.dbline 569
	.dbline 570
;                         if ((ptcb->OSTCBStat & OS_STAT_SUSPEND) == OS_STAT_RDY) { /* Is task suspended?    */
	movw R30,R20
	ldd R2,z+10
	sbrc R2,3
	rjmp L47
X23:
	.dbline 570
	.dbline 571
;                             OSRdyGrp               |= ptcb->OSTCBBitY; /* No,  Make task R-to-R (timed out)*/
	ldd R2,z+15
	lds R3,_OSRdyGrp
	or R3,R2
	sts _OSRdyGrp,R3
	.dbline 572
;                             OSRdyTbl[ptcb->OSTCBY] |= ptcb->OSTCBBitX;
	ldi R24,<_OSRdyTbl
	ldi R25,>_OSRdyTbl
	ldd R12,z+13
	clr R13
	add R12,R24
	adc R13,R25
	ldd R2,z+14
	movw R30,R12
	ldd R3,z+0
	or R3,R2
	std z+0,R3
	.dbline 573
;                         } else {                           /* Yes, Leave 1 tick to prevent loosing the ... */
	xjmp L48
L47:
	.dbline 573
	.dbline 574
;                             ptcb->OSTCBDly = 1;            /* ... task when the suspension is removed.     */
	ldi R24,1
	ldi R25,0
	movw R30,R20
	std z+9,R25
	std z+8,R24
	.dbline 575
;                         }
L48:
	.dbline 576
;                     }
L45:
	.dbline 577
;                 }
L43:
	.dbline 578
;                 ptcb = ptcb->OSTCBNext;                    /* Point at next TCB in TCB list                */
	movw R30,R20
	ldd R20,z+2
	ldd R21,z+3
	.dbline 579
;                 OS_EXIT_CRITICAL();
	mov R16,R10
	xcall _OS_CPU_SR_Restore
	.dbline 580
;             }
L41:
	.dbline 566
	movw R30,R20
	ldd R24,z+11
	cpi R24,63
	breq X28
	xjmp L40
X28:
X24:
	.dbline 581
;         }
L38:
	.dbline 582
;     }
L36:
	.dbline -2
L35:
	.dbline 0 ; func end
	xjmp pop_xgsetF03C
	.dbsym r step 20 c
	.dbsym r cpu_sr 10 c
	.dbsym r ptcb 20 pS[os_tcb]
	.dbend
	.dbfunc e OSVersion _OSVersion fi
	.even
_OSVersion::
	.dbline -1
	.dbline 600
; }
; /*$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 601
;     return (OS_VERSION);
	ldi R16,270
	ldi R17,1
	.dbline -2
L49:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e OS_EventTaskRdy _OS_EventTaskRdy fc
;           bity -> R20
;           bitx -> R14
;           prio -> R10
;              x -> R10
;           ptcb -> R22,R23
;              y -> y+0
;            msk -> y+13
;            msg -> <dead>
;         pevent -> R16,R17
	.even
_OS_EventTaskRdy::
	st -y,r19
	st -y,r18
	xcall push_xgsetF0FC
	sbiw R28,1
	.dbline -1
	.dbline 647
; }
; 
; /*$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
; 
; /*$PAGE*/
; /*
; *********************************************************************************************************
; *                             MAKE TASK READY TO RUN BASED ON EVENT OCCURING
; *
; * Description: This function is called by other uC/OS-II services and is used to ready a task that was
; *              waiting for an event to occur.
; *
; * Arguments  : pevent    is a pointer to the event control block corresponding to the event.
; *
; *              msg       is a pointer to a message.  This pointer is used by message oriented services
; *                        such as MAILBOXEs and QUEUEs.  The pointer is not used when called by other
; *                        service functions.
; *
; *              msk       is a mask that is used to clear the status byte of the TCB.  For example,
; *                        OSSemPost() will pass OS_STAT_SEM, OSMboxPost() will pass OS_STAT_MBOX etc.
; *
; * Returns    : none
; *
; * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
; *********************************************************************************************************
; */

⌨️ 快捷键说明

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