Statistics
| Branch: | Revision:

root / hw / sun4m.c @ 92d88ecb

History | View | Annotate | Download (15.3 kB)

1 420557e8 bellard
/*
2 420557e8 bellard
 * QEMU Sun4m System Emulator
3 420557e8 bellard
 * 
4 b81b3b10 bellard
 * Copyright (c) 2003-2005 Fabrice Bellard
5 420557e8 bellard
 * 
6 420557e8 bellard
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 420557e8 bellard
 * of this software and associated documentation files (the "Software"), to deal
8 420557e8 bellard
 * in the Software without restriction, including without limitation the rights
9 420557e8 bellard
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 420557e8 bellard
 * copies of the Software, and to permit persons to whom the Software is
11 420557e8 bellard
 * furnished to do so, subject to the following conditions:
12 420557e8 bellard
 *
13 420557e8 bellard
 * The above copyright notice and this permission notice shall be included in
14 420557e8 bellard
 * all copies or substantial portions of the Software.
15 420557e8 bellard
 *
16 420557e8 bellard
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 420557e8 bellard
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 420557e8 bellard
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 420557e8 bellard
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 420557e8 bellard
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 420557e8 bellard
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 420557e8 bellard
 * THE SOFTWARE.
23 420557e8 bellard
 */
24 420557e8 bellard
#include "vl.h"
25 420557e8 bellard
26 36cd9210 blueswir1
/*
27 36cd9210 blueswir1
 * Sun4m architecture was used in the following machines:
28 36cd9210 blueswir1
 *
29 36cd9210 blueswir1
 * SPARCserver 6xxMP/xx
30 36cd9210 blueswir1
 * SPARCclassic (SPARCclassic Server)(SPARCstation LC) (4/15), SPARCclassic X (4/10)
31 36cd9210 blueswir1
 * SPARCstation LX/ZX (4/30)
32 36cd9210 blueswir1
 * SPARCstation Voyager
33 36cd9210 blueswir1
 * SPARCstation 10/xx, SPARCserver 10/xx
34 36cd9210 blueswir1
 * SPARCstation 5, SPARCserver 5
35 36cd9210 blueswir1
 * SPARCstation 20/xx, SPARCserver 20
36 36cd9210 blueswir1
 * SPARCstation 4
37 36cd9210 blueswir1
 *
38 36cd9210 blueswir1
 * See for example: http://www.sunhelp.org/faq/sunref1.html
39 36cd9210 blueswir1
 */
