machine_prep.cc Source File

Back to the index.

machine_prep.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-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: Machines conforming to the PowerPC Reference Platform specs
29  */
30 
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <string.h>
34 
35 #include "bus_isa.h"
36 #include "bus_pci.h"
37 #include "cpu.h"
38 #include "device.h"
39 #include "devices.h"
40 #include "machine.h"
41 #include "memory.h"
42 #include "misc.h"
43 
44 
45 
47 {
48  char tmpstr[300];
49 
50  struct pci_data *pci_data;
51  const char *model_name = "";
52 
53  switch (machine->machine_subtype) {
54 
57  strdup("PowerPC Reference Platform, IBM 6050/6070");
58  model_name = "IBM PPS Model 6050/6070 (E)";
59 
60  if (machine->emulated_hz == 0)
61  machine->emulated_hz = 20000000;
62 
63  snprintf(tmpstr, sizeof(tmpstr), "prep irq=%s.cpu[%i]",
65  device_add(machine, tmpstr);
66 
67  snprintf(tmpstr, sizeof(tmpstr), "eagle irq=%s.cpu[%i]",
69  pci_data = (struct pci_data *) device_add(machine, tmpstr);
70 
71  bus_pci_add(machine, pci_data, machine->memory,
72  0, 13, 0, "dec21143");
73 
74  if (machine->x11_md.in_use) {
75  bus_pci_add(machine, pci_data, machine->memory,
76  0, 14, 0, "s3_virge");
77  }
78  break;
79 
81  machine->machine_name = strdup("PowerPC Reference Platform, MVME2400");
82 
83  /* TODO: _EXACT_ model name for mvme2400? */
84  model_name = "MOT MVME2400";
85 
86  snprintf(tmpstr, sizeof(tmpstr), "prep irq=%s.cpu[%i]",
88  device_add(machine, tmpstr);
89 
90  snprintf(tmpstr, sizeof(tmpstr), "eagle irq=%s.cpu[%i]",
92  pci_data = (struct pci_data *) device_add(machine, tmpstr);
93 
94  break;
95 
96  default:fatal("Unimplemented PReP machine subtype %i\n",
98  exit(1);
99  }
100 
101  if (!machine->prom_emulation)
102  return;
103 
104 
105  /* Linux on PReP has 0xdeadc0de at address 0? (See
106  http://joshua.raleigh.nc.us/docs/linux-2.4.10_html/
107  113568.html) */
108  store_32bit_word(cpu, 0, 0xdeadc0de);
109 
110  /*
111  * r4 should point to first free byte after the loaded kernel.
112  * r6 should point to bootinfo.
113  */
114  cpu->cd.ppc.gpr[4] = 6 * 1048576;
115  cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb*1048576-0x8000;
116 
117  /*
118  * (See NetBSD's prep/include/bootinfo.h for details.)
119  *
120  * 32-bit "next" offset;
121  * 32-bit "type";
122  * type-specific data...
123  */
124 
125  /* type: clock */
126  store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+ 0, 12);
127  store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+ 4, 2);
129 
130  /* type: console */
131  store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+12, 20);
132  store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+16, 1);
133  store_buf(cpu, cpu->cd.ppc.gpr[6]+20,
134  machine->x11_md.in_use? "vga":"com", 4);
135  store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+24, 0x3f8);/* addr */
136  store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+28, 9600);/* speed */
137 
138  /* type: residual */
139  store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+32, 0);
140  store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+36, 0);
141  store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+40,/* addr of data */
142  cpu->cd.ppc.gpr[6] + 0x100);
143 
144  /* Residual data: (TODO) */
145  store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+0x100, 0x200);
146  store_string(cpu, cpu->cd.ppc.gpr[6]+0x100+0x8, model_name);
147  store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+0x100+0x1f8,
148  machine->physical_ram_in_mb * 1048576); /* memsize */
149 }
150 
151 
153 {
154  switch (machine->machine_subtype) {
155 
157  machine->cpu_name = strdup("PPC604");
158  break;
159 
161  machine->cpu_name = strdup("PPC750");
162  break;
163 
164  default:fatal("Unimplemented PReP machine subtype %i\n",
166  exit(1);
167  }
168 }
169 
170 
172 {
174 }
175 
176 
178 {
179  MR_DEFAULT(prep, "PowerPC Reference Platform", ARCH_PPC, MACHINE_PREP);
180 
181  machine_entry_add_alias(me, "prep");
182  me->set_default_ram = machine_default_ram_prep;
183 
184  machine_entry_add_subtype(me, "IBM 6050/6070", MACHINE_PREP_IBM6050,
185  "ibm6050", "ibm6070", NULL);
186 
188  "mvme2400", NULL);
189 }
190 
machine::machine_subtype
int machine_subtype
Definition: machine.h:112
machine::bootstrap_cpu
int bootstrap_cpu
Definition: machine.h:136
ARCH_PPC
#define ARCH_PPC
Definition: machine.h:204
store_buf
void store_buf(struct cpu *cpu, uint64_t addr, const char *s, size_t len)
Definition: memory.cc:826
machine::physical_ram_in_mb
int physical_ram_in_mb
Definition: machine.h:147
bus_isa.h
MACHINE_REGISTER
MACHINE_REGISTER(prep)
Definition: machine_prep.cc:177
machine::prom_emulation
int prom_emulation
Definition: machine.h:149
MACHINE_PREP
#define MACHINE_PREP
Definition: machine.h:228
device.h
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
x11_md::in_use
int in_use
Definition: machine.h:82
misc.h
cpu::cd
union cpu::@1 cd
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_PREP_IBM6050
#define MACHINE_PREP_IBM6050
Definition: machine.h:314
MR_DEFAULT
#define MR_DEFAULT(x, name, arch, type)
Definition: machine.h:370
store_string
void store_string(struct cpu *cpu, uint64_t addr, const char *s)
Definition: memory.cc:695
MACHINE_PREP_MVME2400
#define MACHINE_PREP_MVME2400
Definition: machine.h:315
machine::x11_md
struct x11_md x11_md
Definition: machine.h:179
cpu.h
machine::path
char * path
Definition: machine.h:108
cpu::ppc
struct ppc_cpu ppc
Definition: cpu.h:444
machine::memory
struct memory * memory
Definition: machine.h:126
bus_pci.h
store_32bit_word
int store_32bit_word(struct cpu *cpu, uint64_t addr, uint64_t data32)
Definition: memory.cc:783
MACHINE_SETUP
MACHINE_SETUP(prep)
Definition: machine_prep.cc:46
machine::emulated_hz
int emulated_hz
Definition: machine.h:165
MACHINE_DEFAULT_RAM
MACHINE_DEFAULT_RAM(prep)
Definition: machine_prep.cc:171
ppc_cpu::gpr
uint64_t gpr[PPC_NGPRS]
Definition: cpu_ppc.h:124
devices.h
machine::machine_name
const char * machine_name
Definition: machine.h:115
cpu
Definition: cpu.h:326
MACHINE_DEFAULT_CPU
MACHINE_DEFAULT_CPU(prep)
Definition: machine_prep.cc:152
machine_entry_add_alias
void machine_entry_add_alias(struct machine_entry *me, const char *name)
Definition: machine.cc:697
bus_pci_add
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
memory.h

Generated on Tue Mar 24 2020 14:04:48 for GXemul by doxygen 1.8.17