- rearrange hid stack
[reactos.git] / drivers / usb / hidusb / hidusb.c
1 /*
2 * PROJECT: ReactOS Universal Serial Bus Human Interface Device Driver
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: drivers/usb/hidusb/hidusb.c
5 * PURPOSE: HID USB Interface Driver
6 * PROGRAMMERS:
7 * Michael Martin (michael.martin@reactos.org)
8 * Johannes Anderwald (johannes.anderwald@reactos.org)
9 */
10
11 #include "hidusb.h"
12
13 NTSTATUS
14 NTAPI
15 HidCreate(
16 IN PDEVICE_OBJECT DeviceObject,
17 IN PIRP Irp)
18 {
19 PIO_STACK_LOCATION IoStack;
20
21 //
22 // get current irp stack location
23 //
24 IoStack = IoGetCurrentIrpStackLocation(Irp);
25
26 //
27 // sanity check for hidclass driver
28 //
29 ASSERT(IoStack->MajorFunction == IRP_MJ_CREATE || IoStack->MajorFunction == IRP_MJ_CLOSE);
30
31 //
32 // complete request
33 //
34 Irp->IoStatus.Information = 0;
35 Irp->IoStatus.Status = STATUS_SUCCESS;
36 IoCompleteRequest(Irp, IO_NO_INCREMENT);
37
38 //
39 // informal debug print
40 //
41 DPRINT1("HIDUSB Request: %x\n", IoStack->MajorFunction);
42
43 //
44 // done
45 //
46 return STATUS_SUCCESS;
47 }
48
49 NTSTATUS
50 NTAPI
51 HidInternalDeviceControl(
52 IN PDEVICE_OBJECT DeviceObject,
53 IN PIRP Irp)
54 {
55 UNIMPLEMENTED
56 ASSERT(FALSE);
57 return STATUS_NOT_IMPLEMENTED;
58 }
59
60 NTSTATUS
61 NTAPI
62 HidPower(
63 IN PDEVICE_OBJECT DeviceObject,
64 IN PIRP Irp)
65 {
66 UNIMPLEMENTED
67 ASSERT(FALSE);
68 return STATUS_NOT_IMPLEMENTED;
69 }
70
71 NTSTATUS
72 NTAPI
73 HidSystemControl(
74 IN PDEVICE_OBJECT DeviceObject,
75 IN PIRP Irp)
76 {
77 PHID_DEVICE_EXTENSION DeviceExtension;
78
79 //
80 // get hid device extension
81 //
82 DeviceExtension = (PHID_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
83
84 //
85 // copy stack location
86 //
87 IoCopyCurrentIrpStackLocationToNext(Irp);
88
89 //
90 // submit request
91 //
92 return IoCallDriver(DeviceExtension->NextDeviceObject);
93 }
94
95 NTSTATUS
96 NTAPI
97 HidPnp(
98 IN PDEVICE_OBJECT DeviceObject,
99 IN PIRP Irp)
100 {
101 UNIMPLEMENTED
102 ASSERT(FALSE);
103 return STATUS_NOT_IMPLEMENTED;
104 }
105
106 NTSTATUS
107 NTAPI
108 DriverEntry(
109 IN PDRIVER_OBJECT DriverObject,
110 IN PUNICODE_STRING RegPath)
111 {
112 HID_MINIDRIVER_REGISTRATION Registration;
113 NTSTATUS Status;
114
115 //
116 // initialize driver object
117 //
118 DriverObject->MajorFunction[IRP_MJ_CREATE] = HidCreate;
119 DriverObject->MajorFunction[IRP_MJ_CLOSE] = HidCreate;
120 DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = HidInternalDeviceControl;
121 DriverObject->MajorFunction[IRP_MJ_POWER] = HidPower;
122 DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = HidSystemControl;
123 DriverObject->MajorFunction[IRP_MJ_PNP] = HidPnp;
124
125 //
126 // prepare registration info
127 //
128 RtlZeroMemory(&Registration, sizeof(HID_MINIDRIVER_REGISTRATION));
129
130 //
131 // fill in registration info
132 //
133 Registration.Revision = HID_REVISION;
134 Registration.DriverObject = DriverObject;
135 Registration.RegistryPath = RegPath;
136 Registration.DeviceExtensionSize = sizeof(HID_USB_DEVICE_EXTENSION);
137 Registration.DevicesArePolled = FALSE;
138
139 //
140 // register driver
141 //
142 Status = HidRegisterMinidriver(&Registration);
143
144 //
145 // informal debug
146 //
147 DPRINT1("********* HIDUSB *********\n");
148 DPRINT1("HIDUSB Registration Status %x\n", Status);
149
150 return Status;
151 }