diff options
author | jhibbits <jhibbits@FreeBSD.org> | 2015-12-24 04:30:15 +0000 |
---|---|---|
committer | jhibbits <jhibbits@FreeBSD.org> | 2015-12-24 04:30:15 +0000 |
commit | a56b695591d54aeb8a2bfff084697f6e9493855c (patch) | |
tree | 4bad651440260b722d33601cfacf24834ea26a65 | |
parent | 760c079f38ca83ef18d4cef550918dc730e818a6 (diff) | |
download | FreeBSD-src-a56b695591d54aeb8a2bfff084697f6e9493855c.zip FreeBSD-src-a56b695591d54aeb8a2bfff084697f6e9493855c.tar.gz |
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
-rw-r--r-- | sys/powerpc/booke/pmap.c | 18 | ||||
-rw-r--r-- | sys/powerpc/include/param.h | 14 | ||||
-rw-r--r-- | sys/powerpc/include/platform.h | 4 | ||||
-rw-r--r-- | sys/powerpc/include/pmap.h | 2 | ||||
-rw-r--r-- | sys/powerpc/ofw/ofw_machdep.c | 11 | ||||
-rw-r--r-- | sys/powerpc/powerpc/machdep.c | 20 | ||||
-rw-r--r-- | sys/powerpc/powerpc/platform.c | 4 | ||||
-rw-r--r-- | sys/powerpc/powerpc/pmap_dispatch.c | 2 | ||||
-rw-r--r-- | sys/sys/libkern.h | 2 |
9 files changed, 41 insertions, 36 deletions
diff --git a/sys/powerpc/booke/pmap.c b/sys/powerpc/booke/pmap.c index 2539c33e..6ea98b7 100644 --- a/sys/powerpc/booke/pmap.c +++ b/sys/powerpc/booke/pmap.c @@ -1024,12 +1024,13 @@ pte_find(mmu_t mmu, pmap_t pmap, vm_offset_t va) 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_t start, vm_offset_t kernelend) 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_t start, vm_offset_t kernelend) 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_t start, vm_offset_t kernelend) 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) { diff --git a/sys/powerpc/include/param.h b/sys/powerpc/include/param.h index df5a7be..453915c 100644 --- a/sys/powerpc/include/param.h +++ b/sys/powerpc/include/param.h @@ -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_ */ diff --git a/sys/powerpc/include/platform.h b/sys/powerpc/include/platform.h index 854c0be..28f83cc 100644 --- a/sys/powerpc/include/platform.h +++ b/sys/powerpc/include/platform.h @@ -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 *); diff --git a/sys/powerpc/include/pmap.h b/sys/powerpc/include/pmap.h index dc8649e..97c5c79 100644 --- a/sys/powerpc/include/pmap.h +++ b/sys/powerpc/include/pmap.h @@ -250,7 +250,7 @@ boolean_t pmap_mmu_install(char *name, int prio); * 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; diff --git a/sys/powerpc/ofw/ofw_machdep.c b/sys/powerpc/ofw/ofw_machdep.c index 5594d84..d2bb77b 100644 --- a/sys/powerpc/ofw/ofw_machdep.c +++ b/sys/powerpc/ofw/ofw_machdep.c @@ -172,8 +172,8 @@ parse_ofw_memory(phandle_t node, const char *prop, struct mem_region *output) 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 char *prop, struct mem_region *output) 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. diff --git a/sys/powerpc/powerpc/machdep.c b/sys/powerpc/powerpc/machdep.c index 781a3f6..dea3461 100644 --- a/sys/powerpc/powerpc/machdep.c +++ b/sys/powerpc/powerpc/machdep.c @@ -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. diff --git a/sys/powerpc/powerpc/platform.c b/sys/powerpc/powerpc/platform.c index 4698ed2..8168758 100644 --- a/sys/powerpc/powerpc/platform.c +++ b/sys/powerpc/powerpc/platform.c @@ -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; } diff --git a/sys/powerpc/powerpc/pmap_dispatch.c b/sys/powerpc/powerpc/pmap_dispatch.c index 4e31a53..2082ba0 100644 --- a/sys/powerpc/powerpc/pmap_dispatch.c +++ b/sys/powerpc/powerpc/pmap_dispatch.c @@ -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; diff --git a/sys/sys/libkern.h b/sys/sys/libkern.h index 7484cdc..efbaa4a 100644 --- a/sys/sys/libkern.h +++ b/sys/sys/libkern.h @@ -61,6 +61,8 @@ static __inline u_int max(u_int a, u_int b) { return (a > b ? a : b); } 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); } |