aclinux.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /******************************************************************************
  2. *
  3. * Name: aclinux.h - OS specific defines, etc. for Linux
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2016, 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. #ifndef CONFIG_ACPI
  80. /* External globals for __KERNEL__, stubs is needed */
  81. #define ACPI_GLOBAL(t,a)
  82. #define ACPI_INIT_GLOBAL(t,a,b)
  83. /* Generating stubs for configurable ACPICA macros */
  84. #define ACPI_NO_MEM_ALLOCATIONS
  85. /* Generating stubs for configurable ACPICA functions */
  86. #define ACPI_NO_ERROR_MESSAGES
  87. #undef ACPI_DEBUG_OUTPUT
  88. /* External interface for __KERNEL__, stub is needed */
  89. #define ACPI_EXTERNAL_RETURN_STATUS(prototype) \
  90. static ACPI_INLINE prototype {return(AE_NOT_CONFIGURED);}
  91. #define ACPI_EXTERNAL_RETURN_OK(prototype) \
  92. static ACPI_INLINE prototype {return(AE_OK);}
  93. #define ACPI_EXTERNAL_RETURN_VOID(prototype) \
  94. static ACPI_INLINE prototype {return;}
  95. #define ACPI_EXTERNAL_RETURN_UINT32(prototype) \
  96. static ACPI_INLINE prototype {return(0);}
  97. #define ACPI_EXTERNAL_RETURN_PTR(prototype) \
  98. static ACPI_INLINE prototype {return(NULL);}
  99. #endif /* CONFIG_ACPI */
  100. /* Host-dependent types and defines for in-kernel ACPICA */
  101. #define ACPI_MACHINE_WIDTH BITS_PER_LONG
  102. #define ACPI_EXPORT_SYMBOL(symbol) EXPORT_SYMBOL(symbol);
  103. #define strtoul simple_strtoul
  104. #define acpi_cache_t struct kmem_cache
  105. #define acpi_spinlock spinlock_t *
  106. #define acpi_cpu_flags unsigned long
  107. /* Use native linux version of acpi_os_allocate_zeroed */
  108. #define USE_NATIVE_ALLOCATE_ZEROED
  109. /*
  110. * Overrides for in-kernel ACPICA
  111. */
  112. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize
  113. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate
  114. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate
  115. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate_zeroed
  116. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_free
  117. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_object
  118. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id
  119. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_lock
  120. /*
  121. * OSL interfaces used by debugger/disassembler
  122. */
  123. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_readable
  124. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_writable
  125. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize_command_signals
  126. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate_command_signals
  127. /*
  128. * OSL interfaces used by utilities
  129. */
  130. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_redirect_output
  131. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_name
  132. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_index
  133. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_address
  134. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_open_directory
  135. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_next_filename
  136. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_close_directory
  137. #else /* !__KERNEL__ */
  138. #include <stdarg.h>
  139. #include <string.h>
  140. #include <stdlib.h>
  141. #include <ctype.h>
  142. #include <unistd.h>
  143. /* Define/disable kernel-specific declarators */
  144. #ifndef __init
  145. #define __init
  146. #endif
  147. /* Host-dependent types and defines for user-space ACPICA */
  148. #define ACPI_FLUSH_CPU_CACHE()
  149. #define ACPI_CAST_PTHREAD_T(pthread) ((acpi_thread_id) (pthread))
  150. #if defined(__ia64__) || defined(__x86_64__) ||\
  151. defined(__aarch64__) || defined(__PPC64__)
  152. #define ACPI_MACHINE_WIDTH 64
  153. #define COMPILER_DEPENDENT_INT64 long
  154. #define COMPILER_DEPENDENT_UINT64 unsigned long
  155. #else
  156. #define ACPI_MACHINE_WIDTH 32
  157. #define COMPILER_DEPENDENT_INT64 long long
  158. #define COMPILER_DEPENDENT_UINT64 unsigned long long
  159. #define ACPI_USE_NATIVE_DIVIDE
  160. #endif
  161. #ifndef __cdecl
  162. #define __cdecl
  163. #endif
  164. #endif /* __KERNEL__ */
  165. /* Linux uses GCC */
  166. #include <acpi/platform/acgcc.h>
  167. #endif /* __ACLINUX_H__ */