And use it for bus entry points.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/Makefile.in | 3 ++- dlls/winebus.sys/bus.h | 13 --------- dlls/winebus.sys/bus_iohid.c | 1 + dlls/winebus.sys/bus_sdl.c | 1 + dlls/winebus.sys/bus_udev.c | 1 + dlls/winebus.sys/main.c | 34 ++++++++++++++---------- dlls/winebus.sys/unix_private.h | 42 +++++++++++++++++++++++++++++ dlls/winebus.sys/unixlib.c | 44 ++++++++++++++++++++++++++++++ dlls/winebus.sys/unixlib.h | 47 +++++++++++++++++++++++++++++++++ 9 files changed, 158 insertions(+), 28 deletions(-) create mode 100644 dlls/winebus.sys/unix_private.h create mode 100644 dlls/winebus.sys/unixlib.c create mode 100644 dlls/winebus.sys/unixlib.h
diff --git a/dlls/winebus.sys/Makefile.in b/dlls/winebus.sys/Makefile.in index 8cde3c7b422..658d27b70fd 100644 --- a/dlls/winebus.sys/Makefile.in +++ b/dlls/winebus.sys/Makefile.in @@ -9,6 +9,7 @@ C_SRCS = \ bus_sdl.c \ bus_udev.c \ hid.c \ - main.c + main.c \ + unixlib.c
RC_SRCS = winebus.rc diff --git a/dlls/winebus.sys/bus.h b/dlls/winebus.sys/bus.h index cecde2aa83c..a3e84bf8bd8 100644 --- a/dlls/winebus.sys/bus.h +++ b/dlls/winebus.sys/bus.h @@ -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 { diff --git a/dlls/winebus.sys/bus_iohid.c b/dlls/winebus.sys/bus_iohid.c index 49774dd0662..f1fe34e1780 100644 --- a/dlls/winebus.sys/bus_iohid.c +++ b/dlls/winebus.sys/bus_iohid.c @@ -90,6 +90,7 @@ #include "wine/debug.h"
#include "bus.h" +#include "unix_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(plugplay); #ifdef HAVE_IOHIDMANAGERCREATE diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index 02509f1560c..cf81120c2f9 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -51,6 +51,7 @@ #endif
#include "bus.h" +#include "unix_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(plugplay);
diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index 67d00670a26..a4b20f3efae 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -80,6 +80,7 @@ #endif
#include "bus.h" +#include "unix_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(plugplay);
diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index 9d57a0c4db2..b678e86bc8b 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -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]); diff --git a/dlls/winebus.sys/unix_private.h b/dlls/winebus.sys/unix_private.h new file mode 100644 index 00000000000..9468cac45e9 --- /dev/null +++ b/dlls/winebus.sys/unix_private.h @@ -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 */ diff --git a/dlls/winebus.sys/unixlib.c b/dlls/winebus.sys/unixlib.c new file mode 100644 index 00000000000..c4090861675 --- /dev/null +++ b/dlls/winebus.sys/unixlib.c @@ -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, +}; diff --git a/dlls/winebus.sys/unixlib.h b/dlls/winebus.sys/unixlib.h new file mode 100644 index 00000000000..51765f2f2d6 --- /dev/null +++ b/dlls/winebus.sys/unixlib.h @@ -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 */