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"
41 * Sun4m architecture was used in the following machines:
43 * SPARCserver 6xxMP/xx
44 * SPARCclassic (SPARCclassic Server)(SPARCstation LC) (4/15),
45 * SPARCclassic X (4/10)
46 * SPARCstation LX/ZX (4/30)
47 * SPARCstation Voyager
48 * SPARCstation 10/xx, SPARCserver 10/xx
49 * SPARCstation 5, SPARCserver 5
50 * SPARCstation 20/xx, SPARCserver 20
53 * Sun4d architecture was used in the following machines:
58 * Sun4c architecture was used in the following machines:
59 * SPARCstation 1/1+, SPARCserver 1/1+
65 * See for example: http://www.sunhelp.org/faq/sunref1.html
69 #define DPRINTF(fmt, args...) \
70 do { printf("CPUIRQ: " fmt , ##args); } while (0)
72 #define DPRINTF(fmt, args...)
75 #define KERNEL_LOAD_ADDR 0x00004000
76 #define CMDLINE_ADDR 0x007ff000
77 #define INITRD_LOAD_ADDR 0x00800000
78 #define PROM_SIZE_MAX (512 * 1024)
79 #define PROM_VADDR 0xffd00000
80 #define PROM_FILENAME "openbios-sparc32"
82 // Control plane, 8-bit and 24-bit planes
83 #define TCX_SIZE (9 * 1024 * 1024)
89 target_phys_addr_t iommu_base
, slavio_base
;
90 target_phys_addr_t intctl_base
, counter_base
, nvram_base
, ms_kb_base
;
91 target_phys_addr_t serial_base
, fd_base
;
92 target_phys_addr_t idreg_base
, dma_base
, esp_base
, le_base
;
93 target_phys_addr_t tcx_base
, cs_base
, apc_base
, aux1_base
, aux2_base
;
94 target_phys_addr_t ecc_base
;
96 target_phys_addr_t sun4c_intctl_base
, sun4c_counter_base
;
97 long vram_size
, nvram_size
;
98 // IRQ numbers are not PIL ones, but master interrupt controller
99 // register bit numbers
100 int intctl_g_intr
, esp_irq
, le_irq
, clock_irq
, clock1_irq
;
101 int ser_irq
, ms_kb_irq
, fd_irq
, me_irq
, cs_irq
, ecc_irq
;
102 int machine_id
; // For NVRAM
103 uint32_t iommu_version
;
104 uint32_t intbit_to_level
[32];
106 const char * const default_cpu_model
;
109 #define MAX_IOUNITS 5
112 target_phys_addr_t iounit_bases
[MAX_IOUNITS
], slavio_base
;
113 target_phys_addr_t counter_base
, nvram_base
, ms_kb_base
;
114 target_phys_addr_t serial_base
;
115 target_phys_addr_t espdma_base
, esp_base
;
116 target_phys_addr_t ledma_base
, le_base
;
117 target_phys_addr_t tcx_base
;
118 target_phys_addr_t sbi_base
;
119 unsigned long vram_size
, nvram_size
;
120 // IRQ numbers are not PIL ones, but SBI register bit numbers
121 int esp_irq
, le_irq
, clock_irq
, clock1_irq
;
122 int ser_irq
, ms_kb_irq
, me_irq
;
123 int machine_id
; // For NVRAM
124 uint32_t iounit_version
;
126 const char * const default_cpu_model
;
129 int DMA_get_channel_mode (int nchan
)
133 int DMA_read_memory (int nchan
, void *buf
, int pos
, int size
)
137 int DMA_write_memory (int nchan
, void *buf
, int pos
, int size
)
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
,
152 static int nvram_boot_set(void *opaque
, const char *boot_device
)
155 uint8_t image
[sizeof(ohwcfg_v3_t
)];
156 ohwcfg_v3_t
*header
= (ohwcfg_v3_t
*)&image
;
157 m48t59_t
*nvram
= (m48t59_t
*)opaque
;
159 for (i
= 0; i
< sizeof(image
); i
++)
160 image
[i
] = m48t59_read(nvram
, i
) & 0xff;
162 strcpy((char *)header
->boot_devices
, boot_device
);
163 header
->nboot_devices
= strlen(boot_device
) & 0xff;
164 header
->crc
= cpu_to_be16(OHW_compute_crc(header
, 0x00, 0xF8));
166 for (i
= 0; i
< sizeof(image
); i
++)
167 m48t59_write(nvram
, i
, image
[i
]);
172 extern int nographic
;
174 static void nvram_init(m48t59_t
*nvram
, uint8_t *macaddr
, const char *cmdline
,
175 const char *boot_devices
, ram_addr_t RAM_size
,
176 uint32_t kernel_size
,
177 int width
, int height
, int depth
,
178 int machine_id
, const char *arch
)
182 uint8_t image
[0x1ff0];
183 ohwcfg_v3_t
*header
= (ohwcfg_v3_t
*)&image
;
184 struct sparc_arch_cfg
*sparc_header
;
185 struct OpenBIOS_nvpart_v1
*part_header
;
187 memset(image
, '\0', sizeof(image
));
189 // Try to match PPC NVRAM
190 strcpy((char *)header
->struct_ident
, "QEMU_BIOS");
191 header
->struct_version
= cpu_to_be32(3); /* structure v3 */
193 header
->nvram_size
= cpu_to_be16(0x2000);
194 header
->nvram_arch_ptr
= cpu_to_be16(sizeof(ohwcfg_v3_t
));
195 header
->nvram_arch_size
= cpu_to_be16(sizeof(struct sparc_arch_cfg
));
196 strcpy((char *)header
->arch
, arch
);
197 header
->nb_cpus
= smp_cpus
& 0xff;
198 header
->RAM0_base
= 0;
199 header
->RAM0_size
= cpu_to_be64((uint64_t)RAM_size
);
200 strcpy((char *)header
->boot_devices
, boot_devices
);
201 header
->nboot_devices
= strlen(boot_devices
) & 0xff;
202 header
->kernel_image
= cpu_to_be64((uint64_t)KERNEL_LOAD_ADDR
);
203 header
->kernel_size
= cpu_to_be64((uint64_t)kernel_size
);
205 pstrcpy_targphys(CMDLINE_ADDR
, TARGET_PAGE_SIZE
, cmdline
);
206 header
->cmdline
= cpu_to_be64((uint64_t)CMDLINE_ADDR
);
207 header
->cmdline_size
= cpu_to_be64((uint64_t)strlen(cmdline
));
209 // XXX add initrd_image, initrd_size
210 header
->width
= cpu_to_be16(width
);
211 header
->height
= cpu_to_be16(height
);
212 header
->depth
= cpu_to_be16(depth
);
214 header
->graphic_flags
= cpu_to_be16(OHW_GF_NOGRAPHICS
);
216 header
->crc
= cpu_to_be16(OHW_compute_crc(header
, 0x00, 0xF8));
218 // Architecture specific header
219 start
= sizeof(ohwcfg_v3_t
);
220 sparc_header
= (struct sparc_arch_cfg
*)&image
[start
];
221 sparc_header
->valid
= 0;
222 start
+= sizeof(struct sparc_arch_cfg
);
224 // OpenBIOS nvram variables
225 // Variable partition
226 part_header
= (struct OpenBIOS_nvpart_v1
*)&image
[start
];
227 part_header
->signature
= OPENBIOS_PART_SYSTEM
;
228 strcpy(part_header
->name
, "system");
230 end
= start
+ sizeof(struct OpenBIOS_nvpart_v1
);
231 for (i
= 0; i
< nb_prom_envs
; i
++)
232 end
= OpenBIOS_set_var(image
, end
, prom_envs
[i
]);
237 end
= start
+ ((end
- start
+ 15) & ~15);
238 OpenBIOS_finish_partition(part_header
, end
- start
);
242 part_header
= (struct OpenBIOS_nvpart_v1
*)&image
[start
];
243 part_header
->signature
= OPENBIOS_PART_FREE
;
244 strcpy(part_header
->name
, "free");
247 OpenBIOS_finish_partition(part_header
, end
- start
);
249 Sun_init_header((struct Sun_nvram
*)&image
[0x1fd8], macaddr
, machine_id
);
251 for (i
= 0; i
< sizeof(image
); i
++)
252 m48t59_write(nvram
, i
, image
[i
]);
254 qemu_register_boot_set(nvram_boot_set
, nvram
);
257 static void *slavio_intctl
;
262 slavio_pic_info(slavio_intctl
);
268 slavio_irq_info(slavio_intctl
);
271 void cpu_check_irqs(CPUState
*env
)
273 if (env
->pil_in
&& (env
->interrupt_index
== 0 ||
274 (env
->interrupt_index
& ~15) == TT_EXTINT
)) {
277 for (i
= 15; i
> 0; i
--) {
278 if (env
->pil_in
& (1 << i
)) {
279 int old_interrupt
= env
->interrupt_index
;
281 env
->interrupt_index
= TT_EXTINT
| i
;
282 if (old_interrupt
!= env
->interrupt_index
) {
283 DPRINTF("Set CPU IRQ %d\n", i
);
284 cpu_interrupt(env
, CPU_INTERRUPT_HARD
);
289 } else if (!env
->pil_in
&& (env
->interrupt_index
& ~15) == TT_EXTINT
) {
290 DPRINTF("Reset CPU IRQ %d\n", env
->interrupt_index
& 15);
291 env
->interrupt_index
= 0;
292 cpu_reset_interrupt(env
, CPU_INTERRUPT_HARD
);
296 static void cpu_set_irq(void *opaque
, int irq
, int level
)
298 CPUState
*env
= opaque
;
301 DPRINTF("Raise CPU IRQ %d\n", irq
);
303 env
->pil_in
|= 1 << irq
;
306 DPRINTF("Lower CPU IRQ %d\n", irq
);
307 env
->pil_in
&= ~(1 << irq
);
312 static void dummy_cpu_set_irq(void *opaque
, int irq
, int level
)
316 static void *slavio_misc
;
318 void qemu_system_powerdown(void)
320 slavio_set_power_fail(slavio_misc
, 1);
323 static void main_cpu_reset(void *opaque
)
325 CPUState
*env
= opaque
;
331 static void secondary_cpu_reset(void *opaque
)
333 CPUState
*env
= opaque
;
339 static unsigned long sun4m_load_kernel(const char *kernel_filename
,
340 const char *initrd_filename
,
345 long initrd_size
, kernel_size
;
347 linux_boot
= (kernel_filename
!= NULL
);
351 kernel_size
= load_elf(kernel_filename
, -0xf0000000ULL
, NULL
, NULL
,
354 kernel_size
= load_aout(kernel_filename
, KERNEL_LOAD_ADDR
,
355 RAM_size
- KERNEL_LOAD_ADDR
);
357 kernel_size
= load_image_targphys(kernel_filename
,
359 RAM_size
- KERNEL_LOAD_ADDR
);
360 if (kernel_size
< 0) {
361 fprintf(stderr
, "qemu: could not load kernel '%s'\n",
368 if (initrd_filename
) {
369 initrd_size
= load_image_targphys(initrd_filename
,
371 RAM_size
- INITRD_LOAD_ADDR
);
372 if (initrd_size
< 0) {
373 fprintf(stderr
, "qemu: could not load initial ram disk '%s'\n",
378 if (initrd_size
> 0) {
379 for (i
= 0; i
< 64 * TARGET_PAGE_SIZE
; i
+= TARGET_PAGE_SIZE
) {
380 if (ldl_phys(KERNEL_LOAD_ADDR
+ i
) == 0x48647253) { // HdrS
381 stl_phys(KERNEL_LOAD_ADDR
+ i
+ 16, INITRD_LOAD_ADDR
);
382 stl_phys(KERNEL_LOAD_ADDR
+ i
+ 20, initrd_size
);
391 static void sun4m_hw_init(const struct hwdef
*hwdef
, ram_addr_t RAM_size
,
392 const char *boot_device
,
393 DisplayState
*ds
, const char *kernel_filename
,
394 const char *kernel_cmdline
,
395 const char *initrd_filename
, const char *cpu_model
)
398 CPUState
*env
, *envs
[MAX_CPUS
];
400 void *iommu
, *espdma
, *ledma
, *main_esp
, *nvram
;
401 qemu_irq
*cpu_irqs
[MAX_CPUS
], *slavio_irq
, *slavio_cpu_irq
,
402 *espdma_irq
, *ledma_irq
;
403 qemu_irq
*esp_reset
, *le_reset
;
405 unsigned long prom_offset
, kernel_size
;
408 BlockDriverState
*fd
[MAX_FD
];
413 cpu_model
= hwdef
->default_cpu_model
;
415 for(i
= 0; i
< smp_cpus
; i
++) {
416 env
= cpu_init(cpu_model
);
418 fprintf(stderr
, "qemu: Unable to find Sparc CPU definition\n");
421 cpu_sparc_set_id(env
, i
);
424 qemu_register_reset(main_cpu_reset
, env
);
426 qemu_register_reset(secondary_cpu_reset
, env
);
429 register_savevm("cpu", i
, 4, cpu_save
, cpu_load
, env
);
430 cpu_irqs
[i
] = qemu_allocate_irqs(cpu_set_irq
, envs
[i
], MAX_PILS
);
431 env
->prom_addr
= hwdef
->slavio_base
;
434 for (i
= smp_cpus
; i
< MAX_CPUS
; i
++)
435 cpu_irqs
[i
] = qemu_allocate_irqs(dummy_cpu_set_irq
, NULL
, MAX_PILS
);
439 if ((uint64_t)RAM_size
> hwdef
->max_mem
) {
441 "qemu: Too much memory for this machine: %d, maximum %d\n",
442 (unsigned int)(RAM_size
/ (1024 * 1024)),
443 (unsigned int)(hwdef
->max_mem
/ (1024 * 1024)));
446 cpu_register_physical_memory(0, RAM_size
, 0);
449 prom_offset
= RAM_size
+ hwdef
->vram_size
;
450 cpu_register_physical_memory(hwdef
->slavio_base
,
451 (PROM_SIZE_MAX
+ TARGET_PAGE_SIZE
- 1) &
453 prom_offset
| IO_MEM_ROM
);
455 if (bios_name
== NULL
)
456 bios_name
= PROM_FILENAME
;
457 snprintf(buf
, sizeof(buf
), "%s/%s", bios_dir
, bios_name
);
458 ret
= load_elf(buf
, hwdef
->slavio_base
- PROM_VADDR
, NULL
, NULL
, NULL
);
459 if (ret
< 0 || ret
> PROM_SIZE_MAX
)
460 ret
= load_image_targphys(buf
, hwdef
->slavio_base
, PROM_SIZE_MAX
);
461 if (ret
< 0 || ret
> PROM_SIZE_MAX
) {
462 fprintf(stderr
, "qemu: could not load prom '%s'\n",
466 prom_offset
+= (ret
+ TARGET_PAGE_SIZE
- 1) & TARGET_PAGE_MASK
;
469 slavio_intctl
= slavio_intctl_init(hwdef
->intctl_base
,
470 hwdef
->intctl_base
+ 0x10000ULL
,
471 &hwdef
->intbit_to_level
[0],
472 &slavio_irq
, &slavio_cpu_irq
,
476 if (hwdef
->idreg_base
!= (target_phys_addr_t
)-1) {
477 static const uint8_t idreg_data
[] = { 0xfe, 0x81, 0x01, 0x03 };
479 cpu_register_physical_memory(hwdef
->idreg_base
, sizeof(idreg_data
),
480 prom_offset
| IO_MEM_ROM
);
481 cpu_physical_memory_write_rom(hwdef
->idreg_base
, idreg_data
,
485 iommu
= iommu_init(hwdef
->iommu_base
, hwdef
->iommu_version
,
486 slavio_irq
[hwdef
->me_irq
]);
488 espdma
= sparc32_dma_init(hwdef
->dma_base
, slavio_irq
[hwdef
->esp_irq
],
489 iommu
, &espdma_irq
, &esp_reset
);
491 ledma
= sparc32_dma_init(hwdef
->dma_base
+ 16ULL,
492 slavio_irq
[hwdef
->le_irq
], iommu
, &ledma_irq
,
495 if (graphic_depth
!= 8 && graphic_depth
!= 24) {
496 fprintf(stderr
, "qemu: Unsupported depth: %d\n", graphic_depth
);
499 tcx_init(ds
, hwdef
->tcx_base
, phys_ram_base
+ RAM_size
, RAM_size
,
500 hwdef
->vram_size
, graphic_width
, graphic_height
, graphic_depth
);
502 if (nd_table
[0].model
== NULL
503 || strcmp(nd_table
[0].model
, "lance") == 0) {
504 lance_init(&nd_table
[0], hwdef
->le_base
, ledma
, *ledma_irq
, le_reset
);
505 } else if (strcmp(nd_table
[0].model
, "?") == 0) {
506 fprintf(stderr
, "qemu: Supported NICs: lance\n");
509 fprintf(stderr
, "qemu: Unsupported NIC: %s\n", nd_table
[0].model
);
513 nvram
= m48t59_init(slavio_irq
[0], hwdef
->nvram_base
, 0,
514 hwdef
->nvram_size
, 8);
516 slavio_timer_init_all(hwdef
->counter_base
, slavio_irq
[hwdef
->clock1_irq
],
517 slavio_cpu_irq
, smp_cpus
);
519 slavio_serial_ms_kbd_init(hwdef
->ms_kb_base
, slavio_irq
[hwdef
->ms_kb_irq
],
521 // Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
522 // Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
523 slavio_serial_init(hwdef
->serial_base
, slavio_irq
[hwdef
->ser_irq
],
524 serial_hds
[1], serial_hds
[0]);
526 slavio_misc
= slavio_misc_init(hwdef
->slavio_base
, hwdef
->apc_base
,
527 hwdef
->aux1_base
, hwdef
->aux2_base
,
528 slavio_irq
[hwdef
->me_irq
], envs
[0],
531 if (hwdef
->fd_base
!= (target_phys_addr_t
)-1) {
532 /* there is zero or one floppy drive */
533 memset(fd
, 0, sizeof(fd
));
534 drive_index
= drive_get_index(IF_FLOPPY
, 0, 0);
535 if (drive_index
!= -1)
536 fd
[0] = drives_table
[drive_index
].bdrv
;
538 sun4m_fdctrl_init(slavio_irq
[hwdef
->fd_irq
], hwdef
->fd_base
, fd
,
542 if (drive_get_max_bus(IF_SCSI
) > 0) {
543 fprintf(stderr
, "qemu: too many SCSI bus\n");
547 main_esp
= esp_init(hwdef
->esp_base
, 2,
548 espdma_memory_read
, espdma_memory_write
,
549 espdma
, *espdma_irq
, esp_reset
);
551 for (i
= 0; i
< ESP_MAX_DEVS
; i
++) {
552 drive_index
= drive_get_index(IF_SCSI
, 0, i
);
553 if (drive_index
== -1)
555 esp_scsi_attach(main_esp
, drives_table
[drive_index
].bdrv
, i
);
558 if (hwdef
->cs_base
!= (target_phys_addr_t
)-1)
559 cs_init(hwdef
->cs_base
, hwdef
->cs_irq
, slavio_intctl
);
561 kernel_size
= sun4m_load_kernel(kernel_filename
, initrd_filename
,
564 nvram_init(nvram
, (uint8_t *)&nd_table
[0].macaddr
, kernel_cmdline
,
565 boot_device
, RAM_size
, kernel_size
, graphic_width
,
566 graphic_height
, graphic_depth
, hwdef
->machine_id
, "Sun4m");
568 if (hwdef
->ecc_base
!= (target_phys_addr_t
)-1)
569 ecc_init(hwdef
->ecc_base
, slavio_irq
[hwdef
->ecc_irq
],
573 static void sun4c_hw_init(const struct hwdef
*hwdef
, ram_addr_t RAM_size
,
574 const char *boot_device
,
575 DisplayState
*ds
, const char *kernel_filename
,
576 const char *kernel_cmdline
,
577 const char *initrd_filename
, const char *cpu_model
)
581 void *iommu
, *espdma
, *ledma
, *main_esp
, *nvram
;
582 qemu_irq
*cpu_irqs
, *slavio_irq
, *espdma_irq
, *ledma_irq
;
583 qemu_irq
*esp_reset
, *le_reset
;
585 unsigned long prom_offset
, kernel_size
;
588 BlockDriverState
*fd
[MAX_FD
];
593 cpu_model
= hwdef
->default_cpu_model
;
595 env
= cpu_init(cpu_model
);
597 fprintf(stderr
, "qemu: Unable to find Sparc CPU definition\n");
601 cpu_sparc_set_id(env
, 0);
603 qemu_register_reset(main_cpu_reset
, env
);
604 register_savevm("cpu", 0, 4, cpu_save
, cpu_load
, env
);
605 cpu_irqs
= qemu_allocate_irqs(cpu_set_irq
, env
, MAX_PILS
);
606 env
->prom_addr
= hwdef
->slavio_base
;
609 if ((uint64_t)RAM_size
> hwdef
->max_mem
) {
611 "qemu: Too much memory for this machine: %d, maximum %d\n",
612 (unsigned int)(RAM_size
/ (1024 * 1024)),
613 (unsigned int)(hwdef
->max_mem
/ (1024 * 1024)));
616 cpu_register_physical_memory(0, RAM_size
, 0);
619 prom_offset
= RAM_size
+ hwdef
->vram_size
;
620 cpu_register_physical_memory(hwdef
->slavio_base
,
621 (PROM_SIZE_MAX
+ TARGET_PAGE_SIZE
- 1) &
623 prom_offset
| IO_MEM_ROM
);
625 if (bios_name
== NULL
)
626 bios_name
= PROM_FILENAME
;
627 snprintf(buf
, sizeof(buf
), "%s/%s", bios_dir
, bios_name
);
628 ret
= load_elf(buf
, hwdef
->slavio_base
- PROM_VADDR
, NULL
, NULL
, NULL
);
629 if (ret
< 0 || ret
> PROM_SIZE_MAX
)
630 ret
= load_image_targphys(buf
, hwdef
->slavio_base
, PROM_SIZE_MAX
);
631 if (ret
< 0 || ret
> PROM_SIZE_MAX
) {
632 fprintf(stderr
, "qemu: could not load prom '%s'\n",
636 prom_offset
+= (ret
+ TARGET_PAGE_SIZE
- 1) & TARGET_PAGE_MASK
;
639 slavio_intctl
= sun4c_intctl_init(hwdef
->sun4c_intctl_base
,
640 &slavio_irq
, cpu_irqs
);
642 iommu
= iommu_init(hwdef
->iommu_base
, hwdef
->iommu_version
,
643 slavio_irq
[hwdef
->me_irq
]);
645 espdma
= sparc32_dma_init(hwdef
->dma_base
, slavio_irq
[hwdef
->esp_irq
],
646 iommu
, &espdma_irq
, &esp_reset
);
648 ledma
= sparc32_dma_init(hwdef
->dma_base
+ 16ULL,
649 slavio_irq
[hwdef
->le_irq
], iommu
, &ledma_irq
,
652 if (graphic_depth
!= 8 && graphic_depth
!= 24) {
653 fprintf(stderr
, "qemu: Unsupported depth: %d\n", graphic_depth
);
656 tcx_init(ds
, hwdef
->tcx_base
, phys_ram_base
+ RAM_size
, RAM_size
,
657 hwdef
->vram_size
, graphic_width
, graphic_height
, graphic_depth
);
659 if (nd_table
[0].model
== NULL
660 || strcmp(nd_table
[0].model
, "lance") == 0) {
661 lance_init(&nd_table
[0], hwdef
->le_base
, ledma
, *ledma_irq
, le_reset
);
662 } else if (strcmp(nd_table
[0].model
, "?") == 0) {
663 fprintf(stderr
, "qemu: Supported NICs: lance\n");
666 fprintf(stderr
, "qemu: Unsupported NIC: %s\n", nd_table
[0].model
);
670 nvram
= m48t59_init(slavio_irq
[0], hwdef
->nvram_base
, 0,
671 hwdef
->nvram_size
, 2);
673 slavio_serial_ms_kbd_init(hwdef
->ms_kb_base
, slavio_irq
[hwdef
->ms_kb_irq
],
675 // Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
676 // Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
677 slavio_serial_init(hwdef
->serial_base
, slavio_irq
[hwdef
->ser_irq
],
678 serial_hds
[1], serial_hds
[0]);
680 slavio_misc
= slavio_misc_init(-1, hwdef
->apc_base
,
681 hwdef
->aux1_base
, hwdef
->aux2_base
,
682 slavio_irq
[hwdef
->me_irq
], env
, &fdc_tc
);
684 if (hwdef
->fd_base
!= (target_phys_addr_t
)-1) {
685 /* there is zero or one floppy drive */
686 fd
[1] = fd
[0] = NULL
;
687 drive_index
= drive_get_index(IF_FLOPPY
, 0, 0);
688 if (drive_index
!= -1)
689 fd
[0] = drives_table
[drive_index
].bdrv
;
691 sun4m_fdctrl_init(slavio_irq
[hwdef
->fd_irq
], hwdef
->fd_base
, fd
,
695 if (drive_get_max_bus(IF_SCSI
) > 0) {
696 fprintf(stderr
, "qemu: too many SCSI bus\n");
700 main_esp
= esp_init(hwdef
->esp_base
, 2,
701 espdma_memory_read
, espdma_memory_write
,
702 espdma
, *espdma_irq
, esp_reset
);
704 for (i
= 0; i
< ESP_MAX_DEVS
; i
++) {
705 drive_index
= drive_get_index(IF_SCSI
, 0, i
);
706 if (drive_index
== -1)
708 esp_scsi_attach(main_esp
, drives_table
[drive_index
].bdrv
, i
);
711 kernel_size
= sun4m_load_kernel(kernel_filename
, initrd_filename
,
714 nvram_init(nvram
, (uint8_t *)&nd_table
[0].macaddr
, kernel_cmdline
,
715 boot_device
, RAM_size
, kernel_size
, graphic_width
,
716 graphic_height
, graphic_depth
, hwdef
->machine_id
, "Sun4c");
719 static const struct hwdef hwdefs
[] = {
722 .iommu_base
= 0x10000000,
723 .tcx_base
= 0x50000000,
724 .cs_base
= 0x6c000000,
725 .slavio_base
= 0x70000000,
726 .ms_kb_base
= 0x71000000,
727 .serial_base
= 0x71100000,
728 .nvram_base
= 0x71200000,
729 .fd_base
= 0x71400000,
730 .counter_base
= 0x71d00000,
731 .intctl_base
= 0x71e00000,
732 .idreg_base
= 0x78000000,
733 .dma_base
= 0x78400000,
734 .esp_base
= 0x78800000,
735 .le_base
= 0x78c00000,
736 .apc_base
= 0x6a000000,
737 .aux1_base
= 0x71900000,
738 .aux2_base
= 0x71910000,
740 .sun4c_intctl_base
= -1,
741 .sun4c_counter_base
= -1,
742 .vram_size
= 0x00100000,
743 .nvram_size
= 0x2000,
754 .iommu_version
= 0x05000000,
756 2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
757 6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0,
759 .max_mem
= 0x10000000,
760 .default_cpu_model
= "Fujitsu MB86904",
764 .iommu_base
= 0xfe0000000ULL
,
765 .tcx_base
= 0xe20000000ULL
,
767 .slavio_base
= 0xff0000000ULL
,
768 .ms_kb_base
= 0xff1000000ULL
,
769 .serial_base
= 0xff1100000ULL
,
770 .nvram_base
= 0xff1200000ULL
,
771 .fd_base
= 0xff1700000ULL
,
772 .counter_base
= 0xff1300000ULL
,
773 .intctl_base
= 0xff1400000ULL
,
774 .idreg_base
= 0xef0000000ULL
,
775 .dma_base
= 0xef0400000ULL
,
776 .esp_base
= 0xef0800000ULL
,
777 .le_base
= 0xef0c00000ULL
,
778 .apc_base
= 0xefa000000ULL
, // XXX should not exist
779 .aux1_base
= 0xff1800000ULL
,
780 .aux2_base
= 0xff1a01000ULL
,
781 .ecc_base
= 0xf00000000ULL
,
782 .ecc_version
= 0x10000000, // version 0, implementation 1
783 .sun4c_intctl_base
= -1,
784 .sun4c_counter_base
= -1,
785 .vram_size
= 0x00100000,
786 .nvram_size
= 0x2000,
798 .iommu_version
= 0x03000000,
800 2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
801 6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0,
803 .max_mem
= 0xf00000000ULL
,
804 .default_cpu_model
= "TI SuperSparc II",
808 .iommu_base
= 0xfe0000000ULL
,
809 .tcx_base
= 0xe20000000ULL
,
811 .slavio_base
= 0xff0000000ULL
,
812 .ms_kb_base
= 0xff1000000ULL
,
813 .serial_base
= 0xff1100000ULL
,
814 .nvram_base
= 0xff1200000ULL
,
816 .counter_base
= 0xff1300000ULL
,
817 .intctl_base
= 0xff1400000ULL
,
819 .dma_base
= 0xef0081000ULL
,
820 .esp_base
= 0xef0080000ULL
,
821 .le_base
= 0xef0060000ULL
,
822 .apc_base
= 0xefa000000ULL
, // XXX should not exist
823 .aux1_base
= 0xff1800000ULL
,
824 .aux2_base
= 0xff1a01000ULL
, // XXX should not exist
825 .ecc_base
= 0xf00000000ULL
,
826 .ecc_version
= 0x00000000, // version 0, implementation 0
827 .sun4c_intctl_base
= -1,
828 .sun4c_counter_base
= -1,
829 .vram_size
= 0x00100000,
830 .nvram_size
= 0x2000,
842 .iommu_version
= 0x01000000,
844 2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
845 6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0,
847 .max_mem
= 0xf00000000ULL
,
848 .default_cpu_model
= "TI SuperSparc II",
852 .iommu_base
= 0xfe0000000ULL
,
853 .tcx_base
= 0xe20000000ULL
,
855 .slavio_base
= 0xff0000000ULL
,
856 .ms_kb_base
= 0xff1000000ULL
,
857 .serial_base
= 0xff1100000ULL
,
858 .nvram_base
= 0xff1200000ULL
,
859 .fd_base
= 0xff1700000ULL
,
860 .counter_base
= 0xff1300000ULL
,
861 .intctl_base
= 0xff1400000ULL
,
862 .idreg_base
= 0xef0000000ULL
,
863 .dma_base
= 0xef0400000ULL
,
864 .esp_base
= 0xef0800000ULL
,
865 .le_base
= 0xef0c00000ULL
,
866 .apc_base
= 0xefa000000ULL
, // XXX should not exist
867 .aux1_base
= 0xff1800000ULL
,
868 .aux2_base
= 0xff1a01000ULL
,
869 .ecc_base
= 0xf00000000ULL
,
870 .ecc_version
= 0x20000000, // version 0, implementation 2
871 .sun4c_intctl_base
= -1,
872 .sun4c_counter_base
= -1,
873 .vram_size
= 0x00100000,
874 .nvram_size
= 0x2000,
886 .iommu_version
= 0x13000000,
888 2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
889 6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0,
891 .max_mem
= 0xf00000000ULL
,
892 .default_cpu_model
= "TI SuperSparc II",
896 .iommu_base
= 0xf8000000,
897 .tcx_base
= 0xfe000000,
899 .slavio_base
= 0xf6000000,
900 .ms_kb_base
= 0xf0000000,
901 .serial_base
= 0xf1000000,
902 .nvram_base
= 0xf2000000,
903 .fd_base
= 0xf7200000,
906 .dma_base
= 0xf8400000,
907 .esp_base
= 0xf8800000,
908 .le_base
= 0xf8c00000,
910 .aux1_base
= 0xf7400003,
912 .sun4c_intctl_base
= 0xf5000000,
913 .sun4c_counter_base
= 0xf3000000,
914 .vram_size
= 0x00100000,
926 .max_mem
= 0x10000000,
927 .default_cpu_model
= "Cypress CY7C601",
931 .iommu_base
= 0x10000000,
932 .tcx_base
= 0x50000000,
934 .slavio_base
= 0x70000000,
935 .ms_kb_base
= 0x71000000,
936 .serial_base
= 0x71100000,
937 .nvram_base
= 0x71200000,
938 .fd_base
= 0x71400000,
939 .counter_base
= 0x71d00000,
940 .intctl_base
= 0x71e00000,
941 .idreg_base
= 0x78000000,
942 .dma_base
= 0x78400000,
943 .esp_base
= 0x78800000,
944 .le_base
= 0x78c00000,
945 .apc_base
= 0x71300000, // pmc
946 .aux1_base
= 0x71900000,
947 .aux2_base
= 0x71910000,
949 .sun4c_intctl_base
= -1,
950 .sun4c_counter_base
= -1,
951 .vram_size
= 0x00100000,
952 .nvram_size
= 0x2000,
963 .iommu_version
= 0x05000000,
965 2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
966 6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0,
968 .max_mem
= 0x10000000,
969 .default_cpu_model
= "Fujitsu MB86904",
973 .iommu_base
= 0x10000000,
974 .tcx_base
= 0x50000000,
976 .slavio_base
= 0x70000000,
977 .ms_kb_base
= 0x71000000,
978 .serial_base
= 0x71100000,
979 .nvram_base
= 0x71200000,
980 .fd_base
= 0x71400000,
981 .counter_base
= 0x71d00000,
982 .intctl_base
= 0x71e00000,
983 .idreg_base
= 0x78000000,
984 .dma_base
= 0x78400000,
985 .esp_base
= 0x78800000,
986 .le_base
= 0x78c00000,
988 .aux1_base
= 0x71900000,
989 .aux2_base
= 0x71910000,
991 .sun4c_intctl_base
= -1,
992 .sun4c_counter_base
= -1,
993 .vram_size
= 0x00100000,
994 .nvram_size
= 0x2000,
1005 .iommu_version
= 0x04000000,
1006 .intbit_to_level
= {
1007 2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
1008 6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0,
1010 .max_mem
= 0x10000000,
1011 .default_cpu_model
= "TI MicroSparc I",
1015 .iommu_base
= 0x10000000,
1016 .tcx_base
= 0x50000000,
1017 .cs_base
= 0x6c000000,
1018 .slavio_base
= 0x70000000,
1019 .ms_kb_base
= 0x71000000,
1020 .serial_base
= 0x71100000,
1021 .nvram_base
= 0x71200000,
1022 .fd_base
= 0x71400000,
1023 .counter_base
= 0x71d00000,
1024 .intctl_base
= 0x71e00000,
1025 .idreg_base
= 0x78000000,
1026 .dma_base
= 0x78400000,
1027 .esp_base
= 0x78800000,
1028 .le_base
= 0x78c00000,
1029 .apc_base
= 0x6a000000,
1030 .aux1_base
= 0x71900000,
1031 .aux2_base
= 0x71910000,
1033 .sun4c_intctl_base
= -1,
1034 .sun4c_counter_base
= -1,
1035 .vram_size
= 0x00100000,
1036 .nvram_size
= 0x2000,
1047 .iommu_version
= 0x05000000,
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
= "Fujitsu MB86904",
1057 .iommu_base
= 0x10000000,
1058 .tcx_base
= 0x50000000,
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,
1089 .iommu_version
= 0x05000000,
1090 .intbit_to_level
= {
1091 2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
1092 6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0,
1094 .max_mem
= 0x10000000,
1095 .default_cpu_model
= "TI MicroSparc I",
1099 .iommu_base
= 0x10000000,
1100 .tcx_base
= 0x50000000, // XXX
1102 .slavio_base
= 0x70000000,
1103 .ms_kb_base
= 0x71000000,
1104 .serial_base
= 0x71100000,
1105 .nvram_base
= 0x71200000,
1106 .fd_base
= 0x71400000,
1107 .counter_base
= 0x71d00000,
1108 .intctl_base
= 0x71e00000,
1109 .idreg_base
= 0x78000000,
1110 .dma_base
= 0x78400000,
1111 .esp_base
= 0x78800000,
1112 .le_base
= 0x78c00000,
1113 .apc_base
= 0x6a000000,
1114 .aux1_base
= 0x71900000,
1115 .aux2_base
= 0x71910000,
1117 .sun4c_intctl_base
= -1,
1118 .sun4c_counter_base
= -1,
1119 .vram_size
= 0x00100000,
1120 .nvram_size
= 0x2000,
1131 .iommu_version
= 0x05000000,
1132 .intbit_to_level
= {
1133 2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12,
1134 6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0,
1136 .max_mem
= 0x10000000,
1137 .default_cpu_model
= "TI MicroSparc I",
1141 /* SPARCstation 5 hardware initialisation */
1142 static void ss5_init(ram_addr_t RAM_size
, int vga_ram_size
,
1143 const char *boot_device
, DisplayState
*ds
,
1144 const char *kernel_filename
, const char *kernel_cmdline
,
1145 const char *initrd_filename
, const char *cpu_model
)
1147 sun4m_hw_init(&hwdefs
[0], RAM_size
, boot_device
, ds
, kernel_filename
,
1148 kernel_cmdline
, initrd_filename
, cpu_model
);
1151 /* SPARCstation 10 hardware initialisation */
1152 static void ss10_init(ram_addr_t RAM_size
, int vga_ram_size
,
1153 const char *boot_device
, DisplayState
*ds
,
1154 const char *kernel_filename
, const char *kernel_cmdline
,
1155 const char *initrd_filename
, const char *cpu_model
)
1157 sun4m_hw_init(&hwdefs
[1], RAM_size
, boot_device
, ds
, kernel_filename
,
1158 kernel_cmdline
, initrd_filename
, cpu_model
);
1161 /* SPARCserver 600MP hardware initialisation */
1162 static void ss600mp_init(ram_addr_t RAM_size
, int vga_ram_size
,
1163 const char *boot_device
, DisplayState
*ds
,
1164 const char *kernel_filename
,
1165 const char *kernel_cmdline
,
1166 const char *initrd_filename
, const char *cpu_model
)
1168 sun4m_hw_init(&hwdefs
[2], RAM_size
, boot_device
, ds
, kernel_filename
,
1169 kernel_cmdline
, initrd_filename
, cpu_model
);
1172 /* SPARCstation 20 hardware initialisation */
1173 static void ss20_init(ram_addr_t RAM_size
, int vga_ram_size
,
1174 const char *boot_device
, DisplayState
*ds
,
1175 const char *kernel_filename
, const char *kernel_cmdline
,
1176 const char *initrd_filename
, const char *cpu_model
)
1178 sun4m_hw_init(&hwdefs
[3], RAM_size
, boot_device
, ds
, kernel_filename
,
1179 kernel_cmdline
, initrd_filename
, cpu_model
);
1182 /* SPARCstation 2 hardware initialisation */
1183 static void ss2_init(ram_addr_t RAM_size
, int vga_ram_size
,
1184 const char *boot_device
, DisplayState
*ds
,
1185 const char *kernel_filename
, const char *kernel_cmdline
,
1186 const char *initrd_filename
, const char *cpu_model
)
1188 sun4c_hw_init(&hwdefs
[4], RAM_size
, boot_device
, ds
, kernel_filename
,
1189 kernel_cmdline
, initrd_filename
, cpu_model
);
1192 /* SPARCstation Voyager hardware initialisation */
1193 static void vger_init(ram_addr_t RAM_size
, int vga_ram_size
,
1194 const char *boot_device
, DisplayState
*ds
,
1195 const char *kernel_filename
, const char *kernel_cmdline
,
1196 const char *initrd_filename
, const char *cpu_model
)
1198 sun4m_hw_init(&hwdefs
[5], RAM_size
, boot_device
, ds
, kernel_filename
,
1199 kernel_cmdline
, initrd_filename
, cpu_model
);
1202 /* SPARCstation LX hardware initialisation */
1203 static void ss_lx_init(ram_addr_t RAM_size
, int vga_ram_size
,
1204 const char *boot_device
, DisplayState
*ds
,
1205 const char *kernel_filename
, const char *kernel_cmdline
,
1206 const char *initrd_filename
, const char *cpu_model
)
1208 sun4m_hw_init(&hwdefs
[6], RAM_size
, boot_device
, ds
, kernel_filename
,
1209 kernel_cmdline
, initrd_filename
, cpu_model
);
1212 /* SPARCstation 4 hardware initialisation */
1213 static void ss4_init(ram_addr_t RAM_size
, int vga_ram_size
,
1214 const char *boot_device
, DisplayState
*ds
,
1215 const char *kernel_filename
, const char *kernel_cmdline
,
1216 const char *initrd_filename
, const char *cpu_model
)
1218 sun4m_hw_init(&hwdefs
[7], RAM_size
, boot_device
, ds
, kernel_filename
,
1219 kernel_cmdline
, initrd_filename
, cpu_model
);
1222 /* SPARCClassic hardware initialisation */
1223 static void scls_init(ram_addr_t RAM_size
, int vga_ram_size
,
1224 const char *boot_device
, DisplayState
*ds
,
1225 const char *kernel_filename
, const char *kernel_cmdline
,
1226 const char *initrd_filename
, const char *cpu_model
)
1228 sun4m_hw_init(&hwdefs
[8], RAM_size
, boot_device
, ds
, kernel_filename
,
1229 kernel_cmdline
, initrd_filename
, cpu_model
);
1232 /* SPARCbook hardware initialisation */
1233 static void sbook_init(ram_addr_t RAM_size
, int vga_ram_size
,
1234 const char *boot_device
, DisplayState
*ds
,
1235 const char *kernel_filename
, const char *kernel_cmdline
,
1236 const char *initrd_filename
, const char *cpu_model
)
1238 sun4m_hw_init(&hwdefs
[9], RAM_size
, boot_device
, ds
, kernel_filename
,
1239 kernel_cmdline
, initrd_filename
, cpu_model
);
1242 QEMUMachine ss5_machine
= {
1244 "Sun4m platform, SPARCstation 5",
1246 PROM_SIZE_MAX
+ TCX_SIZE
,
1249 QEMUMachine ss10_machine
= {
1251 "Sun4m platform, SPARCstation 10",
1253 PROM_SIZE_MAX
+ TCX_SIZE
,
1256 QEMUMachine ss600mp_machine
= {
1258 "Sun4m platform, SPARCserver 600MP",
1260 PROM_SIZE_MAX
+ TCX_SIZE
,
1263 QEMUMachine ss20_machine
= {
1265 "Sun4m platform, SPARCstation 20",
1267 PROM_SIZE_MAX
+ TCX_SIZE
,
1270 QEMUMachine ss2_machine
= {
1272 "Sun4c platform, SPARCstation 2",
1274 PROM_SIZE_MAX
+ TCX_SIZE
,
1277 QEMUMachine voyager_machine
= {
1279 "Sun4m platform, SPARCstation Voyager",
1281 PROM_SIZE_MAX
+ TCX_SIZE
,
1284 QEMUMachine ss_lx_machine
= {
1286 "Sun4m platform, SPARCstation LX",
1288 PROM_SIZE_MAX
+ TCX_SIZE
,
1291 QEMUMachine ss4_machine
= {
1293 "Sun4m platform, SPARCstation 4",
1295 PROM_SIZE_MAX
+ TCX_SIZE
,
1298 QEMUMachine scls_machine
= {
1300 "Sun4m platform, SPARCClassic",
1302 PROM_SIZE_MAX
+ TCX_SIZE
,
1305 QEMUMachine sbook_machine
= {
1307 "Sun4m platform, SPARCbook",
1309 PROM_SIZE_MAX
+ TCX_SIZE
,
1312 static const struct sun4d_hwdef sun4d_hwdefs
[] = {
1322 .tcx_base
= 0x820000000ULL
,
1323 .slavio_base
= 0xf00000000ULL
,
1324 .ms_kb_base
= 0xf00240000ULL
,
1325 .serial_base
= 0xf00200000ULL
,
1326 .nvram_base
= 0xf00280000ULL
,
1327 .counter_base
= 0xf00300000ULL
,
1328 .espdma_base
= 0x800081000ULL
,
1329 .esp_base
= 0x800080000ULL
,
1330 .ledma_base
= 0x800040000ULL
,
1331 .le_base
= 0x800060000ULL
,
1332 .sbi_base
= 0xf02800000ULL
,
1333 .vram_size
= 0x00100000,
1334 .nvram_size
= 0x2000,
1342 .iounit_version
= 0x03000000,
1343 .max_mem
= 0xf00000000ULL
,
1344 .default_cpu_model
= "TI SuperSparc II",
1355 .tcx_base
= 0x820000000ULL
,
1356 .slavio_base
= 0xf00000000ULL
,
1357 .ms_kb_base
= 0xf00240000ULL
,
1358 .serial_base
= 0xf00200000ULL
,
1359 .nvram_base
= 0xf00280000ULL
,
1360 .counter_base
= 0xf00300000ULL
,
1361 .espdma_base
= 0x800081000ULL
,
1362 .esp_base
= 0x800080000ULL
,
1363 .ledma_base
= 0x800040000ULL
,
1364 .le_base
= 0x800060000ULL
,
1365 .sbi_base
= 0xf02800000ULL
,
1366 .vram_size
= 0x00100000,
1367 .nvram_size
= 0x2000,
1375 .iounit_version
= 0x03000000,
1376 .max_mem
= 0xf00000000ULL
,
1377 .default_cpu_model
= "TI SuperSparc II",
1381 static void sun4d_hw_init(const struct sun4d_hwdef
*hwdef
, ram_addr_t RAM_size
,
1382 const char *boot_device
,
1383 DisplayState
*ds
, const char *kernel_filename
,
1384 const char *kernel_cmdline
,
1385 const char *initrd_filename
, const char *cpu_model
)
1387 CPUState
*env
, *envs
[MAX_CPUS
];
1389 void *iounits
[MAX_IOUNITS
], *espdma
, *ledma
, *main_esp
, *nvram
, *sbi
;
1390 qemu_irq
*cpu_irqs
[MAX_CPUS
], *sbi_irq
, *sbi_cpu_irq
,
1391 *espdma_irq
, *ledma_irq
;
1392 qemu_irq
*esp_reset
, *le_reset
;
1393 unsigned long prom_offset
, kernel_size
;
1400 cpu_model
= hwdef
->default_cpu_model
;
1402 for (i
= 0; i
< smp_cpus
; i
++) {
1403 env
= cpu_init(cpu_model
);
1405 fprintf(stderr
, "qemu: Unable to find Sparc CPU definition\n");
1408 cpu_sparc_set_id(env
, i
);
1411 qemu_register_reset(main_cpu_reset
, env
);
1413 qemu_register_reset(secondary_cpu_reset
, env
);
1416 register_savevm("cpu", i
, 4, cpu_save
, cpu_load
, env
);
1417 cpu_irqs
[i
] = qemu_allocate_irqs(cpu_set_irq
, envs
[i
], MAX_PILS
);
1418 env
->prom_addr
= hwdef
->slavio_base
;
1421 for (i
= smp_cpus
; i
< MAX_CPUS
; i
++)
1422 cpu_irqs
[i
] = qemu_allocate_irqs(dummy_cpu_set_irq
, NULL
, MAX_PILS
);
1425 if ((uint64_t)RAM_size
> hwdef
->max_mem
) {
1427 "qemu: Too much memory for this machine: %d, maximum %d\n",
1428 (unsigned int)(RAM_size
/ (1024 * 1024)),
1429 (unsigned int)(hwdef
->max_mem
/ (1024 * 1024)));
1432 cpu_register_physical_memory(0, RAM_size
, 0);
1434 /* load boot prom */
1435 prom_offset
= RAM_size
+ hwdef
->vram_size
;
1436 cpu_register_physical_memory(hwdef
->slavio_base
,
1437 (PROM_SIZE_MAX
+ TARGET_PAGE_SIZE
- 1) &
1439 prom_offset
| IO_MEM_ROM
);
1441 if (bios_name
== NULL
)
1442 bios_name
= PROM_FILENAME
;
1443 snprintf(buf
, sizeof(buf
), "%s/%s", bios_dir
, bios_name
);
1444 ret
= load_elf(buf
, hwdef
->slavio_base
- PROM_VADDR
, NULL
, NULL
, NULL
);
1445 if (ret
< 0 || ret
> PROM_SIZE_MAX
)
1446 ret
= load_image_targphys(buf
, hwdef
->slavio_base
, PROM_SIZE_MAX
);
1447 if (ret
< 0 || ret
> PROM_SIZE_MAX
) {
1448 fprintf(stderr
, "qemu: could not load prom '%s'\n",
1453 /* set up devices */
1454 sbi
= sbi_init(hwdef
->sbi_base
, &sbi_irq
, &sbi_cpu_irq
, cpu_irqs
);
1456 for (i
= 0; i
< MAX_IOUNITS
; i
++)
1457 if (hwdef
->iounit_bases
[i
] != (target_phys_addr_t
)-1)
1458 iounits
[i
] = iommu_init(hwdef
->iounit_bases
[i
],
1459 hwdef
->iounit_version
,
1460 sbi_irq
[hwdef
->me_irq
]);
1462 espdma
= sparc32_dma_init(hwdef
->espdma_base
, sbi_irq
[hwdef
->esp_irq
],
1463 iounits
[0], &espdma_irq
, &esp_reset
);
1465 ledma
= sparc32_dma_init(hwdef
->ledma_base
, sbi_irq
[hwdef
->le_irq
],
1466 iounits
[0], &ledma_irq
, &le_reset
);
1468 if (graphic_depth
!= 8 && graphic_depth
!= 24) {
1469 fprintf(stderr
, "qemu: Unsupported depth: %d\n", graphic_depth
);
1472 tcx_init(ds
, hwdef
->tcx_base
, phys_ram_base
+ RAM_size
, RAM_size
,
1473 hwdef
->vram_size
, graphic_width
, graphic_height
, graphic_depth
);
1475 if (nd_table
[0].model
== NULL
1476 || strcmp(nd_table
[0].model
, "lance") == 0) {
1477 lance_init(&nd_table
[0], hwdef
->le_base
, ledma
, *ledma_irq
, le_reset
);
1478 } else if (strcmp(nd_table
[0].model
, "?") == 0) {
1479 fprintf(stderr
, "qemu: Supported NICs: lance\n");
1482 fprintf(stderr
, "qemu: Unsupported NIC: %s\n", nd_table
[0].model
);
1486 nvram
= m48t59_init(sbi_irq
[0], hwdef
->nvram_base
, 0,
1487 hwdef
->nvram_size
, 8);
1489 slavio_timer_init_all(hwdef
->counter_base
, sbi_irq
[hwdef
->clock1_irq
],
1490 sbi_cpu_irq
, smp_cpus
);
1492 slavio_serial_ms_kbd_init(hwdef
->ms_kb_base
, sbi_irq
[hwdef
->ms_kb_irq
],
1494 // Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
1495 // Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
1496 slavio_serial_init(hwdef
->serial_base
, sbi_irq
[hwdef
->ser_irq
],
1497 serial_hds
[1], serial_hds
[0]);
1499 if (drive_get_max_bus(IF_SCSI
) > 0) {
1500 fprintf(stderr
, "qemu: too many SCSI bus\n");
1504 main_esp
= esp_init(hwdef
->esp_base
, 2,
1505 espdma_memory_read
, espdma_memory_write
,
1506 espdma
, *espdma_irq
, esp_reset
);
1508 for (i
= 0; i
< ESP_MAX_DEVS
; i
++) {
1509 drive_index
= drive_get_index(IF_SCSI
, 0, i
);
1510 if (drive_index
== -1)
1512 esp_scsi_attach(main_esp
, drives_table
[drive_index
].bdrv
, i
);
1515 kernel_size
= sun4m_load_kernel(kernel_filename
, initrd_filename
,
1518 nvram_init(nvram
, (uint8_t *)&nd_table
[0].macaddr
, kernel_cmdline
,
1519 boot_device
, RAM_size
, kernel_size
, graphic_width
,
1520 graphic_height
, graphic_depth
, hwdef
->machine_id
, "Sun4d");
1523 /* SPARCserver 1000 hardware initialisation */
1524 static void ss1000_init(ram_addr_t RAM_size
, int vga_ram_size
,
1525 const char *boot_device
, DisplayState
*ds
,
1526 const char *kernel_filename
, const char *kernel_cmdline
,
1527 const char *initrd_filename
, const char *cpu_model
)
1529 sun4d_hw_init(&sun4d_hwdefs
[0], RAM_size
, boot_device
, ds
, kernel_filename
,
1530 kernel_cmdline
, initrd_filename
, cpu_model
);
1533 /* SPARCcenter 2000 hardware initialisation */
1534 static void ss2000_init(ram_addr_t RAM_size
, int vga_ram_size
,
1535 const char *boot_device
, DisplayState
*ds
,
1536 const char *kernel_filename
, const char *kernel_cmdline
,
1537 const char *initrd_filename
, const char *cpu_model
)
1539 sun4d_hw_init(&sun4d_hwdefs
[1], RAM_size
, boot_device
, ds
, kernel_filename
,
1540 kernel_cmdline
, initrd_filename
, cpu_model
);
1543 QEMUMachine ss1000_machine
= {
1545 "Sun4d platform, SPARCserver 1000",
1547 PROM_SIZE_MAX
+ TCX_SIZE
,
1550 QEMUMachine ss2000_machine
= {
1552 "Sun4d platform, SPARCcenter 2000",
1554 PROM_SIZE_MAX
+ TCX_SIZE
,