svn commit: r257181 - in projects/ifnet/sys: amd64/amd64 compat/linsysfs compat/linux dev/sfxge dev/sn dev/xe net80211 netinet/libalias netinet6 netipsec netnatm netpfil/ipfw netpfil/pf powerpc/aim...

Gleb Smirnoff glebius at FreeBSD.org
Sat Oct 26 18:22:23 UTC 2013


Author: glebius
Date: Sat Oct 26 18:22:16 2013
New Revision: 257181
URL: http://svnweb.freebsd.org/changeset/base/257181

Log:
  Merge head r256150 through r257180.

Modified:
  projects/ifnet/sys/amd64/amd64/bpf_jit_machdep.c
  projects/ifnet/sys/compat/linsysfs/linsysfs.c
  projects/ifnet/sys/compat/linux/linux_socket.c
  projects/ifnet/sys/dev/sfxge/sfxge_dma.c
  projects/ifnet/sys/dev/sfxge/sfxge_ev.c
  projects/ifnet/sys/dev/sfxge/sfxge_intr.c
  projects/ifnet/sys/dev/sn/if_sn_isa.c
  projects/ifnet/sys/dev/xe/if_xe_pccard.c
  projects/ifnet/sys/net80211/ieee80211_phy.c
  projects/ifnet/sys/net80211/ieee80211_ratectl.c
  projects/ifnet/sys/net80211/ieee80211_ratectl_none.c
  projects/ifnet/sys/netinet/libalias/alias_db.c
  projects/ifnet/sys/netinet6/ip6_id.c
  projects/ifnet/sys/netipsec/keysock.c
  projects/ifnet/sys/netipsec/xform_ah.c
  projects/ifnet/sys/netipsec/xform_esp.c
  projects/ifnet/sys/netnatm/natm_proto.c
  projects/ifnet/sys/netpfil/ipfw/ip_dn_io.c
  projects/ifnet/sys/netpfil/ipfw/ip_dummynet.c
  projects/ifnet/sys/netpfil/pf/pf_ruleset.c
  projects/ifnet/sys/netpfil/pf/pf_table.c
  projects/ifnet/sys/powerpc/aim/machdep.c
  projects/ifnet/sys/powerpc/aim/mmu_oea64.c
  projects/ifnet/sys/powerpc/booke/machdep.c
  projects/ifnet/sys/powerpc/booke/machdep_e500.c
  projects/ifnet/sys/powerpc/booke/pmap.c
  projects/ifnet/sys/powerpc/include/pmap.h
  projects/ifnet/sys/powerpc/include/tlb.h
  projects/ifnet/sys/powerpc/include/vmparam.h
  projects/ifnet/sys/powerpc/mpc85xx/mpc85xx.c
  projects/ifnet/sys/powerpc/mpc85xx/mpc85xx.h
  projects/ifnet/sys/powerpc/powerpc/bus_machdep.c
Directory Properties:
  projects/ifnet/   (props changed)
  projects/ifnet/sys/   (props changed)

Modified: projects/ifnet/sys/amd64/amd64/bpf_jit_machdep.c
==============================================================================
--- projects/ifnet/sys/amd64/amd64/bpf_jit_machdep.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/amd64/amd64/bpf_jit_machdep.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/kernel.h>
 #include <sys/socket.h>
 #include <sys/malloc.h>
+#include <sys/mbuf.h>
 #include <net/if.h>
 #else
 #include <stdlib.h>

Modified: projects/ifnet/sys/compat/linsysfs/linsysfs.c
==============================================================================
--- projects/ifnet/sys/compat/linsysfs/linsysfs.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/compat/linsysfs/linsysfs.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -28,6 +28,7 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
+#include <sys/systm.h>
 #include <sys/queue.h>
 #include <sys/blist.h>
 #include <sys/conf.h>

Modified: projects/ifnet/sys/compat/linux/linux_socket.c
==============================================================================
--- projects/ifnet/sys/compat/linux/linux_socket.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/compat/linux/linux_socket.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/un.h>
 
 #include <net/if.h>
+#include <net/vnet.h>
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
 #include <netinet/ip.h>
@@ -60,7 +61,6 @@ __FBSDID("$FreeBSD$");
 #ifdef INET6
 #include <netinet/ip6.h>
 #include <netinet6/ip6_var.h>
