2020-03-13 21:49:58 +00:00
|
|
|
/*
|
|
|
|
DingusPPC - The Experimental PowerPC Macintosh emulator
|
|
|
|
Copyright (C) 2018-20 divingkatae and maximum
|
|
|
|
(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 Constructs the Gossamer machine.
|
|
|
|
|
|
|
|
Author: Max Poliakovski
|
|
|
|
*/
|
|
|
|
|
2020-03-14 13:23:46 +00:00
|
|
|
#include "cpu/ppc/ppcemu.h"
|
2020-05-12 18:55:45 +00:00
|
|
|
#include "devices/atirage.h"
|
2020-03-13 21:49:58 +00:00
|
|
|
#include "devices/machineid.h"
|
2020-05-08 20:32:29 +00:00
|
|
|
#include "devices/soundserver.h"
|
2020-03-13 21:49:58 +00:00
|
|
|
#include "devices/macio.h"
|
2020-05-12 18:55:45 +00:00
|
|
|
#include "devices/mpc106.h"
|
2020-03-15 13:29:59 +00:00
|
|
|
#include "devices/spdram.h"
|
2020-05-12 18:55:45 +00:00
|
|
|
#include "devices/viacuda.h"
|
|
|
|
#include "machinebase.h"
|
2020-08-26 03:07:02 +00:00
|
|
|
#include "machineproperties.h"
|
2020-05-12 18:55:45 +00:00
|
|
|
#include <thirdparty/loguru/loguru.hpp>
|
2020-03-15 13:29:59 +00:00
|
|
|
|
2020-09-20 21:25:29 +00:00
|
|
|
|
2020-05-12 18:55:45 +00:00
|
|
|
static void setup_ram_slot(std::string name, int i2c_addr, int capacity_megs) {
|
2020-03-15 13:29:59 +00:00
|
|
|
if (!capacity_megs)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gMachineObj->add_component(name, new SpdSdram168(i2c_addr));
|
2020-05-12 18:55:45 +00:00
|
|
|
SpdSdram168* ram_dimm = dynamic_cast<SpdSdram168*>(gMachineObj->get_comp_by_name(name));
|
2020-03-15 13:29:59 +00:00
|
|
|
ram_dimm->set_capacity(capacity_megs);
|
|
|
|
|
|
|
|
/* register RAM DIMM with the I2C bus */
|
2020-05-12 18:55:45 +00:00
|
|
|
I2CBus* i2c_bus = dynamic_cast<I2CBus*>(gMachineObj->get_comp_by_type(HWCompType::I2C_HOST));
|
2020-03-15 13:29:59 +00:00
|
|
|
i2c_bus->register_device(i2c_addr, ram_dimm);
|
|
|
|
}
|
|
|
|
|
2020-03-13 21:49:58 +00:00
|
|
|
|
2020-10-06 09:01:13 +00:00
|
|
|
int create_gossamer() {
|
2020-03-13 21:49:58 +00:00
|
|
|
if (gMachineObj) {
|
|
|
|
LOG_F(ERROR, "Global machine object not empty!");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
LOG_F(INFO, "Initializing the Gossamer hardware...");
|
|
|
|
|
|
|
|
/* initialize the global machine object */
|
|
|
|
gMachineObj.reset(new MachineBase("Gossamer"));
|
|
|
|
|
|
|
|
/* register MPC106 aka Grackle as memory controller and PCI host */
|
2020-03-14 14:39:34 +00:00
|
|
|
gMachineObj->add_component("Grackle", new MPC106);
|
|
|
|
gMachineObj->add_alias("Grackle", "PCI_Host");
|
2020-03-13 21:49:58 +00:00
|
|
|
|
|
|
|
/* get raw pointer to MPC106 object */
|
2020-05-12 18:55:45 +00:00
|
|
|
MPC106* grackle_obj = dynamic_cast<MPC106*>(gMachineObj->get_comp_by_name("Grackle"));
|
2020-03-13 21:49:58 +00:00
|
|
|
|
|
|
|
/* add the machine ID register */
|
2020-03-14 14:39:34 +00:00
|
|
|
gMachineObj->add_component("MachineID", new GossamerID(0x3d8c));
|
2020-05-12 18:55:45 +00:00
|
|
|
grackle_obj->add_mmio_region(
|
|
|
|
0xFF000004, 4096, dynamic_cast<MMIODevice*>(gMachineObj->get_comp_by_name("MachineID")));
|
2020-03-13 21:49:58 +00:00
|
|
|
|
2020-05-08 20:32:29 +00:00
|
|
|
gMachineObj->add_component("SoundServer", new SoundServer());
|
|
|
|
|
2020-03-13 21:49:58 +00:00
|
|
|
/* add the Heathrow I/O controller */
|
2020-03-14 14:39:34 +00:00
|
|
|
gMachineObj->add_component("Heathrow", new HeathrowIC);
|
2020-05-12 18:55:45 +00:00
|
|
|
grackle_obj->pci_register_device(
|
|
|
|
16, dynamic_cast<PCIDevice*>(gMachineObj->get_comp_by_name("Heathrow")));
|
2020-03-13 21:49:58 +00:00
|
|
|
|
|
|
|
/* allocate ROM region */
|
|
|
|
if (!grackle_obj->add_rom_region(0xFFC00000, 0x400000)) {
|
|
|
|
LOG_F(ERROR, "Could not allocate ROM region!\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2020-03-15 13:29:59 +00:00
|
|
|
/* configure RAM slots */
|
2020-10-06 09:01:13 +00:00
|
|
|
setup_ram_slot("RAM_DIMM_1", 0x57, GET_INT_PROP("rambank1_size"));
|
|
|
|
setup_ram_slot("RAM_DIMM_2", 0x56, GET_INT_PROP("rambank2_size"));
|
|
|
|
setup_ram_slot("RAM_DIMM_3", 0x55, GET_INT_PROP("rambank3_size"));
|
2020-03-15 13:29:59 +00:00
|
|
|
|
2020-03-31 16:25:58 +00:00
|
|
|
/* register ATI 3D Rage Pro video card with the PCI host bridge */
|
2020-10-06 09:01:13 +00:00
|
|
|
gMachineObj->add_component("ATIRage",
|
|
|
|
new ATIRage(ATI_RAGE_PRO_DEV_ID, GET_INT_PROP("gfxmem_size")));
|
2020-05-12 18:55:45 +00:00
|
|
|
grackle_obj->pci_register_device(
|
|
|
|
18, dynamic_cast<PCIDevice*>(gMachineObj->get_comp_by_name("ATIRage")));
|
2020-03-31 16:25:58 +00:00
|
|
|
|
2020-03-13 21:49:58 +00:00
|
|
|
/* Init virtual CPU and request MPC750 CPU aka G3 */
|
|
|
|
ppc_cpu_init(grackle_obj, PPC_VER::MPC750);
|
|
|
|
|
|
|
|
LOG_F(INFO, "Initialization complete.\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|