From 7db0a31cc5ba22a86f26bd9108d7120ff33f0043 Mon Sep 17 00:00:00 2001 From: Maxim Poliakovski Date: Sun, 17 Jul 2022 12:52:12 +0200 Subject: [PATCH] nvram: self-registration with the device registry. --- devices/common/nvram.cpp | 7 +++++++ devices/common/nvram.h | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/devices/common/nvram.cpp b/devices/common/nvram.cpp index 751e733..648adbb 100644 --- a/devices/common/nvram.cpp +++ b/devices/common/nvram.cpp @@ -21,6 +21,7 @@ along with this program. If not, see . #include #include +#include #include #include @@ -93,3 +94,9 @@ void NVram::save() { f.close(); } + +static const DeviceDescription Nvram_Descriptor = { + NVram::create, {}, {} +}; + +REGISTER_DEVICE(NVRAM, Nvram_Descriptor); diff --git a/devices/common/nvram.h b/devices/common/nvram.h index 8f9f60f..d3e19bd 100644 --- a/devices/common/nvram.h +++ b/devices/common/nvram.h @@ -25,6 +25,7 @@ along with this program. If not, see . #include #include +#include #include /** @file Non-volatile RAM emulation. @@ -38,6 +39,10 @@ public: NVram(std::string file_name = "nvram.bin", uint32_t ram_size = 8192); ~NVram(); + static std::unique_ptr create() { + return std::unique_ptr(new NVram()); + } + uint8_t read_byte(uint32_t offset); void write_byte(uint32_t offset, uint8_t value);