-#include <netinet6/in6_var.h>
 #endif
 
 #ifdef COMPAT_LINUX32

Modified: projects/ifnet/sys/dev/sfxge/sfxge_dma.c
==============================================================================
--- projects/ifnet/sys/dev/sfxge/sfxge_dma.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/dev/sfxge/sfxge_dma.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -32,6 +32,10 @@ __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
 #include <sys/bus.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/queue.h>
+#include <sys/taskqueue.h>
 
 #include <machine/bus.h>
 

Modified: projects/ifnet/sys/dev/sfxge/sfxge_ev.c
==============================================================================
--- projects/ifnet/sys/dev/sfxge/sfxge_ev.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/dev/sfxge/sfxge_ev.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -31,7 +31,12 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/param.h>
+#include <sys/queue.h>
 #include <sys/systm.h>
+#include <sys/taskqueue.h>
 
 #include "common/efx.h"
 

Modified: projects/ifnet/sys/dev/sfxge/sfxge_intr.c
==============================================================================
--- projects/ifnet/sys/dev/sfxge/sfxge_intr.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/dev/sfxge/sfxge_intr.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -32,9 +32,13 @@ __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
 #include <sys/bus.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/queue.h>
 #include <sys/rman.h>
 #include <sys/smp.h>
 #include <sys/syslog.h>
+#include <sys/taskqueue.h>
 
 #include <machine/bus.h>
 #include <machine/resource.h>

Modified: projects/ifnet/sys/dev/sn/if_sn_isa.c
==============================================================================
--- projects/ifnet/sys/dev/sn/if_sn_isa.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/dev/sn/if_sn_isa.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -28,6 +28,7 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
+#include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/socket.h>
 

Modified: projects/ifnet/sys/dev/xe/if_xe_pccard.c
==============================================================================
--- projects/ifnet/sys/dev/xe/if_xe_pccard.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/dev/xe/if_xe_pccard.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -32,7 +32,9 @@ __FBSDID("$FreeBSD$");
 #include <sys/param.h>
 #include <sys/bus.h>
 #include <sys/kernel.h>
+#include <sys/lock.h>
 #include <sys/module.h>
+#include <sys/mutex.h>
 #include <sys/socket.h>
 #include <sys/systm.h>
 

Modified: projects/ifnet/sys/net80211/ieee80211_phy.c
==============================================================================
--- projects/ifnet/sys/net80211/ieee80211_phy.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/net80211/ieee80211_phy.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -35,12 +35,16 @@ __FBSDID("$FreeBSD$");
 #include <sys/param.h>
 #include <sys/kernel.h>
 #include <sys/systm.h>
+#include <sys/malloc.h>
 
 #include <sys/socket.h>
 
 #include <net/if.h>
 #include <net/if_media.h>
 
+#include <net/ethernet.h>
+#include <net/route.h>
+
 #include <net80211/ieee80211_var.h>
 #include <net80211/ieee80211_phy.h>
 

Modified: projects/ifnet/sys/net80211/ieee80211_ratectl.c
==============================================================================
--- projects/ifnet/sys/net80211/ieee80211_ratectl.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/net80211/ieee80211_ratectl.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -30,9 +30,12 @@ __FBSDID("$FreeBSD$");
 #include <sys/kernel.h>
 #include <sys/systm.h>
 #include <sys/socket.h>
+#include <sys/malloc.h>
 
 #include <net/if.h>
 #include <net/if_media.h>
+#include <net/ethernet.h>
+#include <net/route.h>
 
 #include <net80211/ieee80211_var.h>
 #include <net80211/ieee80211_ratectl.h>

Modified: projects/ifnet/sys/net80211/ieee80211_ratectl_none.c
==============================================================================
--- projects/ifnet/sys/net80211/ieee80211_ratectl_none.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/net80211/ieee80211_ratectl_none.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -29,13 +29,16 @@ __FBSDID("$FreeBSD$");
 #include "opt_wlan.h"
 
 #include <sys/param.h>
+#include <sys/systm.h>
 #include <sys/kernel.h>
+#include <sys/malloc.h>
 #include <sys/module.h>
 #include <sys/socket.h>
 #include <sys/sysctl.h>
 
 #include <net/if.h>
 #include <net/if_media.h>
