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