40 36cd9210 blueswir1
41 420557e8 bellard
#define KERNEL_LOAD_ADDR     0x00004000
42 b6f479d3 bellard
#define CMDLINE_ADDR         0x007ff000
43 713c45fa bellard
#define INITRD_LOAD_ADDR     0x00800000
44 b3783731 bellard
#define PROM_SIZE_MAX        (256 * 1024)
45 e80cfcfc bellard
#define PROM_ADDR             0xffd00000
46 0986ac3b bellard
#define PROM_FILENAME             "openbios-sparc32"
47 b8174937 bellard
48 ba3c64fb bellard
#define MAX_CPUS 16
49 420557e8 bellard
50 36cd9210 blueswir1
struct hwdef {
51 36cd9210 blueswir1
    target_ulong iommu_base, slavio_base;
52 36cd9210 blueswir1
    target_ulong intctl_base, counter_base, nvram_base, ms_kb_base, serial_base;
53 36cd9210 blueswir1
    target_ulong fd_base;
54 36cd9210 blueswir1
    target_ulong dma_base, esp_base, le_base;
55 36cd9210 blueswir1
    target_ulong tcx_base, cs_base;
56 36cd9210 blueswir1
    long vram_size, nvram_size;
57 36cd9210 blueswir1
    // IRQ numbers are not PIL ones, but master interrupt controller register
58 36cd9210 blueswir1
    // bit numbers
59 36cd9210 blueswir1
    int intctl_g_intr, esp_irq, le_irq, cpu_irq, clock_irq, clock1_irq;
60 36cd9210 blueswir1
    int ser_irq, ms_kb_irq, fd_irq, me_irq, cs_irq;
61 36cd9210 blueswir1
    int machine_id; // For NVRAM
62 e0353fe2 blueswir1
    uint32_t intbit_to_level[32];
63 36cd9210 blueswir1
};
64 36cd9210 blueswir1
65 420557e8 bellard
/* TSC handling */
66 420557e8 bellard
67 420557e8 bellard
uint64_t cpu_get_tsc()
68 420557e8 bellard
{
69 420557e8 bellard
    return qemu_get_clock(vm_clock);
70 420557e8 bellard
}
71 420557e8 bellard
72 6f7e9aec bellard
int DMA_get_channel_mode (int nchan)
73 6f7e9aec bellard
{
74 6f7e9aec bellard
    return 0;
75 6f7e9aec bellard
}
76 6f7e9aec bellard
int DMA_read_memory (int nchan, void *buf, int pos, int size)
77 6f7e9aec bellard
{
78 6f7e9aec bellard
    return 0;
79 6f7e9aec bellard
}
80 6f7e9aec bellard
int DMA_write_memory (int nchan, void *buf, int pos, int size)
81 6f7e9aec bellard
{
82 6f7e9aec bellard
    return 0;
83 6f7e9aec bellard
}
84 6f7e9aec bellard
void DMA_hold_DREQ (int nchan) {}
85 6f7e9aec bellard
void DMA_release_DREQ (int nchan) {}
86 6f7e9aec bellard
void DMA_schedule(int nchan) {}
87 6f7e9aec bellard
void DMA_run (void) {}
88 6f7e9aec bellard
void DMA_init (int high_page_enable) {}
89 6f7e9aec bellard
void DMA_register_channel (int nchan,
90 6f7e9aec bellard
                           DMA_transfer_handler transfer_handler,
91 6f7e9aec bellard
                           void *opaque)
92 6f7e9aec bellard
{
93 6f7e9aec bellard
}
94 6f7e9aec bellard
95 819385c5 bellard
static void nvram_set_word (m48t59_t *nvram, uint32_t addr, uint16_t value)
96 6f7e9aec bellard
{
97 819385c5 bellard
    m48t59_write(nvram, addr++, (value >> 8) & 0xff);
98 819385c5 bellard
    m48t59_write(nvram, addr++, value & 0xff);
99 6f7e9aec bellard
}
100 6f7e9aec bellard
101 819385c5 bellard
static void nvram_set_lword (m48t59_t *nvram, uint32_t addr, uint32_t value)
102 6f7e9aec bellard
{
103 819385c5 bellard
    m48t59_write(nvram, addr++, value >> 24);
104 819385c5 bellard
    m48t59_write(nvram, addr++, (value >> 16) & 0xff);
105 819385c5 bellard
    m48t59_write(nvram, addr++, (value >> 8) & 0xff);
106 819385c5 bellard
    m48t59_write(nvram, addr++, value & 0xff);
107 6f7e9aec bellard
}
108 6f7e9aec bellard
109 819385c5 bellard
static void nvram_set_string (m48t59_t *nvram, uint32_t addr,
110 6f7e9aec bellard
                       const unsigned char *str, uint32_t max)
111 6f7e9aec bellard
{
112 6f7e9aec bellard
    unsigned int i;
113 6f7e9aec bellard
114 6f7e9aec bellard
    for (i = 0; i < max && str[i] != '\0'; i++) {
115 819385c5 bellard
        m48t59_write(nvram, addr + i, str[i]);
116 6f7e9aec bellard
    }
117 819385c5 bellard
    m48t59_write(nvram, addr + max - 1, '\0');
118 6f7e9aec bellard
}
119 420557e8 bellard
120 819385c5 bellard
static m48t59_t *nvram;
121 420557e8 bellard
122 6f7e9aec bellard
extern int nographic;
123 6f7e9aec bellard
124 819385c5 bellard
static void nvram_init(m48t59_t *nvram, uint8_t *macaddr, const char *cmdline,
125 6f7e9aec bellard
                       int boot_device, uint32_t RAM_size,
126 6f7e9aec bellard
                       uint32_t kernel_size,
127 36cd9210 blueswir1
                       int width, int height, int depth,
128 36cd9210 blueswir1
                       int machine_id)
