machine_mvmeppc.cc Source File

Back to the index.

machine_mvmeppc.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2010 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: MVMEPPC machines
29  *
30  * This is for experiments with NetBSD/mvmeppc.
31  * (ftp://ftp.netbsd.org/pub/NetBSD/arch/mvmeppc/snapshot/20020302/README)
32  *
33  * Note: MVME machines that really adhere to the PReP standard should be
34  * in machine_prep.c instead.
35  *
36  *
37  * TODO: This is mostly bogus.
38  */
39 
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <string.h>
43 
44 #include "bus_isa.h"
45 #include "bus_pci.h"
46 #include "cpu.h"
47 #include "device.h"
48 #include "devices.h"
49 #include "diskimage.h"
50 #include "machine.h"
51 #include "memory.h"
52 #include "misc.h"
53 
54 
55 MACHINE_SETUP(mvmeppc)
56 {
57  char tmpstr[300], tmpstr2[300];;
58  struct pci_data *pci_data = NULL;
59 
60  switch (machine->machine_subtype) {
61 
63  machine->machine_name = strdup("MVME1600");
64 
65  snprintf(tmpstr, sizeof(tmpstr), "eagle irq=%s.cpu[%i]",
67  device_add(machine, tmpstr);
68 
69  bus_pci_add(machine, pci_data, machine->memory,
70  0, 14, 0, "dec21143");
71 
72  device_add(machine, "nvram addr=0x80000074 name2=mvme1600");
73 
74  /*
75  * "DRAM size register": TODO: turn this into a device?
76  * See the definition of p160x_dram_size in NetBSD's
77  * .../arch/mvmeppc/platform_160x.c for details.
78  *
79  * 0x11 = two banks of 32 MB each.
80  */
81  dev_ram_init(machine, 0x80000804, 1, DEV_RAM_RAM, 0);
82  store_byte(cpu, 0x80000804, 0x11);
83 
84  break;
85 
87  machine->machine_name = strdup("MVME2100");
88 
89  /* 0xfe000000 isa bus space */
90  /* 0xfec00000 pci indirect addr */
91  /* 0xfee00000 pci indirect data */
92 
93  /* TODO: irq */
94  device_add(machine, "ns16550 irq=0 addr=0xffe10000");
95 
96  break;
97 
99  /* Could possibly be used for RTEMS experiments some day. */
100  machine->machine_name = strdup("MVME5500");
101 
102  /* GT64260 interrupt and PCI controller: */
103  snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i]",
105  snprintf(tmpstr2, sizeof(tmpstr2), "%s.cpu[%i]",
107  pci_data = dev_gt_init(machine, machine->memory,
108  0xf1000000,
109  tmpstr, // timer irq path: TODO
110  tmpstr2, // ISA irq path: TODO
111  260);
112 
113  /* TODO: irq */
114  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=%s.cpu[%i] addr=0xf1120000",
116  device_add(machine, tmpstr);
117 
118  break;
119 
120  default:fatal("Unimplemented MVMEPPC machine subtype %i\n",
122  exit(1);
123  }
124 
125  if (!machine->prom_emulation)
126  return;
127 
128  /* r3 = start of kernel, r4 = end of kernel (for NetBSD/mvmeppc) */
129  cpu->cd.ppc.gpr[3] = 0;
130  cpu->cd.ppc.gpr[4] = 1048576 * 10;
131  cpu->cd.ppc.gpr[5] = machine->physical_ram_in_mb * 1048576-0x100;
132  store_string(cpu, cpu->cd.ppc.gpr[5]+ 44, "PC16550");
133  store_32bit_word(cpu, cpu->cd.ppc.gpr[5]+ 68, 9600);
134  store_32bit_word(cpu, cpu->cd.ppc.gpr[5]+ 72, 0);
135 
136  store_16bit_word(cpu, cpu->cd.ppc.gpr[5]+ 76, 0x1600);
137  store_32bit_word(cpu, cpu->cd.ppc.gpr[5]+ 80,
138  machine->physical_ram_in_mb * 1048576);
139  store_32bit_word(cpu, cpu->cd.ppc.gpr[5]+ 84, 33 * 1000000);
140  store_32bit_word(cpu, cpu->cd.ppc.gpr[5]+ 88, 33 * 1000000);
141 #if 0
142 0 u_int32_t bi_boothowto;
143 4 u_int32_t bi_bootaddr;
144 8 u_int16_t bi_bootclun;
145 10 u_int16_t bi_bootdlun;
146 12 char bi_bootline[BOOTLINE_LEN]; (32)
147 44 char bi_consoledev[CONSOLEDEV_LEN]; (16)
148 60 u_int32_t bi_consoleaddr;
149 64 u_int32_t bi_consolechan;
150 68 u_int32_t bi_consolespeed;
151 72 u_int32_t bi_consolecflag;
152 76 u_int16_t bi_modelnumber;
153 80 u_int32_t bi_memsize;
154 84 u_int32_t bi_mpuspeed;
155 88 u_int32_t bi_busspeed;
156 92 u_int32_t bi_clocktps;
157 #endif
158 }
159 
160 
162 {
163  switch (machine->machine_subtype) {
164 
166  /* Suitable for NetBSD/mvmeppc: */
167  machine->cpu_name = strdup("PPC603e");
168  break;
169 
171  machine->cpu_name = strdup("PPC603e");
172  break;
173 
175  machine->cpu_name = strdup("PPC750");
176  break;
177 
178  default:fatal("Unimplemented MVMEPPC machine subtype %i\n",
180  exit(1);
181  }
182 }
183 
184 
186 {
188 }
189 
190 
192 {
193  MR_DEFAULT(mvmeppc, "MVMEPPC", ARCH_PPC, MACHINE_MVMEPPC);
194 
195  machine_entry_add_alias(me, "mvmeppc");
196 
198  "mvme1600", NULL);
199 
201  "mvme2100", NULL);
202 
204  "mvme5500", NULL);
205 
206  me->set_default_ram = machine_default_ram_mvmeppc;
207 }
208 
void fatal(const char *fmt,...)
Definition: main.cc:152
int prom_emulation
Definition: machine.h:149
char * cpu_name
Definition: machine.h:133
int store_32bit_word(struct cpu *cpu, uint64_t addr, uint64_t data32)
Definition: memory.cc:783
#define ARCH_PPC
Definition: machine.h:204
MACHINE_DEFAULT_RAM(mvmeppc)
#define DEV_RAM_RAM
Definition: devices.h:364
struct ppc_cpu ppc
Definition: cpu.h:444
union cpu::@1 cd
void store_string(struct cpu *cpu, uint64_t addr, const char *s)
Definition: memory.cc:695
struct memory * memory
Definition: machine.h:126
void bus_pci_add(struct machine *machine, struct pci_data *pci_data, struct memory *mem, int bus, int device, int function, const char *name)
Definition: bus_pci.cc:216
MACHINE_DEFAULT_CPU(mvmeppc)
void * device_add(struct machine *machine, const char *name_and_params)
Definition: device.cc:252
int physical_ram_in_mb
Definition: machine.h:147
#define MACHINE_MVMEPPC_1600
Definition: machine.h:323
#define MACHINE_MVMEPPC
Definition: machine.h:230
char * path
Definition: machine.h:108
int bootstrap_cpu
Definition: machine.h:136
struct pci_data * dev_gt_init(struct machine *machine, struct memory *mem, uint64_t baseaddr, const char *timer_irq_path, const char *isa_irq_path, int type)
Definition: dev_gt.cc:225
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:134
void machine_entry_add_subtype(struct machine_entry *me, const char *name, int oldstyle_subtype,...)
Definition: machine.cc:717
void machine_entry_add_alias(struct machine_entry *me, const char *name)
Definition: machine.cc:697
MACHINE_SETUP(mvmeppc)
Definition: cpu.h:326
MACHINE_REGISTER(mvmeppc)
#define MACHINE_MVMEPPC_2100
Definition: machine.h:324
void store_byte(struct cpu *cpu, uint64_t addr, uint8_t data)
Definition: memory.cc:679
int store_16bit_word(struct cpu *cpu, uint64_t addr, uint64_t data16)
Definition: memory.cc:807
int machine_subtype
Definition: machine.h:112
#define MACHINE_MVMEPPC_5500
Definition: machine.h:325
#define MR_DEFAULT(x, name, arch, type)
Definition: machine.h:370
const char * machine_name
Definition: machine.h:115
uint64_t gpr[PPC_NGPRS]
Definition: cpu_ppc.h:124

Generated on Fri Dec 7 2018 19:52:23 for GXemul by doxygen 1.8.13