Skip to content

Commit

Permalink
ACPICA: Disassembler/tools: Support for multiple ACPI tables in one file
Browse files Browse the repository at this point in the history
ACPICA commit 5be7dc4d0d69b2953d156f5bc4d3e8a65a390837

Matches the support in iASL and acpi_exec.

Link: https://github.com/acpica/acpica/commit/5be7dc4d
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Bob Moore authored and Rafael J. Wysocki committed Jan 1, 2016
1 parent 675dfa0 commit 2ba7379
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 514 deletions.
1 change: 0 additions & 1 deletion drivers/acpi/acpica/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ acpi-$(ACPI_FUTURE_USAGE) += \
dbfileio.o \
dbtest.o \
utcache.o \
utfileio.o \
utprint.o \
uttrack.o \
utuuid.o
Expand Down
39 changes: 14 additions & 25 deletions drivers/acpi/acpica/acapps.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
#ifndef _ACAPPS
#define _ACAPPS

#include <stdio.h>

/* Common info for tool signons */

#define ACPICA_NAME "Intel ACPI Component Architecture"
Expand Down Expand Up @@ -90,6 +92,18 @@
#define FILE_SUFFIX_DISASSEMBLY "dsl"
#define FILE_SUFFIX_BINARY_TABLE ".dat" /* Needs the dot */

/* acfileio */

acpi_status
acpi_ac_get_all_tables_from_file(char *filename,
u8 get_only_aml_tables,
struct acpi_new_table_desc **return_list_head);

/* Values for get_only_aml_tables */

#define ACPI_GET_ONLY_AML_TABLES TRUE
#define ACPI_GET_ALL_TABLES FALSE

/*
* getopt
*/
Expand All @@ -107,30 +121,6 @@ extern char *acpi_gbl_optarg;
*/
u32 cm_get_file_size(ACPI_FILE file);

#ifndef ACPI_DUMP_APP
/*
* adisasm
*/
acpi_status
ad_aml_disassemble(u8 out_to_file,
char *filename, char *prefix, char **out_filename);

void ad_print_statistics(void);

acpi_status ad_find_dsdt(u8 **dsdt_ptr, u32 *dsdt_length);

void ad_dump_tables(void);

acpi_status ad_get_local_tables(void);

acpi_status
ad_parse_table(struct acpi_table_header *table,
acpi_owner_id * owner_id, u8 load_table, u8 external);

acpi_status ad_display_tables(char *filename, struct acpi_table_header *table);

acpi_status ad_display_statistics(void);

/*
* adwalk
*/
Expand Down Expand Up @@ -168,6 +158,5 @@ char *ad_generate_filename(char *prefix, char *table_id);
void
ad_write_table(struct acpi_table_header *table,
u32 length, char *table_name, char *oem_table_id);
#endif

#endif /* _ACAPPS */
5 changes: 1 addition & 4 deletions drivers/acpi/acpica/acdebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,7 @@ void acpi_db_open_debug_file(char *name);

acpi_status acpi_db_load_acpi_table(char *filename);

acpi_status
acpi_db_get_table_from_file(char *filename,
struct acpi_table_header **table,
u8 must_be_aml_table);
acpi_status acpi_db_load_tables(struct acpi_new_table_desc *list_head);

/*
* dbhistry - debugger HISTORY command
Expand Down
7 changes: 7 additions & 0 deletions drivers/acpi/acpica/aclocal.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ struct acpi_table_list {
#define ACPI_ROOT_ORIGIN_ALLOCATED (1)
#define ACPI_ROOT_ALLOW_RESIZE (2)

/* List to manage incoming ACPI tables */

struct acpi_new_table_desc {
struct acpi_table_header *table;
struct acpi_new_table_desc *next;
};

/* Predefined table indexes */

#define ACPI_INVALID_TABLE_INDEX (0xFFFFFFFF)
Expand Down
12 changes: 0 additions & 12 deletions drivers/acpi/acpica/acutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,18 +352,6 @@ acpi_ut_execute_power_methods(struct acpi_namespace_node *device_node,
const char **method_names,
u8 method_count, u8 *out_values);

/*
* utfileio - file operations
*/
#ifdef ACPI_APPLICATION

acpi_status
acpi_ut_read_tables_from_file(FILE * file, struct acpi_table_header **table);

acpi_status
acpi_ut_read_table_from_file(char *filename, struct acpi_table_header **table);
#endif

/*
* utids - device ID support
*/
Expand Down
123 changes: 15 additions & 108 deletions drivers/acpi/acpica/dbfileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
#include "accommon.h"
#include "acdebug.h"
#include "actables.h"
#include <stdio.h>
#ifdef ACPI_APPLICATION
#include "acapps.h"
#endif

#define _COMPONENT ACPI_CA_DEBUGGER
ACPI_MODULE_NAME("dbfileio")
Expand Down Expand Up @@ -110,122 +114,31 @@ void acpi_db_open_debug_file(char *name)
}
#endif

#ifdef ACPI_APPLICATION
#include "acapps.h"