129 e80cfcfc bellard
{
130 e80cfcfc bellard
    unsigned char tmp = 0;
131 e80cfcfc bellard
    int i, j;
132 e80cfcfc bellard
133 6f7e9aec bellard
    // Try to match PPC NVRAM
134 6f7e9aec bellard
    nvram_set_string(nvram, 0x00, "QEMU_BIOS", 16);
135 6f7e9aec bellard
    nvram_set_lword(nvram,  0x10, 0x00000001); /* structure v1 */
136 6f7e9aec bellard
    // NVRAM_size, arch not applicable
137 ba3c64fb bellard
    m48t59_write(nvram, 0x2D, smp_cpus & 0xff);
138 ba3c64fb bellard
    m48t59_write(nvram, 0x2E, 0);
139 819385c5 bellard
    m48t59_write(nvram, 0x2F, nographic & 0xff);
140 6f7e9aec bellard
    nvram_set_lword(nvram,  0x30, RAM_size);
141 819385c5 bellard
    m48t59_write(nvram, 0x34, boot_device & 0xff);
142 6f7e9aec bellard
    nvram_set_lword(nvram,  0x38, KERNEL_LOAD_ADDR);
143 6f7e9aec bellard
    nvram_set_lword(nvram,  0x3C, kernel_size);
144 b6f479d3 bellard
    if (cmdline) {
145 b6f479d3 bellard
        strcpy(phys_ram_base + CMDLINE_ADDR, cmdline);
146 6f7e9aec bellard
        nvram_set_lword(nvram,  0x40, CMDLINE_ADDR);
147 6f7e9aec bellard
        nvram_set_lword(nvram,  0x44, strlen(cmdline));
148 b6f479d3 bellard
    }
149 6f7e9aec bellard
    // initrd_image, initrd_size passed differently
150 6f7e9aec bellard
    nvram_set_word(nvram,   0x54, width);
151 6f7e9aec bellard
    nvram_set_word(nvram,   0x56, height);
152 6f7e9aec bellard
    nvram_set_word(nvram,   0x58, depth);
153 b6f479d3 bellard
154 6f7e9aec bellard
    // Sun4m specific use
155 e80cfcfc bellard
    i = 0x1fd8;
156 819385c5 bellard
    m48t59_write(nvram, i++, 0x01);
157 36cd9210 blueswir1
    m48t59_write(nvram, i++, machine_id);
158 e80cfcfc bellard
    j = 0;
159 819385c5 bellard
    m48t59_write(nvram, i++, macaddr[j++]);
160 819385c5 bellard
    m48t59_write(nvram, i++, macaddr[j++]);
161 819385c5 bellard
    m48t59_write(nvram, i++, macaddr[j++]);
162 819385c5 bellard
    m48t59_write(nvram, i++, macaddr[j++]);
163 819385c5 bellard
    m48t59_write(nvram, i++, macaddr[j++]);
164 819385c5 bellard
    m48t59_write(nvram, i, macaddr[j]);
165 e80cfcfc bellard
166 e80cfcfc bellard
    /* Calculate checksum */
167 e80cfcfc bellard
    for (i = 0x1fd8; i < 0x1fe7; i++) {
168 819385c5 bellard
        tmp ^= m48t59_read(nvram, i);
169 e80cfcfc bellard
    }
170 819385c5 bellard
    m48t59_write(nvram, 0x1fe7, tmp);
171 e80cfcfc bellard
}
172 e80cfcfc bellard
173 e80cfcfc bellard
static void *slavio_intctl;
174 e80cfcfc bellard
175 e80cfcfc bellard
void pic_info()
176 e80cfcfc bellard
{
177 e80cfcfc bellard
    slavio_pic_info(slavio_intctl);
178 e80cfcfc bellard
}
179 e80cfcfc bellard
180 e80cfcfc bellard
void irq_info()
181 e80cfcfc bellard
{
182 e80cfcfc bellard
    slavio_irq_info(slavio_intctl);
183 e80cfcfc bellard
}
184 e80cfcfc bellard
185 3475187d bellard
static void *slavio_misc;
186 3475187d bellard
187 3475187d bellard
void qemu_system_powerdown(void)
188 3475187d bellard
{
189 3475187d bellard
    slavio_set_power_fail(slavio_misc, 1);
190 3475187d bellard
}
191 3475187d bellard
192 c68ea704 bellard
static void main_cpu_reset(void *opaque)
193 c68ea704 bellard
{
194 c68ea704 bellard
    CPUState *env = opaque;
195 c68ea704 bellard
    cpu_reset(env);
196 c68ea704 bellard
}
197 c68ea704 bellard
198 36cd9210 blueswir1
static void sun4m_hw_init(const struct hwdef *hwdef, int ram_size,
199 36cd9210 blueswir1
                          DisplayState *ds, const char *cpu_model)
