Fri Mar 5 06:06:34 2021 UTC ()
For Explora 451, call calc_delayconst() before pckbc_cnattach(), which
depends on delay() and DELAY().

Unfortunately, proplib(9) API is not available for MD codes, that are
called before consinit() (since pool(9) is not initialized yet).

Therefore, hard-code CPU frequency to calc_delayconst() in case
"processor-frequency" is not initialized.


(rin)
diff -r1.5 -r1.6 src/sys/arch/evbppc/conf/std.explora
diff -r1.9 -r1.10 src/sys/arch/evbppc/explora/consinit.c
diff -r1.97 -r1.98 src/sys/arch/powerpc/conf/files.powerpc
diff -r1.31 -r1.32 src/sys/arch/powerpc/ibm4xx/clock.c

cvs diff -r1.5 -r1.6 src/sys/arch/evbppc/conf/std.explora (expand / switch to unified diff)

--- src/sys/arch/evbppc/conf/std.explora 2011/06/20 17:44:33 1.5
+++ src/sys/arch/evbppc/conf/std.explora 2021/03/05 06:06:34 1.6
@@ -1,25 +1,27 @@ @@ -1,25 +1,27 @@
1# $NetBSD: std.explora,v 1.5 2011/06/20 17:44:33 matt Exp $ 1# $NetBSD: std.explora,v 1.6 2021/03/05 06:06:34 rin Exp $
2# 2#
3# Standard/required options for NetBSD/explora. 3# Standard/required options for NetBSD/explora.
4 4
5machine evbppc powerpc 5machine evbppc powerpc
6include "conf/std" # MI standard options 6include "conf/std" # MI standard options
7 7
8# standard ("mandatory") kernel options. 8# standard ("mandatory") kernel options.
9options PPC_IBM4XX # IBM 40x family 9options PPC_IBM4XX # IBM 40x family
10options PPC_IBM403 # IBM 403GCX 10options PPC_IBM403 # IBM 403GCX
11 11
12# Executable support: 12# Executable support:
13options EXEC_ELF32 # (native) ELF32 binary support 13options EXEC_ELF32 # (native) ELF32 binary support
14options EXEC_AOUT # (native) a.out binary support (deprecated) 14options EXEC_AOUT # (native) a.out binary support (deprecated)
15options EXEC_SCRIPT # shell script support 15options EXEC_SCRIPT # shell script support
16 16
17makeoptions TEXTADDR=0x10000 17makeoptions TEXTADDR=0x10000
18makeoptions BOARDTYPE="explora" 18makeoptions BOARDTYPE="explora"
19makeoptions PPCDIR="ibm4xx" 19makeoptions PPCDIR="ibm4xx"
20 20
21options PPC_INTR_IMPL="<powerpc/intr.h>" 21options PPC_INTR_IMPL="<powerpc/intr.h>"
22 22
23options INTSTK=8192 23options INTSTK=8192
24 24
 25options PPC_CPU_FREQ=66000000 # XXX hack for pckbc_cnattach()
 26
25include "arch/evbppc/conf/files.explora" 27include "arch/evbppc/conf/files.explora"

cvs diff -r1.9 -r1.10 src/sys/arch/evbppc/explora/consinit.c (expand / switch to unified diff)

