summaryrefslogtreecommitdiffstats
path: root/tools/power/acpi/tools/acpidump/apdump.c
diff options
context:
space:
mode:
authorLv Zheng <lv.zheng@intel.com>2014-07-08 10:07:46 +0800
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-07-08 14:22:27 +0200
commitdcaff16df2750a400db1983754542f2cc6bf4e93 (patch)
tree3f2f141e7f9dfa89ac4577933357db10bd34f8d6 /tools/power/acpi/tools/acpidump/apdump.c
parent135610f792addb71af7be0e00aa7486429bf7a37 (diff)
downloadblackbird-op-linux-dcaff16df2750a400db1983754542f2cc6bf4e93.tar.gz
blackbird-op-linux-dcaff16df2750a400db1983754542f2cc6bf4e93.zip
ACPICA: acpidump: Replace file IOs with new APIs to improve portability
The new APIs are enabled to offer a portable layer to access files: 1. acpi_os_XXX_file_XXX: Wrapper of fopen/fclose/fread/fwrite 2. acpi_os_printf: Wrapper of printf 3. acpi_log_error: Wrapper of fprintf(stderr) This patch deploys such mechanisms to acpidump to improve the portability of this tool. Lv Zheng. Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'tools/power/acpi/tools/acpidump/apdump.c')
-rw-r--r--tools/power/acpi/tools/acpidump/apdump.c65
1 files changed, 32 insertions, 33 deletions
diff --git a/tools/power/acpi/tools/acpidump/apdump.c b/tools/power/acpi/tools/acpidump/apdump.c
index ccb6262829d6..34fa5f25be39 100644
--- a/tools/power/acpi/tools/acpidump/apdump.c
+++ b/tools/power/acpi/tools/acpidump/apdump.c
@@ -69,17 +69,16 @@ u8 ap_is_valid_header(struct acpi_table_header *table)
/* Make sure signature is all ASCII and a valid ACPI name */
if (!acpi_ut_valid_acpi_name(table->signature)) {
- fprintf(stderr,
- "Table signature (0x%8.8X) is invalid\n",
- *(u32 *)table->signature);
+ acpi_log_error("Table signature (0x%8.8X) is invalid\n",
+ *(u32 *)table->signature);
return (FALSE);
}
/* Check for minimum table length */
if (table->length < sizeof(struct acpi_table_header)) {
- fprintf(stderr, "Table length (0x%8.8X) is invalid\n",
- table->length);
+ acpi_log_error("Table length (0x%8.8X) is invalid\n",
+ table->length);
return (FALSE);
}
}
@@ -116,8 +115,8 @@ u8 ap_is_valid_checksum(struct acpi_table_header *table)
}
if (ACPI_FAILURE(status)) {
- fprintf(stderr, "%4.4s: Warning: wrong checksum in table\n",
- table->signature);
+ acpi_log_error("%4.4s: Warning: wrong checksum in table\n",
+ table->signature);
}
return (AE_OK);
@@ -196,12 +195,12 @@ ap_dump_table_buffer(struct acpi_table_header *table,
* Note: simplest to just always emit a 64-bit address. acpi_xtract
* utility can handle this.
*/
- printf("%4.4s @ 0x%8.8X%8.8X\n", table->signature,
- ACPI_FORMAT_UINT64(address));
+ acpi_os_printf("%4.4s @ 0x%8.8X%8.8X\n", table->signature,
+ ACPI_FORMAT_UINT64(address));
acpi_ut_dump_buffer(ACPI_CAST_PTR(u8, table), table_length,
DB_BYTE_DISPLAY, 0);
- printf("\n");
+ acpi_os_printf("\n");
return (0);
}
@@ -239,14 +238,14 @@ int ap_dump_all_tables(void)
if (status == AE_LIMIT) {
return (0);
} else if (i == 0) {
- fprintf(stderr,
- "Could not get ACPI tables, %s\n",
- acpi_format_exception(status));
+ acpi_log_error
+ ("Could not get ACPI tables, %s\n",
+ acpi_format_exception(status));
return (-1);
} else {
- fprintf(stderr,
- "Could not get ACPI table at index %u, %s\n",
- i, acpi_format_exception(status));
+ acpi_log_error
+ ("Could not get ACPI table at index %u, %s\n",
+ i, acpi_format_exception(status));
continue;
}
}
@@ -288,17 +287,17 @@ int ap_dump_table_by_address(char *ascii_address)
status = acpi_ut_strtoul64(ascii_address, 0, &long_address);
if (ACPI_FAILURE(status)) {
- fprintf(stderr, "%s: Could not convert to a physical address\n",
- ascii_address);
+ acpi_log_error("%s: Could not convert to a physical address\n",
+ ascii_address);
return (-1);
}
address = (acpi_physical_address) long_address;
status = acpi_os_get_table_by_address(address, &table);
if (ACPI_FAILURE(status)) {
- fprintf(stderr, "Could not get table at 0x%8.8X%8.8X, %s\n",
- ACPI_FORMAT_UINT64(address),
- acpi_format_exception(status));
+ acpi_log_error("Could not get table at 0x%8.8X%8.8X, %s\n",
+ ACPI_FORMAT_UINT64(address),
+ acpi_format_exception(status));
return (-1);
}
@@ -330,9 +329,9 @@ int ap_dump_table_by_name(char *signature)
int table_status;
if (ACPI_STRLEN(signature) != ACPI_NAME_SIZE) {
- fprintf(stderr,
- "Invalid table signature [%s]: must be exactly 4 characters\n",
- signature);
+ acpi_log_error
+ ("Invalid table signature [%s]: must be exactly 4 characters\n",
+ signature);
return (-1);
}
@@ -362,9 +361,9 @@ int ap_dump_table_by_name(char *signature)
return (0);
}
- fprintf(stderr,
- "Could not get ACPI table with signature [%s], %s\n",
- local_signature, acpi_format_exception(status));
+ acpi_log_error
+ ("Could not get ACPI table with signature [%s], %s\n",
+ local_signature, acpi_format_exception(status));
return (-1);
}
@@ -409,16 +408,16 @@ int ap_dump_table_from_file(char *pathname)
/* File must be at least as long as the table length */
if (table->length > file_size) {
- fprintf(stderr,
- "Table length (0x%X) is too large for input file (0x%X) %s\n",
- table->length, file_size, pathname);
+ acpi_log_error
+ ("Table length (0x%X) is too large for input file (0x%X) %s\n",
+ table->length, file_size, pathname);
goto exit;
}
if (gbl_verbose_mode) {
- fprintf(stderr,
- "Input file: %s contains table [%4.4s], 0x%X (%u) bytes\n",
- pathname, table->signature, file_size, file_size);
+ acpi_log_error
+ ("Input file: %s contains table [%4.4s], 0x%X (%u) bytes\n",
+ pathname, table->signature, file_size, file_size);
}
table_status = ap_dump_table_buffer(table, 0, 0);
OpenPOWER on IntegriCloud