aclinux.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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 - 2018, 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_ACPI_REDUCED_HARDWARE_ONLY
  26. #define ACPI_REDUCED_HARDWARE 1
  27. #endif
  28. #ifdef CONFIG_ACPI_DEBUGGER
  29. #define ACPI_DEBUGGER
  30. #endif
  31. #ifdef CONFIG_ACPI_DEBUG
  32. #define ACPI_MUTEX_DEBUG
  33. #endif
  34. #include <linux/string.h>
  35. #include <linux/kernel.h>
  36. #include <linux/ctype.h>
  37. #include <linux/sched.h>
  38. #include <linux/atomic.h>
  39. #include <linux/math64.h>
  40. #include <linux/slab.h>
  41. #include <linux/spinlock_types.h>
  42. #ifdef EXPORT_ACPI_INTERFACES
  43. #include <linux/export.h>
  44. #endif
  45. #ifdef CONFIG_ACPI
  46. #include <asm/acenv.h>
  47. #endif
  48. #define ACPI_INIT_FUNCTION __init
  49. #ifndef CONFIG_ACPI
  50. /* External globals for __KERNEL__, stubs is needed */
  51. #define ACPI_GLOBAL(t,a)
  52. #define ACPI_INIT_GLOBAL(t,a,b)
  53. /* Generating stubs for configurable ACPICA macros */
  54. #define ACPI_NO_MEM_ALLOCATIONS
  55. /* Generating stubs for configurable ACPICA functions */
  56. #define ACPI_NO_ERROR_MESSAGES
  57. #undef ACPI_DEBUG_OUTPUT
  58. /* External interface for __KERNEL__, stub is needed */
  59. #define ACPI_EXTERNAL_RETURN_STATUS(prototype) \
  60. static ACPI_INLINE prototype {return(AE_NOT_CONFIGURED);}
  61. #define ACPI_EXTERNAL_RETURN_OK(prototype) \
  62. static ACPI_INLINE prototype {return(AE_OK);}
  63. #define ACPI_EXTERNAL_RETURN_VOID(prototype) \
  64. static ACPI_INLINE prototype {return;}
  65. #define ACPI_EXTERNAL_RETURN_UINT32(prototype) \
  66. static ACPI_INLINE prototype {return(0);}
  67. #define ACPI_EXTERNAL_RETURN_PTR(prototype) \
  68. static ACPI_INLINE prototype {return(NULL);}
  69. #endif /* CONFIG_ACPI */
  70. /* Host-dependent types and defines for in-kernel ACPICA */
  71. #define ACPI_MACHINE_WIDTH BITS_PER_LONG
  72. #define ACPI_USE_NATIVE_MATH64
  73. #define ACPI_EXPORT_SYMBOL(symbol) EXPORT_SYMBOL(symbol);
  74. #define strtoul simple_strtoul
  75. #define acpi_cache_t struct kmem_cache
  76. #define acpi_spinlock spinlock_t *
  77. #define acpi_raw_spinlock raw_spinlock_t *
  78. #define acpi_cpu_flags unsigned long
  79. /* Use native linux version of acpi_os_allocate_zeroed */
  80. #define USE_NATIVE_ALLOCATE_ZEROED
  81. /*
  82. * Overrides for in-kernel ACPICA
  83. */
  84. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize
  85. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate
  86. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate
  87. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate_zeroed
  88. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_free
  89. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_object
  90. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id
  91. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_lock
  92. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_raw_lock
  93. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_raw_lock
  94. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_raw_lock
  95. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_release_raw_lock
  96. /*
  97. * OSL interfaces used by debugger/disassembler
  98. */
  99. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_readable
  100. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_writable
  101. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize_debugger
  102. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate_debugger
  103. /*
  104. * OSL interfaces used by utilities
  105. */
  106. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_redirect_output
  107. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_name
  108. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_index
  109. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_address
  110. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_open_directory
  111. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_next_filename
  112. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_close_directory
  113. #define ACPI_MSG_ERROR KERN_ERR "ACPI Error: "
  114. #define ACPI_MSG_EXCEPTION KERN_ERR "ACPI Exception: "
  115. #define ACPI_MSG_WARNING KERN_WARNING "ACPI Warning: "
  116. #define ACPI_MSG_INFO KERN_INFO "ACPI: "
  117. #define ACPI_MSG_BIOS_ERROR KERN_ERR "ACPI BIOS Error (bug): "
  118. #define ACPI_MSG_BIOS_WARNING KERN_WARNING "ACPI BIOS Warning (bug): "
  119. /*
  120. * Linux wants to use designated initializers for function pointer structs.
  121. */
  122. #define ACPI_STRUCT_INIT(field, value) .field = value
  123. #else /* !__KERNEL__ */
  124. #define ACPI_USE_STANDARD_HEADERS
  125. #ifdef ACPI_USE_STANDARD_HEADERS
  126. #include <unistd.h>
  127. #endif
  128. /* Define/disable kernel-specific declarators */
  129. #ifndef __init
  130. #define __init
  131. #endif
  132. #ifndef __iomem
  133. #define __iomem
  134. #endif
  135. /* Host-dependent types and defines for user-space ACPICA */
  136. #define ACPI_FLUSH_CPU_CACHE()
  137. #define ACPI_CAST_PTHREAD_T(pthread) ((acpi_thread_id) (pthread))
  138. #if defined(__ia64__) || (defined(__x86_64__) && !defined(__ILP32__)) ||\
  139. defined(__aarch64__) || defined(__PPC64__) ||\
  140. defined(__s390x__)
  141. #define ACPI_MACHINE_WIDTH 64
  142. #define COMPILER_DEPENDENT_INT64 long
  143. #define COMPILER_DEPENDENT_UINT64 unsigned long
  144. #else
  145. #define ACPI_MACHINE_WIDTH 32
  146. #define COMPILER_DEPENDENT_INT64 long long
  147. #define COMPILER_DEPENDENT_UINT64 unsigned long long
  148. #define ACPI_USE_NATIVE_DIVIDE
  149. #define ACPI_USE_NATIVE_MATH64
  150. #endif
  151. #ifndef __cdecl
  152. #define __cdecl
  153. #endif
  154. #endif /* __KERNEL__ */
  155. #endif /* __ACLINUX_H__ */