1
0
mirror of https://github.com/djhackersdev/bemanitools.git synced 2024-11-30 17:24:30 +01:00

refactor: Entire code base, thread and log usage

Boils down to:
- Include headers
- Reduce boiler plate with helpers
- Swap out explicit usages with core API layer
  and ensure the right API is configured beforehand
This commit is contained in:
icex2 2024-02-25 09:30:53 +01:00
parent ea835b32ee
commit e4a221e15b
338 changed files with 1307 additions and 640 deletions

View File

@ -1,6 +1,7 @@
libs += aciodrv-proc
libs_aciodrv-proc := \
core \
src_aciodrv-proc := \
panb.c \

View File

@ -5,8 +5,9 @@
#include "aciodrv/device.h"
#include "aciodrv/panb.h"
#include "util/log.h"
#include "util/thread.h"
#include "core/thread.h"
#include "core/log.h"
static int auto_poll_proc(void *auto_poll_param);
static int auto_poll_threadid;
@ -50,7 +51,7 @@ bool aciodrv_proc_panb_init(struct aciodrv_device_ctx *device)
InitializeCriticalSection(&keypair_lock);
InitializeCriticalSection(&auto_poll_stop_lock);
auto_poll_threadid =
thread_create(auto_poll_proc, (void *) device, 0x4000, 0);
core_thread_create(auto_poll_proc, (void *) device, 0x4000, 0);
return true;
}
@ -80,8 +81,8 @@ void aciodrv_proc_panb_fini(struct aciodrv_device_ctx *device)
auto_poll_stop = true;
LeaveCriticalSection(&auto_poll_stop_lock);
thread_join(auto_poll_threadid, NULL);
thread_destroy(auto_poll_threadid);
core_thread_join(auto_poll_threadid, NULL);
core_thread_destroy(auto_poll_threadid);
DeleteCriticalSection(&keypair_lock);
DeleteCriticalSection(&auto_poll_stop_lock);

View File

@ -7,8 +7,9 @@
#include "aciodrv/port.h"
#include "core/log.h"
#include "util/hex.h"
#include "util/log.h"
#include "util/mem.h"
/* Enable to dump all data to the logger */

View File

