1 /*
2 * Copyright (C) 2003-2020 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 * COMMENT: ARC (Advanced RISC Computing) machines
29 */
30
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <string.h>
34
35 #include "arcbios.h"
36 #include "cpu.h"
37 #include "device.h"
38 #include "devices.h"
39 #include "machine.h"
40 #include "memory.h"
41 #include "misc.h"
42
43 #define MACHINE_NAME_MAXBUF 100
44
45
MACHINE_SETUP(arc)46 MACHINE_SETUP(arc)
47 {
48 void *jazz_data;
49 struct memory *mem = machine->memory;
50 char tmpstr[1000];
51 char tmpstr2[1000];
52 int i, j;
53 const char *eaddr_string = "10:20:30:40:50:60"; /* bogus */
54 unsigned char macaddr[6];
55 char *machineName;
56
57 CHECK_ALLOCATION(machineName = (char *) malloc(MACHINE_NAME_MAXBUF));
58
59 cpu->byte_order = EMUL_LITTLE_ENDIAN;
60 snprintf(machineName, MACHINE_NAME_MAXBUF, "ARC");
61
62 machine->machine_name = machineName;
63
64 switch (machine->machine_subtype) {
65
66 case MACHINE_ARC_JAZZ_PICA:
67 case MACHINE_ARC_JAZZ_MAGNUM:
68 /*
69 * "PICA-61"
70 *
71 * According to NetBSD 1.6.2:
72 *
73 * jazzio0 at mainbus0
74 * timer0 at jazzio0 addr 0xe0000228
75 * mcclock0 at jazzio0 addr 0xe0004000: mc146818 or compatible
76 * lpt at jazzio0 addr 0xe0008000 intr 0 not configured
77 * fdc at jazzio0 addr 0xe0003000 intr 1 not configured
78 * MAGNUM at jazzio0 addr 0xe000c000 intr 2 not configured
79 * ALI_S3 at jazzio0 addr 0xe0800000 intr 3 not configured
80 * sn0 at jazzio0 addr 0xe0001000 intr 4: SONIC Ethernet
81 * sn0: Ethernet address 69:6a:6b:6c:00:00
82 * asc0 at jazzio0 addr 0xe0002000 intr 5: NCR53C94, target 0
83 * pckbd at jazzio0 addr 0xe0005000 intr 6 not configured
84 * pms at jazzio0 addr 0xe0005000 intr 7 not configured
85 * com0 at jazzio0 addr 0xe0006000 intr 8: ns16550a,
86 * working fifo
87 * com at jazzio0 addr 0xe0007000 intr 9 not configured
88 * jazzisabr0 at mainbus0
89 * isa0 at jazzisabr0 isa_io_base 0xe2000000 isa_mem_base
90 * 0xe3000000
91 *
92 * "Microsoft-Jazz", "MIPS Magnum"
93 *
94 * timer0 at jazzio0 addr 0xe0000228
95 * mcclock0 at jazzio0 addr 0xe0004000: mc146818 or compatible
96 * lpt at jazzio0 addr 0xe0008000 intr 0 not configured
97 * fdc at jazzio0 addr 0xe0003000 intr 1 not configured
98 * MAGNUM at jazzio0 addr 0xe000c000 intr 2 not configured
99 * VXL at jazzio0 addr 0xe0800000 intr 3 not configured
100 * sn0 at jazzio0 addr 0xe0001000 intr 4: SONIC Ethernet
101 * sn0: Ethernet address 69:6a:6b:6c:00:00
102 * asc0 at jazzio0 addr 0xe0002000 intr 5: NCR53C94, target 0
103 * scsibus0 at asc0: 8 targets, 8 luns per target
104 * pckbd at jazzio0 addr 0xe0005000 intr 6 not configured
105 * pms at jazzio0 addr 0xe0005000 intr 7 not configured
106 * com0 at jazzio0 addr 0xe0006000 intr 8: ns16550a,
107 * working fifo
108 * com at jazzio0 addr 0xe0007000 intr 9 not configured
109 * jazzisabr0 at mainbus0
110 * isa0 at jazzisabr0 isa_io_base 0xe2000000 isa_mem_base
111 * 0xe3000000
112 */
113
114 switch (machine->machine_subtype) {
115 case MACHINE_ARC_JAZZ_PICA:
116 strlcat(machineName, " (Microsoft Jazz, Acer PICA-61)",
117 MACHINE_NAME_MAXBUF);
118 break;
119 case MACHINE_ARC_JAZZ_MAGNUM:
120 strlcat(machineName, " (Microsoft Jazz, MIPS Magnum)",
121 MACHINE_NAME_MAXBUF);
122 break;
123 default:
124 fatal("error in machine.c. jazz\n");
125 exit(1);
126 }
127
128 jazz_data = device_add(machine, "jazz addr=0x80000000");
129
130 /* Keyboard IRQ is jazz.6, mouse is jazz.7 */
131 snprintf(tmpstr, sizeof(tmpstr),
132 "%s.cpu[%i].jazz.6", machine->path,
133 machine->bootstrap_cpu);
134 snprintf(tmpstr2, sizeof(tmpstr2),
135 "%s.cpu[%i].jazz.7", machine->path,
136 machine->bootstrap_cpu);
137 i = dev_pckbc_init(machine, mem, 0x80005000ULL,
138 PCKBC_JAZZ, tmpstr, tmpstr2,
139 machine->x11_md.in_use, 0);
140
141 /* Serial controllers at JAZZ irq 8 and 9: */
142 snprintf(tmpstr, sizeof(tmpstr),
143 "ns16550 irq=%s.cpu[%i].jazz.8 addr=0x80006000"
144 " in_use=%i name2=tty0", machine->path,
145 machine->bootstrap_cpu, machine->x11_md.in_use? 0 : 1);
146 j = (size_t)device_add(machine, tmpstr);
147 snprintf(tmpstr, sizeof(tmpstr),
148 "ns16550 irq=%s.cpu[%i].jazz.9 addr=0x80007000"
149 " in_use=0 name2=tty1", machine->path,
150 machine->bootstrap_cpu);
151 device_add(machine, tmpstr);
152
153 if (machine->x11_md.in_use)
154 machine->main_console_handle = i;
155 else
156 machine->main_console_handle = j;
157
158 switch (machine->machine_subtype) {
159 case MACHINE_ARC_JAZZ_PICA:
160 if (machine->x11_md.in_use) {
161 dev_vga_init(machine, mem, 0x400a0000ULL,
162 0x600003c0ULL, machine->machine_name);
163 arcbios_console_init(machine,
164 0x400b8000ULL, 0x600003c0ULL);
165 }
166 break;
167 case MACHINE_ARC_JAZZ_MAGNUM:
168 /* PROM mirror? */
169 dev_ram_init(machine, 0xfff00000, 0x100000,
170 DEV_RAM_MIRROR | DEV_RAM_MIGHT_POINT_TO_DEVICES,
171 0x1fc00000);
172
173 /* VXL. TODO */
174 /* control at 0x60100000? */
175 dev_fb_init(machine, mem, 0x60200000ULL,
176 VFB_GENERIC, 1024,768, 1024,768, 8, "VXL");
177 break;
178 }
179
180 /* SN at JAZZ irq 4 */
181 snprintf(tmpstr, sizeof(tmpstr),
182 "sn addr=0x80001000 irq=%s.cpu[%i].jazz.4",
183 machine->path, machine->bootstrap_cpu);
184 device_add(machine, tmpstr);
185
186 /* ASC at JAZZ irq 5 */
187 snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].jazz.5",
188 machine->path, machine->bootstrap_cpu);
189 dev_asc_init(machine, mem, 0x80002000ULL, tmpstr, NULL,
190 DEV_ASC_PICA, dev_jazz_dma_controller, jazz_data);
191
192 /* FDC at JAZZ irq 1 */
193 snprintf(tmpstr, sizeof(tmpstr),
194 "fdc addr=0x80003000 irq=%s.cpu[%i].jazz.1",
195 machine->path, machine->bootstrap_cpu);
196 device_add(machine, tmpstr);
197
198 /* MC146818 at MIPS irq 2: */
199 snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].2",
200 machine->path, machine->bootstrap_cpu);
201 dev_mc146818_init(machine, mem,
202 0x80004000ULL, tmpstr, MC146818_ARC_JAZZ, 1);
203
204 #if 0
205 Not yet.
206 /* WDC at ISA irq 14 */
207 device_add(machine, "wdc addr=0x900001f0, irq=38");
208 #endif
209
210 break;
211
212 default:fatal("Unimplemented ARC machine type %i\n",
213 machine->machine_subtype);
214 exit(1);
215 }
216
217 /*
218 * NOTE: ARCBIOS shouldn't be used before this point. (The only
219 * exception is that arcbios_console_init() may be called.)
220 */
221
222 if (!machine->prom_emulation)
223 return;
224
225 arcbios_init(machine, 0, 0, eaddr_string, macaddr);
226 }
227
228
MACHINE_DEFAULT_CPU(arc)229 MACHINE_DEFAULT_CPU(arc)
230 {
231 switch (machine->machine_subtype) {
232
233 case MACHINE_ARC_JAZZ_PICA:
234 CHECK_ALLOCATION(machine->cpu_name = strdup("R4000"));
235 break;
236
237 default:
238 CHECK_ALLOCATION(machine->cpu_name = strdup("R4400"));
239 }
240 }
241
242
MACHINE_DEFAULT_RAM(arc)243 MACHINE_DEFAULT_RAM(arc)
244 {
245 machine->physical_ram_in_mb = 64;
246 }
247
248
MACHINE_REGISTER(arc)249 MACHINE_REGISTER(arc)
250 {
251 MR_DEFAULT(arc, "ARC", ARCH_MIPS, MACHINE_ARC);
252
253 me->set_default_ram = machine_default_ram_arc;
254
255 machine_entry_add_alias(me, "arc");
256
257 machine_entry_add_subtype(me, "Acer PICA-61", MACHINE_ARC_JAZZ_PICA,
258 "pica-61", "acer pica", "pica", NULL);
259
260 machine_entry_add_subtype(me, "Jazz Magnum", MACHINE_ARC_JAZZ_MAGNUM,
261 "magnum", "jazz magnum", NULL);
262 }
263
264