1 /******************************************************************************
3 * Module Name: evregion - ACPI address_space (op_region) handler dispatch
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2006, R. Byron Moore
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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.
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.
44 #include <acpi/acpi.h>
45 #include <acpi/acevents.h>
46 #include <acpi/acnamesp.h>
47 #include <acpi/acinterp.h>
49 #define _COMPONENT ACPI_EVENTS
50 ACPI_MODULE_NAME("evregion")
51 #define ACPI_NUM_DEFAULT_SPACES 4
52 static u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = {
53 ACPI_ADR_SPACE_SYSTEM_MEMORY,
54 ACPI_ADR_SPACE_SYSTEM_IO,
55 ACPI_ADR_SPACE_PCI_CONFIG,
56 ACPI_ADR_SPACE_DATA_TABLE
59 /* Local prototypes */
62 acpi_ev_reg_run(acpi_handle obj_handle,
63 u32 level, void *context, void **return_value);
66 acpi_ev_install_handler(acpi_handle obj_handle,
67 u32 level, void *context, void **return_value);
69 /*******************************************************************************
71 * FUNCTION: acpi_ev_install_region_handlers
77 * DESCRIPTION: Installs the core subsystem default address space handlers.
79 ******************************************************************************/
81 acpi_status acpi_ev_install_region_handlers(void)
86 ACPI_FUNCTION_TRACE(ev_install_region_handlers);
88 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
89 if (ACPI_FAILURE(status)) {
90 return_ACPI_STATUS(status);
94 * All address spaces (PCI Config, EC, SMBus) are scope dependent
95 * and registration must occur for a specific device.
97 * In the case of the system memory and IO address spaces there is currently
98 * no device associated with the address space. For these we use the root.
100 * We install the default PCI config space handler at the root so
101 * that this space is immediately available even though the we have
102 * not enumerated all the PCI Root Buses yet. This is to conform
103 * to the ACPI specification which states that the PCI config
104 * space must be always available -- even though we are nowhere
105 * near ready to find the PCI root buses at this point.
107 * NOTE: We ignore AE_ALREADY_EXISTS because this means that a handler
108 * has already been installed (via acpi_install_address_space_handler).
109 * Similar for AE_SAME_HANDLER.
111 for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) {
112 status = acpi_ev_install_space_handler(acpi_gbl_root_node,
113 acpi_gbl_default_address_spaces
115 ACPI_DEFAULT_HANDLER,
119 case AE_SAME_HANDLER:
120 case AE_ALREADY_EXISTS:
122 /* These exceptions are all OK */
129 goto unlock_and_exit;
134 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
135 return_ACPI_STATUS(status);
138 /*******************************************************************************
140 * FUNCTION: acpi_ev_initialize_op_regions
146 * DESCRIPTION: Execute _REG methods for all Operation Regions that have
147 * an installed default region handler.
149 ******************************************************************************/
151 acpi_status acpi_ev_initialize_op_regions(void)
156 ACPI_FUNCTION_TRACE(ev_initialize_op_regions);
158 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
159 if (ACPI_FAILURE(status)) {
160 return_ACPI_STATUS(status);
164 * Run the _REG methods for op_regions in each default address space
166 for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) {
168 /* TBD: Make sure handler is the DEFAULT handler, otherwise
169 * _REG will have already been run.
171 status = acpi_ev_execute_reg_methods(acpi_gbl_root_node,
172 acpi_gbl_default_address_spaces
176 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
177 return_ACPI_STATUS(status);
180 /*******************************************************************************
182 * FUNCTION: acpi_ev_execute_reg_method
184 * PARAMETERS: region_obj - Region object
185 * Function - Passed to _REG: On (1) or Off (0)
189 * DESCRIPTION: Execute _REG method for a region
191 ******************************************************************************/
194 acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function)
196 struct acpi_parameter_info info;
197 union acpi_operand_object *params[3];
198 union acpi_operand_object *region_obj2;
201 ACPI_FUNCTION_TRACE(ev_execute_reg_method);
203 region_obj2 = acpi_ns_get_secondary_object(region_obj);
205 return_ACPI_STATUS(AE_NOT_EXIST);
208 if (region_obj2->extra.method_REG == NULL) {
209 return_ACPI_STATUS(AE_OK);
213 * The _REG method has two arguments:
215 * Arg0, Integer: Operation region space ID
216 * Same value as region_obj->Region.space_id
217 * Arg1, Integer: connection status
218 * 1 for connecting the handler,
219 * 0 for disconnecting the handler
220 * Passed as a parameter
222 params[0] = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
224 return_ACPI_STATUS(AE_NO_MEMORY);
227 params[1] = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
229 status = AE_NO_MEMORY;
233 /* Setup the parameter objects */
235 params[0]->integer.value = region_obj->region.space_id;
236 params[1]->integer.value = function;
239 info.node = region_obj2->extra.method_REG;
240 info.parameters = params;
241 info.parameter_type = ACPI_PARAM_ARGS;
243 /* Execute the method, no return value */
245 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
246 (ACPI_TYPE_METHOD, info.node, NULL));
247 status = acpi_ns_evaluate_by_handle(&info);
249 acpi_ut_remove_reference(params[1]);
252 acpi_ut_remove_reference(params[0]);
253 return_ACPI_STATUS(status);
256 /*******************************************************************************
258 * FUNCTION: acpi_ev_address_space_dispatch
260 * PARAMETERS: region_obj - Internal region object
261 * Function - Read or Write operation
262 * Address - Where in the space to read or write
263 * bit_width - Field width in bits (8, 16, 32, or 64)
264 * Value - Pointer to in or out value, must be
265 * full 64-bit acpi_integer
269 * DESCRIPTION: Dispatch an address space or operation region access to
270 * a previously installed handler.
272 ******************************************************************************/
275 acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
277 acpi_physical_address address,
278 u32 bit_width, acpi_integer * value)
282 acpi_adr_space_handler handler;
283 acpi_adr_space_setup region_setup;
284 union acpi_operand_object *handler_desc;
285 union acpi_operand_object *region_obj2;
286 void *region_context = NULL;
288 ACPI_FUNCTION_TRACE(ev_address_space_dispatch);
290 region_obj2 = acpi_ns_get_secondary_object(region_obj);
292 return_ACPI_STATUS(AE_NOT_EXIST);
295 /* Ensure that there is a handler associated with this region */
297 handler_desc = region_obj->region.handler;
300 "No handler for Region [%4.4s] (%p) [%s]",
301 acpi_ut_get_node_name(region_obj->region.node),
303 acpi_ut_get_region_name(region_obj->region.
306 return_ACPI_STATUS(AE_NOT_EXIST);
310 * It may be the case that the region has never been initialized
311 * Some types of regions require special init code
313 if (!(region_obj->region.flags & AOPOBJ_SETUP_COMPLETE)) {
315 * This region has not been initialized yet, do it
317 region_setup = handler_desc->address_space.setup;
320 /* No initialization routine, exit with error */
323 "No init routine for region(%p) [%s]",
325 acpi_ut_get_region_name(region_obj->region.
327 return_ACPI_STATUS(AE_NOT_EXIST);
331 * We must exit the interpreter because the region
332 * setup will potentially execute control methods
333 * (e.g., _REG method for this region)
335 acpi_ex_exit_interpreter();
337 status = region_setup(region_obj, ACPI_REGION_ACTIVATE,
338 handler_desc->address_space.context,
341 /* Re-enter the interpreter */
343 status2 = acpi_ex_enter_interpreter();
344 if (ACPI_FAILURE(status2)) {
345 return_ACPI_STATUS(status2);
348 /* Check for failure of the Region Setup */
350 if (ACPI_FAILURE(status)) {
351 ACPI_EXCEPTION((AE_INFO, status,
352 "During region initialization: [%s]",
353 acpi_ut_get_region_name(region_obj->
356 return_ACPI_STATUS(status);
360 * Region initialization may have been completed by region_setup
362 if (!(region_obj->region.flags & AOPOBJ_SETUP_COMPLETE)) {
363 region_obj->region.flags |= AOPOBJ_SETUP_COMPLETE;
365 if (region_obj2->extra.region_context) {
367 /* The handler for this region was already installed */
369 ACPI_FREE(region_context);
372 * Save the returned context for use in all accesses to
373 * this particular region
375 region_obj2->extra.region_context =
381 /* We have everything we need, we can invoke the address space handler */
383 handler = handler_desc->address_space.handler;
385 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
386 "Handler %p (@%p) Address %8.8X%8.8X [%s]\n",
387 ®ion_obj->region.handler->address_space, handler,
388 ACPI_FORMAT_UINT64(address),
389 acpi_ut_get_region_name(region_obj->region.
392 if (!(handler_desc->address_space.handler_flags &
393 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) {
395 * For handlers other than the default (supplied) handlers, we must
396 * exit the interpreter because the handler *might* block -- we don't
397 * know what it will do, so we can't hold the lock on the intepreter.
399 acpi_ex_exit_interpreter();
402 /* Call the handler */
404 status = handler(function, address, bit_width, value,
405 handler_desc->address_space.context,
406 region_obj2->extra.region_context);
408 if (ACPI_FAILURE(status)) {
409 ACPI_EXCEPTION((AE_INFO, status, "Returned by Handler for [%s]",
410 acpi_ut_get_region_name(region_obj->region.
414 if (!(handler_desc->address_space.handler_flags &
415 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) {
417 * We just returned from a non-default handler, we must re-enter the
420 status2 = acpi_ex_enter_interpreter();
421 if (ACPI_FAILURE(status2)) {
422 return_ACPI_STATUS(status2);
426 return_ACPI_STATUS(status);
429 /*******************************************************************************
431 * FUNCTION: acpi_ev_detach_region
433 * PARAMETERS: region_obj - Region Object
434 * acpi_ns_is_locked - Namespace Region Already Locked?
438 * DESCRIPTION: Break the association between the handler and the region
439 * this is a two way association.
441 ******************************************************************************/
444 acpi_ev_detach_region(union acpi_operand_object *region_obj,
445 u8 acpi_ns_is_locked)
447 union acpi_operand_object *handler_obj;
448 union acpi_operand_object *obj_desc;
449 union acpi_operand_object **last_obj_ptr;
450 acpi_adr_space_setup region_setup;
451 void **region_context;
452 union acpi_operand_object *region_obj2;
455 ACPI_FUNCTION_TRACE(ev_detach_region);
457 region_obj2 = acpi_ns_get_secondary_object(region_obj);
461 region_context = ®ion_obj2->extra.region_context;
463 /* Get the address handler from the region object */
465 handler_obj = region_obj->region.handler;
468 /* This region has no handler, all done */
473 /* Find this region in the handler's list */
475 obj_desc = handler_obj->address_space.region_list;
476 last_obj_ptr = &handler_obj->address_space.region_list;
480 /* Is this the correct Region? */
482 if (obj_desc == region_obj) {
483 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
484 "Removing Region %p from address handler %p\n",
485 region_obj, handler_obj));
487 /* This is it, remove it from the handler's list */
489 *last_obj_ptr = obj_desc->region.next;
490 obj_desc->region.next = NULL; /* Must clear field */
492 if (acpi_ns_is_locked) {
494 acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
495 if (ACPI_FAILURE(status)) {
500 /* Now stop region accesses by executing the _REG method */
502 status = acpi_ev_execute_reg_method(region_obj, 0);
503 if (ACPI_FAILURE(status)) {
504 ACPI_EXCEPTION((AE_INFO, status,
505 "from region _REG, [%s]",
506 acpi_ut_get_region_name
507 (region_obj->region.space_id)));
510 if (acpi_ns_is_locked) {
512 acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
513 if (ACPI_FAILURE(status)) {
518 /* Call the setup handler with the deactivate notification */
520 region_setup = handler_obj->address_space.setup;
522 region_setup(region_obj, ACPI_REGION_DEACTIVATE,
523 handler_obj->address_space.context,
526 /* Init routine may fail, Just ignore errors */
528 if (ACPI_FAILURE(status)) {
529 ACPI_EXCEPTION((AE_INFO, status,
530 "from region init, [%s]",
531 acpi_ut_get_region_name
532 (region_obj->region.space_id)));
535 region_obj->region.flags &= ~(AOPOBJ_SETUP_COMPLETE);
538 * Remove handler reference in the region
540 * NOTE: this doesn't mean that the region goes away
541 * The region is just inaccessible as indicated to
544 * If the region is on the handler's list
545 * this better be the region's handler
547 region_obj->region.handler = NULL;
548 acpi_ut_remove_reference(handler_obj);
553 /* Walk the linked list of handlers */
555 last_obj_ptr = &obj_desc->region.next;
556 obj_desc = obj_desc->region.next;
559 /* If we get here, the region was not in the handler's region list */
561 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
562 "Cannot remove region %p from address handler %p\n",
563 region_obj, handler_obj));
568 /*******************************************************************************
570 * FUNCTION: acpi_ev_attach_region
572 * PARAMETERS: handler_obj - Handler Object
573 * region_obj - Region Object
574 * acpi_ns_is_locked - Namespace Region Already Locked?
578 * DESCRIPTION: Create the association between the handler and the region
579 * this is a two way association.
581 ******************************************************************************/
584 acpi_ev_attach_region(union acpi_operand_object *handler_obj,
585 union acpi_operand_object *region_obj,
586 u8 acpi_ns_is_locked)
589 ACPI_FUNCTION_TRACE(ev_attach_region);
591 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
592 "Adding Region [%4.4s] %p to address handler %p [%s]\n",
593 acpi_ut_get_node_name(region_obj->region.node),
594 region_obj, handler_obj,
595 acpi_ut_get_region_name(region_obj->region.
598 /* Link this region to the front of the handler's list */
600 region_obj->region.next = handler_obj->address_space.region_list;
601 handler_obj->address_space.region_list = region_obj;
603 /* Install the region's handler */
605 if (region_obj->region.handler) {
606 return_ACPI_STATUS(AE_ALREADY_EXISTS);
609 region_obj->region.handler = handler_obj;
610 acpi_ut_add_reference(handler_obj);
612 return_ACPI_STATUS(AE_OK);
615 /*******************************************************************************
617 * FUNCTION: acpi_ev_install_handler
619 * PARAMETERS: walk_namespace callback
621 * DESCRIPTION: This routine installs an address handler into objects that are
622 * of type Region or Device.
624 * If the Object is a Device, and the device has a handler of
625 * the same type then the search is terminated in that branch.
627 * This is because the existing handler is closer in proximity
628 * to any more regions than the one we are trying to install.
630 ******************************************************************************/
633 acpi_ev_install_handler(acpi_handle obj_handle,
634 u32 level, void *context, void **return_value)
636 union acpi_operand_object *handler_obj;
637 union acpi_operand_object *next_handler_obj;
638 union acpi_operand_object *obj_desc;
639 struct acpi_namespace_node *node;
642 ACPI_FUNCTION_NAME(ev_install_handler);
644 handler_obj = (union acpi_operand_object *)context;
646 /* Parameter validation */
652 /* Convert and validate the device handle */
654 node = acpi_ns_map_handle_to_node(obj_handle);
656 return (AE_BAD_PARAMETER);
660 * We only care about regions.and objects
661 * that are allowed to have address space handlers
663 if ((node->type != ACPI_TYPE_DEVICE) &&
664 (node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) {
668 /* Check for an existing internal object */
670 obj_desc = acpi_ns_get_attached_object(node);
673 /* No object, just exit */
678 /* Devices are handled different than regions */
680 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_DEVICE) {
682 /* Check if this Device already has a handler for this address space */
684 next_handler_obj = obj_desc->device.handler;
685 while (next_handler_obj) {
687 /* Found a handler, is it for the same address space? */
689 if (next_handler_obj->address_space.space_id ==
690 handler_obj->address_space.space_id) {
691 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
692 "Found handler for region [%s] in device %p(%p) handler %p\n",
693 acpi_ut_get_region_name
694 (handler_obj->address_space.
700 * Since the object we found it on was a device, then it
701 * means that someone has already installed a handler for
702 * the branch of the namespace from this device on. Just
703 * bail out telling the walk routine to not traverse this
704 * branch. This preserves the scoping rule for handlers.
706 return (AE_CTRL_DEPTH);
709 /* Walk the linked list of handlers attached to this device */
711 next_handler_obj = next_handler_obj->address_space.next;
715 * As long as the device didn't have a handler for this
716 * space we don't care about it. We just ignore it and
722 /* Object is a Region */
724 if (obj_desc->region.space_id != handler_obj->address_space.space_id) {
726 * This region is for a different address space
733 * Now we have a region and it is for the handler's address
736 * First disconnect region for any previous handler (if any)
738 acpi_ev_detach_region(obj_desc, FALSE);
740 /* Connect the region to the new handler */
742 status = acpi_ev_attach_region(handler_obj, obj_desc, FALSE);
746 /*******************************************************************************
748 * FUNCTION: acpi_ev_install_space_handler
750 * PARAMETERS: Node - Namespace node for the device
751 * space_id - The address space ID
752 * Handler - Address of the handler
753 * Setup - Address of the setup function
754 * Context - Value passed to the handler on each access
758 * DESCRIPTION: Install a handler for all op_regions of a given space_id.
759 * Assumes namespace is locked
761 ******************************************************************************/
764 acpi_ev_install_space_handler(struct acpi_namespace_node * node,
765 acpi_adr_space_type space_id,
766 acpi_adr_space_handler handler,
767 acpi_adr_space_setup setup, void *context)
769 union acpi_operand_object *obj_desc;
770 union acpi_operand_object *handler_obj;
772 acpi_object_type type;
775 ACPI_FUNCTION_TRACE(ev_install_space_handler);
778 * This registration is valid for only the types below
779 * and the root. This is where the default handlers
782 if ((node->type != ACPI_TYPE_DEVICE) &&
783 (node->type != ACPI_TYPE_PROCESSOR) &&
784 (node->type != ACPI_TYPE_THERMAL) && (node != acpi_gbl_root_node)) {
785 status = AE_BAD_PARAMETER;
786 goto unlock_and_exit;
789 if (handler == ACPI_DEFAULT_HANDLER) {
790 flags = ACPI_ADDR_HANDLER_DEFAULT_INSTALLED;
793 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
794 handler = acpi_ex_system_memory_space_handler;
795 setup = acpi_ev_system_memory_region_setup;
798 case ACPI_ADR_SPACE_SYSTEM_IO:
799 handler = acpi_ex_system_io_space_handler;
800 setup = acpi_ev_io_space_region_setup;
803 case ACPI_ADR_SPACE_PCI_CONFIG:
804 handler = acpi_ex_pci_config_space_handler;
805 setup = acpi_ev_pci_config_region_setup;
808 case ACPI_ADR_SPACE_CMOS:
809 handler = acpi_ex_cmos_space_handler;
810 setup = acpi_ev_cmos_region_setup;
813 case ACPI_ADR_SPACE_PCI_BAR_TARGET:
814 handler = acpi_ex_pci_bar_space_handler;
815 setup = acpi_ev_pci_bar_region_setup;
818 case ACPI_ADR_SPACE_DATA_TABLE:
819 handler = acpi_ex_data_table_space_handler;
824 status = AE_BAD_PARAMETER;
825 goto unlock_and_exit;
829 /* If the caller hasn't specified a setup routine, use the default */
832 setup = acpi_ev_default_region_setup;
835 /* Check for an existing internal object */
837 obj_desc = acpi_ns_get_attached_object(node);
840 * The attached device object already exists.
841 * Make sure the handler is not already installed.
843 handler_obj = obj_desc->device.handler;
845 /* Walk the handler list for this device */
847 while (handler_obj) {
849 /* Same space_id indicates a handler already installed */
851 if (handler_obj->address_space.space_id == space_id) {
852 if (handler_obj->address_space.handler ==
855 * It is (relatively) OK to attempt to install the SAME
856 * handler twice. This can easily happen
857 * with PCI_Config space.
859 status = AE_SAME_HANDLER;
860 goto unlock_and_exit;
862 /* A handler is already installed */
864 status = AE_ALREADY_EXISTS;
866 goto unlock_and_exit;
869 /* Walk the linked list of handlers */
871 handler_obj = handler_obj->address_space.next;
874 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
875 "Creating object on Device %p while installing handler\n",
878 /* obj_desc does not exist, create one */
880 if (node->type == ACPI_TYPE_ANY) {
881 type = ACPI_TYPE_DEVICE;
886 obj_desc = acpi_ut_create_internal_object(type);
888 status = AE_NO_MEMORY;
889 goto unlock_and_exit;
892 /* Init new descriptor */
894 obj_desc->common.type = (u8) type;
896 /* Attach the new object to the Node */
898 status = acpi_ns_attach_object(node, obj_desc, type);
900 /* Remove local reference to the object */
902 acpi_ut_remove_reference(obj_desc);
904 if (ACPI_FAILURE(status)) {
905 goto unlock_and_exit;
909 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
910 "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n",
911 acpi_ut_get_region_name(space_id), space_id,
912 acpi_ut_get_node_name(node), node, obj_desc));
915 * Install the handler
917 * At this point there is no existing handler.
918 * Just allocate the object for the handler and link it
922 acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_ADDRESS_HANDLER);
924 status = AE_NO_MEMORY;
925 goto unlock_and_exit;
928 /* Init handler obj */
930 handler_obj->address_space.space_id = (u8) space_id;
931 handler_obj->address_space.handler_flags = flags;
932 handler_obj->address_space.region_list = NULL;
933 handler_obj->address_space.node = node;
934 handler_obj->address_space.handler = handler;
935 handler_obj->address_space.context = context;
936 handler_obj->address_space.setup = setup;
938 /* Install at head of Device.address_space list */
940 handler_obj->address_space.next = obj_desc->device.handler;
943 * The Device object is the first reference on the handler_obj.
944 * Each region that uses the handler adds a reference.
946 obj_desc->device.handler = handler_obj;
949 * Walk the namespace finding all of the regions this
950 * handler will manage.
952 * Start at the device and search the branch toward
953 * the leaf nodes until either the leaf is encountered or
954 * a device is detected that has an address handler of the
957 * In either case, back up and search down the remainder
960 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX,
962 acpi_ev_install_handler, handler_obj,
966 return_ACPI_STATUS(status);
969 /*******************************************************************************
971 * FUNCTION: acpi_ev_execute_reg_methods
973 * PARAMETERS: Node - Namespace node for the device
974 * space_id - The address space ID
978 * DESCRIPTION: Run all _REG methods for the input Space ID;
979 * Note: assumes namespace is locked, or system init time.
981 ******************************************************************************/
984 acpi_ev_execute_reg_methods(struct acpi_namespace_node *node,
985 acpi_adr_space_type space_id)
989 ACPI_FUNCTION_TRACE(ev_execute_reg_methods);
992 * Run all _REG methods for all Operation Regions for this
993 * space ID. This is a separate walk in order to handle any
994 * interdependencies between regions and _REG methods. (i.e. handlers
995 * must be installed for all regions of this Space ID before we
996 * can run any _REG methods)
998 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX,
999 ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run,
1002 return_ACPI_STATUS(status);
1005 /*******************************************************************************
1007 * FUNCTION: acpi_ev_reg_run
1009 * PARAMETERS: walk_namespace callback
1011 * DESCRIPTION: Run _REG method for region objects of the requested space_iD
1013 ******************************************************************************/
1016 acpi_ev_reg_run(acpi_handle obj_handle,
1017 u32 level, void *context, void **return_value)
1019 union acpi_operand_object *obj_desc;
1020 struct acpi_namespace_node *node;
1021 acpi_adr_space_type space_id;
1024 space_id = *ACPI_CAST_PTR(acpi_adr_space_type, context);
1026 /* Convert and validate the device handle */
1028 node = acpi_ns_map_handle_to_node(obj_handle);
1030 return (AE_BAD_PARAMETER);
1034 * We only care about regions.and objects
1035 * that are allowed to have address space handlers
1037 if ((node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) {
1041 /* Check for an existing internal object */
1043 obj_desc = acpi_ns_get_attached_object(node);
1046 /* No object, just exit */
1051 /* Object is a Region */
1053 if (obj_desc->region.space_id != space_id) {
1055 * This region is for a different address space
1061 status = acpi_ev_execute_reg_method(obj_desc, 1);