200 36cd9210 blueswir1
201 420557e8 bellard
{
202 ba3c64fb bellard
    CPUState *env, *envs[MAX_CPUS];
203 713c45fa bellard
    unsigned int i;
204 67e999be bellard
    void *iommu, *dma, *main_esp, *main_lance = NULL;
205 62724a37 blueswir1
    const sparc_def_t *def;
206 d537cf6c pbrook
    qemu_irq *slavio_irq;
207 420557e8 bellard
208 ba3c64fb bellard
    /* init CPUs */
209 62724a37 blueswir1
    sparc_find_by_name(cpu_model, &def);
210 62724a37 blueswir1
    if (def == NULL) {
211 62724a37 blueswir1
        fprintf(stderr, "Unable to find Sparc CPU definition\n");
212 62724a37 blueswir1
        exit(1);
213 62724a37 blueswir1
    }
214 ba3c64fb bellard
    for(i = 0; i < smp_cpus; i++) {
215 ba3c64fb bellard
        env = cpu_init();
216 62724a37 blueswir1
        cpu_sparc_register(env, def);
217 ba3c64fb bellard
        envs[i] = env;
218 ba3c64fb bellard
        if (i != 0)
219 ba3c64fb bellard
            env->halted = 1;
220 ba3c64fb bellard
        register_savevm("cpu", i, 3, cpu_save, cpu_load, env);
221 ba3c64fb bellard
        qemu_register_reset(main_cpu_reset, env);
222 ba3c64fb bellard
    }
223 420557e8 bellard
    /* allocate RAM */
224 420557e8 bellard
    cpu_register_physical_memory(0, ram_size, 0);
225 420557e8 bellard
226 36cd9210 blueswir1
    iommu = iommu_init(hwdef->iommu_base);
227 36cd9210 blueswir1
    slavio_intctl = slavio_intctl_init(hwdef->intctl_base,
228 e0353fe2 blueswir1
                                       hwdef->intctl_base + 0x10000,
229 d537cf6c pbrook
                                       &hwdef->intbit_to_level[0],
230 d537cf6c pbrook
                                       &slavio_irq);
231 ba3c64fb bellard
    for(i = 0; i < smp_cpus; i++) {
232 ba3c64fb bellard
        slavio_intctl_set_cpu(slavio_intctl, i, envs[i]);
233 ba3c64fb bellard
    }
234 d537cf6c pbrook
    dma = sparc32_dma_init(hwdef->dma_base, slavio_irq[hwdef->esp_irq],
235 d537cf6c pbrook
                           slavio_irq[hwdef->le_irq], iommu);
236 ba3c64fb bellard
237 36cd9210 blueswir1
    tcx_init(ds, hwdef->tcx_base, phys_ram_base + ram_size, ram_size,
238 36cd9210 blueswir1
             hwdef->vram_size, graphic_width, graphic_height);
239 a41b2ff2 pbrook
    if (nd_table[0].vlan) {
240 a41b2ff2 pbrook
        if (nd_table[0].model == NULL
241 a41b2ff2 pbrook
            || strcmp(nd_table[0].model, "lance") == 0) {
242 d537cf6c pbrook
            main_lance = lance_init(&nd_table[0], hwdef->le_base, dma,
243 d537cf6c pbrook
                                    slavio_irq[hwdef->le_irq]);
244 a41b2ff2 pbrook
        } else {
245 a41b2ff2 pbrook
            fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
246 a41b2ff2 pbrook
            exit (1);
247 a41b2ff2 pbrook
        }
248 a41b2ff2 pbrook
    }
249 d537cf6c pbrook
    nvram = m48t59_init(slavio_irq[0], hwdef->nvram_base, 0,
250 d537cf6c pbrook
                        hwdef->nvram_size, 8);
251 ba3c64fb bellard
    for (i = 0; i < MAX_CPUS; i++) {
252 36cd9210 blueswir1
        slavio_timer_init(hwdef->counter_base + i * TARGET_PAGE_SIZE,
253 52cc07d0 blueswir1
                          hwdef->clock_irq, 0, i, slavio_intctl);
254 ba3c64fb bellard
    }
255 36cd9210 blueswir1
    slavio_timer_init(hwdef->counter_base + 0x10000, hwdef->clock1_irq, 2,
256 52cc07d0 blueswir1
                      (unsigned int)-1, slavio_intctl);
257 d537cf6c pbrook
    slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[hwdef->ms_kb_irq]);
