diff options
38 files changed, 3340 insertions, 404 deletions
diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c index 185334114d71..340d09518f8e 100644 --- a/drivers/acpi/acpi_extlog.c +++ b/drivers/acpi/acpi_extlog.c | |||
@@ -69,11 +69,11 @@ static u32 l1_percpu_entry; | |||
69 | #define ELOG_ENTRY_ADDR(phyaddr) \ | 69 | #define ELOG_ENTRY_ADDR(phyaddr) \ |
70 | (phyaddr - elog_base + (u8 *)elog_addr) | 70 | (phyaddr - elog_base + (u8 *)elog_addr) |
71 | 71 | ||
72 | static struct acpi_generic_status *extlog_elog_entry_check(int cpu, int bank) | 72 | static struct acpi_hest_generic_status *extlog_elog_entry_check(int cpu, int bank) |
73 | { | 73 | { |
74 | int idx; | 74 | int idx; |
75 | u64 data; | 75 | u64 data; |
76 | struct acpi_generic_status *estatus; | 76 | struct acpi_hest_generic_status *estatus; |
77 | 77 | ||
78 | WARN_ON(cpu < 0); | 78 | WARN_ON(cpu < 0); |
79 | idx = ELOG_IDX(cpu, bank); | 79 | idx = ELOG_IDX(cpu, bank); |
@@ -82,7 +82,7 @@ static struct acpi_generic_status *extlog_elog_entry_check(int cpu, int bank) | |||
82 | return NULL; | 82 | return NULL; |
83 | 83 | ||
84 | data &= EXT_ELOG_ENTRY_MASK; | 84 | data &= EXT_ELOG_ENTRY_MASK; |
85 | estatus = (struct acpi_generic_status *)ELOG_ENTRY_ADDR(data); | 85 | estatus = (struct acpi_hest_generic_status *)ELOG_ENTRY_ADDR(data); |
86 | 86 | ||
87 | /* if no valid data in elog entry, just return */ | 87 | /* if no valid data in elog entry, just return */ |
88 | if (estatus->block_status == 0) | 88 | if (estatus->block_status == 0) |
@@ -92,7 +92,7 @@ static struct acpi_generic_status *extlog_elog_entry_check(int cpu, int bank) | |||
92 | } | 92 | } |
93 | 93 | ||
94 | static void __print_extlog_rcd(const char *pfx, | 94 | static void __print_extlog_rcd(const char *pfx, |
95 | struct acpi_generic_status *estatus, int cpu) | 95 | struct acpi_hest_generic_status *estatus, int cpu) |
96 | { | 96 | { |
97 | static atomic_t seqno; | 97 | static atomic_t seqno; |
98 | unsigned int curr_seqno; | 98 | unsigned int curr_seqno; |
@@ -111,7 +111,7 @@ static void __print_extlog_rcd(const char *pfx, | |||
111 | } | 111 | } |
112 | 112 | ||
113 | static int print_extlog_rcd(const char *pfx, | 113 | static int print_extlog_rcd(const char *pfx, |
114 | struct acpi_generic_status *estatus, int cpu) | 114 | struct acpi_hest_generic_status *estatus, int cpu) |
115 | { | 115 | { |
116 | /* Not more than 2 messages every 5 seconds */ | 116 | /* Not more than 2 messages every 5 seconds */ |
117 | static DEFINE_RATELIMIT_STATE(ratelimit_corrected, 5*HZ, 2); | 117 | 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 | struct mce *mce = (struct mce *)data; | 137 | struct mce *mce = (struct mce *)data; |
138 | int bank = mce->bank; | 138 | int bank = mce->bank; |
139 | int cpu = mce->extcpu; | 139 | int cpu = mce->extcpu; |
140 | struct acpi_generic_status *estatus; | 140 | struct acpi_hest_generic_status *estatus; |
141 | int rc; | 141 | int rc; |
142 | 142 | ||
143 | estatus = extlog_elog_entry_check(cpu, bank); | 143 | estatus = extlog_elog_entry_check(cpu, bank); |
@@ -148,7 +148,7 @@ static int extlog_print(struct notifier_block *nb, unsigned long val, | |||
148 | /* clear record status to enable BIOS to update it again */ | 148 | /* clear record status to enable BIOS to update it again */ |
149 | estatus->block_status = 0; | 149 | estatus->block_status = 0; |
150 | 150 | ||
151 | rc = print_extlog_rcd(NULL, (struct acpi_generic_status *)elog_buf, cpu); | 151 | rc = print_extlog_rcd(NULL, (struct acpi_hest_generic_status *)elog_buf, cpu); |
152 | 152 | ||
153 | return NOTIFY_STOP; | 153 | return NOTIFY_STOP; |
154 | } | 154 | } |
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile index 8bb43f06e11f..6b9ec239d578 100644 --- a/drivers/acpi/acpica/Makefile +++ b/drivers/acpi/acpica/Makefile | |||
@@ -175,5 +175,5 @@ acpi-y += \ | |||
175 | utxferror.o \ | 175 | utxferror.o \ |
176 | utxfmutex.o | 176 | utxfmutex.o |
177 | 177 | ||
178 | acpi-$(ACPI_FUTURE_USAGE) += uttrack.o utcache.o | 178 | acpi-$(ACPI_FUTURE_USAGE) += utfileio.o utprint.o uttrack.o utcache.o |
179 | 179 | ||
diff --git a/drivers/acpi/acpica/acapps.h b/drivers/acpi/acpica/acapps.h index 8698ffba6f39..3d2c88289da9 100644 --- a/drivers/acpi/acpica/acapps.h +++ b/drivers/acpi/acpica/acapps.h | |||
@@ -79,10 +79,13 @@ | |||
79 | /* Macros for usage messages */ | 79 | /* Macros for usage messages */ |
80 | 80 | ||
81 | #define ACPI_USAGE_HEADER(usage) \ | 81 | #define ACPI_USAGE_HEADER(usage) \ |
82 | printf ("Usage: %s\nOptions:\n", usage); | 82 | acpi_os_printf ("Usage: %s\nOptions:\n", usage); |
83 | |||
84 | #define ACPI_USAGE_TEXT(description) \ | ||
85 | acpi_os_printf (description); | ||
83 | 86 | ||
84 | #define ACPI_OPTION(name, description) \ | 87 | #define ACPI_OPTION(name, description) \ |
85 | printf (" %-18s%s\n", name, description); | 88 | acpi_os_printf (" %-18s%s\n", name, description); |
86 | 89 | ||
87 | #define FILE_SUFFIX_DISASSEMBLY "dsl" | 90 | #define FILE_SUFFIX_DISASSEMBLY "dsl" |
88 | #define ACPI_TABLE_FILE_SUFFIX ".dat" | 91 | #define ACPI_TABLE_FILE_SUFFIX ".dat" |
@@ -102,7 +105,7 @@ extern char *acpi_gbl_optarg; | |||
102 | /* | 105 | /* |
103 | * cmfsize - Common get file size function | 106 | * cmfsize - Common get file size function |
104 | */ | 107 | */ |
105 | u32 cm_get_file_size(FILE * file); | 108 | u32 cm_get_file_size(ACPI_FILE file); |
106 | 109 | ||
107 | #ifndef ACPI_DUMP_APP | 110 | #ifndef ACPI_DUMP_APP |
108 | /* | 111 | /* |
diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h index 68a91eb0fa48..1d026ff1683f 100644 --- a/drivers/acpi/acpica/acdebug.h +++ b/drivers/acpi/acpica/acdebug.h | |||
@@ -233,9 +233,6 @@ acpi_status acpi_db_load_acpi_table(char *filename); | |||
233 | acpi_status | 233 | acpi_status |
234 | acpi_db_get_table_from_file(char *filename, struct acpi_table_header **table); | 234 | acpi_db_get_table_from_file(char *filename, struct acpi_table_header **table); |
235 | 235 | ||
236 | acpi_status | ||
237 | acpi_db_read_table_from_file(char *filename, struct acpi_table_header **table); | ||
238 | |||
239 | /* | 236 | /* |
240 | * dbhistry - debugger HISTORY command | 237 | * dbhistry - debugger HISTORY command |
241 | */ | 238 | */ |
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h index 115eedcade1e..ebf02cc10a43 100644 --- a/drivers/acpi/acpica/acglobal.h +++ b/drivers/acpi/acpica/acglobal.h | |||
@@ -297,7 +297,7 @@ ACPI_GLOBAL(u32, acpi_gbl_trace_dbg_layer); | |||
297 | * | 297 | * |
298 | ****************************************************************************/ | 298 | ****************************************************************************/ |
299 | 299 | ||
300 | ACPI_GLOBAL(u8, acpi_gbl_db_output_flags); | 300 | ACPI_INIT_GLOBAL(u8, acpi_gbl_db_output_flags, ACPI_DB_CONSOLE_OUTPUT); |
301 | 301 | ||
302 | #ifdef ACPI_DISASSEMBLER | 302 | #ifdef ACPI_DISASSEMBLER |
303 | 303 | ||
@@ -362,6 +362,12 @@ ACPI_GLOBAL(u32, acpi_gbl_num_objects); | |||
362 | #ifdef ACPI_APPLICATION | 362 | #ifdef ACPI_APPLICATION |
363 | 363 | ||
364 | ACPI_INIT_GLOBAL(ACPI_FILE, acpi_gbl_debug_file, NULL); | 364 | ACPI_INIT_GLOBAL(ACPI_FILE, acpi_gbl_debug_file, NULL); |
365 | ACPI_INIT_GLOBAL(ACPI_FILE, acpi_gbl_output_file, NULL); | ||
366 | |||
367 | /* Print buffer */ | ||
368 | |||
369 | ACPI_GLOBAL(acpi_spinlock, acpi_gbl_print_lock); /* For print buffer */ | ||
370 | ACPI_GLOBAL(char, acpi_gbl_print_buffer[1024]); | ||
365 | 371 | ||
366 | #endif /* ACPI_APPLICATION */ | 372 | #endif /* ACPI_APPLICATION */ |
367 | 373 | ||
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h index 1e256c5bda20..ed614f4b2182 100644 --- a/drivers/acpi/acpica/acutils.h +++ b/drivers/acpi/acpica/acutils.h | |||
@@ -95,7 +95,6 @@ extern const char *acpi_gbl_pt_decode[]; | |||
95 | #ifdef ACPI_ASL_COMPILER | 95 | #ifdef ACPI_ASL_COMPILER |
96 | 96 | ||
97 | #include <stdio.h> | 97 | #include <stdio.h> |
98 | extern FILE *acpi_gbl_output_file; | ||
99 | 98 | ||
100 | #define ACPI_MSG_REDIRECT_BEGIN \ | 99 | #define ACPI_MSG_REDIRECT_BEGIN \ |
101 | FILE *output_file = acpi_gbl_output_file; \ | 100 | FILE *output_file = acpi_gbl_output_file; \ |
@@ -211,6 +210,8 @@ void acpi_ut_subsystem_shutdown(void); | |||
211 | 210 | ||
212 | acpi_size acpi_ut_strlen(const char *string); | 211 | acpi_size acpi_ut_strlen(const char *string); |
213 | 212 | ||
213 | char *acpi_ut_strchr(const char *string, int ch); | ||
214 | |||
214 | char *acpi_ut_strcpy(char *dst_string, const char *src_string); | 215 | char *acpi_ut_strcpy(char *dst_string, const char *src_string); |
215 | 216 | ||
216 | char *acpi_ut_strncpy(char *dst_string, | 217 | char *acpi_ut_strncpy(char *dst_string, |
@@ -257,7 +258,7 @@ extern const u8 _acpi_ctype[]; | |||
257 | #define ACPI_IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD)) | 258 | #define ACPI_IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD)) |
258 | #define ACPI_IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP)) | 259 | #define ACPI_IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP)) |
259 | #define ACPI_IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO)) | 260 | #define ACPI_IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO)) |
260 | #define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_SP | _ACPI_PU)) | 261 | #define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_XS | _ACPI_PU)) |
261 | #define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP)) | 262 | #define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP)) |
262 | 263 | ||
263 | #endif /* !ACPI_USE_SYSTEM_CLIBRARY */ | 264 | #endif /* !ACPI_USE_SYSTEM_CLIBRARY */ |
@@ -352,6 +353,13 @@ acpi_ut_debug_dump_buffer(u8 *buffer, u32 count, u32 display, u32 component_id); | |||
352 | 353 | ||
353 | void acpi_ut_dump_buffer(u8 *buffer, u32 count, u32 display, u32 offset); | 354 | void acpi_ut_dump_buffer(u8 *buffer, u32 count, u32 display, u32 offset); |
354 | 355 | ||
356 | #ifdef ACPI_APPLICATION | ||
357 | void | ||
358 | acpi_ut_dump_buffer_to_file(ACPI_FILE file, | ||
359 | u8 *buffer, | ||
360 | u32 count, u32 display, u32 base_offset); | ||
361 | #endif | ||
362 | |||
355 | void acpi_ut_report_error(char *module_name, u32 line_number); | 363 | void acpi_ut_report_error(char *module_name, u32 line_number); |
356 | 364 | ||
357 | void acpi_ut_report_info(char *module_name, u32 line_number); | 365 | void acpi_ut_report_info(char *module_name, u32 line_number); |
@@ -394,6 +402,14 @@ acpi_ut_execute_power_methods(struct acpi_namespace_node *device_node, | |||
394 | u8 method_count, u8 *out_values); | 402 | u8 method_count, u8 *out_values); |
395 | 403 | ||
396 | /* | 404 | /* |
405 | * utfileio - file operations | ||
406 | */ | ||
407 | #ifdef ACPI_APPLICATION | ||
408 | acpi_status | ||
409 | acpi_ut_read_table_from_file(char *filename, struct acpi_table_header **table); | ||
410 | #endif | ||
411 | |||
412 | /* | ||
397 | * utids - device ID support | 413 | * utids - device ID support |
398 | */ | 414 | */ |
399 | acpi_status | 415 | acpi_status |
@@ -743,4 +759,23 @@ const struct ah_predefined_name *acpi_ah_match_predefined_name(char *nameseg); | |||
743 | 759 | ||
744 | const struct ah_device_id *acpi_ah_match_hardware_id(char *hid); | 760 | const struct ah_device_id *acpi_ah_match_hardware_id(char *hid); |
745 | 761 | ||
762 | /* | ||
763 | * utprint - printf/vprintf output functions | ||
764 | */ | ||
765 | const char *acpi_ut_scan_number(const char *string, u64 *number_ptr); | ||
766 | |||
767 | const char *acpi_ut_print_number(char *string, u64 number); | ||
768 | |||
769 | int | ||
770 | acpi_ut_vsnprintf(char *string, | ||
771 | acpi_size size, const char *format, va_list args); | ||
772 | |||
773 | int acpi_ut_snprintf(char *string, acpi_size size, const char *format, ...); | ||
774 | |||
775 | #ifdef ACPI_APPLICATION | ||
776 | int acpi_ut_file_vprintf(ACPI_FILE file, const char *format, va_list args); | ||
777 | |||
778 | int acpi_ut_file_printf(ACPI_FILE file, const char *format, ...); | ||
779 | #endif | ||
780 | |||
746 | #endif /* _ACUTILS_H */ | 781 | #endif /* _ACUTILS_H */ |
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c index 48f70013b488..e4ba4dec86af 100644 --- a/drivers/acpi/acpica/evgpe.c +++ b/drivers/acpi/acpica/evgpe.c | |||
@@ -698,21 +698,6 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device, | |||
698 | } | 698 | } |
699 | 699 | ||
700 | /* | 700 | /* |
701 | * If edge-triggered, clear the GPE status bit now. Note that | ||
702 | * level-triggered events are cleared after the GPE is serviced. | ||
703 | */ | ||
704 | if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == | ||
705 | ACPI_GPE_EDGE_TRIGGERED) { | ||
706 | status = acpi_hw_clear_gpe(gpe_event_info); | ||
707 | if (ACPI_FAILURE(status)) { | ||
708 | ACPI_EXCEPTION((AE_INFO, status, | ||
709 | "Unable to clear GPE %02X", | ||
710 | gpe_number)); | ||
711 | return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); | ||
712 | } | ||
713 | } | ||
714 | |||
715 | /* | ||
716 | * Always disable the GPE so that it does not keep firing before | 701 | * Always disable the GPE so that it does not keep firing before |
717 | * any asynchronous activity completes (either from the execution | 702 | * any asynchronous activity completes (either from the execution |
718 | * of a GPE method or an asynchronous GPE handler.) | 703 | * of a GPE method or an asynchronous GPE handler.) |
@@ -729,6 +714,23 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device, | |||
729 | } | 714 | } |
730 | 715 | ||
731 | /* | 716 | /* |
717 | * If edge-triggered, clear the GPE status bit now. Note that | ||
718 | * level-triggered events are cleared after the GPE is serviced. | ||
719 | */ | ||
720 | if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == | ||
721 | ACPI_GPE_EDGE_TRIGGERED) { | ||
722 | status = acpi_hw_clear_gpe(gpe_event_info); | ||
723 | if (ACPI_FAILURE(status)) { | ||
724 | ACPI_EXCEPTION((AE_INFO, status, | ||
725 | "Unable to clear GPE %02X", | ||
726 | gpe_number)); | ||
727 | (void)acpi_hw_low_set_gpe(gpe_event_info, | ||
728 | ACPI_GPE_CONDITIONAL_ENABLE); | ||
729 | return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); | ||
730 | } | ||
731 | } | ||
732 | |||
733 | /* | ||
732 | * Dispatch the GPE to either an installed handler or the control | 734 | * Dispatch the GPE to either an installed handler or the control |
733 | * method associated with this GPE (_Lxx or _Exx). If a handler | 735 | * method associated with this GPE (_Lxx or _Exx). If a handler |
734 | * exists, we invoke it and do not attempt to run the method. | 736 | * exists, we invoke it and do not attempt to run the method. |
diff --git a/drivers/acpi/acpica/evxfgpe.c b/drivers/acpi/acpica/evxfgpe.c index cb534faf5369..0cf159cc6e6d 100644 --- a/drivers/acpi/acpica/evxfgpe.c +++ b/drivers/acpi/acpica/evxfgpe.c | |||
@@ -126,11 +126,19 @@ acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number) | |||
126 | 126 | ||
127 | flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); | 127 | flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); |
128 | 128 | ||
129 | /* Ensure that we have a valid GPE number */ | 129 | /* |
130 | 130 | * Ensure that we have a valid GPE number and that there is some way | |
131 | * of handling the GPE (handler or a GPE method). In other words, we | ||
132 | * won't allow a valid GPE to be enabled if there is no way to handle it. | ||
133 | */ | ||
131 | gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); | 134 | gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); |
132 | if (gpe_event_info) { | 135 | if (gpe_event_info) { |
133 | status = acpi_ev_add_gpe_reference(gpe_event_info); | 136 | if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) != |
137 | ACPI_GPE_DISPATCH_NONE) { | ||
138 | status = acpi_ev_add_gpe_reference(gpe_event_info); | ||
139 | } else { | ||
140 | status = AE_NO_HANDLER; | ||
141 | } | ||
134 | } | 142 | } |
135 | 143 | ||
136 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); | 144 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); |
@@ -179,6 +187,53 @@ ACPI_EXPORT_SYMBOL(acpi_disable_gpe) | |||
179 | 187 | ||
180 | /******************************************************************************* | 188 | /******************************************************************************* |
181 | * | 189 | * |
190 | * FUNCTION: acpi_mark_gpe_for_wake | ||
191 | * | ||
192 | * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1 | ||
193 | * gpe_number - GPE level within the GPE block | ||
194 | * | ||
195 | * RETURN: Status | ||
196 | * | ||
197 | * DESCRIPTION: Mark a GPE as having the ability to wake the system. Simply | ||
198 | * sets the ACPI_GPE_CAN_WAKE flag. | ||
199 | * | ||
200 | * Some potential callers of acpi_setup_gpe_for_wake may know in advance that | ||
201 | * there won't be any notify handlers installed for device wake notifications | ||
202 | * from the given GPE (one example is a button GPE in Linux). For these cases, | ||
203 | * acpi_mark_gpe_for_wake should be used instead of acpi_setup_gpe_for_wake. | ||
204 | * This will set the ACPI_GPE_CAN_WAKE flag for the GPE without trying to | ||
205 | * setup implicit wake notification for it (since there's no handler method). | ||
206 | * | ||
207 | ******************************************************************************/ | ||
208 | acpi_status acpi_mark_gpe_for_wake(acpi_handle gpe_device, u32 gpe_number) | ||
209 | { | ||
210 | struct acpi_gpe_event_info *gpe_event_info; | ||
211 | acpi_status status = AE_BAD_PARAMETER; | ||
212 | acpi_cpu_flags flags; | ||
213 | |||
214 | ACPI_FUNCTION_TRACE(acpi_mark_gpe_for_wake); | ||
215 | |||
216 | flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); | ||
217 | |||
218 | /* Ensure that we have a valid GPE number */ | ||
219 | |||
220 | gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); | ||
221 | if (gpe_event_info) { | ||
222 | |||
223 | /* Mark the GPE as a possible wake event */ | ||
224 | |||
225 | gpe_event_info->flags |= ACPI_GPE_CAN_WAKE; | ||
226 | status = AE_OK; | ||
227 | } | ||
228 | |||
229 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); | ||
230 | return_ACPI_STATUS(status); | ||
231 | } | ||
232 | |||
233 | ACPI_EXPORT_SYMBOL(acpi_mark_gpe_for_wake) | ||
234 | |||
235 | /******************************************************************************* | ||
236 | * | ||
182 | * FUNCTION: acpi_setup_gpe_for_wake | 237 | * FUNCTION: acpi_setup_gpe_for_wake |
183 | * | 238 | * |
184 | * PARAMETERS: wake_device - Device associated with the GPE (via _PRW) | 239 | * PARAMETERS: wake_device - Device associated with the GPE (via _PRW) |
diff --git a/drivers/acpi/acpica/exfield.c b/drivers/acpi/acpica/exfield.c index 12878e1982f7..1ff42c07b42b 100644 --- a/drivers/acpi/acpica/exfield.c +++ b/drivers/acpi/acpica/exfield.c | |||
@@ -56,7 +56,7 @@ acpi_ex_get_serial_access_length(u32 accessor_type, u32 access_length); | |||
56 | 56 | ||
57 | /******************************************************************************* | 57 | /******************************************************************************* |
58 | * | 58 | * |
59 | * FUNCTION: acpi_get_serial_access_bytes | 59 | * FUNCTION: acpi_ex_get_serial_access_length |
60 | * | 60 | * |
61 | * PARAMETERS: accessor_type - The type of the protocol indicated by region | 61 | * PARAMETERS: accessor_type - The type of the protocol indicated by region |
62 | * field access attributes | 62 | * field access attributes |
@@ -103,7 +103,7 @@ acpi_ex_get_serial_access_length(u32 accessor_type, u32 access_length) | |||
103 | case AML_FIELD_ATTRIB_BLOCK_CALL: | 103 | case AML_FIELD_ATTRIB_BLOCK_CALL: |
104 | default: | 104 | default: |
105 | 105 | ||
106 | length = ACPI_GSBUS_BUFFER_SIZE; | 106 | length = ACPI_GSBUS_BUFFER_SIZE - 2; |
107 | break; | 107 | break; |
108 | } | 108 | } |
109 | 109 | ||
diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c index e0fd9b4978cd..a4c34d2c556b 100644 --- a/drivers/acpi/acpica/hwregs.c +++ b/drivers/acpi/acpica/hwregs.c | |||
@@ -278,8 +278,9 @@ acpi_status acpi_hw_clear_acpi_status(void) | |||
278 | 278 | ||
279 | acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags); | 279 | acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags); |
280 | 280 | ||
281 | if (ACPI_FAILURE(status)) | 281 | if (ACPI_FAILURE(status)) { |
282 | goto exit; | 282 | goto exit; |
283 | } | ||
283 | 284 | ||
284 | /* Clear the GPE Bits in all GPE registers in all GPE blocks */ | 285 | /* Clear the GPE Bits in all GPE registers in all GPE blocks */ |
285 | 286 | ||
diff --git a/drivers/acpi/acpica/nsobject.c b/drivers/acpi/acpica/nsobject.c index fe54a8c73b8c..a42ee9d6970d 100644 --- a/drivers/acpi/acpica/nsobject.c +++ b/drivers/acpi/acpica/nsobject.c | |||
@@ -237,6 +237,16 @@ void acpi_ns_detach_object(struct acpi_namespace_node *node) | |||
237 | (node->object->common.type != ACPI_TYPE_LOCAL_DATA)) { | 237 | (node->object->common.type != ACPI_TYPE_LOCAL_DATA)) { |
238 | node->object = node->object->common.next_object; | 238 | node->object = node->object->common.next_object; |
239 | } | 239 | } |
240 | |||
241 | /* | ||
242 | * Detach the object from any data objects (which are still held by | ||
243 | * the namespace node) | ||
244 | */ | ||
245 | if (obj_desc->common.next_object && | ||
246 | ((obj_desc->common.next_object)->common.type == | ||
247 | ACPI_TYPE_LOCAL_DATA)) { | ||
248 | obj_desc->common.next_object = NULL; | ||
249 | } | ||
240 | } | 250 | } |
241 | 251 | ||
242 | /* Reset the node type to untyped */ | 252 | /* Reset the node type to untyped */ |
diff --git a/drivers/acpi/acpica/utbuffer.c b/drivers/acpi/acpica/utbuffer.c index 3c1699740653..038ea887f562 100644 --- a/drivers/acpi/acpica/utbuffer.c +++ b/drivers/acpi/acpica/utbuffer.c | |||
@@ -199,3 +199,131 @@ acpi_ut_debug_dump_buffer(u8 *buffer, u32 count, u32 display, u32 component_id) | |||
199 | 199 | ||
200 | acpi_ut_dump_buffer(buffer, count, display, 0); | 200 | acpi_ut_dump_buffer(buffer, count, display, 0); |
201 | } | 201 | } |
202 | |||
203 | #ifdef ACPI_APPLICATION | ||
204 | /******************************************************************************* | ||
205 | * | ||
206 | * FUNCTION: acpi_ut_dump_buffer_to_file | ||
207 | * | ||
208 | * PARAMETERS: file - File descriptor | ||
209 | * buffer - Buffer to dump | ||
210 | * count - Amount to dump, in bytes | ||
211 | * display - BYTE, WORD, DWORD, or QWORD display: | ||
212 | * DB_BYTE_DISPLAY | ||
213 | * DB_WORD_DISPLAY | ||
214 | * DB_DWORD_DISPLAY | ||
215 | * DB_QWORD_DISPLAY | ||
216 | * base_offset - Beginning buffer offset (display only) | ||
217 | * | ||
218 | * RETURN: None | ||
219 | * | ||
220 | * DESCRIPTION: Generic dump buffer in both hex and ascii to a file. | ||
221 | * | ||
222 | ******************************************************************************/ | ||
223 | |||
224 | void | ||
225 | acpi_ut_dump_buffer_to_file(ACPI_FILE file, | ||
226 | u8 *buffer, u32 count, u32 display, u32 base_offset) | ||
227 | { | ||
228 | u32 i = 0; | ||
229 | u32 j; | ||
230 | u32 temp32; | ||
231 | u8 buf_char; | ||
232 | |||
233 | if (!buffer) { | ||
234 | acpi_ut_file_printf(file, | ||
235 | "Null Buffer Pointer in DumpBuffer!\n"); | ||
236 | return; | ||
237 | } | ||
238 | |||
239 | if ((count < 4) || (count & 0x01)) { | ||
240 | display = DB_BYTE_DISPLAY; | ||
241 | } | ||
242 | |||
243 | /* Nasty little dump buffer routine! */ | ||
244 | |||
245 | while (i < count) { | ||
246 | |||
247 | /* Print current offset */ | ||
248 | |||
249 | acpi_ut_file_printf(file, "%6.4X: ", (base_offset + i)); | ||
250 | |||
251 | /* Print 16 hex chars */ | ||
252 | |||
253 | for (j = 0; j < 16;) { | ||
254 | if (i + j >= count) { | ||
255 | |||
256 | /* Dump fill spaces */ | ||
257 | |||
258 | acpi_ut_file_printf(file, "%*s", | ||
259 | ((display * 2) + 1), " "); | ||
260 | j += display; | ||
261 | continue; | ||
262 | } | ||
263 | |||
264 | switch (display) { | ||
265 | case DB_BYTE_DISPLAY: | ||
266 | default: /* Default is BYTE display */ | ||
267 | |||
268 | acpi_ut_file_printf(file, "%02X ", | ||
269 | buffer[(acpi_size) i + j]); | ||
270 | break; | ||
271 | |||
272 | case DB_WORD_DISPLAY: | ||
273 | |||
274 | ACPI_MOVE_16_TO_32(&temp32, | ||
275 | &buffer[(acpi_size) i + j]); | ||
276 | acpi_ut_file_printf(file, "%04X ", temp32); | ||
277 | break; | ||
278 | |||
279 | case DB_DWORD_DISPLAY: | ||
280 | |||
281 | ACPI_MOVE_32_TO_32(&temp32, | ||
282 | &buffer[(acpi_size) i + j]); | ||
283 | acpi_ut_file_printf(file, "%08X ", temp32); | ||
284 | break; | ||
285 | |||
286 | case DB_QWORD_DISPLAY: | ||
287 | |||
288 | ACPI_MOVE_32_TO_32(&temp32, | ||
289 | &buffer[(acpi_size) i + j]); | ||
290 | acpi_ut_file_printf(file, "%08X", temp32); | ||
291 | |||
292 | ACPI_MOVE_32_TO_32(&temp32, | ||
293 | &buffer[(acpi_size) i + j + | ||
294 | 4]); | ||
295 | acpi_ut_file_printf(file, "%08X ", temp32); | ||
296 | break; | ||
297 | } | ||
298 | |||
299 | j += display; | ||
300 | } | ||
301 | |||
302 | /* | ||
303 | * Print the ASCII equivalent characters but watch out for the bad | ||
304 | * unprintable ones (printable chars are 0x20 through 0x7E) | ||
305 | */ | ||
306 | acpi_ut_file_printf(file, " "); | ||
307 | for (j = 0; j < 16; j++) { | ||
308 | if (i + j >= count) { | ||
309 | acpi_ut_file_printf(file, "\n"); | ||
310 | return; | ||
311 | } | ||
312 | |||
313 | buf_char = buffer[(acpi_size) i + j]; | ||
314 | if (ACPI_IS_PRINT(buf_char)) { | ||
315 | acpi_ut_file_printf(file, "%c", buf_char); | ||
316 | } else { | ||
317 | acpi_ut_file_printf(file, "."); | ||
318 | } | ||
319 | } | ||
320 | |||
321 | /* Done with that line. */ | ||
322 | |||
323 | acpi_ut_file_printf(file, "\n"); | ||
324 | i += 16; | ||
325 | } | ||
326 | |||
327 | return; | ||
328 | } | ||
329 | #endif | ||
diff --git a/drivers/acpi/acpica/utcopy.c b/drivers/acpi/acpica/utcopy.c index 270c16464dd9..ff601c0f7c7a 100644 --- a/drivers/acpi/acpica/utcopy.c +++ b/drivers/acpi/acpica/utcopy.c | |||
@@ -1001,5 +1001,11 @@ acpi_ut_copy_iobject_to_iobject(union acpi_operand_object *source_desc, | |||
1001 | status = acpi_ut_copy_simple_object(source_desc, *dest_desc); | 1001 | status = acpi_ut_copy_simple_object(source_desc, *dest_desc); |
1002 | } | 1002 | } |
1003 | 1003 | ||
1004 | /* Delete the allocated object if copy failed */ | ||
1005 | |||
1006 | if (ACPI_FAILURE(status)) { | ||
1007 | acpi_ut_remove_reference(*dest_desc); | ||
1008 | } | ||
1009 | |||
1004 | return_ACPI_STATUS(status); | 1010 | return_ACPI_STATUS(status); |
1005 | } | 1011 | } |
diff --git a/drivers/acpi/acpica/utdebug.c b/drivers/acpi/acpica/utdebug.c index 21a20ac5b1e1..e516254c63b2 100644 --- a/drivers/acpi/acpica/utdebug.c +++ b/drivers/acpi/acpica/utdebug.c | |||
@@ -561,3 +561,29 @@ acpi_ut_ptr_exit(u32 line_number, | |||
561 | } | 561 | } |
562 | 562 | ||
563 | #endif | 563 | #endif |
564 | |||
565 | #ifdef ACPI_APPLICATION | ||
566 | /******************************************************************************* | ||
567 | * | ||
568 | * FUNCTION: acpi_log_error | ||
569 | * | ||
570 | * PARAMETERS: format - Printf format field | ||
571 | * ... - Optional printf arguments | ||
572 | * | ||
573 | * RETURN: None | ||
574 | * | ||
575 | * DESCRIPTION: Print error message to the console, used by applications. | ||
576 | * | ||
577 | ******************************************************************************/ | ||
578 | |||
579 | void ACPI_INTERNAL_VAR_XFACE acpi_log_error(const char *format, ...) | ||
580 | { | ||
581 | va_list args; | ||
582 | |||
583 | va_start(args, format); | ||
584 | (void)acpi_ut_file_vprintf(ACPI_FILE_ERR, format, args); | ||
585 | va_end(args); | ||
586 | } | ||
587 | |||
588 | ACPI_EXPORT_SYMBOL(acpi_log_error) | ||
589 | #endif | ||
diff --git a/drivers/acpi/acpica/utfileio.c b/drivers/acpi/acpica/utfileio.c new file mode 100644 index 000000000000..bdf9914733cb --- /dev/null +++ b/drivers/acpi/acpica/utfileio.c | |||
@@ -0,0 +1,332 @@ | |||
1 | /******************************************************************************* | ||
2 | * | ||
3 | * Module Name: utfileio - simple file I/O routines | ||
4 | * | ||
5 | ******************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2014, Intel Corp. | ||
9 | * All rights reserved. | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or without | ||
12 | * modification, are permitted provided that the following conditions | ||
13 | * are met: | ||
14 | * 1. Redistributions of source code must retain the above copyright | ||
15 | * notice, this list of conditions, and the following disclaimer, | ||
16 | * without modification. | ||
17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | ||
18 | * substantially similar to the "NO WARRANTY" disclaimer below | ||
19 | * ("Disclaimer") and any redistribution must be conditioned upon | ||
20 | * including a substantially similar Disclaimer requirement for further | ||
21 | * binary redistribution. | ||
22 | * 3. Neither the names of the above-listed copyright holders nor the names | ||
23 | * of any contributors may be used to endorse or promote products derived | ||
24 | * from this software without specific prior written permission. | ||
25 | * | ||
26 | * Alternatively, this software may be distributed under the terms of the | ||
27 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
28 | * Software Foundation. | ||
29 | * | ||
30 | * NO WARRANTY | ||
31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | ||
34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
41 | * POSSIBILITY OF SUCH DAMAGES. | ||
42 | */ | ||
43 | |||
44 | #include <acpi/acpi.h> | ||
45 | #include "accommon.h" | ||
46 | #include "actables.h" | ||
47 | #include "acapps.h" | ||
48 | |||
49 | #ifdef ACPI_ASL_COMPILER | ||
50 | #include "aslcompiler.h" | ||
51 | #endif | ||
52 | |||
53 | #define _COMPONENT ACPI_CA_DEBUGGER | ||
54 | ACPI_MODULE_NAME("utfileio") | ||
55 | |||
56 | #ifdef ACPI_APPLICATION | ||
57 | /* Local prototypes */ | ||
58 | static acpi_status | ||
59 | acpi_ut_check_text_mode_corruption(u8 *table, | ||
60 | u32 table_length, u32 file_length); | ||
61 | |||
62 | static acpi_status | ||
63 | acpi_ut_read_table(FILE * fp, | ||
64 | struct acpi_table_header **table, u32 *table_length); | ||
65 | |||
66 | /******************************************************************************* | ||
67 | * | ||
68 | * FUNCTION: acpi_ut_check_text_mode_corruption | ||
69 | * | ||
70 | * PARAMETERS: table - Table buffer | ||
71 | * table_length - Length of table from the table header | ||
72 | * file_length - Length of the file that contains the table | ||
73 | * | ||
74 | * RETURN: Status | ||
75 | * | ||
76 | * DESCRIPTION: Check table for text mode file corruption where all linefeed | ||
77 | * characters (LF) have been replaced by carriage return linefeed | ||
78 | * pairs (CR/LF). | ||
79 | * | ||
80 | ******************************************************************************/ | ||
81 | |||
82 | static acpi_status | ||
83 | acpi_ut_check_text_mode_corruption(u8 *table, u32 table_length, u32 file_length) | ||
84 | { | ||
85 | u32 i; | ||
86 | u32 pairs = 0; | ||
87 | |||
88 | if (table_length != file_length) { | ||
89 | ACPI_WARNING((AE_INFO, | ||
90 | "File length (0x%X) is not the same as the table length (0x%X)", | ||
91 | file_length, table_length)); | ||
92 | } | ||
93 | |||
94 | /* Scan entire table to determine if each LF has been prefixed with a CR */ | ||
95 | |||
96 | for (i = 1; i < file_length; i++) { | ||
97 | if (table[i] == 0x0A) { | ||
98 | if (table[i - 1] != 0x0D) { | ||
99 | |||
100 | /* The LF does not have a preceding CR, table not corrupted */ | ||
101 | |||
102 | return (AE_OK); | ||
103 | } else { | ||
104 | /* Found a CR/LF pair */ | ||
105 | |||
106 | pairs++; | ||
107 | } | ||
108 | i++; | ||
109 | } | ||
110 | } | ||
111 | |||
112 | if (!pairs) { | ||
113 | return (AE_OK); | ||
114 | } | ||
115 | |||
116 | /* | ||
117 | * Entire table scanned, each CR is part of a CR/LF pair -- | ||
118 | * meaning that the table was treated as a text file somewhere. | ||
119 | * | ||
120 | * NOTE: We can't "fix" the table, because any existing CR/LF pairs in the | ||
121 | * original table are left untouched by the text conversion process -- | ||
122 | * meaning that we cannot simply replace CR/LF pairs with LFs. | ||
123 | */ | ||
124 | acpi_os_printf("Table has been corrupted by text mode conversion\n"); | ||
125 | acpi_os_printf("All LFs (%u) were changed to CR/LF pairs\n", pairs); | ||
126 | acpi_os_printf("Table cannot be repaired!\n"); | ||
127 | return (AE_BAD_VALUE); | ||
128 | } | ||
129 | |||
130 | /******************************************************************************* | ||
131 | * | ||
132 | * FUNCTION: acpi_ut_read_table | ||
133 | * | ||
134 | * PARAMETERS: fp - File that contains table | ||
135 | * table - Return value, buffer with table | ||
136 | * table_length - Return value, length of table | ||
137 | * | ||
138 | * RETURN: Status | ||
139 | * | ||
140 | * DESCRIPTION: Load the DSDT from the file pointer | ||
141 | * | ||
142 | ******************************************************************************/ | ||
143 | |||
144 | static acpi_status | ||
145 | acpi_ut_read_table(FILE * fp, | ||
146 | struct acpi_table_header **table, u32 *table_length) | ||
147 | { | ||
148 | struct acpi_table_header table_header; | ||
149 | u32 actual; | ||
150 | acpi_status status; | ||
151 | u32 file_size; | ||
152 | u8 standard_header = TRUE; | ||
153 | s32 count; | ||
154 | |||
155 | /* Get the file size */ | ||
156 | |||
157 | file_size = cm_get_file_size(fp); | ||
158 | if (file_size == ACPI_UINT32_MAX) { | ||
159 | return (AE_ERROR); | ||
160 | } | ||
161 | |||
162 | if (file_size < 4) { | ||
163 | return (AE_BAD_HEADER); | ||
164 | } | ||
165 | |||
166 | /* Read the signature */ | ||
167 | |||
168 | fseek(fp, 0, SEEK_SET); | ||
169 | |||
170 | count = fread(&table_header, 1, sizeof(struct acpi_table_header), fp); | ||
171 | if (count != sizeof(struct acpi_table_header)) { | ||
172 | acpi_os_printf("Could not read the table header\n"); | ||
173 | return (AE_BAD_HEADER); | ||
174 | } | ||
175 | |||
176 | /* The RSDP table does not have standard ACPI header */ | ||
177 | |||
178 | if (ACPI_VALIDATE_RSDP_SIG(table_header.signature)) { | ||
179 | *table_length = file_size; | ||
180 | standard_header = FALSE; | ||
181 | } else { | ||
182 | |||
183 | #if 0 | ||
184 | /* Validate the table header/length */ | ||
185 | |||
186 | status = acpi_tb_validate_table_header(&table_header); | ||
187 | if (ACPI_FAILURE(status)) { | ||
188 | acpi_os_printf("Table header is invalid!\n"); | ||
189 | return (status); | ||
190 | } | ||
191 | #endif | ||
192 | |||
193 | /* File size must be at least as long as the Header-specified length */ | ||
194 | |||
195 | if (table_header.length > file_size) { | ||
196 | acpi_os_printf | ||
197 | ("TableHeader length [0x%X] greater than the input file size [0x%X]\n", | ||
198 | table_header.length, file_size); | ||
199 | |||
200 | #ifdef ACPI_ASL_COMPILER | ||
201 | status = fl_check_for_ascii(fp, NULL, FALSE); | ||
202 | if (ACPI_SUCCESS(status)) { | ||
203 | acpi_os_printf | ||
204 | ("File appears to be ASCII only, must be binary\n", | ||
205 | table_header.length, file_size); | ||
206 | } | ||
207 | #endif | ||
208 | return (AE_BAD_HEADER); | ||
209 | } | ||
210 | #ifdef ACPI_OBSOLETE_CODE | ||
211 | /* We only support a limited number of table types */ | ||
212 | |||
213 | if (!ACPI_COMPARE_NAME | ||
214 | ((char *)table_header.signature, ACPI_SIG_DSDT) | ||
215 | && !ACPI_COMPARE_NAME((char *)table_header.signature, | ||
216 | ACPI_SIG_PSDT) | ||
217 | && !ACPI_COMPARE_NAME((char *)table_header.signature, | ||
218 | ACPI_SIG_SSDT)) { | ||
219 | acpi_os_printf | ||
220 | ("Table signature [%4.4s] is invalid or not supported\n", | ||
221 | (char *)table_header.signature); | ||
222 | ACPI_DUMP_BUFFER(&table_header, | ||
223 | sizeof(struct acpi_table_header)); | ||
224 | return (AE_ERROR); | ||
225 | } | ||
226 | #endif | ||
227 | |||
228 | *table_length = table_header.length; | ||
229 | } | ||
230 | |||
231 | /* Allocate a buffer for the table */ | ||
232 | |||
233 | *table = acpi_os_allocate((size_t) file_size); | ||
234 | if (!*table) { | ||
235 | acpi_os_printf | ||
236 | ("Could not allocate memory for ACPI table %4.4s (size=0x%X)\n", | ||
237 | table_header.signature, *table_length); | ||
238 | return (AE_NO_MEMORY); | ||
239 | } | ||
240 | |||
241 | /* Get the rest of the table */ | ||
242 | |||
243 | fseek(fp, 0, SEEK_SET); | ||
244 | actual = fread(*table, 1, (size_t) file_size, fp); | ||
245 | if (actual == file_size) { | ||
246 | if (standard_header) { | ||
247 | |||
248 | /* Now validate the checksum */ | ||
249 | |||
250 | status = acpi_tb_verify_checksum((void *)*table, | ||
251 | ACPI_CAST_PTR(struct | ||
252 | acpi_table_header, | ||
253 | *table)-> | ||
254 | length); | ||
255 | |||
256 | if (status == AE_BAD_CHECKSUM) { | ||
257 | status = | ||
258 | acpi_ut_check_text_mode_corruption((u8 *) | ||
259 | *table, | ||
260 | file_size, | ||
261 | (*table)-> | ||
262 | length); | ||
263 | return (status); | ||
264 | } | ||
265 | } | ||
266 | return (AE_OK); | ||
267 | } | ||
268 | |||
269 | if (actual > 0) { | ||
270 | acpi_os_printf("Warning - reading table, asked for %X got %X\n", | ||
271 | file_size, actual); | ||
272 | return (AE_OK); | ||
273 | } | ||
274 | |||
275 | acpi_os_printf("Error - could not read the table file\n"); | ||
276 | acpi_os_free(*table); | ||
277 | *table = NULL; | ||
278 | *table_length = 0; | ||
279 | return (AE_ERROR); | ||
280 | } | ||
281 | |||
282 | /******************************************************************************* | ||
283 | * | ||
284 | * FUNCTION: acpi_ut_read_table_from_file | ||
285 | * | ||
286 | * PARAMETERS: filename - File where table is located | ||
287 | * table - Where a pointer to the table is returned | ||
288 | * | ||
289 | * RETURN: Status | ||
290 | * | ||
291 | * DESCRIPTION: Get an ACPI table from a file | ||
292 | * | ||
293 | ******************************************************************************/ | ||
294 | |||
295 | acpi_status | ||
296 | acpi_ut_read_table_from_file(char *filename, struct acpi_table_header ** table) | ||
297 | { | ||
298 | FILE *file; | ||
299 | u32 file_size; | ||
300 | u32 table_length; | ||
301 | acpi_status status = AE_ERROR; | ||
302 | |||
303 | /* Open the file, get current size */ | ||
304 | |||
305 | file = fopen(filename, "rb"); | ||
306 | if (!file) { | ||
307 | perror("Could not open input file"); | ||
308 | return (status); | ||
309 | } | ||
310 | |||
311 | file_size = cm_get_file_size(file); | ||
312 | if (file_size == ACPI_UINT32_MAX) { | ||
313 | goto exit; | ||
314 | } | ||
315 | |||
316 | /* Get the entire file */ | ||
317 | |||
318 | fprintf(stderr, | ||
319 | "Loading Acpi table from file %10s - Length %.8u (%06X)\n", | ||
320 | filename, file_size, file_size); | ||
321 | |||
322 | status = acpi_ut_read_table(file, table, &table_length); | ||
323 | if (ACPI_FAILURE(status)) { | ||
324 | acpi_os_printf("Could not get table from the file\n"); | ||
325 | } | ||
326 | |||
327 | exit: | ||
328 | fclose(file); | ||
329 | return (status); | ||
330 | } | ||
331 | |||
332 | #endif | ||
diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c index d69be3cb3fae..77ceac715f28 100644 --- a/drivers/acpi/acpica/utglobal.c +++ b/drivers/acpi/acpica/utglobal.c | |||
@@ -214,152 +214,6 @@ struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] = | |||
214 | }; | 214 | }; |
215 | #endif /* !ACPI_REDUCED_HARDWARE */ | 215 | #endif /* !ACPI_REDUCED_HARDWARE */ |
216 | 216 | ||
217 | /******************************************************************************* | ||
218 | * | ||
219 | * FUNCTION: acpi_ut_init_globals | ||
220 | * | ||
221 | * PARAMETERS: None | ||
222 | * | ||
223 | * RETURN: Status | ||
224 | * | ||
225 | * DESCRIPTION: Initialize ACPICA globals. All globals that require specific | ||
226 | * initialization should be initialized here. This allows for | ||
227 | * a warm restart. | ||
228 | * | ||
229 | ******************************************************************************/ | ||
230 | |||
231 | acpi_status acpi_ut_init_globals(void) | ||
232 | { | ||
233 | acpi_status status; | ||
234 | u32 i; | ||
235 | |||
236 | ACPI_FUNCTION_TRACE(ut_init_globals); | ||
237 | |||
238 | /* Create all memory caches */ | ||
239 | |||
240 | status = acpi_ut_create_caches(); | ||
241 | if (ACPI_FAILURE(status)) { | ||
242 | return_ACPI_STATUS(status); | ||
243 | } | ||
244 | |||
245 | /* Address Range lists */ | ||
246 | |||
247 | for (i = 0; i < ACPI_ADDRESS_RANGE_MAX; i++) { | ||
248 | acpi_gbl_address_range_list[i] = NULL; | ||
249 | } | ||
250 | |||
251 | /* Mutex locked flags */ | ||
252 | |||
253 | for (i = 0; i < ACPI_NUM_MUTEX; i++) { | ||
254 | acpi_gbl_mutex_info[i].mutex = NULL; | ||
255 | acpi_gbl_mutex_info[i].thread_id = ACPI_MUTEX_NOT_ACQUIRED; | ||
256 | acpi_gbl_mutex_info[i].use_count = 0; | ||
257 | } | ||
258 | |||
259 | for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) { | ||
260 | acpi_gbl_owner_id_mask[i] = 0; | ||
261 | } | ||
262 | |||
263 | /* Last owner_ID is never valid */ | ||
264 | |||
265 | acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; | ||
266 | |||
267 | /* Event counters */ | ||
268 | |||
269 | acpi_method_count = 0; | ||
270 | acpi_sci_count = 0; | ||
271 | acpi_gpe_count = 0; | ||
272 | |||
273 | for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) { | ||
274 | acpi_fixed_event_count[i] = 0; | ||
275 | } | ||
276 | |||
277 | #if (!ACPI_REDUCED_HARDWARE) | ||
278 | |||
279 | /* GPE/SCI support */ | ||
280 | |||
281 | acpi_gbl_all_gpes_initialized = FALSE; | ||
282 | acpi_gbl_gpe_xrupt_list_head = NULL; | ||
283 | acpi_gbl_gpe_fadt_blocks[0] = NULL; | ||
284 | acpi_gbl_gpe_fadt_blocks[1] = NULL; | ||
285 | acpi_current_gpe_count = 0; | ||
286 | |||
287 | acpi_gbl_global_event_handler = NULL; | ||
288 | acpi_gbl_sci_handler_list = NULL; | ||
289 | |||
290 | #endif /* !ACPI_REDUCED_HARDWARE */ | ||
291 | |||
292 | /* Global handlers */ | ||
293 | |||
294 | acpi_gbl_global_notify[0].handler = NULL; | ||
295 | acpi_gbl_global_notify[1].handler = NULL; | ||
296 | acpi_gbl_exception_handler = NULL; | ||
297 | acpi_gbl_init_handler = NULL; | ||
298 | acpi_gbl_table_handler = NULL; | ||
299 | acpi_gbl_interface_handler = NULL; | ||
300 | |||
301 | /* Global Lock support */ | ||
302 | |||
303 | acpi_gbl_global_lock_semaphore = NULL; | ||
304 | acpi_gbl_global_lock_mutex = NULL; | ||
305 | acpi_gbl_global_lock_acquired = FALSE; | ||
306 | acpi_gbl_global_lock_handle = 0; | ||
307 | acpi_gbl_global_lock_present = FALSE; | ||
308 | |||
309 | /* Miscellaneous variables */ | ||
310 | |||
311 | acpi_gbl_DSDT = NULL; | ||
312 | acpi_gbl_cm_single_step = FALSE; | ||
313 | acpi_gbl_shutdown = FALSE; | ||
314 | acpi_gbl_ns_lookup_count = 0; | ||
315 | acpi_gbl_ps_find_count = 0; | ||
316 | acpi_gbl_acpi_hardware_present = TRUE; | ||
317 | acpi_gbl_last_owner_id_index = 0; | ||
318 | acpi_gbl_next_owner_id_offset = 0; | ||
319 | acpi_gbl_trace_dbg_level = 0; | ||
320 | acpi_gbl_trace_dbg_layer = 0; | ||
321 | acpi_gbl_debugger_configuration = DEBUGGER_THREADING; | ||
322 | acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT; | ||
323 | acpi_gbl_osi_mutex = NULL; | ||
324 | acpi_gbl_reg_methods_executed = FALSE; | ||
325 | |||
326 | /* Hardware oriented */ | ||
327 | |||
328 | acpi_gbl_events_initialized = FALSE; | ||
329 | acpi_gbl_system_awake_and_running = TRUE; | ||
330 | |||
331 | /* Namespace */ | ||
332 | |||
333 | acpi_gbl_module_code_list = NULL; | ||
334 | acpi_gbl_root_node = NULL; | ||
335 | acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME; | ||
336 | acpi_gbl_root_node_struct.descriptor_type = ACPI_DESC_TYPE_NAMED; | ||
337 | acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE; | ||
338 | acpi_gbl_root_node_struct.parent = NULL; | ||
339 | acpi_gbl_root_node_struct.child = NULL; | ||
340 | acpi_gbl_root_node_struct.peer = NULL; | ||
341 | acpi_gbl_root_node_struct.object = NULL; | ||
342 | |||
343 | #ifdef ACPI_DISASSEMBLER | ||
344 | acpi_gbl_external_list = NULL; | ||
345 | acpi_gbl_num_external_methods = 0; | ||
346 | acpi_gbl_resolved_external_methods = 0; | ||
347 | #endif | ||
348 | |||
349 | #ifdef ACPI_DEBUG_OUTPUT | ||
350 | acpi_gbl_lowest_stack_pointer = ACPI_CAST_PTR(acpi_size, ACPI_SIZE_MAX); | ||
351 | #endif | ||
352 | |||
353 | #ifdef ACPI_DBG_TRACK_ALLOCATIONS | ||
354 | acpi_gbl_display_final_mem_stats = FALSE; | ||
355 | acpi_gbl_disable_mem_tracking = FALSE; | ||
356 | #endif | ||
357 | |||
358 | ACPI_DEBUGGER_EXEC(acpi_gbl_db_terminate_threads = FALSE); | ||
359 | |||
360 | return_ACPI_STATUS(AE_OK); | ||
361 | } | ||
362 | |||
363 | /* Public globals */ | 217 | /* Public globals */ |
364 | 218 | ||
365 | ACPI_EXPORT_SYMBOL(acpi_gbl_FADT) | 219 | ACPI_EXPORT_SYMBOL(acpi_gbl_FADT) |
diff --git a/drivers/acpi/acpica/utinit.c b/drivers/acpi/acpica/utinit.c index 5f56fc49021e..77120ec9ea86 100644 --- a/drivers/acpi/acpica/utinit.c +++ b/drivers/acpi/acpica/utinit.c | |||
@@ -102,6 +102,151 @@ static void acpi_ut_free_gpe_lists(void) | |||
102 | } | 102 | } |
103 | #endif /* !ACPI_REDUCED_HARDWARE */ | 103 | #endif /* !ACPI_REDUCED_HARDWARE */ |
104 | 104 | ||
105 | /******************************************************************************* | ||
106 | * | ||
107 | * FUNCTION: acpi_ut_init_globals | ||
108 | * | ||
109 | * PARAMETERS: None | ||
110 | * | ||
111 | * RETURN: Status | ||
112 | * | ||
113 | * DESCRIPTION: Initialize ACPICA globals. All globals that require specific | ||
114 | * initialization should be initialized here. This allows for | ||
115 | * a warm restart. | ||
116 | * | ||
117 | ******************************************************************************/ | ||
118 | |||
119 | acpi_status acpi_ut_init_globals(void) | ||
120 | { | ||
121 | acpi_status status; | ||
122 | u32 i; | ||
123 | |||
124 | ACPI_FUNCTION_TRACE(ut_init_globals); | ||
125 | |||
126 | /* Create all memory caches */ | ||
127 | |||
128 | status = acpi_ut_create_caches(); | ||
129 | if (ACPI_FAILURE(status)) { | ||
130 | return_ACPI_STATUS(status); | ||
131 | } | ||
132 | |||
133 | /* Address Range lists */ | ||
134 | |||
135 | for (i = 0; i < ACPI_ADDRESS_RANGE_MAX; i++) { | ||
136 | acpi_gbl_address_range_list[i] = NULL; | ||
137 | } | ||
138 | |||
139 | /* Mutex locked flags */ | ||
140 | |||
141 | for (i = 0; i < ACPI_NUM_MUTEX; i++) { | ||
142 | acpi_gbl_mutex_info[i].mutex = NULL; | ||
143 | acpi_gbl_mutex_info[i].thread_id = ACPI_MUTEX_NOT_ACQUIRED; | ||
144 | acpi_gbl_mutex_info[i].use_count = 0; | ||
145 | } | ||
146 | |||
147 | for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) { | ||
148 | acpi_gbl_owner_id_mask[i] = 0; | ||
149 | } | ||
150 | |||
151 | /* Last owner_ID is never valid */ | ||
152 | |||
153 | acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; | ||
154 | |||
155 | /* Event counters */ | ||
156 | |||
157 | acpi_method_count = 0; | ||
158 | acpi_sci_count = 0; | ||
159 | acpi_gpe_count = 0; | ||
160 | |||
161 | for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) { | ||
162 | acpi_fixed_event_count[i] = 0; | ||
163 | } | ||
164 | |||
165 | #if (!ACPI_REDUCED_HARDWARE) | ||
166 | |||
167 | /* GPE/SCI support */ | ||
168 | |||
169 | acpi_gbl_all_gpes_initialized = FALSE; | ||
170 | acpi_gbl_gpe_xrupt_list_head = NULL; | ||
171 | acpi_gbl_gpe_fadt_blocks[0] = NULL; | ||
172 | acpi_gbl_gpe_fadt_blocks[1] = NULL; | ||
173 | acpi_current_gpe_count = 0; | ||
174 | |||
175 | acpi_gbl_global_event_handler = NULL; | ||
176 | acpi_gbl_sci_handler_list = NULL; | ||
177 | |||
178 | #endif /* !ACPI_REDUCED_HARDWARE */ | ||
179 | |||
180 | /* Global handlers */ | ||
181 | |||
182 | acpi_gbl_global_notify[0].handler = NULL; | ||
183 | acpi_gbl_global_notify[1].handler = NULL; | ||
184 | acpi_gbl_exception_handler = NULL; | ||
185 | acpi_gbl_init_handler = NULL; | ||
186 | acpi_gbl_table_handler = NULL; | ||
187 | acpi_gbl_interface_handler = NULL; | ||
188 | |||
189 | /* Global Lock support */ | ||
190 | |||
191 | acpi_gbl_global_lock_semaphore = NULL; | ||
192 | acpi_gbl_global_lock_mutex = NULL; | ||
193 | acpi_gbl_global_lock_acquired = FALSE; | ||
194 | acpi_gbl_global_lock_handle = 0; | ||
195 | acpi_gbl_global_lock_present = FALSE; | ||
196 | |||
197 | /* Miscellaneous variables */ | ||
198 | |||
199 | acpi_gbl_DSDT = NULL; | ||
200 | acpi_gbl_cm_single_step = FALSE; | ||
201 | acpi_gbl_shutdown = FALSE; | ||
202 | acpi_gbl_ns_lookup_count = 0; | ||
203 | acpi_gbl_ps_find_count = 0; | ||
204 | acpi_gbl_acpi_hardware_present = TRUE; | ||
205 | acpi_gbl_last_owner_id_index = 0; | ||
206 | acpi_gbl_next_owner_id_offset = 0; | ||
207 | acpi_gbl_trace_dbg_level = 0; | ||
208 | acpi_gbl_trace_dbg_layer = 0; | ||
209 | acpi_gbl_debugger_configuration = DEBUGGER_THREADING; | ||
210 | acpi_gbl_osi_mutex = NULL; | ||
211 | acpi_gbl_reg_methods_executed = FALSE; | ||
212 | |||
213 | /* Hardware oriented */ | ||
214 | |||
215 | acpi_gbl_events_initialized = FALSE; | ||
216 | acpi_gbl_system_awake_and_running = TRUE; | ||
217 | |||
218 | /* Namespace */ | ||
219 | |||
220 | acpi_gbl_module_code_list = NULL; | ||
221 | acpi_gbl_root_node = NULL; | ||
222 | acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME; | ||
223 | acpi_gbl_root_node_struct.descriptor_type = ACPI_DESC_TYPE_NAMED; | ||
224 | acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE; | ||
225 | acpi_gbl_root_node_struct.parent = NULL; | ||
226 | acpi_gbl_root_node_struct.child = NULL; | ||
227 | acpi_gbl_root_node_struct.peer = NULL; | ||
228 | acpi_gbl_root_node_struct.object = NULL; | ||
229 | |||
230 | #ifdef ACPI_DISASSEMBLER | ||
231 | acpi_gbl_external_list = NULL; | ||
232 | acpi_gbl_num_external_methods = 0; | ||
233 | acpi_gbl_resolved_external_methods = 0; | ||
234 | #endif | ||
235 | |||
236 | #ifdef ACPI_DEBUG_OUTPUT | ||
237 | acpi_gbl_lowest_stack_pointer = ACPI_CAST_PTR(acpi_size, ACPI_SIZE_MAX); | ||
238 | #endif | ||
239 | |||
240 | #ifdef ACPI_DBG_TRACK_ALLOCATIONS | ||
241 | acpi_gbl_display_final_mem_stats = FALSE; | ||
242 | acpi_gbl_disable_mem_tracking = FALSE; | ||
243 | #endif | ||
244 | |||
245 | ACPI_DEBUGGER_EXEC(acpi_gbl_db_terminate_threads = FALSE); | ||
246 | |||
247 | return_ACPI_STATUS(AE_OK); | ||
248 | } | ||
249 | |||
105 | /****************************************************************************** | 250 | /****************************************************************************** |
106 | * | 251 | * |
107 | * FUNCTION: acpi_ut_terminate | 252 | * FUNCTION: acpi_ut_terminate |
diff --git a/drivers/acpi/acpica/utprint.c b/drivers/acpi/acpica/utprint.c new file mode 100644 index 000000000000..10311648f701 --- /dev/null +++ b/drivers/acpi/acpica/utprint.c | |||
@@ -0,0 +1,661 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: utprint - Formatted printing routines | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2014, Intel Corp. | ||
9 | * All rights reserved. | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or without | ||
12 | * modification, are permitted provided that the following conditions | ||
13 | * are met: | ||
14 | * 1. Redistributions of source code must retain the above copyright | ||
15 | * notice, this list of conditions, and the following disclaimer, | ||
16 | * without modification. | ||
17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | ||
18 | * substantially similar to the "NO WARRANTY" disclaimer below | ||
19 | * ("Disclaimer") and any redistribution must be conditioned upon | ||
20 | * including a substantially similar Disclaimer requirement for further | ||
21 | * binary redistribution. | ||
22 | * 3. Neither the names of the above-listed copyright holders nor the names | ||
23 | * of any contributors may be used to endorse or promote products derived | ||
24 | * from this software without specific prior written permission. | ||
25 | * | ||
26 | * Alternatively, this software may be distributed under the terms of the | ||
27 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
28 | * Software Foundation. | ||
29 | * | ||
30 | * NO WARRANTY | ||
31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | ||
34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
41 | * POSSIBILITY OF SUCH DAMAGES. | ||
42 | */ | ||
43 | |||
44 | #include <acpi/acpi.h> | ||
45 | #include "accommon.h" | ||
46 | |||
47 | #define _COMPONENT ACPI_UTILITIES | ||
48 | ACPI_MODULE_NAME("utprint") | ||
49 | |||
50 | #define ACPI_FORMAT_SIGN 0x01 | ||
51 | #define ACPI_FORMAT_SIGN_PLUS 0x02 | ||
52 | #define ACPI_FORMAT_SIGN_PLUS_SPACE 0x04 | ||
53 | #define ACPI_FORMAT_ZERO 0x08 | ||
54 | #define ACPI_FORMAT_LEFT 0x10 | ||
55 | #define ACPI_FORMAT_UPPER 0x20 | ||
56 | #define ACPI_FORMAT_PREFIX 0x40 | ||
57 | /* Local prototypes */ | ||
58 | static acpi_size | ||
59 | acpi_ut_bound_string_length(const char *string, acpi_size count); | ||
60 | |||
61 | static char *acpi_ut_bound_string_output(char *string, const char *end, char c); | ||
62 | |||
63 | static char *acpi_ut_format_number(char *string, | ||
64 | char *end, | ||
65 | u64 number, | ||
66 | u8 base, s32 width, s32 precision, u8 type); | ||
67 | |||
68 | static char *acpi_ut_put_number(char *string, u64 number, u8 base, u8 upper); | ||
69 | |||
70 | /* Module globals */ | ||
71 | |||
72 | static const char acpi_gbl_lower_hex_digits[] = "0123456789abcdef"; | ||
73 | static const char acpi_gbl_upper_hex_digits[] = "0123456789ABCDEF"; | ||
74 | |||
75 | /******************************************************************************* | ||
76 | * | ||
77 | * FUNCTION: acpi_ut_bound_string_length | ||
78 | * | ||
79 | * PARAMETERS: string - String with boundary | ||
80 | * count - Boundary of the string | ||
81 | * | ||
82 | * RETURN: Length of the string. Less than or equal to Count. | ||
83 | * | ||
84 | * DESCRIPTION: Calculate the length of a string with boundary. | ||
85 | * | ||
86 | ******************************************************************************/ | ||
87 | |||
88 | static acpi_size | ||
89 | acpi_ut_bound_string_length(const char *string, acpi_size count) | ||
90 | { | ||
91 | u32 length = 0; | ||
92 | |||
93 | while (*string && count) { | ||
94 | length++; | ||
95 | string++; | ||
96 | count--; | ||
97 | } | ||
98 | |||
99 | return (length); | ||
100 | } | ||
101 | |||
102 | /******************************************************************************* | ||
103 | * | ||
104 | * FUNCTION: acpi_ut_bound_string_output | ||
105 | * | ||
106 | * PARAMETERS: string - String with boundary | ||
107 | * end - Boundary of the string | ||
108 | * c - Character to be output to the string | ||
109 | * | ||
110 | * RETURN: Updated position for next valid character | ||
111 | * | ||
112 | * DESCRIPTION: Output a character into a string with boundary check. | ||
113 | * | ||
114 | ******************************************************************************/ | ||
115 | |||
116 | static char *acpi_ut_bound_string_output(char *string, const char *end, char c) | ||
117 | { | ||
118 | |||
119 | if (string < end) { | ||
120 | *string = c; | ||
121 | } | ||
122 | |||
123 | ++string; | ||
124 | return (string); | ||
125 | } | ||
126 | |||
127 | /******************************************************************************* | ||
128 | * | ||
129 | * FUNCTION: acpi_ut_put_number | ||
130 | * | ||
131 | * PARAMETERS: string - Buffer to hold reverse-ordered string | ||
132 | * number - Integer to be converted | ||
133 | * base - Base of the integer | ||
134 | * upper - Whether or not using upper cased digits | ||
135 | * | ||
136 | * RETURN: Updated position for next valid character | ||
137 | * | ||
138 | * DESCRIPTION: Convert an integer into a string, note that, the string holds a | ||
139 | * reversed ordered number without the trailing zero. | ||
140 | * | ||
141 | ******************************************************************************/ | ||
142 | |||
143 | static char *acpi_ut_put_number(char *string, u64 number, u8 base, u8 upper) | ||
144 | { | ||
145 | const char *digits; | ||
146 | u64 digit_index; | ||
147 | char *pos; | ||
148 | |||
149 | pos = string; | ||
150 | digits = upper ? acpi_gbl_upper_hex_digits : acpi_gbl_lower_hex_digits; | ||
151 | |||
152 | if (number == 0) { | ||
153 | *(pos++) = '0'; | ||
154 | } else { | ||
155 | while (number) { | ||
156 | (void)acpi_ut_divide(number, base, &number, | ||
157 | &digit_index); | ||
158 | *(pos++) = digits[digit_index]; | ||
159 | } | ||
160 | } | ||
161 | |||
162 | /* *(Pos++) = '0'; */ | ||
163 | return (pos); | ||
164 | } | ||
165 | |||
166 | /******************************************************************************* | ||
167 | * | ||
168 | * FUNCTION: acpi_ut_scan_number | ||
169 | * | ||
170 | * PARAMETERS: string - String buffer | ||
171 | * number_ptr - Where the number is returned | ||
172 | * | ||
173 | * RETURN: Updated position for next valid character | ||
174 | * | ||
175 | * DESCRIPTION: Scan a string for a decimal integer. | ||
176 | * | ||
177 | ******************************************************************************/ | ||
178 | |||
179 | const char *acpi_ut_scan_number(const char *string, u64 *number_ptr) | ||
180 | { | ||
181 | u64 number = 0; | ||
182 | |||
183 | while (ACPI_IS_DIGIT(*string)) { | ||
184 | number *= 10; | ||
185 | number += *(string++) - '0'; | ||
186 | } | ||
187 | |||
188 | *number_ptr = number; | ||
189 | return (string); | ||
190 | } | ||
191 | |||
192 | /******************************************************************************* | ||
193 | * | ||
194 | * FUNCTION: acpi_ut_print_number | ||
195 | * | ||
196 | * PARAMETERS: string - String buffer | ||
197 | * number - The number to be converted | ||
198 | * | ||
199 | * RETURN: Updated position for next valid character | ||
200 | * | ||
201 | * DESCRIPTION: Print a decimal integer into a string. | ||
202 | * | ||
203 | ******************************************************************************/ | ||
204 | |||
205 | const char *acpi_ut_print_number(char *string, u64 number) | ||
206 | { | ||
207 | char ascii_string[20]; | ||
208 | const char *pos1; | ||
209 | char *pos2; | ||
210 | |||
211 | pos1 = acpi_ut_put_number(ascii_string, number, 10, FALSE); | ||
212 | pos2 = string; | ||
213 | |||
214 | while (pos1 != ascii_string) { | ||
215 | *(pos2++) = *(--pos1); | ||
216 | } | ||
217 | |||
218 | *pos2 = 0; | ||
219 | return (string); | ||
220 | } | ||
221 | |||
222 | /******************************************************************************* | ||
223 | * | ||
224 | * FUNCTION: acpi_ut_format_number | ||
225 | * | ||
226 | * PARAMETERS: string - String buffer with boundary | ||
227 | * end - Boundary of the string | ||
228 | * number - The number to be converted | ||
229 | * base - Base of the integer | ||
230 | * width - Field width | ||
231 | * precision - Precision of the integer | ||
232 | * type - Special printing flags | ||
233 | * | ||
234 | * RETURN: Updated position for next valid character | ||
235 | * | ||
236 | * DESCRIPTION: Print an integer into a string with any base and any precision. | ||
237 | * | ||
238 | ******************************************************************************/ | ||
239 | |||
240 | static char *acpi_ut_format_number(char *string, | ||
241 | char *end, | ||
242 | u64 number, | ||
243 | u8 base, s32 width, s32 precision, u8 type) | ||
244 | { | ||
245 | char sign; | ||
246 | char zero; | ||
247 | u8 need_prefix; | ||
248 | u8 upper; | ||
249 | s32 i; | ||
250 | char reversed_string[66]; | ||
251 | |||
252 | /* Parameter validation */ | ||
253 | |||
254 | if (base < 2 || base > 16) { | ||
255 | return (NULL); | ||
256 | } | ||
257 | |||
258 | if (type & ACPI_FORMAT_LEFT) { | ||
259 | type &= ~ACPI_FORMAT_ZERO; | ||
260 | } | ||
261 | |||
262 | need_prefix = ((type & ACPI_FORMAT_PREFIX) | ||
263 | && base != 10) ? TRUE : FALSE; | ||
264 | upper = (type & ACPI_FORMAT_UPPER) ? TRUE : FALSE; | ||
265 | zero = (type & ACPI_FORMAT_ZERO) ? '0' : ' '; | ||
266 | |||
267 | /* Calculate size according to sign and prefix */ | ||
268 | |||
269 | sign = '\0'; | ||
270 | if (type & ACPI_FORMAT_SIGN) { | ||
271 | if ((s64) number < 0) { | ||
272 | sign = '-'; | ||
273 | number = -(s64) number; | ||
274 | width--; | ||
275 | } else if (type & ACPI_FORMAT_SIGN_PLUS) { | ||
276 | sign = '+'; | ||
277 | width--; | ||
278 | } else if (type & ACPI_FORMAT_SIGN_PLUS_SPACE) { | ||
279 | sign = ' '; | ||
280 | width--; | ||
281 | } | ||
282 | } | ||
283 | if (need_prefix) { | ||
284 | width--; | ||
285 | if (base == 16) { | ||
286 | width--; | ||
287 | } | ||
288 | } | ||
289 | |||
290 | /* Generate full string in reverse order */ | ||
291 | |||
292 | i = ACPI_PTR_DIFF(acpi_ut_put_number | ||
293 | (reversed_string, number, base, upper), | ||
294 | reversed_string); | ||
295 | |||
296 | /* Printing 100 using %2d gives "100", not "00" */ | ||
297 | |||
298 | if (i > precision) { | ||
299 | precision = i; | ||
300 | } | ||
301 | |||
302 | width -= precision; | ||
303 | |||
304 | /* Output the string */ | ||
305 | |||
306 | if (!(type & (ACPI_FORMAT_ZERO | ACPI_FORMAT_LEFT))) { | ||
307 | while (--width >= 0) { | ||
308 | string = acpi_ut_bound_string_output(string, end, ' '); | ||
309 | } | ||
310 | } | ||
311 | if (sign) { | ||
312 | string = acpi_ut_bound_string_output(string, end, sign); | ||
313 | } | ||
314 | if (need_prefix) { | ||
315 | string = acpi_ut_bound_string_output(string, end, '0'); | ||
316 | if (base == 16) { | ||
317 | string = acpi_ut_bound_string_output(string, end, | ||
318 | upper ? 'X' : 'x'); | ||
319 | } | ||
320 | } | ||
321 | if (!(type & ACPI_FORMAT_LEFT)) { | ||
322 | while (--width >= 0) { | ||
323 | string = acpi_ut_bound_string_output(string, end, zero); | ||
324 | } | ||
325 | } | ||
326 | |||
327 | while (i <= --precision) { | ||
328 | string = acpi_ut_bound_string_output(string, end, '0'); | ||
329 | } | ||
330 | while (--i >= 0) { | ||
331 | string = acpi_ut_bound_string_output(string, end, | ||
332 | reversed_string[i]); | ||
333 | } | ||
334 | while (--width >= 0) { | ||
335 | string = acpi_ut_bound_string_output(string, end, ' '); | ||
336 | } | ||
337 | |||
338 | return (string); | ||
339 | } | ||
340 | |||
341 | /******************************************************************************* | ||
342 | * | ||
343 | * FUNCTION: acpi_ut_vsnprintf | ||
344 | * | ||
345 | * PARAMETERS: string - String with boundary | ||
346 | * size - Boundary of the string | ||
347 | * format - Standard printf format | ||
348 | * args - Argument list | ||
349 | * | ||
350 | * RETURN: Number of bytes actually written. | ||
351 | * | ||
352 | * DESCRIPTION: Formatted output to a string using argument list pointer. | ||
353 | * | ||
354 | ******************************************************************************/ | ||
355 | |||
356 | int | ||
357 | acpi_ut_vsnprintf(char *string, | ||
358 | acpi_size size, const char *format, va_list args) | ||
359 | { | ||
360 | u8 base = 10; | ||
361 | u8 type = 0; | ||
362 | s32 width = -1; | ||
363 | s32 precision = -1; | ||
364 | char qualifier = 0; | ||
365 | u64 number; | ||
366 | char *pos; | ||
367 | char *end; | ||
368 | char c; | ||
369 | const char *s; | ||
370 | const void *p; | ||
371 | s32 length; | ||
372 | int i; | ||
373 | |||
374 | pos = string; | ||
375 | end = string + size; | ||
376 | |||
377 | for (; *format; ++format) { | ||
378 | if (*format != '%') { | ||
379 | pos = acpi_ut_bound_string_output(pos, end, *format); | ||
380 | continue; | ||
381 | } | ||
382 | |||
383 | /* Process sign */ | ||
384 | |||
385 | do { | ||
386 | ++format; | ||
387 | if (*format == '#') { | ||
388 | type |= ACPI_FORMAT_PREFIX; | ||
389 | } else if (*format == '0') { | ||
390 | type |= ACPI_FORMAT_ZERO; | ||
391 | } else if (*format == '+') { | ||
392 | type |= ACPI_FORMAT_SIGN_PLUS; | ||
393 | } else if (*format == ' ') { | ||
394 | type |= ACPI_FORMAT_SIGN_PLUS_SPACE; | ||
395 | } else if (*format == '-') { | ||
396 | type |= ACPI_FORMAT_LEFT; | ||
397 | } else { | ||
398 | break; | ||
399 | } | ||
400 | } while (1); | ||
401 | |||
402 | /* Process width */ | ||
403 | |||
404 | if (ACPI_IS_DIGIT(*format)) { | ||
405 | format = acpi_ut_scan_number(format, &number); | ||
406 | width = (s32) number; | ||
407 | } else if (*format == '*') { | ||
408 | ++format; | ||
409 | width = va_arg(args, int); | ||
410 | if (width < 0) { | ||
411 | width = -width; | ||
412 | type |= ACPI_FORMAT_LEFT; | ||
413 | } | ||
414 | } | ||
415 | |||
416 | /* Process precision */ | ||
417 | |||
418 | if (*format == '.') { | ||
419 | ++format; | ||
420 | if (ACPI_IS_DIGIT(*format)) { | ||
421 | format = acpi_ut_scan_number(format, &number); | ||
422 | precision = (s32) number; | ||
423 | } else if (*format == '*') { | ||
424 | ++format; | ||
425 | precision = va_arg(args, int); | ||
426 | } | ||
427 | if (precision < 0) { | ||
428 | precision = 0; | ||
429 | } | ||
430 | } | ||
431 | |||
432 | /* Process qualifier */ | ||
433 | |||
434 | if (*format == 'h' || *format == 'l' || *format == 'L') { | ||
435 | qualifier = *format; | ||
436 | ++format; | ||
437 | |||
438 | if (qualifier == 'l' && *format == 'l') { | ||
439 | qualifier = 'L'; | ||
440 | ++format; | ||
441 | } | ||
442 | } | ||
443 | |||
444 | switch (*format) { | ||
445 | case '%': | ||
446 | |||
447 | pos = acpi_ut_bound_string_output(pos, end, '%'); | ||
448 | continue; | ||
449 | |||
450 | case 'c': | ||
451 | |||
452 | if (!(type & ACPI_FORMAT_LEFT)) { | ||
453 | while (--width > 0) { | ||
454 | pos = | ||
455 | acpi_ut_bound_string_output(pos, | ||
456 | end, | ||
457 | ' '); | ||
458 | } | ||
459 | } | ||
460 | |||
461 | c = (char)va_arg(args, int); | ||
462 | pos = acpi_ut_bound_string_output(pos, end, c); | ||
463 | |||
464 | while (--width > 0) { | ||
465 | pos = | ||
466 | acpi_ut_bound_string_output(pos, end, ' '); | ||
467 | } | ||
468 | continue; | ||
469 | |||
470 | case 's': | ||
471 | |||
472 | s = va_arg(args, char *); | ||
473 | if (!s) { | ||
474 | s = "<NULL>"; | ||
475 | } | ||
476 | length = acpi_ut_bound_string_length(s, precision); | ||
477 | if (!(type & ACPI_FORMAT_LEFT)) { | ||
478 | while (length < width--) { | ||
479 | pos = | ||
480 | acpi_ut_bound_string_output(pos, | ||
481 | end, | ||
482 | ' '); | ||
483 | } | ||
484 | } | ||
485 | for (i = 0; i < length; ++i) { | ||
486 | pos = acpi_ut_bound_string_output(pos, end, *s); | ||
487 | ++s; | ||
488 | } | ||
489 | while (length < width--) { | ||
490 | pos = | ||
491 | acpi_ut_bound_string_output(pos, end, ' '); | ||
492 | } | ||
493 | continue; | ||
494 | |||
495 | case 'o': | ||
496 | |||
497 | base = 8; | ||
498 | break; | ||
499 | |||
500 | case 'X': | ||
501 | |||
502 | type |= ACPI_FORMAT_UPPER; | ||
503 | |||
504 | case 'x': | ||
505 | |||
506 | base = 16; | ||
507 | break; | ||
508 | |||
509 | case 'd': | ||
510 | case 'i': | ||
511 | |||
512 | type |= ACPI_FORMAT_SIGN; | ||
513 | |||
514 | case 'u': | ||
515 | |||
516 | break; | ||
517 | |||
518 | case 'p': | ||
519 | |||
520 | if (width == -1) { | ||
521 | width = 2 * sizeof(void *); | ||
522 | type |= ACPI_FORMAT_ZERO; | ||
523 | } | ||
524 | |||
525 | p = va_arg(args, void *); | ||
526 | pos = acpi_ut_format_number(pos, end, | ||
527 | ACPI_TO_INTEGER(p), 16, | ||
528 | width, precision, type); | ||
529 | continue; | ||
530 | |||
531 | default: | ||
532 | |||
533 | pos = acpi_ut_bound_string_output(pos, end, '%'); | ||
534 | if (*format) { | ||
535 | pos = | ||
536 | acpi_ut_bound_string_output(pos, end, | ||
537 | *format); | ||
538 | } else { | ||
539 | --format; | ||
540 | } | ||
541 | continue; | ||
542 | } | ||
543 | |||
544 | if (qualifier == 'L') { | ||
545 | number = va_arg(args, u64); | ||
546 | if (type & ACPI_FORMAT_SIGN) { | ||
547 | number = (s64) number; | ||
548 | } | ||
549 | } else if (qualifier == 'l') { | ||
550 | number = va_arg(args, unsigned long); | ||
551 | if (type & ACPI_FORMAT_SIGN) { | ||
552 | number = (s32) number; | ||
553 | } | ||
554 | } else if (qualifier == 'h') { | ||
555 | number = (u16)va_arg(args, int); | ||
556 | if (type & ACPI_FORMAT_SIGN) { | ||
557 | number = (s16) number; | ||
558 | } | ||
559 | } else { | ||
560 | number = va_arg(args, unsigned int); | ||
561 | if (type & ACPI_FORMAT_SIGN) { | ||
562 | number = (signed int)number; | ||
563 | } | ||
564 | } | ||
565 | |||
566 | pos = acpi_ut_format_number(pos, end, number, base, | ||
567 | width, precision, type); | ||
568 | } | ||
569 | |||
570 | if (size > 0) { | ||
571 | if (pos < end) { | ||
572 | *pos = '\0'; | ||
573 | } else { | ||
574 | end[-1] = '\0'; | ||
575 | } | ||
576 | } | ||
577 | |||
578 | return (ACPI_PTR_DIFF(pos, string)); | ||
579 | } | ||
580 | |||
581 | /******************************************************************************* | ||
582 | * | ||
583 | * FUNCTION: acpi_ut_snprintf | ||
584 | * | ||
585 | * PARAMETERS: string - String with boundary | ||
586 | * size - Boundary of the string | ||
587 | * Format, ... - Standard printf format | ||
588 | * | ||
589 | * RETURN: Number of bytes actually written. | ||
590 | * | ||
591 | * DESCRIPTION: Formatted output to a string. | ||
592 | * | ||
593 | ******************************************************************************/ | ||
594 | |||
595 | int acpi_ut_snprintf(char *string, acpi_size size, const char *format, ...) | ||
596 | { | ||
597 | va_list args; | ||
598 | int length; | ||
599 | |||
600 | va_start(args, format); | ||
601 | length = acpi_ut_vsnprintf(string, size, format, args); | ||
602 | va_end(args); | ||
603 | |||
604 | return (length); | ||
605 | } | ||
606 | |||
607 | #ifdef ACPI_APPLICATION | ||
608 | /******************************************************************************* | ||
609 | * | ||
610 | * FUNCTION: acpi_ut_file_vprintf | ||
611 | * | ||
612 | * PARAMETERS: file - File descriptor | ||
613 | * format - Standard printf format | ||
614 | * args - Argument list | ||
615 | * | ||
616 | * RETURN: Number of bytes actually written. | ||
617 | * | ||
618 | * DESCRIPTION: Formatted output to a file using argument list pointer. | ||
619 | * | ||
620 | ******************************************************************************/ | ||
621 | |||
622 | int acpi_ut_file_vprintf(ACPI_FILE file, const char *format, va_list args) | ||
623 | { | ||
624 | acpi_cpu_flags flags; | ||
625 | int length; | ||
626 | |||
627 | flags = acpi_os_acquire_lock(acpi_gbl_print_lock); | ||
628 | length = acpi_ut_vsnprintf(acpi_gbl_print_buffer, | ||
629 | sizeof(acpi_gbl_print_buffer), format, args); | ||
630 | |||
631 | (void)acpi_os_write_file(file, acpi_gbl_print_buffer, length, 1); | ||
632 | acpi_os_release_lock(acpi_gbl_print_lock, flags); | ||
633 | |||
634 | return (length); | ||
635 | } | ||
636 | |||
637 | /******************************************************************************* | ||
638 | * | ||
639 | * FUNCTION: acpi_ut_file_printf | ||
640 | * | ||
641 | * PARAMETERS: file - File descriptor | ||
642 | * Format, ... - Standard printf format | ||
643 | * | ||
644 | * RETURN: Number of bytes actually written. | ||
645 | * | ||
646 | * DESCRIPTION: Formatted output to a file. | ||
647 | * | ||
648 | ******************************************************************************/ | ||
649 | |||
650 | int acpi_ut_file_printf(ACPI_FILE file, const char *format, ...) | ||
651 | { | ||
652 | va_list args; | ||
653 | int length; | ||
654 | |||
655 | va_start(args, format); | ||
656 | length = acpi_ut_file_vprintf(file, format, args); | ||
657 | va_end(args); | ||
658 | |||
659 | return (length); | ||
660 | } | ||
661 | #endif | ||
diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h index e5bcd919d4e6..16129c78b489 100644 --- a/drivers/acpi/apei/apei-internal.h +++ b/drivers/acpi/apei/apei-internal.h | |||
@@ -121,11 +121,11 @@ struct dentry; | |||
121 | struct dentry *apei_get_debugfs_dir(void); | 121 | struct dentry *apei_get_debugfs_dir(void); |
122 | 122 | ||
123 | #define apei_estatus_for_each_section(estatus, section) \ | 123 | #define apei_estatus_for_each_section(estatus, section) \ |
124 | for (section = (struct acpi_generic_data *)(estatus + 1); \ | 124 | for (section = (struct acpi_hest_generic_data *)(estatus + 1); \ |
125 | (void *)section - (void *)estatus < estatus->data_length; \ | 125 | (void *)section - (void *)estatus < estatus->data_length; \ |
126 | section = (void *)(section+1) + section->error_data_length) | 126 | section = (void *)(section+1) + section->error_data_length) |
127 | 127 | ||
128 | static inline u32 cper_estatus_len(struct acpi_generic_status *estatus) | 128 | static inline u32 cper_estatus_len(struct acpi_hest_generic_status *estatus) |
129 | { | 129 | { |
130 | if (estatus->raw_data_length) | 130 | if (estatus->raw_data_length) |
131 | return estatus->raw_data_offset + \ | 131 | return estatus->raw_data_offset + \ |
@@ -135,9 +135,9 @@ static inline u32 cper_estatus_len(struct acpi_generic_status *estatus) | |||
135 | } | 135 | } |
136 | 136 | ||
137 | void cper_estatus_print(const char *pfx, | 137 | void cper_estatus_print(const char *pfx, |
138 | const struct acpi_generic_status *estatus); | 138 | const struct acpi_hest_generic_status *estatus); |
139 | int cper_estatus_check_header(const struct acpi_generic_status *estatus); | 139 | int cper_estatus_check_header(const struct acpi_hest_generic_status *estatus); |
140 | int cper_estatus_check(const struct acpi_generic_status *estatus); | 140 | int cper_estatus_check(const struct acpi_hest_generic_status *estatus); |
141 | 141 | ||
142 | int apei_osc_setup(void); | 142 | int apei_osc_setup(void); |
143 | #endif | 143 | #endif |
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index dab7cb7349df..7a38d1465b61 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c | |||
@@ -74,13 +74,13 @@ | |||
74 | #define GHES_ESTATUS_CACHE_LEN(estatus_len) \ | 74 | #define GHES_ESTATUS_CACHE_LEN(estatus_len) \ |
75 | (sizeof(struct ghes_estatus_cache) + (estatus_len)) | 75 | (sizeof(struct ghes_estatus_cache) + (estatus_len)) |
76 | #define GHES_ESTATUS_FROM_CACHE(estatus_cache) \ | 76 | #define GHES_ESTATUS_FROM_CACHE(estatus_cache) \ |
77 | ((struct acpi_generic_status *) \ | 77 | ((struct acpi_hest_generic_status *) \ |
78 | ((struct ghes_estatus_cache *)(estatus_cache) + 1)) | 78 | ((struct ghes_estatus_cache *)(estatus_cache) + 1)) |
79 | 79 | ||
80 | #define GHES_ESTATUS_NODE_LEN(estatus_len) \ | 80 | #define GHES_ESTATUS_NODE_LEN(estatus_len) \ |
81 | (sizeof(struct ghes_estatus_node) + (estatus_len)) | 81 | (sizeof(struct ghes_estatus_node) + (estatus_len)) |
82 | #define GHES_ESTATUS_FROM_NODE(estatus_node) \ | 82 | #define GHES_ESTATUS_FROM_NODE(estatus_node) \ |
83 | ((struct acpi_generic_status *) \ | 83 | ((struct acpi_hest_generic_status *) \ |
84 | ((struct ghes_estatus_node *)(estatus_node) + 1)) | 84 | ((struct ghes_estatus_node *)(estatus_node) + 1)) |
85 | 85 | ||
86 | bool ghes_disable; | 86 | bool ghes_disable; |
@@ -408,7 +408,7 @@ static void ghes_clear_estatus(struct ghes *ghes) | |||
408 | ghes->flags &= ~GHES_TO_CLEAR; | 408 | ghes->flags &= ~GHES_TO_CLEAR; |
409 | } | 409 | } |
410 | 410 | ||
411 | static void ghes_handle_memory_failure(struct acpi_generic_data *gdata, int sev) | 411 | static void ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata, int sev) |
412 | { | 412 | { |
413 | #ifdef CONFIG_ACPI_APEI_MEMORY_FAILURE | 413 | #ifdef CONFIG_ACPI_APEI_MEMORY_FAILURE |
414 | unsigned long pfn; | 414 | unsigned long pfn; |
@@ -441,10 +441,10 @@ static void ghes_handle_memory_failure(struct acpi_generic_data *gdata, int sev) | |||
441 | } | 441 | } |
442 | 442 | ||
443 | static void ghes_do_proc(struct ghes *ghes, | 443 | static void ghes_do_proc(struct ghes *ghes, |
444 | const struct acpi_generic_status *estatus) | 444 | const struct acpi_hest_generic_status *estatus) |
445 | { | 445 | { |
446 | int sev, sec_sev; | 446 | int sev, sec_sev; |
447 | struct acpi_generic_data *gdata; | 447 | struct acpi_hest_generic_data *gdata; |
448 | 448 | ||
449 | sev = ghes_severity(estatus->error_severity); | 449 | sev = ghes_severity(estatus->error_severity); |
450 | apei_estatus_for_each_section(estatus, gdata) { | 450 | apei_estatus_for_each_section(estatus, gdata) { |
@@ -498,7 +498,7 @@ static void ghes_do_proc(struct ghes *ghes, | |||
498 | 498 | ||
499 | static void __ghes_print_estatus(const char *pfx, | 499 | static void __ghes_print_estatus(const char *pfx, |
500 | const struct acpi_hest_generic *generic, | 500 | const struct acpi_hest_generic *generic, |
501 | const struct acpi_generic_status *estatus) | 501 | const struct acpi_hest_generic_status *estatus) |
502 | { | 502 | { |
503 | static atomic_t seqno; | 503 | static atomic_t seqno; |
504 | unsigned int curr_seqno; | 504 | unsigned int curr_seqno; |
@@ -520,7 +520,7 @@ static void __ghes_print_estatus(const char *pfx, | |||
520 | 520 | ||
521 | static int ghes_print_estatus(const char *pfx, | 521 | static int ghes_print_estatus(const char *pfx, |
522 | const struct acpi_hest_generic *generic, | 522 | const struct acpi_hest_generic *generic, |
523 | const struct acpi_generic_status *estatus) | 523 | const struct acpi_hest_generic_status *estatus) |
524 | { | 524 | { |
525 | /* Not more than 2 messages every 5 seconds */ | 525 | /* Not more than 2 messages every 5 seconds */ |
526 | static DEFINE_RATELIMIT_STATE(ratelimit_corrected, 5*HZ, 2); | 526 | static DEFINE_RATELIMIT_STATE(ratelimit_corrected, 5*HZ, 2); |
@@ -542,13 +542,13 @@ static int ghes_print_estatus(const char *pfx, | |||
542 | * GHES error status reporting throttle, to report more kinds of | 542 | * GHES error status reporting throttle, to report more kinds of |
543 | * errors, instead of just most frequently occurred errors. | 543 | * errors, instead of just most frequently occurred errors. |
544 | */ | 544 | */ |
545 | static int ghes_estatus_cached(struct acpi_generic_status *estatus) | 545 | static int ghes_estatus_cached(struct acpi_hest_generic_status *estatus) |
546 | { | 546 | { |
547 | u32 len; | 547 | u32 len; |
548 | int i, cached = 0; | 548 | int i, cached = 0; |
549 | unsigned long long now; | 549 | unsigned long long now; |
550 | struct ghes_estatus_cache *cache; | 550 | struct ghes_estatus_cache *cache; |
551 | struct acpi_generic_status *cache_estatus; | 551 | struct acpi_hest_generic_status *cache_estatus; |
552 | 552 | ||
553 | len = cper_estatus_len(estatus); | 553 | len = cper_estatus_len(estatus); |
554 | rcu_read_lock(); | 554 | rcu_read_lock(); |
@@ -573,12 +573,12 @@ static int ghes_estatus_cached(struct acpi_generic_status *estatus) | |||
573 | 573 | ||
574 | static struct ghes_estatus_cache *ghes_estatus_cache_alloc( | 574 | static struct ghes_estatus_cache *ghes_estatus_cache_alloc( |
575 | struct acpi_hest_generic *generic, | 575 | struct acpi_hest_generic *generic, |
576 | struct acpi_generic_status *estatus) | 576 | struct acpi_hest_generic_status *estatus) |
577 | { | 577 | { |
578 | int alloced; | 578 | int alloced; |
579 | u32 len, cache_len; | 579 | u32 len, cache_len; |
580 | struct ghes_estatus_cache *cache; | 580 | struct ghes_estatus_cache *cache; |
581 | struct acpi_generic_status *cache_estatus; | 581 | struct acpi_hest_generic_status *cache_estatus; |
582 | 582 | ||
583 | alloced = atomic_add_return(1, &ghes_estatus_cache_alloced); | 583 | alloced = atomic_add_return(1, &ghes_estatus_cache_alloced); |
584 | if (alloced > GHES_ESTATUS_CACHE_ALLOCED_MAX) { | 584 | if (alloced > GHES_ESTATUS_CACHE_ALLOCED_MAX) { |
@@ -621,7 +621,7 @@ static void ghes_estatus_cache_rcu_free(struct rcu_head *head) | |||
621 | 621 | ||
622 | static void ghes_estatus_cache_add( | 622 | static void ghes_estatus_cache_add( |
623 | struct acpi_hest_generic *generic, | 623 | struct acpi_hest_generic *generic, |
624 | struct acpi_generic_status *estatus) | 624 | struct acpi_hest_generic_status *estatus) |
625 | { | 625 | { |
626 | int i, slot = -1, count; | 626 | int i, slot = -1, count; |
627 | unsigned long long now, duration, period, max_period = 0; | 627 | 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 | struct llist_node *llnode, *next; | 753 | struct llist_node *llnode, *next; |
754 | struct ghes_estatus_node *estatus_node; | 754 | struct ghes_estatus_node *estatus_node; |
755 | struct acpi_hest_generic *generic; | 755 | struct acpi_hest_generic *generic; |
756 | struct acpi_generic_status *estatus; | 756 | struct acpi_hest_generic_status *estatus; |
757 | u32 len, node_len; | 757 | u32 len, node_len; |
758 | 758 | ||
759 | llnode = llist_del_all(&ghes_estatus_llist); | 759 | llnode = llist_del_all(&ghes_estatus_llist); |
@@ -786,7 +786,7 @@ static void ghes_print_queued_estatus(void) | |||
786 | struct llist_node *llnode; | 786 | struct llist_node *llnode; |
787 | struct ghes_estatus_node *estatus_node; | 787 | struct ghes_estatus_node *estatus_node; |
788 | struct acpi_hest_generic *generic; | 788 | struct acpi_hest_generic *generic; |
789 | struct acpi_generic_status *estatus; | 789 | struct acpi_hest_generic_status *estatus; |
790 | u32 len, node_len; | 790 | u32 len, node_len; |
791 | 791 | ||
792 | llnode = llist_del_all(&ghes_estatus_llist); | 792 | llnode = llist_del_all(&ghes_estatus_llist); |
@@ -845,7 +845,7 @@ static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs) | |||
845 | #ifdef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG | 845 | #ifdef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG |
846 | u32 len, node_len; | 846 | u32 len, node_len; |
847 | struct ghes_estatus_node *estatus_node; | 847 | struct ghes_estatus_node *estatus_node; |
848 | struct acpi_generic_status *estatus; | 848 | struct acpi_hest_generic_status *estatus; |
849 | #endif | 849 | #endif |
850 | if (!(ghes->flags & GHES_TO_CLEAR)) | 850 | if (!(ghes->flags & GHES_TO_CLEAR)) |
851 | continue; | 851 | continue; |
@@ -925,7 +925,7 @@ static int ghes_probe(struct platform_device *ghes_dev) | |||
925 | 925 | ||
926 | rc = -EIO; | 926 | rc = -EIO; |
927 | if (generic->error_block_length < | 927 | if (generic->error_block_length < |
928 | sizeof(struct acpi_generic_status)) { | 928 | sizeof(struct acpi_hest_generic_status)) { |
929 | pr_warning(FW_BUG GHES_PFX "Invalid error block length: %u for generic hardware error source: %d\n", | 929 | pr_warning(FW_BUG GHES_PFX "Invalid error block length: %u for generic hardware error source: %d\n", |
930 | generic->error_block_length, | 930 | generic->error_block_length, |
931 | generic->header.source_id); | 931 | generic->header.source_id); |
diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c index 1491dd4f08f9..65f2f3fdde24 100644 --- a/drivers/firmware/efi/cper.c +++ b/drivers/firmware/efi/cper.c | |||
@@ -262,7 +262,7 @@ static const char *cper_pcie_port_type_strs[] = { | |||
262 | }; | 262 | }; |
263 | 263 | ||
264 | static void cper_print_pcie(const char *pfx, const struct cper_sec_pcie *pcie, | 264 | static void cper_print_pcie(const char *pfx, const struct cper_sec_pcie *pcie, |
265 | const struct acpi_generic_data *gdata) | 265 | const struct acpi_hest_generic_data *gdata) |
266 | { | 266 | { |
267 | if (pcie->validation_bits & CPER_PCIE_VALID_PORT_TYPE) | 267 | if (pcie->validation_bits & CPER_PCIE_VALID_PORT_TYPE) |
268 | printk("%s""port_type: %d, %s\n", pfx, pcie->port_type, | 268 | 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 | } | 298 | } |
299 | 299 | ||
300 | static void cper_estatus_print_section( | 300 | static void cper_estatus_print_section( |
301 | const char *pfx, const struct acpi_generic_data *gdata, int sec_no) | 301 | const char *pfx, const struct acpi_hest_generic_data *gdata, int sec_no) |
302 | { | 302 | { |
303 | uuid_le *sec_type = (uuid_le *)gdata->section_type; | 303 | uuid_le *sec_type = (uuid_le *)gdata->section_type; |
304 | __u16 severity; | 304 | __u16 severity; |
@@ -344,9 +344,9 @@ err_section_too_small: | |||
344 | } | 344 | } |
345 | 345 | ||
346 | void cper_estatus_print(const char *pfx, | 346 | void cper_estatus_print(const char *pfx, |
347 | const struct acpi_generic_status *estatus) | 347 | const struct acpi_hest_generic_status *estatus) |
348 | { | 348 | { |
349 | struct acpi_generic_data *gdata; | 349 | struct acpi_hest_generic_data *gdata; |
350 | unsigned int data_len, gedata_len; | 350 | unsigned int data_len, gedata_len; |
351 | int sec_no = 0; | 351 | int sec_no = 0; |
352 | char newpfx[64]; | 352 | char newpfx[64]; |
@@ -359,7 +359,7 @@ void cper_estatus_print(const char *pfx, | |||
359 | "and requires no further action"); | 359 | "and requires no further action"); |
360 | printk("%s""event severity: %s\n", pfx, cper_severity_str(severity)); | 360 | printk("%s""event severity: %s\n", pfx, cper_severity_str(severity)); |
361 | data_len = estatus->data_length; | 361 | data_len = estatus->data_length; |
362 | gdata = (struct acpi_generic_data *)(estatus + 1); | 362 | gdata = (struct acpi_hest_generic_data *)(estatus + 1); |
363 | snprintf(newpfx, sizeof(newpfx), "%s%s", pfx, INDENT_SP); | 363 | snprintf(newpfx, sizeof(newpfx), "%s%s", pfx, INDENT_SP); |
364 | while (data_len >= sizeof(*gdata)) { | 364 | while (data_len >= sizeof(*gdata)) { |
365 | gedata_len = gdata->error_data_length; | 365 | gedata_len = gdata->error_data_length; |
@@ -371,10 +371,10 @@ void cper_estatus_print(const char *pfx, | |||
371 | } | 371 | } |
372 | EXPORT_SYMBOL_GPL(cper_estatus_print); | 372 | EXPORT_SYMBOL_GPL(cper_estatus_print); |
373 | 373 | ||
374 | int cper_estatus_check_header(const struct acpi_generic_status *estatus) | 374 | int cper_estatus_check_header(const struct acpi_hest_generic_status *estatus) |
375 | { | 375 | { |
376 | if (estatus->data_length && | 376 | if (estatus->data_length && |
377 | estatus->data_length < sizeof(struct acpi_generic_data)) | 377 | estatus->data_length < sizeof(struct acpi_hest_generic_data)) |
378 | return -EINVAL; | 378 | return -EINVAL; |
379 | if (estatus->raw_data_length && | 379 | if (estatus->raw_data_length && |
380 | estatus->raw_data_offset < sizeof(*estatus) + estatus->data_length) | 380 | 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 | } | 384 | } |
385 | EXPORT_SYMBOL_GPL(cper_estatus_check_header); | 385 | EXPORT_SYMBOL_GPL(cper_estatus_check_header); |
386 | 386 | ||
387 | int cper_estatus_check(const struct acpi_generic_status *estatus) | 387 | int cper_estatus_check(const struct acpi_hest_generic_status *estatus) |
388 | { | 388 | { |
389 | struct acpi_generic_data *gdata; | 389 | struct acpi_hest_generic_data *gdata; |
390 | unsigned int data_len, gedata_len; | 390 | unsigned int data_len, gedata_len; |
391 | int rc; | 391 | int rc; |
392 | 392 | ||
@@ -394,7 +394,7 @@ int cper_estatus_check(const struct acpi_generic_status *estatus) | |||
394 | if (rc) | 394 | if (rc) |
395 | return rc; | 395 | return rc; |
396 | data_len = estatus->data_length; | 396 | data_len = estatus->data_length; |
397 | gdata = (struct acpi_generic_data *)(estatus + 1); | 397 | gdata = (struct acpi_hest_generic_data *)(estatus + 1); |
398 | while (data_len >= sizeof(*gdata)) { | 398 | while (data_len >= sizeof(*gdata)) { |
399 | gedata_len = gdata->error_data_length; | 399 | gedata_len = gdata->error_data_length; |
400 | if (gedata_len > data_len - sizeof(*gdata)) | 400 | if (gedata_len > data_len - sizeof(*gdata)) |
diff --git a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h index f6f5f8af2112..03b3e6d405ff 100644 --- a/include/acpi/acpiosxf.h +++ b/include/acpi/acpiosxf.h | |||
@@ -399,4 +399,35 @@ char *acpi_os_get_next_filename(void *dir_handle); | |||
399 | void acpi_os_close_directory(void *dir_handle); | 399 | void acpi_os_close_directory(void *dir_handle); |
400 | #endif | 400 | #endif |
401 | 401 | ||
402 | /* | ||
403 | * File I/O and related support | ||
404 | */ | ||
405 | #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_open_file | ||
406 | ACPI_FILE acpi_os_open_file(const char *path, u8 modes); | ||
407 | #endif | ||
408 | |||
409 | #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_close_file | ||
410 | void acpi_os_close_file(ACPI_FILE file); | ||
411 | #endif | ||
412 | |||
413 | #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_read_file | ||
414 | int | ||
415 | acpi_os_read_file(ACPI_FILE file, | ||
416 | void *buffer, acpi_size size, acpi_size count); | ||
417 | #endif | ||
418 | |||
419 | #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_write_file | ||
420 | int | ||
421 | acpi_os_write_file(ACPI_FILE file, | ||
422 | void *buffer, acpi_size size, acpi_size count); | ||
423 | #endif | ||
424 | |||
425 | #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_file_offset | ||
426 | long acpi_os_get_file_offset(ACPI_FILE file); | ||
427 | #endif | ||
428 | |||
429 | #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_set_file_offset | ||
430 | acpi_status acpi_os_set_file_offset(ACPI_FILE file, long offset, u8 from); | ||
431 | #endif | ||
432 | |||
402 | #endif /* __ACPIOSXF_H__ */ | 433 | #endif /* __ACPIOSXF_H__ */ |
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h index 35b525c19711..508e5649dda9 100644 --- a/include/acpi/acpixf.h +++ b/include/acpi/acpixf.h | |||
@@ -46,7 +46,7 @@ | |||
46 | 46 | ||
47 | /* Current ACPICA subsystem version in YYYYMMDD format */ | 47 | /* Current ACPICA subsystem version in YYYYMMDD format */ |
48 | 48 | ||
49 | #define ACPI_CA_VERSION 0x20140424 | 49 | #define ACPI_CA_VERSION 0x20140627 |
50 | 50 | ||
51 | #include <acpi/acconfig.h> | 51 | #include <acpi/acconfig.h> |
52 | #include <acpi/actypes.h> | 52 | #include <acpi/actypes.h> |
@@ -335,6 +335,23 @@ ACPI_GLOBAL(u8, acpi_gbl_system_awake_and_running); | |||
335 | 335 | ||
336 | #endif /* ACPI_DEBUG_OUTPUT */ | 336 | #endif /* ACPI_DEBUG_OUTPUT */ |
337 | 337 | ||
338 | /* | ||
339 | * Application prototypes | ||
340 | * | ||
341 | * All interfaces used by application will be configured | ||
342 | * out of the ACPICA build unless the ACPI_APPLICATION | ||
343 | * flag is defined. | ||
344 | */ | ||
345 | #ifdef ACPI_APPLICATION | ||
346 | #define ACPI_APP_DEPENDENT_RETURN_VOID(prototype) \ | ||
347 | prototype; | ||
348 | |||
349 | #else | ||
350 | #define ACPI_APP_DEPENDENT_RETURN_VOID(prototype) \ | ||
351 | static ACPI_INLINE prototype {return;} | ||
352 | |||
353 | #endif /* ACPI_APPLICATION */ | ||
354 | |||
338 | /***************************************************************************** | 355 | /***************************************************************************** |
339 | * | 356 | * |
340 | * ACPICA public interface prototypes | 357 | * ACPICA public interface prototypes |
@@ -658,6 +675,10 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status | |||
658 | u32 gpe_number)) | 675 | u32 gpe_number)) |
659 | 676 | ||
660 | ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status | 677 | ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status |
678 | acpi_mark_gpe_for_wake(acpi_handle gpe_device, | ||
679 | u32 gpe_number)) | ||
680 | |||
681 | ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status | ||
661 | acpi_setup_gpe_for_wake(acpi_handle | 682 | acpi_setup_gpe_for_wake(acpi_handle |
662 | parent_device, | 683 | parent_device, |
663 | acpi_handle gpe_device, | 684 | acpi_handle gpe_device, |
@@ -861,6 +882,9 @@ ACPI_DBG_DEPENDENT_RETURN_VOID(ACPI_PRINTF_LIKE(6) | |||
861 | const char *module_name, | 882 | const char *module_name, |
862 | u32 component_id, | 883 | u32 component_id, |
863 | const char *format, ...)) | 884 | const char *format, ...)) |
885 | ACPI_APP_DEPENDENT_RETURN_VOID(ACPI_PRINTF_LIKE(1) | ||
886 | void ACPI_INTERNAL_VAR_XFACE | ||
887 | acpi_log_error(const char *format, ...)) | ||
864 | 888 | ||
865 | /* | 889 | /* |
866 | * Divergences | 890 | * Divergences |
diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h index 4ad7da805180..9613e8e97960 100644 --- a/include/acpi/actbl1.h +++ b/include/acpi/actbl1.h | |||
@@ -604,7 +604,7 @@ struct acpi_hest_generic { | |||
604 | 604 | ||
605 | /* Generic Error Status block */ | 605 | /* Generic Error Status block */ |
606 | 606 | ||
607 | struct acpi_generic_status { | 607 | struct acpi_hest_generic_status { |
608 | u32 block_status; | 608 | u32 block_status; |
609 | u32 raw_data_offset; | 609 | u32 raw_data_offset; |
610 | u32 raw_data_length; | 610 | u32 raw_data_length; |
@@ -614,15 +614,15 @@ struct acpi_generic_status { | |||
614 | 614 | ||
615 | /* Values for block_status flags above */ | 615 | /* Values for block_status flags above */ |
616 | 616 | ||
617 | #define ACPI_GEN_ERR_UC BIT(0) | 617 | #define ACPI_HEST_UNCORRECTABLE (1) |
618 | #define ACPI_GEN_ERR_CE BIT(1) | 618 | #define ACPI_HEST_CORRECTABLE (1<<1) |
619 | #define ACPI_GEN_ERR_MULTI_UC BIT(2) | 619 | #define ACPI_HEST_MULTIPLE_UNCORRECTABLE (1<<2) |
620 | #define ACPI_GEN_ERR_MULTI_CE BIT(3) | 620 | #define ACPI_HEST_MULTIPLE_CORRECTABLE (1<<3) |
621 | #define ACPI_GEN_ERR_COUNT_SHIFT (0xFF<<4) /* 8 bits, error count */ | 621 | #define ACPI_HEST_ERROR_ENTRY_COUNT (0xFF<<4) /* 8 bits, error count */ |
622 | 622 | ||
623 | /* Generic Error Data entry */ | 623 | /* Generic Error Data entry */ |
624 | 624 | ||
625 | struct acpi_generic_data { | 625 | struct acpi_hest_generic_data { |
626 | u8 section_type[16]; | 626 | u8 section_type[16]; |
627 | u32 error_severity; | 627 | u32 error_severity; |
628 | u16 revision; | 628 | u16 revision; |
diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h index 860e5c883eb3..21314d37cb07 100644 --- a/include/acpi/actbl2.h +++ b/include/acpi/actbl2.h | |||
@@ -516,7 +516,7 @@ struct acpi_dmar_andd { | |||
516 | struct acpi_dmar_header header; | 516 | struct acpi_dmar_header header; |
517 | u8 reserved[3]; | 517 | u8 reserved[3]; |
518 | u8 device_number; | 518 | u8 device_number; |
519 | u8 object_name[]; | 519 | char object_name[1]; |
520 | }; | 520 | }; |
521 | 521 | ||
522 | /******************************************************************************* | 522 | /******************************************************************************* |
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index 19b26bb69a70..608a04019372 100644 --- a/include/acpi/actypes.h +++ b/include/acpi/actypes.h | |||
@@ -126,6 +126,7 @@ | |||
126 | typedef unsigned char u8; | 126 | typedef unsigned char u8; |
127 | typedef unsigned char u8; | 127 | typedef unsigned char u8; |
128 | typedef unsigned short u16; | 128 | typedef unsigned short u16; |
129 | typedef short s16; | ||
129 | typedef COMPILER_DEPENDENT_UINT64 u64; | 130 | typedef COMPILER_DEPENDENT_UINT64 u64; |
130 | typedef COMPILER_DEPENDENT_INT64 s64; | 131 | typedef COMPILER_DEPENDENT_INT64 s64; |
131 | 132 | ||
@@ -1244,4 +1245,17 @@ struct acpi_memory_list { | |||
1244 | #define ACPI_OSI_WIN_7 0x0B | 1245 | #define ACPI_OSI_WIN_7 0x0B |
1245 | #define ACPI_OSI_WIN_8 0x0C | 1246 | #define ACPI_OSI_WIN_8 0x0C |
1246 | 1247 | ||
1248 | /* Definitions of file IO */ | ||
1249 | |||
1250 | #define ACPI_FILE_READING 0x01 | ||
1251 | #define ACPI_FILE_WRITING 0x02 | ||
1252 | #define ACPI_FILE_BINARY 0x04 | ||
1253 | |||
1254 | #define ACPI_FILE_BEGIN 0x01 | ||
1255 | #define ACPI_FILE_END 0x02 | ||
1256 | |||
1257 | /* Definitions of getopt */ | ||
1258 | |||
1259 | #define ACPI_OPT_END -1 | ||
1260 | |||
1247 | #endif /* __ACTYPES_H__ */ | 1261 | #endif /* __ACTYPES_H__ */ |
diff --git a/include/acpi/ghes.h b/include/acpi/ghes.h index dfd60d0bfd27..720446cb243e 100644 --- a/include/acpi/ghes.h +++ b/include/acpi/ghes.h | |||
@@ -14,7 +14,7 @@ | |||
14 | 14 | ||
15 | struct ghes { | 15 | struct ghes { |
16 | struct acpi_hest_generic *generic; | 16 | struct acpi_hest_generic *generic; |
17 | struct acpi_generic_status *estatus; | 17 | struct acpi_hest_generic_status *estatus; |
18 | u64 buffer_paddr; | 18 | u64 buffer_paddr; |
19 | unsigned long flags; | 19 | unsigned long flags; |
20 | union { | 20 | union { |
diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h index e863dd5c4e04..5f8cc1fa3278 100644 --- a/include/acpi/platform/acenv.h +++ b/include/acpi/platform/acenv.h | |||
@@ -87,20 +87,14 @@ | |||
87 | #define ACPI_DBG_TRACK_ALLOCATIONS | 87 | #define ACPI_DBG_TRACK_ALLOCATIONS |
88 | #endif | 88 | #endif |
89 | 89 | ||
90 | /* acpi_names configuration. Single threaded with debugger output enabled. */ | ||
91 | |||
92 | #ifdef ACPI_NAMES_APP | ||
93 | #define ACPI_DEBUGGER | ||
94 | #define ACPI_APPLICATION | ||
95 | #define ACPI_SINGLE_THREADED | ||
96 | #endif | ||
97 | |||
98 | /* | 90 | /* |
99 | * acpi_bin/acpi_dump/acpi_src/acpi_xtract/Example configuration. All single | 91 | * acpi_bin/acpi_dump/acpi_help/acpi_names/acpi_src/acpi_xtract/Example configuration. |
100 | * threaded, with no debug output. | 92 | * All single threaded. |
101 | */ | 93 | */ |
102 | #if (defined ACPI_BIN_APP) || \ | 94 | #if (defined ACPI_BIN_APP) || \ |
103 | (defined ACPI_DUMP_APP) || \ | 95 | (defined ACPI_DUMP_APP) || \ |
96 | (defined ACPI_HELP_APP) || \ | ||
97 | (defined ACPI_NAMES_APP) || \ | ||
104 | (defined ACPI_SRC_APP) || \ | 98 | (defined ACPI_SRC_APP) || \ |
105 | (defined ACPI_XTRACT_APP) || \ | 99 | (defined ACPI_XTRACT_APP) || \ |
106 | (defined ACPI_EXAMPLE_APP) | 100 | (defined ACPI_EXAMPLE_APP) |
@@ -108,12 +102,40 @@ | |||
108 | #define ACPI_SINGLE_THREADED | 102 | #define ACPI_SINGLE_THREADED |
109 | #endif | 103 | #endif |
110 | 104 | ||
105 | /* acpi_help configuration. Error messages disabled. */ | ||
106 | |||
111 | #ifdef ACPI_HELP_APP | 107 | #ifdef ACPI_HELP_APP |
112 | #define ACPI_APPLICATION | ||
113 | #define ACPI_SINGLE_THREADED | ||
114 | #define ACPI_NO_ERROR_MESSAGES | 108 | #define ACPI_NO_ERROR_MESSAGES |
115 | #endif | 109 | #endif |
116 | 110 | ||
111 | /* acpi_names configuration. Debug output enabled. */ | ||
112 | |||
113 | #ifdef ACPI_NAMES_APP | ||
114 | #define ACPI_DEBUG_OUTPUT | ||
115 | #endif | ||
116 | |||
117 | /* acpi_exec/acpi_names/Example configuration. Native RSDP used. */ | ||
118 | |||
119 | #if (defined ACPI_EXEC_APP) || \ | ||
120 | (defined ACPI_EXAMPLE_APP) || \ | ||
121 | (defined ACPI_NAMES_APP) | ||
122 | #define ACPI_USE_NATIVE_RSDP_POINTER | ||
123 | #endif | ||
124 | |||
125 | /* acpi_dump configuration. Native mapping used if provied by OSPMs */ | ||
126 | |||
127 | #ifdef ACPI_DUMP_APP | ||
128 | #define ACPI_USE_NATIVE_MEMORY_MAPPING | ||
129 | #define USE_NATIVE_ALLOCATE_ZEROED | ||
130 | #endif | ||
131 | |||
132 | /* acpi_names/Example configuration. Hardware disabled */ | ||
133 | |||
134 | #if (defined ACPI_EXAMPLE_APP) || \ | ||
135 | (defined ACPI_NAMES_APP) | ||
136 | #define ACPI_REDUCED_HARDWARE 1 | ||
137 | #endif | ||
138 | |||
117 | /* Linkable ACPICA library */ | 139 | /* Linkable ACPICA library */ |
118 | 140 | ||
119 | #ifdef ACPI_LIBRARY | 141 | #ifdef ACPI_LIBRARY |
@@ -185,6 +207,9 @@ | |||
185 | #elif defined(_AED_EFI) | 207 | #elif defined(_AED_EFI) |
186 | #include "acefi.h" | 208 | #include "acefi.h" |
187 | 209 | ||
210 | #elif defined(_GNU_EFI) | ||
211 | #include "acefi.h" | ||
212 | |||
188 | #elif defined(__HAIKU__) | 213 | #elif defined(__HAIKU__) |
189 | #include "achaiku.h" | 214 | #include "achaiku.h" |
190 | 215 | ||
@@ -399,8 +424,12 @@ typedef char *va_list; | |||
399 | #ifdef ACPI_APPLICATION | 424 | #ifdef ACPI_APPLICATION |
400 | #include <stdio.h> | 425 | #include <stdio.h> |
401 | #define ACPI_FILE FILE * | 426 | #define ACPI_FILE FILE * |
427 | #define ACPI_FILE_OUT stdout | ||
428 | #define ACPI_FILE_ERR stderr | ||
402 | #else | 429 | #else |
403 | #define ACPI_FILE void * | 430 | #define ACPI_FILE void * |
431 | #define ACPI_FILE_OUT NULL | ||
432 | #define ACPI_FILE_ERR NULL | ||
404 | #endif /* ACPI_APPLICATION */ | 433 | #endif /* ACPI_APPLICATION */ |
405 | #endif /* ACPI_FILE */ | 434 | #endif /* ACPI_FILE */ |
406 | 435 | ||
diff --git a/tools/power/acpi/Makefile b/tools/power/acpi/Makefile index e5a3c4be2a10..3d1537b93c64 100644 --- a/tools/power/acpi/Makefile +++ b/tools/power/acpi/Makefile | |||
@@ -108,13 +108,18 @@ DUMP_OBJS = \ | |||
108 | apmain.o\ | 108 | apmain.o\ |
109 | osunixdir.o\ | 109 | osunixdir.o\ |
110 | osunixmap.o\ | 110 | osunixmap.o\ |
111 | osunixxf.o\ | ||
111 | tbprint.o\ | 112 | tbprint.o\ |
112 | tbxfroot.o\ | 113 | tbxfroot.o\ |
113 | utbuffer.o\ | 114 | utbuffer.o\ |
115 | utdebug.o\ | ||
114 | utexcep.o\ | 116 | utexcep.o\ |
117 | utglobal.o\ | ||
115 | utmath.o\ | 118 | utmath.o\ |
119 | utprint.o\ | ||
116 | utstring.o\ | 120 | utstring.o\ |
117 | utxferror.o\ | 121 | utxferror.o\ |
122 | oslibcfs.o\ | ||
118 | oslinuxtbl.o\ | 123 | oslinuxtbl.o\ |
119 | cmfsize.o\ | 124 | cmfsize.o\ |
120 | getopt.o | 125 | getopt.o |
diff --git a/tools/power/acpi/common/cmfsize.c b/tools/power/acpi/common/cmfsize.c index 5140e5edae1f..f4b953354ff7 100644 --- a/tools/power/acpi/common/cmfsize.c +++ b/tools/power/acpi/common/cmfsize.c | |||
@@ -58,44 +58,46 @@ ACPI_MODULE_NAME("cmfsize") | |||
58 | * RETURN: File Size. On error, -1 (ACPI_UINT32_MAX) | 58 | * RETURN: File Size. On error, -1 (ACPI_UINT32_MAX) |
59 | * | 59 | * |
60 | * DESCRIPTION: Get the size of a file. Uses seek-to-EOF. File must be open. | 60 | * DESCRIPTION: Get the size of a file. Uses seek-to-EOF. File must be open. |
61 | * Does not disturb the current file pointer. Uses perror for | 61 | * Does not disturb the current file pointer. |
62 | * error messages. | ||
63 | * | 62 | * |
64 | ******************************************************************************/ | 63 | ******************************************************************************/ |
65 | u32 cm_get_file_size(FILE * file) | 64 | u32 cm_get_file_size(ACPI_FILE file) |
66 | { | 65 | { |
67 | long file_size; | 66 | long file_size; |
68 | long current_offset; | 67 | long current_offset; |
68 | acpi_status status; | ||
69 | 69 | ||
70 | /* Save the current file pointer, seek to EOF to obtain file size */ | 70 | /* Save the current file pointer, seek to EOF to obtain file size */ |
71 | 71 | ||
72 | current_offset = ftell(file); | 72 | current_offset = acpi_os_get_file_offset(file); |
73 | if (current_offset < 0) { | 73 | if (current_offset < 0) { |
74 | goto offset_error; | 74 | goto offset_error; |
75 | } | 75 | } |
76 | 76 | ||
77 | if (fseek(file, 0, SEEK_END)) { | 77 | status = acpi_os_set_file_offset(file, 0, ACPI_FILE_END); |
78 | if (ACPI_FAILURE(status)) { | ||
78 | goto seek_error; | 79 | goto seek_error; |
79 | } | 80 | } |
80 | 81 | ||
81 | file_size = ftell(file); | 82 | file_size = acpi_os_get_file_offset(file); |
82 | if (file_size < 0) { | 83 | if (file_size < 0) { |
83 | goto offset_error; | 84 | goto offset_error; |
84 | } | 85 | } |
85 | 86 | ||
86 | /* Restore original file pointer */ | 87 | /* Restore original file pointer */ |
87 | 88 | ||
88 | if (fseek(file, current_offset, SEEK_SET)) { | 89 | status = acpi_os_set_file_offset(file, current_offset, ACPI_FILE_BEGIN); |
90 | if (ACPI_FAILURE(status)) { | ||
89 | goto seek_error; | 91 | goto seek_error; |
90 | } | 92 | } |
91 | 93 | ||
92 | return ((u32)file_size); | 94 | return ((u32)file_size); |
93 | 95 | ||
94 | offset_error: | 96 | offset_error: |
95 | perror("Could not get file offset"); | 97 | acpi_log_error("Could not get file offset"); |
96 | return (ACPI_UINT32_MAX); | 98 | return (ACPI_UINT32_MAX); |
97 | 99 | ||
98 | seek_error: | 100 | seek_error: |
99 | perror("Could not seek file"); | 101 | acpi_log_error("Could not set file offset"); |
100 | return (ACPI_UINT32_MAX); | 102 | return (ACPI_UINT32_MAX); |
101 | } | 103 | } |
diff --git a/tools/power/acpi/common/getopt.c b/tools/power/acpi/common/getopt.c index a302f52e4fd3..2f0f34a36db4 100644 --- a/tools/power/acpi/common/getopt.c +++ b/tools/power/acpi/common/getopt.c | |||
@@ -51,14 +51,12 @@ | |||
51 | * "f|" - Option has required single-char sub-options | 51 | * "f|" - Option has required single-char sub-options |
52 | */ | 52 | */ |
53 | 53 | ||
54 | #include <stdio.h> | ||
55 | #include <string.h> | ||
56 | #include <acpi/acpi.h> | 54 | #include <acpi/acpi.h> |
57 | #include "accommon.h" | 55 | #include "accommon.h" |
58 | #include "acapps.h" | 56 | #include "acapps.h" |
59 | 57 | ||
60 | #define ACPI_OPTION_ERROR(msg, badchar) \ | 58 | #define ACPI_OPTION_ERROR(msg, badchar) \ |
61 | if (acpi_gbl_opterr) {fprintf (stderr, "%s%c\n", msg, badchar);} | 59 | if (acpi_gbl_opterr) {acpi_log_error ("%s%c\n", msg, badchar);} |
62 | 60 | ||
63 | int acpi_gbl_opterr = 1; | 61 | int acpi_gbl_opterr = 1; |
64 | int acpi_gbl_optind = 1; | 62 | int acpi_gbl_optind = 1; |
@@ -113,7 +111,7 @@ int acpi_getopt_argument(int argc, char **argv) | |||
113 | * PARAMETERS: argc, argv - from main | 111 | * PARAMETERS: argc, argv - from main |
114 | * opts - options info list | 112 | * opts - options info list |
115 | * | 113 | * |
116 | * RETURN: Option character or EOF | 114 | * RETURN: Option character or ACPI_OPT_END |
117 | * | 115 | * |
118 | * DESCRIPTION: Get the next option | 116 | * DESCRIPTION: Get the next option |
119 | * | 117 | * |
@@ -128,10 +126,10 @@ int acpi_getopt(int argc, char **argv, char *opts) | |||
128 | if (acpi_gbl_optind >= argc || | 126 | if (acpi_gbl_optind >= argc || |
129 | argv[acpi_gbl_optind][0] != '-' || | 127 | argv[acpi_gbl_optind][0] != '-' || |
130 | argv[acpi_gbl_optind][1] == '\0') { | 128 | argv[acpi_gbl_optind][1] == '\0') { |
131 | return (EOF); | 129 | return (ACPI_OPT_END); |
132 | } else if (strcmp(argv[acpi_gbl_optind], "--") == 0) { | 130 | } else if (ACPI_STRCMP(argv[acpi_gbl_optind], "--") == 0) { |
133 | acpi_gbl_optind++; | 131 | acpi_gbl_optind++; |
134 | return (EOF); | 132 | return (ACPI_OPT_END); |
135 | } | 133 | } |
136 | } | 134 | } |
137 | 135 | ||
@@ -142,7 +140,7 @@ int acpi_getopt(int argc, char **argv, char *opts) | |||
142 | /* Make sure that the option is legal */ | 140 | /* Make sure that the option is legal */ |
143 | 141 | ||
144 | if (current_char == ':' || | 142 | if (current_char == ':' || |
145 | (opts_ptr = strchr(opts, current_char)) == NULL) { | 143 | (opts_ptr = ACPI_STRCHR(opts, current_char)) == NULL) { |
146 | ACPI_OPTION_ERROR("Illegal option: -", current_char); | 144 | ACPI_OPTION_ERROR("Illegal option: -", current_char); |
147 | 145 | ||
148 | if (argv[acpi_gbl_optind][++current_char_ptr] == '\0') { | 146 | if (argv[acpi_gbl_optind][++current_char_ptr] == '\0') { |
diff --git a/tools/power/acpi/os_specific/service_layers/oslibcfs.c b/tools/power/acpi/os_specific/service_layers/oslibcfs.c new file mode 100644 index 000000000000..c13ff9c51d74 --- /dev/null +++ b/tools/power/acpi/os_specific/service_layers/oslibcfs.c | |||
@@ -0,0 +1,214 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: oslibcfs - C library OSL for file I/O | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2014, Intel Corp. | ||
9 | * All rights reserved. | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or without | ||
12 | * modification, are permitted provided that the following conditions | ||
13 | * are met: | ||
14 | * 1. Redistributions of source code must retain the above copyright | ||
15 | * notice, this list of conditions, and the following disclaimer, | ||
16 | * without modification. | ||
17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | ||
18 | * substantially similar to the "NO WARRANTY" disclaimer below | ||
19 | * ("Disclaimer") and any redistribution must be conditioned upon | ||
20 | * including a substantially similar Disclaimer requirement for further | ||
21 | * binary redistribution. | ||
22 | * 3. Neither the names of the above-listed copyright holders nor the names | ||
23 | * of any contributors may be used to endorse or promote products derived | ||
24 | * from this software without specific prior written permission. | ||
25 | * | ||
26 | * Alternatively, this software may be distributed under the terms of the | ||
27 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
28 | * Software Foundation. | ||
29 | * | ||
30 | * NO WARRANTY | ||
31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | ||
34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
41 | * POSSIBILITY OF SUCH DAMAGES. | ||
42 | */ | ||
43 | |||
44 | #include <acpi/acpi.h> | ||
45 | #include <stdio.h> | ||
46 | #include <stdarg.h> | ||
47 | |||
48 | #define _COMPONENT ACPI_OS_SERVICES | ||
49 | ACPI_MODULE_NAME("oslibcfs") | ||
50 | |||
51 | /******************************************************************************* | ||
52 | * | ||
53 | * FUNCTION: acpi_os_open_file | ||
54 | * | ||
55 | * PARAMETERS: path - File path | ||
56 | * modes - File operation type | ||
57 | * | ||
58 | * RETURN: File descriptor. | ||
59 | * | ||
60 | * DESCRIPTION: Open a file for reading (ACPI_FILE_READING) or/and writing | ||
61 | * (ACPI_FILE_WRITING). | ||
62 | * | ||
63 | ******************************************************************************/ | ||
64 | ACPI_FILE acpi_os_open_file(const char *path, u8 modes) | ||
65 | { | ||
66 | ACPI_FILE file; | ||
67 | u32 i = 0; | ||
68 | char modes_str[4]; | ||
69 | |||
70 | if (modes & ACPI_FILE_READING) { | ||
71 | modes_str[i++] = 'r'; | ||
72 | } | ||
73 | if (modes & ACPI_FILE_WRITING) { | ||
74 | modes_str[i++] = 'w'; | ||
75 | } | ||
76 | if (modes & ACPI_FILE_BINARY) { | ||
77 | modes_str[i++] = 'b'; | ||
78 | } | ||
79 | |||
80 | modes_str[i++] = '\0'; | ||
81 | |||
82 | file = fopen(path, modes_str); | ||
83 | if (!file) { | ||
84 | perror("Could not open file"); | ||
85 | } | ||
86 | |||
87 | return (file); | ||
88 | } | ||
89 | |||
90 | /******************************************************************************* | ||
91 | * | ||
92 | * FUNCTION: acpi_os_close_file | ||
93 | * | ||
94 | * PARAMETERS: file - An open file descriptor | ||
95 | * | ||
96 | * RETURN: None. | ||
97 | * | ||
98 | * DESCRIPTION: Close a file opened via acpi_os_open_file. | ||
99 | * | ||
100 | ******************************************************************************/ | ||
101 | |||
102 | void acpi_os_close_file(ACPI_FILE file) | ||
103 | { | ||
104 | fclose(file); | ||
105 | } | ||
106 | |||
107 | /******************************************************************************* | ||
108 | * | ||
109 | * FUNCTION: acpi_os_read_file | ||
110 | * | ||
111 | * PARAMETERS: file - An open file descriptor | ||
112 | * buffer - Data buffer | ||
113 | * size - Data block size | ||
114 | * count - Number of data blocks | ||
115 | * | ||
116 | * RETURN: Number of bytes actually read. | ||
117 | * | ||
118 | * DESCRIPTION: Read from a file. | ||
119 | * | ||
120 | ******************************************************************************/ | ||
121 | |||
122 | int | ||
123 | acpi_os_read_file(ACPI_FILE file, void *buffer, acpi_size size, acpi_size count) | ||
124 | { | ||
125 | int length; | ||
126 | |||
127 | length = fread(buffer, size, count, file); | ||
128 | if (length < 0) { | ||
129 | perror("Error reading file"); | ||
130 | } | ||
131 | |||
132 | return (length); | ||
133 | } | ||
134 | |||
135 | /******************************************************************************* | ||
136 | * | ||
137 | * FUNCTION: acpi_os_write_file | ||
138 | * | ||
139 | * PARAMETERS: file - An open file descriptor | ||
140 | * buffer - Data buffer | ||
141 | * size - Data block size | ||
142 | * count - Number of data blocks | ||
143 | * | ||
144 | * RETURN: Number of bytes actually written. | ||
145 | * | ||
146 | * DESCRIPTION: Write to a file. | ||
147 | * | ||
148 | ******************************************************************************/ | ||
149 | |||
150 | int | ||
151 | acpi_os_write_file(ACPI_FILE file, | ||
152 | void *buffer, acpi_size size, acpi_size count) | ||
153 | { | ||
154 | int length; | ||
155 | |||
156 | length = fwrite(buffer, size, count, file); | ||
157 | if (length < 0) { | ||
158 | perror("Error writing file"); | ||
159 | } | ||
160 | |||
161 | return (length); | ||
162 | } | ||
163 | |||
164 | /******************************************************************************* | ||
165 | * | ||
166 | * FUNCTION: acpi_os_get_file_offset | ||
167 | * | ||
168 | * PARAMETERS: file - An open file descriptor | ||
169 | * | ||
170 | * RETURN: Current file pointer position. | ||
171 | * | ||
172 | * DESCRIPTION: Get current file offset. | ||
173 | * | ||
174 | ******************************************************************************/ | ||
175 | |||
176 | long acpi_os_get_file_offset(ACPI_FILE file) | ||
177 | { | ||
178 | long offset; | ||
179 | |||
180 | offset = ftell(file); | ||
181 | return (offset); | ||
182 | } | ||
183 | |||
184 | /******************************************************************************* | ||
185 | * | ||
186 | * FUNCTION: acpi_os_set_file_offset | ||
187 | * | ||
188 | * PARAMETERS: file - An open file descriptor | ||
189 | * offset - New file offset | ||
190 | * from - From begin/end of file | ||
191 | * | ||
192 | * RETURN: Status | ||
193 | * | ||
194 | * DESCRIPTION: Set current file offset. | ||
195 | * | ||
196 | ******************************************************************************/ | ||
197 | |||
198 | acpi_status acpi_os_set_file_offset(ACPI_FILE file, long offset, u8 from) | ||
199 | { | ||
200 | int ret = 0; | ||
201 | |||
202 | if (from == ACPI_FILE_BEGIN) { | ||
203 | ret = fseek(file, offset, SEEK_SET); | ||
204 | } | ||
205 | if (from == ACPI_FILE_END) { | ||
206 | ret = fseek(file, offset, SEEK_END); | ||
207 | } | ||
208 | |||
209 | if (ret < 0) { | ||
210 | return (AE_ERROR); | ||
211 | } else { | ||
212 | return (AE_OK); | ||
213 | } | ||
214 | } | ||
diff --git a/tools/power/acpi/os_specific/service_layers/oslinuxtbl.c b/tools/power/acpi/os_specific/service_layers/oslinuxtbl.c index 28c52008e854..0dc2485dedf5 100644 --- a/tools/power/acpi/os_specific/service_layers/oslinuxtbl.c +++ b/tools/power/acpi/os_specific/service_layers/oslinuxtbl.c | |||
@@ -77,6 +77,9 @@ osl_map_table(acpi_size address, | |||
77 | 77 | ||
78 | static void osl_unmap_table(struct acpi_table_header *table); | 78 | static void osl_unmap_table(struct acpi_table_header *table); |
79 | 79 | ||
80 | static acpi_physical_address | ||
81 | osl_find_rsdp_via_efi_by_keyword(FILE * file, const char *keyword); | ||
82 | |||
80 | static acpi_physical_address osl_find_rsdp_via_efi(void); | 83 | static acpi_physical_address osl_find_rsdp_via_efi(void); |
81 | 84 | ||
82 | static acpi_status osl_load_rsdp(void); | 85 | static acpi_status osl_load_rsdp(void); |
@@ -417,6 +420,38 @@ acpi_os_get_table_by_index(u32 index, | |||
417 | 420 | ||
418 | /****************************************************************************** | 421 | /****************************************************************************** |
419 | * | 422 | * |
423 | * FUNCTION: osl_find_rsdp_via_efi_by_keyword | ||
424 | * | ||
425 | * PARAMETERS: keyword - Character string indicating ACPI GUID version | ||
426 | * in the EFI table | ||
427 | * | ||
428 | * RETURN: RSDP address if found | ||
429 | * | ||
430 | * DESCRIPTION: Find RSDP address via EFI using keyword indicating the ACPI | ||
431 | * GUID version. | ||
432 | * | ||
433 | *****************************************************************************/ | ||
434 | |||
435 | static acpi_physical_address | ||
436 | osl_find_rsdp_via_efi_by_keyword(FILE * file, const char *keyword) | ||
437 | { | ||
438 | char buffer[80]; | ||
439 | unsigned long long address = 0; | ||
440 | char format[32]; | ||
441 | |||
442 | snprintf(format, 32, "%s=%s", keyword, "%llx"); | ||
443 | fseek(file, 0, SEEK_SET); | ||
444 | while (fgets(buffer, 80, file)) { | ||
445 | if (sscanf(buffer, format, &address) == 1) { | ||
446 | break; | ||
447 | } | ||
448 | } | ||
449 | |||
450 | return ((acpi_physical_address) (address)); | ||
451 | } | ||
452 | |||
453 | /****************************************************************************** | ||
454 | * | ||
420 | * FUNCTION: osl_find_rsdp_via_efi | 455 | * FUNCTION: osl_find_rsdp_via_efi |
421 | * | 456 | * |
422 | * PARAMETERS: None | 457 | * PARAMETERS: None |
@@ -430,20 +465,19 @@ acpi_os_get_table_by_index(u32 index, | |||
430 | static acpi_physical_address osl_find_rsdp_via_efi(void) | 465 | static acpi_physical_address osl_find_rsdp_via_efi(void) |
431 | { | 466 | { |
432 | FILE *file; | 467 | FILE *file; |
433 | char buffer[80]; | 468 | acpi_physical_address address = 0; |
434 | unsigned long address = 0; | ||
435 | 469 | ||
436 | file = fopen(EFI_SYSTAB, "r"); | 470 | file = fopen(EFI_SYSTAB, "r"); |
437 | if (file) { | 471 | if (file) { |
438 | while (fgets(buffer, 80, file)) { | 472 | address = osl_find_rsdp_via_efi_by_keyword(file, "ACPI20"); |
439 | if (sscanf(buffer, "ACPI20=0x%lx", &address) == 1) { | 473 | if (!address) { |
440 | break; | 474 | address = |
441 | } | 475 | osl_find_rsdp_via_efi_by_keyword(file, "ACPI"); |
442 | } | 476 | } |
443 | fclose(file); | 477 | fclose(file); |
444 | } | 478 | } |
445 | 479 | ||
446 | return ((acpi_physical_address) (address)); | 480 | return (address); |
447 | } | 481 | } |
448 | 482 | ||
449 | /****************************************************************************** | 483 | /****************************************************************************** |
diff --git a/tools/power/acpi/os_specific/service_layers/osunixxf.c b/tools/power/acpi/os_specific/service_layers/osunixxf.c new file mode 100644 index 000000000000..60b58cd18410 --- /dev/null +++ b/tools/power/acpi/os_specific/service_layers/osunixxf.c | |||
@@ -0,0 +1,1311 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: osunixxf - UNIX OSL interfaces | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2014, Intel Corp. | ||
9 | * All rights reserved. | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or without | ||
12 | * modification, are permitted provided that the following conditions | ||
13 | * are met: | ||
14 | * 1. Redistributions of source code must retain the above copyright | ||
15 | * notice, this list of conditions, and the following disclaimer, | ||
16 | * without modification. | ||
17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | ||
18 | * substantially similar to the "NO WARRANTY" disclaimer below | ||
19 | * ("Disclaimer") and any redistribution must be conditioned upon | ||
20 | * including a substantially similar Disclaimer requirement for further | ||
21 | * binary redistribution. | ||
22 | * 3. Neither the names of the above-listed copyright holders nor the names | ||
23 | * of any contributors may be used to endorse or promote products derived | ||
24 | * from this software without specific prior written permission. | ||
25 | * | ||
26 | * Alternatively, this software may be distributed under the terms of the | ||
27 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
28 | * Software Foundation. | ||
29 | * | ||
30 | * NO WARRANTY | ||
31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | ||
34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
41 | * POSSIBILITY OF SUCH DAMAGES. | ||
42 | */ | ||
43 | |||
44 | /* | ||
45 | * These interfaces are required in order to compile the ASL compiler and the | ||
46 | * various ACPICA tools under Linux or other Unix-like system. | ||
47 | */ | ||
48 | #include <acpi/acpi.h> | ||
49 | #include "accommon.h" | ||
50 | #include "amlcode.h" | ||
51 | #include "acparser.h" | ||
52 | #include "acdebug.h" | ||
53 | |||
54 | #include <stdio.h> | ||
55 | #include <stdlib.h> | ||
56 | #include <stdarg.h> | ||
57 | #include <unistd.h> | ||
58 | #include <sys/time.h> | ||
59 | #include <semaphore.h> | ||
60 | #include <pthread.h> | ||
61 | #include <errno.h> | ||
62 | |||
63 | #define _COMPONENT ACPI_OS_SERVICES | ||
64 | ACPI_MODULE_NAME("osunixxf") | ||
65 | |||
66 | u8 acpi_gbl_debug_timeout = FALSE; | ||
67 | |||
68 | /* Upcalls to acpi_exec */ | ||
69 | |||
70 | void | ||
71 | ae_table_override(struct acpi_table_header *existing_table, | ||
72 | struct acpi_table_header **new_table); | ||
73 | |||
74 | typedef void *(*PTHREAD_CALLBACK) (void *); | ||
75 | |||
76 | /* Buffer used by acpi_os_vprintf */ | ||
77 | |||
78 | #define ACPI_VPRINTF_BUFFER_SIZE 512 | ||
79 | #define _ASCII_NEWLINE '\n' | ||
80 | |||
81 | /* Terminal support for acpi_exec only */ | ||
82 | |||
83 | #ifdef ACPI_EXEC_APP | ||
84 | #include <termios.h> | ||
85 | |||
86 | struct termios original_term_attributes; | ||
87 | int term_attributes_were_set = 0; | ||
88 | |||
89 | acpi_status acpi_ut_read_line(char *buffer, u32 buffer_length, u32 *bytes_read); | ||
90 | |||
91 | static void os_enter_line_edit_mode(void); | ||
92 | |||
93 | static void os_exit_line_edit_mode(void); | ||
94 | |||
95 | /****************************************************************************** | ||
96 | * | ||
97 | * FUNCTION: os_enter_line_edit_mode, os_exit_line_edit_mode | ||
98 | * | ||
99 | * PARAMETERS: None | ||
100 | * | ||
101 | * RETURN: None | ||
102 | * | ||
103 | * DESCRIPTION: Enter/Exit the raw character input mode for the terminal. | ||
104 | * | ||
105 | * Interactive line-editing support for the AML debugger. Used with the | ||
106 | * common/acgetline module. | ||
107 | * | ||
108 | * readline() is not used because of non-portability. It is not available | ||
109 | * on all systems, and if it is, often the package must be manually installed. | ||
110 | * | ||
111 | * Therefore, we use the POSIX tcgetattr/tcsetattr and do the minimal line | ||
112 | * editing that we need in acpi_os_get_line. | ||
113 | * | ||
114 | * If the POSIX tcgetattr/tcsetattr interfaces are unavailable, these | ||
115 | * calls will also work: | ||
116 | * For os_enter_line_edit_mode: system ("stty cbreak -echo") | ||
117 | * For os_exit_line_edit_mode: system ("stty cooked echo") | ||
118 | * | ||
119 | *****************************************************************************/ | ||
120 | |||
121 | static void os_enter_line_edit_mode(void) | ||
122 | { | ||
123 | struct termios local_term_attributes; | ||
124 | |||
125 | /* Get and keep the original attributes */ | ||
126 | |||
127 | if (tcgetattr(STDIN_FILENO, &original_term_attributes)) { | ||
128 | fprintf(stderr, "Could not get terminal attributes!\n"); | ||
129 | return; | ||
130 | } | ||
131 | |||
132 | /* Set the new attributes to enable raw character input */ | ||
133 | |||
134 | memcpy(&local_term_attributes, &original_term_attributes, | ||
135 | sizeof(struct termios)); | ||
136 | |||
137 | local_term_attributes.c_lflag &= ~(ICANON | ECHO); | ||
138 | local_term_attributes.c_cc[VMIN] = 1; | ||
139 | local_term_attributes.c_cc[VTIME] = 0; | ||
140 | |||
141 | if (tcsetattr(STDIN_FILENO, TCSANOW, &local_term_attributes)) { | ||
142 | fprintf(stderr, "Could not set terminal attributes!\n"); | ||
143 | return; | ||
144 | } | ||
145 | |||
146 | term_attributes_were_set = 1; | ||
147 | } | ||
148 | |||
149 | static void os_exit_line_edit_mode(void) | ||
150 | { | ||
151 | |||
152 | if (!term_attributes_were_set) { | ||
153 | return; | ||
154 | } | ||
155 | |||
156 | /* Set terminal attributes back to the original values */ | ||
157 | |||
158 | if (tcsetattr(STDIN_FILENO, TCSANOW, &original_term_attributes)) { | ||
159 | fprintf(stderr, "Could not restore terminal attributes!\n"); | ||
160 | } | ||
161 | } | ||
162 | |||
163 | #else | ||
164 | |||
165 | /* These functions are not needed for other ACPICA utilities */ | ||
166 | |||
167 | #define os_enter_line_edit_mode() | ||
168 | #define os_exit_line_edit_mode() | ||
169 | #endif | ||
170 | |||
171 | /****************************************************************************** | ||
172 | * | ||
173 | * FUNCTION: acpi_os_initialize, acpi_os_terminate | ||
174 | * | ||
175 | * PARAMETERS: None | ||
176 | * | ||
177 | * RETURN: Status | ||
178 | * | ||
179 | * DESCRIPTION: Initialize and terminate this module. | ||
180 | * | ||
181 | *****************************************************************************/ | ||
182 | |||
183 | acpi_status acpi_os_initialize(void) | ||
184 | { | ||
185 | acpi_status status; | ||
186 | |||
187 | acpi_gbl_output_file = stdout; | ||
188 | |||
189 | os_enter_line_edit_mode(); | ||
190 | |||
191 | status = acpi_os_create_lock(&acpi_gbl_print_lock); | ||
192 | if (ACPI_FAILURE(status)) { | ||
193 | return (status); | ||
194 | } | ||
195 | |||
196 | return (AE_OK); | ||
197 | } | ||
198 | |||
199 | acpi_status acpi_os_terminate(void) | ||
200 | { | ||
201 | |||
202 | os_exit_line_edit_mode(); | ||
203 | return (AE_OK); | ||
204 | } | ||
205 | |||
206 | #ifndef ACPI_USE_NATIVE_RSDP_POINTER | ||
207 | /****************************************************************************** | ||
208 | * | ||
209 | * FUNCTION: acpi_os_get_root_pointer | ||
210 | * | ||
211 | * PARAMETERS: None | ||
212 | * | ||
213 | * RETURN: RSDP physical address | ||
214 | * | ||
215 | * DESCRIPTION: Gets the ACPI root pointer (RSDP) | ||
216 | * | ||
217 | *****************************************************************************/ | ||
218 | |||
219 | acpi_physical_address acpi_os_get_root_pointer(void) | ||
220 | { | ||
221 | |||
222 | return (0); | ||
223 | } | ||
224 | #endif | ||
225 | |||
226 | /****************************************************************************** | ||
227 | * | ||
228 | * FUNCTION: acpi_os_predefined_override | ||
229 | * | ||
230 | * PARAMETERS: init_val - Initial value of the predefined object | ||
231 | * new_val - The new value for the object | ||
232 | * | ||
233 | * RETURN: Status, pointer to value. Null pointer returned if not | ||
234 | * overriding. | ||
235 | * | ||
236 | * DESCRIPTION: Allow the OS to override predefined names | ||
237 | * | ||
238 | *****************************************************************************/ | ||
239 | |||
240 | acpi_status | ||
241 | acpi_os_predefined_override(const struct acpi_predefined_names * init_val, | ||
242 | acpi_string * new_val) | ||
243 | { | ||
244 | |||
245 | if (!init_val || !new_val) { | ||
246 | return (AE_BAD_PARAMETER); | ||
247 | } | ||
248 | |||
249 | *new_val = NULL; | ||
250 | return (AE_OK); | ||
251 | } | ||
252 | |||
253 | /****************************************************************************** | ||
254 | * | ||
255 | * FUNCTION: acpi_os_table_override | ||
256 | * | ||
257 | * PARAMETERS: existing_table - Header of current table (probably | ||
258 | * firmware) | ||
259 | * new_table - Where an entire new table is returned. | ||
260 | * | ||
261 | * RETURN: Status, pointer to new table. Null pointer returned if no | ||
262 | * table is available to override | ||
263 | * | ||
264 | * DESCRIPTION: Return a different version of a table if one is available | ||
265 | * | ||
266 | *****************************************************************************/ | ||
267 | |||
268 | acpi_status | ||
269 | acpi_os_table_override(struct acpi_table_header * existing_table, | ||
270 | struct acpi_table_header ** new_table) | ||
271 | { | ||
272 | |||
273 | if (!existing_table || !new_table) { | ||
274 | return (AE_BAD_PARAMETER); | ||
275 | } | ||
276 | |||
277 | *new_table = NULL; | ||
278 | |||
279 | #ifdef ACPI_EXEC_APP | ||
280 | |||
281 | ae_table_override(existing_table, new_table); | ||
282 | return (AE_OK); | ||
283 | #else | ||
284 | |||
285 | return (AE_NO_ACPI_TABLES); | ||
286 | #endif | ||
287 | } | ||
288 | |||
289 | /****************************************************************************** | ||
290 | * | ||
291 | * FUNCTION: acpi_os_physical_table_override | ||
292 | * | ||
293 | * PARAMETERS: existing_table - Header of current table (probably firmware) | ||
294 | * new_address - Where new table address is returned | ||
295 | * (Physical address) | ||
296 | * new_table_length - Where new table length is returned | ||
297 | * | ||
298 | * RETURN: Status, address/length of new table. Null pointer returned | ||
299 | * if no table is available to override. | ||
300 | * | ||
301 | * DESCRIPTION: Returns AE_SUPPORT, function not used in user space. | ||
302 | * | ||
303 | *****************************************************************************/ | ||
304 | |||
305 | acpi_status | ||
306 | acpi_os_physical_table_override(struct acpi_table_header * existing_table, | ||
307 | acpi_physical_address * new_address, | ||
308 | u32 *new_table_length) | ||
309 | { | ||
310 | |||
311 | return (AE_SUPPORT); | ||
312 | } | ||
313 | |||
314 | /****************************************************************************** | ||
315 | * | ||
316 | * FUNCTION: acpi_os_redirect_output | ||
317 | * | ||
318 | * PARAMETERS: destination - An open file handle/pointer | ||
319 | * | ||
320 | * RETURN: None | ||
321 | * | ||
322 | * DESCRIPTION: Causes redirect of acpi_os_printf and acpi_os_vprintf | ||
323 | * | ||
324 | *****************************************************************************/ | ||
325 | |||
326 | void acpi_os_redirect_output(void *destination) | ||
327 | { | ||
328 | |||
329 | acpi_gbl_output_file = destination; | ||
330 | } | ||
331 | |||
332 | /****************************************************************************** | ||
333 | * | ||
334 | * FUNCTION: acpi_os_printf | ||
335 | * | ||
336 | * PARAMETERS: fmt, ... - Standard printf format | ||
337 | * | ||
338 | * RETURN: None | ||
339 | * | ||
340 | * DESCRIPTION: Formatted output. Note: very similar to acpi_os_vprintf | ||
341 | * (performance), changes should be tracked in both functions. | ||
342 | * | ||
343 | *****************************************************************************/ | ||
344 | |||
345 | void ACPI_INTERNAL_VAR_XFACE acpi_os_printf(const char *fmt, ...) | ||
346 | { | ||
347 | va_list args; | ||
348 | u8 flags; | ||
349 | |||
350 | flags = acpi_gbl_db_output_flags; | ||
351 | if (flags & ACPI_DB_REDIRECTABLE_OUTPUT) { | ||
352 | |||
353 | /* Output is directable to either a file (if open) or the console */ | ||
354 | |||
355 | if (acpi_gbl_debug_file) { | ||
356 | |||
357 | /* Output file is open, send the output there */ | ||
358 | |||
359 | va_start(args, fmt); | ||
360 | vfprintf(acpi_gbl_debug_file, fmt, args); | ||
361 | va_end(args); | ||
362 | } else { | ||
363 | /* No redirection, send output to console (once only!) */ | ||
364 | |||
365 | flags |= ACPI_DB_CONSOLE_OUTPUT; | ||
366 | } | ||
367 | } | ||
368 | |||
369 | if (flags & ACPI_DB_CONSOLE_OUTPUT) { | ||
370 | va_start(args, fmt); | ||
371 | vfprintf(acpi_gbl_output_file, fmt, args); | ||
372 | va_end(args); | ||
373 | } | ||
374 | } | ||
375 | |||
376 | /****************************************************************************** | ||
377 | * | ||
378 | * FUNCTION: acpi_os_vprintf | ||
379 | * | ||
380 | * PARAMETERS: fmt - Standard printf format | ||
381 | * args - Argument list | ||
382 | * | ||
383 | * RETURN: None | ||
384 | * | ||
385 | * DESCRIPTION: Formatted output with argument list pointer. Note: very | ||
386 | * similar to acpi_os_printf, changes should be tracked in both | ||
387 | * functions. | ||
388 | * | ||
389 | *****************************************************************************/ | ||
390 | |||
391 | void acpi_os_vprintf(const char *fmt, va_list args) | ||
392 | { | ||
393 | u8 flags; | ||
394 | char buffer[ACPI_VPRINTF_BUFFER_SIZE]; | ||
395 | |||
396 | /* | ||
397 | * We build the output string in a local buffer because we may be | ||
398 | * outputting the buffer twice. Using vfprintf is problematic because | ||
399 | * some implementations modify the args pointer/structure during | ||
400 | * execution. Thus, we use the local buffer for portability. | ||
401 | * | ||
402 | * Note: Since this module is intended for use by the various ACPICA | ||
403 | * utilities/applications, we can safely declare the buffer on the stack. | ||
404 | * Also, This function is used for relatively small error messages only. | ||
405 | */ | ||
406 | vsnprintf(buffer, ACPI_VPRINTF_BUFFER_SIZE, fmt, args); | ||
407 | |||
408 | flags = acpi_gbl_db_output_flags; | ||
409 | if (flags & ACPI_DB_REDIRECTABLE_OUTPUT) { | ||
410 | |||
411 | /* Output is directable to either a file (if open) or the console */ | ||
412 | |||
413 | if (acpi_gbl_debug_file) { | ||
414 | |||
415 | /* Output file is open, send the output there */ | ||
416 | |||
417 | fputs(buffer, acpi_gbl_debug_file); | ||
418 | } else { | ||
419 | /* No redirection, send output to console (once only!) */ | ||
420 | |||
421 | flags |= ACPI_DB_CONSOLE_OUTPUT; | ||
422 | } | ||
423 | } | ||
424 | |||
425 | if (flags & ACPI_DB_CONSOLE_OUTPUT) { | ||
426 | fputs(buffer, acpi_gbl_output_file); | ||
427 | } | ||
428 | } | ||
429 | |||
430 | #ifndef ACPI_EXEC_APP | ||
431 | /****************************************************************************** | ||
432 | * | ||
433 | * FUNCTION: acpi_os_get_line | ||
434 | * | ||
435 | * PARAMETERS: buffer - Where to return the command line | ||
436 | * buffer_length - Maximum length of Buffer | ||
437 | * bytes_read - Where the actual byte count is returned | ||
438 | * | ||
439 | * RETURN: Status and actual bytes read | ||
440 | * | ||
441 | * DESCRIPTION: Get the next input line from the terminal. NOTE: For the | ||
442 | * acpi_exec utility, we use the acgetline module instead to | ||
443 | * provide line-editing and history support. | ||
444 | * | ||
445 | *****************************************************************************/ | ||
446 | |||
447 | acpi_status acpi_os_get_line(char *buffer, u32 buffer_length, u32 *bytes_read) | ||
448 | { | ||
449 | int input_char; | ||
450 | u32 end_of_line; | ||
451 | |||
452 | /* Standard acpi_os_get_line for all utilities except acpi_exec */ | ||
453 | |||
454 | for (end_of_line = 0;; end_of_line++) { | ||
455 | if (end_of_line >= buffer_length) { | ||
456 | return (AE_BUFFER_OVERFLOW); | ||
457 | } | ||
458 | |||
459 | if ((input_char = getchar()) == EOF) { | ||
460 | return (AE_ERROR); | ||
461 | } | ||
462 | |||
463 | if (!input_char || input_char == _ASCII_NEWLINE) { | ||
464 | break; | ||
465 | } | ||
466 | |||
467 | buffer[end_of_line] = (char)input_char; | ||
468 | } | ||
469 | |||
470 | /* Null terminate the buffer */ | ||
471 | |||
472 | buffer[end_of_line] = 0; | ||
473 | |||
474 | /* Return the number of bytes in the string */ | ||
475 | |||
476 | if (bytes_read) { | ||
477 | *bytes_read = end_of_line; | ||
478 | } | ||
479 | |||
480 | return (AE_OK); | ||
481 | } | ||
482 | #endif | ||
483 | |||
484 | #ifndef ACPI_USE_NATIVE_MEMORY_MAPPING | ||
485 | /****************************************************************************** | ||
486 | * | ||
487 | * FUNCTION: acpi_os_map_memory | ||
488 | * | ||
489 | * PARAMETERS: where - Physical address of memory to be mapped | ||
490 | * length - How much memory to map | ||
491 | * | ||
492 | * RETURN: Pointer to mapped memory. Null on error. | ||
493 | * | ||
494 | * DESCRIPTION: Map physical memory into caller's address space | ||
495 | * | ||
496 | *****************************************************************************/ | ||
497 | |||
498 | void *acpi_os_map_memory(acpi_physical_address where, acpi_size length) | ||
499 | { | ||
500 | |||
501 | return (ACPI_TO_POINTER((acpi_size) where)); | ||
502 | } | ||
503 | |||
504 | /****************************************************************************** | ||
505 | * | ||
506 | * FUNCTION: acpi_os_unmap_memory | ||
507 | * | ||
508 | * PARAMETERS: where - Logical address of memory to be unmapped | ||
509 | * length - How much memory to unmap | ||
510 | * | ||
511 | * RETURN: None. | ||
512 | * | ||
513 | * DESCRIPTION: Delete a previously created mapping. Where and Length must | ||
514 | * correspond to a previous mapping exactly. | ||
515 | * | ||
516 | *****************************************************************************/ | ||
517 | |||
518 | void acpi_os_unmap_memory(void *where, acpi_size length) | ||
519 | { | ||
520 | |||
521 | return; | ||
522 | } | ||
523 | #endif | ||
524 | |||
525 | /****************************************************************************** | ||
526 | * | ||
527 | * FUNCTION: acpi_os_allocate | ||
528 | * | ||
529 | * PARAMETERS: size - Amount to allocate, in bytes | ||
530 | * | ||
531 | * RETURN: Pointer to the new allocation. Null on error. | ||
532 | * | ||
533 | * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS. | ||
534 | * | ||
535 | *****************************************************************************/ | ||
536 | |||
537 | void *acpi_os_allocate(acpi_size size) | ||
538 | { | ||
539 | void *mem; | ||
540 | |||
541 | mem = (void *)malloc((size_t) size); | ||
542 | return (mem); | ||
543 | } | ||
544 | |||
545 | #ifdef USE_NATIVE_ALLOCATE_ZEROED | ||
546 | /****************************************************************************** | ||
547 | * | ||
548 | * FUNCTION: acpi_os_allocate_zeroed | ||
549 | * | ||
550 | * PARAMETERS: size - Amount to allocate, in bytes | ||
551 | * | ||
552 | * RETURN: Pointer to the new allocation. Null on error. | ||
553 | * | ||
554 | * DESCRIPTION: Allocate and zero memory. Algorithm is dependent on the OS. | ||
555 | * | ||
556 | *****************************************************************************/ | ||
557 | |||
558 | void *acpi_os_allocate_zeroed(acpi_size size) | ||
559 | { | ||
560 | void *mem; | ||
561 | |||
562 | mem = (void *)calloc(1, (size_t) size); | ||
563 | return (mem); | ||
564 | } | ||
565 | #endif | ||
566 | |||
567 | /****************************************************************************** | ||
568 | * | ||
569 | * FUNCTION: acpi_os_free | ||
570 | * | ||
571 | * PARAMETERS: mem - Pointer to previously allocated memory | ||
572 | * | ||
573 | * RETURN: None. | ||
574 | * | ||
575 | * DESCRIPTION: Free memory allocated via acpi_os_allocate | ||
576 | * | ||
577 | *****************************************************************************/ | ||
578 | |||
579 | void acpi_os_free(void *mem) | ||
580 | { | ||
581 | |||
582 | free(mem); | ||
583 | } | ||
584 | |||
585 | #ifdef ACPI_SINGLE_THREADED | ||
586 | /****************************************************************************** | ||
587 | * | ||
588 | * FUNCTION: Semaphore stub functions | ||
589 | * | ||
590 | * DESCRIPTION: Stub functions used for single-thread applications that do | ||
591 | * not require semaphore synchronization. Full implementations | ||
592 | * of these functions appear after the stubs. | ||
593 | * | ||
594 | *****************************************************************************/ | ||
595 | |||
596 | acpi_status | ||
597 | acpi_os_create_semaphore(u32 max_units, | ||
598 | u32 initial_units, acpi_handle * out_handle) | ||
599 | { | ||
600 | *out_handle = (acpi_handle) 1; | ||
601 | return (AE_OK); | ||
602 | } | ||
603 | |||
604 | acpi_status acpi_os_delete_semaphore(acpi_handle handle) | ||
605 | { | ||
606 | return (AE_OK); | ||
607 | } | ||
608 | |||
609 | acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout) | ||
610 | { | ||
611 | return (AE_OK); | ||
612 | } | ||
613 | |||
614 | acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units) | ||
615 | { | ||
616 | return (AE_OK); | ||
617 | } | ||
618 | |||
619 | #else | ||
620 | /****************************************************************************** | ||
621 | * | ||
622 | * FUNCTION: acpi_os_create_semaphore | ||
623 | * | ||
624 | * PARAMETERS: initial_units - Units to be assigned to the new semaphore | ||
625 | * out_handle - Where a handle will be returned | ||
626 | * | ||
627 | * RETURN: Status | ||
628 | * | ||
629 | * DESCRIPTION: Create an OS semaphore | ||
630 | * | ||
631 | *****************************************************************************/ | ||
632 | |||
633 | acpi_status | ||
634 | acpi_os_create_semaphore(u32 max_units, | ||
635 | u32 initial_units, acpi_handle * out_handle) | ||
636 | { | ||
637 | sem_t *sem; | ||
638 | |||
639 | if (!out_handle) { | ||
640 | return (AE_BAD_PARAMETER); | ||
641 | } | ||
642 | #ifdef __APPLE__ | ||
643 | { | ||
644 | char *semaphore_name = tmpnam(NULL); | ||
645 | |||
646 | sem = | ||
647 | sem_open(semaphore_name, O_EXCL | O_CREAT, 0755, | ||
648 | initial_units); | ||
649 | if (!sem) { | ||
650 | return (AE_NO_MEMORY); | ||
651 | } | ||
652 | sem_unlink(semaphore_name); /* This just deletes the name */ | ||
653 | } | ||
654 | |||
655 | #else | ||
656 | sem = acpi_os_allocate(sizeof(sem_t)); | ||
657 | if (!sem) { | ||
658 | return (AE_NO_MEMORY); | ||
659 | } | ||
660 | |||
661 | if (sem_init(sem, 0, initial_units) == -1) { | ||
662 | acpi_os_free(sem); | ||
663 | return (AE_BAD_PARAMETER); | ||
664 | } | ||
665 | #endif | ||
666 | |||
667 | *out_handle = (acpi_handle) sem; | ||
668 | return (AE_OK); | ||
669 | } | ||
670 | |||
671 | /****************************************************************************** | ||
672 | * | ||
673 | * FUNCTION: acpi_os_delete_semaphore | ||
674 | * | ||
675 | * PARAMETERS: handle - Handle returned by acpi_os_create_semaphore | ||
676 | * | ||
677 | * RETURN: Status | ||
678 | * | ||
679 | * DESCRIPTION: Delete an OS semaphore | ||
680 | * | ||
681 | *****************************************************************************/ | ||
682 | |||
683 | acpi_status acpi_os_delete_semaphore(acpi_handle handle) | ||
684 | { | ||
685 | sem_t *sem = (sem_t *) handle; | ||
686 | |||
687 | if (!sem) { | ||
688 | return (AE_BAD_PARAMETER); | ||
689 | } | ||
690 | |||
691 | if (sem_destroy(sem) == -1) { | ||
692 | return (AE_BAD_PARAMETER); | ||
693 | } | ||
694 | |||
695 | return (AE_OK); | ||
696 | } | ||
697 | |||
698 | /****************************************************************************** | ||
699 | * | ||
700 | * FUNCTION: acpi_os_wait_semaphore | ||
701 | * | ||
702 | * PARAMETERS: handle - Handle returned by acpi_os_create_semaphore | ||
703 | * units - How many units to wait for | ||
704 | * msec_timeout - How long to wait (milliseconds) | ||
705 | * | ||
706 | * RETURN: Status | ||
707 | * | ||
708 | * DESCRIPTION: Wait for units | ||
709 | * | ||
710 | *****************************************************************************/ | ||
711 | |||
712 | acpi_status | ||
713 | acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 msec_timeout) | ||
714 | { | ||
715 | acpi_status status = AE_OK; | ||
716 | sem_t *sem = (sem_t *) handle; | ||
717 | #ifndef ACPI_USE_ALTERNATE_TIMEOUT | ||
718 | struct timespec time; | ||
719 | int ret_val; | ||
720 | #endif | ||
721 | |||
722 | if (!sem) { | ||
723 | return (AE_BAD_PARAMETER); | ||
724 | } | ||
725 | |||
726 | switch (msec_timeout) { | ||
727 | /* | ||
728 | * No Wait: | ||
729 | * -------- | ||
730 | * A zero timeout value indicates that we shouldn't wait - just | ||
731 | * acquire the semaphore if available otherwise return AE_TIME | ||
732 | * (a.k.a. 'would block'). | ||
733 | */ | ||
734 | case 0: | ||
735 | |||
736 | if (sem_trywait(sem) == -1) { | ||
737 | status = (AE_TIME); | ||
738 | } | ||
739 | break; | ||
740 | |||
741 | /* Wait Indefinitely */ | ||
742 | |||
743 | case ACPI_WAIT_FOREVER: | ||
744 | |||
745 | if (sem_wait(sem)) { | ||
746 | status = (AE_TIME); | ||
747 | } | ||
748 | break; | ||
749 | |||
750 | /* Wait with msec_timeout */ | ||
751 | |||
752 | default: | ||
753 | |||
754 | #ifdef ACPI_USE_ALTERNATE_TIMEOUT | ||
755 | /* | ||
756 | * Alternate timeout mechanism for environments where | ||
757 | * sem_timedwait is not available or does not work properly. | ||
758 | */ | ||
759 | while (msec_timeout) { | ||
760 | if (sem_trywait(sem) == 0) { | ||
761 | |||
762 | /* Got the semaphore */ | ||
763 | return (AE_OK); | ||
764 | } | ||
765 | |||
766 | if (msec_timeout >= 10) { | ||
767 | msec_timeout -= 10; | ||
768 | usleep(10 * ACPI_USEC_PER_MSEC); /* ten milliseconds */ | ||
769 | } else { | ||
770 | msec_timeout--; | ||
771 | usleep(ACPI_USEC_PER_MSEC); /* one millisecond */ | ||
772 | } | ||
773 | } | ||
774 | status = (AE_TIME); | ||
775 | #else | ||
776 | /* | ||
777 | * The interface to sem_timedwait is an absolute time, so we need to | ||
778 | * get the current time, then add in the millisecond Timeout value. | ||
779 | */ | ||
780 | if (clock_gettime(CLOCK_REALTIME, &time) == -1) { | ||
781 | perror("clock_gettime"); | ||
782 | return (AE_TIME); | ||
783 | } | ||
784 | |||
785 | time.tv_sec += (msec_timeout / ACPI_MSEC_PER_SEC); | ||
786 | time.tv_nsec += | ||
787 | ((msec_timeout % ACPI_MSEC_PER_SEC) * ACPI_NSEC_PER_MSEC); | ||
788 | |||
789 | /* Handle nanosecond overflow (field must be less than one second) */ | ||
790 | |||
791 | if (time.tv_nsec >= ACPI_NSEC_PER_SEC) { | ||
792 | time.tv_sec += (time.tv_nsec / ACPI_NSEC_PER_SEC); | ||
793 | time.tv_nsec = (time.tv_nsec % ACPI_NSEC_PER_SEC); | ||
794 | } | ||
795 | |||
796 | while (((ret_val = sem_timedwait(sem, &time)) == -1) | ||
797 | && (errno == EINTR)) { | ||
798 | continue; | ||
799 | } | ||
800 | |||
801 | if (ret_val != 0) { | ||
802 | if (errno != ETIMEDOUT) { | ||
803 | perror("sem_timedwait"); | ||
804 | } | ||
805 | status = (AE_TIME); | ||
806 | } | ||
807 | #endif | ||
808 | break; | ||
809 | } | ||
810 | |||
811 | return (status); | ||
812 | } | ||
813 | |||
814 | /****************************************************************************** | ||
815 | * | ||
816 | * FUNCTION: acpi_os_signal_semaphore | ||
817 | * | ||
818 | * PARAMETERS: handle - Handle returned by acpi_os_create_semaphore | ||
819 | * units - Number of units to send | ||
820 | * | ||
821 | * RETURN: Status | ||
822 | * | ||
823 | * DESCRIPTION: Send units | ||
824 | * | ||
825 | *****************************************************************************/ | ||
826 | |||
827 | acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units) | ||
828 | { | ||
829 | sem_t *sem = (sem_t *) handle; | ||
830 | |||
831 | if (!sem) { | ||
832 | return (AE_BAD_PARAMETER); | ||
833 | } | ||
834 | |||
835 | if (sem_post(sem) == -1) { | ||
836 | return (AE_LIMIT); | ||
837 | } | ||
838 | |||
839 | return (AE_OK); | ||
840 | } | ||
841 | |||
842 | #endif /* ACPI_SINGLE_THREADED */ | ||
843 | |||
844 | /****************************************************************************** | ||
845 | * | ||
846 | * FUNCTION: Spinlock interfaces | ||
847 | * | ||
848 | * DESCRIPTION: Map these interfaces to semaphore interfaces | ||
849 | * | ||
850 | *****************************************************************************/ | ||
851 | |||
852 | acpi_status acpi_os_create_lock(acpi_spinlock * out_handle) | ||
853 | { | ||
854 | |||
855 | return (acpi_os_create_semaphore(1, 1, out_handle)); | ||
856 | } | ||
857 | |||
858 | void acpi_os_delete_lock(acpi_spinlock handle) | ||
859 | { | ||
860 | acpi_os_delete_semaphore(handle); | ||
861 | } | ||
862 | |||
863 | acpi_cpu_flags acpi_os_acquire_lock(acpi_handle handle) | ||
864 | { | ||
865 | acpi_os_wait_semaphore(handle, 1, 0xFFFF); | ||
866 | return (0); | ||
867 | } | ||
868 | |||
869 | void acpi_os_release_lock(acpi_spinlock handle, acpi_cpu_flags flags) | ||
870 | { | ||
871 | acpi_os_signal_semaphore(handle, 1); | ||
872 | } | ||
873 | |||
874 | /****************************************************************************** | ||
875 | * | ||
876 | * FUNCTION: acpi_os_install_interrupt_handler | ||
877 | * | ||
878 | * PARAMETERS: interrupt_number - Level handler should respond to. | ||
879 | * isr - Address of the ACPI interrupt handler | ||
880 | * except_ptr - Where status is returned | ||
881 | * | ||
882 | * RETURN: Handle to the newly installed handler. | ||
883 | * | ||
884 | * DESCRIPTION: Install an interrupt handler. Used to install the ACPI | ||
885 | * OS-independent handler. | ||
886 | * | ||
887 | *****************************************************************************/ | ||
888 | |||
889 | u32 | ||
890 | acpi_os_install_interrupt_handler(u32 interrupt_number, | ||
891 | acpi_osd_handler service_routine, | ||
892 | void *context) | ||
893 | { | ||
894 | |||
895 | return (AE_OK); | ||
896 | } | ||
897 | |||
898 | /****************************************************************************** | ||
899 | * | ||
900 | * FUNCTION: acpi_os_remove_interrupt_handler | ||
901 | * | ||
902 | * PARAMETERS: handle - Returned when handler was installed | ||
903 | * | ||
904 | * RETURN: Status | ||
905 | * | ||
906 | * DESCRIPTION: Uninstalls an interrupt handler. | ||
907 | * | ||
908 | *****************************************************************************/ | ||
909 | |||
910 | acpi_status | ||
911 | acpi_os_remove_interrupt_handler(u32 interrupt_number, | ||
912 | acpi_osd_handler service_routine) | ||
913 | { | ||
914 | |||
915 | return (AE_OK); | ||
916 | } | ||
917 | |||
918 | /****************************************************************************** | ||
919 | * | ||
920 | * FUNCTION: acpi_os_stall | ||
921 | * | ||
922 | * PARAMETERS: microseconds - Time to sleep | ||
923 | * | ||
924 | * RETURN: Blocks until sleep is completed. | ||
925 | * | ||
926 | * DESCRIPTION: Sleep at microsecond granularity | ||
927 | * | ||
928 | *****************************************************************************/ | ||
929 | |||
930 | void acpi_os_stall(u32 microseconds) | ||
931 | { | ||
932 | |||
933 | if (microseconds) { | ||
934 | usleep(microseconds); | ||
935 | } | ||
936 | } | ||
937 | |||
938 | /****************************************************************************** | ||
939 | * | ||
940 | * FUNCTION: acpi_os_sleep | ||
941 | * | ||
942 | * PARAMETERS: milliseconds - Time to sleep | ||
943 | * | ||
944 | * RETURN: Blocks until sleep is completed. | ||
945 | * | ||
946 | * DESCRIPTION: Sleep at millisecond granularity | ||
947 | * | ||
948 | *****************************************************************************/ | ||
949 | |||
950 | void acpi_os_sleep(u64 milliseconds) | ||
951 | { | ||
952 | |||
953 | /* Sleep for whole seconds */ | ||
954 | |||
955 | sleep(milliseconds / ACPI_MSEC_PER_SEC); | ||
956 | |||
957 | /* | ||
958 | * Sleep for remaining microseconds. | ||
959 | * Arg to usleep() is in usecs and must be less than 1,000,000 (1 second). | ||
960 | */ | ||
961 | usleep((milliseconds % ACPI_MSEC_PER_SEC) * ACPI_USEC_PER_MSEC); | ||
962 | } | ||
963 | |||
964 | /****************************************************************************** | ||
965 | * | ||
966 | * FUNCTION: acpi_os_get_timer | ||
967 | * | ||
968 | * PARAMETERS: None | ||
969 | * | ||
970 | * RETURN: Current time in 100 nanosecond units | ||
971 | * | ||
972 | * DESCRIPTION: Get the current system time | ||
973 | * | ||
974 | *****************************************************************************/ | ||
975 | |||
976 | u64 acpi_os_get_timer(void) | ||
977 | { | ||
978 | struct timeval time; | ||
979 | |||
980 | /* This timer has sufficient resolution for user-space application code */ | ||
981 | |||
982 | gettimeofday(&time, NULL); | ||
983 | |||
984 | /* (Seconds * 10^7 = 100ns(10^-7)) + (Microseconds(10^-6) * 10^1 = 100ns) */ | ||
985 | |||
986 | return (((u64)time.tv_sec * ACPI_100NSEC_PER_SEC) + | ||
987 | ((u64)time.tv_usec * ACPI_100NSEC_PER_USEC)); | ||
988 | } | ||
989 | |||
990 | /****************************************************************************** | ||
991 | * | ||
992 | * FUNCTION: acpi_os_read_pci_configuration | ||
993 | * | ||
994 | * PARAMETERS: pci_id - Seg/Bus/Dev | ||
995 | * pci_register - Device Register | ||
996 | * value - Buffer where value is placed | ||
997 | * width - Number of bits | ||
998 | * | ||
999 | * RETURN: Status | ||
1000 | * | ||
1001 | * DESCRIPTION: Read data from PCI configuration space | ||
1002 | * | ||
1003 | *****************************************************************************/ | ||
1004 | |||
1005 | acpi_status | ||
1006 | acpi_os_read_pci_configuration(struct acpi_pci_id *pci_id, | ||
1007 | u32 pci_register, u64 *value, u32 width) | ||
1008 | { | ||
1009 | |||
1010 | *value = 0; | ||
1011 | return (AE_OK); | ||
1012 | } | ||
1013 | |||
1014 | /****************************************************************************** | ||
1015 | * | ||
1016 | * FUNCTION: acpi_os_write_pci_configuration | ||
1017 | * | ||
1018 | * PARAMETERS: pci_id - Seg/Bus/Dev | ||
1019 | * pci_register - Device Register | ||
1020 | * value - Value to be written | ||
1021 | * width - Number of bits | ||
1022 | * | ||
1023 | * RETURN: Status. | ||
1024 | * | ||
1025 | * DESCRIPTION: Write data to PCI configuration space | ||
1026 | * | ||
1027 | *****************************************************************************/ | ||
1028 | |||
1029 | acpi_status | ||
1030 | acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, | ||
1031 | u32 pci_register, u64 value, u32 width) | ||
1032 | { | ||
1033 | |||
1034 | return (AE_OK); | ||
1035 | } | ||
1036 | |||
1037 | /****************************************************************************** | ||
1038 | * | ||
1039 | * FUNCTION: acpi_os_read_port | ||
1040 | * | ||
1041 | * PARAMETERS: address - Address of I/O port/register to read | ||
1042 | * value - Where value is placed | ||
1043 | * width - Number of bits | ||
1044 | * | ||
1045 | * RETURN: Value read from port | ||
1046 | * | ||
1047 | * DESCRIPTION: Read data from an I/O port or register | ||
1048 | * | ||
1049 | *****************************************************************************/ | ||
1050 | |||
1051 | acpi_status acpi_os_read_port(acpi_io_address address, u32 *value, u32 width) | ||
1052 | { | ||
1053 | |||
1054 | switch (width) { | ||
1055 | case 8: | ||
1056 | |||
1057 | *value = 0xFF; | ||
1058 | break; | ||
1059 | |||
1060 | case 16: | ||
1061 | |||
1062 | *value = 0xFFFF; | ||
1063 | break; | ||
1064 | |||
1065 | case 32: | ||
1066 | |||
1067 | *value = 0xFFFFFFFF; | ||
1068 | break; | ||
1069 | |||
1070 | default: | ||
1071 | |||
1072 | return (AE_BAD_PARAMETER); | ||
1073 | } | ||
1074 | |||
1075 | return (AE_OK); | ||
1076 | } | ||
1077 | |||
1078 | /****************************************************************************** | ||
1079 | * | ||
1080 | * FUNCTION: acpi_os_write_port | ||
1081 | * | ||
1082 | * PARAMETERS: address - Address of I/O port/register to write | ||
1083 | * value - Value to write | ||
1084 | * width - Number of bits | ||
1085 | * | ||
1086 | * RETURN: None | ||
1087 | * | ||
1088 | * DESCRIPTION: Write data to an I/O port or register | ||
1089 | * | ||
1090 | *****************************************************************************/ | ||
1091 | |||
1092 | acpi_status acpi_os_write_port(acpi_io_address address, u32 value, u32 width) | ||
1093 | { | ||
1094 | |||
1095 | return (AE_OK); | ||
1096 | } | ||
1097 | |||
1098 | /****************************************************************************** | ||
1099 | * | ||
1100 | * FUNCTION: acpi_os_read_memory | ||
1101 | * | ||
1102 | * PARAMETERS: address - Physical Memory Address to read | ||
1103 | * value - Where value is placed | ||
1104 | * width - Number of bits (8,16,32, or 64) | ||
1105 | * | ||
1106 | * RETURN: Value read from physical memory address. Always returned | ||
1107 | * as a 64-bit integer, regardless of the read width. | ||
1108 | * | ||
1109 | * DESCRIPTION: Read data from a physical memory address | ||
1110 | * | ||
1111 | *****************************************************************************/ | ||
1112 | |||
1113 | acpi_status | ||
1114 | acpi_os_read_memory(acpi_physical_address address, u64 *value, u32 width) | ||
1115 | { | ||
1116 | |||
1117 | switch (width) { | ||
1118 | case 8: | ||
1119 | case 16: | ||
1120 | case 32: | ||
1121 | case 64: | ||
1122 | |||
1123 | *value = 0; | ||
1124 | break; | ||
1125 | |||
1126 | default: | ||
1127 | |||
1128 | return (AE_BAD_PARAMETER); | ||
1129 | } | ||
1130 | return (AE_OK); | ||
1131 | } | ||
1132 | |||
1133 | /****************************************************************************** | ||
1134 | * | ||
1135 | * FUNCTION: acpi_os_write_memory | ||
1136 | * | ||
1137 | * PARAMETERS: address - Physical Memory Address to write | ||
1138 | * value - Value to write | ||
1139 | * width - Number of bits (8,16,32, or 64) | ||
1140 | * | ||
1141 | * RETURN: None | ||
1142 | * | ||
1143 | * DESCRIPTION: Write data to a physical memory address | ||
1144 | * | ||
1145 | *****************************************************************************/ | ||
1146 | |||
1147 | acpi_status | ||
1148 | acpi_os_write_memory(acpi_physical_address address, u64 value, u32 width) | ||
1149 | { | ||
1150 | |||
1151 | return (AE_OK); | ||
1152 | } | ||
1153 | |||
1154 | /****************************************************************************** | ||
1155 | * | ||
1156 | * FUNCTION: acpi_os_readable | ||
1157 | * | ||
1158 | * PARAMETERS: pointer - Area to be verified | ||
1159 | * length - Size of area | ||
1160 | * | ||
1161 | * RETURN: TRUE if readable for entire length | ||
1162 | * | ||
1163 | * DESCRIPTION: Verify that a pointer is valid for reading | ||
1164 | * | ||
1165 | *****************************************************************************/ | ||
1166 | |||
1167 | u8 acpi_os_readable(void *pointer, acpi_size length) | ||
1168 | { | ||
1169 | |||
1170 | return (TRUE); | ||
1171 | } | ||
1172 | |||
1173 | /****************************************************************************** | ||
1174 | * | ||
1175 | * FUNCTION: acpi_os_writable | ||
1176 | * | ||
1177 | * PARAMETERS: pointer - Area to be verified | ||
1178 | * length - Size of area | ||
1179 | * | ||
1180 | * RETURN: TRUE if writable for entire length | ||
1181 | * | ||
1182 | * DESCRIPTION: Verify that a pointer is valid for writing | ||
1183 | * | ||
1184 | *****************************************************************************/ | ||
1185 | |||
1186 | u8 acpi_os_writable(void *pointer, acpi_size length) | ||
1187 | { | ||
1188 | |||
1189 | return (TRUE); | ||
1190 | } | ||
1191 | |||
1192 | /****************************************************************************** | ||
1193 | * | ||
1194 | * FUNCTION: acpi_os_signal | ||
1195 | * | ||
1196 | * PARAMETERS: function - ACPI A signal function code | ||
1197 | * info - Pointer to function-dependent structure | ||
1198 | * | ||
1199 | * RETURN: Status | ||
1200 | * | ||
1201 | * DESCRIPTION: Miscellaneous functions. Example implementation only. | ||
1202 | * | ||
1203 | *****************************************************************************/ | ||
1204 | |||
1205 | acpi_status acpi_os_signal(u32 function, void *info) | ||
1206 | { | ||
1207 | |||
1208 | switch (function) { | ||
1209 | case ACPI_SIGNAL_FATAL: | ||
1210 | |||
1211 | break; | ||
1212 | |||
1213 | case ACPI_SIGNAL_BREAKPOINT: | ||
1214 | |||
1215 | break; | ||
1216 | |||
1217 | default: | ||
1218 | |||
1219 | break; | ||
1220 | } | ||
1221 | |||
1222 | return (AE_OK); | ||
1223 | } | ||
1224 | |||
1225 | /* Optional multi-thread support */ | ||
1226 | |||
1227 | #ifndef ACPI_SINGLE_THREADED | ||
1228 | /****************************************************************************** | ||
1229 | * | ||
1230 | * FUNCTION: acpi_os_get_thread_id | ||
1231 | * | ||
1232 | * PARAMETERS: None | ||
1233 | * | ||
1234 | * RETURN: Id of the running thread | ||
1235 | * | ||
1236 | * DESCRIPTION: Get the ID of the current (running) thread | ||
1237 | * | ||
1238 | *****************************************************************************/ | ||
1239 | |||
1240 | acpi_thread_id acpi_os_get_thread_id(void) | ||
1241 | { | ||
1242 | pthread_t thread; | ||
1243 | |||
1244 | thread = pthread_self(); | ||
1245 | return (ACPI_CAST_PTHREAD_T(thread)); | ||
1246 | } | ||
1247 | |||
1248 | /****************************************************************************** | ||
1249 | * | ||
1250 | * FUNCTION: acpi_os_execute | ||
1251 | * | ||
1252 | * PARAMETERS: type - Type of execution | ||
1253 | * function - Address of the function to execute | ||
1254 | * context - Passed as a parameter to the function | ||
1255 | * | ||
1256 | * RETURN: Status. | ||
1257 | * | ||
1258 | * DESCRIPTION: Execute a new thread | ||
1259 | * | ||
1260 | *****************************************************************************/ | ||
1261 | |||
1262 | acpi_status | ||
1263 | acpi_os_execute(acpi_execute_type type, | ||
1264 | acpi_osd_exec_callback function, void *context) | ||
1265 | { | ||
1266 | pthread_t thread; | ||
1267 | int ret; | ||
1268 | |||
1269 | ret = | ||
1270 | pthread_create(&thread, NULL, (PTHREAD_CALLBACK) function, context); | ||
1271 | if (ret) { | ||
1272 | acpi_os_printf("Create thread failed"); | ||
1273 | } | ||
1274 | return (0); | ||
1275 | } | ||
1276 | |||
1277 | #else /* ACPI_SINGLE_THREADED */ | ||
1278 | acpi_thread_id acpi_os_get_thread_id(void) | ||
1279 | { | ||
1280 | return (1); | ||
1281 | } | ||
1282 | |||
1283 | acpi_status | ||
1284 | acpi_os_execute(acpi_execute_type type, | ||
1285 | acpi_osd_exec_callback function, void *context) | ||
1286 | { | ||
1287 | |||
1288 | function(context); | ||
1289 | |||
1290 | return (AE_OK); | ||
1291 | } | ||
1292 | |||
1293 | #endif /* ACPI_SINGLE_THREADED */ | ||
1294 | |||
1295 | /****************************************************************************** | ||
1296 | * | ||
1297 | * FUNCTION: acpi_os_wait_events_complete | ||
1298 | * | ||
1299 | * PARAMETERS: None | ||
1300 | * | ||
1301 | * RETURN: None | ||
1302 | * | ||
1303 | * DESCRIPTION: Wait for all asynchronous events to complete. This | ||
1304 | * implementation does nothing. | ||
1305 | * | ||
1306 | *****************************************************************************/ | ||
1307 | |||
1308 | void acpi_os_wait_events_complete(void) | ||
1309 | { | ||
1310 | return; | ||
1311 | } | ||
diff --git a/tools/power/acpi/tools/acpidump/acpidump.h b/tools/power/acpi/tools/acpidump/acpidump.h index 46f519597fe5..a2d37d610639 100644 --- a/tools/power/acpi/tools/acpidump/acpidump.h +++ b/tools/power/acpi/tools/acpidump/acpidump.h | |||
@@ -47,7 +47,6 @@ | |||
47 | #ifdef _DECLARE_GLOBALS | 47 | #ifdef _DECLARE_GLOBALS |
48 | #define EXTERN | 48 | #define EXTERN |
49 | #define INIT_GLOBAL(a,b) a=b | 49 | #define INIT_GLOBAL(a,b) a=b |
50 | #define DEFINE_ACPI_GLOBALS 1 | ||
51 | #else | 50 | #else |
52 | #define EXTERN extern | 51 | #define EXTERN extern |
53 | #define INIT_GLOBAL(a,b) a | 52 | #define INIT_GLOBAL(a,b) a |
@@ -69,7 +68,7 @@ EXTERN u8 INIT_GLOBAL(gbl_verbose_mode, FALSE); | |||
69 | EXTERN u8 INIT_GLOBAL(gbl_binary_mode, FALSE); | 68 | EXTERN u8 INIT_GLOBAL(gbl_binary_mode, FALSE); |
70 | EXTERN u8 INIT_GLOBAL(gbl_dump_customized_tables, FALSE); | 69 | EXTERN u8 INIT_GLOBAL(gbl_dump_customized_tables, FALSE); |
71 | EXTERN u8 INIT_GLOBAL(gbl_do_not_dump_xsdt, FALSE); | 70 | EXTERN u8 INIT_GLOBAL(gbl_do_not_dump_xsdt, FALSE); |
72 | EXTERN FILE INIT_GLOBAL(*gbl_output_file, NULL); | 71 | EXTERN ACPI_FILE INIT_GLOBAL(gbl_output_file, NULL); |
73 | EXTERN char INIT_GLOBAL(*gbl_output_filename, NULL); | 72 | EXTERN char INIT_GLOBAL(*gbl_output_filename, NULL); |
74 | EXTERN u64 INIT_GLOBAL(gbl_rsdp_base, 0); | 73 | EXTERN u64 INIT_GLOBAL(gbl_rsdp_base, 0); |
75 | 74 | ||
diff --git a/tools/power/acpi/tools/acpidump/apdump.c b/tools/power/acpi/tools/acpidump/apdump.c index 3cac12378366..53cee781e24e 100644 --- a/tools/power/acpi/tools/acpidump/apdump.c +++ b/tools/power/acpi/tools/acpidump/apdump.c | |||
@@ -69,17 +69,16 @@ u8 ap_is_valid_header(struct acpi_table_header *table) | |||
69 | /* Make sure signature is all ASCII and a valid ACPI name */ | 69 | /* Make sure signature is all ASCII and a valid ACPI name */ |
70 | 70 | ||
71 | if (!acpi_ut_valid_acpi_name(table->signature)) { | 71 | if (!acpi_ut_valid_acpi_name(table->signature)) { |
72 | fprintf(stderr, | 72 | acpi_log_error("Table signature (0x%8.8X) is invalid\n", |
73 | "Table signature (0x%8.8X) is invalid\n", | 73 | *(u32 *)table->signature); |
74 | *(u32 *)table->signature); | ||
75 | return (FALSE); | 74 | return (FALSE); |
76 | } | 75 | } |
77 | 76 | ||
78 | /* Check for minimum table length */ | 77 | /* Check for minimum table length */ |
79 | 78 | ||
80 | if (table->length < sizeof(struct acpi_table_header)) { | 79 | if (table->length < sizeof(struct acpi_table_header)) { |
81 | fprintf(stderr, "Table length (0x%8.8X) is invalid\n", | 80 | acpi_log_error("Table length (0x%8.8X) is invalid\n", |
82 | table->length); | 81 | table->length); |
83 | return (FALSE); | 82 | return (FALSE); |
84 | } | 83 | } |
85 | } | 84 | } |
@@ -116,8 +115,8 @@ u8 ap_is_valid_checksum(struct acpi_table_header *table) | |||
116 | } | 115 | } |
117 | 116 | ||
118 | if (ACPI_FAILURE(status)) { | 117 | if (ACPI_FAILURE(status)) { |
119 | fprintf(stderr, "%4.4s: Warning: wrong checksum in table\n", | 118 | acpi_log_error("%4.4s: Warning: wrong checksum in table\n", |
120 | table->signature); | 119 | table->signature); |
121 | } | 120 | } |
122 | 121 | ||
123 | return (AE_OK); | 122 | return (AE_OK); |
@@ -196,12 +195,13 @@ ap_dump_table_buffer(struct acpi_table_header *table, | |||
196 | * Note: simplest to just always emit a 64-bit address. acpi_xtract | 195 | * Note: simplest to just always emit a 64-bit address. acpi_xtract |
197 | * utility can handle this. | 196 | * utility can handle this. |
198 | */ | 197 | */ |
199 | printf("%4.4s @ 0x%8.8X%8.8X\n", table->signature, | 198 | acpi_ut_file_printf(gbl_output_file, "%4.4s @ 0x%8.8X%8.8X\n", |
200 | ACPI_FORMAT_UINT64(address)); | 199 | table->signature, ACPI_FORMAT_UINT64(address)); |
201 | 200 | ||
202 | acpi_ut_dump_buffer(ACPI_CAST_PTR(u8, table), table_length, | 201 | acpi_ut_dump_buffer_to_file(gbl_output_file, |
203 | DB_BYTE_DISPLAY, 0); | 202 | ACPI_CAST_PTR(u8, table), table_length, |
204 | printf("\n"); | 203 | DB_BYTE_DISPLAY, 0); |
204 | acpi_ut_file_printf(gbl_output_file, "\n"); | ||
205 | return (0); | 205 | return (0); |
206 | } | 206 | } |
207 | 207 | ||
@@ -239,20 +239,20 @@ int ap_dump_all_tables(void) | |||
239 | if (status == AE_LIMIT) { | 239 | if (status == AE_LIMIT) { |
240 | return (0); | 240 | return (0); |
241 | } else if (i == 0) { | 241 | } else if (i == 0) { |
242 | fprintf(stderr, | 242 | acpi_log_error |
243 | "Could not get ACPI tables, %s\n", | 243 | ("Could not get ACPI tables, %s\n", |
244 | acpi_format_exception(status)); | 244 | acpi_format_exception(status)); |
245 | return (-1); | 245 | return (-1); |
246 | } else { | 246 | } else { |
247 | fprintf(stderr, | 247 | acpi_log_error |
248 | "Could not get ACPI table at index %u, %s\n", | 248 | ("Could not get ACPI table at index %u, %s\n", |
249 | i, acpi_format_exception(status)); | 249 | i, acpi_format_exception(status)); |
250 | continue; | 250 | continue; |
251 | } | 251 | } |
252 | } | 252 | } |
253 | 253 | ||
254 | table_status = ap_dump_table_buffer(table, instance, address); | 254 | table_status = ap_dump_table_buffer(table, instance, address); |
255 | free(table); | 255 | ACPI_FREE(table); |
256 | 256 | ||
257 | if (table_status) { | 257 | if (table_status) { |
258 | break; | 258 | break; |
@@ -288,22 +288,22 @@ int ap_dump_table_by_address(char *ascii_address) | |||
288 | 288 | ||
289 | status = acpi_ut_strtoul64(ascii_address, 0, &long_address); | 289 | status = acpi_ut_strtoul64(ascii_address, 0, &long_address); |
290 | if (ACPI_FAILURE(status)) { | 290 | if (ACPI_FAILURE(status)) { |
291 | fprintf(stderr, "%s: Could not convert to a physical address\n", | 291 | acpi_log_error("%s: Could not convert to a physical address\n", |
292 | ascii_address); | 292 | ascii_address); |
293 | return (-1); | 293 | return (-1); |
294 | } | 294 | } |
295 | 295 | ||
296 | address = (acpi_physical_address) long_address; | 296 | address = (acpi_physical_address) long_address; |
297 | status = acpi_os_get_table_by_address(address, &table); | 297 | status = acpi_os_get_table_by_address(address, &table); |
298 | if (ACPI_FAILURE(status)) { | 298 | if (ACPI_FAILURE(status)) { |
299 | fprintf(stderr, "Could not get table at 0x%8.8X%8.8X, %s\n", | 299 | acpi_log_error("Could not get table at 0x%8.8X%8.8X, %s\n", |
300 | ACPI_FORMAT_UINT64(address), | 300 | ACPI_FORMAT_UINT64(address), |
301 | acpi_format_exception(status)); | 301 | acpi_format_exception(status)); |
302 | return (-1); | 302 | return (-1); |
303 | } | 303 | } |
304 | 304 | ||
305 | table_status = ap_dump_table_buffer(table, 0, address); | 305 | table_status = ap_dump_table_buffer(table, 0, address); |
306 | free(table); | 306 | ACPI_FREE(table); |
307 | return (table_status); | 307 | return (table_status); |
308 | } | 308 | } |
309 | 309 | ||
@@ -329,24 +329,24 @@ int ap_dump_table_by_name(char *signature) | |||
329 | acpi_status status; | 329 | acpi_status status; |
330 | int table_status; | 330 | int table_status; |
331 | 331 | ||
332 | if (strlen(signature) != ACPI_NAME_SIZE) { | 332 | if (ACPI_STRLEN(signature) != ACPI_NAME_SIZE) { |
333 | fprintf(stderr, | 333 | acpi_log_error |
334 | "Invalid table signature [%s]: must be exactly 4 characters\n", | 334 | ("Invalid table signature [%s]: must be exactly 4 characters\n", |
335 | signature); | 335 | signature); |
336 | return (-1); | 336 | return (-1); |
337 | } | 337 | } |
338 | 338 | ||
339 | /* Table signatures are expected to be uppercase */ | 339 | /* Table signatures are expected to be uppercase */ |
340 | 340 | ||
341 | strcpy(local_signature, signature); | 341 | ACPI_STRCPY(local_signature, signature); |
342 | acpi_ut_strupr(local_signature); | 342 | acpi_ut_strupr(local_signature); |
343 | 343 | ||
344 | /* To be friendly, handle tables whose signatures do not match the name */ | 344 | /* To be friendly, handle tables whose signatures do not match the name */ |
345 | 345 | ||
346 | if (ACPI_COMPARE_NAME(local_signature, "FADT")) { | 346 | if (ACPI_COMPARE_NAME(local_signature, "FADT")) { |
347 | strcpy(local_signature, ACPI_SIG_FADT); | 347 | ACPI_STRCPY(local_signature, ACPI_SIG_FADT); |
348 | } else if (ACPI_COMPARE_NAME(local_signature, "MADT")) { | 348 | } else if (ACPI_COMPARE_NAME(local_signature, "MADT")) { |
349 | strcpy(local_signature, ACPI_SIG_MADT); | 349 | ACPI_STRCPY(local_signature, ACPI_SIG_MADT); |
350 | } | 350 | } |
351 | 351 | ||
352 | /* Dump all instances of this signature (to handle multiple SSDTs) */ | 352 | /* Dump all instances of this signature (to handle multiple SSDTs) */ |
@@ -362,14 +362,14 @@ int ap_dump_table_by_name(char *signature) | |||
362 | return (0); | 362 | return (0); |
363 | } | 363 | } |
364 | 364 | ||
365 | fprintf(stderr, | 365 | acpi_log_error |
366 | "Could not get ACPI table with signature [%s], %s\n", | 366 | ("Could not get ACPI table with signature [%s], %s\n", |
367 | local_signature, acpi_format_exception(status)); | 367 | local_signature, acpi_format_exception(status)); |
368 | return (-1); | 368 | return (-1); |
369 | } | 369 | } |
370 | 370 | ||
371 | table_status = ap_dump_table_buffer(table, instance, address); | 371 | table_status = ap_dump_table_buffer(table, instance, address); |
372 | free(table); | 372 | ACPI_FREE(table); |
373 | 373 | ||
374 | if (table_status) { | 374 | if (table_status) { |
375 | break; | 375 | break; |
@@ -409,43 +409,21 @@ int ap_dump_table_from_file(char *pathname) | |||
409 | /* File must be at least as long as the table length */ | 409 | /* File must be at least as long as the table length */ |
410 | 410 | ||
411 | if (table->length > file_size) { | 411 | if (table->length > file_size) { |
412 | fprintf(stderr, | 412 | acpi_log_error |
413 | "Table length (0x%X) is too large for input file (0x%X) %s\n", | 413 | ("Table length (0x%X) is too large for input file (0x%X) %s\n", |
414 | table->length, file_size, pathname); | 414 | table->length, file_size, pathname); |
415 | goto exit; | 415 | goto exit; |
416 | } | 416 | } |
417 | 417 | ||
418 | if (gbl_verbose_mode) { | 418 | if (gbl_verbose_mode) { |
419 | fprintf(stderr, | 419 | acpi_log_error |
420 | "Input file: %s contains table [%4.4s], 0x%X (%u) bytes\n", | 420 | ("Input file: %s contains table [%4.4s], 0x%X (%u) bytes\n", |
421 | pathname, table->signature, file_size, file_size); | 421 | pathname, table->signature, file_size, file_size); |
422 | } | 422 | } |
423 | 423 | ||
424 | table_status = ap_dump_table_buffer(table, 0, 0); | 424 | table_status = ap_dump_table_buffer(table, 0, 0); |
425 | 425 | ||
426 | exit: | 426 | exit: |
427 | free(table); | 427 | ACPI_FREE(table); |
428 | return (table_status); | 428 | return (table_status); |
429 | } | 429 | } |
430 | |||
431 | /****************************************************************************** | ||
432 | * | ||
433 | * FUNCTION: acpi_os* print functions | ||
434 | * | ||
435 | * DESCRIPTION: Used for linkage with ACPICA modules | ||
436 | * | ||
437 | ******************************************************************************/ | ||
438 | |||
439 | void ACPI_INTERNAL_VAR_XFACE acpi_os_printf(const char *fmt, ...) | ||
440 | { | ||
441 | va_list args; | ||
442 | |||
443 | va_start(args, fmt); | ||
444 | vfprintf(stdout, fmt, args); | ||
445 | va_end(args); | ||
446 | } | ||
447 | |||
448 | void acpi_os_vprintf(const char *fmt, va_list args) | ||
449 | { | ||
450 | vfprintf(stdout, fmt, args); | ||
451 | } | ||
diff --git a/tools/power/acpi/tools/acpidump/apfiles.c b/tools/power/acpi/tools/acpidump/apfiles.c index 4488accc010b..d470046a6d81 100644 --- a/tools/power/acpi/tools/acpidump/apfiles.c +++ b/tools/power/acpi/tools/acpidump/apfiles.c | |||
@@ -44,6 +44,27 @@ | |||
44 | #include "acpidump.h" | 44 | #include "acpidump.h" |
45 | #include "acapps.h" | 45 | #include "acapps.h" |
46 | 46 | ||
47 | /* Local prototypes */ | ||
48 | |||
49 | static int ap_is_existing_file(char *pathname); | ||
50 | |||
51 | static int ap_is_existing_file(char *pathname) | ||
52 | { | ||
53 | #ifndef _GNU_EFI | ||
54 | struct stat stat_info; | ||
55 | |||
56 | if (!stat(pathname, &stat_info)) { | ||
57 | acpi_log_error("Target path already exists, overwrite? [y|n] "); | ||
58 | |||
59 | if (getchar() != 'y') { | ||
60 | return (-1); | ||
61 | } | ||
62 | } | ||
63 | #endif | ||
64 | |||
65 | return 0; | ||
66 | } | ||
67 | |||
47 | /****************************************************************************** | 68 | /****************************************************************************** |
48 | * | 69 | * |
49 | * FUNCTION: ap_open_output_file | 70 | * FUNCTION: ap_open_output_file |
@@ -59,25 +80,19 @@ | |||
59 | 80 | ||
60 | int ap_open_output_file(char *pathname) | 81 | int ap_open_output_file(char *pathname) |
61 | { | 82 | { |
62 | struct stat stat_info; | 83 | ACPI_FILE file; |
63 | FILE *file; | ||
64 | 84 | ||
65 | /* If file exists, prompt for overwrite */ | 85 | /* If file exists, prompt for overwrite */ |
66 | 86 | ||
67 | if (!stat(pathname, &stat_info)) { | 87 | if (ap_is_existing_file(pathname) != 0) { |
68 | fprintf(stderr, | 88 | return (-1); |
69 | "Target path already exists, overwrite? [y|n] "); | ||
70 | |||
71 | if (getchar() != 'y') { | ||
72 | return (-1); | ||
73 | } | ||
74 | } | 89 | } |
75 | 90 | ||
76 | /* Point stdout to the file */ | 91 | /* Point stdout to the file */ |
77 | 92 | ||
78 | file = freopen(pathname, "w", stdout); | 93 | file = acpi_os_open_file(pathname, ACPI_FILE_WRITING); |
79 | if (!file) { | 94 | if (!file) { |
80 | perror("Could not open output file"); | 95 | acpi_log_error("Could not open output file: %s\n", pathname); |
81 | return (-1); | 96 | return (-1); |
82 | } | 97 | } |
83 | 98 | ||
@@ -106,7 +121,7 @@ int ap_write_to_binary_file(struct acpi_table_header *table, u32 instance) | |||
106 | { | 121 | { |
107 | char filename[ACPI_NAME_SIZE + 16]; | 122 | char filename[ACPI_NAME_SIZE + 16]; |
108 | char instance_str[16]; | 123 | char instance_str[16]; |
109 | FILE *file; | 124 | ACPI_FILE file; |
110 | size_t actual; | 125 | size_t actual; |
111 | u32 table_length; | 126 | u32 table_length; |
112 | 127 | ||
@@ -130,35 +145,37 @@ int ap_write_to_binary_file(struct acpi_table_header *table, u32 instance) | |||
130 | /* Handle multiple SSDts - create different filenames for each */ | 145 | /* Handle multiple SSDts - create different filenames for each */ |
131 | 146 | ||
132 | if (instance > 0) { | 147 | if (instance > 0) { |
133 | sprintf(instance_str, "%u", instance); | 148 | acpi_ut_snprintf(instance_str, sizeof(instance_str), "%u", |
134 | strcat(filename, instance_str); | 149 | instance); |
150 | ACPI_STRCAT(filename, instance_str); | ||
135 | } | 151 | } |
136 | 152 | ||
137 | strcat(filename, ACPI_TABLE_FILE_SUFFIX); | 153 | ACPI_STRCAT(filename, ACPI_TABLE_FILE_SUFFIX); |
138 | 154 | ||
139 | if (gbl_verbose_mode) { | 155 | if (gbl_verbose_mode) { |
140 | fprintf(stderr, | 156 | acpi_log_error |
141 | "Writing [%4.4s] to binary file: %s 0x%X (%u) bytes\n", | 157 | ("Writing [%4.4s] to binary file: %s 0x%X (%u) bytes\n", |
142 | table->signature, filename, table->length, | 158 | table->signature, filename, table->length, table->length); |
143 | table->length); | ||
144 | } | 159 | } |
145 | 160 | ||
146 | /* Open the file and dump the entire table in binary mode */ | 161 | /* Open the file and dump the entire table in binary mode */ |
147 | 162 | ||
148 | file = fopen(filename, "wb"); | 163 | file = acpi_os_open_file(filename, |
164 | ACPI_FILE_WRITING | ACPI_FILE_BINARY); | ||
149 | if (!file) { | 165 | if (!file) { |
150 | perror("Could not open output file"); | 166 | acpi_log_error("Could not open output file: %s\n", filename); |
151 | return (-1); | 167 | return (-1); |
152 | } | 168 | } |
153 | 169 | ||
154 | actual = fwrite(table, 1, table_length, file); | 170 | actual = acpi_os_write_file(file, table, 1, table_length); |
155 | if (actual != table_length) { | 171 | if (actual != table_length) { |
156 | perror("Error writing binary output file"); | 172 | acpi_log_error("Error writing binary output file: %s\n", |
157 | fclose(file); | 173 | filename); |
174 | acpi_os_close_file(file); | ||
158 | return (-1); | 175 | return (-1); |
159 | } | 176 | } |
160 | 177 | ||
161 | fclose(file); | 178 | acpi_os_close_file(file); |
162 | return (0); | 179 | return (0); |
163 | } | 180 | } |
164 | 181 | ||
@@ -179,15 +196,16 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname, | |||
179 | u32 *out_file_size) | 196 | u32 *out_file_size) |
180 | { | 197 | { |
181 | struct acpi_table_header *buffer = NULL; | 198 | struct acpi_table_header *buffer = NULL; |
182 | FILE *file; | 199 | ACPI_FILE file; |
183 | u32 file_size; | 200 | u32 file_size; |
184 | size_t actual; | 201 | size_t actual; |
185 | 202 | ||
186 | /* Must use binary mode */ | 203 | /* Must use binary mode */ |
187 | 204 | ||
188 | file = fopen(pathname, "rb"); | 205 | file = |
206 | acpi_os_open_file(pathname, ACPI_FILE_READING | ACPI_FILE_BINARY); | ||
189 | if (!file) { | 207 | if (!file) { |
190 | perror("Could not open input file"); | 208 | acpi_log_error("Could not open input file: %s\n", pathname); |
191 | return (NULL); | 209 | return (NULL); |
192 | } | 210 | } |
193 | 211 | ||
@@ -195,27 +213,25 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname, | |||
195 | 213 | ||
196 | file_size = cm_get_file_size(file); | 214 | file_size = cm_get_file_size(file); |
197 | if (file_size == ACPI_UINT32_MAX) { | 215 | if (file_size == ACPI_UINT32_MAX) { |
198 | fprintf(stderr, | 216 | acpi_log_error("Could not get input file size: %s\n", pathname); |
199 | "Could not get input file size: %s\n", pathname); | ||
200 | goto cleanup; | 217 | goto cleanup; |
201 | } | 218 | } |
202 | 219 | ||
203 | /* Allocate a buffer for the entire file */ | 220 | /* Allocate a buffer for the entire file */ |
204 | 221 | ||
205 | buffer = calloc(1, file_size); | 222 | buffer = ACPI_ALLOCATE_ZEROED(file_size); |
206 | if (!buffer) { | 223 | if (!buffer) { |
207 | fprintf(stderr, | 224 | acpi_log_error("Could not allocate file buffer of size: %u\n", |
208 | "Could not allocate file buffer of size: %u\n", | 225 | file_size); |
209 | file_size); | ||
210 | goto cleanup; | 226 | goto cleanup; |
211 | } | 227 | } |
212 | 228 | ||
213 | /* Read the entire file */ | 229 | /* Read the entire file */ |
214 | 230 | ||
215 | actual = fread(buffer, 1, file_size, file); | 231 | actual = acpi_os_read_file(file, buffer, 1, file_size); |
216 | if (actual != file_size) { | 232 | if (actual != file_size) { |
217 | fprintf(stderr, "Could not read input file: %s\n", pathname); | 233 | acpi_log_error("Could not read input file: %s\n", pathname); |
218 | free(buffer); | 234 | ACPI_FREE(buffer); |
219 | buffer = NULL; | 235 | buffer = NULL; |
220 | goto cleanup; | 236 | goto cleanup; |
221 | } | 237 | } |
@@ -223,6 +239,6 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname, | |||
223 | *out_file_size = file_size; | 239 | *out_file_size = file_size; |
224 | 240 | ||
225 | cleanup: | 241 | cleanup: |
226 | fclose(file); | 242 | acpi_os_close_file(file); |
227 | return (buffer); | 243 | return (buffer); |
228 | } | 244 | } |
diff --git a/tools/power/acpi/tools/acpidump/apmain.c b/tools/power/acpi/tools/acpidump/apmain.c index 51e8d638db18..853b4da22c3e 100644 --- a/tools/power/acpi/tools/acpidump/apmain.c +++ b/tools/power/acpi/tools/acpidump/apmain.c | |||
@@ -72,7 +72,7 @@ static void ap_display_usage(void); | |||
72 | 72 | ||
73 | static int ap_do_options(int argc, char **argv); | 73 | static int ap_do_options(int argc, char **argv); |
74 | 74 | ||
75 | static void ap_insert_action(char *argument, u32 to_be_done); | 75 | static int ap_insert_action(char *argument, u32 to_be_done); |
76 | 76 | ||
77 | /* Table for deferred actions from command line options */ | 77 | /* Table for deferred actions from command line options */ |
78 | 78 | ||
@@ -104,7 +104,7 @@ static void ap_display_usage(void) | |||
104 | ACPI_OPTION("-v", "Display version information"); | 104 | ACPI_OPTION("-v", "Display version information"); |
105 | ACPI_OPTION("-z", "Verbose mode"); | 105 | ACPI_OPTION("-z", "Verbose mode"); |
106 | 106 | ||
107 | printf("\nTable Options:\n"); | 107 | ACPI_USAGE_TEXT("\nTable Options:\n"); |
108 | 108 | ||
109 | ACPI_OPTION("-a <Address>", "Get table via a physical address"); | 109 | ACPI_OPTION("-a <Address>", "Get table via a physical address"); |
110 | ACPI_OPTION("-f <BinaryFile>", "Get table via a binary file"); | 110 | ACPI_OPTION("-f <BinaryFile>", "Get table via a binary file"); |
@@ -112,9 +112,9 @@ static void ap_display_usage(void) | |||
112 | ACPI_OPTION("-x", "Do not use but dump XSDT"); | 112 | ACPI_OPTION("-x", "Do not use but dump XSDT"); |
113 | ACPI_OPTION("-x -x", "Do not use or dump XSDT"); | 113 | ACPI_OPTION("-x -x", "Do not use or dump XSDT"); |
114 | 114 | ||
115 | printf("\n" | 115 | ACPI_USAGE_TEXT("\n" |
116 | "Invocation without parameters dumps all available tables\n" | 116 | "Invocation without parameters dumps all available tables\n" |
117 | "Multiple mixed instances of -a, -f, and -n are supported\n\n"); | 117 | "Multiple mixed instances of -a, -f, and -n are supported\n\n"); |
118 | } | 118 | } |
119 | 119 | ||
120 | /****************************************************************************** | 120 | /****************************************************************************** |
@@ -124,13 +124,13 @@ static void ap_display_usage(void) | |||
124 | * PARAMETERS: argument - Pointer to the argument for this action | 124 | * PARAMETERS: argument - Pointer to the argument for this action |
125 | * to_be_done - What to do to process this action | 125 | * to_be_done - What to do to process this action |
126 | * | 126 | * |
127 | * RETURN: None. Exits program if action table becomes full. | 127 | * RETURN: Status |
128 | * | 128 | * |
129 | * DESCRIPTION: Add an action item to the action table | 129 | * DESCRIPTION: Add an action item to the action table |
130 | * | 130 | * |
131 | ******************************************************************************/ | 131 | ******************************************************************************/ |
132 | 132 | ||
133 | static void ap_insert_action(char *argument, u32 to_be_done) | 133 | static int ap_insert_action(char *argument, u32 to_be_done) |
134 | { | 134 | { |
135 | 135 | ||
136 | /* Insert action and check for table overflow */ | 136 | /* Insert action and check for table overflow */ |
@@ -140,10 +140,12 @@ static void ap_insert_action(char *argument, u32 to_be_done) | |||
140 | 140 | ||
141 | current_action++; | 141 | current_action++; |
142 | if (current_action > AP_MAX_ACTIONS) { | 142 | if (current_action > AP_MAX_ACTIONS) { |
143 | fprintf(stderr, "Too many table options (max %u)\n", | 143 | acpi_log_error("Too many table options (max %u)\n", |
144 | AP_MAX_ACTIONS); | 144 | AP_MAX_ACTIONS); |
145 | exit(-1); | 145 | return (-1); |
146 | } | 146 | } |
147 | |||
148 | return (0); | ||
147 | } | 149 | } |
148 | 150 | ||
149 | /****************************************************************************** | 151 | /****************************************************************************** |
@@ -166,7 +168,8 @@ static int ap_do_options(int argc, char **argv) | |||
166 | 168 | ||
167 | /* Command line options */ | 169 | /* Command line options */ |
168 | 170 | ||
169 | while ((j = acpi_getopt(argc, argv, AP_SUPPORTED_OPTIONS)) != EOF) | 171 | while ((j = |
172 | acpi_getopt(argc, argv, AP_SUPPORTED_OPTIONS)) != ACPI_OPT_END) | ||
170 | switch (j) { | 173 | switch (j) { |
171 | /* | 174 | /* |
172 | * Global options | 175 | * Global options |
@@ -185,12 +188,12 @@ static int ap_do_options(int argc, char **argv) | |||
185 | case '?': | 188 | case '?': |
186 | 189 | ||
187 | ap_display_usage(); | 190 | ap_display_usage(); |
188 | exit(0); | 191 | return (1); |
189 | 192 | ||
190 | case 'o': /* Redirect output to a single file */ | 193 | case 'o': /* Redirect output to a single file */ |
191 | 194 | ||
192 | if (ap_open_output_file(acpi_gbl_optarg)) { | 195 | if (ap_open_output_file(acpi_gbl_optarg)) { |
193 | exit(-1); | 196 | return (-1); |
194 | } | 197 | } |
195 | continue; | 198 | continue; |
196 | 199 | ||
@@ -200,10 +203,10 @@ static int ap_do_options(int argc, char **argv) | |||
200 | acpi_ut_strtoul64(acpi_gbl_optarg, 0, | 203 | acpi_ut_strtoul64(acpi_gbl_optarg, 0, |
201 | &gbl_rsdp_base); | 204 | &gbl_rsdp_base); |
202 | if (ACPI_FAILURE(status)) { | 205 | if (ACPI_FAILURE(status)) { |
203 | fprintf(stderr, | 206 | acpi_log_error |
204 | "%s: Could not convert to a physical address\n", | 207 | ("%s: Could not convert to a physical address\n", |
205 | acpi_gbl_optarg); | 208 | acpi_gbl_optarg); |
206 | exit(-1); | 209 | return (-1); |
207 | } | 210 | } |
208 | continue; | 211 | continue; |
209 | 212 | ||
@@ -223,13 +226,13 @@ static int ap_do_options(int argc, char **argv) | |||
223 | 226 | ||
224 | case 'v': /* Revision/version */ | 227 | case 'v': /* Revision/version */ |
225 | 228 | ||
226 | printf(ACPI_COMMON_SIGNON(AP_UTILITY_NAME)); | 229 | acpi_os_printf(ACPI_COMMON_SIGNON(AP_UTILITY_NAME)); |
227 | exit(0); | 230 | return (1); |
228 | 231 | ||
229 | case 'z': /* Verbose mode */ | 232 | case 'z': /* Verbose mode */ |
230 | 233 | ||
231 | gbl_verbose_mode = TRUE; | 234 | gbl_verbose_mode = TRUE; |
232 | fprintf(stderr, ACPI_COMMON_SIGNON(AP_UTILITY_NAME)); | 235 | acpi_log_error(ACPI_COMMON_SIGNON(AP_UTILITY_NAME)); |
233 | continue; | 236 | continue; |
234 | 237 | ||
235 | /* | 238 | /* |
@@ -237,32 +240,40 @@ static int ap_do_options(int argc, char **argv) | |||
237 | */ | 240 | */ |
238 | case 'a': /* Get table by physical address */ | 241 | case 'a': /* Get table by physical address */ |
239 | 242 | ||
240 | ap_insert_action(acpi_gbl_optarg, | 243 | if (ap_insert_action |
241 | AP_DUMP_TABLE_BY_ADDRESS); | 244 | (acpi_gbl_optarg, AP_DUMP_TABLE_BY_ADDRESS)) { |
245 | return (-1); | ||
246 | } | ||
242 | break; | 247 | break; |
243 | 248 | ||
244 | case 'f': /* Get table from a file */ | 249 | case 'f': /* Get table from a file */ |
245 | 250 | ||
246 | ap_insert_action(acpi_gbl_optarg, | 251 | if (ap_insert_action |
247 | AP_DUMP_TABLE_BY_FILE); | 252 | (acpi_gbl_optarg, AP_DUMP_TABLE_BY_FILE)) { |
253 | return (-1); | ||
254 | } | ||
248 | break; | 255 | break; |
249 | 256 | ||
250 | case 'n': /* Get table by input name (signature) */ | 257 | case 'n': /* Get table by input name (signature) */ |
251 | 258 | ||
252 | ap_insert_action(acpi_gbl_optarg, | 259 | if (ap_insert_action |
253 | AP_DUMP_TABLE_BY_NAME); | 260 | (acpi_gbl_optarg, AP_DUMP_TABLE_BY_NAME)) { |
261 | return (-1); | ||
262 | } | ||
254 | break; | 263 | break; |
255 | 264 | ||
256 | default: | 265 | default: |
257 | 266 | ||
258 | ap_display_usage(); | 267 | ap_display_usage(); |
259 | exit(-1); | 268 | return (-1); |
260 | } | 269 | } |
261 | 270 | ||
262 | /* If there are no actions, this means "get/dump all tables" */ | 271 | /* If there are no actions, this means "get/dump all tables" */ |
263 | 272 | ||
264 | if (current_action == 0) { | 273 | if (current_action == 0) { |
265 | ap_insert_action(NULL, AP_DUMP_ALL_TABLES); | 274 | if (ap_insert_action(NULL, AP_DUMP_ALL_TABLES)) { |
275 | return (-1); | ||
276 | } | ||
266 | } | 277 | } |
267 | 278 | ||
268 | return (0); | 279 | return (0); |
@@ -280,7 +291,11 @@ static int ap_do_options(int argc, char **argv) | |||
280 | * | 291 | * |
281 | ******************************************************************************/ | 292 | ******************************************************************************/ |
282 | 293 | ||
294 | #ifndef _GNU_EFI | ||
283 | int ACPI_SYSTEM_XFACE main(int argc, char *argv[]) | 295 | int ACPI_SYSTEM_XFACE main(int argc, char *argv[]) |
296 | #else | ||
297 | int ACPI_SYSTEM_XFACE acpi_main(int argc, char *argv[]) | ||
298 | #endif | ||
284 | { | 299 | { |
285 | int status = 0; | 300 | int status = 0; |
286 | struct ap_dump_action *action; | 301 | struct ap_dump_action *action; |
@@ -288,11 +303,17 @@ int ACPI_SYSTEM_XFACE main(int argc, char *argv[]) | |||
288 | u32 i; | 303 | u32 i; |
289 | 304 | ||
290 | ACPI_DEBUG_INITIALIZE(); /* For debug version only */ | 305 | ACPI_DEBUG_INITIALIZE(); /* For debug version only */ |
306 | acpi_os_initialize(); | ||
307 | gbl_output_file = ACPI_FILE_OUT; | ||
291 | 308 | ||
292 | /* Process command line options */ | 309 | /* Process command line options */ |
293 | 310 | ||
294 | if (ap_do_options(argc, argv)) { | 311 | status = ap_do_options(argc, argv); |
295 | return (-1); | 312 | if (status > 0) { |
313 | return (0); | ||
314 | } | ||
315 | if (status < 0) { | ||
316 | return (status); | ||
296 | } | 317 | } |
297 | 318 | ||
298 | /* Get/dump ACPI table(s) as requested */ | 319 | /* Get/dump ACPI table(s) as requested */ |
@@ -322,9 +343,8 @@ int ACPI_SYSTEM_XFACE main(int argc, char *argv[]) | |||
322 | 343 | ||
323 | default: | 344 | default: |
324 | 345 | ||
325 | fprintf(stderr, | 346 | acpi_log_error("Internal error, invalid action: 0x%X\n", |
326 | "Internal error, invalid action: 0x%X\n", | 347 | action->to_be_done); |
327 | action->to_be_done); | ||
328 | return (-1); | 348 | return (-1); |
329 | } | 349 | } |
330 | 350 | ||
@@ -333,18 +353,18 @@ int ACPI_SYSTEM_XFACE main(int argc, char *argv[]) | |||
333 | } | 353 | } |
334 | } | 354 | } |
335 | 355 | ||
336 | if (gbl_output_file) { | 356 | if (gbl_output_filename) { |
337 | if (gbl_verbose_mode) { | 357 | if (gbl_verbose_mode) { |
338 | 358 | ||
339 | /* Summary for the output file */ | 359 | /* Summary for the output file */ |
340 | 360 | ||
341 | file_size = cm_get_file_size(gbl_output_file); | 361 | file_size = cm_get_file_size(gbl_output_file); |
342 | fprintf(stderr, | 362 | acpi_log_error |
343 | "Output file %s contains 0x%X (%u) bytes\n\n", | 363 | ("Output file %s contains 0x%X (%u) bytes\n\n", |
344 | gbl_output_filename, file_size, file_size); | 364 | gbl_output_filename, file_size, file_size); |
345 | } | 365 | } |
346 | 366 | ||
347 | fclose(gbl_output_file); | 367 | acpi_os_close_file(gbl_output_file); |
348 | } | 368 | } |
349 | 369 | ||
350 | return (status); | 370 | return (status); |