root / hw / ppc_oldworld.c @ 37952117
History | View | Annotate | Download (11.6 kB)
1 | ae0bfb79 | Blue Swirl | |
---|---|---|---|
2 | 3cbee15b | j_mayer | /*
|
3 | 4d7ca41e | aurel32 | * QEMU OldWorld PowerMac (currently ~G3 Beige) hardware System Emulator
|
4 | 3cbee15b | j_mayer | *
|
5 | 3cbee15b | j_mayer | * Copyright (c) 2004-2007 Fabrice Bellard
|
6 | 3cbee15b | j_mayer | * Copyright (c) 2007 Jocelyn Mayer
|
7 | 3cbee15b | j_mayer | *
|
8 | 3cbee15b | j_mayer | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 | 3cbee15b | j_mayer | * of this software and associated documentation files (the "Software"), to deal
|
10 | 3cbee15b | j_mayer | * in the Software without restriction, including without limitation the rights
|
11 | 3cbee15b | j_mayer | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12 | 3cbee15b | j_mayer | * copies of the Software, and to permit persons to whom the Software is
|
13 | 3cbee15b | j_mayer | * furnished to do so, subject to the following conditions:
|
14 | 3cbee15b | j_mayer | *
|
15 | 3cbee15b | j_mayer | * The above copyright notice and this permission notice shall be included in
|
16 | 3cbee15b | j_mayer | * all copies or substantial portions of the Software.
|
17 | 3cbee15b | j_mayer | *
|
18 | 3cbee15b | j_mayer | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19 | 3cbee15b | j_mayer | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20 | 3cbee15b | j_mayer | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
21 | 3cbee15b | j_mayer | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22 | 3cbee15b | j_mayer | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23 | 3cbee15b | j_mayer | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
24 | 3cbee15b | j_mayer | * THE SOFTWARE.
|
25 | 3cbee15b | j_mayer | */
|
26 | 87ecb68b | pbrook | #include "hw.h" |
27 | 87ecb68b | pbrook | #include "ppc.h" |
28 | 3cbee15b | j_mayer | #include "ppc_mac.h" |
29 | 7a880d93 | Laurent Vivier | #include "adb.h" |
30 | 28ce5ce6 | aurel32 | #include "mac_dbdma.h" |
31 | 87ecb68b | pbrook | #include "nvram.h" |
32 | 87ecb68b | pbrook | #include "pc.h" |
33 | 87ecb68b | pbrook | #include "sysemu.h" |
34 | 87ecb68b | pbrook | #include "net.h" |
35 | 87ecb68b | pbrook | #include "isa.h" |
36 | 87ecb68b | pbrook | #include "pci.h" |
37 | 87ecb68b | pbrook | #include "boards.h" |
38 | 271dd5e0 | blueswir1 | #include "fw_cfg.h" |
39 | 7fa9ae1a | blueswir1 | #include "escc.h" |
40 | 977e1244 | Gerd Hoffmann | #include "ide.h" |
41 | ca20cf32 | Blue Swirl | #include "loader.h" |
42 | ca20cf32 | Blue Swirl | #include "elf.h" |
43 | dc702288 | Alexander Graf | #include "kvm.h" |
44 | dc333cd6 | Alexander Graf | #include "kvm_ppc.h" |
45 | 2446333c | Blue Swirl | #include "blockdev.h" |
46 | 1e39101c | Avi Kivity | #include "exec-memory.h" |
47 | 3cbee15b | j_mayer | |
48 | e4bcb14c | ths | #define MAX_IDE_BUS 2 |
49 | 271dd5e0 | blueswir1 | #define CFG_ADDR 0xf0000510 |
50 | 271dd5e0 | blueswir1 | |
51 | 513f789f | blueswir1 | static int fw_cfg_boot_set(void *opaque, const char *boot_device) |
52 | 513f789f | blueswir1 | { |
53 | 513f789f | blueswir1 | fw_cfg_add_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]);
|
54 | 513f789f | blueswir1 | return 0; |
55 | 513f789f | blueswir1 | } |
56 | 513f789f | blueswir1 | |
57 | 409dbce5 | Aurelien Jarno | |
58 | 409dbce5 | Aurelien Jarno | static uint64_t translate_kernel_address(void *opaque, uint64_t addr) |
59 | 409dbce5 | Aurelien Jarno | { |
60 | 409dbce5 | Aurelien Jarno | return (addr & 0x0fffffff) + KERNEL_LOAD_ADDR; |
61 | 409dbce5 | Aurelien Jarno | } |
62 | 409dbce5 | Aurelien Jarno | |
63 | b9e17a34 | Alexander Graf | static target_phys_addr_t round_page(target_phys_addr_t addr)
|
64 | b9e17a34 | Alexander Graf | { |
65 | b9e17a34 | Alexander Graf | return (addr + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK; |
66 | b9e17a34 | Alexander Graf | } |
67 | b9e17a34 | Alexander Graf | |
68 | 1bba0dc9 | Andreas Färber | static void ppc_heathrow_reset(void *opaque) |
69 | 1bba0dc9 | Andreas Färber | { |
70 | cd79664f | Andreas Färber | PowerPCCPU *cpu = opaque; |
71 | 1bba0dc9 | Andreas Färber | |
72 | cd79664f | Andreas Färber | cpu_reset(CPU(cpu)); |
73 | 1bba0dc9 | Andreas Färber | } |
74 | 1bba0dc9 | Andreas Färber | |
75 | c227f099 | Anthony Liguori | static void ppc_heathrow_init (ram_addr_t ram_size, |
76 | 3023f332 | aliguori | const char *boot_device, |
77 | 3cbee15b | j_mayer | const char *kernel_filename, |
78 | 3cbee15b | j_mayer | const char *kernel_cmdline, |
79 | 3cbee15b | j_mayer | const char *initrd_filename, |
80 | 3cbee15b | j_mayer | const char *cpu_model) |
81 | 3cbee15b | j_mayer | { |
82 | c92bb2c7 | Avi Kivity | MemoryRegion *sysmem = get_system_memory(); |
83 | 72c33dd7 | Andreas Färber | PowerPCCPU *cpu = NULL;
|
84 | e2684c0b | Andreas Färber | CPUPPCState *env = NULL;
|
85 | 5cea8590 | Paul Brook | char *filename;
|
86 | 3cbee15b | j_mayer | qemu_irq *pic, **heathrow_irqs; |
87 | 3cbee15b | j_mayer | int linux_boot, i;
|
88 | c92bb2c7 | Avi Kivity | MemoryRegion *ram = g_new(MemoryRegion, 1);
|
89 | c92bb2c7 | Avi Kivity | MemoryRegion *bios = g_new(MemoryRegion, 1);
|
90 | b9e17a34 | Alexander Graf | uint32_t kernel_base, initrd_base, cmdline_base = 0;
|
91 | 7373048c | blueswir1 | int32_t kernel_size, initrd_size; |
92 | 3cbee15b | j_mayer | PCIBus *pci_bus; |
93 | 3cbee15b | j_mayer | MacIONVRAMState *nvr; |
94 | ae0bfb79 | Blue Swirl | int bios_size;
|
95 | 23c5e4ca | Avi Kivity | MemoryRegion *pic_mem, *dbdma_mem, *cuda_mem; |
96 | 5b15f275 | Avi Kivity | MemoryRegion *escc_mem, *escc_bar = g_new(MemoryRegion, 1), *ide_mem[2]; |
97 | 513f789f | blueswir1 | uint16_t ppc_boot_device; |
98 | f455e98c | Gerd Hoffmann | DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
99 | 271dd5e0 | blueswir1 | void *fw_cfg;
|
100 | 28ce5ce6 | aurel32 | void *dbdma;
|
101 | 3cbee15b | j_mayer | |
102 | 3cbee15b | j_mayer | linux_boot = (kernel_filename != NULL);
|
103 | 3cbee15b | j_mayer | |
104 | 3cbee15b | j_mayer | /* init CPUs */
|
105 | 3cbee15b | j_mayer | if (cpu_model == NULL) |
106 | f2fde45a | aurel32 | cpu_model = "G3";
|
107 | 3cbee15b | j_mayer | for (i = 0; i < smp_cpus; i++) { |
108 | 72c33dd7 | Andreas Färber | cpu = cpu_ppc_init(cpu_model); |
109 | 72c33dd7 | Andreas Färber | if (cpu == NULL) { |
110 | aaed909a | bellard | fprintf(stderr, "Unable to find PowerPC CPU definition\n");
|
111 | aaed909a | bellard | exit(1);
|
112 | aaed909a | bellard | } |
113 | 72c33dd7 | Andreas Färber | env = &cpu->env; |
114 | 72c33dd7 | Andreas Färber | |
115 | b0fb43d8 | aurel32 | /* Set time-base frequency to 16.6 Mhz */
|
116 | b0fb43d8 | aurel32 | cpu_ppc_tb_init(env, 16600000UL);
|
117 | cd79664f | Andreas Färber | qemu_register_reset(ppc_heathrow_reset, cpu); |
118 | 3cbee15b | j_mayer | } |
119 | 3cbee15b | j_mayer | |
120 | 3cbee15b | j_mayer | /* allocate RAM */
|
121 | 6b4079f8 | aurel32 | if (ram_size > (2047 << 20)) { |
122 | 6b4079f8 | aurel32 | fprintf(stderr, |
123 | 6b4079f8 | aurel32 | "qemu: Too much memory for this machine: %d MB, maximum 2047 MB\n",
|
124 | 6b4079f8 | aurel32 | ((unsigned int)ram_size / (1 << 20))); |
125 | 6b4079f8 | aurel32 | exit(1);
|
126 | 6b4079f8 | aurel32 | } |
127 | 6b4079f8 | aurel32 | |
128 | c5705a77 | Avi Kivity | memory_region_init_ram(ram, "ppc_heathrow.ram", ram_size);
|
129 | c5705a77 | Avi Kivity | vmstate_register_ram_global(ram); |
130 | c92bb2c7 | Avi Kivity | memory_region_add_subregion(sysmem, 0, ram);
|
131 | a748ab6d | aurel32 | |
132 | 3cbee15b | j_mayer | /* allocate and load BIOS */
|
133 | c5705a77 | Avi Kivity | memory_region_init_ram(bios, "ppc_heathrow.bios", BIOS_SIZE);
|
134 | c5705a77 | Avi Kivity | vmstate_register_ram_global(bios); |
135 | 3cbee15b | j_mayer | if (bios_name == NULL) |
136 | 992e5acd | blueswir1 | bios_name = PROM_FILENAME; |
137 | 5cea8590 | Paul Brook | filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); |
138 | c92bb2c7 | Avi Kivity | memory_region_set_readonly(bios, true);
|
139 | c92bb2c7 | Avi Kivity | memory_region_add_subregion(sysmem, PROM_ADDR, bios); |
140 | 992e5acd | blueswir1 | |
141 | 992e5acd | blueswir1 | /* Load OpenBIOS (ELF) */
|
142 | 5cea8590 | Paul Brook | if (filename) {
|
143 | 409dbce5 | Aurelien Jarno | bios_size = load_elf(filename, 0, NULL, NULL, NULL, NULL, |
144 | 409dbce5 | Aurelien Jarno | 1, ELF_MACHINE, 0); |
145 | 7267c094 | Anthony Liguori | g_free(filename); |
146 | 5cea8590 | Paul Brook | } else {
|
147 | 5cea8590 | Paul Brook | bios_size = -1;
|
148 | 5cea8590 | Paul Brook | } |
149 | 3cbee15b | j_mayer | if (bios_size < 0 || bios_size > BIOS_SIZE) { |
150 | 5cea8590 | Paul Brook | hw_error("qemu: could not load PowerPC bios '%s'\n", bios_name);
|
151 | 3cbee15b | j_mayer | exit(1);
|
152 | 3cbee15b | j_mayer | } |
153 | 3cbee15b | j_mayer | |
154 | 3cbee15b | j_mayer | if (linux_boot) {
|
155 | 36bee1e3 | aurel32 | uint64_t lowaddr = 0;
|
156 | ca20cf32 | Blue Swirl | int bswap_needed;
|
157 | ca20cf32 | Blue Swirl | |
158 | ca20cf32 | Blue Swirl | #ifdef BSWAP_NEEDED
|
159 | ca20cf32 | Blue Swirl | bswap_needed = 1;
|
160 | ca20cf32 | Blue Swirl | #else
|
161 | ca20cf32 | Blue Swirl | bswap_needed = 0;
|
162 | ca20cf32 | Blue Swirl | #endif
|
163 | 3cbee15b | j_mayer | kernel_base = KERNEL_LOAD_ADDR; |
164 | 409dbce5 | Aurelien Jarno | kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL,
|
165 | 409dbce5 | Aurelien Jarno | NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0); |
166 | 52f163b7 | blueswir1 | if (kernel_size < 0) |
167 | 52f163b7 | blueswir1 | kernel_size = load_aout(kernel_filename, kernel_base, |
168 | ca20cf32 | Blue Swirl | ram_size - kernel_base, bswap_needed, |
169 | ca20cf32 | Blue Swirl | TARGET_PAGE_SIZE); |
170 | 52f163b7 | blueswir1 | if (kernel_size < 0) |
171 | 52f163b7 | blueswir1 | kernel_size = load_image_targphys(kernel_filename, |
172 | 52f163b7 | blueswir1 | kernel_base, |
173 | 52f163b7 | blueswir1 | ram_size - kernel_base); |
174 | 3cbee15b | j_mayer | if (kernel_size < 0) { |
175 | 2ac71179 | Paul Brook | hw_error("qemu: could not load kernel '%s'\n",
|
176 | 3cbee15b | j_mayer | kernel_filename); |
177 | 3cbee15b | j_mayer | exit(1);
|
178 | 3cbee15b | j_mayer | } |
179 | 3cbee15b | j_mayer | /* load initrd */
|
180 | 3cbee15b | j_mayer | if (initrd_filename) {
|
181 | b9e17a34 | Alexander Graf | initrd_base = round_page(kernel_base + kernel_size + KERNEL_GAP); |
182 | dcac9679 | pbrook | initrd_size = load_image_targphys(initrd_filename, initrd_base, |
183 | dcac9679 | pbrook | ram_size - initrd_base); |
184 | 3cbee15b | j_mayer | if (initrd_size < 0) { |
185 | 2ac71179 | Paul Brook | hw_error("qemu: could not load initial ram disk '%s'\n",
|
186 | 2ac71179 | Paul Brook | initrd_filename); |
187 | 3cbee15b | j_mayer | exit(1);
|
188 | 3cbee15b | j_mayer | } |
189 | b9e17a34 | Alexander Graf | cmdline_base = round_page(initrd_base + initrd_size); |
190 | 3cbee15b | j_mayer | } else {
|
191 | 3cbee15b | j_mayer | initrd_base = 0;
|
192 | 3cbee15b | j_mayer | initrd_size = 0;
|
193 | b9e17a34 | Alexander Graf | cmdline_base = round_page(kernel_base + kernel_size + KERNEL_GAP); |
194 | 3cbee15b | j_mayer | } |
195 | 6ac0e82d | balrog | ppc_boot_device = 'm';
|
196 | 3cbee15b | j_mayer | } else {
|
197 | 3cbee15b | j_mayer | kernel_base = 0;
|
198 | 3cbee15b | j_mayer | kernel_size = 0;
|
199 | 3cbee15b | j_mayer | initrd_base = 0;
|
200 | 3cbee15b | j_mayer | initrd_size = 0;
|
201 | 28c5af54 | j_mayer | ppc_boot_device = '\0';
|
202 | 0d913fdb | j_mayer | for (i = 0; boot_device[i] != '\0'; i++) { |
203 | 28c5af54 | j_mayer | /* TOFIX: for now, the second IDE channel is not properly
|
204 | 0d913fdb | j_mayer | * used by OHW. The Mac floppy disk are not emulated.
|
205 | 28c5af54 | j_mayer | * For now, OHW cannot boot from the network.
|
206 | 28c5af54 | j_mayer | */
|
207 | 28c5af54 | j_mayer | #if 0
|
208 | 0d913fdb | j_mayer | if (boot_device[i] >= 'a' && boot_device[i] <= 'f') {
|
209 | 0d913fdb | j_mayer | ppc_boot_device = boot_device[i];
|
210 | 28c5af54 | j_mayer | break;
|
211 | 0d913fdb | j_mayer | }
|
212 | 28c5af54 | j_mayer | #else
|
213 | 0d913fdb | j_mayer | if (boot_device[i] >= 'c' && boot_device[i] <= 'd') { |
214 | 0d913fdb | j_mayer | ppc_boot_device = boot_device[i]; |
215 | 28c5af54 | j_mayer | break;
|
216 | 0d913fdb | j_mayer | } |
217 | 28c5af54 | j_mayer | #endif
|
218 | 28c5af54 | j_mayer | } |
219 | 28c5af54 | j_mayer | if (ppc_boot_device == '\0') { |
220 | 8a901def | aurel32 | fprintf(stderr, "No valid boot device for G3 Beige machine\n");
|
221 | 28c5af54 | j_mayer | exit(1);
|
222 | 28c5af54 | j_mayer | } |
223 | 3cbee15b | j_mayer | } |
224 | 3cbee15b | j_mayer | |
225 | 3cbee15b | j_mayer | /* Register 2 MB of ISA IO space */
|
226 | 968d683c | Alexander Graf | isa_mmio_init(0xfe000000, 0x00200000); |
227 | 3cbee15b | j_mayer | |
228 | 3cbee15b | j_mayer | /* XXX: we register only 1 output pin for heathrow PIC */
|
229 | 7267c094 | Anthony Liguori | heathrow_irqs = g_malloc0(smp_cpus * sizeof(qemu_irq *));
|
230 | 3cbee15b | j_mayer | heathrow_irqs[0] =
|
231 | 7267c094 | Anthony Liguori | g_malloc0(smp_cpus * sizeof(qemu_irq) * 1); |
232 | 3cbee15b | j_mayer | /* Connect the heathrow PIC outputs to the 6xx bus */
|
233 | 3cbee15b | j_mayer | for (i = 0; i < smp_cpus; i++) { |
234 | 3cbee15b | j_mayer | switch (PPC_INPUT(env)) {
|
235 | 3cbee15b | j_mayer | case PPC_FLAGS_INPUT_6xx:
|
236 | 3cbee15b | j_mayer | heathrow_irqs[i] = heathrow_irqs[0] + (i * 1); |
237 | 3cbee15b | j_mayer | heathrow_irqs[i][0] =
|
238 | 3cbee15b | j_mayer | ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT]; |
239 | 3cbee15b | j_mayer | break;
|
240 | 3cbee15b | j_mayer | default:
|
241 | 2ac71179 | Paul Brook | hw_error("Bus model not supported on OldWorld Mac machine\n");
|
242 | 3cbee15b | j_mayer | } |
243 | 3cbee15b | j_mayer | } |
244 | 3cbee15b | j_mayer | |
245 | 3cbee15b | j_mayer | /* init basic PC hardware */
|
246 | 3cbee15b | j_mayer | if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
|
247 | 2ac71179 | Paul Brook | hw_error("Only 6xx bus is supported on heathrow machine\n");
|
248 | 3cbee15b | j_mayer | } |
249 | 23c5e4ca | Avi Kivity | pic = heathrow_pic_init(&pic_mem, 1, heathrow_irqs);
|
250 | aee97b84 | Avi Kivity | pci_bus = pci_grackle_init(0xfec00000, pic,
|
251 | aee97b84 | Avi Kivity | get_system_memory(), |
252 | aee97b84 | Avi Kivity | get_system_io()); |
253 | 78895427 | Gerd Hoffmann | pci_vga_init(pci_bus); |
254 | aae9366a | j_mayer | |
255 | b39491a8 | Alexander Graf | escc_mem = escc_init(0, pic[0x0f], pic[0x10], serial_hds[0], |
256 | 7fa9ae1a | blueswir1 | serial_hds[1], ESCC_CLOCK, 4); |
257 | 5b15f275 | Avi Kivity | memory_region_init_alias(escc_bar, "escc-bar",
|
258 | 5b15f275 | Avi Kivity | escc_mem, 0, memory_region_size(escc_mem));
|
259 | aae9366a | j_mayer | |
260 | cb457d76 | aliguori | for(i = 0; i < nb_nics; i++) |
261 | 07caea31 | Markus Armbruster | pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL); |
262 | 0d913fdb | j_mayer | |
263 | e4bcb14c | ths | |
264 | 75717903 | Isaku Yamahata | ide_drive_get(hd, MAX_IDE_BUS); |
265 | bd4524ed | aurel32 | |
266 | bd4524ed | aurel32 | /* First IDE channel is a MAC IDE on the MacIO bus */
|
267 | 23c5e4ca | Avi Kivity | dbdma = DBDMA_init(&dbdma_mem); |
268 | 23c5e4ca | Avi Kivity | ide_mem[0] = NULL; |
269 | 23c5e4ca | Avi Kivity | ide_mem[1] = pmac_ide_init(hd, pic[0x0D], dbdma, 0x16, pic[0x02]); |
270 | e4bcb14c | ths | |
271 | bd4524ed | aurel32 | /* Second IDE channel is a CMD646 on the PCI bus */
|
272 | 75717903 | Isaku Yamahata | hd[0] = hd[MAX_IDE_DEVS];
|
273 | 75717903 | Isaku Yamahata | hd[1] = hd[MAX_IDE_DEVS + 1]; |
274 | bd4524ed | aurel32 | hd[3] = hd[2] = NULL; |
275 | bd4524ed | aurel32 | pci_cmd646_ide_init(pci_bus, hd, 0);
|
276 | 3cbee15b | j_mayer | |
277 | 3cbee15b | j_mayer | /* cuda also initialize ADB */
|
278 | 23c5e4ca | Avi Kivity | cuda_init(&cuda_mem, pic[0x12]);
|
279 | 3cbee15b | j_mayer | |
280 | 3cbee15b | j_mayer | adb_kbd_init(&adb_bus); |
281 | 3cbee15b | j_mayer | adb_mouse_init(&adb_bus); |
282 | aae9366a | j_mayer | |
283 | 23c5e4ca | Avi Kivity | nvr = macio_nvram_init(0x2000, 4); |
284 | 3cbee15b | j_mayer | pmac_format_nvram_partition(nvr, 0x2000);
|
285 | 3cbee15b | j_mayer | |
286 | 23c5e4ca | Avi Kivity | macio_init(pci_bus, PCI_DEVICE_ID_APPLE_343S1201, 1, pic_mem,
|
287 | 5b15f275 | Avi Kivity | dbdma_mem, cuda_mem, nvr, 2, ide_mem, escc_bar);
|
288 | 3cbee15b | j_mayer | |
289 | 3cbee15b | j_mayer | if (usb_enabled) {
|
290 | afb9a60e | Gerd Hoffmann | pci_create_simple(pci_bus, -1, "pci-ohci"); |
291 | 3cbee15b | j_mayer | } |
292 | 3cbee15b | j_mayer | |
293 | 3cbee15b | j_mayer | if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8) |
294 | 3cbee15b | j_mayer | graphic_depth = 15;
|
295 | 3cbee15b | j_mayer | |
296 | 3cbee15b | j_mayer | /* No PCI init: the BIOS will do it */
|
297 | 3cbee15b | j_mayer | |
298 | 271dd5e0 | blueswir1 | fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2); |
299 | 271dd5e0 | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
|
300 | 271dd5e0 | blueswir1 | fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); |
301 | 271dd5e0 | blueswir1 | fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_HEATHROW); |
302 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base); |
303 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); |
304 | 513f789f | blueswir1 | if (kernel_cmdline) {
|
305 | b9e17a34 | Alexander Graf | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, cmdline_base); |
306 | b9e17a34 | Alexander Graf | pstrcpy_targphys("cmdline", cmdline_base, TARGET_PAGE_SIZE, kernel_cmdline);
|
307 | 513f789f | blueswir1 | } else {
|
308 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
|
309 | 513f789f | blueswir1 | } |
310 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_base); |
311 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); |
312 | 513f789f | blueswir1 | fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ppc_boot_device); |
313 | 7f1aec5f | Laurent Vivier | |
314 | 7f1aec5f | Laurent Vivier | fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, graphic_width); |
315 | 7f1aec5f | Laurent Vivier | fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height); |
316 | 7f1aec5f | Laurent Vivier | fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth); |
317 | 7f1aec5f | Laurent Vivier | |
318 | 45024f09 | Alexander Graf | fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled()); |
319 | dc333cd6 | Alexander Graf | if (kvm_enabled()) {
|
320 | dc333cd6 | Alexander Graf | #ifdef CONFIG_KVM
|
321 | 45024f09 | Alexander Graf | uint8_t *hypercall; |
322 | 45024f09 | Alexander Graf | |
323 | dc333cd6 | Alexander Graf | fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, kvmppc_get_tbfreq()); |
324 | 7267c094 | Anthony Liguori | hypercall = g_malloc(16);
|
325 | 45024f09 | Alexander Graf | kvmppc_get_hypercall(env, hypercall, 16);
|
326 | 45024f09 | Alexander Graf | fw_cfg_add_bytes(fw_cfg, FW_CFG_PPC_KVM_HC, hypercall, 16);
|
327 | 45024f09 | Alexander Graf | fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_KVM_PID, getpid()); |
328 | dc333cd6 | Alexander Graf | #endif
|
329 | dc333cd6 | Alexander Graf | } else {
|
330 | dc333cd6 | Alexander Graf | fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, get_ticks_per_sec()); |
331 | dc333cd6 | Alexander Graf | } |
332 | dc333cd6 | Alexander Graf | |
333 | 513f789f | blueswir1 | qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); |
334 | 3cbee15b | j_mayer | } |
335 | 3cbee15b | j_mayer | |
336 | f80f9ec9 | Anthony Liguori | static QEMUMachine heathrow_machine = {
|
337 | 4d7ca41e | aurel32 | .name = "g3beige",
|
338 | 4b32e168 | aliguori | .desc = "Heathrow based PowerMAC",
|
339 | 4b32e168 | aliguori | .init = ppc_heathrow_init, |
340 | 3d878caa | balrog | .max_cpus = MAX_CPUS, |
341 | 46214a27 | Andreas Färber | #ifndef TARGET_PPC64
|
342 | 0c257437 | Anthony Liguori | .is_default = 1,
|
343 | 46214a27 | Andreas Färber | #endif
|
344 | 3cbee15b | j_mayer | }; |
345 | f80f9ec9 | Anthony Liguori | |
346 | f80f9ec9 | Anthony Liguori | static void heathrow_machine_init(void) |
347 | f80f9ec9 | Anthony Liguori | { |
348 | f80f9ec9 | Anthony Liguori | qemu_register_machine(&heathrow_machine); |
349 | f80f9ec9 | Anthony Liguori | } |
350 | f80f9ec9 | Anthony Liguori | |
351 | f80f9ec9 | Anthony Liguori | machine_init(heathrow_machine_init); |