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.
This commit is contained in:
parent
c031d605d2
commit
404effc719
@ -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
|
* Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
|
||||||
@ -111,7 +111,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#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 */
|
/* #define XENDEBUG_LOW */
|
||||||
|
|
||||||
@ -1537,10 +1537,6 @@ init_x86_64(paddr_t first_avail)
|
|||||||
int x;
|
int x;
|
||||||
#ifndef XEN
|
#ifndef XEN
|
||||||
int ist;
|
int ist;
|
||||||
extern struct extent *iomem_ex;
|
|
||||||
#if !defined(REALEXTMEM) && !defined(REALBASEMEM)
|
|
||||||
struct btinfo_memmap *bim;
|
|
||||||
#endif
|
|
||||||
#endif /* !XEN */
|
#endif /* !XEN */
|
||||||
|
|
||||||
#ifdef XEN
|
#ifdef XEN
|
||||||
@ -1589,23 +1585,8 @@ init_x86_64(paddr_t first_avail)
|
|||||||
*/
|
*/
|
||||||
avail_start = 8 * PAGE_SIZE;
|
avail_start = 8 * PAGE_SIZE;
|
||||||
|
|
||||||
#if !defined(REALBASEMEM) && !defined(REALEXTMEM)
|
/* Initialize the memory clusters (needed in pmap_boostrap). */
|
||||||
/*
|
init_x86_clusters();
|
||||||
* 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);
|
|
||||||
|
|
||||||
#else /* XEN */
|
#else /* XEN */
|
||||||
/* Parse Xen command line (replace bootinfo) */
|
/* Parse Xen command line (replace bootinfo) */
|
||||||
xen_parse_cmdline(XEN_PARSE_BOOTFLAGS, NULL);
|
xen_parse_cmdline(XEN_PARSE_BOOTFLAGS, NULL);
|
||||||
@ -1629,7 +1610,8 @@ init_x86_64(paddr_t first_avail)
|
|||||||
pmap_prealloc_lowmem_ptps();
|
pmap_prealloc_lowmem_ptps();
|
||||||
|
|
||||||
#ifndef XEN
|
#ifndef XEN
|
||||||
initx86_load_memmap(first_avail);
|
/* Internalize the physical pages into the VM system. */
|
||||||
|
init_x86_vm(first_avail);
|
||||||
#else /* XEN */
|
#else /* XEN */
|
||||||
kern_end = KERNBASE + first_avail;
|
kern_end = KERNBASE + first_avail;
|
||||||
physmem = xen_start_info.nr_pages;
|
physmem = xen_start_info.nr_pages;
|
||||||
|
@ -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
|
* Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
|
||||||
@ -67,7 +67,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#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_beep.h"
|
||||||
#include "opt_compat_ibcs2.h"
|
#include "opt_compat_ibcs2.h"
|
||||||
@ -1129,9 +1129,7 @@ init386(paddr_t first_avail)
|
|||||||
int x;
|
int x;
|
||||||
#ifndef XEN
|
#ifndef XEN
|
||||||
union descriptor *tgdt;
|
union descriptor *tgdt;
|
||||||
extern struct extent *iomem_ex;
|
|
||||||
struct region_descriptor region;
|
struct region_descriptor region;
|
||||||
struct btinfo_memmap *bim;
|
|
||||||
#endif
|
#endif
|
||||||
#if NBIOSCALL > 0
|
#if NBIOSCALL > 0
|
||||||
extern int biostramp_image_size;
|
extern int biostramp_image_size;
|
||||||
@ -1246,24 +1244,11 @@ init386(paddr_t first_avail)
|
|||||||
pmap_bootstrap((vaddr_t)atdevbase + IOM_SIZE);
|
pmap_bootstrap((vaddr_t)atdevbase + IOM_SIZE);
|
||||||
|
|
||||||
#ifndef XEN
|
#ifndef XEN
|
||||||
/*
|
/* Initialize the memory clusters. */
|
||||||
* Check to see if we have a memory map from the BIOS (passed to us by
|
init_x86_clusters();
|
||||||
* 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);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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 */
|
#else /* !XEN */
|
||||||
XENPRINTK(("load the memory cluster 0x%" PRIx64 " (%" PRId64 ") - "
|
XENPRINTK(("load the memory cluster 0x%" PRIx64 " (%" PRId64 ") - "
|
||||||
"0x%" PRIx64 " (%" PRId64 ")\n",
|
"0x%" PRIx64 " (%" PRId64 ")\n",
|
||||||
|
@ -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.
|
* Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@ -41,11 +41,11 @@ void x86_cpu_idle_init(void);
|
|||||||
void x86_cpu_idle_get(void (**)(void), char *, size_t);
|
void x86_cpu_idle_get(void (**)(void), char *, size_t);
|
||||||
void x86_cpu_idle_set(void (*)(void), const char *, bool);
|
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);
|
int x86_select_freelist(uint64_t);
|
||||||
|
|
||||||
|
void init_x86_clusters(void);
|
||||||
|
int init_x86_vm(paddr_t);
|
||||||
|
|
||||||
void x86_startup(void);
|
void x86_startup(void);
|
||||||
void x86_sysctl_machdep_setup(struct sysctllog **);
|
void x86_sysctl_machdep_setup(struct sysctllog **);
|
||||||
|
|
||||||
|
@ -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,
|
* Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi,
|
||||||
@ -31,7 +31,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#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_modular.h"
|
||||||
#include "opt_physmem.h"
|
#include "opt_physmem.h"
|
||||||
@ -588,7 +588,7 @@ add_mem_cluster(phys_ram_seg_t *seg_clusters, int seg_cluster_cnt,
|
|||||||
return seg_cluster_cnt;
|
return seg_cluster_cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
initx86_parse_memmap(struct btinfo_memmap *bim, struct extent *iomem_ex)
|
initx86_parse_memmap(struct btinfo_memmap *bim, struct extent *iomem_ex)
|
||||||
{
|
{
|
||||||
uint64_t seg_start, seg_end;
|
uint64_t seg_start, seg_end;
|
||||||
@ -663,7 +663,7 @@ initx86_parse_memmap(struct btinfo_memmap *bim, struct extent *iomem_ex)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
initx86_fake_memmap(struct extent *iomem_ex)
|
initx86_fake_memmap(struct extent *iomem_ex)
|
||||||
{
|
{
|
||||||
phys_ram_seg_t *cluster;
|
phys_ram_seg_t *cluster;
|
||||||
@ -816,8 +816,51 @@ x86_load_region(uint64_t seg_start, uint64_t seg_end)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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
|
int
|
||||||
initx86_load_memmap(paddr_t first_avail)
|
init_x86_vm(paddr_t first_avail)
|
||||||
{
|
{
|
||||||
uint64_t seg_start, seg_end;
|
uint64_t seg_start, seg_end;
|
||||||
uint64_t seg_start1, seg_end1;
|
uint64_t seg_start1, seg_end1;
|
||||||
|
Loading…
Reference in New Issue
Block a user