14Srgrimes/*-
24Srgrimes * Copyright (c) 1990 The Regents of the University of California.
34Srgrimes * All rights reserved.
4974Sdg * Copyright (c) 1994 John S. Dyson
5974Sdg * All rights reserved.
6122296Speter * Copyright (c) 2003 Peter Wemm
7122296Speter * All rights reserved.
84Srgrimes *
94Srgrimes * This code is derived from software contributed to Berkeley by
104Srgrimes * William Jolitz.
114Srgrimes *
124Srgrimes * Redistribution and use in source and binary forms, with or without
134Srgrimes * modification, are permitted provided that the following conditions
144Srgrimes * are met:
154Srgrimes * 1. Redistributions of source code must retain the above copyright
164Srgrimes *    notice, this list of conditions and the following disclaimer.
174Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
184Srgrimes *    notice, this list of conditions and the following disclaimer in the
194Srgrimes *    documentation and/or other materials provided with the distribution.
204Srgrimes * 3. All advertising materials mentioning features or use of this software
214Srgrimes *    must display the following acknowledgement:
224Srgrimes *	This product includes software developed by the University of
234Srgrimes *	California, Berkeley and its contributors.
244Srgrimes * 4. Neither the name of the University nor the names of its contributors
254Srgrimes *    may be used to endorse or promote products derived from this software
264Srgrimes *    without specific prior written permission.
274Srgrimes *
284Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
294Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
304Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
314Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
324Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
334Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
344Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
354Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
364Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
374Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
384Srgrimes * SUCH DAMAGE.
394Srgrimes *
40607Srgrimes *	from: @(#)vmparam.h	5.9 (Berkeley) 5/12/91
4150477Speter * $FreeBSD$
424Srgrimes */
434Srgrimes
444Srgrimes
45719Swollman#ifndef _MACHINE_VMPARAM_H_
46115251Speter#define	_MACHINE_VMPARAM_H_ 1
47719Swollman
484Srgrimes/*
49114349Speter * Machine dependent constants for AMD64.
504Srgrimes */
514Srgrimes
524Srgrimes/*
534Srgrimes * Virtual memory related constants, all in bytes
544Srgrimes */
5536909Sdg#define	MAXTSIZ		(128UL*1024*1024)	/* max text size */
564Srgrimes#ifndef DFLDSIZ
5736909Sdg#define	DFLDSIZ		(128UL*1024*1024)	/* initial data size limit */
584Srgrimes#endif
594Srgrimes#ifndef MAXDSIZ
60136995Speter#define	MAXDSIZ		(32768UL*1024*1024)	/* max data size */
614Srgrimes#endif
624Srgrimes#ifndef	DFLSSIZ
631288Sdg#define	DFLSSIZ		(8UL*1024*1024)		/* initial stack size limit */
644Srgrimes#endif
654Srgrimes#ifndef	MAXSSIZ
66120423Speter#define	MAXSSIZ		(512UL*1024*1024)	/* max stack size */
674Srgrimes#endif
681288Sdg#ifndef SGROWSIZ
69115251Speter#define	SGROWSIZ	(128UL*1024)		/* amount to grow stack */
701288Sdg#endif
714Srgrimes
724Srgrimes/*
73115257Speter * We provide a machine specific single page allocator through the use
74115251Speter * of the direct mapped segment.  This uses 2MB pages for reduced
75115251Speter * TLB pressure.
76115251Speter */
77115251Speter#define	UMA_MD_SMALL_ALLOC
7815472Sphk
794Srgrimes/*
80169291Salc * The physical address space is densely populated.
81169291Salc */
82169291Salc#define	VM_PHYSSEG_DENSE
83169291Salc
84169291Salc/*
85170253Salc * The number of PHYSSEG entries must be one greater than the number
86170253Salc * of phys_avail entries because the phys_avail entry that spans the
87170253Salc * largest physical address that is accessible by ISA DMA is split
88170253Salc * into two PHYSSEG entries.
89170253Salc */
90170253Salc#define	VM_PHYSSEG_MAX		31
91170253Salc
92170253Salc/*
93172317Salc * Create three free page pools: VM_FREEPOOL_DEFAULT is the default pool
94170253Salc * from which physical pages are allocated and VM_FREEPOOL_DIRECT is
95170253Salc * the pool from which physical pages for page tables and small UMA
96170253Salc * objects are allocated.
97170253Salc */
98172317Salc#define	VM_NFREEPOOL		3
99172317Salc#define	VM_FREEPOOL_CACHE	2
100170253Salc#define	VM_FREEPOOL_DEFAULT	0
101170253Salc#define	VM_FREEPOOL_DIRECT	1
102170253Salc
103170253Salc/*
104170253Salc * Create two free page lists: VM_FREELIST_DEFAULT is for physical
105170253Salc * pages that are above the largest physical address that is
106170253Salc * accessible by ISA DMA and VM_FREELIST_ISADMA is for physical pages
107170253Salc * that are below that address.
108170253Salc */
109170253Salc#define	VM_NFREELIST		2
110170253Salc#define	VM_FREELIST_DEFAULT	0
111170253Salc#define	VM_FREELIST_ISADMA	1
112170253Salc
113170253Salc/*
114170253Salc * An allocation size of 16MB is supported in order to optimize the
115170253Salc * use of the direct map by UMA.  Specifically, a cache line contains
116170253Salc * at most 8 PDEs, collectively mapping 16MB of physical memory.  By
117170253Salc * reducing the number of distinct 16MB "pages" that are used by UMA,
118170253Salc * the physical memory allocator reduces the likelihood of both 2MB
119170253Salc * page TLB misses and cache misses caused by 2MB page TLB misses.
120170253Salc */
121170253Salc#define	VM_NFREEORDER		13
122170253Salc
123170253Salc/*
124210550Sjhb * Only one memory domain.
125210550Sjhb */
126210550Sjhb#ifndef VM_NDOMAIN
127210550Sjhb#define	VM_NDOMAIN		1
128210550Sjhb#endif
129210550Sjhb
130210550Sjhb/*
131174938Salc * Enable superpage reservations: 1 level.
132174938Salc */
133174938Salc#ifndef	VM_NRESERVLEVEL
134174938Salc#define	VM_NRESERVLEVEL		1
135174938Salc#endif
136174938Salc
137174938Salc/*
138174938Salc * Level 0 reservations consist of 512 pages.
139174938Salc */
140174938Salc#ifndef	VM_LEVEL_0_ORDER
141174938Salc#define	VM_LEVEL_0_ORDER	9
142174938Salc#endif
143174938Salc
144207410Skmacy#ifdef	SMP
145207410Skmacy#define	PA_LOCK_COUNT	256
146207410Skmacy#endif
147207410Skmacy
148174938Salc/*
14915472Sphk * Virtual addresses of things.  Derived from the page directory and
15015472Sphk * page table indexes from pmap.h for precision.
151180109Salc *
152180109Salc * 0x0000000000000000 - 0x00007fffffffffff   user map
153180109Salc * 0x0000800000000000 - 0xffff7fffffffffff   does not exist (hole)
154180109Salc * 0xffff800000000000 - 0xffff804020100fff   recursive page table (512GB slot)
155215878Salc * 0xffff804020101000 - 0xfffffdffffffffff   unused
156215878Salc * 0xfffffe0000000000 - 0xfffffeffffffffff   1TB direct map
157215878Salc * 0xffffff0000000000 - 0xffffff7fffffffff   unused
158192227Skmacy * 0xffffff8000000000 - 0xffffffffffffffff   512GB kernel map
159180109Salc *
160180109Salc * Within the kernel map:
161180109Salc *
162180109Salc * 0xffffffff80000000                        KERNBASE
1634Srgrimes */
1644Srgrimes
165180101Salc#define	VM_MAX_KERNEL_ADDRESS	KVADDR(KPML4I, NPDPEPG-1, NPDEPG-1, NPTEPG-1)
166192216Skmacy#define	VM_MIN_KERNEL_ADDRESS	KVADDR(KPML4I, NPDPEPG-512, 0, 0)
167974Sdg
168117370Speter#define	DMAP_MIN_ADDRESS	KVADDR(DMPML4I, 0, 0, 0)
169215878Salc#define	DMAP_MAX_ADDRESS	KVADDR(DMPML4I + NDMPML4E, 0, 0, 0)
17015472Sphk
171180373Salc#define	KERNBASE		KVADDR(KPML4I, KPDPI, 0, 0)
17215472Sphk
173117370Speter#define	UPT_MAX_ADDRESS		KVADDR(PML4PML4I, PML4PML4I, PML4PML4I, PML4PML4I)
174117370Speter#define	UPT_MIN_ADDRESS		KVADDR(PML4PML4I, 0, 0, 0)
17515472Sphk
176117370Speter#define	VM_MAXUSER_ADDRESS	UVADDR(NUPML4E, 0, 0, 0)
17715472Sphk
178217151Skib#define	SHAREDPAGE		(VM_MAXUSER_ADDRESS - PAGE_SIZE)
179217151Skib#define	USRSTACK		SHAREDPAGE
1804Srgrimes
181115251Speter#define	VM_MAX_ADDRESS		UPT_MAX_ADDRESS
182115251Speter#define	VM_MIN_ADDRESS		(0)
183115251Speter
184115251Speter#define	PHYS_TO_DMAP(x)		((x) | DMAP_MIN_ADDRESS)
185115251Speter#define	DMAP_TO_PHYS(x)		((x) & ~DMAP_MIN_ADDRESS)
186115251Speter
1874Srgrimes/* virtual sizes (bytes) for various kernel submaps */
18826945Stegge#ifndef VM_KMEM_SIZE
189115251Speter#define	VM_KMEM_SIZE		(12 * 1024 * 1024)
19026945Stegge#endif
1914Srgrimes
19233757Sdyson/*
19333757Sdyson * How many physical pages per KVA page allocated.
194168920Ssepotvin * min(max(max(VM_KMEM_SIZE, Physical memory/VM_KMEM_SIZE_SCALE),
195168920Ssepotvin *     VM_KMEM_SIZE_MIN), VM_KMEM_SIZE_MAX)
19633757Sdyson * is the total KVA space allocated for kmem_map.
19733757Sdyson */
19833757Sdyson#ifndef VM_KMEM_SIZE_SCALE
199212784Savg#define	VM_KMEM_SIZE_SCALE	(1)
20033757Sdyson#endif
20133757Sdyson
20233757Sdyson/*
20333757Sdyson * Ceiling on amount of kmem_map kva space.
20433757Sdyson */
20533757Sdyson#ifndef VM_KMEM_SIZE_MAX
206180210Salc#define	VM_KMEM_SIZE_MAX	((VM_MAX_KERNEL_ADDRESS - \
207180210Salc    VM_MIN_KERNEL_ADDRESS + 1) * 3 / 5)
20833757Sdyson#endif
20933757Sdyson
21033109Sdyson/* initial pagein size of beginning of executable file */
21133109Sdyson#ifndef VM_INITIAL_PAGEIN
21233109Sdyson#define	VM_INITIAL_PAGEIN	16
21333109Sdyson#endif
21433109Sdyson
215221855Smdf#define	ZERO_REGION_SIZE	(2 * 1024 * 1024)	/* 2MB */
216221855Smdf
217719Swollman#endif /* _MACHINE_VMPARAM_H_ */
218