xref: /netbsd-src/sys/arch/arm/include/arm32/vmparam.h (revision 404fbe5fb94ca1e054339640cabb2801ce52dd30)
1 /*	$NetBSD: vmparam.h,v 1.23 2008/08/06 19:13:45 matt 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 #ifndef __ASSEMBLER__
48 #include <sys/simplelock.h>	/* struct simplelock */
49 #endif /* __ASSEMBLER__ */
50 #include <arm/arm32/pte.h>	/* pt_entry_t */
51 
52 #define	USRSTACK	VM_MAXUSER_ADDRESS
53 
54 /*
55  * Note that MAXTSIZ can't be larger than 32M, otherwise the compiler
56  * would have to be changed to not generate "bl" instructions.
57  */
58 #define	MAXTSIZ		(16*1024*1024)		/* max text size */
59 #ifndef	DFLDSIZ
60 #define	DFLDSIZ		(128*1024*1024)		/* initial data size limit */
61 #endif
62 #ifndef	MAXDSIZ
63 #define	MAXDSIZ		(512*1024*1024)		/* max data size */
64 #endif
65 #ifndef	DFLSSIZ
66 #define	DFLSSIZ		(2*1024*1024)		/* initial stack size limit */
67 #endif
68 #ifndef	MAXSSIZ
69 #define	MAXSSIZ		(8*1024*1024)		/* max stack size */
70 #endif
71 
72 /*
73  * Size of SysV shared memory map
74  */
75 #ifndef SHMMAXPGS
76 #define	SHMMAXPGS	1024
77 #endif
78 
79 /*
80  * While the ARM architecture defines Section mappings, large pages,
81  * and small pages, the standard page size is (and will always be) 4K.
82  */
83 #define	PAGE_SHIFT	12
84 #define	PAGE_SIZE	(1 << PAGE_SHIFT)
85 #define	PAGE_MASK	(PAGE_SIZE - 1)
86 
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 
94 #define	VM_MIN_KERNEL_ADDRESS	((vaddr_t) KERNEL_BASE)
95 #define	VM_MAX_KERNEL_ADDRESS	((vaddr_t) 0xffffffff)
96 
97 #ifndef __ASSEMBLER__
98 /* XXX max. amount of KVM to be used by buffers. */
99 #ifndef VM_MAX_KERNEL_BUF
100 extern vaddr_t virtual_avail;
101 extern vaddr_t virtual_end;
102 
103 #define	VM_MAX_KERNEL_BUF	\
104 	((virtual_end - virtual_avail) * 4 / 10)
105 #endif
106 
107 /*
108  * pmap-specific data store in the vm_page structure.
109  */
110 #define	__HAVE_VM_PAGE_MD
111 struct vm_page_md {
112 	SLIST_HEAD(,pv_entry) pvh_list;		/* pv_entry list */
113 	struct simplelock pvh_slock;		/* lock on this head */
114 	int pvh_attrs;				/* page attributes */
115 	u_int uro_mappings;
116 	u_int urw_mappings;
117 	union {
118 		u_short s_mappings[2];	/* Assume kernel count <= 65535 */
119 		u_int i_mappings;
120 	} k_u;
121 #define	kro_mappings	k_u.s_mappings[0]
122 #define	krw_mappings	k_u.s_mappings[1]
123 #define	k_mappings	k_u.i_mappings
124 };
125 
126 /*
127  * Set the default color of each page.
128  */
129 #if ARM_MMU_V6 > 0
130 #define	VM_MDPAGE_PVH_ATTRS_INIT(pg) \
131 	(pg)->mdpage.pvh_attrs = (pg)->phys_addr & arm_cache_prefer_mask
132 #else
133 #define	VM_MDPAGE_PVH_ATTRS_INIT(pg) \
134 	(pg)->mdpage.pvh_attrs = 0
135 #endif
136 
137 
138 #define	VM_MDPAGE_INIT(pg)						\
139 do {									\
140 	SLIST_INIT(&(pg)->mdpage.pvh_list);				\
141 	simple_lock_init(&(pg)->mdpage.pvh_slock);			\
142 	VM_MDPAGE_PVH_ATTRS_INIT(pg);					\
143 	(pg)->mdpage.uro_mappings = 0;					\
144 	(pg)->mdpage.urw_mappings = 0;					\
145 	(pg)->mdpage.k_mappings = 0;					\
146 } while (/*CONSTCOND*/0)
147 #endif /* __ASSEMBLER__ */
148 
149 #endif /* _KERNEL */
150 
151 #endif /* _ARM_ARM32_VMPARAM_H_ */
152