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

📄 tmhal.c

📁 PNX系列设备驱动 PNX系列设备驱动
💻 C
📖 第 1 页 / 共 2 页
字号:
	HalObject*	Hal = (HalObject*)HalHandle;

#ifdef DEBUG
	if ( objectValidate ( Hal, HalFourCC ) != True )
	{
		return statusInvalidHandle;
	}
#endif

	Hal->Handler = Handler;
	Hal->Context = Context;
	return statusSuccess;
}

TMStatus	halRemoveHandler ( 
	UInt32	HalHandle )
{
	HalObject*	Hal = (HalObject*)HalHandle;

#ifdef DEBUG
	if ( objectValidate ( Hal, HalFourCC ) != True )
	{
		return statusInvalidHandle;
	}
#endif

	Hal->Handler = Null;
	return statusSuccess;
}

TMStatus	halDisableInterrupts ( 
	UInt32	HalHandle,
	UInt32* Saved )
{
	#ifdef DEBUG
	HalObject*	Hal = (HalObject*)HalHandle;
	if ( objectValidate ( Hal, HalFourCC ) != True )
	{
		return statusInvalidHandle;
	}
	#endif

	/* 
		as of now there is no provision to 
		pass a object / dsp node reference 
		to the hal functions 
	*/
	*Saved = intClearIEN ();
	return statusSuccess;
}

TMStatus	halRestoreInterrupts ( 
	UInt32	HalHandle,
	UInt32* Saved )
{
	#ifdef DEBUG
	HalObject*	Hal = (HalObject*)HalHandle;
	if ( objectValidate ( Hal, HalFourCC ) != True )
	{
		return statusInvalidHandle;
	}
	#endif

	intRestoreIEN ( *Saved );
	return statusSuccess;
}

TMStatus	halDisableIRQ ( 
	UInt32	HalHandle )
{
	HalObject*	Hal = (HalObject*)HalHandle;

	intInstanceSetup_t   Setup;

	#ifdef DEBUG
	if ( objectValidate ( Hal, HalFourCC ) != True )
	{
		return statusInvalidHandle;
	}
	#endif


	intGetInstanceSetup ( (intInterrupt_t)Hal->SelfInterrupt, &Setup );
	Setup.enabled = False;
	intInstanceSetup ( (intInterrupt_t)Hal->SelfInterrupt, &Setup );

	return statusSuccess;
}

TMStatus	halEnableIRQ ( 
	UInt32	HalHandle )
{
	HalObject*	Hal = (HalObject*)HalHandle;
	intInstanceSetup_t   Setup;

	#ifdef DEBUG
	if ( objectValidate ( Hal, HalFourCC ) != True )
	{
		return statusInvalidHandle;
	}
	#endif

	intGetInstanceSetup ( (intInterrupt_t)Hal->SelfInterrupt, &Setup );

	Setup.enabled = True;

	intInstanceSetup ( (intInterrupt_t)Hal->SelfInterrupt, &Setup );

	return statusSuccess;
}

TMStatus	halGenerateInterrupt ( 
	UInt32	HalHandle )
{
	HalObject*	Hal = (HalObject*)HalHandle;
	
	#ifdef DEBUG
	if ( objectValidate ( Hal, HalFourCC ) != True )
	{
		return statusInvalidHandle;
	}
	#endif

	halAccessEnable ( HalHandle );
/*    DP(("In halGenerateInterrupt")); */

	while ( 1 )
	{
		if ( halAccess32 ( HalHandle, 
			Hal->Control->HostInterruptSpinLock  ) == False )
		{
			Hal->Control->TargetInterruptSpinLock = 
				halAccess32 ( HalHandle, True  );

			if ( halAccess32 ( HalHandle, 
				Hal->Control->HostInterruptSpinLock  ) == True )
			{
				Hal->Control->TargetInterruptSpinLock = 
					halAccess32 ( HalHandle, False  );			
			}
			else
			{
				*(UInt32*)( Hal->MMIOBase + INT_CTL) = halAccess32 ( HalHandle,
					halAccess32 ( HalHandle, *(UInt32*)( Hal->MMIOBase + INT_CTL) ) |
					( ( 1 << Hal->PeerInterrupt ) |
					( 0x10 << Hal->PeerInterrupt ) ) );
/*                DP(("INT_CTL Addr = %x",Hal->MMIOBase + INT_CTL)); */

				Hal->Control->TargetInterruptSpinLock = 
					halAccess32 ( HalHandle, False  );
				break;
			}

		}
	}

	halAccessDisable ( HalHandle );


	return statusSuccess;
}

TMStatus	halAcknowledgeInterrupt (
	UInt32	HalHandle )
{
	#ifdef DEBUG
	HalObject*	Hal = (HalObject*)HalHandle;
	if ( objectValidate ( Hal, HalFourCC ) != True )
	{
		return statusInvalidHandle;
	}
	#endif
	
	/* NO IMPLEMENTATION FOR THIS PLATFORM */

	return statusSuccess;
}

TMStatus	halStartDSP (
	UInt32	HalHandle )
{
	#ifdef DEBUG
	HalObject*	Hal = (HalObject*)HalHandle;
	if ( objectValidate ( Hal, HalFourCC ) != True )
	{
		return statusInvalidHandle;
	}
	#endif

	/* NO IMPLEMENTATION FOR THIS PLATFORM */

	return statusSuccess;
}

TMStatus	halStopDSP (
	UInt32	HalHandle )
{
	#ifdef DEBUG
	HalObject*	Hal = (HalObject*)HalHandle;
	if ( objectValidate ( Hal, HalFourCC ) != True )
	{
		return statusInvalidHandle;
	}
	#endif

	/* NO IMPLEMENTATION FOR THIS PLATFORM */

	return statusSuccess;
}

TMStatus	halSetPeerVersion (
	UInt32	HalHandle, 
	UInt32	MajorVersion,
	UInt32	MinorVersion )
{
	HalObject*	Hal = (HalObject*)HalHandle;

	if ( objectValidate ( Hal, HalFourCC ) != True )
	{
		return statusInvalidHandle;
	}

	Hal->PeerMajorVersion = MajorVersion;
	Hal->PeerMinorVersion = MinorVersion;

	return statusSuccess;
}

TMStatus	halGetPeerVersion (
	UInt32	HalHandle,
	UInt32*	MajorVersionPtr,
	UInt32*	MinorVersionPtr )
{
	HalObject*	Hal = (HalObject*)HalHandle;

	if ( objectValidate ( Hal, HalFourCC ) != True )
	{
		return statusInvalidHandle;
	}

	*MajorVersionPtr = Hal->PeerMajorVersion;
	*MinorVersionPtr = Hal->PeerMinorVersion;

	return statusSuccess;
}
/* 
this is required since in a multiple TM1 system,
one of the TMs can act as a master and the others as slaves,
the master has to be able to install interrupt handlers for
each slave it is driving 

BEGINhalHardwareInterruptHandler(0)
#pragma	TCS_interruptible_handler
ENDhalHardwareInterruptHandler

BEGINhalHardwareInterruptHandler(1)
#pragma	TCS_interruptible_handler
ENDhalHardwareInterruptHandler

BEGINhalHardwareInterruptHandler(2)
#pragma	TCS_interruptible_handler
ENDhalHardwareInterruptHandler

BEGINhalHardwareInterruptHandler(3)
#pragma	TCS_interruptible_handler
ENDhalHardwareInterruptHandler

BEGINhalHardwareInterruptHandler(4)
#pragma	TCS_interruptible_handler
ENDhalHardwareInterruptHandler
*/

#pragma TCS_noinline = halAccess32

UInt32	halAccess32( 
	UInt32	HalHandle,
	UInt32 volatile Value )
{
	/* we don't validate the object for efficiency reasons */
	/* NO SWAPPING FOR THIS PLATFORM */
	return Value;
}

UInt16	halAccess16 ( 
	UInt32	HalHandle,
	UInt16 volatile Value )
{
	/* we don't validate the object for efficiency reasons */
	/* NO SWAPPING FOR THIS PLATFORM */
	return Value;
}

void	halAccessEnable ( 
	UInt32	HalHandle )
{
	HalObject*	Hal = (HalObject*)HalHandle;
	/* we don't validate the object for efficiency reasons */
	/* NO SWAPPING FOR THIS PLATFORM */
    /* disable the hole & enabble the PCI window - allow PCI loads and stores */
	/* BUGCHECK - we should disable interrupts here - for pSOS */
	if ( Hal->SpeculativeLoadFix )
	{

		Hal->MemoryAccessInterruptState = intClearIEN ( );

		*(UInt32*)(Hal->MMIOBase + DC_LOCK_CTL) = 
			/* read the value of DC_LOCK_CTL - retain all bits except bits 5 & 6 */
			( ( (*(UInt32*)(Hal->MMIOBase + DC_LOCK_CTL)) & (~constTMManDC_LOCK_CTL_MASK) ) | 
			/* or it with the new values of bits 5 & 6 */
			( constTMManDC_LOCK_CTL_MASK  & ( ( constTMManDC_LOCK_CTL_HEN ) << constTMManDC_LOCK_CTL_POSITION ) ) );
	}
	
}

void	halAccessDisable ( 
	UInt32	HalHandle )
{
	HalObject*	Hal = (HalObject*)HalHandle;
	/* we don't validate the object for efficiency reasons */

    /* disable the hole & the PCI window - block all speculative loads */
	/* BUGCHECK - we should restore interrupts here - for pSOS */

	if ( Hal->SpeculativeLoadFix )
	{
		*(UInt32*)(Hal->MMIOBase + DC_LOCK_CTL) = 
			/* read the value of DC_LOCK_CTL - retain all bits except bits 5 & 6 */
			( ( (*(UInt32*)(Hal->MMIOBase + DC_LOCK_CTL)) & (~constTMManDC_LOCK_CTL_MASK) ) | 
			/* or it with the new values of bits 5 & 6 */
			( constTMManDC_LOCK_CTL_MASK  & ( ( constTMManDC_LOCK_CTL_PDS ) << constTMManDC_LOCK_CTL_POSITION ) ) );

		intRestoreIEN ( Hal->MemoryAccessInterruptState );
	}
}

void	halCopyback( Pointer CacheBlock, UInt32 BlockCount  )
{
	COPYBACK( CacheBlock, 1  );
}


UInt32	halTranslateTargetPhysicalAddress ( 
	UInt32 HalHandle, 
	UInt32 PhysicalAddress )
{
	HalObject*	Hal = (HalObject*)HalHandle;

	return ( PhysicalAddress );
}

⌨️ 快捷键说明

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