param.h revision 1.19
11.19Sleo/*	$NetBSD: param.h,v 1.19 1997/02/26 12:18:51 leo Exp $	*/
21.1Sleo
31.1Sleo/*
41.1Sleo * Copyright (c) 1988 University of Utah.
51.1Sleo * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
61.1Sleo * All rights reserved.
71.1Sleo *
81.1Sleo * This code is derived from software contributed to Berkeley by
91.1Sleo * the Systems Programming Group of the University of Utah Computer
101.1Sleo * Science Department.
111.1Sleo *
121.1Sleo * Redistribution and use in source and binary forms, with or without
131.1Sleo * modification, are permitted provided that the following conditions
141.1Sleo * are met:
151.1Sleo * 1. Redistributions of source code must retain the above copyright
161.1Sleo *    notice, this list of conditions and the following disclaimer.
171.1Sleo * 2. Redistributions in binary form must reproduce the above copyright
181.1Sleo *    notice, this list of conditions and the following disclaimer in the
191.1Sleo *    documentation and/or other materials provided with the distribution.
201.1Sleo * 3. All advertising materials mentioning features or use of this software
211.1Sleo *    must display the following acknowledgement:
221.1Sleo *	This product includes software developed by the University of
231.1Sleo *	California, Berkeley and its contributors.
241.1Sleo * 4. Neither the name of the University nor the names of its contributors
251.1Sleo *    may be used to endorse or promote products derived from this software
261.1Sleo *    without specific prior written permission.
271.1Sleo *
281.1Sleo * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
291.1Sleo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
301.1Sleo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
311.1Sleo * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
321.1Sleo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
331.1Sleo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
341.1Sleo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
351.1Sleo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
361.1Sleo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
371.1Sleo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
381.1Sleo * SUCH DAMAGE.
391.1Sleo *
401.1Sleo * from: Utah $Hdr: machparam.h 1.11 89/08/14$
411.1Sleo *
421.1Sleo *	@(#)param.h	7.8 (Berkeley) 6/28/91
431.1Sleo */
441.1Sleo
451.1Sleo#ifndef _MACHINE_PARAM_H_
461.1Sleo#define _MACHINE_PARAM_H_
471.1Sleo
481.1Sleo/*
491.1Sleo * Machine dependent constants for atari
501.1Sleo */
511.13Scgd#define	_MACHINE	atari
521.1Sleo#define	MACHINE		"atari"
531.13Scgd#define	_MACHINE_ARCH	m68k
541.12Scgd#define	MACHINE_ARCH	"m68k"
551.12Scgd#define	MID_MACHINE	MID_M68K
561.1Sleo
571.1Sleo/*
581.1Sleo * Round p (pointer or byte index) up to a correctly-aligned value
591.1Sleo * for all data types (int, long, ...).   The result is u_int and
601.1Sleo * must be cast to any desired pointer type.
611.18Sfvdl *
621.18Sfvdl * ALIGNED_POINTER is a boolean macro that checks whether an address
631.18Sfvdl * is valid to fetch data elements of type t from on this architecture.
641.18Sfvdl * This does not reflect the optimal alignment, just the possibility
651.18Sfvdl * (within reasonable limits).
661.18Sfvdl *
671.1Sleo */
681.1Sleo#define ALIGNBYTES	(sizeof(int) - 1)
691.1Sleo#define	ALIGN(p)	(((u_int)(p) + (sizeof(int) - 1)) &~ (sizeof(int) - 1))
701.18Sfvdl#define ALIGNED_POINTER(p,t)	((((u_long)(p)) & (sizeof(t)-1)) == 0)
711.1Sleo
721.1Sleo#define	NBPG		8192		/* bytes/page */
731.1Sleo#define	PGOFSET		(NBPG-1)	/* byte offset into page */
741.1Sleo#define	PGSHIFT		13		/* LOG2(NBPG) */
751.1Sleo#define	NPTEPG		(NBPG/(sizeof(u_int)))
761.1Sleo
771.16Sleo			/* bytes/segment */
781.16Sleo#define NBSEG		((mmutype == MMU_68040) ? 32*NBPG : 2048*NBPG)
791.16Sleo			/* byte offset into segment */
801.16Sleo#define	SEGOFSET	(NBSEG-1)
811.6Sleo#define	SEGSHIFT	24		/* LOG2(NBSEG) [68030 value] */
821.1Sleo
831.1Sleo#define	KERNBASE	0x0		/* start of kernel virtual */
841.1Sleo#define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
851.1Sleo
861.1Sleo#define	DEV_BSIZE	512
871.1Sleo#define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
881.1Sleo#define BLKDEV_IOSIZE	2048
891.1Sleo#define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
901.1Sleo
911.1Sleo#define	CLSIZE		1
921.1Sleo#define	CLSIZELOG2	0
931.1Sleo
941.1Sleo/* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */
951.1Sleo#define	SSIZE		1		/* initial stack size/NBPG */
961.1Sleo#define	SINCR		1		/* increment of stack/NBPG */
971.1Sleo
981.1Sleo#define	UPAGES		2		/* pages of u-area */
991.1Sleo#define USPACE		(UPAGES * NBPG)
1001.1Sleo
1011.1Sleo/*
1021.1Sleo * Constants related to network buffer management.
1031.1Sleo * MCLBYTES must be no larger than CLBYTES (the software page size), and,
1041.1Sleo * on machines that exchange pages of input or output buffers with mbuf
1051.1Sleo * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
1061.1Sleo * of the hardware page size.
1071.1Sleo */
1081.1Sleo#define	MSIZE		128		/* size of an mbuf */
1091.17Sleo#define	MCLSHIFT	11
1101.17Sleo#define	MCLBYTES	(1 << MCLSHIFT)
1111.1Sleo#define	MCLOFSET	(MCLBYTES - 1)
1121.1Sleo#ifndef NMBCLUSTERS
1131.1Sleo#ifdef GATEWAY
1141.1Sleo#define	NMBCLUSTERS	512		/* map size, max cluster allocation */
1151.1Sleo#else
1161.1Sleo#define	NMBCLUSTERS	256		/* map size, max cluster allocation */
1171.1Sleo#endif
1181.1Sleo#endif
1191.1Sleo
1201.1Sleo/*
1211.1Sleo * Size of kernel malloc arena in CLBYTES-sized logical pages
1221.1Sleo */
1231.1Sleo#ifndef NKMEMCLUSTERS
1241.1Sleo#define	NKMEMCLUSTERS	(3072*1024/CLBYTES)
1251.1Sleo#endif
1261.1Sleo
1271.1Sleo/* pages ("clicks") to disk blocks */
1281.7Scgd#define	ctod(x)		((x) << (PGSHIFT - DEV_BSHIFT))
1291.7Scgd#define	dtoc(x)		((x) >> (PGSHIFT - DEV_BSHIFT))
1301.1Sleo
1311.1Sleo/* pages to bytes */
1321.7Scgd#define	ctob(x)		((x) << PGSHIFT)
1331.7Scgd#define	btoc(x)		(((x) + PGOFSET) >> PGSHIFT)
1341.1Sleo
1351.7Scgd/* bytes to disk blocks */
1361.7Scgd#define	btodb(x)	((x) >> DEV_BSHIFT)
1371.7Scgd#define	dbtob(x)	((x) << DEV_BSHIFT)
1381.1Sleo
1391.1Sleo/*
1401.1Sleo * Map a ``block device block'' to a file system block.
1411.1Sleo * This should be device dependent, and should use the bsize
1421.1Sleo * field from the disk label.
1431.1Sleo * For now though just use DEV_BSIZE.
1441.1Sleo */
1451.1Sleo#define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
1461.1Sleo
1471.1Sleo/*
1481.1Sleo * Mach derived conversion macros
1491.1Sleo */
1501.1Sleo#define atari_round_seg(x)	((((unsigned)(x)) + NBSEG - 1) & ~(NBSEG-1))
1511.1Sleo#define atari_trunc_seg(x)	((unsigned)(x) & ~(NBSEG-1))
1521.1Sleo#define atari_round_page(x)	((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1))
1531.1Sleo#define atari_trunc_page(x)	((unsigned)(x) & ~(NBPG-1))
1541.1Sleo#define atari_btos(x)		((unsigned)(x) >> SEGSHIFT)
1551.1Sleo#define atari_stob(x)		((unsigned)(x) << SEGSHIFT)
1561.1Sleo#define atari_btop(x)		((unsigned)(x) >> PGSHIFT)
1571.1Sleo#define atari_ptob(x)		((unsigned)(x) << PGSHIFT)
1581.1Sleo
1591.19Sleo#include <machine/intr.h>
1601.1Sleo
1611.4Sleo#ifdef _KERNEL
1621.1Sleovoid delay __P((int));
1631.5Sleo
1641.5Sleo#define	DELAY(n)	delay(n)
1651.5Sleo#endif /* _KERNEL */
1661.1Sleo
1671.1Sleo#endif /* !_MACHINE_PARAM_H_ */
168