mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 10:35:28 +00:00
[USB-BRINGUP]
- add template for hidclass driver - fix hidusb build svn path=/branches/usb-bringup/; revision=54759
This commit is contained in:
parent
d13f78582b
commit
8632f8d0f0
11 changed files with 174 additions and 13 deletions
|
@ -1,2 +1,3 @@
|
||||||
|
add_subdirectory(hidclass)
|
||||||
add_subdirectory(hidparse)
|
add_subdirectory(hidparse)
|
||||||
add_subdirectory(hidusb)
|
add_subdirectory(hidusb)
|
19
drivers/hid/hidclass/CMakeLists.txt
Normal file
19
drivers/hid/hidclass/CMakeLists.txt
Normal file
|
@ -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)
|
116
drivers/hid/hidclass/hidclass.c
Normal file
116
drivers/hid/hidclass/hidclass.c
Normal file
|
@ -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;
|
||||||
|
}
|
5
drivers/hid/hidclass/hidclass.rc
Normal file
5
drivers/hid/hidclass/hidclass.rc
Normal file
|
@ -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>
|
4
drivers/hid/hidclass/hidclass.spec
Normal file
4
drivers/hid/hidclass/hidclass.spec
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
@ stdcall -private DllInitialize(long)
|
||||||
|
@ stdcall -private DllUnload()
|
||||||
|
@ stdcall HidRegisterMinidriver(ptr)
|
||||||
|
|
19
drivers/hid/hidclass/precomp.h
Normal file
19
drivers/hid/hidclass/precomp.h
Normal file
|
@ -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;
|
|
@ -1,11 +1,11 @@
|
||||||
|
|
||||||
list(APPEND SOURCE
|
list(APPEND SOURCE
|
||||||
hidusb.c
|
hidusb.c
|
||||||
usbhub.rc)
|
hidusb.rc)
|
||||||
|
|
||||||
add_library(hidusb SHARED ${SOURCE})
|
add_library(hidusb SHARED ${SOURCE})
|
||||||
|
|
||||||
set_module_type(hidusb kernelmodedriver)
|
set_module_type(hidusb kernelmodedriver)
|
||||||
add_importlibs(hidusb hidclass ntoskrnl usbd)
|
add_importlibs(hidusb hidclass ntoskrnl usbd)
|
||||||
|
|
||||||
add_cab_target(usbhub 2)
|
add_cab_target(hidusb 2)
|
||||||
|
|
|
@ -89,7 +89,7 @@ HidSystemControl(
|
||||||
//
|
//
|
||||||
// submit request
|
// submit request
|
||||||
//
|
//
|
||||||
return IoCallDriver(DeviceExtension->NextDeviceObject);
|
return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
|
5
drivers/hid/hidusb/hidusb.rc
Normal file
5
drivers/hid/hidusb/hidusb.rc
Normal file
|
@ -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>
|
|
@ -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_INDEXED_STRING HID_OUT_CTL_CODE(120)
|
||||||
#define IOCTL_HID_GET_MS_GENRE_DESCRIPTOR HID_OUT_CTL_CODE(121)
|
#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
|
typedef enum _HID_STRING_TYPE
|
||||||
{
|
{
|
||||||
HID_STRING_INDEXED = 0,
|
HID_STRING_INDEXED = 0,
|
||||||
|
|
|
@ -50,8 +50,8 @@ typedef struct _HID_DESCRIPTOR
|
||||||
|
|
||||||
typedef
|
typedef
|
||||||
VOID
|
VOID
|
||||||
(*HID_SEND_IDLE_CALLBACK)(
|
(NTAPI *HID_SEND_IDLE_CALLBACK)(
|
||||||
__in PVOID Context
|
IN PVOID Context
|
||||||
);
|
);
|
||||||
|
|
||||||
typedef struct _HID_SUBMIT_IDLE_NOTIFICATION_CALLBACK_INFO
|
typedef struct _HID_SUBMIT_IDLE_NOTIFICATION_CALLBACK_INFO
|
||||||
|
|
Loading…
Reference in a new issue