2020-03-14 13:23:46 +00:00
|
|
|
/*
|
|
|
|
DingusPPC - The Experimental PowerPC Macintosh emulator
|
2022-02-06 14:20:07 +00:00
|
|
|
Copyright (C) 2018-22 divingkatae and maximum
|
2020-03-14 13:23:46 +00:00
|
|
|
(theweirdo) spatium
|
|
|
|
|
|
|
|
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HW_COMPONENT_H
|
|
|
|
#define HW_COMPONENT_H
|
|
|
|
|
2022-01-26 15:45:21 +00:00
|
|
|
#include <cinttypes>
|
2020-03-14 13:23:46 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
/** types of different HW components */
|
2022-01-26 15:45:21 +00:00
|
|
|
enum HWCompType {
|
|
|
|
UNKNOWN = 0ULL, /* unknown component type */
|
|
|
|
MEM_CTRL = 1ULL << 0, /* memory controller */
|
2022-03-28 23:45:00 +00:00
|
|
|
NVRAM = 1ULL << 1, /* non-volatile random access memory */
|
2022-01-26 15:45:21 +00:00
|
|
|
ROM = 1ULL << 2, /* read-only memory */
|
|
|
|
RAM = 1ULL << 3, /* random access memory */
|
|
|
|
MMIO_DEV = 1ULL << 4, /* memory mapped I/O device */
|
|
|
|
PCI_HOST = 1ULL << 5, /* PCI host */
|
|
|
|
PCI_DEV = 1ULL << 6, /* PCI device */
|
|
|
|
I2C_HOST = 1ULL << 8, /* I2C host */
|
|
|
|
I2C_DEV = 1ULL << 9, /* I2C device */
|
|
|
|
ADB_HOST = 1ULL << 12, /* ADB host */
|
|
|
|
ADB_DEV = 1ULL << 13, /* ADB device */
|
|
|
|
INT_CTRL = 1ULL << 16, /* interrupt controller */
|
2022-02-05 17:12:10 +00:00
|
|
|
SCSI_BUS = 1ULL << 20, /* SCSI bus */
|
|
|
|
SCSI_HOST = 1ULL << 21, /* SCSI host adapter */
|
|
|
|
SCSI_DEV = 1ULL << 22, /* SCSI device */
|
2022-10-22 18:41:52 +00:00
|
|
|
IDE_DEV = 1ULL << 25, /* IDE device */
|
2022-01-26 15:45:21 +00:00
|
|
|
SND_SERVER = 1ULL << 31, /* host sound server */
|
2022-02-07 22:04:13 +00:00
|
|
|
FLOPPY_CTRL = 1ULL << 32, /* floppy disk controller */
|
|
|
|
FLOPPY_DRV = 1ULL << 33, /* floppy disk drive */
|
2020-03-14 13:23:46 +00:00
|
|
|
};
|
|
|
|
|
2022-02-06 14:20:07 +00:00
|
|
|
/** Base class for HW components. */
|
2020-03-14 13:23:46 +00:00
|
|
|
class HWComponent {
|
|
|
|
public:
|
2022-01-10 16:40:52 +00:00
|
|
|
HWComponent() = default;
|
2020-03-14 13:23:46 +00:00
|
|
|
virtual ~HWComponent() = default;
|
|
|
|
|
2020-05-12 18:55:45 +00:00
|
|
|
virtual std::string get_name(void) {
|
|
|
|
return this->name;
|
|
|
|
};
|
|
|
|
virtual void set_name(std::string name) {
|
|
|
|
this->name = name;
|
|
|
|
};
|
2020-03-14 13:23:46 +00:00
|
|
|
|
2022-01-26 15:45:21 +00:00
|
|
|
virtual bool supports_type(HWCompType type) {
|
|
|
|
return !!(this->supported_types & type);
|
|
|
|
};
|
|
|
|
|
|
|
|
virtual void supports_types(uint64_t types) {
|
|
|
|
this->supported_types = types;
|
|
|
|
};
|
2020-03-14 13:23:46 +00:00
|
|
|
|
2022-01-21 10:16:34 +00:00
|
|
|
virtual int device_postinit() {
|
|
|
|
return 0;
|
|
|
|
};
|
|
|
|
|
2020-03-14 13:23:46 +00:00
|
|
|
protected:
|
|
|
|
std::string name;
|
2022-01-26 15:45:21 +00:00
|
|
|
uint64_t supported_types = HWCompType::UNKNOWN;
|
2020-03-14 13:23:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* HW_COMPONENT_H */
|