258 b81b3b10 bellard
    // Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
259 b81b3b10 bellard
    // Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
260 d537cf6c pbrook
    slavio_serial_init(hwdef->serial_base, slavio_irq[hwdef->ser_irq],
261 d537cf6c pbrook
                       serial_hds[1], serial_hds[0]);
262 d537cf6c pbrook
    fdctrl_init(slavio_irq[hwdef->fd_irq], 0, 1, hwdef->fd_base, fd_table);
263 36cd9210 blueswir1
    main_esp = esp_init(bs_table, hwdef->esp_base, dma);
264 f1587550 ths
265 f1587550 ths
    for (i = 0; i < MAX_DISKS; i++) {
266 f1587550 ths
        if (bs_table[i]) {
267 f1587550 ths
            esp_scsi_attach(main_esp, bs_table[i], i);
268 f1587550 ths
        }
269 f1587550 ths
    }
270 f1587550 ths
271 d537cf6c pbrook
    slavio_misc = slavio_misc_init(hwdef->slavio_base, 
272 d537cf6c pbrook
                                   slavio_irq[hwdef->me_irq]);
273 803b3c7b blueswir1
    if (hwdef->cs_base != (target_ulong)-1)
274 803b3c7b blueswir1
        cs_init(hwdef->cs_base, hwdef->cs_irq, slavio_intctl);
275 67e999be bellard
    sparc32_dma_set_reset_data(dma, main_esp, main_lance);
276 36cd9210 blueswir1
}
277 36cd9210 blueswir1
278 36cd9210 blueswir1
static void sun4m_load_kernel(long vram_size, int ram_size, int boot_device,
279 36cd9210 blueswir1
                              const char *kernel_filename,
280 36cd9210 blueswir1
                              const char *kernel_cmdline,
281 36cd9210 blueswir1
                              const char *initrd_filename,
282 36cd9210 blueswir1
                              int machine_id)
