/******************************************************************************1*2* Module Name: dsinit - Object initialization namespace walk3*4*****************************************************************************/56/*7* Copyright (C) 2000 - 2011, Intel Corp.8* All rights reserved.9*10* Redistribution and use in source and binary forms, with or without11* modification, are permitted provided that the following conditions12* are met:13* 1. Redistributions of source code must retain the above copyright14* notice, this list of conditions, and the following disclaimer,15* without modification.16* 2. Redistributions in binary form must reproduce at minimum a disclaimer17* substantially similar to the "NO WARRANTY" disclaimer below18* ("Disclaimer") and any redistribution must be conditioned upon19* including a substantially similar Disclaimer requirement for further20* binary redistribution.21* 3. Neither the names of the above-listed copyright holders nor the names22* of any contributors may be used to endorse or promote products derived23* from this software without specific prior written permission.24*25* Alternatively, this software may be distributed under the terms of the26* GNU General Public License ("GPL") version 2 as published by the Free27* Software Foundation.28*29* NO WARRANTY30* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS31* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT32* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR33* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT34* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL35* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS36* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)37* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,38* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING39* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE40* POSSIBILITY OF SUCH DAMAGES.41*/4243#include <acpi/acpi.h>44#include "accommon.h"45#include "acdispat.h"46#include "acnamesp.h"47#include "actables.h"4849#define _COMPONENT ACPI_DISPATCHER50ACPI_MODULE_NAME("dsinit")5152/* Local prototypes */53static acpi_status54acpi_ds_init_one_object(acpi_handle obj_handle,55u32 level, void *context, void **return_value);5657/*******************************************************************************58*59* FUNCTION: acpi_ds_init_one_object60*61* PARAMETERS: obj_handle - Node for the object62* Level - Current nesting level63* Context - Points to a init info struct64* return_value - Not used65*66* RETURN: Status67*68* DESCRIPTION: Callback from acpi_walk_namespace. Invoked for every object69* within the namespace.70*71* Currently, the only objects that require initialization are:72* 1) Methods73* 2) Operation Regions74*75******************************************************************************/7677static acpi_status78acpi_ds_init_one_object(acpi_handle obj_handle,79u32 level, void *context, void **return_value)80{81struct acpi_init_walk_info *info =82(struct acpi_init_walk_info *)context;83struct acpi_namespace_node *node =84(struct acpi_namespace_node *)obj_handle;85acpi_object_type type;86acpi_status status;8788ACPI_FUNCTION_ENTRY();8990/*91* We are only interested in NS nodes owned by the table that92* was just loaded93*/94if (node->owner_id != info->owner_id) {95return (AE_OK);96}9798info->object_count++;99100/* And even then, we are only interested in a few object types */101102type = acpi_ns_get_type(obj_handle);103104switch (type) {105case ACPI_TYPE_REGION:106107status = acpi_ds_initialize_region(obj_handle);108if (ACPI_FAILURE(status)) {109ACPI_EXCEPTION((AE_INFO, status,110"During Region initialization %p [%4.4s]",111obj_handle,112acpi_ut_get_node_name(obj_handle)));113}114115info->op_region_count++;116break;117118case ACPI_TYPE_METHOD:119120info->method_count++;121break;122123case ACPI_TYPE_DEVICE:124125info->device_count++;126break;127128default:129break;130}131132/*133* We ignore errors from above, and always return OK, since134* we don't want to abort the walk on a single error.135*/136return (AE_OK);137}138139/*******************************************************************************140*141* FUNCTION: acpi_ds_initialize_objects142*143* PARAMETERS: table_desc - Descriptor for parent ACPI table144* start_node - Root of subtree to be initialized.145*146* RETURN: Status147*148* DESCRIPTION: Walk the namespace starting at "StartNode" and perform any149* necessary initialization on the objects found therein150*151******************************************************************************/152153acpi_status154acpi_ds_initialize_objects(u32 table_index,155struct acpi_namespace_node * start_node)156{157acpi_status status;158struct acpi_init_walk_info info;159struct acpi_table_header *table;160acpi_owner_id owner_id;161162ACPI_FUNCTION_TRACE(ds_initialize_objects);163164status = acpi_tb_get_owner_id(table_index, &owner_id);165if (ACPI_FAILURE(status)) {166return_ACPI_STATUS(status);167}168169ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,170"**** Starting initialization of namespace objects ****\n"));171ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "Parsing all Control Methods:"));172173/* Set all init info to zero */174175ACPI_MEMSET(&info, 0, sizeof(struct acpi_init_walk_info));176177info.owner_id = owner_id;178info.table_index = table_index;179180/* Walk entire namespace from the supplied root */181182status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);183if (ACPI_FAILURE(status)) {184return_ACPI_STATUS(status);185}186187/*188* We don't use acpi_walk_namespace since we do not want to acquire189* the namespace reader lock.190*/191status =192acpi_ns_walk_namespace(ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX,193ACPI_NS_WALK_UNLOCK, acpi_ds_init_one_object,194NULL, &info, NULL);195if (ACPI_FAILURE(status)) {196ACPI_EXCEPTION((AE_INFO, status, "During WalkNamespace"));197}198(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);199200status = acpi_get_table_by_index(table_index, &table);201if (ACPI_FAILURE(status)) {202return_ACPI_STATUS(status);203}204205ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,206"\nTable [%4.4s](id %4.4X) - %u Objects with %u Devices %u Methods %u Regions\n",207table->signature, owner_id, info.object_count,208info.device_count, info.method_count,209info.op_region_count));210211ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,212"%u Methods, %u Regions\n", info.method_count,213info.op_region_count));214215return_ACPI_STATUS(AE_OK);216}217218219