Statistics
| Branch: | Revision:

root / hw / sun4m.c @ beb811bd

History | View | Annotate | Download (15.2 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 e80cfcfc bellard
void pic_set_irq(int irq, int level)
186 e80cfcfc bellard
{
187 52cc07d0 blueswir1
    pic_set_irq_new(slavio_intctl, irq, level);
188 ba3c64fb bellard
}
189 ba3c64fb bellard
190 3475187d bellard
static void *slavio_misc;
191 3475187d bellard
192 3475187d bellard
void qemu_system_powerdown(void)
193 3475187d bellard
{
194 3475187d bellard
    slavio_set_power_fail(slavio_misc, 1);
195 3475187d bellard
}
196 3475187d bellard
197 c68ea704 bellard
static void main_cpu_reset(void *opaque)
198 c68ea704 bellard
{
199 c68ea704 bellard
    CPUState *env = opaque;
200 c68ea704 bellard
    cpu_reset(env);
201 c68ea704 bellard
}
202 c68ea704 bellard
203 36cd9210 blueswir1
static void sun4m_hw_init(const struct hwdef *hwdef, int ram_size,
204 36cd9210 blueswir1
                          DisplayState *ds, const char *cpu_model)
205 36cd9210 blueswir1
206 420557e8 bellard
{
207 ba3c64fb bellard
    CPUState *env, *envs[MAX_CPUS];
208 713c45fa bellard
    unsigned int i;
209 67e999be bellard
    void *iommu, *dma, *main_esp, *main_lance = NULL;
210 62724a37 blueswir1
    const sparc_def_t *def;
211 420557e8 bellard
212 ba3c64fb bellard
    /* init CPUs */
213 62724a37 blueswir1
    sparc_find_by_name(cpu_model, &def);
214 62724a37 blueswir1
    if (def == NULL) {
215 62724a37 blueswir1
        fprintf(stderr, "Unable to find Sparc CPU definition\n");
216 62724a37 blueswir1
        exit(1);
217 62724a37 blueswir1
    }
218 ba3c64fb bellard
    for(i = 0; i < smp_cpus; i++) {
219 ba3c64fb bellard
        env = cpu_init();
220 62724a37 blueswir1
        cpu_sparc_register(env, def);
221 ba3c64fb bellard
        envs[i] = env;
222 ba3c64fb bellard
        if (i != 0)
223 ba3c64fb bellard
            env->halted = 1;
224 ba3c64fb bellard
        register_savevm("cpu", i, 3, cpu_save, cpu_load, env);
225 ba3c64fb bellard
        qemu_register_reset(main_cpu_reset, env);
226 ba3c64fb bellard
    }
227 420557e8 bellard
    /* allocate RAM */
228 420557e8 bellard
    cpu_register_physical_memory(0, ram_size, 0);
229 420557e8 bellard
230 36cd9210 blueswir1
    iommu = iommu_init(hwdef->iommu_base);
231 36cd9210 blueswir1
    slavio_intctl = slavio_intctl_init(hwdef->intctl_base,
232 e0353fe2 blueswir1
                                       hwdef->intctl_base + 0x10000,
233 e0353fe2 blueswir1
                                       &hwdef->intbit_to_level[0]);
234 ba3c64fb bellard
    for(i = 0; i < smp_cpus; i++) {
235 ba3c64fb bellard
        slavio_intctl_set_cpu(slavio_intctl, i, envs[i]);
236 ba3c64fb bellard
    }
237 36cd9210 blueswir1
    dma = sparc32_dma_init(hwdef->dma_base, hwdef->esp_irq,
238 36cd9210 blueswir1
                           hwdef->le_irq, iommu, slavio_intctl);
239 ba3c64fb bellard
240 36cd9210 blueswir1
    tcx_init(ds, hwdef->tcx_base, phys_ram_base + ram_size, ram_size,
241 36cd9210 blueswir1
             hwdef->vram_size, graphic_width, graphic_height);
242 a41b2ff2 pbrook
    if (nd_table[0].vlan) {
243 a41b2ff2 pbrook
        if (nd_table[0].model == NULL
244 a41b2ff2 pbrook
            || strcmp(nd_table[0].model, "lance") == 0) {
245 36cd9210 blueswir1
            main_lance = lance_init(&nd_table[0], hwdef->le_base, dma);
246 a41b2ff2 pbrook
        } else {
247 a41b2ff2 pbrook
            fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
248 a41b2ff2 pbrook
            exit (1);
249 a41b2ff2 pbrook
        }
250 a41b2ff2 pbrook
    }
251 36cd9210 blueswir1
    nvram = m48t59_init(0, hwdef->nvram_base, 0, hwdef->nvram_size, 8);
252 ba3c64fb bellard
    for (i = 0; i < MAX_CPUS; i++) {
253 36cd9210 blueswir1
        slavio_timer_init(hwdef->counter_base + i * TARGET_PAGE_SIZE,
254 52cc07d0 blueswir1
                          hwdef->clock_irq, 0, i, slavio_intctl);
255 ba3c64fb bellard
    }
256 36cd9210 blueswir1
    slavio_timer_init(hwdef->counter_base + 0x10000, hwdef->clock1_irq, 2,
257 52cc07d0 blueswir1
                      (unsigned int)-1, slavio_intctl);
258 52cc07d0 blueswir1
    slavio_serial_ms_kbd_init(hwdef->ms_kb_base, hwdef->ms_kb_irq,
259 52cc07d0 blueswir1
                              slavio_intctl);
260 b81b3b10 bellard
    // Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
261 b81b3b10 bellard
    // Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
262 36cd9210 blueswir1
    slavio_serial_init(hwdef->serial_base, hwdef->ser_irq,
263 52cc07d0 blueswir1
                       serial_hds[1], serial_hds[0], slavio_intctl);
264 36cd9210 blueswir1
    fdctrl_init(hwdef->fd_irq, 0, 1, hwdef->fd_base, fd_table);
265 36cd9210 blueswir1
    main_esp = esp_init(bs_table, hwdef->esp_base, dma);
266 f1587550 ths
267 f1587550 ths
    for (i = 0; i < MAX_DISKS; i++) {
268 f1587550 ths
        if (bs_table[i]) {
269 f1587550 ths
            esp_scsi_attach(main_esp, bs_table[i], i);
270 f1587550 ths
        }
271 f1587550 ths
    }
272 f1587550 ths
273 52cc07d0 blueswir1
    slavio_misc = slavio_misc_init(hwdef->slavio_base, hwdef->me_irq,
274 52cc07d0 blueswir1
                                   slavio_intctl);
275 803b3c7b blueswir1
    if (hwdef->cs_base != (target_ulong)-1)
276 803b3c7b blueswir1
        cs_init(hwdef->cs_base, hwdef->cs_irq, slavio_intctl);
277 67e999be bellard
    sparc32_dma_set_reset_data(dma, main_esp, main_lance);
278 36cd9210 blueswir1
}
279 36cd9210 blueswir1
280 36cd9210 blueswir1
static void sun4m_load_kernel(long vram_size, int ram_size, int boot_device,
281 36cd9210 blueswir1
                              const char *kernel_filename,
282 36cd9210 blueswir1
                              const char *kernel_cmdline,
283 36cd9210 blueswir1
                              const char *initrd_filename,
284 36cd9210 blueswir1
                              int machine_id)
285 36cd9210 blueswir1
{
286 36cd9210 blueswir1
    int ret, linux_boot;
287 36cd9210 blueswir1
    char buf[1024];
288 36cd9210 blueswir1
    unsigned int i;
289 36cd9210 blueswir1
    long prom_offset, initrd_size, kernel_size;
290 36cd9210 blueswir1
291 36cd9210 blueswir1
    linux_boot = (kernel_filename != NULL);
292 420557e8 bellard
293 e80cfcfc bellard
    prom_offset = ram_size + vram_size;
294 b3783731 bellard
    cpu_register_physical_memory(PROM_ADDR, 
295 b3783731 bellard
                                 (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK, 
296 b3783731 bellard
                                 prom_offset | IO_MEM_ROM);
297 e80cfcfc bellard
298 0986ac3b bellard
    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, PROM_FILENAME);
299 74287114 ths
    ret = load_elf(buf, 0, NULL, NULL, NULL);
300 e80cfcfc bellard
    if (ret < 0) {
301 e80cfcfc bellard
        fprintf(stderr, "qemu: could not load prom '%s'\n", 
302 e80cfcfc bellard
                buf);
303 e80cfcfc bellard
        exit(1);
304 e80cfcfc bellard
    }
305 e80cfcfc bellard
306 6f7e9aec bellard
    kernel_size = 0;
307 e80cfcfc bellard
    if (linux_boot) {
308 74287114 ths
        kernel_size = load_elf(kernel_filename, -0xf0000000, NULL, NULL, NULL);
309 6f7e9aec bellard
        if (kernel_size < 0)
310 6f7e9aec bellard
            kernel_size = load_aout(kernel_filename, phys_ram_base + KERNEL_LOAD_ADDR);
311 6f7e9aec bellard
        if (kernel_size < 0)
312 6f7e9aec bellard
            kernel_size = load_image(kernel_filename, phys_ram_base + KERNEL_LOAD_ADDR);
313 6f7e9aec bellard
        if (kernel_size < 0) {
314 420557e8 bellard
            fprintf(stderr, "qemu: could not load kernel '%s'\n", 
315 e80cfcfc bellard
                    kernel_filename);
316 e80cfcfc bellard
            exit(1);
317 420557e8 bellard
        }
318 713c45fa bellard
319 713c45fa bellard
        /* load initrd */
320 713c45fa bellard
        initrd_size = 0;
321 713c45fa bellard
        if (initrd_filename) {
322 713c45fa bellard
            initrd_size = load_image(initrd_filename, phys_ram_base + INITRD_LOAD_ADDR);
323 713c45fa bellard
            if (initrd_size < 0) {
324 713c45fa bellard
                fprintf(stderr, "qemu: could not load initial ram disk '%s'\n", 
325 713c45fa bellard
                        initrd_filename);
326 713c45fa bellard
                exit(1);
327 713c45fa bellard
            }
328 713c45fa bellard
        }
329 713c45fa bellard
        if (initrd_size > 0) {
330 713c45fa bellard
            for (i = 0; i < 64 * TARGET_PAGE_SIZE; i += TARGET_PAGE_SIZE) {
331 713c45fa bellard
                if (ldl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i)
332 713c45fa bellard
                    == 0x48647253) { // HdrS
333 713c45fa bellard
                    stl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i + 16, INITRD_LOAD_ADDR);
334 713c45fa bellard
                    stl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i + 20, initrd_size);
335 713c45fa bellard
                    break;
336 713c45fa bellard
                }
337 713c45fa bellard
            }
338 713c45fa bellard
        }
