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