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

📄 platform.h

📁 PNX系列设备驱动 PNX系列设备驱动
💻 H
字号:
/*---------------------------------------------------------------------------- 
COPYRIGHT (c) 1998 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
	970703	Tilakraj Roy	Created
	010828	Wim de Haan		Moved "HalObject" struct typedef from "tmhal.c"
							to here, because it is needed by "osal.c"
							
*/

/*----------------------------------------------------------------------------
          SYSTEM INCLUDE FILES
----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------
          DRIVER SPECIFIC INCLUDE FILES
----------------------------------------------------------------------------*/
#include "tmtypes.h"
#include "tmmanapi.h"

#define		constTMMANPCIRegisters			0x10

// required by the hal for bit settings
#define constTMManBIU_CTL_SE    0x0001
#define constTMManBIU_CTL_BO    0x0002
#define constTMManBIU_CTL_IE    0x0100
#define constTMManBIU_CTL_HE    0x0200
#define constTMManBIU_CTL_CR    0x0400
#define constTMManBIU_CTL_SR    0x0800


#define	constTMManDC_LOCK_CTL_MASK	0x00000060
#define	constTMManDC_LOCK_CTL_POSITION	5	/* LEFT SHIFT POSITIONS */

#define	constTMManDC_LOCK_CTL_HEN	0x0	/* HOLE ENABLE */
#define	constTMManDC_LOCK_CTL_HDS	0x1	/* HOLE DISABLE */
#define	constTMManDC_LOCK_CTL_PDS	0x2 /* PCI DSIABLE */
#define	constTMManDC_LOCK_CTL_RES	0x3	/* RESERVED */

//#define	constTMManHostTraceBufferSize	2048

#define	constTMMan_DEVICE_STATE_NEVERSTARTED	0
#define	constTMMan_DEVICE_STATE_STARTED			1
#define	constTMMan_DEVICE_STATE_REMOVEPENDING	2
#define	constTMMan_DEVICE_STATE_REMOVED			3
#define	constTMMan_DEVICE_STATE_STOPPENDING		4
#define	constTMMan_DEVICE_STATE_STOPPED			5
#define	constTMMan_DEVICE_STATE_SURPRISEREMOVED	6


typedef struct tagDebugObject
{
    UInt32  DBGLevelBitmap;
    UInt32  DBGType;
	UInt8	DBGBuffer[constTMManStringLength];
	UInt8	TraceBufferData[constTMManHostTraceBufferSize]; /*HARDCODED */
	UInt8*	TraceBuffer;
	UInt32	TracePosition;
	UInt32	TraceLength;
	Bool	TraceWrapped;
}	DebugObject;


typedef struct tagClientDeviceObject
{
	PVOID			Device;
	PUCHAR			SDRAMAddrUser;
	PUCHAR			MMIOAddrUser;
	PUCHAR			MemoryAddrUser; // pagelocked shared memory 

	UInt32			SDRAMHandleUser;
	UInt32			MMIOHandleUser;
	UInt32			MemoryHandleUser; 

}	ClientDeviceObject;

typedef struct tagPageLockBufferDescription
{
	PIRP		IORequestPacket;
}	PageLockBufferDescription;

typedef struct tagClientObject
{
    PEPROCESS			Process;
	ULONG				DeviceCount;
	ClientDeviceObject	Device[1];
}	ClientObject;

