1a9643ea8Slogwang /*- 2*22ce4affSfengbojiang * SPDX-License-Identifier: BSD-4-Clause 3*22ce4affSfengbojiang * 4a9643ea8Slogwang * Copyright (c) 2001 David E. O'Brien 5a9643ea8Slogwang * Copyright (c) 1990 The Regents of the University of California. 6a9643ea8Slogwang * All rights reserved. 7a9643ea8Slogwang * 8a9643ea8Slogwang * This code is derived from software contributed to Berkeley by 9a9643ea8Slogwang * William Jolitz. 10a9643ea8Slogwang * 11a9643ea8Slogwang * Redistribution and use in source and binary forms, with or without 12a9643ea8Slogwang * modification, are permitted provided that the following conditions 13a9643ea8Slogwang * are met: 14a9643ea8Slogwang * 1. Redistributions of source code must retain the above copyright 15a9643ea8Slogwang * notice, this list of conditions and the following disclaimer. 16a9643ea8Slogwang * 2. Redistributions in binary form must reproduce the above copyright 17a9643ea8Slogwang * notice, this list of conditions and the following disclaimer in the 18a9643ea8Slogwang * documentation and/or other materials provided with the distribution. 19a9643ea8Slogwang * 3. All advertising materials mentioning features or use of this software 20a9643ea8Slogwang * must display the following acknowledgement: 21a9643ea8Slogwang * This product includes software developed by the University of 22a9643ea8Slogwang * California, Berkeley and its contributors. 23a9643ea8Slogwang * 4. Neither the name of the University nor the names of its contributors 24a9643ea8Slogwang * may be used to endorse or promote products derived from this software 25a9643ea8Slogwang * without specific prior written permission. 26a9643ea8Slogwang * 27a9643ea8Slogwang * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 28a9643ea8Slogwang * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29a9643ea8Slogwang * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30a9643ea8Slogwang * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 31a9643ea8Slogwang * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32a9643ea8Slogwang * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33a9643ea8Slogwang * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34a9643ea8Slogwang * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35a9643ea8Slogwang * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36a9643ea8Slogwang * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37a9643ea8Slogwang * SUCH DAMAGE. 38a9643ea8Slogwang * 39a9643ea8Slogwang * from: @(#)param.h 5.8 (Berkeley) 6/28/91 40a9643ea8Slogwang * $FreeBSD$ 41a9643ea8Slogwang */ 42a9643ea8Slogwang 43a9643ea8Slogwang #ifndef _ARM_INCLUDE_PARAM_H_ 44a9643ea8Slogwang #define _ARM_INCLUDE_PARAM_H_ 45a9643ea8Slogwang 46a9643ea8Slogwang /* 47a9643ea8Slogwang * Machine dependent constants for StrongARM 48a9643ea8Slogwang */ 49a9643ea8Slogwang 50a9643ea8Slogwang #include <machine/_align.h> 51a9643ea8Slogwang 52a9643ea8Slogwang #define STACKALIGNBYTES (8 - 1) 53a9643ea8Slogwang #define STACKALIGN(p) ((u_int)(p) & ~STACKALIGNBYTES) 54a9643ea8Slogwang 55a9643ea8Slogwang #define __PCI_REROUTE_INTERRUPT 56a9643ea8Slogwang 57a9643ea8Slogwang #ifndef MACHINE 58a9643ea8Slogwang #define MACHINE "arm" 59a9643ea8Slogwang #endif 60a9643ea8Slogwang #ifndef MACHINE_ARCH 61*22ce4affSfengbojiang #if __ARM_ARCH >= 7 62*22ce4affSfengbojiang #define MACHINE_ARCH "armv7" 63*22ce4affSfengbojiang #else 64*22ce4affSfengbojiang #define MACHINE_ARCH "armv6" 65*22ce4affSfengbojiang #endif 66a9643ea8Slogwang #endif 67a9643ea8Slogwang 68*22ce4affSfengbojiang #ifdef SMP 69a9643ea8Slogwang #ifndef MAXCPU 70a9643ea8Slogwang #define MAXCPU 4 71a9643ea8Slogwang #endif 72a9643ea8Slogwang #else 73a9643ea8Slogwang #define MAXCPU 1 74*22ce4affSfengbojiang #endif 75a9643ea8Slogwang 76a9643ea8Slogwang #ifndef MAXMEMDOM 77a9643ea8Slogwang #define MAXMEMDOM 1 78a9643ea8Slogwang #endif 79a9643ea8Slogwang 80a9643ea8Slogwang #define ALIGNBYTES _ALIGNBYTES 81a9643ea8Slogwang #define ALIGN(p) _ALIGN(p) 82a9643ea8Slogwang /* 83a9643ea8Slogwang * ALIGNED_POINTER is a boolean macro that checks whether an address 84a9643ea8Slogwang * is valid to fetch data elements of type t from on this architecture. 85a9643ea8Slogwang * This does not reflect the optimal alignment, just the possibility 86a9643ea8Slogwang * (within reasonable limits). 87a9643ea8Slogwang * 88a9643ea8Slogwang * armv4 and v5 require alignment to the type's size. armv6 requires 8-byte 89a9643ea8Slogwang * alignment for the ldrd/strd instructions, but otherwise follows armv7 rules. 90a9643ea8Slogwang * armv7 requires that an 8-byte type be aligned to at least a 4-byte boundary; 91a9643ea8Slogwang * access to smaller types can be unaligned, except that the compiler may 92a9643ea8Slogwang * optimize access to adjacent uint32_t values into a single load/store-multiple 93a9643ea8Slogwang * instruction which requires 4-byte alignment, so we must provide the most- 94a9643ea8Slogwang * pessimistic answer possible even on armv7. 95a9643ea8Slogwang */ 96a9643ea8Slogwang #define ALIGNED_POINTER(p, t) ((((unsigned)(p)) & (sizeof(t)-1)) == 0) 97a9643ea8Slogwang 98a9643ea8Slogwang /* 99a9643ea8Slogwang * CACHE_LINE_SIZE is the compile-time maximum cache line size for an 100a9643ea8Slogwang * architecture. It should be used with appropriate caution. 101a9643ea8Slogwang */ 102a9643ea8Slogwang #define CACHE_LINE_SHIFT 6 103a9643ea8Slogwang #define CACHE_LINE_SIZE (1 << CACHE_LINE_SHIFT) 104a9643ea8Slogwang 105a9643ea8Slogwang #define PAGE_SHIFT 12 106a9643ea8Slogwang #define PAGE_SIZE (1 << PAGE_SHIFT) /* Page size */ 107a9643ea8Slogwang #define PAGE_MASK (PAGE_SIZE - 1) 108a9643ea8Slogwang 109a9643ea8Slogwang #define PDR_SHIFT 20 /* log2(NBPDR) */ 110a9643ea8Slogwang #define NBPDR (1 << PDR_SHIFT) 111a9643ea8Slogwang #define PDRMASK (NBPDR - 1) 112a9643ea8Slogwang #define NPDEPG (1 << (32 - PDR_SHIFT)) 113a9643ea8Slogwang 114a9643ea8Slogwang #define MAXPAGESIZES 2 /* maximum number of supported page sizes */ 115a9643ea8Slogwang 116a9643ea8Slogwang #ifndef KSTACK_PAGES 117a9643ea8Slogwang #define KSTACK_PAGES 2 118a9643ea8Slogwang #endif /* !KSTACK_PAGES */ 119a9643ea8Slogwang 120a9643ea8Slogwang #ifndef FPCONTEXTSIZE 121a9643ea8Slogwang #define FPCONTEXTSIZE (0x100) 122a9643ea8Slogwang #endif 123a9643ea8Slogwang 124a9643ea8Slogwang #ifndef KSTACK_GUARD_PAGES 125a9643ea8Slogwang #define KSTACK_GUARD_PAGES 1 126a9643ea8Slogwang #endif /* !KSTACK_GUARD_PAGES */ 127a9643ea8Slogwang 128a9643ea8Slogwang #define USPACE_SVC_STACK_TOP (kstack_pages * PAGE_SIZE) 129a9643ea8Slogwang 130a9643ea8Slogwang /* 131a9643ea8Slogwang * Mach derived conversion macros 132a9643ea8Slogwang */ 133a9643ea8Slogwang #define trunc_page(x) ((x) & ~PAGE_MASK) 134a9643ea8Slogwang #define round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK) 135a9643ea8Slogwang #define trunc_1mpage(x) ((unsigned)(x) & ~PDRMASK) 136a9643ea8Slogwang #define round_1mpage(x) ((((unsigned)(x)) + PDRMASK) & ~PDRMASK) 137a9643ea8Slogwang 138a9643ea8Slogwang #define atop(x) ((unsigned)(x) >> PAGE_SHIFT) 139a9643ea8Slogwang #define ptoa(x) ((unsigned)(x) << PAGE_SHIFT) 140a9643ea8Slogwang 141a9643ea8Slogwang #define arm32_btop(x) ((unsigned)(x) >> PAGE_SHIFT) 142a9643ea8Slogwang #define arm32_ptob(x) ((unsigned)(x) << PAGE_SHIFT) 143a9643ea8Slogwang 144a9643ea8Slogwang #define pgtok(x) ((x) * (PAGE_SIZE / 1024)) 145a9643ea8Slogwang 146a9643ea8Slogwang #endif /* !_ARM_INCLUDE_PARAM_H_ */ 147