param.h revision 1.4
1/*	$NetBSD: param.h,v 1.4 2003/06/23 11:01:17 martin Exp $	*/
2
3/*	$OpenBSD: param.h,v 1.12 2001/07/06 02:07:41 provos Exp $	*/
4
5/*
6 * Copyright (c) 1988-1994, The University of Utah and
7 * the Computer Systems Laboratory at the University of Utah (CSL).
8 * All rights reserved.
9 *
10 * Permission to use, copy, modify and distribute this software is hereby
11 * granted provided that (1) source code retains these copyright, permission,
12 * and disclaimer notices, and (2) redistributions including binaries
13 * reproduce the notices in supporting documentation, and (3) all advertising
14 * materials mentioning features or use of this software display the following
15 * acknowledgement: ``This product includes software developed by the
16 * Computer Systems Laboratory at the University of Utah.''
17 *
18 * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
19 * IS" CONDITION.  THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
20 * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
21 *
22 * CSL requests users of this software to return to csl-dist@cs.utah.edu any
23 * improvements that they make and grant CSL redistribution rights.
24 *
25 * 	Utah $Hdr: param.h 1.18 94/12/16$
26 */
27
28#include "opt_compat_hpux.h"
29#include <sys/featuretest.h>
30
31#if defined(_NETBSD_SOURCE)
32#include <machine/cpu.h>
33#endif
34
35/*
36 * Machine dependent constants for PA-RISC.
37 */
38
39#define	_MACHINE_ARCH	hppa
40#define	MACHINE_ARCH	"hppa"
41#define	MID_MACHINE	MID_HPUX800
42
43/*
44 * Round p (pointer or byte index) up to a correctly-aligned value for all
45 * data types (int, long, ...).   The result is u_int and must be cast to
46 * any desired pointer type.
47 */
48#define	ALIGNBYTES	7
49#define	ALIGN(p)	(((u_long)(p) + ALIGNBYTES) &~ ALIGNBYTES)
50#define	ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t) - 1)) == 0)
51
52#define	PGSHIFT		12		/* LOG2(NBPG) */
53#define	NBPG		(1 << PGSHIFT)	/* bytes/page */
54#define	PGOFSET		(NBPG-1)	/* byte offset into page */
55
56#define	SEGSHIFT	(PGSHIFT + (PGSHIFT-PTESHIFT))	/* LOG2(NBSEG) */
57#define NBSEG		(1 << SEGSHIFT)	/* bytes/segment (quadrant) */
58#define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
59
60#define	KERNBASE	0x00000000	/* start of kernel virtual */
61#define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
62
63#define	DEV_BSIZE	512
64#define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
65#define BLKDEV_IOSIZE	2048
66#define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
67
68#define	SSIZE		(1)		/* initial stack size/NBPG */
69#define	SINCR		(1)		/* increment of stack/NBPG */
70
71#define	UADDR		0x7ffe6000	/* u-area lives here */
72#define	USHIFT		(3)		/* log2(UPAGES) */
73#define	UPAGES		(1<<USHIFT)	/* pages of u-area */
74#define	USPACE		(UPAGES * NBPG)	/* pages for user struct and kstack */
75
76#ifndef	MSGBUFSIZE
77#define	MSGBUFSIZE	2*NBPG		/* default message buffer size */
78#endif
79
80/*
81 * Constants related to network buffer management.
82 * MCLBYTES must be no larger than the software page size, and,
83 * on machines that exchange pages of input or output buffers with mbuf
84 * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
85 * of the hardware page size.
86 */
87#define	MSIZE		256		/* size of an mbuf */
88#define	MCLSHIFT	11
89#define	MCLBYTES	(1 << MCLSHIFT)	/* large enough for ether MTU */
90#define	MCLOFSET	(MCLBYTES - 1)
91#ifndef NMBCLUSTERS
92#define	NMBCLUSTERS	(2048)		/* cl map size: 1MB */
93#endif
94
95/*
96 * Size of kernel malloc arena in logical pages
97 */
98#define NKMEMPAGES_MIN_DEFAULT  ((16 * 1024 * 1024) >> PAGE_SHIFT)
99#define NKMEMPAGES_MAX_DEFAULT  ((16 * 1024 * 1024) >> PAGE_SHIFT)
100
101/* pages ("clicks") (4096 bytes) to disk blocks */
102#define	ctod(x)	((x)<<(PGSHIFT-DEV_BSHIFT))
103#define	dtoc(x)	((x)>>(PGSHIFT-DEV_BSHIFT))
104
105/* pages to bytes */
106#define	ctob(x)	((x)<<PGSHIFT)
107#define	btoc(x)	(((unsigned)(x)+(NBPG-1))>>PGSHIFT)
108
109#define	btodb(bytes)	((unsigned)(bytes) >> DEV_BSHIFT)
110#define	dbtob(db)	((unsigned)(db) << DEV_BSHIFT)
111
112/*
113 * Map a ``block device block'' to a file system block.
114 * This should be device dependent, and should use the bsize
115 * field from the disk label.
116 * For now though just use DEV_BSIZE.
117 */
118#define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
119
120/*
121 * Mach derived conversion macros
122 */
123#define hppa_round_page(x)	((((unsigned long)(x)) + NBPG - 1) & ~(NBPG-1))
124#define hppa_trunc_page(x)	((unsigned long)(x) & ~(NBPG-1))
125
126#define btop(x)		((unsigned long)(x) >> PGSHIFT)
127#define ptob(x)		((unsigned long)(x) << PGSHIFT)
128
129#ifdef _KERNEL
130#ifdef COMPAT_HPUX
131/*
132 * Constants/macros for HPUX multiple mapping of user address space.
133 * Pages in the first 256Mb are mapped in at every 256Mb segment.
134 */
135#define HPMMMASK	0xF0000000
136#define ISHPMMADDR(v)	0		/* XXX ...jef */
137#define HPMMBASEADDR(v)	((unsigned)(v) & ~HPMMMASK)
138#endif
139
140#endif
141