param.h revision 217354
1260684Skaiw/* $OpenBSD: param.h,v 1.11 1998/08/30 22:05:35 millert Exp $ */ 2260684Skaiw 3260684Skaiw/*- 4260684Skaiw * Copyright (c) 1988 University of Utah. 5260684Skaiw * Copyright (c) 1992, 1993 6260684Skaiw * The Regents of the University of California. All rights reserved. 7260684Skaiw * 8260684Skaiw * This code is derived from software contributed to Berkeley by 9260684Skaiw * the Systems Programming Group of the University of Utah Computer 10260684Skaiw * Science Department and Ralph Campbell. 11260684Skaiw * 12260684Skaiw * Redistribution and use in source and binary forms, with or without 13260684Skaiw * modification, are permitted provided that the following conditions 14260684Skaiw * are met: 15260684Skaiw * 1. Redistributions of source code must retain the above copyright 16260684Skaiw * notice, this list of conditions and the following disclaimer. 17260684Skaiw * 2. Redistributions in binary form must reproduce the above copyright 18260684Skaiw * notice, this list of conditions and the following disclaimer in the 19260684Skaiw * documentation and/or other materials provided with the distribution. 20260684Skaiw * 4. Neither the name of the University nor the names of its contributors 21260684Skaiw * may be used to endorse or promote products derived from this software 22260684Skaiw * without specific prior written permission. 23260684Skaiw * 24260684Skaiw * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25260684Skaiw * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26260684Skaiw * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27260684Skaiw * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28260684Skaiw * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29260684Skaiw * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30260684Skaiw * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31260684Skaiw * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32260684Skaiw * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33260684Skaiw * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34260684Skaiw * SUCH DAMAGE. 35260684Skaiw * 36260684Skaiw * from: Utah Hdr: machparam.h 1.11 89/08/14 37260684Skaiw * from: @(#)param.h 8.1 (Berkeley) 6/10/93 38260684Skaiw * JNPR: param.h,v 1.6.2.1 2007/09/10 07:49:36 girish 39260684Skaiw * $FreeBSD: head/sys/mips/include/param.h 217354 2011-01-13 15:17:29Z jchandra $ 40260684Skaiw */ 41260684Skaiw 42260684Skaiw#ifndef _MIPS_INCLUDE_PARAM_H_ 43260684Skaiw#define _MIPS_INCLUDE_PARAM_H_ 44260684Skaiw 45260684Skaiw#include <machine/_align.h> 46260684Skaiw 47260684Skaiw#include <sys/cdefs.h> 48260684Skaiw#ifdef _KERNEL 49260684Skaiw#ifndef _LOCORE 50260684Skaiw#include <machine/cpu.h> 51260684Skaiw#endif 52260684Skaiw#endif 53260684Skaiw 54260684Skaiw#define __PCI_REROUTE_INTERRUPT 55260684Skaiw 56260684Skaiw#ifndef MACHINE 57260684Skaiw#define MACHINE "mips" 58260684Skaiw#endif 59260684Skaiw#ifndef MACHINE_ARCH 60260684Skaiw#if _BYTE_ORDER == _BIG_ENDIAN 61260684Skaiw#ifdef __mips_n64 62260684Skaiw#define MACHINE_ARCH "mips64eb" 63260684Skaiw#elif defined(__mips_n32) 64260684Skaiw#define MACHINE_ARCH "mipsn32eb" 65260684Skaiw#else 66260684Skaiw#define MACHINE_ARCH "mipseb" 67260684Skaiw#endif 68260684Skaiw#else 69260684Skaiw#ifdef __mips_n64 70260684Skaiw#define MACHINE_ARCH "mips64el" 71260684Skaiw#elif defined(__mips_n32) 72260684Skaiw#define MACHINE_ARCH "mipsn32el" 73260684Skaiw#else 74260684Skaiw#define MACHINE_ARCH "mipsel" 75260684Skaiw#endif 76260684Skaiw#endif 77260684Skaiw#endif 78260684Skaiw 79260684Skaiw/* 80260684Skaiw * OBJFORMAT_NAMES is a comma-separated list of the object formats 81260684Skaiw * that are supported on the architecture. 82260684Skaiw */ 83260684Skaiw#define OBJFORMAT_NAMES "elf" 84260684Skaiw#define OBJFORMAT_DEFAULT "elf" 85260684Skaiw 86260684Skaiw#define MID_MACHINE 0 /* None but has to be defined */ 87260684Skaiw 88260684Skaiw#ifdef SMP 89260684Skaiw#define MAXSMPCPU 32 90260684Skaiw#define MAXCPU MAXSMPCPU 91260684Skaiw#else 92260684Skaiw#define MAXSMPCPU 1 93260684Skaiw#define MAXCPU 1 94260684Skaiw#endif 95260684Skaiw 96260684Skaiw/* 97260684Skaiw * Round p (pointer or byte index) up to a correctly-aligned value for all 98260684Skaiw * data types (int, long, ...). The result is u_int and must be cast to 99260684Skaiw * any desired pointer type. 100260684Skaiw */ 101260684Skaiw 102260684Skaiw#define ALIGNBYTES _ALIGNBYTES 103260684Skaiw#define ALIGN(p) _ALIGN(p) 104260684Skaiw/* 105260684Skaiw * ALIGNED_POINTER is a boolean macro that checks whether an address 106260684Skaiw * is valid to fetch data elements of type t from on this architecture. 107260684Skaiw * This does not reflect the optimal alignment, just the possibility 108260684Skaiw * (within reasonable limits). 109260684Skaiw */ 110260684Skaiw#define ALIGNED_POINTER(p, t) ((((unsigned long)(p)) & (sizeof (t) - 1)) == 0) 111260684Skaiw 112260684Skaiw/* 113260684Skaiw * CACHE_LINE_SIZE is the compile-time maximum cache line size for an 114260684Skaiw * architecture. It should be used with appropriate caution. 115260684Skaiw */ 116260684Skaiw#define CACHE_LINE_SHIFT 6 117260684Skaiw#define CACHE_LINE_SIZE (1 << CACHE_LINE_SHIFT) 118260684Skaiw 119260684Skaiw#define PAGE_SHIFT 12 /* LOG2(PAGE_SIZE) */ 120260684Skaiw#define PAGE_SIZE (1<<PAGE_SHIFT) /* bytes/page */ 121260684Skaiw#define PAGE_MASK (PAGE_SIZE-1) 122260684Skaiw 123260684Skaiw#define NPTEPG (PAGE_SIZE/(sizeof (pt_entry_t))) 124260684Skaiw#define NPDEPG (PAGE_SIZE/(sizeof (pd_entry_t))) 125260684Skaiw 126260684Skaiw#if defined(__mips_n32) || defined(__mips_n64) /* PHYSADDR_64_BIT */ 127260684Skaiw#define NPTEPGSHIFT 9 /* LOG2(NPTEPG) */ 128260684Skaiw#else 129260684Skaiw#define NPTEPGSHIFT 10 /* LOG2(NPTEPG) */ 130260684Skaiw#endif 131260684Skaiw 132260684Skaiw#ifdef __mips_n64 133260684Skaiw#define NPDEPGSHIFT 9 /* LOG2(NPTEPG) */ 134260684Skaiw#define SEGSHIFT (PAGE_SHIFT + NPTEPGSHIFT + NPDEPGSHIFT) 135260684Skaiw#define NBSEG (1ul << SEGSHIFT) 136260684Skaiw#define PDRSHIFT (PAGE_SHIFT + NPTEPGSHIFT) 137260684Skaiw#define PDRMASK ((1 << PDRSHIFT) - 1) 138260684Skaiw#else 139260684Skaiw#define NPDEPGSHIFT 10 /* LOG2(NPTEPG) */ 140260684Skaiw#define SEGSHIFT (PAGE_SHIFT + NPTEPGSHIFT) 141260684Skaiw#define NBSEG (1 << SEGSHIFT) /* bytes/segment */ 142260684Skaiw#define PDRSHIFT SEGSHIFT /* alias for SEG in 32 bit */ 143260684Skaiw#define PDRMASK ((1 << PDRSHIFT) - 1) 144260684Skaiw#endif 145260684Skaiw#define NBPDR (1 << PDRSHIFT) /* bytes/pagedir */ 146260684Skaiw#define SEGMASK (NBSEG - 1) /* byte offset into segment */ 147260684Skaiw 148260684Skaiw#define MAXPAGESIZES 1 /* max supported pagesizes */ 149260684Skaiw 150260684Skaiw#define BLKDEV_IOSIZE 2048 /* xxx: Why is this 1/2 page? */ 151260684Skaiw#define MAXDUMPPGS 1 /* xxx: why is this only one? */ 152260684Skaiw 153260684Skaiw/* 154260684Skaiw * The kernel stack needs to be aligned on a (PAGE_SIZE * 2) boundary. 155260684Skaiw */ 156260684Skaiw#define KSTACK_PAGES 2 /* kernel stack */ 157260684Skaiw#define KSTACK_GUARD_PAGES 2 /* pages of kstack guard; 0 disables */ 158260684Skaiw 159260684Skaiw#define UPAGES 2 160260684Skaiw 161260684Skaiw/* pages ("clicks") (4096 bytes) to disk blocks */ 162260684Skaiw#define ctod(x) ((x) << (PAGE_SHIFT - DEV_BSHIFT)) 163260684Skaiw#define dtoc(x) ((x) >> (PAGE_SHIFT - DEV_BSHIFT)) 164260684Skaiw 165260684Skaiw/* 166 * Map a ``block device block'' to a file system block. 167 * This should be device dependent, and should use the bsize 168 * field from the disk label. 169 * For now though just use DEV_BSIZE. 170 */ 171#define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 172 173/* 174 * Mach derived conversion macros 175 */ 176#define round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK) 177#define trunc_page(x) ((x) & ~PAGE_MASK) 178 179#define atop(x) ((x) >> PAGE_SHIFT) 180#define ptoa(x) ((x) << PAGE_SHIFT) 181 182#define pgtok(x) ((x) * (PAGE_SIZE / 1024)) 183 184#endif /* !_MIPS_INCLUDE_PARAM_H_ */ 185