Statistics
| Branch: | Revision:

root / hw / sun4m.c @ c4470b25

History | View | Annotate | Download (52.2 kB)

1
/*
2
 * QEMU Sun4m & Sun4d & Sun4c System Emulator
3
 *
4
 * Copyright (c) 2003-2005 Fabrice Bellard
5
 *
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:
12
 *
13
 * The above copyright notice and this permission notice shall be included in
14
 * all copies or substantial portions of the Software.
15
 *
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
22
 * THE SOFTWARE.
23
 */
24
#include "sysbus.h"
25
#include "qemu-timer.h"
26
#include "sun4m.h"
27
#include "nvram.h"
28
#include "sparc32_dma.h"
29
#include "fdc.h"
30
#include "sysemu.h"
31
#include "net.h"
32
#include "boards.h"
33
#include "firmware_abi.h"
34
#include "scsi.h"
35
#include "pc.h"
36
#include "isa.h"
37
#include "fw_cfg.h"
38
#include "escc.h"
39
#include "qdev-addr.h"
40

    
41
//#define DEBUG_IRQ
42

    
43
/*
44
 * Sun4m architecture was used in the following machines:
45
 *
46
 * SPARCserver 6xxMP/xx
47
 * SPARCclassic (SPARCclassic Server)(SPARCstation LC) (4/15),
48
 * SPARCclassic X (4/10)
49
 * SPARCstation LX/ZX (4/30)
50
 * SPARCstation Voyager
51
 * SPARCstation 10/xx, SPARCserver 10/xx
52
 * SPARCstation 5, SPARCserver 5
53
 * SPARCstation 20/xx, SPARCserver 20
54
 * SPARCstation 4
55
 *
56
 * Sun4d architecture was used in the following machines:
57
 *
58
 * SPARCcenter 2000
59
 * SPARCserver 1000
60
 *
61
 * Sun4c architecture was used in the following machines:
62
 * SPARCstation 1/1+, SPARCserver 1/1+
63
 * SPARCstation SLC
64
 * SPARCstation IPC
65
 * SPARCstation ELC
66
 * SPARCstation IPX
67
 *
68
 * See for example: http://www.sunhelp.org/faq/sunref1.html
69
 */
70

    
71
#ifdef DEBUG_IRQ
72
#define DPRINTF(fmt, ...)                                       \
73
    do { printf("CPUIRQ: " fmt , ## __VA_ARGS__); } while (0)
74
#else
75
#define DPRINTF(fmt, ...)
76
#endif
77

    
78
#define KERNEL_LOAD_ADDR     0x00004000
79
#define CMDLINE_ADDR         0x007ff000
80
#define INITRD_LOAD_ADDR     0x00800000
81
#define PROM_SIZE_MAX        (1024 * 1024)
82
#define PROM_VADDR           0xffd00000
83
#define PROM_FILENAME        "openbios-sparc32"
84
#define CFG_ADDR             0xd00000510ULL
85
#define FW_CFG_SUN4M_DEPTH   (FW_CFG_ARCH_LOCAL + 0x00)
86

    
87
#define MAX_CPUS 16
88
#define MAX_PILS 16
89

    
90
#define ESCC_CLOCK 4915200
91

    
92
struct sun4m_hwdef {
93
    target_phys_addr_t iommu_base, slavio_base;
94
    target_phys_addr_t intctl_base, counter_base, nvram_base, ms_kb_base;
95
    target_phys_addr_t serial_base, fd_base;
96
    target_phys_addr_t idreg_base, dma_base, esp_base, le_base;
97
    target_phys_addr_t tcx_base, cs_base, apc_base, aux1_base, aux2_base;
98
    target_phys_addr_t ecc_base;
99
    uint32_t ecc_version;
100
    uint8_t nvram_machine_id;
101
    uint16_t machine_id;
102
    uint32_t iommu_version;
103
    uint64_t max_mem;
104
    const char * const default_cpu_model;
105
};
106

    
107
#define MAX_IOUNITS 5
108

    
109
struct sun4d_hwdef {
110
    target_phys_addr_t iounit_bases[MAX_IOUNITS], slavio_base;
111
    target_phys_addr_t counter_base, nvram_base, ms_kb_base;
112
    target_phys_addr_t serial_base;
113
    target_phys_addr_t espdma_base, esp_base;
114
    target_phys_addr_t ledma_base, le_base;
115
    target_phys_addr_t tcx_base;
116
    target_phys_addr_t sbi_base;
117
    uint8_t nvram_machine_id;
118
    uint16_t machine_id;
119
    uint32_t iounit_version;
120
    uint64_t max_mem;
121
    const char * const default_cpu_model;
122
};
123

    
124
struct sun4c_hwdef {
125
    target_phys_addr_t iommu_base, slavio_base;
126
    target_phys_addr_t intctl_base, counter_base, nvram_base, ms_kb_base;
127
    target_phys_addr_t serial_base, fd_base;
128
    target_phys_addr_t idreg_base, dma_base, esp_base, le_base;
129
    target_phys_addr_t tcx_base, aux1_base;
130
    uint8_t nvram_machine_id;
131
    uint16_t machine_id;
132
    uint32_t iommu_version;
133
    uint64_t max_mem;
134
    const char * const default_cpu_model;
135
};
136

    
137
int DMA_get_channel_mode (int nchan)
138
{
139
    return 0;
140
}
141
int DMA_read_memory (int nchan, void *buf, int pos, int size)
142
{
143
    return 0;
144
}
145
int DMA_write_memory (int nchan, void *buf, int pos, int size)
146
{
147
    return 0;
148
}
149
void DMA_hold_DREQ (int nchan) {}
150
void DMA_release_DREQ (int nchan) {}
151
void DMA_schedule(int nchan) {}
152
void DMA_init (int high_page_enable) {}
153
void DMA_register_channel (int nchan,
154
                           DMA_transfer_handler transfer_handler,
155
                           void *opaque)
156
{
157
}
158

    
159
static int fw_cfg_boot_set(void *opaque, const char *boot_device)
160
{
161
    fw_cfg_add_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]);
162
    return 0;
163
}
164

    
165
static void nvram_init(m48t59_t *nvram, uint8_t *macaddr, const char *cmdline,
166
                       const char *boot_devices, ram_addr_t RAM_size,
167
                       uint32_t kernel_size,
168
                       int width, int height, int depth,
169
                       int nvram_machine_id, const char *arch)
170
{
171
    unsigned int i;
172
    uint32_t start, end;
173
    uint8_t image[0x1ff0];
174
    struct OpenBIOS_nvpart_v1 *part_header;
175

    
176
    memset(image, '\0', sizeof(image));
177

    
178
    start = 0;
179

    
180
    // OpenBIOS nvram variables
181
    // Variable partition
182
    part_header = (struct OpenBIOS_nvpart_v1 *)&image[start];
183
    part_header->signature = OPENBIOS_PART_SYSTEM;
184
    pstrcpy(part_header->name, sizeof(part_header->name), "system");
185

    
186
    end = start + sizeof(struct OpenBIOS_nvpart_v1);
187
    for (i = 0; i < nb_prom_envs; i++)
188
        end = OpenBIOS_set_var(image, end, prom_envs[i]);
189

    
190
    // End marker
191
    image[end++] = '\0';
192

    
193
    end = start + ((end - start + 15) & ~15);
194
    OpenBIOS_finish_partition(part_header, end - start);
195

    
196
    // free partition
197
    start = end;
198
    part_header = (struct OpenBIOS_nvpart_v1 *)&image[start];
199
    part_header->signature = OPENBIOS_PART_FREE;
200
    pstrcpy(part_header->name, sizeof(part_header->name), "free");
201

    
202
    end = 0x1fd0;
203
    OpenBIOS_finish_partition(part_header, end - start);
204

    
205
    Sun_init_header((struct Sun_nvram *)&image[0x1fd8], macaddr,
206
                    nvram_machine_id);
207

    
208
    for (i = 0; i < sizeof(image); i++)
209
        m48t59_write(nvram, i, image[i]);
210
}
211

    
212
static void *slavio_intctl;
213

    
214
void pic_info(Monitor *mon)
215
{
216
    if (slavio_intctl)
217
        slavio_pic_info(mon, slavio_intctl);
218
}
219

    
220
void irq_info(Monitor *mon)
221
{
222
    if (slavio_intctl)
223
        slavio_irq_info(mon, slavio_intctl);
224
}
225

    
226
void cpu_check_irqs(CPUState *env)
227
{
228
    if (env->pil_in && (env->interrupt_index == 0 ||
229
                        (env->interrupt_index & ~15) == TT_EXTINT)) {
230
        unsigned int i;
231

    
232
        for (i = 15; i > 0; i--) {
233
            if (env->pil_in & (1 << i)) {
234
                int old_interrupt = env->interrupt_index;
235

    
236
                env->interrupt_index = TT_EXTINT | i;
237
                if (old_interrupt != env->interrupt_index) {
238
                    DPRINTF("Set CPU IRQ %d\n", i);
239
                    cpu_interrupt(env, CPU_INTERRUPT_HARD);
240
                }
241
                break;
242
            }
243
        }
244
    } else if (!env->pil_in && (env->interrupt_index & ~15) == TT_EXTINT) {
245
        DPRINTF("Reset CPU IRQ %d\n", env->interrupt_index & 15);
246
        env->interrupt_index = 0;
247
        cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
248
    }
249
}
250

    
251
static void cpu_set_irq(void *opaque, int irq, int level)
252
{
253
    CPUState *env = opaque;
254

    
255
    if (level) {
256
        DPRINTF("Raise CPU IRQ %d\n", irq);
257
        env->halted = 0;
258
        env->pil_in |= 1 << irq;
259
        cpu_check_irqs(env);
260
    } else {
261
        DPRINTF("Lower CPU IRQ %d\n", irq);
262
        env->pil_in &= ~(1 << irq);
263
        cpu_check_irqs(env);
264
    }
265
}
266

    
267
static void dummy_cpu_set_irq(void *opaque, int irq, int level)
268
{
269
}
270

    
271
static void main_cpu_reset(void *opaque)
272
{
273
    CPUState *env = opaque;
274

    
275
    cpu_reset(env);
276
    env->halted = 0;
277
}
278

    
279
static void secondary_cpu_reset(void *opaque)
280
{
281
    CPUState *env = opaque;
282

    
283
    cpu_reset(env);
284
    env->halted = 1;
285
}
286

    
287
static void cpu_halt_signal(void *opaque, int irq, int level)
288
{
289
    if (level && cpu_single_env)
290
        cpu_interrupt(cpu_single_env, CPU_INTERRUPT_HALT);
291
}
292

    
293
static unsigned long sun4m_load_kernel(const char *kernel_filename,
294
                                       const char *initrd_filename,
295
                                       ram_addr_t RAM_size)
