param.h revision 205072
1139749Simp/*	$OpenBSD: param.h,v 1.11 1998/08/30 22:05:35 millert Exp $ */
265832Snyan
365832Snyan/*-
465832Snyan * Copyright (c) 1988 University of Utah.
565832Snyan * Copyright (c) 1992, 1993
665832Snyan *	The Regents of the University of California.  All rights reserved.
765832Snyan *
865832Snyan * This code is derived from software contributed to Berkeley by
965832Snyan * the Systems Programming Group of the University of Utah Computer
1065832Snyan * Science Department and Ralph Campbell.
1165832Snyan *
1265832Snyan * Redistribution and use in source and binary forms, with or without
1365832Snyan * modification, are permitted provided that the following conditions
1465832Snyan * are met:
1565832Snyan * 1. Redistributions of source code must retain the above copyright
1665832Snyan *    notice, this list of conditions and the following disclaimer.
1765832Snyan * 2. Redistributions in binary form must reproduce the above copyright
1865832Snyan *    notice, this list of conditions and the following disclaimer in the
1965832Snyan *    documentation and/or other materials provided with the distribution.
2065832Snyan * 4. Neither the name of the University nor the names of its contributors
2165832Snyan *    may be used to endorse or promote products derived from this software
2265832Snyan *    without specific prior written permission.
2365832Snyan *
24119418Sobrien * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25119418Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26119418Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2765832Snyan * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2865832Snyan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2965832Snyan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3067158Sphk * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3165832Snyan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3265832Snyan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3365832Snyan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3465832Snyan * SUCH DAMAGE.
35140543Simp *
3665832Snyan *	from: Utah Hdr: machparam.h 1.11 89/08/14
3765832Snyan *	from: @(#)param.h	8.1 (Berkeley) 6/10/93
3865832Snyan *	JNPR: param.h,v 1.6.2.1 2007/09/10 07:49:36 girish
3965832Snyan * $FreeBSD: head/sys/mips/include/param.h 205072 2010-03-12 07:08:20Z neel $
4065832Snyan */
4165832Snyan
4265832Snyan#ifndef _MIPS_INCLUDE_PARAM_H_
4365832Snyan#define	_MIPS_INCLUDE_PARAM_H_
4465832Snyan
45142135Simp#include <machine/_align.h>
4665832Snyan
4765832Snyan#include <sys/cdefs.h>
4865832Snyan#ifdef _KERNEL
4965832Snyan#ifdef _LOCORE
50140528Simp#include <machine/psl.h>
51129764Simp#else
52129764Simp#include <machine/cpu.h>
53129740Simp#endif
5465832Snyan#endif
5565832Snyan
56150458Simp#define __PCI_REROUTE_INTERRUPT
5765832Snyan
5865832Snyan#ifndef MACHINE
5965832Snyan#define	MACHINE		"mips"
6065832Snyan#endif
6165832Snyan#ifndef MACHINE_ARCH
6282778Sshiba#define	MACHINE_ARCH	"mips"
6382778Sshiba#endif
64140041Simp
65140543Simp/*
66151638Simp * OBJFORMAT_NAMES is a comma-separated list of the object formats
67189681Simp * that are supported on the architecture.
6882778Sshiba */
69140041Simp#define	OBJFORMAT_NAMES		"elf"
70147580Simp#define	OBJFORMAT_DEFAULT	"elf"
71147580Simp
72147580Simp#define	MID_MACHINE	0	/* None but has to be defined */
73147580Simp
74140041Simp#ifdef SMP
75147580Simp#define	MAXSMPCPU	16
76147580Simp#define	MAXCPU		MAXSMPCPU
7782778Sshiba#else
78147580Simp#define	MAXSMPCPU	1
7982778Sshiba#define	MAXCPU		1
80147580Simp#endif
81147580Simp
82147580Simp/*
83147580Simp * Round p (pointer or byte index) up to a correctly-aligned value for all
84189681Simp * data types (int, long, ...).	  The result is u_int and must be cast to
85147580Simp * any desired pointer type.
86151638Simp */
8782778Sshiba
8882778Sshiba#define	ALIGNBYTES	_ALIGNBYTES
8982778Sshiba#define	ALIGN(p)	_ALIGN(p)
9082778Sshiba/*
91150396Simp * ALIGNED_POINTER is a boolean macro that checks whether an address
9282778Sshiba * is valid to fetch data elements of type t from on this architecture.
93140528Simp * This does not reflect the optimal alignment, just the possibility
94140528Simp * (within reasonable limits).
95151638Simp */
96189681Simp#define	ALIGNED_POINTER(p, t)	((((unsigned long)(p)) & (sizeof (t) - 1)) == 0)
9782778Sshiba
98151638Simp/*
9982778Sshiba * CACHE_LINE_SIZE is the compile-time maximum cache line size for an
10082778Sshiba * architecture.  It should be used with appropriate caution.
101151638Simp */
102151638Simp#define	CACHE_LINE_SHIFT	6
103151638Simp#define	CACHE_LINE_SIZE		(1 << CACHE_LINE_SHIFT)
104151638Simp
105151638Simp#define	NBPG		4096		/* bytes/page */
106151638Simp#define	PGOFSET		(NBPG-1)	/* byte offset into page */
107151638Simp#define	PGSHIFT		12		/* LOG2(NBPG) */
108151638Simp
109151638Simp#define	PAGE_SHIFT	12		/* LOG2(PAGE_SIZE) */
110151638Simp#define	PAGE_SIZE	(1<<PAGE_SHIFT) /* bytes/page */
111189681Simp#define	PAGE_MASK	(PAGE_SIZE-1)
112189681Simp#define	NPTEPG		(PAGE_SIZE/(sizeof (pt_entry_t)))
113189681Simp
114189681Simp#define	NBSEG		0x400000	/* bytes/segment */
115189681Simp#define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
116189681Simp#define	SEGSHIFT	22		/* LOG2(NBSEG) */
117189681Simp
118189681Simp#define	MAXPAGESIZES	1		/* maximum number of supported page sizes */
119189681Simp
120189681Simp/* XXXimp: This has moved to vmparam.h */
121152621Simp/* Also, this differs from the mips2 definition, but likely is better */
12282778Sshiba/* since this means the kernel won't chew up TLBs when it is executing */
123151638Simp/* code */
12482778Sshiba#define	KERNBASE	0x80000000	/* start of kernel virtual */
12582778Sshiba#define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
12665832Snyan
12782778Sshiba#define	BLKDEV_IOSIZE	2048		/* xxx: Why is this 1/2 page? */
128150396Simp#define	MAXDUMPPGS	1		/* xxx: why is this only one? */
129150396Simp
13082778Sshiba/*
13165832Snyan * The kernel stack needs to be aligned on a (PAGE_SIZE * 2) boundary.
13265832Snyan *
13365832Snyan * Although we allocate 3 pages for the kernel stack we end up using
13465832Snyan * only the 2 pages that are aligned on a (PAGE_SIZE * 2) boundary.
13565832Snyan */
13665832Snyan#define	KSTACK_PAGES		3	/* kernel stack*/
13765832Snyan#define	KSTACK_GUARD_PAGES	1	/* pages of kstack guard; 0 disables */
13865832Snyan
13965832Snyan#define	UPAGES			2
14065832Snyan
14165832Snyan/* pages ("clicks") (4096 bytes) to disk blocks */
142189681Simp#define	ctod(x)		((x) << (PGSHIFT - DEV_BSHIFT))
14365832Snyan#define	dtoc(x)		((x) >> (PGSHIFT - DEV_BSHIFT))
144140543Simp
145140543Simp/*
14665832Snyan * Map a ``block device block'' to a file system block.
14765832Snyan * This should be device dependent, and should use the bsize
14865832Snyan * field from the disk label.
14965832Snyan * For now though just use DEV_BSIZE.
150150396Simp */
15165832Snyan#define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
15265832Snyan
153140543Simp/*
15465832Snyan * Conversion macros
15565832Snyan */
15665832Snyan#define	mips_round_page(x)	((((unsigned long)(x)) + NBPG - 1) & ~(NBPG-1))
15765832Snyan#define	mips_trunc_page(x)	((unsigned long)(x) & ~(NBPG-1))
15865832Snyan#define	mips_btop(x)		((unsigned long)(x) >> PGSHIFT)
15965832Snyan#define	mips_ptob(x)		((unsigned long)(x) << PGSHIFT)
160140543Simp#define	round_page		mips_round_page
161140543Simp#define	trunc_page		mips_trunc_page
162140543Simp#define	atop(x)			((unsigned long)(x) >> PAGE_SHIFT)
163140543Simp#define	ptoa(x)			((unsigned long)(x) << PAGE_SHIFT)
164140543Simp
16565832Snyan#define	pgtok(x)		((x) * (PAGE_SIZE / 1024))
166140543Simp
167140543Simp#ifndef _KERNEL
168140543Simp#define	DELAY(n)	{ register int N = (n); while (--N > 0); }
169140543Simp#endif /* !_KERNEL */
170150396Simp
171150396Simp#endif /* !_MIPS_INCLUDE_PARAM_H_ */
172150396Simp