Author: nwhitehorn
Date: Fri Nov 12 05:12:38 2010
New Revision: 215163
URL: http://svn.freebsd.org/changeset/base/215163

Log:
  Remove use of a separate ofw_pmap on 32-bit CPUs. Many Open Firmware
  mappings need to end up in the kernel anyway since the kernel begins
  executing in OF context. Separating them adds needless complexity,
  especially since the powerpc64 and mmu_oea64 code gave up on it a long
  time ago.
  
  As a side effect, the PPC ofw_machdep code is no longer AIM-specific,
  so move it to powerpc/ofw.

Added:
  head/sys/powerpc/ofw/ofw_machdep.c
     - copied, changed from r215159, head/sys/powerpc/aim/ofw_machdep.c
Deleted:
  head/sys/powerpc/aim/ofw_machdep.c
Modified:
  head/sys/conf/files.powerpc
  head/sys/powerpc/aim/machdep.c
  head/sys/powerpc/aim/mmu_oea.c
  head/sys/powerpc/aim/mmu_oea64.c

Modified: head/sys/conf/files.powerpc
==============================================================================
--- head/sys/conf/files.powerpc Fri Nov 12 05:09:47 2010        (r215162)
+++ head/sys/conf/files.powerpc Fri Nov 12 05:12:38 2010        (r215163)
@@ -85,7 +85,6 @@ powerpc/aim/mmu_oea.c         optional        aim powe
 powerpc/aim/mmu_oea64.c                optional        aim
 powerpc/aim/mp_cpudep.c                optional        aim smp
 powerpc/aim/nexus.c            optional        aim
-powerpc/aim/ofw_machdep.c      optional        aim
 powerpc/aim/ofwmagic.S         optional        aim
 powerpc/aim/slb.c              optional        aim powerpc64
 powerpc/aim/swtch32.S          optional        aim powerpc
@@ -131,6 +130,7 @@ powerpc/mpc85xx/nexus.c             optional        mpc85x
 powerpc/mpc85xx/openpic_fdt.c  optional        fdt
 powerpc/mpc85xx/pci_fdt.c      optional        pci mpc85xx
 powerpc/ofw/ofw_cpu.c          optional        aim
+powerpc/ofw/ofw_machdep.c      optional        aim
 powerpc/ofw/ofw_pcibus.c       optional        pci aim
 powerpc/ofw/ofw_pcib_pci.c     optional        pci aim
 powerpc/ofw/ofw_real.c         optional        aim

Modified: head/sys/powerpc/aim/machdep.c
==============================================================================
--- head/sys/powerpc/aim/machdep.c      Fri Nov 12 05:09:47 2010        
(r215162)
+++ head/sys/powerpc/aim/machdep.c      Fri Nov 12 05:12:38 2010        
(r215163)
@@ -159,8 +159,6 @@ int             setfault(faultbuf);     
 long           Maxmem = 0;
 long           realmem = 0;
 
-struct pmap    ofw_pmap;
-
 #ifndef __powerpc64__
 struct bat     battable[16];
 #endif

Modified: head/sys/powerpc/aim/mmu_oea.c
==============================================================================
--- head/sys/powerpc/aim/mmu_oea.c      Fri Nov 12 05:09:47 2010        
(r215162)
+++ head/sys/powerpc/aim/mmu_oea.c      Fri Nov 12 05:12:38 2010        
(r215163)
@@ -197,8 +197,6 @@ static u_int    phys_avail_count;
 static int     regions_sz, pregions_sz;
 static struct  ofw_map *translations;
 
-extern struct pmap ofw_pmap;
-
 /*
  * Lock for the pteg and pvo tables.
  */
@@ -669,10 +667,7 @@ moea_cpu_bootstrap(mmu_t mmup, int ap)
        isync();
 
        for (i = 0; i < 16; i++)
-               mtsrin(i << ADDR_SR_SHFT, EMPTY_SEGMENT);
-
-       __asm __volatile("mtsr %0,%1" :: "n"(KERNEL_SR), "r"(KERNEL_SEGMENT));
-       __asm __volatile("mtsr %0,%1" :: "n"(KERNEL2_SR), "r"(KERNEL2_SEGMENT));
+               mtsrin(i << ADDR_SR_SHFT, kernel_pmap->pm_sr[i]);
        powerpc_sync();
 
        sdr = (u_int)moea_pteg_table | (moea_pteg_mask >> 10);
