mirror of
https://github.com/dingusdev/dingusppc.git
synced 2024-12-24 12:30:05 +00:00
Make NVRAM a full-fledged HW component.
This commit is contained in:
parent
32891867f2
commit
4b2f3cedc7
@ -29,6 +29,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
enum HWCompType {
|
||||
UNKNOWN = 0ULL, /* unknown component type */
|
||||
MEM_CTRL = 1ULL << 0, /* memory controller */
|
||||
NVRAM = 1ULL << 1, /* non-volatile random access memory */
|
||||
ROM = 1ULL << 2, /* read-only memory */
|
||||
RAM = 1ULL << 3, /* random access memory */
|
||||
MMIO_DEV = 1ULL << 4, /* memory mapped I/O device */
|
||||
|
@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <devices/common/hwcomponent.h>
|
||||
#include <devices/common/nvram.h>
|
||||
|
||||
#include <cinttypes>
|
||||
@ -35,7 +36,12 @@ using namespace std;
|
||||
/** the signature for NVRAM backing file identification. */
|
||||
static char NVRAM_FILE_ID[] = "DINGUSPPCNVRAM";
|
||||
|
||||
NVram::NVram(std::string file_name, uint32_t ram_size) {
|
||||
NVram::NVram(std::string file_name, uint32_t ram_size)
|
||||
{
|
||||
this->name = "NVRAM";
|
||||
|
||||
supports_types(HWCompType::NVRAM);
|
||||
|
||||
this->file_name = file_name;
|
||||
this->ram_size = ram_size;
|
||||
|
||||
|
@ -22,6 +22,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#ifndef NVRAM_H
|
||||
#define NVRAM_H
|
||||
|
||||
#include <devices/common/hwcomponent.h>
|
||||
|
||||
#include <cinttypes>
|
||||
#include <string>
|
||||
|
||||
@ -31,7 +33,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
automatically saved to and restored from the dedicated file.
|
||||
*/
|
||||
|
||||
class NVram {
|
||||
class NVram : public HWComponent {
|
||||
public:
|
||||
NVram(std::string file_name = "nvram.bin", uint32_t ram_size = 8192);
|
||||
~NVram();
|
||||
@ -40,9 +42,9 @@ public:
|
||||
void write_byte(uint32_t offset, uint8_t value);
|
||||
|
||||
private:
|
||||
std::string file_name; /* file name for the backing file. */
|
||||
uint16_t ram_size; /* NVRAM size. */
|
||||
uint8_t* storage;
|
||||
std::string file_name; // file name for the backing file
|
||||
uint16_t ram_size; // NVRAM size
|
||||
uint8_t* storage;
|
||||
|
||||
void init();
|
||||
void save();
|
||||
|
@ -49,9 +49,11 @@ GrandCentral::GrandCentral() : PCIDevice("mac-io/grandcentral"), InterruptCtrl()
|
||||
// construct subdevices
|
||||
this->mace = std::unique_ptr<MaceController> (new MaceController(MACE_ID));
|
||||
this->viacuda = std::unique_ptr<ViaCuda> (new ViaCuda());
|
||||
gMachineObj->add_subdevice("ViaCuda", this->viacuda.get());
|
||||
this->nvram = std::unique_ptr<NVram> (new NVram());
|
||||
|
||||
gMachineObj->add_subdevice("ViaCuda", this->viacuda.get());
|
||||
gMachineObj->add_subdevice("NVRAM", this->nvram.get());
|
||||
|
||||
// initialize sound chip and its DMA output channel, then wire them together
|
||||
this->awacs = std::unique_ptr<AwacsScreamer> (new AwacsScreamer());
|
||||
this->snd_out_dma = std::unique_ptr<DMAChannel> (new DMAChannel());
|
||||
|
@ -60,6 +60,7 @@ HeathrowIC::HeathrowIC() : PCIDevice("mac-io/heathrow"), InterruptCtrl()
|
||||
};
|
||||
|
||||
this->nvram = std::unique_ptr<NVram> (new NVram());
|
||||
gMachineObj->add_subdevice("NVRAM", this->nvram.get());
|
||||
|
||||
this->viacuda = std::unique_ptr<ViaCuda> (new ViaCuda());
|
||||
gMachineObj->add_subdevice("ViaCuda", this->viacuda.get());
|
||||
|
Loading…
Reference in New Issue
Block a user