xref: /netbsd-src/sys/arch/arm/include/arm32/vmparam.h (revision 1ffa7b76c40339c17a0fb2a09fac93f287cfc046)
1 /*	$NetBSD: vmparam.h,v 1.15 2003/05/02 23:26:47 thorpej Exp $	*/
2 
3 /*
4  * Copyright (c) 2001, 2002 Wasabi Systems, Inc.
5  * All rights reserved.
6  *
7  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *	This product includes software developed for the NetBSD Project by
20  *	Wasabi Systems, Inc.
21  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22  *    or promote products derived from this software without specific prior
23  *    written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
29  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #ifndef _ARM_ARM32_VMPARAM_H_
39 #define	_ARM_ARM32_VMPARAM_H_
40 
41 #ifdef _KERNEL
42 
43 /*
44  * Virtual Memory parameters common to all arm32 platforms.
45  */
46 
47 #include <sys/lock.h>		/* struct simplelock */
48 #include <arm/arm32/pte.h>	/* pt_entry_t */
49 
50 #define	USRSTACK	VM_MAXUSER_ADDRESS
51 
52 /*
53  * Note that MAXTSIZ can't be larger than 32M, otherwise the compiler
54  * would have to be changed to not generate "bl" instructions.
55  */
56 #define	MAXTSIZ		(16*1024*1024)		/* max text size */
57 #ifndef	DFLDSIZ
58 #define	DFLDSIZ		(128*1024*1024)		/* initial data size limit */
59 #endif
60 #ifndef	MAXDSIZ
61 #define	MAXDSIZ		(512*1024*1024)		/* max data size */
62 #endif
63 #ifndef	DFLSSIZ
64 #define	DFLSSIZ		(2*1024*1024)		/* initial stack size limit */
65 #endif
66 #ifndef	MAXSSIZ
67 #define	MAXSSIZ		(8*1024*1024)		/* max stack size */
68 #endif
69 
70 /*
71  * Size of SysV shared memory map
72  */
73 #ifndef SHMMAXPGS
74 #define	SHMMAXPGS	1024
75 #endif
76 
77 /*
78  * While the ARM architecture defines Section mappings, large pages,
79  * and small pages, the standard page size is (and will always be) 4K.
80  */
81 #define	PAGE_SHIFT	12
82 #define	PAGE_SIZE	(1 << PAGE_SHIFT)
83 #define	PAGE_MASK	(PAGE_SIZE - 1)
84 
85 #ifndef ARM32_NEW_VM_LAYOUT
86 #ifdef ARM32_PMAP_NEW
87 /*
88  * Mach derived constants
89  */
90 #define	VM_MIN_ADDRESS		((vaddr_t) 0x00001000)
91 #define	VM_MAXUSER_ADDRESS	((vaddr_t) KERNEL_BASE)
92 #define	VM_MAX_ADDRESS		VM_MAXUSER_ADDRESS
93 #define	VM_MIN_KERNEL_ADDRESS	((vaddr_t) KERNEL_TEXT_BASE)
94 #define	VM_MAX_KERNEL_ADDRESS	((vaddr_t) 0xffffffff)
95 #else /* ! ARM32_PMAP_NEW */
96 /*
97  * Linear page table space: number of PTEs required to map the 4G address
98  * space * size of each PTE.
99  */
100 #define	PAGE_TABLE_SPACE	((1 << (32 - PGSHIFT)) * sizeof(pt_entry_t))
101 
102 /* Address where the page talbles are mapped. */
103 #define	PTE_BASE		(KERNEL_BASE - PAGE_TABLE_SPACE)
104 
105 /*
106  * Mach derived constants
107  */
108 #define	VM_MIN_ADDRESS		((vaddr_t) 0x00001000)
109 #define	VM_MAXUSER_ADDRESS	((vaddr_t) (PTE_BASE - UPAGES * PAGE_SIZE))
110 #define	VM_MAX_ADDRESS		((vaddr_t) (PTE_BASE + \
111 					    (KERNEL_BASE >> PGSHIFT) * \
112 					    sizeof(pt_entry_t)))
113 #define	VM_MIN_KERNEL_ADDRESS	((vaddr_t) KERNEL_TEXT_BASE)
114 #define	VM_MAX_KERNEL_ADDRESS	((vaddr_t) 0xffffffff)
115 #endif /* ARM32_PMAP_NEW */
116 
117 #else /* ARM32_NEW_VM_LAYOUT */
118 /*
119  * New VM layout
120  */
121 #define	VM_MIN_ADDRESS		((vaddr_t) 0x00001000)
122 #define	VM_MAXUSER_ADDRESS	((vaddr_t) KERNEL_BASE)
123 #define	VM_MAX_ADDRESS		VM_MAXUSER_ADDRESS
124 
125 #define	VM_MIN_KERNEL_ADDRESS	((vaddr_t) KERNEL_BASE)
126 #define	VM_MAX_KERNEL_ADDRESS	((vaddr_t) 0xffffffff)
127 #endif	/* ARM32_NEW_VM_LAYOUT */
128 
129 /*
130  * pmap-specific data store in the vm_page structure.
131  */
132 #define	__HAVE_VM_PAGE_MD
133 struct vm_page_md {
134 	struct pv_entry *pvh_list;		/* pv_entry list */
135 	struct simplelock pvh_slock;		/* lock on this head */
136 	int pvh_attrs;				/* page attributes */
137 #ifndef ARM32_PMAP_NEW
138 #ifdef PMAP_ALIAS_DEBUG
139 	u_int ro_mappings;
140 	u_int rw_mappings;
141 	u_int kro_mappings;
142 	u_int krw_mappings;
143 #endif /* PMAP_ALIAS_DEBUG */
144 #else  /* ARM32_PMAP_NEW */
145 	u_int uro_mappings;
146 	u_int urw_mappings;
147 	union {
148 		u_short s_mappings[2];	/* Assume kernel count <= 65535 */
149 		u_int i_mappings;
150 	} k_u;
151 #define	kro_mappings	k_u.s_mappings[0]
152 #define	krw_mappings	k_u.s_mappings[1]
153 #define	k_mappings	k_u.i_mappings
154 #endif
155 };
156 
157 #ifndef ARM32_PMAP_NEW
158 #define	VM_MDPAGE_INIT(pg)						\
159 do {									\
160 	(pg)->mdpage.pvh_list = NULL;					\
161 	simple_lock_init(&(pg)->mdpage.pvh_slock);			\
162 	(pg)->mdpage.pvh_attrs = 0;					\
163 } while (/*CONSTCOND*/0)
164 #else
165 #define	VM_MDPAGE_INIT(pg)						\
166 do {									\
167 	(pg)->mdpage.pvh_list = NULL;					\
168 	simple_lock_init(&(pg)->mdpage.pvh_slock);			\
169 	(pg)->mdpage.pvh_attrs = 0;					\
170 	(pg)->mdpage.uro_mappings = 0;					\
171 	(pg)->mdpage.urw_mappings = 0;					\
172 	(pg)->mdpage.k_mappings = 0;					\
173 } while (/*CONSTCOND*/0)
174 #endif
175 
176 #endif /* _KERNEL */
177 
178 #endif /* _ARM_ARM32_VMPARAM_H_ */
179