aclinux.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
  2. /******************************************************************************
  3. *
  4. * Name: aclinux.h - OS specific defines, etc. for Linux
  5. *
  6. * Copyright (C) 2000 - 2022, Intel Corp.
  7. *
  8. *****************************************************************************/
  9. #ifndef __ACLINUX_H__
  10. #define __ACLINUX_H__
  11. #ifdef __KERNEL__
  12. /* ACPICA external files should not include ACPICA headers directly. */
  13. #if !defined(BUILDING_ACPICA) && !defined(_LINUX_ACPI_H)
  14. #error "Please don't include <acpi/acpi.h> directly, include <linux/acpi.h> instead."
  15. #endif
  16. #endif
  17. /* Common (in-kernel/user-space) ACPICA configuration */
  18. #define ACPI_USE_SYSTEM_CLIBRARY
  19. #define ACPI_USE_DO_WHILE_0
  20. #define ACPI_IGNORE_PACKAGE_RESOLUTION_ERRORS
  21. #ifdef __KERNEL__
  22. #define ACPI_USE_SYSTEM_INTTYPES
  23. #define ACPI_USE_GPE_POLLING
  24. /* Kernel specific ACPICA configuration */
  25. #ifdef CONFIG_PCI
  26. #define ACPI_PCI_CONFIGURED
  27. #endif
  28. #ifdef CONFIG_ACPI_REDUCED_HARDWARE_ONLY
  29. #define ACPI_REDUCED_HARDWARE 1
  30. #endif
  31. #ifdef CONFIG_ACPI_DEBUGGER
  32. #define ACPI_DEBUGGER
  33. #endif
  34. #ifdef CONFIG_ACPI_DEBUG
  35. #define ACPI_MUTEX_DEBUG
  36. #endif
  37. #include <linux/string.h>
  38. #include <linux/kernel.h>
  39. #include <linux/ctype.h>
  40. #include <linux/sched.h>
  41. #include <linux/atomic.h>
  42. #include <linux/math64.h>
  43. #include <linux/slab.h>
  44. #include <linux/spinlock_types.h>
  45. #ifdef EXPORT_ACPI_INTERFACES
  46. #include <linux/export.h>
  47. #endif
  48. #ifdef CONFIG_ACPI
  49. #include <asm/acenv.h>
  50. #endif
  51. #define ACPI_INIT_FUNCTION __init
  52. /* Use a specific bugging default separate from ACPICA */
  53. #undef ACPI_DEBUG_DEFAULT
  54. #define ACPI_DEBUG_DEFAULT (ACPI_LV_INFO | ACPI_LV_REPAIR)
  55. #ifndef CONFIG_ACPI
  56. /* External globals for __KERNEL__, stubs is needed */
  57. #define ACPI_GLOBAL(t,a)
  58. #define ACPI_INIT_GLOBAL(t,a,b)
  59. /* Generating stubs for configurable ACPICA macros */
  60. #define ACPI_NO_MEM_ALLOCATIONS
  61. /* Generating stubs for configurable ACPICA functions */
  62. #define ACPI_NO_ERROR_MESSAGES
  63. #undef ACPI_DEBUG_OUTPUT
  64. /* External interface for __KERNEL__, stub is needed */
  65. #define ACPI_EXTERNAL_RETURN_STATUS(prototype) \
  66. static ACPI_INLINE prototype {return(AE_NOT_CONFIGURED);}
  67. #define ACPI_EXTERNAL_RETURN_OK(prototype) \
  68. static ACPI_INLINE prototype {return(AE_OK);}
  69. #define ACPI_EXTERNAL_RETURN_VOID(prototype) \
  70. static ACPI_INLINE prototype {return;}
  71. #define ACPI_EXTERNAL_RETURN_UINT32(prototype) \
  72. static ACPI_INLINE prototype {return(0);}
  73. #define ACPI_EXTERNAL_RETURN_PTR(prototype) \
  74. static ACPI_INLINE prototype {return(NULL);}
  75. #endif /* CONFIG_ACPI */
  76. /* Host-dependent types and defines for in-kernel ACPICA */
  77. #define ACPI_MACHINE_WIDTH BITS_PER_LONG
  78. #define ACPI_USE_NATIVE_MATH64
  79. #define ACPI_EXPORT_SYMBOL(symbol) EXPORT_SYMBOL(symbol);
  80. #define strtoul simple_strtoul
  81. #define acpi_cache_t struct kmem_cache
  82. #define acpi_spinlock spinlock_t *
  83. #define acpi_raw_spinlock raw_spinlock_t *
  84. #define acpi_cpu_flags unsigned long
  85. #define acpi_uintptr_t uintptr_t
  86. #define ACPI_TO_INTEGER(p) ((uintptr_t)(p))
  87. #define ACPI_OFFSET(d, f) offsetof(d, f)
  88. /* Use native linux version of acpi_os_allocate_zeroed */
  89. #define USE_NATIVE_ALLOCATE_ZEROED
  90. /* Use logical addresses for accessing GPE registers in system memory */
  91. #define ACPI_GPE_USE_LOGICAL_ADDRESSES
  92. /*
  93. * Overrides for in-kernel ACPICA
  94. */
  95. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize
  96. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate
  97. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate
  98. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate_zeroed
  99. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_free
  100. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_object
  101. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id
  102. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_lock
  103. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_raw_lock
  104. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_raw_lock
  105. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_raw_lock
  106. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_release_raw_lock
  107. /*
  108. * OSL interfaces used by debugger/disassembler
  109. */
  110. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_readable
  111. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_writable
  112. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize_debugger
  113. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate_debugger
  114. /*
  115. * OSL interfaces used by utilities
  116. */
  117. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_redirect_output
  118. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_name
  119. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_index
  120. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_address
  121. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_open_directory
  122. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_next_filename
  123. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_close_directory
  124. #define ACPI_MSG_ERROR KERN_ERR "ACPI Error: "
  125. #define ACPI_MSG_EXCEPTION KERN_ERR "ACPI Exception: "
  126. #define ACPI_MSG_WARNING KERN_WARNING "ACPI Warning: "
  127. #define ACPI_MSG_INFO KERN_INFO "ACPI: "
  128. #define ACPI_MSG_BIOS_ERROR KERN_ERR "ACPI BIOS Error (bug): "
  129. #define ACPI_MSG_BIOS_WARNING KERN_WARNING "ACPI BIOS Warning (bug): "
  130. /*
  131. * Linux wants to use designated initializers for function pointer structs.
  132. */
  133. #define ACPI_STRUCT_INIT(field, value) .field = value
  134. #else /* !__KERNEL__ */
  135. #define ACPI_USE_STANDARD_HEADERS
  136. #ifdef ACPI_USE_STANDARD_HEADERS
  137. #include <unistd.h>
  138. #endif
  139. /* Define/disable kernel-specific declarators */
  140. #ifndef __init
  141. #define __init
  142. #endif
  143. #ifndef __iomem
  144. #define __iomem
  145. #endif
  146. /* Host-dependent types and defines for user-space ACPICA */
  147. #define ACPI_FLUSH_CPU_CACHE()
  148. #define ACPI_CAST_PTHREAD_T(pthread) ((acpi_thread_id) (pthread))
  149. #if defined(__ia64__) || (defined(__x86_64__) && !defined(__ILP32__)) ||\
  150. defined(__aarch64__) || defined(__PPC64__) ||\
  151. defined(__s390x__) ||\
  152. (defined(__riscv) && (defined(__LP64__) || defined(_LP64)))
  153. #define ACPI_MACHINE_WIDTH 64
  154. #define COMPILER_DEPENDENT_INT64 long
  155. #define COMPILER_DEPENDENT_UINT64 unsigned long
  156. #else
  157. #define ACPI_MACHINE_WIDTH 32
  158. #define COMPILER_DEPENDENT_INT64 long long
  159. #define COMPILER_DEPENDENT_UINT64 unsigned long long
  160. #define ACPI_USE_NATIVE_DIVIDE
  161. #define ACPI_USE_NATIVE_MATH64
  162. #endif
  163. #ifndef __cdecl
  164. #define __cdecl
  165. #endif
  166. #endif /* __KERNEL__ */
  167. #endif /* __ACLINUX_H__ */