From d0a5a1e7be1e5ff8f5ea9313952bf0e4d83dcb7e Mon Sep 17 00:00:00 2001 From: joevt Date: Sat, 25 Nov 2023 04:04:25 -0800 Subject: [PATCH] Add ability to override built-in GPU. --- devices/memctrl/mpc106.cpp | 4 +++- machines/machinegossamer.cpp | 10 ++++++---- machines/machineproperties.h | 3 +++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/devices/memctrl/mpc106.cpp b/devices/memctrl/mpc106.cpp index e5b6d62..bda6c9e 100644 --- a/devices/memctrl/mpc106.cpp +++ b/devices/memctrl/mpc106.cpp @@ -60,7 +60,7 @@ int MPC106::device_postinit() std::string pci_dev_name; static const std::map pci_slots = { - {"pci_PERCH", DEV_FUN(0xC,0)}, {"pci_A1", DEV_FUN(0xD,0)}, {"pci_B1", DEV_FUN(0xE,0)}, {"pci_C1", DEV_FUN(0xF,0)} + {"pci_PERCH", DEV_FUN(0xC,0)}, {"pci_A1", DEV_FUN(0xD,0)}, {"pci_B1", DEV_FUN(0xE,0)}, {"pci_C1", DEV_FUN(0xF,0)}, {"pci_GPU", DEV_FUN(0x12,0)} }; for (auto& slot : pci_slots) { @@ -351,6 +351,8 @@ static const PropMap Grackle_Properties = { new StrProperty("")}, {"pci_C1", new StrProperty("")}, + {"pci_GPU", + new StrProperty("")}, }; static const DeviceDescription Grackle_Descriptor = { diff --git a/machines/machinegossamer.cpp b/machines/machinegossamer.cpp index b9df3b4..e47529c 100644 --- a/machines/machinegossamer.cpp +++ b/machines/machinegossamer.cpp @@ -123,8 +123,10 @@ int initialize_gossamer(std::string& id) // add pci devices grackle_obj->pci_register_device( DEV_FUN(0x10,0), dynamic_cast(gMachineObj->get_comp_by_name("Heathrow"))); - grackle_obj->pci_register_device( - DEV_FUN(0x12,0), dynamic_cast(gMachineObj->get_comp_by_name(id == "pmg3twr" ? "AtiRagePro" : "AtiRageGT"))); + + std::string gpu = GET_STR_PROP("pci_GPU"); + if (gpu.empty()) + SET_STR_PROP("pci_GPU", id == "pmg3twr" ? "AtiRagePro" : "AtiRageGT"); // add Athens clock generator device and register it with the I2C host gMachineObj->add_device("Athens", std::unique_ptr(new AthensClocks(0x28))); @@ -168,11 +170,11 @@ static const PropMap gossamer_settings = { }; static vector pmg3_devices = { - "Grackle", "ScreamerSnd", "Heathrow", "AtiRageGT", "AtaHardDisk", "AtapiCdrom" + "Grackle", "ScreamerSnd", "Heathrow", "AtaHardDisk", "AtapiCdrom" }; static vector pmg3twr_devices = { - "Grackle", "ScreamerSnd", "Heathrow", "AtiRagePro", "AtaHardDisk", "AtapiCdrom" + "Grackle", "ScreamerSnd", "Heathrow", "AtaHardDisk", "AtapiCdrom" }; static const MachineDescription pmg3dt_descriptor = { diff --git a/machines/machineproperties.h b/machines/machineproperties.h index 52f20b1..ba077b4 100644 --- a/machines/machineproperties.h +++ b/machines/machineproperties.h @@ -196,6 +196,9 @@ typedef map PropMap; extern map> gMachineSettings; /** Conveniency macros to hide complex casts. */ +#define SET_STR_PROP(name, value) \ + dynamic_cast(gMachineSettings.at(name).get())->set_string(value) + #define GET_STR_PROP(name) \ dynamic_cast(gMachineSettings.at(name).get())->get_string()