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

📄 tmboard.c

📁 wince host 和 target PCI驱动程序
💻 C
📖 第 1 页 / 共 2 页
字号:
STATUS	boardDestroy ( PVOID pBoard )
{
	PTMBOARD_OBJECT	this = (PTMBOARD_OBJECT)pBoard;;

	/* destroy all the objects here */
	buffermDestroy ( this->pBufferMgr );
	taskmDestroy ( this->pTaskMgr );
	msgmDestroy ( this->pMsgMgr );
	chnlmDestroy ( this->pChnlMgr );
	ipcDestroy ( this->pIPC );
	halDestroy ( this->pHAL );
	shmemFree ( this->pShMem, this->pSharedData );
	shmemDestroy ( this->pShMem );

	this->Size = 0;

	if ( FlagGet ( this->Flags, TMBOARD_FLAG_DYNAMICOBJ ) )
	{	
		vxdFree ( this );
	}

	return TMOK;
}

STATUS	boardOpen ( PVOID Object )
{
	PTMBOARD_OBJECT	this = (PTMBOARD_OBJECT)Object;
	this->ReferenceCount++;
	return TMOK;
}


STATUS	boardClose ( PVOID Object )
{
	PTMBOARD_OBJECT	this = (PTMBOARD_OBJECT)Object;
	this->ReferenceCount--;
	return TMOK;
}

STATUS	boardImageLoad ( PVOID pBoard, DWORD PhysLoadAddr, DWORD Size,
	PVOID	pImageAddr, DWORD ArgC, PCHAR *ArgV )
{
	PTMBOARD_OBJECT	this = (PTMBOARD_OBJECT)pBoard;
	PBYTE	pArgVBase;
	PBYTE	*pArgVPtr;
	DWORD	Idx;

	/* copy the image into SDRAM */
	vxdMemCopy ( 
		pImageAddr,
		(PVOID)( this->SDRAMLinear + (PhysLoadAddr - this->Config.dwSDRAMBase) ),
		Size);

	/* set up the command line parameters in the board objects internal buffer */
	pArgVPtr = (PBYTE *)this->ArgumentBuffer;
	pArgVBase = &((PDWORD)this->ArgumentBuffer)[ArgC + 1]; /* skip 1 entry for NULL */

	/* copy the arguments and the pointers to the buffer */
	for ( Idx = 0; Idx < ArgC ; Idx ++ )
	{
		pArgVPtr[Idx] = pArgVBase;
		vxdStrCopy (  ArgV[Idx], pArgVBase );
		pArgVBase += (DWORD)vxdStrLen ( ArgV [Idx]);
	}

	pArgVPtr[Idx] = NULL;
	this->ArgC = ArgC;
	this->ArgV = this->ArgumentBuffer;

	return TMOK;
}

STATUS	boardImageRun ( PVOID pBoard, DWORD PhysStartAddr )
{
	PTMBOARD_OBJECT	this = (PTMBOARD_OBJECT)pBoard;
	TMMAN_DSP_CAPS	DSPCaps;
    DWORD   TargetMajorVersion, TargetMinorVersion;

	boardGetCaps ( this, &DSPCaps );
	this->pSharedData->CPUVersion = DSPCaps.dwCPUVersion;

	this->pSharedData->SDRAM = DSPCaps.SDRAM;
	this->pSharedData->MMIO = DSPCaps.MMIO;
	this->pSharedData->User = DSPCaps.User;

	this->pSharedData->HostVersion.dwMajor = verGetFileMajorVersion();

    halGetTargetVersion ( 
        this->pHAL, 
        &TargetMajorVersion, 
        &TargetMinorVersion );

	this->pSharedData->HostVersion.dwMinor =  TargetMinorVersion;
	this->pSharedData->HostVersion.dwBuild = verGetFileBuildVersion();

	this->pSharedData->TargetVersion.dwMajor = 0;
	this->pSharedData->TargetVersion.dwMinor = 0;
	this->pSharedData->TargetVersion.dwBuild = 0;

	ipcReset ( this->pIPC  );
	chnlmReset ( this->pChnlMgr );
	halDSPStart ( this->pHAL );
	return TMOK;
}

STATUS	boardImageStop ( PVOID pBoard )
{
	PTMBOARD_OBJECT	this = (PTMBOARD_OBJECT)pBoard;

	if ( halIsTMRunning ( this->pHAL ) )
	{
		/*	TRC970325
			commented out since it pisses off renga -
			this interferes with program running in batch mode.
		*/
		if ( ( this->pSharedData->TargetVersion.dwMajor ==  0 ) &&
			( this->pSharedData->TargetVersion.dwMinor == 0 ) )
		{
			if ( ((PINIT_OBJECT)(pDriverObject->pInitObj))->InteractiveMode )
			{
 				vxdErrorBox ( "TriMedia Manager : Win95 Kernel Mode Driver", 
					"WARNING : Program Execution may not have started on TriMedia : Click [OK] to Proceed" );
			}
			DP(0, "WARNING : Program Execution may not have started on TriMedia\n");
			goto boardImageStopExit;

		}
		/*
	
		if ( ( this->pSharedData->TargetVersion.dwMajor != verGetFileMajorVersion() ) ||
			( this->pSharedData->TargetVersion.dwMinor != verGetFileMinorVersion() ) )
		{

			if ( ((PINIT_OBJECT)(pDriverObject->pInitObj))->InteractiveMode )
			{
				vxdErrorBox ( "TriMedia Manager : Win95 Kernel Mode Driver", 
					"WARNING : Incompatible Version of TMMan may be running on TriMedia : Click [OK] to Proceed" );
			}
			DP(0,"WARNING : Incompatible Version of TMMan may be running on TriMedia\n" );
			goto boardImageStopExit;
		}
		*/
		
	}

boardImageStopExit :
	if ( ((PINIT_OBJECT)(pDriverObject->pInitObj))->dwHardReset )
	{
			boardReset ( this );
	}
	else
	{
		halDSPStop ( this->pHAL );
		ipcReset ( this->pIPC  );
		chnlmReset ( this->pChnlMgr );
	}
	return TMOK;
}

STATUS	boardReset ( PVOID pBoard )
{
	PTMBOARD_OBJECT	this = (PTMBOARD_OBJECT)pBoard;
	halDSPStop ( this->pHAL );
	ipcReset ( this->pIPC  );
	chnlmReset ( this->pChnlMgr );

	halDSPReset ( this->pHAL );

	// restore all the PCI registers that we had saved before.
	// we start with the third register since all the ones before
	// are read only.
	// and of course for obvious reasons we have to write to register 1
	// at the very end.
	//CACHE LINE SIZE & LATENCY TIMER
	pciWriteConfigDW ( this->Config.bBusNum, this->Config.bDevFuncNum,
		3*4, 	this->PCIRegisters[3] );
	//SDRAM BASE
	pciWriteConfigDW ( this->Config.bBusNum, this->Config.bDevFuncNum,
		4*4, 	this->PCIRegisters[4] );
	//MMIOBASE
	pciWriteConfigDW ( this->Config.bBusNum, this->Config.bDevFuncNum,
		5*4, 	this->PCIRegisters[5] );
	// INTERRUPT LINE
	pciWriteConfigDW ( this->Config.bBusNum, this->Config.bDevFuncNum,
		0xf*4, 	this->PCIRegisters[0xf] );
	// COMMAND & STATUS
	pciWriteConfigDW ( this->Config.bBusNum, this->Config.bDevFuncNum,
		1*4, 	this->PCIRegisters[1] );

	halRegisterInit ( this->pHAL, this->Config.dwSDRAMBase,
		(this->Config.dwSDRAMBase + this->Config.dwSDRAMLength),
		this->Config.dwMMIOBase );
	return TMOK;
}

STATUS	boardGetMiscInfo( PVOID pBoard, PVOID pInfo )
{
	PTMBOARD_OBJECT	this = (PTMBOARD_OBJECT)pBoard;
	PTMMAN_DSP_INFO pDSPInfo  = (PTMMAN_DSP_INFO)pInfo;

	pDSPInfo->ArgCount = this->ArgC;
	pDSPInfo->ArgVector = this->ArgV;
	pDSPInfo->TMMANSharedPhys = this->SharedDataPhys;
	pDSPInfo->pDBGSharedData = this->pDBGSharedData;
	pDSPInfo->Flags = this->SharedFlags;
	/* other stuff to be added here */
	return TMOK;
}

STATUS	boardSetMiscInfo( PVOID pBoard, PVOID pInfo )
{
	PTMBOARD_OBJECT	this = (PTMBOARD_OBJECT)pBoard;
	PTMMAN_DSP_INFO pDSPInfo  = (PTMMAN_DSP_INFO)pInfo;

	this->ArgC = pDSPInfo->ArgCount;
	this->ArgV = pDSPInfo->ArgVector;
	this->SharedDataPhys = pDSPInfo->TMMANSharedPhys;
	this->pDBGSharedData = pDSPInfo->pDBGSharedData;
	this->SharedFlags = pDSPInfo->Flags;
	/* other stuff to be added here */
	return TMOK;
}

STATUS	boardGetStatus( PVOID pBoard, PDWORD pdwStatus )
{
	PTMBOARD_OBJECT	this = (PTMBOARD_OBJECT)pBoard;

	if ( ! ipcGetInterruptState ( ((PTMBOARD_OBJECT)pBoard)->pIPC ) )
	{
		*pdwStatus	 = TMMAN_DSPSTATUS_INTERRUPT_NONFUNCTIONAL;
		return TMOK;
	}

	*pdwStatus = halIsTMRunning ( ((PTMBOARD_OBJECT)pBoard)->pHAL );
	/* other stuff to be added here */
	return TMOK;
}


/* GETFUNCTIONS */
PVOID	GetDevNodeObject ( PVOID pBoard )
{
	return ( ((PTMBOARD_OBJECT)pBoard)->Config.dwDevNode );
}

PVOID	GetHALObject ( PVOID pBoard )
{
	return ( ((PTMBOARD_OBJECT)pBoard)->pHAL );
}

PVOID	GetIPCObject ( PVOID pBoard )
{
	return ( ((PTMBOARD_OBJECT)pBoard)->pIPC );
}

PVOID	GetChnlMgrObject ( PVOID pBoard )
{
	return ( ((PTMBOARD_OBJECT)pBoard)->pChnlMgr );
}

PVOID	GetTaskMgrObject ( PVOID pBoard )
{
	return ( ((PTMBOARD_OBJECT)pBoard)->pTaskMgr );
}

PVOID	GetMsgMgrObject ( PVOID pBoard )
{
	return ( ((PTMBOARD_OBJECT)pBoard)->pMsgMgr );
}

PVOID	GetShMemObject ( PVOID pBoard )
{
	return ( ((PTMBOARD_OBJECT)pBoard)->pShMem );
}
PVOID	GetBufferMgrObject ( PVOID pBoard )
{
	return ( ((PTMBOARD_OBJECT)pBoard)->pBufferMgr );
}



/*
PVOID	GetStrmMgrObject ( PVOID )
{
}
PVOID	GetMemMgrObject ( PVOID )
{
}
PVOID	GetSBufMgrObject ( PVOID )
{
}
*/

⌨️ 快捷键说明

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