296
{
297
    int linux_boot;
298
    unsigned int i;
299
    long initrd_size, kernel_size;
300

    
301
    linux_boot = (kernel_filename != NULL);
302

    
303
    kernel_size = 0;
304
    if (linux_boot) {
305
        kernel_size = load_elf(kernel_filename, -0xf0000000ULL, NULL, NULL,
306
                               NULL);
307
        if (kernel_size < 0)
308
            kernel_size = load_aout(kernel_filename, KERNEL_LOAD_ADDR,
309
                                    RAM_size - KERNEL_LOAD_ADDR);
310
        if (kernel_size < 0)
311
            kernel_size = load_image_targphys(kernel_filename,
312
                                              KERNEL_LOAD_ADDR,
313
                                              RAM_size - KERNEL_LOAD_ADDR);
314
        if (kernel_size < 0) {
315
            fprintf(stderr, "qemu: could not load kernel '%s'\n",
316
                    kernel_filename);
317
            exit(1);
318
        }
319

    
320
        /* load initrd */
321
        initrd_size = 0;
322
        if (initrd_filename) {
323
            initrd_size = load_image_targphys(initrd_filename,
324
                                              INITRD_LOAD_ADDR,
325
                                              RAM_size - INITRD_LOAD_ADDR);
326
            if (initrd_size < 0) {
327
                fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
328
                        initrd_filename);
329
                exit(1);
330
            }
331
        }
332
        if (initrd_size > 0) {
333
            for (i = 0; i < 64 * TARGET_PAGE_SIZE; i += TARGET_PAGE_SIZE) {
334
                if (ldl_phys(KERNEL_LOAD_ADDR + i) == 0x48647253) { // HdrS
335
                    stl_phys(KERNEL_LOAD_ADDR + i + 16, INITRD_LOAD_ADDR);
336
                    stl_phys(KERNEL_LOAD_ADDR + i + 20, initrd_size);
337
                    break;
338
                }
339
            }
340
        }
341
    }
342
    return kernel_size;
343
}
344

    
345
static void *iommu_init(target_phys_addr_t addr, uint32_t version, qemu_irq irq)
346
{
347
    DeviceState *dev;
348
    SysBusDevice *s;
349

    
350
    dev = qdev_create(NULL, "iommu");
351
    qdev_prop_set_uint32(dev, "version", version);
352
    qdev_init(dev);
353
    s = sysbus_from_qdev(dev);
354
    sysbus_connect_irq(s, 0, irq);
355
    sysbus_mmio_map(s, 0, addr);
356

    
357
    return s;
358
}
359

    
360
static void *sparc32_dma_init(target_phys_addr_t daddr, qemu_irq parent_irq,
361
                              void *iommu, qemu_irq *dev_irq)
362
{
363
    DeviceState *dev;
364
    SysBusDevice *s;
365

    
366
    dev = qdev_create(NULL, "sparc32_dma");
367
    qdev_prop_set_ptr(dev, "iommu_opaque", iommu);
368
    qdev_init(dev);
369
    s = sysbus_from_qdev(dev);
370
    sysbus_connect_irq(s, 0, parent_irq);
371
    *dev_irq = qdev_get_gpio_in(dev, 0);
372
    sysbus_mmio_map(s, 0, daddr);
373

    
374
    return s;
375
}
376

    
377
static void lance_init(NICInfo *nd, target_phys_addr_t leaddr,
378
                       void *dma_opaque, qemu_irq irq)
379
{
380
    DeviceState *dev;
381
    SysBusDevice *s;
382
    qemu_irq reset;
383

    
384
    qemu_check_nic_model(&nd_table[0], "lance");
385

    
386
    dev = qdev_create(NULL, "lance");
387
    dev->nd = nd;
388
    qdev_prop_set_ptr(dev, "dma", dma_opaque);
389
    qdev_init(dev);
390
    s = sysbus_from_qdev(dev);
391
    sysbus_mmio_map(s, 0, leaddr);
392
    sysbus_connect_irq(s, 0, irq);
393
    reset = qdev_get_gpio_in(dev, 0);
394
    qdev_connect_gpio_out(dma_opaque, 0, reset);
395
}
396

    
397
static DeviceState *slavio_intctl_init(target_phys_addr_t addr,
398
                                       target_phys_addr_t addrg,
399
                                       qemu_irq **parent_irq,
400
                                       unsigned int cputimer)
401
{
402
    DeviceState *dev;
403
    SysBusDevice *s;
404
    unsigned int i, j;
405

    
406
    dev = qdev_create(NULL, "slavio_intctl");
407
    qdev_prop_set_uint32(dev, "cputimer_bit", cputimer);
408
    qdev_init(dev);
409

    
410
    s = sysbus_from_qdev(dev);
411

    
412
    for (i = 0; i < MAX_CPUS; i++) {
413
        for (j = 0; j < MAX_PILS; j++) {
414
            sysbus_connect_irq(s, i * MAX_PILS + j, parent_irq[i][j]);
415
        }
416
    }
417
    sysbus_mmio_map(s, 0, addrg);
418
    for (i = 0; i < MAX_CPUS; i++) {
419
        sysbus_mmio_map(s, i + 1, addr + i * TARGET_PAGE_SIZE);
420
    }
421

    
422
    return dev;
423
}
424

    
425
#define SYS_TIMER_OFFSET      0x10000ULL
426
#define CPU_TIMER_OFFSET(cpu) (0x1000ULL * cpu)
427

    
428
static void slavio_timer_init_all(target_phys_addr_t addr, qemu_irq master_irq,
429
                                  qemu_irq *cpu_irqs, unsigned int num_cpus)
430
{
431
    DeviceState *dev;
432
    SysBusDevice *s;
433
    unsigned int i;
434

    
435
    dev = qdev_create(NULL, "slavio_timer");
436
    qdev_prop_set_uint32(dev, "num_cpus", num_cpus);
437
    qdev_init(dev);
438
    s = sysbus_from_qdev(dev);
439
    sysbus_connect_irq(s, 0, master_irq);
440
    sysbus_mmio_map(s, 0, addr + SYS_TIMER_OFFSET);
441

    
442
    for (i = 0; i < MAX_CPUS; i++) {
443
        sysbus_mmio_map(s, i + 1, addr + (target_phys_addr_t)CPU_TIMER_OFFSET(i));
444
        sysbus_connect_irq(s, i + 1, cpu_irqs[i]);
445
    }
446
}
447

    
448
#define MISC_LEDS 0x01600000
449
#define MISC_CFG  0x01800000
450
#define MISC_DIAG 0x01a00000
451
#define MISC_MDM  0x01b00000
452
#define MISC_SYS  0x01f00000
453

    
454
static void slavio_misc_init(target_phys_addr_t base,
455
                             target_phys_addr_t aux1_base,
456
                             target_phys_addr_t aux2_base, qemu_irq irq,
457
                             qemu_irq fdc_tc)
