Statistics
| Branch: | Revision:

root / hw / sun4m.c @ e4bcb14c

History | View | Annotate | Download (20.7 kB)

1
/*
2
 * QEMU Sun4m 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 "hw.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

    
35
//#define DEBUG_IRQ
36

    
37
/*
38
 * Sun4m architecture was used in the following machines:
39
 *
40
 * SPARCserver 6xxMP/xx
41
 * SPARCclassic (SPARCclassic Server)(SPARCstation LC) (4/15), SPARCclassic X (4/10)
42
 * SPARCstation LX/ZX (4/30)
43
 * SPARCstation Voyager
44
 * SPARCstation 10/xx, SPARCserver 10/xx
45
 * SPARCstation 5, SPARCserver 5
46
 * SPARCstation 20/xx, SPARCserver 20
47
 * SPARCstation 4
48
 *
49
 * See for example: http://www.sunhelp.org/faq/sunref1.html
50
 */
51

    
52
#ifdef DEBUG_IRQ
53
#define DPRINTF(fmt, args...)                           \
54
    do { printf("CPUIRQ: " fmt , ##args); } while (0)
55
#else
56
#define DPRINTF(fmt, args...)
57
#endif
58

    
59
#define KERNEL_LOAD_ADDR     0x00004000
60
#define CMDLINE_ADDR         0x007ff000
61
#define INITRD_LOAD_ADDR     0x00800000
62
#define PROM_SIZE_MAX        (512 * 1024)
63
#define PROM_VADDR           0xffd00000
64
#define PROM_FILENAME        "openbios-sparc32"
65

    
66
#define MAX_CPUS 16
67
#define MAX_PILS 16
68

    
69
struct hwdef {
70
    target_phys_addr_t iommu_base, slavio_base;
71
    target_phys_addr_t intctl_base, counter_base, nvram_base, ms_kb_base;
72
    target_phys_addr_t serial_base, fd_base;
73
    target_phys_addr_t dma_base, esp_base, le_base;
74
    target_phys_addr_t tcx_base, cs_base, power_base;
75
    long vram_size, nvram_size;
76
    // IRQ numbers are not PIL ones, but master interrupt controller register
77
    // bit numbers
78
    int intctl_g_intr, esp_irq, le_irq, clock_irq, clock1_irq;
79
    int ser_irq, ms_kb_irq, fd_irq, me_irq, cs_irq;
80
    int machine_id; // For NVRAM
81
    uint32_t iommu_version;
82
    uint32_t intbit_to_level[32];
83
    uint64_t max_mem;
84
    const char * const default_cpu_model;
85
};
86

    
87
/* TSC handling */
88

    
89
uint64_t cpu_get_tsc()
90
{
91
    return qemu_get_clock(vm_clock);
92
}
93

    
94
int DMA_get_channel_mode (int nchan)
95
{
96
    return 0;
97
}
98
int DMA_read_memory (int nchan, void *buf, int pos, int size)
99
{
100
    return 0;
101
}
102
int DMA_write_memory (int nchan, void *buf, int pos, int size)
103
{
104
    return 0;
105
}
106
void DMA_hold_DREQ (int nchan) {}
107
void DMA_release_DREQ (int nchan) {}
108
void DMA_schedule(int nchan) {}
109
void DMA_run (void) {}
110
void DMA_init (int high_page_enable) {}
111
void DMA_register_channel (int nchan,
112
                           DMA_transfer_handler transfer_handler,
113
                           void *opaque)
114
{
115
}
116

    
117
extern int nographic;
118

    
119
static void nvram_init(m48t59_t *nvram, uint8_t *macaddr, const char *cmdline,
120
                       const char *boot_devices, uint32_t RAM_size,
121
                       uint32_t kernel_size,
122
                       int width, int height, int depth,
123
                       int machine_id)
124
{
125
    unsigned int i;
126
    uint32_t start, end;
127
    uint8_t image[0x1ff0];
128
    ohwcfg_v3_t *header = (ohwcfg_v3_t *)ℑ
129
    struct sparc_arch_cfg *sparc_header;
130
    struct OpenBIOS_nvpart_v1 *part_header;
131

    
132
    memset(image, '\0', sizeof(image));
133

    
134
    // Try to match PPC NVRAM
135
    strcpy(header->struct_ident, "QEMU_BIOS");
136
    header->struct_version = cpu_to_be32(3); /* structure v3 */
137

    
138
    header->nvram_size = cpu_to_be16(0x2000);
139
    header->nvram_arch_ptr = cpu_to_be16(sizeof(ohwcfg_v3_t));
140
    header->nvram_arch_size = cpu_to_be16(sizeof(struct sparc_arch_cfg));
141
    strcpy(header->arch, "sun4m");
142
    header->nb_cpus = smp_cpus & 0xff;
143
    header->RAM0_base = 0;
144
    header->RAM0_size = cpu_to_be64((uint64_t)RAM_size);
145
    strcpy(header->boot_devices, boot_devices);
146
    header->nboot_devices = strlen(boot_devices) & 0xff;
147
    header->kernel_image = cpu_to_be64((uint64_t)KERNEL_LOAD_ADDR);
148
    header->kernel_size = cpu_to_be64((uint64_t)kernel_size);
149
    if (cmdline) {
150
        strcpy(phys_ram_base + CMDLINE_ADDR, cmdline);
151
        header->cmdline = cpu_to_be64((uint64_t)CMDLINE_ADDR);
152
        header->cmdline_size = cpu_to_be64((uint64_t)strlen(cmdline));
153
    }
154
    // XXX add initrd_image, initrd_size
155
    header->width = cpu_to_be16(width);
156
    header->height = cpu_to_be16(height);
157
    header->depth = cpu_to_be16(depth);
158
    if (nographic)
159
        header->graphic_flags = cpu_to_be16(OHW_GF_NOGRAPHICS);
160

    
161
    header->crc = cpu_to_be16(OHW_compute_crc(header, 0x00, 0xF8));
162

    
163
    // Architecture specific header
164
    start = sizeof(ohwcfg_v3_t);
165
    sparc_header = (struct sparc_arch_cfg *)&image[start];
166
    sparc_header->valid = 0;
167
    start += sizeof(struct sparc_arch_cfg);
168

    
169
    // OpenBIOS nvram variables
170
    // Variable partition
171
    part_header = (struct OpenBIOS_nvpart_v1 *)&image[start];
172
    part_header->signature = OPENBIOS_PART_SYSTEM;
173
    strcpy(part_header->name, "system");
174

    
175
    end = start + sizeof(struct OpenBIOS_nvpart_v1);
176
    for (i = 0; i < nb_prom_envs; i++)
177
        end = OpenBIOS_set_var(image, end, prom_envs[i]);
178

    
179
    // End marker
180
    image[end++] = '\0';
181

    
182
    end = start + ((end - start + 15) & ~15);
183
    OpenBIOS_finish_partition(part_header, end - start);
184

    
185
    // free partition
186
    start = end;
187
    part_header = (struct OpenBIOS_nvpart_v1 *)&image[start];
188
    part_header->signature = OPENBIOS_PART_FREE;
189
    strcpy(part_header->name, "free");
190

    
191
    end = 0x1fd0;
192
    OpenBIOS_finish_partition(part_header, end - start);
193

    
194
    Sun_init_header((struct Sun_nvram *)&image[0x1fd8], macaddr, machine_id);
195

    
196
    for (i = 0; i < sizeof(image); i++)
197
        m48t59_write(nvram, i, image[i]);
198
}
199

    
200
static void *slavio_intctl;
201

    
202
void pic_info()
203
{
204
    slavio_pic_info(slavio_intctl);
205
}
206

    
207
void irq_info()
208
{
209
    slavio_irq_info(slavio_intctl);
210
}
211

    
212
void cpu_check_irqs(CPUState *env)
213
{
214
    if (env->pil_in && (env->interrupt_index == 0 ||
215
                        (env->interrupt_index & ~15) == TT_EXTINT)) {
216
        unsigned int i;
217

    
218
        for (i = 15; i > 0; i--) {
219
            if (env->pil_in & (1 << i)) {
220
                int old_interrupt = env->interrupt_index;
221

    
222
                env->interrupt_index = TT_EXTINT | i;
223
                if (old_interrupt != env->interrupt_index)
224
                    cpu_interrupt(env, CPU_INTERRUPT_HARD);
225
                break;
226
            }
227
        }
228
    } else if (!env->pil_in && (env->interrupt_index & ~15) == TT_EXTINT) {
229
        env->interrupt_index = 0;
230
        cpu_reset_interrupt(env, CPU_INTERRUPT_HARD);
231
    }
232
}
233

    
234
static void cpu_set_irq(void *opaque, int irq, int level)
235
{
236
    CPUState *env = opaque;
237

    
238
    if (level) {
239
        DPRINTF("Raise CPU IRQ %d\n", irq);
240
        env->halted = 0;
241
        env->pil_in |= 1 << irq;
242
        cpu_check_irqs(env);
243
    } else {
244
        DPRINTF("Lower CPU IRQ %d\n", irq);
245
        env->pil_in &= ~(1 << irq);
246
        cpu_check_irqs(env);
247
    }
248
}
249

    
250
static void dummy_cpu_set_irq(void *opaque, int irq, int level)
251
{
252
}
253

    
254
static void *slavio_misc;
255

    
256
void qemu_system_powerdown(void)
257
{
258
    slavio_set_power_fail(slavio_misc, 1);
259
}
260

    
261
static void main_cpu_reset(void *opaque)
262
{
263
    CPUState *env = opaque;
264

    
265
    cpu_reset(env);
266
    env->halted = 0;
267
}
268

    
269
static void secondary_cpu_reset(void *opaque)
270
{
271
    CPUState *env = opaque;
272

    
273
    cpu_reset(env);
274
    env->halted = 1;
275
}
276

    
277
static unsigned long sun4m_load_kernel(const char *kernel_filename,
278
                                       const char *kernel_cmdline,
279
                                       const char *initrd_filename)
280
{
281
    int linux_boot;
282
    unsigned int i;
283
    long initrd_size, kernel_size;
284

    
285
    linux_boot = (kernel_filename != NULL);
286

    
287
    kernel_size = 0;
288
    if (linux_boot) {
289
        kernel_size = load_elf(kernel_filename, -0xf0000000ULL, NULL, NULL,
290
                               NULL);
291
        if (kernel_size < 0)
292
            kernel_size = load_aout(kernel_filename, phys_ram_base + KERNEL_LOAD_ADDR);
293
        if (kernel_size < 0)
294
            kernel_size = load_image(kernel_filename, phys_ram_base + KERNEL_LOAD_ADDR);
295
        if (kernel_size < 0) {
296
            fprintf(stderr, "qemu: could not load kernel '%s'\n",
297
                    kernel_filename);
298
            exit(1);
299
        }
300

    
301
        /* load initrd */
302
        initrd_size = 0;
303
        if (initrd_filename) {
304
            initrd_size = load_image(initrd_filename, phys_ram_base + INITRD_LOAD_ADDR);
305
            if (initrd_size < 0) {
306
                fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
307
                        initrd_filename);
308
                exit(1);
309
            }
310
        }
311
        if (initrd_size > 0) {
312
            for (i = 0; i < 64 * TARGET_PAGE_SIZE; i += TARGET_PAGE_SIZE) {
313
                if (ldl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i)
314
                    == 0x48647253) { // HdrS
315
                    stl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i + 16, INITRD_LOAD_ADDR);
316
                    stl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i + 20, initrd_size);
317
                    break;
318
                }
319
            }
320
        }
