root / hw / ppc_oldworld.c @ e6e055c9
History | View | Annotate | Download (11 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 | 28ce5ce6 | aurel32 | #include "mac_dbdma.h" |
30 | 87ecb68b | pbrook | #include "nvram.h" |
31 | 87ecb68b | pbrook | #include "pc.h" |
32 | 87ecb68b | pbrook | #include "sysemu.h" |
33 | 87ecb68b | pbrook | #include "net.h" |
34 | 87ecb68b | pbrook | #include "isa.h" |
35 | 87ecb68b | pbrook | #include "pci.h" |
36 | 18e08a55 | Michael S. Tsirkin | #include "usb-ohci.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 | 3cbee15b | j_mayer | |
47 | e4bcb14c | ths | #define MAX_IDE_BUS 2 |
48 | 271dd5e0 | blueswir1 | #define CFG_ADDR 0xf0000510 |
49 | 271dd5e0 | blueswir1 | |
50 | 513f789f | blueswir1 | static int fw_cfg_boot_set(void *opaque, const char *boot_device) |
51 | 513f789f | blueswir1 | { |
52 | 513f789f | blueswir1 | fw_cfg_add_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]);
|
53 | 513f789f | blueswir1 | return 0; |
54 | 513f789f | blueswir1 | } |
55 | 513f789f | blueswir1 | |
56 | 409dbce5 | Aurelien Jarno | |
57 | 409dbce5 | Aurelien Jarno | static uint64_t translate_kernel_address(void *opaque, uint64_t addr) |
58 | 409dbce5 | Aurelien Jarno | { |
59 | 409dbce5 | Aurelien Jarno | return (addr & 0x0fffffff) + KERNEL_LOAD_ADDR; |
60 | 409dbce5 | Aurelien Jarno | } |
61 | 409dbce5 | Aurelien Jarno | |
62 | c227f099 | Anthony Liguori | static void ppc_heathrow_init (ram_addr_t ram_size, |
63 | 3023f332 | aliguori | const char *boot_device, |
64 | 3cbee15b | j_mayer | const char *kernel_filename, |
65 | 3cbee15b | j_mayer | const char *kernel_cmdline, |
66 | 3cbee15b | j_mayer | const char *initrd_filename, |
67 | 3cbee15b | j_mayer | const char *cpu_model) |
68 | 3cbee15b | j_mayer | { |
69 | 49a2942d | Blue Swirl | CPUState *env = NULL;
|
70 | 5cea8590 | Paul Brook | char *filename;
|
71 | 3cbee15b | j_mayer | qemu_irq *pic, **heathrow_irqs; |
72 | 3cbee15b | j_mayer | int linux_boot, i;
|
73 | ae0bfb79 | Blue Swirl | ram_addr_t ram_offset, bios_offset; |
74 | 7373048c | blueswir1 | uint32_t kernel_base, initrd_base; |
75 | 7373048c | blueswir1 | int32_t kernel_size, initrd_size; |
76 | 3cbee15b | j_mayer | PCIBus *pci_bus; |
77 | 3cbee15b | j_mayer | MacIONVRAMState *nvr; |
78 | ae0bfb79 | Blue Swirl | int bios_size;
|
79 | 3cbee15b | j_mayer | int pic_mem_index, nvram_mem_index, dbdma_mem_index, cuda_mem_index;
|
80 | 7fa9ae1a | blueswir1 | int escc_mem_index, ide_mem_index[2]; |
81 | 513f789f | blueswir1 | uint16_t ppc_boot_device; |
82 | f455e98c | Gerd Hoffmann | DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
83 | 271dd5e0 | blueswir1 | void *fw_cfg;
|
84 | 28ce5ce6 | aurel32 | void *dbdma;
|
85 | 3cbee15b | j_mayer | |
86 | 3cbee15b | j_mayer | linux_boot = (kernel_filename != NULL);
|
87 | 3cbee15b | j_mayer | |
88 | 3cbee15b | j_mayer | /* init CPUs */
|
89 | 3cbee15b | j_mayer | if (cpu_model == NULL) |
90 | f2fde45a | aurel32 | cpu_model = "G3";
|
91 | 3cbee15b | j_mayer | for (i = 0; i < smp_cpus; i++) { |
92 | aaed909a | bellard | env = cpu_init(cpu_model); |
93 | aaed909a | bellard | if (!env) {
|
94 | aaed909a | bellard | fprintf(stderr, "Unable to find PowerPC CPU definition\n");
|
95 | aaed909a | bellard | exit(1);
|
96 | aaed909a | bellard | } |
97 | b0fb43d8 | aurel32 | /* Set time-base frequency to 16.6 Mhz */
|
98 | b0fb43d8 | aurel32 | cpu_ppc_tb_init(env, 16600000UL);
|
99 | d84bda46 | Blue Swirl | qemu_register_reset((QEMUResetHandler*)&cpu_reset, env); |
100 | 3cbee15b | j_mayer | } |
101 | 3cbee15b | j_mayer | |
102 | 3cbee15b | j_mayer | /* allocate RAM */
|
103 | 6b4079f8 | aurel32 | if (ram_size > (2047 << 20)) { |
104 | 6b4079f8 | aurel32 | fprintf(stderr, |
105 | 6b4079f8 | aurel32 | "qemu: Too much memory for this machine: %d MB, maximum 2047 MB\n",
|
106 | 6b4079f8 | aurel32 | ((unsigned int)ram_size / (1 << 20))); |
107 | 6b4079f8 | aurel32 | exit(1);
|
108 | 6b4079f8 | aurel32 | } |
109 | 6b4079f8 | aurel32 | |
110 | 1724f049 | Alex Williamson | ram_offset = qemu_ram_alloc(NULL, "ppc_heathrow.ram", ram_size); |
111 | a748ab6d | aurel32 | cpu_register_physical_memory(0, ram_size, ram_offset);
|
112 | a748ab6d | aurel32 | |
113 | 3cbee15b | j_mayer | /* allocate and load BIOS */
|
114 | 1724f049 | Alex Williamson | bios_offset = qemu_ram_alloc(NULL, "ppc_heathrow.bios", BIOS_SIZE); |
115 | 3cbee15b | j_mayer | if (bios_name == NULL) |
116 | 992e5acd | blueswir1 | bios_name = PROM_FILENAME; |
117 | 5cea8590 | Paul Brook | filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); |
118 | 992e5acd | blueswir1 | cpu_register_physical_memory(PROM_ADDR, BIOS_SIZE, bios_offset | IO_MEM_ROM); |
119 | 992e5acd | blueswir1 | |
120 | 992e5acd | blueswir1 | /* Load OpenBIOS (ELF) */
|
121 | 5cea8590 | Paul Brook | if (filename) {
|
122 | 409dbce5 | Aurelien Jarno | bios_size = load_elf(filename, 0, NULL, NULL, NULL, NULL, |
123 | 409dbce5 | Aurelien Jarno | 1, ELF_MACHINE, 0); |
124 | 5cea8590 | Paul Brook | qemu_free(filename); |
125 | 5cea8590 | Paul Brook | } else {
|
126 | 5cea8590 | Paul Brook | bios_size = -1;
|
127 | 5cea8590 | Paul Brook | } |
128 | 3cbee15b | j_mayer | if (bios_size < 0 || bios_size > BIOS_SIZE) { |
129 | 5cea8590 | Paul Brook | hw_error("qemu: could not load PowerPC bios '%s'\n", bios_name);
|
130 | 3cbee15b | j_mayer | exit(1);
|
131 | 3cbee15b | j_mayer | } |
132 | 3cbee15b | j_mayer | |
133 | 3cbee15b | j_mayer | if (linux_boot) {
|
134 | 36bee1e3 | aurel32 | uint64_t lowaddr = 0;
|
135 | ca20cf32 | Blue Swirl | int bswap_needed;
|
136 | ca20cf32 | Blue Swirl | |
137 | ca20cf32 | Blue Swirl | #ifdef BSWAP_NEEDED
|
138 | ca20cf32 | Blue Swirl | bswap_needed = 1;
|
139 | ca20cf32 | Blue Swirl | #else
|
140 | ca20cf32 | Blue Swirl | bswap_needed = 0;
|
141 | ca20cf32 | Blue Swirl | #endif
|
142 | 3cbee15b | j_mayer | kernel_base = KERNEL_LOAD_ADDR; |
143 | 409dbce5 | Aurelien Jarno | kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL,
|
144 | 409dbce5 | Aurelien Jarno | NULL, &lowaddr, NULL, 1, ELF_MACHINE, 0); |
145 | 52f163b7 | blueswir1 | if (kernel_size < 0) |
146 | 52f163b7 | blueswir1 | kernel_size = load_aout(kernel_filename, kernel_base, |
147 | ca20cf32 | Blue Swirl | ram_size - kernel_base, bswap_needed, |
148 | ca20cf32 | Blue Swirl | TARGET_PAGE_SIZE); |
149 | 52f163b7 | blueswir1 | if (kernel_size < 0) |
150 | 52f163b7 | blueswir1 | kernel_size = load_image_targphys(kernel_filename, |
151 | 52f163b7 | blueswir1 | kernel_base, |
152 | 52f163b7 | blueswir1 | ram_size - kernel_base); |
153 | 3cbee15b | j_mayer | if (kernel_size < 0) { |
154 | 2ac71179 | Paul Brook | hw_error("qemu: could not load kernel '%s'\n",
|
155 | 3cbee15b | j_mayer | kernel_filename); |
156 | 3cbee15b | j_mayer | exit(1);
|
157 | 3cbee15b | j_mayer | } |
158 | 3cbee15b | j_mayer | /* load initrd */
|
159 | 3cbee15b | j_mayer | if (initrd_filename) {
|
160 | 3cbee15b | j_mayer | initrd_base = INITRD_LOAD_ADDR; |
161 | dcac9679 | pbrook | initrd_size = load_image_targphys(initrd_filename, initrd_base, |
162 | dcac9679 | pbrook | ram_size - initrd_base); |
163 | 3cbee15b | j_mayer | if (initrd_size < 0) { |
164 | 2ac71179 | Paul Brook | hw_error("qemu: could not load initial ram disk '%s'\n",
|
165 | 2ac71179 | Paul Brook | initrd_filename); |
166 | 3cbee15b | j_mayer | exit(1);
|
167 | 3cbee15b | j_mayer | } |
168 | 3cbee15b | j_mayer | } else {
|
169 | 3cbee15b | j_mayer | initrd_base = 0;
|
170 | 3cbee15b | j_mayer | initrd_size = 0;
|
171 | 3cbee15b | j_mayer | } |
172 | 6ac0e82d | balrog | ppc_boot_device = 'm';
|
173 | 3cbee15b | j_mayer | } else {
|
174 | 3cbee15b | j_mayer | kernel_base = 0;
|
175 | 3cbee15b | j_mayer | kernel_size = 0;
|
176 | 3cbee15b | j_mayer | initrd_base = 0;
|
177 | 3cbee15b | j_mayer | initrd_size = 0;
|
178 | 28c5af54 | j_mayer | ppc_boot_device = '\0';
|
179 | 0d913fdb | j_mayer | for (i = 0; boot_device[i] != '\0'; i++) { |
180 | 28c5af54 | j_mayer | /* TOFIX: for now, the second IDE channel is not properly
|
181 | 0d913fdb | j_mayer | * used by OHW. The Mac floppy disk are not emulated.
|
182 | 28c5af54 | j_mayer | * For now, OHW cannot boot from the network.
|
183 | 28c5af54 | j_mayer | */
|
184 | 28c5af54 | j_mayer | #if 0
|
185 | 0d913fdb | j_mayer | if (boot_device[i] >= 'a' && boot_device[i] <= 'f') {
|
186 | 0d913fdb | j_mayer | ppc_boot_device = boot_device[i];
|
187 | 28c5af54 | j_mayer | break;
|
188 | 0d913fdb | j_mayer | }
|
189 | 28c5af54 | j_mayer | #else
|
190 | 0d913fdb | j_mayer | if (boot_device[i] >= 'c' && boot_device[i] <= 'd') { |
191 | 0d913fdb | j_mayer | ppc_boot_device = boot_device[i]; |
192 | 28c5af54 | j_mayer | break;
|
193 | 0d913fdb | j_mayer | } |
194 | 28c5af54 | j_mayer | #endif
|
195 | 28c5af54 | j_mayer | } |
196 | 28c5af54 | j_mayer | if (ppc_boot_device == '\0') { |
197 | 8a901def | aurel32 | fprintf(stderr, "No valid boot device for G3 Beige machine\n");
|
198 | 28c5af54 | j_mayer | exit(1);
|
199 | 28c5af54 | j_mayer | } |
200 | 3cbee15b | j_mayer | } |
201 | 3cbee15b | j_mayer | |
202 | 3cbee15b | j_mayer | isa_mem_base = 0x80000000;
|
203 | aae9366a | j_mayer | |
204 | 3cbee15b | j_mayer | /* Register 2 MB of ISA IO space */
|
205 | 84108e12 | Blue Swirl | isa_mmio_init(0xfe000000, 0x00200000, 1); |
206 | 3cbee15b | j_mayer | |
207 | 3cbee15b | j_mayer | /* XXX: we register only 1 output pin for heathrow PIC */
|
208 | 3cbee15b | j_mayer | heathrow_irqs = qemu_mallocz(smp_cpus * sizeof(qemu_irq *));
|
209 | 3cbee15b | j_mayer | heathrow_irqs[0] =
|
210 | 3cbee15b | j_mayer | qemu_mallocz(smp_cpus * sizeof(qemu_irq) * 1); |
211 | 3cbee15b | j_mayer | /* Connect the heathrow PIC outputs to the 6xx bus */
|
212 | 3cbee15b | j_mayer | for (i = 0; i < smp_cpus; i++) { |
213 | 3cbee15b | j_mayer | switch (PPC_INPUT(env)) {
|
214 | 3cbee15b | j_mayer | case PPC_FLAGS_INPUT_6xx:
|
215 | 3cbee15b | j_mayer | heathrow_irqs[i] = heathrow_irqs[0] + (i * 1); |
216 | 3cbee15b | j_mayer | heathrow_irqs[i][0] =
|
217 | 3cbee15b | j_mayer | ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT]; |
218 | 3cbee15b | j_mayer | break;
|
219 | 3cbee15b | j_mayer | default:
|
220 | 2ac71179 | Paul Brook | hw_error("Bus model not supported on OldWorld Mac machine\n");
|
221 | 3cbee15b | j_mayer | } |
222 | 3cbee15b | j_mayer | } |
223 | 3cbee15b | j_mayer | |
224 | 3cbee15b | j_mayer | /* init basic PC hardware */
|
225 | 3cbee15b | j_mayer | if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
|
226 | 2ac71179 | Paul Brook | hw_error("Only 6xx bus is supported on heathrow machine\n");
|
227 | 3cbee15b | j_mayer | } |
228 | 3cbee15b | j_mayer | pic = heathrow_pic_init(&pic_mem_index, 1, heathrow_irqs);
|
229 | 3cbee15b | j_mayer | pci_bus = pci_grackle_init(0xfec00000, pic);
|
230 | 78895427 | Gerd Hoffmann | pci_vga_init(pci_bus); |
231 | aae9366a | j_mayer | |
232 | aeeb69c7 | aurel32 | escc_mem_index = escc_init(0x80013000, pic[0x0f], pic[0x10], serial_hds[0], |
233 | 7fa9ae1a | blueswir1 | serial_hds[1], ESCC_CLOCK, 4); |
234 | aae9366a | j_mayer | |
235 | cb457d76 | aliguori | for(i = 0; i < nb_nics; i++) |
236 | 07caea31 | Markus Armbruster | pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL); |
237 | 0d913fdb | j_mayer | |
238 | e4bcb14c | ths | |
239 | e4bcb14c | ths | if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
|
240 | e4bcb14c | ths | fprintf(stderr, "qemu: too many IDE bus\n");
|
241 | e4bcb14c | ths | exit(1);
|
242 | e4bcb14c | ths | } |
243 | bd4524ed | aurel32 | |
244 | bd4524ed | aurel32 | /* First IDE channel is a MAC IDE on the MacIO bus */
|
245 | f455e98c | Gerd Hoffmann | hd[0] = drive_get(IF_IDE, 0, 0); |
246 | f455e98c | Gerd Hoffmann | hd[1] = drive_get(IF_IDE, 0, 1); |
247 | bd4524ed | aurel32 | dbdma = DBDMA_init(&dbdma_mem_index); |
248 | bd4524ed | aurel32 | ide_mem_index[0] = -1; |
249 | bd4524ed | aurel32 | ide_mem_index[1] = pmac_ide_init(hd, pic[0x0D], dbdma, 0x16, pic[0x02]); |
250 | e4bcb14c | ths | |
251 | bd4524ed | aurel32 | /* Second IDE channel is a CMD646 on the PCI bus */
|
252 | f455e98c | Gerd Hoffmann | hd[0] = drive_get(IF_IDE, 1, 0); |
253 | f455e98c | Gerd Hoffmann | hd[1] = drive_get(IF_IDE, 1, 1); |
254 | bd4524ed | aurel32 | hd[3] = hd[2] = NULL; |
255 | bd4524ed | aurel32 | pci_cmd646_ide_init(pci_bus, hd, 0);
|
256 | 3cbee15b | j_mayer | |
257 | 3cbee15b | j_mayer | /* cuda also initialize ADB */
|
258 | 3cbee15b | j_mayer | cuda_init(&cuda_mem_index, pic[0x12]);
|
259 | 3cbee15b | j_mayer | |
260 | 3cbee15b | j_mayer | adb_kbd_init(&adb_bus); |
261 | 3cbee15b | j_mayer | adb_mouse_init(&adb_bus); |
262 | aae9366a | j_mayer | |
263 | 68af3f24 | blueswir1 | nvr = macio_nvram_init(&nvram_mem_index, 0x2000, 4); |
264 | 3cbee15b | j_mayer | pmac_format_nvram_partition(nvr, 0x2000);
|
265 | 3cbee15b | j_mayer | |
266 | 4ebcf884 | blueswir1 | macio_init(pci_bus, PCI_DEVICE_ID_APPLE_343S1201, 1, pic_mem_index,
|
267 | 4ebcf884 | blueswir1 | dbdma_mem_index, cuda_mem_index, nvr, 2, ide_mem_index,
|
268 | 4ebcf884 | blueswir1 | escc_mem_index); |
269 | 3cbee15b | j_mayer | |
270 | 3cbee15b | j_mayer | if (usb_enabled) {
|
271 | a67ba3b6 | Paul Brook | usb_ohci_init_pci(pci_bus, -1);
|
272 | 3cbee15b | j_mayer | } |
273 | 3cbee15b | j_mayer | |
274 | 3cbee15b | j_mayer | if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8) |
275 | 3cbee15b | j_mayer | graphic_depth = 15;
|
276 | 3cbee15b | j_mayer | |
277 | 3cbee15b | j_mayer | /* No PCI init: the BIOS will do it */
|
278 | 3cbee15b | j_mayer | |
279 | 271dd5e0 | blueswir1 | fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2); |
280 | 271dd5e0 | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
|
281 | 271dd5e0 | blueswir1 | fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); |
282 | 271dd5e0 | blueswir1 | fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_HEATHROW); |
283 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base); |
284 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); |
285 | 513f789f | blueswir1 | if (kernel_cmdline) {
|
286 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR); |
287 | 3c178e72 | Gerd Hoffmann | pstrcpy_targphys("cmdline", CMDLINE_ADDR, TARGET_PAGE_SIZE, kernel_cmdline);
|
288 | 513f789f | blueswir1 | } else {
|
289 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
|
290 | 513f789f | blueswir1 | } |
291 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_base); |
292 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); |
293 | 513f789f | blueswir1 | fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ppc_boot_device); |
294 | 7f1aec5f | Laurent Vivier | |
295 | 7f1aec5f | Laurent Vivier | fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, graphic_width); |
296 | 7f1aec5f | Laurent Vivier | fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height); |
297 | 7f1aec5f | Laurent Vivier | fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth); |
298 | 7f1aec5f | Laurent Vivier | |
299 | 45024f09 | Alexander Graf | fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled()); |
300 | dc333cd6 | Alexander Graf | if (kvm_enabled()) {
|
301 | dc333cd6 | Alexander Graf | #ifdef CONFIG_KVM
|
302 | 45024f09 | Alexander Graf | uint8_t *hypercall; |
303 | 45024f09 | Alexander Graf | |
304 | dc333cd6 | Alexander Graf | fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, kvmppc_get_tbfreq()); |
305 | 45024f09 | Alexander Graf | hypercall = qemu_malloc(16);
|
306 | 45024f09 | Alexander Graf | kvmppc_get_hypercall(env, hypercall, 16);
|
307 | 45024f09 | Alexander Graf | fw_cfg_add_bytes(fw_cfg, FW_CFG_PPC_KVM_HC, hypercall, 16);
|
308 | 45024f09 | Alexander Graf | fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_KVM_PID, getpid()); |
309 | dc333cd6 | Alexander Graf | #endif
|
310 | dc333cd6 | Alexander Graf | } else {
|
311 | dc333cd6 | Alexander Graf | fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, get_ticks_per_sec()); |
312 | dc333cd6 | Alexander Graf | } |
313 | dc333cd6 | Alexander Graf | |
314 | 513f789f | blueswir1 | qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); |
315 | 3cbee15b | j_mayer | } |
316 | 3cbee15b | j_mayer | |
317 | f80f9ec9 | Anthony Liguori | static QEMUMachine heathrow_machine = {
|
318 | 4d7ca41e | aurel32 | .name = "g3beige",
|
319 | 4b32e168 | aliguori | .desc = "Heathrow based PowerMAC",
|
320 | 4b32e168 | aliguori | .init = ppc_heathrow_init, |
321 | 3d878caa | balrog | .max_cpus = MAX_CPUS, |
322 | 46214a27 | Andreas Färber | #ifndef TARGET_PPC64
|
323 | 0c257437 | Anthony Liguori | .is_default = 1,
|
324 | 46214a27 | Andreas Färber | #endif
|
325 | 3cbee15b | j_mayer | }; |
326 | f80f9ec9 | Anthony Liguori | |
327 | f80f9ec9 | Anthony Liguori | static void heathrow_machine_init(void) |
328 | f80f9ec9 | Anthony Liguori | { |
329 | f80f9ec9 | Anthony Liguori | qemu_register_machine(&heathrow_machine); |
330 | f80f9ec9 | Anthony Liguori | } |
331 | f80f9ec9 | Anthony Liguori | |
332 | f80f9ec9 | Anthony Liguori | machine_init(heathrow_machine_init); |