nvram: self-registration with the device registry.

This commit is contained in:
Maxim Poliakovski 2022-07-17 12:52:12 +02:00
parent 5e6f3a51b5
commit 7db0a31cc5
2 changed files with 12 additions and 0 deletions

View File

@ -21,6 +21,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <devices/common/hwcomponent.h>
#include <devices/common/nvram.h>
#include <devices/deviceregistry.h>
#include <cinttypes>
#include <cstring>
@ -93,3 +94,9 @@ void NVram::save() {
f.close();
}
static const DeviceDescription Nvram_Descriptor = {
NVram::create, {}, {}
};
REGISTER_DEVICE(NVRAM, Nvram_Descriptor);

View File

@ -25,6 +25,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <devices/common/hwcomponent.h>
#include <cinttypes>
#include <memory>
#include <string>
/** @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<HWComponent> create() {
return std::unique_ptr<NVram>(new NVram());
}
uint8_t read_byte(uint32_t offset);
void write_byte(uint32_t offset, uint8_t value);