Annotation of src/sys/arch/ibmnws/ibmnws/machdep.c, Revision 1.8.14.3
1.8.14.3! garbled 1: /* $NetBSD: machdep.c,v 1.8.14.2 2007/05/09 13:41:56 rjs Exp $ */
1.1 matt 2:
3: /*
4: * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5: * Copyright (C) 1995, 1996 TooLs GmbH.
6: * All rights reserved.
7: *
8: * Redistribution and use in source and binary forms, with or without
9: * modification, are permitted provided that the following conditions
10: * are met:
11: * 1. Redistributions of source code must retain the above copyright
12: * notice, this list of conditions and the following disclaimer.
13: * 2. Redistributions in binary form must reproduce the above copyright
14: * notice, this list of conditions and the following disclaimer in the
15: * documentation and/or other materials provided with the distribution.
16: * 3. All advertising materials mentioning features or use of this software
17: * must display the following acknowledgement:
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
20: * derived from this software without specific prior written permission.
21: *
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
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,
26: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
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,
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
31: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32: */
33:
1.8.14.1 rjs 34: #include <sys/cdefs.h>
1.8.14.3! garbled 35: __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.8.14.2 2007/05/09 13:41:56 rjs Exp $");
1.8.14.1 rjs 36:
1.1 matt 37: #include "opt_compat_netbsd.h"
38: #include "opt_ddb.h"
39:
40: #include <sys/param.h>
41: #include <sys/buf.h>
42: #include <sys/conf.h>
43: #include <sys/device.h>
44: #include <sys/exec.h>
45: #include <sys/extent.h>
46: #include <sys/kernel.h>
47: #include <sys/malloc.h>
48: #include <sys/mbuf.h>
49: #include <sys/mount.h>
50: #include <sys/msgbuf.h>
51: #include <sys/proc.h>
52: #include <sys/reboot.h>
53: #include <sys/syscallargs.h>
54: #include <sys/syslog.h>
55: #include <sys/systm.h>
56: #include <sys/user.h>
1.7 rjs 57: #include <sys/ksyms.h>
1.1 matt 58:
59: #include <uvm/uvm_extern.h>
60:
61: #include <sys/sysctl.h>
62:
63: #include <net/netisr.h>
64:
65: #include <machine/autoconf.h>
66: #include <machine/bus.h>
67: #include <machine/intr.h>
68: #include <machine/pmap.h>
69: #include <machine/powerpc.h>
70: #include <machine/trap.h>
1.2 matt 71:
72: #include <powerpc/oea/bat.h>
1.8.14.1 rjs 73: #include <arch/powerpc/pic/picvar.h>
1.1 matt 74:
75: #include <dev/cons.h>
76:
77: #ifdef DDB
78: #include <machine/db_machdep.h>
79: #include <ddb/db_extern.h>
80: #endif
81:
1.7 rjs 82: #include "ksyms.h"
83:
1.1 matt 84: void initppc(u_long, u_long, u_int, void *);
85: void dumpsys(void);
86: void ibmnws_bus_space_init(void);
87:
88: vaddr_t prep_intr_reg; /* PReP interrupt vector register */
89:
90: #define OFMEMREGIONS 32
91: struct mem_region physmemr[OFMEMREGIONS], availmemr[OFMEMREGIONS];
92:
93: paddr_t avail_end; /* XXX temporary */
1.8.14.1 rjs 94: struct pic_ops *isa_pic;
95: int isa_pcmciamask = 0x8b28;
1.1 matt 96:
1.7 rjs 97: #if NKSYMS || defined(DDB) || defined(LKM)
1.1 matt 98: extern void *endsym, *startsym;
99: #endif
100:
101: void
1.6 rjs 102: initppc(u_long startkernel, u_long endkernel, u_int args, void *btinfo)
1.1 matt 103: {
104:
105: /*
106: * Set memory region
107: */
108: {
109: u_long memsize;
110:
111: #if 0
112: /* Get the memory size from the PCI host bridge */
113:
114: pci_read_config_32(0, 0x90, &ea);
115: if(ea & 0xff00)
116: memsize = (((ea >> 8) & 0xff) + 1) << 20;
117: else
118: memsize = ((ea & 0xff) + 1) << 20;
119: #else
120: memsize = 64 * 1024 * 1024; /* 64MB hardcoded for now */
121: #endif
122:
123: physmemr[0].start = 0;
124: physmemr[0].size = memsize & ~PGOFSET;
125: availmemr[0].start = (endkernel + PGOFSET) & ~PGOFSET;
126: availmemr[0].size = memsize - availmemr[0].start;
127: }
128: avail_end = physmemr[0].start + physmemr[0].size; /* XXX temporary */
129:
130: /*
131: * Set CPU clock
132: */
133: {
134: extern u_long ticks_per_sec, ns_per_tick;
135:
136: ticks_per_sec = 16666666; /* hardcoded */
137: ns_per_tick = 1000000000 / ticks_per_sec;
138: }
139:
140: /* Initialize the CPU type */
141: /* ident_platform(); */
142:
143: /*
144: * boothowto
145: */
146: boothowto = 0; /* XXX - should make this an option */
147:
148: /*
149: * Initialize bus_space.
150: */
151: ibmnws_bus_space_init();
152:
153: /*
154: * Now setup fixed bat registers
155: */
156: oea_batinit(
157: PREP_BUS_SPACE_MEM, BAT_BL_256M,
158: PREP_BUS_SPACE_IO, BAT_BL_256M,
159: 0);
160:
161: /*
162: * i386 port says, that this shouldn't be here,
163: * but I really think the console should be initialized
164: * as early as possible.
165: */
166: consinit();
167:
168: /*
1.8.14.1 rjs 169: * Install vectors and interrupt handler.
1.1 matt 170: */
1.8.14.1 rjs 171: oea_init(NULL);
1.1 matt 172:
173: /*
174: * Set the page size.
175: */
176: uvm_setpagesize();
177:
178: /*
179: * Initialize pmap module.
180: */
181: pmap_bootstrap(startkernel, endkernel);
182:
1.7 rjs 183: #if NKSYMS || defined(DDB) || defined(LKM)
184: ksyms_init((int)((u_long)endsym - (u_long)startsym), startsym, endsym);
185: #endif
186:
1.1 matt 187: #ifdef DDB
188: if (boothowto & RB_KDB)
189: Debugger();
190: #endif
191: }
192:
193: void
1.6 rjs 194: mem_regions(struct mem_region **mem, struct mem_region **avail)
1.1 matt 195: {
196:
197: *mem = physmemr;
198: *avail = availmemr;
199: }
200:
201: /*
202: * Machine dependent startup code.
203: */
204: void
1.6 rjs 205: cpu_startup(void)
1.1 matt 206: {
207: /*
208: * Mapping PReP interrput vector register.
209: */
210: prep_intr_reg = (vaddr_t) mapiodev(PREP_INTR_REG, PAGE_SIZE);
211: if (!prep_intr_reg)
212: panic("startup: no room for interrupt register");
1.8.14.2 rjs 213: prep_intr_reg_off = INTR_VECTOR_REG;
1.1 matt 214:
215: /*
216: * Do common startup.
217: */
218: oea_startup("IBM NetworkStation 1000 (8362-XXX)");
219:
1.8.14.1 rjs 220: isa_pic = setup_prepivr();
221:
222: oea_install_extint(pic_ext_intr);
223:
1.1 matt 224: /*
1.6 rjs 225: * Initialize soft interrupt framework.
226: */
227: softintr__init();
228: /*
1.1 matt 229: * Now allow hardware interrupts.
230: */
231: {
232: int msr;
233:
234: splraise(-1);
1.4 perry 235: __asm volatile ("mfmsr %0; ori %0,%0,%1; mtmsr %0"
1.1 matt 236: : "=r"(msr) : "K"(PSL_EE));
237: }
238:
239: /*
240: * Now safe for bus space allocation to use malloc.
241: */
242: bus_space_mallocok();
243: }
244:
245: /*
246: * Halt or reboot the machine after syncing/dumping according to howto.
247: */
248: void
1.6 rjs 249: cpu_reboot(int howto, char *what)
1.1 matt 250: {
251: static int syncing;
252:
253: if (cold) {
254: howto |= RB_HALT;
255: goto halt_sys;
256: }
257:
258: boothowto = howto;
259: if ((howto & RB_NOSYNC) == 0 && syncing == 0) {
260: syncing = 1;
261: vfs_shutdown(); /* sync */
262: resettodr(); /* set wall clock */
263: }
264:
265: /* Disable intr */
266: splhigh();
267:
268: /* Do dump if requested */
269: if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP)
270: oea_dumpsys();
271:
272: halt_sys:
273: doshutdownhooks();
274:
275: if (howto & RB_HALT) {
276: printf("\n");
277: printf("The operating system has halted.\n");
278: printf("Please press any key to reboot.\n\n");
279: cnpollc(1); /* for proper keyboard command handling */
280: cngetc();
281: cnpollc(0);
282: }
283:
284: printf("rebooting...\n\n");
285:
286:
287: {
288: int msr;
289: u_char reg;
290:
1.5 perry 291: __asm volatile("mfmsr %0" : "=r"(msr));
1.1 matt 292: msr |= PSL_IP;
1.5 perry 293: __asm volatile("mtmsr %0" :: "r"(msr));
1.1 matt 294:
295: reg = *(volatile u_char *)(PREP_BUS_SPACE_IO + 0x92);
296: reg &= ~1UL;
297: *(volatile u_char *)(PREP_BUS_SPACE_IO + 0x92) = reg;
298:
1.5 perry 299: __asm volatile("sync; eieio\n");
1.1 matt 300:
301: reg = *(volatile u_char *)(PREP_BUS_SPACE_IO + 0x92);
302: reg |= 1;
303: *(volatile u_char *)(PREP_BUS_SPACE_IO + 0x92) = reg;
304:
1.5 perry 305: __asm volatile("sync; eieio\n");
1.1 matt 306: }
307:
308: for (;;)
309: continue;
310: /* NOTREACHED */
311: }
312:
1.8.14.1 rjs 313: struct powerpc_bus_space ibmnws_io_space_tag = {
1.1 matt 314: _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
315: 0x80000000, 0x00000000, 0x3f800000,
316: };
1.8.14.1 rjs 317: struct powerpc_bus_space genppc_isa_io_space_tag = {
1.1 matt 318: _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_IO_TYPE,
319: 0x80000000, 0x00000000, 0x00010000,
320: };
1.8.14.1 rjs 321: struct powerpc_bus_space ibmnws_mem_space_tag = {
1.1 matt 322: _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
323: 0xC0000000, 0x00000000, 0x3f000000,
324: };
1.8.14.1 rjs 325: struct powerpc_bus_space genppc_isa_mem_space_tag = {
1.1 matt 326: _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
327: 0xC0000000, 0x00000000, 0x01000000,
328: };
329:
330: static char ex_storage[2][EXTENT_FIXED_STORAGE_SIZE(8)]
331: __attribute__((aligned(8)));
332:
333: void
334: ibmnws_bus_space_init(void)
335: {
336: int error;
337:
1.8.14.1 rjs 338: error = bus_space_init(&ibmnws_io_space_tag, "ioport",
1.1 matt 339: ex_storage[0], sizeof(ex_storage[0]));
340: if (error)
1.8.14.1 rjs 341: panic("ibmnws_bus_space_init: can't init io tag");
1.1 matt 342:
1.8.14.1 rjs 343: error = extent_alloc_region(ibmnws_io_space_tag.pbs_extent,
1.1 matt 344: 0x10000, 0x7F0000, EX_NOWAIT);
345: if (error)
1.8.14.1 rjs 346: panic("ibmnws_bus_space_init: can't block out reserved I/O"
1.1 matt 347: " space 0x10000-0x7fffff: error=%d", error);
1.8.14.1 rjs 348: error = bus_space_init(&ibmnws_mem_space_tag, "iomem",
1.1 matt 349: ex_storage[1], sizeof(ex_storage[1]));
350: if (error)
1.8.14.1 rjs 351: panic("ibmnws_bus_space_init: can't init mem tag");
1.1 matt 352:
1.8.14.1 rjs 353: genppc_isa_io_space_tag.pbs_extent = ibmnws_io_space_tag.pbs_extent;
354: error = bus_space_init(&genppc_isa_io_space_tag, "isa-ioport", NULL, 0);
1.1 matt 355: if (error)
1.8.14.1 rjs 356: panic("ibmnws_bus_space_init: can't init isa io tag");
1.1 matt 357:
1.8.14.1 rjs 358: genppc_isa_mem_space_tag.pbs_extent = ibmnws_mem_space_tag.pbs_extent;
359: error = bus_space_init(&genppc_isa_mem_space_tag, "isa-iomem", NULL, 0);
1.1 matt 360: if (error)
1.8.14.1 rjs 361: panic("ibmnws_bus_space_init: can't init isa mem tag");
1.1 matt 362: }
CVSweb <webmaster@jp.NetBSD.org>