]> CyberLeo.Net >> Repos - FreeBSD/releng/8.2.git/blob - sys/mips/include/param.h
Copy stable/8 to releng/8.2 in preparation for FreeBSD-8.2 release.
[FreeBSD/releng/8.2.git] / sys / mips / include / param.h
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 _MACHINE_PARAM_H_
43 #define _MACHINE_PARAM_H_
44
45 #include <sys/cdefs.h>
46 #ifdef _KERNEL
47 #ifndef _LOCORE
48 #include <machine/cpu.h>
49 #endif
50 #endif
51
52 #define __PCI_REROUTE_INTERRUPT
53
54 #ifndef MACHINE
55 #define MACHINE         "mips"
56 #endif
57 #ifndef MACHINE_ARCH
58 #define MACHINE_ARCH    "mips"
59 #endif
60
61 /*
62  * OBJFORMAT_NAMES is a comma-separated list of the object formats
63  * that are supported on the architecture.
64  */
65 #define OBJFORMAT_NAMES         "elf"
66 #define OBJFORMAT_DEFAULT       "elf"
67
68 #define MID_MACHINE     0       /* None but has to be defined */
69
70 #ifdef SMP
71 #define MAXSMPCPU       32
72 #define MAXCPU          MAXSMPCPU
73 #else
74 #define MAXSMPCPU       1
75 #define MAXCPU          1
76 #endif
77
78 /*
79  * Round p (pointer or byte index) up to a correctly-aligned value for all
80  * data types (int, long, ...).   The result is u_int and must be cast to
81  * any desired pointer type.
82  */
83 #define _ALIGNBYTES     7
84 #define _ALIGN(p)       (((u_int)(p) + _ALIGNBYTES) &~ _ALIGNBYTES)
85
86 #define ALIGNBYTES      _ALIGNBYTES
87 #define ALIGN(p)        _ALIGN(p)
88 /*
89  * ALIGNED_POINTER is a boolean macro that checks whether an address
90  * is valid to fetch data elements of type t from on this architecture.
91  * This does not reflect the optimal alignment, just the possibility
92  * (within reasonable limits). 
93  */
94 #define ALIGNED_POINTER(p, t)   ((((unsigned long)(p)) & (sizeof (t) - 1)) == 0)
95
96 /*
97  * CACHE_LINE_SIZE is the compile-time maximum cache line size for an
98  * architecture.  It should be used with appropriate caution.
99  */
100 #define CACHE_LINE_SHIFT        6
101 #define CACHE_LINE_SIZE         (1 << CACHE_LINE_SHIFT)
102
103 #define PAGE_SHIFT      12              /* LOG2(PAGE_SIZE) */
104 #define PAGE_SIZE       (1<<PAGE_SHIFT) /* bytes/page */
105 #define PAGE_MASK       (PAGE_SIZE-1)
106
107 #define NPTEPG          (PAGE_SIZE/(sizeof (pt_entry_t)))
108 #define NPDEPG          (PAGE_SIZE/(sizeof (pd_entry_t)))
109
110 #if defined(__mips_n64)
111 #define SEGSHIFT        31              /* LOG2(NBSEG) */
112 #define NBSEG           (1ul << SEGSHIFT)       /* bytes/segment */
113 #define PDRSHIFT        22              /* second level */
114 #define PDRMASK         ((1 << PDRSHIFT) - 1)
115 #else
116 #define SEGSHIFT        22              /* LOG2(NBSEG) */
117 #define NBSEG           (1 << SEGSHIFT) /* bytes/segment */
118 #define PDRSHIFT        SEGSHIFT        /* alias for SEG in 32 bit */
119 #define PDRMASK         ((1 << PDRSHIFT) - 1)
120 #endif
121 #define NBPDR           (1 << PDRSHIFT) /* bytes/pagedir */
122 #define SEGMASK         (NBSEG-1)       /* byte offset into segment */
123
124 #define MAXPAGESIZES    1               /* maximum number of supported page sizes */
125
126 #define BLKDEV_IOSIZE   2048            /* xxx: Why is this 1/2 page? */
127 #define MAXDUMPPGS      1               /* xxx: why is this only one? */
128
129 /*
130  * The kernel stack needs to be aligned on a (PAGE_SIZE * 2) boundary.
131  */
132 #define KSTACK_PAGES            2       /* kernel stack */
133 #define KSTACK_GUARD_PAGES      2       /* pages of kstack guard; 0 disables */
134
135 #define UPAGES                  2
136
137 /* pages ("clicks") (4096 bytes) to disk blocks */
138 #define ctod(x)         ((x) << (PAGE_SHIFT - DEV_BSHIFT))
139 #define dtoc(x)         ((x) >> (PAGE_SHIFT - DEV_BSHIFT))
140
141 /*
142  * Map a ``block device block'' to a file system block.
143  * This should be device dependent, and should use the bsize
144  * field from the disk label.
145  * For now though just use DEV_BSIZE.
146  */
147 #define bdbtofsb(bn)    ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
148
149 /*
150  * Mach derived conversion macros
151  */
152 #define round_page(x)           (((unsigned long)(x) + PAGE_MASK) & ~PAGE_MASK)
153 #define trunc_page(x)           ((unsigned long)(x) & ~PAGE_MASK)
154
155 #define atop(x)                 ((unsigned long)(x) >> PAGE_SHIFT)
156 #define ptoa(x)                 ((unsigned long)(x) << PAGE_SHIFT)
157
158 #define mips_btop(x)            ((unsigned long)(x) >> PAGE_SHIFT)
159 #define mips_ptob(x)            ((unsigned long)(x) << PAGE_SHIFT)
160
161 #define pgtok(x)                ((unsigned long)(x) * (PAGE_SIZE / 1024))
162
163 #ifndef _KERNEL
164 #define DELAY(n)        { register int N = (n); while (--N > 0); }
165 #endif /* !_KERNEL */
166
167 #endif /* !_MACHINE_PARAM_H_ */