Wed Jun 14 12:27:24 2017 UTC ()
Define MAXPHYSMEM globally.


(maxv)
diff -r1.21 -r1.22 src/sys/arch/amd64/include/param.h
diff -r1.80 -r1.81 src/sys/arch/i386/include/param.h
diff -r1.92 -r1.93 src/sys/arch/x86/x86/x86_machdep.c

cvs diff -r1.21 -r1.22 src/sys/arch/amd64/include/param.h (expand / switch to unified diff)

--- src/sys/arch/amd64/include/param.h 2017/02/02 19:09:08 1.21
+++ src/sys/arch/amd64/include/param.h 2017/06/14 12:27:24 1.22
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: param.h,v 1.21 2017/02/02 19:09:08 maxv Exp $ */ 1/* $NetBSD: param.h,v 1.22 2017/06/14 12:27:24 maxv Exp $ */
2 2
3#ifdef __x86_64__ 3#ifdef __x86_64__
4 4
5#ifndef XEN 5#ifndef XEN
6/* Must be defined before cpu.h */ 6/* Must be defined before cpu.h */
7#define MAXCPUS 256 7#define MAXCPUS 256
8#endif 8#endif
9 9
10#ifdef _KERNEL 10#ifdef _KERNEL
11#include <machine/cpu.h> 11#include <machine/cpu.h>
12#endif 12#endif
13 13
14#define _MACHINE amd64 14#define _MACHINE amd64
@@ -20,26 +20,31 @@ @@ -20,26 +20,31 @@
20#define ALIGNED_POINTER(p,t) 1 20#define ALIGNED_POINTER(p,t) 1
21 21
22#define ALIGNBYTES32 (sizeof(int) - 1) 22#define ALIGNBYTES32 (sizeof(int) - 1)
23#define ALIGN32(p) (((u_long)(p) + ALIGNBYTES32) &~ALIGNBYTES32) 23#define ALIGN32(p) (((u_long)(p) + ALIGNBYTES32) &~ALIGNBYTES32)
24 24
25#define PGSHIFT 12 /* LOG2(NBPG) */ 25#define PGSHIFT 12 /* LOG2(NBPG) */
26#define NBPG (1 << PGSHIFT) /* bytes/page */ 26#define NBPG (1 << PGSHIFT) /* bytes/page */
27#define PGOFSET (NBPG-1) /* byte offset into page */ 27#define PGOFSET (NBPG-1) /* byte offset into page */
28#define NPTEPG (NBPG/(sizeof (pt_entry_t))) 28#define NPTEPG (NBPG/(sizeof (pt_entry_t)))
29 29
30#define MAXIOMEM 0xffffffffffff 30#define MAXIOMEM 0xffffffffffff
31 31
32/* 32/*
 33 * Maximum physical memory supported by the implementation.
 34 */
 35#define MAXPHYSMEM 0x100000000000ULL /* 16TB */
 36
 37/*
33 * XXXfvdl change this (after bootstrap) to take # of bits from 38 * XXXfvdl change this (after bootstrap) to take # of bits from
34 * config info into account. 39 * config info into account.
35 */ 40 */
36#define KERNBASE 0xffffffff80000000 /* start of kernel virtual space */ 41#define KERNBASE 0xffffffff80000000 /* start of kernel virtual space */
37#define KERNTEXTOFF 0xffffffff80200000 /* start of kernel text */ 42#define KERNTEXTOFF 0xffffffff80200000 /* start of kernel text */
38#define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) 43#define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT)
39 44
40#define KERNTEXTOFF_HI 0xffffffff 45#define KERNTEXTOFF_HI 0xffffffff
41#define KERNTEXTOFF_LO 0x80200000 46#define KERNTEXTOFF_LO 0x80200000
42 47
43#define KERNBASE_HI 0xffffffff 48#define KERNBASE_HI 0xffffffff
44#define KERNBASE_LO 0x80000000 49#define KERNBASE_LO 0x80000000
45 50

cvs diff -r1.80 -r1.81 src/sys/arch/i386/include/param.h (expand / switch to unified diff)

