Cleanups in the Bochs system timer code

- Now using macro DEV_register_timer() in all devices and lowlevel modules.
- Removed unused timer stuff from the plugin.cc/.h code.
This commit is contained in:
Volker Ruppert 2017-03-30 18:08:15 +00:00
parent cb33607004
commit c897ffa619
31 changed files with 51 additions and 83 deletions

View File

@ -130,7 +130,7 @@ void bx_acpi_ctrl_c::init(void)
if (BX_ACPI_THIS s.timer_index == BX_NULL_TIMER_HANDLE) {
BX_ACPI_THIS s.timer_index =
bx_pc_system.register_timer(this, timer_handler, 1000, 0, 0, "ACPI");
DEV_register_timer(this, timer_handler, 1000, 0, 0, "ACPI");
}
DEV_register_iowrite_handler(this, write_handler, ACPI_DBG_IO_ADDR, "ACPI", 4);

View File

@ -114,7 +114,7 @@ void bx_busm_c::init(void)
// Call our timer routine at 30hz
BX_BUSM_THIS timer_index =
bx_pc_system.register_timer(this, timer_handler, 33334, 1, 1, "bus mouse timer");
DEV_register_timer(this, timer_handler, 33334, 1, 1, "bus mouse timer");
for (int i=0x23C; i<=0x23F; i++) {
DEV_register_ioread_handler(this, read_handler, i, "Bus Mouse", 1);

View File

@ -298,7 +298,7 @@ void bx_devices_c::init(BX_MEM_C *newmem)
}
if (timer_handle != BX_NULL_TIMER_HANDLE) {
timer_handle = bx_pc_system.register_timer(this, timer_handler,
timer_handle = DEV_register_timer(this, timer_handler,
(unsigned) BX_IODEV_HANDLER_PERIOD, 1, 1, "devices.cc");
}

View File

@ -285,7 +285,7 @@ void bx_floppy_ctrl_c::init(void)
if (BX_FD_THIS s.floppy_timer_index == BX_NULL_TIMER_HANDLE) {
BX_FD_THIS s.floppy_timer_index =
bx_pc_system.register_timer(this, timer_handler, 250, 0, 0, "floppy");
DEV_register_timer(this, timer_handler, 250, 0, 0, "floppy");
}
/* phase out s.non_dma in favor of using FD_MS_NDMA, more like hardware */
BX_FD_THIS s.main_status_reg &= ~FD_MS_NDMA; // enable DMA from start

View File

@ -129,7 +129,7 @@ void bx_keyb_c::init(void)
0x0060, "8042 Keyboard controller", 1);
DEV_register_iowrite_handler(this, write_handler,
0x0064, "8042 Keyboard controller", 1);
BX_KEY_THIS timer_handle = bx_pc_system.register_timer(this, timer_handler,
BX_KEY_THIS timer_handle = DEV_register_timer(this, timer_handler,
SIM->get_param_num(BXPN_KBD_SERIAL_DELAY)->get(), 1, 1,
"8042 Keyboard controller");

View File

@ -473,8 +473,7 @@ void bx_e1000_c::init(void)
if (BX_E1000_THIS s.tx_timer_index == BX_NULL_TIMER_HANDLE) {
BX_E1000_THIS s.tx_timer_index =
bx_pc_system.register_timer(this, tx_timer_handler, 0,
0, 0, "e1000"); // one-shot, inactive
DEV_register_timer(this, tx_timer_handler, 0, 0, 0, "e1000"); // one-shot, inactive
}
BX_E1000_THIS s.statusbar_id = bx_gui->register_statusitem("E1000", 1);

View File

@ -285,8 +285,8 @@ bx_fbsd_pktmover_c::bx_fbsd_pktmover_c(const char *netif,
// Start the rx poll
this->rx_timer_index =
bx_pc_system.register_timer(this, this->rx_timer_handler, BX_BPF_POLL,
1, 1, "eth_fbsd"); // continuous, active
DEV_register_timer(this, this->rx_timer_handler, BX_BPF_POLL, 1, 1,
"eth_fbsd"); // continuous, active
this->rxh = rxh;
this->rxstat = rxstat;

View File

@ -239,8 +239,8 @@ bx_linux_pktmover_c::bx_linux_pktmover_c(const char *netif,
// Start the rx poll
this->rx_timer_index =
bx_pc_system.register_timer(this, this->rx_timer_handler, BX_PACKET_POLL,
1, 1, "eth_linux"); // continuous, active
DEV_register_timer(this, this->rx_timer_handler, BX_PACKET_POLL, 1, 1,
"eth_linux"); // continuous, active
this->rxh = rxh;
this->rxstat = rxstat;

View File

@ -105,8 +105,8 @@ bx_null_pktmover_c::bx_null_pktmover_c(const char *netif,
#if BX_ETH_NULL_LOGGING
// Start the rx poll
this->rx_timer_index =
bx_pc_system.register_timer(this, this->rx_timer_handler, 1000,
1, 1, "eth_null"); // continuous, active
DEV_register_timer(this, this->rx_timer_handler, 1000, 1, 1,
"eth_null"); // continuous, active
this->rxh = rxh;
this->rxstat = rxstat;
// eventually Bryce wants txlog to dump in pcap format so that

View File

@ -322,8 +322,8 @@ bx_slirp_pktmover_c::bx_slirp_pktmover_c(const char *netif,
(status == BX_NETDEV_100MBIT) ? 100 : 10;
if (bx_slirp_instances == 0) {
rx_timer_index =
bx_pc_system.register_timer(this, this->rx_timer_handler, 1000,
1, 1, "eth_slirp");
DEV_register_timer(this, this->rx_timer_handler, 1000, 1, 1,
"eth_slirp");
#ifndef WIN32
signal(SIGPIPE, SIG_IGN);
#endif

View File

@ -261,8 +261,8 @@ bx_socket_pktmover_c::bx_socket_pktmover_c(const char *netif,
// Start the rx poll
//
this->rx_timer_index =
bx_pc_system.register_timer(this, this->rx_timer_handler, BX_PACKET_POLL,
1, 1, "eth_socket"); // continuous, active
DEV_register_timer(this, this->rx_timer_handler, BX_PACKET_POLL, 1, 1,
"eth_socket"); // continuous, active
this->rxh = rxh;
this->rxstat = rxstat;

View File

@ -279,8 +279,8 @@ bx_tap_pktmover_c::bx_tap_pktmover_c(const char *netif,
// Start the rx poll
this->rx_timer_index =
bx_pc_system.register_timer(this, this->rx_timer_handler, 1000,
1, 1, "eth_tap"); // continuous, active
DEV_register_timer(this, this->rx_timer_handler, 1000, 1, 1,
"eth_tap"); // continuous, active
this->rxh = rxh;
this->rxstat = rxstat;
memcpy(&guest_macaddr[0], macaddr, 6);

View File

@ -203,8 +203,8 @@ bx_tuntap_pktmover_c::bx_tuntap_pktmover_c(const char *netif,
// Start the rx poll
this->rx_timer_index =
bx_pc_system.register_timer(this, this->rx_timer_handler, 1000,
1, 1, "eth_tuntap"); // continuous, active
DEV_register_timer(this, this->rx_timer_handler, 1000, 1, 1,
"eth_tuntap"); // continuous, active
this->rxh = rxh;
this->rxstat = rxstat;
memcpy(&guest_macaddr[0], macaddr, 6);

View File

@ -165,8 +165,8 @@ bx_vde_pktmover_c::bx_vde_pktmover_c(const char *netif,
// Start the rx poll
this->rx_timer_index =
bx_pc_system.register_timer(this, this->rx_timer_handler, 1000,
1, 1, "eth_vde"); // continuous, active
DEV_register_timer(this, this->rx_timer_handler, 1000, 1, 1,
"eth_vde"); // continuous, active
this->rxh = rxh;
this->rxstat = rxstat;
#if BX_ETH_VDE_LOGGING

View File

@ -252,8 +252,7 @@ void bx_vnet_pktmover_c::pktmover_init(
this->netdev_speed = (status == BX_NETDEV_1GBIT) ? 1000 :
(status == BX_NETDEV_100MBIT) ? 100 : 10;
this->rx_timer_index =
bx_pc_system.register_timer(this, this->rx_timer_handler, 1000,
0, 0, "eth_vnet");
DEV_register_timer(this, this->rx_timer_handler, 1000, 0, 0, "eth_vnet");
BX_INFO(("'vnet' network driver initialized"));
bx_vnet_instances++;

View File

@ -346,7 +346,7 @@ bx_win32_pktmover_c::bx_win32_pktmover_c(
BX_PANIC(("Could not allocate a recv packet"));
}
rx_timer_index =
bx_pc_system.register_timer(this, this->rx_timer_handler, 10000, 1, 1, "eth_win32");
DEV_register_timer(this, this->rx_timer_handler, 10000, 1, 1, "eth_win32");
#if BX_ETH_WIN32_LOGGING
pktlog_txt = fopen("eth_win32-pktlog.txt", "wb");

View File

@ -215,8 +215,8 @@ void bx_ne2k_c::init(void)
if (BX_NE2K_THIS s.tx_timer_index == BX_NULL_TIMER_HANDLE) {
BX_NE2K_THIS s.tx_timer_index =
bx_pc_system.register_timer(this, tx_timer_handler, 0,
0,0, "ne2k"); // one-shot, inactive
DEV_register_timer(this, tx_timer_handler, 0, 0, 0,
"ne2k"); // one-shot, inactive
}
// Register the IRQ and i/o port addresses
if (!BX_NE2K_THIS s.pci_enabled) {

View File

@ -293,21 +293,21 @@ bx_serial_c::init(void)
if (BX_SER_THIS s[i].tx_timer_index == BX_NULL_TIMER_HANDLE) {
BX_SER_THIS s[i].tx_timer_index =
bx_pc_system.register_timer(this, tx_timer_handler, 0,
0,0, "serial.tx"); // one-shot, inactive
DEV_register_timer(this, tx_timer_handler, 0, 0, 0,
"serial.tx"); // one-shot, inactive
bx_pc_system.setTimerParam(BX_SER_THIS s[i].tx_timer_index, i);
}
if (BX_SER_THIS s[i].rx_timer_index == BX_NULL_TIMER_HANDLE) {
BX_SER_THIS s[i].rx_timer_index =
bx_pc_system.register_timer(this, rx_timer_handler, 0,
0,0, "serial.rx"); // one-shot, inactive
DEV_register_timer(this, rx_timer_handler, 0, 0, 0,
"serial.rx"); // one-shot, inactive
bx_pc_system.setTimerParam(BX_SER_THIS s[i].rx_timer_index, i);
}
if (BX_SER_THIS s[i].fifo_timer_index == BX_NULL_TIMER_HANDLE) {
BX_SER_THIS s[i].fifo_timer_index =
bx_pc_system.register_timer(this, fifo_timer_handler, 0,
0,0, "serial.fifo"); // one-shot, inactive
DEV_register_timer(this, fifo_timer_handler, 0, 0, 0,
"serial.fifo"); // one-shot, inactive
bx_pc_system.setTimerParam(BX_SER_THIS s[i].fifo_timer_index, i);
}

View File

@ -293,19 +293,19 @@ void bx_es1370_c::init(void)
BX_ES1370_THIS s.mpu_outputinit = (BX_ES1370_THIS midimode & 1);
if (BX_ES1370_THIS s.dac1_timer_index == BX_NULL_TIMER_HANDLE) {
BX_ES1370_THIS s.dac1_timer_index = bx_pc_system.register_timer
BX_ES1370_THIS s.dac1_timer_index = DEV_register_timer
(BX_ES1370_THIS_PTR, es1370_timer_handler, 1, 1, 0, "es1370.dac1");
// DAC1 timer: inactive, continuous, frequency variable
bx_pc_system.setTimerParam(BX_ES1370_THIS s.dac1_timer_index, 0);
}
if (BX_ES1370_THIS s.dac2_timer_index == BX_NULL_TIMER_HANDLE) {
BX_ES1370_THIS s.dac2_timer_index = bx_pc_system.register_timer
BX_ES1370_THIS s.dac2_timer_index = DEV_register_timer
(BX_ES1370_THIS_PTR, es1370_timer_handler, 1, 1, 0, "es1370.dac2");
// DAC2 timer: inactive, continuous, frequency variable
bx_pc_system.setTimerParam(BX_ES1370_THIS s.dac2_timer_index, 1);
}
if (BX_ES1370_THIS s.mpu_timer_index == BX_NULL_TIMER_HANDLE) {
BX_ES1370_THIS s.mpu_timer_index = bx_pc_system.register_timer
BX_ES1370_THIS s.mpu_timer_index = DEV_register_timer
(BX_ES1370_THIS_PTR, mpu_timer_handler, 500000 / 384, 1, 1, "es1370.mpu");
// midi timer: active, continuous, 500000 / 384 seconds (384 = delta time, 500000 = sec per beat at 120 bpm. Don't change this!)
}

View File

@ -396,19 +396,19 @@ void bx_sb16_c::init(void)
// initialize the timers
if (MPU.timer_handle == BX_NULL_TIMER_HANDLE) {
MPU.timer_handle = bx_pc_system.register_timer
MPU.timer_handle = DEV_register_timer
(BX_SB16_THISP, mpu_timer, 500000 / 384, 1, 1, "sb16.mpu");
// midi timer: active, continuous, 500000 / 384 seconds (384 = delta time, 500000 = sec per beat at 120 bpm. Don't change this!)
}
if (DSP.timer_handle == BX_NULL_TIMER_HANDLE) {
DSP.timer_handle = bx_pc_system.register_timer
DSP.timer_handle = DEV_register_timer
(BX_SB16_THISP, dsp_dmatimer, 1, 1, 0, "sb16.dsp");
// dma timer: inactive, continuous, frequency variable
}
if (OPL.timer_handle == BX_NULL_TIMER_HANDLE) {
OPL.timer_handle = bx_pc_system.register_timer
OPL.timer_handle = DEV_register_timer
(BX_SB16_THISP, opl_timer, 80, 1, 0, "sb16.opl");
// opl timer: inactive, continuous, frequency 80us
}

View File

@ -203,7 +203,7 @@ int bx_soundlow_wavein_alsa_c::openwaveinput(const char *wavedev, sound_record_h
{
record_handler = rh;
if (rh != NULL) {
record_timer_index = bx_pc_system.register_timer(this, record_timer_handler, 1, 1, 0, "wavein");
record_timer_index = DEV_register_timer(this, record_timer_handler, 1, 1, 0, "wavein");
// record timer: inactive, continuous, frequency variable
}
wavein_param.samplerate = 0;

View File

@ -518,7 +518,7 @@ int bx_soundlow_wavein_c::openwaveinput(const char *wavedev, sound_record_handle
UNUSED(wavedev);
record_handler = rh;
if (rh != NULL) {
record_timer_index = bx_pc_system.register_timer(this, record_timer_handler, 1, 1, 0, "wavein");
record_timer_index = DEV_register_timer(this, record_timer_handler, 1, 1, 0, "wavein");
// record timer: inactive, continuous, frequency variable
}
return BX_SOUNDLOW_OK;

View File

@ -186,7 +186,7 @@ int bx_soundlow_wavein_oss_c::openwaveinput(const char *wavedev, sound_record_ha
{
record_handler = rh;
if (rh != NULL) {
record_timer_index = bx_pc_system.register_timer(this, record_timer_handler, 1, 1, 0, "soundlnx");
record_timer_index = DEV_register_timer(this, record_timer_handler, 1, 1, 0, "soundlnx");
// record timer: inactive, continuous, frequency variable
}
if (wavein_fd == -1) {

View File

@ -203,7 +203,7 @@ int bx_soundlow_wavein_sdl2_c::openwaveinput(const char *wavedev, sound_record_h
UNUSED(wavedev);
record_handler = rh;
if (rh != NULL) {
record_timer_index = bx_pc_system.register_timer(this, record_timer_handler, 1, 1, 0, "wavein");
record_timer_index = DEV_register_timer(this, record_timer_handler, 1, 1, 0, "wavein");
// record timer: inactive, continuous, frequency variable
}
return BX_SOUNDLOW_OK;

View File

@ -244,7 +244,7 @@ int bx_soundlow_wavein_win_c::openwaveinput(const char *wavedev, sound_record_ha
UNUSED(wavedev);
record_handler = rh;
if (rh != NULL) {
record_timer_index = bx_pc_system.register_timer(this, record_timer_handler, 1, 1, 0, "soundwin");
record_timer_index = DEV_register_timer(this, record_timer_handler, 1, 1, 0, "soundwin");
// record timer: inactive, continuous, frequency variable
}
recording = 0;

View File

@ -78,7 +78,7 @@ void bx_uhci_core_c::init_uhci(Bit8u devfunc, Bit16u devid, Bit8u headt, Bit8u i
// Call our timer routine every 1mS (1,000uS)
// Continuous and active
hub.timer_index =
bx_pc_system.register_timer(this, uhci_timer_handler, 1000, 1,1, "usb.timer");
DEV_register_timer(this, uhci_timer_handler, 1000, 1,1, "usb.timer");
hub.devfunc = devfunc;
DEV_register_pci_handlers(this, &hub.devfunc, BX_PLUGIN_USB_UHCI,

View File

@ -234,7 +234,7 @@ void bx_usb_ehci_c::init(void)
// Call our frame timer routine every 1mS (1,024uS)
// Continuous and active
BX_EHCI_THIS hub.frame_timer_index = bx_pc_system.register_timer(this, ehci_frame_handler,
BX_EHCI_THIS hub.frame_timer_index = DEV_register_timer(this, ehci_frame_handler,
FRAME_TIMER_USEC, 1, 1, "ehci.frame_timer");
BX_EHCI_THIS devfunc = 0x07;

View File

@ -174,7 +174,7 @@ void bx_usb_ohci_c::init(void)
// Call our frame timer routine every 1mS (1,000uS)
// Continuous and active
BX_OHCI_THIS hub.frame_timer_index =
bx_pc_system.register_timer(this, usb_frame_handler, 1000, 1,1, "ohci.frame_timer");
DEV_register_timer(this, usb_frame_handler, 1000, 1,1, "ohci.frame_timer");
BX_OHCI_THIS hub.devfunc = 0x00;
DEV_register_pci_handlers(this, &BX_OHCI_THIS hub.devfunc, BX_PLUGIN_USB_OHCI,

View File

@ -257,7 +257,7 @@ void bx_usb_xhci_c::init(void)
}
BX_XHCI_THIS xhci_timer_index =
bx_pc_system.register_timer(this, xhci_timer_handler, 1024, 1, 1, "xhci_timer");
DEV_register_timer(this, xhci_timer_handler, 1024, 1, 1, "xhci_timer");
BX_XHCI_THIS devfunc = 0x00;
DEV_register_pci_handlers(this, &BX_XHCI_THIS devfunc, BX_PLUGIN_USB_XHCI,

View File

@ -86,10 +86,6 @@ int (*pluginRegisterDefaultIOReadHandler)(void *thisPtr, ioReadHandler_t callbac
const char *name, Bit8u mask) = 0;
int (*pluginRegisterDefaultIOWriteHandler)(void *thisPtr, ioWriteHandler_t callback,
const char *name, Bit8u mask) = 0;
int (*pluginRegisterTimer)(void *this_ptr, void (*funct)(void *),
Bit32u useconds, bx_bool continuous,
bx_bool active, const char* name) = 0;
void (*pluginActivateTimer)(unsigned id, Bit32u usec, bx_bool continuous) = 0;
void (*pluginHRQHackCallback)(void);
unsigned pluginHRQ = 0;
@ -256,23 +252,6 @@ builtinRegisterDefaultIOWriteHandler(void *thisPtr, ioWriteHandler_t callback,
return 0;
}
static int
builtinRegisterTimer(void *this_ptr, void (*funct)(void *),
Bit32u useconds, bx_bool continuous,
bx_bool active, const char* name)
{
int id = bx_pc_system.register_timer (this_ptr, funct, useconds, continuous, active, name);
pluginlog->ldebug("plugin %s registered timer %d", name, id);
return id;
}
static void
builtinActivateTimer(unsigned id, Bit32u usec, bx_bool continuous)
{
bx_pc_system.activate_timer (id, usec, continuous);
pluginlog->ldebug("plugin activated timer %d", id);
}
#if BX_PLUGINS
/************************************************************************/
/* Plugin initialization / deinitialization */
@ -495,9 +474,6 @@ plugin_startup(void)
pluginRegisterDefaultIOReadHandler = builtinRegisterDefaultIOReadHandler;
pluginRegisterDefaultIOWriteHandler = builtinRegisterDefaultIOWriteHandler;
pluginRegisterTimer = builtinRegisterTimer;
pluginActivateTimer = builtinActivateTimer;
pluginlog = new logfunctions();
pluginlog->put("PLUGIN");
#if BX_PLUGINS && !defined(WIN32)

View File

@ -141,10 +141,7 @@ extern "C" {
#define DEV_reset_devices(type) {bx_devices.reset(type); }
#define DEV_register_state() {bx_devices.register_state(); }
#define DEV_after_restore_state() {bx_devices.after_restore_state(); }
#define DEV_register_timer(a,b,c,d,e,f) bx_pc_system.register_timer(a,b,c,d,e,f)
#define DEV_mouse_enabled_changed(en) (bx_devices.mouse_enabled_changed(en))
#define DEV_mouse_motion(dx, dy, dz, bs, absxy) (bx_devices.mouse_motion(dx, dy, dz, bs, absxy))
///////// Removable devices macros
#define DEV_optional_key_enq(a) (bx_devices.optional_key_enq(a))
@ -172,6 +169,10 @@ extern "C" {
(bx_devices.pluginKeyboard->paste_bytes(bytes,count))
#define DEV_kbd_release_keys() (bx_devices.pluginKeyboard->release_keys())
///////// mouse macros
#define DEV_mouse_enabled_changed(en) (bx_devices.mouse_enabled_changed(en))
#define DEV_mouse_motion(dx, dy, dz, bs, absxy) (bx_devices.mouse_motion(dx, dy, dz, bs, absxy))
///////// hard drive macros
#define DEV_hd_read_handler(a, b, c) \
(bx_devices.pluginHardDrive->virt_read_handler(b, c))
@ -332,13 +333,6 @@ BOCHSAPI extern int (*pluginRegisterDefaultIOWriteHandler)(void *thisPtr, ioWrit
BOCHSAPI extern void (*pluginRegisterIRQ)(unsigned irq, const char *name);
BOCHSAPI extern void (*pluginUnregisterIRQ)(unsigned irq, const char *name);
/* === Timer stuff === */
BOCHSAPI extern int (*pluginRegisterTimer)(void *this_ptr, void (*funct)(void *),
Bit32u useconds, bx_bool continuous,
bx_bool active, const char *name);
BOCHSAPI extern void (*pluginActivateTimer)(unsigned id, Bit32u usec, bx_bool continuous);
/* === HRQ stuff === */
BOCHSAPI extern void (*pluginSetHRQ)(unsigned val);
BOCHSAPI extern void (*pluginSetHRQHackCallback)(void (*callback)(void));