1412042e2SAndrew Turner /*- 2412042e2SAndrew Turner * Copyright (c) 1990 The Regents of the University of California. 3412042e2SAndrew Turner * All rights reserved. 4412042e2SAndrew Turner * 5412042e2SAndrew Turner * This code is derived from software contributed to Berkeley by 6412042e2SAndrew Turner * William Jolitz. 7412042e2SAndrew Turner * 8412042e2SAndrew Turner * Redistribution and use in source and binary forms, with or without 9412042e2SAndrew Turner * modification, are permitted provided that the following conditions 10412042e2SAndrew Turner * are met: 11412042e2SAndrew Turner * 1. Redistributions of source code must retain the above copyright 12412042e2SAndrew Turner * notice, this list of conditions and the following disclaimer. 13412042e2SAndrew Turner * 2. Redistributions in binary form must reproduce the above copyright 14412042e2SAndrew Turner * notice, this list of conditions and the following disclaimer in the 15412042e2SAndrew Turner * documentation and/or other materials provided with the distribution. 16412042e2SAndrew Turner * 17412042e2SAndrew Turner * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18412042e2SAndrew Turner * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19412042e2SAndrew Turner * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20412042e2SAndrew Turner * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21412042e2SAndrew Turner * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22412042e2SAndrew Turner * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23412042e2SAndrew Turner * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24412042e2SAndrew Turner * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25412042e2SAndrew Turner * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26412042e2SAndrew Turner * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27412042e2SAndrew Turner * SUCH DAMAGE. 28412042e2SAndrew Turner */ 29412042e2SAndrew Turner 30d5d97bedSMike Karels #ifdef __arm__ 31d5d97bedSMike Karels #include <arm/param.h> 32d5d97bedSMike Karels #else /* !__arm__ */ 33d5d97bedSMike Karels 34412042e2SAndrew Turner #ifndef _MACHINE_PARAM_H_ 35412042e2SAndrew Turner #define _MACHINE_PARAM_H_ 36412042e2SAndrew Turner 37412042e2SAndrew Turner /* 38412042e2SAndrew Turner * Machine dependent constants for arm64. 39412042e2SAndrew Turner */ 40412042e2SAndrew Turner 41412042e2SAndrew Turner #include <machine/_align.h> 42412042e2SAndrew Turner 43412042e2SAndrew Turner #define STACKALIGNBYTES (16 - 1) 44412042e2SAndrew Turner #define STACKALIGN(p) ((uint64_t)(p) & ~STACKALIGNBYTES) 45412042e2SAndrew Turner 46412042e2SAndrew Turner #ifndef MACHINE 47412042e2SAndrew Turner #define MACHINE "arm64" 48412042e2SAndrew Turner #endif 49412042e2SAndrew Turner #ifndef MACHINE_ARCH 50412042e2SAndrew Turner #define MACHINE_ARCH "aarch64" 51412042e2SAndrew Turner #endif 529dcf90f8SEd Schouten #ifndef MACHINE_ARCH32 539dcf90f8SEd Schouten #define MACHINE_ARCH32 "armv7" 549dcf90f8SEd Schouten #endif 55412042e2SAndrew Turner 56c3d326fdSMark Johnston #ifdef SMP 57412042e2SAndrew Turner #ifndef MAXCPU 58e0c6e891SEd Maste #define MAXCPU 1024 59412042e2SAndrew Turner #endif 60412042e2SAndrew Turner #else 61412042e2SAndrew Turner #define MAXCPU 1 62c3d326fdSMark Johnston #endif 63412042e2SAndrew Turner 64412042e2SAndrew Turner #ifndef MAXMEMDOM 65014812b9SOleksandr Tymoshenko #define MAXMEMDOM 8 66412042e2SAndrew Turner #endif 67412042e2SAndrew Turner 68412042e2SAndrew Turner #define ALIGNBYTES _ALIGNBYTES 69412042e2SAndrew Turner #define ALIGN(p) _ALIGN(p) 70412042e2SAndrew Turner /* 71412042e2SAndrew Turner * ALIGNED_POINTER is a boolean macro that checks whether an address 72412042e2SAndrew Turner * is valid to fetch data elements of type t from on this architecture. 73412042e2SAndrew Turner * This does not reflect the optimal alignment, just the possibility 74412042e2SAndrew Turner * (within reasonable limits). 75412042e2SAndrew Turner */ 76412042e2SAndrew Turner #define ALIGNED_POINTER(p, t) ((((u_long)(p)) & (sizeof(t) - 1)) == 0) 77412042e2SAndrew Turner 78412042e2SAndrew Turner /* 79412042e2SAndrew Turner * CACHE_LINE_SIZE is the compile-time maximum cache line size for an 80412042e2SAndrew Turner * architecture. It should be used with appropriate caution. 81412042e2SAndrew Turner */ 829eb0ccbbSAndrew Turner #define CACHE_LINE_SHIFT 7 83412042e2SAndrew Turner #define CACHE_LINE_SIZE (1 << CACHE_LINE_SHIFT) 84412042e2SAndrew Turner 853413a8cdSAndrew Turner #define PAGE_SHIFT_4K 12 863413a8cdSAndrew Turner #define PAGE_SIZE_4K (1 << PAGE_SHIFT_4K) 87412042e2SAndrew Turner 881ae9c994SZbigniew Bodek #define PAGE_SHIFT_16K 14 891ae9c994SZbigniew Bodek #define PAGE_SIZE_16K (1 << PAGE_SHIFT_16K) 901ae9c994SZbigniew Bodek 91412042e2SAndrew Turner #define PAGE_SHIFT_64K 16 92412042e2SAndrew Turner #define PAGE_SIZE_64K (1 << PAGE_SHIFT_64K) 93412042e2SAndrew Turner 943413a8cdSAndrew Turner #define PAGE_SHIFT PAGE_SHIFT_4K 95abc7a4a0SAndrew Turner #define PAGE_SIZE (1 << PAGE_SHIFT) 96abc7a4a0SAndrew Turner #define PAGE_MASK (PAGE_SIZE - 1) 973413a8cdSAndrew Turner 98*3e00c11aSAlan Cox #define MAXPAGESIZES 4 /* maximum number of supported page sizes */ 99412042e2SAndrew Turner 100412042e2SAndrew Turner #ifndef KSTACK_PAGES 10189c52f9dSKyle Evans #if defined(KASAN) || defined(KMSAN) 10289c52f9dSKyle Evans #define KSTACK_PAGES 6 10389c52f9dSKyle Evans #else 104412042e2SAndrew Turner #define KSTACK_PAGES 4 /* pages of kernel stack (with pcb) */ 105412042e2SAndrew Turner #endif 10689c52f9dSKyle Evans #endif 107412042e2SAndrew Turner 108412042e2SAndrew Turner #define KSTACK_GUARD_PAGES 1 /* pages of kstack guard; 0 disables */ 109412042e2SAndrew Turner #define PCPU_PAGES 1 110412042e2SAndrew Turner 11103bf40c5SMark Johnston #ifdef PERTHREAD_SSP 11203bf40c5SMark Johnston #define NO_PERTHREAD_SSP __nostackprotector 11303bf40c5SMark Johnston #else 11403bf40c5SMark Johnston #define NO_PERTHREAD_SSP 11503bf40c5SMark Johnston #endif 11603bf40c5SMark Johnston 117412042e2SAndrew Turner /* 118412042e2SAndrew Turner * Mach derived conversion macros 119412042e2SAndrew Turner */ 120412042e2SAndrew Turner #define arm64_btop(x) ((unsigned long)(x) >> PAGE_SHIFT) 121412042e2SAndrew Turner #define arm64_ptob(x) ((unsigned long)(x) << PAGE_SHIFT) 122412042e2SAndrew Turner 123412042e2SAndrew Turner #endif /* !_MACHINE_PARAM_H_ */ 124d5d97bedSMike Karels 125d5d97bedSMike Karels #endif /* !__arm__ */ 126