Skip to content

Commit

Permalink
Merge branch 'acpica' into acpi-sysfs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafael J. Wysocki committed Sep 16, 2016
2 parents 18864cc + 86ec64b commit 2375020
Show file tree
Hide file tree
Showing 45 changed files with 1,223 additions and 822 deletions.
1 change: 1 addition & 0 deletions drivers/acpi/acpica/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ acpi-y += \
utresrc.o \
utstate.o \
utstring.o \
utstrtoul64.o \
utxface.o \
utxfinit.o \
utxferror.o \
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/acpica/acdebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ acpi_status acpi_db_disassemble_method(char *name);

void acpi_db_disassemble_aml(char *statements, union acpi_parse_object *op);

void acpi_db_batch_execute(char *count_arg);
void acpi_db_evaluate_predefined_names(void);

/*
* dbnames - namespace commands
Expand Down
8 changes: 8 additions & 0 deletions drivers/acpi/acpica/acnamesp.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ struct acpi_namespace_node *acpi_ns_get_next_node_typed(acpi_object_type type,
acpi_status
acpi_ns_parse_table(u32 table_index, struct acpi_namespace_node *start_node);

acpi_status
acpi_ns_execute_table(u32 table_index, struct acpi_namespace_node *start_node);

acpi_status
acpi_ns_one_complete_parse(u32 pass_number,
u32 table_index,
Expand Down Expand Up @@ -295,6 +298,11 @@ acpi_ns_handle_to_pathname(acpi_handle target_handle,
u8
acpi_ns_pattern_match(struct acpi_namespace_node *obj_node, char *search_for);

acpi_status
acpi_ns_get_node_unlocked(struct acpi_namespace_node *prefix_node,
const char *external_pathname,
u32 flags, struct acpi_namespace_node **out_node);

acpi_status
acpi_ns_get_node(struct acpi_namespace_node *prefix_node,
const char *external_pathname,
Expand Down
2 changes: 2 additions & 0 deletions drivers/acpi/acpica/acparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ extern const u8 acpi_gbl_long_op_index[];
*/
acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info);

acpi_status acpi_ps_execute_table(struct acpi_evaluate_info *info);

