Statistics
| Branch: | Revision:

root / hw / sun4m.c @ 99a0949b

History | View | Annotate | Download (52.4 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
#include "loader.h"
41
#include "elf.h"
42

    
43
//#define DEBUG_IRQ
44

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

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

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

    
89
#define MAX_CPUS 16
90
#define MAX_PILS 16
91

    
92
#define ESCC_CLOCK 4915200
93

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

    
109
#define MAX_IOUNITS 5
110

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

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

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

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

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

    
178
    memset(image, '\0', sizeof(image));
179

    
180
    start = 0;
181

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

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

    
192
    // End marker
193
    image[end++] = '\0';
194

    
195
    end = start + ((end - start + 15) & ~15);
196
    OpenBIOS_finish_partition(part_header, end - start);
197

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

    
204
    end = 0x1fd0;
205
    OpenBIOS_finish_partition(part_header, end - start);
206

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

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

    
214
static DeviceState *slavio_intctl;
215

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

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

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

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

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

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

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

    
269
static void dummy_cpu_set_irq(void *opaque, int irq, int level)
270
{
271
}
272

    
273
static void main_cpu_reset(void *opaque)
274
{
275
    CPUState *env = opaque;
276

    
277
    cpu_reset(env);
278
    env->halted = 0;
279
}
280

    
281
static void secondary_cpu_reset(void *opaque)
282
{
283
    CPUState *env = opaque;
284

    
285
    cpu_reset(env);
286
    env->halted = 1;
287
}
288

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

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

    
303
    linux_boot = (kernel_filename != NULL);
304

    
305
    kernel_size = 0;
306
    if (linux_boot) {
307
        int bswap_needed;
308

    
309
#ifdef BSWAP_NEEDED
310
        bswap_needed = 1;
311
#else
312
        bswap_needed = 0;
313
#endif
314
        kernel_size = load_elf(kernel_filename, -0xf0000000ULL, NULL, NULL,
315
                               NULL, 1, ELF_MACHINE, 0);
316
        if (kernel_size < 0)
317
            kernel_size = load_aout(kernel_filename, KERNEL_LOAD_ADDR,
318
                                    RAM_size - KERNEL_LOAD_ADDR, bswap_needed,
319
                                    TARGET_PAGE_SIZE);
320
        if (kernel_size < 0)
321
            kernel_size = load_image_targphys(kernel_filename,
322
                                              KERNEL_LOAD_ADDR,
323
                                              RAM_size - KERNEL_LOAD_ADDR);
324
        if (kernel_size < 0) {
325
            fprintf(stderr, "qemu: could not load kernel '%s'\n",
326
                    kernel_filename);
327
            exit(1);
328
        }
329

    
330
        /* load initrd */
331
        initrd_size = 0;
332
        if (initrd_filename) {
333
            initrd_size = load_image_targphys(initrd_filename,
334
                                              INITRD_LOAD_ADDR,
335
                                              RAM_size - INITRD_LOAD_ADDR);
336
            if (initrd_size < 0) {
337
                fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
338
                        initrd_filename);
339
                exit(1);
340
            }
341
        }
342
        if (initrd_size > 0) {
343
            for (i = 0; i < 64 * TARGET_PAGE_SIZE; i += TARGET_PAGE_SIZE) {
344
                if (ldl_phys(KERNEL_LOAD_ADDR + i) == 0x48647253) { // HdrS
345
                    stl_phys(KERNEL_LOAD_ADDR + i + 16, INITRD_LOAD_ADDR);
346
                    stl_phys(KERNEL_LOAD_ADDR + i + 20, initrd_size);
347
                    break;
348
                }
349
            }
350
        }
351
    }
352
    return kernel_size;
353
}
354

    
355
static void *iommu_init(a_target_phys_addr addr, uint32_t version, qemu_irq irq)
356
{
357
    DeviceState *dev;
358
    SysBusDevice *s;
359

    
360
    dev = qdev_create(NULL, "iommu");
361
    qdev_prop_set_uint32(dev, "version", version);
362
    qdev_init(dev);
363
    s = sysbus_from_qdev(dev);
364
    sysbus_connect_irq(s, 0, irq);
365
    sysbus_mmio_map(s, 0, addr);
366

    
367
    return s;
368
}
369

    
370
static void *sparc32_dma_init(a_target_phys_addr daddr, qemu_irq parent_irq,
371
                              void *iommu, qemu_irq *dev_irq)
372
{
373
    DeviceState *dev;
374
    SysBusDevice *s;
375

    
376
    dev = qdev_create(NULL, "sparc32_dma");
377
    qdev_prop_set_ptr(dev, "iommu_opaque", iommu);
378
    qdev_init(dev);
379
    s = sysbus_from_qdev(dev);
380
    sysbus_connect_irq(s, 0, parent_irq);
381
    *dev_irq = qdev_get_gpio_in(dev, 0);
382
    sysbus_mmio_map(s, 0, daddr);
383

    
384
    return s;
385
}
386

    
387
static void lance_init(NICInfo *nd, a_target_phys_addr leaddr,
388
                       void *dma_opaque, qemu_irq irq)
389
{
390
    DeviceState *dev;
391
    SysBusDevice *s;
392
    qemu_irq reset;
393

    
394
    qemu_check_nic_model(&nd_table[0], "lance");
395

    
396
    dev = qdev_create(NULL, "lance");
397
    dev->nd = nd;
398
    qdev_prop_set_ptr(dev, "dma", dma_opaque);
399
    qdev_init(dev);
400
    s = sysbus_from_qdev(dev);
401
    sysbus_mmio_map(s, 0, leaddr);
402
    sysbus_connect_irq(s, 0, irq);
403
    reset = qdev_get_gpio_in(dev, 0);
404
    qdev_connect_gpio_out(dma_opaque, 0, reset);
405
}
406

    
407
static DeviceState *slavio_intctl_init(a_target_phys_addr addr,
408
                                       a_target_phys_addr addrg,
409
                                       qemu_irq **parent_irq)
