machine_alpha.cc Source File

Back to the index.

machine_alpha.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2011 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: DEC Alpha machines
29  */
30 
31 #include <stdio.h>
32 #include <string.h>
33 #include <stdlib.h>
34 
35 #include "cpu.h"
36 #include "device.h"
37 #include "devices.h"
38 #include "machine.h"
39 #include "memory.h"
40 #include "misc.h"
41 
43 #include "thirdparty/alpha_rpb.h"
44 
45 
47 {
48  struct rpb rpb;
49  struct crb crb;
50  struct ctb ctb;
51  struct mddt mddt;
52  struct pcs *pcs = (struct pcs *) malloc(sizeof(struct pcs) * machine->ncpus);
53  int i;
54 
55  switch (machine->machine_subtype) {
56 
57  case ST_ALPHABOOK1:
58  machine->machine_name = strdup("AlphaBook 1");
59  if (machine->emulated_hz == 0)
60  machine->emulated_hz = 233000000;
61  device_add(machine, "lca");
62  break;
63 
64  case ST_DEC_4100:
65  machine->machine_name = strdup("AlphaServer 4100");
66  break;
67 
68  case ST_DEC_3000_300:
69  machine->machine_name = strdup("DEC 3000/300");
71  "z8530 addr=0x1b0200000 irq=0 addr_mult=4");
72  break;
73 
74  case ST_EB164:
75  machine->machine_name = strdup("EB164");
76  break;
77 
78  default:fatal("Unimplemented Alpha machine type %i\n",
80  exit(1);
81  }
82 
83  if (!machine->prom_emulation)
84  return;
85 
86  /* These are used by NetBSD/alpha: */
87  /* a0 = First free Page Frame Number */
88  /* a1 = PFN of current Level 1 page table */
89  /* a2 = Bootinfo magic */
90  /* a3 = Bootinfo pointer */
91  /* a4 = Bootinfo version */
92  cpu->cd.alpha.r[ALPHA_A0] = 16*1024*1024 / 8192;
93  cpu->cd.alpha.r[ALPHA_A1] = 0; /* TODO */
94  cpu->cd.alpha.r[ALPHA_A2] = 0; /* Note: NOT ALPHA_BOOTINFO_MAGIC */
95  cpu->cd.alpha.r[ALPHA_A3] = 0; /* TODO */
96  cpu->cd.alpha.r[ALPHA_A4] = 1;
97 
98  /*
99  * HWRPB: Hardware Restart Parameter Block
100  *
101  * TODO: Almost everything.
102  */
103  memset(&rpb, 0, sizeof(struct rpb));
104  store_64bit_word_in_host(cpu, (unsigned char *)
105  &(rpb.rpb_phys), 0x14000);
106  strlcpy((char *)&(rpb.rpb_magic), "HWRPB", 8);
107  store_64bit_word_in_host(cpu, (unsigned char *)
109  store_64bit_word_in_host(cpu, (unsigned char *)
110  &(rpb.rpb_size), sizeof(struct rpb));
111  store_64bit_word_in_host(cpu, (unsigned char *)
112  &(rpb.rpb_page_size), 8192);
113  strlcpy((char *)&(rpb.rpb_ssn), "123456789", 10);
114  store_64bit_word_in_host(cpu, (unsigned char *)
116  store_64bit_word_in_host(cpu, (unsigned char *)
118  store_64bit_word_in_host(cpu, (unsigned char *)
119  &(rpb.rpb_intr_freq), 1024 << 12);
120  store_64bit_word_in_host(cpu, (unsigned char *)
122  store_64bit_word_in_host(cpu, (unsigned char *)
123  &(rpb.rpb_pcs_size), sizeof(struct pcs));
124  store_64bit_word_in_host(cpu, (unsigned char *)
126  store_64bit_word_in_host(cpu, (unsigned char *)
128  store_64bit_word_in_host(cpu, (unsigned char *)
130  store_64bit_word_in_host(cpu, (unsigned char *)
132 
133  /* CTB: Console Terminal Block */
134  memset(&ctb, 0, sizeof(struct ctb));
135  store_64bit_word_in_host(cpu, (unsigned char *)
138 
139  /* CRB: Console Routine Block */
140  memset(&crb, 0, sizeof(struct crb));
141  store_64bit_word_in_host(cpu, (unsigned char *)
142  &(crb.crb_v_dispatch), CRB_ADDR - 0x100);
144  store_64bit_word_in_host(cpu, (unsigned char *)
145  &(crb.crb_v_fixup), CRB_ADDR - 0x80);
146  store_64bit_word(cpu, CRB_ADDR - 0x80 + 8, PROM_ENTRY_PADDR + 0x800);
147 
148  /* PCS: Processor ID etc. */
149  for (i=0; i<machine->ncpus; i++) {
150  memset(&pcs[i], 0, sizeof(struct pcs));
151  store_64bit_word_in_host(cpu, (unsigned char *)
152  &(pcs[i].pcs_flags), PCS_RC | PCS_PA | PCS_PP |
153  PCS_CV | PCS_PV | PCS_PMV | PCS_PL);
154  store_64bit_word_in_host(cpu, (unsigned char *)
155  &(pcs[i].pcs_proc_type),
157  }
158 
159  /*
160  * MDDT: Memory Data Descriptor Table. For now, it is a simple
161  * two-entry table with half of the available RAM in each entry.
162  * (The values are in number of 8K pages.)
163  * The first 16 MB are not included (the kernel lives there).
164  * The last 1 MB is not included either, it is reserved for bootup
165  * and similar.
166  */
167  memset(&mddt, 0, sizeof(struct mddt));
168  memset(&mddt.mddt_clusters[0], 0, sizeof(struct mddt_cluster));
169  memset(&mddt.mddt_clusters[1], 0, sizeof(struct mddt_cluster));
170  store_64bit_word_in_host(cpu, (unsigned char *)
171  &(mddt.mddt_cluster_cnt), 2);
172  store_64bit_word_in_host(cpu, (unsigned char *)
173  &(mddt.mddt_clusters[0].mddt_pfn), 16 * 128);
174  store_64bit_word_in_host(cpu, (unsigned char *)
176  (machine->physical_ram_in_mb/2 - 16) * 128);
177  store_64bit_word_in_host(cpu, (unsigned char *)
179  machine->physical_ram_in_mb/2 * 128);
180  store_64bit_word_in_host(cpu, (unsigned char *)
182  (machine->physical_ram_in_mb/2) * 128);
183 
184  /*
185  * Place a special "hack" palcode call at PROM_ENTRY_PADDR and
186  * PROM_ENTRY_PADDR + 0x800:
187  * (Hopefully nothing else will be there.)
188  */
190  store_32bit_word(cpu, PROM_ENTRY_PADDR + 0x800, 0x3fffffd);
191 
192  store_buf(cpu, HWRPB_ADDR, (char *)&rpb, sizeof(struct rpb));
193  store_buf(cpu, CTB_ADDR, (char *)&ctb, sizeof(struct ctb));
194  store_buf(cpu, CRB_ADDR, (char *)&crb, sizeof(struct crb));
195  store_buf(cpu, MEMDAT_ADDR, (char *)&mddt, sizeof(struct mddt));
196  store_buf(cpu, PCS_ADDR, (char *)pcs, sizeof(struct pcs) *
197  machine->ncpus);
198 
199  free(pcs);
200 }
201 
202 
204 {
205  switch (machine->machine_subtype) {
206 
207  case ST_ALPHABOOK1:
208  machine->cpu_name = strdup("21066");
209  break;
210 
211  case ST_DEC_4100:
212  machine->cpu_name = strdup("21164A-2");
213  break;
214 
215  case ST_DEC_3000_300:
216  machine->cpu_name = strdup("21064");
217  break;
218 
219  case ST_EB164:
220  machine->cpu_name = strdup("21164PC");
221  break;
222 
223  default:fatal("Unimplemented Alpha machine type %i\n",
225  exit(1);
226  }
227 }
228 
229 
231 {
233 }
234 
235 
237 {
238  MR_DEFAULT(alpha, "Alpha", ARCH_ALPHA, MACHINE_ALPHA);
239 
240  machine_entry_add_alias(me, "alpha");
241 
242  machine_entry_add_subtype(me, "AlphaBook 1", ST_ALPHABOOK1,
243  "alphabook1", NULL);
244 
245  machine_entry_add_subtype(me, "AlphaServer 4100", ST_DEC_4100,
246  "alphaserver4100", NULL);
247 
248  machine_entry_add_subtype(me, "DEC 3000/300", ST_DEC_3000_300,
249  "3000/300", NULL);
250 
251  machine_entry_add_subtype(me, "EB164", ST_EB164,
252  "eb164", NULL);
253 
254  me->set_default_ram = machine_default_ram_alpha;
255 }
256 
alpha_rpb.h
machine::machine_subtype
int machine_subtype
Definition: machine.h:112
CTB_PRINTERPORT
#define CTB_PRINTERPORT
Definition: alpha_rpb.h:365
rpb::rpb_ssn
char rpb_ssn[16]
Definition: alpha_rpb.h:63
rpb
Definition: alpha_rpb.h:53
mddt::mddt_clusters
struct mddt_cluster mddt_clusters[2]
Definition: alpha_rpb.h:476
ALPHA_A3
#define ALPHA_A3
Definition: cpu_alpha.h:96
store_buf
void store_buf(struct cpu *cpu, uint64_t addr, const char *s, size_t len)
Definition: memory.cc:826
PCS_PV
#define PCS_PV
Definition: alpha_rpb.h:242
MACHINE_DEFAULT_CPU
MACHINE_DEFAULT_CPU(alpha)
Definition: machine_alpha.cc:203
rpb::rpb_cc_freq
u_int64_t rpb_cc_freq
Definition: alpha_rpb.h:198
CRB_ADDR
#define CRB_ADDR
Definition: alpha_rpb.h:48
ALPHA_A0
#define ALPHA_A0
Definition: cpu_alpha.h:93
machine::cpus
struct cpu ** cpus
Definition: machine.h:140
rpb::rpb_version
u_int64_t rpb_version
Definition: alpha_rpb.h:56
mddt_cluster::mddt_pg_cnt
u_int64_t mddt_pg_cnt
Definition: alpha_rpb.h:457
store_64bit_word
int store_64bit_word(struct cpu *cpu, uint64_t addr, uint64_t data64)
Definition: memory.cc:752
rpb::rpb_ctb_off
u_int64_t rpb_ctb_off
Definition: alpha_rpb.h:207
cpu::alpha
struct alpha_cpu alpha
Definition: cpu.h:443
ST_EB164
#define ST_EB164
Definition: alpha_rpb.h:86
rpb::rpb_pcs_cnt
u_int64_t rpb_pcs_cnt
Definition: alpha_rpb.h:202
rpb::rpb_page_size
u_int64_t rpb_page_size
Definition: alpha_rpb.h:59
ctb::ctb_term_type
u_int64_t ctb_term_type
Definition: alpha_rpb.h:369
MACHINE_DEFAULT_RAM
MACHINE_DEFAULT_RAM(alpha)
Definition: machine_alpha.cc:230
HWRPB_DSRDB_MINVERS
#define HWRPB_DSRDB_MINVERS
Definition: alpha_rpb.h:496
pcs::pcs_proc_type
u_int64_t pcs_proc_type
Definition: alpha_rpb.h:283
machine::prom_emulation
int prom_emulation
Definition: machine.h:149
ALPHA_A2
#define ALPHA_A2
Definition: cpu_alpha.h:95
CTB_ADDR
#define CTB_ADDR
Definition: alpha_rpb.h:47
device.h
rpb::rpb_intr_freq
u_int64_t rpb_intr_freq
Definition: alpha_rpb.h:197
pcs
Definition: alpha_rpb.h:233
rpb::rpb_pcs_size
u_int64_t rpb_pcs_size
Definition: alpha_rpb.h:203
mddt_cluster
Definition: alpha_rpb.h:455
MACHINE_REGISTER
MACHINE_REGISTER(alpha)
Definition: machine_alpha.cc:236
CTB_GRAPHICS
#define CTB_GRAPHICS
Definition: alpha_rpb.h:366
ST_DEC_4100
#define ST_DEC_4100
Definition: alpha_rpb.h:83
rpb::rpb_phys
u_int64_t rpb_phys
Definition: alpha_rpb.h:54
mddt
Definition: alpha_rpb.h:470
fatal
void fatal(const char *fmt,...)
Definition: main.cc:152
machine::cpu_name
char * cpu_name
Definition: machine.h:133
ALPHA_A4
#define ALPHA_A4
Definition: cpu_alpha.h:97
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
alpha_autoconf.h
PROM_ENTRY_PADDR
#define PROM_ENTRY_PADDR
Definition: alpha_rpb.h:44
misc.h
PCS_PMV
#define PCS_PMV
Definition: alpha_rpb.h:243
rpb::rpb_memdat_off
u_int64_t rpb_memdat_off
Definition: alpha_rpb.h:209
ctb
Definition: alpha_rpb.h:354
cpu::cd
union cpu::@1 cd
ST_ALPHABOOK1
#define ST_ALPHABOOK1
Definition: alpha_rpb.h:82
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
alpha_cpu::r
uint64_t r[N_ALPHA_REGS]
Definition: cpu_alpha.h:151
MR_DEFAULT
#define MR_DEFAULT(x, name, arch, type)
Definition: machine.h:373
rpb::rpb_type
u_int64_t rpb_type
Definition: alpha_rpb.h:101
crb::crb_v_dispatch
u_int64_t crb_v_dispatch
Definition: alpha_rpb.h:443
alpha_cpu::cpu_type
struct alpha_cpu_type_def cpu_type
Definition: cpu_alpha.h:144
rpb::rpb_magic
char rpb_magic[8]
Definition: alpha_rpb.h:55
machine::x11_md
struct x11_md x11_md
Definition: machine.h:179
crb
Definition: alpha_rpb.h:441
MEMDAT_ADDR
#define MEMDAT_ADDR
Definition: alpha_rpb.h:49
cpu.h
alpha_cpu_type_def::pcs_type
uint64_t pcs_type
Definition: cpu_alpha.h:42
machine::physical_ram_in_mb
uint32_t physical_ram_in_mb
Definition: machine.h:147
PCS_PP
#define PCS_PP
Definition: alpha_rpb.h:239
PCS_PL
#define PCS_PL
Definition: alpha_rpb.h:244
rpb::rpb_crb_off
u_int64_t rpb_crb_off
Definition: alpha_rpb.h:208
store_32bit_word
int store_32bit_word(struct cpu *cpu, uint64_t addr, uint64_t data32)
Definition: memory.cc:783
pcs::pcs_flags
u_int64_t pcs_flags
Definition: alpha_rpb.h:253
HWRPB_ADDR
#define HWRPB_ADDR
Definition: alpha_rpb.h:41
machine::emulated_hz
int emulated_hz
Definition: machine.h:165
ARCH_ALPHA
#define ARCH_ALPHA
Definition: machine.h:205
store_64bit_word_in_host
void store_64bit_word_in_host(struct cpu *cpu, unsigned char *data, uint64_t data32)
Definition: memory.cc:945
PCS_CV
#define PCS_CV
Definition: alpha_rpb.h:241
PCS_ADDR
#define PCS_ADDR
Definition: alpha_rpb.h:50
PCS_RC
#define PCS_RC
Definition: alpha_rpb.h:237
mddt_cluster::mddt_pfn
u_int64_t mddt_pfn
Definition: alpha_rpb.h:456
devices.h
machine::machine_name
const char * machine_name
Definition: machine.h:115
cpu
Definition: cpu.h:326
PCS_PA
#define PCS_PA
Definition: alpha_rpb.h:238
mddt::mddt_cluster_cnt
u_int64_t mddt_cluster_cnt
Definition: alpha_rpb.h:475
ALPHA_A1
#define ALPHA_A1
Definition: cpu_alpha.h:94
MACHINE_ALPHA
#define MACHINE_ALPHA
Definition: machine.h:234
machine_entry_add_alias
void machine_entry_add_alias(struct machine_entry *me, const char *name)
Definition: machine.cc:697
rpb::rpb_size
u_int64_t rpb_size
Definition: alpha_rpb.h:57
MACHINE_SETUP
MACHINE_SETUP(alpha)
Definition: machine_alpha.cc:46
memory.h
rpb::rpb_pcs_off
u_int64_t rpb_pcs_off
Definition: alpha_rpb.h:204
ST_DEC_3000_300
#define ST_DEC_3000_300
Definition: alpha_rpb.h:70
machine::ncpus
int ncpus
Definition: machine.h:139
crb::crb_v_fixup
u_int64_t crb_v_fixup
Definition: alpha_rpb.h:446

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