Mon Dec 12 11:31:46 2011 UTC ()
Call bus_space_mallocok earlier.  Moreover, don't bus_space_unmap call.


(kiyohara)
diff -r1.7 -r1.8 src/sys/arch/evbppc/obs405/obs600_machdep.c

cvs diff -r1.7 -r1.8 src/sys/arch/evbppc/obs405/obs600_machdep.c (expand / switch to unified diff)

--- src/sys/arch/evbppc/obs405/obs600_machdep.c 2011/06/20 17:44:33 1.7
+++ src/sys/arch/evbppc/obs405/obs600_machdep.c 2011/12/12 11:31:46 1.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: obs600_machdep.c,v 1.7 2011/06/20 17:44:33 matt Exp $ */ 1/* $NetBSD: obs600_machdep.c,v 1.8 2011/12/12 11:31:46 kiyohara 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.
@@ -58,27 +58,27 @@ @@ -58,27 +58,27 @@
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: obs600_machdep.c,v 1.7 2011/06/20 17:44:33 matt Exp $"); 71__KERNEL_RCSID(0, "$NetBSD: obs600_machdep.c,v 1.8 2011/12/12 11:31:46 kiyohara Exp $");
72 72
73#include "opt_compat_netbsd.h" 73#include "opt_compat_netbsd.h"
74#include "opt_ddb.h" 74#include "opt_ddb.h"
75#include "opt_ipkdb.h" 75#include "opt_ipkdb.h"
76#include "opt_modular.h" 76#include "opt_modular.h"
77 77
78#include <sys/param.h> 78#include <sys/param.h>
79#include <sys/bus.h> 79#include <sys/bus.h>
80#include <sys/errno.h> 80#include <sys/errno.h>
81#include <sys/kernel.h> 81#include <sys/kernel.h>
82#include <sys/ksyms.h> 82#include <sys/ksyms.h>
83#include <sys/mount.h> 83#include <sys/mount.h>
84#include <sys/reboot.h> 84#include <sys/reboot.h>
@@ -205,26 +205,31 @@ cpu_startup(void) @@ -205,26 +205,31 @@ cpu_startup(void)
205 u_char *macaddr, *macaddr1; 205 u_char *macaddr, *macaddr1;
206 static u_char buf[16]; /* MAC address x2 buffer */ 206 static u_char buf[16]; /* MAC address x2 buffer */
207 207
208 /* 208 /*
209 * cpu common startup 209 * cpu common startup
210 */ 210 */
211 ibm4xx_cpu_startup("OpenBlockS600 AMCC PowerPC 405EX Board"); 211 ibm4xx_cpu_startup("OpenBlockS600 AMCC PowerPC 405EX Board");
212 212
213 /* 213 /*
214 * Set up the board properties database. 214 * Set up the board properties database.
215 */ 215 */
216 board_info_init(); 216 board_info_init();
217 217
 218 /*
 219 * Now that we have VM, malloc()s are OK in bus_space.
 220 */
 221 bus_space_mallocok();
 222
218 read_eeprom(sizeof(buf), buf); 223 read_eeprom(sizeof(buf), buf);
219 macaddr = &buf[0]; 224 macaddr = &buf[0];
220 macaddr1 = &buf[8]; 225 macaddr1 = &buf[8];
221 226
222 pn = prop_number_create_integer(OBS600_CPU_FREQ); 227 pn = prop_number_create_integer(OBS600_CPU_FREQ);
223 KASSERT(pn != NULL); 228 KASSERT(pn != NULL);
224 if (prop_dictionary_set(board_properties, "processor-frequency", pn) == 229 if (prop_dictionary_set(board_properties, "processor-frequency", pn) ==
225 false) 230 false)
226 panic("setting processor-frequency"); 231 panic("setting processor-frequency");
227 prop_object_release(pn); 232 prop_object_release(pn);
228 233
229 pn = prop_number_create_integer(OBS600_MEM_SIZE); 234 pn = prop_number_create_integer(OBS600_MEM_SIZE);
230 KASSERT(pn != NULL); 235 KASSERT(pn != NULL);
@@ -250,31 +255,26 @@ cpu_startup(void) @@ -250,31 +255,26 @@ cpu_startup(void)
250 /* emac0 connects to phy 2 and emac1 to phy 3 via RGMII. */ 255 /* emac0 connects to phy 2 and emac1 to phy 3 via RGMII. */
251 pn = prop_number_create_integer(2); 256 pn = prop_number_create_integer(2);
252 KASSERT(pn != NULL); 257 KASSERT(pn != NULL);
253 if (prop_dictionary_set(board_properties, "emac0-mii-phy", pn) == false) 258 if (prop_dictionary_set(board_properties, "emac0-mii-phy", pn) == false)
254 panic("setting emac0-mii-phy"); 259 panic("setting emac0-mii-phy");
255 prop_object_release(pn); 260 prop_object_release(pn);
256 pn = prop_number_create_integer(3); 261 pn = prop_number_create_integer(3);
257 KASSERT(pn != NULL); 262 KASSERT(pn != NULL);
258 if (prop_dictionary_set(board_properties, "emac1-mii-phy", pn) == false) 263 if (prop_dictionary_set(board_properties, "emac1-mii-phy", pn) == false)
259 panic("setting emac1-mii-phy"); 264 panic("setting emac1-mii-phy");
260 prop_object_release(pn); 265 prop_object_release(pn);
261 266
262 /* 267 /*
263 * Now that we have VM, malloc()s are OK in bus_space. 
264 */ 
265 bus_space_mallocok(); 
266 
267 /* 
268 * no fake mapiodev 268 * no fake mapiodev
269 */ 269 */
270 fake_mapiodev = 0; 270 fake_mapiodev = 0;
271 271
272 splraise(-1); 272 splraise(-1);
273} 273}
274 274
275/* 275/*
276 * Halt or reboot the machine after syncing/dumping according to howto. 276 * Halt or reboot the machine after syncing/dumping according to howto.
277 */ 277 */
278void 278void
279cpu_reboot(int howto, char *what) 279cpu_reboot(int howto, char *what)
280{ 280{
@@ -403,17 +403,19 @@ read_eeprom(int len, char *buf) @@ -403,17 +403,19 @@ read_eeprom(int len, char *buf)
403 if ((sts & IIC_STS_PT) || (sts & IIC_STS_ERR)) 403 if ((sts & IIC_STS_PT) || (sts & IIC_STS_ERR))
404 break; 404 break;
405 if (sts & IIC_STS_MDBS) { 405 if (sts & IIC_STS_MDBS) {
406 delay(1); 406 delay(1);
407 /* read 4byte */ 407 /* read 4byte */
408 for (i = 0; i < 4 && cnt < len; i++, cnt++) 408 for (i = 0; i < 4 && cnt < len; i++, cnt++)
409 buf[cnt] = 409 buf[cnt] =
410 bus_space_read_1(bst, bsh, IIC_MDBUF); 410 bus_space_read_1(bst, bsh, IIC_MDBUF);
411 } 411 }
412 } 412 }
413 for ( ; i < 4; i++) 413 for ( ; i < 4; i++)
414 (void) bus_space_read_1(bst, bsh, IIC_MDBUF); 414 (void) bus_space_read_1(bst, bsh, IIC_MDBUF);
415 415
 416#if 0 /* Ooops, can't unmap here... */
416 bus_space_unmap(bst, bsh, IIC_NREG); 417 bus_space_unmap(bst, bsh, IIC_NREG);
 418#endif
417 419
418 return (cnt == len) ? 0 : EINVAL; 420 return (cnt == len) ? 0 : EINVAL;
419} 421}