/*
* psargs - Parse AML opcode arguments
*/
Expand Down
15 changes: 9 additions & 6 deletions drivers/acpi/acpica/actables.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ acpi_tb_install_standard_table(acpi_physical_address address,

void acpi_tb_uninstall_table(struct acpi_table_desc *table_desc);

acpi_status
acpi_tb_load_table(u32 table_index, struct acpi_namespace_node *parent_node);

acpi_status
acpi_tb_install_and_load_table(struct acpi_table_header *table,
acpi_physical_address address,
u8 flags, u8 override, u32 *table_index);

void acpi_tb_terminate(void);

acpi_status acpi_tb_delete_namespace_by_owner(u32 table_index);
Expand Down Expand Up @@ -155,12 +163,7 @@ void
acpi_tb_install_table_with_override(struct acpi_table_desc *new_table_desc,
u8 override, u32 *table_index);

acpi_status
acpi_tb_install_fixed_table(acpi_physical_address address,
char *signature, u32 *table_index);

acpi_status ACPI_INIT_FUNCTION
acpi_tb_parse_root_table(acpi_physical_address rsdp_address);
acpi_status acpi_tb_parse_root_table(acpi_physical_address rsdp_address);

/*
* tbxfload
Expand Down
17 changes: 10 additions & 7 deletions drivers/acpi/acpica/acutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,15 @@ void acpi_ut_strlwr(char *src_string);

int acpi_ut_stricmp(char *string1, char *string2);

acpi_status
acpi_ut_strtoul64(char *string,
u32 base, u32 max_integer_byte_width, u64 *ret_integer);

/* Values for max_integer_byte_width above */
acpi_status acpi_ut_strtoul64(char *string, u32 flags, u64 *ret_integer);

#define ACPI_MAX32_BYTE_WIDTH 4
#define ACPI_MAX64_BYTE_WIDTH 8
/*
* Values for Flags above
* Note: LIMIT values correspond to acpi_gbl_integer_byte_width values (4/8)
*/
#define ACPI_STRTOUL_32BIT 0x04 /* 4 bytes */
#define ACPI_STRTOUL_64BIT 0x08 /* 8 bytes */
#define ACPI_STRTOUL_BASE16 0x10 /* Default: Base10/16 */

/*
* utglobal - Global data structures and procedures
Expand Down Expand Up @@ -233,6 +234,8 @@ const char *acpi_ut_get_event_name(u32 event_id);

char acpi_ut_hex_to_ascii_char(u64 integer, u32 position);

acpi_status acpi_ut_ascii_to_hex_byte(char *two_ascii_chars, u8 *return_byte);

u8 acpi_ut_ascii_char_to_hex(int hex_char);

u8 acpi_ut_valid_object_type(acpi_object_type type);
Expand Down
7 changes: 4 additions & 3 deletions drivers/acpi/acpica/dbconvert.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,10 @@ acpi_db_convert_to_object(acpi_object_type type,
default:

object->type = ACPI_TYPE_INTEGER;
status =
acpi_ut_strtoul64(string, 16, acpi_gbl_integer_byte_width,
&object->integer.value);
status = acpi_ut_strtoul64(string,
(acpi_gbl_integer_byte_width |
ACPI_STRTOUL_BASE16),
&object->integer.value);
break;
}

Expand Down
62 changes: 34 additions & 28 deletions drivers/acpi/acpica/dbexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,42 +392,48 @@ acpi_db_execute(char *name, char **args, acpi_object_type *types, u32 flags)
acpi_db_execution_walk, NULL, NULL,
NULL);
return;
} else {
name_string = ACPI_ALLOCATE(strlen(name) + 1);
if (!name_string) {
return;
}
}

memset(&acpi_gbl_db_method_info, 0,
sizeof(struct acpi_db_method_info));
name_string = ACPI_ALLOCATE(strlen(name) + 1);
if (!name_string) {
return;
}

strcpy(name_string, name);
acpi_ut_strupr(name_string);
acpi_gbl_db_method_info.name = name_string;
acpi_gbl_db_method_info.args = args;
acpi_gbl_db_method_info.types = types;
acpi_gbl_db_method_info.flags = flags;
memset(&acpi_gbl_db_method_info, 0, sizeof(struct acpi_db_method_info));
strcpy(name_string, name);
acpi_ut_strupr(name_string);

return_obj.pointer = NULL;
return_obj.length = ACPI_ALLOCATE_BUFFER;
/* Subcommand to Execute all predefined names in the namespace */

status = acpi_db_execute_setup(&acpi_gbl_db_method_info);
if (ACPI_FAILURE(status)) {
ACPI_FREE(name_string);
return;
}
if (!strncmp(name_string, "PREDEF", 6)) {
acpi_db_evaluate_predefined_names();
ACPI_FREE(name_string);
return;
}

/* Get the NS node, determines existence also */
acpi_gbl_db_method_info.name = name_string;
acpi_gbl_db_method_info.args = args;
acpi_gbl_db_method_info.types = types;
acpi_gbl_db_method_info.flags = flags;

status = acpi_get_handle(NULL, acpi_gbl_db_method_info.pathname,
&acpi_gbl_db_method_info.method);
if (ACPI_SUCCESS(status)) {
status =
acpi_db_execute_method(&acpi_gbl_db_method_info,
&return_obj);
}
return_obj.pointer = NULL;
return_obj.length = ACPI_ALLOCATE_BUFFER;

status = acpi_db_execute_setup(&acpi_gbl_db_method_info);
if (ACPI_FAILURE(status)) {
ACPI_FREE(name_string);
return;
}

/* Get the NS node, determines existence also */

status = acpi_get_handle(NULL, acpi_gbl_db_method_info.pathname,
&acpi_gbl_db_method_info.method);
if (ACPI_SUCCESS(status)) {
status = acpi_db_execute_method(&acpi_gbl_db_method_info,
&return_obj);
}
ACPI_FREE(name_string);

/*
* Allow any handlers in separate threads to complete.
Expand Down
2 changes: 2 additions & 0 deletions drivers/acpi/acpica/dbinput.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ static const struct acpi_db_command_help acpi_gbl_db_command_help[] = {
{1, " \"Ascii String\"", "String method argument\n"},
{1, " (Hex Byte List)", "Buffer method argument\n"},
{1, " [Package Element List]", "Package method argument\n"},
{5, " Execute predefined",
"Execute all predefined (public) methods\n"},
{1, " Go", "Allow method to run to completion\n"},
{1, " Information", "Display info about the current method\n"},
{1, " Into", "Step into (not over) a method call\n"},
Expand Down
132 changes: 132 additions & 0 deletions drivers/acpi/acpica/dbmethod.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
#define _COMPONENT ACPI_CA_DEBUGGER
ACPI_MODULE_NAME("dbmethod")

/* Local prototypes */
static acpi_status
acpi_db_walk_for_execute(acpi_handle obj_handle,
u32 nesting_level, void *context, void **return_value);

/*******************************************************************************
*
* FUNCTION: acpi_db_set_method_breakpoint
Expand All @@ -66,6 +71,7 @@ ACPI_MODULE_NAME("dbmethod")
* AML offset
*
******************************************************************************/

void
acpi_db_set_method_breakpoint(char *location,
struct acpi_walk_state *walk_state,
Expand Down Expand Up @@ -367,3 +373,129 @@ acpi_status acpi_db_disassemble_method(char *name)
acpi_ut_release_owner_id(&obj_desc->method.owner_id);
return (AE_OK);
}

/*******************************************************************************
*
* FUNCTION: acpi_db_walk_for_execute
*
* PARAMETERS: Callback from walk_namespace
*
* RETURN: Status
*
* DESCRIPTION: Batch execution module. Currently only executes predefined
* ACPI names.
*
******************************************************************************/

static acpi_status
acpi_db_walk_for_execute(acpi_handle obj_handle,
u32 nesting_level, void *context, void **return_value)
{
struct acpi_namespace_node *node =
(struct acpi_namespace_node *)obj_handle;
struct acpi_db_execute_walk *info =
(struct acpi_db_execute_walk *)context;
struct acpi_buffer return_obj;
acpi_status status;
char *pathname;
u32 i;
struct acpi_device_info *obj_info;
struct acpi_object_list param_objects;
union acpi_object params[ACPI_METHOD_NUM_ARGS];
const union acpi_predefined_info *predefined;

predefined = acpi_ut_match_predefined_method(node->name.ascii);
if (!predefined) {
return (AE_OK);
}

if (node->type == ACPI_TYPE_LOCAL_SCOPE) {
return (AE_OK);
}

pathname = acpi_ns_get_external_pathname(node);
if (!pathname) {
return (AE_OK);
}

/* Get the object info for number of method parameters */

status = acpi_get_object_info(obj_handle, &obj_info);
if (ACPI_FAILURE(status)) {
return (status);
}

param_objects.pointer = NULL;
param_objects.count = 0;

if (obj_info->type == ACPI_TYPE_METHOD) {

/* Setup default parameters */

for (i = 0; i < obj_info->param_count; i++) {
params[i].type = ACPI_TYPE_INTEGER;
params[i].integer.value = 1;
}

param_objects.pointer = params;
param_objects.count = obj_info->param_count;
}

ACPI_FREE(obj_info);
return_obj.pointer = NULL;
return_obj.length = ACPI_ALLOCATE_BUFFER;

/* Do the actual method execution */

acpi_gbl_method_executing = TRUE;

status = acpi_evaluate_object(node, NULL, &param_objects, &return_obj);

acpi_os_printf("%-32s returned %s\n", pathname,
acpi_format_exception(status));
acpi_gbl_method_executing = FALSE;
ACPI_FREE(pathname);

/* Ignore status from method execution */

status = AE_OK;

/* Update count, check if we have executed enough methods */

info->count++;
if (info->count >= info->max_count) {
status = AE_CTRL_TERMINATE;
}

return (status);
}

/*******************************************************************************
*
* FUNCTION: acpi_db_evaluate_predefined_names
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Namespace batch execution. Execute predefined names in the
* namespace, up to the max count, if specified.
*
******************************************************************************/

void acpi_db_evaluate_predefined_names(void)
{
struct acpi_db_execute_walk info;

info.count = 0;
info.max_count = ACPI_UINT32_MAX;

/* Search all nodes in namespace */

(void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX, acpi_db_walk_for_execute,
NULL, (void *)&info, NULL);

acpi_os_printf("Evaluated %u predefined names in the namespace\n",
info.count);
}
Loading

0 comments on commit 2375020

Please sign in to comment.