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

📄 os-task-switch.s

📁 ucos-ii-at90S-icc-avr
💻 S
📖 第 1 页 / 共 4 页
字号:
	rcall _OSDebug
	.dbline 346
;             OSIntCtxSw();                        /* Perform interrupt level context switch             */
	rcall _OSIntCtxSw
	.dbline 347
;         }//end OSPrioHighRdy != OSPrioCur
L78:
L77:
	.dbline 348
;     }//end nesting==0
L74:
	.dbline 349
;     OS_EXIT_CRITICAL();
	st -y,r16
	pop r16
	out 0x3F,r16
	ld r16,y+
	.dbline 349
	.dbline -2
	.dbline 350
; }
L73:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e OSDebug _OSDebug fV
;         port_a -> R16
	.even
_OSDebug::
	.dbline -1
	.dbline 353
; 
; void OSDebug(void)
; {
	.dbline 356
; INT8U port_a;
;             //debug
; 			DDRA=0;port_a=PORTA;
	clr R2
	out 0x1a,R2
	.dbline 356
	in R16,0x1b
	.dbline 357
; 			DDRA=0xff;PORTA=~port_a;
	ldi R24,255
	out 0x1a,R24
	.dbline 357
	mov R2,R16
	com R2
	out 0x1b,R2
	.dbline -2
	.dbline 359
; 			//end debug
; }
L85:
	.dbline 0 ; func end
	ret
	.dbsym r port_a 16 c
	.dbend
	.dbfunc e OSEventInit _OSEventInit fV
;              i -> R20
;         pevent -> R16,R17
	.even
_OSEventInit::
	rcall push_gset1
	.dbline -1
	.dbline 386
; 
; /*
; *********************************************************************************************************
; *                             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.
; *********************************************************************************************************
; */
; #if OS_EVENT_EN
; 
; /*init event structure*/
; void  OSEventInit(OS_EVENT *pevent)
; {
	.dbline 388
; 	INT8U i;
; 	if(0==pevent)
	cpi R16,0
	cpc R16,R17
	brne L87
X18:
	.dbline 389
; 		return;
	rjmp L86
L87:
	.dbline 390
;     for(i=0;i<OS_TASK_COUNT;i++)
	clr R20
	rjmp L92
L89:
	.dbline 391
	mov R30,R20
	clr R31
	lsl R30
	rol R31
	add R30,R16
	adc R31,R17
	clr R2
	clr R3
	std z+0,R2
	std z+1,R3
L90:
	.dbline 390
	inc R20
L92:
	.dbline 390
	cpi R20,3
	brlo L89
	.dbline 392
; 		pevent->OSTaskTbl[i]=0;
;     pevent->OSEventCnt=0;
	clr R2
	clr R3
	mov R30,R16
	mov R31,R17
	std z+6,R2
	std z+7,R3
	.dbline 393
;     pevent->OSEventType=OS_EVENT_TYPE_INVALID;                   /* OS_EVENT_TYPE_MBOX, OS_EVENT_TYPE_Q or OS_EVENT_TYPE_SEM */
	std z+8,R2
	.dbline -2
	.dbline 394
; }
L86:
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r i 20 c
	.dbsym r pevent 16 pX
	.dbend
	.dbfunc e OSEventGetHighPrioRdy _OSEventGetHighPrioRdy fc
;           ptcb -> R20,R21
;              i -> R22
;         pevent -> R16,R17
	.even
_OSEventGetHighPrioRdy::
	rcall push_gset2
	.dbline -1
	.dbline 400
; 
; /*get highest prio from event's waiting task list,
;   ignore OSTCBStat and OSTCBDly.
;   Find first tcb in pevent->OSTaskTbl which is not null*/
; INT8U OSEventGetHighPrioRdy(OS_EVENT *pevent)
; {
	.dbline 403
; 	INT8U i;
; 	OS_TCB *ptcb;
; 	if(0==pevent)
	cpi R16,0
	cpc R16,R17
	brne L94
X19:
	.dbline 404
; 		return OS_TASK_COUNT;//error
	ldi R16,3
	rjmp L93
L94:
	.dbline 405
;     for(i=0;i<OS_TASK_COUNT;i++)
	clr R22
	rjmp L99
L96:
	.dbline 406
; 	{
	.dbline 407
; 		ptcb=pevent->OSTaskTbl[i];
	mov R30,R22
	clr R31
	lsl R30
	rol R31
	add R30,R16
	adc R31,R17
	ldd R20,z+0
	ldd R21,z+1
	.dbline 408
; 		if(ptcb)
	cpi R20,0
	cpc R20,R21
	breq L100
X20:
	.dbline 409
; 		{
	.dbline 410
; 			return ptcb->OSTCBPrio;
	mov R30,R20
	mov R31,R21
	ldd R16,z+5
	rjmp L93
L100:
	.dbline 412
L97:
	.dbline 405
	inc R22
L99:
	.dbline 405
	cpi R22,3
	brlo L96
	.dbline 413
; 		}
; 	}
; 	return OS_TASK_COUNT;//error
	ldi R16,3
	.dbline -2
L93:
	rcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r ptcb 20 pX
	.dbsym r i 22 c
	.dbsym r pevent 16 pX
	.dbend
	.dbfunc e OSEventTaskRdy _OSEventTaskRdy fV
;           prio -> R22
;           ptcb -> R22,R23
;            msk -> R20
;         pevent -> R22,R23
	.even
_OSEventTaskRdy::
	rcall push_gset2
	mov R20,R18
	mov R22,R16
	mov R23,R17
	.dbline -1
	.dbline 418
; }
; 
; /*when OSSemPend success,call OSEventTaskRdy to remove task from event waitting task list*/
; void  OSEventTaskRdy (OS_EVENT *pevent, INT8U msk)
; {
	.dbline 422
;     OS_TCB *ptcb;
;     INT8U   prio;
; 
; 	prio=OSEventGetHighPrioRdy(pevent);
	mov R16,R22
	mov R17,R23
	rcall _OSEventGetHighPrioRdy
	mov R22,R16
	.dbline 424
; #if OS_STRICT
; 	if(prio>OS_LOWEST_PRIO)
	ldi R24,2
	cp R24,R16
	brsh L103
	.dbline 425
; 		OSError(0);
	clr R16
	rcall _OSError
L103:
	.dbline 427
; #endif
;     ptcb                 =  OSpTCBList[prio];       /* Point to this task's OS_TCB                   */
	ldi R24,<_OSpTCBList
	ldi R25,>_OSpTCBList
	mov R30,R22
	clr R31
	lsl R30
	rol R31
	add R30,R24
	adc R31,R25
	ldd R22,z+0
	ldd R23,z+1
	.dbline 429
; #if OS_STRICT
; 	if(0==ptcb)
	cpi R22,0
	cpc R22,R23
	brne L105
X21:
	.dbline 430
; 		OSError(0);
	clr R16
	rcall _OSError
L105:
	.dbline 433
; #endif
; 	//clear event flags
;     ptcb->OSTCBDly       =  0;                        /* Prevent OSTimeTick() from readying task       */
	clr R2
	clr R3
	mov R30,R22
	mov R31,R23
	std z+2,R2
	std z+3,R3
	.dbline 434
;     ptcb->OSTCBStat     &= ~msk;                      /* Clear bit associated with event type          */
	mov R24,R22
	mov R25,R23
	adiw R24,4
	mov R4,R20
	com R4
	mov R30,R24
	mov R31,R25
	ldd R5,z+0
	and R5,R4
	std z+0,R5
	.dbline -2
	.dbline 435
; }
L102:
	rcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r prio 22 c
	.dbsym r ptcb 22 pX
	.dbsym r msk 20 c
	.dbsym r pevent 22 pX
	.dbend
	.dbfunc e OSEventTaskWait _OSEventTaskWait fV
;         pevent -> R20,R21
	.even
_OSEventTaskWait::
	rcall push_gset1
	mov R20,R16
	mov R21,R17
	.dbline -1
	.dbline 453
	.dbline 455
	lds R2,_OSTCBCur
	lds R3,_OSTCBCur+1
	tst R2
	brne L108
	tst R3
	brne L108
X22:
	.dbline 456
	clr R16
	rcall _OSError
L108:
	.dbline -2
	.dbline 458
; 
; 
; /*
; *********************************************************************************************************
; *                                   MAKE TASK WAIT FOR EVENT TO OCCUR
; *
; * Description: This function is called by other uC/OS-II services to suspend a task because an event has
; *              not occurred.
; *
; * Arguments  : pevent   is a pointer to the event control block for which the task will be waiting for.
; *
; * Returns    : none
; *
; * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
; *********************************************************************************************************
; */
; void  OSEventTaskWait (OS_EVENT *pevent)
; {
; #if OS_STRICT
; 	if(!OSTCBCur)
; 		OSError(0);
; #endif
; }
L107:
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r pevent 20 pX
	.dbend
	.dbfunc e OSEventTO _OSEventTO fV
;         pevent -> R16,R17
	.even
_OSEventTO::
	.dbline -1
	.dbline 474
