xref: /openbsd-src/sys/arch/i386/include/param.h (revision 8500990981f885cbe5e6a4958549cacc238b5ae6)
1 /*	$OpenBSD: param.h,v 1.24 2003/06/02 23:27:47 millert Exp $	*/
2 /*	$NetBSD: param.h,v 1.29 1996/03/04 05:04:26 cgd Exp $	*/
3 
4 /*-
5  * Copyright (c) 1990 The Regents of the University of California.
6  * All rights reserved.
7  *
8  * This code is derived from software contributed to Berkeley by
9  * William Jolitz.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. Neither the name of the University nor the names of its contributors
20  *    may be used to endorse or promote products derived from this software
21  *    without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  *
35  *	@(#)param.h	5.8 (Berkeley) 6/28/91
36  */
37 
38 /*
39  * Machine dependent constants for Intel 386.
40  */
41 
42 #ifdef _KERNEL
43 #ifdef _LOCORE
44 #include <machine/psl.h>
45 #else
46 #include <machine/cpu.h>
47 #endif
48 #endif
49 
50 #define	_MACHINE	i386
51 #define	MACHINE		"i386"
52 #define	_MACHINE_ARCH	i386
53 #define	MACHINE_ARCH	"i386"
54 #define	MID_MACHINE	MID_I386
55 
56 /*
57  * Round p (pointer or byte index) up to a correctly-aligned value
58  * for all data types (int, long, ...).   The result is u_int and
59  * must be cast to any desired pointer type.
60  *
61  * ALIGNED_POINTER is a boolean macro that checks whether an address
62  * is valid to fetch data elements of type t from on this architecture.
63  * This does not reflect the optimal alignment, just the possibility
64  * (within reasonable limits).
65  */
66 #define ALIGNBYTES	(sizeof(int) - 1)
67 #define ALIGN(p)	(((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
68 #define ALIGNED_POINTER(p,t)   1
69 
70 #define	PGSHIFT		12		/* LOG2(NBPG) */
71 #define	NBPG		(1 << PGSHIFT)	/* bytes/page */
72 #define	PGOFSET		(NBPG-1)	/* byte offset into page */
73 
74 #define PAGE_SHIFT	12
75 #define PAGE_SIZE	(1 << PAGE_SHIFT)
76 #define PAGE_MASK	(PAGE_SIZE - 1)
77 
78 #define	NPTEPG		(NBPG/(sizeof (pt_entry_t)))
79 
80 /*
81  * Start of kernel virtual space.  Remember to alter the memory and
82  * page table layout description in pmap.h when changing this.
83  */
84 #define	KERNBASE	0xd0000000
85 
86 #define	KERNTEXTOFF	(KERNBASE+0x100000)	/* start of kernel text */
87 #define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
88 
89 #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
90 #define	DEV_BSIZE	(1 << DEV_BSHIFT)
91 #define	BLKDEV_IOSIZE	2048
92 #ifndef	MAXPHYS
93 #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
94 #endif
95 
96 #define	SSIZE		1		/* initial stack size/NBPG */
97 #define	SINCR		1		/* increment of stack/NBPG */
98 #define	UPAGES		2		/* pages of u-area */
99 #define	USPACE		(UPAGES * NBPG)	/* total size of u-area */
100 
101 #ifndef MSGBUFSIZE
102 #define MSGBUFSIZE	2*NBPG		/* default message buffer size */
103 #endif
104 
105 /*
106  * Constants related to network buffer management.
107  * MCLBYTES must be no larger than the software page size, and,
108  * on machines that exchange pages of input or output buffers with mbuf
109  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
110  * of the hardware page size.
111  */
112 #define	MSIZE		256		/* size of an mbuf */
113 #define	MCLSHIFT	11		/* convert bytes to m_buf clusters */
114 #define	MCLBYTES	(1 << MCLSHIFT)	/* size of a m_buf cluster */
115 #define	MCLOFSET	(MCLBYTES - 1)	/* offset within a m_buf cluster */
116 
117 #ifndef NMBCLUSTERS
118 #define	NMBCLUSTERS	2048		/* map size, max cluster allocation */
119 #endif
120 
121 /*
122  * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
123  * logical pages.
124  */
125 #define	NKMEMPAGES_MIN_DEFAULT	((8 * 1024 * 1024) >> PAGE_SHIFT)
126 #define	NKMEMPAGES_MAX_DEFAULT	((64 * 1024 * 1024) >> PAGE_SHIFT)
127 
128 /* pages ("clicks") to disk blocks */
129 #define	ctod(x)		((x) << (PGSHIFT - DEV_BSHIFT))
130 #define	dtoc(x)		((x) >> (PGSHIFT - DEV_BSHIFT))
131 
132 /* bytes to pages */
133 #define	ctob(x)		((x) << PGSHIFT)
134 #define	btoc(x)		(((x) + PGOFSET) >> PGSHIFT)
135 
136 /* bytes to disk blocks */
137 #define	dbtob(x)	((x) << DEV_BSHIFT)
138 #define	btodb(x)	((x) >> DEV_BSHIFT)
139 
140 /*
141  * Map a ``block device block'' to a file system block.
142  * This should be device dependent, and should use the bsize
143  * field from the disk label.
144  * For now though just use DEV_BSIZE.
145  */
146 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE / DEV_BSIZE))
147 
148 /*
149  * Mach derived conversion macros
150  */
151 #define	i386_round_pdr(x)	((((unsigned)(x)) + PDOFSET) & ~PDOFSET)
152 #define	i386_trunc_pdr(x)	((unsigned)(x) & ~PDOFSET)
153 #define	i386_btod(x)		((unsigned)(x) >> PDSHIFT)
154 #define	i386_dtob(x)		((unsigned)(x) << PDSHIFT)
155 #define	i386_round_page(x)	((((unsigned)(x)) + PGOFSET) & ~PGOFSET)
156 #define	i386_trunc_page(x)	((unsigned)(x) & ~PGOFSET)
157 #define	i386_btop(x)		((unsigned)(x) >> PGSHIFT)
158 #define	i386_ptob(x)		((unsigned)(x) << PGSHIFT)
159