--- src/sys/arch/evbppc/explora/consinit.c 2012/10/13 17:58:53 1.9
+++ src/sys/arch/evbppc/explora/consinit.c 2021/03/05 06:06:34 1.10
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: consinit.c,v 1.9 2012/10/13 17:58:53 jdc Exp $ */ 1/* $NetBSD: consinit.c,v 1.10 2021/03/05 06:06:34 rin Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2003 The NetBSD Foundation, Inc. 4 * Copyright (c) 2003 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Juergen Hannken-Illjes. 8 * by Juergen Hannken-Illjes.
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.
@@ -20,50 +20,51 @@ @@ -20,50 +20,51 @@
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.9 2012/10/13 17:58:53 jdc Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.10 2021/03/05 06:06:34 rin Exp $");
34 34
35#include <sys/param.h> 35#include <sys/param.h>
36#include <sys/systm.h> 36#include <sys/systm.h>
37 37
38#include <machine/explora.h> 38#include <machine/explora.h>
39#include <sys/bus.h> 39#include <sys/bus.h>
40 40
41#include "com.h" 41#include "com.h"
42#if NCOM > 0 42#if NCOM > 0
43#include <sys/termios.h> 43#include <sys/termios.h>
44#include <dev/ic/comreg.h> 44#include <dev/ic/comreg.h>
45#include <dev/ic/comvar.h> 45#include <dev/ic/comvar.h>
46#endif 46#endif
47 47
48#include "pckbc.h" 48#include "pckbc.h"
49#if (NPCKBC > 0) 49#if (NPCKBC > 0)
50#include <dev/isa/isareg.h> 50#include <dev/isa/isareg.h>
51#include <dev/ic/i8042reg.h> 51#include <dev/ic/i8042reg.h>
52#include <dev/ic/pckbcvar.h> 52#include <dev/ic/pckbcvar.h>
53#endif 53#endif
54#include "pckbd.h" 54#include "pckbd.h"
55 55
56#include <evbppc/explora/dev/elbvar.h> 56#include <evbppc/explora/dev/elbvar.h>
 57#include <powerpc/ibm4xx/cpu.h>
57 58
58#include "opt_explora.h" 59#include "opt_explora.h"
59 60
60#ifndef COM_CONSOLE_SPEED 61#ifndef COM_CONSOLE_SPEED
61#define COM_CONSOLE_SPEED 9600 62#define COM_CONSOLE_SPEED 9600
62#endif 63#endif
63 64
64void 65void
65consinit(void) 66consinit(void)
66{ 67{
67 bus_space_tag_t tag; 68 bus_space_tag_t tag;
68 static int done = 0; 69 static int done = 0;
69#ifndef COM_IS_CONSOLE 70#ifndef COM_IS_CONSOLE
@@ -76,19 +77,22 @@ consinit(void) @@ -76,19 +77,22 @@ consinit(void)
76 done = 1; 77 done = 1;
77 78
78#ifdef COM_IS_CONSOLE 79#ifdef COM_IS_CONSOLE
79 tag = elb_get_bus_space_tag(BASE_COM); 80 tag = elb_get_bus_space_tag(BASE_COM);
80 comcnattach(tag, _BUS_SPACE_UNSTRIDE(tag, BASE_COM), COM_CONSOLE_SPEED, 81 comcnattach(tag, _BUS_SPACE_UNSTRIDE(tag, BASE_COM), COM_CONSOLE_SPEED,
81 COM_FREQ, COM_TYPE_NORMAL, 82 COM_FREQ, COM_TYPE_NORMAL,
82 (TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8); 83 (TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8);
83#else 84#else
84 /* Clear VRam */ 85 /* Clear VRam */
85 memset((void *)BASE_FB, 0, SIZE_FB); 86 memset((void *)BASE_FB, 0, SIZE_FB);
86 87
87 tag = elb_get_bus_space_tag(BASE_FB); 88 tag = elb_get_bus_space_tag(BASE_FB);
88 fb_cnattach(tag, BASE_FB2, (void *)BASE_FB); 89 fb_cnattach(tag, BASE_FB2, (void *)BASE_FB);
 90
 91 calc_delayconst(); /* required by pckbc_cnattach() */
 92
89 tag = elb_get_bus_space_tag(BASE_PCKBC); 93 tag = elb_get_bus_space_tag(BASE_PCKBC);
90 pckbc_cnattach(tag, _BUS_SPACE_UNSTRIDE(tag, BASE_PCKBC), 94 pckbc_cnattach(tag, _BUS_SPACE_UNSTRIDE(tag, BASE_PCKBC),
91 _BUS_SPACE_UNSTRIDE(tag, BASE_PCKBC2-BASE_PCKBC), PCKBC_KBD_SLOT, 95 _BUS_SPACE_UNSTRIDE(tag, BASE_PCKBC2-BASE_PCKBC), PCKBC_KBD_SLOT,
92 0); 96 0);
93#endif 97#endif
94} 98}

cvs diff -r1.97 -r1.98 src/sys/arch/powerpc/conf/files.powerpc (expand / switch to unified diff)

