[USB-BRINGUP]
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Sun, 25 Dec 2011 20:21:34 +0000 (20:21 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Sun, 25 Dec 2011 20:21:34 +0000 (20:21 +0000)
- add template for hidclass driver
- fix hidusb build

svn path=/branches/usb-bringup/; revision=54759

drivers/hid/CMakeLists.txt
drivers/hid/hidclass/CMakeLists.txt [new file with mode: 0644]
drivers/hid/hidclass/hidclass.c [new file with mode: 0644]
drivers/hid/hidclass/hidclass.rc [new file with mode: 0644]
drivers/hid/hidclass/hidclass.spec [new file with mode: 0644]
drivers/hid/hidclass/precomp.h [new file with mode: 0644]
drivers/hid/hidusb/CMakeLists.txt
drivers/hid/hidusb/hidusb.c
drivers/hid/hidusb/hidusb.rc [new file with mode: 0644]
include/ddk/hidclass.h
include/ddk/hidport.h

index d61190c..43e9bda 100644 (file)
@@ -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 (file)
index 0000000..b1f14d7
--- /dev/null
@@ -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 (file)
index 0000000..138a1b4
--- /dev/null
@@ -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 (file)
index 0000000..a700199
--- /dev/null
@@ -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 <reactos/version.rc>
diff --git a/drivers/hid/hidclass/hidclass.spec b/drivers/hid/hidclass/hidclass.spec
new file mode 100644 (file)
index 0000000..3539f1f
--- /dev/null
@@ -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 (file)
index 0000000..9c75214
--- /dev/null
@@ -0,0 +1,19 @@
+#pragma once
+
+#define _HIDPI_NO_FUNCTION_MACROS_
+#include <ntddk.h>
+#include <hidport.h>
+#include <debug.h>
+
+
+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
index 87de508..577f580 100644 (file)
@@ -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)
index 56af50a..01b614a 100644 (file)
@@ -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 (file)
index 0000000..4ad02a0
--- /dev/null
@@ -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 <reactos/version.rc>
index 80c088e..a523f88 100644 (file)
@@ -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,
index 413f9ee..078f58e 100644 (file)
@@ -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