2005-04-16 15:20:36 -07:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Module Name: nsparse - namespace interface to AML parser
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
2006-01-13 14:22:00 -07:00
|
|
|
* Copyright (C) 2000 - 2006, R. Byron Moore
|
2005-04-16 15:20:36 -07:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions, and the following disclaimer,
|
|
|
|
* without modification.
|
|
|
|
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
|
|
|
|
* substantially similar to the "NO WARRANTY" disclaimer below
|
|
|
|
* ("Disclaimer") and any redistribution must be conditioned upon
|
|
|
|
* including a substantially similar Disclaimer requirement for further
|
|
|
|
* binary redistribution.
|
|
|
|
* 3. Neither the names of the above-listed copyright holders nor the names
|
|
|
|
* of any contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* Alternatively, this software may be distributed under the terms of the
|
|
|
|
* GNU General Public License ("GPL") version 2 as published by the Free
|
|
|
|
* Software Foundation.
|
|
|
|
*
|
|
|
|
* NO WARRANTY
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
|
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGES.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <acpi/acpi.h>
|
|
|
|
#include <acpi/acnamesp.h>
|
|
|
|
#include <acpi/acparser.h>
|
|
|
|
#include <acpi/acdispat.h>
|
|
|
|
|
|
|
|
#define _COMPONENT ACPI_NAMESPACE
|
2005-08-04 21:44:28 -07:00
|
|
|
ACPI_MODULE_NAME("nsparse")
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: ns_one_complete_parse
|
|
|
|
*
|
|
|
|
* PARAMETERS: pass_number - 1 or 2
|
|
|
|
* table_desc - The table to be parsed.
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Perform one complete parse of an ACPI/AML table.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
acpi_status
|
2006-10-02 21:00:00 -07:00
|
|
|
acpi_ns_one_complete_parse(u8 pass_number, struct acpi_table_desc *table_desc)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2005-08-04 21:44:28 -07:00
|
|
|
union acpi_parse_object *parse_root;
|
|
|
|
acpi_status status;
|
|
|
|
struct acpi_walk_state *walk_state;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2005-08-04 21:44:28 -07:00
|
|
|
ACPI_FUNCTION_TRACE("ns_one_complete_parse");
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/* Create and init a Root Node */
|
|
|
|
|
2005-08-04 21:44:28 -07:00
|
|
|
parse_root = acpi_ps_create_scope_op();
|
2005-04-16 15:20:36 -07:00
|
|
|
if (!parse_root) {
|
2005-08-04 21:44:28 -07:00
|
|
|
return_ACPI_STATUS(AE_NO_MEMORY);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Create and initialize a new walk state */
|
|
|
|
|
2005-08-04 21:44:28 -07:00
|
|
|
walk_state = acpi_ds_create_walk_state(table_desc->owner_id,
|
|
|
|
NULL, NULL, NULL);
|
2005-04-16 15:20:36 -07:00
|
|
|
if (!walk_state) {
|
2005-08-04 21:44:28 -07:00
|
|
|
acpi_ps_free_op(parse_root);
|
|
|
|
return_ACPI_STATUS(AE_NO_MEMORY);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2005-08-04 21:44:28 -07:00
|
|
|
status = acpi_ds_init_aml_walk(walk_state, parse_root, NULL,
|
|
|
|
table_desc->aml_start,
|
|
|
|
table_desc->aml_length, NULL,
|
|
|
|
pass_number);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
acpi_ds_delete_walk_state(walk_state);
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Parse the AML */
|
|
|
|
|
2005-08-04 21:44:28 -07:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "*PARSE* pass %d parse\n",
|
|
|
|
pass_number));
|
|
|
|
status = acpi_ps_parse_aml(walk_state);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2005-08-04 21:44:28 -07:00
|
|
|
acpi_ps_delete_parse_tree(parse_root);
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ns_parse_table
|
|
|
|
*
|
|
|
|
* PARAMETERS: table_desc - An ACPI table descriptor for table to parse
|
|
|
|
* start_node - Where to enter the table into the namespace
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Parse AML within an ACPI table and return a tree of ops
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-04 21:44:28 -07:00
|
|
|
acpi_ns_parse_table(struct acpi_table_desc *table_desc,
|
|
|
|
struct acpi_namespace_node *start_node)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2005-08-04 21:44:28 -07:00
|
|
|
acpi_status status;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2005-08-04 21:44:28 -07:00
|
|
|
ACPI_FUNCTION_TRACE("ns_parse_table");
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* AML Parse, pass 1
|
|
|
|
*
|
|
|
|
* In this pass, we load most of the namespace. Control methods
|
|
|
|
* are not parsed until later. A parse tree is not created. Instead,
|
|
|
|
* each Parser Op subtree is deleted when it is finished. This saves
|
|
|
|
* a great deal of memory, and allows a small cache of parse objects
|
|
|
|
* to service the entire parse. The second pass of the parse then
|
|
|
|
* performs another complete parse of the AML..
|
|
|
|
*/
|
2005-08-04 21:44:28 -07:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Start pass 1\n"));
|
|
|
|
status = acpi_ns_one_complete_parse(1, table_desc);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* AML Parse, pass 2
|
|
|
|
*
|
|
|
|
* In this pass, we resolve forward references and other things
|
|
|
|
* that could not be completed during the first pass.
|
|
|
|
* Another complete parse of the AML is performed, but the
|
|
|
|
* overhead of this is compensated for by the fact that the
|
|
|
|
* parse objects are all cached.
|
|
|
|
*/
|
2005-08-04 21:44:28 -07:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Start pass 2\n"));
|
|
|
|
status = acpi_ns_one_complete_parse(2, table_desc);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2005-08-04 21:44:28 -07:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|