Sat Aug 7 06:16:22 2010 UTC ()
Remove unnecessary line.
Variable openpic_base exists, if defined PIC_OPENPIC.


(kiyohara)
diff -r1.70 -r1.71 src/sys/arch/prep/prep/machdep.c

cvs diff -r1.70 -r1.71 src/sys/arch/prep/prep/machdep.c (switch to unified diff)

--- src/sys/arch/prep/prep/machdep.c 2009/11/27 03:23:12 1.70
+++ src/sys/arch/prep/prep/machdep.c 2010/08/07 06:16:22 1.71
@@ -1,482 +1,483 @@ @@ -1,482 +1,483 @@
1/* $NetBSD: machdep.c,v 1.70 2009/11/27 03:23:12 rmind Exp $ */ 1/* $NetBSD: machdep.c,v 1.71 2010/08/07 06:16:22 kiyohara Exp $ */
2 2
3/* 3/*
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank. 4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH. 5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution. 15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software 16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement: 17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH. 18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products 19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission. 20 * derived from this software without specific prior written permission.
21 * 21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34#include <sys/cdefs.h> 34#include <sys/cdefs.h>
35__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.70 2009/11/27 03:23:12 rmind Exp $"); 35__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.71 2010/08/07 06:16:22 kiyohara Exp $");
36 36
37#include "opt_compat_netbsd.h" 37#include "opt_compat_netbsd.h"
38#include "opt_openpic.h" 38#include "opt_openpic.h"
39 39
40#include <sys/param.h> 40#include <sys/param.h>
41#include <sys/buf.h> 41#include <sys/buf.h>
42#include <sys/conf.h> 42#include <sys/conf.h>
43#include <sys/device.h> 43#include <sys/device.h>
44#include <sys/exec.h> 44#include <sys/exec.h>
45#include <sys/extent.h> 45#include <sys/extent.h>
46#include <sys/kernel.h> 46#include <sys/kernel.h>
47#include <sys/malloc.h> 47#include <sys/malloc.h>
48#include <sys/mbuf.h> 48#include <sys/mbuf.h>
49#include <sys/mount.h> 49#include <sys/mount.h>
50#include <sys/msgbuf.h> 50#include <sys/msgbuf.h>
51#include <sys/proc.h> 51#include <sys/proc.h>
52#include <sys/reboot.h> 52#include <sys/reboot.h>
53#include <sys/syscallargs.h> 53#include <sys/syscallargs.h>
54#include <sys/syslog.h> 54#include <sys/syslog.h>
55#include <sys/systm.h> 55#include <sys/systm.h>
56 56
57#include <uvm/uvm_extern.h> 57#include <uvm/uvm_extern.h>
58 58
59#include <sys/sysctl.h> 59#include <sys/sysctl.h>
60 60
61#include <net/netisr.h> 61#include <net/netisr.h>
62 62
63#include <machine/autoconf.h> 63#include <machine/autoconf.h>
64#include <machine/bootinfo.h> 64#include <machine/bootinfo.h>
65#include <machine/bus.h> 65#include <machine/bus.h>
66#include <machine/intr.h> 66#include <machine/intr.h>
67#include <machine/pmap.h> 67#include <machine/pmap.h>
68#include <machine/platform.h> 68#include <machine/platform.h>
69#include <machine/powerpc.h> 69#include <machine/powerpc.h>
70#include <machine/residual.h> 70#include <machine/residual.h>
71#include <machine/trap.h> 71#include <machine/trap.h>
72 72
73#include <powerpc/oea/bat.h> 73#include <powerpc/oea/bat.h>
74#include <powerpc/openpic.h> 74#include <powerpc/openpic.h>
75#include <arch/powerpc/pic/picvar.h> 75#include <arch/powerpc/pic/picvar.h>
76#ifdef MULTIPROCESSOR 76#ifdef MULTIPROCESSOR
77#include <arch/powerpc/pic/ipivar.h> 77#include <arch/powerpc/pic/ipivar.h>
78#endif 78#endif
79 79
80#include <dev/cons.h> 80#include <dev/cons.h>
81 81
82#include "com.h" 82#include "com.h"
83#if (NCOM > 0) 83#if (NCOM > 0)
84#include <sys/termios.h> 84#include <sys/termios.h>
85#include <dev/ic/comreg.h> 85#include <dev/ic/comreg.h>
86#include <dev/ic/comvar.h> 86#include <dev/ic/comvar.h>
87#endif 87#endif
88 88
89#include "opt_interrupt.h" 89#include "opt_interrupt.h"
90 90
91void initppc(u_long, u_long, u_int, void *); 91void initppc(u_long, u_long, u_int, void *);
92void dumpsys(void); 92void dumpsys(void);
93static void prep_init(void); 93static void prep_init(void);
94static void init_intr(void); 94static void init_intr(void);
95 95
96char bootinfo[BOOTINFO_MAXSIZE]; 96char bootinfo[BOOTINFO_MAXSIZE];
97char bootpath[256]; 97char bootpath[256];
98 98
99vaddr_t prep_intr_reg; /* PReP interrupt vector register */ 99vaddr_t prep_intr_reg; /* PReP interrupt vector register */
100uint32_t prep_intr_reg_off; /* IVR offset within the mapped page */ 100uint32_t prep_intr_reg_off; /* IVR offset within the mapped page */
101 101
102#define OFMEMREGIONS 32 102#define OFMEMREGIONS 32
103struct mem_region physmemr[OFMEMREGIONS], availmemr[OFMEMREGIONS]; 103struct mem_region physmemr[OFMEMREGIONS], availmemr[OFMEMREGIONS];
104 104
105paddr_t avail_end; /* XXX temporary */ 105paddr_t avail_end; /* XXX temporary */
106struct pic_ops *isa_pic; 106struct pic_ops *isa_pic;
107int isa_pcmciamask = 0x8b28; 107int isa_pcmciamask = 0x8b28;
108uint32_t busfreq; 108uint32_t busfreq;
109 109
110extern int primary_pic; 110extern int primary_pic;
111extern struct platform_quirkdata platform_quirks[]; 111extern struct platform_quirkdata platform_quirks[];
112 112
113RESIDUAL *res; 113RESIDUAL *res;
114RESIDUAL resdata; 114RESIDUAL resdata;
115 115
116void 116void
117initppc(u_long startkernel, u_long endkernel, u_int args, void *btinfo) 117initppc(u_long startkernel, u_long endkernel, u_int args, void *btinfo)
118{ 118{
119 119
120 /* 120 /*
121 * copy bootinfo 121 * copy bootinfo
122 */ 122 */
123 memcpy(bootinfo, btinfo, sizeof(bootinfo)); 123 memcpy(bootinfo, btinfo, sizeof(bootinfo));
124 124
125 /* 125 /*
126 * copy residual data 126 * copy residual data
127 */ 127 */
128 { 128 {
129 struct btinfo_residual *resinfo; 129 struct btinfo_residual *resinfo;
130 130
131 resinfo = 131 resinfo =
132 (struct btinfo_residual *)lookup_bootinfo(BTINFO_RESIDUAL); 132 (struct btinfo_residual *)lookup_bootinfo(BTINFO_RESIDUAL);
133 if (!resinfo) 133 if (!resinfo)
134 panic("not found residual information in bootinfo"); 134 panic("not found residual information in bootinfo");
135 135
136 if (((RESIDUAL *)resinfo->addr != 0) && 136 if (((RESIDUAL *)resinfo->addr != 0) &&
137 ((RESIDUAL *)resinfo->addr)->ResidualLength != 0) { 137 ((RESIDUAL *)resinfo->addr)->ResidualLength != 0) {
138 memcpy(&resdata, resinfo->addr, sizeof(resdata)); 138 memcpy(&resdata, resinfo->addr, sizeof(resdata));
139 res = &resdata; 139 res = &resdata;
140 } else 140 } else
141 panic("No residual data."); 141 panic("No residual data.");
142 } 142 }
143 aprint_normal("got residual data\n"); 143 aprint_normal("got residual data\n");
144 144
145 /* 145 /*
146 * Set memory region 146 * Set memory region
147 */ 147 */
148 { 148 {
149 u_long memsize = res->TotalMemory; 149 u_long memsize = res->TotalMemory;
150 150
151 physmemr[0].start = 0; 151 physmemr[0].start = 0;
152 physmemr[0].size = memsize & ~PGOFSET; 152 physmemr[0].size = memsize & ~PGOFSET;
153 availmemr[0].start = (endkernel + PGOFSET) & ~PGOFSET; 153 availmemr[0].start = (endkernel + PGOFSET) & ~PGOFSET;
154 availmemr[0].size = memsize - availmemr[0].start; 154 availmemr[0].size = memsize - availmemr[0].start;
155 } 155 }
156 avail_end = physmemr[0].start + physmemr[0].size; /* XXX temporary */ 156 avail_end = physmemr[0].start + physmemr[0].size; /* XXX temporary */
157 157
158 /* 158 /*
159 * Set CPU clock 159 * Set CPU clock
160 */ 160 */
161 { 161 {
162 struct btinfo_clock *clockinfo; 162 struct btinfo_clock *clockinfo;
163 extern u_long ticks_per_sec, ns_per_tick; 163 extern u_long ticks_per_sec, ns_per_tick;
164 VPD *vpd; 164 VPD *vpd;
165 165
166 clockinfo = 166 clockinfo =
167 (struct btinfo_clock *)lookup_bootinfo(BTINFO_CLOCK); 167 (struct btinfo_clock *)lookup_bootinfo(BTINFO_CLOCK);
168 if (!clockinfo) 168 if (!clockinfo)
169 panic("not found clock information in bootinfo"); 169 panic("not found clock information in bootinfo");
170 170
171 ticks_per_sec = clockinfo->ticks_per_sec; 171 ticks_per_sec = clockinfo->ticks_per_sec;
172 ns_per_tick = 1000000000 / ticks_per_sec; 172 ns_per_tick = 1000000000 / ticks_per_sec;
173 173
174 vpd = &res->VitalProductData; 174 vpd = &res->VitalProductData;
175 busfreq = be32toh(vpd->ProcessorBusHz); 175 busfreq = be32toh(vpd->ProcessorBusHz);
176 } 176 }
177 177
178 prep_initppc(startkernel, endkernel, args); 178 prep_initppc(startkernel, endkernel, args);
179} 179}
180 180
181/* 181/*
182 * Machine dependent startup code. 182 * Machine dependent startup code.
183 */ 183 */
184void 184void
185cpu_startup(void) 185cpu_startup(void)
186{ 186{
187 /* 187 /*
188 * Do common startup. 188 * Do common startup.
189 */ 189 */
190 oea_startup(res->VitalProductData.PrintableModel); 190 oea_startup(res->VitalProductData.PrintableModel);
191 191
192 /* 192 /*
193 * General prep setup using pnp residual. Also provides for 193 * General prep setup using pnp residual. Also provides for
194 * external interrupt handler install 194 * external interrupt handler install
195 */ 195 */
196 prep_init(); 196 prep_init();
197 197
198 /* 198 /*
199 * Now allow hardware interrupts. 199 * Now allow hardware interrupts.
200 */ 200 */
201 { 201 {
202 int msr; 202 int msr;
203 203
204 splraise(-1); 204 splraise(-1);
205 __asm volatile ("mfmsr %0; ori %0,%0,%1; mtmsr %0" 205 __asm volatile ("mfmsr %0; ori %0,%0,%1; mtmsr %0"
206 : "=r"(msr) : "K"(PSL_EE)); 206 : "=r"(msr) : "K"(PSL_EE));
207 } 207 }
208 /* 208 /*
209 * Now safe for bus space allocation to use malloc. 209 * Now safe for bus space allocation to use malloc.
210 */ 210 */
211 bus_space_mallocok(); 211 bus_space_mallocok();
212 212
213 /* 213 /*
214 * Gather the pci interrupt routings. 214 * Gather the pci interrupt routings.
215 */ 215 */
216 setup_pciroutinginfo(); 216 setup_pciroutinginfo();
217 217
218} 218}
219 219
220/* 220/*
221 * lookup_bootinfo: 221 * lookup_bootinfo:
222 * Look up information in bootinfo of boot loader. 222 * Look up information in bootinfo of boot loader.
223 */ 223 */
224void * 224void *
225lookup_bootinfo(int type) 225lookup_bootinfo(int type)
226{ 226{
227 struct btinfo_common *bt; 227 struct btinfo_common *bt;
228 struct btinfo_common *help = (struct btinfo_common *)bootinfo; 228 struct btinfo_common *help = (struct btinfo_common *)bootinfo;
229 229
230 do { 230 do {
231 bt = help; 231 bt = help;
232 if (bt->type == type) 232 if (bt->type == type)
233 return (help); 233 return (help);
234 help = (struct btinfo_common *)((char*)help + bt->next); 234 help = (struct btinfo_common *)((char*)help + bt->next);
235 } while (bt->next && 235 } while (bt->next &&
236 (size_t)help < (size_t)bootinfo + sizeof (bootinfo)); 236 (size_t)help < (size_t)bootinfo + sizeof (bootinfo));
237 237
238 return (NULL); 238 return (NULL);
239} 239}
240 240
241/* 241/*
242 * Halt or reboot the machine after syncing/dumping according to howto. 242 * Halt or reboot the machine after syncing/dumping according to howto.
243 */ 243 */
244void 244void
245cpu_reboot(int howto, char *what) 245cpu_reboot(int howto, char *what)
246{ 246{
247 static int syncing; 247 static int syncing;
248 248
249 if (cold) { 249 if (cold) {
250 howto |= RB_HALT; 250 howto |= RB_HALT;
251 goto halt_sys; 251 goto halt_sys;
252 } 252 }
253 253
254 boothowto = howto; 254 boothowto = howto;
255 if ((howto & RB_NOSYNC) == 0 && syncing == 0) { 255 if ((howto & RB_NOSYNC) == 0 && syncing == 0) {
256 syncing = 1; 256 syncing = 1;
257 vfs_shutdown(); /* sync */ 257 vfs_shutdown(); /* sync */
258 resettodr(); /* set wall clock */ 258 resettodr(); /* set wall clock */
259 } 259 }
260 260
261 /* Disable intr */ 261 /* Disable intr */
262 splhigh(); 262 splhigh();
263 263
264#ifdef MULTIPROCESSOR 264#ifdef MULTIPROCESSOR
265 /* Halt other CPUs */ 265 /* Halt other CPUs */
266 ppc_send_ipi(IPI_T_NOTME, PPC_IPI_HALT); 266 ppc_send_ipi(IPI_T_NOTME, PPC_IPI_HALT);
267 delay(100000); /* XXX */ 267 delay(100000); /* XXX */
268#endif 268#endif
269 269
270 /* Do dump if requested */ 270 /* Do dump if requested */
271 if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP) 271 if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP)
272 oea_dumpsys(); 272 oea_dumpsys();
273 273
274halt_sys: 274halt_sys:
275 doshutdownhooks(); 275 doshutdownhooks();
276 276
277 pmf_system_shutdown(boothowto); 277 pmf_system_shutdown(boothowto);
278 278
279 if (howto & RB_HALT) { 279 if (howto & RB_HALT) {
280 printf("\n"); 280 printf("\n");
281 printf("The operating system has halted.\n"); 281 printf("The operating system has halted.\n");
282 printf("Please press any key to reboot.\n\n"); 282 printf("Please press any key to reboot.\n\n");
283 cnpollc(1); /* for proper keyboard command handling */ 283 cnpollc(1); /* for proper keyboard command handling */
284 cngetc(); 284 cngetc();
285 cnpollc(0); 285 cnpollc(0);
286 } 286 }
287 287
288 printf("rebooting...\n\n"); 288 printf("rebooting...\n\n");
289 289
290 reset_prep(); 290 reset_prep();
291 291
292 for (;;) 292 for (;;)
293 continue; 293 continue;
294 /* NOTREACHED */ 294 /* NOTREACHED */
295} 295}
296 296
297struct powerpc_bus_space prep_eisa_io_space_tag = { 297struct powerpc_bus_space prep_eisa_io_space_tag = {
298 .pbs_flags = _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE, 298 .pbs_flags = _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
299 .pbs_offset = 0x80000000, 299 .pbs_offset = 0x80000000,
300 .pbs_base = 0x00000000, 300 .pbs_base = 0x00000000,
301 .pbs_limit = 0x0000f000, 301 .pbs_limit = 0x0000f000,
302}; 302};
303 303
304struct powerpc_bus_space prep_eisa_mem_space_tag = { 304struct powerpc_bus_space prep_eisa_mem_space_tag = {
305 .pbs_flags = _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE, 305 .pbs_flags = _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
306 .pbs_offset = 0xC0000000, 306 .pbs_offset = 0xC0000000,
307 .pbs_base = 0x00000000, 307 .pbs_base = 0x00000000,
308 .pbs_limit = 0x3f000000, 308 .pbs_limit = 0x3f000000,
309}; 309};
310 310
311#if defined(PIC_OPENPIC) 311#if defined(PIC_OPENPIC)
312 312
313static int 313static int
314prep_setup_openpic(PPC_DEVICE *dev) 314prep_setup_openpic(PPC_DEVICE *dev)
315{ 315{
316 uint32_t l; 316 uint32_t l;
317 uint8_t *p; 317 uint8_t *p;
318 void *v; 318 void *v;
319 int tag, size, item, i; 319 int tag, size, item, i;
320 unsigned char *baseaddr = NULL; 320 unsigned char *baseaddr = NULL;
321 321
322 l = be32toh(dev->AllocatedOffset); 322 l = be32toh(dev->AllocatedOffset);
323 p = res->DevicePnPHeap + l; 323 p = res->DevicePnPHeap + l;
324 324
325 i = find_platform_quirk(res->VitalProductData.PrintableModel); 325 i = find_platform_quirk(res->VitalProductData.PrintableModel);
326 326
327 /* look for the large vendor item that describes the MPIC's memory 327 /* look for the large vendor item that describes the MPIC's memory
328 * range */ 328 * range */
329 for (; p[0] != END_TAG; p += size) { 329 for (; p[0] != END_TAG; p += size) {
330 struct _L4_Pack *pack = (void *)p; 330 struct _L4_Pack *pack = (void *)p;
331 struct _L4_PPCPack *pa = &pack->L4_Data.L4_PPCPack; 331 struct _L4_PPCPack *pa = &pack->L4_Data.L4_PPCPack;
332 332
333 tag = *p; 333 tag = *p;
334 v = p; 334 v = p;
335 if (tag_type(p[0]) == PNP_SMALL) { 335 if (tag_type(p[0]) == PNP_SMALL) {
336 size = tag_small_count(tag) + 1; 336 size = tag_small_count(tag) + 1;
337 continue; 337 continue;
338 } 338 }
339 size = (p[1] | (p[2] << 8)) + 3 /* tag + length */; 339 size = (p[1] | (p[2] << 8)) + 3 /* tag + length */;
340 item = tag_large_item_name(tag); 340 item = tag_large_item_name(tag);
341 if (item != LargeVendorItem || pa->Type != LV_GenericAddress) 341 if (item != LargeVendorItem || pa->Type != LV_GenericAddress)
342 continue; 342 continue;
343 /* otherwise, we have a memory packet */ 343 /* otherwise, we have a memory packet */
344 if (pa->PPCData[0] == 1) 344 if (pa->PPCData[0] == 1)
345 baseaddr = (unsigned char *)mapiodev( 345 baseaddr = (unsigned char *)mapiodev(
346 le64dec(&pa->PPCData[4]) | PREP_BUS_SPACE_IO, 346 le64dec(&pa->PPCData[4]) | PREP_BUS_SPACE_IO,
347 le64dec(&pa->PPCData[12])); 347 le64dec(&pa->PPCData[12]));
348 else if (pa->PPCData[0] == 2) 348 else if (pa->PPCData[0] == 2)
349 baseaddr = (unsigned char *)mapiodev( 349 baseaddr = (unsigned char *)mapiodev(
350 le64dec(&pa->PPCData[4]) | PREP_BUS_SPACE_MEM, 350 le64dec(&pa->PPCData[4]) | PREP_BUS_SPACE_MEM,
351 le64dec(&pa->PPCData[12])); 351 le64dec(&pa->PPCData[12]));
352 if (baseaddr == NULL) 352 if (baseaddr == NULL)
353 return 0; 353 return 0;
354 pic_init(); 354 pic_init();
355 if (i != -1 && 355 if (i != -1 &&
356 (platform_quirks[i].quirk & PLAT_QUIRK_ISA_HANDLER && 356 (platform_quirks[i].quirk & PLAT_QUIRK_ISA_HANDLER &&
357 platform_quirks[i].isa_intr_handler == EXT_INTR_I8259)) { 357 platform_quirks[i].isa_intr_handler == EXT_INTR_I8259)) {
358 isa_pic = setup_prepivr(PIC_IVR_MOT); 358 isa_pic = setup_prepivr(PIC_IVR_MOT);
359 } else 359 } else
360 isa_pic = setup_prepivr(PIC_IVR_IBM); 360 isa_pic = setup_prepivr(PIC_IVR_IBM);
361 (void)setup_openpic(baseaddr, 0); 361 (void)setup_openpic(baseaddr, 0);
362 /* set the timebase frequency to 1/8th busfreq */ 362 /* set the timebase frequency to 1/8th busfreq */
363 openpic_write(OPENPIC_TIMER_FREQ, busfreq/8); 363 openpic_write(OPENPIC_TIMER_FREQ, busfreq/8);
364 primary_pic = 1; 364 primary_pic = 1;
365 /* set up the IVR as a cascade on openpic 0 */ 365 /* set up the IVR as a cascade on openpic 0 */
366 intr_establish(16, IST_LEVEL, IPL_NONE, pic_handle_intr, 366 intr_establish(16, IST_LEVEL, IPL_NONE, pic_handle_intr,
367 isa_pic); 367 isa_pic);
368 oea_install_extint(pic_ext_intr); 368 oea_install_extint(pic_ext_intr);
369#ifdef MULTIPROCESSOR 369#ifdef MULTIPROCESSOR
370 setup_openpic_ipi(); 370 setup_openpic_ipi();
371#endif 371#endif
372 return 1; 372 return 1;
373 } 373 }
374 return 0; 374 return 0;
375} 375}
376 376
377#endif /* PIC_OPENPIC */ 377#endif /* PIC_OPENPIC */
378 378
379/* 379/*
380 * Locate and setup the isa_ivr. 380 * Locate and setup the isa_ivr.
381 */ 381 */
382 382
383static void 383static void
384setup_ivr(PPC_DEVICE *dev) 384setup_ivr(PPC_DEVICE *dev)
385{ 385{
386 uint32_t l, addr; 386 uint32_t l, addr;
387 uint8_t *p; 387 uint8_t *p;
388 void *v; 388 void *v;
389 int tag, size, item; 389 int tag, size, item;
390 390
391 l = be32toh(dev->AllocatedOffset); 391 l = be32toh(dev->AllocatedOffset);
392 p = res->DevicePnPHeap + l; 392 p = res->DevicePnPHeap + l;
393 393
394 /* Find the IVR vector's Generic Address in a LVI */ 394 /* Find the IVR vector's Generic Address in a LVI */
395 for (; p[0] != END_TAG; p += size) { 395 for (; p[0] != END_TAG; p += size) {
396 struct _L4_Pack *pack = (void *)p; 396 struct _L4_Pack *pack = (void *)p;
397 struct _L4_PPCPack *pa = &pack->L4_Data.L4_PPCPack; 397 struct _L4_PPCPack *pa = &pack->L4_Data.L4_PPCPack;
398 398
399 tag = *p; 399 tag = *p;
400 v = p; 400 v = p;
401 if (tag_type(p[0]) == PNP_SMALL) { 401 if (tag_type(p[0]) == PNP_SMALL) {
402 size = tag_small_count(tag) + 1; 402 size = tag_small_count(tag) + 1;
403 continue; 403 continue;
404 } 404 }
405 size = (p[1] | (p[2] << 8)) + 3 /* tag + length */; 405 size = (p[1] | (p[2] << 8)) + 3 /* tag + length */;
406 item = tag_large_item_name(tag); 406 item = tag_large_item_name(tag);
407 if (item != LargeVendorItem || pa->Type != LV_GenericAddress) 407 if (item != LargeVendorItem || pa->Type != LV_GenericAddress)
408 continue; 408 continue;
409 /* otherwise we have a memory packet */ 409 /* otherwise we have a memory packet */
410 addr = le64dec(&pa->PPCData[4]) & ~(PAGE_SIZE-1); 410 addr = le64dec(&pa->PPCData[4]) & ~(PAGE_SIZE-1);
411 prep_intr_reg_off = le64dec(&pa->PPCData[4]) & (PAGE_SIZE-1);  411 prep_intr_reg_off = le64dec(&pa->PPCData[4]) & (PAGE_SIZE-1);
412 prep_intr_reg = (vaddr_t)mapiodev(addr, PAGE_SIZE); 412 prep_intr_reg = (vaddr_t)mapiodev(addr, PAGE_SIZE);
413 if (!prep_intr_reg) 413 if (!prep_intr_reg)
414 panic("startup: no room for interrupt register"); 414 panic("startup: no room for interrupt register");
415 return; 415 return;
416 } 416 }
417} 417}
418 418
419/* 419/*
420 * There are a few things that need setting up early on in the prep  420 * There are a few things that need setting up early on in the prep
421 * architecture. Foremost of these is the MPIC (if present) and the 421 * architecture. Foremost of these is the MPIC (if present) and the
422 * l2 cache controller. This is a cut-down version of pnpbus_search() 422 * l2 cache controller. This is a cut-down version of pnpbus_search()
423 * that looks for specific devices, and sets them up accordingly. 423 * that looks for specific devices, and sets them up accordingly.
424 * This should also look for and wire up the interrupt vector. 424 * This should also look for and wire up the interrupt vector.
425 */ 425 */
426 426
427static void 427static void
428prep_init(void) 428prep_init(void)
429{ 429{
430 PPC_DEVICE *ppc_dev; 430 PPC_DEVICE *ppc_dev;
431 int i, foundmpic; 431 int i, foundmpic;
432 uint32_t ndev; 432 uint32_t ndev;
433 433
434 ndev = be32toh(res->ActualNumDevices); 434 ndev = be32toh(res->ActualNumDevices);
435 ppc_dev = res->Devices; 435 ppc_dev = res->Devices;
436 foundmpic = 0; 436 foundmpic = 0;
437 prep_intr_reg = 0; 437 prep_intr_reg = 0;
438 438
439 for (i = 0; i < ((ndev > MAX_DEVICES) ? MAX_DEVICES : ndev); i++) { 439 for (i = 0; i < ((ndev > MAX_DEVICES) ? MAX_DEVICES : ndev); i++) {
440 if (ppc_dev[i].DeviceId.DevId == 0x41d00000) /* ISA_PIC */ 440 if (ppc_dev[i].DeviceId.DevId == 0x41d00000) /* ISA_PIC */
441 setup_ivr(&ppc_dev[i]); 441 setup_ivr(&ppc_dev[i]);
442#if defined(PIC_OPENPIC) 442#if defined(PIC_OPENPIC)
443 if (ppc_dev[i].DeviceId.DevId == 0x244d000d) { /* MPIC */ 443 if (ppc_dev[i].DeviceId.DevId == 0x244d000d) { /* MPIC */
444 foundmpic = prep_setup_openpic(&ppc_dev[i]); 444 foundmpic = prep_setup_openpic(&ppc_dev[i]);
445 } 445 }
446#else 
447 ; 
448#endif 446#endif
449 447
450 } 448 }
451 if (!prep_intr_reg) { 449 if (!prep_intr_reg) {
452 /* 450 /*
453 * For some reason we never found one, this is known to 451 * For some reason we never found one, this is known to
454 * occur on certain motorola VME boards. Instead we need 452 * occur on certain motorola VME boards. Instead we need
455 * to just hardcode it. 453 * to just hardcode it.
456 */ 454 */
457 prep_intr_reg = (vaddr_t) mapiodev(PREP_INTR_REG, PAGE_SIZE); 455 prep_intr_reg = (vaddr_t) mapiodev(PREP_INTR_REG, PAGE_SIZE);
458 if (!prep_intr_reg) 456 if (!prep_intr_reg)
459 panic("startup: no room for interrupt register"); 457 panic("startup: no room for interrupt register");
460 prep_intr_reg_off = INTR_VECTOR_REG; 458 prep_intr_reg_off = INTR_VECTOR_REG;
461 } 459 }
462 if (!foundmpic) 460 if (!foundmpic)
463 init_intr(); 461 init_intr();
464} 462}
465 463
466static void 464static void
467init_intr(void) 465init_intr(void)
468{ 466{
469 int i; 467 int i;
 468
 469#if defined(PIC_OPENPIC)
470 openpic_base = 0; 470 openpic_base = 0;
 471#endif
471 472
472 pic_init(); 473 pic_init();
473 i = find_platform_quirk(res->VitalProductData.PrintableModel); 474 i = find_platform_quirk(res->VitalProductData.PrintableModel);
474 if (i != -1) 475 if (i != -1)
475 if (platform_quirks[i].quirk & PLAT_QUIRK_ISA_HANDLER && 476 if (platform_quirks[i].quirk & PLAT_QUIRK_ISA_HANDLER &&
476 platform_quirks[i].isa_intr_handler == EXT_INTR_I8259) { 477 platform_quirks[i].isa_intr_handler == EXT_INTR_I8259) {
477 isa_pic = setup_prepivr(PIC_IVR_MOT); 478 isa_pic = setup_prepivr(PIC_IVR_MOT);
478 return; 479 return;
479 } 480 }
480 isa_pic = setup_prepivr(PIC_IVR_IBM); 481 isa_pic = setup_prepivr(PIC_IVR_IBM);
481 oea_install_extint(pic_ext_intr); 482 oea_install_extint(pic_ext_intr);
482} 483}