458
{
459
    DeviceState *dev;
460
    SysBusDevice *s;
461

    
462
    dev = qdev_create(NULL, "slavio_misc");
463
    qdev_init(dev);
464
    s = sysbus_from_qdev(dev);
465
    if (base) {
466
        /* 8 bit registers */
467
        /* Slavio control */
468
        sysbus_mmio_map(s, 0, base + MISC_CFG);
469
        /* Diagnostics */
470
        sysbus_mmio_map(s, 1, base + MISC_DIAG);
471
        /* Modem control */
472
        sysbus_mmio_map(s, 2, base + MISC_MDM);
473
        /* 16 bit registers */
474
        /* ss600mp diag LEDs */
475
        sysbus_mmio_map(s, 3, base + MISC_LEDS);
476
        /* 32 bit registers */
477
        /* System control */
478
        sysbus_mmio_map(s, 4, base + MISC_SYS);
479
    }
480
    if (aux1_base) {
481
        /* AUX 1 (Misc System Functions) */
482
        sysbus_mmio_map(s, 5, aux1_base);
483
    }
484
    if (aux2_base) {
485
        /* AUX 2 (Software Powerdown Control) */
486
        sysbus_mmio_map(s, 6, aux2_base);
487
    }
488
    sysbus_connect_irq(s, 0, irq);
489
    sysbus_connect_irq(s, 1, fdc_tc);
490
    qemu_system_powerdown = qdev_get_gpio_in(dev, 0);
491
}
492

    
493
static void ecc_init(target_phys_addr_t base, qemu_irq irq, uint32_t version)
494
{
495
    DeviceState *dev;
496
    SysBusDevice *s;
497

    
498
    dev = qdev_create(NULL, "eccmemctl");
499
    qdev_prop_set_uint32(dev, "version", version);
500
    qdev_init(dev);
501
    s = sysbus_from_qdev(dev);
502
    sysbus_connect_irq(s, 0, irq);
503
    sysbus_mmio_map(s, 0, base);
504
    if (version == 0) { // SS-600MP only
505
        sysbus_mmio_map(s, 1, base + 0x1000);
506
    }
507
}
508

    
509
static void apc_init(target_phys_addr_t power_base, qemu_irq cpu_halt)
510
{
511
    DeviceState *dev;
512
    SysBusDevice *s;
513

    
514
    dev = qdev_create(NULL, "apc");
515
    qdev_init(dev);
516
    s = sysbus_from_qdev(dev);
517
    /* Power management (APC) XXX: not a Slavio device */
518
    sysbus_mmio_map(s, 0, power_base);
519
    sysbus_connect_irq(s, 0, cpu_halt);
520
}
521

    
522
static void tcx_init(target_phys_addr_t addr, int vram_size, int width,
523
                     int height, int depth)
524
{
525
    DeviceState *dev;
526
    SysBusDevice *s;
527

    
528
    dev = qdev_create(NULL, "SUNW,tcx");
529
    qdev_prop_set_taddr(dev, "addr", addr);
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(dev);
535
    s = sysbus_from_qdev(dev);
536
    /* 8-bit plane */
537
    sysbus_mmio_map(s, 0, addr + 0x00800000ULL);
538
    /* DAC */
539
    sysbus_mmio_map(s, 1, addr + 0x00200000ULL);
540
    /* TEC (dummy) */
541
    sysbus_mmio_map(s, 2, addr + 0x00700000ULL);
542
    /* THC 24 bit: NetBSD writes here even with 8-bit display: dummy */
543
    sysbus_mmio_map(s, 3, addr + 0x00301000ULL);
544
    if (depth == 24) {
545
        /* 24-bit plane */
546
        sysbus_mmio_map(s, 4, addr + 0x02000000ULL);
547
        /* Control plane */
548
        sysbus_mmio_map(s, 5, addr + 0x0a000000ULL);
549
    } else {
550
        /* THC 8 bit (dummy) */
551
        sysbus_mmio_map(s, 4, addr + 0x00300000ULL);
552
    }
553
}
554

    
555
/* NCR89C100/MACIO Internal ID register */
556
static const uint8_t idreg_data[] = { 0xfe, 0x81, 0x01, 0x03 };
557

    
558
static void idreg_init(target_phys_addr_t addr)
559
{
560
    DeviceState *dev;
561
    SysBusDevice *s;
562

    
563
    dev = qdev_create(NULL, "macio_idreg");
564
    qdev_init(dev);
565
    s = sysbus_from_qdev(dev);
566

    
567
    sysbus_mmio_map(s, 0, addr);
568
    cpu_physical_memory_write_rom(addr, idreg_data, sizeof(idreg_data));
569
}
570

    
571
static void idreg_init1(SysBusDevice *dev)
572
{
573
    ram_addr_t idreg_offset;
574

    
575
    idreg_offset = qemu_ram_alloc(sizeof(idreg_data));
576
    sysbus_init_mmio(dev, sizeof(idreg_data), idreg_offset | IO_MEM_ROM);
577
}
578

    
579
static SysBusDeviceInfo idreg_info = {
580
    .init = idreg_init1,
581
    .qdev.name  = "macio_idreg",
582
    .qdev.size  = sizeof(SysBusDevice),
583
};
584

    
585
static void idreg_register_devices(void)
586
{
587
    sysbus_register_withprop(&idreg_info);
588
}
589

    
590
device_init(idreg_register_devices);
591

    
592
/* Boot PROM (OpenBIOS) */
593
static void prom_init(target_phys_addr_t addr, const char *bios_name)
594
{
595
    DeviceState *dev;
596
    SysBusDevice *s;
597
    char *filename;
598
    int ret;
599

    
600
    dev = qdev_create(NULL, "openprom");
601
    qdev_init(dev);
602
    s = sysbus_from_qdev(dev);
603

    
604
    sysbus_mmio_map(s, 0, addr);
605

    
606
    /* load boot prom */
607
    if (bios_name == NULL) {
608
        bios_name = PROM_FILENAME;
609
    }
610
    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
611
    if (filename) {
612
        ret = load_elf(filename, addr - PROM_VADDR, NULL, NULL, NULL);
613
        if (ret < 0 || ret > PROM_SIZE_MAX) {
614
            ret = load_image_targphys(filename, addr, PROM_SIZE_MAX);
615
        }
616
        qemu_free(filename);
617
    } else {
618
        ret = -1;
619
    }
620
    if (ret < 0 || ret > PROM_SIZE_MAX) {
621
        fprintf(stderr, "qemu: could not load prom '%s'\n", bios_name);
622
        exit(1);
623
    }
624
}
625

    
626
static void prom_init1(SysBusDevice *dev)
627
{
628
    ram_addr_t prom_offset;
629

    
630
    prom_offset = qemu_ram_alloc(PROM_SIZE_MAX);
631
    sysbus_init_mmio(dev, PROM_SIZE_MAX, prom_offset | IO_MEM_ROM);
632
}
633

    
634
static SysBusDeviceInfo prom_info = {
635
    .init = prom_init1,
636
    .qdev.name  = "openprom",
637
    .qdev.size  = sizeof(SysBusDevice),
638
    .qdev.props = (Property[]) {
639
        {/* end of property list */}
640
    }
641
};
642

    
643
static void prom_register_devices(void)
644
{
645
    sysbus_register_withprop(&prom_info);
646
}
647

    
648
device_init(prom_register_devices);
649

    
650
typedef struct RamDevice
651
{
652
    SysBusDevice busdev;
653
    uint64_t size;
654
} RamDevice;
655

    
656
/* System RAM */
657
static void ram_init1(SysBusDevice *dev)
658
{
659
    ram_addr_t RAM_size, ram_offset;
660
    RamDevice *d = FROM_SYSBUS(RamDevice, dev);
661

    
662
    RAM_size = d->size;
663

    
664
    ram_offset = qemu_ram_alloc(RAM_size);
665
    sysbus_init_mmio(dev, RAM_size, ram_offset);
666
}
667

    
668
static void ram_init(target_phys_addr_t addr, ram_addr_t RAM_size,
669
                     uint64_t max_mem)