/*******************************************************************************
*
* FUNCTION: ae_local_load_table
*
* PARAMETERS: table - pointer to a buffer containing the entire
* table to be loaded
*
* RETURN: Status
*
* DESCRIPTION: This function is called to load a table from the caller's
* buffer. The buffer must contain an entire ACPI Table including
* a valid header. The header fields will be verified, and if it
* is determined that the table is invalid, the call will fail.
*
******************************************************************************/

static acpi_status ae_local_load_table(struct acpi_table_header *table)
{
acpi_status status = AE_OK;

ACPI_FUNCTION_TRACE(ae_local_load_table);

#if 0
/* struct acpi_table_desc table_info; */

if (!table) {
return_ACPI_STATUS(AE_BAD_PARAMETER);
}

table_info.pointer = table;
status = acpi_tb_recognize_table(&table_info, ACPI_TABLE_ALL);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}

/* Install the new table into the local data structures */

status = acpi_tb_init_table_descriptor(&table_info);
if (ACPI_FAILURE(status)) {
if (status == AE_ALREADY_EXISTS) {

/* Table already exists, no error */

status = AE_OK;
}

/* Free table allocated by acpi_tb_get_table */

acpi_tb_delete_single_table(&table_info);
return_ACPI_STATUS(status);
}
#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))

status =
acpi_ns_load_table(table_info.installed_desc, acpi_gbl_root_node);
if (ACPI_FAILURE(status)) {

/* Uninstall table and free the buffer */

acpi_tb_delete_tables_by_type(ACPI_TABLE_ID_DSDT);
return_ACPI_STATUS(status);
}
#endif
#endif

return_ACPI_STATUS(status);
}
#endif

/*******************************************************************************
*
* FUNCTION: acpi_db_get_table_from_file
* FUNCTION: acpi_db_load_tables
*
* PARAMETERS: filename - File where table is located
* return_table - Where a pointer to the table is returned
* PARAMETERS: list_head - List of ACPI tables to load
*
* RETURN: Status
*
* DESCRIPTION: Load an ACPI table from a file
* DESCRIPTION: Load ACPI tables from a previously constructed table list.
*
******************************************************************************/

acpi_status
acpi_db_get_table_from_file(char *filename,
struct acpi_table_header **return_table,
u8 must_be_aml_file)
acpi_status acpi_db_load_tables(struct acpi_new_table_desc *list_head)
{
#ifdef ACPI_APPLICATION
acpi_status status;
struct acpi_new_table_desc *table_list_head;
struct acpi_table_header *table;
u8 is_aml_table = TRUE;

status = acpi_ut_read_table_from_file(filename, &table);
if (ACPI_FAILURE(status)) {
return (status);
}

if (must_be_aml_file) {
is_aml_table = acpi_ut_is_aml_table(table);
if (!is_aml_table) {
ACPI_EXCEPTION((AE_INFO, AE_OK,
"Input for -e is not an AML table: "
"\"%4.4s\" (must be DSDT/SSDT)",
table->signature));
return (AE_TYPE);
}
}

if (is_aml_table) {
/* Load all ACPI tables in the list */

/* Attempt to recognize and install the table */
table_list_head = list_head;
while (table_list_head) {
table = table_list_head->table;

status = ae_local_load_table(table);
status = acpi_load_table(table);
if (ACPI_FAILURE(status)) {
if (status == AE_ALREADY_EXISTS) {
acpi_os_printf
Expand All @@ -239,18 +152,12 @@ acpi_db_get_table_from_file(char *filename,
return (status);
}

acpi_tb_print_table_header(0, table);

fprintf(stderr,
"Acpi table [%4.4s] successfully installed and loaded\n",
table->signature);
}

acpi_gbl_acpi_hardware_present = FALSE;
if (return_table) {
*return_table = table;
table_list_head = table_list_head->next;
}

#endif /* ACPI_APPLICATION */
return (AE_OK);
}
19 changes: 15 additions & 4 deletions drivers/acpi/acpica/dbinput.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
#include "accommon.h"
#include "acdebug.h"

#ifdef ACPI_APPLICATION
#include "acapps.h"
#endif

#define _COMPONENT ACPI_CA_DEBUGGER
ACPI_MODULE_NAME("dbinput")

Expand Down Expand Up @@ -1048,11 +1052,18 @@ acpi_db_command_dispatch(char *input_buffer,
acpi_db_close_debug_file();
break;

case CMD_LOAD:
case CMD_LOAD:{
struct acpi_new_table_desc *list_head = NULL;

status =
acpi_db_get_table_from_file(acpi_gbl_db_args[1], NULL,
FALSE);
status =
acpi_ac_get_all_tables_from_file(acpi_gbl_db_args
[1],
ACPI_GET_ALL_TABLES,
&list_head);
if (ACPI_SUCCESS(status)) {
acpi_db_load_tables(list_head);
}
}
break;

case CMD_OPEN:
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/acpica/tbxfload.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ acpi_status acpi_tb_load_namespace(void)

if (!tables_failed) {
ACPI_INFO((AE_INFO,
"%u ACPI AML tables successfully acquired and loaded",
"%u ACPI AML tables successfully acquired and loaded\n",
tables_loaded));
} else {
ACPI_ERROR((AE_INFO,
Expand Down
Loading

0 comments on commit 2ba7379

Please sign in to comment.