159191Skris/*	$OpenBSD: param.h,v 1.11 1998/08/30 22:05:35 millert Exp $ */
259191Skris
359191Skris/*-
459191Skris * Copyright (c) 1988 University of Utah.
568651Skris * Copyright (c) 1992, 1993
659191Skris *	The Regents of the University of California.  All rights reserved.
759191Skris *
859191Skris * This code is derived from software contributed to Berkeley by
959191Skris * the Systems Programming Group of the University of Utah Computer
1059191Skris * Science Department and Ralph Campbell.
11160814Ssimon *
1259191Skris * Redistribution and use in source and binary forms, with or without
1359191Skris * modification, are permitted provided that the following conditions
1459191Skris * are met:
1559191Skris * 1. Redistributions of source code must retain the above copyright
16100936Snectar *    notice, this list of conditions and the following disclaimer.
1772613Skris * 2. Redistributions in binary form must reproduce the above copyright
1872613Skris *    notice, this list of conditions and the following disclaimer in the
1959191Skris *    documentation and/or other materials provided with the distribution.
2059191Skris * 4. Neither the name of the University nor the names of its contributors
2159191Skris *    may be used to endorse or promote products derived from this software
2259191Skris *    without specific prior written permission.
2368651Skris *
2459191Skris * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2568651Skris * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2659191Skris * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2759191Skris * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2859191Skris * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2959191Skris * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3059191Skris * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3159191Skris * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3259191Skris * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3359191Skris * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3459191Skris * SUCH DAMAGE.
3559191Skris *
3668651Skris *	from: Utah Hdr: machparam.h 1.11 89/08/14
3759191Skris *	from: @(#)param.h	8.1 (Berkeley) 6/10/93
3859191Skris *	JNPR: param.h,v 1.6.2.1 2007/09/10 07:49:36 girish
3959191Skris * $FreeBSD$
4059191Skris */
41312826Sjkim
42312826Sjkim#ifndef _MIPS_INCLUDE_PARAM_H_
43312826Sjkim#define	_MIPS_INCLUDE_PARAM_H_
44312826Sjkim
45312826Sjkim#include <machine/_align.h>
46312826Sjkim
4759191Skris#include <sys/cdefs.h>
48312826Sjkim#ifdef _KERNEL
4959191Skris#ifndef _LOCORE
5059191Skris#include <machine/cpu.h>
5168651Skris#endif
5272613Skris#endif
5372613Skris
5472613Skris#define __PCI_REROUTE_INTERRUPT
5572613Skris
5672613Skris#ifndef MACHINE
5772613Skris#define	MACHINE		"mips"
5872613Skris#endif
5972613Skris#ifndef MACHINE_ARCH
6072613Skris#if _BYTE_ORDER == _BIG_ENDIAN
6159191Skris#ifdef __mips_n64
6272613Skris#define	MACHINE_ARCH	"mips64"
6372613Skris#ifndef	MACHINE_ARCH32
6472613Skris#define	MACHINE_ARCH32	"mips"
6572613Skris#endif
6668651Skris#elif defined(__mips_n32)
6772613Skris#define	MACHINE_ARCH	"mipsn32"
6872613Skris#else
6972613Skris#define	MACHINE_ARCH	"mips"
7072613Skris#endif
7172613Skris#else
7259191Skris#ifdef __mips_n64
7389837Skris#define	MACHINE_ARCH	"mips64el"
7479998Skris#ifndef	MACHINE_ARCH32
7579998Skris#define	MACHINE_ARCH32	"mipsel"
7679998Skris#endif
7789837Skris#elif defined(__mips_n32)
7889837Skris#define	MACHINE_ARCH	"mipsn32el"
7989837Skris#else
8079998Skris#define	MACHINE_ARCH	"mipsel"
8179998Skris#endif
8279998Skris#endif
8379998Skris#endif
8459191Skris
8559191Skris/*
8659191Skris * OBJFORMAT_NAMES is a comma-separated list of the object formats
8759191Skris * that are supported on the architecture.
8868651Skris */
8959191Skris#define	OBJFORMAT_NAMES		"elf"
9059191Skris#define	OBJFORMAT_DEFAULT	"elf"
9159191Skris
9259191Skris#define	MID_MACHINE	0	/* None but has to be defined */
93344604Sjkim
94344604Sjkim#ifdef SMP
95344604Sjkim#define	MAXSMPCPU	32
96344604Sjkim#ifndef MAXCPU
9759191Skris#define	MAXCPU		MAXSMPCPU
9859191Skris#endif
9959191Skris#else
100344604Sjkim#define	MAXSMPCPU	1
101344604Sjkim#define	MAXCPU		1
102344604Sjkim#endif
103344604Sjkim
10459191Skris#ifndef MAXMEMDOM
10559191Skris#define	MAXMEMDOM	1
10659191Skris#endif
10759191Skris
10859191Skris/*
10959191Skris * Round p (pointer or byte index) up to a correctly-aligned value for all
11059191Skris * data types (int, long, ...).	  The result is u_int and must be cast to
11159191Skris * any desired pointer type.
11259191Skris */
11359191Skris
11459191Skris#define	ALIGNBYTES	_ALIGNBYTES
11559191Skris#define	ALIGN(p)	_ALIGN(p)
116/*
117 * ALIGNED_POINTER is a boolean macro that checks whether an address
118 * is valid to fetch data elements of type t from on this architecture.
119 * This does not reflect the optimal alignment, just the possibility
120 * (within reasonable limits).
121 */
122#define	ALIGNED_POINTER(p, t)	((((unsigned long)(p)) & (sizeof (t) - 1)) == 0)
123
124/*
125 * CACHE_LINE_SIZE is the compile-time maximum cache line size for an
126 * architecture.  It should be used with appropriate caution.
127 */
128#define	CACHE_LINE_SHIFT	6
129#define	CACHE_LINE_SIZE		(1 << CACHE_LINE_SHIFT)
130
131#define	PAGE_SHIFT		12		/* LOG2(PAGE_SIZE) */
132#define	PAGE_SIZE		(1<<PAGE_SHIFT) /* bytes/page */
133#define	PAGE_MASK		(PAGE_SIZE-1)
134
135#define	NPTEPG			(PAGE_SIZE/(sizeof (pt_entry_t)))
136#define	NPDEPG			(PAGE_SIZE/(sizeof (pd_entry_t)))
137
138#if defined(__mips_n32) || defined(__mips_n64) /*  PHYSADDR_64_BIT */
139#define	NPTEPGSHIFT		9               /* LOG2(NPTEPG) */
140#else
141#define	NPTEPGSHIFT		10               /* LOG2(NPTEPG) */
142#endif
143
144#ifdef __mips_n64
145#define	NPDEPGSHIFT		9               /* LOG2(NPTEPG) */
146#define	SEGSHIFT		(PAGE_SHIFT + NPTEPGSHIFT + NPDEPGSHIFT)
147#define	NBSEG			(1ul << SEGSHIFT)
148#define	PDRSHIFT		(PAGE_SHIFT + NPTEPGSHIFT)
149#define	PDRMASK			((1 << PDRSHIFT) - 1)
150#else
151#define	NPDEPGSHIFT		10               /* LOG2(NPTEPG) */
152#define	SEGSHIFT		(PAGE_SHIFT + NPTEPGSHIFT)
153#define	NBSEG			(1 << SEGSHIFT)	/* bytes/segment */
154#define	PDRSHIFT		SEGSHIFT	/* alias for SEG in 32 bit */
155#define	PDRMASK			((1 << PDRSHIFT) - 1)
156#endif
157#define	NBPDR			(1 << PDRSHIFT)	/* bytes/pagedir */
158#define	SEGMASK			(NBSEG - 1)	/* byte offset into segment */
159
160#define	MAXPAGESIZES		1		/* max supported pagesizes */
161
162#define	MAXDUMPPGS		1		/* xxx: why is this only one? */
163
164/*
165 * The kernel stack needs to be aligned on a (PAGE_SIZE * 2) boundary.
166 */
167#define	KSTACK_PAGES		2	/* kernel stack */
168#define	KSTACK_GUARD_PAGES	2	/* pages of kstack guard; 0 disables */
169
170/*
171 * Mach derived conversion macros
172 */
173#define	round_page(x)		(((x) + PAGE_MASK) & ~PAGE_MASK)
174#define	trunc_page(x)		((x) & ~PAGE_MASK)
175
176#define	atop(x)			((x) >> PAGE_SHIFT)
177#define	ptoa(x)			((x) << PAGE_SHIFT)
178
179#define	pgtok(x)		((x) * (PAGE_SIZE / 1024))
180
181#endif /* !_MIPS_INCLUDE_PARAM_H_ */
182