339 420557e8 bellard
    }
340 36cd9210 blueswir1
    nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
341 36cd9210 blueswir1
               boot_device, ram_size, kernel_size, graphic_width,
342 36cd9210 blueswir1
               graphic_height, graphic_depth, machine_id);
343 36cd9210 blueswir1
}
344 36cd9210 blueswir1
345 36cd9210 blueswir1
static const struct hwdef hwdefs[] = {
346 36cd9210 blueswir1
    /* SS-5 */
347 36cd9210 blueswir1
    {
348 36cd9210 blueswir1
        .iommu_base   = 0x10000000,
349 36cd9210 blueswir1
        .tcx_base     = 0x50000000,
350 36cd9210 blueswir1
        .cs_base      = 0x6c000000,
351 36cd9210 blueswir1
        .slavio_base  = 0x71000000,
352 36cd9210 blueswir1
        .ms_kb_base   = 0x71000000,
353 36cd9210 blueswir1
        .serial_base  = 0x71100000,
354 36cd9210 blueswir1
        .nvram_base   = 0x71200000,
355 36cd9210 blueswir1
        .fd_base      = 0x71400000,
356 36cd9210 blueswir1
        .counter_base = 0x71d00000,
357 36cd9210 blueswir1
        .intctl_base  = 0x71e00000,
358 36cd9210 blueswir1
        .dma_base     = 0x78400000,
359 36cd9210 blueswir1
        .esp_base     = 0x78800000,
360 36cd9210 blueswir1
        .le_base      = 0x78c00000,
361 36cd9210 blueswir1
        .vram_size    = 0x00100000,
362 36cd9210 blueswir1
        .nvram_size   = 0x2000,
363 36cd9210 blueswir1
        .esp_irq = 18,
364 36cd9210 blueswir1
        .le_irq = 16,
365 36cd9210 blueswir1
        .clock_irq = 7,
366 36cd9210 blueswir1
        .clock1_irq = 19,
367 36cd9210 blueswir1
        .ms_kb_irq = 14,
368 36cd9210 blueswir1
        .ser_irq = 15,
369 36cd9210 blueswir1
        .fd_irq = 22,
370 36cd9210 blueswir1
        .me_irq = 30,
371 36cd9210 blueswir1
        .cs_irq = 5,
372 36cd9210 blueswir1
        .machine_id = 0x80,
373 e0353fe2 blueswir1
        .intbit_to_level = {
374 e0353fe2 blueswir1
            2, 3, 5, 7, 9, 11, 0, 14,        3, 5, 7, 9, 11, 13, 12, 12,
375 e0353fe2 blueswir1
            6, 0, 4, 10, 8, 0, 11, 0,        0, 0, 0, 0, 15, 0, 15, 0,
376 e0353fe2 blueswir1
        },
377 e0353fe2 blueswir1
    },
378 e0353fe2 blueswir1
    /* SS-10 */
379 e0353fe2 blueswir1
    {
380 803b3c7b blueswir1
        .iommu_base   = 0xe0000000, // XXX Actually at 0xfe0000000ULL (36 bits)
381 803b3c7b blueswir1
        .tcx_base     = 0x21000000, // 0xe21000000ULL,
382 803b3c7b blueswir1
        .cs_base      = -1,
383 803b3c7b blueswir1
        .slavio_base  = 0xf1000000, // 0xff1000000ULL,
384 803b3c7b blueswir1
        .ms_kb_base   = 0xf1000000, // 0xff1000000ULL,
385 803b3c7b blueswir1
        .serial_base  = 0xf1100000, // 0xff1100000ULL,
386 803b3c7b blueswir1
        .nvram_base   = 0xf1200000, // 0xff1200000ULL,
387 803b3c7b blueswir1
        .fd_base      = 0xf1700000, // 0xff1700000ULL,
388 803b3c7b blueswir1
        .counter_base = 0xf1300000, // 0xff1300000ULL,
389 803b3c7b blueswir1
        .intctl_base  = 0xf1400000, // 0xff1400000ULL,
390 803b3c7b blueswir1
        .dma_base     = 0xf0400000, // 0xef0400000ULL,
391 803b3c7b blueswir1
        .esp_base     = 0xf0800000, // 0xef0800000ULL,
392 803b3c7b blueswir1
        .le_base      = 0xf0c00000, // 0xef0c00000ULL,
393 e0353fe2 blueswir1
        .vram_size    = 0x00100000,
394 e0353fe2 blueswir1
        .nvram_size   = 0x2000,
395 e0353fe2 blueswir1
        .esp_irq = 18,
396 e0353fe2 blueswir1
        .le_irq = 16,
397 e0353fe2 blueswir1
        .clock_irq = 7,
398 e0353fe2 blueswir1
        .clock1_irq = 19,
399 e0353fe2 blueswir1
        .ms_kb_irq = 14,
400 e0353fe2 blueswir1
        .ser_irq = 15,
401 e0353fe2 blueswir1
        .fd_irq = 22,
402 e0353fe2 blueswir1
        .me_irq = 30,
403 803b3c7b blueswir1
        .cs_irq = -1,
404 803b3c7b blueswir1
        .machine_id = 0x72,
405 e0353fe2 blueswir1
        .intbit_to_level = {
406 e0353fe2 blueswir1
            2, 3, 5, 7, 9, 11, 0, 14,        3, 5, 7, 9, 11, 13, 12, 12,
407 e0353fe2 blueswir1
            6, 0, 4, 10, 8, 0, 11, 0,        0, 0, 0, 0, 15, 0, 15, 0,
408 e0353fe2 blueswir1
        },
409 36cd9210 blueswir1
    },
410 36cd9210 blueswir1
};
411 36cd9210 blueswir1
412 36cd9210 blueswir1
static void sun4m_common_init(int ram_size, int boot_device, DisplayState *ds,
413 36cd9210 blueswir1
                              const char *kernel_filename, const char *kernel_cmdline,
414 36cd9210 blueswir1
                              const char *initrd_filename, const char *cpu_model,
415 36cd9210 blueswir1
                              unsigned int machine)
