Move phys_avail definition into MI code. It is consumed in the MI layer and

doing so adds more flexibility with less redundant code.

Reviewed by:	jhb, markj, kib
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D21250
This commit is contained in:
Jeff Roberson 2019-08-16 00:45:14 +00:00
parent ccfbff6d59
commit 2194393787
41 changed files with 106 additions and 119 deletions

View File

@ -210,21 +210,6 @@ int cold = 1;
long Maxmem = 0;
long realmem = 0;
/*
* The number of PHYSMAP entries must be one less than the number of
* PHYSSEG entries because the PHYSMAP entry that spans the largest
* physical address that is accessible by ISA DMA is split into two
* PHYSSEG entries.
*/
#define PHYSMAP_SIZE (2 * (VM_PHYSSEG_MAX - 1))
vm_paddr_t phys_avail[PHYSMAP_SIZE + 2];
vm_paddr_t dump_avail[PHYSMAP_SIZE + 2];
/* must be 2 less so 0 0 can signal end of chunks */
#define PHYS_AVAIL_ARRAY_END (nitems(phys_avail) - 2)
#define DUMP_AVAIL_ARRAY_END (nitems(dump_avail) - 2)
struct kva_md_info kmi;
static struct trapframe proc0_tf;
@ -1036,7 +1021,7 @@ add_physmap_entry(uint64_t base, uint64_t length, vm_paddr_t *physmap,
physmap_idx += 2;
*physmap_idxp = physmap_idx;
if (physmap_idx == PHYSMAP_SIZE) {
if (physmap_idx == PHYS_AVAIL_ENTRIES) {
printf(
"Too many segments in the physical address map, giving up\n");
return (0);
@ -1229,7 +1214,7 @@ static void
getmemsize(caddr_t kmdp, u_int64_t first)
{
int i, physmap_idx, pa_indx, da_indx;
vm_paddr_t pa, physmap[PHYSMAP_SIZE];
vm_paddr_t pa, physmap[PHYS_AVAIL_ENTRIES];
u_long physmem_start, physmem_tunable, memtest;
pt_entry_t *pte;
quad_t dcons_addr, dcons_size;
@ -1446,7 +1431,7 @@ getmemsize(caddr_t kmdp, u_int64_t first)
phys_avail[pa_indx] += PAGE_SIZE;
} else {
pa_indx++;
if (pa_indx == PHYS_AVAIL_ARRAY_END) {
if (pa_indx == PHYS_AVAIL_ENTRIES) {
printf(
"Too many holes in the physical address space, giving up\n");
pa_indx--;
@ -1462,7 +1447,7 @@ getmemsize(caddr_t kmdp, u_int64_t first)
dump_avail[da_indx] += PAGE_SIZE;
} else {
da_indx++;
if (da_indx == DUMP_AVAIL_ARRAY_END) {
if (da_indx == PHYS_AVAIL_ENTRIES) {
da_indx--;
goto do_next;
}

View File

@ -408,8 +408,6 @@ struct pv_chunk {
extern caddr_t CADDR1;
extern pt_entry_t *CMAP1;
extern vm_paddr_t phys_avail[];
extern vm_paddr_t dump_avail[];
extern vm_offset_t virtual_avail;
extern vm_offset_t virtual_end;
extern vm_paddr_t dmaplimit;

View File

@ -70,7 +70,9 @@ __FBSDID("$FreeBSD$");
#include <sys/uio.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_page.h>
#include <vm/vm_phys.h>
#include <vm/vm_map.h>
#include <vm/vm_extern.h>
#include <vm/vm_kern.h>

View File

@ -52,7 +52,9 @@ __FBSDID("$FreeBSD$");
#include <sys/uio.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_page.h>
#include <vm/vm_phys.h>
#include <vm/vm_map.h>
#include <vm/vm_extern.h>
#include <vm/vm_kern.h>

View File

@ -62,6 +62,9 @@ __FBSDID("$FreeBSD$");
#include <sys/uio.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_page.h>
#include <vm/vm_phys.h>
#include <vm/pmap.h>
#include <vm/vm_extern.h>

View File

@ -45,13 +45,15 @@ __FBSDID("$FreeBSD$");
#include <sys/watchdog.h>
#endif
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_page.h>
#include <vm/vm_phys.h>
#include <vm/pmap.h>
#include <machine/atomic.h>
#include <machine/cpu.h>
#include <machine/elf.h>
#include <machine/md_var.h>
#include <machine/minidump.h>
#include <machine/vmparam.h>
CTASSERT(sizeof(struct kerneldumpheader) == 512);

View File

@ -39,6 +39,9 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_page.h>
#include <vm/vm_phys.h>
#include <machine/md_var.h>
#include <arm/include/physmem.h>
@ -77,32 +80,6 @@ static struct region exregions[MAX_EXCNT];
static size_t hwcnt;
static size_t excnt;
/*
* These "avail lists" are globals used to communicate physical memory layout to
* other parts of the kernel. Within the arrays, each value is the starting
* address of a contiguous area of physical address space. The values at even
* indexes are areas that contain usable memory and the values at odd indexes
* are areas that aren't usable. Each list is terminated by a pair of zero
* entries.
*
* dump_avail tells the dump code what regions to include in a crash dump, and
* phys_avail is the way we hand all the remaining physical ram we haven't used
* in early kernel init over to the vm system for allocation management.
*
* We size these arrays to hold twice as many available regions as we allow for
* hardware memory regions, to allow for the fact that exclusions can split a
* hardware region into two or more available regions. In the real world there
* will typically be one or two hardware regions and two or three exclusions.
*
* Each available region in this list occupies two array slots (the start of the
* available region and the start of the unavailable region that follows it).
*/
#define MAX_AVAIL_REGIONS (MAX_HWCNT * 2)
#define MAX_AVAIL_ENTRIES (MAX_AVAIL_REGIONS * 2)
vm_paddr_t phys_avail[MAX_AVAIL_ENTRIES + 2]; /* +2 to allow for a pair */
vm_paddr_t dump_avail[MAX_AVAIL_ENTRIES + 2]; /* of zeroes to terminate. */
/*
* realmem is the total number of hardware pages, excluded or not.
* Maxmem is one greater than the last physical page number.
@ -405,10 +382,10 @@ arm_physmem_init_kernel_globals(void)
{
size_t nextidx;
regions_to_avail(dump_avail, EXFLAG_NODUMP, MAX_AVAIL_ENTRIES, NULL,
regions_to_avail(dump_avail, EXFLAG_NODUMP, PHYS_AVAIL_ENTRIES, NULL,
NULL);
nextidx = regions_to_avail(phys_avail, EXFLAG_NOALLOC,
MAX_AVAIL_ENTRIES, &physmem, &realmem);
PHYS_AVAIL_ENTRIES, &physmem, &realmem);
if (nextidx == 0)
panic("No memory entries in phys_avail");
Maxmem = atop(phys_avail[nextidx - 1]);

View File

@ -41,9 +41,6 @@
#ifdef _KERNEL
#include <sys/systm.h>
extern vm_paddr_t dump_avail[];
extern vm_paddr_t phys_avail[];
extern char *_tmppt; /* poor name! */
extern vm_offset_t virtual_avail;

View File

@ -132,9 +132,6 @@ extern struct pmap kernel_pmap_store;
#define PMAP_TRYLOCK(pmap) mtx_trylock(&(pmap)->pm_mtx)
#define PMAP_UNLOCK(pmap) mtx_unlock(&(pmap)->pm_mtx)
#define PHYS_AVAIL_SIZE 32
extern vm_paddr_t phys_avail[];
extern vm_paddr_t dump_avail[];
extern vm_offset_t virtual_avail;
extern vm_offset_t virtual_end;

View File

@ -194,21 +194,6 @@ long realmem = 0;
FEATURE(pae, "Physical Address Extensions");
#endif
/*
* The number of PHYSMAP entries must be one less than the number of
* PHYSSEG entries because the PHYSMAP entry that spans the largest
* physical address that is accessible by ISA DMA is split into two
* PHYSSEG entries.
*/
#define PHYSMAP_SIZE (2 * (VM_PHYSSEG_MAX - 1))
vm_paddr_t phys_avail[PHYSMAP_SIZE + 2];
vm_paddr_t dump_avail[PHYSMAP_SIZE + 2];
/* must be 2 less so 0 0 can signal end of chunks */
#define PHYS_AVAIL_ARRAY_END (nitems(phys_avail) - 2)
#define DUMP_AVAIL_ARRAY_END (nitems(dump_avail) - 2)
struct kva_md_info kmi;
static struct trapframe proc0_tf;
@ -1736,7 +1721,7 @@ add_physmap_entry(uint64_t base, uint64_t length, vm_paddr_t *physmap,
physmap_idx += 2;
*physmap_idxp = physmap_idx;
if (physmap_idx == PHYSMAP_SIZE) {
if (physmap_idx == PHYS_AVAIL_ENTRIES) {
printf(
"Too many segments in the physical address map, giving up\n");
return (0);
@ -1823,7 +1808,7 @@ getmemsize(int first)
{
int has_smap, off, physmap_idx, pa_indx, da_indx;
u_long memtest;
vm_paddr_t physmap[PHYSMAP_SIZE];
vm_paddr_t physmap[PHYS_AVAIL_ENTRIES];
quad_t dcons_addr, dcons_size, physmem_tunable;
int hasbrokenint12, i, res;
u_int extmem;
@ -2136,7 +2121,7 @@ getmemsize(int first)
phys_avail[pa_indx] += PAGE_SIZE;
} else {
pa_indx++;
if (pa_indx == PHYS_AVAIL_ARRAY_END) {
if (pa_indx == PHYS_AVAIL_ENTRIES) {
printf(
"Too many holes in the physical address space, giving up\n");
pa_indx--;
@ -2152,7 +2137,7 @@ getmemsize(int first)
dump_avail[da_indx] += PAGE_SIZE;
} else {
da_indx++;
if (da_indx == DUMP_AVAIL_ARRAY_END) {
if (da_indx == PHYS_AVAIL_ENTRIES) {
da_indx--;
goto do_next;
}

View File

@ -40,6 +40,9 @@ __FBSDID("$FreeBSD$");
#include <sys/msgbuf.h>
#include <sys/watchdog.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_page.h>
#include <vm/vm_phys.h>
#include <vm/pmap.h>
#include <machine/atomic.h>
#include <machine/elf.h>

View File

@ -234,8 +234,6 @@ struct pv_chunk {
#ifdef _KERNEL
extern vm_paddr_t phys_avail[];
extern vm_paddr_t dump_avail[];
extern char *ptvmmap; /* poor name! */
extern vm_offset_t virtual_avail;
extern vm_offset_t virtual_end;

View File

@ -37,6 +37,8 @@ __FBSDID("$FreeBSD$");
#include <sys/watchdog.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_page.h>
#include <vm/vm_phys.h>
#include <vm/pmap.h>
#include <machine/dump.h>
#include <machine/elf.h>

View File

@ -42,7 +42,9 @@ __FBSDID("$FreeBSD$");
#include <sys/boot.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_page.h>
#include <vm/vm_phys.h>
#include <net/ethernet.h>
@ -52,7 +54,6 @@ __FBSDID("$FreeBSD$");
#include <machine/hwfunc.h>
#include <machine/md_var.h>
#include <machine/trap.h>
#include <machine/vmparam.h>
#include <mips/atheros/ar531x/ar5315reg.h>

View File

@ -45,7 +45,9 @@ __FBSDID("$FreeBSD$");
#include <sys/reboot.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_page.h>
#include <vm/vm_phys.h>
#include <net/ethernet.h>
@ -55,7 +57,6 @@ __FBSDID("$FreeBSD$");
#include <machine/hwfunc.h>
#include <machine/md_var.h>
#include <machine/trap.h>
#include <machine/vmparam.h>
#include <mips/atheros/ar71xxreg.h>

View File

@ -65,8 +65,10 @@ __FBSDID("$FreeBSD$");
#endif
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_object.h>
#include <vm/vm_page.h>
#include <vm/vm_phys.h>
#include <machine/bootinfo.h>
#include <machine/clock.h>

View File

@ -57,8 +57,10 @@ __FBSDID("$FreeBSD$");
#include <sys/user.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_object.h>
#include <vm/vm_page.h>
#include <vm/vm_phys.h>
#include <machine/cache.h>
#include <machine/clock.h>
@ -73,7 +75,6 @@ __FBSDID("$FreeBSD$");
#include <machine/pte.h>
#include <machine/sigframe.h>
#include <machine/trap.h>
#include <machine/vmparam.h>
#include <dev/bhnd/bhnd.h>
#include <dev/bhnd/bhndreg.h>

View File

@ -56,8 +56,10 @@ __FBSDID("$FreeBSD$");
#include <sys/user.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_object.h>
#include <vm/vm_page.h>
#include <vm/vm_phys.h>
#include <machine/atomic.h>
#include <machine/cache.h>
@ -73,7 +75,6 @@ __FBSDID("$FreeBSD$");
#include <machine/pcpu.h>
#include <machine/pte.h>
#include <machine/trap.h>
#include <machine/vmparam.h>
#include <contrib/octeon-sdk/cvmx.h>
#include <contrib/octeon-sdk/cvmx-bootmem.h>

View File

@ -48,7 +48,7 @@
#ifndef _MACHINE_PMAP_H_
#define _MACHINE_PMAP_H_
#include <machine/vmparam.h>
#include <vm/vm_param.h>
#include <machine/pte.h>
#if defined(__mips_n32) || defined(__mips_n64) /* PHYSADDR_64BIT */
@ -157,15 +157,11 @@ struct pv_chunk {
* so we can describe up to (PHYS_AVAIL_ENTRIES / 2) distinct memory
* regions.
*/
#define PHYS_AVAIL_ENTRIES 10
extern vm_paddr_t phys_avail[PHYS_AVAIL_ENTRIES + 2];
extern vm_paddr_t physmem_desc[PHYS_AVAIL_ENTRIES + 2];
extern vm_paddr_t physmem_desc[PHYS_AVAIL_COUNT];
extern vm_offset_t virtual_avail;
extern vm_offset_t virtual_end;
extern vm_paddr_t dump_avail[PHYS_AVAIL_ENTRIES + 2];
#define pmap_page_get_memattr(m) (((m)->md.pv_flags & PV_MEMATTR_MASK) >> PV_MEMATTR_SHIFT)
#define pmap_page_is_mapped(m) (!TAILQ_EMPTY(&(m)->md.pv_list))
#define pmap_page_is_write_mapped(m) (((m)->aflags & PGA_WRITEABLE) != 0)

View File

@ -48,7 +48,9 @@ __FBSDID("$FreeBSD$");
#endif
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_page.h>
#include <vm/vm_phys.h>
#include <net/ethernet.h>
@ -58,7 +60,6 @@ __FBSDID("$FreeBSD$");
#include <machine/hwfunc.h>
#include <machine/md_var.h>
#include <machine/trap.h>
#include <machine/vmparam.h>
#include <mips/ingenic/jz4780_regs.h>
#include <mips/ingenic/jz4780_cpuregs.h>

View File

@ -54,8 +54,10 @@ __FBSDID("$FreeBSD$");
#include <sys/user.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_object.h>
#include <vm/vm_page.h>
#include <vm/vm_phys.h>
#include <machine/clock.h>
#include <machine/cpu.h>

View File

@ -54,8 +54,10 @@ __FBSDID("$FreeBSD$");
#include <sys/user.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_object.h>
#include <vm/vm_page.h>
#include <vm/vm_phys.h>
#include <machine/cache.h>
#include <machine/clock.h>
@ -70,7 +72,6 @@ __FBSDID("$FreeBSD$");
#include <machine/pte.h>
#include <machine/sigframe.h>
#include <machine/trap.h>
#include <machine/vmparam.h>
#include <mips/mediatek/mtk_sysctl.h>
#include <mips/mediatek/mtk_soc.h>

View File

@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_extern.h>
#include <vm/vm_kern.h>
#include <vm/vm_page.h>
#include <vm/vm_phys.h>
#include <vm/vm_map.h>
#include <machine/atomic.h>

View File

@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_kern.h>
#include <vm/vm_object.h>
#include <vm/vm_page.h>
#include <vm/vm_phys.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
#include <vm/vm_pager.h>
@ -140,9 +141,7 @@ char pcpu_space[MAXCPU][PAGE_SIZE * 2] \
struct pcpu *pcpup = (struct pcpu *)pcpu_space;
vm_paddr_t phys_avail[PHYS_AVAIL_ENTRIES + 2];
vm_paddr_t physmem_desc[PHYS_AVAIL_ENTRIES + 2];
vm_paddr_t dump_avail[PHYS_AVAIL_ENTRIES + 2];
vm_paddr_t physmem_desc[PHYS_AVAIL_COUNT];
#ifdef UNIMPLEMENTED
struct platform platform;

View File

@ -88,6 +88,7 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_param.h>
#include <vm/vm_kern.h>
#include <vm/vm_page.h>
#include <vm/vm_phys.h>
#include <vm/vm_map.h>
#include <vm/vm_object.h>
#include <vm/vm_extern.h>

View File

@ -56,7 +56,9 @@ __FBSDID("$FreeBSD$");
#include <sys/timetc.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_page.h>
#include <vm/vm_phys.h>
#include <machine/cpu.h>
#include <machine/cpufunc.h>

View File

@ -132,6 +132,8 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_map.h>
#include <vm/vm_object.h>
#include <vm/vm_extern.h>
#include <vm/vm_page.h>
#include <vm/vm_phys.h>
#include <vm/vm_pageout.h>
#include <vm/uma.h>
@ -749,7 +751,7 @@ moea_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm_offset_t kernelend)
} while (pa < end);
}
if (nitems(phys_avail) < regions_sz)
if (PHYS_AVAIL_ENTRIES < regions_sz)
panic("moea_bootstrap: phys_avail too small");
phys_avail_count = 0;

View File

@ -74,6 +74,7 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_param.h>
#include <vm/vm_kern.h>
#include <vm/vm_page.h>
#include <vm/vm_phys.h>
#include <vm/vm_map.h>
#include <vm/vm_object.h>
#include <vm/vm_extern.h>
@ -784,7 +785,7 @@ moea64_early_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm_offset_t kernelen
mem_regions(&pregions, &pregions_sz, &regions, &regions_sz);
CTR0(KTR_PMAP, "moea64_bootstrap: physical memory");
if (nitems(phys_avail) < regions_sz)
if (PHYS_AVAIL_ENTRIES < regions_sz)
panic("moea64_bootstrap: phys_avail too small");
phys_avail_count = 0;

View File

@ -1687,7 +1687,7 @@ mmu_booke_bootstrap(mmu_t mmu, vm_offset_t start, vm_offset_t kernelend)
mem_regions(&physmem_regions, &physmem_regions_sz,
&availmem_regions, &availmem_regions_sz);
if (nitems(phys_avail) < availmem_regions_sz)
if (PHYS_AVAIL_ENTRIES < availmem_regions_sz)
panic("mmu_booke_bootstrap: phys_avail too small");
sz = 0;

View File

@ -75,6 +75,7 @@
#include <machine/pte.h>
#include <machine/slb.h>
#include <machine/tlb.h>
#include <machine/vmparam.h>
struct pmap;
typedef struct pmap *pmap_t;
@ -268,12 +269,6 @@ boolean_t pmap_mmu_install(char *name, int prio);
#define vtophys(va) pmap_kextract((vm_offset_t)(va))
#define PHYS_AVAIL_SZ 256 /* Allows up to 16GB Ram on pSeries with
* logical memory block size of 64MB.
* For more Ram increase the lmb or this value.
*/
extern vm_paddr_t phys_avail[PHYS_AVAIL_SZ];
extern vm_offset_t virtual_avail;
extern vm_offset_t virtual_end;

View File

@ -154,7 +154,15 @@ struct pmap_physseg {
};
#endif
#define VM_PHYSSEG_MAX 16 /* 1? */
#define VM_PHYSSEG_MAX 16
#define PHYS_AVAIL_SZ 256 /* Allows up to 16GB Ram on pSeries with
* logical memory block size of 64MB.
* For more Ram increase the lmb or this value.
*/
/* XXX This is non-sensical. Phys avail should hold contiguous regions. */
#define PHYS_AVAIL_ENTRIES PHYS_AVAIL_SZ
/*
* The physical address space is densely populated on 32-bit systems,

View File

@ -100,6 +100,7 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_extern.h>
#include <vm/vm_kern.h>
#include <vm/vm_page.h>
#include <vm/vm_phys.h>
#include <vm/vm_map.h>
#include <vm/vm_object.h>
#include <vm/vm_pager.h>

View File

@ -75,7 +75,6 @@ struct pmap kernel_pmap_store;
vm_offset_t msgbuf_phys;
vm_offset_t kernel_vm_end;
vm_paddr_t phys_avail[PHYS_AVAIL_SZ];
vm_offset_t virtual_avail;
vm_offset_t virtual_end;

View File

@ -127,9 +127,6 @@ extern struct pmap kernel_pmap_store;
#define PMAP_TRYLOCK(pmap) mtx_trylock(&(pmap)->pm_mtx)
#define PMAP_UNLOCK(pmap) mtx_unlock(&(pmap)->pm_mtx)
#define PHYS_AVAIL_SIZE 10
extern vm_paddr_t phys_avail[];
extern vm_paddr_t dump_avail[];
extern vm_offset_t virtual_avail;
extern vm_offset_t virtual_end;

View File

@ -67,9 +67,11 @@ __FBSDID("$FreeBSD$");
#include <sys/vmmeter.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_kern.h>
#include <vm/vm_object.h>
#include <vm/vm_page.h>
#include <vm/vm_phys.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
#include <vm/vm_pager.h>
@ -100,9 +102,6 @@ struct pcpu __pcpu[MAXCPU];
static struct trapframe proc0_tf;
vm_paddr_t phys_avail[PHYS_AVAIL_SIZE + 2];
vm_paddr_t dump_avail[PHYS_AVAIL_SIZE + 2];
int early_boot = 1;
int cold = 1;
long realmem = 0;
@ -110,8 +109,7 @@ long Maxmem = 0;
#define DTB_SIZE_MAX (1024 * 1024)
#define PHYSMAP_SIZE (2 * (VM_PHYSSEG_MAX - 1))
vm_paddr_t physmap[PHYSMAP_SIZE];
vm_paddr_t physmap[PHYS_AVAIL_ENTRIES];
u_int physmap_idx;
struct kva_md_info kmi;
@ -707,7 +705,7 @@ add_physmap_entry(uint64_t base, uint64_t length, vm_paddr_t *physmap,
_physmap_idx += 2;
*physmap_idxp = _physmap_idx;
if (_physmap_idx == PHYSMAP_SIZE) {
if (_physmap_idx == PHYS_AVAIL_ENTRIES) {
printf(
"Too many segments in the physical address map, giving up\n");
return (0);

View File

@ -105,7 +105,6 @@ void pmap_set_kctx(void);
extern struct pmap kernel_pmap_store;
#define kernel_pmap (&kernel_pmap_store)
extern struct rwlock_padalign tte_list_global_lock;
extern vm_paddr_t phys_avail[];
extern vm_offset_t virtual_avail;
extern vm_offset_t virtual_end;

View File

@ -102,11 +102,10 @@ __FBSDID("$FreeBSD$");
/*
* Map of physical memory reagions
*/
vm_paddr_t phys_avail[128];
static struct ofw_mem_region mra[128];
struct ofw_mem_region sparc64_memreg[128];
static struct ofw_mem_region mra[VM_PHYSSEG_MAX];
struct ofw_mem_region sparc64_memreg[VM_PHYSSEG_MAX];
int sparc64_nmemreg;
static struct ofw_map translations[128];
static struct ofw_map translations[VM_PHYSSEG_MAX];
static int translations_size;
static vm_offset_t pmap_idle_map;
@ -331,7 +330,7 @@ pmap_bootstrap(u_int cpu_impl)
OF_panic("%s: finddevice /memory", __func__);
if ((sz = OF_getproplen(pmem, "available")) == -1)
OF_panic("%s: getproplen /memory/available", __func__);
if (sizeof(phys_avail) < sz)
if (PHYS_AVAIL_ENTRIES < sz)
OF_panic("%s: phys_avail too small", __func__);
if (sizeof(mra) < sz)
OF_panic("%s: mra too small", __func__);

View File

@ -126,6 +126,11 @@ struct xswdev {
#define KSTACK_MAX_PAGES 32
#endif
#ifndef PHYS_AVAIL_ENTRIES
#define PHYS_AVAIL_ENTRIES (VM_PHYSSEG_MAX * 2)
#endif
#define PHYS_AVAIL_COUNT (PHYS_AVAIL_ENTRIES + 2)
#ifndef ASSEMBLER
#ifdef _KERNEL
#define num_pages(x) \

View File

@ -110,6 +110,24 @@ static struct vm_freelist __aligned(CACHE_LINE_SIZE)
static int __read_mostly vm_nfreelists;
/*
* These "avail lists" are globals used to communicate boot-time physical
* memory layout to other parts of the kernel. Each physically contiguous
* region of memory is defined by a start address at an even index and an
* end address at the following odd index. Each list is terminated by a
* pair of zero entries.
*
* dump_avail tells the dump code what regions to include in a crash dump, and
* phys_avail is all of the remaining physical memory that is available for
* the vm system.
*
* Initially dump_avail and phys_avail are identical. Boot time memory
* allocations remove extents from phys_avail that may still be included
* in dumps.
*/
vm_paddr_t phys_avail[PHYS_AVAIL_COUNT];
vm_paddr_t dump_avail[PHYS_AVAIL_COUNT];
/*
* Provides the mapping from VM_FREELIST_* to free list indices (flind).
*/

View File

@ -46,6 +46,9 @@
#define VM_NFREEORDER_MAX VM_NFREEORDER
#endif
extern vm_paddr_t phys_avail[];
extern vm_paddr_t dump_avail[];
/* Domains must be dense (non-sparse) and zero-based. */
struct mem_affinity {
vm_paddr_t start;

View File

@ -62,8 +62,10 @@ __FBSDID("$FreeBSD$");
#include <sys/interrupt.h>
#include <machine/md_var.h>
#include <machine/vmparam.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_page.h>
#include <vm/vm_phys.h>
#include <vm/pmap.h>
#include <machine/metadata.h>