410
{
411
    DeviceState *dev;
412
    SysBusDevice *s;
413
    unsigned int i, j;
414

    
415
    dev = qdev_create(NULL, "slavio_intctl");
416
    qdev_init(dev);
417

    
418
    s = sysbus_from_qdev(dev);
419

    
420
    for (i = 0; i < MAX_CPUS; i++) {
421
        for (j = 0; j < MAX_PILS; j++) {
422
            sysbus_connect_irq(s, i * MAX_PILS + j, parent_irq[i][j]);
423
        }
424
    }
425
    sysbus_mmio_map(s, 0, addrg);
426
    for (i = 0; i < MAX_CPUS; i++) {
427
        sysbus_mmio_map(s, i + 1, addr + i * TARGET_PAGE_SIZE);
428
    }
429

    
430
    return dev;
431
}
432

    
433
#define SYS_TIMER_OFFSET      0x10000ULL
434
#define CPU_TIMER_OFFSET(cpu) (0x1000ULL * cpu)
435

    
436
static void slavio_timer_init_all(a_target_phys_addr addr, qemu_irq master_irq,
437
                                  qemu_irq *cpu_irqs, unsigned int num_cpus)
438
{
439
    DeviceState *dev;
440
    SysBusDevice *s;
441
    unsigned int i;
442

    
443
    dev = qdev_create(NULL, "slavio_timer");
444
    qdev_prop_set_uint32(dev, "num_cpus", num_cpus);
445
    qdev_init(dev);
446
    s = sysbus_from_qdev(dev);
447
    sysbus_connect_irq(s, 0, master_irq);
448
    sysbus_mmio_map(s, 0, addr + SYS_TIMER_OFFSET);
449

    
450
    for (i = 0; i < MAX_CPUS; i++) {
451
        sysbus_mmio_map(s, i + 1, addr + (a_target_phys_addr)CPU_TIMER_OFFSET(i));
452
        sysbus_connect_irq(s, i + 1, cpu_irqs[i]);
453
    }
454
}
455

    
456
#define MISC_LEDS 0x01600000
457
#define MISC_CFG  0x01800000
458
#define MISC_DIAG 0x01a00000
459
#define MISC_MDM  0x01b00000
460
#define MISC_SYS  0x01f00000
461

    
462
static void slavio_misc_init(a_target_phys_addr base,
463
                             a_target_phys_addr aux1_base,
464
                             a_target_phys_addr aux2_base, qemu_irq irq,
465
                             qemu_irq fdc_tc)