--- src/sys/arch/powerpc/conf/files.powerpc 2020/10/21 13:31:51 1.97
+++ src/sys/arch/powerpc/conf/files.powerpc 2021/03/05 06:06:34 1.98
@@ -1,18 +1,18 @@ @@ -1,18 +1,18 @@
1# $NetBSD: files.powerpc,v 1.97 2020/10/21 13:31:51 christos Exp $ 1# $NetBSD: files.powerpc,v 1.98 2021/03/05 06:06:34 rin Exp $
2 2
3defflag opt_altivec.h ALTIVEC K_ALTIVEC PPC_HAVE_SPE 3defflag opt_altivec.h ALTIVEC K_ALTIVEC PPC_HAVE_SPE
4defflag opt_openpic.h OPENPIC_DISTRIBUTE 4defflag opt_openpic.h OPENPIC_DISTRIBUTE
5defparam opt_ppcparam.h L2CR_CONFIG L3CR_CONFIG INTSTK CLOCKBASE VERBOSE_INITPPC 5defparam opt_ppcparam.h L2CR_CONFIG L3CR_CONFIG INTSTK CLOCKBASE VERBOSE_INITPPC PPC_CPU_FREQ
6defflag opt_ppcarch.h PPC_OEA PPC_OEA601 PPC_OEA64 PPC_OEA64_BRIDGE PPC_MPC8XX PPC_IBM4XX PPC_IBM403 PPC_IBM440 PPC_BOOKE 6defflag opt_ppcarch.h PPC_OEA PPC_OEA601 PPC_OEA64 PPC_OEA64_BRIDGE PPC_MPC8XX PPC_IBM4XX PPC_IBM403 PPC_IBM440 PPC_BOOKE
7defflag opt_ppccache.h CACHE_PROTO_MEI 7defflag opt_ppccache.h CACHE_PROTO_MEI
8defflag opt_pmap.h PMAPDEBUG PMAPCHECK PMAPCOUNTERS PMAP_MINIMALTLB PMAP_TLBDEBUG 8defflag opt_pmap.h PMAPDEBUG PMAPCHECK PMAPCOUNTERS PMAP_MINIMALTLB PMAP_TLBDEBUG
9defparam opt_pmap.h PTEGCOUNT PMAP_MEMLIMIT 9defparam opt_pmap.h PTEGCOUNT PMAP_MEMLIMIT
10 10
11file arch/powerpc/powerpc/core_machdep.c coredump 11file arch/powerpc/powerpc/core_machdep.c coredump
12file arch/powerpc/powerpc/fixup.c 12file arch/powerpc/powerpc/fixup.c
13file arch/powerpc/powerpc/kgdb_machdep.c kgdb 13file arch/powerpc/powerpc/kgdb_machdep.c kgdb
14file arch/powerpc/powerpc/kobj_machdep.c modular 14file arch/powerpc/powerpc/kobj_machdep.c modular
15file arch/powerpc/powerpc/lock_stubs.S 15file arch/powerpc/powerpc/lock_stubs.S
16file arch/powerpc/powerpc/openpic.c openpic 16file arch/powerpc/powerpc/openpic.c openpic
17file arch/powerpc/powerpc/pmap_subr.c ppc_oea | ppc_oea64 | ppc_oea64_bridge | ppc_oea601 17file arch/powerpc/powerpc/pmap_subr.c ppc_oea | ppc_oea64 | ppc_oea64_bridge | ppc_oea601
18file arch/powerpc/powerpc/powerpc_machdep.c 18file arch/powerpc/powerpc/powerpc_machdep.c

cvs diff -r1.31 -r1.32 src/sys/arch/powerpc/ibm4xx/clock.c (expand / switch to unified diff)

