1/* $NetBSD: param.h,v 1.16 2021/05/31 14:38:57 simonb 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#include "opt_param.h"
 40#endif
 41
 42/*
 43 * Machine dependent constants for all ARM processors
 44 */
 45
 46/*
 47 * For KERNEL code:
 48 *	MACHINE must be defined by the individual port.  This is so that
 49 *	uname returns the correct thing, etc.
 50 *
 51 *	MACHINE_ARCH may be defined by individual ports as a temporary
 52 *	measure while we're finishing the conversion to ELF.
 53 *
 54 * For non-KERNEL code:
 55 *	If ELF, MACHINE and MACHINE_ARCH are forced to "arm/armeb".
 56 */
 57
 58#if defined(_KERNEL)
 59# ifndef MACHINE_ARCH		/* XXX For now */
 60#  ifdef __AARCH64EB__
 61#   define	_MACHINE_ARCH	aarch64eb
 62#   define	MACHINE_ARCH	"aarch64eb"
 63#   define	_MACHINE32_ARCH	earmv7hfeb
 64#   define	MACHINE32_ARCH	"earmv7hfeb"
 65#  else
 66#   define	_MACHINE_ARCH	aarch64
 67#   define	MACHINE_ARCH	"aarch64"
 68#   define	_MACHINE32_ARCH	earmv7hf
 69#   define	MACHINE32_ARCH	"earmv7hf"
 70#  endif /* __AARCH64EB__ */
 71# endif /* MACHINE_ARCH */
 72#else
 73# undef _MACHINE
 74# undef MACHINE
 75# undef _MACHINE_ARCH
 76# undef MACHINE_ARCH
 77# undef _MACHINE32_ARCH
 78# undef MACHINE32_ARCH
 79# define	_MACHINE	aarch64
 80# define	MACHINE		"aarch64"
 81# ifdef __AARCH64EB__
 82#  define	_MACHINE_ARCH	aarch64eb
 83#  define	MACHINE_ARCH	"aarch64eb"
 84#  define	_MACHINE32_ARCH	earmv7hfeb
 85#  define	MACHINE32_ARCH	"earmv7hfeb"
 86# else
 87#  define	_MACHINE_ARCH	aarch64
 88#  define	MACHINE_ARCH	"aarch64"
 89#  define	_MACHINE32_ARCH	earmv7hf
 90#  define	MACHINE32_ARCH	"earmv7hf"
 91# endif /* __AARCH64EB__ */
 92#endif /* !_KERNEL */
 93
 94#define	MID_MACHINE	MID_AARCH64
 95
 96/* AARCH64-specific macro to align a stack pointer (downwards). */
 97#define STACK_ALIGNBYTES	(16 - 1)
 98
 99#define ALIGNBYTES32		(8 - 1)
100#define ALIGN32(p)		\
101	(((uintptr_t)(p) + ALIGNBYTES32) & ~ALIGNBYTES32)
102
103#define NKMEMPAGES_MIN_DEFAULT		((128UL * 1024 * 1024) >> PAGE_SHIFT)
104#define NKMEMPAGES_MAX_UNLIMITED	1
105
106#ifdef AARCH64_PAGE_SHIFT
107#if (1 << AARCH64_PAGE_SHIFT) & ~0x141000
108#error AARCH64_PAGE_SHIFT contains an unsupported value.
109#endif
110#define PGSHIFT			AARCH64_PAGE_SHIFT
111#else
112#define PGSHIFT			12
113#endif
114#define NBPG			(1 << PGSHIFT)
115#define PGOFSET			(NBPG - 1)
116
117/*
118 * Constants related to network buffer management.
119 * MCLBYTES must be no larger than NBPG (the software page size), and
120 * NBPG % MCLBYTES must be zero.
121 */
122#if PGSHIFT > 12
123#define MSIZE			256	/* size of an mbuf */
124#else
125#define MSIZE			512	/* size of an mbuf */
126#endif
127
128#ifndef MCLSHIFT
129#define MCLSHIFT		11	/* convert bytes to m_buf clusters */
130					/* 2K cluster can hold Ether frame */
131#endif /* MCLSHIFT */
132
133#define MCLBYTES		(1 << MCLSHIFT)	/* size of a m_buf cluster */
134
135#ifndef NFS_RSIZE
136#define NFS_RSIZE		32768	/* Default NFS read data size */
137#endif
138#ifndef NFS_WSIZE
139#define NFS_WSIZE		32768	/* Default NFS write data size */
140#endif
141
142#ifndef MSGBUFSIZE
143#define MSGBUFSIZE		65536	/* default message buffer size */
144#endif
145
146#define COHERENCY_UNIT		128
147#define CACHE_LINE_SIZE		128
148
149#define MAXCPUS			256
150
151#ifdef _KERNEL
152
153#ifndef __HIDE_DELAY
154void delay(unsigned int);
155#define	DELAY(x)	delay(x)
156#endif
157/*
158 * Compatibility /dev/zero mapping.
159 */
160#ifdef COMPAT_16
161#define COMPAT_ZERODEV(x)	(x == makedev(0, _DEV_ZERO_oARM))
162#endif
163
164#endif /* _KERNEL */
165
166#define aarch64_btop(x)		((unsigned long)(x) >> PGSHIFT)
167#define aarch64_ptob(x)		((unsigned long)(x) << PGSHIFT)
168#define aarch64_trunc_page(x)	((unsigned long)(x) & ~PGSHIFT)
169#define aarch64_round_page(x)	((((unsigned long)(x)) + PGOFSET) & ~PGOFSET)
170
171/* compatibility for arm */
172#define arm_btop(x)		aarch64_btop(x)
173#define arm_ptob(x)		aarch64_ptob(x)
174
175#elif defined(__arm__)
176
177#include <arm/param.h>
178
179#endif /* __aarch64__/__arm__ */
180
181#endif /* _AARCH64_PARAM_H_ */