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: releng/10.3/sys/ia64/include/vmparam.h 266204 2014-05-16 01:30:30Z ian $
3966458Sdfr */
4066458Sdfr
41178296Smarcel#ifndef	_MACHINE_VMPARAM_H_
42178296Smarcel#define	_MACHINE_VMPARAM_H_
43178296Smarcel
4466458Sdfr/*
4566458Sdfr * Virtual memory related constants, all in bytes
4666458Sdfr */
4766458Sdfr#ifndef MAXTSIZ
4866458Sdfr#define	MAXTSIZ		(1<<30)			/* max text size (1G) */
4966458Sdfr#endif
5066458Sdfr#ifndef DFLDSIZ
5166458Sdfr#define	DFLDSIZ		(1<<27)			/* initial data size (128M) */
5266458Sdfr#endif
5366458Sdfr#ifndef MAXDSIZ
5466458Sdfr#define	MAXDSIZ		(1<<30)			/* max data size (1G) */
5566458Sdfr#endif
5666458Sdfr#ifndef	DFLSSIZ
5766458Sdfr#define	DFLSSIZ		(1<<21)			/* initial stack size (2M) */
5866458Sdfr#endif
5966458Sdfr#ifndef	MAXSSIZ
6092670Speter#define	MAXSSIZ		(1<<28)			/* max stack size (256M) */
6166458Sdfr#endif
6266458Sdfr#ifndef SGROWSIZ
6366458Sdfr#define SGROWSIZ	(128UL*1024)		/* amount to grow stack */
6466458Sdfr#endif
6566458Sdfr
6666458Sdfr/*
67106486Smarcel * We need region 7 virtual addresses for pagetables.
68106486Smarcel */
69106486Smarcel#define UMA_MD_SMALL_ALLOC
70106486Smarcel
71106486Smarcel/*
72169291Salc * The physical address space is sparsely populated.
73169291Salc */
74169291Salc#define	VM_PHYSSEG_SPARSE
75169291Salc
76169291Salc/*
77170519Salc * The number of PHYSSEG entries is equal to the number of phys_avail
78170519Salc * entries.
79170519Salc */
80170519Salc#define	VM_PHYSSEG_MAX		49
81170519Salc
82170519Salc/*
83172317Salc * Create three free page pools: VM_FREEPOOL_DEFAULT is the default pool
84170519Salc * from which physical pages are allocated and VM_FREEPOOL_DIRECT is
85170519Salc * the pool from which physical pages for small UMA objects are
86170519Salc * allocated.
87170519Salc */
88172317Salc#define	VM_NFREEPOOL		3
89172317Salc#define	VM_FREEPOOL_CACHE	2
90170519Salc#define	VM_FREEPOOL_DEFAULT	0
91170519Salc#define	VM_FREEPOOL_DIRECT	1
92170519Salc
93170519Salc/*
94170519Salc * Create one free page list.
95170519Salc */
96170519Salc#define	VM_NFREELIST		1
97170519Salc#define	VM_FREELIST_DEFAULT	0
98170519Salc
99170519Salc/*
100170519Salc * An allocation size of 256MB is supported in order to optimize the
101170519Salc * use of the identity mappings in region 7 by UMA.
102170519Salc */
103170519Salc#define	VM_NFREEORDER		16
104170519Salc
105170519Salc/*
106174938Salc * Disable superpage reservations.
107174938Salc */
108174938Salc#ifndef	VM_NRESERVLEVEL
109174938Salc#define	VM_NRESERVLEVEL		0
110174938Salc#endif
111174938Salc
112219808Smarcel#define	IA64_VM_MINKERN_REGION	4
113219808Smarcel
114174938Salc/*
11596912Smarcel * Manipulating region bits of an address.
11696912Smarcel */
117208283Smarcel#define IA64_RR_BASE(n)         (((uint64_t) (n)) << 61)
11896912Smarcel#define IA64_RR_MASK(x)         ((x) & ((1L << 61) - 1))
11996912Smarcel
120221271Smarcel#define	IA64_PHYS_TO_RR6(x)	((x) | IA64_RR_BASE(6))
121221271Smarcel#define	IA64_PHYS_TO_RR7(x)	((x) | IA64_RR_BASE(7))
12296912Smarcel
12396912Smarcel/*
124219691Smarcel * The Itanium architecture defines that all implementations support at
125219691Smarcel * least 51 virtual address bits (i.e. IMPL_VA_MSB=50). The unimplemented
126219691Smarcel * bits are sign-extended from VA{IMPL_VA_MSB}. As such, there's a gap in
127219691Smarcel * the virtual address range, which extends at most from 0x0004000000000000
128219691Smarcel * to 0x1ffbffffffffffff. We define the top half of a region in terms of
129219691Smarcel * this worst-case gap.
130219691Smarcel */
131219808Smarcel#define	IA64_REGION_GAP_START	0x0004000000000000
132219808Smarcel#define	IA64_REGION_GAP_EXTEND	0x1ffc000000000000
133219691Smarcel
134219691Smarcel/*
135219691Smarcel * Parameters for Pre-Boot Virtual Memory (PBVM).
136219691Smarcel * The kernel, its modules and metadata are loaded in the PBVM by the loader.
137219691Smarcel * The PBVM consists of pages for which the mapping is maintained in a page
138219691Smarcel * table. The page table is at least 1 EFI page large (i.e. 4KB), but can be
139219691Smarcel * larger to accommodate more PBVM. The maximum page table size is 1MB. With
140219691Smarcel * 8 bytes per page table entry, this means that the PBVM has at least 512
141219691Smarcel * pages and at most 128K pages.
142219691Smarcel * The GNU toolchain (in particular GNU ld) does not support an alignment
143219691Smarcel * larger than 64K. This means that we cannot guarantee page alignment for
144219691Smarcel * a page size that's larger than 64K. We do want to have text and data in
145219691Smarcel * different pages, which means that the maximum usable page size is 64KB.
146219691Smarcel * Consequently:
147219691Smarcel * The maximum total PBVM size is 8GB -- enough for a DVD image. A page table
148219691Smarcel * of a single EFI page (4KB) allows for 32MB of PBVM.
149219691Smarcel *
150219691Smarcel * The kernel is given the PA and size of the page table that provides the
151219691Smarcel * mapping of the PBVM. The page table itself is assumed to be mapped at a
152219691Smarcel * known virtual address and using a single translation wired into the CPU.
153219691Smarcel * As such, the page table is assumed to be a power of 2 and naturally aligned.
154219691Smarcel * The kernel also assumes that a good portion of the kernel text is mapped
155219691Smarcel * and wired into the CPU, but does not assume that the mapping covers the
156219691Smarcel * whole of PBVM.
157219691Smarcel */
158219808Smarcel#define	IA64_PBVM_RR		IA64_VM_MINKERN_REGION
159219691Smarcel#define	IA64_PBVM_BASE		\
160219808Smarcel		(IA64_RR_BASE(IA64_PBVM_RR) + IA64_REGION_GAP_EXTEND)
161219691Smarcel
162219691Smarcel#define	IA64_PBVM_PGTBL_MAXSZ	1048576
163219691Smarcel#define	IA64_PBVM_PGTBL		\
164219691Smarcel		(IA64_RR_BASE(IA64_PBVM_RR + 1) - IA64_PBVM_PGTBL_MAXSZ)
165219691Smarcel
166219691Smarcel#define	IA64_PBVM_PAGE_SHIFT	16	/* 64KB */
167219691Smarcel#define	IA64_PBVM_PAGE_SIZE	(1 << IA64_PBVM_PAGE_SHIFT)
168219691Smarcel#define	IA64_PBVM_PAGE_MASK	(IA64_PBVM_PAGE_SIZE - 1)
169219691Smarcel
170219691Smarcel/*
17166458Sdfr * Mach derived constants
17266458Sdfr */
17366458Sdfr
17466458Sdfr/* user/kernel map constants */
175219808Smarcel#define	VM_MIN_ADDRESS		0
176219808Smarcel#define	VM_MAXUSER_ADDRESS	IA64_RR_BASE(IA64_VM_MINKERN_REGION)
177247251Smarcel#define	VM_MIN_KERNEL_ADDRESS	VM_MAXUSER_ADDRESS
178247251Smarcel#define	VM_INIT_KERNEL_ADDRESS	IA64_RR_BASE(IA64_VM_MINKERN_REGION + 1)
179247251Smarcel#define	VM_MAX_KERNEL_ADDRESS	(IA64_RR_BASE(IA64_VM_MINKERN_REGION + 2) - 1)
180219741Smarcel#define	VM_MAX_ADDRESS		~0UL
18166458Sdfr
182247251Smarcel/* We link the kernel at IA64_PBVM_BASE. */
183247251Smarcel#define	KERNBASE		IA64_PBVM_BASE
18496912Smarcel
185219808Smarcel/*
186219808Smarcel * USRSTACK is the top (end) of the user stack.  Immediately above the user
187219808Smarcel * stack resides the syscall gateway page.
188219808Smarcel */
189219808Smarcel#define	USRSTACK		VM_MAXUSER_ADDRESS
190219808Smarcel#define	IA64_BACKINGSTORE	(USRSTACK - (2 * MAXSSIZ) - PAGE_SIZE)
191219808Smarcel
19266458Sdfr/*
193266204Sian * How many physical pages per kmem arena virtual page.
19466458Sdfr */
19566458Sdfr#ifndef VM_KMEM_SIZE_SCALE
196266204Sian#define	VM_KMEM_SIZE_SCALE	(4)
19766458Sdfr#endif
19866458Sdfr
19966458Sdfr/* initial pagein size of beginning of executable file */
20066458Sdfr#ifndef VM_INITIAL_PAGEIN
20166458Sdfr#define	VM_INITIAL_PAGEIN	16
20266458Sdfr#endif
20366458Sdfr
204221855Smdf#define	ZERO_REGION_SIZE	(2 * 1024 * 1024)	/* 2MB */
205221855Smdf
206178296Smarcel#endif	/* !_MACHINE_VMPARAM_H_ */
207