acpi_status acpi_ns_repair_null_element(struct acpi_predefined_data *data, u32 expected_btypes, u32 package_index, union acpi_operand_object **return_object_ptr) { union acpi_operand_object *return_object = *return_object_ptr; union acpi_operand_object *new_object; ACPI_FUNCTION_NAME(ns_repair_null_element); /* No repair needed if return object is non-NULL */ if (return_object) { return (AE_OK); } /* * Attempt to repair a NULL element of a Package object. This applies to * predefined names that return a fixed-length package and each element * is required. It does not apply to variable-length packages where NULL * elements are allowed, especially at the end of the package. */ if (expected_btypes & ACPI_RTYPE_INTEGER) { /* Need an Integer - create a zero-value integer */ <<<<<<< HEAD new_object = acpi_ut_create_integer_object((u64)0); =======
/******************************************************************************* * * FUNCTION: acpi_ns_convert_to_integer * * PARAMETERS: original_object - Object to be converted * return_object - Where the new converted object is returned * * RETURN: Status. AE_OK if conversion was successful. * * DESCRIPTION: Attempt to convert a String/Buffer object to an Integer. * ******************************************************************************/ acpi_status acpi_ns_convert_to_integer(union acpi_operand_object *original_object, union acpi_operand_object **return_object) { union acpi_operand_object *new_object; acpi_status status; u64 value = 0; u32 i; switch (original_object->common.type) { case ACPI_TYPE_STRING: /* String-to-Integer conversion */ status = acpi_ut_strtoul64(original_object->string.pointer, ACPI_ANY_BASE, &value); if (ACPI_FAILURE(status)) { return (status); } break; case ACPI_TYPE_BUFFER: /* Buffer-to-Integer conversion. Max buffer size is 64 bits. */ if (original_object->buffer.length > 8) { return (AE_AML_OPERAND_TYPE); } /* Extract each buffer byte to create the integer */ for (i = 0; i < original_object->buffer.length; i++) { value |= ((u64)original_object->buffer. pointer[i] << (i * 8)); } break; default: return (AE_AML_OPERAND_TYPE); } new_object = acpi_ut_create_integer_object(value); if (!new_object) { return (AE_NO_MEMORY); } *return_object = new_object; return (AE_OK); }
/******************************************************************************* * * FUNCTION: acpi_ex_opcode_0A_0T_1R * * PARAMETERS: walk_state - Current state (contains AML opcode) * * RETURN: Status * * DESCRIPTION: Execute operator with no operands, one return value * ******************************************************************************/ acpi_status acpi_ex_opcode_0A_0T_1R(struct acpi_walk_state *walk_state) { acpi_status status = AE_OK; union acpi_operand_object *return_desc = NULL; ACPI_FUNCTION_TRACE_STR(ex_opcode_0A_0T_1R, acpi_ps_get_opcode_name(walk_state->opcode)); /* Examine the AML opcode */ switch (walk_state->opcode) { case AML_TIMER_OP: /* Timer () */ /* Create a return object of type Integer */ return_desc = acpi_ut_create_integer_object(acpi_os_get_timer()); if (!return_desc) { status = AE_NO_MEMORY; goto cleanup; } break; default: /* Unknown opcode */ ACPI_ERROR((AE_INFO, "Unknown AML opcode 0x%X", walk_state->opcode)); status = AE_AML_BAD_OPCODE; break; } cleanup: /* Delete return object on error */ if ((ACPI_FAILURE(status)) || walk_state->result_obj) { acpi_ut_remove_reference(return_desc); walk_state->result_obj = NULL; } else { /* Save the return value */ walk_state->result_obj = return_desc; } return_ACPI_STATUS(status); }
static acpi_status acpi_ns_convert_to_package(union acpi_operand_object *original_object, union acpi_operand_object **return_object) { union acpi_operand_object *new_object; union acpi_operand_object **elements; u32 length; u8 *buffer; switch (original_object->common.type) { case ACPI_TYPE_BUFFER: /* Buffer-to-Package conversion */ length = original_object->buffer.length; new_object = acpi_ut_create_package_object(length); if (!new_object) { return (AE_NO_MEMORY); } /* Convert each buffer byte to an integer package element */ elements = new_object->package.elements; buffer = original_object->buffer.pointer; while (length--) { *elements = acpi_ut_create_integer_object((u64) *buffer); if (!*elements) { acpi_ut_remove_reference(new_object); return (AE_NO_MEMORY); } elements++; buffer++; } break; default: return (AE_AML_OPERAND_TYPE); } *return_object = new_object; return (AE_OK); }
acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state) { union acpi_operand_object **operand = &walk_state->operands[0]; union acpi_operand_object *return_desc = NULL; acpi_status status = AE_OK; u64 index; union acpi_operand_object *this_element; ACPI_FUNCTION_TRACE_STR(ex_opcode_6A_0T_1R, acpi_ps_get_opcode_name(walk_state->opcode)); switch (walk_state->opcode) { case AML_MATCH_OP: if ((operand[1]->integer.value > MAX_MATCH_OPERATOR) || (operand[3]->integer.value > MAX_MATCH_OPERATOR)) { ACPI_ERROR((AE_INFO, "Match operator out of range")); status = AE_AML_OPERAND_VALUE; goto cleanup; } index = operand[5]->integer.value; if (index >= operand[0]->package.count) { ACPI_ERROR((AE_INFO, "Index (0x%8.8X%8.8X) beyond package end (0x%X)", ACPI_FORMAT_UINT64(index), operand[0]->package.count)); status = AE_AML_PACKAGE_LIMIT; goto cleanup; } return_desc = acpi_ut_create_integer_object(ACPI_UINT64_MAX); if (!return_desc) { status = AE_NO_MEMORY; goto cleanup; } for (; index < operand[0]->package.count; index++) { this_element = operand[0]->package.elements[index]; if (!this_element) { continue; } if (!acpi_ex_do_match((u32) operand[1]->integer.value, this_element, operand[2])) { continue; } if (!acpi_ex_do_match((u32) operand[3]->integer.value, this_element, operand[4])) { continue; } return_desc->integer.value = index; break; } break; case AML_LOAD_TABLE_OP: status = acpi_ex_load_table_op(walk_state, &return_desc); break; default: ACPI_ERROR((AE_INFO, "Unknown AML opcode 0x%X", walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } cleanup: if (ACPI_FAILURE(status)) { acpi_ut_remove_reference(return_desc); } else { walk_state->result_obj = return_desc; } return_ACPI_STATUS(status); }
acpi_status acpi_ex_read_data_from_field(struct acpi_walk_state * walk_state, union acpi_operand_object *obj_desc, union acpi_operand_object **ret_buffer_desc) { acpi_status status; union acpi_operand_object *buffer_desc; acpi_size length; void *buffer; u32 function; u16 accessor_type; ACPI_FUNCTION_TRACE_PTR(ex_read_data_from_field, obj_desc); /* Parameter validation */ if (!obj_desc) { return_ACPI_STATUS(AE_AML_NO_OPERAND); } if (!ret_buffer_desc) { return_ACPI_STATUS(AE_BAD_PARAMETER); } if (obj_desc->common.type == ACPI_TYPE_BUFFER_FIELD) { /* * If the buffer_field arguments have not been previously evaluated, * evaluate them now and save the results. */ if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) { status = acpi_ds_get_buffer_field_arguments(obj_desc); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } } } else if ((obj_desc->common.type == ACPI_TYPE_LOCAL_REGION_FIELD) && (obj_desc->field.region_obj->region.space_id == ACPI_ADR_SPACE_SMBUS || obj_desc->field.region_obj->region.space_id == ACPI_ADR_SPACE_GSBUS || obj_desc->field.region_obj->region.space_id == ACPI_ADR_SPACE_IPMI)) { /* * This is an SMBus, GSBus or IPMI read. We must create a buffer to hold * the data and then directly access the region handler. * * Note: SMBus and GSBus protocol value is passed in upper 16-bits of Function */ if (obj_desc->field.region_obj->region.space_id == ACPI_ADR_SPACE_SMBUS) { length = ACPI_SMBUS_BUFFER_SIZE; function = ACPI_READ | (obj_desc->field.attribute << 16); } else if (obj_desc->field.region_obj->region.space_id == ACPI_ADR_SPACE_GSBUS) { accessor_type = obj_desc->field.attribute; length = acpi_ex_get_serial_access_length(accessor_type, obj_desc-> field. access_length); /* * Add additional 2 bytes for the generic_serial_bus data buffer: * * Status; (Byte 0 of the data buffer) * Length; (Byte 1 of the data buffer) * Data[x-1]; (Bytes 2-x of the arbitrary length data buffer) */ length += 2; function = ACPI_READ | (accessor_type << 16); } else { /* IPMI */ length = ACPI_IPMI_BUFFER_SIZE; function = ACPI_READ; } buffer_desc = acpi_ut_create_buffer_object(length); if (!buffer_desc) { return_ACPI_STATUS(AE_NO_MEMORY); } /* Lock entire transaction if requested */ acpi_ex_acquire_global_lock(obj_desc->common_field.field_flags); /* Call the region handler for the read */ status = acpi_ex_access_region(obj_desc, 0, ACPI_CAST_PTR(u64, buffer_desc-> buffer.pointer), function); acpi_ex_release_global_lock(obj_desc->common_field.field_flags); goto exit; } /* * Allocate a buffer for the contents of the field. * * If the field is larger than the current integer width, create * a BUFFER to hold it. Otherwise, use an INTEGER. This allows * the use of arithmetic operators on the returned value if the * field size is equal or smaller than an Integer. * * Note: Field.length is in bits. */ length = (acpi_size) ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->field.bit_length); if (length > acpi_gbl_integer_byte_width) { /* Field is too large for an Integer, create a Buffer instead */ buffer_desc = acpi_ut_create_buffer_object(length); if (!buffer_desc) { return_ACPI_STATUS(AE_NO_MEMORY); } buffer = buffer_desc->buffer.pointer; } else { /* Field will fit within an Integer (normal case) */ buffer_desc = acpi_ut_create_integer_object((u64) 0); if (!buffer_desc) { return_ACPI_STATUS(AE_NO_MEMORY); } length = acpi_gbl_integer_byte_width; buffer = &buffer_desc->integer.value; } if ((obj_desc->common.type == ACPI_TYPE_LOCAL_REGION_FIELD) && (obj_desc->field.region_obj->region.space_id == ACPI_ADR_SPACE_GPIO)) { /* * For GPIO (general_purpose_io), the Address will be the bit offset * from the previous Connection() operator, making it effectively a * pin number index. The bit_length is the length of the field, which * is thus the number of pins. */ ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, "GPIO FieldRead [FROM]: Pin %u Bits %u\n", obj_desc->field.pin_number_index, obj_desc->field.bit_length)); /* Lock entire transaction if requested */ acpi_ex_acquire_global_lock(obj_desc->common_field.field_flags); /* Perform the write */ status = acpi_ex_access_region(obj_desc, 0, (u64 *)buffer, ACPI_READ); acpi_ex_release_global_lock(obj_desc->common_field.field_flags); if (ACPI_FAILURE(status)) { acpi_ut_remove_reference(buffer_desc); } else { *ret_buffer_desc = buffer_desc; } return_ACPI_STATUS(status); } ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, "FieldRead [TO]: Obj %p, Type %X, Buf %p, ByteLen %X\n", obj_desc, obj_desc->common.type, buffer, (u32) length)); ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, "FieldRead [FROM]: BitLen %X, BitOff %X, ByteOff %X\n", obj_desc->common_field.bit_length, obj_desc->common_field.start_field_bit_offset, obj_desc->common_field.base_byte_offset)); /* Lock entire transaction if requested */ acpi_ex_acquire_global_lock(obj_desc->common_field.field_flags); /* Read from the field */ status = acpi_ex_extract_from_field(obj_desc, buffer, (u32) length); acpi_ex_release_global_lock(obj_desc->common_field.field_flags); exit: if (ACPI_FAILURE(status)) { acpi_ut_remove_reference(buffer_desc); } else { *ret_buffer_desc = buffer_desc; } return_ACPI_STATUS(status); }
acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state * walk_state) { union acpi_operand_object **operand = &walk_state->operands[0]; union acpi_operand_object *return_desc = NULL; acpi_status status = AE_OK; u64 index; union acpi_operand_object *this_element; ACPI_FUNCTION_TRACE_STR(ex_opcode_6A_0T_1R, acpi_ps_get_opcode_name(walk_state->opcode)); switch (walk_state->opcode) { case AML_MATCH_OP: /* * Match (search_pkg[0], match_op1[1], match_obj1[2], * match_op2[3], match_obj2[4], start_index[5]) */ /* Validate both Match Term Operators (MTR, MEQ, etc.) */ if ((operand[1]->integer.value > MAX_MATCH_OPERATOR) || (operand[3]->integer.value > MAX_MATCH_OPERATOR)) { ACPI_ERROR((AE_INFO, "Match operator out of range")); status = AE_AML_OPERAND_VALUE; goto cleanup; } /* Get the package start_index, validate against the package length */ index = operand[5]->integer.value; if (index >= operand[0]->package.count) { ACPI_ERROR((AE_INFO, "Index (0x%8.8X%8.8X) beyond package end (0x%X)", ACPI_FORMAT_UINT64(index), operand[0]->package.count)); status = AE_AML_PACKAGE_LIMIT; goto cleanup; } /* Create an integer for the return value */ /* Default return value is ACPI_UINT64_MAX if no match found */ return_desc = acpi_ut_create_integer_object(ACPI_UINT64_MAX); if (!return_desc) { status = AE_NO_MEMORY; goto cleanup; } /* * Examine each element until a match is found. Both match conditions * must be satisfied for a match to occur. Within the loop, * "continue" signifies that the current element does not match * and the next should be examined. * * Upon finding a match, the loop will terminate via "break" at * the bottom. If it terminates "normally", match_value will be * ACPI_UINT64_MAX (Ones) (its initial value) indicating that no * match was found. */ for (; index < operand[0]->package.count; index++) { /* Get the current package element */ this_element = operand[0]->package.elements[index]; /* Treat any uninitialized (NULL) elements as non-matching */ if (!this_element) { continue; } /* * Both match conditions must be satisfied. Execution of a continue * (proceed to next iteration of enclosing for loop) signifies a * non-match. */ if (!acpi_ex_do_match((u32) operand[1]->integer.value, this_element, operand[2])) { continue; } if (!acpi_ex_do_match((u32) operand[3]->integer.value, this_element, operand[4])) { continue; } /* Match found: Index is the return value */ return_desc->integer.value = index; break; } break; case AML_LOAD_TABLE_OP: status = acpi_ex_load_table_op(walk_state, &return_desc); break; default: ACPI_ERROR((AE_INFO, "Unknown AML opcode 0x%X", walk_state->opcode)); status = AE_AML_BAD_OPCODE; goto cleanup; } cleanup: /* Delete return object on error */ if (ACPI_FAILURE(status)) { acpi_ut_remove_reference(return_desc); } /* Save return object on success */ else { walk_state->result_obj = return_desc; } return_ACPI_STATUS(status); }
acpi_status acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function) { struct acpi_evaluate_info *info; union acpi_operand_object *args[3]; union acpi_operand_object *region_obj2; acpi_status status; ACPI_FUNCTION_TRACE(ev_execute_reg_method); region_obj2 = acpi_ns_get_secondary_object(region_obj); if (!region_obj2) { return_ACPI_STATUS(AE_NOT_EXIST); } if (region_obj2->extra.method_REG == NULL) { return_ACPI_STATUS(AE_OK); } /* Allocate and initialize the evaluation information block */ info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info)); if (!info) { return_ACPI_STATUS(AE_NO_MEMORY); } info->prefix_node = region_obj2->extra.method_REG; info->relative_pathname = NULL; info->parameters = args; info->flags = ACPI_IGNORE_RETURN_VALUE; /* * The _REG method has two arguments: * * arg0 - Integer: * Operation region space ID Same value as region_obj->Region.space_id * * arg1 - Integer: * connection status 1 for connecting the handler, 0 for disconnecting * the handler (Passed as a parameter) */ args[0] = acpi_ut_create_integer_object((u64)region_obj->region.space_id); if (!args[0]) { status = AE_NO_MEMORY; goto cleanup1; } args[1] = acpi_ut_create_integer_object((u64)function); if (!args[1]) { status = AE_NO_MEMORY; goto cleanup2; } args[2] = NULL; /* Terminate list */ /* Execute the method, no return value */ ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname (ACPI_TYPE_METHOD, info->prefix_node, NULL)); status = acpi_ns_evaluate(info); acpi_ut_remove_reference(args[1]); cleanup2: acpi_ut_remove_reference(args[0]); cleanup1: ACPI_FREE(info); return_ACPI_STATUS(status); }
acpi_status acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state, union acpi_operand_object *obj_desc, union acpi_operand_object **ret_buffer_desc) { acpi_status status; union acpi_operand_object *buffer_desc; acpi_size length; void *buffer; u32 function; ACPI_FUNCTION_TRACE_PTR(ex_read_data_from_field, obj_desc); if (!obj_desc) { return_ACPI_STATUS(AE_AML_NO_OPERAND); } if (!ret_buffer_desc) { return_ACPI_STATUS(AE_BAD_PARAMETER); } if (obj_desc->common.type == ACPI_TYPE_BUFFER_FIELD) { if (!(obj_desc->common.flags & AOPOBJ_DATA_VALID)) { status = acpi_ds_get_buffer_field_arguments(obj_desc); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } } } else if ((obj_desc->common.type == ACPI_TYPE_LOCAL_REGION_FIELD) && (obj_desc->field.region_obj->region.space_id == ACPI_ADR_SPACE_SMBUS || obj_desc->field.region_obj->region.space_id == ACPI_ADR_SPACE_GSBUS || obj_desc->field.region_obj->region.space_id == ACPI_ADR_SPACE_IPMI)) { if (obj_desc->field.region_obj->region.space_id == ACPI_ADR_SPACE_SMBUS) { length = ACPI_SMBUS_BUFFER_SIZE; function = ACPI_READ | (obj_desc->field.attribute << 16); } else if (obj_desc->field.region_obj->region.space_id == ACPI_ADR_SPACE_GSBUS) { length = ACPI_GSBUS_BUFFER_SIZE; function = ACPI_READ | (obj_desc->field.attribute << 16); } else { length = ACPI_IPMI_BUFFER_SIZE; function = ACPI_READ; } buffer_desc = acpi_ut_create_buffer_object(length); if (!buffer_desc) { return_ACPI_STATUS(AE_NO_MEMORY); } acpi_ex_acquire_global_lock(obj_desc->common_field.field_flags); status = acpi_ex_access_region(obj_desc, 0, ACPI_CAST_PTR(u64, buffer_desc-> buffer.pointer), function); acpi_ex_release_global_lock(obj_desc->common_field.field_flags); goto exit; } length = (acpi_size) ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->field.bit_length); if (length > acpi_gbl_integer_byte_width) { buffer_desc = acpi_ut_create_buffer_object(length); if (!buffer_desc) { return_ACPI_STATUS(AE_NO_MEMORY); } buffer = buffer_desc->buffer.pointer; } else { buffer_desc = acpi_ut_create_integer_object((u64) 0); if (!buffer_desc) { return_ACPI_STATUS(AE_NO_MEMORY); } length = acpi_gbl_integer_byte_width; buffer = &buffer_desc->integer.value; } ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, "FieldRead [TO]: Obj %p, Type %X, Buf %p, ByteLen %X\n", obj_desc, obj_desc->common.type, buffer, (u32) length)); ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, "FieldRead [FROM]: BitLen %X, BitOff %X, ByteOff %X\n", obj_desc->common_field.bit_length, obj_desc->common_field.start_field_bit_offset, obj_desc->common_field.base_byte_offset)); acpi_ex_acquire_global_lock(obj_desc->common_field.field_flags); status = acpi_ex_extract_from_field(obj_desc, buffer, (u32) length); acpi_ex_release_global_lock(obj_desc->common_field.field_flags); exit: if (ACPI_FAILURE(status)) { acpi_ut_remove_reference(buffer_desc); } else { *ret_buffer_desc = buffer_desc; } return_ACPI_STATUS(status); }
acpi_status acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc, union acpi_operand_object **result_desc, u32 flags) { union acpi_operand_object *return_desc; u8 *pointer; acpi_integer result; u32 i; u32 count; acpi_status status; ACPI_FUNCTION_TRACE_PTR(ex_convert_to_integer, obj_desc); switch (obj_desc->common.type) { case ACPI_TYPE_INTEGER: /* No conversion necessary */ *result_desc = obj_desc; return_ACPI_STATUS(AE_OK); case ACPI_TYPE_BUFFER: case ACPI_TYPE_STRING: /* Note: Takes advantage of common buffer/string fields */ pointer = obj_desc->buffer.pointer; count = obj_desc->buffer.length; break; default: return_ACPI_STATUS(AE_TYPE); } /* * Convert the buffer/string to an integer. Note that both buffers and * strings are treated as raw data - we don't convert ascii to hex for * strings. * * There are two terminating conditions for the loop: * 1) The size of an integer has been reached, or * 2) The end of the buffer or string has been reached */ result = 0; /* String conversion is different than Buffer conversion */ switch (obj_desc->common.type) { case ACPI_TYPE_STRING: /* * Convert string to an integer - for most cases, the string must be * hexadecimal as per the ACPI specification. The only exception (as * of ACPI 3.0) is that the to_integer() operator allows both decimal * and hexadecimal strings (hex prefixed with "0x"). */ status = acpi_ut_strtoul64((char *)pointer, flags, &result); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } break; case ACPI_TYPE_BUFFER: /* Check for zero-length buffer */ if (!count) { return_ACPI_STATUS(AE_AML_BUFFER_LIMIT); } /* Transfer no more than an integer's worth of data */ if (count > acpi_gbl_integer_byte_width) { count = acpi_gbl_integer_byte_width; } /* * Convert buffer to an integer - we simply grab enough raw data * from the buffer to fill an integer */ for (i = 0; i < count; i++) { /* * Get next byte and shift it into the Result. * Little endian is used, meaning that the first byte of the buffer * is the LSB of the integer */ result |= (((acpi_integer) pointer[i]) << (i * 8)); } break; default: /* No other types can get here */ break; } /* Create a new integer */ return_desc = acpi_ut_create_integer_object(result); if (!return_desc) { return_ACPI_STATUS(AE_NO_MEMORY); } ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n", ACPI_FORMAT_UINT64(result))); /* Save the Result */ acpi_ex_truncate_for32bit_table(return_desc); *result_desc = return_desc; return_ACPI_STATUS(AE_OK); }
acpi_status acpi_ns_repair_null_element(struct acpi_evaluate_info * info, u32 expected_btypes, u32 package_index, union acpi_operand_object **return_object_ptr) { union acpi_operand_object *return_object = *return_object_ptr; union acpi_operand_object *new_object; ACPI_FUNCTION_NAME(ns_repair_null_element); /* No repair needed if return object is non-NULL */ if (return_object) { return (AE_OK); } /* * Attempt to repair a NULL element of a Package object. This applies to * predefined names that return a fixed-length package and each element * is required. It does not apply to variable-length packages where NULL * elements are allowed, especially at the end of the package. */ if (expected_btypes & ACPI_RTYPE_INTEGER) { /* Need an integer - create a zero-value integer */ new_object = acpi_ut_create_integer_object((u64)0); } else if (expected_btypes & ACPI_RTYPE_STRING) { /* Need a string - create a NULL string */ new_object = acpi_ut_create_string_object(0); } else if (expected_btypes & ACPI_RTYPE_BUFFER) { /* Need a buffer - create a zero-length buffer */ new_object = acpi_ut_create_buffer_object(0); } else { /* Error for all other expected types */ return (AE_AML_OPERAND_TYPE); } if (!new_object) { return (AE_NO_MEMORY); } /* Set the reference count according to the parent Package object */ new_object->common.reference_count = info->parent_package->common.reference_count; ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, "%s: Converted NULL package element to expected %s at index %u\n", info->full_pathname, acpi_ut_get_object_type_name(new_object), package_index)); *return_object_ptr = new_object; info->return_flags |= ACPI_OBJECT_REPAIRED; return (AE_OK); }
acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info) { acpi_status status; union acpi_parse_object *op; struct acpi_walk_state *walk_state; ACPI_FUNCTION_TRACE(ps_execute_method); /* Quick validation of DSDT header */ acpi_tb_check_dsdt_header(); /* Validate the Info and method Node */ if (!info || !info->resolved_node) { return_ACPI_STATUS(AE_NULL_ENTRY); } /* Init for new method, wait on concurrency semaphore */ status = acpi_ds_begin_method_execution(info->resolved_node, info->obj_desc, NULL); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } /* * The caller "owns" the parameters, so give each one an extra reference */ acpi_ps_update_parameter_list(info, REF_INCREMENT); /* Begin tracing if requested */ acpi_ps_start_trace(info); /* * Execute the method. Performs parse simultaneously */ ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "**** Begin Method Parse/Execute [%4.4s] **** Node=%p Obj=%p\n", info->resolved_node->name.ascii, info->resolved_node, info->obj_desc)); /* Create and init a Root Node */ op = acpi_ps_create_scope_op(); if (!op) { status = AE_NO_MEMORY; goto cleanup; } /* Create and initialize a new walk state */ info->pass_number = ACPI_IMODE_EXECUTE; walk_state = acpi_ds_create_walk_state(info->obj_desc->method.owner_id, NULL, NULL, NULL); if (!walk_state) { status = AE_NO_MEMORY; goto cleanup; } status = acpi_ds_init_aml_walk(walk_state, op, info->resolved_node, info->obj_desc->method.aml_start, info->obj_desc->method.aml_length, info, info->pass_number); if (ACPI_FAILURE(status)) { acpi_ds_delete_walk_state(walk_state); goto cleanup; } if (info->obj_desc->method.info_flags & ACPI_METHOD_MODULE_LEVEL) { walk_state->parse_flags |= ACPI_PARSE_MODULE_LEVEL; } /* Invoke an internal method if necessary */ if (info->obj_desc->method.info_flags & ACPI_METHOD_INTERNAL_ONLY) { status = info->obj_desc->method.dispatch.implementation(walk_state); info->return_object = walk_state->return_desc; /* Cleanup states */ acpi_ds_scope_stack_clear(walk_state); acpi_ps_cleanup_scope(&walk_state->parser_state); acpi_ds_terminate_control_method(walk_state->method_desc, walk_state); acpi_ds_delete_walk_state(walk_state); goto cleanup; } /* * Start method evaluation with an implicit return of zero. * This is done for Windows compatibility. */ if (acpi_gbl_enable_interpreter_slack) { walk_state->implicit_return_obj = acpi_ut_create_integer_object((u64) 0); if (!walk_state->implicit_return_obj) { status = AE_NO_MEMORY; acpi_ds_delete_walk_state(walk_state); goto cleanup; } } /* Parse the AML */ status = acpi_ps_parse_aml(walk_state); /* walk_state was deleted by parse_aml */ cleanup: acpi_ps_delete_parse_tree(op); /* End optional tracing */ acpi_ps_stop_trace(info); /* Take away the extra reference that we gave the parameters above */ acpi_ps_update_parameter_list(info, REF_DECREMENT); /* Exit now if error above */ if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } /* * If the method has returned an object, signal this to the caller with * a control exception code */ if (info->return_object) { ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "Method returned ObjDesc=%p\n", info->return_object)); ACPI_DUMP_STACK_ENTRY(info->return_object); status = AE_CTRL_RETURN_VALUE; } return_ACPI_STATUS(status); }
} /* * Attempt to repair a NULL element of a Package object. This applies to * predefined names that return a fixed-length package and each element * is required. It does not apply to variable-length packages where NULL * elements are allowed, especially at the end of the package. */ if (expected_btypes & ACPI_RTYPE_INTEGER) { /* Need an Integer - create a zero-value integer */ <<<<<<< HEAD new_object = acpi_ut_create_integer_object((u64)0); ======= new_object = acpi_ut_create_integer_object(0); >>>>>>> 296c66da8a02d52243f45b80521febece5ed498a } else if (expected_btypes & ACPI_RTYPE_STRING) { /* Need a String - create a NULL string */ new_object = acpi_ut_create_string_object(0); } else if (expected_btypes & ACPI_RTYPE_BUFFER) { /* Need a Buffer - create a zero-length buffer */ new_object = acpi_ut_create_buffer_object(0); } else { /* Error for all other expected types */ return (AE_AML_OPERAND_TYPE);