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