Tue Mar 30 03:57:03 2021 UTC ()
G/C unused. Use tlb.h directly instead of uvm_extern.h.
No binary changes.


(rin)
diff -r1.24 -r1.25 src/sys/arch/evbppc/obs405/obs266_machdep.c

cvs diff -r1.24 -r1.25 src/sys/arch/evbppc/obs405/obs266_machdep.c (switch to unified diff)

--- src/sys/arch/evbppc/obs405/obs266_machdep.c 2021/03/30 01:47:44 1.24
+++ src/sys/arch/evbppc/obs405/obs266_machdep.c 2021/03/30 03:57:03 1.25
@@ -1,280 +1,273 @@ @@ -1,280 +1,273 @@
1/* $NetBSD: obs266_machdep.c,v 1.24 2021/03/30 01:47:44 rin Exp $ */ 1/* $NetBSD: obs266_machdep.c,v 1.25 2021/03/30 03:57:03 rin Exp $ */
2/* Original: md_machdep.c,v 1.3 2005/01/24 18:47:37 shige Exp $ */ 2/* Original: md_machdep.c,v 1.3 2005/01/24 18:47:37 shige Exp $ */
3 3
4/* 4/*
5 * Copyright 2001, 2002 Wasabi Systems, Inc. 5 * Copyright 2001, 2002 Wasabi Systems, Inc.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc. 8 * Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software 18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement: 19 * must display the following acknowledgement:
20 * This product includes software developed for the NetBSD Project by 20 * This product includes software developed for the NetBSD Project by
21 * Wasabi Systems, Inc. 21 * Wasabi Systems, Inc.
22 * 4. The name of Wasabi Systems, Inc. may not be used to endorse 22 * 4. The name of Wasabi Systems, Inc. may not be used to endorse
23 * or promote products derived from this software without specific prior 23 * or promote products derived from this software without specific prior
24 * written permission. 24 * written permission.
25 * 25 *
26 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 26 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE. 36 * POSSIBILITY OF SUCH DAMAGE.
37 */ 37 */
38 38
39/* 39/*
40 * Copyright (C) 1995, 1996 Wolfgang Solfrank. 40 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
41 * Copyright (C) 1995, 1996 TooLs GmbH. 41 * Copyright (C) 1995, 1996 TooLs GmbH.
42 * All rights reserved. 42 * All rights reserved.
43 * 43 *
44 * Redistribution and use in source and binary forms, with or without 44 * Redistribution and use in source and binary forms, with or without
45 * modification, are permitted provided that the following conditions 45 * modification, are permitted provided that the following conditions
46 * are met: 46 * are met:
47 * 1. Redistributions of source code must retain the above copyright 47 * 1. Redistributions of source code must retain the above copyright
48 * notice, this list of conditions and the following disclaimer. 48 * notice, this list of conditions and the following disclaimer.
49 * 2. Redistributions in binary form must reproduce the above copyright 49 * 2. Redistributions in binary form must reproduce the above copyright
50 * notice, this list of conditions and the following disclaimer in the 50 * notice, this list of conditions and the following disclaimer in the
51 * documentation and/or other materials provided with the distribution. 51 * documentation and/or other materials provided with the distribution.
52 * 3. All advertising materials mentioning features or use of this software 52 * 3. All advertising materials mentioning features or use of this software
53 * must display the following acknowledgement: 53 * must display the following acknowledgement:
54 * This product includes software developed by TooLs GmbH. 54 * This product includes software developed by TooLs GmbH.
55 * 4. The name of TooLs GmbH may not be used to endorse or promote products 55 * 4. The name of TooLs GmbH may not be used to endorse or promote products
56 * derived from this software without specific prior written permission. 56 * derived from this software without specific prior written permission.
57 * 57 *
58 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 58 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
59 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 59 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
60 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 60 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
61 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 61 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 62 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
63 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 63 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
64 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 64 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
65 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 65 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
66 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 66 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
67 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 67 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
68 */ 68 */
69 69
70#include <sys/cdefs.h> 70#include <sys/cdefs.h>
71__KERNEL_RCSID(0, "$NetBSD: obs266_machdep.c,v 1.24 2021/03/30 01:47:44 rin Exp $"); 71__KERNEL_RCSID(0, "$NetBSD: obs266_machdep.c,v 1.25 2021/03/30 03:57:03 rin Exp $");
72 72
73#include "opt_compat_netbsd.h" 
74#include "opt_ddb.h" 73#include "opt_ddb.h"
75 74
76#include <sys/param.h> 75#include <sys/param.h>
77#include <sys/kernel.h> 76#include <sys/kernel.h>
78#include <sys/ksyms.h> 
79#include <sys/mount.h> 
80#include <sys/reboot.h> 77#include <sys/reboot.h>
81#include <sys/systm.h> 78#include <sys/systm.h>
82#include <sys/device.h> 79#include <sys/device.h>
83#include <sys/module.h> 80#include <sys/module.h>
84#include <sys/bus.h> 81#include <sys/bus.h>
85#include <sys/cpu.h> 
86 
87#include <uvm/uvm_extern.h> 
88 82
89#include <machine/obs266.h> 83#include <machine/obs266.h>
90 84
91#include <powerpc/ibm4xx/dcr4xx.h> 85#include <powerpc/ibm4xx/dcr4xx.h>
92#include <powerpc/ibm4xx/cpu.h> 86#include <powerpc/ibm4xx/cpu.h>
93#include <powerpc/ibm4xx/ibm405gp.h> 87#include <powerpc/ibm4xx/ibm405gp.h>
94#include <powerpc/ibm4xx/pci_machdep.h> 88#include <powerpc/ibm4xx/pci_machdep.h>
95#include <powerpc/ibm4xx/openbios.h> 89#include <powerpc/ibm4xx/openbios.h>
 90#include <powerpc/ibm4xx/tlb.h>
