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