param.h revision 1.1 1 1.1 ichiro /* $NetBSD: param.h,v 1.1 2001/02/23 03:48:17 ichiro Exp $ */
2 1.1 ichiro
3 1.1 ichiro /*
4 1.1 ichiro * Copyright (c) 1994,1995 Mark Brinicombe.
5 1.1 ichiro * All rights reserved.
6 1.1 ichiro *
7 1.1 ichiro * Redistribution and use in source and binary forms, with or without
8 1.1 ichiro * modification, are permitted provided that the following conditions
9 1.1 ichiro * are met:
10 1.1 ichiro * 1. Redistributions of source code must retain the above copyright
11 1.1 ichiro * notice, this list of conditions and the following disclaimer.
12 1.1 ichiro * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 ichiro * notice, this list of conditions and the following disclaimer in the
14 1.1 ichiro * documentation and/or other materials provided with the distribution.
15 1.1 ichiro * 3. All advertising materials mentioning features or use of this software
16 1.1 ichiro * must display the following acknowledgement:
17 1.1 ichiro * This product includes software developed by the RiscBSD team.
18 1.1 ichiro * 4. The name "RiscBSD" nor the name of the author may be used to
19 1.1 ichiro * endorse or promote products derived from this software without specific
20 1.1 ichiro * prior written permission.
21 1.1 ichiro *
22 1.1 ichiro * THIS SOFTWARE IS PROVIDED BY RISCBSD ``AS IS'' AND ANY EXPRESS OR IMPLIED
23 1.1 ichiro * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 1.1 ichiro * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 1.1 ichiro * IN NO EVENT SHALL RISCBSD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
26 1.1 ichiro * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 1.1 ichiro * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 1.1 ichiro * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 1.1 ichiro * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 1.1 ichiro * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 1.1 ichiro * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 1.1 ichiro * SUCH DAMAGE.
33 1.1 ichiro */
34 1.1 ichiro
35 1.1 ichiro #ifndef _ARM32_PARAM_H_
36 1.1 ichiro #define _ARM32_PARAM_H_
37 1.1 ichiro
38 1.1 ichiro #ifdef _KERNEL
39 1.1 ichiro # include <machine/cpu.h>
40 1.1 ichiro #endif
41 1.1 ichiro
42 1.1 ichiro /*
43 1.1 ichiro * Machine dependent constants for StrongARM processors
44 1.1 ichiro */
45 1.1 ichiro
46 1.1 ichiro #define _MACHINE hpcarm
47 1.1 ichiro #define MACHINE "hpcarm"
48 1.1 ichiro #define _MACHINE_ARCH arm
49 1.1 ichiro #define MACHINE_ARCH "arm"
50 1.1 ichiro #define MID_MACHINE MID_ARM6
51 1.1 ichiro
52 1.1 ichiro /*
53 1.1 ichiro * Round p (pointer or byte index) up to a correctly-aligned value
54 1.1 ichiro * for all data types (int, long, ...). The result is u_int and
55 1.1 ichiro * must be cast to any desired pointer type.
56 1.1 ichiro *
57 1.1 ichiro * ALIGNED_POINTER is a boolean macro that checks whether an address
58 1.1 ichiro * is valid to fetch data elements of type t from on this architecture.
59 1.1 ichiro * This does not reflect the optimal alignment, just the possibility
60 1.1 ichiro * (within reasonable limits).
61 1.1 ichiro *
62 1.1 ichiro */
63 1.1 ichiro #define ALIGNBYTES (sizeof(int) - 1)
64 1.1 ichiro #define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
65 1.1 ichiro #define ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t)-1)) == 0)
66 1.1 ichiro
67 1.1 ichiro #define PGSHIFT 12 /* LOG2(NBPG) */
68 1.1 ichiro #define NBPG (1 << PGSHIFT) /* bytes/page */
69 1.1 ichiro #define PGOFSET (NBPG-1) /* byte offset into page */
70 1.1 ichiro #define NPTEPG (NBPG/(sizeof (pt_entry_t)))
71 1.1 ichiro
72 1.1 ichiro
73 1.1 ichiro #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
74 1.1 ichiro #define DEV_BSIZE (1 << DEV_BSHIFT)
75 1.1 ichiro #define BLKDEV_IOSIZE 2048
76 1.1 ichiro #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */
77 1.1 ichiro
78 1.1 ichiro #define SSIZE 1 /* initial stack size/NBPG */
79 1.1 ichiro #define SINCR 1 /* increment of stack/NBPG */
80 1.1 ichiro #define UPAGES 2 /* pages of u-area */
81 1.1 ichiro #define USPACE (UPAGES * NBPG) /* total size of u-area */
82 1.1 ichiro
83 1.1 ichiro #ifndef MSGBUFSIZE
84 1.1 ichiro #define MSGBUFSIZE NBPG /* default message buffer size */
85 1.1 ichiro #endif
86 1.1 ichiro
87 1.1 ichiro /*
88 1.1 ichiro * Constants related to network buffer management.
89 1.1 ichiro * MCLBYTES must be no larger than NBPG (the software page size), and,
90 1.1 ichiro * on machines that exchange pages of input or output buffers with mbuf
91 1.1 ichiro * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
92 1.1 ichiro * of the hardware page size.
93 1.1 ichiro */
94 1.1 ichiro #define MSIZE 256 /* size of an mbuf */
95 1.1 ichiro #define MCLSHIFT 11 /* convert bytes to m_buf clusters */
96 1.1 ichiro #define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */
97 1.1 ichiro #define MCLOFSET (MCLBYTES - 1) /* offset within a m_buf cluster */
98 1.1 ichiro
99 1.1 ichiro #ifndef NMBCLUSTERS
100 1.1 ichiro
101 1.1 ichiro #if defined(_KERNEL) && !defined(_LKM)
102 1.1 ichiro #include "opt_gateway.h"
103 1.1 ichiro #endif /* _KERNEL && ! _LKM */
104 1.1 ichiro
105 1.1 ichiro #ifdef GATEWAY
106 1.1 ichiro #define NMBCLUSTERS 512 /* map size, max cluster allocation */
107 1.1 ichiro #else
108 1.1 ichiro #define NMBCLUSTERS 256 /* map size, max cluster allocation */
109 1.1 ichiro #endif
110 1.1 ichiro #endif
111 1.1 ichiro
112 1.1 ichiro /*
113 1.1 ichiro * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
114 1.1 ichiro * logical pages.
115 1.1 ichiro */
116 1.1 ichiro #define NKMEMPAGES_MIN_DEFAULT ((6 * 1024 * 1024) >> PAGE_SHIFT)
117 1.1 ichiro #define NKMEMPAGES_MAX_DEFAULT ((7 * 1024 * 1024) >> PAGE_SHIFT)
118 1.1 ichiro
119 1.1 ichiro /* pages ("clicks") (4096 bytes) to disk blocks */
120 1.1 ichiro #define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT))
121 1.1 ichiro #define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT))
122 1.1 ichiro /*#define dtob(x) ((x) << DEV_BSHIFT)*/
123 1.1 ichiro
124 1.1 ichiro #define ctob(x) ((x) << PGSHIFT)
125 1.1 ichiro
126 1.1 ichiro /* bytes to pages */
127 1.1 ichiro #define btoc(x) (((x) + PGOFSET) >> PGSHIFT)
128 1.1 ichiro
129 1.1 ichiro #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \
130 1.1 ichiro ((bytes) >> DEV_BSHIFT)
131 1.1 ichiro #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \
132 1.1 ichiro ((db) << DEV_BSHIFT)
133 1.1 ichiro
134 1.1 ichiro /*
135 1.1 ichiro * Map a ``block device block'' to a file system block.
136 1.1 ichiro * This should be device dependent, and should use the bsize
137 1.1 ichiro * field from the disk label.
138 1.1 ichiro * For now though just use DEV_BSIZE.
139 1.1 ichiro */
140 1.1 ichiro #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE / DEV_BSIZE))
141 1.1 ichiro
142 1.1 ichiro /* Constants used to divide the USPACE area */
143 1.1 ichiro
144 1.1 ichiro /*
145 1.1 ichiro * The USPACE area contains :
146 1.1 ichiro * 1. the user structure for the process
147 1.1 ichiro * 2. the fp context for FP emulation
148 1.1 ichiro * 3. the kernel (svc) stack
149 1.1 ichiro * 4. the undefined instruction stack
150 1.1 ichiro *
151 1.1 ichiro * The layout of the area looks like this
152 1.1 ichiro *
153 1.1 ichiro * | user area | FP context | undefined stack | kernel stack |
154 1.1 ichiro *
155 1.1 ichiro * The size of the user area is known.
156 1.1 ichiro * The size of the FP context is variable depending of the FP emulator
157 1.1 ichiro * in use and whether there is hardware FP support. However we can put
158 1.1 ichiro * an upper limit on it.
159 1.1 ichiro * The undefined stack needs to be at least 512 bytes. This is a requirement
160 1.1 ichiro * if the FP emulators
161 1.1 ichiro * The kernel stack should be at least 4K is size.
162 1.1 ichiro *
163 1.1 ichiro * The stack top addresses are used to set the stack pointers. The stack bottom
164 1.1 ichiro * addresses at the addresses monitored by the diagnostic code for stack overflows
165 1.1 ichiro *
166 1.1 ichiro */
167 1.1 ichiro
168 1.1 ichiro #define FPCONTEXTSIZE (0x100)
169 1.1 ichiro #define USPACE_SVC_STACK_TOP (USPACE)
170 1.1 ichiro #define USPACE_SVC_STACK_BOTTOM (USPACE_SVC_STACK_TOP - 0x1000)
171 1.1 ichiro #define USPACE_UNDEF_STACK_TOP (USPACE_SVC_STACK_BOTTOM - 0x10)
172 1.1 ichiro #define USPACE_UNDEF_STACK_BOTTOM (sizeof(struct user) + FPCONTEXTSIZE + 10)
173 1.1 ichiro
174 1.1 ichiro #define arm_byte_to_page(x) ((x) >> PGSHIFT)
175 1.1 ichiro #define arm_page_to_byte(x) ((x) << PGSHIFT)
176 1.1 ichiro
177 1.1 ichiro #ifdef _KERNEL
178 1.1 ichiro #ifndef _LOCORE
179 1.1 ichiro void delay __P((unsigned));
180 1.1 ichiro #define DELAY(x) delay(x)
181 1.1 ichiro #endif
182 1.1 ichiro #endif
183 1.1 ichiro
184 1.1 ichiro #endif /* _ARM_PARAM_H_ */
185