321
    }
322
    return kernel_size;
323
}
324

    
325
static void sun4m_hw_init(const struct hwdef *hwdef, int RAM_size,
326
                          const char *boot_device,
327
                          DisplayState *ds, const char *kernel_filename,
328
                          const char *kernel_cmdline,
329
                          const char *initrd_filename, const char *cpu_model)
330

    
331
{
332
    CPUState *env, *envs[MAX_CPUS];
333
    unsigned int i;
334
    void *iommu, *espdma, *ledma, *main_esp, *nvram;
335
    qemu_irq *cpu_irqs[MAX_CPUS], *slavio_irq, *slavio_cpu_irq,
336
        *espdma_irq, *ledma_irq;
337
    qemu_irq *esp_reset, *le_reset;
338
    unsigned long prom_offset, kernel_size;
339
    int ret;
340
    char buf[1024];
341
    BlockDriverState *fd[MAX_FD];
342
    int index;
343

    
344
    /* init CPUs */
345
    if (!cpu_model)
346
        cpu_model = hwdef->default_cpu_model;
347

    
348
    for(i = 0; i < smp_cpus; i++) {
349
        env = cpu_init(cpu_model);
350
        if (!env) {
351
            fprintf(stderr, "Unable to find Sparc CPU definition\n");
352
            exit(1);
353
        }
354
        cpu_sparc_set_id(env, i);
355
        envs[i] = env;
356
        if (i == 0) {
357
            qemu_register_reset(main_cpu_reset, env);
358
        } else {
359
            qemu_register_reset(secondary_cpu_reset, env);
360
            env->halted = 1;
361
        }
362
        register_savevm("cpu", i, 3, cpu_save, cpu_load, env);
363
        cpu_irqs[i] = qemu_allocate_irqs(cpu_set_irq, envs[i], MAX_PILS);
364
        env->prom_addr = hwdef->slavio_base;
365
    }
366

    
367
    for (i = smp_cpus; i < MAX_CPUS; i++)
368
        cpu_irqs[i] = qemu_allocate_irqs(dummy_cpu_set_irq, NULL, MAX_PILS);
369

    
370

    
371
    /* allocate RAM */
372
    if ((uint64_t)RAM_size > hwdef->max_mem) {
373
        fprintf(stderr, "qemu: Too much memory for this machine: %d, maximum %d\n",
374
                (unsigned int)RAM_size / (1024 * 1024),
375
                (unsigned int)(hwdef->max_mem / (1024 * 1024)));
376
        exit(1);
377
    }
378
    cpu_register_physical_memory(0, RAM_size, 0);
379

    
380
    /* load boot prom */
381
    prom_offset = RAM_size + hwdef->vram_size;
382
    cpu_register_physical_memory(hwdef->slavio_base,
383
                                 (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) &
384
                                 TARGET_PAGE_MASK,
385
                                 prom_offset | IO_MEM_ROM);
386

    
387
    if (bios_name == NULL)
388
        bios_name = PROM_FILENAME;
389
    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
390
    ret = load_elf(buf, hwdef->slavio_base - PROM_VADDR, NULL, NULL, NULL);
391
    if (ret < 0 || ret > PROM_SIZE_MAX)
392
        ret = load_image(buf, phys_ram_base + prom_offset);
393
    if (ret < 0 || ret > PROM_SIZE_MAX) {
394
        fprintf(stderr, "qemu: could not load prom '%s'\n",
395
                buf);
396
        exit(1);
397
    }
398

    
399
    /* set up devices */
400
    iommu = iommu_init(hwdef->iommu_base, hwdef->iommu_version);
401
    slavio_intctl = slavio_intctl_init(hwdef->intctl_base,
402
                                       hwdef->intctl_base + 0x10000ULL,
403
                                       &hwdef->intbit_to_level[0],
404
                                       &slavio_irq, &slavio_cpu_irq,
405
                                       cpu_irqs,
406
                                       hwdef->clock_irq);
407

    
408
    espdma = sparc32_dma_init(hwdef->dma_base, slavio_irq[hwdef->esp_irq],
409
                              iommu, &espdma_irq, &esp_reset);
410

    
411
    ledma = sparc32_dma_init(hwdef->dma_base + 16ULL,
412
                             slavio_irq[hwdef->le_irq], iommu, &ledma_irq,
413
                             &le_reset);
414

    
415
    if (graphic_depth != 8 && graphic_depth != 24) {
416
        fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth);
417
        exit (1);
418
    }
