From 0899186ffc096b5467b10e793c041c059535623e Mon Sep 17 00:00:00 2001 From: Maxim Poliakovski Date: Fri, 21 Jan 2022 12:37:47 +0100 Subject: [PATCH] ViaCuda: implement post-initialization. --- devices/common/viacuda.cpp | 19 +++++++++---------- devices/common/viacuda.h | 3 +++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/devices/common/viacuda.cpp b/devices/common/viacuda.cpp index 09e05fc..1228bb6 100644 --- a/devices/common/viacuda.cpp +++ b/devices/common/viacuda.cpp @@ -78,6 +78,15 @@ ViaCuda::ViaCuda() { this->int_ctrl = nullptr; } +int ViaCuda::device_postinit() +{ + this->int_ctrl = dynamic_cast( + gMachineObj->get_comp_by_type(HWCompType::INT_CTRL)); + this->irq_id = this->int_ctrl->register_dev_int(IntSrc::VIA_CUDA); + + return 0; +} + void ViaCuda::cuda_init() { this->old_tip = 0; this->old_byteack = 0; @@ -189,17 +198,7 @@ void ViaCuda::print_enabled_ints() { } } -void ViaCuda::init_ints() { - // lazy interrupt wiring - if (this->int_ctrl == nullptr) { - this->int_ctrl = dynamic_cast( - gMachineObj->get_comp_by_type(HWCompType::INT_CTRL)); - this->irq_id = this->int_ctrl->register_dev_int(IntSrc::VIA_CUDA); - } -} - inline void ViaCuda::update_irq() { - init_ints(); uint8_t new_irq = !!(this->_via_ifr & this->_via_ier & 0x7F); this->_via_ifr = (this->_via_ifr & 0x7F) | (new_irq << 7); if (new_irq != this->irq) { diff --git a/devices/common/viacuda.h b/devices/common/viacuda.h index 31951e4..8877ab9 100644 --- a/devices/common/viacuda.h +++ b/devices/common/viacuda.h @@ -154,10 +154,13 @@ public: ViaCuda(); ~ViaCuda() = default; + // HWComponent methods bool supports_type(HWCompType type) { return (type == HWCompType::ADB_HOST || type == HWCompType::I2C_HOST); }; + int device_postinit(); + uint8_t read(int reg); void write(int reg, uint8_t value);