Home | History | Annotate | Line # | Download | only in arm32
param.h revision 1.1
      1 /*	$NetBSD: param.h,v 1.1 2001/02/23 21:23:49 reinoud 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 ARM6+ processors
     44  */
     45 
     46 #ifdef HPCARM
     47 #	define	_MACHINE	hpcarm
     48 #	define	MACHINE		"hpcarm"
     49 #	define	_MACHINE_ARCH	arm
     50 #	define	MACHINE_ARCH	"arm"
     51 #else
     52 #	define	_MACHINE	arm32
     53 #	define	MACHINE		"arm32"
     54 #	define	_MACHINE_ARCH	arm32
     55 #	define	MACHINE_ARCH	"arm32"
     56 #	define	MID_MACHINE	MID_ARM6
     57 #endif
     58 
     59 /*
     60  * Round p (pointer or byte index) up to a correctly-aligned value
     61  * for all data types (int, long, ...).   The result is u_int and
     62  * must be cast to any desired pointer type.
     63  *
     64  * ALIGNED_POINTER is a boolean macro that checks whether an address
     65  * is valid to fetch data elements of type t from on this architecture.
     66  * This does not reflect the optimal alignment, just the possibility
     67  * (within reasonable limits).
     68  *
     69  */
     70 #define ALIGNBYTES		(sizeof(int) - 1)
     71 #define ALIGN(p)		(((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
     72 #define ALIGNED_POINTER(p,t)	((((u_long)(p)) & (sizeof(t)-1)) == 0)
     73 
     74 #define	PGSHIFT		12		/* LOG2(NBPG) */
     75 #define	NBPG		(1 << PGSHIFT)	/* bytes/page */
     76 #define	PGOFSET		(NBPG-1)	/* byte offset into page */
     77 #define	NPTEPG		(NBPG/(sizeof (pt_entry_t)))
     78 
     79 
     80 #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
     81 #define	DEV_BSIZE	(1 << DEV_BSHIFT)
     82 #define	BLKDEV_IOSIZE	2048
     83 #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
     84 
     85 #define SSIZE           1               /* initial stack size/NBPG */
     86 #define SINCR           1               /* increment of stack/NBPG */
     87 #define UPAGES          2               /* pages of u-area */
     88 #define USPACE          (UPAGES * NBPG) /* total size of u-area */
     89 
     90 #ifndef MSGBUFSIZE
     91 #define MSGBUFSIZE	NBPG		/* default message buffer size */
     92 #endif
     93 
     94 /*
     95  * Constants related to network buffer management.
     96  * MCLBYTES must be no larger than NBPG (the software page size), and,
     97  * on machines that exchange pages of input or output buffers with mbuf
     98  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
     99  * of the hardware page size.
    100  */
    101 #define	MSIZE		256		/* size of an mbuf */
    102 #define	MCLSHIFT	11		/* convert bytes to m_buf clusters */
    103 #define	MCLBYTES	(1 << MCLSHIFT)	/* size of a m_buf cluster */
    104 #define	MCLOFSET	(MCLBYTES - 1)	/* offset within a m_buf cluster */
    105 
    106 #ifndef NMBCLUSTERS
    107 
    108 #if defined(_KERNEL) && !defined(_LKM)
    109 #include "opt_gateway.h"
    110 #endif /* _KERNEL && ! _LKM */
    111 
    112 #ifdef GATEWAY
    113 #define	NMBCLUSTERS	512		/* map size, max cluster allocation */
    114 #else
    115 #define	NMBCLUSTERS	256		/* map size, max cluster allocation */
    116 #endif
    117 #endif
    118 
    119 /*
    120  * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
    121  * logical pages.
    122  */
    123 #define	NKMEMPAGES_MIN_DEFAULT	((6 * 1024 * 1024) >> PAGE_SHIFT)
    124 #define	NKMEMPAGES_MAX_DEFAULT	((7 * 1024 * 1024) >> PAGE_SHIFT)
    125 
    126 /* pages ("clicks") (4096 bytes) to disk blocks */
    127 #define	ctod(x)	((x) << (PGSHIFT - DEV_BSHIFT))
    128 #define	dtoc(x)	((x) >> (PGSHIFT - DEV_BSHIFT))
    129 /*#define	dtob(x)	((x) << DEV_BSHIFT)*/
    130 
    131 #define	ctob(x)	((x) << PGSHIFT)
    132 
    133 /* bytes to pages */
    134 #define	btoc(x)	(((x) + PGOFSET) >> PGSHIFT)
    135 
    136 #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
    137 	((bytes) >> DEV_BSHIFT)
    138 #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
    139 	((db) << DEV_BSHIFT)
    140 
    141 /*
    142  * Map a ``block device block'' to a file system block.
    143  * This should be device dependent, and should use the bsize
    144  * field from the disk label.
    145  * For now though just use DEV_BSIZE.
    146  */
    147 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE / DEV_BSIZE))
    148 
    149 /* Constants used to divide the USPACE area */
    150 
    151 /*
    152  * The USPACE area contains :
    153  * 1. the user structure for the process
    154  * 2. the fp context for FP emulation
    155  * 3. the kernel (svc) stack
    156  * 4. the undefined instruction stack
    157  *
    158  * The layout of the area looks like this
    159  *
    160  * | user area | FP context | undefined stack | kernel stack |
    161  *
    162  * The size of the user area is known.
    163  * The size of the FP context is variable depending of the FP emulator
    164  * in use and whether there is hardware FP support. However we can put
    165  * an upper limit on it.
    166  * The undefined stack needs to be at least 512 bytes. This is a requirement
    167  * if the FP emulators
    168  * The kernel stack should be at least 4K is size.
    169  *
    170  * The stack top addresses are used to set the stack pointers. The stack bottom
    171  * addresses at the addresses monitored by the diagnostic code for stack overflows
    172  *
    173  */
    174 
    175 #define FPCONTEXTSIZE			(0x100)
    176 #define USPACE_SVC_STACK_TOP		(USPACE)
    177 #define USPACE_SVC_STACK_BOTTOM		(USPACE_SVC_STACK_TOP - 0x1000)
    178 #define	USPACE_UNDEF_STACK_TOP		(USPACE_SVC_STACK_BOTTOM - 0x10)
    179 #define USPACE_UNDEF_STACK_BOTTOM	(sizeof(struct user) + FPCONTEXTSIZE + 10)
    180 
    181 #define arm_byte_to_page(x) ((x) >> PGSHIFT)
    182 #define arm_page_to_byte(x) ((x) << PGSHIFT)
    183 
    184 #ifdef _KERNEL
    185 #ifndef _LOCORE
    186 void	delay __P((unsigned));
    187 #define DELAY(x)	delay(x)
    188 #endif
    189 #endif
    190 
    191 #endif	/* _ARM_PARAM_H_ */
    192