670
{
671
    DeviceState *dev;
672
    SysBusDevice *s;
673
    RamDevice *d;
674

    
675
    /* allocate RAM */
676
    if ((uint64_t)RAM_size > max_mem) {
677
        fprintf(stderr,
678
                "qemu: Too much memory for this machine: %d, maximum %d\n",
679
                (unsigned int)(RAM_size / (1024 * 1024)),
680
                (unsigned int)(max_mem / (1024 * 1024)));
681
        exit(1);
682
    }
683
    dev = qdev_create(NULL, "memory");
684
    s = sysbus_from_qdev(dev);
685

    
686
    d = FROM_SYSBUS(RamDevice, s);
687
    d->size = RAM_size;
688
    qdev_init(dev);
689

    
690
    sysbus_mmio_map(s, 0, addr);
691
}
692

    
693
static SysBusDeviceInfo ram_info = {
694
    .init = ram_init1,
695
    .qdev.name  = "memory",
696
    .qdev.size  = sizeof(RamDevice),
697
    .qdev.props = (Property[]) {
698
        DEFINE_PROP_UINT64("size", RamDevice, size, 0),
699
        DEFINE_PROP_END_OF_LIST(),
700
    }
701
};
702

    
703
static void ram_register_devices(void)
704
{
705
    sysbus_register_withprop(&ram_info);
706
}
707

    
708
device_init(ram_register_devices);
709

    
710
static CPUState *cpu_devinit(const char *cpu_model, unsigned int id,
711
                             uint64_t prom_addr, qemu_irq **cpu_irqs)
712
{
713
    CPUState *env;
714

    
715
    env = cpu_init(cpu_model);
716
    if (!env) {
717
        fprintf(stderr, "qemu: Unable to find Sparc CPU definition\n");
718
        exit(1);
719
    }
720

    
721
    cpu_sparc_set_id(env, id);
722
    if (id == 0) {
723
        qemu_register_reset(main_cpu_reset, env);
724
    } else {
725
        qemu_register_reset(secondary_cpu_reset, env);
726
        env->halted = 1;
727
    }
728
    *cpu_irqs = qemu_allocate_irqs(cpu_set_irq, env, MAX_PILS);
729
    env->prom_addr = prom_addr;
730

    
731
    return env;
732
}
733

    
734
static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,
735
                          const char *boot_device,
736
                          const char *kernel_filename,
737
                          const char *kernel_cmdline,
738
                          const char *initrd_filename, const char *cpu_model)
739
{
740
    CPUState *envs[MAX_CPUS];
741
    unsigned int i;
742
    void *iommu, *espdma, *ledma, *nvram;
743
    qemu_irq *cpu_irqs[MAX_CPUS], slavio_irq[32], slavio_cpu_irq[MAX_CPUS],
744
        espdma_irq, ledma_irq;
745
    qemu_irq esp_reset;
746
    qemu_irq fdc_tc;
747
    qemu_irq *cpu_halt;
748
    unsigned long kernel_size;
749
    BlockDriverState *fd[MAX_FD];
750
    void *fw_cfg;
751
    DeviceState *dev;
752
    DriveInfo *dinfo;
753

    
754
    /* init CPUs */
755
    if (!cpu_model)
756
        cpu_model = hwdef->default_cpu_model;
757

    
758
    for(i = 0; i < smp_cpus; i++) {
759
        envs[i] = cpu_devinit(cpu_model, i, hwdef->slavio_base, &cpu_irqs[i]);
760
    }
761

    
762
    for (i = smp_cpus; i < MAX_CPUS; i++)
763
        cpu_irqs[i] = qemu_allocate_irqs(dummy_cpu_set_irq, NULL, MAX_PILS);
764

    
765

    
766
    /* set up devices */
767
    ram_init(0, RAM_size, hwdef->max_mem);
768

    
769
    prom_init(hwdef->slavio_base, bios_name);
770

    
771
    dev = slavio_intctl_init(hwdef->intctl_base,
772
                             hwdef->intctl_base + 0x10000ULL,
773
                             cpu_irqs,
774
                             7);
775

    
776
    for (i = 0; i < 32; i++) {
777
        slavio_irq[i] = qdev_get_gpio_in(dev, i);
778
    }
779
    for (i = 0; i < MAX_CPUS; i++) {
780
        slavio_cpu_irq[i] = qdev_get_gpio_in(dev, 32 + i);
781
    }
782

    
783
    if (hwdef->idreg_base) {
784
        idreg_init(hwdef->idreg_base);
785
    }
786

    
787
    iommu = iommu_init(hwdef->iommu_base, hwdef->iommu_version,
788
                       slavio_irq[30]);
789

    
790
    espdma = sparc32_dma_init(hwdef->dma_base, slavio_irq[18],
791
                              iommu, &espdma_irq);
792

    
793
    ledma = sparc32_dma_init(hwdef->dma_base + 16ULL,
794
                             slavio_irq[16], iommu, &ledma_irq);
795

    
796
    if (graphic_depth != 8 && graphic_depth != 24) {
797
        fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth);
798
        exit (1);
799
    }
800
    tcx_init(hwdef->tcx_base, 0x00100000, graphic_width, graphic_height,
801
             graphic_depth);
802

    
803
    lance_init(&nd_table[0], hwdef->le_base, ledma, ledma_irq);
804

    
805
    nvram = m48t59_init(slavio_irq[0], hwdef->nvram_base, 0, 0x2000, 8);
806

    
807
    slavio_timer_init_all(hwdef->counter_base, slavio_irq[19], slavio_cpu_irq, smp_cpus);
808

    
809
    slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[14],
810
                              display_type == DT_NOGRAPHIC, ESCC_CLOCK, 1);
811
    // Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
812
    // Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
813
    escc_init(hwdef->serial_base, slavio_irq[15], slavio_irq[15],
814
              serial_hds[0], serial_hds[1], ESCC_CLOCK, 1);
815

    
816
    cpu_halt = qemu_allocate_irqs(cpu_halt_signal, NULL, 1);
817
    slavio_misc_init(hwdef->slavio_base, hwdef->aux1_base, hwdef->aux2_base,
818
                     slavio_irq[30], fdc_tc);
819

    
820
    if (hwdef->apc_base) {
821
        apc_init(hwdef->apc_base, cpu_halt[0]);
822
    }
823

    
824
    if (hwdef->fd_base) {
825
        /* there is zero or one floppy drive */
826
        memset(fd, 0, sizeof(fd));
827
        dinfo = drive_get(IF_FLOPPY, 0, 0);
828
        if (dinfo)
829
            fd[0] = dinfo->bdrv;
830

    
831
        sun4m_fdctrl_init(slavio_irq[22], hwdef->fd_base, fd,
832
                          &fdc_tc);
833
    }
834

    
835
    if (drive_get_max_bus(IF_SCSI) > 0) {
836
        fprintf(stderr, "qemu: too many SCSI bus\n");
837
        exit(1);
838
    }
839

    
840
    esp_reset = qdev_get_gpio_in(espdma, 0);
841
    esp_init(hwdef->esp_base, 2,
842
             espdma_memory_read, espdma_memory_write,
843
             espdma, espdma_irq, &esp_reset);
844

    
845

    
846
    if (hwdef->cs_base) {
847
        sysbus_create_simple("SUNW,CS4231", hwdef->cs_base,
848
                             slavio_irq[5]);
849
    }
850

    
851
    kernel_size = sun4m_load_kernel(kernel_filename, initrd_filename,
852
                                    RAM_size);
853

    
854
    nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
855
               boot_device, RAM_size, kernel_size, graphic_width,
856
               graphic_height, graphic_depth, hwdef->nvram_machine_id,
857
               "Sun4m");
858

    
859
    if (hwdef->ecc_base)
860
        ecc_init(hwdef->ecc_base, slavio_irq[28],
861
                 hwdef->ecc_version);
862

    
863
    fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2);
864
    fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
865
    fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
866
    fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id);
867
    fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_DEPTH, graphic_depth);
868
    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, KERNEL_LOAD_ADDR);
869
    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
870
    if (kernel_cmdline) {
871
        fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);
872
        pstrcpy_targphys(CMDLINE_ADDR, TARGET_PAGE_SIZE, kernel_cmdline);
873
    } else {
874
        fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
875
    }
876
    fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, INITRD_LOAD_ADDR);
877
    fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, 0); // not used
878
    fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, boot_device[0]);
879
    qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
