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