| 1 | #pragma once |
| 2 | |
| 3 | #ifdef UACPI_OVERRIDE_CONFIG |
| 4 | #include "uacpi_config.h" |
| 5 | #else |
| 6 | |
| 7 | #include <uacpi/helpers.h> |
| 8 | #include <uacpi/log.h> |
| 9 | |
| 10 | /* |
| 11 | * ======================= |
| 12 | * Context-related options |
| 13 | * ======================= |
| 14 | */ |
| 15 | #ifndef UACPI_DEFAULT_LOG_LEVEL |
| 16 | #define UACPI_DEFAULT_LOG_LEVEL UACPI_LOG_INFO |
| 17 | #endif |
| 18 | |
| 19 | UACPI_BUILD_BUG_ON_WITH_MSG( |
| 20 | UACPI_DEFAULT_LOG_LEVEL < UACPI_LOG_ERROR || |
| 21 | UACPI_DEFAULT_LOG_LEVEL > UACPI_LOG_DEBUG, |
| 22 | "configured default log level is invalid" |
| 23 | ); |
| 24 | |
| 25 | #ifndef UACPI_DEFAULT_LOOP_TIMEOUT_SECONDS |
| 26 | #define UACPI_DEFAULT_LOOP_TIMEOUT_SECONDS 30 |
| 27 | #endif |
| 28 | |
| 29 | UACPI_BUILD_BUG_ON_WITH_MSG( |
| 30 | UACPI_DEFAULT_LOOP_TIMEOUT_SECONDS < 1, |
| 31 | "configured default loop timeout is invalid (expecting at least 1 second)" |
| 32 | ); |
| 33 | |
| 34 | #ifndef UACPI_DEFAULT_MAX_CALL_STACK_DEPTH |
| 35 | #define UACPI_DEFAULT_MAX_CALL_STACK_DEPTH 256 |
| 36 | #endif |
| 37 | |
| 38 | UACPI_BUILD_BUG_ON_WITH_MSG( |
| 39 | UACPI_DEFAULT_MAX_CALL_STACK_DEPTH < 4, |
| 40 | "configured default max call stack depth is invalid " |
| 41 | "(expecting at least 4 frames)" |
| 42 | ); |
| 43 | |
| 44 | /* |
| 45 | * =================== |
| 46 | * Kernel-api options |
| 47 | * =================== |
| 48 | */ |
| 49 | |
| 50 | /* |
| 51 | * Convenience initialization/deinitialization hooks that will be called by |
| 52 | * uACPI automatically when appropriate if compiled-in. |
| 53 | */ |
| 54 | // #define UACPI_KERNEL_INITIALIZATION |
| 55 | |
| 56 | /* |
| 57 | * Makes kernel api logging callbacks work with unformatted printf-style |
| 58 | * strings and va_args instead of a pre-formatted string. Can be useful if |
| 59 | * your native logging is implemented in terms of this format as well. |
| 60 | */ |
| 61 | // #define UACPI_FORMATTED_LOGGING |
| 62 | |
| 63 | /* |
| 64 | * Makes uacpi_kernel_free take in an additional 'size_hint' parameter, which |
| 65 | * contains the size of the original allocation. Note that this comes with a |
| 66 | * performance penalty in some cases. |
| 67 | */ |
| 68 | // #define UACPI_SIZED_FREES |
| 69 | |
| 70 | |
| 71 | /* |
| 72 | * Makes uacpi_kernel_alloc_zeroed mandatory to implement by the host, uACPI |
| 73 | * will not provide a default implementation if this is enabled. |
| 74 | */ |
| 75 | // #define UACPI_NATIVE_ALLOC_ZEROED |
| 76 | |
| 77 | /* |
| 78 | * ========================= |
| 79 | * Platform-specific options |
| 80 | * ========================= |
| 81 | */ |
| 82 | |
| 83 | /* |
| 84 | * Makes uACPI use the internal versions of mem{cpy,move,set,cmp} instead of |
| 85 | * relying on the host to provide them. Note that compilers like clang and GCC |
| 86 | * rely on these being available by default, even in freestanding mode, so |
| 87 | * compiling uACPI may theoretically generate implicit dependencies on them |
| 88 | * even if this option is defined. |
| 89 | */ |
| 90 | // #define UACPI_USE_BUILTIN_STRING |
| 91 | |
| 92 | /* |
| 93 | * Turns uacpi_phys_addr and uacpi_io_addr into a 32-bit type, and adds extra |
| 94 | * code for address truncation. Needed for e.g. i686 platforms without PAE |
| 95 | * support. |
| 96 | */ |
| 97 | // #define UACPI_PHYS_ADDR_IS_32BITS |
| 98 | |
| 99 | /* |
| 100 | * Switches uACPI into reduced-hardware-only mode. Strips all full-hardware |
| 101 | * ACPI support code at compile-time, including the event subsystem, the global |
| 102 | * lock, and other full-hardware features. |
| 103 | */ |
| 104 | // #define UACPI_REDUCED_HARDWARE |
| 105 | |
| 106 | /* |
| 107 | * Switches uACPI into tables-subsystem-only mode and strips all other code. |
| 108 | * This means only the table API will be usable, no other subsystems are |
| 109 | * compiled in. In this mode, uACPI only depends on the following kernel APIs: |
| 110 | * - uacpi_kernel_get_rsdp |
| 111 | * - uacpi_kernel_{map,unmap} |
| 112 | * - uacpi_kernel_log |
| 113 | * |
| 114 | * Use uacpi_setup_early_table_access to initialize, uacpi_state_reset to |
| 115 | * deinitialize. |
| 116 | * |
| 117 | * This mode is primarily designed for these three use-cases: |
| 118 | * - Bootloader/pre-kernel environments that need to parse ACPI tables, but |
| 119 | * don't actually need a fully-featured AML interpreter, and everything else |
| 120 | * that a full APCI implementation entails. |
| 121 | * - A micro-kernel that has the full AML interpreter running in userspace, but |
| 122 | * still needs to parse ACPI tables to bootstrap allocators, timers, SMP etc. |
| 123 | * - A WIP kernel that needs to parse ACPI tables for bootrapping SMP/timers, |
| 124 | * ECAM, etc., but doesn't yet have enough subsystems implemented in order |
| 125 | * to run a fully-featured AML interpreter. |
| 126 | */ |
| 127 | // #define UACPI_BAREBONES_MODE |
| 128 | |
| 129 | /* |
| 130 | * ============= |
| 131 | * Misc. options |
| 132 | * ============= |
| 133 | */ |
| 134 | |
| 135 | /* |
| 136 | * If UACPI_FORMATTED_LOGGING is not enabled, this is the maximum length of the |
| 137 | * pre-formatted message that is passed to the logging callback. |
| 138 | */ |
| 139 | #ifndef UACPI_PLAIN_LOG_BUFFER_SIZE |
| 140 | #define UACPI_PLAIN_LOG_BUFFER_SIZE 128 |
| 141 | #endif |
| 142 | |
| 143 | UACPI_BUILD_BUG_ON_WITH_MSG( |
| 144 | UACPI_PLAIN_LOG_BUFFER_SIZE < 16, |
| 145 | "configured log buffer size is too small (expecting at least 16 bytes)" |
| 146 | ); |
| 147 | |
| 148 | /* |
| 149 | * The size of the table descriptor inline storage. All table descriptors past |
| 150 | * this length will be stored in a dynamically allocated heap array. The size |
| 151 | * of one table descriptor is approximately 56 bytes. |
| 152 | */ |
| 153 | #ifndef UACPI_STATIC_TABLE_ARRAY_LEN |
| 154 | #define UACPI_STATIC_TABLE_ARRAY_LEN 16 |
| 155 | #endif |
| 156 | |
| 157 | UACPI_BUILD_BUG_ON_WITH_MSG( |
| 158 | UACPI_STATIC_TABLE_ARRAY_LEN < 1, |
| 159 | "configured static table array length is too small (expecting at least 1)" |
| 160 | ); |
| 161 | |
| 162 | #endif |
| 163 | |