From be9d369a915348c67760b1387f9e1eab51f6b193 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 12 Jul 2020 20:20:06 +0200 Subject: [PATCH] A number of bugfixes. --- src/codegen_new/codegen_accumulate.c | 2 +- src/include/86box/network.h | 2 ++ src/network/network.c | 15 ++++++++++++++- src/pc.c | 2 ++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/codegen_new/codegen_accumulate.c b/src/codegen_new/codegen_accumulate.c index 88ab1c0f7..3b71d78d7 100644 --- a/src/codegen_new/codegen_accumulate.c +++ b/src/codegen_new/codegen_accumulate.c @@ -17,7 +17,7 @@ static struct [ACCREG_cycles] = {0, IREG_cycles}, }; -void codegen_accumulate(r_data_t *ir, int acc_reg, int delta) +void codegen_accumulate(ir_data_t *ir, int acc_reg, int delta) { acc_regs[acc_reg].count += delta; diff --git a/src/include/86box/network.h b/src/include/86box/network.h index f4e653a33..fb69e398f 100644 --- a/src/include/86box/network.h +++ b/src/include/86box/network.h @@ -141,6 +141,8 @@ extern const device_t *network_card_getdevice(int); extern void network_set_wait(int wait); extern int network_get_wait(void); +extern int network_timer_stop(void); + extern void network_queue_put(int tx, void *priv, uint8_t *data, int len); #ifdef __cplusplus diff --git a/src/network/network.c b/src/network/network.c index 77fbfa1ae..186baee15 100644 --- a/src/network/network.c +++ b/src/network/network.c @@ -122,6 +122,7 @@ int nic_do_log = ENABLE_NIC_LOG; static volatile int net_wait = 0; static mutex_t *network_mutex; static uint8_t *network_mac; +static uint8_t network_timer_active = 0; static pc_timer_t network_rx_queue_timer; static netpkt_t *first_pkt[2] = { NULL, NULL }, *last_pkt[2] = { NULL, NULL }; @@ -354,6 +355,18 @@ network_attach(void *dev, uint8_t *mac, NETRXCB rx, NETWAITCB wait, NETSETLINKST timer_add(&network_rx_queue_timer, network_rx_queue, NULL, 0); /* 10 mbps. */ timer_on_auto(&network_rx_queue_timer, 0.762939453125 * 2.0); + network_timer_active = 1; +} + + +/* Stop the network timer. */ +void +network_timer_stop(void) +{ + if (network_timer_active) { + timer_stop(&network_rx_queue_timer); + network_timer_active = 0; + } } @@ -361,7 +374,7 @@ network_attach(void *dev, uint8_t *mac, NETRXCB rx, NETWAITCB wait, NETSETLINKST void network_close(void) { - timer_stop(&network_rx_queue_timer); + network_timer_stop(); /* If already closed, do nothing. */ if (network_mutex == NULL) return; diff --git a/src/pc.c b/src/pc.c index 0a7ea9b14..11dc209e2 100644 --- a/src/pc.c +++ b/src/pc.c @@ -681,6 +681,8 @@ pc_reset_hard_close(void) { ui_sb_set_ready(0); + network_timer_close(); + /* Turn off timer processing to avoid potential segmentation faults. */ timer_close();