Home | History | Annotate | Line # | Download | only in include
param.h revision 1.1
      1 /*	$NetBSD: param.h,v 1.1 2001/02/23 03:48:17 ichiro Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1994,1995 Mark Brinicombe.
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *	This product includes software developed by the RiscBSD team.
     18  * 4. The name "RiscBSD" nor the name of the author may be used to
     19  *    endorse or promote products derived from this software without specific
     20  *    prior written permission.
     21  *
     22  * THIS SOFTWARE IS PROVIDED BY RISCBSD ``AS IS'' AND ANY EXPRESS OR IMPLIED
     23  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     24  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25  * IN NO EVENT SHALL RISCBSD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     26  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     27  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32  * SUCH DAMAGE.
     33  */
     34 
     35 #ifndef	_ARM32_PARAM_H_
     36 #define	_ARM32_PARAM_H_
     37 
     38 #ifdef _KERNEL
     39 #  include <machine/cpu.h>
     40 #endif
     41 
     42 /*
     43  * Machine dependent constants for StrongARM processors
     44  */
     45 
     46 #define	_MACHINE	hpcarm
     47 #define	MACHINE		"hpcarm"
     48 #define	_MACHINE_ARCH	arm
     49 #define	MACHINE_ARCH	"arm"
     50 #define	MID_MACHINE	MID_ARM6
     51 
     52 /*
     53  * Round p (pointer or byte index) up to a correctly-aligned value
     54  * for all data types (int, long, ...).   The result is u_int and
     55  * must be cast to any desired pointer type.
     56  *
     57  * ALIGNED_POINTER is a boolean macro that checks whether an address
     58  * is valid to fetch data elements of type t from on this architecture.
     59  * This does not reflect the optimal alignment, just the possibility
     60  * (within reasonable limits).
     61  *
     62  */
     63 #define ALIGNBYTES		(sizeof(int) - 1)
     64 #define ALIGN(p)		(((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
     65 #define ALIGNED_POINTER(p,t)	((((u_long)(p)) & (sizeof(t)-1)) == 0)
     66 
     67 #define	PGSHIFT		12		/* LOG2(NBPG) */
     68 #define	NBPG		(1 << PGSHIFT)	/* bytes/page */
     69 #define	PGOFSET		(NBPG-1)	/* byte offset into page */
     70 #define	NPTEPG		(NBPG/(sizeof (pt_entry_t)))
     71 
     72 
     73 #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
     74 #define	DEV_BSIZE	(1 << DEV_BSHIFT)
     75 #define	BLKDEV_IOSIZE	2048
     76 #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
     77 
     78 #define SSIZE           1               /* initial stack size/NBPG */
     79 #define SINCR           1               /* increment of stack/NBPG */
     80 #define UPAGES          2               /* pages of u-area */
     81 #define USPACE          (UPAGES * NBPG) /* total size of u-area */
     82 
     83 #ifndef MSGBUFSIZE
     84 #define MSGBUFSIZE	NBPG		/* default message buffer size */
     85 #endif
     86 
     87 /*
     88  * Constants related to network buffer management.
     89  * MCLBYTES must be no larger than NBPG (the software page size), and,
     90  * on machines that exchange pages of input or output buffers with mbuf
     91  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
     92  * of the hardware page size.
     93  */
     94 #define	MSIZE		256		/* size of an mbuf */
     95 #define	MCLSHIFT	11		/* convert bytes to m_buf clusters */
     96 #define	MCLBYTES	(1 << MCLSHIFT)	/* size of a m_buf cluster */
     97 #define	MCLOFSET	(MCLBYTES - 1)	/* offset within a m_buf cluster */
     98 
     99 #ifndef NMBCLUSTERS
    100 
    101 #if defined(_KERNEL) && !defined(_LKM)
    102 #include "opt_gateway.h"
    103 #endif /* _KERNEL && ! _LKM */
    104 
    105 #ifdef GATEWAY
    106 #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
    107 #else
    108 #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
    109 #endif
    110 #endif
    111 
    112 /*
    113  * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
    114  * logical pages.
    115  */
    116 #define	NKMEMPAGES_MIN_DEFAULT	((6 * 1024 * 1024) >> PAGE_SHIFT)
    117 #define	NKMEMPAGES_MAX_DEFAULT	((7 * 1024 * 1024) >> PAGE_SHIFT)
    118 
    119 /* pages ("clicks") (4096 bytes) to disk blocks */
    120 #define	ctod(x)	((x) << (PGSHIFT - DEV_BSHIFT))
    121 #define	dtoc(x)	((x) >> (PGSHIFT - DEV_BSHIFT))
    122 /*#define	dtob(x)	((x) << DEV_BSHIFT)*/
    123 
    124 #define	ctob(x)	((x) << PGSHIFT)
    125 
    126 /* bytes to pages */
    127 #define	btoc(x)	(((x) + PGOFSET) >> PGSHIFT)
    128 
    129 #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
    130 	((bytes) >> DEV_BSHIFT)
    131 #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
    132 	((db) << DEV_BSHIFT)
    133 
    134 /*
    135  * Map a ``block device block'' to a file system block.
    136  * This should be device dependent, and should use the bsize
    137  * field from the disk label.
    138  * For now though just use DEV_BSIZE.
    139  */
    140 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE / DEV_BSIZE))
    141 
    142 /* Constants used to divide the USPACE area */
    143 
    144 /*
    145  * The USPACE area contains :
    146  * 1. the user structure for the process
    147  * 2. the fp context for FP emulation
    148  * 3. the kernel (svc) stack
    149  * 4. the undefined instruction stack
    150  *
    151  * The layout of the area looks like this
    152  *
    153  * | user area | FP context | undefined stack | kernel stack |
    154  *
    155  * The size of the user area is known.
    156  * The size of the FP context is variable depending of the FP emulator
    157  * in use and whether there is hardware FP support. However we can put
    158  * an upper limit on it.
    159  * The undefined stack needs to be at least 512 bytes. This is a requirement
    160  * if the FP emulators
    161  * The kernel stack should be at least 4K is size.
    162  *
    163  * The stack top addresses are used to set the stack pointers. The stack bottom
    164  * addresses at the addresses monitored by the diagnostic code for stack overflows
    165  *
    166  */
    167 
    168 #define FPCONTEXTSIZE			(0x100)
    169 #define USPACE_SVC_STACK_TOP		(USPACE)
    170 #define USPACE_SVC_STACK_BOTTOM		(USPACE_SVC_STACK_TOP - 0x1000)
    171 #define	USPACE_UNDEF_STACK_TOP		(USPACE_SVC_STACK_BOTTOM - 0x10)
    172 #define USPACE_UNDEF_STACK_BOTTOM	(sizeof(struct user) + FPCONTEXTSIZE + 10)
    173 
    174 #define arm_byte_to_page(x) ((x) >> PGSHIFT)
    175 #define arm_page_to_byte(x) ((x) << PGSHIFT)
    176 
    177 #ifdef _KERNEL
    178 #ifndef _LOCORE
    179 void	delay __P((unsigned));
    180 #define DELAY(x)	delay(x)
    181 #endif
    182 #endif
    183 
    184 #endif	/* _ARM_PARAM_H_ */
    185