// Declarations for AIOWDM driver #ifndef DRIVER_H #define DRIVER_H #define DRIVERNAME "AIOWDM" // for use in messages #define LDRIVERNAME L"AIOWDM" // for use in UNICODE string constants #define DEVICE_DEVICE_NAME L"\\Device\\AIOWDMCoreDevice" #define AIOWDM_DEVICE_NAME L"\\DosDevices\\AIOWDMCore" #if DBG #define DBGONLY(_X_) _X_ #else #define DBGONLY(_X_) #endif /////////////////////////////////////////////////////////////////////////////// // Device extension structure enum DEVSTATE { STOPPED, // device stopped WORKING, // started and working PENDINGSTOP, // stop pending PENDINGREMOVE, // remove pending SURPRISEREMOVED, // removed by surprise REMOVED, // removed }; typedef struct IOACTION { char Operation; UCHAR Offset; UCHAR Data; } _IOACTION, *PIOACTION; typedef struct _DEVICE_EXTENSION { PDEVICE_OBJECT DeviceObject; // device object this extension belongs to PDEVICE_OBJECT LowerDeviceObject; // next lower driver in same stack PDEVICE_OBJECT Pdo; // the PDO IO_REMOVE_LOCK RemoveLock; // removal control locking structure UNICODE_STRING ifname; // interface name DEVSTATE state; // current state of device DEVSTATE prevstate; // state prior to removal query DEVICE_POWER_STATE devpower; // current device power state SYSTEM_POWER_STATE syspower; // current system power state DEVICE_POWER_STATE PerfBoundary; // context restore very expensive from >= this power state POWER_SEQUENCE oldseq; // old power sequence numbers DEVICE_CAPABILITIES devcaps; // copy of most recent device capabilities LONG handles; // # open handles PKINTERRUPT InterruptObject; // address of interrupt object PUCHAR portbase; // I/O port base address ULONG nports; // number of assigned ports ULONG DeviceID; // The card's PCI device ID or ISA virtual device ID IOACTION IAm; // how to find out if the device is generating an IRQ IOACTION Disable; // how to disable IRQs IOACTION Clear; // how to clear IRQs IOACTION Enable; // how to enable IRQs ULONG InterruptOccurred; ULONG InterruptRequested; PIRP PendingIrp; BOOLEAN HasPendingIrp; long IRQIndex; PUCHAR StatusBase; ULONG COSSize; USHORT UnmappedBase, UnmappedAuxBase; ULONG Bench; BOOLEAN bRealDevice; //false if central device(just for global commands) BOOLEAN GotIRQ; //true if device has IRQ BOOLEAN mappedport; // true if we mapped port addr in StartDevice BOOLEAN busy; // true if device busy with a request } DEVICE_EXTENSION, *PDEVICE_EXTENSION; typedef struct _TCARDINFO { ULONG DeviceID; USHORT BaseAddress; USHORT Reserved; } TCARDINFO, *PCARDINFO; typedef struct _TPORTOP { USHORT Address; UCHAR Flags; UCHAR Size; union { UCHAR Data8; USHORT Data16; ULONG Data32; } ; } TPORTOP, *PPORTOP; typedef struct _TMEMOP { ULONG Address; USHORT Padding0; UCHAR Flags; UCHAR Size; union { UCHAR Data8; USHORT Data16; ULONG Data32; } ; } TMEMOP, *PMEMOP; #define POF_RELATIVE 0x01 /////////////////////////////////////////////////////////////////////////////// // Global functions VOID RemoveDevice(IN PDEVICE_OBJECT fdo); NTSTATUS CompleteRequest(IN PIRP Irp, IN NTSTATUS status, IN ULONG_PTR info); NTSTATUS CompleteRequest(IN PIRP Irp, IN NTSTATUS status); NTSTATUS ForwardAndWait(IN PDEVICE_OBJECT fdo, IN PIRP Irp); NTSTATUS SendDeviceSetPower(PDEVICE_EXTENSION fdo, DEVICE_POWER_STATE state, BOOLEAN wait = FALSE); VOID SendAsyncNotification(PVOID context); VOID EnableAllInterfaces(PDEVICE_EXTENSION pdx, BOOLEAN enable); VOID DeregisterAllInterfaces(PDEVICE_EXTENSION pdx); NTSTATUS StartDevice(PDEVICE_OBJECT fdo, PCM_PARTIAL_RESOURCE_LIST raw, PCM_PARTIAL_RESOURCE_LIST translated); VOID StopDevice(PDEVICE_OBJECT fdo, BOOLEAN oktouch = FALSE); // I/O request handlers NTSTATUS DispatchCreate(PDEVICE_OBJECT fdo, PIRP Irp); NTSTATUS DispatchClose(PDEVICE_OBJECT fdo, PIRP Irp); NTSTATUS DispatchControl(PDEVICE_OBJECT fdo, PIRP Irp); NTSTATUS DispatchPower(PDEVICE_OBJECT fdo, PIRP Irp); NTSTATUS DispatchPnp(PDEVICE_OBJECT fdo, PIRP Irp); extern BOOLEAN win98; extern UNICODE_STRING servkey; // IRQ handling VOID DpcForIsr(PKDPC Dpc, PDEVICE_OBJECT fdo, PIRP junk, PDEVICE_EXTENSION pdx); BOOLEAN OnInterrupt(PKINTERRUPT InterruptObject, PVOID corrupt); #define MAX_SLOTS_OPEN 16 extern PDEVICE_EXTENSION GlobalExtension[MAX_SLOTS_OPEN]; #endif // DRIVER_H