419
    tcx_init(ds, hwdef->tcx_base, phys_ram_base + RAM_size, RAM_size,
420
             hwdef->vram_size, graphic_width, graphic_height, graphic_depth);
421

    
422
    if (nd_table[0].model == NULL
423
        || strcmp(nd_table[0].model, "lance") == 0) {
424
        lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
425
    } else if (strcmp(nd_table[0].model, "?") == 0) {
426
        fprintf(stderr, "qemu: Supported NICs: lance\n");
427
        exit (1);
428
    } else {
429
        fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
430
        exit (1);
431
    }
432

    
433
    nvram = m48t59_init(slavio_irq[0], hwdef->nvram_base, 0,
434
                        hwdef->nvram_size, 8);
435

    
436
    slavio_timer_init_all(hwdef->counter_base, slavio_irq[hwdef->clock1_irq],
437
                          slavio_cpu_irq);
438

    
439
    slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[hwdef->ms_kb_irq]);
440
    // Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
441
    // Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
442
    slavio_serial_init(hwdef->serial_base, slavio_irq[hwdef->ser_irq],
443
                       serial_hds[1], serial_hds[0]);
444

    
445
    if (hwdef->fd_base != (target_phys_addr_t)-1) {
446
        /* there is zero or one floppy drive */
447
        fd[1] = fd[0] = NULL;
448
        index = drive_get_index(IF_FLOPPY, 0, 0);
449
        if (index != -1)
450
            fd[0] = drives_table[index].bdrv;
451

    
452
        sun4m_fdctrl_init(slavio_irq[hwdef->fd_irq], hwdef->fd_base, fd);
453
    }
