]>
Commit | Line | Data |
---|---|---|
ae0bfb79 | 1 | |
3cbee15b | 2 | /* |
4d7ca41e | 3 | * QEMU OldWorld PowerMac (currently ~G3 Beige) hardware System Emulator |
3cbee15b JM |
4 | * |
5 | * Copyright (c) 2004-2007 Fabrice Bellard | |
6 | * Copyright (c) 2007 Jocelyn Mayer | |
7 | * | |
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
9 | * of this software and associated documentation files (the "Software"), to deal | |
10 | * in the Software without restriction, including without limitation the rights | |
11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
12 | * copies of the Software, and to permit persons to whom the Software is | |
13 | * furnished to do so, subject to the following conditions: | |
14 | * | |
15 | * The above copyright notice and this permission notice shall be included in | |
16 | * all copies or substantial portions of the Software. | |
17 | * | |
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
21 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
24 | * THE SOFTWARE. | |
25 | */ | |
a8d25326 | 26 | |
0d75590d | 27 | #include "qemu/osdep.h" |
2c65db5e | 28 | #include "qemu/datadir.h" |
ab3dd749 | 29 | #include "qemu/units.h" |
da34e65c | 30 | #include "qapi/error.h" |
0d09e41a | 31 | #include "hw/ppc/ppc.h" |
a27bd6c7 | 32 | #include "hw/qdev-properties.h" |
baec1910 | 33 | #include "mac.h" |
0d09e41a | 34 | #include "hw/input/adb.h" |
9c17d615 | 35 | #include "sysemu/sysemu.h" |
1422e32d | 36 | #include "net/net.h" |
0d09e41a | 37 | #include "hw/isa/isa.h" |
baec1910 | 38 | #include "hw/pci/pci.h" |
a773e64a | 39 | #include "hw/pci/pci_host.h" |
0d09e41a PB |
40 | #include "hw/nvram/fw_cfg.h" |
41 | #include "hw/char/escc.h" | |
e1218e48 | 42 | #include "hw/misc/macio/macio.h" |
baec1910 | 43 | #include "hw/loader.h" |
bbcc635f | 44 | #include "hw/fw-path-provider.h" |
ca20cf32 | 45 | #include "elf.h" |
c525436e | 46 | #include "qemu/error-report.h" |
9c17d615 | 47 | #include "sysemu/kvm.h" |
71e8a915 | 48 | #include "sysemu/reset.h" |
dc333cd6 | 49 | #include "kvm_ppc.h" |
3cbee15b | 50 | |
e4bcb14c | 51 | #define MAX_IDE_BUS 2 |
271dd5e0 | 52 | #define CFG_ADDR 0xf0000510 |
536d8cda | 53 | #define TBFREQ 16600000UL |
9d1c1283 BZ |
54 | #define CLOCKFREQ 266000000UL |
55 | #define BUSFREQ 66000000UL | |
271dd5e0 | 56 | |
b50de5cd MCA |
57 | #define NDRV_VGA_FILENAME "qemu_vga.ndrv" |
58 | ||
a773e64a | 59 | #define GRACKLE_BASE 0xfec00000 |
464c73e8 BZ |
60 | #define PROM_BASE 0xffc00000 |
61 | #define PROM_SIZE (4 * MiB) | |
a773e64a | 62 | |
ddcd5531 GA |
63 | static void fw_cfg_boot_set(void *opaque, const char *boot_device, |
64 | Error **errp) | |
513f789f | 65 | { |
48779e50 | 66 | fw_cfg_modify_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]); |
513f789f BS |
67 | } |
68 | ||
409dbce5 AJ |
69 | static uint64_t translate_kernel_address(void *opaque, uint64_t addr) |
70 | { | |
71 | return (addr & 0x0fffffff) + KERNEL_LOAD_ADDR; | |
72 | } | |
73 | ||
1bba0dc9 AF |
74 | static void ppc_heathrow_reset(void *opaque) |
75 | { | |
cd79664f | 76 | PowerPCCPU *cpu = opaque; |
1bba0dc9 | 77 | |
cd79664f | 78 | cpu_reset(CPU(cpu)); |
1bba0dc9 AF |
79 | } |
80 | ||
3ef96221 | 81 | static void ppc_heathrow_init(MachineState *machine) |
3cbee15b | 82 | { |
3ef96221 | 83 | ram_addr_t ram_size = machine->ram_size; |
cd7b9498 | 84 | const char *bios_name = machine->firmware ?: PROM_FILENAME; |
3ef96221 | 85 | const char *boot_device = machine->boot_order; |
72c33dd7 | 86 | PowerPCCPU *cpu = NULL; |
e2684c0b | 87 | CPUPPCState *env = NULL; |
5cea8590 | 88 | char *filename; |
b8df3255 | 89 | int i; |
c92bb2c7 | 90 | MemoryRegion *bios = g_new(MemoryRegion, 1); |
b9e17a34 | 91 | uint32_t kernel_base, initrd_base, cmdline_base = 0; |
7373048c | 92 | int32_t kernel_size, initrd_size; |
3cbee15b | 93 | PCIBus *pci_bus; |
7d612261 | 94 | PCIDevice *macio; |
07a7484e | 95 | MACIOIDEState *macio_ide; |
348b8d1a | 96 | ESCCState *escc; |
a773e64a | 97 | SysBusDevice *s; |
370022ce | 98 | DeviceState *dev, *pic_dev, *grackle_dev; |
293c867d | 99 | BusState *adb_bus; |
464c73e8 | 100 | uint64_t bios_addr; |
9776874f | 101 | int bios_size; |
fe6b6346 | 102 | unsigned int smp_cpus = machine->smp.cpus; |
513f789f | 103 | uint16_t ppc_boot_device; |
f455e98c | 104 | DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
271dd5e0 | 105 | void *fw_cfg; |
caae6c96 | 106 | uint64_t tbfreq; |
3cbee15b | 107 | |
3cbee15b | 108 | /* init CPUs */ |
3cbee15b | 109 | for (i = 0; i < smp_cpus; i++) { |
f4c6604e | 110 | cpu = POWERPC_CPU(cpu_create(machine->cpu_type)); |
72c33dd7 AF |
111 | env = &cpu->env; |
112 | ||
b0fb43d8 | 113 | /* Set time-base frequency to 16.6 Mhz */ |
536d8cda | 114 | cpu_ppc_tb_init(env, TBFREQ); |
cd79664f | 115 | qemu_register_reset(ppc_heathrow_reset, cpu); |
3cbee15b JM |
116 | } |
117 | ||
118 | /* allocate RAM */ | |
ab3dd749 PMD |
119 | if (ram_size > 2047 * MiB) { |
120 | error_report("Too much memory for this machine: %" PRId64 " MB, " | |
121 | "maximum 2047 MB", ram_size / MiB); | |
6b4079f8 AJ |
122 | exit(1); |
123 | } | |
124 | ||
c3481ab0 | 125 | memory_region_add_subregion(get_system_memory(), 0, machine->ram); |
a748ab6d | 126 | |
464c73e8 BZ |
127 | /* allocate and load firmware ROM */ |
128 | memory_region_init_rom(bios, NULL, "ppc_heathrow.bios", PROM_SIZE, | |
f8ed85ac | 129 | &error_fatal); |
c3481ab0 | 130 | memory_region_add_subregion(get_system_memory(), PROM_BASE, bios); |
e206ad48 | 131 | |
5cea8590 | 132 | filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); |
5cea8590 | 133 | if (filename) { |
464c73e8 BZ |
134 | /* Load OpenBIOS (ELF) */ |
135 | bios_size = load_elf(filename, NULL, NULL, NULL, NULL, &bios_addr, | |
136 | NULL, NULL, 1, PPC_ELF_MACHINE, 0, 0); | |
137 | /* Unfortunately, load_elf sign-extends reading elf32 */ | |
138 | bios_addr = (uint32_t)bios_addr; | |
139 | ||
140 | if (bios_size <= 0) { | |
b8df3255 | 141 | /* or if could not load ELF try loading a binary ROM image */ |
464c73e8 BZ |
142 | bios_size = load_image_targphys(filename, PROM_BASE, PROM_SIZE); |
143 | bios_addr = PROM_BASE; | |
144 | } | |
7267c094 | 145 | g_free(filename); |
5cea8590 PB |
146 | } else { |
147 | bios_size = -1; | |
148 | } | |
464c73e8 | 149 | if (bios_size < 0 || bios_addr - PROM_BASE + bios_size > PROM_SIZE) { |
c525436e | 150 | error_report("could not load PowerPC bios '%s'", bios_name); |
3cbee15b JM |
151 | exit(1); |
152 | } | |
3cbee15b | 153 | |
b8df3255 | 154 | if (machine->kernel_filename) { |
ca20cf32 BS |
155 | int bswap_needed; |
156 | ||
157 | #ifdef BSWAP_NEEDED | |
158 | bswap_needed = 1; | |
159 | #else | |
160 | bswap_needed = 0; | |
161 | #endif | |
3cbee15b | 162 | kernel_base = KERNEL_LOAD_ADDR; |
b8df3255 | 163 | kernel_size = load_elf(machine->kernel_filename, NULL, |
617160c9 BZ |
164 | translate_kernel_address, NULL, NULL, NULL, |
165 | NULL, NULL, 1, PPC_ELF_MACHINE, 0, 0); | |
52f163b7 | 166 | if (kernel_size < 0) |
b8df3255 | 167 | kernel_size = load_aout(machine->kernel_filename, kernel_base, |
ca20cf32 BS |
168 | ram_size - kernel_base, bswap_needed, |
169 | TARGET_PAGE_SIZE); | |
52f163b7 | 170 | if (kernel_size < 0) |
b8df3255 | 171 | kernel_size = load_image_targphys(machine->kernel_filename, |
52f163b7 BS |
172 | kernel_base, |
173 | ram_size - kernel_base); | |
3cbee15b | 174 | if (kernel_size < 0) { |
b8df3255 BZ |
175 | error_report("could not load kernel '%s'", |
176 | machine->kernel_filename); | |
3cbee15b JM |
177 | exit(1); |
178 | } | |
179 | /* load initrd */ | |
b8df3255 BZ |
180 | if (machine->initrd_filename) { |
181 | initrd_base = TARGET_PAGE_ALIGN(kernel_base + kernel_size + | |
182 | KERNEL_GAP); | |
183 | initrd_size = load_image_targphys(machine->initrd_filename, | |
184 | initrd_base, | |
dcac9679 | 185 | ram_size - initrd_base); |
3cbee15b | 186 | if (initrd_size < 0) { |
c525436e | 187 | error_report("could not load initial ram disk '%s'", |
b8df3255 | 188 | machine->initrd_filename); |
3cbee15b JM |
189 | exit(1); |
190 | } | |
39d96847 | 191 | cmdline_base = TARGET_PAGE_ALIGN(initrd_base + initrd_size); |
3cbee15b JM |
192 | } else { |
193 | initrd_base = 0; | |
194 | initrd_size = 0; | |
39d96847 | 195 | cmdline_base = TARGET_PAGE_ALIGN(kernel_base + kernel_size + KERNEL_GAP); |
3cbee15b | 196 | } |
6ac0e82d | 197 | ppc_boot_device = 'm'; |
3cbee15b JM |
198 | } else { |
199 | kernel_base = 0; | |
200 | kernel_size = 0; | |
201 | initrd_base = 0; | |
202 | initrd_size = 0; | |
28c5af54 | 203 | ppc_boot_device = '\0'; |
0d913fdb | 204 | for (i = 0; boot_device[i] != '\0'; i++) { |
28c5af54 | 205 | /* TOFIX: for now, the second IDE channel is not properly |
0d913fdb | 206 | * used by OHW. The Mac floppy disk are not emulated. |
28c5af54 JM |
207 | * For now, OHW cannot boot from the network. |
208 | */ | |
209 | #if 0 | |
0d913fdb JM |
210 | if (boot_device[i] >= 'a' && boot_device[i] <= 'f') { |
211 | ppc_boot_device = boot_device[i]; | |
28c5af54 | 212 | break; |
0d913fdb | 213 | } |
28c5af54 | 214 | #else |
0d913fdb JM |
215 | if (boot_device[i] >= 'c' && boot_device[i] <= 'd') { |
216 | ppc_boot_device = boot_device[i]; | |
28c5af54 | 217 | break; |
0d913fdb | 218 | } |
28c5af54 JM |
219 | #endif |
220 | } | |
221 | if (ppc_boot_device == '\0') { | |
6f76b817 | 222 | error_report("No valid boot device for G3 Beige machine"); |
28c5af54 JM |
223 | exit(1); |
224 | } | |
3cbee15b JM |
225 | } |
226 | ||
370022ce MCA |
227 | /* Timebase Frequency */ |
228 | if (kvm_enabled()) { | |
229 | tbfreq = kvmppc_get_tbfreq(); | |
230 | } else { | |
231 | tbfreq = TBFREQ; | |
232 | } | |
233 | ||
49ac51ae | 234 | /* Grackle PCI host bridge */ |
370022ce MCA |
235 | grackle_dev = qdev_new(TYPE_GRACKLE_PCI_HOST_BRIDGE); |
236 | qdev_prop_set_uint32(grackle_dev, "ofw-addr", 0x80000000); | |
237 | s = SYS_BUS_DEVICE(grackle_dev); | |
49ac51ae MCA |
238 | sysbus_realize_and_unref(s, &error_fatal); |
239 | ||
240 | sysbus_mmio_map(s, 0, GRACKLE_BASE); | |
241 | sysbus_mmio_map(s, 1, GRACKLE_BASE + 0x200000); | |
242 | /* PCI hole */ | |
243 | memory_region_add_subregion(get_system_memory(), 0x80000000ULL, | |
244 | sysbus_mmio_get_region(s, 2)); | |
245 | /* Register 2 MB of ISA IO space */ | |
246 | memory_region_add_subregion(get_system_memory(), 0xfe000000, | |
247 | sysbus_mmio_get_region(s, 3)); | |
248 | ||
370022ce MCA |
249 | pci_bus = PCI_HOST_BRIDGE(grackle_dev)->bus; |
250 | ||
251 | /* MacIO */ | |
252 | macio = pci_new(PCI_DEVFN(16, 0), TYPE_OLDWORLD_MACIO); | |
253 | dev = DEVICE(macio); | |
254 | qdev_prop_set_uint64(dev, "frequency", tbfreq); | |
255 | ||
256 | escc = ESCC(object_resolve_path_component(OBJECT(macio), "escc")); | |
257 | qdev_prop_set_chr(DEVICE(escc), "chrA", serial_hd(0)); | |
258 | qdev_prop_set_chr(DEVICE(escc), "chrB", serial_hd(1)); | |
259 | ||
260 | pci_realize_and_unref(macio, pci_bus, &error_fatal); | |
261 | ||
262 | pic_dev = DEVICE(object_resolve_path_component(OBJECT(macio), "pic")); | |
263 | for (i = 0; i < 4; i++) { | |
264 | qdev_connect_gpio_out(grackle_dev, i, | |
265 | qdev_get_gpio_in(pic_dev, 0x15 + i)); | |
266 | } | |
a5ed75fe | 267 | |
3cbee15b JM |
268 | /* Connect the heathrow PIC outputs to the 6xx bus */ |
269 | for (i = 0; i < smp_cpus; i++) { | |
270 | switch (PPC_INPUT(env)) { | |
271 | case PPC_FLAGS_INPUT_6xx: | |
370022ce | 272 | /* XXX: we register only 1 output pin for heathrow PIC */ |
a5ed75fe MCA |
273 | qdev_connect_gpio_out(pic_dev, 0, |
274 | ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT]); | |
3cbee15b JM |
275 | break; |
276 | default: | |
c525436e MA |
277 | error_report("Bus model not supported on OldWorld Mac machine"); |
278 | exit(1); | |
3cbee15b JM |
279 | } |
280 | } | |
281 | ||
3e20ad3a | 282 | pci_vga_init(pci_bus); |
aae9366a | 283 | |
343bd85a | 284 | for (i = 0; i < nb_nics; i++) { |
29b358f9 | 285 | pci_nic_init_nofail(&nd_table[i], pci_bus, "ne2k_pci", NULL); |
343bd85a | 286 | } |
e4bcb14c | 287 | |
370022ce | 288 | /* MacIO IDE */ |
d8f94e1b | 289 | ide_drive_get(hd, ARRAY_SIZE(hd)); |
07a7484e | 290 | macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio), |
14eefd0e | 291 | "ide[0]")); |
07a7484e AF |
292 | macio_ide_init_drives(macio_ide, hd); |
293 | ||
14eefd0e AG |
294 | macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio), |
295 | "ide[1]")); | |
296 | macio_ide_init_drives(macio_ide, &hd[MAX_IDE_DEVS]); | |
3cbee15b | 297 | |
370022ce | 298 | /* MacIO CUDA/ADB */ |
293c867d AF |
299 | dev = DEVICE(object_resolve_path_component(OBJECT(macio), "cuda")); |
300 | adb_bus = qdev_get_child_bus(dev, "adb.0"); | |
3e80f690 MA |
301 | dev = qdev_new(TYPE_ADB_KEYBOARD); |
302 | qdev_realize_and_unref(dev, adb_bus, &error_fatal); | |
303 | dev = qdev_new(TYPE_ADB_MOUSE); | |
304 | qdev_realize_and_unref(dev, adb_bus, &error_fatal); | |
45fa67fb | 305 | |
4bcbe0b6 | 306 | if (machine_usb(machine)) { |
afb9a60e | 307 | pci_create_simple(pci_bus, -1, "pci-ohci"); |
3cbee15b JM |
308 | } |
309 | ||
310 | if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8) | |
311 | graphic_depth = 15; | |
312 | ||
3cbee15b JM |
313 | /* No PCI init: the BIOS will do it */ |
314 | ||
3e80f690 | 315 | dev = qdev_new(TYPE_FW_CFG_MEM); |
81a07050 MCA |
316 | fw_cfg = FW_CFG(dev); |
317 | qdev_prop_set_uint32(dev, "data_width", 1); | |
318 | qdev_prop_set_bit(dev, "dma_enabled", false); | |
319 | object_property_add_child(OBJECT(qdev_get_machine()), TYPE_FW_CFG, | |
d2623129 | 320 | OBJECT(fw_cfg)); |
81a07050 | 321 | s = SYS_BUS_DEVICE(dev); |
3c6ef471 | 322 | sysbus_realize_and_unref(s, &error_fatal); |
81a07050 MCA |
323 | sysbus_mmio_map(s, 0, CFG_ADDR); |
324 | sysbus_mmio_map(s, 1, CFG_ADDR + 2); | |
325 | ||
5836d168 | 326 | fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, (uint16_t)smp_cpus); |
fe6b6346 | 327 | fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)machine->smp.max_cpus); |
271dd5e0 BS |
328 | fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); |
329 | fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_HEATHROW); | |
513f789f BS |
330 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base); |
331 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); | |
b8df3255 | 332 | if (machine->kernel_cmdline) { |
b9e17a34 | 333 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, cmdline_base); |
b8df3255 BZ |
334 | pstrcpy_targphys("cmdline", cmdline_base, TARGET_PAGE_SIZE, |
335 | machine->kernel_cmdline); | |
513f789f BS |
336 | } else { |
337 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0); | |
338 | } | |
339 | fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_base); | |
340 | fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); | |
341 | fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ppc_boot_device); | |
7f1aec5f LV |
342 | |
343 | fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, graphic_width); | |
344 | fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height); | |
345 | fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth); | |
346 | ||
45024f09 | 347 | fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled()); |
dc333cd6 | 348 | if (kvm_enabled()) { |
45024f09 AG |
349 | uint8_t *hypercall; |
350 | ||
7267c094 | 351 | hypercall = g_malloc(16); |
45024f09 AG |
352 | kvmppc_get_hypercall(env, hypercall, 16); |
353 | fw_cfg_add_bytes(fw_cfg, FW_CFG_PPC_KVM_HC, hypercall, 16); | |
354 | fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_KVM_PID, getpid()); | |
dc333cd6 | 355 | } |
caae6c96 | 356 | fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, tbfreq); |
a1014f25 | 357 | /* Mac OS X requires a "known good" clock-frequency value; pass it one. */ |
9d1c1283 BZ |
358 | fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_CLOCKFREQ, CLOCKFREQ); |
359 | fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_BUSFREQ, BUSFREQ); | |
dc333cd6 | 360 | |
b50de5cd MCA |
361 | /* MacOS NDRV VGA driver */ |
362 | filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, NDRV_VGA_FILENAME); | |
363 | if (filename) { | |
9776874f PM |
364 | gchar *ndrv_file; |
365 | gsize ndrv_size; | |
b50de5cd | 366 | |
9776874f | 367 | if (g_file_get_contents(filename, &ndrv_file, &ndrv_size, NULL)) { |
b50de5cd MCA |
368 | fw_cfg_add_file(fw_cfg, "ndrv/qemu_vga.ndrv", ndrv_file, ndrv_size); |
369 | } | |
370 | g_free(filename); | |
371 | } | |
372 | ||
513f789f | 373 | qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); |
3cbee15b JM |
374 | } |
375 | ||
bbcc635f MCA |
376 | /* |
377 | * Implementation of an interface to adjust firmware path | |
378 | * for the bootindex property handling. | |
379 | */ | |
380 | static char *heathrow_fw_dev_path(FWPathProvider *p, BusState *bus, | |
381 | DeviceState *dev) | |
382 | { | |
383 | PCIDevice *pci; | |
bbcc635f MCA |
384 | MACIOIDEState *macio_ide; |
385 | ||
386 | if (!strcmp(object_get_typename(OBJECT(dev)), "macio-oldworld")) { | |
387 | pci = PCI_DEVICE(dev); | |
388 | return g_strdup_printf("mac-io@%x", PCI_SLOT(pci->devfn)); | |
389 | } | |
390 | ||
391 | if (!strcmp(object_get_typename(OBJECT(dev)), "macio-ide")) { | |
392 | macio_ide = MACIO_IDE(dev); | |
393 | return g_strdup_printf("ata-3@%x", macio_ide->addr); | |
394 | } | |
395 | ||
bbcc635f | 396 | if (!strcmp(object_get_typename(OBJECT(dev)), "ide-hd")) { |
484d366e | 397 | return g_strdup("disk"); |
bbcc635f MCA |
398 | } |
399 | ||
400 | if (!strcmp(object_get_typename(OBJECT(dev)), "ide-cd")) { | |
401 | return g_strdup("cdrom"); | |
402 | } | |
403 | ||
404 | if (!strcmp(object_get_typename(OBJECT(dev)), "virtio-blk-device")) { | |
405 | return g_strdup("disk"); | |
406 | } | |
407 | ||
408 | return NULL; | |
409 | } | |
410 | ||
dc0ca80e | 411 | static int heathrow_kvm_type(MachineState *machine, const char *arg) |
277c7a4d AG |
412 | { |
413 | /* Always force PR KVM */ | |
414 | return 2; | |
415 | } | |
416 | ||
c8bd3526 | 417 | static void heathrow_class_init(ObjectClass *oc, void *data) |
e264d29d | 418 | { |
c8bd3526 | 419 | MachineClass *mc = MACHINE_CLASS(oc); |
bbcc635f | 420 | FWPathProviderClass *fwc = FW_PATH_PROVIDER_CLASS(oc); |
c8bd3526 | 421 | |
e264d29d EH |
422 | mc->desc = "Heathrow based PowerMAC"; |
423 | mc->init = ppc_heathrow_init; | |
2059839b | 424 | mc->block_default_type = IF_IDE; |
83234b82 PM |
425 | /* SMP is not supported currently */ |
426 | mc->max_cpus = 1; | |
46214a27 | 427 | #ifndef TARGET_PPC64 |
ea0ac7f6 | 428 | mc->is_default = true; |
46214a27 | 429 | #endif |
f309ae85 | 430 | /* TOFIX "cad" when Mac floppy is implemented */ |
e264d29d EH |
431 | mc->default_boot_order = "cd"; |
432 | mc->kvm_type = heathrow_kvm_type; | |
f4c6604e | 433 | mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("750_v3.1"); |
3232794b | 434 | mc->default_display = "std"; |
bbcc635f | 435 | mc->ignore_boot_device_suffixes = true; |
8ee06e4c | 436 | mc->default_ram_id = "ppc_heathrow.ram"; |
bbcc635f | 437 | fwc->get_dev_path = heathrow_fw_dev_path; |
f80f9ec9 AL |
438 | } |
439 | ||
c8bd3526 MCA |
440 | static const TypeInfo ppc_heathrow_machine_info = { |
441 | .name = MACHINE_TYPE_NAME("g3beige"), | |
442 | .parent = TYPE_MACHINE, | |
bbcc635f MCA |
443 | .class_init = heathrow_class_init, |
444 | .interfaces = (InterfaceInfo[]) { | |
445 | { TYPE_FW_PATH_PROVIDER }, | |
446 | { } | |
447 | }, | |
c8bd3526 MCA |
448 | }; |
449 | ||
450 | static void ppc_heathrow_register_types(void) | |
451 | { | |
452 | type_register_static(&ppc_heathrow_machine_info); | |
453 | } | |
454 | ||
455 | type_init(ppc_heathrow_register_types); |