Commit 9c14cc44 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

Merge branch 'acpica' into acpi-gpe

parents 9a3c4145 c12f07d1
...@@ -69,11 +69,11 @@ static u32 l1_percpu_entry; ...@@ -69,11 +69,11 @@ static u32 l1_percpu_entry;
#define ELOG_ENTRY_ADDR(phyaddr) \ #define ELOG_ENTRY_ADDR(phyaddr) \
(phyaddr - elog_base + (u8 *)elog_addr) (phyaddr - elog_base + (u8 *)elog_addr)
static struct acpi_generic_status *extlog_elog_entry_check(int cpu, int bank) static struct acpi_hest_generic_status *extlog_elog_entry_check(int cpu, int bank)
{ {
int idx; int idx;
u64 data; u64 data;
struct acpi_generic_status *estatus; struct acpi_hest_generic_status *estatus;
WARN_ON(cpu < 0); WARN_ON(cpu < 0);
idx = ELOG_IDX(cpu, bank); idx = ELOG_IDX(cpu, bank);
...@@ -82,7 +82,7 @@ static struct acpi_generic_status *extlog_elog_entry_check(int cpu, int bank) ...@@ -82,7 +82,7 @@ static struct acpi_generic_status *extlog_elog_entry_check(int cpu, int bank)
return NULL; return NULL;
data &= EXT_ELOG_ENTRY_MASK; data &= EXT_ELOG_ENTRY_MASK;
estatus = (struct acpi_generic_status *)ELOG_ENTRY_ADDR(data); estatus = (struct acpi_hest_generic_status *)ELOG_ENTRY_ADDR(data);
/* if no valid data in elog entry, just return */ /* if no valid data in elog entry, just return */
if (estatus->block_status == 0) if (estatus->block_status == 0)
...@@ -92,7 +92,7 @@ static struct acpi_generic_status *extlog_elog_entry_check(int cpu, int bank) ...@@ -92,7 +92,7 @@ static struct acpi_generic_status *extlog_elog_entry_check(int cpu, int bank)
} }
static void __print_extlog_rcd(const char *pfx, static void __print_extlog_rcd(const char *pfx,
struct acpi_generic_status *estatus, int cpu) struct acpi_hest_generic_status *estatus, int cpu)
{ {
static atomic_t seqno; static atomic_t seqno;
unsigned int curr_seqno; unsigned int curr_seqno;
...@@ -111,7 +111,7 @@ static void __print_extlog_rcd(const char *pfx, ...@@ -111,7 +111,7 @@ static void __print_extlog_rcd(const char *pfx,
} }
static int print_extlog_rcd(const char *pfx, static int print_extlog_rcd(const char *pfx,
struct acpi_generic_status *estatus, int cpu) struct acpi_hest_generic_status *estatus, int cpu)
{ {
/* Not more than 2 messages every 5 seconds */ /* Not more than 2 messages every 5 seconds */
static DEFINE_RATELIMIT_STATE(ratelimit_corrected, 5*HZ, 2); static DEFINE_RATELIMIT_STATE(ratelimit_corrected, 5*HZ, 2);
...@@ -137,7 +137,7 @@ static int extlog_print(struct notifier_block *nb, unsigned long val, ...@@ -137,7 +137,7 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
struct mce *mce = (struct mce *)data; struct mce *mce = (struct mce *)data;
int bank = mce->bank; int bank = mce->bank;
int cpu = mce->extcpu; int cpu = mce->extcpu;
struct acpi_generic_status *estatus; struct acpi_hest_generic_status *estatus;
int rc; int rc;
estatus = extlog_elog_entry_check(cpu, bank); estatus = extlog_elog_entry_check(cpu, bank);
...@@ -148,7 +148,7 @@ static int extlog_print(struct notifier_block *nb, unsigned long val, ...@@ -148,7 +148,7 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
/* clear record status to enable BIOS to update it again */ /* clear record status to enable BIOS to update it again */
estatus->block_status = 0; estatus->block_status = 0;
rc = print_extlog_rcd(NULL, (struct acpi_generic_status *)elog_buf, cpu); rc = print_extlog_rcd(NULL, (struct acpi_hest_generic_status *)elog_buf, cpu);
return NOTIFY_STOP; return NOTIFY_STOP;
} }
......
...@@ -175,5 +175,5 @@ acpi-y += \ ...@@ -175,5 +175,5 @@ acpi-y += \
utxferror.o \ utxferror.o \
utxfmutex.o utxfmutex.o
acpi-$(ACPI_FUTURE_USAGE) += uttrack.o utcache.o acpi-$(ACPI_FUTURE_USAGE) += utfileio.o utprint.o uttrack.o utcache.o
...@@ -79,10 +79,13 @@ ...@@ -79,10 +79,13 @@
/* Macros for usage messages */ /* Macros for usage messages */
#define ACPI_USAGE_HEADER(usage) \ #define ACPI_USAGE_HEADER(usage) \
printf ("Usage: %s\nOptions:\n", usage); acpi_os_printf ("Usage: %s\nOptions:\n", usage);
#define ACPI_USAGE_TEXT(description) \
acpi_os_printf (description);
#define ACPI_OPTION(name, description) \ #define ACPI_OPTION(name, description) \
printf (" %-18s%s\n", name, description); acpi_os_printf (" %-18s%s\n", name, description);
#define FILE_SUFFIX_DISASSEMBLY "dsl" #define FILE_SUFFIX_DISASSEMBLY "dsl"
#define ACPI_TABLE_FILE_SUFFIX ".dat" #define ACPI_TABLE_FILE_SUFFIX ".dat"
...@@ -102,7 +105,7 @@ extern char *acpi_gbl_optarg; ...@@ -102,7 +105,7 @@ extern char *acpi_gbl_optarg;
/* /*
* cmfsize - Common get file size function * cmfsize - Common get file size function
*/ */
u32 cm_get_file_size(FILE * file); u32 cm_get_file_size(ACPI_FILE file);
#ifndef ACPI_DUMP_APP #ifndef ACPI_DUMP_APP
/* /*
......
...@@ -233,9 +233,6 @@ acpi_status acpi_db_load_acpi_table(char *filename); ...@@ -233,9 +233,6 @@ acpi_status acpi_db_load_acpi_table(char *filename);
acpi_status acpi_status
acpi_db_get_table_from_file(char *filename, struct acpi_table_header **table); acpi_db_get_table_from_file(char *filename, struct acpi_table_header **table);
acpi_status
acpi_db_read_table_from_file(char *filename, struct acpi_table_header **table);
/* /*
* dbhistry - debugger HISTORY command * dbhistry - debugger HISTORY command
*/ */
......
...@@ -297,7 +297,7 @@ ACPI_GLOBAL(u32, acpi_gbl_trace_dbg_layer); ...@@ -297,7 +297,7 @@ ACPI_GLOBAL(u32, acpi_gbl_trace_dbg_layer);
* *
****************************************************************************/ ****************************************************************************/
ACPI_GLOBAL(u8, acpi_gbl_db_output_flags); ACPI_INIT_GLOBAL(u8, acpi_gbl_db_output_flags, ACPI_DB_CONSOLE_OUTPUT);
#ifdef ACPI_DISASSEMBLER #ifdef ACPI_DISASSEMBLER
...@@ -362,6 +362,12 @@ ACPI_GLOBAL(u32, acpi_gbl_num_objects); ...@@ -362,6 +362,12 @@ ACPI_GLOBAL(u32, acpi_gbl_num_objects);
#ifdef ACPI_APPLICATION #ifdef ACPI_APPLICATION
ACPI_INIT_GLOBAL(ACPI_FILE, acpi_gbl_debug_file, NULL); ACPI_INIT_GLOBAL(ACPI_FILE, acpi_gbl_debug_file, NULL);
ACPI_INIT_GLOBAL(ACPI_FILE, acpi_gbl_output_file, NULL);
/* Print buffer */
ACPI_GLOBAL(acpi_spinlock, acpi_gbl_print_lock); /* For print buffer */
ACPI_GLOBAL(char, acpi_gbl_print_buffer[1024]);
#endif /* ACPI_APPLICATION */ #endif /* ACPI_APPLICATION */
......
...@@ -95,7 +95,6 @@ extern const char *acpi_gbl_pt_decode[]; ...@@ -95,7 +95,6 @@ extern const char *acpi_gbl_pt_decode[];
#ifdef ACPI_ASL_COMPILER #ifdef ACPI_ASL_COMPILER
#include <stdio.h> #include <stdio.h>
extern FILE *acpi_gbl_output_file;
#define ACPI_MSG_REDIRECT_BEGIN \ #define ACPI_MSG_REDIRECT_BEGIN \
FILE *output_file = acpi_gbl_output_file; \ FILE *output_file = acpi_gbl_output_file; \
...@@ -211,6 +210,8 @@ void acpi_ut_subsystem_shutdown(void); ...@@ -211,6 +210,8 @@ void acpi_ut_subsystem_shutdown(void);
acpi_size acpi_ut_strlen(const char *string); acpi_size acpi_ut_strlen(const char *string);
char *acpi_ut_strchr(const char *string, int ch);
char *acpi_ut_strcpy(char *dst_string, const char *src_string); char *acpi_ut_strcpy(char *dst_string, const char *src_string);
char *acpi_ut_strncpy(char *dst_string, char *acpi_ut_strncpy(char *dst_string,
...@@ -257,7 +258,7 @@ extern const u8 _acpi_ctype[]; ...@@ -257,7 +258,7 @@ extern const u8 _acpi_ctype[];
#define ACPI_IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD)) #define ACPI_IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD))
#define ACPI_IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP)) #define ACPI_IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP))
#define ACPI_IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO)) #define ACPI_IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO))
#define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_SP | _ACPI_PU)) #define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_XS | _ACPI_PU))
#define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP)) #define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP))
#endif /* !ACPI_USE_SYSTEM_CLIBRARY */ #endif /* !ACPI_USE_SYSTEM_CLIBRARY */
...@@ -352,6 +353,13 @@ acpi_ut_debug_dump_buffer(u8 *buffer, u32 count, u32 display, u32 component_id); ...@@ -352,6 +353,13 @@ acpi_ut_debug_dump_buffer(u8 *buffer, u32 count, u32 display, u32 component_id);
void acpi_ut_dump_buffer(u8 *buffer, u32 count, u32 display, u32 offset); void acpi_ut_dump_buffer(u8 *buffer, u32 count, u32 display, u32 offset);
#ifdef ACPI_APPLICATION
void
acpi_ut_dump_buffer_to_file(ACPI_FILE file,
u8 *buffer,
u32 count, u32 display, u32 base_offset);
#endif
void acpi_ut_report_error(char *module_name, u32 line_number); void acpi_ut_report_error(char *module_name, u32 line_number);
void acpi_ut_report_info(char *module_name, u32 line_number); void acpi_ut_report_info(char *module_name, u32 line_number);
...@@ -393,6 +401,14 @@ acpi_ut_execute_power_methods(struct acpi_namespace_node *device_node, ...@@ -393,6 +401,14 @@ acpi_ut_execute_power_methods(struct acpi_namespace_node *device_node,
const char **method_names, const char **method_names,
u8 method_count, u8 *out_values); u8 method_count, u8 *out_values);
/*
* utfileio - file operations
*/
#ifdef ACPI_APPLICATION
acpi_status
acpi_ut_read_table_from_file(char *filename, struct acpi_table_header **table);
#endif
/* /*
* utids - device ID support * utids - device ID support
*/ */
...@@ -743,4 +759,23 @@ const struct ah_predefined_name *acpi_ah_match_predefined_name(char *nameseg); ...@@ -743,4 +759,23 @@ const struct ah_predefined_name *acpi_ah_match_predefined_name(char *nameseg);
const struct ah_device_id *acpi_ah_match_hardware_id(char *hid); const struct ah_device_id *acpi_ah_match_hardware_id(char *hid);
/*
* utprint - printf/vprintf output functions
*/
const char *acpi_ut_scan_number(const char *string, u64 *number_ptr);
const char *acpi_ut_print_number(char *string, u64 number);
int
acpi_ut_vsnprintf(char *string,
acpi_size size, const char *format, va_list args);
int acpi_ut_snprintf(char *string, acpi_size size, const char *format, ...);
#ifdef ACPI_APPLICATION
int acpi_ut_file_vprintf(ACPI_FILE file, const char *format, va_list args);
int acpi_ut_file_printf(ACPI_FILE file, const char *format, ...);
#endif
#endif /* _ACUTILS_H */ #endif /* _ACUTILS_H */
...@@ -697,21 +697,6 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device, ...@@ -697,21 +697,6 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device,
acpi_gbl_global_event_handler_context); acpi_gbl_global_event_handler_context);
} }
/*
* If edge-triggered, clear the GPE status bit now. Note that
* level-triggered events are cleared after the GPE is serviced.
*/
if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
ACPI_GPE_EDGE_TRIGGERED) {
status = acpi_hw_clear_gpe(gpe_event_info);
if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status,
"Unable to clear GPE %02X",
gpe_number));
return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
}
}
/* /*
* Always disable the GPE so that it does not keep firing before * Always disable the GPE so that it does not keep firing before
* any asynchronous activity completes (either from the execution * any asynchronous activity completes (either from the execution
...@@ -728,6 +713,23 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device, ...@@ -728,6 +713,23 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device,
return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
} }
/*
* If edge-triggered, clear the GPE status bit now. Note that
* level-triggered events are cleared after the GPE is serviced.
*/
if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
ACPI_GPE_EDGE_TRIGGERED) {
status = acpi_hw_clear_gpe(gpe_event_info);
if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status,
"Unable to clear GPE %02X",
gpe_number));
(void)acpi_hw_low_set_gpe(gpe_event_info,
ACPI_GPE_CONDITIONAL_ENABLE);
return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
}
}
/* /*
* Dispatch the GPE to either an installed handler or the control * Dispatch the GPE to either an installed handler or the control
* method associated with this GPE (_Lxx or _Exx). If a handler * method associated with this GPE (_Lxx or _Exx). If a handler
......
...@@ -126,11 +126,19 @@ acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number) ...@@ -126,11 +126,19 @@ acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number)
flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
/* Ensure that we have a valid GPE number */ /*
* Ensure that we have a valid GPE number and that there is some way
* of handling the GPE (handler or a GPE method). In other words, we
* won't allow a valid GPE to be enabled if there is no way to handle it.
*/
gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
if (gpe_event_info) { if (gpe_event_info) {
status = acpi_ev_add_gpe_reference(gpe_event_info); if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) !=
ACPI_GPE_DISPATCH_NONE) {
status = acpi_ev_add_gpe_reference(gpe_event_info);
} else {
status = AE_NO_HANDLER;
}
} }
acpi_os_release_lock(acpi_gbl_gpe_lock, flags); acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
...@@ -177,6 +185,53 @@ acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number) ...@@ -177,6 +185,53 @@ acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number)
ACPI_EXPORT_SYMBOL(acpi_disable_gpe) ACPI_EXPORT_SYMBOL(acpi_disable_gpe)
/*******************************************************************************
*
* FUNCTION: acpi_mark_gpe_for_wake
*
* PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
* gpe_number - GPE level within the GPE block
*
* RETURN: Status
*
* DESCRIPTION: Mark a GPE as having the ability to wake the system. Simply
* sets the ACPI_GPE_CAN_WAKE flag.
*
* Some potential callers of acpi_setup_gpe_for_wake may know in advance that
* there won't be any notify handlers installed for device wake notifications
* from the given GPE (one example is a button GPE in Linux). For these cases,
* acpi_mark_gpe_for_wake should be used instead of acpi_setup_gpe_for_wake.
* This will set the ACPI_GPE_CAN_WAKE flag for the GPE without trying to
* setup implicit wake notification for it (since there's no handler method).
*
******************************************************************************/
acpi_status acpi_mark_gpe_for_wake(acpi_handle gpe_device, u32 gpe_number)
{
struct acpi_gpe_event_info *gpe_event_info;
acpi_status status = AE_BAD_PARAMETER;
acpi_cpu_flags flags;
ACPI_FUNCTION_TRACE(acpi_mark_gpe_for_wake);
flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
/* Ensure that we have a valid GPE number */
gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
if (gpe_event_info) {
/* Mark the GPE as a possible wake event */
gpe_event_info->flags |= ACPI_GPE_CAN_WAKE;
status = AE_OK;
}
acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
return_ACPI_STATUS(status);
}
ACPI_EXPORT_SYMBOL(acpi_mark_gpe_for_wake)
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_setup_gpe_for_wake * FUNCTION: acpi_setup_gpe_for_wake
......
...@@ -56,7 +56,7 @@ acpi_ex_get_serial_access_length(u32 accessor_type, u32 access_length); ...@@ -56,7 +56,7 @@ acpi_ex_get_serial_access_length(u32 accessor_type, u32 access_length);
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_get_serial_access_bytes * FUNCTION: acpi_ex_get_serial_access_length
* *
* PARAMETERS: accessor_type - The type of the protocol indicated by region * PARAMETERS: accessor_type - The type of the protocol indicated by region
* field access attributes * field access attributes
...@@ -103,7 +103,7 @@ acpi_ex_get_serial_access_length(u32 accessor_type, u32 access_length) ...@@ -103,7 +103,7 @@ acpi_ex_get_serial_access_length(u32 accessor_type, u32 access_length)
case AML_FIELD_ATTRIB_BLOCK_CALL: case AML_FIELD_ATTRIB_BLOCK_CALL:
default: default:
length = ACPI_GSBUS_BUFFER_SIZE; length = ACPI_GSBUS_BUFFER_SIZE - 2;
break; break;
} }
......
...@@ -278,8 +278,9 @@ acpi_status acpi_hw_clear_acpi_status(void) ...@@ -278,8 +278,9 @@ acpi_status acpi_hw_clear_acpi_status(void)
acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags); acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags);
if (ACPI_FAILURE(status)) if (ACPI_FAILURE(status)) {
goto exit; goto exit;
}
/* Clear the GPE Bits in all GPE registers in all GPE blocks */ /* Clear the GPE Bits in all GPE registers in all GPE blocks */
......
...@@ -237,6 +237,16 @@ void acpi_ns_detach_object(struct acpi_namespace_node *node) ...@@ -237,6 +237,16 @@ void acpi_ns_detach_object(struct acpi_namespace_node *node)
(node->object->common.type != ACPI_TYPE_LOCAL_DATA)) { (node->object->common.type != ACPI_TYPE_LOCAL_DATA)) {
node->object = node->object->common.next_object; node->object = node->object->common.next_object;
} }
/*
* Detach the object from any data objects (which are still held by
* the namespace node)
*/
if (obj_desc->common.next_object &&
((obj_desc->common.next_object)->common.type ==
ACPI_TYPE_LOCAL_DATA)) {
obj_desc->common.next_object = NULL;
}
} }
/* Reset the node type to untyped */ /* Reset the node type to untyped */
......
...@@ -199,3 +199,131 @@ acpi_ut_debug_dump_buffer(u8 *buffer, u32 count, u32 display, u32 component_id) ...@@ -199,3 +199,131 @@ acpi_ut_debug_dump_buffer(u8 *buffer, u32 count, u32 display, u32 component_id)
acpi_ut_dump_buffer(buffer, count, display, 0); acpi_ut_dump_buffer(buffer, count, display, 0);
} }
#ifdef ACPI_APPLICATION
/*******************************************************************************
*
* FUNCTION: acpi_ut_dump_buffer_to_file
*
* PARAMETERS: file - File descriptor
* buffer - Buffer to dump
* count - Amount to dump, in bytes
* display - BYTE, WORD, DWORD, or QWORD display:
* DB_BYTE_DISPLAY
* DB_WORD_DISPLAY
* DB_DWORD_DISPLAY
* DB_QWORD_DISPLAY
* base_offset - Beginning buffer offset (display only)
*
* RETURN: None
*
* DESCRIPTION: Generic dump buffer in both hex and ascii to a file.
*
******************************************************************************/
void
acpi_ut_dump_buffer_to_file(ACPI_FILE file,
u8 *buffer, u32 count, u32 display, u32 base_offset)
{
u32 i = 0;
u32 j;
u32 temp32;
u8 buf_char;
if (!buffer) {
acpi_ut_file_printf(file,
"Null Buffer Pointer in DumpBuffer!\n");
return;
}
if ((count < 4) || (count & 0x01)) {
display = DB_BYTE_DISPLAY;
}
/* Nasty little dump buffer routine! */
while (i < count) {
/* Print current offset */
acpi_ut_file_printf(file, "%6.4X: ", (base_offset + i));
/* Print 16 hex chars */
for (j = 0; j < 16;) {
if (i + j >= count) {
/* Dump fill spaces */
acpi_ut_file_printf(file, "%*s",
((display * 2) + 1), " ");
j += display;
continue;
}
switch (display) {
case DB_BYTE_DISPLAY:
default: /* Default is BYTE display */
acpi_ut_file_printf(file, "%02X ",
buffer[(acpi_size) i + j]);
break;
case DB_WORD_DISPLAY:
ACPI_MOVE_16_TO_32(&temp32,
&buffer[(acpi_size) i + j]);
acpi_ut_file_printf(file, "%04X ", temp32);
break;
case DB_DWORD_DISPLAY:
ACPI_MOVE_32_TO_32(&temp32,
&buffer[(acpi_size) i + j]);
acpi_ut_file_printf(file, "%08X ", temp32);
break;
case DB_QWORD_DISPLAY:
ACPI_MOVE_32_TO_32(&temp32,
&buffer[(acpi_size) i + j]);
acpi_ut_file_printf(file, "%08X", temp32);
ACPI_MOVE_32_TO_32(&temp32,
&buffer[(acpi_size) i + j +
4]);
acpi_ut_file_printf(file, "%08X ", temp32);
break;
}
j += display;
}
/*
* Print the ASCII equivalent characters but watch out for the bad
* unprintable ones (printable chars are 0x20 through 0x7E)
*/
acpi_ut_file_printf(file, " ");
for (j = 0; j < 16; j++) {
if (i + j >= count) {
acpi_ut_file_printf(file, "\n");
return;
}
buf_char = buffer[(acpi_size) i + j];
if (ACPI_IS_PRINT(buf_char)) {
acpi_ut_file_printf(file, "%c", buf_char);
} else {
acpi_ut_file_printf(file, ".");
}
}
/* Done with that line. */
acpi_ut_file_printf(file, "\n");
i += 16;
}
return;
}
#endif
...@@ -1001,5 +1001,11 @@ acpi_ut_copy_iobject_to_iobject(union acpi_operand_object *source_desc, ...@@ -1001,5 +1001,11 @@ acpi_ut_copy_iobject_to_iobject(union acpi_operand_object *source_desc,
status = acpi_ut_copy_simple_object(source_desc, *dest_desc); status = acpi_ut_copy_simple_object(source_desc, *dest_desc);
} }
/* Delete the allocated object if copy failed */
if (ACPI_FAILURE(status)) {
acpi_ut_remove_reference(*dest_desc);
}
return_ACPI_STATUS(status); return_ACPI_STATUS(status);
} }
...@@ -561,3 +561,29 @@ acpi_ut_ptr_exit(u32 line_number, ...@@ -561,3 +561,29 @@ acpi_ut_ptr_exit(u32 line_number,
} }
#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)acpi_ut_file_vprintf(ACPI_FILE_ERR, format, args);
va_end(args);
}
ACPI_EXPORT_SYMBOL(acpi_log_error)
#endif
/*******************************************************************************
*
* Module Name: utfileio - simple file I/O routines
*
******************************************************************************/
/*
* Copyright (C) 2000 - 2014, 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 "accommon.h"
#include "actables.h"
#include "acapps.h"
#ifdef ACPI_ASL_COMPILER
#include "aslcompiler.h"
#endif
#define _COMPONENT ACPI_CA_DEBUGGER
ACPI_MODULE_NAME("utfileio")
#ifdef ACPI_APPLICATION
/* Local prototypes */
static acpi_status
acpi_ut_check_text_mode_corruption(u8 *table,
u32 table_length, u32 file_length);
static acpi_status
acpi_ut_read_table(FILE * fp,
struct acpi_table_header **table, u32 *table_length);
/*******************************************************************************
*
* FUNCTION: acpi_ut_check_text_mode_corruption
*
* PARAMETERS: table - Table buffer
* table_length - Length of table from the table header
* file_length - Length of the file that contains the table
*
* RETURN: Status
*
* DESCRIPTION: Check table for text mode file corruption where all linefeed
* characters (LF) have been replaced by carriage return linefeed
* pairs (CR/LF).
*
******************************************************************************/
static acpi_status
acpi_ut_check_text_mode_corruption(u8 *table, u32 table_length, u32 file_length)
{
u32 i;
u32 pairs = 0;
if (table_length != file_length) {
ACPI_WARNING((AE_INFO,
"File length (0x%X) is not the same as the table length (0x%X)",
file_length, table_length));
}
/* Scan entire table to determine if each LF has been prefixed with a CR */
for (i = 1; i < file_length; i++) {
if (table[i] == 0x0A) {
if (table[i - 1] != 0x0D) {
/* The LF does not have a preceding CR, table not corrupted */
return (AE_OK);
} else {
/* Found a CR/LF pair */
pairs++;
}
i++;
}
}
if (!pairs) {
return (AE_OK);
}
/*
* Entire table scanned, each CR is part of a CR/LF pair --
* meaning that the table was treated as a text file somewhere.
*
* NOTE: We can't "fix" the table, because any existing CR/LF pairs in the
* original table are left untouched by the text conversion process --
* meaning that we cannot simply replace CR/LF pairs with LFs.
*/
acpi_os_printf("Table has been corrupted by text mode conversion\n");
acpi_os_printf("All LFs (%u) were changed to CR/LF pairs\n", pairs);
acpi_os_printf("Table cannot be repaired!\n");
return (AE_BAD_VALUE);
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_read_table
*
* PARAMETERS: fp - File that contains table
* table - Return value, buffer with table
* table_length - Return value, length of table
*
* RETURN: Status
*
* DESCRIPTION: Load the DSDT from the file pointer
*
******************************************************************************/
static acpi_status
acpi_ut_read_table(FILE * fp,
struct acpi_table_header **table, u32 *table_length)
{
struct acpi_table_header table_header;
u32 actual;
acpi_status status;
u32 file_size;
u8 standard_header = TRUE;
s32 count;
/* Get the file size */
file_size = cm_get_file_size(fp);
if (file_size == ACPI_UINT32_MAX) {
return (AE_ERROR);
}
if (file_size < 4) {
return (AE_BAD_HEADER);
}
/* Read the signature */
fseek(fp, 0, SEEK_SET);
count = fread(&table_header, 1, sizeof(struct acpi_table_header), fp);
if (count != sizeof(struct acpi_table_header)) {
acpi_os_printf("Could not read the table header\n");
return (AE_BAD_HEADER);
}
/* The RSDP table does not have standard ACPI header */
if (ACPI_VALIDATE_RSDP_SIG(table_header.signature)) {
*table_length = file_size;
standard_header = FALSE;
} else {
#if 0
/* Validate the table header/length */
status = acpi_tb_validate_table_header(&table_header);
if (ACPI_FAILURE(status)) {
acpi_os_printf("Table header is invalid!\n");
return (status);
}
#endif
/* File size must be at least as long as the Header-specified length */
if (table_header.length > file_size) {
acpi_os_printf
("TableHeader length [0x%X] greater than the input file size [0x%X]\n",
table_header.length, file_size);
#ifdef ACPI_ASL_COMPILER
status = fl_check_for_ascii(fp, NULL, FALSE);
if (ACPI_SUCCESS(status)) {
acpi_os_printf
("File appears to be ASCII only, must be binary\n",
table_header.length, file_size);
}
#endif
return (AE_BAD_HEADER);
}
#ifdef ACPI_OBSOLETE_CODE
/* We only support a limited number of table types */
if (!ACPI_COMPARE_NAME
((char *)table_header.signature, ACPI_SIG_DSDT)
&& !ACPI_COMPARE_NAME((char *)table_header.signature,
ACPI_SIG_PSDT)
&& !ACPI_COMPARE_NAME((char *)table_header.signature,
ACPI_SIG_SSDT)) {
acpi_os_printf
("Table signature [%4.4s] is invalid or not supported\n",
(char *)table_header.signature);
ACPI_DUMP_BUFFER(&table_header,
sizeof(struct acpi_table_header));
return (AE_ERROR);
}
#endif
*table_length = table_header.length;
}
/* Allocate a buffer for the table */
*table = acpi_os_allocate((size_t) file_size);
if (!*table) {
acpi_os_printf
("Could not allocate memory for ACPI table %4.4s (size=0x%X)\n",
table_header.signature, *table_length);
return (AE_NO_MEMORY);
}
/* Get the rest of the table */
fseek(fp, 0, SEEK_SET);
actual = fread(*table, 1, (size_t) file_size, fp);
if (actual == file_size) {
if (standard_header) {
/* Now validate the checksum */
status = acpi_tb_verify_checksum((void *)*table,
ACPI_CAST_PTR(struct
acpi_table_header,
*table)->
length);
if (status == AE_BAD_CHECKSUM) {
status =
acpi_ut_check_text_mode_corruption((u8 *)
*table,
file_size,
(*table)->
length);
return (status);
}
}
return (AE_OK);
}
if (actual > 0) {
acpi_os_printf("Warning - reading table, asked for %X got %X\n",
file_size, actual);
return (AE_OK);
}
acpi_os_printf("Error - could not read the table file\n");
acpi_os_free(*table);
*table = NULL;
*table_length = 0;
return (AE_ERROR);
}
/*******************************************************************************
*
* FUNCTION: acpi_ut_read_table_from_file
*
* PARAMETERS: filename - File where table is located
* table - Where a pointer to the table is returned
*
* RETURN: Status
*
* DESCRIPTION: Get an ACPI table from a file
*
******************************************************************************/
acpi_status
acpi_ut_read_table_from_file(char *filename, struct acpi_table_header ** table)
{
FILE *file;
u32 file_size;
u32 table_length;
acpi_status status = AE_ERROR;
/* Open the file, get current size */
file = fopen(filename, "rb");
if (!file) {
perror("Could not open input file");
return (status);
}
file_size = cm_get_file_size(file);
if (file_size == ACPI_UINT32_MAX) {
goto exit;
}
/* Get the entire file */
fprintf(stderr,
"Loading Acpi table from file %10s - Length %.8u (%06X)\n",
filename, file_size, file_size);
status = acpi_ut_read_table(file, table, &table_length);
if (ACPI_FAILURE(status)) {
acpi_os_printf("Could not get table from the file\n");
}
exit:
fclose(file);
return (status);
}
#endif
...@@ -214,152 +214,6 @@ struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] = ...@@ -214,152 +214,6 @@ struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] =
}; };
#endif /* !ACPI_REDUCED_HARDWARE */ #endif /* !ACPI_REDUCED_HARDWARE */
/*******************************************************************************
*
* FUNCTION: acpi_ut_init_globals
*
* PARAMETERS: None
*
* RETURN: Status
*
* DESCRIPTION: Initialize ACPICA globals. All globals that require specific
* initialization should be initialized here. This allows for
* a warm restart.
*
******************************************************************************/
acpi_status acpi_ut_init_globals(void)
{
acpi_status status;
u32 i;
ACPI_FUNCTION_TRACE(ut_init_globals);
/* Create all memory caches */
status = acpi_ut_create_caches();
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Address Range lists */
for (i = 0; i < ACPI_ADDRESS_RANGE_MAX; i++) {
acpi_gbl_address_range_list[i] = NULL;
}
/* Mutex locked flags */
for (i = 0; i < ACPI_NUM_MUTEX; i++) {
acpi_gbl_mutex_info[i].mutex = NULL;
acpi_gbl_mutex_info[i].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
acpi_gbl_mutex_info[i].use_count = 0;
}
for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) {
acpi_gbl_owner_id_mask[i] = 0;
}
/* Last owner_ID is never valid */
acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000;
/* Event counters */
acpi_method_count = 0;
acpi_sci_count = 0;
acpi_gpe_count = 0;
for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
acpi_fixed_event_count[i] = 0;
}
#if (!ACPI_REDUCED_HARDWARE)
/* GPE/SCI support */
acpi_gbl_all_gpes_initialized = FALSE;
acpi_gbl_gpe_xrupt_list_head = NULL;
acpi_gbl_gpe_fadt_blocks[0] = NULL;
acpi_gbl_gpe_fadt_blocks[1] = NULL;
acpi_current_gpe_count = 0;
acpi_gbl_global_event_handler = NULL;
acpi_gbl_sci_handler_list = NULL;
#endif /* !ACPI_REDUCED_HARDWARE */
/* Global handlers */
acpi_gbl_global_notify[0].handler = NULL;
acpi_gbl_global_notify[1].handler = NULL;
acpi_gbl_exception_handler = NULL;
acpi_gbl_init_handler = NULL;
acpi_gbl_table_handler = NULL;
acpi_gbl_interface_handler = NULL;
/* Global Lock support */
acpi_gbl_global_lock_semaphore = NULL;
acpi_gbl_global_lock_mutex = NULL;
acpi_gbl_global_lock_acquired = FALSE;
acpi_gbl_global_lock_handle = 0;
acpi_gbl_global_lock_present = FALSE;
/* Miscellaneous variables */
acpi_gbl_DSDT = NULL;
acpi_gbl_cm_single_step = FALSE;
acpi_gbl_shutdown = FALSE;
acpi_gbl_ns_lookup_count = 0;
acpi_gbl_ps_find_count = 0;
acpi_gbl_acpi_hardware_present = TRUE;
acpi_gbl_last_owner_id_index = 0;
acpi_gbl_next_owner_id_offset = 0;
acpi_gbl_trace_dbg_level = 0;
acpi_gbl_trace_dbg_layer = 0;
acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT;
acpi_gbl_osi_mutex = NULL;
acpi_gbl_reg_methods_executed = FALSE;
/* Hardware oriented */
acpi_gbl_events_initialized = FALSE;
acpi_gbl_system_awake_and_running = TRUE;
/* Namespace */
acpi_gbl_module_code_list = NULL;
acpi_gbl_root_node = NULL;
acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
acpi_gbl_root_node_struct.descriptor_type = ACPI_DESC_TYPE_NAMED;
acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
acpi_gbl_root_node_struct.parent = NULL;
acpi_gbl_root_node_struct.child = NULL;
acpi_gbl_root_node_struct.peer = NULL;
acpi_gbl_root_node_struct.object = NULL;
#ifdef ACPI_DISASSEMBLER
acpi_gbl_external_list = NULL;
acpi_gbl_num_external_methods = 0;
acpi_gbl_resolved_external_methods = 0;
#endif
#ifdef ACPI_DEBUG_OUTPUT
acpi_gbl_lowest_stack_pointer = ACPI_CAST_PTR(acpi_size, ACPI_SIZE_MAX);
#endif
#ifdef ACPI_DBG_TRACK_ALLOCATIONS
acpi_gbl_display_final_mem_stats = FALSE;
acpi_gbl_disable_mem_tracking = FALSE;
#endif
ACPI_DEBUGGER_EXEC(acpi_gbl_db_terminate_threads = FALSE);
return_ACPI_STATUS(AE_OK);
}
/* Public globals */ /* Public globals */
ACPI_EXPORT_SYMBOL(acpi_gbl_FADT) ACPI_EXPORT_SYMBOL(acpi_gbl_FADT)
......
...@@ -102,6 +102,151 @@ static void acpi_ut_free_gpe_lists(void) ...@@ -102,6 +102,151 @@ static void acpi_ut_free_gpe_lists(void)
} }
#endif /* !ACPI_REDUCED_HARDWARE */ #endif /* !ACPI_REDUCED_HARDWARE */
/*******************************************************************************
*
* FUNCTION: acpi_ut_init_globals
*
* PARAMETERS: None
*
* RETURN: Status
*
* DESCRIPTION: Initialize ACPICA globals. All globals that require specific
* initialization should be initialized here. This allows for
* a warm restart.
*
******************************************************************************/
acpi_status acpi_ut_init_globals(void)
{
acpi_status status;
u32 i;
ACPI_FUNCTION_TRACE(ut_init_globals);
/* Create all memory caches */
status = acpi_ut_create_caches();
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Address Range lists */
for (i = 0; i < ACPI_ADDRESS_RANGE_MAX; i++) {
acpi_gbl_address_range_list[i] = NULL;
}
/* Mutex locked flags */
for (i = 0; i < ACPI_NUM_MUTEX; i++) {
acpi_gbl_mutex_info[i].mutex = NULL;
acpi_gbl_mutex_info[i].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
acpi_gbl_mutex_info[i].use_count = 0;
}
for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) {
acpi_gbl_owner_id_mask[i] = 0;
}
/* Last owner_ID is never valid */
acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000;
/* Event counters */
acpi_method_count = 0;
acpi_sci_count = 0;
acpi_gpe_count = 0;
for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
acpi_fixed_event_count[i] = 0;
}
#if (!ACPI_REDUCED_HARDWARE)
/* GPE/SCI support */
acpi_gbl_all_gpes_initialized = FALSE;
acpi_gbl_gpe_xrupt_list_head = NULL;
acpi_gbl_gpe_fadt_blocks[0] = NULL;
acpi_gbl_gpe_fadt_blocks[1] = NULL;
acpi_current_gpe_count = 0;
acpi_gbl_global_event_handler = NULL;
acpi_gbl_sci_handler_list = NULL;
#endif /* !ACPI_REDUCED_HARDWARE */
/* Global handlers */
acpi_gbl_global_notify[0].handler = NULL;
acpi_gbl_global_notify[1].handler = NULL;
acpi_gbl_exception_handler = NULL;
acpi_gbl_init_handler = NULL;
acpi_gbl_table_handler = NULL;
acpi_gbl_interface_handler = NULL;
/* Global Lock support */
acpi_gbl_global_lock_semaphore = NULL;
acpi_gbl_global_lock_mutex = NULL;
acpi_gbl_global_lock_acquired = FALSE;
acpi_gbl_global_lock_handle = 0;
acpi_gbl_global_lock_present = FALSE;
/* Miscellaneous variables */
acpi_gbl_DSDT = NULL;
acpi_gbl_cm_single_step = FALSE;
acpi_gbl_shutdown = FALSE;
acpi_gbl_ns_lookup_count = 0;
acpi_gbl_ps_find_count = 0;
acpi_gbl_acpi_hardware_present = TRUE;
acpi_gbl_last_owner_id_index = 0;
acpi_gbl_next_owner_id_offset = 0;
acpi_gbl_trace_dbg_level = 0;
acpi_gbl_trace_dbg_layer = 0;
acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
acpi_gbl_osi_mutex = NULL;
acpi_gbl_reg_methods_executed = FALSE;
/* Hardware oriented */
acpi_gbl_events_initialized = FALSE;
acpi_gbl_system_awake_and_running = TRUE;
/* Namespace */
acpi_gbl_module_code_list = NULL;
acpi_gbl_root_node = NULL;
acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
acpi_gbl_root_node_struct.descriptor_type = ACPI_DESC_TYPE_NAMED;
acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
acpi_gbl_root_node_struct.parent = NULL;
acpi_gbl_root_node_struct.child = NULL;
acpi_gbl_root_node_struct.peer = NULL;
acpi_gbl_root_node_struct.object = NULL;
#ifdef ACPI_DISASSEMBLER
acpi_gbl_external_list = NULL;
acpi_gbl_num_external_methods = 0;
acpi_gbl_resolved_external_methods = 0;
#endif
#ifdef ACPI_DEBUG_OUTPUT
acpi_gbl_lowest_stack_pointer = ACPI_CAST_PTR(acpi_size, ACPI_SIZE_MAX);
#endif
#ifdef ACPI_DBG_TRACK_ALLOCATIONS
acpi_gbl_display_final_mem_stats = FALSE;
acpi_gbl_disable_mem_tracking = FALSE;
#endif
ACPI_DEBUGGER_EXEC(acpi_gbl_db_terminate_threads = FALSE);
return_ACPI_STATUS(AE_OK);
}
/****************************************************************************** /******************************************************************************
* *
* FUNCTION: acpi_ut_terminate * FUNCTION: acpi_ut_terminate
......
This diff is collapsed.
...@@ -121,11 +121,11 @@ struct dentry; ...@@ -121,11 +121,11 @@ struct dentry;
struct dentry *apei_get_debugfs_dir(void); struct dentry *apei_get_debugfs_dir(void);
#define apei_estatus_for_each_section(estatus, section) \ #define apei_estatus_for_each_section(estatus, section) \
for (section = (struct acpi_generic_data *)(estatus + 1); \ for (section = (struct acpi_hest_generic_data *)(estatus + 1); \
(void *)section - (void *)estatus < estatus->data_length; \ (void *)section - (void *)estatus < estatus->data_length; \
section = (void *)(section+1) + section->error_data_length) section = (void *)(section+1) + section->error_data_length)
static inline u32 cper_estatus_len(struct acpi_generic_status *estatus) static inline u32 cper_estatus_len(struct acpi_hest_generic_status *estatus)
{ {
if (estatus->raw_data_length) if (estatus->raw_data_length)
return estatus->raw_data_offset + \ return estatus->raw_data_offset + \
...@@ -135,9 +135,9 @@ static inline u32 cper_estatus_len(struct acpi_generic_status *estatus) ...@@ -135,9 +135,9 @@ static inline u32 cper_estatus_len(struct acpi_generic_status *estatus)
} }
void cper_estatus_print(const char *pfx, void cper_estatus_print(const char *pfx,
const struct acpi_generic_status *estatus); const struct acpi_hest_generic_status *estatus);
int cper_estatus_check_header(const struct acpi_generic_status *estatus); int cper_estatus_check_header(const struct acpi_hest_generic_status *estatus);
int cper_estatus_check(const struct acpi_generic_status *estatus); int cper_estatus_check(const struct acpi_hest_generic_status *estatus);
int apei_osc_setup(void); int apei_osc_setup(void);
#endif #endif
...@@ -74,13 +74,13 @@ ...@@ -74,13 +74,13 @@
#define GHES_ESTATUS_CACHE_LEN(estatus_len) \ #define GHES_ESTATUS_CACHE_LEN(estatus_len) \
(sizeof(struct ghes_estatus_cache) + (estatus_len)) (sizeof(struct ghes_estatus_cache) + (estatus_len))
#define GHES_ESTATUS_FROM_CACHE(estatus_cache) \ #define GHES_ESTATUS_FROM_CACHE(estatus_cache) \
((struct acpi_generic_status *) \ ((struct acpi_hest_generic_status *) \
((struct ghes_estatus_cache *)(estatus_cache) + 1)) ((struct ghes_estatus_cache *)(estatus_cache) + 1))
#define GHES_ESTATUS_NODE_LEN(estatus_len) \ #define GHES_ESTATUS_NODE_LEN(estatus_len) \
(sizeof(struct ghes_estatus_node) + (estatus_len)) (sizeof(struct ghes_estatus_node) + (estatus_len))
#define GHES_ESTATUS_FROM_NODE(estatus_node) \ #define GHES_ESTATUS_FROM_NODE(estatus_node) \
((struct acpi_generic_status *) \ ((struct acpi_hest_generic_status *) \
((struct ghes_estatus_node *)(estatus_node) + 1)) ((struct ghes_estatus_node *)(estatus_node) + 1))
bool ghes_disable; bool ghes_disable;
...@@ -408,7 +408,7 @@ static void ghes_clear_estatus(struct ghes *ghes) ...@@ -408,7 +408,7 @@ static void ghes_clear_estatus(struct ghes *ghes)
ghes->flags &= ~GHES_TO_CLEAR; ghes->flags &= ~GHES_TO_CLEAR;
} }
static void ghes_handle_memory_failure(struct acpi_generic_data *gdata, int sev) static void ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata, int sev)
{ {
#ifdef CONFIG_ACPI_APEI_MEMORY_FAILURE #ifdef CONFIG_ACPI_APEI_MEMORY_FAILURE
unsigned long pfn; unsigned long pfn;
...@@ -441,10 +441,10 @@ static void ghes_handle_memory_failure(struct acpi_generic_data *gdata, int sev) ...@@ -441,10 +441,10 @@ static void ghes_handle_memory_failure(struct acpi_generic_data *gdata, int sev)
} }
static void ghes_do_proc(struct ghes *ghes, static void ghes_do_proc(struct ghes *ghes,
const struct acpi_generic_status *estatus) const struct acpi_hest_generic_status *estatus)
{ {
int sev, sec_sev; int sev, sec_sev;
struct acpi_generic_data *gdata; struct acpi_hest_generic_data *gdata;
sev = ghes_severity(estatus->error_severity); sev = ghes_severity(estatus->error_severity);
apei_estatus_for_each_section(estatus, gdata) { apei_estatus_for_each_section(estatus, gdata) {
...@@ -498,7 +498,7 @@ static void ghes_do_proc(struct ghes *ghes, ...@@ -498,7 +498,7 @@ static void ghes_do_proc(struct ghes *ghes,
static void __ghes_print_estatus(const char *pfx, static void __ghes_print_estatus(const char *pfx,
const struct acpi_hest_generic *generic, const struct acpi_hest_generic *generic,
const struct acpi_generic_status *estatus) const struct acpi_hest_generic_status *estatus)
{ {
static atomic_t seqno; static atomic_t seqno;
unsigned int curr_seqno; unsigned int curr_seqno;
...@@ -520,7 +520,7 @@ static void __ghes_print_estatus(const char *pfx, ...@@ -520,7 +520,7 @@ static void __ghes_print_estatus(const char *pfx,
static int ghes_print_estatus(const char *pfx, static int ghes_print_estatus(const char *pfx,
const struct acpi_hest_generic *generic, const struct acpi_hest_generic *generic,
const struct acpi_generic_status *estatus) const struct acpi_hest_generic_status *estatus)
{ {
/* Not more than 2 messages every 5 seconds */ /* Not more than 2 messages every 5 seconds */
static DEFINE_RATELIMIT_STATE(ratelimit_corrected, 5*HZ, 2); static DEFINE_RATELIMIT_STATE(ratelimit_corrected, 5*HZ, 2);
...@@ -542,13 +542,13 @@ static int ghes_print_estatus(const char *pfx, ...@@ -542,13 +542,13 @@ static int ghes_print_estatus(const char *pfx,
* GHES error status reporting throttle, to report more kinds of * GHES error status reporting throttle, to report more kinds of
* errors, instead of just most frequently occurred errors. * errors, instead of just most frequently occurred errors.
*/ */
static int ghes_estatus_cached(struct acpi_generic_status *estatus) static int ghes_estatus_cached(struct acpi_hest_generic_status *estatus)
{ {
u32 len; u32 len;
int i, cached = 0; int i, cached = 0;
unsigned long long now; unsigned long long now;
struct ghes_estatus_cache *cache; struct ghes_estatus_cache *cache;
struct acpi_generic_status *cache_estatus; struct acpi_hest_generic_status *cache_estatus;
len = cper_estatus_len(estatus); len = cper_estatus_len(estatus);
rcu_read_lock(); rcu_read_lock();
...@@ -573,12 +573,12 @@ static int ghes_estatus_cached(struct acpi_generic_status *estatus) ...@@ -573,12 +573,12 @@ static int ghes_estatus_cached(struct acpi_generic_status *estatus)
static struct ghes_estatus_cache *ghes_estatus_cache_alloc( static struct ghes_estatus_cache *ghes_estatus_cache_alloc(
struct acpi_hest_generic *generic, struct acpi_hest_generic *generic,
struct acpi_generic_status *estatus) struct acpi_hest_generic_status *estatus)
{ {
int alloced; int alloced;
u32 len, cache_len; u32 len, cache_len;
struct ghes_estatus_cache *cache; struct ghes_estatus_cache *cache;
struct acpi_generic_status *cache_estatus; struct acpi_hest_generic_status *cache_estatus;
alloced = atomic_add_return(1, &ghes_estatus_cache_alloced); alloced = atomic_add_return(1, &ghes_estatus_cache_alloced);
if (alloced > GHES_ESTATUS_CACHE_ALLOCED_MAX) { if (alloced > GHES_ESTATUS_CACHE_ALLOCED_MAX) {
...@@ -621,7 +621,7 @@ static void ghes_estatus_cache_rcu_free(struct rcu_head *head) ...@@ -621,7 +621,7 @@ static void ghes_estatus_cache_rcu_free(struct rcu_head *head)
static void ghes_estatus_cache_add( static void ghes_estatus_cache_add(
struct acpi_hest_generic *generic, struct acpi_hest_generic *generic,
struct acpi_generic_status *estatus) struct acpi_hest_generic_status *estatus)
{ {
int i, slot = -1, count; int i, slot = -1, count;
unsigned long long now, duration, period, max_period = 0; unsigned long long now, duration, period, max_period = 0;
...@@ -753,7 +753,7 @@ static void ghes_proc_in_irq(struct irq_work *irq_work) ...@@ -753,7 +753,7 @@ static void ghes_proc_in_irq(struct irq_work *irq_work)
struct llist_node *llnode, *next; struct llist_node *llnode, *next;
struct ghes_estatus_node *estatus_node; struct ghes_estatus_node *estatus_node;
struct acpi_hest_generic *generic; struct acpi_hest_generic *generic;
struct acpi_generic_status *estatus; struct acpi_hest_generic_status *estatus;
u32 len, node_len; u32 len, node_len;
llnode = llist_del_all(&ghes_estatus_llist); llnode = llist_del_all(&ghes_estatus_llist);
...@@ -786,7 +786,7 @@ static void ghes_print_queued_estatus(void) ...@@ -786,7 +786,7 @@ static void ghes_print_queued_estatus(void)
struct llist_node *llnode; struct llist_node *llnode;
struct ghes_estatus_node *estatus_node; struct ghes_estatus_node *estatus_node;
struct acpi_hest_generic *generic; struct acpi_hest_generic *generic;
struct acpi_generic_status *estatus; struct acpi_hest_generic_status *estatus;
u32 len, node_len; u32 len, node_len;
llnode = llist_del_all(&ghes_estatus_llist); llnode = llist_del_all(&ghes_estatus_llist);
...@@ -845,7 +845,7 @@ static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs) ...@@ -845,7 +845,7 @@ static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs)
#ifdef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG #ifdef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG
u32 len, node_len; u32 len, node_len;
struct ghes_estatus_node *estatus_node; struct ghes_estatus_node *estatus_node;
struct acpi_generic_status *estatus; struct acpi_hest_generic_status *estatus;
#endif #endif
if (!(ghes->flags & GHES_TO_CLEAR)) if (!(ghes->flags & GHES_TO_CLEAR))
continue; continue;
...@@ -925,7 +925,7 @@ static int ghes_probe(struct platform_device *ghes_dev) ...@@ -925,7 +925,7 @@ static int ghes_probe(struct platform_device *ghes_dev)
rc = -EIO; rc = -EIO;
if (generic->error_block_length < if (generic->error_block_length <
sizeof(struct acpi_generic_status)) { sizeof(struct acpi_hest_generic_status)) {
pr_warning(FW_BUG GHES_PFX "Invalid error block length: %u for generic hardware error source: %d\n", pr_warning(FW_BUG GHES_PFX "Invalid error block length: %u for generic hardware error source: %d\n",
generic->error_block_length, generic->error_block_length,
generic->header.source_id); generic->header.source_id);
......
...@@ -262,7 +262,7 @@ static const char *cper_pcie_port_type_strs[] = { ...@@ -262,7 +262,7 @@ static const char *cper_pcie_port_type_strs[] = {
}; };
static void cper_print_pcie(const char *pfx, const struct cper_sec_pcie *pcie, static void cper_print_pcie(const char *pfx, const struct cper_sec_pcie *pcie,
const struct acpi_generic_data *gdata) const struct acpi_hest_generic_data *gdata)
{ {
if (pcie->validation_bits & CPER_PCIE_VALID_PORT_TYPE) if (pcie->validation_bits & CPER_PCIE_VALID_PORT_TYPE)
printk("%s""port_type: %d, %s\n", pfx, pcie->port_type, printk("%s""port_type: %d, %s\n", pfx, pcie->port_type,
...@@ -298,7 +298,7 @@ static void cper_print_pcie(const char *pfx, const struct cper_sec_pcie *pcie, ...@@ -298,7 +298,7 @@ static void cper_print_pcie(const char *pfx, const struct cper_sec_pcie *pcie,
} }
static void cper_estatus_print_section( static void cper_estatus_print_section(
const char *pfx, const struct acpi_generic_data *gdata, int sec_no) const char *pfx, const struct acpi_hest_generic_data *gdata, int sec_no)
{ {
uuid_le *sec_type = (uuid_le *)gdata->section_type; uuid_le *sec_type = (uuid_le *)gdata->section_type;
__u16 severity; __u16 severity;
...@@ -344,9 +344,9 @@ static void cper_estatus_print_section( ...@@ -344,9 +344,9 @@ static void cper_estatus_print_section(
} }
void cper_estatus_print(const char *pfx, void cper_estatus_print(const char *pfx,
const struct acpi_generic_status *estatus) const struct acpi_hest_generic_status *estatus)
{ {
struct acpi_generic_data *gdata; struct acpi_hest_generic_data *gdata;
unsigned int data_len, gedata_len; unsigned int data_len, gedata_len;
int sec_no = 0; int sec_no = 0;
char newpfx[64]; char newpfx[64];
...@@ -359,7 +359,7 @@ void cper_estatus_print(const char *pfx, ...@@ -359,7 +359,7 @@ void cper_estatus_print(const char *pfx,
"and requires no further action"); "and requires no further action");
printk("%s""event severity: %s\n", pfx, cper_severity_str(severity)); printk("%s""event severity: %s\n", pfx, cper_severity_str(severity));
data_len = estatus->data_length; data_len = estatus->data_length;
gdata = (struct acpi_generic_data *)(estatus + 1); gdata = (struct acpi_hest_generic_data *)(estatus + 1);
snprintf(newpfx, sizeof(newpfx), "%s%s", pfx, INDENT_SP); snprintf(newpfx, sizeof(newpfx), "%s%s", pfx, INDENT_SP);
while (data_len >= sizeof(*gdata)) { while (data_len >= sizeof(*gdata)) {
gedata_len = gdata->error_data_length; gedata_len = gdata->error_data_length;
...@@ -371,10 +371,10 @@ void cper_estatus_print(const char *pfx, ...@@ -371,10 +371,10 @@ void cper_estatus_print(const char *pfx,
} }
EXPORT_SYMBOL_GPL(cper_estatus_print); EXPORT_SYMBOL_GPL(cper_estatus_print);
int cper_estatus_check_header(const struct acpi_generic_status *estatus) int cper_estatus_check_header(const struct acpi_hest_generic_status *estatus)
{ {
if (estatus->data_length && if (estatus->data_length &&
estatus->data_length < sizeof(struct acpi_generic_data)) estatus->data_length < sizeof(struct acpi_hest_generic_data))
return -EINVAL; return -EINVAL;
if (estatus->raw_data_length && if (estatus->raw_data_length &&
estatus->raw_data_offset < sizeof(*estatus) + estatus->data_length) estatus->raw_data_offset < sizeof(*estatus) + estatus->data_length)
...@@ -384,9 +384,9 @@ int cper_estatus_check_header(const struct acpi_generic_status *estatus) ...@@ -384,9 +384,9 @@ int cper_estatus_check_header(const struct acpi_generic_status *estatus)
} }
EXPORT_SYMBOL_GPL(cper_estatus_check_header); EXPORT_SYMBOL_GPL(cper_estatus_check_header);
int cper_estatus_check(const struct acpi_generic_status *estatus) int cper_estatus_check(const struct acpi_hest_generic_status *estatus)
{ {
struct acpi_generic_data *gdata; struct acpi_hest_generic_data *gdata;
unsigned int data_len, gedata_len; unsigned int data_len, gedata_len;
int rc; int rc;
...@@ -394,7 +394,7 @@ int cper_estatus_check(const struct acpi_generic_status *estatus) ...@@ -394,7 +394,7 @@ int cper_estatus_check(const struct acpi_generic_status *estatus)
if (rc) if (rc)
return rc; return rc;
data_len = estatus->data_length; data_len = estatus->data_length;
gdata = (struct acpi_generic_data *)(estatus + 1); gdata = (struct acpi_hest_generic_data *)(estatus + 1);
while (data_len >= sizeof(*gdata)) { while (data_len >= sizeof(*gdata)) {
gedata_len = gdata->error_data_length; gedata_len = gdata->error_data_length;
if (gedata_len > data_len - sizeof(*gdata)) if (gedata_len > data_len - sizeof(*gdata))
......
...@@ -399,4 +399,35 @@ char *acpi_os_get_next_filename(void *dir_handle); ...@@ -399,4 +399,35 @@ 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
#endif /* __ACPIOSXF_H__ */ #endif /* __ACPIOSXF_H__ */
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
/* Current ACPICA subsystem version in YYYYMMDD format */ /* Current ACPICA subsystem version in YYYYMMDD format */
#define ACPI_CA_VERSION 0x20140424 #define ACPI_CA_VERSION 0x20140627
#include <acpi/acconfig.h> #include <acpi/acconfig.h>
#include <acpi/actypes.h> #include <acpi/actypes.h>
...@@ -335,6 +335,23 @@ ACPI_GLOBAL(u8, acpi_gbl_system_awake_and_running); ...@@ -335,6 +335,23 @@ ACPI_GLOBAL(u8, acpi_gbl_system_awake_and_running);
#endif /* ACPI_DEBUG_OUTPUT */ #endif /* ACPI_DEBUG_OUTPUT */
/*
* Application prototypes
*
* All interfaces used by application will be configured
* out of the ACPICA build unless the ACPI_APPLICATION
* flag is defined.
*/
#ifdef ACPI_APPLICATION
#define ACPI_APP_DEPENDENT_RETURN_VOID(prototype) \
prototype;
#else
#define ACPI_APP_DEPENDENT_RETURN_VOID(prototype) \
static ACPI_INLINE prototype {return;}
#endif /* ACPI_APPLICATION */
/***************************************************************************** /*****************************************************************************
* *
* ACPICA public interface prototypes * ACPICA public interface prototypes
...@@ -657,6 +674,10 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status ...@@ -657,6 +674,10 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
acpi_finish_gpe(acpi_handle gpe_device, acpi_finish_gpe(acpi_handle gpe_device,
u32 gpe_number)) u32 gpe_number))
ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
acpi_mark_gpe_for_wake(acpi_handle gpe_device,
u32 gpe_number))
ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
acpi_setup_gpe_for_wake(acpi_handle acpi_setup_gpe_for_wake(acpi_handle
parent_device, parent_device,
...@@ -861,6 +882,9 @@ ACPI_DBG_DEPENDENT_RETURN_VOID(ACPI_PRINTF_LIKE(6) ...@@ -861,6 +882,9 @@ ACPI_DBG_DEPENDENT_RETURN_VOID(ACPI_PRINTF_LIKE(6)
const char *module_name, const char *module_name,
u32 component_id, u32 component_id,
const char *format, ...)) const char *format, ...))
ACPI_APP_DEPENDENT_RETURN_VOID(ACPI_PRINTF_LIKE(1)
void ACPI_INTERNAL_VAR_XFACE
acpi_log_error(const char *format, ...))
/* /*
* Divergences * Divergences
......
...@@ -604,7 +604,7 @@ struct acpi_hest_generic { ...@@ -604,7 +604,7 @@ struct acpi_hest_generic {
/* Generic Error Status block */ /* Generic Error Status block */
struct acpi_generic_status { struct acpi_hest_generic_status {
u32 block_status; u32 block_status;
u32 raw_data_offset; u32 raw_data_offset;
u32 raw_data_length; u32 raw_data_length;
...@@ -614,15 +614,15 @@ struct acpi_generic_status { ...@@ -614,15 +614,15 @@ struct acpi_generic_status {
/* Values for block_status flags above */ /* Values for block_status flags above */
#define ACPI_GEN_ERR_UC BIT(0) #define ACPI_HEST_UNCORRECTABLE (1)
#define ACPI_GEN_ERR_CE BIT(1) #define ACPI_HEST_CORRECTABLE (1<<1)
#define ACPI_GEN_ERR_MULTI_UC BIT(2) #define ACPI_HEST_MULTIPLE_UNCORRECTABLE (1<<2)
#define ACPI_GEN_ERR_MULTI_CE BIT(3) #define ACPI_HEST_MULTIPLE_CORRECTABLE (1<<3)
#define ACPI_GEN_ERR_COUNT_SHIFT (0xFF<<4) /* 8 bits, error count */ #define ACPI_HEST_ERROR_ENTRY_COUNT (0xFF<<4) /* 8 bits, error count */
/* Generic Error Data entry */ /* Generic Error Data entry */
struct acpi_generic_data { struct acpi_hest_generic_data {
u8 section_type[16]; u8 section_type[16];
u32 error_severity; u32 error_severity;
u16 revision; u16 revision;
......
...@@ -516,7 +516,7 @@ struct acpi_dmar_andd { ...@@ -516,7 +516,7 @@ struct acpi_dmar_andd {
struct acpi_dmar_header header; struct acpi_dmar_header header;
u8 reserved[3]; u8 reserved[3];
u8 device_number; u8 device_number;
u8 object_name[]; char object_name[1];
}; };
/******************************************************************************* /*******************************************************************************
......
...@@ -126,6 +126,7 @@ ...@@ -126,6 +126,7 @@
typedef unsigned char u8; typedef unsigned char u8;
typedef unsigned char u8; typedef unsigned char u8;
typedef unsigned short u16; typedef unsigned short u16;
typedef short s16;
typedef COMPILER_DEPENDENT_UINT64 u64; typedef COMPILER_DEPENDENT_UINT64 u64;
typedef COMPILER_DEPENDENT_INT64 s64; typedef COMPILER_DEPENDENT_INT64 s64;
...@@ -1244,4 +1245,17 @@ struct acpi_memory_list { ...@@ -1244,4 +1245,17 @@ struct acpi_memory_list {
#define ACPI_OSI_WIN_7 0x0B #define ACPI_OSI_WIN_7 0x0B
#define ACPI_OSI_WIN_8 0x0C #define ACPI_OSI_WIN_8 0x0C
/* 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 */
#define ACPI_OPT_END -1
#endif /* __ACTYPES_H__ */ #endif /* __ACTYPES_H__ */
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
struct ghes { struct ghes {
struct acpi_hest_generic *generic; struct acpi_hest_generic *generic;
struct acpi_generic_status *estatus; struct acpi_hest_generic_status *estatus;
u64 buffer_paddr; u64 buffer_paddr;
unsigned long flags; unsigned long flags;
union { union {
......
...@@ -87,20 +87,14 @@ ...@@ -87,20 +87,14 @@
#define ACPI_DBG_TRACK_ALLOCATIONS #define ACPI_DBG_TRACK_ALLOCATIONS
#endif #endif
/* acpi_names configuration. Single threaded with debugger output enabled. */
#ifdef ACPI_NAMES_APP
#define ACPI_DEBUGGER
#define ACPI_APPLICATION
#define ACPI_SINGLE_THREADED
#endif
/* /*
* acpi_bin/acpi_dump/acpi_src/acpi_xtract/Example configuration. All single * acpi_bin/acpi_dump/acpi_help/acpi_names/acpi_src/acpi_xtract/Example configuration.
* threaded, with no debug output. * All single threaded.
*/ */
#if (defined ACPI_BIN_APP) || \ #if (defined ACPI_BIN_APP) || \
(defined ACPI_DUMP_APP) || \ (defined ACPI_DUMP_APP) || \
(defined ACPI_HELP_APP) || \
(defined ACPI_NAMES_APP) || \
(defined ACPI_SRC_APP) || \ (defined ACPI_SRC_APP) || \
(defined ACPI_XTRACT_APP) || \ (defined ACPI_XTRACT_APP) || \
(defined ACPI_EXAMPLE_APP) (defined ACPI_EXAMPLE_APP)
...@@ -108,12 +102,40 @@ ...@@ -108,12 +102,40 @@
#define ACPI_SINGLE_THREADED #define ACPI_SINGLE_THREADED
#endif #endif
/* acpi_help configuration. Error messages disabled. */
#ifdef ACPI_HELP_APP #ifdef ACPI_HELP_APP
#define ACPI_APPLICATION
#define ACPI_SINGLE_THREADED
#define ACPI_NO_ERROR_MESSAGES #define ACPI_NO_ERROR_MESSAGES
#endif #endif
/* acpi_names configuration. Debug output enabled. */
#ifdef ACPI_NAMES_APP
#define ACPI_DEBUG_OUTPUT
#endif
/* acpi_exec/acpi_names/Example configuration. Native RSDP used. */
#if (defined ACPI_EXEC_APP) || \
(defined ACPI_EXAMPLE_APP) || \
(defined ACPI_NAMES_APP)
#define ACPI_USE_NATIVE_RSDP_POINTER
#endif
/* acpi_dump configuration. Native mapping used if provied by OSPMs */
#ifdef ACPI_DUMP_APP
#define ACPI_USE_NATIVE_MEMORY_MAPPING
#define USE_NATIVE_ALLOCATE_ZEROED
#endif
/* acpi_names/Example configuration. Hardware disabled */
#if (defined ACPI_EXAMPLE_APP) || \
(defined ACPI_NAMES_APP)
#define ACPI_REDUCED_HARDWARE 1
#endif
/* Linkable ACPICA library */ /* Linkable ACPICA library */
#ifdef ACPI_LIBRARY #ifdef ACPI_LIBRARY
...@@ -185,6 +207,9 @@ ...@@ -185,6 +207,9 @@
#elif defined(_AED_EFI) #elif defined(_AED_EFI)
#include "acefi.h" #include "acefi.h"
#elif defined(_GNU_EFI)
#include "acefi.h"
#elif defined(__HAIKU__) #elif defined(__HAIKU__)
#include "achaiku.h" #include "achaiku.h"
...@@ -399,8 +424,12 @@ typedef char *va_list; ...@@ -399,8 +424,12 @@ typedef char *va_list;
#ifdef ACPI_APPLICATION #ifdef ACPI_APPLICATION
#include <stdio.h> #include <stdio.h>
#define ACPI_FILE FILE * #define ACPI_FILE FILE *
#define ACPI_FILE_OUT stdout
#define ACPI_FILE_ERR stderr
#else #else
#define ACPI_FILE void * #define ACPI_FILE void *
#define ACPI_FILE_OUT NULL
#define ACPI_FILE_ERR NULL
#endif /* ACPI_APPLICATION */ #endif /* ACPI_APPLICATION */
#endif /* ACPI_FILE */ #endif /* ACPI_FILE */
......
...@@ -108,13 +108,18 @@ DUMP_OBJS = \ ...@@ -108,13 +108,18 @@ DUMP_OBJS = \
apmain.o\ apmain.o\
osunixdir.o\ osunixdir.o\
osunixmap.o\ osunixmap.o\
osunixxf.o\
tbprint.o\ tbprint.o\
tbxfroot.o\ tbxfroot.o\
utbuffer.o\ utbuffer.o\
utdebug.o\
utexcep.o\ utexcep.o\
utglobal.o\
utmath.o\ utmath.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
......
...@@ -58,44 +58,46 @@ ACPI_MODULE_NAME("cmfsize") ...@@ -58,44 +58,46 @@ ACPI_MODULE_NAME("cmfsize")
* RETURN: File Size. On error, -1 (ACPI_UINT32_MAX) * RETURN: File Size. On error, -1 (ACPI_UINT32_MAX)
* *
* DESCRIPTION: Get the size of a file. Uses seek-to-EOF. File must be open. * DESCRIPTION: Get the size of a file. Uses seek-to-EOF. File must be open.
* Does not disturb the current file pointer. Uses perror for * Does not disturb the current file pointer.
* error messages.
* *
******************************************************************************/ ******************************************************************************/
u32 cm_get_file_size(FILE * file) u32 cm_get_file_size(ACPI_FILE file)
{ {
long file_size; long file_size;
long current_offset; long current_offset;
acpi_status status;
/* 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 = ftell(file); current_offset = acpi_os_get_file_offset(file);
if (current_offset < 0) { if (current_offset < 0) {
goto offset_error; goto offset_error;
} }
if (fseek(file, 0, SEEK_END)) { status = acpi_os_set_file_offset(file, 0, ACPI_FILE_END);
if (ACPI_FAILURE(status)) {
goto seek_error; goto seek_error;
} }
file_size = ftell(file); file_size = acpi_os_get_file_offset(file);
if (file_size < 0) { if (file_size < 0) {
goto offset_error; goto offset_error;
} }
/* Restore original file pointer */ /* Restore original file pointer */
if (fseek(file, current_offset, SEEK_SET)) { status = acpi_os_set_file_offset(file, current_offset, ACPI_FILE_BEGIN);
if (ACPI_FAILURE(status)) {
goto seek_error; goto seek_error;
} }
return ((u32)file_size); return ((u32)file_size);
offset_error: offset_error:
perror("Could not get file offset"); acpi_log_error("Could not get file offset");
return (ACPI_UINT32_MAX); return (ACPI_UINT32_MAX);
seek_error: seek_error:
perror("Could not seek file"); acpi_log_error("Could not set file offset");
return (ACPI_UINT32_MAX); return (ACPI_UINT32_MAX);
} }
...@@ -51,14 +51,12 @@ ...@@ -51,14 +51,12 @@
* "f|" - Option has required single-char sub-options * "f|" - Option has required single-char sub-options
*/ */
#include <stdio.h>
#include <string.h>
#include <acpi/acpi.h> #include <acpi/acpi.h>
#include "accommon.h" #include "accommon.h"
#include "acapps.h" #include "acapps.h"
#define ACPI_OPTION_ERROR(msg, badchar) \ #define ACPI_OPTION_ERROR(msg, badchar) \
if (acpi_gbl_opterr) {fprintf (stderr, "%s%c\n", msg, badchar);} if (acpi_gbl_opterr) {acpi_log_error ("%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;
...@@ -113,7 +111,7 @@ int acpi_getopt_argument(int argc, char **argv) ...@@ -113,7 +111,7 @@ int acpi_getopt_argument(int argc, char **argv)
* PARAMETERS: argc, argv - from main * PARAMETERS: argc, argv - from main
* opts - options info list * opts - options info list
* *
* RETURN: Option character or EOF * RETURN: Option character or ACPI_OPT_END
* *
* DESCRIPTION: Get the next option * DESCRIPTION: Get the next option
* *
...@@ -128,10 +126,10 @@ int acpi_getopt(int argc, char **argv, char *opts) ...@@ -128,10 +126,10 @@ int acpi_getopt(int argc, char **argv, char *opts)
if (acpi_gbl_optind >= argc || if (acpi_gbl_optind >= argc ||
argv[acpi_gbl_optind][0] != '-' || argv[acpi_gbl_optind][0] != '-' ||
argv[acpi_gbl_optind][1] == '\0') { argv[acpi_gbl_optind][1] == '\0') {
return (EOF); return (ACPI_OPT_END);
} else if (strcmp(argv[acpi_gbl_optind], "--") == 0) { } else if (ACPI_STRCMP(argv[acpi_gbl_optind], "--") == 0) {
acpi_gbl_optind++; acpi_gbl_optind++;
return (EOF); return (ACPI_OPT_END);
} }
} }
...@@ -142,7 +140,7 @@ int acpi_getopt(int argc, char **argv, char *opts) ...@@ -142,7 +140,7 @@ int acpi_getopt(int argc, char **argv, char *opts)
/* Make sure that the option is legal */ /* Make sure that the option is legal */
if (current_char == ':' || if (current_char == ':' ||
(opts_ptr = strchr(opts, current_char)) == NULL) { (opts_ptr = ACPI_STRCHR(opts, current_char)) == NULL) {
ACPI_OPTION_ERROR("Illegal option: -", current_char); ACPI_OPTION_ERROR("Illegal option: -", current_char);
if (argv[acpi_gbl_optind][++current_char_ptr] == '\0') { if (argv[acpi_gbl_optind][++current_char_ptr] == '\0') {
......
/******************************************************************************
*
* Module Name: oslibcfs - C library OSL for file I/O
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2014, 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);
}
}
...@@ -77,6 +77,9 @@ osl_map_table(acpi_size address, ...@@ -77,6 +77,9 @@ osl_map_table(acpi_size address,
static void osl_unmap_table(struct acpi_table_header *table); static void osl_unmap_table(struct acpi_table_header *table);
static acpi_physical_address
osl_find_rsdp_via_efi_by_keyword(FILE * file, const char *keyword);
static acpi_physical_address osl_find_rsdp_via_efi(void); static acpi_physical_address osl_find_rsdp_via_efi(void);
static acpi_status osl_load_rsdp(void); static acpi_status osl_load_rsdp(void);
...@@ -415,6 +418,38 @@ acpi_os_get_table_by_index(u32 index, ...@@ -415,6 +418,38 @@ acpi_os_get_table_by_index(u32 index,
return (status); return (status);
} }
/******************************************************************************
*
* FUNCTION: osl_find_rsdp_via_efi_by_keyword
*
* PARAMETERS: keyword - Character string indicating ACPI GUID version
* in the EFI table
*
* RETURN: RSDP address if found
*
* DESCRIPTION: Find RSDP address via EFI using keyword indicating the ACPI
* GUID version.
*
*****************************************************************************/
static acpi_physical_address
osl_find_rsdp_via_efi_by_keyword(FILE * file, const char *keyword)
{
char buffer[80];
unsigned long long address = 0;
char format[32];
snprintf(format, 32, "%s=%s", keyword, "%llx");
fseek(file, 0, SEEK_SET);
while (fgets(buffer, 80, file)) {
if (sscanf(buffer, format, &address) == 1) {
break;
}
}
return ((acpi_physical_address) (address));
}
/****************************************************************************** /******************************************************************************
* *
* FUNCTION: osl_find_rsdp_via_efi * FUNCTION: osl_find_rsdp_via_efi
...@@ -430,20 +465,19 @@ acpi_os_get_table_by_index(u32 index, ...@@ -430,20 +465,19 @@ acpi_os_get_table_by_index(u32 index,
static acpi_physical_address osl_find_rsdp_via_efi(void) static acpi_physical_address osl_find_rsdp_via_efi(void)
{ {
FILE *file; FILE *file;
char buffer[80]; acpi_physical_address address = 0;
unsigned long address = 0;
file = fopen(EFI_SYSTAB, "r"); file = fopen(EFI_SYSTAB, "r");
if (file) { if (file) {
while (fgets(buffer, 80, file)) { address = osl_find_rsdp_via_efi_by_keyword(file, "ACPI20");
if (sscanf(buffer, "ACPI20=0x%lx", &address) == 1) { if (!address) {
break; address =
} osl_find_rsdp_via_efi_by_keyword(file, "ACPI");
} }
fclose(file); fclose(file);
} }
return ((acpi_physical_address) (address)); return (address);
} }
/****************************************************************************** /******************************************************************************
......
This diff is collapsed.
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
#ifdef _DECLARE_GLOBALS #ifdef _DECLARE_GLOBALS
#define EXTERN #define EXTERN
#define INIT_GLOBAL(a,b) a=b #define INIT_GLOBAL(a,b) a=b
#define DEFINE_ACPI_GLOBALS 1
#else #else
#define EXTERN extern #define EXTERN extern
#define INIT_GLOBAL(a,b) a #define INIT_GLOBAL(a,b) a
...@@ -69,7 +68,7 @@ EXTERN u8 INIT_GLOBAL(gbl_verbose_mode, FALSE); ...@@ -69,7 +68,7 @@ EXTERN u8 INIT_GLOBAL(gbl_verbose_mode, FALSE);
EXTERN u8 INIT_GLOBAL(gbl_binary_mode, FALSE); EXTERN u8 INIT_GLOBAL(gbl_binary_mode, FALSE);
EXTERN u8 INIT_GLOBAL(gbl_dump_customized_tables, FALSE); EXTERN u8 INIT_GLOBAL(gbl_dump_customized_tables, FALSE);
EXTERN u8 INIT_GLOBAL(gbl_do_not_dump_xsdt, FALSE); EXTERN u8 INIT_GLOBAL(gbl_do_not_dump_xsdt, FALSE);
EXTERN FILE INIT_GLOBAL(*gbl_output_file, NULL); EXTERN ACPI_FILE INIT_GLOBAL(gbl_output_file, NULL);
EXTERN char INIT_GLOBAL(*gbl_output_filename, NULL); EXTERN char INIT_GLOBAL(*gbl_output_filename, NULL);
EXTERN u64 INIT_GLOBAL(gbl_rsdp_base, 0); EXTERN u64 INIT_GLOBAL(gbl_rsdp_base, 0);
......
...@@ -69,17 +69,16 @@ u8 ap_is_valid_header(struct acpi_table_header *table) ...@@ -69,17 +69,16 @@ u8 ap_is_valid_header(struct acpi_table_header *table)
/* Make sure signature is all ASCII and a valid ACPI name */ /* Make sure signature is all ASCII and a valid ACPI name */
if (!acpi_ut_valid_acpi_name(table->signature)) { if (!acpi_ut_valid_acpi_name(table->signature)) {
fprintf(stderr, acpi_log_error("Table signature (0x%8.8X) is invalid\n",
"Table signature (0x%8.8X) is invalid\n", *(u32 *)table->signature);
*(u32 *)table->signature);
return (FALSE); return (FALSE);
} }
/* 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)) {
fprintf(stderr, "Table length (0x%8.8X) is invalid\n", acpi_log_error("Table length (0x%8.8X) is invalid\n",
table->length); table->length);
return (FALSE); return (FALSE);
} }
} }
...@@ -116,8 +115,8 @@ u8 ap_is_valid_checksum(struct acpi_table_header *table) ...@@ -116,8 +115,8 @@ u8 ap_is_valid_checksum(struct acpi_table_header *table)
} }
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
fprintf(stderr, "%4.4s: Warning: wrong checksum in table\n", acpi_log_error("%4.4s: Warning: wrong checksum in table\n",
table->signature); table->signature);
} }
return (AE_OK); return (AE_OK);
...@@ -196,12 +195,13 @@ ap_dump_table_buffer(struct acpi_table_header *table, ...@@ -196,12 +195,13 @@ ap_dump_table_buffer(struct acpi_table_header *table,
* Note: simplest to just always emit a 64-bit address. acpi_xtract * Note: simplest to just always emit a 64-bit address. acpi_xtract
* utility can handle this. * utility can handle this.
*/ */
printf("%4.4s @ 0x%8.8X%8.8X\n", table->signature, acpi_ut_file_printf(gbl_output_file, "%4.4s @ 0x%8.8X%8.8X\n",
ACPI_FORMAT_UINT64(address)); table->signature, ACPI_FORMAT_UINT64(address));
acpi_ut_dump_buffer(ACPI_CAST_PTR(u8, table), table_length, acpi_ut_dump_buffer_to_file(gbl_output_file,
DB_BYTE_DISPLAY, 0); ACPI_CAST_PTR(u8, table), table_length,
printf("\n"); DB_BYTE_DISPLAY, 0);
acpi_ut_file_printf(gbl_output_file, "\n");
return (0); return (0);
} }
...@@ -239,20 +239,20 @@ int ap_dump_all_tables(void) ...@@ -239,20 +239,20 @@ 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) {
fprintf(stderr, acpi_log_error
"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 {
fprintf(stderr, acpi_log_error
"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;
} }
} }
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;
...@@ -288,22 +288,22 @@ int ap_dump_table_by_address(char *ascii_address) ...@@ -288,22 +288,22 @@ int ap_dump_table_by_address(char *ascii_address)
status = acpi_ut_strtoul64(ascii_address, 0, &long_address); status = acpi_ut_strtoul64(ascii_address, 0, &long_address);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
fprintf(stderr, "%s: Could not convert to a physical address\n", acpi_log_error("%s: Could not convert to a physical address\n",
ascii_address); ascii_address);
return (-1); return (-1);
} }
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)) {
fprintf(stderr, "Could not get table at 0x%8.8X%8.8X, %s\n", acpi_log_error("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);
} }
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,24 +329,24 @@ int ap_dump_table_by_name(char *signature) ...@@ -329,24 +329,24 @@ 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, acpi_log_error
"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);
} }
/* 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) */
...@@ -362,14 +362,14 @@ int ap_dump_table_by_name(char *signature) ...@@ -362,14 +362,14 @@ int ap_dump_table_by_name(char *signature)
return (0); return (0);
} }
fprintf(stderr, acpi_log_error
"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);
} }
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;
...@@ -409,43 +409,21 @@ int ap_dump_table_from_file(char *pathname) ...@@ -409,43 +409,21 @@ int ap_dump_table_from_file(char *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) {
fprintf(stderr, acpi_log_error
"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) {
fprintf(stderr, acpi_log_error
"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);
} }
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);
} }
/******************************************************************************
*
* FUNCTION: acpi_os* print functions
*
* DESCRIPTION: Used for linkage with ACPICA modules
*
******************************************************************************/
void ACPI_INTERNAL_VAR_XFACE acpi_os_printf(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
vfprintf(stdout, fmt, args);
va_end(args);
}
void acpi_os_vprintf(const char *fmt, va_list args)
{
vfprintf(stdout, fmt, args);
}
...@@ -44,6 +44,27 @@ ...@@ -44,6 +44,27 @@
#include "acpidump.h" #include "acpidump.h"
#include "acapps.h" #include "acapps.h"
/* Local prototypes */
static int ap_is_existing_file(char *pathname);
static int ap_is_existing_file(char *pathname)
{
#ifndef _GNU_EFI
struct stat stat_info;
if (!stat(pathname, &stat_info)) {
acpi_log_error("Target path already exists, overwrite? [y|n] ");
if (getchar() != 'y') {
return (-1);
}
}
#endif
return 0;
}
/****************************************************************************** /******************************************************************************
* *
* FUNCTION: ap_open_output_file * FUNCTION: ap_open_output_file
...@@ -59,25 +80,19 @@ ...@@ -59,25 +80,19 @@
int ap_open_output_file(char *pathname) int ap_open_output_file(char *pathname)
{ {
struct stat stat_info; ACPI_FILE file;
FILE *file;
/* If file exists, prompt for overwrite */ /* If file exists, prompt for overwrite */
if (!stat(pathname, &stat_info)) { if (ap_is_existing_file(pathname) != 0) {
fprintf(stderr, return (-1);
"Target path already exists, overwrite? [y|n] ");
if (getchar() != 'y') {
return (-1);
}
} }
/* Point stdout to the file */ /* Point stdout to the file */
file = freopen(pathname, "w", stdout); file = acpi_os_open_file(pathname, ACPI_FILE_WRITING);
if (!file) { if (!file) {
perror("Could not open output file"); acpi_log_error("Could not open output file: %s\n", pathname);
return (-1); return (-1);
} }
...@@ -106,7 +121,7 @@ int ap_write_to_binary_file(struct acpi_table_header *table, u32 instance) ...@@ -106,7 +121,7 @@ int ap_write_to_binary_file(struct acpi_table_header *table, u32 instance)
{ {
char filename[ACPI_NAME_SIZE + 16]; char filename[ACPI_NAME_SIZE + 16];
char instance_str[16]; char instance_str[16];
FILE *file; ACPI_FILE file;
size_t actual; size_t actual;
u32 table_length; u32 table_length;
...@@ -130,35 +145,37 @@ int ap_write_to_binary_file(struct acpi_table_header *table, u32 instance) ...@@ -130,35 +145,37 @@ 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, acpi_log_error
"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->signature, filename, table->length, 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 = fopen(filename, "wb"); file = acpi_os_open_file(filename,
ACPI_FILE_WRITING | ACPI_FILE_BINARY);
if (!file) { if (!file) {
perror("Could not open output file"); acpi_log_error("Could not open output file: %s\n", filename);
return (-1); return (-1);
} }
actual = fwrite(table, 1, table_length, file); actual = acpi_os_write_file(file, table, 1, table_length);
if (actual != table_length) { if (actual != table_length) {
perror("Error writing binary output file"); acpi_log_error("Error writing binary output file: %s\n",
fclose(file); filename);
acpi_os_close_file(file);
return (-1); return (-1);
} }
fclose(file); acpi_os_close_file(file);
return (0); return (0);
} }
...@@ -179,15 +196,16 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname, ...@@ -179,15 +196,16 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname,
u32 *out_file_size) u32 *out_file_size)
{ {
struct acpi_table_header *buffer = NULL; struct acpi_table_header *buffer = NULL;
FILE *file; ACPI_FILE file;
u32 file_size; u32 file_size;
size_t actual; size_t actual;
/* Must use binary mode */ /* Must use binary mode */
file = fopen(pathname, "rb"); file =
acpi_os_open_file(pathname, ACPI_FILE_READING | ACPI_FILE_BINARY);
if (!file) { if (!file) {
perror("Could not open input file"); acpi_log_error("Could not open input file: %s\n", pathname);
return (NULL); return (NULL);
} }
...@@ -195,27 +213,25 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname, ...@@ -195,27 +213,25 @@ 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) {
fprintf(stderr, acpi_log_error("Could not get input file size: %s\n", pathname);
"Could not get input file size: %s\n", pathname);
goto cleanup; goto cleanup;
} }
/* 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, acpi_log_error("Could not allocate file buffer of size: %u\n",
"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 = fread(buffer, 1, file_size, file); actual = acpi_os_read_file(file, buffer, 1, file_size);
if (actual != file_size) { if (actual != file_size) {
fprintf(stderr, "Could not read input file: %s\n", pathname); acpi_log_error("Could not read input file: %s\n", pathname);
free(buffer); ACPI_FREE(buffer);
buffer = NULL; buffer = NULL;
goto cleanup; goto cleanup;
} }
...@@ -223,6 +239,6 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname, ...@@ -223,6 +239,6 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname,
*out_file_size = file_size; *out_file_size = file_size;
cleanup: cleanup:
fclose(file); acpi_os_close_file(file);
return (buffer); return (buffer);
} }
...@@ -72,7 +72,7 @@ static void ap_display_usage(void); ...@@ -72,7 +72,7 @@ static void ap_display_usage(void);
static int ap_do_options(int argc, char **argv); static int ap_do_options(int argc, char **argv);
static void ap_insert_action(char *argument, u32 to_be_done); static int ap_insert_action(char *argument, u32 to_be_done);
/* Table for deferred actions from command line options */ /* Table for deferred actions from command line options */
...@@ -104,7 +104,7 @@ static void ap_display_usage(void) ...@@ -104,7 +104,7 @@ static void ap_display_usage(void)
ACPI_OPTION("-v", "Display version information"); ACPI_OPTION("-v", "Display version information");
ACPI_OPTION("-z", "Verbose mode"); ACPI_OPTION("-z", "Verbose mode");
printf("\nTable Options:\n"); ACPI_USAGE_TEXT("\nTable Options:\n");
ACPI_OPTION("-a <Address>", "Get table via a physical address"); ACPI_OPTION("-a <Address>", "Get table via a physical address");
ACPI_OPTION("-f <BinaryFile>", "Get table via a binary file"); ACPI_OPTION("-f <BinaryFile>", "Get table via a binary file");
...@@ -112,9 +112,9 @@ static void ap_display_usage(void) ...@@ -112,9 +112,9 @@ static void ap_display_usage(void)
ACPI_OPTION("-x", "Do not use but dump XSDT"); ACPI_OPTION("-x", "Do not use but dump XSDT");
ACPI_OPTION("-x -x", "Do not use or dump XSDT"); ACPI_OPTION("-x -x", "Do not use or dump XSDT");
printf("\n" ACPI_USAGE_TEXT("\n"
"Invocation without parameters dumps all available tables\n" "Invocation without parameters dumps all available tables\n"
"Multiple mixed instances of -a, -f, and -n are supported\n\n"); "Multiple mixed instances of -a, -f, and -n are supported\n\n");
} }
/****************************************************************************** /******************************************************************************
...@@ -124,13 +124,13 @@ static void ap_display_usage(void) ...@@ -124,13 +124,13 @@ static void ap_display_usage(void)
* PARAMETERS: argument - Pointer to the argument for this action * PARAMETERS: argument - Pointer to the argument for this action
* to_be_done - What to do to process this action * to_be_done - What to do to process this action
* *
* RETURN: None. Exits program if action table becomes full. * RETURN: Status
* *
* DESCRIPTION: Add an action item to the action table * DESCRIPTION: Add an action item to the action table
* *
******************************************************************************/ ******************************************************************************/
static void ap_insert_action(char *argument, u32 to_be_done) static int ap_insert_action(char *argument, u32 to_be_done)
{ {
/* Insert action and check for table overflow */ /* Insert action and check for table overflow */
...@@ -140,10 +140,12 @@ static void ap_insert_action(char *argument, u32 to_be_done) ...@@ -140,10 +140,12 @@ static void 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) {
fprintf(stderr, "Too many table options (max %u)\n", acpi_log_error("Too many table options (max %u)\n",
AP_MAX_ACTIONS); AP_MAX_ACTIONS);
exit(-1); return (-1);
} }
return (0);
} }
/****************************************************************************** /******************************************************************************
...@@ -166,7 +168,8 @@ static int ap_do_options(int argc, char **argv) ...@@ -166,7 +168,8 @@ static int ap_do_options(int argc, char **argv)
/* Command line options */ /* Command line options */
while ((j = acpi_getopt(argc, argv, AP_SUPPORTED_OPTIONS)) != EOF) while ((j =
acpi_getopt(argc, argv, AP_SUPPORTED_OPTIONS)) != ACPI_OPT_END)
switch (j) { switch (j) {
/* /*
* Global options * Global options
...@@ -185,12 +188,12 @@ static int ap_do_options(int argc, char **argv) ...@@ -185,12 +188,12 @@ static int ap_do_options(int argc, char **argv)
case '?': case '?':
ap_display_usage(); ap_display_usage();
exit(0); return (1);
case 'o': /* Redirect output to a single file */ case 'o': /* Redirect output to a single file */
if (ap_open_output_file(acpi_gbl_optarg)) { if (ap_open_output_file(acpi_gbl_optarg)) {
exit(-1); return (-1);
} }
continue; continue;
...@@ -200,10 +203,10 @@ static int ap_do_options(int argc, char **argv) ...@@ -200,10 +203,10 @@ static int ap_do_options(int argc, char **argv)
acpi_ut_strtoul64(acpi_gbl_optarg, 0, acpi_ut_strtoul64(acpi_gbl_optarg, 0,
&gbl_rsdp_base); &gbl_rsdp_base);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
fprintf(stderr, acpi_log_error
"%s: Could not convert to a physical address\n", ("%s: Could not convert to a physical address\n",
acpi_gbl_optarg); acpi_gbl_optarg);
exit(-1); return (-1);
} }
continue; continue;
...@@ -223,13 +226,13 @@ static int ap_do_options(int argc, char **argv) ...@@ -223,13 +226,13 @@ static int ap_do_options(int argc, char **argv)
case 'v': /* Revision/version */ case 'v': /* Revision/version */
printf(ACPI_COMMON_SIGNON(AP_UTILITY_NAME)); acpi_os_printf(ACPI_COMMON_SIGNON(AP_UTILITY_NAME));
exit(0); return (1);
case 'z': /* Verbose mode */ case 'z': /* Verbose mode */
gbl_verbose_mode = TRUE; gbl_verbose_mode = TRUE;
fprintf(stderr, ACPI_COMMON_SIGNON(AP_UTILITY_NAME)); acpi_log_error(ACPI_COMMON_SIGNON(AP_UTILITY_NAME));
continue; continue;
/* /*
...@@ -237,32 +240,40 @@ static int ap_do_options(int argc, char **argv) ...@@ -237,32 +240,40 @@ static int ap_do_options(int argc, char **argv)
*/ */
case 'a': /* Get table by physical address */ case 'a': /* Get table by physical address */
ap_insert_action(acpi_gbl_optarg, if (ap_insert_action
AP_DUMP_TABLE_BY_ADDRESS); (acpi_gbl_optarg, AP_DUMP_TABLE_BY_ADDRESS)) {
return (-1);
}
break; break;
case 'f': /* Get table from a file */ case 'f': /* Get table from a file */
ap_insert_action(acpi_gbl_optarg, if (ap_insert_action
AP_DUMP_TABLE_BY_FILE); (acpi_gbl_optarg, AP_DUMP_TABLE_BY_FILE)) {
return (-1);
}
break; break;
case 'n': /* Get table by input name (signature) */ case 'n': /* Get table by input name (signature) */
ap_insert_action(acpi_gbl_optarg, if (ap_insert_action
AP_DUMP_TABLE_BY_NAME); (acpi_gbl_optarg, AP_DUMP_TABLE_BY_NAME)) {
return (-1);
}
break; break;
default: default:
ap_display_usage(); ap_display_usage();
exit(-1); return (-1);
} }
/* If there are no actions, this means "get/dump all tables" */ /* If there are no actions, this means "get/dump all tables" */
if (current_action == 0) { if (current_action == 0) {
ap_insert_action(NULL, AP_DUMP_ALL_TABLES); if (ap_insert_action(NULL, AP_DUMP_ALL_TABLES)) {
return (-1);
}
} }
return (0); return (0);
...@@ -280,7 +291,11 @@ static int ap_do_options(int argc, char **argv) ...@@ -280,7 +291,11 @@ static int ap_do_options(int argc, char **argv)
* *
******************************************************************************/ ******************************************************************************/
#ifndef _GNU_EFI
int ACPI_SYSTEM_XFACE main(int argc, char *argv[]) int ACPI_SYSTEM_XFACE main(int argc, char *argv[])
#else
int ACPI_SYSTEM_XFACE acpi_main(int argc, char *argv[])
#endif
{ {
int status = 0; int status = 0;
struct ap_dump_action *action; struct ap_dump_action *action;
...@@ -288,11 +303,17 @@ int ACPI_SYSTEM_XFACE main(int argc, char *argv[]) ...@@ -288,11 +303,17 @@ int ACPI_SYSTEM_XFACE main(int argc, char *argv[])
u32 i; u32 i;
ACPI_DEBUG_INITIALIZE(); /* For debug version only */ ACPI_DEBUG_INITIALIZE(); /* For debug version only */
acpi_os_initialize();
gbl_output_file = ACPI_FILE_OUT;
/* Process command line options */ /* Process command line options */
if (ap_do_options(argc, argv)) { status = ap_do_options(argc, argv);
return (-1); if (status > 0) {
return (0);
}
if (status < 0) {
return (status);
} }
/* Get/dump ACPI table(s) as requested */ /* Get/dump ACPI table(s) as requested */
...@@ -322,9 +343,8 @@ int ACPI_SYSTEM_XFACE main(int argc, char *argv[]) ...@@ -322,9 +343,8 @@ int ACPI_SYSTEM_XFACE main(int argc, char *argv[])
default: default:
fprintf(stderr, acpi_log_error("Internal error, invalid action: 0x%X\n",
"Internal error, invalid action: 0x%X\n", action->to_be_done);
action->to_be_done);
return (-1); return (-1);
} }
...@@ -333,18 +353,18 @@ int ACPI_SYSTEM_XFACE main(int argc, char *argv[]) ...@@ -333,18 +353,18 @@ int ACPI_SYSTEM_XFACE main(int argc, char *argv[])
} }
} }
if (gbl_output_file) { if (gbl_output_filename) {
if (gbl_verbose_mode) { if (gbl_verbose_mode) {
/* 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);
fprintf(stderr, acpi_log_error
"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);
} }
fclose(gbl_output_file); acpi_os_close_file(gbl_output_file);
} }
return (status); return (status);
......
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