]>
Commit | Line | Data |
---|---|---|
95857638 | 1 | // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 |
1da177e4 LT |
2 | /****************************************************************************** |
3 | * | |
4 | * Module Name: evrgnini- ACPI address_space (op_region) init | |
5 | * | |
da6f8320 | 6 | * Copyright (C) 2000 - 2018, Intel Corp. |
1da177e4 | 7 | * |
95857638 | 8 | *****************************************************************************/ |
1da177e4 | 9 | |
1da177e4 | 10 | #include <acpi/acpi.h> |
e2f7a777 LB |
11 | #include "accommon.h" |
12 | #include "acevents.h" | |
13 | #include "acnamesp.h" | |
8633db6b | 14 | #include "acinterp.h" |
1da177e4 LT |
15 | |
16 | #define _COMPONENT ACPI_EVENTS | |
4be44fcd | 17 | ACPI_MODULE_NAME("evrgnini") |
1da177e4 LT |
18 | |
19 | /******************************************************************************* | |
20 | * | |
21 | * FUNCTION: acpi_ev_system_memory_region_setup | |
22 | * | |
ba494bee BM |
23 | * PARAMETERS: handle - Region we are interested in |
24 | * function - Start or stop | |
1da177e4 LT |
25 | * handler_context - Address space handler context |
26 | * region_context - Region specific context | |
27 | * | |
28 | * RETURN: Status | |
29 | * | |
44f6c012 | 30 | * DESCRIPTION: Setup a system_memory operation region |
1da177e4 LT |
31 | * |
32 | ******************************************************************************/ | |
1da177e4 | 33 | acpi_status |
4be44fcd LB |
34 | acpi_ev_system_memory_region_setup(acpi_handle handle, |
35 | u32 function, | |
36 | void *handler_context, void **region_context) | |
1da177e4 | 37 | { |
4be44fcd LB |
38 | union acpi_operand_object *region_desc = |
39 | (union acpi_operand_object *)handle; | |
40 | struct acpi_mem_space_context *local_region_context; | |
1da177e4 | 41 | |
b229cf92 | 42 | ACPI_FUNCTION_TRACE(ev_system_memory_region_setup); |
1da177e4 LT |
43 | |
44 | if (function == ACPI_REGION_DEACTIVATE) { | |
45 | if (*region_context) { | |
793c2388 BM |
46 | local_region_context = |
47 | (struct acpi_mem_space_context *)*region_context; | |
48 | ||
49 | /* Delete a cached mapping if present */ | |
50 | ||
51 | if (local_region_context->mapped_length) { | |
52 | acpi_os_unmap_memory(local_region_context-> | |
53 | mapped_logical_address, | |
54 | local_region_context-> | |
55 | mapped_length); | |
56 | } | |
57 | ACPI_FREE(local_region_context); | |
1da177e4 LT |
58 | *region_context = NULL; |
59 | } | |
4be44fcd | 60 | return_ACPI_STATUS(AE_OK); |
1da177e4 LT |
61 | } |
62 | ||
63 | /* Create a new context */ | |
64 | ||
4be44fcd | 65 | local_region_context = |
8313524a | 66 | ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_mem_space_context)); |
1da177e4 | 67 | if (!(local_region_context)) { |
4be44fcd | 68 | return_ACPI_STATUS(AE_NO_MEMORY); |
1da177e4 LT |
69 | } |
70 | ||
71 | /* Save the region length and address for use in the handler */ | |
72 | ||
73 | local_region_context->length = region_desc->region.length; | |
74 | local_region_context->address = region_desc->region.address; | |
75 | ||
76 | *region_context = local_region_context; | |
4be44fcd | 77 | return_ACPI_STATUS(AE_OK); |
1da177e4 LT |
78 | } |
79 | ||
1da177e4 LT |
80 | /******************************************************************************* |
81 | * | |
82 | * FUNCTION: acpi_ev_io_space_region_setup | |
83 | * | |
ba494bee BM |
84 | * PARAMETERS: handle - Region we are interested in |
85 | * function - Start or stop | |
1da177e4 LT |
86 | * handler_context - Address space handler context |
87 | * region_context - Region specific context | |
88 | * | |
89 | * RETURN: Status | |
90 | * | |
44f6c012 | 91 | * DESCRIPTION: Setup a IO operation region |
1da177e4 LT |
92 | * |
93 | ******************************************************************************/ | |
94 | ||
95 | acpi_status | |
4be44fcd LB |
96 | acpi_ev_io_space_region_setup(acpi_handle handle, |
97 | u32 function, | |
98 | void *handler_context, void **region_context) | |
1da177e4 | 99 | { |
b229cf92 | 100 | ACPI_FUNCTION_TRACE(ev_io_space_region_setup); |
1da177e4 LT |
101 | |
102 | if (function == ACPI_REGION_DEACTIVATE) { | |
103 | *region_context = NULL; | |
4be44fcd | 104 | } else { |
1da177e4 LT |
105 | *region_context = handler_context; |
106 | } | |
107 | ||
4be44fcd | 108 | return_ACPI_STATUS(AE_OK); |
1da177e4 LT |
109 | } |
110 | ||
1da177e4 LT |
111 | /******************************************************************************* |
112 | * | |
113 | * FUNCTION: acpi_ev_pci_config_region_setup | |
114 | * | |
ba494bee BM |
115 | * PARAMETERS: handle - Region we are interested in |
116 | * function - Start or stop | |
1da177e4 LT |
117 | * handler_context - Address space handler context |
118 | * region_context - Region specific context | |
119 | * | |
120 | * RETURN: Status | |
121 | * | |
44f6c012 | 122 | * DESCRIPTION: Setup a PCI_Config operation region |
1da177e4 LT |
123 | * |
124 | * MUTEX: Assumes namespace is not locked | |
125 | * | |
126 | ******************************************************************************/ | |
127 | ||
128 | acpi_status | |
4be44fcd LB |
129 | acpi_ev_pci_config_region_setup(acpi_handle handle, |
130 | u32 function, | |
131 | void *handler_context, void **region_context) | |
1da177e4 | 132 | { |
4be44fcd | 133 | acpi_status status = AE_OK; |
5df7e6cb | 134 | u64 pci_value; |
4be44fcd LB |
135 | struct acpi_pci_id *pci_id = *region_context; |
136 | union acpi_operand_object *handler_obj; | |
137 | struct acpi_namespace_node *parent_node; | |
138 | struct acpi_namespace_node *pci_root_node; | |
b7a69806 | 139 | struct acpi_namespace_node *pci_device_node; |
4be44fcd LB |
140 | union acpi_operand_object *region_obj = |
141 | (union acpi_operand_object *)handle; | |
4be44fcd | 142 | |
b229cf92 | 143 | ACPI_FUNCTION_TRACE(ev_pci_config_region_setup); |
1da177e4 LT |
144 | |
145 | handler_obj = region_obj->region.handler; | |
146 | if (!handler_obj) { | |
147 | /* | |
148 | * No installed handler. This shouldn't happen because the dispatch | |
149 | * routine checks before we get here, but we check again just in case. | |
150 | */ | |
4be44fcd LB |
151 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, |
152 | "Attempting to init a region %p, with no handler\n", | |
153 | region_obj)); | |
154 | return_ACPI_STATUS(AE_NOT_EXIST); | |
1da177e4 LT |
155 | } |
156 | ||
157 | *region_context = NULL; | |
158 | if (function == ACPI_REGION_DEACTIVATE) { | |
159 | if (pci_id) { | |
8313524a | 160 | ACPI_FREE(pci_id); |
1da177e4 | 161 | } |
4be44fcd | 162 | return_ACPI_STATUS(status); |
1da177e4 LT |
163 | } |
164 | ||
c45b5c09 | 165 | parent_node = region_obj->region.node->parent; |
1da177e4 LT |
166 | |
167 | /* | |
168 | * Get the _SEG and _BBN values from the device upon which the handler | |
169 | * is installed. | |
170 | * | |
171 | * We need to get the _SEG and _BBN objects relative to the PCI BUS device. | |
172 | * This is the device the handler has been registered to handle. | |
173 | */ | |
174 | ||
175 | /* | |
176 | * If the address_space.Node is still pointing to the root, we need | |
177 | * to scan upward for a PCI Root bridge and re-associate the op_region | |
178 | * handlers with that device. | |
179 | */ | |
180 | if (handler_obj->address_space.node == acpi_gbl_root_node) { | |
52fc0b02 | 181 | |
1da177e4 LT |
182 | /* Start search from the parent object */ |
183 | ||
184 | pci_root_node = parent_node; | |
185 | while (pci_root_node != acpi_gbl_root_node) { | |
b7a69806 BM |
186 | |
187 | /* Get the _HID/_CID in order to detect a root_bridge */ | |
188 | ||
189 | if (acpi_ev_is_pci_root_bridge(pci_root_node)) { | |
190 | ||
191 | /* Install a handler for this PCI root bridge */ | |
192 | ||
f5c1e1c5 | 193 | status = acpi_install_address_space_handler((acpi_handle)pci_root_node, ACPI_ADR_SPACE_PCI_CONFIG, ACPI_DEFAULT_HANDLER, NULL, NULL); |
b7a69806 BM |
194 | if (ACPI_FAILURE(status)) { |
195 | if (status == AE_SAME_HANDLER) { | |
196 | /* | |
9f15fc66 BM |
197 | * It is OK if the handler is already installed on the |
198 | * root bridge. Still need to return a context object | |
199 | * for the new PCI_Config operation region, however. | |
b7a69806 BM |
200 | */ |
201 | status = AE_OK; | |
202 | } else { | |
203 | ACPI_EXCEPTION((AE_INFO, status, | |
d4913dc6 BM |
204 | "Could not install PciConfig handler " |
205 | "for Root Bridge %4.4s", | |
b7a69806 BM |
206 | acpi_ut_get_node_name |
207 | (pci_root_node))); | |
1da177e4 | 208 | } |
1da177e4 | 209 | } |
b7a69806 | 210 | break; |
1da177e4 LT |
211 | } |
212 | ||
c45b5c09 | 213 | pci_root_node = pci_root_node->parent; |
1da177e4 LT |
214 | } |
215 | ||
216 | /* PCI root bridge not found, use namespace root node */ | |
4be44fcd | 217 | } else { |
1da177e4 LT |
218 | pci_root_node = handler_obj->address_space.node; |
219 | } | |
220 | ||
221 | /* | |
222 | * If this region is now initialized, we are done. | |
223 | * (install_address_space_handler could have initialized it) | |
224 | */ | |
225 | if (region_obj->region.flags & AOPOBJ_SETUP_COMPLETE) { | |
4be44fcd | 226 | return_ACPI_STATUS(AE_OK); |
1da177e4 LT |
227 | } |
228 | ||
229 | /* Region is still not initialized. Create a new context */ | |
230 | ||
8313524a | 231 | pci_id = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pci_id)); |
1da177e4 | 232 | if (!pci_id) { |
4be44fcd | 233 | return_ACPI_STATUS(AE_NO_MEMORY); |
1da177e4 LT |
234 | } |
235 | ||
236 | /* | |
9f15fc66 BM |
237 | * For PCI_Config space access, we need the segment, bus, device and |
238 | * function numbers. Acquire them here. | |
b7a69806 BM |
239 | * |
240 | * Find the parent device object. (This allows the operation region to be | |
241 | * within a subscope under the device, such as a control method.) | |
1da177e4 | 242 | */ |
b7a69806 BM |
243 | pci_device_node = region_obj->region.node; |
244 | while (pci_device_node && (pci_device_node->type != ACPI_TYPE_DEVICE)) { | |
c45b5c09 | 245 | pci_device_node = pci_device_node->parent; |
b7a69806 BM |
246 | } |
247 | ||
248 | if (!pci_device_node) { | |
e6917317 | 249 | ACPI_FREE(pci_id); |
b7a69806 BM |
250 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
251 | } | |
1da177e4 LT |
252 | |
253 | /* | |
95abccb5 BM |
254 | * Get the PCI device and function numbers from the _ADR object |
255 | * contained in the parent's scope. | |
1da177e4 | 256 | */ |
d4913dc6 BM |
257 | status = acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR, |
258 | pci_device_node, &pci_value); | |
1da177e4 LT |
259 | |
260 | /* | |
9f15fc66 BM |
261 | * The default is zero, and since the allocation above zeroed the data, |
262 | * just do nothing on failure. | |
1da177e4 | 263 | */ |
4be44fcd LB |
264 | if (ACPI_SUCCESS(status)) { |
265 | pci_id->device = ACPI_HIWORD(ACPI_LODWORD(pci_value)); | |
266 | pci_id->function = ACPI_LOWORD(ACPI_LODWORD(pci_value)); | |
1da177e4 LT |
267 | } |
268 | ||
269 | /* The PCI segment number comes from the _SEG method */ | |
270 | ||
d4913dc6 BM |
271 | status = acpi_ut_evaluate_numeric_object(METHOD_NAME__SEG, |
272 | pci_root_node, &pci_value); | |
4be44fcd LB |
273 | if (ACPI_SUCCESS(status)) { |
274 | pci_id->segment = ACPI_LOWORD(pci_value); | |
1da177e4 LT |
275 | } |
276 | ||
277 | /* The PCI bus number comes from the _BBN method */ | |
278 | ||
d4913dc6 BM |
279 | status = acpi_ut_evaluate_numeric_object(METHOD_NAME__BBN, |
280 | pci_root_node, &pci_value); | |
4be44fcd LB |
281 | if (ACPI_SUCCESS(status)) { |
282 | pci_id->bus = ACPI_LOWORD(pci_value); | |
1da177e4 LT |
283 | } |
284 | ||
95abccb5 | 285 | /* Complete/update the PCI ID for this device */ |
1da177e4 | 286 | |
95abccb5 BM |
287 | status = |
288 | acpi_hw_derive_pci_id(pci_id, pci_root_node, | |
289 | region_obj->region.node); | |
290 | if (ACPI_FAILURE(status)) { | |
291 | ACPI_FREE(pci_id); | |
292 | return_ACPI_STATUS(status); | |
293 | } | |
1da177e4 LT |
294 | |
295 | *region_context = pci_id; | |
4be44fcd | 296 | return_ACPI_STATUS(AE_OK); |
1da177e4 LT |
297 | } |
298 | ||
b7a69806 BM |
299 | /******************************************************************************* |
300 | * | |
301 | * FUNCTION: acpi_ev_is_pci_root_bridge | |
302 | * | |
ba494bee | 303 | * PARAMETERS: node - Device node being examined |
b7a69806 BM |
304 | * |
305 | * RETURN: TRUE if device is a PCI/PCI-Express Root Bridge | |
306 | * | |
307 | * DESCRIPTION: Determine if the input device represents a PCI Root Bridge by | |
308 | * examining the _HID and _CID for the device. | |
309 | * | |
310 | ******************************************************************************/ | |
311 | ||
8b1cafdc | 312 | u8 acpi_ev_is_pci_root_bridge(struct acpi_namespace_node *node) |
b7a69806 BM |
313 | { |
314 | acpi_status status; | |
78e25fef LZ |
315 | struct acpi_pnp_device_id *hid; |
316 | struct acpi_pnp_device_id_list *cid; | |
67a119f9 | 317 | u32 i; |
15b8dd53 | 318 | u8 match; |
b7a69806 | 319 | |
9f15fc66 BM |
320 | /* Get the _HID and check for a PCI Root Bridge */ |
321 | ||
b7a69806 BM |
322 | status = acpi_ut_execute_HID(node, &hid); |
323 | if (ACPI_FAILURE(status)) { | |
324 | return (FALSE); | |
325 | } | |
326 | ||
15b8dd53 BM |
327 | match = acpi_ut_is_pci_root_bridge(hid->string); |
328 | ACPI_FREE(hid); | |
329 | ||
330 | if (match) { | |
b7a69806 BM |
331 | return (TRUE); |
332 | } | |
333 | ||
9f15fc66 BM |
334 | /* The _HID did not match. Get the _CID and check for a PCI Root Bridge */ |
335 | ||
b7a69806 BM |
336 | status = acpi_ut_execute_CID(node, &cid); |
337 | if (ACPI_FAILURE(status)) { | |
338 | return (FALSE); | |
339 | } | |
340 | ||
341 | /* Check all _CIDs in the returned list */ | |
342 | ||
343 | for (i = 0; i < cid->count; i++) { | |
15b8dd53 | 344 | if (acpi_ut_is_pci_root_bridge(cid->ids[i].string)) { |
b7a69806 BM |
345 | ACPI_FREE(cid); |
346 | return (TRUE); | |
347 | } | |
348 | } | |
349 | ||
350 | ACPI_FREE(cid); | |
351 | return (FALSE); | |
352 | } | |
353 | ||
1da177e4 LT |
354 | /******************************************************************************* |
355 | * | |
356 | * FUNCTION: acpi_ev_pci_bar_region_setup | |
357 | * | |
ba494bee BM |
358 | * PARAMETERS: handle - Region we are interested in |
359 | * function - Start or stop | |
1da177e4 LT |
360 | * handler_context - Address space handler context |
361 | * region_context - Region specific context | |
362 | * | |
363 | * RETURN: Status | |
364 | * | |
ba494bee | 365 | * DESCRIPTION: Setup a pci_BAR operation region |
1da177e4 LT |
366 | * |
367 | * MUTEX: Assumes namespace is not locked | |
368 | * | |
369 | ******************************************************************************/ | |
370 | ||
371 | acpi_status | |
4be44fcd LB |
372 | acpi_ev_pci_bar_region_setup(acpi_handle handle, |
373 | u32 function, | |
374 | void *handler_context, void **region_context) | |
1da177e4 | 375 | { |
b229cf92 | 376 | ACPI_FUNCTION_TRACE(ev_pci_bar_region_setup); |
1da177e4 | 377 | |
4be44fcd | 378 | return_ACPI_STATUS(AE_OK); |
1da177e4 LT |
379 | } |
380 | ||
1da177e4 LT |
381 | /******************************************************************************* |
382 | * | |
383 | * FUNCTION: acpi_ev_cmos_region_setup | |
384 | * | |
ba494bee BM |
385 | * PARAMETERS: handle - Region we are interested in |
386 | * function - Start or stop | |
1da177e4 LT |
387 | * handler_context - Address space handler context |
388 | * region_context - Region specific context | |
389 | * | |
390 | * RETURN: Status | |
391 | * | |
44f6c012 | 392 | * DESCRIPTION: Setup a CMOS operation region |
1da177e4 LT |
393 | * |
394 | * MUTEX: Assumes namespace is not locked | |
395 | * | |
396 | ******************************************************************************/ | |
397 | ||
398 | acpi_status | |
4be44fcd LB |
399 | acpi_ev_cmos_region_setup(acpi_handle handle, |
400 | u32 function, | |
401 | void *handler_context, void **region_context) | |
1da177e4 | 402 | { |
b229cf92 | 403 | ACPI_FUNCTION_TRACE(ev_cmos_region_setup); |
1da177e4 | 404 | |
4be44fcd | 405 | return_ACPI_STATUS(AE_OK); |
1da177e4 LT |
406 | } |
407 | ||
1da177e4 LT |
408 | /******************************************************************************* |
409 | * | |
410 | * FUNCTION: acpi_ev_default_region_setup | |
411 | * | |
ba494bee BM |
412 | * PARAMETERS: handle - Region we are interested in |
413 | * function - Start or stop | |
1da177e4 LT |
414 | * handler_context - Address space handler context |
415 | * region_context - Region specific context | |
416 | * | |
417 | * RETURN: Status | |
418 | * | |
44f6c012 | 419 | * DESCRIPTION: Default region initialization |
1da177e4 LT |
420 | * |
421 | ******************************************************************************/ | |
422 | ||
423 | acpi_status | |
4be44fcd LB |
424 | acpi_ev_default_region_setup(acpi_handle handle, |
425 | u32 function, | |
426 | void *handler_context, void **region_context) | |
1da177e4 | 427 | { |
b229cf92 | 428 | ACPI_FUNCTION_TRACE(ev_default_region_setup); |
1da177e4 LT |
429 | |
430 | if (function == ACPI_REGION_DEACTIVATE) { | |
431 | *region_context = NULL; | |
4be44fcd | 432 | } else { |
1da177e4 LT |
433 | *region_context = handler_context; |
434 | } | |
435 | ||
4be44fcd | 436 | return_ACPI_STATUS(AE_OK); |
1da177e4 LT |
437 | } |
438 | ||
1da177e4 LT |
439 | /******************************************************************************* |
440 | * | |
441 | * FUNCTION: acpi_ev_initialize_region | |
442 | * | |
443 | * PARAMETERS: region_obj - Region we are initializing | |
1da177e4 LT |
444 | * |
445 | * RETURN: Status | |
446 | * | |
447 | * DESCRIPTION: Initializes the region, finds any _REG methods and saves them | |
448 | * for execution at a later time | |
449 | * | |
450 | * Get the appropriate address space handler for a newly | |
451 | * created region. | |
452 | * | |
9f15fc66 | 453 | * This also performs address space specific initialization. For |
1da177e4 | 454 | * example, PCI regions must have an _ADR object that contains |
9f15fc66 | 455 | * a PCI address in the scope of the definition. This address is |
1da177e4 LT |
456 | * required to perform an access to PCI config space. |
457 | * | |
c9e3ba2c BM |
458 | * MUTEX: Interpreter should be unlocked, because we may run the _REG |
459 | * method for this region. | |
460 | * | |
760235cd LZ |
461 | * NOTE: Possible incompliance: |
462 | * There is a behavior conflict in automatic _REG execution: | |
463 | * 1. When the interpreter is evaluating a method, we can only | |
464 | * automatically run _REG for the following case: | |
465 | * operation_region (OPR1, 0x80, 0x1000010, 0x4) | |
466 | * 2. When the interpreter is loading a table, we can also | |
467 | * automatically run _REG for the following case: | |
468 | * operation_region (OPR1, 0x80, 0x1000010, 0x4) | |
469 | * Though this may not be compliant to the de-facto standard, the | |
470 | * logic is kept in order not to trigger regressions. And keeping | |
471 | * this logic should be taken care by the caller of this function. | |
472 | * | |
1da177e4 LT |
473 | ******************************************************************************/ |
474 | ||
760235cd | 475 | acpi_status acpi_ev_initialize_region(union acpi_operand_object *region_obj) |
1da177e4 | 476 | { |
4be44fcd LB |
477 | union acpi_operand_object *handler_obj; |
478 | union acpi_operand_object *obj_desc; | |
479 | acpi_adr_space_type space_id; | |
480 | struct acpi_namespace_node *node; | |
1da177e4 | 481 | |
760235cd | 482 | ACPI_FUNCTION_TRACE(ev_initialize_region); |
1da177e4 LT |
483 | |
484 | if (!region_obj) { | |
4be44fcd | 485 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
1da177e4 LT |
486 | } |
487 | ||
488 | if (region_obj->common.flags & AOPOBJ_OBJECT_INITIALIZED) { | |
4be44fcd | 489 | return_ACPI_STATUS(AE_OK); |
1da177e4 LT |
490 | } |
491 | ||
849c2571 | 492 | region_obj->common.flags |= AOPOBJ_OBJECT_INITIALIZED; |
1da177e4 | 493 | |
c45b5c09 | 494 | node = region_obj->region.node->parent; |
1da177e4 LT |
495 | space_id = region_obj->region.space_id; |
496 | ||
1da177e4 LT |
497 | /* |
498 | * The following loop depends upon the root Node having no parent | |
7b738064 | 499 | * ie: acpi_gbl_root_node->Parent being set to NULL |
1da177e4 LT |
500 | */ |
501 | while (node) { | |
52fc0b02 | 502 | |
1da177e4 LT |
503 | /* Check to see if a handler exists */ |
504 | ||
505 | handler_obj = NULL; | |
4be44fcd | 506 | obj_desc = acpi_ns_get_attached_object(node); |
1da177e4 | 507 | if (obj_desc) { |
52fc0b02 | 508 | |
1da177e4 LT |
509 | /* Can only be a handler if the object exists */ |
510 | ||
511 | switch (node->type) { | |
512 | case ACPI_TYPE_DEVICE: | |
1da177e4 | 513 | case ACPI_TYPE_PROCESSOR: |
1da177e4 LT |
514 | case ACPI_TYPE_THERMAL: |
515 | ||
aa6abd2b | 516 | handler_obj = obj_desc->common_notify.handler; |
1da177e4 LT |
517 | break; |
518 | ||
e31c32cf LM |
519 | case ACPI_TYPE_METHOD: |
520 | /* | |
521 | * If we are executing module level code, the original | |
522 | * Node's object was replaced by this Method object and we | |
523 | * saved the handler in the method object. | |
524 | * | |
a406dea8 BM |
525 | * Note: Only used for the legacy MLC support. Will |
526 | * be removed in the future. | |
527 | * | |
e31c32cf LM |
528 | * See acpi_ns_exec_module_code |
529 | */ | |
e7d970f6 | 530 | if (!acpi_gbl_execute_tables_as_methods && |
de56ba95 | 531 | obj_desc->method. |
26294842 | 532 | info_flags & ACPI_METHOD_MODULE_LEVEL) { |
e31c32cf | 533 | handler_obj = |
26294842 | 534 | obj_desc->method.dispatch.handler; |
e31c32cf LM |
535 | } |
536 | break; | |
537 | ||
1da177e4 | 538 | default: |
1d1ea1b7 | 539 | |
1da177e4 | 540 | /* Ignore other objects */ |
1d1ea1b7 | 541 | |
1da177e4 LT |
542 | break; |
543 | } | |
544 | ||
f31a99ce LZ |
545 | handler_obj = |
546 | acpi_ev_find_region_handler(space_id, handler_obj); | |
547 | if (handler_obj) { | |
52fc0b02 | 548 | |
f31a99ce | 549 | /* Found correct handler */ |
1da177e4 | 550 | |
f31a99ce LZ |
551 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, |
552 | "Found handler %p for region %p in obj %p\n", | |
553 | handler_obj, region_obj, | |
554 | obj_desc)); | |
52fc0b02 | 555 | |
760235cd LZ |
556 | (void)acpi_ev_attach_region(handler_obj, |
557 | region_obj, FALSE); | |
1da177e4 | 558 | |
f31a99ce LZ |
559 | /* |
560 | * Tell all users that this region is usable by | |
561 | * running the _REG method | |
562 | */ | |
8633db6b | 563 | acpi_ex_exit_interpreter(); |
760235cd LZ |
564 | (void)acpi_ev_execute_reg_method(region_obj, |
565 | ACPI_REG_CONNECT); | |
8633db6b | 566 | acpi_ex_enter_interpreter(); |
f31a99ce | 567 | return_ACPI_STATUS(AE_OK); |
1da177e4 LT |
568 | } |
569 | } | |
570 | ||
9f15fc66 BM |
571 | /* This node does not have the handler we need; Pop up one level */ |
572 | ||
c45b5c09 | 573 | node = node->parent; |
1da177e4 LT |
574 | } |
575 | ||
760235cd LZ |
576 | /* |
577 | * If we get here, there is no handler for this region. This is not | |
578 | * fatal because many regions get created before a handler is installed | |
579 | * for said region. | |
580 | */ | |
4be44fcd | 581 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, |
b229cf92 | 582 | "No handler for RegionType %s(%X) (RegionObj %p)\n", |
4be44fcd LB |
583 | acpi_ut_get_region_name(space_id), space_id, |
584 | region_obj)); | |
1da177e4 | 585 | |
760235cd | 586 | return_ACPI_STATUS(AE_OK); |
1da177e4 | 587 | } |