2020-12-19 08:53:17 +00:00
|
|
|
/*
|
|
|
|
DingusPPC - The Experimental PowerPC Macintosh emulator
|
2022-07-18 09:48:23 +00:00
|
|
|
Copyright (C) 2018-22 divingkatae and maximum
|
2020-12-19 08:53:17 +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 Construct a PDM-style PowerMacintosh machine.
|
|
|
|
|
|
|
|
Author: Max Poliakovski
|
|
|
|
*/
|
|
|
|
|
2021-10-23 18:17:47 +00:00
|
|
|
#include <cpu/ppc/ppcemu.h>
|
|
|
|
#include <devices/common/machineid.h>
|
2022-02-05 17:15:46 +00:00
|
|
|
#include <devices/common/scsi/scsi.h>
|
2022-11-13 23:52:53 +00:00
|
|
|
#include <devices/common/scsi/scsicdrom.h>
|
2022-12-14 15:14:37 +00:00
|
|
|
#include <devices/common/scsi/scsihd.h>
|
2021-10-23 18:17:47 +00:00
|
|
|
#include <devices/memctrl/hmc.h>
|
2021-09-25 21:16:38 +00:00
|
|
|
#include <loguru.hpp>
|
2021-10-23 18:17:47 +00:00
|
|
|
#include <machines/machinebase.h>
|
2022-07-18 09:48:23 +00:00
|
|
|
#include <machines/machinefactory.h>
|
2021-10-23 18:17:47 +00:00
|
|
|
#include <machines/machineproperties.h>
|
|
|
|
|
2020-12-19 08:53:17 +00:00
|
|
|
#include <string>
|
2022-07-18 09:48:23 +00:00
|
|
|
#include <vector>
|
2020-12-19 08:53:17 +00:00
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
int initialize_pdm(std::string& id)
|
|
|
|
{
|
2023-01-11 22:35:54 +00:00
|
|
|
LOG_F(INFO, "Building machine PDM...");
|
2022-12-21 10:24:22 +00:00
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
uint16_t machine_id;
|
2021-10-04 21:46:19 +00:00
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
// get raw pointer to HMC object
|
2020-12-19 08:53:17 +00:00
|
|
|
HMC* hmc_obj = dynamic_cast<HMC*>(gMachineObj->get_comp_by_name("HMC"));
|
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
if (id == "pm6100") {
|
|
|
|
machine_id = 0x3010;
|
|
|
|
} else if (id == "pm7100") {
|
|
|
|
machine_id = 0x3012;
|
|
|
|
} else if (id == "pm8100") {
|
|
|
|
machine_id = 0x3013;
|
|
|
|
} else {
|
|
|
|
LOG_F(ERROR, "Unknown machine ID: %s!", id.c_str());
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// create machine ID register
|
|
|
|
//gMachineObj->add_component("MachineID", new NubusMacID(machine_id));
|
|
|
|
gMachineObj->add_device("MachineID", std::unique_ptr<NubusMacID>(new NubusMacID(machine_id)));
|
2021-09-30 21:00:56 +00:00
|
|
|
hmc_obj->add_mmio_region(0x5FFFFFFC, 4,
|
|
|
|
dynamic_cast<MMIODevice*>(gMachineObj->get_comp_by_name("MachineID")));
|
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
// allocate ROM region
|
2020-12-19 08:53:17 +00:00
|
|
|
if (!hmc_obj->add_rom_region(0x40000000, 0x400000)) {
|
2022-08-14 12:26:56 +00:00
|
|
|
LOG_F(ERROR, "Could not allocate ROM region!");
|
2020-12-19 08:53:17 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
// mirror ROM to 0xFFC00000 for a PowerPC CPU to start
|
2020-12-19 08:53:17 +00:00
|
|
|
if (!hmc_obj->add_mem_mirror(0xFFC00000, 0x40000000)) {
|
2022-08-14 12:26:56 +00:00
|
|
|
LOG_F(ERROR, "Could not create ROM mirror!");
|
2020-12-19 08:53:17 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
// add 8MB of soldered on-board RAM
|
2020-12-19 08:53:17 +00:00
|
|
|
if (!hmc_obj->add_ram_region(0x00000000, 0x800000)) {
|
2022-08-14 12:26:56 +00:00
|
|
|
LOG_F(ERROR, "Could not allocate built-in RAM region!");
|
2020-12-19 08:53:17 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2023-05-30 17:46:27 +00:00
|
|
|
// get internal SCSI bus object
|
|
|
|
auto scsi_bus = dynamic_cast<ScsiBus*>(gMachineObj->get_comp_by_name("Scsi0"));
|
2022-10-22 21:42:37 +00:00
|
|
|
|
2022-10-31 22:48:19 +00:00
|
|
|
std::string hd_image_path = GET_STR_PROP("hdd_img");
|
|
|
|
if (!hd_image_path.empty()) {
|
|
|
|
// attach SCSI HD to the main bus, ID #0
|
2022-11-10 17:22:44 +00:00
|
|
|
auto my_hd = dynamic_cast<ScsiHardDisk*>(gMachineObj->get_comp_by_name("ScsiHD"));
|
|
|
|
scsi_bus->register_device(0, my_hd);
|
2022-10-31 22:48:19 +00:00
|
|
|
// insert specified disk image
|
|
|
|
my_hd->insert_image(hd_image_path);
|
|
|
|
}
|
2022-02-05 17:15:46 +00:00
|
|
|
|
2022-11-13 23:52:53 +00:00
|
|
|
std::string cdr_image_path = GET_STR_PROP("cdr_img");
|
|
|
|
if (!cdr_image_path.empty()) {
|
|
|
|
// attach SCSI CD-ROM to the main bus, ID #3
|
|
|
|
auto my_cdr = dynamic_cast<ScsiCdrom*>(gMachineObj->get_comp_by_name("ScsiCdrom"));
|
|
|
|
scsi_bus->register_device(3, my_cdr);
|
|
|
|
// insert specified disk image
|
|
|
|
my_cdr->insert_image(cdr_image_path);
|
|
|
|
}
|
2022-02-05 17:15:46 +00:00
|
|
|
|
2022-07-18 09:48:23 +00:00
|
|
|
// Init virtual CPU and request MPC601
|
2022-03-22 11:23:54 +00:00
|
|
|
ppc_cpu_init(hmc_obj, PPC_VER::MPC601, 7812500ULL);
|
2020-12-19 08:53:17 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2022-07-18 09:48:23 +00:00
|
|
|
|
|
|
|
// Monitors supported by the PDM on-board video.
|
|
|
|
// see displayid.cpp for the full list of supported monitor IDs.
|
|
|
|
static const vector<string> PDMBuiltinMonitorIDs = {
|
|
|
|
"PortraitGS", "MacRGB12in", "MacRGB15in", "HiRes12-14in", "VGA-SVGA",
|
|
|
|
"MacRGB16in", "Multiscan15in", "Multiscan17in", "Multiscan20in",
|
|
|
|
"NotConnected"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const PropMap pm6100_settings = {
|
|
|
|
{"rambank1_size",
|
|
|
|
new IntProperty(0, vector<uint32_t>({0, 8, 16, 32, 64, 128}))},
|
|
|
|
{"rambank2_size",
|
|
|
|
new IntProperty(0, vector<uint32_t>({0, 8, 16, 32, 64, 128}))},
|
|
|
|
{"mon_id",
|
|
|
|
new StrProperty("HiRes12-14in", PDMBuiltinMonitorIDs)},
|
2022-07-19 23:36:05 +00:00
|
|
|
{"emmo",
|
|
|
|
new BinProperty(0)},
|
2022-07-18 09:48:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static vector<string> pm6100_devices = {
|
2022-11-13 23:52:53 +00:00
|
|
|
"HMC", "Amic", "ScsiHD", "ScsiCdrom"
|
2022-07-18 09:48:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const MachineDescription pm6100_descriptor = {
|
|
|
|
.name = "pm6100",
|
|
|
|
.description = "Power Macintosh 6100",
|
|
|
|
.devices = pm6100_devices,
|
|
|
|
.settings = pm6100_settings,
|
|
|
|
.init_func = initialize_pdm
|
|
|
|
};
|
|
|
|
|
|
|
|
// self-registration with the MachineFactory
|
|
|
|
REGISTER_MACHINE(pm6100, pm6100_descriptor);
|