typedef struct  tagGlobalObject
{
	ULONG			MaximumDevices;
	ULONG			DeviceCount;
    PVOID			DeviceList[constTMMANMaximumDeviceCount];

	ULONG			CurrentDevice;

	ULONG			MaximumClients;
	ULONG			ClientCount;
    PVOID			ClientList[constTMMANMaximumClientCount];

    PDRIVER_OBJECT	DriverObject;
    UNICODE_STRING  DriverRegistryPath;
	PDEVICE_OBJECT	DeviceObject;

	DebugObject		Debug;

    ULONG			BitFlags;

    HANDLE			RegistryHandle;

	ULONG			XlatedAddress;

	/* settings read from the registry */
	ULONG			TargetTraceBufferSize;
	ULONG			TargetTraceLeveBitmap;
	ULONG			TargetTraceType;
	ULONG			MemorySize;
	ULONG			MailboxCount;
	ULONG			ChannelCount;
	ULONG			VIntrCount;
	ULONG			MessageCount;
	ULONG			EventCount;
	ULONG			StreamCount;
	ULONG			NameSpaceCount;
	ULONG			MemoryCount;
	ULONG			SGBufferCount;
	ULONG			SpeculativeLoadFix;
	ULONG			PCIInterruptNumber;
	ULONG			MMIOInterruptNumber;
	ULONG			MapSDRAM;

}   GlobalObject;

typedef struct taghalParameters
{
    ULONG				TMDeviceVendorID;
	ULONG				TMSubsystemID;
	ULONG				TMClassRevisionID;

    ULONG				BridgeDeviceVendorID;
    ULONG				BridgeSubsystemID;
	ULONG				BridgeClassRevisionID;


    ULONG				BusNumber;
    PCI_SLOT_NUMBER		SlotNumber;

	ULONG				DSPNumber;

    ULONG				PCIIrq;
    ULONG				TMIrq;

    KIRQL				InterruptLevel;
    ULONG		        InterruptVector;
    KAFFINITY		    InterruptAffinity;
	KINTERRUPT_MODE		InterruptMode;


    PHYSICAL_ADDRESS    MMIOAddrPhysical;
    ULONG               MMIOLength;

    PHYSICAL_ADDRESS    SDRAMAddrPhysical;
    ULONG               SDRAMLength;

	PDRIVER_OBJECT		DriverObject;
	PDEVICE_OBJECT		DeviceObject;

	PDEVICE_OBJECT		PhysicalDeviceObject;
	PDEVICE_OBJECT		FunctionalDeviceObject;
	PDEVICE_OBJECT		StackDeviceObject;

	Pointer				SharedData;

	ULONG				SpeculativeLoadFix;

	ULONG				SystemBaseAddress;
	ULONG				MMIOBaseAddress;
	ULONG				SDRAMBaseAddress;

	ULONG				PCIRegisters[constTMMANPCIRegisters];
}	halParameters;

typedef struct tagHalObject
{
	GenericObject		Object;
    ULONG				TMDeviceVendorID;
	ULONG				TMSubsystemID;
	ULONG				TMClassRevisionID;

    ULONG				BridgeDeviceVendorID;
    ULONG				BridgeSubsystemID;
	ULONG				BridgeClassRevisionID;

	ULONG				SelfInterrupt;	// from Target -> Host 
	ULONG				PeerInterrupt;	// Host -> Target 
	HalInterruptHandler	Handler;
	Pointer				Context;

	HalControl*			Control;
	/*	true -  target processor is running in different indianess */
	/*	false -  target processor is running in different indianess */
	Bool				Swapping;	

	ULONG				PeerMajorVersion;
	ULONG				PeerMinorVersion;

	/* BEGIN Platform Specific */

    ULONG				BusNumber;
    PCI_SLOT_NUMBER		SlotNumber;

	PHYSICAL_ADDRESS    MMIOAddrPhysicalBridge;
    PHYSICAL_ADDRESS    MMIOAddrPhysical;
    ULONG               MMIOLength;
	PUCHAR				MMIOAddrKernel;

	PHYSICAL_ADDRESS    SDRAMAddrPhysicalBridge;
    PHYSICAL_ADDRESS    SDRAMAddrPhysical;
    ULONG               SDRAMLength;
	PUCHAR				SDRAMAddrKernel;
	

	ULONG				MappedInterruptVector;

	BOOLEAN				FirstTimeReset;

	PKINTERRUPT			InterruptObject;

	ULONG				DSPNumber;

	PDEVICE_OBJECT		PhysicalDeviceObject;
	PDEVICE_OBJECT		FunctionalDeviceObject;
	PDEVICE_OBJECT		StackDeviceObject;

	PDEVICE_OBJECT		DeviceObject;
	PDRIVER_OBJECT		DriverObject;
	PADAPTER_OBJECT		AdapterObject;

	ULONG				NumberOfMapRegisters;
	ULONG				SpeculativeLoadFix;

	ULONG				SDRAMMapCount;
	ULONG				Offset;

	ULONG				PCIRegisters[constTMMANPCIRegisters];

	// performance counters

	ULONGLONG	DPCRequested;
	ULONGLONG	LastInterrupt;

	// worst case numbers
	ULONG	DPCLatency;
	ULONG	DPCDuration;
	ULONG	InterruptInterval;


}	HalObject;

