2 * QEMU Sun4m & Sun4d & Sun4c System Emulator
4 * Copyright (c) 2003-2005 Fabrice Bellard
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:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
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
25 #include "qemu-timer.h"
28 #include "sparc32_dma.h"
33 #include "firmware_abi.h"
42 * Sun4m architecture was used in the following machines:
44 * SPARCserver 6xxMP/xx
45 * SPARCclassic (SPARCclassic Server)(SPARCstation LC) (4/15),
46 * SPARCclassic X (4/10)
47 * SPARCstation LX/ZX (4/30)
48 * SPARCstation Voyager
49 * SPARCstation 10/xx, SPARCserver 10/xx
50 * SPARCstation 5, SPARCserver 5
51 * SPARCstation 20/xx, SPARCserver 20
54 * Sun4d architecture was used in the following machines:
59 * Sun4c architecture was used in the following machines:
60 * SPARCstation 1/1+, SPARCserver 1/1+
66 * See for example: http://www.sunhelp.org/faq/sunref1.html
70 #define DPRINTF(fmt, args...) \
71 do { printf("CPUIRQ: " fmt , ##args); } while (0)
73 #define DPRINTF(fmt, args...)
76 #define KERNEL_LOAD_ADDR 0x00004000
77 #define CMDLINE_ADDR 0x007ff000
78 #define INITRD_LOAD_ADDR 0x00800000
79 #define PROM_SIZE_MAX (512 * 1024)
80 #define PROM_VADDR 0xffd00000
81 #define PROM_FILENAME "openbios-sparc32"
82 #define CFG_ADDR 0xd00000510ULL
84 // Control plane, 8-bit and 24-bit planes
85 #define TCX_SIZE (9 * 1024 * 1024)
91 target_phys_addr_t iommu_base
, slavio_base
;
92 target_phys_addr_t intctl_base
, counter_base
, nvram_base
, ms_kb_base
;
93 target_phys_addr_t serial_base
, fd_base
;
94 target_phys_addr_t idreg_base
, dma_base
, esp_base
, le_base
;
95 target_phys_addr_t tcx_base
, cs_base
, apc_base
, aux1_base
, aux2_base
;
96 target_phys_addr_t ecc_base
;
98 target_phys_addr_t sun4c_intctl_base
, sun4c_counter_base
;
99 long vram_size
, nvram_size
;
100 // IRQ numbers are not PIL ones, but master interrupt controller
101 // register bit numbers
102 int intctl_g_intr
, esp_irq
, le_irq
, clock_irq
, clock1_irq
;
103 int ser_irq
, ms_kb_irq
, fd_irq
, me_irq
, cs_irq
, ecc_irq
;
104 uint8_t nvram_machine_id
;
106 uint32_t iommu_version
;
107 uint32_t intbit_to_level
[32];
109 const char * const default_cpu_model
;
112 #define MAX_IOUNITS 5
115 target_phys_addr_t iounit_bases
[MAX_IOUNITS
], slavio_base
;
116 target_phys_addr_t counter_base
, nvram_base
, ms_kb_base
;
117 target_phys_addr_t serial_base
;
118 target_phys_addr_t espdma_base
, esp_base
;
119 target_phys_addr_t ledma_base
, le_base
;
120 target_phys_addr_t tcx_base
;
121 target_phys_addr_t sbi_base
;
122 unsigned long vram_size
, nvram_size
;
123 // IRQ numbers are not PIL ones, but SBI register bit numbers
124 int esp_irq
, le_irq
, clock_irq
, clock1_irq
;
125 int ser_irq
, ms_kb_irq
, me_irq
;
126 uint8_t nvram_machine_id
;
128 uint32_t iounit_version
;
130 const char * const default_cpu_model
;
133 int DMA_get_channel_mode (int nchan
)
137 int DMA_read_memory (int nchan
, void *buf
, int pos
, int size
)
141 int DMA_write_memory (int nchan
, void *buf
, int pos
, int size
)
145 void DMA_hold_DREQ (int nchan
) {}
146 void DMA_release_DREQ (int nchan
) {}
147 void DMA_schedule(int nchan
) {}
148 void DMA_run (void) {}
149 void DMA_init (int high_page_enable
) {}
150 void DMA_register_channel (int nchan
,
151 DMA_transfer_handler transfer_handler
,
156 static int nvram_boot_set(void *opaque
, const char *boot_device
)
159 uint8_t image
[sizeof(ohwcfg_v3_t
)];
160 ohwcfg_v3_t
*header
= (ohwcfg_v3_t
*)&image
;
161 m48t59_t
*nvram
= (m48t59_t
*)opaque
;
163 for (i
= 0; i
< sizeof(image
); i
++)
164 image
[i
] = m48t59_read(nvram
, i
) & 0xff;
166 pstrcpy((char *)header
->boot_devices
, sizeof(header
->boot_devices
),
168 header
->nboot_devices
= strlen(boot_device
) & 0xff;
169 header
->crc
= cpu_to_be16(OHW_compute_crc(header
, 0x00, 0xF8));
171 for (i
= 0; i
< sizeof(image
); i
++)
172 m48t59_write(nvram
, i
, image
[i
]);
177 extern int nographic
;
179 static void nvram_init(m48t59_t
*nvram
, uint8_t *macaddr
, const char *cmdline
,
180 const char *boot_devices
, ram_addr_t RAM_size
,
181 uint32_t kernel_size
,
182 int width
, int height
, int depth
,
183 int nvram_machine_id
, const char *arch
)
187 uint8_t image
[0x1ff0];
188 ohwcfg_v3_t
*header
= (ohwcfg_v3_t
*)&image
;
189 struct sparc_arch_cfg
*sparc_header
;
190 struct OpenBIOS_nvpart_v1
*part_header
;
192 memset(image
, '\0', sizeof(image
));
194 // Try to match PPC NVRAM
195 pstrcpy((char *)header
->struct_ident
, sizeof(header
->struct_ident
),
197 header
->struct_version
= cpu_to_be32(3); /* structure v3 */
199 header
->nvram_size
= cpu_to_be16(0x2000);
200 header
->nvram_arch_ptr
= cpu_to_be16(sizeof(ohwcfg_v3_t
));
201 header
->nvram_arch_size
= cpu_to_be16(sizeof(struct sparc_arch_cfg
));
202 pstrcpy((char *)header
->arch
, sizeof(header
->arch
), arch
);
203 header
->nb_cpus
= smp_cpus
& 0xff;
204 header
->RAM0_base
= 0;
205 header
->RAM0_size
= cpu_to_be64((uint64_t)RAM_size
);
206 pstrcpy((char *)header
->boot_devices
, sizeof(header
->boot_devices
),
208 header
->nboot_devices
= strlen(boot_devices
) & 0xff;
209 header
->kernel_image
= cpu_to_be64((uint64_t)KERNEL_LOAD_ADDR
);
210 header
->kernel_size
= cpu_to_be64((uint64_t)kernel_size
);
212 pstrcpy_targphys(CMDLINE_ADDR
, TARGET_PAGE_SIZE
, cmdline
);
213 header
->cmdline
= cpu_to_be64((uint64_t)CMDLINE_ADDR
);
214 header
->cmdline_size
= cpu_to_be64((uint64_t)strlen(cmdline
));
216 // XXX add initrd_image, initrd_size
217 header
->width
= cpu_to_be16(width
);
218 header
->height
= cpu_to_be16(height
);
219 header
->depth
= cpu_to_be16(depth
);
221 header
->graphic_flags
= cpu_to_be16(OHW_GF_NOGRAPHICS
);
223 header
->crc
= cpu_to_be16(OHW_compute_crc(header
, 0x00, 0xF8));
225 // Architecture specific header
226 start
= sizeof(ohwcfg_v3_t
);
227 sparc_header
= (struct sparc_arch_cfg
*)&image
[start
];
228 sparc_header
->valid
= 0;
229 start
+= sizeof(struct sparc_arch_cfg
);
231 // OpenBIOS nvram variables
232 // Variable partition
233 part_header
= (struct OpenBIOS_nvpart_v1
*)&image
[start
];
234 part_header
->signature
= OPENBIOS_PART_SYSTEM
;
235 pstrcpy(part_header
->name
, sizeof(part_header
->name
), "system");
237 end
= start
+ sizeof(struct OpenBIOS_nvpart_v1
);
238 for (i
= 0; i
< nb_prom_envs
; i
++)
239 end
= OpenBIOS_set_var(image
, end
, prom_envs
[i
]);
244 end
= start
+ ((end
- start
+ 15) & ~15);
245 OpenBIOS_finish_partition(part_header
, end
- start
);
249 part_header
= (struct OpenBIOS_nvpart_v1
*)&image
[start
];
250 part_header
->signature
= OPENBIOS_PART_FREE
;
251 pstrcpy(part_header
->name
, sizeof(part_header
->name
), "free");
254 OpenBIOS_finish_partition(part_header
, end
- start
);
256 Sun_init_header((struct Sun_nvram
*)&image
[0x1fd8], macaddr
,
259 for (i
= 0; i
< sizeof(image
); i
++)
260 m48t59_write(nvram
, i
, image
[i
]);
262 qemu_register_boot_set(nvram_boot_set
, nvram
);
265 static void *slavio_intctl
;
270 slavio_pic_info(slavio_intctl
);
276 slavio_irq_info(slavio_intctl
);
279 void cpu_check_irqs(CPUState
*env
)
281 if (env
->pil_in
&& (env
->interrupt_index
== 0 ||
282 (env
->interrupt_index
& ~15) == TT_EXTINT
)) {
285 for (i
= 15; i
> 0; i
--) {
286 if (env
->pil_in
& (1 << i
)) {
287 int old_interrupt
= env
->interrupt_index
;
289 env
->interrupt_index
= TT_EXTINT
| i
;
290 if (old_interrupt
!= env
->interrupt_index
) {
291 DPRINTF("Set CPU IRQ %d\n", i
);
292 cpu_interrupt(env
, CPU_INTERRUPT_HARD
);
297 } else if (!env
->pil_in
&& (env
->interrupt_index
& ~15) == TT_EXTINT
) {
298 DPRINTF("Reset CPU IRQ %d\n", env
->interrupt_index
& 15);
299 env
->interrupt_index
= 0;
300 cpu_reset_interrupt(env
, CPU_INTERRUPT_HARD
);
304 static void cpu_set_irq(void *opaque
, int irq
, int level
)
306 CPUState
*env
= opaque
;
309 DPRINTF("Raise CPU IRQ %d\n", irq
);
311 env
->pil_in
|= 1 << irq
;
314 DPRINTF("Lower CPU IRQ %d\n", irq
);
315 env
->pil_in
&= ~(1 << irq
);
320 static void dummy_cpu_set_irq(void *opaque
, int irq
, int level
)
324 static void *slavio_misc
;
326 void qemu_system_powerdown(void)
328 slavio_set_power_fail(slavio_misc
, 1);
331 static void main_cpu_reset(void *opaque
)
333 CPUState
*env
= opaque
;
339 static void secondary_cpu_reset(void *opaque
)
341 CPUState
*env
= opaque
;
347 static unsigned long sun4m_load_kernel(const char *kernel_filename
,
348 const char *initrd_filename
,
353 long initrd_size
, kernel_size
;
355 linux_boot
= (kernel_filename
!= NULL
);
359 kernel_size
= load_elf(kernel_filename
, -0xf0000000ULL
, NULL
, NULL
,
362 kernel_size
= load_aout(kernel_filename
, KERNEL_LOAD_ADDR
,
363 RAM_size
- KERNEL_LOAD_ADDR
);
365 kernel_size
= load_image_targphys(kernel_filename
,
367 RAM_size
- KERNEL_LOAD_ADDR
);
368 if (kernel_size
< 0) {
369 fprintf(stderr
, "qemu: could not load kernel '%s'\n",
376 if (initrd_filename
) {
377 initrd_size
= load_image_targphys(initrd_filename
,
379 RAM_size
- INITRD_LOAD_ADDR
);
380 if (initrd_size
< 0) {
381 fprintf(stderr
, "qemu: could not load initial ram disk '%s'\n",
386 if (initrd_size
> 0) {
387 for (i
= 0; i
< 64 * TARGET_PAGE_SIZE
; i
+= TARGET_PAGE_SIZE
) {
388 if (ldl_phys(KERNEL_LOAD_ADDR
+ i
) == 0x48647253) { // HdrS
389 stl_phys(KERNEL_LOAD_ADDR
+ i
+ 16, INITRD_LOAD_ADDR
);
390 stl_phys(KERNEL_LOAD_ADDR
+ i
+ 20, initrd_size
);
399 static void sun4m_hw_init(const struct hwdef
*hwdef
, ram_addr_t RAM_size
,
400 const char *boot_device
,
401 DisplayState
*ds
, const char *kernel_filename
,
402 const char *kernel_cmdline
,
403 const char *initrd_filename
, const char *cpu_model
)
406 CPUState
*env
, *envs
[MAX_CPUS
];
408 void *iommu
, *espdma
, *ledma
, *main_esp
, *nvram
;
409 qemu_irq
*cpu_irqs
[MAX_CPUS
], *slavio_irq
, *slavio_cpu_irq
,
410 *espdma_irq
, *ledma_irq
;
411 qemu_irq
*esp_reset
, *le_reset
;
413 unsigned long prom_offset
, kernel_size
;
416 BlockDriverState
*fd
[MAX_FD
];
422 cpu_model
= hwdef
->default_cpu_model
;
424 for(i
= 0; i
< smp_cpus
; i
++) {
425 env
= cpu_init(cpu_model
);
427 fprintf(stderr
, "qemu: Unable to find Sparc CPU definition\n");
430 cpu_sparc_set_id(env
, i
);
433 qemu_register_reset(main_cpu_reset
, env
);
435 qemu_register_reset(secondary_cpu_reset
, env
);
438 cpu_irqs
[i
] = qemu_allocate_irqs(cpu_set_irq
, envs
[i
], MAX_PILS
);
439 env
->prom_addr
= hwdef
->slavio_base
;
442 for (i
= smp_cpus
; i
< MAX_CPUS
; i
++)
443 cpu_irqs
[i
] = qemu_allocate_irqs(dummy_cpu_set_irq
, NULL
, MAX_PILS
);
447 if ((uint64_t)RAM_size
> hwdef
->max_mem
) {
449 "qemu: Too much memory for this machine: %d, maximum %d\n",
450 (unsigned int)(RAM_size
/ (1024 * 1024)),
451 (unsigned int)(hwdef
->max_mem
/ (1024 * 1024)));
454 cpu_register_physical_memory(0, RAM_size
, 0);
457 prom_offset
= RAM_size
+ hwdef
->vram_size
;
458 cpu_register_physical_memory(hwdef
->slavio_base
,
459 (PROM_SIZE_MAX
+ TARGET_PAGE_SIZE
- 1) &
461 prom_offset
| IO_MEM_ROM
);
463 if (bios_name
== NULL
)
464 bios_name
= PROM_FILENAME
;
465 snprintf(buf
, sizeof(buf
), "%s/%s", bios_dir
, bios_name
);
466 ret
= load_elf(buf
, hwdef
->slavio_base
- PROM_VADDR
, NULL
, NULL
, NULL
);
467 if (ret
< 0 || ret
> PROM_SIZE_MAX
)
468 ret
= load_image_targphys(buf
, hwdef
->slavio_base
, PROM_SIZE_MAX
);
469 if (ret
< 0 || ret
> PROM_SIZE_MAX
) {
470 fprintf(stderr
, "qemu: could not load prom '%s'\n",
474 prom_offset
+= (ret
+ TARGET_PAGE_SIZE
- 1) & TARGET_PAGE_MASK
;
477 slavio_intctl
= slavio_intctl_init(hwdef
->intctl_base
,
478 hwdef
->intctl_base
+ 0x10000ULL
,
479 &hwdef
->intbit_to_level
[0],
480 &slavio_irq
, &slavio_cpu_irq
,
484 if (hwdef
->idreg_base
!= (target_phys_addr_t
)-1) {
485 static const uint8_t idreg_data
[] = { 0xfe, 0x81, 0x01, 0x03 };
487 cpu_register_physical_memory(hwdef
->idreg_base
, sizeof(idreg_data
),
488 prom_offset
| IO_MEM_ROM
);
489 cpu_physical_memory_write_rom(hwdef
->idreg_base
, idreg_data
,
493 iommu
= iommu_init(hwdef
->iommu_base
, hwdef
->iommu_version
,
494 slavio_irq
[hwdef
->me_irq
]);
496 espdma
= sparc32_dma_init(hwdef
->dma_base
, slavio_irq
[hwdef
->esp_irq
],
497 iommu
, &espdma_irq
, &esp_reset
);
499 ledma
= sparc32_dma_init(hwdef
->dma_base
+ 16ULL,
500 slavio_irq
[hwdef
->le_irq
], iommu
, &ledma_irq
,
503 if (graphic_depth
!= 8 && graphic_depth
!= 24) {
504 fprintf(stderr
, "qemu: Unsupported depth: %d\n", graphic_depth
);
507 tcx_init(ds
, hwdef
->tcx_base
, phys_ram_base
+ RAM_size
, RAM_size
,
508 hwdef
->vram_size
, graphic_width
, graphic_height
, graphic_depth
);
510 if (nd_table
[0].model
== NULL
511 || strcmp(nd_table
[0].model
, "lance") == 0) {
512 lance_init(&nd_table
[0], hwdef
->le_base
, ledma
, *ledma_irq
, le_reset
);
513 } else if (strcmp(nd_table
[0].model
, "?") == 0) {
514 fprintf(stderr
, "qemu: Supported NICs: lance\n");
517 fprintf(stderr
, "qemu: Unsupported NIC: %s\n", nd_table
[0].model
);
521 nvram
= m48t59_init(slavio_irq
[0], hwdef
->nvram_base
, 0,
522 hwdef
->nvram_size
, 8);
524 slavio_timer_init_all(hwdef
->counter_base
, slavio_irq
[hwdef
->clock1_irq
],
525 slavio_cpu_irq
, smp_cpus
);
527 slavio_serial_ms_kbd_init(hwdef
->ms_kb_base
, slavio_irq
[hwdef
->ms_kb_irq
],
529 // Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
530 // Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
531 slavio_serial_init(hwdef
->serial_base
, slavio_irq
[hwdef
->ser_irq
],
532 serial_hds
[1], serial_hds
[0]);
534 slavio_misc
= slavio_misc_init(hwdef
->slavio_base
, hwdef
->apc_base
,
535 hwdef
->aux1_base
, hwdef
->aux2_base
,
536 slavio_irq
[hwdef
->me_irq
], envs
[0],
539 if (hwdef
->fd_base
!= (target_phys_addr_t
)-1) {
540 /* there is zero or one floppy drive */
541 memset(fd
, 0, sizeof(fd
));
542 drive_index
= drive_get_index(IF_FLOPPY
, 0, 0);
543 if (drive_index
!= -1)
544 fd
[0] = drives_table
[drive_index
].bdrv
;
546 sun4m_fdctrl_init(slavio_irq
[hwdef
->fd_irq
], hwdef
->fd_base
, fd
,
550 if (drive_get_max_bus(IF_SCSI
) > 0) {
551 fprintf(stderr
, "qemu: too many SCSI bus\n");
555 main_esp
= esp_init(hwdef
->esp_base
, 2,
556 espdma_memory_read
, espdma_memory_write
,
557 espdma
, *espdma_irq
, esp_reset
);
559 for (i
= 0; i
< ESP_MAX_DEVS
; i
++) {
560 drive_index
= drive_get_index(IF_SCSI
, 0, i
);
561 if (drive_index
== -1)
563 esp_scsi_attach(main_esp
, drives_table
[drive_index
].bdrv
, i
);
566 if (hwdef
->cs_base
!= (target_phys_addr_t
)-1)
567 cs_init(hwdef
->cs_base
, hwdef
->cs_irq
, slavio_intctl
);
569 kernel_size
= sun4m_load_kernel(kernel_filename
, initrd_filename
,
572 nvram_init(nvram
, (uint8_t *)&nd_table
[0].macaddr
, kernel_cmdline
,
573 boot_device
, RAM_size
, kernel_size
, graphic_width
,
574 graphic_height
, graphic_depth
, hwdef
->nvram_machine_id
,
577 if (hwdef
->ecc_base
!= (target_phys_addr_t
)-1)
578 ecc_init(hwdef
->ecc_base
, slavio_irq
[hwdef
->ecc_irq
],
581 fw_cfg
= fw_cfg_init(0, 0, CFG_ADDR
, CFG_ADDR
+ 2);
582 fw_cfg_add_i32(fw_cfg
, FW_CFG_ID
, 1);
583 fw_cfg_add_i64(fw_cfg
, FW_CFG_RAM_SIZE
, (uint64_t)ram_size
);
584 fw_cfg_add_i16(fw_cfg
, FW_CFG_MACHINE_ID
, hwdef
->machine_id
);
587 static void sun4c_hw_init(const struct hwdef
*hwdef
, ram_addr_t RAM_size
,
588 const char *boot_device
,
589 DisplayState
*ds
, const char *kernel_filename
,
590 const char *kernel_cmdline
,
591 const char *initrd_filename
, const char *cpu_model
)
595 void *iommu
, *espdma
, *ledma
, *main_esp
, *nvram
;
596 qemu_irq
*cpu_irqs
, *slavio_irq
, *espdma_irq
, *ledma_irq
;
597 qemu_irq
*esp_reset
, *le_reset
;
599 unsigned long prom_offset
, kernel_size
;
602 BlockDriverState
*fd
[MAX_FD
];
608 cpu_model
= hwdef
->default_cpu_model
;
610 env
= cpu_init(cpu_model
);
612 fprintf(stderr
, "qemu: Unable to find Sparc CPU definition\n");
616 cpu_sparc_set_id(env
, 0);
618 qemu_register_reset(main_cpu_reset
, env
);
619 cpu_irqs
= qemu_allocate_irqs(cpu_set_irq
, env
, MAX_PILS
);
620 env
->prom_addr
= hwdef
->slavio_base
;
623 if ((uint64_t)RAM_size
> hwdef
->max_mem
) {
625 "qemu: Too much memory for this machine: %d, maximum %d\n",
626 (unsigned int)(RAM_size
/ (1024 * 1024)),
627 (unsigned int)(hwdef
->max_mem
/ (1024 * 1024)));
630 cpu_register_physical_memory(0, RAM_size
, 0);
633 prom_offset
= RAM_size
+ hwdef
->vram_size
;
634 cpu_register_physical_memory(hwdef
->slavio_base
,
635 (PROM_SIZE_MAX
+ TARGET_PAGE_SIZE
- 1) &
637 prom_offset
| IO_MEM_ROM
);
639 if (bios_name
== NULL
)
640 bios_name
= PROM_FILENAME
;
641 snprintf(buf
, sizeof(buf
), "%s/%s", bios_dir
, bios_name
);
642 ret
= load_elf(buf
, hwdef
->slavio_base
- PROM_VADDR
, NULL
, NULL
, NULL
);
643 if (ret
< 0 || ret
> PROM_SIZE_MAX
)
644 ret
= load_image_targphys(buf
, hwdef
->slavio_base
, PROM_SIZE_MAX
);
645 if (ret
< 0 || ret
> PROM_SIZE_MAX
) {
646 fprintf(stderr
, "qemu: could not load prom '%s'\n",
650 prom_offset
+= (ret
+ TARGET_PAGE_SIZE
- 1) & TARGET_PAGE_MASK
;
653 slavio_intctl
= sun4c_intctl_init(hwdef
->sun4c_intctl_base
,
654 &slavio_irq
, cpu_irqs
);
656 iommu
= iommu_init(hwdef
->iommu_base
, hwdef
->iommu_version
,
657 slavio_irq
[hwdef
->me_irq
]);
659 espdma
= sparc32_dma_init(hwdef
->dma_base
, slavio_irq
[hwdef
->esp_irq
],
660 iommu
, &espdma_irq
, &esp_reset
);
662 ledma
= sparc32_dma_init(hwdef
->dma_base
+ 16ULL,
663 slavio_irq
[hwdef
->le_irq
], iommu
, &ledma_irq
,
666 if (graphic_depth
!= 8 && graphic_depth
!= 24) {
667 fprintf(stderr
, "qemu: Unsupported depth: %d\n", graphic_depth
);
670 tcx_init(ds
, hwdef
->tcx_base
, phys_ram_base
+ RAM_size
, RAM_size
,
671 hwdef
->vram_size
, graphic_width
, graphic_height
, graphic_depth
);
673 if (nd_table
[0].model
== NULL
674 || strcmp(nd_table
[0].model
, "lance") == 0) {
675 lance_init(&nd_table
[0], hwdef
->le_base
, ledma
, *ledma_irq
, le_reset
);
676 } else if (strcmp(nd_table
[0].model
, "?") == 0) {
677 fprintf(stderr
, "qemu: Supported NICs: lance\n");
680 fprintf(stderr
, "qemu: Unsupported NIC: %s\n", nd_table
[0].model
);
684 nvram
= m48t59_init(slavio_irq
[0], hwdef
->nvram_base
, 0,
685 hwdef
->nvram_size
, 2);
687 slavio_serial_ms_kbd_init(hwdef
->ms_kb_base
, slavio_irq
[hwdef
->ms_kb_irq
],
689 // Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
690 // Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
691 slavio_serial_init(hwdef
->serial_base
, slavio_irq
[hwdef
->ser_irq
],
692 serial_hds
[1], serial_hds
[0]);
694 slavio_misc
= slavio_misc_init(-1, hwdef
->apc_base
,
695 hwdef
->aux1_base
, hwdef
->aux2_base
,
696 slavio_irq
[hwdef
->me_irq
], env
, &fdc_tc
);
698 if (hwdef
->fd_base
!= (target_phys_addr_t
)-1) {
699 /* there is zero or one floppy drive */
700 fd
[1] = fd
[0] = NULL
;
701 drive_index
= drive_get_index(IF_FLOPPY
, 0, 0);
702 if (drive_index
!= -1)
703 fd
[0] = drives_table
[drive_index
].bdrv
;
705 sun4m_fdctrl_init(slavio_irq
[hwdef
->fd_irq
], hwdef
->fd_base
, fd
,
709 if (drive_get_max_bus(IF_SCSI
) > 0) {
710 fprintf(stderr
, "qemu: too many SCSI bus\n");
714 main_esp
= esp_init(hwdef
->esp_base
, 2,
715 espdma_memory_read
, espdma_memory_write
,
716 espdma
, *espdma_irq
, esp_reset
);
718 for (i
= 0; i
< ESP_MAX_DEVS
; i
++) {
719 drive_index
= drive_get_index(IF_SCSI
, 0, i
);
720 if (drive_index
== -1)
722 esp_scsi_attach(main_esp
, drives_table
[drive_index
].bdrv
, i
);
725 kernel_size
= sun4m_load_kernel(kernel_filename
, initrd_filename
,
728 nvram_init(nvram
, (uint8_t *)&nd_table
[0].macaddr
, kernel_cmdline
,
729 boot_device
, RAM_size
, kernel_size
, graphic_width
,
730 graphic_height
, graphic_depth
, hwdef
->nvram_machine_id
,
733 fw_cfg
= fw_cfg_init(0, 0, CFG_ADDR
, CFG_ADDR
+ 2);
734 fw_cfg_add_i32(fw_cfg
, FW_CFG_ID
, 1);
735 fw_cfg_add_i64(fw_cfg
, FW_CFG_RAM_SIZE
, (uint64_t)ram_size
);
736 fw_cfg_add_i16(fw_cfg
, FW_CFG_MACHINE_ID
, hwdef
->machine_id
);
754 static const struct hwdef hwdefs
[] = {
757 .iommu_base
= 0x10000000,
758 .tcx_base
= 0x50000000,
759 .cs_base
= 0x6c000000,
760 .slavio_base
= 0x70000000,
761 .ms_kb_base
= 0x71000000,
762 .serial_base
= 0x71100000,
763 .nvram_base
= 0x71200000,
764 .fd_base
= 0x71400000,
765 .counter_base
= 0x71d00000,
766 .intctl_base
= 0x71e00000,
767 .idreg_base
= 0x78000000,
768 .dma_base
= 0x78400000,
769 .esp_base
= 0x78800000,
770 .le_base
= 0x78c00000,
771 .apc_base
= 0x6a000000,
772 .aux1_base
= 0x71900000,
773 .aux2_base
= 0x71910000,
775 .sun4c_intctl_base
= -1,
776 .sun4c_counter_base
= -1,
777 .vram_size
= 0x00100000,
778 .nvram_size
= 0x2000,
788 .nvram_machine_id
= 0x80,
789 .machine_id
= ss5_id
,
790 .iommu_version
= 0x05000000,
792 2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
793 6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0,
795 .max_mem
= 0x10000000,
796 .default_cpu_model
= "Fujitsu MB86904",
800 .iommu_base
= 0xfe0000000ULL
,
801 .tcx_base
= 0xe20000000ULL
,
803 .slavio_base
= 0xff0000000ULL
,
804 .ms_kb_base
= 0xff1000000ULL
,
805 .serial_base
= 0xff1100000ULL
,
806 .nvram_base
= 0xff1200000ULL
,
807 .fd_base
= 0xff1700000ULL
,
808 .counter_base
= 0xff1300000ULL
,
809 .intctl_base
= 0xff1400000ULL
,
810 .idreg_base
= 0xef0000000ULL
,
811 .dma_base
= 0xef0400000ULL
,
812 .esp_base
= 0xef0800000ULL
,
813 .le_base
= 0xef0c00000ULL
,
814 .apc_base
= 0xefa000000ULL
, // XXX should not exist
815 .aux1_base
= 0xff1800000ULL
,
816 .aux2_base
= 0xff1a01000ULL
,
817 .ecc_base
= 0xf00000000ULL
,
818 .ecc_version
= 0x10000000, // version 0, implementation 1
819 .sun4c_intctl_base
= -1,
820 .sun4c_counter_base
= -1,
821 .vram_size
= 0x00100000,
822 .nvram_size
= 0x2000,
833 .nvram_machine_id
= 0x72,
834 .machine_id
= ss10_id
,
835 .iommu_version
= 0x03000000,
837 2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
838 6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0,
840 .max_mem
= 0xf00000000ULL
,
841 .default_cpu_model
= "TI SuperSparc II",
845 .iommu_base
= 0xfe0000000ULL
,
846 .tcx_base
= 0xe20000000ULL
,
848 .slavio_base
= 0xff0000000ULL
,
849 .ms_kb_base
= 0xff1000000ULL
,
850 .serial_base
= 0xff1100000ULL
,
851 .nvram_base
= 0xff1200000ULL
,
853 .counter_base
= 0xff1300000ULL
,
854 .intctl_base
= 0xff1400000ULL
,
856 .dma_base
= 0xef0081000ULL
,
857 .esp_base
= 0xef0080000ULL
,
858 .le_base
= 0xef0060000ULL
,
859 .apc_base
= 0xefa000000ULL
, // XXX should not exist
860 .aux1_base
= 0xff1800000ULL
,
861 .aux2_base
= 0xff1a01000ULL
, // XXX should not exist
862 .ecc_base
= 0xf00000000ULL
,
863 .ecc_version
= 0x00000000, // version 0, implementation 0
864 .sun4c_intctl_base
= -1,
865 .sun4c_counter_base
= -1,
866 .vram_size
= 0x00100000,
867 .nvram_size
= 0x2000,
878 .nvram_machine_id
= 0x71,
879 .machine_id
= ss600mp_id
,
880 .iommu_version
= 0x01000000,
882 2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
883 6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0,
885 .max_mem
= 0xf00000000ULL
,
886 .default_cpu_model
= "TI SuperSparc II",
890 .iommu_base
= 0xfe0000000ULL
,
891 .tcx_base
= 0xe20000000ULL
,
893 .slavio_base
= 0xff0000000ULL
,
894 .ms_kb_base
= 0xff1000000ULL
,
895 .serial_base
= 0xff1100000ULL
,
896 .nvram_base
= 0xff1200000ULL
,
897 .fd_base
= 0xff1700000ULL
,
898 .counter_base
= 0xff1300000ULL
,
899 .intctl_base
= 0xff1400000ULL
,
900 .idreg_base
= 0xef0000000ULL
,
901 .dma_base
= 0xef0400000ULL
,
902 .esp_base
= 0xef0800000ULL
,
903 .le_base
= 0xef0c00000ULL
,
904 .apc_base
= 0xefa000000ULL
, // XXX should not exist
905 .aux1_base
= 0xff1800000ULL
,
906 .aux2_base
= 0xff1a01000ULL
,
907 .ecc_base
= 0xf00000000ULL
,
908 .ecc_version
= 0x20000000, // version 0, implementation 2
909 .sun4c_intctl_base
= -1,
910 .sun4c_counter_base
= -1,
911 .vram_size
= 0x00100000,
912 .nvram_size
= 0x2000,
923 .nvram_machine_id
= 0x72,
924 .machine_id
= ss20_id
,
925 .iommu_version
= 0x13000000,
927 2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
928 6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0,
930 .max_mem
= 0xf00000000ULL
,
931 .default_cpu_model
= "TI SuperSparc II",
935 .iommu_base
= 0xf8000000,
936 .tcx_base
= 0xfe000000,
938 .slavio_base
= 0xf6000000,
939 .ms_kb_base
= 0xf0000000,
940 .serial_base
= 0xf1000000,
941 .nvram_base
= 0xf2000000,
942 .fd_base
= 0xf7200000,
945 .dma_base
= 0xf8400000,
946 .esp_base
= 0xf8800000,
947 .le_base
= 0xf8c00000,
949 .aux1_base
= 0xf7400003,
951 .sun4c_intctl_base
= 0xf5000000,
952 .sun4c_counter_base
= 0xf3000000,
953 .vram_size
= 0x00100000,
964 .nvram_machine_id
= 0x55,
965 .machine_id
= ss2_id
,
966 .max_mem
= 0x10000000,
967 .default_cpu_model
= "Cypress CY7C601",
971 .iommu_base
= 0x10000000,
972 .tcx_base
= 0x50000000,
974 .slavio_base
= 0x70000000,
975 .ms_kb_base
= 0x71000000,
976 .serial_base
= 0x71100000,
977 .nvram_base
= 0x71200000,
978 .fd_base
= 0x71400000,
979 .counter_base
= 0x71d00000,
980 .intctl_base
= 0x71e00000,
981 .idreg_base
= 0x78000000,
982 .dma_base
= 0x78400000,
983 .esp_base
= 0x78800000,
984 .le_base
= 0x78c00000,
985 .apc_base
= 0x71300000, // pmc
986 .aux1_base
= 0x71900000,
987 .aux2_base
= 0x71910000,
989 .sun4c_intctl_base
= -1,
990 .sun4c_counter_base
= -1,
991 .vram_size
= 0x00100000,
992 .nvram_size
= 0x2000,
1002 .nvram_machine_id
= 0x80,
1003 .machine_id
= vger_id
,
1004 .iommu_version
= 0x05000000,
1005 .intbit_to_level
= {
1006 2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
1007 6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0,
1009 .max_mem
= 0x10000000,
1010 .default_cpu_model
= "Fujitsu MB86904",
1014 .iommu_base
= 0x10000000,
1015 .tcx_base
= 0x50000000,
1017 .slavio_base
= 0x70000000,
1018 .ms_kb_base
= 0x71000000,
1019 .serial_base
= 0x71100000,
1020 .nvram_base
= 0x71200000,
1021 .fd_base
= 0x71400000,
1022 .counter_base
= 0x71d00000,
1023 .intctl_base
= 0x71e00000,
1024 .idreg_base
= 0x78000000,
1025 .dma_base
= 0x78400000,
1026 .esp_base
= 0x78800000,
1027 .le_base
= 0x78c00000,
1029 .aux1_base
= 0x71900000,
1030 .aux2_base
= 0x71910000,
1032 .sun4c_intctl_base
= -1,
1033 .sun4c_counter_base
= -1,
1034 .vram_size
= 0x00100000,
1035 .nvram_size
= 0x2000,
1045 .nvram_machine_id
= 0x80,
1046 .machine_id
= lx_id
,
1047 .iommu_version
= 0x04000000,
1048 .intbit_to_level
= {
1049 2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
1050 6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0,
1052 .max_mem
= 0x10000000,
1053 .default_cpu_model
= "TI MicroSparc I",
1057 .iommu_base
= 0x10000000,
1058 .tcx_base
= 0x50000000,
1059 .cs_base
= 0x6c000000,
1060 .slavio_base
= 0x70000000,
1061 .ms_kb_base
= 0x71000000,
1062 .serial_base
= 0x71100000,
1063 .nvram_base
= 0x71200000,
1064 .fd_base
= 0x71400000,
1065 .counter_base
= 0x71d00000,
1066 .intctl_base
= 0x71e00000,
1067 .idreg_base
= 0x78000000,
1068 .dma_base
= 0x78400000,
1069 .esp_base
= 0x78800000,
1070 .le_base
= 0x78c00000,
1071 .apc_base
= 0x6a000000,
1072 .aux1_base
= 0x71900000,
1073 .aux2_base
= 0x71910000,
1075 .sun4c_intctl_base
= -1,
1076 .sun4c_counter_base
= -1,
1077 .vram_size
= 0x00100000,
1078 .nvram_size
= 0x2000,
1088 .nvram_machine_id
= 0x80,
1089 .machine_id
= ss4_id
,
1090 .iommu_version
= 0x05000000,
1091 .intbit_to_level
= {
1092 2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
1093 6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0,
1095 .max_mem
= 0x10000000,
1096 .default_cpu_model
= "Fujitsu MB86904",
1100 .iommu_base
= 0x10000000,
1101 .tcx_base
= 0x50000000,
1103 .slavio_base
= 0x70000000,
1104 .ms_kb_base
= 0x71000000,
1105 .serial_base
= 0x71100000,
1106 .nvram_base
= 0x71200000,
1107 .fd_base
= 0x71400000,
1108 .counter_base
= 0x71d00000,
1109 .intctl_base
= 0x71e00000,
1110 .idreg_base
= 0x78000000,
1111 .dma_base
= 0x78400000,
1112 .esp_base
= 0x78800000,
1113 .le_base
= 0x78c00000,
1114 .apc_base
= 0x6a000000,
1115 .aux1_base
= 0x71900000,
1116 .aux2_base
= 0x71910000,
1118 .sun4c_intctl_base
= -1,
1119 .sun4c_counter_base
= -1,
1120 .vram_size
= 0x00100000,
1121 .nvram_size
= 0x2000,
1131 .nvram_machine_id
= 0x80,
1132 .machine_id
= scls_id
,
1133 .iommu_version
= 0x05000000,
1134 .intbit_to_level
= {
1135 2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
1136 6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0,
1138 .max_mem
= 0x10000000,
1139 .default_cpu_model
= "TI MicroSparc I",
1143 .iommu_base
= 0x10000000,
1144 .tcx_base
= 0x50000000, // XXX
1146 .slavio_base
= 0x70000000,
1147 .ms_kb_base
= 0x71000000,
1148 .serial_base
= 0x71100000,
1149 .nvram_base
= 0x71200000,
1150 .fd_base
= 0x71400000,
1151 .counter_base
= 0x71d00000,
1152 .intctl_base
= 0x71e00000,
1153 .idreg_base
= 0x78000000,
1154 .dma_base
= 0x78400000,
1155 .esp_base
= 0x78800000,
1156 .le_base
= 0x78c00000,
1157 .apc_base
= 0x6a000000,
1158 .aux1_base
= 0x71900000,
1159 .aux2_base
= 0x71910000,
1161 .sun4c_intctl_base
= -1,
1162 .sun4c_counter_base
= -1,
1163 .vram_size
= 0x00100000,
1164 .nvram_size
= 0x2000,
1174 .nvram_machine_id
= 0x80,
1175 .machine_id
= sbook_id
,
1176 .iommu_version
= 0x05000000,
1177 .intbit_to_level
= {
1178 2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
1179 6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0,
1181 .max_mem
= 0x10000000,
1182 .default_cpu_model
= "TI MicroSparc I",
1186 /* SPARCstation 5 hardware initialisation */
1187 static void ss5_init(ram_addr_t RAM_size
, int vga_ram_size
,
1188 const char *boot_device
, DisplayState
*ds
,
1189 const char *kernel_filename
, const char *kernel_cmdline
,
1190 const char *initrd_filename
, const char *cpu_model
)
1192 sun4m_hw_init(&hwdefs
[0], RAM_size
, boot_device
, ds
, kernel_filename
,
1193 kernel_cmdline
, initrd_filename
, cpu_model
);
1196 /* SPARCstation 10 hardware initialisation */
1197 static void ss10_init(ram_addr_t RAM_size
, int vga_ram_size
,
1198 const char *boot_device
, DisplayState
*ds
,
1199 const char *kernel_filename
, const char *kernel_cmdline
,
1200 const char *initrd_filename
, const char *cpu_model
)
1202 sun4m_hw_init(&hwdefs
[1], RAM_size
, boot_device
, ds
, kernel_filename
,
1203 kernel_cmdline
, initrd_filename
, cpu_model
);
1206 /* SPARCserver 600MP hardware initialisation */
1207 static void ss600mp_init(ram_addr_t RAM_size
, int vga_ram_size
,
1208 const char *boot_device
, DisplayState
*ds
,
1209 const char *kernel_filename
,
1210 const char *kernel_cmdline
,
1211 const char *initrd_filename
, const char *cpu_model
)
1213 sun4m_hw_init(&hwdefs
[2], RAM_size
, boot_device
, ds
, kernel_filename
,
1214 kernel_cmdline
, initrd_filename
, cpu_model
);
1217 /* SPARCstation 20 hardware initialisation */
1218 static void ss20_init(ram_addr_t RAM_size
, int vga_ram_size
,
1219 const char *boot_device
, DisplayState
*ds
,
1220 const char *kernel_filename
, const char *kernel_cmdline
,
1221 const char *initrd_filename
, const char *cpu_model
)
1223 sun4m_hw_init(&hwdefs
[3], RAM_size
, boot_device
, ds
, kernel_filename
,
1224 kernel_cmdline
, initrd_filename
, cpu_model
);
1227 /* SPARCstation 2 hardware initialisation */
1228 static void ss2_init(ram_addr_t RAM_size
, int vga_ram_size
,
1229 const char *boot_device
, DisplayState
*ds
,
1230 const char *kernel_filename
, const char *kernel_cmdline
,
1231 const char *initrd_filename
, const char *cpu_model
)
1233 sun4c_hw_init(&hwdefs
[4], RAM_size
, boot_device
, ds
, kernel_filename
,
1234 kernel_cmdline
, initrd_filename
, cpu_model
);
1237 /* SPARCstation Voyager hardware initialisation */
1238 static void vger_init(ram_addr_t RAM_size
, int vga_ram_size
,
1239 const char *boot_device
, DisplayState
*ds
,
1240 const char *kernel_filename
, const char *kernel_cmdline
,
1241 const char *initrd_filename
, const char *cpu_model
)
1243 sun4m_hw_init(&hwdefs
[5], RAM_size
, boot_device
, ds
, kernel_filename
,
1244 kernel_cmdline
, initrd_filename
, cpu_model
);
1247 /* SPARCstation LX hardware initialisation */
1248 static void ss_lx_init(ram_addr_t RAM_size
, int vga_ram_size
,
1249 const char *boot_device
, DisplayState
*ds
,
1250 const char *kernel_filename
, const char *kernel_cmdline
,
1251 const char *initrd_filename
, const char *cpu_model
)
1253 sun4m_hw_init(&hwdefs
[6], RAM_size
, boot_device
, ds
, kernel_filename
,
1254 kernel_cmdline
, initrd_filename
, cpu_model
);
1257 /* SPARCstation 4 hardware initialisation */
1258 static void ss4_init(ram_addr_t RAM_size
, int vga_ram_size
,
1259 const char *boot_device
, DisplayState
*ds
,
1260 const char *kernel_filename
, const char *kernel_cmdline
,
1261 const char *initrd_filename
, const char *cpu_model
)
1263 sun4m_hw_init(&hwdefs
[7], RAM_size
, boot_device
, ds
, kernel_filename
,
1264 kernel_cmdline
, initrd_filename
, cpu_model
);
1267 /* SPARCClassic hardware initialisation */
1268 static void scls_init(ram_addr_t RAM_size
, int vga_ram_size
,
1269 const char *boot_device
, DisplayState
*ds
,
1270 const char *kernel_filename
, const char *kernel_cmdline
,
1271 const char *initrd_filename
, const char *cpu_model
)
1273 sun4m_hw_init(&hwdefs
[8], RAM_size
, boot_device
, ds
, kernel_filename
,
1274 kernel_cmdline
, initrd_filename
, cpu_model
);
1277 /* SPARCbook hardware initialisation */
1278 static void sbook_init(ram_addr_t RAM_size
, int vga_ram_size
,
1279 const char *boot_device
, DisplayState
*ds
,
1280 const char *kernel_filename
, const char *kernel_cmdline
,
1281 const char *initrd_filename
, const char *cpu_model
)
1283 sun4m_hw_init(&hwdefs
[9], RAM_size
, boot_device
, ds
, kernel_filename
,
1284 kernel_cmdline
, initrd_filename
, cpu_model
);
1287 QEMUMachine ss5_machine
= {
1289 .desc
= "Sun4m platform, SPARCstation 5",
1291 .ram_require
= PROM_SIZE_MAX
+ TCX_SIZE
,
1295 QEMUMachine ss10_machine
= {
1297 .desc
= "Sun4m platform, SPARCstation 10",
1299 .ram_require
= PROM_SIZE_MAX
+ TCX_SIZE
,
1303 QEMUMachine ss600mp_machine
= {
1305 .desc
= "Sun4m platform, SPARCserver 600MP",
1306 .init
= ss600mp_init
,
1307 .ram_require
= PROM_SIZE_MAX
+ TCX_SIZE
,
1311 QEMUMachine ss20_machine
= {
1313 .desc
= "Sun4m platform, SPARCstation 20",
1315 .ram_require
= PROM_SIZE_MAX
+ TCX_SIZE
,
1319 QEMUMachine ss2_machine
= {
1321 .desc
= "Sun4c platform, SPARCstation 2",
1323 .ram_require
= PROM_SIZE_MAX
+ TCX_SIZE
,
1327 QEMUMachine voyager_machine
= {
1329 .desc
= "Sun4m platform, SPARCstation Voyager",
1331 .ram_require
= PROM_SIZE_MAX
+ TCX_SIZE
,
1335 QEMUMachine ss_lx_machine
= {
1337 .desc
= "Sun4m platform, SPARCstation LX",
1339 .ram_require
= PROM_SIZE_MAX
+ TCX_SIZE
,
1343 QEMUMachine ss4_machine
= {
1345 .desc
= "Sun4m platform, SPARCstation 4",
1347 .ram_require
= PROM_SIZE_MAX
+ TCX_SIZE
,
1351 QEMUMachine scls_machine
= {
1352 .name
= "SPARCClassic",
1353 .desc
= "Sun4m platform, SPARCClassic",
1355 .ram_require
= PROM_SIZE_MAX
+ TCX_SIZE
,
1359 QEMUMachine sbook_machine
= {
1360 .name
= "SPARCbook",
1361 .desc
= "Sun4m platform, SPARCbook",
1363 .ram_require
= PROM_SIZE_MAX
+ TCX_SIZE
,
1367 static const struct sun4d_hwdef sun4d_hwdefs
[] = {
1377 .tcx_base
= 0x820000000ULL
,
1378 .slavio_base
= 0xf00000000ULL
,
1379 .ms_kb_base
= 0xf00240000ULL
,
1380 .serial_base
= 0xf00200000ULL
,
1381 .nvram_base
= 0xf00280000ULL
,
1382 .counter_base
= 0xf00300000ULL
,
1383 .espdma_base
= 0x800081000ULL
,
1384 .esp_base
= 0x800080000ULL
,
1385 .ledma_base
= 0x800040000ULL
,
1386 .le_base
= 0x800060000ULL
,
1387 .sbi_base
= 0xf02800000ULL
,
1388 .vram_size
= 0x00100000,
1389 .nvram_size
= 0x2000,
1396 .nvram_machine_id
= 0x80,
1397 .machine_id
= ss1000_id
,
1398 .iounit_version
= 0x03000000,
1399 .max_mem
= 0xf00000000ULL
,
1400 .default_cpu_model
= "TI SuperSparc II",
1411 .tcx_base
= 0x820000000ULL
,
1412 .slavio_base
= 0xf00000000ULL
,
1413 .ms_kb_base
= 0xf00240000ULL
,
1414 .serial_base
= 0xf00200000ULL
,
1415 .nvram_base
= 0xf00280000ULL
,
1416 .counter_base
= 0xf00300000ULL
,
1417 .espdma_base
= 0x800081000ULL
,
1418 .esp_base
= 0x800080000ULL
,
1419 .ledma_base
= 0x800040000ULL
,
1420 .le_base
= 0x800060000ULL
,
1421 .sbi_base
= 0xf02800000ULL
,
1422 .vram_size
= 0x00100000,
1423 .nvram_size
= 0x2000,
1430 .nvram_machine_id
= 0x80,
1431 .machine_id
= ss2000_id
,
1432 .iounit_version
= 0x03000000,
1433 .max_mem
= 0xf00000000ULL
,
1434 .default_cpu_model
= "TI SuperSparc II",
1438 static void sun4d_hw_init(const struct sun4d_hwdef
*hwdef
, ram_addr_t RAM_size
,
1439 const char *boot_device
,
1440 DisplayState
*ds
, const char *kernel_filename
,
1441 const char *kernel_cmdline
,
1442 const char *initrd_filename
, const char *cpu_model
)
1444 CPUState
*env
, *envs
[MAX_CPUS
];
1446 void *iounits
[MAX_IOUNITS
], *espdma
, *ledma
, *main_esp
, *nvram
, *sbi
;
1447 qemu_irq
*cpu_irqs
[MAX_CPUS
], *sbi_irq
, *sbi_cpu_irq
,
1448 *espdma_irq
, *ledma_irq
;
1449 qemu_irq
*esp_reset
, *le_reset
;
1450 unsigned long prom_offset
, kernel_size
;
1458 cpu_model
= hwdef
->default_cpu_model
;
1460 for (i
= 0; i
< smp_cpus
; i
++) {
1461 env
= cpu_init(cpu_model
);
1463 fprintf(stderr
, "qemu: Unable to find Sparc CPU definition\n");
1466 cpu_sparc_set_id(env
, i
);
1469 qemu_register_reset(main_cpu_reset
, env
);
1471 qemu_register_reset(secondary_cpu_reset
, env
);
1474 cpu_irqs
[i
] = qemu_allocate_irqs(cpu_set_irq
, envs
[i
], MAX_PILS
);
1475 env
->prom_addr
= hwdef
->slavio_base
;
1478 for (i
= smp_cpus
; i
< MAX_CPUS
; i
++)
1479 cpu_irqs
[i
] = qemu_allocate_irqs(dummy_cpu_set_irq
, NULL
, MAX_PILS
);
1482 if ((uint64_t)RAM_size
> hwdef
->max_mem
) {
1484 "qemu: Too much memory for this machine: %d, maximum %d\n",
1485 (unsigned int)(RAM_size
/ (1024 * 1024)),
1486 (unsigned int)(hwdef
->max_mem
/ (1024 * 1024)));
1489 cpu_register_physical_memory(0, RAM_size
, 0);
1491 /* load boot prom */
1492 prom_offset
= RAM_size
+ hwdef
->vram_size
;
1493 cpu_register_physical_memory(hwdef
->slavio_base
,
1494 (PROM_SIZE_MAX
+ TARGET_PAGE_SIZE
- 1) &
1496 prom_offset
| IO_MEM_ROM
);
1498 if (bios_name
== NULL
)
1499 bios_name
= PROM_FILENAME
;
1500 snprintf(buf
, sizeof(buf
), "%s/%s", bios_dir
, bios_name
);
1501 ret
= load_elf(buf
, hwdef
->slavio_base
- PROM_VADDR
, NULL
, NULL
, NULL
);
1502 if (ret
< 0 || ret
> PROM_SIZE_MAX
)
1503 ret
= load_image_targphys(buf
, hwdef
->slavio_base
, PROM_SIZE_MAX
);
1504 if (ret
< 0 || ret
> PROM_SIZE_MAX
) {
1505 fprintf(stderr
, "qemu: could not load prom '%s'\n",
1510 /* set up devices */
1511 sbi
= sbi_init(hwdef
->sbi_base
, &sbi_irq
, &sbi_cpu_irq
, cpu_irqs
);
1513 for (i
= 0; i
< MAX_IOUNITS
; i
++)
1514 if (hwdef
->iounit_bases
[i
] != (target_phys_addr_t
)-1)
1515 iounits
[i
] = iommu_init(hwdef
->iounit_bases
[i
],
1516 hwdef
->iounit_version
,
1517 sbi_irq
[hwdef
->me_irq
]);
1519 espdma
= sparc32_dma_init(hwdef
->espdma_base
, sbi_irq
[hwdef
->esp_irq
],
1520 iounits
[0], &espdma_irq
, &esp_reset
);
1522 ledma
= sparc32_dma_init(hwdef
->ledma_base
, sbi_irq
[hwdef
->le_irq
],
1523 iounits
[0], &ledma_irq
, &le_reset
);
1525 if (graphic_depth
!= 8 && graphic_depth
!= 24) {
1526 fprintf(stderr
, "qemu: Unsupported depth: %d\n", graphic_depth
);
1529 tcx_init(ds
, hwdef
->tcx_base
, phys_ram_base
+ RAM_size
, RAM_size
,
1530 hwdef
->vram_size
, graphic_width
, graphic_height
, graphic_depth
);
1532 if (nd_table
[0].model
== NULL
1533 || strcmp(nd_table
[0].model
, "lance") == 0) {
1534 lance_init(&nd_table
[0], hwdef
->le_base
, ledma
, *ledma_irq
, le_reset
);
1535 } else if (strcmp(nd_table
[0].model
, "?") == 0) {
1536 fprintf(stderr
, "qemu: Supported NICs: lance\n");
1539 fprintf(stderr
, "qemu: Unsupported NIC: %s\n", nd_table
[0].model
);
1543 nvram
= m48t59_init(sbi_irq
[0], hwdef
->nvram_base
, 0,
1544 hwdef
->nvram_size
, 8);
1546 slavio_timer_init_all(hwdef
->counter_base
, sbi_irq
[hwdef
->clock1_irq
],
1547 sbi_cpu_irq
, smp_cpus
);
1549 slavio_serial_ms_kbd_init(hwdef
->ms_kb_base
, sbi_irq
[hwdef
->ms_kb_irq
],
1551 // Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
1552 // Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
1553 slavio_serial_init(hwdef
->serial_base
, sbi_irq
[hwdef
->ser_irq
],
1554 serial_hds
[1], serial_hds
[0]);
1556 if (drive_get_max_bus(IF_SCSI
) > 0) {
1557 fprintf(stderr
, "qemu: too many SCSI bus\n");
1561 main_esp
= esp_init(hwdef
->esp_base
, 2,
1562 espdma_memory_read
, espdma_memory_write
,
1563 espdma
, *espdma_irq
, esp_reset
);
1565 for (i
= 0; i
< ESP_MAX_DEVS
; i
++) {
1566 drive_index
= drive_get_index(IF_SCSI
, 0, i
);
1567 if (drive_index
== -1)
1569 esp_scsi_attach(main_esp
, drives_table
[drive_index
].bdrv
, i
);
1572 kernel_size
= sun4m_load_kernel(kernel_filename
, initrd_filename
,
1575 nvram_init(nvram
, (uint8_t *)&nd_table
[0].macaddr
, kernel_cmdline
,
1576 boot_device
, RAM_size
, kernel_size
, graphic_width
,
1577 graphic_height
, graphic_depth
, hwdef
->nvram_machine_id
,
1580 fw_cfg
= fw_cfg_init(0, 0, CFG_ADDR
, CFG_ADDR
+ 2);
1581 fw_cfg_add_i32(fw_cfg
, FW_CFG_ID
, 1);
1582 fw_cfg_add_i64(fw_cfg
, FW_CFG_RAM_SIZE
, (uint64_t)ram_size
);
1583 fw_cfg_add_i16(fw_cfg
, FW_CFG_MACHINE_ID
, hwdef
->machine_id
);
1586 /* SPARCserver 1000 hardware initialisation */
1587 static void ss1000_init(ram_addr_t RAM_size
, int vga_ram_size
,
1588 const char *boot_device
, DisplayState
*ds
,
1589 const char *kernel_filename
, const char *kernel_cmdline
,
1590 const char *initrd_filename
, const char *cpu_model
)
1592 sun4d_hw_init(&sun4d_hwdefs
[0], RAM_size
, boot_device
, ds
, kernel_filename
,
1593 kernel_cmdline
, initrd_filename
, cpu_model
);
1596 /* SPARCcenter 2000 hardware initialisation */
1597 static void ss2000_init(ram_addr_t RAM_size
, int vga_ram_size
,
1598 const char *boot_device
, DisplayState
*ds
,
1599 const char *kernel_filename
, const char *kernel_cmdline
,
1600 const char *initrd_filename
, const char *cpu_model
)
1602 sun4d_hw_init(&sun4d_hwdefs
[1], RAM_size
, boot_device
, ds
, kernel_filename
,
1603 kernel_cmdline
, initrd_filename
, cpu_model
);
1606 QEMUMachine ss1000_machine
= {
1608 .desc
= "Sun4d platform, SPARCserver 1000",
1609 .init
= ss1000_init
,
1610 .ram_require
= PROM_SIZE_MAX
+ TCX_SIZE
,
1614 QEMUMachine ss2000_machine
= {
1616 .desc
= "Sun4d platform, SPARCcenter 2000",
1617 .init
= ss2000_init
,
1618 .ram_require
= PROM_SIZE_MAX
+ TCX_SIZE
,