1 |
/* |
2 |
* Copyright (C) 2003-2006 Anders Gavare. All rights reserved. |
3 |
* |
4 |
* Redistribution and use in source and binary forms, with or without |
5 |
* modification, are permitted provided that the following conditions are met: |
6 |
* |
7 |
* 1. Redistributions of source code must retain the above copyright |
8 |
* notice, this list of conditions and the following disclaimer. |
9 |
* 2. Redistributions in binary form must reproduce the above copyright |
10 |
* notice, this list of conditions and the following disclaimer in the |
11 |
* documentation and/or other materials provided with the distribution. |
12 |
* 3. The name of the author may not be used to endorse or promote products |
13 |
* derived from this software without specific prior written permission. |
14 |
* |
15 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
16 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
18 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
19 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
20 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
21 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
22 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
23 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
24 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
25 |
* SUCH DAMAGE. |
26 |
* |
27 |
* |
28 |
* $Id: machine_arc.c,v 1.2 2006/02/03 17:25:14 debug Exp $ |
29 |
*/ |
30 |
|
31 |
#include <stdio.h> |
32 |
#include <stdlib.h> |
33 |
#include <string.h> |
34 |
|
35 |
#include "arcbios.h" |
36 |
#include "bus_isa.h" |
37 |
#include "cpu.h" |
38 |
#include "device.h" |
39 |
#include "devices.h" |
40 |
#include "machine.h" |
41 |
#include "machine_interrupts.h" |
42 |
#include "memory.h" |
43 |
#include "misc.h" |
44 |
|
45 |
|
46 |
MACHINE_SETUP(arc) |
47 |
{ |
48 |
struct pci_data *pci_data; |
49 |
struct memory *mem = machine->memory; |
50 |
char tmpstr[1000]; |
51 |
int i, j; |
52 |
char *eaddr_string = "eaddr=10:20:30:40:50:60"; /* bogus */ |
53 |
unsigned char macaddr[6]; |
54 |
|
55 |
machine->machine_name = malloc(MACHINE_NAME_MAXBUF); |
56 |
if (machine->machine_name == NULL) { |
57 |
fprintf(stderr, "out of memory\n"); |
58 |
exit(1); |
59 |
} |
60 |
|
61 |
cpu->byte_order = EMUL_LITTLE_ENDIAN; |
62 |
snprintf(machine->machine_name, |
63 |
MACHINE_NAME_MAXBUF, "ARC"); |
64 |
|
65 |
switch (machine->machine_subtype) { |
66 |
|
67 |
case MACHINE_ARC_NEC_RD94: |
68 |
case MACHINE_ARC_NEC_R94: |
69 |
case MACHINE_ARC_NEC_R96: |
70 |
/* |
71 |
* "NEC-RD94" (NEC RISCstation 2250) |
72 |
* "NEC-R94" (NEC RISCstation 2200) |
73 |
* "NEC-R96" (NEC Express RISCserver) |
74 |
* |
75 |
* http://mirror.aarnet.edu.au/pub/NetBSD/misc/chs/arcdiag.out |
76 |
* (NEC-R96) |
77 |
*/ |
78 |
|
79 |
switch (machine->machine_subtype) { |
80 |
case MACHINE_ARC_NEC_RD94: |
81 |
strlcat(machine->machine_name, |
82 |
" (NEC-RD94, NEC RISCstation 2250)", |
83 |
MACHINE_NAME_MAXBUF); |
84 |
break; |
85 |
case MACHINE_ARC_NEC_R94: |
86 |
strlcat(machine->machine_name, " (NEC-R94; NEC RISCstation 2200)", |
87 |
MACHINE_NAME_MAXBUF); |
88 |
break; |
89 |
case MACHINE_ARC_NEC_R96: |
90 |
strlcat(machine->machine_name, " (NEC-R96; NEC Express RISCserver)", |
91 |
MACHINE_NAME_MAXBUF); |
92 |
break; |
93 |
} |
94 |
|
95 |
/* TODO: interrupt controller! */ |
96 |
|
97 |
pci_data = device_add(machine, |
98 |
"rd94 addr=0x80000000, irq=0"); |
99 |
|
100 |
device_add(machine, "sn addr=0x80001000 irq=0"); |
101 |
dev_mc146818_init(machine, mem, 0x80004000ULL, 0, |
102 |
MC146818_ARC_NEC, 1); |
103 |
i = dev_pckbc_init(machine, mem, 0x80005000ULL, PCKBC_8042, |
104 |
0, 0, machine->use_x11, 0); |
105 |
|
106 |
snprintf(tmpstr, sizeof(tmpstr), |
107 |
"ns16550 irq=3 addr=0x80006000 in_use=%i name2=tty0", |
108 |
machine->use_x11? 0 : 1); |
109 |
j = (size_t)device_add(machine, tmpstr); |
110 |
snprintf(tmpstr, sizeof(tmpstr), |
111 |
"ns16550 irq=0 addr=0x80007000 in_use=%i name2=tty1", 0); |
112 |
device_add(machine, tmpstr); |
113 |
|
114 |
if (machine->use_x11) |
115 |
machine->main_console_handle = i; |
116 |
else |
117 |
machine->main_console_handle = j; |
118 |
|
119 |
/* lpt at 0x80008000 */ |
120 |
|
121 |
device_add(machine, "fdc addr=0x8000c000, irq=0"); |
122 |
|
123 |
switch (machine->machine_subtype) { |
124 |
case MACHINE_ARC_NEC_RD94: |
125 |
case MACHINE_ARC_NEC_R94: |
126 |
/* PCI devices: (NOTE: bus must be 0, device must be |
127 |
3, 4, or 5, for NetBSD to accept interrupts) */ |
128 |
bus_pci_add(machine, pci_data, mem, 0, 3, 0, |
129 |
"dec21030"); /* tga graphics */ |
130 |
break; |
131 |
case MACHINE_ARC_NEC_R96: |
132 |
dev_fb_init(machine, mem, 0x100e00000ULL, |
133 |
VFB_GENERIC, 640,480, 1024,480, |
134 |
8, "necvdfrb"); |
135 |
break; |
136 |
} |
137 |
break; |
138 |
|
139 |
case MACHINE_ARC_NEC_R98: |
140 |
/* |
141 |
* "NEC-R98" (NEC RISCserver 4200) |
142 |
* |
143 |
* According to http://mail-index.netbsd.org/port-arc/ |
144 |
* 2004/02/01/0001.html: |
145 |
* |
146 |
* Network adapter at "start: 0x 0 18600000, length: 0x1000, level: 4, vector: 9" |
147 |
* Disk at "start: 0x 0 18c103f0, length: 0x1000, level: 5, vector: 6" |
148 |
* Keyboard at "start: 0x 0 18c20060, length: 0x1000, level: 5, vector: 3" |
149 |
* Serial at "start: 0x 0 18c103f8, length: 0x1000, level: 5, vector: 4" |
150 |
* Serial at "start: 0x 0 18c102f8, length: 0x1000, level: 5, vector: 4" |
151 |
* Parallel at "start: 0x 0 18c10278, length: 0x1000, level: 5, vector: 5" |
152 |
*/ |
153 |
|
154 |
strlcat(machine->machine_name, |
155 |
" (NEC-R98; NEC RISCserver 4200)", MACHINE_NAME_MAXBUF); |
156 |
|
157 |
/* |
158 |
* Windows NT access stuff at these addresses: |
159 |
* |
160 |
* 19980308, 18000210, 18c0a008, |
161 |
* 19022018, 19026010, andso on. |
162 |
*/ |
163 |
break; |
164 |
|
165 |
case MACHINE_ARC_JAZZ_PICA: |
166 |
case MACHINE_ARC_JAZZ_MAGNUM: |
167 |
/* |
168 |
* "PICA-61" |
169 |
* |
170 |
* According to NetBSD 1.6.2: |
171 |
* |
172 |
* jazzio0 at mainbus0 |
173 |
* timer0 at jazzio0 addr 0xe0000228 |
174 |
* mcclock0 at jazzio0 addr 0xe0004000: mc146818 or compatible |
175 |
* lpt at jazzio0 addr 0xe0008000 intr 0 not configured |
176 |
* fdc at jazzio0 addr 0xe0003000 intr 1 not configured |
177 |
* MAGNUM at jazzio0 addr 0xe000c000 intr 2 not configured |
178 |
* ALI_S3 at jazzio0 addr 0xe0800000 intr 3 not configured |
179 |
* sn0 at jazzio0 addr 0xe0001000 intr 4: SONIC Ethernet |
180 |
* sn0: Ethernet address 69:6a:6b:6c:00:00 |
181 |
* asc0 at jazzio0 addr 0xe0002000 intr 5: NCR53C94, target 0 |
182 |
* pckbd at jazzio0 addr 0xe0005000 intr 6 not configured |
183 |
* pms at jazzio0 addr 0xe0005000 intr 7 not configured |
184 |
* com0 at jazzio0 addr 0xe0006000 intr 8: ns16550a, working fifo |
185 |
* com at jazzio0 addr 0xe0007000 intr 9 not configured |
186 |
* jazzisabr0 at mainbus0 |
187 |
* isa0 at jazzisabr0 isa_io_base 0xe2000000 isa_mem_base 0xe3000000 |
188 |
* |
189 |
* "Microsoft-Jazz", "MIPS Magnum" |
190 |
* |
191 |
* timer0 at jazzio0 addr 0xe0000228 |
192 |
* mcclock0 at jazzio0 addr 0xe0004000: mc146818 or compatible |
193 |
* lpt at jazzio0 addr 0xe0008000 intr 0 not configured |
194 |
* fdc at jazzio0 addr 0xe0003000 intr 1 not configured |
195 |
* MAGNUM at jazzio0 addr 0xe000c000 intr 2 not configured |
196 |
* VXL at jazzio0 addr 0xe0800000 intr 3 not configured |
197 |
* sn0 at jazzio0 addr 0xe0001000 intr 4: SONIC Ethernet |
198 |
* sn0: Ethernet address 69:6a:6b:6c:00:00 |
199 |
* asc0 at jazzio0 addr 0xe0002000 intr 5: NCR53C94, target 0 |
200 |
* scsibus0 at asc0: 8 targets, 8 luns per target |
201 |
* pckbd at jazzio0 addr 0xe0005000 intr 6 not configured |
202 |
* pms at jazzio0 addr 0xe0005000 intr 7 not configured |
203 |
* com0 at jazzio0 addr 0xe0006000 intr 8: ns16550a, working fifo |
204 |
* com at jazzio0 addr 0xe0007000 intr 9 not configured |
205 |
* jazzisabr0 at mainbus0 |
206 |
* isa0 at jazzisabr0 isa_io_base 0xe2000000 isa_mem_base 0xe3000000 |
207 |
*/ |
208 |
|
209 |
switch (machine->machine_subtype) { |
210 |
case MACHINE_ARC_JAZZ_PICA: |
211 |
strlcat(machine->machine_name, " (Microsoft Jazz, Acer PICA-61)", |
212 |
MACHINE_NAME_MAXBUF); |
213 |
machine->stable = 1; |
214 |
break; |
215 |
case MACHINE_ARC_JAZZ_MAGNUM: |
216 |
strlcat(machine->machine_name, " (Microsoft Jazz, MIPS Magnum)", |
217 |
MACHINE_NAME_MAXBUF); |
218 |
break; |
219 |
default: |
220 |
fatal("error in machine.c. jazz\n"); |
221 |
exit(1); |
222 |
} |
223 |
|
224 |
machine->md_int.jazz_data = device_add(machine, |
225 |
"jazz addr=0x80000000"); |
226 |
machine->md_interrupt = jazz_interrupt; |
227 |
|
228 |
i = dev_pckbc_init(machine, mem, 0x80005000ULL, |
229 |
PCKBC_JAZZ, 8 + 6, 8 + 7, machine->use_x11, 0); |
230 |
|
231 |
snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=16 addr=0x80006000 in_use=%i name2=tty0", machine->use_x11? 0 : 1); |
232 |
j = (size_t)device_add(machine, tmpstr); |
233 |
snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=17 addr=0x80007000 in_use=%i name2=tty1", 0); |
234 |
device_add(machine, tmpstr); |
235 |
|
236 |
if (machine->use_x11) |
237 |
machine->main_console_handle = i; |
238 |
else |
239 |
machine->main_console_handle = j; |
240 |
|
241 |
switch (machine->machine_subtype) { |
242 |
case MACHINE_ARC_JAZZ_PICA: |
243 |
if (machine->use_x11) { |
244 |
dev_vga_init(machine, mem, |
245 |
0x400a0000ULL, 0x600003c0ULL, |
246 |
machine->machine_name); |
247 |
arcbios_console_init(machine, |
248 |
0x400b8000ULL, 0x600003c0ULL); |
249 |
} |
250 |
break; |
251 |
case MACHINE_ARC_JAZZ_MAGNUM: |
252 |
/* PROM mirror? */ |
253 |
dev_ram_init(machine, 0xfff00000, 0x100000, |
254 |
DEV_RAM_MIRROR | DEV_RAM_MIGHT_POINT_TO_DEVICES, 0x1fc00000); |
255 |
|
256 |
/* VXL. TODO */ |
257 |
/* control at 0x60100000? */ |
258 |
dev_fb_init(machine, mem, 0x60200000ULL, |
259 |
VFB_GENERIC, 1024,768, 1024,768, |
260 |
8, "VXL"); |
261 |
break; |
262 |
} |
263 |
|
264 |
/* irq 8 + 4 */ |
265 |
device_add(machine, "sn addr=0x80001000 irq=12"); |
266 |
|
267 |
dev_asc_init(machine, mem, |
268 |
0x80002000ULL, 8 + 5, NULL, DEV_ASC_PICA, |
269 |
dev_jazz_dma_controller, |
270 |
machine->md_int.jazz_data); |
271 |
|
272 |
device_add(machine, "fdc addr=0x80003000, irq=0"); |
273 |
|
274 |
dev_mc146818_init(machine, mem, |
275 |
0x80004000ULL, 2, MC146818_ARC_JAZZ, 1); |
276 |
|
277 |
#if 0 |
278 |
Not yet. |
279 |
/* irq = 8+16 + 14 */ |
280 |
device_add(machine, "wdc addr=0x900001f0, irq=38"); |
281 |
#endif |
282 |
|
283 |
break; |
284 |
|
285 |
case MACHINE_ARC_JAZZ_M700: |
286 |
/* |
287 |
* "Microsoft-Jazz", "Olivetti M700" |
288 |
* |
289 |
* Different enough from Pica and Magnum to be |
290 |
* separate here. |
291 |
* |
292 |
* See http://mail-index.netbsd.org/port-arc/2000/10/18/0001.html. |
293 |
*/ |
294 |
|
295 |
strlcat(machine->machine_name, " (Microsoft Jazz, Olivetti M700)", |
296 |
MACHINE_NAME_MAXBUF); |
297 |
|
298 |
machine->md_int.jazz_data = device_add(machine, |
299 |
"jazz addr=0x80000000"); |
300 |
machine->md_interrupt = jazz_interrupt; |
301 |
|
302 |
dev_mc146818_init(machine, mem, |
303 |
0x80004000ULL, 2, MC146818_ARC_JAZZ, 1); |
304 |
|
305 |
i = 0; /* TODO: Yuck! */ |
306 |
#if 0 |
307 |
i = dev_pckbc_init(machine, mem, 0x80005000ULL, |
308 |
PCKBC_JAZZ, 8 + 6, 8 + 7, machine->use_x11, 0); |
309 |
#endif |
310 |
|
311 |
snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=16 addr=0x80006000 in_use=%i name2=tty0", machine->use_x11? 0 : 1); |
312 |
j = (size_t)device_add(machine, tmpstr); |
313 |
snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=17 addr=0x80007000 in_use=%i name2=tty1", 0); |
314 |
device_add(machine, tmpstr); |
315 |
|
316 |
if (machine->use_x11) |
317 |
machine->main_console_handle = i; |
318 |
else |
319 |
machine->main_console_handle = j; |
320 |
|
321 |
dev_m700_fb_init(machine, mem, |
322 |
0x180080000ULL, 0x100000000ULL); |
323 |
|
324 |
break; |
325 |
|
326 |
case MACHINE_ARC_DESKTECH_TYNE: |
327 |
/* |
328 |
* "Deskstation Tyne" (?) |
329 |
* |
330 |
* TODO |
331 |
* http://mail-index.netbsd.org/port-arc/2000/10/14/0000.html |
332 |
*/ |
333 |
|
334 |
strlcat(machine->machine_name, " (Deskstation Tyne)", |
335 |
MACHINE_NAME_MAXBUF); |
336 |
|
337 |
/* TODO: IRQs! */ |
338 |
bus_isa_init(machine, 0, 0x900000000ULL, |
339 |
0x100000000ULL, 8, 24); |
340 |
#if 0 |
341 |
snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x9000003f8 in_use=%i name2=tty0", machine->use_x11? 0 : 1); |
342 |
i = (size_t)device_add(machine, tmpstr); |
343 |
device_add(machine, "ns16550 irq=0 addr=0x9000002f8 in_use=0 name2=tty1"); |
344 |
#endif |
345 |
device_add(machine, "ns16550 irq=0 addr=0x9000003e8 in_use=0 name2=tty2"); |
346 |
device_add(machine, "ns16550 irq=0 addr=0x9000002e8 in_use=0 name2=tty3"); |
347 |
#if 0 |
348 |
dev_mc146818_init(machine, mem, |
349 |
0x900000070ULL, 2, MC146818_PC_CMOS, 1); |
350 |
/* TODO: irq, etc */ |
351 |
device_add(machine, "wdc addr=0x9000001f0, irq=0"); |
352 |
device_add(machine, "wdc addr=0x900000170, irq=0"); |
353 |
|
354 |
/* PC kbd */ |
355 |
j = dev_pckbc_init(machine, mem, 0x900000060ULL, |
356 |
PCKBC_8042, 0, 0, machine->use_x11, 0); |
357 |
|
358 |
if (machine->use_x11) |
359 |
machine->main_console_handle = j; |
360 |
else |
361 |
machine->main_console_handle = i; |
362 |
#endif |
363 |
|
364 |
if (machine->use_x11) { |
365 |
dev_vga_init(machine, mem, 0x1000a0000ULL, |
366 |
0x9000003c0ULL, machine->machine_name); |
367 |
arcbios_console_init(machine, |
368 |
0x1000b8000ULL, 0x9000003c0ULL); |
369 |
} |
370 |
break; |
371 |
|
372 |
default:fatal("Unimplemented ARC machine type %i\n", |
373 |
machine->machine_subtype); |
374 |
exit(1); |
375 |
} |
376 |
|
377 |
/* |
378 |
* NOTE: ARCBIOS shouldn't be used before this point. (The only |
379 |
* exception is that arcbios_console_init() may be called.) |
380 |
*/ |
381 |
|
382 |
if (!machine->prom_emulation) |
383 |
return; |
384 |
|
385 |
arcbios_init(machine, 0, 0, eaddr_string, macaddr); |
386 |
} |
387 |
|
388 |
|
389 |
MACHINE_DEFAULT_CPU(arc) |
390 |
{ |
391 |
switch (machine->machine_subtype) { |
392 |
case MACHINE_ARC_JAZZ_PICA: |
393 |
machine->cpu_name = strdup("R4000"); |
394 |
break; |
395 |
default: |
396 |
machine->cpu_name = strdup("R4400"); |
397 |
} |
398 |
} |
399 |
|
400 |
|
401 |
MACHINE_DEFAULT_RAM(arc) |
402 |
{ |
403 |
machine->physical_ram_in_mb = 64; |
404 |
} |
405 |
|
406 |
|
407 |
MACHINE_REGISTER(arc) |
408 |
{ |
409 |
MR_DEFAULT(arc, "ARC", ARCH_MIPS, MACHINE_ARC, 1, 8); |
410 |
|
411 |
me->set_default_ram = machine_default_ram_arc; |
412 |
|
413 |
me->aliases[0] = "arc"; |
414 |
|
415 |
me->subtype[0] = machine_entry_subtype_new( |
416 |
"Acer PICA-61", MACHINE_ARC_JAZZ_PICA, 3); |
417 |
me->subtype[0]->aliases[0] = "pica-61"; |
418 |
me->subtype[0]->aliases[1] = "acer pica"; |
419 |
me->subtype[0]->aliases[2] = "pica"; |
420 |
|
421 |
me->subtype[1] = machine_entry_subtype_new( |
422 |
"Deskstation Tyne", MACHINE_ARC_DESKTECH_TYNE, 3); |
423 |
me->subtype[1]->aliases[0] = "deskstation tyne"; |
424 |
me->subtype[1]->aliases[1] = "desktech"; |
425 |
me->subtype[1]->aliases[2] = "tyne"; |
426 |
|
427 |
me->subtype[2] = machine_entry_subtype_new( |
428 |
"Jazz Magnum", MACHINE_ARC_JAZZ_MAGNUM, 2); |
429 |
me->subtype[2]->aliases[0] = "magnum"; |
430 |
me->subtype[2]->aliases[1] = "jazz magnum"; |
431 |
|
432 |
me->subtype[3] = machine_entry_subtype_new( |
433 |
"NEC-R94", MACHINE_ARC_NEC_R94, 2); |
434 |
me->subtype[3]->aliases[0] = "nec-r94"; |
435 |
me->subtype[3]->aliases[1] = "r94"; |
436 |
|
437 |
me->subtype[4] = machine_entry_subtype_new( |
438 |
"NEC-RD94", MACHINE_ARC_NEC_RD94, 2); |
439 |
me->subtype[4]->aliases[0] = "nec-rd94"; |
440 |
me->subtype[4]->aliases[1] = "rd94"; |
441 |
|
442 |
me->subtype[5] = machine_entry_subtype_new( |
443 |
"NEC-R96", MACHINE_ARC_NEC_R96, 2); |
444 |
me->subtype[5]->aliases[0] = "nec-r96"; |
445 |
me->subtype[5]->aliases[1] = "r96"; |
446 |
|
447 |
me->subtype[6] = machine_entry_subtype_new( |
448 |
"NEC-R98", MACHINE_ARC_NEC_R98, 2); |
449 |
me->subtype[6]->aliases[0] = "nec-r98"; |
450 |
me->subtype[6]->aliases[1] = "r98"; |
451 |
|
452 |
me->subtype[7] = machine_entry_subtype_new( |
453 |
"Olivetti M700", MACHINE_ARC_JAZZ_M700, 2); |
454 |
me->subtype[7]->aliases[0] = "olivetti"; |
455 |
me->subtype[7]->aliases[1] = "m700"; |
456 |
|
457 |
machine_entry_add(me, ARCH_MIPS); |
458 |
} |
459 |
|