454

    
455
    if (drive_get_max_bus(IF_SCSI) > 0) {
456
        fprintf(stderr, "qemu: too many SCSI bus\n");
457
        exit(1);
458
    }
459

    
460
    main_esp = esp_init(hwdef->esp_base, espdma, *espdma_irq,
461
                        esp_reset);
462

    
463
    for (i = 0; i < ESP_MAX_DEVS; i++) {
464
        index = drive_get_index(IF_SCSI, 0, i);
465
        if (index == -1)
466
            continue;
467
        esp_scsi_attach(main_esp, drives_table[index].bdrv, i);
468
    }
469

    
470
    slavio_misc = slavio_misc_init(hwdef->slavio_base, hwdef->power_base,
471
                                   slavio_irq[hwdef->me_irq]);
472
    if (hwdef->cs_base != (target_phys_addr_t)-1)
473
        cs_init(hwdef->cs_base, hwdef->cs_irq, slavio_intctl);
474

    
475
    kernel_size = sun4m_load_kernel(kernel_filename, kernel_cmdline,
476
                                    initrd_filename);
477

    
478
    nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
479
               boot_device, RAM_size, kernel_size, graphic_width,
480
               graphic_height, graphic_depth, hwdef->machine_id);
481
}
482

    
483
static const struct hwdef hwdefs[] = {
484
    /* SS-5 */
485
    {
486
        .iommu_base   = 0x10000000,
487
        .tcx_base     = 0x50000000,
488
        .cs_base      = 0x6c000000,
489
        .slavio_base  = 0x70000000,
490
        .ms_kb_base   = 0x71000000,
491
        .serial_base  = 0x71100000,
492
        .nvram_base   = 0x71200000,
493
        .fd_base      = 0x71400000,
494
        .counter_base = 0x71d00000,
495
        .intctl_base  = 0x71e00000,
496
        .dma_base     = 0x78400000,
497
        .esp_base     = 0x78800000,
498
        .le_base      = 0x78c00000,
499
        .power_base   = 0x7a000000,
500
        .vram_size    = 0x00100000,
501
        .nvram_size   = 0x2000,
502
        .esp_irq = 18,
503
        .le_irq = 16,
504
        .clock_irq = 7,
505
        .clock1_irq = 19,
506
        .ms_kb_irq = 14,
507
        .ser_irq = 15,
508
        .fd_irq = 22,
509
        .me_irq = 30,
510
        .cs_irq = 5,
511
        .machine_id = 0x80,
512
        .iommu_version = 0x04000000,
513
        .intbit_to_level = {
514
            2, 3, 5, 7, 9, 11, 0, 14,   3, 5, 7, 9, 11, 13, 12, 12,
515
            6, 0, 4, 10, 8, 0, 11, 0,   0, 0, 0, 0, 15, 0, 15, 0,
516
        },
517
        .max_mem = 0x10000000,
518
        .default_cpu_model = "Fujitsu MB86904",
519
    },
520
    /* SS-10 */
521
    {
522
        .iommu_base   = 0xfe0000000ULL,
523
        .tcx_base     = 0xe20000000ULL,
524
        .cs_base      = -1,
525
        .slavio_base  = 0xff0000000ULL,
526
        .ms_kb_base   = 0xff1000000ULL,
527
        .serial_base  = 0xff1100000ULL,
528
        .nvram_base   = 0xff1200000ULL,
529
        .fd_base      = 0xff1700000ULL,
530
        .counter_base = 0xff1300000ULL,
531
        .intctl_base  = 0xff1400000ULL,
532
        .dma_base     = 0xef0400000ULL,
533
        .esp_base     = 0xef0800000ULL,
534
        .le_base      = 0xef0c00000ULL,
535
        .power_base   = 0xefa000000ULL,
536
        .vram_size    = 0x00100000,
537
        .nvram_size   = 0x2000,
538
        .esp_irq = 18,
539
        .le_irq = 16,
540
        .clock_irq = 7,
541
        .clock1_irq = 19,
542
        .ms_kb_irq = 14,
543
        .ser_irq = 15,
544
        .fd_irq = 22,
545
        .me_irq = 30,
546
        .cs_irq = -1,
547
        .machine_id = 0x72,
548
        .iommu_version = 0x03000000,
549
        .intbit_to_level = {
550
            2, 3, 5, 7, 9, 11, 0, 14,   3, 5, 7, 9, 11, 13, 12, 12,
551
            6, 0, 4, 10, 8, 0, 11, 0,   0, 0, 0, 0, 15, 0, 15, 0,
552
        },
553
        .max_mem = 0xffffffff, // XXX actually first 62GB ok
554
        .default_cpu_model = "TI SuperSparc II",
555
    },
556
    /* SS-600MP */
557
    {
558
        .iommu_base   = 0xfe0000000ULL,
559
        .tcx_base     = 0xe20000000ULL,
560
        .cs_base      = -1,
561
        .slavio_base  = 0xff0000000ULL,
562
        .ms_kb_base   = 0xff1000000ULL,
563
        .serial_base  = 0xff1100000ULL,
564
        .nvram_base   = 0xff1200000ULL,
565
        .fd_base      = -1,
566
        .counter_base = 0xff1300000ULL,
567
        .intctl_base  = 0xff1400000ULL,
568
        .dma_base     = 0xef0081000ULL,
569
        .esp_base     = 0xef0080000ULL,
570
        .le_base      = 0xef0060000ULL,
571
        .power_base   = 0xefa000000ULL,
572
        .vram_size    = 0x00100000,
573
        .nvram_size   = 0x2000,
574
        .esp_irq = 18,
575
        .le_irq = 16,
576
        .clock_irq = 7,
577
        .clock1_irq = 19,
578
        .ms_kb_irq = 14,
579
        .ser_irq = 15,
580
        .fd_irq = 22,
581
        .me_irq = 30,
582
        .cs_irq = -1,
583
        .machine_id = 0x71,
584
        .iommu_version = 0x01000000,
585
        .intbit_to_level = {
586
            2, 3, 5, 7, 9, 11, 0, 14,   3, 5, 7, 9, 11, 13, 12, 12,
587
            6, 0, 4, 10, 8, 0, 11, 0,   0, 0, 0, 0, 15, 0, 15, 0,
588
        },
589
        .max_mem = 0xffffffff, // XXX actually first 62GB ok
590
        .default_cpu_model = "TI SuperSparc II",
591
    },
592
};
593

    
594
/* SPARCstation 5 hardware initialisation */
595
static void ss5_init(int RAM_size, int vga_ram_size,
596
                     const char *boot_device, DisplayState *ds,
597
                     const char *kernel_filename, const char *kernel_cmdline,
598
                     const char *initrd_filename, const char *cpu_model)