typedef struct tagTMManDeviceObject
{
	/* generic part */
	// user set Flags - for storing device specific information
	UInt32	Flags;

	// handle to the CRT Object
	// just stored here by tmman32 for later retrieval
	// not interpreted in kernel mode.
	UInt32	CRunTimeHandle;

	// current state of the DSP
	// LOADED, RESET, RUNNING, DEAD, DEFUNCT
	UInt32	Status; 

	UInt32	DSPNumber;

	UInt8*	SharedMapped;

	TMManSharedStruct*		SharedData;

	// handle to all the component objects
	UInt32	HalHandle;
	UInt32	ChannelManagerHandle;
	UInt32	VIntrManagerHandle;
	UInt32	EventManagerHandle;
	UInt32	MessageManagerHandle;
	UInt32	MemoryManagerHandle;
	UInt32	SGBufferManagerHandle;
	UInt32	NameSpaceManagerHandle;

	Pointer	HalSharedData;
	Pointer	MemorySharedData;
	Pointer	NameSpaceSharedData;
	UInt32	ChannelSharedData;
	UInt32	VIntrSharedData;
	UInt32	EventSharedData;
	
	UInt32	SGBufferSharedData;

	UInt32	SharedDataHandle;

	

	Pointer	MemoryBlock;
	UInt32	MemoryBlockSize;


	// physical addresses needed by the loader for relocation
	PHYSICAL_ADDRESS	HalSharedAddress;
	PHYSICAL_ADDRESS	EventSharedAddress;
	PHYSICAL_ADDRESS	ChannelSharedAddress;
	PHYSICAL_ADDRESS	VIntrSharedAddress;
	PHYSICAL_ADDRESS	DebugSharedAddress;
	PHYSICAL_ADDRESS	MemorySharedAddress;
	PHYSICAL_ADDRESS	MemoryBlockAddress;
	PHYSICAL_ADDRESS	NameSpaceSharedAddress;
	PHYSICAL_ADDRESS	SGBufferSharedAddress;
	PHYSICAL_ADDRESS	TMManSharedAddress;

	// hardware initialization parameters
	halParameters	HalParameters;

    HANDLE		RegistryHandle;

	KEVENT		RemoveEvent;
	KEVENT		StopEvent;
	Bool		Stopped;
	Bool		Removed;

	UInt32		References;

	PDEVICE_OBJECT		FunctionalDeviceObject;
	PDEVICE_OBJECT		PhysicalDeviceObject;
	PDEVICE_OBJECT		StackDeviceObject;
	ULONG				DeviceState;

}	TMManDeviceObject;

extern GlobalObject *TMManGlobal;

BOOLEAN	pnpFindPCIDevices ( USHORT wVendor, USHORT wDevice );

BOOLEAN	halMapSDRAM ( UInt32 HalHandle );
BOOLEAN	halUnmapSDRAM ( UInt32 HalHandle );

BOOLEAN	halAllocateBusMasterChannel ( 
	UInt32 HalHandle,
	Pointer Context,
	PDRIVER_CONTROL ExecutionRoutine );