283 36cd9210 blueswir1
{
284 36cd9210 blueswir1
    int ret, linux_boot;
285 36cd9210 blueswir1
    char buf[1024];
286 36cd9210 blueswir1
    unsigned int i;
287 36cd9210 blueswir1
    long prom_offset, initrd_size, kernel_size;
288 36cd9210 blueswir1
289 36cd9210 blueswir1
    linux_boot = (kernel_filename != NULL);
290 420557e8 bellard
291 e80cfcfc bellard
    prom_offset = ram_size + vram_size;
292 b3783731 bellard
    cpu_register_physical_memory(PROM_ADDR, 
293 b3783731 bellard
                                 (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK, 
294 b3783731 bellard
                                 prom_offset | IO_MEM_ROM);
295 e80cfcfc bellard
296 0986ac3b bellard
    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, PROM_FILENAME);
297 74287114 ths
    ret = load_elf(buf, 0, NULL, NULL, NULL);
298 e80cfcfc bellard
    if (ret < 0) {
299 e80cfcfc bellard
        fprintf(stderr, "qemu: could not load prom '%s'\n", 
300 e80cfcfc bellard
                buf);
301 e80cfcfc bellard
        exit(1);
302 e80cfcfc bellard
    }
303 e80cfcfc bellard
304 6f7e9aec bellard
    kernel_size = 0;
305 e80cfcfc bellard
    if (linux_boot) {
306 74287114 ths
        kernel_size = load_elf(kernel_filename, -0xf0000000, NULL, NULL, NULL);
307 6f7e9aec bellard
        if (kernel_size < 0)
308 6f7e9aec bellard
            kernel_size = load_aout(kernel_filename, phys_ram_base + KERNEL_LOAD_ADDR);
309 6f7e9aec bellard
        if (kernel_size < 0)
310 6f7e9aec bellard
            kernel_size = load_image(kernel_filename, phys_ram_base + KERNEL_LOAD_ADDR);
311 6f7e9aec bellard
        if (kernel_size < 0) {
312 420557e8 bellard
            fprintf(stderr, "qemu: could not load kernel '%s'\n", 
313 e80cfcfc bellard
                    kernel_filename);
314 e80cfcfc bellard
            exit(1);
315 420557e8 bellard
        }
316 713c45fa bellard
317 713c45fa bellard
        /* load initrd */
318 713c45fa bellard
        initrd_size = 0;
319 713c45fa bellard
        if (initrd_filename) {
320 713c45fa bellard
            initrd_size = load_image(initrd_filename, phys_ram_base + INITRD_LOAD_ADDR);
321 713c45fa bellard
            if (initrd_size < 0) {
322 713c45fa bellard
                fprintf(stderr, "qemu: could not load initial ram disk '%s'\n", 
323 713c45fa bellard
                        initrd_filename);
324 713c45fa bellard
                exit(1);
325 713c45fa bellard
            }
326 713c45fa bellard
        }
327 713c45fa bellard
        if (initrd_size > 0) {
328 713c45fa bellard
            for (i = 0; i < 64 * TARGET_PAGE_SIZE; i += TARGET_PAGE_SIZE) {
329 713c45fa bellard
                if (ldl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i)
330 713c45fa bellard
                    == 0x48647253) { // HdrS
331 713c45fa bellard
                    stl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i + 16, INITRD_LOAD_ADDR);
332 713c45fa bellard
                    stl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i + 20, initrd_size);
333 713c45fa bellard
                    break;
334 713c45fa bellard
                }
335 713c45fa bellard
            }
336 713c45fa bellard
        }
337 420557e8 bellard
    }
338 36cd9210 blueswir1
    nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
339 36cd9210 blueswir1
               boot_device, ram_size, kernel_size, graphic_width,
340 36cd9210 blueswir1
               graphic_height, graphic_depth, machine_id);
