Improve JVS bus life cycle handling

This commit is contained in:
Tau
2019-11-03 13:01:03 -05:00
parent 93fcdf8f6d
commit 0e1cfb66db
24 changed files with 164 additions and 65 deletions

View File

@ -45,12 +45,7 @@ static DWORD CALLBACK diva_pre_startup(void)
"AAV0",
diva_hook_mod);
amex_hook_init(&diva_hook_cfg.amex);
if (diva_hook_cfg.amex.jvs.enable) {
diva_jvs_init();
}
amex_hook_init(&diva_hook_cfg.amex, diva_jvs_init);
sg_reader_hook_init(&diva_hook_cfg.aime, 10);
slider_hook_init();

View File

@ -28,10 +28,25 @@ static const struct io3_ops diva_jvs_io3_ops = {
static struct io3 diva_jvs_io3;
void diva_jvs_init(void)
HRESULT diva_jvs_init(struct jvs_node **out)
{
HRESULT hr;
assert(out != NULL);
dprintf("JVS I/O: Starting Diva backend DLL\n");
hr = diva_io_jvs_init();
if (FAILED(hr)) {
dprintf("JVS I/O: Backend error, I/O disconnected: %x\n", (int) hr);
return hr;
}
io3_init(&diva_jvs_io3, NULL, &diva_jvs_io3_ops, NULL);
jvs_attach(&diva_jvs_io3.jvs);
*out = io3_to_jvs_node(&diva_jvs_io3);
return S_OK;
}
static void diva_jvs_read_switches(void *ctx, struct io3_switch_state *out)

View File

@ -1,3 +1,7 @@
#pragma once
void diva_jvs_init(void);
#include <windows.h>
#include "jvs/jvs-bus.h"
HRESULT diva_jvs_init(struct jvs_node **root);

View File

@ -73,6 +73,17 @@ static HRESULT slider_handle_irp_locked(struct irp *irp)
struct iobuf req_iobuf;
HRESULT hr;
if (irp->op == IRP_OP_OPEN) {
dprintf("Diva slider: Starting backend DLL\n");
hr = diva_io_jvs_init();
if (FAILED(hr)) {
dprintf("Diva slider: Backend DLL error: %x\n", (int) hr);
return hr;
}
}
hr = uart_handle_irp(&slider_uart, irp);
if (FAILED(hr) || irp->op != IRP_OP_WRITE) {