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

📄 rzksuspendinterruptthread.s

📁 zilog的实时操作系统RZK,可以移植到多种处理器上
💻 S
字号:
;/*
;* File				:	RZKSuspendInterruptThread.s
;*
;* Description		:	Contains a routine to suspend interrupt thread
;* 
;* Copyright 2004 ZiLOG Inc.  ALL RIGHTS RESERVED.
;*
;* This file contains unpublished confidential and proprietary information
;* of ZiLOG, Inc.
;* NO PART OF THIS WORK MAY BE DUPLICATED, STORED, PUBLISHED OR DISCLOSED 
;* IN ANY FORM WITHOUT THE PRIOR WRITTEN CONSENT OF ZiLOG, INC.
;* This is not a license and no use of any kind of this work is authorized
;* in the absence of a written license granted by ZiLOG, Inc. in ZiLOG's 
;* sole discretion 
;*/
			.extern _hCurrentThread
			.extern _DispatchQueue
			.extern _DQPriorityBitMap
			.extern _pMap
			.extern _QueueAppend
			.extern _QueueNodeRemove
			.extern _RZKScheduler

			OFFSET_STATE			:	equ	06H
			OFFSET_OPMODE			:	equ	11H
			OFFSET_DP				:	equ	12H
			THREAD_RUNNING			:	equ	08H
			THREAD_INFINITESUSPEND	:	equ	80H

			.def _RZKSuspendInterruptThread
			.assume	adl=1
;/* Function		:	RZKSuspendInterruptThread
;*
;* Description		:	Suspends interrupt thread
;* 
;* Inputs			:	None.
;*							
;* Outputs			:	None
;*							
;* Dependencies		:	None.
;*/
_RZKSuspendInterruptThread:
		LD IY, (_hCurrentThread);IY now contains thread handle

;		Below code is equivalent to the above mentioned code
		LD HL, (IY + %3)
		LD BC, (IY)
		LD (HL),BC
		LD DE, (IY)

		LD BC, (IY + %3)
		PUSH DE
		POP IY
		LD (IY + %3),BC

		LD IY, (_hCurrentThread)					;Restore IY:IY now contains thread handle
;		Below code is equivalent to the above mentioned code
		LD L,(IY + OFFSET_DP)			;pThread->cDispPriority
		LD H,6							;size of DispatchQueue=6 	typedef struct DISPATCHQ_t
										;							{ RZK_TCB_t  * pNext;	
										;							  RZK_TCB_t  * pPrevious;	
										;							} RZK_DISPATCHQ_t 
		MLT HL							;multiply with pThread->cDispPriority*Dispatchqueue size

		LD BC,_DispatchQueue			;
		ADD HL,BC						;DispatchQueue[pThread->cDispPriority]
		PUSH HL							;
		POP DE							;

		LD BC,3
		ADD HL,BC						;DispatchQueue[pThread->cDispPriority]
		LD HL, (HL)						;DispatchQueue[pThread->cDispPriority].pPrevious


		SBC HL, DE						;if( ( void * ) DispatchQueue[pThread->cDispPriority].pPrevious == 
										;( void * ) &DispatchQueue[pThread->cDispPriority])	
		
		jp nz, _return

		;Below code is equivalent to &pMap[pThread->cDispPriority]

		LD L,(IY + OFFSET_DP)			;pThread->cDispPriority	
		LD H,4							;size of each member of pMap array = 4
		MLT HL							;Multiply to get index into pmap array bytewise
		LD BC, _pMap					;_pMap
		ADD HL, BC						;&pMap[pThread->cDispPriority]

		LD A, (HL)
		CPL A							;~pMap[pThread->cDispPriority]

		LD IY, _DQPriorityBitMap

		AND A, (IY)						;DQPriorityBitMap &= (~pMap[pThread->cDispPriority]);
		LD (IY), A						;DQPriorityBitMap &= (~pMap[pThread->cDispPriority]);

		INC HL
		LD A, (HL)
		CPL A							;~pMap[pThread->cDispPriority]
		AND A, (IY+1)						;DQPriorityBitMap &= (~pMap[pThread->cDispPriority]);
		LD (IY+1), A						;DQPriorityBitMap &= (~pMap[pThread->cDispPriority]);

		INC HL
		LD A, (HL)
		CPL A							;~pMap[pThread->cDispPriority]
		AND A, (IY+2)						;DQPriorityBitMap &= (~pMap[pThread->cDispPriority]);
		LD (IY+2), A						;DQPriorityBitMap &= (~pMap[pThread->cDispPriority]);

		INC HL
		LD A, (HL)
		CPL A							;~pMap[pThread->cDispPriority]
		AND A, (IY+3)						;DQPriorityBitMap &= (~pMap[pThread->cDispPriority]);
		LD (IY+3), A						;DQPriorityBitMap &= (~pMap[pThread->cDispPriority]);
_return	
		;Below code is equivalent to pThread->uState |= THREAD_INFINITESUSPEND and pThread->uState &= (~THREAD_RUNNING)
		LD IY, (_hCurrentThread)					;IY now contains thread handle

		LD A, (IY+OFFSET_STATE)
		RES 3,A
		OR A,THREAD_INFINITESUSPEND
		LD (IY+OFFSET_STATE), A

		EI
		DI
		CALL _RZKScheduler

		RET

⌨️ 快捷键说明

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