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