diff options
author | Bob Moore <robert.moore@intel.com> | 2010-04-26 23:41:19 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2010-05-06 03:05:54 -0400 |
commit | 3fe50208b29b2463eb6c181c1433dd1beb39f282 (patch) | |
tree | a35b7e47a5130e2d0179e34c69a7cae55a327b77 /drivers/acpi | |
parent | 186c307f008d2a53961cd970aaf7cb9c33e79cb1 (diff) |
ACPICA: Split large file, evgpeblk
Create two new files, evgpeinit.c and evgpeutil.c. Updated
unix and linux makefiles.
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/acpica/Makefile | 2 | ||||
-rw-r--r-- | drivers/acpi/acpica/acevents.h | 50 | ||||
-rw-r--r-- | drivers/acpi/acpica/evgpeblk.c | 909 | ||||
-rw-r--r-- | drivers/acpi/acpica/evgpeinit.c | 653 | ||||
-rw-r--r-- | drivers/acpi/acpica/evgpeutil.c | 337 |
5 files changed, 1025 insertions, 926 deletions
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile index c1102098dbfb..d93cc06f4bf8 100644 --- a/drivers/acpi/acpica/Makefile +++ b/drivers/acpi/acpica/Makefile | |||
@@ -14,7 +14,7 @@ acpi-y := dsfield.o dsmthdat.o dsopcode.o dswexec.o dswscope.o \ | |||
14 | 14 | ||
15 | acpi-y += evevent.o evregion.o evsci.o evxfevnt.o \ | 15 | acpi-y += evevent.o evregion.o evsci.o evxfevnt.o \ |
16 | evmisc.o evrgnini.o evxface.o evxfregn.o \ | 16 | evmisc.o evrgnini.o evxface.o evxfregn.o \ |
17 | evgpe.o evgpeblk.o | 17 | evgpe.o evgpeblk.o evgpeinit.o evgpeutil.o |
18 | 18 | ||
19 | acpi-y += exconfig.o exfield.o exnames.o exoparg6.o exresolv.o exstorob.o\ | 19 | acpi-y += exconfig.o exfield.o exnames.o exoparg6.o exresolv.o exstorob.o\ |
20 | exconvrt.o exfldio.o exoparg1.o exprep.o exresop.o exsystem.o\ | 20 | exconvrt.o exfldio.o exoparg1.o exprep.o exresop.o exsystem.o\ |
diff --git a/drivers/acpi/acpica/acevents.h b/drivers/acpi/acpica/acevents.h index 0f83dc46bd93..64d1e5c2d4ae 100644 --- a/drivers/acpi/acpica/acevents.h +++ b/drivers/acpi/acpica/acevents.h | |||
@@ -73,8 +73,10 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node *node, | |||
73 | u32 notify_value); | 73 | u32 notify_value); |
74 | 74 | ||
75 | /* | 75 | /* |
76 | * evgpe - GPE handling and dispatch | 76 | * evgpe - Low-level GPE support |
77 | */ | 77 | */ |
78 | u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info *gpe_xrupt_list); | ||
79 | |||
78 | acpi_status | 80 | acpi_status |
79 | acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info); | 81 | acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info); |
80 | 82 | ||
@@ -90,18 +92,8 @@ struct acpi_gpe_event_info *acpi_ev_low_get_gpe_info(u32 gpe_number, | |||
90 | *gpe_block); | 92 | *gpe_block); |
91 | 93 | ||
92 | /* | 94 | /* |
93 | * evgpeblk | 95 | * evgpeblk - Upper-level GPE block support |
94 | */ | 96 | */ |
95 | u8 acpi_ev_valid_gpe_event(struct acpi_gpe_event_info *gpe_event_info); | ||
96 | |||
97 | acpi_status | ||
98 | acpi_ev_walk_gpe_list(acpi_gpe_callback gpe_walk_callback, void *context); | ||
99 | |||
100 | acpi_status | ||
101 | acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info, | ||
102 | struct acpi_gpe_block_info *gpe_block, | ||
103 | void *context); | ||
104 | |||
105 | acpi_status | 97 | acpi_status |
106 | acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device, | 98 | acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device, |
107 | struct acpi_generic_address *gpe_block_address, | 99 | struct acpi_generic_address *gpe_block_address, |
@@ -110,8 +102,6 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device, | |||
110 | u32 interrupt_number, | 102 | u32 interrupt_number, |
111 | struct acpi_gpe_block_info **return_gpe_block); | 103 | struct acpi_gpe_block_info **return_gpe_block); |
112 | 104 | ||
113 | void acpi_ev_update_gpes(acpi_owner_id table_owner_id); | ||
114 | |||
115 | acpi_status | 105 | acpi_status |
116 | acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device, | 106 | acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device, |
117 | struct acpi_gpe_block_info *gpe_block); | 107 | struct acpi_gpe_block_info *gpe_block); |
@@ -122,10 +112,38 @@ u32 | |||
122 | acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, | 112 | acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, |
123 | u32 gpe_number); | 113 | u32 gpe_number); |
124 | 114 | ||
125 | u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info *gpe_xrupt_list); | 115 | /* |
126 | 116 | * evgpeinit - GPE initialization and update | |
117 | */ | ||
127 | acpi_status acpi_ev_gpe_initialize(void); | 118 | acpi_status acpi_ev_gpe_initialize(void); |
128 | 119 | ||
120 | void acpi_ev_update_gpes(acpi_owner_id table_owner_id); | ||
121 | |||
122 | acpi_status | ||
123 | acpi_ev_match_gpe_method(acpi_handle obj_handle, | ||
124 | u32 level, void *context, void **return_value); | ||
125 | |||
126 | acpi_status | ||
127 | acpi_ev_match_prw_and_gpe(acpi_handle obj_handle, | ||
128 | u32 level, void *context, void **return_value); | ||
129 | |||
130 | /* | ||
131 | * evgpeutil - GPE utilities | ||
132 | */ | ||
133 | acpi_status | ||
134 | acpi_ev_walk_gpe_list(acpi_gpe_callback gpe_walk_callback, void *context); | ||
135 | |||
136 | u8 acpi_ev_valid_gpe_event(struct acpi_gpe_event_info *gpe_event_info); | ||
137 | |||
138 | struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number); | ||
139 | |||
140 | acpi_status acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt); | ||
141 | |||
142 | acpi_status | ||
143 | acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info, | ||
144 | struct acpi_gpe_block_info *gpe_block, | ||
145 | void *context); | ||
146 | |||
129 | /* | 147 | /* |
130 | * evregion - Address Space handling | 148 | * evregion - Address Space handling |
131 | */ | 149 | */ |
diff --git a/drivers/acpi/acpica/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c index 3341d1dfe78a..7c28f2d9fd35 100644 --- a/drivers/acpi/acpica/evgpeblk.c +++ b/drivers/acpi/acpica/evgpeblk.c | |||
@@ -45,27 +45,12 @@ | |||
45 | #include "accommon.h" | 45 | #include "accommon.h" |
46 | #include "acevents.h" | 46 | #include "acevents.h" |
47 | #include "acnamesp.h" | 47 | #include "acnamesp.h" |
48 | #include "acinterp.h" | ||
49 | 48 | ||
50 | #define _COMPONENT ACPI_EVENTS | 49 | #define _COMPONENT ACPI_EVENTS |
51 | ACPI_MODULE_NAME("evgpeblk") | 50 | ACPI_MODULE_NAME("evgpeblk") |
52 | 51 | ||
53 | /* Local prototypes */ | 52 | /* Local prototypes */ |
54 | static acpi_status | 53 | static acpi_status |
55 | acpi_ev_match_gpe_method(acpi_handle obj_handle, | ||
56 | u32 level, void *obj_desc, void **return_value); | ||
57 | |||
58 | static acpi_status | ||
59 | acpi_ev_match_prw_and_gpe(acpi_handle obj_handle, | ||
60 | u32 level, void *info, void **return_value); | ||
61 | |||
62 | static struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 | ||
63 | interrupt_number); | ||
64 | |||
65 | static acpi_status | ||
66 | acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt); | ||
67 | |||
68 | static acpi_status | ||
69 | acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block, | 54 | acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block, |
70 | u32 interrupt_number); | 55 | u32 interrupt_number); |
71 | 56 | ||
@@ -74,632 +59,6 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block); | |||
74 | 59 | ||
75 | /******************************************************************************* | 60 | /******************************************************************************* |
76 | * | 61 | * |
77 | * FUNCTION: acpi_ev_valid_gpe_event | ||
78 | * | ||
79 | * PARAMETERS: gpe_event_info - Info for this GPE | ||
80 | * | ||
81 | * RETURN: TRUE if the gpe_event is valid | ||
82 | * | ||
83 | * DESCRIPTION: Validate a GPE event. DO NOT CALL FROM INTERRUPT LEVEL. | ||
84 | * Should be called only when the GPE lists are semaphore locked | ||
85 | * and not subject to change. | ||
86 | * | ||
87 | ******************************************************************************/ | ||
88 | |||
89 | u8 acpi_ev_valid_gpe_event(struct acpi_gpe_event_info *gpe_event_info) | ||
90 | { | ||
91 | struct acpi_gpe_xrupt_info *gpe_xrupt_block; | ||
92 | struct acpi_gpe_block_info *gpe_block; | ||
93 | |||
94 | ACPI_FUNCTION_ENTRY(); | ||
95 | |||
96 | /* No need for spin lock since we are not changing any list elements */ | ||
97 | |||
98 | /* Walk the GPE interrupt levels */ | ||
99 | |||
100 | gpe_xrupt_block = acpi_gbl_gpe_xrupt_list_head; | ||
101 | while (gpe_xrupt_block) { | ||
102 | gpe_block = gpe_xrupt_block->gpe_block_list_head; | ||
103 | |||
104 | /* Walk the GPE blocks on this interrupt level */ | ||
105 | |||
106 | while (gpe_block) { | ||
107 | if ((&gpe_block->event_info[0] <= gpe_event_info) && | ||
108 | (&gpe_block->event_info[gpe_block->gpe_count] > | ||
109 | gpe_event_info)) { | ||
110 | return (TRUE); | ||
111 | } | ||
112 | |||
113 | gpe_block = gpe_block->next; | ||
114 | } | ||
115 | |||
116 | gpe_xrupt_block = gpe_xrupt_block->next; | ||
117 | } | ||
118 | |||
119 | return (FALSE); | ||
120 | } | ||
121 | |||
122 | /******************************************************************************* | ||
123 | * | ||
124 | * FUNCTION: acpi_ev_walk_gpe_list | ||
125 | * | ||
126 | * PARAMETERS: gpe_walk_callback - Routine called for each GPE block | ||
127 | * Context - Value passed to callback | ||
128 | * | ||
129 | * RETURN: Status | ||
130 | * | ||
131 | * DESCRIPTION: Walk the GPE lists. | ||
132 | * | ||
133 | ******************************************************************************/ | ||
134 | |||
135 | acpi_status | ||
136 | acpi_ev_walk_gpe_list(acpi_gpe_callback gpe_walk_callback, void *context) | ||
137 | { | ||
138 | struct acpi_gpe_block_info *gpe_block; | ||
139 | struct acpi_gpe_xrupt_info *gpe_xrupt_info; | ||
140 | acpi_status status = AE_OK; | ||
141 | acpi_cpu_flags flags; | ||
142 | |||
143 | ACPI_FUNCTION_TRACE(ev_walk_gpe_list); | ||
144 | |||
145 | flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); | ||
146 | |||
147 | /* Walk the interrupt level descriptor list */ | ||
148 | |||
149 | gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head; | ||
150 | while (gpe_xrupt_info) { | ||
151 | |||
152 | /* Walk all Gpe Blocks attached to this interrupt level */ | ||
153 | |||
154 | gpe_block = gpe_xrupt_info->gpe_block_list_head; | ||
155 | while (gpe_block) { | ||
156 | |||
157 | /* One callback per GPE block */ | ||
158 | |||
159 | status = | ||
160 | gpe_walk_callback(gpe_xrupt_info, gpe_block, | ||
161 | context); | ||
162 | if (ACPI_FAILURE(status)) { | ||
163 | if (status == AE_CTRL_END) { /* Callback abort */ | ||
164 | status = AE_OK; | ||
165 | } | ||
166 | goto unlock_and_exit; | ||
167 | } | ||
168 | |||
169 | gpe_block = gpe_block->next; | ||
170 | } | ||
171 | |||
172 | gpe_xrupt_info = gpe_xrupt_info->next; | ||
173 | } | ||
174 | |||
175 | unlock_and_exit: | ||
176 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); | ||
177 | return_ACPI_STATUS(status); | ||
178 | } | ||
179 | |||
180 | /******************************************************************************* | ||
181 | * | ||
182 | * FUNCTION: acpi_ev_delete_gpe_handlers | ||
183 | * | ||
184 | * PARAMETERS: gpe_xrupt_info - GPE Interrupt info | ||
185 | * gpe_block - Gpe Block info | ||
186 | * | ||
187 | * RETURN: Status | ||
188 | * | ||
189 | * DESCRIPTION: Delete all Handler objects found in the GPE data structs. | ||
190 | * Used only prior to termination. | ||
191 | * | ||
192 | ******************************************************************************/ | ||
193 | |||
194 | acpi_status | ||
195 | acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info, | ||
196 | struct acpi_gpe_block_info *gpe_block, | ||
197 | void *context) | ||
198 | { | ||
199 | struct acpi_gpe_event_info *gpe_event_info; | ||
200 | u32 i; | ||
201 | u32 j; | ||
202 | |||
203 | ACPI_FUNCTION_TRACE(ev_delete_gpe_handlers); | ||
204 | |||
205 | /* Examine each GPE Register within the block */ | ||
206 | |||
207 | for (i = 0; i < gpe_block->register_count; i++) { | ||
208 | |||
209 | /* Now look at the individual GPEs in this byte register */ | ||
210 | |||
211 | for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { | ||
212 | gpe_event_info = &gpe_block->event_info[((acpi_size) i * | ||
213 | ACPI_GPE_REGISTER_WIDTH) | ||
214 | + j]; | ||
215 | |||
216 | if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == | ||
217 | ACPI_GPE_DISPATCH_HANDLER) { | ||
218 | ACPI_FREE(gpe_event_info->dispatch.handler); | ||
219 | gpe_event_info->dispatch.handler = NULL; | ||
220 | gpe_event_info->flags &= | ||
221 | ~ACPI_GPE_DISPATCH_MASK; | ||
222 | } | ||
223 | } | ||
224 | } | ||
225 | |||
226 | return_ACPI_STATUS(AE_OK); | ||
227 | } | ||
228 | |||
229 | /******************************************************************************* | ||
230 | * | ||
231 | * FUNCTION: acpi_ev_match_gpe_method | ||
232 | * | ||
233 | * PARAMETERS: Callback from walk_namespace | ||
234 | * | ||
235 | * RETURN: Status | ||
236 | * | ||
237 | * DESCRIPTION: Called from acpi_walk_namespace. Expects each object to be a | ||
238 | * control method under the _GPE portion of the namespace. | ||
239 | * Extract the name and GPE type from the object, saving this | ||
240 | * information for quick lookup during GPE dispatch. Allows a | ||
241 | * per-owner_id evaluation if execute_by_owner_id is TRUE in the | ||
242 | * walk_info parameter block. | ||
243 | * | ||
244 | * The name of each GPE control method is of the form: | ||
245 | * "_Lxx" or "_Exx", where: | ||
246 | * L - means that the GPE is level triggered | ||
247 | * E - means that the GPE is edge triggered | ||
248 | * xx - is the GPE number [in HEX] | ||
249 | * | ||
250 | * If walk_info->execute_by_owner_id is TRUE, we only execute examine GPE methods | ||
251 | * with that owner. | ||
252 | * If walk_info->enable_this_gpe is TRUE, the GPE that is referred to by a GPE | ||
253 | * method is immediately enabled (Used for Load/load_table operators) | ||
254 | * | ||
255 | ******************************************************************************/ | ||
256 | |||
257 | static acpi_status | ||
258 | acpi_ev_match_gpe_method(acpi_handle obj_handle, | ||
259 | u32 level, void *context, void **return_value) | ||
260 | { | ||
261 | struct acpi_namespace_node *method_node = | ||
262 | ACPI_CAST_PTR(struct acpi_namespace_node, obj_handle); | ||
263 | struct acpi_gpe_walk_info *walk_info = | ||
264 | ACPI_CAST_PTR(struct acpi_gpe_walk_info, context); | ||
265 | struct acpi_gpe_event_info *gpe_event_info; | ||
266 | struct acpi_namespace_node *gpe_device; | ||
267 | acpi_status status; | ||
268 | u32 gpe_number; | ||
269 | char name[ACPI_NAME_SIZE + 1]; | ||
270 | u8 type; | ||
271 | |||
272 | ACPI_FUNCTION_TRACE(ev_match_gpe_method); | ||
273 | |||
274 | /* Check if requested owner_id matches this owner_id */ | ||
275 | |||
276 | if ((walk_info->execute_by_owner_id) && | ||
277 | (method_node->owner_id != walk_info->owner_id)) { | ||
278 | return_ACPI_STATUS(AE_OK); | ||
279 | } | ||
280 | |||
281 | /* | ||
282 | * Match and decode the _Lxx and _Exx GPE method names | ||
283 | * | ||
284 | * 1) Extract the method name and null terminate it | ||
285 | */ | ||
286 | ACPI_MOVE_32_TO_32(name, &method_node->name.integer); | ||
287 | name[ACPI_NAME_SIZE] = 0; | ||
288 | |||
289 | /* 2) Name must begin with an underscore */ | ||
290 | |||
291 | if (name[0] != '_') { | ||
292 | return_ACPI_STATUS(AE_OK); /* Ignore this method */ | ||
293 | } | ||
294 | |||
295 | /* | ||
296 | * 3) Edge/Level determination is based on the 2nd character | ||
297 | * of the method name | ||
298 | * | ||
299 | * NOTE: Default GPE type is RUNTIME only. Later, if a _PRW object is | ||
300 | * found that points to this GPE, the ACPI_GPE_CAN_WAKE flag is set. | ||
301 | */ | ||
302 | switch (name[1]) { | ||
303 | case 'L': | ||
304 | type = ACPI_GPE_LEVEL_TRIGGERED; | ||
305 | break; | ||
306 | |||
307 | case 'E': | ||
308 | type = ACPI_GPE_EDGE_TRIGGERED; | ||
309 | break; | ||
310 | |||
311 | default: | ||
312 | /* Unknown method type, just ignore it */ | ||
313 | |||
314 | ACPI_DEBUG_PRINT((ACPI_DB_LOAD, | ||
315 | "Ignoring unknown GPE method type: %s " | ||
316 | "(name not of form _Lxx or _Exx)", name)); | ||
317 | return_ACPI_STATUS(AE_OK); | ||
318 | } | ||
319 | |||
320 | /* 4) The last two characters of the name are the hex GPE Number */ | ||
321 | |||
322 | gpe_number = ACPI_STRTOUL(&name[2], NULL, 16); | ||
323 | if (gpe_number == ACPI_UINT32_MAX) { | ||
324 | |||
325 | /* Conversion failed; invalid method, just ignore it */ | ||
326 | |||
327 | ACPI_DEBUG_PRINT((ACPI_DB_LOAD, | ||
328 | "Could not extract GPE number from name: %s " | ||
329 | "(name is not of form _Lxx or _Exx)", name)); | ||
330 | return_ACPI_STATUS(AE_OK); | ||
331 | } | ||
332 | |||
333 | /* Ensure that we have a valid GPE number for this GPE block */ | ||
334 | |||
335 | gpe_event_info = | ||
336 | acpi_ev_low_get_gpe_info(gpe_number, walk_info->gpe_block); | ||
337 | if (!gpe_event_info) { | ||
338 | /* | ||
339 | * This gpe_number is not valid for this GPE block, just ignore it. | ||
340 | * However, it may be valid for a different GPE block, since GPE0 | ||
341 | * and GPE1 methods both appear under \_GPE. | ||
342 | */ | ||
343 | return_ACPI_STATUS(AE_OK); | ||
344 | } | ||
345 | |||
346 | if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == | ||
347 | ACPI_GPE_DISPATCH_HANDLER) { | ||
348 | |||
349 | /* If there is already a handler, ignore this GPE method */ | ||
350 | |||
351 | return_ACPI_STATUS(AE_OK); | ||
352 | } | ||
353 | |||
354 | if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == | ||
355 | ACPI_GPE_DISPATCH_METHOD) { | ||
356 | /* | ||
357 | * If there is already a method, ignore this method. But check | ||
358 | * for a type mismatch (if both the _Lxx AND _Exx exist) | ||
359 | */ | ||
360 | if (type != (gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK)) { | ||
361 | ACPI_ERROR((AE_INFO, | ||
362 | "For GPE 0x%.2X, found both _L%2.2X and _E%2.2X methods", | ||
363 | gpe_number, gpe_number, gpe_number)); | ||
364 | } | ||
365 | return_ACPI_STATUS(AE_OK); | ||
366 | } | ||
367 | |||
368 | /* | ||
369 | * Add the GPE information from above to the gpe_event_info block for | ||
370 | * use during dispatch of this GPE. | ||
371 | */ | ||
372 | gpe_event_info->flags |= (u8)(type | ACPI_GPE_DISPATCH_METHOD); | ||
373 | gpe_event_info->dispatch.method_node = method_node; | ||
374 | |||
375 | /* | ||
376 | * Enable this GPE if requested. This only happens when during the | ||
377 | * execution of a Load or load_table operator. We have found a new | ||
378 | * GPE method and want to immediately enable the GPE if it is a | ||
379 | * runtime GPE. | ||
380 | */ | ||
381 | if (walk_info->enable_this_gpe) { | ||
382 | |||
383 | /* Ignore GPEs that can wake the system */ | ||
384 | |||
385 | if (!(gpe_event_info->flags & ACPI_GPE_CAN_WAKE) || | ||
386 | !acpi_gbl_leave_wake_gpes_disabled) { | ||
387 | walk_info->count++; | ||
388 | gpe_device = walk_info->gpe_device; | ||
389 | |||
390 | if (gpe_device == acpi_gbl_fadt_gpe_device) { | ||
391 | gpe_device = NULL; | ||
392 | } | ||
393 | |||
394 | status = acpi_enable_gpe(gpe_device, gpe_number, | ||
395 | ACPI_GPE_TYPE_RUNTIME); | ||
396 | if (ACPI_FAILURE(status)) { | ||
397 | ACPI_EXCEPTION((AE_INFO, status, | ||
398 | "Could not enable GPE 0x%02X", | ||
399 | gpe_number)); | ||
400 | } | ||
401 | } | ||
402 | } | ||
403 | |||
404 | ACPI_DEBUG_PRINT((ACPI_DB_LOAD, | ||
405 | "Registered GPE method %s as GPE number 0x%.2X\n", | ||
406 | name, gpe_number)); | ||
407 | return_ACPI_STATUS(AE_OK); | ||
408 | } | ||
409 | |||
410 | /******************************************************************************* | ||
411 | * | ||
412 | * FUNCTION: acpi_ev_match_prw_and_gpe | ||
413 | * | ||
414 | * PARAMETERS: Callback from walk_namespace | ||
415 | * | ||
416 | * RETURN: Status. NOTE: We ignore errors so that the _PRW walk is | ||
417 | * not aborted on a single _PRW failure. | ||
418 | * | ||
419 | * DESCRIPTION: Called from acpi_walk_namespace. Expects each object to be a | ||
420 | * Device. Run the _PRW method. If present, extract the GPE | ||
421 | * number and mark the GPE as a CAN_WAKE GPE. Allows a | ||
422 | * per-owner_id execution if execute_by_owner_id is TRUE in the | ||
423 | * walk_info parameter block. | ||
424 | * | ||
425 | * If walk_info->execute_by_owner_id is TRUE, we only execute _PRWs with that | ||
426 | * owner. | ||
427 | * If walk_info->gpe_device is NULL, we execute every _PRW found. Otherwise, | ||
428 | * we only execute _PRWs that refer to the input gpe_device. | ||
429 | * | ||
430 | ******************************************************************************/ | ||
431 | |||
432 | static acpi_status | ||
433 | acpi_ev_match_prw_and_gpe(acpi_handle obj_handle, | ||
434 | u32 level, void *context, void **return_value) | ||
435 | { | ||
436 | struct acpi_gpe_walk_info *walk_info = | ||
437 | ACPI_CAST_PTR(struct acpi_gpe_walk_info, context); | ||
438 | struct acpi_namespace_node *gpe_device; | ||
439 | struct acpi_gpe_block_info *gpe_block; | ||
440 | struct acpi_namespace_node *target_gpe_device; | ||
441 | struct acpi_namespace_node *prw_node; | ||
442 | struct acpi_gpe_event_info *gpe_event_info; | ||
443 | union acpi_operand_object *pkg_desc; | ||
444 | union acpi_operand_object *obj_desc; | ||
445 | u32 gpe_number; | ||
446 | acpi_status status; | ||
447 | |||
448 | ACPI_FUNCTION_TRACE(ev_match_prw_and_gpe); | ||
449 | |||
450 | /* Check for a _PRW method under this device */ | ||
451 | |||
452 | status = acpi_ns_get_node(obj_handle, METHOD_NAME__PRW, | ||
453 | ACPI_NS_NO_UPSEARCH, &prw_node); | ||
454 | if (ACPI_FAILURE(status)) { | ||
455 | return_ACPI_STATUS(AE_OK); | ||
456 | } | ||
457 | |||
458 | /* Check if requested owner_id matches this owner_id */ | ||
459 | |||
460 | if ((walk_info->execute_by_owner_id) && | ||
461 | (prw_node->owner_id != walk_info->owner_id)) { | ||
462 | return_ACPI_STATUS(AE_OK); | ||
463 | } | ||
464 | |||
465 | /* Execute the _PRW */ | ||
466 | |||
467 | status = acpi_ut_evaluate_object(prw_node, NULL, | ||
468 | ACPI_BTYPE_PACKAGE, &pkg_desc); | ||
469 | if (ACPI_FAILURE(status)) { | ||
470 | return_ACPI_STATUS(AE_OK); | ||
471 | } | ||
472 | |||
473 | /* The returned _PRW package must have at least two elements */ | ||
474 | |||
475 | if (pkg_desc->package.count < 2) { | ||
476 | goto cleanup; | ||
477 | } | ||
478 | |||
479 | /* Extract pointers from the input context */ | ||
480 | |||
481 | gpe_device = walk_info->gpe_device; | ||
482 | gpe_block = walk_info->gpe_block; | ||
483 | |||
484 | /* | ||
485 | * The _PRW object must return a package, we are only interested | ||
486 | * in the first element | ||
487 | */ | ||
488 | obj_desc = pkg_desc->package.elements[0]; | ||
489 | |||
490 | if (obj_desc->common.type == ACPI_TYPE_INTEGER) { | ||
491 | |||
492 | /* Use FADT-defined GPE device (from definition of _PRW) */ | ||
493 | |||
494 | target_gpe_device = NULL; | ||
495 | if (gpe_device) { | ||
496 | target_gpe_device = acpi_gbl_fadt_gpe_device; | ||
497 | } | ||
498 | |||
499 | /* Integer is the GPE number in the FADT described GPE blocks */ | ||
500 | |||
501 | gpe_number = (u32) obj_desc->integer.value; | ||
502 | } else if (obj_desc->common.type == ACPI_TYPE_PACKAGE) { | ||
503 | |||
504 | /* Package contains a GPE reference and GPE number within a GPE block */ | ||
505 | |||
506 | if ((obj_desc->package.count < 2) || | ||
507 | ((obj_desc->package.elements[0])->common.type != | ||
508 | ACPI_TYPE_LOCAL_REFERENCE) || | ||
509 | ((obj_desc->package.elements[1])->common.type != | ||
510 | ACPI_TYPE_INTEGER)) { | ||
511 | goto cleanup; | ||
512 | } | ||
513 | |||
514 | /* Get GPE block reference and decode */ | ||
515 | |||
516 | target_gpe_device = | ||
517 | obj_desc->package.elements[0]->reference.node; | ||
518 | gpe_number = (u32) obj_desc->package.elements[1]->integer.value; | ||
519 | } else { | ||
520 | /* Unknown type, just ignore it */ | ||
521 | |||
522 | goto cleanup; | ||
523 | } | ||
524 | |||
525 | /* Get the gpe_event_info for this GPE */ | ||
526 | |||
527 | if (gpe_device) { | ||
528 | /* | ||
529 | * Is this GPE within this block? | ||
530 | * | ||
531 | * TRUE if and only if these conditions are true: | ||
532 | * 1) The GPE devices match. | ||
533 | * 2) The GPE index(number) is within the range of the Gpe Block | ||
534 | * associated with the GPE device. | ||
535 | */ | ||
536 | if (gpe_device != target_gpe_device) { | ||
537 | goto cleanup; | ||
538 | } | ||
539 | |||
540 | gpe_event_info = | ||
541 | acpi_ev_low_get_gpe_info(gpe_number, gpe_block); | ||
542 | } else { | ||
543 | /* gpe_device is NULL, just match the target_device and gpe_number */ | ||
544 | |||
545 | gpe_event_info = | ||
546 | acpi_ev_get_gpe_event_info(target_gpe_device, gpe_number); | ||
547 | } | ||
548 | |||
549 | if (gpe_event_info) { | ||
550 | if (!(gpe_event_info->flags & ACPI_GPE_CAN_WAKE)) { | ||
551 | |||
552 | /* This GPE can wake the system */ | ||
553 | |||
554 | gpe_event_info->flags |= ACPI_GPE_CAN_WAKE; | ||
555 | walk_info->count++; | ||
556 | } | ||
557 | } | ||
558 | |||
559 | cleanup: | ||
560 | acpi_ut_remove_reference(pkg_desc); | ||
561 | return_ACPI_STATUS(AE_OK); | ||
562 | } | ||
563 | |||
564 | /******************************************************************************* | ||
565 | * | ||
566 | * FUNCTION: acpi_ev_get_gpe_xrupt_block | ||
567 | * | ||
568 | * PARAMETERS: interrupt_number - Interrupt for a GPE block | ||
569 | * | ||
570 | * RETURN: A GPE interrupt block | ||
571 | * | ||
572 | * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt | ||
573 | * block per unique interrupt level used for GPEs. Should be | ||
574 | * called only when the GPE lists are semaphore locked and not | ||
575 | * subject to change. | ||
576 | * | ||
577 | ******************************************************************************/ | ||
578 | |||
579 | static struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 | ||
580 | interrupt_number) | ||
581 | { | ||
582 | struct acpi_gpe_xrupt_info *next_gpe_xrupt; | ||
583 | struct acpi_gpe_xrupt_info *gpe_xrupt; | ||
584 | acpi_status status; | ||
585 | acpi_cpu_flags flags; | ||
586 | |||
587 | ACPI_FUNCTION_TRACE(ev_get_gpe_xrupt_block); | ||
588 | |||
589 | /* No need for lock since we are not changing any list elements here */ | ||
590 | |||
591 | next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; | ||
592 | while (next_gpe_xrupt) { | ||
593 | if (next_gpe_xrupt->interrupt_number == interrupt_number) { | ||
594 | return_PTR(next_gpe_xrupt); | ||
595 | } | ||
596 | |||
597 | next_gpe_xrupt = next_gpe_xrupt->next; | ||
598 | } | ||
599 | |||
600 | /* Not found, must allocate a new xrupt descriptor */ | ||
601 | |||
602 | gpe_xrupt = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_xrupt_info)); | ||
603 | if (!gpe_xrupt) { | ||
604 | return_PTR(NULL); | ||
605 | } | ||
606 | |||
607 | gpe_xrupt->interrupt_number = interrupt_number; | ||
608 | |||
609 | /* Install new interrupt descriptor with spin lock */ | ||
610 | |||
611 | flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); | ||
612 | if (acpi_gbl_gpe_xrupt_list_head) { | ||
613 | next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; | ||
614 | while (next_gpe_xrupt->next) { | ||
615 | next_gpe_xrupt = next_gpe_xrupt->next; | ||
616 | } | ||
617 | |||
618 | next_gpe_xrupt->next = gpe_xrupt; | ||
619 | gpe_xrupt->previous = next_gpe_xrupt; | ||
620 | } else { | ||
621 | acpi_gbl_gpe_xrupt_list_head = gpe_xrupt; | ||
622 | } | ||
623 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); | ||
624 | |||
625 | /* Install new interrupt handler if not SCI_INT */ | ||
626 | |||
627 | if (interrupt_number != acpi_gbl_FADT.sci_interrupt) { | ||
628 | status = acpi_os_install_interrupt_handler(interrupt_number, | ||
629 | acpi_ev_gpe_xrupt_handler, | ||
630 | gpe_xrupt); | ||
631 | if (ACPI_FAILURE(status)) { | ||
632 | ACPI_ERROR((AE_INFO, | ||
633 | "Could not install GPE interrupt handler at level 0x%X", | ||
634 | interrupt_number)); | ||
635 | return_PTR(NULL); | ||
636 | } | ||
637 | } | ||
638 | |||
639 | return_PTR(gpe_xrupt); | ||
640 | } | ||
641 | |||
642 | /******************************************************************************* | ||
643 | * | ||
644 | * FUNCTION: acpi_ev_delete_gpe_xrupt | ||
645 | * | ||
646 | * PARAMETERS: gpe_xrupt - A GPE interrupt info block | ||
647 | * | ||
648 | * RETURN: Status | ||
649 | * | ||
650 | * DESCRIPTION: Remove and free a gpe_xrupt block. Remove an associated | ||
651 | * interrupt handler if not the SCI interrupt. | ||
652 | * | ||
653 | ******************************************************************************/ | ||
654 | |||
655 | static acpi_status | ||
656 | acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt) | ||
657 | { | ||
658 | acpi_status status; | ||
659 | acpi_cpu_flags flags; | ||
660 | |||
661 | ACPI_FUNCTION_TRACE(ev_delete_gpe_xrupt); | ||
662 | |||
663 | /* We never want to remove the SCI interrupt handler */ | ||
664 | |||
665 | if (gpe_xrupt->interrupt_number == acpi_gbl_FADT.sci_interrupt) { | ||
666 | gpe_xrupt->gpe_block_list_head = NULL; | ||
667 | return_ACPI_STATUS(AE_OK); | ||
668 | } | ||
669 | |||
670 | /* Disable this interrupt */ | ||
671 | |||
672 | status = | ||
673 | acpi_os_remove_interrupt_handler(gpe_xrupt->interrupt_number, | ||
674 | acpi_ev_gpe_xrupt_handler); | ||
675 | if (ACPI_FAILURE(status)) { | ||
676 | return_ACPI_STATUS(status); | ||
677 | } | ||
678 | |||
679 | /* Unlink the interrupt block with lock */ | ||
680 | |||
681 | flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); | ||
682 | if (gpe_xrupt->previous) { | ||
683 | gpe_xrupt->previous->next = gpe_xrupt->next; | ||
684 | } else { | ||
685 | /* No previous, update list head */ | ||
686 | |||
687 | acpi_gbl_gpe_xrupt_list_head = gpe_xrupt->next; | ||
688 | } | ||
689 | |||
690 | if (gpe_xrupt->next) { | ||
691 | gpe_xrupt->next->previous = gpe_xrupt->previous; | ||
692 | } | ||
693 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); | ||
694 | |||
695 | /* Free the block */ | ||
696 | |||
697 | ACPI_FREE(gpe_xrupt); | ||
698 | return_ACPI_STATUS(AE_OK); | ||
699 | } | ||
700 | |||
701 | /******************************************************************************* | ||
702 | * | ||
703 | * FUNCTION: acpi_ev_install_gpe_block | 62 | * FUNCTION: acpi_ev_install_gpe_block |
704 | * | 63 | * |
705 | * PARAMETERS: gpe_block - New GPE block | 64 | * PARAMETERS: gpe_block - New GPE block |
@@ -1060,123 +419,6 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device, | |||
1060 | 419 | ||
1061 | /******************************************************************************* | 420 | /******************************************************************************* |
1062 | * | 421 | * |
1063 | * FUNCTION: acpi_ev_update_gpes | ||
1064 | * | ||
1065 | * PARAMETERS: table_owner_id - ID of the newly-loaded ACPI table | ||
1066 | * | ||
1067 | * RETURN: None | ||
1068 | * | ||
1069 | * DESCRIPTION: Check for new GPE methods (_Lxx/_Exx) made available as a | ||
1070 | * result of a Load() or load_table() operation. If new GPE | ||
1071 | * methods have been installed, register the new methods and | ||
1072 | * enable and runtime GPEs that are associated with them. Also, | ||
1073 | * run any newly loaded _PRW methods in order to discover any | ||
1074 | * new CAN_WAKE GPEs. | ||
1075 | * | ||
1076 | ******************************************************************************/ | ||
1077 | |||
1078 | void acpi_ev_update_gpes(acpi_owner_id table_owner_id) | ||
1079 | { | ||
1080 | struct acpi_gpe_xrupt_info *gpe_xrupt_info; | ||
1081 | struct acpi_gpe_block_info *gpe_block; | ||
1082 | struct acpi_gpe_walk_info walk_info; | ||
1083 | acpi_status status = AE_OK; | ||
1084 | u32 new_wake_gpe_count = 0; | ||
1085 | |||
1086 | /* We will examine only _PRW/_Lxx/_Exx methods owned by this table */ | ||
1087 | |||
1088 | walk_info.owner_id = table_owner_id; | ||
1089 | walk_info.execute_by_owner_id = TRUE; | ||
1090 | walk_info.count = 0; | ||
1091 | |||
1092 | if (acpi_gbl_leave_wake_gpes_disabled) { | ||
1093 | /* | ||
1094 | * 1) Run any newly-loaded _PRW methods to find any GPEs that | ||
1095 | * can now be marked as CAN_WAKE GPEs. Note: We must run the | ||
1096 | * _PRW methods before we process the _Lxx/_Exx methods because | ||
1097 | * we will enable all runtime GPEs associated with the new | ||
1098 | * _Lxx/_Exx methods at the time we process those methods. | ||
1099 | * | ||
1100 | * Unlock interpreter so that we can run the _PRW methods. | ||
1101 | */ | ||
1102 | walk_info.gpe_block = NULL; | ||
1103 | walk_info.gpe_device = NULL; | ||
1104 | |||
1105 | acpi_ex_exit_interpreter(); | ||
1106 | |||
1107 | status = | ||
1108 | acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | ||
1109 | ACPI_UINT32_MAX, | ||
1110 | ACPI_NS_WALK_NO_UNLOCK, | ||
1111 | acpi_ev_match_prw_and_gpe, NULL, | ||
1112 | &walk_info, NULL); | ||
1113 | if (ACPI_FAILURE(status)) { | ||
1114 | ACPI_EXCEPTION((AE_INFO, status, | ||
1115 | "While executing _PRW methods")); | ||
1116 | } | ||
1117 | |||
1118 | acpi_ex_enter_interpreter(); | ||
1119 | new_wake_gpe_count = walk_info.count; | ||
1120 | } | ||
1121 | |||
1122 | /* | ||
1123 | * 2) Find any _Lxx/_Exx GPE methods that have just been loaded. | ||
1124 | * | ||
1125 | * Any GPEs that correspond to new _Lxx/_Exx methods and are not | ||
1126 | * marked as CAN_WAKE are immediately enabled. | ||
1127 | * | ||
1128 | * Examine the namespace underneath each gpe_device within the | ||
1129 | * gpe_block lists. | ||
1130 | */ | ||
1131 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); | ||
1132 | if (ACPI_FAILURE(status)) { | ||
1133 | return; | ||
1134 | } | ||
1135 | |||
1136 | walk_info.count = 0; | ||
1137 | walk_info.enable_this_gpe = TRUE; | ||
1138 | |||
1139 | /* Walk the interrupt level descriptor list */ | ||
1140 | |||
1141 | gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head; | ||
1142 | while (gpe_xrupt_info) { | ||
1143 | |||
1144 | /* Walk all Gpe Blocks attached to this interrupt level */ | ||
1145 | |||
1146 | gpe_block = gpe_xrupt_info->gpe_block_list_head; | ||
1147 | while (gpe_block) { | ||
1148 | walk_info.gpe_block = gpe_block; | ||
1149 | walk_info.gpe_device = gpe_block->node; | ||
1150 | |||
1151 | status = acpi_ns_walk_namespace(ACPI_TYPE_METHOD, | ||
1152 | walk_info.gpe_device, | ||
1153 | ACPI_UINT32_MAX, | ||
1154 | ACPI_NS_WALK_NO_UNLOCK, | ||
1155 | acpi_ev_match_gpe_method, | ||
1156 | NULL, &walk_info, NULL); | ||
1157 | if (ACPI_FAILURE(status)) { | ||
1158 | ACPI_EXCEPTION((AE_INFO, status, | ||
1159 | "While decoding _Lxx/_Exx methods")); | ||
1160 | } | ||
1161 | |||
1162 | gpe_block = gpe_block->next; | ||
1163 | } | ||
1164 | |||
1165 | gpe_xrupt_info = gpe_xrupt_info->next; | ||
1166 | } | ||
1167 | |||
1168 | if (walk_info.count || new_wake_gpe_count) { | ||
1169 | ACPI_INFO((AE_INFO, | ||
1170 | "Enabled %u new runtime GPEs, added %u new wakeup GPEs", | ||
1171 | walk_info.count, new_wake_gpe_count)); | ||
1172 | } | ||
1173 | |||
1174 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); | ||
1175 | return; | ||
1176 | } | ||
1177 | |||
1178 | /******************************************************************************* | ||
1179 | * | ||
1180 | * FUNCTION: acpi_ev_initialize_gpe_block | 422 | * FUNCTION: acpi_ev_initialize_gpe_block |
1181 | * | 423 | * |
1182 | * PARAMETERS: gpe_device - Handle to the parent GPE block | 424 | * PARAMETERS: gpe_device - Handle to the parent GPE block |
@@ -1296,154 +538,3 @@ acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device, | |||
1296 | 538 | ||
1297 | return_ACPI_STATUS(AE_OK); | 539 | return_ACPI_STATUS(AE_OK); |
1298 | } | 540 | } |
1299 | |||
1300 | /******************************************************************************* | ||
1301 | * | ||
1302 | * FUNCTION: acpi_ev_gpe_initialize | ||
1303 | * | ||
1304 | * PARAMETERS: None | ||
1305 | * | ||
1306 | * RETURN: Status | ||
1307 | * | ||
1308 | * DESCRIPTION: Initialize the GPE data structures | ||
1309 | * | ||
1310 | ******************************************************************************/ | ||
1311 | |||
1312 | acpi_status acpi_ev_gpe_initialize(void) | ||
1313 | { | ||
1314 | u32 register_count0 = 0; | ||
1315 | u32 register_count1 = 0; | ||
1316 | u32 gpe_number_max = 0; | ||
1317 | acpi_status status; | ||
1318 | |||
1319 | ACPI_FUNCTION_TRACE(ev_gpe_initialize); | ||
1320 | |||
1321 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); | ||
1322 | if (ACPI_FAILURE(status)) { | ||
1323 | return_ACPI_STATUS(status); | ||
1324 | } | ||
1325 | |||
1326 | /* | ||
1327 | * Initialize the GPE Block(s) defined in the FADT | ||
1328 | * | ||
1329 | * Why the GPE register block lengths are divided by 2: From the ACPI | ||
1330 | * Spec, section "General-Purpose Event Registers", we have: | ||
1331 | * | ||
1332 | * "Each register block contains two registers of equal length | ||
1333 | * GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the | ||
1334 | * GPE0_STS and GPE0_EN registers is equal to half the GPE0_LEN | ||
1335 | * The length of the GPE1_STS and GPE1_EN registers is equal to | ||
1336 | * half the GPE1_LEN. If a generic register block is not supported | ||
1337 | * then its respective block pointer and block length values in the | ||
1338 | * FADT table contain zeros. The GPE0_LEN and GPE1_LEN do not need | ||
1339 | * to be the same size." | ||
1340 | */ | ||
1341 | |||
1342 | /* | ||
1343 | * Determine the maximum GPE number for this machine. | ||
1344 | * | ||
1345 | * Note: both GPE0 and GPE1 are optional, and either can exist without | ||
1346 | * the other. | ||
1347 | * | ||
1348 | * If EITHER the register length OR the block address are zero, then that | ||
1349 | * particular block is not supported. | ||
1350 | */ | ||
1351 | if (acpi_gbl_FADT.gpe0_block_length && | ||
1352 | acpi_gbl_FADT.xgpe0_block.address) { | ||
1353 | |||
1354 | /* GPE block 0 exists (has both length and address > 0) */ | ||
1355 | |||
1356 | register_count0 = (u16) (acpi_gbl_FADT.gpe0_block_length / 2); | ||
1357 | |||
1358 | gpe_number_max = | ||
1359 | (register_count0 * ACPI_GPE_REGISTER_WIDTH) - 1; | ||
1360 | |||
1361 | /* Install GPE Block 0 */ | ||
1362 | |||
1363 | status = acpi_ev_create_gpe_block(acpi_gbl_fadt_gpe_device, | ||
1364 | &acpi_gbl_FADT.xgpe0_block, | ||
1365 | register_count0, 0, | ||
1366 | acpi_gbl_FADT.sci_interrupt, | ||
1367 | &acpi_gbl_gpe_fadt_blocks[0]); | ||
1368 | |||
1369 | if (ACPI_FAILURE(status)) { | ||
1370 | ACPI_EXCEPTION((AE_INFO, status, | ||
1371 | "Could not create GPE Block 0")); | ||
1372 | } | ||
1373 | } | ||
1374 | |||
1375 | if (acpi_gbl_FADT.gpe1_block_length && | ||
1376 | acpi_gbl_FADT.xgpe1_block.address) { | ||
1377 | |||
1378 | /* GPE block 1 exists (has both length and address > 0) */ | ||
1379 | |||
1380 | register_count1 = (u16) (acpi_gbl_FADT.gpe1_block_length / 2); | ||
1381 | |||
1382 | /* Check for GPE0/GPE1 overlap (if both banks exist) */ | ||
1383 | |||
1384 | if ((register_count0) && | ||
1385 | (gpe_number_max >= acpi_gbl_FADT.gpe1_base)) { | ||
1386 | ACPI_ERROR((AE_INFO, | ||
1387 | "GPE0 block (GPE 0 to %u) overlaps the GPE1 block " | ||
1388 | "(GPE %u to %u) - Ignoring GPE1", | ||
1389 | gpe_number_max, acpi_gbl_FADT.gpe1_base, | ||
1390 | acpi_gbl_FADT.gpe1_base + | ||
1391 | ((register_count1 * | ||
1392 | ACPI_GPE_REGISTER_WIDTH) - 1))); | ||
1393 | |||
1394 | /* Ignore GPE1 block by setting the register count to zero */ | ||
1395 | |||
1396 | register_count1 = 0; | ||
1397 | } else { | ||
1398 | /* Install GPE Block 1 */ | ||
1399 | |||
1400 | status = | ||
1401 | acpi_ev_create_gpe_block(acpi_gbl_fadt_gpe_device, | ||
1402 | &acpi_gbl_FADT.xgpe1_block, | ||
1403 | register_count1, | ||
1404 | acpi_gbl_FADT.gpe1_base, | ||
1405 | acpi_gbl_FADT. | ||
1406 | sci_interrupt, | ||
1407 | &acpi_gbl_gpe_fadt_blocks | ||
1408 | [1]); | ||
1409 | |||
1410 | if (ACPI_FAILURE(status)) { | ||
1411 | ACPI_EXCEPTION((AE_INFO, status, | ||
1412 | "Could not create GPE Block 1")); | ||
1413 | } | ||
1414 | |||
1415 | /* | ||
1416 | * GPE0 and GPE1 do not have to be contiguous in the GPE number | ||
1417 | * space. However, GPE0 always starts at GPE number zero. | ||
1418 | */ | ||
1419 | gpe_number_max = acpi_gbl_FADT.gpe1_base + | ||
1420 | ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1); | ||
1421 | } | ||
1422 | } | ||
1423 | |||
1424 | /* Exit if there are no GPE registers */ | ||
1425 | |||
1426 | if ((register_count0 + register_count1) == 0) { | ||
1427 | |||
1428 | /* GPEs are not required by ACPI, this is OK */ | ||
1429 | |||
1430 | ACPI_DEBUG_PRINT((ACPI_DB_INIT, | ||
1431 | "There are no GPE blocks defined in the FADT\n")); | ||
1432 | status = AE_OK; | ||
1433 | goto cleanup; | ||
1434 | } | ||
1435 | |||
1436 | /* Check for Max GPE number out-of-range */ | ||
1437 | |||
1438 | if (gpe_number_max > ACPI_GPE_MAX) { | ||
1439 | ACPI_ERROR((AE_INFO, | ||
1440 | "Maximum GPE number from FADT is too large: 0x%X", | ||
1441 | gpe_number_max)); | ||
1442 | status = AE_BAD_VALUE; | ||
1443 | goto cleanup; | ||
1444 | } | ||
1445 | |||
1446 | cleanup: | ||
1447 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | ||
1448 | return_ACPI_STATUS(AE_OK); | ||
1449 | } | ||
diff --git a/drivers/acpi/acpica/evgpeinit.c b/drivers/acpi/acpica/evgpeinit.c new file mode 100644 index 000000000000..3f6c2d26410d --- /dev/null +++ b/drivers/acpi/acpica/evgpeinit.c | |||
@@ -0,0 +1,653 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: evgpeinit - System GPE initialization and update | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2010, 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 | #include <acpi/acpi.h> | ||
45 | #include "accommon.h" | ||
46 | #include "acevents.h" | ||
47 | #include "acnamesp.h" | ||
48 | #include "acinterp.h" | ||
49 | |||
50 | #define _COMPONENT ACPI_EVENTS | ||
51 | ACPI_MODULE_NAME("evgpeinit") | ||
52 | |||
53 | /******************************************************************************* | ||
54 | * | ||
55 | * FUNCTION: acpi_ev_gpe_initialize | ||
56 | * | ||
57 | * PARAMETERS: None | ||
58 | * | ||
59 | * RETURN: Status | ||
60 | * | ||
61 | * DESCRIPTION: Initialize the GPE data structures and the FADT GPE 0/1 blocks | ||
62 | * | ||
63 | ******************************************************************************/ | ||
64 | acpi_status acpi_ev_gpe_initialize(void) | ||
65 | { | ||
66 | u32 register_count0 = 0; | ||
67 | u32 register_count1 = 0; | ||
68 | u32 gpe_number_max = 0; | ||
69 | acpi_status status; | ||
70 | |||
71 | ACPI_FUNCTION_TRACE(ev_gpe_initialize); | ||
72 | |||
73 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); | ||
74 | if (ACPI_FAILURE(status)) { | ||
75 | return_ACPI_STATUS(status); | ||
76 | } | ||
77 | |||
78 | /* | ||
79 | * Initialize the GPE Block(s) defined in the FADT | ||
80 | * | ||
81 | * Why the GPE register block lengths are divided by 2: From the ACPI | ||
82 | * Spec, section "General-Purpose Event Registers", we have: | ||
83 | * | ||
84 | * "Each register block contains two registers of equal length | ||
85 | * GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the | ||
86 | * GPE0_STS and GPE0_EN registers is equal to half the GPE0_LEN | ||
87 | * The length of the GPE1_STS and GPE1_EN registers is equal to | ||
88 | * half the GPE1_LEN. If a generic register block is not supported | ||
89 | * then its respective block pointer and block length values in the | ||
90 | * FADT table contain zeros. The GPE0_LEN and GPE1_LEN do not need | ||
91 | * to be the same size." | ||
92 | */ | ||
93 | |||
94 | /* | ||
95 | * Determine the maximum GPE number for this machine. | ||
96 | * | ||
97 | * Note: both GPE0 and GPE1 are optional, and either can exist without | ||
98 | * the other. | ||
99 | * | ||
100 | * If EITHER the register length OR the block address are zero, then that | ||
101 | * particular block is not supported. | ||
102 | */ | ||
103 | if (acpi_gbl_FADT.gpe0_block_length && | ||
104 | acpi_gbl_FADT.xgpe0_block.address) { | ||
105 | |||
106 | /* GPE block 0 exists (has both length and address > 0) */ | ||
107 | |||
108 | register_count0 = (u16)(acpi_gbl_FADT.gpe0_block_length / 2); | ||
109 | |||
110 | gpe_number_max = | ||
111 | (register_count0 * ACPI_GPE_REGISTER_WIDTH) - 1; | ||
112 | |||
113 | /* Install GPE Block 0 */ | ||
114 | |||
115 | status = acpi_ev_create_gpe_block(acpi_gbl_fadt_gpe_device, | ||
116 | &acpi_gbl_FADT.xgpe0_block, | ||
117 | register_count0, 0, | ||
118 | acpi_gbl_FADT.sci_interrupt, | ||
119 | &acpi_gbl_gpe_fadt_blocks[0]); | ||
120 | |||
121 | if (ACPI_FAILURE(status)) { | ||
122 | ACPI_EXCEPTION((AE_INFO, status, | ||
123 | "Could not create GPE Block 0")); | ||
124 | } | ||
125 | } | ||
126 | |||
127 | if (acpi_gbl_FADT.gpe1_block_length && | ||
128 | acpi_gbl_FADT.xgpe1_block.address) { | ||
129 | |||
130 | /* GPE block 1 exists (has both length and address > 0) */ | ||
131 | |||
132 | register_count1 = (u16)(acpi_gbl_FADT.gpe1_block_length / 2); | ||
133 | |||
134 | /* Check for GPE0/GPE1 overlap (if both banks exist) */ | ||
135 | |||
136 | if ((register_count0) && | ||
137 | (gpe_number_max >= acpi_gbl_FADT.gpe1_base)) { | ||
138 | ACPI_ERROR((AE_INFO, | ||
139 | "GPE0 block (GPE 0 to %u) overlaps the GPE1 block " | ||
140 | "(GPE %u to %u) - Ignoring GPE1", | ||
141 | gpe_number_max, acpi_gbl_FADT.gpe1_base, | ||
142 | acpi_gbl_FADT.gpe1_base + | ||
143 | ((register_count1 * | ||
144 | ACPI_GPE_REGISTER_WIDTH) - 1))); | ||
145 | |||
146 | /* Ignore GPE1 block by setting the register count to zero */ | ||
147 | |||
148 | register_count1 = 0; | ||
149 | } else { | ||
150 | /* Install GPE Block 1 */ | ||
151 | |||
152 | status = | ||
153 | acpi_ev_create_gpe_block(acpi_gbl_fadt_gpe_device, | ||
154 | &acpi_gbl_FADT.xgpe1_block, | ||
155 | register_count1, | ||
156 | acpi_gbl_FADT.gpe1_base, | ||
157 | acpi_gbl_FADT. | ||
158 | sci_interrupt, | ||
159 | &acpi_gbl_gpe_fadt_blocks | ||
160 | [1]); | ||
161 | |||
162 | if (ACPI_FAILURE(status)) { | ||
163 | ACPI_EXCEPTION((AE_INFO, status, | ||
164 | "Could not create GPE Block 1")); | ||
165 | } | ||
166 | |||
167 | /* | ||
168 | * GPE0 and GPE1 do not have to be contiguous in the GPE number | ||
169 | * space. However, GPE0 always starts at GPE number zero. | ||
170 | */ | ||
171 | gpe_number_max = acpi_gbl_FADT.gpe1_base + | ||
172 | ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1); | ||
173 | } | ||
174 | } | ||
175 | |||
176 | /* Exit if there are no GPE registers */ | ||
177 | |||
178 | if ((register_count0 + register_count1) == 0) { | ||
179 | |||
180 | /* GPEs are not required by ACPI, this is OK */ | ||
181 | |||
182 | ACPI_DEBUG_PRINT((ACPI_DB_INIT, | ||
183 | "There are no GPE blocks defined in the FADT\n")); | ||
184 | status = AE_OK; | ||
185 | goto cleanup; | ||
186 | } | ||
187 | |||
188 | /* Check for Max GPE number out-of-range */ | ||
189 | |||
190 | if (gpe_number_max > ACPI_GPE_MAX) { | ||
191 | ACPI_ERROR((AE_INFO, | ||
192 | "Maximum GPE number from FADT is too large: 0x%X", | ||
193 | gpe_number_max)); | ||
194 | status = AE_BAD_VALUE; | ||
195 | goto cleanup; | ||
196 | } | ||
197 | |||
198 | cleanup: | ||
199 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | ||
200 | return_ACPI_STATUS(AE_OK); | ||
201 | } | ||
202 | |||
203 | /******************************************************************************* | ||
204 | * | ||
205 | * FUNCTION: acpi_ev_update_gpes | ||
206 | * | ||
207 | * PARAMETERS: table_owner_id - ID of the newly-loaded ACPI table | ||
208 | * | ||
209 | * RETURN: None | ||
210 | * | ||
211 | * DESCRIPTION: Check for new GPE methods (_Lxx/_Exx) made available as a | ||
212 | * result of a Load() or load_table() operation. If new GPE | ||
213 | * methods have been installed, register the new methods and | ||
214 | * enable and runtime GPEs that are associated with them. Also, | ||
215 | * run any newly loaded _PRW methods in order to discover any | ||
216 | * new CAN_WAKE GPEs. | ||
217 | * | ||
218 | ******************************************************************************/ | ||
219 | |||
220 | void acpi_ev_update_gpes(acpi_owner_id table_owner_id) | ||
221 | { | ||
222 | struct acpi_gpe_xrupt_info *gpe_xrupt_info; | ||
223 | struct acpi_gpe_block_info *gpe_block; | ||
224 | struct acpi_gpe_walk_info walk_info; | ||
225 | acpi_status status = AE_OK; | ||
226 | u32 new_wake_gpe_count = 0; | ||
227 | |||
228 | /* We will examine only _PRW/_Lxx/_Exx methods owned by this table */ | ||
229 | |||
230 | walk_info.owner_id = table_owner_id; | ||
231 | walk_info.execute_by_owner_id = TRUE; | ||
232 | walk_info.count = 0; | ||
233 | |||
234 | if (acpi_gbl_leave_wake_gpes_disabled) { | ||
235 | /* | ||
236 | * 1) Run any newly-loaded _PRW methods to find any GPEs that | ||
237 | * can now be marked as CAN_WAKE GPEs. Note: We must run the | ||
238 | * _PRW methods before we process the _Lxx/_Exx methods because | ||
239 | * we will enable all runtime GPEs associated with the new | ||
240 | * _Lxx/_Exx methods at the time we process those methods. | ||
241 | * | ||
242 | * Unlock interpreter so that we can run the _PRW methods. | ||
243 | */ | ||
244 | walk_info.gpe_block = NULL; | ||
245 | walk_info.gpe_device = NULL; | ||
246 | |||
247 | acpi_ex_exit_interpreter(); | ||
248 | |||
249 | status = | ||
250 | acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | ||
251 | ACPI_UINT32_MAX, | ||
252 | ACPI_NS_WALK_NO_UNLOCK, | ||
253 | acpi_ev_match_prw_and_gpe, NULL, | ||
254 | &walk_info, NULL); | ||
255 | if (ACPI_FAILURE(status)) { | ||
256 | ACPI_EXCEPTION((AE_INFO, status, | ||
257 | "While executing _PRW methods")); | ||
258 | } | ||
259 | |||
260 | acpi_ex_enter_interpreter(); | ||
261 | new_wake_gpe_count = walk_info.count; | ||
262 | } | ||
263 | |||
264 | /* | ||
265 | * 2) Find any _Lxx/_Exx GPE methods that have just been loaded. | ||
266 | * | ||
267 | * Any GPEs that correspond to new _Lxx/_Exx methods and are not | ||
268 | * marked as CAN_WAKE are immediately enabled. | ||
269 | * | ||
270 | * Examine the namespace underneath each gpe_device within the | ||
271 | * gpe_block lists. | ||
272 | */ | ||
273 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); | ||
274 | if (ACPI_FAILURE(status)) { | ||
275 | return; | ||
276 | } | ||
277 | |||
278 | walk_info.count = 0; | ||
279 | walk_info.enable_this_gpe = TRUE; | ||
280 | |||
281 | /* Walk the interrupt level descriptor list */ | ||
282 | |||
283 | gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head; | ||
284 | while (gpe_xrupt_info) { | ||
285 | |||
286 | /* Walk all Gpe Blocks attached to this interrupt level */ | ||
287 | |||
288 | gpe_block = gpe_xrupt_info->gpe_block_list_head; | ||
289 | while (gpe_block) { | ||
290 | walk_info.gpe_block = gpe_block; | ||
291 | walk_info.gpe_device = gpe_block->node; | ||
292 | |||
293 | status = acpi_ns_walk_namespace(ACPI_TYPE_METHOD, | ||
294 | walk_info.gpe_device, | ||
295 | ACPI_UINT32_MAX, | ||
296 | ACPI_NS_WALK_NO_UNLOCK, | ||
297 | acpi_ev_match_gpe_method, | ||
298 | NULL, &walk_info, NULL); | ||
299 | if (ACPI_FAILURE(status)) { | ||
300 | ACPI_EXCEPTION((AE_INFO, status, | ||
301 | "While decoding _Lxx/_Exx methods")); | ||
302 | } | ||
303 | |||
304 | gpe_block = gpe_block->next; | ||
305 | } | ||
306 | |||
307 | gpe_xrupt_info = gpe_xrupt_info->next; | ||
308 | } | ||
309 | |||
310 | if (walk_info.count || new_wake_gpe_count) { | ||
311 | ACPI_INFO((AE_INFO, | ||
312 | "Enabled %u new runtime GPEs, added %u new wakeup GPEs", | ||
313 | walk_info.count, new_wake_gpe_count)); | ||
314 | } | ||
315 | |||
316 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); | ||
317 | return; | ||
318 | } | ||
319 | |||
320 | /******************************************************************************* | ||
321 | * | ||
322 | * FUNCTION: acpi_ev_match_gpe_method | ||
323 | * | ||
324 | * PARAMETERS: Callback from walk_namespace | ||
325 | * | ||
326 | * RETURN: Status | ||
327 | * | ||
328 | * DESCRIPTION: Called from acpi_walk_namespace. Expects each object to be a | ||
329 | * control method under the _GPE portion of the namespace. | ||
330 | * Extract the name and GPE type from the object, saving this | ||
331 | * information for quick lookup during GPE dispatch. Allows a | ||
332 | * per-owner_id evaluation if execute_by_owner_id is TRUE in the | ||
333 | * walk_info parameter block. | ||
334 | * | ||
335 | * The name of each GPE control method is of the form: | ||
336 | * "_Lxx" or "_Exx", where: | ||
337 | * L - means that the GPE is level triggered | ||
338 | * E - means that the GPE is edge triggered | ||
339 | * xx - is the GPE number [in HEX] | ||
340 | * | ||
341 | * If walk_info->execute_by_owner_id is TRUE, we only execute examine GPE methods | ||
342 | * with that owner. | ||
343 | * If walk_info->enable_this_gpe is TRUE, the GPE that is referred to by a GPE | ||
344 | * method is immediately enabled (Used for Load/load_table operators) | ||
345 | * | ||
346 | ******************************************************************************/ | ||
347 | |||
348 | acpi_status | ||
349 | acpi_ev_match_gpe_method(acpi_handle obj_handle, | ||
350 | u32 level, void *context, void **return_value) | ||
351 | { | ||
352 | struct acpi_namespace_node *method_node = | ||
353 | ACPI_CAST_PTR(struct acpi_namespace_node, obj_handle); | ||
354 | struct acpi_gpe_walk_info *walk_info = | ||
355 | ACPI_CAST_PTR(struct acpi_gpe_walk_info, context); | ||
356 | struct acpi_gpe_event_info *gpe_event_info; | ||
357 | struct acpi_namespace_node *gpe_device; | ||
358 | acpi_status status; | ||
359 | u32 gpe_number; | ||
360 | char name[ACPI_NAME_SIZE + 1]; | ||
361 | u8 type; | ||
362 | |||
363 | ACPI_FUNCTION_TRACE(ev_match_gpe_method); | ||
364 | |||
365 | /* Check if requested owner_id matches this owner_id */ | ||
366 | |||
367 | if ((walk_info->execute_by_owner_id) && | ||
368 | (method_node->owner_id != walk_info->owner_id)) { | ||
369 | return_ACPI_STATUS(AE_OK); | ||
370 | } | ||
371 | |||
372 | /* | ||
373 | * Match and decode the _Lxx and _Exx GPE method names | ||
374 | * | ||
375 | * 1) Extract the method name and null terminate it | ||
376 | */ | ||
377 | ACPI_MOVE_32_TO_32(name, &method_node->name.integer); | ||
378 | name[ACPI_NAME_SIZE] = 0; | ||
379 | |||
380 | /* 2) Name must begin with an underscore */ | ||
381 | |||
382 | if (name[0] != '_') { | ||
383 | return_ACPI_STATUS(AE_OK); /* Ignore this method */ | ||
384 | } | ||
385 | |||
386 | /* | ||
387 | * 3) Edge/Level determination is based on the 2nd character | ||
388 | * of the method name | ||
389 | * | ||
390 | * NOTE: Default GPE type is RUNTIME only. Later, if a _PRW object is | ||
391 | * found that points to this GPE, the ACPI_GPE_CAN_WAKE flag is set. | ||
392 | */ | ||
393 | switch (name[1]) { | ||
394 | case 'L': | ||
395 | type = ACPI_GPE_LEVEL_TRIGGERED; | ||
396 | break; | ||
397 | |||
398 | case 'E': | ||
399 | type = ACPI_GPE_EDGE_TRIGGERED; | ||
400 | break; | ||
401 | |||
402 | default: | ||
403 | /* Unknown method type, just ignore it */ | ||
404 | |||
405 | ACPI_DEBUG_PRINT((ACPI_DB_LOAD, | ||
406 | "Ignoring unknown GPE method type: %s " | ||
407 | "(name not of form _Lxx or _Exx)", name)); | ||
408 | return_ACPI_STATUS(AE_OK); | ||
409 | } | ||
410 | |||
411 | /* 4) The last two characters of the name are the hex GPE Number */ | ||
412 | |||
413 | gpe_number = ACPI_STRTOUL(&name[2], NULL, 16); | ||
414 | if (gpe_number == ACPI_UINT32_MAX) { | ||
415 | |||
416 | /* Conversion failed; invalid method, just ignore it */ | ||
417 | |||
418 | ACPI_DEBUG_PRINT((ACPI_DB_LOAD, | ||
419 | "Could not extract GPE number from name: %s " | ||
420 | "(name is not of form _Lxx or _Exx)", name)); | ||
421 | return_ACPI_STATUS(AE_OK); | ||
422 | } | ||
423 | |||
424 | /* Ensure that we have a valid GPE number for this GPE block */ | ||
425 | |||
426 | gpe_event_info = | ||
427 | acpi_ev_low_get_gpe_info(gpe_number, walk_info->gpe_block); | ||
428 | if (!gpe_event_info) { | ||
429 | /* | ||
430 | * This gpe_number is not valid for this GPE block, just ignore it. | ||
431 | * However, it may be valid for a different GPE block, since GPE0 | ||
432 | * and GPE1 methods both appear under \_GPE. | ||
433 | */ | ||
434 | return_ACPI_STATUS(AE_OK); | ||
435 | } | ||
436 | |||
437 | if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == | ||
438 | ACPI_GPE_DISPATCH_HANDLER) { | ||
439 | |||
440 | /* If there is already a handler, ignore this GPE method */ | ||
441 | |||
442 | return_ACPI_STATUS(AE_OK); | ||
443 | } | ||
444 | |||
445 | if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == | ||
446 | ACPI_GPE_DISPATCH_METHOD) { | ||
447 | /* | ||
448 | * If there is already a method, ignore this method. But check | ||
449 | * for a type mismatch (if both the _Lxx AND _Exx exist) | ||
450 | */ | ||
451 | if (type != (gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK)) { | ||
452 | ACPI_ERROR((AE_INFO, | ||
453 | "For GPE 0x%.2X, found both _L%2.2X and _E%2.2X methods", | ||
454 | gpe_number, gpe_number, gpe_number)); | ||
455 | } | ||
456 | return_ACPI_STATUS(AE_OK); | ||
457 | } | ||
458 | |||
459 | /* | ||
460 | * Add the GPE information from above to the gpe_event_info block for | ||
461 | * use during dispatch of this GPE. | ||
462 | */ | ||
463 | gpe_event_info->flags |= (u8)(type | ACPI_GPE_DISPATCH_METHOD); | ||
464 | gpe_event_info->dispatch.method_node = method_node; | ||
465 | |||
466 | /* | ||
467 | * Enable this GPE if requested. This only happens when during the | ||
468 | * execution of a Load or load_table operator. We have found a new | ||
469 | * GPE method and want to immediately enable the GPE if it is a | ||
470 | * runtime GPE. | ||
471 | */ | ||
472 | if (walk_info->enable_this_gpe) { | ||
473 | |||
474 | /* Ignore GPEs that can wake the system */ | ||
475 | |||
476 | if (!(gpe_event_info->flags & ACPI_GPE_CAN_WAKE) || | ||
477 | !acpi_gbl_leave_wake_gpes_disabled) { | ||
478 | walk_info->count++; | ||
479 | gpe_device = walk_info->gpe_device; | ||
480 | |||
481 | if (gpe_device == acpi_gbl_fadt_gpe_device) { | ||
482 | gpe_device = NULL; | ||
483 | } | ||
484 | |||
485 | status = acpi_enable_gpe(gpe_device, gpe_number, | ||
486 | ACPI_GPE_TYPE_RUNTIME); | ||
487 | if (ACPI_FAILURE(status)) { | ||
488 | ACPI_EXCEPTION((AE_INFO, status, | ||
489 | "Could not enable GPE 0x%02X", | ||
490 | gpe_number)); | ||
491 | } | ||
492 | } | ||
493 | } | ||
494 | |||
495 | ACPI_DEBUG_PRINT((ACPI_DB_LOAD, | ||
496 | "Registered GPE method %s as GPE number 0x%.2X\n", | ||
497 | name, gpe_number)); | ||
498 | return_ACPI_STATUS(AE_OK); | ||
499 | } | ||
500 | |||
501 | /******************************************************************************* | ||
502 | * | ||
503 | * FUNCTION: acpi_ev_match_prw_and_gpe | ||
504 | * | ||
505 | * PARAMETERS: Callback from walk_namespace | ||
506 | * | ||
507 | * RETURN: Status. NOTE: We ignore errors so that the _PRW walk is | ||
508 | * not aborted on a single _PRW failure. | ||
509 | * | ||
510 | * DESCRIPTION: Called from acpi_walk_namespace. Expects each object to be a | ||
511 | * Device. Run the _PRW method. If present, extract the GPE | ||
512 | * number and mark the GPE as a CAN_WAKE GPE. Allows a | ||
513 | * per-owner_id execution if execute_by_owner_id is TRUE in the | ||
514 | * walk_info parameter block. | ||
515 | * | ||
516 | * If walk_info->execute_by_owner_id is TRUE, we only execute _PRWs with that | ||
517 | * owner. | ||
518 | * If walk_info->gpe_device is NULL, we execute every _PRW found. Otherwise, | ||
519 | * we only execute _PRWs that refer to the input gpe_device. | ||
520 | * | ||
521 | ******************************************************************************/ | ||
522 | |||
523 | acpi_status | ||
524 | acpi_ev_match_prw_and_gpe(acpi_handle obj_handle, | ||
525 | u32 level, void *context, void **return_value) | ||
526 | { | ||
527 | struct acpi_gpe_walk_info *walk_info = | ||
528 | ACPI_CAST_PTR(struct acpi_gpe_walk_info, context); | ||
529 | struct acpi_namespace_node *gpe_device; | ||
530 | struct acpi_gpe_block_info *gpe_block; | ||
531 | struct acpi_namespace_node *target_gpe_device; | ||
532 | struct acpi_namespace_node *prw_node; | ||
533 | struct acpi_gpe_event_info *gpe_event_info; | ||
534 | union acpi_operand_object *pkg_desc; | ||
535 | union acpi_operand_object *obj_desc; | ||
536 | u32 gpe_number; | ||
537 | acpi_status status; | ||
538 | |||
539 | ACPI_FUNCTION_TRACE(ev_match_prw_and_gpe); | ||
540 | |||
541 | /* Check for a _PRW method under this device */ | ||
542 | |||
543 | status = acpi_ns_get_node(obj_handle, METHOD_NAME__PRW, | ||
544 | ACPI_NS_NO_UPSEARCH, &prw_node); | ||
545 | if (ACPI_FAILURE(status)) { | ||
546 | return_ACPI_STATUS(AE_OK); | ||
547 | } | ||
548 | |||
549 | /* Check if requested owner_id matches this owner_id */ | ||
550 | |||
551 | if ((walk_info->execute_by_owner_id) && | ||
552 | (prw_node->owner_id != walk_info->owner_id)) { | ||
553 | return_ACPI_STATUS(AE_OK); | ||
554 | } | ||
555 | |||
556 | /* Execute the _PRW */ | ||
557 | |||
558 | status = acpi_ut_evaluate_object(prw_node, NULL, | ||
559 | ACPI_BTYPE_PACKAGE, &pkg_desc); | ||
560 | if (ACPI_FAILURE(status)) { | ||
561 | return_ACPI_STATUS(AE_OK); | ||
562 | } | ||
563 | |||
564 | /* The returned _PRW package must have at least two elements */ | ||
565 | |||
566 | if (pkg_desc->package.count < 2) { | ||
567 | goto cleanup; | ||
568 | } | ||
569 | |||
570 | /* Extract pointers from the input context */ | ||
571 | |||
572 | gpe_device = walk_info->gpe_device; | ||
573 | gpe_block = walk_info->gpe_block; | ||
574 | |||
575 | /* | ||
576 | * The _PRW object must return a package, we are only interested | ||
577 | * in the first element | ||
578 | */ | ||
579 | obj_desc = pkg_desc->package.elements[0]; | ||
580 | |||
581 | if (obj_desc->common.type == ACPI_TYPE_INTEGER) { | ||
582 | |||
583 | /* Use FADT-defined GPE device (from definition of _PRW) */ | ||
584 | |||
585 | target_gpe_device = NULL; | ||
586 | if (gpe_device) { | ||
587 | target_gpe_device = acpi_gbl_fadt_gpe_device; | ||
588 | } | ||
589 | |||
590 | /* Integer is the GPE number in the FADT described GPE blocks */ | ||
591 | |||
592 | gpe_number = (u32)obj_desc->integer.value; | ||
593 | } else if (obj_desc->common.type == ACPI_TYPE_PACKAGE) { | ||
594 | |||
595 | /* Package contains a GPE reference and GPE number within a GPE block */ | ||
596 | |||
597 | if ((obj_desc->package.count < 2) || | ||
598 | ((obj_desc->package.elements[0])->common.type != | ||
599 | ACPI_TYPE_LOCAL_REFERENCE) || | ||
600 | ((obj_desc->package.elements[1])->common.type != | ||
601 | ACPI_TYPE_INTEGER)) { | ||
602 | goto cleanup; | ||
603 | } | ||
604 | |||
605 | /* Get GPE block reference and decode */ | ||
606 | |||
607 | target_gpe_device = | ||
608 | obj_desc->package.elements[0]->reference.node; | ||
609 | gpe_number = (u32)obj_desc->package.elements[1]->integer.value; | ||
610 | } else { | ||
611 | /* Unknown type, just ignore it */ | ||
612 | |||
613 | goto cleanup; | ||
614 | } | ||
615 | |||
616 | /* Get the gpe_event_info for this GPE */ | ||
617 | |||
618 | if (gpe_device) { | ||
619 | /* | ||
620 | * Is this GPE within this block? | ||
621 | * | ||
622 | * TRUE if and only if these conditions are true: | ||
623 | * 1) The GPE devices match. | ||
624 | * 2) The GPE index(number) is within the range of the Gpe Block | ||
625 | * associated with the GPE device. | ||
626 | */ | ||
627 | if (gpe_device != target_gpe_device) { | ||
628 | goto cleanup; | ||
629 | } | ||
630 | |||
631 | gpe_event_info = | ||
632 | acpi_ev_low_get_gpe_info(gpe_number, gpe_block); | ||
633 | } else { | ||
634 | /* gpe_device is NULL, just match the target_device and gpe_number */ | ||
635 | |||
636 | gpe_event_info = | ||
637 | acpi_ev_get_gpe_event_info(target_gpe_device, gpe_number); | ||
638 | } | ||
639 | |||
640 | if (gpe_event_info) { | ||
641 | if (!(gpe_event_info->flags & ACPI_GPE_CAN_WAKE)) { | ||
642 | |||
643 | /* This GPE can wake the system */ | ||
644 | |||
645 | gpe_event_info->flags |= ACPI_GPE_CAN_WAKE; | ||
646 | walk_info->count++; | ||
647 | } | ||
648 | } | ||
649 | |||
650 | cleanup: | ||
651 | acpi_ut_remove_reference(pkg_desc); | ||
652 | return_ACPI_STATUS(AE_OK); | ||
653 | } | ||
diff --git a/drivers/acpi/acpica/evgpeutil.c b/drivers/acpi/acpica/evgpeutil.c new file mode 100644 index 000000000000..19a0e513ea48 --- /dev/null +++ b/drivers/acpi/acpica/evgpeutil.c | |||
@@ -0,0 +1,337 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: evgpeutil - GPE utilities | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2010, 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 | #include <acpi/acpi.h> | ||
45 | #include "accommon.h" | ||
46 | #include "acevents.h" | ||
47 | |||
48 | #define _COMPONENT ACPI_EVENTS | ||
49 | ACPI_MODULE_NAME("evgpeutil") | ||
50 | |||
51 | /******************************************************************************* | ||
52 | * | ||
53 | * FUNCTION: acpi_ev_walk_gpe_list | ||
54 | * | ||
55 | * PARAMETERS: gpe_walk_callback - Routine called for each GPE block | ||
56 | * Context - Value passed to callback | ||
57 | * | ||
58 | * RETURN: Status | ||
59 | * | ||
60 | * DESCRIPTION: Walk the GPE lists. | ||
61 | * | ||
62 | ******************************************************************************/ | ||
63 | acpi_status | ||
64 | acpi_ev_walk_gpe_list(acpi_gpe_callback gpe_walk_callback, void *context) | ||
65 | { | ||
66 | struct acpi_gpe_block_info *gpe_block; | ||
67 | struct acpi_gpe_xrupt_info *gpe_xrupt_info; | ||
68 | acpi_status status = AE_OK; | ||
69 | acpi_cpu_flags flags; | ||
70 | |||
71 | ACPI_FUNCTION_TRACE(ev_walk_gpe_list); | ||
72 | |||
73 | flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); | ||
74 | |||
75 | /* Walk the interrupt level descriptor list */ | ||
76 | |||
77 | gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head; | ||
78 | while (gpe_xrupt_info) { | ||
79 | |||
80 | /* Walk all Gpe Blocks attached to this interrupt level */ | ||
81 | |||
82 | gpe_block = gpe_xrupt_info->gpe_block_list_head; | ||
83 | while (gpe_block) { | ||
84 | |||
85 | /* One callback per GPE block */ | ||
86 | |||
87 | status = | ||
88 | gpe_walk_callback(gpe_xrupt_info, gpe_block, | ||
89 | context); | ||
90 | if (ACPI_FAILURE(status)) { | ||
91 | if (status == AE_CTRL_END) { /* Callback abort */ | ||
92 | status = AE_OK; | ||
93 | } | ||
94 | goto unlock_and_exit; | ||
95 | } | ||
96 | |||
97 | gpe_block = gpe_block->next; | ||
98 | } | ||
99 | |||
100 | gpe_xrupt_info = gpe_xrupt_info->next; | ||
101 | } | ||
102 | |||
103 | unlock_and_exit: | ||
104 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); | ||
105 | return_ACPI_STATUS(status); | ||
106 | } | ||
107 | |||
108 | /******************************************************************************* | ||
109 | * | ||
110 | * FUNCTION: acpi_ev_valid_gpe_event | ||
111 | * | ||
112 | * PARAMETERS: gpe_event_info - Info for this GPE | ||
113 | * | ||
114 | * RETURN: TRUE if the gpe_event is valid | ||
115 | * | ||
116 | * DESCRIPTION: Validate a GPE event. DO NOT CALL FROM INTERRUPT LEVEL. | ||
117 | * Should be called only when the GPE lists are semaphore locked | ||
118 | * and not subject to change. | ||
119 | * | ||
120 | ******************************************************************************/ | ||
121 | |||
122 | u8 acpi_ev_valid_gpe_event(struct acpi_gpe_event_info *gpe_event_info) | ||
123 | { | ||
124 | struct acpi_gpe_xrupt_info *gpe_xrupt_block; | ||
125 | struct acpi_gpe_block_info *gpe_block; | ||
126 | |||
127 | ACPI_FUNCTION_ENTRY(); | ||
128 | |||
129 | /* No need for spin lock since we are not changing any list elements */ | ||
130 | |||
131 | /* Walk the GPE interrupt levels */ | ||
132 | |||
133 | gpe_xrupt_block = acpi_gbl_gpe_xrupt_list_head; | ||
134 | while (gpe_xrupt_block) { | ||
135 | gpe_block = gpe_xrupt_block->gpe_block_list_head; | ||
136 | |||
137 | /* Walk the GPE blocks on this interrupt level */ | ||
138 | |||
139 | while (gpe_block) { | ||
140 | if ((&gpe_block->event_info[0] <= gpe_event_info) && | ||
141 | (&gpe_block->event_info[gpe_block->gpe_count] > | ||
142 | gpe_event_info)) { | ||
143 | return (TRUE); | ||
144 | } | ||
145 | |||
146 | gpe_block = gpe_block->next; | ||
147 | } | ||
148 | |||
149 | gpe_xrupt_block = gpe_xrupt_block->next; | ||
150 | } | ||
151 | |||
152 | return (FALSE); | ||
153 | } | ||
154 | |||
155 | /******************************************************************************* | ||
156 | * | ||
157 | * FUNCTION: acpi_ev_get_gpe_xrupt_block | ||
158 | * | ||
159 | * PARAMETERS: interrupt_number - Interrupt for a GPE block | ||
160 | * | ||
161 | * RETURN: A GPE interrupt block | ||
162 | * | ||
163 | * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt | ||
164 | * block per unique interrupt level used for GPEs. Should be | ||
165 | * called only when the GPE lists are semaphore locked and not | ||
166 | * subject to change. | ||
167 | * | ||
168 | ******************************************************************************/ | ||
169 | |||
170 | struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 interrupt_number) | ||
171 | { | ||
172 | struct acpi_gpe_xrupt_info *next_gpe_xrupt; | ||
173 | struct acpi_gpe_xrupt_info *gpe_xrupt; | ||
174 | acpi_status status; | ||
175 | acpi_cpu_flags flags; | ||
176 | |||
177 | ACPI_FUNCTION_TRACE(ev_get_gpe_xrupt_block); | ||
178 | |||
179 | /* No need for lock since we are not changing any list elements here */ | ||
180 | |||
181 | next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; | ||
182 | while (next_gpe_xrupt) { | ||
183 | if (next_gpe_xrupt->interrupt_number == interrupt_number) { | ||
184 | return_PTR(next_gpe_xrupt); | ||
185 | } | ||
186 | |||
187 | next_gpe_xrupt = next_gpe_xrupt->next; | ||
188 | } | ||
189 | |||
190 | /* Not found, must allocate a new xrupt descriptor */ | ||
191 | |||
192 | gpe_xrupt = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_xrupt_info)); | ||
193 | if (!gpe_xrupt) { | ||
194 | return_PTR(NULL); | ||
195 | } | ||
196 | |||
197 | gpe_xrupt->interrupt_number = interrupt_number; | ||
198 | |||
199 | /* Install new interrupt descriptor with spin lock */ | ||
200 | |||
201 | flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); | ||
202 | if (acpi_gbl_gpe_xrupt_list_head) { | ||
203 | next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; | ||
204 | while (next_gpe_xrupt->next) { | ||
205 | next_gpe_xrupt = next_gpe_xrupt->next; | ||
206 | } | ||
207 | |||
208 | next_gpe_xrupt->next = gpe_xrupt; | ||
209 | gpe_xrupt->previous = next_gpe_xrupt; | ||
210 | } else { | ||
211 | acpi_gbl_gpe_xrupt_list_head = gpe_xrupt; | ||
212 | } | ||
213 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); | ||
214 | |||
215 | /* Install new interrupt handler if not SCI_INT */ | ||
216 | |||
217 | if (interrupt_number != acpi_gbl_FADT.sci_interrupt) { | ||
218 | status = acpi_os_install_interrupt_handler(interrupt_number, | ||
219 | acpi_ev_gpe_xrupt_handler, | ||
220 | gpe_xrupt); | ||
221 | if (ACPI_FAILURE(status)) { | ||
222 | ACPI_ERROR((AE_INFO, | ||
223 | "Could not install GPE interrupt handler at level 0x%X", | ||
224 | interrupt_number)); | ||
225 | return_PTR(NULL); | ||
226 | } | ||
227 | } | ||
228 | |||
229 | return_PTR(gpe_xrupt); | ||
230 | } | ||
231 | |||
232 | /******************************************************************************* | ||
233 | * | ||
234 | * FUNCTION: acpi_ev_delete_gpe_xrupt | ||
235 | * | ||
236 | * PARAMETERS: gpe_xrupt - A GPE interrupt info block | ||
237 | * | ||
238 | * RETURN: Status | ||
239 | * | ||
240 | * DESCRIPTION: Remove and free a gpe_xrupt block. Remove an associated | ||
241 | * interrupt handler if not the SCI interrupt. | ||
242 | * | ||
243 | ******************************************************************************/ | ||
244 | |||
245 | acpi_status acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt) | ||
246 | { | ||
247 | acpi_status status; | ||
248 | acpi_cpu_flags flags; | ||
249 | |||
250 | ACPI_FUNCTION_TRACE(ev_delete_gpe_xrupt); | ||
251 | |||
252 | /* We never want to remove the SCI interrupt handler */ | ||
253 | |||
254 | if (gpe_xrupt->interrupt_number == acpi_gbl_FADT.sci_interrupt) { | ||
255 | gpe_xrupt->gpe_block_list_head = NULL; | ||
256 | return_ACPI_STATUS(AE_OK); | ||
257 | } | ||
258 | |||
259 | /* Disable this interrupt */ | ||
260 | |||
261 | status = | ||
262 | acpi_os_remove_interrupt_handler(gpe_xrupt->interrupt_number, | ||
263 | acpi_ev_gpe_xrupt_handler); | ||
264 | if (ACPI_FAILURE(status)) { | ||
265 | return_ACPI_STATUS(status); | ||
266 | } | ||
267 | |||
268 | /* Unlink the interrupt block with lock */ | ||
269 | |||
270 | flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); | ||
271 | if (gpe_xrupt->previous) { | ||
272 | gpe_xrupt->previous->next = gpe_xrupt->next; | ||
273 | } else { | ||
274 | /* No previous, update list head */ | ||
275 | |||
276 | acpi_gbl_gpe_xrupt_list_head = gpe_xrupt->next; | ||
277 | } | ||
278 | |||
279 | if (gpe_xrupt->next) { | ||
280 | gpe_xrupt->next->previous = gpe_xrupt->previous; | ||
281 | } | ||
282 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); | ||
283 | |||
284 | /* Free the block */ | ||
285 | |||
286 | ACPI_FREE(gpe_xrupt); | ||
287 | return_ACPI_STATUS(AE_OK); | ||
288 | } | ||
289 | |||
290 | /******************************************************************************* | ||
291 | * | ||
292 | * FUNCTION: acpi_ev_delete_gpe_handlers | ||
293 | * | ||
294 | * PARAMETERS: gpe_xrupt_info - GPE Interrupt info | ||
295 | * gpe_block - Gpe Block info | ||
296 | * | ||
297 | * RETURN: Status | ||
298 | * | ||
299 | * DESCRIPTION: Delete all Handler objects found in the GPE data structs. | ||
300 | * Used only prior to termination. | ||
301 | * | ||
302 | ******************************************************************************/ | ||
303 | |||
304 | acpi_status | ||
305 | acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info, | ||
306 | struct acpi_gpe_block_info *gpe_block, | ||
307 | void *context) | ||
308 | { | ||
309 | struct acpi_gpe_event_info *gpe_event_info; | ||
310 | u32 i; | ||
311 | u32 j; | ||
312 | |||
313 | ACPI_FUNCTION_TRACE(ev_delete_gpe_handlers); | ||
314 | |||
315 | /* Examine each GPE Register within the block */ | ||
316 | |||
317 | for (i = 0; i < gpe_block->register_count; i++) { | ||
318 | |||
319 | /* Now look at the individual GPEs in this byte register */ | ||
320 | |||
321 | for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { | ||
322 | gpe_event_info = &gpe_block->event_info[((acpi_size) i * | ||
323 | ACPI_GPE_REGISTER_WIDTH) | ||
324 | + j]; | ||
325 | |||
326 | if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == | ||
327 | ACPI_GPE_DISPATCH_HANDLER) { | ||
328 | ACPI_FREE(gpe_event_info->dispatch.handler); | ||
329 | gpe_event_info->dispatch.handler = NULL; | ||
330 | gpe_event_info->flags &= | ||
331 | ~ACPI_GPE_DISPATCH_MASK; | ||
332 | } | ||
333 | } | ||
334 | } | ||
335 | |||
336 | return_ACPI_STATUS(AE_OK); | ||
337 | } | ||