vmparam.h revision 219741
1139790Simp/*-
266458Sdfr * Copyright (c) 1988 University of Utah.
366458Sdfr * Copyright (c) 1992, 1993
466458Sdfr *	The Regents of the University of California.  All rights reserved.
566458Sdfr *
666458Sdfr * This code is derived from software contributed to Berkeley by
766458Sdfr * the Systems Programming Group of the University of Utah Computer
866458Sdfr * Science Department and Ralph Campbell.
966458Sdfr *
1066458Sdfr * Redistribution and use in source and binary forms, with or without
1166458Sdfr * modification, are permitted provided that the following conditions
1266458Sdfr * are met:
1366458Sdfr * 1. Redistributions of source code must retain the above copyright
1466458Sdfr *    notice, this list of conditions and the following disclaimer.
1566458Sdfr * 2. Redistributions in binary form must reproduce the above copyright
1666458Sdfr *    notice, this list of conditions and the following disclaimer in the
1766458Sdfr *    documentation and/or other materials provided with the distribution.
1866458Sdfr * 4. Neither the name of the University nor the names of its contributors
1966458Sdfr *    may be used to endorse or promote products derived from this software
2066458Sdfr *    without specific prior written permission.
2166458Sdfr *
2266458Sdfr * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2366458Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2466458Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2566458Sdfr * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2666458Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2766458Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2866458Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2966458Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3066458Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3166458Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3266458Sdfr * SUCH DAMAGE.
3366458Sdfr *
3466458Sdfr * from: Utah $Hdr: vmparam.h 1.16 91/01/18$
3566458Sdfr *
3666458Sdfr *	@(#)vmparam.h	8.2 (Berkeley) 4/22/94
37178296Smarcel *
38178296Smarcel * $FreeBSD: head/sys/ia64/include/vmparam.h 219741 2011-03-18 15:36:28Z marcel $
3966458Sdfr */
4066458Sdfr
41178296Smarcel#ifndef	_MACHINE_VMPARAM_H_
42178296Smarcel#define	_MACHINE_VMPARAM_H_
43178296Smarcel
4466458Sdfr/*
45170033Salc * USRSTACK is the top (end) of the user stack.  Immediately above the user
46170033Salc * stack resides the syscall gateway page.
4766458Sdfr */
48219741Smarcel#define	USRSTACK	VM_MAXUSER_ADDRESS
4966458Sdfr
5066458Sdfr/*
5166458Sdfr * Virtual memory related constants, all in bytes
5266458Sdfr */
5366458Sdfr#ifndef MAXTSIZ
5466458Sdfr#define	MAXTSIZ		(1<<30)			/* max text size (1G) */
5566458Sdfr#endif
5666458Sdfr#ifndef DFLDSIZ
5766458Sdfr#define	DFLDSIZ		(1<<27)			/* initial data size (128M) */
5866458Sdfr#endif
5966458Sdfr#ifndef MAXDSIZ
6066458Sdfr#define	MAXDSIZ		(1<<30)			/* max data size (1G) */
6166458Sdfr#endif
6266458Sdfr#ifndef	DFLSSIZ
6366458Sdfr#define	DFLSSIZ		(1<<21)			/* initial stack size (2M) */
6466458Sdfr#endif
6566458Sdfr#ifndef	MAXSSIZ
6692670Speter#define	MAXSSIZ		(1<<28)			/* max stack size (256M) */
6766458Sdfr#endif
6866458Sdfr#ifndef SGROWSIZ
6966458Sdfr#define SGROWSIZ	(128UL*1024)		/* amount to grow stack */
7066458Sdfr#endif
7166458Sdfr
7266458Sdfr/*
73106486Smarcel * We need region 7 virtual addresses for pagetables.
74106486Smarcel */
75106486Smarcel#define UMA_MD_SMALL_ALLOC
76106486Smarcel
77106486Smarcel/*
78169291Salc * The physical address space is sparsely populated.
79169291Salc */
80169291Salc#define	VM_PHYSSEG_SPARSE
81169291Salc
82169291Salc/*
83170519Salc * The number of PHYSSEG entries is equal to the number of phys_avail
84170519Salc * entries.
85170519Salc */
86170519Salc#define	VM_PHYSSEG_MAX		49
87170519Salc
88170519Salc/*
89172317Salc * Create three free page pools: VM_FREEPOOL_DEFAULT is the default pool
90170519Salc * from which physical pages are allocated and VM_FREEPOOL_DIRECT is
91170519Salc * the pool from which physical pages for small UMA objects are
92170519Salc * allocated.
93170519Salc */
94172317Salc#define	VM_NFREEPOOL		3
95172317Salc#define	VM_FREEPOOL_CACHE	2
96170519Salc#define	VM_FREEPOOL_DEFAULT	0
97170519Salc#define	VM_FREEPOOL_DIRECT	1
98170519Salc
99170519Salc/*
100170519Salc * Create one free page list.
101170519Salc */
102170519Salc#define	VM_NFREELIST		1
103170519Salc#define	VM_FREELIST_DEFAULT	0
104170519Salc
105170519Salc/*
106170519Salc * An allocation size of 256MB is supported in order to optimize the
107170519Salc * use of the identity mappings in region 7 by UMA.
108170519Salc */
109170519Salc#define	VM_NFREEORDER		16
110170519Salc
111170519Salc/*
112210550Sjhb * Only one memory domain.
113210550Sjhb */
114210550Sjhb#ifndef VM_NDOMAIN
115210550Sjhb#define	VM_NDOMAIN		1
116210550Sjhb#endif
117210550Sjhb
118210550Sjhb/*
119174938Salc * Disable superpage reservations.
120174938Salc */
121174938Salc#ifndef	VM_NRESERVLEVEL
122174938Salc#define	VM_NRESERVLEVEL		0
123174938Salc#endif
124174938Salc
125174938Salc/*
12696912Smarcel * Manipulating region bits of an address.
12796912Smarcel */
128208283Smarcel#define IA64_RR_BASE(n)         (((uint64_t) (n)) << 61)
12996912Smarcel#define IA64_RR_MASK(x)         ((x) & ((1L << 61) - 1))
13096912Smarcel
13196912Smarcel#define IA64_PHYS_TO_RR7(x)     ((x) | IA64_RR_BASE(7))
13296912Smarcel
13396912Smarcel/*
134219691Smarcel * The Itanium architecture defines that all implementations support at
135219691Smarcel * least 51 virtual address bits (i.e. IMPL_VA_MSB=50). The unimplemented
136219691Smarcel * bits are sign-extended from VA{IMPL_VA_MSB}. As such, there's a gap in
137219691Smarcel * the virtual address range, which extends at most from 0x0004000000000000
138219691Smarcel * to 0x1ffbffffffffffff. We define the top half of a region in terms of
139219691Smarcel * this worst-case gap.
140219691Smarcel */
141219691Smarcel#define	IA64_REGION_TOP_HALF	0x1ffc000000000000
142219691Smarcel
143219691Smarcel/*
144119906Smarcel * Page size of the identity mappings in region 7.
145119906Smarcel */
146119906Smarcel#ifndef LOG2_ID_PAGE_SIZE
147119906Smarcel#define	LOG2_ID_PAGE_SIZE	28		/* 256M */
148119906Smarcel#endif
149119906Smarcel
150119906Smarcel#define	IA64_ID_PAGE_SHIFT	(LOG2_ID_PAGE_SIZE)
151119906Smarcel#define	IA64_ID_PAGE_SIZE	(1<<(LOG2_ID_PAGE_SIZE))
152119906Smarcel#define	IA64_ID_PAGE_MASK	(IA64_ID_PAGE_SIZE-1)
153119906Smarcel
154121268Smarcel#define	IA64_BACKINGSTORE	IA64_RR_BASE(4)
155121268Smarcel
156119906Smarcel/*
157219691Smarcel * Parameters for Pre-Boot Virtual Memory (PBVM).
158219691Smarcel * The kernel, its modules and metadata are loaded in the PBVM by the loader.
159219691Smarcel * The PBVM consists of pages for which the mapping is maintained in a page
160219691Smarcel * table. The page table is at least 1 EFI page large (i.e. 4KB), but can be
161219691Smarcel * larger to accommodate more PBVM. The maximum page table size is 1MB. With
162219691Smarcel * 8 bytes per page table entry, this means that the PBVM has at least 512
163219691Smarcel * pages and at most 128K pages.
164219691Smarcel * The GNU toolchain (in particular GNU ld) does not support an alignment
165219691Smarcel * larger than 64K. This means that we cannot guarantee page alignment for
166219691Smarcel * a page size that's larger than 64K. We do want to have text and data in
167219691Smarcel * different pages, which means that the maximum usable page size is 64KB.
168219691Smarcel * Consequently:
169219691Smarcel * The maximum total PBVM size is 8GB -- enough for a DVD image. A page table
170219691Smarcel * of a single EFI page (4KB) allows for 32MB of PBVM.
171219691Smarcel *
172219691Smarcel * The kernel is given the PA and size of the page table that provides the
173219691Smarcel * mapping of the PBVM. The page table itself is assumed to be mapped at a
174219691Smarcel * known virtual address and using a single translation wired into the CPU.
175219691Smarcel * As such, the page table is assumed to be a power of 2 and naturally aligned.
176219691Smarcel * The kernel also assumes that a good portion of the kernel text is mapped
177219691Smarcel * and wired into the CPU, but does not assume that the mapping covers the
178219691Smarcel * whole of PBVM.
179219691Smarcel */
180219691Smarcel#define	IA64_PBVM_RR		4
181219691Smarcel#define	IA64_PBVM_BASE		\
182219691Smarcel		(IA64_RR_BASE(IA64_PBVM_RR) + IA64_REGION_TOP_HALF)
183219691Smarcel
184219691Smarcel#define	IA64_PBVM_PGTBL_MAXSZ	1048576
185219691Smarcel#define	IA64_PBVM_PGTBL		\
186219691Smarcel		(IA64_RR_BASE(IA64_PBVM_RR + 1) - IA64_PBVM_PGTBL_MAXSZ)
187219691Smarcel
188219691Smarcel#define	IA64_PBVM_PAGE_SHIFT	16	/* 64KB */
189219691Smarcel#define	IA64_PBVM_PAGE_SIZE	(1 << IA64_PBVM_PAGE_SHIFT)
190219691Smarcel#define	IA64_PBVM_PAGE_MASK	(IA64_PBVM_PAGE_SIZE - 1)
191219691Smarcel
192219691Smarcel/*
19366458Sdfr * Mach derived constants
19466458Sdfr */
19566458Sdfr
19666458Sdfr/* user/kernel map constants */
19766458Sdfr#define VM_MIN_ADDRESS		0
198219741Smarcel#define	VM_MAXUSER_ADDRESS	IA64_RR_BASE(5)
199115084Smarcel#define	VM_GATEWAY_SIZE		PAGE_SIZE
200219741Smarcel#define	VM_MIN_KERNEL_ADDRESS	(VM_MAXUSER_ADDRESS + VM_GATEWAY_SIZE)
20166458Sdfr#define VM_MAX_KERNEL_ADDRESS	(IA64_RR_BASE(6) - 1)
202219741Smarcel#define	VM_MAX_ADDRESS		~0UL
20366458Sdfr
204219741Smarcel#define	KERNBASE		VM_MAXUSER_ADDRESS
20596912Smarcel
20666458Sdfr/* virtual sizes (bytes) for various kernel submaps */
20766458Sdfr#ifndef VM_KMEM_SIZE
20866458Sdfr#define VM_KMEM_SIZE		(12 * 1024 * 1024)
20966458Sdfr#endif
21066458Sdfr
21166458Sdfr/*
21266458Sdfr * How many physical pages per KVA page allocated.
213168920Ssepotvin * min(max(max(VM_KMEM_SIZE, Physical memory/VM_KMEM_SIZE_SCALE),
214168920Ssepotvin *     VM_KMEM_SIZE_MIN), VM_KMEM_SIZE_MAX)
21566458Sdfr * is the total KVA space allocated for kmem_map.
21666458Sdfr */
21766458Sdfr#ifndef VM_KMEM_SIZE_SCALE
21866458Sdfr#define	VM_KMEM_SIZE_SCALE	(4) /* XXX 8192 byte pages */
21966458Sdfr#endif
22066458Sdfr
22166458Sdfr/* initial pagein size of beginning of executable file */
22266458Sdfr#ifndef VM_INITIAL_PAGEIN
22366458Sdfr#define	VM_INITIAL_PAGEIN	16
22466458Sdfr#endif
22566458Sdfr
226178296Smarcel#endif	/* !_MACHINE_VMPARAM_H_ */
227