Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Simplify the way physical pages are internalized in...
details: https://anonhg.NetBSD.org/src/rev/3feeca14ef88
branches: trunk
changeset: 816657:3feeca14ef88
user: maxv <maxv%NetBSD.org@localhost>
date: Sat Jul 16 17:02:34 2016 +0000
description:
Simplify the way physical pages are internalized into the VM system on x86.
Only two functions are called now: init_x86_clusters, which initializes the
memory clusters from the bootinfo, and init_x86_vm, which inserts the pages
from the clusters into VM.
diffstat:
sys/arch/amd64/amd64/machdep.c | 30 ++++-------------------
sys/arch/i386/i386/machdep.c | 27 ++++----------------
sys/arch/x86/include/machdep.h | 8 +++---
sys/arch/x86/x86/x86_machdep.c | 53 ++++++++++++++++++++++++++++++++++++++---
4 files changed, 64 insertions(+), 54 deletions(-)
diffs (235 lines):
diff -r 424e32511090 -r 3feeca14ef88 sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c Sat Jul 16 14:51:45 2016 +0000
+++ b/sys/arch/amd64/amd64/machdep.c Sat Jul 16 17:02:34 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.223 2016/07/13 15:53:26 maxv Exp $ */
+/* $NetBSD: machdep.c,v 1.224 2016/07/16 17:02:34 maxv Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -111,7 +111,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.223 2016/07/13 15:53:26 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.224 2016/07/16 17:02:34 maxv Exp $");
/* #define XENDEBUG_LOW */
@@ -1537,10 +1537,6 @@
int x;
#ifndef XEN
int ist;
- extern struct extent *iomem_ex;
-#if !defined(REALEXTMEM) && !defined(REALBASEMEM)
- struct btinfo_memmap *bim;
-#endif
#endif /* !XEN */
#ifdef XEN
@@ -1589,23 +1585,8 @@
*/
avail_start = 8 * PAGE_SIZE;
-#if !defined(REALBASEMEM) && !defined(REALEXTMEM)
- /*
- * Check to see if we have a memory map from the BIOS (passed to us by
- * the boot program).
- */
- bim = lookup_bootinfo(BTINFO_MEMMAP);
- if (bim != NULL && bim->num > 0)
- initx86_parse_memmap(bim, iomem_ex);
-#endif /* ! REALBASEMEM && ! REALEXTMEM */
-
- /*
- * If initx86_parse_memmap didn't find any valid segment, fall back to
- * former code.
- */
- if (mem_cluster_cnt == 0)
- initx86_fake_memmap(iomem_ex);
-
+ /* Initialize the memory clusters (needed in pmap_boostrap). */
+ init_x86_clusters();
#else /* XEN */
/* Parse Xen command line (replace bootinfo) */
xen_parse_cmdline(XEN_PARSE_BOOTFLAGS, NULL);
@@ -1629,7 +1610,8 @@
pmap_prealloc_lowmem_ptps();
#ifndef XEN
- initx86_load_memmap(first_avail);
+ /* Internalize the physical pages into the VM system. */
+ init_x86_vm(first_avail);
#else /* XEN */
kern_end = KERNBASE + first_avail;
physmem = xen_start_info.nr_pages;
diff -r 424e32511090 -r 3feeca14ef88 sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c Sat Jul 16 14:51:45 2016 +0000
+++ b/sys/arch/i386/i386/machdep.c Sat Jul 16 17:02:34 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.758 2016/07/13 15:53:27 maxv Exp $ */
+/* $NetBSD: machdep.c,v 1.759 2016/07/16 17:02:34 maxv Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.758 2016/07/13 15:53:27 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.759 2016/07/16 17:02:34 maxv Exp $");
#include "opt_beep.h"
#include "opt_compat_ibcs2.h"
@@ -1129,9 +1129,7 @@
int x;
#ifndef XEN
union descriptor *tgdt;
- extern struct extent *iomem_ex;
struct region_descriptor region;
- struct btinfo_memmap *bim;
#endif
#if NBIOSCALL > 0
extern int biostramp_image_size;
@@ -1246,24 +1244,11 @@
pmap_bootstrap((vaddr_t)atdevbase + IOM_SIZE);
#ifndef XEN
- /*
- * Check to see if we have a memory map from the BIOS (passed to us by
- * the boot program).
- */
- bim = lookup_bootinfo(BTINFO_MEMMAP);
- if ((biosmem_implicit || (biosbasemem == 0 && biosextmem == 0)) &&
- bim != NULL && bim->num > 0)
- initx86_parse_memmap(bim, iomem_ex);
+ /* Initialize the memory clusters. */
+ init_x86_clusters();
- /*
- * If initx86_parse_memmap didn't find any valid segment, fall back to
- * former code.
- */
- if (mem_cluster_cnt == 0)
- initx86_fake_memmap(iomem_ex);
-
- initx86_load_memmap(first_avail);
-
+ /* Internalize the physical pages into the VM system. */
+ init_x86_vm(first_avail);
#else /* !XEN */
XENPRINTK(("load the memory cluster 0x%" PRIx64 " (%" PRId64 ") - "
"0x%" PRIx64 " (%" PRId64 ")\n",
diff -r 424e32511090 -r 3feeca14ef88 sys/arch/x86/include/machdep.h
--- a/sys/arch/x86/include/machdep.h Sat Jul 16 14:51:45 2016 +0000
+++ b/sys/arch/x86/include/machdep.h Sat Jul 16 17:02:34 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.h,v 1.7 2014/06/12 19:02:35 riastradh Exp $ */
+/* $NetBSD: machdep.h,v 1.8 2016/07/16 17:02:34 maxv Exp $ */
/*
* Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -41,11 +41,11 @@
void x86_cpu_idle_get(void (**)(void), char *, size_t);
void x86_cpu_idle_set(void (*)(void), const char *, bool);
-int initx86_parse_memmap(struct btinfo_memmap *, struct extent *);
-int initx86_fake_memmap(struct extent *);
-int initx86_load_memmap(paddr_t first_avail);
int x86_select_freelist(uint64_t);
+void init_x86_clusters(void);
+int init_x86_vm(paddr_t);
+
void x86_startup(void);
void x86_sysctl_machdep_setup(struct sysctllog **);
diff -r 424e32511090 -r 3feeca14ef88 sys/arch/x86/x86/x86_machdep.c
--- a/sys/arch/x86/x86/x86_machdep.c Sat Jul 16 14:51:45 2016 +0000
+++ b/sys/arch/x86/x86/x86_machdep.c Sat Jul 16 17:02:34 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: x86_machdep.c,v 1.71 2016/07/16 14:51:45 maxv Exp $ */
+/* $NetBSD: x86_machdep.c,v 1.72 2016/07/16 17:02:34 maxv Exp $ */
/*-
* Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi,
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.71 2016/07/16 14:51:45 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.72 2016/07/16 17:02:34 maxv Exp $");
#include "opt_modular.h"
#include "opt_physmem.h"
@@ -588,7 +588,7 @@
return seg_cluster_cnt;
}
-int
+static int
initx86_parse_memmap(struct btinfo_memmap *bim, struct extent *iomem_ex)
{
uint64_t seg_start, seg_end;
@@ -663,7 +663,7 @@
return 0;
}
-int
+static int
initx86_fake_memmap(struct extent *iomem_ex)
{
phys_ram_seg_t *cluster;
@@ -816,8 +816,51 @@
}
}
+/*
+ * init_x86_clusters: retrieve the memory clusters provided by the BIOS, and
+ * initialize mem_clusters.
+ */
+void
+init_x86_clusters(void)
+{
+ extern struct extent *iomem_ex;
+ struct btinfo_memmap *bim;
+
+ /*
+ * Check to see if we have a memory map from the BIOS (passed to us by
+ * the boot program).
+ */
+#ifdef i386
+ bim = lookup_bootinfo(BTINFO_MEMMAP);
+ if ((biosmem_implicit || (biosbasemem == 0 && biosextmem == 0)) &&
+ bim != NULL && bim->num > 0)
+ initx86_parse_memmap(bim, iomem_ex);
+#else
+#if !defined(REALBASEMEM) && !defined(REALEXTMEM)
+ bim = lookup_bootinfo(BTINFO_MEMMAP);
+ if (bim != NULL && bim->num > 0)
+ initx86_parse_memmap(bim, iomem_ex);
+#else
+ (void)bim, (void)iomem_ex;
+#endif
+#endif
+
+ if (mem_cluster_cnt == 0) {
+ /*
+ * If initx86_parse_memmap didn't find any valid segment, create
+ * fake clusters.
+ */
+ initx86_fake_memmap(iomem_ex);
+ }
+}
+
+/*
+ * init_x86_vm: initialize the VM system on x86. We basically internalize as
+ * many physical pages as we can, starting at avail_start, but we don't
+ * internalize the kernel physical pages (from IOM_END to first_avail).
+ */
int
-initx86_load_memmap(paddr_t first_avail)
+init_x86_vm(paddr_t first_avail)
{
uint64_t seg_start, seg_end;
uint64_t seg_start1, seg_end1;
Home |
Main Index |
Thread Index |
Old Index