machineid: implement BoardRegister class.

This commit is contained in:
Maxim Poliakovski 2023-12-10 00:00:39 +01:00
parent 858f699750
commit a1ad0a3e07
2 changed files with 36 additions and 2 deletions

View File

@ -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

View File

@ -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 <https://www.gnu.org/licenses/>.
#include <devices/common/hwcomponent.h>
#include <devices/common/mmiodevice.h>
#include <devices/ioctrl/macio.h>
#include <cinttypes>
#include <string>
/**
@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