param.h revision 70651
170651Sobrien/*-
270651Sobrien * Copyright (c) 2001 David E. O'Brien
370651Sobrien * Copyright (c) 1990 The Regents of the University of California.
470651Sobrien * All rights reserved.
570651Sobrien *
670651Sobrien * This code is derived from software contributed to Berkeley by
770651Sobrien * William Jolitz.
870651Sobrien *
970651Sobrien * Redistribution and use in source and binary forms, with or without
1070651Sobrien * modification, are permitted provided that the following conditions
1170651Sobrien * are met:
1270651Sobrien * 1. Redistributions of source code must retain the above copyright
1370651Sobrien *    notice, this list of conditions and the following disclaimer.
1470651Sobrien * 2. Redistributions in binary form must reproduce the above copyright
1570651Sobrien *    notice, this list of conditions and the following disclaimer in the
1670651Sobrien *    documentation and/or other materials provided with the distribution.
1770651Sobrien * 3. All advertising materials mentioning features or use of this software
1870651Sobrien *    must display the following acknowledgement:
1970651Sobrien *	This product includes software developed by the University of
2070651Sobrien *	California, Berkeley and its contributors.
2170651Sobrien * 4. Neither the name of the University nor the names of its contributors
2270651Sobrien *    may be used to endorse or promote products derived from this software
2370651Sobrien *    without specific prior written permission.
2470651Sobrien *
2570651Sobrien * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2670651Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2770651Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2870651Sobrien * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2970651Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3070651Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3170651Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3270651Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3370651Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3470651Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3570651Sobrien * SUCH DAMAGE.
3670651Sobrien *
3770651Sobrien *	from: @(#)param.h	5.8 (Berkeley) 6/28/91
3870651Sobrien * $FreeBSD: head/sys/arm/include/param.h 70651 2001-01-04 05:23:06Z obrien $
3970651Sobrien */
4070651Sobrien
4170651Sobrien/*
4270651Sobrien * Machine dependent constants for StrongARM
4370651Sobrien */
4470651Sobrien
4570651Sobrien/*
4670651Sobrien * Round p (pointer or byte index) up to a correctly-aligned value
4770651Sobrien * for all data types (int, long, ...).   The result is unsigned int
4870651Sobrien * and must be cast to any desired pointer type.
4970651Sobrien */
5070651Sobrien#ifndef _ALIGNBYTES
5170651Sobrien#define	_ALIGNBYTES	(sizeof(int) - 1)
5270651Sobrien#endif
5370651Sobrien#ifndef _ALIGN
5470651Sobrien#define	_ALIGN(p)	(((unsigned)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
5570651Sobrien#endif
5670651Sobrien
5770651Sobrien#ifndef	_MACHINE
5870651Sobrien#define	_MACHIN		"arm32"
5970651Sobrien#endif
6070651Sobrien#ifndef _MACHINE_ARCH
6170651Sobrien#define	_MACHINE_ARCH	"arm32"
6270651Sobrien#endif
6370651Sobrien
6470651Sobrien#ifndef _NO_NAMESPACE_POLLUTION
6570651Sobrien
6670651Sobrien#ifndef _MACHINE_PARAM_H_
6770651Sobrien#define	_MACHINE_PARAM_H_
6870651Sobrien
6970651Sobrien#ifndef MACHINE
7070651Sobrien#define	MACHINE		"arm32"
7170651Sobrien#endif
7270651Sobrien#ifndef MACHINE_ARCH
7370651Sobrien#define	MACHINE_ARCH	"arm32"
7470651Sobrien#endif
7570651Sobrien#define	MID_MACHINE	MID_ARM32
7670651Sobrien
7770651Sobrien#include <machine/cpu.h>
7870651Sobrien
7970651Sobrien/*
8070651Sobrien * OBJFORMAT_NAMES is a comma-separated list of the object formats
8170651Sobrien * that are supported on the architecture.
8270651Sobrien */
8370651Sobrien#define	OBJFORMAT_NAMES		"elf"
8470651Sobrien#define	OBJFORMAT_DEFAULT	"elf"
8570651Sobrien
8670651Sobrien#ifdef SMP
8770651Sobrien#define	MAXCPU		2
8870651Sobrien#else
8970651Sobrien#define	MAXCPU		1
9070651Sobrien#endif /* SMP */
9170651Sobrien
9270651Sobrien#define	ALIGNBYTES	_ALIGNBYTES
9370651Sobrien#define	ALIGN(p)	_ALIGN(p)
9470651Sobrien
9570651Sobrien#define	PAGE_SHIFT	12
9670651Sobrien#define	PAGE_SIZE	(1 << PAGE_SHIFT)	/* Page size */
9770651Sobrien#define	PAGE_MASK	(PAGE_SIZE - 1)
9870651Sobrien#define	NPTEPG		(PAGE_SIZE/(sizeof (pt_entry_t)))
9970651Sobrien
10070651Sobrien#define	KERNBASE	0x100000	/* start of kernel virtual */
10170651Sobrien#define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
10270651Sobrien
10370651Sobrien#define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
10470651Sobrien#define	DEV_BSIZE	(1 << DEV_BSHIFT)
10570651Sobrien
10670651Sobrien#ifndef BLKDEV_IOSIZE
10770651Sobrien#define	BLKDEV_IOSIZE	PAGE_SIZE	/* default block device I/O size */
10870651Sobrien#endif
10970651Sobrien#define	DFLTPHYS	(64 * 1024)	/* default max raw I/O transfer size */
11070651Sobrien#define	MAXPHYS		(128 * 1024)	/* max raw I/O transfer size */
11170651Sobrien#define	MAXDUMPPGS	(DFLTPHYS/PAGE_SIZE)
11270651Sobrien
11370651Sobrien#define	UPAGES		2		/* pages of u-area */
11470651Sobrien#define	USPACE		(UPAGES * PAGE_SIZE)	/* total size of u-area */
11570651Sobrien
11670651Sobrien/*
11770651Sobrien * Constants related to network buffer management.
11870651Sobrien * MCLBYTES must be no larger than PAGE_SIZE.
11970651Sobrien */
12070651Sobrien#ifndef	MSIZE
12170651Sobrien#define	MSIZE		256		/* size of an mbuf */
12270651Sobrien#endif	/* MSIZE */
12370651Sobrien
12470651Sobrien#ifndef	MCLSHIFT
12570651Sobrien#define	MCLSHIFT	11		/* convert bytes to mbuf clusters */
12670651Sobrien#endif	/* MCLSHIFT */
12770651Sobrien#define	MCLBYTES	(1 << MCLSHIFT)	/* size of an mbuf cluster */
12870651Sobrien
12970651Sobrien/*
13070651Sobrien * Some macros for units conversion
13170651Sobrien */
13270651Sobrien
13370651Sobrien/* pages ("clicks") to bytes */
13470651Sobrien#define	ctob(x)		((x) << PAGE_SHIFT)
13570651Sobrien
13670651Sobrien/* bytes to clicks */
13770651Sobrien#define	btoc(x)		(((unsigned)(x) + PAGE_MASK) >> PAGE_SHIFT)
13870651Sobrien
13970651Sobrien/* pages ("clicks") to disk blocks */
14070651Sobrien#define	ctod(x)		((x) << (PAGE_SHIFT - DEV_BSHIFT))
14170651Sobrien#define	dtoc(x)		((x) >> (PAGE_SHIFT - DEV_BSHIFT))
14270651Sobrien
14370651Sobrien/* bytes to disk blocks */
14470651Sobrien/*
14570651Sobrien * btodb() is messy and perhaps slow because `bytes' may be an off_t.  We
14670651Sobrien * want to shift an unsigned type to avoid sign extension and we don't
14770651Sobrien * want to widen `bytes' unnecessarily.  Assume that the result fits in
14870651Sobrien * a daddr_t.
14970651Sobrien */
15070651Sobrien#define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
15170651Sobrien	(sizeof (bytes) > sizeof(long) \
15270651Sobrien	 ? (daddr_t)((unsigned long long)(bytes) >> DEV_BSHIFT) \
15370651Sobrien	 : (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT))
15470651Sobrien
15570651Sobrien#define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
15670651Sobrien	((off_t)(db) << DEV_BSHIFT)
15770651Sobrien
15870651Sobrien/*
15970651Sobrien * Mach derived conversion macros
16070651Sobrien */
16170651Sobrien#define	trunc_page(x)		((x) & ~PAGE_MASK)
16270651Sobrien#define	round_page(x)		(((x) + PAGE_MASK) & ~PAGE_MASK)
16370651Sobrien#define	trunc_4mpage(x)		((unsigned)(x) & ~PDRMASK)
16470651Sobrien#define	round_4mpage(x)		((((unsigned)(x)) + PDRMASK) & ~PDRMASK)
16570651Sobrien
16670651Sobrien#define	atop(x)			((unsigned)(x) >> PAGE_SHIFT)
16770651Sobrien#define	ptoa(x)			((unsigned)(x) << PAGE_SHIFT)
16870651Sobrien
16970651Sobrien#define	arm32_btop(x)		((unsigned)(x) >> PAGE_SHIFT)
17070651Sobrien#define	arm32_ptob(x)		((unsigned)(x) << PAGE_SHIFT)
17170651Sobrien
17270651Sobrien#define	pgtok(x)		((x) * (PAGE_SIZE / 1024))
17370651Sobrien
17470651Sobrien#endif /* !_MACHINE_PARAM_H_ */
17570651Sobrien#endif /* !_NO_NAMESPACE_POLLUTION */
176