diff options
| author | macallan <macallan@NetBSD.org> | 2013-04-11 17:13:15 +0000 |
|---|---|---|
| committer | macallan <macallan@NetBSD.org> | 2013-04-11 17:13:15 +0000 |
| commit | 359c75fa6ae33f82df7aae254f89a64d534e6ae2 (patch) | |
| tree | db64a7cc9e979c3933a2e19c4c5cd7169dc55d0c /sys | |
| parent | 80a2bef9f05bad1926c56123a149be4010116f82 (diff) | |
make PPC_OEA64_BRIDGE mode work
from Phileas Fogg
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/arch/powerpc/oea/ofwoea_machdep.c | 75 | ||||
| -rw-r--r-- | sys/arch/powerpc/oea/pmap.c | 6 | ||||
| -rw-r--r-- | sys/arch/powerpc/powerpc/trap_subr.S | 26 |
3 files changed, 87 insertions, 20 deletions
diff --git a/sys/arch/powerpc/oea/ofwoea_machdep.c b/sys/arch/powerpc/oea/ofwoea_machdep.c index a10f5168a98..d21981946bc 100644 --- a/sys/arch/powerpc/oea/ofwoea_machdep.c +++ b/sys/arch/powerpc/oea/ofwoea_machdep.c @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: ofwoea_machdep.c,v 1.31 2012/10/20 14:42:15 kiyohara #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 @@ __KERNEL_RCSID(0, "$NetBSD: ofwoea_machdep.c,v 1.31 2012/10/20 14:42:15 kiyohara #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 @@ __KERNEL_RCSID(0, "$NetBSD: ofwoea_machdep.c,v 1.31 2012/10/20 14:42:15 kiyohara #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 @@ ofwoea_initppc(u_int startkernel, u_int endkernel, char *args) #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 @@ restore_ofmap(struct ofw_translations *map, int len) 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 @@ static void 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 @@ find_ranges(int base, rangemap_t *regions, int *cur, int type) 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 @@ find_ranges(int base, rangemap_t *regions, int *cur, int type) 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 @@ find_ranges(int base, rangemap_t *regions, int *cur, int type) 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 @@ ofwoea_map_space(int rangetype, int iomem, int node, 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 --git a/sys/arch/powerpc/oea/pmap.c b/sys/arch/powerpc/oea/pmap.c index 2f487f4d841..fb475c57dd7 100644 --- a/sys/arch/powerpc/oea/pmap.c +++ b/sys/arch/powerpc/oea/pmap.c @@ -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 @@ pmap_bootstrap(paddr_t kernelstart, paddr_t kernelend) 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 --git a/sys/arch/powerpc/powerpc/trap_subr.S b/sys/arch/powerpc/powerpc/trap_subr.S index 364741a4082..d6218e5af46 100644 --- a/sys/arch/powerpc/powerpc/trap_subr.S +++ b/sys/arch/powerpc/powerpc/trap_subr.S @@ -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 @@ _C_LABEL(trapsize) = .-_C_LABEL(trapcode) .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 @@ _C_LABEL(alisize) = .-_C_LABEL(alitrap) .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 @@ _C_LABEL(dsisize) = .-_C_LABEL(dsitrap) .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 @@ _C_LABEL(dsi601size) = .-_C_LABEL(dsi601trap) .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 @@ _C_LABEL(extsize) = .-_C_LABEL(extint) .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 @@ _C_LABEL(tlbdsmsize) = .-_C_LABEL(tlbdsmiss) .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 @@ _C_LABEL(ddbsize) = .-_C_LABEL(ddblow) .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 @@ intrleave: .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 @@ _C_LABEL(ddb_trap): andi. %r3,%r3,~(PSL_EE|PSL_ME)@l mtmsr %r3 /* disable interrupts */ isync + ENABLE_64BIT_BRIDGE(%r3) GET_CPUINFO(%r3) streg %r28,(CI_DDBSAVE+CPUSAVE_R28)(%r3) streg %r29,(CI_DDBSAVE+CPUSAVE_R29)(%r3) @@ -1253,6 +1272,7 @@ _C_LABEL(ipkdb_trap): andi. %r3,%r3,~(PSL_EE|PSL_ME)@l mtmsr %r3 /* disable interrupts */ isync + ENABLE_64BIT_BRIDGE(%r3) GET_CPUINFO(%r3) streg %r28,(CI_IPKDBSAVE+CPUSAVE_R28)(%r3) streg %r29,(CI_IPKDBSAVE+CPUSAVE_R29)(%r3) |
