aclinux.h 6.5 KB

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