escc: self-registration with the device registry.

This commit is contained in:
Maxim Poliakovski 2022-07-12 01:01:43 +02:00
parent 439029cafe
commit 7fc28baf96
2 changed files with 20 additions and 1 deletions

View File

@ -21,6 +21,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
/** @file Enhanced Serial Communications Controller (ESCC) emulation. */
#include <devices/deviceregistry.h>
#include <devices/serial/chario.h>
#include <devices/serial/escc.h>
#include <loguru.hpp>
@ -29,6 +30,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <cinttypes>
#include <memory>
#include <string>
#include <vector>
/** 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<string> 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);

View File

@ -24,6 +24,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef ESCC_H
#define ESCC_H
#include <devices/common/hwcomponent.h>
#include <devices/serial/chario.h>
#include <cinttypes>
@ -116,11 +117,15 @@ private:
};
/** ESCC Controller class. */
class EsccController {
class EsccController : public HWComponent {
public:
EsccController();
~EsccController() = default;
static std::unique_ptr<HWComponent> create() {
return std::unique_ptr<EsccController>(new EsccController());
}
// ESCC registers access
uint8_t read(uint8_t reg_offset);
void write(uint8_t reg_offset, uint8_t value);