2020-03-13 21:49:58 +00:00
|
|
|
/*
|
|
|
|
DingusPPC - The Experimental PowerPC Macintosh emulator
|
2023-06-04 09:00:29 +00:00
|
|
|
Copyright (C) 2018-23 divingkatae and maximum
|
2020-03-13 21:49:58 +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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @file Factory for creating different machines.
|
|
|
|
|
|
|
|
Author: Max Poliakovski
|
|
|
|
*/
|
|
|
|
|
2023-11-03 07:21:33 +00:00
|
|
|
#include <devices/common/hwcomponent.h>
|
2022-07-18 09:48:23 +00:00
|
|
|
#include <devices/deviceregistry.h>
|
2021-10-23 18:17:47 +00:00
|
|
|
#include <devices/memctrl/memctrlbase.h>
|
2022-07-18 09:48:23 +00:00
|
|
|
#include <devices/sound/soundserver.h>
|
2021-10-23 18:17:47 +00:00
|
|
|
#include <loguru.hpp>
|
2022-07-18 09:48:23 +00:00
|
|
|
#include <machines/machinebase.h>
|
2021-10-23 18:17:47 +00:00
|
|
|
#include <machines/machinefactory.h>
|
|
|
|
#include <machines/machineproperties.h>
|
|
|
|
#include <memaccess.h>
|
|
|
|
|
2020-03-13 21:49:58 +00:00
|
|
|
#include <cinttypes>
|
|
|
|
#include <cstring>
|
|
|
|
#include <fstream>
|
2023-11-03 07:21:33 +00:00
|
|
|
#include <tuple>
|
2020-05-12 18:55:45 +00:00
|
|
|
#include <iostream>
|
2020-10-14 03:20:44 +00:00
|
|
|
#include <iomanip>
|
2020-05-12 18:55:45 +00:00
|
|
|
#include <map>
|
2020-12-19 08:53:17 +00:00
|
|
|
#include <string>
|
2020-10-09 13:58:47 +00:00
|
|
|
#include <vector>
|
2020-03-13 21:49:58 +00:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2020-10-06 09:01:13 +00:00
|
|
|
map<string, unique_ptr<BasicProperty>> gMachineSettings;
|
|
|
|
|
2020-03-13 21:49:58 +00:00
|
|
|
/**
|
2020-09-20 21:25:29 +00:00
|
|
|
Power Macintosh ROM identification map.
|
2020-03-13 21:49:58 +00:00
|
|
|
|
2020-09-20 21:25:29 +00:00
|
|
|
Maps Bootstrap string located at offset 0x30D064 (PCI Macs)
|
|
|
|
or 0x30C064 (Nubus Macs) to machine name and description.
|
2020-03-13 21:49:58 +00:00
|
|
|
*/
|
2020-09-20 21:25:29 +00:00
|
|
|
static const map<uint32_t, std::tuple<string, const char*>> rom_identity = {
|
|
|
|
{0x416C6368, {"pm6400", "Performa 6400"}}, // Alchemy
|
|
|
|
//{"Come", "PowerBook 2400"}, // Comet
|
|
|
|
{0x436F7264, {"pm5200", "Power Mac 5200/6200 series"}}, // Cordyceps
|
|
|
|
{0x47617A65, {"pm6500", "Power Mac 6500"}}, // Gazelle
|
2022-07-18 09:48:23 +00:00
|
|
|
{0x476F7373, {"pmg3dt", "Power Mac G3 Beige"}}, // Gossamer
|
2020-09-20 21:25:29 +00:00
|
|
|
{0x47525820, {"pbg3", "PowerBook G3 Wallstreet"}},
|
|
|
|
//{"Hoop", "PowerBook 3400"}, // Hooper
|
|
|
|
{0x50425820, {"pb-preg3", "PowerBook Pre-G3"}},
|
|
|
|
{0x50444D20, {"pm6100", "Nubus Power Mac"}}, // Piltdown Man (6100/7100/8100)
|
|
|
|
{0x50697020, {"pippin", "Bandai Pippin"}}, // Pippin
|
2023-12-03 09:12:37 +00:00
|
|
|
//{"Powe", "Generic Power Mac"}, // Power Mac?
|
2020-09-20 21:25:29 +00:00
|
|
|
{0x544E5420, {"pm7200", "Power Mac 7xxxx/8xxx series"}}, // Trinitrotoluene :-)
|
|
|
|
{0x5A616E7A, {"pm4400", "Power Mac 4400/7220"}}, // Zanzibar
|
2020-03-13 21:49:58 +00:00
|
|
|
};
|
|
|
|
|
2020-10-13 02:24:54 +00:00
|
|
|
static const map<string, string> PropHelp = {
|
|
|
|
{"rambank1_size", "specifies RAM bank 1 size in MB"},
|
|
|
|
{"rambank2_size", "specifies RAM bank 2 size in MB"},
|
|
|
|
{"rambank3_size", "specifies RAM bank 3 size in MB"},
|
2022-01-17 12:58:51 +00:00
|
|
|
{"rambank4_size", "specifies RAM bank 4 size in MB"},
|
2020-10-13 02:24:54 +00:00
|
|
|
{"gfxmem_size", "specifies video memory size in MB"},
|
2021-12-04 13:22:02 +00:00
|
|
|
{"fdd_img", "specifies path to floppy disk image"},
|
2022-09-03 22:20:29 +00:00
|
|
|
{"fdd_fmt", "specifies floppy disk format"},
|
2022-07-18 09:48:23 +00:00
|
|
|
{"fdd_wr_prot", "toggles floppy disk's write protection"},
|
2022-10-08 23:51:54 +00:00
|
|
|
{"hdd_img", "specifies path to hard disk image"},
|
|
|
|
{"hdd_wr_prot", "toggles hard disk's write protection"},
|
2023-06-18 21:15:08 +00:00
|
|
|
{"cdr_config", "CD-ROM device path in [bus]:[device#] format"},
|
2022-11-13 23:52:53 +00:00
|
|
|
{"cdr_img", "specifies path to CD-ROM image"},
|
2021-12-05 19:07:22 +00:00
|
|
|
{"mon_id", "specifies which monitor to emulate"},
|
2023-09-18 23:26:27 +00:00
|
|
|
{"pci_PERCH", "insert a PCI device into PERCH slot"},
|
2022-08-19 17:44:10 +00:00
|
|
|
{"pci_A1", "insert a PCI device into A1 slot"},
|
|
|
|
{"pci_B1", "insert a PCI device into B1 slot"},
|
|
|
|
{"pci_C1", "insert a PCI device into C1 slot"},
|
2022-05-07 19:38:27 +00:00
|
|
|
{"serial_backend", "specifies the backend for the serial port"},
|
2022-07-19 23:36:05 +00:00
|
|
|
{"emmo", "enables/disables factory HW tests during startup"},
|
2020-10-13 02:24:54 +00:00
|
|
|
};
|
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
bool MachineFactory::add(const string& machine_id, MachineDescription desc)
|
|
|
|
{
|
|
|
|
if (get_registry().find(machine_id) != get_registry().end()) {
|
|
|
|
return false;
|
|
|
|
}
|
2020-09-20 21:25:29 +00:00
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
get_registry()[machine_id] = desc;
|
|
|
|
return true;
|
|
|
|
}
|
2020-09-20 21:25:29 +00:00
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
void MachineFactory::list_machines()
|
|
|
|
{
|
|
|
|
cout << endl << "Supported machines:" << endl << endl;
|
2020-09-20 21:25:29 +00:00
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
for (auto& m : get_registry()) {
|
|
|
|
cout << setw(13) << m.first << "\t\t" << m.second.description << endl;
|
2020-09-20 21:25:29 +00:00
|
|
|
}
|
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
cout << endl;
|
|
|
|
}
|
2020-09-20 21:25:29 +00:00
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
void MachineFactory::create_device(string& dev_name, DeviceDescription& dev)
|
|
|
|
{
|
|
|
|
for (auto& subdev_name : dev.subdev_list) {
|
|
|
|
create_device(subdev_name, DeviceRegistry::get_descriptor(subdev_name));
|
2020-09-20 21:25:29 +00:00
|
|
|
}
|
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
gMachineObj->add_device(dev_name, dev.m_create_func());
|
|
|
|
}
|
2020-09-20 21:25:29 +00:00
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
int MachineFactory::create(string& mach_id)
|
|
|
|
{
|
|
|
|
auto it = get_registry().find(mach_id);
|
|
|
|
if (it == get_registry().end()) {
|
|
|
|
LOG_F(ERROR, "Unknown machine id %s", mach_id.c_str());
|
|
|
|
return -1;
|
|
|
|
}
|
2020-09-20 21:25:29 +00:00
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
LOG_F(INFO, "Initializing %s hardware...", it->second.description.c_str());
|
2020-09-20 21:25:29 +00:00
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
// initialize global machine object
|
|
|
|
gMachineObj.reset(new MachineBase(it->second.name));
|
|
|
|
|
|
|
|
// create and register sound server
|
|
|
|
gMachineObj->add_device("SoundServer", std::unique_ptr<SoundServer>(new SoundServer()));
|
|
|
|
|
|
|
|
// recursively create device objects
|
|
|
|
for (auto& dev_name : it->second.devices) {
|
|
|
|
create_device(dev_name, DeviceRegistry::get_descriptor(dev_name));
|
2020-09-20 21:25:29 +00:00
|
|
|
}
|
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
if (it->second.init_func(mach_id)) {
|
|
|
|
LOG_F(ERROR, "Machine initialization function failed!");
|
|
|
|
return -1;
|
|
|
|
}
|
2020-09-20 21:25:29 +00:00
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
// post-initialize all devices
|
|
|
|
if (gMachineObj->postinit_devices()) {
|
2022-08-14 12:26:56 +00:00
|
|
|
LOG_F(ERROR, "Could not post-initialize devices!");
|
2022-07-18 09:48:23 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2020-09-20 21:25:29 +00:00
|
|
|
|
2022-08-14 12:26:56 +00:00
|
|
|
LOG_F(INFO, "Initialization completed.");
|
2020-09-20 21:25:29 +00:00
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2020-09-20 21:25:29 +00:00
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
void MachineFactory::list_properties()
|
|
|
|
{
|
|
|
|
cout << endl;
|
|
|
|
|
|
|
|
for (auto& mach : get_registry()) {
|
|
|
|
cout << mach.second.description << " supported properties:" << endl << endl;
|
|
|
|
|
|
|
|
print_settings(mach.second.settings);
|
|
|
|
|
|
|
|
for (auto& d : mach.second.devices) {
|
|
|
|
list_device_settings(DeviceRegistry::get_descriptor(d));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cout << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MachineFactory::list_device_settings(DeviceDescription& dev)
|
|
|
|
{
|
|
|
|
for (auto& d : dev.subdev_list) {
|
|
|
|
list_device_settings(DeviceRegistry::get_descriptor(d));
|
|
|
|
}
|
|
|
|
|
|
|
|
print_settings(dev.properties);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MachineFactory::print_settings(PropMap& prop_map)
|
|
|
|
{
|
2022-08-19 17:44:10 +00:00
|
|
|
string help;
|
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
for (auto& p : prop_map) {
|
2022-08-19 17:44:10 +00:00
|
|
|
if (PropHelp.find(p.first) != PropHelp.end())
|
|
|
|
help = PropHelp.at(p.first);
|
|
|
|
else
|
|
|
|
help = "";
|
|
|
|
|
|
|
|
cout << setw(13) << p.first << "\t\t" << help << endl;
|
2022-07-18 09:48:23 +00:00
|
|
|
|
|
|
|
cout << setw(13) << "\t\t\t" "Valid values: ";
|
|
|
|
|
|
|
|
switch(p.second->get_type()) {
|
|
|
|
case PROP_TYPE_INTEGER:
|
|
|
|
cout << dynamic_cast<IntProperty*>(p.second)->get_valid_values_as_str()
|
|
|
|
<< endl;
|
|
|
|
break;
|
|
|
|
case PROP_TYPE_STRING:
|
|
|
|
cout << dynamic_cast<StrProperty*>(p.second)->get_valid_values_as_str()
|
|
|
|
<< endl;
|
|
|
|
break;
|
2022-07-19 21:48:17 +00:00
|
|
|
case PROP_TYPE_BINARY:
|
|
|
|
cout << dynamic_cast<BinProperty*>(p.second)->get_valid_values_as_str()
|
|
|
|
<< endl;
|
|
|
|
break;
|
2022-07-18 09:48:23 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
cout << endl;
|
|
|
|
}
|
2020-09-20 21:25:29 +00:00
|
|
|
}
|
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
void MachineFactory::get_device_settings(DeviceDescription& dev, map<string, string> &settings)
|
|
|
|
{
|
|
|
|
for (auto& d : dev.subdev_list) {
|
|
|
|
get_device_settings(DeviceRegistry::get_descriptor(d), settings);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto& p : dev.properties) {
|
|
|
|
settings[p.first] = p.second->get_string();
|
|
|
|
|
|
|
|
// populate dynamic machine settings from presets
|
|
|
|
gMachineSettings[p.first] = unique_ptr<BasicProperty>(p.second->clone());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int MachineFactory::get_machine_settings(const string& id, map<string, string> &settings)
|
|
|
|
{
|
|
|
|
auto it = get_registry().find(id);
|
|
|
|
if (it != get_registry().end()) {
|
|
|
|
auto props = it->second.settings;
|
2020-10-06 09:01:13 +00:00
|
|
|
|
|
|
|
gMachineSettings.clear();
|
2020-09-20 21:25:29 +00:00
|
|
|
|
|
|
|
for (auto& p : props) {
|
2020-10-06 09:01:13 +00:00
|
|
|
settings[p.first] = p.second->get_string();
|
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
// populate dynamic machine settings from presets
|
2020-10-06 09:01:13 +00:00
|
|
|
gMachineSettings[p.first] = unique_ptr<BasicProperty>(p.second->clone());
|
2020-09-20 21:25:29 +00:00
|
|
|
}
|
2022-07-18 09:48:23 +00:00
|
|
|
|
|
|
|
for (auto& dev : it->second.devices) {
|
|
|
|
get_device_settings(DeviceRegistry::get_descriptor(dev), settings);
|
|
|
|
}
|
|
|
|
} else {
|
2020-09-20 21:25:29 +00:00
|
|
|
LOG_F(ERROR, "Unknown machine id %s", id.c_str());
|
|
|
|
return -1;
|
|
|
|
}
|
2022-07-18 09:48:23 +00:00
|
|
|
|
2020-09-20 21:25:29 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
void MachineFactory::set_machine_settings(map<string, string> &settings) {
|
2020-09-20 21:25:29 +00:00
|
|
|
for (auto& s : settings) {
|
2020-10-06 09:01:13 +00:00
|
|
|
gMachineSettings.at(s.first)->set_string(s.second);
|
|
|
|
}
|
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
// print machine settings summary
|
2020-10-06 09:01:13 +00:00
|
|
|
cout << endl << "Machine settings summary: " << endl;
|
|
|
|
|
|
|
|
for (auto& p : gMachineSettings) {
|
|
|
|
cout << p.first << " : " << p.second->get_string() << endl;
|
2020-09-20 21:25:29 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-13 21:49:58 +00:00
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
string MachineFactory::machine_name_from_rom(string& rom_filepath) {
|
|
|
|
ifstream rom_file;
|
2022-12-21 11:20:39 +00:00
|
|
|
size_t file_size;
|
|
|
|
uint32_t config_info_offset, rom_id;
|
2022-07-18 09:48:23 +00:00
|
|
|
char rom_id_str[17];
|
2020-10-13 02:24:54 +00:00
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
string machine_name = "";
|
|
|
|
|
|
|
|
rom_file.open(rom_filepath, ios::in | ios::binary);
|
|
|
|
if (rom_file.fail()) {
|
2023-06-04 09:00:29 +00:00
|
|
|
LOG_F(ERROR, "Could not open the specified ROM file.");
|
2022-07-18 09:48:23 +00:00
|
|
|
goto bail_out;
|
2020-10-13 02:24:54 +00:00
|
|
|
}
|
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
rom_file.seekg(0, rom_file.end);
|
|
|
|
file_size = rom_file.tellg();
|
|
|
|
rom_file.seekg(0, rom_file.beg);
|
2020-10-13 02:24:54 +00:00
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
if (file_size != 0x400000UL) {
|
|
|
|
LOG_F(ERROR, "Unxpected ROM File size. Expected size is 4 megabytes.");
|
|
|
|
goto bail_out;
|
|
|
|
}
|
2020-10-13 02:24:54 +00:00
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
/* read config info offset from file */
|
|
|
|
config_info_offset = 0;
|
|
|
|
rom_file.seekg(0x300080, ios::beg);
|
|
|
|
rom_file.read((char*)&config_info_offset, 4);
|
|
|
|
config_info_offset = READ_DWORD_BE_A(&config_info_offset);
|
2020-10-13 02:24:54 +00:00
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
/* rewind to ConfigInfo.BootstrapVersion field */
|
|
|
|
rom_file.seekg(0x300064 + config_info_offset, ios::beg);
|
2021-12-05 19:07:22 +00:00
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
/* read BootstrapVersion as C string */
|
|
|
|
rom_file.read(rom_id_str, 16);
|
|
|
|
rom_id_str[16] = 0;
|
|
|
|
LOG_F(INFO, "ROM BootstrapVersion: %s", rom_id_str);
|
|
|
|
|
|
|
|
if (strncmp(rom_id_str, "Boot", 4) != 0) {
|
|
|
|
LOG_F(ERROR, "Invalid BootstrapVersion string.");
|
|
|
|
goto bail_out;
|
2020-10-13 02:24:54 +00:00
|
|
|
}
|
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
/* convert BootstrapVersion string to ROM ID */
|
|
|
|
rom_id = (rom_id_str[5] << 24) | (rom_id_str[6] << 16) |
|
|
|
|
(rom_id_str[7] << 8) | rom_id_str[8];
|
2020-10-13 02:24:54 +00:00
|
|
|
|
2022-08-14 12:26:56 +00:00
|
|
|
LOG_F(INFO, "The machine is identified as... %s",
|
2022-07-18 09:48:23 +00:00
|
|
|
std::get<1>(rom_identity.at(rom_id)));
|
2020-03-13 21:49:58 +00:00
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
machine_name = std::get<0>(rom_identity.at(rom_id));
|
2020-03-13 21:49:58 +00:00
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
bail_out:
|
|
|
|
rom_file.close();
|
2020-03-13 21:49:58 +00:00
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
return machine_name;
|
2020-03-13 21:49:58 +00:00
|
|
|
}
|
|
|
|
|
2020-10-06 09:01:13 +00:00
|
|
|
/* Read ROM file content and transfer it to the dedicated ROM region */
|
2022-07-18 09:48:23 +00:00
|
|
|
int MachineFactory::load_boot_rom(string& rom_filepath) {
|
2020-10-06 09:01:13 +00:00
|
|
|
ifstream rom_file;
|
|
|
|
size_t file_size;
|
2023-02-02 21:47:52 +00:00
|
|
|
int result = 0;
|
|
|
|
uint32_t rom_load_addr;
|
2021-10-06 20:46:39 +00:00
|
|
|
AddressMapEntry *rom_reg;
|
2020-10-06 09:01:13 +00:00
|
|
|
|
|
|
|
rom_file.open(rom_filepath, ios::in | ios::binary);
|
|
|
|
if (rom_file.fail()) {
|
2023-06-04 09:00:29 +00:00
|
|
|
LOG_F(ERROR, "Could not open the specified ROM file.");
|
2020-10-06 09:01:13 +00:00
|
|
|
rom_file.close();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
rom_file.seekg(0, rom_file.end);
|
|
|
|
file_size = rom_file.tellg();
|
|
|
|
rom_file.seekg(0, rom_file.beg);
|
|
|
|
|
2023-02-02 21:47:52 +00:00
|
|
|
if (file_size == 0x400000UL) { // Old World ROMs
|
|
|
|
rom_load_addr = 0xFFC00000UL;
|
|
|
|
} else if (file_size == 0x100000UL) { // New World ROMs
|
|
|
|
rom_load_addr = 0xFFF00000UL;
|
2020-10-06 09:01:13 +00:00
|
|
|
} else {
|
2023-02-02 21:47:52 +00:00
|
|
|
LOG_F(ERROR, "Unxpected ROM File size: %zu bytes.", file_size);
|
|
|
|
result = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!result) {
|
2020-10-06 09:01:13 +00:00
|
|
|
unsigned char* sysrom_mem = new unsigned char[file_size];
|
|
|
|
|
|
|
|
rom_file.seekg(0, ios::beg);
|
|
|
|
rom_file.read((char*)sysrom_mem, file_size);
|
|
|
|
|
|
|
|
MemCtrlBase* mem_ctrl = dynamic_cast<MemCtrlBase*>(
|
|
|
|
gMachineObj->get_comp_by_type(HWCompType::MEM_CTRL));
|
|
|
|
|
2021-10-06 20:46:39 +00:00
|
|
|
if ((rom_reg = mem_ctrl->find_rom_region())) {
|
2023-02-02 21:47:52 +00:00
|
|
|
mem_ctrl->set_data(rom_load_addr, sysrom_mem, (uint32_t)file_size);
|
2021-10-06 20:46:39 +00:00
|
|
|
} else {
|
2023-02-02 21:47:52 +00:00
|
|
|
LOG_F(ERROR, "Could not locate physical ROM region!");
|
|
|
|
result = -1;
|
2021-10-06 20:46:39 +00:00
|
|
|
}
|
|
|
|
|
2020-10-06 09:01:13 +00:00
|
|
|
delete[] sysrom_mem;
|
|
|
|
}
|
|
|
|
|
|
|
|
rom_file.close();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
int MachineFactory::create_machine_for_id(string& id, string& rom_filepath) {
|
|
|
|
if (MachineFactory::create(id) < 0 || load_boot_rom(rom_filepath) < 0) {
|
2020-10-06 09:01:13 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|