1baec1910SAndreas Färber 2baec1910SAndreas Färber /* 3baec1910SAndreas Färber * QEMU OldWorld PowerMac (currently ~G3 Beige) hardware System Emulator 4baec1910SAndreas Färber * 5baec1910SAndreas Färber * Copyright (c) 2004-2007 Fabrice Bellard 6baec1910SAndreas Färber * Copyright (c) 2007 Jocelyn Mayer 7baec1910SAndreas Färber * 8baec1910SAndreas Färber * Permission is hereby granted, free of charge, to any person obtaining a copy 9baec1910SAndreas Färber * of this software and associated documentation files (the "Software"), to deal 10baec1910SAndreas Färber * in the Software without restriction, including without limitation the rights 11baec1910SAndreas Färber * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12baec1910SAndreas Färber * copies of the Software, and to permit persons to whom the Software is 13baec1910SAndreas Färber * furnished to do so, subject to the following conditions: 14baec1910SAndreas Färber * 15baec1910SAndreas Färber * The above copyright notice and this permission notice shall be included in 16baec1910SAndreas Färber * all copies or substantial portions of the Software. 17baec1910SAndreas Färber * 18baec1910SAndreas Färber * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19baec1910SAndreas Färber * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20baec1910SAndreas Färber * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21baec1910SAndreas Färber * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22baec1910SAndreas Färber * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23baec1910SAndreas Färber * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24baec1910SAndreas Färber * THE SOFTWARE. 25baec1910SAndreas Färber */ 26baec1910SAndreas Färber #include "hw/hw.h" 270d09e41aSPaolo Bonzini #include "hw/ppc/ppc.h" 28baec1910SAndreas Färber #include "mac.h" 290d09e41aSPaolo Bonzini #include "hw/input/adb.h" 300d09e41aSPaolo Bonzini #include "hw/timer/m48t59.h" 31baec1910SAndreas Färber #include "sysemu/sysemu.h" 32baec1910SAndreas Färber #include "net/net.h" 330d09e41aSPaolo Bonzini #include "hw/isa/isa.h" 34baec1910SAndreas Färber #include "hw/pci/pci.h" 35baec1910SAndreas Färber #include "hw/boards.h" 360d09e41aSPaolo Bonzini #include "hw/nvram/fw_cfg.h" 370d09e41aSPaolo Bonzini #include "hw/char/escc.h" 38baec1910SAndreas Färber #include "hw/ide.h" 39baec1910SAndreas Färber #include "hw/loader.h" 40baec1910SAndreas Färber #include "elf.h" 41baec1910SAndreas Färber #include "sysemu/kvm.h" 42baec1910SAndreas Färber #include "kvm_ppc.h" 434be74634SMarkus Armbruster #include "sysemu/block-backend.h" 44baec1910SAndreas Färber #include "exec/address-spaces.h" 45baec1910SAndreas Färber 46baec1910SAndreas Färber #define MAX_IDE_BUS 2 47baec1910SAndreas Färber #define CFG_ADDR 0xf0000510 48536d8cdaSAlexander Graf #define TBFREQ 16600000UL 499d1c1283SBALATON Zoltan #define CLOCKFREQ 266000000UL 509d1c1283SBALATON Zoltan #define BUSFREQ 66000000UL 51baec1910SAndreas Färber 52ddcd5531SGonglei static void fw_cfg_boot_set(void *opaque, const char *boot_device, 53ddcd5531SGonglei Error **errp) 54baec1910SAndreas Färber { 5548779e50SGabriel L. Somlo fw_cfg_modify_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]); 56baec1910SAndreas Färber } 57baec1910SAndreas Färber 58baec1910SAndreas Färber static uint64_t translate_kernel_address(void *opaque, uint64_t addr) 59baec1910SAndreas Färber { 60baec1910SAndreas Färber return (addr & 0x0fffffff) + KERNEL_LOAD_ADDR; 61baec1910SAndreas Färber } 62baec1910SAndreas Färber 63baec1910SAndreas Färber static hwaddr round_page(hwaddr addr) 64baec1910SAndreas Färber { 65baec1910SAndreas Färber return (addr + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK; 66baec1910SAndreas Färber } 67baec1910SAndreas Färber 68baec1910SAndreas Färber static void ppc_heathrow_reset(void *opaque) 69baec1910SAndreas Färber { 70baec1910SAndreas Färber PowerPCCPU *cpu = opaque; 71baec1910SAndreas Färber 72baec1910SAndreas Färber cpu_reset(CPU(cpu)); 73baec1910SAndreas Färber } 74baec1910SAndreas Färber 753ef96221SMarcel Apfelbaum static void ppc_heathrow_init(MachineState *machine) 76baec1910SAndreas Färber { 773ef96221SMarcel Apfelbaum ram_addr_t ram_size = machine->ram_size; 783ef96221SMarcel Apfelbaum const char *kernel_filename = machine->kernel_filename; 793ef96221SMarcel Apfelbaum const char *kernel_cmdline = machine->kernel_cmdline; 803ef96221SMarcel Apfelbaum const char *initrd_filename = machine->initrd_filename; 813ef96221SMarcel Apfelbaum const char *boot_device = machine->boot_order; 82baec1910SAndreas Färber MemoryRegion *sysmem = get_system_memory(); 83baec1910SAndreas Färber PowerPCCPU *cpu = NULL; 84baec1910SAndreas Färber CPUPPCState *env = NULL; 85baec1910SAndreas Färber char *filename; 86baec1910SAndreas Färber qemu_irq *pic, **heathrow_irqs; 87baec1910SAndreas Färber int linux_boot, i; 88baec1910SAndreas Färber MemoryRegion *ram = g_new(MemoryRegion, 1); 89baec1910SAndreas Färber MemoryRegion *bios = g_new(MemoryRegion, 1); 907d52857eSPaolo Bonzini MemoryRegion *isa = g_new(MemoryRegion, 1); 91baec1910SAndreas Färber uint32_t kernel_base, initrd_base, cmdline_base = 0; 92baec1910SAndreas Färber int32_t kernel_size, initrd_size; 93baec1910SAndreas Färber PCIBus *pci_bus; 94d037834aSAndreas Färber PCIDevice *macio; 9507a7484eSAndreas Färber MACIOIDEState *macio_ide; 9607a7484eSAndreas Färber DeviceState *dev; 97293c867dSAndreas Färber BusState *adb_bus; 98baec1910SAndreas Färber int bios_size; 9945fa67fbSAndreas Färber MemoryRegion *pic_mem; 10007a7484eSAndreas Färber MemoryRegion *escc_mem, *escc_bar = g_new(MemoryRegion, 1); 101baec1910SAndreas Färber uint16_t ppc_boot_device; 102baec1910SAndreas Färber DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; 103baec1910SAndreas Färber void *fw_cfg; 104caae6c96SAlexander Graf uint64_t tbfreq; 105baec1910SAndreas Färber 106baec1910SAndreas Färber linux_boot = (kernel_filename != NULL); 107baec1910SAndreas Färber 108baec1910SAndreas Färber /* init CPUs */ 10919fb2c36SBharata B Rao if (machine->cpu_model == NULL) 11019fb2c36SBharata B Rao machine->cpu_model = "G3"; 111baec1910SAndreas Färber for (i = 0; i < smp_cpus; i++) { 11219fb2c36SBharata B Rao cpu = cpu_ppc_init(machine->cpu_model); 113baec1910SAndreas Färber if (cpu == NULL) { 114baec1910SAndreas Färber fprintf(stderr, "Unable to find PowerPC CPU definition\n"); 115baec1910SAndreas Färber exit(1); 116baec1910SAndreas Färber } 117baec1910SAndreas Färber env = &cpu->env; 118baec1910SAndreas Färber 119baec1910SAndreas Färber /* Set time-base frequency to 16.6 Mhz */ 120536d8cdaSAlexander Graf cpu_ppc_tb_init(env, TBFREQ); 121baec1910SAndreas Färber qemu_register_reset(ppc_heathrow_reset, cpu); 122baec1910SAndreas Färber } 123baec1910SAndreas Färber 124baec1910SAndreas Färber /* allocate RAM */ 125baec1910SAndreas Färber if (ram_size > (2047 << 20)) { 126baec1910SAndreas Färber fprintf(stderr, 127baec1910SAndreas Färber "qemu: Too much memory for this machine: %d MB, maximum 2047 MB\n", 128baec1910SAndreas Färber ((unsigned int)ram_size / (1 << 20))); 129baec1910SAndreas Färber exit(1); 130baec1910SAndreas Färber } 131baec1910SAndreas Färber 132e938ba0cSShreyas B. Prabhu memory_region_allocate_system_memory(ram, NULL, "ppc_heathrow.ram", 133e938ba0cSShreyas B. Prabhu ram_size); 134baec1910SAndreas Färber memory_region_add_subregion(sysmem, 0, ram); 135baec1910SAndreas Färber 136baec1910SAndreas Färber /* allocate and load BIOS */ 13749946538SHu Tao memory_region_init_ram(bios, NULL, "ppc_heathrow.bios", BIOS_SIZE, 138f8ed85acSMarkus Armbruster &error_fatal); 139e206ad48SHu Tao vmstate_register_ram_global(bios); 140e206ad48SHu Tao 141baec1910SAndreas Färber if (bios_name == NULL) 142baec1910SAndreas Färber bios_name = PROM_FILENAME; 143baec1910SAndreas Färber filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); 144baec1910SAndreas Färber memory_region_set_readonly(bios, true); 145baec1910SAndreas Färber memory_region_add_subregion(sysmem, PROM_ADDR, bios); 146baec1910SAndreas Färber 147baec1910SAndreas Färber /* Load OpenBIOS (ELF) */ 148baec1910SAndreas Färber if (filename) { 149baec1910SAndreas Färber bios_size = load_elf(filename, 0, NULL, NULL, NULL, NULL, 150baec1910SAndreas Färber 1, ELF_MACHINE, 0); 151baec1910SAndreas Färber g_free(filename); 152baec1910SAndreas Färber } else { 153baec1910SAndreas Färber bios_size = -1; 154baec1910SAndreas Färber } 155baec1910SAndreas Färber if (bios_size < 0 || bios_size > BIOS_SIZE) { 156baec1910SAndreas Färber hw_error("qemu: could not load PowerPC bios '%s'\n", bios_name); 157baec1910SAndreas Färber exit(1); 158baec1910SAndreas Färber } 159baec1910SAndreas Färber 160baec1910SAndreas Färber if (linux_boot) { 161baec1910SAndreas Färber uint64_t lowaddr = 0; 162baec1910SAndreas Färber int bswap_needed; 163baec1910SAndreas Färber 164baec1910SAndreas Färber #ifdef BSWAP_NEEDED 165baec1910SAndreas Färber bswap_needed = 1; 166baec1910SAndreas Färber #else 167baec1910SAndreas Färber bswap_needed = 0; 168baec1910SAndreas Färber #endif 169baec1910SAndreas Färber kernel_base = KERNEL_LOAD_ADDR; 170baec1910SAndreas Färber kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL, 171baec1910SAndreas Färber NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0); 172baec1910SAndreas Färber if (kernel_size < 0) 173baec1910SAndreas Färber kernel_size = load_aout(kernel_filename, kernel_base, 174baec1910SAndreas Färber ram_size - kernel_base, bswap_needed, 175baec1910SAndreas Färber TARGET_PAGE_SIZE); 176baec1910SAndreas Färber if (kernel_size < 0) 177baec1910SAndreas Färber kernel_size = load_image_targphys(kernel_filename, 178baec1910SAndreas Färber kernel_base, 179baec1910SAndreas Färber ram_size - kernel_base); 180baec1910SAndreas Färber if (kernel_size < 0) { 181baec1910SAndreas Färber hw_error("qemu: could not load kernel '%s'\n", 182baec1910SAndreas Färber kernel_filename); 183baec1910SAndreas Färber exit(1); 184baec1910SAndreas Färber } 185baec1910SAndreas Färber /* load initrd */ 186baec1910SAndreas Färber if (initrd_filename) { 187baec1910SAndreas Färber initrd_base = round_page(kernel_base + kernel_size + KERNEL_GAP); 188baec1910SAndreas Färber initrd_size = load_image_targphys(initrd_filename, initrd_base, 189baec1910SAndreas Färber ram_size - initrd_base); 190baec1910SAndreas Färber if (initrd_size < 0) { 191baec1910SAndreas Färber hw_error("qemu: could not load initial ram disk '%s'\n", 192baec1910SAndreas Färber initrd_filename); 193baec1910SAndreas Färber exit(1); 194baec1910SAndreas Färber } 195baec1910SAndreas Färber cmdline_base = round_page(initrd_base + initrd_size); 196baec1910SAndreas Färber } else { 197baec1910SAndreas Färber initrd_base = 0; 198baec1910SAndreas Färber initrd_size = 0; 199baec1910SAndreas Färber cmdline_base = round_page(kernel_base + kernel_size + KERNEL_GAP); 200baec1910SAndreas Färber } 201baec1910SAndreas Färber ppc_boot_device = 'm'; 202baec1910SAndreas Färber } else { 203baec1910SAndreas Färber kernel_base = 0; 204baec1910SAndreas Färber kernel_size = 0; 205baec1910SAndreas Färber initrd_base = 0; 206baec1910SAndreas Färber initrd_size = 0; 207baec1910SAndreas Färber ppc_boot_device = '\0'; 208baec1910SAndreas Färber for (i = 0; boot_device[i] != '\0'; i++) { 209baec1910SAndreas Färber /* TOFIX: for now, the second IDE channel is not properly 210baec1910SAndreas Färber * used by OHW. The Mac floppy disk are not emulated. 211baec1910SAndreas Färber * For now, OHW cannot boot from the network. 212baec1910SAndreas Färber */ 213baec1910SAndreas Färber #if 0 214baec1910SAndreas Färber if (boot_device[i] >= 'a' && boot_device[i] <= 'f') { 215baec1910SAndreas Färber ppc_boot_device = boot_device[i]; 216baec1910SAndreas Färber break; 217baec1910SAndreas Färber } 218baec1910SAndreas Färber #else 219baec1910SAndreas Färber if (boot_device[i] >= 'c' && boot_device[i] <= 'd') { 220baec1910SAndreas Färber ppc_boot_device = boot_device[i]; 221baec1910SAndreas Färber break; 222baec1910SAndreas Färber } 223baec1910SAndreas Färber #endif 224baec1910SAndreas Färber } 225baec1910SAndreas Färber if (ppc_boot_device == '\0') { 226baec1910SAndreas Färber fprintf(stderr, "No valid boot device for G3 Beige machine\n"); 227baec1910SAndreas Färber exit(1); 228baec1910SAndreas Färber } 229baec1910SAndreas Färber } 230baec1910SAndreas Färber 231baec1910SAndreas Färber /* Register 2 MB of ISA IO space */ 2327d52857eSPaolo Bonzini memory_region_init_alias(isa, NULL, "isa_mmio", 2337d52857eSPaolo Bonzini get_system_io(), 0, 0x00200000); 2347d52857eSPaolo Bonzini memory_region_add_subregion(sysmem, 0xfe000000, isa); 235baec1910SAndreas Färber 236baec1910SAndreas Färber /* XXX: we register only 1 output pin for heathrow PIC */ 237baec1910SAndreas Färber heathrow_irqs = g_malloc0(smp_cpus * sizeof(qemu_irq *)); 238baec1910SAndreas Färber heathrow_irqs[0] = 239baec1910SAndreas Färber g_malloc0(smp_cpus * sizeof(qemu_irq) * 1); 240baec1910SAndreas Färber /* Connect the heathrow PIC outputs to the 6xx bus */ 241baec1910SAndreas Färber for (i = 0; i < smp_cpus; i++) { 242baec1910SAndreas Färber switch (PPC_INPUT(env)) { 243baec1910SAndreas Färber case PPC_FLAGS_INPUT_6xx: 244baec1910SAndreas Färber heathrow_irqs[i] = heathrow_irqs[0] + (i * 1); 245baec1910SAndreas Färber heathrow_irqs[i][0] = 246baec1910SAndreas Färber ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT]; 247baec1910SAndreas Färber break; 248baec1910SAndreas Färber default: 249baec1910SAndreas Färber hw_error("Bus model not supported on OldWorld Mac machine\n"); 250baec1910SAndreas Färber } 251baec1910SAndreas Färber } 252baec1910SAndreas Färber 253caae6c96SAlexander Graf /* Timebase Frequency */ 254caae6c96SAlexander Graf if (kvm_enabled()) { 255caae6c96SAlexander Graf tbfreq = kvmppc_get_tbfreq(); 256caae6c96SAlexander Graf } else { 257caae6c96SAlexander Graf tbfreq = TBFREQ; 258caae6c96SAlexander Graf } 259caae6c96SAlexander Graf 260baec1910SAndreas Färber /* init basic PC hardware */ 261baec1910SAndreas Färber if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) { 262baec1910SAndreas Färber hw_error("Only 6xx bus is supported on heathrow machine\n"); 263baec1910SAndreas Färber } 264baec1910SAndreas Färber pic = heathrow_pic_init(&pic_mem, 1, heathrow_irqs); 265baec1910SAndreas Färber pci_bus = pci_grackle_init(0xfec00000, pic, 266baec1910SAndreas Färber get_system_memory(), 267baec1910SAndreas Färber get_system_io()); 268baec1910SAndreas Färber pci_vga_init(pci_bus); 269baec1910SAndreas Färber 270baec1910SAndreas Färber escc_mem = escc_init(0, pic[0x0f], pic[0x10], serial_hds[0], 271baec1910SAndreas Färber serial_hds[1], ESCC_CLOCK, 4); 2722c9b15caSPaolo Bonzini memory_region_init_alias(escc_bar, NULL, "escc-bar", 273baec1910SAndreas Färber escc_mem, 0, memory_region_size(escc_mem)); 274baec1910SAndreas Färber 275baec1910SAndreas Färber for(i = 0; i < nb_nics; i++) 27629b358f9SDavid Gibson pci_nic_init_nofail(&nd_table[i], pci_bus, "ne2k_pci", NULL); 277baec1910SAndreas Färber 278baec1910SAndreas Färber 279d8f94e1bSJohn Snow ide_drive_get(hd, ARRAY_SIZE(hd)); 280baec1910SAndreas Färber 281d037834aSAndreas Färber macio = pci_create(pci_bus, -1, TYPE_OLDWORLD_MACIO); 28207a7484eSAndreas Färber dev = DEVICE(macio); 28345fa67fbSAndreas Färber qdev_connect_gpio_out(dev, 0, pic[0x12]); /* CUDA */ 28414eefd0eSAlexander Graf qdev_connect_gpio_out(dev, 1, pic[0x0D]); /* IDE-0 */ 28514eefd0eSAlexander Graf qdev_connect_gpio_out(dev, 2, pic[0x02]); /* IDE-0 DMA */ 28614eefd0eSAlexander Graf qdev_connect_gpio_out(dev, 3, pic[0x0E]); /* IDE-1 */ 28714eefd0eSAlexander Graf qdev_connect_gpio_out(dev, 4, pic[0x03]); /* IDE-1 DMA */ 288b981289cSAlexander Graf qdev_prop_set_uint64(dev, "frequency", tbfreq); 28945fa67fbSAndreas Färber macio_init(macio, pic_mem, escc_bar); 29007a7484eSAndreas Färber 29107a7484eSAndreas Färber macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio), 29214eefd0eSAlexander Graf "ide[0]")); 29307a7484eSAndreas Färber macio_ide_init_drives(macio_ide, hd); 29407a7484eSAndreas Färber 29514eefd0eSAlexander Graf macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio), 29614eefd0eSAlexander Graf "ide[1]")); 29714eefd0eSAlexander Graf macio_ide_init_drives(macio_ide, &hd[MAX_IDE_DEVS]); 298baec1910SAndreas Färber 299293c867dSAndreas Färber dev = DEVICE(object_resolve_path_component(OBJECT(macio), "cuda")); 300293c867dSAndreas Färber adb_bus = qdev_get_child_bus(dev, "adb.0"); 301293c867dSAndreas Färber dev = qdev_create(adb_bus, TYPE_ADB_KEYBOARD); 3022e4a7c9cSAndreas Färber qdev_init_nofail(dev); 303293c867dSAndreas Färber dev = qdev_create(adb_bus, TYPE_ADB_MOUSE); 3042e4a7c9cSAndreas Färber qdev_init_nofail(dev); 30545fa67fbSAndreas Färber 306de77a243SMarcel Apfelbaum if (usb_enabled()) { 307baec1910SAndreas Färber pci_create_simple(pci_bus, -1, "pci-ohci"); 308baec1910SAndreas Färber } 309baec1910SAndreas Färber 310baec1910SAndreas Färber if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8) 311baec1910SAndreas Färber graphic_depth = 15; 312baec1910SAndreas Färber 313baec1910SAndreas Färber /* No PCI init: the BIOS will do it */ 314baec1910SAndreas Färber 31566708822SLaszlo Ersek fw_cfg = fw_cfg_init_mem(CFG_ADDR, CFG_ADDR + 2); 31670db9222SEduardo Habkost fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus); 317baec1910SAndreas Färber fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); 318baec1910SAndreas Färber fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_HEATHROW); 319baec1910SAndreas Färber fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base); 320baec1910SAndreas Färber fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); 321baec1910SAndreas Färber if (kernel_cmdline) { 322baec1910SAndreas Färber fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, cmdline_base); 323baec1910SAndreas Färber pstrcpy_targphys("cmdline", cmdline_base, TARGET_PAGE_SIZE, kernel_cmdline); 324baec1910SAndreas Färber } else { 325baec1910SAndreas Färber fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0); 326baec1910SAndreas Färber } 327baec1910SAndreas Färber fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_base); 328baec1910SAndreas Färber fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); 329baec1910SAndreas Färber fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ppc_boot_device); 330baec1910SAndreas Färber 331baec1910SAndreas Färber fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, graphic_width); 332baec1910SAndreas Färber fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height); 333baec1910SAndreas Färber fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth); 334baec1910SAndreas Färber 335baec1910SAndreas Färber fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled()); 336baec1910SAndreas Färber if (kvm_enabled()) { 337baec1910SAndreas Färber #ifdef CONFIG_KVM 338baec1910SAndreas Färber uint8_t *hypercall; 339baec1910SAndreas Färber 340baec1910SAndreas Färber hypercall = g_malloc(16); 341baec1910SAndreas Färber kvmppc_get_hypercall(env, hypercall, 16); 342baec1910SAndreas Färber fw_cfg_add_bytes(fw_cfg, FW_CFG_PPC_KVM_HC, hypercall, 16); 343baec1910SAndreas Färber fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_KVM_PID, getpid()); 344baec1910SAndreas Färber #endif 345baec1910SAndreas Färber } 346caae6c96SAlexander Graf fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, tbfreq); 347a1014f25SAlexander Graf /* Mac OS X requires a "known good" clock-frequency value; pass it one. */ 3489d1c1283SBALATON Zoltan fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_CLOCKFREQ, CLOCKFREQ); 3499d1c1283SBALATON Zoltan fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_BUSFREQ, BUSFREQ); 350baec1910SAndreas Färber 351baec1910SAndreas Färber qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); 352baec1910SAndreas Färber } 353baec1910SAndreas Färber 354277c7a4dSAlexander Graf static int heathrow_kvm_type(const char *arg) 355277c7a4dSAlexander Graf { 356277c7a4dSAlexander Graf /* Always force PR KVM */ 357277c7a4dSAlexander Graf return 2; 358277c7a4dSAlexander Graf } 359277c7a4dSAlexander Graf 360baec1910SAndreas Färber static QEMUMachine heathrow_machine = { 361baec1910SAndreas Färber .name = "g3beige", 362baec1910SAndreas Färber .desc = "Heathrow based PowerMAC", 363baec1910SAndreas Färber .init = ppc_heathrow_init, 364baec1910SAndreas Färber .max_cpus = MAX_CPUS, 365baec1910SAndreas Färber #ifndef TARGET_PPC64 366baec1910SAndreas Färber .is_default = 1, 367baec1910SAndreas Färber #endif 368*f309ae85SEduardo Habkost /* TOFIX "cad" when Mac floppy is implemented */ 369*f309ae85SEduardo Habkost .default_boot_order = "cd", 370277c7a4dSAlexander Graf .kvm_type = heathrow_kvm_type, 371baec1910SAndreas Färber }; 372baec1910SAndreas Färber 373baec1910SAndreas Färber static void heathrow_machine_init(void) 374baec1910SAndreas Färber { 375baec1910SAndreas Färber qemu_register_machine(&heathrow_machine); 376baec1910SAndreas Färber } 377baec1910SAndreas Färber 378baec1910SAndreas Färber machine_init(heathrow_machine_init); 379