25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: machine_alpha.c,v 1.2 2006/01/08 11:05:03 debug Exp $ |
* $Id: machine_alpha.c,v 1.11 2006/09/01 11:39:50 debug Exp $ |
29 |
*/ |
*/ |
30 |
|
|
31 |
#include <stdio.h> |
#include <stdio.h> |
39 |
#include "memory.h" |
#include "memory.h" |
40 |
#include "misc.h" |
#include "misc.h" |
41 |
|
|
42 |
|
#include "alpha_autoconf.h" |
43 |
#include "alpha_rpb.h" |
#include "alpha_rpb.h" |
44 |
|
|
45 |
|
|
48 |
struct rpb rpb; |
struct rpb rpb; |
49 |
struct crb crb; |
struct crb crb; |
50 |
struct ctb ctb; |
struct ctb ctb; |
51 |
|
struct mddt mddt; |
52 |
|
struct pcs *pcs = malloc(sizeof(struct pcs) * machine->ncpus); |
53 |
|
int i; |
54 |
|
|
55 |
switch (machine->machine_subtype) { |
switch (machine->machine_subtype) { |
56 |
|
|
57 |
|
case ST_ALPHABOOK1: |
58 |
|
machine->machine_name = "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 = "AlphaServer 4100"; |
66 |
|
break; |
67 |
|
|
68 |
case ST_DEC_3000_300: |
case ST_DEC_3000_300: |
69 |
machine->machine_name = "DEC 3000/300"; |
machine->machine_name = "DEC 3000/300"; |
70 |
machine->main_console_handle = (size_t)device_add(machine, |
machine->main_console_handle = (size_t)device_add(machine, |
71 |
"z8530 addr=0x1b0200000 irq=0 addr_mult=4"); |
"z8530 addr=0x1b0200000 irq=0 addr_mult=4"); |
72 |
break; |
break; |
73 |
|
|
74 |
case ST_EB164: |
case ST_EB164: |
75 |
machine->machine_name = "EB164"; |
machine->machine_name = "EB164"; |
76 |
break; |
break; |
77 |
|
|
78 |
default:fatal("Unimplemented Alpha machine type %i\n", |
default:fatal("Unimplemented Alpha machine type %i\n", |
79 |
machine->machine_subtype); |
machine->machine_subtype); |
80 |
exit(1); |
exit(1); |
83 |
if (!machine->prom_emulation) |
if (!machine->prom_emulation) |
84 |
return; |
return; |
85 |
|
|
86 |
/* TODO: Most of these... They are used by NetBSD/alpha: */ |
/* These are used by NetBSD/alpha: */ |
87 |
/* a0 = First free Page Frame Number */ |
/* a0 = First free Page Frame Number */ |
88 |
/* a1 = PFN of current Level 1 page table */ |
/* a1 = PFN of current Level 1 page table */ |
89 |
/* a2 = Bootinfo magic */ |
/* a2 = Bootinfo magic */ |
90 |
/* a3 = Bootinfo pointer */ |
/* a3 = Bootinfo pointer */ |
91 |
/* a4 = Bootinfo version */ |
/* a4 = Bootinfo version */ |
92 |
cpu->cd.alpha.r[ALPHA_A0] = 16*1024*1024 / 8192; |
cpu->cd.alpha.r[ALPHA_A0] = 16*1024*1024 / 8192; |
93 |
cpu->cd.alpha.r[ALPHA_A1] = 0; |
cpu->cd.alpha.r[ALPHA_A1] = 0; /* TODO */ |
94 |
cpu->cd.alpha.r[ALPHA_A2] = 0; |
cpu->cd.alpha.r[ALPHA_A2] = 0; /* Note: NOT ALPHA_BOOTINFO_MAGIC */ |
95 |
cpu->cd.alpha.r[ALPHA_A3] = 0; |
cpu->cd.alpha.r[ALPHA_A3] = 0; /* TODO */ |
96 |
cpu->cd.alpha.r[ALPHA_A4] = 0; |
cpu->cd.alpha.r[ALPHA_A4] = 1; |
97 |
|
|
98 |
/* HWRPB: Hardware Restart Parameter Block */ |
/* |
99 |
|
* HWRPB: Hardware Restart Parameter Block |
100 |
|
* |
101 |
|
* TODO: Almost everything. |
102 |
|
*/ |
103 |
memset(&rpb, 0, sizeof(struct rpb)); |
memset(&rpb, 0, sizeof(struct rpb)); |
104 |
store_64bit_word_in_host(cpu, (unsigned char *) |
store_64bit_word_in_host(cpu, (unsigned char *) |
105 |
&(rpb.rpb_phys), HWRPB_ADDR); |
&(rpb.rpb_phys), 0x14000); |
106 |
strlcpy((char *)&(rpb.rpb_magic), "HWRPB", 8); |
strlcpy((char *)&(rpb.rpb_magic), "HWRPB", 8); |
107 |
store_64bit_word_in_host(cpu, (unsigned char *) |
store_64bit_word_in_host(cpu, (unsigned char *) |
108 |
&(rpb.rpb_size), sizeof(struct rpb)); |
&(rpb.rpb_size), sizeof(struct rpb)); |
109 |
store_64bit_word_in_host(cpu, (unsigned char *) |
store_64bit_word_in_host(cpu, (unsigned char *) |
110 |
&(rpb.rpb_page_size), 8192); |
&(rpb.rpb_page_size), 8192); |
111 |
|
strlcpy((char *)&(rpb.rpb_ssn), "123456789", 10); |
112 |
store_64bit_word_in_host(cpu, (unsigned char *) |
store_64bit_word_in_host(cpu, (unsigned char *) |
113 |
&(rpb.rpb_type), machine->machine_subtype); |
&(rpb.rpb_type), machine->machine_subtype); |
114 |
store_64bit_word_in_host(cpu, (unsigned char *) |
store_64bit_word_in_host(cpu, (unsigned char *) |
115 |
&(rpb.rpb_cc_freq), 100000000); |
&(rpb.rpb_cc_freq), machine->emulated_hz); |
116 |
|
store_64bit_word_in_host(cpu, (unsigned char *) |
117 |
|
&(rpb.rpb_intr_freq), 1024 << 12); |
118 |
|
store_64bit_word_in_host(cpu, (unsigned char *) |
119 |
|
&(rpb.rpb_pcs_cnt), machine->ncpus); |
120 |
|
store_64bit_word_in_host(cpu, (unsigned char *) |
121 |
|
&(rpb.rpb_pcs_size), sizeof(struct pcs)); |
122 |
|
store_64bit_word_in_host(cpu, (unsigned char *) |
123 |
|
&(rpb.rpb_pcs_off), PCS_ADDR - HWRPB_ADDR); |
124 |
store_64bit_word_in_host(cpu, (unsigned char *) |
store_64bit_word_in_host(cpu, (unsigned char *) |
125 |
&(rpb.rpb_ctb_off), CTB_ADDR - HWRPB_ADDR); |
&(rpb.rpb_ctb_off), CTB_ADDR - HWRPB_ADDR); |
126 |
store_64bit_word_in_host(cpu, (unsigned char *) |
store_64bit_word_in_host(cpu, (unsigned char *) |
127 |
&(rpb.rpb_crb_off), CRB_ADDR - HWRPB_ADDR); |
&(rpb.rpb_crb_off), CRB_ADDR - HWRPB_ADDR); |
128 |
|
store_64bit_word_in_host(cpu, (unsigned char *) |
129 |
|
&(rpb.rpb_memdat_off), MEMDAT_ADDR - HWRPB_ADDR); |
130 |
|
|
131 |
/* CTB: Console Terminal Block */ |
/* CTB: Console Terminal Block */ |
132 |
memset(&ctb, 0, sizeof(struct ctb)); |
memset(&ctb, 0, sizeof(struct ctb)); |
138 |
memset(&crb, 0, sizeof(struct crb)); |
memset(&crb, 0, sizeof(struct crb)); |
139 |
store_64bit_word_in_host(cpu, (unsigned char *) |
store_64bit_word_in_host(cpu, (unsigned char *) |
140 |
&(crb.crb_v_dispatch), CRB_ADDR - 0x100); |
&(crb.crb_v_dispatch), CRB_ADDR - 0x100); |
141 |
store_64bit_word(cpu, CRB_ADDR - 0x100 + 8, 0x10000); |
store_64bit_word(cpu, CRB_ADDR - 0x100 + 8, PROM_ENTRY_PADDR); |
142 |
|
store_64bit_word_in_host(cpu, (unsigned char *) |
143 |
|
&(crb.crb_v_fixup), CRB_ADDR - 0x80); |
144 |
|
store_64bit_word(cpu, CRB_ADDR - 0x80 + 8, PROM_ENTRY_PADDR + 0x800); |
145 |
|
|
146 |
|
/* PCS: Processor ID etc. */ |
147 |
|
for (i=0; i<machine->ncpus; i++) { |
148 |
|
memset(&pcs[i], 0, sizeof(struct pcs)); |
149 |
|
store_64bit_word_in_host(cpu, (unsigned char *) |
150 |
|
&(pcs[i].pcs_flags), PCS_RC | PCS_PA | PCS_PP | |
151 |
|
PCS_CV | PCS_PV | PCS_PMV | PCS_PL); |
152 |
|
store_64bit_word_in_host(cpu, (unsigned char *) |
153 |
|
&(pcs[i].pcs_proc_type), |
154 |
|
machine->cpus[i]->cd.alpha.cpu_type.pcs_type); |
155 |
|
} |
156 |
|
|
157 |
|
/* |
158 |
|
* MDDT: Memory Data Descriptor Table. For now, it is a simple |
159 |
|
* two-entry table with half of the available RAM in each entry. |
160 |
|
* (The values are in number of 8K pages.) |
161 |
|
* The first 16 MB are not included (the kernel lives there). |
162 |
|
* The last 1 MB is not included either, it is reserved for bootup |
163 |
|
* and similar. |
164 |
|
*/ |
165 |
|
memset(&mddt, 0, sizeof(struct mddt)); |
166 |
|
memset(&mddt.mddt_clusters[0], 0, sizeof(struct mddt_cluster)); |
167 |
|
memset(&mddt.mddt_clusters[1], 0, sizeof(struct mddt_cluster)); |
168 |
|
store_64bit_word_in_host(cpu, (unsigned char *) |
169 |
|
&(mddt.mddt_cluster_cnt), 2); |
170 |
|
store_64bit_word_in_host(cpu, (unsigned char *) |
171 |
|
&(mddt.mddt_clusters[0].mddt_pfn), 16 * 128); |
172 |
|
store_64bit_word_in_host(cpu, (unsigned char *) |
173 |
|
&(mddt.mddt_clusters[0].mddt_pg_cnt), |
174 |
|
(machine->physical_ram_in_mb/2 - 16) * 128); |
175 |
|
store_64bit_word_in_host(cpu, (unsigned char *) |
176 |
|
&(mddt.mddt_clusters[1].mddt_pfn), |
177 |
|
machine->physical_ram_in_mb/2 * 128); |
178 |
|
store_64bit_word_in_host(cpu, (unsigned char *) |
179 |
|
&(mddt.mddt_clusters[1].mddt_pg_cnt), |
180 |
|
(machine->physical_ram_in_mb/2) * 128); |
181 |
|
|
182 |
/* |
/* |
183 |
* Place a special "hack" palcode call at 0x10000: |
* Place a special "hack" palcode call at PROM_ENTRY_PADDR and |
184 |
|
* PROM_ENTRY_PADDR + 0x800: |
185 |
* (Hopefully nothing else will be there.) |
* (Hopefully nothing else will be there.) |
186 |
*/ |
*/ |
187 |
store_32bit_word(cpu, 0x10000, 0x3fffffe); |
store_32bit_word(cpu, PROM_ENTRY_PADDR, 0x3fffffe); |
188 |
|
store_32bit_word(cpu, PROM_ENTRY_PADDR + 0x800, 0x3fffffd); |
189 |
|
|
190 |
store_buf(cpu, HWRPB_ADDR, (char *)&rpb, sizeof(struct rpb)); |
store_buf(cpu, HWRPB_ADDR, (char *)&rpb, sizeof(struct rpb)); |
191 |
store_buf(cpu, CTB_ADDR, (char *)&ctb, sizeof(struct ctb)); |
store_buf(cpu, CTB_ADDR, (char *)&ctb, sizeof(struct ctb)); |
192 |
store_buf(cpu, CRB_ADDR, (char *)&crb, sizeof(struct crb)); |
store_buf(cpu, CRB_ADDR, (char *)&crb, sizeof(struct crb)); |
193 |
|
store_buf(cpu, MEMDAT_ADDR, (char *)&mddt, sizeof(struct mddt)); |
194 |
|
store_buf(cpu, PCS_ADDR, (char *)pcs, sizeof(struct pcs) * |
195 |
|
machine->ncpus); |
196 |
|
|
197 |
|
free(pcs); |
198 |
} |
} |
199 |
|
|
200 |
|
|
201 |
MACHINE_DEFAULT_CPU(alpha) |
MACHINE_DEFAULT_CPU(alpha) |
202 |
{ |
{ |
203 |
machine->cpu_name = strdup("Alpha"); |
switch (machine->machine_subtype) { |
204 |
|
|
205 |
|
case ST_ALPHABOOK1: |
206 |
|
machine->cpu_name = strdup("21066"); |
207 |
|
break; |
208 |
|
|
209 |
|
case ST_DEC_4100: |
210 |
|
machine->cpu_name = strdup("21164A-2"); |
211 |
|
break; |
212 |
|
|
213 |
|
case ST_DEC_3000_300: |
214 |
|
machine->cpu_name = strdup("21064"); |
215 |
|
break; |
216 |
|
|
217 |
|
case ST_EB164: |
218 |
|
machine->cpu_name = strdup("21164PC"); |
219 |
|
break; |
220 |
|
|
221 |
|
default:fatal("Unimplemented Alpha machine type %i\n", |
222 |
|
machine->machine_subtype); |
223 |
|
exit(1); |
224 |
|
} |
225 |
} |
} |
226 |
|
|
227 |
|
|
228 |
MACHINE_DEFAULT_RAM(alpha) |
MACHINE_DEFAULT_RAM(alpha) |
229 |
{ |
{ |
230 |
machine->physical_ram_in_mb = 64; |
machine->physical_ram_in_mb = 128; |
231 |
} |
} |
232 |
|
|
233 |
|
|
234 |
MACHINE_REGISTER(alpha) |
MACHINE_REGISTER(alpha) |
235 |
{ |
{ |
236 |
MR_DEFAULT(alpha, "Alpha", ARCH_ALPHA, MACHINE_ALPHA, 1, 2); |
MR_DEFAULT(alpha, "Alpha", ARCH_ALPHA, MACHINE_ALPHA); |
237 |
me->aliases[0] = "alpha"; |
|
238 |
me->subtype[0] = machine_entry_subtype_new("DEC 3000/300", |
machine_entry_add_alias(me, "alpha"); |
239 |
ST_DEC_3000_300, 1); |
|
240 |
me->subtype[0]->aliases[0] = "3000/300"; |
machine_entry_add_subtype(me, "AlphaBook 1", ST_ALPHABOOK1, |
241 |
me->subtype[1] = machine_entry_subtype_new("EB164", ST_EB164, 1); |
"alphabook1", NULL); |
242 |
me->subtype[1]->aliases[0] = "eb164"; |
|
243 |
|
machine_entry_add_subtype(me, "AlphaServer 4100", ST_DEC_4100, |
244 |
|
"alphaserver4100", NULL); |
245 |
|
|
246 |
|
machine_entry_add_subtype(me, "DEC 3000/300", ST_DEC_3000_300, |
247 |
|
"3000/300", NULL); |
248 |
|
|
249 |
|
machine_entry_add_subtype(me, "EB164", ST_EB164, |
250 |
|
"eb164", NULL); |
251 |
|
|
252 |
me->set_default_ram = machine_default_ram_alpha; |
me->set_default_ram = machine_default_ram_alpha; |
|
machine_entry_add(me, ARCH_ALPHA); |
|
253 |
} |
} |
254 |
|
|