mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-01 10:53:38 +00:00
winebus.sys: Introduce a new unixlib interface.
And use it for bus entry points. Signed-off-by: Rémi Bernon <rbernon@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b4d8cd3891
commit
edbb3fac25
|
@ -9,6 +9,7 @@ C_SRCS = \
|
|||
bus_sdl.c \
|
||||
bus_udev.c \
|
||||
hid.c \
|
||||
main.c
|
||||
main.c \
|
||||
unixlib.c
|
||||
|
||||
RC_SRCS = winebus.rc
|
||||
|
|
|
@ -27,19 +27,6 @@
|
|||
|
||||
typedef int(*enum_func)(DEVICE_OBJECT *device, void *context);
|
||||
|
||||
/* Buses */
|
||||
extern NTSTATUS sdl_bus_init(void *) DECLSPEC_HIDDEN;
|
||||
extern NTSTATUS sdl_bus_wait(void *) DECLSPEC_HIDDEN;
|
||||
extern NTSTATUS sdl_bus_stop(void *) DECLSPEC_HIDDEN;
|
||||
|
||||
extern NTSTATUS udev_bus_init(void *) DECLSPEC_HIDDEN;
|
||||
extern NTSTATUS udev_bus_wait(void *) DECLSPEC_HIDDEN;
|
||||
extern NTSTATUS udev_bus_stop(void *) DECLSPEC_HIDDEN;
|
||||
|
||||
extern NTSTATUS iohid_bus_init(void *) DECLSPEC_HIDDEN;
|
||||
extern NTSTATUS iohid_bus_wait(void *) DECLSPEC_HIDDEN;
|
||||
extern NTSTATUS iohid_bus_stop(void *) DECLSPEC_HIDDEN;
|
||||
|
||||
/* Native device function table */
|
||||
typedef struct
|
||||
{
|
||||
|
|
|
@ -90,6 +90,7 @@
|
|||
#include "wine/debug.h"
|
||||
|
||||
#include "bus.h"
|
||||
#include "unix_private.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(plugplay);
|
||||
#ifdef HAVE_IOHIDMANAGERCREATE
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#endif
|
||||
|
||||
#include "bus.h"
|
||||
#include "unix_private.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(plugplay);
|
||||
|
||||
|
|
|
@ -80,6 +80,7 @@
|
|||
#endif
|
||||
|
||||
#include "bus.h"
|
||||
#include "unix_private.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(plugplay);
|
||||
|
||||
|
|
|
@ -32,8 +32,10 @@
|
|||
#include "wine/debug.h"
|
||||
#include "wine/unicode.h"
|
||||
#include "wine/list.h"
|
||||
#include "wine/unixlib.h"
|
||||
|
||||
#include "bus.h"
|
||||
#include "unixlib.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(plugplay);
|
||||
WINE_DECLARE_DEBUG_CHANNEL(hid_report);
|
||||
|
@ -155,6 +157,11 @@ static const WCHAR zero_serialW[]= {'0','0','0','0',0};
|
|||
static const WCHAR miW[] = {'M','I',0};
|
||||
static const WCHAR igW[] = {'I','G',0};
|
||||
|
||||
static NTSTATUS winebus_call(unsigned int code, void *args)
|
||||
{
|
||||
return __wine_unix_call_funcs[code]( args );
|
||||
}
|
||||
|
||||
static inline WCHAR *strdupW(const WCHAR *src)
|
||||
{
|
||||
WCHAR *dst;
|
||||
|
@ -626,9 +633,8 @@ struct bus_main_params
|
|||
const WCHAR *name;
|
||||
|
||||
HANDLE init_done;
|
||||
NTSTATUS (*init_func)(void *args);
|
||||
|
||||
NTSTATUS (*wait_func)(void *args);
|
||||
unsigned int init_code;
|
||||
unsigned int wait_code;
|
||||
};
|
||||
|
||||
static DWORD CALLBACK bus_main_thread(void *args)
|
||||
|
@ -637,12 +643,12 @@ static DWORD CALLBACK bus_main_thread(void *args)
|
|||
NTSTATUS status;
|
||||
|
||||
TRACE("%s main loop starting\n", debugstr_w(bus.name));
|
||||
status = bus.init_func(NULL);
|
||||
status = winebus_call(bus.init_code, NULL);
|
||||
SetEvent(bus.init_done);
|
||||
TRACE("%s main loop started\n", debugstr_w(bus.name));
|
||||
|
||||
if (status) WARN("%s bus init returned status %#x\n", debugstr_w(bus.name), status);
|
||||
else status = bus.wait_func(NULL);
|
||||
else status = winebus_call(bus.wait_code, NULL);
|
||||
|
||||
if (status) WARN("%s bus wait returned status %#x\n", debugstr_w(bus.name), status);
|
||||
else TRACE("%s main loop exited\n", debugstr_w(bus.name));
|
||||
|
@ -679,8 +685,8 @@ static NTSTATUS sdl_driver_init(void)
|
|||
struct bus_main_params bus =
|
||||
{
|
||||
.name = bus_name,
|
||||
.init_func = sdl_bus_init,
|
||||
.wait_func = sdl_bus_wait,
|
||||
.init_code = sdl_init,
|
||||
.wait_code = sdl_wait,
|
||||
};
|
||||
|
||||
return bus_main_thread_start(&bus);
|
||||
|
@ -692,8 +698,8 @@ static NTSTATUS udev_driver_init(void)
|
|||
struct bus_main_params bus =
|
||||
{
|
||||
.name = bus_name,
|
||||
.init_func = udev_bus_init,
|
||||
.wait_func = udev_bus_wait,
|
||||
.init_code = udev_init,
|
||||
.wait_code = udev_wait,
|
||||
};
|
||||
|
||||
return bus_main_thread_start(&bus);
|
||||
|
@ -705,8 +711,8 @@ static NTSTATUS iohid_driver_init(void)
|
|||
struct bus_main_params bus =
|
||||
{
|
||||
.name = bus_name,
|
||||
.init_func = iohid_bus_init,
|
||||
.wait_func = iohid_bus_wait,
|
||||
.init_code = iohid_init,
|
||||
.wait_code = iohid_wait,
|
||||
};
|
||||
|
||||
return bus_main_thread_start(&bus);
|
||||
|
@ -740,9 +746,9 @@ static NTSTATUS fdo_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp)
|
|||
irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
break;
|
||||
case IRP_MN_REMOVE_DEVICE:
|
||||
sdl_bus_stop(NULL);
|
||||
udev_bus_stop(NULL);
|
||||
iohid_bus_stop(NULL);
|
||||
winebus_call(sdl_stop, NULL);
|
||||
winebus_call(udev_stop, NULL);
|
||||
winebus_call(iohid_stop, NULL);
|
||||
|
||||
WaitForMultipleObjects(bus_count, bus_thread, TRUE, INFINITE);
|
||||
while (bus_count--) CloseHandle(bus_thread[bus_count]);
|
||||
|
|
42
dlls/winebus.sys/unix_private.h
Normal file
42
dlls/winebus.sys/unix_private.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright 2021 Rémi Bernon for CodeWeavers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef __WINEBUS_UNIX_PRIVATE_H
|
||||
#define __WINEBUS_UNIX_PRIVATE_H
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <windef.h>
|
||||
#include <winbase.h>
|
||||
#include <winternl.h>
|
||||
|
||||
#include "unixlib.h"
|
||||
|
||||
extern NTSTATUS sdl_bus_init(void *) DECLSPEC_HIDDEN;
|
||||
extern NTSTATUS sdl_bus_wait(void *) DECLSPEC_HIDDEN;
|
||||
extern NTSTATUS sdl_bus_stop(void *) DECLSPEC_HIDDEN;
|
||||
|
||||
extern NTSTATUS udev_bus_init(void *) DECLSPEC_HIDDEN;
|
||||
extern NTSTATUS udev_bus_wait(void *) DECLSPEC_HIDDEN;
|
||||
extern NTSTATUS udev_bus_stop(void *) DECLSPEC_HIDDEN;
|
||||
|
||||
extern NTSTATUS iohid_bus_init(void *) DECLSPEC_HIDDEN;
|
||||
extern NTSTATUS iohid_bus_wait(void *) DECLSPEC_HIDDEN;
|
||||
extern NTSTATUS iohid_bus_stop(void *) DECLSPEC_HIDDEN;
|
||||
|
||||
#endif /* __WINEBUS_UNIX_PRIVATE_H */
|
44
dlls/winebus.sys/unixlib.c
Normal file
44
dlls/winebus.sys/unixlib.c
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright 2021 Rémi Bernon for CodeWeavers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include "ntstatus.h"
|
||||
#define WIN32_NO_STATUS
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winternl.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
#include "wine/unixlib.h"
|
||||
|
||||
#include "unix_private.h"
|
||||
|
||||
const unixlib_entry_t __wine_unix_call_funcs[] =
|
||||
{
|
||||
sdl_bus_init,
|
||||
sdl_bus_wait,
|
||||
sdl_bus_stop,
|
||||
udev_bus_init,
|
||||
udev_bus_wait,
|
||||
udev_bus_stop,
|
||||
iohid_bus_init,
|
||||
iohid_bus_wait,
|
||||
iohid_bus_stop,
|
||||
};
|
47
dlls/winebus.sys/unixlib.h
Normal file
47
dlls/winebus.sys/unixlib.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright 2021 Rémi Bernon for CodeWeavers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef __WINEBUS_UNIXLIB_H
|
||||
#define __WINEBUS_UNIXLIB_H
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <windef.h>
|
||||
#include <winbase.h>
|
||||
#include <winternl.h>
|
||||
#include <ddk/wdm.h>
|
||||
#include <hidusage.h>
|
||||
|
||||
#include "wine/unixlib.h"
|
||||
|
||||
enum unix_funcs
|
||||
{
|
||||
sdl_init,
|
||||
sdl_wait,
|
||||
sdl_stop,
|
||||
udev_init,
|
||||
udev_wait,
|
||||
udev_stop,
|
||||
iohid_init,
|
||||
iohid_wait,
|
||||
iohid_stop,
|
||||
};
|
||||
|
||||
extern const unixlib_entry_t __wine_unix_call_funcs[] DECLSPEC_HIDDEN;
|
||||
|
||||
#endif /* __WINEBUS_UNIXLIB_H */
|
Loading…
Reference in a new issue