+#include <net/ethernet.h>
 
 #ifdef INET
 #include <netinet/in.h>

Modified: projects/ifnet/sys/netinet/libalias/alias_db.c
==============================================================================
--- projects/ifnet/sys/netinet/libalias/alias_db.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/netinet/libalias/alias_db.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -146,6 +146,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/stdarg.h>
 #include <sys/param.h>
 #include <sys/kernel.h>
+#include <sys/systm.h>
 #include <sys/lock.h>
 #include <sys/module.h>
 #include <sys/rwlock.h>

Modified: projects/ifnet/sys/netinet6/ip6_id.c
==============================================================================
--- projects/ifnet/sys/netinet6/ip6_id.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/netinet6/ip6_id.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -97,6 +97,7 @@ __FBSDID("$FreeBSD$");
 
 #include <net/if.h>
 #include <net/route.h>
+#include <net/vnet.h>
 #include <netinet/in.h>
 #include <netinet/ip6.h>
 #include <netinet6/ip6_var.h>

Modified: projects/ifnet/sys/netipsec/keysock.c
==============================================================================
--- projects/ifnet/sys/netipsec/keysock.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/netipsec/keysock.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -52,9 +52,9 @@
 #include <sys/systm.h>
 
 #include <net/if.h>
+#include <net/vnet.h>
 #include <net/raw_cb.h>
 #include <net/route.h>
-#include <net/vnet.h>
 
 #include <netinet/in.h>
 

Modified: projects/ifnet/sys/netipsec/xform_ah.c
==============================================================================
--- projects/ifnet/sys/netipsec/xform_ah.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/netipsec/xform_ah.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -45,6 +45,8 @@
 #include <sys/socket.h>
 #include <sys/syslog.h>
 #include <sys/kernel.h>
+#include <sys/lock.h>
+#include <sys/rwlock.h>
 #include <sys/sysctl.h>
 
 #include <net/if.h>

Modified: projects/ifnet/sys/netipsec/xform_esp.c
==============================================================================
--- projects/ifnet/sys/netipsec/xform_esp.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/netipsec/xform_esp.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -44,7 +44,9 @@
 #include <sys/socket.h>
 #include <sys/syslog.h>
 #include <sys/kernel.h>
+#include <sys/lock.h>
 #include <sys/random.h>
+#include <sys/rwlock.h>
 #include <sys/sysctl.h>
 
 #include <net/if.h>

Modified: projects/ifnet/sys/netnatm/natm_proto.c
==============================================================================
--- projects/ifnet/sys/netnatm/natm_proto.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/netnatm/natm_proto.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -41,6 +41,8 @@ __FBSDID("$FreeBSD$");
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
 #include <sys/socket.h>
 #include <sys/protosw.h>
 #include <sys/domain.h>

Modified: projects/ifnet/sys/netpfil/ipfw/ip_dn_io.c
==============================================================================
--- projects/ifnet/sys/netpfil/ipfw/ip_dn_io.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/netpfil/ipfw/ip_dn_io.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/kernel.h>
 #include <sys/lock.h>
 #include <sys/module.h>
+#include <sys/mutex.h>
 #include <sys/priv.h>
 #include <sys/proc.h>
 #include <sys/rwlock.h>

Modified: projects/ifnet/sys/netpfil/ipfw/ip_dummynet.c
==============================================================================
--- projects/ifnet/sys/netpfil/ipfw/ip_dummynet.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/netpfil/ipfw/ip_dummynet.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/kernel.h>
 #include <sys/lock.h>
 #include <sys/module.h>
+#include <sys/mutex.h>
 #include <sys/priv.h>
 #include <sys/proc.h>
 #include <sys/rwlock.h>

Modified: projects/ifnet/sys/netpfil/pf/pf_ruleset.c
==============================================================================
--- projects/ifnet/sys/netpfil/pf/pf_ruleset.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/netpfil/pf/pf_ruleset.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
 #include <netinet/tcp.h>
 
 #include <net/if.h>
+#include <net/vnet.h>
 #include <net/pfvar.h>
 
 #ifdef INET6

Modified: projects/ifnet/sys/netpfil/pf/pf_table.c
==============================================================================
--- projects/ifnet/sys/netpfil/pf/pf_table.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/netpfil/pf/pf_table.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/kernel.h>
 #include <sys/lock.h>
 #include <sys/malloc.h>