880
}
881

    
882
enum {
883
    ss2_id = 0,
884
    ss5_id = 32,
885
    vger_id,
886
    lx_id,
887
    ss4_id,
888
    scls_id,
889
    sbook_id,
890
    ss10_id = 64,
891
    ss20_id,
892
    ss600mp_id,
893
    ss1000_id = 96,
894
    ss2000_id,
895
};
896

    
897
static const struct sun4m_hwdef sun4m_hwdefs[] = {
898
    /* SS-5 */
899
    {
900
        .iommu_base   = 0x10000000,
901
        .tcx_base     = 0x50000000,
902
        .cs_base      = 0x6c000000,
903
        .slavio_base  = 0x70000000,
904
        .ms_kb_base   = 0x71000000,
905
        .serial_base  = 0x71100000,
906
        .nvram_base   = 0x71200000,
907
        .fd_base      = 0x71400000,
908
        .counter_base = 0x71d00000,
909
        .intctl_base  = 0x71e00000,
910
        .idreg_base   = 0x78000000,
911
        .dma_base     = 0x78400000,
912
        .esp_base     = 0x78800000,
913
        .le_base      = 0x78c00000,
914
        .apc_base     = 0x6a000000,
915
        .aux1_base    = 0x71900000,
916
        .aux2_base    = 0x71910000,
917
        .nvram_machine_id = 0x80,
918
        .machine_id = ss5_id,
919
        .iommu_version = 0x05000000,
920
        .max_mem = 0x10000000,
921
        .default_cpu_model = "Fujitsu MB86904",
922
    },
923
    /* SS-10 */
924
    {
925
        .iommu_base   = 0xfe0000000ULL,
926
        .tcx_base     = 0xe20000000ULL,
927
        .slavio_base  = 0xff0000000ULL,
928
        .ms_kb_base   = 0xff1000000ULL,
929
        .serial_base  = 0xff1100000ULL,
930
        .nvram_base   = 0xff1200000ULL,
931
        .fd_base      = 0xff1700000ULL,
932
        .counter_base = 0xff1300000ULL,
933
        .intctl_base  = 0xff1400000ULL,
934
        .idreg_base   = 0xef0000000ULL,
935
        .dma_base     = 0xef0400000ULL,
936
        .esp_base     = 0xef0800000ULL,
937
        .le_base      = 0xef0c00000ULL,
938
        .apc_base     = 0xefa000000ULL, // XXX should not exist
939
        .aux1_base    = 0xff1800000ULL,
940
        .aux2_base    = 0xff1a01000ULL,
941
        .ecc_base     = 0xf00000000ULL,
942
        .ecc_version  = 0x10000000, // version 0, implementation 1
943
        .nvram_machine_id = 0x72,
944
        .machine_id = ss10_id,
945
        .iommu_version = 0x03000000,
946
        .max_mem = 0xf00000000ULL,
947
        .default_cpu_model = "TI SuperSparc II",
948
    },
949
    /* SS-600MP */
950
    {
951
        .iommu_base   = 0xfe0000000ULL,
952
        .tcx_base     = 0xe20000000ULL,
953
        .slavio_base  = 0xff0000000ULL,
954
        .ms_kb_base   = 0xff1000000ULL,
955
        .serial_base  = 0xff1100000ULL,
956
        .nvram_base   = 0xff1200000ULL,
957
        .counter_base = 0xff1300000ULL,
958
        .intctl_base  = 0xff1400000ULL,
959
        .dma_base     = 0xef0081000ULL,
960
        .esp_base     = 0xef0080000ULL,
961
        .le_base      = 0xef0060000ULL,
962
        .apc_base     = 0xefa000000ULL, // XXX should not exist
963
        .aux1_base    = 0xff1800000ULL,
964
        .aux2_base    = 0xff1a01000ULL, // XXX should not exist
965
        .ecc_base     = 0xf00000000ULL,
966
        .ecc_version  = 0x00000000, // version 0, implementation 0
967
        .nvram_machine_id = 0x71,
968
        .machine_id = ss600mp_id,
969
        .iommu_version = 0x01000000,
970
        .max_mem = 0xf00000000ULL,
971
        .default_cpu_model = "TI SuperSparc II",
972
    },
973
    /* SS-20 */
974
    {
975
        .iommu_base   = 0xfe0000000ULL,
976
        .tcx_base     = 0xe20000000ULL,
977
        .slavio_base  = 0xff0000000ULL,
978
        .ms_kb_base   = 0xff1000000ULL,
979
        .serial_base  = 0xff1100000ULL,
980
        .nvram_base   = 0xff1200000ULL,
981
        .fd_base      = 0xff1700000ULL,
982
        .counter_base = 0xff1300000ULL,
983
        .intctl_base  = 0xff1400000ULL,
984
        .idreg_base   = 0xef0000000ULL,
985
        .dma_base     = 0xef0400000ULL,
986
        .esp_base     = 0xef0800000ULL,
987
        .le_base      = 0xef0c00000ULL,
988
        .apc_base     = 0xefa000000ULL, // XXX should not exist
989
        .aux1_base    = 0xff1800000ULL,
990
        .aux2_base    = 0xff1a01000ULL,
991
        .ecc_base     = 0xf00000000ULL,
992
        .ecc_version  = 0x20000000, // version 0, implementation 2
993
        .nvram_machine_id = 0x72,
994
        .machine_id = ss20_id,
995
        .iommu_version = 0x13000000,
996
        .max_mem = 0xf00000000ULL,
997
        .default_cpu_model = "TI SuperSparc II",
998
    },
999
    /* Voyager */
1000
    {
1001
        .iommu_base   = 0x10000000,
1002
        .tcx_base     = 0x50000000,
1003
        .slavio_base  = 0x70000000,
1004
        .ms_kb_base   = 0x71000000,
1005
        .serial_base  = 0x71100000,
1006
        .nvram_base   = 0x71200000,
1007
        .fd_base      = 0x71400000,
1008
        .counter_base = 0x71d00000,
1009
        .intctl_base  = 0x71e00000,
1010
        .idreg_base   = 0x78000000,
1011
        .dma_base     = 0x78400000,
1012
        .esp_base     = 0x78800000,
1013
        .le_base      = 0x78c00000,
1014
        .apc_base     = 0x71300000, // pmc
1015
        .aux1_base    = 0x71900000,
1016
        .aux2_base    = 0x71910000,
1017
        .nvram_machine_id = 0x80,
1018
        .machine_id = vger_id,
1019
        .iommu_version = 0x05000000,
1020
        .max_mem = 0x10000000,
1021
        .default_cpu_model = "Fujitsu MB86904",
1022
    },
1023
    /* LX */
1024
    {
1025
        .iommu_base   = 0x10000000,
1026
        .tcx_base     = 0x50000000,
1027
        .slavio_base  = 0x70000000,
1028
        .ms_kb_base   = 0x71000000,
1029
        .serial_base  = 0x71100000,
1030
        .nvram_base   = 0x71200000,
1031
        .fd_base      = 0x71400000,
1032
        .counter_base = 0x71d00000,
1033
        .intctl_base  = 0x71e00000,
1034
        .idreg_base   = 0x78000000,
1035
        .dma_base     = 0x78400000,
1036
        .esp_base     = 0x78800000,
1037
        .le_base      = 0x78c00000,
1038
        .aux1_base    = 0x71900000,
1039
        .aux2_base    = 0x71910000,
1040
        .nvram_machine_id = 0x80,
1041
        .machine_id = lx_id,
1042
        .iommu_version = 0x04000000,
1043
        .max_mem = 0x10000000,
1044
        .default_cpu_model = "TI MicroSparc I",
1045
    },
1046
    /* SS-4 */
1047
    {
1048
        .iommu_base   = 0x10000000,
1049
        .tcx_base     = 0x50000000,
1050
        .cs_base      = 0x6c000000,
1051
        .slavio_base  = 0x70000000,
1052
        .ms_kb_base   = 0x71000000,
1053
        .serial_base  = 0x71100000,
1054
        .nvram_base   = 0x71200000,
1055
        .fd_base      = 0x71400000,
1056
        .counter_base = 0x71d00000,
1057
        .intctl_base  = 0x71e00000,
1058
        .idreg_base   = 0x78000000,
1059
        .dma_base     = 0x78400000,
1060
        .esp_base     = 0x78800000,
1061
        .le_base      = 0x78c00000,
1062
        .apc_base     = 0x6a000000,
1063
        .aux1_base    = 0x71900000,
1064
        .aux2_base    = 0x71910000,
1065
        .nvram_machine_id = 0x80,
1066
        .machine_id = ss4_id,
1067
        .iommu_version = 0x05000000,
1068
        .max_mem = 0x10000000,
1069
        .default_cpu_model = "Fujitsu MB86904",
1070
    },
1071
    /* SPARCClassic */
1072
    {
1073
        .iommu_base   = 0x10000000,
1074
        .tcx_base     = 0x50000000,
1075
        .slavio_base  = 0x70000000,
1076
        .ms_kb_base   = 0x71000000,
1077
        .serial_base  = 0x71100000,
1078
        .nvram_base   = 0x71200000,
1079
        .fd_base      = 0x71400000,
1080
        .counter_base = 0x71d00000,
1081
        .intctl_base  = 0x71e00000,
1082
        .idreg_base   = 0x78000000,
1083
        .dma_base     = 0x78400000,
1084
        .esp_base     = 0x78800000,
1085
        .le_base      = 0x78c00000,
1086
        .apc_base     = 0x6a000000,
1087
        .aux1_base    = 0x71900000,
1088
        .aux2_base    = 0x71910000,
1089
        .nvram_machine_id = 0x80,
1090
        .machine_id = scls_id,
1091
        .iommu_version = 0x05000000,
1092
        .max_mem = 0x10000000,
1093
        .default_cpu_model = "TI MicroSparc I",
1094
    },
1095
    /* SPARCbook */
1096
    {
1097
        .iommu_base   = 0x10000000,
1098
        .tcx_base     = 0x50000000, // XXX
1099
        .slavio_base  = 0x70000000,
1100
        .ms_kb_base   = 0x71000000,
1101
        .serial_base  = 0x71100000,
1102
        .nvram_base   = 0x71200000,
1103
        .fd_base      = 0x71400000,
1104
        .counter_base = 0x71d00000,
1105
        .intctl_base  = 0x71e00000,
1106
        .idreg_base   = 0x78000000,
1107
        .dma_base     = 0x78400000,
1108
        .esp_base     = 0x78800000,
1109
        .le_base      = 0x78c00000,
1110
        .apc_base     = 0x6a000000,
1111
        .aux1_base    = 0x71900000,
1112
        .aux2_base    = 0x71910000,
1113
        .nvram_machine_id = 0x80,
1114
        .machine_id = sbook_id,
1115
        .iommu_version = 0x05000000,
1116
        .max_mem = 0x10000000,
1117
        .default_cpu_model = "TI MicroSparc I",
1118
    },
1119
};
1120

    
1121
/* SPARCstation 5 hardware initialisation */
1122
static void ss5_init(ram_addr_t RAM_size,
1123
                     const char *boot_device,
1124
                     const char *kernel_filename, const char *kernel_cmdline,
1125
                     const char *initrd_filename, const char *cpu_model)
