From a1ad0a3e07b1d064d653c1a531d22310c34591ac Mon Sep 17 00:00:00 2001 From: Maxim Poliakovski Date: Sun, 10 Dec 2023 00:00:39 +0100 Subject: [PATCH] machineid: implement BoardRegister class. --- devices/common/hwcomponent.h | 2 ++ devices/common/machineid.h | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/devices/common/hwcomponent.h b/devices/common/hwcomponent.h index 8d064bb..9315ca7 100644 --- a/devices/common/hwcomponent.h +++ b/devices/common/hwcomponent.h @@ -39,6 +39,8 @@ enum HWCompType : uint64_t { I2C_DEV = 1ULL << 9, // I2C device ADB_HOST = 1ULL << 12, // ADB host ADB_DEV = 1ULL << 13, // ADB device + IOBUS_HOST = 1ULL << 14, // IOBus host + IOBUS_DEV = 1ULL << 15, // IOBus device INT_CTRL = 1ULL << 16, // interrupt controller SCSI_BUS = 1ULL << 20, // SCSI bus SCSI_HOST = 1ULL << 21, // SCSI host adapter diff --git a/devices/common/machineid.h b/devices/common/machineid.h index 36df9f4..aedbd19 100644 --- a/devices/common/machineid.h +++ b/devices/common/machineid.h @@ -1,6 +1,6 @@ /* DingusPPC - The Experimental PowerPC Macintosh emulator -Copyright (C) 2018-21 divingkatae and maximum +Copyright (C) 2018-23 divingkatae and maximum (theweirdo) spatium (Contact divingkatae#1017 or powermax#2286 on Discord for more info) @@ -24,8 +24,10 @@ along with this program. If not, see . #include #include +#include #include +#include /** @file Contains definitions for PowerMacintosh machine ID registers. @@ -66,6 +68,36 @@ private: uint8_t id[4]; }; +/** + TNT-style machines and derivatives provide two board registers + telling whether some particular piece of HW is installed or not. + Both board registers are attached to the IOBus of the I/O controller. + See machines/machinetnt.cpp for further details. + **/ +class BoardRegister : public HWComponent, public IobusDevice { +public: + BoardRegister(std::string name, const uint16_t data) { + this->set_name(name); + supports_types(HWCompType::IOBUS_DEV); + this->data = data; + }; + ~BoardRegister() = default; + + uint16_t iodev_read(uint32_t address) { + return (!address) ? this->data : 0xFFFFU; + }; + + // appears read-only to guest + void iodev_write(uint32_t address, uint16_t value) {}; + + void update_bits(const uint16_t val, const uint16_t mask) { + this->data = (this->data & ~mask) | (val & mask); + }; + +private: + uint16_t data; +}; + /** The machine ID for the Gossamer board is accesible at 0xFF000004 (phys). It contains a 16-bit value revealing machine's capabilities like bus speed, @@ -92,4 +124,4 @@ private: uint16_t id; }; -#endif /* MACHINE_ID_H */ +#endif // MACHINE_ID_H