Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/powerpc make PPC_OEA64_BRIDGE mode work
details: https://anonhg.NetBSD.org/src/rev/298598650e17
branches: trunk
changeset: 786019:298598650e17
user: macallan <macallan%NetBSD.org@localhost>
date: Thu Apr 11 17:13:15 2013 +0000
description:
make PPC_OEA64_BRIDGE mode work
from Phileas Fogg
diffstat:
sys/arch/powerpc/oea/ofwoea_machdep.c | 75 ++++++++++++++++++++++++++++------
sys/arch/powerpc/oea/pmap.c | 6 +-
sys/arch/powerpc/powerpc/trap_subr.S | 26 ++++++++++-
3 files changed, 87 insertions(+), 20 deletions(-)
diffs (truncated from 315 to 300 lines):
diff -r a317b7a4c570 -r 298598650e17 sys/arch/powerpc/oea/ofwoea_machdep.c
--- a/sys/arch/powerpc/oea/ofwoea_machdep.c Thu Apr 11 17:00:12 2013 +0000
+++ b/sys/arch/powerpc/oea/ofwoea_machdep.c Thu Apr 11 17:13:15 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ofwoea_machdep.c,v 1.31 2012/10/20 14:42:15 kiyohara Exp $ */
+/* $NetBSD: ofwoea_machdep.c,v 1.32 2013/04/11 17:13:15 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.31 2012/10/20 14:42:15 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofwoea_machdep.c,v 1.32 2013/04/11 17:13:15 macallan Exp $");
#include "opt_ppcarch.h"
#include "opt_compat_netbsd.h"
@@ -39,6 +39,8 @@
#include "opt_ipkdb.h"
#include "opt_modular.h"
+#include "wsdisplay.h"
+
#include <sys/param.h>
#include <sys/buf.h>
#include <sys/boot_flag.h>
@@ -48,6 +50,10 @@
#include <uvm/uvm_extern.h>
#include <dev/ofw/openfirm.h>
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wsdisplayvar.h>
+#include <dev/rasops/rasops.h>
+#include <dev/wscons/wsdisplay_vconsvar.h>
#include <machine/pmap.h>
#include <machine/powerpc.h>
#include <machine/trap.h>
@@ -55,6 +61,7 @@
#include <machine/autoconf.h>
#include <sys/bus.h>
#include <powerpc/oea/bat.h>
+#include <powerpc/oea/ofw_rasconsvar.h>
#include <powerpc/oea/cpufeat.h>
#include <powerpc/ofw_cons.h>
#include <powerpc/spr.h>
@@ -230,9 +237,44 @@
#if defined(PPC_OEA64) || defined (PPC_OEA64_BRIDGE)
#if defined (PMAC_G5)
/* Mapin 1st 256MB segment 1:1, also map in mem needed to access OFW*/
- if (oeacpufeat & OEACPU_64_BRIDGE)
- pmap_setup_segment0_map(0, 0xff800000, 0x3fc00000, 0x400000,
- 0x0);
+ if (oeacpufeat & OEACPU_64_BRIDGE) {
+ vaddr_t va;
+ paddr_t pa;
+ int i;
+
+ pmap_setup_segment0_map(0, 0x0);
+
+ /* Map OFW code+data */
+
+ for (i = 0; i < ofmaplen / sizeof(struct ofw_translations); i++) {
+ if (ofmap[i].va < 0xff800000)
+ continue;
+
+ for (va = ofmap[i].va, pa = ofmap[i].pa;
+ va < ofmap[i].va + ofmap[i].len;
+ va += PAGE_SIZE, pa += PAGE_SIZE) {
+ pmap_enter(pmap_kernel(), va, pa, VM_PROT_ALL,
+ VM_PROT_ALL | PMAP_WIRED);
+ }
+ }
+
+#if NWSDISPLAY > 0
+ /* Map video frame buffer */
+
+ struct rasops_info *ri = &rascons_console_screen.scr_ri;
+
+ if (ri->ri_bits != NULL) {
+ for (va = (vaddr_t) ri->ri_bits;
+ va < round_page((vaddr_t) ri->ri_bits +
+ ri->ri_height * ri->ri_stride);
+ va += PAGE_SIZE) {
+ pmap_enter(pmap_kernel(), va, va,
+ VM_PROT_READ | VM_PROT_WRITE,
+ PMAP_NOCACHE | PMAP_WIRED);
+ }
+ }
+#endif
+ }
#elif defined (MAMBO)
/* Mapin 1st 256MB segment 1:1, also map in mem needed to access OFW*/
if (oeacpufeat & OEACPU_64_BRIDGE)
@@ -330,10 +372,11 @@
pmap_pinit(&ofw_pmap);
- ofw_pmap.pm_sr[KERNEL_SR] = KERNEL_SEGMENT;
+ ofw_pmap.pm_sr[0] = KERNELN_SEGMENT(0)|SR_PRKEY;
+ ofw_pmap.pm_sr[KERNEL_SR] = KERNEL_SEGMENT|SR_SUKEY|SR_PRKEY;
#ifdef KERNEL2_SR
- ofw_pmap.pm_sr[KERNEL2_SR] = KERNEL2_SEGMENT;
+ ofw_pmap.pm_sr[KERNEL2_SR] = KERNEL2_SEGMENT|SR_SUKEY|SR_PRKEY;
#endif
for (i = 0; i < n; i++) {
@@ -466,7 +509,7 @@
find_ranges(int base, rangemap_t *regions, int *cur, int type)
{
int node, i, len, reclen;
- u_int32_t acells, scells, map[160];
+ u_int32_t parent_acells, acells, scells, map[160];
char tmp[32];
node = base;
@@ -480,12 +523,15 @@
len = OF_getprop(node, "ranges", map, sizeof(map));
if (len == -1)
goto rec;
+ if (OF_getprop(OF_parent(node), "#address-cells", &parent_acells,
+ sizeof(parent_acells)) != sizeof(parent_acells))
+ parent_acells = 1;
if (OF_getprop(node, "#address-cells", &acells,
sizeof(acells)) != sizeof(acells))
- acells = 1;
+ acells = 3;
if (OF_getprop(node, "#size-cells", &scells,
sizeof(scells)) != sizeof(scells))
- scells = 1;
+ scells = 2;
#ifdef ofppc
if (modeldata.ranges_offset == 0)
scells -= 1;
@@ -493,7 +539,7 @@
if (type == RANGE_TYPE_ISA)
reclen = 6;
else
- reclen = acells + scells + 1;
+ reclen = parent_acells + acells + scells;
/*
* There exist ISA buses with empty ranges properties. This is
* known to occur on the Pegasos II machine, and likely others.
@@ -514,12 +560,12 @@
for (i=0; i < len/(4*reclen); i++) {
DPRINTF("FOUND PCI RANGE\n");
regions[*cur].size =
- map[i*reclen + acells + scells];
+ map[i*reclen + parent_acells + acells + scells - 1];
/* skip ranges of size==0 */
if (regions[*cur].size == 0)
continue;
- regions[*cur].type = map[i*reclen] >> 24;
- regions[*cur].addr = map[i*reclen + acells];
+ regions[*cur].type = (map[i*reclen] >> 24) & 0x3;
+ regions[*cur].addr = map[i*reclen + parent_acells + acells - 1];
(*cur)++;
}
break;
@@ -583,6 +629,7 @@
rangemap_t region, holes[32], list[32];
memset(list, 0, sizeof(list));
+ memset(®ion, 0, sizeof(region));
cur = 0;
if (rangetype == RANGE_TYPE_ISA || node == -1)
node = OF_finddevice("/");
diff -r a317b7a4c570 -r 298598650e17 sys/arch/powerpc/oea/pmap.c
--- a/sys/arch/powerpc/oea/pmap.c Thu Apr 11 17:00:12 2013 +0000
+++ b/sys/arch/powerpc/oea/pmap.c Thu Apr 11 17:13:15 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.88 2013/03/28 00:22:21 christos Exp $ */
+/* $NetBSD: pmap.c,v 1.89 2013/04/11 17:13:15 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.88 2013/03/28 00:22:21 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.89 2013/04/11 17:13:15 macallan Exp $");
#define PMAP_NOOPNAMES
@@ -3465,7 +3465,7 @@
sizeof(void *), 0, 0, "pmap_pl", &pmap_pool_uallocator,
IPL_NONE);
-#if defined(PMAP_NEED_MAPKERNEL) || 1
+#if defined(PMAP_NEED_MAPKERNEL)
{
struct pmap *pm = pmap_kernel();
#if defined(PMAP_NEED_FULL_MAPKERNEL)
diff -r a317b7a4c570 -r 298598650e17 sys/arch/powerpc/powerpc/trap_subr.S
--- a/sys/arch/powerpc/powerpc/trap_subr.S Thu Apr 11 17:00:12 2013 +0000
+++ b/sys/arch/powerpc/powerpc/trap_subr.S Thu Apr 11 17:13:15 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap_subr.S,v 1.75 2012/07/27 04:17:07 matt Exp $ */
+/* $NetBSD: trap_subr.S,v 1.76 2013/04/11 17:13:15 macallan Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -55,11 +55,20 @@
#define RESTORE_VRSAVE(tf,b)
#endif
-#if defined (PPC_OEA64)
+#if defined (PPC_OEA64) || defined (PPC_OEA64_BRIDGE)
#define RFI rfid
#else
#define RFI rfi
-#endif /* PPC_OEA64 */
+#endif /* PPC_OEA64 || PPC_OEA64_BRIDGE*/
+
+#if defined (PPC_OEA64_BRIDGE)
+#define ENABLE_64BIT_BRIDGE(t0) \
+ mfmsr t0; \
+ clrldi t0,t0,1; \
+ mtmsrd t0;
+#else
+#define ENABLE_64BIT_BRIDGE(t0)
+#endif /* PPC_OEA64_BRIDGE */
#if defined(PPC_OEA64)
/*
@@ -170,6 +179,7 @@
.globl _C_LABEL(trapcode),_C_LABEL(trapsize)
_C_LABEL(trapcode):
mtsprg1 %r1 /* save SP */
+ ENABLE_64BIT_BRIDGE(%r1)
GET_CPUINFO(%r1)
streg %r28,(CI_TEMPSAVE+CPUSAVE_R28)(%r1) /* free r28 */
streg %r29,(CI_TEMPSAVE+CPUSAVE_R29)(%r1) /* free r29 */
@@ -199,6 +209,7 @@
.globl _C_LABEL(alitrap),_C_LABEL(alisize)
_C_LABEL(alitrap):
mtsprg1 %r1 /* save SP */
+ ENABLE_64BIT_BRIDGE(%r1)
GET_CPUINFO(%r1)
streg %r28,(CI_TEMPSAVE+CPUSAVE_R28)(%r1) /* save r28 */
streg %r29,(CI_TEMPSAVE+CPUSAVE_R29)(%r1) /* save r29 */
@@ -234,6 +245,7 @@
.globl _C_LABEL(dsitrap),_C_LABEL(dsisize)
_C_LABEL(dsitrap):
mtsprg1 %r1
+ ENABLE_64BIT_BRIDGE(%r1)
GET_CPUINFO(%r1)
streg %r28,(CI_DISISAVE+CPUSAVE_R28)(%r1) /* save r28 */
streg %r29,(CI_DISISAVE+CPUSAVE_R29)(%r1) /* save r29 */
@@ -330,6 +342,7 @@
.globl _C_LABEL(dsi601trap),_C_LABEL(dsi601size)
_C_LABEL(dsi601trap):
mtsprg1 %r1
+ ENABLE_64BIT_BRIDGE(%r1)
GET_CPUINFO(%r1)
streg %r28,(CI_DISISAVE+CPUSAVE_R28)(%r1) /* save r28 */
streg %r29,(CI_DISISAVE+CPUSAVE_R29)(%r1) /* save r29 */
@@ -397,6 +410,7 @@
.globl _C_LABEL(extint),_C_LABEL(extsize)
_C_LABEL(extint):
mtsprg1 %r1 /* save SP */
+ ENABLE_64BIT_BRIDGE(%r1)
GET_CPUINFO(%r1)
streg %r28,(CI_TEMPSAVE+CPUSAVE_R28)(%r1) /* save r28 */
streg %r29,(CI_TEMPSAVE+CPUSAVE_R29)(%r1) /* save r29 */
@@ -430,6 +444,7 @@
.globl _C_LABEL(decrint),_C_LABEL(decrsize)
_C_LABEL(decrint):
mtsprg1 %r1 /* save SP */
+ ENABLE_64BIT_BRIDGE(%r1)
GET_CPUINFO(%r1)
streg %r28,(CI_TEMPSAVE+CPUSAVE_R28)(%r1) /* save r28 */
streg %r29,(CI_TEMPSAVE+CPUSAVE_R29)(%r1) /* save r29 */
@@ -673,6 +688,7 @@
.globl _C_LABEL(ddblow),_C_LABEL(ddbsize)
_C_LABEL(ddblow):
mtsprg1 %r1 /* save SP */
+ ENABLE_64BIT_BRIDGE(%r1)
mtsprg2 %r29 /* save r29 */
mfcr %r29 /* save CR in r29 */
mfsrr1 %r1
@@ -728,6 +744,7 @@
.globl _C_LABEL(ipkdblow),_C_LABEL(ipkdbsize)
_C_LABEL(ipkdblow):
mtsprg1 %r1 /* save SP */
+ ENABLE_64BIT_BRIDGE(%r1)
GET_CPUINFO(%r1)
streg %r28,(CI_IPKDBSAVE+CPUSAVE_R28)(%r1) /* save r28 */
streg %r29,(CI_IPKDBSAVE+CPUSAVE_R29)(%r1) /* save r29 */
@@ -1020,6 +1037,7 @@
.globl _C_LABEL(sctrap),_C_LABEL(scsize),_C_LABEL(sctrapexit)
_C_LABEL(sctrap):
mtsprg1 %r1 /* save SP */
+ ENABLE_64BIT_BRIDGE(%r1)
GET_CPUINFO(%r1)
streg %r28,(CI_TEMPSAVE+CPUSAVE_R28)(%r1) /* save r28 */
streg %r29,(CI_TEMPSAVE+CPUSAVE_R29)(%r1) /* save r20 */
@@ -1213,6 +1231,7 @@
Home |
Main Index |
Thread Index |
Old Index