param.h revision 205072
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 205072 2010-03-12 07:08:20Z neel $
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
49178172Simp#ifdef _LOCORE
50178172Simp#include <machine/psl.h>
51178172Simp#else
52178172Simp#include <machine/cpu.h>
53178172Simp#endif
54178172Simp#endif
55178172Simp
56178172Simp#define __PCI_REROUTE_INTERRUPT
57178172Simp
58178172Simp#ifndef MACHINE
59178172Simp#define	MACHINE		"mips"
60178172Simp#endif
61178172Simp#ifndef MACHINE_ARCH
62178172Simp#define	MACHINE_ARCH	"mips"
63178172Simp#endif
64178172Simp
65178172Simp/*
66178172Simp * OBJFORMAT_NAMES is a comma-separated list of the object formats
67178172Simp * that are supported on the architecture.
68178172Simp */
69178172Simp#define	OBJFORMAT_NAMES		"elf"
70178172Simp#define	OBJFORMAT_DEFAULT	"elf"
71178172Simp
72178172Simp#define	MID_MACHINE	0	/* None but has to be defined */
73178172Simp
74178172Simp#ifdef SMP
75178172Simp#define	MAXSMPCPU	16
76178172Simp#define	MAXCPU		MAXSMPCPU
77178172Simp#else
78178172Simp#define	MAXSMPCPU	1
79178172Simp#define	MAXCPU		1
80178172Simp#endif
81178172Simp
82178172Simp/*
83178172Simp * Round p (pointer or byte index) up to a correctly-aligned value for all
84178172Simp * data types (int, long, ...).	  The result is u_int and must be cast to
85178172Simp * any desired pointer type.
86178172Simp */
87178172Simp
88178172Simp#define	ALIGNBYTES	_ALIGNBYTES
89178172Simp#define	ALIGN(p)	_ALIGN(p)
90195376Ssam/*
91195376Ssam * ALIGNED_POINTER is a boolean macro that checks whether an address
92195376Ssam * is valid to fetch data elements of type t from on this architecture.
93195376Ssam * This does not reflect the optimal alignment, just the possibility
94195376Ssam * (within reasonable limits).
95195376Ssam */
96202031Simp#define	ALIGNED_POINTER(p, t)	((((unsigned long)(p)) & (sizeof (t) - 1)) == 0)
97178172Simp
98191278Srwatson/*
99191278Srwatson * CACHE_LINE_SIZE is the compile-time maximum cache line size for an
100191278Srwatson * architecture.  It should be used with appropriate caution.
101191278Srwatson */
102191276Srwatson#define	CACHE_LINE_SHIFT	6
103191276Srwatson#define	CACHE_LINE_SIZE		(1 << CACHE_LINE_SHIFT)
104191276Srwatson
105178172Simp#define	NBPG		4096		/* bytes/page */
106178172Simp#define	PGOFSET		(NBPG-1)	/* byte offset into page */
107178172Simp#define	PGSHIFT		12		/* LOG2(NBPG) */
108178172Simp
109178172Simp#define	PAGE_SHIFT	12		/* LOG2(PAGE_SIZE) */
110178172Simp#define	PAGE_SIZE	(1<<PAGE_SHIFT) /* bytes/page */
111178172Simp#define	PAGE_MASK	(PAGE_SIZE-1)
112178172Simp#define	NPTEPG		(PAGE_SIZE/(sizeof (pt_entry_t)))
113178172Simp
114178172Simp#define	NBSEG		0x400000	/* bytes/segment */
115178172Simp#define	SEGOFSET	(NBSEG-1)	/* byte offset into segment */
116178172Simp#define	SEGSHIFT	22		/* LOG2(NBSEG) */
117178172Simp
118197316Salc#define	MAXPAGESIZES	1		/* maximum number of supported page sizes */
119197316Salc
120178172Simp/* XXXimp: This has moved to vmparam.h */
121178172Simp/* Also, this differs from the mips2 definition, but likely is better */
122178172Simp/* since this means the kernel won't chew up TLBs when it is executing */
123178172Simp/* code */
124178172Simp#define	KERNBASE	0x80000000	/* start of kernel virtual */
125178172Simp#define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
126178172Simp
127183441Simp#define	BLKDEV_IOSIZE	2048		/* xxx: Why is this 1/2 page? */
128183441Simp#define	MAXDUMPPGS	1		/* xxx: why is this only one? */
129178172Simp
130178172Simp/*
131205072Sneel * The kernel stack needs to be aligned on a (PAGE_SIZE * 2) boundary.
132205072Sneel *
133205072Sneel * Although we allocate 3 pages for the kernel stack we end up using
134205072Sneel * only the 2 pages that are aligned on a (PAGE_SIZE * 2) boundary.
135178172Simp */
136178172Simp#define	KSTACK_PAGES		3	/* kernel stack*/
137205072Sneel#define	KSTACK_GUARD_PAGES	1	/* pages of kstack guard; 0 disables */
138178172Simp
139178172Simp#define	UPAGES			2
140178172Simp
141178172Simp/* pages ("clicks") (4096 bytes) to disk blocks */
142178172Simp#define	ctod(x)		((x) << (PGSHIFT - DEV_BSHIFT))
143178172Simp#define	dtoc(x)		((x) >> (PGSHIFT - DEV_BSHIFT))
144178172Simp
145178172Simp/*
146178172Simp * Map a ``block device block'' to a file system block.
147178172Simp * This should be device dependent, and should use the bsize
148178172Simp * field from the disk label.
149178172Simp * For now though just use DEV_BSIZE.
150178172Simp */
151178172Simp#define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
152178172Simp
153178172Simp/*
154178172Simp * Conversion macros
155178172Simp */
156202031Simp#define	mips_round_page(x)	((((unsigned long)(x)) + NBPG - 1) & ~(NBPG-1))
157202031Simp#define	mips_trunc_page(x)	((unsigned long)(x) & ~(NBPG-1))
158202031Simp#define	mips_btop(x)		((unsigned long)(x) >> PGSHIFT)
159202031Simp#define	mips_ptob(x)		((unsigned long)(x) << PGSHIFT)
160178172Simp#define	round_page		mips_round_page
161178172Simp#define	trunc_page		mips_trunc_page
162178172Simp#define	atop(x)			((unsigned long)(x) >> PAGE_SHIFT)
163178172Simp#define	ptoa(x)			((unsigned long)(x) << PAGE_SHIFT)
164178172Simp
165178172Simp#define	pgtok(x)		((x) * (PAGE_SIZE / 1024))
166178172Simp
167178172Simp#ifndef _KERNEL
168178172Simp#define	DELAY(n)	{ register int N = (n); while (--N > 0); }
169178172Simp#endif /* !_KERNEL */
170178172Simp
171196994Sphk#endif /* !_MIPS_INCLUDE_PARAM_H_ */
172