root / hw / sun4m.c @ 3cce6243
History | View | Annotate | Download (53.2 kB)
1 |
/*
|
---|---|
2 |
* QEMU Sun4m & Sun4d & Sun4c System Emulator
|
3 |
*
|
4 |
* Copyright (c) 2003-2005 Fabrice Bellard
|
5 |
*
|
6 |
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 |
* of this software and associated documentation files (the "Software"), to deal
|
8 |
* in the Software without restriction, including without limitation the rights
|
9 |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 |
* copies of the Software, and to permit persons to whom the Software is
|
11 |
* furnished to do so, subject to the following conditions:
|
12 |
*
|
13 |
* The above copyright notice and this permission notice shall be included in
|
14 |
* all copies or substantial portions of the Software.
|
15 |
*
|
16 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 |
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 |
* THE SOFTWARE.
|
23 |
*/
|
24 |
#include "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 |
#include "scsi.h" |
35 |
#include "pc.h" |
36 |
#include "isa.h" |
37 |
#include "fw_cfg.h" |
38 |
|
39 |
//#define DEBUG_IRQ
|
40 |
|
41 |
/*
|
42 |
* Sun4m architecture was used in the following machines:
|
43 |
*
|
44 |
* SPARCserver 6xxMP/xx
|
45 |
* SPARCclassic (SPARCclassic Server)(SPARCstation LC) (4/15),
|
46 |
* SPARCclassic X (4/10)
|
47 |
* SPARCstation LX/ZX (4/30)
|
48 |
* SPARCstation Voyager
|
49 |
* SPARCstation 10/xx, SPARCserver 10/xx
|
50 |
* SPARCstation 5, SPARCserver 5
|
51 |
* SPARCstation 20/xx, SPARCserver 20
|
52 |
* SPARCstation 4
|
53 |
*
|
54 |
* Sun4d architecture was used in the following machines:
|
55 |
*
|
56 |
* SPARCcenter 2000
|
57 |
* SPARCserver 1000
|
58 |
*
|
59 |
* Sun4c architecture was used in the following machines:
|
60 |
* SPARCstation 1/1+, SPARCserver 1/1+
|
61 |
* SPARCstation SLC
|
62 |
* SPARCstation IPC
|
63 |
* SPARCstation ELC
|
64 |
* SPARCstation IPX
|
65 |
*
|
66 |
* See for example: http://www.sunhelp.org/faq/sunref1.html
|
67 |
*/
|
68 |
|
69 |
#ifdef DEBUG_IRQ
|
70 |
#define DPRINTF(fmt, args...) \
|
71 |
do { printf("CPUIRQ: " fmt , ##args); } while (0) |
72 |
#else
|
73 |
#define DPRINTF(fmt, args...)
|
74 |
#endif
|
75 |
|
76 |
#define KERNEL_LOAD_ADDR 0x00004000 |
77 |
#define CMDLINE_ADDR 0x007ff000 |
78 |
#define INITRD_LOAD_ADDR 0x00800000 |
79 |
#define PROM_SIZE_MAX (512 * 1024) |
80 |
#define PROM_VADDR 0xffd00000 |
81 |
#define PROM_FILENAME "openbios-sparc32" |
82 |
#define CFG_ADDR 0xd00000510ULL |
83 |
|
84 |
// Control plane, 8-bit and 24-bit planes
|
85 |
#define TCX_SIZE (9 * 1024 * 1024) |
86 |
|
87 |
#define MAX_CPUS 16 |
88 |
#define MAX_PILS 16 |
89 |
|
90 |
struct hwdef {
|
91 |
target_phys_addr_t iommu_base, slavio_base; |
92 |
target_phys_addr_t intctl_base, counter_base, nvram_base, ms_kb_base; |
93 |
target_phys_addr_t serial_base, fd_base; |
94 |
target_phys_addr_t idreg_base, dma_base, esp_base, le_base; |
95 |
target_phys_addr_t tcx_base, cs_base, apc_base, aux1_base, aux2_base; |
96 |
target_phys_addr_t ecc_base; |
97 |
uint32_t ecc_version; |
98 |
target_phys_addr_t sun4c_intctl_base, sun4c_counter_base; |
99 |
long vram_size, nvram_size;
|
100 |
// IRQ numbers are not PIL ones, but master interrupt controller
|
101 |
// register bit numbers
|
102 |
int intctl_g_intr, esp_irq, le_irq, clock_irq, clock1_irq;
|
103 |
int ser_irq, ms_kb_irq, fd_irq, me_irq, cs_irq, ecc_irq;
|
104 |
int machine_id; // For NVRAM |
105 |
uint32_t iommu_version; |
106 |
uint32_t intbit_to_level[32];
|
107 |
uint64_t max_mem; |
108 |
const char * const default_cpu_model; |
109 |
}; |
110 |
|
111 |
#define MAX_IOUNITS 5 |
112 |
|
113 |
struct sun4d_hwdef {
|
114 |
target_phys_addr_t iounit_bases[MAX_IOUNITS], slavio_base; |
115 |
target_phys_addr_t counter_base, nvram_base, ms_kb_base; |
116 |
target_phys_addr_t serial_base; |
117 |
target_phys_addr_t espdma_base, esp_base; |
118 |
target_phys_addr_t ledma_base, le_base; |
119 |
target_phys_addr_t tcx_base; |
120 |
target_phys_addr_t sbi_base; |
121 |
unsigned long vram_size, nvram_size; |
122 |
// IRQ numbers are not PIL ones, but SBI register bit numbers
|
123 |
int esp_irq, le_irq, clock_irq, clock1_irq;
|
124 |
int ser_irq, ms_kb_irq, me_irq;
|
125 |
int machine_id; // For NVRAM |
126 |
uint32_t iounit_version; |
127 |
uint64_t max_mem; |
128 |
const char * const default_cpu_model; |
129 |
}; |
130 |
|
131 |
int DMA_get_channel_mode (int nchan) |
132 |
{ |
133 |
return 0; |
134 |
} |
135 |
int DMA_read_memory (int nchan, void *buf, int pos, int size) |
136 |
{ |
137 |
return 0; |
138 |
} |
139 |
int DMA_write_memory (int nchan, void *buf, int pos, int size) |
140 |
{ |
141 |
return 0; |
142 |
} |
143 |
void DMA_hold_DREQ (int nchan) {} |
144 |
void DMA_release_DREQ (int nchan) {} |
145 |
void DMA_schedule(int nchan) {} |
146 |
void DMA_run (void) {} |
147 |
void DMA_init (int high_page_enable) {} |
148 |
void DMA_register_channel (int nchan, |
149 |
DMA_transfer_handler transfer_handler, |
150 |
void *opaque)
|
151 |
{ |
152 |
} |
153 |
|
154 |
static int nvram_boot_set(void *opaque, const char *boot_device) |
155 |
{ |
156 |
unsigned int i; |
157 |
uint8_t image[sizeof(ohwcfg_v3_t)];
|
158 |
ohwcfg_v3_t *header = (ohwcfg_v3_t *)ℑ |
159 |
m48t59_t *nvram = (m48t59_t *)opaque; |
160 |
|
161 |
for (i = 0; i < sizeof(image); i++) |
162 |
image[i] = m48t59_read(nvram, i) & 0xff;
|
163 |
|
164 |
pstrcpy((char *)header->boot_devices, sizeof(header->boot_devices), |
165 |
boot_device); |
166 |
header->nboot_devices = strlen(boot_device) & 0xff;
|
167 |
header->crc = cpu_to_be16(OHW_compute_crc(header, 0x00, 0xF8)); |
168 |
|
169 |
for (i = 0; i < sizeof(image); i++) |
170 |
m48t59_write(nvram, i, image[i]); |
171 |
|
172 |
return 0; |
173 |
} |
174 |
|
175 |
extern int nographic; |
176 |
|
177 |
static void nvram_init(m48t59_t *nvram, uint8_t *macaddr, const char *cmdline, |
178 |
const char *boot_devices, ram_addr_t RAM_size, |
179 |
uint32_t kernel_size, |
180 |
int width, int height, int depth, |
181 |
int machine_id, const char *arch) |
182 |
{ |
183 |
unsigned int i; |
184 |
uint32_t start, end; |
185 |
uint8_t image[0x1ff0];
|
186 |
ohwcfg_v3_t *header = (ohwcfg_v3_t *)ℑ |
187 |
struct sparc_arch_cfg *sparc_header;
|
188 |
struct OpenBIOS_nvpart_v1 *part_header;
|
189 |
|
190 |
memset(image, '\0', sizeof(image)); |
191 |
|
192 |
// Try to match PPC NVRAM
|
193 |
pstrcpy((char *)header->struct_ident, sizeof(header->struct_ident), |
194 |
"QEMU_BIOS");
|
195 |
header->struct_version = cpu_to_be32(3); /* structure v3 */ |
196 |
|
197 |
header->nvram_size = cpu_to_be16(0x2000);
|
198 |
header->nvram_arch_ptr = cpu_to_be16(sizeof(ohwcfg_v3_t));
|
199 |
header->nvram_arch_size = cpu_to_be16(sizeof(struct sparc_arch_cfg)); |
200 |
pstrcpy((char *)header->arch, sizeof(header->arch), arch); |
201 |
header->nb_cpus = smp_cpus & 0xff;
|
202 |
header->RAM0_base = 0;
|
203 |
header->RAM0_size = cpu_to_be64((uint64_t)RAM_size); |
204 |
pstrcpy((char *)header->boot_devices, sizeof(header->boot_devices), |
205 |
boot_devices); |
206 |
header->nboot_devices = strlen(boot_devices) & 0xff;
|
207 |
header->kernel_image = cpu_to_be64((uint64_t)KERNEL_LOAD_ADDR); |
208 |
header->kernel_size = cpu_to_be64((uint64_t)kernel_size); |
209 |
if (cmdline) {
|
210 |
pstrcpy_targphys(CMDLINE_ADDR, TARGET_PAGE_SIZE, cmdline); |
211 |
header->cmdline = cpu_to_be64((uint64_t)CMDLINE_ADDR); |
212 |
header->cmdline_size = cpu_to_be64((uint64_t)strlen(cmdline)); |
213 |
} |
214 |
// XXX add initrd_image, initrd_size
|
215 |
header->width = cpu_to_be16(width); |
216 |
header->height = cpu_to_be16(height); |
217 |
header->depth = cpu_to_be16(depth); |
218 |
if (nographic)
|
219 |
header->graphic_flags = cpu_to_be16(OHW_GF_NOGRAPHICS); |
220 |
|
221 |
header->crc = cpu_to_be16(OHW_compute_crc(header, 0x00, 0xF8)); |
222 |
|
223 |
// Architecture specific header
|
224 |
start = sizeof(ohwcfg_v3_t);
|
225 |
sparc_header = (struct sparc_arch_cfg *)&image[start];
|
226 |
sparc_header->valid = 0;
|
227 |
start += sizeof(struct sparc_arch_cfg); |
228 |
|
229 |
// OpenBIOS nvram variables
|
230 |
// Variable partition
|
231 |
part_header = (struct OpenBIOS_nvpart_v1 *)&image[start];
|
232 |
part_header->signature = OPENBIOS_PART_SYSTEM; |
233 |
pstrcpy(part_header->name, sizeof(part_header->name), "system"); |
234 |
|
235 |
end = start + sizeof(struct OpenBIOS_nvpart_v1); |
236 |
for (i = 0; i < nb_prom_envs; i++) |
237 |
end = OpenBIOS_set_var(image, end, prom_envs[i]); |
238 |
|
239 |
// End marker
|
240 |
image[end++] = '\0';
|
241 |
|
242 |
end = start + ((end - start + 15) & ~15); |
243 |
OpenBIOS_finish_partition(part_header, end - start); |
244 |
|
245 |
// free partition
|
246 |
start = end; |
247 |
part_header = (struct OpenBIOS_nvpart_v1 *)&image[start];
|
248 |
part_header->signature = OPENBIOS_PART_FREE; |
249 |
pstrcpy(part_header->name, sizeof(part_header->name), "free"); |
250 |
|
251 |
end = 0x1fd0;
|
252 |
OpenBIOS_finish_partition(part_header, end - start); |
253 |
|
254 |
Sun_init_header((struct Sun_nvram *)&image[0x1fd8], macaddr, machine_id); |
255 |
|
256 |
for (i = 0; i < sizeof(image); i++) |
257 |
m48t59_write(nvram, i, image[i]); |
258 |
|
259 |
qemu_register_boot_set(nvram_boot_set, nvram); |
260 |
} |
261 |
|
262 |
static void *slavio_intctl; |
263 |
|
264 |
void pic_info(void) |
265 |
{ |
266 |
if (slavio_intctl)
|
267 |
slavio_pic_info(slavio_intctl); |
268 |
} |
269 |
|
270 |
void irq_info(void) |
271 |
{ |
272 |
if (slavio_intctl)
|
273 |
slavio_irq_info(slavio_intctl); |
274 |
} |
275 |
|
276 |
void cpu_check_irqs(CPUState *env)
|
277 |
{ |
278 |
if (env->pil_in && (env->interrupt_index == 0 || |
279 |
(env->interrupt_index & ~15) == TT_EXTINT)) {
|
280 |
unsigned int i; |
281 |
|
282 |
for (i = 15; i > 0; i--) { |
283 |
if (env->pil_in & (1 << i)) { |
284 |
int old_interrupt = env->interrupt_index;
|
285 |
|
286 |
env->interrupt_index = TT_EXTINT | i; |
287 |
if (old_interrupt != env->interrupt_index) {
|
288 |
DPRINTF("Set CPU IRQ %d\n", i);
|
289 |
cpu_interrupt(env, CPU_INTERRUPT_HARD); |
290 |
} |
291 |
break;
|
292 |
} |
293 |
} |
294 |
} else if (!env->pil_in && (env->interrupt_index & ~15) == TT_EXTINT) { |
295 |
DPRINTF("Reset CPU IRQ %d\n", env->interrupt_index & 15); |
296 |
env->interrupt_index = 0;
|
297 |
cpu_reset_interrupt(env, CPU_INTERRUPT_HARD); |
298 |
} |
299 |
} |
300 |
|
301 |
static void cpu_set_irq(void *opaque, int irq, int level) |
302 |
{ |
303 |
CPUState *env = opaque; |
304 |
|
305 |
if (level) {
|
306 |
DPRINTF("Raise CPU IRQ %d\n", irq);
|
307 |
env->halted = 0;
|
308 |
env->pil_in |= 1 << irq;
|
309 |
cpu_check_irqs(env); |
310 |
} else {
|
311 |
DPRINTF("Lower CPU IRQ %d\n", irq);
|
312 |
env->pil_in &= ~(1 << irq);
|
313 |
cpu_check_irqs(env); |
314 |
} |
315 |
} |
316 |
|
317 |
static void dummy_cpu_set_irq(void *opaque, int irq, int level) |
318 |
{ |
319 |
} |
320 |
|
321 |
static void *slavio_misc; |
322 |
|
323 |
void qemu_system_powerdown(void) |
324 |
{ |
325 |
slavio_set_power_fail(slavio_misc, 1);
|
326 |
} |
327 |
|
328 |
static void main_cpu_reset(void *opaque) |
329 |
{ |
330 |
CPUState *env = opaque; |
331 |
|
332 |
cpu_reset(env); |
333 |
env->halted = 0;
|
334 |
} |
335 |
|
336 |
static void secondary_cpu_reset(void *opaque) |
337 |
{ |
338 |
CPUState *env = opaque; |
339 |
|
340 |
cpu_reset(env); |
341 |
env->halted = 1;
|
342 |
} |
343 |
|
344 |
static unsigned long sun4m_load_kernel(const char *kernel_filename, |
345 |
const char *initrd_filename, |
346 |
ram_addr_t RAM_size) |
347 |
{ |
348 |
int linux_boot;
|
349 |
unsigned int i; |
350 |
long initrd_size, kernel_size;
|
351 |
|
352 |
linux_boot = (kernel_filename != NULL);
|
353 |
|
354 |
kernel_size = 0;
|
355 |
if (linux_boot) {
|
356 |
kernel_size = load_elf(kernel_filename, -0xf0000000ULL, NULL, NULL, |
357 |
NULL);
|
358 |
if (kernel_size < 0) |
359 |
kernel_size = load_aout(kernel_filename, KERNEL_LOAD_ADDR, |
360 |
RAM_size - KERNEL_LOAD_ADDR); |
361 |
if (kernel_size < 0) |
362 |
kernel_size = load_image_targphys(kernel_filename, |
363 |
KERNEL_LOAD_ADDR, |
364 |
RAM_size - KERNEL_LOAD_ADDR); |
365 |
if (kernel_size < 0) { |
366 |
fprintf(stderr, "qemu: could not load kernel '%s'\n",
|
367 |
kernel_filename); |
368 |
exit(1);
|
369 |
} |
370 |
|
371 |
/* load initrd */
|
372 |
initrd_size = 0;
|
373 |
if (initrd_filename) {
|
374 |
initrd_size = load_image_targphys(initrd_filename, |
375 |
INITRD_LOAD_ADDR, |
376 |
RAM_size - INITRD_LOAD_ADDR); |
377 |
if (initrd_size < 0) { |
378 |
fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
|
379 |
initrd_filename); |
380 |
exit(1);
|
381 |
} |
382 |
} |
383 |
if (initrd_size > 0) { |
384 |
for (i = 0; i < 64 * TARGET_PAGE_SIZE; i += TARGET_PAGE_SIZE) { |
385 |
if (ldl_phys(KERNEL_LOAD_ADDR + i) == 0x48647253) { // HdrS |
386 |
stl_phys(KERNEL_LOAD_ADDR + i + 16, INITRD_LOAD_ADDR);
|
387 |
stl_phys(KERNEL_LOAD_ADDR + i + 20, initrd_size);
|
388 |
break;
|
389 |
} |
390 |
} |
391 |
} |
392 |
} |
393 |
return kernel_size;
|
394 |
} |
395 |
|
396 |
static void sun4m_hw_init(const struct hwdef *hwdef, ram_addr_t RAM_size, |
397 |
const char *boot_device, |
398 |
DisplayState *ds, const char *kernel_filename, |
399 |
const char *kernel_cmdline, |
400 |
const char *initrd_filename, const char *cpu_model) |
401 |
|
402 |
{ |
403 |
CPUState *env, *envs[MAX_CPUS]; |
404 |
unsigned int i; |
405 |
void *iommu, *espdma, *ledma, *main_esp, *nvram;
|
406 |
qemu_irq *cpu_irqs[MAX_CPUS], *slavio_irq, *slavio_cpu_irq, |
407 |
*espdma_irq, *ledma_irq; |
408 |
qemu_irq *esp_reset, *le_reset; |
409 |
qemu_irq *fdc_tc; |
410 |
unsigned long prom_offset, kernel_size; |
411 |
int ret;
|
412 |
char buf[1024]; |
413 |
BlockDriverState *fd[MAX_FD]; |
414 |
int drive_index;
|
415 |
void *fw_cfg;
|
416 |
|
417 |
/* init CPUs */
|
418 |
if (!cpu_model)
|
419 |
cpu_model = hwdef->default_cpu_model; |
420 |
|
421 |
for(i = 0; i < smp_cpus; i++) { |
422 |
env = cpu_init(cpu_model); |
423 |
if (!env) {
|
424 |
fprintf(stderr, "qemu: Unable to find Sparc CPU definition\n");
|
425 |
exit(1);
|
426 |
} |
427 |
cpu_sparc_set_id(env, i); |
428 |
envs[i] = env; |
429 |
if (i == 0) { |
430 |
qemu_register_reset(main_cpu_reset, env); |
431 |
} else {
|
432 |
qemu_register_reset(secondary_cpu_reset, env); |
433 |
env->halted = 1;
|
434 |
} |
435 |
cpu_irqs[i] = qemu_allocate_irqs(cpu_set_irq, envs[i], MAX_PILS); |
436 |
env->prom_addr = hwdef->slavio_base; |
437 |
} |
438 |
|
439 |
for (i = smp_cpus; i < MAX_CPUS; i++)
|
440 |
cpu_irqs[i] = qemu_allocate_irqs(dummy_cpu_set_irq, NULL, MAX_PILS);
|
441 |
|
442 |
|
443 |
/* allocate RAM */
|
444 |
if ((uint64_t)RAM_size > hwdef->max_mem) {
|
445 |
fprintf(stderr, |
446 |
"qemu: Too much memory for this machine: %d, maximum %d\n",
|
447 |
(unsigned int)(RAM_size / (1024 * 1024)), |
448 |
(unsigned int)(hwdef->max_mem / (1024 * 1024))); |
449 |
exit(1);
|
450 |
} |
451 |
cpu_register_physical_memory(0, RAM_size, 0); |
452 |
|
453 |
/* load boot prom */
|
454 |
prom_offset = RAM_size + hwdef->vram_size; |
455 |
cpu_register_physical_memory(hwdef->slavio_base, |
456 |
(PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) &
|
457 |
TARGET_PAGE_MASK, |
458 |
prom_offset | IO_MEM_ROM); |
459 |
|
460 |
if (bios_name == NULL) |
461 |
bios_name = PROM_FILENAME; |
462 |
snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); |
463 |
ret = load_elf(buf, hwdef->slavio_base - PROM_VADDR, NULL, NULL, NULL); |
464 |
if (ret < 0 || ret > PROM_SIZE_MAX) |
465 |
ret = load_image_targphys(buf, hwdef->slavio_base, PROM_SIZE_MAX); |
466 |
if (ret < 0 || ret > PROM_SIZE_MAX) { |
467 |
fprintf(stderr, "qemu: could not load prom '%s'\n",
|
468 |
buf); |
469 |
exit(1);
|
470 |
} |
471 |
prom_offset += (ret + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK;
|
472 |
|
473 |
/* set up devices */
|
474 |
slavio_intctl = slavio_intctl_init(hwdef->intctl_base, |
475 |
hwdef->intctl_base + 0x10000ULL,
|
476 |
&hwdef->intbit_to_level[0],
|
477 |
&slavio_irq, &slavio_cpu_irq, |
478 |
cpu_irqs, |
479 |
hwdef->clock_irq); |
480 |
|
481 |
if (hwdef->idreg_base != (target_phys_addr_t)-1) { |
482 |
static const uint8_t idreg_data[] = { 0xfe, 0x81, 0x01, 0x03 }; |
483 |
|
484 |
cpu_register_physical_memory(hwdef->idreg_base, sizeof(idreg_data),
|
485 |
prom_offset | IO_MEM_ROM); |
486 |
cpu_physical_memory_write_rom(hwdef->idreg_base, idreg_data, |
487 |
sizeof(idreg_data));
|
488 |
} |
489 |
|
490 |
iommu = iommu_init(hwdef->iommu_base, hwdef->iommu_version, |
491 |
slavio_irq[hwdef->me_irq]); |
492 |
|
493 |
espdma = sparc32_dma_init(hwdef->dma_base, slavio_irq[hwdef->esp_irq], |
494 |
iommu, &espdma_irq, &esp_reset); |
495 |
|
496 |
ledma = sparc32_dma_init(hwdef->dma_base + 16ULL,
|
497 |
slavio_irq[hwdef->le_irq], iommu, &ledma_irq, |
498 |
&le_reset); |
499 |
|
500 |
if (graphic_depth != 8 && graphic_depth != 24) { |
501 |
fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth);
|
502 |
exit (1);
|
503 |
} |
504 |
tcx_init(ds, hwdef->tcx_base, phys_ram_base + RAM_size, RAM_size, |
505 |
hwdef->vram_size, graphic_width, graphic_height, graphic_depth); |
506 |
|
507 |
if (nd_table[0].model == NULL |
508 |
|| strcmp(nd_table[0].model, "lance") == 0) { |
509 |
lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
|
510 |
} else if (strcmp(nd_table[0].model, "?") == 0) { |
511 |
fprintf(stderr, "qemu: Supported NICs: lance\n");
|
512 |
exit (1);
|
513 |
} else {
|
514 |
fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model); |
515 |
exit (1);
|
516 |
} |
517 |
|
518 |
nvram = m48t59_init(slavio_irq[0], hwdef->nvram_base, 0, |
519 |
hwdef->nvram_size, 8);
|
520 |
|
521 |
slavio_timer_init_all(hwdef->counter_base, slavio_irq[hwdef->clock1_irq], |
522 |
slavio_cpu_irq, smp_cpus); |
523 |
|
524 |
slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[hwdef->ms_kb_irq], |
525 |
nographic); |
526 |
// Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
|
527 |
// Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
|
528 |
slavio_serial_init(hwdef->serial_base, slavio_irq[hwdef->ser_irq], |
529 |
serial_hds[1], serial_hds[0]); |
530 |
|
531 |
slavio_misc = slavio_misc_init(hwdef->slavio_base, hwdef->apc_base, |
532 |
hwdef->aux1_base, hwdef->aux2_base, |
533 |
slavio_irq[hwdef->me_irq], envs[0],
|
534 |
&fdc_tc); |
535 |
|
536 |
if (hwdef->fd_base != (target_phys_addr_t)-1) { |
537 |
/* there is zero or one floppy drive */
|
538 |
memset(fd, 0, sizeof(fd)); |
539 |
drive_index = drive_get_index(IF_FLOPPY, 0, 0); |
540 |
if (drive_index != -1) |
541 |
fd[0] = drives_table[drive_index].bdrv;
|
542 |
|
543 |
sun4m_fdctrl_init(slavio_irq[hwdef->fd_irq], hwdef->fd_base, fd, |
544 |
fdc_tc); |
545 |
} |
546 |
|
547 |
if (drive_get_max_bus(IF_SCSI) > 0) { |
548 |
fprintf(stderr, "qemu: too many SCSI bus\n");
|
549 |
exit(1);
|
550 |
} |
551 |
|
552 |
main_esp = esp_init(hwdef->esp_base, 2,
|
553 |
espdma_memory_read, espdma_memory_write, |
554 |
espdma, *espdma_irq, esp_reset); |
555 |
|
556 |
for (i = 0; i < ESP_MAX_DEVS; i++) { |
557 |
drive_index = drive_get_index(IF_SCSI, 0, i);
|
558 |
if (drive_index == -1) |
559 |
continue;
|
560 |
esp_scsi_attach(main_esp, drives_table[drive_index].bdrv, i); |
561 |
} |
562 |
|
563 |
if (hwdef->cs_base != (target_phys_addr_t)-1) |
564 |
cs_init(hwdef->cs_base, hwdef->cs_irq, slavio_intctl); |
565 |
|
566 |
kernel_size = sun4m_load_kernel(kernel_filename, initrd_filename, |
567 |
RAM_size); |
568 |
|
569 |
nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
|
570 |
boot_device, RAM_size, kernel_size, graphic_width, |
571 |
graphic_height, graphic_depth, hwdef->machine_id, "Sun4m");
|
572 |
|
573 |
if (hwdef->ecc_base != (target_phys_addr_t)-1) |
574 |
ecc_init(hwdef->ecc_base, slavio_irq[hwdef->ecc_irq], |
575 |
hwdef->ecc_version); |
576 |
|
577 |
fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2); |
578 |
fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
|
579 |
} |
580 |
|
581 |
static void sun4c_hw_init(const struct hwdef *hwdef, ram_addr_t RAM_size, |
582 |
const char *boot_device, |
583 |
DisplayState *ds, const char *kernel_filename, |
584 |
const char *kernel_cmdline, |
585 |
const char *initrd_filename, const char *cpu_model) |
586 |
{ |
587 |
CPUState *env; |
588 |
unsigned int i; |
589 |
void *iommu, *espdma, *ledma, *main_esp, *nvram;
|
590 |
qemu_irq *cpu_irqs, *slavio_irq, *espdma_irq, *ledma_irq; |
591 |
qemu_irq *esp_reset, *le_reset; |
592 |
qemu_irq *fdc_tc; |
593 |
unsigned long prom_offset, kernel_size; |
594 |
int ret;
|
595 |
char buf[1024]; |
596 |
BlockDriverState *fd[MAX_FD]; |
597 |
int drive_index;
|
598 |
void *fw_cfg;
|
599 |
|
600 |
/* init CPU */
|
601 |
if (!cpu_model)
|
602 |
cpu_model = hwdef->default_cpu_model; |
603 |
|
604 |
env = cpu_init(cpu_model); |
605 |
if (!env) {
|
606 |
fprintf(stderr, "qemu: Unable to find Sparc CPU definition\n");
|
607 |
exit(1);
|
608 |
} |
609 |
|
610 |
cpu_sparc_set_id(env, 0);
|
611 |
|
612 |
qemu_register_reset(main_cpu_reset, env); |
613 |
cpu_irqs = qemu_allocate_irqs(cpu_set_irq, env, MAX_PILS); |
614 |
env->prom_addr = hwdef->slavio_base; |
615 |
|
616 |
/* allocate RAM */
|
617 |
if ((uint64_t)RAM_size > hwdef->max_mem) {
|
618 |
fprintf(stderr, |
619 |
"qemu: Too much memory for this machine: %d, maximum %d\n",
|
620 |
(unsigned int)(RAM_size / (1024 * 1024)), |
621 |
(unsigned int)(hwdef->max_mem / (1024 * 1024))); |
622 |
exit(1);
|
623 |
} |
624 |
cpu_register_physical_memory(0, RAM_size, 0); |
625 |
|
626 |
/* load boot prom */
|
627 |
prom_offset = RAM_size + hwdef->vram_size; |
628 |
cpu_register_physical_memory(hwdef->slavio_base, |
629 |
(PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) &
|
630 |
TARGET_PAGE_MASK, |
631 |
prom_offset | IO_MEM_ROM); |
632 |
|
633 |
if (bios_name == NULL) |
634 |
bios_name = PROM_FILENAME; |
635 |
snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); |
636 |
ret = load_elf(buf, hwdef->slavio_base - PROM_VADDR, NULL, NULL, NULL); |
637 |
if (ret < 0 || ret > PROM_SIZE_MAX) |
638 |
ret = load_image_targphys(buf, hwdef->slavio_base, PROM_SIZE_MAX); |
639 |
if (ret < 0 || ret > PROM_SIZE_MAX) { |
640 |
fprintf(stderr, "qemu: could not load prom '%s'\n",
|
641 |
buf); |
642 |
exit(1);
|
643 |
} |
644 |
prom_offset += (ret + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK;
|
645 |
|
646 |
/* set up devices */
|
647 |
slavio_intctl = sun4c_intctl_init(hwdef->sun4c_intctl_base, |
648 |
&slavio_irq, cpu_irqs); |
649 |
|
650 |
iommu = iommu_init(hwdef->iommu_base, hwdef->iommu_version, |
651 |
slavio_irq[hwdef->me_irq]); |
652 |
|
653 |
espdma = sparc32_dma_init(hwdef->dma_base, slavio_irq[hwdef->esp_irq], |
654 |
iommu, &espdma_irq, &esp_reset); |
655 |
|
656 |
ledma = sparc32_dma_init(hwdef->dma_base + 16ULL,
|
657 |
slavio_irq[hwdef->le_irq], iommu, &ledma_irq, |
658 |
&le_reset); |
659 |
|
660 |
if (graphic_depth != 8 && graphic_depth != 24) { |
661 |
fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth);
|
662 |
exit (1);
|
663 |
} |
664 |
tcx_init(ds, hwdef->tcx_base, phys_ram_base + RAM_size, RAM_size, |
665 |
hwdef->vram_size, graphic_width, graphic_height, graphic_depth); |
666 |
|
667 |
if (nd_table[0].model == NULL |
668 |
|| strcmp(nd_table[0].model, "lance") == 0) { |
669 |
lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
|
670 |
} else if (strcmp(nd_table[0].model, "?") == 0) { |
671 |
fprintf(stderr, "qemu: Supported NICs: lance\n");
|
672 |
exit (1);
|
673 |
} else {
|
674 |
fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model); |
675 |
exit (1);
|
676 |
} |
677 |
|
678 |
nvram = m48t59_init(slavio_irq[0], hwdef->nvram_base, 0, |
679 |
hwdef->nvram_size, 2);
|
680 |
|
681 |
slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[hwdef->ms_kb_irq], |
682 |
nographic); |
683 |
// Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
|
684 |
// Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
|
685 |
slavio_serial_init(hwdef->serial_base, slavio_irq[hwdef->ser_irq], |
686 |
serial_hds[1], serial_hds[0]); |
687 |
|
688 |
slavio_misc = slavio_misc_init(-1, hwdef->apc_base,
|
689 |
hwdef->aux1_base, hwdef->aux2_base, |
690 |
slavio_irq[hwdef->me_irq], env, &fdc_tc); |
691 |
|
692 |
if (hwdef->fd_base != (target_phys_addr_t)-1) { |
693 |
/* there is zero or one floppy drive */
|
694 |
fd[1] = fd[0] = NULL; |
695 |
drive_index = drive_get_index(IF_FLOPPY, 0, 0); |
696 |
if (drive_index != -1) |
697 |
fd[0] = drives_table[drive_index].bdrv;
|
698 |
|
699 |
sun4m_fdctrl_init(slavio_irq[hwdef->fd_irq], hwdef->fd_base, fd, |
700 |
fdc_tc); |
701 |
} |
702 |
|
703 |
if (drive_get_max_bus(IF_SCSI) > 0) { |
704 |
fprintf(stderr, "qemu: too many SCSI bus\n");
|
705 |
exit(1);
|
706 |
} |
707 |
|
708 |
main_esp = esp_init(hwdef->esp_base, 2,
|
709 |
espdma_memory_read, espdma_memory_write, |
710 |
espdma, *espdma_irq, esp_reset); |
711 |
|
712 |
for (i = 0; i < ESP_MAX_DEVS; i++) { |
713 |
drive_index = drive_get_index(IF_SCSI, 0, i);
|
714 |
if (drive_index == -1) |
715 |
continue;
|
716 |
esp_scsi_attach(main_esp, drives_table[drive_index].bdrv, i); |
717 |
} |
718 |
|
719 |
kernel_size = sun4m_load_kernel(kernel_filename, initrd_filename, |
720 |
RAM_size); |
721 |
|
722 |
nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
|
723 |
boot_device, RAM_size, kernel_size, graphic_width, |
724 |
graphic_height, graphic_depth, hwdef->machine_id, "Sun4c");
|
725 |
|
726 |
fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2); |
727 |
fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
|
728 |
} |
729 |
|
730 |
static const struct hwdef hwdefs[] = { |
731 |
/* SS-5 */
|
732 |
{ |
733 |
.iommu_base = 0x10000000,
|
734 |
.tcx_base = 0x50000000,
|
735 |
.cs_base = 0x6c000000,
|
736 |
.slavio_base = 0x70000000,
|
737 |
.ms_kb_base = 0x71000000,
|
738 |
.serial_base = 0x71100000,
|
739 |
.nvram_base = 0x71200000,
|
740 |
.fd_base = 0x71400000,
|
741 |
.counter_base = 0x71d00000,
|
742 |
.intctl_base = 0x71e00000,
|
743 |
.idreg_base = 0x78000000,
|
744 |
.dma_base = 0x78400000,
|
745 |
.esp_base = 0x78800000,
|
746 |
.le_base = 0x78c00000,
|
747 |
.apc_base = 0x6a000000,
|
748 |
.aux1_base = 0x71900000,
|
749 |
.aux2_base = 0x71910000,
|
750 |
.ecc_base = -1,
|
751 |
.sun4c_intctl_base = -1,
|
752 |
.sun4c_counter_base = -1,
|
753 |
.vram_size = 0x00100000,
|
754 |
.nvram_size = 0x2000,
|
755 |
.esp_irq = 18,
|
756 |
.le_irq = 16,
|
757 |
.clock_irq = 7,
|
758 |
.clock1_irq = 19,
|
759 |
.ms_kb_irq = 14,
|
760 |
.ser_irq = 15,
|
761 |
.fd_irq = 22,
|
762 |
.me_irq = 30,
|
763 |
.cs_irq = 5,
|
764 |
.machine_id = 0x80,
|
765 |
.iommu_version = 0x05000000,
|
766 |
.intbit_to_level = { |
767 |
2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12, |
768 |
6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0, |
769 |
}, |
770 |
.max_mem = 0x10000000,
|
771 |
.default_cpu_model = "Fujitsu MB86904",
|
772 |
}, |
773 |
/* SS-10 */
|
774 |
{ |
775 |
.iommu_base = 0xfe0000000ULL,
|
776 |
.tcx_base = 0xe20000000ULL,
|
777 |
.cs_base = -1,
|
778 |
.slavio_base = 0xff0000000ULL,
|
779 |
.ms_kb_base = 0xff1000000ULL,
|
780 |
.serial_base = 0xff1100000ULL,
|
781 |
.nvram_base = 0xff1200000ULL,
|
782 |
.fd_base = 0xff1700000ULL,
|
783 |
.counter_base = 0xff1300000ULL,
|
784 |
.intctl_base = 0xff1400000ULL,
|
785 |
.idreg_base = 0xef0000000ULL,
|
786 |
.dma_base = 0xef0400000ULL,
|
787 |
.esp_base = 0xef0800000ULL,
|
788 |
.le_base = 0xef0c00000ULL,
|
789 |
.apc_base = 0xefa000000ULL, // XXX should not exist |
790 |
.aux1_base = 0xff1800000ULL,
|
791 |
.aux2_base = 0xff1a01000ULL,
|
792 |
.ecc_base = 0xf00000000ULL,
|
793 |
.ecc_version = 0x10000000, // version 0, implementation 1 |
794 |
.sun4c_intctl_base = -1,
|
795 |
.sun4c_counter_base = -1,
|
796 |
.vram_size = 0x00100000,
|
797 |
.nvram_size = 0x2000,
|
798 |
.esp_irq = 18,
|
799 |
.le_irq = 16,
|
800 |
.clock_irq = 7,
|
801 |
.clock1_irq = 19,
|
802 |
.ms_kb_irq = 14,
|
803 |
.ser_irq = 15,
|
804 |
.fd_irq = 22,
|
805 |
.me_irq = 30,
|
806 |
.cs_irq = -1,
|
807 |
.ecc_irq = 28,
|
808 |
.machine_id = 0x72,
|
809 |
.iommu_version = 0x03000000,
|
810 |
.intbit_to_level = { |
811 |
2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12, |
812 |
6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0, |
813 |
}, |
814 |
.max_mem = 0xf00000000ULL,
|
815 |
.default_cpu_model = "TI SuperSparc II",
|
816 |
}, |
817 |
/* SS-600MP */
|
818 |
{ |
819 |
.iommu_base = 0xfe0000000ULL,
|
820 |
.tcx_base = 0xe20000000ULL,
|
821 |
.cs_base = -1,
|
822 |
.slavio_base = 0xff0000000ULL,
|
823 |
.ms_kb_base = 0xff1000000ULL,
|
824 |
.serial_base = 0xff1100000ULL,
|
825 |
.nvram_base = 0xff1200000ULL,
|
826 |
.fd_base = -1,
|
827 |
.counter_base = 0xff1300000ULL,
|
828 |
.intctl_base = 0xff1400000ULL,
|
829 |
.idreg_base = -1,
|
830 |
.dma_base = 0xef0081000ULL,
|
831 |
.esp_base = 0xef0080000ULL,
|
832 |
.le_base = 0xef0060000ULL,
|
833 |
.apc_base = 0xefa000000ULL, // XXX should not exist |
834 |
.aux1_base = 0xff1800000ULL,
|
835 |
.aux2_base = 0xff1a01000ULL, // XXX should not exist |
836 |
.ecc_base = 0xf00000000ULL,
|
837 |
.ecc_version = 0x00000000, // version 0, implementation 0 |
838 |
.sun4c_intctl_base = -1,
|
839 |
.sun4c_counter_base = -1,
|
840 |
.vram_size = 0x00100000,
|
841 |
.nvram_size = 0x2000,
|
842 |
.esp_irq = 18,
|
843 |
.le_irq = 16,
|
844 |
.clock_irq = 7,
|
845 |
.clock1_irq = 19,
|
846 |
.ms_kb_irq = 14,
|
847 |
.ser_irq = 15,
|
848 |
.fd_irq = 22,
|
849 |
.me_irq = 30,
|
850 |
.cs_irq = -1,
|
851 |
.ecc_irq = 28,
|
852 |
.machine_id = 0x71,
|
853 |
.iommu_version = 0x01000000,
|
854 |
.intbit_to_level = { |
855 |
2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12, |
856 |
6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0, |
857 |
}, |
858 |
.max_mem = 0xf00000000ULL,
|
859 |
.default_cpu_model = "TI SuperSparc II",
|
860 |
}, |
861 |
/* SS-20 */
|
862 |
{ |
863 |
.iommu_base = 0xfe0000000ULL,
|
864 |
.tcx_base = 0xe20000000ULL,
|
865 |
.cs_base = -1,
|
866 |
.slavio_base = 0xff0000000ULL,
|
867 |
.ms_kb_base = 0xff1000000ULL,
|
868 |
.serial_base = 0xff1100000ULL,
|
869 |
.nvram_base = 0xff1200000ULL,
|
870 |
.fd_base = 0xff1700000ULL,
|
871 |
.counter_base = 0xff1300000ULL,
|
872 |
.intctl_base = 0xff1400000ULL,
|
873 |
.idreg_base = 0xef0000000ULL,
|
874 |
.dma_base = 0xef0400000ULL,
|
875 |
.esp_base = 0xef0800000ULL,
|
876 |
.le_base = 0xef0c00000ULL,
|
877 |
.apc_base = 0xefa000000ULL, // XXX should not exist |
878 |
.aux1_base = 0xff1800000ULL,
|
879 |
.aux2_base = 0xff1a01000ULL,
|
880 |
.ecc_base = 0xf00000000ULL,
|
881 |
.ecc_version = 0x20000000, // version 0, implementation 2 |
882 |
.sun4c_intctl_base = -1,
|
883 |
.sun4c_counter_base = -1,
|
884 |
.vram_size = 0x00100000,
|
885 |
.nvram_size = 0x2000,
|
886 |
.esp_irq = 18,
|
887 |
.le_irq = 16,
|
888 |
.clock_irq = 7,
|
889 |
.clock1_irq = 19,
|
890 |
.ms_kb_irq = 14,
|
891 |
.ser_irq = 15,
|
892 |
.fd_irq = 22,
|
893 |
.me_irq = 30,
|
894 |
.cs_irq = -1,
|
895 |
.ecc_irq = 28,
|
896 |
.machine_id = 0x72,
|
897 |
.iommu_version = 0x13000000,
|
898 |
.intbit_to_level = { |
899 |
2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12, |
900 |
6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0, |
901 |
}, |
902 |
.max_mem = 0xf00000000ULL,
|
903 |
.default_cpu_model = "TI SuperSparc II",
|
904 |
}, |
905 |
/* SS-2 */
|
906 |
{ |
907 |
.iommu_base = 0xf8000000,
|
908 |
.tcx_base = 0xfe000000,
|
909 |
.cs_base = -1,
|
910 |
.slavio_base = 0xf6000000,
|
911 |
.ms_kb_base = 0xf0000000,
|
912 |
.serial_base = 0xf1000000,
|
913 |
.nvram_base = 0xf2000000,
|
914 |
.fd_base = 0xf7200000,
|
915 |
.counter_base = -1,
|
916 |
.intctl_base = -1,
|
917 |
.dma_base = 0xf8400000,
|
918 |
.esp_base = 0xf8800000,
|
919 |
.le_base = 0xf8c00000,
|
920 |
.apc_base = -1,
|
921 |
.aux1_base = 0xf7400003,
|
922 |
.aux2_base = -1,
|
923 |
.sun4c_intctl_base = 0xf5000000,
|
924 |
.sun4c_counter_base = 0xf3000000,
|
925 |
.vram_size = 0x00100000,
|
926 |
.nvram_size = 0x800,
|
927 |
.esp_irq = 2,
|
928 |
.le_irq = 3,
|
929 |
.clock_irq = 5,
|
930 |
.clock1_irq = 7,
|
931 |
.ms_kb_irq = 1,
|
932 |
.ser_irq = 1,
|
933 |
.fd_irq = 1,
|
934 |
.me_irq = 1,
|
935 |
.cs_irq = -1,
|
936 |
.machine_id = 0x55,
|
937 |
.max_mem = 0x10000000,
|
938 |
.default_cpu_model = "Cypress CY7C601",
|
939 |
}, |
940 |
/* Voyager */
|
941 |
{ |
942 |
.iommu_base = 0x10000000,
|
943 |
.tcx_base = 0x50000000,
|
944 |
.cs_base = -1,
|
945 |
.slavio_base = 0x70000000,
|
946 |
.ms_kb_base = 0x71000000,
|
947 |
.serial_base = 0x71100000,
|
948 |
.nvram_base = 0x71200000,
|
949 |
.fd_base = 0x71400000,
|
950 |
.counter_base = 0x71d00000,
|
951 |
.intctl_base = 0x71e00000,
|
952 |
.idreg_base = 0x78000000,
|
953 |
.dma_base = 0x78400000,
|
954 |
.esp_base = 0x78800000,
|
955 |
.le_base = 0x78c00000,
|
956 |
.apc_base = 0x71300000, // pmc |
957 |
.aux1_base = 0x71900000,
|
958 |
.aux2_base = 0x71910000,
|
959 |
.ecc_base = -1,
|
960 |
.sun4c_intctl_base = -1,
|
961 |
.sun4c_counter_base = -1,
|
962 |
.vram_size = 0x00100000,
|
963 |
.nvram_size = 0x2000,
|
964 |
.esp_irq = 18,
|
965 |
.le_irq = 16,
|
966 |
.clock_irq = 7,
|
967 |
.clock1_irq = 19,
|
968 |
.ms_kb_irq = 14,
|
969 |
.ser_irq = 15,
|
970 |
.fd_irq = 22,
|
971 |
.me_irq = 30,
|
972 |
.cs_irq = -1,
|
973 |
.machine_id = 0x80,
|
974 |
.iommu_version = 0x05000000,
|
975 |
.intbit_to_level = { |
976 |
2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12, |
977 |
6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0, |
978 |
}, |
979 |
.max_mem = 0x10000000,
|
980 |
.default_cpu_model = "Fujitsu MB86904",
|
981 |
}, |
982 |
/* LX */
|
983 |
{ |
984 |
.iommu_base = 0x10000000,
|
985 |
.tcx_base = 0x50000000,
|
986 |
.cs_base = -1,
|
987 |
.slavio_base = 0x70000000,
|
988 |
.ms_kb_base = 0x71000000,
|
989 |
.serial_base = 0x71100000,
|
990 |
.nvram_base = 0x71200000,
|
991 |
.fd_base = 0x71400000,
|
992 |
.counter_base = 0x71d00000,
|
993 |
.intctl_base = 0x71e00000,
|
994 |
.idreg_base = 0x78000000,
|
995 |
.dma_base = 0x78400000,
|
996 |
.esp_base = 0x78800000,
|
997 |
.le_base = 0x78c00000,
|
998 |
.apc_base = -1,
|
999 |
.aux1_base = 0x71900000,
|
1000 |
.aux2_base = 0x71910000,
|
1001 |
.ecc_base = -1,
|
1002 |
.sun4c_intctl_base = -1,
|
1003 |
.sun4c_counter_base = -1,
|
1004 |
.vram_size = 0x00100000,
|
1005 |
.nvram_size = 0x2000,
|
1006 |
.esp_irq = 18,
|
1007 |
.le_irq = 16,
|
1008 |
.clock_irq = 7,
|
1009 |
.clock1_irq = 19,
|
1010 |
.ms_kb_irq = 14,
|
1011 |
.ser_irq = 15,
|
1012 |
.fd_irq = 22,
|
1013 |
.me_irq = 30,
|
1014 |
.cs_irq = -1,
|
1015 |
.machine_id = 0x80,
|
1016 |
.iommu_version = 0x04000000,
|
1017 |
.intbit_to_level = { |
1018 |
2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12, |
1019 |
6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0, |
1020 |
}, |
1021 |
.max_mem = 0x10000000,
|
1022 |
.default_cpu_model = "TI MicroSparc I",
|
1023 |
}, |
1024 |
/* SS-4 */
|
1025 |
{ |
1026 |
.iommu_base = 0x10000000,
|
1027 |
.tcx_base = 0x50000000,
|
1028 |
.cs_base = 0x6c000000,
|
1029 |
.slavio_base = 0x70000000,
|
1030 |
.ms_kb_base = 0x71000000,
|
1031 |
.serial_base = 0x71100000,
|
1032 |
.nvram_base = 0x71200000,
|
1033 |
.fd_base = 0x71400000,
|
1034 |
.counter_base = 0x71d00000,
|
1035 |
.intctl_base = 0x71e00000,
|
1036 |
.idreg_base = 0x78000000,
|
1037 |
.dma_base = 0x78400000,
|
1038 |
.esp_base = 0x78800000,
|
1039 |
.le_base = 0x78c00000,
|
1040 |
.apc_base = 0x6a000000,
|
1041 |
.aux1_base = 0x71900000,
|
1042 |
.aux2_base = 0x71910000,
|
1043 |
.ecc_base = -1,
|
1044 |
.sun4c_intctl_base = -1,
|
1045 |
.sun4c_counter_base = -1,
|
1046 |
.vram_size = 0x00100000,
|
1047 |
.nvram_size = 0x2000,
|
1048 |
.esp_irq = 18,
|
1049 |
.le_irq = 16,
|
1050 |
.clock_irq = 7,
|
1051 |
.clock1_irq = 19,
|
1052 |
.ms_kb_irq = 14,
|
1053 |
.ser_irq = 15,
|
1054 |
.fd_irq = 22,
|
1055 |
.me_irq = 30,
|
1056 |
.cs_irq = 5,
|
1057 |
.machine_id = 0x80,
|
1058 |
.iommu_version = 0x05000000,
|
1059 |
.intbit_to_level = { |
1060 |
2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12, |
1061 |
6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0, |
1062 |
}, |
1063 |
.max_mem = 0x10000000,
|
1064 |
.default_cpu_model = "Fujitsu MB86904",
|
1065 |
}, |
1066 |
/* SPARCClassic */
|
1067 |
{ |
1068 |
.iommu_base = 0x10000000,
|
1069 |
.tcx_base = 0x50000000,
|
1070 |
.cs_base = -1,
|
1071 |
.slavio_base = 0x70000000,
|
1072 |
.ms_kb_base = 0x71000000,
|
1073 |
.serial_base = 0x71100000,
|
1074 |
.nvram_base = 0x71200000,
|
1075 |
.fd_base = 0x71400000,
|
1076 |
.counter_base = 0x71d00000,
|
1077 |
.intctl_base = 0x71e00000,
|
1078 |
.idreg_base = 0x78000000,
|
1079 |
.dma_base = 0x78400000,
|
1080 |
.esp_base = 0x78800000,
|
1081 |
.le_base = 0x78c00000,
|
1082 |
.apc_base = 0x6a000000,
|
1083 |
.aux1_base = 0x71900000,
|
1084 |
.aux2_base = 0x71910000,
|
1085 |
.ecc_base = -1,
|
1086 |
.sun4c_intctl_base = -1,
|
1087 |
.sun4c_counter_base = -1,
|
1088 |
.vram_size = 0x00100000,
|
1089 |
.nvram_size = 0x2000,
|
1090 |
.esp_irq = 18,
|
1091 |
.le_irq = 16,
|
1092 |
.clock_irq = 7,
|
1093 |
.clock1_irq = 19,
|
1094 |
.ms_kb_irq = 14,
|
1095 |
.ser_irq = 15,
|
1096 |
.fd_irq = 22,
|
1097 |
.me_irq = 30,
|
1098 |
.cs_irq = -1,
|
1099 |
.machine_id = 0x80,
|
1100 |
.iommu_version = 0x05000000,
|
1101 |
.intbit_to_level = { |
1102 |
2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12, |
1103 |
6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0, |
1104 |
}, |
1105 |
.max_mem = 0x10000000,
|
1106 |
.default_cpu_model = "TI MicroSparc I",
|
1107 |
}, |
1108 |
/* SPARCbook */
|
1109 |
{ |
1110 |
.iommu_base = 0x10000000,
|
1111 |
.tcx_base = 0x50000000, // XXX |
1112 |
.cs_base = -1,
|
1113 |
.slavio_base = 0x70000000,
|
1114 |
.ms_kb_base = 0x71000000,
|
1115 |
.serial_base = 0x71100000,
|
1116 |
.nvram_base = 0x71200000,
|
1117 |
.fd_base = 0x71400000,
|
1118 |
.counter_base = 0x71d00000,
|
1119 |
.intctl_base = 0x71e00000,
|
1120 |
.idreg_base = 0x78000000,
|
1121 |
.dma_base = 0x78400000,
|
1122 |
.esp_base = 0x78800000,
|
1123 |
.le_base = 0x78c00000,
|
1124 |
.apc_base = 0x6a000000,
|
1125 |
.aux1_base = 0x71900000,
|
1126 |
.aux2_base = 0x71910000,
|
1127 |
.ecc_base = -1,
|
1128 |
.sun4c_intctl_base = -1,
|
1129 |
.sun4c_counter_base = -1,
|
1130 |
.vram_size = 0x00100000,
|
1131 |
.nvram_size = 0x2000,
|
1132 |
.esp_irq = 18,
|
1133 |
.le_irq = 16,
|
1134 |
.clock_irq = 7,
|
1135 |
.clock1_irq = 19,
|
1136 |
.ms_kb_irq = 14,
|
1137 |
.ser_irq = 15,
|
1138 |
.fd_irq = 22,
|
1139 |
.me_irq = 30,
|
1140 |
.cs_irq = -1,
|
1141 |
.machine_id = 0x80,
|
1142 |
.iommu_version = 0x05000000,
|
1143 |
.intbit_to_level = { |
1144 |
2, 3, 5, 7, 9, 11, 0, 14, 3, 5, 7, 9, 11, 13, 12, 12, |
1145 |
6, 0, 4, 10, 8, 0, 11, 0, 0, 0, 0, 0, 15, 0, 15, 0, |
1146 |
}, |
1147 |
.max_mem = 0x10000000,
|
1148 |
.default_cpu_model = "TI MicroSparc I",
|
1149 |
}, |
1150 |
}; |
1151 |
|
1152 |
/* SPARCstation 5 hardware initialisation */
|
1153 |
static void ss5_init(ram_addr_t RAM_size, int vga_ram_size, |
1154 |
const char *boot_device, DisplayState *ds, |
1155 |
const char *kernel_filename, const char *kernel_cmdline, |
1156 |
const char *initrd_filename, const char *cpu_model) |
1157 |
{ |
1158 |
sun4m_hw_init(&hwdefs[0], RAM_size, boot_device, ds, kernel_filename,
|
1159 |
kernel_cmdline, initrd_filename, cpu_model); |
1160 |
} |
1161 |
|
1162 |
/* SPARCstation 10 hardware initialisation */
|
1163 |
static void ss10_init(ram_addr_t RAM_size, int vga_ram_size, |
1164 |
const char *boot_device, DisplayState *ds, |
1165 |
const char *kernel_filename, const char *kernel_cmdline, |
1166 |
const char *initrd_filename, const char *cpu_model) |
1167 |
{ |
1168 |
sun4m_hw_init(&hwdefs[1], RAM_size, boot_device, ds, kernel_filename,
|
1169 |
kernel_cmdline, initrd_filename, cpu_model); |
1170 |
} |
1171 |
|
1172 |
/* SPARCserver 600MP hardware initialisation */
|
1173 |
static void ss600mp_init(ram_addr_t RAM_size, int vga_ram_size, |
1174 |
const char *boot_device, DisplayState *ds, |
1175 |
const char *kernel_filename, |
1176 |
const char *kernel_cmdline, |
1177 |
const char *initrd_filename, const char *cpu_model) |
1178 |
{ |
1179 |
sun4m_hw_init(&hwdefs[2], RAM_size, boot_device, ds, kernel_filename,
|
1180 |
kernel_cmdline, initrd_filename, cpu_model); |
1181 |
} |
1182 |
|
1183 |
/* SPARCstation 20 hardware initialisation */
|
1184 |
static void ss20_init(ram_addr_t RAM_size, int vga_ram_size, |
1185 |
const char *boot_device, DisplayState *ds, |
1186 |
const char *kernel_filename, const char *kernel_cmdline, |
1187 |
const char *initrd_filename, const char *cpu_model) |
1188 |
{ |
1189 |
sun4m_hw_init(&hwdefs[3], RAM_size, boot_device, ds, kernel_filename,
|
1190 |
kernel_cmdline, initrd_filename, cpu_model); |
1191 |
} |
1192 |
|
1193 |
/* SPARCstation 2 hardware initialisation */
|
1194 |
static void ss2_init(ram_addr_t RAM_size, int vga_ram_size, |
1195 |
const char *boot_device, DisplayState *ds, |
1196 |
const char *kernel_filename, const char *kernel_cmdline, |
1197 |
const char *initrd_filename, const char *cpu_model) |
1198 |
{ |
1199 |
sun4c_hw_init(&hwdefs[4], RAM_size, boot_device, ds, kernel_filename,
|
1200 |
kernel_cmdline, initrd_filename, cpu_model); |
1201 |
} |
1202 |
|
1203 |
/* SPARCstation Voyager hardware initialisation */
|
1204 |
static void vger_init(ram_addr_t RAM_size, int vga_ram_size, |
1205 |
const char *boot_device, DisplayState *ds, |
1206 |
const char *kernel_filename, const char *kernel_cmdline, |
1207 |
const char *initrd_filename, const char *cpu_model) |
1208 |
{ |
1209 |
sun4m_hw_init(&hwdefs[5], RAM_size, boot_device, ds, kernel_filename,
|
1210 |
kernel_cmdline, initrd_filename, cpu_model); |
1211 |
} |
1212 |
|
1213 |
/* SPARCstation LX hardware initialisation */
|
1214 |
static void ss_lx_init(ram_addr_t RAM_size, int vga_ram_size, |
1215 |
const char *boot_device, DisplayState *ds, |
1216 |
const char *kernel_filename, const char *kernel_cmdline, |
1217 |
const char *initrd_filename, const char *cpu_model) |
1218 |
{ |
1219 |
sun4m_hw_init(&hwdefs[6], RAM_size, boot_device, ds, kernel_filename,
|
1220 |
kernel_cmdline, initrd_filename, cpu_model); |
1221 |
} |
1222 |
|
1223 |
/* SPARCstation 4 hardware initialisation */
|
1224 |
static void ss4_init(ram_addr_t RAM_size, int vga_ram_size, |
1225 |
const char *boot_device, DisplayState *ds, |
1226 |
const char *kernel_filename, const char *kernel_cmdline, |
1227 |
const char *initrd_filename, const char *cpu_model) |
1228 |
{ |
1229 |
sun4m_hw_init(&hwdefs[7], RAM_size, boot_device, ds, kernel_filename,
|
1230 |
kernel_cmdline, initrd_filename, cpu_model); |
1231 |
} |
1232 |
|
1233 |
/* SPARCClassic hardware initialisation */
|
1234 |
static void scls_init(ram_addr_t RAM_size, int vga_ram_size, |
1235 |
const char *boot_device, DisplayState *ds, |
1236 |
const char *kernel_filename, const char *kernel_cmdline, |
1237 |
const char *initrd_filename, const char *cpu_model) |
1238 |
{ |
1239 |
sun4m_hw_init(&hwdefs[8], RAM_size, boot_device, ds, kernel_filename,
|
1240 |
kernel_cmdline, initrd_filename, cpu_model); |
1241 |
} |
1242 |
|
1243 |
/* SPARCbook hardware initialisation */
|
1244 |
static void sbook_init(ram_addr_t RAM_size, int vga_ram_size, |
1245 |
const char *boot_device, DisplayState *ds, |
1246 |
const char *kernel_filename, const char *kernel_cmdline, |
1247 |
const char *initrd_filename, const char *cpu_model) |
1248 |
{ |
1249 |
sun4m_hw_init(&hwdefs[9], RAM_size, boot_device, ds, kernel_filename,
|
1250 |
kernel_cmdline, initrd_filename, cpu_model); |
1251 |
} |
1252 |
|
1253 |
QEMUMachine ss5_machine = { |
1254 |
.name = "SS-5",
|
1255 |
.desc = "Sun4m platform, SPARCstation 5",
|
1256 |
.init = ss5_init, |
1257 |
.ram_require = PROM_SIZE_MAX + TCX_SIZE, |
1258 |
.nodisk_ok = 1,
|
1259 |
}; |
1260 |
|
1261 |
QEMUMachine ss10_machine = { |
1262 |
.name = "SS-10",
|
1263 |
.desc = "Sun4m platform, SPARCstation 10",
|
1264 |
.init = ss10_init, |
1265 |
.ram_require = PROM_SIZE_MAX + TCX_SIZE, |
1266 |
.nodisk_ok = 1,
|
1267 |
}; |
1268 |
|
1269 |
QEMUMachine ss600mp_machine = { |
1270 |
.name = "SS-600MP",
|
1271 |
.desc = "Sun4m platform, SPARCserver 600MP",
|
1272 |
.init = ss600mp_init, |
1273 |
.ram_require = PROM_SIZE_MAX + TCX_SIZE, |
1274 |
.nodisk_ok = 1,
|
1275 |
}; |
1276 |
|
1277 |
QEMUMachine ss20_machine = { |
1278 |
.name = "SS-20",
|
1279 |
.desc = "Sun4m platform, SPARCstation 20",
|
1280 |
.init = ss20_init, |
1281 |
.ram_require = PROM_SIZE_MAX + TCX_SIZE, |
1282 |
.nodisk_ok = 1,
|
1283 |
}; |
1284 |
|
1285 |
QEMUMachine ss2_machine = { |
1286 |
.name = "SS-2",
|
1287 |
.desc = "Sun4c platform, SPARCstation 2",
|
1288 |
.init = ss2_init, |
1289 |
.ram_require = PROM_SIZE_MAX + TCX_SIZE, |
1290 |
.nodisk_ok = 1,
|
1291 |
}; |
1292 |
|
1293 |
QEMUMachine voyager_machine = { |
1294 |
.name = "Voyager",
|
1295 |
.desc = "Sun4m platform, SPARCstation Voyager",
|
1296 |
.init = vger_init, |
1297 |
.ram_require = PROM_SIZE_MAX + TCX_SIZE, |
1298 |
.nodisk_ok = 1,
|
1299 |
}; |
1300 |
|
1301 |
QEMUMachine ss_lx_machine = { |
1302 |
.name = "LX",
|
1303 |
.desc = "Sun4m platform, SPARCstation LX",
|
1304 |
.init = ss_lx_init, |
1305 |
.ram_require = PROM_SIZE_MAX + TCX_SIZE, |
1306 |
.nodisk_ok = 1,
|
1307 |
}; |
1308 |
|
1309 |
QEMUMachine ss4_machine = { |
1310 |
.name = "SS-4",
|
1311 |
.desc = "Sun4m platform, SPARCstation 4",
|
1312 |
.init = ss4_init, |
1313 |
.ram_require = PROM_SIZE_MAX + TCX_SIZE, |
1314 |
.nodisk_ok = 1,
|
1315 |
}; |
1316 |
|
1317 |
QEMUMachine scls_machine = { |
1318 |
.name = "SPARCClassic",
|
1319 |
.desc = "Sun4m platform, SPARCClassic",
|
1320 |
.init = scls_init, |
1321 |
.ram_require = PROM_SIZE_MAX + TCX_SIZE, |
1322 |
.nodisk_ok = 1,
|
1323 |
}; |
1324 |
|
1325 |
QEMUMachine sbook_machine = { |
1326 |
.name = "SPARCbook",
|
1327 |
.desc = "Sun4m platform, SPARCbook",
|
1328 |
.init = sbook_init, |
1329 |
.ram_require = PROM_SIZE_MAX + TCX_SIZE, |
1330 |
.nodisk_ok = 1,
|
1331 |
}; |
1332 |
|
1333 |
static const struct sun4d_hwdef sun4d_hwdefs[] = { |
1334 |
/* SS-1000 */
|
1335 |
{ |
1336 |
.iounit_bases = { |
1337 |
0xfe0200000ULL,
|
1338 |
0xfe1200000ULL,
|
1339 |
0xfe2200000ULL,
|
1340 |
0xfe3200000ULL,
|
1341 |
-1,
|
1342 |
}, |
1343 |
.tcx_base = 0x820000000ULL,
|
1344 |
.slavio_base = 0xf00000000ULL,
|
1345 |
.ms_kb_base = 0xf00240000ULL,
|
1346 |
.serial_base = 0xf00200000ULL,
|
1347 |
.nvram_base = 0xf00280000ULL,
|
1348 |
.counter_base = 0xf00300000ULL,
|
1349 |
.espdma_base = 0x800081000ULL,
|
1350 |
.esp_base = 0x800080000ULL,
|
1351 |
.ledma_base = 0x800040000ULL,
|
1352 |
.le_base = 0x800060000ULL,
|
1353 |
.sbi_base = 0xf02800000ULL,
|
1354 |
.vram_size = 0x00100000,
|
1355 |
.nvram_size = 0x2000,
|
1356 |
.esp_irq = 3,
|
1357 |
.le_irq = 4,
|
1358 |
.clock_irq = 14,
|
1359 |
.clock1_irq = 10,
|
1360 |
.ms_kb_irq = 12,
|
1361 |
.ser_irq = 12,
|
1362 |
.machine_id = 0x80,
|
1363 |
.iounit_version = 0x03000000,
|
1364 |
.max_mem = 0xf00000000ULL,
|
1365 |
.default_cpu_model = "TI SuperSparc II",
|
1366 |
}, |
1367 |
/* SS-2000 */
|
1368 |
{ |
1369 |
.iounit_bases = { |
1370 |
0xfe0200000ULL,
|
1371 |
0xfe1200000ULL,
|
1372 |
0xfe2200000ULL,
|
1373 |
0xfe3200000ULL,
|
1374 |
0xfe4200000ULL,
|
1375 |
}, |
1376 |
.tcx_base = 0x820000000ULL,
|
1377 |
.slavio_base = 0xf00000000ULL,
|
1378 |
.ms_kb_base = 0xf00240000ULL,
|
1379 |
.serial_base = 0xf00200000ULL,
|
1380 |
.nvram_base = 0xf00280000ULL,
|
1381 |
.counter_base = 0xf00300000ULL,
|
1382 |
.espdma_base = 0x800081000ULL,
|
1383 |
.esp_base = 0x800080000ULL,
|
1384 |
.ledma_base = 0x800040000ULL,
|
1385 |
.le_base = 0x800060000ULL,
|
1386 |
.sbi_base = 0xf02800000ULL,
|
1387 |
.vram_size = 0x00100000,
|
1388 |
.nvram_size = 0x2000,
|
1389 |
.esp_irq = 3,
|
1390 |
.le_irq = 4,
|
1391 |
.clock_irq = 14,
|
1392 |
.clock1_irq = 10,
|
1393 |
.ms_kb_irq = 12,
|
1394 |
.ser_irq = 12,
|
1395 |
.machine_id = 0x80,
|
1396 |
.iounit_version = 0x03000000,
|
1397 |
.max_mem = 0xf00000000ULL,
|
1398 |
.default_cpu_model = "TI SuperSparc II",
|
1399 |
}, |
1400 |
}; |
1401 |
|
1402 |
static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size, |
1403 |
const char *boot_device, |
1404 |
DisplayState *ds, const char *kernel_filename, |
1405 |
const char *kernel_cmdline, |
1406 |
const char *initrd_filename, const char *cpu_model) |
1407 |
{ |
1408 |
CPUState *env, *envs[MAX_CPUS]; |
1409 |
unsigned int i; |
1410 |
void *iounits[MAX_IOUNITS], *espdma, *ledma, *main_esp, *nvram, *sbi;
|
1411 |
qemu_irq *cpu_irqs[MAX_CPUS], *sbi_irq, *sbi_cpu_irq, |
1412 |
*espdma_irq, *ledma_irq; |
1413 |
qemu_irq *esp_reset, *le_reset; |
1414 |
unsigned long prom_offset, kernel_size; |
1415 |
int ret;
|
1416 |
char buf[1024]; |
1417 |
int drive_index;
|
1418 |
void *fw_cfg;
|
1419 |
|
1420 |
/* init CPUs */
|
1421 |
if (!cpu_model)
|
1422 |
cpu_model = hwdef->default_cpu_model; |
1423 |
|
1424 |
for (i = 0; i < smp_cpus; i++) { |
1425 |
env = cpu_init(cpu_model); |
1426 |
if (!env) {
|
1427 |
fprintf(stderr, "qemu: Unable to find Sparc CPU definition\n");
|
1428 |
exit(1);
|
1429 |
} |
1430 |
cpu_sparc_set_id(env, i); |
1431 |
envs[i] = env; |
1432 |
if (i == 0) { |
1433 |
qemu_register_reset(main_cpu_reset, env); |
1434 |
} else {
|
1435 |
qemu_register_reset(secondary_cpu_reset, env); |
1436 |
env->halted = 1;
|
1437 |
} |
1438 |
cpu_irqs[i] = qemu_allocate_irqs(cpu_set_irq, envs[i], MAX_PILS); |
1439 |
env->prom_addr = hwdef->slavio_base; |
1440 |
} |
1441 |
|
1442 |
for (i = smp_cpus; i < MAX_CPUS; i++)
|
1443 |
cpu_irqs[i] = qemu_allocate_irqs(dummy_cpu_set_irq, NULL, MAX_PILS);
|
1444 |
|
1445 |
/* allocate RAM */
|
1446 |
if ((uint64_t)RAM_size > hwdef->max_mem) {
|
1447 |
fprintf(stderr, |
1448 |
"qemu: Too much memory for this machine: %d, maximum %d\n",
|
1449 |
(unsigned int)(RAM_size / (1024 * 1024)), |
1450 |
(unsigned int)(hwdef->max_mem / (1024 * 1024))); |
1451 |
exit(1);
|
1452 |
} |
1453 |
cpu_register_physical_memory(0, RAM_size, 0); |
1454 |
|
1455 |
/* load boot prom */
|
1456 |
prom_offset = RAM_size + hwdef->vram_size; |
1457 |
cpu_register_physical_memory(hwdef->slavio_base, |
1458 |
(PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) &
|
1459 |
TARGET_PAGE_MASK, |
1460 |
prom_offset | IO_MEM_ROM); |
1461 |
|
1462 |
if (bios_name == NULL) |
1463 |
bios_name = PROM_FILENAME; |
1464 |
snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); |
1465 |
ret = load_elf(buf, hwdef->slavio_base - PROM_VADDR, NULL, NULL, NULL); |
1466 |
if (ret < 0 || ret > PROM_SIZE_MAX) |
1467 |
ret = load_image_targphys(buf, hwdef->slavio_base, PROM_SIZE_MAX); |
1468 |
if (ret < 0 || ret > PROM_SIZE_MAX) { |
1469 |
fprintf(stderr, "qemu: could not load prom '%s'\n",
|
1470 |
buf); |
1471 |
exit(1);
|
1472 |
} |
1473 |
|
1474 |
/* set up devices */
|
1475 |
sbi = sbi_init(hwdef->sbi_base, &sbi_irq, &sbi_cpu_irq, cpu_irqs); |
1476 |
|
1477 |
for (i = 0; i < MAX_IOUNITS; i++) |
1478 |
if (hwdef->iounit_bases[i] != (target_phys_addr_t)-1) |
1479 |
iounits[i] = iommu_init(hwdef->iounit_bases[i], |
1480 |
hwdef->iounit_version, |
1481 |
sbi_irq[hwdef->me_irq]); |
1482 |
|
1483 |
espdma = sparc32_dma_init(hwdef->espdma_base, sbi_irq[hwdef->esp_irq], |
1484 |
iounits[0], &espdma_irq, &esp_reset);
|
1485 |
|
1486 |
ledma = sparc32_dma_init(hwdef->ledma_base, sbi_irq[hwdef->le_irq], |
1487 |
iounits[0], &ledma_irq, &le_reset);
|
1488 |
|
1489 |
if (graphic_depth != 8 && graphic_depth != 24) { |
1490 |
fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth);
|
1491 |
exit (1);
|
1492 |
} |
1493 |
tcx_init(ds, hwdef->tcx_base, phys_ram_base + RAM_size, RAM_size, |
1494 |
hwdef->vram_size, graphic_width, graphic_height, graphic_depth); |
1495 |
|
1496 |
if (nd_table[0].model == NULL |
1497 |
|| strcmp(nd_table[0].model, "lance") == 0) { |
1498 |
lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
|
1499 |
} else if (strcmp(nd_table[0].model, "?") == 0) { |
1500 |
fprintf(stderr, "qemu: Supported NICs: lance\n");
|
1501 |
exit (1);
|
1502 |
} else {
|
1503 |
fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model); |
1504 |
exit (1);
|
1505 |
} |
1506 |
|
1507 |
nvram = m48t59_init(sbi_irq[0], hwdef->nvram_base, 0, |
1508 |
hwdef->nvram_size, 8);
|
1509 |
|
1510 |
slavio_timer_init_all(hwdef->counter_base, sbi_irq[hwdef->clock1_irq], |
1511 |
sbi_cpu_irq, smp_cpus); |
1512 |
|
1513 |
slavio_serial_ms_kbd_init(hwdef->ms_kb_base, sbi_irq[hwdef->ms_kb_irq], |
1514 |
nographic); |
1515 |
// Slavio TTYA (base+4, Linux ttyS0) is the first Qemu serial device
|
1516 |
// Slavio TTYB (base+0, Linux ttyS1) is the second Qemu serial device
|
1517 |
slavio_serial_init(hwdef->serial_base, sbi_irq[hwdef->ser_irq], |
1518 |
serial_hds[1], serial_hds[0]); |
1519 |
|
1520 |
if (drive_get_max_bus(IF_SCSI) > 0) { |
1521 |
fprintf(stderr, "qemu: too many SCSI bus\n");
|
1522 |
exit(1);
|
1523 |
} |
1524 |
|
1525 |
main_esp = esp_init(hwdef->esp_base, 2,
|
1526 |
espdma_memory_read, espdma_memory_write, |
1527 |
espdma, *espdma_irq, esp_reset); |
1528 |
|
1529 |
for (i = 0; i < ESP_MAX_DEVS; i++) { |
1530 |
drive_index = drive_get_index(IF_SCSI, 0, i);
|
1531 |
if (drive_index == -1) |
1532 |
continue;
|
1533 |
esp_scsi_attach(main_esp, drives_table[drive_index].bdrv, i); |
1534 |
} |
1535 |
|
1536 |
kernel_size = sun4m_load_kernel(kernel_filename, initrd_filename, |
1537 |
RAM_size); |
1538 |
|
1539 |
nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
|
1540 |
boot_device, RAM_size, kernel_size, graphic_width, |
1541 |
graphic_height, graphic_depth, hwdef->machine_id, "Sun4d");
|
1542 |
|
1543 |
fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2); |
1544 |
fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
|
1545 |
} |
1546 |
|
1547 |
/* SPARCserver 1000 hardware initialisation */
|
1548 |
static void ss1000_init(ram_addr_t RAM_size, int vga_ram_size, |
1549 |
const char *boot_device, DisplayState *ds, |
1550 |
const char *kernel_filename, const char *kernel_cmdline, |
1551 |
const char *initrd_filename, const char *cpu_model) |
1552 |
{ |
1553 |
sun4d_hw_init(&sun4d_hwdefs[0], RAM_size, boot_device, ds, kernel_filename,
|
1554 |
kernel_cmdline, initrd_filename, cpu_model); |
1555 |
} |
1556 |
|
1557 |
/* SPARCcenter 2000 hardware initialisation */
|
1558 |
static void ss2000_init(ram_addr_t RAM_size, int vga_ram_size, |
1559 |
const char *boot_device, DisplayState *ds, |
1560 |
const char *kernel_filename, const char *kernel_cmdline, |
1561 |
const char *initrd_filename, const char *cpu_model) |
1562 |
{ |
1563 |
sun4d_hw_init(&sun4d_hwdefs[1], RAM_size, boot_device, ds, kernel_filename,
|
1564 |
kernel_cmdline, initrd_filename, cpu_model); |
1565 |
} |
1566 |
|
1567 |
QEMUMachine ss1000_machine = { |
1568 |
.name = "SS-1000",
|
1569 |
.desc = "Sun4d platform, SPARCserver 1000",
|
1570 |
.init = ss1000_init, |
1571 |
.ram_require = PROM_SIZE_MAX + TCX_SIZE, |
1572 |
.nodisk_ok = 1,
|
1573 |
}; |
1574 |
|
1575 |
QEMUMachine ss2000_machine = { |
1576 |
.name = "SS-2000",
|
1577 |
.desc = "Sun4d platform, SPARCcenter 2000",
|
1578 |
.init = ss2000_init, |
1579 |
.ram_require = PROM_SIZE_MAX + TCX_SIZE, |
1580 |
.nodisk_ok = 1,
|
1581 |
}; |