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>
This commit is contained in:

committed by
Rafael J. Wysocki

parent
f173a7750e
commit
dd99cbcca4
@@ -628,27 +628,3 @@ acpi_trace_point(acpi_trace_event_type type, u8 begin, u8 *aml, char *pathname)
|
|||||||
|
|
||||||
ACPI_EXPORT_SYMBOL(acpi_trace_point)
|
ACPI_EXPORT_SYMBOL(acpi_trace_point)
|
||||||
#endif
|
#endif
|
||||||
#ifdef ACPI_APPLICATION
|
|
||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
* FUNCTION: acpi_log_error
|
|
||||||
*
|
|
||||||
* PARAMETERS: format - Printf format field
|
|
||||||
* ... - Optional printf arguments
|
|
||||||
*
|
|
||||||
* RETURN: None
|
|
||||||
*
|
|
||||||
* DESCRIPTION: Print error message to the console, used by applications.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
void ACPI_INTERNAL_VAR_XFACE acpi_log_error(const char *format, ...)
|
|
||||||
{
|
|
||||||
va_list args;
|
|
||||||
|
|
||||||
va_start(args, format);
|
|
||||||
(void)vfprintf(ACPI_FILE_ERR, format, args);
|
|
||||||
va_end(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
ACPI_EXPORT_SYMBOL(acpi_log_error)
|
|
||||||
#endif
|
|
||||||
|
@@ -656,8 +656,7 @@ int vprintf(const char *format, va_list args)
|
|||||||
length = vsnprintf(acpi_gbl_print_buffer,
|
length = vsnprintf(acpi_gbl_print_buffer,
|
||||||
sizeof(acpi_gbl_print_buffer), format, args);
|
sizeof(acpi_gbl_print_buffer), format, args);
|
||||||
|
|
||||||
(void)acpi_os_write_file(ACPI_FILE_OUT, acpi_gbl_print_buffer, length,
|
(void)fwrite(acpi_gbl_print_buffer, length, 1, ACPI_FILE_OUT);
|
||||||
1);
|
|
||||||
acpi_os_release_lock(acpi_gbl_print_lock, flags);
|
acpi_os_release_lock(acpi_gbl_print_lock, flags);
|
||||||
|
|
||||||
return (length);
|
return (length);
|
||||||
@@ -710,7 +709,7 @@ int vfprintf(FILE * file, const char *format, va_list args)
|
|||||||
length = vsnprintf(acpi_gbl_print_buffer,
|
length = vsnprintf(acpi_gbl_print_buffer,
|
||||||
sizeof(acpi_gbl_print_buffer), format, args);
|
sizeof(acpi_gbl_print_buffer), format, args);
|
||||||
|
|
||||||
(void)acpi_os_write_file(file, acpi_gbl_print_buffer, length, 1);
|
(void)fwrite(acpi_gbl_print_buffer, length, 1, file);
|
||||||
acpi_os_release_lock(acpi_gbl_print_lock, flags);
|
acpi_os_release_lock(acpi_gbl_print_lock, flags);
|
||||||
|
|
||||||
return (length);
|
return (length);
|
||||||
|
@@ -371,6 +371,12 @@ acpi_status acpi_os_wait_command_ready(void);
|
|||||||
acpi_status acpi_os_notify_command_complete(void);
|
acpi_status acpi_os_notify_command_complete(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_trace_point
|
||||||
|
void
|
||||||
|
acpi_os_trace_point(acpi_trace_event_type type,
|
||||||
|
u8 begin, u8 *aml, char *pathname);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Obtain ACPI table(s)
|
* Obtain ACPI table(s)
|
||||||
*/
|
*/
|
||||||
@@ -416,41 +422,4 @@ char *acpi_os_get_next_filename(void *dir_handle);
|
|||||||
void acpi_os_close_directory(void *dir_handle);
|
void acpi_os_close_directory(void *dir_handle);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
* File I/O and related support
|
|
||||||
*/
|
|
||||||
#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_open_file
|
|
||||||
ACPI_FILE acpi_os_open_file(const char *path, u8 modes);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_close_file
|
|
||||||
void acpi_os_close_file(ACPI_FILE file);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_read_file
|
|
||||||
int
|
|
||||||
acpi_os_read_file(ACPI_FILE file,
|
|
||||||
void *buffer, acpi_size size, acpi_size count);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_write_file
|
|
||||||
int
|
|
||||||
acpi_os_write_file(ACPI_FILE file,
|
|
||||||
void *buffer, acpi_size size, acpi_size count);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_file_offset
|
|
||||||
long acpi_os_get_file_offset(ACPI_FILE file);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_set_file_offset
|
|
||||||
acpi_status acpi_os_set_file_offset(ACPI_FILE file, long offset, u8 from);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_trace_point
|
|
||||||
void
|
|
||||||
acpi_os_trace_point(acpi_trace_event_type type,
|
|
||||||
u8 begin, u8 *aml, char *pathname);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __ACPIOSXF_H__ */
|
#endif /* __ACPIOSXF_H__ */
|
||||||
|
@@ -943,9 +943,6 @@ ACPI_DBG_DEPENDENT_RETURN_VOID(void
|
|||||||
acpi_trace_point(acpi_trace_event_type type,
|
acpi_trace_point(acpi_trace_event_type type,
|
||||||
u8 begin,
|
u8 begin,
|
||||||
u8 *aml, char *pathname))
|
u8 *aml, char *pathname))
|
||||||
ACPI_APP_DEPENDENT_RETURN_VOID(ACPI_PRINTF_LIKE(1)
|
|
||||||
void ACPI_INTERNAL_VAR_XFACE
|
|
||||||
acpi_log_error(const char *format, ...))
|
|
||||||
|
|
||||||
acpi_status acpi_initialize_debugger(void);
|
acpi_status acpi_initialize_debugger(void);
|
||||||
|
|
||||||
|
@@ -1288,15 +1288,6 @@ typedef enum {
|
|||||||
#define ACPI_OSI_WIN_8 0x0C
|
#define ACPI_OSI_WIN_8 0x0C
|
||||||
#define ACPI_OSI_WIN_10 0x0D
|
#define ACPI_OSI_WIN_10 0x0D
|
||||||
|
|
||||||
/* Definitions of file IO */
|
|
||||||
|
|
||||||
#define ACPI_FILE_READING 0x01
|
|
||||||
#define ACPI_FILE_WRITING 0x02
|
|
||||||
#define ACPI_FILE_BINARY 0x04
|
|
||||||
|
|
||||||
#define ACPI_FILE_BEGIN 0x01
|
|
||||||
#define ACPI_FILE_END 0x02
|
|
||||||
|
|
||||||
/* Definitions of getopt */
|
/* Definitions of getopt */
|
||||||
|
|
||||||
#define ACPI_OPT_END -1
|
#define ACPI_OPT_END -1
|
||||||
|
@@ -68,24 +68,24 @@ u32 cm_get_file_size(ACPI_FILE file)
|
|||||||
|
|
||||||
/* Save the current file pointer, seek to EOF to obtain file size */
|
/* Save the current file pointer, seek to EOF to obtain file size */
|
||||||
|
|
||||||
current_offset = acpi_os_get_file_offset(file);
|
current_offset = ftell(file);
|
||||||
if (current_offset < 0) {
|
if (current_offset < 0) {
|
||||||
goto offset_error;
|
goto offset_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = acpi_os_set_file_offset(file, 0, ACPI_FILE_END);
|
status = fseek(file, 0, SEEK_END);
|
||||||
if (ACPI_FAILURE(status)) {
|
if (ACPI_FAILURE(status)) {
|
||||||
goto seek_error;
|
goto seek_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
file_size = acpi_os_get_file_offset(file);
|
file_size = ftell(file);
|
||||||
if (file_size < 0) {
|
if (file_size < 0) {
|
||||||
goto offset_error;
|
goto offset_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Restore original file pointer */
|
/* Restore original file pointer */
|
||||||
|
|
||||||
status = acpi_os_set_file_offset(file, current_offset, ACPI_FILE_BEGIN);
|
status = fseek(file, current_offset, SEEK_SET);
|
||||||
if (ACPI_FAILURE(status)) {
|
if (ACPI_FAILURE(status)) {
|
||||||
goto seek_error;
|
goto seek_error;
|
||||||
}
|
}
|
||||||
@@ -93,10 +93,10 @@ u32 cm_get_file_size(ACPI_FILE file)
|
|||||||
return ((u32)file_size);
|
return ((u32)file_size);
|
||||||
|
|
||||||
offset_error:
|
offset_error:
|
||||||
acpi_log_error("Could not get file offset");
|
fprintf(stderr, "Could not get file offset\n");
|
||||||
return (ACPI_UINT32_MAX);
|
return (ACPI_UINT32_MAX);
|
||||||
|
|
||||||
seek_error:
|
seek_error:
|
||||||
acpi_log_error("Could not set file offset");
|
fprintf(stderr, "Could not set file offset\n");
|
||||||
return (ACPI_UINT32_MAX);
|
return (ACPI_UINT32_MAX);
|
||||||
}
|
}
|
||||||
|
@@ -57,7 +57,7 @@
|
|||||||
#include "acapps.h"
|
#include "acapps.h"
|
||||||
|
|
||||||
#define ACPI_OPTION_ERROR(msg, badchar) \
|
#define ACPI_OPTION_ERROR(msg, badchar) \
|
||||||
if (acpi_gbl_opterr) {acpi_log_error ("%s%c\n", msg, badchar);}
|
if (acpi_gbl_opterr) {fprintf (stderr, "%s%c\n", msg, badchar);}
|
||||||
|
|
||||||
int acpi_gbl_opterr = 1;
|
int acpi_gbl_opterr = 1;
|
||||||
int acpi_gbl_optind = 1;
|
int acpi_gbl_optind = 1;
|
||||||
|
@@ -1,217 +0,0 @@
|
|||||||
/******************************************************************************
|
|
||||||
*
|
|
||||||
* Module Name: oslibcfs - C library OSL for file I/O
|
|
||||||
*
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2000 - 2016, Intel Corp.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions, and the following disclaimer,
|
|
||||||
* without modification.
|
|
||||||
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
|
|
||||||
* substantially similar to the "NO WARRANTY" disclaimer below
|
|
||||||
* ("Disclaimer") and any redistribution must be conditioned upon
|
|
||||||
* including a substantially similar Disclaimer requirement for further
|
|
||||||
* binary redistribution.
|
|
||||||
* 3. Neither the names of the above-listed copyright holders nor the names
|
|
||||||
* of any contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* Alternatively, this software may be distributed under the terms of the
|
|
||||||
* GNU General Public License ("GPL") version 2 as published by the Free
|
|
||||||
* Software Foundation.
|
|
||||||
*
|
|
||||||
* NO WARRANTY
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
||||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGES.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <acpi/acpi.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
#define _COMPONENT ACPI_OS_SERVICES
|
|
||||||
ACPI_MODULE_NAME("oslibcfs")
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
* FUNCTION: acpi_os_open_file
|
|
||||||
*
|
|
||||||
* PARAMETERS: path - File path
|
|
||||||
* modes - File operation type
|
|
||||||
*
|
|
||||||
* RETURN: File descriptor.
|
|
||||||
*
|
|
||||||
* DESCRIPTION: Open a file for reading (ACPI_FILE_READING) or/and writing
|
|
||||||
* (ACPI_FILE_WRITING).
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
ACPI_FILE acpi_os_open_file(const char *path, u8 modes)
|
|
||||||
{
|
|
||||||
ACPI_FILE file;
|
|
||||||
u32 i = 0;
|
|
||||||
char modes_str[4];
|
|
||||||
|
|
||||||
if (modes & ACPI_FILE_READING) {
|
|
||||||
modes_str[i++] = 'r';
|
|
||||||
}
|
|
||||||
if (modes & ACPI_FILE_WRITING) {
|
|
||||||
modes_str[i++] = 'w';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (modes & ACPI_FILE_BINARY) {
|
|
||||||
modes_str[i++] = 'b';
|
|
||||||
}
|
|
||||||
|
|
||||||
modes_str[i++] = '\0';
|
|
||||||
|
|
||||||
file = fopen(path, modes_str);
|
|
||||||
if (!file) {
|
|
||||||
perror("Could not open file");
|
|
||||||
}
|
|
||||||
|
|
||||||
return (file);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
* FUNCTION: acpi_os_close_file
|
|
||||||
*
|
|
||||||
* PARAMETERS: file - An open file descriptor
|
|
||||||
*
|
|
||||||
* RETURN: None.
|
|
||||||
*
|
|
||||||
* DESCRIPTION: Close a file opened via acpi_os_open_file.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
void acpi_os_close_file(ACPI_FILE file)
|
|
||||||
{
|
|
||||||
|
|
||||||
fclose(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
* FUNCTION: acpi_os_read_file
|
|
||||||
*
|
|
||||||
* PARAMETERS: file - An open file descriptor
|
|
||||||
* buffer - Data buffer
|
|
||||||
* size - Data block size
|
|
||||||
* count - Number of data blocks
|
|
||||||
*
|
|
||||||
* RETURN: Number of bytes actually read.
|
|
||||||
*
|
|
||||||
* DESCRIPTION: Read from a file.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
int
|
|
||||||
acpi_os_read_file(ACPI_FILE file, void *buffer, acpi_size size, acpi_size count)
|
|
||||||
{
|
|
||||||
int length;
|
|
||||||
|
|
||||||
length = fread(buffer, size, count, file);
|
|
||||||
if (length < 0) {
|
|
||||||
perror("Error reading file");
|
|
||||||
}
|
|
||||||
|
|
||||||
return (length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
* FUNCTION: acpi_os_write_file
|
|
||||||
*
|
|
||||||
* PARAMETERS: file - An open file descriptor
|
|
||||||
* buffer - Data buffer
|
|
||||||
* size - Data block size
|
|
||||||
* count - Number of data blocks
|
|
||||||
*
|
|
||||||
* RETURN: Number of bytes actually written.
|
|
||||||
*
|
|
||||||
* DESCRIPTION: Write to a file.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
int
|
|
||||||
acpi_os_write_file(ACPI_FILE file,
|
|
||||||
void *buffer, acpi_size size, acpi_size count)
|
|
||||||
{
|
|
||||||
int length;
|
|
||||||
|
|
||||||
length = fwrite(buffer, size, count, file);
|
|
||||||
if (length < 0) {
|
|
||||||
perror("Error writing file");
|
|
||||||
}
|
|
||||||
|
|
||||||
return (length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
* FUNCTION: acpi_os_get_file_offset
|
|
||||||
*
|
|
||||||
* PARAMETERS: file - An open file descriptor
|
|
||||||
*
|
|
||||||
* RETURN: Current file pointer position.
|
|
||||||
*
|
|
||||||
* DESCRIPTION: Get current file offset.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
long acpi_os_get_file_offset(ACPI_FILE file)
|
|
||||||
{
|
|
||||||
long offset;
|
|
||||||
|
|
||||||
offset = ftell(file);
|
|
||||||
return (offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
* FUNCTION: acpi_os_set_file_offset
|
|
||||||
*
|
|
||||||
* PARAMETERS: file - An open file descriptor
|
|
||||||
* offset - New file offset
|
|
||||||
* from - From begin/end of file
|
|
||||||
*
|
|
||||||
* RETURN: Status
|
|
||||||
*
|
|
||||||
* DESCRIPTION: Set current file offset.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
acpi_status acpi_os_set_file_offset(ACPI_FILE file, long offset, u8 from)
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
if (from == ACPI_FILE_BEGIN) {
|
|
||||||
ret = fseek(file, offset, SEEK_SET);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (from == ACPI_FILE_END) {
|
|
||||||
ret = fseek(file, offset, SEEK_END);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret < 0) {
|
|
||||||
return (AE_ERROR);
|
|
||||||
} else {
|
|
||||||
return (AE_OK);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -41,7 +41,6 @@ TOOL_OBJS = \
|
|||||||
utprint.o\
|
utprint.o\
|
||||||
utstring.o\
|
utstring.o\
|
||||||
utxferror.o\
|
utxferror.o\
|
||||||
oslibcfs.o\
|
|
||||||
oslinuxtbl.o\
|
oslinuxtbl.o\
|
||||||
cmfsize.o\
|
cmfsize.o\
|
||||||
getopt.o
|
getopt.o
|
||||||
|
@@ -69,7 +69,8 @@ u8 ap_is_valid_header(struct acpi_table_header *table)
|
|||||||
/* Make sure signature is all ASCII and a valid ACPI name */
|
/* Make sure signature is all ASCII and a valid ACPI name */
|
||||||
|
|
||||||
if (!acpi_ut_valid_nameseg(table->signature)) {
|
if (!acpi_ut_valid_nameseg(table->signature)) {
|
||||||
acpi_log_error("Table signature (0x%8.8X) is invalid\n",
|
fprintf(stderr,
|
||||||
|
"Table signature (0x%8.8X) is invalid\n",
|
||||||
*(u32 *)table->signature);
|
*(u32 *)table->signature);
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
@@ -77,7 +78,7 @@ u8 ap_is_valid_header(struct acpi_table_header *table)
|
|||||||
/* Check for minimum table length */
|
/* Check for minimum table length */
|
||||||
|
|
||||||
if (table->length < sizeof(struct acpi_table_header)) {
|
if (table->length < sizeof(struct acpi_table_header)) {
|
||||||
acpi_log_error("Table length (0x%8.8X) is invalid\n",
|
fprintf(stderr, "Table length (0x%8.8X) is invalid\n",
|
||||||
table->length);
|
table->length);
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
@@ -115,7 +116,7 @@ u8 ap_is_valid_checksum(struct acpi_table_header *table)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ACPI_FAILURE(status)) {
|
if (ACPI_FAILURE(status)) {
|
||||||
acpi_log_error("%4.4s: Warning: wrong checksum in table\n",
|
fprintf(stderr, "%4.4s: Warning: wrong checksum in table\n",
|
||||||
table->signature);
|
table->signature);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,13 +240,13 @@ int ap_dump_all_tables(void)
|
|||||||
if (status == AE_LIMIT) {
|
if (status == AE_LIMIT) {
|
||||||
return (0);
|
return (0);
|
||||||
} else if (i == 0) {
|
} else if (i == 0) {
|
||||||
acpi_log_error
|
fprintf(stderr,
|
||||||
("Could not get ACPI tables, %s\n",
|
"Could not get ACPI tables, %s\n",
|
||||||
acpi_format_exception(status));
|
acpi_format_exception(status));
|
||||||
return (-1);
|
return (-1);
|
||||||
} else {
|
} else {
|
||||||
acpi_log_error
|
fprintf(stderr,
|
||||||
("Could not get ACPI table at index %u, %s\n",
|
"Could not get ACPI table at index %u, %s\n",
|
||||||
i, acpi_format_exception(status));
|
i, acpi_format_exception(status));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -289,7 +290,7 @@ int ap_dump_table_by_address(char *ascii_address)
|
|||||||
status = acpi_ut_strtoul64(ascii_address, ACPI_ANY_BASE,
|
status = acpi_ut_strtoul64(ascii_address, ACPI_ANY_BASE,
|
||||||
ACPI_MAX64_BYTE_WIDTH, &long_address);
|
ACPI_MAX64_BYTE_WIDTH, &long_address);
|
||||||
if (ACPI_FAILURE(status)) {
|
if (ACPI_FAILURE(status)) {
|
||||||
acpi_log_error("%s: Could not convert to a physical address\n",
|
fprintf(stderr, "%s: Could not convert to a physical address\n",
|
||||||
ascii_address);
|
ascii_address);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@@ -297,7 +298,7 @@ int ap_dump_table_by_address(char *ascii_address)
|
|||||||
address = (acpi_physical_address)long_address;
|
address = (acpi_physical_address)long_address;
|
||||||
status = acpi_os_get_table_by_address(address, &table);
|
status = acpi_os_get_table_by_address(address, &table);
|
||||||
if (ACPI_FAILURE(status)) {
|
if (ACPI_FAILURE(status)) {
|
||||||
acpi_log_error("Could not get table at 0x%8.8X%8.8X, %s\n",
|
fprintf(stderr, "Could not get table at 0x%8.8X%8.8X, %s\n",
|
||||||
ACPI_FORMAT_UINT64(address),
|
ACPI_FORMAT_UINT64(address),
|
||||||
acpi_format_exception(status));
|
acpi_format_exception(status));
|
||||||
return (-1);
|
return (-1);
|
||||||
@@ -331,8 +332,8 @@ int ap_dump_table_by_name(char *signature)
|
|||||||
int table_status;
|
int table_status;
|
||||||
|
|
||||||
if (strlen(signature) != ACPI_NAME_SIZE) {
|
if (strlen(signature) != ACPI_NAME_SIZE) {
|
||||||
acpi_log_error
|
fprintf(stderr,
|
||||||
("Invalid table signature [%s]: must be exactly 4 characters\n",
|
"Invalid table signature [%s]: must be exactly 4 characters\n",
|
||||||
signature);
|
signature);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@@ -363,8 +364,8 @@ int ap_dump_table_by_name(char *signature)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
acpi_log_error
|
fprintf(stderr,
|
||||||
("Could not get ACPI table with signature [%s], %s\n",
|
"Could not get ACPI table with signature [%s], %s\n",
|
||||||
local_signature, acpi_format_exception(status));
|
local_signature, acpi_format_exception(status));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@@ -408,23 +409,23 @@ int ap_dump_table_from_file(char *pathname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!acpi_ut_valid_nameseg(table->signature)) {
|
if (!acpi_ut_valid_nameseg(table->signature)) {
|
||||||
acpi_log_error
|
fprintf(stderr,
|
||||||
("No valid ACPI signature was found in input file %s\n",
|
"No valid ACPI signature was found in input file %s\n",
|
||||||
pathname);
|
pathname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* File must be at least as long as the table length */
|
/* File must be at least as long as the table length */
|
||||||
|
|
||||||
if (table->length > file_size) {
|
if (table->length > file_size) {
|
||||||
acpi_log_error
|
fprintf(stderr,
|
||||||
("Table length (0x%X) is too large for input file (0x%X) %s\n",
|
"Table length (0x%X) is too large for input file (0x%X) %s\n",
|
||||||
table->length, file_size, pathname);
|
table->length, file_size, pathname);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gbl_verbose_mode) {
|
if (gbl_verbose_mode) {
|
||||||
acpi_log_error
|
fprintf(stderr,
|
||||||
("Input file: %s contains table [%4.4s], 0x%X (%u) bytes\n",
|
"Input file: %s contains table [%4.4s], 0x%X (%u) bytes\n",
|
||||||
pathname, table->signature, file_size, file_size);
|
pathname, table->signature, file_size, file_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -65,7 +65,8 @@ static int ap_is_existing_file(char *pathname)
|
|||||||
struct stat stat_info;
|
struct stat stat_info;
|
||||||
|
|
||||||
if (!stat(pathname, &stat_info)) {
|
if (!stat(pathname, &stat_info)) {
|
||||||
acpi_log_error("Target path already exists, overwrite? [y|n] ");
|
fprintf(stderr,
|
||||||
|
"Target path already exists, overwrite? [y|n] ");
|
||||||
|
|
||||||
if (getchar() != 'y') {
|
if (getchar() != 'y') {
|
||||||
return (-1);
|
return (-1);
|
||||||
@@ -101,9 +102,9 @@ int ap_open_output_file(char *pathname)
|
|||||||
|
|
||||||
/* Point stdout to the file */
|
/* Point stdout to the file */
|
||||||
|
|
||||||
file = acpi_os_open_file(pathname, ACPI_FILE_WRITING);
|
file = fopen(pathname, "w");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
acpi_log_error("Could not open output file: %s\n", pathname);
|
fprintf(stderr, "Could not open output file: %s\n", pathname);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,29 +165,29 @@ int ap_write_to_binary_file(struct acpi_table_header *table, u32 instance)
|
|||||||
strcat(filename, FILE_SUFFIX_BINARY_TABLE);
|
strcat(filename, FILE_SUFFIX_BINARY_TABLE);
|
||||||
|
|
||||||
if (gbl_verbose_mode) {
|
if (gbl_verbose_mode) {
|
||||||
acpi_log_error
|
fprintf(stderr,
|
||||||
("Writing [%4.4s] to binary file: %s 0x%X (%u) bytes\n",
|
"Writing [%4.4s] to binary file: %s 0x%X (%u) bytes\n",
|
||||||
table->signature, filename, table->length, table->length);
|
table->signature, filename, table->length,
|
||||||
|
table->length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open the file and dump the entire table in binary mode */
|
/* Open the file and dump the entire table in binary mode */
|
||||||
|
|
||||||
file = acpi_os_open_file(filename,
|
file = fopen(filename, "wb");
|
||||||
ACPI_FILE_WRITING | ACPI_FILE_BINARY);
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
acpi_log_error("Could not open output file: %s\n", filename);
|
fprintf(stderr, "Could not open output file: %s\n", filename);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
actual = acpi_os_write_file(file, table, 1, table_length);
|
actual = fwrite(table, 1, table_length, file);
|
||||||
if (actual != table_length) {
|
if (actual != table_length) {
|
||||||
acpi_log_error("Error writing binary output file: %s\n",
|
fprintf(stderr, "Error writing binary output file: %s\n",
|
||||||
filename);
|
filename);
|
||||||
acpi_os_close_file(file);
|
fclose(file);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
acpi_os_close_file(file);
|
fclose(file);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,10 +214,9 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname,
|
|||||||
|
|
||||||
/* Must use binary mode */
|
/* Must use binary mode */
|
||||||
|
|
||||||
file =
|
file = fopen(pathname, "rb");
|
||||||
acpi_os_open_file(pathname, ACPI_FILE_READING | ACPI_FILE_BINARY);
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
acpi_log_error("Could not open input file: %s\n", pathname);
|
fprintf(stderr, "Could not open input file: %s\n", pathname);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,7 +224,8 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname,
|
|||||||
|
|
||||||
file_size = cm_get_file_size(file);
|
file_size = cm_get_file_size(file);
|
||||||
if (file_size == ACPI_UINT32_MAX) {
|
if (file_size == ACPI_UINT32_MAX) {
|
||||||
acpi_log_error("Could not get input file size: %s\n", pathname);
|
fprintf(stderr,
|
||||||
|
"Could not get input file size: %s\n", pathname);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,16 +233,17 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname,
|
|||||||
|
|
||||||
buffer = ACPI_ALLOCATE_ZEROED(file_size);
|
buffer = ACPI_ALLOCATE_ZEROED(file_size);
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
acpi_log_error("Could not allocate file buffer of size: %u\n",
|
fprintf(stderr,
|
||||||
|
"Could not allocate file buffer of size: %u\n",
|
||||||
file_size);
|
file_size);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read the entire file */
|
/* Read the entire file */
|
||||||
|
|
||||||
actual = acpi_os_read_file(file, buffer, 1, file_size);
|
actual = fread(buffer, 1, file_size, file);
|
||||||
if (actual != file_size) {
|
if (actual != file_size) {
|
||||||
acpi_log_error("Could not read input file: %s\n", pathname);
|
fprintf(stderr, "Could not read input file: %s\n", pathname);
|
||||||
ACPI_FREE(buffer);
|
ACPI_FREE(buffer);
|
||||||
buffer = NULL;
|
buffer = NULL;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@@ -250,6 +252,6 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname,
|
|||||||
*out_file_size = file_size;
|
*out_file_size = file_size;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
acpi_os_close_file(file);
|
fclose(file);
|
||||||
return (buffer);
|
return (buffer);
|
||||||
}
|
}
|
||||||
|
@@ -139,7 +139,7 @@ static int ap_insert_action(char *argument, u32 to_be_done)
|
|||||||
|
|
||||||
current_action++;
|
current_action++;
|
||||||
if (current_action > AP_MAX_ACTIONS) {
|
if (current_action > AP_MAX_ACTIONS) {
|
||||||
acpi_log_error("Too many table options (max %u)\n",
|
fprintf(stderr, "Too many table options (max %u)\n",
|
||||||
AP_MAX_ACTIONS);
|
AP_MAX_ACTIONS);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@@ -185,8 +185,8 @@ static int ap_do_options(int argc, char **argv)
|
|||||||
} else if (!strcmp(acpi_gbl_optarg, "off")) {
|
} else if (!strcmp(acpi_gbl_optarg, "off")) {
|
||||||
gbl_dump_customized_tables = FALSE;
|
gbl_dump_customized_tables = FALSE;
|
||||||
} else {
|
} else {
|
||||||
acpi_log_error
|
fprintf(stderr,
|
||||||
("%s: Cannot handle this switch, please use on|off\n",
|
"%s: Cannot handle this switch, please use on|off\n",
|
||||||
acpi_gbl_optarg);
|
acpi_gbl_optarg);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@@ -212,8 +212,8 @@ static int ap_do_options(int argc, char **argv)
|
|||||||
ACPI_MAX64_BYTE_WIDTH,
|
ACPI_MAX64_BYTE_WIDTH,
|
||||||
&gbl_rsdp_base);
|
&gbl_rsdp_base);
|
||||||
if (ACPI_FAILURE(status)) {
|
if (ACPI_FAILURE(status)) {
|
||||||
acpi_log_error
|
fprintf(stderr,
|
||||||
("%s: Could not convert to a physical address\n",
|
"%s: Could not convert to a physical address\n",
|
||||||
acpi_gbl_optarg);
|
acpi_gbl_optarg);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@@ -241,7 +241,7 @@ static int ap_do_options(int argc, char **argv)
|
|||||||
case 'z': /* Verbose mode */
|
case 'z': /* Verbose mode */
|
||||||
|
|
||||||
gbl_verbose_mode = TRUE;
|
gbl_verbose_mode = TRUE;
|
||||||
acpi_log_error(ACPI_COMMON_SIGNON(AP_UTILITY_NAME));
|
fprintf(stderr, ACPI_COMMON_SIGNON(AP_UTILITY_NAME));
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -353,7 +353,8 @@ int ACPI_SYSTEM_XFACE acpi_main(int argc, char *argv[])
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
acpi_log_error("Internal error, invalid action: 0x%X\n",
|
fprintf(stderr,
|
||||||
|
"Internal error, invalid action: 0x%X\n",
|
||||||
action->to_be_done);
|
action->to_be_done);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@@ -369,12 +370,12 @@ int ACPI_SYSTEM_XFACE acpi_main(int argc, char *argv[])
|
|||||||
/* Summary for the output file */
|
/* Summary for the output file */
|
||||||
|
|
||||||
file_size = cm_get_file_size(gbl_output_file);
|
file_size = cm_get_file_size(gbl_output_file);
|
||||||
acpi_log_error
|
fprintf(stderr,
|
||||||
("Output file %s contains 0x%X (%u) bytes\n\n",
|
"Output file %s contains 0x%X (%u) bytes\n\n",
|
||||||
gbl_output_filename, file_size, file_size);
|
gbl_output_filename, file_size, file_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
acpi_os_close_file(gbl_output_file);
|
fclose(gbl_output_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (status);
|
return (status);
|
||||||
|
Reference in New Issue
Block a user