+#include <sys/mbuf.h>
 #include <sys/mutex.h>
 #include <sys/refcount.h>
 #include <sys/rwlock.h>

Modified: projects/ifnet/sys/powerpc/aim/machdep.c
==============================================================================
--- projects/ifnet/sys/powerpc/aim/machdep.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/powerpc/aim/machdep.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -775,3 +775,11 @@ va_to_vsid(pmap_t pm, vm_offset_t va)
 }
 
 #endif
+
+vm_offset_t
+pmap_early_io_map(vm_paddr_t pa, vm_size_t size)
+{
+
+	return (pa);
+}
+

Modified: projects/ifnet/sys/powerpc/aim/mmu_oea64.c
==============================================================================
--- projects/ifnet/sys/powerpc/aim/mmu_oea64.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/powerpc/aim/mmu_oea64.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -498,15 +498,7 @@ moea64_add_ofw_mappings(mmu_t mmup, phan
 	qsort(translations, sz, sizeof (*translations), om_cmp);
 
 	for (i = 0; i < sz; i++) {
-		CTR3(KTR_PMAP, "translation: pa=%#x va=%#x len=%#x",
-		    (uint32_t)(translations[i].om_pa_lo), translations[i].om_va,
-		    translations[i].om_len);
-
-		if (translations[i].om_pa_lo % PAGE_SIZE)
-			panic("OFW translation not page-aligned!");
-
 		pa_base = translations[i].om_pa_lo;
-
 	      #ifdef __powerpc64__
 		pa_base += (vm_offset_t)translations[i].om_pa_hi << 32;
 	      #else
@@ -514,6 +506,14 @@ moea64_add_ofw_mappings(mmu_t mmup, phan
 			panic("OFW translations above 32-bit boundary!");
 	      #endif
 
+		if (pa_base % PAGE_SIZE)
+			panic("OFW translation not page-aligned (phys)!");
+		if (translations[i].om_va % PAGE_SIZE)
+			panic("OFW translation not page-aligned (virt)!");
+
+		CTR3(KTR_PMAP, "translation: pa=%#zx va=%#x len=%#x",
+		    pa_base, translations[i].om_va, translations[i].om_len);
+
 		/* Now enter the pages for this mapping */
 
 		DISABLE_TRANS(msr);
@@ -690,9 +690,9 @@ moea64_early_bootstrap(mmu_t mmup, vm_of
 	hwphyssz = 0;
 	TUNABLE_ULONG_FETCH("hw.physmem", (u_long *) &hwphyssz);
 	for (i = 0, j = 0; i < regions_sz; i++, j += 2) {
-		CTR3(KTR_PMAP, "region: %#x - %#x (%#x)", regions[i].mr_start,
-		    regions[i].mr_start + regions[i].mr_size,
-		    regions[i].mr_size);
+		CTR3(KTR_PMAP, "region: %#zx - %#zx (%#zx)",
+		    regions[i].mr_start, regions[i].mr_start +
+		    regions[i].mr_size, regions[i].mr_size);
 		if (hwphyssz != 0 &&
 		    (physsz + regions[i].mr_size) >= hwphyssz) {
 			if (physsz < hwphyssz) {

Modified: projects/ifnet/sys/powerpc/booke/machdep.c
==============================================================================
--- projects/ifnet/sys/powerpc/booke/machdep.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/powerpc/booke/machdep.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -350,13 +350,18 @@ booke_init(uint32_t arg1, uint32_t arg2)
 	if (OF_init((void *)dtbp) != 0)
 		while (1);
 
-	if (fdt_immr_addr(CCSRBAR_VA) != 0)
-		while (1);
-
 	OF_interpret("perform-fixup", 0);
 	
 	/* Set up TLB initially */
-	booke_init_tlb(fdt_immr_pa);
+	tlb1_init();
+
+	/* Set up IMMR */
+	if (fdt_immr_addr(0) == 0) {
+		fdt_immr_va = pmap_early_io_map(fdt_immr_pa, fdt_immr_size);
+	} else {
+		printf("Warning: SOC base registers could not be found!\n");
+		fdt_immr_va = 0;
+	}
 
 	/* Reset Time Base */
 	mttb(0);

Modified: projects/ifnet/sys/powerpc/booke/machdep_e500.c
==============================================================================
--- projects/ifnet/sys/powerpc/booke/machdep_e500.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/powerpc/booke/machdep_e500.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -47,8 +47,6 @@ void
 booke_init_tlb(vm_paddr_t fdt_immr_pa)
 {
 
-	/* Initialize TLB1 handling */
-	tlb1_init(fdt_immr_pa);
 }
 
 void

Modified: projects/ifnet/sys/powerpc/booke/pmap.c
==============================================================================
--- projects/ifnet/sys/powerpc/booke/pmap.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/powerpc/booke/pmap.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -113,7 +113,6 @@ extern uint32_t *bootinfo;
 extern uint32_t bp_ntlb1s;
 #endif
 
-vm_paddr_t ccsrbar_pa;
 vm_paddr_t kernload;
 vm_offset_t kernstart;
 vm_size_t kernsize;
@@ -2662,22 +2661,25 @@ mmu_booke_mapdev_attr(mmu_t mmu, vm_padd
 	void *res;
 	uintptr_t va;
 	vm_size_t sz;
+	int i;
 
 	/*
-	 * CCSR is premapped. Note that (pa + size - 1) is there to make sure
-	 * we don't wrap around. Devices on the local bus typically extend all
-	 * the way up to and including 0xffffffff. In that case (pa + size)
-	 * would be 0. This creates a false positive (i.e. we think it's
-	 * within the CCSR) and not create a mapping.
-	 */
-	if (ma == VM_MEMATTR_DEFAULT && pa >= ccsrbar_pa &&
-	    (pa + size - 1) < (ccsrbar_pa + CCSRBAR_SIZE)) {
-		va = CCSRBAR_VA + (pa - ccsrbar_pa);
-		return ((void *)va);
+	 * Check if this is premapped in TLB1. Note: this should probably also
+	 * check whether a sequence of TLB1 entries exist that match the
+	 * requirement, but now only checks the easy case.
+	 */
+	if (ma == VM_MEMATTR_DEFAULT) {
+		for (i = 0; i < tlb1_idx; i++) {
+			if (!(tlb1[i].mas1 & MAS1_VALID))
+				continue;
+			if (pa >= tlb1[i].phys &&
+			    (pa + size) <= (tlb1[i].phys + tlb1[i].size))
+				return (void *)(tlb1[i].virt +
+				    (pa - tlb1[i].phys));
+		}
 	}
 
-	if (size < PAGE_SIZE)
-	    size = PAGE_SIZE;
+	size = roundup(size, PAGE_SIZE);
 
 	if (pa >= (VM_MAXUSER_ADDRESS + PAGE_SIZE) &&
 	    (pa + size - 1) < VM_MIN_KERNEL_ADDRESS) 
@@ -2899,9 +2901,8 @@ tlb0_print_tlbentries(void)
 /*
  * TLB1 mapping notes:
  *
- * TLB1[0]	CCSRBAR
- * TLB1[1]	Kernel text and data.
- * TLB1[2-15]	Additional kernel text and data mappings (if required), PCI
+ * TLB1[0]	Kernel text and data.
+ * TLB1[1-15]	Additional kernel text and data mappings (if required), PCI
  *		windows, other devices mappings.
  */
 
@@ -3094,14 +3095,12 @@ tlb1_mapin_region(vm_offset_t va, vm_pad
  * assembler level setup done in locore.S.
  */
 void
-tlb1_init(vm_offset_t ccsrbar)
+tlb1_init()
 {
-	uint32_t mas0, mas1, mas3;
+	uint32_t mas0, mas1, mas2, mas3;
 	uint32_t tsz;
 	u_int i;
 
-	ccsrbar_pa = ccsrbar;
-
 	if (bootinfo != NULL && bootinfo[0] != 1) {
 		tlb1_idx = *((uint16_t *)(bootinfo + 8));
 	} else
@@ -3117,22 +3116,23 @@ tlb1_init(vm_offset_t ccsrbar)
 		if ((mas1 & MAS1_VALID) == 0)
 			continue;
 
+		mas2 = mfspr(SPR_MAS2);
 		mas3 = mfspr(SPR_MAS3);
 
 		tlb1[i].mas1 = mas1;
 		tlb1[i].mas2 = mfspr(SPR_MAS2);
 		tlb1[i].mas3 = mas3;
+		tlb1[i].virt = mas2 & MAS2_EPN_MASK;
+		tlb1[i].phys = mas3 & MAS3_RPN;
 
 		if (i == 0)
 			kernload = mas3 & MAS3_RPN;
 
 		tsz = (mas1 & MAS1_TSIZE_MASK) >> MAS1_TSIZE_SHIFT;
-		kernsize += (tsz > 0) ? tsize2size(tsz) : 0;
+		tlb1[i].size = (tsz > 0) ? tsize2size(tsz) : 0;
+		kernsize += tlb1[i].size;
 	}
 
-	/* Map in CCSRBAR. */
-	tlb1_set_entry(CCSRBAR_VA, ccsrbar, CCSRBAR_SIZE, _TLB_ENTRY_IO);
-
 #ifdef SMP
 	bp_ntlb1s = tlb1_idx;
 #endif
@@ -3145,6 +3145,43 @@ tlb1_init(vm_offset_t ccsrbar)
 	set_mas4_defaults();
 }
 
+vm_offset_t 
+pmap_early_io_map(vm_paddr_t pa, vm_size_t size)
+{
+	static vm_offset_t early_io_map_base = VM_MAX_KERNEL_ADDRESS;
+	vm_paddr_t pa_base;
+	vm_offset_t va, sz;
+	int i;
+
+	KASSERT(!pmap_bootstrapped, ("Do not use after PMAP is up!"));
+	
+	for (i = 0; i < tlb1_idx; i++) {
+		if (!(tlb1[i].mas1 & MAS1_VALID))
+			continue;
+		if (pa >= tlb1[i].phys && (pa + size) <=
+		    (tlb1[i].phys + tlb1[i].size))
+			return (tlb1[i].virt + (pa - tlb1[i].phys));
+	}
+
+	pa_base = trunc_page(pa);
+	size = roundup(size + (pa - pa_base), PAGE_SIZE);
+	va = early_io_map_base + (pa - pa_base);
+
+	do {
+		sz = 1 << (ilog2(size) & ~1);
+		tlb1_set_entry(early_io_map_base, pa_base, sz, _TLB_ENTRY_IO);
+		size -= sz;
+		pa_base += sz;
+		early_io_map_base += sz;
+	} while (size > 0);
+
+#ifdef SMP
+	bp_ntlb1s = tlb1_idx;
+#endif
+
+	return (va);
+}
+
 /*
  * Setup MAS4 defaults.
  * These values are loaded to MAS0-2 on a TLB miss.

Modified: projects/ifnet/sys/powerpc/include/pmap.h
==============================================================================
--- projects/ifnet/sys/powerpc/include/pmap.h	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/powerpc/include/pmap.h	Sat Oct 26 18:22:16 2013	(r257181)
@@ -254,6 +254,8 @@ extern void pmap_dumpsys_unmap(struct pm
 
 extern struct pmap_md *pmap_scan_md(struct pmap_md *);
 
+vm_offset_t pmap_early_io_map(vm_paddr_t pa, vm_size_t size);
+
 #endif
 
 #endif /* !_MACHINE_PMAP_H_ */

Modified: projects/ifnet/sys/powerpc/include/tlb.h
==============================================================================
--- projects/ifnet/sys/powerpc/include/tlb.h	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/powerpc/include/tlb.h	Sat Oct 26 18:22:16 2013	(r257181)
@@ -126,6 +126,9 @@
 
 #if !defined(LOCORE)
 typedef struct tlb_entry {
+	vm_paddr_t phys;
+	vm_offset_t virt;
+	vm_size_t size;
 	uint32_t mas1;
 	uint32_t mas2;
 	uint32_t mas3;
@@ -134,7 +137,7 @@ typedef struct tlb_entry {
 void tlb0_print_tlbentries(void);
 
 void tlb1_inval_entry(unsigned int);
-void tlb1_init(vm_offset_t);
+void tlb1_init(void);
 void tlb1_print_entries(void);
 void tlb1_print_tlbentries(void);
 #endif /* !LOCORE */

Modified: projects/ifnet/sys/powerpc/include/vmparam.h
==============================================================================
--- projects/ifnet/sys/powerpc/include/vmparam.h	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/powerpc/include/vmparam.h	Sat Oct 26 18:22:16 2013	(r257181)
@@ -108,12 +108,6 @@
 
 #else /* Book-E */
 
-/*
- * Kernel CCSRBAR location. We make this the reset location.
- */
-#define	CCSRBAR_VA		0xfef00000
-#define	CCSRBAR_SIZE		0x00100000
-
 #define	KERNBASE		0xc0000000	/* start of kernel virtual */
 
 #define	VM_MIN_KERNEL_ADDRESS	KERNBASE

Modified: projects/ifnet/sys/powerpc/mpc85xx/mpc85xx.c
==============================================================================
--- projects/ifnet/sys/powerpc/mpc85xx/mpc85xx.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/powerpc/mpc85xx/mpc85xx.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -41,6 +41,8 @@ __FBSDID("$FreeBSD$");
 #include <machine/pio.h>
 #include <machine/spr.h>
 
+#include <dev/fdt/fdt_common.h>
+
 #include <powerpc/mpc85xx/mpc85xx.h>
 
 /*

Modified: projects/ifnet/sys/powerpc/mpc85xx/mpc85xx.h
==============================================================================
--- projects/ifnet/sys/powerpc/mpc85xx/mpc85xx.h	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/powerpc/mpc85xx/mpc85xx.h	Sat Oct 26 18:22:16 2013	(r257181)
@@ -33,6 +33,7 @@
 /*
  * Configuration control and status registers
  */
+#define CCSRBAR_VA		fdt_immr_va
 #define	OCP85XX_CCSRBAR		(CCSRBAR_VA + 0x0)
 #define	OCP85XX_BPTR		(CCSRBAR_VA + 0x20)
 

Modified: projects/ifnet/sys/powerpc/powerpc/bus_machdep.c
==============================================================================
--- projects/ifnet/sys/powerpc/powerpc/bus_machdep.c	Sat Oct 26 18:19:36 2013	(r257180)
+++ projects/ifnet/sys/powerpc/powerpc/bus_machdep.c	Sat Oct 26 18:22:16 2013	(r257181)
@@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$");
 #define	MAX_EARLYBOOT_MAPPINGS	6
 
 static struct {
+	vm_offset_t virt;
 	bus_addr_t addr;
 	bus_size_t size;
 	int flags;
@@ -86,10 +87,12 @@ bs_gen_map(bus_addr_t addr, bus_size_t s
 		KASSERT(earlyboot_map_idx < MAX_EARLYBOOT_MAPPINGS,
 		    ("%s: too many early boot mapping requests", __func__));
 		earlyboot_mappings[earlyboot_map_idx].addr = addr;
+		earlyboot_mappings[earlyboot_map_idx].virt =
+		    pmap_early_io_map(addr, size);
 		earlyboot_mappings[earlyboot_map_idx].size = size;
 		earlyboot_mappings[earlyboot_map_idx].flags = flags;
+		*bshp = earlyboot_mappings[earlyboot_map_idx].virt;
 		earlyboot_map_idx++;
-		*bshp = addr;
 	} else {
 		ma = VM_MEMATTR_DEFAULT;
 		switch (flags) {
@@ -110,13 +113,13 @@ void
 bs_remap_earlyboot(void)
 {
 	int i;
-	vm_offset_t pa, spa;
+	vm_offset_t pa, spa, va;
 	vm_memattr_t ma;
 
 	for (i = 0; i < earlyboot_map_idx; i++) {
 		spa = earlyboot_mappings[i].addr;
-		if (pmap_dev_direct_mapped(spa, earlyboot_mappings[i].size)
-		    == 0)
+		if (spa == earlyboot_mappings[i].virt &&
+		   pmap_dev_direct_mapped(spa, earlyboot_mappings[i].size) == 0)
 			continue;
 
 		ma = VM_MEMATTR_DEFAULT;
@@ -130,8 +133,10 @@ bs_remap_earlyboot(void)
 		}
 
 		pa = trunc_page(spa);
+		va = trunc_page(earlyboot_mappings[i].virt);
 		while (pa < spa + earlyboot_mappings[i].size) {
-			pmap_kenter_attr(pa, pa, ma);
+			pmap_kenter_attr(va, pa, ma);
+			va += PAGE_SIZE;
 			pa += PAGE_SIZE;
 		}
 	}


More information about the svn-src-projects mailing list