#include #include #include #include "gpioctl.h" // Get IOCTL interface definitions /* Default base port, and # of ports */ #define BASE_PORT 0xED00 #define NUMBER_PORTS 0x1000 // NT device name #define GPD_DEVICE_NAME L"\\Device\\PortIO0" // File system device name. #define DOS_DEVICE_NAME L"\\DosDevices\\PortIODev" // driver local data structure specific to each device object typedef struct _LOCAL_DEVICE_INFO { ULONG DeviceType; // Our private Device Type BOOLEAN PortWasMapped[10]; // If TRUE, we have to unmap on unload PVOID PortBase[10]; // base port address ULONG PortCount[10]; // Count of I/O addresses used. ULONG PortMemoryType[10]; // HalTranslateBusAddress MemoryType PDEVICE_OBJECT DeviceObject; // The Gpd device object. USHORT NumberRanges; } LOCAL_DEVICE_INFO, *PLOCAL_DEVICE_INFO; /********************* function prototypes ***********************************/ // NTSTATUS DriverEntry( IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath ); NTSTATUS GpdCreateDevice( IN PWSTR szPrototypeName, IN DEVICE_TYPE DeviceType, IN PDRIVER_OBJECT DriverObject, OUT PDEVICE_OBJECT *ppDevObj ); NTSTATUS GpdDispatch( IN PDEVICE_OBJECT pDO, IN PIRP pIrp ); NTSTATUS GpdIoctlReadPort( IN PLOCAL_DEVICE_INFO pLDI, IN PIRP pIrp, IN PIO_STACK_LOCATION IrpStack, IN ULONG IoctlCode ); NTSTATUS GpdIoctlWritePort( IN PLOCAL_DEVICE_INFO pLDI, IN PIRP pIrp, IN PIO_STACK_LOCATION IrpStack, IN ULONG IoctlCode ); VOID GpdUnload( IN PDRIVER_OBJECT DriverObject );