153018216SPaolo Bonzini /*
253018216SPaolo Bonzini * QEMU Sun4m & Sun4d & Sun4c System Emulator
353018216SPaolo Bonzini *
453018216SPaolo Bonzini * Copyright (c) 2003-2005 Fabrice Bellard
553018216SPaolo Bonzini *
653018216SPaolo Bonzini * Permission is hereby granted, free of charge, to any person obtaining a copy
753018216SPaolo Bonzini * of this software and associated documentation files (the "Software"), to deal
853018216SPaolo Bonzini * in the Software without restriction, including without limitation the rights
953018216SPaolo Bonzini * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1053018216SPaolo Bonzini * copies of the Software, and to permit persons to whom the Software is
1153018216SPaolo Bonzini * furnished to do so, subject to the following conditions:
1253018216SPaolo Bonzini *
1353018216SPaolo Bonzini * The above copyright notice and this permission notice shall be included in
1453018216SPaolo Bonzini * all copies or substantial portions of the Software.
1553018216SPaolo Bonzini *
1653018216SPaolo Bonzini * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1753018216SPaolo Bonzini * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1853018216SPaolo Bonzini * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1953018216SPaolo Bonzini * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2053018216SPaolo Bonzini * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2153018216SPaolo Bonzini * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2253018216SPaolo Bonzini * THE SOFTWARE.
2353018216SPaolo Bonzini */
2471e8a915SMarkus Armbruster
25db5ebe5fSPeter Maydell #include "qemu/osdep.h"
260a2e467bSPhilippe Mathieu-Daudé #include "qemu/units.h"
27da34e65cSMarkus Armbruster #include "qapi/error.h"
282c65db5eSPaolo Bonzini #include "qemu/datadir.h"
294771d756SPaolo Bonzini #include "cpu.h"
3053018216SPaolo Bonzini #include "hw/sysbus.h"
31af87bf29SMark Cave-Ayland #include "qemu/error-report.h"
3253018216SPaolo Bonzini #include "qemu/timer.h"
331527f488SMark Cave-Ayland #include "hw/sparc/sun4m_iommu.h"
34819ce6b2SPhilippe Mathieu-Daudé #include "hw/rtc/m48t59.h"
35d6454270SMarkus Armbruster #include "migration/vmstate.h"
360d09e41aSPaolo Bonzini #include "hw/sparc/sparc32_dma.h"
370d09e41aSPaolo Bonzini #include "hw/block/fdc.h"
3871e8a915SMarkus Armbruster #include "sysemu/reset.h"
3954d31236SMarkus Armbruster #include "sysemu/runstate.h"
4053018216SPaolo Bonzini #include "sysemu/sysemu.h"
4153018216SPaolo Bonzini #include "net/net.h"
4253018216SPaolo Bonzini #include "hw/boards.h"
430d09e41aSPaolo Bonzini #include "hw/scsi/esp.h"
44c6363baeSThomas Huth #include "hw/nvram/sun_nvram.h"
45a27bd6c7SMarkus Armbruster #include "hw/qdev-properties.h"
462024c014SThomas Huth #include "hw/nvram/chrp_nvram.h"
470d09e41aSPaolo Bonzini #include "hw/nvram/fw_cfg.h"
480d09e41aSPaolo Bonzini #include "hw/char/escc.h"
496007523aSPhilippe Mathieu-Daudé #include "hw/misc/empty_slot.h"
50077f0f3dSPhilippe Mathieu-Daudé #include "hw/misc/unimp.h"
5164552b6bSMarkus Armbruster #include "hw/irq.h"
52a879306cSMark Cave-Ayland #include "hw/or-irq.h"
5353018216SPaolo Bonzini #include "hw/loader.h"
5453018216SPaolo Bonzini #include "elf.h"
5553018216SPaolo Bonzini #include "trace.h"
56db1015e9SEduardo Habkost #include "qom/object.h"
5753018216SPaolo Bonzini
5853018216SPaolo Bonzini /*
5953018216SPaolo Bonzini * Sun4m architecture was used in the following machines:
6053018216SPaolo Bonzini *
6153018216SPaolo Bonzini * SPARCserver 6xxMP/xx
6253018216SPaolo Bonzini * SPARCclassic (SPARCclassic Server)(SPARCstation LC) (4/15),
6353018216SPaolo Bonzini * SPARCclassic X (4/10)
6453018216SPaolo Bonzini * SPARCstation LX/ZX (4/30)
6553018216SPaolo Bonzini * SPARCstation Voyager
6653018216SPaolo Bonzini * SPARCstation 10/xx, SPARCserver 10/xx
6753018216SPaolo Bonzini * SPARCstation 5, SPARCserver 5
6853018216SPaolo Bonzini * SPARCstation 20/xx, SPARCserver 20
6953018216SPaolo Bonzini * SPARCstation 4
7053018216SPaolo Bonzini *
7153018216SPaolo Bonzini * See for example: http://www.sunhelp.org/faq/sunref1.html
7253018216SPaolo Bonzini */
7353018216SPaolo Bonzini
7453018216SPaolo Bonzini #define KERNEL_LOAD_ADDR 0x00004000
7553018216SPaolo Bonzini #define CMDLINE_ADDR 0x007ff000
7653018216SPaolo Bonzini #define INITRD_LOAD_ADDR 0x00800000
770a2e467bSPhilippe Mathieu-Daudé #define PROM_SIZE_MAX (1 * MiB)
7853018216SPaolo Bonzini #define PROM_VADDR 0xffd00000
7953018216SPaolo Bonzini #define PROM_FILENAME "openbios-sparc32"
8053018216SPaolo Bonzini #define CFG_ADDR 0xd00000510ULL
8153018216SPaolo Bonzini #define FW_CFG_SUN4M_DEPTH (FW_CFG_ARCH_LOCAL + 0x00)
82b96919e0SMark Cave-Ayland #define FW_CFG_SUN4M_WIDTH (FW_CFG_ARCH_LOCAL + 0x01)
83b96919e0SMark Cave-Ayland #define FW_CFG_SUN4M_HEIGHT (FW_CFG_ARCH_LOCAL + 0x02)
8453018216SPaolo Bonzini
8553018216SPaolo Bonzini #define MAX_CPUS 16
8653018216SPaolo Bonzini #define MAX_PILS 16
8753018216SPaolo Bonzini #define MAX_VSIMMS 4
8853018216SPaolo Bonzini
8953018216SPaolo Bonzini #define ESCC_CLOCK 4915200
9053018216SPaolo Bonzini
9153018216SPaolo Bonzini struct sun4m_hwdef {
9253018216SPaolo Bonzini hwaddr iommu_base, iommu_pad_base, iommu_pad_len, slavio_base;
9353018216SPaolo Bonzini hwaddr intctl_base, counter_base, nvram_base, ms_kb_base;
9453018216SPaolo Bonzini hwaddr serial_base, fd_base;
9553018216SPaolo Bonzini hwaddr afx_base, idreg_base, dma_base, esp_base, le_base;
9653018216SPaolo Bonzini hwaddr tcx_base, cs_base, apc_base, aux1_base, aux2_base;
9753018216SPaolo Bonzini hwaddr bpp_base, dbri_base, sx_base;
9853018216SPaolo Bonzini struct {
9953018216SPaolo Bonzini hwaddr reg_base, vram_base;
10053018216SPaolo Bonzini } vsimm[MAX_VSIMMS];
10153018216SPaolo Bonzini hwaddr ecc_base;
10253018216SPaolo Bonzini uint64_t max_mem;
10353018216SPaolo Bonzini uint32_t ecc_version;
10453018216SPaolo Bonzini uint32_t iommu_version;
10553018216SPaolo Bonzini uint16_t machine_id;
10653018216SPaolo Bonzini uint8_t nvram_machine_id;
10753018216SPaolo Bonzini };
10853018216SPaolo Bonzini
10995bc47deSPhilippe Mathieu-Daudé struct Sun4mMachineClass {
11095bc47deSPhilippe Mathieu-Daudé /*< private >*/
11195bc47deSPhilippe Mathieu-Daudé MachineClass parent_obj;
11295bc47deSPhilippe Mathieu-Daudé /*< public >*/
11395bc47deSPhilippe Mathieu-Daudé const struct sun4m_hwdef *hwdef;
11495bc47deSPhilippe Mathieu-Daudé };
11595bc47deSPhilippe Mathieu-Daudé typedef struct Sun4mMachineClass Sun4mMachineClass;
11695bc47deSPhilippe Mathieu-Daudé
117828d01b7SPhilippe Mathieu-Daudé #define TYPE_SUN4M_MACHINE MACHINE_TYPE_NAME("sun4m-common")
DECLARE_CLASS_CHECKERS(Sun4mMachineClass,SUN4M_MACHINE,TYPE_SUN4M_MACHINE)11895bc47deSPhilippe Mathieu-Daudé DECLARE_CLASS_CHECKERS(Sun4mMachineClass, SUN4M_MACHINE, TYPE_SUN4M_MACHINE)
119828d01b7SPhilippe Mathieu-Daudé
120d5a42d19SPhilippe Mathieu-Daudé const char *fw_cfg_arch_key_name(uint16_t key)
121d5a42d19SPhilippe Mathieu-Daudé {
122d5a42d19SPhilippe Mathieu-Daudé static const struct {
123d5a42d19SPhilippe Mathieu-Daudé uint16_t key;
124d5a42d19SPhilippe Mathieu-Daudé const char *name;
125d5a42d19SPhilippe Mathieu-Daudé } fw_cfg_arch_wellknown_keys[] = {
126d5a42d19SPhilippe Mathieu-Daudé {FW_CFG_SUN4M_DEPTH, "depth"},
127d5a42d19SPhilippe Mathieu-Daudé {FW_CFG_SUN4M_WIDTH, "width"},
128d5a42d19SPhilippe Mathieu-Daudé {FW_CFG_SUN4M_HEIGHT, "height"},
129d5a42d19SPhilippe Mathieu-Daudé };
130d5a42d19SPhilippe Mathieu-Daudé
131d5a42d19SPhilippe Mathieu-Daudé for (size_t i = 0; i < ARRAY_SIZE(fw_cfg_arch_wellknown_keys); i++) {
132d5a42d19SPhilippe Mathieu-Daudé if (fw_cfg_arch_wellknown_keys[i].key == key) {
133d5a42d19SPhilippe Mathieu-Daudé return fw_cfg_arch_wellknown_keys[i].name;
134d5a42d19SPhilippe Mathieu-Daudé }
135d5a42d19SPhilippe Mathieu-Daudé }
136d5a42d19SPhilippe Mathieu-Daudé return NULL;
137d5a42d19SPhilippe Mathieu-Daudé }
138d5a42d19SPhilippe Mathieu-Daudé
fw_cfg_boot_set(void * opaque,const char * boot_device,Error ** errp)139ddcd5531SGonglei static void fw_cfg_boot_set(void *opaque, const char *boot_device,
140ddcd5531SGonglei Error **errp)
14153018216SPaolo Bonzini {
14248779e50SGabriel L. Somlo fw_cfg_modify_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]);
14353018216SPaolo Bonzini }
14453018216SPaolo Bonzini
nvram_init(Nvram * nvram,uint8_t * macaddr,const char * cmdline,const char * boot_devices,ram_addr_t RAM_size,uint32_t kernel_size,int width,int height,int depth,int nvram_machine_id,const char * arch)14531688246SHervé Poussineau static void nvram_init(Nvram *nvram, uint8_t *macaddr,
14653018216SPaolo Bonzini const char *cmdline, const char *boot_devices,
14753018216SPaolo Bonzini ram_addr_t RAM_size, uint32_t kernel_size,
14853018216SPaolo Bonzini int width, int height, int depth,
14953018216SPaolo Bonzini int nvram_machine_id, const char *arch)
15053018216SPaolo Bonzini {
15153018216SPaolo Bonzini unsigned int i;
1522024c014SThomas Huth int sysp_end;
15353018216SPaolo Bonzini uint8_t image[0x1ff0];
15431688246SHervé Poussineau NvramClass *k = NVRAM_GET_CLASS(nvram);
15553018216SPaolo Bonzini
15653018216SPaolo Bonzini memset(image, '\0', sizeof(image));
15753018216SPaolo Bonzini
1582024c014SThomas Huth /* OpenBIOS nvram variables partition */
15937035df5SGreg Kurz sysp_end = chrp_nvram_create_system_partition(image, 0, 0x1fd0);
16053018216SPaolo Bonzini
1612024c014SThomas Huth /* Free space partition */
1622024c014SThomas Huth chrp_nvram_create_free_partition(&image[sysp_end], 0x1fd0 - sysp_end);
16353018216SPaolo Bonzini
16453018216SPaolo Bonzini Sun_init_header((struct Sun_nvram *)&image[0x1fd8], macaddr,
16553018216SPaolo Bonzini nvram_machine_id);
16653018216SPaolo Bonzini
16731688246SHervé Poussineau for (i = 0; i < sizeof(image); i++) {
16831688246SHervé Poussineau (k->write)(nvram, i, image[i]);
16931688246SHervé Poussineau }
17053018216SPaolo Bonzini }
17153018216SPaolo Bonzini
cpu_kick_irq(SPARCCPU * cpu)17253018216SPaolo Bonzini static void cpu_kick_irq(SPARCCPU *cpu)
17353018216SPaolo Bonzini {
17453018216SPaolo Bonzini CPUSPARCState *env = &cpu->env;
175259186a7SAndreas Färber CPUState *cs = CPU(cpu);
17653018216SPaolo Bonzini
177259186a7SAndreas Färber cs->halted = 0;
17853018216SPaolo Bonzini cpu_check_irqs(env);
179259186a7SAndreas Färber qemu_cpu_kick(cs);
18053018216SPaolo Bonzini }
18153018216SPaolo Bonzini
cpu_set_irq(void * opaque,int irq,int level)18253018216SPaolo Bonzini static void cpu_set_irq(void *opaque, int irq, int level)
18353018216SPaolo Bonzini {
18453018216SPaolo Bonzini SPARCCPU *cpu = opaque;
18553018216SPaolo Bonzini CPUSPARCState *env = &cpu->env;
18653018216SPaolo Bonzini
18753018216SPaolo Bonzini if (level) {
18853018216SPaolo Bonzini trace_sun4m_cpu_set_irq_raise(irq);
18953018216SPaolo Bonzini env->pil_in |= 1 << irq;
19053018216SPaolo Bonzini cpu_kick_irq(cpu);
19153018216SPaolo Bonzini } else {
19253018216SPaolo Bonzini trace_sun4m_cpu_set_irq_lower(irq);
19353018216SPaolo Bonzini env->pil_in &= ~(1 << irq);
19453018216SPaolo Bonzini cpu_check_irqs(env);
19553018216SPaolo Bonzini }
19653018216SPaolo Bonzini }
19753018216SPaolo Bonzini
dummy_cpu_set_irq(void * opaque,int irq,int level)19853018216SPaolo Bonzini static void dummy_cpu_set_irq(void *opaque, int irq, int level)
19953018216SPaolo Bonzini {
20053018216SPaolo Bonzini }
20153018216SPaolo Bonzini
sun4m_cpu_reset(void * opaque)20224f675cdSThiago Jung Bauermann static void sun4m_cpu_reset(void *opaque)
20353018216SPaolo Bonzini {
20453018216SPaolo Bonzini SPARCCPU *cpu = opaque;
205259186a7SAndreas Färber CPUState *cs = CPU(cpu);
20653018216SPaolo Bonzini
207259186a7SAndreas Färber cpu_reset(cs);
20853018216SPaolo Bonzini }
20953018216SPaolo Bonzini
cpu_halt_signal(void * opaque,int irq,int level)21053018216SPaolo Bonzini static void cpu_halt_signal(void *opaque, int irq, int level)
21153018216SPaolo Bonzini {
2124917cf44SAndreas Färber if (level && current_cpu) {
2134917cf44SAndreas Färber cpu_interrupt(current_cpu, CPU_INTERRUPT_HALT);
214c3affe56SAndreas Färber }
21553018216SPaolo Bonzini }
21653018216SPaolo Bonzini
translate_kernel_address(void * opaque,uint64_t addr)21753018216SPaolo Bonzini static uint64_t translate_kernel_address(void *opaque, uint64_t addr)
21853018216SPaolo Bonzini {
21953018216SPaolo Bonzini return addr - 0xf0000000ULL;
22053018216SPaolo Bonzini }
22153018216SPaolo Bonzini
sun4m_load_kernel(const char * kernel_filename,const char * initrd_filename,ram_addr_t RAM_size,uint32_t * initrd_size)22253018216SPaolo Bonzini static unsigned long sun4m_load_kernel(const char *kernel_filename,
22353018216SPaolo Bonzini const char *initrd_filename,
2246031ff8bSMark Cave-Ayland ram_addr_t RAM_size,
2256031ff8bSMark Cave-Ayland uint32_t *initrd_size)
22653018216SPaolo Bonzini {
22753018216SPaolo Bonzini int linux_boot;
22853018216SPaolo Bonzini unsigned int i;
2296031ff8bSMark Cave-Ayland long kernel_size;
23053018216SPaolo Bonzini uint8_t *ptr;
23153018216SPaolo Bonzini
23253018216SPaolo Bonzini linux_boot = (kernel_filename != NULL);
23353018216SPaolo Bonzini
23453018216SPaolo Bonzini kernel_size = 0;
23553018216SPaolo Bonzini if (linux_boot) {
23653018216SPaolo Bonzini int bswap_needed;
23753018216SPaolo Bonzini
23853018216SPaolo Bonzini #ifdef BSWAP_NEEDED
23953018216SPaolo Bonzini bswap_needed = 1;
24053018216SPaolo Bonzini #else
24153018216SPaolo Bonzini bswap_needed = 0;
24253018216SPaolo Bonzini #endif
2434366e1dbSLiam Merwick kernel_size = load_elf(kernel_filename, NULL,
2444366e1dbSLiam Merwick translate_kernel_address, NULL,
2456cdda0ffSAleksandar Markovic NULL, NULL, NULL, NULL, 1, EM_SPARC, 0, 0);
24653018216SPaolo Bonzini if (kernel_size < 0)
24753018216SPaolo Bonzini kernel_size = load_aout(kernel_filename, KERNEL_LOAD_ADDR,
24853018216SPaolo Bonzini RAM_size - KERNEL_LOAD_ADDR, bswap_needed,
24953018216SPaolo Bonzini TARGET_PAGE_SIZE);
25053018216SPaolo Bonzini if (kernel_size < 0)
25153018216SPaolo Bonzini kernel_size = load_image_targphys(kernel_filename,
25253018216SPaolo Bonzini KERNEL_LOAD_ADDR,
25353018216SPaolo Bonzini RAM_size - KERNEL_LOAD_ADDR);
25453018216SPaolo Bonzini if (kernel_size < 0) {
25529bd7231SAlistair Francis error_report("could not load kernel '%s'", kernel_filename);
25653018216SPaolo Bonzini exit(1);
25753018216SPaolo Bonzini }
25853018216SPaolo Bonzini
25953018216SPaolo Bonzini /* load initrd */
2606031ff8bSMark Cave-Ayland *initrd_size = 0;
26153018216SPaolo Bonzini if (initrd_filename) {
2626031ff8bSMark Cave-Ayland *initrd_size = load_image_targphys(initrd_filename,
26353018216SPaolo Bonzini INITRD_LOAD_ADDR,
26453018216SPaolo Bonzini RAM_size - INITRD_LOAD_ADDR);
2656031ff8bSMark Cave-Ayland if ((int)*initrd_size < 0) {
26629bd7231SAlistair Francis error_report("could not load initial ram disk '%s'",
26753018216SPaolo Bonzini initrd_filename);
26853018216SPaolo Bonzini exit(1);
26953018216SPaolo Bonzini }
27053018216SPaolo Bonzini }
2716031ff8bSMark Cave-Ayland if (*initrd_size > 0) {
27253018216SPaolo Bonzini for (i = 0; i < 64 * TARGET_PAGE_SIZE; i += TARGET_PAGE_SIZE) {
2730f0f8b61SThomas Huth ptr = rom_ptr(KERNEL_LOAD_ADDR + i, 24);
2740f0f8b61SThomas Huth if (ptr && ldl_p(ptr) == 0x48647253) { /* HdrS */
27553018216SPaolo Bonzini stl_p(ptr + 16, INITRD_LOAD_ADDR);
2766031ff8bSMark Cave-Ayland stl_p(ptr + 20, *initrd_size);
27753018216SPaolo Bonzini break;
27853018216SPaolo Bonzini }
27953018216SPaolo Bonzini }
28053018216SPaolo Bonzini }
28153018216SPaolo Bonzini }
28253018216SPaolo Bonzini return kernel_size;
28353018216SPaolo Bonzini }
28453018216SPaolo Bonzini
iommu_init(hwaddr addr,uint32_t version,qemu_irq irq)28553018216SPaolo Bonzini static void *iommu_init(hwaddr addr, uint32_t version, qemu_irq irq)
28653018216SPaolo Bonzini {
28753018216SPaolo Bonzini DeviceState *dev;
28853018216SPaolo Bonzini SysBusDevice *s;
28953018216SPaolo Bonzini
2903e80f690SMarkus Armbruster dev = qdev_new(TYPE_SUN4M_IOMMU);
29153018216SPaolo Bonzini qdev_prop_set_uint32(dev, "version", version);
29253018216SPaolo Bonzini s = SYS_BUS_DEVICE(dev);
2933c6ef471SMarkus Armbruster sysbus_realize_and_unref(s, &error_fatal);
29453018216SPaolo Bonzini sysbus_connect_irq(s, 0, irq);
29553018216SPaolo Bonzini sysbus_mmio_map(s, 0, addr);
29653018216SPaolo Bonzini
29753018216SPaolo Bonzini return s;
29853018216SPaolo Bonzini }
29953018216SPaolo Bonzini
sparc32_dma_init(hwaddr dma_base,hwaddr esp_base,qemu_irq espdma_irq,hwaddr le_base,qemu_irq ledma_irq,MACAddr * mac)3006aa62ed6SMark Cave-Ayland static void *sparc32_dma_init(hwaddr dma_base,
3016aa62ed6SMark Cave-Ayland hwaddr esp_base, qemu_irq espdma_irq,
302ae0b175bSDavid Woodhouse hwaddr le_base, qemu_irq ledma_irq,
303ae0b175bSDavid Woodhouse MACAddr *mac)
30453018216SPaolo Bonzini {
3056aa62ed6SMark Cave-Ayland DeviceState *dma;
3066aa62ed6SMark Cave-Ayland ESPDMADeviceState *espdma;
3076aa62ed6SMark Cave-Ayland LEDMADeviceState *ledma;
3086aa62ed6SMark Cave-Ayland SysBusESPState *esp;
3096aa62ed6SMark Cave-Ayland SysBusPCNetState *lance;
310ae0b175bSDavid Woodhouse NICInfo *nd = qemu_find_nic_info("lance", true, NULL);
31153018216SPaolo Bonzini
3123e80f690SMarkus Armbruster dma = qdev_new(TYPE_SPARC32_DMA);
3136aa62ed6SMark Cave-Ayland espdma = SPARC32_ESPDMA_DEVICE(object_resolve_path_component(
3146aa62ed6SMark Cave-Ayland OBJECT(dma), "espdma"));
3156aa62ed6SMark Cave-Ayland
31684fbefedSMark Cave-Ayland esp = SYSBUS_ESP(object_resolve_path_component(OBJECT(espdma), "esp"));
3176aa62ed6SMark Cave-Ayland
3186aa62ed6SMark Cave-Ayland ledma = SPARC32_LEDMA_DEVICE(object_resolve_path_component(
3196aa62ed6SMark Cave-Ayland OBJECT(dma), "ledma"));
3206aa62ed6SMark Cave-Ayland
3216aa62ed6SMark Cave-Ayland lance = SYSBUS_PCNET(object_resolve_path_component(
3226aa62ed6SMark Cave-Ayland OBJECT(ledma), "lance"));
323ae0b175bSDavid Woodhouse
324ae0b175bSDavid Woodhouse if (nd) {
325c4210bc1SMark Cave-Ayland qdev_set_nic_properties(DEVICE(lance), nd);
326ae0b175bSDavid Woodhouse memcpy(mac->a, nd->macaddr.a, sizeof(mac->a));
327ae0b175bSDavid Woodhouse } else {
328ae0b175bSDavid Woodhouse qemu_macaddr_default_if_unset(mac);
329ae0b175bSDavid Woodhouse qdev_prop_set_macaddr(DEVICE(lance), "mac", mac->a);
330ae0b175bSDavid Woodhouse }
331c4210bc1SMark Cave-Ayland
332c4210bc1SMark Cave-Ayland sysbus_realize_and_unref(SYS_BUS_DEVICE(dma), &error_fatal);
333*73a143b3SPhilippe Mathieu-Daudé
334*73a143b3SPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(espdma), 0, espdma_irq);
335*73a143b3SPhilippe Mathieu-Daudé
336*73a143b3SPhilippe Mathieu-Daudé sysbus_connect_irq(SYS_BUS_DEVICE(ledma), 0, ledma_irq);
337*73a143b3SPhilippe Mathieu-Daudé
338c4210bc1SMark Cave-Ayland sysbus_mmio_map(SYS_BUS_DEVICE(dma), 0, dma_base);
339c4210bc1SMark Cave-Ayland
340c4210bc1SMark Cave-Ayland sysbus_mmio_map(SYS_BUS_DEVICE(esp), 0, esp_base);
341c4210bc1SMark Cave-Ayland scsi_bus_legacy_handle_cmdline(&esp->esp.bus);
342c4210bc1SMark Cave-Ayland
3436aa62ed6SMark Cave-Ayland sysbus_mmio_map(SYS_BUS_DEVICE(lance), 0, le_base);
3446aa62ed6SMark Cave-Ayland
3456aa62ed6SMark Cave-Ayland return dma;
34653018216SPaolo Bonzini }
34753018216SPaolo Bonzini
slavio_intctl_init(hwaddr addr,hwaddr addrg,qemu_irq ** parent_irq)34853018216SPaolo Bonzini static DeviceState *slavio_intctl_init(hwaddr addr,
34953018216SPaolo Bonzini hwaddr addrg,
35053018216SPaolo Bonzini qemu_irq **parent_irq)
35153018216SPaolo Bonzini {
35253018216SPaolo Bonzini DeviceState *dev;
35353018216SPaolo Bonzini SysBusDevice *s;
35453018216SPaolo Bonzini unsigned int i, j;
35553018216SPaolo Bonzini
3563e80f690SMarkus Armbruster dev = qdev_new("slavio_intctl");
35753018216SPaolo Bonzini
35853018216SPaolo Bonzini s = SYS_BUS_DEVICE(dev);
3593c6ef471SMarkus Armbruster sysbus_realize_and_unref(s, &error_fatal);
36053018216SPaolo Bonzini
36153018216SPaolo Bonzini for (i = 0; i < MAX_CPUS; i++) {
36253018216SPaolo Bonzini for (j = 0; j < MAX_PILS; j++) {
36353018216SPaolo Bonzini sysbus_connect_irq(s, i * MAX_PILS + j, parent_irq[i][j]);
36453018216SPaolo Bonzini }
36553018216SPaolo Bonzini }
36653018216SPaolo Bonzini sysbus_mmio_map(s, 0, addrg);
36753018216SPaolo Bonzini for (i = 0; i < MAX_CPUS; i++) {
36853018216SPaolo Bonzini sysbus_mmio_map(s, i + 1, addr + i * TARGET_PAGE_SIZE);
36953018216SPaolo Bonzini }
37053018216SPaolo Bonzini
37153018216SPaolo Bonzini return dev;
37253018216SPaolo Bonzini }
37353018216SPaolo Bonzini
37453018216SPaolo Bonzini #define SYS_TIMER_OFFSET 0x10000ULL
37553018216SPaolo Bonzini #define CPU_TIMER_OFFSET(cpu) (0x1000ULL * cpu)
37653018216SPaolo Bonzini
slavio_timer_init_all(hwaddr addr,qemu_irq master_irq,qemu_irq * cpu_irqs,unsigned int num_cpus)37753018216SPaolo Bonzini static void slavio_timer_init_all(hwaddr addr, qemu_irq master_irq,
37853018216SPaolo Bonzini qemu_irq *cpu_irqs, unsigned int num_cpus)
37953018216SPaolo Bonzini {
38053018216SPaolo Bonzini DeviceState *dev;
38153018216SPaolo Bonzini SysBusDevice *s;
38253018216SPaolo Bonzini unsigned int i;
38353018216SPaolo Bonzini
3843e80f690SMarkus Armbruster dev = qdev_new("slavio_timer");
38553018216SPaolo Bonzini qdev_prop_set_uint32(dev, "num_cpus", num_cpus);
38653018216SPaolo Bonzini s = SYS_BUS_DEVICE(dev);
3873c6ef471SMarkus Armbruster sysbus_realize_and_unref(s, &error_fatal);
38853018216SPaolo Bonzini sysbus_connect_irq(s, 0, master_irq);
38953018216SPaolo Bonzini sysbus_mmio_map(s, 0, addr + SYS_TIMER_OFFSET);
39053018216SPaolo Bonzini
39153018216SPaolo Bonzini for (i = 0; i < MAX_CPUS; i++) {
39253018216SPaolo Bonzini sysbus_mmio_map(s, i + 1, addr + (hwaddr)CPU_TIMER_OFFSET(i));
39353018216SPaolo Bonzini sysbus_connect_irq(s, i + 1, cpu_irqs[i]);
39453018216SPaolo Bonzini }
39553018216SPaolo Bonzini }
39653018216SPaolo Bonzini
39753018216SPaolo Bonzini static qemu_irq slavio_system_powerdown;
39853018216SPaolo Bonzini
slavio_powerdown_req(Notifier * n,void * opaque)39953018216SPaolo Bonzini static void slavio_powerdown_req(Notifier *n, void *opaque)
40053018216SPaolo Bonzini {
40153018216SPaolo Bonzini qemu_irq_raise(slavio_system_powerdown);
40253018216SPaolo Bonzini }
40353018216SPaolo Bonzini
40453018216SPaolo Bonzini static Notifier slavio_system_powerdown_notifier = {
40553018216SPaolo Bonzini .notify = slavio_powerdown_req
40653018216SPaolo Bonzini };
40753018216SPaolo Bonzini
40853018216SPaolo Bonzini #define MISC_LEDS 0x01600000
40953018216SPaolo Bonzini #define MISC_CFG 0x01800000
41053018216SPaolo Bonzini #define MISC_DIAG 0x01a00000
41153018216SPaolo Bonzini #define MISC_MDM 0x01b00000
41253018216SPaolo Bonzini #define MISC_SYS 0x01f00000
41353018216SPaolo Bonzini
slavio_misc_init(hwaddr base,hwaddr aux1_base,hwaddr aux2_base,qemu_irq irq,qemu_irq fdc_tc)41453018216SPaolo Bonzini static void slavio_misc_init(hwaddr base,
41553018216SPaolo Bonzini hwaddr aux1_base,
41653018216SPaolo Bonzini hwaddr aux2_base, qemu_irq irq,
41753018216SPaolo Bonzini qemu_irq fdc_tc)
41853018216SPaolo Bonzini {
41953018216SPaolo Bonzini DeviceState *dev;
42053018216SPaolo Bonzini SysBusDevice *s;
42153018216SPaolo Bonzini
4223e80f690SMarkus Armbruster dev = qdev_new("slavio_misc");
42353018216SPaolo Bonzini s = SYS_BUS_DEVICE(dev);
4243c6ef471SMarkus Armbruster sysbus_realize_and_unref(s, &error_fatal);
42553018216SPaolo Bonzini if (base) {
42653018216SPaolo Bonzini /* 8 bit registers */
42753018216SPaolo Bonzini /* Slavio control */
42853018216SPaolo Bonzini sysbus_mmio_map(s, 0, base + MISC_CFG);
42953018216SPaolo Bonzini /* Diagnostics */
43053018216SPaolo Bonzini sysbus_mmio_map(s, 1, base + MISC_DIAG);
43153018216SPaolo Bonzini /* Modem control */
43253018216SPaolo Bonzini sysbus_mmio_map(s, 2, base + MISC_MDM);
43353018216SPaolo Bonzini /* 16 bit registers */
43453018216SPaolo Bonzini /* ss600mp diag LEDs */
43553018216SPaolo Bonzini sysbus_mmio_map(s, 3, base + MISC_LEDS);
43653018216SPaolo Bonzini /* 32 bit registers */
43753018216SPaolo Bonzini /* System control */
43853018216SPaolo Bonzini sysbus_mmio_map(s, 4, base + MISC_SYS);
43953018216SPaolo Bonzini }
44053018216SPaolo Bonzini if (aux1_base) {
44153018216SPaolo Bonzini /* AUX 1 (Misc System Functions) */
44253018216SPaolo Bonzini sysbus_mmio_map(s, 5, aux1_base);
44353018216SPaolo Bonzini }
44453018216SPaolo Bonzini if (aux2_base) {
44553018216SPaolo Bonzini /* AUX 2 (Software Powerdown Control) */
44653018216SPaolo Bonzini sysbus_mmio_map(s, 6, aux2_base);
44753018216SPaolo Bonzini }
44853018216SPaolo Bonzini sysbus_connect_irq(s, 0, irq);
44953018216SPaolo Bonzini sysbus_connect_irq(s, 1, fdc_tc);
45053018216SPaolo Bonzini slavio_system_powerdown = qdev_get_gpio_in(dev, 0);
45153018216SPaolo Bonzini qemu_register_powerdown_notifier(&slavio_system_powerdown_notifier);
45253018216SPaolo Bonzini }
45353018216SPaolo Bonzini
ecc_init(hwaddr base,qemu_irq irq,uint32_t version)45453018216SPaolo Bonzini static void ecc_init(hwaddr base, qemu_irq irq, uint32_t version)
45553018216SPaolo Bonzini {
45653018216SPaolo Bonzini DeviceState *dev;
45753018216SPaolo Bonzini SysBusDevice *s;
45853018216SPaolo Bonzini
4593e80f690SMarkus Armbruster dev = qdev_new("eccmemctl");
46053018216SPaolo Bonzini qdev_prop_set_uint32(dev, "version", version);
46153018216SPaolo Bonzini s = SYS_BUS_DEVICE(dev);
4623c6ef471SMarkus Armbruster sysbus_realize_and_unref(s, &error_fatal);
46353018216SPaolo Bonzini sysbus_connect_irq(s, 0, irq);
46453018216SPaolo Bonzini sysbus_mmio_map(s, 0, base);
46553018216SPaolo Bonzini if (version == 0) { // SS-600MP only
46653018216SPaolo Bonzini sysbus_mmio_map(s, 1, base + 0x1000);
46753018216SPaolo Bonzini }
46853018216SPaolo Bonzini }
46953018216SPaolo Bonzini
apc_init(hwaddr power_base,qemu_irq cpu_halt)47053018216SPaolo Bonzini static void apc_init(hwaddr power_base, qemu_irq cpu_halt)
47153018216SPaolo Bonzini {
47253018216SPaolo Bonzini DeviceState *dev;
47353018216SPaolo Bonzini SysBusDevice *s;
47453018216SPaolo Bonzini
4753e80f690SMarkus Armbruster dev = qdev_new("apc");
47653018216SPaolo Bonzini s = SYS_BUS_DEVICE(dev);
4773c6ef471SMarkus Armbruster sysbus_realize_and_unref(s, &error_fatal);
47853018216SPaolo Bonzini /* Power management (APC) XXX: not a Slavio device */
47953018216SPaolo Bonzini sysbus_mmio_map(s, 0, power_base);
48053018216SPaolo Bonzini sysbus_connect_irq(s, 0, cpu_halt);
48153018216SPaolo Bonzini }
48253018216SPaolo Bonzini
tcx_init(hwaddr addr,qemu_irq irq,int vram_size,int width,int height,int depth)48355d7bfe2SMark Cave-Ayland static void tcx_init(hwaddr addr, qemu_irq irq, int vram_size, int width,
48453018216SPaolo Bonzini int height, int depth)
48553018216SPaolo Bonzini {
48653018216SPaolo Bonzini DeviceState *dev;
48753018216SPaolo Bonzini SysBusDevice *s;
48853018216SPaolo Bonzini
489e178113fSMarkus Armbruster dev = qdev_new("sun-tcx");
49053018216SPaolo Bonzini qdev_prop_set_uint32(dev, "vram_size", vram_size);
49153018216SPaolo Bonzini qdev_prop_set_uint16(dev, "width", width);
49253018216SPaolo Bonzini qdev_prop_set_uint16(dev, "height", height);
49353018216SPaolo Bonzini qdev_prop_set_uint16(dev, "depth", depth);
49453018216SPaolo Bonzini s = SYS_BUS_DEVICE(dev);
4953c6ef471SMarkus Armbruster sysbus_realize_and_unref(s, &error_fatal);
49655d7bfe2SMark Cave-Ayland
49755d7bfe2SMark Cave-Ayland /* 10/ROM : FCode ROM */
498da87dd7bSMark Cave-Ayland sysbus_mmio_map(s, 0, addr);
49955d7bfe2SMark Cave-Ayland /* 2/STIP : Stipple */
50055d7bfe2SMark Cave-Ayland sysbus_mmio_map(s, 1, addr + 0x04000000ULL);
50155d7bfe2SMark Cave-Ayland /* 3/BLIT : Blitter */
50255d7bfe2SMark Cave-Ayland sysbus_mmio_map(s, 2, addr + 0x06000000ULL);
50355d7bfe2SMark Cave-Ayland /* 5/RSTIP : Raw Stipple */
50455d7bfe2SMark Cave-Ayland sysbus_mmio_map(s, 3, addr + 0x0c000000ULL);
50555d7bfe2SMark Cave-Ayland /* 6/RBLIT : Raw Blitter */
50655d7bfe2SMark Cave-Ayland sysbus_mmio_map(s, 4, addr + 0x0e000000ULL);
50755d7bfe2SMark Cave-Ayland /* 7/TEC : Transform Engine */
50855d7bfe2SMark Cave-Ayland sysbus_mmio_map(s, 5, addr + 0x00700000ULL);
50955d7bfe2SMark Cave-Ayland /* 8/CMAP : DAC */
51055d7bfe2SMark Cave-Ayland sysbus_mmio_map(s, 6, addr + 0x00200000ULL);
51155d7bfe2SMark Cave-Ayland /* 9/THC : */
51255d7bfe2SMark Cave-Ayland if (depth == 8) {
51355d7bfe2SMark Cave-Ayland sysbus_mmio_map(s, 7, addr + 0x00300000ULL);
51453018216SPaolo Bonzini } else {
51555d7bfe2SMark Cave-Ayland sysbus_mmio_map(s, 7, addr + 0x00301000ULL);
51653018216SPaolo Bonzini }
51755d7bfe2SMark Cave-Ayland /* 11/DHC : */
51855d7bfe2SMark Cave-Ayland sysbus_mmio_map(s, 8, addr + 0x00240000ULL);
51955d7bfe2SMark Cave-Ayland /* 12/ALT : */
52055d7bfe2SMark Cave-Ayland sysbus_mmio_map(s, 9, addr + 0x00280000ULL);
52155d7bfe2SMark Cave-Ayland /* 0/DFB8 : 8-bit plane */
52255d7bfe2SMark Cave-Ayland sysbus_mmio_map(s, 10, addr + 0x00800000ULL);
52355d7bfe2SMark Cave-Ayland /* 1/DFB24 : 24bit plane */
52455d7bfe2SMark Cave-Ayland sysbus_mmio_map(s, 11, addr + 0x02000000ULL);
52555d7bfe2SMark Cave-Ayland /* 4/RDFB32: Raw framebuffer. Control plane */
52655d7bfe2SMark Cave-Ayland sysbus_mmio_map(s, 12, addr + 0x0a000000ULL);
52755d7bfe2SMark Cave-Ayland /* 9/THC24bits : NetBSD writes here even with 8-bit display: dummy */
52855d7bfe2SMark Cave-Ayland if (depth == 8) {
52955d7bfe2SMark Cave-Ayland sysbus_mmio_map(s, 13, addr + 0x00301000ULL);
53055d7bfe2SMark Cave-Ayland }
53155d7bfe2SMark Cave-Ayland
53255d7bfe2SMark Cave-Ayland sysbus_connect_irq(s, 0, irq);
53353018216SPaolo Bonzini }
53453018216SPaolo Bonzini
cg3_init(hwaddr addr,qemu_irq irq,int vram_size,int width,int height,int depth)535af87bf29SMark Cave-Ayland static void cg3_init(hwaddr addr, qemu_irq irq, int vram_size, int width,
536af87bf29SMark Cave-Ayland int height, int depth)
537af87bf29SMark Cave-Ayland {
538af87bf29SMark Cave-Ayland DeviceState *dev;
539af87bf29SMark Cave-Ayland SysBusDevice *s;
540af87bf29SMark Cave-Ayland
5413e80f690SMarkus Armbruster dev = qdev_new("cgthree");
542af87bf29SMark Cave-Ayland qdev_prop_set_uint32(dev, "vram-size", vram_size);
543af87bf29SMark Cave-Ayland qdev_prop_set_uint16(dev, "width", width);
544af87bf29SMark Cave-Ayland qdev_prop_set_uint16(dev, "height", height);
545af87bf29SMark Cave-Ayland qdev_prop_set_uint16(dev, "depth", depth);
546af87bf29SMark Cave-Ayland s = SYS_BUS_DEVICE(dev);
5473c6ef471SMarkus Armbruster sysbus_realize_and_unref(s, &error_fatal);
548af87bf29SMark Cave-Ayland
549af87bf29SMark Cave-Ayland /* FCode ROM */
550af87bf29SMark Cave-Ayland sysbus_mmio_map(s, 0, addr);
551af87bf29SMark Cave-Ayland /* DAC */
552af87bf29SMark Cave-Ayland sysbus_mmio_map(s, 1, addr + 0x400000ULL);
553af87bf29SMark Cave-Ayland /* 8-bit plane */
554af87bf29SMark Cave-Ayland sysbus_mmio_map(s, 2, addr + 0x800000ULL);
555af87bf29SMark Cave-Ayland
556af87bf29SMark Cave-Ayland sysbus_connect_irq(s, 0, irq);
557af87bf29SMark Cave-Ayland }
558af87bf29SMark Cave-Ayland
55953018216SPaolo Bonzini /* NCR89C100/MACIO Internal ID register */
560ef9dfa4cSAndreas Färber
561ef9dfa4cSAndreas Färber #define TYPE_MACIO_ID_REGISTER "macio_idreg"
562ef9dfa4cSAndreas Färber
56353018216SPaolo Bonzini static const uint8_t idreg_data[] = { 0xfe, 0x81, 0x01, 0x03 };
56453018216SPaolo Bonzini
idreg_init(hwaddr addr)56553018216SPaolo Bonzini static void idreg_init(hwaddr addr)
56653018216SPaolo Bonzini {
56753018216SPaolo Bonzini DeviceState *dev;
56853018216SPaolo Bonzini SysBusDevice *s;
56953018216SPaolo Bonzini
5703e80f690SMarkus Armbruster dev = qdev_new(TYPE_MACIO_ID_REGISTER);
57153018216SPaolo Bonzini s = SYS_BUS_DEVICE(dev);
5723c6ef471SMarkus Armbruster sysbus_realize_and_unref(s, &error_fatal);
57353018216SPaolo Bonzini
57453018216SPaolo Bonzini sysbus_mmio_map(s, 0, addr);
5753c8133f9SPeter Maydell address_space_write_rom(&address_space_memory, addr,
5763c8133f9SPeter Maydell MEMTXATTRS_UNSPECIFIED,
5773c8133f9SPeter Maydell idreg_data, sizeof(idreg_data));
57853018216SPaolo Bonzini }
57953018216SPaolo Bonzini
5808063396bSEduardo Habkost OBJECT_DECLARE_SIMPLE_TYPE(IDRegState, MACIO_ID_REGISTER)
581ef9dfa4cSAndreas Färber
582db1015e9SEduardo Habkost struct IDRegState {
583ef9dfa4cSAndreas Färber SysBusDevice parent_obj;
584ef9dfa4cSAndreas Färber
58553018216SPaolo Bonzini MemoryRegion mem;
586db1015e9SEduardo Habkost };
58753018216SPaolo Bonzini
idreg_realize(DeviceState * ds,Error ** errp)588a2a5a7b5SThomas Huth static void idreg_realize(DeviceState *ds, Error **errp)
58953018216SPaolo Bonzini {
590a2a5a7b5SThomas Huth IDRegState *s = MACIO_ID_REGISTER(ds);
591a2a5a7b5SThomas Huth SysBusDevice *dev = SYS_BUS_DEVICE(ds);
59253018216SPaolo Bonzini
59302e0ecb4SPhilippe Mathieu-Daudé if (!memory_region_init_ram_nomigrate(&s->mem, OBJECT(ds), "sun4m.idreg",
59402e0ecb4SPhilippe Mathieu-Daudé sizeof(idreg_data), errp)) {
595a2a5a7b5SThomas Huth return;
596a2a5a7b5SThomas Huth }
597a2a5a7b5SThomas Huth
59853018216SPaolo Bonzini vmstate_register_ram_global(&s->mem);
59953018216SPaolo Bonzini memory_region_set_readonly(&s->mem, true);
60053018216SPaolo Bonzini sysbus_init_mmio(dev, &s->mem);
60153018216SPaolo Bonzini }
60253018216SPaolo Bonzini
idreg_class_init(ObjectClass * oc,void * data)603a2a5a7b5SThomas Huth static void idreg_class_init(ObjectClass *oc, void *data)
604a2a5a7b5SThomas Huth {
605a2a5a7b5SThomas Huth DeviceClass *dc = DEVICE_CLASS(oc);
606a2a5a7b5SThomas Huth
607a2a5a7b5SThomas Huth dc->realize = idreg_realize;
608a2a5a7b5SThomas Huth }
609a2a5a7b5SThomas Huth
61053018216SPaolo Bonzini static const TypeInfo idreg_info = {
611ef9dfa4cSAndreas Färber .name = TYPE_MACIO_ID_REGISTER,
61253018216SPaolo Bonzini .parent = TYPE_SYS_BUS_DEVICE,
61353018216SPaolo Bonzini .instance_size = sizeof(IDRegState),
614a2a5a7b5SThomas Huth .class_init = idreg_class_init,
61553018216SPaolo Bonzini };
61653018216SPaolo Bonzini
617b3a49965SAndreas Färber #define TYPE_TCX_AFX "tcx_afx"
6188063396bSEduardo Habkost OBJECT_DECLARE_SIMPLE_TYPE(AFXState, TCX_AFX)
619b3a49965SAndreas Färber
620db1015e9SEduardo Habkost struct AFXState {
621b3a49965SAndreas Färber SysBusDevice parent_obj;
622b3a49965SAndreas Färber
62353018216SPaolo Bonzini MemoryRegion mem;
624db1015e9SEduardo Habkost };
62553018216SPaolo Bonzini
62653018216SPaolo Bonzini /* SS-5 TCX AFX register */
afx_init(hwaddr addr)62753018216SPaolo Bonzini static void afx_init(hwaddr addr)
62853018216SPaolo Bonzini {
62953018216SPaolo Bonzini DeviceState *dev;
63053018216SPaolo Bonzini SysBusDevice *s;
63153018216SPaolo Bonzini
6323e80f690SMarkus Armbruster dev = qdev_new(TYPE_TCX_AFX);
63353018216SPaolo Bonzini s = SYS_BUS_DEVICE(dev);
6343c6ef471SMarkus Armbruster sysbus_realize_and_unref(s, &error_fatal);
63553018216SPaolo Bonzini
63653018216SPaolo Bonzini sysbus_mmio_map(s, 0, addr);
63753018216SPaolo Bonzini }
63853018216SPaolo Bonzini
afx_realize(DeviceState * ds,Error ** errp)639a2a5a7b5SThomas Huth static void afx_realize(DeviceState *ds, Error **errp)
64053018216SPaolo Bonzini {
641a2a5a7b5SThomas Huth AFXState *s = TCX_AFX(ds);
642a2a5a7b5SThomas Huth SysBusDevice *dev = SYS_BUS_DEVICE(ds);
64353018216SPaolo Bonzini
64402e0ecb4SPhilippe Mathieu-Daudé if (!memory_region_init_ram_nomigrate(&s->mem, OBJECT(ds), "sun4m.afx",
64502e0ecb4SPhilippe Mathieu-Daudé 4, errp)) {
646a2a5a7b5SThomas Huth return;
647a2a5a7b5SThomas Huth }
648a2a5a7b5SThomas Huth
64953018216SPaolo Bonzini vmstate_register_ram_global(&s->mem);
65053018216SPaolo Bonzini sysbus_init_mmio(dev, &s->mem);
65153018216SPaolo Bonzini }
65253018216SPaolo Bonzini
afx_class_init(ObjectClass * oc,void * data)653a2a5a7b5SThomas Huth static void afx_class_init(ObjectClass *oc, void *data)
654a2a5a7b5SThomas Huth {
655a2a5a7b5SThomas Huth DeviceClass *dc = DEVICE_CLASS(oc);
656a2a5a7b5SThomas Huth
657a2a5a7b5SThomas Huth dc->realize = afx_realize;
658a2a5a7b5SThomas Huth }
659a2a5a7b5SThomas Huth
66053018216SPaolo Bonzini static const TypeInfo afx_info = {
661b3a49965SAndreas Färber .name = TYPE_TCX_AFX,
66253018216SPaolo Bonzini .parent = TYPE_SYS_BUS_DEVICE,
66353018216SPaolo Bonzini .instance_size = sizeof(AFXState),
664a2a5a7b5SThomas Huth .class_init = afx_class_init,
66553018216SPaolo Bonzini };
66653018216SPaolo Bonzini
667e6f54c91SAndreas Färber #define TYPE_OPENPROM "openprom"
668db1015e9SEduardo Habkost typedef struct PROMState PROMState;
6698110fa1dSEduardo Habkost DECLARE_INSTANCE_CHECKER(PROMState, OPENPROM,
6708110fa1dSEduardo Habkost TYPE_OPENPROM)
671e6f54c91SAndreas Färber
672db1015e9SEduardo Habkost struct PROMState {
673e6f54c91SAndreas Färber SysBusDevice parent_obj;
674e6f54c91SAndreas Färber
67553018216SPaolo Bonzini MemoryRegion prom;
676db1015e9SEduardo Habkost };
67753018216SPaolo Bonzini
67853018216SPaolo Bonzini /* Boot PROM (OpenBIOS) */
translate_prom_address(void * opaque,uint64_t addr)67953018216SPaolo Bonzini static uint64_t translate_prom_address(void *opaque, uint64_t addr)
68053018216SPaolo Bonzini {
68153018216SPaolo Bonzini hwaddr *base_addr = (hwaddr *)opaque;
68253018216SPaolo Bonzini return addr + *base_addr - PROM_VADDR;
68353018216SPaolo Bonzini }
68453018216SPaolo Bonzini
prom_init(hwaddr addr,const char * bios_name)68553018216SPaolo Bonzini static void prom_init(hwaddr addr, const char *bios_name)
68653018216SPaolo Bonzini {
68753018216SPaolo Bonzini DeviceState *dev;
68853018216SPaolo Bonzini SysBusDevice *s;
68953018216SPaolo Bonzini char *filename;
69053018216SPaolo Bonzini int ret;
69153018216SPaolo Bonzini
6923e80f690SMarkus Armbruster dev = qdev_new(TYPE_OPENPROM);
69353018216SPaolo Bonzini s = SYS_BUS_DEVICE(dev);
6943c6ef471SMarkus Armbruster sysbus_realize_and_unref(s, &error_fatal);
69553018216SPaolo Bonzini
69653018216SPaolo Bonzini sysbus_mmio_map(s, 0, addr);
69753018216SPaolo Bonzini
69853018216SPaolo Bonzini /* load boot prom */
69953018216SPaolo Bonzini if (bios_name == NULL) {
70053018216SPaolo Bonzini bios_name = PROM_FILENAME;
70153018216SPaolo Bonzini }
70253018216SPaolo Bonzini filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
70353018216SPaolo Bonzini if (filename) {
7044366e1dbSLiam Merwick ret = load_elf(filename, NULL,
7054366e1dbSLiam Merwick translate_prom_address, &addr, NULL,
7066cdda0ffSAleksandar Markovic NULL, NULL, NULL, 1, EM_SPARC, 0, 0);
70753018216SPaolo Bonzini if (ret < 0 || ret > PROM_SIZE_MAX) {
70853018216SPaolo Bonzini ret = load_image_targphys(filename, addr, PROM_SIZE_MAX);
70953018216SPaolo Bonzini }
71053018216SPaolo Bonzini g_free(filename);
71153018216SPaolo Bonzini } else {
71253018216SPaolo Bonzini ret = -1;
71353018216SPaolo Bonzini }
71453018216SPaolo Bonzini if (ret < 0 || ret > PROM_SIZE_MAX) {
71529bd7231SAlistair Francis error_report("could not load prom '%s'", bios_name);
71653018216SPaolo Bonzini exit(1);
71753018216SPaolo Bonzini }
71853018216SPaolo Bonzini }
71953018216SPaolo Bonzini
prom_realize(DeviceState * ds,Error ** errp)720a2a5a7b5SThomas Huth static void prom_realize(DeviceState *ds, Error **errp)
72153018216SPaolo Bonzini {
722a2a5a7b5SThomas Huth PROMState *s = OPENPROM(ds);
723a2a5a7b5SThomas Huth SysBusDevice *dev = SYS_BUS_DEVICE(ds);
72453018216SPaolo Bonzini
72502e0ecb4SPhilippe Mathieu-Daudé if (!memory_region_init_ram_nomigrate(&s->prom, OBJECT(ds), "sun4m.prom",
72602e0ecb4SPhilippe Mathieu-Daudé PROM_SIZE_MAX, errp)) {
727a2a5a7b5SThomas Huth return;
728a2a5a7b5SThomas Huth }
729a2a5a7b5SThomas Huth
73053018216SPaolo Bonzini vmstate_register_ram_global(&s->prom);
73153018216SPaolo Bonzini memory_region_set_readonly(&s->prom, true);
73253018216SPaolo Bonzini sysbus_init_mmio(dev, &s->prom);
73353018216SPaolo Bonzini }
73453018216SPaolo Bonzini
73553018216SPaolo Bonzini static Property prom_properties[] = {
73653018216SPaolo Bonzini {/* end of property list */},
73753018216SPaolo Bonzini };
73853018216SPaolo Bonzini
prom_class_init(ObjectClass * klass,void * data)73953018216SPaolo Bonzini static void prom_class_init(ObjectClass *klass, void *data)
74053018216SPaolo Bonzini {
74153018216SPaolo Bonzini DeviceClass *dc = DEVICE_CLASS(klass);
74253018216SPaolo Bonzini
7434f67d30bSMarc-André Lureau device_class_set_props(dc, prom_properties);
744a2a5a7b5SThomas Huth dc->realize = prom_realize;
74553018216SPaolo Bonzini }
74653018216SPaolo Bonzini
74753018216SPaolo Bonzini static const TypeInfo prom_info = {
748e6f54c91SAndreas Färber .name = TYPE_OPENPROM,
74953018216SPaolo Bonzini .parent = TYPE_SYS_BUS_DEVICE,
75053018216SPaolo Bonzini .instance_size = sizeof(PROMState),
75153018216SPaolo Bonzini .class_init = prom_class_init,
75253018216SPaolo Bonzini };
75353018216SPaolo Bonzini
7545ab6b4c6SAndreas Färber #define TYPE_SUN4M_MEMORY "memory"
755db1015e9SEduardo Habkost typedef struct RamDevice RamDevice;
7568110fa1dSEduardo Habkost DECLARE_INSTANCE_CHECKER(RamDevice, SUN4M_RAM,
7578110fa1dSEduardo Habkost TYPE_SUN4M_MEMORY)
7585ab6b4c6SAndreas Färber
759db1015e9SEduardo Habkost struct RamDevice {
7605ab6b4c6SAndreas Färber SysBusDevice parent_obj;
761b2554752SIgor Mammedov HostMemoryBackend *memdev;
762db1015e9SEduardo Habkost };
76353018216SPaolo Bonzini
76453018216SPaolo Bonzini /* System RAM */
ram_realize(DeviceState * dev,Error ** errp)765dc8b6dd9Sxiaoqiang zhao static void ram_realize(DeviceState *dev, Error **errp)
76653018216SPaolo Bonzini {
7675ab6b4c6SAndreas Färber RamDevice *d = SUN4M_RAM(dev);
768b2554752SIgor Mammedov MemoryRegion *ram = host_memory_backend_get_memory(d->memdev);
76953018216SPaolo Bonzini
770b2554752SIgor Mammedov sysbus_init_mmio(SYS_BUS_DEVICE(dev), ram);
77153018216SPaolo Bonzini }
77253018216SPaolo Bonzini
ram_initfn(Object * obj)773b2554752SIgor Mammedov static void ram_initfn(Object *obj)
77453018216SPaolo Bonzini {
775b2554752SIgor Mammedov RamDevice *d = SUN4M_RAM(obj);
776b2554752SIgor Mammedov object_property_add_link(obj, "memdev", TYPE_MEMORY_BACKEND,
777b2554752SIgor Mammedov (Object **)&d->memdev,
778b2554752SIgor Mammedov object_property_allow_set_link,
779d2623129SMarkus Armbruster OBJ_PROP_LINK_STRONG);
780b2554752SIgor Mammedov object_property_set_description(obj, "memdev", "Set RAM backend"
7817eecec7dSMarkus Armbruster "Valid value is ID of a hostmem backend");
78253018216SPaolo Bonzini }
78353018216SPaolo Bonzini
ram_class_init(ObjectClass * klass,void * data)78453018216SPaolo Bonzini static void ram_class_init(ObjectClass *klass, void *data)
78553018216SPaolo Bonzini {
78653018216SPaolo Bonzini DeviceClass *dc = DEVICE_CLASS(klass);
78753018216SPaolo Bonzini
788dc8b6dd9Sxiaoqiang zhao dc->realize = ram_realize;
78953018216SPaolo Bonzini }
79053018216SPaolo Bonzini
79153018216SPaolo Bonzini static const TypeInfo ram_info = {
7925ab6b4c6SAndreas Färber .name = TYPE_SUN4M_MEMORY,
79353018216SPaolo Bonzini .parent = TYPE_SYS_BUS_DEVICE,
79453018216SPaolo Bonzini .instance_size = sizeof(RamDevice),
795b2554752SIgor Mammedov .instance_init = ram_initfn,
79653018216SPaolo Bonzini .class_init = ram_class_init,
79753018216SPaolo Bonzini };
79853018216SPaolo Bonzini
cpu_devinit(const char * cpu_type,unsigned int id,uint64_t prom_addr,qemu_irq ** cpu_irqs)79949cbd887SIgor Mammedov static void cpu_devinit(const char *cpu_type, unsigned int id,
80053018216SPaolo Bonzini uint64_t prom_addr, qemu_irq **cpu_irqs)
80153018216SPaolo Bonzini {
80253018216SPaolo Bonzini SPARCCPU *cpu;
80353018216SPaolo Bonzini CPUSPARCState *env;
80453018216SPaolo Bonzini
80524f675cdSThiago Jung Bauermann cpu = SPARC_CPU(object_new(cpu_type));
80653018216SPaolo Bonzini env = &cpu->env;
80753018216SPaolo Bonzini
80824f675cdSThiago Jung Bauermann qemu_register_reset(sun4m_cpu_reset, cpu);
80924f675cdSThiago Jung Bauermann object_property_set_bool(OBJECT(cpu), "start-powered-off", id != 0,
810287fa323SPhilippe Mathieu-Daudé &error_abort);
81124f675cdSThiago Jung Bauermann qdev_realize_and_unref(DEVICE(cpu), NULL, &error_fatal);
812e97a8a59SMark Cave-Ayland cpu_sparc_set_id(env, id);
81353018216SPaolo Bonzini *cpu_irqs = qemu_allocate_irqs(cpu_set_irq, cpu, MAX_PILS);
81453018216SPaolo Bonzini env->prom_addr = prom_addr;
81553018216SPaolo Bonzini }
81653018216SPaolo Bonzini
dummy_fdc_tc(void * opaque,int irq,int level)81753018216SPaolo Bonzini static void dummy_fdc_tc(void *opaque, int irq, int level)
81853018216SPaolo Bonzini {
81953018216SPaolo Bonzini }
82053018216SPaolo Bonzini
sun4m_hw_init(MachineState * machine)82195bc47deSPhilippe Mathieu-Daudé static void sun4m_hw_init(MachineState *machine)
82253018216SPaolo Bonzini {
82395bc47deSPhilippe Mathieu-Daudé const struct sun4m_hwdef *hwdef = SUN4M_MACHINE_GET_CLASS(machine)->hwdef;
82461b97833SHervé Poussineau DeviceState *slavio_intctl;
82553018216SPaolo Bonzini unsigned int i;
826cb0fa36bSMark Cave-Ayland Nvram *nvram;
8279540619dSMark Cave-Ayland qemu_irq *cpu_irqs[MAX_CPUS], slavio_irq[32], slavio_cpu_irq[MAX_CPUS];
82853018216SPaolo Bonzini qemu_irq fdc_tc;
82953018216SPaolo Bonzini unsigned long kernel_size;
8306031ff8bSMark Cave-Ayland uint32_t initrd_size;
83153018216SPaolo Bonzini DriveInfo *fd[MAX_FD];
832a88b362cSLaszlo Ersek FWCfgState *fw_cfg;
833a879306cSMark Cave-Ayland DeviceState *dev, *ms_kb_orgate, *serial_orgate;
8342cc75c32SLaurent Vivier SysBusDevice *s;
83533decbd2SLike Xu unsigned int smp_cpus = machine->smp.cpus;
83633decbd2SLike Xu unsigned int max_cpus = machine->smp.max_cpus;
83726f88d84SPaolo Bonzini HostMemoryBackend *ram_memdev = machine->memdev;
838ae0b175bSDavid Woodhouse MACAddr hostid;
839b2554752SIgor Mammedov
840b2554752SIgor Mammedov if (machine->ram_size > hwdef->max_mem) {
841b2554752SIgor Mammedov error_report("Too much memory for this machine: %" PRId64 ","
842b2554752SIgor Mammedov " maximum %" PRId64,
843b2554752SIgor Mammedov machine->ram_size / MiB, hwdef->max_mem / MiB);
844b2554752SIgor Mammedov exit(1);
845b2554752SIgor Mammedov }
84653018216SPaolo Bonzini
84753018216SPaolo Bonzini /* init CPUs */
84853018216SPaolo Bonzini for(i = 0; i < smp_cpus; i++) {
84949cbd887SIgor Mammedov cpu_devinit(machine->cpu_type, i, hwdef->slavio_base, &cpu_irqs[i]);
85053018216SPaolo Bonzini }
85153018216SPaolo Bonzini
85253018216SPaolo Bonzini for (i = smp_cpus; i < MAX_CPUS; i++)
85353018216SPaolo Bonzini cpu_irqs[i] = qemu_allocate_irqs(dummy_cpu_set_irq, NULL, MAX_PILS);
85453018216SPaolo Bonzini
855b2554752SIgor Mammedov /* Create and map RAM frontend */
8563e80f690SMarkus Armbruster dev = qdev_new("memory");
85726f88d84SPaolo Bonzini object_property_set_link(OBJECT(dev), "memdev", OBJECT(ram_memdev), &error_fatal);
8583c6ef471SMarkus Armbruster sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
859b2554752SIgor Mammedov sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0);
86053018216SPaolo Bonzini
86153018216SPaolo Bonzini /* models without ECC don't trap when missing ram is accessed */
86253018216SPaolo Bonzini if (!hwdef->ecc_base) {
86328c78fe8SPhilippe Mathieu-Daudé empty_slot_init("ecc", machine->ram_size,
86428c78fe8SPhilippe Mathieu-Daudé hwdef->max_mem - machine->ram_size);
86553018216SPaolo Bonzini }
86653018216SPaolo Bonzini
867377ce9cbSPaolo Bonzini prom_init(hwdef->slavio_base, machine->firmware);
86853018216SPaolo Bonzini
86953018216SPaolo Bonzini slavio_intctl = slavio_intctl_init(hwdef->intctl_base,
87053018216SPaolo Bonzini hwdef->intctl_base + 0x10000ULL,
87153018216SPaolo Bonzini cpu_irqs);
87253018216SPaolo Bonzini
87353018216SPaolo Bonzini for (i = 0; i < 32; i++) {
87453018216SPaolo Bonzini slavio_irq[i] = qdev_get_gpio_in(slavio_intctl, i);
87553018216SPaolo Bonzini }
87653018216SPaolo Bonzini for (i = 0; i < MAX_CPUS; i++) {
87753018216SPaolo Bonzini slavio_cpu_irq[i] = qdev_get_gpio_in(slavio_intctl, 32 + i);
87853018216SPaolo Bonzini }
87953018216SPaolo Bonzini
88053018216SPaolo Bonzini if (hwdef->idreg_base) {
88153018216SPaolo Bonzini idreg_init(hwdef->idreg_base);
88253018216SPaolo Bonzini }
88353018216SPaolo Bonzini
88453018216SPaolo Bonzini if (hwdef->afx_base) {
88553018216SPaolo Bonzini afx_init(hwdef->afx_base);
88653018216SPaolo Bonzini }
88753018216SPaolo Bonzini
8886aa62ed6SMark Cave-Ayland iommu_init(hwdef->iommu_base, hwdef->iommu_version, slavio_irq[30]);
88953018216SPaolo Bonzini
89053018216SPaolo Bonzini if (hwdef->iommu_pad_base) {
89153018216SPaolo Bonzini /* On the real hardware (SS-5, LX) the MMU is not padded, but aliased.
89253018216SPaolo Bonzini Software shouldn't use aliased addresses, neither should it crash
89353018216SPaolo Bonzini when does. Using empty_slot instead of aliasing can help with
89453018216SPaolo Bonzini debugging such accesses */
89528c78fe8SPhilippe Mathieu-Daudé empty_slot_init("iommu.alias",
89628c78fe8SPhilippe Mathieu-Daudé hwdef->iommu_pad_base, hwdef->iommu_pad_len);
89753018216SPaolo Bonzini }
89853018216SPaolo Bonzini
8996aa62ed6SMark Cave-Ayland sparc32_dma_init(hwdef->dma_base,
9006aa62ed6SMark Cave-Ayland hwdef->esp_base, slavio_irq[18],
901ae0b175bSDavid Woodhouse hwdef->le_base, slavio_irq[16], &hostid);
902e6ca02a4SMark Cave-Ayland
90353018216SPaolo Bonzini if (graphic_depth != 8 && graphic_depth != 24) {
904af87bf29SMark Cave-Ayland error_report("Unsupported depth: %d", graphic_depth);
90553018216SPaolo Bonzini exit (1);
90653018216SPaolo Bonzini }
9076807874dSPaolo Bonzini if (vga_interface_type != VGA_NONE) {
908af87bf29SMark Cave-Ayland if (vga_interface_type == VGA_CG3) {
909af87bf29SMark Cave-Ayland if (graphic_depth != 8) {
910af87bf29SMark Cave-Ayland error_report("Unsupported depth: %d", graphic_depth);
911af87bf29SMark Cave-Ayland exit(1);
912af87bf29SMark Cave-Ayland }
913af87bf29SMark Cave-Ayland
914af87bf29SMark Cave-Ayland if (!(graphic_width == 1024 && graphic_height == 768) &&
915af87bf29SMark Cave-Ayland !(graphic_width == 1152 && graphic_height == 900)) {
916af87bf29SMark Cave-Ayland error_report("Unsupported resolution: %d x %d", graphic_width,
917af87bf29SMark Cave-Ayland graphic_height);
918af87bf29SMark Cave-Ayland exit(1);
919af87bf29SMark Cave-Ayland }
920af87bf29SMark Cave-Ayland
921af87bf29SMark Cave-Ayland /* sbus irq 5 */
922af87bf29SMark Cave-Ayland cg3_init(hwdef->tcx_base, slavio_irq[11], 0x00100000,
923af87bf29SMark Cave-Ayland graphic_width, graphic_height, graphic_depth);
924f9bcb2d6SGautam Agrawal vga_interface_created = true;
925af87bf29SMark Cave-Ayland } else {
926af87bf29SMark Cave-Ayland /* If no display specified, default to TCX */
927af87bf29SMark Cave-Ayland if (graphic_depth != 8 && graphic_depth != 24) {
928af87bf29SMark Cave-Ayland error_report("Unsupported depth: %d", graphic_depth);
929af87bf29SMark Cave-Ayland exit(1);
930af87bf29SMark Cave-Ayland }
931af87bf29SMark Cave-Ayland
932af87bf29SMark Cave-Ayland if (!(graphic_width == 1024 && graphic_height == 768)) {
933af87bf29SMark Cave-Ayland error_report("Unsupported resolution: %d x %d",
934af87bf29SMark Cave-Ayland graphic_width, graphic_height);
935af87bf29SMark Cave-Ayland exit(1);
936af87bf29SMark Cave-Ayland }
937af87bf29SMark Cave-Ayland
93855d7bfe2SMark Cave-Ayland tcx_init(hwdef->tcx_base, slavio_irq[11], 0x00100000,
93955d7bfe2SMark Cave-Ayland graphic_width, graphic_height, graphic_depth);
940f9bcb2d6SGautam Agrawal vga_interface_created = true;
94153018216SPaolo Bonzini }
942af87bf29SMark Cave-Ayland }
94353018216SPaolo Bonzini
9446807874dSPaolo Bonzini for (i = 0; i < MAX_VSIMMS; i++) {
94553018216SPaolo Bonzini /* vsimm registers probed by OBP */
94653018216SPaolo Bonzini if (hwdef->vsimm[i].reg_base) {
94728c78fe8SPhilippe Mathieu-Daudé char *name = g_strdup_printf("vsimm[%d]", i);
94828c78fe8SPhilippe Mathieu-Daudé empty_slot_init(name, hwdef->vsimm[i].reg_base, 0x2000);
94928c78fe8SPhilippe Mathieu-Daudé g_free(name);
95053018216SPaolo Bonzini }
95153018216SPaolo Bonzini }
95253018216SPaolo Bonzini
95353018216SPaolo Bonzini if (hwdef->sx_base) {
954e178113fSMarkus Armbruster create_unimplemented_device("sun-sx", hwdef->sx_base, 0x2000);
95553018216SPaolo Bonzini }
95653018216SPaolo Bonzini
957cb0fa36bSMark Cave-Ayland dev = qdev_new("sysbus-m48t08");
958cb0fa36bSMark Cave-Ayland qdev_prop_set_int32(dev, "base-year", 1968);
959cb0fa36bSMark Cave-Ayland s = SYS_BUS_DEVICE(dev);
960cb0fa36bSMark Cave-Ayland sysbus_realize_and_unref(s, &error_fatal);
961cb0fa36bSMark Cave-Ayland sysbus_connect_irq(s, 0, slavio_irq[0]);
962cb0fa36bSMark Cave-Ayland sysbus_mmio_map(s, 0, hwdef->nvram_base);
963cb0fa36bSMark Cave-Ayland nvram = NVRAM(dev);
96453018216SPaolo Bonzini
96553018216SPaolo Bonzini slavio_timer_init_all(hwdef->counter_base, slavio_irq[19], slavio_cpu_irq, smp_cpus);
96653018216SPaolo Bonzini
96753018216SPaolo Bonzini /* Slavio TTYA (base+4, Linux ttyS0) is the first QEMU serial device
96853018216SPaolo Bonzini Slavio TTYB (base+0, Linux ttyS1) is the second QEMU serial device */
9693e80f690SMarkus Armbruster dev = qdev_new(TYPE_ESCC);
9702cc75c32SLaurent Vivier qdev_prop_set_uint32(dev, "disabled", !machine->enable_graphics);
9712cc75c32SLaurent Vivier qdev_prop_set_uint32(dev, "frequency", ESCC_CLOCK);
9722cc75c32SLaurent Vivier qdev_prop_set_uint32(dev, "it_shift", 1);
9732cc75c32SLaurent Vivier qdev_prop_set_chr(dev, "chrB", NULL);
9742cc75c32SLaurent Vivier qdev_prop_set_chr(dev, "chrA", NULL);
9752cc75c32SLaurent Vivier qdev_prop_set_uint32(dev, "chnBtype", escc_mouse);
9762cc75c32SLaurent Vivier qdev_prop_set_uint32(dev, "chnAtype", escc_kbd);
9772cc75c32SLaurent Vivier s = SYS_BUS_DEVICE(dev);
9783c6ef471SMarkus Armbruster sysbus_realize_and_unref(s, &error_fatal);
9792cc75c32SLaurent Vivier sysbus_mmio_map(s, 0, hwdef->ms_kb_base);
9802cc75c32SLaurent Vivier
981a879306cSMark Cave-Ayland /* Logically OR both its IRQs together */
982a879306cSMark Cave-Ayland ms_kb_orgate = DEVICE(object_new(TYPE_OR_IRQ));
983a879306cSMark Cave-Ayland object_property_set_int(OBJECT(ms_kb_orgate), "num-lines", 2, &error_fatal);
984a879306cSMark Cave-Ayland qdev_realize_and_unref(ms_kb_orgate, NULL, &error_fatal);
985a879306cSMark Cave-Ayland sysbus_connect_irq(s, 0, qdev_get_gpio_in(ms_kb_orgate, 0));
986a879306cSMark Cave-Ayland sysbus_connect_irq(s, 1, qdev_get_gpio_in(ms_kb_orgate, 1));
9877d5b0d68SPhilippe Mathieu-Daudé qdev_connect_gpio_out(ms_kb_orgate, 0, slavio_irq[14]);
988a879306cSMark Cave-Ayland
9893e80f690SMarkus Armbruster dev = qdev_new(TYPE_ESCC);
9902cc75c32SLaurent Vivier qdev_prop_set_uint32(dev, "disabled", 0);
9912cc75c32SLaurent Vivier qdev_prop_set_uint32(dev, "frequency", ESCC_CLOCK);
9922cc75c32SLaurent Vivier qdev_prop_set_uint32(dev, "it_shift", 1);
9939bca0edbSPeter Maydell qdev_prop_set_chr(dev, "chrB", serial_hd(1));
9949bca0edbSPeter Maydell qdev_prop_set_chr(dev, "chrA", serial_hd(0));
9952cc75c32SLaurent Vivier qdev_prop_set_uint32(dev, "chnBtype", escc_serial);
9962cc75c32SLaurent Vivier qdev_prop_set_uint32(dev, "chnAtype", escc_serial);
9972cc75c32SLaurent Vivier
9982cc75c32SLaurent Vivier s = SYS_BUS_DEVICE(dev);
9993c6ef471SMarkus Armbruster sysbus_realize_and_unref(s, &error_fatal);
10002cc75c32SLaurent Vivier sysbus_mmio_map(s, 0, hwdef->serial_base);
100153018216SPaolo Bonzini
1002a879306cSMark Cave-Ayland /* Logically OR both its IRQs together */
1003a879306cSMark Cave-Ayland serial_orgate = DEVICE(object_new(TYPE_OR_IRQ));
1004a879306cSMark Cave-Ayland object_property_set_int(OBJECT(serial_orgate), "num-lines", 2,
1005a879306cSMark Cave-Ayland &error_fatal);
1006a879306cSMark Cave-Ayland qdev_realize_and_unref(serial_orgate, NULL, &error_fatal);
1007a879306cSMark Cave-Ayland sysbus_connect_irq(s, 0, qdev_get_gpio_in(serial_orgate, 0));
1008a879306cSMark Cave-Ayland sysbus_connect_irq(s, 1, qdev_get_gpio_in(serial_orgate, 1));
10097d5b0d68SPhilippe Mathieu-Daudé qdev_connect_gpio_out(serial_orgate, 0, slavio_irq[15]);
1010a879306cSMark Cave-Ayland
101153018216SPaolo Bonzini if (hwdef->apc_base) {
1012ca43b97bSShannon Zhao apc_init(hwdef->apc_base, qemu_allocate_irq(cpu_halt_signal, NULL, 0));
101353018216SPaolo Bonzini }
101453018216SPaolo Bonzini
101553018216SPaolo Bonzini if (hwdef->fd_base) {
101653018216SPaolo Bonzini /* there is zero or one floppy drive */
101753018216SPaolo Bonzini memset(fd, 0, sizeof(fd));
101853018216SPaolo Bonzini fd[0] = drive_get(IF_FLOPPY, 0, 0);
101953018216SPaolo Bonzini sun4m_fdctrl_init(slavio_irq[22], hwdef->fd_base, fd,
102053018216SPaolo Bonzini &fdc_tc);
102153018216SPaolo Bonzini } else {
1022ca43b97bSShannon Zhao fdc_tc = qemu_allocate_irq(dummy_fdc_tc, NULL, 0);
102353018216SPaolo Bonzini }
102453018216SPaolo Bonzini
102553018216SPaolo Bonzini slavio_misc_init(hwdef->slavio_base, hwdef->aux1_base, hwdef->aux2_base,
102653018216SPaolo Bonzini slavio_irq[30], fdc_tc);
102753018216SPaolo Bonzini
102853018216SPaolo Bonzini if (hwdef->cs_base) {
1029e178113fSMarkus Armbruster sysbus_create_simple("sun-CS4231", hwdef->cs_base,
103053018216SPaolo Bonzini slavio_irq[5]);
103153018216SPaolo Bonzini }
103253018216SPaolo Bonzini
103353018216SPaolo Bonzini if (hwdef->dbri_base) {
103453018216SPaolo Bonzini /* ISDN chip with attached CS4215 audio codec */
103553018216SPaolo Bonzini /* prom space */
1036e178113fSMarkus Armbruster create_unimplemented_device("sun-DBRI.prom",
1037077f0f3dSPhilippe Mathieu-Daudé hwdef->dbri_base + 0x1000, 0x30);
103853018216SPaolo Bonzini /* reg space */
1039e178113fSMarkus Armbruster create_unimplemented_device("sun-DBRI",
1040077f0f3dSPhilippe Mathieu-Daudé hwdef->dbri_base + 0x10000, 0x100);
104153018216SPaolo Bonzini }
104253018216SPaolo Bonzini
104353018216SPaolo Bonzini if (hwdef->bpp_base) {
104453018216SPaolo Bonzini /* parallel port */
1045e178113fSMarkus Armbruster create_unimplemented_device("sun-bpp", hwdef->bpp_base, 0x20);
104653018216SPaolo Bonzini }
104753018216SPaolo Bonzini
10486031ff8bSMark Cave-Ayland initrd_size = 0;
10493ef96221SMarcel Apfelbaum kernel_size = sun4m_load_kernel(machine->kernel_filename,
10503ef96221SMarcel Apfelbaum machine->initrd_filename,
10516031ff8bSMark Cave-Ayland machine->ram_size, &initrd_size);
105253018216SPaolo Bonzini
1053ae0b175bSDavid Woodhouse nvram_init(nvram, hostid.a, machine->kernel_cmdline,
105497ec4d21SPaolo Bonzini machine->boot_config.order, machine->ram_size, kernel_size,
10553ef96221SMarcel Apfelbaum graphic_width, graphic_height, graphic_depth,
10563ef96221SMarcel Apfelbaum hwdef->nvram_machine_id, "Sun4m");
105753018216SPaolo Bonzini
105853018216SPaolo Bonzini if (hwdef->ecc_base)
105953018216SPaolo Bonzini ecc_init(hwdef->ecc_base, slavio_irq[28],
106053018216SPaolo Bonzini hwdef->ecc_version);
106153018216SPaolo Bonzini
10623e80f690SMarkus Armbruster dev = qdev_new(TYPE_FW_CFG_MEM);
106384983214SMark Cave-Ayland fw_cfg = FW_CFG(dev);
106484983214SMark Cave-Ayland qdev_prop_set_uint32(dev, "data_width", 1);
106584983214SMark Cave-Ayland qdev_prop_set_bit(dev, "dma_enabled", false);
106684983214SMark Cave-Ayland object_property_add_child(OBJECT(qdev_get_machine()), TYPE_FW_CFG,
1067d2623129SMarkus Armbruster OBJECT(fw_cfg));
106884983214SMark Cave-Ayland s = SYS_BUS_DEVICE(dev);
10693c6ef471SMarkus Armbruster sysbus_realize_and_unref(s, &error_fatal);
107084983214SMark Cave-Ayland sysbus_mmio_map(s, 0, CFG_ADDR);
107184983214SMark Cave-Ayland sysbus_mmio_map(s, 1, CFG_ADDR + 2);
107284983214SMark Cave-Ayland
10735836d168SIgor Mammedov fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, (uint16_t)smp_cpus);
107453018216SPaolo Bonzini fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);
1075b2554752SIgor Mammedov fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)machine->ram_size);
107653018216SPaolo Bonzini fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id);
107753018216SPaolo Bonzini fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_DEPTH, graphic_depth);
1078b96919e0SMark Cave-Ayland fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_WIDTH, graphic_width);
1079b96919e0SMark Cave-Ayland fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_HEIGHT, graphic_height);
108053018216SPaolo Bonzini fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, KERNEL_LOAD_ADDR);
108153018216SPaolo Bonzini fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
10823ef96221SMarcel Apfelbaum if (machine->kernel_cmdline) {
108353018216SPaolo Bonzini fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);
10846b63ef4dSMarkus Armbruster pstrcpy_targphys("cmdline", CMDLINE_ADDR, TARGET_PAGE_SIZE,
10853ef96221SMarcel Apfelbaum machine->kernel_cmdline);
10863ef96221SMarcel Apfelbaum fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, machine->kernel_cmdline);
108753018216SPaolo Bonzini fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE,
10883ef96221SMarcel Apfelbaum strlen(machine->kernel_cmdline) + 1);
108953018216SPaolo Bonzini } else {
109053018216SPaolo Bonzini fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
109153018216SPaolo Bonzini fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, 0);
109253018216SPaolo Bonzini }
109353018216SPaolo Bonzini fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, INITRD_LOAD_ADDR);
10946031ff8bSMark Cave-Ayland fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size);
109597ec4d21SPaolo Bonzini fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, machine->boot_config.order[0]);
109653018216SPaolo Bonzini qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
109753018216SPaolo Bonzini }
109853018216SPaolo Bonzini
109953018216SPaolo Bonzini enum {
110053018216SPaolo Bonzini ss5_id = 32,
110153018216SPaolo Bonzini vger_id,
110253018216SPaolo Bonzini lx_id,
110353018216SPaolo Bonzini ss4_id,
110453018216SPaolo Bonzini scls_id,
110553018216SPaolo Bonzini sbook_id,
110653018216SPaolo Bonzini ss10_id = 64,
110753018216SPaolo Bonzini ss20_id,
110853018216SPaolo Bonzini ss600mp_id,
110953018216SPaolo Bonzini };
111053018216SPaolo Bonzini
sun4m_machine_class_init(ObjectClass * oc,void * data)1111bcdd781fSPhilippe Mathieu-Daudé static void sun4m_machine_class_init(ObjectClass *oc, void *data)
111253018216SPaolo Bonzini {
1113bcdd781fSPhilippe Mathieu-Daudé MachineClass *mc = MACHINE_CLASS(oc);
1114bcdd781fSPhilippe Mathieu-Daudé
1115bcdd781fSPhilippe Mathieu-Daudé mc->init = sun4m_hw_init;
1116bcdd781fSPhilippe Mathieu-Daudé mc->block_default_type = IF_SCSI;
1117bcdd781fSPhilippe Mathieu-Daudé mc->default_boot_order = "c";
1118bcdd781fSPhilippe Mathieu-Daudé mc->default_display = "tcx";
1119bcdd781fSPhilippe Mathieu-Daudé mc->default_ram_id = "sun4m.ram";
1120bcdd781fSPhilippe Mathieu-Daudé }
1121bcdd781fSPhilippe Mathieu-Daudé
ss5_class_init(ObjectClass * oc,void * data)1122bcdd781fSPhilippe Mathieu-Daudé static void ss5_class_init(ObjectClass *oc, void *data)
1123bcdd781fSPhilippe Mathieu-Daudé {
1124bcdd781fSPhilippe Mathieu-Daudé MachineClass *mc = MACHINE_CLASS(oc);
1125bcdd781fSPhilippe Mathieu-Daudé Sun4mMachineClass *smc = SUN4M_MACHINE_CLASS(mc);
1126bcdd781fSPhilippe Mathieu-Daudé static const struct sun4m_hwdef ss5_hwdef = {
112753018216SPaolo Bonzini .iommu_base = 0x10000000,
112853018216SPaolo Bonzini .iommu_pad_base = 0x10004000,
112953018216SPaolo Bonzini .iommu_pad_len = 0x0fffb000,
113053018216SPaolo Bonzini .tcx_base = 0x50000000,
113153018216SPaolo Bonzini .cs_base = 0x6c000000,
113253018216SPaolo Bonzini .slavio_base = 0x70000000,
113353018216SPaolo Bonzini .ms_kb_base = 0x71000000,
113453018216SPaolo Bonzini .serial_base = 0x71100000,
113553018216SPaolo Bonzini .nvram_base = 0x71200000,
113653018216SPaolo Bonzini .fd_base = 0x71400000,
113753018216SPaolo Bonzini .counter_base = 0x71d00000,
113853018216SPaolo Bonzini .intctl_base = 0x71e00000,
113953018216SPaolo Bonzini .idreg_base = 0x78000000,
114053018216SPaolo Bonzini .dma_base = 0x78400000,
114153018216SPaolo Bonzini .esp_base = 0x78800000,
114253018216SPaolo Bonzini .le_base = 0x78c00000,
114353018216SPaolo Bonzini .apc_base = 0x6a000000,
114453018216SPaolo Bonzini .afx_base = 0x6e000000,
114553018216SPaolo Bonzini .aux1_base = 0x71900000,
114653018216SPaolo Bonzini .aux2_base = 0x71910000,
114753018216SPaolo Bonzini .nvram_machine_id = 0x80,
114853018216SPaolo Bonzini .machine_id = ss5_id,
114953018216SPaolo Bonzini .iommu_version = 0x05000000,
115053018216SPaolo Bonzini .max_mem = 0x10000000,
1151bcdd781fSPhilippe Mathieu-Daudé };
1152bcdd781fSPhilippe Mathieu-Daudé
1153bcdd781fSPhilippe Mathieu-Daudé mc->desc = "Sun4m platform, SPARCstation 5";
1154bcdd781fSPhilippe Mathieu-Daudé mc->is_default = true;
1155bcdd781fSPhilippe Mathieu-Daudé mc->default_cpu_type = SPARC_CPU_TYPE_NAME("Fujitsu-MB86904");
1156bcdd781fSPhilippe Mathieu-Daudé smc->hwdef = &ss5_hwdef;
1157bcdd781fSPhilippe Mathieu-Daudé }
1158bcdd781fSPhilippe Mathieu-Daudé
ss10_class_init(ObjectClass * oc,void * data)1159bcdd781fSPhilippe Mathieu-Daudé static void ss10_class_init(ObjectClass *oc, void *data)
116053018216SPaolo Bonzini {
1161bcdd781fSPhilippe Mathieu-Daudé MachineClass *mc = MACHINE_CLASS(oc);
1162bcdd781fSPhilippe Mathieu-Daudé Sun4mMachineClass *smc = SUN4M_MACHINE_CLASS(mc);
1163bcdd781fSPhilippe Mathieu-Daudé static const struct sun4m_hwdef ss10_hwdef = {
116453018216SPaolo Bonzini .iommu_base = 0xfe0000000ULL,
116553018216SPaolo Bonzini .tcx_base = 0xe20000000ULL,
116653018216SPaolo Bonzini .slavio_base = 0xff0000000ULL,
116753018216SPaolo Bonzini .ms_kb_base = 0xff1000000ULL,
116853018216SPaolo Bonzini .serial_base = 0xff1100000ULL,
116953018216SPaolo Bonzini .nvram_base = 0xff1200000ULL,
117053018216SPaolo Bonzini .fd_base = 0xff1700000ULL,
117153018216SPaolo Bonzini .counter_base = 0xff1300000ULL,
117253018216SPaolo Bonzini .intctl_base = 0xff1400000ULL,
117353018216SPaolo Bonzini .idreg_base = 0xef0000000ULL,
117453018216SPaolo Bonzini .dma_base = 0xef0400000ULL,
117553018216SPaolo Bonzini .esp_base = 0xef0800000ULL,
117653018216SPaolo Bonzini .le_base = 0xef0c00000ULL,
117741db3b77SPhilippe Mathieu-Daudé .apc_base = 0xefa000000ULL, /* XXX should not exist */
117853018216SPaolo Bonzini .aux1_base = 0xff1800000ULL,
117953018216SPaolo Bonzini .aux2_base = 0xff1a01000ULL,
118053018216SPaolo Bonzini .ecc_base = 0xf00000000ULL,
118141db3b77SPhilippe Mathieu-Daudé .ecc_version = 0x10000000, /* version 0, implementation 1 */
118253018216SPaolo Bonzini .nvram_machine_id = 0x72,
118353018216SPaolo Bonzini .machine_id = ss10_id,
118453018216SPaolo Bonzini .iommu_version = 0x03000000,
118553018216SPaolo Bonzini .max_mem = 0xf00000000ULL,
1186bcdd781fSPhilippe Mathieu-Daudé };
1187bcdd781fSPhilippe Mathieu-Daudé
1188bcdd781fSPhilippe Mathieu-Daudé mc->desc = "Sun4m platform, SPARCstation 10";
1189bcdd781fSPhilippe Mathieu-Daudé mc->max_cpus = 4;
1190bcdd781fSPhilippe Mathieu-Daudé mc->default_cpu_type = SPARC_CPU_TYPE_NAME("TI-SuperSparc-II");
1191bcdd781fSPhilippe Mathieu-Daudé smc->hwdef = &ss10_hwdef;
1192bcdd781fSPhilippe Mathieu-Daudé }
1193bcdd781fSPhilippe Mathieu-Daudé
ss600mp_class_init(ObjectClass * oc,void * data)1194bcdd781fSPhilippe Mathieu-Daudé static void ss600mp_class_init(ObjectClass *oc, void *data)
119553018216SPaolo Bonzini {
1196bcdd781fSPhilippe Mathieu-Daudé MachineClass *mc = MACHINE_CLASS(oc);
1197bcdd781fSPhilippe Mathieu-Daudé Sun4mMachineClass *smc = SUN4M_MACHINE_CLASS(mc);
1198bcdd781fSPhilippe Mathieu-Daudé static const struct sun4m_hwdef ss600mp_hwdef = {
119953018216SPaolo Bonzini .iommu_base = 0xfe0000000ULL,
120053018216SPaolo Bonzini .tcx_base = 0xe20000000ULL,
120153018216SPaolo Bonzini .slavio_base = 0xff0000000ULL,
120253018216SPaolo Bonzini .ms_kb_base = 0xff1000000ULL,
120353018216SPaolo Bonzini .serial_base = 0xff1100000ULL,
120453018216SPaolo Bonzini .nvram_base = 0xff1200000ULL,
120553018216SPaolo Bonzini .counter_base = 0xff1300000ULL,
120653018216SPaolo Bonzini .intctl_base = 0xff1400000ULL,
120753018216SPaolo Bonzini .dma_base = 0xef0081000ULL,
120853018216SPaolo Bonzini .esp_base = 0xef0080000ULL,
120953018216SPaolo Bonzini .le_base = 0xef0060000ULL,
121041db3b77SPhilippe Mathieu-Daudé .apc_base = 0xefa000000ULL, /* XXX should not exist */
121153018216SPaolo Bonzini .aux1_base = 0xff1800000ULL,
121241db3b77SPhilippe Mathieu-Daudé .aux2_base = 0xff1a01000ULL, /* XXX should not exist */
121353018216SPaolo Bonzini .ecc_base = 0xf00000000ULL,
121441db3b77SPhilippe Mathieu-Daudé .ecc_version = 0x00000000, /* version 0, implementation 0 */
121553018216SPaolo Bonzini .nvram_machine_id = 0x71,
121653018216SPaolo Bonzini .machine_id = ss600mp_id,
121753018216SPaolo Bonzini .iommu_version = 0x01000000,
121853018216SPaolo Bonzini .max_mem = 0xf00000000ULL,
1219bcdd781fSPhilippe Mathieu-Daudé };
1220bcdd781fSPhilippe Mathieu-Daudé
1221bcdd781fSPhilippe Mathieu-Daudé mc->desc = "Sun4m platform, SPARCserver 600MP";
1222bcdd781fSPhilippe Mathieu-Daudé mc->max_cpus = 4;
1223bcdd781fSPhilippe Mathieu-Daudé mc->default_cpu_type = SPARC_CPU_TYPE_NAME("TI-SuperSparc-II");
1224bcdd781fSPhilippe Mathieu-Daudé smc->hwdef = &ss600mp_hwdef;
1225bcdd781fSPhilippe Mathieu-Daudé }
1226bcdd781fSPhilippe Mathieu-Daudé
ss20_class_init(ObjectClass * oc,void * data)1227bcdd781fSPhilippe Mathieu-Daudé static void ss20_class_init(ObjectClass *oc, void *data)
122853018216SPaolo Bonzini {
1229bcdd781fSPhilippe Mathieu-Daudé MachineClass *mc = MACHINE_CLASS(oc);
1230bcdd781fSPhilippe Mathieu-Daudé Sun4mMachineClass *smc = SUN4M_MACHINE_CLASS(mc);
1231bcdd781fSPhilippe Mathieu-Daudé static const struct sun4m_hwdef ss20_hwdef = {
123253018216SPaolo Bonzini .iommu_base = 0xfe0000000ULL,
123353018216SPaolo Bonzini .tcx_base = 0xe20000000ULL,
123453018216SPaolo Bonzini .slavio_base = 0xff0000000ULL,
123553018216SPaolo Bonzini .ms_kb_base = 0xff1000000ULL,
123653018216SPaolo Bonzini .serial_base = 0xff1100000ULL,
123753018216SPaolo Bonzini .nvram_base = 0xff1200000ULL,
123853018216SPaolo Bonzini .fd_base = 0xff1700000ULL,
123953018216SPaolo Bonzini .counter_base = 0xff1300000ULL,
124053018216SPaolo Bonzini .intctl_base = 0xff1400000ULL,
124153018216SPaolo Bonzini .idreg_base = 0xef0000000ULL,
124253018216SPaolo Bonzini .dma_base = 0xef0400000ULL,
124353018216SPaolo Bonzini .esp_base = 0xef0800000ULL,
124453018216SPaolo Bonzini .le_base = 0xef0c00000ULL,
124553018216SPaolo Bonzini .bpp_base = 0xef4800000ULL,
124641db3b77SPhilippe Mathieu-Daudé .apc_base = 0xefa000000ULL, /* XXX should not exist */
124753018216SPaolo Bonzini .aux1_base = 0xff1800000ULL,
124853018216SPaolo Bonzini .aux2_base = 0xff1a01000ULL,
124953018216SPaolo Bonzini .dbri_base = 0xee0000000ULL,
125053018216SPaolo Bonzini .sx_base = 0xf80000000ULL,
125153018216SPaolo Bonzini .vsimm = {
125253018216SPaolo Bonzini {
125353018216SPaolo Bonzini .reg_base = 0x9c000000ULL,
125453018216SPaolo Bonzini .vram_base = 0xfc000000ULL
125553018216SPaolo Bonzini }, {
125653018216SPaolo Bonzini .reg_base = 0x90000000ULL,
125753018216SPaolo Bonzini .vram_base = 0xf0000000ULL
125853018216SPaolo Bonzini }, {
125953018216SPaolo Bonzini .reg_base = 0x94000000ULL
126053018216SPaolo Bonzini }, {
126153018216SPaolo Bonzini .reg_base = 0x98000000ULL
126253018216SPaolo Bonzini }
126353018216SPaolo Bonzini },
126453018216SPaolo Bonzini .ecc_base = 0xf00000000ULL,
126541db3b77SPhilippe Mathieu-Daudé .ecc_version = 0x20000000, /* version 0, implementation 2 */
126653018216SPaolo Bonzini .nvram_machine_id = 0x72,
126753018216SPaolo Bonzini .machine_id = ss20_id,
126853018216SPaolo Bonzini .iommu_version = 0x13000000,
126953018216SPaolo Bonzini .max_mem = 0xf00000000ULL,
1270bcdd781fSPhilippe Mathieu-Daudé };
1271bcdd781fSPhilippe Mathieu-Daudé
1272bcdd781fSPhilippe Mathieu-Daudé mc->desc = "Sun4m platform, SPARCstation 20";
1273bcdd781fSPhilippe Mathieu-Daudé mc->max_cpus = 4;
1274bcdd781fSPhilippe Mathieu-Daudé mc->default_cpu_type = SPARC_CPU_TYPE_NAME("TI-SuperSparc-II");
1275bcdd781fSPhilippe Mathieu-Daudé smc->hwdef = &ss20_hwdef;
1276bcdd781fSPhilippe Mathieu-Daudé }
1277bcdd781fSPhilippe Mathieu-Daudé
voyager_class_init(ObjectClass * oc,void * data)1278bcdd781fSPhilippe Mathieu-Daudé static void voyager_class_init(ObjectClass *oc, void *data)
127953018216SPaolo Bonzini {
1280bcdd781fSPhilippe Mathieu-Daudé MachineClass *mc = MACHINE_CLASS(oc);
1281bcdd781fSPhilippe Mathieu-Daudé Sun4mMachineClass *smc = SUN4M_MACHINE_CLASS(mc);
1282bcdd781fSPhilippe Mathieu-Daudé static const struct sun4m_hwdef voyager_hwdef = {
128353018216SPaolo Bonzini .iommu_base = 0x10000000,
128453018216SPaolo Bonzini .tcx_base = 0x50000000,
128553018216SPaolo Bonzini .slavio_base = 0x70000000,
128653018216SPaolo Bonzini .ms_kb_base = 0x71000000,
128753018216SPaolo Bonzini .serial_base = 0x71100000,
128853018216SPaolo Bonzini .nvram_base = 0x71200000,
128953018216SPaolo Bonzini .fd_base = 0x71400000,
129053018216SPaolo Bonzini .counter_base = 0x71d00000,
129153018216SPaolo Bonzini .intctl_base = 0x71e00000,
129253018216SPaolo Bonzini .idreg_base = 0x78000000,
129353018216SPaolo Bonzini .dma_base = 0x78400000,
129453018216SPaolo Bonzini .esp_base = 0x78800000,
129553018216SPaolo Bonzini .le_base = 0x78c00000,
129641db3b77SPhilippe Mathieu-Daudé .apc_base = 0x71300000, /* pmc */
129753018216SPaolo Bonzini .aux1_base = 0x71900000,
129853018216SPaolo Bonzini .aux2_base = 0x71910000,
129953018216SPaolo Bonzini .nvram_machine_id = 0x80,
130053018216SPaolo Bonzini .machine_id = vger_id,
130153018216SPaolo Bonzini .iommu_version = 0x05000000,
130253018216SPaolo Bonzini .max_mem = 0x10000000,
1303bcdd781fSPhilippe Mathieu-Daudé };
1304bcdd781fSPhilippe Mathieu-Daudé
1305bcdd781fSPhilippe Mathieu-Daudé mc->desc = "Sun4m platform, SPARCstation Voyager";
1306bcdd781fSPhilippe Mathieu-Daudé mc->default_cpu_type = SPARC_CPU_TYPE_NAME("Fujitsu-MB86904");
1307bcdd781fSPhilippe Mathieu-Daudé smc->hwdef = &voyager_hwdef;
1308bcdd781fSPhilippe Mathieu-Daudé }
1309bcdd781fSPhilippe Mathieu-Daudé
ss_lx_class_init(ObjectClass * oc,void * data)1310bcdd781fSPhilippe Mathieu-Daudé static void ss_lx_class_init(ObjectClass *oc, void *data)
131153018216SPaolo Bonzini {
1312bcdd781fSPhilippe Mathieu-Daudé MachineClass *mc = MACHINE_CLASS(oc);
1313bcdd781fSPhilippe Mathieu-Daudé Sun4mMachineClass *smc = SUN4M_MACHINE_CLASS(mc);
1314bcdd781fSPhilippe Mathieu-Daudé static const struct sun4m_hwdef ss_lx_hwdef = {
131553018216SPaolo Bonzini .iommu_base = 0x10000000,
131653018216SPaolo Bonzini .iommu_pad_base = 0x10004000,
131753018216SPaolo Bonzini .iommu_pad_len = 0x0fffb000,
131853018216SPaolo Bonzini .tcx_base = 0x50000000,
131953018216SPaolo Bonzini .slavio_base = 0x70000000,
132053018216SPaolo Bonzini .ms_kb_base = 0x71000000,
132153018216SPaolo Bonzini .serial_base = 0x71100000,
132253018216SPaolo Bonzini .nvram_base = 0x71200000,
132353018216SPaolo Bonzini .fd_base = 0x71400000,
132453018216SPaolo Bonzini .counter_base = 0x71d00000,
132553018216SPaolo Bonzini .intctl_base = 0x71e00000,
132653018216SPaolo Bonzini .idreg_base = 0x78000000,
132753018216SPaolo Bonzini .dma_base = 0x78400000,
132853018216SPaolo Bonzini .esp_base = 0x78800000,
132953018216SPaolo Bonzini .le_base = 0x78c00000,
133053018216SPaolo Bonzini .aux1_base = 0x71900000,
133153018216SPaolo Bonzini .aux2_base = 0x71910000,
133253018216SPaolo Bonzini .nvram_machine_id = 0x80,
133353018216SPaolo Bonzini .machine_id = lx_id,
133453018216SPaolo Bonzini .iommu_version = 0x04000000,
133553018216SPaolo Bonzini .max_mem = 0x10000000,
1336bcdd781fSPhilippe Mathieu-Daudé };
1337bcdd781fSPhilippe Mathieu-Daudé
1338bcdd781fSPhilippe Mathieu-Daudé mc->desc = "Sun4m platform, SPARCstation LX";
1339bcdd781fSPhilippe Mathieu-Daudé mc->default_cpu_type = SPARC_CPU_TYPE_NAME("TI-MicroSparc-I");
1340bcdd781fSPhilippe Mathieu-Daudé smc->hwdef = &ss_lx_hwdef;
1341bcdd781fSPhilippe Mathieu-Daudé }
1342bcdd781fSPhilippe Mathieu-Daudé
ss4_class_init(ObjectClass * oc,void * data)1343bcdd781fSPhilippe Mathieu-Daudé static void ss4_class_init(ObjectClass *oc, void *data)
134453018216SPaolo Bonzini {
1345bcdd781fSPhilippe Mathieu-Daudé MachineClass *mc = MACHINE_CLASS(oc);
1346bcdd781fSPhilippe Mathieu-Daudé Sun4mMachineClass *smc = SUN4M_MACHINE_CLASS(mc);
1347bcdd781fSPhilippe Mathieu-Daudé static const struct sun4m_hwdef ss4_hwdef = {
134853018216SPaolo Bonzini .iommu_base = 0x10000000,
134953018216SPaolo Bonzini .tcx_base = 0x50000000,
135053018216SPaolo Bonzini .cs_base = 0x6c000000,
135153018216SPaolo Bonzini .slavio_base = 0x70000000,
135253018216SPaolo Bonzini .ms_kb_base = 0x71000000,
135353018216SPaolo Bonzini .serial_base = 0x71100000,
135453018216SPaolo Bonzini .nvram_base = 0x71200000,
135553018216SPaolo Bonzini .fd_base = 0x71400000,
135653018216SPaolo Bonzini .counter_base = 0x71d00000,
135753018216SPaolo Bonzini .intctl_base = 0x71e00000,
135853018216SPaolo Bonzini .idreg_base = 0x78000000,
135953018216SPaolo Bonzini .dma_base = 0x78400000,
136053018216SPaolo Bonzini .esp_base = 0x78800000,
136153018216SPaolo Bonzini .le_base = 0x78c00000,
136253018216SPaolo Bonzini .apc_base = 0x6a000000,
136353018216SPaolo Bonzini .aux1_base = 0x71900000,
136453018216SPaolo Bonzini .aux2_base = 0x71910000,
136553018216SPaolo Bonzini .nvram_machine_id = 0x80,
136653018216SPaolo Bonzini .machine_id = ss4_id,
136753018216SPaolo Bonzini .iommu_version = 0x05000000,
136853018216SPaolo Bonzini .max_mem = 0x10000000,
1369bcdd781fSPhilippe Mathieu-Daudé };
1370bcdd781fSPhilippe Mathieu-Daudé
1371bcdd781fSPhilippe Mathieu-Daudé mc->desc = "Sun4m platform, SPARCstation 4";
1372bcdd781fSPhilippe Mathieu-Daudé mc->default_cpu_type = SPARC_CPU_TYPE_NAME("Fujitsu-MB86904");
1373bcdd781fSPhilippe Mathieu-Daudé smc->hwdef = &ss4_hwdef;
1374bcdd781fSPhilippe Mathieu-Daudé }
1375bcdd781fSPhilippe Mathieu-Daudé
scls_class_init(ObjectClass * oc,void * data)1376bcdd781fSPhilippe Mathieu-Daudé static void scls_class_init(ObjectClass *oc, void *data)
137753018216SPaolo Bonzini {
1378bcdd781fSPhilippe Mathieu-Daudé MachineClass *mc = MACHINE_CLASS(oc);
1379bcdd781fSPhilippe Mathieu-Daudé Sun4mMachineClass *smc = SUN4M_MACHINE_CLASS(mc);
1380bcdd781fSPhilippe Mathieu-Daudé static const struct sun4m_hwdef scls_hwdef = {
138153018216SPaolo Bonzini .iommu_base = 0x10000000,
138253018216SPaolo Bonzini .tcx_base = 0x50000000,
138353018216SPaolo Bonzini .slavio_base = 0x70000000,
138453018216SPaolo Bonzini .ms_kb_base = 0x71000000,
138553018216SPaolo Bonzini .serial_base = 0x71100000,
138653018216SPaolo Bonzini .nvram_base = 0x71200000,
138753018216SPaolo Bonzini .fd_base = 0x71400000,
138853018216SPaolo Bonzini .counter_base = 0x71d00000,
138953018216SPaolo Bonzini .intctl_base = 0x71e00000,
139053018216SPaolo Bonzini .idreg_base = 0x78000000,
139153018216SPaolo Bonzini .dma_base = 0x78400000,
139253018216SPaolo Bonzini .esp_base = 0x78800000,
139353018216SPaolo Bonzini .le_base = 0x78c00000,
139453018216SPaolo Bonzini .apc_base = 0x6a000000,
139553018216SPaolo Bonzini .aux1_base = 0x71900000,
139653018216SPaolo Bonzini .aux2_base = 0x71910000,
139753018216SPaolo Bonzini .nvram_machine_id = 0x80,
139853018216SPaolo Bonzini .machine_id = scls_id,
139953018216SPaolo Bonzini .iommu_version = 0x05000000,
140053018216SPaolo Bonzini .max_mem = 0x10000000,
1401bcdd781fSPhilippe Mathieu-Daudé };
1402bcdd781fSPhilippe Mathieu-Daudé
1403bcdd781fSPhilippe Mathieu-Daudé mc->desc = "Sun4m platform, SPARCClassic";
1404bcdd781fSPhilippe Mathieu-Daudé mc->default_cpu_type = SPARC_CPU_TYPE_NAME("TI-MicroSparc-I");
1405bcdd781fSPhilippe Mathieu-Daudé smc->hwdef = &scls_hwdef;
1406bcdd781fSPhilippe Mathieu-Daudé }
1407bcdd781fSPhilippe Mathieu-Daudé
sbook_class_init(ObjectClass * oc,void * data)1408bcdd781fSPhilippe Mathieu-Daudé static void sbook_class_init(ObjectClass *oc, void *data)
140953018216SPaolo Bonzini {
1410bcdd781fSPhilippe Mathieu-Daudé MachineClass *mc = MACHINE_CLASS(oc);
1411bcdd781fSPhilippe Mathieu-Daudé Sun4mMachineClass *smc = SUN4M_MACHINE_CLASS(mc);
1412bcdd781fSPhilippe Mathieu-Daudé static const struct sun4m_hwdef sbook_hwdef = {
141353018216SPaolo Bonzini .iommu_base = 0x10000000,
141441db3b77SPhilippe Mathieu-Daudé .tcx_base = 0x50000000, /* XXX */
141553018216SPaolo Bonzini .slavio_base = 0x70000000,
141653018216SPaolo Bonzini .ms_kb_base = 0x71000000,
141753018216SPaolo Bonzini .serial_base = 0x71100000,
141853018216SPaolo Bonzini .nvram_base = 0x71200000,
141953018216SPaolo Bonzini .fd_base = 0x71400000,
142053018216SPaolo Bonzini .counter_base = 0x71d00000,
142153018216SPaolo Bonzini .intctl_base = 0x71e00000,
142253018216SPaolo Bonzini .idreg_base = 0x78000000,
142353018216SPaolo Bonzini .dma_base = 0x78400000,
142453018216SPaolo Bonzini .esp_base = 0x78800000,
142553018216SPaolo Bonzini .le_base = 0x78c00000,
142653018216SPaolo Bonzini .apc_base = 0x6a000000,
142753018216SPaolo Bonzini .aux1_base = 0x71900000,
142853018216SPaolo Bonzini .aux2_base = 0x71910000,
142953018216SPaolo Bonzini .nvram_machine_id = 0x80,
143053018216SPaolo Bonzini .machine_id = sbook_id,
143153018216SPaolo Bonzini .iommu_version = 0x05000000,
143253018216SPaolo Bonzini .max_mem = 0x10000000,
143353018216SPaolo Bonzini };
143453018216SPaolo Bonzini
1435e264d29dSEduardo Habkost mc->desc = "Sun4m platform, SPARCbook";
143649cbd887SIgor Mammedov mc->default_cpu_type = SPARC_CPU_TYPE_NAME("TI-MicroSparc-I");
1437bcdd781fSPhilippe Mathieu-Daudé smc->hwdef = &sbook_hwdef;
1438e264d29dSEduardo Habkost }
1439e264d29dSEduardo Habkost
1440355eb81aSPhilippe Mathieu-Daudé static const TypeInfo sun4m_machine_types[] = {
1441355eb81aSPhilippe Mathieu-Daudé {
1442355eb81aSPhilippe Mathieu-Daudé .name = MACHINE_TYPE_NAME("SS-5"),
1443355eb81aSPhilippe Mathieu-Daudé .parent = TYPE_SUN4M_MACHINE,
1444355eb81aSPhilippe Mathieu-Daudé .class_init = ss5_class_init,
1445355eb81aSPhilippe Mathieu-Daudé }, {
1446355eb81aSPhilippe Mathieu-Daudé .name = MACHINE_TYPE_NAME("SS-10"),
1447355eb81aSPhilippe Mathieu-Daudé .parent = TYPE_SUN4M_MACHINE,
1448355eb81aSPhilippe Mathieu-Daudé .class_init = ss10_class_init,
1449355eb81aSPhilippe Mathieu-Daudé }, {
1450355eb81aSPhilippe Mathieu-Daudé .name = MACHINE_TYPE_NAME("SS-600MP"),
1451355eb81aSPhilippe Mathieu-Daudé .parent = TYPE_SUN4M_MACHINE,
1452355eb81aSPhilippe Mathieu-Daudé .class_init = ss600mp_class_init,
1453355eb81aSPhilippe Mathieu-Daudé }, {
1454355eb81aSPhilippe Mathieu-Daudé .name = MACHINE_TYPE_NAME("SS-20"),
1455355eb81aSPhilippe Mathieu-Daudé .parent = TYPE_SUN4M_MACHINE,
1456355eb81aSPhilippe Mathieu-Daudé .class_init = ss20_class_init,
1457355eb81aSPhilippe Mathieu-Daudé }, {
1458355eb81aSPhilippe Mathieu-Daudé .name = MACHINE_TYPE_NAME("Voyager"),
1459355eb81aSPhilippe Mathieu-Daudé .parent = TYPE_SUN4M_MACHINE,
1460355eb81aSPhilippe Mathieu-Daudé .class_init = voyager_class_init,
1461355eb81aSPhilippe Mathieu-Daudé }, {
1462355eb81aSPhilippe Mathieu-Daudé .name = MACHINE_TYPE_NAME("LX"),
1463355eb81aSPhilippe Mathieu-Daudé .parent = TYPE_SUN4M_MACHINE,
1464355eb81aSPhilippe Mathieu-Daudé .class_init = ss_lx_class_init,
1465355eb81aSPhilippe Mathieu-Daudé }, {
1466355eb81aSPhilippe Mathieu-Daudé .name = MACHINE_TYPE_NAME("SS-4"),
1467355eb81aSPhilippe Mathieu-Daudé .parent = TYPE_SUN4M_MACHINE,
1468355eb81aSPhilippe Mathieu-Daudé .class_init = ss4_class_init,
1469355eb81aSPhilippe Mathieu-Daudé }, {
1470355eb81aSPhilippe Mathieu-Daudé .name = MACHINE_TYPE_NAME("SPARCClassic"),
1471355eb81aSPhilippe Mathieu-Daudé .parent = TYPE_SUN4M_MACHINE,
1472355eb81aSPhilippe Mathieu-Daudé .class_init = scls_class_init,
1473355eb81aSPhilippe Mathieu-Daudé }, {
14748a661aeaSAndreas Färber .name = MACHINE_TYPE_NAME("SPARCbook"),
1475828d01b7SPhilippe Mathieu-Daudé .parent = TYPE_SUN4M_MACHINE,
14768a661aeaSAndreas Färber .class_init = sbook_class_init,
1477355eb81aSPhilippe Mathieu-Daudé }, {
1478828d01b7SPhilippe Mathieu-Daudé .name = TYPE_SUN4M_MACHINE,
1479828d01b7SPhilippe Mathieu-Daudé .parent = TYPE_MACHINE,
148095bc47deSPhilippe Mathieu-Daudé .class_size = sizeof(Sun4mMachineClass),
1481f55e8977SPhilippe Mathieu-Daudé .class_init = sun4m_machine_class_init,
1482828d01b7SPhilippe Mathieu-Daudé .abstract = true,
1483828d01b7SPhilippe Mathieu-Daudé }
1484828d01b7SPhilippe Mathieu-Daudé };
1485828d01b7SPhilippe Mathieu-Daudé
DEFINE_TYPES(sun4m_machine_types)1486828d01b7SPhilippe Mathieu-Daudé DEFINE_TYPES(sun4m_machine_types)
1487828d01b7SPhilippe Mathieu-Daudé
148853018216SPaolo Bonzini static void sun4m_register_types(void)
148953018216SPaolo Bonzini {
149053018216SPaolo Bonzini type_register_static(&idreg_info);
149153018216SPaolo Bonzini type_register_static(&afx_info);
149253018216SPaolo Bonzini type_register_static(&prom_info);
149353018216SPaolo Bonzini type_register_static(&ram_info);
14948a661aeaSAndreas Färber }
14958a661aeaSAndreas Färber
149653018216SPaolo Bonzini type_init(sun4m_register_types)
1497