@ -7,7 +7,7 @@
#include "aciodrv/device.h"
#include "util/log.h"
#include "core/log.h"
bool aciodrv_h44b_init(struct aciodrv_device_ctx *device, uint8_t node_id)
{

View File

@ -5,7 +5,7 @@
#include "aciodrv/device.h"
#include "aciodrv/icca.h"
#include "util/log.h"
#include "core/log.h"
static bool aciodrv_icca_queue_loop_start(
struct aciodrv_device_ctx *device, uint8_t node_id)

View File

@ -5,7 +5,7 @@
#include "aciodrv/device.h"
#include "util/log.h"
#include "core/log.h"
static bool
aciodrv_kfca_watchdog_start(struct aciodrv_device_ctx *device, uint8_t node_id)

View File

@ -5,8 +5,7 @@
#include "aciodrv/device.h"
#include "aciodrv/panb.h"
#include "util/log.h"
#include "util/thread.h"
#include "core/log.h"
bool aciodrv_panb_start_auto_input(
struct aciodrv_device_ctx *device, uint8_t node_id, uint8_t node_count)

View File

@ -6,7 +6,7 @@
#include <windows.h>
#include "util/log.h"
#include "core/log.h"
HANDLE aciodrv_port_open(const char *port_path, int baud)
{

View File

@ -5,7 +5,7 @@
#include "aciodrv/device.h"
#include "util/log.h"
#include "core/log.h"
static bool aciodrv_rvol_change_expand_mode(
struct aciodrv_device_ctx *device, uint8_t node_id, uint8_t mode)

View File

@ -5,7 +5,7 @@
#include "acioemu/addr.h"
#include "acioemu/emu.h"
#include "util/log.h"
#include "core/log.h"
void ac_io_emu_cmd_assign_addrs(
struct ac_io_emu *emu, const struct ac_io_message *req, uint8_t node_count)

View File

@ -14,9 +14,10 @@
#include "acioemu/emu.h"
#include "acioemu/pipe.h"
#include "core/log.h"
#include "hook/iohook.h"
#include "util/log.h"
#include "util/str.h"
static HRESULT ac_io_emu_open(struct ac_io_emu *emu, struct irp *irp);

View File

@ -6,7 +6,7 @@
#include "acioemu/emu.h"
#include "acioemu/hdxs.h"
#include "util/log.h"
#include "core/log.h"
static void ac_io_emu_hdxs_cmd_send_version(
struct ac_io_emu_hdxs *hdxs, const struct ac_io_message *req);

View File

@ -7,9 +7,10 @@
#include "acio/acio.h"
#include "core/log.h"
#include "util/iobuf.h"
#include "util/list.h"
#include "util/log.h"
/* This uses the USB convention where OUT and IN are from the host's (game's)
perspective. So an OUT transaction comes in to us and vice versa.

View File

@ -1,6 +1,7 @@
dlls += aciomgr
libs_aciomgr := \
core \
aciodrv \
util \

View File

@ -5,14 +5,15 @@
#include <stdatomic.h>
#include "aciomgr/manager-init.h"
#include "aciomgr/manager.h"
#include "acio/acio.h"
#include "aciodrv/device.h"
#include "core/log.h"
#include "util/array.h"
#include "util/log.h"
#define MAX_PORT_PATH_LENGTH 256
@ -90,7 +91,7 @@ void aciomgr_set_loggers(
log_formatter_t warning,
log_formatter_t fatal)
{
log_to_external(misc, info, warning, fatal);
core_log_impl_set(misc, warning, info, fatal);
}
struct aciomgr_port_dispatcher *aciomgr_port_init(const char *path, int baud)

View File

@ -1,6 +1,7 @@
exes += aciotest
libs_aciotest := \
core \
bio2drv \
aciodrv \
aciodrv-proc \

View File

@ -15,7 +15,14 @@
#include "aciotest/panb.h"
#include "aciotest/rvol.h"
#include "util/log.h"
#include "core/log-bt-ext.h"
#include "core/log-bt.h"
#include "core/log.h"
#include "core/thread-crt-ext.h"
#include "core/thread-crt.h"
#include "core/thread.h"
#include "core/log.h"
static uint8_t aciotest_cnt = 0;
static uint8_t bi2a_mode = 255;
@ -112,7 +119,10 @@ int main(int argc, char **argv)
}
}
log_to_writer(log_writer_stdout, NULL);
core_thread_crt_ext_impl_set();
core_log_bt_ext_impl_set();
core_log_bt_ext_init_with_stdout();
struct aciodrv_device_ctx *device =
aciodrv_device_open_path(argv[1], atoi(argv[2]));

View File

@ -10,13 +10,14 @@
#include <stdio.h>
#include "asio/asio-reghook.h"
#include "core/log.h"
#include "hook/com-proxy.h"
#include "hook/table.h"
#include "asio/asio-reghook.h"
#include "util/defs.h"
#include "util/log.h"
#include "util/str.h"
#include "util/time.h"

View File

@ -1,8 +1,8 @@
#include "cconfig/cconfig-util.h"
#include "asio/config-asio.h"
#include "core/log.h"
#include "util/log.h"
#include "asio/config-asio.h"
#define ASIOHOOK_CONFIG_IO_FORCE_ASIO_KEY "asio.force_asio"
#define ASIOHOOK_CONFIG_IO_FORCE_WASAPI_KEY "asio.force_wasapi"

View File

@ -1,10 +1,11 @@
libs += bio2drv
libs_bio2drv := \
aciodrv
core \
aciodrv \
src_bio2drv := \
detect.c \
config-bio2.c \
bi2a-iidx.c \
bi2a-sdvx.c
bi2a-sdvx.c \

View File

@ -7,7 +7,7 @@
#include "aciodrv/device.h"
#include "util/log.h"
#include "core/log.h"
// Must be provided on init command. Actual meaning unknown right now.
// Not providing this will not initialize the IO correctly resulting

View File

@ -7,7 +7,7 @@
#include "aciodrv/device.h"
#include "util/log.h"
#include "core/log.h"
static const uint8_t _BIO2DR_BI2A_SDVX_INIT_DATA = 0x3B;

View File

@ -1,8 +1,8 @@
#include "cconfig/cconfig-util.h"
#include "bio2drv/config-bio2.h"
#include "core/log.h"
#include "util/log.h"
#include "bio2drv/config-bio2.h"
#define BIO2DRV_CONFIG_BIO2_AUTO_KEY "bio2.autodetect"
#define BIO2DRV_CONFIG_BIO2_PORT_KEY "bio2.port"

View File

@ -8,11 +8,11 @@
#include "bio2drv/detect.h"
#include "core/log.h"
#include <stdio.h>
#include <string.h>
#include "util/log.h"
DEFINE_GUID(
GUID_COM_BUS_ENUMERATOR,
0x4D36E978,
@ -142,7 +142,7 @@ void bio2drv_set_loggers(
log_formatter_t warning,
log_formatter_t fatal)
{
log_to_external(misc, info, warning, fatal);
core_log_impl_set(misc, warning, info, fatal);
}
bool bio2drv_detect(

View File

@ -14,6 +14,8 @@
#include "acioemu/addr.h"
#include "acioemu/emu.h"
#include "core/log.h"
#include "hook/iohook.h"
#include "hooklib/rs232.h"
@ -25,7 +27,6 @@
#include "util/array.h"
#include "util/defs.h"
#include "util/iobuf.h"
#include "util/log.h"
#include "util/str.h"
static struct array bio2_active_ports;

View File

@ -6,13 +6,14 @@
#include <cfgmgr32.h>
#include <setupapi.h>
#include "core/log.h"
#include "hook/table.h"
#include "bio2emu/emu.h"
#include "bio2emu/setupapi.h"
#include "util/defs.h"
#include "util/log.h"
#include "util/str.h"
#include "util/time.h"

View File

@ -4,6 +4,8 @@ deplibs_bsthook := \
avs \
libs_bsthook := \
avs-util \
core \
acioemu \
bstio \
hook \

View File

@ -19,13 +19,14 @@
#include "bsthook/acio.h"
#include "bsthook/kfca.h"
#include "core/log.h"
#include "hook/iohook.h"
#include "imports/avs.h"
#include "util/defs.h"
#include "util/iobuf.h"
#include "util/log.h"
#include "util/str.h"
static struct ac_io_emu ac_io_emu;

View File

@ -2,9 +2,14 @@
#include <stdbool.h>
#include "avs-util/core-interop.h"
#include "bemanitools/bstio.h"
#include "bemanitools/eamio.h"
#include "core/log.h"
#include "core/thread.h"
#include "hook/iohook.h"
#include "hooklib/app.h"
@ -18,7 +23,6 @@
#include "util/cmdline.h"
#include "util/defs.h"
#include "util/log.h"
static bool my_dll_entry_init(char *sidcode, struct property_node *config);
static bool my_dll_entry_main(void);
@ -33,19 +37,23 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *config)
log_info("Starting up BeatStream IO backend");
bst_io_set_loggers(
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
core_log_impl_assign(bst_io_set_loggers);
ok = bst_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy);
ok = bst_io_init(
core_thread_create_impl_get(),
core_thread_join_impl_get(),
core_thread_destroy_impl_get());
if (!ok) {
goto bst_io_fail;
}
eam_io_set_loggers(
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
core_log_impl_assign(eam_io_set_loggers);
ok = eam_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy);
ok = eam_io_init(
core_thread_create_impl_get(),
core_thread_join_impl_get(),
core_thread_destroy_impl_get());
if (!ok) {
goto eam_io_fail;
@ -91,8 +99,9 @@ BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx)
return TRUE;
}
log_to_external(
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
// Use AVS APIs
avs_util_core_interop_thread_avs_impl_set();
avs_util_core_interop_log_avs_impl_set();
args_recover(&argc, &argv);

View File

@ -3,6 +3,8 @@
#include <stdbool.h>
#include "core/log.h"
#include "hook/com-proxy.h"
#include "hook/pe.h"
#include "hook/table.h"
@ -10,7 +12,6 @@
#include "sdvxhook/gfx.h"
#include "util/defs.h"
#include "util/log.h"
static HRESULT STDCALL my_CreateDevice(
IDirect3D9 *self,

View File

@ -7,10 +7,11 @@
#include <stdio.h>
#include <string.h>
#include "core/log.h"
#include "hook/table.h"
#include "util/defs.h"
#include "util/log.h"
#include "util/str.h"
/* ------------------------------------------------------------------------- */

View File

@ -15,13 +15,14 @@
#include <stdio.h>
#include "camhook/cam.h"
#include "core/log.h"
#include "hook/com-proxy.h"
#include "hook/table.h"
#include "camhook/cam.h"
#include "util/defs.h"
#include "util/log.h"
#include "util/str.h"
#include "util/time.h"

View File

@ -1,8 +1,8 @@
#include "cconfig/cconfig-util.h"
#include "camhook/config-cam.h"
#include "core/log.h"
#include "util/log.h"
#include "camhook/config-cam.h"
#define CAMHOOK_CONFIG_CAM_DISABLE_EMU_KEY "cam.disable_emu"
#define CAMHOOK_CONFIG_CAM_DEFAULT_DISABLE_EMU_VALUE false

View File

@ -6,8 +6,9 @@
#include "cconfig/cconfig-main.h"
#include "core/log.h"
#include "util/cmdline.h"
#include "util/log.h"
bool cconfig_main_config_init(
struct cconfig *config,
@ -84,7 +85,7 @@ bool cconfig_main_config_init(
}
log_misc("Config state after file loading:");
cconfig_util_log(config, log_impl_misc);
cconfig_util_log(config, core_log_misc_impl_get());
}
log_misc("Parsing override config parameters from cmd");
@ -96,7 +97,7 @@ bool cconfig_main_config_init(
}
log_misc("Config state after cmd parameter overrides:");
cconfig_util_log(config, log_impl_misc);
cconfig_util_log(config, core_log_misc_impl_get());
goto success;

View File

@ -5,8 +5,9 @@
#include "cconfig/cconfig-util.h"
#include "core/log.h"
#include "util/hex.h"
#include "util/log.h"
#include "util/mem.h"
bool cconfig_util_get_int(
@ -220,10 +221,10 @@ void cconfig_util_set_data(
free(str);
}
void cconfig_util_log(struct cconfig *config, log_formatter_t log_formatter)
void cconfig_util_log(struct cconfig *config, core_log_message_t log_message)
{
for (uint32_t i = 0; i < config->nentries; i++) {
log_formatter(
log_message(
LOG_MODULE,
"%s=%s",
config->entries[i].key,

View File

@ -7,7 +7,7 @@
#include "cconfig/cconfig.h"
#include "util/log.h"
#include "core/log.h"
bool cconfig_util_get_int(
struct cconfig *config,
@ -57,6 +57,6 @@ void cconfig_util_set_data(
size_t len,
const char *desc);
void cconfig_util_log(struct cconfig *config, log_formatter_t log_formatter);
void cconfig_util_log(struct cconfig *config, core_log_message_t log_message);
#endif

View File

@ -2,7 +2,8 @@
#include "cconfig/cconfig.h"
#include "util/log.h"
#include "core/log.h"
#include "util/mem.h"
#include "util/str.h"

View File

@ -7,8 +7,9 @@
#include "cconfig/cmd.h"
#include "core/log.h"
#include "util/hex.h"
#include "util/log.h"
#include "util/str.h"
static void

View File

@ -6,8 +6,9 @@
#include "cconfig/conf.h"
#include "core/log.h"
#include "util/fs.h"
#include "util/log.h"
#include "util/str.h"
enum cconfig_conf_error cconfig_conf_load_from_file(

View File

@ -3,6 +3,7 @@ rc_config := config.rc
cppflags_config := -DUNICODE
libs_config := \
core \
eamio \
geninput \
util \

View File

@ -11,13 +11,14 @@
#include "config/schema.h"
#include "config/usages.h"
#include "core/log.h"
#include "geninput/hid-mgr.h"
#include "geninput/input-config.h"
#include "geninput/mapper.h"
#include "util/array.h"
#include "util/defs.h"
#include "util/log.h"
#include "util/mem.h"
#include "util/str.h"

View File

@ -15,11 +15,12 @@
#include "config/schema.h"
#include "config/usages.h"
#include "core/log.h"
#include "geninput/input-config.h"
#include "geninput/mapper.h"
#include "util/defs.h"
#include "util/log.h"
#include "util/mem.h"
#include "util/winres.h"

View File

@ -13,6 +13,8 @@
#include "config/resource.h"
#include "config/schema.h"
#include "core/log.h"
#include "eamio/eam-config.h"
#include "geninput/hid-mgr.h"
@ -21,7 +23,6 @@
#include "util/array.h"
#include "util/defs.h"
#include "util/log.h"
#include "util/mem.h"
#include "util/str.h"

View File

@ -6,8 +6,9 @@
#include "config/resource.h"
#include "config/schema.h"
#include "core/log.h"
#include "util/defs.h"
#include "util/log.h"
static INT_PTR CALLBACK
game_type_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);

View File

@ -14,14 +14,19 @@
#include "config/spinner.h"
#include "config/usages.h"
#include "core/log-bt.h"
#include "core/log-sink-debug.h"
#include "core/log.h"
#include "core/thread-crt-ext.h"
#include "core/thread-crt.h"
#include "core/thread.h"
#include "eamio/eam-config.h"
#include "geninput/input-config.h"
#include "util/defs.h"
#include "util/log.h"
#include "util/str.h"
#include "util/thread.h"
#include "util/winres.h"
HPROPSHEETPAGE
@ -61,11 +66,22 @@ int main(int argc, char **argv)
wchar_t text[1024];
int max_light;
size_t i;
struct core_log_sink sink;
inst = GetModuleHandle(NULL);
log_to_writer(log_writer_debug, NULL);
log_to_external(log_impl_misc, log_impl_info, log_impl_warning, my_fatal);
core_thread_crt_ext_impl_set();
core_log_impl_set(
core_log_bt_log_misc,
core_log_bt_log_info,
core_log_bt_log_warning,
my_fatal);
core_log_sink_debug_open(&sink);
core_log_bt_init(&sink);
core_log_bt_level_set(CORE_LOG_BT_LOG_LEVEL_MISC);
usages_init(inst);
@ -96,13 +112,17 @@ int main(int argc, char **argv)
}
}
input_set_loggers(
log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
input_init(crt_thread_create, crt_thread_join, crt_thread_destroy);
core_log_impl_assign(input_set_loggers);
input_init(
core_thread_create_impl_get(),
core_thread_join_impl_get(),
core_thread_destroy_impl_get());
eam_io_set_loggers(
log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
eam_io_init(crt_thread_create, crt_thread_join, crt_thread_destroy);
core_log_impl_assign(eam_io_set_loggers);
eam_io_init(
core_thread_create_impl_get(),
core_thread_join_impl_get(),
core_thread_destroy_impl_get());
eam_io_config_api = eam_io_get_config_api();
// calculate these and check against the loaded config

View File

@ -6,10 +6,11 @@
#include "config/snap.h"
#include "core/log.h"
#include "geninput/hid-mgr.h"
#include "util/defs.h"
#include "util/log.h"
#include "util/mem.h"
enum snap_control_heuristic { CONTROL_CENTERING_AXIS, CONTROL_MULTISWITCH };

View File

@ -9,8 +9,9 @@
#include "config/resource.h"
#include "core/log.h"
#include "util/array.h"
#include "util/log.h"
#include "util/str.h"
#include "util/winres.h"

View File

@ -4,9 +4,9 @@
#include "cconfig/cconfig-util.h"
#include "d3d9exhook/config-gfx.h"
#include "core/log.h"
#include "util/log.h"
#include "d3d9exhook/config-gfx.h"
#define D3D9EXHOOK_CONFIG_GFX_FRAMED_KEY "gfx.framed"
#define D3D9EXHOOK_CONFIG_GFX_WINDOWED_KEY "gfx.windowed"

View File

@ -9,13 +9,14 @@
#include <stdint.h>
#include <stdio.h>
#include "core/log.h"
#include "hook/com-proxy.h"
#include "hook/table.h"
#include "d3d9exhook/d3d9ex.h"
#include "util/defs.h"
#include "util/log.h"
#include "util/str.h"
#include "util/time.h"

View File

@ -19,6 +19,8 @@
#include "bemanitools/ddrio.h"
#include "core/log.h"
#include "ddrhook-util/_com4.h"
#include "hook/iohook.h"
@ -27,7 +29,6 @@
#include "util/defs.h"
#include "util/iobuf.h"
#include "util/log.h"
static struct ac_io_emu com4_ac_io_emu;
static struct ac_io_emu_hdxs com4_hdxs;

View File

@ -5,12 +5,13 @@
#include <stdbool.h>
#include "core/log.h"
#include "hook/com-proxy.h"
#include "hook/pe.h"
#include "hook/table.h"
#include "util/defs.h"
#include "util/log.h"
static HRESULT STDCALL my_DirectInput8Create(
HINSTANCE hinst,

View File

@ -14,10 +14,11 @@
#include "bemanitools/ddrio.h"
#include "core/log.h"
#include "hook/iohook.h"
#include "util/iobuf.h"
#include "util/log.h"
#include "util/str.h"
static HRESULT extio_open(struct irp *irp);

View File

@ -11,13 +11,14 @@
#include <stdint.h>
#include <stdio.h>
#include "core/log.h"
#include "hook/com-proxy.h"
#include "hook/table.h"
#include "ddrhook-util/gfx.h"
#include "util/defs.h"
#include "util/log.h"
#include "util/str.h"
#include "util/time.h"

View File

@ -2,13 +2,14 @@
#include <stdint.h>
#include "core/log.h"
#include "ddrhook-util/gfx.h"
#include "hook/pe.h"
#include "hook/table.h"
#include "util/defs.h"
#include "util/log.h"
#include "util/str.h"
static LRESULT(STDCALL *real_SendMessageW)(

View File

@ -7,12 +7,13 @@
#include <stdbool.h>
#include <wchar.h>
#include "core/log.h"
#include "ddrhook-util/monitor.h"
#include "hook/table.h"
#include "util/defs.h"
#include "util/log.h"
#include "util/str.h"
/* Link pointers */

View File

@ -7,11 +7,11 @@
#include "ddrhook-util/p3io.h"
#include "core/log.h"
#include "p3ioemu/emu.h"
#include "p3ioemu/uart.h"
#include "util/log.h"
extern bool _15khz;
extern bool standard_def;

View File

@ -15,10 +15,11 @@
#include "acioemu/addr.h"
#include "acioemu/emu.h"
#include "core/log.h"
#include "hook/iohook.h"
#include "util/defs.h"
#include "util/log.h"
#include "util/str.h"
static struct ac_io_emu spike_ac_io_emu;

View File

@ -12,12 +12,13 @@
#include <string.h>
#include <wchar.h>
#include "core/log.h"
#include "hook/iohook.h"
#include "util/crc.h"
#include "util/fs.h"
#include "util/iobuf.h"
#include "util/log.h"
#include "util/str.h"
#define USBMEM_DEVICE_COUNT 2

View File

@ -7,6 +7,8 @@ deplibs_ddrhook1 := \
avs \
libs_ddrhook1 := \
avs-util \
core \
acioemu \
cconfig \
ddrhook-util \

View File

@ -5,6 +5,9 @@
#include <stdio.h>
#include <string.h>
#include "core/log-bt.h"
#include "core/log.h"
#include "hook/iohook.h"
#include "hook/table.h"
@ -13,7 +16,6 @@
#include "ddrhook1/avs-boot.h"
#include "ddrhook1/filesystem.h"
#include "util/log.h"
#include "util/str.h"
static void (*real_avs_boot)(
@ -50,6 +52,11 @@ static const struct hook_symbol ddrhook1_avs_ea3_hook_syms[] = {
.link = (void **) &real_ea3_boot},
};
static AVS_LOG_WRITER(_avs_boot_log_writer, chars, nchars, ctx)
{
core_log_bt_direct_sink_write(chars, nchars);
}
static void avs_boot_replace_property_str(
struct property_node *node, const char *name, const char *val)
{
@ -115,7 +122,7 @@ static void my_avs_boot(
sz_std_heap,
avs_heap,
sz_avs_heap,
log_writer_debug,
_avs_boot_log_writer,
NULL);
}

View File

@ -2,9 +2,9 @@
#include "cconfig/cconfig-util.h"
#include "ddrhook1/config-ddrhook1.h"
#include "core/log.h"
#include "util/log.h"
#include "ddrhook1/config-ddrhook1.h"
#define DDRHOOK1_CONFIG_DDRHOOK1_USE_COM4_EMU_KEY "ddrhook1.use_com4_emu"
#define DDRHOOK1_CONFIG_DDRHOOK1_STANDARD_DEF_KEY "ddrhook1.standard_def"

View File

@ -2,9 +2,10 @@
#include "cconfig/cconfig-util.h"
#include "core/log.h"
#include "ddrhook1/config-eamuse.h"
#include "util/log.h"
#include "util/net.h"
#define DDRHOOK1_CONFIG_EAMUSE_SERVER_KEY "eamuse.server"

View File

@ -2,9 +2,9 @@
#include "cconfig/cconfig-util.h"
#include "ddrhook1/config-gfx.h"
#include "core/log.h"
#include "util/log.h"
#include "ddrhook1/config-gfx.h"
#define DDRHOOK1_CONFIG_GFX_WINDOWED_KEY "gfx.windowed"

View File

@ -2,11 +2,12 @@
#include "cconfig/cconfig-util.h"
#include "core/log.h"
#include "ddrhook1/config-security.h"
#include "security/mcode.h"
#include "util/log.h"
#include "util/net.h"
#define DDRHOOK1_CONFIG_SECURITY_MCODE_KEY "security.mcode"

View File

@ -2,11 +2,20 @@
#include <stdbool.h>
#include "avs-util/core-interop.h"
#include "bemanitools/ddrio.h"
#include "bemanitools/eamio.h"
#include "cconfig/cconfig-hook.h"
#include "core/log-bt-ext.h"
#include "core/log-bt.h"
#include "core/log-sink-debug.h"
#include "core/log.h"
#include "core/thread-crt.h"
#include "core/thread.h"
#include "ddrhook-util/_com4.h"
#include "ddrhook-util/extio.h"
#include "ddrhook-util/p3io.h"
@ -37,8 +46,6 @@
#include "util/cmdline.h"
#include "util/defs.h"
#include "util/log.h"
#include "util/thread.h"
#define DDRHOOK1_INFO_HEADER \
"ddrhook1 for DDR X" \
@ -68,6 +75,15 @@ static const struct hook_symbol init_hook_syms[] = {
},
};
static void _ddrhook1_log_init()
{
core_log_bt_ext_impl_set();
core_log_bt_ext_init_with_debug();
// TODO change log level support
core_log_bt_level_set(CORE_LOG_BT_LOG_LEVEL_MISC);
}
static DWORD STDCALL
my_GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize)
{
@ -155,7 +171,12 @@ my_GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize)
log_info("Initializing DDR IO backend");
ok = ddr_io_init(thread_create, thread_join, thread_destroy);
core_log_impl_assign(ddr_io_set_loggers);
ok = ddr_io_init(
core_thread_create_impl_get(),
core_thread_join_impl_get(),
core_thread_destroy_impl_get());
if (!ok) {
log_fatal("Couldn't initialize DDR IO backend");
@ -165,10 +186,12 @@ my_GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize)
if (config_ddrhook1.use_com4_emu) {
log_info("Initializing card reader backend");
eam_io_set_loggers(
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
core_log_impl_assign(eam_io_set_loggers);
ok = eam_io_init(thread_create, thread_join, thread_destroy);
ok = eam_io_init(
core_thread_create_impl_get(),
core_thread_join_impl_get(),
core_thread_destroy_impl_get());
if (!ok) {
log_fatal("Couldn't initialize card reader backend");
@ -185,7 +208,12 @@ skip:
BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx)
{
if (reason == DLL_PROCESS_ATTACH) {
log_to_writer(log_writer_debug, NULL);
// Use AVS APIs
avs_util_core_interop_thread_avs_impl_set();
// TODO init debug logging but with avs available? why not use avs
// logging?
_ddrhook1_log_init();
hook_table_apply(
NULL, "kernel32.dll", init_hook_syms, lengthof(init_hook_syms));

View File

@ -6,10 +6,11 @@
#include <stdlib.h>
#include <string.h>
#include "core/log.h"
#include "hook/table.h"
#include "util/defs.h"
#include "util/log.h"
#include "util/mem.h"
#include "util/str.h"

View File

@ -1,3 +1,5 @@
#include "core/log.h"
#include "ddrhook1/master.h"
#include "ddrhook-util/dinput.h"
@ -9,7 +11,6 @@
#include "p3ioemu/devmgr.h"
#include "util/defs.h"
#include "util/log.h"
static HMODULE(STDCALL *real_LoadLibraryA)(const char *name);
static BOOL(STDCALL *real_IsDebuggerPresent)();

View File

@ -4,6 +4,8 @@ deplibs_ddrhook2 := \
avs \
libs_ddrhook2 := \
avs-util \
core \
acioemu \
ddrhook-util \
p3ioemu \

View File

@ -2,9 +2,14 @@
#include <stdbool.h>
#include "avs-util/core-interop.h"
#include "bemanitools/ddrio.h"
#include "bemanitools/eamio.h"
#include "core/log.h"
#include "core/thread.h"
#include "ddrhook-util/_com4.h"
#include "ddrhook-util/extio.h"
#include "ddrhook-util/gfx.h"
@ -25,7 +30,6 @@
#include "util/cmdline.h"
#include "util/defs.h"
#include "util/log.h"
static bool my_dll_entry_init(char *sidcode, struct property_node *param);
static bool my_dll_entry_main(void);
@ -119,10 +123,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
log_info("Initializing DDR IO backend");
ddr_io_set_loggers(
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
core_log_impl_assign(ddr_io_set_loggers);
ok = ddr_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy);
ok = ddr_io_init(
core_thread_create_impl_get(),
core_thread_join_impl_get(),
core_thread_destroy_impl_get());
if (!ok) {
return false;
@ -131,11 +137,12 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
if (com4) {
log_info("Initializing card reader backend");
eam_io_set_loggers(
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
core_log_impl_assign(eam_io_set_loggers);
ok =
eam_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy);
ok = eam_io_init(
core_thread_create_impl_get(),
core_thread_join_impl_get(),
core_thread_destroy_impl_get());
if (!ok) {
return false;
@ -174,8 +181,9 @@ BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx)
goto end;
}
log_to_external(
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
// Use AVS APIs
avs_util_core_interop_thread_avs_impl_set();
avs_util_core_interop_log_avs_impl_set();
app_hook_init(my_dll_entry_init, my_dll_entry_main);

View File

@ -1,3 +1,5 @@
#include "core/log.h"
#include "ddrhook2/master.h"
#include "ddrhook-util/dinput.h"
@ -10,7 +12,6 @@
#include "p3ioemu/devmgr.h"
#include "util/defs.h"
#include "util/log.h"
static HMODULE(STDCALL *real_LoadLibraryA)(const char *name);

View File

@ -3,6 +3,7 @@ dlls += ddrio-async
ldflags_ddrio-async:= \
libs_ddrio-async := \
core \
util \
src_ddrio-async := \

View File

@ -11,8 +11,9 @@
#include "bemanitools/ddrio.h"
#include "util/log.h"
#include "util/thread.h"
#include "core/log.h"
#include "core/thread.h"
#include "util/time.h"
typedef void (*ddr_io_set_loggers_t)(
@ -154,7 +155,7 @@ void ddr_io_set_loggers(
_log_formatter_warning = warning;
_log_formatter_fatal = fatal;
log_to_external(misc, info, warning, fatal);
core_log_impl_set(misc, info, warning, fatal);
}
bool ddr_io_init(
@ -164,6 +165,8 @@ bool ddr_io_init(
{
log_info("Loading ddrio-async-child.dll as child ddrio library...");
core_thread_impl_set(thread_create, thread_join, thread_destroy);
_child_ddr_io_module = LoadLibraryA("ddrio-async-child.dll");
if (_child_ddr_io_module == NULL) {

View File

@ -5,6 +5,7 @@ ldflags_ddrio-mm:= \
-lsetupapi \
libs_ddrio-mm := \
core \
mm \
util \

View File

@ -7,11 +7,12 @@
#include "bemanitools/ddrio.h"
#include "core/log.h"
#include "mm/mm.h"
#include "util/cmdline.h"
#include "util/defs.h"
#include "util/log.h"
#include "util/mem.h"
struct ddr_bittrans {
@ -117,7 +118,7 @@ void ddr_io_set_loggers(
log_formatter_t warning,
log_formatter_t fatal)
{
log_to_external(misc, info, warning, fatal);
core_log_impl_set(misc, info, warning, fatal);
}
bool ddr_io_init(

View File

@ -4,6 +4,7 @@ ldflags_ddrio-p3io:= \
-lsetupapi \
libs_ddrio-p3io := \
core \
cconfig \
extio \
extiodrv \

View File

@ -1,6 +1,6 @@
#include "cconfig/cconfig-util.h"
#include "util/log.h"
#include "core/log.h"
#include "config.h"

View File

@ -10,15 +10,15 @@
#include "cconfig/cconfig-main.h"
#include "core/log.h"
#include "core/thread.h"
#include "extiodrv/device.h"
#include "extiodrv/extio.h"
#include "p3iodrv/ddr.h"
#include "p3iodrv/device.h"
#include "util/log.h"
#include "util/thread.h"
#include "config.h"
static struct ddrio_p3io_config _ddr_io_p3io_config;
@ -255,7 +255,7 @@ void ddr_io_set_loggers(
log_formatter_t warning,
log_formatter_t fatal)
{
log_to_external(misc, info, warning, fatal);
core_log_impl_set(misc, info, warning, fatal);
}
static void _ddr_io_config_init(struct ddrio_p3io_config *config_ddrio_p3io)

View File

@ -5,6 +5,7 @@ deplibs_ddrio-smx := \
SMX \
libs_ddrio-smx := \
core \
geninput \
util \

View File

@ -6,11 +6,12 @@
#include "bemanitools/ddrio.h"
#include "bemanitools/input.h"
#include "core/log.h"
#include "imports/SMX.h"
#include "imports/avs.h"
#include "util/defs.h"
#include "util/log.h"
struct ddr_io_smx_pad_map {
int pad_no;
@ -99,7 +100,7 @@ void ddr_io_set_loggers(
log_formatter_t warning,
log_formatter_t fatal)
{
log_to_external(misc, info, warning, fatal);
core_log_impl_set(misc, info, warning, fatal);
input_set_loggers(misc, info, warning, fatal);
/* We would need a log server thread to accept log messages from SMX, since

View File

@ -4,7 +4,7 @@
#include "bemanitools/input.h"
#include "util/log.h"
#include "core/log.h"
void ddr_io_set_loggers(
log_formatter_t misc,

View File

@ -1,6 +1,7 @@
exes += ddriotest \
libs_ddriotest := \
core \
ddrio \
util \

View File

@ -7,32 +7,41 @@
#include "bemanitools/ddrio.h"
#include "util/log.h"
#include "util/thread.h"
#include "core/log-bt-ext.h"
#include "core/log-bt.h"
#include "core/log.h"
#include "core/thread-crt-ext.h"
#include "core/thread-crt.h"
#include "core/thread.h"
int main(int argc, char **argv)
{
enum log_level log_level;
enum core_log_bt_log_level log_level;
log_level = LOG_LEVEL_FATAL;
log_level = CORE_LOG_BT_LOG_LEVEL_FATAL;
for (int i = 0; i < argc; i++) {
if (!strcmp(argv[i], "-v")) {
log_level = LOG_LEVEL_WARNING;
log_level = CORE_LOG_BT_LOG_LEVEL_WARNING;
} else if (!strcmp(argv[i], "-vv")) {
log_level = LOG_LEVEL_INFO;
log_level = CORE_LOG_BT_LOG_LEVEL_INFO;
} else if (!strcmp(argv[i], "-vvv")) {
log_level = LOG_LEVEL_MISC;
log_level = CORE_LOG_BT_LOG_LEVEL_MISC;
}
}
log_to_writer(log_writer_stderr, NULL);
log_set_level(log_level);
core_thread_crt_ext_impl_set();
core_log_bt_ext_impl_set();
ddr_io_set_loggers(
log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
core_log_bt_ext_init_with_stderr();
core_log_bt_level_set(log_level);
if (!ddr_io_init(crt_thread_create, crt_thread_join, crt_thread_destroy)) {
core_log_impl_assign(ddr_io_set_loggers);
if (!ddr_io_init(
core_thread_create_impl_get(),
core_thread_join_impl_get(),
core_thread_destroy_impl_get())) {
fprintf(stderr, "Initializing ddrio failed\n");
return -1;
}

View File

@ -8,12 +8,13 @@
#include <stdbool.h>
#include "core/log.h"
#include "hook/com-proxy.h"
#include "hook/pe.h"
#include "hook/table.h"
#include "util/defs.h"
#include "util/log.h"
static HRESULT STDCALL my_DirectInput8Create(
HINSTANCE hinst,

View File

@ -2,6 +2,7 @@ dlls += \
eamio-icca \
libs_eamio-icca := \
core \
aciodrv \
aciomgr \
cconfig \

View File

@ -2,8 +2,6 @@
#include "eamio-icca/config-icc.h"
#include "util/log.h"
#define EAMIO_ICCA_CONFIG_ICC_PORT_KEY "icc.port"
#define EAMIO_ICCA_CONFIG_ICC_BAUD_KEY "icc.baud"

View File

@ -14,11 +14,11 @@
#include "bemanitools/eamio.h"
#include "core/log.h"
#include "cconfig/cconfig-main.h"
#include "eamio-icca/config-icc.h"
#include "util/log.h"
#define IDLE_RESPONSES_BETWEEN_FELICA_POLLS 5
#define NUMBER_OF_EMULATED_READERS 2
#define INVALID_NODE_ID -1
@ -60,7 +60,7 @@ void eam_io_set_loggers(
{
aciomgr_set_loggers(misc, info, warning, fatal);
log_to_external(misc, info, warning, fatal);
core_log_impl_set(misc, info, warning, fatal);
}
// all of these are referred to internally as ICCA

View File

@ -1,5 +1,5 @@
dlls += eamio
libs_eamio := geninput util
libs_eamio := core geninput util
src_eamio := \
eam-api.c \
eam-impl.c \

View File

@ -11,14 +11,15 @@
#include "bemanitools/eamio.h"
#include "bemanitools/input.h"
#include "core/log.h"
#include "core/thread.h"
#include "eamio/eam-config.h"
#include "eamio/eam-impl.h"
#include "eamio/eam-s11n.h"
#include "util/fs.h"
#include "util/log.h"
#include "util/msg-thread.h"
#include "util/thread.h"
static void eam_handle_hotplug_msg(WPARAM wparam, const DEV_BROADCAST_HDR *hdr);
static FILE *eam_io_config_open(const char *mode);
@ -108,14 +109,14 @@ void eam_io_set_loggers(
log_formatter_t warning,
log_formatter_t fatal)
{
log_to_external(misc, info, warning, fatal);
core_log_impl_set(misc, info, warning, fatal);
}
bool eam_io_init(
thread_create_t create, thread_join_t join, thread_destroy_t destroy)
{
input_init(create, join, destroy);
thread_api_init(create, join, destroy);
core_thread_impl_set(create, join, destroy);
eam_io_config_load();
msg_thread_init(eam_hinst);

View File

@ -9,6 +9,8 @@
#include "bemanitools/eamio.h"
#include "core/log.h"
#include "eamio/eam-impl.h"
#include "geninput/hid-mgr.h"
@ -16,7 +18,6 @@
#include "util/defs.h"
#include "util/fs.h"
#include "util/hex.h"
#include "util/log.h"
#include "util/mem.h"
#include "util/str.h"

View File

@ -1,6 +1,7 @@
exes += eamiotest
libs_eamiotest := \
core \
eamio \
util \

View File

@ -7,20 +7,29 @@
#include "bemanitools/eamio.h"
#include "util/log.h"
#include "util/thread.h"
#include "core/log-bt-ext.h"
#include "core/log-bt.h"
#include "core/log.h"
#include "core/thread-crt-ext.h"
#include "core/thread-crt.h"
#include "core/thread.h"
/**
* Tool to test your implementations of eamio.
*/
int main(int argc, char **argv)
{
log_to_writer(log_writer_stdout, NULL);
core_thread_crt_ext_impl_set();
core_log_bt_ext_impl_set();
eam_io_set_loggers(
log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
core_log_bt_ext_init_with_stdout();
if (!eam_io_init(crt_thread_create, crt_thread_join, crt_thread_destroy)) {
core_log_impl_assign(eam_io_set_loggers);
if (!eam_io_init(
core_thread_create_impl_get(),
core_thread_join_impl_get(),
core_thread_destroy_impl_get())) {
printf("Initializing eamio failed\n");
return -1;
}

View File

@ -2,7 +2,7 @@
#include "device.h"
#include "util/log.h"
#include "core/log.h"
HRESULT extiodrv_device_open(const char *port, HANDLE *handle)
{

View File

@ -2,7 +2,7 @@
#include "extio.h"
#include "util/log.h"
#include "core/log.h"
// static uint8_t _extiodrv_extio_sensor_read_mode_map[5] = {
// 1, // all

View File

@ -3,6 +3,7 @@ exes += extiotest \
libs_extiotest := \
extiodrv \
extio \
core \
util \
src_extiotest := \

View File

@ -5,12 +5,15 @@
#include <windows.h>
#include "extiodrv/extio.h"
#include "core/log-bt.h"
#include "core/log-sink-std.h"
#include "core/log.h"
#include "util/log.h"
#include "extiodrv/extio.h"
int main(int argc, char **argv)
{
struct core_log_sink log_sink;
HRESULT hr;
const char *port;
HANDLE handle;
@ -22,8 +25,9 @@ int main(int argc, char **argv)
fprintf(stderr, " COM_PORT: For example COM1\n");
}
log_to_writer(log_writer_stderr, NULL);
log_set_level(LOG_LEVEL_MISC);
core_log_sink_std_err_open(true, &log_sink);
core_log_bt_init(&log_sink);
core_log_bt_level_set(CORE_LOG_BT_LOG_LEVEL_MISC);
port = argv[1];

View File

@ -9,6 +9,8 @@
#include <string.h>
#include "core/log.h"
#include "ezusb/ezusbsys2.h"
#include "ezusb/util.h"
@ -25,7 +27,6 @@
#include "util/fs.h"
#include "util/hex.h"
#include "util/iobuf.h"
#include "util/log.h"
#include "util/str.h"
// The max buffer size in iidx's ezusb client library is 4096 for the initial

View File

@ -1,11 +1,11 @@
#define LOG_MODULE "ezusb-emu-node-coin"
#include "core/log.h"
#include "ezusb-emu/node-coin.h"
#include "ezusb-iidx/coin-cmd.h"
#include "util/log.h"
static uint8_t ezusb_iidx_emu_node_coin_mode = 0;
uint8_t ezusb_iidx_emu_node_coin_process_cmd(

View File

@ -2,12 +2,12 @@
#include <string.h>
#include "core/log.h"
#include "ezusb-emu/node-eeprom.h"
#include "ezusb-iidx/eeprom-cmd.h"
#include "util/log.h"
/* not verified, but we got calls with 3 pages only so far */
#define EEPROM_NPAGES 3

View File

@ -2,11 +2,11 @@
#include <string.h>
#include "core/log.h"
#include "ezusb-emu/node-security-mem.h"
#include "ezusb-iidx/secmem-cmd.h"
#include "util/log.h"
#define SECURITY2_NPAGES 5
/* Starting GOLD with the new IO2 (C02 is not affected), the game does not

View File

@ -2,6 +2,8 @@
#include <string.h>
#include "core/log.h"
#include "ezusb-emu/node-eeprom.h"
#include "ezusb-emu/node-security-mem.h"
#include "ezusb-emu/node-security-plug.h"
@ -11,8 +13,6 @@
#include "security/rp2.h"
#include "security/util.h"
#include "util/log.h"
static struct security_mcode ezusb_iidx_emu_node_security_plug_boot_version;
static uint32_t ezusb_iidx_emu_node_security_plug_boot_seeds[3];

Some files were not shown because too many files have changed in this diff Show More