From e33b141b7e35c292d4150b70b8f305366844f2b0 Mon Sep 17 00:00:00 2001 From: Maxim Poliakovski Date: Mon, 29 Aug 2022 11:18:53 +0200 Subject: [PATCH] machinepdm: support for pluggable PDS devices. --- machines/machinefactory.cpp | 1 + machines/machinepdm.cpp | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/machines/machinefactory.cpp b/machines/machinefactory.cpp index ac2553b..09b4d1d 100644 --- a/machines/machinefactory.cpp +++ b/machines/machinefactory.cpp @@ -84,6 +84,7 @@ static const map PropHelp = { {"pci_C1", "insert a PCI device into C1 slot"}, {"serial_backend", "specifies the backend for the serial port"}, {"emmo", "enables/disables factory HW tests during startup"}, + {"pds", "specify device for the processsor direct slot"}, }; bool MachineFactory::add(const string& machine_id, MachineDescription desc) diff --git a/machines/machinepdm.cpp b/machines/machinepdm.cpp index 3681e57..bd38b18 100644 --- a/machines/machinepdm.cpp +++ b/machines/machinepdm.cpp @@ -36,6 +36,35 @@ along with this program. If not, see . #include #include +void setup_pds() +{ + std::string dev_name = GET_STR_PROP("pds"); + if (!dev_name.empty()) { + if (!DeviceRegistry::device_registered(dev_name)) { + LOG_F(WARNING, "specified PDS device %s doesn't exist", dev_name.c_str()); + goto empty_slot; + } + + // attempt to create device object + auto dev_obj = DeviceRegistry::get_descriptor(dev_name).m_create_func(); + + // safety check + if (!dev_obj->supports_type(HWCompType::PDS_DEV)) { + LOG_F(WARNING, "Cannot use device %s with the PDS", dev_name.c_str()); + goto empty_slot; + } + + // add device to the machine object + gMachineObj->add_device(dev_name, std::move(dev_obj)); + + LOG_F(INFO, "PDS slot: %s", dev_name.c_str()); + return; + } + +empty_slot: + LOG_F(INFO, "PDS slot: empty"); +} + int initialize_pdm(std::string& id) { uint16_t machine_id; @@ -81,6 +110,9 @@ int initialize_pdm(std::string& id) // add internal SCSI bus gMachineObj->add_device("SCSI0", std::unique_ptr(new ScsiBus())); + // set up the processor direct slot + setup_pds(); + // Init virtual CPU and request MPC601 ppc_cpu_init(hmc_obj, PPC_VER::MPC601, 7812500ULL); @@ -102,6 +134,8 @@ static const PropMap pm6100_settings = { new IntProperty(0, vector({0, 8, 16, 32, 64, 128}))}, {"mon_id", new StrProperty("HiRes12-14in", PDMBuiltinMonitorIDs)}, + {"pds", + new StrProperty("")}, {"emmo", new BinProperty(0)}, };