📄 vxmainc.c
字号:
/*----------------------------------------------------------------------------
COPYRIGHT (c) 1995 by Philips Semiconductors
THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED AND COPIED IN
ACCORDANCE WITH THE TERMS AND CONDITIONS OF SUCH A LICENSE AND WITH THE
INCLUSION OF THE THIS COPY RIGHT NOTICE. THIS SOFTWARE OR ANY OTHER COPIES
OF THIS SOFTWARE MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER
PERSON. THE OWNERSHIP AND TITLE OF THIS SOFTWARE IS NOT TRANSFERRED.
THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT ANY PRIOR NOTICE
AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY Philips Semiconductor.
PHILIPS ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF THIS SOFTWARE
ON PLATFORMS OTHER THAN THE ONE ON WHICH THIS SOFTWARE IS FURNISHED.
----------------------------------------------------------------------------*/
/*
HISTORY
#define TR Tilakraj Roy
950919 TR Created ).
960212 TR Modified for TriMedia ).
960406 TR changed from existing vtmctc sources
ABSTRACT
Dynamic Device Driver.
Hardcoded PCI ID.
Can load upto 4 PCI TriMedia cards.
*/
/*----------------------------------------------------------------------------
SYSTEM INCLUDE FILES
----------------------------------------------------------------------------*/
#define WANTVXDWRAPS
#include <basedef.h>
#include <vmm.h>
#include <vmmreg.h>
#include <vxdwraps.h>
#include <vpicd.h>
#include <configmg.h>
#include <vwin32.h>
/*----------------------------------------------------------------------------
DRIVER SPECIFIC INCLUDE FILES
----------------------------------------------------------------------------*/
#include "vxstd.h"
#include "vxwin.h"
#include "vxdbg.h"
#include "tmwincom.h"
#include "tmman32.h"
#include "tmshare.h"
#include "tmpnp.h"
#include "verinfo.h"
#define MAX_BOARDS 10
/*----------------------------------------------------------------------------
GLOBAL DATA STRUCTURES INSTANCIATION
----------------------------------------------------------------------------*/
#pragma VxD_LOCKED_CODE_SEG
#pragma VxD_LOCKED_DATA_SEG
#define VTMMAN_DEVICE_ID 0x1234 // have to register this with MSFT
PVOID BoardObj[MAX_BOARDS];
// the DEVICE / DRIVER extension objects
// fields of thisobject have to be partitioned in to driver and device specific
// attributes.
INIT_OBJECT InitObj = {
4 * 1024, // UserBufferSize
64 * 1024, // TotalBufferSize
MAX_BOARDS, // BoardCount
0, // DisableHal
8 * 1024 * 1024, // SdramSize
"TMMan", // FriendlyName
0x00000001, // HostDebugLevel
0x0, // HostDebugType
0x00000001, // TargetDebugLevel
0x378, // PrinterPort
1, // PrinterDongle
0, // HardReset
1, // InteractiveMode
1, // DisablePlugAndPlay
0x60, // BufferMaxCount
"." // INIPath
};
// rename this to driver object.
DRIVEROBJECT DriverObject = {
4, // Windows Version
0, // VxD Version
0, // Static Loading Count
0, // Dynamic Loading Count
0, // Device CB Offset in VM struct
"VTMMAN", // name of the vxd
NULL, // client manager object created by clntmCreate
NULL, // TMLDR Loader object created by loaderCreate
0, // Number Of Cards installed.
BoardObj, // this should be created by device manager
&InitObj, // pointer to the global init object
0 // handle to the registry for this component (TMMan)
};
PDRIVEROBJECT pDriverObject = &DriverObject;
/*----------------------------------------------------------------------------
IMPORTED FUNCTIONS
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
FUNCTION PROTOTYPES
----------------------------------------------------------------------------*/
BOOL vxdInitializeDynamicDeviceC( VOID );
BOOL vxdExitDynamicDeviceC(VOID);
BOOL vxdCommonDeviceInit ( VOID );
BOOL pnpFindPCIDevices ( IN USHORT wVendor, IN USHORT wDevice );
/*----------------------------------------------------------------------------
FUNCTION DEFINITIONS
----------------------------------------------------------------------------*/
//----------------------------------------------------------------------------
// PAGEABLE CODE
//----------------------------------------------------------------------------
//#pragma VxD_PAGEABLE_CODE_SEG
//#pragma VxD_PAGEABLE_DATA_SEG
/*-----------------------------------------------------------------------------
FUNC vxdInitializeDynamicDeviceC - Init Code - Win40 only
ENTRY
Nothing
EXIT
SUCCESS - STATUS_SUCCESS
FAIL - STATUS_ERROR
ABOUT
This function is the Dynamic Loading entry point for the VxD. It is
called by the assembly wrapper VxdInitializeDynamicDeviceA. I just
checks for multiple loadings and does the VxD specific Initialization.
-----------------------------------------------------------------------------*/
BOOL vxdInitializeDynamicDeviceC( VOID )
{
if( pDriverObject->wStaticLoaded || pDriverObject->wDynamicLoaded )
{
// we are loaded already we are being loaded again.
return FALSE;
}
// Remember that we are loaded Dynamically
pDriverObject->wDynamicLoaded ++;
return ( vxdCommonDeviceInit ( ) );
return TRUE;//abc
}
/*-----------------------------------------------------------------------------
FUNC vxdExitDynamicDeviceC - Rare Code - Win40 only
ENTRY
Nothing
EXIT
SUCCESS - STATUS_SUCCESS
FAIL - STATUS_ERROR
ABOUT
This function is called by the system, when the VxD has to be unloaded.
This function has to free up all the VxD specific resources.
-----------------------------------------------------------------------------*/
//#pragma VXD_RARE_CODE
BOOL vxdExitDynamicDeviceC(VOID)
{
DWORD dwBoardIdx;
DEVNODE DevNode;
STATUS Status;
if ( clntmDestroy ( pDriverObject->pClientManager ) != TMOK )
{
DP(0, "TM:vxdExitDynamicDeviceC:clntmDestroy:FAIL\n");
return FALSE;
}
if ( ((PINIT_OBJECT)(pDriverObject->pInitObj))->dwDisablePnP )
{
for ( dwBoardIdx = 0 ;
dwBoardIdx < ((PINIT_OBJECT)(pDriverObject->pInitObj))->dwMaximumBoards ;
dwBoardIdx++ )
{
if ( ! pDriverObject->pDeviceList[dwBoardIdx] )
continue;
/*
if ( ( Status = pnpDevNodeGet ( TMPNP_PCI_VENDOR_ID,
TMPNP_PCI_DEVICE_ID, dwBoardIdx, &DevNode ) ) != TMOK )
break;
*/
pnpOnConfigRemove ( GetDevNodeObject ( pDriverObject->pDeviceList[dwBoardIdx] ) );
}
return TRUE;
}
if ( pDriverObject->RegistryHandle != 0 )
{
_RegCloseKey ( pDriverObject->RegistryHandle );
}
}
BOOL vxdInitCriticalStaticDeviceC( VOID )
{
return TRUE;
}
BOOL vxdInitStaticDeviceC ( VOID )
{
if ( pDriverObject->wStaticLoaded || pDriverObject->wDynamicLoaded )
{
// already laoded - being loaded again.
return TRUE;
}
// everything successful so increment the load count
pDriverObject->wStaticLoaded++;
return ( vxdCommonDeviceInit ( ) );
}
BOOL vxdCommonDeviceInit ( VOID )
{
WORD BoardIdx;
STATUS Status;
DWORD RegResult;
DWORD Size;
/* initialize the registry here */
// initialize the debugging subsystem - Global Data structure
RegResult = _RegOpenKey (
HKEY_LOCAL_MACHINE,
"SOFTWARE\\PhilipsSemiconductors\\TriMedia\\TMMan",
&pDriverObject->RegistryHandle );
if ( ERROR_SUCCESS == RegResult )
{
Size = sizeof ( DWORD);
_RegQueryValueEx ( pDriverObject->RegistryHandle,
"UserBufferSize",
NULL, NULL,
&((PINIT_OBJECT)(pDriverObject->pInitObj))->dwUserBufferSize,
&Size);
Size = sizeof ( DWORD);
_RegQueryValueEx ( pDriverObject->RegistryHandle,
"TotalBufferSize",
NULL, NULL,
&((PINIT_OBJECT)(pDriverObject->pInitObj))->dwTotalBufferSize,
&Size);
Size = sizeof ( DWORD);
_RegQueryValueEx ( pDriverObject->RegistryHandle,
"DisableHal",
NULL, NULL,
&((PINIT_OBJECT)(pDriverObject->pInitObj))->dwDisableHal,
&Size);
Size = sizeof ( DWORD);
_RegQueryValueEx ( pDriverObject->RegistryHandle,
"SdramSize",
NULL, NULL,
&((PINIT_OBJECT)(pDriverObject->pInitObj))->dwSDRAMSize,
&Size);
Size = 80;
_RegQueryValueEx ( pDriverObject->RegistryHandle,
"FriendlyName",
NULL, NULL,
&((PINIT_OBJECT)(pDriverObject->pInitObj))->szFriendlyName,
&Size);
Size = sizeof ( DWORD);
_RegQueryValueEx ( pDriverObject->RegistryHandle,
"HostDebugLevel",
NULL, NULL,
&((PINIT_OBJECT)(pDriverObject->pInitObj))->dwDBGLevelBitmap,
&Size);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -