xref: /netbsd-src/sys/arch/ia64/include/vmparam.h (revision f9ac86e62634e8fe296f268c518a7f351b2d99c2)
1 /*	$NetBSD: vmparam.h,v 1.12 2023/10/06 11:45:37 skrll Exp $	*/
2 
3 /*-
4  * Copyright (c) 1990 The Regents of the University of California.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to Berkeley by
8  * William Jolitz.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. Neither the name of the University nor the names of its contributors
19  *    may be used to endorse or promote products derived from this software
20  *    without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  *
34  *	@(#)vmparam.h	5.9 (Berkeley) 5/12/91
35  */
36 
37 #ifndef _VMPARAM_H_
38 #define _VMPARAM_H_
39 
40 #define	USRSTACK	VM_MAX_ADDRESS /* XXX: Revisit vm address space. */
41 
42 /*
43  * Virtual memory related constants, all in bytes
44  */
45 #ifndef MAXTSIZ
46 #define	MAXTSIZ		(1<<30)			/* max text size (1G) */
47 #endif
48 #ifndef DFLDSIZ
49 #define	DFLDSIZ		(1<<27)			/* initial data size (128M) */
50 #endif
51 #ifndef MAXDSIZ
52 #define	MAXDSIZ		(1<<30)			/* max data size (1G) */
53 #endif
54 #ifndef	DFLSSIZ
55 #define	DFLSSIZ		(1<<21)			/* initial stack size (2M) */
56 #endif
57 #ifndef	MAXSSIZ
58 #define	MAXSSIZ		(1<<28)			/* max stack size (256M) */
59 #endif
60 
61 #define	IA64_VM_MINKERN_REGION	4
62 
63 /*
64  * PTEs for mapping user space into the kernel for phyio operations.
65  * 64 pte's are enough to cover 8 disks * MAXBSIZE.
66  */
67 #ifndef USRIOSIZE
68 #define USRIOSIZE	64
69 #endif
70 
71 /*
72  * Manipulating region bits of an address.
73  */
74 #define IA64_RR_BASE(n)         (((uint64_t) (n)) << 61)
75 #define IA64_RR_MASK(x)         ((x) & ((1L << 61) - 1))
76 
77 #define IA64_PHYS_TO_RR6(x)     ((x) | IA64_RR_BASE(6))
78 #define IA64_PHYS_TO_RR7(x)     ((x) | IA64_RR_BASE(7))
79 
80 /*
81  * The Itanium architecture defines that all implementations support at
82  * least 51 virtual address bits (i.e. IMPL_VA_MSB=50). The unimplemented
83  * bits are sign-extended from VA{IMPL_VA_MSB}. As such, there's a gap in
84  * the virtual address range, which extends at most from 0x0004000000000000
85  * to 0x1ffbffffffffffff. We define the top half of a region in terms of
86  * this worst-case gap.
87  */
88 #define IA64_REGION_GAP_START   0x0004000000000000
89 #define IA64_REGION_GAP_EXTEND  0x1ffc000000000000
90 
91 /*
92  * Parameters for Pre-Boot Virtual Memory (PBVM).
93  * The kernel, its modules and metadata are loaded in the PBVM by the loader.
94  * The PBVM consists of pages for which the mapping is maintained in a page
95  * table. The page table is at least 1 EFI page large (i.e. 4KB), but can be
96  * larger to accommodate more PBVM. The maximum page table size is 1MB. With
97  * 8 bytes per page table entry, this means that the PBVM has at least 512
98  * pages and at most 128K pages.
99  * The GNU toolchain (in particular GNU ld) does not support an alignment
100  * larger than 64K. This means that we cannot guarantee page alignment for
101  * a page size that's larger than 64K. We do want to have text and data in
102  * different pages, which means that the maximum usable page size is 64KB.
103  * Consequently:
104  * The maximum total PBVM size is 8GB -- enough for a DVD image. A page table
105  * of a single EFI page (4KB) allows for 32MB of PBVM.
106  *
107  * The kernel is given the PA and size of the page table that provides the
108  * mapping of the PBVM. The page table itself is assumed to be mapped at a
109  * known virtual address and using a single translation wired into the CPU.
110  * As such, the page table is assumed to be a power of 2 and naturally aligned.
111  * The kernel also assumes that a good portion of the kernel text is mapped
112  * and wired into the CPU, but does not assume that the mapping covers the
113  * whole of PBVM.
114  */
115 #define IA64_PBVM_RR            IA64_VM_MINKERN_REGION
116 #define IA64_PBVM_BASE          \
117                 (IA64_RR_BASE(IA64_PBVM_RR) + IA64_REGION_GAP_EXTEND)
118 
119 #define IA64_PBVM_PGTBL_MAXSZ   1048576
120 #define IA64_PBVM_PGTBL         \
121                 (IA64_RR_BASE(IA64_PBVM_RR + 1) - IA64_PBVM_PGTBL_MAXSZ)
122 
123 #define IA64_PBVM_PAGE_SHIFT    16      /* 64KB */
124 #define IA64_PBVM_PAGE_SIZE     (1 << IA64_PBVM_PAGE_SHIFT)
125 #define IA64_PBVM_PAGE_MASK     (IA64_PBVM_PAGE_SIZE - 1)
126 
127 #define	IA64_ID_PAGE_SHIFT	28		/* 256M */
128 #define	IA64_ID_PAGE_SIZE	(1 << IA64_ID_PAGE_SHIFT)
129 #define	IA64_ID_PAGE_MASK	(IA64_ID_PAGE_SIZE-1)
130 
131 /* XXX freebsd uses
132 #define IA64_BACKINGSTORE       (USRSTACK - (2 * MAXSSIZ) - PAGE_SIZE)
133 */
134 #define	IA64_BACKINGSTORE	IA64_RR_BASE(4)
135 
136 #define	PAGE_SHIFT	14		/* 16K pages by default. */
137 #define	PAGE_SIZE	(1 << PAGE_SHIFT)
138 #define	PAGE_MASK	(PAGE_SIZE - 1)
139 
140 /* user/kernel map constants */
141 #define VM_MIN_ADDRESS		((vaddr_t)0)
142 #define	VM_MAX_ADDRESS		((vaddr_t) IA64_RR_BASE(5))
143 #define	VM_GATEWAY_SIZE		PAGE_SIZE
144 #define	VM_MAXUSER_ADDRESS	(VM_MAX_ADDRESS + VM_GATEWAY_SIZE)
145 #define	VM_MIN_KERNEL_ADDRESS	VM_MAXUSER_ADDRESS
146 #define VM_INIT_KERNEL_ADDRESS  IA64_RR_BASE(IA64_VM_MINKERN_REGION + 1)
147 #define VM_MAX_KERNEL_ADDRESS	((vaddr_t) (IA64_RR_BASE(6) - 1))
148 
149 #define VM_PHYSSEG_MAX		16		/* XXX: */
150 #define VM_PHYSSEG_STRAT	VM_PSTRAT_BSEARCH
151 
152 #define	VM_NFREELIST		1 /* XXX: */
153 #define	VM_FREELIST_DEFAULT	0 /* XXX: */
154 
155 /* virtual sizes (bytes) for various kernel submaps */
156 #define VM_PHYS_SIZE		(USRIOSIZE*PAGE_SIZE)
157 
158 #endif /* _VMPARAM_H_ */
159