466
{
467
    DeviceState *dev;
468
    SysBusDevice *s;
469

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

    
501
static void ecc_init(a_target_phys_addr base, qemu_irq irq, uint32_t version)
502
{
503
    DeviceState *dev;
504
    SysBusDevice *s;
505

    
506
    dev = qdev_create(NULL, "eccmemctl");
507
    qdev_prop_set_uint32(dev, "version", version);
508
    qdev_init(dev);
509
    s = sysbus_from_qdev(dev);
510
    sysbus_connect_irq(s, 0, irq);
511
    sysbus_mmio_map(s, 0, base);
512
    if (version == 0) { // SS-600MP only
513
        sysbus_mmio_map(s, 1, base + 0x1000);
514
    }
515
}
516

    
517
static void apc_init(a_target_phys_addr power_base, qemu_irq cpu_halt)
518
{
519
    DeviceState *dev;
520
    SysBusDevice *s;
521

    
522
    dev = qdev_create(NULL, "apc");
523
    qdev_init(dev);
524
    s = sysbus_from_qdev(dev);
525
    /* Power management (APC) XXX: not a Slavio device */
526
    sysbus_mmio_map(s, 0, power_base);
527
    sysbus_connect_irq(s, 0, cpu_halt);
528
}
529

    
530
static void tcx_init(a_target_phys_addr addr, int vram_size, int width,
531
                     int height, int depth)
532
{
533
    DeviceState *dev;
534
    SysBusDevice *s;
535

    
536
    dev = qdev_create(NULL, "SUNW,tcx");
537
    qdev_prop_set_taddr(dev, "addr", addr);
538
    qdev_prop_set_uint32(dev, "vram_size", vram_size);
539
    qdev_prop_set_uint16(dev, "width", width);
540
    qdev_prop_set_uint16(dev, "height", height);
541
    qdev_prop_set_uint16(dev, "depth", depth);
542
    qdev_init(dev);
543
    s = sysbus_from_qdev(dev);
544
    /* 8-bit plane */
545
    sysbus_mmio_map(s, 0, addr + 0x00800000ULL);
546
    /* DAC */
547
    sysbus_mmio_map(s, 1, addr + 0x00200000ULL);
548
    /* TEC (dummy) */
549
    sysbus_mmio_map(s, 2, addr + 0x00700000ULL);
550
    /* THC 24 bit: NetBSD writes here even with 8-bit display: dummy */
551
    sysbus_mmio_map(s, 3, addr + 0x00301000ULL);
552
    if (depth == 24) {
553
        /* 24-bit plane */
554
        sysbus_mmio_map(s, 4, addr + 0x02000000ULL);
555
        /* Control plane */
556
        sysbus_mmio_map(s, 5, addr + 0x0a000000ULL);
557
    } else {
558
        /* THC 8 bit (dummy) */
559
        sysbus_mmio_map(s, 4, addr + 0x00300000ULL);
560
    }
561
}
562

    
563
/* NCR89C100/MACIO Internal ID register */
564
static const uint8_t idreg_data[] = { 0xfe, 0x81, 0x01, 0x03 };
565

    
566
static void idreg_init(a_target_phys_addr addr)
567
{
568
    DeviceState *dev;
569
    SysBusDevice *s;
570

    
571
    dev = qdev_create(NULL, "macio_idreg");
572
    qdev_init(dev);
573
    s = sysbus_from_qdev(dev);
574

    
575
    sysbus_mmio_map(s, 0, addr);
576
    cpu_physical_memory_write_rom(addr, idreg_data, sizeof(idreg_data));
577
}
578

    
579
static int idreg_init1(SysBusDevice *dev)
580
{
581
    a_ram_addr idreg_offset;
582

    
583
    idreg_offset = qemu_ram_alloc(sizeof(idreg_data));
584
    sysbus_init_mmio(dev, sizeof(idreg_data), idreg_offset | IO_MEM_ROM);
585
    return 0;
586
}
587

    
588
static SysBusDeviceInfo idreg_info = {
589
    .init = idreg_init1,
590
    .qdev.name  = "macio_idreg",
591
    .qdev.size  = sizeof(SysBusDevice),
592
};
593

    
594
static void idreg_register_devices(void)
595
{
596
    sysbus_register_withprop(&idreg_info);
597
}
598

    
599
device_init(idreg_register_devices);
600

    
601
/* Boot PROM (OpenBIOS) */
602
static void prom_init(a_target_phys_addr addr, const char *bios_name)
603
{
604
    DeviceState *dev;
605
    SysBusDevice *s;
606
    char *filename;
607
    int ret;
608

    
609
    dev = qdev_create(NULL, "openprom");
610
    qdev_init(dev);
611
    s = sysbus_from_qdev(dev);
612

    
613
    sysbus_mmio_map(s, 0, addr);
614

    
615
    /* load boot prom */
616
    if (bios_name == NULL) {
617
        bios_name = PROM_FILENAME;
618
    }
619
    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
620
    if (filename) {
621
        ret = load_elf(filename, addr - PROM_VADDR, NULL, NULL, NULL,
622
                       1, ELF_MACHINE, 0);
623
        if (ret < 0 || ret > PROM_SIZE_MAX) {
624
            ret = load_image_targphys(filename, addr, PROM_SIZE_MAX);
625
        }
626
        qemu_free(filename);
627
    } else {
628
        ret = -1;
629
    }
630
    if (ret < 0 || ret > PROM_SIZE_MAX) {
631
        fprintf(stderr, "qemu: could not load prom '%s'\n", bios_name);
632
        exit(1);
633
    }
634
}
635

    
636
static int prom_init1(SysBusDevice *dev)
637
{
638
    a_ram_addr prom_offset;
639

    
640
    prom_offset = qemu_ram_alloc(PROM_SIZE_MAX);
641
    sysbus_init_mmio(dev, PROM_SIZE_MAX, prom_offset | IO_MEM_ROM);
642
    return 0;
643
}
644

    
645
static SysBusDeviceInfo prom_info = {
646
    .init = prom_init1,
647
    .qdev.name  = "openprom",
648
    .qdev.size  = sizeof(SysBusDevice),
649
    .qdev.props = (Property[]) {
650
        {/* end of property list */}
651
    }
652
};
653

    
654
static void prom_register_devices(void)
655
{
656
    sysbus_register_withprop(&prom_info);
657
}
658

    
659
device_init(prom_register_devices);
660

    
661
typedef struct RamDevice
662
{
663
    SysBusDevice busdev;
664
    uint64_t size;
665
} RamDevice;
666

    
667
/* System RAM */
668
static int ram_init1(SysBusDevice *dev)
669
{
670
    a_ram_addr RAM_size, ram_offset;
671
    RamDevice *d = FROM_SYSBUS(RamDevice, dev);
672

    
673
    RAM_size = d->size;
674

    
675
    ram_offset = qemu_ram_alloc(RAM_size);
676
    sysbus_init_mmio(dev, RAM_size, ram_offset);
677
    return 0;
678
}
679

    
680
static void ram_init(a_target_phys_addr addr, a_ram_addr RAM_size,
681
                     uint64_t max_mem)
682
{
683
    DeviceState *dev;
684
    SysBusDevice *s;
685
    RamDevice *d;
686

    
687
    /* allocate RAM */
688
    if ((uint64_t)RAM_size > max_mem) {
689
        fprintf(stderr,
690
                "qemu: Too much memory for this machine: %d, maximum %d\n",
691
                (unsigned int)(RAM_size / (1024 * 1024)),
692
                (unsigned int)(max_mem / (1024 * 1024)));
693
        exit(1);
694
    }
695
    dev = qdev_create(NULL, "memory");
696
    s = sysbus_from_qdev(dev);
697

    
698
    d = FROM_SYSBUS(RamDevice, s);
699
    d->size = RAM_size;
700
    qdev_init(dev);
701

    
702
    sysbus_mmio_map(s, 0, addr);
703
}
704

    
705
static SysBusDeviceInfo ram_info = {
706
    .init = ram_init1,
707
    .qdev.name  = "memory",
708
    .qdev.size  = sizeof(RamDevice),
709
    .qdev.props = (Property[]) {
710
        DEFINE_PROP_UINT64("size", RamDevice, size, 0),
711
        DEFINE_PROP_END_OF_LIST(),
712
    }
713
};
714

    
715
static void ram_register_devices(void)
716
{
717
    sysbus_register_withprop(&ram_info);
718
}
719

    
720
device_init(ram_register_devices);
721

    
722
static CPUState *cpu_devinit(const char *cpu_model, unsigned int id,
723
                             uint64_t prom_addr, qemu_irq **cpu_irqs)
724
{
725
    CPUState *env;
726

    
727
    env = cpu_init(cpu_model);
728
    if (!env) {
729
        fprintf(stderr, "qemu: Unable to find Sparc CPU definition\n");
730
        exit(1);
731
    }
732

    
733
    cpu_sparc_set_id(env, id);
734
    if (id == 0) {
735
        qemu_register_reset(main_cpu_reset, env);
736
    } else {
737
        qemu_register_reset(secondary_cpu_reset, env);
738
        env->halted = 1;
739
    }
740
    *cpu_irqs = qemu_allocate_irqs(cpu_set_irq, env, MAX_PILS);
741
    env->prom_addr = prom_addr;
742

    
743
    return env;
744
}
745

    
746
static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, a_ram_addr RAM_size,
747
                          const char *boot_device,
748
                          const char *kernel_filename,
749
                          const char *kernel_cmdline,
750
                          const char *initrd_filename, const char *cpu_model)
