Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Dec 2015 04:30:15 +0000 (UTC)
From:      Justin Hibbits <jhibbits@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r292680 - in head/sys: powerpc/booke powerpc/include powerpc/ofw powerpc/powerpc sys
Message-ID:  <201512240430.tBO4UFJx004929@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhibbits
Date: Thu Dec 24 04:30:15 2015
New Revision: 292680
URL: https://svnweb.freebsd.org/changeset/base/292680

Log:
  Extend Book-E to support >4GB RAM
  
  Summary:
  With some additional changes for AIM, that could also support much
  larger physmem sizes.  Given that 32-bit AIM is more or less obsolete, though,
  it's not worth it at this time.
  
  Differential Revision: https://reviews.freebsd.org/D4345

Modified:
  head/sys/powerpc/booke/pmap.c
  head/sys/powerpc/include/param.h
  head/sys/powerpc/include/platform.h
  head/sys/powerpc/include/pmap.h
  head/sys/powerpc/ofw/ofw_machdep.c
  head/sys/powerpc/powerpc/machdep.c
  head/sys/powerpc/powerpc/platform.c
  head/sys/powerpc/powerpc/pmap_dispatch.c
  head/sys/sys/libkern.h

Modified: head/sys/powerpc/booke/pmap.c
==============================================================================
--- head/sys/powerpc/booke/pmap.c	Thu Dec 24 02:35:59 2015	(r292679)
+++ head/sys/powerpc/booke/pmap.c	Thu Dec 24 04:30:15 2015	(r292680)
@@ -1024,12 +1024,13 @@ pte_find(mmu_t mmu, pmap_t pmap, vm_offs
 static void
 mmu_booke_bootstrap(mmu_t mmu, vm_offset_t start, vm_offset_t kernelend)
 {
-	vm_offset_t phys_kernelend;
+	vm_paddr_t phys_kernelend;
 	struct mem_region *mp, *mp1;
 	int cnt, i, j;
-	u_int s, e, sz;
+	vm_paddr_t s, e, sz;
+	vm_paddr_t physsz, hwphyssz;
 	u_int phys_avail_count;
-	vm_size_t physsz, hwphyssz, kstack0_sz;
+	vm_size_t kstack0_sz;
 	vm_offset_t kernel_pdir, kstack0, va;
 	vm_paddr_t kstack0_phys;
 	void *dpcpu;
@@ -1163,7 +1164,7 @@ mmu_booke_bootstrap(mmu_t mmu, vm_offset
 	for (mp = availmem_regions; mp->mr_size; mp++) {
 		s = mp->mr_start;
 		e = mp->mr_start + mp->mr_size;
-		debugf(" %08x-%08x -> ", s, e);
+		debugf(" %09jx-%09jx -> ", (uintmax_t)s, (uintmax_t)e);
 		/* Check whether this region holds all of the kernel. */
 		if (s < kernload && e > phys_kernelend) {
 			availmem_regions[cnt].mr_start = phys_kernelend;
@@ -1188,7 +1189,8 @@ mmu_booke_bootstrap(mmu_t mmu, vm_offset
 		if (e < s)
 			e = s;
 		sz = e - s;
-		debugf("%08x-%08x = %x\n", s, e, sz);
+		debugf("%09jx-%09jx = %jx\n",
+		    (uintmax_t)s, (uintmax_t)e, (uintmax_t)sz);
 
 		/* Check whether some memory is left here. */
 		if (sz == 0) {
@@ -1237,10 +1239,10 @@ mmu_booke_bootstrap(mmu_t mmu, vm_offset
 	for (i = 0, j = 0; i < availmem_regions_sz; i++, j += 2) {
 
 		debugf(" region: 0x%jx - 0x%jx (0x%jx)\n",
-		    availmem_regions[i].mr_start,
-		    availmem_regions[i].mr_start +
+		    (uintmax_t)availmem_regions[i].mr_start,
+		    (uintmax_t)availmem_regions[i].mr_start +
 		        availmem_regions[i].mr_size,
-		    availmem_regions[i].mr_size);
+		    (uintmax_t)availmem_regions[i].mr_size);
 
 		if (hwphyssz != 0 &&
 		    (physsz + availmem_regions[i].mr_size) >= hwphyssz) {

Modified: head/sys/powerpc/include/param.h
==============================================================================
--- head/sys/powerpc/include/param.h	Thu Dec 24 02:35:59 2015	(r292679)
+++ head/sys/powerpc/include/param.h	Thu Dec 24 04:30:15 2015	(r292680)
@@ -98,7 +98,7 @@
 
 #define	PAGE_SHIFT	12
 #define	PAGE_SIZE	(1L << PAGE_SHIFT)	/* Page size */
-#define	PAGE_MASK	(vm_offset_t)(PAGE_SIZE - 1)
+#define	PAGE_MASK	(PAGE_SIZE - 1)
 #define	NPTEPG		(PAGE_SIZE/(sizeof (pt_entry_t)))
 
 #define	MAXPAGESIZES	1		/* maximum number of supported page sizes */
@@ -116,15 +116,17 @@
 /*
  * Mach derived conversion macros
  */
-#define	trunc_page(x)		((unsigned long)(x) & ~(PAGE_MASK))
+#define	trunc_page(x)		((x) & ~(PAGE_MASK))
 #define	round_page(x)		(((x) + PAGE_MASK) & ~PAGE_MASK)
 
-#define	atop(x)			((unsigned long)(x) >> PAGE_SHIFT)
-#define	ptoa(x)			((unsigned long)(x) << PAGE_SHIFT)
+#define	atop(x)			((x) >> PAGE_SHIFT)
+#define	ptoa(x)			((x) << PAGE_SHIFT)
 
-#define	powerpc_btop(x)		((unsigned long)(x) >> PAGE_SHIFT)
-#define	powerpc_ptob(x)		((unsigned long)(x) << PAGE_SHIFT)
+#define	powerpc_btop(x)		((x) >> PAGE_SHIFT)
+#define	powerpc_ptob(x)		((x) << PAGE_SHIFT)
 
 #define	pgtok(x)		((x) * (PAGE_SIZE / 1024UL))
 
+#define btoc(x)			((vm_offset_t)(((x)+PAGE_MASK)>>PAGE_SHIFT))
+
 #endif /* !_POWERPC_INCLUDE_PARAM_H_ */

Modified: head/sys/powerpc/include/platform.h
==============================================================================
--- head/sys/powerpc/include/platform.h	Thu Dec 24 02:35:59 2015	(r292679)
+++ head/sys/powerpc/include/platform.h	Thu Dec 24 04:30:15 2015	(r292680)
@@ -39,8 +39,8 @@
 #include <machine/pcpu.h>
 
 struct mem_region {
-	vm_offset_t	mr_start;
-	vm_size_t	mr_size;
+	uint64_t	mr_start;
+	uint64_t	mr_size;
 };
 
 void	mem_regions(struct mem_region **, int *, struct mem_region **, int *);

Modified: head/sys/powerpc/include/pmap.h
==============================================================================
--- head/sys/powerpc/include/pmap.h	Thu Dec 24 02:35:59 2015	(r292679)
+++ head/sys/powerpc/include/pmap.h	Thu Dec 24 04:30:15 2015	(r292680)
@@ -250,7 +250,7 @@ boolean_t	pmap_mmu_install(char *name, i
 				 * For more Ram increase the lmb or this value.
 				 */
 
-extern	vm_offset_t phys_avail[PHYS_AVAIL_SZ];
+extern	vm_paddr_t phys_avail[PHYS_AVAIL_SZ];
 extern	vm_offset_t virtual_avail;
 extern	vm_offset_t virtual_end;
 

Modified: head/sys/powerpc/ofw/ofw_machdep.c
==============================================================================
--- head/sys/powerpc/ofw/ofw_machdep.c	Thu Dec 24 02:35:59 2015	(r292679)
+++ head/sys/powerpc/ofw/ofw_machdep.c	Thu Dec 24 04:30:15 2015	(r292680)
@@ -172,8 +172,8 @@ parse_ofw_memory(phandle_t node, const c
 	i = 0;
 	j = 0;
 	while (i < sz/sizeof(cell_t)) {
-	      #ifndef __powerpc64__
-		/* On 32-bit PPC, ignore regions starting above 4 GB */
+	      #if !defined(__powerpc64__) && !defined(BOOKE)
+		/* On 32-bit PPC (OEA), ignore regions starting above 4 GB */
 		if (address_cells > 1 && OFmem[i] > 0) {
 			i += address_cells + size_cells;
 			continue;
@@ -182,21 +182,18 @@ parse_ofw_memory(phandle_t node, const c
 
 		output[j].mr_start = OFmem[i++];
 		if (address_cells == 2) {
-			#ifdef __powerpc64__
 			output[j].mr_start <<= 32;
-			#endif
 			output[j].mr_start += OFmem[i++];
 		}
 			
 		output[j].mr_size = OFmem[i++];
 		if (size_cells == 2) {
-			#ifdef __powerpc64__
 			output[j].mr_size <<= 32;
-			#endif
 			output[j].mr_size += OFmem[i++];
 		}
 
-	      #ifndef __powerpc64__
+	      #if !defined(__powerpc64__) && !defined(BOOKE)
+		/* Book-E can support 36-bit addresses. */
 		/*
 		 * Check for memory regions extending above 32-bit
 		 * memory space, and restrict them to stay there.

Modified: head/sys/powerpc/powerpc/machdep.c
==============================================================================
--- head/sys/powerpc/powerpc/machdep.c	Thu Dec 24 02:35:59 2015	(r292679)
+++ head/sys/powerpc/powerpc/machdep.c	Thu Dec 24 04:30:15 2015	(r292680)
@@ -176,8 +176,8 @@ cpu_startup(void *dummy)
 #ifdef PERFMON
 	perfmon_init();
 #endif
-	printf("real memory  = %lu (%lu MB)\n", ptoa(physmem),
-	    ptoa(physmem) / 1048576);
+	printf("real memory  = %ju (%ju MB)\n", ptoa((uintmax_t)physmem),
+	    ptoa((uintmax_t)physmem) / 1048576);
 	realmem = physmem;
 
 	if (bootverbose)
@@ -193,23 +193,25 @@ cpu_startup(void *dummy)
 
 		printf("Physical memory chunk(s):\n");
 		for (indx = 0; phys_avail[indx + 1] != 0; indx += 2) {
-			vm_offset_t size1 =
+			vm_paddr_t size1 =
 			    phys_avail[indx + 1] - phys_avail[indx];
 
 			#ifdef __powerpc64__
-			printf("0x%016lx - 0x%016lx, %ld bytes (%ld pages)\n",
+			printf("0x%016jx - 0x%016jx, %jd bytes (%jd pages)\n",
 			#else
-			printf("0x%08x - 0x%08x, %u bytes (%lu pages)\n",
+			printf("0x%09jx - 0x%09jx, %ju bytes (%ju pages)\n",
 			#endif
-			    phys_avail[indx], phys_avail[indx + 1] - 1, size1,
-			    size1 / PAGE_SIZE);
+			    (uintmax_t)phys_avail[indx],
+			    (uintmax_t)phys_avail[indx + 1] - 1,
+			    (uintmax_t)size1, (uintmax_t)size1 / PAGE_SIZE);
 		}
 	}
 
 	vm_ksubmap_init(&kmi);
 
-	printf("avail memory = %lu (%lu MB)\n", ptoa(vm_cnt.v_free_count),
-	    ptoa(vm_cnt.v_free_count) / 1048576);
+	printf("avail memory = %ju (%ju MB)\n",
+	    ptoa((uintmax_t)vm_cnt.v_free_count),
+	    ptoa((uintmax_t)vm_cnt.v_free_count) / 1048576);
 
 	/*
 	 * Set up buffers, so they can be used to read disk labels.

Modified: head/sys/powerpc/powerpc/platform.c
==============================================================================
--- head/sys/powerpc/powerpc/platform.c	Thu Dec 24 02:35:59 2015	(r292679)
+++ head/sys/powerpc/powerpc/platform.c	Thu Dec 24 04:30:15 2015	(r292680)
@@ -86,8 +86,8 @@ static void
 memr_merge(struct mem_region *from, struct mem_region *to)
 {
 	vm_offset_t end;
-	end = ulmax(to->mr_start + to->mr_size, from->mr_start + from->mr_size);
-	to->mr_start = ulmin(from->mr_start, to->mr_start);
+	end = uqmax(to->mr_start + to->mr_size, from->mr_start + from->mr_size);
+	to->mr_start = uqmin(from->mr_start, to->mr_start);
 	to->mr_size = end - to->mr_start;
 }
 

Modified: head/sys/powerpc/powerpc/pmap_dispatch.c
==============================================================================
--- head/sys/powerpc/powerpc/pmap_dispatch.c	Thu Dec 24 02:35:59 2015	(r292679)
+++ head/sys/powerpc/powerpc/pmap_dispatch.c	Thu Dec 24 04:30:15 2015	(r292680)
@@ -74,7 +74,7 @@ struct msgbuf *msgbufp;
 vm_offset_t    msgbuf_phys;
 
 vm_offset_t kernel_vm_end;
-vm_offset_t phys_avail[PHYS_AVAIL_SZ];
+vm_paddr_t phys_avail[PHYS_AVAIL_SZ];
 vm_offset_t virtual_avail;
 vm_offset_t virtual_end;
 

Modified: head/sys/sys/libkern.h
==============================================================================
--- head/sys/sys/libkern.h	Thu Dec 24 02:35:59 2015	(r292679)
+++ head/sys/sys/libkern.h	Thu Dec 24 04:30:15 2015	(r292680)
@@ -61,6 +61,8 @@ static __inline u_int max(u_int a, u_int
 static __inline u_int min(u_int a, u_int b) { return (a < b ? a : b); }
 static __inline quad_t qmax(quad_t a, quad_t b) { return (a > b ? a : b); }
 static __inline quad_t qmin(quad_t a, quad_t b) { return (a < b ? a : b); }
+static __inline u_quad_t uqmax(u_quad_t a, u_quad_t b) { return (a > b ? a : b); }
+static __inline u_quad_t uqmin(u_quad_t a, u_quad_t b) { return (a < b ? a : b); }
 static __inline u_long ulmax(u_long a, u_long b) { return (a > b ? a : b); }
 static __inline u_long ulmin(u_long a, u_long b) { return (a < b ? a : b); }
 static __inline off_t omax(off_t a, off_t b) { return (a > b ? a : b); }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201512240430.tBO4UFJx004929>