--- src/sys/arch/i386/include/param.h 2017/01/20 00:29:28 1.80
+++ src/sys/arch/i386/include/param.h 2017/06/14 12:27:24 1.81
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: param.h,v 1.80 2017/01/20 00:29:28 maya Exp $ */ 1/* $NetBSD: param.h,v 1.81 2017/06/14 12:27:24 maxv Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1990 The Regents of the University of California. 4 * Copyright (c) 1990 The Regents of the University of California.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * William Jolitz. 8 * William Jolitz.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -57,26 +57,35 @@ @@ -57,26 +57,35 @@
57#define _MACHINE_ARCH i386 57#define _MACHINE_ARCH i386
58#define MACHINE_ARCH "i386" 58#define MACHINE_ARCH "i386"
59#define MID_MACHINE MID_I386 59#define MID_MACHINE MID_I386
60 60
61#define ALIGNED_POINTER(p,t) 1 61#define ALIGNED_POINTER(p,t) 1
62 62
63#define PGSHIFT 12 /* LOG2(NBPG) */ 63#define PGSHIFT 12 /* LOG2(NBPG) */
64#define NBPG (1 << PGSHIFT) /* bytes/page */ 64#define NBPG (1 << PGSHIFT) /* bytes/page */
65#define PGOFSET (NBPG-1) /* byte offset into page */ 65#define PGOFSET (NBPG-1) /* byte offset into page */
66#define NPTEPG (NBPG/(sizeof (pt_entry_t))) 66#define NPTEPG (NBPG/(sizeof (pt_entry_t)))
67 67
68#define MAXIOMEM 0xffffffff 68#define MAXIOMEM 0xffffffff
69 69
 70/*
 71 * Maximum physical memory supported by the implementation.
 72 */
 73#ifdef PAE
 74#define MAXPHYSMEM 0x1000000000ULL /* 64GB */
 75#else
 76#define MAXPHYSMEM 0x100000000ULL /* 4GB */
 77#endif
 78
70#if defined(_KERNEL_OPT) 79#if defined(_KERNEL_OPT)
71#include "opt_kernbase.h" 80#include "opt_kernbase.h"
72#endif /* defined(_KERNEL_OPT) */ 81#endif /* defined(_KERNEL_OPT) */
73 82
74#ifdef KERNBASE_LOCORE 83#ifdef KERNBASE_LOCORE
75#error "You should only re-define KERNBASE" 84#error "You should only re-define KERNBASE"
76#endif 85#endif
77 86
78#ifndef KERNBASE 87#ifndef KERNBASE
79#define KERNBASE 0xc0000000UL /* start of kernel virtual space */ 88#define KERNBASE 0xc0000000UL /* start of kernel virtual space */
80#endif 89#endif
81 90
82#define KERNTEXTOFF (KERNBASE + 0x100000) /* start of kernel text */ 91#define KERNTEXTOFF (KERNBASE + 0x100000) /* start of kernel text */

cvs diff -r1.92 -r1.93 src/sys/arch/x86/x86/x86_machdep.c (expand / switch to unified diff)

