xref: /netbsd-src/sys/arch/arm/include/param.h (revision 3b01aba77a7a698587faaae455bbfe740923c1f5)
1 /*	$NetBSD: param.h,v 1.3 2001/07/14 07:31:31 matt Exp $	*/
2 
3 /*
4  * Copyright (c) 1994,1995 Mark Brinicombe.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *	This product includes software developed by the RiscBSD team.
18  * 4. The name "RiscBSD" nor the name of the author may be used to
19  *    endorse or promote products derived from this software without specific
20  *    prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY RISCBSD ``AS IS'' AND ANY EXPRESS OR IMPLIED
23  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25  * IN NO EVENT SHALL RISCBSD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
26  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  */
34 
35 #ifndef	_ARM_PARAM_H_
36 #define	_ARM_PARAM_H_
37 
38 /*
39  * Machine dependent constants for all ARM processors
40  */
41 
42 /*
43  * For KERNEL code:
44  *	MACHINE must be defined by the individual port.
45  *	MACHINE_ARCH may be defined by an individual port.
46  *
47  * For non-KERNEL code:
48  *	MACHINE && MACHINE_ARCH default to "arm"
49  */
50 
51 #ifndef _KERNEL
52 #ifndef MACHINE
53 #define	MACHINE		"arm"
54 #endif
55 #endif /* !_KERNEL */
56 
57 #ifndef MACHINE_ARCH
58 #define	MACHINE_ARCH	"arm"
59 #endif
60 
61 #define	MID_MACHINE	MID_ARM6
62 
63 /*
64  * Round p (pointer or byte index) up to a correctly-aligned value
65  * for all data types (int, long, ...).   The result is u_int and
66  * must be cast to any desired pointer type.
67  *
68  * ALIGNED_POINTER is a boolean macro that checks whether an address
69  * is valid to fetch data elements of type t from on this architecture.
70  * This does not reflect the optimal alignment, just the possibility
71  * (within reasonable limits).
72  *
73  */
74 #define ALIGNBYTES		(sizeof(int) - 1)
75 #define ALIGN(p)		(((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
76 #define ALIGNED_POINTER(p,t)	((((u_long)(p)) & (sizeof(t)-1)) == 0)
77 
78 #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
79 #define	DEV_BSIZE	(1 << DEV_BSHIFT)
80 #define	BLKDEV_IOSIZE	2048
81 
82 #ifndef MAXPHYS
83 #define	MAXPHYS		65536		/* max I/O transfer size */
84 #endif
85 
86 /* pages ("clicks") to disk blocks */
87 #define	ctod(x)	((x) << (PGSHIFT - DEV_BSHIFT))
88 #define	dtoc(x)	((x) >> (PGSHIFT - DEV_BSHIFT))
89 /*#define	dtob(x)	((x) << DEV_BSHIFT)*/
90 
91 #define	ctob(x)	((x) << PGSHIFT)
92 
93 /* bytes to pages */
94 #define	btoc(x)	(((x) + PGOFSET) >> PGSHIFT)
95 
96 #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
97 	((bytes) >> DEV_BSHIFT)
98 #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
99 	((db) << DEV_BSHIFT)
100 
101 /*
102  * Map a ``block device block'' to a file system block.
103  * This should be device dependent, and should use the bsize
104  * field from the disk label.
105  * For now though just use DEV_BSIZE.
106  */
107 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE / DEV_BSIZE))
108 
109 /*
110  * Constants related to network buffer management.
111  * MCLBYTES must be no larger than NBPG (the software page size), and,
112  * on machines that exchange pages of input or output buffers with mbuf
113  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
114  * of the hardware page size.
115  */
116 #define	MSIZE		256		/* size of an mbuf */
117 #define	MCLSHIFT	11		/* convert bytes to m_buf clusters */
118 #define	MCLBYTES	(1 << MCLSHIFT)	/* size of a m_buf cluster */
119 #define	MCLOFSET	(MCLBYTES - 1)	/* offset within a m_buf cluster */
120 
121 #endif /* _ARM_PARAM_H_ */
122