Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/powerpc support ppc601
details: https://anonhg.NetBSD.org/src/rev/941dcc3887e8
branches: trunk
changeset: 327273:941dcc3887e8
user: macallan <macallan%NetBSD.org@localhost>
date: Mon Mar 03 15:36:36 2014 +0000
description:
support ppc601
from scole_mail, ok matt@
diffstat:
sys/arch/powerpc/include/cpu.h | 22 +-
sys/arch/powerpc/include/trap.h | 71 +++++-
sys/arch/powerpc/oea/oea_machdep.c | 11 +-
sys/arch/powerpc/oea/ofwoea_machdep.c | 35 ++-
sys/arch/powerpc/oea/pmap.c | 14 +-
sys/arch/powerpc/powerpc/clock.c | 16 +-
sys/arch/powerpc/powerpc/fixup.c | 21 +-
sys/arch/powerpc/powerpc/trap.c | 396 +++++++++++++++++++++++++++++++++-
8 files changed, 557 insertions(+), 29 deletions(-)
diffs (truncated from 859 to 300 lines):
diff -r 944da046c79c -r 941dcc3887e8 sys/arch/powerpc/include/cpu.h
--- a/sys/arch/powerpc/include/cpu.h Mon Mar 03 15:30:31 2014 +0000
+++ b/sys/arch/powerpc/include/cpu.h Mon Mar 03 15:36:36 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.98 2013/11/08 03:59:35 nisimura Exp $ */
+/* $NetBSD: cpu.h,v 1.99 2014/03/03 15:36:36 macallan Exp $ */
/*
* Copyright (C) 1999 Wolfgang Solfrank.
@@ -316,6 +316,26 @@
: [rtcu] "=r"(rtcp[0]), [rtcl] "=r"(rtcp[1]), [tmp] "=r"(tmp)
:: "cr0");
}
+
+static __inline uint64_t
+rtc_nanosecs(void)
+{
+ /*
+ * 601 RTC/DEC registers share clock of 7.8125 MHz, 128 ns per tick.
+ * DEC has max of 25 bits, FFFFFF => 2.14748352 seconds.
+ * RTCU is seconds, 32 bits.
+ * RTCL is nano-seconds, 23 bit counter from 0 - 999,999,872 (999,999,999 - 128 ns)
+ */
+ uint64_t cycles;
+ uint32_t tmp[2];
+
+ mfrtc(tmp);
+
+ cycles = tmp[0] * 1000000000;
+ cycles += (tmp[1] >> 7);
+
+ return cycles;
+}
#endif /* !_MODULE */
static __inline uint32_t
diff -r 944da046c79c -r 941dcc3887e8 sys/arch/powerpc/include/trap.h
--- a/sys/arch/powerpc/include/trap.h Mon Mar 03 15:30:31 2014 +0000
+++ b/sys/arch/powerpc/include/trap.h Mon Mar 03 15:36:36 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.h,v 1.12 2012/07/18 16:44:52 matt Exp $ */
+/* $NetBSD: trap.h,v 1.13 2014/03/03 15:36:36 macallan Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -47,7 +47,8 @@
#define EXC_TRC 0x0d00 /* Trace */
#define EXC_FPA 0x0e00 /* Floating-point Assist */
-/* The following is only available on the 601: */
+/* The following are only available on the 601: */
+#define EXC_IOC 0x0a00 /* I/O Controller Interface Exception */
#define EXC_RUNMODETRC 0x2000 /* Run Mode/Trace Exception */
/* The following are only available on 7400(G4): */
@@ -112,12 +113,78 @@
*/
#define EXC_ALI_OPCODE_INDICATOR(dsisr) ((dsisr >> 10) & 0x7f)
+
+#define EXC_ALI_LWARX_LWZ 0x00
+#define EXC_ALI_LDARX 0x01
+#define EXC_ALI_STW 0x02
+#define EXC_ALI_LHZ 0x04
+#define EXC_ALI_LHA 0x05
+#define EXC_ALI_STH 0x06
+#define EXC_ALI_LMW 0x07
+#define EXC_ALI_LFS 0x08
#define EXC_ALI_LFD 0x09
+#define EXC_ALI_STFS 0x0a
#define EXC_ALI_STFD 0x0b
+#define EXC_ALI_LD_LDU_LWA 0x0d
+#define EXC_ALI_STD_STDU 0x0f
+#define EXC_ALI_LWZU 0x10
+#define EXC_ALI_STWU 0x12
+#define EXC_ALI_LHZU 0x14
+#define EXC_ALI_LHAU 0x15
+#define EXC_ALI_STHU 0x16
+#define EXC_ALI_STMW 0x17
+#define EXC_ALI_LFSU 0x18
+#define EXC_ALI_LFDU 0x19
+#define EXC_ALI_STFSU 0x1a
+#define EXC_ALI_STFDU 0x1b
+#define EXC_ALI_LDX 0x20
+#define EXC_ALI_STDX 0x22
+#define EXC_ALI_LWAX 0x25
+#define EXC_ALI_LSWX 0x28
+#define EXC_ALI_LSWI 0x29
+#define EXC_ALI_STSWX 0x2a
+#define EXC_ALI_STSWI 0x2b
+#define EXC_ALI_LDUX 0x30
+#define EXC_ALI_STDUX 0x32
+#define EXC_ALI_LWAUX 0x35
+#define EXC_ALI_STWCX 0x42 /* stwcx. */
+#define EXC_ALI_STDCX 0x43 /* stdcx. */
+#define EXC_ALI_LWBRX 0x48
+#define EXC_ALI_STWBRX 0x4a
+#define EXC_ALI_LHBRX 0x4c
+#define EXC_ALI_STHBRX 0x4e
+#define EXC_ALI_ECIWX 0x54
+#define EXC_ALI_ECOWX 0x56
#define EXC_ALI_DCBZ 0x5f
+#define EXC_ALI_LWZX 0x60
+#define EXC_ALI_STWX 0x62
+#define EXC_ALI_LHZX 0x64
+#define EXC_ALI_LHAX 0x65
+#define EXC_ALI_STHX 0x66
+#define EXC_ALI_LSFX 0x68
+#define EXC_ALI_LDFX 0x69
+#define EXC_ALI_STFSX 0x6a
+#define EXC_ALI_STFDX 0x6b
+#define EXC_ALI_STFIWX 0x6f
+#define EXC_ALI_LWZUX 0x70
+#define EXC_ALI_STWUX 0x72
+#define EXC_ALI_LHZUX 0x74
+#define EXC_ALI_LHAUX 0x75
+#define EXC_ALI_STHUX 0x76
+#define EXC_ALI_LFSUX 0x78
+#define EXC_ALI_LFDUX 0x79
+#define EXC_ALI_STFSUX 0x7a
+#define EXC_ALI_STFDUX 0x7b
/* Macros to extract register information */
#define EXC_ALI_RST(dsisr) ((dsisr >> 5) & 0x1f) /* source or target */
#define EXC_ALI_RA(dsisr) (dsisr & 0x1f)
+/* Helper defines to classify EXC_ALI_ */
+#define DSI_OP_ZERO 0x0001
+#define DSI_OP_UPDATE 0x0002
+#define DSI_OP_INDEXED 0x0004
+#define DSI_OP_ALGEBRAIC 0x0008
+#define DSI_OP_REVERSED 0x0010
+
#endif /* _POWERPC_TRAP_H_ */
diff -r 944da046c79c -r 941dcc3887e8 sys/arch/powerpc/oea/oea_machdep.c
--- a/sys/arch/powerpc/oea/oea_machdep.c Mon Mar 03 15:30:31 2014 +0000
+++ b/sys/arch/powerpc/oea/oea_machdep.c Mon Mar 03 15:36:36 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: oea_machdep.c,v 1.69 2014/02/28 05:34:39 matt Exp $ */
+/* $NetBSD: oea_machdep.c,v 1.70 2014/03/03 15:36:36 macallan Exp $ */
/*
* Copyright (C) 2002 Matt Thomas
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: oea_machdep.c,v 1.69 2014/02/28 05:34:39 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: oea_machdep.c,v 1.70 2014/03/03 15:36:36 macallan Exp $");
#include "opt_ppcarch.h"
#include "opt_compat_netbsd.h"
@@ -496,9 +496,16 @@
* in pmap_bootstrap().
*/
iosrtable[i] = SR601(SR601_Ks, SR601_BUID_MEMFORCED, 0, i);
+
+ /*
+ * XXX Setting segment register 0xf on my powermac 7200
+ * wedges machine so set later in pmap.c
+ */
+ /*
__asm volatile ("mtsrin %0,%1"
:: "r"(iosrtable[i]),
"r"(pa));
+ */
}
#endif /* PPC_OEA601 */
diff -r 944da046c79c -r 941dcc3887e8 sys/arch/powerpc/oea/ofwoea_machdep.c
--- a/sys/arch/powerpc/oea/ofwoea_machdep.c Mon Mar 03 15:30:31 2014 +0000
+++ b/sys/arch/powerpc/oea/ofwoea_machdep.c Mon Mar 03 15:36:36 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ofwoea_machdep.c,v 1.36 2014/02/28 05:35:49 matt Exp $ */
+/* $NetBSD: ofwoea_machdep.c,v 1.37 2014/03/03 15:36:36 macallan Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofwoea_machdep.c,v 1.36 2014/02/28 05:35:49 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofwoea_machdep.c,v 1.37 2014/03/03 15:36:36 macallan Exp $");
#include "opt_ppcarch.h"
#include "opt_compat_netbsd.h"
@@ -63,6 +63,7 @@
#include <powerpc/oea/bat.h>
#include <powerpc/oea/ofw_rasconsvar.h>
#include <powerpc/oea/cpufeat.h>
+#include <powerpc/include/oea/spr.h>
#include <powerpc/ofw_cons.h>
#include <powerpc/spr.h>
#include <powerpc/pic/picvar.h>
@@ -120,6 +121,11 @@
#if NKSYMS || defined(DDB) || defined(MODULAR)
void *startsym, *endsym;
#endif
+
+#if PPC_OEA601
+#define TIMEBASE_FREQ (1000000000) /* RTC register */
+#endif
+
#ifdef TIMEBASE_FREQ
u_int timebase_freq = TIMEBASE_FREQ;
#else
@@ -334,7 +340,14 @@
ns_per_tick = 1000000000 / ticks_per_sec;
ticks_per_intr = ticks_per_sec / hz;
cpu_timebase = ticks_per_sec;
+
+#ifdef PPC_OEA601
+ if ((mfpvr() >> 16) == MPC601)
+ curcpu()->ci_lasttb = rtc_nanosecs();
+ else
+#endif
curcpu()->ci_lasttb = mftbl();
+
mtspr(SPR_DEC, ticks_per_intr);
mtmsr(msr);
}
@@ -459,6 +472,24 @@
/*
* cover PCI and register space but not the firmware ROM
*/
+#ifdef PPC_OEA601
+
+ /*
+ * use segment registers for the 601
+ */
+ if ((mfpvr() >> 16 ) == MPC601)
+ oea_batinit(
+ 0x80000000, BAT_BL_256M,
+ 0x90000000, BAT_BL_256M,
+ 0xa0000000, BAT_BL_256M,
+ 0xb0000000, BAT_BL_256M,
+ 0xf0000000, BAT_BL_256M,
+ 0);
+ else
+#endif
+ /*
+ * map to bats
+ */
oea_batinit(0x80000000, BAT_BL_1G,
0xf0000000, BAT_BL_128M,
0xf8000000, BAT_BL_64M,
diff -r 944da046c79c -r 941dcc3887e8 sys/arch/powerpc/oea/pmap.c
--- a/sys/arch/powerpc/oea/pmap.c Mon Mar 03 15:30:31 2014 +0000
+++ b/sys/arch/powerpc/oea/pmap.c Mon Mar 03 15:36:36 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.90 2013/11/03 22:15:57 mrg Exp $ */
+/* $NetBSD: pmap.c,v 1.91 2014/03/03 15:36:36 macallan Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -63,7 +63,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.90 2013/11/03 22:15:57 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.91 2014/03/03 15:36:36 macallan Exp $");
#define PMAP_NOOPNAMES
@@ -3403,6 +3403,11 @@
/* PMAP_OEA64_BRIDGE does support these instructions */
#if defined (PMAP_OEA) || defined (PMAP_OEA64_BRIDGE)
for (i = 0; i < 16; i++) {
+#if defined(PPC_OEA601)
+ /* XXX wedges for segment register 0xf , so set later */
+ if ((iosrtable[i] & SR601_T) && ((MFPVR() >> 16) == MPC601))
+ continue;
+#endif
pmap_kernel()->pm_sr[i] = KERNELN_SEGMENT(i)|SR_PRKEY;
__asm volatile ("mtsrin %0,%1"
:: "r"(KERNELN_SEGMENT(i)|SR_PRKEY), "r"(i << ADDR_SR_SHFT));
@@ -3530,4 +3535,9 @@
:: "r"(sr), "r"(kernelstart));
}
#endif
+
+#if defined(PMAPDEBUG)
+ if ( pmapdebug )
+ pmap_print_mmuregs();
+#endif
}
diff -r 944da046c79c -r 941dcc3887e8 sys/arch/powerpc/powerpc/clock.c
--- a/sys/arch/powerpc/powerpc/clock.c Mon Mar 03 15:30:31 2014 +0000
+++ b/sys/arch/powerpc/powerpc/clock.c Mon Mar 03 15:36:36 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: clock.c,v 1.13 2013/04/25 00:11:35 macallan Exp $ */
+/* $NetBSD: clock.c,v 1.14 2014/03/03 15:36:36 macallan Exp $ */
/* $OpenBSD: clock.c,v 1.3 1997/10/13 13:42:53 pefo Exp $ */
/*
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
Home |
Main Index |
Thread Index |
Old Index