xref: /openbsd-src/sys/arch/alpha/include/param.h (revision b2ea75c1b17e1a9a339660e7ed45cd24946b230e)
1 /* $OpenBSD: param.h,v 1.20 2001/05/05 20:56:31 art Exp $ */
2 /* $NetBSD: param.h,v 1.30 2000/06/09 16:03:04 thorpej Exp $ */
3 
4 /*
5  * Copyright (c) 1988 University of Utah.
6  * Copyright (c) 1992, 1993
7  *	The Regents of the University of California.  All rights reserved.
8  *
9  * This code is derived from software contributed to Berkeley by
10  * the Systems Programming Group of the University of Utah Computer
11  * Science Department and Ralph Campbell.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions
15  * are met:
16  * 1. Redistributions of source code must retain the above copyright
17  *    notice, this list of conditions and the following disclaimer.
18  * 2. Redistributions in binary form must reproduce the above copyright
19  *    notice, this list of conditions and the following disclaimer in the
20  *    documentation and/or other materials provided with the distribution.
21  * 3. All advertising materials mentioning features or use of this software
22  *    must display the following acknowledgement:
23  *	This product includes software developed by the University of
24  *	California, Berkeley and its contributors.
25  * 4. 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  * from: Utah $Hdr: machparam.h 1.11 89/08/14$
42  *
43  *	@(#)param.h	8.1 (Berkeley) 6/10/93
44  */
45 
46 /*
47  * Machine dependent constants for the Alpha.
48  */
49 #define	_MACHINE	alpha
50 #define	MACHINE		"alpha"
51 #define	_MACHINE_ARCH	alpha
52 #define	MACHINE_ARCH	"alpha"
53 #define	MID_MACHINE	MID_ALPHA
54 
55 #include <machine/alpha_cpu.h>
56 #include <machine/cpu.h>
57 
58 /*
59  * Round p (pointer or byte index) up to a correctly-aligned value for all
60  * data types (int, long, ...).   The result is u_long and must be cast to
61  * any desired pointer type.
62  *
63  * ALIGNED_POINTER is a boolean macro that checks whether an address
64  * is valid to fetch data elements of type t from on this architecture.
65  * This does not reflect the optimal alignment, just the possibility
66  * (within reasonable limits).
67  *
68  */
69 #define	ALIGNBYTES		7
70 #define	ALIGN(p)		(((u_long)(p) + ALIGNBYTES) &~ ALIGNBYTES)
71 #define ALIGNED_POINTER(p,t)	((((u_long)(p)) & (sizeof(t)-1)) == 0)
72 
73 #define	NBPG		(1 << ALPHA_PGSHIFT)		/* bytes/page */
74 #define	PGOFSET		(NBPG-1)			/* byte off. into pg */
75 #define	PGSHIFT		ALPHA_PGSHIFT			/* LOG2(NBPG) */
76 
77 #define PAGE_SHIFT	13
78 #define PAGE_SIZE	(1 << PAGE_SHIFT)
79 #define PAGE_MASK	(PAGE_SIZE - 1)
80 
81 #define	KERNBASE	0xfffffc0000230000	/* start of kernel virtual */
82 #define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
83 
84 #define	DEV_BSIZE	512
85 #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
86 #define	BLKDEV_IOSIZE	2048
87 #ifndef	MAXPHYS
88 #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
89 #endif
90 
91 #define	SSIZE		1		/* initial stack size/NBPG */
92 #define	SINCR		1		/* increment of stack/NBPG */
93 
94 #define	UPAGES		2			/* pages of u-area */
95 #define	USPACE		(UPAGES * NBPG)		/* total size of u-area */
96 
97 #ifndef MSGBUFSIZE
98 #define MSGBUFSIZE	NBPG		/* default message buffer size */
99 #endif
100 
101 /*
102  * Constants related to network buffer management.
103  * MCLBYTES must be no larger than NBPG (the software page size), and,
104  * on machines that exchange pages of input or output buffers with mbuf
105  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
106  * of the hardware page size.
107  */
108 #define	MSIZE		256		/* size of an mbuf */
109 #ifndef MCLSHIFT
110 # define	MCLSHIFT	11	/* convert bytes to m_buf clusters */
111 					/* 2K cluster can hold Ether frame */
112 #endif	/* MCLSHIFT */
113 #define	MCLBYTES	(1 << MCLSHIFT)	/* size of a m_buf cluster */
114 #define	MCLOFSET	(MCLBYTES - 1)
115 #ifndef NMBCLUSTERS
116 
117 #ifdef GATEWAY
118 #define	NMBCLUSTERS	1024		/* map size, max cluster allocation */
119 #else
120 #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
121 #endif
122 #endif
123 
124 /*
125  * Size of kernel malloc arena in CLBYTES-sized logical pages
126  */
127 #ifndef NKMEMCLUSTERS
128 #define NKMEMCLUSTERS	(32768*1024/NBPG)
129 #endif
130 
131 
132 /* pages ("clicks") to disk blocks */
133 #define	ctod(x)		((x) << (PGSHIFT - DEV_BSHIFT))
134 #define	dtoc(x)		((x) >> (PGSHIFT - DEV_BSHIFT))
135 
136 /* pages to bytes */
137 #define	ctob(x)		((x) << PGSHIFT)
138 #define	btoc(x)		(((x) + PGOFSET) >> PGSHIFT)
139 
140 /* bytes to disk blocks */
141 #define	btodb(x)	((x) >> DEV_BSHIFT)
142 #define	dbtob(x)	((x) << DEV_BSHIFT)
143 
144 /*
145  * Map a ``block device block'' to a file system block.
146  * This should be device dependent, and should use the bsize
147  * field from the disk label.
148  * For now though just use DEV_BSIZE.
149  */
150 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
151 
152 /*
153  * Mach derived conversion macros
154  */
155 #define	alpha_round_page(x)	((((unsigned long)(x)) + NBPG - 1) & ~(NBPG-1))
156 #define	alpha_trunc_page(x)	((unsigned long)(x) & ~(NBPG-1))
157 #define	alpha_btop(x)		((unsigned long)(x) >> PGSHIFT)
158 #define	alpha_ptob(x)		((unsigned long)(x) << PGSHIFT)
159 
160 #ifdef _KERNEL
161 #ifndef _LOCORE
162 
163 #include <machine/intr.h>
164 
165 void	delay(unsigned long);
166 #define	DELAY(n)	delay(n)
167 
168 /* XXX THE FOLLOWING PROTOTYPE BELONGS IN INTR.H */
169 int spl0 __P((void));			/* drop ipl to zero */
170 /* XXX END INTR.H */
171 
172 /* XXX THE FOLLOWING PROTOTYPE SHOULD BE A BUS.H INTERFACE */
173 paddr_t alpha_XXX_dmamap(vaddr_t);
174 /* XXX END BUS.H */
175 
176 #endif
177 #endif /* !_KERNEL */
178