add default port fallback for vfd

This commit is contained in:
kyoubate-haruka 2024-08-23 17:20:05 +02:00
parent 54cbbffae9
commit e6794807a6
9 changed files with 16 additions and 11 deletions

View File

@ -50,7 +50,7 @@ HRESULT vfd_handle_create_char2(struct const_iobuf* reader, struct iobuf* writer
static bool utf_enabled;
HRESULT vfd_hook_init(struct vfd_config *cfg)
HRESULT vfd_hook_init(struct vfd_config *cfg, int default_port)
{
if (!cfg->enable){
return S_FALSE;
@ -58,8 +58,13 @@ HRESULT vfd_hook_init(struct vfd_config *cfg)
utf_enabled = cfg->utf_conversion;
dprintf("VFD: enabling (port=%d)\n", cfg->port);
uart_init(&vfd_uart, cfg->port);
int port = cfg->port;
if (port == 0){
port = default_port;
}
dprintf("VFD: enabling (port=%d)\n", port);
uart_init(&vfd_uart, port);
vfd_uart.written.bytes = vfd_written;
vfd_uart.written.nbytes = sizeof(vfd_written);
vfd_uart.readable.bytes = vfd_readable;

View File

@ -9,5 +9,5 @@ struct vfd_config {
};
HRESULT vfd_hook_init(struct vfd_config *cfg);
HRESULT vfd_hook_init(struct vfd_config *cfg, int default_port);

View File

@ -146,7 +146,7 @@ static DWORD CALLBACK chusan_pre_startup(void)
unsigned int first_port = is_cvt ? 2 : 20;
if (!is_cvt) {
hr = vfd_hook_init(&chusan_hook_cfg.vfd);
hr = vfd_hook_init(&chusan_hook_cfg.vfd, 2);
if (FAILED(hr)) {
goto fail;

View File

@ -84,7 +84,7 @@ static DWORD CALLBACK cm_pre_startup(void)
goto fail;
}
hr = vfd_hook_init(&cm_hook_cfg.vfd);
hr = vfd_hook_init(&cm_hook_cfg.vfd, 2);
if (FAILED(hr)) {
goto fail;

View File

@ -84,7 +84,7 @@ static DWORD CALLBACK fgo_pre_startup(void)
goto fail;
}
hr = vfd_hook_init(&fgo_hook_cfg.vfd);
hr = vfd_hook_init(&fgo_hook_cfg.vfd, 1);
if (FAILED(hr)) {
goto fail;

View File

@ -79,7 +79,7 @@ static DWORD CALLBACK mai2_pre_startup(void)
goto fail;
}
hr = vfd_hook_init(&mai2_hook_cfg.vfd);
hr = vfd_hook_init(&mai2_hook_cfg.vfd, 2);
if (FAILED(hr)) {
goto fail;

View File

@ -77,7 +77,7 @@ static DWORD CALLBACK mercury_pre_startup(void)
goto fail;
}
hr = vfd_hook_init(&mercury_hook_cfg.vfd);
hr = vfd_hook_init(&mercury_hook_cfg.vfd, 2);
if (FAILED(hr)) {
goto fail;

View File

@ -93,7 +93,7 @@ static DWORD CALLBACK mu3_pre_startup(void)
goto fail;
}
hr = vfd_hook_init(&mu3_hook_cfg.vfd);
hr = vfd_hook_init(&mu3_hook_cfg.vfd, 2);
if (FAILED(hr)) {
goto fail;

View File

@ -79,7 +79,7 @@ static DWORD CALLBACK swdc_pre_startup(void)
goto fail;
}
hr = vfd_hook_init(&swdc_hook_cfg.vfd);
hr = vfd_hook_init(&swdc_hook_cfg.vfd, 4);
if (FAILED(hr)) {
return hr;