param.h revision 233644
1178172Simp/* $OpenBSD: param.h,v 1.11 1998/08/30 22:05:35 millert Exp $ */ 2178172Simp 3178172Simp/*- 4178172Simp * Copyright (c) 1988 University of Utah. 5178172Simp * Copyright (c) 1992, 1993 6178172Simp * The Regents of the University of California. All rights reserved. 7178172Simp * 8178172Simp * This code is derived from software contributed to Berkeley by 9178172Simp * the Systems Programming Group of the University of Utah Computer 10178172Simp * Science Department and Ralph Campbell. 11178172Simp * 12178172Simp * Redistribution and use in source and binary forms, with or without 13178172Simp * modification, are permitted provided that the following conditions 14178172Simp * are met: 15178172Simp * 1. Redistributions of source code must retain the above copyright 16178172Simp * notice, this list of conditions and the following disclaimer. 17178172Simp * 2. Redistributions in binary form must reproduce the above copyright 18178172Simp * notice, this list of conditions and the following disclaimer in the 19178172Simp * documentation and/or other materials provided with the distribution. 20178172Simp * 4. Neither the name of the University nor the names of its contributors 21178172Simp * may be used to endorse or promote products derived from this software 22178172Simp * without specific prior written permission. 23178172Simp * 24178172Simp * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25178172Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26178172Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27178172Simp * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28178172Simp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29178172Simp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30178172Simp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31178172Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32178172Simp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33178172Simp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34178172Simp * SUCH DAMAGE. 35178172Simp * 36178172Simp * from: Utah Hdr: machparam.h 1.11 89/08/14 37178172Simp * from: @(#)param.h 8.1 (Berkeley) 6/10/93 38178172Simp * JNPR: param.h,v 1.6.2.1 2007/09/10 07:49:36 girish 39178172Simp * $FreeBSD: head/sys/mips/include/param.h 233644 2012-03-29 02:54:35Z jmallett $ 40178172Simp */ 41178172Simp 42196994Sphk#ifndef _MIPS_INCLUDE_PARAM_H_ 43196994Sphk#define _MIPS_INCLUDE_PARAM_H_ 44178172Simp 45196994Sphk#include <machine/_align.h> 46196994Sphk 47178172Simp#include <sys/cdefs.h> 48178172Simp#ifdef _KERNEL 49206717Sjmallett#ifndef _LOCORE 50178172Simp#include <machine/cpu.h> 51178172Simp#endif 52178172Simp#endif 53178172Simp 54178172Simp#define __PCI_REROUTE_INTERRUPT 55178172Simp 56178172Simp#ifndef MACHINE 57178172Simp#define MACHINE "mips" 58178172Simp#endif 59178172Simp#ifndef MACHINE_ARCH 60215971Sjmallett#if _BYTE_ORDER == _BIG_ENDIAN 61215971Sjmallett#ifdef __mips_n64 62233644Sjmallett#define MACHINE_ARCH "mips64" 63232449Sjmallett#ifndef MACHINE_ARCH32 64233644Sjmallett#define MACHINE_ARCH32 "mips" 65232449Sjmallett#endif 66215971Sjmallett#elif defined(__mips_n32) 67233644Sjmallett#define MACHINE_ARCH "mipsn32" 68215971Sjmallett#else 69233644Sjmallett#define MACHINE_ARCH "mips" 70178172Simp#endif 71215971Sjmallett#else 72215971Sjmallett#ifdef __mips_n64 73215971Sjmallett#define MACHINE_ARCH "mips64el" 74232449Sjmallett#ifndef MACHINE_ARCH32 75232449Sjmallett#define MACHINE_ARCH32 "mipsel" 76232449Sjmallett#endif 77215971Sjmallett#elif defined(__mips_n32) 78215971Sjmallett#define MACHINE_ARCH "mipsn32el" 79215971Sjmallett#else 80215971Sjmallett#define MACHINE_ARCH "mipsel" 81215971Sjmallett#endif 82215971Sjmallett#endif 83215971Sjmallett#endif 84178172Simp 85178172Simp/* 86178172Simp * OBJFORMAT_NAMES is a comma-separated list of the object formats 87178172Simp * that are supported on the architecture. 88178172Simp */ 89178172Simp#define OBJFORMAT_NAMES "elf" 90178172Simp#define OBJFORMAT_DEFAULT "elf" 91178172Simp 92178172Simp#define MID_MACHINE 0 /* None but has to be defined */ 93178172Simp 94178172Simp#ifdef SMP 95208165Srrs#define MAXSMPCPU 32 96224207Sattilio#ifndef MAXCPU 97178172Simp#define MAXCPU MAXSMPCPU 98224207Sattilio#endif 99178172Simp#else 100178172Simp#define MAXSMPCPU 1 101178172Simp#define MAXCPU 1 102178172Simp#endif 103178172Simp 104178172Simp/* 105178172Simp * Round p (pointer or byte index) up to a correctly-aligned value for all 106178172Simp * data types (int, long, ...). The result is u_int and must be cast to 107178172Simp * any desired pointer type. 108178172Simp */ 109178172Simp 110178172Simp#define ALIGNBYTES _ALIGNBYTES 111178172Simp#define ALIGN(p) _ALIGN(p) 112195376Ssam/* 113195376Ssam * ALIGNED_POINTER is a boolean macro that checks whether an address 114195376Ssam * is valid to fetch data elements of type t from on this architecture. 115195376Ssam * This does not reflect the optimal alignment, just the possibility 116195376Ssam * (within reasonable limits). 117195376Ssam */ 118202031Simp#define ALIGNED_POINTER(p, t) ((((unsigned long)(p)) & (sizeof (t) - 1)) == 0) 119178172Simp 120191278Srwatson/* 121191278Srwatson * CACHE_LINE_SIZE is the compile-time maximum cache line size for an 122191278Srwatson * architecture. It should be used with appropriate caution. 123191278Srwatson */ 124191276Srwatson#define CACHE_LINE_SHIFT 6 125191276Srwatson#define CACHE_LINE_SIZE (1 << CACHE_LINE_SHIFT) 126191276Srwatson 127217354Sjchandra#define PAGE_SHIFT 12 /* LOG2(PAGE_SIZE) */ 128217354Sjchandra#define PAGE_SIZE (1<<PAGE_SHIFT) /* bytes/page */ 129217354Sjchandra#define PAGE_MASK (PAGE_SIZE-1) 130210627Sjchandra 131217354Sjchandra#define NPTEPG (PAGE_SIZE/(sizeof (pt_entry_t))) 132217354Sjchandra#define NPDEPG (PAGE_SIZE/(sizeof (pd_entry_t))) 133178172Simp 134217354Sjchandra#if defined(__mips_n32) || defined(__mips_n64) /* PHYSADDR_64_BIT */ 135217354Sjchandra#define NPTEPGSHIFT 9 /* LOG2(NPTEPG) */ 136210846Sjchandra#else 137217354Sjchandra#define NPTEPGSHIFT 10 /* LOG2(NPTEPG) */ 138210846Sjchandra#endif 139210627Sjchandra 140217354Sjchandra#ifdef __mips_n64 141217354Sjchandra#define NPDEPGSHIFT 9 /* LOG2(NPTEPG) */ 142217354Sjchandra#define SEGSHIFT (PAGE_SHIFT + NPTEPGSHIFT + NPDEPGSHIFT) 143217354Sjchandra#define NBSEG (1ul << SEGSHIFT) 144217354Sjchandra#define PDRSHIFT (PAGE_SHIFT + NPTEPGSHIFT) 145217354Sjchandra#define PDRMASK ((1 << PDRSHIFT) - 1) 146217354Sjchandra#else 147217354Sjchandra#define NPDEPGSHIFT 10 /* LOG2(NPTEPG) */ 148217354Sjchandra#define SEGSHIFT (PAGE_SHIFT + NPTEPGSHIFT) 149217354Sjchandra#define NBSEG (1 << SEGSHIFT) /* bytes/segment */ 150217354Sjchandra#define PDRSHIFT SEGSHIFT /* alias for SEG in 32 bit */ 151217354Sjchandra#define PDRMASK ((1 << PDRSHIFT) - 1) 152217354Sjchandra#endif 153217354Sjchandra#define NBPDR (1 << PDRSHIFT) /* bytes/pagedir */ 154217354Sjchandra#define SEGMASK (NBSEG - 1) /* byte offset into segment */ 155197316Salc 156217354Sjchandra#define MAXPAGESIZES 1 /* max supported pagesizes */ 157178172Simp 158217354Sjchandra#define MAXDUMPPGS 1 /* xxx: why is this only one? */ 159217354Sjchandra 160178172Simp/* 161205072Sneel * The kernel stack needs to be aligned on a (PAGE_SIZE * 2) boundary. 162178172Simp */ 163210846Sjchandra#define KSTACK_PAGES 2 /* kernel stack */ 164206819Sjmallett#define KSTACK_GUARD_PAGES 2 /* pages of kstack guard; 0 disables */ 165178172Simp 166178172Simp#define UPAGES 2 167178172Simp 168178172Simp/* pages ("clicks") (4096 bytes) to disk blocks */ 169217354Sjchandra#define ctod(x) ((x) << (PAGE_SHIFT - DEV_BSHIFT)) 170217354Sjchandra#define dtoc(x) ((x) >> (PAGE_SHIFT - DEV_BSHIFT)) 171178172Simp 172178172Simp/* 173178172Simp * Map a ``block device block'' to a file system block. 174178172Simp * This should be device dependent, and should use the bsize 175178172Simp * field from the disk label. 176178172Simp * For now though just use DEV_BSIZE. 177178172Simp */ 178217354Sjchandra#define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 179178172Simp 180178172Simp/* 181206746Sjmallett * Mach derived conversion macros 182178172Simp */ 183217354Sjchandra#define round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK) 184217354Sjchandra#define trunc_page(x) ((x) & ~PAGE_MASK) 185178172Simp 186217354Sjchandra#define atop(x) ((x) >> PAGE_SHIFT) 187217354Sjchandra#define ptoa(x) ((x) << PAGE_SHIFT) 188178172Simp 189217354Sjchandra#define pgtok(x) ((x) * (PAGE_SIZE / 1024)) 190206746Sjmallett 191196994Sphk#endif /* !_MIPS_INCLUDE_PARAM_H_ */ 192