Home | History | Annotate | Line # | Download | only in include
param.h revision 1.8
      1 /* $NetBSD: param.h,v 1.8 2018/12/06 18:36:06 skrll Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 2014 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Matt Thomas of 3am Software Foundry.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 #ifndef _AARCH64_PARAM_H_
     33 #define _AARCH64_PARAM_H_
     34 
     35 #ifdef __aarch64__
     36 
     37 #ifdef _KERNEL_OPT
     38 #include "opt_cputypes.h"
     39 #endif
     40 
     41 /*
     42  * Machine dependent constants for all ARM processors
     43  */
     44 
     45 /*
     46  * For KERNEL code:
     47  *	MACHINE must be defined by the individual port.  This is so that
     48  *	uname returns the correct thing, etc.
     49  *
     50  *	MACHINE_ARCH may be defined by individual ports as a temporary
     51  *	measure while we're finishing the conversion to ELF.
     52  *
     53  * For non-KERNEL code:
     54  *	If ELF, MACHINE and MACHINE_ARCH are forced to "arm/armeb".
     55  */
     56 
     57 #if defined(_KERNEL)
     58 # ifndef MACHINE_ARCH		/* XXX For now */
     59 #  ifdef __AARCH64EB__
     60 #   define	_MACHINE_ARCH	aarch64eb
     61 #   define	MACHINE_ARCH	"aarch64eb"
     62 #  else
     63 #   define	_MACHINE_ARCH	aarch64
     64 #   define	MACHINE_ARCH	"aarch64"
     65 #  endif /* __AARCH64EB__ */
     66 # endif /* MACHINE_ARCH */
     67 #else
     68 # undef _MACHINE
     69 # undef MACHINE
     70 # undef _MACHINE_ARCH
     71 # undef MACHINE_ARCH
     72 # define	_MACHINE	aarch64
     73 # define	MACHINE		"aarch64"
     74 # ifdef __AARCH64EB__
     75 #  define	_MACHINE_ARCH	aarch64eb
     76 #  define	MACHINE_ARCH	"aarch64eb"
     77 # else
     78 #  define	_MACHINE_ARCH	aarch64
     79 #  define	MACHINE_ARCH	"aarch64"
     80 # endif /* __AARCH64EB__ */
     81 #endif /* !_KERNEL */
     82 
     83 #define	MID_MACHINE	MID_AARCH64
     84 
     85 /* AARCH64-specific macro to align a stack pointer (downwards). */
     86 #define STACK_ALIGNBYTES	(16 - 1)
     87 
     88 #define ALIGNBYTES32		(4 - 1)
     89 #define ALIGN32(p)		\
     90 	(((uintptr_t)(p) + ALIGNBYTES32) & ~ALIGNBYTES32)
     91 
     92 #define DEV_BSHIFT		9	/* log2(DEV_BSIZE) */
     93 #define DEV_BSIZE		(1 << DEV_BSHIFT)
     94 #define BLKDEV_IOSIZE		2048
     95 
     96 #ifndef MAXPHYS
     97 #define MAXPHYS			65536	/* max I/O transfer size */
     98 #endif
     99 
    100 #define NKMEMPAGES_MIN_DEFAULT		((128UL * 1024 * 1024) >> PAGE_SHIFT)
    101 #define NKMEMPAGES_MAX_UNLIMITED	1
    102 
    103 #ifdef AARCH64_PAGE_SHIFT
    104 #if (1 << AARCH64_PAGE_SHIFT) & ~0x141000
    105 #error AARCH64_PAGE_SHIFT contains an unsupported value.
    106 #endif
    107 #define PGSHIFT			AARCH64_PAGE_SHIFT
    108 #else
    109 #define PGSHIFT			12
    110 #endif
    111 #define NBPG			(1 << PGSHIFT)
    112 #define PGOFSET			(NBPG - 1)
    113 
    114 /*
    115  * Constants related to network buffer management.
    116  * MCLBYTES must be no larger than NBPG (the software page size), and
    117  * NBPG % MCLBYTES must be zero.
    118  */
    119 #if PGSHIFT > 12
    120 #define MSIZE			256	/* size of an mbuf */
    121 #else
    122 #define MSIZE			512	/* size of an mbuf */
    123 #endif
    124 
    125 #ifndef MCLSHIFT
    126 #define MCLSHIFT		11	/* convert bytes to m_buf clusters */
    127 					/* 2K cluster can hold Ether frame */
    128 #endif /* MCLSHIFT */
    129 
    130 #define MCLBYTES		(1 << MCLSHIFT)	/* size of a m_buf cluster */
    131 
    132 
    133 #ifndef MSGBUFSIZE
    134 #define MSGBUFSIZE		16384	/* default message buffer size */
    135 #endif
    136 
    137 #define COHERENCY_UNIT		128
    138 #define CACHE_LINE_SIZE		128
    139 
    140 #ifdef _KERNEL
    141 
    142 #ifndef __HIDE_DELAY
    143 void delay(unsigned int);
    144 #define	DELAY(x)	delay(x)
    145 #endif
    146 /*
    147  * Compatibility /dev/zero mapping.
    148  */
    149 #ifdef COMPAT_16
    150 #define COMPAT_ZERODEV(x)	(x == makedev(0, _DEV_ZERO_oARM))
    151 #endif
    152 
    153 #endif /* _KERNEL */
    154 
    155 #define aarch64_btop(x)		((unsigned long)(x) >> PGSHIFT)
    156 #define aarch64_ptob(x)		((unsigned long)(x) << PGSHIFT)
    157 #define aarch64_trunc_page(x)	((unsigned long)(x) & ~PGSHIFT)
    158 #define aarch64_round_page(x)	((((unsigned long)(x)) + PGOFSET) & ~PGOFSET)
    159 
    160 /* compatibility for arm */
    161 #define arm_btop(x)		aarch64_btop(x)
    162 #define arm_ptob(x)		aarch64_ptob(x)
    163 #define arm_trunc_page(x)	aarch64_trunc_page(x)
    164 #define arm_round_page(x)	aarch64_round_page(x)
    165 
    166 #elif defined(__arm__)
    167 
    168 #include <arm/param.h>
    169 
    170 #endif /* __aarch64__/__arm__ */
    171 
    172 #endif /* _AARCH64_PARAM_H_ */
    173