--- src/sys/arch/powerpc/ibm4xx/clock.c 2021/01/18 04:35:04 1.31
+++ src/sys/arch/powerpc/ibm4xx/clock.c 2021/03/05 06:06:34 1.32
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: clock.c,v 1.31 2021/01/18 04:35:04 rin Exp $ */ 1/* $NetBSD: clock.c,v 1.32 2021/03/05 06:06:34 rin Exp $ */
2/* $OpenBSD: clock.c,v 1.3 1997/10/13 13:42:53 pefo Exp $ */ 2/* $OpenBSD: clock.c,v 1.3 1997/10/13 13:42:53 pefo Exp $ */
3 3
4/* 4/*
5 * Copyright (C) 1995, 1996 Wolfgang Solfrank. 5 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
6 * Copyright (C) 1995, 1996 TooLs GmbH. 6 * Copyright (C) 1995, 1996 TooLs GmbH.
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -23,30 +23,31 @@ @@ -23,30 +23,31 @@
23 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 23 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 28 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
29 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
31 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 31 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */ 33 */
34 34
35#include <sys/cdefs.h> 35#include <sys/cdefs.h>
36__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.31 2021/01/18 04:35:04 rin Exp $"); 36__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.32 2021/03/05 06:06:34 rin Exp $");
37 37
38#ifdef _KERNEL_OPT 38#ifdef _KERNEL_OPT
39#include "opt_ppcarch.h" 39#include "opt_ppcarch.h"
 40#include "opt_ppcparam.h"
40#endif 41#endif
41 42
42#include <sys/param.h> 43#include <sys/param.h>
43#include <sys/kernel.h> 44#include <sys/kernel.h>
44#include <sys/systm.h> 45#include <sys/systm.h>
45#include <sys/timetc.h> 46#include <sys/timetc.h>
46#include <sys/cpu.h> 47#include <sys/cpu.h>
47 48
48#include <uvm/uvm_extern.h> 49#include <uvm/uvm_extern.h>
49 50
50#include <prop/proplib.h> 51#include <prop/proplib.h>
51 52
52#include <powerpc/spr.h> 53#include <powerpc/spr.h>
@@ -187,29 +188,37 @@ cpu_initclocks(void) @@ -187,29 +188,37 @@ cpu_initclocks(void)
187 188
188 /* Enable PIT & FIT(2^17c = 0.655ms) interrupts and auto-reload */ 189 /* Enable PIT & FIT(2^17c = 0.655ms) interrupts and auto-reload */
189 mtspr(SPR_TCR, TCR_PIE | TCR_ARE | TCR_FIE | TCR_PERIOD); 190 mtspr(SPR_TCR, TCR_PIE | TCR_ARE | TCR_FIE | TCR_PERIOD);
190 191
191 init_ppc4xx_tc(); 192 init_ppc4xx_tc();
192} 193}
193 194
194void 195void
195calc_delayconst(void) 196calc_delayconst(void)
196{ 197{
197 prop_number_t freq; 198 prop_number_t freq;
198 199
199 freq = prop_dictionary_get(board_properties, "processor-frequency"); 200 freq = prop_dictionary_get(board_properties, "processor-frequency");
 201
 202#ifndef PPC_CPU_FREQ
200 KASSERT(freq != NULL); 203 KASSERT(freq != NULL);
 204#else
 205 /* XXX hack for pckbc_cnattach() for Explora */
 206 if (freq == NULL)
 207 ticks_per_sec = (u_long) PPC_CPU_FREQ;
 208 else
 209#endif
 210 ticks_per_sec = (u_long) prop_number_integer_value(freq);
201 211
202 ticks_per_sec = (u_long) prop_number_integer_value(freq); 
203 ns_per_tick = 1000000000 / ticks_per_sec; 212 ns_per_tick = 1000000000 / ticks_per_sec;
204} 213}
205 214
206static u_int 215static u_int
207get_ppc4xx_timecount(struct timecounter *tc) 216get_ppc4xx_timecount(struct timecounter *tc)
208{ 217{
209 u_long tb; 218 u_long tb;
210 int msr; 219 int msr;
211 220
212 __asm volatile ("mfmsr %0; wrteei 0" : "=r"(msr) :); 221 __asm volatile ("mfmsr %0; wrteei 0" : "=r"(msr) :);
213 tb = mftbl(); 222 tb = mftbl();
214 __asm volatile ("mtmsr %0" :: "r"(msr)); 223 __asm volatile ("mtmsr %0" :: "r"(msr));
215 224