751
{
752
    CPUState *envs[MAX_CPUS];
753
    unsigned int i;
754
    void *iommu, *espdma, *ledma, *nvram;
755
    qemu_irq *cpu_irqs[MAX_CPUS], slavio_irq[32], slavio_cpu_irq[MAX_CPUS],
756
        espdma_irq, ledma_irq;
757
    qemu_irq esp_reset;
758
    qemu_irq fdc_tc;
759
    qemu_irq *cpu_halt;
760
    unsigned long kernel_size;
761
    BlockDriverState *fd[MAX_FD];
762
    void *fw_cfg;
763
    DriveInfo *dinfo;
764

    
765
    /* init CPUs */
766
    if (!cpu_model)
767
        cpu_model = hwdef->default_cpu_model;
768

    
769
    for(i = 0; i < smp_cpus; i++) {
770
        envs[i] = cpu_devinit(cpu_model, i, hwdef->slavio_base, &cpu_irqs[i]);
771
    }
772

    
773
    for (i = smp_cpus; i < MAX_CPUS; i++)
774
        cpu_irqs[i] = qemu_allocate_irqs(dummy_cpu_set_irq, NULL, MAX_PILS);
775

    
776

    
777
    /* set up devices */
778
    ram_init(0, RAM_size, hwdef->max_mem);
779

    
780
    prom_init(hwdef->slavio_base, bios_name);
781

    
782
    slavio_intctl = slavio_intctl_init(hwdef->intctl_base,
783
                                       hwdef->intctl_base + 0x10000ULL,
784
                                       cpu_irqs);
785

    
786
    for (i = 0; i < 32; i++) {
787
        slavio_irq[i] = qdev_get_gpio_in(slavio_intctl, i);
788
    }
789
    for (i = 0; i < MAX_CPUS; i++) {
790
        slavio_cpu_irq[i] = qdev_get_gpio_in(slavio_intctl, 32 + i);
791
    }
792

    
793
    if (hwdef->idreg_base) {
794
        idreg_init(hwdef->idreg_base);
795
    }
796

    
797
    iommu = iommu_init(hwdef->iommu_base, hwdef->iommu_version,
798
                       slavio_irq[30]);
799

    
800
    espdma = sparc32_dma_init(hwdef->dma_base, slavio_irq[18],
801
                              iommu, &espdma_irq);
802

    
803
    ledma = sparc32_dma_init(hwdef->dma_base + 16ULL,
804
                             slavio_irq[16], iommu, &ledma_irq);
805

    
806
    if (graphic_depth != 8 && graphic_depth != 24) {
807
        fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth);
808
        exit (1);
809
    }
810
    tcx_init(hwdef->tcx_base, 0x00100000, graphic_width, graphic_height,
811
             graphic_depth);
812

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

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

    
817
    slavio_timer_init_all(hwdef->counter_base, slavio_irq[19], slavio_cpu_irq, smp_cpus);
818

    
819
    slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[14],
820
                              display_type == DT_NOGRAPHIC, ESCC_CLOCK, 1);
821
    // Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
822
    // Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
823
    escc_init(hwdef->serial_base, slavio_irq[15], slavio_irq[15],
824
              serial_hds[0], serial_hds[1], ESCC_CLOCK, 1);
825

    
826
    cpu_halt = qemu_allocate_irqs(cpu_halt_signal, NULL, 1);
827
    slavio_misc_init(hwdef->slavio_base, hwdef->aux1_base, hwdef->aux2_base,
828
                     slavio_irq[30], fdc_tc);
829

    
830
    if (hwdef->apc_base) {
831
        apc_init(hwdef->apc_base, cpu_halt[0]);
832
    }
833

    
834
    if (hwdef->fd_base) {
835
        /* there is zero or one floppy drive */
836
        memset(fd, 0, sizeof(fd));
837
        dinfo = drive_get(IF_FLOPPY, 0, 0);
838
        if (dinfo)
839
            fd[0] = dinfo->bdrv;
840

    
841
        sun4m_fdctrl_init(slavio_irq[22], hwdef->fd_base, fd,
842
                          &fdc_tc);
843
    }
844

    
845
    if (drive_get_max_bus(IF_SCSI) > 0) {
846
        fprintf(stderr, "qemu: too many SCSI bus\n");
847
        exit(1);
848
    }
849

    
850
    esp_reset = qdev_get_gpio_in(espdma, 0);
851
    esp_init(hwdef->esp_base, 2,
852
             espdma_memory_read, espdma_memory_write,
853
             espdma, espdma_irq, &esp_reset);
854

    
855

    
856
    if (hwdef->cs_base) {
857
        sysbus_create_simple("SUNW,CS4231", hwdef->cs_base,
858
                             slavio_irq[5]);
859
    }
860

    
861
    kernel_size = sun4m_load_kernel(kernel_filename, initrd_filename,
862
                                    RAM_size);
863

    
864
    nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
865
               boot_device, RAM_size, kernel_size, graphic_width,
866
               graphic_height, graphic_depth, hwdef->nvram_machine_id,
867
               "Sun4m");
868

    
869
    if (hwdef->ecc_base)
870
        ecc_init(hwdef->ecc_base, slavio_irq[28],
871
                 hwdef->ecc_version);
872

    
873
    fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2);
874
    fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
875
    fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
876
    fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id);
877
    fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_DEPTH, graphic_depth);
878
    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, KERNEL_LOAD_ADDR);
879
    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
880
    if (kernel_cmdline) {
881
        fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);
882
        pstrcpy_targphys(CMDLINE_ADDR, TARGET_PAGE_SIZE, kernel_cmdline);
883
    } else {
884
        fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
885
    }
886
    fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, INITRD_LOAD_ADDR);
887
    fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, 0); // not used
888
    fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, boot_device[0]);
889
    qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
890
}
891

    
892
enum {
893
    ss2_id = 0,
894
    ss5_id = 32,
895
    vger_id,
896
    lx_id,
897
    ss4_id,
898
    scls_id,
899
    sbook_id,
900
    ss10_id = 64,
901
    ss20_id,
902
    ss600mp_id,
903
    ss1000_id = 96,
904
    ss2000_id,
905
};
906

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

    
1131
/* SPARCstation 5 hardware initialisation */
1132
static void ss5_init(a_ram_addr 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[0], RAM_size, boot_device, kernel_filename,
1138
                  kernel_cmdline, initrd_filename, cpu_model);
1139
}
1140

    
1141
/* SPARCstation 10 hardware initialisation */
1142
static void ss10_init(a_ram_addr RAM_size,
1143
                      const char *boot_device,
1144
                      const char *kernel_filename, const char *kernel_cmdline,
1145
                      const char *initrd_filename, const char *cpu_model)
1146
{
1147
    sun4m_hw_init(&sun4m_hwdefs[1], RAM_size, boot_device, kernel_filename,
1148
                  kernel_cmdline, initrd_filename, cpu_model);
1149
}
1150

    
1151
/* SPARCserver 600MP hardware initialisation */
1152
static void ss600mp_init(a_ram_addr RAM_size,
1153
                         const char *boot_device,
1154
                         const char *kernel_filename,
1155
                         const char *kernel_cmdline,
1156
                         const char *initrd_filename, const char *cpu_model)
1157
{
1158
    sun4m_hw_init(&sun4m_hwdefs[2], RAM_size, boot_device, kernel_filename,
1159
                  kernel_cmdline, initrd_filename, cpu_model);
1160
}
1161

    
1162
/* SPARCstation 20 hardware initialisation */
1163
static void ss20_init(a_ram_addr 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[3], RAM_size, boot_device, kernel_filename,
1169
                  kernel_cmdline, initrd_filename, cpu_model);
1170
}
1171

    
1172
/* SPARCstation Voyager hardware initialisation */
1173
static void vger_init(a_ram_addr 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[4], RAM_size, boot_device, kernel_filename,
1179
                  kernel_cmdline, initrd_filename, cpu_model);
1180
}
1181

    
1182
/* SPARCstation LX hardware initialisation */
1183
static void ss_lx_init(a_ram_addr 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[5], RAM_size, boot_device, kernel_filename,
1189
                  kernel_cmdline, initrd_filename, cpu_model);
1190
}
1191

    
1192
/* SPARCstation 4 hardware initialisation */
1193
static void ss4_init(a_ram_addr 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[6], RAM_size, boot_device, kernel_filename,
1199
                  kernel_cmdline, initrd_filename, cpu_model);
1200
}
1201

    
1202
/* SPARCClassic hardware initialisation */
1203
static void scls_init(a_ram_addr 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[7], RAM_size, boot_device, kernel_filename,
1209
                  kernel_cmdline, initrd_filename, cpu_model);
1210
}
1211

    
1212
/* SPARCbook hardware initialisation */
1213
static void sbook_init(a_ram_addr RAM_size,
1214
                       const char *boot_device,
1215
                       const char *kernel_filename, const char *kernel_cmdline,
1216
                       const char *initrd_filename, const char *cpu_model)
