diff options
author | Lv Zheng <lv.zheng@intel.com> | 2014-05-12 03:46:32 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-05-27 12:13:07 -0400 |
commit | d13bd5a602982cd7f697e39b13ac736c2c553af1 (patch) | |
tree | d2c19fde5c0dfde6a4e3b10f73512758509dbb7b /include/acpi/platform | |
parent | 636fcfefa2a45f5b54f475309928ef191b27dd19 (diff) |
ACPICA: Linux headers: Add <acpi/platform/aclinuxex.h>
From ACPICA's perspective, <acpi/actypes.h> should be included after
inclusion of <acpi/platform/acenv.h>. But currently in Linux,
<acpi/platform/aclinux.h> included by <acpi/platform/acenv.h> has
included <acpi/actypes.h> to find ACPICA types for inline functions.
This causes the following problem:
1. Redundant code in <asm/acpi.h> and <acpi/platform/aclinux.h>:
Linux must be careful to keep conditions for <acpi/actypes.h> inclusion
consistent with the conditions for <acpi/platform/aclinux.h> inclusion.
Which finally leads to the issue that we have to keep many useless macro
definitions in <acpi/platform/aclinux.h> or <asm/acpi.h>.
Such conditions include:
COMPILER_DEPENDENT_UINT64
COMPILER_DEPENDENT_INT64
ACPI_INLINE
ACPI_SYSTEM_XFACE
ACPI_EXTERNAL_XFACE
ACPI_INTERNAL_XFACE
ACPI_INTERNAL_VAR_XFACE
ACPI_MUTEX_TYPE
DEBUGGER_THREADING
ACPI_ACQUIRE_GLOBAL_LOCK
ACPI_RELEASE_GLOBAL_LOCK
ACPI_FLUSH_CPU_CACHE
They have default implementations in <include/acpi/platform/acenv.h>
while Linux need to keep a copy in <asm/acpi.h> to avoid build errors.
This patch introduces <acpi/platform/aclinuxex.h> to fix this issue by
splitting conditions and declarations (most of them are inline functions)
into 2 header files so that the wrong inclusion of <acpi/actypes.h> can be
removed from <acpi/platform/aclinux.h>.
This patch also removes old ACPI_NATIVE_INTERFACE_HEADER mechanism which is
not preferred by Linux and adds the platform/acenvex.h to be the solution
to solve this issue.
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'include/acpi/platform')
-rw-r--r-- | include/acpi/platform/acenvex.h | 63 | ||||
-rw-r--r-- | include/acpi/platform/aclinux.h | 154 | ||||
-rw-r--r-- | include/acpi/platform/aclinuxex.h | 116 |
3 files changed, 215 insertions, 118 deletions
diff --git a/include/acpi/platform/acenvex.h b/include/acpi/platform/acenvex.h new file mode 100644 index 000000000000..2b612384c994 --- /dev/null +++ b/include/acpi/platform/acenvex.h | |||
@@ -0,0 +1,63 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Name: acenvex.h - Extra host and compiler configuration | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2014, Intel Corp. | ||
9 | * All rights reserved. | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or without | ||
12 | * modification, are permitted provided that the following conditions | ||
13 | * are met: | ||
14 | * 1. Redistributions of source code must retain the above copyright | ||
15 | * notice, this list of conditions, and the following disclaimer, | ||
16 | * without modification. | ||
17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | ||
18 | * substantially similar to the "NO WARRANTY" disclaimer below | ||
19 | * ("Disclaimer") and any redistribution must be conditioned upon | ||
20 | * including a substantially similar Disclaimer requirement for further | ||
21 | * binary redistribution. | ||
22 | * 3. Neither the names of the above-listed copyright holders nor the names | ||
23 | * of any contributors may be used to endorse or promote products derived | ||
24 | * from this software without specific prior written permission. | ||
25 | * | ||
26 | * Alternatively, this software may be distributed under the terms of the | ||
27 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
28 | * Software Foundation. | ||
29 | * | ||
30 | * NO WARRANTY | ||
31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | ||
34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
41 | * POSSIBILITY OF SUCH DAMAGES. | ||
42 | */ | ||
43 | |||
44 | #ifndef __ACENVEX_H__ | ||
45 | #define __ACENVEX_H__ | ||
46 | |||
47 | /*! [Begin] no source code translation */ | ||
48 | |||
49 | /****************************************************************************** | ||
50 | * | ||
51 | * Extra host configuration files. All ACPICA headers are included before | ||
52 | * including these files. | ||
53 | * | ||
54 | *****************************************************************************/ | ||
55 | |||
56 | #if defined(_LINUX) || defined(__linux__) | ||
57 | #include <acpi/platform/aclinuxex.h> | ||
58 | |||
59 | #endif | ||
60 | |||
61 | /*! [End] no source code translation !*/ | ||
62 | |||
63 | #endif /* __ACENVEX_H__ */ | ||
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h index 3b8b52f8a4e9..0ab05d95e3a3 100644 --- a/include/acpi/platform/aclinux.h +++ b/include/acpi/platform/aclinux.h | |||
@@ -114,6 +114,42 @@ | |||
114 | #define acpi_spinlock spinlock_t * | 114 | #define acpi_spinlock spinlock_t * |
115 | #define acpi_cpu_flags unsigned long | 115 | #define acpi_cpu_flags unsigned long |
116 | 116 | ||
117 | /* Use native linux version of acpi_os_allocate_zeroed */ | ||
118 | |||
119 | #define USE_NATIVE_ALLOCATE_ZEROED | ||
120 | |||
121 | /* | ||
122 | * Overrides for in-kernel ACPICA | ||
123 | */ | ||
124 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize | ||
125 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate | ||
126 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate | ||
127 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate_zeroed | ||
128 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_free | ||
129 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_object | ||
130 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id | ||
131 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_lock | ||
132 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_map_memory | ||
133 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_unmap_memory | ||
134 | |||
135 | /* | ||
136 | * OSL interfaces used by debugger/disassembler | ||
137 | */ | ||
138 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_readable | ||
139 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_writable | ||
140 | |||
141 | /* | ||
142 | * OSL interfaces used by utilities | ||
143 | */ | ||
144 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_redirect_output | ||
145 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_line | ||
146 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_name | ||
147 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_index | ||
148 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_address | ||
149 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_open_directory | ||
150 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_next_filename | ||
151 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_close_directory | ||
152 | |||
117 | #else /* !__KERNEL__ */ | 153 | #else /* !__KERNEL__ */ |
118 | 154 | ||
119 | #include <stdarg.h> | 155 | #include <stdarg.h> |
@@ -159,122 +195,4 @@ | |||
159 | 195 | ||
160 | #include <acpi/platform/acgcc.h> | 196 | #include <acpi/platform/acgcc.h> |
161 | 197 | ||
162 | #ifdef __KERNEL__ | ||
163 | |||
164 | /* | ||
165 | * FIXME: Inclusion of actypes.h | ||
166 | * Linux kernel need this before defining inline OSL interfaces as | ||
167 | * actypes.h need to be included to find ACPICA type definitions. | ||
168 | * Since from ACPICA's perspective, the actypes.h should be included after | ||
169 | * acenv.h (aclinux.h), this leads to a inclusion mis-ordering issue. | ||
170 | */ | ||
171 | #include <acpi/actypes.h> | ||
172 | |||
173 | /* | ||
174 | * Overrides for in-kernel ACPICA | ||
175 | */ | ||
176 | acpi_status __init acpi_os_initialize(void); | ||
177 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize | ||
178 | |||
179 | acpi_status acpi_os_terminate(void); | ||
180 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate | ||
181 | |||
182 | /* | ||
183 | * Memory allocation/deallocation | ||
184 | */ | ||
185 | |||
186 | /* | ||
187 | * The irqs_disabled() check is for resume from RAM. | ||
188 | * Interrupts are off during resume, just like they are for boot. | ||
189 | * However, boot has (system_state != SYSTEM_RUNNING) | ||
190 | * to quiet __might_sleep() in kmalloc() and resume does not. | ||
191 | */ | ||
192 | static inline void *acpi_os_allocate(acpi_size size) | ||
193 | { | ||
194 | return kmalloc(size, irqs_disabled()? GFP_ATOMIC : GFP_KERNEL); | ||
195 | } | ||
196 | |||
197 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate | ||
198 | |||
199 | /* Use native linux version of acpi_os_allocate_zeroed */ | ||
200 | |||
201 | static inline void *acpi_os_allocate_zeroed(acpi_size size) | ||
202 | { | ||
203 | return kzalloc(size, irqs_disabled()? GFP_ATOMIC : GFP_KERNEL); | ||
204 | } | ||
205 | |||
206 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate_zeroed | ||
207 | #define USE_NATIVE_ALLOCATE_ZEROED | ||
208 | |||
209 | static inline void acpi_os_free(void *memory) | ||
210 | { | ||
211 | kfree(memory); | ||
212 | } | ||
213 | |||
214 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_free | ||
215 | |||
216 | static inline void *acpi_os_acquire_object(acpi_cache_t * cache) | ||
217 | { | ||
218 | return kmem_cache_zalloc(cache, | ||
219 | irqs_disabled()? GFP_ATOMIC : GFP_KERNEL); | ||
220 | } | ||
221 | |||
222 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_object | ||
223 | |||
224 | static inline acpi_thread_id acpi_os_get_thread_id(void) | ||
225 | { | ||
226 | return (acpi_thread_id) (unsigned long)current; | ||
227 | } | ||
228 | |||
229 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id | ||
230 | |||
231 | /* | ||
232 | * When lockdep is enabled, the spin_lock_init() macro stringifies it's | ||
233 | * argument and uses that as a name for the lock in debugging. | ||
234 | * By executing spin_lock_init() in a macro the key changes from "lock" for | ||
235 | * all locks to the name of the argument of acpi_os_create_lock(), which | ||
236 | * prevents lockdep from reporting false positives for ACPICA locks. | ||
237 | */ | ||
238 | #define acpi_os_create_lock(__handle) \ | ||
239 | ({ \ | ||
240 | spinlock_t *lock = ACPI_ALLOCATE(sizeof(*lock)); \ | ||
241 | if (lock) { \ | ||
242 | *(__handle) = lock; \ | ||
243 | spin_lock_init(*(__handle)); \ | ||
244 | } \ | ||
245 | lock ? AE_OK : AE_NO_MEMORY; \ | ||
246 | }) | ||
247 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_lock | ||
248 | |||
249 | void __iomem *acpi_os_map_memory(acpi_physical_address where, acpi_size length); | ||
250 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_map_memory | ||
251 | |||
252 | void acpi_os_unmap_memory(void __iomem * logical_address, acpi_size size); | ||
253 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_unmap_memory | ||
254 | |||
255 | /* | ||
256 | * OSL interfaces used by debugger/disassembler | ||
257 | */ | ||
258 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_readable | ||
259 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_writable | ||
260 | |||
261 | /* | ||
262 | * OSL interfaces used by utilities | ||
263 | */ | ||
264 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_redirect_output | ||
265 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_line | ||
266 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_name | ||
267 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_index | ||
268 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_address | ||
269 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_open_directory | ||
270 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_next_filename | ||
271 | #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_close_directory | ||
272 | |||
273 | /* | ||
274 | * OSL interfaces added by Linux | ||
275 | */ | ||
276 | void early_acpi_os_unmap_memory(void __iomem * virt, acpi_size size); | ||
277 | |||
278 | #endif /* __KERNEL__ */ | ||
279 | |||
280 | #endif /* __ACLINUX_H__ */ | 198 | #endif /* __ACLINUX_H__ */ |
diff --git a/include/acpi/platform/aclinuxex.h b/include/acpi/platform/aclinuxex.h new file mode 100644 index 000000000000..cce0723d05a9 --- /dev/null +++ b/include/acpi/platform/aclinuxex.h | |||
@@ -0,0 +1,116 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Name: aclinuxex.h - Extra OS specific defines, etc. for Linux | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2014, Intel Corp. | ||
9 | * All rights reserved. | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or without | ||
12 | * modification, are permitted provided that the following conditions | ||
13 | * are met: | ||
14 | * 1. Redistributions of source code must retain the above copyright | ||
15 | * notice, this list of conditions, and the following disclaimer, | ||
16 | * without modification. | ||
17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | ||
18 | * substantially similar to the "NO WARRANTY" disclaimer below | ||
19 | * ("Disclaimer") and any redistribution must be conditioned upon | ||
20 | * including a substantially similar Disclaimer requirement for further | ||
21 | * binary redistribution. | ||
22 | * 3. Neither the names of the above-listed copyright holders nor the names | ||
23 | * of any contributors may be used to endorse or promote products derived | ||
24 | * from this software without specific prior written permission. | ||
25 | * | ||
26 | * Alternatively, this software may be distributed under the terms of the | ||
27 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
28 | * Software Foundation. | ||
29 | * | ||
30 | * NO WARRANTY | ||
31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | ||
34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
41 | * POSSIBILITY OF SUCH DAMAGES. | ||
42 | */ | ||
43 | |||
44 | #ifndef __ACLINUXEX_H__ | ||
45 | #define __ACLINUXEX_H__ | ||
46 | |||
47 | #ifdef __KERNEL__ | ||
48 | |||
49 | /* | ||
50 | * Overrides for in-kernel ACPICA | ||
51 | */ | ||
52 | acpi_status __init acpi_os_initialize(void); | ||
53 | |||
54 | acpi_status acpi_os_terminate(void); | ||
55 | |||
56 | /* | ||
57 | * The irqs_disabled() check is for resume from RAM. | ||
58 | * Interrupts are off during resume, just like they are for boot. | ||
59 | * However, boot has (system_state != SYSTEM_RUNNING) | ||
60 | * to quiet __might_sleep() in kmalloc() and resume does not. | ||
61 | */ | ||
62 | static inline void *acpi_os_allocate(acpi_size size) | ||
63 | { | ||
64 | return kmalloc(size, irqs_disabled()? GFP_ATOMIC : GFP_KERNEL); | ||
65 | } | ||
66 | |||
67 | static inline void *acpi_os_allocate_zeroed(acpi_size size) | ||
68 | { | ||
69 | return kzalloc(size, irqs_disabled()? GFP_ATOMIC : GFP_KERNEL); | ||
70 | } | ||
71 | |||
72 | static inline void acpi_os_free(void *memory) | ||
73 | { | ||
74 | kfree(memory); | ||
75 | } | ||
76 | |||
77 | static inline void *acpi_os_acquire_object(acpi_cache_t * cache) | ||
78 | { | ||
79 | return kmem_cache_zalloc(cache, | ||
80 | irqs_disabled()? GFP_ATOMIC : GFP_KERNEL); | ||
81 | } | ||
82 | |||
83 | static inline acpi_thread_id acpi_os_get_thread_id(void) | ||
84 | { | ||
85 | return (acpi_thread_id) (unsigned long)current; | ||
86 | } | ||
87 | |||
88 | /* | ||
89 | * When lockdep is enabled, the spin_lock_init() macro stringifies it's | ||
90 | * argument and uses that as a name for the lock in debugging. | ||
91 | * By executing spin_lock_init() in a macro the key changes from "lock" for | ||
92 | * all locks to the name of the argument of acpi_os_create_lock(), which | ||
93 | * prevents lockdep from reporting false positives for ACPICA locks. | ||
94 | */ | ||
95 | #define acpi_os_create_lock(__handle) \ | ||
96 | ({ \ | ||
97 | spinlock_t *lock = ACPI_ALLOCATE(sizeof(*lock)); \ | ||
98 | if (lock) { \ | ||
99 | *(__handle) = lock; \ | ||
100 | spin_lock_init(*(__handle)); \ | ||
101 | } \ | ||
102 | lock ? AE_OK : AE_NO_MEMORY; \ | ||
103 | }) | ||
104 | |||
105 | void __iomem *acpi_os_map_memory(acpi_physical_address where, acpi_size length); | ||
106 | |||
107 | void acpi_os_unmap_memory(void __iomem * logical_address, acpi_size size); | ||
108 | |||
109 | /* | ||
110 | * OSL interfaces added by Linux | ||
111 | */ | ||
112 | void early_acpi_os_unmap_memory(void __iomem * virt, acpi_size size); | ||
113 | |||
114 | #endif /* __KERNEL__ */ | ||
115 | |||
116 | #endif /* __ACLINUXEX_H__ */ | ||