vmparam.h revision 266204
1118611Snjl/*-
2118611Snjl * Copyright (c) 1988 University of Utah.
3118611Snjl * Copyright (c) 1992, 1993
4118611Snjl *	The Regents of the University of California.  All rights reserved.
5118611Snjl *
6118611Snjl * This code is derived from software contributed to Berkeley by
7217365Sjkim * the Systems Programming Group of the University of Utah Computer
8306536Sjkim * Science Department and Ralph Campbell.
9118611Snjl *
10118611Snjl * Redistribution and use in source and binary forms, with or without
11217365Sjkim * modification, are permitted provided that the following conditions
12217365Sjkim * are met:
13217365Sjkim * 1. Redistributions of source code must retain the above copyright
14217365Sjkim *    notice, this list of conditions and the following disclaimer.
15217365Sjkim * 2. Redistributions in binary form must reproduce the above copyright
16217365Sjkim *    notice, this list of conditions and the following disclaimer in the
17217365Sjkim *    documentation and/or other materials provided with the distribution.
18217365Sjkim * 4. Neither the name of the University nor the names of its contributors
19217365Sjkim *    may be used to endorse or promote products derived from this software
20217365Sjkim *    without specific prior written permission.
21217365Sjkim *
22217365Sjkim * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23217365Sjkim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24217365Sjkim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25118611Snjl * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26217365Sjkim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27217365Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28217365Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29118611Snjl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30217365Sjkim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31217365Sjkim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32217365Sjkim * SUCH DAMAGE.
33217365Sjkim *
34217365Sjkim * from: Utah $Hdr: vmparam.h 1.16 91/01/18$
35217365Sjkim *
36217365Sjkim *	@(#)vmparam.h	8.2 (Berkeley) 4/22/94
37217365Sjkim *
38217365Sjkim * $FreeBSD: stable/10/sys/ia64/include/vmparam.h 266204 2014-05-16 01:30:30Z ian $
39217365Sjkim */
40217365Sjkim
41217365Sjkim#ifndef	_MACHINE_VMPARAM_H_
42217365Sjkim#define	_MACHINE_VMPARAM_H_
43118611Snjl
44151937Sjkim/*
45118611Snjl * Virtual memory related constants, all in bytes
46118611Snjl */
47118611Snjl#ifndef MAXTSIZ
48118611Snjl#define	MAXTSIZ		(1<<30)			/* max text size (1G) */
49118611Snjl#endif
50151937Sjkim#ifndef DFLDSIZ
51118611Snjl#define	DFLDSIZ		(1<<27)			/* initial data size (128M) */
52151937Sjkim#endif
53151937Sjkim#ifndef MAXDSIZ
54151937Sjkim#define	MAXDSIZ		(1<<30)			/* max data size (1G) */
55151937Sjkim#endif
56151937Sjkim#ifndef	DFLSSIZ
57151937Sjkim#define	DFLSSIZ		(1<<21)			/* initial stack size (2M) */
58151937Sjkim#endif
59151937Sjkim#ifndef	MAXSSIZ
60151937Sjkim#define	MAXSSIZ		(1<<28)			/* max stack size (256M) */
61151937Sjkim#endif
62151937Sjkim#ifndef SGROWSIZ
63151937Sjkim#define SGROWSIZ	(128UL*1024)		/* amount to grow stack */
64151937Sjkim#endif
65151937Sjkim
66151937Sjkim/*
67151937Sjkim * We need region 7 virtual addresses for pagetables.
68151937Sjkim */
69151937Sjkim#define UMA_MD_SMALL_ALLOC
70151937Sjkim
71151937Sjkim/*
72151937Sjkim * The physical address space is sparsely populated.
73151937Sjkim */
74151937Sjkim#define	VM_PHYSSEG_SPARSE
75151937Sjkim
76151937Sjkim/*
77151937Sjkim * The number of PHYSSEG entries is equal to the number of phys_avail
78151937Sjkim * entries.
79151937Sjkim */
80151937Sjkim#define	VM_PHYSSEG_MAX		49
81151937Sjkim
82151937Sjkim/*
83151937Sjkim * Create three free page pools: VM_FREEPOOL_DEFAULT is the default pool
84151937Sjkim * from which physical pages are allocated and VM_FREEPOOL_DIRECT is
85151937Sjkim * the pool from which physical pages for small UMA objects are
86151937Sjkim * allocated.
87151937Sjkim */
88151937Sjkim#define	VM_NFREEPOOL		3
89151937Sjkim#define	VM_FREEPOOL_CACHE	2
90118611Snjl#define	VM_FREEPOOL_DEFAULT	0
91118611Snjl#define	VM_FREEPOOL_DIRECT	1
92118611Snjl
93118611Snjl/*
94151937Sjkim * Create one free page list.
95151937Sjkim */
96151937Sjkim#define	VM_NFREELIST		1
97151937Sjkim#define	VM_FREELIST_DEFAULT	0
98118611Snjl
99151937Sjkim/*
100118611Snjl * An allocation size of 256MB is supported in order to optimize the
101241973Sjkim * use of the identity mappings in region 7 by UMA.
102151937Sjkim */
103118611Snjl#define	VM_NFREEORDER		16
104118611Snjl
105118611Snjl/*
106151937Sjkim * Disable superpage reservations.
107118611Snjl */
108151937Sjkim#ifndef	VM_NRESERVLEVEL
109151937Sjkim#define	VM_NRESERVLEVEL		0
110118611Snjl#endif
111118611Snjl
112118611Snjl#define	IA64_VM_MINKERN_REGION	4
113118611Snjl
114306536Sjkim/*
115118611Snjl * Manipulating region bits of an address.
116118611Snjl */
117151937Sjkim#define IA64_RR_BASE(n)         (((uint64_t) (n)) << 61)
118151937Sjkim#define IA64_RR_MASK(x)         ((x) & ((1L << 61) - 1))
119151937Sjkim
120118611Snjl#define	IA64_PHYS_TO_RR6(x)	((x) | IA64_RR_BASE(6))
121118611Snjl#define	IA64_PHYS_TO_RR7(x)	((x) | IA64_RR_BASE(7))
122151937Sjkim
123138287Smarks/*
124151937Sjkim * The Itanium architecture defines that all implementations support at
125138287Smarks * least 51 virtual address bits (i.e. IMPL_VA_MSB=50). The unimplemented
126151937Sjkim * bits are sign-extended from VA{IMPL_VA_MSB}. As such, there's a gap in
127138287Smarks * the virtual address range, which extends at most from 0x0004000000000000
128151937Sjkim * to 0x1ffbffffffffffff. We define the top half of a region in terms of
129138287Smarks * this worst-case gap.
130151937Sjkim */
131138287Smarks#define	IA64_REGION_GAP_START	0x0004000000000000
132306536Sjkim#define	IA64_REGION_GAP_EXTEND	0x1ffc000000000000
133151937Sjkim
134118611Snjl/*
135151937Sjkim * Parameters for Pre-Boot Virtual Memory (PBVM).
136118611Snjl * The kernel, its modules and metadata are loaded in the PBVM by the loader.
137151937Sjkim * The PBVM consists of pages for which the mapping is maintained in a page
138151937Sjkim * table. The page table is at least 1 EFI page large (i.e. 4KB), but can be
139151937Sjkim * larger to accommodate more PBVM. The maximum page table size is 1MB. With
140118611Snjl * 8 bytes per page table entry, this means that the PBVM has at least 512
141151937Sjkim * pages and at most 128K pages.
142118611Snjl * The GNU toolchain (in particular GNU ld) does not support an alignment
143118611Snjl * larger than 64K. This means that we cannot guarantee page alignment for
144118611Snjl * a page size that's larger than 64K. We do want to have text and data in
145118611Snjl * different pages, which means that the maximum usable page size is 64KB.
146118611Snjl * Consequently:
147118611Snjl * The maximum total PBVM size is 8GB -- enough for a DVD image. A page table
148118611Snjl * of a single EFI page (4KB) allows for 32MB of PBVM.
149151937Sjkim *
150118611Snjl * The kernel is given the PA and size of the page table that provides the
151118611Snjl * mapping of the PBVM. The page table itself is assumed to be mapped at a
152118611Snjl * known virtual address and using a single translation wired into the CPU.
153118611Snjl * As such, the page table is assumed to be a power of 2 and naturally aligned.
154118611Snjl * The kernel also assumes that a good portion of the kernel text is mapped
155118611Snjl * and wired into the CPU, but does not assume that the mapping covers the
156118611Snjl * whole of PBVM.
157118611Snjl */
158151937Sjkim#define	IA64_PBVM_RR		IA64_VM_MINKERN_REGION
159118611Snjl#define	IA64_PBVM_BASE		\
160118611Snjl		(IA64_RR_BASE(IA64_PBVM_RR) + IA64_REGION_GAP_EXTEND)
161118611Snjl
162118611Snjl#define	IA64_PBVM_PGTBL_MAXSZ	1048576
163118611Snjl#define	IA64_PBVM_PGTBL		\
164118611Snjl		(IA64_RR_BASE(IA64_PBVM_RR + 1) - IA64_PBVM_PGTBL_MAXSZ)
165118611Snjl
166118611Snjl#define	IA64_PBVM_PAGE_SHIFT	16	/* 64KB */
167118611Snjl#define	IA64_PBVM_PAGE_SIZE	(1 << IA64_PBVM_PAGE_SHIFT)
168118611Snjl#define	IA64_PBVM_PAGE_MASK	(IA64_PBVM_PAGE_SIZE - 1)
169118611Snjl
170118611Snjl/*
171118611Snjl * Mach derived constants
172118611Snjl */
173118611Snjl
174118611Snjl/* user/kernel map constants */
175118611Snjl#define	VM_MIN_ADDRESS		0
176151937Sjkim#define	VM_MAXUSER_ADDRESS	IA64_RR_BASE(IA64_VM_MINKERN_REGION)
177118611Snjl#define	VM_MIN_KERNEL_ADDRESS	VM_MAXUSER_ADDRESS
178118611Snjl#define	VM_INIT_KERNEL_ADDRESS	IA64_RR_BASE(IA64_VM_MINKERN_REGION + 1)
179118611Snjl#define	VM_MAX_KERNEL_ADDRESS	(IA64_RR_BASE(IA64_VM_MINKERN_REGION + 2) - 1)
180118611Snjl#define	VM_MAX_ADDRESS		~0UL
181118611Snjl
182118611Snjl/* We link the kernel at IA64_PBVM_BASE. */
183118611Snjl#define	KERNBASE		IA64_PBVM_BASE
184118611Snjl
185151937Sjkim/*
186118611Snjl * USRSTACK is the top (end) of the user stack.  Immediately above the user
187118611Snjl * stack resides the syscall gateway page.
188118611Snjl */
189118611Snjl#define	USRSTACK		VM_MAXUSER_ADDRESS
190118611Snjl#define	IA64_BACKINGSTORE	(USRSTACK - (2 * MAXSSIZ) - PAGE_SIZE)
191118611Snjl
192118611Snjl/*
193118611Snjl * How many physical pages per kmem arena virtual page.
194118611Snjl */
195118611Snjl#ifndef VM_KMEM_SIZE_SCALE
196118611Snjl#define	VM_KMEM_SIZE_SCALE	(4)
197118611Snjl#endif
198118611Snjl
199118611Snjl/* initial pagein size of beginning of executable file */
200151937Sjkim#ifndef VM_INITIAL_PAGEIN
201118611Snjl#define	VM_INITIAL_PAGEIN	16
202118611Snjl#endif
203118611Snjl
204118611Snjl#define	ZERO_REGION_SIZE	(2 * 1024 * 1024)	/* 2MB */
205118611Snjl
206118611Snjl#endif	/* !_MACHINE_VMPARAM_H_ */
207118611Snjl