aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-10-01 19:37:32 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-10-01 19:37:32 -0400
commit9274139f4e8bb0835a5a6224957e15b8e63693e4 (patch)
treeb5c282b0087aef2532948cc8901faabe964f1422 /tools
parent52ff5adc1f942008a790d6f964dec13793480c27 (diff)
parent7a0b71dc80f2b829c8587267d188712f614a4727 (diff)
Merge branch 'acpica'
* acpica: (45 commits) ACPICA: Parser: Fix a regression in LoadTable support ACPICA: Tables: Fix "UNLOAD" code path lock issues ACPICA: Tables: Fix a regression in acpi_tb_find_table() ACPICA: Update version to 20160831 ACPICA: Tables: Tune table mutex to be a leaf lock ACPICA: Dispatcher: Fix a mutex issue for method auto serialization ACPICA: Namespace: Fix dynamic table loading issues ACPICA: Namespace: Add acpi_ns_get_node_unlocked() ACPICA: Interpreter: Fix MLC issues by switching to new term_list grammar for table loading ACPICA: Update return value for intenal _OSI method ACPICA: Tables: Override all 64-bit GAS fields when acpi_gbl_use32_bit_fadt_addresses is TRUE ACPICA: Tables: Add new table events indicating table installation/uninstallation ACPICA: Tables: Remove wrong table event macros ACPICA: Tables: Remove acpi_tb_install_fixed_table() ACPICA: Add a couple of casts to uthex.c ACPICA: Cleanup for all string-to-integer conversions ACPICA: Debugger: Add subcommand for predefined name execution ACPICA: Update version to 20160729 ACPICA: OSL: Fix a regression that old GCC requires a workaround for strchr() ACPICA: OSL: Cleanup the inclusion order of the compiler-specific headers ...
Diffstat (limited to 'tools')
-rw-r--r--tools/power/acpi/common/cmfsize.c13
-rw-r--r--tools/power/acpi/common/getopt.c4
-rw-r--r--tools/power/acpi/os_specific/service_layers/oslibcfs.c217
-rw-r--r--tools/power/acpi/os_specific/service_layers/osunixxf.c3
-rw-r--r--tools/power/acpi/tools/acpidump/Makefile3
-rw-r--r--tools/power/acpi/tools/acpidump/acpidump.h12
-rw-r--r--tools/power/acpi/tools/acpidump/apdump.c75
-rw-r--r--tools/power/acpi/tools/acpidump/apfiles.c56
-rw-r--r--tools/power/acpi/tools/acpidump/apmain.c37
9 files changed, 96 insertions, 324 deletions
diff --git a/tools/power/acpi/common/cmfsize.c b/tools/power/acpi/common/cmfsize.c
index e73a79fce015..bc82596d7354 100644
--- a/tools/power/acpi/common/cmfsize.c
+++ b/tools/power/acpi/common/cmfsize.c
@@ -44,7 +44,6 @@
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include "accommon.h" 45#include "accommon.h"
46#include "acapps.h" 46#include "acapps.h"
47#include <stdio.h>
48 47
49#define _COMPONENT ACPI_TOOLS 48#define _COMPONENT ACPI_TOOLS
50ACPI_MODULE_NAME("cmfsize") 49ACPI_MODULE_NAME("cmfsize")
@@ -69,24 +68,24 @@ u32 cm_get_file_size(ACPI_FILE file)
69 68
70 /* Save the current file pointer, seek to EOF to obtain file size */ 69 /* Save the current file pointer, seek to EOF to obtain file size */
71 70
72 current_offset = acpi_os_get_file_offset(file); 71 current_offset = ftell(file);
73 if (current_offset < 0) { 72 if (current_offset < 0) {
74 goto offset_error; 73 goto offset_error;
75 } 74 }
76 75
77 status = acpi_os_set_file_offset(file, 0, ACPI_FILE_END); 76 status = fseek(file, 0, SEEK_END);
78 if (ACPI_FAILURE(status)) { 77 if (ACPI_FAILURE(status)) {
79 goto seek_error; 78 goto seek_error;
80 } 79 }
81 80
82 file_size = acpi_os_get_file_offset(file); 81 file_size = ftell(file);
83 if (file_size < 0) { 82 if (file_size < 0) {
84 goto offset_error; 83 goto offset_error;
85 } 84 }
86 85
87 /* Restore original file pointer */ 86 /* Restore original file pointer */
88 87
89 status = acpi_os_set_file_offset(file, current_offset, ACPI_FILE_BEGIN); 88 status = fseek(file, current_offset, SEEK_SET);
90 if (ACPI_FAILURE(status)) { 89 if (ACPI_FAILURE(status)) {
91 goto seek_error; 90 goto seek_error;
92 } 91 }
@@ -94,10 +93,10 @@ u32 cm_get_file_size(ACPI_FILE file)
94 return ((u32)file_size); 93 return ((u32)file_size);
95 94
96offset_error: 95offset_error:
97 acpi_log_error("Could not get file offset"); 96 fprintf(stderr, "Could not get file offset\n");
98 return (ACPI_UINT32_MAX); 97 return (ACPI_UINT32_MAX);
99 98
100seek_error: 99seek_error:
101 acpi_log_error("Could not set file offset"); 100 fprintf(stderr, "Could not set file offset\n");
102 return (ACPI_UINT32_MAX); 101 return (ACPI_UINT32_MAX);
103} 102}
diff --git a/tools/power/acpi/common/getopt.c b/tools/power/acpi/common/getopt.c
index 0bd343f136a4..3919970f5aea 100644
--- a/tools/power/acpi/common/getopt.c
+++ b/tools/power/acpi/common/getopt.c
@@ -57,7 +57,7 @@
57#include "acapps.h" 57#include "acapps.h"
58 58
59#define ACPI_OPTION_ERROR(msg, badchar) \ 59#define ACPI_OPTION_ERROR(msg, badchar) \
60 if (acpi_gbl_opterr) {acpi_log_error ("%s%c\n", msg, badchar);} 60 if (acpi_gbl_opterr) {fprintf (stderr, "%s%c\n", msg, badchar);}
61 61
62int acpi_gbl_opterr = 1; 62int acpi_gbl_opterr = 1;
63int acpi_gbl_optind = 1; 63int acpi_gbl_optind = 1;
@@ -94,7 +94,7 @@ int acpi_getopt_argument(int argc, char **argv)
94 acpi_gbl_optarg = 94 acpi_gbl_optarg =
95 &argv[acpi_gbl_optind++][(int)(current_char_ptr + 1)]; 95 &argv[acpi_gbl_optind++][(int)(current_char_ptr + 1)];
96 } else if (++acpi_gbl_optind >= argc) { 96 } else if (++acpi_gbl_optind >= argc) {
97 ACPI_OPTION_ERROR("Option requires an argument: -", 'v'); 97 ACPI_OPTION_ERROR("\nOption requires an argument", 0);
98 98
99 current_char_ptr = 1; 99 current_char_ptr = 1;
100 return (-1); 100 return (-1);
diff --git a/tools/power/acpi/os_specific/service_layers/oslibcfs.c b/tools/power/acpi/os_specific/service_layers/oslibcfs.c
deleted file mode 100644
index 11f4aba55aab..000000000000
--- a/tools/power/acpi/os_specific/service_layers/oslibcfs.c
+++ /dev/null
@@ -1,217 +0,0 @@
1/******************************************************************************
2 *
3 * Module Name: oslibcfs - C library OSL for file I/O
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2016, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include <stdio.h>
46#include <stdarg.h>
47
48#define _COMPONENT ACPI_OS_SERVICES
49ACPI_MODULE_NAME("oslibcfs")
50
51/*******************************************************************************
52 *
53 * FUNCTION: acpi_os_open_file
54 *
55 * PARAMETERS: path - File path
56 * modes - File operation type
57 *
58 * RETURN: File descriptor.
59 *
60 * DESCRIPTION: Open a file for reading (ACPI_FILE_READING) or/and writing
61 * (ACPI_FILE_WRITING).
62 *
63 ******************************************************************************/
64ACPI_FILE acpi_os_open_file(const char *path, u8 modes)
65{
66 ACPI_FILE file;
67 u32 i = 0;
68 char modes_str[4];
69
70 if (modes & ACPI_FILE_READING) {
71 modes_str[i++] = 'r';
72 }
73 if (modes & ACPI_FILE_WRITING) {
74 modes_str[i++] = 'w';
75 }
76
77 if (modes & ACPI_FILE_BINARY) {
78 modes_str[i++] = 'b';
79 }
80
81 modes_str[i++] = '\0';
82
83 file = fopen(path, modes_str);
84 if (!file) {
85 perror("Could not open file");
86 }
87
88 return (file);
89}
90
91/*******************************************************************************
92 *
93 * FUNCTION: acpi_os_close_file
94 *
95 * PARAMETERS: file - An open file descriptor
96 *
97 * RETURN: None.
98 *
99 * DESCRIPTION: Close a file opened via acpi_os_open_file.
100 *
101 ******************************************************************************/
102
103void acpi_os_close_file(ACPI_FILE file)
104{
105
106 fclose(file);
107}
108
109/*******************************************************************************
110 *
111 * FUNCTION: acpi_os_read_file
112 *
113 * PARAMETERS: file - An open file descriptor
114 * buffer - Data buffer
115 * size - Data block size
116 * count - Number of data blocks
117 *
118 * RETURN: Number of bytes actually read.
119 *
120 * DESCRIPTION: Read from a file.
121 *
122 ******************************************************************************/
123
124int
125acpi_os_read_file(ACPI_FILE file, void *buffer, acpi_size size, acpi_size count)
126{
127 int length;
128
129 length = fread(buffer, size, count, file);
130 if (length < 0) {
131 perror("Error reading file");
132 }
133
134 return (length);
135}
136
137/*******************************************************************************
138 *
139 * FUNCTION: acpi_os_write_file
140 *
141 * PARAMETERS: file - An open file descriptor
142 * buffer - Data buffer
143 * size - Data block size
144 * count - Number of data blocks
145 *
146 * RETURN: Number of bytes actually written.
147 *
148 * DESCRIPTION: Write to a file.
149 *
150 ******************************************************************************/
151
152int
153acpi_os_write_file(ACPI_FILE file,
154 void *buffer, acpi_size size, acpi_size count)
155{
156 int length;
157
158 length = fwrite(buffer, size, count, file);
159 if (length < 0) {
160 perror("Error writing file");
161 }
162
163 return (length);
164}
165
166/*******************************************************************************
167 *
168 * FUNCTION: acpi_os_get_file_offset
169 *
170 * PARAMETERS: file - An open file descriptor
171 *
172 * RETURN: Current file pointer position.
173 *
174 * DESCRIPTION: Get current file offset.
175 *
176 ******************************************************************************/
177
178long acpi_os_get_file_offset(ACPI_FILE file)
179{
180 long offset;
181
182 offset = ftell(file);
183 return (offset);
184}
185
186/*******************************************************************************
187 *
188 * FUNCTION: acpi_os_set_file_offset
189 *
190 * PARAMETERS: file - An open file descriptor
191 * offset - New file offset
192 * from - From begin/end of file
193 *
194 * RETURN: Status
195 *
196 * DESCRIPTION: Set current file offset.
197 *
198 ******************************************************************************/
199
200acpi_status acpi_os_set_file_offset(ACPI_FILE file, long offset, u8 from)
201{
202 int ret = 0;
203
204 if (from == ACPI_FILE_BEGIN) {
205 ret = fseek(file, offset, SEEK_SET);
206 }
207
208 if (from == ACPI_FILE_END) {
209 ret = fseek(file, offset, SEEK_END);
210 }
211
212 if (ret < 0) {
213 return (AE_ERROR);
214 } else {
215 return (AE_OK);
216 }
217}
diff --git a/tools/power/acpi/os_specific/service_layers/osunixxf.c b/tools/power/acpi/os_specific/service_layers/osunixxf.c
index 88aa66ef4ad5..8d8003c919d4 100644
--- a/tools/power/acpi/os_specific/service_layers/osunixxf.c
+++ b/tools/power/acpi/os_specific/service_layers/osunixxf.c
@@ -63,10 +63,7 @@
63#define _COMPONENT ACPI_OS_SERVICES 63#define _COMPONENT ACPI_OS_SERVICES
64ACPI_MODULE_NAME("osunixxf") 64ACPI_MODULE_NAME("osunixxf")
65 65
66u8 acpi_gbl_debug_timeout = FALSE;
67
68/* Upcalls to acpi_exec */ 66/* Upcalls to acpi_exec */
69
70void 67void
71ae_table_override(struct acpi_table_header *existing_table, 68ae_table_override(struct acpi_table_header *existing_table,
72 struct acpi_table_header **new_table); 69 struct acpi_table_header **new_table);
diff --git a/tools/power/acpi/tools/acpidump/Makefile b/tools/power/acpi/tools/acpidump/Makefile
index 2942cdced2ad..04b5db7c7c0b 100644
--- a/tools/power/acpi/tools/acpidump/Makefile
+++ b/tools/power/acpi/tools/acpidump/Makefile
@@ -36,12 +36,13 @@ TOOL_OBJS = \
36 utdebug.o\ 36 utdebug.o\
37 utexcep.o\ 37 utexcep.o\
38 utglobal.o\ 38 utglobal.o\
39 uthex.o\
39 utmath.o\ 40 utmath.o\
40 utnonansi.o\ 41 utnonansi.o\
41 utprint.o\ 42 utprint.o\
42 utstring.o\ 43 utstring.o\
44 utstrtoul64.o\
43 utxferror.o\ 45 utxferror.o\
44 oslibcfs.o\
45 oslinuxtbl.o\ 46 oslinuxtbl.o\
46 cmfsize.o\ 47 cmfsize.o\
47 getopt.o 48 getopt.o
diff --git a/tools/power/acpi/tools/acpidump/acpidump.h b/tools/power/acpi/tools/acpidump/acpidump.h
index 025c232e920d..00423fc45e7c 100644
--- a/tools/power/acpi/tools/acpidump/acpidump.h
+++ b/tools/power/acpi/tools/acpidump/acpidump.h
@@ -55,11 +55,7 @@
55#include <acpi/acpi.h> 55#include <acpi/acpi.h>
56#include "accommon.h" 56#include "accommon.h"
57#include "actables.h" 57#include "actables.h"
58 58#include "acapps.h"
59#include <stdio.h>
60#include <fcntl.h>
61#include <errno.h>
62#include <sys/stat.h>
63 59
64/* Globals */ 60/* Globals */
65 61
@@ -72,12 +68,6 @@ EXTERN ACPI_FILE INIT_GLOBAL(gbl_output_file, NULL);
72EXTERN char INIT_GLOBAL(*gbl_output_filename, NULL); 68EXTERN char INIT_GLOBAL(*gbl_output_filename, NULL);
73EXTERN u64 INIT_GLOBAL(gbl_rsdp_base, 0); 69EXTERN u64 INIT_GLOBAL(gbl_rsdp_base, 0);
74 70
75/* Globals required for use with ACPICA modules */
76
77#ifdef _DECLARE_GLOBALS
78u8 acpi_gbl_integer_byte_width = 8;
79#endif
80
81/* Action table used to defer requested options */ 71/* Action table used to defer requested options */
82 72
83struct ap_dump_action { 73struct ap_dump_action {
diff --git a/tools/power/acpi/tools/acpidump/apdump.c b/tools/power/acpi/tools/acpidump/apdump.c
index fb8f1d9e3b1b..9031be1afe63 100644
--- a/tools/power/acpi/tools/acpidump/apdump.c
+++ b/tools/power/acpi/tools/acpidump/apdump.c
@@ -69,16 +69,17 @@ u8 ap_is_valid_header(struct acpi_table_header *table)
69 /* Make sure signature is all ASCII and a valid ACPI name */ 69 /* Make sure signature is all ASCII and a valid ACPI name */
70 70
71 if (!acpi_ut_valid_nameseg(table->signature)) { 71 if (!acpi_ut_valid_nameseg(table->signature)) {
72 acpi_log_error("Table signature (0x%8.8X) is invalid\n", 72 fprintf(stderr,
73 *(u32 *)table->signature); 73 "Table signature (0x%8.8X) is invalid\n",
74 *(u32 *)table->signature);
74 return (FALSE); 75 return (FALSE);
75 } 76 }
76 77
77 /* Check for minimum table length */ 78 /* Check for minimum table length */
78 79
79 if (table->length < sizeof(struct acpi_table_header)) { 80 if (table->length < sizeof(struct acpi_table_header)) {
80 acpi_log_error("Table length (0x%8.8X) is invalid\n", 81 fprintf(stderr, "Table length (0x%8.8X) is invalid\n",
81 table->length); 82 table->length);
82 return (FALSE); 83 return (FALSE);
83 } 84 }
84 } 85 }
@@ -115,8 +116,8 @@ u8 ap_is_valid_checksum(struct acpi_table_header *table)
115 } 116 }
116 117
117 if (ACPI_FAILURE(status)) { 118 if (ACPI_FAILURE(status)) {
118 acpi_log_error("%4.4s: Warning: wrong checksum in table\n", 119 fprintf(stderr, "%4.4s: Warning: wrong checksum in table\n",
119 table->signature); 120 table->signature);
120 } 121 }
121 122
122 return (AE_OK); 123 return (AE_OK);
@@ -195,13 +196,13 @@ ap_dump_table_buffer(struct acpi_table_header *table,
195 * Note: simplest to just always emit a 64-bit address. acpi_xtract 196 * Note: simplest to just always emit a 64-bit address. acpi_xtract
196 * utility can handle this. 197 * utility can handle this.
197 */ 198 */
198 acpi_ut_file_printf(gbl_output_file, "%4.4s @ 0x%8.8X%8.8X\n", 199 fprintf(gbl_output_file, "%4.4s @ 0x%8.8X%8.8X\n",
199 table->signature, ACPI_FORMAT_UINT64(address)); 200 table->signature, ACPI_FORMAT_UINT64(address));
200 201
201 acpi_ut_dump_buffer_to_file(gbl_output_file, 202 acpi_ut_dump_buffer_to_file(gbl_output_file,
202 ACPI_CAST_PTR(u8, table), table_length, 203 ACPI_CAST_PTR(u8, table), table_length,
203 DB_BYTE_DISPLAY, 0); 204 DB_BYTE_DISPLAY, 0);
204 acpi_ut_file_printf(gbl_output_file, "\n"); 205 fprintf(gbl_output_file, "\n");
205 return (0); 206 return (0);
206} 207}
207 208
@@ -239,14 +240,14 @@ int ap_dump_all_tables(void)
239 if (status == AE_LIMIT) { 240 if (status == AE_LIMIT) {
240 return (0); 241 return (0);
241 } else if (i == 0) { 242 } else if (i == 0) {
242 acpi_log_error 243 fprintf(stderr,
243 ("Could not get ACPI tables, %s\n", 244 "Could not get ACPI tables, %s\n",
244 acpi_format_exception(status)); 245 acpi_format_exception(status));
245 return (-1); 246 return (-1);
246 } else { 247 } else {
247 acpi_log_error 248 fprintf(stderr,
248 ("Could not get ACPI table at index %u, %s\n", 249 "Could not get ACPI table at index %u, %s\n",
249 i, acpi_format_exception(status)); 250 i, acpi_format_exception(status));
250 continue; 251 continue;
251 } 252 }
252 } 253 }
@@ -286,20 +287,20 @@ int ap_dump_table_by_address(char *ascii_address)
286 287
287 /* Convert argument to an integer physical address */ 288 /* Convert argument to an integer physical address */
288 289
289 status = acpi_ut_strtoul64(ascii_address, ACPI_ANY_BASE, 290 status = acpi_ut_strtoul64(ascii_address, ACPI_STRTOUL_64BIT,
290 ACPI_MAX64_BYTE_WIDTH, &long_address); 291 &long_address);
291 if (ACPI_FAILURE(status)) { 292 if (ACPI_FAILURE(status)) {
292 acpi_log_error("%s: Could not convert to a physical address\n", 293 fprintf(stderr, "%s: Could not convert to a physical address\n",
293 ascii_address); 294 ascii_address);
294 return (-1); 295 return (-1);
295 } 296 }
296 297
297 address = (acpi_physical_address)long_address; 298 address = (acpi_physical_address)long_address;
298 status = acpi_os_get_table_by_address(address, &table); 299 status = acpi_os_get_table_by_address(address, &table);
299 if (ACPI_FAILURE(status)) { 300 if (ACPI_FAILURE(status)) {
300 acpi_log_error("Could not get table at 0x%8.8X%8.8X, %s\n", 301 fprintf(stderr, "Could not get table at 0x%8.8X%8.8X, %s\n",
301 ACPI_FORMAT_UINT64(address), 302 ACPI_FORMAT_UINT64(address),
302 acpi_format_exception(status)); 303 acpi_format_exception(status));
303 return (-1); 304 return (-1);
304 } 305 }
305 306
@@ -331,9 +332,9 @@ int ap_dump_table_by_name(char *signature)
331 int table_status; 332 int table_status;
332 333
333 if (strlen(signature) != ACPI_NAME_SIZE) { 334 if (strlen(signature) != ACPI_NAME_SIZE) {
334 acpi_log_error 335 fprintf(stderr,
335 ("Invalid table signature [%s]: must be exactly 4 characters\n", 336 "Invalid table signature [%s]: must be exactly 4 characters\n",
336 signature); 337 signature);
337 return (-1); 338 return (-1);
338 } 339 }
339 340
@@ -363,9 +364,9 @@ int ap_dump_table_by_name(char *signature)
363 return (0); 364 return (0);
364 } 365 }
365 366
366 acpi_log_error 367 fprintf(stderr,
367 ("Could not get ACPI table with signature [%s], %s\n", 368 "Could not get ACPI table with signature [%s], %s\n",
368 local_signature, acpi_format_exception(status)); 369 local_signature, acpi_format_exception(status));
369 return (-1); 370 return (-1);
370 } 371 }
371 372
@@ -408,24 +409,24 @@ int ap_dump_table_from_file(char *pathname)
408 } 409 }
409 410
410 if (!acpi_ut_valid_nameseg(table->signature)) { 411 if (!acpi_ut_valid_nameseg(table->signature)) {
411 acpi_log_error 412 fprintf(stderr,
412 ("No valid ACPI signature was found in input file %s\n", 413 "No valid ACPI signature was found in input file %s\n",
413 pathname); 414 pathname);
414 } 415 }
415 416
416 /* File must be at least as long as the table length */ 417 /* File must be at least as long as the table length */
417 418
418 if (table->length > file_size) { 419 if (table->length > file_size) {
419 acpi_log_error 420 fprintf(stderr,
420 ("Table length (0x%X) is too large for input file (0x%X) %s\n", 421 "Table length (0x%X) is too large for input file (0x%X) %s\n",
421 table->length, file_size, pathname); 422 table->length, file_size, pathname);
422 goto exit; 423 goto exit;
423 } 424 }
424 425
425 if (gbl_verbose_mode) { 426 if (gbl_verbose_mode) {
426 acpi_log_error 427 fprintf(stderr,
427 ("Input file: %s contains table [%4.4s], 0x%X (%u) bytes\n", 428 "Input file: %s contains table [%4.4s], 0x%X (%u) bytes\n",
428 pathname, table->signature, file_size, file_size); 429 pathname, table->signature, file_size, file_size);
429 } 430 }
430 431
431 table_status = ap_dump_table_buffer(table, 0, 0); 432 table_status = ap_dump_table_buffer(table, 0, 0);
diff --git a/tools/power/acpi/tools/acpidump/apfiles.c b/tools/power/acpi/tools/acpidump/apfiles.c
index 5fcd9700ac18..dd5b861dc4a8 100644
--- a/tools/power/acpi/tools/acpidump/apfiles.c
+++ b/tools/power/acpi/tools/acpidump/apfiles.c
@@ -42,7 +42,6 @@
42 */ 42 */
43 43
44#include "acpidump.h" 44#include "acpidump.h"
45#include "acapps.h"
46 45
47/* Local prototypes */ 46/* Local prototypes */
48 47
@@ -66,7 +65,8 @@ static int ap_is_existing_file(char *pathname)
66 struct stat stat_info; 65 struct stat stat_info;
67 66
68 if (!stat(pathname, &stat_info)) { 67 if (!stat(pathname, &stat_info)) {
69 acpi_log_error("Target path already exists, overwrite? [y|n] "); 68 fprintf(stderr,
69 "Target path already exists, overwrite? [y|n] ");
70 70
71 if (getchar() != 'y') { 71 if (getchar() != 'y') {
72 return (-1); 72 return (-1);
@@ -102,9 +102,9 @@ int ap_open_output_file(char *pathname)
102 102
103 /* Point stdout to the file */ 103 /* Point stdout to the file */
104 104
105 file = acpi_os_open_file(pathname, ACPI_FILE_WRITING); 105 file = fopen(pathname, "w");
106 if (!file) { 106 if (!file) {
107 acpi_log_error("Could not open output file: %s\n", pathname); 107 fprintf(stderr, "Could not open output file: %s\n", pathname);
108 return (-1); 108 return (-1);
109 } 109 }
110 110
@@ -134,7 +134,7 @@ int ap_write_to_binary_file(struct acpi_table_header *table, u32 instance)
134 char filename[ACPI_NAME_SIZE + 16]; 134 char filename[ACPI_NAME_SIZE + 16];
135 char instance_str[16]; 135 char instance_str[16];
136 ACPI_FILE file; 136 ACPI_FILE file;
137 size_t actual; 137 acpi_size actual;
138 u32 table_length; 138 u32 table_length;
139 139
140 /* Obtain table length */ 140 /* Obtain table length */
@@ -158,37 +158,36 @@ int ap_write_to_binary_file(struct acpi_table_header *table, u32 instance)
158 /* Handle multiple SSDts - create different filenames for each */ 158 /* Handle multiple SSDts - create different filenames for each */
159 159
160 if (instance > 0) { 160 if (instance > 0) {
161 acpi_ut_snprintf(instance_str, sizeof(instance_str), "%u", 161 snprintf(instance_str, sizeof(instance_str), "%u", instance);
162 instance);
163 strcat(filename, instance_str); 162 strcat(filename, instance_str);
164 } 163 }
165 164
166 strcat(filename, FILE_SUFFIX_BINARY_TABLE); 165 strcat(filename, FILE_SUFFIX_BINARY_TABLE);
167 166
168 if (gbl_verbose_mode) { 167 if (gbl_verbose_mode) {
169 acpi_log_error 168 fprintf(stderr,
170 ("Writing [%4.4s] to binary file: %s 0x%X (%u) bytes\n", 169 "Writing [%4.4s] to binary file: %s 0x%X (%u) bytes\n",
171 table->signature, filename, table->length, table->length); 170 table->signature, filename, table->length,
171 table->length);
172 } 172 }
173 173
174 /* Open the file and dump the entire table in binary mode */ 174 /* Open the file and dump the entire table in binary mode */
175 175
176 file = acpi_os_open_file(filename, 176 file = fopen(filename, "wb");
177 ACPI_FILE_WRITING | ACPI_FILE_BINARY);
178 if (!file) { 177 if (!file) {
179 acpi_log_error("Could not open output file: %s\n", filename); 178 fprintf(stderr, "Could not open output file: %s\n", filename);
180 return (-1); 179 return (-1);
181 } 180 }
182 181
183 actual = acpi_os_write_file(file, table, 1, table_length); 182 actual = fwrite(table, 1, table_length, file);
184 if (actual != table_length) { 183 if (actual != table_length) {
185 acpi_log_error("Error writing binary output file: %s\n", 184 fprintf(stderr, "Error writing binary output file: %s\n",
186 filename); 185 filename);
187 acpi_os_close_file(file); 186 fclose(file);
188 return (-1); 187 return (-1);
189 } 188 }
190 189
191 acpi_os_close_file(file); 190 fclose(file);
192 return (0); 191 return (0);
193} 192}
194 193
@@ -211,14 +210,13 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname,
211 struct acpi_table_header *buffer = NULL; 210 struct acpi_table_header *buffer = NULL;
212 ACPI_FILE file; 211 ACPI_FILE file;
213 u32 file_size; 212 u32 file_size;
214 size_t actual; 213 acpi_size actual;
215 214
216 /* Must use binary mode */ 215 /* Must use binary mode */
217 216
218 file = 217 file = fopen(pathname, "rb");
219 acpi_os_open_file(pathname, ACPI_FILE_READING | ACPI_FILE_BINARY);
220 if (!file) { 218 if (!file) {
221 acpi_log_error("Could not open input file: %s\n", pathname); 219 fprintf(stderr, "Could not open input file: %s\n", pathname);
222 return (NULL); 220 return (NULL);
223 } 221 }
224 222
@@ -226,7 +224,8 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname,
226 224
227 file_size = cm_get_file_size(file); 225 file_size = cm_get_file_size(file);
228 if (file_size == ACPI_UINT32_MAX) { 226 if (file_size == ACPI_UINT32_MAX) {
229 acpi_log_error("Could not get input file size: %s\n", pathname); 227 fprintf(stderr,
228 "Could not get input file size: %s\n", pathname);
230 goto cleanup; 229 goto cleanup;
231 } 230 }
232 231
@@ -234,16 +233,17 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname,
234 233
235 buffer = ACPI_ALLOCATE_ZEROED(file_size); 234 buffer = ACPI_ALLOCATE_ZEROED(file_size);
236 if (!buffer) { 235 if (!buffer) {
237 acpi_log_error("Could not allocate file buffer of size: %u\n", 236 fprintf(stderr,
238 file_size); 237 "Could not allocate file buffer of size: %u\n",
238 file_size);
239 goto cleanup; 239 goto cleanup;
240 } 240 }
241 241
242 /* Read the entire file */ 242 /* Read the entire file */
243 243
244 actual = acpi_os_read_file(file, buffer, 1, file_size); 244 actual = fread(buffer, 1, file_size, file);
245 if (actual != file_size) { 245 if (actual != file_size) {
246 acpi_log_error("Could not read input file: %s\n", pathname); 246 fprintf(stderr, "Could not read input file: %s\n", pathname);
247 ACPI_FREE(buffer); 247 ACPI_FREE(buffer);
248 buffer = NULL; 248 buffer = NULL;
249 goto cleanup; 249 goto cleanup;
@@ -252,6 +252,6 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname,
252 *out_file_size = file_size; 252 *out_file_size = file_size;
253 253
254cleanup: 254cleanup:
255 acpi_os_close_file(file); 255 fclose(file);
256 return (buffer); 256 return (buffer);
257} 257}
diff --git a/tools/power/acpi/tools/acpidump/apmain.c b/tools/power/acpi/tools/acpidump/apmain.c
index 7692e6b887e1..7ff46be908f0 100644
--- a/tools/power/acpi/tools/acpidump/apmain.c
+++ b/tools/power/acpi/tools/acpidump/apmain.c
@@ -43,7 +43,6 @@
43 43
44#define _DECLARE_GLOBALS 44#define _DECLARE_GLOBALS
45#include "acpidump.h" 45#include "acpidump.h"
46#include "acapps.h"
47 46
48/* 47/*
49 * acpidump - A portable utility for obtaining system ACPI tables and dumping 48 * acpidump - A portable utility for obtaining system ACPI tables and dumping
@@ -140,8 +139,8 @@ static int ap_insert_action(char *argument, u32 to_be_done)
140 139
141 current_action++; 140 current_action++;
142 if (current_action > AP_MAX_ACTIONS) { 141 if (current_action > AP_MAX_ACTIONS) {
143 acpi_log_error("Too many table options (max %u)\n", 142 fprintf(stderr, "Too many table options (max %u)\n",
144 AP_MAX_ACTIONS); 143 AP_MAX_ACTIONS);
145 return (-1); 144 return (-1);
146 } 145 }
147 146
@@ -186,9 +185,9 @@ static int ap_do_options(int argc, char **argv)
186 } else if (!strcmp(acpi_gbl_optarg, "off")) { 185 } else if (!strcmp(acpi_gbl_optarg, "off")) {
187 gbl_dump_customized_tables = FALSE; 186 gbl_dump_customized_tables = FALSE;
188 } else { 187 } else {
189 acpi_log_error 188 fprintf(stderr,
190 ("%s: Cannot handle this switch, please use on|off\n", 189 "%s: Cannot handle this switch, please use on|off\n",
191 acpi_gbl_optarg); 190 acpi_gbl_optarg);
192 return (-1); 191 return (-1);
193 } 192 }
194 continue; 193 continue;
@@ -209,13 +208,13 @@ static int ap_do_options(int argc, char **argv)
209 case 'r': /* Dump tables from specified RSDP */ 208 case 'r': /* Dump tables from specified RSDP */
210 209
211 status = 210 status =
212 acpi_ut_strtoul64(acpi_gbl_optarg, ACPI_ANY_BASE, 211 acpi_ut_strtoul64(acpi_gbl_optarg,
213 ACPI_MAX64_BYTE_WIDTH, 212 ACPI_STRTOUL_64BIT,
214 &gbl_rsdp_base); 213 &gbl_rsdp_base);
215 if (ACPI_FAILURE(status)) { 214 if (ACPI_FAILURE(status)) {
216 acpi_log_error 215 fprintf(stderr,
217 ("%s: Could not convert to a physical address\n", 216 "%s: Could not convert to a physical address\n",
218 acpi_gbl_optarg); 217 acpi_gbl_optarg);
219 return (-1); 218 return (-1);
220 } 219 }
221 continue; 220 continue;
@@ -242,7 +241,7 @@ static int ap_do_options(int argc, char **argv)
242 case 'z': /* Verbose mode */ 241 case 'z': /* Verbose mode */
243 242
244 gbl_verbose_mode = TRUE; 243 gbl_verbose_mode = TRUE;
245 acpi_log_error(ACPI_COMMON_SIGNON(AP_UTILITY_NAME)); 244 fprintf(stderr, ACPI_COMMON_SIGNON(AP_UTILITY_NAME));
246 continue; 245 continue;
247 246
248 /* 247 /*
@@ -315,6 +314,7 @@ int ACPI_SYSTEM_XFACE acpi_main(int argc, char *argv[])
315 ACPI_DEBUG_INITIALIZE(); /* For debug version only */ 314 ACPI_DEBUG_INITIALIZE(); /* For debug version only */
316 acpi_os_initialize(); 315 acpi_os_initialize();
317 gbl_output_file = ACPI_FILE_OUT; 316 gbl_output_file = ACPI_FILE_OUT;
317 acpi_gbl_integer_byte_width = 8;
318 318
319 /* Process command line options */ 319 /* Process command line options */
320 320
@@ -353,8 +353,9 @@ int ACPI_SYSTEM_XFACE acpi_main(int argc, char *argv[])
353 353
354 default: 354 default:
355 355
356 acpi_log_error("Internal error, invalid action: 0x%X\n", 356 fprintf(stderr,
357 action->to_be_done); 357 "Internal error, invalid action: 0x%X\n",
358 action->to_be_done);
358 return (-1); 359 return (-1);
359 } 360 }
360 361
@@ -369,12 +370,12 @@ int ACPI_SYSTEM_XFACE acpi_main(int argc, char *argv[])
369 /* Summary for the output file */ 370 /* Summary for the output file */
370 371
371 file_size = cm_get_file_size(gbl_output_file); 372 file_size = cm_get_file_size(gbl_output_file);
372 acpi_log_error 373 fprintf(stderr,
373 ("Output file %s contains 0x%X (%u) bytes\n\n", 374 "Output file %s contains 0x%X (%u) bytes\n\n",
374 gbl_output_filename, file_size, file_size); 375 gbl_output_filename, file_size, file_size);
375 } 376 }
376 377
377 acpi_os_close_file(gbl_output_file); 378 fclose(gbl_output_file);
378 } 379 }
379 380
380 return (status); 381 return (status);