aclinux.h 6.4 KB

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