BOOLEAN	halFreeBusMasterChannel ( 
	UInt32 HalHandle, 
	Pointer MapRegisetBase, 
	UInt32 MapRegiserCount );

Pointer	sectionMapPhysicalAddress ( 
	UInt32 Address, 
	UInt32 Length,
	UInt32 *SectionHandlePointer );

void	sectionUnmapPhysicalAddress ( 
	Pointer UserModeVirtualAddress, 
	UInt32 SectionHandle );


/* WDM plug and play functions */

NTSTATUS
tmmanPnp(
	PDEVICE_OBJECT DeviceObject, 
	PIRP Irp );

NTSTATUS
tmmanPower(
	PDEVICE_OBJECT DeviceObject, 
	PIRP Irp );

NTSTATUS
tmmanPnpAddDevice(
	PDRIVER_OBJECT DriverObject,
	PDEVICE_OBJECT PhysicalDeviceObject );

NTSTATUS
tmmanPnpRemoveDevice(
	PDEVICE_OBJECT FunctionalDeviceObject );

NTSTATUS
tmmanPnpStartDevice(
	PDEVICE_OBJECT FunctionalDeviceObject,
	PIRP Irp );

NTSTATUS
tmmanPnpStopDevice(
	PDEVICE_OBJECT FunctionalDeviceObject );

NTSTATUS	
tmmanDeviceCanRemove ( 
	TMManDeviceObject* TMManDevice );

VOID	
tmmanDeviceWaitForRemove ( 
	TMManDeviceObject* TMManDevice );

VOID	
tmmanDeviceWaitForStop ( 
	TMManDeviceObject* TMManDevice );

NTSTATUS
tmmanPower(
	PDEVICE_OBJECT DeviceObject, 
	PIRP Irp );


//someone forgot to include these in WDM.H 
//they are however exported by ntkern.vxd
typedef enum _BUS_DATA_TYPE {
    ConfigurationSpaceUndefined = -1,
    Cmos,
    EisaConfiguration,
    Pos,
    CbusConfiguration,
    PCIConfiguration,
    VMEConfiguration,
    NuBusConfiguration,
    PCMCIAConfiguration,
    MPIConfiguration,
    MPSAConfiguration,
    PNPISAConfiguration,
    SgiInternalConfiguration,
    MaximumBusDataType
} BUS_DATA_TYPE, *PBUS_DATA_TYPE;

NTKERNELAPI
PVOID
MmAllocateContiguousMemory (
    IN ULONG NumberOfBytes,
    IN PHYSICAL_ADDRESS HighestAcceptableAddress
    );

NTKERNELAPI
VOID
MmFreeContiguousMemory (
    IN PVOID BaseAddress
    );

NTKERNELAPI
PHYSICAL_ADDRESS
MmGetPhysicalAddress (
    IN PVOID BaseAddress
    );

NTHALAPI
ULONG
HalGetBusData(
    IN BUS_DATA_TYPE BusDataType,
    IN ULONG BusNumber,
    IN ULONG SlotNumber,
    IN PVOID Buffer,
    IN ULONG Length
    );

NTHALAPI
ULONG
HalSetBusData(
    IN BUS_DATA_TYPE BusDataType,
    IN ULONG BusNumber,
    IN ULONG SlotNumber,
    IN PVOID Buffer,
    IN ULONG Length
    );

ULONG
HalSetBusDataByOffset(
    IN BUS_DATA_TYPE BusDataType,
    IN ULONG BusNumber,
    IN ULONG SlotNumber,
    IN PVOID Buffer,
    IN ULONG Offset,
    IN ULONG Length
    );


ULONG
HalGetBusDataByOffset(
    IN BUS_DATA_TYPE BusDataType,
    IN ULONG BusNumber,
    IN ULONG SlotNumber,
    IN PVOID Buffer,
    IN ULONG Offset,
    IN ULONG Length
    );

⌨️ 快捷键说明

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