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

📄 windalib.s

📁 vxworks源码源码解读是学习vxworks的最佳途径
💻 S
📖 第 1 页 / 共 3 页
字号:
/* windALib.s - I80x86 internal VxWorks kernel assembly library *//* Copyright 1984-1993 Wind River Systems, Inc. */	.data	.globl	_copyright_wind_river	.long	_copyright_wind_river/*modification history--------------------01m,28aug98,hdn  replaced sysIntLevel() with "movl INT29(%edi),%eax"01l,10aug98,pr   replaced evtsched with function pointer _func_evtLogTSched01k,29apr98,cjtc fix WV instrumentation in idle01j,16apr98,pr   cleanup.01i,17feb98,pr   added WindView 2.0 code.01h,29jul96,sbs  Made windview conditionally compile.01g,14jun95,hdn  changed CODE_SELECTOR to sysCodeSelector.01f,08aug94,hdn  added support for WindView.01e,02jun93,hdn  updated to 5.1.		  - fixed #else and #endif		  - changed VOID to void		  - changed ASMLANGUAGE to _ASMLANGUAGE		  - changed copyright notice01d,15oct92,hdn  supported nested interrupt.01c,13oct92,hdn  debugged.01b,07apr92,hdn  written optimized codes.01a,28feb92,hdn  written based on TRON, 68k version.*//*DESCRIPTIONThis module contains internals to the VxWorks kernel.These routines have been coded in assembler because they are eitherspecific to this processor, or they have been optimized for performance.*/#define _ASMLANGUAGE#include "vxWorks.h"#include "asm.h"#include "regs.h"#include "private/eventP.h"#include "private/trgLibP.h"#include "private/taskLibP.h"#include "private/semLibP.h"#include "private/workQLibP.h"	/* globals */	.globl	_windExit		/* routine to exit mutual exclusion */	.globl	_vxTaskEntry		/* task entry wrapper */	.globl	_intEnt			/* interrupt entrance routine */	.globl	_intExit		/* interrupt exit routine */	.globl	_windIntStackSet	/* interrupt stack set routine */#ifdef PORTABLE	.globl	_windLoadContext	/* needed by portable reschedule () */#else	.globl	_reschedule		/* optimized reschedule () routine */#endif	/* PORTABLE */	.text	.align 4/********************************************************************************* windExitInt - exit kernel routine from interrupt level** windExit branches here if exiting kernel routine from int level* No rescheduling is necessary because the ISR will exit via intExit, and* intExit does the necessary rescheduling.*/windExitIntWork:	popfl				/* pop original level */	call	_workQDoWork		/* empty the work queue */windExitInt:	pushfl				/* push interrupt level to stack */	cli				/* LOCK INTERRUPTS */	cmpl	$0,_workQIsEmpty	/* test for work to do */	je	windExitIntWork		/* workQ is not empty */#ifdef WV_INSTRUMENTATION	/* windview instrumentation - BEGIN	 * exit windExit with no dispatch; point 1 in the windExit diagram.	 */        cmpl    $0,_evtAction           /* is WindView on? */        je      noInst1	movl	$ WV_CLASS_1_ON,%eax        andl    _wvEvtClass,%eax          /* is event collection on? */        cmpl    $ WV_CLASS_1_ON,%eax          /* is event collection on? */        jne     trgCheckInst1	movl	__func_evtLogTSched,%edx	/* event log routine */	cmpl	$0,%edx        je      trgCheckInst1        movl	_taskIdCurrent,%eax		/* current task */        movl	WIND_TCB_PRIORITY(%eax),%ecx        pushl	%ecx	                        /* WIND_TCB_PRIORITY */        pushl	%eax	                        /* taskIdCurrent */        /* Here we try to determine if the task is running at an         * inherited priority, if so a different event is generated.         */        cmpl	WIND_TCB_PRI_NORMAL(%eax),%ecx        jge     noInst1Inheritance		/* no inheritance */        pushl	$ EVENT_WIND_EXIT_NODISPATCH_PI        jmp     inst1Inheritance		/* no inheritance */noInst1Inheritance:        pushl	$ EVENT_WIND_EXIT_NODISPATCH	/* event id */inst1Inheritance:        call    *%edx                           /* call evtsched routine */	addl    $12,%esptrgCheckInst1:	movl	$ TRG_CLASS_1,%eax     	orl 	$ TRG_ON,%eax        cmpl    _trgEvtClass,%eax       /* any trigger? */        jne     noInst1        movl    __func_trgCheck,%edx    /* triggering routine */	cmpl	$0,%edx        je      noInst1        movl	_taskIdCurrent,%eax		/* current task */        movl	WIND_TCB_PRIORITY(%eax),%ecx        pushl   $ 0                     /* 0 */        pushl   $ 0                     /* 0 */        pushl   $ 0                     /* 0 */        pushl	%ecx	                /* WIND_TCB_PRIORITY */        pushl	%eax	                /* taskIdCurrent */        pushl   $ 0                     /* obj */        pushl   $ 0                     /* TRG_CLASS1_INDEX */        /* Here we try to determine if the task is running at an         * inherited priority, if so a different event is generated.         */        cmpl	WIND_TCB_PRI_NORMAL(%eax),%ecx        jge     noTrgInst1Inheritance		/* no inheritance */        pushl	$ EVENT_WIND_EXIT_NODISPATCH_PI        jmp     trgInst1Inheritance		/* no inheritance */noTrgInst1Inheritance:        pushl	$ EVENT_WIND_EXIT_NODISPATCH    /* event id */trgInst1Inheritance:        call    *%edx                           /* call triggering routine */	addl    $32,%espnoInst1:	/* windview instrumentation - END */#endif  /* WV_INSTRUMENTATION */	movl	$0,_kernelState		/* release mutual exclusion to kernel */	popfl				/* pop original level */	xorl	%eax,%eax		/* return OK */	ret				/* intExit will do rescheduling *//********************************************************************************* checkTaskReady - check that taskIdCurrent is ready to run** This code branched to by windExit when it finds preemption is disabled.* It is possible that even though preemption is disabled, a context switch* must occur.  This situation arrises when a task block during a preemption* lock.  So this routine checks if taskIdCurrent is ready to run, if not it* branches to save the context of taskIdCurrent, otherwise it falls thru to* check the work queue for any pending work.*/	.align 4,0x90checkTaskReady:	cmpl	$0,WIND_TCB_STATUS(%edx) /* is task ready to run */	jne	saveTaskContext		/* if no, we blocked with preempt off */	/* FALL THRU TO CHECK WORK QUEUE *//********************************************************************************* checkWorkQ -	check the work queue for any work to do** This code is branched to by windExit.  Currently taskIdCurrent is highest* priority ready task, but before we can return to it we must check the work* queue.  If there is work we empty it via doWorkPreSave, otherwise we unlock* interrupts, clear d0, and return to taskIdCurrent.*/checkWorkQ:	cli				/* LOCK INTERRUPTS */	cmpl	$0,_workQIsEmpty	/* test for work to do */	je	doWorkPreSave		/* workQueue is not empty */#ifdef WV_INSTRUMENTATION	/* windview instrumentation - BEGIN	 * exit windExit with no dispatch; point 4 in the windExit diagram.	 */        cmpl    $0,_evtAction           /* is WindView on? */        je      noInst4	movl	$ WV_CLASS_1_ON,%eax        andl    _wvEvtClass,%eax          /* is event collection on? */        cmpl    $ WV_CLASS_1_ON,%eax          /* is event collection on? */        jne     trgCheckInst4	movl	__func_evtLogTSched,%edx	/* event log routine */	cmpl	$0,%edx        je      trgCheckInst4        movl	_taskIdCurrent,%eax		/* current task */        movl	WIND_TCB_PRIORITY(%eax),%ecx        pushl	%ecx	                        /* WIND_TCB_PRIORITY */        pushl	%eax	                        /* taskIdCurrent */	/* Here we try to determine if the task is running at an	 * inherited priority, if so a different event is generated.	 */        cmpl	WIND_TCB_PRI_NORMAL(%eax),%ecx        jge     noInst4Inheritance		/* no inheritance */        pushl	$ EVENT_WIND_EXIT_NODISPATCH_PI        jmp     inst4Inheritance		/* no inheritance */noInst4Inheritance:        pushl	$ EVENT_WIND_EXIT_NODISPATCH	/* event id */inst4Inheritance:        call    *%edx                           /* call evtsched routine */	addl    $12,%esptrgCheckInst4:	movl	$ TRG_CLASS_1,%eax     	orl 	$ TRG_ON,%eax        cmpl    _trgEvtClass,%eax       /* any trigger? */        jne     noInst4        movl    __func_trgCheck,%edx    /* triggering routine */	cmpl	$0,%edx        je      noInst4        movl	_taskIdCurrent,%eax		/* current task */        movl	WIND_TCB_PRIORITY(%eax),%ecx        pushl   $ 0                     /* 0 */        pushl   $ 0                     /* 0 */        pushl   $ 0                     /* 0 */        pushl	%ecx	                /* WIND_TCB_PRIORITY */        pushl	%eax	                /* taskIdCurrent */        pushl   $ 0                     /* obj */        pushl   $ 0                     /* TRG_CLASS1_INDEX */	/* Here we try to determine if the task is running at an	 * inherited priority, if so a different event is generated.	 */        cmpl	WIND_TCB_PRI_NORMAL(%eax),%ecx        jge     noTrgInst4Inheritance		/* no inheritance */        pushl	$ EVENT_WIND_EXIT_NODISPATCH_PI        jmp     trgInst4Inheritance		/* no inheritance */noTrgInst4Inheritance:        pushl	$ EVENT_WIND_EXIT_NODISPATCH	/* event id */trgInst4Inheritance:        call    *%edx                   /* call triggering routine */	addl    $32,%espnoInst4:	/* windview instrumentation - END */#endif  /* WV_INSTRUMENTATION */	movl	$0,_kernelState		/* else release exclusion */	sti				/* UNLOCK INTERRUPTS */	xorl	%eax,%eax		/* return OK */	ret				/* back to calling task *//********************************************************************************* doWorkPreSave - empty the work queue with current context not saved** We try to empty the work queue here, rather than let reschedule* perform the work because there is a strong chance that the* work we do will not preempt the calling task.  If this is the case, then* saving the entire context just to restore it in reschedule is a waste of* time.  Once the work has been emptied, the ready queue must be checked to* see if reschedule must be called, the check of the ready queue is done by* branching back up to checkTaskCode.*/	.align 4,0x90doWorkPreSave:	sti				/* UNLOCK INTERRUPTS */	call	_workQDoWork		/* empty the work queue */	jmp	checkTaskSwitch		/* back up to test if tasks switched *//******************************************************************************** windExit - task level exit from kernel** Release kernel mutual exclusion (kernelState) and dispatch any new task if* necessary.  If a higher priority task than the current task has been made* ready, then we invoke the rescheduler.  Before releasing mutual exclusion,* the work queue is checked and emptied if necessary.** If rescheduling is necessary, the context of the calling task is saved in its* associated TCB with the PC pointing at the next instruction after the jsr to* this routine.  The SP in the tcb is modified to ignore the return address* on the stack.  Thus the context saved is as if this routine was never called.** Only the volatile registers e[adc]x are safe to use until the context* is saved in saveTaskContext.** At the call to reschedule the value of taskIdCurrent must be in edx.** RETURNS: OK or*	   ERROR if semaphore timeout occurs.** NOMANUAL* STATUS windExit ()*/	.align 4,0x90_windExit:	cmpl	$0,_intCnt		/* if intCnt == 0 we're from task */	jne	windExitInt		/* else we're exiting interrupt code */	/* FALL THRU TO CHECK THAT CURRENT TASK IS STILL HIGHEST *//********************************************************************************* checkTaskSwitch - check to see if taskIdCurrent is still highest task** We arrive at this code either as the result of falling thru from windExit,

⌨️ 快捷键说明

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