1217
{
1218
    sun4m_hw_init(&sun4m_hwdefs[8], RAM_size, boot_device, kernel_filename,
1219
                  kernel_cmdline, initrd_filename, cpu_model);
1220
}
1221

    
1222
static QEMUMachine ss5_machine = {
1223
    .name = "SS-5",
1224
    .desc = "Sun4m platform, SPARCstation 5",
1225
    .init = ss5_init,
1226
    .use_scsi = 1,
1227
    .is_default = 1,
1228
};
1229

    
1230
static QEMUMachine ss10_machine = {
1231
    .name = "SS-10",
1232
    .desc = "Sun4m platform, SPARCstation 10",
1233
    .init = ss10_init,
1234
    .use_scsi = 1,
1235
    .max_cpus = 4,
1236
};
1237

    
1238
static QEMUMachine ss600mp_machine = {
1239
    .name = "SS-600MP",
1240
    .desc = "Sun4m platform, SPARCserver 600MP",
1241
    .init = ss600mp_init,
1242
    .use_scsi = 1,
1243
    .max_cpus = 4,
1244
};
1245

    
1246
static QEMUMachine ss20_machine = {
1247
    .name = "SS-20",
1248
    .desc = "Sun4m platform, SPARCstation 20",
1249
    .init = ss20_init,
1250
    .use_scsi = 1,
1251
    .max_cpus = 4,
1252
};
1253

    
1254
static QEMUMachine voyager_machine = {
1255
    .name = "Voyager",
1256
    .desc = "Sun4m platform, SPARCstation Voyager",
1257
    .init = vger_init,
1258
    .use_scsi = 1,
1259
};
1260

    
1261
static QEMUMachine ss_lx_machine = {
1262
    .name = "LX",
1263
    .desc = "Sun4m platform, SPARCstation LX",
1264
    .init = ss_lx_init,
1265
    .use_scsi = 1,
1266
};
1267

    
1268
static QEMUMachine ss4_machine = {
1269
    .name = "SS-4",
1270
    .desc = "Sun4m platform, SPARCstation 4",
1271
    .init = ss4_init,
1272
    .use_scsi = 1,
1273
};
1274

    
1275
static QEMUMachine scls_machine = {
1276
    .name = "SPARCClassic",
1277
    .desc = "Sun4m platform, SPARCClassic",
1278
    .init = scls_init,
1279
    .use_scsi = 1,
1280
};
1281

    
1282
static QEMUMachine sbook_machine = {
1283
    .name = "SPARCbook",
1284
    .desc = "Sun4m platform, SPARCbook",
1285
    .init = sbook_init,
1286
    .use_scsi = 1,
1287
};
1288

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

    
1344
static DeviceState *sbi_init(a_target_phys_addr addr, qemu_irq **parent_irq)
1345
{
1346
    DeviceState *dev;
1347
    SysBusDevice *s;
1348
    unsigned int i;
1349

    
1350
    dev = qdev_create(NULL, "sbi");
1351
    qdev_init(dev);
1352

    
1353
    s = sysbus_from_qdev(dev);
1354

    
1355
    for (i = 0; i < MAX_CPUS; i++) {
1356
        sysbus_connect_irq(s, i, *parent_irq[i]);
1357
    }
1358

    
1359
    sysbus_mmio_map(s, 0, addr);
1360

    
1361
    return dev;
1362
}
1363

    
1364
static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, a_ram_addr RAM_size,
1365
                          const char *boot_device,
1366
                          const char *kernel_filename,
1367
                          const char *kernel_cmdline,
1368
                          const char *initrd_filename, const char *cpu_model)
1369
{
1370
    CPUState *envs[MAX_CPUS];
1371
    unsigned int i;
1372
    void *iounits[MAX_IOUNITS], *espdma, *ledma, *nvram;
1373
    qemu_irq *cpu_irqs[MAX_CPUS], sbi_irq[32], sbi_cpu_irq[MAX_CPUS],
1374
        espdma_irq, ledma_irq;
1375
    qemu_irq esp_reset;
1376
    unsigned long kernel_size;
1377
    void *fw_cfg;
1378
    DeviceState *dev;
1379

    
1380
    /* init CPUs */
1381
    if (!cpu_model)
1382
        cpu_model = hwdef->default_cpu_model;
1383

    
1384
    for(i = 0; i < smp_cpus; i++) {
1385
        envs[i] = cpu_devinit(cpu_model, i, hwdef->slavio_base, &cpu_irqs[i]);
1386
    }
1387

    
1388
    for (i = smp_cpus; i < MAX_CPUS; i++)
1389
        cpu_irqs[i] = qemu_allocate_irqs(dummy_cpu_set_irq, NULL, MAX_PILS);
1390

    
1391
    /* set up devices */
1392
    ram_init(0, RAM_size, hwdef->max_mem);
1393

    
1394
    prom_init(hwdef->slavio_base, bios_name);
1395

    
1396
    dev = sbi_init(hwdef->sbi_base, cpu_irqs);
1397

    
1398
    for (i = 0; i < 32; i++) {
1399
        sbi_irq[i] = qdev_get_gpio_in(dev, i);
1400
    }
1401
    for (i = 0; i < MAX_CPUS; i++) {
1402
        sbi_cpu_irq[i] = qdev_get_gpio_in(dev, 32 + i);
1403
    }
1404

    
1405
    for (i = 0; i < MAX_IOUNITS; i++)
1406
        if (hwdef->iounit_bases[i] != (a_target_phys_addr)-1)
1407
            iounits[i] = iommu_init(hwdef->iounit_bases[i],
1408
                                    hwdef->iounit_version,
1409
                                    sbi_irq[0]);
1410

    
1411
    espdma = sparc32_dma_init(hwdef->espdma_base, sbi_irq[3],
1412
                              iounits[0], &espdma_irq);
1413

    
1414
    ledma = sparc32_dma_init(hwdef->ledma_base, sbi_irq[4],
1415
                             iounits[0], &ledma_irq);
1416

    
1417
    if (graphic_depth != 8 && graphic_depth != 24) {
1418
        fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth);
1419
        exit (1);
1420
    }
1421
    tcx_init(hwdef->tcx_base, 0x00100000, graphic_width, graphic_height,
1422
             graphic_depth);
1423

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

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

    
1428
    slavio_timer_init_all(hwdef->counter_base, sbi_irq[10], sbi_cpu_irq, smp_cpus);
