mace: self-registration with the device registry.

This commit is contained in:
Maxim Poliakovski 2022-07-17 05:42:42 +02:00
parent 41a314d6d6
commit 1d37982d02
2 changed files with 18 additions and 4 deletions

View File

@ -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 <https://www.gnu.org/licenses/>.
/** @file Media Access Controller for Ethernet (MACE) emulation. */
#include "mace.h"
#include <devices/deviceregistry.h>
#include <devices/ethernet/mace.h>
#include <loguru.hpp>
#include <cinttypes>
@ -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);

View File

@ -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 <https://www.gnu.org/licenses/>.
#ifndef MACE_H
#define MACE_H
#include <devices/common/hwcomponent.h>
#include <cinttypes>
#include <memory>
// 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<HWComponent> create() {
return std::unique_ptr<MaceController>(new MaceController(MACE_ID));
}
// MACE registers access
uint8_t read(uint8_t reg_offset);
void write(uint8_t reg_offset, uint8_t value);