4.4BSD snapshot (revision 8.1)
[unix-history] / usr / src / sys / hp300 / include / param.h
CommitLineData
88a7e859
KM
1/*
2 * Copyright (c) 1988 University of Utah.
3 * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * the Systems Programming Group of the University of Utah Computer
8 * Science Department.
9 *
10 * %sccs.include.redist.c%
11 *
b1c25049 12 * from: Utah $Hdr: machparam.h 1.16 92/12/20$
88a7e859 13 *
b1c25049 14 * @(#)param.h 7.13 (Berkeley) %G%
88a7e859
KM
15 */
16
17/*
18 * Machine dependent constants for HP9000 series 300.
19 */
20#define MACHINE "hp300"
21
d04ccb97 22/*
bc2f18e8
KB
23 * Round p (pointer or byte index) up to a correctly-aligned value for all
24 * data types (int, long, ...). The result is u_int and must be cast to
25 * any desired pointer type.
d04ccb97 26 */
83305898
KB
27#define ALIGNBYTES 3
28#define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
d04ccb97 29
88a7e859
KM
30#define NBPG 4096 /* bytes/page */
31#define PGOFSET (NBPG-1) /* byte offset into page */
32#define PGSHIFT 12 /* LOG2(NBPG) */
33#define NPTEPG (NBPG/(sizeof (struct pte)))
34
9acfa6cd 35#define NBSEG 0x400000 /* bytes/segment */
88a7e859
KM
36#define SEGOFSET (NBSEG-1) /* byte offset into segment */
37#define SEGSHIFT 22 /* LOG2(NBSEG) */
38
39#define KERNBASE 0x00000000 /* start of kernel virtual */
40#define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT)
41
42#define DEV_BSIZE 512
43#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
44#define BLKDEV_IOSIZE 2048
45#define MAXPHYS (64 * 1024) /* max raw I/O transfer size */
46
47#define CLSIZE 1
48#define CLSIZELOG2 0
49
98a9a1f2 50/* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */
88a7e859
KM
51#define SSIZE 1 /* initial stack size/NBPG */
52#define SINCR 1 /* increment of stack/NBPG */
53
b1c25049 54#define UPAGES 2 /* pages of u-area */
88a7e859
KM
55
56/*
57 * Constants related to network buffer management.
58 * MCLBYTES must be no larger than CLBYTES (the software page size), and,
59 * on machines that exchange pages of input or output buffers with mbuf
60 * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
61 * of the hardware page size.
62 */
63#define MSIZE 128 /* size of an mbuf */
b1c25049
MH
64#define MCLBYTES 2048 /* large enough for ether MTU */
65#define MCLSHIFT 11
88a7e859
KM
66#define MCLOFSET (MCLBYTES - 1)
67#ifndef NMBCLUSTERS
68#ifdef GATEWAY
69#define NMBCLUSTERS 512 /* map size, max cluster allocation */
70#else
71#define NMBCLUSTERS 256 /* map size, max cluster allocation */
72#endif
73#endif
74
75/*
76 * Size of kernel malloc arena in CLBYTES-sized logical pages
77 */
78#ifndef NKMEMCLUSTERS
db6c00fa 79#define NKMEMCLUSTERS (2048*1024/CLBYTES)
88a7e859
KM
80#endif
81
96b316eb 82/* pages ("clicks") (4096 bytes) to disk blocks */
88a7e859
KM
83#define ctod(x) ((x)<<(PGSHIFT-DEV_BSHIFT))
84#define dtoc(x) ((x)>>(PGSHIFT-DEV_BSHIFT))
85#define dtob(x) ((x)<<DEV_BSHIFT)
86
96b316eb 87/* pages to bytes */
88a7e859
KM
88#define ctob(x) ((x)<<PGSHIFT)
89
96b316eb 90/* bytes to pages */
88a7e859
KM
91#define btoc(x) (((unsigned)(x)+(NBPG-1))>>PGSHIFT)
92
b1c25049
MH
93#define LABELSECTOR (1024/DEV_BSIZE)
94#define LABELOFFSET 0
95
88a7e859
KM
96#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \
97 ((unsigned)(bytes) >> DEV_BSHIFT)
98#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \
99 ((unsigned)(db) << DEV_BSHIFT)
100
101/*
102 * Map a ``block device block'' to a file system block.
98a9a1f2
MK
103 * This should be device dependent, and should use the bsize
104 * field from the disk label.
88a7e859
KM
105 * For now though just use DEV_BSIZE.
106 */
107#define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
108
4534a638
KM
109/*
110 * Mach derived conversion macros
111 */
4534a638
KM
112#define hp300_round_page(x) ((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1))
113#define hp300_trunc_page(x) ((unsigned)(x) & ~(NBPG-1))
4534a638
KM
114#define hp300_btop(x) ((unsigned)(x) >> PGSHIFT)
115#define hp300_ptob(x) ((unsigned)(x) << PGSHIFT)
116
88a7e859 117/*
98a9a1f2 118 * spl functions; all but spl0 are done in-line
88a7e859 119 */
98a9a1f2
MK
120#include <machine/psl.h>
121
122#define _spl(s) \
123({ \
124 register int _spl_r; \
125\
126 asm __volatile ("clrl %0; movew sr,%0; movew %1,sr" : \
127 "&=d" (_spl_r) : "di" (s)); \
128 _spl_r; \
129})
130
131/* spl0 requires checking for software interrupts */
132#define spl1() _spl(PSL_S|PSL_IPL1)
133#define spl2() _spl(PSL_S|PSL_IPL2)
134#define spl3() _spl(PSL_S|PSL_IPL3)
135#define spl4() _spl(PSL_S|PSL_IPL4)
136#define spl5() _spl(PSL_S|PSL_IPL5)
137#define spl6() _spl(PSL_S|PSL_IPL6)
138#define spl7() _spl(PSL_S|PSL_IPL7)
139
ce0d9cf2
KM
140#define splsoftclock() spl1()
141#define splnet() spl1()
142#define splbio() spl5()
143#define splimp() spl5()
144#define spltty() spl5()
145#define splclock() spl6()
146#define splstatclock() spl6()
147#define splvm() spl6()
148#define splhigh() spl7()
149#define splsched() spl7()
98a9a1f2
MK
150
151/* watch out for side effects */
152#define splx(s) (s & PSL_IPL ? _spl(s) : spl0())
88a7e859
KM
153
154#ifdef KERNEL
155#ifndef LOCORE
156int cpuspeed;
157#define DELAY(n) { register int N = cpuspeed * (n); while (--N > 0); }
158#endif
ffbc6a8d 159#else
88a7e859 160#define DELAY(n) { register int N = (n); while (--N > 0); }
ffbc6a8d 161#endif
88a7e859
KM
162
163#ifdef HPUXCOMPAT
164/*
165 * Constants/macros for HPUX multiple mapping of user address space.
166 * Pages in the first 256Mb are mapped in at every 256Mb segment.
167 */
168#define HPMMMASK 0xF0000000
9acfa6cd 169#define ISHPMMADDR(v) \
b1c25049
MH
170 ((curproc->p_md.md_flags & MDP_HPUXMMAP) && \
171 ((unsigned)(v) & HPMMMASK) && \
9acfa6cd
MH
172 ((unsigned)(v) & HPMMMASK) != HPMMMASK)
173#define HPMMBASEADDR(v) \
174 ((unsigned)(v) & ~HPMMMASK)
88a7e859 175#endif