From 1d37982d02d799c07b7ba7d1661cedb8cf7568ba Mon Sep 17 00:00:00 2001 From: Maxim Poliakovski Date: Sun, 17 Jul 2022 05:42:42 +0200 Subject: [PATCH] mace: self-registration with the device registry. --- devices/ethernet/mace.cpp | 11 +++++++++-- devices/ethernet/mace.h | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/devices/ethernet/mace.cpp b/devices/ethernet/mace.cpp index f5c9358..8c67d94 100644 --- a/devices/ethernet/mace.cpp +++ b/devices/ethernet/mace.cpp @@ -1,6 +1,6 @@ /* DingusPPC - The Experimental PowerPC Macintosh emulator -Copyright (C) 2018-21 divingkatae and maximum +Copyright (C) 2018-22 divingkatae and maximum (theweirdo) spatium (Contact divingkatae#1017 or powermax#2286 on Discord for more info) @@ -21,7 +21,8 @@ along with this program. If not, see . /** @file Media Access Controller for Ethernet (MACE) emulation. */ -#include "mace.h" +#include +#include #include #include @@ -55,3 +56,9 @@ void MaceController::write(uint8_t reg_offset, uint8_t value) LOG_F(INFO, "Writing 0x%X to MACE register %d", value, reg_offset); } } + +static const DeviceDescription Mace_Descriptor = { + MaceController::create, {}, {} +}; + +REGISTER_DEVICE(Mace, Mace_Descriptor); diff --git a/devices/ethernet/mace.h b/devices/ethernet/mace.h index d722453..a7c505e 100644 --- a/devices/ethernet/mace.h +++ b/devices/ethernet/mace.h @@ -1,6 +1,6 @@ /* DingusPPC - The Experimental PowerPC Macintosh emulator -Copyright (C) 2018-21 divingkatae and maximum +Copyright (C) 2018-22 divingkatae and maximum (theweirdo) spatium (Contact divingkatae#1017 or powermax#2286 on Discord for more info) @@ -24,7 +24,10 @@ along with this program. If not, see . #ifndef MACE_H #define MACE_H +#include + #include +#include // MACE Chip ID from AMD datasheet // TODO: compare with real HW @@ -66,11 +69,15 @@ enum MaceReg : uint8_t { }; // namespace MaceEnet -class MaceController { +class MaceController : public HWComponent { public: MaceController(uint16_t id) { this->chip_id = id; }; ~MaceController() = default; + static std::unique_ptr create() { + return std::unique_ptr(new MaceController(MACE_ID)); + } + // MACE registers access uint8_t read(uint8_t reg_offset); void write(uint8_t reg_offset, uint8_t value);