aclinux.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /******************************************************************************
  2. *
  3. * Name: aclinux.h - OS specific defines, etc. for Linux
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2017, Intel Corp.
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions, and the following disclaimer,
  15. * without modification.
  16. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  17. * substantially similar to the "NO WARRANTY" disclaimer below
  18. * ("Disclaimer") and any redistribution must be conditioned upon
  19. * including a substantially similar Disclaimer requirement for further
  20. * binary redistribution.
  21. * 3. Neither the names of the above-listed copyright holders nor the names
  22. * of any contributors may be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * Alternatively, this software may be distributed under the terms of the
  26. * GNU General Public License ("GPL") version 2 as published by the Free
  27. * Software Foundation.
  28. *
  29. * NO WARRANTY
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  31. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  32. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  33. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  34. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  35. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  36. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  38. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  39. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. * POSSIBILITY OF SUCH DAMAGES.
  41. */
  42. #ifndef __ACLINUX_H__
  43. #define __ACLINUX_H__
  44. #ifdef __KERNEL__
  45. /* ACPICA external files should not include ACPICA headers directly. */
  46. #if !defined(BUILDING_ACPICA) && !defined(_LINUX_ACPI_H)
  47. #error "Please don't include <acpi/acpi.h> directly, include <linux/acpi.h> instead."
  48. #endif
  49. #endif
  50. /* Common (in-kernel/user-space) ACPICA configuration */
  51. #define ACPI_USE_SYSTEM_CLIBRARY
  52. #define ACPI_USE_DO_WHILE_0
  53. #ifdef __KERNEL__
  54. #define ACPI_USE_SYSTEM_INTTYPES
  55. /* Kernel specific ACPICA configuration */
  56. #ifdef CONFIG_ACPI_REDUCED_HARDWARE_ONLY
  57. #define ACPI_REDUCED_HARDWARE 1
  58. #endif
  59. #ifdef CONFIG_ACPI_DEBUGGER
  60. #define ACPI_DEBUGGER
  61. #endif
  62. #ifdef CONFIG_ACPI_DEBUG
  63. #define ACPI_MUTEX_DEBUG
  64. #endif
  65. #include <linux/string.h>
  66. #include <linux/kernel.h>
  67. #include <linux/ctype.h>
  68. #include <linux/sched.h>
  69. #include <linux/atomic.h>
  70. #include <linux/math64.h>
  71. #include <linux/slab.h>
  72. #include <linux/spinlock_types.h>
  73. #ifdef EXPORT_ACPI_INTERFACES
  74. #include <linux/export.h>
  75. #endif
  76. #ifdef CONFIG_ACPI
  77. #include <asm/acenv.h>
  78. #endif
  79. #define ACPI_INIT_FUNCTION __init
  80. #ifndef CONFIG_ACPI
  81. /* External globals for __KERNEL__, stubs is needed */
  82. #define ACPI_GLOBAL(t,a)
  83. #define ACPI_INIT_GLOBAL(t,a,b)
  84. /* Generating stubs for configurable ACPICA macros */
  85. #define ACPI_NO_MEM_ALLOCATIONS
  86. /* Generating stubs for configurable ACPICA functions */
  87. #define ACPI_NO_ERROR_MESSAGES
  88. #undef ACPI_DEBUG_OUTPUT
  89. /* External interface for __KERNEL__, stub is needed */
  90. #define ACPI_EXTERNAL_RETURN_STATUS(prototype) \
  91. static ACPI_INLINE prototype {return(AE_NOT_CONFIGURED);}
  92. #define ACPI_EXTERNAL_RETURN_OK(prototype) \
  93. static ACPI_INLINE prototype {return(AE_OK);}
  94. #define ACPI_EXTERNAL_RETURN_VOID(prototype) \
  95. static ACPI_INLINE prototype {return;}
  96. #define ACPI_EXTERNAL_RETURN_UINT32(prototype) \
  97. static ACPI_INLINE prototype {return(0);}
  98. #define ACPI_EXTERNAL_RETURN_PTR(prototype) \
  99. static ACPI_INLINE prototype {return(NULL);}
  100. #endif /* CONFIG_ACPI */
  101. /* Host-dependent types and defines for in-kernel ACPICA */
  102. #define ACPI_MACHINE_WIDTH BITS_PER_LONG
  103. #define ACPI_USE_NATIVE_MATH64
  104. #define ACPI_EXPORT_SYMBOL(symbol) EXPORT_SYMBOL(symbol);
  105. #define strtoul simple_strtoul
  106. #define acpi_cache_t struct kmem_cache
  107. #define acpi_spinlock spinlock_t *
  108. #define acpi_cpu_flags unsigned long
  109. /* Use native linux version of acpi_os_allocate_zeroed */
  110. #define USE_NATIVE_ALLOCATE_ZEROED
  111. /*
  112. * Overrides for in-kernel ACPICA
  113. */
  114. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize
  115. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate
  116. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate
  117. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate_zeroed
  118. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_free
  119. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_object
  120. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id
  121. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_lock
  122. /*
  123. * OSL interfaces used by debugger/disassembler
  124. */
  125. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_readable
  126. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_writable
  127. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize_debugger
  128. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate_debugger
  129. /*
  130. * OSL interfaces used by utilities
  131. */
  132. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_redirect_output
  133. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_name
  134. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_index
  135. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_address
  136. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_open_directory
  137. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_next_filename
  138. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_close_directory
  139. #define ACPI_MSG_ERROR KERN_ERR "ACPI Error: "
  140. #define ACPI_MSG_EXCEPTION KERN_ERR "ACPI Exception: "
  141. #define ACPI_MSG_WARNING KERN_WARNING "ACPI Warning: "
  142. #define ACPI_MSG_INFO KERN_INFO "ACPI: "
  143. #define ACPI_MSG_BIOS_ERROR KERN_ERR "ACPI BIOS Error (bug): "
  144. #define ACPI_MSG_BIOS_WARNING KERN_WARNING "ACPI BIOS Warning (bug): "
  145. /*
  146. * Linux wants to use designated initializers for function pointer structs.
  147. */
  148. #define ACPI_STRUCT_INIT(field, value) .field = value
  149. #else /* !__KERNEL__ */
  150. #define ACPI_USE_STANDARD_HEADERS
  151. #ifdef ACPI_USE_STANDARD_HEADERS
  152. #include <unistd.h>
  153. #endif
  154. /* Define/disable kernel-specific declarators */
  155. #ifndef __init
  156. #define __init
  157. #endif
  158. #ifndef __iomem
  159. #define __iomem
  160. #endif
  161. /* Host-dependent types and defines for user-space ACPICA */
  162. #define ACPI_FLUSH_CPU_CACHE()
  163. #define ACPI_CAST_PTHREAD_T(pthread) ((acpi_thread_id) (pthread))
  164. #if defined(__ia64__) || defined(__x86_64__) ||\
  165. defined(__aarch64__) || defined(__PPC64__) ||\
  166. defined(__s390x__)
  167. #define ACPI_MACHINE_WIDTH 64
  168. #define COMPILER_DEPENDENT_INT64 long
  169. #define COMPILER_DEPENDENT_UINT64 unsigned long
  170. #else
  171. #define ACPI_MACHINE_WIDTH 32
  172. #define COMPILER_DEPENDENT_INT64 long long
  173. #define COMPILER_DEPENDENT_UINT64 unsigned long long
  174. #define ACPI_USE_NATIVE_DIVIDE
  175. #define ACPI_USE_NATIVE_MATH64
  176. #endif
  177. #ifndef __cdecl
  178. #define __cdecl
  179. #endif
  180. #endif /* __KERNEL__ */
  181. #endif /* __ACLINUX_H__ */