Commit fbee6b21 authored by Lv Zheng's avatar Lv Zheng Committed by Rafael J. Wysocki

ACPICA: acpidump: Add memory/string OSL usage to improve portability

This patch adds code to use generic OSL for acpidump to improve the
portability of this tool. Lv Zheng.
Signed-off-by: default avatarLv Zheng <lv.zheng@intel.com>
Signed-off-by: default avatarBob Moore <robert.moore@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent a92e9577
...@@ -126,6 +126,7 @@ ...@@ -126,6 +126,7 @@
#ifdef ACPI_DUMP_APP #ifdef ACPI_DUMP_APP
#define ACPI_USE_NATIVE_MEMORY_MAPPING #define ACPI_USE_NATIVE_MEMORY_MAPPING
#define USE_NATIVE_ALLOCATE_ZEROED
#endif #endif
/* acpi_names/Example configuration. Hardware disabled */ /* acpi_names/Example configuration. Hardware disabled */
......
...@@ -252,7 +252,7 @@ int ap_dump_all_tables(void) ...@@ -252,7 +252,7 @@ int ap_dump_all_tables(void)
} }
table_status = ap_dump_table_buffer(table, instance, address); table_status = ap_dump_table_buffer(table, instance, address);
free(table); ACPI_FREE(table);
if (table_status) { if (table_status) {
break; break;
...@@ -303,7 +303,7 @@ int ap_dump_table_by_address(char *ascii_address) ...@@ -303,7 +303,7 @@ int ap_dump_table_by_address(char *ascii_address)
} }
table_status = ap_dump_table_buffer(table, 0, address); table_status = ap_dump_table_buffer(table, 0, address);
free(table); ACPI_FREE(table);
return (table_status); return (table_status);
} }
...@@ -329,7 +329,7 @@ int ap_dump_table_by_name(char *signature) ...@@ -329,7 +329,7 @@ int ap_dump_table_by_name(char *signature)
acpi_status status; acpi_status status;
int table_status; int table_status;
if (strlen(signature) != ACPI_NAME_SIZE) { if (ACPI_STRLEN(signature) != ACPI_NAME_SIZE) {
fprintf(stderr, fprintf(stderr,
"Invalid table signature [%s]: must be exactly 4 characters\n", "Invalid table signature [%s]: must be exactly 4 characters\n",
signature); signature);
...@@ -338,15 +338,15 @@ int ap_dump_table_by_name(char *signature) ...@@ -338,15 +338,15 @@ int ap_dump_table_by_name(char *signature)
/* Table signatures are expected to be uppercase */ /* Table signatures are expected to be uppercase */
strcpy(local_signature, signature); ACPI_STRCPY(local_signature, signature);
acpi_ut_strupr(local_signature); acpi_ut_strupr(local_signature);
/* To be friendly, handle tables whose signatures do not match the name */ /* To be friendly, handle tables whose signatures do not match the name */
if (ACPI_COMPARE_NAME(local_signature, "FADT")) { if (ACPI_COMPARE_NAME(local_signature, "FADT")) {
strcpy(local_signature, ACPI_SIG_FADT); ACPI_STRCPY(local_signature, ACPI_SIG_FADT);
} else if (ACPI_COMPARE_NAME(local_signature, "MADT")) { } else if (ACPI_COMPARE_NAME(local_signature, "MADT")) {
strcpy(local_signature, ACPI_SIG_MADT); ACPI_STRCPY(local_signature, ACPI_SIG_MADT);
} }
/* Dump all instances of this signature (to handle multiple SSDTs) */ /* Dump all instances of this signature (to handle multiple SSDTs) */
...@@ -369,7 +369,7 @@ int ap_dump_table_by_name(char *signature) ...@@ -369,7 +369,7 @@ int ap_dump_table_by_name(char *signature)
} }
table_status = ap_dump_table_buffer(table, instance, address); table_status = ap_dump_table_buffer(table, instance, address);
free(table); ACPI_FREE(table);
if (table_status) { if (table_status) {
break; break;
...@@ -424,6 +424,6 @@ int ap_dump_table_from_file(char *pathname) ...@@ -424,6 +424,6 @@ int ap_dump_table_from_file(char *pathname)
table_status = ap_dump_table_buffer(table, 0, 0); table_status = ap_dump_table_buffer(table, 0, 0);
exit: exit:
free(table); ACPI_FREE(table);
return (table_status); return (table_status);
} }
...@@ -130,11 +130,12 @@ int ap_write_to_binary_file(struct acpi_table_header *table, u32 instance) ...@@ -130,11 +130,12 @@ int ap_write_to_binary_file(struct acpi_table_header *table, u32 instance)
/* Handle multiple SSDts - create different filenames for each */ /* Handle multiple SSDts - create different filenames for each */
if (instance > 0) { if (instance > 0) {
sprintf(instance_str, "%u", instance); acpi_ut_snprintf(instance_str, sizeof(instance_str), "%u",
strcat(filename, instance_str); instance);
ACPI_STRCAT(filename, instance_str);
} }
strcat(filename, ACPI_TABLE_FILE_SUFFIX); ACPI_STRCAT(filename, ACPI_TABLE_FILE_SUFFIX);
if (gbl_verbose_mode) { if (gbl_verbose_mode) {
fprintf(stderr, fprintf(stderr,
...@@ -202,7 +203,7 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname, ...@@ -202,7 +203,7 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname,
/* Allocate a buffer for the entire file */ /* Allocate a buffer for the entire file */
buffer = calloc(1, file_size); buffer = ACPI_ALLOCATE_ZEROED(file_size);
if (!buffer) { if (!buffer) {
fprintf(stderr, fprintf(stderr,
"Could not allocate file buffer of size: %u\n", "Could not allocate file buffer of size: %u\n",
...@@ -215,7 +216,7 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname, ...@@ -215,7 +216,7 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname,
actual = fread(buffer, 1, file_size, file); actual = fread(buffer, 1, file_size, file);
if (actual != file_size) { if (actual != file_size) {
fprintf(stderr, "Could not read input file: %s\n", pathname); fprintf(stderr, "Could not read input file: %s\n", pathname);
free(buffer); ACPI_FREE(buffer);
buffer = NULL; buffer = NULL;
goto cleanup; goto cleanup;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment