vxmainc.c

来自「wince host 和 target PCI驱动程序」· C语言 代码 · 共 582 行 · 第 1/2 页

C
582
字号

		Size = sizeof ( DWORD);
		_RegQueryValueEx ( pDriverObject->RegistryHandle, 
			"HostDebugType", 
			NULL, NULL,
			&((PINIT_OBJECT)(pDriverObject->pInitObj))->dwDBGType, 
			&Size);

		Size = sizeof ( DWORD);
		_RegQueryValueEx ( pDriverObject->RegistryHandle, 
			"TargetDebugLevel", 
			NULL, NULL,
			&((PINIT_OBJECT)(pDriverObject->pInitObj))->dwTargetDBGLevel, 
			&Size);

		Size = sizeof ( DWORD);
		_RegQueryValueEx ( pDriverObject->RegistryHandle, 
			"PrinterPort", 
			NULL, NULL,
			&((PINIT_OBJECT)(pDriverObject->pInitObj))->dwPrinterPort, 
			&Size);

		Size = sizeof ( DWORD);
		_RegQueryValueEx ( pDriverObject->RegistryHandle, 
			"PrinterDongle", 
			NULL, NULL,
			&((PINIT_OBJECT)(pDriverObject->pInitObj))->dwPrinterDongle, 
			&Size);

		Size = sizeof ( DWORD);
		_RegQueryValueEx ( pDriverObject->RegistryHandle, 
			"HardReset", 
			NULL, NULL,
			&((PINIT_OBJECT)(pDriverObject->pInitObj))->dwHardReset, 
			&Size);

		Size = sizeof ( DWORD);
		_RegQueryValueEx ( pDriverObject->RegistryHandle, 
			"InteractiveMode", 
			NULL, NULL,
			&((PINIT_OBJECT)(pDriverObject->pInitObj))->InteractiveMode, 
			&Size);

		Size = 256;
		_RegQueryValueEx ( pDriverObject->RegistryHandle, 
			"INIPath", 
			NULL, NULL,
			&((PINIT_OBJECT)(pDriverObject->pInitObj))->szIniPath, 
			&Size);

		Size = sizeof ( DWORD);
		_RegQueryValueEx ( pDriverObject->RegistryHandle, 
			"DisablePlugAndPlay", 
			NULL, NULL,
			&((PINIT_OBJECT)(pDriverObject->pInitObj))->dwDisablePnP, 
			&Size);

		Size = sizeof ( DWORD);
		_RegQueryValueEx ( pDriverObject->RegistryHandle, 
			"BufferMaxCount", 
			NULL, NULL,
			&((PINIT_OBJECT)(pDriverObject->pInitObj))->dwBufferMaxCount, 
			&Size);

	}

	dbgInit ();

	if ( ERROR_SUCCESS != RegResult )
	{
		DP(0,"TM:vxdCommonInit:WARNING:RegOpenKey[%s]:FAIL[%x]\n", 
					"SOFTWARE\\PhilipsSemiconductors\\TriMedia\\TMMan", RegResult );

	}

	DP(11,"TM:vxdCommonDeviceInit:UserBufferSize[%x]\n", 
		((PINIT_OBJECT)(pDriverObject->pInitObj))->dwUserBufferSize );

	DP(11,"TM:vxdCommonDeviceInit:TotalBufferSize[%x]\n", 
		((PINIT_OBJECT)(pDriverObject->pInitObj))->dwTotalBufferSize );

	DP(11,"TM:vxdCommonDeviceInit:DisableHal[%x]\n", 
		((PINIT_OBJECT)(pDriverObject->pInitObj))->dwDisableHal );

	DP(11,"TM:vxdCommonDeviceInit:SdramSize[%x]\n", 
		((PINIT_OBJECT)(pDriverObject->pInitObj))->dwSDRAMSize );

	DP(11,"TM:vxdCommonDeviceInit:FriendlyName[%s]\n", 
		((PINIT_OBJECT)(pDriverObject->pInitObj))->szFriendlyName );

	DP(11,"TM:vxdCommonDeviceInit:HostDebugLevel[%x]\n", 
		((PINIT_OBJECT)(pDriverObject->pInitObj))->dwDBGLevelBitmap );

	DP(11,"TM:vxdCommonDeviceInit:HostDebugType[%x]\n", 
		((PINIT_OBJECT)(pDriverObject->pInitObj))->dwDBGType );

	DP(11,"TM:vxdCommonDeviceInit:TargetDebugLevel[%x]\n", 
		((PINIT_OBJECT)(pDriverObject->pInitObj))->dwTargetDBGLevel );

	DP(11,"TM:vxdCommonDeviceInit:PrinterPort[%x]\n", 
		((PINIT_OBJECT)(pDriverObject->pInitObj))->dwPrinterPort );

	DP(11,"TM:vxdCommonDeviceInit:PrinterDongle[%x]\n", 
		((PINIT_OBJECT)(pDriverObject->pInitObj))->dwPrinterDongle );

	DP(11,"TM:vxdCommonDeviceInit:HardReset[%x]\n", 
		((PINIT_OBJECT)(pDriverObject->pInitObj))->dwHardReset );

	DP(11,"TM:vxdCommonDeviceInit:InteractiveMode[%x]\n", 
		((PINIT_OBJECT)(pDriverObject->pInitObj))->InteractiveMode );

	DP(11,"TM:vxdCommonDeviceInit:DisablePlugAndPlay[%x]\n", 
		((PINIT_OBJECT)(pDriverObject->pInitObj))->dwDisablePnP );

	DP(11,"TM:vxdCommonDeviceInit:BufferMaxCount[%x]\n", 
		((PINIT_OBJECT)(pDriverObject->pInitObj))->dwBufferMaxCount );

	DP(11,"TM:vxdCommonDeviceInit:INIPath[%s]\n", 
		((PINIT_OBJECT)(pDriverObject->pInitObj))->szIniPath );

	for ( BoardIdx = 0 ; 
		BoardIdx < ((PINIT_OBJECT)(pDriverObject->pInitObj))->dwMaximumBoards ; 
		BoardIdx++ )
	{
		pDriverObject->pDeviceList[BoardIdx] = NULL;
	}


	DP( 0, "TM:vtmman:Version[%d.%d.%d]\n",
		verGetFileMajorVersion(),
		verGetFileMinorVersion(),
		verGetFileBuildVersion() );


	// check if we are being run on a PCI system
	if ( ( pnpPCICheck () ) != TRUE )
	{
		DP(0, "TM:vxdCommonDevicveInit:pnpPCICheck:FAIL\n");
		return FALSE;
	}

	// create the client manager object
	pDriverObject->pClientManager = NULL;
	if ( clntmCreate ( &pDriverObject->pClientManager, pDriverObject ) != TMOK )
	{
		DP(0, "TM:vxdCommonDevicveInit:clntmCreate:FAIL\n");
		return FALSE;
	}




/*
	// get the configuration for all the boards in the system.
	for ( BoardIdx = 0 ; 
		BoardIdx < ((PINIT_OBJECT)(pDriverObject->pInitObj))->dwMaximumBoards ; 
		BoardIdx++ )
	{
		DEVNODE		DevNode;

			//&((PTMBOARD_OBJECT)VxDObject.pBoardList)[VxDObject.wNumberOfCards];
		// TBD : change DRIVEROBJECT to have only pointers ( link list )  of
		// DEVICEOBJECTS, other wise tmdevice.h ( tmboard.h ) will have to 
		// be included in this file also.

		// note that all these calls should be changed to call CoCreateInstance
		// with the GUID of these objects:TBD
		if ( ( Status = pnpDevNodeGet  ( TMPNP_PCI_VENDOR_ID,
			TMPNP_PCI_DEVICE_ID, BoardIdx, &DevNode ) ) != TMOK )
			break;

		// This function internally calls
		// boardCreate
		// vxdAddDevice
		if ( pnpOnConfigStart ( DevNode ) != CR_SUCCESS )
		{
			DP(0,"TM:vxdCommonDevicveInit:pnpOnConfigStart:Dev[%x]:FAIL\n",
				pDriverObject->wDeviceCount  );
			break;
		}
	}
*/
	if ( ((PINIT_OBJECT)(pDriverObject->pInitObj))->dwDisablePnP )
	{
		pnpFindPCIDevices ( TMPNP_PCI_VENDOR_ID, TMPNP_PCI_DEVICE_ID );
	}
/*
	// if we haven't found atleast one board to run on, then unload
	if ( pDriverObject->wDeviceCount  == 0 )
	{
		if ( ((PINIT_OBJECT)(pDriverObject->pInitObj))->InteractiveMode )
		{
			vxdErrorBox ( "TriMedia Manager : Win95 Kernel Mode Driver", 
				"ERROR : TriMedia Device NOT Found : Click [OK] to Abort" );
			return FALSE;
		}
	}
*/


	return TRUE;

}

DWORD	vxdGetDeviceNumber ( PVOID pDevice )
{
	WORD	BoardIdx;
	for ( BoardIdx = 0 ; 
		BoardIdx < ((PINIT_OBJECT)(pDriverObject->pInitObj))->dwMaximumBoards ; 
		BoardIdx++ )
	{
		if ( pDriverObject->pDeviceList[BoardIdx] == pDevice )
		{
			return BoardIdx;
		}

	}
	return TMMAN_DEFAULT;
}
/*
PVOID	vxdGetDeviceFromIRQ ( DWORD dwIRQHandle )
{
		return pDriverObject->pDeviceList[0]; // HARDCODED 
}
*/

PVOID	vxdGetDeviceFromDevNode ( DWORD DevNode )
{
	WORD	BoardIdx;

	for ( BoardIdx = 0 ; 
		BoardIdx < ((PINIT_OBJECT)(pDriverObject->pInitObj))->dwMaximumBoards ; 
		BoardIdx++ )
	{
		if ( GetDevNodeObject ( pDriverObject->pDeviceList[BoardIdx] ) == DevNode )
		{
			return pDriverObject->pDeviceList[BoardIdx];
		}
	}
}

/*
PVOID	vxdGetDeviceDefault ( VOID )
{
		return pDriverObject->pDeviceList[0]; // HARDCODED 
}
*/

BOOL	vxdAddDevice ( PVOID pDevice )
{
	WORD	BoardIdx;
	if ( pDriverObject->wDeviceCount >= MAX_BOARDS )
		return FALSE;

	for ( BoardIdx = 0 ; 
		BoardIdx < ((PINIT_OBJECT)(pDriverObject->pInitObj))->dwMaximumBoards ; 
		BoardIdx++ )
	{
		if ( pDriverObject->pDeviceList[BoardIdx] == NULL )
		{
			pDriverObject->pDeviceList[BoardIdx] = pDevice;
			pDriverObject->wDeviceCount++;
			return TRUE;
		}

	}
	return FALSE;
}

BOOL	vxdRemoveDevice ( PVOID pDevice )
{
  	WORD	BoardIdx;

	if ( pDriverObject->wDeviceCount == 0 )
		return FALSE;

	for ( BoardIdx = 0 ; 
		BoardIdx < ((PINIT_OBJECT)(pDriverObject->pInitObj))->dwMaximumBoards ; 
		BoardIdx++ )
	{
		if ( pDriverObject->pDeviceList[BoardIdx] == pDevice )
		{
			pDriverObject->pDeviceList[BoardIdx] = NULL;
			pDriverObject->wDeviceCount--;
			return TRUE;
		}

	}
	return FALSE;
}

⌨️ 快捷键说明

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