2020-02-28 16:04:28 +00:00
|
|
|
/*
|
|
|
|
DingusPPC - The Experimental PowerPC Macintosh emulator
|
2023-04-16 22:03:36 +00:00
|
|
|
Copyright (C) 2018-23 divingkatae and maximum
|
2020-02-28 16:04:28 +00:00
|
|
|
(theweirdo) spatium
|
|
|
|
|
|
|
|
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-01-05 16:52:46 +00:00
|
|
|
#ifndef NVRAM_H
|
|
|
|
#define NVRAM_H
|
|
|
|
|
2022-03-28 23:45:00 +00:00
|
|
|
#include <devices/common/hwcomponent.h>
|
|
|
|
|
2020-01-05 16:52:46 +00:00
|
|
|
#include <cinttypes>
|
2022-07-17 10:52:12 +00:00
|
|
|
#include <memory>
|
2020-05-12 18:55:45 +00:00
|
|
|
#include <string>
|
2020-01-05 16:52:46 +00:00
|
|
|
|
2020-01-07 10:52:38 +00:00
|
|
|
/** @file Non-volatile RAM emulation.
|
|
|
|
|
|
|
|
It implements a non-volatile random access storage whose content will be
|
|
|
|
automatically saved to and restored from the dedicated file.
|
|
|
|
*/
|
|
|
|
|
2022-03-28 23:45:00 +00:00
|
|
|
class NVram : public HWComponent {
|
2020-01-05 16:52:46 +00:00
|
|
|
public:
|
2020-01-07 10:52:38 +00:00
|
|
|
NVram(std::string file_name = "nvram.bin", uint32_t ram_size = 8192);
|
2020-01-05 16:52:46 +00:00
|
|
|
~NVram();
|
|
|
|
|
2022-07-17 10:52:12 +00:00
|
|
|
static std::unique_ptr<HWComponent> create() {
|
|
|
|
return std::unique_ptr<NVram>(new NVram());
|
|
|
|
}
|
|
|
|
|
2020-01-07 10:52:38 +00:00
|
|
|
uint8_t read_byte(uint32_t offset);
|
2020-05-12 18:55:45 +00:00
|
|
|
void write_byte(uint32_t offset, uint8_t value);
|
2020-01-05 16:52:46 +00:00
|
|
|
|
|
|
|
private:
|
2022-03-28 23:45:00 +00:00
|
|
|
std::string file_name; // file name for the backing file
|
|
|
|
uint16_t ram_size; // NVRAM size
|
2023-04-16 22:03:36 +00:00
|
|
|
std::unique_ptr<uint8_t[]> storage;
|
2020-01-07 10:52:38 +00:00
|
|
|
|
2020-05-12 18:55:45 +00:00
|
|
|
void init();
|
|
|
|
void save();
|
2020-01-05 16:52:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* NVRAM_H */
|