machine_arc.cc Source File

Back to the index.

machine_arc.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2003-2009 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 
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 = "eaddr=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 
60  snprintf(machineName, MACHINE_NAME_MAXBUF, "ARC");
61 
62  machine->machine_name = machineName;
63 
64  switch (machine->machine_subtype) {
65 
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) {
116  strlcat(machineName, " (Microsoft Jazz, Acer PICA-61)",
118  break;
120  strlcat(machineName, " (Microsoft Jazz, MIPS Magnum)",
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,
134  snprintf(tmpstr2, sizeof(tmpstr2),
135  "%s.cpu[%i].jazz.7", machine->path,
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,
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,
151  device_add(machine, tmpstr);
152 
153  if (machine->x11_md.in_use)
155  else
157 
158  switch (machine->machine_subtype) {
160  if (machine->x11_md.in_use) {
161  dev_vga_init(machine, mem, 0x400a0000ULL,
162  0x600003c0ULL, machine->machine_name);
164  0x400b8000ULL, 0x600003c0ULL);
165  }
166  break;
168  /* PROM mirror? */
169  dev_ram_init(machine, 0xfff00000, 0x100000,
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",
184  device_add(machine, tmpstr);
185 
186  /* ASC at JAZZ irq 5 */
187  snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].jazz.5",
189  dev_asc_init(machine, mem, 0x80002000ULL, tmpstr, NULL,
191 
192  /* FDC at JAZZ irq 1 */
193  snprintf(tmpstr, sizeof(tmpstr),
194  "fdc addr=0x80003000 irq=%s.cpu[%i].jazz.1",
196  device_add(machine, tmpstr);
197 
198  /* MC146818 at MIPS irq 2: */
199  snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].2",
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",
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 
230 {
231  switch (machine->machine_subtype) {
232 
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 
244 {
246 }
247 
248 
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 
258  "pica-61", "acer pica", "pica", NULL);
259 
261  "magnum", "jazz magnum", NULL);
262 }
263 
machine::machine_subtype
int machine_subtype
Definition: machine.h:112
machine::bootstrap_cpu
int bootstrap_cpu
Definition: machine.h:136
MC146818_ARC_JAZZ
#define MC146818_ARC_JAZZ
Definition: devices.h:305
MACHINE_DEFAULT_CPU
MACHINE_DEFAULT_CPU(arc)
Definition: machine_arc.cc:229
VFB_GENERIC
#define VFB_GENERIC
Definition: devices.h:190
memory
Definition: memory.h:75
MACHINE_ARC_JAZZ_PICA
#define MACHINE_ARC_JAZZ_PICA
Definition: machine.h:301
DEV_RAM_MIRROR
#define DEV_RAM_MIRROR
Definition: devices.h:365
dev_vga_init
void dev_vga_init(struct machine *machine, struct memory *mem, uint64_t videomem_base, uint64_t control_base, const char *name)
Definition: dev_vga.cc:1187
cpu::byte_order
uint8_t byte_order
Definition: cpu.h:347
dev_jazz_dma_controller
size_t dev_jazz_dma_controller(void *dma_controller_data, unsigned char *data, size_t len, int writeflag)
Definition: dev_jazz.cc:150
MACHINE_SETUP
MACHINE_SETUP(arc)
Definition: machine_arc.cc:46
machine::prom_emulation
int prom_emulation
Definition: machine.h:149
device.h
ARCH_MIPS
#define ARCH_MIPS
Definition: machine.h:203
fatal
void fatal(const char *fmt,...)
Definition: main.cc:152
machine::cpu_name
char * cpu_name
Definition: machine.h:133
machine_entry_add_subtype
void machine_entry_add_subtype(struct machine_entry *me, const char *name, int oldstyle_subtype,...)
Definition: machine.cc:717
MACHINE_REGISTER
MACHINE_REGISTER(arc)
Definition: machine_arc.cc:249
x11_md::in_use
int in_use
Definition: machine.h:82
misc.h
device_add
void * device_add(struct machine *machine, const char *name_and_params)
Definition: device.cc:252
machine.h
machine
Definition: machine.h:97
machine::main_console_handle
int main_console_handle
Definition: machine.h:128
MR_DEFAULT
#define MR_DEFAULT(x, name, arch, type)
Definition: machine.h:373
machine::x11_md
struct x11_md x11_md
Definition: machine.h:179
PCKBC_JAZZ
#define PCKBC_JAZZ
Definition: devices.h:322
cpu.h
machine::path
char * path
Definition: machine.h:108
machine::memory
struct memory * memory
Definition: machine.h:126
machine::physical_ram_in_mb
uint32_t physical_ram_in_mb
Definition: machine.h:147
EMUL_LITTLE_ENDIAN
#define EMUL_LITTLE_ENDIAN
Definition: misc.h:164
arcbios_console_init
void arcbios_console_init(struct machine *machine, uint64_t vram, uint64_t ctrlregs)
Definition: arcbios.cc:2160
dev_pckbc_init
int dev_pckbc_init(struct machine *machine, struct memory *mem, uint64_t baseaddr, int type, char *keyboard_irqpath, char *mouse_irqpath, int in_use, int pc_style_flag)
Definition: dev_pckbc.cc:1157
DEV_ASC_PICA
#define DEV_ASC_PICA
Definition: devices.h:117
dev_asc_init
void dev_asc_init(struct machine *machine, struct memory *mem, uint64_t baseaddr, const char *irq_path, void *turbochannel, int mode, size_t(*dma_controller)(void *dma_controller_data, unsigned char *data, size_t len, int writeflag), void *dma_controller_data)
Definition: dev_asc.cc:1226
DEV_RAM_MIGHT_POINT_TO_DEVICES
#define DEV_RAM_MIGHT_POINT_TO_DEVICES
Definition: devices.h:366
MACHINE_DEFAULT_RAM
MACHINE_DEFAULT_RAM(arc)
Definition: machine_arc.cc:243
jazz_data
Definition: dev_jazz.cc:65
arcbios_init
void arcbios_init(struct machine *machine, int is64bit, uint64_t sgi_ram_offset, const char *primary_ether_string, uint8_t *primary_ether_macaddr)
Definition: arcbios.cc:2481
arcbios.h
devices.h
machine::machine_name
const char * machine_name
Definition: machine.h:115
dev_mc146818_init
void dev_mc146818_init(struct machine *machine, struct memory *mem, uint64_t baseaddr, char *irq_path, int access_style, int addrdiv)
Definition: dev_mc146818.cc:587
cpu
Definition: cpu.h:326
MACHINE_ARC
#define MACHINE_ARC
Definition: machine.h:218
machine_entry_add_alias
void machine_entry_add_alias(struct machine_entry *me, const char *name)
Definition: machine.cc:697
dev_ram_init
void dev_ram_init(struct machine *machine, uint64_t baseaddr, uint64_t length, int mode, uint64_t otheraddress, const char *name)
Definition: dev_ram.cc:146
MACHINE_ARC_JAZZ_MAGNUM
#define MACHINE_ARC_JAZZ_MAGNUM
Definition: machine.h:302
memory.h
dev_fb_init
struct vfb_data * dev_fb_init(struct machine *machine, struct memory *mem, uint64_t baseaddr, int vfb_type, int visible_xsize, int visible_ysize, int xsize, int ysize, int bit_depth, const char *name)
Definition: dev_fb.cc:834
MACHINE_NAME_MAXBUF
#define MACHINE_NAME_MAXBUF
Definition: machine_arc.cc:43
CHECK_ALLOCATION
#define CHECK_ALLOCATION(ptr)
Definition: misc.h:239

Generated on Tue Aug 25 2020 19:25:06 for GXemul by doxygen 1.8.18