@@ -859,11 +854,16 @@ moea_bootstrap(mmu_t mmup, vm_offset_t k
        moea_vsid_bitmap[0] |= 1;
 
        /*
-        * Set up the Open Firmware pmap and add it's mappings.
+        * Initialize the kernel pmap (which is statically allocated).
+        */
+       PMAP_LOCK_INIT(kernel_pmap);
+       for (i = 0; i < 16; i++)
+               kernel_pmap->pm_sr[i] = EMPTY_SEGMENT + i;
+       kernel_pmap->pm_active = ~0;
+
+       /*
+        * Set up the Open Firmware mappings
         */
-       moea_pinit(mmup, &ofw_pmap);
-       ofw_pmap.pm_sr[KERNEL_SR] = KERNEL_SEGMENT;
-       ofw_pmap.pm_sr[KERNEL2_SR] = KERNEL2_SEGMENT;
        if ((chosen = OF_finddevice("/chosen")) == -1)
                panic("moea_bootstrap: can't find /chosen");
        OF_getprop(chosen, "mmu", &mmui, 4);
@@ -900,16 +900,8 @@ moea_bootstrap(mmu_t mmup, vm_offset_t k
 
                /* Enter the pages */
                for (off = 0; off < translations[i].om_len; off += PAGE_SIZE) {
-                       struct  vm_page m;
-
-                       m.phys_addr = translations[i].om_pa + off;
-                       m.md.mdpg_cache_attrs = VM_MEMATTR_DEFAULT;
-                       m.oflags = VPO_BUSY;
-                       PMAP_LOCK(&ofw_pmap);
-                       moea_enter_locked(&ofw_pmap,
-                                  translations[i].om_va + off, &m,
-                                  VM_PROT_ALL, 1);
-                       PMAP_UNLOCK(&ofw_pmap);
+                       moea_kenter(mmup, translations[i].om_va + off, 
+                                   translations[i].om_pa + off);
                        ofw_mappings++;
                }
        }
@@ -921,17 +913,6 @@ moea_bootstrap(mmu_t mmup, vm_offset_t k
                ;
        Maxmem = powerpc_btop(phys_avail[i + 1]);
 
-       /*
-        * Initialize the kernel pmap (which is statically allocated).
-        */
-       PMAP_LOCK_INIT(kernel_pmap);
-       for (i = 0; i < 16; i++) {
-               kernel_pmap->pm_sr[i] = EMPTY_SEGMENT;
-       }
-       kernel_pmap->pm_sr[KERNEL_SR] = KERNEL_SEGMENT;
-       kernel_pmap->pm_sr[KERNEL2_SR] = KERNEL2_SEGMENT;
-       kernel_pmap->pm_active = ~0;
-
        moea_cpu_bootstrap(mmup,0);
 
        pmap_bootstrapped++;

Modified: head/sys/powerpc/aim/mmu_oea64.c
==============================================================================
--- head/sys/powerpc/aim/mmu_oea64.c    Fri Nov 12 05:09:47 2010        
(r215162)
+++ head/sys/powerpc/aim/mmu_oea64.c    Fri Nov 12 05:12:38 2010        
(r215163)
@@ -275,8 +275,6 @@ static struct       mem_region *pregions;
 static u_int   phys_avail_count;
 static int     regions_sz, pregions_sz;
 
-extern struct pmap ofw_pmap;
-
 extern void bs_remap_earlyboot(void);
 
 
@@ -1119,13 +1117,6 @@ moea64_bootstrap(mmu_t mmup, vm_offset_t
 
        chosen = OF_finddevice("/chosen");
        if (chosen != -1 && OF_getprop(chosen, "mmu", &mmui, 4) != -1) {
-           #ifndef __powerpc64__
-           moea64_pinit(mmup, &ofw_pmap);
-
-           for (i = 0; i < 16; i++)
-               ofw_pmap.pm_sr[i] = kernel_pmap->pm_sr[i];
-           #endif
-
            mmu = OF_instance_to_package(mmui);
            if (mmu == -1 || (sz = OF_getproplen(mmu, "translations")) == -1)
                sz = 0;

Copied and modified: head/sys/powerpc/ofw/ofw_machdep.c (from r215159, 
head/sys/powerpc/aim/ofw_machdep.c)
==============================================================================
--- head/sys/powerpc/aim/ofw_machdep.c  Fri Nov 12 04:18:19 2010        
(r215159, copy source)
+++ head/sys/powerpc/ofw/ofw_machdep.c  Fri Nov 12 05:12:38 2010        
(r215163)
@@ -66,7 +66,6 @@ static struct mem_region OFfree[OFMEM_RE
 static int nOFmem;
 
 extern register_t ofmsr[5];
-extern struct  pmap ofw_pmap;
 static int     (*ofwcall)(void *);
 static void    *fdt;
 int            ofw_real_mode;
@@ -417,59 +416,27 @@ openfirmware_core(void *args)
 {
        int             result;
        register_t      oldmsr;
-       #ifndef __powerpc64__
-       register_t      srsave[16];
-       u_int           i;
-       #endif
 
        /*
         * Turn off exceptions - we really don't want to end up
-        * anywhere unexpected with PCPU set to something strange,
-        * the stack pointer wrong, or the OFW mapping enabled.
+        * anywhere unexpected with PCPU set to something strange
+        * or the stack pointer wrong.
         */
        oldmsr = intr_disable();
 
        ofw_sprg_prepare();
 
-      #ifndef __powerpc64__
-       if (pmap_bootstrapped && !ofw_real_mode) {
-               /*
-                * Swap the kernel's address space with Open Firmware's
-                */
-
-               for (i = 0; i < 16; i++) {
-                       srsave[i] = mfsrin(i << ADDR_SR_SHFT);
-                       mtsrin(i << ADDR_SR_SHFT, ofw_pmap.pm_sr[i]);
-               }
-
-               /*
-                * Clear battable[] translations
-                */
-               if (!(cpu_features & PPC_FEATURE_64)) {
-                       __asm __volatile("mtdbatu 2, %0\n"
-                                        "mtdbatu 3, %0" : : "r" (0));
-               }
-               isync();
-       }
-      #endif
+#if defined(AIM) && !defined(__powerpc64__)
+       /*
+        * Clear battable[] translations
+        */
+       if (!(cpu_features & PPC_FEATURE_64))
+               __asm __volatile("mtdbatu 2, %0\n"
+                                "mtdbatu 3, %0" : : "r" (0));
+       isync();
+#endif
 
                result = ofwcall(args);
-
-      #ifndef __powerpc64__
-       if (pmap_bootstrapped && !ofw_real_mode) {
-               /*
-                * Restore the kernel's addr space. The isync() doesn;t
-                * work outside the loop unless mtsrin() is open-coded
-                * in an asm statement :(
-                */
-
-               for (i = 0; i < 16; i++) {
-                       mtsrin(i << ADDR_SR_SHFT, srsave[i]);
-                       isync();
-               }
-       }
-      #endif
-
        ofw_sprg_restore();
 
        intr_restore(oldmsr);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to