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/osdep.h"
26 #include "qemu/units.h"
27 #include "qapi/error.h"
28 #include "qemu/datadir.h"
29 #include "qemu-common.h"
31 #include "hw/sysbus.h"
32 #include "qemu/error-report.h"
33 #include "qemu/timer.h"
34 #include "hw/sparc/sun4m_iommu.h"
35 #include "hw/rtc/m48t59.h"
36 #include "migration/vmstate.h"
37 #include "hw/sparc/sparc32_dma.h"
38 #include "hw/block/fdc.h"
39 #include "sysemu/reset.h"
40 #include "sysemu/runstate.h"
41 #include "sysemu/sysemu.h"
43 #include "hw/boards.h"
44 #include "hw/scsi/esp.h"
45 #include "hw/nvram/sun_nvram.h"
46 #include "hw/qdev-properties.h"
47 #include "hw/nvram/chrp_nvram.h"
48 #include "hw/nvram/fw_cfg.h"
49 #include "hw/char/escc.h"
50 #include "hw/misc/empty_slot.h"
51 #include "hw/misc/unimp.h"
53 #include "hw/loader.h"
56 #include "qom/object.h"
59 * Sun4m architecture was used in the following machines:
61 * SPARCserver 6xxMP/xx
62 * SPARCclassic (SPARCclassic Server)(SPARCstation LC) (4/15),
63 * SPARCclassic X (4/10)
64 * SPARCstation LX/ZX (4/30)
65 * SPARCstation Voyager
66 * SPARCstation 10/xx, SPARCserver 10/xx
67 * SPARCstation 5, SPARCserver 5
68 * SPARCstation 20/xx, SPARCserver 20
71 * See for example: http://www.sunhelp.org/faq/sunref1.html
74 #define KERNEL_LOAD_ADDR 0x00004000
75 #define CMDLINE_ADDR 0x007ff000
76 #define INITRD_LOAD_ADDR 0x00800000
77 #define PROM_SIZE_MAX (1 * MiB)
78 #define PROM_VADDR 0xffd00000
79 #define PROM_FILENAME "openbios-sparc32"
80 #define CFG_ADDR 0xd00000510ULL
81 #define FW_CFG_SUN4M_DEPTH (FW_CFG_ARCH_LOCAL + 0x00)
82 #define FW_CFG_SUN4M_WIDTH (FW_CFG_ARCH_LOCAL + 0x01)
83 #define FW_CFG_SUN4M_HEIGHT (FW_CFG_ARCH_LOCAL + 0x02)
89 #define ESCC_CLOCK 4915200
92 hwaddr iommu_base
, iommu_pad_base
, iommu_pad_len
, slavio_base
;
93 hwaddr intctl_base
, counter_base
, nvram_base
, ms_kb_base
;
94 hwaddr serial_base
, fd_base
;
95 hwaddr afx_base
, idreg_base
, dma_base
, esp_base
, le_base
;
96 hwaddr tcx_base
, cs_base
, apc_base
, aux1_base
, aux2_base
;
97 hwaddr bpp_base
, dbri_base
, sx_base
;
99 hwaddr reg_base
, vram_base
;
103 uint32_t ecc_version
;
104 uint32_t iommu_version
;
106 uint8_t nvram_machine_id
;
109 const char *fw_cfg_arch_key_name(uint16_t key
)
111 static const struct {
114 } fw_cfg_arch_wellknown_keys
[] = {
115 {FW_CFG_SUN4M_DEPTH
, "depth"},
116 {FW_CFG_SUN4M_WIDTH
, "width"},
117 {FW_CFG_SUN4M_HEIGHT
, "height"},
120 for (size_t i
= 0; i
< ARRAY_SIZE(fw_cfg_arch_wellknown_keys
); i
++) {
121 if (fw_cfg_arch_wellknown_keys
[i
].key
== key
) {
122 return fw_cfg_arch_wellknown_keys
[i
].name
;
128 static void fw_cfg_boot_set(void *opaque
, const char *boot_device
,
131 fw_cfg_modify_i16(opaque
, FW_CFG_BOOT_DEVICE
, boot_device
[0]);
134 static void nvram_init(Nvram
*nvram
, uint8_t *macaddr
,
135 const char *cmdline
, const char *boot_devices
,
136 ram_addr_t RAM_size
, uint32_t kernel_size
,
137 int width
, int height
, int depth
,
138 int nvram_machine_id
, const char *arch
)
142 uint8_t image
[0x1ff0];
143 NvramClass
*k
= NVRAM_GET_CLASS(nvram
);
145 memset(image
, '\0', sizeof(image
));
147 /* OpenBIOS nvram variables partition */
148 sysp_end
= chrp_nvram_create_system_partition(image
, 0, 0x1fd0);
150 /* Free space partition */
151 chrp_nvram_create_free_partition(&image
[sysp_end
], 0x1fd0 - sysp_end
);
153 Sun_init_header((struct Sun_nvram
*)&image
[0x1fd8], macaddr
,
156 for (i
= 0; i
< sizeof(image
); i
++) {
157 (k
->write
)(nvram
, i
, image
[i
]);
161 void cpu_check_irqs(CPUSPARCState
*env
)
165 /* We should be holding the BQL before we mess with IRQs */
166 g_assert(qemu_mutex_iothread_locked());
168 if (env
->pil_in
&& (env
->interrupt_index
== 0 ||
169 (env
->interrupt_index
& ~15) == TT_EXTINT
)) {
172 for (i
= 15; i
> 0; i
--) {
173 if (env
->pil_in
& (1 << i
)) {
174 int old_interrupt
= env
->interrupt_index
;
176 env
->interrupt_index
= TT_EXTINT
| i
;
177 if (old_interrupt
!= env
->interrupt_index
) {
179 trace_sun4m_cpu_interrupt(i
);
180 cpu_interrupt(cs
, CPU_INTERRUPT_HARD
);
185 } else if (!env
->pil_in
&& (env
->interrupt_index
& ~15) == TT_EXTINT
) {
187 trace_sun4m_cpu_reset_interrupt(env
->interrupt_index
& 15);
188 env
->interrupt_index
= 0;
189 cpu_reset_interrupt(cs
, CPU_INTERRUPT_HARD
);
193 static void cpu_kick_irq(SPARCCPU
*cpu
)
195 CPUSPARCState
*env
= &cpu
->env
;
196 CPUState
*cs
= CPU(cpu
);
203 static void cpu_set_irq(void *opaque
, int irq
, int level
)
205 SPARCCPU
*cpu
= opaque
;
206 CPUSPARCState
*env
= &cpu
->env
;
209 trace_sun4m_cpu_set_irq_raise(irq
);
210 env
->pil_in
|= 1 << irq
;
213 trace_sun4m_cpu_set_irq_lower(irq
);
214 env
->pil_in
&= ~(1 << irq
);
219 static void dummy_cpu_set_irq(void *opaque
, int irq
, int level
)
223 static void sun4m_cpu_reset(void *opaque
)
225 SPARCCPU
*cpu
= opaque
;
226 CPUState
*cs
= CPU(cpu
);
231 static void cpu_halt_signal(void *opaque
, int irq
, int level
)
233 if (level
&& current_cpu
) {
234 cpu_interrupt(current_cpu
, CPU_INTERRUPT_HALT
);
238 static uint64_t translate_kernel_address(void *opaque
, uint64_t addr
)
240 return addr
- 0xf0000000ULL
;
243 static unsigned long sun4m_load_kernel(const char *kernel_filename
,
244 const char *initrd_filename
,
246 uint32_t *initrd_size
)
253 linux_boot
= (kernel_filename
!= NULL
);
264 kernel_size
= load_elf(kernel_filename
, NULL
,
265 translate_kernel_address
, NULL
,
266 NULL
, NULL
, NULL
, NULL
, 1, EM_SPARC
, 0, 0);
268 kernel_size
= load_aout(kernel_filename
, KERNEL_LOAD_ADDR
,
269 RAM_size
- KERNEL_LOAD_ADDR
, bswap_needed
,
272 kernel_size
= load_image_targphys(kernel_filename
,
274 RAM_size
- KERNEL_LOAD_ADDR
);
275 if (kernel_size
< 0) {
276 error_report("could not load kernel '%s'", kernel_filename
);
282 if (initrd_filename
) {
283 *initrd_size
= load_image_targphys(initrd_filename
,
285 RAM_size
- INITRD_LOAD_ADDR
);
286 if ((int)*initrd_size
< 0) {
287 error_report("could not load initial ram disk '%s'",
292 if (*initrd_size
> 0) {
293 for (i
= 0; i
< 64 * TARGET_PAGE_SIZE
; i
+= TARGET_PAGE_SIZE
) {
294 ptr
= rom_ptr(KERNEL_LOAD_ADDR
+ i
, 24);
295 if (ptr
&& ldl_p(ptr
) == 0x48647253) { /* HdrS */
296 stl_p(ptr
+ 16, INITRD_LOAD_ADDR
);
297 stl_p(ptr
+ 20, *initrd_size
);
306 static void *iommu_init(hwaddr addr
, uint32_t version
, qemu_irq irq
)
311 dev
= qdev_new(TYPE_SUN4M_IOMMU
);
312 qdev_prop_set_uint32(dev
, "version", version
);
313 s
= SYS_BUS_DEVICE(dev
);
314 sysbus_realize_and_unref(s
, &error_fatal
);
315 sysbus_connect_irq(s
, 0, irq
);
316 sysbus_mmio_map(s
, 0, addr
);
321 static void *sparc32_dma_init(hwaddr dma_base
,
322 hwaddr esp_base
, qemu_irq espdma_irq
,
323 hwaddr le_base
, qemu_irq ledma_irq
, NICInfo
*nd
)
326 ESPDMADeviceState
*espdma
;
327 LEDMADeviceState
*ledma
;
329 SysBusPCNetState
*lance
;
331 dma
= qdev_new(TYPE_SPARC32_DMA
);
332 espdma
= SPARC32_ESPDMA_DEVICE(object_resolve_path_component(
333 OBJECT(dma
), "espdma"));
334 sysbus_connect_irq(SYS_BUS_DEVICE(espdma
), 0, espdma_irq
);
336 esp
= ESP(object_resolve_path_component(OBJECT(espdma
), "esp"));
338 ledma
= SPARC32_LEDMA_DEVICE(object_resolve_path_component(
339 OBJECT(dma
), "ledma"));
340 sysbus_connect_irq(SYS_BUS_DEVICE(ledma
), 0, ledma_irq
);
342 lance
= SYSBUS_PCNET(object_resolve_path_component(
343 OBJECT(ledma
), "lance"));
344 qdev_set_nic_properties(DEVICE(lance
), nd
);
346 sysbus_realize_and_unref(SYS_BUS_DEVICE(dma
), &error_fatal
);
347 sysbus_mmio_map(SYS_BUS_DEVICE(dma
), 0, dma_base
);
349 sysbus_mmio_map(SYS_BUS_DEVICE(esp
), 0, esp_base
);
350 scsi_bus_legacy_handle_cmdline(&esp
->esp
.bus
);
352 sysbus_mmio_map(SYS_BUS_DEVICE(lance
), 0, le_base
);
357 static DeviceState
*slavio_intctl_init(hwaddr addr
,
359 qemu_irq
**parent_irq
)
365 dev
= qdev_new("slavio_intctl");
367 s
= SYS_BUS_DEVICE(dev
);
368 sysbus_realize_and_unref(s
, &error_fatal
);
370 for (i
= 0; i
< MAX_CPUS
; i
++) {
371 for (j
= 0; j
< MAX_PILS
; j
++) {
372 sysbus_connect_irq(s
, i
* MAX_PILS
+ j
, parent_irq
[i
][j
]);
375 sysbus_mmio_map(s
, 0, addrg
);
376 for (i
= 0; i
< MAX_CPUS
; i
++) {
377 sysbus_mmio_map(s
, i
+ 1, addr
+ i
* TARGET_PAGE_SIZE
);
383 #define SYS_TIMER_OFFSET 0x10000ULL
384 #define CPU_TIMER_OFFSET(cpu) (0x1000ULL * cpu)
386 static void slavio_timer_init_all(hwaddr addr
, qemu_irq master_irq
,
387 qemu_irq
*cpu_irqs
, unsigned int num_cpus
)
393 dev
= qdev_new("slavio_timer");
394 qdev_prop_set_uint32(dev
, "num_cpus", num_cpus
);
395 s
= SYS_BUS_DEVICE(dev
);
396 sysbus_realize_and_unref(s
, &error_fatal
);
397 sysbus_connect_irq(s
, 0, master_irq
);
398 sysbus_mmio_map(s
, 0, addr
+ SYS_TIMER_OFFSET
);
400 for (i
= 0; i
< MAX_CPUS
; i
++) {
401 sysbus_mmio_map(s
, i
+ 1, addr
+ (hwaddr
)CPU_TIMER_OFFSET(i
));
402 sysbus_connect_irq(s
, i
+ 1, cpu_irqs
[i
]);
406 static qemu_irq slavio_system_powerdown
;
408 static void slavio_powerdown_req(Notifier
*n
, void *opaque
)
410 qemu_irq_raise(slavio_system_powerdown
);
413 static Notifier slavio_system_powerdown_notifier
= {
414 .notify
= slavio_powerdown_req
417 #define MISC_LEDS 0x01600000
418 #define MISC_CFG 0x01800000
419 #define MISC_DIAG 0x01a00000
420 #define MISC_MDM 0x01b00000
421 #define MISC_SYS 0x01f00000
423 static void slavio_misc_init(hwaddr base
,
425 hwaddr aux2_base
, qemu_irq irq
,
431 dev
= qdev_new("slavio_misc");
432 s
= SYS_BUS_DEVICE(dev
);
433 sysbus_realize_and_unref(s
, &error_fatal
);
435 /* 8 bit registers */
437 sysbus_mmio_map(s
, 0, base
+ MISC_CFG
);
439 sysbus_mmio_map(s
, 1, base
+ MISC_DIAG
);
441 sysbus_mmio_map(s
, 2, base
+ MISC_MDM
);
442 /* 16 bit registers */
443 /* ss600mp diag LEDs */
444 sysbus_mmio_map(s
, 3, base
+ MISC_LEDS
);
445 /* 32 bit registers */
447 sysbus_mmio_map(s
, 4, base
+ MISC_SYS
);
450 /* AUX 1 (Misc System Functions) */
451 sysbus_mmio_map(s
, 5, aux1_base
);
454 /* AUX 2 (Software Powerdown Control) */
455 sysbus_mmio_map(s
, 6, aux2_base
);
457 sysbus_connect_irq(s
, 0, irq
);
458 sysbus_connect_irq(s
, 1, fdc_tc
);
459 slavio_system_powerdown
= qdev_get_gpio_in(dev
, 0);
460 qemu_register_powerdown_notifier(&slavio_system_powerdown_notifier
);
463 static void ecc_init(hwaddr base
, qemu_irq irq
, uint32_t version
)
468 dev
= qdev_new("eccmemctl");
469 qdev_prop_set_uint32(dev
, "version", version
);
470 s
= SYS_BUS_DEVICE(dev
);
471 sysbus_realize_and_unref(s
, &error_fatal
);
472 sysbus_connect_irq(s
, 0, irq
);
473 sysbus_mmio_map(s
, 0, base
);
474 if (version
== 0) { // SS-600MP only
475 sysbus_mmio_map(s
, 1, base
+ 0x1000);
479 static void apc_init(hwaddr power_base
, qemu_irq cpu_halt
)
484 dev
= qdev_new("apc");
485 s
= SYS_BUS_DEVICE(dev
);
486 sysbus_realize_and_unref(s
, &error_fatal
);
487 /* Power management (APC) XXX: not a Slavio device */
488 sysbus_mmio_map(s
, 0, power_base
);
489 sysbus_connect_irq(s
, 0, cpu_halt
);
492 static void tcx_init(hwaddr addr
, qemu_irq irq
, int vram_size
, int width
,
493 int height
, int depth
)
498 dev
= qdev_new("SUNW,tcx");
499 qdev_prop_set_uint32(dev
, "vram_size", vram_size
);
500 qdev_prop_set_uint16(dev
, "width", width
);
501 qdev_prop_set_uint16(dev
, "height", height
);
502 qdev_prop_set_uint16(dev
, "depth", depth
);
503 s
= SYS_BUS_DEVICE(dev
);
504 sysbus_realize_and_unref(s
, &error_fatal
);
506 /* 10/ROM : FCode ROM */
507 sysbus_mmio_map(s
, 0, addr
);
508 /* 2/STIP : Stipple */
509 sysbus_mmio_map(s
, 1, addr
+ 0x04000000ULL
);
510 /* 3/BLIT : Blitter */
511 sysbus_mmio_map(s
, 2, addr
+ 0x06000000ULL
);
512 /* 5/RSTIP : Raw Stipple */
513 sysbus_mmio_map(s
, 3, addr
+ 0x0c000000ULL
);
514 /* 6/RBLIT : Raw Blitter */
515 sysbus_mmio_map(s
, 4, addr
+ 0x0e000000ULL
);
516 /* 7/TEC : Transform Engine */
517 sysbus_mmio_map(s
, 5, addr
+ 0x00700000ULL
);
519 sysbus_mmio_map(s
, 6, addr
+ 0x00200000ULL
);
522 sysbus_mmio_map(s
, 7, addr
+ 0x00300000ULL
);
524 sysbus_mmio_map(s
, 7, addr
+ 0x00301000ULL
);
527 sysbus_mmio_map(s
, 8, addr
+ 0x00240000ULL
);
529 sysbus_mmio_map(s
, 9, addr
+ 0x00280000ULL
);
530 /* 0/DFB8 : 8-bit plane */
531 sysbus_mmio_map(s
, 10, addr
+ 0x00800000ULL
);
532 /* 1/DFB24 : 24bit plane */
533 sysbus_mmio_map(s
, 11, addr
+ 0x02000000ULL
);
534 /* 4/RDFB32: Raw framebuffer. Control plane */
535 sysbus_mmio_map(s
, 12, addr
+ 0x0a000000ULL
);
536 /* 9/THC24bits : NetBSD writes here even with 8-bit display: dummy */
538 sysbus_mmio_map(s
, 13, addr
+ 0x00301000ULL
);
541 sysbus_connect_irq(s
, 0, irq
);
544 static void cg3_init(hwaddr addr
, qemu_irq irq
, int vram_size
, int width
,
545 int height
, int depth
)
550 dev
= qdev_new("cgthree");
551 qdev_prop_set_uint32(dev
, "vram-size", vram_size
);
552 qdev_prop_set_uint16(dev
, "width", width
);
553 qdev_prop_set_uint16(dev
, "height", height
);
554 qdev_prop_set_uint16(dev
, "depth", depth
);
555 s
= SYS_BUS_DEVICE(dev
);
556 sysbus_realize_and_unref(s
, &error_fatal
);
559 sysbus_mmio_map(s
, 0, addr
);
561 sysbus_mmio_map(s
, 1, addr
+ 0x400000ULL
);
563 sysbus_mmio_map(s
, 2, addr
+ 0x800000ULL
);
565 sysbus_connect_irq(s
, 0, irq
);
568 /* NCR89C100/MACIO Internal ID register */
570 #define TYPE_MACIO_ID_REGISTER "macio_idreg"
572 static const uint8_t idreg_data
[] = { 0xfe, 0x81, 0x01, 0x03 };
574 static void idreg_init(hwaddr addr
)
579 dev
= qdev_new(TYPE_MACIO_ID_REGISTER
);
580 s
= SYS_BUS_DEVICE(dev
);
581 sysbus_realize_and_unref(s
, &error_fatal
);
583 sysbus_mmio_map(s
, 0, addr
);
584 address_space_write_rom(&address_space_memory
, addr
,
585 MEMTXATTRS_UNSPECIFIED
,
586 idreg_data
, sizeof(idreg_data
));
589 OBJECT_DECLARE_SIMPLE_TYPE(IDRegState
, MACIO_ID_REGISTER
)
592 SysBusDevice parent_obj
;
597 static void idreg_realize(DeviceState
*ds
, Error
**errp
)
599 IDRegState
*s
= MACIO_ID_REGISTER(ds
);
600 SysBusDevice
*dev
= SYS_BUS_DEVICE(ds
);
601 Error
*local_err
= NULL
;
603 memory_region_init_ram_nomigrate(&s
->mem
, OBJECT(ds
), "sun4m.idreg",
604 sizeof(idreg_data
), &local_err
);
606 error_propagate(errp
, local_err
);
610 vmstate_register_ram_global(&s
->mem
);
611 memory_region_set_readonly(&s
->mem
, true);
612 sysbus_init_mmio(dev
, &s
->mem
);
615 static void idreg_class_init(ObjectClass
*oc
, void *data
)
617 DeviceClass
*dc
= DEVICE_CLASS(oc
);
619 dc
->realize
= idreg_realize
;
622 static const TypeInfo idreg_info
= {
623 .name
= TYPE_MACIO_ID_REGISTER
,
624 .parent
= TYPE_SYS_BUS_DEVICE
,
625 .instance_size
= sizeof(IDRegState
),
626 .class_init
= idreg_class_init
,
629 #define TYPE_TCX_AFX "tcx_afx"
630 OBJECT_DECLARE_SIMPLE_TYPE(AFXState
, TCX_AFX
)
633 SysBusDevice parent_obj
;
638 /* SS-5 TCX AFX register */
639 static void afx_init(hwaddr addr
)
644 dev
= qdev_new(TYPE_TCX_AFX
);
645 s
= SYS_BUS_DEVICE(dev
);
646 sysbus_realize_and_unref(s
, &error_fatal
);
648 sysbus_mmio_map(s
, 0, addr
);
651 static void afx_realize(DeviceState
*ds
, Error
**errp
)
653 AFXState
*s
= TCX_AFX(ds
);
654 SysBusDevice
*dev
= SYS_BUS_DEVICE(ds
);
655 Error
*local_err
= NULL
;
657 memory_region_init_ram_nomigrate(&s
->mem
, OBJECT(ds
), "sun4m.afx", 4,
660 error_propagate(errp
, local_err
);
664 vmstate_register_ram_global(&s
->mem
);
665 sysbus_init_mmio(dev
, &s
->mem
);
668 static void afx_class_init(ObjectClass
*oc
, void *data
)
670 DeviceClass
*dc
= DEVICE_CLASS(oc
);
672 dc
->realize
= afx_realize
;
675 static const TypeInfo afx_info
= {
676 .name
= TYPE_TCX_AFX
,
677 .parent
= TYPE_SYS_BUS_DEVICE
,
678 .instance_size
= sizeof(AFXState
),
679 .class_init
= afx_class_init
,
682 #define TYPE_OPENPROM "openprom"
683 typedef struct PROMState PROMState
;
684 DECLARE_INSTANCE_CHECKER(PROMState
, OPENPROM
,
688 SysBusDevice parent_obj
;
693 /* Boot PROM (OpenBIOS) */
694 static uint64_t translate_prom_address(void *opaque
, uint64_t addr
)
696 hwaddr
*base_addr
= (hwaddr
*)opaque
;
697 return addr
+ *base_addr
- PROM_VADDR
;
700 static void prom_init(hwaddr addr
, const char *bios_name
)
707 dev
= qdev_new(TYPE_OPENPROM
);
708 s
= SYS_BUS_DEVICE(dev
);
709 sysbus_realize_and_unref(s
, &error_fatal
);
711 sysbus_mmio_map(s
, 0, addr
);
714 if (bios_name
== NULL
) {
715 bios_name
= PROM_FILENAME
;
717 filename
= qemu_find_file(QEMU_FILE_TYPE_BIOS
, bios_name
);
719 ret
= load_elf(filename
, NULL
,
720 translate_prom_address
, &addr
, NULL
,
721 NULL
, NULL
, NULL
, 1, EM_SPARC
, 0, 0);
722 if (ret
< 0 || ret
> PROM_SIZE_MAX
) {
723 ret
= load_image_targphys(filename
, addr
, PROM_SIZE_MAX
);
729 if (ret
< 0 || ret
> PROM_SIZE_MAX
) {
730 error_report("could not load prom '%s'", bios_name
);
735 static void prom_realize(DeviceState
*ds
, Error
**errp
)
737 PROMState
*s
= OPENPROM(ds
);
738 SysBusDevice
*dev
= SYS_BUS_DEVICE(ds
);
739 Error
*local_err
= NULL
;
741 memory_region_init_ram_nomigrate(&s
->prom
, OBJECT(ds
), "sun4m.prom",
742 PROM_SIZE_MAX
, &local_err
);
744 error_propagate(errp
, local_err
);
748 vmstate_register_ram_global(&s
->prom
);
749 memory_region_set_readonly(&s
->prom
, true);
750 sysbus_init_mmio(dev
, &s
->prom
);
753 static Property prom_properties
[] = {
754 {/* end of property list */},
757 static void prom_class_init(ObjectClass
*klass
, void *data
)
759 DeviceClass
*dc
= DEVICE_CLASS(klass
);
761 device_class_set_props(dc
, prom_properties
);
762 dc
->realize
= prom_realize
;
765 static const TypeInfo prom_info
= {
766 .name
= TYPE_OPENPROM
,
767 .parent
= TYPE_SYS_BUS_DEVICE
,
768 .instance_size
= sizeof(PROMState
),
769 .class_init
= prom_class_init
,
772 #define TYPE_SUN4M_MEMORY "memory"
773 typedef struct RamDevice RamDevice
;
774 DECLARE_INSTANCE_CHECKER(RamDevice
, SUN4M_RAM
,
778 SysBusDevice parent_obj
;
779 HostMemoryBackend
*memdev
;
783 static void ram_realize(DeviceState
*dev
, Error
**errp
)
785 RamDevice
*d
= SUN4M_RAM(dev
);
786 MemoryRegion
*ram
= host_memory_backend_get_memory(d
->memdev
);
788 sysbus_init_mmio(SYS_BUS_DEVICE(dev
), ram
);
791 static void ram_initfn(Object
*obj
)
793 RamDevice
*d
= SUN4M_RAM(obj
);
794 object_property_add_link(obj
, "memdev", TYPE_MEMORY_BACKEND
,
795 (Object
**)&d
->memdev
,
796 object_property_allow_set_link
,
797 OBJ_PROP_LINK_STRONG
);
798 object_property_set_description(obj
, "memdev", "Set RAM backend"
799 "Valid value is ID of a hostmem backend");
802 static void ram_class_init(ObjectClass
*klass
, void *data
)
804 DeviceClass
*dc
= DEVICE_CLASS(klass
);
806 dc
->realize
= ram_realize
;
809 static const TypeInfo ram_info
= {
810 .name
= TYPE_SUN4M_MEMORY
,
811 .parent
= TYPE_SYS_BUS_DEVICE
,
812 .instance_size
= sizeof(RamDevice
),
813 .instance_init
= ram_initfn
,
814 .class_init
= ram_class_init
,
817 static void cpu_devinit(const char *cpu_type
, unsigned int id
,
818 uint64_t prom_addr
, qemu_irq
**cpu_irqs
)
823 cpu
= SPARC_CPU(object_new(cpu_type
));
826 cpu_sparc_set_id(env
, id
);
827 qemu_register_reset(sun4m_cpu_reset
, cpu
);
828 object_property_set_bool(OBJECT(cpu
), "start-powered-off", id
!= 0,
830 qdev_realize_and_unref(DEVICE(cpu
), NULL
, &error_fatal
);
831 *cpu_irqs
= qemu_allocate_irqs(cpu_set_irq
, cpu
, MAX_PILS
);
832 env
->prom_addr
= prom_addr
;
835 static void dummy_fdc_tc(void *opaque
, int irq
, int level
)
839 static void sun4m_hw_init(const struct sun4m_hwdef
*hwdef
,
840 MachineState
*machine
)
842 DeviceState
*slavio_intctl
;
845 qemu_irq
*cpu_irqs
[MAX_CPUS
], slavio_irq
[32], slavio_cpu_irq
[MAX_CPUS
];
847 unsigned long kernel_size
;
848 uint32_t initrd_size
;
849 DriveInfo
*fd
[MAX_FD
];
853 unsigned int smp_cpus
= machine
->smp
.cpus
;
854 unsigned int max_cpus
= machine
->smp
.max_cpus
;
855 Object
*ram_memdev
= object_resolve_path_type(machine
->ram_memdev_id
,
856 TYPE_MEMORY_BACKEND
, NULL
);
857 NICInfo
*nd
= &nd_table
[0];
859 if (machine
->ram_size
> hwdef
->max_mem
) {
860 error_report("Too much memory for this machine: %" PRId64
","
862 machine
->ram_size
/ MiB
, hwdef
->max_mem
/ MiB
);
867 for(i
= 0; i
< smp_cpus
; i
++) {
868 cpu_devinit(machine
->cpu_type
, i
, hwdef
->slavio_base
, &cpu_irqs
[i
]);
871 for (i
= smp_cpus
; i
< MAX_CPUS
; i
++)
872 cpu_irqs
[i
] = qemu_allocate_irqs(dummy_cpu_set_irq
, NULL
, MAX_PILS
);
874 /* Create and map RAM frontend */
875 dev
= qdev_new("memory");
876 object_property_set_link(OBJECT(dev
), "memdev", ram_memdev
, &error_fatal
);
877 sysbus_realize_and_unref(SYS_BUS_DEVICE(dev
), &error_fatal
);
878 sysbus_mmio_map(SYS_BUS_DEVICE(dev
), 0, 0);
880 /* models without ECC don't trap when missing ram is accessed */
881 if (!hwdef
->ecc_base
) {
882 empty_slot_init("ecc", machine
->ram_size
,
883 hwdef
->max_mem
- machine
->ram_size
);
886 prom_init(hwdef
->slavio_base
, machine
->firmware
);
888 slavio_intctl
= slavio_intctl_init(hwdef
->intctl_base
,
889 hwdef
->intctl_base
+ 0x10000ULL
,
892 for (i
= 0; i
< 32; i
++) {
893 slavio_irq
[i
] = qdev_get_gpio_in(slavio_intctl
, i
);
895 for (i
= 0; i
< MAX_CPUS
; i
++) {
896 slavio_cpu_irq
[i
] = qdev_get_gpio_in(slavio_intctl
, 32 + i
);
899 if (hwdef
->idreg_base
) {
900 idreg_init(hwdef
->idreg_base
);
903 if (hwdef
->afx_base
) {
904 afx_init(hwdef
->afx_base
);
907 iommu_init(hwdef
->iommu_base
, hwdef
->iommu_version
, slavio_irq
[30]);
909 if (hwdef
->iommu_pad_base
) {
910 /* On the real hardware (SS-5, LX) the MMU is not padded, but aliased.
911 Software shouldn't use aliased addresses, neither should it crash
912 when does. Using empty_slot instead of aliasing can help with
913 debugging such accesses */
914 empty_slot_init("iommu.alias",
915 hwdef
->iommu_pad_base
, hwdef
->iommu_pad_len
);
918 qemu_check_nic_model(nd
, TYPE_LANCE
);
919 sparc32_dma_init(hwdef
->dma_base
,
920 hwdef
->esp_base
, slavio_irq
[18],
921 hwdef
->le_base
, slavio_irq
[16], nd
);
923 if (graphic_depth
!= 8 && graphic_depth
!= 24) {
924 error_report("Unsupported depth: %d", graphic_depth
);
927 if (vga_interface_type
!= VGA_NONE
) {
928 if (vga_interface_type
== VGA_CG3
) {
929 if (graphic_depth
!= 8) {
930 error_report("Unsupported depth: %d", graphic_depth
);
934 if (!(graphic_width
== 1024 && graphic_height
== 768) &&
935 !(graphic_width
== 1152 && graphic_height
== 900)) {
936 error_report("Unsupported resolution: %d x %d", graphic_width
,
942 cg3_init(hwdef
->tcx_base
, slavio_irq
[11], 0x00100000,
943 graphic_width
, graphic_height
, graphic_depth
);
945 /* If no display specified, default to TCX */
946 if (graphic_depth
!= 8 && graphic_depth
!= 24) {
947 error_report("Unsupported depth: %d", graphic_depth
);
951 if (!(graphic_width
== 1024 && graphic_height
== 768)) {
952 error_report("Unsupported resolution: %d x %d",
953 graphic_width
, graphic_height
);
957 tcx_init(hwdef
->tcx_base
, slavio_irq
[11], 0x00100000,
958 graphic_width
, graphic_height
, graphic_depth
);
962 for (i
= 0; i
< MAX_VSIMMS
; i
++) {
963 /* vsimm registers probed by OBP */
964 if (hwdef
->vsimm
[i
].reg_base
) {
965 char *name
= g_strdup_printf("vsimm[%d]", i
);
966 empty_slot_init(name
, hwdef
->vsimm
[i
].reg_base
, 0x2000);
971 if (hwdef
->sx_base
) {
972 create_unimplemented_device("SUNW,sx", hwdef
->sx_base
, 0x2000);
975 dev
= qdev_new("sysbus-m48t08");
976 qdev_prop_set_int32(dev
, "base-year", 1968);
977 s
= SYS_BUS_DEVICE(dev
);
978 sysbus_realize_and_unref(s
, &error_fatal
);
979 sysbus_connect_irq(s
, 0, slavio_irq
[0]);
980 sysbus_mmio_map(s
, 0, hwdef
->nvram_base
);
983 slavio_timer_init_all(hwdef
->counter_base
, slavio_irq
[19], slavio_cpu_irq
, smp_cpus
);
985 /* Slavio TTYA (base+4, Linux ttyS0) is the first QEMU serial device
986 Slavio TTYB (base+0, Linux ttyS1) is the second QEMU serial device */
987 dev
= qdev_new(TYPE_ESCC
);
988 qdev_prop_set_uint32(dev
, "disabled", !machine
->enable_graphics
);
989 qdev_prop_set_uint32(dev
, "frequency", ESCC_CLOCK
);
990 qdev_prop_set_uint32(dev
, "it_shift", 1);
991 qdev_prop_set_chr(dev
, "chrB", NULL
);
992 qdev_prop_set_chr(dev
, "chrA", NULL
);
993 qdev_prop_set_uint32(dev
, "chnBtype", escc_mouse
);
994 qdev_prop_set_uint32(dev
, "chnAtype", escc_kbd
);
995 s
= SYS_BUS_DEVICE(dev
);
996 sysbus_realize_and_unref(s
, &error_fatal
);
997 sysbus_connect_irq(s
, 0, slavio_irq
[14]);
998 sysbus_connect_irq(s
, 1, slavio_irq
[14]);
999 sysbus_mmio_map(s
, 0, hwdef
->ms_kb_base
);
1001 dev
= qdev_new(TYPE_ESCC
);
1002 qdev_prop_set_uint32(dev
, "disabled", 0);
1003 qdev_prop_set_uint32(dev
, "frequency", ESCC_CLOCK
);
1004 qdev_prop_set_uint32(dev
, "it_shift", 1);
1005 qdev_prop_set_chr(dev
, "chrB", serial_hd(1));
1006 qdev_prop_set_chr(dev
, "chrA", serial_hd(0));
1007 qdev_prop_set_uint32(dev
, "chnBtype", escc_serial
);
1008 qdev_prop_set_uint32(dev
, "chnAtype", escc_serial
);
1010 s
= SYS_BUS_DEVICE(dev
);
1011 sysbus_realize_and_unref(s
, &error_fatal
);
1012 sysbus_connect_irq(s
, 0, slavio_irq
[15]);
1013 sysbus_connect_irq(s
, 1, slavio_irq
[15]);
1014 sysbus_mmio_map(s
, 0, hwdef
->serial_base
);
1016 if (hwdef
->apc_base
) {
1017 apc_init(hwdef
->apc_base
, qemu_allocate_irq(cpu_halt_signal
, NULL
, 0));
1020 if (hwdef
->fd_base
) {
1021 /* there is zero or one floppy drive */
1022 memset(fd
, 0, sizeof(fd
));
1023 fd
[0] = drive_get(IF_FLOPPY
, 0, 0);
1024 sun4m_fdctrl_init(slavio_irq
[22], hwdef
->fd_base
, fd
,
1027 fdc_tc
= qemu_allocate_irq(dummy_fdc_tc
, NULL
, 0);
1030 slavio_misc_init(hwdef
->slavio_base
, hwdef
->aux1_base
, hwdef
->aux2_base
,
1031 slavio_irq
[30], fdc_tc
);
1033 if (hwdef
->cs_base
) {
1034 sysbus_create_simple("SUNW,CS4231", hwdef
->cs_base
,
1038 if (hwdef
->dbri_base
) {
1039 /* ISDN chip with attached CS4215 audio codec */
1041 create_unimplemented_device("SUNW,DBRI.prom",
1042 hwdef
->dbri_base
+ 0x1000, 0x30);
1044 create_unimplemented_device("SUNW,DBRI",
1045 hwdef
->dbri_base
+ 0x10000, 0x100);
1048 if (hwdef
->bpp_base
) {
1050 create_unimplemented_device("SUNW,bpp", hwdef
->bpp_base
, 0x20);
1054 kernel_size
= sun4m_load_kernel(machine
->kernel_filename
,
1055 machine
->initrd_filename
,
1056 machine
->ram_size
, &initrd_size
);
1058 nvram_init(nvram
, (uint8_t *)&nd
->macaddr
, machine
->kernel_cmdline
,
1059 machine
->boot_order
, machine
->ram_size
, kernel_size
,
1060 graphic_width
, graphic_height
, graphic_depth
,
1061 hwdef
->nvram_machine_id
, "Sun4m");
1063 if (hwdef
->ecc_base
)
1064 ecc_init(hwdef
->ecc_base
, slavio_irq
[28],
1065 hwdef
->ecc_version
);
1067 dev
= qdev_new(TYPE_FW_CFG_MEM
);
1068 fw_cfg
= FW_CFG(dev
);
1069 qdev_prop_set_uint32(dev
, "data_width", 1);
1070 qdev_prop_set_bit(dev
, "dma_enabled", false);
1071 object_property_add_child(OBJECT(qdev_get_machine()), TYPE_FW_CFG
,
1073 s
= SYS_BUS_DEVICE(dev
);
1074 sysbus_realize_and_unref(s
, &error_fatal
);
1075 sysbus_mmio_map(s
, 0, CFG_ADDR
);
1076 sysbus_mmio_map(s
, 1, CFG_ADDR
+ 2);
1078 fw_cfg_add_i16(fw_cfg
, FW_CFG_NB_CPUS
, (uint16_t)smp_cpus
);
1079 fw_cfg_add_i16(fw_cfg
, FW_CFG_MAX_CPUS
, (uint16_t)max_cpus
);
1080 fw_cfg_add_i64(fw_cfg
, FW_CFG_RAM_SIZE
, (uint64_t)machine
->ram_size
);
1081 fw_cfg_add_i16(fw_cfg
, FW_CFG_MACHINE_ID
, hwdef
->machine_id
);
1082 fw_cfg_add_i16(fw_cfg
, FW_CFG_SUN4M_DEPTH
, graphic_depth
);
1083 fw_cfg_add_i16(fw_cfg
, FW_CFG_SUN4M_WIDTH
, graphic_width
);
1084 fw_cfg_add_i16(fw_cfg
, FW_CFG_SUN4M_HEIGHT
, graphic_height
);
1085 fw_cfg_add_i32(fw_cfg
, FW_CFG_KERNEL_ADDR
, KERNEL_LOAD_ADDR
);
1086 fw_cfg_add_i32(fw_cfg
, FW_CFG_KERNEL_SIZE
, kernel_size
);
1087 if (machine
->kernel_cmdline
) {
1088 fw_cfg_add_i32(fw_cfg
, FW_CFG_KERNEL_CMDLINE
, CMDLINE_ADDR
);
1089 pstrcpy_targphys("cmdline", CMDLINE_ADDR
, TARGET_PAGE_SIZE
,
1090 machine
->kernel_cmdline
);
1091 fw_cfg_add_string(fw_cfg
, FW_CFG_CMDLINE_DATA
, machine
->kernel_cmdline
);
1092 fw_cfg_add_i32(fw_cfg
, FW_CFG_CMDLINE_SIZE
,
1093 strlen(machine
->kernel_cmdline
) + 1);
1095 fw_cfg_add_i32(fw_cfg
, FW_CFG_KERNEL_CMDLINE
, 0);
1096 fw_cfg_add_i32(fw_cfg
, FW_CFG_CMDLINE_SIZE
, 0);
1098 fw_cfg_add_i32(fw_cfg
, FW_CFG_INITRD_ADDR
, INITRD_LOAD_ADDR
);
1099 fw_cfg_add_i32(fw_cfg
, FW_CFG_INITRD_SIZE
, initrd_size
);
1100 fw_cfg_add_i16(fw_cfg
, FW_CFG_BOOT_DEVICE
, machine
->boot_order
[0]);
1101 qemu_register_boot_set(fw_cfg_boot_set
, fw_cfg
);
1116 static const struct sun4m_hwdef sun4m_hwdefs
[] = {
1119 .iommu_base
= 0x10000000,
1120 .iommu_pad_base
= 0x10004000,
1121 .iommu_pad_len
= 0x0fffb000,
1122 .tcx_base
= 0x50000000,
1123 .cs_base
= 0x6c000000,
1124 .slavio_base
= 0x70000000,
1125 .ms_kb_base
= 0x71000000,
1126 .serial_base
= 0x71100000,
1127 .nvram_base
= 0x71200000,
1128 .fd_base
= 0x71400000,
1129 .counter_base
= 0x71d00000,
1130 .intctl_base
= 0x71e00000,
1131 .idreg_base
= 0x78000000,
1132 .dma_base
= 0x78400000,
1133 .esp_base
= 0x78800000,
1134 .le_base
= 0x78c00000,
1135 .apc_base
= 0x6a000000,
1136 .afx_base
= 0x6e000000,
1137 .aux1_base
= 0x71900000,
1138 .aux2_base
= 0x71910000,
1139 .nvram_machine_id
= 0x80,
1140 .machine_id
= ss5_id
,
1141 .iommu_version
= 0x05000000,
1142 .max_mem
= 0x10000000,
1146 .iommu_base
= 0xfe0000000ULL
,
1147 .tcx_base
= 0xe20000000ULL
,
1148 .slavio_base
= 0xff0000000ULL
,
1149 .ms_kb_base
= 0xff1000000ULL
,
1150 .serial_base
= 0xff1100000ULL
,
1151 .nvram_base
= 0xff1200000ULL
,
1152 .fd_base
= 0xff1700000ULL
,
1153 .counter_base
= 0xff1300000ULL
,
1154 .intctl_base
= 0xff1400000ULL
,
1155 .idreg_base
= 0xef0000000ULL
,
1156 .dma_base
= 0xef0400000ULL
,
1157 .esp_base
= 0xef0800000ULL
,
1158 .le_base
= 0xef0c00000ULL
,
1159 .apc_base
= 0xefa000000ULL
, // XXX should not exist
1160 .aux1_base
= 0xff1800000ULL
,
1161 .aux2_base
= 0xff1a01000ULL
,
1162 .ecc_base
= 0xf00000000ULL
,
1163 .ecc_version
= 0x10000000, // version 0, implementation 1
1164 .nvram_machine_id
= 0x72,
1165 .machine_id
= ss10_id
,
1166 .iommu_version
= 0x03000000,
1167 .max_mem
= 0xf00000000ULL
,
1171 .iommu_base
= 0xfe0000000ULL
,
1172 .tcx_base
= 0xe20000000ULL
,
1173 .slavio_base
= 0xff0000000ULL
,
1174 .ms_kb_base
= 0xff1000000ULL
,
1175 .serial_base
= 0xff1100000ULL
,
1176 .nvram_base
= 0xff1200000ULL
,
1177 .counter_base
= 0xff1300000ULL
,
1178 .intctl_base
= 0xff1400000ULL
,
1179 .dma_base
= 0xef0081000ULL
,
1180 .esp_base
= 0xef0080000ULL
,
1181 .le_base
= 0xef0060000ULL
,
1182 .apc_base
= 0xefa000000ULL
, // XXX should not exist
1183 .aux1_base
= 0xff1800000ULL
,
1184 .aux2_base
= 0xff1a01000ULL
, // XXX should not exist
1185 .ecc_base
= 0xf00000000ULL
,
1186 .ecc_version
= 0x00000000, // version 0, implementation 0
1187 .nvram_machine_id
= 0x71,
1188 .machine_id
= ss600mp_id
,
1189 .iommu_version
= 0x01000000,
1190 .max_mem
= 0xf00000000ULL
,
1194 .iommu_base
= 0xfe0000000ULL
,
1195 .tcx_base
= 0xe20000000ULL
,
1196 .slavio_base
= 0xff0000000ULL
,
1197 .ms_kb_base
= 0xff1000000ULL
,
1198 .serial_base
= 0xff1100000ULL
,
1199 .nvram_base
= 0xff1200000ULL
,
1200 .fd_base
= 0xff1700000ULL
,
1201 .counter_base
= 0xff1300000ULL
,
1202 .intctl_base
= 0xff1400000ULL
,
1203 .idreg_base
= 0xef0000000ULL
,
1204 .dma_base
= 0xef0400000ULL
,
1205 .esp_base
= 0xef0800000ULL
,
1206 .le_base
= 0xef0c00000ULL
,
1207 .bpp_base
= 0xef4800000ULL
,
1208 .apc_base
= 0xefa000000ULL
, // XXX should not exist
1209 .aux1_base
= 0xff1800000ULL
,
1210 .aux2_base
= 0xff1a01000ULL
,
1211 .dbri_base
= 0xee0000000ULL
,
1212 .sx_base
= 0xf80000000ULL
,
1215 .reg_base
= 0x9c000000ULL
,
1216 .vram_base
= 0xfc000000ULL
1218 .reg_base
= 0x90000000ULL
,
1219 .vram_base
= 0xf0000000ULL
1221 .reg_base
= 0x94000000ULL
1223 .reg_base
= 0x98000000ULL
1226 .ecc_base
= 0xf00000000ULL
,
1227 .ecc_version
= 0x20000000, // version 0, implementation 2
1228 .nvram_machine_id
= 0x72,
1229 .machine_id
= ss20_id
,
1230 .iommu_version
= 0x13000000,
1231 .max_mem
= 0xf00000000ULL
,
1235 .iommu_base
= 0x10000000,
1236 .tcx_base
= 0x50000000,
1237 .slavio_base
= 0x70000000,
1238 .ms_kb_base
= 0x71000000,
1239 .serial_base
= 0x71100000,
1240 .nvram_base
= 0x71200000,
1241 .fd_base
= 0x71400000,
1242 .counter_base
= 0x71d00000,
1243 .intctl_base
= 0x71e00000,
1244 .idreg_base
= 0x78000000,
1245 .dma_base
= 0x78400000,
1246 .esp_base
= 0x78800000,
1247 .le_base
= 0x78c00000,
1248 .apc_base
= 0x71300000, // pmc
1249 .aux1_base
= 0x71900000,
1250 .aux2_base
= 0x71910000,
1251 .nvram_machine_id
= 0x80,
1252 .machine_id
= vger_id
,
1253 .iommu_version
= 0x05000000,
1254 .max_mem
= 0x10000000,
1258 .iommu_base
= 0x10000000,
1259 .iommu_pad_base
= 0x10004000,
1260 .iommu_pad_len
= 0x0fffb000,
1261 .tcx_base
= 0x50000000,
1262 .slavio_base
= 0x70000000,
1263 .ms_kb_base
= 0x71000000,
1264 .serial_base
= 0x71100000,
1265 .nvram_base
= 0x71200000,
1266 .fd_base
= 0x71400000,
1267 .counter_base
= 0x71d00000,
1268 .intctl_base
= 0x71e00000,
1269 .idreg_base
= 0x78000000,
1270 .dma_base
= 0x78400000,
1271 .esp_base
= 0x78800000,
1272 .le_base
= 0x78c00000,
1273 .aux1_base
= 0x71900000,
1274 .aux2_base
= 0x71910000,
1275 .nvram_machine_id
= 0x80,
1276 .machine_id
= lx_id
,
1277 .iommu_version
= 0x04000000,
1278 .max_mem
= 0x10000000,
1282 .iommu_base
= 0x10000000,
1283 .tcx_base
= 0x50000000,
1284 .cs_base
= 0x6c000000,
1285 .slavio_base
= 0x70000000,
1286 .ms_kb_base
= 0x71000000,
1287 .serial_base
= 0x71100000,
1288 .nvram_base
= 0x71200000,
1289 .fd_base
= 0x71400000,
1290 .counter_base
= 0x71d00000,
1291 .intctl_base
= 0x71e00000,
1292 .idreg_base
= 0x78000000,
1293 .dma_base
= 0x78400000,
1294 .esp_base
= 0x78800000,
1295 .le_base
= 0x78c00000,
1296 .apc_base
= 0x6a000000,
1297 .aux1_base
= 0x71900000,
1298 .aux2_base
= 0x71910000,
1299 .nvram_machine_id
= 0x80,
1300 .machine_id
= ss4_id
,
1301 .iommu_version
= 0x05000000,
1302 .max_mem
= 0x10000000,
1306 .iommu_base
= 0x10000000,
1307 .tcx_base
= 0x50000000,
1308 .slavio_base
= 0x70000000,
1309 .ms_kb_base
= 0x71000000,
1310 .serial_base
= 0x71100000,
1311 .nvram_base
= 0x71200000,
1312 .fd_base
= 0x71400000,
1313 .counter_base
= 0x71d00000,
1314 .intctl_base
= 0x71e00000,
1315 .idreg_base
= 0x78000000,
1316 .dma_base
= 0x78400000,
1317 .esp_base
= 0x78800000,
1318 .le_base
= 0x78c00000,
1319 .apc_base
= 0x6a000000,
1320 .aux1_base
= 0x71900000,
1321 .aux2_base
= 0x71910000,
1322 .nvram_machine_id
= 0x80,
1323 .machine_id
= scls_id
,
1324 .iommu_version
= 0x05000000,
1325 .max_mem
= 0x10000000,
1329 .iommu_base
= 0x10000000,
1330 .tcx_base
= 0x50000000, // XXX
1331 .slavio_base
= 0x70000000,
1332 .ms_kb_base
= 0x71000000,
1333 .serial_base
= 0x71100000,
1334 .nvram_base
= 0x71200000,
1335 .fd_base
= 0x71400000,
1336 .counter_base
= 0x71d00000,
1337 .intctl_base
= 0x71e00000,
1338 .idreg_base
= 0x78000000,
1339 .dma_base
= 0x78400000,
1340 .esp_base
= 0x78800000,
1341 .le_base
= 0x78c00000,
1342 .apc_base
= 0x6a000000,
1343 .aux1_base
= 0x71900000,
1344 .aux2_base
= 0x71910000,
1345 .nvram_machine_id
= 0x80,
1346 .machine_id
= sbook_id
,
1347 .iommu_version
= 0x05000000,
1348 .max_mem
= 0x10000000,
1352 /* SPARCstation 5 hardware initialisation */
1353 static void ss5_init(MachineState
*machine
)
1355 sun4m_hw_init(&sun4m_hwdefs
[0], machine
);
1358 /* SPARCstation 10 hardware initialisation */
1359 static void ss10_init(MachineState
*machine
)
1361 sun4m_hw_init(&sun4m_hwdefs
[1], machine
);
1364 /* SPARCserver 600MP hardware initialisation */
1365 static void ss600mp_init(MachineState
*machine
)
1367 sun4m_hw_init(&sun4m_hwdefs
[2], machine
);
1370 /* SPARCstation 20 hardware initialisation */
1371 static void ss20_init(MachineState
*machine
)
1373 sun4m_hw_init(&sun4m_hwdefs
[3], machine
);
1376 /* SPARCstation Voyager hardware initialisation */
1377 static void vger_init(MachineState
*machine
)
1379 sun4m_hw_init(&sun4m_hwdefs
[4], machine
);
1382 /* SPARCstation LX hardware initialisation */
1383 static void ss_lx_init(MachineState
*machine
)
1385 sun4m_hw_init(&sun4m_hwdefs
[5], machine
);
1388 /* SPARCstation 4 hardware initialisation */
1389 static void ss4_init(MachineState
*machine
)
1391 sun4m_hw_init(&sun4m_hwdefs
[6], machine
);
1394 /* SPARCClassic hardware initialisation */
1395 static void scls_init(MachineState
*machine
)
1397 sun4m_hw_init(&sun4m_hwdefs
[7], machine
);
1400 /* SPARCbook hardware initialisation */
1401 static void sbook_init(MachineState
*machine
)
1403 sun4m_hw_init(&sun4m_hwdefs
[8], machine
);
1406 static void ss5_class_init(ObjectClass
*oc
, void *data
)
1408 MachineClass
*mc
= MACHINE_CLASS(oc
);
1410 mc
->desc
= "Sun4m platform, SPARCstation 5";
1411 mc
->init
= ss5_init
;
1412 mc
->block_default_type
= IF_SCSI
;
1413 mc
->is_default
= true;
1414 mc
->default_boot_order
= "c";
1415 mc
->default_cpu_type
= SPARC_CPU_TYPE_NAME("Fujitsu-MB86904");
1416 mc
->default_display
= "tcx";
1417 mc
->default_ram_id
= "sun4m.ram";
1420 static const TypeInfo ss5_type
= {
1421 .name
= MACHINE_TYPE_NAME("SS-5"),
1422 .parent
= TYPE_MACHINE
,
1423 .class_init
= ss5_class_init
,
1426 static void ss10_class_init(ObjectClass
*oc
, void *data
)
1428 MachineClass
*mc
= MACHINE_CLASS(oc
);
1430 mc
->desc
= "Sun4m platform, SPARCstation 10";
1431 mc
->init
= ss10_init
;
1432 mc
->block_default_type
= IF_SCSI
;
1434 mc
->default_boot_order
= "c";
1435 mc
->default_cpu_type
= SPARC_CPU_TYPE_NAME("TI-SuperSparc-II");
1436 mc
->default_display
= "tcx";
1437 mc
->default_ram_id
= "sun4m.ram";
1440 static const TypeInfo ss10_type
= {
1441 .name
= MACHINE_TYPE_NAME("SS-10"),
1442 .parent
= TYPE_MACHINE
,
1443 .class_init
= ss10_class_init
,
1446 static void ss600mp_class_init(ObjectClass
*oc
, void *data
)
1448 MachineClass
*mc
= MACHINE_CLASS(oc
);
1450 mc
->desc
= "Sun4m platform, SPARCserver 600MP";
1451 mc
->init
= ss600mp_init
;
1452 mc
->block_default_type
= IF_SCSI
;
1454 mc
->default_boot_order
= "c";
1455 mc
->default_cpu_type
= SPARC_CPU_TYPE_NAME("TI-SuperSparc-II");
1456 mc
->default_display
= "tcx";
1457 mc
->default_ram_id
= "sun4m.ram";
1460 static const TypeInfo ss600mp_type
= {
1461 .name
= MACHINE_TYPE_NAME("SS-600MP"),
1462 .parent
= TYPE_MACHINE
,
1463 .class_init
= ss600mp_class_init
,
1466 static void ss20_class_init(ObjectClass
*oc
, void *data
)
1468 MachineClass
*mc
= MACHINE_CLASS(oc
);
1470 mc
->desc
= "Sun4m platform, SPARCstation 20";
1471 mc
->init
= ss20_init
;
1472 mc
->block_default_type
= IF_SCSI
;
1474 mc
->default_boot_order
= "c";
1475 mc
->default_cpu_type
= SPARC_CPU_TYPE_NAME("TI-SuperSparc-II");
1476 mc
->default_display
= "tcx";
1477 mc
->default_ram_id
= "sun4m.ram";
1480 static const TypeInfo ss20_type
= {
1481 .name
= MACHINE_TYPE_NAME("SS-20"),
1482 .parent
= TYPE_MACHINE
,
1483 .class_init
= ss20_class_init
,
1486 static void voyager_class_init(ObjectClass
*oc
, void *data
)
1488 MachineClass
*mc
= MACHINE_CLASS(oc
);
1490 mc
->desc
= "Sun4m platform, SPARCstation Voyager";
1491 mc
->init
= vger_init
;
1492 mc
->block_default_type
= IF_SCSI
;
1493 mc
->default_boot_order
= "c";
1494 mc
->default_cpu_type
= SPARC_CPU_TYPE_NAME("Fujitsu-MB86904");
1495 mc
->default_display
= "tcx";
1496 mc
->default_ram_id
= "sun4m.ram";
1499 static const TypeInfo voyager_type
= {
1500 .name
= MACHINE_TYPE_NAME("Voyager"),
1501 .parent
= TYPE_MACHINE
,
1502 .class_init
= voyager_class_init
,
1505 static void ss_lx_class_init(ObjectClass
*oc
, void *data
)
1507 MachineClass
*mc
= MACHINE_CLASS(oc
);
1509 mc
->desc
= "Sun4m platform, SPARCstation LX";
1510 mc
->init
= ss_lx_init
;
1511 mc
->block_default_type
= IF_SCSI
;
1512 mc
->default_boot_order
= "c";
1513 mc
->default_cpu_type
= SPARC_CPU_TYPE_NAME("TI-MicroSparc-I");
1514 mc
->default_display
= "tcx";
1515 mc
->default_ram_id
= "sun4m.ram";
1518 static const TypeInfo ss_lx_type
= {
1519 .name
= MACHINE_TYPE_NAME("LX"),
1520 .parent
= TYPE_MACHINE
,
1521 .class_init
= ss_lx_class_init
,
1524 static void ss4_class_init(ObjectClass
*oc
, void *data
)
1526 MachineClass
*mc
= MACHINE_CLASS(oc
);
1528 mc
->desc
= "Sun4m platform, SPARCstation 4";
1529 mc
->init
= ss4_init
;
1530 mc
->block_default_type
= IF_SCSI
;
1531 mc
->default_boot_order
= "c";
1532 mc
->default_cpu_type
= SPARC_CPU_TYPE_NAME("Fujitsu-MB86904");
1533 mc
->default_display
= "tcx";
1534 mc
->default_ram_id
= "sun4m.ram";
1537 static const TypeInfo ss4_type
= {
1538 .name
= MACHINE_TYPE_NAME("SS-4"),
1539 .parent
= TYPE_MACHINE
,
1540 .class_init
= ss4_class_init
,
1543 static void scls_class_init(ObjectClass
*oc
, void *data
)
1545 MachineClass
*mc
= MACHINE_CLASS(oc
);
1547 mc
->desc
= "Sun4m platform, SPARCClassic";
1548 mc
->init
= scls_init
;
1549 mc
->block_default_type
= IF_SCSI
;
1550 mc
->default_boot_order
= "c";
1551 mc
->default_cpu_type
= SPARC_CPU_TYPE_NAME("TI-MicroSparc-I");
1552 mc
->default_display
= "tcx";
1553 mc
->default_ram_id
= "sun4m.ram";
1556 static const TypeInfo scls_type
= {
1557 .name
= MACHINE_TYPE_NAME("SPARCClassic"),
1558 .parent
= TYPE_MACHINE
,
1559 .class_init
= scls_class_init
,
1562 static void sbook_class_init(ObjectClass
*oc
, void *data
)
1564 MachineClass
*mc
= MACHINE_CLASS(oc
);
1566 mc
->desc
= "Sun4m platform, SPARCbook";
1567 mc
->init
= sbook_init
;
1568 mc
->block_default_type
= IF_SCSI
;
1569 mc
->default_boot_order
= "c";
1570 mc
->default_cpu_type
= SPARC_CPU_TYPE_NAME("TI-MicroSparc-I");
1571 mc
->default_display
= "tcx";
1572 mc
->default_ram_id
= "sun4m.ram";
1575 static const TypeInfo sbook_type
= {
1576 .name
= MACHINE_TYPE_NAME("SPARCbook"),
1577 .parent
= TYPE_MACHINE
,
1578 .class_init
= sbook_class_init
,
1581 static void sun4m_register_types(void)
1583 type_register_static(&idreg_info
);
1584 type_register_static(&afx_info
);
1585 type_register_static(&prom_info
);
1586 type_register_static(&ram_info
);
1588 type_register_static(&ss5_type
);
1589 type_register_static(&ss10_type
);
1590 type_register_static(&ss600mp_type
);
1591 type_register_static(&ss20_type
);
1592 type_register_static(&voyager_type
);
1593 type_register_static(&ss_lx_type
);
1594 type_register_static(&ss4_type
);
1595 type_register_static(&scls_type
);
1596 type_register_static(&sbook_type
);
1599 type_init(sun4m_register_types
)