416 36cd9210 blueswir1
{
417 36cd9210 blueswir1
    sun4m_hw_init(&hwdefs[machine], ram_size, ds, cpu_model);
418 36cd9210 blueswir1
419 36cd9210 blueswir1
    sun4m_load_kernel(hwdefs[machine].vram_size, ram_size, boot_device,
420 36cd9210 blueswir1
                      kernel_filename, kernel_cmdline, initrd_filename,
421 36cd9210 blueswir1
                      hwdefs[machine].machine_id);
422 36cd9210 blueswir1
}
423 36cd9210 blueswir1
424 36cd9210 blueswir1
/* SPARCstation 5 hardware initialisation */
425 36cd9210 blueswir1
static void ss5_init(int ram_size, int vga_ram_size, int boot_device,
426 36cd9210 blueswir1
                       DisplayState *ds, const char **fd_filename, int snapshot,
427 36cd9210 blueswir1
                       const char *kernel_filename, const char *kernel_cmdline,
428 36cd9210 blueswir1
                       const char *initrd_filename, const char *cpu_model)
429 36cd9210 blueswir1
{
430 36cd9210 blueswir1
    if (cpu_model == NULL)
431 36cd9210 blueswir1
        cpu_model = "Fujitsu MB86904";
432 36cd9210 blueswir1
    sun4m_common_init(ram_size, boot_device, ds, kernel_filename,
433 36cd9210 blueswir1
                      kernel_cmdline, initrd_filename, cpu_model,
434 36cd9210 blueswir1
                      0);
435 420557e8 bellard
}
436 c0e564d5 bellard
437 e0353fe2 blueswir1
/* SPARCstation 10 hardware initialisation */
438 e0353fe2 blueswir1
static void ss10_init(int ram_size, int vga_ram_size, int boot_device,
439 e0353fe2 blueswir1
                            DisplayState *ds, const char **fd_filename, int snapshot,
440 e0353fe2 blueswir1
                            const char *kernel_filename, const char *kernel_cmdline,
441 e0353fe2 blueswir1
                            const char *initrd_filename, const char *cpu_model)
442 e0353fe2 blueswir1
{
443 e0353fe2 blueswir1
    if (cpu_model == NULL)
444 e0353fe2 blueswir1
        cpu_model = "TI SuperSparc II";
445 e0353fe2 blueswir1
    sun4m_common_init(ram_size, boot_device, ds, kernel_filename,
446 e0353fe2 blueswir1
                      kernel_cmdline, initrd_filename, cpu_model,
447 e0353fe2 blueswir1
                      1);
448 e0353fe2 blueswir1
}
449 e0353fe2 blueswir1
450 36cd9210 blueswir1
QEMUMachine ss5_machine = {
451 36cd9210 blueswir1
    "SS-5",
452 36cd9210 blueswir1
    "Sun4m platform, SPARCstation 5",
453 36cd9210 blueswir1
    ss5_init,
454 c0e564d5 bellard
};
455 e0353fe2 blueswir1
456 e0353fe2 blueswir1
QEMUMachine ss10_machine = {
457 e0353fe2 blueswir1
    "SS-10",
458 e0353fe2 blueswir1
    "Sun4m platform, SPARCstation 10",
459 e0353fe2 blueswir1
    ss10_init,
460 e0353fe2 blueswir1
};