Set SS-5 IOMMU version to Turbosparc to match default CPU (Robert Reif)
[qemu] / hw / sun4m.c
1 /*
2  * QEMU Sun4m & Sun4d & Sun4c System Emulator
3  *
4  * Copyright (c) 2003-2005 Fabrice Bellard
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 #include "hw.h"
25 #include "qemu-timer.h"
26 #include "sun4m.h"
27 #include "nvram.h"
28 #include "sparc32_dma.h"
29 #include "fdc.h"
30 #include "sysemu.h"
31 #include "net.h"
32 #include "boards.h"
33 #include "firmware_abi.h"
34
35 //#define DEBUG_IRQ
36
37 /*
38  * Sun4m architecture was used in the following machines:
39  *
40  * SPARCserver 6xxMP/xx
41  * SPARCclassic (SPARCclassic Server)(SPARCstation LC) (4/15), SPARCclassic X (4/10)
42  * SPARCstation LX/ZX (4/30)
43  * SPARCstation Voyager
44  * SPARCstation 10/xx, SPARCserver 10/xx
45  * SPARCstation 5, SPARCserver 5
46  * SPARCstation 20/xx, SPARCserver 20
47  * SPARCstation 4
48  *
49  * Sun4d architecture was used in the following machines:
50  *
51  * SPARCcenter 2000
52  * SPARCserver 1000
53  *
54  * Sun4c architecture was used in the following machines:
55  * SPARCstation 1/1+, SPARCserver 1/1+
56  * SPARCstation SLC
57  * SPARCstation IPC
58  * SPARCstation ELC
59  * SPARCstation IPX
60  *
61  * See for example: http://www.sunhelp.org/faq/sunref1.html
62  */
63
64 #ifdef DEBUG_IRQ
65 #define DPRINTF(fmt, args...)                           \
66     do { printf("CPUIRQ: " fmt , ##args); } while (0)
67 #else
68 #define DPRINTF(fmt, args...)
69 #endif
70
71 #define KERNEL_LOAD_ADDR     0x00004000
72 #define CMDLINE_ADDR         0x007ff000
73 #define INITRD_LOAD_ADDR     0x00800000
74 #define PROM_SIZE_MAX        (512 * 1024)
75 #define PROM_VADDR           0xffd00000
76 #define PROM_FILENAME        "openbios-sparc32"
77
78 #define MAX_CPUS 16
79 #define MAX_PILS 16
80
81 struct hwdef {
82     target_phys_addr_t iommu_base, slavio_base;
83     target_phys_addr_t intctl_base, counter_base, nvram_base, ms_kb_base;
84     target_phys_addr_t serial_base, fd_base;
85     target_phys_addr_t idreg_base, dma_base, esp_base, le_base;
86     target_phys_addr_t tcx_base, cs_base, power_base;
87     target_phys_addr_t ecc_base;
88     uint32_t ecc_version;
89     target_phys_addr_t sun4c_intctl_base, sun4c_counter_base;
90     long vram_size, nvram_size;
91     // IRQ numbers are not PIL ones, but master interrupt controller register
92     // bit numbers
93     int intctl_g_intr, esp_irq, le_irq, clock_irq, clock1_irq;
94     int ser_irq, ms_kb_irq, fd_irq, me_irq, cs_irq;
95     int machine_id; // For NVRAM
96     uint32_t iommu_version;
97     uint32_t intbit_to_level[32];
98     uint64_t max_mem;
99     const char * const default_cpu_model;
100 };
101
102 #define MAX_IOUNITS 5
103
104 struct sun4d_hwdef {
105     target_phys_addr_t iounit_bases[MAX_IOUNITS], slavio_base;
106     target_phys_addr_t counter_base, nvram_base, ms_kb_base;
107     target_phys_addr_t serial_base;
108     target_phys_addr_t espdma_base, esp_base;
109     target_phys_addr_t ledma_base, le_base;
110     target_phys_addr_t tcx_base;
111     target_phys_addr_t sbi_base;
112     unsigned long vram_size, nvram_size;
113     // IRQ numbers are not PIL ones, but SBI register bit numbers
114     int esp_irq, le_irq, clock_irq, clock1_irq;
115     int ser_irq, ms_kb_irq, me_irq;
116     int machine_id; // For NVRAM
117     uint32_t iounit_version;
118     uint64_t max_mem;
119     const char * const default_cpu_model;
120 };
121
122 /* TSC handling */
123
124 uint64_t cpu_get_tsc()
125 {
126     return qemu_get_clock(vm_clock);
127 }
128
129 int DMA_get_channel_mode (int nchan)
130 {
131     return 0;
132 }
133 int DMA_read_memory (int nchan, void *buf, int pos, int size)
134 {
135     return 0;
136 }
137 int DMA_write_memory (int nchan, void *buf, int pos, int size)
138 {
139     return 0;
140 }
141 void DMA_hold_DREQ (int nchan) {}
142 void DMA_release_DREQ (int nchan) {}
143 void DMA_schedule(int nchan) {}
144 void DMA_run (void) {}
145 void DMA_init (int high_page_enable) {}
146 void DMA_register_channel (int nchan,
147                            DMA_transfer_handler transfer_handler,
148                            void *opaque)
149 {
150 }
151
152 extern int nographic;
153
154 static void nvram_init(m48t59_t *nvram, uint8_t *macaddr, const char *cmdline,
155                        const char *boot_devices, uint32_t RAM_size,
156                        uint32_t kernel_size,
157                        int width, int height, int depth,
158                        int machine_id, const char *arch)
159 {
160     unsigned int i;
161     uint32_t start, end;
162     uint8_t image[0x1ff0];
163     ohwcfg_v3_t *header = (ohwcfg_v3_t *)ℑ
164     struct sparc_arch_cfg *sparc_header;
165     struct OpenBIOS_nvpart_v1 *part_header;
166
167     memset(image, '\0', sizeof(image));
168
169     // Try to match PPC NVRAM
170     strcpy(header->struct_ident, "QEMU_BIOS");
171     header->struct_version = cpu_to_be32(3); /* structure v3 */
172
173     header->nvram_size = cpu_to_be16(0x2000);
174     header->nvram_arch_ptr = cpu_to_be16(sizeof(ohwcfg_v3_t));
175     header->nvram_arch_size = cpu_to_be16(sizeof(struct sparc_arch_cfg));
176     strcpy(header->arch, arch);
177     header->nb_cpus = smp_cpus & 0xff;
178     header->RAM0_base = 0;
179     header->RAM0_size = cpu_to_be64((uint64_t)RAM_size);
180     strcpy(header->boot_devices, boot_devices);
181     header->nboot_devices = strlen(boot_devices) & 0xff;
182     header->kernel_image = cpu_to_be64((uint64_t)KERNEL_LOAD_ADDR);
183     header->kernel_size = cpu_to_be64((uint64_t)kernel_size);
184     if (cmdline) {
185         strcpy(phys_ram_base + CMDLINE_ADDR, cmdline);
186         header->cmdline = cpu_to_be64((uint64_t)CMDLINE_ADDR);
187         header->cmdline_size = cpu_to_be64((uint64_t)strlen(cmdline));
188     }
189     // XXX add initrd_image, initrd_size
190     header->width = cpu_to_be16(width);
191     header->height = cpu_to_be16(height);
192     header->depth = cpu_to_be16(depth);
193     if (nographic)
194         header->graphic_flags = cpu_to_be16(OHW_GF_NOGRAPHICS);
195
196     header->crc = cpu_to_be16(OHW_compute_crc(header, 0x00, 0xF8));
197
198     // Architecture specific header
199     start = sizeof(ohwcfg_v3_t);
200     sparc_header = (struct sparc_arch_cfg *)&image[start];
201     sparc_header->valid = 0;
202     start += sizeof(struct sparc_arch_cfg);
203
204     // OpenBIOS nvram variables
205     // Variable partition
206     part_header = (struct OpenBIOS_nvpart_v1 *)&image[start];
207     part_header->signature = OPENBIOS_PART_SYSTEM;
208     strcpy(part_header->name, "system");
209
210     end = start + sizeof(struct OpenBIOS_nvpart_v1);
211     for (i = 0; i < nb_prom_envs; i++)
212         end = OpenBIOS_set_var(image, end, prom_envs[i]);
213
214     // End marker
215     image[end++] = '\0';
216
217     end = start + ((end - start + 15) & ~15);
218     OpenBIOS_finish_partition(part_header, end - start);
219
220     // free partition
221     start = end;
222     part_header = (struct OpenBIOS_nvpart_v1 *)&image[start];
223     part_header->signature = OPENBIOS_PART_FREE;
224     strcpy(part_header->name, "free");
225
226     end = 0x1fd0;
227     OpenBIOS_finish_partition(part_header, end - start);
228
229     Sun_init_header((struct Sun_nvram *)&image[0x1fd8], macaddr, machine_id);
230
231     for (i = 0; i < sizeof(image); i++)
232         m48t59_write(nvram, i, image[i]);
233 }
234
235 static void *slavio_intctl;
236
237 void pic_info()
238 {
239     if (slavio_intctl)
240         slavio_pic_info(slavio_intctl);
241 }
242
243 void irq_info()
244 {
245     if (slavio_intctl)
246         slavio_irq_info(slavio_intctl);
247 }
248
249 void cpu_check_irqs(CPUState *env)
250 {
251     if (env->pil_in && (env->interrupt_index == 0 ||
252                         (env->interrupt_index & ~15) == TT_EXTINT)) {
253         unsigned int i;
254
255         for (i = 15; i > 0; i--) {
256             if (env->pil_in & (1 << i)) {
257                 int old_interrupt = env->interrupt_index;
258
259                 env->interrupt_index = TT_EXTINT | i;
260                 if (old_interrupt != env->interrupt_index)
261                     cpu_interrupt(env, CPU_INTERRUPT_HARD);
262                 break;
263             }
264         }
265     } else if (!env->pil_in && (env->interrupt_index & ~15) == TT_EXTINT) {
266         env->interrupt_index = 0;
267         cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
268     }
269 }
270
271 static void cpu_set_irq(void *opaque, int irq, int level)
272 {
273     CPUState *env = opaque;
274
275     if (level) {
276         DPRINTF("Raise CPU IRQ %d\n", irq);
277         env->halted = 0;
278         env->pil_in |= 1 << irq;
279         cpu_check_irqs(env);
280     } else {
281         DPRINTF("Lower CPU IRQ %d\n", irq);
282         env->pil_in &= ~(1 << irq);
283         cpu_check_irqs(env);
284     }
285 }
286
287 static void dummy_cpu_set_irq(void *opaque, int irq, int level)
288 {
289 }
290
291 static void *slavio_misc;
292
293 void qemu_system_powerdown(void)
294 {
295     slavio_set_power_fail(slavio_misc, 1);
296 }
297
298 static void main_cpu_reset(void *opaque)
299 {
300     CPUState *env = opaque;
301
302     cpu_reset(env);
303     env->halted = 0;
304 }
305
306 static void secondary_cpu_reset(void *opaque)
307 {
308     CPUState *env = opaque;
309
310     cpu_reset(env);
311     env->halted = 1;
312 }
313
314 static unsigned long sun4m_load_kernel(const char *kernel_filename,
315                                        const char *kernel_cmdline,
316                                        const char *initrd_filename)
317 {
318     int linux_boot;
319     unsigned int i;
320     long initrd_size, kernel_size;
321
322     linux_boot = (kernel_filename != NULL);
323
324     kernel_size = 0;
325     if (linux_boot) {
326         kernel_size = load_elf(kernel_filename, -0xf0000000ULL, NULL, NULL,
327                                NULL);
328         if (kernel_size < 0)
329             kernel_size = load_aout(kernel_filename, phys_ram_base + KERNEL_LOAD_ADDR);
330         if (kernel_size < 0)
331             kernel_size = load_image(kernel_filename, phys_ram_base + KERNEL_LOAD_ADDR);
332         if (kernel_size < 0) {
333             fprintf(stderr, "qemu: could not load kernel '%s'\n",
334                     kernel_filename);
335             exit(1);
336         }
337
338         /* load initrd */
339         initrd_size = 0;
340         if (initrd_filename) {
341             initrd_size = load_image(initrd_filename, phys_ram_base + INITRD_LOAD_ADDR);
342             if (initrd_size < 0) {
343                 fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
344                         initrd_filename);
345                 exit(1);
346             }
347         }
348         if (initrd_size > 0) {
349             for (i = 0; i < 64 * TARGET_PAGE_SIZE; i += TARGET_PAGE_SIZE) {
350                 if (ldl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i)
351                     == 0x48647253) { // HdrS
352                     stl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i + 16, INITRD_LOAD_ADDR);
353                     stl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i + 20, initrd_size);
354                     break;
355                 }
356             }
357         }
358     }
359     return kernel_size;
360 }
361
362 static void sun4m_hw_init(const struct hwdef *hwdef, int RAM_size,
363                           const char *boot_device,
364                           DisplayState *ds, const char *kernel_filename,
365                           const char *kernel_cmdline,
366                           const char *initrd_filename, const char *cpu_model)
367
368 {
369     CPUState *env, *envs[MAX_CPUS];
370     unsigned int i;
371     void *iommu, *espdma, *ledma, *main_esp, *nvram;
372     qemu_irq *cpu_irqs[MAX_CPUS], *slavio_irq, *slavio_cpu_irq,
373         *espdma_irq, *ledma_irq;
374     qemu_irq *esp_reset, *le_reset;
375     unsigned long prom_offset, kernel_size;
376     int ret;
377     char buf[1024];
378     BlockDriverState *fd[MAX_FD];
379     int index;
380
381     /* init CPUs */
382     if (!cpu_model)
383         cpu_model = hwdef->default_cpu_model;
384
385     for(i = 0; i < smp_cpus; i++) {
386         env = cpu_init(cpu_model);
387         if (!env) {
388             fprintf(stderr, "Unable to find Sparc CPU definition\n");
389             exit(1);
390         }
391         cpu_sparc_set_id(env, i);
392         envs[i] = env;
393         if (i == 0) {
394             qemu_register_reset(main_cpu_reset, env);
395         } else {
396             qemu_register_reset(secondary_cpu_reset, env);
397             env->halted = 1;
398         }
399         register_savevm("cpu", i, 3, cpu_save, cpu_load, env);
400         cpu_irqs[i] = qemu_allocate_irqs(cpu_set_irq, envs[i], MAX_PILS);
401         env->prom_addr = hwdef->slavio_base;
402     }
403
404     for (i = smp_cpus; i < MAX_CPUS; i++)
405         cpu_irqs[i] = qemu_allocate_irqs(dummy_cpu_set_irq, NULL, MAX_PILS);
406
407
408     /* allocate RAM */
409     if ((uint64_t)RAM_size > hwdef->max_mem) {
410         fprintf(stderr, "qemu: Too much memory for this machine: %d, maximum %d\n",
411                 (unsigned int)RAM_size / (1024 * 1024),
412                 (unsigned int)(hwdef->max_mem / (1024 * 1024)));
413         exit(1);
414     }
415     cpu_register_physical_memory(0, RAM_size, 0);
416
417     /* load boot prom */
418     prom_offset = RAM_size + hwdef->vram_size;
419     cpu_register_physical_memory(hwdef->slavio_base,
420                                  (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) &
421                                  TARGET_PAGE_MASK,
422                                  prom_offset | IO_MEM_ROM);
423
424     if (bios_name == NULL)
425         bios_name = PROM_FILENAME;
426     snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
427     ret = load_elf(buf, hwdef->slavio_base - PROM_VADDR, NULL, NULL, NULL);
428     if (ret < 0 || ret > PROM_SIZE_MAX)
429         ret = load_image(buf, phys_ram_base + prom_offset);
430     if (ret < 0 || ret > PROM_SIZE_MAX) {
431         fprintf(stderr, "qemu: could not load prom '%s'\n",
432                 buf);
433         exit(1);
434     }
435     prom_offset += (ret + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK;
436
437     /* set up devices */
438     iommu = iommu_init(hwdef->iommu_base, hwdef->iommu_version);
439     slavio_intctl = slavio_intctl_init(hwdef->intctl_base,
440                                        hwdef->intctl_base + 0x10000ULL,
441                                        &hwdef->intbit_to_level[0],
442                                        &slavio_irq, &slavio_cpu_irq,
443                                        cpu_irqs,
444                                        hwdef->clock_irq);
445
446     if (hwdef->idreg_base != (target_phys_addr_t)-1) {
447         stl_raw(phys_ram_base + prom_offset, 0xfe810103);
448
449         cpu_register_physical_memory(hwdef->idreg_base, sizeof(uint32_t),
450                                      prom_offset | IO_MEM_ROM);
451     }
452
453     espdma = sparc32_dma_init(hwdef->dma_base, slavio_irq[hwdef->esp_irq],
454                               iommu, &espdma_irq, &esp_reset);
455
456     ledma = sparc32_dma_init(hwdef->dma_base + 16ULL,
457                              slavio_irq[hwdef->le_irq], iommu, &ledma_irq,
458                              &le_reset);
459
460     if (graphic_depth != 8 && graphic_depth != 24) {
461         fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth);
462         exit (1);
463     }
464     tcx_init(ds, hwdef->tcx_base, phys_ram_base + RAM_size, RAM_size,
465              hwdef->vram_size, graphic_width, graphic_height, graphic_depth);
466
467     if (nd_table[0].model == NULL
468         || strcmp(nd_table[0].model, "lance") == 0) {
469         lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
470     } else if (strcmp(nd_table[0].model, "?") == 0) {
471         fprintf(stderr, "qemu: Supported NICs: lance\n");
472         exit (1);
473     } else {
474         fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
475         exit (1);
476     }
477
478     nvram = m48t59_init(slavio_irq[0], hwdef->nvram_base, 0,
479                         hwdef->nvram_size, 8);
480
481     slavio_timer_init_all(hwdef->counter_base, slavio_irq[hwdef->clock1_irq],
482                           slavio_cpu_irq, smp_cpus);
483
484     slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[hwdef->ms_kb_irq],
485                               nographic);
486     // Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
487     // Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
488     slavio_serial_init(hwdef->serial_base, slavio_irq[hwdef->ser_irq],
489                        serial_hds[1], serial_hds[0]);
490
491     if (hwdef->fd_base != (target_phys_addr_t)-1) {
492         /* there is zero or one floppy drive */
493         fd[1] = fd[0] = NULL;
494         index = drive_get_index(IF_FLOPPY, 0, 0);
495         if (index != -1)
496             fd[0] = drives_table[index].bdrv;
497
498         sun4m_fdctrl_init(slavio_irq[hwdef->fd_irq], hwdef->fd_base, fd);
499     }
500
501     if (drive_get_max_bus(IF_SCSI) > 0) {
502         fprintf(stderr, "qemu: too many SCSI bus\n");
503         exit(1);
504     }
505
506     main_esp = esp_init(hwdef->esp_base, espdma, *espdma_irq,
507                         esp_reset);
508
509     for (i = 0; i < ESP_MAX_DEVS; i++) {
510         index = drive_get_index(IF_SCSI, 0, i);
511         if (index == -1)
512             continue;
513         esp_scsi_attach(main_esp, drives_table[index].bdrv, i);
514     }
515
516     slavio_misc = slavio_misc_init(hwdef->slavio_base, hwdef->power_base,
517                                    slavio_irq[hwdef->me_irq]);
518     if (hwdef->cs_base != (target_phys_addr_t)-1)
519         cs_init(hwdef->cs_base, hwdef->cs_irq, slavio_intctl);
520
521     kernel_size = sun4m_load_kernel(kernel_filename, kernel_cmdline,
522                                     initrd_filename);
523
524     nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
525                boot_device, RAM_size, kernel_size, graphic_width,
526                graphic_height, graphic_depth, hwdef->machine_id, "Sun4m");
527
528     if (hwdef->ecc_base != (target_phys_addr_t)-1)
529         ecc_init(hwdef->ecc_base, hwdef->ecc_version);
530 }
531
532 static void sun4c_hw_init(const struct hwdef *hwdef, int RAM_size,
533                           const char *boot_device,
534                           DisplayState *ds, const char *kernel_filename,
535                           const char *kernel_cmdline,
536                           const char *initrd_filename, const char *cpu_model)
537 {
538     CPUState *env;
539     unsigned int i;
540     void *iommu, *espdma, *ledma, *main_esp, *nvram;
541     qemu_irq *cpu_irqs, *slavio_irq, *espdma_irq, *ledma_irq;
542     qemu_irq *esp_reset, *le_reset;
543     unsigned long prom_offset, kernel_size;
544     int ret;
545     char buf[1024];
546     BlockDriverState *fd[MAX_FD];
547     int index;
548
549     /* init CPU */
550     if (!cpu_model)
551         cpu_model = hwdef->default_cpu_model;
552
553     env = cpu_init(cpu_model);
554     if (!env) {
555         fprintf(stderr, "Unable to find Sparc CPU definition\n");
556         exit(1);
557     }
558
559     cpu_sparc_set_id(env, 0);
560
561     qemu_register_reset(main_cpu_reset, env);
562     register_savevm("cpu", 0, 3, cpu_save, cpu_load, env);
563     cpu_irqs = qemu_allocate_irqs(cpu_set_irq, env, MAX_PILS);
564
565     /* allocate RAM */
566     if ((uint64_t)RAM_size > hwdef->max_mem) {
567         fprintf(stderr, "qemu: Too much memory for this machine: %d, maximum %d\n",
568                 (unsigned int)RAM_size / (1024 * 1024),
569                 (unsigned int)hwdef->max_mem / (1024 * 1024));
570         exit(1);
571     }
572     cpu_register_physical_memory(0, RAM_size, 0);
573
574     /* load boot prom */
575     prom_offset = RAM_size + hwdef->vram_size;
576     cpu_register_physical_memory(hwdef->slavio_base,
577                                  (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) &
578                                  TARGET_PAGE_MASK,
579                                  prom_offset | IO_MEM_ROM);
580
581     if (bios_name == NULL)
582         bios_name = PROM_FILENAME;
583     snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
584     ret = load_elf(buf, hwdef->slavio_base - PROM_VADDR, NULL, NULL, NULL);
585     if (ret < 0 || ret > PROM_SIZE_MAX)
586         ret = load_image(buf, phys_ram_base + prom_offset);
587     if (ret < 0 || ret > PROM_SIZE_MAX) {
588         fprintf(stderr, "qemu: could not load prom '%s'\n",
589                 buf);
590         exit(1);
591     }
592     prom_offset += (ret + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK;
593
594     /* set up devices */
595     slavio_intctl = sun4c_intctl_init(hwdef->sun4c_intctl_base,
596                                       &slavio_irq, cpu_irqs);
597
598     iommu = iommu_init(hwdef->iommu_base, hwdef->iommu_version);
599
600     espdma = sparc32_dma_init(hwdef->dma_base, slavio_irq[hwdef->esp_irq],
601                               iommu, &espdma_irq, &esp_reset);
602
603     ledma = sparc32_dma_init(hwdef->dma_base + 16ULL,
604                              slavio_irq[hwdef->le_irq], iommu, &ledma_irq,
605                              &le_reset);
606
607     if (graphic_depth != 8 && graphic_depth != 24) {
608         fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth);
609         exit (1);
610     }
611     tcx_init(ds, hwdef->tcx_base, phys_ram_base + RAM_size, RAM_size,
612              hwdef->vram_size, graphic_width, graphic_height, graphic_depth);
613
614     if (nd_table[0].model == NULL
615         || strcmp(nd_table[0].model, "lance") == 0) {
616         lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
617     } else if (strcmp(nd_table[0].model, "?") == 0) {
618         fprintf(stderr, "qemu: Supported NICs: lance\n");
619         exit (1);
620     } else {
621         fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
622         exit (1);
623     }
624
625     nvram = m48t59_init(slavio_irq[0], hwdef->nvram_base, 0,
626                         hwdef->nvram_size, 2);
627
628     slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[hwdef->ms_kb_irq],
629                               nographic);
630     // Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
631     // Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
632     slavio_serial_init(hwdef->serial_base, slavio_irq[hwdef->ser_irq],
633                        serial_hds[1], serial_hds[0]);
634
635     if (hwdef->fd_base != (target_phys_addr_t)-1) {
636         /* there is zero or one floppy drive */
637         fd[1] = fd[0] = NULL;
638         index = drive_get_index(IF_FLOPPY, 0, 0);
639         if (index != -1)
640             fd[0] = drives_table[index].bdrv;
641
642         sun4m_fdctrl_init(slavio_irq[hwdef->fd_irq], hwdef->fd_base, fd);
643     }
644
645     if (drive_get_max_bus(IF_SCSI) > 0) {
646         fprintf(stderr, "qemu: too many SCSI bus\n");
647         exit(1);
648     }
649
650     main_esp = esp_init(hwdef->esp_base, espdma, *espdma_irq,
651                         esp_reset);
652
653     for (i = 0; i < ESP_MAX_DEVS; i++) {
654         index = drive_get_index(IF_SCSI, 0, i);
655         if (index == -1)
656             continue;
657         esp_scsi_attach(main_esp, drives_table[index].bdrv, i);
658     }
659
660     kernel_size = sun4m_load_kernel(kernel_filename, kernel_cmdline,
661                                     initrd_filename);
662
663     nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
664                boot_device, RAM_size, kernel_size, graphic_width,
665                graphic_height, graphic_depth, hwdef->machine_id, "Sun4c");
666 }
667
668 static const struct hwdef hwdefs[] = {
669     /* SS-5 */
670     {
671         .iommu_base   = 0x10000000,
672         .tcx_base     = 0x50000000,
673         .cs_base      = 0x6c000000,
674         .slavio_base  = 0x70000000,
675         .ms_kb_base   = 0x71000000,
676         .serial_base  = 0x71100000,
677         .nvram_base   = 0x71200000,
678         .fd_base      = 0x71400000,
679         .counter_base = 0x71d00000,
680         .intctl_base  = 0x71e00000,
681         .idreg_base   = 0x78000000,
682         .dma_base     = 0x78400000,
683         .esp_base     = 0x78800000,
684         .le_base      = 0x78c00000,
685         .power_base   = 0x7a000000,
686         .ecc_base     = -1,
687         .sun4c_intctl_base  = -1,
688         .sun4c_counter_base = -1,
689         .vram_size    = 0x00100000,
690         .nvram_size   = 0x2000,
691         .esp_irq = 18,
692         .le_irq = 16,
693         .clock_irq = 7,
694         .clock1_irq = 19,
695         .ms_kb_irq = 14,
696         .ser_irq = 15,
697         .fd_irq = 22,
698         .me_irq = 30,
699         .cs_irq = 5,
700         .machine_id = 0x80,
701         .iommu_version = 0x05000000,
702         .intbit_to_level = {
703             2, 3, 5, 7, 9, 11, 0, 14,   3, 5, 7, 9, 11, 13, 12, 12,
704             6, 0, 4, 10, 8, 0, 11, 0,   0, 0, 0, 0, 15, 0, 15, 0,
705         },
706         .max_mem = 0x10000000,
707         .default_cpu_model = "Fujitsu MB86904",
708     },
709     /* SS-10 */
710     {
711         .iommu_base   = 0xfe0000000ULL,
712         .tcx_base     = 0xe20000000ULL,
713         .cs_base      = -1,
714         .slavio_base  = 0xff0000000ULL,
715         .ms_kb_base   = 0xff1000000ULL,
716         .serial_base  = 0xff1100000ULL,
717         .nvram_base   = 0xff1200000ULL,
718         .fd_base      = 0xff1700000ULL,
719         .counter_base = 0xff1300000ULL,
720         .intctl_base  = 0xff1400000ULL,
721         .idreg_base   = 0xef0000000ULL,
722         .dma_base     = 0xef0400000ULL,
723         .esp_base     = 0xef0800000ULL,
724         .le_base      = 0xef0c00000ULL,
725         .power_base   = 0xefa000000ULL,
726         .ecc_base     = 0xf00000000ULL,
727         .ecc_version  = 0x10000000, // version 0, implementation 1
728         .sun4c_intctl_base  = -1,
729         .sun4c_counter_base = -1,
730         .vram_size    = 0x00100000,
731         .nvram_size   = 0x2000,
732         .esp_irq = 18,
733         .le_irq = 16,
734         .clock_irq = 7,
735         .clock1_irq = 19,
736         .ms_kb_irq = 14,
737         .ser_irq = 15,
738         .fd_irq = 22,
739         .me_irq = 30,
740         .cs_irq = -1,
741         .machine_id = 0x72,
742         .iommu_version = 0x03000000,
743         .intbit_to_level = {
744             2, 3, 5, 7, 9, 11, 0, 14,   3, 5, 7, 9, 11, 13, 12, 12,
745             6, 0, 4, 10, 8, 0, 11, 0,   0, 0, 0, 0, 15, 0, 15, 0,
746         },
747         .max_mem = 0xffffffff, // XXX actually first 62GB ok
748         .default_cpu_model = "TI SuperSparc II",
749     },
750     /* SS-600MP */
751     {
752         .iommu_base   = 0xfe0000000ULL,
753         .tcx_base     = 0xe20000000ULL,
754         .cs_base      = -1,
755         .slavio_base  = 0xff0000000ULL,
756         .ms_kb_base   = 0xff1000000ULL,
757         .serial_base  = 0xff1100000ULL,
758         .nvram_base   = 0xff1200000ULL,
759         .fd_base      = -1,
760         .counter_base = 0xff1300000ULL,
761         .intctl_base  = 0xff1400000ULL,
762         .idreg_base   = -1,
763         .dma_base     = 0xef0081000ULL,
764         .esp_base     = 0xef0080000ULL,
765         .le_base      = 0xef0060000ULL,
766         .power_base   = 0xefa000000ULL,
767         .ecc_base     = 0xf00000000ULL,
768         .ecc_version  = 0x00000000, // version 0, implementation 0
769         .sun4c_intctl_base  = -1,
770         .sun4c_counter_base = -1,
771         .vram_size    = 0x00100000,
772         .nvram_size   = 0x2000,
773         .esp_irq = 18,
774         .le_irq = 16,
775         .clock_irq = 7,
776         .clock1_irq = 19,
777         .ms_kb_irq = 14,
778         .ser_irq = 15,
779         .fd_irq = 22,
780         .me_irq = 30,
781         .cs_irq = -1,
782         .machine_id = 0x71,
783         .iommu_version = 0x01000000,
784         .intbit_to_level = {
785             2, 3, 5, 7, 9, 11, 0, 14,   3, 5, 7, 9, 11, 13, 12, 12,
786             6, 0, 4, 10, 8, 0, 11, 0,   0, 0, 0, 0, 15, 0, 15, 0,
787         },
788         .max_mem = 0xffffffff, // XXX actually first 62GB ok
789         .default_cpu_model = "TI SuperSparc II",
790     },
791     /* SS-20 */
792     {
793         .iommu_base   = 0xfe0000000ULL,
794         .tcx_base     = 0xe20000000ULL,
795         .cs_base      = -1,
796         .slavio_base  = 0xff0000000ULL,
797         .ms_kb_base   = 0xff1000000ULL,
798         .serial_base  = 0xff1100000ULL,
799         .nvram_base   = 0xff1200000ULL,
800         .fd_base      = 0xff1700000ULL,
801         .counter_base = 0xff1300000ULL,
802         .intctl_base  = 0xff1400000ULL,
803         .idreg_base   = 0xef0000000ULL,
804         .dma_base     = 0xef0400000ULL,
805         .esp_base     = 0xef0800000ULL,
806         .le_base      = 0xef0c00000ULL,
807         .power_base   = 0xefa000000ULL,
808         .ecc_base     = 0xf00000000ULL,
809         .ecc_version  = 0x20000000, // version 0, implementation 2
810         .sun4c_intctl_base  = -1,
811         .sun4c_counter_base = -1,
812         .vram_size    = 0x00100000,
813         .nvram_size   = 0x2000,
814         .esp_irq = 18,
815         .le_irq = 16,
816         .clock_irq = 7,
817         .clock1_irq = 19,
818         .ms_kb_irq = 14,
819         .ser_irq = 15,
820         .fd_irq = 22,
821         .me_irq = 30,
822         .cs_irq = -1,
823         .machine_id = 0x72,
824         .iommu_version = 0x13000000,
825         .intbit_to_level = {
826             2, 3, 5, 7, 9, 11, 0, 14,   3, 5, 7, 9, 11, 13, 12, 12,
827             6, 0, 4, 10, 8, 0, 11, 0,   0, 0, 0, 0, 15, 0, 15, 0,
828         },
829         .max_mem = 0xffffffff, // XXX actually first 62GB ok
830         .default_cpu_model = "TI SuperSparc II",
831     },
832     /* SS-2 */
833     {
834         .iommu_base   = 0xf8000000,
835         .tcx_base     = 0xfe000000,
836         .cs_base      = -1,
837         .slavio_base  = 0xf6000000,
838         .ms_kb_base   = 0xf0000000,
839         .serial_base  = 0xf1000000,
840         .nvram_base   = 0xf2000000,
841         .fd_base      = 0xf7200000,
842         .counter_base = -1,
843         .intctl_base  = -1,
844         .dma_base     = 0xf8400000,
845         .esp_base     = 0xf8800000,
846         .le_base      = 0xf8c00000,
847         .power_base   = -1,
848         .sun4c_intctl_base  = 0xf5000000,
849         .sun4c_counter_base = 0xf3000000,
850         .vram_size    = 0x00100000,
851         .nvram_size   = 0x800,
852         .esp_irq = 2,
853         .le_irq = 3,
854         .clock_irq = 5,
855         .clock1_irq = 7,
856         .ms_kb_irq = 1,
857         .ser_irq = 1,
858         .fd_irq = 1,
859         .me_irq = 1,
860         .cs_irq = -1,
861         .machine_id = 0x55,
862         .max_mem = 0x10000000,
863         .default_cpu_model = "Cypress CY7C601",
864     },
865 };
866
867 /* SPARCstation 5 hardware initialisation */
868 static void ss5_init(int RAM_size, int vga_ram_size,
869                      const char *boot_device, DisplayState *ds,
870                      const char *kernel_filename, const char *kernel_cmdline,
871                      const char *initrd_filename, const char *cpu_model)
872 {
873     sun4m_hw_init(&hwdefs[0], RAM_size, boot_device, ds, kernel_filename,
874                   kernel_cmdline, initrd_filename, cpu_model);
875 }
876
877 /* SPARCstation 10 hardware initialisation */
878 static void ss10_init(int RAM_size, int vga_ram_size,
879                       const char *boot_device, DisplayState *ds,
880                       const char *kernel_filename, const char *kernel_cmdline,
881                       const char *initrd_filename, const char *cpu_model)
882 {
883     sun4m_hw_init(&hwdefs[1], RAM_size, boot_device, ds, kernel_filename,
884                   kernel_cmdline, initrd_filename, cpu_model);
885 }
886
887 /* SPARCserver 600MP hardware initialisation */
888 static void ss600mp_init(int RAM_size, int vga_ram_size,
889                          const char *boot_device, DisplayState *ds,
890                          const char *kernel_filename, const char *kernel_cmdline,
891                          const char *initrd_filename, const char *cpu_model)
892 {
893     sun4m_hw_init(&hwdefs[2], RAM_size, boot_device, ds, kernel_filename,
894                   kernel_cmdline, initrd_filename, cpu_model);
895 }
896
897 /* SPARCstation 20 hardware initialisation */
898 static void ss20_init(int RAM_size, int vga_ram_size,
899                       const char *boot_device, DisplayState *ds,
900                       const char *kernel_filename, const char *kernel_cmdline,
901                       const char *initrd_filename, const char *cpu_model)
902 {
903     sun4m_hw_init(&hwdefs[3], RAM_size, boot_device, ds, kernel_filename,
904                   kernel_cmdline, initrd_filename, cpu_model);
905 }
906
907 /* SPARCstation 2 hardware initialisation */
908 static void ss2_init(int RAM_size, int vga_ram_size,
909                      const char *boot_device, DisplayState *ds,
910                      const char *kernel_filename, const char *kernel_cmdline,
911                      const char *initrd_filename, const char *cpu_model)
912 {
913     sun4c_hw_init(&hwdefs[4], RAM_size, boot_device, ds, kernel_filename,
914                   kernel_cmdline, initrd_filename, cpu_model);
915 }
916
917 QEMUMachine ss5_machine = {
918     "SS-5",
919     "Sun4m platform, SPARCstation 5",
920     ss5_init,
921 };
922
923 QEMUMachine ss10_machine = {
924     "SS-10",
925     "Sun4m platform, SPARCstation 10",
926     ss10_init,
927 };
928
929 QEMUMachine ss600mp_machine = {
930     "SS-600MP",
931     "Sun4m platform, SPARCserver 600MP",
932     ss600mp_init,
933 };
934
935 QEMUMachine ss20_machine = {
936     "SS-20",
937     "Sun4m platform, SPARCstation 20",
938     ss20_init,
939 };
940
941 QEMUMachine ss2_machine = {
942     "SS-2",
943     "Sun4c platform, SPARCstation 2",
944     ss2_init,
945 };
946
947 static const struct sun4d_hwdef sun4d_hwdefs[] = {
948     /* SS-1000 */
949     {
950         .iounit_bases   = {
951             0xfe0200000ULL,
952             0xfe1200000ULL,
953             0xfe2200000ULL,
954             0xfe3200000ULL,
955             -1,
956         },
957         .tcx_base     = 0x820000000ULL,
958         .slavio_base  = 0xf00000000ULL,
959         .ms_kb_base   = 0xf00240000ULL,
960         .serial_base  = 0xf00200000ULL,
961         .nvram_base   = 0xf00280000ULL,
962         .counter_base = 0xf00300000ULL,
963         .espdma_base  = 0x800081000ULL,
964         .esp_base     = 0x800080000ULL,
965         .ledma_base   = 0x800040000ULL,
966         .le_base      = 0x800060000ULL,
967         .sbi_base     = 0xf02800000ULL,
968         .vram_size    = 0x00100000,
969         .nvram_size   = 0x2000,
970         .esp_irq = 3,
971         .le_irq = 4,
972         .clock_irq = 14,
973         .clock1_irq = 10,
974         .ms_kb_irq = 12,
975         .ser_irq = 12,
976         .machine_id = 0x80,
977         .iounit_version = 0x03000000,
978         .max_mem = 0xffffffff, // XXX actually first 62GB ok
979         .default_cpu_model = "TI SuperSparc II",
980     },
981     /* SS-2000 */
982     {
983         .iounit_bases   = {
984             0xfe0200000ULL,
985             0xfe1200000ULL,
986             0xfe2200000ULL,
987             0xfe3200000ULL,
988             0xfe4200000ULL,
989         },
990         .tcx_base     = 0x820000000ULL,
991         .slavio_base  = 0xf00000000ULL,
992         .ms_kb_base   = 0xf00240000ULL,
993         .serial_base  = 0xf00200000ULL,
994         .nvram_base   = 0xf00280000ULL,
995         .counter_base = 0xf00300000ULL,
996         .espdma_base  = 0x800081000ULL,
997         .esp_base     = 0x800080000ULL,
998         .ledma_base   = 0x800040000ULL,
999         .le_base      = 0x800060000ULL,
1000         .sbi_base     = 0xf02800000ULL,
1001         .vram_size    = 0x00100000,
1002         .nvram_size   = 0x2000,
1003         .esp_irq = 3,
1004         .le_irq = 4,
1005         .clock_irq = 14,
1006         .clock1_irq = 10,
1007         .ms_kb_irq = 12,
1008         .ser_irq = 12,
1009         .machine_id = 0x80,
1010         .iounit_version = 0x03000000,
1011         .max_mem = 0xffffffff, // XXX actually first 62GB ok
1012         .default_cpu_model = "TI SuperSparc II",
1013     },
1014 };
1015
1016 static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, int RAM_size,
1017                           const char *boot_device,
1018                           DisplayState *ds, const char *kernel_filename,
1019                           const char *kernel_cmdline,
1020                           const char *initrd_filename, const char *cpu_model)
1021 {
1022     CPUState *env, *envs[MAX_CPUS];
1023     unsigned int i;
1024     void *iounits[MAX_IOUNITS], *espdma, *ledma, *main_esp, *nvram, *sbi;
1025     qemu_irq *cpu_irqs[MAX_CPUS], *sbi_irq, *sbi_cpu_irq,
1026         *espdma_irq, *ledma_irq;
1027     qemu_irq *esp_reset, *le_reset;
1028     unsigned long prom_offset, kernel_size;
1029     int ret;
1030     char buf[1024];
1031     int index;
1032
1033     /* init CPUs */
1034     if (!cpu_model)
1035         cpu_model = hwdef->default_cpu_model;
1036
1037     for (i = 0; i < smp_cpus; i++) {
1038         env = cpu_init(cpu_model);
1039         if (!env) {
1040             fprintf(stderr, "Unable to find Sparc CPU definition\n");
1041             exit(1);
1042         }
1043         cpu_sparc_set_id(env, i);
1044         envs[i] = env;
1045         if (i == 0) {
1046             qemu_register_reset(main_cpu_reset, env);
1047         } else {
1048             qemu_register_reset(secondary_cpu_reset, env);
1049             env->halted = 1;
1050         }
1051         register_savevm("cpu", i, 3, cpu_save, cpu_load, env);
1052         cpu_irqs[i] = qemu_allocate_irqs(cpu_set_irq, envs[i], MAX_PILS);
1053         env->prom_addr = hwdef->slavio_base;
1054     }
1055
1056     for (i = smp_cpus; i < MAX_CPUS; i++)
1057         cpu_irqs[i] = qemu_allocate_irqs(dummy_cpu_set_irq, NULL, MAX_PILS);
1058
1059     /* allocate RAM */
1060     if ((uint64_t)RAM_size > hwdef->max_mem) {
1061         fprintf(stderr, "qemu: Too much memory for this machine: %d, maximum %d\n",
1062                 (unsigned int)RAM_size / (1024 * 1024),
1063                 (unsigned int)(hwdef->max_mem / (1024 * 1024)));
1064         exit(1);
1065     }
1066     cpu_register_physical_memory(0, RAM_size, 0);
1067
1068     /* load boot prom */
1069     prom_offset = RAM_size + hwdef->vram_size;
1070     cpu_register_physical_memory(hwdef->slavio_base,
1071                                  (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) &
1072                                  TARGET_PAGE_MASK,
1073                                  prom_offset | IO_MEM_ROM);
1074
1075     if (bios_name == NULL)
1076         bios_name = PROM_FILENAME;
1077     snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
1078     ret = load_elf(buf, hwdef->slavio_base - PROM_VADDR, NULL, NULL, NULL);
1079     if (ret < 0 || ret > PROM_SIZE_MAX)
1080         ret = load_image(buf, phys_ram_base + prom_offset);
1081     if (ret < 0 || ret > PROM_SIZE_MAX) {
1082         fprintf(stderr, "qemu: could not load prom '%s'\n",
1083                 buf);
1084         exit(1);
1085     }
1086
1087     /* set up devices */
1088     sbi = sbi_init(hwdef->sbi_base, &sbi_irq, &sbi_cpu_irq, cpu_irqs);
1089
1090     for (i = 0; i < MAX_IOUNITS; i++)
1091         if (hwdef->iounit_bases[i] != (target_phys_addr_t)-1)
1092             iounits[i] = iommu_init(hwdef->iounit_bases[i], hwdef->iounit_version);
1093
1094     espdma = sparc32_dma_init(hwdef->espdma_base, sbi_irq[hwdef->esp_irq],
1095                               iounits[0], &espdma_irq, &esp_reset);
1096
1097     ledma = sparc32_dma_init(hwdef->ledma_base, sbi_irq[hwdef->le_irq],
1098                              iounits[0], &ledma_irq, &le_reset);
1099
1100     if (graphic_depth != 8 && graphic_depth != 24) {
1101         fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth);
1102         exit (1);
1103     }
1104     tcx_init(ds, hwdef->tcx_base, phys_ram_base + RAM_size, RAM_size,
1105              hwdef->vram_size, graphic_width, graphic_height, graphic_depth);
1106
1107     if (nd_table[0].model == NULL
1108         || strcmp(nd_table[0].model, "lance") == 0) {
1109         lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
1110     } else if (strcmp(nd_table[0].model, "?") == 0) {
1111         fprintf(stderr, "qemu: Supported NICs: lance\n");
1112         exit (1);
1113     } else {
1114         fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
1115         exit (1);
1116     }
1117
1118     nvram = m48t59_init(sbi_irq[0], hwdef->nvram_base, 0,
1119                         hwdef->nvram_size, 8);
1120
1121     slavio_timer_init_all(hwdef->counter_base, sbi_irq[hwdef->clock1_irq],
1122                           sbi_cpu_irq, smp_cpus);
1123
1124     slavio_serial_ms_kbd_init(hwdef->ms_kb_base, sbi_irq[hwdef->ms_kb_irq],
1125                               nographic);
1126     // Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
1127     // Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
1128     slavio_serial_init(hwdef->serial_base, sbi_irq[hwdef->ser_irq],
1129                        serial_hds[1], serial_hds[0]);
1130
1131     if (drive_get_max_bus(IF_SCSI) > 0) {
1132         fprintf(stderr, "qemu: too many SCSI bus\n");
1133         exit(1);
1134     }
1135
1136     main_esp = esp_init(hwdef->esp_base, espdma, *espdma_irq,
1137                         esp_reset);
1138
1139     for (i = 0; i < ESP_MAX_DEVS; i++) {
1140         index = drive_get_index(IF_SCSI, 0, i);
1141         if (index == -1)
1142             continue;
1143         esp_scsi_attach(main_esp, drives_table[index].bdrv, i);
1144     }
1145
1146     kernel_size = sun4m_load_kernel(kernel_filename, kernel_cmdline,
1147                                     initrd_filename);
1148
1149     nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
1150                boot_device, RAM_size, kernel_size, graphic_width,
1151                graphic_height, graphic_depth, hwdef->machine_id, "Sun4d");
1152 }
1153
1154 /* SPARCserver 1000 hardware initialisation */
1155 static void ss1000_init(int RAM_size, int vga_ram_size,
1156                         const char *boot_device, DisplayState *ds,
1157                         const char *kernel_filename, const char *kernel_cmdline,
1158                         const char *initrd_filename, const char *cpu_model)
1159 {
1160     sun4d_hw_init(&sun4d_hwdefs[0], RAM_size, boot_device, ds, kernel_filename,
1161                   kernel_cmdline, initrd_filename, cpu_model);
1162 }
1163
1164 /* SPARCcenter 2000 hardware initialisation */
1165 static void ss2000_init(int RAM_size, int vga_ram_size,
1166                         const char *boot_device, DisplayState *ds,
1167                         const char *kernel_filename, const char *kernel_cmdline,
1168                         const char *initrd_filename, const char *cpu_model)
1169 {
1170     sun4d_hw_init(&sun4d_hwdefs[1], RAM_size, boot_device, ds, kernel_filename,
1171                   kernel_cmdline, initrd_filename, cpu_model);
1172 }
1173
1174 QEMUMachine ss1000_machine = {
1175     "SS-1000",
1176     "Sun4d platform, SPARCserver 1000",
1177     ss1000_init,
1178 };
1179
1180 QEMUMachine ss2000_machine = {
1181     "SS-2000",
1182     "Sun4d platform, SPARCcenter 2000",
1183     ss2000_init,
1184 };