2020-12-19 08:53:17 +00:00
|
|
|
/*
|
|
|
|
DingusPPC - The Experimental PowerPC Macintosh emulator
|
2021-10-23 19:00:31 +00:00
|
|
|
Copyright (C) 2018-21 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-02-06 14:23:30 +00:00
|
|
|
#include <devices/floppy/superdrive.h>
|
2021-10-23 18:17:47 +00:00
|
|
|
#include <devices/ioctrl/amic.h>
|
|
|
|
#include <devices/memctrl/hmc.h>
|
|
|
|
#include <devices/sound/soundserver.h>
|
2021-09-25 21:16:38 +00:00
|
|
|
#include <loguru.hpp>
|
2021-10-23 18:17:47 +00:00
|
|
|
#include <machines/machinebase.h>
|
|
|
|
#include <machines/machineproperties.h>
|
|
|
|
|
2020-12-19 08:53:17 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
int create_pdm(std::string& id) {
|
|
|
|
if (gMachineObj) {
|
|
|
|
LOG_F(ERROR, "PDM Factory: global machine object not empty!");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
LOG_F(INFO, "Initializing the %s hardware...", id.c_str());
|
|
|
|
|
|
|
|
/* initialize the global machine object */
|
|
|
|
gMachineObj.reset(new MachineBase("PDM"));
|
|
|
|
|
|
|
|
/* register HMC memory controller */
|
|
|
|
gMachineObj->add_component("HMC", new HMC);
|
|
|
|
|
2021-10-04 21:46:19 +00:00
|
|
|
/* start the sound server. */
|
|
|
|
gMachineObj->add_component("SoundServer", new SoundServer());
|
|
|
|
|
2021-09-30 21:00:56 +00:00
|
|
|
/* register AMIC I/O controller */
|
|
|
|
gMachineObj->add_component("AMIC", new AMIC);
|
|
|
|
|
2020-12-19 08:53:17 +00:00
|
|
|
/* get raw pointer to HMC object */
|
|
|
|
HMC* hmc_obj = dynamic_cast<HMC*>(gMachineObj->get_comp_by_name("HMC"));
|
|
|
|
|
2022-01-21 10:16:34 +00:00
|
|
|
// allocate machine ID register and tell we're running PowerMac 6100
|
2021-09-30 21:00:56 +00:00
|
|
|
// TODO: add a possibility to select another machine
|
|
|
|
// to be used with the same ROM
|
|
|
|
gMachineObj->add_component("MachineID", new NubusMacID(0x3010));
|
|
|
|
hmc_obj->add_mmio_region(0x5FFFFFFC, 4,
|
|
|
|
dynamic_cast<MMIODevice*>(gMachineObj->get_comp_by_name("MachineID")));
|
|
|
|
|
2020-12-19 08:53:17 +00:00
|
|
|
/* allocate ROM region */
|
|
|
|
if (!hmc_obj->add_rom_region(0x40000000, 0x400000)) {
|
|
|
|
LOG_F(ERROR, "Could not allocate ROM region!\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mirror ROM to 0xFFC00000 for a PowerPC CPU to start */
|
|
|
|
if (!hmc_obj->add_mem_mirror(0xFFC00000, 0x40000000)) {
|
|
|
|
LOG_F(ERROR, "Could not create ROM mirror!\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add 8MB of soldered on-board RAM */
|
|
|
|
if (!hmc_obj->add_ram_region(0x00000000, 0x800000)) {
|
|
|
|
LOG_F(ERROR, "Could not allocate built-in RAM region!\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-02-05 17:15:46 +00:00
|
|
|
/* add internal SCSI bus */
|
|
|
|
gMachineObj->add_component("SCSI0", new ScsiBus);
|
|
|
|
|
2020-12-19 08:53:17 +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
|
|
|
|
2022-01-21 10:16:34 +00:00
|
|
|
// post-initialize all devices
|
|
|
|
if (gMachineObj->postinit_devices()) {
|
|
|
|
LOG_F(ERROR, "Could not post-initialize devices!\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-02-06 14:23:30 +00:00
|
|
|
// if a floppy image was given "insert" it into the virtual superdrive
|
|
|
|
std::string fd_image_path = GET_STR_PROP("fdd_img");
|
2022-02-24 14:33:30 +00:00
|
|
|
std::string fd_write_prot = GET_STR_PROP("fdd_wr_prot");
|
2022-02-06 14:23:30 +00:00
|
|
|
if (!fd_image_path.empty()) {
|
|
|
|
using namespace MacSuperdrive;
|
|
|
|
|
|
|
|
MacSuperDrive* fdd = dynamic_cast<MacSuperDrive*>
|
|
|
|
(gMachineObj->get_comp_by_name("Superdrive"));
|
2022-02-24 14:33:30 +00:00
|
|
|
|
|
|
|
bool write_flag = false;
|
|
|
|
|
|
|
|
if (!fd_write_prot.empty()) {
|
2022-03-12 22:43:45 +00:00
|
|
|
if ((fd_write_prot.compare("ON") == 0) || (fd_write_prot.compare("on") == 0)) {
|
2022-02-24 14:33:30 +00:00
|
|
|
write_flag = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fdd->insert_disk(fd_image_path, write_flag);
|
2021-12-04 13:22:02 +00:00
|
|
|
}
|
|
|
|
|
2020-12-19 08:53:17 +00:00
|
|
|
LOG_F(INFO, "Initialization completed.\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|