96#include <powerpc/ibm4xx/dev/comopbvar.h> 91#include <powerpc/ibm4xx/dev/comopbvar.h>
97 92
98#include <powerpc/spr.h> 93#include <powerpc/spr.h>
99#include <powerpc/ibm4xx/spr.h> 94#include <powerpc/ibm4xx/spr.h>
100 95
101#include <dev/ic/comreg.h> 96#include <dev/ic/comreg.h>
102#include <dev/pci/pcivar.h> 97#include <dev/pci/pcivar.h>
103#include <dev/pci/pciconf.h> 98#include <dev/pci/pciconf.h>
104 99
105#include "ksyms.h" 
106 
107#include "com.h" 100#include "com.h"
108#if (NCOM > 0) 101#if (NCOM > 0)
109#include <sys/termios.h> 102#include <sys/termios.h>
110 103
111#ifndef CONADDR 104#ifndef CONADDR
112#define CONADDR IBM405GP_UART0_BASE 105#define CONADDR IBM405GP_UART0_BASE
113#endif 106#endif
114#ifndef CONSPEED 107#ifndef CONSPEED
115#define CONSPEED B9600 108#define CONSPEED B9600
116#endif 109#endif
117#ifndef CONMODE 110#ifndef CONMODE
118 /* 8N1 */ 111 /* 8N1 */
119#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) 112#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8)
120#endif 113#endif
121#endif /* NCOM */ 114#endif /* NCOM */
122 115
123#define TLB_PG_SIZE (16*1024*1024) 116#define TLB_PG_SIZE (16*1024*1024)
124 117
125void initppc(vaddr_t, vaddr_t, char *, void *); 118void initppc(vaddr_t, vaddr_t, char *, void *);
126 119
127void 120void
128initppc(vaddr_t startkernel, vaddr_t endkernel, char *args, void *info_block) 121initppc(vaddr_t startkernel, vaddr_t endkernel, char *args, void *info_block)
129{ 122{
130 vaddr_t va; 123 vaddr_t va;
131 u_int memsize; 124 u_int memsize;
132 125
133 /* Setup board from OpenBIOS */ 126 /* Setup board from OpenBIOS */
134 openbios_board_init(info_block); 127 openbios_board_init(info_block);
135 memsize = openbios_board_memsize_get(); 128 memsize = openbios_board_memsize_get();
136 129
137 /* Linear map kernel memory */ 130 /* Linear map kernel memory */
138 for (va = 0; va < endkernel; va += TLB_PG_SIZE) 131 for (va = 0; va < endkernel; va += TLB_PG_SIZE)
139 ppc4xx_tlb_reserve(va, va, TLB_PG_SIZE, TLB_EX); 132 ppc4xx_tlb_reserve(va, va, TLB_PG_SIZE, TLB_EX);
140 133
141 /* Map console after RAM (see pmap_tlbmiss()) */ 134 /* Map console after RAM (see pmap_tlbmiss()) */
142 ppc4xx_tlb_reserve(CONADDR, roundup(memsize, TLB_PG_SIZE), TLB_PG_SIZE, 135 ppc4xx_tlb_reserve(CONADDR, roundup(memsize, TLB_PG_SIZE), TLB_PG_SIZE,
143 TLB_I | TLB_G); 136 TLB_I | TLB_G);
144 137
145 /* Initialize IBM405GPr CPU */ 138 /* Initialize IBM405GPr CPU */
146 ibm40x_memsize_init(memsize, startkernel); 139 ibm40x_memsize_init(memsize, startkernel);
147 ibm4xx_init(startkernel, endkernel, pic_ext_intr); 140 ibm4xx_init(startkernel, endkernel, pic_ext_intr);
148 141
149#ifdef DEBUG 142#ifdef DEBUG
150 openbios_board_print(); 143 openbios_board_print();
151#endif 144#endif
152 145
153#ifdef DDB 146#ifdef DDB
154 if (boothowto & RB_KDB) 147 if (boothowto & RB_KDB)
155 Debugger(); 148 Debugger();
156#endif 149#endif
157 150
158 /* 151 /*
159 * Look for the ibm4xx modules in the right place. 152 * Look for the ibm4xx modules in the right place.
160 */ 153 */
161 module_machine = module_machine_ibm4xx; 154 module_machine = module_machine_ibm4xx;
162} 155}
163 156
164void 157void
165consinit(void) 158consinit(void)
166{ 159{
167 160
168#if (NCOM > 0) 161#if (NCOM > 0)
169 com_opb_cnattach(OBS266_COM_FREQ, CONADDR, CONSPEED, CONMODE); 162 com_opb_cnattach(OBS266_COM_FREQ, CONADDR, CONSPEED, CONMODE);
170#endif 163#endif
171} 164}
172 165
173/* 166/*
174 * Machine dependent startup code. 167 * Machine dependent startup code.
175 */ 168 */
176void 169void
177cpu_startup(void) 170cpu_startup(void)
178{ 171{
179 172
180 /* 173 /*
181 * cpu common startup 174 * cpu common startup
182 */ 175 */
183 ibm4xx_cpu_startup("OpenBlockS266 IBM PowerPC 405GPr Board"); 176 ibm4xx_cpu_startup("OpenBlockS266 IBM PowerPC 405GPr Board");
184 177
185 /* 178 /*
186 * Set up the board properties database. 179 * Set up the board properties database.
187 */ 180 */
188 openbios_board_info_set(); 181 openbios_board_info_set();
189 182
190 /* 183 /*
191 * Now that we have VM, malloc()s are OK in bus_space. 184 * Now that we have VM, malloc()s are OK in bus_space.
192 */ 185 */
193 bus_space_mallocok(); 186 bus_space_mallocok();
194 187
195 /* 188 /*
196 * no fake mapiodev 189 * no fake mapiodev
197 */ 190 */
198 fake_mapiodev = 0; 191 fake_mapiodev = 0;
199} 192}
200 193
201int 194int
202ibm4xx_pci_bus_maxdevs(void *v, int busno) 195ibm4xx_pci_bus_maxdevs(void *v, int busno)
203{ 196{
204 197
205 /* 198 /*
206 * Bus number is irrelevant. Configuration Mechanism 1 is in 199 * Bus number is irrelevant. Configuration Mechanism 1 is in
207 * use, can have devices 0-32 (i.e. the `normal' range). 200 * use, can have devices 0-32 (i.e. the `normal' range).
208 */ 201 */
209 return 31; 202 return 31;
210} 203}
211 204
212int 205int
213ibm4xx_pci_intr_map(const struct pci_attach_args *pa, pci_intr_handle_t *ihp) 206ibm4xx_pci_intr_map(const struct pci_attach_args *pa, pci_intr_handle_t *ihp)
214{ 207{
215 /* 208 /*
216 * We need to map the interrupt pin to the interrupt bit 209 * We need to map the interrupt pin to the interrupt bit
217 * in the UIC associated with it. 210 * in the UIC associated with it.
218 * 211 *
219 * This platform has 4 PCI devices. 212 * This platform has 4 PCI devices.
220 * 213 *
221 # External IRQ Mappings: 214 # External IRQ Mappings:
222 * dev 1 (Ext IRQ3): PCI Connector 215 * dev 1 (Ext IRQ3): PCI Connector
223 * dev 2 (Ext IRQ4): PCI Connector 216 * dev 2 (Ext IRQ4): PCI Connector
224 * dev 3 (Ext IRQ5): HPT IDE Controller 217 * dev 3 (Ext IRQ5): HPT IDE Controller
225 * dev 4 (Ext IRQ6): Davicom Ethernet 218 * dev 4 (Ext IRQ6): Davicom Ethernet
226 */ 219 */
227 static const int irqmap[4/*device*/][4/*pin*/] = { 220 static const int irqmap[4/*device*/][4/*pin*/] = {
228 { 3, 3, 3, 3 }, /* 1: PCI Connector 1 */ 221 { 3, 3, 3, 3 }, /* 1: PCI Connector 1 */
229 { 4, 4, 4, 4 }, /* 2: PCI Connector 2 */ 222 { 4, 4, 4, 4 }, /* 2: PCI Connector 2 */
230 { 5, 5, -1, -1 }, /* 3: HPT IDE Controller */ 223 { 5, 5, -1, -1 }, /* 3: HPT IDE Controller */
231 { 6, 6, -1, -1 }, /* 4: Damicom Ethernet */ 224 { 6, 6, -1, -1 }, /* 4: Damicom Ethernet */
232 }; 225 };
233 226
234 int pin, dev, irq; 227 int pin, dev, irq;
235 228
236 pin = pa->pa_intrpin; 229 pin = pa->pa_intrpin;
237 dev = pa->pa_device; 230 dev = pa->pa_device;
238 *ihp = -1; 231 *ihp = -1;
239 232
240 /* if interrupt pin not used... */ 233 /* if interrupt pin not used... */
241 if (pin == 0) 234 if (pin == 0)
242 return 1; 235 return 1;
243 236
244 if (pin > 4) { 237 if (pin > 4) {
245 printf("pci_intr_map: bad interrupt pin %d\n", pin); 238 printf("pci_intr_map: bad interrupt pin %d\n", pin);
246 return 1; 239 return 1;
247 } 240 }
248 241
249 if ((dev < 1) || (dev > 4)) { 242 if ((dev < 1) || (dev > 4)) {
250 printf("pci_intr_map: bad device %d\n", dev); 243 printf("pci_intr_map: bad device %d\n", dev);
251 return 1; 244 return 1;
252 } 245 }
253 246
254 247
255 if ((irq = irqmap[dev - 1][pin - 1]) == -1) { 248 if ((irq = irqmap[dev - 1][pin - 1]) == -1) {
256 printf("pci_intr_map: no IRQ routing for device %d pin %d\n", 249 printf("pci_intr_map: no IRQ routing for device %d pin %d\n",
257 dev, pin); 250 dev, pin);
258 return 1; 251 return 1;
259 } 252 }
260 253
261 *ihp = irq + 25; 254 *ihp = irq + 25;
262 return 0; 255 return 0;
263} 256}
264 257
265void 258void
266ibm4xx_pci_conf_interrupt(void *v, int bus, int dev, int pin, int swiz, 259ibm4xx_pci_conf_interrupt(void *v, int bus, int dev, int pin, int swiz,
267 int *iline) 260 int *iline)
268{ 261{
269 262
270 static const int ilinemap[4/*device*/] = { 263 static const int ilinemap[4/*device*/] = {
271 28, 29, 30, 31 264 28, 29, 30, 31
272 }; 265 };
273 266
274 if ((dev < 1) || (dev > 4)) { 267 if ((dev < 1) || (dev > 4)) {
275 printf("%s: bad device %d\n", __func__, dev); 268 printf("%s: bad device %d\n", __func__, dev);
276 *iline = 0; 269 *iline = 0;
277 return; 270 return;
278 } 271 }
279 *iline = ilinemap[dev - 1]; 272 *iline = ilinemap[dev - 1];
280} 273}