From: Andy P. <at...@us...> - 2002-04-09 14:08:14
|
Update of /cvsroot/linux-vax/kernel-2.4/drivers/acpi/dispatcher In directory usw-pr-cvs1:/tmp/cvs-serv13840/acpi/dispatcher Modified Files: Makefile dsfield.c dsmethod.c dsmthdat.c dsobject.c dsopcode.c dsutils.c dswexec.c dswload.c dswscope.c dswstate.c Log Message: synch 2.4.15 commit 17 Index: Makefile =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/drivers/acpi/dispatcher/Makefile,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- Makefile 14 Jan 2001 19:15:24 -0000 1.1.1.1 +++ Makefile 9 Apr 2002 14:05:42 -0000 1.2 @@ -1,16 +1,12 @@ # # Makefile for all Linux ACPI interpreter subdirectories +# EXCEPT for the ospm directory # -O_TARGET := ../$(shell basename `pwd`).o +O_TARGET := $(notdir $(CURDIR)).o obj-$(CONFIG_ACPI) := $(patsubst %.c,%.o,$(wildcard *.c)) -EXTRA_CFLAGS += -I../include - EXTRA_CFLAGS += $(ACPI_CFLAGS) include $(TOPDIR)/Rules.make - -clean: - $(RM) *.o Index: dsfield.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/drivers/acpi/dispatcher/dsfield.c,v retrieving revision 1.1.1.2 retrieving revision 1.2 diff -u -r1.1.1.2 -r1.2 --- dsfield.c 25 Feb 2001 23:15:15 -0000 1.1.1.2 +++ dsfield.c 9 Apr 2002 14:05:42 -0000 1.2 @@ -29,264 +29,359 @@ #include "acdispat.h" #include "acinterp.h" #include "acnamesp.h" +#include "acparser.h" -#define _COMPONENT DISPATCHER +#define _COMPONENT ACPI_DISPATCHER MODULE_NAME ("dsfield") -/* - * Field flags: Bits 00 - 03 : Access_type (Any_acc, Byte_acc, etc.) - * 04 : Lock_rule (1 == Lock) - * 05 - 06 : Update_rule - */ - -#define FIELD_ACCESS_TYPE_MASK 0x0F -#define FIELD_LOCK_RULE_MASK 0x10 -#define FIELD_UPDATE_RULE_MASK 0x60 - - /******************************************************************************* * - * FUNCTION: Acpi_ds_create_field + * FUNCTION: Acpi_ds_create_buffer_field * - * PARAMETERS: Op - Op containing the Field definition and args - * Region_node - Object for the containing Operation Region + * PARAMETERS: Opcode - The opcode to be executed + * Operands - List of operands for the opcode + * Walk_state - Current state * * RETURN: Status * - * DESCRIPTION: Create a new field in the specified operation region + * DESCRIPTION: Execute the Create_field operators: + * Create_bit_field_op, + * Create_byte_field_op, + * Create_word_field_op, + * Create_dWord_field_op, + * Create_qWord_field_op, + * Create_field_op (all of which define fields in buffers) * ******************************************************************************/ -ACPI_STATUS -acpi_ds_create_field ( - ACPI_PARSE_OBJECT *op, - ACPI_NAMESPACE_NODE *region_node, - ACPI_WALK_STATE *walk_state) +acpi_status +acpi_ds_create_buffer_field ( + acpi_parse_object *op, + acpi_walk_state *walk_state) { - ACPI_STATUS status = AE_AML_ERROR; - ACPI_PARSE_OBJECT *arg; - ACPI_NAMESPACE_NODE *node; - u8 field_flags; - u8 access_attribute = 0; - u32 field_bit_position = 0; + acpi_parse_object *arg; + acpi_namespace_node *node; + acpi_status status; + acpi_operand_object *obj_desc; - /* First arg is the name of the parent Op_region */ + FUNCTION_TRACE ("Ds_create_buffer_field"); - arg = op->value.arg; - if (!region_node) { - status = acpi_ns_lookup (walk_state->scope_info, arg->value.name, - ACPI_TYPE_REGION, IMODE_EXECUTE, - NS_SEARCH_PARENT, walk_state, - ®ion_node); - if (ACPI_FAILURE (status)) { - return (status); - } + /* Get the Name_string argument */ + + if (op->opcode == AML_CREATE_FIELD_OP) { + arg = acpi_ps_get_arg (op, 3); } + else { + /* Create Bit/Byte/Word/Dword field */ - /* Second arg is the field flags */ + arg = acpi_ps_get_arg (op, 2); + } - arg = arg->next; - field_flags = (u8) arg->value.integer; + if (!arg) { + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } - /* Each remaining arg is a Named Field */ + /* + * Enter the Name_string into the namespace + */ + status = acpi_ns_lookup (walk_state->scope_info, arg->value.string, + INTERNAL_TYPE_DEF_ANY, IMODE_LOAD_PASS1, + NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, + walk_state, &(node)); + if (ACPI_FAILURE (status)) { + return_ACPI_STATUS (status); + } + + /* We could put the returned object (Node) on the object stack for later, but + * for now, we will put it in the "op" object that the parser uses, so we + * can get it again at the end of this scope + */ + op->node = node; + + /* + * If there is no object attached to the node, this node was just created and + * we need to create the field object. Otherwise, this was a lookup of an + * existing node and we don't want to create the field object again. + */ + if (node->object) { + return_ACPI_STATUS (AE_OK); + } + + /* + * The Field definition is not fully parsed at this time. + * (We must save the address of the AML for the buffer and index operands) + */ + + /* Create the buffer field object */ + + obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER_FIELD); + if (!obj_desc) { + status = AE_NO_MEMORY; + goto cleanup; + } + + /* + * Allocate a method object for this field unit + */ + obj_desc->buffer_field.extra = acpi_ut_create_internal_object ( + INTERNAL_TYPE_EXTRA); + if (!obj_desc->buffer_field.extra) { + status = AE_NO_MEMORY; + goto cleanup; + } + + /* + * Remember location in AML stream of the field unit + * opcode and operands -- since the buffer and index + * operands must be evaluated. + */ + obj_desc->buffer_field.extra->extra.aml_start = ((acpi_parse2_object *) op)->data; + obj_desc->buffer_field.extra->extra.aml_length = ((acpi_parse2_object *) op)->length; + obj_desc->buffer_field.node = node; + + /* Attach constructed field descriptor to parent node */ + + status = acpi_ns_attach_object (node, obj_desc, ACPI_TYPE_BUFFER_FIELD); + + +cleanup: + + /* Remove local reference to the object */ + + acpi_ut_remove_reference (obj_desc); + return_ACPI_STATUS (status); +} + + +/******************************************************************************* + * + * FUNCTION: Acpi_ds_get_field_names + * + * PARAMETERS: Info - Create_field info structure + * ` Walk_state - Current method state + * Arg - First parser arg for the field name list + * + * RETURN: Status + * + * DESCRIPTION: Process all named fields in a field declaration. Names are + * entered into the namespace. + * + ******************************************************************************/ + +acpi_status +acpi_ds_get_field_names ( + ACPI_CREATE_FIELD_INFO *info, + acpi_walk_state *walk_state, + acpi_parse_object *arg) +{ + acpi_status status; + + + FUNCTION_TRACE_U32 ("Ds_get_field_names", info); + + + /* First field starts at bit zero */ + + info->field_bit_position = 0; + + /* Process all elements in the field list (of parse nodes) */ - arg = arg->next; while (arg) { - switch (arg->opcode) - { - case AML_RESERVEDFIELD_OP: + /* + * Three types of field elements are handled: + * 1) Offset - specifies a bit offset + * 2) Access_as - changes the access mode + * 3) Name - Enters a new named field into the namespace + */ + switch (arg->opcode) { + case AML_INT_RESERVEDFIELD_OP: - field_bit_position += arg->value.size; + info->field_bit_position += arg->value.size; break; - case AML_ACCESSFIELD_OP: + case AML_INT_ACCESSFIELD_OP: /* * Get a new Access_type and Access_attribute for all * entries (until end or another Access_as keyword) */ - - access_attribute = (u8) arg->value.integer; - field_flags = (u8) - ((field_flags & FIELD_ACCESS_TYPE_MASK) || + info->field_flags = (u8) ((info->field_flags & FIELD_ACCESS_TYPE_MASK) || ((u8) (arg->value.integer >> 8))); break; - case AML_NAMEDFIELD_OP: + case AML_INT_NAMEDFIELD_OP: + + /* Enter a new field name into the namespace */ status = acpi_ns_lookup (walk_state->scope_info, - (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)arg)->name, - INTERNAL_TYPE_DEF_FIELD, - IMODE_LOAD_PASS1, + (NATIVE_CHAR *) &((acpi_parse2_object *)arg)->name, + info->field_type, IMODE_LOAD_PASS1, NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, - NULL, &node); - + NULL, &info->field_node); if (ACPI_FAILURE (status)) { - return (status); + return_ACPI_STATUS (status); } - /* - * Initialize an object for the new Node that is on - * the object stack - */ + /* Create and initialize an object for the new Field Node */ - status = acpi_aml_prep_def_field_value (node, region_node, field_flags, - access_attribute, field_bit_position, arg->value.size); + info->field_bit_length = arg->value.size; + status = acpi_ex_prep_field_value (info); if (ACPI_FAILURE (status)) { - return (status); + return_ACPI_STATUS (status); } - /* Keep track of bit position for *next* field */ + /* Keep track of bit position for the next field */ + + info->field_bit_position += info->field_bit_length; + break; + + + default: - field_bit_position += arg->value.size; + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid opcode in field list: %X\n", + arg->opcode)); + return_ACPI_STATUS (AE_AML_ERROR); break; } arg = arg->next; } - return (status); + return_ACPI_STATUS (AE_OK); } /******************************************************************************* * - * FUNCTION: Acpi_ds_create_bank_field + * FUNCTION: Acpi_ds_create_field * * PARAMETERS: Op - Op containing the Field definition and args - * Region_node - Object for the containing Operation Region + * Region_node - Object for the containing Operation Region + * ` Walk_state - Current method state * * RETURN: Status * - * DESCRIPTION: Create a new bank field in the specified operation region + * DESCRIPTION: Create a new field in the specified operation region * ******************************************************************************/ -ACPI_STATUS -acpi_ds_create_bank_field ( - ACPI_PARSE_OBJECT *op, - ACPI_NAMESPACE_NODE *region_node, - ACPI_WALK_STATE *walk_state) +acpi_status +acpi_ds_create_field ( + acpi_parse_object *op, + acpi_namespace_node *region_node, + acpi_walk_state *walk_state) { - ACPI_STATUS status = AE_AML_ERROR; - ACPI_PARSE_OBJECT *arg; - ACPI_NAMESPACE_NODE *register_node; - ACPI_NAMESPACE_NODE *node; - u32 bank_value; - u8 field_flags; - u8 access_attribute = 0; - u32 field_bit_position = 0; + acpi_status status = AE_AML_ERROR; + acpi_parse_object *arg; + ACPI_CREATE_FIELD_INFO info; + + + FUNCTION_TRACE_PTR ("Ds_create_field", op); - /* First arg is the name of the parent Op_region */ + /* First arg is the name of the parent Op_region (must already exist) */ arg = op->value.arg; if (!region_node) { status = acpi_ns_lookup (walk_state->scope_info, arg->value.name, - ACPI_TYPE_REGION, IMODE_EXECUTE, - NS_SEARCH_PARENT, walk_state, - ®ion_node); - + ACPI_TYPE_REGION, IMODE_EXECUTE, + NS_SEARCH_PARENT, walk_state, ®ion_node); if (ACPI_FAILURE (status)) { - return (status); + return_ACPI_STATUS (status); } } - /* Second arg is the Bank Register */ - - arg = arg->next; - - status = acpi_ns_lookup (walk_state->scope_info, arg->value.string, - INTERNAL_TYPE_BANK_FIELD_DEFN, - IMODE_LOAD_PASS1, - NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, - NULL, ®ister_node); - - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Third arg is the Bank_value */ + /* Second arg is the field flags */ arg = arg->next; - bank_value = arg->value.integer; + info.field_flags = arg->value.integer8; + /* Each remaining arg is a Named Field */ - /* Next arg is the field flags */ + info.field_type = INTERNAL_TYPE_REGION_FIELD; + info.region_node = region_node; - arg = arg->next; - field_flags = (u8) arg->value.integer; + status = acpi_ds_get_field_names (&info, walk_state, arg->next); - /* Each remaining arg is a Named Field */ + return_ACPI_STATUS (status); +} - arg = arg->next; - while (arg) { - switch (arg->opcode) - { - case AML_RESERVEDFIELD_OP: - field_bit_position += arg->value.size; - break; +/******************************************************************************* + * + * FUNCTION: Acpi_ds_create_bank_field + * + * PARAMETERS: Op - Op containing the Field definition and args + * Region_node - Object for the containing Operation Region + * ` Walk_state - Current method state + * + * RETURN: Status + * + * DESCRIPTION: Create a new bank field in the specified operation region + * + ******************************************************************************/ +acpi_status +acpi_ds_create_bank_field ( + acpi_parse_object *op, + acpi_namespace_node *region_node, + acpi_walk_state *walk_state) +{ + acpi_status status = AE_AML_ERROR; + acpi_parse_object *arg; + ACPI_CREATE_FIELD_INFO info; - case AML_ACCESSFIELD_OP: - /* - * Get a new Access_type and Access_attribute for - * all entries (until end or another Access_as keyword) - */ + FUNCTION_TRACE_PTR ("Ds_create_bank_field", op); - access_attribute = (u8) arg->value.integer; - field_flags = (u8) - ((field_flags & FIELD_ACCESS_TYPE_MASK) || - ((u8) (arg->value.integer >> 8))); - break; + /* First arg is the name of the parent Op_region (must already exist) */ - case AML_NAMEDFIELD_OP: + arg = op->value.arg; + if (!region_node) { + status = acpi_ns_lookup (walk_state->scope_info, arg->value.name, + ACPI_TYPE_REGION, IMODE_EXECUTE, + NS_SEARCH_PARENT, walk_state, ®ion_node); + if (ACPI_FAILURE (status)) { + return_ACPI_STATUS (status); + } + } - status = acpi_ns_lookup (walk_state->scope_info, - (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)arg)->name, - INTERNAL_TYPE_DEF_FIELD, - IMODE_LOAD_PASS1, - NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, - NULL, &node); + /* Second arg is the Bank Register (must already exist) */ - if (ACPI_FAILURE (status)) { - return (status); - } + arg = arg->next; + status = acpi_ns_lookup (walk_state->scope_info, arg->value.string, + INTERNAL_TYPE_BANK_FIELD_DEFN, IMODE_EXECUTE, + NS_SEARCH_PARENT, walk_state, &info.register_node); + if (ACPI_FAILURE (status)) { + return_ACPI_STATUS (status); + } - /* - * Initialize an object for the new Node that is on - * the object stack - */ + /* Third arg is the Bank_value */ - status = acpi_aml_prep_bank_field_value (node, region_node, register_node, - bank_value, field_flags, access_attribute, - field_bit_position, arg->value.size); + arg = arg->next; + info.bank_value = arg->value.integer32; - if (ACPI_FAILURE (status)) { - return (status); - } + /* Fourth arg is the field flags */ - /* Keep track of bit position for the *next* field */ + arg = arg->next; + info.field_flags = arg->value.integer8; - field_bit_position += arg->value.size; - break; + /* Each remaining arg is a Named Field */ - } + info.field_type = INTERNAL_TYPE_BANK_FIELD; + info.region_node = region_node; - arg = arg->next; - } + status = acpi_ds_get_field_names (&info, walk_state, arg->next); - return (status); + return_ACPI_STATUS (status); } @@ -295,7 +390,8 @@ * FUNCTION: Acpi_ds_create_index_field * * PARAMETERS: Op - Op containing the Field definition and args - * Region_node - Object for the containing Operation Region + * Region_node - Object for the containing Operation Region + * ` Walk_state - Current method state * * RETURN: Status * @@ -303,124 +399,54 @@ * ******************************************************************************/ -ACPI_STATUS +acpi_status acpi_ds_create_index_field ( - ACPI_PARSE_OBJECT *op, - ACPI_HANDLE region_node, - ACPI_WALK_STATE *walk_state) + acpi_parse_object *op, + acpi_namespace_node *region_node, + acpi_walk_state *walk_state) { - ACPI_STATUS status; - ACPI_PARSE_OBJECT *arg; - ACPI_NAMESPACE_NODE *node; - ACPI_NAMESPACE_NODE *index_register_node; - ACPI_NAMESPACE_NODE *data_register_node; - u8 field_flags; - u8 access_attribute = 0; - u32 field_bit_position = 0; + acpi_status status; + acpi_parse_object *arg; + ACPI_CREATE_FIELD_INFO info; - arg = op->value.arg; + FUNCTION_TRACE_PTR ("Ds_create_index_field", op); - /* First arg is the name of the Index register */ - status = acpi_ns_lookup (walk_state->scope_info, arg->value.string, - ACPI_TYPE_ANY, IMODE_LOAD_PASS1, - NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, - NULL, &index_register_node); + /* First arg is the name of the Index register (must already exist) */ + arg = op->value.arg; + status = acpi_ns_lookup (walk_state->scope_info, arg->value.string, + ACPI_TYPE_ANY, IMODE_EXECUTE, + NS_SEARCH_PARENT, walk_state, &info.register_node); if (ACPI_FAILURE (status)) { - return (status); + return_ACPI_STATUS (status); } - /* Second arg is the data register */ + /* Second arg is the data register (must already exist) */ arg = arg->next; - status = acpi_ns_lookup (walk_state->scope_info, arg->value.string, - INTERNAL_TYPE_INDEX_FIELD_DEFN, - IMODE_LOAD_PASS1, - NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, - NULL, &data_register_node); - + INTERNAL_TYPE_INDEX_FIELD_DEFN, IMODE_EXECUTE, + NS_SEARCH_PARENT, walk_state, &info.data_register_node); if (ACPI_FAILURE (status)) { - return (status); + return_ACPI_STATUS (status); } - /* Next arg is the field flags */ arg = arg->next; - field_flags = (u8) arg->value.integer; + info.field_flags = arg->value.integer8; /* Each remaining arg is a Named Field */ - arg = arg->next; - while (arg) { - switch (arg->opcode) - { - case AML_RESERVEDFIELD_OP: - - field_bit_position += arg->value.size; - break; - + info.field_type = INTERNAL_TYPE_INDEX_FIELD; + info.region_node = region_node; - case AML_ACCESSFIELD_OP: - - /* - * Get a new Access_type and Access_attribute for all - * entries (until end or another Access_as keyword) - */ - - access_attribute = (u8) arg->value.integer; - field_flags = (u8) - ((field_flags & FIELD_ACCESS_TYPE_MASK) || - ((u8) (arg->value.integer >> 8))); - break; - - - case AML_NAMEDFIELD_OP: - - status = acpi_ns_lookup (walk_state->scope_info, - (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)arg)->name, - INTERNAL_TYPE_INDEX_FIELD, - IMODE_LOAD_PASS1, - NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, - NULL, &node); - - if (ACPI_FAILURE (status)) { - return (status); - } - - /* - * Initialize an object for the new Node that is on - * the object stack - */ - - status = acpi_aml_prep_index_field_value (node, index_register_node, data_register_node, - field_flags, access_attribute, - field_bit_position, arg->value.size); - - if (ACPI_FAILURE (status)) { - return (status); - } - - /* Keep track of bit position for the *next* field */ - - field_bit_position += arg->value.size; - break; - - - default: - - status = AE_AML_ERROR; - break; - } - - arg = arg->next; - } + status = acpi_ds_get_field_names (&info, walk_state, arg->next); - return (status); + return_ACPI_STATUS (status); } Index: dsmethod.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/drivers/acpi/dispatcher/dsmethod.c,v retrieving revision 1.1.1.2 retrieving revision 1.2 diff -u -r1.1.1.2 -r1.2 --- dsmethod.c 25 Feb 2001 23:15:15 -0000 1.1.1.2 +++ dsmethod.c 9 Apr 2002 14:05:42 -0000 1.2 @@ -34,7 +34,7 @@ #include "acdebug.h" -#define _COMPONENT DISPATCHER +#define _COMPONENT ACPI_DISPATCHER MODULE_NAME ("dsmethod") @@ -56,41 +56,48 @@ * ******************************************************************************/ -ACPI_STATUS +acpi_status acpi_ds_parse_method ( - ACPI_HANDLE obj_handle) + acpi_handle obj_handle) { - ACPI_STATUS status; - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_PARSE_OBJECT *op; - ACPI_NAMESPACE_NODE *node; - ACPI_OWNER_ID owner_id; + acpi_status status; + acpi_operand_object *obj_desc; + acpi_parse_object *op; + acpi_namespace_node *node; + acpi_owner_id owner_id; + acpi_walk_state *walk_state; + + + FUNCTION_TRACE_PTR ("Ds_parse_method", obj_handle); /* Parameter Validation */ if (!obj_handle) { - return (AE_NULL_ENTRY); + return_ACPI_STATUS (AE_NULL_ENTRY); } + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Parsing [%4.4s] **** Named_obj=%p\n", + (char*)&((acpi_namespace_node *)obj_handle)->name, obj_handle)); + /* Extract the method object from the method Node */ - node = (ACPI_NAMESPACE_NODE *) obj_handle; + node = (acpi_namespace_node *) obj_handle; obj_desc = node->object; if (!obj_desc) { - return (AE_NULL_OBJECT); + return_ACPI_STATUS (AE_NULL_OBJECT); } - /* Create a mutex for the method if there is a concurrency limit */ + /* Create a mutex for the method if there is a concurrency limit */ if ((obj_desc->method.concurrency != INFINITE_CONCURRENCY) && - (!obj_desc->method.semaphore)) - { - status = acpi_os_create_semaphore (1,obj_desc->method.concurrency, + (!obj_desc->method.semaphore)) { + status = acpi_os_create_semaphore (obj_desc->method.concurrency, + obj_desc->method.concurrency, &obj_desc->method.semaphore); if (ACPI_FAILURE (status)) { - return (status); + return_ACPI_STATUS (status); } } @@ -98,10 +105,9 @@ * Allocate a new parser op to be the root of the parsed * method tree */ - op = acpi_ps_alloc_op (AML_METHOD_OP); if (!op) { - return (AE_NO_MEMORY); + return_ACPI_STATUS (AE_NO_MEMORY); } /* Init new op with the method name and pointer back to the Node */ @@ -109,41 +115,47 @@ acpi_ps_set_name (op, node->name); op->node = node; + /* Create and initialize a new walk state */ + + walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT, + NULL, NULL, NULL); + if (!walk_state) { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + status = acpi_ds_init_aml_walk (walk_state, op, node, obj_desc->method.aml_start, + obj_desc->method.aml_length, NULL, NULL, 1); + if (ACPI_FAILURE (status)) { + /* TBD: delete walk state */ + return_ACPI_STATUS (status); + } /* * Parse the method, first pass * - * The first pass load is - * where newly declared named objects are + * The first pass load is where newly declared named objects are * added into the namespace. Actual evaluation of * the named objects (what would be called a "second * pass") happens during the actual execution of the * method so that operands to the named objects can * take on dynamic run-time values. */ - - status = acpi_ps_parse_aml (op, obj_desc->method.pcode, - obj_desc->method.pcode_length, - ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE, - node, NULL, NULL, - acpi_ds_load1_begin_op, acpi_ds_load1_end_op); - + status = acpi_ps_parse_aml (walk_state); if (ACPI_FAILURE (status)) { - return (status); + return_ACPI_STATUS (status); } /* Get a new Owner_id for objects created by this method */ - owner_id = acpi_cm_allocate_owner_id (OWNER_TYPE_METHOD); + owner_id = acpi_ut_allocate_owner_id (OWNER_TYPE_METHOD); obj_desc->method.owning_id = owner_id; - /* Install the parsed tree in the method object */ - /* TBD: [Restructure] Obsolete field? */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** [%4.4s] Parsed **** Named_obj=%p Op=%p\n", + (char*)&((acpi_namespace_node *)obj_handle)->name, obj_handle, op)); acpi_ps_delete_parse_tree (op); - - return (status); + return_ACPI_STATUS (status); } @@ -151,8 +163,9 @@ * * FUNCTION: Acpi_ds_begin_method_execution * - * PARAMETERS: Method_node - Node of the method + * PARAMETERS: Method_node - Node of the method * Obj_desc - The method object + * Calling_method_node - Caller of this method (if non-null) * * RETURN: Status * @@ -164,47 +177,58 @@ * ******************************************************************************/ -ACPI_STATUS +acpi_status acpi_ds_begin_method_execution ( - ACPI_NAMESPACE_NODE *method_node, - ACPI_OPERAND_OBJECT *obj_desc) + acpi_namespace_node *method_node, + acpi_operand_object *obj_desc, + acpi_namespace_node *calling_method_node) { - ACPI_STATUS status = AE_OK; + acpi_status status = AE_OK; - if (!method_node) { - return (AE_NULL_ENTRY); - } + FUNCTION_TRACE_PTR ("Ds_begin_method_execution", method_node); - obj_desc = acpi_ns_get_attached_object (method_node); - if (!obj_desc) { - return (AE_NULL_OBJECT); + + if (!method_node) { + return_ACPI_STATUS (AE_NULL_ENTRY); } /* * If there is a concurrency limit on this method, we need to - * obtain a unit from the method semaphore. This releases the - * interpreter if we block + * obtain a unit from the method semaphore. */ - if (obj_desc->method.semaphore) { - status = acpi_aml_system_wait_semaphore (obj_desc->method.semaphore, + /* + * Allow recursive method calls, up to the reentrancy/concurrency + * limit imposed by the SERIALIZED rule and the Sync_level method + * parameter. + * + * The point of this code is to avoid permanently blocking a + * thread that is making recursive method calls. + */ + if (method_node == calling_method_node) { + if (obj_desc->method.thread_count >= obj_desc->method.concurrency) { + return_ACPI_STATUS (AE_AML_METHOD_LIMIT); + } + } + + /* + * Get a unit from the method semaphore. This releases the + * interpreter if we block + */ + status = acpi_ex_system_wait_semaphore (obj_desc->method.semaphore, WAIT_FOREVER); } /* - * Increment the method parse tree thread count since there - * is one additional thread executing in it. If configured - * for deletion-on-exit, the parse tree will be deleted when - * the last thread completes execution of the method + * Increment the method parse tree thread count since it has been + * reentered one more time (even if it is the same thread) */ - obj_desc->method.thread_count++; - - return (status); + return_ACPI_STATUS (status); } @@ -221,123 +245,107 @@ * ******************************************************************************/ -ACPI_STATUS +acpi_status acpi_ds_call_control_method ( - ACPI_WALK_LIST *walk_list, - ACPI_WALK_STATE *this_walk_state, - ACPI_PARSE_OBJECT *op) + acpi_walk_list *walk_list, + acpi_walk_state *this_walk_state, + acpi_parse_object *op) /* TBD: This operand is obsolete */ { - ACPI_STATUS status; - ACPI_NAMESPACE_NODE *method_node; - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_WALK_STATE *next_walk_state; - ACPI_PARSE_STATE *parser_state; + acpi_status status; + acpi_namespace_node *method_node; + acpi_operand_object *obj_desc; + acpi_walk_state *next_walk_state; u32 i; + FUNCTION_TRACE_PTR ("Ds_call_control_method", this_walk_state); + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Execute method %p, currentstate=%p\n", + this_walk_state->prev_op, this_walk_state)); + /* * Get the namespace entry for the control method we are about to call */ - method_node = this_walk_state->method_call_node; if (!method_node) { - return (AE_NULL_ENTRY); + return_ACPI_STATUS (AE_NULL_ENTRY); } obj_desc = acpi_ns_get_attached_object (method_node); if (!obj_desc) { - return (AE_NULL_OBJECT); + return_ACPI_STATUS (AE_NULL_OBJECT); } - /* Init for new method, wait on concurrency semaphore */ - status = acpi_ds_begin_method_execution (method_node, obj_desc); + status = acpi_ds_begin_method_execution (method_node, obj_desc, + this_walk_state->method_node); if (ACPI_FAILURE (status)) { - return (status); + return_ACPI_STATUS (status); } - /* Create and initialize a new parser state */ + /* 1) Parse: Create a new walk state for the preempting walk */ - parser_state = acpi_ps_create_state (obj_desc->method.pcode, - obj_desc->method.pcode_length); - if (!parser_state) { - return (AE_NO_MEMORY); + next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id, + op, obj_desc, NULL); + if (!next_walk_state) { + return_ACPI_STATUS (AE_NO_MEMORY); + goto cleanup; } - acpi_ps_init_scope (parser_state, NULL); - parser_state->start_node = method_node; - - - /* Create a new state for the preempting walk */ + /* Create and init a Root Node */ - next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id, - NULL, obj_desc, walk_list); - if (!next_walk_state) { - /* TBD: delete parser state */ + op = acpi_ps_alloc_op (AML_SCOPE_OP); + if (!op) { + status = AE_NO_MEMORY; + goto cleanup; + } - return (AE_NO_MEMORY); + status = acpi_ds_init_aml_walk (next_walk_state, op, method_node, + obj_desc->method.aml_start, obj_desc->method.aml_length, + NULL, NULL, 1); + if (ACPI_FAILURE (status)) { + /* TBD: delete walk state */ + goto cleanup; } - next_walk_state->walk_type = WALK_METHOD; - next_walk_state->method_node = method_node; - next_walk_state->parser_state = parser_state; - next_walk_state->parse_flags = this_walk_state->parse_flags; - next_walk_state->descending_callback = this_walk_state->descending_callback; - next_walk_state->ascending_callback = this_walk_state->ascending_callback; + /* Begin AML parse */ - /* The Next_op of the Next_walk will be the beginning of the method */ - /* TBD: [Restructure] -- obsolete? */ + status = acpi_ps_parse_aml (next_walk_state); + acpi_ps_delete_parse_tree (op); - next_walk_state->next_op = NULL; - /* Open a new scope */ + /* 2) Execute: Create a new state for the preempting walk */ - status = acpi_ds_scope_stack_push (method_node, - ACPI_TYPE_METHOD, next_walk_state); - if (ACPI_FAILURE (status)) { + next_walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id, + NULL, obj_desc, walk_list); + if (!next_walk_state) { + status = AE_NO_MEMORY; goto cleanup; } - /* - * Initialize the arguments for the method. The resolved - * arguments were put on the previous walk state's operand + * The resolved arguments were put on the previous walk state's operand * stack. Operands on the previous walk state stack always * start at index 0. + * Null terminate the list of arguments */ + this_walk_state->operands [this_walk_state->num_operands] = NULL; - status = acpi_ds_method_data_init_args (&this_walk_state->operands[0], - this_walk_state->num_operands, - next_walk_state); + status = acpi_ds_init_aml_walk (next_walk_state, NULL, method_node, + obj_desc->method.aml_start, obj_desc->method.aml_length, + &this_walk_state->operands[0], NULL, 3); if (ACPI_FAILURE (status)) { goto cleanup; } - - /* Create and init a Root Node */ - - op = acpi_ps_alloc_op (AML_SCOPE_OP); - if (!op) { - return (AE_NO_MEMORY); - } - - status = acpi_ps_parse_aml (op, obj_desc->method.pcode, - obj_desc->method.pcode_length, - ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE, - method_node, NULL, NULL, - acpi_ds_load1_begin_op, acpi_ds_load1_end_op); - acpi_ps_delete_parse_tree (op); - - /* * Delete the operands on the previous walkstate operand stack * (they were copied to new objects) */ - for (i = 0; i < obj_desc->method.param_count; i++) { - acpi_cm_remove_reference (this_walk_state->operands [i]); + acpi_ut_remove_reference (this_walk_state->operands [i]); this_walk_state->operands [i] = NULL; } @@ -345,8 +353,10 @@ this_walk_state->num_operands = 0; + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Starting nested execution, newstate=%p\n", + next_walk_state)); - return (AE_OK); + return_ACPI_STATUS (AE_OK); /* On error, we must delete the new walk state */ @@ -354,7 +364,7 @@ cleanup: acpi_ds_terminate_control_method (next_walk_state); acpi_ds_delete_walk_state (next_walk_state); - return (status); + return_ACPI_STATUS (status); } @@ -372,12 +382,15 @@ * ******************************************************************************/ -ACPI_STATUS +acpi_status acpi_ds_restart_control_method ( - ACPI_WALK_STATE *walk_state, - ACPI_OPERAND_OBJECT *return_desc) + acpi_walk_state *walk_state, + acpi_operand_object *return_desc) { - ACPI_STATUS status; + acpi_status status; + + + FUNCTION_TRACE_PTR ("Ds_restart_control_method", walk_state); if (return_desc) { @@ -386,11 +399,10 @@ * Get the return value (if any) from the previous method. * NULL if no return value */ - status = acpi_ds_result_push (return_desc, walk_state); if (ACPI_FAILURE (status)) { - acpi_cm_remove_reference (return_desc); - return (status); + acpi_ut_remove_reference (return_desc); + return_ACPI_STATUS (status); } } @@ -399,13 +411,18 @@ * Delete the return value if it will not be used by the * calling method */ - acpi_cm_remove_reference (return_desc); + acpi_ut_remove_reference (return_desc); } } + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Method=%p Return=%p Return_used?=%X Res_stack=%p State=%p\n", + walk_state->method_call_op, return_desc, walk_state->return_used, + walk_state->results, walk_state)); + - return (AE_OK); + return_ACPI_STATUS (AE_OK); } @@ -423,20 +440,22 @@ * ******************************************************************************/ -ACPI_STATUS +acpi_status acpi_ds_terminate_control_method ( - ACPI_WALK_STATE *walk_state) + acpi_walk_state *walk_state) { - ACPI_STATUS status; - ACPI_OPERAND_OBJECT *obj_desc; - ACPI_NAMESPACE_NODE *method_node; + acpi_operand_object *obj_desc; + acpi_namespace_node *method_node; + + + FUNCTION_TRACE_PTR ("Ds_terminate_control_method", walk_state); /* The method object should be stored in the walk state */ obj_desc = walk_state->method_desc; if (!obj_desc) { - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /* Delete all arguments and locals */ @@ -448,15 +467,14 @@ * If this is the last thread executing the method, * we have additional cleanup to perform */ - - acpi_cm_acquire_mutex (ACPI_MTX_PARSER); + acpi_ut_acquire_mutex (ACPI_MTX_PARSER); /* Signal completion of the execution of this method if necessary */ if (walk_state->method_desc->method.semaphore) { - status = acpi_os_signal_semaphore ( - walk_state->method_desc->method.semaphore, 1); + acpi_os_signal_semaphore ( + walk_state->method_desc->method.semaphore, 1); } /* Decrement the thread count on the method parse tree */ @@ -470,11 +488,12 @@ * The method Node is stored in the walk state */ method_node = walk_state->method_node; + /* * Delete any namespace entries created immediately underneath * the method */ - acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE); + acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); if (method_node->child) { acpi_ns_delete_namespace_subtree (method_node); } @@ -484,11 +503,11 @@ * the namespace */ acpi_ns_delete_namespace_by_owner (walk_state->method_desc->method.owning_id); - acpi_cm_release_mutex (ACPI_MTX_NAMESPACE); + acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); } - acpi_cm_release_mutex (ACPI_MTX_PARSER); - return (AE_OK); + acpi_ut_release_mutex (ACPI_MTX_PARSER); + return_ACPI_STATUS (AE_OK); } Index: dsmthdat.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/drivers/acpi/dispatcher/dsmthdat.c,v retrieving revision 1.1.1.2 retrieving revision 1.2 diff -u -r1.1.1.2 -r1.2 --- dsmthdat.c 25 Feb 2001 23:15:15 -0000 1.1.1.2 +++ dsmthdat.c 9 Apr 2002 14:05:42 -0000 1.2 @@ -32,7 +32,7 @@ #include "acnamesp.h" -#define _COMPONENT DISPATCHER +#define _COMPONENT ACPI_DISPATCHER MODULE_NAME ("dsmthdat") @@ -51,16 +51,18 @@ * ******************************************************************************/ -ACPI_STATUS +acpi_status acpi_ds_method_data_init ( - ACPI_WALK_STATE *walk_state) + acpi_walk_state *walk_state) { u32 i; + FUNCTION_TRACE ("Ds_method_data_init"); + /* * Walk_state fields are initialized to zero by the - * Acpi_cm_callocate(). + * ACPI_MEM_CALLOCATE(). * * An Node is assigned to each argument and local so * that Ref_of() can return a pointer to the Node. @@ -89,7 +91,7 @@ walk_state->local_variables[i].flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL; } - return (AE_OK); + return_ACPI_STATUS (AE_OK); } @@ -106,46 +108,57 @@ * ******************************************************************************/ -ACPI_STATUS +acpi_status acpi_ds_method_data_delete_all ( - ACPI_WALK_STATE *walk_state) + acpi_walk_state *walk_state) { u32 index; - ACPI_OPERAND_OBJECT *object; + acpi_operand_object *object; + + + FUNCTION_TRACE ("Ds_method_data_delete_all"); /* Delete the locals */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Deleting local variables in %p\n", walk_state)); + for (index = 0; index < MTH_NUM_LOCALS; index++) { object = walk_state->local_variables[index].object; if (object) { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%d=%p\n", index, object)); + /* Remove first */ walk_state->local_variables[index].object = NULL; /* Was given a ref when stored */ - acpi_cm_remove_reference (object); + acpi_ut_remove_reference (object); } } /* Delete the arguments */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Deleting arguments in %p\n", walk_state)); + for (index = 0; index < MTH_NUM_ARGS; index++) { object = walk_state->arguments[index].object; if (object) { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%d=%p\n", index, object)); + /* Remove first */ walk_state->arguments[index].object = NULL; /* Was given a ref when stored */ - acpi_cm_remove_reference (object); + acpi_ut_remove_reference (object); } } - return (AE_OK); + return_ACPI_STATUS (AE_OK); } @@ -163,35 +176,38 @@ * ******************************************************************************/ -ACPI_STATUS +acpi_status acpi_ds_method_data_init_args ( - ACPI_OPERAND_OBJECT **params, + acpi_operand_object **params, u32 max_param_count, - ACPI_WALK_STATE *walk_state) + acpi_walk_state *walk_state) { - ACPI_STATUS status; + acpi_status status; u32 mindex; u32 pindex; + FUNCTION_TRACE_PTR ("Ds_method_data_init_args", params); + + if (!params) { - return (AE_OK); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "No param list passed to method\n")); + return_ACPI_STATUS (AE_OK); } /* Copy passed parameters into the new method stack frame */ for (pindex = mindex = 0; (mindex < MTH_NUM_ARGS) && (pindex < max_param_count); - mindex++) - { + mindex++) { if (params[pindex]) { /* * A valid parameter. * Set the current method argument to the * Params[Pindex++] argument object descriptor */ - status = acpi_ds_method_data_set_value (MTH_TYPE_ARG, mindex, - params[pindex], walk_state); + status = acpi_ds_store_object_to_local (AML_ARG_OP, mindex, + params[pindex], walk_state); if (ACPI_FAILURE (status)) { break; } @@ -204,7 +220,8 @@ } } - return (AE_OK); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%d args passed to method\n", pindex)); + return_ACPI_STATUS (AE_OK); } @@ -212,7 +229,7 @@ * * FUNCTION: Acpi_ds_method_data_get_entry * - * PARAMETERS: Type - Either MTH_TYPE_LOCAL or MTH_TYPE_ARG + * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP * Index - Which local_var or argument to get * Entry - Pointer to where a pointer to the stack * entry is returned. @@ -220,55 +237,60 @@ * * RETURN: Status * - * DESCRIPTION: Get the address of the stack entry given by Type:Index + * DESCRIPTION: Get the address of the object entry given by Opcode:Index * ******************************************************************************/ -ACPI_STATUS +acpi_status acpi_ds_method_data_get_entry ( - u32 type, + u16 opcode, u32 index, - ACPI_WALK_STATE *walk_state, - ACPI_OPERAND_OBJECT ***entry) + acpi_walk_state *walk_state, + acpi_operand_object ***entry) { + FUNCTION_TRACE_U32 ("Ds_method_data_get_entry", index); + /* * Get the requested object. - * The stack "Type" is either a Local_variable or an Argument + * The stack "Opcode" is either a Local_variable or an Argument */ + switch (opcode) { - switch (type) - { - - case MTH_TYPE_LOCAL: + case AML_LOCAL_OP: if (index > MTH_MAX_LOCAL) { - return (AE_BAD_PARAMETER); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Local_var index %d is invalid (max %d)\n", + index, MTH_MAX_LOCAL)); + return_ACPI_STATUS (AE_BAD_PARAMETER); } - *entry = - (ACPI_OPERAND_OBJECT **) &walk_state->local_variables[index].object; + *entry = (acpi_operand_object **) + &walk_state->local_variables[index].object; break; - case MTH_TYPE_ARG: + case AML_ARG_OP: if (index > MTH_MAX_ARG) { - return (AE_BAD_PARAMETER); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Arg index %d is invalid (max %d)\n", + index, MTH_MAX_ARG)); + return_ACPI_STATUS (AE_BAD_PARAMETER); } - *entry = - (ACPI_OPERAND_OBJECT **) &walk_state->arguments[index].object; + *entry = (acpi_operand_object **) + &walk_state->arguments[index].object; break; default: - return (AE_BAD_PARAMETER); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Opcode %d is invalid\n", opcode)); + return_ACPI_STATUS (AE_BAD_PARAMETER); } - return (AE_OK); + return_ACPI_STATUS (AE_OK); } @@ -276,44 +298,47 @@ * * FUNCTION: Acpi_ds_method_data_set_entry * - * PARAMETERS: Type - Either MTH_TYPE_LOCAL or MTH_TYPE_ARG + * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP * Index - Which local_var or argument to get * Object - Object to be inserted into the stack entry * Walk_state - Current walk state object * * RETURN: Status * - * DESCRIPTION: Insert an object onto the method stack at entry Type:Index. + * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index. * ******************************************************************************/ -ACPI_STATUS +acpi_status acpi_ds_method_data_set_entry ( - u32 type, + u16 opcode, u32 index, - ACPI_OPERAND_OBJECT *object, - ACPI_WALK_STATE *walk_state) + acpi_operand_object *object, + acpi_walk_state *walk_state) { - ACPI_STATUS status; - ACPI_OPERAND_OBJECT **entry; + acpi_status status; + acpi_operand_object **entry; + + + FUNCTION_TRACE ("Ds_method_data_set_entry"); /* Get a pointer to the stack entry to set */ - status = acpi_ds_method_data_get_entry (type, index, walk_state, &entry); + status = acpi_ds_method_data_get_entry (opcode, index, walk_state, &entry); if (ACPI_FAILURE (status)) { - return (status); + return_ACPI_STATUS (status); } /* Increment ref count so object can't be deleted while installed */ - acpi_cm_add_reference (object); + acpi_ut_add_reference (object); /* Install the object into the stack entry */ *entry = object; - return (AE_OK); + return_ACPI_STATUS (AE_OK); } @@ -321,7 +346,7 @@ * * FUNCTION: Acpi_ds_method_data_get_type * - * PARAMETERS: Type - Either MTH_TYPE_LOCAL or MTH_TYPE_ARG + * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP * Index - Which local_var or argument whose type * to get * Walk_state - Current walk state object @@ -331,22 +356,25 @@ * ******************************************************************************/ -OBJECT_TYPE_INTERNAL +acpi_object_type8 acpi_ds_method_data_get_type ( - u32 type, + u16 opcode, u32 index, - ACPI_WALK_STATE *walk_state) + acpi_walk_state *walk_state) { - ACPI_STATUS status; - ACPI_OPERAND_OBJECT **entry; - ACPI_OPERAND_OBJECT *object; + acpi_status status; + acpi_operand_object **entry; + acpi_operand_object *object; + + + FUNCTION_TRACE ("Ds_method_data_get_type"); /* Get a pointer to the requested stack entry */ - status = acpi_ds_method_data_get_entry (type, index, walk_state, &entry); + status = acpi_ds_method_data_get_entry (opcode, index, walk_state, &entry); if (ACPI_FAILURE (status)) { - return ((ACPI_TYPE_NOT_FOUND)); + return_VALUE ((ACPI_TYPE_NOT_FOUND)); } /* Get the object from the method stack */ @@ -357,18 +385,18 @@ if (!object) { /* Any == 0 => "uninitialized" -- see spec 15.2.3.5.2.28 */ - return (ACPI_TYPE_ANY); + return_VALUE (ACPI_TYPE_ANY); } - return (object->common.type); + return_VALUE (object->common.type); } /******************************************************************************* * - * FUNCTION: Acpi_ds_method_data_get_nte + * FUNCTION: Acpi_ds_method_data_get_node * - * PARAMETERS: Type - Either MTH_TYPE_LOCAL or MTH_TYPE_ARG + * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP * Index - Which local_var or argument whose type * to get * Walk_state - Current walk state object @@ -377,32 +405,38 @@ * ******************************************************************************/ -ACPI_NAMESPACE_NODE * -acpi_ds_method_data_get_nte ( - u32 type, +acpi_namespace_node * +acpi_ds_method_data_get_node ( + u16 opcode, u32 index, - ACPI_WALK_STATE *walk_state) + acpi_walk_state *walk_state) { - ACPI_NAMESPACE_NODE *node = NULL; + acpi_namespace_node *node = NULL; + + FUNCTION_TRACE ("Ds_method_data_get_node"); - switch (type) - { - case MTH_TYPE_LOCAL: + switch (opcode) { + + case AML_LOCAL_OP: if (index > MTH_MAX_LOCAL) { - return (node); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Local index %d is invalid (max %d)\n", + index, MTH_MAX_LOCAL)); + return_PTR (node); } node = &walk_state->local_variables[index]; break; - case MTH_TYPE_ARG: + case AML_ARG_OP: if (index > MTH_MAX_ARG) { - return (node); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Arg index %d is invalid (max %d)\n", + index, MTH_MAX_ARG)); + return_PTR (node); } node = &walk_state->arguments[index]; @@ -410,11 +444,12 @@ default: + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Opcode %d is invalid\n", opcode)); break; } - return (node); + return_PTR (node); } @@ -422,7 +457,7 @@ * * FUNCTION: Acpi_ds_method_data_get_value * - * PARAMETERS: Type - Either MTH_TYPE_LOCAL or MTH_TYPE_ARG + * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP * Index - Which local_var or argument to get * Walk_state - Current walk state object * *Dest_desc - Ptr to Descriptor into which selected Arg @@ -432,34 +467,38 @@ * * DESCRIPTION: Retrieve value of selected Arg or Local from the method frame * at the current top of the method stack. - * Used only in Acpi_aml_resolve_to_value(). + * Used only in Acpi_ex_resolve_to_value(). * ******************************************************************************/ -ACPI_STATUS +acpi_status acpi_ds_method_data_get_value ( - u32 type, + u16 opcode, u32 index, - ACPI_WALK_STATE *walk_state, - ACPI_OPERAND_OBJECT **dest_desc) + acpi_walk_state *walk_state, + acpi_operand_object **dest_desc) { - ACPI_STATUS status; - ACPI_OPERAND_OBJECT **entry; - ACPI_OPERAND_OBJECT *object; + acpi_status status; + acpi_operand_object **entry; + acpi_operand_object *object; + + + FUNCTION_TRACE ("Ds_method_data_get_value"); /* Validate the object descriptor */ if (!dest_desc) { - return (AE_BAD_PARAMETER); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null object descriptor pointer\n")); + return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Get a pointer to the requested method stack entry */ - status = acpi_ds_method_data_get_entry (type, index, walk_state, &entry); + status = acpi_ds_method_data_get_entry (opcode, index, walk_state, &entry); if (ACPI_FAILURE (status)) { - return (status); + return_ACPI_STATUS (status); } /* Get the object from the method stack */ @@ -477,17 +516,21 @@ * was referenced by the method (via the ASL) * before it was initialized. Either case is an error. */ + switch (opcode) { + case AML_ARG_OP: - switch (type) - { - case MTH_TYPE_ARG: + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Arg[%d] at entry %p\n", + index, entry)); - return (AE_AML_UNINITIALIZED_ARG); + return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG); break; - case MTH_TYPE_LOCAL: + case AML_LOCAL_OP: + + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Local[%d] at entry %p\n", + index, entry)); - return (AE_AML_UNINITIALIZED_LOCAL); + return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL); break; } } @@ -497,11 +540,10 @@ * Index points to initialized and valid object stack value. * Return an additional reference to the object */ - *dest_desc = object; - acpi_cm_add_reference (object); + acpi_ut_add_reference (object); - return (AE_OK); + return_ACPI_STATUS (AE_OK); } @@ -509,33 +551,36 @@ * * FUNCTION: Acpi_ds_method_data_delete_value * - * PARAMETERS: Type - Either MTH_TYPE_LOCAL or MTH_TYPE_ARG + * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP * Index - Which local_var or argument to delete * Walk_state - Current walk state object * * RETURN: Status * - * DESCRIPTION: Delete the entry at Type:Index on the method stack. Inserts + * DESCRIPTION: Delete the entry at Opcode:Index on the method stack. Inserts * a null into the stack slot after the object is deleted. * ******************************************************************************/ -ACPI_STATUS +acpi_status acpi_ds_method_data_delete_value ( - u32 type, + u16 opcode, u32 index, - ACPI_WALK_STATE *walk_state) + acpi_walk_state *walk_state) { - ACPI_STATUS status; - ACPI_OPERAND_OBJECT **entry; - ACPI_OPERAND_OBJECT *object; + acpi_status status; + acpi_operand_object **entry; + acpi_operand_object *object; + + + FUNCTION_TRACE ("Ds_method_data_delete_value"); /* Get a pointer to the requested entry */ - status = acpi_ds_method_data_get_entry (type, index, walk_state, &entry); + status = acpi_ds_method_data_get_entry (opcode, index, walk_state, &entry); if (ACPI_FAILURE (status)) { - return (status); + return_ACPI_STATUS (status); } /* Get the current entry in this slot k */ @@ -549,28 +594,25 @@ */ *entry = NULL; - if ((object) && - (VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_INTERNAL))) - { + (VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_INTERNAL))) { /* * There is a valid object in this slot * Decrement the reference count by one to balance the * increment when the object was stored in the slot. */ - acpi_cm_remove_reference (object); + acpi_ut_remove_reference (object); } - - return (AE_OK); + return_ACPI_STATUS (AE_OK); } /******************************************************************************* * - * FUNCTION: Acpi_ds_method_data_set_value + * FUNCTION: Acpi_ds_store_object_to_local * - * PARAMETERS: Type - Either MTH_TYPE_LOCAL or MTH_TYPE_ARG + * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP * Index - Which local_var or argument to set * Src_desc - Value to be stored * Walk_state - Current walk state @@ -583,32 +625,38 @@ * ******************************************************************************/ -ACPI_STATUS -acpi_ds_method_data_set_value ( - u32 type, +acpi_status +acpi_ds_store_object_to_local ( + u16 opcode, u32 index, - ACPI_OPERAND_OBJECT *src_desc, - ACPI_WALK_STATE *walk_state) + acpi_operand_object *src_desc, + acpi_walk_state *walk_state) { - ACPI_STATUS status; - ACPI_OPERAND_OBJECT **entry; + acpi_status status; + acpi_operand_object **entry; + + + FUNCTION_TRACE ("Ds_method_data_set_value"); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%d Idx=%d Obj=%p\n", + opcode, index, src_desc)); /* Parameter validation */ if (!src_desc) { - return (AE_BAD_PARAMETER); + return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Get a pointer to the requested method stack entry */ - status = acpi_ds_method_data_get_entry (type, index, walk_state, &entry); + status = acpi_ds_method_data_get_entry (opcode, index, walk_state, &entry); if (ACPI_FAILURE (status)) { goto cleanup; } if (*entry == src_desc) { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n", src_desc)); goto cleanup; } @@ -619,7 +667,6 @@ * is an object reference stored there, we have to do * an indirect store! */ - if (*entry) { /* * Check for an indirect store if an argument @@ -637,38 +684,42 @@ * * Weird, but true. */ + if ((opcode == AML_ARG_OP) && + (VALID_DESCRIPTOR_TYPE (*entry, ACPI_DESC_TYPE_NAMED))) { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Arg (%p) is an Obj_ref(Node), storing in %p\n", + src_desc, *entry)); - if ((type == MTH_TYPE_ARG) && - (VALID_DESCRIPTOR_TYPE (*entry, ACPI_DESC_TYPE_NAMED))) - { /* Detach an existing object from the Node */ - acpi_ns_detach_object ((ACPI_NAMESPACE_NODE *) *entry); + acpi_ns_detach_object ((acpi_namespace_node *) *entry); /* * Store this object into the Node * (do the indirect store) */ - status = acpi_ns_attach_object ((ACPI_NAMESPACE_NODE *) *entry, src_desc, + status = acpi_ns_attach_object ((acpi_namespace_node *) *entry, src_desc, src_desc->common.type); - return (status); + return_ACPI_STATUS (status); } +#ifdef ACPI_ENABLE_IMPLICIT_CONVERSION /* * Perform "Implicit conversion" of the new object to the type of the * existing object */ - status = acpi_aml_convert_to_target_type ((*entry)->common.type, &src_desc, walk_state); + status = acpi_ex_convert_to_target_type ((*entry)->common.type, &src_desc, walk_state); if (ACPI_FAILURE (status)) { goto cleanup; } +#endif /* * Delete the existing object * before storing the new one */ - acpi_ds_method_data_delete_value (type, index, walk_state); + acpi_ds_method_data_delete_value (opcode, index, walk_state); } @@ -678,20 +729,20 @@ * Install the new object in the stack entry * (increments the object reference count by one) */ - status = acpi_ds_method_data_set_entry (type, index, src_desc, walk_state); + status = acpi_ds_method_data_set_entry (opcode, index, src_desc, walk_state); if (ACPI_FAILURE (status)) { goto cleanup; } /* Normal exit */ - return (AE_OK); + return_ACPI_STATUS (AE_OK); /* Error exit */ cleanup: - return (status); + return_ACPI_STATUS (status); } Index: dsobject.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/drivers/acpi/dispatcher/dsobject.c,v retrieving revision 1.1.1.2 retrieving revision 1.2 diff -u -r1.1.1.2 -r1.2 --- dsobject.c 25 Feb 2001 23:15:15 -0000 1.1.1.2 +++ dsobject.c 9 Apr 2002 14:05:42 -0000 1.2 @@ -31,7 +31,7 @@ #include "acinterp.h" #include "acnamesp.h" -#define _COMPONENT DISPATCHER +#define _COMPONENT ACPI_DISPATCHER MODULE_NAME ("dsobject") @@ -55,19 +55,22 @@ * ******************************************************************************/ -ACPI_STATUS +acpi_status acpi_ds_init_one_object ( - ACPI_HANDLE obj_handle, + acpi_handle obj_handle, u32 level, void *context, void **return_value) { - OBJECT_TYPE_INTERNAL type; - ACPI_STATUS status; - ACPI_INIT_WALK_INFO *info = (ACPI_INIT_WALK_INFO *) context; + acpi_object_type8 type; + acpi_status status; + acpi_init_walk_info *info = (acpi_init_walk_info *) context; u8 table_revision; + PROC_NAME ("Ds_init_one_object"); + + info->object_count++; table_revision = info->table_desc->pointer->revision; @@ -75,10 +78,8 @@ * We are only interested in objects owned by the table that * was just loaded */ - - if (((ACPI_NAMESPACE_NODE *) obj_handle)->owner_id != - info->table_desc->table_id) - { + if (((acpi_namespace_node *) obj_handle)->owner_id != + info->table_desc->table_id) { return (AE_OK); } @@ -87,8 +88,7 @@ type = acpi_ns_get_type (obj_handle); - switch (type) - { + switch (type) { case ACPI_TYPE_REGION: @@ -102,26 +102,30 @@ info->method_count++; + if (!(acpi_dbg_level & ACPI_LV_INIT)) { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, ".")); + } /* * Set the execution data width (32 or 64) based upon the * revision number of the parent ACPI table. */ - if (table_revision == 1) { - ((ACPI_NAMESPACE_NODE *)obj_handle)->flags |= ANOBJ_DATA_WIDTH_32; + ((acpi_namespace_node *)obj_handle)->flags |= ANOBJ_DATA_WIDTH_32; } /* * Always parse methods to detect errors, we may delete * the parse tree below */ - status = acpi_ds_parse_method (obj_handle); + if (ACPI_FAILURE (status)) { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Method %p [%4.4s] - parse failure, %s\n", + obj_handle, (char*)&((acpi_namespace_node *)obj_handle)->name, + acpi_format_exception (status))); - /* TBD: [Errors] what do we do with an error? */ + /* This parse failed, but we will continue parsing more methods */ - if (ACPI_FAILURE (status)) { break; } @@ -157,13 +161,21 @@ * ******************************************************************************/ -ACPI_STATUS +acpi_status acpi_ds_initialize_objects ( - ACPI_TABLE_DESC *table_desc, - ACPI_NAMESPACE_NODE *start_node) + acpi_table_desc *table_desc, + acpi_namespace_node *start_node) { - ACPI_STATUS status; - ACPI_INIT_WALK_INFO in... [truncated message content] |