Port-macppc archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: [PATCH] Incorrect segment 0 initialization for PMAC G5



Hi,

as we discussed, here are the modified locore.S.patch and
ofwoea_machdep.c.patch.

locore.S.patch clears SF and ISF bits only if we are in bridge mode.

ofwoea_machdep.c.patch uses display framebuffer address
from rascons_console_screen now.

As soon as the first set of patches is approved i'll send the second
one which adds PIC support ;)

Regards
Index: sys/arch/macppc/macppc/locore.S
===================================================================
RCS file: /pub/NetBSD-CVS/src/sys/arch/macppc/macppc/locore.S,v
retrieving revision 1.70
diff -u -r1.70 locore.S
--- sys/arch/macppc/macppc/locore.S     20 Jun 2011 19:56:12 -0000      1.70
+++ sys/arch/macppc/macppc/locore.S     2 Apr 2013 16:25:41 -0000
@@ -87,6 +87,11 @@
 
        li      0,0
        mtmsr   0                       /* Disable FPU/MMU/exceptions */
+#if defined(PMAP_OEA64_BRIDGE)
+       mfmsr   0                       /* Clear SF and ISF bits */
+       clrldi  0,0,3
+       mtmsrd  0
+#endif /* PMAP_OEA64_BRIDGE */
        isync
 
 /* compute end of kernel memory */
Index: sys/arch/powerpc/oea/ofwoea_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/oea/ofwoea_machdep.c,v
retrieving revision 1.31
diff -u -r1.31 ofwoea_machdep.c
--- sys/arch/powerpc/oea/ofwoea_machdep.c       20 Oct 2012 14:42:15 -0000      
1.31
+++ sys/arch/powerpc/oea/ofwoea_machdep.c       2 Apr 2013 16:23:23 -0000
@@ -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 != 0) {
+                       for (va = (vaddr_t) ri->ri_bits;
+                           va < roundup((vaddr_t) ri->ri_bits +
+                               ri->ri_height * ri->ri_stride, PAGE_SIZE);
+                           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++) {


Home | Main Index | Thread Index | Old Index