From 3c593372946c93b60aa73aa7054c00d9cf046fd0 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Sun, 25 Dec 2011 18:17:07 +0000 Subject: [PATCH] - rearrange hid stack svn path=/branches/usb-bringup/; revision=54754 --- drivers/hid/hidusb/CMakeLists.txt | 11 +++ drivers/hid/hidusb/hidusb.c | 151 ++++++++++++++++++++++++++++++ drivers/hid/hidusb/hidusb.h | 22 +++++ 3 files changed, 184 insertions(+) create mode 100644 drivers/hid/hidusb/CMakeLists.txt create mode 100644 drivers/hid/hidusb/hidusb.c create mode 100644 drivers/hid/hidusb/hidusb.h diff --git a/drivers/hid/hidusb/CMakeLists.txt b/drivers/hid/hidusb/CMakeLists.txt new file mode 100644 index 00000000000..87de50832bb --- /dev/null +++ b/drivers/hid/hidusb/CMakeLists.txt @@ -0,0 +1,11 @@ + +list(APPEND SOURCE + hidusb.c + usbhub.rc) + +add_library(hidusb SHARED ${SOURCE}) + +set_module_type(hidusb kernelmodedriver) +add_importlibs(hidusb hidclass ntoskrnl usbd) + +add_cab_target(usbhub 2) diff --git a/drivers/hid/hidusb/hidusb.c b/drivers/hid/hidusb/hidusb.c new file mode 100644 index 00000000000..56af50a6516 --- /dev/null +++ b/drivers/hid/hidusb/hidusb.c @@ -0,0 +1,151 @@ +/* + * PROJECT: ReactOS Universal Serial Bus Human Interface Device Driver + * LICENSE: GPL - See COPYING in the top level directory + * FILE: drivers/usb/hidusb/hidusb.c + * PURPOSE: HID USB Interface Driver + * PROGRAMMERS: + * Michael Martin (michael.martin@reactos.org) + * Johannes Anderwald (johannes.anderwald@reactos.org) + */ + +#include "hidusb.h" + +NTSTATUS +NTAPI +HidCreate( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PIO_STACK_LOCATION IoStack; + + // + // get current irp stack location + // + IoStack = IoGetCurrentIrpStackLocation(Irp); + + // + // sanity check for hidclass driver + // + ASSERT(IoStack->MajorFunction == IRP_MJ_CREATE || IoStack->MajorFunction == IRP_MJ_CLOSE); + + // + // complete request + // + Irp->IoStatus.Information = 0; + Irp->IoStatus.Status = STATUS_SUCCESS; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + + // + // informal debug print + // + DPRINT1("HIDUSB Request: %x\n", IoStack->MajorFunction); + + // + // done + // + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +HidInternalDeviceControl( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + UNIMPLEMENTED + ASSERT(FALSE); + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +NTAPI +HidPower( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + UNIMPLEMENTED + ASSERT(FALSE); + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +NTAPI +HidSystemControl( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PHID_DEVICE_EXTENSION DeviceExtension; + + // + // get hid device extension + // + DeviceExtension = (PHID_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + + // + // copy stack location + // + IoCopyCurrentIrpStackLocationToNext(Irp); + + // + // submit request + // + return IoCallDriver(DeviceExtension->NextDeviceObject); +} + +NTSTATUS +NTAPI +HidPnp( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + UNIMPLEMENTED + ASSERT(FALSE); + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +NTAPI +DriverEntry( + IN PDRIVER_OBJECT DriverObject, + IN PUNICODE_STRING RegPath) +{ + HID_MINIDRIVER_REGISTRATION Registration; + NTSTATUS Status; + + // + // initialize driver object + // + DriverObject->MajorFunction[IRP_MJ_CREATE] = HidCreate; + DriverObject->MajorFunction[IRP_MJ_CLOSE] = HidCreate; + DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = HidInternalDeviceControl; + DriverObject->MajorFunction[IRP_MJ_POWER] = HidPower; + DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = HidSystemControl; + DriverObject->MajorFunction[IRP_MJ_PNP] = HidPnp; + + // + // prepare registration info + // + RtlZeroMemory(&Registration, sizeof(HID_MINIDRIVER_REGISTRATION)); + + // + // fill in registration info + // + Registration.Revision = HID_REVISION; + Registration.DriverObject = DriverObject; + Registration.RegistryPath = RegPath; + Registration.DeviceExtensionSize = sizeof(HID_USB_DEVICE_EXTENSION); + Registration.DevicesArePolled = FALSE; + + // + // register driver + // + Status = HidRegisterMinidriver(&Registration); + + // + // informal debug + // + DPRINT1("********* HIDUSB *********\n"); + DPRINT1("HIDUSB Registration Status %x\n", Status); + + return Status; +} diff --git a/drivers/hid/hidusb/hidusb.h b/drivers/hid/hidusb/hidusb.h new file mode 100644 index 00000000000..e991861d25a --- /dev/null +++ b/drivers/hid/hidusb/hidusb.h @@ -0,0 +1,22 @@ +#pragma once + +#define _HIDPI_ +#define _HIDPI_NO_FUNCTION_MACROS_ +#include +#include +#include + +typedef struct +{ + // + // event for completion + // + KEVENT Event; + + // + // list for pending requests + // + LIST_ENTRY PendingRequests; + +}HID_USB_DEVICE_EXTENSION, *PHID_USB_DEVICE_EXTENSION; + -- 2.17.1