acenv.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
  2. /******************************************************************************
  3. *
  4. * Name: acenv.h - Host and compiler configuration
  5. *
  6. * Copyright (C) 2000 - 2025, Intel Corp.
  7. *
  8. *****************************************************************************/
  9. #ifndef __ACENV_H__
  10. #define __ACENV_H__
  11. /*
  12. * Environment configuration. The purpose of this file is to interface ACPICA
  13. * to the local environment. This includes compiler-specific, OS-specific,
  14. * and machine-specific configuration.
  15. */
  16. /* Types for ACPI_MUTEX_TYPE */
  17. #define ACPI_BINARY_SEMAPHORE 0
  18. #define ACPI_OSL_MUTEX 1
  19. /* Types for DEBUGGER_THREADING */
  20. #define DEBUGGER_SINGLE_THREADED 0
  21. #define DEBUGGER_MULTI_THREADED 1
  22. /******************************************************************************
  23. *
  24. * Configuration for ACPI tools and utilities
  25. *
  26. *****************************************************************************/
  27. /* Common application configuration. All single threaded except for acpi_exec. */
  28. #if (defined ACPI_ASL_COMPILER) || \
  29. (defined ACPI_BIN_APP) || \
  30. (defined ACPI_DUMP_APP) || \
  31. (defined ACPI_HELP_APP) || \
  32. (defined ACPI_NAMES_APP) || \
  33. (defined ACPI_SRC_APP) || \
  34. (defined ACPI_XTRACT_APP) || \
  35. (defined ACPI_EXAMPLE_APP) || \
  36. (defined ACPI_EFI_HELLO)
  37. #define ACPI_APPLICATION
  38. #define ACPI_SINGLE_THREADED
  39. #define USE_NATIVE_ALLOCATE_ZEROED
  40. #endif
  41. /* iASL configuration */
  42. #ifdef ACPI_ASL_COMPILER
  43. #define ACPI_DEBUG_OUTPUT
  44. #define ACPI_CONSTANT_EVAL_ONLY
  45. #define ACPI_LARGE_NAMESPACE_NODE
  46. #define ACPI_DATA_TABLE_DISASSEMBLY
  47. #define ACPI_32BIT_PHYSICAL_ADDRESS
  48. #define ACPI_DISASSEMBLER 1
  49. #endif
  50. /* acpi_exec configuration. Multithreaded with full AML debugger */
  51. #ifdef ACPI_EXEC_APP
  52. #define ACPI_APPLICATION
  53. #define ACPI_FULL_DEBUG
  54. #define ACPI_MUTEX_DEBUG
  55. #define ACPI_DBG_TRACK_ALLOCATIONS
  56. #endif
  57. /* acpi_help configuration. Error messages disabled. */
  58. #ifdef ACPI_HELP_APP
  59. #define ACPI_NO_ERROR_MESSAGES
  60. #endif
  61. /* acpi_names configuration. Debug output enabled. */
  62. #ifdef ACPI_NAMES_APP
  63. #define ACPI_DEBUG_OUTPUT
  64. #endif
  65. /* acpi_exec/acpi_names/Example configuration. Native RSDP used. */
  66. #if (defined ACPI_EXEC_APP) || \
  67. (defined ACPI_EXAMPLE_APP) || \
  68. (defined ACPI_NAMES_APP)
  69. #define ACPI_USE_NATIVE_RSDP_POINTER
  70. #endif
  71. /* acpi_dump configuration. Native mapping used if provided by the host */
  72. #ifdef ACPI_DUMP_APP
  73. #define ACPI_USE_NATIVE_MEMORY_MAPPING
  74. #endif
  75. /* acpi_names/Example configuration. Hardware disabled */
  76. #if (defined ACPI_EXAMPLE_APP) || \
  77. (defined ACPI_NAMES_APP)
  78. #define ACPI_REDUCED_HARDWARE 1
  79. #endif
  80. /* Linkable ACPICA library. Two versions, one with full debug. */
  81. #ifdef ACPI_LIBRARY
  82. #define ACPI_USE_LOCAL_CACHE
  83. #define ACPI_DEBUGGER 1
  84. #define ACPI_DISASSEMBLER 1
  85. #ifdef _DEBUG
  86. #define ACPI_DEBUG_OUTPUT
  87. #endif
  88. #endif
  89. /* Common for all ACPICA applications */
  90. #ifdef ACPI_APPLICATION
  91. #define ACPI_USE_LOCAL_CACHE
  92. #endif
  93. /* Common debug/disassembler support */
  94. #ifdef ACPI_FULL_DEBUG
  95. #define ACPI_DEBUG_OUTPUT
  96. #define ACPI_DEBUGGER 1
  97. #define ACPI_DISASSEMBLER 1
  98. #endif
  99. /*
  100. * acpisrc CR\LF support
  101. * Unix file line endings do not include the carriage return.
  102. * If the acpisrc utility is being built using a microsoft compiler, it means
  103. * that it will be running on a windows machine which means that the output is
  104. * expected to have CR/LF newlines. If the acpisrc utility is built with
  105. * anything else, it will likely run on a system with LF newlines. This flag
  106. * tells the acpisrc utility that newlines will be in the LF format.
  107. */
  108. #define ACPI_SRC_OS_LF_ONLY 0
  109. /*! [Begin] no source code translation */
  110. /******************************************************************************
  111. *
  112. * Host configuration files. The compiler configuration files are included
  113. * first.
  114. *
  115. *****************************************************************************/
  116. #if defined(__GNUC__)
  117. #include <acpi/platform/acgcc.h>
  118. #elif defined(_MSC_VER)
  119. #include "acmsvc.h"
  120. #endif
  121. #if defined(_LINUX) || defined(__linux__)
  122. #include <acpi/platform/aclinux.h>
  123. #elif defined(_APPLE) || defined(__APPLE__)
  124. #include "acmacosx.h"
  125. #elif defined(__DragonFly__)
  126. #include "acdragonfly.h"
  127. #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
  128. #include "acfreebsd.h"
  129. #elif defined(__NetBSD__)
  130. #include "acnetbsd.h"
  131. #elif defined(__sun)
  132. #include "acsolaris.h"
  133. #elif defined(MODESTO)
  134. #include "acmodesto.h"
  135. #elif defined(NETWARE)
  136. #include "acnetware.h"
  137. #elif defined(_CYGWIN)
  138. #include "accygwin.h"
  139. #elif defined(WIN32)
  140. #include "acwin.h"
  141. #elif defined(WIN64)
  142. #include "acwin64.h"
  143. #elif defined(_WRS_LIB_BUILD)
  144. #include "acvxworks.h"
  145. #elif defined(__OS2__)
  146. #include "acos2.h"
  147. #elif defined(__HAIKU__)
  148. #include "achaiku.h"
  149. #elif defined(__QNX__)
  150. #include "acqnx.h"
  151. /*
  152. * EFI applications can be built with -nostdlib, in this case, it must be
  153. * included after including all other host environmental definitions, in
  154. * order to override the definitions.
  155. */
  156. #elif defined(_AED_EFI) || defined(_GNU_EFI) || defined(_EDK2_EFI)
  157. #include "acefi.h"
  158. #elif defined(__ZEPHYR__)
  159. #include "aczephyr.h"
  160. #else
  161. /* Unknown environment */
  162. #error Unknown target environment
  163. #endif
  164. /*! [End] no source code translation !*/
  165. /******************************************************************************
  166. *
  167. * Setup defaults for the required symbols that were not defined in one of
  168. * the host/compiler files above.
  169. *
  170. *****************************************************************************/
  171. /* 64-bit data types */
  172. #ifndef COMPILER_DEPENDENT_INT64
  173. #define COMPILER_DEPENDENT_INT64 long long
  174. #endif
  175. #ifndef COMPILER_DEPENDENT_UINT64
  176. #define COMPILER_DEPENDENT_UINT64 unsigned long long
  177. #endif
  178. /* Type of mutex supported by host. Default is binary semaphores. */
  179. #ifndef ACPI_MUTEX_TYPE
  180. #define ACPI_MUTEX_TYPE ACPI_BINARY_SEMAPHORE
  181. #endif
  182. /* Global Lock acquire/release */
  183. #ifndef ACPI_ACQUIRE_GLOBAL_LOCK
  184. #define ACPI_ACQUIRE_GLOBAL_LOCK(Glptr, acquired) acquired = 1
  185. #endif
  186. #ifndef ACPI_RELEASE_GLOBAL_LOCK
  187. #define ACPI_RELEASE_GLOBAL_LOCK(Glptr, pending) pending = 0
  188. #endif
  189. /* NULL/invalid value to use for destroyed or not-yet-created semaphores. */
  190. #ifndef ACPI_SEMAPHORE_NULL
  191. #define ACPI_SEMAPHORE_NULL NULL
  192. #endif
  193. /* Flush CPU cache - used when going to sleep. Wbinvd or similar. */
  194. #ifndef ACPI_FLUSH_CPU_CACHE
  195. #define ACPI_FLUSH_CPU_CACHE()
  196. #endif
  197. /* "inline" keywords - configurable since inline is not standardized */
  198. #ifndef ACPI_INLINE
  199. #define ACPI_INLINE
  200. #endif
  201. /* Use ordered initialization if compiler doesn't support designated. */
  202. #ifndef ACPI_STRUCT_INIT
  203. #define ACPI_STRUCT_INIT(field, value) value
  204. #endif
  205. /*
  206. * Configurable calling conventions:
  207. *
  208. * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
  209. * ACPI_EXTERNAL_XFACE - External ACPI interfaces
  210. * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
  211. * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
  212. */
  213. #ifndef ACPI_SYSTEM_XFACE
  214. #define ACPI_SYSTEM_XFACE
  215. #endif
  216. #ifndef ACPI_EXTERNAL_XFACE
  217. #define ACPI_EXTERNAL_XFACE
  218. #endif
  219. #ifndef ACPI_INTERNAL_XFACE
  220. #define ACPI_INTERNAL_XFACE
  221. #endif
  222. #ifndef ACPI_INTERNAL_VAR_XFACE
  223. #define ACPI_INTERNAL_VAR_XFACE
  224. #endif
  225. /*
  226. * Debugger threading model
  227. * Use single threaded if the entire subsystem is contained in an application
  228. * Use multiple threaded when the subsystem is running in the kernel.
  229. *
  230. * By default the model is single threaded if ACPI_APPLICATION is set,
  231. * multi-threaded if ACPI_APPLICATION is not set.
  232. */
  233. #ifndef DEBUGGER_THREADING
  234. #if !defined (ACPI_APPLICATION) || defined (ACPI_EXEC_APP)
  235. #define DEBUGGER_THREADING DEBUGGER_MULTI_THREADED
  236. #else
  237. #define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED
  238. #endif
  239. #endif /* !DEBUGGER_THREADING */
  240. /******************************************************************************
  241. *
  242. * C library configuration
  243. *
  244. *****************************************************************************/
  245. /*
  246. * ACPI_USE_SYSTEM_CLIBRARY - Define this if linking to an actual C library.
  247. * Otherwise, local versions of string/memory functions will be used.
  248. * ACPI_USE_STANDARD_HEADERS - Define this if linking to a C library and
  249. * the standard header files may be used. Defining this implies that
  250. * ACPI_USE_SYSTEM_CLIBRARY has been defined.
  251. *
  252. * The ACPICA subsystem only uses low level C library functions that do not
  253. * call operating system services and may therefore be inlined in the code.
  254. *
  255. * It may be necessary to tailor these include files to the target
  256. * generation environment.
  257. */
  258. /* Use the standard C library headers. We want to keep these to a minimum. */
  259. #ifdef ACPI_USE_STANDARD_HEADERS
  260. /* Use the standard headers from the standard locations */
  261. #include <stdlib.h>
  262. #include <string.h>
  263. #include <ctype.h>
  264. #if defined (ACPI_APPLICATION) || defined(ACPI_LIBRARY)
  265. #include <stdio.h>
  266. #include <fcntl.h>
  267. #include <errno.h>
  268. #include <time.h>
  269. #include <signal.h>
  270. #endif
  271. #endif /* ACPI_USE_STANDARD_HEADERS */
  272. #ifdef ACPI_APPLICATION
  273. #define ACPI_FILE FILE *
  274. #define ACPI_FILE_OUT stdout
  275. #define ACPI_FILE_ERR stderr
  276. #else
  277. #define ACPI_FILE void *
  278. #define ACPI_FILE_OUT NULL
  279. #define ACPI_FILE_ERR NULL
  280. #endif /* ACPI_APPLICATION */
  281. #ifndef ACPI_INIT_FUNCTION
  282. #define ACPI_INIT_FUNCTION
  283. #endif
  284. #endif /* __ACENV_H__ */