diff --git a/drivers/hid/CMakeLists.txt b/drivers/hid/CMakeLists.txt index d61190cdf50..43e9bdabeec 100644 --- a/drivers/hid/CMakeLists.txt +++ b/drivers/hid/CMakeLists.txt @@ -1,2 +1,3 @@ +add_subdirectory(hidclass) add_subdirectory(hidparse) add_subdirectory(hidusb) \ No newline at end of file diff --git a/drivers/hid/hidclass/CMakeLists.txt b/drivers/hid/hidclass/CMakeLists.txt new file mode 100644 index 00000000000..b1f14d7db07 --- /dev/null +++ b/drivers/hid/hidclass/CMakeLists.txt @@ -0,0 +1,19 @@ + +spec2def(hidclass.sys hidclass.spec) + +list(APPEND SOURCE + hidclass.c + hidclass.rc + ${CMAKE_CURRENT_BINARY_DIR}/hidclass.def) + +add_library(hidclass SHARED ${SOURCE}) + +set_entrypoint(hidclass 0) +set_image_base(hidclass 0x00010000) +set_subsystem(hidclass native) +set_target_properties(hidclass PROPERTIES SUFFIX ".sys") + + +add_importlibs(hidclass ntoskrnl hidparse hal) +add_cab_target(hidclass 2) +add_importlib_target(hidclass.spec) \ No newline at end of file diff --git a/drivers/hid/hidclass/hidclass.c b/drivers/hid/hidclass/hidclass.c new file mode 100644 index 00000000000..138a1b4880c --- /dev/null +++ b/drivers/hid/hidclass/hidclass.c @@ -0,0 +1,116 @@ +/* + * PROJECT: ReactOS Universal Serial Bus Human Interface Device Driver + * LICENSE: GPL - See COPYING in the top level directory + * FILE: drivers/hid/hidclass/hidclass.c + * PURPOSE: HID Class Driver + * PROGRAMMERS: + * Michael Martin (michael.martin@reactos.org) + * Johannes Anderwald (johannes.anderwald@reactos.org) + */ + +#include "precomp.h" + +static LPWSTR ClientIdentificationAddress = L"HIDCLASS"; + +ULONG +NTAPI +DllInitialize(ULONG Unknown) +{ + return 0; +} + +ULONG +NTAPI +DllUnload() +{ + return 0; +} + +NTSTATUS +NTAPI +HidClassAddDevice( + IN PDRIVER_OBJECT DriverObject, + IN PDEVICE_OBJECT PhysicalDeviceObject) +{ + UNIMPLEMENTED + ASSERT(FALSE); + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +NTAPI +HidClassDriverUnload( + IN PDRIVER_OBJECT DriverObject) +{ + UNIMPLEMENTED + ASSERT(FALSE); + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +NTAPI +HidClassDispatch( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + UNIMPLEMENTED + ASSERT(FALSE); + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +NTAPI +HidRegisterMinidriver( + IN PHID_MINIDRIVER_REGISTRATION MinidriverRegistration) +{ + NTSTATUS Status; + PHIDCLASS_DRIVER_EXTENSION DriverExtension; + + /* check if the version matches */ + if (MinidriverRegistration->Revision > HID_REVISION) + { + /* revision mismatch */ + ASSERT(FALSE); + return STATUS_REVISION_MISMATCH; + } + + /* now allocate the driver object extension */ + Status = IoAllocateDriverObjectExtension(MinidriverRegistration->DriverObject, (PVOID)ClientIdentificationAddress, sizeof(HIDCLASS_DRIVER_EXTENSION), (PVOID*)&DriverExtension); + if (!NT_SUCCESS(Status)) + { + /* failed to allocate driver extension */ + ASSERT(FALSE); + return Status; + } + + /* zero driver extension */ + RtlZeroMemory(DriverExtension, sizeof(HIDCLASS_DRIVER_EXTENSION)); + + /* init driver extension */ + DriverExtension->DriverObject = MinidriverRegistration->DriverObject; + DriverExtension->DeviceExtensionSize = MinidriverRegistration->DeviceExtensionSize; + DriverExtension->DevicesArePolled = MinidriverRegistration->DevicesArePolled; + DriverExtension->AddDevice = MinidriverRegistration->DriverObject->DriverExtension->AddDevice; + DriverExtension->DriverUnload = MinidriverRegistration->DriverObject->DriverUnload; + + /* copy driver dispatch routines */ + RtlCopyMemory(DriverExtension->MajorFunction, MinidriverRegistration->DriverObject->MajorFunction, sizeof(PDRIVER_DISPATCH) * IRP_MJ_MAXIMUM_FUNCTION); + + /* initialize lock */ + KeInitializeSpinLock(&DriverExtension->Lock); + + /* now replace dispatch routines */ + DriverExtension->DriverObject->DriverExtension->AddDevice = HidClassAddDevice; + DriverExtension->DriverObject->DriverUnload = HidClassDriverUnload; + DriverExtension->DriverObject->MajorFunction[IRP_MJ_CREATE] = HidClassDispatch; + DriverExtension->DriverObject->MajorFunction[IRP_MJ_CLOSE] = HidClassDispatch; + DriverExtension->DriverObject->MajorFunction[IRP_MJ_READ] = HidClassDispatch; + DriverExtension->DriverObject->MajorFunction[IRP_MJ_WRITE] = HidClassDispatch; + DriverExtension->DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = HidClassDispatch; + DriverExtension->DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = HidClassDispatch; + DriverExtension->DriverObject->MajorFunction[IRP_MJ_POWER] = HidClassDispatch; + DriverExtension->DriverObject->MajorFunction[IRP_MJ_PNP] = HidClassDispatch; + + /* done */ + return STATUS_SUCCESS; +} diff --git a/drivers/hid/hidclass/hidclass.rc b/drivers/hid/hidclass/hidclass.rc new file mode 100644 index 00000000000..a700199fb14 --- /dev/null +++ b/drivers/hid/hidclass/hidclass.rc @@ -0,0 +1,5 @@ +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "USB HID Bus Driver\0" +#define REACTOS_STR_INTERNAL_NAME "hidclass\0" +#define REACTOS_STR_ORIGINAL_FILENAME "hidclass.sys\0" +#include diff --git a/drivers/hid/hidclass/hidclass.spec b/drivers/hid/hidclass/hidclass.spec new file mode 100644 index 00000000000..3539f1f6aea --- /dev/null +++ b/drivers/hid/hidclass/hidclass.spec @@ -0,0 +1,4 @@ +@ stdcall -private DllInitialize(long) +@ stdcall -private DllUnload() +@ stdcall HidRegisterMinidriver(ptr) + diff --git a/drivers/hid/hidclass/precomp.h b/drivers/hid/hidclass/precomp.h new file mode 100644 index 00000000000..9c75214c90c --- /dev/null +++ b/drivers/hid/hidclass/precomp.h @@ -0,0 +1,19 @@ +#pragma once + +#define _HIDPI_NO_FUNCTION_MACROS_ +#include +#include +#include + + +typedef struct +{ + PDRIVER_OBJECT DriverObject; + ULONG DeviceExtensionSize; + BOOLEAN DevicesArePolled; + PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION]; + PDRIVER_ADD_DEVICE AddDevice; + PDRIVER_UNLOAD DriverUnload; + KSPIN_LOCK Lock; + +}HIDCLASS_DRIVER_EXTENSION, *PHIDCLASS_DRIVER_EXTENSION; \ No newline at end of file diff --git a/drivers/hid/hidusb/CMakeLists.txt b/drivers/hid/hidusb/CMakeLists.txt index 87de50832bb..577f5808933 100644 --- a/drivers/hid/hidusb/CMakeLists.txt +++ b/drivers/hid/hidusb/CMakeLists.txt @@ -1,11 +1,11 @@ list(APPEND SOURCE hidusb.c - usbhub.rc) + hidusb.rc) add_library(hidusb SHARED ${SOURCE}) set_module_type(hidusb kernelmodedriver) add_importlibs(hidusb hidclass ntoskrnl usbd) -add_cab_target(usbhub 2) +add_cab_target(hidusb 2) diff --git a/drivers/hid/hidusb/hidusb.c b/drivers/hid/hidusb/hidusb.c index 56af50a6516..01b614ac8d2 100644 --- a/drivers/hid/hidusb/hidusb.c +++ b/drivers/hid/hidusb/hidusb.c @@ -89,7 +89,7 @@ HidSystemControl( // // submit request // - return IoCallDriver(DeviceExtension->NextDeviceObject); + return IoCallDriver(DeviceExtension->NextDeviceObject, Irp); } NTSTATUS diff --git a/drivers/hid/hidusb/hidusb.rc b/drivers/hid/hidusb/hidusb.rc new file mode 100644 index 00000000000..4ad02a08141 --- /dev/null +++ b/drivers/hid/hidusb/hidusb.rc @@ -0,0 +1,5 @@ +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "USB HID Interface Driver\0" +#define REACTOS_STR_INTERNAL_NAME "hidusb\0" +#define REACTOS_STR_ORIGINAL_FILENAME "hidusb.sys\0" +#include diff --git a/include/ddk/hidclass.h b/include/ddk/hidclass.h index 80c088e061b..a523f882991 100644 --- a/include/ddk/hidclass.h +++ b/include/ddk/hidclass.h @@ -76,14 +76,6 @@ DEFINE_GUID (GUID_HID_INTERFACE_HIDPARSE, \ #define IOCTL_HID_GET_INDEXED_STRING HID_OUT_CTL_CODE(120) #define IOCTL_HID_GET_MS_GENRE_DESCRIPTOR HID_OUT_CTL_CODE(121) -/* FIXME: these values are wrong! */ -#define IOCTL_HID_GET_STRING 0 -#define IOCTL_HID_GET_DEVICE_ATTRIBUTES 1 -#define IOCTL_HID_GET_DEVICE_DESCRIPTOR 2 -#define IOCTL_HID_READ_REPORT 3 -#define IOCTL_HID_WRITE_REPORT 4 -#define IOCTL_HID_GET_REPORT_DESCRIPTOR 5 - typedef enum _HID_STRING_TYPE { HID_STRING_INDEXED = 0, diff --git a/include/ddk/hidport.h b/include/ddk/hidport.h index 413f9ee1147..078f58ea9b5 100644 --- a/include/ddk/hidport.h +++ b/include/ddk/hidport.h @@ -50,8 +50,8 @@ typedef struct _HID_DESCRIPTOR typedef VOID -(*HID_SEND_IDLE_CALLBACK)( - __in PVOID Context +(NTAPI *HID_SEND_IDLE_CALLBACK)( + IN PVOID Context ); typedef struct _HID_SUBMIT_IDLE_NOTIFICATION_CALLBACK_INFO