xref: /freebsd-12.1/sys/mips/include/param.h (revision cf771f22)
1 /*	$OpenBSD: param.h,v 1.11 1998/08/30 22:05:35 millert Exp $ */
2 
3 /*-
4  * Copyright (c) 1988 University of Utah.
5  * Copyright (c) 1992, 1993
6  *	The Regents of the University of California.  All rights reserved.
7  *
8  * This code is derived from software contributed to Berkeley by
9  * the Systems Programming Group of the University of Utah Computer
10  * Science Department and Ralph Campbell.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  * 4. Neither the name of the University nor the names of its contributors
21  *    may be used to endorse or promote products derived from this software
22  *    without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGE.
35  *
36  *	from: Utah Hdr: machparam.h 1.11 89/08/14
37  *	from: @(#)param.h	8.1 (Berkeley) 6/10/93
38  *	JNPR: param.h,v 1.6.2.1 2007/09/10 07:49:36 girish
39  * $FreeBSD$
40  */
41 
42 #ifndef _MIPS_INCLUDE_PARAM_H_
43 #define	_MIPS_INCLUDE_PARAM_H_
44 
45 #include <machine/_align.h>
46 
47 #include <sys/cdefs.h>
48 #ifdef _KERNEL
49 #ifndef _LOCORE
50 #include <machine/cpu.h>
51 #endif
52 #endif
53 
54 #define __PCI_REROUTE_INTERRUPT
55 
56 #ifndef MACHINE
57 #define	MACHINE		"mips"
58 #endif
59 #ifndef MACHINE_ARCH
60 #if _BYTE_ORDER == _BIG_ENDIAN
61 #ifdef __mips_n64
62 #define	MACHINE_ARCH	"mips64"
63 #ifndef	MACHINE_ARCH32
64 #define	MACHINE_ARCH32	"mips"
65 #endif
66 #elif defined(__mips_n32)
67 #define	MACHINE_ARCH	"mipsn32"
68 #else
69 #define	MACHINE_ARCH	"mips"
70 #endif
71 #else
72 #ifdef __mips_n64
73 #define	MACHINE_ARCH	"mips64el"
74 #ifndef	MACHINE_ARCH32
75 #define	MACHINE_ARCH32	"mipsel"
76 #endif
77 #elif defined(__mips_n32)
78 #define	MACHINE_ARCH	"mipsn32el"
79 #else
80 #define	MACHINE_ARCH	"mipsel"
81 #endif
82 #endif
83 #endif
84 
85 /*
86  * OBJFORMAT_NAMES is a comma-separated list of the object formats
87  * that are supported on the architecture.
88  */
89 #define	OBJFORMAT_NAMES		"elf"
90 #define	OBJFORMAT_DEFAULT	"elf"
91 
92 #define	MID_MACHINE	0	/* None but has to be defined */
93 
94 #ifdef SMP
95 #define	MAXSMPCPU	32
96 #ifndef MAXCPU
97 #define	MAXCPU		MAXSMPCPU
98 #endif
99 #else
100 #define	MAXSMPCPU	1
101 #define	MAXCPU		1
102 #endif
103 
104 /*
105  * Round p (pointer or byte index) up to a correctly-aligned value for all
106  * data types (int, long, ...).	  The result is u_int and must be cast to
107  * any desired pointer type.
108  */
109 
110 #define	ALIGNBYTES	_ALIGNBYTES
111 #define	ALIGN(p)	_ALIGN(p)
112 /*
113  * ALIGNED_POINTER is a boolean macro that checks whether an address
114  * is valid to fetch data elements of type t from on this architecture.
115  * This does not reflect the optimal alignment, just the possibility
116  * (within reasonable limits).
117  */
118 #define	ALIGNED_POINTER(p, t)	((((unsigned long)(p)) & (sizeof (t) - 1)) == 0)
119 
120 /*
121  * CACHE_LINE_SIZE is the compile-time maximum cache line size for an
122  * architecture.  It should be used with appropriate caution.
123  */
124 #define	CACHE_LINE_SHIFT	6
125 #define	CACHE_LINE_SIZE		(1 << CACHE_LINE_SHIFT)
126 
127 #define	PAGE_SHIFT		12		/* LOG2(PAGE_SIZE) */
128 #define	PAGE_SIZE		(1<<PAGE_SHIFT) /* bytes/page */
129 #define	PAGE_MASK		(PAGE_SIZE-1)
130 
131 #define	NPTEPG			(PAGE_SIZE/(sizeof (pt_entry_t)))
132 #define	NPDEPG			(PAGE_SIZE/(sizeof (pd_entry_t)))
133 
134 #if defined(__mips_n32) || defined(__mips_n64) /*  PHYSADDR_64_BIT */
135 #define	NPTEPGSHIFT		9               /* LOG2(NPTEPG) */
136 #else
137 #define	NPTEPGSHIFT		10               /* LOG2(NPTEPG) */
138 #endif
139 
140 #ifdef __mips_n64
141 #define	NPDEPGSHIFT		9               /* LOG2(NPTEPG) */
142 #define	SEGSHIFT		(PAGE_SHIFT + NPTEPGSHIFT + NPDEPGSHIFT)
143 #define	NBSEG			(1ul << SEGSHIFT)
144 #define	PDRSHIFT		(PAGE_SHIFT + NPTEPGSHIFT)
145 #define	PDRMASK			((1 << PDRSHIFT) - 1)
146 #else
147 #define	NPDEPGSHIFT		10               /* LOG2(NPTEPG) */
148 #define	SEGSHIFT		(PAGE_SHIFT + NPTEPGSHIFT)
149 #define	NBSEG			(1 << SEGSHIFT)	/* bytes/segment */
150 #define	PDRSHIFT		SEGSHIFT	/* alias for SEG in 32 bit */
151 #define	PDRMASK			((1 << PDRSHIFT) - 1)
152 #endif
153 #define	NBPDR			(1 << PDRSHIFT)	/* bytes/pagedir */
154 #define	SEGMASK			(NBSEG - 1)	/* byte offset into segment */
155 
156 #define	MAXPAGESIZES		1		/* max supported pagesizes */
157 
158 #define	MAXDUMPPGS		1		/* xxx: why is this only one? */
159 
160 /*
161  * The kernel stack needs to be aligned on a (PAGE_SIZE * 2) boundary.
162  */
163 #define	KSTACK_PAGES		2	/* kernel stack */
164 #define	KSTACK_GUARD_PAGES	2	/* pages of kstack guard; 0 disables */
165 
166 #define	UPAGES			2
167 
168 /* pages ("clicks") (4096 bytes) to disk blocks */
169 #define	ctod(x)			((x) << (PAGE_SHIFT - DEV_BSHIFT))
170 #define	dtoc(x)			((x) >> (PAGE_SHIFT - DEV_BSHIFT))
171 
172 /*
173  * Map a ``block device block'' to a file system block.
174  * This should be device dependent, and should use the bsize
175  * field from the disk label.
176  * For now though just use DEV_BSIZE.
177  */
178 #define	bdbtofsb(bn)		((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
179 
180 /*
181  * Mach derived conversion macros
182  */
183 #define	round_page(x)		(((x) + PAGE_MASK) & ~PAGE_MASK)
184 #define	trunc_page(x)		((x) & ~PAGE_MASK)
185 
186 #define	atop(x)			((x) >> PAGE_SHIFT)
187 #define	ptoa(x)			((x) << PAGE_SHIFT)
188 
189 #define	pgtok(x)		((x) * (PAGE_SIZE / 1024))
190 
191 #endif /* !_MIPS_INCLUDE_PARAM_H_ */
192