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. |
| 24 | */ |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 25 | #include "hw.h" |
| 26 | #include "ppc.h" |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 27 | #include "ppc_mac.h" |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 28 | #include "nvram.h" |
| 29 | #include "pc.h" |
| 30 | #include "pci.h" |
| 31 | #include "net.h" |
| 32 | #include "sysemu.h" |
| 33 | #include "boards.h" |
blueswir1 | 7fa9ae1 | 2009-01-12 17:40:23 +0000 | [diff] [blame] | 34 | #include "escc.h" |
bellard | 267002c | 2004-06-03 18:46:20 +0000 | [diff] [blame] | 35 | |
ths | e4bcb14 | 2007-12-02 04:51:10 +0000 | [diff] [blame] | 36 | #define MAX_IDE_BUS 2 |
| 37 | |
bellard | 0aa6a4a | 2005-06-05 15:11:17 +0000 | [diff] [blame] | 38 | /* UniN device */ |
| 39 | static void unin_writel (void *opaque, target_phys_addr_t addr, uint32_t value) |
| 40 | { |
| 41 | } |
| 42 | |
| 43 | static uint32_t unin_readl (void *opaque, target_phys_addr_t addr) |
| 44 | { |
| 45 | return 0; |
| 46 | } |
| 47 | |
| 48 | static CPUWriteMemoryFunc *unin_write[] = { |
| 49 | &unin_writel, |
| 50 | &unin_writel, |
| 51 | &unin_writel, |
| 52 | }; |
| 53 | |
| 54 | static CPUReadMemoryFunc *unin_read[] = { |
| 55 | &unin_readl, |
| 56 | &unin_readl, |
| 57 | &unin_readl, |
| 58 | }; |
| 59 | |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 60 | /* PowerPC Mac99 hardware initialisation */ |
aurel32 | 00f82b8 | 2008-04-27 21:12:55 +0000 | [diff] [blame] | 61 | static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size, |
balrog | 6ac0e82 | 2007-10-31 01:54:04 +0000 | [diff] [blame] | 62 | const char *boot_device, DisplayState *ds, |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 63 | const char *kernel_filename, |
| 64 | const char *kernel_cmdline, |
| 65 | const char *initrd_filename, |
| 66 | const char *cpu_model) |
bellard | 6420120 | 2004-05-26 22:55:16 +0000 | [diff] [blame] | 67 | { |
bellard | aaed909 | 2007-11-10 15:15:54 +0000 | [diff] [blame] | 68 | CPUState *env = NULL, *envs[MAX_CPUS]; |
bellard | 6420120 | 2004-05-26 22:55:16 +0000 | [diff] [blame] | 69 | char buf[1024]; |
j_mayer | e9df014 | 2007-04-09 22:45:36 +0000 | [diff] [blame] | 70 | qemu_irq *pic, **openpic_irqs; |
pbrook | aef445b | 2006-09-18 01:15:29 +0000 | [diff] [blame] | 71 | int unin_memory; |
bellard | d529525 | 2005-07-03 14:00:51 +0000 | [diff] [blame] | 72 | int linux_boot, i; |
| 73 | unsigned long bios_offset, vga_bios_offset; |
bellard | b6b8bd1 | 2004-06-21 16:55:53 +0000 | [diff] [blame] | 74 | uint32_t kernel_base, kernel_size, initrd_base, initrd_size; |
bellard | 46e50e9 | 2004-06-21 19:43:00 +0000 | [diff] [blame] | 75 | PCIBus *pci_bus; |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 76 | nvram_t nvram; |
| 77 | #if 0 |
| 78 | MacIONVRAMState *nvr; |
| 79 | int nvram_mem_index; |
| 80 | #endif |
| 81 | m48t59_t *m48t59; |
bellard | d529525 | 2005-07-03 14:00:51 +0000 | [diff] [blame] | 82 | int vga_bios_size, bios_size; |
pbrook | d537cf6 | 2007-04-07 18:14:41 +0000 | [diff] [blame] | 83 | qemu_irq *dummy_irq; |
blueswir1 | 7fa9ae1 | 2009-01-12 17:40:23 +0000 | [diff] [blame] | 84 | int pic_mem_index, dbdma_mem_index, cuda_mem_index, escc_mem_index; |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 85 | int ide_mem_index[2]; |
j_mayer | 28c5af5 | 2007-11-11 01:50:45 +0000 | [diff] [blame] | 86 | int ppc_boot_device; |
ths | e4bcb14 | 2007-12-02 04:51:10 +0000 | [diff] [blame] | 87 | int index; |
| 88 | BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
bellard | 46e50e9 | 2004-06-21 19:43:00 +0000 | [diff] [blame] | 89 | |
bellard | 6420120 | 2004-05-26 22:55:16 +0000 | [diff] [blame] | 90 | linux_boot = (kernel_filename != NULL); |
| 91 | |
bellard | c68ea70 | 2005-11-21 23:33:12 +0000 | [diff] [blame] | 92 | /* init CPUs */ |
j_mayer | 94fc95c | 2007-03-05 19:44:02 +0000 | [diff] [blame] | 93 | if (cpu_model == NULL) |
j_mayer | d12f4c3 | 2007-09-29 11:51:08 +0000 | [diff] [blame] | 94 | cpu_model = "default"; |
j_mayer | e9df014 | 2007-04-09 22:45:36 +0000 | [diff] [blame] | 95 | for (i = 0; i < smp_cpus; i++) { |
bellard | aaed909 | 2007-11-10 15:15:54 +0000 | [diff] [blame] | 96 | env = cpu_init(cpu_model); |
| 97 | if (!env) { |
| 98 | fprintf(stderr, "Unable to find PowerPC CPU definition\n"); |
| 99 | exit(1); |
| 100 | } |
j_mayer | e9df014 | 2007-04-09 22:45:36 +0000 | [diff] [blame] | 101 | /* Set time-base frequency to 100 Mhz */ |
| 102 | cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL); |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 103 | #if 0 |
j_mayer | e9df014 | 2007-04-09 22:45:36 +0000 | [diff] [blame] | 104 | env->osi_call = vga_osi_call; |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 105 | #endif |
j_mayer | fe33cc7 | 2007-10-03 01:06:57 +0000 | [diff] [blame] | 106 | qemu_register_reset(&cpu_ppc_reset, env); |
j_mayer | e9df014 | 2007-04-09 22:45:36 +0000 | [diff] [blame] | 107 | envs[i] = env; |
| 108 | } |
j_mayer | 4c823cf | 2007-10-29 10:19:50 +0000 | [diff] [blame] | 109 | if (env->nip < 0xFFF80000) { |
| 110 | /* Special test for PowerPC 601: |
| 111 | * the boot vector is at 0xFFF00100, then we need a 1MB BIOS. |
| 112 | * But the NVRAM is located at 0xFFF04000... |
| 113 | */ |
| 114 | cpu_abort(env, "Mac99 hardware can not handle 1 MB BIOS\n"); |
| 115 | } |
bellard | c68ea70 | 2005-11-21 23:33:12 +0000 | [diff] [blame] | 116 | |
bellard | 6420120 | 2004-05-26 22:55:16 +0000 | [diff] [blame] | 117 | /* allocate RAM */ |
| 118 | cpu_register_physical_memory(0, ram_size, IO_MEM_RAM); |
| 119 | |
| 120 | /* allocate and load BIOS */ |
| 121 | bios_offset = ram_size + vga_ram_size; |
j_mayer | 1192dad | 2007-10-05 13:08:35 +0000 | [diff] [blame] | 122 | if (bios_name == NULL) |
| 123 | bios_name = BIOS_FILENAME; |
| 124 | snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); |
bellard | d529525 | 2005-07-03 14:00:51 +0000 | [diff] [blame] | 125 | bios_size = load_image(buf, phys_ram_base + bios_offset); |
| 126 | if (bios_size < 0 || bios_size > BIOS_SIZE) { |
j_mayer | 4a05771 | 2007-04-19 08:42:21 +0000 | [diff] [blame] | 127 | cpu_abort(env, "qemu: could not load PowerPC bios '%s'\n", buf); |
bellard | 6420120 | 2004-05-26 22:55:16 +0000 | [diff] [blame] | 128 | exit(1); |
| 129 | } |
bellard | d529525 | 2005-07-03 14:00:51 +0000 | [diff] [blame] | 130 | bios_size = (bios_size + 0xfff) & ~0xfff; |
j_mayer | 4c823cf | 2007-10-29 10:19:50 +0000 | [diff] [blame] | 131 | if (bios_size > 0x00080000) { |
| 132 | /* As the NVRAM is located at 0xFFF04000, we cannot use 1 MB BIOSes */ |
| 133 | cpu_abort(env, "Mac99 hardware can not handle 1 MB BIOS\n"); |
| 134 | } |
j_mayer | 4a05771 | 2007-04-19 08:42:21 +0000 | [diff] [blame] | 135 | cpu_register_physical_memory((uint32_t)(-bios_size), |
bellard | d529525 | 2005-07-03 14:00:51 +0000 | [diff] [blame] | 136 | bios_size, bios_offset | IO_MEM_ROM); |
ths | 3b46e62 | 2007-09-17 08:09:54 +0000 | [diff] [blame] | 137 | |
bellard | d529525 | 2005-07-03 14:00:51 +0000 | [diff] [blame] | 138 | /* allocate and load VGA BIOS */ |
| 139 | vga_bios_offset = bios_offset + bios_size; |
| 140 | snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME); |
| 141 | vga_bios_size = load_image(buf, phys_ram_base + vga_bios_offset + 8); |
| 142 | if (vga_bios_size < 0) { |
| 143 | /* if no bios is present, we can still work */ |
| 144 | fprintf(stderr, "qemu: warning: could not load VGA bios '%s'\n", buf); |
| 145 | vga_bios_size = 0; |
| 146 | } else { |
| 147 | /* set a specific header (XXX: find real Apple format for NDRV |
| 148 | drivers) */ |
| 149 | phys_ram_base[vga_bios_offset] = 'N'; |
| 150 | phys_ram_base[vga_bios_offset + 1] = 'D'; |
| 151 | phys_ram_base[vga_bios_offset + 2] = 'R'; |
| 152 | phys_ram_base[vga_bios_offset + 3] = 'V'; |
ths | 5fafdf2 | 2007-09-16 21:08:06 +0000 | [diff] [blame] | 153 | cpu_to_be32w((uint32_t *)(phys_ram_base + vga_bios_offset + 4), |
bellard | d529525 | 2005-07-03 14:00:51 +0000 | [diff] [blame] | 154 | vga_bios_size); |
| 155 | vga_bios_size += 8; |
| 156 | } |
| 157 | vga_bios_size = (vga_bios_size + 0xfff) & ~0xfff; |
ths | 3b46e62 | 2007-09-17 08:09:54 +0000 | [diff] [blame] | 158 | |
bellard | b6b8bd1 | 2004-06-21 16:55:53 +0000 | [diff] [blame] | 159 | if (linux_boot) { |
| 160 | kernel_base = KERNEL_LOAD_ADDR; |
| 161 | /* now we can load the kernel */ |
| 162 | kernel_size = load_image(kernel_filename, phys_ram_base + kernel_base); |
| 163 | if (kernel_size < 0) { |
j_mayer | 4a05771 | 2007-04-19 08:42:21 +0000 | [diff] [blame] | 164 | cpu_abort(env, "qemu: could not load kernel '%s'\n", |
| 165 | kernel_filename); |
bellard | b6b8bd1 | 2004-06-21 16:55:53 +0000 | [diff] [blame] | 166 | exit(1); |
| 167 | } |
| 168 | /* load initrd */ |
| 169 | if (initrd_filename) { |
| 170 | initrd_base = INITRD_LOAD_ADDR; |
| 171 | initrd_size = load_image(initrd_filename, |
| 172 | phys_ram_base + initrd_base); |
| 173 | if (initrd_size < 0) { |
j_mayer | 4a05771 | 2007-04-19 08:42:21 +0000 | [diff] [blame] | 174 | cpu_abort(env, "qemu: could not load initial ram disk '%s'\n", |
| 175 | initrd_filename); |
bellard | b6b8bd1 | 2004-06-21 16:55:53 +0000 | [diff] [blame] | 176 | exit(1); |
| 177 | } |
| 178 | } else { |
| 179 | initrd_base = 0; |
| 180 | initrd_size = 0; |
| 181 | } |
balrog | 6ac0e82 | 2007-10-31 01:54:04 +0000 | [diff] [blame] | 182 | ppc_boot_device = 'm'; |
bellard | b6b8bd1 | 2004-06-21 16:55:53 +0000 | [diff] [blame] | 183 | } else { |
| 184 | kernel_base = 0; |
| 185 | kernel_size = 0; |
| 186 | initrd_base = 0; |
| 187 | initrd_size = 0; |
j_mayer | 28c5af5 | 2007-11-11 01:50:45 +0000 | [diff] [blame] | 188 | ppc_boot_device = '\0'; |
| 189 | /* We consider that NewWorld PowerMac never have any floppy drive |
| 190 | * For now, OHW cannot boot from the network. |
| 191 | */ |
j_mayer | 0d913fd | 2007-11-11 14:44:28 +0000 | [diff] [blame] | 192 | for (i = 0; boot_device[i] != '\0'; i++) { |
| 193 | if (boot_device[i] >= 'c' && boot_device[i] <= 'f') { |
| 194 | ppc_boot_device = boot_device[i]; |
j_mayer | 28c5af5 | 2007-11-11 01:50:45 +0000 | [diff] [blame] | 195 | break; |
j_mayer | 0d913fd | 2007-11-11 14:44:28 +0000 | [diff] [blame] | 196 | } |
j_mayer | 28c5af5 | 2007-11-11 01:50:45 +0000 | [diff] [blame] | 197 | } |
| 198 | if (ppc_boot_device == '\0') { |
| 199 | fprintf(stderr, "No valid boot device for Mac99 machine\n"); |
| 200 | exit(1); |
| 201 | } |
bellard | b6b8bd1 | 2004-06-21 16:55:53 +0000 | [diff] [blame] | 202 | } |
bellard | 6420120 | 2004-05-26 22:55:16 +0000 | [diff] [blame] | 203 | |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 204 | isa_mem_base = 0x80000000; |
j_mayer | dd37a5e | 2007-04-16 07:41:07 +0000 | [diff] [blame] | 205 | |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 206 | /* Register 8 MB of ISA IO space */ |
| 207 | isa_mmio_init(0xf2000000, 0x00800000); |
pbrook | aef445b | 2006-09-18 01:15:29 +0000 | [diff] [blame] | 208 | |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 209 | /* UniN init */ |
| 210 | unin_memory = cpu_register_io_memory(0, unin_read, unin_write, NULL); |
| 211 | cpu_register_physical_memory(0xf8000000, 0x00001000, unin_memory); |
| 212 | |
| 213 | openpic_irqs = qemu_mallocz(smp_cpus * sizeof(qemu_irq *)); |
| 214 | openpic_irqs[0] = |
| 215 | qemu_mallocz(smp_cpus * sizeof(qemu_irq) * OPENPIC_OUTPUT_NB); |
| 216 | for (i = 0; i < smp_cpus; i++) { |
| 217 | /* Mac99 IRQ connection between OpenPIC outputs pins |
| 218 | * and PowerPC input pins |
| 219 | */ |
| 220 | switch (PPC_INPUT(env)) { |
| 221 | case PPC_FLAGS_INPUT_6xx: |
| 222 | openpic_irqs[i] = openpic_irqs[0] + (i * OPENPIC_OUTPUT_NB); |
| 223 | openpic_irqs[i][OPENPIC_OUTPUT_INT] = |
| 224 | ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT]; |
| 225 | openpic_irqs[i][OPENPIC_OUTPUT_CINT] = |
| 226 | ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT]; |
| 227 | openpic_irqs[i][OPENPIC_OUTPUT_MCK] = |
| 228 | ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_MCP]; |
| 229 | /* Not connected ? */ |
| 230 | openpic_irqs[i][OPENPIC_OUTPUT_DEBUG] = NULL; |
| 231 | /* Check this */ |
| 232 | openpic_irqs[i][OPENPIC_OUTPUT_RESET] = |
| 233 | ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_HRESET]; |
| 234 | break; |
| 235 | #if defined(TARGET_PPC64) |
| 236 | case PPC_FLAGS_INPUT_970: |
| 237 | openpic_irqs[i] = openpic_irqs[0] + (i * OPENPIC_OUTPUT_NB); |
| 238 | openpic_irqs[i][OPENPIC_OUTPUT_INT] = |
| 239 | ((qemu_irq *)env->irq_inputs)[PPC970_INPUT_INT]; |
| 240 | openpic_irqs[i][OPENPIC_OUTPUT_CINT] = |
| 241 | ((qemu_irq *)env->irq_inputs)[PPC970_INPUT_INT]; |
| 242 | openpic_irqs[i][OPENPIC_OUTPUT_MCK] = |
| 243 | ((qemu_irq *)env->irq_inputs)[PPC970_INPUT_MCP]; |
| 244 | /* Not connected ? */ |
| 245 | openpic_irqs[i][OPENPIC_OUTPUT_DEBUG] = NULL; |
| 246 | /* Check this */ |
| 247 | openpic_irqs[i][OPENPIC_OUTPUT_RESET] = |
| 248 | ((qemu_irq *)env->irq_inputs)[PPC970_INPUT_HRESET]; |
| 249 | break; |
| 250 | #endif /* defined(TARGET_PPC64) */ |
| 251 | default: |
| 252 | cpu_abort(env, "Bus model not supported on mac99 machine\n"); |
j_mayer | dd37a5e | 2007-04-16 07:41:07 +0000 | [diff] [blame] | 253 | exit(1); |
| 254 | } |
bellard | 6420120 | 2004-05-26 22:55:16 +0000 | [diff] [blame] | 255 | } |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 256 | pic = openpic_init(NULL, &pic_mem_index, smp_cpus, openpic_irqs, NULL); |
| 257 | pci_bus = pci_pmac_init(pic); |
| 258 | /* init basic PC hardware */ |
| 259 | pci_vga_init(pci_bus, ds, phys_ram_base + ram_size, |
| 260 | ram_size, vga_ram_size, |
| 261 | vga_bios_offset, vga_bios_size); |
j_mayer | aae9366 | 2007-11-24 02:56:36 +0000 | [diff] [blame] | 262 | |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 263 | /* XXX: suppress that */ |
| 264 | dummy_irq = i8259_init(NULL); |
| 265 | |
aurel32 | aeeb69c | 2009-01-14 14:47:56 +0000 | [diff] [blame] | 266 | escc_mem_index = escc_init(0x80013000, dummy_irq[4], dummy_irq[5], |
| 267 | serial_hds[0], serial_hds[1], ESCC_CLOCK, 4); |
aliguori | cb457d7 | 2009-01-13 19:47:10 +0000 | [diff] [blame] | 268 | |
| 269 | for(i = 0; i < nb_nics; i++) |
| 270 | pci_nic_init(pci_bus, &nd_table[i], -1, "ne2k_pci"); |
| 271 | |
ths | e4bcb14 | 2007-12-02 04:51:10 +0000 | [diff] [blame] | 272 | if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) { |
| 273 | fprintf(stderr, "qemu: too many IDE bus\n"); |
| 274 | exit(1); |
| 275 | } |
| 276 | for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) { |
| 277 | index = drive_get_index(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); |
| 278 | if (index != -1) |
| 279 | hd[i] = drives_table[index].bdrv; |
| 280 | else |
| 281 | hd[i] = NULL; |
| 282 | } |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 283 | #if 1 |
ths | e4bcb14 | 2007-12-02 04:51:10 +0000 | [diff] [blame] | 284 | ide_mem_index[0] = pmac_ide_init(&hd[0], pic[0x13]); |
| 285 | ide_mem_index[1] = pmac_ide_init(&hd[2], pic[0x14]); |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 286 | #else |
ths | e4bcb14 | 2007-12-02 04:51:10 +0000 | [diff] [blame] | 287 | pci_cmd646_ide_init(pci_bus, &hd[0], 0); |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 288 | #endif |
| 289 | /* cuda also initialize ADB */ |
| 290 | cuda_init(&cuda_mem_index, pic[0x19]); |
j_mayer | aae9366 | 2007-11-24 02:56:36 +0000 | [diff] [blame] | 291 | |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 292 | adb_kbd_init(&adb_bus); |
| 293 | adb_mouse_init(&adb_bus); |
| 294 | |
| 295 | dbdma_init(&dbdma_mem_index); |
| 296 | |
| 297 | macio_init(pci_bus, 0x0022, 0, pic_mem_index, dbdma_mem_index, |
blueswir1 | 7fa9ae1 | 2009-01-12 17:40:23 +0000 | [diff] [blame] | 298 | cuda_mem_index, NULL, 2, ide_mem_index, escc_mem_index); |
pbrook | 0d92ed3 | 2006-05-21 16:30:15 +0000 | [diff] [blame] | 299 | |
| 300 | if (usb_enabled) { |
pbrook | e24ad6f | 2007-03-17 16:59:31 +0000 | [diff] [blame] | 301 | usb_ohci_init_pci(pci_bus, 3, -1); |
pbrook | 0d92ed3 | 2006-05-21 16:30:15 +0000 | [diff] [blame] | 302 | } |
| 303 | |
bellard | b6b8bd1 | 2004-06-21 16:55:53 +0000 | [diff] [blame] | 304 | if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8) |
| 305 | graphic_depth = 15; |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 306 | #if 0 /* XXX: this is ugly but needed for now, or OHW won't boot */ |
| 307 | /* The NewWorld NVRAM is not located in the MacIO device */ |
j_mayer | 74e9115 | 2007-11-04 01:16:04 +0000 | [diff] [blame] | 308 | nvr = macio_nvram_init(&nvram_mem_index, 0x2000); |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 309 | pmac_format_nvram_partition(nvr, 0x2000); |
j_mayer | 74e9115 | 2007-11-04 01:16:04 +0000 | [diff] [blame] | 310 | macio_nvram_map(nvr, 0xFFF04000); |
j_mayer | 3cbee15 | 2007-10-28 23:42:18 +0000 | [diff] [blame] | 311 | nvram.opaque = nvr; |
| 312 | nvram.read_fn = &macio_nvram_read; |
| 313 | nvram.write_fn = &macio_nvram_write; |
| 314 | #else |
| 315 | m48t59 = m48t59_init(dummy_irq[8], 0xFFF04000, 0x0074, NVRAM_SIZE, 59); |
| 316 | nvram.opaque = m48t59; |
| 317 | nvram.read_fn = &m48t59_read; |
| 318 | nvram.write_fn = &m48t59_write; |
| 319 | #endif |
balrog | 6ac0e82 | 2007-10-31 01:54:04 +0000 | [diff] [blame] | 320 | PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "MAC99", ram_size, |
| 321 | ppc_boot_device, kernel_base, kernel_size, |
bellard | b6b8bd1 | 2004-06-21 16:55:53 +0000 | [diff] [blame] | 322 | kernel_cmdline, |
| 323 | initrd_base, initrd_size, |
| 324 | /* XXX: need an option to load a NVRAM image */ |
| 325 | 0, |
| 326 | graphic_width, graphic_height, graphic_depth); |
| 327 | /* No PCI init: the BIOS will do it */ |
bellard | 0aa6a4a | 2005-06-05 15:11:17 +0000 | [diff] [blame] | 328 | |
| 329 | /* Special port to get debug messages from Open-Firmware */ |
| 330 | register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL); |
j_mayer | aae9366 | 2007-11-24 02:56:36 +0000 | [diff] [blame] | 331 | } |
bellard | 0aa6a4a | 2005-06-05 15:11:17 +0000 | [diff] [blame] | 332 | |
| 333 | QEMUMachine core99_machine = { |
aliguori | 4b32e16 | 2008-10-07 20:34:35 +0000 | [diff] [blame] | 334 | .name = "mac99", |
| 335 | .desc = "Mac99 based PowerMAC", |
| 336 | .init = ppc_core99_init, |
| 337 | .ram_require = BIOS_SIZE + VGA_RAM_SIZE, |
balrog | 3d878ca | 2008-10-28 10:59:59 +0000 | [diff] [blame] | 338 | .max_cpus = MAX_CPUS, |
bellard | 0aa6a4a | 2005-06-05 15:11:17 +0000 | [diff] [blame] | 339 | }; |