From 7fc28baf96f4d4c54cb81400b87ad15efaa16427 Mon Sep 17 00:00:00 2001 From: Maxim Poliakovski Date: Tue, 12 Jul 2022 01:01:43 +0200 Subject: [PATCH] escc: self-registration with the device registry. --- devices/serial/escc.cpp | 14 ++++++++++++++ devices/serial/escc.h | 7 ++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/devices/serial/escc.cpp b/devices/serial/escc.cpp index 205167c..4bed831 100644 --- a/devices/serial/escc.cpp +++ b/devices/serial/escc.cpp @@ -21,6 +21,7 @@ along with this program. If not, see . /** @file Enhanced Serial Communications Controller (ESCC) emulation. */ +#include #include #include #include @@ -29,6 +30,7 @@ along with this program. If not, see . #include #include #include +#include /** Remap the compatible addressing scheme to MacRISC one. */ const uint8_t compat_to_macrisc[6] = { @@ -306,3 +308,15 @@ uint8_t EsccChannel::receive_byte() this->read_regs[0] &= ~1; return c; } + +static const vector CharIoBackends = {"null", "stdio"}; + +static const PropMap Escc_Properties = { + {"serial_backend", new StrProperty("null", CharIoBackends)}, +}; + +static const DeviceDescription Escc_Descriptor = { + EsccController::create, {}, Escc_Properties +}; + +REGISTER_DEVICE(Escc, Escc_Descriptor); diff --git a/devices/serial/escc.h b/devices/serial/escc.h index 44e4ca9..423f5d2 100644 --- a/devices/serial/escc.h +++ b/devices/serial/escc.h @@ -24,6 +24,7 @@ along with this program. If not, see . #ifndef ESCC_H #define ESCC_H +#include #include #include @@ -116,11 +117,15 @@ private: }; /** ESCC Controller class. */ -class EsccController { +class EsccController : public HWComponent { public: EsccController(); ~EsccController() = default; + static std::unique_ptr create() { + return std::unique_ptr(new EsccController()); + } + // ESCC registers access uint8_t read(uint8_t reg_offset); void write(uint8_t reg_offset, uint8_t value);