diff --git a/core/timermanager.cpp b/core/timermanager.cpp index 78e31ca1..fad7ef0b 100644 --- a/core/timermanager.cpp +++ b/core/timermanager.cpp @@ -112,7 +112,7 @@ uint64_t TimerManager::process_timers() this->cb_active = true; // invoke timer callback - cb(); + cb(time_now, timeout_ns); this->cb_active = false; diff --git a/core/timermanager.h b/core/timermanager.h index 37e01447..03494c2f 100644 --- a/core/timermanager.h +++ b/core/timermanager.h @@ -40,7 +40,7 @@ constexpr auto ONE_BILLION_NS = 1000000000; #define USECS_TO_NSECS(us) (us) * NS_PER_USEC #define MSECS_TO_NSECS(ms) (ms) * NS_PER_MSEC -typedef std::function timer_cb; +typedef std::function timer_cb; typedef std::function notify_changes_cb; /** Extend std::priority_queue as suggested here: diff --git a/cpu/ppc/ppcopcodes.cpp b/cpu/ppc/ppcopcodes.cpp index 140fb70e..d001392d 100644 --- a/cpu/ppc/ppcopcodes.cpp +++ b/cpu/ppc/ppcopcodes.cpp @@ -913,7 +913,7 @@ static uint32_t decrementer_timer_id = 0; static void update_decrementer(bool update_time_stamp, uint32_t oldval, uint32_t newval); -static void trigger_decrementer_exception() { +static void trigger_decrementer_exception(uint64_t = 0, uint64_t = 0) { if (ppc_state.msr & MSR::EE) { dec_exception_pending = false; //LOG_F(WARNING, "decrementer exception triggered"); @@ -925,7 +925,7 @@ static void trigger_decrementer_exception() { } } -static void trigger_timed_decrementer_exception() { +static void trigger_timed_decrementer_exception(uint64_t, uint64_t) { decrementer_timer_id = 0; uint32_t new_val = calc_dec_value(); if (new_val >= 0 && new_val != uint32_t(-1)) { @@ -935,7 +935,7 @@ static void trigger_timed_decrementer_exception() { trigger_decrementer_exception(); } -static void trigger_immediate_decrementer_exception() { +static void trigger_immediate_decrementer_exception(uint64_t, uint64_t) { decrementer_timer_id = 0; update_decrementer(false, ppc_state.spr[SPR::DEC_S], ppc_state.spr[SPR::DEC_S]); trigger_decrementer_exception(); diff --git a/debugger/debugger.cpp b/debugger/debugger.cpp index 5bd24886..30e5648a 100644 --- a/debugger/debugger.cpp +++ b/debugger/debugger.cpp @@ -1167,7 +1167,7 @@ void DppcDebugger::enter_debugger() { cout << exc.what() << endl; continue; } - TimerManager::get_instance()->add_oneshot_timer(0, [irq_bit](){ + TimerManager::get_instance()->add_oneshot_timer(0, [irq_bit](uint64_t, uint64_t){ ViaCuda* via_obj = dynamic_cast(gMachineObj->get_comp_by_name("ViaCuda")); via_obj->assert_int(irq_bit); }); diff --git a/devices/common/ata/atabasedevice.cpp b/devices/common/ata/atabasedevice.cpp index 16bdac08..9bf3cd56 100644 --- a/devices/common/ata/atabasedevice.cpp +++ b/devices/common/ata/atabasedevice.cpp @@ -78,7 +78,7 @@ uint16_t AtaBaseDevice::read(const uint8_t reg_addr) { } else { this->chunk_cnt = std::min(this->xfer_cnt, this->chunk_size); TimerManager::get_instance()->add_oneshot_timer( - USECS_TO_NSECS(100), [this]() { this->update_intrq(1); }); + USECS_TO_NSECS(100), [this](uint64_t, uint64_t) { this->update_intrq(1); }); } } return ret_data; @@ -121,7 +121,7 @@ void AtaBaseDevice::write(const uint8_t reg_addr, const uint16_t value) { this->xfer_cnt = 0; this->r_status &= ~DRQ; //LOG_F(INFO, "%s: write complete", name.c_str()); - TimerManager::get_instance()->add_oneshot_timer(USECS_TO_NSECS(100), [this]() { + TimerManager::get_instance()->add_oneshot_timer(USECS_TO_NSECS(100), [this](uint64_t, uint64_t) { this->r_status &= ~BSY; this->update_intrq(1); }); @@ -129,7 +129,7 @@ void AtaBaseDevice::write(const uint8_t reg_addr, const uint16_t value) { this->cur_data_ptr = this->data_ptr; this->chunk_cnt = std::min(this->xfer_cnt, this->chunk_size); //LOG_F(INFO, "%s: write needs more data (left: 0x%x)", name.c_str(), xfer_cnt); - TimerManager::get_instance()->add_oneshot_timer(USECS_TO_NSECS(100), [this]() { + TimerManager::get_instance()->add_oneshot_timer(USECS_TO_NSECS(100), [this](uint64_t, uint64_t) { this->signal_data_ready(); }); } @@ -213,7 +213,7 @@ int AtaBaseDevice::pull_data(uint8_t *buf, int len) { if (!this->xfer_cnt) { this->is_dma_xfer = false; this->data_ptr = nullptr; - TimerManager::get_instance()->add_oneshot_timer(500, [this]() { + TimerManager::get_instance()->add_oneshot_timer(500, [this](uint64_t, uint64_t) { this->r_status &= ~(BSY | DRQ); this->update_intrq(1); }); @@ -240,7 +240,7 @@ int AtaBaseDevice::push_data(uint8_t *buf, int len) { this->is_dma_xfer = false; this->data_ptr = nullptr; this->cur_data_ptr = nullptr; - TimerManager::get_instance()->add_oneshot_timer(500, [this]() { + TimerManager::get_instance()->add_oneshot_timer(500, [this](uint64_t, uint64_t) { this->r_status &= ~(BSY | DRQ); this->update_intrq(1); }); diff --git a/devices/common/ata/idechannel.cpp b/devices/common/ata/idechannel.cpp index 184c3002..970e48ef 100644 --- a/devices/common/ata/idechannel.cpp +++ b/devices/common/ata/idechannel.cpp @@ -91,7 +91,7 @@ int IdeChannel::xfer_to(DmaChannel *ch_obj, uint8_t *buf, int len) { } void IdeChannel::assert_dmareq(uint64_t delay) { - TimerManager::get_instance()->add_oneshot_timer(delay, [this]() { + TimerManager::get_instance()->add_oneshot_timer(delay, [this](uint64_t, uint64_t) { //LOG_F(INFO, "%s: DMAREQ asserted", this->name.c_str()); this->channel_obj->xfer_retry(); }); diff --git a/devices/common/dbdma.cpp b/devices/common/dbdma.cpp index f17351c0..f2e6612c 100644 --- a/devices/common/dbdma.cpp +++ b/devices/common/dbdma.cpp @@ -291,7 +291,7 @@ void DMAChannel::update_irq(uint8_t cmd_bits) { } if (cond) { if (int_ctrl) { - TimerManager::get_instance()->add_immediate_timer([this] { + TimerManager::get_instance()->add_immediate_timer([this](uint64_t, uint64_t) { this->int_ctrl->ack_dma_int(this->irq_id, 1); }); } else diff --git a/devices/common/scsi/sc53c94.cpp b/devices/common/scsi/sc53c94.cpp index 1f9cefa5..eed38642 100644 --- a/devices/common/scsi/sc53c94.cpp +++ b/devices/common/scsi/sc53c94.cpp @@ -327,7 +327,7 @@ void Sc53C94::exec_command() } my_timer_id = TimerManager::get_instance()->add_oneshot_timer( USECS_TO_NSECS(25), - [this]() { + [this](uint64_t, uint64_t) { my_timer_id = 0; this->bus_obj->release_ctrl_line(this->my_bus_id, SCSI_CTRL_RST); }); @@ -485,7 +485,7 @@ void Sc53C94::seq_defer_state(uint64_t delay_ns) if (delay_ns) { this->seq_timer_id = TimerManager::get_instance()->add_oneshot_timer( delay_ns, - [this]() { + [this](uint64_t, uint64_t) { // re-enter the sequencer with the state specified in next_state this->seq_timer_id = 0; this->cur_state = this->next_state; @@ -493,7 +493,7 @@ void Sc53C94::seq_defer_state(uint64_t delay_ns) }); } else { this->seq_timer_id = TimerManager::get_instance()->add_immediate_timer( - [this]() { + [this](uint64_t, uint64_t) { // re-enter the sequencer with the state specified in next_state this->seq_timer_id = 0; this->cur_state = this->next_state; diff --git a/devices/common/scsi/scsibusctrl.cpp b/devices/common/scsi/scsibusctrl.cpp index fd694606..b2ee20f0 100644 --- a/devices/common/scsi/scsibusctrl.cpp +++ b/devices/common/scsi/scsibusctrl.cpp @@ -33,7 +33,7 @@ using namespace Scsi_Bus_Controller; void ScsiBusController::seq_defer_state(uint64_t delay_ns) { seq_timer_id = TimerManager::get_instance()->add_oneshot_timer( delay_ns, - [this]() { + [this](uint64_t, uint64_t) { // re-enter the sequencer with the state specified in next_state this->cur_state = this->next_state; this->sequencer(); diff --git a/devices/common/scsi/scsihd.cpp b/devices/common/scsi/scsihd.cpp index fde42cba..929518b1 100644 --- a/devices/common/scsi/scsihd.cpp +++ b/devices/common/scsi/scsihd.cpp @@ -177,7 +177,7 @@ void ScsiHardDisk::format() { if (this->cmd_buf[1] & 0x10) ABORT_F("%s: defect list isn't supported yet", this->name.c_str()); - TimerManager::get_instance()->add_oneshot_timer(NS_PER_SEC, [this]() { + TimerManager::get_instance()->add_oneshot_timer(NS_PER_SEC, [this](uint64_t, uint64_t) { this->switch_phase(ScsiPhase::STATUS); }); } diff --git a/devices/common/scsi/scsiphysdevice.cpp b/devices/common/scsi/scsiphysdevice.cpp index b98ce46d..49936fc2 100644 --- a/devices/common/scsi/scsiphysdevice.cpp +++ b/devices/common/scsi/scsiphysdevice.cpp @@ -39,7 +39,7 @@ void ScsiPhysDevice::notify(ScsiNotification notif_type, int param) LOG_F(9, "device %d selected", this->scsi_id); TimerManager::get_instance()->add_oneshot_timer( BUS_SETTLE_DELAY, - [this]() { + [this](uint64_t, uint64_t) { // don't confirm selection if BSY or I/O are asserted if (this->bus_obj->test_ctrl_lines(SCSI_CTRL_BSY | SCSI_CTRL_IO)) return; diff --git a/devices/common/viacuda.cpp b/devices/common/viacuda.cpp index cd91837b..b75e5f9a 100644 --- a/devices/common/viacuda.cpp +++ b/devices/common/viacuda.cpp @@ -252,7 +252,7 @@ void ViaCuda::write(int reg, uint8_t value) { // set up timeout timer for T2 this->t2_timer_id = TimerManager::get_instance()->add_oneshot_timer( (this->via_clk_dur * (this->t2_counter + 3) + (uint64_t(1) << 36)) >> 37, - [this]() { + [this](uint64_t, uint64_t) { this->t2_timer_id = 0; this->assert_t2_int(); } @@ -306,7 +306,7 @@ void ViaCuda::activate_t1() { // set up timout timer for T1 this->t1_timer_id = TimerManager::get_instance()->add_oneshot_timer( (this->via_clk_dur * (this->t1_counter + 3) + (uint64_t(1) << 36)) >> 37, - [this]() { + [this](uint64_t, uint64_t) { // reload the T1 counter from the corresponding latches this->t1_counter = (this->via_t1lh << 8) | this->via_t1ll; this->t1_timer_id = 0; @@ -388,7 +388,7 @@ void ViaCuda::schedule_sr_int(uint64_t timeout_ns) { } this->sr_timer_id = TimerManager::get_instance()->add_oneshot_timer( timeout_ns, - [this]() { + [this](uint64_t, uint64_t) { this->sr_timer_id = 0; this->assert_sr_int(); } @@ -422,7 +422,7 @@ void ViaCuda::write(uint8_t new_state) { // start response transaction this->treq_timer_id = TimerManager::get_instance()->add_oneshot_timer( USECS_TO_NSECS(13), // delay TREQ assertion for New World - [this]() { + [this](uint64_t, uint64_t) { this->via_portb &= ~CUDA_TREQ; // assert TREQ this->treq = 0; this->treq_timer_id = 0; diff --git a/devices/floppy/swim3.cpp b/devices/floppy/swim3.cpp index ac561860..1452169e 100644 --- a/devices/floppy/swim3.cpp +++ b/devices/floppy/swim3.cpp @@ -275,7 +275,7 @@ void Swim3Ctrl::start_stepping() if (this->step_count > 1) { this->step_timer_id = TimerManager::get_instance()->add_cyclic_timer( USECS_TO_NSECS(80), - [this]() { + [this](uint64_t, uint64_t) { this->do_step(); } ); @@ -319,7 +319,7 @@ void Swim3Ctrl::start_disk_access() this->access_timer_id = TimerManager::get_instance()->add_oneshot_timer( this->int_drive->sync_to_disk(), - [this]() { + [this](uint64_t, uint64_t) { this->cur_state = SWIM3_ADDR_MARK_SEARCH; this->disk_access(); } @@ -371,7 +371,7 @@ void Swim3Ctrl::disk_access() this->access_timer_id = TimerManager::get_instance()->add_oneshot_timer( delay, - [this]() { + [this](uint64_t, uint64_t) { this->disk_access(); } ); @@ -401,7 +401,7 @@ void Swim3Ctrl::init_timer(const uint8_t start_val) this->one_us_timer_id = TimerManager::get_instance()->add_oneshot_timer( uint32_t(this->timer_val) * NS_PER_USEC, - [this]() { + [this](uint64_t, uint64_t) { this->timer_val = 0; this->int_flags |= INT_TIMER_DONE; update_irq(); diff --git a/devices/ioctrl/amic.cpp b/devices/ioctrl/amic.cpp index 0f7c2c5a..dc7f949f 100644 --- a/devices/ioctrl/amic.cpp +++ b/devices/ioctrl/amic.cpp @@ -115,7 +115,7 @@ int AMIC::device_postinit() // AMIC drives the VIA CA1 internally to generate 60.15 Hz interrupts this->pseudo_vbl_tid = TimerManager::get_instance()->add_cyclic_timer( static_cast((1.0f/60.15) * NS_PER_SEC + 0.5f), - [this]() { + [this](uint64_t, uint64_t) { this->viacuda->assert_ctrl_line(ViaLine::CA1); }); @@ -635,7 +635,7 @@ void AmicSndOutDma::update_irq() { uint8_t new_level = !!((this->dma_out_ctrl >> 4) & this->dma_out_ctrl); if (new_level != this->irq_level) { this->irq_level = new_level; - TimerManager::get_instance()->add_immediate_timer([this] { + TimerManager::get_instance()->add_immediate_timer([this](uint64_t, uint64_t) { this->int_ctrl->ack_dma_int(this->snd_dma_irq_id, this->irq_level); }); } diff --git a/devices/memctrl/platinum.cpp b/devices/memctrl/platinum.cpp index 6d58213d..707ae07f 100644 --- a/devices/memctrl/platinum.cpp +++ b/devices/memctrl/platinum.cpp @@ -591,7 +591,7 @@ void PlatinumCtrl::enable_cursor_int() { this->cursor_task_id = TimerManager::get_instance()->add_cyclic_timer( cursor_int_freq, - [this]() { + [this](uint64_t, uint64_t) { this->update_irq(1, SWATCH_INT_CURSOR); // generate cursor interrupt } ); diff --git a/devices/sound/awacs.cpp b/devices/sound/awacs.cpp index 2162863d..82ce029d 100644 --- a/devices/sound/awacs.cpp +++ b/devices/sound/awacs.cpp @@ -116,7 +116,7 @@ void AwacsBase::dma_in_data() { this->dma_in_timer_id = TimerManager::get_instance()->add_oneshot_timer( 10000, - [this]() { + [this](uint64_t, uint64_t) { // re-enter the sequencer with the state specified in next_state this->dma_in_timer_id = 0; this->dma_in_data(); diff --git a/devices/sound/burgundy.cpp b/devices/sound/burgundy.cpp index 52c02eef..e127ea51 100644 --- a/devices/sound/burgundy.cpp +++ b/devices/sound/burgundy.cpp @@ -115,7 +115,7 @@ void BurgundyCodec::snd_ctrl_write(uint32_t offset, uint32_t value, int size) { TimerManager::get_instance()->add_oneshot_timer( USECS_TO_NSECS(22), // average is approximately 22.6 µs on a real B&W G3 - [this]() { + [this](uint64_t, uint64_t) { this->first_valid = false; this->byte_counter = (this->byte_counter + 1) & 3; }); diff --git a/devices/sound/soundserver_cubeb.cpp b/devices/sound/soundserver_cubeb.cpp index f31cb301..6ec82f53 100644 --- a/devices/sound/soundserver_cubeb.cpp +++ b/devices/sound/soundserver_cubeb.cpp @@ -170,7 +170,7 @@ int SoundServer::open_out_stream(uint32_t sample_rate, DmaOutChannel *dma_ch) // Set up a cyclic-timer DMA drain callback. It keeps the guest sound DMA // advancing even if the host audio stream cannot be started, otherwise // the guest sound driver would stall forever waiting for DMA interrupts. - impl->deterministic_poll_cb = [dma_ch] { + impl->deterministic_poll_cb = [dma_ch](uint64_t, uint64_t) { if (!dma_ch->is_out_active()) { return; } diff --git a/devices/video/appleramdac.cpp b/devices/video/appleramdac.cpp index 313cde72..87017d6a 100644 --- a/devices/video/appleramdac.cpp +++ b/devices/video/appleramdac.cpp @@ -107,7 +107,7 @@ void AppleRamdac::iodev_write(uint32_t address, uint16_t value) { } this->cursor_pos_lo = value; this->cursor_timer_id = TimerManager::get_instance()->add_oneshot_timer( - NS_PER_SEC / 60, [this]() { + NS_PER_SEC / 60, [this](uint64_t, uint64_t) { this->cursor_xpos = (this->cursor_xpos & 0xff00) | (this->cursor_pos_lo & 0x00ff); }); #else diff --git a/devices/video/valkyrie.cpp b/devices/video/valkyrie.cpp index 3df5d204..7b25df12 100644 --- a/devices/video/valkyrie.cpp +++ b/devices/video/valkyrie.cpp @@ -193,7 +193,7 @@ void ValkyrieVideo::schedule_mode_switch() { TimerManager::get_instance()->cancel_timer(this->mode_timer_id); this->mode_timer_id = TimerManager::get_instance()->add_oneshot_timer( - MSECS_TO_NSECS(3), [this] { + MSECS_TO_NSECS(3), [this](uint64_t, uint64_t) { this->enable_video_internal(); }); } diff --git a/devices/video/videoctrl.cpp b/devices/video/videoctrl.cpp index d76d1414..0ea36259 100644 --- a/devices/video/videoctrl.cpp +++ b/devices/video/videoctrl.cpp @@ -104,7 +104,7 @@ void VideoCtrlBase::start_refresh_task() { uint64_t refresh_interval = static_cast(1.0f / refresh_rate * NS_PER_SEC + 0.5); this->refresh_task_id = TimerManager::get_instance()->add_cyclic_timer( refresh_interval, - [this]() { + [this](uint64_t, uint64_t) { // assert VBL interrupt this->vbl_cb(1); this->update_screen(); @@ -120,7 +120,7 @@ void VideoCtrlBase::start_refresh_task() { this->vbl_end_task_id = TimerManager::get_instance()->add_cyclic_timer( refresh_interval, refresh_interval + vbl_duration, - [this]() { + [this](uint64_t, uint64_t) { // deassert VBL interrupt this->vbl_cb(0); } diff --git a/main.cpp b/main.cpp index 37d96d33..b8f29db1 100644 --- a/main.cpp +++ b/main.cpp @@ -387,7 +387,7 @@ void run_machine(std::string machine_str, char* rom_data, EventManager::get_instance()->disable_input_handlers(); // Log the PC and instruction every second to make it easier to validate // that execution is the same every time. - deterministic_timer = TimerManager::get_instance()->add_cyclic_timer(MSECS_TO_NSECS(1000), [] { + deterministic_timer = TimerManager::get_instance()->add_cyclic_timer(MSECS_TO_NSECS(1000), [](uint64_t, uint64_t) { // We may be running after an exceptions or RFI changed the address // translation context. In those cases the PC address cannot be // translated (it would either be stale or invalid). @@ -410,14 +410,16 @@ void run_machine(std::string machine_str, char* rom_data, // set up system wide event polling using // default Macintosh polling rate of 11 ms - uint32_t event_timer = TimerManager::get_instance()->add_cyclic_timer(MSECS_TO_NSECS(11), [] { + uint32_t event_timer = TimerManager::get_instance()->add_cyclic_timer(MSECS_TO_NSECS(11), [](uint64_t, uint64_t) { EventManager::get_instance()->poll_events(); }); #ifdef CPU_PROFILING uint32_t profiling_timer; if (profiling_interval_ms > 0) { - profiling_timer = TimerManager::get_instance()->add_cyclic_timer(MSECS_TO_NSECS(profiling_interval_ms), [] { + profiling_timer = TimerManager::get_instance()->add_cyclic_timer(MSECS_TO_NSECS(profiling_interval_ms), + [](uint64_t, uint64_t) + { gProfilerObj->print_profile("PPC_CPU"); }); }