1429

    
1430
    slavio_serial_ms_kbd_init(hwdef->ms_kb_base, sbi_irq[12],
1431
                              display_type == DT_NOGRAPHIC, ESCC_CLOCK, 1);
1432
    // Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
1433
    // Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
1434
    escc_init(hwdef->serial_base, sbi_irq[12], sbi_irq[12],
1435
              serial_hds[0], serial_hds[1], ESCC_CLOCK, 1);
1436

    
1437
    if (drive_get_max_bus(IF_SCSI) > 0) {
1438
        fprintf(stderr, "qemu: too many SCSI bus\n");
1439
        exit(1);
1440
    }
1441

    
1442
    esp_reset = qdev_get_gpio_in(espdma, 0);
1443
    esp_init(hwdef->esp_base, 2,
1444
             espdma_memory_read, espdma_memory_write,
1445
             espdma, espdma_irq, &esp_reset);
1446

    
1447
    kernel_size = sun4m_load_kernel(kernel_filename, initrd_filename,
1448
                                    RAM_size);
1449

    
1450
    nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
1451
               boot_device, RAM_size, kernel_size, graphic_width,
1452
               graphic_height, graphic_depth, hwdef->nvram_machine_id,
1453
               "Sun4d");
1454

    
1455
    fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2);
1456
    fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
1457
    fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
1458
    fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id);
1459
    fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_DEPTH, graphic_depth);
1460
    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, KERNEL_LOAD_ADDR);
1461
    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
1462
    if (kernel_cmdline) {
1463
        fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);
1464
        pstrcpy_targphys(CMDLINE_ADDR, TARGET_PAGE_SIZE, kernel_cmdline);
1465
    } else {
1466
        fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
1467
    }
1468
    fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, INITRD_LOAD_ADDR);
1469
    fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, 0); // not used
1470
    fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, boot_device[0]);
1471
    qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
1472
}
1473

    
1474
/* SPARCserver 1000 hardware initialisation */
1475
static void ss1000_init(a_ram_addr 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[0], RAM_size, boot_device, kernel_filename,
1481
                  kernel_cmdline, initrd_filename, cpu_model);
1482
}
1483

    
1484
/* SPARCcenter 2000 hardware initialisation */
1485
static void ss2000_init(a_ram_addr RAM_size,
1486
                        const char *boot_device,
1487
                        const char *kernel_filename, const char *kernel_cmdline,
1488
                        const char *initrd_filename, const char *cpu_model)
1489
{
1490
    sun4d_hw_init(&sun4d_hwdefs[1], RAM_size, boot_device, kernel_filename,
1491
                  kernel_cmdline, initrd_filename, cpu_model);
1492
}
1493

    
1494
static QEMUMachine ss1000_machine = {
1495
    .name = "SS-1000",
1496
    .desc = "Sun4d platform, SPARCserver 1000",
1497
    .init = ss1000_init,
1498
    .use_scsi = 1,
1499
    .max_cpus = 8,
1500
};
1501

    
1502
static QEMUMachine ss2000_machine = {
1503
    .name = "SS-2000",
1504
    .desc = "Sun4d platform, SPARCcenter 2000",
1505
    .init = ss2000_init,
1506
    .use_scsi = 1,
1507
    .max_cpus = 20,
1508
};
1509

    
1510
static const struct sun4c_hwdef sun4c_hwdefs[] = {
1511
    /* SS-2 */
1512
    {
1513
        .iommu_base   = 0xf8000000,
1514
        .tcx_base     = 0xfe000000,
1515
        .slavio_base  = 0xf6000000,
1516
        .intctl_base  = 0xf5000000,
1517
        .counter_base = 0xf3000000,
1518
        .ms_kb_base   = 0xf0000000,
1519
        .serial_base  = 0xf1000000,
1520
        .nvram_base   = 0xf2000000,
1521
        .fd_base      = 0xf7200000,
1522
        .dma_base     = 0xf8400000,
1523
        .esp_base     = 0xf8800000,
1524
        .le_base      = 0xf8c00000,
1525
        .aux1_base    = 0xf7400003,
1526
        .nvram_machine_id = 0x55,
1527
        .machine_id = ss2_id,
1528
        .max_mem = 0x10000000,
1529
        .default_cpu_model = "Cypress CY7C601",
1530
    },
1531
};
1532

    
1533
static DeviceState *sun4c_intctl_init(a_target_phys_addr addr,
1534
                                      qemu_irq *parent_irq)
1535
{
1536
    DeviceState *dev;
1537
    SysBusDevice *s;
1538
    unsigned int i;
1539

    
1540
    dev = qdev_create(NULL, "sun4c_intctl");
1541
    qdev_init(dev);
1542

    
1543
    s = sysbus_from_qdev(dev);
1544

    
1545
    for (i = 0; i < MAX_PILS; i++) {
1546
        sysbus_connect_irq(s, i, parent_irq[i]);
1547
    }
1548
    sysbus_mmio_map(s, 0, addr);
1549

    
1550
    return dev;
1551
}
1552

    
1553
static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, a_ram_addr RAM_size,
1554
                          const char *boot_device,
1555
                          const char *kernel_filename,
1556
                          const char *kernel_cmdline,
1557
                          const char *initrd_filename, const char *cpu_model)
