|
| 1 | +// Copyright (c) 2017 ARM Limited. All rights reserved. |
| 2 | +// SPDX-License-Identifier: BSD-3-Clause |
| 3 | + |
| 4 | +#pragma once |
| 5 | + |
| 6 | +// Architecture detection is inferred from the toolchain. This relies on |
| 7 | +// the C compiler's system-specific macros. |
| 8 | +#if defined(__aarch64__) |
| 9 | +#define CONFIG_ARCH_ARM_V8 |
| 10 | +#define CONFIG_ARCH_64BIT |
| 11 | +#elif defined(__arm__) |
| 12 | +#define CONFIG_ARCH_ARM_V7 |
| 13 | +#define CONFIG_ARCH_32BIT |
| 14 | +#elif defined(__x86_64__) |
| 15 | +#define CONFIG_ARCH_X86_64 |
| 16 | +#define CONFIG_ARCH_64BIT |
| 17 | +#elif defined(__i386__) |
| 18 | +#define CONFIG_ARCH_X86 |
| 19 | +#define CONFIG_ARCH_32BIT |
| 20 | +#endif |
| 21 | + |
| 22 | +#if !defined(CONFIG_ARCH_64BIT) && !defined(CONFIG_ARCH_32BIT) |
| 23 | +#error Please add support for N-bit computing to build_config.h |
| 24 | +// If you experience this C pre-processor error, take a look at the place |
| 25 | +// in this file where CONFIG_ARCH_64/32BIT are defined. If there are no issues |
| 26 | +// there and you are needing to add support for a new N-bit processor, please |
| 27 | +// search the source code for all occurances of CONFIG_ARCH_64BIT and |
| 28 | +// CONFIG_ARCH_32BIT to check whether further modification is necessary. |
| 29 | +// These places will not necessarily #error for unsupported N-bit computing. |
| 30 | +#endif |
| 31 | + |
| 32 | +// OS detection is also inferred from the toolchain. |
| 33 | +#if defined(__APPLE__) |
| 34 | +#define OS_MACOSX 1 |
| 35 | +#elif defined(__linux__) |
| 36 | +#define OS_LINUX 1 |
| 37 | +#elif defined(__FreeBSD__) |
| 38 | +#define OS_FREEBSD 1 |
| 39 | +#endif |
| 40 | + |
| 41 | +#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_FREEBSD) |
| 42 | +#define OS_POSIX 1 |
| 43 | +#endif |
| 44 | + |
| 45 | +#define MAX_THREADS 32 |
| 46 | + |
| 47 | +//Use LL/SC atomic primitives instead of __atomic_compare_exchange built-ins |
| 48 | +//This seems to be the most performant option on ARM but may violate |
| 49 | +//recommendations by the ARM architecture (e.g. no memory accesses between |
| 50 | +//LL and SC) |
| 51 | +//USE_LLSC overrides the use of __atomic_compare_exchange |
| 52 | +#ifdef __ARM_ARCH |
| 53 | +#define USE_LLSC |
| 54 | +#endif |
| 55 | + |
| 56 | +//Use barrier + relaxed store (DMB;STR) instead of store-release (STRL) |
| 57 | +//This is more performant on Cortex-A57 and possibly also on Cortex-A53 |
| 58 | +#if defined(__aarch64__) |
| 59 | +#define USE_DMB |
| 60 | +#endif |
| 61 | + |
| 62 | +#if defined(USE_DMB) && defined(__arm__) |
| 63 | +#error USE_DMB optimization only applies to select ARMv8 processors |
| 64 | +#endif |
| 65 | + |
| 66 | +//Use ARM wait-for-event mechanism when busy polling |
| 67 | +//This will minimise interconnect transactions and often increase system-wide |
| 68 | +//performance |
| 69 | +#if defined __ARM_ARCH |
| 70 | +#define USE_WFE |
| 71 | +#if defined(__arm__) |
| 72 | +//TODO: WFE on ARMv7 |
| 73 | +#undef USE_WFE |
| 74 | +#endif |
| 75 | +#endif |
0 commit comments