winebus.sys: Introduce a new start_device callback.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2021-08-18 09:14:18 +02:00 committed by Alexandre Julliard
parent cfddd2c1e2
commit 68c6c7d936
5 changed files with 53 additions and 5 deletions

View File

@ -39,6 +39,7 @@ typedef struct
{
void (*free_device)(DEVICE_OBJECT *device);
int (*compare_platform_device)(DEVICE_OBJECT *device, void *platform_dev);
NTSTATUS (*start_device)(DEVICE_OBJECT *device);
NTSTATUS (*get_reportdescriptor)(DEVICE_OBJECT *device, BYTE *buffer, DWORD length, DWORD *out_length);
NTSTATUS (*get_string)(DEVICE_OBJECT *device, DWORD index, WCHAR *buffer, DWORD length);
NTSTATUS (*begin_report_processing)(DEVICE_OBJECT *device);

View File

@ -148,6 +148,11 @@ static int compare_platform_device(DEVICE_OBJECT *device, void *platform_dev)
return 0;
}
static NTSTATUS start_device(DEVICE_OBJECT *device)
{
return STATUS_SUCCESS;
}
static NTSTATUS get_reportdescriptor(DEVICE_OBJECT *device, BYTE *buffer, DWORD length, DWORD *out_length)
{
struct platform_private *private = impl_from_DEVICE_OBJECT(device);
@ -274,6 +279,7 @@ static const platform_vtbl iohid_vtbl =
{
free_device,
compare_platform_device,
start_device,
get_reportdescriptor,
get_string,
begin_report_processing,

View File

@ -487,6 +487,11 @@ static int compare_platform_device(DEVICE_OBJECT *device, void *context)
return impl_from_DEVICE_OBJECT(device)->id - PtrToUlong(context);
}
static NTSTATUS start_device(DEVICE_OBJECT *device)
{
return STATUS_SUCCESS;
}
static NTSTATUS get_reportdescriptor(DEVICE_OBJECT *device, BYTE *buffer, DWORD length, DWORD *out_length)
{
struct platform_private *ext = impl_from_DEVICE_OBJECT(device);
@ -596,6 +601,7 @@ static const platform_vtbl sdl_vtbl =
{
free_device,
compare_platform_device,
start_device,
get_reportdescriptor,
get_string,
begin_report_processing,

View File

@ -558,6 +558,11 @@ static int compare_platform_device(DEVICE_OBJECT *device, void *platform_dev)
return strcmp(udev_device_get_syspath(dev1), udev_device_get_syspath(dev2));
}
static NTSTATUS hidraw_start_device(DEVICE_OBJECT *device)
{
return STATUS_SUCCESS;
}
static NTSTATUS hidraw_get_reportdescriptor(DEVICE_OBJECT *device, BYTE *buffer, DWORD length, DWORD *out_length)
{
#ifdef HAVE_LINUX_HIDRAW_H
@ -818,6 +823,7 @@ static const platform_vtbl hidraw_vtbl =
{
hidraw_free_device,
compare_platform_device,
hidraw_start_device,
hidraw_get_reportdescriptor,
hidraw_get_string,
begin_report_processing,
@ -854,6 +860,11 @@ static void lnxev_free_device(DEVICE_OBJECT *device)
udev_device_unref(ext->base.udev_device);
}
static NTSTATUS lnxev_start_device(DEVICE_OBJECT *device)
{
return STATUS_SUCCESS;
}
static NTSTATUS lnxev_get_reportdescriptor(DEVICE_OBJECT *device, BYTE *buffer, DWORD length, DWORD *out_length)
{
struct wine_input_private *ext = input_impl_from_DEVICE_OBJECT(device);
@ -967,6 +978,7 @@ static NTSTATUS lnxev_set_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *
static const platform_vtbl lnxev_vtbl = {
lnxev_free_device,
compare_platform_device,
lnxev_start_device,
lnxev_get_reportdescriptor,
lnxev_get_string,
lnxev_begin_report_processing,

View File

@ -109,11 +109,17 @@ struct pnp_device
DEVICE_OBJECT *device;
};
enum device_state
{
DEVICE_STATE_STOPPED,
DEVICE_STATE_STARTED,
DEVICE_STATE_REMOVED,
};
struct device_extension
{
CRITICAL_SECTION cs;
BOOL removed;
enum device_state state;
struct pnp_device *pnp_device;
@ -480,6 +486,11 @@ static void mouse_free_device(DEVICE_OBJECT *device)
{
}
static NTSTATUS mouse_start_device(DEVICE_OBJECT *device)
{
return STATUS_SUCCESS;
}
static NTSTATUS mouse_get_reportdescriptor(DEVICE_OBJECT *device, BYTE *buffer, DWORD length, DWORD *ret_length)
{
TRACE("buffer %p, length %u.\n", buffer, length);
@ -528,6 +539,7 @@ static NTSTATUS mouse_set_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *
static const platform_vtbl mouse_vtbl =
{
.free_device = mouse_free_device,
.start_device = mouse_start_device,
.get_reportdescriptor = mouse_get_reportdescriptor,
.get_string = mouse_get_string,
.begin_report_processing = mouse_begin_report_processing,
@ -555,6 +567,11 @@ static void keyboard_free_device(DEVICE_OBJECT *device)
{
}
static NTSTATUS keyboard_start_device(DEVICE_OBJECT *device)
{
return STATUS_SUCCESS;
}
static NTSTATUS keyboard_get_reportdescriptor(DEVICE_OBJECT *device, BYTE *buffer, DWORD length, DWORD *ret_length)
{
TRACE("buffer %p, length %u.\n", buffer, length);
@ -603,6 +620,7 @@ static NTSTATUS keyboard_set_feature_report(DEVICE_OBJECT *device, UCHAR id, BYT
static const platform_vtbl keyboard_vtbl =
{
.free_device = keyboard_free_device,
.start_device = keyboard_start_device,
.get_reportdescriptor = keyboard_get_reportdescriptor,
.get_string = keyboard_get_string,
.begin_report_processing = keyboard_begin_report_processing,
@ -695,13 +713,18 @@ static NTSTATUS pdo_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp)
break;
case IRP_MN_START_DEVICE:
status = STATUS_SUCCESS;
EnterCriticalSection(&ext->cs);
if (ext->state != DEVICE_STATE_STOPPED) status = STATUS_SUCCESS;
else if (ext->state == DEVICE_STATE_REMOVED) status = STATUS_DELETE_PENDING;
else if (!(status = ext->vtbl->start_device(device))) ext->state = DEVICE_STATE_STARTED;
else ERR("failed to start device %p, status %#x\n", device, status);
LeaveCriticalSection(&ext->cs);
break;
case IRP_MN_SURPRISE_REMOVAL:
EnterCriticalSection(&ext->cs);
remove_pending_irps(device);
ext->removed = TRUE;
ext->state = DEVICE_STATE_REMOVED;
LeaveCriticalSection(&ext->cs);
status = STATUS_SUCCESS;
break;
@ -834,7 +857,7 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
EnterCriticalSection(&ext->cs);
if (ext->removed)
if (ext->state == DEVICE_STATE_REMOVED)
{
LeaveCriticalSection(&ext->cs);
irp->IoStatus.Status = STATUS_DELETE_PENDING;