1558
{
1559
    CPUState *env;
1560
    void *iommu, *espdma, *ledma, *nvram;
1561
    qemu_irq *cpu_irqs, slavio_irq[8], espdma_irq, ledma_irq;
1562
    qemu_irq esp_reset;
1563
    qemu_irq fdc_tc;
1564
    unsigned long kernel_size;
1565
    BlockDriverState *fd[MAX_FD];
1566
    void *fw_cfg;
1567
    DeviceState *dev;
1568
    unsigned int i;
1569
    DriveInfo *dinfo;
1570

    
1571
    /* init CPU */
1572
    if (!cpu_model)
1573
        cpu_model = hwdef->default_cpu_model;
1574

    
1575
    env = cpu_devinit(cpu_model, 0, hwdef->slavio_base, &cpu_irqs);
1576

    
1577
    /* set up devices */
1578
    ram_init(0, RAM_size, hwdef->max_mem);
1579

    
1580
    prom_init(hwdef->slavio_base, bios_name);
1581

    
1582
    dev = sun4c_intctl_init(hwdef->intctl_base, cpu_irqs);
1583

    
1584
    for (i = 0; i < 8; i++) {
1585
        slavio_irq[i] = qdev_get_gpio_in(dev, i);
1586
    }
1587

    
1588
    iommu = iommu_init(hwdef->iommu_base, hwdef->iommu_version,
1589
                       slavio_irq[1]);
1590

    
1591
    espdma = sparc32_dma_init(hwdef->dma_base, slavio_irq[2],
1592
                              iommu, &espdma_irq);
1593

    
1594
    ledma = sparc32_dma_init(hwdef->dma_base + 16ULL,
1595
                             slavio_irq[3], iommu, &ledma_irq);
1596

    
1597
    if (graphic_depth != 8 && graphic_depth != 24) {
1598
        fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth);
1599
        exit (1);
1600
    }
1601
    tcx_init(hwdef->tcx_base, 0x00100000, graphic_width, graphic_height,
1602
             graphic_depth);
1603

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

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

    
1608
    slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[1],
1609
                              display_type == DT_NOGRAPHIC, ESCC_CLOCK, 1);
1610
    // Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
1611
    // Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
1612
    escc_init(hwdef->serial_base, slavio_irq[1],
1613
              slavio_irq[1], serial_hds[0], serial_hds[1],
1614
              ESCC_CLOCK, 1);
1615

    
1616
    slavio_misc_init(0, hwdef->aux1_base, 0, slavio_irq[1], fdc_tc);
1617

    
1618
    if (hwdef->fd_base != (a_target_phys_addr)-1) {
1619
        /* there is zero or one floppy drive */
1620
        memset(fd, 0, sizeof(fd));
1621
        dinfo = drive_get(IF_FLOPPY, 0, 0);
1622
        if (dinfo)
1623
            fd[0] = dinfo->bdrv;
1624

    
1625
        sun4m_fdctrl_init(slavio_irq[1], hwdef->fd_base, fd,
1626
                          &fdc_tc);
1627
    }
1628

    
1629
    if (drive_get_max_bus(IF_SCSI) > 0) {
1630
        fprintf(stderr, "qemu: too many SCSI bus\n");
1631
        exit(1);
1632
    }
1633

    
1634
    esp_reset = qdev_get_gpio_in(espdma, 0);
1635
    esp_init(hwdef->esp_base, 2,
1636
             espdma_memory_read, espdma_memory_write,
1637
             espdma, espdma_irq, &esp_reset);
1638

    
1639
    kernel_size = sun4m_load_kernel(kernel_filename, initrd_filename,
1640
                                    RAM_size);
1641

    
1642
    nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
1643
               boot_device, RAM_size, kernel_size, graphic_width,
1644
               graphic_height, graphic_depth, hwdef->nvram_machine_id,
1645
               "Sun4c");
1646

    
1647
    fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2);
1648
    fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
1649
    fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
1650
    fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id);
1651
    fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_DEPTH, graphic_depth);
1652
    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, KERNEL_LOAD_ADDR);
1653
    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
1654
    if (kernel_cmdline) {
1655
        fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);
1656
        pstrcpy_targphys(CMDLINE_ADDR, TARGET_PAGE_SIZE, kernel_cmdline);
1657
    } else {
1658
        fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
1659
    }
1660
    fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, INITRD_LOAD_ADDR);
1661
    fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, 0); // not used
1662
    fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, boot_device[0]);
1663
    qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
1664
}
1665

    
1666
/* SPARCstation 2 hardware initialisation */
1667
static void ss2_init(a_ram_addr RAM_size,
1668
                     const char *boot_device,
1669
                     const char *kernel_filename, const char *kernel_cmdline,
1670
                     const char *initrd_filename, const char *cpu_model)
1671
{
1672
    sun4c_hw_init(&sun4c_hwdefs[0], RAM_size, boot_device, kernel_filename,
1673
                  kernel_cmdline, initrd_filename, cpu_model);
1674
}
1675

    
1676
static QEMUMachine ss2_machine = {
1677
    .name = "SS-2",
1678
    .desc = "Sun4c platform, SPARCstation 2",
1679
    .init = ss2_init,
1680
    .use_scsi = 1,
1681
};
1682

    
1683
static void ss2_machine_init(void)
1684
{
1685
    qemu_register_machine(&ss5_machine);
1686
    qemu_register_machine(&ss10_machine);
1687
    qemu_register_machine(&ss600mp_machine);
1688
    qemu_register_machine(&ss20_machine);
1689
    qemu_register_machine(&voyager_machine);
1690
    qemu_register_machine(&ss_lx_machine);
1691
    qemu_register_machine(&ss4_machine);
1692
    qemu_register_machine(&scls_machine);
1693
    qemu_register_machine(&sbook_machine);
1694
    qemu_register_machine(&ss1000_machine);
1695
    qemu_register_machine(&ss2000_machine);
1696
    qemu_register_machine(&ss2_machine);
1697
}
1698

    
1699
machine_init(ss2_machine_init);