bellard | 6420120 | 2004-05-26 22:55:16 +0000 | [diff] [blame] | 1 | /* |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 2 | * QEMU PowerPC CHRP (currently NewWorld PowerMac) hardware System Emulator |
ths | 5fafdf2 | 2007-09-16 21:08:06 +0000 | [diff] [blame] | 3 | * |
j_mayer | 4710357 | 2007-03-30 09:38:04 +0000 | [diff] [blame] | 4 | * Copyright (c) 2004-2007 Fabrice Bellard |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 5 | * Copyright (c) 2007 Jocelyn Mayer |
ths | 5fafdf2 | 2007-09-16 21:08:06 +0000 | [diff] [blame] | 6 | * |
bellard | 6420120 | 2004-05-26 22:55:16 +0000 | [diff] [blame] | 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | * of this software and associated documentation files (the "Software"), to deal |
| 9 | * in the Software without restriction, including without limitation the rights |
| 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 11 | * copies of the Software, and to permit persons to whom the Software is |
| 12 | * furnished to do so, subject to the following conditions: |
| 13 | * |
| 14 | * The above copyright notice and this permission notice shall be included in |
| 15 | * all copies or substantial portions of the Software. |
| 16 | * |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 20 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 23 | * THE SOFTWARE. |
Alexander Graf | 915cd3a | 2010-02-09 17:37:03 +0100 | [diff] [blame] | 24 | * |
| 25 | * PCI bus layout on a real G5 (U3 based): |
| 26 | * |
| 27 | * 0000:f0:0b.0 Host bridge [0600]: Apple Computer Inc. U3 AGP [106b:004b] |
| 28 | * 0000:f0:10.0 VGA compatible controller [0300]: ATI Technologies Inc RV350 AP [Radeon 9600] [1002:4150] |
| 29 | * 0001:00:00.0 Host bridge [0600]: Apple Computer Inc. CPC945 HT Bridge [106b:004a] |
| 30 | * 0001:00:01.0 PCI bridge [0604]: Advanced Micro Devices [AMD] AMD-8131 PCI-X Bridge [1022:7450] (rev 12) |
| 31 | * 0001:00:02.0 PCI bridge [0604]: Advanced Micro Devices [AMD] AMD-8131 PCI-X Bridge [1022:7450] (rev 12) |
| 32 | * 0001:00:03.0 PCI bridge [0604]: Apple Computer Inc. K2 HT-PCI Bridge [106b:0045] |
| 33 | * 0001:00:04.0 PCI bridge [0604]: Apple Computer Inc. K2 HT-PCI Bridge [106b:0046] |
| 34 | * 0001:00:05.0 PCI bridge [0604]: Apple Computer Inc. K2 HT-PCI Bridge [106b:0047] |
| 35 | * 0001:00:06.0 PCI bridge [0604]: Apple Computer Inc. K2 HT-PCI Bridge [106b:0048] |
| 36 | * 0001:00:07.0 PCI bridge [0604]: Apple Computer Inc. K2 HT-PCI Bridge [106b:0049] |
| 37 | * 0001:01:07.0 Class [ff00]: Apple Computer Inc. K2 KeyLargo Mac/IO [106b:0041] (rev 20) |
| 38 | * 0001:01:08.0 USB Controller [0c03]: Apple Computer Inc. K2 KeyLargo USB [106b:0040] |
| 39 | * 0001:01:09.0 USB Controller [0c03]: Apple Computer Inc. K2 KeyLargo USB [106b:0040] |
| 40 | * 0001:02:0b.0 USB Controller [0c03]: NEC Corporation USB [1033:0035] (rev 43) |
| 41 | * 0001:02:0b.1 USB Controller [0c03]: NEC Corporation USB [1033:0035] (rev 43) |
| 42 | * 0001:02:0b.2 USB Controller [0c03]: NEC Corporation USB 2.0 [1033:00e0] (rev 04) |
| 43 | * 0001:03:0d.0 Class [ff00]: Apple Computer Inc. K2 ATA/100 [106b:0043] |
| 44 | * 0001:03:0e.0 FireWire (IEEE 1394) [0c00]: Apple Computer Inc. K2 FireWire [106b:0042] |
| 45 | * 0001:04:0f.0 Ethernet controller [0200]: Apple Computer Inc. K2 GMAC (Sun GEM) [106b:004c] |
| 46 | * 0001:05:0c.0 IDE interface [0101]: Broadcom K2 SATA [1166:0240] |
bellard | 6420120 | 2004-05-26 22:55:16 +0000 | [diff] [blame] | 47 | */ |
Markus Armbruster | a8d2532 | 2019-05-23 16:35:08 +0200 | [diff] [blame] | 48 | |
Peter Maydell | 0d75590 | 2016-01-26 18:16:58 +0000 | [diff] [blame] | 49 | #include "qemu/osdep.h" |
Paolo Bonzini | 2c65db5 | 2020-10-28 07:36:57 -0400 | [diff] [blame] | 50 | #include "qemu/datadir.h" |
BALATON Zoltan | cfb47bf | 2022-10-28 13:56:23 +0200 | [diff] [blame] | 51 | #include "qemu/units.h" |
Markus Armbruster | da34e65 | 2016-03-14 09:01:28 +0100 | [diff] [blame] | 52 | #include "qapi/error.h" |
Paolo Bonzini | 0d09e41 | 2013-02-05 17:06:20 +0100 | [diff] [blame] | 53 | #include "hw/ppc/ppc.h" |
Markus Armbruster | a27bd6c | 2019-08-12 07:23:51 +0200 | [diff] [blame] | 54 | #include "hw/qdev-properties.h" |
BALATON Zoltan | 443f07b | 2022-10-28 13:56:27 +0200 | [diff] [blame] | 55 | #include "hw/nvram/mac_nvram.h" |
BALATON Zoltan | cfb47bf | 2022-10-28 13:56:23 +0200 | [diff] [blame] | 56 | #include "hw/boards.h" |
| 57 | #include "hw/pci-host/uninorth.h" |
Paolo Bonzini | 0d09e41 | 2013-02-05 17:06:20 +0100 | [diff] [blame] | 58 | #include "hw/input/adb.h" |
| 59 | #include "hw/ppc/mac_dbdma.h" |
Andreas Färber | baec191 | 2013-01-23 23:03:54 +0000 | [diff] [blame] | 60 | #include "hw/pci/pci.h" |
Paolo Bonzini | 1422e32 | 2012-10-24 08:43:34 +0200 | [diff] [blame] | 61 | #include "net/net.h" |
Paolo Bonzini | 9c17d61 | 2012-12-17 18:20:04 +0100 | [diff] [blame] | 62 | #include "sysemu/sysemu.h" |
Paolo Bonzini | 0d09e41 | 2013-02-05 17:06:20 +0100 | [diff] [blame] | 63 | #include "hw/nvram/fw_cfg.h" |
| 64 | #include "hw/char/escc.h" |
Mark Cave-Ayland | e1218e4 | 2018-02-28 20:32:37 +0000 | [diff] [blame] | 65 | #include "hw/misc/macio/macio.h" |
Paolo Bonzini | 0d09e41 | 2013-02-05 17:06:20 +0100 | [diff] [blame] | 66 | #include "hw/ppc/openpic.h" |
Andreas Färber | baec191 | 2013-01-23 23:03:54 +0000 | [diff] [blame] | 67 | #include "hw/loader.h" |
Mark Cave-Ayland | 5d19be6 | 2018-08-29 17:59:11 +0100 | [diff] [blame] | 68 | #include "hw/fw-path-provider.h" |
Blue Swirl | ca20cf3 | 2009-09-20 14:58:02 +0000 | [diff] [blame] | 69 | #include "elf.h" |
Markus Armbruster | c525436 | 2015-12-17 17:35:09 +0100 | [diff] [blame] | 70 | #include "qemu/error-report.h" |
Paolo Bonzini | 9c17d61 | 2012-12-17 18:20:04 +0100 | [diff] [blame] | 71 | #include "sysemu/kvm.h" |
Markus Armbruster | 71e8a91 | 2019-08-12 07:23:38 +0200 | [diff] [blame] | 72 | #include "sysemu/reset.h" |
Alexander Graf | dc333cd | 2010-02-09 17:37:05 +0100 | [diff] [blame] | 73 | #include "kvm_ppc.h" |
Alexander Graf | a2236d4 | 2010-02-09 17:37:08 +0100 | [diff] [blame] | 74 | #include "hw/usb.h" |
Andreas Färber | baec191 | 2013-01-23 23:03:54 +0000 | [diff] [blame] | 75 | #include "hw/sysbus.h" |
Laurent Vivier | 5283c27 | 2017-02-10 10:27:22 +0100 | [diff] [blame] | 76 | #include "trace.h" |
bellard | 267002c | 2004-06-03 18:46:20 +0000 | [diff] [blame] | 77 | |
ths | e4bcb14 | 2007-12-02 04:51:10 +0000 | [diff] [blame] | 78 | #define MAX_IDE_BUS 2 |
blueswir1 | 006f3a4 | 2009-02-08 15:59:36 +0000 | [diff] [blame] | 79 | #define CFG_ADDR 0xf0000510 |
Mark Cave-Ayland | 78abf93 | 2024-03-04 07:35:48 +0000 | [diff] [blame] | 80 | #define TBFREQ (25UL * 1000UL * 1000UL) |
Benjamin Herrenschmidt | 3c06228 | 2017-09-17 18:15:42 +0100 | [diff] [blame] | 81 | #define CLOCKFREQ (900UL * 1000UL * 1000UL) |
BALATON Zoltan | 9d1c128 | 2014-04-17 19:04:44 +0200 | [diff] [blame] | 82 | #define BUSFREQ (100UL * 1000UL * 1000UL) |
ths | e4bcb14 | 2007-12-02 04:51:10 +0000 | [diff] [blame] | 83 | |
Mark Cave-Ayland | 53ecf09 | 2017-05-01 14:43:33 +0100 | [diff] [blame] | 84 | #define NDRV_VGA_FILENAME "qemu_vga.ndrv" |
| 85 | |
BALATON Zoltan | 3d0031c | 2022-10-28 13:56:26 +0200 | [diff] [blame] | 86 | #define PROM_FILENAME "openbios-ppc" |
BALATON Zoltan | 31a6f35 | 2020-10-16 01:47:17 +0200 | [diff] [blame] | 87 | #define PROM_BASE 0xfff00000 |
| 88 | #define PROM_SIZE (1 * MiB) |
bellard | 0aa6a4a | 2005-06-05 15:11:17 +0000 | [diff] [blame] | 89 | |
BALATON Zoltan | 3d0031c | 2022-10-28 13:56:26 +0200 | [diff] [blame] | 90 | #define KERNEL_LOAD_ADDR 0x01000000 |
| 91 | #define KERNEL_GAP 0x00100000 |
| 92 | |
BALATON Zoltan | cfb47bf | 2022-10-28 13:56:23 +0200 | [diff] [blame] | 93 | #define TYPE_CORE99_MACHINE MACHINE_TYPE_NAME("mac99") |
| 94 | typedef struct Core99MachineState Core99MachineState; |
| 95 | DECLARE_INSTANCE_CHECKER(Core99MachineState, CORE99_MACHINE, |
| 96 | TYPE_CORE99_MACHINE) |
| 97 | |
BALATON Zoltan | 53cb552 | 2022-10-28 13:56:30 +0200 | [diff] [blame] | 98 | typedef enum { |
| 99 | CORE99_VIA_CONFIG_CUDA = 0, |
| 100 | CORE99_VIA_CONFIG_PMU, |
| 101 | CORE99_VIA_CONFIG_PMU_ADB |
| 102 | } Core99ViaConfig; |
BALATON Zoltan | cfb47bf | 2022-10-28 13:56:23 +0200 | [diff] [blame] | 103 | |
| 104 | struct Core99MachineState { |
| 105 | /*< private >*/ |
| 106 | MachineState parent; |
| 107 | |
BALATON Zoltan | 53cb552 | 2022-10-28 13:56:30 +0200 | [diff] [blame] | 108 | Core99ViaConfig via_config; |
BALATON Zoltan | cfb47bf | 2022-10-28 13:56:23 +0200 | [diff] [blame] | 109 | }; |
| 110 | |
Gonglei | ddcd553 | 2014-12-03 19:04:02 +0000 | [diff] [blame] | 111 | static void fw_cfg_boot_set(void *opaque, const char *boot_device, |
| 112 | Error **errp) |
blueswir1 | 513f789 | 2009-03-08 09:51:29 +0000 | [diff] [blame] | 113 | { |
Gabriel L. Somlo | 48779e5 | 2015-06-08 14:10:45 -0400 | [diff] [blame] | 114 | fw_cfg_modify_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]); |
blueswir1 | 513f789 | 2009-03-08 09:51:29 +0000 | [diff] [blame] | 115 | } |
| 116 | |
Aurelien Jarno | 409dbce | 2010-03-14 21:20:59 +0100 | [diff] [blame] | 117 | static uint64_t translate_kernel_address(void *opaque, uint64_t addr) |
| 118 | { |
| 119 | return (addr & 0x0fffffff) + KERNEL_LOAD_ADDR; |
| 120 | } |
| 121 | |
Andreas Färber | 1bba0dc | 2012-02-08 03:03:33 +0100 | [diff] [blame] | 122 | static void ppc_core99_reset(void *opaque) |
| 123 | { |
Andreas Färber | 6680988 | 2012-05-04 17:30:25 +0200 | [diff] [blame] | 124 | PowerPCCPU *cpu = opaque; |
Andreas Färber | 1bba0dc | 2012-02-08 03:03:33 +0100 | [diff] [blame] | 125 | |
Andreas Färber | 6680988 | 2012-05-04 17:30:25 +0200 | [diff] [blame] | 126 | cpu_reset(CPU(cpu)); |
Alexander Graf | 20f649d | 2013-04-04 18:45:07 +0200 | [diff] [blame] | 127 | /* 970 CPUs want to get their initial IP as part of their boot protocol */ |
BALATON Zoltan | 31a6f35 | 2020-10-16 01:47:17 +0200 | [diff] [blame] | 128 | cpu->env.nip = PROM_BASE + 0x100; |
Andreas Färber | 1bba0dc | 2012-02-08 03:03:33 +0100 | [diff] [blame] | 129 | } |
| 130 | |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 131 | /* PowerPC Mac99 hardware initialisation */ |
Marcel Apfelbaum | 3ef9622 | 2014-05-07 17:42:57 +0300 | [diff] [blame] | 132 | static void ppc_core99_init(MachineState *machine) |
bellard | 6420120 | 2004-05-26 22:55:16 +0000 | [diff] [blame] | 133 | { |
Mark Cave-Ayland | f1114c1 | 2018-06-12 17:43:57 +0100 | [diff] [blame] | 134 | Core99MachineState *core99_machine = CORE99_MACHINE(machine); |
Thomas Huth | 053b708 | 2023-05-12 14:40:20 +0200 | [diff] [blame] | 135 | MachineClass *mc = MACHINE_GET_CLASS(machine); |
Andreas Färber | 8f8204e | 2012-05-04 17:29:07 +0200 | [diff] [blame] | 136 | PowerPCCPU *cpu = NULL; |
Andreas Färber | e2684c0 | 2012-03-14 01:38:23 +0100 | [diff] [blame] | 137 | CPUPPCState *env = NULL; |
Paul Brook | 5cea859 | 2009-05-30 00:52:44 +0100 | [diff] [blame] | 138 | char *filename; |
Greg Kurz | 9929301 | 2018-11-27 14:06:22 +0100 | [diff] [blame] | 139 | IrqLines *openpic_irqs; |
BALATON Zoltan | 6120dc8 | 2022-10-28 13:56:20 +0200 | [diff] [blame] | 140 | int i, j, k, ppc_boot_device, machine_arch, bios_size = -1; |
BALATON Zoltan | cc4a140 | 2022-10-28 13:56:17 +0200 | [diff] [blame] | 141 | const char *bios_name = machine->firmware ?: PROM_FILENAME; |
Igor Mammedov | a5b5de0 | 2020-02-19 11:09:34 -0500 | [diff] [blame] | 142 | MemoryRegion *bios = g_new(MemoryRegion, 1); |
BALATON Zoltan | 6120dc8 | 2022-10-28 13:56:20 +0200 | [diff] [blame] | 143 | hwaddr kernel_base = 0, initrd_base = 0, cmdline_base = 0; |
| 144 | long kernel_size = 0, initrd_size = 0; |
bellard | 46e50e9 | 2004-06-21 19:43:00 +0000 | [diff] [blame] | 145 | PCIBus *pci_bus; |
Mark Cave-Ayland | f1114c1 | 2018-06-12 17:43:57 +0100 | [diff] [blame] | 146 | bool has_pmu, has_adb; |
BALATON Zoltan | 18e0383 | 2022-10-28 13:56:22 +0200 | [diff] [blame] | 147 | Object *macio; |
Andreas Färber | 07a7484 | 2013-01-23 23:04:01 +0000 | [diff] [blame] | 148 | MACIOIDEState *macio_ide; |
Andreas Färber | 293c867 | 2013-01-23 23:04:05 +0000 | [diff] [blame] | 149 | BusState *adb_bus; |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 150 | MacIONVRAMState *nvr; |
Gerd Hoffmann | f455e98 | 2009-08-28 15:47:03 +0200 | [diff] [blame] | 151 | DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
blueswir1 | 006f3a4 | 2009-02-08 15:59:36 +0000 | [diff] [blame] | 152 | void *fw_cfg; |
Alexander Graf | d0b7263 | 2012-12-08 05:17:14 +0100 | [diff] [blame] | 153 | SysBusDevice *s; |
BALATON Zoltan | 18e0383 | 2022-10-28 13:56:22 +0200 | [diff] [blame] | 154 | DeviceState *dev, *pic_dev, *uninorth_pci_dev; |
Mark Cave-Ayland | 6ce97b2 | 2020-12-29 17:56:16 +0000 | [diff] [blame] | 155 | DeviceState *uninorth_internal_dev = NULL, *uninorth_agp_dev = NULL; |
Alexander Graf | 261265c | 2014-07-11 03:24:39 +0200 | [diff] [blame] | 156 | hwaddr nvram_addr = 0xFFF04000; |
BALATON Zoltan | 6b924ab | 2022-10-28 13:56:19 +0200 | [diff] [blame] | 157 | uint64_t tbfreq = kvm_enabled() ? kvmppc_get_tbfreq() : TBFREQ; |
bellard | 6420120 | 2004-05-26 22:55:16 +0000 | [diff] [blame] | 158 | |
bellard | c68ea70 | 2005-11-21 23:33:12 +0000 | [diff] [blame] | 159 | /* init CPUs */ |
BALATON Zoltan | cc4a140 | 2022-10-28 13:56:17 +0200 | [diff] [blame] | 160 | for (i = 0; i < machine->smp.cpus; i++) { |
Igor Mammedov | 9dff4c0 | 2017-10-09 21:50:52 +0200 | [diff] [blame] | 161 | cpu = POWERPC_CPU(cpu_create(machine->cpu_type)); |
Andreas Färber | 8f8204e | 2012-05-04 17:29:07 +0200 | [diff] [blame] | 162 | env = &cpu->env; |
| 163 | |
j_mayer | e9df014 | 2007-04-09 22:45:36 +0000 | [diff] [blame] | 164 | /* Set time-base frequency to 100 Mhz */ |
Alexander Graf | 536d8cd | 2013-06-29 17:34:58 +0200 | [diff] [blame] | 165 | cpu_ppc_tb_init(env, TBFREQ); |
Andreas Färber | 6680988 | 2012-05-04 17:30:25 +0200 | [diff] [blame] | 166 | qemu_register_reset(ppc_core99_reset, cpu); |
j_mayer | e9df014 | 2007-04-09 22:45:36 +0000 | [diff] [blame] | 167 | } |
bellard | c68ea70 | 2005-11-21 23:33:12 +0000 | [diff] [blame] | 168 | |
bellard | 6420120 | 2004-05-26 22:55:16 +0000 | [diff] [blame] | 169 | /* allocate RAM */ |
Philippe Mathieu-Daudé | 03b3542 | 2021-04-06 10:48:42 +0200 | [diff] [blame] | 170 | if (machine->ram_size > 2 * GiB) { |
| 171 | error_report("RAM size more than 2 GiB is not supported"); |
| 172 | exit(1); |
| 173 | } |
Igor Mammedov | a5b5de0 | 2020-02-19 11:09:34 -0500 | [diff] [blame] | 174 | memory_region_add_subregion(get_system_memory(), 0, machine->ram); |
blueswir1 | 864c136 | 2009-02-05 20:20:29 +0000 | [diff] [blame] | 175 | |
BALATON Zoltan | 31a6f35 | 2020-10-16 01:47:17 +0200 | [diff] [blame] | 176 | /* allocate and load firmware ROM */ |
| 177 | memory_region_init_rom(bios, NULL, "ppc_core99.bios", PROM_SIZE, |
Markus Armbruster | f8ed85a | 2015-09-11 16:51:43 +0200 | [diff] [blame] | 178 | &error_fatal); |
BALATON Zoltan | 31a6f35 | 2020-10-16 01:47:17 +0200 | [diff] [blame] | 179 | memory_region_add_subregion(get_system_memory(), PROM_BASE, bios); |
Hu Tao | e206ad4 | 2014-07-21 17:30:17 +0800 | [diff] [blame] | 180 | |
Paul Brook | 5cea859 | 2009-05-30 00:52:44 +0100 | [diff] [blame] | 181 | filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); |
Paul Brook | 5cea859 | 2009-05-30 00:52:44 +0100 | [diff] [blame] | 182 | if (filename) { |
BALATON Zoltan | 31a6f35 | 2020-10-16 01:47:17 +0200 | [diff] [blame] | 183 | /* Load OpenBIOS (ELF) */ |
Liam Merwick | 4366e1d | 2019-01-15 12:18:03 +0000 | [diff] [blame] | 184 | bios_size = load_elf(filename, NULL, NULL, NULL, NULL, |
Aleksandar Markovic | 6cdda0f | 2020-01-26 23:55:04 +0100 | [diff] [blame] | 185 | NULL, NULL, NULL, 1, PPC_ELF_MACHINE, 0, 0); |
Blue Swirl | ca20cf3 | 2009-09-20 14:58:02 +0000 | [diff] [blame] | 186 | |
BALATON Zoltan | 31a6f35 | 2020-10-16 01:47:17 +0200 | [diff] [blame] | 187 | if (bios_size <= 0) { |
| 188 | /* or load binary ROM image */ |
| 189 | bios_size = load_image_targphys(filename, PROM_BASE, PROM_SIZE); |
| 190 | } |
Anthony Liguori | 7267c09 | 2011-08-20 22:09:37 -0500 | [diff] [blame] | 191 | g_free(filename); |
Paul Brook | 5cea859 | 2009-05-30 00:52:44 +0100 | [diff] [blame] | 192 | } |
BALATON Zoltan | 31a6f35 | 2020-10-16 01:47:17 +0200 | [diff] [blame] | 193 | if (bios_size < 0 || bios_size > PROM_SIZE) { |
Markus Armbruster | c525436 | 2015-12-17 17:35:09 +0100 | [diff] [blame] | 194 | error_report("could not load PowerPC bios '%s'", bios_name); |
bellard | 6420120 | 2004-05-26 22:55:16 +0000 | [diff] [blame] | 195 | exit(1); |
| 196 | } |
ths | 3b46e62 | 2007-09-17 08:09:54 +0000 | [diff] [blame] | 197 | |
BALATON Zoltan | cc4a140 | 2022-10-28 13:56:17 +0200 | [diff] [blame] | 198 | if (machine->kernel_filename) { |
BALATON Zoltan | 6120dc8 | 2022-10-28 13:56:20 +0200 | [diff] [blame] | 199 | int bswap_needed = 0; |
Blue Swirl | ca20cf3 | 2009-09-20 14:58:02 +0000 | [diff] [blame] | 200 | |
| 201 | #ifdef BSWAP_NEEDED |
| 202 | bswap_needed = 1; |
Blue Swirl | ca20cf3 | 2009-09-20 14:58:02 +0000 | [diff] [blame] | 203 | #endif |
bellard | b6b8bd1 | 2004-06-21 16:55:53 +0000 | [diff] [blame] | 204 | kernel_base = KERNEL_LOAD_ADDR; |
BALATON Zoltan | cc4a140 | 2022-10-28 13:56:17 +0200 | [diff] [blame] | 205 | kernel_size = load_elf(machine->kernel_filename, NULL, |
BALATON Zoltan | 617160c | 2020-07-05 19:22:11 +0200 | [diff] [blame] | 206 | translate_kernel_address, NULL, NULL, NULL, |
| 207 | NULL, NULL, 1, PPC_ELF_MACHINE, 0, 0); |
BALATON Zoltan | cc537e1 | 2022-10-28 13:56:29 +0200 | [diff] [blame] | 208 | if (kernel_size < 0) { |
BALATON Zoltan | cc4a140 | 2022-10-28 13:56:17 +0200 | [diff] [blame] | 209 | kernel_size = load_aout(machine->kernel_filename, kernel_base, |
| 210 | machine->ram_size - kernel_base, |
| 211 | bswap_needed, TARGET_PAGE_SIZE); |
BALATON Zoltan | cc537e1 | 2022-10-28 13:56:29 +0200 | [diff] [blame] | 212 | } |
| 213 | if (kernel_size < 0) { |
BALATON Zoltan | cc4a140 | 2022-10-28 13:56:17 +0200 | [diff] [blame] | 214 | kernel_size = load_image_targphys(machine->kernel_filename, |
blueswir1 | 513f789 | 2009-03-08 09:51:29 +0000 | [diff] [blame] | 215 | kernel_base, |
BALATON Zoltan | cc4a140 | 2022-10-28 13:56:17 +0200 | [diff] [blame] | 216 | machine->ram_size - kernel_base); |
BALATON Zoltan | cc537e1 | 2022-10-28 13:56:29 +0200 | [diff] [blame] | 217 | } |
bellard | b6b8bd1 | 2004-06-21 16:55:53 +0000 | [diff] [blame] | 218 | if (kernel_size < 0) { |
BALATON Zoltan | cc4a140 | 2022-10-28 13:56:17 +0200 | [diff] [blame] | 219 | error_report("could not load kernel '%s'", |
| 220 | machine->kernel_filename); |
bellard | b6b8bd1 | 2004-06-21 16:55:53 +0000 | [diff] [blame] | 221 | exit(1); |
| 222 | } |
| 223 | /* load initrd */ |
BALATON Zoltan | cc4a140 | 2022-10-28 13:56:17 +0200 | [diff] [blame] | 224 | if (machine->initrd_filename) { |
Kamil Rytarowski | 39d9684 | 2017-09-11 22:16:10 +0200 | [diff] [blame] | 225 | initrd_base = TARGET_PAGE_ALIGN(kernel_base + kernel_size + KERNEL_GAP); |
BALATON Zoltan | cc4a140 | 2022-10-28 13:56:17 +0200 | [diff] [blame] | 226 | initrd_size = load_image_targphys(machine->initrd_filename, |
| 227 | initrd_base, |
| 228 | machine->ram_size - initrd_base); |
bellard | b6b8bd1 | 2004-06-21 16:55:53 +0000 | [diff] [blame] | 229 | if (initrd_size < 0) { |
Markus Armbruster | c525436 | 2015-12-17 17:35:09 +0100 | [diff] [blame] | 230 | error_report("could not load initial ram disk '%s'", |
BALATON Zoltan | cc4a140 | 2022-10-28 13:56:17 +0200 | [diff] [blame] | 231 | machine->initrd_filename); |
bellard | b6b8bd1 | 2004-06-21 16:55:53 +0000 | [diff] [blame] | 232 | exit(1); |
| 233 | } |
Kamil Rytarowski | 39d9684 | 2017-09-11 22:16:10 +0200 | [diff] [blame] | 234 | cmdline_base = TARGET_PAGE_ALIGN(initrd_base + initrd_size); |
bellard | b6b8bd1 | 2004-06-21 16:55:53 +0000 | [diff] [blame] | 235 | } else { |
Kamil Rytarowski | 39d9684 | 2017-09-11 22:16:10 +0200 | [diff] [blame] | 236 | cmdline_base = TARGET_PAGE_ALIGN(kernel_base + kernel_size + KERNEL_GAP); |
bellard | b6b8bd1 | 2004-06-21 16:55:53 +0000 | [diff] [blame] | 237 | } |
balrog | 6ac0e82 | 2007-10-31 01:54:04 +0000 | [diff] [blame] | 238 | ppc_boot_device = 'm'; |
bellard | b6b8bd1 | 2004-06-21 16:55:53 +0000 | [diff] [blame] | 239 | } else { |
j_mayer | 28c5af5 | 2007-11-11 01:50:45 +0000 | [diff] [blame] | 240 | ppc_boot_device = '\0'; |
| 241 | /* We consider that NewWorld PowerMac never have any floppy drive |
| 242 | * For now, OHW cannot boot from the network. |
| 243 | */ |
BALATON Zoltan | cc4a140 | 2022-10-28 13:56:17 +0200 | [diff] [blame] | 244 | for (i = 0; machine->boot_config.order[i] != '\0'; i++) { |
| 245 | if (machine->boot_config.order[i] >= 'c' && |
| 246 | machine->boot_config.order[i] <= 'f') { |
| 247 | ppc_boot_device = machine->boot_config.order[i]; |
j_mayer | 28c5af5 | 2007-11-11 01:50:45 +0000 | [diff] [blame] | 248 | break; |
j_mayer | 0d913fd | 2007-11-11 14:44:28 +0000 | [diff] [blame] | 249 | } |
j_mayer | 28c5af5 | 2007-11-11 01:50:45 +0000 | [diff] [blame] | 250 | } |
| 251 | if (ppc_boot_device == '\0') { |
Alistair Francis | 6f76b81 | 2018-02-03 09:43:10 +0100 | [diff] [blame] | 252 | error_report("No valid boot device for Mac99 machine"); |
j_mayer | 28c5af5 | 2007-11-11 01:50:45 +0000 | [diff] [blame] | 253 | exit(1); |
| 254 | } |
bellard | b6b8bd1 | 2004-06-21 16:55:53 +0000 | [diff] [blame] | 255 | } |
bellard | 6420120 | 2004-05-26 22:55:16 +0000 | [diff] [blame] | 256 | |
BALATON Zoltan | cc4a140 | 2022-10-28 13:56:17 +0200 | [diff] [blame] | 257 | openpic_irqs = g_new0(IrqLines, machine->smp.cpus); |
BALATON Zoltan | 18e0383 | 2022-10-28 13:56:22 +0200 | [diff] [blame] | 258 | dev = DEVICE(cpu); |
BALATON Zoltan | cc4a140 | 2022-10-28 13:56:17 +0200 | [diff] [blame] | 259 | for (i = 0; i < machine->smp.cpus; i++) { |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 260 | /* Mac99 IRQ connection between OpenPIC outputs pins |
| 261 | * and PowerPC input pins |
| 262 | */ |
| 263 | switch (PPC_INPUT(env)) { |
| 264 | case PPC_FLAGS_INPUT_6xx: |
Greg Kurz | 9929301 | 2018-11-27 14:06:22 +0100 | [diff] [blame] | 265 | openpic_irqs[i].irq[OPENPIC_OUTPUT_INT] = |
BALATON Zoltan | 18e0383 | 2022-10-28 13:56:22 +0200 | [diff] [blame] | 266 | qdev_get_gpio_in(dev, PPC6xx_INPUT_INT); |
Greg Kurz | 9929301 | 2018-11-27 14:06:22 +0100 | [diff] [blame] | 267 | openpic_irqs[i].irq[OPENPIC_OUTPUT_CINT] = |
BALATON Zoltan | 18e0383 | 2022-10-28 13:56:22 +0200 | [diff] [blame] | 268 | qdev_get_gpio_in(dev, PPC6xx_INPUT_INT); |
Greg Kurz | 9929301 | 2018-11-27 14:06:22 +0100 | [diff] [blame] | 269 | openpic_irqs[i].irq[OPENPIC_OUTPUT_MCK] = |
BALATON Zoltan | 18e0383 | 2022-10-28 13:56:22 +0200 | [diff] [blame] | 270 | qdev_get_gpio_in(dev, PPC6xx_INPUT_MCP); |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 271 | /* Not connected ? */ |
Greg Kurz | 9929301 | 2018-11-27 14:06:22 +0100 | [diff] [blame] | 272 | openpic_irqs[i].irq[OPENPIC_OUTPUT_DEBUG] = NULL; |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 273 | /* Check this */ |
Greg Kurz | 9929301 | 2018-11-27 14:06:22 +0100 | [diff] [blame] | 274 | openpic_irqs[i].irq[OPENPIC_OUTPUT_RESET] = |
BALATON Zoltan | 18e0383 | 2022-10-28 13:56:22 +0200 | [diff] [blame] | 275 | qdev_get_gpio_in(dev, PPC6xx_INPUT_HRESET); |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 276 | break; |
| 277 | #if defined(TARGET_PPC64) |
| 278 | case PPC_FLAGS_INPUT_970: |
Greg Kurz | 9929301 | 2018-11-27 14:06:22 +0100 | [diff] [blame] | 279 | openpic_irqs[i].irq[OPENPIC_OUTPUT_INT] = |
BALATON Zoltan | 18e0383 | 2022-10-28 13:56:22 +0200 | [diff] [blame] | 280 | qdev_get_gpio_in(dev, PPC970_INPUT_INT); |
Greg Kurz | 9929301 | 2018-11-27 14:06:22 +0100 | [diff] [blame] | 281 | openpic_irqs[i].irq[OPENPIC_OUTPUT_CINT] = |
BALATON Zoltan | 18e0383 | 2022-10-28 13:56:22 +0200 | [diff] [blame] | 282 | qdev_get_gpio_in(dev, PPC970_INPUT_INT); |
Greg Kurz | 9929301 | 2018-11-27 14:06:22 +0100 | [diff] [blame] | 283 | openpic_irqs[i].irq[OPENPIC_OUTPUT_MCK] = |
BALATON Zoltan | 18e0383 | 2022-10-28 13:56:22 +0200 | [diff] [blame] | 284 | qdev_get_gpio_in(dev, PPC970_INPUT_MCP); |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 285 | /* Not connected ? */ |
Greg Kurz | 9929301 | 2018-11-27 14:06:22 +0100 | [diff] [blame] | 286 | openpic_irqs[i].irq[OPENPIC_OUTPUT_DEBUG] = NULL; |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 287 | /* Check this */ |
Greg Kurz | 9929301 | 2018-11-27 14:06:22 +0100 | [diff] [blame] | 288 | openpic_irqs[i].irq[OPENPIC_OUTPUT_RESET] = |
BALATON Zoltan | 18e0383 | 2022-10-28 13:56:22 +0200 | [diff] [blame] | 289 | qdev_get_gpio_in(dev, PPC970_INPUT_HRESET); |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 290 | break; |
| 291 | #endif /* defined(TARGET_PPC64) */ |
| 292 | default: |
Markus Armbruster | c525436 | 2015-12-17 17:35:09 +0100 | [diff] [blame] | 293 | error_report("Bus model not supported on mac99 machine"); |
j_mayer | dd37a5e | 2007-04-16 07:41:07 +0000 | [diff] [blame] | 294 | exit(1); |
| 295 | } |
bellard | 6420120 | 2004-05-26 22:55:16 +0000 | [diff] [blame] | 296 | } |
Alexander Graf | d0b7263 | 2012-12-08 05:17:14 +0100 | [diff] [blame] | 297 | |
BALATON Zoltan | 50c496d27 | 2022-10-28 13:56:21 +0200 | [diff] [blame] | 298 | /* UniN init */ |
| 299 | s = SYS_BUS_DEVICE(qdev_new(TYPE_UNI_NORTH)); |
| 300 | sysbus_realize_and_unref(s, &error_fatal); |
| 301 | memory_region_add_subregion(get_system_memory(), 0xf8000000, |
| 302 | sysbus_mmio_get_region(s, 0)); |
| 303 | |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 304 | if (PPC_INPUT(env) == PPC_FLAGS_INPUT_970) { |
BALATON Zoltan | 50c496d27 | 2022-10-28 13:56:21 +0200 | [diff] [blame] | 305 | machine_arch = ARCH_MAC99_U3; |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 306 | /* 970 gets a U3 bus */ |
Mark Cave-Ayland | 8ce3f74 | 2018-03-06 20:30:57 +0000 | [diff] [blame] | 307 | /* Uninorth AGP bus */ |
BALATON Zoltan | 18e0383 | 2022-10-28 13:56:22 +0200 | [diff] [blame] | 308 | uninorth_pci_dev = qdev_new(TYPE_U3_AGP_HOST_BRIDGE); |
| 309 | s = SYS_BUS_DEVICE(uninorth_pci_dev); |
BALATON Zoltan | 50c496d27 | 2022-10-28 13:56:21 +0200 | [diff] [blame] | 310 | sysbus_realize_and_unref(s, &error_fatal); |
| 311 | sysbus_mmio_map(s, 0, 0xf0800000); |
| 312 | sysbus_mmio_map(s, 1, 0xf0c00000); |
Mark Cave-Ayland | 8ce3f74 | 2018-03-06 20:30:57 +0000 | [diff] [blame] | 313 | /* PCI hole */ |
BALATON Zoltan | 50c496d27 | 2022-10-28 13:56:21 +0200 | [diff] [blame] | 314 | memory_region_add_subregion(get_system_memory(), 0x80000000, |
Mark Cave-Ayland | 8ce3f74 | 2018-03-06 20:30:57 +0000 | [diff] [blame] | 315 | sysbus_mmio_get_region(s, 2)); |
Mark Cave-Ayland | e226efb | 2018-03-06 20:30:59 +0000 | [diff] [blame] | 316 | /* Register 8 MB of ISA IO space */ |
| 317 | memory_region_add_subregion(get_system_memory(), 0xf2000000, |
| 318 | sysbus_mmio_get_region(s, 3)); |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 319 | } else { |
BALATON Zoltan | 50c496d27 | 2022-10-28 13:56:21 +0200 | [diff] [blame] | 320 | machine_arch = ARCH_MAC99; |
Mark Cave-Ayland | 7b19318 | 2018-03-06 20:30:56 +0000 | [diff] [blame] | 321 | /* Use values found on a real PowerMac */ |
| 322 | /* Uninorth AGP bus */ |
Mark Cave-Ayland | 6ce97b2 | 2020-12-29 17:56:16 +0000 | [diff] [blame] | 323 | uninorth_agp_dev = qdev_new(TYPE_UNI_NORTH_AGP_HOST_BRIDGE); |
| 324 | s = SYS_BUS_DEVICE(uninorth_agp_dev); |
Markus Armbruster | 3c6ef47 | 2020-06-10 07:32:34 +0200 | [diff] [blame] | 325 | sysbus_realize_and_unref(s, &error_fatal); |
Mark Cave-Ayland | 7b19318 | 2018-03-06 20:30:56 +0000 | [diff] [blame] | 326 | sysbus_mmio_map(s, 0, 0xf0800000); |
| 327 | sysbus_mmio_map(s, 1, 0xf0c00000); |
| 328 | |
| 329 | /* Uninorth internal bus */ |
Mark Cave-Ayland | 6ce97b2 | 2020-12-29 17:56:16 +0000 | [diff] [blame] | 330 | uninorth_internal_dev = qdev_new( |
| 331 | TYPE_UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE); |
| 332 | s = SYS_BUS_DEVICE(uninorth_internal_dev); |
Markus Armbruster | 3c6ef47 | 2020-06-10 07:32:34 +0200 | [diff] [blame] | 333 | sysbus_realize_and_unref(s, &error_fatal); |
Mark Cave-Ayland | 7b19318 | 2018-03-06 20:30:56 +0000 | [diff] [blame] | 334 | sysbus_mmio_map(s, 0, 0xf4800000); |
| 335 | sysbus_mmio_map(s, 1, 0xf4c00000); |
| 336 | |
BALATON Zoltan | 50c496d27 | 2022-10-28 13:56:21 +0200 | [diff] [blame] | 337 | /* Uninorth main bus - this must be last to make it the default */ |
BALATON Zoltan | 18e0383 | 2022-10-28 13:56:22 +0200 | [diff] [blame] | 338 | uninorth_pci_dev = qdev_new(TYPE_UNI_NORTH_PCI_HOST_BRIDGE); |
| 339 | qdev_prop_set_uint32(uninorth_pci_dev, "ofw-addr", 0xf2000000); |
| 340 | s = SYS_BUS_DEVICE(uninorth_pci_dev); |
BALATON Zoltan | 50c496d27 | 2022-10-28 13:56:21 +0200 | [diff] [blame] | 341 | sysbus_realize_and_unref(s, &error_fatal); |
| 342 | sysbus_mmio_map(s, 0, 0xf2800000); |
| 343 | sysbus_mmio_map(s, 1, 0xf2c00000); |
Mark Cave-Ayland | 7b19318 | 2018-03-06 20:30:56 +0000 | [diff] [blame] | 344 | /* PCI hole */ |
BALATON Zoltan | 50c496d27 | 2022-10-28 13:56:21 +0200 | [diff] [blame] | 345 | memory_region_add_subregion(get_system_memory(), 0x80000000, |
Mark Cave-Ayland | 7b19318 | 2018-03-06 20:30:56 +0000 | [diff] [blame] | 346 | sysbus_mmio_get_region(s, 2)); |
Mark Cave-Ayland | e226efb | 2018-03-06 20:30:59 +0000 | [diff] [blame] | 347 | /* Register 8 MB of ISA IO space */ |
| 348 | memory_region_add_subregion(get_system_memory(), 0xf2000000, |
| 349 | sysbus_mmio_get_region(s, 3)); |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 350 | } |
Alexander Graf | caae6c9 | 2014-07-13 22:29:02 +0200 | [diff] [blame] | 351 | |
Alexander Graf | 72f1f97 | 2015-11-11 22:49:41 +0000 | [diff] [blame] | 352 | machine->usb |= defaults_enabled() && !machine->usb_disabled; |
Mark Cave-Ayland | f1114c1 | 2018-06-12 17:43:57 +0100 | [diff] [blame] | 353 | has_pmu = (core99_machine->via_config != CORE99_VIA_CONFIG_CUDA); |
| 354 | has_adb = (core99_machine->via_config == CORE99_VIA_CONFIG_CUDA || |
| 355 | core99_machine->via_config == CORE99_VIA_CONFIG_PMU_ADB); |
Alexander Graf | 72f1f97 | 2015-11-11 22:49:41 +0000 | [diff] [blame] | 356 | |
Mark Cave-Ayland | 0f4b541 | 2018-03-06 20:30:50 +0000 | [diff] [blame] | 357 | /* init basic PC hardware */ |
BALATON Zoltan | 18e0383 | 2022-10-28 13:56:22 +0200 | [diff] [blame] | 358 | pci_bus = PCI_HOST_BRIDGE(uninorth_pci_dev)->bus; |
Mark Cave-Ayland | 0f4b541 | 2018-03-06 20:30:50 +0000 | [diff] [blame] | 359 | |
Mark Cave-Ayland | 343bd85 | 2018-02-28 20:32:33 +0000 | [diff] [blame] | 360 | /* MacIO */ |
BALATON Zoltan | 18e0383 | 2022-10-28 13:56:22 +0200 | [diff] [blame] | 361 | macio = OBJECT(pci_new(-1, TYPE_NEWWORLD_MACIO)); |
Andreas Färber | 07a7484 | 2013-01-23 23:04:01 +0000 | [diff] [blame] | 362 | dev = DEVICE(macio); |
Alexander Graf | b981289 | 2014-07-13 22:31:53 +0200 | [diff] [blame] | 363 | qdev_prop_set_uint64(dev, "frequency", tbfreq); |
Mark Cave-Ayland | f1114c1 | 2018-06-12 17:43:57 +0100 | [diff] [blame] | 364 | qdev_prop_set_bit(dev, "has-pmu", has_pmu); |
| 365 | qdev_prop_set_bit(dev, "has-adb", has_adb); |
Mark Cave-Ayland | 348b8d1 | 2020-10-13 12:49:20 +0100 | [diff] [blame] | 366 | |
BALATON Zoltan | 18e0383 | 2022-10-28 13:56:22 +0200 | [diff] [blame] | 367 | dev = DEVICE(object_resolve_path_component(macio, "escc")); |
| 368 | qdev_prop_set_chr(dev, "chrA", serial_hd(0)); |
| 369 | qdev_prop_set_chr(dev, "chrB", serial_hd(1)); |
Mark Cave-Ayland | 348b8d1 | 2020-10-13 12:49:20 +0100 | [diff] [blame] | 370 | |
BALATON Zoltan | 18e0383 | 2022-10-28 13:56:22 +0200 | [diff] [blame] | 371 | pci_realize_and_unref(PCI_DEVICE(macio), pci_bus, &error_fatal); |
Andreas Färber | 07a7484 | 2013-01-23 23:04:01 +0000 | [diff] [blame] | 372 | |
BALATON Zoltan | 18e0383 | 2022-10-28 13:56:22 +0200 | [diff] [blame] | 373 | pic_dev = DEVICE(object_resolve_path_component(macio, "pic")); |
Mark Cave-Ayland | 6ce97b2 | 2020-12-29 17:56:16 +0000 | [diff] [blame] | 374 | for (i = 0; i < 4; i++) { |
BALATON Zoltan | 18e0383 | 2022-10-28 13:56:22 +0200 | [diff] [blame] | 375 | qdev_connect_gpio_out(uninorth_pci_dev, i, |
Mark Cave-Ayland | 6ce97b2 | 2020-12-29 17:56:16 +0000 | [diff] [blame] | 376 | qdev_get_gpio_in(pic_dev, 0x1b + i)); |
| 377 | } |
| 378 | |
| 379 | /* TODO: additional PCI buses only wired up for 32-bit machines */ |
| 380 | if (PPC_INPUT(env) != PPC_FLAGS_INPUT_970) { |
| 381 | /* Uninorth AGP bus */ |
| 382 | for (i = 0; i < 4; i++) { |
| 383 | qdev_connect_gpio_out(uninorth_agp_dev, i, |
| 384 | qdev_get_gpio_in(pic_dev, 0x1b + i)); |
| 385 | } |
| 386 | |
| 387 | /* Uninorth internal bus */ |
| 388 | for (i = 0; i < 4; i++) { |
| 389 | qdev_connect_gpio_out(uninorth_internal_dev, i, |
| 390 | qdev_get_gpio_in(pic_dev, 0x1b + i)); |
| 391 | } |
| 392 | } |
| 393 | |
Mark Cave-Ayland | 7e4d62d | 2020-12-29 17:56:17 +0000 | [diff] [blame] | 394 | /* OpenPIC */ |
| 395 | s = SYS_BUS_DEVICE(pic_dev); |
| 396 | k = 0; |
BALATON Zoltan | cc4a140 | 2022-10-28 13:56:17 +0200 | [diff] [blame] | 397 | for (i = 0; i < machine->smp.cpus; i++) { |
Mark Cave-Ayland | 7e4d62d | 2020-12-29 17:56:17 +0000 | [diff] [blame] | 398 | for (j = 0; j < OPENPIC_OUTPUT_NB; j++) { |
| 399 | sysbus_connect_irq(s, k++, openpic_irqs[i].irq[j]); |
| 400 | } |
| 401 | } |
| 402 | g_free(openpic_irqs); |
| 403 | |
Andreas Färber | 07a7484 | 2013-01-23 23:04:01 +0000 | [diff] [blame] | 404 | /* We only emulate 2 out of 3 IDE controllers for now */ |
John Snow | d8f94e1 | 2014-10-01 14:19:27 -0400 | [diff] [blame] | 405 | ide_drive_get(hd, ARRAY_SIZE(hd)); |
BALATON Zoltan | a0bb2a5 | 2014-06-24 00:03:48 +0200 | [diff] [blame] | 406 | |
BALATON Zoltan | 18e0383 | 2022-10-28 13:56:22 +0200 | [diff] [blame] | 407 | macio_ide = MACIO_IDE(object_resolve_path_component(macio, "ide[0]")); |
Andreas Färber | 07a7484 | 2013-01-23 23:04:01 +0000 | [diff] [blame] | 408 | macio_ide_init_drives(macio_ide, hd); |
| 409 | |
BALATON Zoltan | 18e0383 | 2022-10-28 13:56:22 +0200 | [diff] [blame] | 410 | macio_ide = MACIO_IDE(object_resolve_path_component(macio, "ide[1]")); |
Andreas Färber | 07a7484 | 2013-01-23 23:04:01 +0000 | [diff] [blame] | 411 | macio_ide_init_drives(macio_ide, &hd[MAX_IDE_DEVS]); |
pbrook | 0d92ed3 | 2006-05-21 16:30:15 +0000 | [diff] [blame] | 412 | |
Mark Cave-Ayland | f1114c1 | 2018-06-12 17:43:57 +0100 | [diff] [blame] | 413 | if (has_adb) { |
Mark Cave-Ayland | d811d61 | 2018-06-12 17:44:02 +0100 | [diff] [blame] | 414 | if (has_pmu) { |
BALATON Zoltan | 18e0383 | 2022-10-28 13:56:22 +0200 | [diff] [blame] | 415 | dev = DEVICE(object_resolve_path_component(macio, "pmu")); |
Mark Cave-Ayland | d811d61 | 2018-06-12 17:44:02 +0100 | [diff] [blame] | 416 | } else { |
BALATON Zoltan | 18e0383 | 2022-10-28 13:56:22 +0200 | [diff] [blame] | 417 | dev = DEVICE(object_resolve_path_component(macio, "cuda")); |
Mark Cave-Ayland | d811d61 | 2018-06-12 17:44:02 +0100 | [diff] [blame] | 418 | } |
| 419 | |
Mark Cave-Ayland | f1114c1 | 2018-06-12 17:43:57 +0100 | [diff] [blame] | 420 | adb_bus = qdev_get_child_bus(dev, "adb.0"); |
Markus Armbruster | 3e80f69 | 2020-06-10 07:31:58 +0200 | [diff] [blame] | 421 | dev = qdev_new(TYPE_ADB_KEYBOARD); |
Markus Armbruster | 3e80f69 | 2020-06-10 07:31:58 +0200 | [diff] [blame] | 422 | qdev_realize_and_unref(dev, adb_bus, &error_fatal); |
Mark Cave-Ayland | d811d61 | 2018-06-12 17:44:02 +0100 | [diff] [blame] | 423 | |
Markus Armbruster | 3e80f69 | 2020-06-10 07:31:58 +0200 | [diff] [blame] | 424 | dev = qdev_new(TYPE_ADB_MOUSE); |
Markus Armbruster | 3e80f69 | 2020-06-10 07:31:58 +0200 | [diff] [blame] | 425 | qdev_realize_and_unref(dev, adb_bus, &error_fatal); |
Mark Cave-Ayland | f1114c1 | 2018-06-12 17:43:57 +0100 | [diff] [blame] | 426 | } |
Andreas Färber | 45fa67f | 2013-01-23 23:04:02 +0000 | [diff] [blame] | 427 | |
Marcel Apfelbaum | 59a0419 | 2015-01-06 15:29:17 +0200 | [diff] [blame] | 428 | if (machine->usb) { |
Gerd Hoffmann | afb9a60 | 2012-03-07 15:06:32 +0100 | [diff] [blame] | 429 | pci_create_simple(pci_bus, -1, "pci-ohci"); |
Markus Armbruster | c86580b | 2015-02-04 13:28:14 +0100 | [diff] [blame] | 430 | |
zhlcindy@gmail.com | 094b287 | 2012-09-02 19:25:28 +0000 | [diff] [blame] | 431 | /* U3 needs to use USB for input because Linux doesn't support via-cuda |
| 432 | on PPC64 */ |
Mark Cave-Ayland | f1114c1 | 2018-06-12 17:43:57 +0100 | [diff] [blame] | 433 | if (!has_adb || machine_arch == ARCH_MAC99_U3) { |
Paolo Bonzini | 2dd2f2e | 2024-02-23 13:44:02 +0100 | [diff] [blame] | 434 | USBBus *usb_bus; |
Markus Armbruster | c86580b | 2015-02-04 13:28:14 +0100 | [diff] [blame] | 435 | |
Paolo Bonzini | 2dd2f2e | 2024-02-23 13:44:02 +0100 | [diff] [blame] | 436 | usb_bus = USB_BUS(object_resolve_type_unambiguous(TYPE_USB_BUS, |
| 437 | &error_abort)); |
Markus Armbruster | c86580b | 2015-02-04 13:28:14 +0100 | [diff] [blame] | 438 | usb_create_simple(usb_bus, "usb-kbd"); |
| 439 | usb_create_simple(usb_bus, "usb-mouse"); |
zhlcindy@gmail.com | 094b287 | 2012-09-02 19:25:28 +0000 | [diff] [blame] | 440 | } |
Alexander Graf | a2236d4 | 2010-02-09 17:37:08 +0100 | [diff] [blame] | 441 | } |
| 442 | |
BALATON Zoltan | a0bb2a5 | 2014-06-24 00:03:48 +0200 | [diff] [blame] | 443 | pci_vga_init(pci_bus); |
| 444 | |
| 445 | if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8) { |
bellard | b6b8bd1 | 2004-06-21 16:55:53 +0000 | [diff] [blame] | 446 | graphic_depth = 15; |
BALATON Zoltan | a0bb2a5 | 2014-06-24 00:03:48 +0200 | [diff] [blame] | 447 | } |
| 448 | |
David Woodhouse | 36b6968 | 2023-10-23 09:37:19 +0100 | [diff] [blame] | 449 | pci_init_nic_devices(pci_bus, mc->default_nic); |
blueswir1 | 4f3f238 | 2009-02-08 16:01:01 +0000 | [diff] [blame] | 450 | |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 451 | /* The NewWorld NVRAM is not located in the MacIO device */ |
Marc-André Lureau | 8e3b0cb | 2022-03-23 19:57:22 +0400 | [diff] [blame] | 452 | if (kvm_enabled() && qemu_real_host_page_size() > 4096) { |
Alexander Graf | 261265c | 2014-07-11 03:24:39 +0200 | [diff] [blame] | 453 | /* We can't combine read-write and read-only in a single page, so |
| 454 | move the NVRAM out of ROM again for KVM */ |
| 455 | nvram_addr = 0xFFE00000; |
| 456 | } |
Markus Armbruster | 3e80f69 | 2020-06-10 07:31:58 +0200 | [diff] [blame] | 457 | dev = qdev_new(TYPE_MACIO_NVRAM); |
BALATON Zoltan | 458586f | 2022-10-28 13:56:28 +0200 | [diff] [blame] | 458 | qdev_prop_set_uint32(dev, "size", MACIO_NVRAM_SIZE); |
Andreas Färber | 95ed3b7 | 2013-01-23 23:04:00 +0000 | [diff] [blame] | 459 | qdev_prop_set_uint32(dev, "it_shift", 1); |
Markus Armbruster | 3c6ef47 | 2020-06-10 07:32:34 +0200 | [diff] [blame] | 460 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); |
Alexander Graf | 261265c | 2014-07-11 03:24:39 +0200 | [diff] [blame] | 461 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, nvram_addr); |
Andreas Färber | 95ed3b7 | 2013-01-23 23:04:00 +0000 | [diff] [blame] | 462 | nvr = MACIO_NVRAM(dev); |
BALATON Zoltan | 458586f | 2022-10-28 13:56:28 +0200 | [diff] [blame] | 463 | pmac_format_nvram_partition(nvr, MACIO_NVRAM_SIZE); |
bellard | b6b8bd1 | 2004-06-21 16:55:53 +0000 | [diff] [blame] | 464 | /* No PCI init: the BIOS will do it */ |
bellard | 0aa6a4a | 2005-06-05 15:11:17 +0000 | [diff] [blame] | 465 | |
Markus Armbruster | 3e80f69 | 2020-06-10 07:31:58 +0200 | [diff] [blame] | 466 | dev = qdev_new(TYPE_FW_CFG_MEM); |
Mark Cave-Ayland | 74887ed | 2018-08-10 11:27:57 +0100 | [diff] [blame] | 467 | fw_cfg = FW_CFG(dev); |
| 468 | qdev_prop_set_uint32(dev, "data_width", 1); |
| 469 | qdev_prop_set_bit(dev, "dma_enabled", false); |
BALATON Zoltan | 4db4847 | 2023-01-04 22:59:37 +0100 | [diff] [blame] | 470 | object_property_add_child(OBJECT(machine), TYPE_FW_CFG, OBJECT(fw_cfg)); |
Mark Cave-Ayland | 74887ed | 2018-08-10 11:27:57 +0100 | [diff] [blame] | 471 | s = SYS_BUS_DEVICE(dev); |
Markus Armbruster | 3c6ef47 | 2020-06-10 07:32:34 +0200 | [diff] [blame] | 472 | sysbus_realize_and_unref(s, &error_fatal); |
Mark Cave-Ayland | 74887ed | 2018-08-10 11:27:57 +0100 | [diff] [blame] | 473 | sysbus_mmio_map(s, 0, CFG_ADDR); |
| 474 | sysbus_mmio_map(s, 1, CFG_ADDR + 2); |
| 475 | |
BALATON Zoltan | cc4a140 | 2022-10-28 13:56:17 +0200 | [diff] [blame] | 476 | fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, (uint16_t)machine->smp.cpus); |
Like Xu | fe6b634 | 2019-05-19 04:54:22 +0800 | [diff] [blame] | 477 | fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)machine->smp.max_cpus); |
BALATON Zoltan | cc4a140 | 2022-10-28 13:56:17 +0200 | [diff] [blame] | 478 | fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)machine->ram_size); |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 479 | fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, machine_arch); |
blueswir1 | 513f789 | 2009-03-08 09:51:29 +0000 | [diff] [blame] | 480 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base); |
| 481 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); |
BALATON Zoltan | cc4a140 | 2022-10-28 13:56:17 +0200 | [diff] [blame] | 482 | if (machine->kernel_cmdline) { |
Alexander Graf | b9e17a3 | 2011-06-15 23:27:19 +0200 | [diff] [blame] | 483 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, cmdline_base); |
BALATON Zoltan | cc4a140 | 2022-10-28 13:56:17 +0200 | [diff] [blame] | 484 | pstrcpy_targphys("cmdline", cmdline_base, TARGET_PAGE_SIZE, |
| 485 | machine->kernel_cmdline); |
blueswir1 | 513f789 | 2009-03-08 09:51:29 +0000 | [diff] [blame] | 486 | } else { |
| 487 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0); |
| 488 | } |
| 489 | fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_base); |
| 490 | fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); |
| 491 | fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ppc_boot_device); |
Blue Swirl | 10696b4 | 2009-08-08 10:47:15 +0000 | [diff] [blame] | 492 | |
| 493 | fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, graphic_width); |
| 494 | fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height); |
| 495 | fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth); |
| 496 | |
Mark Cave-Ayland | f1114c1 | 2018-06-12 17:43:57 +0100 | [diff] [blame] | 497 | fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_VIACONFIG, core99_machine->via_config); |
| 498 | |
Alexander Graf | 45024f0 | 2010-08-03 15:22:42 +0200 | [diff] [blame] | 499 | fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled()); |
Alexander Graf | dc333cd | 2010-02-09 17:37:05 +0100 | [diff] [blame] | 500 | if (kvm_enabled()) { |
Alexander Graf | 45024f0 | 2010-08-03 15:22:42 +0200 | [diff] [blame] | 501 | uint8_t *hypercall; |
| 502 | |
Anthony Liguori | 7267c09 | 2011-08-20 22:09:37 -0500 | [diff] [blame] | 503 | hypercall = g_malloc(16); |
Alexander Graf | 45024f0 | 2010-08-03 15:22:42 +0200 | [diff] [blame] | 504 | kvmppc_get_hypercall(env, hypercall, 16); |
| 505 | fw_cfg_add_bytes(fw_cfg, FW_CFG_PPC_KVM_HC, hypercall, 16); |
| 506 | fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_KVM_PID, getpid()); |
Alexander Graf | dc333cd | 2010-02-09 17:37:05 +0100 | [diff] [blame] | 507 | } |
Alexander Graf | caae6c9 | 2014-07-13 22:29:02 +0200 | [diff] [blame] | 508 | fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, tbfreq); |
Alexander Graf | a1014f2 | 2013-06-23 00:22:50 +0200 | [diff] [blame] | 509 | /* Mac OS X requires a "known good" clock-frequency value; pass it one. */ |
BALATON Zoltan | 9d1c128 | 2014-04-17 19:04:44 +0200 | [diff] [blame] | 510 | fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_CLOCKFREQ, CLOCKFREQ); |
| 511 | fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_BUSFREQ, BUSFREQ); |
Alexander Graf | 261265c | 2014-07-11 03:24:39 +0200 | [diff] [blame] | 512 | fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_NVRAM_ADDR, nvram_addr); |
Alexander Graf | dc333cd | 2010-02-09 17:37:05 +0100 | [diff] [blame] | 513 | |
Mark Cave-Ayland | 53ecf09 | 2017-05-01 14:43:33 +0100 | [diff] [blame] | 514 | /* MacOS NDRV VGA driver */ |
| 515 | filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, NDRV_VGA_FILENAME); |
| 516 | if (filename) { |
Peter Maydell | 9776874 | 2018-12-14 13:30:50 +0000 | [diff] [blame] | 517 | gchar *ndrv_file; |
| 518 | gsize ndrv_size; |
Mark Cave-Ayland | 53ecf09 | 2017-05-01 14:43:33 +0100 | [diff] [blame] | 519 | |
Peter Maydell | 9776874 | 2018-12-14 13:30:50 +0000 | [diff] [blame] | 520 | if (g_file_get_contents(filename, &ndrv_file, &ndrv_size, NULL)) { |
Mark Cave-Ayland | 53ecf09 | 2017-05-01 14:43:33 +0100 | [diff] [blame] | 521 | fw_cfg_add_file(fw_cfg, "ndrv/qemu_vga.ndrv", ndrv_file, ndrv_size); |
| 522 | } |
| 523 | g_free(filename); |
| 524 | } |
| 525 | |
blueswir1 | 513f789 | 2009-03-08 09:51:29 +0000 | [diff] [blame] | 526 | qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); |
j_mayer | aae9366 | 2007-11-24 02:56:36 +0000 | [diff] [blame] | 527 | } |
bellard | 0aa6a4a | 2005-06-05 15:11:17 +0000 | [diff] [blame] | 528 | |
Mark Cave-Ayland | 5d19be6 | 2018-08-29 17:59:11 +0100 | [diff] [blame] | 529 | /* |
| 530 | * Implementation of an interface to adjust firmware path |
| 531 | * for the bootindex property handling. |
| 532 | */ |
| 533 | static char *core99_fw_dev_path(FWPathProvider *p, BusState *bus, |
| 534 | DeviceState *dev) |
| 535 | { |
| 536 | PCIDevice *pci; |
Mark Cave-Ayland | 5d19be6 | 2018-08-29 17:59:11 +0100 | [diff] [blame] | 537 | MACIOIDEState *macio_ide; |
| 538 | |
| 539 | if (!strcmp(object_get_typename(OBJECT(dev)), "macio-newworld")) { |
| 540 | pci = PCI_DEVICE(dev); |
| 541 | return g_strdup_printf("mac-io@%x", PCI_SLOT(pci->devfn)); |
| 542 | } |
| 543 | |
| 544 | if (!strcmp(object_get_typename(OBJECT(dev)), "macio-ide")) { |
| 545 | macio_ide = MACIO_IDE(dev); |
| 546 | return g_strdup_printf("ata-3@%x", macio_ide->addr); |
| 547 | } |
| 548 | |
Mark Cave-Ayland | 5d19be6 | 2018-08-29 17:59:11 +0100 | [diff] [blame] | 549 | if (!strcmp(object_get_typename(OBJECT(dev)), "ide-hd")) { |
Mark Cave-Ayland | 31bc6fa | 2019-03-07 21:20:58 +0000 | [diff] [blame] | 550 | return g_strdup("disk"); |
Mark Cave-Ayland | 5d19be6 | 2018-08-29 17:59:11 +0100 | [diff] [blame] | 551 | } |
| 552 | |
| 553 | if (!strcmp(object_get_typename(OBJECT(dev)), "ide-cd")) { |
| 554 | return g_strdup("cdrom"); |
| 555 | } |
| 556 | |
| 557 | if (!strcmp(object_get_typename(OBJECT(dev)), "virtio-blk-device")) { |
| 558 | return g_strdup("disk"); |
| 559 | } |
| 560 | |
| 561 | return NULL; |
| 562 | } |
Eric Auger | dc0ca80 | 2019-03-04 11:13:33 +0100 | [diff] [blame] | 563 | static int core99_kvm_type(MachineState *machine, const char *arg) |
Alexander Graf | 277c7a4 | 2014-07-24 10:46:47 +0200 | [diff] [blame] | 564 | { |
| 565 | /* Always force PR KVM */ |
| 566 | return 2; |
| 567 | } |
| 568 | |
Marcel Apfelbaum | b1c2fb9 | 2015-01-06 15:29:15 +0200 | [diff] [blame] | 569 | static void core99_machine_class_init(ObjectClass *oc, void *data) |
Anthony Liguori | f80f9ec | 2009-05-20 18:38:09 -0500 | [diff] [blame] | 570 | { |
Marcel Apfelbaum | b1c2fb9 | 2015-01-06 15:29:15 +0200 | [diff] [blame] | 571 | MachineClass *mc = MACHINE_CLASS(oc); |
Mark Cave-Ayland | 5d19be6 | 2018-08-29 17:59:11 +0100 | [diff] [blame] | 572 | FWPathProviderClass *fwc = FW_PATH_PROVIDER_CLASS(oc); |
Marcel Apfelbaum | b1c2fb9 | 2015-01-06 15:29:15 +0200 | [diff] [blame] | 573 | |
Tejas Vipin | 9d906ad | 2024-08-05 12:31:50 +0530 | [diff] [blame] | 574 | mc->desc = "Mac99 based PowerMac"; |
Marcel Apfelbaum | b1c2fb9 | 2015-01-06 15:29:15 +0200 | [diff] [blame] | 575 | mc->init = ppc_core99_init; |
Markus Armbruster | 2059839 | 2017-02-15 11:05:40 +0100 | [diff] [blame] | 576 | mc->block_default_type = IF_IDE; |
Peter Maydell | 83234b8 | 2021-12-17 17:57:12 +0100 | [diff] [blame] | 577 | /* SMP is not supported currently */ |
| 578 | mc->max_cpus = 1; |
Marcel Apfelbaum | b1c2fb9 | 2015-01-06 15:29:15 +0200 | [diff] [blame] | 579 | mc->default_boot_order = "cd"; |
Mark Cave-Ayland | 3232794 | 2018-07-03 20:10:43 +0100 | [diff] [blame] | 580 | mc->default_display = "std"; |
Thomas Huth | 053b708 | 2023-05-12 14:40:20 +0200 | [diff] [blame] | 581 | mc->default_nic = "sungem"; |
Marcel Apfelbaum | b1c2fb9 | 2015-01-06 15:29:15 +0200 | [diff] [blame] | 582 | mc->kvm_type = core99_kvm_type; |
Igor Mammedov | 9dff4c0 | 2017-10-09 21:50:52 +0200 | [diff] [blame] | 583 | #ifdef TARGET_PPC64 |
| 584 | mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("970fx_v3.1"); |
| 585 | #else |
| 586 | mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("7400_v2.9"); |
| 587 | #endif |
Igor Mammedov | a5b5de0 | 2020-02-19 11:09:34 -0500 | [diff] [blame] | 588 | mc->default_ram_id = "ppc_core99.ram"; |
Mark Cave-Ayland | 5d19be6 | 2018-08-29 17:59:11 +0100 | [diff] [blame] | 589 | mc->ignore_boot_device_suffixes = true; |
| 590 | fwc->get_dev_path = core99_fw_dev_path; |
Anthony Liguori | f80f9ec | 2009-05-20 18:38:09 -0500 | [diff] [blame] | 591 | } |
| 592 | |
Mark Cave-Ayland | f1114c1 | 2018-06-12 17:43:57 +0100 | [diff] [blame] | 593 | static char *core99_get_via_config(Object *obj, Error **errp) |
| 594 | { |
| 595 | Core99MachineState *cms = CORE99_MACHINE(obj); |
| 596 | |
| 597 | switch (cms->via_config) { |
| 598 | default: |
| 599 | case CORE99_VIA_CONFIG_CUDA: |
| 600 | return g_strdup("cuda"); |
| 601 | |
| 602 | case CORE99_VIA_CONFIG_PMU: |
| 603 | return g_strdup("pmu"); |
| 604 | |
| 605 | case CORE99_VIA_CONFIG_PMU_ADB: |
| 606 | return g_strdup("pmu-adb"); |
| 607 | } |
| 608 | } |
| 609 | |
| 610 | static void core99_set_via_config(Object *obj, const char *value, Error **errp) |
| 611 | { |
| 612 | Core99MachineState *cms = CORE99_MACHINE(obj); |
| 613 | |
| 614 | if (!strcmp(value, "cuda")) { |
| 615 | cms->via_config = CORE99_VIA_CONFIG_CUDA; |
| 616 | } else if (!strcmp(value, "pmu")) { |
| 617 | cms->via_config = CORE99_VIA_CONFIG_PMU; |
| 618 | } else if (!strcmp(value, "pmu-adb")) { |
| 619 | cms->via_config = CORE99_VIA_CONFIG_PMU_ADB; |
| 620 | } else { |
| 621 | error_setg(errp, "Invalid via value"); |
| 622 | error_append_hint(errp, "Valid values are cuda, pmu, pmu-adb.\n"); |
| 623 | } |
| 624 | } |
| 625 | |
Mark Cave-Ayland | 06fe3a5 | 2018-06-12 17:43:56 +0100 | [diff] [blame] | 626 | static void core99_instance_init(Object *obj) |
| 627 | { |
Mark Cave-Ayland | f1114c1 | 2018-06-12 17:43:57 +0100 | [diff] [blame] | 628 | Core99MachineState *cms = CORE99_MACHINE(obj); |
| 629 | |
| 630 | /* Default via_config is CORE99_VIA_CONFIG_CUDA */ |
| 631 | cms->via_config = CORE99_VIA_CONFIG_CUDA; |
| 632 | object_property_add_str(obj, "via", core99_get_via_config, |
Markus Armbruster | d262312 | 2020-05-05 17:29:22 +0200 | [diff] [blame] | 633 | core99_set_via_config); |
Mark Cave-Ayland | f1114c1 | 2018-06-12 17:43:57 +0100 | [diff] [blame] | 634 | object_property_set_description(obj, "via", |
| 635 | "Set VIA configuration. " |
Markus Armbruster | 7eecec7 | 2020-05-05 17:29:15 +0200 | [diff] [blame] | 636 | "Valid values are cuda, pmu and pmu-adb"); |
Mark Cave-Ayland | f1114c1 | 2018-06-12 17:43:57 +0100 | [diff] [blame] | 637 | |
Mark Cave-Ayland | 06fe3a5 | 2018-06-12 17:43:56 +0100 | [diff] [blame] | 638 | return; |
| 639 | } |
| 640 | |
Marcel Apfelbaum | b1c2fb9 | 2015-01-06 15:29:15 +0200 | [diff] [blame] | 641 | static const TypeInfo core99_machine_info = { |
Eduardo Habkost | c0f3651 | 2015-08-20 14:54:34 -0700 | [diff] [blame] | 642 | .name = MACHINE_TYPE_NAME("mac99"), |
Marcel Apfelbaum | b1c2fb9 | 2015-01-06 15:29:15 +0200 | [diff] [blame] | 643 | .parent = TYPE_MACHINE, |
| 644 | .class_init = core99_machine_class_init, |
Mark Cave-Ayland | 06fe3a5 | 2018-06-12 17:43:56 +0100 | [diff] [blame] | 645 | .instance_init = core99_instance_init, |
Mark Cave-Ayland | 5d19be6 | 2018-08-29 17:59:11 +0100 | [diff] [blame] | 646 | .instance_size = sizeof(Core99MachineState), |
| 647 | .interfaces = (InterfaceInfo[]) { |
| 648 | { TYPE_FW_PATH_PROVIDER }, |
| 649 | { } |
| 650 | }, |
Marcel Apfelbaum | b1c2fb9 | 2015-01-06 15:29:15 +0200 | [diff] [blame] | 651 | }; |
| 652 | |
| 653 | static void mac_machine_register_types(void) |
| 654 | { |
| 655 | type_register_static(&core99_machine_info); |
| 656 | } |
| 657 | |
| 658 | type_init(mac_machine_register_types) |