aclinux.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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. #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_EXPORT_SYMBOL(symbol) EXPORT_SYMBOL(symbol);
  104. #define strtoul simple_strtoul
  105. #define acpi_cache_t struct kmem_cache
  106. #define acpi_spinlock spinlock_t *
  107. #define acpi_cpu_flags unsigned long
  108. /* Use native linux version of acpi_os_allocate_zeroed */
  109. #define USE_NATIVE_ALLOCATE_ZEROED
  110. /*
  111. * Overrides for in-kernel ACPICA
  112. */
  113. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize
  114. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate
  115. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate
  116. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate_zeroed
  117. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_free
  118. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_object
  119. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id
  120. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_lock
  121. /*
  122. * OSL interfaces used by debugger/disassembler
  123. */
  124. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_readable
  125. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_writable
  126. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize_command_signals
  127. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate_command_signals
  128. /*
  129. * OSL interfaces used by utilities
  130. */
  131. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_redirect_output
  132. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_name
  133. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_index
  134. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_address
  135. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_open_directory
  136. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_next_filename
  137. #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_close_directory
  138. #define ACPI_MSG_ERROR KERN_ERR "ACPI Error: "
  139. #define ACPI_MSG_EXCEPTION KERN_ERR "ACPI Exception: "
  140. #define ACPI_MSG_WARNING KERN_WARNING "ACPI Warning: "
  141. #define ACPI_MSG_INFO KERN_INFO "ACPI: "
  142. #define ACPI_MSG_BIOS_ERROR KERN_ERR "ACPI BIOS Error (bug): "
  143. #define ACPI_MSG_BIOS_WARNING KERN_WARNING "ACPI BIOS Warning (bug): "
  144. #else /* !__KERNEL__ */
  145. #define ACPI_USE_STANDARD_HEADERS
  146. #ifdef ACPI_USE_STANDARD_HEADERS
  147. #include <unistd.h>
  148. #endif
  149. /* Define/disable kernel-specific declarators */
  150. #ifndef __init
  151. #define __init
  152. #endif
  153. #ifndef __iomem
  154. #define __iomem
  155. #endif
  156. /* Host-dependent types and defines for user-space ACPICA */
  157. #define ACPI_FLUSH_CPU_CACHE()
  158. #define ACPI_CAST_PTHREAD_T(pthread) ((acpi_thread_id) (pthread))
  159. #if defined(__ia64__) || defined(__x86_64__) ||\
  160. defined(__aarch64__) || defined(__PPC64__)
  161. #define ACPI_MACHINE_WIDTH 64
  162. #define COMPILER_DEPENDENT_INT64 long
  163. #define COMPILER_DEPENDENT_UINT64 unsigned long
  164. #else
  165. #define ACPI_MACHINE_WIDTH 32
  166. #define COMPILER_DEPENDENT_INT64 long long
  167. #define COMPILER_DEPENDENT_UINT64 unsigned long long
  168. #define ACPI_USE_NATIVE_DIVIDE
  169. #endif
  170. #ifndef __cdecl
  171. #define __cdecl
  172. #endif
  173. #endif /* __KERNEL__ */
  174. #endif /* __ACLINUX_H__ */