1126
{
1127
    sun4m_hw_init(&sun4m_hwdefs[0], RAM_size, boot_device, kernel_filename,
1128
                  kernel_cmdline, initrd_filename, cpu_model);
1129
}
1130

    
1131
/* SPARCstation 10 hardware initialisation */
1132
static void ss10_init(ram_addr_t RAM_size,
1133
                      const char *boot_device,
1134
                      const char *kernel_filename, const char *kernel_cmdline,
1135
                      const char *initrd_filename, const char *cpu_model)
1136
{
1137
    sun4m_hw_init(&sun4m_hwdefs[1], RAM_size, boot_device, kernel_filename,
1138
                  kernel_cmdline, initrd_filename, cpu_model);
1139
}
1140

    
1141
/* SPARCserver 600MP hardware initialisation */
1142
static void ss600mp_init(ram_addr_t RAM_size,
1143
                         const char *boot_device,
1144
                         const char *kernel_filename,
1145
                         const char *kernel_cmdline,
1146
                         const char *initrd_filename, const char *cpu_model)
1147
{
1148
    sun4m_hw_init(&sun4m_hwdefs[2], RAM_size, boot_device, kernel_filename,
1149
                  kernel_cmdline, initrd_filename, cpu_model);
1150
}
1151

    
1152
/* SPARCstation 20 hardware initialisation */
1153
static void ss20_init(ram_addr_t RAM_size,
1154
                      const char *boot_device,
1155
                      const char *kernel_filename, const char *kernel_cmdline,
1156
                      const char *initrd_filename, const char *cpu_model)
1157
{
1158
    sun4m_hw_init(&sun4m_hwdefs[3], RAM_size, boot_device, kernel_filename,
1159
                  kernel_cmdline, initrd_filename, cpu_model);
1160
}
1161

    
1162
/* SPARCstation Voyager hardware initialisation */
1163
static void vger_init(ram_addr_t RAM_size,
1164
                      const char *boot_device,
1165
                      const char *kernel_filename, const char *kernel_cmdline,
1166
                      const char *initrd_filename, const char *cpu_model)
1167
{
1168
    sun4m_hw_init(&sun4m_hwdefs[4], RAM_size, boot_device, kernel_filename,
1169
                  kernel_cmdline, initrd_filename, cpu_model);
1170
}
1171

    
1172
/* SPARCstation LX hardware initialisation */
1173
static void ss_lx_init(ram_addr_t RAM_size,
1174
                       const char *boot_device,
1175
                       const char *kernel_filename, const char *kernel_cmdline,
1176
                       const char *initrd_filename, const char *cpu_model)
1177
{
1178
    sun4m_hw_init(&sun4m_hwdefs[5], RAM_size, boot_device, kernel_filename,
1179
                  kernel_cmdline, initrd_filename, cpu_model);
1180
}
1181

    
1182
/* SPARCstation 4 hardware initialisation */
1183
static void ss4_init(ram_addr_t RAM_size,
1184
                     const char *boot_device,
1185
                     const char *kernel_filename, const char *kernel_cmdline,
1186
                     const char *initrd_filename, const char *cpu_model)
1187
{
1188
    sun4m_hw_init(&sun4m_hwdefs[6], RAM_size, boot_device, kernel_filename,
1189
                  kernel_cmdline, initrd_filename, cpu_model);
1190
}
1191

    
1192
/* SPARCClassic hardware initialisation */
1193
static void scls_init(ram_addr_t RAM_size,
1194
                      const char *boot_device,
1195
                      const char *kernel_filename, const char *kernel_cmdline,
1196
                      const char *initrd_filename, const char *cpu_model)
1197
{
1198
    sun4m_hw_init(&sun4m_hwdefs[7], RAM_size, boot_device, kernel_filename,
1199
                  kernel_cmdline, initrd_filename, cpu_model);
1200
}
1201

    
1202
/* SPARCbook hardware initialisation */
1203
static void sbook_init(ram_addr_t RAM_size,
1204
                       const char *boot_device,
1205
                       const char *kernel_filename, const char *kernel_cmdline,
1206
                       const char *initrd_filename, const char *cpu_model)
1207
{
1208
    sun4m_hw_init(&sun4m_hwdefs[8], RAM_size, boot_device, kernel_filename,
1209
                  kernel_cmdline, initrd_filename, cpu_model);
1210
}
1211

    
1212
static QEMUMachine ss5_machine = {
1213
    .name = "SS-5",
1214
    .desc = "Sun4m platform, SPARCstation 5",
1215
    .init = ss5_init,
1216
    .use_scsi = 1,
1217
    .is_default = 1,
1218
};
1219

    
1220
static QEMUMachine ss10_machine = {
1221
    .name = "SS-10",
1222
    .desc = "Sun4m platform, SPARCstation 10",
1223
    .init = ss10_init,
1224
    .use_scsi = 1,
1225
    .max_cpus = 4,
1226
};
1227

    
1228
static QEMUMachine ss600mp_machine = {
1229
    .name = "SS-600MP",
1230
    .desc = "Sun4m platform, SPARCserver 600MP",
1231
    .init = ss600mp_init,
1232
    .use_scsi = 1,
1233
    .max_cpus = 4,
1234
};
1235

    
1236
static QEMUMachine ss20_machine = {
1237
    .name = "SS-20",
1238
    .desc = "Sun4m platform, SPARCstation 20",
1239
    .init = ss20_init,
1240
    .use_scsi = 1,
1241
    .max_cpus = 4,
1242
};
1243

    
1244
static QEMUMachine voyager_machine = {
1245
    .name = "Voyager",
1246
    .desc = "Sun4m platform, SPARCstation Voyager",
1247
    .init = vger_init,
1248
    .use_scsi = 1,
1249
};
1250

    
1251
static QEMUMachine ss_lx_machine = {
1252
    .name = "LX",
1253
    .desc = "Sun4m platform, SPARCstation LX",
1254
    .init = ss_lx_init,
1255
    .use_scsi = 1,
1256
};
1257

    
1258
static QEMUMachine ss4_machine = {
1259
    .name = "SS-4",
1260
    .desc = "Sun4m platform, SPARCstation 4",
1261
    .init = ss4_init,
1262
    .use_scsi = 1,
1263
};
1264

    
1265
static QEMUMachine scls_machine = {
1266
    .name = "SPARCClassic",
1267
    .desc = "Sun4m platform, SPARCClassic",
1268
    .init = scls_init,
1269
    .use_scsi = 1,
1270
};
1271

    
1272
static QEMUMachine sbook_machine = {
1273
    .name = "SPARCbook",
1274
    .desc = "Sun4m platform, SPARCbook",
1275
    .init = sbook_init,
1276
    .use_scsi = 1,
1277
};
1278

    
1279
static const struct sun4d_hwdef sun4d_hwdefs[] = {
1280
    /* SS-1000 */
1281
    {
1282
        .iounit_bases   = {
1283
            0xfe0200000ULL,
1284
            0xfe1200000ULL,
1285
            0xfe2200000ULL,
1286
            0xfe3200000ULL,
1287
            -1,
1288
        },
1289
        .tcx_base     = 0x820000000ULL,
1290
        .slavio_base  = 0xf00000000ULL,
1291
        .ms_kb_base   = 0xf00240000ULL,
1292
        .serial_base  = 0xf00200000ULL,
1293
        .nvram_base   = 0xf00280000ULL,
1294
        .counter_base = 0xf00300000ULL,
1295
        .espdma_base  = 0x800081000ULL,
1296
        .esp_base     = 0x800080000ULL,
1297
        .ledma_base   = 0x800040000ULL,
1298
        .le_base      = 0x800060000ULL,
1299
        .sbi_base     = 0xf02800000ULL,
1300
        .nvram_machine_id = 0x80,
1301
        .machine_id = ss1000_id,
1302
        .iounit_version = 0x03000000,
1303
        .max_mem = 0xf00000000ULL,
1304
        .default_cpu_model = "TI SuperSparc II",
1305
    },
1306
    /* SS-2000 */
1307
    {
1308
        .iounit_bases   = {
1309
            0xfe0200000ULL,
1310
            0xfe1200000ULL,
1311
            0xfe2200000ULL,
1312
            0xfe3200000ULL,
1313
            0xfe4200000ULL,
1314
        },
1315
        .tcx_base     = 0x820000000ULL,
1316
        .slavio_base  = 0xf00000000ULL,
1317
        .ms_kb_base   = 0xf00240000ULL,
1318
        .serial_base  = 0xf00200000ULL,
1319
        .nvram_base   = 0xf00280000ULL,
1320
        .counter_base = 0xf00300000ULL,
1321
        .espdma_base  = 0x800081000ULL,
1322
        .esp_base     = 0x800080000ULL,
1323
        .ledma_base   = 0x800040000ULL,
1324
        .le_base      = 0x800060000ULL,
1325
        .sbi_base     = 0xf02800000ULL,
1326
        .nvram_machine_id = 0x80,
1327
        .machine_id = ss2000_id,
1328
        .iounit_version = 0x03000000,
1329
        .max_mem = 0xf00000000ULL,
1330
        .default_cpu_model = "TI SuperSparc II",
1331
    },
1332
};
1333

    
1334
static DeviceState *sbi_init(target_phys_addr_t addr, qemu_irq **parent_irq)
1335
{
1336
    DeviceState *dev;
1337
    SysBusDevice *s;
1338
    unsigned int i;
1339

    
1340
    dev = qdev_create(NULL, "sbi");
1341
    qdev_init(dev);
1342

    
1343
    s = sysbus_from_qdev(dev);
1344

    
1345
    for (i = 0; i < MAX_CPUS; i++) {
1346
        sysbus_connect_irq(s, i, *parent_irq[i]);
1347
    }
1348

    
1349
    sysbus_mmio_map(s, 0, addr);
1350

    
1351
    return dev;
1352
}
1353

    
1354
static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size,
1355
                          const char *boot_device,
