Annotation of sys/arch/sparc/include/param.h, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: param.h,v 1.39 2007/05/28 21:02:49 thib Exp $ */
2: /* $NetBSD: param.h,v 1.29 1997/03/10 22:50:37 pk Exp $ */
3:
4: /*
5: * Copyright (c) 1992, 1993
6: * The Regents of the University of California. All rights reserved.
7: *
8: * This software was developed by the Computer Systems Engineering group
9: * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
10: * contributed to Berkeley.
11: *
12: * All advertising materials mentioning features or use of this software
13: * must display the following acknowledgement:
14: * This product includes software developed by the University of
15: * California, Lawrence Berkeley Laboratory.
16: *
17: * Redistribution and use in source and binary forms, with or without
18: * modification, are permitted provided that the following conditions
19: * are met:
20: * 1. Redistributions of source code must retain the above copyright
21: * notice, this list of conditions and the following disclaimer.
22: * 2. Redistributions in binary form must reproduce the above copyright
23: * notice, this list of conditions and the following disclaimer in the
24: * documentation and/or other materials provided with the distribution.
25: * 3. Neither the name of the University nor the names of its contributors
26: * may be used to endorse or promote products derived from this software
27: * without specific prior written permission.
28: *
29: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39: * SUCH DAMAGE.
40: *
41: * @(#)param.h 8.1 (Berkeley) 6/11/93
42: */
43:
44: #ifndef _SPARC_PARAM_H_
45: #define _SPARC_PARAM_H_
46:
47: /*
48: * Sun4M support by Aaron Brown, Harvard University.
49: * Changes Copyright (c) 1995 The President and Fellows of Harvard College.
50: * All rights reserved.
51: */
52: #define _MACHINE sparc
53: #define MACHINE "sparc"
54: #define _MACHINE_ARCH sparc
55: #define MACHINE_ARCH "sparc"
56: #define MID_MACHINE MID_SPARC
57:
58: #ifdef _KERNEL /* XXX */
59: #ifndef _LOCORE /* XXX */
60: #include <machine/cpu.h> /* XXX */
61: #endif /* XXX */
62: #endif /* XXX */
63:
64: /*
65: * Round p (pointer or byte index) up to a correctly-aligned value for
66: * the machine's strictest data type. The result is u_int and must be
67: * cast to any desired pointer type.
68: *
69: * ALIGNED_POINTER is a boolean macro that checks whether an address
70: * is valid to fetch data elements of type t from on this architecture.
71: * This does not reflect the optimal alignment, just the possibility
72: * (within reasonable limits).
73: *
74: */
75: #define ALIGNBYTES 7
76: #define ALIGN(p) (((u_int)(p) + ALIGNBYTES) & ~ALIGNBYTES)
77: #define ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t)-1)) == 0)
78:
79: #define SUN4_PGSHIFT 13 /* for a sun4 machine */
80: #define SUN4CM_PGSHIFT 12 /* for a sun4c or sun4m machine */
81:
82: #define KERNBASE 0xf8000000 /* start of kernel virtual space */
83: #define KERNTEXTOFF 0xf8004000 /* start of kernel text */
84:
85: #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
86: #define DEV_BSIZE (1 << DEV_BSHIFT)
87: #define BLKDEV_IOSIZE 2048
88: #define MAXPHYS (64 * 1024)
89:
90: #define USPACE 8192
91: #define USPACE_ALIGN (0) /* u-area alignment 0-none */
92:
93: /*
94: * Constants related to network buffer management.
95: */
96: #define NMBCLUSTERS 2048 /* map size, max cluster allocation */
97:
98: #define MSGBUFSIZE 4096 /* cannot be changed without great pain */
99:
100: /*
101: * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
102: * logical pages.
103: */
104: #define NKMEMPAGES_MIN_DEFAULT ((4 * 1024 * 1024) >> PAGE_SHIFT)
105: #define NKMEMPAGES_MAX_DEFAULT ((4 * 1024 * 1024) >> PAGE_SHIFT)
106:
107: /* pages ("clicks") to disk blocks */
108: #define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT))
109: #define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT))
110:
111: /* pages to bytes */
112: #define ctob(x) ((x) << PGSHIFT)
113: #define btoc(x) (((x) + PGOFSET) >> PGSHIFT)
114:
115: /* bytes to disk blocks */
116: #define btodb(x) ((x) >> DEV_BSHIFT)
117: #define dbtob(x) ((x) << DEV_BSHIFT)
118:
119: /*
120: * dvmamap manages a range of DVMA addresses intended to create double
121: * mappings of physical memory. In a way, `dvmamap' is a submap of the
122: * VM map `phys_map'. The difference is the use of the `resource map'
123: * routines to manage page allocation, allowing DVMA addresses to be
124: * allocated and freed from within interrupt routines.
125: *
126: * Note that `phys_map' can still be used to allocate memory-backed pages
127: * in DVMA space.
128: */
129: #ifdef _KERNEL
130: #ifndef _LOCORE
131: extern vaddr_t dvma_base;
132: extern vaddr_t dvma_end;
133: extern struct extent *dvmamap_extent;
134:
135: extern caddr_t kdvma_mapin(caddr_t, int, int);
136: extern caddr_t dvma_malloc_space(size_t, void *, int, int);
137: extern void dvma_free(caddr_t, size_t, void *);
138: #define dvma_malloc(len,kaddr,flags) dvma_malloc_space(len,kaddr,flags,0)
139:
140: extern void delay(unsigned int);
141: #define DELAY(n) delay(n)
142:
143: extern int cputyp;
144: #if 0
145: extern int cpumod;
146: extern int mmumod;
147: #endif
148:
149: #endif /* _LOCORE */
150: #endif /* _KERNEL */
151:
152: /*
153: * Values for the cputyp variable.
154: */
155: #define CPU_SUN4 0
156: #define CPU_SUN4C 1
157: #define CPU_SUN4M 2
158:
159: /*
160: * Shorthand CPU-type macros. Enumerate all eight cases.
161: * Let compiler optimize away code conditional on constants.
162: *
163: * On a sun4 machine, the page size is 8192, while on a sun4c and sun4m
164: * it is 4096. Therefore, in the (SUN4 && (SUN4C || SUN4M)) cases below,
165: * NBPG, PGOFSET and PGSHIFT are defined as variables which are initialized
166: * early in locore.s after the machine type has been detected.
167: *
168: * Note that whenever the macros defined below evaluate to expressions
169: * involving variables, the kernel will perform slightly worse due to the
170: * extra memory references they'll generate.
171: */
172: #if defined(SUN4M) && defined(SUN4C) && defined(SUN4)
173: # define CPU_ISSUN4M (cputyp == CPU_SUN4M)
174: # define CPU_ISSUN4C (cputyp == CPU_SUN4C)
175: # define CPU_ISSUN4 (cputyp == CPU_SUN4)
176: # define CPU_ISSUN4OR4C (cputyp == CPU_SUN4 || cputyp == CPU_SUN4C)
177: # define CPU_ISSUN4COR4M (cputyp == CPU_SUN4C || cputyp == CPU_SUN4M)
178: #elif defined(SUN4M) && defined(SUN4C) && !defined(SUN4)
179: # define CPU_ISSUN4M (cputyp == CPU_SUN4M)
180: # define CPU_ISSUN4C (cputyp == CPU_SUN4C)
181: # define CPU_ISSUN4 (0)
182: # define CPU_ISSUN4OR4C (cputyp == CPU_SUN4C)
183: # define CPU_ISSUN4COR4M (cputyp == CPU_SUN4C || cputyp == CPU_SUN4M)
184: # define NBPG 4096
185: # define PGOFSET (NBPG-1)
186: # define PGSHIFT SUN4CM_PGSHIFT
187: # define PAGE_SIZE 4096
188: # define PAGE_MASK (PAGE_SIZE - 1)
189: # define PAGE_SHIFT SUN4CM_PGSHIFT
190: #elif defined(SUN4M) && !defined(SUN4C) && defined(SUN4)
191: # define CPU_ISSUN4M (cputyp == CPU_SUN4M)
192: # define CPU_ISSUN4C (0)
193: # define CPU_ISSUN4 (cputyp == CPU_SUN4)
194: # define CPU_ISSUN4OR4C (cputyp == CPU_SUN4)
195: # define CPU_ISSUN4COR4M (cputyp == CPU_SUN4M)
196: #elif defined(SUN4M) && !defined(SUN4C) && !defined(SUN4)
197: # define CPU_ISSUN4M (1)
198: # define CPU_ISSUN4C (0)
199: # define CPU_ISSUN4 (0)
200: # define CPU_ISSUN4OR4C (0)
201: # define CPU_ISSUN4COR4M (1)
202: # define NBPG 4096
203: # define PGOFSET (NBPG-1)
204: # define PGSHIFT SUN4CM_PGSHIFT
205: # define PAGE_SIZE 4096
206: # define PAGE_MASK (PAGE_SIZE - 1)
207: # define PAGE_SHIFT SUN4CM_PGSHIFT
208: #elif !defined(SUN4M) && defined(SUN4C) && defined(SUN4)
209: # define CPU_ISSUN4M (0)
210: # define CPU_ISSUN4C (cputyp == CPU_SUN4C)
211: # define CPU_ISSUN4 (cputyp == CPU_SUN4)
212: # define CPU_ISSUN4OR4C (1)
213: # define CPU_ISSUN4COR4M (cputyp == CPU_SUN4C)
214: #elif !defined(SUN4M) && defined(SUN4C) && !defined(SUN4)
215: # define CPU_ISSUN4M (0)
216: # define CPU_ISSUN4C (1)
217: # define CPU_ISSUN4 (0)
218: # define CPU_ISSUN4OR4C (1)
219: # define CPU_ISSUN4COR4M (1)
220: # define NBPG 4096
221: # define PGOFSET (NBPG-1)
222: # define PGSHIFT SUN4CM_PGSHIFT
223: # define PAGE_SIZE 4096
224: # define PAGE_MASK (PAGE_SIZE - 1)
225: # define PAGE_SHIFT SUN4CM_PGSHIFT
226: #elif !defined(SUN4M) && !defined(SUN4C) && defined(SUN4)
227: # define CPU_ISSUN4M (0)
228: # define CPU_ISSUN4C (0)
229: # define CPU_ISSUN4 (1)
230: # define CPU_ISSUN4OR4C (1)
231: # define CPU_ISSUN4COR4M (0)
232: # define NBPG 8192
233: # define PGOFSET (NBPG-1)
234: # define PGSHIFT SUN4_PGSHIFT
235: # define PAGE_SIZE 8192
236: # define PAGE_MASK (PAGE_SIZE - 1)
237: # define PAGE_SHIFT SUN4_PGSHIFT
238: #elif !defined(SUN4M) && !defined(SUN4C) && !defined(SUN4)
239: # define CPU_ISSUN4M (cputyp == CPU_SUN4M)
240: # define CPU_ISSUN4C (cputyp == CPU_SUN4C)
241: # define CPU_ISSUN4 (cputyp == CPU_SUN4)
242: # define CPU_ISSUN4OR4C (cputyp == CPU_SUN4 || cputyp == CPU_SUN4C)
243: # define CPU_ISSUN4COR4M (cputyp == CPU_SUN4C || cputyp == CPU_SUN4M)
244: #endif
245:
246: #ifndef NBPG
247: #ifdef STANDALONE /* boot blocks */
248: # define NBPG nbpg
249: # define PGOFSET pgofset
250: # define PGSHIFT pgshift
251: # define PAGE_SIZE nbpg
252: # define PAGE_MASK pgofset
253: # define PAGE_SHIFT pgshift
254: #else
255: # define NBPG uvmexp.pagesize
256: # define PGOFSET uvmexp.pagemask
257: # define PGSHIFT uvmexp.pageshift
258: # define PAGE_SIZE uvmexp.pagesize
259: # define PAGE_MASK uvmexp.pagemask
260: # define PAGE_SHIFT uvmexp.pageshift
261: #endif
262: #endif
263:
264: #endif /* _SPARC_PARAM_H_ */
CVSweb