[USB-BRINGUP]

- add template for hidclass driver 
- fix hidusb build

svn path=/branches/usb-bringup/; revision=54759
This commit is contained in:
Johannes Anderwald 2011-12-25 20:21:34 +00:00
parent d13f78582b
commit 8632f8d0f0
11 changed files with 174 additions and 13 deletions

View file

@ -1,2 +1,3 @@
add_subdirectory(hidclass)
add_subdirectory(hidparse)
add_subdirectory(hidusb)

View 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)

View 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;
}

View 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>

View file

@ -0,0 +1,4 @@
@ stdcall -private DllInitialize(long)
@ stdcall -private DllUnload()
@ stdcall HidRegisterMinidriver(ptr)

View 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;

View 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)

View file

@ -89,7 +89,7 @@ HidSystemControl(
//
// submit request
//
return IoCallDriver(DeviceExtension->NextDeviceObject);
return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
}
NTSTATUS

View 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>

View 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,

View 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