1356
                          const char *kernel_filename,
1357
                          const char *kernel_cmdline,
1358
                          const char *initrd_filename, const char *cpu_model)
1359
{
1360
    CPUState *envs[MAX_CPUS];
1361
    unsigned int i;
1362
    void *iounits[MAX_IOUNITS], *espdma, *ledma, *nvram;
1363
    qemu_irq *cpu_irqs[MAX_CPUS], sbi_irq[32], sbi_cpu_irq[MAX_CPUS],
1364
        espdma_irq, ledma_irq;
1365
    qemu_irq esp_reset;
1366
    unsigned long kernel_size;
1367
    void *fw_cfg;
1368
    DeviceState *dev;
1369

    
1370
    /* init CPUs */
1371
    if (!cpu_model)
1372
        cpu_model = hwdef->default_cpu_model;
1373

    
1374
    for(i = 0; i < smp_cpus; i++) {
1375
        envs[i] = cpu_devinit(cpu_model, i, hwdef->slavio_base, &cpu_irqs[i]);
1376
    }
1377

    
1378
    for (i = smp_cpus; i < MAX_CPUS; i++)
1379
        cpu_irqs[i] = qemu_allocate_irqs(dummy_cpu_set_irq, NULL, MAX_PILS);
1380

    
1381
    /* set up devices */
1382
    ram_init(0, RAM_size, hwdef->max_mem);
1383

    
1384
    prom_init(hwdef->slavio_base, bios_name);
1385

    
1386
    dev = sbi_init(hwdef->sbi_base, cpu_irqs);
1387

    
1388
    for (i = 0; i < 32; i++) {
1389
        sbi_irq[i] = qdev_get_gpio_in(dev, i);
1390
    }
1391
    for (i = 0; i < MAX_CPUS; i++) {
1392
        sbi_cpu_irq[i] = qdev_get_gpio_in(dev, 32 + i);
1393
    }
1394

    
1395
    for (i = 0; i < MAX_IOUNITS; i++)
1396
        if (hwdef->iounit_bases[i] != (target_phys_addr_t)-1)
1397
            iounits[i] = iommu_init(hwdef->iounit_bases[i],
1398
                                    hwdef->iounit_version,
1399
                                    sbi_irq[0]);
1400

    
1401
    espdma = sparc32_dma_init(hwdef->espdma_base, sbi_irq[3],
1402
                              iounits[0], &espdma_irq);
1403

    
1404
    ledma = sparc32_dma_init(hwdef->ledma_base, sbi_irq[4],
1405
                             iounits[0], &ledma_irq);
1406

    
1407
    if (graphic_depth != 8 && graphic_depth != 24) {
1408
        fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth);
1409
        exit (1);
1410
    }
1411
    tcx_init(hwdef->tcx_base, 0x00100000, graphic_width, graphic_height,
1412
             graphic_depth);
1413

    
1414
    lance_init(&nd_table[0], hwdef->le_base, ledma, ledma_irq);
1415

    
1416
    nvram = m48t59_init(sbi_irq[0], hwdef->nvram_base, 0, 0x2000, 8);
1417

    
1418
    slavio_timer_init_all(hwdef->counter_base, sbi_irq[10], sbi_cpu_irq, smp_cpus);
1419

    
1420
    slavio_serial_ms_kbd_init(hwdef->ms_kb_base, sbi_irq[12],
1421
                              display_type == DT_NOGRAPHIC, ESCC_CLOCK, 1);
1422
    // Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
1423
    // Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
1424
    escc_init(hwdef->serial_base, sbi_irq[12], sbi_irq[12],
1425
              serial_hds[0], serial_hds[1], ESCC_CLOCK, 1);
1426

    
1427
    if (drive_get_max_bus(IF_SCSI) > 0) {
1428
        fprintf(stderr, "qemu: too many SCSI bus\n");
1429
        exit(1);
1430
    }
1431

    
1432
    esp_reset = qdev_get_gpio_in(espdma, 0);
1433
    esp_init(hwdef->esp_base, 2,
1434
             espdma_memory_read, espdma_memory_write,
1435
             espdma, espdma_irq, &esp_reset);
1436

    
1437
    kernel_size = sun4m_load_kernel(kernel_filename, initrd_filename,
1438
                                    RAM_size);
1439

    
1440
    nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
1441
               boot_device, RAM_size, kernel_size, graphic_width,
1442
               graphic_height, graphic_depth, hwdef->nvram_machine_id,
1443
               "Sun4d");
1444

    
1445
    fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2);
1446
    fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
1447
    fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
1448
    fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id);
1449
    fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_DEPTH, graphic_depth);
1450
    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, KERNEL_LOAD_ADDR);
1451
    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
1452
    if (kernel_cmdline) {
1453
        fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);
1454
        pstrcpy_targphys(CMDLINE_ADDR, TARGET_PAGE_SIZE, kernel_cmdline);
1455
    } else {
1456
        fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
1457
    }
1458
    fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, INITRD_LOAD_ADDR);
1459
    fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, 0); // not used
1460
    fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, boot_device[0]);
1461
    qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
1462
}
1463

    
1464
/* SPARCserver 1000 hardware initialisation */
1465
static void ss1000_init(ram_addr_t RAM_size,
1466
                        const char *boot_device,
1467
                        const char *kernel_filename, const char *kernel_cmdline,
1468
                        const char *initrd_filename, const char *cpu_model)
1469
{
1470
    sun4d_hw_init(&sun4d_hwdefs[0], RAM_size, boot_device, kernel_filename,
1471
                  kernel_cmdline, initrd_filename, cpu_model);
1472
}
1473

    
1474
/* SPARCcenter 2000 hardware initialisation */
1475
static void ss2000_init(ram_addr_t RAM_size,
1476
                        const char *boot_device,
1477
                        const char *kernel_filename, const char *kernel_cmdline,
1478
                        const char *initrd_filename, const char *cpu_model)
