aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-04-08 06:31:38 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-04-08 06:31:38 -0400
commit6912897d7574d780994ac9a531f76c5df1669aeb (patch)
tree9fe4d0bef6270a1ecf804865dfe3cf5b18a9f24a /drivers/acpi
parent16b53e7e8542082ac628e9e69f6cdf725a576f81 (diff)
parentf084dbb939070281be7c882db63a4a428c51fcf4 (diff)
Merge branch 'acpica' into linux-next
* acpica: (22 commits) ACPI: Set length even for TYPE_END_TAG acpi resource ACPICA: Update version to 20130214 ACPICA: Object repair: Allow 0-length packages for variable-length packages ACPICA: Disassembler: Add warnings for unresolved control methods ACPICA: Return object repair: Add resource template repairs ACPICA: Return object repair: Add string-to-unicode conversion ACPICA: Split object conversion functions to a new file ACPICA: Add mechanism for early object repairs on a per-name basis ACPICA: Remove trailing comma in enum declarations ACPICA: Add exception descriptions to exception info table ACPICA: Add macros to exception code definitions ACPICA: Regression fix: reinstate safe exit macros ACPICA: Update for ACPI 5 hardware-reduced feature ACPICA: Add parens within macros around parameter names ACPICA: Add macros to access pointer to next object in the descriptor list ACPICA: Update error/debug messages for fixed events ACPICA: Fix a long-standing bug in local cache ACPICA: iASL/Disassembler: Add support for MTMR table ACPICA: iASL/Disassembler: Add support for VRTC table ACPICA: Update RASF table definition ...
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/acpica/Makefile1
-rw-r--r--drivers/acpi/acpica/acglobal.h4
-rw-r--r--drivers/acpi/acpica/aclocal.h16
-rw-r--r--drivers/acpi/acpica/acmacros.h6
-rw-r--r--drivers/acpi/acpica/acnamesp.h25
-rw-r--r--drivers/acpi/acpica/acutils.h3
-rw-r--r--drivers/acpi/acpica/dsutils.c10
-rw-r--r--drivers/acpi/acpica/evevent.c12
-rw-r--r--drivers/acpi/acpica/evgpe.c6
-rw-r--r--drivers/acpi/acpica/evsci.c4
-rw-r--r--drivers/acpi/acpica/evxface.c21
-rw-r--r--drivers/acpi/acpica/evxfevnt.c12
-rw-r--r--drivers/acpi/acpica/exprep.c4
-rw-r--r--drivers/acpi/acpica/exutils.c4
-rw-r--r--drivers/acpi/acpica/hwacpi.c20
-rw-r--r--drivers/acpi/acpica/nsconvert.c443
-rw-r--r--drivers/acpi/acpica/nspredef.c141
-rw-r--r--drivers/acpi/acpica/nsprepkg.c10
-rw-r--r--drivers/acpi/acpica/nsrepair.c381
-rw-r--r--drivers/acpi/acpica/nsrepair2.c16
-rw-r--r--drivers/acpi/acpica/nsutils.c8
-rw-r--r--drivers/acpi/acpica/psargs.c2
-rw-r--r--drivers/acpi/acpica/rscalc.c6
-rw-r--r--drivers/acpi/acpica/rsdump.c8
-rw-r--r--drivers/acpi/acpica/rslist.c8
-rw-r--r--drivers/acpi/acpica/rsxface.c8
-rw-r--r--drivers/acpi/acpica/utaddress.c4
-rw-r--r--drivers/acpi/acpica/utcache.c18
-rw-r--r--drivers/acpi/acpica/utexcep.c26
-rw-r--r--drivers/acpi/acpica/utglobal.c2
-rw-r--r--drivers/acpi/pci_link.c1
31 files changed, 830 insertions, 400 deletions
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
index a1b9bf5085a2..5a542c8db942 100644
--- a/drivers/acpi/acpica/Makefile
+++ b/drivers/acpi/acpica/Makefile
@@ -83,6 +83,7 @@ acpi-$(ACPI_FUTURE_USAGE) += hwtimer.o
83acpi-y += \ 83acpi-y += \
84 nsaccess.o \ 84 nsaccess.o \
85 nsalloc.o \ 85 nsalloc.o \
86 nsconvert.o \
86 nsdump.o \ 87 nsdump.o \
87 nseval.o \ 88 nseval.o \
88 nsinit.o \ 89 nsinit.o \
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index ecb49927b817..833fbc5be2d6 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -413,10 +413,12 @@ ACPI_EXTERN u8 acpi_gbl_db_output_flags;
413 413
414#ifdef ACPI_DISASSEMBLER 414#ifdef ACPI_DISASSEMBLER
415 415
416u8 ACPI_INIT_GLOBAL(acpi_gbl_ignore_noop_operator, FALSE); 416ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_ignore_noop_operator, FALSE);
417 417
418ACPI_EXTERN u8 acpi_gbl_db_opt_disasm; 418ACPI_EXTERN u8 acpi_gbl_db_opt_disasm;
419ACPI_EXTERN u8 acpi_gbl_db_opt_verbose; 419ACPI_EXTERN u8 acpi_gbl_db_opt_verbose;
420ACPI_EXTERN u8 acpi_gbl_num_external_methods;
421ACPI_EXTERN u32 acpi_gbl_resolved_external_methods;
420ACPI_EXTERN struct acpi_external_list *acpi_gbl_external_list; 422ACPI_EXTERN struct acpi_external_list *acpi_gbl_external_list;
421ACPI_EXTERN struct acpi_external_file *acpi_gbl_external_file_list; 423ACPI_EXTERN struct acpi_external_file *acpi_gbl_external_file_list;
422#endif 424#endif
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index 805f419086ab..636658ffc9b1 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -363,6 +363,7 @@ struct acpi_predefined_data {
363 union acpi_operand_object *parent_package; 363 union acpi_operand_object *parent_package;
364 struct acpi_namespace_node *node; 364 struct acpi_namespace_node *node;
365 u32 flags; 365 u32 flags;
366 u32 return_btype;
366 u8 node_flags; 367 u8 node_flags;
367}; 368};
368 369
@@ -371,6 +372,20 @@ struct acpi_predefined_data {
371#define ACPI_OBJECT_REPAIRED 1 372#define ACPI_OBJECT_REPAIRED 1
372#define ACPI_OBJECT_WRAPPED 2 373#define ACPI_OBJECT_WRAPPED 2
373 374
375/* Return object auto-repair info */
376
377typedef acpi_status(*acpi_object_converter) (union acpi_operand_object
378 *original_object,
379 union acpi_operand_object
380 **converted_object);
381
382struct acpi_simple_repair_info {
383 char name[ACPI_NAME_SIZE];
384 u32 unexpected_btypes;
385 u32 package_index;
386 acpi_object_converter object_converter;
387};
388
374/* 389/*
375 * Bitmapped return value types 390 * Bitmapped return value types
376 * Note: the actual data types must be contiguous, a loop in nspredef.c 391 * Note: the actual data types must be contiguous, a loop in nspredef.c
@@ -1037,6 +1052,7 @@ struct acpi_external_list {
1037 u16 length; 1052 u16 length;
1038 u8 type; 1053 u8 type;
1039 u8 flags; 1054 u8 flags;
1055 u8 resolved;
1040}; 1056};
1041 1057
1042/* Values for Flags field above */ 1058/* Values for Flags field above */
diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h
index ed7943b9044f..53666bd9193d 100644
--- a/drivers/acpi/acpica/acmacros.h
+++ b/drivers/acpi/acpica/acmacros.h
@@ -322,10 +322,12 @@
322 * where a pointer to an object of type union acpi_operand_object can also 322 * where a pointer to an object of type union acpi_operand_object can also
323 * appear. This macro is used to distinguish them. 323 * appear. This macro is used to distinguish them.
324 * 324 *
325 * The "Descriptor" field is the first field in both structures. 325 * The "DescriptorType" field is the second field in both structures.
326 */ 326 */
327#define ACPI_GET_DESCRIPTOR_PTR(d) (((union acpi_descriptor *)(void *)(d))->common.common_pointer)
328#define ACPI_SET_DESCRIPTOR_PTR(d, p) (((union acpi_descriptor *)(void *)(d))->common.common_pointer = (p))
327#define ACPI_GET_DESCRIPTOR_TYPE(d) (((union acpi_descriptor *)(void *)(d))->common.descriptor_type) 329#define ACPI_GET_DESCRIPTOR_TYPE(d) (((union acpi_descriptor *)(void *)(d))->common.descriptor_type)
328#define ACPI_SET_DESCRIPTOR_TYPE(d, t) (((union acpi_descriptor *)(void *)(d))->common.descriptor_type = t) 330#define ACPI_SET_DESCRIPTOR_TYPE(d, t) (((union acpi_descriptor *)(void *)(d))->common.descriptor_type = (t))
329 331
330/* 332/*
331 * Macros for the master AML opcode table 333 * Macros for the master AML opcode table
diff --git a/drivers/acpi/acpica/acnamesp.h b/drivers/acpi/acpica/acnamesp.h
index 02cd5482ff8b..6475962a7f2d 100644
--- a/drivers/acpi/acpica/acnamesp.h
+++ b/drivers/acpi/acpica/acnamesp.h
@@ -167,6 +167,29 @@ void acpi_ns_delete_children(struct acpi_namespace_node *parent);
167int acpi_ns_compare_names(char *name1, char *name2); 167int acpi_ns_compare_names(char *name1, char *name2);
168 168
169/* 169/*
170 * nsconvert - Dynamic object conversion routines
171 */
172acpi_status
173acpi_ns_convert_to_integer(union acpi_operand_object *original_object,
174 union acpi_operand_object **return_object);
175
176acpi_status
177acpi_ns_convert_to_string(union acpi_operand_object *original_object,
178 union acpi_operand_object **return_object);
179
180acpi_status
181acpi_ns_convert_to_buffer(union acpi_operand_object *original_object,
182 union acpi_operand_object **return_object);
183
184acpi_status
185acpi_ns_convert_to_unicode(union acpi_operand_object *original_object,
186 union acpi_operand_object **return_object);
187
188acpi_status
189acpi_ns_convert_to_resource(union acpi_operand_object *original_object,
190 union acpi_operand_object **return_object);
191
192/*
170 * nsdump - Namespace dump/print utilities 193 * nsdump - Namespace dump/print utilities
171 */ 194 */
172#ifdef ACPI_FUTURE_USAGE 195#ifdef ACPI_FUTURE_USAGE
@@ -289,7 +312,7 @@ acpi_ns_get_attached_data(struct acpi_namespace_node *node,
289 * predefined methods/objects 312 * predefined methods/objects
290 */ 313 */
291acpi_status 314acpi_status
292acpi_ns_repair_object(struct acpi_predefined_data *data, 315acpi_ns_simple_repair(struct acpi_predefined_data *data,
293 u32 expected_btypes, 316 u32 expected_btypes,
294 u32 package_index, 317 u32 package_index,
295 union acpi_operand_object **return_object_ptr); 318 union acpi_operand_object **return_object_ptr);
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
index 0082fa0a6139..c01f1a10a9d7 100644
--- a/drivers/acpi/acpica/acutils.h
+++ b/drivers/acpi/acpica/acutils.h
@@ -483,7 +483,8 @@ acpi_ut_short_divide(u64 in_dividend,
483/* 483/*
484 * utmisc 484 * utmisc
485 */ 485 */
486const char *acpi_ut_validate_exception(acpi_status status); 486const struct acpi_exception_info *acpi_ut_validate_exception(acpi_status
487 status);
487 488
488u8 acpi_ut_is_pci_root_bridge(char *id); 489u8 acpi_ut_is_pci_root_bridge(char *id);
489 490
diff --git a/drivers/acpi/acpica/dsutils.c b/drivers/acpi/acpica/dsutils.c
index 4d8c992a51d8..99778997c35a 100644
--- a/drivers/acpi/acpica/dsutils.c
+++ b/drivers/acpi/acpica/dsutils.c
@@ -178,7 +178,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
178 178
179 if (!op) { 179 if (!op) {
180 ACPI_ERROR((AE_INFO, "Null Op")); 180 ACPI_ERROR((AE_INFO, "Null Op"));
181 return_VALUE(TRUE); 181 return_UINT8(TRUE);
182 } 182 }
183 183
184 /* 184 /*
@@ -210,7 +210,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
210 "At Method level, result of [%s] not used\n", 210 "At Method level, result of [%s] not used\n",
211 acpi_ps_get_opcode_name(op->common. 211 acpi_ps_get_opcode_name(op->common.
212 aml_opcode))); 212 aml_opcode)));
213 return_VALUE(FALSE); 213 return_UINT8(FALSE);
214 } 214 }
215 215
216 /* Get info on the parent. The root_op is AML_SCOPE */ 216 /* Get info on the parent. The root_op is AML_SCOPE */
@@ -219,7 +219,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
219 acpi_ps_get_opcode_info(op->common.parent->common.aml_opcode); 219 acpi_ps_get_opcode_info(op->common.parent->common.aml_opcode);
220 if (parent_info->class == AML_CLASS_UNKNOWN) { 220 if (parent_info->class == AML_CLASS_UNKNOWN) {
221 ACPI_ERROR((AE_INFO, "Unknown parent opcode Op=%p", op)); 221 ACPI_ERROR((AE_INFO, "Unknown parent opcode Op=%p", op));
222 return_VALUE(FALSE); 222 return_UINT8(FALSE);
223 } 223 }
224 224
225 /* 225 /*
@@ -307,7 +307,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
307 acpi_ps_get_opcode_name(op->common.parent->common. 307 acpi_ps_get_opcode_name(op->common.parent->common.
308 aml_opcode), op)); 308 aml_opcode), op));
309 309
310 return_VALUE(TRUE); 310 return_UINT8(TRUE);
311 311
312 result_not_used: 312 result_not_used:
313 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 313 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
@@ -316,7 +316,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op,
316 acpi_ps_get_opcode_name(op->common.parent->common. 316 acpi_ps_get_opcode_name(op->common.parent->common.
317 aml_opcode), op)); 317 aml_opcode), op));
318 318
319 return_VALUE(FALSE); 319 return_UINT8(FALSE);
320} 320}
321 321
322/******************************************************************************* 322/*******************************************************************************
diff --git a/drivers/acpi/acpica/evevent.c b/drivers/acpi/acpica/evevent.c
index b8ea0b26cde3..02219ffba8b6 100644
--- a/drivers/acpi/acpica/evevent.c
+++ b/drivers/acpi/acpica/evevent.c
@@ -257,6 +257,8 @@ u32 acpi_ev_fixed_event_detect(void)
257 * 257 *
258 * DESCRIPTION: Clears the status bit for the requested event, calls the 258 * DESCRIPTION: Clears the status bit for the requested event, calls the
259 * handler that previously registered for the event. 259 * handler that previously registered for the event.
260 * NOTE: If there is no handler for the event, the event is
261 * disabled to prevent futher interrupts.
260 * 262 *
261 ******************************************************************************/ 263 ******************************************************************************/
262 264
@@ -271,17 +273,17 @@ static u32 acpi_ev_fixed_event_dispatch(u32 event)
271 status_register_id, ACPI_CLEAR_STATUS); 273 status_register_id, ACPI_CLEAR_STATUS);
272 274
273 /* 275 /*
274 * Make sure we've got a handler. If not, report an error. The event is 276 * Make sure that a handler exists. If not, report an error
275 * disabled to prevent further interrupts. 277 * and disable the event to prevent further interrupts.
276 */ 278 */
277 if (NULL == acpi_gbl_fixed_event_handlers[event].handler) { 279 if (!acpi_gbl_fixed_event_handlers[event].handler) {
278 (void)acpi_write_bit_register(acpi_gbl_fixed_event_info[event]. 280 (void)acpi_write_bit_register(acpi_gbl_fixed_event_info[event].
279 enable_register_id, 281 enable_register_id,
280 ACPI_DISABLE_EVENT); 282 ACPI_DISABLE_EVENT);
281 283
282 ACPI_ERROR((AE_INFO, 284 ACPI_ERROR((AE_INFO,
283 "No installed handler for fixed event [0x%08X]", 285 "No installed handler for fixed event - %s (%u), disabling",
284 event)); 286 acpi_ut_get_event_name(event), event));
285 287
286 return (ACPI_INTERRUPT_NOT_HANDLED); 288 return (ACPI_INTERRUPT_NOT_HANDLED);
287 } 289 }
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c
index b9adb9a7ed85..a493b528f8f9 100644
--- a/drivers/acpi/acpica/evgpe.c
+++ b/drivers/acpi/acpica/evgpe.c
@@ -707,7 +707,7 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device,
707 if (ACPI_FAILURE(status)) { 707 if (ACPI_FAILURE(status)) {
708 ACPI_EXCEPTION((AE_INFO, status, 708 ACPI_EXCEPTION((AE_INFO, status,
709 "Unable to clear GPE%02X", gpe_number)); 709 "Unable to clear GPE%02X", gpe_number));
710 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); 710 return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
711 } 711 }
712 } 712 }
713 713
@@ -724,7 +724,7 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device,
724 if (ACPI_FAILURE(status)) { 724 if (ACPI_FAILURE(status)) {
725 ACPI_EXCEPTION((AE_INFO, status, 725 ACPI_EXCEPTION((AE_INFO, status,
726 "Unable to disable GPE%02X", gpe_number)); 726 "Unable to disable GPE%02X", gpe_number));
727 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); 727 return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
728 } 728 }
729 729
730 /* 730 /*
@@ -784,7 +784,7 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device,
784 break; 784 break;
785 } 785 }
786 786
787 return_VALUE(ACPI_INTERRUPT_HANDLED); 787 return_UINT32(ACPI_INTERRUPT_HANDLED);
788} 788}
789 789
790#endif /* !ACPI_REDUCED_HARDWARE */ 790#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/evsci.c b/drivers/acpi/acpica/evsci.c
index f4b43bede015..b905acf7aacd 100644
--- a/drivers/acpi/acpica/evsci.c
+++ b/drivers/acpi/acpica/evsci.c
@@ -89,7 +89,7 @@ static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context)
89 */ 89 */
90 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list); 90 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list);
91 91
92 return_VALUE(interrupt_handled); 92 return_UINT32(interrupt_handled);
93} 93}
94 94
95/******************************************************************************* 95/*******************************************************************************
@@ -120,7 +120,7 @@ u32 ACPI_SYSTEM_XFACE acpi_ev_gpe_xrupt_handler(void *context)
120 120
121 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list); 121 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list);
122 122
123 return_VALUE(interrupt_handled); 123 return_UINT32(interrupt_handled);
124} 124}
125 125
126/****************************************************************************** 126/******************************************************************************
diff --git a/drivers/acpi/acpica/evxface.c b/drivers/acpi/acpica/evxface.c
index ddffd6847914..ca5fba99c33b 100644
--- a/drivers/acpi/acpica/evxface.c
+++ b/drivers/acpi/acpica/evxface.c
@@ -467,9 +467,9 @@ acpi_install_fixed_event_handler(u32 event,
467 return_ACPI_STATUS(status); 467 return_ACPI_STATUS(status);
468 } 468 }
469 469
470 /* Don't allow two handlers. */ 470 /* Do not allow multiple handlers */
471 471
472 if (NULL != acpi_gbl_fixed_event_handlers[event].handler) { 472 if (acpi_gbl_fixed_event_handlers[event].handler) {
473 status = AE_ALREADY_EXISTS; 473 status = AE_ALREADY_EXISTS;
474 goto cleanup; 474 goto cleanup;
475 } 475 }
@@ -483,8 +483,9 @@ acpi_install_fixed_event_handler(u32 event,
483 if (ACPI_SUCCESS(status)) 483 if (ACPI_SUCCESS(status))
484 status = acpi_enable_event(event, 0); 484 status = acpi_enable_event(event, 0);
485 if (ACPI_FAILURE(status)) { 485 if (ACPI_FAILURE(status)) {
486 ACPI_WARNING((AE_INFO, "Could not enable fixed event 0x%X", 486 ACPI_WARNING((AE_INFO,
487 event)); 487 "Could not enable fixed event - %s (%u)",
488 acpi_ut_get_event_name(event), event));
488 489
489 /* Remove the handler */ 490 /* Remove the handler */
490 491
@@ -492,7 +493,8 @@ acpi_install_fixed_event_handler(u32 event,
492 acpi_gbl_fixed_event_handlers[event].context = NULL; 493 acpi_gbl_fixed_event_handlers[event].context = NULL;
493 } else { 494 } else {
494 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 495 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
495 "Enabled fixed event %X, Handler=%p\n", event, 496 "Enabled fixed event %s (%X), Handler=%p\n",
497 acpi_ut_get_event_name(event), event,
496 handler)); 498 handler));
497 } 499 }
498 500
@@ -544,11 +546,12 @@ acpi_remove_fixed_event_handler(u32 event, acpi_event_handler handler)
544 546
545 if (ACPI_FAILURE(status)) { 547 if (ACPI_FAILURE(status)) {
546 ACPI_WARNING((AE_INFO, 548 ACPI_WARNING((AE_INFO,
547 "Could not write to fixed event enable register 0x%X", 549 "Could not disable fixed event - %s (%u)",
548 event)); 550 acpi_ut_get_event_name(event), event));
549 } else { 551 } else {
550 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabled fixed event %X\n", 552 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
551 event)); 553 "Disabled fixed event - %s (%X)\n",
554 acpi_ut_get_event_name(event), event));
552 } 555 }
553 556
554 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); 557 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
diff --git a/drivers/acpi/acpica/evxfevnt.c b/drivers/acpi/acpica/evxfevnt.c
index d6e4e42316db..7039606a0ba8 100644
--- a/drivers/acpi/acpica/evxfevnt.c
+++ b/drivers/acpi/acpica/evxfevnt.c
@@ -74,6 +74,12 @@ acpi_status acpi_enable(void)
74 return_ACPI_STATUS(AE_NO_ACPI_TABLES); 74 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
75 } 75 }
76 76
77 /* If the Hardware Reduced flag is set, machine is always in acpi mode */
78
79 if (acpi_gbl_reduced_hardware) {
80 return_ACPI_STATUS(AE_OK);
81 }
82
77 /* Check current mode */ 83 /* Check current mode */
78 84
79 if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) { 85 if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) {
@@ -126,6 +132,12 @@ acpi_status acpi_disable(void)
126 132
127 ACPI_FUNCTION_TRACE(acpi_disable); 133 ACPI_FUNCTION_TRACE(acpi_disable);
128 134
135 /* If the Hardware Reduced flag is set, machine is always in acpi mode */
136
137 if (acpi_gbl_reduced_hardware) {
138 return_ACPI_STATUS(AE_OK);
139 }
140
129 if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY) { 141 if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY) {
130 ACPI_DEBUG_PRINT((ACPI_DB_INIT, 142 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
131 "System is already in legacy (non-ACPI) mode\n")); 143 "System is already in legacy (non-ACPI) mode\n"));
diff --git a/drivers/acpi/acpica/exprep.c b/drivers/acpi/acpica/exprep.c
index d6eab81f54fb..6b728aef2dca 100644
--- a/drivers/acpi/acpica/exprep.c
+++ b/drivers/acpi/acpica/exprep.c
@@ -276,7 +276,7 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc,
276 /* Invalid field access type */ 276 /* Invalid field access type */
277 277
278 ACPI_ERROR((AE_INFO, "Unknown field access type 0x%X", access)); 278 ACPI_ERROR((AE_INFO, "Unknown field access type 0x%X", access));
279 return_VALUE(0); 279 return_UINT32(0);
280 } 280 }
281 281
282 if (obj_desc->common.type == ACPI_TYPE_BUFFER_FIELD) { 282 if (obj_desc->common.type == ACPI_TYPE_BUFFER_FIELD) {
@@ -289,7 +289,7 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc,
289 } 289 }
290 290
291 *return_byte_alignment = byte_alignment; 291 *return_byte_alignment = byte_alignment;
292 return_VALUE(bit_length); 292 return_UINT32(bit_length);
293} 293}
294 294
295/******************************************************************************* 295/*******************************************************************************
diff --git a/drivers/acpi/acpica/exutils.c b/drivers/acpi/acpica/exutils.c
index b205cbb4b50c..99dc7b287d55 100644
--- a/drivers/acpi/acpica/exutils.c
+++ b/drivers/acpi/acpica/exutils.c
@@ -340,7 +340,7 @@ static u32 acpi_ex_digits_needed(u64 value, u32 base)
340 /* u64 is unsigned, so we don't worry about a '-' prefix */ 340 /* u64 is unsigned, so we don't worry about a '-' prefix */
341 341
342 if (value == 0) { 342 if (value == 0) {
343 return_VALUE(1); 343 return_UINT32(1);
344 } 344 }
345 345
346 current_value = value; 346 current_value = value;
@@ -354,7 +354,7 @@ static u32 acpi_ex_digits_needed(u64 value, u32 base)
354 num_digits++; 354 num_digits++;
355 } 355 }
356 356
357 return_VALUE(num_digits); 357 return_UINT32(num_digits);
358} 358}
359 359
360/******************************************************************************* 360/*******************************************************************************
diff --git a/drivers/acpi/acpica/hwacpi.c b/drivers/acpi/acpica/hwacpi.c
index deb3f61e2bd1..579c3a53ac87 100644
--- a/drivers/acpi/acpica/hwacpi.c
+++ b/drivers/acpi/acpica/hwacpi.c
@@ -66,6 +66,12 @@ acpi_status acpi_hw_set_mode(u32 mode)
66 66
67 ACPI_FUNCTION_TRACE(hw_set_mode); 67 ACPI_FUNCTION_TRACE(hw_set_mode);
68 68
69 /* If the Hardware Reduced flag is set, machine is always in acpi mode */
70
71 if (acpi_gbl_reduced_hardware) {
72 return_ACPI_STATUS(AE_OK);
73 }
74
69 /* 75 /*
70 * ACPI 2.0 clarified that if SMI_CMD in FADT is zero, 76 * ACPI 2.0 clarified that if SMI_CMD in FADT is zero,
71 * system does not support mode transition. 77 * system does not support mode transition.
@@ -146,23 +152,29 @@ u32 acpi_hw_get_mode(void)
146 152
147 ACPI_FUNCTION_TRACE(hw_get_mode); 153 ACPI_FUNCTION_TRACE(hw_get_mode);
148 154
155 /* If the Hardware Reduced flag is set, machine is always in acpi mode */
156
157 if (acpi_gbl_reduced_hardware) {
158 return_UINT32(ACPI_SYS_MODE_ACPI);
159 }
160
149 /* 161 /*
150 * ACPI 2.0 clarified that if SMI_CMD in FADT is zero, 162 * ACPI 2.0 clarified that if SMI_CMD in FADT is zero,
151 * system does not support mode transition. 163 * system does not support mode transition.
152 */ 164 */
153 if (!acpi_gbl_FADT.smi_command) { 165 if (!acpi_gbl_FADT.smi_command) {
154 return_VALUE(ACPI_SYS_MODE_ACPI); 166 return_UINT32(ACPI_SYS_MODE_ACPI);
155 } 167 }
156 168
157 status = acpi_read_bit_register(ACPI_BITREG_SCI_ENABLE, &value); 169 status = acpi_read_bit_register(ACPI_BITREG_SCI_ENABLE, &value);
158 if (ACPI_FAILURE(status)) { 170 if (ACPI_FAILURE(status)) {
159 return_VALUE(ACPI_SYS_MODE_LEGACY); 171 return_UINT32(ACPI_SYS_MODE_LEGACY);
160 } 172 }
161 173
162 if (value) { 174 if (value) {
163 return_VALUE(ACPI_SYS_MODE_ACPI); 175 return_UINT32(ACPI_SYS_MODE_ACPI);
164 } else { 176 } else {
165 return_VALUE(ACPI_SYS_MODE_LEGACY); 177 return_UINT32(ACPI_SYS_MODE_LEGACY);
166 } 178 }
167} 179}
168 180
diff --git a/drivers/acpi/acpica/nsconvert.c b/drivers/acpi/acpica/nsconvert.c
new file mode 100644
index 000000000000..8f79a9d2d50e
--- /dev/null
+++ b/drivers/acpi/acpica/nsconvert.c
@@ -0,0 +1,443 @@
1/******************************************************************************
2 *
3 * Module Name: nsconvert - Object conversions for objects returned by
4 * predefined methods
5 *
6 *****************************************************************************/
7
8/*
9 * Copyright (C) 2000 - 2013, Intel Corp.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
30 *
31 * NO WARRANTY
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
43 */
44
45#include <acpi/acpi.h>
46#include "accommon.h"
47#include "acnamesp.h"
48#include "acinterp.h"
49#include "acpredef.h"
50#include "amlresrc.h"
51
52#define _COMPONENT ACPI_NAMESPACE
53ACPI_MODULE_NAME("nsconvert")
54
55/*******************************************************************************
56 *
57 * FUNCTION: acpi_ns_convert_to_integer
58 *
59 * PARAMETERS: original_object - Object to be converted
60 * return_object - Where the new converted object is returned
61 *
62 * RETURN: Status. AE_OK if conversion was successful.
63 *
64 * DESCRIPTION: Attempt to convert a String/Buffer object to an Integer.
65 *
66 ******************************************************************************/
67acpi_status
68acpi_ns_convert_to_integer(union acpi_operand_object *original_object,
69 union acpi_operand_object **return_object)
70{
71 union acpi_operand_object *new_object;
72 acpi_status status;
73 u64 value = 0;
74 u32 i;
75
76 switch (original_object->common.type) {
77 case ACPI_TYPE_STRING:
78
79 /* String-to-Integer conversion */
80
81 status = acpi_ut_strtoul64(original_object->string.pointer,
82 ACPI_ANY_BASE, &value);
83 if (ACPI_FAILURE(status)) {
84 return (status);
85 }
86 break;
87
88 case ACPI_TYPE_BUFFER:
89
90 /* Buffer-to-Integer conversion. Max buffer size is 64 bits. */
91
92 if (original_object->buffer.length > 8) {
93 return (AE_AML_OPERAND_TYPE);
94 }
95
96 /* Extract each buffer byte to create the integer */
97
98 for (i = 0; i < original_object->buffer.length; i++) {
99 value |=
100 ((u64)original_object->buffer.
101 pointer[i] << (i * 8));
102 }
103 break;
104
105 default:
106 return (AE_AML_OPERAND_TYPE);
107 }
108
109 new_object = acpi_ut_create_integer_object(value);
110 if (!new_object) {
111 return (AE_NO_MEMORY);
112 }
113
114 *return_object = new_object;
115 return (AE_OK);
116}
117
118/*******************************************************************************
119 *
120 * FUNCTION: acpi_ns_convert_to_string
121 *
122 * PARAMETERS: original_object - Object to be converted
123 * return_object - Where the new converted object is returned
124 *
125 * RETURN: Status. AE_OK if conversion was successful.
126 *
127 * DESCRIPTION: Attempt to convert a Integer/Buffer object to a String.
128 *
129 ******************************************************************************/
130
131acpi_status
132acpi_ns_convert_to_string(union acpi_operand_object *original_object,
133 union acpi_operand_object **return_object)
134{
135 union acpi_operand_object *new_object;
136 acpi_size length;
137 acpi_status status;
138
139 switch (original_object->common.type) {
140 case ACPI_TYPE_INTEGER:
141 /*
142 * Integer-to-String conversion. Commonly, convert
143 * an integer of value 0 to a NULL string. The last element of
144 * _BIF and _BIX packages occasionally need this fix.
145 */
146 if (original_object->integer.value == 0) {
147
148 /* Allocate a new NULL string object */
149
150 new_object = acpi_ut_create_string_object(0);
151 if (!new_object) {
152 return (AE_NO_MEMORY);
153 }
154 } else {
155 status =
156 acpi_ex_convert_to_string(original_object,
157 &new_object,
158 ACPI_IMPLICIT_CONVERT_HEX);
159 if (ACPI_FAILURE(status)) {
160 return (status);
161 }
162 }
163 break;
164
165 case ACPI_TYPE_BUFFER:
166 /*
167 * Buffer-to-String conversion. Use a to_string
168 * conversion, no transform performed on the buffer data. The best
169 * example of this is the _BIF method, where the string data from
170 * the battery is often (incorrectly) returned as buffer object(s).
171 */
172 length = 0;
173 while ((length < original_object->buffer.length) &&
174 (original_object->buffer.pointer[length])) {
175 length++;
176 }
177
178 /* Allocate a new string object */
179
180 new_object = acpi_ut_create_string_object(length);
181 if (!new_object) {
182 return (AE_NO_MEMORY);
183 }
184
185 /*
186 * Copy the raw buffer data with no transform. String is already NULL
187 * terminated at Length+1.
188 */
189 ACPI_MEMCPY(new_object->string.pointer,
190 original_object->buffer.pointer, length);
191 break;
192
193 default:
194 return (AE_AML_OPERAND_TYPE);
195 }
196
197 *return_object = new_object;
198 return (AE_OK);
199}
200
201/*******************************************************************************
202 *
203 * FUNCTION: acpi_ns_convert_to_buffer
204 *
205 * PARAMETERS: original_object - Object to be converted
206 * return_object - Where the new converted object is returned
207 *
208 * RETURN: Status. AE_OK if conversion was successful.
209 *
210 * DESCRIPTION: Attempt to convert a Integer/String/Package object to a Buffer.
211 *
212 ******************************************************************************/
213
214acpi_status
215acpi_ns_convert_to_buffer(union acpi_operand_object *original_object,
216 union acpi_operand_object **return_object)
217{
218 union acpi_operand_object *new_object;
219 acpi_status status;
220 union acpi_operand_object **elements;
221 u32 *dword_buffer;
222 u32 count;
223 u32 i;
224
225 switch (original_object->common.type) {
226 case ACPI_TYPE_INTEGER:
227 /*
228 * Integer-to-Buffer conversion.
229 * Convert the Integer to a packed-byte buffer. _MAT and other
230 * objects need this sometimes, if a read has been performed on a
231 * Field object that is less than or equal to the global integer
232 * size (32 or 64 bits).
233 */
234 status =
235 acpi_ex_convert_to_buffer(original_object, &new_object);
236 if (ACPI_FAILURE(status)) {
237 return (status);
238 }
239 break;
240
241 case ACPI_TYPE_STRING:
242
243 /* String-to-Buffer conversion. Simple data copy */
244
245 new_object =
246 acpi_ut_create_buffer_object(original_object->string.
247 length);
248 if (!new_object) {
249 return (AE_NO_MEMORY);
250 }
251
252 ACPI_MEMCPY(new_object->buffer.pointer,
253 original_object->string.pointer,
254 original_object->string.length);
255 break;
256
257 case ACPI_TYPE_PACKAGE:
258 /*
259 * This case is often seen for predefined names that must return a
260 * Buffer object with multiple DWORD integers within. For example,
261 * _FDE and _GTM. The Package can be converted to a Buffer.
262 */
263
264 /* All elements of the Package must be integers */
265
266 elements = original_object->package.elements;
267 count = original_object->package.count;
268
269 for (i = 0; i < count; i++) {
270 if ((!*elements) ||
271 ((*elements)->common.type != ACPI_TYPE_INTEGER)) {
272 return (AE_AML_OPERAND_TYPE);
273 }
274 elements++;
275 }
276
277 /* Create the new buffer object to replace the Package */
278
279 new_object = acpi_ut_create_buffer_object(ACPI_MUL_4(count));
280 if (!new_object) {
281 return (AE_NO_MEMORY);
282 }
283
284 /* Copy the package elements (integers) to the buffer as DWORDs */
285
286 elements = original_object->package.elements;
287 dword_buffer = ACPI_CAST_PTR(u32, new_object->buffer.pointer);
288
289 for (i = 0; i < count; i++) {
290 *dword_buffer = (u32)(*elements)->integer.value;
291 dword_buffer++;
292 elements++;
293 }
294 break;
295
296 default:
297 return (AE_AML_OPERAND_TYPE);
298 }
299
300 *return_object = new_object;
301 return (AE_OK);
302}
303
304/*******************************************************************************
305 *
306 * FUNCTION: acpi_ns_convert_to_unicode
307 *
308 * PARAMETERS: original_object - ASCII String Object to be converted
309 * return_object - Where the new converted object is returned
310 *
311 * RETURN: Status. AE_OK if conversion was successful.
312 *
313 * DESCRIPTION: Attempt to convert a String object to a Unicode string Buffer.
314 *
315 ******************************************************************************/
316
317acpi_status
318acpi_ns_convert_to_unicode(union acpi_operand_object *original_object,
319 union acpi_operand_object **return_object)
320{
321 union acpi_operand_object *new_object;
322 char *ascii_string;
323 u16 *unicode_buffer;
324 u32 unicode_length;
325 u32 i;
326
327 if (!original_object) {
328 return (AE_OK);
329 }
330
331 /* If a Buffer was returned, it must be at least two bytes long */
332
333 if (original_object->common.type == ACPI_TYPE_BUFFER) {
334 if (original_object->buffer.length < 2) {
335 return (AE_AML_OPERAND_VALUE);
336 }
337
338 *return_object = NULL;
339 return (AE_OK);
340 }
341
342 /*
343 * The original object is an ASCII string. Convert this string to
344 * a unicode buffer.
345 */
346 ascii_string = original_object->string.pointer;
347 unicode_length = (original_object->string.length * 2) + 2;
348
349 /* Create a new buffer object for the Unicode data */
350
351 new_object = acpi_ut_create_buffer_object(unicode_length);
352 if (!new_object) {
353 return (AE_NO_MEMORY);
354 }
355
356 unicode_buffer = ACPI_CAST_PTR(u16, new_object->buffer.pointer);
357
358 /* Convert ASCII to Unicode */
359
360 for (i = 0; i < original_object->string.length; i++) {
361 unicode_buffer[i] = (u16)ascii_string[i];
362 }
363
364 *return_object = new_object;
365 return (AE_OK);
366}
367
368/*******************************************************************************
369 *
370 * FUNCTION: acpi_ns_convert_to_resource
371 *
372 * PARAMETERS: original_object - Object to be converted
373 * return_object - Where the new converted object is returned
374 *
375 * RETURN: Status. AE_OK if conversion was successful
376 *
377 * DESCRIPTION: Attempt to convert a Integer object to a resource_template
378 * Buffer.
379 *
380 ******************************************************************************/
381
382acpi_status
383acpi_ns_convert_to_resource(union acpi_operand_object *original_object,
384 union acpi_operand_object **return_object)
385{
386 union acpi_operand_object *new_object;
387 u8 *buffer;
388
389 /*
390 * We can fix the following cases for an expected resource template:
391 * 1. No return value (interpreter slack mode is disabled)
392 * 2. A "Return (Zero)" statement
393 * 3. A "Return empty buffer" statement
394 *
395 * We will return a buffer containing a single end_tag
396 * resource descriptor.
397 */
398 if (original_object) {
399 switch (original_object->common.type) {
400 case ACPI_TYPE_INTEGER:
401
402 /* We can only repair an Integer==0 */
403
404 if (original_object->integer.value) {
405 return (AE_AML_OPERAND_TYPE);
406 }
407 break;
408
409 case ACPI_TYPE_BUFFER:
410
411 if (original_object->buffer.length) {
412
413 /* Additional checks can be added in the future */
414
415 *return_object = NULL;
416 return (AE_OK);
417 }
418 break;
419
420 case ACPI_TYPE_STRING:
421 default:
422
423 return (AE_AML_OPERAND_TYPE);
424 }
425 }
426
427 /* Create the new buffer object for the resource descriptor */
428
429 new_object = acpi_ut_create_buffer_object(2);
430 if (!new_object) {
431 return (AE_NO_MEMORY);
432 }
433
434 buffer = ACPI_CAST_PTR(u8, new_object->buffer.pointer);
435
436 /* Initialize the Buffer with a single end_tag descriptor */
437
438 buffer[0] = (ACPI_RESOURCE_NAME_END_TAG | ASL_RDESC_END_TAG_SIZE);
439 buffer[1] = 0x00;
440
441 *return_object = new_object;
442 return (AE_OK);
443}
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c
index 224c30053401..36f724085dca 100644
--- a/drivers/acpi/acpica/nspredef.c
+++ b/drivers/acpi/acpica/nspredef.c
@@ -78,6 +78,8 @@ acpi_ns_check_reference(struct acpi_predefined_data *data,
78 78
79static void acpi_ns_get_expected_types(char *buffer, u32 expected_btypes); 79static void acpi_ns_get_expected_types(char *buffer, u32 expected_btypes);
80 80
81static u32 acpi_ns_get_bitmapped_type(union acpi_operand_object *return_object);
82
81/* 83/*
82 * Names for the types that can be returned by the predefined objects. 84 * Names for the types that can be returned by the predefined objects.
83 * Used for warning messages. Must be in the same order as the ACPI_RTYPEs 85 * Used for warning messages. Must be in the same order as the ACPI_RTYPEs
@@ -112,7 +114,6 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
112 acpi_status return_status, 114 acpi_status return_status,
113 union acpi_operand_object **return_object_ptr) 115 union acpi_operand_object **return_object_ptr)
114{ 116{
115 union acpi_operand_object *return_object = *return_object_ptr;
116 acpi_status status = AE_OK; 117 acpi_status status = AE_OK;
117 const union acpi_predefined_info *predefined; 118 const union acpi_predefined_info *predefined;
118 char *pathname; 119 char *pathname;
@@ -152,25 +153,6 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
152 } 153 }
153 154
154 /* 155 /*
155 * If there is no return value, check if we require a return value for
156 * this predefined name. Either one return value is expected, or none,
157 * for both methods and other objects.
158 *
159 * Exit now if there is no return object. Warning if one was expected.
160 */
161 if (!return_object) {
162 if ((predefined->info.expected_btypes) &&
163 (!(predefined->info.expected_btypes & ACPI_RTYPE_NONE))) {
164 ACPI_WARN_PREDEFINED((AE_INFO, pathname,
165 ACPI_WARN_ALWAYS,
166 "Missing expected return value"));
167
168 status = AE_AML_NO_RETURN_VALUE;
169 }
170 goto cleanup;
171 }
172
173 /*
174 * Return value validation and possible repair. 156 * Return value validation and possible repair.
175 * 157 *
176 * 1) Don't perform return value validation/repair if this feature 158 * 1) Don't perform return value validation/repair if this feature
@@ -410,28 +392,12 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data,
410{ 392{
411 union acpi_operand_object *return_object = *return_object_ptr; 393 union acpi_operand_object *return_object = *return_object_ptr;
412 acpi_status status = AE_OK; 394 acpi_status status = AE_OK;
413 u32 return_btype;
414 char type_buffer[48]; /* Room for 5 types */ 395 char type_buffer[48]; /* Room for 5 types */
415 396
416 /*
417 * If we get a NULL return_object here, it is a NULL package element.
418 * Since all extraneous NULL package elements were removed earlier by a
419 * call to acpi_ns_remove_null_elements, this is an unexpected NULL element.
420 * We will attempt to repair it.
421 */
422 if (!return_object) {
423 status = acpi_ns_repair_null_element(data, expected_btypes,
424 package_index,
425 return_object_ptr);
426 if (ACPI_SUCCESS(status)) {
427 return (AE_OK); /* Repair was successful */
428 }
429 goto type_error_exit;
430 }
431
432 /* A Namespace node should not get here, but make sure */ 397 /* A Namespace node should not get here, but make sure */
433 398
434 if (ACPI_GET_DESCRIPTOR_TYPE(return_object) == ACPI_DESC_TYPE_NAMED) { 399 if (return_object &&
400 ACPI_GET_DESCRIPTOR_TYPE(return_object) == ACPI_DESC_TYPE_NAMED) {
435 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, 401 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
436 "Invalid return type - Found a Namespace node [%4.4s] type %s", 402 "Invalid return type - Found a Namespace node [%4.4s] type %s",
437 return_object->node.name.ascii, 403 return_object->node.name.ascii,
@@ -448,53 +414,25 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data,
448 * from all of the predefined names (including elements of returned 414 * from all of the predefined names (including elements of returned
449 * packages) 415 * packages)
450 */ 416 */
451 switch (return_object->common.type) { 417 data->return_btype = acpi_ns_get_bitmapped_type(return_object);
452 case ACPI_TYPE_INTEGER: 418 if (data->return_btype == ACPI_RTYPE_ANY) {
453 return_btype = ACPI_RTYPE_INTEGER;
454 break;
455
456 case ACPI_TYPE_BUFFER:
457 return_btype = ACPI_RTYPE_BUFFER;
458 break;
459
460 case ACPI_TYPE_STRING:
461 return_btype = ACPI_RTYPE_STRING;
462 break;
463 419
464 case ACPI_TYPE_PACKAGE:
465 return_btype = ACPI_RTYPE_PACKAGE;
466 break;
467
468 case ACPI_TYPE_LOCAL_REFERENCE:
469 return_btype = ACPI_RTYPE_REFERENCE;
470 break;
471
472 default:
473 /* Not one of the supported objects, must be incorrect */ 420 /* Not one of the supported objects, must be incorrect */
474
475 goto type_error_exit; 421 goto type_error_exit;
476 } 422 }
477 423
478 /* Is the object one of the expected types? */ 424 /* For reference objects, check that the reference type is correct */
479
480 if (return_btype & expected_btypes) {
481
482 /* For reference objects, check that the reference type is correct */
483
484 if (return_object->common.type == ACPI_TYPE_LOCAL_REFERENCE) {
485 status = acpi_ns_check_reference(data, return_object);
486 }
487 425
426 if ((data->return_btype & expected_btypes) == ACPI_RTYPE_REFERENCE) {
427 status = acpi_ns_check_reference(data, return_object);
488 return (status); 428 return (status);
489 } 429 }
490 430
491 /* Type mismatch -- attempt repair of the returned object */ 431 /* Attempt simple repair of the returned object if necessary */
492 432
493 status = acpi_ns_repair_object(data, expected_btypes, 433 status = acpi_ns_simple_repair(data, expected_btypes,
494 package_index, return_object_ptr); 434 package_index, return_object_ptr);
495 if (ACPI_SUCCESS(status)) { 435 return (status);
496 return (AE_OK); /* Repair was successful */
497 }
498 436
499 type_error_exit: 437 type_error_exit:
500 438
@@ -558,6 +496,61 @@ acpi_ns_check_reference(struct acpi_predefined_data *data,
558 496
559/******************************************************************************* 497/*******************************************************************************
560 * 498 *
499 * FUNCTION: acpi_ns_get_bitmapped_type
500 *
501 * PARAMETERS: return_object - Object returned from method/obj evaluation
502 *
503 * RETURN: Object return type. ACPI_RTYPE_ANY indicates that the object
504 * type is not supported. ACPI_RTYPE_NONE indicates that no
505 * object was returned (return_object is NULL).
506 *
507 * DESCRIPTION: Convert object type into a bitmapped object return type.
508 *
509 ******************************************************************************/
510
511static u32 acpi_ns_get_bitmapped_type(union acpi_operand_object *return_object)
512{
513 u32 return_btype;
514
515 if (!return_object) {
516 return (ACPI_RTYPE_NONE);
517 }
518
519 /* Map acpi_object_type to internal bitmapped type */
520
521 switch (return_object->common.type) {
522 case ACPI_TYPE_INTEGER:
523 return_btype = ACPI_RTYPE_INTEGER;
524 break;
525
526 case ACPI_TYPE_BUFFER:
527 return_btype = ACPI_RTYPE_BUFFER;
528 break;
529
530 case ACPI_TYPE_STRING:
531 return_btype = ACPI_RTYPE_STRING;
532 break;
533
534 case ACPI_TYPE_PACKAGE:
535 return_btype = ACPI_RTYPE_PACKAGE;
536 break;
537
538 case ACPI_TYPE_LOCAL_REFERENCE:
539 return_btype = ACPI_RTYPE_REFERENCE;
540 break;
541
542 default:
543 /* Not one of the supported objects, must be incorrect */
544
545 return_btype = ACPI_RTYPE_ANY;
546 break;
547 }
548
549 return (return_btype);
550}
551
552/*******************************************************************************
553 *
561 * FUNCTION: acpi_ns_get_expected_types 554 * FUNCTION: acpi_ns_get_expected_types
562 * 555 *
563 * PARAMETERS: buffer - Pointer to where the string is returned 556 * PARAMETERS: buffer - Pointer to where the string is returned
diff --git a/drivers/acpi/acpica/nsprepkg.c b/drivers/acpi/acpica/nsprepkg.c
index a40155467d2e..77cdd539de16 100644
--- a/drivers/acpi/acpica/nsprepkg.c
+++ b/drivers/acpi/acpica/nsprepkg.c
@@ -112,9 +112,15 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
112 elements = return_object->package.elements; 112 elements = return_object->package.elements;
113 count = return_object->package.count; 113 count = return_object->package.count;
114 114
115 /* The package must have at least one element, else invalid */ 115 /*
116 116 * Most packages must have at least one element. The only exception
117 * is the variable-length package (ACPI_PTYPE1_VAR).
118 */
117 if (!count) { 119 if (!count) {
120 if (package->ret_info.type == ACPI_PTYPE1_VAR) {
121 return (AE_OK);
122 }
123
118 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, 124 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
119 "Return Package has no elements (empty)")); 125 "Return Package has no elements (empty)"));
120 126
diff --git a/drivers/acpi/acpica/nsrepair.c b/drivers/acpi/acpica/nsrepair.c
index 9e833353c06a..18f02e4ece01 100644
--- a/drivers/acpi/acpica/nsrepair.c
+++ b/drivers/acpi/acpica/nsrepair.c
@@ -46,6 +46,7 @@
46#include "acnamesp.h" 46#include "acnamesp.h"
47#include "acinterp.h" 47#include "acinterp.h"
48#include "acpredef.h" 48#include "acpredef.h"
49#include "amlresrc.h"
49 50
50#define _COMPONENT ACPI_NAMESPACE 51#define _COMPONENT ACPI_NAMESPACE
51ACPI_MODULE_NAME("nsrepair") 52ACPI_MODULE_NAME("nsrepair")
@@ -71,6 +72,11 @@ ACPI_MODULE_NAME("nsrepair")
71 * Buffer -> String 72 * Buffer -> String
72 * Buffer -> Package of Integers 73 * Buffer -> Package of Integers
73 * Package -> Package of one Package 74 * Package -> Package of one Package
75 *
76 * Additional conversions that are available:
77 * Convert a null return or zero return value to an end_tag descriptor
78 * Convert an ASCII string to a Unicode buffer
79 *
74 * An incorrect standalone object is wrapped with required outer package 80 * An incorrect standalone object is wrapped with required outer package
75 * 81 *
76 * Additional possible repairs: 82 * Additional possible repairs:
@@ -78,21 +84,51 @@ ACPI_MODULE_NAME("nsrepair")
78 * 84 *
79 ******************************************************************************/ 85 ******************************************************************************/
80/* Local prototypes */ 86/* Local prototypes */
81static acpi_status 87static const struct acpi_simple_repair_info *acpi_ns_match_simple_repair(struct
82acpi_ns_convert_to_integer(union acpi_operand_object *original_object, 88 acpi_namespace_node
83 union acpi_operand_object **return_object); 89 *node,
84 90 u32
85static acpi_status 91 return_btype,
86acpi_ns_convert_to_string(union acpi_operand_object *original_object, 92 u32
87 union acpi_operand_object **return_object); 93 package_index);
88 94
89static acpi_status 95/*
90acpi_ns_convert_to_buffer(union acpi_operand_object *original_object, 96 * Special but simple repairs for some names.
91 union acpi_operand_object **return_object); 97 *
98 * 2nd argument: Unexpected types that can be repaired
99 */
100static const struct acpi_simple_repair_info acpi_object_repair_info[] = {
101 /* Resource descriptor conversions */
102
103 {"_CRS",
104 ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER |
105 ACPI_RTYPE_NONE,
106 ACPI_NOT_PACKAGE_ELEMENT,
107 acpi_ns_convert_to_resource},
108 {"_DMA",
109 ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER |
110 ACPI_RTYPE_NONE,
111 ACPI_NOT_PACKAGE_ELEMENT,
112 acpi_ns_convert_to_resource},
113 {"_PRS",
114 ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER |
115 ACPI_RTYPE_NONE,
116 ACPI_NOT_PACKAGE_ELEMENT,
117 acpi_ns_convert_to_resource},
118
119 /* Unicode conversions */
120
121 {"_MLS", ACPI_RTYPE_STRING, 1,
122 acpi_ns_convert_to_unicode},
123 {"_STR", ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER,
124 ACPI_NOT_PACKAGE_ELEMENT,
125 acpi_ns_convert_to_unicode},
126 {{0, 0, 0, 0}, 0, 0, NULL} /* Table terminator */
127};
92 128
93/******************************************************************************* 129/*******************************************************************************
94 * 130 *
95 * FUNCTION: acpi_ns_repair_object 131 * FUNCTION: acpi_ns_simple_repair
96 * 132 *
97 * PARAMETERS: data - Pointer to validation data structure 133 * PARAMETERS: data - Pointer to validation data structure
98 * expected_btypes - Object types expected 134 * expected_btypes - Object types expected
@@ -110,16 +146,54 @@ acpi_ns_convert_to_buffer(union acpi_operand_object *original_object,
110 ******************************************************************************/ 146 ******************************************************************************/
111 147
112acpi_status 148acpi_status
113acpi_ns_repair_object(struct acpi_predefined_data *data, 149acpi_ns_simple_repair(struct acpi_predefined_data *data,
114 u32 expected_btypes, 150 u32 expected_btypes,
115 u32 package_index, 151 u32 package_index,
116 union acpi_operand_object **return_object_ptr) 152 union acpi_operand_object **return_object_ptr)
117{ 153{
118 union acpi_operand_object *return_object = *return_object_ptr; 154 union acpi_operand_object *return_object = *return_object_ptr;
119 union acpi_operand_object *new_object; 155 union acpi_operand_object *new_object = NULL;
120 acpi_status status; 156 acpi_status status;
157 const struct acpi_simple_repair_info *predefined;
158
159 ACPI_FUNCTION_NAME(ns_simple_repair);
160
161 /*
162 * Special repairs for certain names that are in the repair table.
163 * Check if this name is in the list of repairable names.
164 */
165 predefined = acpi_ns_match_simple_repair(data->node,
166 data->return_btype,
167 package_index);
168 if (predefined) {
169 if (!return_object) {
170 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname,
171 ACPI_WARN_ALWAYS,
172 "Missing expected return value"));
173 }
174
175 status =
176 predefined->object_converter(return_object, &new_object);
177 if (ACPI_FAILURE(status)) {
178
179 /* A fatal error occurred during a conversion */
180
181 ACPI_EXCEPTION((AE_INFO, status,
182 "During return object analysis"));
183 return (status);
184 }
185 if (new_object) {
186 goto object_repaired;
187 }
188 }
121 189
122 ACPI_FUNCTION_NAME(ns_repair_object); 190 /*
191 * Do not perform simple object repair unless the return type is not
192 * expected.
193 */
194 if (data->return_btype & expected_btypes) {
195 return (AE_OK);
196 }
123 197
124 /* 198 /*
125 * At this point, we know that the type of the returned object was not 199 * At this point, we know that the type of the returned object was not
@@ -127,6 +201,24 @@ acpi_ns_repair_object(struct acpi_predefined_data *data,
127 * repair the object by converting it to one of the expected object 201 * repair the object by converting it to one of the expected object
128 * types for this predefined name. 202 * types for this predefined name.
129 */ 203 */
204
205 /*
206 * If there is no return value, check if we require a return value for
207 * this predefined name. Either one return value is expected, or none,
208 * for both methods and other objects.
209 *
210 * Exit now if there is no return object. Warning if one was expected.
211 */
212 if (!return_object) {
213 if (expected_btypes && (!(expected_btypes & ACPI_RTYPE_NONE))) {
214 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname,
215 ACPI_WARN_ALWAYS,
216 "Missing expected return value"));
217
218 return (AE_AML_NO_RETURN_VALUE);
219 }
220 }
221
130 if (expected_btypes & ACPI_RTYPE_INTEGER) { 222 if (expected_btypes & ACPI_RTYPE_INTEGER) {
131 status = acpi_ns_convert_to_integer(return_object, &new_object); 223 status = acpi_ns_convert_to_integer(return_object, &new_object);
132 if (ACPI_SUCCESS(status)) { 224 if (ACPI_SUCCESS(status)) {
@@ -216,254 +308,51 @@ acpi_ns_repair_object(struct acpi_predefined_data *data,
216 return (AE_OK); 308 return (AE_OK);
217} 309}
218 310
219/******************************************************************************* 311/******************************************************************************
220 *
221 * FUNCTION: acpi_ns_convert_to_integer
222 *
223 * PARAMETERS: original_object - Object to be converted
224 * return_object - Where the new converted object is returned
225 *
226 * RETURN: Status. AE_OK if conversion was successful.
227 *
228 * DESCRIPTION: Attempt to convert a String/Buffer object to an Integer.
229 *
230 ******************************************************************************/
231
232static acpi_status
233acpi_ns_convert_to_integer(union acpi_operand_object *original_object,
234 union acpi_operand_object **return_object)
235{
236 union acpi_operand_object *new_object;
237 acpi_status status;
238 u64 value = 0;
239 u32 i;
240
241 switch (original_object->common.type) {
242 case ACPI_TYPE_STRING:
243
244 /* String-to-Integer conversion */
245
246 status = acpi_ut_strtoul64(original_object->string.pointer,
247 ACPI_ANY_BASE, &value);
248 if (ACPI_FAILURE(status)) {
249 return (status);
250 }
251 break;
252
253 case ACPI_TYPE_BUFFER:
254
255 /* Buffer-to-Integer conversion. Max buffer size is 64 bits. */
256
257 if (original_object->buffer.length > 8) {
258 return (AE_AML_OPERAND_TYPE);
259 }
260
261 /* Extract each buffer byte to create the integer */
262
263 for (i = 0; i < original_object->buffer.length; i++) {
264 value |=
265 ((u64) original_object->buffer.
266 pointer[i] << (i * 8));
267 }
268 break;
269
270 default:
271 return (AE_AML_OPERAND_TYPE);
272 }
273
274 new_object = acpi_ut_create_integer_object(value);
275 if (!new_object) {
276 return (AE_NO_MEMORY);
277 }
278
279 *return_object = new_object;
280 return (AE_OK);
281}
282
283/*******************************************************************************
284 *
285 * FUNCTION: acpi_ns_convert_to_string
286 *
287 * PARAMETERS: original_object - Object to be converted
288 * return_object - Where the new converted object is returned
289 *
290 * RETURN: Status. AE_OK if conversion was successful.
291 *
292 * DESCRIPTION: Attempt to convert a Integer/Buffer object to a String.
293 *
294 ******************************************************************************/
295
296static acpi_status
297acpi_ns_convert_to_string(union acpi_operand_object *original_object,
298 union acpi_operand_object **return_object)
299{
300 union acpi_operand_object *new_object;
301 acpi_size length;
302 acpi_status status;
303
304 switch (original_object->common.type) {
305 case ACPI_TYPE_INTEGER:
306 /*
307 * Integer-to-String conversion. Commonly, convert
308 * an integer of value 0 to a NULL string. The last element of
309 * _BIF and _BIX packages occasionally need this fix.
310 */
311 if (original_object->integer.value == 0) {
312
313 /* Allocate a new NULL string object */
314
315 new_object = acpi_ut_create_string_object(0);
316 if (!new_object) {
317 return (AE_NO_MEMORY);
318 }
319 } else {
320 status =
321 acpi_ex_convert_to_string(original_object,
322 &new_object,
323 ACPI_IMPLICIT_CONVERT_HEX);
324 if (ACPI_FAILURE(status)) {
325 return (status);
326 }
327 }
328 break;
329
330 case ACPI_TYPE_BUFFER:
331 /*
332 * Buffer-to-String conversion. Use a to_string
333 * conversion, no transform performed on the buffer data. The best
334 * example of this is the _BIF method, where the string data from
335 * the battery is often (incorrectly) returned as buffer object(s).
336 */
337 length = 0;
338 while ((length < original_object->buffer.length) &&
339 (original_object->buffer.pointer[length])) {
340 length++;
341 }
342
343 /* Allocate a new string object */
344
345 new_object = acpi_ut_create_string_object(length);
346 if (!new_object) {
347 return (AE_NO_MEMORY);
348 }
349
350 /*
351 * Copy the raw buffer data with no transform. String is already NULL
352 * terminated at Length+1.
353 */
354 ACPI_MEMCPY(new_object->string.pointer,
355 original_object->buffer.pointer, length);
356 break;
357
358 default:
359 return (AE_AML_OPERAND_TYPE);
360 }
361
362 *return_object = new_object;
363 return (AE_OK);
364}
365
366/*******************************************************************************
367 * 312 *
368 * FUNCTION: acpi_ns_convert_to_buffer 313 * FUNCTION: acpi_ns_match_simple_repair
369 * 314 *
370 * PARAMETERS: original_object - Object to be converted 315 * PARAMETERS: node - Namespace node for the method/object
371 * return_object - Where the new converted object is returned 316 * return_btype - Object type that was returned
317 * package_index - Index of object within parent package (if
318 * applicable - ACPI_NOT_PACKAGE_ELEMENT
319 * otherwise)
372 * 320 *
373 * RETURN: Status. AE_OK if conversion was successful. 321 * RETURN: Pointer to entry in repair table. NULL indicates not found.
374 * 322 *
375 * DESCRIPTION: Attempt to convert a Integer/String/Package object to a Buffer. 323 * DESCRIPTION: Check an object name against the repairable object list.
376 * 324 *
377 ******************************************************************************/ 325 *****************************************************************************/
378 326
379static acpi_status 327static const struct acpi_simple_repair_info *acpi_ns_match_simple_repair(struct
380acpi_ns_convert_to_buffer(union acpi_operand_object *original_object, 328 acpi_namespace_node
381 union acpi_operand_object **return_object) 329 *node,
330 u32
331 return_btype,
332 u32
333 package_index)
382{ 334{
383 union acpi_operand_object *new_object; 335 const struct acpi_simple_repair_info *this_name;
384 acpi_status status;
385 union acpi_operand_object **elements;
386 u32 *dword_buffer;
387 u32 count;
388 u32 i;
389 336
390 switch (original_object->common.type) { 337 /* Search info table for a repairable predefined method/object name */
391 case ACPI_TYPE_INTEGER:
392 /*
393 * Integer-to-Buffer conversion.
394 * Convert the Integer to a packed-byte buffer. _MAT and other
395 * objects need this sometimes, if a read has been performed on a
396 * Field object that is less than or equal to the global integer
397 * size (32 or 64 bits).
398 */
399 status =
400 acpi_ex_convert_to_buffer(original_object, &new_object);
401 if (ACPI_FAILURE(status)) {
402 return (status);
403 }
404 break;
405 338
406 case ACPI_TYPE_STRING: 339 this_name = acpi_object_repair_info;
340 while (this_name->object_converter) {
341 if (ACPI_COMPARE_NAME(node->name.ascii, this_name->name)) {
407 342
408 /* String-to-Buffer conversion. Simple data copy */ 343 /* Check if we can actually repair this name/type combination */
409
410 new_object =
411 acpi_ut_create_buffer_object(original_object->string.
412 length);
413 if (!new_object) {
414 return (AE_NO_MEMORY);
415 }
416 344
417 ACPI_MEMCPY(new_object->buffer.pointer, 345 if ((return_btype & this_name->unexpected_btypes) &&
418 original_object->string.pointer, 346 (package_index == this_name->package_index)) {
419 original_object->string.length); 347 return (this_name);
420 break;
421
422 case ACPI_TYPE_PACKAGE:
423 /*
424 * This case is often seen for predefined names that must return a
425 * Buffer object with multiple DWORD integers within. For example,
426 * _FDE and _GTM. The Package can be converted to a Buffer.
427 */
428
429 /* All elements of the Package must be integers */
430
431 elements = original_object->package.elements;
432 count = original_object->package.count;
433
434 for (i = 0; i < count; i++) {
435 if ((!*elements) ||
436 ((*elements)->common.type != ACPI_TYPE_INTEGER)) {
437 return (AE_AML_OPERAND_TYPE);
438 } 348 }
439 elements++;
440 }
441
442 /* Create the new buffer object to replace the Package */
443 349
444 new_object = acpi_ut_create_buffer_object(ACPI_MUL_4(count)); 350 return (NULL);
445 if (!new_object) {
446 return (AE_NO_MEMORY);
447 } 351 }
448 352 this_name++;
449 /* Copy the package elements (integers) to the buffer as DWORDs */
450
451 elements = original_object->package.elements;
452 dword_buffer = ACPI_CAST_PTR(u32, new_object->buffer.pointer);
453
454 for (i = 0; i < count; i++) {
455 *dword_buffer = (u32) (*elements)->integer.value;
456 dword_buffer++;
457 elements++;
458 }
459 break;
460
461 default:
462 return (AE_AML_OPERAND_TYPE);
463 } 353 }
464 354
465 *return_object = new_object; 355 return (NULL); /* Name was not found in the repair table */
466 return (AE_OK);
467} 356}
468 357
469/******************************************************************************* 358/*******************************************************************************
diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c
index ba4d98287c6a..149e9b9c2c1b 100644
--- a/drivers/acpi/acpica/nsrepair2.c
+++ b/drivers/acpi/acpica/nsrepair2.c
@@ -66,9 +66,9 @@ typedef struct acpi_repair_info {
66 66
67/* Local prototypes */ 67/* Local prototypes */
68 68
69static const struct acpi_repair_info *acpi_ns_match_repairable_name(struct 69static const struct acpi_repair_info *acpi_ns_match_complex_repair(struct
70 acpi_namespace_node 70 acpi_namespace_node
71 *node); 71 *node);
72 72
73static acpi_status 73static acpi_status
74acpi_ns_repair_ALR(struct acpi_predefined_data *data, 74acpi_ns_repair_ALR(struct acpi_predefined_data *data,
@@ -175,7 +175,7 @@ acpi_ns_complex_repairs(struct acpi_predefined_data *data,
175 175
176 /* Check if this name is in the list of repairable names */ 176 /* Check if this name is in the list of repairable names */
177 177
178 predefined = acpi_ns_match_repairable_name(node); 178 predefined = acpi_ns_match_complex_repair(node);
179 if (!predefined) { 179 if (!predefined) {
180 return (validate_status); 180 return (validate_status);
181 } 181 }
@@ -186,7 +186,7 @@ acpi_ns_complex_repairs(struct acpi_predefined_data *data,
186 186
187/****************************************************************************** 187/******************************************************************************
188 * 188 *
189 * FUNCTION: acpi_ns_match_repairable_name 189 * FUNCTION: acpi_ns_match_complex_repair
190 * 190 *
191 * PARAMETERS: node - Namespace node for the method/object 191 * PARAMETERS: node - Namespace node for the method/object
192 * 192 *
@@ -196,9 +196,9 @@ acpi_ns_complex_repairs(struct acpi_predefined_data *data,
196 * 196 *
197 *****************************************************************************/ 197 *****************************************************************************/
198 198
199static const struct acpi_repair_info *acpi_ns_match_repairable_name(struct 199static const struct acpi_repair_info *acpi_ns_match_complex_repair(struct
200 acpi_namespace_node 200 acpi_namespace_node
201 *node) 201 *node)
202{ 202{
203 const struct acpi_repair_info *this_name; 203 const struct acpi_repair_info *this_name;
204 204
diff --git a/drivers/acpi/acpica/nsutils.c b/drivers/acpi/acpica/nsutils.c
index 686420df684f..2808586fad30 100644
--- a/drivers/acpi/acpica/nsutils.c
+++ b/drivers/acpi/acpica/nsutils.c
@@ -112,10 +112,10 @@ acpi_object_type acpi_ns_get_type(struct acpi_namespace_node * node)
112 112
113 if (!node) { 113 if (!node) {
114 ACPI_WARNING((AE_INFO, "Null Node parameter")); 114 ACPI_WARNING((AE_INFO, "Null Node parameter"));
115 return_VALUE(ACPI_TYPE_ANY); 115 return_UINT8(ACPI_TYPE_ANY);
116 } 116 }
117 117
118 return_VALUE(node->type); 118 return_UINT8(node->type);
119} 119}
120 120
121/******************************************************************************* 121/*******************************************************************************
@@ -140,10 +140,10 @@ u32 acpi_ns_local(acpi_object_type type)
140 /* Type code out of range */ 140 /* Type code out of range */
141 141
142 ACPI_WARNING((AE_INFO, "Invalid Object Type 0x%X", type)); 142 ACPI_WARNING((AE_INFO, "Invalid Object Type 0x%X", type));
143 return_VALUE(ACPI_NS_NORMAL); 143 return_UINT32(ACPI_NS_NORMAL);
144 } 144 }
145 145
146 return_VALUE(acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL); 146 return_UINT32(acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL);
147} 147}
148 148
149/******************************************************************************* 149/*******************************************************************************
diff --git a/drivers/acpi/acpica/psargs.c b/drivers/acpi/acpica/psargs.c
index f51308cdbc65..9f25a3d4e992 100644
--- a/drivers/acpi/acpica/psargs.c
+++ b/drivers/acpi/acpica/psargs.c
@@ -108,7 +108,7 @@ acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state)
108 /* Byte 0 is a special case, either bits [0:3] or [0:5] are used */ 108 /* Byte 0 is a special case, either bits [0:3] or [0:5] are used */
109 109
110 package_length |= (aml[0] & byte_zero_mask); 110 package_length |= (aml[0] & byte_zero_mask);
111 return_VALUE(package_length); 111 return_UINT32(package_length);
112} 112}
113 113
114/******************************************************************************* 114/*******************************************************************************
diff --git a/drivers/acpi/acpica/rscalc.c b/drivers/acpi/acpica/rscalc.c
index 7816d4eef04e..72077fa1eea5 100644
--- a/drivers/acpi/acpica/rscalc.c
+++ b/drivers/acpi/acpica/rscalc.c
@@ -202,6 +202,12 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
202 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); 202 return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
203 } 203 }
204 204
205 /* Sanity check the length. It must not be zero, or we loop forever */
206
207 if (!resource->length) {
208 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
209 }
210
205 /* Get the base size of the (external stream) resource descriptor */ 211 /* Get the base size of the (external stream) resource descriptor */
206 212
207 total_size = acpi_gbl_aml_resource_sizes[resource->type]; 213 total_size = acpi_gbl_aml_resource_sizes[resource->type];
diff --git a/drivers/acpi/acpica/rsdump.c b/drivers/acpi/acpica/rsdump.c
index cab51445189d..b5fc0db2e87b 100644
--- a/drivers/acpi/acpica/rsdump.c
+++ b/drivers/acpi/acpica/rsdump.c
@@ -385,6 +385,14 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list)
385 return; 385 return;
386 } 386 }
387 387
388 /* Sanity check the length. It must not be zero, or we loop forever */
389
390 if (!resource_list->length) {
391 acpi_os_printf
392 ("Invalid zero length descriptor in resource list\n");
393 return;
394 }
395
388 /* Dump the resource descriptor */ 396 /* Dump the resource descriptor */
389 397
390 if (type == ACPI_RESOURCE_TYPE_SERIAL_BUS) { 398 if (type == ACPI_RESOURCE_TYPE_SERIAL_BUS) {
diff --git a/drivers/acpi/acpica/rslist.c b/drivers/acpi/acpica/rslist.c
index ee2e206fc6c8..6053aa182093 100644
--- a/drivers/acpi/acpica/rslist.c
+++ b/drivers/acpi/acpica/rslist.c
@@ -178,6 +178,14 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
178 return_ACPI_STATUS(AE_BAD_DATA); 178 return_ACPI_STATUS(AE_BAD_DATA);
179 } 179 }
180 180
181 /* Sanity check the length. It must not be zero, or we loop forever */
182
183 if (!resource->length) {
184 ACPI_ERROR((AE_INFO,
185 "Invalid zero length descriptor in resource list\n"));
186 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
187 }
188
181 /* Perform the conversion */ 189 /* Perform the conversion */
182 190
183 if (resource->type == ACPI_RESOURCE_TYPE_SERIAL_BUS) { 191 if (resource->type == ACPI_RESOURCE_TYPE_SERIAL_BUS) {
diff --git a/drivers/acpi/acpica/rsxface.c b/drivers/acpi/acpica/rsxface.c
index 15d6eaef0e28..c0e5d2d3ce67 100644
--- a/drivers/acpi/acpica/rsxface.c
+++ b/drivers/acpi/acpica/rsxface.c
@@ -563,13 +563,19 @@ acpi_walk_resource_buffer(struct acpi_buffer * buffer,
563 563
564 while (resource < resource_end) { 564 while (resource < resource_end) {
565 565
566 /* Sanity check the resource */ 566 /* Sanity check the resource type */
567 567
568 if (resource->type > ACPI_RESOURCE_TYPE_MAX) { 568 if (resource->type > ACPI_RESOURCE_TYPE_MAX) {
569 status = AE_AML_INVALID_RESOURCE_TYPE; 569 status = AE_AML_INVALID_RESOURCE_TYPE;
570 break; 570 break;
571 } 571 }
572 572
573 /* Sanity check the length. It must not be zero, or we loop forever */
574
575 if (!resource->length) {
576 return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
577 }
578
573 /* Invoke the user function, abort on any error returned */ 579 /* Invoke the user function, abort on any error returned */
574 580
575 status = user_function(resource, context); 581 status = user_function(resource, context);
diff --git a/drivers/acpi/acpica/utaddress.c b/drivers/acpi/acpica/utaddress.c
index 698b9d385516..e0a2e2779c2e 100644
--- a/drivers/acpi/acpica/utaddress.c
+++ b/drivers/acpi/acpica/utaddress.c
@@ -214,7 +214,7 @@ acpi_ut_check_address_range(acpi_adr_space_type space_id,
214 214
215 if ((space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) && 215 if ((space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) &&
216 (space_id != ACPI_ADR_SPACE_SYSTEM_IO)) { 216 (space_id != ACPI_ADR_SPACE_SYSTEM_IO)) {
217 return_VALUE(0); 217 return_UINT32(0);
218 } 218 }
219 219
220 range_info = acpi_gbl_address_range_list[space_id]; 220 range_info = acpi_gbl_address_range_list[space_id];
@@ -256,7 +256,7 @@ acpi_ut_check_address_range(acpi_adr_space_type space_id,
256 range_info = range_info->next; 256 range_info = range_info->next;
257 } 257 }
258 258
259 return_VALUE(overlap_count); 259 return_UINT32(overlap_count);
260} 260}
261 261
262/******************************************************************************* 262/*******************************************************************************
diff --git a/drivers/acpi/acpica/utcache.c b/drivers/acpi/acpica/utcache.c
index e0e8579deaac..a877a9647fd9 100644
--- a/drivers/acpi/acpica/utcache.c
+++ b/drivers/acpi/acpica/utcache.c
@@ -85,7 +85,6 @@ acpi_os_create_cache(char *cache_name,
85 /* Populate the cache object and return it */ 85 /* Populate the cache object and return it */
86 86
87 ACPI_MEMSET(cache, 0, sizeof(struct acpi_memory_list)); 87 ACPI_MEMSET(cache, 0, sizeof(struct acpi_memory_list));
88 cache->link_offset = 8;
89 cache->list_name = cache_name; 88 cache->list_name = cache_name;
90 cache->object_size = object_size; 89 cache->object_size = object_size;
91 cache->max_depth = max_depth; 90 cache->max_depth = max_depth;
@@ -108,7 +107,7 @@ acpi_os_create_cache(char *cache_name,
108 107
109acpi_status acpi_os_purge_cache(struct acpi_memory_list * cache) 108acpi_status acpi_os_purge_cache(struct acpi_memory_list * cache)
110{ 109{
111 char *next; 110 void *next;
112 acpi_status status; 111 acpi_status status;
113 112
114 ACPI_FUNCTION_ENTRY(); 113 ACPI_FUNCTION_ENTRY();
@@ -128,10 +127,7 @@ acpi_status acpi_os_purge_cache(struct acpi_memory_list * cache)
128 127
129 /* Delete and unlink one cached state object */ 128 /* Delete and unlink one cached state object */
130 129
131 next = *(ACPI_CAST_INDIRECT_PTR(char, 130 next = ACPI_GET_DESCRIPTOR_PTR(cache->list_head);
132 &(((char *)cache->
133 list_head)[cache->
134 link_offset])));
135 ACPI_FREE(cache->list_head); 131 ACPI_FREE(cache->list_head);
136 132
137 cache->list_head = next; 133 cache->list_head = next;
@@ -221,10 +217,7 @@ acpi_os_release_object(struct acpi_memory_list * cache, void *object)
221 217
222 /* Put the object at the head of the cache list */ 218 /* Put the object at the head of the cache list */
223 219
224 *(ACPI_CAST_INDIRECT_PTR(char, 220 ACPI_SET_DESCRIPTOR_PTR(object, cache->list_head);
225 &(((char *)object)[cache->
226 link_offset]))) =
227 cache->list_head;
228 cache->list_head = object; 221 cache->list_head = object;
229 cache->current_depth++; 222 cache->current_depth++;
230 223
@@ -272,10 +265,7 @@ void *acpi_os_acquire_object(struct acpi_memory_list *cache)
272 /* There is an object available, use it */ 265 /* There is an object available, use it */
273 266
274 object = cache->list_head; 267 object = cache->list_head;
275 cache->list_head = *(ACPI_CAST_INDIRECT_PTR(char, 268 cache->list_head = ACPI_GET_DESCRIPTOR_PTR(object);
276 &(((char *)
277 object)[cache->
278 link_offset])));
279 269
280 cache->current_depth--; 270 cache->current_depth--;
281 271
diff --git a/drivers/acpi/acpica/utexcep.c b/drivers/acpi/acpica/utexcep.c
index a0ab7c02e87c..b543a144941a 100644
--- a/drivers/acpi/acpica/utexcep.c
+++ b/drivers/acpi/acpica/utexcep.c
@@ -64,7 +64,7 @@ ACPI_MODULE_NAME("utexcep")
64 ******************************************************************************/ 64 ******************************************************************************/
65const char *acpi_format_exception(acpi_status status) 65const char *acpi_format_exception(acpi_status status)
66{ 66{
67 const char *exception = NULL; 67 const struct acpi_exception_info *exception;
68 68
69 ACPI_FUNCTION_ENTRY(); 69 ACPI_FUNCTION_ENTRY();
70 70
@@ -76,10 +76,10 @@ const char *acpi_format_exception(acpi_status status)
76 ACPI_ERROR((AE_INFO, 76 ACPI_ERROR((AE_INFO,
77 "Unknown exception code: 0x%8.8X", status)); 77 "Unknown exception code: 0x%8.8X", status));
78 78
79 exception = "UNKNOWN_STATUS_CODE"; 79 return ("UNKNOWN_STATUS_CODE");
80 } 80 }
81 81
82 return (ACPI_CAST_PTR(const char, exception)); 82 return (exception->name);
83} 83}
84 84
85ACPI_EXPORT_SYMBOL(acpi_format_exception) 85ACPI_EXPORT_SYMBOL(acpi_format_exception)
@@ -97,10 +97,10 @@ ACPI_EXPORT_SYMBOL(acpi_format_exception)
97 * an ASCII string. 97 * an ASCII string.
98 * 98 *
99 ******************************************************************************/ 99 ******************************************************************************/
100const char *acpi_ut_validate_exception(acpi_status status) 100const struct acpi_exception_info *acpi_ut_validate_exception(acpi_status status)
101{ 101{
102 u32 sub_status; 102 u32 sub_status;
103 const char *exception = NULL; 103 const struct acpi_exception_info *exception = NULL;
104 104
105 ACPI_FUNCTION_ENTRY(); 105 ACPI_FUNCTION_ENTRY();
106 106
@@ -113,35 +113,35 @@ const char *acpi_ut_validate_exception(acpi_status status)
113 case AE_CODE_ENVIRONMENTAL: 113 case AE_CODE_ENVIRONMENTAL:
114 114
115 if (sub_status <= AE_CODE_ENV_MAX) { 115 if (sub_status <= AE_CODE_ENV_MAX) {
116 exception = acpi_gbl_exception_names_env[sub_status]; 116 exception = &acpi_gbl_exception_names_env[sub_status];
117 } 117 }
118 break; 118 break;
119 119
120 case AE_CODE_PROGRAMMER: 120 case AE_CODE_PROGRAMMER:
121 121
122 if (sub_status <= AE_CODE_PGM_MAX) { 122 if (sub_status <= AE_CODE_PGM_MAX) {
123 exception = acpi_gbl_exception_names_pgm[sub_status]; 123 exception = &acpi_gbl_exception_names_pgm[sub_status];
124 } 124 }
125 break; 125 break;
126 126
127 case AE_CODE_ACPI_TABLES: 127 case AE_CODE_ACPI_TABLES:
128 128
129 if (sub_status <= AE_CODE_TBL_MAX) { 129 if (sub_status <= AE_CODE_TBL_MAX) {
130 exception = acpi_gbl_exception_names_tbl[sub_status]; 130 exception = &acpi_gbl_exception_names_tbl[sub_status];
131 } 131 }
132 break; 132 break;
133 133
134 case AE_CODE_AML: 134 case AE_CODE_AML:
135 135
136 if (sub_status <= AE_CODE_AML_MAX) { 136 if (sub_status <= AE_CODE_AML_MAX) {
137 exception = acpi_gbl_exception_names_aml[sub_status]; 137 exception = &acpi_gbl_exception_names_aml[sub_status];
138 } 138 }
139 break; 139 break;
140 140
141 case AE_CODE_CONTROL: 141 case AE_CODE_CONTROL:
142 142
143 if (sub_status <= AE_CODE_CTRL_MAX) { 143 if (sub_status <= AE_CODE_CTRL_MAX) {
144 exception = acpi_gbl_exception_names_ctrl[sub_status]; 144 exception = &acpi_gbl_exception_names_ctrl[sub_status];
145 } 145 }
146 break; 146 break;
147 147
@@ -149,5 +149,9 @@ const char *acpi_ut_validate_exception(acpi_status status)
149 break; 149 break;
150 } 150 }
151 151
152 return (ACPI_CAST_PTR(const char, exception)); 152 if (!exception || !exception->name) {
153 return (NULL);
154 }
155
156 return (exception);
153} 157}
diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c
index ffecf4b4f0dd..f736448a8606 100644
--- a/drivers/acpi/acpica/utglobal.c
+++ b/drivers/acpi/acpica/utglobal.c
@@ -359,6 +359,8 @@ acpi_status acpi_ut_init_globals(void)
359 359
360#ifdef ACPI_DISASSEMBLER 360#ifdef ACPI_DISASSEMBLER
361 acpi_gbl_external_list = NULL; 361 acpi_gbl_external_list = NULL;
362 acpi_gbl_num_external_methods = 0;
363 acpi_gbl_resolved_external_methods = 0;
362#endif 364#endif
363 365
364#ifdef ACPI_DEBUG_OUTPUT 366#ifdef ACPI_DEBUG_OUTPUT
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index ab764ed34a50..2652a614deeb 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -354,6 +354,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
354 354
355 } 355 }
356 resource->end.type = ACPI_RESOURCE_TYPE_END_TAG; 356 resource->end.type = ACPI_RESOURCE_TYPE_END_TAG;
357 resource->end.length = sizeof(struct acpi_resource);
357 358
358 /* Attempt to set the resource */ 359 /* Attempt to set the resource */
359 status = acpi_set_current_resources(link->device->handle, &buffer); 360 status = acpi_set_current_resources(link->device->handle, &buffer);