599
{
600
    sun4m_hw_init(&hwdefs[0], RAM_size, boot_device, ds, kernel_filename,
601
                  kernel_cmdline, initrd_filename, cpu_model);
602
}
603

    
604
/* SPARCstation 10 hardware initialisation */
605
static void ss10_init(int RAM_size, int vga_ram_size,
606
                      const char *boot_device, DisplayState *ds,
607
                      const char *kernel_filename, const char *kernel_cmdline,
608
                      const char *initrd_filename, const char *cpu_model)
609
{
610
    sun4m_hw_init(&hwdefs[1], RAM_size, boot_device, ds, kernel_filename,
611
                  kernel_cmdline, initrd_filename, cpu_model);
612
}
613

    
614
/* SPARCserver 600MP hardware initialisation */
615
static void ss600mp_init(int RAM_size, int vga_ram_size,
616
                         const char *boot_device, DisplayState *ds,
617
                         const char *kernel_filename, const char *kernel_cmdline,
618
                         const char *initrd_filename, const char *cpu_model)
619
{
620
    sun4m_hw_init(&hwdefs[2], RAM_size, boot_device, ds, kernel_filename,
621
                  kernel_cmdline, initrd_filename, cpu_model);
622
}
623

    
624
QEMUMachine ss5_machine = {
625
    "SS-5",
626
    "Sun4m platform, SPARCstation 5",
627
    ss5_init,
628
};
629

    
630
QEMUMachine ss10_machine = {
631
    "SS-10",
632
    "Sun4m platform, SPARCstation 10",
633
    ss10_init,
634
};
635

    
636
QEMUMachine ss600mp_machine = {
637
    "SS-600MP",
638
    "Sun4m platform, SPARCserver 600MP",
639
    ss600mp_init,
640
};