1479
{
1480
    sun4d_hw_init(&sun4d_hwdefs[1], RAM_size, boot_device, kernel_filename,
1481
                  kernel_cmdline, initrd_filename, cpu_model);
1482
}
1483

    
1484
static QEMUMachine ss1000_machine = {
1485
    .name = "SS-1000",
1486
    .desc = "Sun4d platform, SPARCserver 1000",
1487
    .init = ss1000_init,
1488
    .use_scsi = 1,
1489
    .max_cpus = 8,
1490
};
1491

    
1492
static QEMUMachine ss2000_machine = {
1493
    .name = "SS-2000",
1494
    .desc = "Sun4d platform, SPARCcenter 2000",
1495
    .init = ss2000_init,
1496
    .use_scsi = 1,
1497
    .max_cpus = 20,
1498
};
1499

    
1500
static const struct sun4c_hwdef sun4c_hwdefs[] = {
1501
    /* SS-2 */
1502
    {
1503
        .iommu_base   = 0xf8000000,
1504
        .tcx_base     = 0xfe000000,
1505
        .slavio_base  = 0xf6000000,
1506
        .intctl_base  = 0xf5000000,
1507
        .counter_base = 0xf3000000,
1508
        .ms_kb_base   = 0xf0000000,
1509
        .serial_base  = 0xf1000000,
1510
        .nvram_base   = 0xf2000000,
1511
        .fd_base      = 0xf7200000,
1512
        .dma_base     = 0xf8400000,
1513
        .esp_base     = 0xf8800000,
1514
        .le_base      = 0xf8c00000,
1515
        .aux1_base    = 0xf7400003,
1516
        .nvram_machine_id = 0x55,
1517
        .machine_id = ss2_id,
1518
        .max_mem = 0x10000000,
1519
        .default_cpu_model = "Cypress CY7C601",
1520
    },
1521
};
1522

    
1523
static DeviceState *sun4c_intctl_init(target_phys_addr_t addr,
1524
                                      qemu_irq *parent_irq)
1525
{
1526
    DeviceState *dev;
1527
    SysBusDevice *s;
1528
    unsigned int i;
1529

    
1530
    dev = qdev_create(NULL, "sun4c_intctl");
1531
    qdev_init(dev);
1532

    
1533
    s = sysbus_from_qdev(dev);
1534

    
1535
    for (i = 0; i < MAX_PILS; i++) {
1536
        sysbus_connect_irq(s, i, parent_irq[i]);
1537
    }
1538
    sysbus_mmio_map(s, 0, addr);
1539

    
1540
    return dev;
1541
}
1542

    
1543
static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size,
1544
                          const char *boot_device,
1545
                          const char *kernel_filename,
1546
                          const char *kernel_cmdline,
1547
                          const char *initrd_filename, const char *cpu_model)
1548
{
1549
    CPUState *env;
1550
    void *iommu, *espdma, *ledma, *nvram;
1551
    qemu_irq *cpu_irqs, slavio_irq[8], espdma_irq, ledma_irq;
1552
    qemu_irq esp_reset;
1553
    qemu_irq fdc_tc;
1554
    unsigned long kernel_size;
1555
    BlockDriverState *fd[MAX_FD];
1556
    void *fw_cfg;
1557
    DeviceState *dev;
1558
    unsigned int i;
1559
    DriveInfo *dinfo;
1560

    
1561
    /* init CPU */
1562
    if (!cpu_model)
1563
        cpu_model = hwdef->default_cpu_model;
1564

    
1565
    env = cpu_devinit(cpu_model, 0, hwdef->slavio_base, &cpu_irqs);
1566

    
1567
    /* set up devices */
1568
    ram_init(0, RAM_size, hwdef->max_mem);
1569

    
1570
    prom_init(hwdef->slavio_base, bios_name);
1571

    
1572
    dev = sun4c_intctl_init(hwdef->intctl_base, cpu_irqs);
1573

    
1574
    for (i = 0; i < 8; i++) {
1575
        slavio_irq[i] = qdev_get_gpio_in(dev, i);
1576
    }
1577

    
1578
    iommu = iommu_init(hwdef->iommu_base, hwdef->iommu_version,
1579
                       slavio_irq[1]);
1580

    
1581
    espdma = sparc32_dma_init(hwdef->dma_base, slavio_irq[2],
1582
                              iommu, &espdma_irq);
1583

    
1584
    ledma = sparc32_dma_init(hwdef->dma_base + 16ULL,
1585
                             slavio_irq[3], iommu, &ledma_irq);
1586

    
1587
    if (graphic_depth != 8 && graphic_depth != 24) {
1588
        fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth);
1589
        exit (1);
1590
    }
1591
    tcx_init(hwdef->tcx_base, 0x00100000, graphic_width, graphic_height,
1592
             graphic_depth);
1593

    
1594
    lance_init(&nd_table[0], hwdef->le_base, ledma, ledma_irq);
1595

    
1596
    nvram = m48t59_init(slavio_irq[0], hwdef->nvram_base, 0, 0x800, 2);
1597

    
1598
    slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[1],
1599
                              display_type == DT_NOGRAPHIC, ESCC_CLOCK, 1);
1600
    // Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
1601
    // Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
1602
    escc_init(hwdef->serial_base, slavio_irq[1],
1603
              slavio_irq[1], serial_hds[0], serial_hds[1],
1604
              ESCC_CLOCK, 1);
1605

    
1606
    slavio_misc_init(0, hwdef->aux1_base, 0, slavio_irq[1], fdc_tc);
1607

    
1608
    if (hwdef->fd_base != (target_phys_addr_t)-1) {
1609
        /* there is zero or one floppy drive */
1610
        memset(fd, 0, sizeof(fd));
1611
        dinfo = drive_get(IF_FLOPPY, 0, 0);
1612
        if (dinfo)
1613
            fd[0] = dinfo->bdrv;
1614

    
1615
        sun4m_fdctrl_init(slavio_irq[1], hwdef->fd_base, fd,
1616
                          &fdc_tc);
1617
    }
1618

    
1619
    if (drive_get_max_bus(IF_SCSI) > 0) {
1620
        fprintf(stderr, "qemu: too many SCSI bus\n");
1621
        exit(1);
1622
    }
1623

    
1624
    esp_reset = qdev_get_gpio_in(espdma, 0);
1625
    esp_init(hwdef->esp_base, 2,
1626
             espdma_memory_read, espdma_memory_write,
1627
             espdma, espdma_irq, &esp_reset);
1628

    
1629
    kernel_size = sun4m_load_kernel(kernel_filename, initrd_filename,
1630
                                    RAM_size);
1631

    
1632
    nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
1633
               boot_device, RAM_size, kernel_size, graphic_width,
1634
               graphic_height, graphic_depth, hwdef->nvram_machine_id,
1635
               "Sun4c");
1636

    
1637
    fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2);
1638
    fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
1639
    fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
1640
    fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id);
1641
    fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_DEPTH, graphic_depth);
1642
    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, KERNEL_LOAD_ADDR);
1643
    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
1644
    if (kernel_cmdline) {
1645
        fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);
1646
        pstrcpy_targphys(CMDLINE_ADDR, TARGET_PAGE_SIZE, kernel_cmdline);
1647
    } else {
1648
        fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
1649
    }
1650
    fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, INITRD_LOAD_ADDR);
1651
    fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, 0); // not used
1652
    fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, boot_device[0]);
1653
    qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
1654
}
1655

    
1656
/* SPARCstation 2 hardware initialisation */
1657
static void ss2_init(ram_addr_t RAM_size,
1658
                     const char *boot_device,
1659
                     const char *kernel_filename, const char *kernel_cmdline,
1660
                     const char *initrd_filename, const char *cpu_model)
1661
{
1662
    sun4c_hw_init(&sun4c_hwdefs[0], RAM_size, boot_device, kernel_filename,
1663
                  kernel_cmdline, initrd_filename, cpu_model);
1664
}
1665

    
1666
static QEMUMachine ss2_machine = {
1667
    .name = "SS-2",
1668
    .desc = "Sun4c platform, SPARCstation 2",
1669
    .init = ss2_init,
1670
    .use_scsi = 1,
1671
};
1672

    
1673
static void ss2_machine_init(void)
1674
{
1675
    qemu_register_machine(&ss5_machine);
1676
    qemu_register_machine(&ss10_machine);
1677
    qemu_register_machine(&ss600mp_machine);
1678
    qemu_register_machine(&ss20_machine);
1679
    qemu_register_machine(&voyager_machine);
1680
    qemu_register_machine(&ss_lx_machine);
1681
    qemu_register_machine(&ss4_machine);
1682
    qemu_register_machine(&scls_machine);
1683
    qemu_register_machine(&sbook_machine);
1684
    qemu_register_machine(&ss1000_machine);
1685
    qemu_register_machine(&ss2000_machine);
1686
    qemu_register_machine(&ss2_machine);
1687
}
1688

    
1689
machine_init(ss2_machine_init);