; /*
; *********************************************************************************************************
; *                              MAKE TASK READY TO RUN BASED ON EVENT TIMEOUT
; *
; * Description: This function is called by other uC/OS-II services to make a task ready to run because a
; *              timeout occurred.
; *
; * Arguments  : pevent   is a pointer to the event control block which is readying a task.
; *
; * Returns    : none
; *
; * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
; *********************************************************************************************************
; */
; void  OSEventTO (OS_EVENT *pevent)
; {
	.dbline 475
;     OSTCBCur->OSTCBStat     = OS_STAT_RDY;       /* Set status to ready                                */
	ldi R24,1
	lds R30,_OSTCBCur
	lds R31,_OSTCBCur+1
	std z+4,R24
	.dbline -2
	.dbline 476
; }
L110:
	.dbline 0 ; func end
	ret
	.dbsym r pevent 16 pX
	.dbend
	.dbfunc e OSSemAccept _OSSemAccept fi
;            cnt -> R20,R21
;         pevent -> R16,R17
	.even
_OSSemAccept::
	rcall push_gset1
	.dbline -1
	.dbline 497
; #endif//OS_EVENT_EN
; 
; #if OS_SEM_EN
; /*
; *********************************************************************************************************
; *                                           ACCEPT SEMAPHORE
; *
; * Description: This function checks the semaphore to see if a resource is available or, if an event
; *              occurred.  Unlike OSSemPend(), OSSemAccept() does not suspend the calling task if the
; *              resource is not available or the event did not occur.
; *
; * Arguments  : pevent     is a pointer to the event control block
; *
; * Returns    : >  0       if the resource is available or the event did not occur the semaphore is
; *                         decremented to obtain the resource.
; *              == 0       if the resource is not available or the event did not occur or,
; *                         you didn't pass a pointer to a semaphore
; *********************************************************************************************************
; */
; INT16U OSSemAccept (OS_EVENT *pevent)
; {
	.dbline 500
;     INT16U cnt;
; 
;     OS_ENTER_CRITICAL();
	st -y,r16
	 in r16,0x3f
	 cli
	 push r16
	ld r16,y+
	.dbline 500
	.dbline 501
;     if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                     */
	mov R30,R16
	mov R31,R17
	ldd R24,z+8
	cpi R24,1
	breq L112
	.dbline 501
	.dbline 502
;         OS_EXIT_CRITICAL();
	st -y,r16
	pop r16
	out 0x3F,r16
	ld r16,y+
	.dbline 502
	.dbline 503
;         return (0);
	clr R16
	clr R17
	rjmp L111
L112:
	.dbline 505
;     }
;     cnt = pevent->OSEventCnt;
	mov R30,R16
	mov R31,R17
	ldd R20,z+6
	ldd R21,z+7
	.dbline 506
;     if (cnt > 0) {                                    /* See if resource is available                  */
	cpi R20,0
	cpc R20,R21
	breq L114
X23:
	.dbline 506
	.dbline 507
;         pevent->OSEventCnt--;                         /* Yes, decrement semaphore and notify caller    */
	mov R24,R16
	mov R25,R17
	adiw R24,6
	mov R30,R24
	mov R31,R25
	ldd R24,z+0
	ldd R25,z+1
	sbiw R24,1
	std z+0,R24
	std z+1,R25
	.dbline 508
;     }
L114:
	.dbline 509
;     OS_EXIT_CRITICAL();
	st -y,r16
	pop r16
	out 0x3F,r16
	ld r16,y+
	.dbline 509
	.dbline 510
;     return (cnt);                                     /* Return semaphore count                        */
	mov R16,R20
	mov R17,R21
	.dbline -2
L111:
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r cnt 20 i
	.dbsym r pevent 16 pX
	.dbend
	.dbfunc e OSSemCreate _OSSemCreate fpX
;            cnt -> R22,R23
;         pevent -> R20,R21
	.even
_OSSemCreate::
	rcall push_gset2
	mov R22,R18
	mov R23,R19
	mov R20,R16
	mov R21,R17
	.dbline -1
	.dbline 531
; }
; 
; /*
; *********************************************************************************************************
; *                                           CREATE A SEMAPHORE
; *
; * Description: This function creates a semaphore.
; *
; * Arguments  : cnt           is the initial value for the semaphore.  If the value is 0, no resource is
; *                            available (or no event has occurred).  You initialize the semaphore to a 
; *                            non-zero value to specify how many resources are available (e.g. if you have
; *                            10 resources, you would initialize the semaphore to 10).
; *
; * Returns    : != (void *)0  is a pointer to the event control clock (OS_EVENT) associated with the
; *                            created semaphore
; *              == (void *)0  if no event control blocks were available
; *********************************************************************************************************
; */
; 
; OS_EVENT *OSSemCreate (OS_EVENT *pevent,INT16U cnt)
; {
	.dbline 532
;     if (pevent != (OS_EVENT *)0) {                         /* Get an event control block               */
	cpi R20,0
	cpc R20,R21
	breq L117

⌨️ 快捷键说明

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