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

📄 semalib.s

📁 vxworks源码源码解读是学习vxworks的最佳途径
💻 S
📖 第 1 页 / 共 2 页
字号:
        movl	SEM_STATE(%ecx),%edx	/* state/count/owner */        pushl	%edx        pushl	%ecx			/* semId */	pushl	$ 3			/* number of paramters */	pushl	$ EVENT_SEMTAKE		/* EVENT_SEMTAKE, event id */        movl	SEM_INST_RTN(%eax),%edx	/* get logging routine */        call	*%edx			/* call routine */        addl	$28,%esptrgNoSemTake:	popl	%edx	popl	%ecx			/* semId */	popl	%eaxtrgCheckSemTake:	movl	$ TRG_CLASS_3,%eax     	orl 	$ TRG_ON,%eax        cmpl    _trgEvtClass,%eax       /* any trigger? */	jne	noSemTakeEvt        movl    __func_trgCheck,%eax    /* triggering routine */        cmpl    $0,%eax        je      noSemTakeEvt	pushl	%ecx			/* semId */	pushl	%edx        pushl   $ 0                     /* 0 */        pushl   $ 0                     /* 0 */        movl	$0,%edx        movw	SEM_RECURSE(%ecx),%edx	/* recursively called */        pushl	%edx        movl	SEM_STATE(%ecx),%edx	/* state/count/owner */        pushl	%edx        pushl	%ecx			/* semId */	pushl	%ecx			/* objId */        pushl   $ TRG_CLASS3_INDEX      /* TRG_CLASS3_INDEX */	pushl	$ EVENT_SEMTAKE		/* EVENT_SEMTAKE, event id */        call    *%eax                   /* call triggering routine */        addl    $32,%esp	popl	%edx	popl	%ecx			/* semId */noSemTakeEvt:        /* windview instrumentation - END */#endif  /* WV_INSTRUMENTATION */	movb	SEM_TYPE(%ecx),%dl	/* get semaphore class into %edx */	andl	$7,%edx			/* mask %edx to sane value */	jne	semTakeNotBinary	/* optimize binary semaphore %edx==0 */			/* BINARY SEMAPHORE OPTIMIZATION */_semBTake:					/* %ecx = semId! */		cli				/* LOCK INTERRUPTS */		cmpl	$_semClass,(%ecx)	/* check validity */#ifdef WV_INSTRUMENTATION        	je	objOkBTake		/* windview - check the validity of instrumented class */        	cmpl	$_semInstClass,(%ecx)	/* check validity */        	jne	semIsInvalidUnlock	/* semaphore id error */objOkBTake:#else                jne     semIsInvalidUnlock      /* invalid semaphore */#endif  /* WV_INSTRUMENTATION */		movl	SEM_STATE(%ecx),%eax	/* test for owner */		cmpl	$0,%eax		jne	_semQPut		/* if sem is owned we block */		movl	_taskIdCurrent,%edx		movl	%edx,SEM_STATE(%ecx)		sti				/* UNLOCK INTERRUPTS */		ret				/* %eax is still 0 for OK */	.align 4,0x90semTakeNotBinary:	movl	_semTakeTbl(,%edx,4),%edx	jmp	*%edx			/* invoke the routine; it will do ret */	.align 4,0x90semTakeGlobal:	addl	_smObjPoolMinusOne,%ecx    /* convert id to local address */	movb	7(%ecx),%dl		   /* get semaphore type in %dl */				           /* offset 7 is used as the type					    * is stored in  network order					    */			andl	$7,%edx			   /* mask %edx to MAX_SEM_TYPE */	movl	_semTakeTbl(,%edx,4),%edx  /* %edx is appropriate give rtn. */	pushl	SP_ARG2(%esp)		   /* push timeout */	pushl	%ecx			   /* push converted semId */	call	*%edx			   /* call appropriate take rtn. */	addl	$8,%esp			   /* clean up */	ret/********************************************************************************* semQGet - unblock a task from the semaphore queue head*/	.align 4,0x90_semQGet:	movl	$1,_kernelState		/* KERNEL ENTER */#ifdef WV_INSTRUMENTATION        /* windview instrumentation - BEGIN         * semGive: task transition state class         */	cmpl	$0,_evtAction		/* is WindView on? */	je	noSemQGetEvt	movl	$ WV_CLASS_2_ON,%eax        andl    _wvEvtClass,%eax          /* is event collection on? */        cmpl    $ WV_CLASS_2_ON,%eax          /* is event collection on? */	jne	trgCheckSemQGet	movl	__func_evtLogM1,%edx	/* event log routine */	cmpl	$0,%edx	je	noSemQGetEvt	pushl	%ecx			/* push semId */	pushl	$ EVENT_OBJ_SEMGIVE	/* EVENT_OBJ_SEMGIVE */	call	*%edx			/* call event log routine */			addl	$4,%esp			/* restore stack pointer */        popl	%ecx        		/* pop semId */trgCheckSemQGet:	movl	$ TRG_CLASS_2,%eax     	orl 	$ TRG_ON,%eax        cmpl    _trgEvtClass,%eax       /* any trigger? */	jne	noSemQGetEvt        movl    __func_trgCheck,%edx    /* triggering routine */        cmpl    $0,%edx        je      noSemQGetEvt	pushl	%ecx			/* semId */        pushl   $ 0                     /* 0 */        pushl   $ 0                     /* 0 */        pushl   $ 0                     /* 0 */        pushl   $ 0                     /* 0 */	pushl	%ecx			/* push semId */	pushl	%ecx			/* objId */        pushl   $ TRG_CLASS2_INDEX      /* TRG_CLASS3_INDEX */	pushl	$ EVENT_OBJ_SEMGIVE	/* EVENT_OBJ_SEMGIVE */	call	*%edx			/* call triggering routine */		        addl    $32,%esp	popl	%ecx			/* semId */noSemQGetEvt:        /* windview instrumentation - END */#endif  /* WV_INSTRUMENTATION */	sti				/* UNLOCK INTERRUPTS */	leal	SEM_Q_HEAD(%ecx),%edx	pushl	%edx			/* push the pointer to qHead */	call	_windPendQGet		/* unblock someone */	addl	$4,%esp			/* clean up */	call	_windExit		/* KERNEL EXIT */	ret         			/* windExit sets %eax *//********************************************************************************* semQPut - block current task on the semaphore queue head*/	.align 4,0x90_semQPut:	movl	$1,_kernelState		/* KERNEL ENTER */#ifdef WV_INSTRUMENTATION        /* windview instrumentation - BEGIN         * semTake: task transition state class         */	cmpl	$0,_evtAction		/* is WindView on? */	je	noSemQPutEvt	movl	$ WV_CLASS_2_ON,%eax        andl    _wvEvtClass,%eax          /* is event collection on? */        cmpl    $ WV_CLASS_2_ON,%eax          /* is event collection on? */	jne	trgCheckSemQPut        movl	__func_evtLogM1,%edx	/* call event log routine */	cmpl	$0,%edx        je	trgCheckSemQPut        pushl	%ecx			/* push semId */        pushl	$ EVENT_OBJ_SEMTAKE	/* EVENT_OBJ_SEMTAKE */        call	*%edx        addl	$4,%esp			/* restore stack pointer */        popl	%ecx			/* pop semId */trgCheckSemQPut:	movl	$ TRG_CLASS_2,%eax     	orl 	$ TRG_ON,%eax        cmpl    _trgEvtClass,%eax       /* any trigger? */	jne	noSemQPutEvt        movl    __func_trgCheck,%edx    /* triggering routine */        cmpl    $0,%edx        je      noSemQPutEvt	pushl	%ecx			/* semId */        pushl   $ 0                     /* 0 */        pushl   $ 0                     /* 0 */        pushl   $ 0                     /* 0 */        pushl   $ 0                     /* 0 */	pushl	%ecx			/* push semId */	pushl	%ecx			/* objId */        pushl   $ TRG_CLASS2_INDEX      /* TRG_CLASS3_INDEX */	pushl	$ EVENT_OBJ_SEMTAKE	/* EVENT_OBJ_SEMTAKE */	call	*%edx			/* call triggering routine */		        addl    $32,%esp	popl	%ecx			/* semId */noSemQPutEvt:        /* windview instrumentation - END */#endif  /* WV_INSTRUMENTATION */	sti				/* UNLOCK INTERRUPTS */	pushl	SP_ARG2(%esp)		/* push the timeout */	leal	SEM_Q_HEAD(%ecx),%eax	pushl	%eax			/* push the &semId->qHead */	call	_windPendQPut		/* block on the semaphore */	addl	$8,%esp			/* tidy up */	cmpl	$0,%eax			/* if (windPendQPut != OK) */	jne	semQPutFail		/* put failed */	call	_windExit		/* else KERNEL EXIT */	cmpl	$0,%eax			/* test windExit */	jg	semRestart		/* RESTART */	ret				/* done */	.align 4,0x90semQPutFail:	call	_windExit		/* KERNEL EXIT */	movl	$-1,%eax		/* return ERROR */	ret				/* return to sender */	.align 4,0x90semRestart:	pushl	SP_ARG2(%esp)		/* push the timeout */	movl	__func_sigTimeoutRecalc,%eax	call	*%eax			/* recalc the timeout */	addl	$4,%esp			/* clean up */	movl	%eax,SP_ARG2(%esp)	/* and store it */	jmp	_semTake		/* start the whole thing over *//********************************************************************************* semOTake - VxWorks 4.x semTake** Optimized version of semOTake.  This inserts the necessary argument of* WAIT_FOREVER for semBTake.*/	.align 4,0x90_semOTake:	pushl	$-1			/* push WAIT_FOREVER on stack */	movl	SP_ARG1+4(%esp),%eax	/* put semId in %eax */	pushl	%eax			/* put semId on stack */	call	_semBTake		/* do semBTake */	addl	$8,%esp			/* cleanup */	ret	/********************************************************************************* semClear - VxWorks 4.x semClear** Optimized version of semClear.  This inserts the necessary argument of* NO_WAIT for semBTake().*/	.align 4,0x90_semClear:	pushl	$0			/* push NO_WAIT on stack */	movl	SP_ARG1+4(%esp),%eax	/* put semId in %eax */	pushl	%eax			/* put semId on stack */	call	_semBTake		/* do semBTake */	addl	$8,%esp			/* cleanup */	ret#endif	/* !PORTABLE */

⌨️ 快捷键说明

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