diff --git a/src/devices/disk/hdc_esdi_at.c b/src/devices/disk/hdc_esdi_at.c index 691823c..e474ef8 100644 --- a/src/devices/disk/hdc_esdi_at.c +++ b/src/devices/disk/hdc_esdi_at.c @@ -8,7 +8,7 @@ * * Driver for the ESDI controller (WD1007-vse1) for PC/AT. * - * Version: @(#)hdc_esdi_at.c 1.0.15 2019/04/11 + * Version: @(#)hdc_esdi_at.c 1.0.16 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -820,7 +820,7 @@ wd1007vse1_init(const device_t *info, UNUSED(void *parent)) io_sethandler(0x03f6, 1, NULL, NULL, NULL, hdc_write, NULL, NULL, dev); - timer_add(hdc_callback, &dev->callback, &dev->callback, dev); + timer_add(hdc_callback, dev, &dev->callback, &dev->callback); return(dev); } diff --git a/src/devices/disk/hdc_esdi_mca.c b/src/devices/disk/hdc_esdi_mca.c index 56e8916..8976e8a 100644 --- a/src/devices/disk/hdc_esdi_mca.c +++ b/src/devices/disk/hdc_esdi_mca.c @@ -52,7 +52,7 @@ * however, are auto-configured by the system software as * shown above. * - * Version: @(#)hdc_esdi_mca.c 1.0.16 2019/04/09 + * Version: @(#)hdc_esdi_mca.c 1.0.17 2019/04/25 * * Authors: Fred N. van Kempen, * Sarah Walker, @@ -1138,7 +1138,7 @@ esdi_init(const device_t *info, UNUSED(void *parent)) dev->status = STATUS_BUSY; /* Set the reply timer. */ - timer_add(hdc_callback, &dev->callback, &dev->callback, dev); + timer_add(hdc_callback, dev, &dev->callback, &dev->callback); return(dev); } diff --git a/src/devices/disk/hdc_ide_ata.c b/src/devices/disk/hdc_ide_ata.c index f54a3f6..42429bd 100644 --- a/src/devices/disk/hdc_ide_ata.c +++ b/src/devices/disk/hdc_ide_ata.c @@ -2322,7 +2322,8 @@ ide_ter_init(const device_t *info, UNUSED(void *parent)) ide_set_handlers(2); - timer_add(ide_callback, &ide_boards[2]->callback, &ide_boards[2]->callback, ide_boards[2]); + timer_add(ide_callback, ide_boards[2], + &ide_boards[2]->callback, &ide_boards[2]->callback); ide_board_init(2); @@ -2354,7 +2355,8 @@ ide_qua_init(const device_t *info, UNUSED(void *parent)) ide_set_handlers(3); - timer_add(ide_callback, &ide_boards[3]->callback, &ide_boards[3]->callback, ide_boards[3]); + timer_add(ide_callback, ide_boards[3], + &ide_boards[3]->callback, &ide_boards[3]->callback); ide_board_init(3); @@ -2394,8 +2396,8 @@ ide_xtide_init(void) memset(ide_boards[0], 0, sizeof(ide_board_t)); ide_boards[0]->cur_dev = 0; - timer_add(ide_callback, &ide_boards[0]->callback, &ide_boards[0]->callback, - ide_boards[0]); + timer_add(ide_callback, ide_boards[0], + &ide_boards[0]->callback, &ide_boards[0]->callback); ide_board_init(0); } @@ -2471,8 +2473,8 @@ ide_init(const device_t *info, UNUSED(void *parent)) ide_base_main[0] = 0x1f0; ide_side_main[0] = 0x3f6; ide_set_handlers(0); - timer_add(ide_callback, &ide_boards[0]->callback, &ide_boards[0]->callback, - ide_boards[0]); + timer_add(ide_callback, ide_boards[0], + &ide_boards[0]->callback, &ide_boards[0]->callback); DEBUG("Callback 0 pointer: %08X\n", &ide_boards[0]->callback); ide_board_init(0); @@ -2490,8 +2492,8 @@ ide_init(const device_t *info, UNUSED(void *parent)) ide_base_main[1] = 0x170; ide_side_main[1] = 0x376; ide_set_handlers(1); - timer_add(ide_callback, &ide_boards[1]->callback, &ide_boards[1]->callback, - ide_boards[1]); + timer_add(ide_callback, ide_boards[1], + &ide_boards[1]->callback, &ide_boards[1]->callback); DEBUG("Callback 1 pointer: %08X\n", &ide_boards[1]->callback); ide_board_init(1); diff --git a/src/devices/disk/hdc_ide_xta.c b/src/devices/disk/hdc_ide_xta.c index ce222e7..68e07eb 100644 --- a/src/devices/disk/hdc_ide_xta.c +++ b/src/devices/disk/hdc_ide_xta.c @@ -46,7 +46,7 @@ * * NOTE: The XTA interface is 0-based for sector numbers !! * - * Version: @(#)hdc_ide_xta.c 1.0.13 2019/04/11 + * Version: @(#)hdc_ide_xta.c 1.0.14 2019/04/25 * * Author: Fred N. van Kempen, * @@ -1104,7 +1104,7 @@ xta_init(const device_t *info, UNUSED(void *parent)) dev->rom_addr, 0x2000, 0x1fff, 0, MEM_MAPPING_EXTERNAL); /* Create a timer for command delays. */ - timer_add(hdc_callback, &dev->callback, &dev->callback, dev); + timer_add(hdc_callback, dev, &dev->callback, &dev->callback); return(dev); } diff --git a/src/devices/disk/hdc_st506_at.c b/src/devices/disk/hdc_st506_at.c index e4697e4..bfd2873 100644 --- a/src/devices/disk/hdc_st506_at.c +++ b/src/devices/disk/hdc_st506_at.c @@ -12,7 +12,7 @@ * based design. Most cards were WD1003-WA2 or -WAH, where the * -WA2 cards had a floppy controller as well (to save space.) * - * Version: @(#)hdc_st506_at.c 1.0.14 2019/04/11 + * Version: @(#)hdc_st506_at.c 1.0.15 2019/04/25 * * Authors: Fred N. van Kempen, * Sarah Walker, @@ -731,7 +731,7 @@ st506_init(const device_t *info, UNUSED(void *parent)) io_sethandler(0x03f6, 1, NULL, NULL, NULL, hdc_write, NULL, NULL, dev); - timer_add(do_callback, &dev->callback, &dev->callback, dev); + timer_add(do_callback, dev, &dev->callback, &dev->callback); return(dev); } diff --git a/src/devices/disk/hdc_st506_xt.c b/src/devices/disk/hdc_st506_xt.c index 884180e..e760e82 100644 --- a/src/devices/disk/hdc_st506_xt.c +++ b/src/devices/disk/hdc_st506_xt.c @@ -41,7 +41,7 @@ * Since all controllers (including the ones made by DTC) use * (mostly) the same API, we keep them all in this module. * - * Version: @(#)hdc_st506_xt.c 1.0.18 2019/04/20 + * Version: @(#)hdc_st506_xt.c 1.0.19 2019/04/25 * * Authors: Fred N. van Kempen, * Sarah Walker, @@ -1537,7 +1537,7 @@ st506_init(const device_t *info, UNUSED(void *parent)) st506_read,NULL,NULL, st506_write,NULL,NULL, dev); /* Add the timer. */ - timer_add(st506_callback, &dev->callback, &dev->callback, dev); + timer_add(st506_callback, dev, &dev->callback, &dev->callback); INFO("ST506: %s (I/O=%03X, IRQ=%i, DMA=%i, BIOS @0x%06lX, size %lu)\n", info->name,dev->base,dev->irq,dev->dma, dev->bios_addr,dev->bios_size); diff --git a/src/devices/disk/hdc_xtide.c b/src/devices/disk/hdc_xtide.c index 1b8a9ed..2ad61fe 100644 --- a/src/devices/disk/hdc_xtide.c +++ b/src/devices/disk/hdc_xtide.c @@ -24,7 +24,7 @@ * FIXME: Make sure this works with the new IDE stuff, the AT and PS/2 * controllers do not have dev->ide set to anything... * - * Version: @(#)hdc_xtide.c 1.0.11 2019/04/09 + * Version: @(#)hdc_xtide.c 1.0.12 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, diff --git a/src/devices/floppy/fdc.c b/src/devices/floppy/fdc.c index b9158d4..86fdb2d 100644 --- a/src/devices/floppy/fdc.c +++ b/src/devices/floppy/fdc.c @@ -9,7 +9,7 @@ * Implementation of the NEC uPD-765 and compatible floppy disk * controller. * - * Version: @(#)fdc.c 1.0.20 2019/04/11 + * Version: @(#)fdc.c 1.0.21 2019/04/25 * * Authors: Miran Grca, * Sarah Walker, @@ -2292,13 +2292,14 @@ fdc_init(const device_t *info, UNUSED(void *parent)) fdc->irq = 6; if (fdc->flags & FDC_FLAG_PCJR) - timer_add(fdc_watchdog_poll, &fdc->watchdog_timer, &fdc->watchdog_timer, fdc); + timer_add(fdc_watchdog_poll, fdc, + &fdc->watchdog_timer, &fdc->watchdog_timer); else fdc->dma_ch = 2; DEBUG("FDC: %04X (flags: %08X)\n", fdc->base_address, fdc->flags); - timer_add(fdc_callback, &fdc->time, &fdc->time, fdc); + timer_add(fdc_callback, fdc, &fdc->time, &fdc->time); /* FIXME: should be handled through table. */ d86f_set_fdc(fdc); diff --git a/src/devices/input/game/js_sw_pad.c b/src/devices/input/game/js_sw_pad.c index d09d02b..78bdfb3 100644 --- a/src/devices/input/game/js_sw_pad.c +++ b/src/devices/input/game/js_sw_pad.c @@ -29,12 +29,12 @@ * - Some DOS stuff will write to 0x201 while a packet is * being transferred. This seems to be ignored. * - * Version: @(#)js_sw_pad.c 1.0.9 2018/09/22 + * Version: @(#)js_sw_pad.c 1.0.10 2019/04/25 * * Authors: Fred N. van Kempen, * Sarah Walker, * - * Copyright 2018 Fred N. van Kempen. + * Copyright 2018,2019 Fred N. van Kempen. * Copyright 2008-2018 Sarah Walker. * * This program is free software; you can redistribute it and/or modify @@ -137,8 +137,8 @@ sw_init(void) sw = (sw_data *)mem_alloc(sizeof(sw_data)); memset(sw, 0x00, sizeof(sw_data)); - timer_add(timer_over, &sw->poll_time, &sw->poll_time, sw); - timer_add(trigger_timer_over, &sw->trigger_time, &sw->trigger_time, sw); + timer_add(timer_over, sw, &sw->poll_time, &sw->poll_time); + timer_add(trigger_timer_over, sw, &sw->trigger_time, &sw->trigger_time); return(sw); } diff --git a/src/devices/input/keyboard_at.c b/src/devices/input/keyboard_at.c index 704d4fb..9f918a0 100644 --- a/src/devices/input/keyboard_at.c +++ b/src/devices/input/keyboard_at.c @@ -11,7 +11,7 @@ * NOTE: Several changes to disable Mode1 for now, as this breaks * the TSX32 operating system. More cleanups needed.. * - * Version: @(#)keyboard_at.c 1.0.23 2019/04/22 + * Version: @(#)keyboard_at.c 1.0.24 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -62,6 +62,9 @@ #include "../../plat.h" #include "keyboard.h" +#undef DEBUG +#define DEBUG INFO + //FIXME: get rid of this! #include "../../machines/m_tosh3100e.h" @@ -101,6 +104,7 @@ #define KBC_VEN_QUADTEL 0x0c #define KBC_VEN_TOSHIBA 0x10 #define KBC_VEN_XI8088 0x14 +#define KBC_VEN_ACER 0x18 #define KBC_VEN_MASK 0x1c @@ -1142,6 +1146,64 @@ kbd_write64_generic(void *p, uint8_t val) } +static uint8_t +kbd_write60_acer(void *p, uint8_t val) +{ + atkbd_t *kbd = (atkbd_t *) p; + +INFO("ACER: write60(%02x, %02x)\n", kbd->command, val); + switch(kbd->command) { + /* 0x40 - 0x5F are aliases for 0x60-0x7F */ + case 0x40: case 0x41: case 0x42: case 0x43: + case 0x44: case 0x45: case 0x46: case 0x47: + case 0x48: case 0x49: case 0x4a: case 0x4b: + case 0x4c: case 0x4d: case 0x4e: case 0x4f: + case 0x50: case 0x51: case 0x52: case 0x53: + case 0x54: case 0x55: case 0x56: case 0x57: + case 0x58: case 0x59: case 0x5a: case 0x5b: + case 0x5c: case 0x5d: case 0x5e: case 0x5f: + DEBUG("ATkbd: AMI - alias write to %08X\n", kbd->command); + kbd->mem[kbd->command & 0x1f] = val; + if (kbd->command == 0x60) + kbd_cmd_write(kbd, val); + return 0; + + case 0xaf: /*AMI - set extended controller RAM*/ + DEBUG("ATkbd: AMI - set extended controller RAM\n"); + if (kbd->secr_phase == 1) { + kbd->mem_addr = val; + kbd->want60 = 1; + kbd->secr_phase = 2; + } else if (kbd->secr_phase == 2) { + kbd->mem[kbd->mem_addr] = val; + kbd->secr_phase = 0; + } + return 0; + + case 0xcb: /*AMI - set keyboard mode*/ + DEBUG("ATkbd: AMI - set keyboard mode\n"); + return 0; + } + + return 1; +} + + +static uint8_t +kbd_write64_acer(void *p, uint8_t val) +{ + atkbd_t *kbd = (atkbd_t *) p; + +INFO("ACER: write64(%02x, %02x)\n", kbd->command, val); + switch (val) { + case 0xc0: /* sent by Acer V30 BIOS */ + return 0; + } + + return kbd_write64_generic(kbd, val); +} + + static uint8_t kbd_write60_ami(void *p, uint8_t val) { @@ -2034,10 +2096,10 @@ kbd_init(const device_t *info, UNUSED(void *parent)) kbd_read, NULL, NULL, kbd_write, NULL, NULL, kbd); keyboard_send = kbd_adddata_keyboard; - timer_add(kbd_poll, &keyboard_delay, TIMER_ALWAYS_ENABLED, kbd); + timer_add(kbd_poll, kbd, &keyboard_delay, TIMER_ALWAYS_ENABLED); if ((kbd->flags & KBC_TYPE_MASK) != KBC_TYPE_ISA) { -#if 0 +#if 1 if ((kbd->flags & KBC_TYPE_MASK) == KBC_TYPE_PS2_2) { /* * These machines force translation off, so the @@ -2048,12 +2110,10 @@ kbd_init(const device_t *info, UNUSED(void *parent)) } #endif - timer_add(kbd_refresh, - &kbd->refresh_time, TIMER_ALWAYS_ENABLED, kbd); + timer_add(kbd_refresh, kbd, &kbd->refresh_time, TIMER_ALWAYS_ENABLED); } - timer_add(kbd_pulse_poll, - &kbd->pulse_cb, &kbd->pulse_cb, kbd); + timer_add(kbd_pulse_poll, kbd, &kbd->pulse_cb, &kbd->pulse_cb); kbd->write60_ven = NULL; kbd->write64_ven = NULL; @@ -2081,6 +2141,11 @@ kbd_init(const device_t *info, UNUSED(void *parent)) kbd->write60_ven = &kbd_write60_toshiba; kbd->write64_ven = &kbd_write64_toshiba; break; + + case KBC_VEN_ACER: +// kbd->write60_ven = &kbd_write60_acer; + kbd->write64_ven = &kbd_write64_acer; + break; } /* We need this, sadly. */ @@ -2156,7 +2221,7 @@ const device_t keyboard_ps2_device = { const device_t keyboard_ps2_acer_device = { "Acer 90M002A PS/2 Keyboard", 0, - KBC_TYPE_PS2_2 | KBC_VEN_AMI, + KBC_TYPE_PS2_2 | KBC_VEN_ACER, NULL, kbd_init, kbd_close, kbd_reset, NULL, NULL, NULL, NULL, diff --git a/src/devices/input/keyboard_xt.c b/src/devices/input/keyboard_xt.c index 6094827..c227aec 100644 --- a/src/devices/input/keyboard_xt.c +++ b/src/devices/input/keyboard_xt.c @@ -8,7 +8,7 @@ * * Implementation of the XT-style keyboard. * - * Version: @(#)keyboard_xt.c 1.0.16 2019/04/20 + * Version: @(#)keyboard_xt.c 1.0.17 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -725,7 +725,7 @@ kbd_init(const device_t *info, UNUSED(void *parent)) io_sethandler(0x0060, 4, kbd_read,NULL,NULL, kbd_write,NULL,NULL, dev); - timer_add(kbd_poll, &keyboard_delay, TIMER_ALWAYS_ENABLED, dev); + timer_add(kbd_poll, dev, &keyboard_delay, TIMER_ALWAYS_ENABLED); keyboard_set_table(scancode_xt); diff --git a/src/devices/input/mouse_bus.c b/src/devices/input/mouse_bus.c index 2b8cc40..a1580d9 100644 --- a/src/devices/input/mouse_bus.c +++ b/src/devices/input/mouse_bus.c @@ -53,7 +53,7 @@ * Microsoft Windows NT 3.1 * Microsoft Windows 98 SE * - * Version: @(#)mouse_bus.c 1.1.7 2019/04/23 + * Version: @(#)mouse_bus.c 1.1.8 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -738,7 +738,7 @@ bm_init(const device_t *info, UNUSED(void *parent)) lt_read,NULL,NULL, lt_write,NULL,NULL, dev); } - timer_add(bm_timer, &dev->timer, &dev->timer_enabled, dev); + timer_add(bm_timer, dev, &dev->timer, &dev->timer_enabled); INFO("MOUSE: %s (I/O=%04x, IRQ=%i, buttons=%i\n", dev->name, dev->base, dev->irq, dev->bn); diff --git a/src/devices/input/mouse_serial.c b/src/devices/input/mouse_serial.c index 19f5b94..6bb61eb 100644 --- a/src/devices/input/mouse_serial.c +++ b/src/devices/input/mouse_serial.c @@ -10,7 +10,7 @@ * * TODO: Add the Genius Serial Mouse. * - * Version: @(#)mouse_serial.c 1.0.14 2019/04/11 + * Version: @(#)mouse_serial.c 1.0.15 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -661,7 +661,7 @@ ser_init(const device_t *info, UNUSED(void *parent)) INFO("MOUSE: %s (port=COM%i, buttons=%i)\n", dev->name, dev->port+1, i); - timer_add(ser_timer, &dev->delay, &dev->delay, dev); + timer_add(ser_timer, dev, &dev->delay, &dev->delay); /* Tell them how many buttons we have. */ mouse_set_buttons((dev->flags & FLAG_3BTN) ? 3 : 2); diff --git a/src/devices/ports/game.c b/src/devices/ports/game.c index b347dee..828b5db 100644 --- a/src/devices/ports/game.c +++ b/src/devices/ports/game.c @@ -8,7 +8,7 @@ * * Implementation of a generic Game Port. * - * Version: @(#)game.c 1.0.20 2019/04/19 + * Version: @(#)game.c 1.0.21 2019/04/25 * * Authors: Fred N. van Kempen, * Sarah Walker, @@ -200,8 +200,8 @@ game_init(const device_t *info, UNUSED(void *parent)) dev->axis[i].game = dev; dev->axis[i].axis_nr = i; - timer_add(game_over, - &dev->axis[i].count, &dev->axis[i].count, &dev->axis[i]); + timer_add(game_over, &dev->axis[i], + &dev->axis[i].count, &dev->axis[i].count); } if (joystick_type != 0) { diff --git a/src/devices/ports/serial.c b/src/devices/ports/serial.c index d77fc35..ef5d072 100644 --- a/src/devices/ports/serial.c +++ b/src/devices/ports/serial.c @@ -32,7 +32,7 @@ * The lower half of the driver can interface to the host system * serial ports, or other channels, for real-world access. * - * Version: @(#)serial.c 1.0.14 2019/04/14 + * Version: @(#)serial.c 1.0.15 2019/04/25 * * Author: Fred N. van Kempen, * @@ -533,8 +533,8 @@ pclog(0,"Serial%i: tried to enable FIFO (%02x), type %d!\n", dev->port, val, dev } else { #endif /* Not linked, start RX timer. */ - timer_add(read_timer, - &dev->delay, &dev->delay, dev); + timer_add(read_timer, dev, + &dev->delay, &dev->delay); /* Fake CTS, DSR and DCD (for now.) */ dev->msr = (MSR_CTS | MSR_DCTS | @@ -709,7 +709,7 @@ ser_init(const device_t *info, UNUSED(void *parent)) /* Enable the I/O handler for this port. */ io_sethandler(dev->base, 8, ser_read,NULL,NULL, ser_write,NULL,NULL, dev); - timer_add(receive_callback, &dev->delay, &dev->delay, dev); + timer_add(receive_callback, dev, &dev->delay, &dev->delay); INFO("SERIAL: COM%i (I/O=%04X, IRQ=%i)\n", info->local & 127, dev->base, dev->irq); diff --git a/src/devices/printer/prt_escp.c b/src/devices/printer/prt_escp.c index f26871d..6e3af66 100644 --- a/src/devices/printer/prt_escp.c +++ b/src/devices/printer/prt_escp.c @@ -8,7 +8,7 @@ * * Implementation of the Generic ESC/P Dot-Matrix printer. * - * Version: @(#)prt_escp.c 1.0.8 2019/04/11 + * Version: @(#)prt_escp.c 1.0.9 2019/04/25 * * Authors: Michael Drüing, * Fred N. van Kempen, @@ -2079,7 +2079,7 @@ escp_init(const lpt_device_t *info) memset(dev->page->pixels, 0x00, dev->page->pitch * dev->page->h); /* Create a timer to detect port timeouts. */ - timer_add(printer_timeout, &dev->timeout, &dev->timeout, dev); + timer_add(printer_timeout, dev, &dev->timeout, &dev->timeout); dev->ctrl = 0x04; diff --git a/src/devices/printer/prt_text.c b/src/devices/printer/prt_text.c index 808c29c..21bff32 100644 --- a/src/devices/printer/prt_text.c +++ b/src/devices/printer/prt_text.c @@ -15,7 +15,7 @@ * printer mechanics. This would lead to a page being 66 lines * of 80 characters each. * - * Version: @(#)prt_text.c 1.0.6 2019/01/13 + * Version: @(#)prt_text.c 1.0.7 2019/04/25 * * Author: Fred N. van Kempen, * @@ -368,7 +368,7 @@ prnt_init(const lpt_device_t *info) prnt_reset(dev); /* Create a timer to catch port timeouts. */ - timer_add(prnt_timeout, &dev->timeout, &dev->timeout, dev); + timer_add(prnt_timeout, dev, &dev->timeout, &dev->timeout); /* Create a page buffer. */ dev->page = (psurface_t *)mem_alloc(sizeof(psurface_t)); diff --git a/src/devices/scsi/scsi_ncr5380.c b/src/devices/scsi/scsi_ncr5380.c index ac63d59..a89179a 100644 --- a/src/devices/scsi/scsi_ncr5380.c +++ b/src/devices/scsi/scsi_ncr5380.c @@ -11,7 +11,7 @@ * * NOTE: This code now only supports targets at LUN=0 !! * - * Version: @(#)scsi_ncr5380.c 1.0.16 2019/04/23 + * Version: @(#)scsi_ncr5380.c 1.0.17 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -1493,8 +1493,8 @@ ncr_init(const device_t *info, UNUSED(void *parent)) ncr_dev->buffer_host_pos = 128; ncr_dev->timer_period = 10LL * TIMER_USEC; - timer_add(ncr_callback, &ncr_dev->timer_period, - TIMER_ALWAYS_ENABLED, ncr_dev); + timer_add(ncr_callback, ncr_dev, + &ncr_dev->timer_period, TIMER_ALWAYS_ENABLED); return(ncr_dev); } diff --git a/src/devices/scsi/scsi_ncr53c810.c b/src/devices/scsi/scsi_ncr53c810.c index f3ff84a..7738f7d 100644 --- a/src/devices/scsi/scsi_ncr53c810.c +++ b/src/devices/scsi/scsi_ncr53c810.c @@ -10,7 +10,7 @@ * NCR and later Symbios and LSI. This controller was designed * for the PCI bus. * - * Version: @(#)scsi_ncr53c810.c 1.0.14 2019/04/11 + * Version: @(#)scsi_ncr53c810.c 1.0.15 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -2270,8 +2270,7 @@ ncr53c810_init(const device_t *info, UNUSED(void *parent)) ncr53c810_soft_reset(dev); - timer_add(ncr53c810_callback, - &dev->timer_period, &dev->timer_enabled, dev); + timer_add(ncr53c810_callback, dev, &dev->timer_period, &dev->timer_enabled); dev->has_bios = device_get_config_int("bios"); diff --git a/src/devices/scsi/scsi_x54x.c b/src/devices/scsi/scsi_x54x.c index 9939837..934a588 100644 --- a/src/devices/scsi/scsi_x54x.c +++ b/src/devices/scsi/scsi_x54x.c @@ -12,7 +12,7 @@ * * These controllers were designed for various buses. * - * Version: @(#)scsi_x54x.c 1.0.16 2019/04/24 + * Version: @(#)scsi_x54x.c 1.0.17 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -1941,10 +1941,9 @@ x54x_init(const device_t *info) dev->bus = info->flags; dev->callback_phase = 0; - timer_add(x54x_reset_poll, &dev->ResetCB, &dev->ResetCB, dev); + timer_add(x54x_reset_poll, dev, &dev->ResetCB, &dev->ResetCB); dev->timer_period = 10LL * TIMER_USEC; - timer_add(x54x_cmd_callback, - &dev->timer_period, TIMER_ALWAYS_ENABLED, dev); + timer_add(x54x_cmd_callback, dev, &dev->timer_period, TIMER_ALWAYS_ENABLED); x54x_dev = dev; diff --git a/src/devices/sound/snd_ad1848.c b/src/devices/sound/snd_ad1848.c index a318011..06cf538 100644 --- a/src/devices/sound/snd_ad1848.c +++ b/src/devices/sound/snd_ad1848.c @@ -8,13 +8,13 @@ * * Emulation of the AD1848 (Windows Sound System) CODEC. * - * Version: @(#)snd_ad1848.c 1.0.6 2018/10/16 + * Version: @(#)snd_ad1848.c 1.0.7 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, * Sarah Walker, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * Copyright 2008-2018 Sarah Walker. * @@ -254,5 +254,5 @@ void ad1848_init(ad1848_t *ad1848) ad1848_vols[c] = (int)(attenuation * 65536); } - timer_add(ad1848_poll, &ad1848->timer_count, &ad1848->enable, ad1848); + timer_add(ad1848_poll, ad1848, &ad1848->timer_count, &ad1848->enable); } diff --git a/src/devices/sound/snd_adlibgold.c b/src/devices/sound/snd_adlibgold.c index 01c175a..8f2ba9e 100644 --- a/src/devices/sound/snd_adlibgold.c +++ b/src/devices/sound/snd_adlibgold.c @@ -10,7 +10,7 @@ * * TODO: Stack allocation of big buffers (line 688 et al.) * - * Version: @(#)snd_adlibgold.c 1.0.12 2019/04/11 + * Version: @(#)snd_adlibgold.c 1.0.13 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -863,7 +863,8 @@ void *adgold_init(const device_t *info, UNUSED(void *parent)) /*388/389 are handled by adlib_init*/ io_sethandler(0x0388, 0x0008, adgold_read, NULL, NULL, adgold_write, NULL, NULL, adgold); - timer_add(adgold_timer_poll, &adgold->adgold_mma_timer_count, TIMER_ALWAYS_ENABLED, adgold); + timer_add(adgold_timer_poll, adgold, + &adgold->adgold_mma_timer_count, TIMER_ALWAYS_ENABLED); sound_add_handler(adgold_get_buffer, adgold); diff --git a/src/devices/sound/snd_audiopci.c b/src/devices/sound/snd_audiopci.c index 0a4b87b..ebb8393 100644 --- a/src/devices/sound/snd_audiopci.c +++ b/src/devices/sound/snd_audiopci.c @@ -8,7 +8,7 @@ * * Implementation of the AudioPCI sound device. * - * Version: @(#)snd_audiopci.c 1.0.16 2019/04/09 + * Version: @(#)snd_audiopci.c 1.0.17 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -1341,7 +1341,7 @@ es1371_init(const device_t *info, UNUSED(void *parent)) dev->card = pci_add_card(PCI_ADD_NORMAL, es1371_pci_read, es1371_pci_write, dev); - timer_add(es1371_poll, &dev->dac[1].time, TIMER_ALWAYS_ENABLED, dev); + timer_add(es1371_poll, dev, &dev->dac[1].time, TIMER_ALWAYS_ENABLED); generate_es1371_filter(); diff --git a/src/devices/sound/snd_cs423x.c b/src/devices/sound/snd_cs423x.c index 38a2c3c..6736da5 100644 --- a/src/devices/sound/snd_cs423x.c +++ b/src/devices/sound/snd_cs423x.c @@ -8,7 +8,7 @@ * * Implementation of Cirrus Logic Crystal 423x sound devices. * - * Version: @(#)snd_cs423x.c 1.0.2 2019/03/15 + * Version: @(#)snd_cs423x.c 1.0.3 2019/04/25 * * Authors: Altheos, * Fred N. van Kempen, @@ -349,7 +349,7 @@ cs423x_init(cs423x_t *dev) cs423x_vols[c] = (int)(attenuation * 65536); } - timer_add(cs423x_poll, &dev->timer_count, &dev->enable, dev); + timer_add(cs423x_poll, dev, &dev->timer_count, &dev->enable); } diff --git a/src/devices/sound/snd_gus.c b/src/devices/sound/snd_gus.c index 7d36260..2bf6a8d 100644 --- a/src/devices/sound/snd_gus.c +++ b/src/devices/sound/snd_gus.c @@ -8,7 +8,7 @@ * * Implementation of the Gravis UltraSound sound device. * - * Version: @(#)snd_gus.c 1.0.12 2019/04/09 + * Version: @(#)snd_gus.c 1.0.13 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -1221,9 +1221,9 @@ gus_init(const device_t *info, UNUSED(void *parent)) #endif } - timer_add(poll_wave, &dev->samp_timer, TIMER_ALWAYS_ENABLED, dev); - timer_add(poll_timer_1, &dev->timer_1, TIMER_ALWAYS_ENABLED, dev); - timer_add(poll_timer_2, &dev->timer_2, TIMER_ALWAYS_ENABLED, dev); + timer_add(poll_wave, dev, &dev->samp_timer, TIMER_ALWAYS_ENABLED); + timer_add(poll_timer_1, dev, &dev->timer_1, TIMER_ALWAYS_ENABLED); + timer_add(poll_timer_2, dev, &dev->timer_2, TIMER_ALWAYS_ENABLED); sound_add_handler(get_buffer, dev); diff --git a/src/devices/sound/snd_lpt_dss.c b/src/devices/sound/snd_lpt_dss.c index d7e947b..659c49a 100644 --- a/src/devices/sound/snd_lpt_dss.c +++ b/src/devices/sound/snd_lpt_dss.c @@ -8,7 +8,7 @@ * * Implementation of the LPT-based DSS sound device. * - * Version: @(#)snd_lpt_dss.c 1.0.10 2019/04/11 + * Version: @(#)snd_lpt_dss.c 1.0.11 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -155,7 +155,7 @@ dss_init(const lpt_device_t *info) sound_add_handler(dss_get_buffer, dev); - timer_add(dss_callback, &dev->time, TIMER_ALWAYS_ENABLED, dev); + timer_add(dss_callback, dev, &dev->time, TIMER_ALWAYS_ENABLED); return dev; } diff --git a/src/devices/sound/snd_mpu401.c b/src/devices/sound/snd_mpu401.c index 67b595c..63845c6 100644 --- a/src/devices/sound/snd_mpu401.c +++ b/src/devices/sound/snd_mpu401.c @@ -8,7 +8,7 @@ * * Roland MPU-401 emulation. * - * Version: @(#)snd_mpu401.c 1.0.13 2019/04/11 + * Version: @(#)snd_mpu401.c 1.0.14 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -915,9 +915,13 @@ mpu401_init(mpu_t *mpu, uint16_t addr, int irq, int mode) mpu401_read, NULL, NULL, mpu401_write, NULL, NULL, mpu); io_sethandler(0x2A20, 16, NULL, NULL, NULL, imf_write, NULL, NULL, mpu); - timer_add(MPU401_Event, &mpu401_event_callback, &mpu401_event_callback, mpu); - timer_add(MPU401_EOIHandler, &mpu401_eoi_callback, &mpu401_eoi_callback, mpu); - timer_add(MPU401_ResetDone, &mpu401_reset_callback, &mpu401_reset_callback, mpu); + + timer_add(MPU401_Event, mpu, + &mpu401_event_callback, &mpu401_event_callback); + timer_add(MPU401_EOIHandler, mpu, + &mpu401_eoi_callback, &mpu401_eoi_callback); + timer_add(MPU401_ResetDone, mpu, + &mpu401_reset_callback, &mpu401_reset_callback); MPU401_Reset(mpu); } diff --git a/src/devices/sound/snd_opl.c b/src/devices/sound/snd_opl.c index 00f09ac..1247354 100644 --- a/src/devices/sound/snd_opl.c +++ b/src/devices/sound/snd_opl.c @@ -8,7 +8,7 @@ * * Interface to the actual OPL emulator. * - * Version: @(#)snd_opl.c 1.0.5 2019/02/11 + * Version: @(#)snd_opl.c 1.0.6 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -204,16 +204,24 @@ void opl2_init(opl_t *opl) { opl_init(ym3812_timer_set_0, opl, 0, 0); opl_init(ym3812_timer_set_1, opl, 1, 0); - timer_add(opl_timer_callback00, &opl->timers[0][0], &opl->timers_enable[0][0], (void *)opl); - timer_add(opl_timer_callback01, &opl->timers[0][1], &opl->timers_enable[0][1], (void *)opl); - timer_add(opl_timer_callback10, &opl->timers[1][0], &opl->timers_enable[1][0], (void *)opl); - timer_add(opl_timer_callback11, &opl->timers[1][1], &opl->timers_enable[1][1], (void *)opl); + + timer_add(opl_timer_callback00, opl, + &opl->timers[0][0], &opl->timers_enable[0][0]); + timer_add(opl_timer_callback01, opl, + &opl->timers[0][1], &opl->timers_enable[0][1]); + timer_add(opl_timer_callback10, opl, + &opl->timers[1][0], &opl->timers_enable[1][0]); + timer_add(opl_timer_callback11, opl, + &opl->timers[1][1], &opl->timers_enable[1][1]); } void opl3_init(opl_t *opl) { opl_init(ymf262_timer_set, opl, 0, 1); - timer_add(opl_timer_callback00, &opl->timers[0][0], &opl->timers_enable[0][0], (void *)opl); - timer_add(opl_timer_callback01, &opl->timers[0][1], &opl->timers_enable[0][1], (void *)opl); + + timer_add(opl_timer_callback00, opl, + &opl->timers[0][0], &opl->timers_enable[0][0]); + timer_add(opl_timer_callback01, opl, + &opl->timers[0][1], &opl->timers_enable[0][1]); } diff --git a/src/devices/sound/snd_pas16.c b/src/devices/sound/snd_pas16.c index 416d30f..2c3239a 100644 --- a/src/devices/sound/snd_pas16.c +++ b/src/devices/sound/snd_pas16.c @@ -79,7 +79,7 @@ * FF88 - board model * 3 = PAS16 * - * Version: @(#)snd_pas16.c 1.0.12 2019/04/09 + * Version: @(#)snd_pas16.c 1.0.13 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -781,7 +781,8 @@ static void *pas16_init(const device_t *info, UNUSED(void *parent)) io_sethandler(0x9a01, 0x0001, NULL, NULL, NULL, pas16_out_base, NULL, NULL, pas16); - timer_add(pas16_pcm_poll, &pas16->pit.c[0], &pas16->pit.enable[0], pas16); + timer_add(pas16_pcm_poll, pas16, + &pas16->pit.c[0], &pas16->pit.enable[0]); sound_add_handler(pas16_get_buffer, pas16); diff --git a/src/devices/sound/snd_sb_dsp.c b/src/devices/sound/snd_sb_dsp.c index 60aba38..aab120e 100644 --- a/src/devices/sound/snd_sb_dsp.c +++ b/src/devices/sound/snd_sb_dsp.c @@ -14,13 +14,13 @@ * 486-50 - 32kHz * Pentium - 45kHz * - * Version: @(#)snd_sb_dsp.c 1.0.8 2018/10/16 + * Version: @(#)snd_sb_dsp.c 1.0.9 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, * Sarah Walker, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * Copyright 2008-2018 Sarah Walker. * @@ -787,9 +787,9 @@ void sb_dsp_init(sb_dsp_t *dsp, int type) sb_doreset(dsp); - timer_add(pollsb, &dsp->sbcount, &dsp->sbenable, dsp); - timer_add(sb_poll_i, &dsp->sb_count_i, &dsp->sb_enable_i, dsp); - timer_add(sb_wb_clear, &dsp->wb_time, &dsp->wb_time, dsp); + timer_add(pollsb, dsp, &dsp->sbcount, &dsp->sbenable); + timer_add(sb_poll_i, dsp, &dsp->sb_count_i, &dsp->sb_enable_i); + timer_add(sb_wb_clear, dsp, &dsp->wb_time, &dsp->wb_time); /*Initialise SB16 filter to same cutoff as 8-bit SBs (3.2 kHz). This will be recalculated when a set frequency command is sent.*/ diff --git a/src/devices/system/intel.c b/src/devices/system/intel.c index 7d3f375..ee86833 100644 --- a/src/devices/system/intel.c +++ b/src/devices/system/intel.c @@ -8,7 +8,7 @@ * * Implementation of Intel mainboards. * - * Version: @(#)intel.c 1.0.9 2019/04/11 + * Version: @(#)intel.c 1.0.10 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -148,7 +148,7 @@ batman_init(const device_t *info, UNUSED(void *parent)) io_sethandler(0x0078, 0x0002, timer_read,NULL,NULL, timer_write,NULL,NULL, dev); - timer_add(timer_over, &dev->timer, &dev->timer, dev); + timer_add(timer_over, dev, &dev->timer, &dev->timer); return(dev); } diff --git a/src/devices/system/nvr_at.c b/src/devices/system/nvr_at.c index 30dd5e5..0123392 100644 --- a/src/devices/system/nvr_at.c +++ b/src/devices/system/nvr_at.c @@ -189,7 +189,7 @@ * including the later update (DS12887A) which implemented a * "century" register to be compatible with Y2K. * - * Version: @(#)nvr_at.c 1.0.14 2019/04/09 + * Version: @(#)nvr_at.c 1.0.15 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -698,8 +698,8 @@ nvr_at_init(const device_t *info, UNUSED(void *parent)) nvr_init(nvr); /* Start the timers. */ - timer_add(timer_update, &local->ecount, &local->ecount, nvr); - timer_add(timer_intr, &local->rtctime, TIMER_ALWAYS_ENABLED, nvr); + timer_add(timer_update, nvr, &local->ecount, &local->ecount); + timer_add(timer_intr, nvr, &local->rtctime, TIMER_ALWAYS_ENABLED); /* Set up the I/O handler for this device. */ io_sethandler(0x0070, 2, diff --git a/src/devices/video/vid_cga.c b/src/devices/video/vid_cga.c index 3289787..6c3bf1e 100644 --- a/src/devices/video/vid_cga.c +++ b/src/devices/video/vid_cga.c @@ -8,7 +8,7 @@ * * Emulation of the old and new IBM CGA graphics cards. * - * Version: @(#)vid_cga.c 1.0.16 2019/04/19 + * Version: @(#)vid_cga.c 1.0.17 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -662,7 +662,7 @@ cga_standalone_init(const device_t *info, UNUSED(void *parent)) if (dev->composite) dev->cpriv = cga_comp_init(dev->revision); - timer_add(cga_poll, &dev->vidtime, TIMER_ALWAYS_ENABLED, dev); + timer_add(cga_poll, dev, &dev->vidtime, TIMER_ALWAYS_ENABLED); mem_map_add(&dev->mapping, 0xb8000, 0x08000, cga_read,NULL,NULL, cga_write,NULL,NULL, diff --git a/src/devices/video/vid_cga_compaq.c b/src/devices/video/vid_cga_compaq.c index 2bb9728..cb63eec 100644 --- a/src/devices/video/vid_cga_compaq.c +++ b/src/devices/video/vid_cga_compaq.c @@ -8,7 +8,7 @@ * * Implementation of CGA used by Compaq PC's. * - * Version: @(#)vid_cga_compaq.c 1.0.9 2019/04/11 + * Version: @(#)vid_cga_compaq.c 1.0.10 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -379,7 +379,7 @@ compaq_cga_init(const device_t *info, UNUSED(void *parent)) dev->cga.cpriv = cga_comp_init(dev->cga.revision); - timer_add(compaq_poll, &dev->cga.vidtime, TIMER_ALWAYS_ENABLED, dev); + timer_add(compaq_poll, dev, &dev->cga.vidtime, TIMER_ALWAYS_ENABLED); mem_map_add(&dev->cga.mapping, 0xb8000, 0x08000, cga_read,NULL,NULL, cga_write,NULL,NULL, diff --git a/src/devices/video/vid_colorplus.c b/src/devices/video/vid_colorplus.c index e979bd4..4c190b9 100644 --- a/src/devices/video/vid_colorplus.c +++ b/src/devices/video/vid_colorplus.c @@ -8,7 +8,7 @@ * * Plantronics ColorPlus emulation. * - * Version: @(#)vid_colorplus.c 1.0.13 2019/04/19 + * Version: @(#)vid_colorplus.c 1.0.14 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -391,7 +391,7 @@ colorplus_init(const device_t *info, UNUSED(void *parent)) dev->cga.cpriv = cga_comp_init(1); - timer_add(colorplus_poll, &dev->cga.vidtime, TIMER_ALWAYS_ENABLED, dev); + timer_add(colorplus_poll, dev, &dev->cga.vidtime, TIMER_ALWAYS_ENABLED); mem_map_add(&dev->cga.mapping, 0xb8000, 0x08000, colorplus_read,NULL,NULL, colorplus_write,NULL,NULL, diff --git a/src/devices/video/vid_ega.c b/src/devices/video/vid_ega.c index 03a7019..8333edd 100644 --- a/src/devices/video/vid_ega.c +++ b/src/devices/video/vid_ega.c @@ -9,7 +9,7 @@ * Emulation of the EGA, Chips & Technologies SuperEGA, and * AX JEGA graphics cards. * - * Version: @(#)vid_ega.c 1.0.14 2019/04/23 + * Version: @(#)vid_ega.c 1.0.15 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -1077,7 +1077,7 @@ ega_standalone_init(const device_t *info, UNUSED(void *parent)) ega_read,NULL,NULL, ega_write,NULL,NULL, NULL, MEM_MAPPING_EXTERNAL, dev); - timer_add(ega_poll, &dev->vidtime, TIMER_ALWAYS_ENABLED, dev); + timer_add(ega_poll, dev, &dev->vidtime, TIMER_ALWAYS_ENABLED); io_sethandler(0x03a0, 0x0040, ega_in,NULL,NULL, ega_out,NULL,NULL, dev); diff --git a/src/devices/video/vid_genius.c b/src/devices/video/vid_genius.c index 4e93ec7..085358b 100644 --- a/src/devices/video/vid_genius.c +++ b/src/devices/video/vid_genius.c @@ -63,7 +63,7 @@ * reducing the height of characters so they fit in an 8x12 cell * if necessary. * - * Version: @(#)vid_genius.c 1.0.12 2019/04/19 + * Version: @(#)vid_genius.c 1.0.13 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -602,7 +602,7 @@ genius_init(const device_t *info, UNUSED(void *parent)) /* 160K video RAM */ dev->vram = (uint8_t *)mem_alloc(0x28000); - timer_add(genius_poll, &dev->vidtime, TIMER_ALWAYS_ENABLED, dev); + timer_add(genius_poll, dev, &dev->vidtime, TIMER_ALWAYS_ENABLED); /* Occupy memory between 0xB0000 and 0xBFFFF (moves to 0xA0000 in * high-resolution modes) */ diff --git a/src/devices/video/vid_hercules.c b/src/devices/video/vid_hercules.c index a7ea823..fe636cf 100644 --- a/src/devices/video/vid_hercules.c +++ b/src/devices/video/vid_hercules.c @@ -8,7 +8,7 @@ * * Hercules emulation. * - * Version: @(#)vid_hercules.c 1.0.17 2019/04/19 + * Version: @(#)vid_hercules.c 1.0.18 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -439,7 +439,7 @@ hercules_init(const device_t *info, UNUSED(void *parent)) dev->vram = (uint8_t *)mem_alloc(0x10000); - timer_add(hercules_poll, &dev->vidtime, TIMER_ALWAYS_ENABLED, dev); + timer_add(hercules_poll, dev, &dev->vidtime, TIMER_ALWAYS_ENABLED); /* * Map in the memory, enable exec on it (for software like basich.com diff --git a/src/devices/video/vid_herculesplus.c b/src/devices/video/vid_herculesplus.c index 84b4ac7..b9974ad 100644 --- a/src/devices/video/vid_herculesplus.c +++ b/src/devices/video/vid_herculesplus.c @@ -8,7 +8,7 @@ * * Hercules InColor emulation. * - * Version: @(#)vid_hercules_plus.c 1.0.18 2019/04/19 + * Version: @(#)vid_hercules_plus.c 1.0.19 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -654,7 +654,7 @@ herculesplus_init(const device_t *info, UNUSED(void *parent)) dev->vram = (uint8_t *)mem_alloc(0x10000); /* 64k VRAM */ - timer_add(herculesplus_poll, &dev->vidtime, TIMER_ALWAYS_ENABLED, dev); + timer_add(herculesplus_poll, dev, &dev->vidtime, TIMER_ALWAYS_ENABLED); mem_map_add(&dev->mapping, 0xb0000, 0x10000, herculesplus_read,NULL,NULL, diff --git a/src/devices/video/vid_incolor.c b/src/devices/video/vid_incolor.c index 5a05789..db91614 100644 --- a/src/devices/video/vid_incolor.c +++ b/src/devices/video/vid_incolor.c @@ -8,7 +8,7 @@ * * Hercules InColor emulation. * - * Version: @(#)vid_incolor.c 1.0.16 2019/04/19 + * Version: @(#)vid_incolor.c 1.0.17 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -990,7 +990,7 @@ incolor_init(const device_t *info, UNUSED(void *parent)) dev->vram = (uint8_t *)mem_alloc(0x40000); /* 4 planes of 64k */ - timer_add(incolor_poll, &dev->vidtime, TIMER_ALWAYS_ENABLED, dev); + timer_add(incolor_poll, dev, &dev->vidtime, TIMER_ALWAYS_ENABLED); mem_map_add(&dev->mapping, 0xb0000, 0x08000, incolor_read,NULL,NULL, incolor_write,NULL,NULL, diff --git a/src/devices/video/vid_mda.c b/src/devices/video/vid_mda.c index 5303de0..f05da57 100644 --- a/src/devices/video/vid_mda.c +++ b/src/devices/video/vid_mda.c @@ -8,7 +8,7 @@ * * MDA emulation. * - * Version: @(#)vid_mda.c 1.0.13 2019/04/19 + * Version: @(#)vid_mda.c 1.0.14 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -366,7 +366,7 @@ mda_standalone_init(const device_t *info, UNUSED(void *parent)) io_sethandler(0x03b0, 16, mda_in,NULL,NULL, mda_out,NULL,NULL, dev); - timer_add(mda_poll, &dev->vidtime, TIMER_ALWAYS_ENABLED, dev); + timer_add(mda_poll, dev, &dev->vidtime, TIMER_ALWAYS_ENABLED); video_inform(DEVICE_VIDEO_GET(info->flags), (const video_timings_t *)&mda_timings); diff --git a/src/devices/video/vid_pgc.c b/src/devices/video/vid_pgc.c index 0630dc2..961c8c9 100644 --- a/src/devices/video/vid_pgc.c +++ b/src/devices/video/vid_pgc.c @@ -44,7 +44,7 @@ * * This is expected to be done shortly. * - * Version: @(#)vid_pgc.c 1.0.4 2019/04/19 + * Version: @(#)vid_pgc.c 1.0.5 2019/04/25 * * Authors: Fred N. van Kempen, * John Elliott, @@ -2613,9 +2613,8 @@ pgc_init(pgc_t *dev, int maxw, int maxh, int visw, int vish, dev->pgc_wake_thread = thread_create_event(); dev->pgc_thread = thread_create(pgc_thread, dev); - timer_add(pgc_poll, &dev->vidtime, TIMER_ALWAYS_ENABLED, dev); - - timer_add(wake_timer, &dev->wake_timer, &dev->wake_timer, (void *)dev); + timer_add(pgc_poll, dev, &dev->vidtime, TIMER_ALWAYS_ENABLED); + timer_add(wake_timer, dev, &dev->wake_timer, &dev->wake_timer); } diff --git a/src/devices/video/vid_sigma.c b/src/devices/video/vid_sigma.c index ff64ded..dcb6c88 100644 --- a/src/devices/video/vid_sigma.c +++ b/src/devices/video/vid_sigma.c @@ -41,7 +41,7 @@ * even-numbered columns, so the top bit of the control register * at 0x2D9 is used to adjust the position. * - * Version: @(#)vid_sigma.c 1.0.6 2019/04/19 + * Version: @(#)vid_sigma.c 1.0.7 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -911,7 +911,7 @@ sigma_init(const device_t *info, UNUSED(void *parent)) io_sethandler(0x02d0, 16, sigma_in,NULL,NULL, sigma_out,NULL,NULL, dev); - timer_add(sigma_poll, &dev->vidtime, TIMER_ALWAYS_ENABLED, dev); + timer_add(sigma_poll, dev, &dev->vidtime, TIMER_ALWAYS_ENABLED); /* Start with ROM paged in, BIOS RAM paged out */ dev->rom_paged = 0x80; diff --git a/src/devices/video/vid_svga.c b/src/devices/video/vid_svga.c index df444e2..639ebf4 100644 --- a/src/devices/video/vid_svga.c +++ b/src/devices/video/vid_svga.c @@ -11,7 +11,7 @@ * This is intended to be used by another SVGA driver, * and not as a card in it's own right. * - * Version: @(#)vid_svga.c 1.0.18 2019/04/22 + * Version: @(#)vid_svga.c 1.0.19 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -851,7 +851,7 @@ svga_init(svga_t *svga, void *p, int vramsize, svga_write, svga_writew, svga_writel, NULL, MEM_MAPPING_EXTERNAL, svga); - timer_add(svga_poll, &svga->vidtime, TIMER_ALWAYS_ENABLED, svga); + timer_add(svga_poll, svga, &svga->vidtime, TIMER_ALWAYS_ENABLED); svga_pri = svga; diff --git a/src/devices/video/vid_voodoo.c b/src/devices/video/vid_voodoo.c index 6150430..28cfea5 100644 --- a/src/devices/video/vid_voodoo.c +++ b/src/devices/video/vid_voodoo.c @@ -8,7 +8,7 @@ * * Emulation of the 3DFX Voodoo Graphics controller. * - * Version: @(#)vid_voodoo.c 1.0.18 2019/04/11 + * Version: @(#)vid_voodoo.c 1.0.19 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -7615,7 +7615,8 @@ void *voodoo_card_init() } } - timer_add(voodoo_callback, &voodoo->timer_count, TIMER_ALWAYS_ENABLED, voodoo); + timer_add(voodoo_callback, voodoo, + &voodoo->timer_count, TIMER_ALWAYS_ENABLED); voodoo->svga = svga_get_pri(); voodoo->fbiInit0 = 0; @@ -7632,7 +7633,8 @@ void *voodoo_card_init() if (voodoo->render_threads == 2) voodoo->render_thread[1] = thread_create(render_thread_2, voodoo); - timer_add(voodoo_wake_timer, &voodoo->wake_timer, &voodoo->wake_timer, (void *)voodoo); + timer_add(voodoo_wake_timer, voodoo, + &voodoo->wake_timer, &voodoo->wake_timer); for (c = 0; c < 0x100; c++) { diff --git a/src/devices/video/vid_wy700.c b/src/devices/video/vid_wy700.c index 6926226..86244c8 100644 --- a/src/devices/video/vid_wy700.c +++ b/src/devices/video/vid_wy700.c @@ -53,7 +53,7 @@ * What doesn't work, is untested or not well understood: * - Cursor detach (commands 4 and 5) * - * Version: @(#)vid_wy700.c 1.0.9 2019/04/19 + * Version: @(#)vid_wy700.c 1.0.10 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -894,7 +894,7 @@ wy700_init(const device_t *info, UNUSED(void *parent)) /* 128K video RAM */ dev->vram = (uint8_t *)mem_alloc(0x20000); - timer_add(wy700_poll, &dev->vidtime, TIMER_ALWAYS_ENABLED, dev); + timer_add(wy700_poll, dev, &dev->vidtime, TIMER_ALWAYS_ENABLED); /* Occupy memory between 0xB0000 and 0xBFFFF (moves to 0xA0000 in * high-resolution modes) diff --git a/src/machines/m_amstrad.c b/src/machines/m_amstrad.c index 0444aa7..00a5f3f 100644 --- a/src/machines/m_amstrad.c +++ b/src/machines/m_amstrad.c @@ -15,7 +15,7 @@ * 80 columns. To be fixed... * Also, the DDM bits stuff needs to be verified. * - * Version: @(#)m_amstrad.c 1.0.25 2019/04/20 + * Version: @(#)m_amstrad.c 1.0.26 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -608,7 +608,7 @@ amstrad_init(const device_t *info, void *arg) /* Initialize the (custom) keyboard interface. */ dev->wantirq = 0; io_sethandler(0x0060, 7, kbd_read,NULL,NULL, kbd_write,NULL,NULL, dev); - timer_add(kbd_poll, &keyboard_delay, TIMER_ALWAYS_ENABLED, dev); + timer_add(kbd_poll, dev, &keyboard_delay, TIMER_ALWAYS_ENABLED); keyboard_set_table(scancode_xt); keyboard_send = kbd_adddata_ex; keyboard_scan = 1; diff --git a/src/machines/m_amstrad_vid.c b/src/machines/m_amstrad_vid.c index edcfa9f..028c9d1 100644 --- a/src/machines/m_amstrad_vid.c +++ b/src/machines/m_amstrad_vid.c @@ -25,7 +25,7 @@ * by the ROS. * PPC: MDA Monitor results in half-screen, half-cell-height display?? * - * Version: @(#)m_amstrad_vid.c 1.0.2 2019/04/20 + * Version: @(#)m_amstrad_vid.c 1.0.3 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -634,7 +634,7 @@ m_amstrad_1512_vid_init(const wchar_t *fn, int fnt, int cp) dev->cgacol = 7; dev->cgamode = 0x12; - timer_add(pc1512_poll, &dev->vidtime, TIMER_ALWAYS_ENABLED, dev); + timer_add(pc1512_poll, dev, &dev->vidtime, TIMER_ALWAYS_ENABLED); mem_map_add(&dev->cga.mapping, 0xb8000, 0x08000, pc1512_read,NULL,NULL, pc1512_write,NULL,NULL, NULL, 0, dev); io_sethandler(0x03d0, 16, pc1512_in,NULL,NULL, pc1512_out,NULL,NULL, dev); @@ -829,7 +829,7 @@ m_amstrad_1640_vid_init(const wchar_t *fn, int sz) /* We currently do not implement the MDA/Hercules mode regs at 3B0H */ io_sethandler(0x03a0, 64, pc1640_in,NULL,NULL, pc1640_out,NULL,NULL, dev); - timer_add(pc1640_poll, &dev->vidtime, TIMER_ALWAYS_ENABLED, dev); + timer_add(pc1640_poll, dev, &dev->vidtime, TIMER_ALWAYS_ENABLED); overscan_x = overscan_y = 16; @@ -1702,7 +1702,7 @@ m_amstrad_ida_init(int type, const wchar_t *fn, int cp, int em, int dt) dev->blue = makecol(0x0f, 0x21, 0x3f); set_lcd_cols(dev, 0); - timer_add(ida_poll, &dev->vidtime, TIMER_ALWAYS_ENABLED, dev); + timer_add(ida_poll, dev, &dev->vidtime, TIMER_ALWAYS_ENABLED); overscan_x = overscan_y = 16; diff --git a/src/machines/m_compaq_vid.c b/src/machines/m_compaq_vid.c index 62dd314..5e979ed 100644 --- a/src/machines/m_compaq_vid.c +++ b/src/machines/m_compaq_vid.c @@ -19,7 +19,7 @@ * plasma display. The code for this was taken from the code * for the Toshiba 3100e machine, which used a similar display. * - * Version: @(#)m_compaq_vid.c 1.0.1 2019/04/13 + * Version: @(#)m_compaq_vid.c 1.0.2 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -738,7 +738,7 @@ INFO("CPQ: video_init(type=%i)\n", dev->type); } if (dev->mode != 0) - timer_add(vid_poll, &dev->vidtime, TIMER_ALWAYS_ENABLED, dev); + timer_add(vid_poll, dev, &dev->vidtime, TIMER_ALWAYS_ENABLED); #if 0 /* diff --git a/src/machines/m_olim24.c b/src/machines/m_olim24.c index 6cb238e..da7dbff 100644 --- a/src/machines/m_olim24.c +++ b/src/machines/m_olim24.c @@ -21,7 +21,7 @@ * data at all, so there seems to not be a way to properly do * that.. The chip's interrupt pin is not connected. * - * Version: @(#)m_olim24.c 1.0.17 2019/04/21 + * Version: @(#)m_olim24.c 1.0.18 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -698,7 +698,7 @@ olim24_init(const device_t *info, void *arg) keyboard_set_table(scancode_xt); keyboard_send = kbd_adddata_ex; keyboard_scan = 1; - timer_add(kbd_poll, &keyboard_delay, TIMER_ALWAYS_ENABLED, dev); + timer_add(kbd_poll, dev, &keyboard_delay, TIMER_ALWAYS_ENABLED); /* Tell mouse driver about our internal mouse. */ mouse_reset(); diff --git a/src/machines/m_olim24_vid.c b/src/machines/m_olim24_vid.c index f4c0656..fa70776 100644 --- a/src/machines/m_olim24_vid.c +++ b/src/machines/m_olim24_vid.c @@ -8,7 +8,7 @@ * * Emulation of the Olivetti M24 built-in video controller. * - * Version: @(#)m_olim24_vid.c 1.0.2 2019/04/08 + * Version: @(#)m_olim24_vid.c 1.0.3 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -534,7 +534,7 @@ m_olim24_vid_init(int type) break; } - timer_add(vid_poll, &dev->vidtime, TIMER_ALWAYS_ENABLED, dev); + timer_add(vid_poll, dev, &dev->vidtime, TIMER_ALWAYS_ENABLED); device_add_ex(&video_device, dev); diff --git a/src/machines/m_pcjr.c b/src/machines/m_pcjr.c index 29b573e..9011137 100644 --- a/src/machines/m_pcjr.c +++ b/src/machines/m_pcjr.c @@ -8,7 +8,7 @@ * * Emulation of the IBM PCjr. * - * Version: @(#)m_pcjr.c 1.0.17 2019/04/11 + * Version: @(#)m_pcjr.c 1.0.18 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -785,7 +785,7 @@ pcjr_init(const device_t *info, UNUSED(void *arg)) vid_write, NULL, NULL, NULL, 0, dev); io_sethandler(0x03d0, 16, vid_in,NULL,NULL, vid_out,NULL,NULL, dev); - timer_add(vid_poll, &dev->vidtime, TIMER_ALWAYS_ENABLED, dev); + timer_add(vid_poll, dev, &dev->vidtime, TIMER_ALWAYS_ENABLED); video_inform(VID_TYPE_CGA, &pcjr_timings); /* Initialize the keyboard. */ @@ -795,7 +795,7 @@ pcjr_init(const device_t *info, UNUSED(void *arg)) kbd_read, NULL, NULL, kbd_write, NULL, NULL, dev); io_sethandler(0x00a0, 8, kbd_read, NULL, NULL, kbd_write, NULL, NULL, dev); - timer_add(kbd_poll, &keyboard_delay, TIMER_ALWAYS_ENABLED, dev); + timer_add(kbd_poll, dev, &keyboard_delay, TIMER_ALWAYS_ENABLED); keyboard_set_table(scancode_xt); keyboard_send = kbd_adddata_ex; diff --git a/src/machines/m_ps1.c b/src/machines/m_ps1.c index dc98497..bd5ec54 100644 --- a/src/machines/m_ps1.c +++ b/src/machines/m_ps1.c @@ -22,7 +22,7 @@ * The reserved 384K is remapped to the top of extended memory. * If this is not done then you get an error on startup. * - * Version: @(#)m_ps1.c 1.0.25 2019/04/20 + * Version: @(#)m_ps1.c 1.0.26 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -87,7 +87,8 @@ typedef struct { sn76489_t sn76489; uint8_t status, ctrl; - int64_t timer_latch, timer_count, timer_enable; + int64_t timer_latch, timer_count; + int64_t timer_enable; uint8_t fifo[2048]; int fifo_read_idx, fifo_write_idx; int fifo_threshold; @@ -266,7 +267,7 @@ snd_init(const device_t *info, UNUSED(void *parent)) io_sethandler(0x0202, 6, snd_read,NULL,NULL, snd_write,NULL,NULL, snd); - timer_add(snd_callback, &snd->timer_count, &snd->timer_enable, snd); + timer_add(snd_callback, snd, &snd->timer_count, &snd->timer_enable); sound_add_handler(snd_get_buffer, snd); diff --git a/src/machines/m_ps1_hdc.c b/src/machines/m_ps1_hdc.c index ee3de77..056ae4f 100644 --- a/src/machines/m_ps1_hdc.c +++ b/src/machines/m_ps1_hdc.c @@ -43,7 +43,7 @@ * Type table with the main code, so the user can only select * items from that list... * - * Version: @(#)m_ps1_hdc.c 1.0.11 2018/04/19 + * Version: @(#)m_ps1_hdc.c 1.0.12 2018/04/25 * * Author: Fred N. van Kempen, * @@ -1466,7 +1466,7 @@ hdc_init_ps1(const device_t *info, void *parent) hdc_read,NULL,NULL, hdc_write,NULL,NULL, dev); /* Create a timer for command delays. */ - timer_add(hdc_callback, &dev->callback, &dev->callback, dev); + timer_add(hdc_callback, dev, &dev->callback, &dev->callback); return(dev); } diff --git a/src/machines/m_tandy1000.c b/src/machines/m_tandy1000.c index 448f922..9e352db 100644 --- a/src/machines/m_tandy1000.c +++ b/src/machines/m_tandy1000.c @@ -8,7 +8,7 @@ * * Emulation of Tandy models 1000, 1000HX and 1000SL2. * - * Version: @(#)m_tandy1000.c 1.0.19 2019/04/11 + * Version: @(#)m_tandy1000.c 1.0.20 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -88,8 +88,8 @@ typedef struct { int amplitude; int irq; - int64_t timer_count; - int64_t enable; + int64_t timer_count, + enable; int wave_pos; int pulse_width; @@ -574,7 +574,7 @@ snd_init(const device_t *info, UNUSED(void *parent)) io_sethandler(0x00c4, 4, snd_read,NULL,NULL, snd_write,NULL,NULL, dev); - timer_add(snd_callback, &dev->timer_count, &dev->enable, dev); + timer_add(snd_callback, dev, &dev->timer_count, &dev->enable); sound_add_handler(snd_get_buffer, dev); diff --git a/src/machines/m_tandy1000_vid.c b/src/machines/m_tandy1000_vid.c index fa8b051..39c291c 100644 --- a/src/machines/m_tandy1000_vid.c +++ b/src/machines/m_tandy1000_vid.c @@ -8,7 +8,7 @@ * * Emulation of video controllers for Tandy models. * - * Version: @(#)m_tandy1000_vid.c 1.0.2 2019/04/08 + * Version: @(#)m_tandy1000_vid.c 1.0.3 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -1086,11 +1086,11 @@ tandy1k_video_init(int type, int display_type, uint32_t base, const wchar_t *fn) io_sethandler(0x0065, 1, vid_in,NULL,NULL, vid_out,NULL,NULL, dev); - timer_add(vid_poll_sl, &dev->vidtime, TIMER_ALWAYS_ENABLED, dev); + timer_add(vid_poll_sl, dev, &dev->vidtime, TIMER_ALWAYS_ENABLED); } else { dev->b8000_mask = 0x3fff; - timer_add(vid_poll, &dev->vidtime, TIMER_ALWAYS_ENABLED, dev); + timer_add(vid_poll, dev, &dev->vidtime, TIMER_ALWAYS_ENABLED); } mem_map_add(&dev->mapping, 0xb8000, 0x08000, diff --git a/src/machines/m_tosh1x00_vid.c b/src/machines/m_tosh1x00_vid.c index 2afe402..11f0571 100644 --- a/src/machines/m_tosh1x00_vid.c +++ b/src/machines/m_tosh1x00_vid.c @@ -9,7 +9,7 @@ * Implementation of the Toshiba T1000 plasma display, which * has a fixed resolution of 640x200 pixels. * - * Version: @(#)m_tosh1x00_vid.c 1.0.10 2019/04/08 + * Version: @(#)m_tosh1x00_vid.c 1.0.11 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -675,7 +675,7 @@ vid_init(const device_t *info, UNUSED(void *parent)) io_sethandler(0x03d0, 0x000c, vid_in,NULL,NULL, vid_out,NULL,NULL, dev); - timer_add(vid_poll, &dev->cga.vidtime, TIMER_ALWAYS_ENABLED, dev); + timer_add(vid_poll, dev, &dev->cga.vidtime, TIMER_ALWAYS_ENABLED); video_inform(VID_TYPE_CGA, &timing_t1000); diff --git a/src/machines/m_tosh3100e_vid.c b/src/machines/m_tosh3100e_vid.c index 1884f5b..9c7bf44 100644 --- a/src/machines/m_tosh3100e_vid.c +++ b/src/machines/m_tosh3100e_vid.c @@ -22,7 +22,7 @@ * 61 50 52 0F 19 06 19 19 02 0D 0B 0C MONO * 2D 28 22 0A 67 00 64 67 02 03 06 07 640x400 * - * Version: @(#)m_t3100e_vid.c 1.0.10 2019/04/08 + * Version: @(#)m_t3100e_vid.c 1.0.11 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -713,7 +713,7 @@ vid_init(const device_t *info, UNUSED(void *parent)) /* 32K video RAM */ dev->vram = (uint8_t *)mem_alloc(0x8000); - timer_add(vid_poll, &dev->cga.vidtime, TIMER_ALWAYS_ENABLED, dev); + timer_add(vid_poll, dev, &dev->cga.vidtime, TIMER_ALWAYS_ENABLED); /* Occupy memory between 0xB8000 and 0xBFFFF */ mem_map_add(&dev->mapping, 0xb8000, 0x8000, diff --git a/src/machines/m_zenith_vid.c b/src/machines/m_zenith_vid.c index dcffbe5..d379920 100644 --- a/src/machines/m_zenith_vid.c +++ b/src/machines/m_zenith_vid.c @@ -17,7 +17,7 @@ * done on implementing other parts of the Yamaha V6355 chip * that implements the video controller. * - * Version: @(#)m_zenith_vid.c 1.0.2 2019/04/21 + * Version: @(#)m_zenith_vid.c 1.0.3 2019/04/25 * * Authors: Fred N. van Kempen, * John Elliott, @@ -655,7 +655,7 @@ vid_init(const device_t *info, UNUSED(void *parent)) io_sethandler(0x03d0, 0x000c, vid_in,NULL,NULL, vid_out,NULL,NULL, dev); - timer_add(vid_poll, &dev->cga.vidtime, TIMER_ALWAYS_ENABLED, dev); + timer_add(vid_poll, dev, &dev->cga.vidtime, TIMER_ALWAYS_ENABLED); /* Load the CGA Font ROM. */ video_load_font(CGA_FONT_ROM_PATH, FONT_CGA_THICK); diff --git a/src/mem.c b/src/mem.c index 883a1d7..ce3cce5 100644 --- a/src/mem.c +++ b/src/mem.c @@ -12,7 +12,7 @@ * The Port92 stuff should be moved to devices/system/memctl.c * as a standard device. * - * Version: @(#)mem.c 1.0.30 2019/04/25 + * Version: @(#)mem.c 1.0.31 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -690,8 +690,8 @@ writememwl(uint32_t seg, uint32_t addr, uint16_t val) } if (map && map->write_b) { - map->write_b(addr2, val, map->p); - map->write_b(addr2 + 1, val >> 8, map->p); + map->write_b(addr2, (val & 0xff), map->p); + map->write_b(addr2 + 1, (val >> 8), map->p); } } @@ -919,28 +919,28 @@ writememql(uint32_t seg, uint32_t addr, uint64_t val) map = write_mapping[addr2 >> 14]; if (map && map->write_l) { - map->write_l(addr2, val, map->p); - map->write_l(addr2+4, val >> 32, map->p); + map->write_l(addr2, (val & 0xffffffff), map->p); + map->write_l(addr2+4, (val >> 32), map->p); return; } if (map && map->write_w) { - map->write_w(addr2, val, map->p); - map->write_w(addr2 + 2, val >> 16, map->p); - map->write_w(addr2 + 4, val >> 32, map->p); - map->write_w(addr2 + 6, val >> 48, map->p); + map->write_w(addr2, (val & 0xffff), map->p); + map->write_w(addr2 + 2, (uint16_t)(val >> 16), map->p); + map->write_w(addr2 + 4, (uint16_t)(val >> 32), map->p); + map->write_w(addr2 + 6, (uint16_t)(val >> 48), map->p); return; } if (map && map->write_b) { - map->write_b(addr2, val, map->p); - map->write_b(addr2 + 1, val >> 8, map->p); - map->write_b(addr2 + 2, val >> 16, map->p); - map->write_b(addr2 + 3, val >> 24, map->p); - map->write_b(addr2 + 4, val >> 32, map->p); - map->write_b(addr2 + 5, val >> 40, map->p); - map->write_b(addr2 + 6, val >> 48, map->p); - map->write_b(addr2 + 7, val >> 56, map->p); + map->write_b(addr2, (val & 0xff), map->p); + map->write_b(addr2 + 1, (uint8_t)(val >> 8), map->p); + map->write_b(addr2 + 2, (uint8_t)(val >> 16), map->p); + map->write_b(addr2 + 3, (uint8_t)(val >> 24), map->p); + map->write_b(addr2 + 4, (uint8_t)(val >> 32), map->p); + map->write_b(addr2 + 5, (uint8_t)(val >> 40), map->p); + map->write_b(addr2 + 6, (uint8_t)(val >> 48), map->p); + map->write_b(addr2 + 7, (uint8_t)(val >> 56), map->p); } } diff --git a/src/nvr.c b/src/nvr.c index 0977a48..0b98704 100644 --- a/src/nvr.c +++ b/src/nvr.c @@ -8,7 +8,7 @@ * * Implement a generic NVRAM/CMOS/RTC device. * - * Version: @(#)nvr.c 1.0.15 2019/04/21 + * Version: @(#)nvr.c 1.0.16 2019/04/25 * * Author: Fred N. van Kempen, * @@ -215,7 +215,7 @@ nvr_init(nvr_t *nvr) } /* Set up our timer. */ - timer_add(onesec_timer, &nvr->onesec_time, TIMER_ALWAYS_ENABLED, nvr); + timer_add(onesec_timer, nvr, &nvr->onesec_time, TIMER_ALWAYS_ENABLED); /* It does not need saving yet. */ nvr_dosave = 0; diff --git a/src/timer.c b/src/timer.c index 2d7efdf..44e0041 100644 --- a/src/timer.c +++ b/src/timer.c @@ -8,13 +8,13 @@ * * System timer module. * - * Version: @(#)timer.c 1.0.2 2018/09/06 + * Version: @(#)timer.c 1.0.3 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, * Sarah Walker, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * Copyright 2008-2018 Sarah Walker. * @@ -47,129 +47,128 @@ #define TIMERS_MAX 64 -static struct +int64_t TIMER_USEC; +int64_t timer_one = 1; +int64_t timer_start = 0; +int64_t timer_count = 0; + + +static struct { + int present; + + int64_t *count; + int64_t *enable; + + void (*callback)(void *priv); + void *priv; +} timers[TIMERS_MAX]; +static int present = 0; +static int64_t latch = 0; + + +void +timer_process(void) { - int64_t present; - void (*callback)(void *priv); - void *priv; - int64_t *enable; - int64_t *count; -} timers[TIMERS_MAX]; + int64_t diff = latch - timer_count; /* get actual elapsed time */ + int64_t enable[TIMERS_MAX]; + int c, process = 0; + latch = 0; -int64_t TIMER_USEC; -int64_t timers_present = 0; -int64_t timer_one = 1; - -int64_t timer_count = 0, timer_latch = 0; -int64_t timer_start = 0; + for (c = 0; c < present; c++) { + /* This is needed to avoid timer crashes on hard reset. */ + if ((timers[c].enable == NULL) || (timers[c].count == NULL)) + continue; - -void timer_process(void) -{ - int64_t c; - int64_t process = 0; - /*Get actual elapsed time*/ - int64_t diff = timer_latch - timer_count; - int64_t enable[TIMERS_MAX]; - - timer_latch = 0; - - for (c = 0; c < timers_present; c++) - { - /* This is needed to avoid timer crashes on hard reset. */ - if ((timers[c].enable == NULL) || (timers[c].count == NULL)) - { - continue; - } - enable[c] = *timers[c].enable; - if (*timers[c].enable) - { - *timers[c].count = *timers[c].count - diff; - if (*timers[c].count <= 0) - process = 1; - } - } - - if (!process) - return; - - while (1) - { - int64_t lowest = 1, lowest_c; - - for (c = 0; c < timers_present; c++) - { - if (enable[c]) - { - if (*timers[c].count < lowest) - { - lowest = *timers[c].count; - lowest_c = c; - } - } - } - - if (lowest > 0) - break; - - timers[lowest_c].callback(timers[lowest_c].priv); - enable[lowest_c] = *timers[lowest_c].enable; - } -} - - -void timer_update_outstanding(void) -{ - int64_t c; - timer_latch = 0x7fffffffffffffff; - for (c = 0; c < timers_present; c++) - { - if (*timers[c].enable && *timers[c].count < timer_latch) - timer_latch = *timers[c].count; + enable[c] = *timers[c].enable; + if (enable[c]) { + *timers[c].count = *timers[c].count - diff; + if (*timers[c].count <= 0) + process = 1; } - timer_count = timer_latch = (timer_latch + ((1 << TIMER_SHIFT) - 1)); -} + } + if (! process) + return; -void timer_reset(void) -{ - timers_present = 0; - timer_latch = timer_count = 0; -} + while (1) { + int64_t lowest = 1; + int lowest_c; - -int64_t timer_add(void (*callback)(void *priv), int64_t *count, int64_t *enable, void *priv) -{ - int64_t i = 0; - - if (timers_present < TIMERS_MAX) - { - if (timers_present != 0) - { - /* This is the sanity check - it goes through all present timers and makes sure we're not adding a timer that already exists. */ - for (i = 0; i < timers_present; i++) - { - if (timers[i].present && (timers[i].callback == callback) && (timers[i].priv == priv) && (timers[i].count == count) && (timers[i].enable == enable)) - { - return 0; - } + for (c = 0; c < present; c++) { + if (enable[c]) { + if (*timers[c].count < lowest) { + lowest = *timers[c].count; + lowest_c = c; } } - - timers[timers_present].present = 1; - timers[timers_present].callback = callback; - timers[timers_present].priv = priv; - timers[timers_present].count = count; - timers[timers_present].enable = enable; - timers_present++; - return timers_present - 1; } - return -1; + + if (lowest > 0) + break; + + timers[lowest_c].callback(timers[lowest_c].priv); + + enable[lowest_c] = *timers[lowest_c].enable; + } } -void timer_set_callback(int64_t timer, void (*callback)(void *priv)) +void +timer_update_outstanding(void) { - timers[timer].callback = callback; + int c; + + latch = 0x7fffffffffffffff; + + for (c = 0; c < present; c++) { + if (*timers[c].enable && *timers[c].count < latch) + latch = *timers[c].count; + } + + timer_count = latch = (latch + ((1 << TIMER_SHIFT) - 1)); +} + + +void +timer_reset(void) +{ + present = 0; + + latch = timer_count = 0; +} + + +int +timer_add(void (*callback)(void *priv), void *priv, int64_t *count, int64_t *enable) +{ + int i = 0; + + /* Can we allocate another one/ */ + if (present == TIMERS_MAX) + return(-1); + + if (present != 0) { + /* + * Sanity check: + * go through all present timers and make sure + * we're not adding a timer that already exists. + */ + for (i = 0; i < present; i++) { + if (timers[i].present && + (timers[i].callback == callback) && + (timers[i].priv == priv) && + (timers[i].count == count) && (timers[i].enable == enable)) + return 0; + } + } + + timers[present].present = 1; + timers[present].callback = callback; + timers[present].priv = priv; + timers[present].count = count; + timers[present].enable = enable; + present++; + + return present - 1; } diff --git a/src/timer.h b/src/timer.h index 6da8068..a6504d2 100644 --- a/src/timer.h +++ b/src/timer.h @@ -8,13 +8,13 @@ * * Definitions for the system timer module. * - * Version: @(#)timer.h 1.0.2 2018/05/04 + * Version: @(#)timer.h 1.0.3 2019/04/25 * * Authors: Fred N. van Kempen, * Miran Grca, * Sarah Walker, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * Copyright 2008-2018 Sarah Walker. * @@ -40,57 +40,52 @@ # define EMU_TIMER_H -extern int64_t timer_start; +#define TIMER_SHIFT 6 -#define timer_start_period(cycles) \ +#define TIMER_ALWAYS_ENABLED &timer_one + + +extern int64_t TIMER_USEC; +extern int64_t timer_one; +extern int64_t timer_start; +extern int64_t timer_count; + + +#define timer_start_period(cycles) \ timer_start = cycles; -#define timer_end_period(cycles) \ - do \ - { \ - int64_t __diff = timer_start - (cycles); \ - timer_count -= __diff; \ - timer_start = cycles; \ - if (timer_count <= 0) \ - { \ - timer_process(); \ - timer_update_outstanding(); \ - } \ +#define timer_end_period(cycles) \ + do { \ + int64_t __diff = timer_start - (cycles); \ + timer_count -= __diff; \ + timer_start = cycles; \ + if (timer_count <= 0) { \ + timer_process(); \ + timer_update_outstanding(); \ + } \ } while (0) -#define timer_clock() \ - do \ - { \ - int64_t __diff; \ - if (AT) \ - { \ - __diff = timer_start - (cycles << TIMER_SHIFT); \ - timer_start = cycles << TIMER_SHIFT; \ - } \ - else \ - { \ +#define timer_clock() \ + do { \ + int64_t __diff; \ + if (AT) { \ + __diff = timer_start - (cycles << TIMER_SHIFT); \ + timer_start = cycles << TIMER_SHIFT; \ + } else { \ __diff = timer_start - (cycles * xt_cpu_multi); \ - timer_start = cycles * xt_cpu_multi; \ - } \ - timer_count -= __diff; \ - timer_process(); \ - timer_update_outstanding(); \ + timer_start = cycles * xt_cpu_multi; \ + } \ + timer_count -= __diff; \ + timer_process(); \ + timer_update_outstanding(); \ } while (0) -extern void timer_process(void); -extern void timer_update_outstanding(void); -extern void timer_reset(void); -extern int64_t timer_add(void (*callback)(void *priv), int64_t *count, int64_t *enable, void *priv); -extern void timer_set_callback(int64_t timer, void (*callback)(void *priv)); -#define TIMER_ALWAYS_ENABLED &timer_one - -extern int64_t timer_count; -extern int64_t timer_one; - -#define TIMER_SHIFT 6 - -extern int64_t TIMER_USEC; +extern void timer_process(void); +extern void timer_update_outstanding(void); +extern void timer_reset(void); +extern int timer_add(void (*callback)(void *priv), void *priv, + int64_t *count, int64_t *enable); #endif /*EMU_TIMER_H*/