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
24 #include "qemu/osdep.h"
25 #include "qemu/units.h"
26 #include "qapi/error.h"
27 #include "qemu-common.h"
29 #include "hw/sysbus.h"
30 #include "qemu/error-report.h"
31 #include "qemu/timer.h"
32 #include "hw/sparc/sun4m_iommu.h"
33 #include "hw/timer/m48t59.h"
34 #include "hw/sparc/sparc32_dma.h"
35 #include "hw/block/fdc.h"
36 #include "sysemu/sysemu.h"
38 #include "hw/boards.h"
39 #include "hw/scsi/esp.h"
40 #include "hw/nvram/sun_nvram.h"
41 #include "hw/nvram/chrp_nvram.h"
42 #include "hw/nvram/fw_cfg.h"
43 #include "hw/char/escc.h"
44 #include "hw/empty_slot.h"
45 #include "hw/loader.h"
50 * Sun4m architecture was used in the following machines:
52 * SPARCserver 6xxMP/xx
53 * SPARCclassic (SPARCclassic Server)(SPARCstation LC) (4/15),
54 * SPARCclassic X (4/10)
55 * SPARCstation LX/ZX (4/30)
56 * SPARCstation Voyager
57 * SPARCstation 10/xx, SPARCserver 10/xx
58 * SPARCstation 5, SPARCserver 5
59 * SPARCstation 20/xx, SPARCserver 20
62 * See for example: http://www.sunhelp.org/faq/sunref1.html
65 #define KERNEL_LOAD_ADDR 0x00004000
66 #define CMDLINE_ADDR 0x007ff000
67 #define INITRD_LOAD_ADDR 0x00800000
68 #define PROM_SIZE_MAX (1 * MiB)
69 #define PROM_VADDR 0xffd00000
70 #define PROM_FILENAME "openbios-sparc32"
71 #define CFG_ADDR 0xd00000510ULL
72 #define FW_CFG_SUN4M_DEPTH (FW_CFG_ARCH_LOCAL + 0x00)
73 #define FW_CFG_SUN4M_WIDTH (FW_CFG_ARCH_LOCAL + 0x01)
74 #define FW_CFG_SUN4M_HEIGHT (FW_CFG_ARCH_LOCAL + 0x02)
80 #define ESCC_CLOCK 4915200
83 hwaddr iommu_base
, iommu_pad_base
, iommu_pad_len
, slavio_base
;
84 hwaddr intctl_base
, counter_base
, nvram_base
, ms_kb_base
;
85 hwaddr serial_base
, fd_base
;
86 hwaddr afx_base
, idreg_base
, dma_base
, esp_base
, le_base
;
87 hwaddr tcx_base
, cs_base
, apc_base
, aux1_base
, aux2_base
;
88 hwaddr bpp_base
, dbri_base
, sx_base
;
90 hwaddr reg_base
, vram_base
;
95 uint32_t iommu_version
;
97 uint8_t nvram_machine_id
;
100 static void fw_cfg_boot_set(void *opaque
, const char *boot_device
,
103 fw_cfg_modify_i16(opaque
, FW_CFG_BOOT_DEVICE
, boot_device
[0]);
106 static void nvram_init(Nvram
*nvram
, uint8_t *macaddr
,
107 const char *cmdline
, const char *boot_devices
,
108 ram_addr_t RAM_size
, uint32_t kernel_size
,
109 int width
, int height
, int depth
,
110 int nvram_machine_id
, const char *arch
)
114 uint8_t image
[0x1ff0];
115 NvramClass
*k
= NVRAM_GET_CLASS(nvram
);
117 memset(image
, '\0', sizeof(image
));
119 /* OpenBIOS nvram variables partition */
120 sysp_end
= chrp_nvram_create_system_partition(image
, 0);
122 /* Free space partition */
123 chrp_nvram_create_free_partition(&image
[sysp_end
], 0x1fd0 - sysp_end
);
125 Sun_init_header((struct Sun_nvram
*)&image
[0x1fd8], macaddr
,
128 for (i
= 0; i
< sizeof(image
); i
++) {
129 (k
->write
)(nvram
, i
, image
[i
]);
133 void cpu_check_irqs(CPUSPARCState
*env
)
137 /* We should be holding the BQL before we mess with IRQs */
138 g_assert(qemu_mutex_iothread_locked());
140 if (env
->pil_in
&& (env
->interrupt_index
== 0 ||
141 (env
->interrupt_index
& ~15) == TT_EXTINT
)) {
144 for (i
= 15; i
> 0; i
--) {
145 if (env
->pil_in
& (1 << i
)) {
146 int old_interrupt
= env
->interrupt_index
;
148 env
->interrupt_index
= TT_EXTINT
| i
;
149 if (old_interrupt
!= env
->interrupt_index
) {
150 cs
= CPU(sparc_env_get_cpu(env
));
151 trace_sun4m_cpu_interrupt(i
);
152 cpu_interrupt(cs
, CPU_INTERRUPT_HARD
);
157 } else if (!env
->pil_in
&& (env
->interrupt_index
& ~15) == TT_EXTINT
) {
158 cs
= CPU(sparc_env_get_cpu(env
));
159 trace_sun4m_cpu_reset_interrupt(env
->interrupt_index
& 15);
160 env
->interrupt_index
= 0;
161 cpu_reset_interrupt(cs
, CPU_INTERRUPT_HARD
);
165 static void cpu_kick_irq(SPARCCPU
*cpu
)
167 CPUSPARCState
*env
= &cpu
->env
;
168 CPUState
*cs
= CPU(cpu
);
175 static void cpu_set_irq(void *opaque
, int irq
, int level
)
177 SPARCCPU
*cpu
= opaque
;
178 CPUSPARCState
*env
= &cpu
->env
;
181 trace_sun4m_cpu_set_irq_raise(irq
);
182 env
->pil_in
|= 1 << irq
;
185 trace_sun4m_cpu_set_irq_lower(irq
);
186 env
->pil_in
&= ~(1 << irq
);
191 static void dummy_cpu_set_irq(void *opaque
, int irq
, int level
)
195 static void main_cpu_reset(void *opaque
)
197 SPARCCPU
*cpu
= opaque
;
198 CPUState
*cs
= CPU(cpu
);
204 static void secondary_cpu_reset(void *opaque
)
206 SPARCCPU
*cpu
= opaque
;
207 CPUState
*cs
= CPU(cpu
);
213 static void cpu_halt_signal(void *opaque
, int irq
, int level
)
215 if (level
&& current_cpu
) {
216 cpu_interrupt(current_cpu
, CPU_INTERRUPT_HALT
);
220 static uint64_t translate_kernel_address(void *opaque
, uint64_t addr
)
222 return addr
- 0xf0000000ULL
;
225 static unsigned long sun4m_load_kernel(const char *kernel_filename
,
226 const char *initrd_filename
,
228 uint32_t *initrd_size
)
235 linux_boot
= (kernel_filename
!= NULL
);
246 kernel_size
= load_elf(kernel_filename
, NULL
,
247 translate_kernel_address
, NULL
,
248 NULL
, NULL
, NULL
, 1, EM_SPARC
, 0, 0);
250 kernel_size
= load_aout(kernel_filename
, KERNEL_LOAD_ADDR
,
251 RAM_size
- KERNEL_LOAD_ADDR
, bswap_needed
,
254 kernel_size
= load_image_targphys(kernel_filename
,
256 RAM_size
- KERNEL_LOAD_ADDR
);
257 if (kernel_size
< 0) {
258 error_report("could not load kernel '%s'", kernel_filename
);
264 if (initrd_filename
) {
265 *initrd_size
= load_image_targphys(initrd_filename
,
267 RAM_size
- INITRD_LOAD_ADDR
);
268 if ((int)*initrd_size
< 0) {
269 error_report("could not load initial ram disk '%s'",
274 if (*initrd_size
> 0) {
275 for (i
= 0; i
< 64 * TARGET_PAGE_SIZE
; i
+= TARGET_PAGE_SIZE
) {
276 ptr
= rom_ptr(KERNEL_LOAD_ADDR
+ i
, 24);
277 if (ptr
&& ldl_p(ptr
) == 0x48647253) { /* HdrS */
278 stl_p(ptr
+ 16, INITRD_LOAD_ADDR
);
279 stl_p(ptr
+ 20, *initrd_size
);
288 static void *iommu_init(hwaddr addr
, uint32_t version
, qemu_irq irq
)
293 dev
= qdev_create(NULL
, TYPE_SUN4M_IOMMU
);
294 qdev_prop_set_uint32(dev
, "version", version
);
295 qdev_init_nofail(dev
);
296 s
= SYS_BUS_DEVICE(dev
);
297 sysbus_connect_irq(s
, 0, irq
);
298 sysbus_mmio_map(s
, 0, addr
);
303 static void *sparc32_dma_init(hwaddr dma_base
,
304 hwaddr esp_base
, qemu_irq espdma_irq
,
305 hwaddr le_base
, qemu_irq ledma_irq
)
308 ESPDMADeviceState
*espdma
;
309 LEDMADeviceState
*ledma
;
311 SysBusPCNetState
*lance
;
313 dma
= qdev_create(NULL
, TYPE_SPARC32_DMA
);
314 qdev_init_nofail(dma
);
315 sysbus_mmio_map(SYS_BUS_DEVICE(dma
), 0, dma_base
);
317 espdma
= SPARC32_ESPDMA_DEVICE(object_resolve_path_component(
318 OBJECT(dma
), "espdma"));
319 sysbus_connect_irq(SYS_BUS_DEVICE(espdma
), 0, espdma_irq
);
321 esp
= ESP_STATE(object_resolve_path_component(OBJECT(espdma
), "esp"));
322 sysbus_mmio_map(SYS_BUS_DEVICE(esp
), 0, esp_base
);
323 scsi_bus_legacy_handle_cmdline(&esp
->esp
.bus
);
325 ledma
= SPARC32_LEDMA_DEVICE(object_resolve_path_component(
326 OBJECT(dma
), "ledma"));
327 sysbus_connect_irq(SYS_BUS_DEVICE(ledma
), 0, ledma_irq
);
329 lance
= SYSBUS_PCNET(object_resolve_path_component(
330 OBJECT(ledma
), "lance"));
331 sysbus_mmio_map(SYS_BUS_DEVICE(lance
), 0, le_base
);
336 static DeviceState
*slavio_intctl_init(hwaddr addr
,
338 qemu_irq
**parent_irq
)
344 dev
= qdev_create(NULL
, "slavio_intctl");
345 qdev_init_nofail(dev
);
347 s
= SYS_BUS_DEVICE(dev
);
349 for (i
= 0; i
< MAX_CPUS
; i
++) {
350 for (j
= 0; j
< MAX_PILS
; j
++) {
351 sysbus_connect_irq(s
, i
* MAX_PILS
+ j
, parent_irq
[i
][j
]);
354 sysbus_mmio_map(s
, 0, addrg
);
355 for (i
= 0; i
< MAX_CPUS
; i
++) {
356 sysbus_mmio_map(s
, i
+ 1, addr
+ i
* TARGET_PAGE_SIZE
);
362 #define SYS_TIMER_OFFSET 0x10000ULL
363 #define CPU_TIMER_OFFSET(cpu) (0x1000ULL * cpu)
365 static void slavio_timer_init_all(hwaddr addr
, qemu_irq master_irq
,
366 qemu_irq
*cpu_irqs
, unsigned int num_cpus
)
372 dev
= qdev_create(NULL
, "slavio_timer");
373 qdev_prop_set_uint32(dev
, "num_cpus", num_cpus
);
374 qdev_init_nofail(dev
);
375 s
= SYS_BUS_DEVICE(dev
);
376 sysbus_connect_irq(s
, 0, master_irq
);
377 sysbus_mmio_map(s
, 0, addr
+ SYS_TIMER_OFFSET
);
379 for (i
= 0; i
< MAX_CPUS
; i
++) {
380 sysbus_mmio_map(s
, i
+ 1, addr
+ (hwaddr
)CPU_TIMER_OFFSET(i
));
381 sysbus_connect_irq(s
, i
+ 1, cpu_irqs
[i
]);
385 static qemu_irq slavio_system_powerdown
;
387 static void slavio_powerdown_req(Notifier
*n
, void *opaque
)
389 qemu_irq_raise(slavio_system_powerdown
);
392 static Notifier slavio_system_powerdown_notifier
= {
393 .notify
= slavio_powerdown_req
396 #define MISC_LEDS 0x01600000
397 #define MISC_CFG 0x01800000
398 #define MISC_DIAG 0x01a00000
399 #define MISC_MDM 0x01b00000
400 #define MISC_SYS 0x01f00000
402 static void slavio_misc_init(hwaddr base
,
404 hwaddr aux2_base
, qemu_irq irq
,
410 dev
= qdev_create(NULL
, "slavio_misc");
411 qdev_init_nofail(dev
);
412 s
= SYS_BUS_DEVICE(dev
);
414 /* 8 bit registers */
416 sysbus_mmio_map(s
, 0, base
+ MISC_CFG
);
418 sysbus_mmio_map(s
, 1, base
+ MISC_DIAG
);
420 sysbus_mmio_map(s
, 2, base
+ MISC_MDM
);
421 /* 16 bit registers */
422 /* ss600mp diag LEDs */
423 sysbus_mmio_map(s
, 3, base
+ MISC_LEDS
);
424 /* 32 bit registers */
426 sysbus_mmio_map(s
, 4, base
+ MISC_SYS
);
429 /* AUX 1 (Misc System Functions) */
430 sysbus_mmio_map(s
, 5, aux1_base
);
433 /* AUX 2 (Software Powerdown Control) */
434 sysbus_mmio_map(s
, 6, aux2_base
);
436 sysbus_connect_irq(s
, 0, irq
);
437 sysbus_connect_irq(s
, 1, fdc_tc
);
438 slavio_system_powerdown
= qdev_get_gpio_in(dev
, 0);
439 qemu_register_powerdown_notifier(&slavio_system_powerdown_notifier
);
442 static void ecc_init(hwaddr base
, qemu_irq irq
, uint32_t version
)
447 dev
= qdev_create(NULL
, "eccmemctl");
448 qdev_prop_set_uint32(dev
, "version", version
);
449 qdev_init_nofail(dev
);
450 s
= SYS_BUS_DEVICE(dev
);
451 sysbus_connect_irq(s
, 0, irq
);
452 sysbus_mmio_map(s
, 0, base
);
453 if (version
== 0) { // SS-600MP only
454 sysbus_mmio_map(s
, 1, base
+ 0x1000);
458 static void apc_init(hwaddr power_base
, qemu_irq cpu_halt
)
463 dev
= qdev_create(NULL
, "apc");
464 qdev_init_nofail(dev
);
465 s
= SYS_BUS_DEVICE(dev
);
466 /* Power management (APC) XXX: not a Slavio device */
467 sysbus_mmio_map(s
, 0, power_base
);
468 sysbus_connect_irq(s
, 0, cpu_halt
);
471 static void tcx_init(hwaddr addr
, qemu_irq irq
, int vram_size
, int width
,
472 int height
, int depth
)
477 dev
= qdev_create(NULL
, "SUNW,tcx");
478 qdev_prop_set_uint32(dev
, "vram_size", vram_size
);
479 qdev_prop_set_uint16(dev
, "width", width
);
480 qdev_prop_set_uint16(dev
, "height", height
);
481 qdev_prop_set_uint16(dev
, "depth", depth
);
482 qdev_init_nofail(dev
);
483 s
= SYS_BUS_DEVICE(dev
);
485 /* 10/ROM : FCode ROM */
486 sysbus_mmio_map(s
, 0, addr
);
487 /* 2/STIP : Stipple */
488 sysbus_mmio_map(s
, 1, addr
+ 0x04000000ULL
);
489 /* 3/BLIT : Blitter */
490 sysbus_mmio_map(s
, 2, addr
+ 0x06000000ULL
);
491 /* 5/RSTIP : Raw Stipple */
492 sysbus_mmio_map(s
, 3, addr
+ 0x0c000000ULL
);
493 /* 6/RBLIT : Raw Blitter */
494 sysbus_mmio_map(s
, 4, addr
+ 0x0e000000ULL
);
495 /* 7/TEC : Transform Engine */
496 sysbus_mmio_map(s
, 5, addr
+ 0x00700000ULL
);
498 sysbus_mmio_map(s
, 6, addr
+ 0x00200000ULL
);
501 sysbus_mmio_map(s
, 7, addr
+ 0x00300000ULL
);
503 sysbus_mmio_map(s
, 7, addr
+ 0x00301000ULL
);
506 sysbus_mmio_map(s
, 8, addr
+ 0x00240000ULL
);
508 sysbus_mmio_map(s
, 9, addr
+ 0x00280000ULL
);
509 /* 0/DFB8 : 8-bit plane */
510 sysbus_mmio_map(s
, 10, addr
+ 0x00800000ULL
);
511 /* 1/DFB24 : 24bit plane */
512 sysbus_mmio_map(s
, 11, addr
+ 0x02000000ULL
);
513 /* 4/RDFB32: Raw framebuffer. Control plane */
514 sysbus_mmio_map(s
, 12, addr
+ 0x0a000000ULL
);
515 /* 9/THC24bits : NetBSD writes here even with 8-bit display: dummy */
517 sysbus_mmio_map(s
, 13, addr
+ 0x00301000ULL
);
520 sysbus_connect_irq(s
, 0, irq
);
523 static void cg3_init(hwaddr addr
, qemu_irq irq
, int vram_size
, int width
,
524 int height
, int depth
)
529 dev
= qdev_create(NULL
, "cgthree");
530 qdev_prop_set_uint32(dev
, "vram-size", vram_size
);
531 qdev_prop_set_uint16(dev
, "width", width
);
532 qdev_prop_set_uint16(dev
, "height", height
);
533 qdev_prop_set_uint16(dev
, "depth", depth
);
534 qdev_init_nofail(dev
);
535 s
= SYS_BUS_DEVICE(dev
);
538 sysbus_mmio_map(s
, 0, addr
);
540 sysbus_mmio_map(s
, 1, addr
+ 0x400000ULL
);
542 sysbus_mmio_map(s
, 2, addr
+ 0x800000ULL
);
544 sysbus_connect_irq(s
, 0, irq
);
547 /* NCR89C100/MACIO Internal ID register */
549 #define TYPE_MACIO_ID_REGISTER "macio_idreg"
551 static const uint8_t idreg_data
[] = { 0xfe, 0x81, 0x01, 0x03 };
553 static void idreg_init(hwaddr addr
)
558 dev
= qdev_create(NULL
, TYPE_MACIO_ID_REGISTER
);
559 qdev_init_nofail(dev
);
560 s
= SYS_BUS_DEVICE(dev
);
562 sysbus_mmio_map(s
, 0, addr
);
563 address_space_write_rom(&address_space_memory
, addr
,
564 MEMTXATTRS_UNSPECIFIED
,
565 idreg_data
, sizeof(idreg_data
));
568 #define MACIO_ID_REGISTER(obj) \
569 OBJECT_CHECK(IDRegState, (obj), TYPE_MACIO_ID_REGISTER)
571 typedef struct IDRegState
{
572 SysBusDevice parent_obj
;
577 static void idreg_realize(DeviceState
*ds
, Error
**errp
)
579 IDRegState
*s
= MACIO_ID_REGISTER(ds
);
580 SysBusDevice
*dev
= SYS_BUS_DEVICE(ds
);
581 Error
*local_err
= NULL
;
583 memory_region_init_ram_nomigrate(&s
->mem
, OBJECT(ds
), "sun4m.idreg",
584 sizeof(idreg_data
), &local_err
);
586 error_propagate(errp
, local_err
);
590 vmstate_register_ram_global(&s
->mem
);
591 memory_region_set_readonly(&s
->mem
, true);
592 sysbus_init_mmio(dev
, &s
->mem
);
595 static void idreg_class_init(ObjectClass
*oc
, void *data
)
597 DeviceClass
*dc
= DEVICE_CLASS(oc
);
599 dc
->realize
= idreg_realize
;
602 static const TypeInfo idreg_info
= {
603 .name
= TYPE_MACIO_ID_REGISTER
,
604 .parent
= TYPE_SYS_BUS_DEVICE
,
605 .instance_size
= sizeof(IDRegState
),
606 .class_init
= idreg_class_init
,
609 #define TYPE_TCX_AFX "tcx_afx"
610 #define TCX_AFX(obj) OBJECT_CHECK(AFXState, (obj), TYPE_TCX_AFX)
612 typedef struct AFXState
{
613 SysBusDevice parent_obj
;
618 /* SS-5 TCX AFX register */
619 static void afx_init(hwaddr addr
)
624 dev
= qdev_create(NULL
, TYPE_TCX_AFX
);
625 qdev_init_nofail(dev
);
626 s
= SYS_BUS_DEVICE(dev
);
628 sysbus_mmio_map(s
, 0, addr
);
631 static void afx_realize(DeviceState
*ds
, Error
**errp
)
633 AFXState
*s
= TCX_AFX(ds
);
634 SysBusDevice
*dev
= SYS_BUS_DEVICE(ds
);
635 Error
*local_err
= NULL
;
637 memory_region_init_ram_nomigrate(&s
->mem
, OBJECT(ds
), "sun4m.afx", 4,
640 error_propagate(errp
, local_err
);
644 vmstate_register_ram_global(&s
->mem
);
645 sysbus_init_mmio(dev
, &s
->mem
);
648 static void afx_class_init(ObjectClass
*oc
, void *data
)
650 DeviceClass
*dc
= DEVICE_CLASS(oc
);
652 dc
->realize
= afx_realize
;
655 static const TypeInfo afx_info
= {
656 .name
= TYPE_TCX_AFX
,
657 .parent
= TYPE_SYS_BUS_DEVICE
,
658 .instance_size
= sizeof(AFXState
),
659 .class_init
= afx_class_init
,
662 #define TYPE_OPENPROM "openprom"
663 #define OPENPROM(obj) OBJECT_CHECK(PROMState, (obj), TYPE_OPENPROM)
665 typedef struct PROMState
{
666 SysBusDevice parent_obj
;
671 /* Boot PROM (OpenBIOS) */
672 static uint64_t translate_prom_address(void *opaque
, uint64_t addr
)
674 hwaddr
*base_addr
= (hwaddr
*)opaque
;
675 return addr
+ *base_addr
- PROM_VADDR
;
678 static void prom_init(hwaddr addr
, const char *bios_name
)
685 dev
= qdev_create(NULL
, TYPE_OPENPROM
);
686 qdev_init_nofail(dev
);
687 s
= SYS_BUS_DEVICE(dev
);
689 sysbus_mmio_map(s
, 0, addr
);
692 if (bios_name
== NULL
) {
693 bios_name
= PROM_FILENAME
;
695 filename
= qemu_find_file(QEMU_FILE_TYPE_BIOS
, bios_name
);
697 ret
= load_elf(filename
, NULL
,
698 translate_prom_address
, &addr
, NULL
,
699 NULL
, NULL
, 1, EM_SPARC
, 0, 0);
700 if (ret
< 0 || ret
> PROM_SIZE_MAX
) {
701 ret
= load_image_targphys(filename
, addr
, PROM_SIZE_MAX
);
707 if (ret
< 0 || ret
> PROM_SIZE_MAX
) {
708 error_report("could not load prom '%s'", bios_name
);
713 static void prom_realize(DeviceState
*ds
, Error
**errp
)
715 PROMState
*s
= OPENPROM(ds
);
716 SysBusDevice
*dev
= SYS_BUS_DEVICE(ds
);
717 Error
*local_err
= NULL
;
719 memory_region_init_ram_nomigrate(&s
->prom
, OBJECT(ds
), "sun4m.prom",
720 PROM_SIZE_MAX
, &local_err
);
722 error_propagate(errp
, local_err
);
726 vmstate_register_ram_global(&s
->prom
);
727 memory_region_set_readonly(&s
->prom
, true);
728 sysbus_init_mmio(dev
, &s
->prom
);
731 static Property prom_properties
[] = {
732 {/* end of property list */},
735 static void prom_class_init(ObjectClass
*klass
, void *data
)
737 DeviceClass
*dc
= DEVICE_CLASS(klass
);
739 dc
->props
= prom_properties
;
740 dc
->realize
= prom_realize
;
743 static const TypeInfo prom_info
= {
744 .name
= TYPE_OPENPROM
,
745 .parent
= TYPE_SYS_BUS_DEVICE
,
746 .instance_size
= sizeof(PROMState
),
747 .class_init
= prom_class_init
,
750 #define TYPE_SUN4M_MEMORY "memory"
751 #define SUN4M_RAM(obj) OBJECT_CHECK(RamDevice, (obj), TYPE_SUN4M_MEMORY)
753 typedef struct RamDevice
{
754 SysBusDevice parent_obj
;
761 static void ram_realize(DeviceState
*dev
, Error
**errp
)
763 RamDevice
*d
= SUN4M_RAM(dev
);
764 SysBusDevice
*sbd
= SYS_BUS_DEVICE(dev
);
766 memory_region_allocate_system_memory(&d
->ram
, OBJECT(d
), "sun4m.ram",
768 sysbus_init_mmio(sbd
, &d
->ram
);
771 static void ram_init(hwaddr addr
, ram_addr_t RAM_size
,
779 if ((uint64_t)RAM_size
> max_mem
) {
780 error_report("Too much memory for this machine: %" PRId64
","
782 RAM_size
/ MiB
, max_mem
/ MiB
);
785 dev
= qdev_create(NULL
, "memory");
786 s
= SYS_BUS_DEVICE(dev
);
790 qdev_init_nofail(dev
);
792 sysbus_mmio_map(s
, 0, addr
);
795 static Property ram_properties
[] = {
796 DEFINE_PROP_UINT64("size", RamDevice
, size
, 0),
797 DEFINE_PROP_END_OF_LIST(),
800 static void ram_class_init(ObjectClass
*klass
, void *data
)
802 DeviceClass
*dc
= DEVICE_CLASS(klass
);
804 dc
->realize
= ram_realize
;
805 dc
->props
= ram_properties
;
808 static const TypeInfo ram_info
= {
809 .name
= TYPE_SUN4M_MEMORY
,
810 .parent
= TYPE_SYS_BUS_DEVICE
,
811 .instance_size
= sizeof(RamDevice
),
812 .class_init
= ram_class_init
,
815 static void cpu_devinit(const char *cpu_type
, unsigned int id
,
816 uint64_t prom_addr
, qemu_irq
**cpu_irqs
)
822 cpu
= SPARC_CPU(cpu_create(cpu_type
));
825 cpu_sparc_set_id(env
, id
);
827 qemu_register_reset(main_cpu_reset
, cpu
);
829 qemu_register_reset(secondary_cpu_reset
, cpu
);
833 *cpu_irqs
= qemu_allocate_irqs(cpu_set_irq
, cpu
, MAX_PILS
);
834 env
->prom_addr
= prom_addr
;
837 static void dummy_fdc_tc(void *opaque
, int irq
, int level
)
841 static void sun4m_hw_init(const struct sun4m_hwdef
*hwdef
,
842 MachineState
*machine
)
844 DeviceState
*slavio_intctl
;
847 qemu_irq
*cpu_irqs
[MAX_CPUS
], slavio_irq
[32], slavio_cpu_irq
[MAX_CPUS
];
849 unsigned long kernel_size
;
850 uint32_t initrd_size
;
851 DriveInfo
*fd
[MAX_FD
];
853 unsigned int num_vsimms
;
858 for(i
= 0; i
< smp_cpus
; i
++) {
859 cpu_devinit(machine
->cpu_type
, i
, hwdef
->slavio_base
, &cpu_irqs
[i
]);
862 for (i
= smp_cpus
; i
< MAX_CPUS
; i
++)
863 cpu_irqs
[i
] = qemu_allocate_irqs(dummy_cpu_set_irq
, NULL
, MAX_PILS
);
867 ram_init(0, machine
->ram_size
, hwdef
->max_mem
);
868 /* models without ECC don't trap when missing ram is accessed */
869 if (!hwdef
->ecc_base
) {
870 empty_slot_init(machine
->ram_size
, hwdef
->max_mem
- machine
->ram_size
);
873 prom_init(hwdef
->slavio_base
, bios_name
);
875 slavio_intctl
= slavio_intctl_init(hwdef
->intctl_base
,
876 hwdef
->intctl_base
+ 0x10000ULL
,
879 for (i
= 0; i
< 32; i
++) {
880 slavio_irq
[i
] = qdev_get_gpio_in(slavio_intctl
, i
);
882 for (i
= 0; i
< MAX_CPUS
; i
++) {
883 slavio_cpu_irq
[i
] = qdev_get_gpio_in(slavio_intctl
, 32 + i
);
886 if (hwdef
->idreg_base
) {
887 idreg_init(hwdef
->idreg_base
);
890 if (hwdef
->afx_base
) {
891 afx_init(hwdef
->afx_base
);
894 iommu_init(hwdef
->iommu_base
, hwdef
->iommu_version
, slavio_irq
[30]);
896 if (hwdef
->iommu_pad_base
) {
897 /* On the real hardware (SS-5, LX) the MMU is not padded, but aliased.
898 Software shouldn't use aliased addresses, neither should it crash
899 when does. Using empty_slot instead of aliasing can help with
900 debugging such accesses */
901 empty_slot_init(hwdef
->iommu_pad_base
,hwdef
->iommu_pad_len
);
904 sparc32_dma_init(hwdef
->dma_base
,
905 hwdef
->esp_base
, slavio_irq
[18],
906 hwdef
->le_base
, slavio_irq
[16]);
908 if (graphic_depth
!= 8 && graphic_depth
!= 24) {
909 error_report("Unsupported depth: %d", graphic_depth
);
913 if (num_vsimms
== 0) {
914 if (vga_interface_type
== VGA_CG3
) {
915 if (graphic_depth
!= 8) {
916 error_report("Unsupported depth: %d", graphic_depth
);
920 if (!(graphic_width
== 1024 && graphic_height
== 768) &&
921 !(graphic_width
== 1152 && graphic_height
== 900)) {
922 error_report("Unsupported resolution: %d x %d", graphic_width
,
928 cg3_init(hwdef
->tcx_base
, slavio_irq
[11], 0x00100000,
929 graphic_width
, graphic_height
, graphic_depth
);
931 /* If no display specified, default to TCX */
932 if (graphic_depth
!= 8 && graphic_depth
!= 24) {
933 error_report("Unsupported depth: %d", graphic_depth
);
937 if (!(graphic_width
== 1024 && graphic_height
== 768)) {
938 error_report("Unsupported resolution: %d x %d",
939 graphic_width
, graphic_height
);
943 tcx_init(hwdef
->tcx_base
, slavio_irq
[11], 0x00100000,
944 graphic_width
, graphic_height
, graphic_depth
);
948 for (i
= num_vsimms
; i
< MAX_VSIMMS
; i
++) {
949 /* vsimm registers probed by OBP */
950 if (hwdef
->vsimm
[i
].reg_base
) {
951 empty_slot_init(hwdef
->vsimm
[i
].reg_base
, 0x2000);
955 if (hwdef
->sx_base
) {
956 empty_slot_init(hwdef
->sx_base
, 0x2000);
959 nvram
= m48t59_init(slavio_irq
[0], hwdef
->nvram_base
, 0, 0x2000, 1968, 8);
961 slavio_timer_init_all(hwdef
->counter_base
, slavio_irq
[19], slavio_cpu_irq
, smp_cpus
);
963 /* Slavio TTYA (base+4, Linux ttyS0) is the first QEMU serial device
964 Slavio TTYB (base+0, Linux ttyS1) is the second QEMU serial device */
965 dev
= qdev_create(NULL
, TYPE_ESCC
);
966 qdev_prop_set_uint32(dev
, "disabled", !machine
->enable_graphics
);
967 qdev_prop_set_uint32(dev
, "frequency", ESCC_CLOCK
);
968 qdev_prop_set_uint32(dev
, "it_shift", 1);
969 qdev_prop_set_chr(dev
, "chrB", NULL
);
970 qdev_prop_set_chr(dev
, "chrA", NULL
);
971 qdev_prop_set_uint32(dev
, "chnBtype", escc_mouse
);
972 qdev_prop_set_uint32(dev
, "chnAtype", escc_kbd
);
973 qdev_init_nofail(dev
);
974 s
= SYS_BUS_DEVICE(dev
);
975 sysbus_connect_irq(s
, 0, slavio_irq
[14]);
976 sysbus_connect_irq(s
, 1, slavio_irq
[14]);
977 sysbus_mmio_map(s
, 0, hwdef
->ms_kb_base
);
979 dev
= qdev_create(NULL
, TYPE_ESCC
);
980 qdev_prop_set_uint32(dev
, "disabled", 0);
981 qdev_prop_set_uint32(dev
, "frequency", ESCC_CLOCK
);
982 qdev_prop_set_uint32(dev
, "it_shift", 1);
983 qdev_prop_set_chr(dev
, "chrB", serial_hd(1));
984 qdev_prop_set_chr(dev
, "chrA", serial_hd(0));
985 qdev_prop_set_uint32(dev
, "chnBtype", escc_serial
);
986 qdev_prop_set_uint32(dev
, "chnAtype", escc_serial
);
987 qdev_init_nofail(dev
);
989 s
= SYS_BUS_DEVICE(dev
);
990 sysbus_connect_irq(s
, 0, slavio_irq
[15]);
991 sysbus_connect_irq(s
, 1, slavio_irq
[15]);
992 sysbus_mmio_map(s
, 0, hwdef
->serial_base
);
994 if (hwdef
->apc_base
) {
995 apc_init(hwdef
->apc_base
, qemu_allocate_irq(cpu_halt_signal
, NULL
, 0));
998 if (hwdef
->fd_base
) {
999 /* there is zero or one floppy drive */
1000 memset(fd
, 0, sizeof(fd
));
1001 fd
[0] = drive_get(IF_FLOPPY
, 0, 0);
1002 sun4m_fdctrl_init(slavio_irq
[22], hwdef
->fd_base
, fd
,
1005 fdc_tc
= qemu_allocate_irq(dummy_fdc_tc
, NULL
, 0);
1008 slavio_misc_init(hwdef
->slavio_base
, hwdef
->aux1_base
, hwdef
->aux2_base
,
1009 slavio_irq
[30], fdc_tc
);
1011 if (hwdef
->cs_base
) {
1012 sysbus_create_simple("SUNW,CS4231", hwdef
->cs_base
,
1016 if (hwdef
->dbri_base
) {
1017 /* ISDN chip with attached CS4215 audio codec */
1019 empty_slot_init(hwdef
->dbri_base
+0x1000, 0x30);
1021 empty_slot_init(hwdef
->dbri_base
+0x10000, 0x100);
1024 if (hwdef
->bpp_base
) {
1026 empty_slot_init(hwdef
->bpp_base
, 0x20);
1030 kernel_size
= sun4m_load_kernel(machine
->kernel_filename
,
1031 machine
->initrd_filename
,
1032 machine
->ram_size
, &initrd_size
);
1034 nvram_init(nvram
, (uint8_t *)&nd_table
[0].macaddr
, machine
->kernel_cmdline
,
1035 machine
->boot_order
, machine
->ram_size
, kernel_size
,
1036 graphic_width
, graphic_height
, graphic_depth
,
1037 hwdef
->nvram_machine_id
, "Sun4m");
1039 if (hwdef
->ecc_base
)
1040 ecc_init(hwdef
->ecc_base
, slavio_irq
[28],
1041 hwdef
->ecc_version
);
1043 dev
= qdev_create(NULL
, TYPE_FW_CFG_MEM
);
1044 fw_cfg
= FW_CFG(dev
);
1045 qdev_prop_set_uint32(dev
, "data_width", 1);
1046 qdev_prop_set_bit(dev
, "dma_enabled", false);
1047 object_property_add_child(OBJECT(qdev_get_machine()), TYPE_FW_CFG
,
1048 OBJECT(fw_cfg
), NULL
);
1049 qdev_init_nofail(dev
);
1050 s
= SYS_BUS_DEVICE(dev
);
1051 sysbus_mmio_map(s
, 0, CFG_ADDR
);
1052 sysbus_mmio_map(s
, 1, CFG_ADDR
+ 2);
1054 fw_cfg_add_i16(fw_cfg
, FW_CFG_NB_CPUS
, (uint16_t)smp_cpus
);
1055 fw_cfg_add_i16(fw_cfg
, FW_CFG_MAX_CPUS
, (uint16_t)max_cpus
);
1056 fw_cfg_add_i64(fw_cfg
, FW_CFG_RAM_SIZE
, (uint64_t)ram_size
);
1057 fw_cfg_add_i16(fw_cfg
, FW_CFG_MACHINE_ID
, hwdef
->machine_id
);
1058 fw_cfg_add_i16(fw_cfg
, FW_CFG_SUN4M_DEPTH
, graphic_depth
);
1059 fw_cfg_add_i16(fw_cfg
, FW_CFG_SUN4M_WIDTH
, graphic_width
);
1060 fw_cfg_add_i16(fw_cfg
, FW_CFG_SUN4M_HEIGHT
, graphic_height
);
1061 fw_cfg_add_i32(fw_cfg
, FW_CFG_KERNEL_ADDR
, KERNEL_LOAD_ADDR
);
1062 fw_cfg_add_i32(fw_cfg
, FW_CFG_KERNEL_SIZE
, kernel_size
);
1063 if (machine
->kernel_cmdline
) {
1064 fw_cfg_add_i32(fw_cfg
, FW_CFG_KERNEL_CMDLINE
, CMDLINE_ADDR
);
1065 pstrcpy_targphys("cmdline", CMDLINE_ADDR
, TARGET_PAGE_SIZE
,
1066 machine
->kernel_cmdline
);
1067 fw_cfg_add_string(fw_cfg
, FW_CFG_CMDLINE_DATA
, machine
->kernel_cmdline
);
1068 fw_cfg_add_i32(fw_cfg
, FW_CFG_CMDLINE_SIZE
,
1069 strlen(machine
->kernel_cmdline
) + 1);
1071 fw_cfg_add_i32(fw_cfg
, FW_CFG_KERNEL_CMDLINE
, 0);
1072 fw_cfg_add_i32(fw_cfg
, FW_CFG_CMDLINE_SIZE
, 0);
1074 fw_cfg_add_i32(fw_cfg
, FW_CFG_INITRD_ADDR
, INITRD_LOAD_ADDR
);
1075 fw_cfg_add_i32(fw_cfg
, FW_CFG_INITRD_SIZE
, initrd_size
);
1076 fw_cfg_add_i16(fw_cfg
, FW_CFG_BOOT_DEVICE
, machine
->boot_order
[0]);
1077 qemu_register_boot_set(fw_cfg_boot_set
, fw_cfg
);
1092 static const struct sun4m_hwdef sun4m_hwdefs
[] = {
1095 .iommu_base
= 0x10000000,
1096 .iommu_pad_base
= 0x10004000,
1097 .iommu_pad_len
= 0x0fffb000,
1098 .tcx_base
= 0x50000000,
1099 .cs_base
= 0x6c000000,
1100 .slavio_base
= 0x70000000,
1101 .ms_kb_base
= 0x71000000,
1102 .serial_base
= 0x71100000,
1103 .nvram_base
= 0x71200000,
1104 .fd_base
= 0x71400000,
1105 .counter_base
= 0x71d00000,
1106 .intctl_base
= 0x71e00000,
1107 .idreg_base
= 0x78000000,
1108 .dma_base
= 0x78400000,
1109 .esp_base
= 0x78800000,
1110 .le_base
= 0x78c00000,
1111 .apc_base
= 0x6a000000,
1112 .afx_base
= 0x6e000000,
1113 .aux1_base
= 0x71900000,
1114 .aux2_base
= 0x71910000,
1115 .nvram_machine_id
= 0x80,
1116 .machine_id
= ss5_id
,
1117 .iommu_version
= 0x05000000,
1118 .max_mem
= 0x10000000,
1122 .iommu_base
= 0xfe0000000ULL
,
1123 .tcx_base
= 0xe20000000ULL
,
1124 .slavio_base
= 0xff0000000ULL
,
1125 .ms_kb_base
= 0xff1000000ULL
,
1126 .serial_base
= 0xff1100000ULL
,
1127 .nvram_base
= 0xff1200000ULL
,
1128 .fd_base
= 0xff1700000ULL
,
1129 .counter_base
= 0xff1300000ULL
,
1130 .intctl_base
= 0xff1400000ULL
,
1131 .idreg_base
= 0xef0000000ULL
,
1132 .dma_base
= 0xef0400000ULL
,
1133 .esp_base
= 0xef0800000ULL
,
1134 .le_base
= 0xef0c00000ULL
,
1135 .apc_base
= 0xefa000000ULL
, // XXX should not exist
1136 .aux1_base
= 0xff1800000ULL
,
1137 .aux2_base
= 0xff1a01000ULL
,
1138 .ecc_base
= 0xf00000000ULL
,
1139 .ecc_version
= 0x10000000, // version 0, implementation 1
1140 .nvram_machine_id
= 0x72,
1141 .machine_id
= ss10_id
,
1142 .iommu_version
= 0x03000000,
1143 .max_mem
= 0xf00000000ULL
,
1147 .iommu_base
= 0xfe0000000ULL
,
1148 .tcx_base
= 0xe20000000ULL
,
1149 .slavio_base
= 0xff0000000ULL
,
1150 .ms_kb_base
= 0xff1000000ULL
,
1151 .serial_base
= 0xff1100000ULL
,
1152 .nvram_base
= 0xff1200000ULL
,
1153 .counter_base
= 0xff1300000ULL
,
1154 .intctl_base
= 0xff1400000ULL
,
1155 .dma_base
= 0xef0081000ULL
,
1156 .esp_base
= 0xef0080000ULL
,
1157 .le_base
= 0xef0060000ULL
,
1158 .apc_base
= 0xefa000000ULL
, // XXX should not exist
1159 .aux1_base
= 0xff1800000ULL
,
1160 .aux2_base
= 0xff1a01000ULL
, // XXX should not exist
1161 .ecc_base
= 0xf00000000ULL
,
1162 .ecc_version
= 0x00000000, // version 0, implementation 0
1163 .nvram_machine_id
= 0x71,
1164 .machine_id
= ss600mp_id
,
1165 .iommu_version
= 0x01000000,
1166 .max_mem
= 0xf00000000ULL
,
1170 .iommu_base
= 0xfe0000000ULL
,
1171 .tcx_base
= 0xe20000000ULL
,
1172 .slavio_base
= 0xff0000000ULL
,
1173 .ms_kb_base
= 0xff1000000ULL
,
1174 .serial_base
= 0xff1100000ULL
,
1175 .nvram_base
= 0xff1200000ULL
,
1176 .fd_base
= 0xff1700000ULL
,
1177 .counter_base
= 0xff1300000ULL
,
1178 .intctl_base
= 0xff1400000ULL
,
1179 .idreg_base
= 0xef0000000ULL
,
1180 .dma_base
= 0xef0400000ULL
,
1181 .esp_base
= 0xef0800000ULL
,
1182 .le_base
= 0xef0c00000ULL
,
1183 .bpp_base
= 0xef4800000ULL
,
1184 .apc_base
= 0xefa000000ULL
, // XXX should not exist
1185 .aux1_base
= 0xff1800000ULL
,
1186 .aux2_base
= 0xff1a01000ULL
,
1187 .dbri_base
= 0xee0000000ULL
,
1188 .sx_base
= 0xf80000000ULL
,
1191 .reg_base
= 0x9c000000ULL
,
1192 .vram_base
= 0xfc000000ULL
1194 .reg_base
= 0x90000000ULL
,
1195 .vram_base
= 0xf0000000ULL
1197 .reg_base
= 0x94000000ULL
1199 .reg_base
= 0x98000000ULL
1202 .ecc_base
= 0xf00000000ULL
,
1203 .ecc_version
= 0x20000000, // version 0, implementation 2
1204 .nvram_machine_id
= 0x72,
1205 .machine_id
= ss20_id
,
1206 .iommu_version
= 0x13000000,
1207 .max_mem
= 0xf00000000ULL
,
1211 .iommu_base
= 0x10000000,
1212 .tcx_base
= 0x50000000,
1213 .slavio_base
= 0x70000000,
1214 .ms_kb_base
= 0x71000000,
1215 .serial_base
= 0x71100000,
1216 .nvram_base
= 0x71200000,
1217 .fd_base
= 0x71400000,
1218 .counter_base
= 0x71d00000,
1219 .intctl_base
= 0x71e00000,
1220 .idreg_base
= 0x78000000,
1221 .dma_base
= 0x78400000,
1222 .esp_base
= 0x78800000,
1223 .le_base
= 0x78c00000,
1224 .apc_base
= 0x71300000, // pmc
1225 .aux1_base
= 0x71900000,
1226 .aux2_base
= 0x71910000,
1227 .nvram_machine_id
= 0x80,
1228 .machine_id
= vger_id
,
1229 .iommu_version
= 0x05000000,
1230 .max_mem
= 0x10000000,
1234 .iommu_base
= 0x10000000,
1235 .iommu_pad_base
= 0x10004000,
1236 .iommu_pad_len
= 0x0fffb000,
1237 .tcx_base
= 0x50000000,
1238 .slavio_base
= 0x70000000,
1239 .ms_kb_base
= 0x71000000,
1240 .serial_base
= 0x71100000,
1241 .nvram_base
= 0x71200000,
1242 .fd_base
= 0x71400000,
1243 .counter_base
= 0x71d00000,
1244 .intctl_base
= 0x71e00000,
1245 .idreg_base
= 0x78000000,
1246 .dma_base
= 0x78400000,
1247 .esp_base
= 0x78800000,
1248 .le_base
= 0x78c00000,
1249 .aux1_base
= 0x71900000,
1250 .aux2_base
= 0x71910000,
1251 .nvram_machine_id
= 0x80,
1252 .machine_id
= lx_id
,
1253 .iommu_version
= 0x04000000,
1254 .max_mem
= 0x10000000,
1258 .iommu_base
= 0x10000000,
1259 .tcx_base
= 0x50000000,
1260 .cs_base
= 0x6c000000,
1261 .slavio_base
= 0x70000000,
1262 .ms_kb_base
= 0x71000000,
1263 .serial_base
= 0x71100000,
1264 .nvram_base
= 0x71200000,
1265 .fd_base
= 0x71400000,
1266 .counter_base
= 0x71d00000,
1267 .intctl_base
= 0x71e00000,
1268 .idreg_base
= 0x78000000,
1269 .dma_base
= 0x78400000,
1270 .esp_base
= 0x78800000,
1271 .le_base
= 0x78c00000,
1272 .apc_base
= 0x6a000000,
1273 .aux1_base
= 0x71900000,
1274 .aux2_base
= 0x71910000,
1275 .nvram_machine_id
= 0x80,
1276 .machine_id
= ss4_id
,
1277 .iommu_version
= 0x05000000,
1278 .max_mem
= 0x10000000,
1282 .iommu_base
= 0x10000000,
1283 .tcx_base
= 0x50000000,
1284 .slavio_base
= 0x70000000,
1285 .ms_kb_base
= 0x71000000,
1286 .serial_base
= 0x71100000,
1287 .nvram_base
= 0x71200000,
1288 .fd_base
= 0x71400000,
1289 .counter_base
= 0x71d00000,
1290 .intctl_base
= 0x71e00000,
1291 .idreg_base
= 0x78000000,
1292 .dma_base
= 0x78400000,
1293 .esp_base
= 0x78800000,
1294 .le_base
= 0x78c00000,
1295 .apc_base
= 0x6a000000,
1296 .aux1_base
= 0x71900000,
1297 .aux2_base
= 0x71910000,
1298 .nvram_machine_id
= 0x80,
1299 .machine_id
= scls_id
,
1300 .iommu_version
= 0x05000000,
1301 .max_mem
= 0x10000000,
1305 .iommu_base
= 0x10000000,
1306 .tcx_base
= 0x50000000, // XXX
1307 .slavio_base
= 0x70000000,
1308 .ms_kb_base
= 0x71000000,
1309 .serial_base
= 0x71100000,
1310 .nvram_base
= 0x71200000,
1311 .fd_base
= 0x71400000,
1312 .counter_base
= 0x71d00000,
1313 .intctl_base
= 0x71e00000,
1314 .idreg_base
= 0x78000000,
1315 .dma_base
= 0x78400000,
1316 .esp_base
= 0x78800000,
1317 .le_base
= 0x78c00000,
1318 .apc_base
= 0x6a000000,
1319 .aux1_base
= 0x71900000,
1320 .aux2_base
= 0x71910000,
1321 .nvram_machine_id
= 0x80,
1322 .machine_id
= sbook_id
,
1323 .iommu_version
= 0x05000000,
1324 .max_mem
= 0x10000000,
1328 /* SPARCstation 5 hardware initialisation */
1329 static void ss5_init(MachineState
*machine
)
1331 sun4m_hw_init(&sun4m_hwdefs
[0], machine
);
1334 /* SPARCstation 10 hardware initialisation */
1335 static void ss10_init(MachineState
*machine
)
1337 sun4m_hw_init(&sun4m_hwdefs
[1], machine
);
1340 /* SPARCserver 600MP hardware initialisation */
1341 static void ss600mp_init(MachineState
*machine
)
1343 sun4m_hw_init(&sun4m_hwdefs
[2], machine
);
1346 /* SPARCstation 20 hardware initialisation */
1347 static void ss20_init(MachineState
*machine
)
1349 sun4m_hw_init(&sun4m_hwdefs
[3], machine
);
1352 /* SPARCstation Voyager hardware initialisation */
1353 static void vger_init(MachineState
*machine
)
1355 sun4m_hw_init(&sun4m_hwdefs
[4], machine
);
1358 /* SPARCstation LX hardware initialisation */
1359 static void ss_lx_init(MachineState
*machine
)
1361 sun4m_hw_init(&sun4m_hwdefs
[5], machine
);
1364 /* SPARCstation 4 hardware initialisation */
1365 static void ss4_init(MachineState
*machine
)
1367 sun4m_hw_init(&sun4m_hwdefs
[6], machine
);
1370 /* SPARCClassic hardware initialisation */
1371 static void scls_init(MachineState
*machine
)
1373 sun4m_hw_init(&sun4m_hwdefs
[7], machine
);
1376 /* SPARCbook hardware initialisation */
1377 static void sbook_init(MachineState
*machine
)
1379 sun4m_hw_init(&sun4m_hwdefs
[8], machine
);
1382 static void ss5_class_init(ObjectClass
*oc
, void *data
)
1384 MachineClass
*mc
= MACHINE_CLASS(oc
);
1386 mc
->desc
= "Sun4m platform, SPARCstation 5";
1387 mc
->init
= ss5_init
;
1388 mc
->block_default_type
= IF_SCSI
;
1390 mc
->default_boot_order
= "c";
1391 mc
->default_cpu_type
= SPARC_CPU_TYPE_NAME("Fujitsu-MB86904");
1394 static const TypeInfo ss5_type
= {
1395 .name
= MACHINE_TYPE_NAME("SS-5"),
1396 .parent
= TYPE_MACHINE
,
1397 .class_init
= ss5_class_init
,
1400 static void ss10_class_init(ObjectClass
*oc
, void *data
)
1402 MachineClass
*mc
= MACHINE_CLASS(oc
);
1404 mc
->desc
= "Sun4m platform, SPARCstation 10";
1405 mc
->init
= ss10_init
;
1406 mc
->block_default_type
= IF_SCSI
;
1408 mc
->default_boot_order
= "c";
1409 mc
->default_cpu_type
= SPARC_CPU_TYPE_NAME("TI-SuperSparc-II");
1412 static const TypeInfo ss10_type
= {
1413 .name
= MACHINE_TYPE_NAME("SS-10"),
1414 .parent
= TYPE_MACHINE
,
1415 .class_init
= ss10_class_init
,
1418 static void ss600mp_class_init(ObjectClass
*oc
, void *data
)
1420 MachineClass
*mc
= MACHINE_CLASS(oc
);
1422 mc
->desc
= "Sun4m platform, SPARCserver 600MP";
1423 mc
->init
= ss600mp_init
;
1424 mc
->block_default_type
= IF_SCSI
;
1426 mc
->default_boot_order
= "c";
1427 mc
->default_cpu_type
= SPARC_CPU_TYPE_NAME("TI-SuperSparc-II");
1430 static const TypeInfo ss600mp_type
= {
1431 .name
= MACHINE_TYPE_NAME("SS-600MP"),
1432 .parent
= TYPE_MACHINE
,
1433 .class_init
= ss600mp_class_init
,
1436 static void ss20_class_init(ObjectClass
*oc
, void *data
)
1438 MachineClass
*mc
= MACHINE_CLASS(oc
);
1440 mc
->desc
= "Sun4m platform, SPARCstation 20";
1441 mc
->init
= ss20_init
;
1442 mc
->block_default_type
= IF_SCSI
;
1444 mc
->default_boot_order
= "c";
1445 mc
->default_cpu_type
= SPARC_CPU_TYPE_NAME("TI-SuperSparc-II");
1448 static const TypeInfo ss20_type
= {
1449 .name
= MACHINE_TYPE_NAME("SS-20"),
1450 .parent
= TYPE_MACHINE
,
1451 .class_init
= ss20_class_init
,
1454 static void voyager_class_init(ObjectClass
*oc
, void *data
)
1456 MachineClass
*mc
= MACHINE_CLASS(oc
);
1458 mc
->desc
= "Sun4m platform, SPARCstation Voyager";
1459 mc
->init
= vger_init
;
1460 mc
->block_default_type
= IF_SCSI
;
1461 mc
->default_boot_order
= "c";
1462 mc
->default_cpu_type
= SPARC_CPU_TYPE_NAME("Fujitsu-MB86904");
1465 static const TypeInfo voyager_type
= {
1466 .name
= MACHINE_TYPE_NAME("Voyager"),
1467 .parent
= TYPE_MACHINE
,
1468 .class_init
= voyager_class_init
,
1471 static void ss_lx_class_init(ObjectClass
*oc
, void *data
)
1473 MachineClass
*mc
= MACHINE_CLASS(oc
);
1475 mc
->desc
= "Sun4m platform, SPARCstation LX";
1476 mc
->init
= ss_lx_init
;
1477 mc
->block_default_type
= IF_SCSI
;
1478 mc
->default_boot_order
= "c";
1479 mc
->default_cpu_type
= SPARC_CPU_TYPE_NAME("TI-MicroSparc-I");
1482 static const TypeInfo ss_lx_type
= {
1483 .name
= MACHINE_TYPE_NAME("LX"),
1484 .parent
= TYPE_MACHINE
,
1485 .class_init
= ss_lx_class_init
,
1488 static void ss4_class_init(ObjectClass
*oc
, void *data
)
1490 MachineClass
*mc
= MACHINE_CLASS(oc
);
1492 mc
->desc
= "Sun4m platform, SPARCstation 4";
1493 mc
->init
= ss4_init
;
1494 mc
->block_default_type
= IF_SCSI
;
1495 mc
->default_boot_order
= "c";
1496 mc
->default_cpu_type
= SPARC_CPU_TYPE_NAME("Fujitsu-MB86904");
1499 static const TypeInfo ss4_type
= {
1500 .name
= MACHINE_TYPE_NAME("SS-4"),
1501 .parent
= TYPE_MACHINE
,
1502 .class_init
= ss4_class_init
,
1505 static void scls_class_init(ObjectClass
*oc
, void *data
)
1507 MachineClass
*mc
= MACHINE_CLASS(oc
);
1509 mc
->desc
= "Sun4m platform, SPARCClassic";
1510 mc
->init
= scls_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");
1516 static const TypeInfo scls_type
= {
1517 .name
= MACHINE_TYPE_NAME("SPARCClassic"),
1518 .parent
= TYPE_MACHINE
,
1519 .class_init
= scls_class_init
,
1522 static void sbook_class_init(ObjectClass
*oc
, void *data
)
1524 MachineClass
*mc
= MACHINE_CLASS(oc
);
1526 mc
->desc
= "Sun4m platform, SPARCbook";
1527 mc
->init
= sbook_init
;
1528 mc
->block_default_type
= IF_SCSI
;
1529 mc
->default_boot_order
= "c";
1530 mc
->default_cpu_type
= SPARC_CPU_TYPE_NAME("TI-MicroSparc-I");
1533 static const TypeInfo sbook_type
= {
1534 .name
= MACHINE_TYPE_NAME("SPARCbook"),
1535 .parent
= TYPE_MACHINE
,
1536 .class_init
= sbook_class_init
,
1539 static void sun4m_register_types(void)
1541 type_register_static(&idreg_info
);
1542 type_register_static(&afx_info
);
1543 type_register_static(&prom_info
);
1544 type_register_static(&ram_info
);
1546 type_register_static(&ss5_type
);
1547 type_register_static(&ss10_type
);
1548 type_register_static(&ss600mp_type
);
1549 type_register_static(&ss20_type
);
1550 type_register_static(&voyager_type
);
1551 type_register_static(&ss_lx_type
);
1552 type_register_static(&ss4_type
);
1553 type_register_static(&scls_type
);
1554 type_register_static(&sbook_type
);
1557 type_init(sun4m_register_types
)