diff options
Diffstat (limited to 'drivers/acpi/dispatcher/dsopcode.c')
-rw-r--r-- | drivers/acpi/dispatcher/dsopcode.c | 710 |
1 files changed, 344 insertions, 366 deletions
diff --git a/drivers/acpi/dispatcher/dsopcode.c b/drivers/acpi/dispatcher/dsopcode.c index 750bdb1..939d167 100644 --- a/drivers/acpi/dispatcher/dsopcode.c +++ b/drivers/acpi/dispatcher/dsopcode.c @@ -42,7 +42,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include <acpi/acpi.h> #include <acpi/acparser.h> #include <acpi/amlcode.h> @@ -52,26 +51,21 @@ #include <acpi/acevents.h> #define _COMPONENT ACPI_DISPATCHER - ACPI_MODULE_NAME ("dsopcode") +ACPI_MODULE_NAME("dsopcode") /* Local prototypes */ - static acpi_status -acpi_ds_execute_arguments ( - struct acpi_namespace_node *node, - struct acpi_namespace_node *scope_node, - u32 aml_length, - u8 *aml_start); +acpi_ds_execute_arguments(struct acpi_namespace_node *node, + struct acpi_namespace_node *scope_node, + u32 aml_length, u8 * aml_start); static acpi_status -acpi_ds_init_buffer_field ( - u16 aml_opcode, - union acpi_operand_object *obj_desc, - union acpi_operand_object *buffer_desc, - union acpi_operand_object *offset_desc, - union acpi_operand_object *length_desc, - union acpi_operand_object *result_desc); - +acpi_ds_init_buffer_field(u16 aml_opcode, + union acpi_operand_object *obj_desc, + union acpi_operand_object *buffer_desc, + union acpi_operand_object *offset_desc, + union acpi_operand_object *length_desc, + union acpi_operand_object *result_desc); /******************************************************************************* * @@ -89,26 +83,22 @@ acpi_ds_init_buffer_field ( ******************************************************************************/ static acpi_status -acpi_ds_execute_arguments ( - struct acpi_namespace_node *node, - struct acpi_namespace_node *scope_node, - u32 aml_length, - u8 *aml_start) +acpi_ds_execute_arguments(struct acpi_namespace_node *node, + struct acpi_namespace_node *scope_node, + u32 aml_length, u8 * aml_start) { - acpi_status status; - union acpi_parse_object *op; - struct acpi_walk_state *walk_state; - - - ACPI_FUNCTION_TRACE ("ds_execute_arguments"); + acpi_status status; + union acpi_parse_object *op; + struct acpi_walk_state *walk_state; + ACPI_FUNCTION_TRACE("ds_execute_arguments"); /* * Allocate a new parser op to be the root of the parsed tree */ - op = acpi_ps_alloc_op (AML_INT_EVAL_SUBTREE_OP); + op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP); if (!op) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } /* Save the Node for use in acpi_ps_parse_aml */ @@ -117,16 +107,16 @@ acpi_ds_execute_arguments ( /* Create and initialize a new parser state */ - walk_state = acpi_ds_create_walk_state (0, NULL, NULL, NULL); + walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL); if (!walk_state) { status = AE_NO_MEMORY; goto cleanup; } - status = acpi_ds_init_aml_walk (walk_state, op, NULL, aml_start, - aml_length, NULL, 1); - if (ACPI_FAILURE (status)) { - acpi_ds_delete_walk_state (walk_state); + status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start, + aml_length, NULL, 1); + if (ACPI_FAILURE(status)) { + acpi_ds_delete_walk_state(walk_state); goto cleanup; } @@ -137,28 +127,28 @@ acpi_ds_execute_arguments ( /* Pass1: Parse the entire declaration */ - status = acpi_ps_parse_aml (walk_state); - if (ACPI_FAILURE (status)) { + status = acpi_ps_parse_aml(walk_state); + if (ACPI_FAILURE(status)) { goto cleanup; } /* Get and init the Op created above */ op->common.node = node; - acpi_ps_delete_parse_tree (op); + acpi_ps_delete_parse_tree(op); /* Evaluate the deferred arguments */ - op = acpi_ps_alloc_op (AML_INT_EVAL_SUBTREE_OP); + op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP); if (!op) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } op->common.node = scope_node; /* Create and initialize a new parser state */ - walk_state = acpi_ds_create_walk_state (0, NULL, NULL, NULL); + walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL); if (!walk_state) { status = AE_NO_MEMORY; goto cleanup; @@ -166,24 +156,23 @@ acpi_ds_execute_arguments ( /* Execute the opcode and arguments */ - status = acpi_ds_init_aml_walk (walk_state, op, NULL, aml_start, - aml_length, NULL, 3); - if (ACPI_FAILURE (status)) { - acpi_ds_delete_walk_state (walk_state); + status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start, + aml_length, NULL, 3); + if (ACPI_FAILURE(status)) { + acpi_ds_delete_walk_state(walk_state); goto cleanup; } /* Mark this execution as a deferred opcode */ walk_state->deferred_node = node; - status = acpi_ps_parse_aml (walk_state); + status = acpi_ps_parse_aml(walk_state); -cleanup: - acpi_ps_delete_parse_tree (op); - return_ACPI_STATUS (status); + cleanup: + acpi_ps_delete_parse_tree(op); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_get_buffer_field_arguments @@ -198,38 +187,36 @@ cleanup: ******************************************************************************/ acpi_status -acpi_ds_get_buffer_field_arguments ( - union acpi_operand_object *obj_desc) +acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc) { - union acpi_operand_object *extra_desc; - struct acpi_namespace_node *node; - acpi_status status; - - - ACPI_FUNCTION_TRACE_PTR ("ds_get_buffer_field_arguments", obj_desc); + union acpi_operand_object *extra_desc; + struct acpi_namespace_node *node; + acpi_status status; + ACPI_FUNCTION_TRACE_PTR("ds_get_buffer_field_arguments", obj_desc); if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Get the AML pointer (method object) and buffer_field node */ - extra_desc = acpi_ns_get_secondary_object (obj_desc); + extra_desc = acpi_ns_get_secondary_object(obj_desc); node = obj_desc->buffer_field.node; - ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname (ACPI_TYPE_BUFFER_FIELD, node, NULL)); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] buffer_field Arg Init\n", - acpi_ut_get_node_name (node))); + ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname + (ACPI_TYPE_BUFFER_FIELD, node, NULL)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] buffer_field Arg Init\n", + acpi_ut_get_node_name(node))); /* Execute the AML code for the term_arg arguments */ - status = acpi_ds_execute_arguments (node, acpi_ns_get_parent_node (node), - extra_desc->extra.aml_length, extra_desc->extra.aml_start); - return_ACPI_STATUS (status); + status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node), + extra_desc->extra.aml_length, + extra_desc->extra.aml_start); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_get_buffer_arguments @@ -243,40 +230,35 @@ acpi_ds_get_buffer_field_arguments ( * ******************************************************************************/ -acpi_status -acpi_ds_get_buffer_arguments ( - union acpi_operand_object *obj_desc) +acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc) { - struct acpi_namespace_node *node; - acpi_status status; - - - ACPI_FUNCTION_TRACE_PTR ("ds_get_buffer_arguments", obj_desc); + struct acpi_namespace_node *node; + acpi_status status; + ACPI_FUNCTION_TRACE_PTR("ds_get_buffer_arguments", obj_desc); if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Get the Buffer node */ node = obj_desc->buffer.node; if (!node) { - ACPI_REPORT_ERROR (( - "No pointer back to NS node in buffer obj %p\n", obj_desc)); - return_ACPI_STATUS (AE_AML_INTERNAL); + ACPI_REPORT_ERROR(("No pointer back to NS node in buffer obj %p\n", obj_desc)); + return_ACPI_STATUS(AE_AML_INTERNAL); } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer Arg Init\n")); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Buffer Arg Init\n")); /* Execute the AML code for the term_arg arguments */ - status = acpi_ds_execute_arguments (node, node, - obj_desc->buffer.aml_length, obj_desc->buffer.aml_start); - return_ACPI_STATUS (status); + status = acpi_ds_execute_arguments(node, node, + obj_desc->buffer.aml_length, + obj_desc->buffer.aml_start); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_get_package_arguments @@ -290,40 +272,36 @@ acpi_ds_get_buffer_arguments ( * ******************************************************************************/ -acpi_status -acpi_ds_get_package_arguments ( - union acpi_operand_object *obj_desc) +acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc) { - struct acpi_namespace_node *node; - acpi_status status; - - - ACPI_FUNCTION_TRACE_PTR ("ds_get_package_arguments", obj_desc); + struct acpi_namespace_node *node; + acpi_status status; + ACPI_FUNCTION_TRACE_PTR("ds_get_package_arguments", obj_desc); if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } /* Get the Package node */ node = obj_desc->package.node; if (!node) { - ACPI_REPORT_ERROR (( - "No pointer back to NS node in package %p\n", obj_desc)); - return_ACPI_STATUS (AE_AML_INTERNAL); + ACPI_REPORT_ERROR(("No pointer back to NS node in package %p\n", + obj_desc)); + return_ACPI_STATUS(AE_AML_INTERNAL); } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package Arg Init\n")); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Package Arg Init\n")); /* Execute the AML code for the term_arg arguments */ - status = acpi_ds_execute_arguments (node, node, - obj_desc->package.aml_length, obj_desc->package.aml_start); - return_ACPI_STATUS (status); + status = acpi_ds_execute_arguments(node, node, + obj_desc->package.aml_length, + obj_desc->package.aml_start); + return_ACPI_STATUS(status); } - /***************************************************************************** * * FUNCTION: acpi_ds_get_region_arguments @@ -337,44 +315,43 @@ acpi_ds_get_package_arguments ( * ****************************************************************************/ -acpi_status -acpi_ds_get_region_arguments ( - union acpi_operand_object *obj_desc) +acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *obj_desc) { - struct acpi_namespace_node *node; - acpi_status status; - union acpi_operand_object *extra_desc; - - - ACPI_FUNCTION_TRACE_PTR ("ds_get_region_arguments", obj_desc); + struct acpi_namespace_node *node; + acpi_status status; + union acpi_operand_object *extra_desc; + ACPI_FUNCTION_TRACE_PTR("ds_get_region_arguments", obj_desc); if (obj_desc->region.flags & AOPOBJ_DATA_VALID) { - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } - extra_desc = acpi_ns_get_secondary_object (obj_desc); + extra_desc = acpi_ns_get_secondary_object(obj_desc); if (!extra_desc) { - return_ACPI_STATUS (AE_NOT_EXIST); + return_ACPI_STATUS(AE_NOT_EXIST); } /* Get the Region node */ node = obj_desc->region.node; - ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_REGION, node, NULL)); + ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname + (ACPI_TYPE_REGION, node, NULL)); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] op_region Arg Init at AML %p\n", - acpi_ut_get_node_name (node), extra_desc->extra.aml_start)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, + "[%4.4s] op_region Arg Init at AML %p\n", + acpi_ut_get_node_name(node), + extra_desc->extra.aml_start)); /* Execute the argument AML */ - status = acpi_ds_execute_arguments (node, acpi_ns_get_parent_node (node), - extra_desc->extra.aml_length, extra_desc->extra.aml_start); - return_ACPI_STATUS (status); + status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node), + extra_desc->extra.aml_length, + extra_desc->extra.aml_start); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_initialize_region @@ -387,23 +364,19 @@ acpi_ds_get_region_arguments ( * ******************************************************************************/ -acpi_status -acpi_ds_initialize_region ( - acpi_handle obj_handle) +acpi_status acpi_ds_initialize_region(acpi_handle obj_handle) { - union acpi_operand_object *obj_desc; - acpi_status status; + union acpi_operand_object *obj_desc; + acpi_status status; - - obj_desc = acpi_ns_get_attached_object (obj_handle); + obj_desc = acpi_ns_get_attached_object(obj_handle); /* Namespace is NOT locked */ - status = acpi_ev_initialize_region (obj_desc, FALSE); + status = acpi_ev_initialize_region(obj_desc, FALSE); return (status); } - /******************************************************************************* * * FUNCTION: acpi_ds_init_buffer_field @@ -422,30 +395,27 @@ acpi_ds_initialize_region ( ******************************************************************************/ static acpi_status -acpi_ds_init_buffer_field ( - u16 aml_opcode, - union acpi_operand_object *obj_desc, - union acpi_operand_object *buffer_desc, - union acpi_operand_object *offset_desc, - union acpi_operand_object *length_desc, - union acpi_operand_object *result_desc) +acpi_ds_init_buffer_field(u16 aml_opcode, + union acpi_operand_object *obj_desc, + union acpi_operand_object *buffer_desc, + union acpi_operand_object *offset_desc, + union acpi_operand_object *length_desc, + union acpi_operand_object *result_desc) { - u32 offset; - u32 bit_offset; - u32 bit_count; - u8 field_flags; - acpi_status status; - - - ACPI_FUNCTION_TRACE_PTR ("ds_init_buffer_field", obj_desc); + u32 offset; + u32 bit_offset; + u32 bit_count; + u8 field_flags; + acpi_status status; + ACPI_FUNCTION_TRACE_PTR("ds_init_buffer_field", obj_desc); /* Host object must be a Buffer */ - if (ACPI_GET_OBJECT_TYPE (buffer_desc) != ACPI_TYPE_BUFFER) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Target of Create Field is not a Buffer object - %s\n", - acpi_ut_get_object_type_name (buffer_desc))); + if (ACPI_GET_OBJECT_TYPE(buffer_desc) != ACPI_TYPE_BUFFER) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Target of Create Field is not a Buffer object - %s\n", + acpi_ut_get_object_type_name(buffer_desc))); status = AE_AML_OPERAND_TYPE; goto cleanup; @@ -456,11 +426,11 @@ acpi_ds_init_buffer_field ( * out as a name_string, and should therefore now be a NS node * after resolution in acpi_ex_resolve_operands(). */ - if (ACPI_GET_DESCRIPTOR_TYPE (result_desc) != ACPI_DESC_TYPE_NAMED) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "(%s) destination not a NS Node [%s]\n", - acpi_ps_get_opcode_name (aml_opcode), - acpi_ut_get_descriptor_name (result_desc))); + if (ACPI_GET_DESCRIPTOR_TYPE(result_desc) != ACPI_DESC_TYPE_NAMED) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "(%s) destination not a NS Node [%s]\n", + acpi_ps_get_opcode_name(aml_opcode), + acpi_ut_get_descriptor_name(result_desc))); status = AE_AML_OPERAND_TYPE; goto cleanup; @@ -478,13 +448,13 @@ acpi_ds_init_buffer_field ( field_flags = AML_FIELD_ACCESS_BYTE; bit_offset = offset; - bit_count = (u32) length_desc->integer.value; + bit_count = (u32) length_desc->integer.value; /* Must have a valid (>0) bit count */ if (bit_count == 0) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Attempt to create_field of length 0\n")); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Attempt to create_field of length 0\n")); status = AE_AML_OPERAND_VALUE; goto cleanup; } @@ -495,7 +465,7 @@ acpi_ds_init_buffer_field ( /* Offset is in bits, Field is one bit */ bit_offset = offset; - bit_count = 1; + bit_count = 1; field_flags = AML_FIELD_ACCESS_BYTE; break; @@ -504,7 +474,7 @@ acpi_ds_init_buffer_field ( /* Offset is in bytes, field is one byte */ bit_offset = 8 * offset; - bit_count = 8; + bit_count = 8; field_flags = AML_FIELD_ACCESS_BYTE; break; @@ -513,7 +483,7 @@ acpi_ds_init_buffer_field ( /* Offset is in bytes, field is one word */ bit_offset = 8 * offset; - bit_count = 16; + bit_count = 16; field_flags = AML_FIELD_ACCESS_WORD; break; @@ -522,7 +492,7 @@ acpi_ds_init_buffer_field ( /* Offset is in bytes, field is one dword */ bit_offset = 8 * offset; - bit_count = 32; + bit_count = 32; field_flags = AML_FIELD_ACCESS_DWORD; break; @@ -531,29 +501,29 @@ acpi_ds_init_buffer_field ( /* Offset is in bytes, field is one qword */ bit_offset = 8 * offset; - bit_count = 64; + bit_count = 64; field_flags = AML_FIELD_ACCESS_QWORD; break; default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unknown field creation opcode %02x\n", - aml_opcode)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unknown field creation opcode %02x\n", + aml_opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } /* Entire field must fit within the current length of the buffer */ - if ((bit_offset + bit_count) > - (8 * (u32) buffer_desc->buffer.length)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Field [%4.4s] size %d exceeds Buffer [%4.4s] size %d (bits)\n", - acpi_ut_get_node_name (result_desc), - bit_offset + bit_count, - acpi_ut_get_node_name (buffer_desc->buffer.node), - 8 * (u32) buffer_desc->buffer.length)); + if ((bit_offset + bit_count) > (8 * (u32) buffer_desc->buffer.length)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Field [%4.4s] size %d exceeds Buffer [%4.4s] size %d (bits)\n", + acpi_ut_get_node_name(result_desc), + bit_offset + bit_count, + acpi_ut_get_node_name(buffer_desc->buffer. + node), + 8 * (u32) buffer_desc->buffer.length)); status = AE_AML_BUFFER_LIMIT; goto cleanup; } @@ -563,9 +533,9 @@ acpi_ds_init_buffer_field ( * For field_flags, use LOCK_RULE = 0 (NO_LOCK), * UPDATE_RULE = 0 (UPDATE_PRESERVE) */ - status = acpi_ex_prep_common_field_object (obj_desc, field_flags, 0, - bit_offset, bit_count); - if (ACPI_FAILURE (status)) { + status = acpi_ex_prep_common_field_object(obj_desc, field_flags, 0, + bit_offset, bit_count); + if (ACPI_FAILURE(status)) { goto cleanup; } @@ -574,35 +544,33 @@ acpi_ds_init_buffer_field ( /* Reference count for buffer_desc inherits obj_desc count */ buffer_desc->common.reference_count = (u16) - (buffer_desc->common.reference_count + obj_desc->common.reference_count); + (buffer_desc->common.reference_count + + obj_desc->common.reference_count); - -cleanup: + cleanup: /* Always delete the operands */ - acpi_ut_remove_reference (offset_desc); - acpi_ut_remove_reference (buffer_desc); + acpi_ut_remove_reference(offset_desc); + acpi_ut_remove_reference(buffer_desc); if (aml_opcode == AML_CREATE_FIELD_OP) { - acpi_ut_remove_reference (length_desc); + acpi_ut_remove_reference(length_desc); } /* On failure, delete the result descriptor */ - if (ACPI_FAILURE (status)) { - acpi_ut_remove_reference (result_desc); /* Result descriptor */ - } - else { + if (ACPI_FAILURE(status)) { + acpi_ut_remove_reference(result_desc); /* Result descriptor */ + } else { /* Now the address and length are valid for this buffer_field */ obj_desc->buffer_field.flags |= AOPOBJ_DATA_VALID; } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_eval_buffer_field_operands @@ -618,24 +586,21 @@ cleanup: ******************************************************************************/ acpi_status -acpi_ds_eval_buffer_field_operands ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op) +acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state, + union acpi_parse_object *op) { - acpi_status status; - union acpi_operand_object *obj_desc; - struct acpi_namespace_node *node; - union acpi_parse_object *next_op; - - - ACPI_FUNCTION_TRACE_PTR ("ds_eval_buffer_field_operands", op); + acpi_status status; + union acpi_operand_object *obj_desc; + struct acpi_namespace_node *node; + union acpi_parse_object *next_op; + ACPI_FUNCTION_TRACE_PTR("ds_eval_buffer_field_operands", op); /* * This is where we evaluate the address and length fields of the * create_xxx_field declaration */ - node = op->common.node; + node = op->common.node; /* next_op points to the op that holds the Buffer */ @@ -643,30 +608,32 @@ acpi_ds_eval_buffer_field_operands ( /* Evaluate/create the address and length operands */ - status = acpi_ds_create_operands (walk_state, next_op); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ds_create_operands(walk_state, next_op); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - obj_desc = acpi_ns_get_attached_object (node); + obj_desc = acpi_ns_get_attached_object(node); if (!obj_desc) { - return_ACPI_STATUS (AE_NOT_EXIST); + return_ACPI_STATUS(AE_NOT_EXIST); } /* Resolve the operands */ - status = acpi_ex_resolve_operands (op->common.aml_opcode, - ACPI_WALK_OPERANDS, walk_state); + status = acpi_ex_resolve_operands(op->common.aml_opcode, + ACPI_WALK_OPERANDS, walk_state); - ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, - acpi_ps_get_opcode_name (op->common.aml_opcode), - walk_state->num_operands, "after acpi_ex_resolve_operands"); + ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, + acpi_ps_get_opcode_name(op->common.aml_opcode), + walk_state->num_operands, + "after acpi_ex_resolve_operands"); - if (ACPI_FAILURE (status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) bad operand(s) (%X)\n", - acpi_ps_get_opcode_name (op->common.aml_opcode), status)); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "(%s) bad operand(s) (%X)\n", + acpi_ps_get_opcode_name(op->common. + aml_opcode), status)); - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } /* Initialize the Buffer Field */ @@ -674,22 +641,25 @@ acpi_ds_eval_buffer_field_operands ( if (op->common.aml_opcode == AML_CREATE_FIELD_OP) { /* NOTE: Slightly different operands for this opcode */ - status = acpi_ds_init_buffer_field (op->common.aml_opcode, obj_desc, - walk_state->operands[0], walk_state->operands[1], - walk_state->operands[2], walk_state->operands[3]); - } - else { + status = + acpi_ds_init_buffer_field(op->common.aml_opcode, obj_desc, + walk_state->operands[0], + walk_state->operands[1], + walk_state->operands[2], + walk_state->operands[3]); + } else { /* All other, create_xxx_field opcodes */ - status = acpi_ds_init_buffer_field (op->common.aml_opcode, obj_desc, - walk_state->operands[0], walk_state->operands[1], - NULL, walk_state->operands[2]); + status = + acpi_ds_init_buffer_field(op->common.aml_opcode, obj_desc, + walk_state->operands[0], + walk_state->operands[1], NULL, + walk_state->operands[2]); } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_eval_region_operands @@ -705,25 +675,22 @@ acpi_ds_eval_buffer_field_operands ( ******************************************************************************/ acpi_status -acpi_ds_eval_region_operands ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op) +acpi_ds_eval_region_operands(struct acpi_walk_state *walk_state, + union acpi_parse_object *op) { - acpi_status status; - union acpi_operand_object *obj_desc; - union acpi_operand_object *operand_desc; - struct acpi_namespace_node *node; - union acpi_parse_object *next_op; - - - ACPI_FUNCTION_TRACE_PTR ("ds_eval_region_operands", op); + acpi_status status; + union acpi_operand_object *obj_desc; + union acpi_operand_object *operand_desc; + struct acpi_namespace_node *node; + union acpi_parse_object *next_op; + ACPI_FUNCTION_TRACE_PTR("ds_eval_region_operands", op); /* * This is where we evaluate the address and length fields of the * op_region declaration */ - node = op->common.node; + node = op->common.node; /* next_op points to the op that holds the space_iD */ @@ -735,26 +702,26 @@ acpi_ds_eval_region_operands ( /* Evaluate/create the address and length operands */ - status = acpi_ds_create_operands (walk_state, next_op); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ds_create_operands(walk_state, next_op); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Resolve the length and address operands to numbers */ - status = acpi_ex_resolve_operands (op->common.aml_opcode, - ACPI_WALK_OPERANDS, walk_state); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ex_resolve_operands(op->common.aml_opcode, + ACPI_WALK_OPERANDS, walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, - acpi_ps_get_opcode_name (op->common.aml_opcode), - 1, "after acpi_ex_resolve_operands"); + ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, + acpi_ps_get_opcode_name(op->common.aml_opcode), + 1, "after acpi_ex_resolve_operands"); - obj_desc = acpi_ns_get_attached_object (node); + obj_desc = acpi_ns_get_attached_object(node); if (!obj_desc) { - return_ACPI_STATUS (AE_NOT_EXIST); + return_ACPI_STATUS(AE_NOT_EXIST); } /* @@ -764,7 +731,7 @@ acpi_ds_eval_region_operands ( operand_desc = walk_state->operands[walk_state->num_operands - 1]; obj_desc->region.length = (u32) operand_desc->integer.value; - acpi_ut_remove_reference (operand_desc); + acpi_ut_remove_reference(operand_desc); /* * Get the address and save it @@ -773,22 +740,21 @@ acpi_ds_eval_region_operands ( operand_desc = walk_state->operands[walk_state->num_operands - 2]; obj_desc->region.address = (acpi_physical_address) - operand_desc->integer.value; - acpi_ut_remove_reference (operand_desc); + operand_desc->integer.value; + acpi_ut_remove_reference(operand_desc); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "rgn_obj %p Addr %8.8X%8.8X Len %X\n", - obj_desc, - ACPI_FORMAT_UINT64 (obj_desc->region.address), - obj_desc->region.length)); + ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "rgn_obj %p Addr %8.8X%8.8X Len %X\n", + obj_desc, + ACPI_FORMAT_UINT64(obj_desc->region.address), + obj_desc->region.length)); /* Now the address and length are valid for this opregion */ obj_desc->region.flags |= AOPOBJ_DATA_VALID; - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_eval_data_object_operands @@ -805,46 +771,44 @@ acpi_ds_eval_region_operands ( ******************************************************************************/ acpi_status -acpi_ds_eval_data_object_operands ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op, - union acpi_operand_object *obj_desc) +acpi_ds_eval_data_object_operands(struct acpi_walk_state *walk_state, + union acpi_parse_object *op, + union acpi_operand_object *obj_desc) { - acpi_status status; - union acpi_operand_object *arg_desc; - u32 length; - - - ACPI_FUNCTION_TRACE ("ds_eval_data_object_operands"); + acpi_status status; + union acpi_operand_object *arg_desc; + u32 length; + ACPI_FUNCTION_TRACE("ds_eval_data_object_operands"); /* The first operand (for all of these data objects) is the length */ - status = acpi_ds_create_operand (walk_state, op->common.value.arg, 1); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ds_create_operand(walk_state, op->common.value.arg, 1); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - status = acpi_ex_resolve_operands (walk_state->opcode, - &(walk_state->operands [walk_state->num_operands -1]), - walk_state); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ex_resolve_operands(walk_state->opcode, + &(walk_state-> + operands[walk_state->num_operands - + 1]), walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Extract length operand */ - arg_desc = walk_state->operands [walk_state->num_operands - 1]; + arg_desc = walk_state->operands[walk_state->num_operands - 1]; length = (u32) arg_desc->integer.value; /* Cleanup for length operand */ - status = acpi_ds_obj_stack_pop (1, walk_state); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_ds_obj_stack_pop(1, walk_state); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - acpi_ut_remove_reference (arg_desc); + acpi_ut_remove_reference(arg_desc); /* * Create the actual data object @@ -852,37 +816,42 @@ acpi_ds_eval_data_object_operands ( switch (op->common.aml_opcode) { case AML_BUFFER_OP: - status = acpi_ds_build_internal_buffer_obj (walk_state, op, length, &obj_desc); + status = + acpi_ds_build_internal_buffer_obj(walk_state, op, length, + &obj_desc); break; case AML_PACKAGE_OP: case AML_VAR_PACKAGE_OP: - status = acpi_ds_build_internal_package_obj (walk_state, op, length, &obj_desc); + status = + acpi_ds_build_internal_package_obj(walk_state, op, length, + &obj_desc); break; default: - return_ACPI_STATUS (AE_AML_BAD_OPCODE); + return_ACPI_STATUS(AE_AML_BAD_OPCODE); } - if (ACPI_SUCCESS (status)) { + if (ACPI_SUCCESS(status)) { /* * Return the object in the walk_state, unless the parent is a package - * in this case, the return object will be stored in the parse tree * for the package. */ if ((!op->common.parent) || - ((op->common.parent->common.aml_opcode != AML_PACKAGE_OP) && - (op->common.parent->common.aml_opcode != AML_VAR_PACKAGE_OP) && - (op->common.parent->common.aml_opcode != AML_NAME_OP))) { + ((op->common.parent->common.aml_opcode != AML_PACKAGE_OP) && + (op->common.parent->common.aml_opcode != + AML_VAR_PACKAGE_OP) + && (op->common.parent->common.aml_opcode != + AML_NAME_OP))) { walk_state->result_obj = obj_desc; } } - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_ds_exec_begin_control_op @@ -898,19 +867,16 @@ acpi_ds_eval_data_object_operands ( ******************************************************************************/ acpi_status -acpi_ds_exec_begin_control_op ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op) +acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state, + union acpi_parse_object *op) { - acpi_status status = AE_OK; - union acpi_generic_state *control_state; - - - ACPI_FUNCTION_NAME ("ds_exec_begin_control_op"); + acpi_status status = AE_OK; + union acpi_generic_state *control_state; + ACPI_FUNCTION_NAME("ds_exec_begin_control_op"); - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", op, - op->common.aml_opcode, walk_state)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", op, + op->common.aml_opcode, walk_state)); switch (op->common.aml_opcode) { case AML_IF_OP: @@ -921,7 +887,7 @@ acpi_ds_exec_begin_control_op ( * constructs. We need to manage these as a stack, in order * to handle nesting. */ - control_state = acpi_ut_create_control_state (); + control_state = acpi_ut_create_control_state(); if (!control_state) { status = AE_NO_MEMORY; break; @@ -930,14 +896,16 @@ acpi_ds_exec_begin_control_op ( * Save a pointer to the predicate for multiple executions * of a loop */ - control_state->control.aml_predicate_start = walk_state->parser_state.aml - 1; - control_state->control.package_end = walk_state->parser_state.pkg_end; + control_state->control.aml_predicate_start = + walk_state->parser_state.aml - 1; + control_state->control.package_end = + walk_state->parser_state.pkg_end; control_state->control.opcode = op->common.aml_opcode; - /* Push the control state on this walk's control stack */ - acpi_ut_push_generic_state (&walk_state->control_state, control_state); + acpi_ut_push_generic_state(&walk_state->control_state, + control_state); break; case AML_ELSE_OP: @@ -962,7 +930,6 @@ acpi_ds_exec_begin_control_op ( return (status); } - /******************************************************************************* * * FUNCTION: acpi_ds_exec_end_control_op @@ -978,46 +945,42 @@ acpi_ds_exec_begin_control_op ( ******************************************************************************/ acpi_status -acpi_ds_exec_end_control_op ( - struct acpi_walk_state *walk_state, - union acpi_parse_object *op) +acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state, + union acpi_parse_object * op) { - acpi_status status = AE_OK; - union acpi_generic_state *control_state; - - - ACPI_FUNCTION_NAME ("ds_exec_end_control_op"); + acpi_status status = AE_OK; + union acpi_generic_state *control_state; + ACPI_FUNCTION_NAME("ds_exec_end_control_op"); switch (op->common.aml_opcode) { case AML_IF_OP: - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", op)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", op)); /* * Save the result of the predicate in case there is an * ELSE to come */ walk_state->last_predicate = - (u8) walk_state->control_state->common.value; + (u8) walk_state->control_state->common.value; /* * Pop the control state that was created at the start * of the IF and free it */ - control_state = acpi_ut_pop_generic_state (&walk_state->control_state); - acpi_ut_delete_generic_state (control_state); + control_state = + acpi_ut_pop_generic_state(&walk_state->control_state); + acpi_ut_delete_generic_state(control_state); break; - case AML_ELSE_OP: break; - case AML_WHILE_OP: - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", op)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", op)); if (walk_state->control_state->common.value) { /* Predicate was true, go back and evaluate it again! */ @@ -1025,22 +988,24 @@ acpi_ds_exec_end_control_op ( status = AE_CTRL_PENDING; } - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "[WHILE_OP] termination! Op=%p\n",op)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "[WHILE_OP] termination! Op=%p\n", op)); /* Pop this control state and free it */ - control_state = acpi_ut_pop_generic_state (&walk_state->control_state); + control_state = + acpi_ut_pop_generic_state(&walk_state->control_state); - walk_state->aml_last_while = control_state->control.aml_predicate_start; - acpi_ut_delete_generic_state (control_state); + walk_state->aml_last_while = + control_state->control.aml_predicate_start; + acpi_ut_delete_generic_state(control_state); break; - case AML_RETURN_OP: - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "[RETURN_OP] Op=%p Arg=%p\n",op, op->common.value.arg)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "[RETURN_OP] Op=%p Arg=%p\n", op, + op->common.value.arg)); /* * One optional operand -- the return value @@ -1050,12 +1015,14 @@ acpi_ds_exec_end_control_op ( if (op->common.value.arg) { /* Since we have a real Return(), delete any implicit return */ - acpi_ds_clear_implicit_return (walk_state); + acpi_ds_clear_implicit_return(walk_state); /* Return statement has an immediate operand */ - status = acpi_ds_create_operands (walk_state, op->common.value.arg); - if (ACPI_FAILURE (status)) { + status = + acpi_ds_create_operands(walk_state, + op->common.value.arg); + if (ACPI_FAILURE(status)) { return (status); } @@ -1064,8 +1031,10 @@ acpi_ds_exec_end_control_op ( * an arg or local), resolve it now because it may * cease to exist at the end of the method. */ - status = acpi_ex_resolve_to_value (&walk_state->operands [0], walk_state); - if (ACPI_FAILURE (status)) { + status = + acpi_ex_resolve_to_value(&walk_state->operands[0], + walk_state); + if (ACPI_FAILURE(status)) { return (status); } @@ -1075,12 +1044,11 @@ acpi_ds_exec_end_control_op ( * is set to anything other than zero! */ walk_state->return_desc = walk_state->operands[0]; - } - else if ((walk_state->results) && - (walk_state->results->results.num_results > 0)) { + } else if ((walk_state->results) && + (walk_state->results->results.num_results > 0)) { /* Since we have a real Return(), delete any implicit return */ - acpi_ds_clear_implicit_return (walk_state); + acpi_ds_clear_implicit_return(walk_state); /* * The return value has come from a previous calculation. @@ -1091,67 +1059,78 @@ acpi_ds_exec_end_control_op ( * * Allow references created by the Index operator to return unchanged. */ - if ((ACPI_GET_DESCRIPTOR_TYPE (walk_state->results->results.obj_desc[0]) == ACPI_DESC_TYPE_OPERAND) && - (ACPI_GET_OBJECT_TYPE (walk_state->results->results.obj_desc [0]) == ACPI_TYPE_LOCAL_REFERENCE) && - ((walk_state->results->results.obj_desc [0])->reference.opcode != AML_INDEX_OP)) { - status = acpi_ex_resolve_to_value (&walk_state->results->results.obj_desc [0], walk_state); - if (ACPI_FAILURE (status)) { + if ((ACPI_GET_DESCRIPTOR_TYPE + (walk_state->results->results.obj_desc[0]) == + ACPI_DESC_TYPE_OPERAND) + && + (ACPI_GET_OBJECT_TYPE + (walk_state->results->results.obj_desc[0]) == + ACPI_TYPE_LOCAL_REFERENCE) + && ((walk_state->results->results.obj_desc[0])-> + reference.opcode != AML_INDEX_OP)) { + status = + acpi_ex_resolve_to_value(&walk_state-> + results->results. + obj_desc[0], + walk_state); + if (ACPI_FAILURE(status)) { return (status); } } - walk_state->return_desc = walk_state->results->results.obj_desc [0]; - } - else { + walk_state->return_desc = + walk_state->results->results.obj_desc[0]; + } else { /* No return operand */ if (walk_state->num_operands) { - acpi_ut_remove_reference (walk_state->operands [0]); + acpi_ut_remove_reference(walk_state-> + operands[0]); } - walk_state->operands [0] = NULL; - walk_state->num_operands = 0; - walk_state->return_desc = NULL; + walk_state->operands[0] = NULL; + walk_state->num_operands = 0; + walk_state->return_desc = NULL; } - - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "Completed RETURN_OP State=%p, ret_val=%p\n", - walk_state, walk_state->return_desc)); + ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, + "Completed RETURN_OP State=%p, ret_val=%p\n", + walk_state, walk_state->return_desc)); /* End the control method execution right now */ status = AE_CTRL_TERMINATE; break; - case AML_NOOP_OP: /* Just do nothing! */ break; - case AML_BREAK_POINT_OP: /* Call up to the OS service layer to handle this */ - status = acpi_os_signal (ACPI_SIGNAL_BREAKPOINT, "Executed AML Breakpoint opcode"); + status = + acpi_os_signal(ACPI_SIGNAL_BREAKPOINT, + "Executed AML Breakpoint opcode"); /* If and when it returns, all done. */ break; - case AML_BREAK_OP: - case AML_CONTINUE_OP: /* ACPI 2.0 */ - + case AML_CONTINUE_OP: /* ACPI 2.0 */ /* Pop and delete control states until we find a while */ while (walk_state->control_state && - (walk_state->control_state->control.opcode != AML_WHILE_OP)) { - control_state = acpi_ut_pop_generic_state (&walk_state->control_state); - acpi_ut_delete_generic_state (control_state); + (walk_state->control_state->control.opcode != + AML_WHILE_OP)) { + control_state = + acpi_ut_pop_generic_state(&walk_state-> + control_state); + acpi_ut_delete_generic_state(control_state); } /* No while found? */ @@ -1162,23 +1141,23 @@ acpi_ds_exec_end_control_op ( /* Was: walk_state->aml_last_while = walk_state->control_state->Control.aml_predicate_start; */ - walk_state->aml_last_while = walk_state->control_state->control.package_end; + walk_state->aml_last_while = + walk_state->control_state->control.package_end; /* Return status depending on opcode */ if (op->common.aml_opcode == AML_BREAK_OP) { status = AE_CTRL_BREAK; - } - else { + } else { status = AE_CTRL_CONTINUE; } break; - default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown control opcode=%X Op=%p\n", - op->common.aml_opcode, op)); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Unknown control opcode=%X Op=%p\n", + op->common.aml_opcode, op)); status = AE_AML_BAD_OPCODE; break; @@ -1186,4 +1165,3 @@ acpi_ds_exec_end_control_op ( return (status); } - |