--- src/sys/arch/x86/x86/x86_machdep.c 2017/06/14 08:12:22 1.92
+++ src/sys/arch/x86/x86/x86_machdep.c 2017/06/14 12:27:24 1.93
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: x86_machdep.c,v 1.92 2017/06/14 08:12:22 maxv Exp $ */ 1/* $NetBSD: x86_machdep.c,v 1.93 2017/06/14 12:27:24 maxv Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi, 4 * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi,
5 * Copyright (c) 2005, 2008, 2009 The NetBSD Foundation, Inc. 5 * Copyright (c) 2005, 2008, 2009 The NetBSD Foundation, Inc.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * This code is derived from software contributed to The NetBSD Foundation 8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Julio M. Merino Vidal. 9 * by Julio M. Merino Vidal.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -21,27 +21,27 @@ @@ -21,27 +21,27 @@
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE. 30 * POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33#include <sys/cdefs.h> 33#include <sys/cdefs.h>
34__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.92 2017/06/14 08:12:22 maxv Exp $"); 34__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.93 2017/06/14 12:27:24 maxv Exp $");
35 35
36#include "opt_modular.h" 36#include "opt_modular.h"
37#include "opt_physmem.h" 37#include "opt_physmem.h"
38#include "opt_splash.h" 38#include "opt_splash.h"
39 39
40#include <sys/types.h> 40#include <sys/types.h>
41#include <sys/param.h> 41#include <sys/param.h>
42#include <sys/systm.h> 42#include <sys/systm.h>
43#include <sys/kcore.h> 43#include <sys/kcore.h>
44#include <sys/errno.h> 44#include <sys/errno.h>
45#include <sys/kauth.h> 45#include <sys/kauth.h>
46#include <sys/mutex.h> 46#include <sys/mutex.h>
47#include <sys/cpu.h> 47#include <sys/cpu.h>
@@ -509,47 +509,37 @@ x86_select_freelist(uint64_t maxaddr) @@ -509,47 +509,37 @@ x86_select_freelist(uint64_t maxaddr)
509 509
510 panic("no freelist for maximum address %"PRIx64, maxaddr); 510 panic("no freelist for maximum address %"PRIx64, maxaddr);
511} 511}
512 512
513static int 513static int
514x86_add_cluster(uint64_t seg_start, uint64_t seg_end, uint32_t type) 514x86_add_cluster(uint64_t seg_start, uint64_t seg_end, uint32_t type)
515{ 515{
516 extern struct extent *iomem_ex; 516 extern struct extent *iomem_ex;
517 const uint64_t endext = MAXIOMEM + 1; 517 const uint64_t endext = MAXIOMEM + 1;
518 uint64_t new_physmem = 0; 518 uint64_t new_physmem = 0;
519 phys_ram_seg_t *cluster; 519 phys_ram_seg_t *cluster;
520 int i; 520 int i;
521 521
522#ifdef i386 522 if (seg_end > MAXPHYSMEM) {
523#ifdef PAE 
524#define TOPLIMIT 0x1000000000ULL /* 64GB */ 
525#else 
526#define TOPLIMIT 0x100000000ULL /* 4GB */ 
527#endif 
528#else 
529#define TOPLIMIT 0x100000000000ULL /* 16TB */ 
530#endif 
531 
532 if (seg_end > TOPLIMIT) { 
533 aprint_verbose("WARNING: skipping large memory map entry: " 523 aprint_verbose("WARNING: skipping large memory map entry: "
534 "0x%"PRIx64"/0x%"PRIx64"/0x%x\n", 524 "0x%"PRIx64"/0x%"PRIx64"/0x%x\n",
535 seg_start, (seg_end - seg_start), type); 525 seg_start, (seg_end - seg_start), type);
536 return 0; 526 return 0;
537 } 527 }
538 528
539 /* 529 /*
540 * XXX: Chop the last page off the size so that it can fit in avail_end. 530 * XXX: Chop the last page off the size so that it can fit in avail_end.
541 */ 531 */
542 if (seg_end == TOPLIMIT) 532 if (seg_end == MAXPHYSMEM)
543 seg_end -= PAGE_SIZE; 533 seg_end -= PAGE_SIZE;
544 534
545 if (seg_end <= seg_start) 535 if (seg_end <= seg_start)
546 return 0; 536 return 0;
547 537
548 for (i = 0; i < mem_cluster_cnt; i++) { 538 for (i = 0; i < mem_cluster_cnt; i++) {
549 cluster = &mem_clusters[i]; 539 cluster = &mem_clusters[i];
550 if ((cluster->start == round_page(seg_start)) && 540 if ((cluster->start == round_page(seg_start)) &&
551 (cluster->size == trunc_page(seg_end) - cluster->start)) { 541 (cluster->size == trunc_page(seg_end) - cluster->start)) {
552#ifdef DEBUG_MEMLOAD 542#ifdef DEBUG_MEMLOAD
553 printf("WARNING: skipping duplicate segment entry\n"); 543 printf("WARNING: skipping duplicate segment entry\n");
554#endif 544#endif
555 return 0; 545 return 0;