diff options
author | Lv Zheng <lv.zheng@intel.com> | 2016-08-04 04:45:13 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-08-12 21:12:32 -0400 |
commit | dd99cbcca4fea59ec5e93cf160cb4b939306f5c9 (patch) | |
tree | debd1b449d7bde5be4fb94f3cb1abd88a40f4265 /tools | |
parent | f173a7750eb188fd7d888d5950d58454bcfbd09b (diff) |
ACPICA: Clib: Eliminate acpi_os_XXXFile()/acpi_log_error and link clibrary fxxx()/errno/perror() instead
ACPICA commit 189429fb7d06cdb89043ae32d615faf553467f1d
This patch follows new ACPICA design, eliminates old portable OSLs, and
implements fopen/fread/fwrite/fclose/fseek/ftell for GNU EFI
environment. This patch also eliminates acpi_log_error(), convering them
into fprintf(stderr)/perror(). Lv Zheng.
Link: https://github.com/acpica/acpica/commit/189429fb
Link: https://bugs.acpica.org/show_bug.cgi?id=1302
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')
-rw-r--r-- | tools/power/acpi/common/cmfsize.c | 12 | ||||
-rw-r--r-- | tools/power/acpi/common/getopt.c | 2 | ||||
-rw-r--r-- | tools/power/acpi/os_specific/service_layers/oslibcfs.c | 217 | ||||
-rw-r--r-- | tools/power/acpi/tools/acpidump/Makefile | 1 | ||||
-rw-r--r-- | tools/power/acpi/tools/acpidump/apdump.c | 65 | ||||
-rw-r--r-- | tools/power/acpi/tools/acpidump/apfiles.c | 48 | ||||
-rw-r--r-- | tools/power/acpi/tools/acpidump/apmain.c | 31 |
7 files changed, 81 insertions, 295 deletions
diff --git a/tools/power/acpi/common/cmfsize.c b/tools/power/acpi/common/cmfsize.c index d2240e60566f..bc82596d7354 100644 --- a/tools/power/acpi/common/cmfsize.c +++ b/tools/power/acpi/common/cmfsize.c | |||
@@ -68,24 +68,24 @@ u32 cm_get_file_size(ACPI_FILE file) | |||
68 | 68 | ||
69 | /* 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 */ |
70 | 70 | ||
71 | current_offset = acpi_os_get_file_offset(file); | 71 | current_offset = ftell(file); |
72 | if (current_offset < 0) { | 72 | if (current_offset < 0) { |
73 | goto offset_error; | 73 | goto offset_error; |
74 | } | 74 | } |
75 | 75 | ||
76 | status = acpi_os_set_file_offset(file, 0, ACPI_FILE_END); | 76 | status = fseek(file, 0, SEEK_END); |
77 | if (ACPI_FAILURE(status)) { | 77 | if (ACPI_FAILURE(status)) { |
78 | goto seek_error; | 78 | goto seek_error; |
79 | } | 79 | } |
80 | 80 | ||
81 | file_size = acpi_os_get_file_offset(file); | 81 | file_size = ftell(file); |
82 | if (file_size < 0) { | 82 | if (file_size < 0) { |
83 | goto offset_error; | 83 | goto offset_error; |
84 | } | 84 | } |
85 | 85 | ||
86 | /* Restore original file pointer */ | 86 | /* Restore original file pointer */ |
87 | 87 | ||
88 | status = acpi_os_set_file_offset(file, current_offset, ACPI_FILE_BEGIN); | 88 | status = fseek(file, current_offset, SEEK_SET); |
89 | if (ACPI_FAILURE(status)) { | 89 | if (ACPI_FAILURE(status)) { |
90 | goto seek_error; | 90 | goto seek_error; |
91 | } | 91 | } |
@@ -93,10 +93,10 @@ u32 cm_get_file_size(ACPI_FILE file) | |||
93 | return ((u32)file_size); | 93 | return ((u32)file_size); |
94 | 94 | ||
95 | offset_error: | 95 | offset_error: |
96 | acpi_log_error("Could not get file offset"); | 96 | fprintf(stderr, "Could not get file offset\n"); |
97 | return (ACPI_UINT32_MAX); | 97 | return (ACPI_UINT32_MAX); |
98 | 98 | ||
99 | seek_error: | 99 | seek_error: |
100 | acpi_log_error("Could not set file offset"); | 100 | fprintf(stderr, "Could not set file offset\n"); |
101 | return (ACPI_UINT32_MAX); | 101 | return (ACPI_UINT32_MAX); |
102 | } | 102 | } |
diff --git a/tools/power/acpi/common/getopt.c b/tools/power/acpi/common/getopt.c index e9e80910a61d..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 | ||
62 | int acpi_gbl_opterr = 1; | 62 | int acpi_gbl_opterr = 1; |
63 | int acpi_gbl_optind = 1; | 63 | int acpi_gbl_optind = 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 | ||
49 | ACPI_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 | ******************************************************************************/ | ||
64 | ACPI_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 | |||
103 | void 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 | |||
124 | int | ||
125 | acpi_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 | |||
152 | int | ||
153 | acpi_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 | |||
178 | long 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 | |||
200 | acpi_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/tools/acpidump/Makefile b/tools/power/acpi/tools/acpidump/Makefile index 2942cdced2ad..a710f60290ee 100644 --- a/tools/power/acpi/tools/acpidump/Makefile +++ b/tools/power/acpi/tools/acpidump/Makefile | |||
@@ -41,7 +41,6 @@ TOOL_OBJS = \ | |||
41 | utprint.o\ | 41 | utprint.o\ |
42 | utstring.o\ | 42 | utstring.o\ |
43 | utxferror.o\ | 43 | utxferror.o\ |
44 | oslibcfs.o\ | ||
45 | oslinuxtbl.o\ | 44 | oslinuxtbl.o\ |
46 | cmfsize.o\ | 45 | cmfsize.o\ |
47 | getopt.o | 46 | getopt.o |
diff --git a/tools/power/acpi/tools/acpidump/apdump.c b/tools/power/acpi/tools/acpidump/apdump.c index 2a1507c89dbf..1c4e00bd8acb 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); |
@@ -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 | } |
@@ -289,17 +290,17 @@ int ap_dump_table_by_address(char *ascii_address) | |||
289 | status = acpi_ut_strtoul64(ascii_address, ACPI_ANY_BASE, | 290 | status = acpi_ut_strtoul64(ascii_address, ACPI_ANY_BASE, |
290 | ACPI_MAX64_BYTE_WIDTH, &long_address); | 291 | ACPI_MAX64_BYTE_WIDTH, &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 71edeb499096..dd5b861dc4a8 100644 --- a/tools/power/acpi/tools/acpidump/apfiles.c +++ b/tools/power/acpi/tools/acpidump/apfiles.c | |||
@@ -65,7 +65,8 @@ static int ap_is_existing_file(char *pathname) | |||
65 | struct stat stat_info; | 65 | struct stat stat_info; |
66 | 66 | ||
67 | if (!stat(pathname, &stat_info)) { | 67 | if (!stat(pathname, &stat_info)) { |
68 | acpi_log_error("Target path already exists, overwrite? [y|n] "); | 68 | fprintf(stderr, |
69 | "Target path already exists, overwrite? [y|n] "); | ||
69 | 70 | ||
70 | if (getchar() != 'y') { | 71 | if (getchar() != 'y') { |
71 | return (-1); | 72 | return (-1); |
@@ -101,9 +102,9 @@ int ap_open_output_file(char *pathname) | |||
101 | 102 | ||
102 | /* Point stdout to the file */ | 103 | /* Point stdout to the file */ |
103 | 104 | ||
104 | file = acpi_os_open_file(pathname, ACPI_FILE_WRITING); | 105 | file = fopen(pathname, "w"); |
105 | if (!file) { | 106 | if (!file) { |
106 | acpi_log_error("Could not open output file: %s\n", pathname); | 107 | fprintf(stderr, "Could not open output file: %s\n", pathname); |
107 | return (-1); | 108 | return (-1); |
108 | } | 109 | } |
109 | 110 | ||
@@ -164,29 +165,29 @@ int ap_write_to_binary_file(struct acpi_table_header *table, u32 instance) | |||
164 | strcat(filename, FILE_SUFFIX_BINARY_TABLE); | 165 | strcat(filename, FILE_SUFFIX_BINARY_TABLE); |
165 | 166 | ||
166 | if (gbl_verbose_mode) { | 167 | if (gbl_verbose_mode) { |
167 | acpi_log_error | 168 | fprintf(stderr, |
168 | ("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", |
169 | table->signature, filename, table->length, table->length); | 170 | table->signature, filename, table->length, |
171 | table->length); | ||
170 | } | 172 | } |
171 | 173 | ||
172 | /* Open the file and dump the entire table in binary mode */ | 174 | /* Open the file and dump the entire table in binary mode */ |
173 | 175 | ||
174 | file = acpi_os_open_file(filename, | 176 | file = fopen(filename, "wb"); |
175 | ACPI_FILE_WRITING | ACPI_FILE_BINARY); | ||
176 | if (!file) { | 177 | if (!file) { |
177 | acpi_log_error("Could not open output file: %s\n", filename); | 178 | fprintf(stderr, "Could not open output file: %s\n", filename); |
178 | return (-1); | 179 | return (-1); |
179 | } | 180 | } |
180 | 181 | ||
181 | actual = acpi_os_write_file(file, table, 1, table_length); | 182 | actual = fwrite(table, 1, table_length, file); |
182 | if (actual != table_length) { | 183 | if (actual != table_length) { |
183 | acpi_log_error("Error writing binary output file: %s\n", | 184 | fprintf(stderr, "Error writing binary output file: %s\n", |
184 | filename); | 185 | filename); |
185 | acpi_os_close_file(file); | 186 | fclose(file); |
186 | return (-1); | 187 | return (-1); |
187 | } | 188 | } |
188 | 189 | ||
189 | acpi_os_close_file(file); | 190 | fclose(file); |
190 | return (0); | 191 | return (0); |
191 | } | 192 | } |
192 | 193 | ||
@@ -213,10 +214,9 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname, | |||
213 | 214 | ||
214 | /* Must use binary mode */ | 215 | /* Must use binary mode */ |
215 | 216 | ||
216 | file = | 217 | file = fopen(pathname, "rb"); |
217 | acpi_os_open_file(pathname, ACPI_FILE_READING | ACPI_FILE_BINARY); | ||
218 | if (!file) { | 218 | if (!file) { |
219 | acpi_log_error("Could not open input file: %s\n", pathname); | 219 | fprintf(stderr, "Could not open input file: %s\n", pathname); |
220 | return (NULL); | 220 | return (NULL); |
221 | } | 221 | } |
222 | 222 | ||
@@ -224,7 +224,8 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname, | |||
224 | 224 | ||
225 | file_size = cm_get_file_size(file); | 225 | file_size = cm_get_file_size(file); |
226 | if (file_size == ACPI_UINT32_MAX) { | 226 | if (file_size == ACPI_UINT32_MAX) { |
227 | 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); | ||
228 | goto cleanup; | 229 | goto cleanup; |
229 | } | 230 | } |
230 | 231 | ||
@@ -232,16 +233,17 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname, | |||
232 | 233 | ||
233 | buffer = ACPI_ALLOCATE_ZEROED(file_size); | 234 | buffer = ACPI_ALLOCATE_ZEROED(file_size); |
234 | if (!buffer) { | 235 | if (!buffer) { |
235 | acpi_log_error("Could not allocate file buffer of size: %u\n", | 236 | fprintf(stderr, |
236 | file_size); | 237 | "Could not allocate file buffer of size: %u\n", |
238 | file_size); | ||
237 | goto cleanup; | 239 | goto cleanup; |
238 | } | 240 | } |
239 | 241 | ||
240 | /* Read the entire file */ | 242 | /* Read the entire file */ |
241 | 243 | ||
242 | actual = acpi_os_read_file(file, buffer, 1, file_size); | 244 | actual = fread(buffer, 1, file_size, file); |
243 | if (actual != file_size) { | 245 | if (actual != file_size) { |
244 | acpi_log_error("Could not read input file: %s\n", pathname); | 246 | fprintf(stderr, "Could not read input file: %s\n", pathname); |
245 | ACPI_FREE(buffer); | 247 | ACPI_FREE(buffer); |
246 | buffer = NULL; | 248 | buffer = NULL; |
247 | goto cleanup; | 249 | goto cleanup; |
@@ -250,6 +252,6 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname, | |||
250 | *out_file_size = file_size; | 252 | *out_file_size = file_size; |
251 | 253 | ||
252 | cleanup: | 254 | cleanup: |
253 | acpi_os_close_file(file); | 255 | fclose(file); |
254 | return (buffer); | 256 | return (buffer); |
255 | } | 257 | } |
diff --git a/tools/power/acpi/tools/acpidump/apmain.c b/tools/power/acpi/tools/acpidump/apmain.c index 17ce0d7ef29d..f32968e22af5 100644 --- a/tools/power/acpi/tools/acpidump/apmain.c +++ b/tools/power/acpi/tools/acpidump/apmain.c | |||
@@ -139,8 +139,8 @@ static int ap_insert_action(char *argument, u32 to_be_done) | |||
139 | 139 | ||
140 | current_action++; | 140 | current_action++; |
141 | if (current_action > AP_MAX_ACTIONS) { | 141 | if (current_action > AP_MAX_ACTIONS) { |
142 | acpi_log_error("Too many table options (max %u)\n", | 142 | fprintf(stderr, "Too many table options (max %u)\n", |
143 | AP_MAX_ACTIONS); | 143 | AP_MAX_ACTIONS); |
144 | return (-1); | 144 | return (-1); |
145 | } | 145 | } |
146 | 146 | ||
@@ -185,9 +185,9 @@ static int ap_do_options(int argc, char **argv) | |||
185 | } else if (!strcmp(acpi_gbl_optarg, "off")) { | 185 | } else if (!strcmp(acpi_gbl_optarg, "off")) { |
186 | gbl_dump_customized_tables = FALSE; | 186 | gbl_dump_customized_tables = FALSE; |
187 | } else { | 187 | } else { |
188 | acpi_log_error | 188 | fprintf(stderr, |
189 | ("%s: Cannot handle this switch, please use on|off\n", | 189 | "%s: Cannot handle this switch, please use on|off\n", |
190 | acpi_gbl_optarg); | 190 | acpi_gbl_optarg); |
191 | return (-1); | 191 | return (-1); |
192 | } | 192 | } |
193 | continue; | 193 | continue; |
@@ -212,9 +212,9 @@ static int ap_do_options(int argc, char **argv) | |||
212 | ACPI_MAX64_BYTE_WIDTH, | 212 | ACPI_MAX64_BYTE_WIDTH, |
213 | &gbl_rsdp_base); | 213 | &gbl_rsdp_base); |
214 | if (ACPI_FAILURE(status)) { | 214 | if (ACPI_FAILURE(status)) { |
215 | acpi_log_error | 215 | fprintf(stderr, |
216 | ("%s: Could not convert to a physical address\n", | 216 | "%s: Could not convert to a physical address\n", |
217 | acpi_gbl_optarg); | 217 | acpi_gbl_optarg); |
218 | return (-1); | 218 | return (-1); |
219 | } | 219 | } |
220 | continue; | 220 | continue; |
@@ -241,7 +241,7 @@ static int ap_do_options(int argc, char **argv) | |||
241 | case 'z': /* Verbose mode */ | 241 | case 'z': /* Verbose mode */ |
242 | 242 | ||
243 | gbl_verbose_mode = TRUE; | 243 | gbl_verbose_mode = TRUE; |
244 | acpi_log_error(ACPI_COMMON_SIGNON(AP_UTILITY_NAME)); | 244 | fprintf(stderr, ACPI_COMMON_SIGNON(AP_UTILITY_NAME)); |
245 | continue; | 245 | continue; |
246 | 246 | ||
247 | /* | 247 | /* |
@@ -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); |