341 36cd9210 blueswir1
}
342 36cd9210 blueswir1
343 36cd9210 blueswir1
static const struct hwdef hwdefs[] = {
344 36cd9210 blueswir1
    /* SS-5 */
345 36cd9210 blueswir1
    {
346 36cd9210 blueswir1
        .iommu_base   = 0x10000000,
347 36cd9210 blueswir1
        .tcx_base     = 0x50000000,
348 36cd9210 blueswir1
        .cs_base      = 0x6c000000,
349 36cd9210 blueswir1
        .slavio_base  = 0x71000000,
350 36cd9210 blueswir1
        .ms_kb_base   = 0x71000000,
351 36cd9210 blueswir1
        .serial_base  = 0x71100000,
352 36cd9210 blueswir1
        .nvram_base   = 0x71200000,
353 36cd9210 blueswir1
        .fd_base      = 0x71400000,
354 36cd9210 blueswir1
        .counter_base = 0x71d00000,
355 36cd9210 blueswir1
        .intctl_base  = 0x71e00000,
356 36cd9210 blueswir1
        .dma_base     = 0x78400000,
357 36cd9210 blueswir1
        .esp_base     = 0x78800000,
358 36cd9210 blueswir1
        .le_base      = 0x78c00000,
359 36cd9210 blueswir1
        .vram_size    = 0x00100000,
360 36cd9210 blueswir1
        .nvram_size   = 0x2000,
361 36cd9210 blueswir1
        .esp_irq = 18,
362 36cd9210 blueswir1
        .le_irq = 16,
363 36cd9210 blueswir1
        .clock_irq = 7,
364 36cd9210 blueswir1
        .clock1_irq = 19,
365 36cd9210 blueswir1
        .ms_kb_irq = 14,
366 36cd9210 blueswir1
        .ser_irq = 15,
367 36cd9210 blueswir1
        .fd_irq = 22,
368 36cd9210 blueswir1
        .me_irq = 30,
369 36cd9210 blueswir1
        .cs_irq = 5,
370 36cd9210 blueswir1
        .machine_id = 0x80,
371 e0353fe2 blueswir1
        .intbit_to_level = {
372 e0353fe2 blueswir1
            2, 3, 5, 7, 9, 11, 0, 14,        3, 5, 7, 9, 11, 13, 12, 12,
373 e0353fe2 blueswir1
            6, 0, 4, 10, 8, 0, 11, 0,        0, 0, 0, 0, 15, 0, 15, 0,
374 e0353fe2 blueswir1
        },
375 e0353fe2 blueswir1
    },
376 e0353fe2 blueswir1
    /* SS-10 */
377 e0353fe2 blueswir1
    {
378 803b3c7b blueswir1
        .iommu_base   = 0xe0000000, // XXX Actually at 0xfe0000000ULL (36 bits)
379 1c6e9070 blueswir1
        .tcx_base     = 0x20000000, // 0xe20000000ULL,
380 803b3c7b blueswir1
        .cs_base      = -1,
381 803b3c7b blueswir1
        .slavio_base  = 0xf1000000, // 0xff1000000ULL,
382 803b3c7b blueswir1
        .ms_kb_base   = 0xf1000000, // 0xff1000000ULL,
383 803b3c7b blueswir1
        .serial_base  = 0xf1100000, // 0xff1100000ULL,
384 803b3c7b blueswir1
        .nvram_base   = 0xf1200000, // 0xff1200000ULL,
385 803b3c7b blueswir1
        .fd_base      = 0xf1700000, // 0xff1700000ULL,
386 803b3c7b blueswir1
        .counter_base = 0xf1300000, // 0xff1300000ULL,
387 803b3c7b blueswir1
        .intctl_base  = 0xf1400000, // 0xff1400000ULL,
388 803b3c7b blueswir1
        .dma_base     = 0xf0400000, // 0xef0400000ULL,
389 803b3c7b blueswir1
        .esp_base     = 0xf0800000, // 0xef0800000ULL,
390 803b3c7b blueswir1
        .le_base      = 0xf0c00000, // 0xef0c00000ULL,
391 e0353fe2 blueswir1
        .vram_size    = 0x00100000,
392 e0353fe2 blueswir1
        .nvram_size   = 0x2000,
393 e0353fe2 blueswir1
        .esp_irq = 18,
394 e0353fe2 blueswir1
        .le_irq = 16,
395 e0353fe2 blueswir1
        .clock_irq = 7,
396 e0353fe2 blueswir1
        .clock1_irq = 19,
397 e0353fe2 blueswir1
        .ms_kb_irq = 14,
398 e0353fe2 blueswir1
        .ser_irq = 15,
399 e0353fe2 blueswir1
        .fd_irq = 22,
400 e0353fe2 blueswir1
        .me_irq = 30,
401 803b3c7b blueswir1
        .cs_irq = -1,
402 803b3c7b blueswir1
        .machine_id = 0x72,
403 e0353fe2 blueswir1
        .intbit_to_level = {
404 e0353fe2 blueswir1
            2, 3, 5, 7, 9, 11, 0, 14,        3, 5, 7, 9, 11, 13, 12, 12,
405 e0353fe2 blueswir1
            6, 0, 4, 10, 8, 0, 11, 0,        0, 0, 0, 0, 15, 0, 15, 0,
406 e0353fe2 blueswir1
        },
407 36cd9210 blueswir1
    },
408 36cd9210 blueswir1
};
409 36cd9210 blueswir1
410 36cd9210 blueswir1
static void sun4m_common_init(int ram_size, int boot_device, DisplayState *ds,
411 36cd9210 blueswir1
                              const char *kernel_filename, const char *kernel_cmdline,
412 36cd9210 blueswir1
                              const char *initrd_filename, const char *cpu_model,
413 36cd9210 blueswir1
                              unsigned int machine)
414 36cd9210 blueswir1
{
415 36cd9210 blueswir1
    sun4m_hw_init(&hwdefs[machine], ram_size, ds, cpu_model);
416 36cd9210 blueswir1
417 36cd9210 blueswir1
    sun4m_load_kernel(hwdefs[machine].vram_size, ram_size, boot_device,
418 36cd9210 blueswir1
                      kernel_filename, kernel_cmdline, initrd_filename,
419 36cd9210 blueswir1
                      hwdefs[machine].machine_id);
420 36cd9210 blueswir1
}
421 36cd9210 blueswir1
422 36cd9210 blueswir1
/* SPARCstation 5 hardware initialisation */
423 36cd9210 blueswir1
static void ss5_init(int ram_size, int vga_ram_size, int boot_device,
424 36cd9210 blueswir1
                       DisplayState *ds, const char **fd_filename, int snapshot,
425 36cd9210 blueswir1
                       const char *kernel_filename, const char *kernel_cmdline,
426 36cd9210 blueswir1
                       const char *initrd_filename, const char *cpu_model)
427 36cd9210 blueswir1
{
428 36cd9210 blueswir1
    if (cpu_model == NULL)
429 36cd9210 blueswir1
        cpu_model = "Fujitsu MB86904";
430 36cd9210 blueswir1
    sun4m_common_init(ram_size, boot_device, ds, kernel_filename,
431 36cd9210 blueswir1
                      kernel_cmdline, initrd_filename, cpu_model,
432 36cd9210 blueswir1
                      0);
433 420557e8 bellard
}
434 c0e564d5 bellard
435 e0353fe2 blueswir1
/* SPARCstation 10 hardware initialisation */
436 e0353fe2 blueswir1
static void ss10_init(int ram_size, int vga_ram_size, int boot_device,
437 e0353fe2 blueswir1
                            DisplayState *ds, const char **fd_filename, int snapshot,
438 e0353fe2 blueswir1
                            const char *kernel_filename, const char *kernel_cmdline,
439 e0353fe2 blueswir1
                            const char *initrd_filename, const char *cpu_model)
440 e0353fe2 blueswir1
{
441 e0353fe2 blueswir1
    if (cpu_model == NULL)
442 e0353fe2 blueswir1
        cpu_model = "TI SuperSparc II";
443 e0353fe2 blueswir1
    sun4m_common_init(ram_size, boot_device, ds, kernel_filename,
444 e0353fe2 blueswir1
                      kernel_cmdline, initrd_filename, cpu_model,
445 e0353fe2 blueswir1
                      1);
446 e0353fe2 blueswir1
}
447 e0353fe2 blueswir1
448 36cd9210 blueswir1
QEMUMachine ss5_machine = {
449 36cd9210 blueswir1
    "SS-5",
450 36cd9210 blueswir1
    "Sun4m platform, SPARCstation 5",
451 36cd9210 blueswir1
    ss5_init,
452 c0e564d5 bellard
};
453 e0353fe2 blueswir1
454 e0353fe2 blueswir1
QEMUMachine ss10_machine = {
455 e0353fe2 blueswir1
    "SS-10",
456 e0353fe2 blueswir1
    "Sun4m platform, SPARCstation 10",
457 e0353fe2 blueswir1
    ss10_init,
458 e0353fe2 blueswir1
};