123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
#include <acpi/acpi.h>
#include "accommon.h"
#include "acinterp.h"
#include <acpi/acoutput.h>
#include "acparser.h"
#include "amlcode.h"
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME("exoparg3")
acpi_status acpi_ex_opcode_3A_0T_0R(struct acpi_walk_state *walk_state)
{
union acpi_operand_object **operand = &walk_state->operands[0];
struct acpi_signal_fatal_info fatal;
ACPI_FUNCTION_TRACE_STR(ex_opcode_3A_0T_0R,
acpi_ps_get_opcode_name(walk_state->opcode));
switch (walk_state->opcode) {
case AML_FATAL_OP:
fatal.type = (u32)operand[0]->integer.value;
fatal.code = (u32)operand[1]->integer.value;
fatal.argument = (u32)operand[2]->integer.value;
ACPI_BIOS_ERROR((AE_INFO,
"Fatal ACPI BIOS error (Type 0x%X Code 0x%X Arg 0x%X)\n",
fatal.type, fatal.code, fatal.argument));
acpi_os_signal(ACPI_SIGNAL_FATAL, &fatal);
#ifndef ACPI_CONTINUE_ON_FATAL
return_ACPI_STATUS(AE_ERROR);
#else
return_ACPI_STATUS(AE_OK);
#endif
case AML_EXTERNAL_OP:
ACPI_ERROR((AE_INFO, "Executed External Op"));
return_ACPI_STATUS(AE_OK);
default:
ACPI_ERROR((AE_INFO, "Unknown AML opcode 0x%X",
walk_state->opcode));
return_ACPI_STATUS(AE_AML_BAD_OPCODE);
}
}
acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state)
{
union acpi_operand_object **operand = &walk_state->operands[0];
union acpi_operand_object *return_desc = NULL;
char *buffer = NULL;
acpi_status status = AE_OK;
u64 index;
acpi_size length;
ACPI_FUNCTION_TRACE_STR(ex_opcode_3A_1T_1R,
acpi_ps_get_opcode_name(walk_state->opcode));
switch (walk_state->opcode) {
case AML_MID_OP:
return_desc = acpi_ut_create_internal_object((operand[0])->
common.type);
if (!return_desc) {
status = AE_NO_MEMORY;
goto cleanup;
}
index = operand[1]->integer.value;
length = (acpi_size)operand[2]->integer.value;
if (index >= operand[0]->string.length) {
length = 0;
}
else if ((index + length) > operand[0]->string.length || (index + length) < index) {
length =
(acpi_size)operand[0]->string.length -
(acpi_size)index;
}
switch ((operand[0])->common.type) {
case ACPI_TYPE_STRING:
buffer = ACPI_ALLOCATE_ZEROED((acpi_size)length + 1);
if (!buffer) {
status = AE_NO_MEMORY;
goto cleanup;
}
break;
case ACPI_TYPE_BUFFER:
if (length > 0) {
buffer = ACPI_ALLOCATE_ZEROED(length);
if (!buffer) {
status = AE_NO_MEMORY;
goto cleanup;
}
}
break;
default:
status = AE_AML_OPERAND_TYPE;
goto cleanup;
}
if (buffer) {
memcpy(buffer,
operand[0]->string.pointer + index, length);
}
return_desc->string.pointer = buffer;
return_desc->string.length = (u32) length;
return_desc->buffer.flags |= AOPOBJ_DATA_VALID;
break;
default:
ACPI_ERROR((AE_INFO, "Unknown AML opcode 0x%X",
walk_state->opcode));
status = AE_AML_BAD_OPCODE;
goto cleanup;
}
status = acpi_ex_store(return_desc, operand[3], walk_state);
cleanup:
if (ACPI_FAILURE(status) || walk_state->result_obj) {
acpi_ut_remove_reference(return_desc);
walk_state->result_obj = NULL;
} else {
walk_state->result_obj = return_desc;
}
return_ACPI_STATUS(status);
}