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