aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/acpi_memhotplug.c11
-rw-r--r--drivers/acpi/acpica/Makefile4
-rw-r--r--drivers/acpi/acpica/acconfig.h10
-rw-r--r--drivers/acpi/acpica/acdebug.h4
-rw-r--r--drivers/acpi/acpica/acglobal.h37
-rw-r--r--drivers/acpi/acpica/achware.h8
-rw-r--r--drivers/acpi/acpica/acinterp.h4
-rw-r--r--drivers/acpi/acpica/aclocal.h16
-rw-r--r--drivers/acpi/acpica/acmacros.h2
-rw-r--r--drivers/acpi/acpica/acnamesp.h25
-rw-r--r--drivers/acpi/acpica/acobject.h1
-rw-r--r--drivers/acpi/acpica/acparser.h2
-rw-r--r--drivers/acpi/acpica/acpredef.h584
-rw-r--r--drivers/acpi/acpica/acutils.h30
-rw-r--r--drivers/acpi/acpica/amlcode.h1
-rw-r--r--drivers/acpi/acpica/dsfield.c18
-rw-r--r--drivers/acpi/acpica/dsmethod.c15
-rw-r--r--drivers/acpi/acpica/dsmthdat.c8
-rw-r--r--drivers/acpi/acpica/dsobject.c23
-rw-r--r--drivers/acpi/acpica/dswload.c41
-rw-r--r--drivers/acpi/acpica/evgpe.c8
-rw-r--r--drivers/acpi/acpica/evgpeblk.c4
-rw-r--r--drivers/acpi/acpica/evrgnini.c45
-rw-r--r--drivers/acpi/acpica/exconfig.c7
-rw-r--r--drivers/acpi/acpica/exdump.c6
-rw-r--r--drivers/acpi/acpica/exfield.c82
-rw-r--r--drivers/acpi/acpica/exfldio.c7
-rw-r--r--drivers/acpi/acpica/exutils.c53
-rw-r--r--drivers/acpi/acpica/hwgpe.c34
-rw-r--r--drivers/acpi/acpica/hwregs.c206
-rw-r--r--drivers/acpi/acpica/hwtimer.c2
-rw-r--r--drivers/acpi/acpica/hwxface.c181
-rw-r--r--drivers/acpi/acpica/nsalloc.c88
-rw-r--r--drivers/acpi/acpica/nsdumpdv.c7
-rw-r--r--drivers/acpi/acpica/nseval.c137
-rw-r--r--drivers/acpi/acpica/nsinit.c15
-rw-r--r--drivers/acpi/acpica/nsload.c3
-rw-r--r--drivers/acpi/acpica/nspredef.c718
-rw-r--r--drivers/acpi/acpica/nsrepair.c203
-rw-r--r--drivers/acpi/acpica/nsutils.c5
-rw-r--r--drivers/acpi/acpica/nsxfeval.c23
-rw-r--r--drivers/acpi/acpica/nsxfname.c237
-rw-r--r--drivers/acpi/acpica/psloop.c119
-rw-r--r--drivers/acpi/acpica/psxface.c4
-rw-r--r--drivers/acpi/acpica/tbutils.c82
-rw-r--r--drivers/acpi/acpica/uteval.c378
-rw-r--r--drivers/acpi/acpica/utglobal.c12
-rw-r--r--drivers/acpi/acpica/utids.c382
-rw-r--r--drivers/acpi/acpica/utinit.c22
-rw-r--r--drivers/acpi/acpica/utmisc.c85
-rw-r--r--drivers/acpi/acpica/utxface.c26
-rw-r--r--drivers/acpi/bus.c2
-rw-r--r--drivers/acpi/container.c11
-rw-r--r--drivers/acpi/dock.c8
-rw-r--r--drivers/acpi/glue.c8
-rw-r--r--drivers/acpi/scan.c163
56 files changed, 2812 insertions, 1405 deletions
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 9a62224cc278..80eacbe157e2 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -481,26 +481,23 @@ static acpi_status is_memory_device(acpi_handle handle)
481{ 481{
482 char *hardware_id; 482 char *hardware_id;
483 acpi_status status; 483 acpi_status status;
484 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
485 struct acpi_device_info *info; 484 struct acpi_device_info *info;
486 485
487 486 status = acpi_get_object_info(handle, &info);
488 status = acpi_get_object_info(handle, &buffer);
489 if (ACPI_FAILURE(status)) 487 if (ACPI_FAILURE(status))
490 return status; 488 return status;
491 489
492 info = buffer.pointer;
493 if (!(info->valid & ACPI_VALID_HID)) { 490 if (!(info->valid & ACPI_VALID_HID)) {
494 kfree(buffer.pointer); 491 kfree(info);
495 return AE_ERROR; 492 return AE_ERROR;
496 } 493 }
497 494
498 hardware_id = info->hardware_id.value; 495 hardware_id = info->hardware_id.string;
499 if ((hardware_id == NULL) || 496 if ((hardware_id == NULL) ||
500 (strcmp(hardware_id, ACPI_MEMORY_DEVICE_HID))) 497 (strcmp(hardware_id, ACPI_MEMORY_DEVICE_HID)))
501 status = AE_ERROR; 498 status = AE_ERROR;
502 499
503 kfree(buffer.pointer); 500 kfree(info);
504 return status; 501 return status;
505} 502}
506 503
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
index 72ac28da14e3..e7973bc16846 100644
--- a/drivers/acpi/acpica/Makefile
+++ b/drivers/acpi/acpica/Makefile
@@ -28,7 +28,7 @@ acpi-$(ACPI_FUTURE_USAGE) += hwtimer.o
28acpi-y += nsaccess.o nsload.o nssearch.o nsxfeval.o \ 28acpi-y += nsaccess.o nsload.o nssearch.o nsxfeval.o \
29 nsalloc.o nseval.o nsnames.o nsutils.o nsxfname.o \ 29 nsalloc.o nseval.o nsnames.o nsutils.o nsxfname.o \
30 nsdump.o nsinit.o nsobject.o nswalk.o nsxfobj.o \ 30 nsdump.o nsinit.o nsobject.o nswalk.o nsxfobj.o \
31 nsparse.o nspredef.o 31 nsparse.o nspredef.o nsrepair.o
32 32
33acpi-$(ACPI_FUTURE_USAGE) += nsdumpdv.o 33acpi-$(ACPI_FUTURE_USAGE) += nsdumpdv.o
34 34
@@ -44,4 +44,4 @@ acpi-y += tbxface.o tbinstal.o tbutils.o tbfind.o tbfadt.o tbxfroot.o
44 44
45acpi-y += utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \ 45acpi-y += utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \
46 utcopy.o utdelete.o utglobal.o utmath.o utobject.o \ 46 utcopy.o utdelete.o utglobal.o utmath.o utobject.o \
47 utstate.o utmutex.o utobject.o utresrc.o utlock.o 47 utstate.o utmutex.o utobject.o utresrc.o utlock.o utids.o
diff --git a/drivers/acpi/acpica/acconfig.h b/drivers/acpi/acpica/acconfig.h
index e6777fb883d2..8e679ef5b231 100644
--- a/drivers/acpi/acpica/acconfig.h
+++ b/drivers/acpi/acpica/acconfig.h
@@ -183,7 +183,7 @@
183 183
184/* Operation regions */ 184/* Operation regions */
185 185
186#define ACPI_NUM_PREDEFINED_REGIONS 8 186#define ACPI_NUM_PREDEFINED_REGIONS 9
187#define ACPI_USER_REGION_BEGIN 0x80 187#define ACPI_USER_REGION_BEGIN 0x80
188 188
189/* Maximum space_ids for Operation Regions */ 189/* Maximum space_ids for Operation Regions */
@@ -199,9 +199,15 @@
199#define ACPI_RSDP_CHECKSUM_LENGTH 20 199#define ACPI_RSDP_CHECKSUM_LENGTH 20
200#define ACPI_RSDP_XCHECKSUM_LENGTH 36 200#define ACPI_RSDP_XCHECKSUM_LENGTH 36
201 201
202/* SMBus bidirectional buffer size */ 202/* SMBus and IPMI bidirectional buffer size */
203 203
204#define ACPI_SMBUS_BUFFER_SIZE 34 204#define ACPI_SMBUS_BUFFER_SIZE 34
205#define ACPI_IPMI_BUFFER_SIZE 66
206
207/* _sx_d and _sx_w control methods */
208
209#define ACPI_NUM_sx_d_METHODS 4
210#define ACPI_NUM_sx_w_METHODS 5
205 211
206/****************************************************************************** 212/******************************************************************************
207 * 213 *
diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h
index 62c59df3b86c..a4fb001d96f1 100644
--- a/drivers/acpi/acpica/acdebug.h
+++ b/drivers/acpi/acpica/acdebug.h
@@ -154,10 +154,6 @@ void
154acpi_db_display_argument_object(union acpi_operand_object *obj_desc, 154acpi_db_display_argument_object(union acpi_operand_object *obj_desc,
155 struct acpi_walk_state *walk_state); 155 struct acpi_walk_state *walk_state);
156 156
157void acpi_db_check_predefined_names(void);
158
159void acpi_db_batch_execute(void);
160
161/* 157/*
162 * dbexec - debugger control method execution 158 * dbexec - debugger control method execution
163 */ 159 */
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 3d87362d17ed..29ba66d5a790 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -58,6 +58,10 @@
58#define ACPI_INIT_GLOBAL(a,b) a 58#define ACPI_INIT_GLOBAL(a,b) a
59#endif 59#endif
60 60
61#ifdef DEFINE_ACPI_GLOBALS
62
63/* Public globals, available from outside ACPICA subsystem */
64
61/***************************************************************************** 65/*****************************************************************************
62 * 66 *
63 * Runtime configuration (static defaults that can be overriden at runtime) 67 * Runtime configuration (static defaults that can be overriden at runtime)
@@ -78,7 +82,7 @@
78 * 5) Allow unresolved references (invalid target name) in package objects 82 * 5) Allow unresolved references (invalid target name) in package objects
79 * 6) Enable warning messages for behavior that is not ACPI spec compliant 83 * 6) Enable warning messages for behavior that is not ACPI spec compliant
80 */ 84 */
81ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_enable_interpreter_slack, FALSE); 85u8 ACPI_INIT_GLOBAL(acpi_gbl_enable_interpreter_slack, FALSE);
82 86
83/* 87/*
84 * Automatically serialize ALL control methods? Default is FALSE, meaning 88 * Automatically serialize ALL control methods? Default is FALSE, meaning
@@ -86,27 +90,36 @@ ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_enable_interpreter_slack, FALSE);
86 * Only change this if the ASL code is poorly written and cannot handle 90 * Only change this if the ASL code is poorly written and cannot handle
87 * reentrancy even though methods are marked "NotSerialized". 91 * reentrancy even though methods are marked "NotSerialized".
88 */ 92 */
89ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_all_methods_serialized, FALSE); 93u8 ACPI_INIT_GLOBAL(acpi_gbl_all_methods_serialized, FALSE);
90 94
91/* 95/*
92 * Create the predefined _OSI method in the namespace? Default is TRUE 96 * Create the predefined _OSI method in the namespace? Default is TRUE
93 * because ACPI CA is fully compatible with other ACPI implementations. 97 * because ACPI CA is fully compatible with other ACPI implementations.
94 * Changing this will revert ACPI CA (and machine ASL) to pre-OSI behavior. 98 * Changing this will revert ACPI CA (and machine ASL) to pre-OSI behavior.
95 */ 99 */
96ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_create_osi_method, TRUE); 100u8 ACPI_INIT_GLOBAL(acpi_gbl_create_osi_method, TRUE);
97 101
98/* 102/*
99 * Disable wakeup GPEs during runtime? Default is TRUE because WAKE and 103 * Disable wakeup GPEs during runtime? Default is TRUE because WAKE and
100 * RUNTIME GPEs should never be shared, and WAKE GPEs should typically only 104 * RUNTIME GPEs should never be shared, and WAKE GPEs should typically only
101 * be enabled just before going to sleep. 105 * be enabled just before going to sleep.
102 */ 106 */
103ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_leave_wake_gpes_disabled, TRUE); 107u8 ACPI_INIT_GLOBAL(acpi_gbl_leave_wake_gpes_disabled, TRUE);
104 108
105/* 109/*
106 * Optionally use default values for the ACPI register widths. Set this to 110 * Optionally use default values for the ACPI register widths. Set this to
107 * TRUE to use the defaults, if an FADT contains incorrect widths/lengths. 111 * TRUE to use the defaults, if an FADT contains incorrect widths/lengths.
108 */ 112 */
109ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_use_default_register_widths, TRUE); 113u8 ACPI_INIT_GLOBAL(acpi_gbl_use_default_register_widths, TRUE);
114
115/* acpi_gbl_FADT is a local copy of the FADT, converted to a common format. */
116
117struct acpi_table_fadt acpi_gbl_FADT;
118u32 acpi_current_gpe_count;
119u32 acpi_gbl_trace_flags;
120acpi_name acpi_gbl_trace_method_name;
121
122#endif
110 123
111/***************************************************************************** 124/*****************************************************************************
112 * 125 *
@@ -114,11 +127,6 @@ ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_use_default_register_widths, TRUE);
114 * 127 *
115 ****************************************************************************/ 128 ****************************************************************************/
116 129
117/* Runtime configuration of debug print levels */
118
119extern u32 acpi_dbg_level;
120extern u32 acpi_dbg_layer;
121
122/* Procedure nesting level for debug output */ 130/* Procedure nesting level for debug output */
123 131
124extern u32 acpi_gbl_nesting_level; 132extern u32 acpi_gbl_nesting_level;
@@ -127,10 +135,8 @@ extern u32 acpi_gbl_nesting_level;
127 135
128ACPI_EXTERN u32 acpi_gbl_original_dbg_level; 136ACPI_EXTERN u32 acpi_gbl_original_dbg_level;
129ACPI_EXTERN u32 acpi_gbl_original_dbg_layer; 137ACPI_EXTERN u32 acpi_gbl_original_dbg_layer;
130ACPI_EXTERN acpi_name acpi_gbl_trace_method_name;
131ACPI_EXTERN u32 acpi_gbl_trace_dbg_level; 138ACPI_EXTERN u32 acpi_gbl_trace_dbg_level;
132ACPI_EXTERN u32 acpi_gbl_trace_dbg_layer; 139ACPI_EXTERN u32 acpi_gbl_trace_dbg_layer;
133ACPI_EXTERN u32 acpi_gbl_trace_flags;
134 140
135/***************************************************************************** 141/*****************************************************************************
136 * 142 *
@@ -142,10 +148,8 @@ ACPI_EXTERN u32 acpi_gbl_trace_flags;
142 * acpi_gbl_root_table_list is the master list of ACPI tables found in the 148 * acpi_gbl_root_table_list is the master list of ACPI tables found in the
143 * RSDT/XSDT. 149 * RSDT/XSDT.
144 * 150 *
145 * acpi_gbl_FADT is a local copy of the FADT, converted to a common format.
146 */ 151 */
147ACPI_EXTERN struct acpi_internal_rsdt acpi_gbl_root_table_list; 152ACPI_EXTERN struct acpi_internal_rsdt acpi_gbl_root_table_list;
148ACPI_EXTERN struct acpi_table_fadt acpi_gbl_FADT;
149ACPI_EXTERN struct acpi_table_facs *acpi_gbl_FACS; 153ACPI_EXTERN struct acpi_table_facs *acpi_gbl_FACS;
150 154
151/* These addresses are calculated from the FADT Event Block addresses */ 155/* These addresses are calculated from the FADT Event Block addresses */
@@ -261,7 +265,8 @@ ACPI_EXTERN u8 acpi_gbl_osi_data;
261extern u8 acpi_gbl_shutdown; 265extern u8 acpi_gbl_shutdown;
262extern u32 acpi_gbl_startup_flags; 266extern u32 acpi_gbl_startup_flags;
263extern const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT]; 267extern const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT];
264extern const char *acpi_gbl_highest_dstate_names[4]; 268extern const char *acpi_gbl_lowest_dstate_names[ACPI_NUM_sx_w_METHODS];
269extern const char *acpi_gbl_highest_dstate_names[ACPI_NUM_sx_d_METHODS];
265extern const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES]; 270extern const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES];
266extern const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS]; 271extern const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS];
267 272
@@ -290,6 +295,7 @@ extern char const *acpi_gbl_exception_names_ctrl[];
290ACPI_EXTERN struct acpi_namespace_node acpi_gbl_root_node_struct; 295ACPI_EXTERN struct acpi_namespace_node acpi_gbl_root_node_struct;
291ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_root_node; 296ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_root_node;
292ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_fadt_gpe_device; 297ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_fadt_gpe_device;
298ACPI_EXTERN union acpi_operand_object *acpi_gbl_module_code_list;
293 299
294extern const u8 acpi_gbl_ns_properties[ACPI_NUM_NS_TYPES]; 300extern const u8 acpi_gbl_ns_properties[ACPI_NUM_NS_TYPES];
295extern const struct acpi_predefined_names 301extern const struct acpi_predefined_names
@@ -340,7 +346,6 @@ ACPI_EXTERN struct acpi_fixed_event_handler
340ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head; 346ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head;
341ACPI_EXTERN struct acpi_gpe_block_info 347ACPI_EXTERN struct acpi_gpe_block_info
342*acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS]; 348*acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS];
343ACPI_EXTERN u32 acpi_current_gpe_count;
344 349
345/***************************************************************************** 350/*****************************************************************************
346 * 351 *
diff --git a/drivers/acpi/acpica/achware.h b/drivers/acpi/acpica/achware.h
index 4afa3d8e0efb..36192f142fbb 100644
--- a/drivers/acpi/acpica/achware.h
+++ b/drivers/acpi/acpica/achware.h
@@ -62,6 +62,14 @@ u32 acpi_hw_get_mode(void);
62/* 62/*
63 * hwregs - ACPI Register I/O 63 * hwregs - ACPI Register I/O
64 */ 64 */
65acpi_status
66acpi_hw_validate_register(struct acpi_generic_address *reg,
67 u8 max_bit_width, u64 *address);
68
69acpi_status acpi_hw_read(u32 *value, struct acpi_generic_address *reg);
70
71acpi_status acpi_hw_write(u32 value, struct acpi_generic_address *reg);
72
65struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id); 73struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id);
66 74
67acpi_status acpi_hw_write_pm1_control(u32 pm1a_control, u32 pm1b_control); 75acpi_status acpi_hw_write_pm1_control(u32 pm1a_control, u32 pm1b_control);
diff --git a/drivers/acpi/acpica/acinterp.h b/drivers/acpi/acpica/acinterp.h
index e8db7a3143a5..5db9f2916f7c 100644
--- a/drivers/acpi/acpica/acinterp.h
+++ b/drivers/acpi/acpica/acinterp.h
@@ -461,9 +461,9 @@ void acpi_ex_acquire_global_lock(u32 rule);
461 461
462void acpi_ex_release_global_lock(u32 rule); 462void acpi_ex_release_global_lock(u32 rule);
463 463
464void acpi_ex_eisa_id_to_string(u32 numeric_id, char *out_string); 464void acpi_ex_eisa_id_to_string(char *dest, acpi_integer compressed_id);
465 465
466void acpi_ex_unsigned_integer_to_string(acpi_integer value, char *out_string); 466void acpi_ex_integer_to_string(char *dest, acpi_integer value);
467 467
468/* 468/*
469 * exregion - default op_region handlers 469 * exregion - default op_region handlers
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index ee986edfa0da..81e64f478679 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -369,6 +369,19 @@ union acpi_predefined_info {
369 struct acpi_package_info3 ret_info3; 369 struct acpi_package_info3 ret_info3;
370}; 370};
371 371
372/* Data block used during object validation */
373
374struct acpi_predefined_data {
375 char *pathname;
376 const union acpi_predefined_info *predefined;
377 u32 flags;
378 u8 node_flags;
379};
380
381/* Defines for Flags field above */
382
383#define ACPI_OBJECT_REPAIRED 1
384
372/* 385/*
373 * Bitmapped return value types 386 * Bitmapped return value types
374 * Note: the actual data types must be contiguous, a loop in nspredef.c 387 * Note: the actual data types must be contiguous, a loop in nspredef.c
@@ -885,6 +898,9 @@ struct acpi_bit_register_info {
885#define ACPI_OSI_WIN_XP_SP2 0x05 898#define ACPI_OSI_WIN_XP_SP2 0x05
886#define ACPI_OSI_WINSRV_2003_SP1 0x06 899#define ACPI_OSI_WINSRV_2003_SP1 0x06
887#define ACPI_OSI_WIN_VISTA 0x07 900#define ACPI_OSI_WIN_VISTA 0x07
901#define ACPI_OSI_WINSRV_2008 0x08
902#define ACPI_OSI_WIN_VISTA_SP1 0x09
903#define ACPI_OSI_WIN_7 0x0A
888 904
889#define ACPI_ALWAYS_ILLEGAL 0x00 905#define ACPI_ALWAYS_ILLEGAL 0x00
890 906
diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h
index 91ac7d7b4402..3acd9c6760ea 100644
--- a/drivers/acpi/acpica/acmacros.h
+++ b/drivers/acpi/acpica/acmacros.h
@@ -340,6 +340,7 @@
340 */ 340 */
341#define ACPI_ERROR_NAMESPACE(s, e) acpi_ns_report_error (AE_INFO, s, e); 341#define ACPI_ERROR_NAMESPACE(s, e) acpi_ns_report_error (AE_INFO, s, e);
342#define ACPI_ERROR_METHOD(s, n, p, e) acpi_ns_report_method_error (AE_INFO, s, n, p, e); 342#define ACPI_ERROR_METHOD(s, n, p, e) acpi_ns_report_method_error (AE_INFO, s, n, p, e);
343#define ACPI_WARN_PREDEFINED(plist) acpi_ut_predefined_warning plist
343 344
344#else 345#else
345 346
@@ -347,6 +348,7 @@
347 348
348#define ACPI_ERROR_NAMESPACE(s, e) 349#define ACPI_ERROR_NAMESPACE(s, e)
349#define ACPI_ERROR_METHOD(s, n, p, e) 350#define ACPI_ERROR_METHOD(s, n, p, e)
351#define ACPI_WARN_PREDEFINED(plist)
350#endif /* ACPI_NO_ERROR_MESSAGES */ 352#endif /* ACPI_NO_ERROR_MESSAGES */
351 353
352/* 354/*
diff --git a/drivers/acpi/acpica/acnamesp.h b/drivers/acpi/acpica/acnamesp.h
index 94cdc2b8cb93..09a2764c734b 100644
--- a/drivers/acpi/acpica/acnamesp.h
+++ b/drivers/acpi/acpica/acnamesp.h
@@ -73,6 +73,14 @@
73#define ACPI_NS_WALK_UNLOCK 0x01 73#define ACPI_NS_WALK_UNLOCK 0x01
74#define ACPI_NS_WALK_TEMP_NODES 0x02 74#define ACPI_NS_WALK_TEMP_NODES 0x02
75 75
76/* Object is not a package element */
77
78#define ACPI_NOT_PACKAGE_ELEMENT ACPI_UINT32_MAX
79
80/* Always emit warning message, not dependent on node flags */
81
82#define ACPI_WARN_ALWAYS 0
83
76/* 84/*
77 * nsinit - Namespace initialization 85 * nsinit - Namespace initialization
78 */ 86 */
@@ -144,6 +152,8 @@ struct acpi_namespace_node *acpi_ns_create_node(u32 name);
144 152
145void acpi_ns_delete_node(struct acpi_namespace_node *node); 153void acpi_ns_delete_node(struct acpi_namespace_node *node);
146 154
155void acpi_ns_remove_node(struct acpi_namespace_node *node);
156
147void 157void
148acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_handle); 158acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_handle);
149 159
@@ -186,6 +196,8 @@ acpi_ns_dump_objects(acpi_object_type type,
186 */ 196 */
187acpi_status acpi_ns_evaluate(struct acpi_evaluate_info *info); 197acpi_status acpi_ns_evaluate(struct acpi_evaluate_info *info);
188 198
199void acpi_ns_exec_module_code_list(void);
200
189/* 201/*
190 * nspredef - Support for predefined/reserved names 202 * nspredef - Support for predefined/reserved names
191 */ 203 */
@@ -260,6 +272,19 @@ acpi_ns_get_attached_data(struct acpi_namespace_node *node,
260 acpi_object_handler handler, void **data); 272 acpi_object_handler handler, void **data);
261 273
262/* 274/*
275 * nsrepair - return object repair for predefined methods/objects
276 */
277acpi_status
278acpi_ns_repair_object(struct acpi_predefined_data *data,
279 u32 expected_btypes,
280 u32 package_index,
281 union acpi_operand_object **return_object_ptr);
282
283acpi_status
284acpi_ns_repair_package_list(struct acpi_predefined_data *data,
285 union acpi_operand_object **obj_desc_ptr);
286
287/*
263 * nssearch - Namespace searching and entry 288 * nssearch - Namespace searching and entry
264 */ 289 */
265acpi_status 290acpi_status
diff --git a/drivers/acpi/acpica/acobject.h b/drivers/acpi/acpica/acobject.h
index eb6f038b03d9..b39d682a2140 100644
--- a/drivers/acpi/acpica/acobject.h
+++ b/drivers/acpi/acpica/acobject.h
@@ -98,6 +98,7 @@
98#define AOPOBJ_SETUP_COMPLETE 0x10 98#define AOPOBJ_SETUP_COMPLETE 0x10
99#define AOPOBJ_SINGLE_DATUM 0x20 99#define AOPOBJ_SINGLE_DATUM 0x20
100#define AOPOBJ_INVALID 0x40 /* Used if host OS won't allow an op_region address */ 100#define AOPOBJ_INVALID 0x40 /* Used if host OS won't allow an op_region address */
101#define AOPOBJ_MODULE_LEVEL 0x80
101 102
102/****************************************************************************** 103/******************************************************************************
103 * 104 *
diff --git a/drivers/acpi/acpica/acparser.h b/drivers/acpi/acpica/acparser.h
index 23ee0fbf5619..22881e8ce229 100644
--- a/drivers/acpi/acpica/acparser.h
+++ b/drivers/acpi/acpica/acparser.h
@@ -62,6 +62,8 @@
62#define ACPI_PARSE_DEFERRED_OP 0x0100 62#define ACPI_PARSE_DEFERRED_OP 0x0100
63#define ACPI_PARSE_DISASSEMBLE 0x0200 63#define ACPI_PARSE_DISASSEMBLE 0x0200
64 64
65#define ACPI_PARSE_MODULE_LEVEL 0x0400
66
65/****************************************************************************** 67/******************************************************************************
66 * 68 *
67 * Parser interfaces 69 * Parser interfaces
diff --git a/drivers/acpi/acpica/acpredef.h b/drivers/acpi/acpica/acpredef.h
index 63f656ae3604..cd80d1dd1950 100644
--- a/drivers/acpi/acpica/acpredef.h
+++ b/drivers/acpi/acpica/acpredef.h
@@ -64,8 +64,8 @@
64 * (Used for _PRW) 64 * (Used for _PRW)
65 * 65 *
66 * 66 *
67 * 2) PTYPE2 packages contain a variable number of sub-packages. Each of the 67 * 2) PTYPE2 packages contain a Variable-length number of sub-packages. Each
68 * different types describe the contents of each of the sub-packages. 68 * of the different types describe the contents of each of the sub-packages.
69 * 69 *
70 * ACPI_PTYPE2: Each subpackage contains 1 or 2 object types: 70 * ACPI_PTYPE2: Each subpackage contains 1 or 2 object types:
71 * object type 71 * object type
@@ -91,6 +91,9 @@
91 * ACPI_PTYPE2_MIN: Each subpackage has a variable but minimum length 91 * ACPI_PTYPE2_MIN: Each subpackage has a variable but minimum length
92 * (Used for _HPX) 92 * (Used for _HPX)
93 * 93 *
94 * ACPI_PTYPE2_REV_FIXED: Revision at start, each subpackage is Fixed-length
95 * (Used for _ART, _FPS)
96 *
94 *****************************************************************************/ 97 *****************************************************************************/
95 98
96enum acpi_return_package_types { 99enum acpi_return_package_types {
@@ -101,9 +104,11 @@ enum acpi_return_package_types {
101 ACPI_PTYPE2_COUNT = 5, 104 ACPI_PTYPE2_COUNT = 5,
102 ACPI_PTYPE2_PKG_COUNT = 6, 105 ACPI_PTYPE2_PKG_COUNT = 6,
103 ACPI_PTYPE2_FIXED = 7, 106 ACPI_PTYPE2_FIXED = 7,
104 ACPI_PTYPE2_MIN = 8 107 ACPI_PTYPE2_MIN = 8,
108 ACPI_PTYPE2_REV_FIXED = 9
105}; 109};
106 110
111#ifdef ACPI_CREATE_PREDEFINED_TABLE
107/* 112/*
108 * Predefined method/object information table. 113 * Predefined method/object information table.
109 * 114 *
@@ -136,239 +141,384 @@ enum acpi_return_package_types {
136 * is saved here (rather than in a separate table) in order to minimize the 141 * is saved here (rather than in a separate table) in order to minimize the
137 * overall size of the stored data. 142 * overall size of the stored data.
138 */ 143 */
139static const union acpi_predefined_info predefined_names[] = { 144static const union acpi_predefined_info predefined_names[] =
140 {.info = {"_AC0", 0, ACPI_RTYPE_INTEGER}}, 145{
141 {.info = {"_AC1", 0, ACPI_RTYPE_INTEGER}}, 146 {{"_AC0", 0, ACPI_RTYPE_INTEGER}},
142 {.info = {"_AC2", 0, ACPI_RTYPE_INTEGER}}, 147 {{"_AC1", 0, ACPI_RTYPE_INTEGER}},
143 {.info = {"_AC3", 0, ACPI_RTYPE_INTEGER}}, 148 {{"_AC2", 0, ACPI_RTYPE_INTEGER}},
144 {.info = {"_AC4", 0, ACPI_RTYPE_INTEGER}}, 149 {{"_AC3", 0, ACPI_RTYPE_INTEGER}},
145 {.info = {"_AC5", 0, ACPI_RTYPE_INTEGER}}, 150 {{"_AC4", 0, ACPI_RTYPE_INTEGER}},
146 {.info = {"_AC6", 0, ACPI_RTYPE_INTEGER}}, 151 {{"_AC5", 0, ACPI_RTYPE_INTEGER}},
147 {.info = {"_AC7", 0, ACPI_RTYPE_INTEGER}}, 152 {{"_AC6", 0, ACPI_RTYPE_INTEGER}},
148 {.info = {"_AC8", 0, ACPI_RTYPE_INTEGER}}, 153 {{"_AC7", 0, ACPI_RTYPE_INTEGER}},
149 {.info = {"_AC9", 0, ACPI_RTYPE_INTEGER}}, 154 {{"_AC8", 0, ACPI_RTYPE_INTEGER}},
150 {.info = {"_ADR", 0, ACPI_RTYPE_INTEGER}}, 155 {{"_AC9", 0, ACPI_RTYPE_INTEGER}},
151 {.info = {"_AL0", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */ 156 {{"_ADR", 0, ACPI_RTYPE_INTEGER}},
152 {.info = {"_AL1", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */ 157 {{"_AL0", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */
153 {.info = {"_AL2", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */ 158 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}},
154 {.info = {"_AL3", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */ 159
155 {.info = {"_AL4", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */ 160 {{"_AL1", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */
156 {.info = {"_AL5", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */ 161 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}},
157 {.info = {"_AL6", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */ 162
158 {.info = {"_AL7", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */ 163 {{"_AL2", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */
159 {.info = {"_AL8", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */ 164 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}},
160 {.info = {"_AL9", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */ 165
161 {.info = {"_ALC", 0, ACPI_RTYPE_INTEGER}}, 166 {{"_AL3", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */
162 {.info = {"_ALI", 0, ACPI_RTYPE_INTEGER}}, 167 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}},
163 {.info = {"_ALP", 0, ACPI_RTYPE_INTEGER}}, 168
164 {.info = {"_ALR", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 2, 0, 0, 0}}, /* variable (Pkgs) each 2 (Ints) */ 169 {{"_AL4", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */
165 {.info = {"_ALT", 0, ACPI_RTYPE_INTEGER}}, 170 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}},
166 {.info = {"_BBN", 0, ACPI_RTYPE_INTEGER}}, 171
167 {.info = {"_BCL", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0, 0, 0, 0}}, /* variable (Ints) */ 172 {{"_AL5", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */
168 {.info = {"_BCM", 1, 0}}, 173 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}},
169 {.info = {"_BDN", 0, ACPI_RTYPE_INTEGER}}, 174
170 {.info = {"_BFS", 1, 0}}, 175 {{"_AL6", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */
171 {.info = {"_BIF", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 176 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}},
172 9, 177
173 ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER, 4, 0}}, /* fixed (9 Int),(4 Str) */ 178 {{"_AL7", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */
174 {.info = {"_BLT", 3, 0}}, 179 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}},
175 {.info = {"_BMC", 1, 0}}, 180
176 {.info = {"_BMD", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 5, 0, 0, 0}}, /* fixed (5 Int) */ 181 {{"_AL8", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */
177 {.info = {"_BQC", 0, ACPI_RTYPE_INTEGER}}, 182 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}},
178 {.info = {"_BST", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4, 0, 0, 0}}, /* fixed (4 Int) */ 183
179 {.info = {"_BTM", 1, ACPI_RTYPE_INTEGER}}, 184 {{"_AL9", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */
180 {.info = {"_BTP", 1, 0}}, 185 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}},
181 {.info = {"_CBA", 0, ACPI_RTYPE_INTEGER}}, /* see PCI firmware spec 3.0 */ 186
182 {.info = {"_CID", 0, 187 {{"_ALC", 0, ACPI_RTYPE_INTEGER}},
183 ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_PACKAGE}}, 188 {{"_ALI", 0, ACPI_RTYPE_INTEGER}},
184 {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING, 0, 0, 0, 0}}, /* variable (Ints/Strs) */ 189 {{"_ALP", 0, ACPI_RTYPE_INTEGER}},
185 {.info = {"_CRS", 0, ACPI_RTYPE_BUFFER}}, 190 {{"_ALR", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 2 (Ints) */
186 {.info = {"_CRT", 0, ACPI_RTYPE_INTEGER}}, 191 {{{ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 2,0}, 0,0}},
187 {.info = {"_CSD", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER, 0, 0, 0, 0}}, /* variable (1 Int(n), n-1 Int) */ 192
188 {.info = {"_CST", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2_PKG_COUNT, 193 {{"_ALT", 0, ACPI_RTYPE_INTEGER}},
189 ACPI_RTYPE_BUFFER, 1, 194 {{"_ART", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(rev), n Pkg (2 Ref/11 Int) */
190 ACPI_RTYPE_INTEGER, 3, 0}}, /* variable (1 Int(n), n Pkg (1 Buf/3 Int) */ 195 {{{ACPI_PTYPE2_REV_FIXED, ACPI_RTYPE_REFERENCE, 2, ACPI_RTYPE_INTEGER},
191 {.info = {"_DCK", 1, ACPI_RTYPE_INTEGER}}, 196 11, 0}},
192 {.info = {"_DCS", 0, ACPI_RTYPE_INTEGER}}, 197
193 {.info = {"_DDC", 1, ACPI_RTYPE_INTEGER | ACPI_RTYPE_BUFFER}}, 198 {{"_BBN", 0, ACPI_RTYPE_INTEGER}},
194 {.info = {"_DDN", 0, ACPI_RTYPE_STRING}}, 199 {{"_BCL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints) */
195 {.info = {"_DGS", 0, ACPI_RTYPE_INTEGER}}, 200 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0,0}, 0,0}},
196 {.info = {"_DIS", 0, 0}}, 201
197 {.info = {"_DMA", 0, ACPI_RTYPE_BUFFER}}, 202 {{"_BCM", 1, 0}},
198 {.info = {"_DOD", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0, 0, 0, 0}}, /* variable (Ints) */ 203 {{"_BCT", 1, ACPI_RTYPE_INTEGER}},
199 {.info = {"_DOS", 1, 0}}, 204 {{"_BDN", 0, ACPI_RTYPE_INTEGER}},
200 {.info = {"_DSM", 4, ACPI_RTYPE_ALL}}, /* Must return a type, but it can be of any type */ 205 {{"_BFS", 1, 0}},
201 {.info = {"_DSS", 1, 0}}, 206 {{"_BIF", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (9 Int),(4 Str) */
202 {.info = {"_DSW", 3, 0}}, 207 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 9, ACPI_RTYPE_STRING}, 4,0}},
203 {.info = {"_EC_", 0, ACPI_RTYPE_INTEGER}}, 208
204 {.info = {"_EDL", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */ 209 {{"_BIX", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (16 Int),(4 Str) */
205 {.info = {"_EJ0", 1, 0}}, 210 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 16, ACPI_RTYPE_STRING}, 4,
206 {.info = {"_EJ1", 1, 0}}, 211 0}},
207 {.info = {"_EJ2", 1, 0}}, 212
208 {.info = {"_EJ3", 1, 0}}, 213 {{"_BLT", 3, 0}},
209 {.info = {"_EJ4", 1, 0}}, 214 {{"_BMA", 1, ACPI_RTYPE_INTEGER}},
210 {.info = {"_EJD", 0, ACPI_RTYPE_STRING}}, 215 {{"_BMC", 1, 0}},
211 {.info = {"_FDE", 0, ACPI_RTYPE_BUFFER}}, 216 {{"_BMD", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (5 Int) */
212 {.info = {"_FDI", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 16, 0, 0, 0}}, /* fixed (16 Int) */ 217 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 5,0}, 0,0}},
213 {.info = {"_FDM", 1, 0}}, 218
214 {.info = {"_FIX", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0, 0, 0, 0}}, /* variable (Ints) */ 219 {{"_BMS", 1, ACPI_RTYPE_INTEGER}},
215 {.info = {"_GLK", 0, ACPI_RTYPE_INTEGER}}, 220 {{"_BQC", 0, ACPI_RTYPE_INTEGER}},
216 {.info = {"_GPD", 0, ACPI_RTYPE_INTEGER}}, 221 {{"_BST", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (4 Int) */
217 {.info = {"_GPE", 0, ACPI_RTYPE_INTEGER}}, /* _GPE method, not _GPE scope */ 222 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0}, 0,0}},
218 {.info = {"_GSB", 0, ACPI_RTYPE_INTEGER}}, 223
219 {.info = {"_GTF", 0, ACPI_RTYPE_BUFFER}}, 224 {{"_BTM", 1, ACPI_RTYPE_INTEGER}},
220 {.info = {"_GTM", 0, ACPI_RTYPE_BUFFER}}, 225 {{"_BTP", 1, 0}},
221 {.info = {"_GTS", 1, 0}}, 226 {{"_CBA", 0, ACPI_RTYPE_INTEGER}}, /* See PCI firmware spec 3.0 */
222 {.info = {"_HID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING}}, 227 {{"_CDM", 0, ACPI_RTYPE_INTEGER}},
223 {.info = {"_HOT", 0, ACPI_RTYPE_INTEGER}}, 228 {{"_CID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints/Strs) */
224 {.info = {"_HPP", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4, 0, 0, 0}}, /* fixed (4 Int) */ 229 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING, 0,0}, 0,0}},
230
231 {{"_CRS", 0, ACPI_RTYPE_BUFFER}},
232 {{"_CRT", 0, ACPI_RTYPE_INTEGER}},
233 {{"_CSD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(n), n-1 Int) */
234 {{{ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER, 0,0}, 0,0}},
235
236 {{"_CST", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(n), n Pkg (1 Buf/3 Int) */
237 {{{ACPI_PTYPE2_PKG_COUNT,ACPI_RTYPE_BUFFER, 1, ACPI_RTYPE_INTEGER}, 3,0}},
238
239 {{"_DCK", 1, ACPI_RTYPE_INTEGER}},
240 {{"_DCS", 0, ACPI_RTYPE_INTEGER}},
241 {{"_DDC", 1, ACPI_RTYPE_INTEGER | ACPI_RTYPE_BUFFER}},
242 {{"_DDN", 0, ACPI_RTYPE_STRING}},
243 {{"_DGS", 0, ACPI_RTYPE_INTEGER}},
244 {{"_DIS", 0, 0}},
245 {{"_DMA", 0, ACPI_RTYPE_BUFFER}},
246 {{"_DOD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints) */
247 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0,0}, 0,0}},
248
249 {{"_DOS", 1, 0}},
250 {{"_DSM", 4, ACPI_RTYPE_ALL}}, /* Must return a type, but it can be of any type */
251 {{"_DSS", 1, 0}},
252 {{"_DSW", 3, 0}},
253 {{"_DTI", 1, 0}},
254 {{"_EC_", 0, ACPI_RTYPE_INTEGER}},
255 {{"_EDL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs)*/
256 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}},
257
258 {{"_EJ0", 1, 0}},
259 {{"_EJ1", 1, 0}},
260 {{"_EJ2", 1, 0}},
261 {{"_EJ3", 1, 0}},
262 {{"_EJ4", 1, 0}},
263 {{"_EJD", 0, ACPI_RTYPE_STRING}},
264 {{"_FDE", 0, ACPI_RTYPE_BUFFER}},
265 {{"_FDI", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (16 Int) */
266 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 16,0}, 0,0}},
267
268 {{"_FDM", 1, 0}},
269 {{"_FIF", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (4 Int) */
270 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4, 0}, 0, 0}},
271
272 {{"_FIX", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints) */
273 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0,0}, 0,0}},
274
275 {{"_FPS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(rev), n Pkg (5 Int) */
276 {{{ACPI_PTYPE2_REV_FIXED, ACPI_RTYPE_INTEGER, 5, 0}, 0, 0}},
277
278 {{"_FSL", 1, 0}},
279 {{"_FST", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (3 Int) */
280 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 3, 0}, 0, 0}},
281
282 {{"_GAI", 0, ACPI_RTYPE_INTEGER}},
283 {{"_GHL", 0, ACPI_RTYPE_INTEGER}},
284 {{"_GLK", 0, ACPI_RTYPE_INTEGER}},
285 {{"_GPD", 0, ACPI_RTYPE_INTEGER}},
286 {{"_GPE", 0, ACPI_RTYPE_INTEGER}}, /* _GPE method, not _GPE scope */
287 {{"_GSB", 0, ACPI_RTYPE_INTEGER}},
288 {{"_GTF", 0, ACPI_RTYPE_BUFFER}},
289 {{"_GTM", 0, ACPI_RTYPE_BUFFER}},
290 {{"_GTS", 1, 0}},
291 {{"_HID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING}},
292 {{"_HOT", 0, ACPI_RTYPE_INTEGER}},
293 {{"_HPP", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (4 Int) */
294 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0}, 0,0}},
225 295
226 /* 296 /*
227 * For _HPX, a single package is returned, containing a variable number of sub-packages. 297 * For _HPX, a single package is returned, containing a Variable-length number
228 * Each sub-package contains a PCI record setting. There are several different type of 298 * of sub-packages. Each sub-package contains a PCI record setting.
229 * record settings, of different lengths, but all elements of all settings are Integers. 299 * There are several different type of record settings, of different
300 * lengths, but all elements of all settings are Integers.
230 */ 301 */
231 {.info = {"_HPX", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2_MIN, ACPI_RTYPE_INTEGER, 5, 0, 0, 0}}, /* variable (Pkgs) each (var Ints) */ 302 {{"_HPX", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (var Ints) */
232 {.info = {"_IFT", 0, ACPI_RTYPE_INTEGER}}, /* see IPMI spec */ 303 {{{ACPI_PTYPE2_MIN, ACPI_RTYPE_INTEGER, 5,0}, 0,0}},
233 {.info = {"_INI", 0, 0}}, 304
234 {.info = {"_IRC", 0, 0}}, 305 {{"_IFT", 0, ACPI_RTYPE_INTEGER}}, /* See IPMI spec */
235 {.info = {"_LCK", 1, 0}}, 306 {{"_INI", 0, 0}},
236 {.info = {"_LID", 0, ACPI_RTYPE_INTEGER}}, 307 {{"_IRC", 0, 0}},
237 {.info = {"_MAT", 0, ACPI_RTYPE_BUFFER}}, 308 {{"_LCK", 1, 0}},
238 {.info = {"_MLS", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2, ACPI_RTYPE_STRING, 2, 0, 0, 0}}, /* variable (Pkgs) each (2 Str) */ 309 {{"_LID", 0, ACPI_RTYPE_INTEGER}},
239 {.info = {"_MSG", 1, 0}}, 310 {{"_MAT", 0, ACPI_RTYPE_BUFFER}},
240 {.info = {"_OFF", 0, 0}}, 311 {{"_MBM", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (8 Int) */
241 {.info = {"_ON_", 0, 0}}, 312 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 8, 0}, 0, 0}},
242 {.info = {"_OS_", 0, ACPI_RTYPE_STRING}}, 313
243 {.info = {"_OSC", 4, ACPI_RTYPE_BUFFER}}, 314 {{"_MLS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (2 Str) */
244 {.info = {"_OST", 3, 0}}, 315 {{{ACPI_PTYPE2, ACPI_RTYPE_STRING, 2,0}, 0,0}},
245 {.info = {"_PCL", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */ 316
246 {.info = {"_PCT", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_BUFFER, 2, 0, 0, 0}}, /* fixed (2 Buf) */ 317 {{"_MSG", 1, 0}},
247 {.info = {"_PDC", 1, 0}}, 318 {{"_MSM", 4, ACPI_RTYPE_INTEGER}},
248 {.info = {"_PIC", 1, 0}}, 319 {{"_NTT", 0, ACPI_RTYPE_INTEGER}},
249 {.info = {"_PLD", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_BUFFER, 0, 0, 0, 0}}, /* variable (Bufs) */ 320 {{"_OFF", 0, 0}},
250 {.info = {"_PPC", 0, ACPI_RTYPE_INTEGER}}, 321 {{"_ON_", 0, 0}},
251 {.info = {"_PPE", 0, ACPI_RTYPE_INTEGER}}, /* see dig64 spec */ 322 {{"_OS_", 0, ACPI_RTYPE_STRING}},
252 {.info = {"_PR0", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */ 323 {{"_OSC", 4, ACPI_RTYPE_BUFFER}},
253 {.info = {"_PR1", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */ 324 {{"_OST", 3, 0}},
254 {.info = {"_PR2", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */ 325 {{"_PAI", 1, ACPI_RTYPE_INTEGER}},
255 {.info = {"_PRS", 0, ACPI_RTYPE_BUFFER}}, 326 {{"_PCL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */
327 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}},
328
329 {{"_PCT", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (2 Buf) */
330 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_BUFFER, 2,0}, 0,0}},
331
332 {{"_PDC", 1, 0}},
333 {{"_PDL", 0, ACPI_RTYPE_INTEGER}},
334 {{"_PIC", 1, 0}},
335 {{"_PIF", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (3 Int),(3 Str) */
336 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 3, ACPI_RTYPE_STRING}, 3, 0}},
337
338 {{"_PLD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Bufs) */
339 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_BUFFER, 0,0}, 0,0}},
340
341 {{"_PMC", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (11 Int),(3 Str) */
342 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 11, ACPI_RTYPE_STRING}, 3,
343 0}},
344
345 {{"_PMD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */
346 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0}, 0, 0}},
347
348 {{"_PMM", 0, ACPI_RTYPE_INTEGER}},
349 {{"_PPC", 0, ACPI_RTYPE_INTEGER}},
350 {{"_PPE", 0, ACPI_RTYPE_INTEGER}}, /* See dig64 spec */
351 {{"_PR0", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */
352 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}},
353
354 {{"_PR1", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */
355 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}},
356
357 {{"_PR2", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */
358 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}},
359
360 {{"_PR3", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */
361 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0}, 0, 0}},
362
363 {{"_PRL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */
364 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0}, 0, 0}},
365
366 {{"_PRS", 0, ACPI_RTYPE_BUFFER}},
256 367
257 /* 368 /*
258 * For _PRT, many BIOSs reverse the 2nd and 3rd Package elements. This bug is so prevalent that there 369 * For _PRT, many BIOSs reverse the 3rd and 4th Package elements (Source
259 * is code in the ACPICA Resource Manager to detect this and switch them back. For now, do not allow 370 * and source_index). This bug is so prevalent that there is code in the
260 * and issue a warning. To allow this and eliminate the warning, add the ACPI_RTYPE_REFERENCE 371 * ACPICA Resource Manager to detect this and switch them back. For now,
261 * type to the 2nd element (index 1) in the statement below. 372 * do not allow and issue a warning. To allow this and eliminate the
373 * warning, add the ACPI_RTYPE_REFERENCE type to the 4th element (index 3)
374 * in the statement below.
262 */ 375 */
263 {.info = {"_PRT", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2_FIXED, 4, 376 {{"_PRT", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (4): Int,Int,Int/Ref,Int */
264 ACPI_RTYPE_INTEGER, 377 {{{ACPI_PTYPE2_FIXED, 4, ACPI_RTYPE_INTEGER,ACPI_RTYPE_INTEGER},
265 ACPI_RTYPE_INTEGER, 378 ACPI_RTYPE_INTEGER | ACPI_RTYPE_REFERENCE,
266 ACPI_RTYPE_INTEGER | ACPI_RTYPE_REFERENCE, ACPI_RTYPE_INTEGER}}, /* variable (Pkgs) each (4): Int,Int,Int/Ref,Int */ 379 ACPI_RTYPE_INTEGER}},
267 380
268 {.info = {"_PRW", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_OPTION, 2, 381 {{"_PRW", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each: Pkg/Int,Int,[Variable-length Refs] (Pkg is Ref/Int) */
269 ACPI_RTYPE_INTEGER | 382 {{{ACPI_PTYPE1_OPTION, 2, ACPI_RTYPE_INTEGER | ACPI_RTYPE_PACKAGE,
270 ACPI_RTYPE_PACKAGE, 383 ACPI_RTYPE_INTEGER}, ACPI_RTYPE_REFERENCE,0}},
271 ACPI_RTYPE_INTEGER, ACPI_RTYPE_REFERENCE, 0}}, /* variable (Pkgs) each: Pkg/Int,Int,[variable Refs] (Pkg is Ref/Int) */ 384
272 385 {{"_PS0", 0, 0}},
273 {.info = {"_PS0", 0, 0}}, 386 {{"_PS1", 0, 0}},
274 {.info = {"_PS1", 0, 0}}, 387 {{"_PS2", 0, 0}},
275 {.info = {"_PS2", 0, 0}}, 388 {{"_PS3", 0, 0}},
276 {.info = {"_PS3", 0, 0}}, 389 {{"_PSC", 0, ACPI_RTYPE_INTEGER}},
277 {.info = {"_PSC", 0, ACPI_RTYPE_INTEGER}}, 390 {{"_PSD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (5 Int) with count */
278 {.info = {"_PSD", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER, 0, 0, 0, 0}}, /* variable (Pkgs) each (5 Int) with count */ 391 {{{ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER,0,0}, 0,0}},
279 {.info = {"_PSL", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */ 392
280 {.info = {"_PSR", 0, ACPI_RTYPE_INTEGER}}, 393 {{"_PSL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */
281 {.info = {"_PSS", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 6, 0, 0, 0}}, /* variable (Pkgs) each (6 Int) */ 394 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}},
282 {.info = {"_PSV", 0, ACPI_RTYPE_INTEGER}}, 395
283 {.info = {"_PSW", 1, 0}}, 396 {{"_PSR", 0, ACPI_RTYPE_INTEGER}},
284 {.info = {"_PTC", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_BUFFER, 2, 0, 0, 0}}, /* fixed (2 Buf) */ 397 {{"_PSS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (6 Int) */
285 {.info = {"_PTS", 1, 0}}, 398 {{{ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 6,0}, 0,0}},
286 {.info = {"_PXM", 0, ACPI_RTYPE_INTEGER}}, 399
287 {.info = {"_REG", 2, 0}}, 400 {{"_PSV", 0, ACPI_RTYPE_INTEGER}},
288 {.info = {"_REV", 0, ACPI_RTYPE_INTEGER}}, 401 {{"_PSW", 1, 0}},
289 {.info = {"_RMV", 0, ACPI_RTYPE_INTEGER}}, 402 {{"_PTC", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (2 Buf) */
290 {.info = {"_ROM", 2, ACPI_RTYPE_BUFFER}}, 403 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_BUFFER, 2,0}, 0,0}},
291 {.info = {"_RTV", 0, ACPI_RTYPE_INTEGER}}, 404
405 {{"_PTP", 2, ACPI_RTYPE_INTEGER}},
406 {{"_PTS", 1, 0}},
407 {{"_PUR", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (2 Int) */
408 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 2, 0}, 0, 0}},
409
410 {{"_PXM", 0, ACPI_RTYPE_INTEGER}},
411 {{"_REG", 2, 0}},
412 {{"_REV", 0, ACPI_RTYPE_INTEGER}},
413 {{"_RMV", 0, ACPI_RTYPE_INTEGER}},
414 {{"_ROM", 2, ACPI_RTYPE_BUFFER}},
415 {{"_RTV", 0, ACPI_RTYPE_INTEGER}},
292 416
293 /* 417 /*
294 * For _S0_ through _S5_, the ACPI spec defines a return Package containing 1 Integer, 418 * For _S0_ through _S5_, the ACPI spec defines a return Package
295 * but most DSDTs have it wrong - 2,3, or 4 integers. Allow this by making the objects "variable length", 419 * containing 1 Integer, but most DSDTs have it wrong - 2,3, or 4 integers.
296 * but all elements must be Integers. 420 * Allow this by making the objects "Variable-length length", but all elements
421 * must be Integers.
297 */ 422 */
298 {.info = {"_S0_", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1, 0, 0, 0}}, /* fixed (1 Int) */ 423 {{"_S0_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */
299 {.info = {"_S1_", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1, 0, 0, 0}}, /* fixed (1 Int) */ 424 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}},
300 {.info = {"_S2_", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1, 0, 0, 0}}, /* fixed (1 Int) */ 425
301 {.info = {"_S3_", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1, 0, 0, 0}}, /* fixed (1 Int) */ 426 {{"_S1_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */
302 {.info = {"_S4_", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1, 0, 0, 0}}, /* fixed (1 Int) */ 427 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}},
303 {.info = {"_S5_", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1, 0, 0, 0}}, /* fixed (1 Int) */ 428
304 429 {{"_S2_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */
305 {.info = {"_S1D", 0, ACPI_RTYPE_INTEGER}}, 430 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}},
306 {.info = {"_S2D", 0, ACPI_RTYPE_INTEGER}}, 431
307 {.info = {"_S3D", 0, ACPI_RTYPE_INTEGER}}, 432 {{"_S3_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */
308 {.info = {"_S4D", 0, ACPI_RTYPE_INTEGER}}, 433 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}},
309 {.info = {"_S0W", 0, ACPI_RTYPE_INTEGER}}, 434
310 {.info = {"_S1W", 0, ACPI_RTYPE_INTEGER}}, 435 {{"_S4_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */
311 {.info = {"_S2W", 0, ACPI_RTYPE_INTEGER}}, 436 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}},
312 {.info = {"_S3W", 0, ACPI_RTYPE_INTEGER}}, 437
313 {.info = {"_S4W", 0, ACPI_RTYPE_INTEGER}}, 438 {{"_S5_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */
314 {.info = {"_SBS", 0, ACPI_RTYPE_INTEGER}}, 439 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}},
315 {.info = {"_SCP", 0x13, 0}}, /* Acpi 1.0 allowed 1 arg. Acpi 3.0 expanded to 3 args. Allow both. */ 440
316 /* Note: the 3-arg definition may be removed for ACPI 4.0 */ 441 {{"_S1D", 0, ACPI_RTYPE_INTEGER}},
317 {.info = {"_SDD", 1, 0}}, 442 {{"_S2D", 0, ACPI_RTYPE_INTEGER}},
318 {.info = {"_SEG", 0, ACPI_RTYPE_INTEGER}}, 443 {{"_S3D", 0, ACPI_RTYPE_INTEGER}},
319 {.info = {"_SLI", 0, ACPI_RTYPE_BUFFER}}, 444 {{"_S4D", 0, ACPI_RTYPE_INTEGER}},
320 {.info = {"_SPD", 1, ACPI_RTYPE_INTEGER}}, 445 {{"_S0W", 0, ACPI_RTYPE_INTEGER}},
321 {.info = {"_SRS", 1, 0}}, 446 {{"_S1W", 0, ACPI_RTYPE_INTEGER}},
322 {.info = {"_SRV", 0, ACPI_RTYPE_INTEGER}}, /* see IPMI spec */ 447 {{"_S2W", 0, ACPI_RTYPE_INTEGER}},
323 {.info = {"_SST", 1, 0}}, 448 {{"_S3W", 0, ACPI_RTYPE_INTEGER}},
324 {.info = {"_STA", 0, ACPI_RTYPE_INTEGER}}, 449 {{"_S4W", 0, ACPI_RTYPE_INTEGER}},
325 {.info = {"_STM", 3, 0}}, 450 {{"_SBS", 0, ACPI_RTYPE_INTEGER}},
326 {.info = {"_STR", 0, ACPI_RTYPE_BUFFER}}, 451 {{"_SCP", 0x13, 0}}, /* Acpi 1.0 allowed 1 arg. Acpi 3.0 expanded to 3 args. Allow both. */
327 {.info = {"_SUN", 0, ACPI_RTYPE_INTEGER}}, 452 /* Note: the 3-arg definition may be removed for ACPI 4.0 */
328 {.info = {"_SWS", 0, ACPI_RTYPE_INTEGER}}, 453 {{"_SDD", 1, 0}},
329 {.info = {"_TC1", 0, ACPI_RTYPE_INTEGER}}, 454 {{"_SEG", 0, ACPI_RTYPE_INTEGER}},
330 {.info = {"_TC2", 0, ACPI_RTYPE_INTEGER}}, 455 {{"_SHL", 1, ACPI_RTYPE_INTEGER}},
331 {.info = {"_TMP", 0, ACPI_RTYPE_INTEGER}}, 456 {{"_SLI", 0, ACPI_RTYPE_BUFFER}},
332 {.info = {"_TPC", 0, ACPI_RTYPE_INTEGER}}, 457 {{"_SPD", 1, ACPI_RTYPE_INTEGER}},
333 {.info = {"_TPT", 1, 0}}, 458 {{"_SRS", 1, 0}},
334 {.info = {"_TRT", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2, ACPI_RTYPE_REFERENCE, 2, 459 {{"_SRV", 0, ACPI_RTYPE_INTEGER}}, /* See IPMI spec */
335 ACPI_RTYPE_INTEGER, 6, 0}}, /* variable (Pkgs) each 2_ref/6_int */ 460 {{"_SST", 1, 0}},
336 {.info = {"_TSD", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER, 5, 0, 0, 0}}, /* variable (Pkgs) each 5_int with count */ 461 {{"_STA", 0, ACPI_RTYPE_INTEGER}},
337 {.info = {"_TSP", 0, ACPI_RTYPE_INTEGER}}, 462 {{"_STM", 3, 0}},
338 {.info = {"_TSS", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 5, 0, 0, 0}}, /* variable (Pkgs) each 5_int */ 463 {{"_STP", 2, ACPI_RTYPE_INTEGER}},
339 {.info = {"_TST", 0, ACPI_RTYPE_INTEGER}}, 464 {{"_STR", 0, ACPI_RTYPE_BUFFER}},
340 {.info = {"_TTS", 1, 0}}, 465 {{"_STV", 2, ACPI_RTYPE_INTEGER}},
341 {.info = {"_TZD", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */ 466 {{"_SUN", 0, ACPI_RTYPE_INTEGER}},
342 {.info = {"_TZM", 0, ACPI_RTYPE_REFERENCE}}, 467 {{"_SWS", 0, ACPI_RTYPE_INTEGER}},
343 {.info = {"_TZP", 0, ACPI_RTYPE_INTEGER}}, 468 {{"_TC1", 0, ACPI_RTYPE_INTEGER}},
344 {.info = {"_UID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING}}, 469 {{"_TC2", 0, ACPI_RTYPE_INTEGER}},
345 {.info = {"_UPC", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4, 0, 0, 0}}, /* fixed (4 Int) */ 470 {{"_TIP", 1, ACPI_RTYPE_INTEGER}},
346 {.info = {"_UPD", 0, ACPI_RTYPE_INTEGER}}, 471 {{"_TIV", 1, ACPI_RTYPE_INTEGER}},
347 {.info = {"_UPP", 0, ACPI_RTYPE_INTEGER}}, 472 {{"_TMP", 0, ACPI_RTYPE_INTEGER}},
348 {.info = {"_VPO", 0, ACPI_RTYPE_INTEGER}}, 473 {{"_TPC", 0, ACPI_RTYPE_INTEGER}},
474 {{"_TPT", 1, 0}},
475 {{"_TRT", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 2_ref/6_int */
476 {{{ACPI_PTYPE2, ACPI_RTYPE_REFERENCE, 2, ACPI_RTYPE_INTEGER}, 6, 0}},
477
478 {{"_TSD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 5_int with count */
479 {{{ACPI_PTYPE2_COUNT,ACPI_RTYPE_INTEGER, 5,0}, 0,0}},
480
481 {{"_TSP", 0, ACPI_RTYPE_INTEGER}},
482 {{"_TSS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 5_int */
483 {{{ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 5,0}, 0,0}},
484
485 {{"_TST", 0, ACPI_RTYPE_INTEGER}},
486 {{"_TTS", 1, 0}},
487 {{"_TZD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */
488 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}},
489
490 {{"_TZM", 0, ACPI_RTYPE_REFERENCE}},
491 {{"_TZP", 0, ACPI_RTYPE_INTEGER}},
492 {{"_UID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING}},
493 {{"_UPC", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (4 Int) */
494 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0}, 0,0}},
495
496 {{"_UPD", 0, ACPI_RTYPE_INTEGER}},
497 {{"_UPP", 0, ACPI_RTYPE_INTEGER}},
498 {{"_VPO", 0, ACPI_RTYPE_INTEGER}},
349 499
350 /* Acpi 1.0 defined _WAK with no return value. Later, it was changed to return a package */ 500 /* Acpi 1.0 defined _WAK with no return value. Later, it was changed to return a package */
351 501
352 {.info = {"_WAK", 1, ACPI_RTYPE_NONE | ACPI_RTYPE_INTEGER | ACPI_RTYPE_PACKAGE}}, 502 {{"_WAK", 1, ACPI_RTYPE_NONE | ACPI_RTYPE_INTEGER | ACPI_RTYPE_PACKAGE}},
353 {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 2, 0, 0, 0}}, /* fixed (2 Int), but is optional */ 503 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 2,0}, 0,0}}, /* Fixed-length (2 Int), but is optional */
354 {.ret_info = {0, 0, 0, 0, 0, 0}} /* Table terminator */ 504
505 {{{0,0,0,0}, 0,0}} /* Table terminator */
355}; 506};
356 507
357#if 0 508#if 0
358 /* Not implemented */ 509 /* Not implemented */
359 510
360{ 511 {{"_WDG", 0, ACPI_RTYPE_BUFFER}}, /* MS Extension */
361"_WDG", 0, ACPI_RTYPE_BUFFER}, /* MS Extension */ 512 {{"_WED", 1, ACPI_RTYPE_PACKAGE}}, /* MS Extension */
362 513
363{ 514 /* This is an internally implemented control method, no need to check */
364"_WED", 1, ACPI_RTYPE_PACKAGE}, /* MS Extension */ 515 {{"_OSI", 1, ACPI_RTYPE_INTEGER}},
365 516
366 /* This is an internally implemented control method, no need to check */ 517 /* TBD: */
367{ 518
368"_OSI", 1, ACPI_RTYPE_INTEGER}, 519 _PRT - currently ignore reversed entries. attempt to fix here?
520 think about possibly fixing package elements like _BIF, etc.
521#endif
369 522
370 /* TBD: */
371 _PRT - currently ignore reversed entries.attempt to fix here ?
372 think about code that attempts to fix package elements like _BIF, etc.
373#endif 523#endif
374#endif 524#endif
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
index 897810ba0ccc..863a264b829e 100644
--- a/drivers/acpi/acpica/acutils.h
+++ b/drivers/acpi/acpica/acutils.h
@@ -324,26 +324,30 @@ acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
324acpi_status 324acpi_status
325acpi_ut_evaluate_numeric_object(char *object_name, 325acpi_ut_evaluate_numeric_object(char *object_name,
326 struct acpi_namespace_node *device_node, 326 struct acpi_namespace_node *device_node,
327 acpi_integer * address); 327 acpi_integer *value);
328 328
329acpi_status 329acpi_status
330acpi_ut_execute_HID(struct acpi_namespace_node *device_node, 330acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 *status_flags);
331 struct acpica_device_id *hid);
332 331
333acpi_status 332acpi_status
334acpi_ut_execute_CID(struct acpi_namespace_node *device_node, 333acpi_ut_execute_power_methods(struct acpi_namespace_node *device_node,
335 struct acpi_compatible_id_list **return_cid_list); 334 const char **method_names,
335 u8 method_count, u8 *out_values);
336 336
337/*
338 * utids - device ID support
339 */
337acpi_status 340acpi_status
338acpi_ut_execute_STA(struct acpi_namespace_node *device_node, 341acpi_ut_execute_HID(struct acpi_namespace_node *device_node,
339 u32 * status_flags); 342 struct acpica_device_id **return_id);
340 343
341acpi_status 344acpi_status
342acpi_ut_execute_UID(struct acpi_namespace_node *device_node, 345acpi_ut_execute_UID(struct acpi_namespace_node *device_node,
343 struct acpica_device_id *uid); 346 struct acpica_device_id **return_id);
344 347
345acpi_status 348acpi_status
346acpi_ut_execute_sxds(struct acpi_namespace_node *device_node, u8 * highest); 349acpi_ut_execute_CID(struct acpi_namespace_node *device_node,
350 struct acpica_device_id_list **return_cid_list);
347 351
348/* 352/*
349 * utlock - reader/writer locks 353 * utlock - reader/writer locks
@@ -445,6 +449,8 @@ acpi_ut_short_divide(acpi_integer in_dividend,
445 */ 449 */
446const char *acpi_ut_validate_exception(acpi_status status); 450const char *acpi_ut_validate_exception(acpi_status status);
447 451
452u8 acpi_ut_is_pci_root_bridge(char *id);
453
448u8 acpi_ut_is_aml_table(struct acpi_table_header *table); 454u8 acpi_ut_is_aml_table(struct acpi_table_header *table);
449 455
450acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id); 456acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id);
@@ -469,6 +475,12 @@ u8 acpi_ut_valid_acpi_char(char character, u32 position);
469acpi_status 475acpi_status
470acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer); 476acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer);
471 477
478void ACPI_INTERNAL_VAR_XFACE
479acpi_ut_predefined_warning(const char *module_name,
480 u32 line_number,
481 char *pathname,
482 u8 node_flags, const char *format, ...);
483
472/* Values for Base above (16=Hex, 10=Decimal) */ 484/* Values for Base above (16=Hex, 10=Decimal) */
473 485
474#define ACPI_ANY_BASE 0 486#define ACPI_ANY_BASE 0
diff --git a/drivers/acpi/acpica/amlcode.h b/drivers/acpi/acpica/amlcode.h
index 067f967eb389..4940249f2524 100644
--- a/drivers/acpi/acpica/amlcode.h
+++ b/drivers/acpi/acpica/amlcode.h
@@ -404,6 +404,7 @@ typedef enum {
404 REGION_SMBUS, 404 REGION_SMBUS,
405 REGION_CMOS, 405 REGION_CMOS,
406 REGION_PCI_BAR, 406 REGION_PCI_BAR,
407 REGION_IPMI,
407 REGION_DATA_TABLE, /* Internal use only */ 408 REGION_DATA_TABLE, /* Internal use only */
408 REGION_FIXED_HW = 0x7F 409 REGION_FIXED_HW = 0x7F
409} AML_REGION_TYPES; 410} AML_REGION_TYPES;
diff --git a/drivers/acpi/acpica/dsfield.c b/drivers/acpi/acpica/dsfield.c
index 53e27bc5a734..54a225e56a64 100644
--- a/drivers/acpi/acpica/dsfield.c
+++ b/drivers/acpi/acpica/dsfield.c
@@ -123,9 +123,12 @@ acpi_ds_create_buffer_field(union acpi_parse_object *op,
123 flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | 123 flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
124 ACPI_NS_ERROR_IF_FOUND; 124 ACPI_NS_ERROR_IF_FOUND;
125 125
126 /* Mark node temporary if we are executing a method */ 126 /*
127 127 * Mark node temporary if we are executing a normal control
128 if (walk_state->method_node) { 128 * method. (Don't mark if this is a module-level code method)
129 */
130 if (walk_state->method_node &&
131 !(walk_state->parse_flags & ACPI_PARSE_MODULE_LEVEL)) {
129 flags |= ACPI_NS_TEMPORARY; 132 flags |= ACPI_NS_TEMPORARY;
130 } 133 }
131 134
@@ -456,9 +459,12 @@ acpi_ds_init_field_objects(union acpi_parse_object *op,
456 flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | 459 flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
457 ACPI_NS_ERROR_IF_FOUND; 460 ACPI_NS_ERROR_IF_FOUND;
458 461
459 /* Mark node(s) temporary if we are executing a method */ 462 /*
460 463 * Mark node(s) temporary if we are executing a normal control
461 if (walk_state->method_node) { 464 * method. (Don't mark if this is a module-level code method)
465 */
466 if (walk_state->method_node &&
467 !(walk_state->parse_flags & ACPI_PARSE_MODULE_LEVEL)) {
462 flags |= ACPI_NS_TEMPORARY; 468 flags |= ACPI_NS_TEMPORARY;
463 } 469 }
464 470
diff --git a/drivers/acpi/acpica/dsmethod.c b/drivers/acpi/acpica/dsmethod.c
index 14b8b8ed8023..567a4899a018 100644
--- a/drivers/acpi/acpica/dsmethod.c
+++ b/drivers/acpi/acpica/dsmethod.c
@@ -578,10 +578,15 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
578 } 578 }
579 579
580 /* 580 /*
581 * Delete any namespace objects created anywhere within 581 * Delete any namespace objects created anywhere within the
582 * the namespace by the execution of this method 582 * namespace by the execution of this method. Unless this method
583 * is a module-level executable code method, in which case we
584 * want make the objects permanent.
583 */ 585 */
584 acpi_ns_delete_namespace_by_owner(method_desc->method.owner_id); 586 if (!(method_desc->method.flags & AOPOBJ_MODULE_LEVEL)) {
587 acpi_ns_delete_namespace_by_owner(method_desc->method.
588 owner_id);
589 }
585 } 590 }
586 591
587 /* Decrement the thread count on the method */ 592 /* Decrement the thread count on the method */
@@ -622,7 +627,9 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
622 627
623 /* No more threads, we can free the owner_id */ 628 /* No more threads, we can free the owner_id */
624 629
625 acpi_ut_release_owner_id(&method_desc->method.owner_id); 630 if (!(method_desc->method.flags & AOPOBJ_MODULE_LEVEL)) {
631 acpi_ut_release_owner_id(&method_desc->method.owner_id);
632 }
626 } 633 }
627 634
628 return_VOID; 635 return_VOID;
diff --git a/drivers/acpi/acpica/dsmthdat.c b/drivers/acpi/acpica/dsmthdat.c
index 22b1a3ce2c94..7d077bb2f525 100644
--- a/drivers/acpi/acpica/dsmthdat.c
+++ b/drivers/acpi/acpica/dsmthdat.c
@@ -433,10 +433,10 @@ acpi_ds_method_data_get_value(u8 type,
433 433
434 case ACPI_REFCLASS_LOCAL: 434 case ACPI_REFCLASS_LOCAL:
435 435
436 ACPI_ERROR((AE_INFO, 436 /*
437 "Uninitialized Local[%d] at node %p", 437 * No error message for this case, will be trapped again later to
438 index, node)); 438 * detect and ignore cases of Store(local_x,local_x)
439 439 */
440 return_ACPI_STATUS(AE_AML_UNINITIALIZED_LOCAL); 440 return_ACPI_STATUS(AE_AML_UNINITIALIZED_LOCAL);
441 441
442 default: 442 default:
diff --git a/drivers/acpi/acpica/dsobject.c b/drivers/acpi/acpica/dsobject.c
index 02e6caad4a76..507e1f0bbdfd 100644
--- a/drivers/acpi/acpica/dsobject.c
+++ b/drivers/acpi/acpica/dsobject.c
@@ -482,14 +482,27 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
482 if (arg) { 482 if (arg) {
483 /* 483 /*
484 * num_elements was exhausted, but there are remaining elements in the 484 * num_elements was exhausted, but there are remaining elements in the
485 * package_list. 485 * package_list. Truncate the package to num_elements.
486 * 486 *
487 * Note: technically, this is an error, from ACPI spec: "It is an error 487 * Note: technically, this is an error, from ACPI spec: "It is an error
488 * for NumElements to be less than the number of elements in the 488 * for NumElements to be less than the number of elements in the
489 * PackageList". However, for now, we just print an error message and 489 * PackageList". However, we just print an error message and
490 * no exception is returned. 490 * no exception is returned. This provides Windows compatibility. Some
491 * BIOSs will alter the num_elements on the fly, creating this type
492 * of ill-formed package object.
491 */ 493 */
492 while (arg) { 494 while (arg) {
495 /*
496 * We must delete any package elements that were created earlier
497 * and are not going to be used because of the package truncation.
498 */
499 if (arg->common.node) {
500 acpi_ut_remove_reference(ACPI_CAST_PTR
501 (union
502 acpi_operand_object,
503 arg->common.node));
504 arg->common.node = NULL;
505 }
493 506
494 /* Find out how many elements there really are */ 507 /* Find out how many elements there really are */
495 508
@@ -498,7 +511,7 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
498 } 511 }
499 512
500 ACPI_WARNING((AE_INFO, 513 ACPI_WARNING((AE_INFO,
501 "Package List length (%X) larger than NumElements count (%X), truncated\n", 514 "Package List length (0x%X) larger than NumElements count (0x%X), truncated\n",
502 i, element_count)); 515 i, element_count));
503 } else if (i < element_count) { 516 } else if (i < element_count) {
504 /* 517 /*
@@ -506,7 +519,7 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
506 * Note: this is not an error, the package is padded out with NULLs. 519 * Note: this is not an error, the package is padded out with NULLs.
507 */ 520 */
508 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 521 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
509 "Package List length (%X) smaller than NumElements count (%X), padded with null elements\n", 522 "Package List length (0x%X) smaller than NumElements count (0x%X), padded with null elements\n",
510 i, element_count)); 523 i, element_count));
511 } 524 }
512 525
diff --git a/drivers/acpi/acpica/dswload.c b/drivers/acpi/acpica/dswload.c
index 3023ceaa8d54..6de3a99d4cd4 100644
--- a/drivers/acpi/acpica/dswload.c
+++ b/drivers/acpi/acpica/dswload.c
@@ -581,21 +581,6 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
581 if ((!(walk_state->op_info->flags & AML_NSOPCODE) && 581 if ((!(walk_state->op_info->flags & AML_NSOPCODE) &&
582 (walk_state->opcode != AML_INT_NAMEPATH_OP)) || 582 (walk_state->opcode != AML_INT_NAMEPATH_OP)) ||
583 (!(walk_state->op_info->flags & AML_NAMED))) { 583 (!(walk_state->op_info->flags & AML_NAMED))) {
584#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE
585 if ((walk_state->op_info->class == AML_CLASS_EXECUTE) ||
586 (walk_state->op_info->class == AML_CLASS_CONTROL)) {
587 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
588 "Begin/EXEC: %s (fl %8.8X)\n",
589 walk_state->op_info->name,
590 walk_state->op_info->flags));
591
592 /* Executing a type1 or type2 opcode outside of a method */
593
594 status =
595 acpi_ds_exec_begin_op(walk_state, out_op);
596 return_ACPI_STATUS(status);
597 }
598#endif
599 return_ACPI_STATUS(AE_OK); 584 return_ACPI_STATUS(AE_OK);
600 } 585 }
601 586
@@ -768,7 +753,13 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
768 753
769 /* Execution mode, node cannot already exist, node is temporary */ 754 /* Execution mode, node cannot already exist, node is temporary */
770 755
771 flags |= (ACPI_NS_ERROR_IF_FOUND | ACPI_NS_TEMPORARY); 756 flags |= ACPI_NS_ERROR_IF_FOUND;
757
758 if (!
759 (walk_state->
760 parse_flags & ACPI_PARSE_MODULE_LEVEL)) {
761 flags |= ACPI_NS_TEMPORARY;
762 }
772 } 763 }
773 764
774 /* Add new entry or lookup existing entry */ 765 /* Add new entry or lookup existing entry */
@@ -851,24 +842,6 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
851 /* Check if opcode had an associated namespace object */ 842 /* Check if opcode had an associated namespace object */
852 843
853 if (!(walk_state->op_info->flags & AML_NSOBJECT)) { 844 if (!(walk_state->op_info->flags & AML_NSOBJECT)) {
854#ifndef ACPI_NO_METHOD_EXECUTION
855#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE
856 /* No namespace object. Executable opcode? */
857
858 if ((walk_state->op_info->class == AML_CLASS_EXECUTE) ||
859 (walk_state->op_info->class == AML_CLASS_CONTROL)) {
860 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
861 "End/EXEC: %s (fl %8.8X)\n",
862 walk_state->op_info->name,
863 walk_state->op_info->flags));
864
865 /* Executing a type1 or type2 opcode outside of a method */
866
867 status = acpi_ds_exec_end_op(walk_state);
868 return_ACPI_STATUS(status);
869 }
870#endif
871#endif
872 return_ACPI_STATUS(AE_OK); 845 return_ACPI_STATUS(AE_OK);
873 } 846 }
874 847
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c
index b9d8ee69ca6c..afacf4416c73 100644
--- a/drivers/acpi/acpica/evgpe.c
+++ b/drivers/acpi/acpica/evgpe.c
@@ -424,8 +424,8 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
424 /* Read the Status Register */ 424 /* Read the Status Register */
425 425
426 status = 426 status =
427 acpi_read(&status_reg, 427 acpi_hw_read(&status_reg,
428 &gpe_register_info->status_address); 428 &gpe_register_info->status_address);
429 if (ACPI_FAILURE(status)) { 429 if (ACPI_FAILURE(status)) {
430 goto unlock_and_exit; 430 goto unlock_and_exit;
431 } 431 }
@@ -433,8 +433,8 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
433 /* Read the Enable Register */ 433 /* Read the Enable Register */
434 434
435 status = 435 status =
436 acpi_read(&enable_reg, 436 acpi_hw_read(&enable_reg,
437 &gpe_register_info->enable_address); 437 &gpe_register_info->enable_address);
438 if (ACPI_FAILURE(status)) { 438 if (ACPI_FAILURE(status)) {
439 goto unlock_and_exit; 439 goto unlock_and_exit;
440 } 440 }
diff --git a/drivers/acpi/acpica/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c
index 7b3463639422..a60aaa7635f3 100644
--- a/drivers/acpi/acpica/evgpeblk.c
+++ b/drivers/acpi/acpica/evgpeblk.c
@@ -843,14 +843,14 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
843 843
844 /* Disable all GPEs within this register */ 844 /* Disable all GPEs within this register */
845 845
846 status = acpi_write(0x00, &this_register->enable_address); 846 status = acpi_hw_write(0x00, &this_register->enable_address);
847 if (ACPI_FAILURE(status)) { 847 if (ACPI_FAILURE(status)) {
848 goto error_exit; 848 goto error_exit;
849 } 849 }
850 850
851 /* Clear any pending GPE events within this register */ 851 /* Clear any pending GPE events within this register */
852 852
853 status = acpi_write(0xFF, &this_register->status_address); 853 status = acpi_hw_write(0xFF, &this_register->status_address);
854 if (ACPI_FAILURE(status)) { 854 if (ACPI_FAILURE(status)) {
855 goto error_exit; 855 goto error_exit;
856 } 856 }
diff --git a/drivers/acpi/acpica/evrgnini.c b/drivers/acpi/acpica/evrgnini.c
index 284a7becbe96..cf29c4953028 100644
--- a/drivers/acpi/acpica/evrgnini.c
+++ b/drivers/acpi/acpica/evrgnini.c
@@ -50,8 +50,6 @@
50ACPI_MODULE_NAME("evrgnini") 50ACPI_MODULE_NAME("evrgnini")
51 51
52/* Local prototypes */ 52/* Local prototypes */
53static u8 acpi_ev_match_pci_root_bridge(char *id);
54
55static u8 acpi_ev_is_pci_root_bridge(struct acpi_namespace_node *node); 53static u8 acpi_ev_is_pci_root_bridge(struct acpi_namespace_node *node);
56 54
57/******************************************************************************* 55/*******************************************************************************
@@ -332,37 +330,6 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
332 330
333/******************************************************************************* 331/*******************************************************************************
334 * 332 *
335 * FUNCTION: acpi_ev_match_pci_root_bridge
336 *
337 * PARAMETERS: Id - The HID/CID in string format
338 *
339 * RETURN: TRUE if the Id is a match for a PCI/PCI-Express Root Bridge
340 *
341 * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID.
342 *
343 ******************************************************************************/
344
345static u8 acpi_ev_match_pci_root_bridge(char *id)
346{
347
348 /*
349 * Check if this is a PCI root.
350 * ACPI 3.0+: check for a PCI Express root also.
351 */
352 if (!(ACPI_STRNCMP(id,
353 PCI_ROOT_HID_STRING,
354 sizeof(PCI_ROOT_HID_STRING))) ||
355 !(ACPI_STRNCMP(id,
356 PCI_EXPRESS_ROOT_HID_STRING,
357 sizeof(PCI_EXPRESS_ROOT_HID_STRING)))) {
358 return (TRUE);
359 }
360
361 return (FALSE);
362}
363
364/*******************************************************************************
365 *
366 * FUNCTION: acpi_ev_is_pci_root_bridge 333 * FUNCTION: acpi_ev_is_pci_root_bridge
367 * 334 *
368 * PARAMETERS: Node - Device node being examined 335 * PARAMETERS: Node - Device node being examined
@@ -377,9 +344,10 @@ static u8 acpi_ev_match_pci_root_bridge(char *id)
377static u8 acpi_ev_is_pci_root_bridge(struct acpi_namespace_node *node) 344static u8 acpi_ev_is_pci_root_bridge(struct acpi_namespace_node *node)
378{ 345{
379 acpi_status status; 346 acpi_status status;
380 struct acpica_device_id hid; 347 struct acpica_device_id *hid;
381 struct acpi_compatible_id_list *cid; 348 struct acpica_device_id_list *cid;
382 u32 i; 349 u32 i;
350 u8 match;
383 351
384 /* Get the _HID and check for a PCI Root Bridge */ 352 /* Get the _HID and check for a PCI Root Bridge */
385 353
@@ -388,7 +356,10 @@ static u8 acpi_ev_is_pci_root_bridge(struct acpi_namespace_node *node)
388 return (FALSE); 356 return (FALSE);
389 } 357 }
390 358
391 if (acpi_ev_match_pci_root_bridge(hid.value)) { 359 match = acpi_ut_is_pci_root_bridge(hid->string);
360 ACPI_FREE(hid);
361
362 if (match) {
392 return (TRUE); 363 return (TRUE);
393 } 364 }
394 365
@@ -402,7 +373,7 @@ static u8 acpi_ev_is_pci_root_bridge(struct acpi_namespace_node *node)
402 /* Check all _CIDs in the returned list */ 373 /* Check all _CIDs in the returned list */
403 374
404 for (i = 0; i < cid->count; i++) { 375 for (i = 0; i < cid->count; i++) {
405 if (acpi_ev_match_pci_root_bridge(cid->id[i].value)) { 376 if (acpi_ut_is_pci_root_bridge(cid->ids[i].string)) {
406 ACPI_FREE(cid); 377 ACPI_FREE(cid);
407 return (TRUE); 378 return (TRUE);
408 } 379 }
diff --git a/drivers/acpi/acpica/exconfig.c b/drivers/acpi/acpica/exconfig.c
index 277fd609611a..24afef81af39 100644
--- a/drivers/acpi/acpica/exconfig.c
+++ b/drivers/acpi/acpica/exconfig.c
@@ -110,8 +110,15 @@ acpi_ex_add_table(u32 table_index,
110 if (ACPI_FAILURE(status)) { 110 if (ACPI_FAILURE(status)) {
111 acpi_ut_remove_reference(obj_desc); 111 acpi_ut_remove_reference(obj_desc);
112 *ddb_handle = NULL; 112 *ddb_handle = NULL;
113 return_ACPI_STATUS(status);
113 } 114 }
114 115
116 /* Execute any module-level code that was found in the table */
117
118 acpi_ex_exit_interpreter();
119 acpi_ns_exec_module_code_list();
120 acpi_ex_enter_interpreter();
121
115 return_ACPI_STATUS(status); 122 return_ACPI_STATUS(status);
116} 123}
117 124
diff --git a/drivers/acpi/acpica/exdump.c b/drivers/acpi/acpica/exdump.c
index ec524614e708..de3446372ddc 100644
--- a/drivers/acpi/acpica/exdump.c
+++ b/drivers/acpi/acpica/exdump.c
@@ -418,9 +418,9 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc,
418 case ACPI_EXD_REFERENCE: 418 case ACPI_EXD_REFERENCE:
419 419
420 acpi_ex_out_string("Class Name", 420 acpi_ex_out_string("Class Name",
421 (char *) 421 ACPI_CAST_PTR(char,
422 acpi_ut_get_reference_name 422 acpi_ut_get_reference_name
423 (obj_desc)); 423 (obj_desc)));
424 acpi_ex_dump_reference_obj(obj_desc); 424 acpi_ex_dump_reference_obj(obj_desc);
425 break; 425 break;
426 426
diff --git a/drivers/acpi/acpica/exfield.c b/drivers/acpi/acpica/exfield.c
index 546dcdd86785..0b33d6c887b9 100644
--- a/drivers/acpi/acpica/exfield.c
+++ b/drivers/acpi/acpica/exfield.c
@@ -72,6 +72,7 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
72 union acpi_operand_object *buffer_desc; 72 union acpi_operand_object *buffer_desc;
73 acpi_size length; 73 acpi_size length;
74 void *buffer; 74 void *buffer;
75 u32 function;
75 76
76 ACPI_FUNCTION_TRACE_PTR(ex_read_data_from_field, obj_desc); 77 ACPI_FUNCTION_TRACE_PTR(ex_read_data_from_field, obj_desc);
77 78
@@ -97,13 +98,27 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
97 } 98 }
98 } else if ((obj_desc->common.type == ACPI_TYPE_LOCAL_REGION_FIELD) && 99 } else if ((obj_desc->common.type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
99 (obj_desc->field.region_obj->region.space_id == 100 (obj_desc->field.region_obj->region.space_id ==
100 ACPI_ADR_SPACE_SMBUS)) { 101 ACPI_ADR_SPACE_SMBUS
102 || obj_desc->field.region_obj->region.space_id ==
103 ACPI_ADR_SPACE_IPMI)) {
101 /* 104 /*
102 * This is an SMBus read. We must create a buffer to hold the data 105 * This is an SMBus or IPMI read. We must create a buffer to hold
103 * and directly access the region handler. 106 * the data and then directly access the region handler.
107 *
108 * Note: Smbus protocol value is passed in upper 16-bits of Function
104 */ 109 */
105 buffer_desc = 110 if (obj_desc->field.region_obj->region.space_id ==
106 acpi_ut_create_buffer_object(ACPI_SMBUS_BUFFER_SIZE); 111 ACPI_ADR_SPACE_SMBUS) {
112 length = ACPI_SMBUS_BUFFER_SIZE;
113 function =
114 ACPI_READ | (obj_desc->field.attribute << 16);
115 } else { /* IPMI */
116
117 length = ACPI_IPMI_BUFFER_SIZE;
118 function = ACPI_READ;
119 }
120
121 buffer_desc = acpi_ut_create_buffer_object(length);
107 if (!buffer_desc) { 122 if (!buffer_desc) {
108 return_ACPI_STATUS(AE_NO_MEMORY); 123 return_ACPI_STATUS(AE_NO_MEMORY);
109 } 124 }
@@ -112,16 +127,13 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
112 127
113 acpi_ex_acquire_global_lock(obj_desc->common_field.field_flags); 128 acpi_ex_acquire_global_lock(obj_desc->common_field.field_flags);
114 129
115 /* 130 /* Call the region handler for the read */
116 * Perform the read. 131
117 * Note: Smbus protocol value is passed in upper 16-bits of Function
118 */
119 status = acpi_ex_access_region(obj_desc, 0, 132 status = acpi_ex_access_region(obj_desc, 0,
120 ACPI_CAST_PTR(acpi_integer, 133 ACPI_CAST_PTR(acpi_integer,
121 buffer_desc-> 134 buffer_desc->
122 buffer.pointer), 135 buffer.pointer),
123 ACPI_READ | (obj_desc->field. 136 function);
124 attribute << 16));
125 acpi_ex_release_global_lock(obj_desc->common_field.field_flags); 137 acpi_ex_release_global_lock(obj_desc->common_field.field_flags);
126 goto exit; 138 goto exit;
127 } 139 }
@@ -212,6 +224,7 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
212 u32 length; 224 u32 length;
213 void *buffer; 225 void *buffer;
214 union acpi_operand_object *buffer_desc; 226 union acpi_operand_object *buffer_desc;
227 u32 function;
215 228
216 ACPI_FUNCTION_TRACE_PTR(ex_write_data_to_field, obj_desc); 229 ACPI_FUNCTION_TRACE_PTR(ex_write_data_to_field, obj_desc);
217 230
@@ -234,39 +247,56 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
234 } 247 }
235 } else if ((obj_desc->common.type == ACPI_TYPE_LOCAL_REGION_FIELD) && 248 } else if ((obj_desc->common.type == ACPI_TYPE_LOCAL_REGION_FIELD) &&
236 (obj_desc->field.region_obj->region.space_id == 249 (obj_desc->field.region_obj->region.space_id ==
237 ACPI_ADR_SPACE_SMBUS)) { 250 ACPI_ADR_SPACE_SMBUS
251 || obj_desc->field.region_obj->region.space_id ==
252 ACPI_ADR_SPACE_IPMI)) {
238 /* 253 /*
239 * This is an SMBus write. We will bypass the entire field mechanism 254 * This is an SMBus or IPMI write. We will bypass the entire field
240 * and handoff the buffer directly to the handler. 255 * mechanism and handoff the buffer directly to the handler. For
256 * these address spaces, the buffer is bi-directional; on a write,
257 * return data is returned in the same buffer.
258 *
259 * Source must be a buffer of sufficient size:
260 * ACPI_SMBUS_BUFFER_SIZE or ACPI_IPMI_BUFFER_SIZE.
241 * 261 *
242 * Source must be a buffer of sufficient size (ACPI_SMBUS_BUFFER_SIZE). 262 * Note: SMBus protocol type is passed in upper 16-bits of Function
243 */ 263 */
244 if (source_desc->common.type != ACPI_TYPE_BUFFER) { 264 if (source_desc->common.type != ACPI_TYPE_BUFFER) {
245 ACPI_ERROR((AE_INFO, 265 ACPI_ERROR((AE_INFO,
246 "SMBus write requires Buffer, found type %s", 266 "SMBus or IPMI write requires Buffer, found type %s",
247 acpi_ut_get_object_type_name(source_desc))); 267 acpi_ut_get_object_type_name(source_desc)));
248 268
249 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 269 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
250 } 270 }
251 271
252 if (source_desc->buffer.length < ACPI_SMBUS_BUFFER_SIZE) { 272 if (obj_desc->field.region_obj->region.space_id ==
273 ACPI_ADR_SPACE_SMBUS) {
274 length = ACPI_SMBUS_BUFFER_SIZE;
275 function =
276 ACPI_WRITE | (obj_desc->field.attribute << 16);
277 } else { /* IPMI */
278
279 length = ACPI_IPMI_BUFFER_SIZE;
280 function = ACPI_WRITE;
281 }
282
283 if (source_desc->buffer.length < length) {
253 ACPI_ERROR((AE_INFO, 284 ACPI_ERROR((AE_INFO,
254 "SMBus write requires Buffer of length %X, found length %X", 285 "SMBus or IPMI write requires Buffer of length %X, found length %X",
255 ACPI_SMBUS_BUFFER_SIZE, 286 length, source_desc->buffer.length));
256 source_desc->buffer.length));
257 287
258 return_ACPI_STATUS(AE_AML_BUFFER_LIMIT); 288 return_ACPI_STATUS(AE_AML_BUFFER_LIMIT);
259 } 289 }
260 290
261 buffer_desc = 291 /* Create the bi-directional buffer */
262 acpi_ut_create_buffer_object(ACPI_SMBUS_BUFFER_SIZE); 292
293 buffer_desc = acpi_ut_create_buffer_object(length);
263 if (!buffer_desc) { 294 if (!buffer_desc) {
264 return_ACPI_STATUS(AE_NO_MEMORY); 295 return_ACPI_STATUS(AE_NO_MEMORY);
265 } 296 }
266 297
267 buffer = buffer_desc->buffer.pointer; 298 buffer = buffer_desc->buffer.pointer;
268 ACPI_MEMCPY(buffer, source_desc->buffer.pointer, 299 ACPI_MEMCPY(buffer, source_desc->buffer.pointer, length);
269 ACPI_SMBUS_BUFFER_SIZE);
270 300
271 /* Lock entire transaction if requested */ 301 /* Lock entire transaction if requested */
272 302
@@ -275,12 +305,10 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
275 /* 305 /*
276 * Perform the write (returns status and perhaps data in the 306 * Perform the write (returns status and perhaps data in the
277 * same buffer) 307 * same buffer)
278 * Note: SMBus protocol type is passed in upper 16-bits of Function.
279 */ 308 */
280 status = acpi_ex_access_region(obj_desc, 0, 309 status = acpi_ex_access_region(obj_desc, 0,
281 (acpi_integer *) buffer, 310 (acpi_integer *) buffer,
282 ACPI_WRITE | (obj_desc->field. 311 function);
283 attribute << 16));
284 acpi_ex_release_global_lock(obj_desc->common_field.field_flags); 312 acpi_ex_release_global_lock(obj_desc->common_field.field_flags);
285 313
286 *result_desc = buffer_desc; 314 *result_desc = buffer_desc;
diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c
index 6687be167f5f..d7b3b418fb45 100644
--- a/drivers/acpi/acpica/exfldio.c
+++ b/drivers/acpi/acpica/exfldio.c
@@ -120,12 +120,13 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc,
120 } 120 }
121 121
122 /* 122 /*
123 * Exit now for SMBus address space, it has a non-linear address space 123 * Exit now for SMBus or IPMI address space, it has a non-linear address space
124 * and the request cannot be directly validated 124 * and the request cannot be directly validated
125 */ 125 */
126 if (rgn_desc->region.space_id == ACPI_ADR_SPACE_SMBUS) { 126 if (rgn_desc->region.space_id == ACPI_ADR_SPACE_SMBUS ||
127 rgn_desc->region.space_id == ACPI_ADR_SPACE_IPMI) {
127 128
128 /* SMBus has a non-linear address space */ 129 /* SMBus or IPMI has a non-linear address space */
129 130
130 return_ACPI_STATUS(AE_OK); 131 return_ACPI_STATUS(AE_OK);
131 } 132 }
diff --git a/drivers/acpi/acpica/exutils.c b/drivers/acpi/acpica/exutils.c
index 87730e944132..7d41f99f7052 100644
--- a/drivers/acpi/acpica/exutils.c
+++ b/drivers/acpi/acpica/exutils.c
@@ -358,50 +358,67 @@ static u32 acpi_ex_digits_needed(acpi_integer value, u32 base)
358 * 358 *
359 * FUNCTION: acpi_ex_eisa_id_to_string 359 * FUNCTION: acpi_ex_eisa_id_to_string
360 * 360 *
361 * PARAMETERS: numeric_id - EISA ID to be converted 361 * PARAMETERS: compressed_id - EISAID to be converted
362 * out_string - Where to put the converted string (8 bytes) 362 * out_string - Where to put the converted string (8 bytes)
363 * 363 *
364 * RETURN: None 364 * RETURN: None
365 * 365 *
366 * DESCRIPTION: Convert a numeric EISA ID to string representation 366 * DESCRIPTION: Convert a numeric EISAID to string representation. Return
367 * buffer must be large enough to hold the string. The string
368 * returned is always exactly of length ACPI_EISAID_STRING_SIZE
369 * (includes null terminator). The EISAID is always 32 bits.
367 * 370 *
368 ******************************************************************************/ 371 ******************************************************************************/
369 372
370void acpi_ex_eisa_id_to_string(u32 numeric_id, char *out_string) 373void acpi_ex_eisa_id_to_string(char *out_string, acpi_integer compressed_id)
371{ 374{
372 u32 eisa_id; 375 u32 swapped_id;
373 376
374 ACPI_FUNCTION_ENTRY(); 377 ACPI_FUNCTION_ENTRY();
375 378
379 /* The EISAID should be a 32-bit integer */
380
381 if (compressed_id > ACPI_UINT32_MAX) {
382 ACPI_WARNING((AE_INFO,
383 "Expected EISAID is larger than 32 bits: 0x%8.8X%8.8X, truncating",
384 ACPI_FORMAT_UINT64(compressed_id)));
385 }
386
376 /* Swap ID to big-endian to get contiguous bits */ 387 /* Swap ID to big-endian to get contiguous bits */
377 388
378 eisa_id = acpi_ut_dword_byte_swap(numeric_id); 389 swapped_id = acpi_ut_dword_byte_swap((u32)compressed_id);
379 390
380 out_string[0] = (char)('@' + (((unsigned long)eisa_id >> 26) & 0x1f)); 391 /* First 3 bytes are uppercase letters. Next 4 bytes are hexadecimal */
381 out_string[1] = (char)('@' + ((eisa_id >> 21) & 0x1f)); 392
382 out_string[2] = (char)('@' + ((eisa_id >> 16) & 0x1f)); 393 out_string[0] =
383 out_string[3] = acpi_ut_hex_to_ascii_char((acpi_integer) eisa_id, 12); 394 (char)(0x40 + (((unsigned long)swapped_id >> 26) & 0x1F));
384 out_string[4] = acpi_ut_hex_to_ascii_char((acpi_integer) eisa_id, 8); 395 out_string[1] = (char)(0x40 + ((swapped_id >> 21) & 0x1F));
385 out_string[5] = acpi_ut_hex_to_ascii_char((acpi_integer) eisa_id, 4); 396 out_string[2] = (char)(0x40 + ((swapped_id >> 16) & 0x1F));
386 out_string[6] = acpi_ut_hex_to_ascii_char((acpi_integer) eisa_id, 0); 397 out_string[3] = acpi_ut_hex_to_ascii_char((acpi_integer)swapped_id, 12);
398 out_string[4] = acpi_ut_hex_to_ascii_char((acpi_integer)swapped_id, 8);
399 out_string[5] = acpi_ut_hex_to_ascii_char((acpi_integer)swapped_id, 4);
400 out_string[6] = acpi_ut_hex_to_ascii_char((acpi_integer)swapped_id, 0);
387 out_string[7] = 0; 401 out_string[7] = 0;
388} 402}
389 403
390/******************************************************************************* 404/*******************************************************************************
391 * 405 *
392 * FUNCTION: acpi_ex_unsigned_integer_to_string 406 * FUNCTION: acpi_ex_integer_to_string
393 * 407 *
394 * PARAMETERS: Value - Value to be converted 408 * PARAMETERS: out_string - Where to put the converted string. At least
395 * out_string - Where to put the converted string (8 bytes) 409 * 21 bytes are needed to hold the largest
410 * possible 64-bit integer.
411 * Value - Value to be converted
396 * 412 *
397 * RETURN: None, string 413 * RETURN: None, string
398 * 414 *
399 * DESCRIPTION: Convert a number to string representation. Assumes string 415 * DESCRIPTION: Convert a 64-bit integer to decimal string representation.
400 * buffer is large enough to hold the string. 416 * Assumes string buffer is large enough to hold the string. The
417 * largest string is (ACPI_MAX64_DECIMAL_DIGITS + 1).
401 * 418 *
402 ******************************************************************************/ 419 ******************************************************************************/
403 420
404void acpi_ex_unsigned_integer_to_string(acpi_integer value, char *out_string) 421void acpi_ex_integer_to_string(char *out_string, acpi_integer value)
405{ 422{
406 u32 count; 423 u32 count;
407 u32 digits_needed; 424 u32 digits_needed;
diff --git a/drivers/acpi/acpica/hwgpe.c b/drivers/acpi/acpica/hwgpe.c
index d3b7e37c9eed..c28c41b3180b 100644
--- a/drivers/acpi/acpica/hwgpe.c
+++ b/drivers/acpi/acpica/hwgpe.c
@@ -82,7 +82,7 @@ acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info)
82 82
83 /* Get current value of the enable register that contains this GPE */ 83 /* Get current value of the enable register that contains this GPE */
84 84
85 status = acpi_read(&enable_mask, &gpe_register_info->enable_address); 85 status = acpi_hw_read(&enable_mask, &gpe_register_info->enable_address);
86 if (ACPI_FAILURE(status)) { 86 if (ACPI_FAILURE(status)) {
87 return (status); 87 return (status);
88 } 88 }
@@ -95,7 +95,7 @@ acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info)
95 95
96 /* Write the updated enable mask */ 96 /* Write the updated enable mask */
97 97
98 status = acpi_write(enable_mask, &gpe_register_info->enable_address); 98 status = acpi_hw_write(enable_mask, &gpe_register_info->enable_address);
99 return (status); 99 return (status);
100} 100}
101 101
@@ -130,8 +130,8 @@ acpi_hw_write_gpe_enable_reg(struct acpi_gpe_event_info * gpe_event_info)
130 130
131 /* Write the entire GPE (runtime) enable register */ 131 /* Write the entire GPE (runtime) enable register */
132 132
133 status = acpi_write(gpe_register_info->enable_for_run, 133 status = acpi_hw_write(gpe_register_info->enable_for_run,
134 &gpe_register_info->enable_address); 134 &gpe_register_info->enable_address);
135 135
136 return (status); 136 return (status);
137} 137}
@@ -163,8 +163,8 @@ acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info)
163 * Write a one to the appropriate bit in the status register to 163 * Write a one to the appropriate bit in the status register to
164 * clear this GPE. 164 * clear this GPE.
165 */ 165 */
166 status = acpi_write(register_bit, 166 status = acpi_hw_write(register_bit,
167 &gpe_event_info->register_info->status_address); 167 &gpe_event_info->register_info->status_address);
168 168
169 return (status); 169 return (status);
170} 170}
@@ -222,7 +222,7 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
222 222
223 /* GPE currently active (status bit == 1)? */ 223 /* GPE currently active (status bit == 1)? */
224 224
225 status = acpi_read(&in_byte, &gpe_register_info->status_address); 225 status = acpi_hw_read(&in_byte, &gpe_register_info->status_address);
226 if (ACPI_FAILURE(status)) { 226 if (ACPI_FAILURE(status)) {
227 goto unlock_and_exit; 227 goto unlock_and_exit;
228 } 228 }
@@ -266,8 +266,8 @@ acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
266 /* Disable all GPEs in this register */ 266 /* Disable all GPEs in this register */
267 267
268 status = 268 status =
269 acpi_write(0x00, 269 acpi_hw_write(0x00,
270 &gpe_block->register_info[i].enable_address); 270 &gpe_block->register_info[i].enable_address);
271 if (ACPI_FAILURE(status)) { 271 if (ACPI_FAILURE(status)) {
272 return (status); 272 return (status);
273 } 273 }
@@ -303,8 +303,8 @@ acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
303 /* Clear status on all GPEs in this register */ 303 /* Clear status on all GPEs in this register */
304 304
305 status = 305 status =
306 acpi_write(0xFF, 306 acpi_hw_write(0xFF,
307 &gpe_block->register_info[i].status_address); 307 &gpe_block->register_info[i].status_address);
308 if (ACPI_FAILURE(status)) { 308 if (ACPI_FAILURE(status)) {
309 return (status); 309 return (status);
310 } 310 }
@@ -345,9 +345,9 @@ acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
345 345
346 /* Enable all "runtime" GPEs in this register */ 346 /* Enable all "runtime" GPEs in this register */
347 347
348 status = acpi_write(gpe_block->register_info[i].enable_for_run, 348 status =
349 &gpe_block->register_info[i]. 349 acpi_hw_write(gpe_block->register_info[i].enable_for_run,
350 enable_address); 350 &gpe_block->register_info[i].enable_address);
351 if (ACPI_FAILURE(status)) { 351 if (ACPI_FAILURE(status)) {
352 return (status); 352 return (status);
353 } 353 }
@@ -387,9 +387,9 @@ acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
387 387
388 /* Enable all "wake" GPEs in this register */ 388 /* Enable all "wake" GPEs in this register */
389 389
390 status = acpi_write(gpe_block->register_info[i].enable_for_wake, 390 status =
391 &gpe_block->register_info[i]. 391 acpi_hw_write(gpe_block->register_info[i].enable_for_wake,
392 enable_address); 392 &gpe_block->register_info[i].enable_address);
393 if (ACPI_FAILURE(status)) { 393 if (ACPI_FAILURE(status)) {
394 return (status); 394 return (status);
395 } 395 }
diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c
index 23d5505cb1f7..15c9ed2be853 100644
--- a/drivers/acpi/acpica/hwregs.c
+++ b/drivers/acpi/acpica/hwregs.c
@@ -62,6 +62,184 @@ acpi_hw_write_multiple(u32 value,
62 struct acpi_generic_address *register_a, 62 struct acpi_generic_address *register_a,
63 struct acpi_generic_address *register_b); 63 struct acpi_generic_address *register_b);
64 64
65/******************************************************************************
66 *
67 * FUNCTION: acpi_hw_validate_register
68 *
69 * PARAMETERS: Reg - GAS register structure
70 * max_bit_width - Max bit_width supported (32 or 64)
71 * Address - Pointer to where the gas->address
72 * is returned
73 *
74 * RETURN: Status
75 *
76 * DESCRIPTION: Validate the contents of a GAS register. Checks the GAS
77 * pointer, Address, space_id, bit_width, and bit_offset.
78 *
79 ******************************************************************************/
80
81acpi_status
82acpi_hw_validate_register(struct acpi_generic_address *reg,
83 u8 max_bit_width, u64 *address)
84{
85
86 /* Must have a valid pointer to a GAS structure */
87
88 if (!reg) {
89 return (AE_BAD_PARAMETER);
90 }
91
92 /*
93 * Copy the target address. This handles possible alignment issues.
94 * Address must not be null. A null address also indicates an optional
95 * ACPI register that is not supported, so no error message.
96 */
97 ACPI_MOVE_64_TO_64(address, &reg->address);
98 if (!(*address)) {
99 return (AE_BAD_ADDRESS);
100 }
101
102 /* Validate the space_iD */
103
104 if ((reg->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) &&
105 (reg->space_id != ACPI_ADR_SPACE_SYSTEM_IO)) {
106 ACPI_ERROR((AE_INFO,
107 "Unsupported address space: 0x%X", reg->space_id));
108 return (AE_SUPPORT);
109 }
110
111 /* Validate the bit_width */
112
113 if ((reg->bit_width != 8) &&
114 (reg->bit_width != 16) &&
115 (reg->bit_width != 32) && (reg->bit_width != max_bit_width)) {
116 ACPI_ERROR((AE_INFO,
117 "Unsupported register bit width: 0x%X",
118 reg->bit_width));
119 return (AE_SUPPORT);
120 }
121
122 /* Validate the bit_offset. Just a warning for now. */
123
124 if (reg->bit_offset != 0) {
125 ACPI_WARNING((AE_INFO,
126 "Unsupported register bit offset: 0x%X",
127 reg->bit_offset));
128 }
129
130 return (AE_OK);
131}
132
133/******************************************************************************
134 *
135 * FUNCTION: acpi_hw_read
136 *
137 * PARAMETERS: Value - Where the value is returned
138 * Reg - GAS register structure
139 *
140 * RETURN: Status
141 *
142 * DESCRIPTION: Read from either memory or IO space. This is a 32-bit max
143 * version of acpi_read, used internally since the overhead of
144 * 64-bit values is not needed.
145 *
146 * LIMITATIONS: <These limitations also apply to acpi_hw_write>
147 * bit_width must be exactly 8, 16, or 32.
148 * space_iD must be system_memory or system_iO.
149 * bit_offset and access_width are currently ignored, as there has
150 * not been a need to implement these.
151 *
152 ******************************************************************************/
153
154acpi_status acpi_hw_read(u32 *value, struct acpi_generic_address *reg)
155{
156 u64 address;
157 acpi_status status;
158
159 ACPI_FUNCTION_NAME(hw_read);
160
161 /* Validate contents of the GAS register */
162
163 status = acpi_hw_validate_register(reg, 32, &address);
164 if (ACPI_FAILURE(status)) {
165 return (status);
166 }
167
168 /* Initialize entire 32-bit return value to zero */
169
170 *value = 0;
171
172 /*
173 * Two address spaces supported: Memory or IO. PCI_Config is
174 * not supported here because the GAS structure is insufficient
175 */
176 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
177 status = acpi_os_read_memory((acpi_physical_address)
178 address, value, reg->bit_width);
179 } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
180
181 status = acpi_hw_read_port((acpi_io_address)
182 address, value, reg->bit_width);
183 }
184
185 ACPI_DEBUG_PRINT((ACPI_DB_IO,
186 "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n",
187 *value, reg->bit_width, ACPI_FORMAT_UINT64(address),
188 acpi_ut_get_region_name(reg->space_id)));
189
190 return (status);
191}
192
193/******************************************************************************
194 *
195 * FUNCTION: acpi_hw_write
196 *
197 * PARAMETERS: Value - Value to be written
198 * Reg - GAS register structure
199 *
200 * RETURN: Status
201 *
202 * DESCRIPTION: Write to either memory or IO space. This is a 32-bit max
203 * version of acpi_write, used internally since the overhead of
204 * 64-bit values is not needed.
205 *
206 ******************************************************************************/
207
208acpi_status acpi_hw_write(u32 value, struct acpi_generic_address *reg)
209{
210 u64 address;
211 acpi_status status;
212
213 ACPI_FUNCTION_NAME(hw_write);
214
215 /* Validate contents of the GAS register */
216
217 status = acpi_hw_validate_register(reg, 32, &address);
218 if (ACPI_FAILURE(status)) {
219 return (status);
220 }
221
222 /*
223 * Two address spaces supported: Memory or IO. PCI_Config is
224 * not supported here because the GAS structure is insufficient
225 */
226 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
227 status = acpi_os_write_memory((acpi_physical_address)
228 address, value, reg->bit_width);
229 } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
230
231 status = acpi_hw_write_port((acpi_io_address)
232 address, value, reg->bit_width);
233 }
234
235 ACPI_DEBUG_PRINT((ACPI_DB_IO,
236 "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n",
237 value, reg->bit_width, ACPI_FORMAT_UINT64(address),
238 acpi_ut_get_region_name(reg->space_id)));
239
240 return (status);
241}
242
65/******************************************************************************* 243/*******************************************************************************
66 * 244 *
67 * FUNCTION: acpi_hw_clear_acpi_status 245 * FUNCTION: acpi_hw_clear_acpi_status
@@ -152,15 +330,16 @@ acpi_status acpi_hw_write_pm1_control(u32 pm1a_control, u32 pm1b_control)
152 330
153 ACPI_FUNCTION_TRACE(hw_write_pm1_control); 331 ACPI_FUNCTION_TRACE(hw_write_pm1_control);
154 332
155 status = acpi_write(pm1a_control, &acpi_gbl_FADT.xpm1a_control_block); 333 status =
334 acpi_hw_write(pm1a_control, &acpi_gbl_FADT.xpm1a_control_block);
156 if (ACPI_FAILURE(status)) { 335 if (ACPI_FAILURE(status)) {
157 return_ACPI_STATUS(status); 336 return_ACPI_STATUS(status);
158 } 337 }
159 338
160 if (acpi_gbl_FADT.xpm1b_control_block.address) { 339 if (acpi_gbl_FADT.xpm1b_control_block.address) {
161 status = 340 status =
162 acpi_write(pm1b_control, 341 acpi_hw_write(pm1b_control,
163 &acpi_gbl_FADT.xpm1b_control_block); 342 &acpi_gbl_FADT.xpm1b_control_block);
164 } 343 }
165 return_ACPI_STATUS(status); 344 return_ACPI_STATUS(status);
166} 345}
@@ -218,12 +397,13 @@ acpi_hw_register_read(u32 register_id, u32 * return_value)
218 397
219 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ 398 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
220 399
221 status = acpi_read(&value, &acpi_gbl_FADT.xpm2_control_block); 400 status =
401 acpi_hw_read(&value, &acpi_gbl_FADT.xpm2_control_block);
222 break; 402 break;
223 403
224 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ 404 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
225 405
226 status = acpi_read(&value, &acpi_gbl_FADT.xpm_timer_block); 406 status = acpi_hw_read(&value, &acpi_gbl_FADT.xpm_timer_block);
227 break; 407 break;
228 408
229 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ 409 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
@@ -340,7 +520,8 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value)
340 * as per the ACPI spec. 520 * as per the ACPI spec.
341 */ 521 */
342 status = 522 status =
343 acpi_read(&read_value, &acpi_gbl_FADT.xpm2_control_block); 523 acpi_hw_read(&read_value,
524 &acpi_gbl_FADT.xpm2_control_block);
344 if (ACPI_FAILURE(status)) { 525 if (ACPI_FAILURE(status)) {
345 goto exit; 526 goto exit;
346 } 527 }
@@ -350,12 +531,13 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value)
350 ACPI_INSERT_BITS(value, ACPI_PM2_CONTROL_PRESERVED_BITS, 531 ACPI_INSERT_BITS(value, ACPI_PM2_CONTROL_PRESERVED_BITS,
351 read_value); 532 read_value);
352 533
353 status = acpi_write(value, &acpi_gbl_FADT.xpm2_control_block); 534 status =
535 acpi_hw_write(value, &acpi_gbl_FADT.xpm2_control_block);
354 break; 536 break;
355 537
356 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ 538 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
357 539
358 status = acpi_write(value, &acpi_gbl_FADT.xpm_timer_block); 540 status = acpi_hw_write(value, &acpi_gbl_FADT.xpm_timer_block);
359 break; 541 break;
360 542
361 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ 543 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
@@ -401,7 +583,7 @@ acpi_hw_read_multiple(u32 *value,
401 583
402 /* The first register is always required */ 584 /* The first register is always required */
403 585
404 status = acpi_read(&value_a, register_a); 586 status = acpi_hw_read(&value_a, register_a);
405 if (ACPI_FAILURE(status)) { 587 if (ACPI_FAILURE(status)) {
406 return (status); 588 return (status);
407 } 589 }
@@ -409,7 +591,7 @@ acpi_hw_read_multiple(u32 *value,
409 /* Second register is optional */ 591 /* Second register is optional */
410 592
411 if (register_b->address) { 593 if (register_b->address) {
412 status = acpi_read(&value_b, register_b); 594 status = acpi_hw_read(&value_b, register_b);
413 if (ACPI_FAILURE(status)) { 595 if (ACPI_FAILURE(status)) {
414 return (status); 596 return (status);
415 } 597 }
@@ -452,7 +634,7 @@ acpi_hw_write_multiple(u32 value,
452 634
453 /* The first register is always required */ 635 /* The first register is always required */
454 636
455 status = acpi_write(value, register_a); 637 status = acpi_hw_write(value, register_a);
456 if (ACPI_FAILURE(status)) { 638 if (ACPI_FAILURE(status)) {
457 return (status); 639 return (status);
458 } 640 }
@@ -470,7 +652,7 @@ acpi_hw_write_multiple(u32 value,
470 * and writes have no side effects" 652 * and writes have no side effects"
471 */ 653 */
472 if (register_b->address) { 654 if (register_b->address) {
473 status = acpi_write(value, register_b); 655 status = acpi_hw_write(value, register_b);
474 } 656 }
475 657
476 return (status); 658 return (status);
diff --git a/drivers/acpi/acpica/hwtimer.c b/drivers/acpi/acpica/hwtimer.c
index b7f522c8f023..6b282e85d039 100644
--- a/drivers/acpi/acpica/hwtimer.c
+++ b/drivers/acpi/acpica/hwtimer.c
@@ -100,7 +100,7 @@ acpi_status acpi_get_timer(u32 * ticks)
100 } 100 }
101 101
102 status = 102 status =
103 acpi_hw_low_level_read(32, ticks, &acpi_gbl_FADT.xpm_timer_block); 103 acpi_hw_read(ticks, &acpi_gbl_FADT.xpm_timer_block);
104 104
105 return_ACPI_STATUS(status); 105 return_ACPI_STATUS(status);
106} 106}
diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c
index 9829979f2bdd..647c7b6e6756 100644
--- a/drivers/acpi/acpica/hwxface.c
+++ b/drivers/acpi/acpica/hwxface.c
@@ -78,9 +78,22 @@ acpi_status acpi_reset(void)
78 return_ACPI_STATUS(AE_NOT_EXIST); 78 return_ACPI_STATUS(AE_NOT_EXIST);
79 } 79 }
80 80
81 /* Write the reset value to the reset register */ 81 if (reset_reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
82 /*
83 * For I/O space, write directly to the OSL. This bypasses the port
84 * validation mechanism, which may block a valid write to the reset
85 * register.
86 */
87 status =
88 acpi_os_write_port((acpi_io_address) reset_reg->address,
89 acpi_gbl_FADT.reset_value,
90 reset_reg->bit_width);
91 } else {
92 /* Write the reset value to the reset register */
93
94 status = acpi_hw_write(acpi_gbl_FADT.reset_value, reset_reg);
95 }
82 96
83 status = acpi_write(acpi_gbl_FADT.reset_value, reset_reg);
84 return_ACPI_STATUS(status); 97 return_ACPI_STATUS(status);
85} 98}
86 99
@@ -97,67 +110,92 @@ ACPI_EXPORT_SYMBOL(acpi_reset)
97 * 110 *
98 * DESCRIPTION: Read from either memory or IO space. 111 * DESCRIPTION: Read from either memory or IO space.
99 * 112 *
113 * LIMITATIONS: <These limitations also apply to acpi_write>
114 * bit_width must be exactly 8, 16, 32, or 64.
115 * space_iD must be system_memory or system_iO.
116 * bit_offset and access_width are currently ignored, as there has
117 * not been a need to implement these.
118 *
100 ******************************************************************************/ 119 ******************************************************************************/
101acpi_status acpi_read(u32 *value, struct acpi_generic_address *reg) 120acpi_status acpi_read(u64 *return_value, struct acpi_generic_address *reg)
102{ 121{
122 u32 value;
103 u32 width; 123 u32 width;
104 u64 address; 124 u64 address;
105 acpi_status status; 125 acpi_status status;
106 126
107 ACPI_FUNCTION_NAME(acpi_read); 127 ACPI_FUNCTION_NAME(acpi_read);
108 128
109 /* 129 if (!return_value) {
110 * Must have a valid pointer to a GAS structure, and a non-zero address
111 * within.
112 */
113 if (!reg) {
114 return (AE_BAD_PARAMETER); 130 return (AE_BAD_PARAMETER);
115 } 131 }
116 132
117 /* Get a local copy of the address. Handles possible alignment issues */ 133 /* Validate contents of the GAS register. Allow 64-bit transfers */
118 134
119 ACPI_MOVE_64_TO_64(&address, &reg->address); 135 status = acpi_hw_validate_register(reg, 64, &address);
120 if (!address) { 136 if (ACPI_FAILURE(status)) {
121 return (AE_BAD_ADDRESS); 137 return (status);
122 } 138 }
123 139
124 /* Supported widths are 8/16/32 */
125
126 width = reg->bit_width; 140 width = reg->bit_width;
127 if ((width != 8) && (width != 16) && (width != 32)) { 141 if (width == 64) {
128 return (AE_SUPPORT); 142 width = 32; /* Break into two 32-bit transfers */
129 } 143 }
130 144
131 /* Initialize entire 32-bit return value to zero */ 145 /* Initialize entire 64-bit return value to zero */
132 146
133 *value = 0; 147 *return_value = 0;
148 value = 0;
134 149
135 /* 150 /*
136 * Two address spaces supported: Memory or IO. PCI_Config is 151 * Two address spaces supported: Memory or IO. PCI_Config is
137 * not supported here because the GAS structure is insufficient 152 * not supported here because the GAS structure is insufficient
138 */ 153 */
139 switch (reg->space_id) { 154 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
140 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 155 status = acpi_os_read_memory((acpi_physical_address)
156 address, &value, width);
157 if (ACPI_FAILURE(status)) {
158 return (status);
159 }
160 *return_value = value;
141 161
142 status = acpi_os_read_memory((acpi_physical_address) address, 162 if (reg->bit_width == 64) {
143 value, width);
144 break;
145 163
146 case ACPI_ADR_SPACE_SYSTEM_IO: 164 /* Read the top 32 bits */
147 165
148 status = 166 status = acpi_os_read_memory((acpi_physical_address)
149 acpi_hw_read_port((acpi_io_address) address, value, width); 167 (address + 4), &value, 32);
150 break; 168 if (ACPI_FAILURE(status)) {
169 return (status);
170 }
171 *return_value |= ((u64)value << 32);
172 }
173 } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
151 174
152 default: 175 status = acpi_hw_read_port((acpi_io_address)
153 ACPI_ERROR((AE_INFO, 176 address, &value, width);
154 "Unsupported address space: %X", reg->space_id)); 177 if (ACPI_FAILURE(status)) {
155 return (AE_BAD_PARAMETER); 178 return (status);
179 }
180 *return_value = value;
181
182 if (reg->bit_width == 64) {
183
184 /* Read the top 32 bits */
185
186 status = acpi_hw_read_port((acpi_io_address)
187 (address + 4), &value, 32);
188 if (ACPI_FAILURE(status)) {
189 return (status);
190 }
191 *return_value |= ((u64)value << 32);
192 }
156 } 193 }
157 194
158 ACPI_DEBUG_PRINT((ACPI_DB_IO, 195 ACPI_DEBUG_PRINT((ACPI_DB_IO,
159 "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", 196 "Read: %8.8X%8.8X width %2d from %8.8X%8.8X (%s)\n",
160 *value, width, ACPI_FORMAT_UINT64(address), 197 ACPI_FORMAT_UINT64(*return_value), reg->bit_width,
198 ACPI_FORMAT_UINT64(address),
161 acpi_ut_get_region_name(reg->space_id))); 199 acpi_ut_get_region_name(reg->space_id)));
162 200
163 return (status); 201 return (status);
@@ -169,7 +207,7 @@ ACPI_EXPORT_SYMBOL(acpi_read)
169 * 207 *
170 * FUNCTION: acpi_write 208 * FUNCTION: acpi_write
171 * 209 *
172 * PARAMETERS: Value - To be written 210 * PARAMETERS: Value - Value to be written
173 * Reg - GAS register structure 211 * Reg - GAS register structure
174 * 212 *
175 * RETURN: Status 213 * RETURN: Status
@@ -177,7 +215,7 @@ ACPI_EXPORT_SYMBOL(acpi_read)
177 * DESCRIPTION: Write to either memory or IO space. 215 * DESCRIPTION: Write to either memory or IO space.
178 * 216 *
179 ******************************************************************************/ 217 ******************************************************************************/
180acpi_status acpi_write(u32 value, struct acpi_generic_address *reg) 218acpi_status acpi_write(u64 value, struct acpi_generic_address *reg)
181{ 219{
182 u32 width; 220 u32 width;
183 u64 address; 221 u64 address;
@@ -185,54 +223,61 @@ acpi_status acpi_write(u32 value, struct acpi_generic_address *reg)
185 223
186 ACPI_FUNCTION_NAME(acpi_write); 224 ACPI_FUNCTION_NAME(acpi_write);
187 225
188 /* 226 /* Validate contents of the GAS register. Allow 64-bit transfers */
189 * Must have a valid pointer to a GAS structure, and a non-zero address
190 * within.
191 */
192 if (!reg) {
193 return (AE_BAD_PARAMETER);
194 }
195
196 /* Get a local copy of the address. Handles possible alignment issues */
197 227
198 ACPI_MOVE_64_TO_64(&address, &reg->address); 228 status = acpi_hw_validate_register(reg, 64, &address);
199 if (!address) { 229 if (ACPI_FAILURE(status)) {
200 return (AE_BAD_ADDRESS); 230 return (status);
201 } 231 }
202 232
203 /* Supported widths are 8/16/32 */
204
205 width = reg->bit_width; 233 width = reg->bit_width;
206 if ((width != 8) && (width != 16) && (width != 32)) { 234 if (width == 64) {
207 return (AE_SUPPORT); 235 width = 32; /* Break into two 32-bit transfers */
208 } 236 }
209 237
210 /* 238 /*
211 * Two address spaces supported: Memory or IO. 239 * Two address spaces supported: Memory or IO. PCI_Config is
212 * PCI_Config is not supported here because the GAS struct is insufficient 240 * not supported here because the GAS structure is insufficient
213 */ 241 */
214 switch (reg->space_id) { 242 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
215 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 243 status = acpi_os_write_memory((acpi_physical_address)
216 244 address, ACPI_LODWORD(value),
217 status = acpi_os_write_memory((acpi_physical_address) address, 245 width);
218 value, width); 246 if (ACPI_FAILURE(status)) {
219 break; 247 return (status);
248 }
220 249
221 case ACPI_ADR_SPACE_SYSTEM_IO: 250 if (reg->bit_width == 64) {
251 status = acpi_os_write_memory((acpi_physical_address)
252 (address + 4),
253 ACPI_HIDWORD(value), 32);
254 if (ACPI_FAILURE(status)) {
255 return (status);
256 }
257 }
258 } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
222 259
223 status = acpi_hw_write_port((acpi_io_address) address, value, 260 status = acpi_hw_write_port((acpi_io_address)
261 address, ACPI_LODWORD(value),
224 width); 262 width);
225 break; 263 if (ACPI_FAILURE(status)) {
264 return (status);
265 }
226 266
227 default: 267 if (reg->bit_width == 64) {
228 ACPI_ERROR((AE_INFO, 268 status = acpi_hw_write_port((acpi_io_address)
229 "Unsupported address space: %X", reg->space_id)); 269 (address + 4),
230 return (AE_BAD_PARAMETER); 270 ACPI_HIDWORD(value), 32);
271 if (ACPI_FAILURE(status)) {
272 return (status);
273 }
274 }
231 } 275 }
232 276
233 ACPI_DEBUG_PRINT((ACPI_DB_IO, 277 ACPI_DEBUG_PRINT((ACPI_DB_IO,
234 "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", 278 "Wrote: %8.8X%8.8X width %2d to %8.8X%8.8X (%s)\n",
235 value, width, ACPI_FORMAT_UINT64(address), 279 ACPI_FORMAT_UINT64(value), reg->bit_width,
280 ACPI_FORMAT_UINT64(address),
236 acpi_ut_get_region_name(reg->space_id))); 281 acpi_ut_get_region_name(reg->space_id)));
237 282
238 return (status); 283 return (status);
diff --git a/drivers/acpi/acpica/nsalloc.c b/drivers/acpi/acpica/nsalloc.c
index efc971ab7d65..8a58a1b85aa0 100644
--- a/drivers/acpi/acpica/nsalloc.c
+++ b/drivers/acpi/acpica/nsalloc.c
@@ -96,17 +96,68 @@ struct acpi_namespace_node *acpi_ns_create_node(u32 name)
96 * 96 *
97 * RETURN: None 97 * RETURN: None
98 * 98 *
99 * DESCRIPTION: Delete a namespace node 99 * DESCRIPTION: Delete a namespace node. All node deletions must come through
100 * here. Detaches any attached objects, including any attached
101 * data. If a handler is associated with attached data, it is
102 * invoked before the node is deleted.
100 * 103 *
101 ******************************************************************************/ 104 ******************************************************************************/
102 105
103void acpi_ns_delete_node(struct acpi_namespace_node *node) 106void acpi_ns_delete_node(struct acpi_namespace_node *node)
104{ 107{
108 union acpi_operand_object *obj_desc;
109
110 ACPI_FUNCTION_NAME(ns_delete_node);
111
112 /* Detach an object if there is one */
113
114 acpi_ns_detach_object(node);
115
116 /*
117 * Delete an attached data object if present (an object that was created
118 * and attached via acpi_attach_data). Note: After any normal object is
119 * detached above, the only possible remaining object is a data object.
120 */
121 obj_desc = node->object;
122 if (obj_desc && (obj_desc->common.type == ACPI_TYPE_LOCAL_DATA)) {
123
124 /* Invoke the attached data deletion handler if present */
125
126 if (obj_desc->data.handler) {
127 obj_desc->data.handler(node, obj_desc->data.pointer);
128 }
129
130 acpi_ut_remove_reference(obj_desc);
131 }
132
133 /* Now we can delete the node */
134
135 (void)acpi_os_release_object(acpi_gbl_namespace_cache, node);
136
137 ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++);
138 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Node %p, Remaining %X\n",
139 node, acpi_gbl_current_node_count));
140}
141
142/*******************************************************************************
143 *
144 * FUNCTION: acpi_ns_remove_node
145 *
146 * PARAMETERS: Node - Node to be removed/deleted
147 *
148 * RETURN: None
149 *
150 * DESCRIPTION: Remove (unlink) and delete a namespace node
151 *
152 ******************************************************************************/
153
154void acpi_ns_remove_node(struct acpi_namespace_node *node)
155{
105 struct acpi_namespace_node *parent_node; 156 struct acpi_namespace_node *parent_node;
106 struct acpi_namespace_node *prev_node; 157 struct acpi_namespace_node *prev_node;
107 struct acpi_namespace_node *next_node; 158 struct acpi_namespace_node *next_node;
108 159
109 ACPI_FUNCTION_TRACE_PTR(ns_delete_node, node); 160 ACPI_FUNCTION_TRACE_PTR(ns_remove_node, node);
110 161
111 parent_node = acpi_ns_get_parent_node(node); 162 parent_node = acpi_ns_get_parent_node(node);
112 163
@@ -142,12 +193,9 @@ void acpi_ns_delete_node(struct acpi_namespace_node *node)
142 } 193 }
143 } 194 }
144 195
145 ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++); 196 /* Delete the node and any attached objects */
146
147 /* Detach an object if there is one, then delete the node */
148 197
149 acpi_ns_detach_object(node); 198 acpi_ns_delete_node(node);
150 (void)acpi_os_release_object(acpi_gbl_namespace_cache, node);
151 return_VOID; 199 return_VOID;
152} 200}
153 201
@@ -273,25 +321,11 @@ void acpi_ns_delete_children(struct acpi_namespace_node *parent_node)
273 parent_node, child_node)); 321 parent_node, child_node));
274 } 322 }
275 323
276 /* Now we can free this child object */ 324 /*
277 325 * Delete this child node and move on to the next child in the list.
278 ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++); 326 * No need to unlink the node since we are deleting the entire branch.
279 327 */
280 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, 328 acpi_ns_delete_node(child_node);
281 "Object %p, Remaining %X\n", child_node,
282 acpi_gbl_current_node_count));
283
284 /* Detach an object if there is one, then free the child node */
285
286 acpi_ns_detach_object(child_node);
287
288 /* Now we can delete the node */
289
290 (void)acpi_os_release_object(acpi_gbl_namespace_cache,
291 child_node);
292
293 /* And move on to the next child in the list */
294
295 child_node = next_node; 329 child_node = next_node;
296 330
297 } while (!(flags & ANOBJ_END_OF_PEER_LIST)); 331 } while (!(flags & ANOBJ_END_OF_PEER_LIST));
@@ -433,7 +467,7 @@ void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id)
433 467
434 if (deletion_node) { 468 if (deletion_node) {
435 acpi_ns_delete_children(deletion_node); 469 acpi_ns_delete_children(deletion_node);
436 acpi_ns_delete_node(deletion_node); 470 acpi_ns_remove_node(deletion_node);
437 deletion_node = NULL; 471 deletion_node = NULL;
438 } 472 }
439 473
diff --git a/drivers/acpi/acpica/nsdumpdv.c b/drivers/acpi/acpica/nsdumpdv.c
index 41994fe7fbb8..0fe87f1aef16 100644
--- a/drivers/acpi/acpica/nsdumpdv.c
+++ b/drivers/acpi/acpica/nsdumpdv.c
@@ -70,7 +70,6 @@ static acpi_status
70acpi_ns_dump_one_device(acpi_handle obj_handle, 70acpi_ns_dump_one_device(acpi_handle obj_handle,
71 u32 level, void *context, void **return_value) 71 u32 level, void *context, void **return_value)
72{ 72{
73 struct acpi_buffer buffer;
74 struct acpi_device_info *info; 73 struct acpi_device_info *info;
75 acpi_status status; 74 acpi_status status;
76 u32 i; 75 u32 i;
@@ -80,17 +79,15 @@ acpi_ns_dump_one_device(acpi_handle obj_handle,
80 status = 79 status =
81 acpi_ns_dump_one_object(obj_handle, level, context, return_value); 80 acpi_ns_dump_one_object(obj_handle, level, context, return_value);
82 81
83 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; 82 status = acpi_get_object_info(obj_handle, &info);
84 status = acpi_get_object_info(obj_handle, &buffer);
85 if (ACPI_SUCCESS(status)) { 83 if (ACPI_SUCCESS(status)) {
86 info = buffer.pointer;
87 for (i = 0; i < level; i++) { 84 for (i = 0; i < level; i++) {
88 ACPI_DEBUG_PRINT_RAW((ACPI_DB_TABLES, " ")); 85 ACPI_DEBUG_PRINT_RAW((ACPI_DB_TABLES, " "));
89 } 86 }
90 87
91 ACPI_DEBUG_PRINT_RAW((ACPI_DB_TABLES, 88 ACPI_DEBUG_PRINT_RAW((ACPI_DB_TABLES,
92 " HID: %s, ADR: %8.8X%8.8X, Status: %X\n", 89 " HID: %s, ADR: %8.8X%8.8X, Status: %X\n",
93 info->hardware_id.value, 90 info->hardware_id.string,
94 ACPI_FORMAT_UINT64(info->address), 91 ACPI_FORMAT_UINT64(info->address),
95 info->current_status)); 92 info->current_status));
96 ACPI_FREE(info); 93 ACPI_FREE(info);
diff --git a/drivers/acpi/acpica/nseval.c b/drivers/acpi/acpica/nseval.c
index 8e7dec1176c9..846d1132feb1 100644
--- a/drivers/acpi/acpica/nseval.c
+++ b/drivers/acpi/acpica/nseval.c
@@ -50,6 +50,11 @@
50#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
51ACPI_MODULE_NAME("nseval") 51ACPI_MODULE_NAME("nseval")
52 52
53/* Local prototypes */
54static void
55acpi_ns_exec_module_code(union acpi_operand_object *method_obj,
56 struct acpi_evaluate_info *info);
57
53/******************************************************************************* 58/*******************************************************************************
54 * 59 *
55 * FUNCTION: acpi_ns_evaluate 60 * FUNCTION: acpi_ns_evaluate
@@ -76,6 +81,7 @@ ACPI_MODULE_NAME("nseval")
76 * MUTEX: Locks interpreter 81 * MUTEX: Locks interpreter
77 * 82 *
78 ******************************************************************************/ 83 ******************************************************************************/
84
79acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info) 85acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
80{ 86{
81 acpi_status status; 87 acpi_status status;
@@ -276,3 +282,134 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
276 */ 282 */
277 return_ACPI_STATUS(status); 283 return_ACPI_STATUS(status);
278} 284}
285
286/*******************************************************************************
287 *
288 * FUNCTION: acpi_ns_exec_module_code_list
289 *
290 * PARAMETERS: None
291 *
292 * RETURN: None. Exceptions during method execution are ignored, since
293 * we cannot abort a table load.
294 *
295 * DESCRIPTION: Execute all elements of the global module-level code list.
296 * Each element is executed as a single control method.
297 *
298 ******************************************************************************/
299
300void acpi_ns_exec_module_code_list(void)
301{
302 union acpi_operand_object *prev;
303 union acpi_operand_object *next;
304 struct acpi_evaluate_info *info;
305 u32 method_count = 0;
306
307 ACPI_FUNCTION_TRACE(ns_exec_module_code_list);
308
309 /* Exit now if the list is empty */
310
311 next = acpi_gbl_module_code_list;
312 if (!next) {
313 return_VOID;
314 }
315
316 /* Allocate the evaluation information block */
317
318 info = ACPI_ALLOCATE(sizeof(struct acpi_evaluate_info));
319 if (!info) {
320 return_VOID;
321 }
322
323 /* Walk the list, executing each "method" */
324
325 while (next) {
326 prev = next;
327 next = next->method.mutex;
328
329 /* Clear the link field and execute the method */
330
331 prev->method.mutex = NULL;
332 acpi_ns_exec_module_code(prev, info);
333 method_count++;
334
335 /* Delete the (temporary) method object */
336
337 acpi_ut_remove_reference(prev);
338 }
339
340 ACPI_INFO((AE_INFO,
341 "Executed %u blocks of module-level executable AML code",
342 method_count));
343
344 ACPI_FREE(info);
345 acpi_gbl_module_code_list = NULL;
346 return_VOID;
347}
348
349/*******************************************************************************
350 *
351 * FUNCTION: acpi_ns_exec_module_code
352 *
353 * PARAMETERS: method_obj - Object container for the module-level code
354 * Info - Info block for method evaluation
355 *
356 * RETURN: None. Exceptions during method execution are ignored, since
357 * we cannot abort a table load.
358 *
359 * DESCRIPTION: Execute a control method containing a block of module-level
360 * executable AML code. The control method is temporarily
361 * installed to the root node, then evaluated.
362 *
363 ******************************************************************************/
364
365static void
366acpi_ns_exec_module_code(union acpi_operand_object *method_obj,
367 struct acpi_evaluate_info *info)
368{
369 union acpi_operand_object *root_obj;
370 acpi_status status;
371
372 ACPI_FUNCTION_TRACE(ns_exec_module_code);
373
374 /* Initialize the evaluation information block */
375
376 ACPI_MEMSET(info, 0, sizeof(struct acpi_evaluate_info));
377 info->prefix_node = acpi_gbl_root_node;
378
379 /*
380 * Get the currently attached root object. Add a reference, because the
381 * ref count will be decreased when the method object is installed to
382 * the root node.
383 */
384 root_obj = acpi_ns_get_attached_object(acpi_gbl_root_node);
385 acpi_ut_add_reference(root_obj);
386
387 /* Install the method (module-level code) in the root node */
388
389 status = acpi_ns_attach_object(acpi_gbl_root_node, method_obj,
390 ACPI_TYPE_METHOD);
391 if (ACPI_FAILURE(status)) {
392 goto exit;
393 }
394
395 /* Execute the root node as a control method */
396
397 status = acpi_ns_evaluate(info);
398
399 ACPI_DEBUG_PRINT((ACPI_DB_INIT, "Executed module-level code at %p\n",
400 method_obj->method.aml_start));
401
402 /* Detach the temporary method object */
403
404 acpi_ns_detach_object(acpi_gbl_root_node);
405
406 /* Restore the original root object */
407
408 status =
409 acpi_ns_attach_object(acpi_gbl_root_node, root_obj,
410 ACPI_TYPE_DEVICE);
411
412 exit:
413 acpi_ut_remove_reference(root_obj);
414 return_VOID;
415}
diff --git a/drivers/acpi/acpica/nsinit.c b/drivers/acpi/acpica/nsinit.c
index 2adfcf329e15..1d5b360eb25b 100644
--- a/drivers/acpi/acpica/nsinit.c
+++ b/drivers/acpi/acpica/nsinit.c
@@ -170,6 +170,21 @@ acpi_status acpi_ns_initialize_devices(void)
170 goto error_exit; 170 goto error_exit;
171 } 171 }
172 172
173 /*
174 * Execute the "global" _INI method that may appear at the root. This
175 * support is provided for Windows compatibility (Vista+) and is not
176 * part of the ACPI specification.
177 */
178 info.evaluate_info->prefix_node = acpi_gbl_root_node;
179 info.evaluate_info->pathname = METHOD_NAME__INI;
180 info.evaluate_info->parameters = NULL;
181 info.evaluate_info->flags = ACPI_IGNORE_RETURN_VALUE;
182
183 status = acpi_ns_evaluate(info.evaluate_info);
184 if (ACPI_SUCCESS(status)) {
185 info.num_INI++;
186 }
187
173 /* Walk namespace to execute all _INIs on present devices */ 188 /* Walk namespace to execute all _INIs on present devices */
174 189
175 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 190 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
diff --git a/drivers/acpi/acpica/nsload.c b/drivers/acpi/acpica/nsload.c
index dcd7a6adbbbc..a7234e60e985 100644
--- a/drivers/acpi/acpica/nsload.c
+++ b/drivers/acpi/acpica/nsload.c
@@ -270,8 +270,7 @@ static acpi_status acpi_ns_delete_subtree(acpi_handle start_handle)
270 270
271 /* Now delete the starting object, and we are done */ 271 /* Now delete the starting object, and we are done */
272 272
273 acpi_ns_delete_node(child_handle); 273 acpi_ns_remove_node(child_handle);
274
275 return_ACPI_STATUS(AE_OK); 274 return_ACPI_STATUS(AE_OK);
276} 275}
277 276
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c
index 7f8e066b12a3..f8427afeebdf 100644
--- a/drivers/acpi/acpica/nspredef.c
+++ b/drivers/acpi/acpica/nspredef.c
@@ -42,6 +42,8 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45#define ACPI_CREATE_PREDEFINED_TABLE
46
45#include <acpi/acpi.h> 47#include <acpi/acpi.h>
46#include "accommon.h" 48#include "accommon.h"
47#include "acnamesp.h" 49#include "acnamesp.h"
@@ -72,30 +74,31 @@ ACPI_MODULE_NAME("nspredef")
72 ******************************************************************************/ 74 ******************************************************************************/
73/* Local prototypes */ 75/* Local prototypes */
74static acpi_status 76static acpi_status
75acpi_ns_check_package(char *pathname, 77acpi_ns_check_package(struct acpi_predefined_data *data,
76 union acpi_operand_object **return_object_ptr, 78 union acpi_operand_object **return_object_ptr);
77 const union acpi_predefined_info *predefined); 79
80static acpi_status
81acpi_ns_check_package_list(struct acpi_predefined_data *data,
82 const union acpi_predefined_info *package,
83 union acpi_operand_object **elements, u32 count);
78 84
79static acpi_status 85static acpi_status
80acpi_ns_check_package_elements(char *pathname, 86acpi_ns_check_package_elements(struct acpi_predefined_data *data,
81 union acpi_operand_object **elements, 87 union acpi_operand_object **elements,
82 u8 type1, 88 u8 type1,
83 u32 count1, 89 u32 count1,
84 u8 type2, u32 count2, u32 start_index); 90 u8 type2, u32 count2, u32 start_index);
85 91
86static acpi_status 92static acpi_status
87acpi_ns_check_object_type(char *pathname, 93acpi_ns_check_object_type(struct acpi_predefined_data *data,
88 union acpi_operand_object **return_object_ptr, 94 union acpi_operand_object **return_object_ptr,
89 u32 expected_btypes, u32 package_index); 95 u32 expected_btypes, u32 package_index);
90 96
91static acpi_status 97static acpi_status
92acpi_ns_check_reference(char *pathname, 98acpi_ns_check_reference(struct acpi_predefined_data *data,
93 union acpi_operand_object *return_object); 99 union acpi_operand_object *return_object);
94 100
95static acpi_status 101static void acpi_ns_get_expected_types(char *buffer, u32 expected_btypes);
96acpi_ns_repair_object(u32 expected_btypes,
97 u32 package_index,
98 union acpi_operand_object **return_object_ptr);
99 102
100/* 103/*
101 * Names for the types that can be returned by the predefined objects. 104 * Names for the types that can be returned by the predefined objects.
@@ -109,13 +112,13 @@ static const char *acpi_rtype_names[] = {
109 "/Reference", 112 "/Reference",
110}; 113};
111 114
112#define ACPI_NOT_PACKAGE ACPI_UINT32_MAX
113
114/******************************************************************************* 115/*******************************************************************************
115 * 116 *
116 * FUNCTION: acpi_ns_check_predefined_names 117 * FUNCTION: acpi_ns_check_predefined_names
117 * 118 *
118 * PARAMETERS: Node - Namespace node for the method/object 119 * PARAMETERS: Node - Namespace node for the method/object
120 * user_param_count - Number of parameters actually passed
121 * return_status - Status from the object evaluation
119 * return_object_ptr - Pointer to the object returned from the 122 * return_object_ptr - Pointer to the object returned from the
120 * evaluation of a method or object 123 * evaluation of a method or object
121 * 124 *
@@ -135,12 +138,13 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
135 acpi_status status = AE_OK; 138 acpi_status status = AE_OK;
136 const union acpi_predefined_info *predefined; 139 const union acpi_predefined_info *predefined;
137 char *pathname; 140 char *pathname;
141 struct acpi_predefined_data *data;
138 142
139 /* Match the name for this method/object against the predefined list */ 143 /* Match the name for this method/object against the predefined list */
140 144
141 predefined = acpi_ns_check_for_predefined_name(node); 145 predefined = acpi_ns_check_for_predefined_name(node);
142 146
143 /* Get the full pathname to the object, for use in error messages */ 147 /* Get the full pathname to the object, for use in warning messages */
144 148
145 pathname = acpi_ns_get_external_pathname(node); 149 pathname = acpi_ns_get_external_pathname(node);
146 if (!pathname) { 150 if (!pathname) {
@@ -158,28 +162,17 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
158 /* If not a predefined name, we cannot validate the return object */ 162 /* If not a predefined name, we cannot validate the return object */
159 163
160 if (!predefined) { 164 if (!predefined) {
161 goto exit; 165 goto cleanup;
162 }
163
164 /* If the method failed, we cannot validate the return object */
165
166 if ((return_status != AE_OK) && (return_status != AE_CTRL_RETURN_VALUE)) {
167 goto exit;
168 } 166 }
169 167
170 /* 168 /*
171 * Only validate the return value on the first successful evaluation of 169 * If the method failed or did not actually return an object, we cannot
172 * the method. This ensures that any warnings will only be emitted during 170 * validate the return object
173 * the very first evaluation of the method/object.
174 */ 171 */
175 if (node->flags & ANOBJ_EVALUATED) { 172 if ((return_status != AE_OK) && (return_status != AE_CTRL_RETURN_VALUE)) {
176 goto exit; 173 goto cleanup;
177 } 174 }
178 175
179 /* Mark the node as having been successfully evaluated */
180
181 node->flags |= ANOBJ_EVALUATED;
182
183 /* 176 /*
184 * If there is no return value, check if we require a return value for 177 * If there is no return value, check if we require a return value for
185 * this predefined name. Either one return value is expected, or none, 178 * this predefined name. Either one return value is expected, or none,
@@ -190,46 +183,67 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
190 if (!return_object) { 183 if (!return_object) {
191 if ((predefined->info.expected_btypes) && 184 if ((predefined->info.expected_btypes) &&
192 (!(predefined->info.expected_btypes & ACPI_RTYPE_NONE))) { 185 (!(predefined->info.expected_btypes & ACPI_RTYPE_NONE))) {
193 ACPI_ERROR((AE_INFO, 186 ACPI_WARN_PREDEFINED((AE_INFO, pathname,
194 "%s: Missing expected return value", 187 ACPI_WARN_ALWAYS,
195 pathname)); 188 "Missing expected return value"));
196 189
197 status = AE_AML_NO_RETURN_VALUE; 190 status = AE_AML_NO_RETURN_VALUE;
198 } 191 }
199 goto exit; 192 goto cleanup;
200 } 193 }
201 194
202 /* 195 /*
203 * We have a return value, but if one wasn't expected, just exit, this is 196 * 1) We have a return value, but if one wasn't expected, just exit, this is
204 * not a problem 197 * not a problem. For example, if the "Implicit Return" feature is
198 * enabled, methods will always return a value.
205 * 199 *
206 * For example, if the "Implicit Return" feature is enabled, methods will 200 * 2) If the return value can be of any type, then we cannot perform any
207 * always return a value 201 * validation, exit.
208 */ 202 */
209 if (!predefined->info.expected_btypes) { 203 if ((!predefined->info.expected_btypes) ||
210 goto exit; 204 (predefined->info.expected_btypes == ACPI_RTYPE_ALL)) {
205 goto cleanup;
211 } 206 }
212 207
208 /* Create the parameter data block for object validation */
209
210 data = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_predefined_data));
211 if (!data) {
212 goto cleanup;
213 }
214 data->predefined = predefined;
215 data->node_flags = node->flags;
216 data->pathname = pathname;
217
213 /* 218 /*
214 * Check that the type of the return object is what is expected for 219 * Check that the type of the return object is what is expected for
215 * this predefined name 220 * this predefined name
216 */ 221 */
217 status = acpi_ns_check_object_type(pathname, return_object_ptr, 222 status = acpi_ns_check_object_type(data, return_object_ptr,
218 predefined->info.expected_btypes, 223 predefined->info.expected_btypes,
219 ACPI_NOT_PACKAGE); 224 ACPI_NOT_PACKAGE_ELEMENT);
220 if (ACPI_FAILURE(status)) { 225 if (ACPI_FAILURE(status)) {
221 goto exit; 226 goto check_validation_status;
222 } 227 }
223 228
224 /* For returned Package objects, check the type of all sub-objects */ 229 /* For returned Package objects, check the type of all sub-objects */
225 230
226 if (return_object->common.type == ACPI_TYPE_PACKAGE) { 231 if (return_object->common.type == ACPI_TYPE_PACKAGE) {
227 status = 232 status = acpi_ns_check_package(data, return_object_ptr);
228 acpi_ns_check_package(pathname, return_object_ptr, 233 }
229 predefined); 234
235check_validation_status:
236 /*
237 * If the object validation failed or if we successfully repaired one
238 * or more objects, mark the parent node to suppress further warning
239 * messages during the next evaluation of the same method/object.
240 */
241 if (ACPI_FAILURE(status) || (data->flags & ACPI_OBJECT_REPAIRED)) {
242 node->flags |= ANOBJ_EVALUATED;
230 } 243 }
244 ACPI_FREE(data);
231 245
232 exit: 246cleanup:
233 ACPI_FREE(pathname); 247 ACPI_FREE(pathname);
234 return (status); 248 return (status);
235} 249}
@@ -268,64 +282,58 @@ acpi_ns_check_parameter_count(char *pathname,
268 param_count = node->object->method.param_count; 282 param_count = node->object->method.param_count;
269 } 283 }
270 284
271 /* Argument count check for non-predefined methods/objects */
272
273 if (!predefined) { 285 if (!predefined) {
274 /* 286 /*
287 * Check the parameter count for non-predefined methods/objects.
288 *
275 * Warning if too few or too many arguments have been passed by the 289 * Warning if too few or too many arguments have been passed by the
276 * caller. An incorrect number of arguments may not cause the method 290 * caller. An incorrect number of arguments may not cause the method
277 * to fail. However, the method will fail if there are too few 291 * to fail. However, the method will fail if there are too few
278 * arguments and the method attempts to use one of the missing ones. 292 * arguments and the method attempts to use one of the missing ones.
279 */ 293 */
280 if (user_param_count < param_count) { 294 if (user_param_count < param_count) {
281 ACPI_WARNING((AE_INFO, 295 ACPI_WARN_PREDEFINED((AE_INFO, pathname,
282 "%s: Insufficient arguments - needs %d, found %d", 296 ACPI_WARN_ALWAYS,
283 pathname, param_count, user_param_count)); 297 "Insufficient arguments - needs %u, found %u",
298 param_count, user_param_count));
284 } else if (user_param_count > param_count) { 299 } else if (user_param_count > param_count) {
285 ACPI_WARNING((AE_INFO, 300 ACPI_WARN_PREDEFINED((AE_INFO, pathname,
286 "%s: Excess arguments - needs %d, found %d", 301 ACPI_WARN_ALWAYS,
287 pathname, param_count, user_param_count)); 302 "Excess arguments - needs %u, found %u",
303 param_count, user_param_count));
288 } 304 }
289 return; 305 return;
290 } 306 }
291 307
292 /* Allow two different legal argument counts (_SCP, etc.) */ 308 /*
293 309 * Validate the user-supplied parameter count.
310 * Allow two different legal argument counts (_SCP, etc.)
311 */
294 required_params_current = predefined->info.param_count & 0x0F; 312 required_params_current = predefined->info.param_count & 0x0F;
295 required_params_old = predefined->info.param_count >> 4; 313 required_params_old = predefined->info.param_count >> 4;
296 314
297 if (user_param_count != ACPI_UINT32_MAX) { 315 if (user_param_count != ACPI_UINT32_MAX) {
298
299 /* Validate the user-supplied parameter count */
300
301 if ((user_param_count != required_params_current) && 316 if ((user_param_count != required_params_current) &&
302 (user_param_count != required_params_old)) { 317 (user_param_count != required_params_old)) {
303 ACPI_WARNING((AE_INFO, 318 ACPI_WARN_PREDEFINED((AE_INFO, pathname,
304 "%s: Parameter count mismatch - " 319 ACPI_WARN_ALWAYS,
305 "caller passed %d, ACPI requires %d", 320 "Parameter count mismatch - "
306 pathname, user_param_count, 321 "caller passed %u, ACPI requires %u",
307 required_params_current)); 322 user_param_count,
323 required_params_current));
308 } 324 }
309 } 325 }
310 326
311 /* 327 /*
312 * Only validate the argument count on the first successful evaluation of
313 * the method. This ensures that any warnings will only be emitted during
314 * the very first evaluation of the method/object.
315 */
316 if (node->flags & ANOBJ_EVALUATED) {
317 return;
318 }
319
320 /*
321 * Check that the ASL-defined parameter count is what is expected for 328 * Check that the ASL-defined parameter count is what is expected for
322 * this predefined name. 329 * this predefined name (parameter count as defined by the ACPI
330 * specification)
323 */ 331 */
324 if ((param_count != required_params_current) && 332 if ((param_count != required_params_current) &&
325 (param_count != required_params_old)) { 333 (param_count != required_params_old)) {
326 ACPI_WARNING((AE_INFO, 334 ACPI_WARN_PREDEFINED((AE_INFO, pathname, node->flags,
327 "%s: Parameter count mismatch - ASL declared %d, ACPI requires %d", 335 "Parameter count mismatch - ASL declared %u, ACPI requires %u",
328 pathname, param_count, required_params_current)); 336 param_count, required_params_current));
329 } 337 }
330} 338}
331 339
@@ -358,9 +366,6 @@ const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct
358 this_name = predefined_names; 366 this_name = predefined_names;
359 while (this_name->info.name[0]) { 367 while (this_name->info.name[0]) {
360 if (ACPI_COMPARE_NAME(node->name.ascii, this_name->info.name)) { 368 if (ACPI_COMPARE_NAME(node->name.ascii, this_name->info.name)) {
361
362 /* Return pointer to this table entry */
363
364 return (this_name); 369 return (this_name);
365 } 370 }
366 371
@@ -375,17 +380,16 @@ const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct
375 this_name++; 380 this_name++;
376 } 381 }
377 382
378 return (NULL); 383 return (NULL); /* Not found */
379} 384}
380 385
381/******************************************************************************* 386/*******************************************************************************
382 * 387 *
383 * FUNCTION: acpi_ns_check_package 388 * FUNCTION: acpi_ns_check_package
384 * 389 *
385 * PARAMETERS: Pathname - Full pathname to the node (for error msgs) 390 * PARAMETERS: Data - Pointer to validation data structure
386 * return_object_ptr - Pointer to the object returned from the 391 * return_object_ptr - Pointer to the object returned from the
387 * evaluation of a method or object 392 * evaluation of a method or object
388 * Predefined - Pointer to entry in predefined name table
389 * 393 *
390 * RETURN: Status 394 * RETURN: Status
391 * 395 *
@@ -395,30 +399,26 @@ const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct
395 ******************************************************************************/ 399 ******************************************************************************/
396 400
397static acpi_status 401static acpi_status
398acpi_ns_check_package(char *pathname, 402acpi_ns_check_package(struct acpi_predefined_data *data,
399 union acpi_operand_object **return_object_ptr, 403 union acpi_operand_object **return_object_ptr)
400 const union acpi_predefined_info *predefined)
401{ 404{
402 union acpi_operand_object *return_object = *return_object_ptr; 405 union acpi_operand_object *return_object = *return_object_ptr;
403 const union acpi_predefined_info *package; 406 const union acpi_predefined_info *package;
404 union acpi_operand_object *sub_package;
405 union acpi_operand_object **elements; 407 union acpi_operand_object **elements;
406 union acpi_operand_object **sub_elements; 408 acpi_status status = AE_OK;
407 acpi_status status;
408 u32 expected_count; 409 u32 expected_count;
409 u32 count; 410 u32 count;
410 u32 i; 411 u32 i;
411 u32 j;
412 412
413 ACPI_FUNCTION_NAME(ns_check_package); 413 ACPI_FUNCTION_NAME(ns_check_package);
414 414
415 /* The package info for this name is in the next table entry */ 415 /* The package info for this name is in the next table entry */
416 416
417 package = predefined + 1; 417 package = data->predefined + 1;
418 418
419 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 419 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
420 "%s Validating return Package of Type %X, Count %X\n", 420 "%s Validating return Package of Type %X, Count %X\n",
421 pathname, package->ret_info.type, 421 data->pathname, package->ret_info.type,
422 return_object->package.count)); 422 return_object->package.count));
423 423
424 /* Extract package count and elements array */ 424 /* Extract package count and elements array */
@@ -429,9 +429,8 @@ acpi_ns_check_package(char *pathname,
429 /* The package must have at least one element, else invalid */ 429 /* The package must have at least one element, else invalid */
430 430
431 if (!count) { 431 if (!count) {
432 ACPI_WARNING((AE_INFO, 432 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
433 "%s: Return Package has no elements (empty)", 433 "Return Package has no elements (empty)"));
434 pathname));
435 434
436 return (AE_AML_OPERAND_VALUE); 435 return (AE_AML_OPERAND_VALUE);
437 } 436 }
@@ -456,15 +455,16 @@ acpi_ns_check_package(char *pathname,
456 if (count < expected_count) { 455 if (count < expected_count) {
457 goto package_too_small; 456 goto package_too_small;
458 } else if (count > expected_count) { 457 } else if (count > expected_count) {
459 ACPI_WARNING((AE_INFO, 458 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname,
460 "%s: Return Package is larger than needed - " 459 data->node_flags,
461 "found %u, expected %u", pathname, count, 460 "Return Package is larger than needed - "
462 expected_count)); 461 "found %u, expected %u", count,
462 expected_count));
463 } 463 }
464 464
465 /* Validate all elements of the returned package */ 465 /* Validate all elements of the returned package */
466 466
467 status = acpi_ns_check_package_elements(pathname, elements, 467 status = acpi_ns_check_package_elements(data, elements,
468 package->ret_info. 468 package->ret_info.
469 object_type1, 469 object_type1,
470 package->ret_info. 470 package->ret_info.
@@ -473,9 +473,6 @@ acpi_ns_check_package(char *pathname,
473 object_type2, 473 object_type2,
474 package->ret_info. 474 package->ret_info.
475 count2, 0); 475 count2, 0);
476 if (ACPI_FAILURE(status)) {
477 return (status);
478 }
479 break; 476 break;
480 477
481 case ACPI_PTYPE1_VAR: 478 case ACPI_PTYPE1_VAR:
@@ -485,7 +482,7 @@ acpi_ns_check_package(char *pathname,
485 * elements must be of the same type 482 * elements must be of the same type
486 */ 483 */
487 for (i = 0; i < count; i++) { 484 for (i = 0; i < count; i++) {
488 status = acpi_ns_check_object_type(pathname, elements, 485 status = acpi_ns_check_object_type(data, elements,
489 package->ret_info. 486 package->ret_info.
490 object_type1, i); 487 object_type1, i);
491 if (ACPI_FAILURE(status)) { 488 if (ACPI_FAILURE(status)) {
@@ -517,8 +514,7 @@ acpi_ns_check_package(char *pathname,
517 /* These are the required package elements (0, 1, or 2) */ 514 /* These are the required package elements (0, 1, or 2) */
518 515
519 status = 516 status =
520 acpi_ns_check_object_type(pathname, 517 acpi_ns_check_object_type(data, elements,
521 elements,
522 package-> 518 package->
523 ret_info3. 519 ret_info3.
524 object_type[i], 520 object_type[i],
@@ -530,8 +526,7 @@ acpi_ns_check_package(char *pathname,
530 /* These are the optional package elements */ 526 /* These are the optional package elements */
531 527
532 status = 528 status =
533 acpi_ns_check_object_type(pathname, 529 acpi_ns_check_object_type(data, elements,
534 elements,
535 package-> 530 package->
536 ret_info3. 531 ret_info3.
537 tail_object_type, 532 tail_object_type,
@@ -544,11 +539,30 @@ acpi_ns_check_package(char *pathname,
544 } 539 }
545 break; 540 break;
546 541
542 case ACPI_PTYPE2_REV_FIXED:
543
544 /* First element is the (Integer) revision */
545
546 status = acpi_ns_check_object_type(data, elements,
547 ACPI_RTYPE_INTEGER, 0);
548 if (ACPI_FAILURE(status)) {
549 return (status);
550 }
551
552 elements++;
553 count--;
554
555 /* Examine the sub-packages */
556
557 status =
558 acpi_ns_check_package_list(data, package, elements, count);
559 break;
560
547 case ACPI_PTYPE2_PKG_COUNT: 561 case ACPI_PTYPE2_PKG_COUNT:
548 562
549 /* First element is the (Integer) count of sub-packages to follow */ 563 /* First element is the (Integer) count of sub-packages to follow */
550 564
551 status = acpi_ns_check_object_type(pathname, elements, 565 status = acpi_ns_check_object_type(data, elements,
552 ACPI_RTYPE_INTEGER, 0); 566 ACPI_RTYPE_INTEGER, 0);
553 if (ACPI_FAILURE(status)) { 567 if (ACPI_FAILURE(status)) {
554 return (status); 568 return (status);
@@ -566,9 +580,11 @@ acpi_ns_check_package(char *pathname,
566 count = expected_count; 580 count = expected_count;
567 elements++; 581 elements++;
568 582
569 /* Now we can walk the sub-packages */ 583 /* Examine the sub-packages */
570 584
571 /*lint -fallthrough */ 585 status =
586 acpi_ns_check_package_list(data, package, elements, count);
587 break;
572 588
573 case ACPI_PTYPE2: 589 case ACPI_PTYPE2:
574 case ACPI_PTYPE2_FIXED: 590 case ACPI_PTYPE2_FIXED:
@@ -576,176 +592,240 @@ acpi_ns_check_package(char *pathname,
576 case ACPI_PTYPE2_COUNT: 592 case ACPI_PTYPE2_COUNT:
577 593
578 /* 594 /*
579 * These types all return a single package that consists of a variable 595 * These types all return a single Package that consists of a
580 * number of sub-packages 596 * variable number of sub-Packages.
597 *
598 * First, ensure that the first element is a sub-Package. If not,
599 * the BIOS may have incorrectly returned the object as a single
600 * package instead of a Package of Packages (a common error if
601 * there is only one entry). We may be able to repair this by
602 * wrapping the returned Package with a new outer Package.
581 */ 603 */
582 for (i = 0; i < count; i++) { 604 if ((*elements)->common.type != ACPI_TYPE_PACKAGE) {
583 sub_package = *elements;
584 sub_elements = sub_package->package.elements;
585 605
586 /* Each sub-object must be of type Package */ 606 /* Create the new outer package and populate it */
587 607
588 status = 608 status =
589 acpi_ns_check_object_type(pathname, &sub_package, 609 acpi_ns_repair_package_list(data,
590 ACPI_RTYPE_PACKAGE, i); 610 return_object_ptr);
591 if (ACPI_FAILURE(status)) { 611 if (ACPI_FAILURE(status)) {
592 return (status); 612 return (status);
593 } 613 }
594 614
595 /* Examine the different types of sub-packages */ 615 /* Update locals to point to the new package (of 1 element) */
596 616
597 switch (package->ret_info.type) { 617 return_object = *return_object_ptr;
598 case ACPI_PTYPE2: 618 elements = return_object->package.elements;
599 case ACPI_PTYPE2_PKG_COUNT: 619 count = 1;
620 }
600 621
601 /* Each subpackage has a fixed number of elements */ 622 /* Examine the sub-packages */
602 623
603 expected_count = 624 status =
604 package->ret_info.count1 + 625 acpi_ns_check_package_list(data, package, elements, count);
605 package->ret_info.count2; 626 break;
606 if (sub_package->package.count !=
607 expected_count) {
608 count = sub_package->package.count;
609 goto package_too_small;
610 }
611 627
612 status = 628 default:
613 acpi_ns_check_package_elements(pathname,
614 sub_elements,
615 package->
616 ret_info.
617 object_type1,
618 package->
619 ret_info.
620 count1,
621 package->
622 ret_info.
623 object_type2,
624 package->
625 ret_info.
626 count2, 0);
627 if (ACPI_FAILURE(status)) {
628 return (status);
629 }
630 break;
631 629
632 case ACPI_PTYPE2_FIXED: 630 /* Should not get here if predefined info table is correct */
633 631
634 /* Each sub-package has a fixed length */ 632 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
633 "Invalid internal return type in table entry: %X",
634 package->ret_info.type));
635 635
636 expected_count = package->ret_info2.count; 636 return (AE_AML_INTERNAL);
637 if (sub_package->package.count < expected_count) { 637 }
638 count = sub_package->package.count;
639 goto package_too_small;
640 }
641 638
642 /* Check the type of each sub-package element */ 639 return (status);
643 640
644 for (j = 0; j < expected_count; j++) { 641package_too_small:
645 status =
646 acpi_ns_check_object_type(pathname,
647 &sub_elements[j],
648 package->ret_info2.object_type[j], j);
649 if (ACPI_FAILURE(status)) {
650 return (status);
651 }
652 }
653 break;
654 642
655 case ACPI_PTYPE2_MIN: 643 /* Error exit for the case with an incorrect package count */
656 644
657 /* Each sub-package has a variable but minimum length */ 645 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
646 "Return Package is too small - found %u elements, expected %u",
647 count, expected_count));
658 648
659 expected_count = package->ret_info.count1; 649 return (AE_AML_OPERAND_VALUE);
660 if (sub_package->package.count < expected_count) { 650}
661 count = sub_package->package.count;
662 goto package_too_small;
663 }
664 651
665 /* Check the type of each sub-package element */ 652/*******************************************************************************
653 *
654 * FUNCTION: acpi_ns_check_package_list
655 *
656 * PARAMETERS: Data - Pointer to validation data structure
657 * Package - Pointer to package-specific info for method
658 * Elements - Element list of parent package. All elements
659 * of this list should be of type Package.
660 * Count - Count of subpackages
661 *
662 * RETURN: Status
663 *
664 * DESCRIPTION: Examine a list of subpackages
665 *
666 ******************************************************************************/
666 667
667 status = 668static acpi_status
668 acpi_ns_check_package_elements(pathname, 669acpi_ns_check_package_list(struct acpi_predefined_data *data,
669 sub_elements, 670 const union acpi_predefined_info *package,
670 package-> 671 union acpi_operand_object **elements, u32 count)
671 ret_info. 672{
672 object_type1, 673 union acpi_operand_object *sub_package;
673 sub_package-> 674 union acpi_operand_object **sub_elements;
674 package. 675 acpi_status status;
675 count, 0, 0, 676 u32 expected_count;
676 0); 677 u32 i;
677 if (ACPI_FAILURE(status)) { 678 u32 j;
678 return (status);
679 }
680 break;
681 679
682 case ACPI_PTYPE2_COUNT: 680 /* Validate each sub-Package in the parent Package */
683 681
684 /* First element is the (Integer) count of elements to follow */ 682 for (i = 0; i < count; i++) {
683 sub_package = *elements;
684 sub_elements = sub_package->package.elements;
685 685
686 status = 686 /* Each sub-object must be of type Package */
687 acpi_ns_check_object_type(pathname,
688 sub_elements,
689 ACPI_RTYPE_INTEGER,
690 0);
691 if (ACPI_FAILURE(status)) {
692 return (status);
693 }
694 687
695 /* Make sure package is large enough for the Count */ 688 status = acpi_ns_check_object_type(data, &sub_package,
689 ACPI_RTYPE_PACKAGE, i);
690 if (ACPI_FAILURE(status)) {
691 return (status);
692 }
696 693
697 expected_count = 694 /* Examine the different types of expected sub-packages */
698 (u32) (*sub_elements)->integer.value; 695
699 if (sub_package->package.count < expected_count) { 696 switch (package->ret_info.type) {
700 count = sub_package->package.count; 697 case ACPI_PTYPE2:
701 goto package_too_small; 698 case ACPI_PTYPE2_PKG_COUNT:
702 } 699 case ACPI_PTYPE2_REV_FIXED:
700
701 /* Each subpackage has a fixed number of elements */
702
703 expected_count =
704 package->ret_info.count1 + package->ret_info.count2;
705 if (sub_package->package.count < expected_count) {
706 goto package_too_small;
707 }
708
709 status =
710 acpi_ns_check_package_elements(data, sub_elements,
711 package->ret_info.
712 object_type1,
713 package->ret_info.
714 count1,
715 package->ret_info.
716 object_type2,
717 package->ret_info.
718 count2, 0);
719 if (ACPI_FAILURE(status)) {
720 return (status);
721 }
722 break;
703 723
704 /* Check the type of each sub-package element */ 724 case ACPI_PTYPE2_FIXED:
705 725
726 /* Each sub-package has a fixed length */
727
728 expected_count = package->ret_info2.count;
729 if (sub_package->package.count < expected_count) {
730 goto package_too_small;
731 }
732
733 /* Check the type of each sub-package element */
734
735 for (j = 0; j < expected_count; j++) {
706 status = 736 status =
707 acpi_ns_check_package_elements(pathname, 737 acpi_ns_check_object_type(data,
708 (sub_elements 738 &sub_elements[j],
709 + 1), 739 package->
710 package-> 740 ret_info2.
711 ret_info. 741 object_type[j],
712 object_type1, 742 j);
713 (expected_count
714 - 1), 0, 0,
715 1);
716 if (ACPI_FAILURE(status)) { 743 if (ACPI_FAILURE(status)) {
717 return (status); 744 return (status);
718 } 745 }
719 break; 746 }
747 break;
748
749 case ACPI_PTYPE2_MIN:
720 750
721 default: 751 /* Each sub-package has a variable but minimum length */
722 break; 752
753 expected_count = package->ret_info.count1;
754 if (sub_package->package.count < expected_count) {
755 goto package_too_small;
723 } 756 }
724 757
725 elements++; 758 /* Check the type of each sub-package element */
726 }
727 break;
728 759
729 default: 760 status =
761 acpi_ns_check_package_elements(data, sub_elements,
762 package->ret_info.
763 object_type1,
764 sub_package->package.
765 count, 0, 0, 0);
766 if (ACPI_FAILURE(status)) {
767 return (status);
768 }
769 break;
730 770
731 /* Should not get here if predefined info table is correct */ 771 case ACPI_PTYPE2_COUNT:
772
773 /*
774 * First element is the (Integer) count of elements, including
775 * the count field.
776 */
777 status = acpi_ns_check_object_type(data, sub_elements,
778 ACPI_RTYPE_INTEGER,
779 0);
780 if (ACPI_FAILURE(status)) {
781 return (status);
782 }
732 783
733 ACPI_WARNING((AE_INFO, 784 /*
734 "%s: Invalid internal return type in table entry: %X", 785 * Make sure package is large enough for the Count and is
735 pathname, package->ret_info.type)); 786 * is as large as the minimum size
787 */
788 expected_count = (u32)(*sub_elements)->integer.value;
789 if (sub_package->package.count < expected_count) {
790 goto package_too_small;
791 }
792 if (sub_package->package.count <
793 package->ret_info.count1) {
794 expected_count = package->ret_info.count1;
795 goto package_too_small;
796 }
736 797
737 return (AE_AML_INTERNAL); 798 /* Check the type of each sub-package element */
799
800 status =
801 acpi_ns_check_package_elements(data,
802 (sub_elements + 1),
803 package->ret_info.
804 object_type1,
805 (expected_count - 1),
806 0, 0, 1);
807 if (ACPI_FAILURE(status)) {
808 return (status);
809 }
810 break;
811
812 default: /* Should not get here, type was validated by caller */
813
814 return (AE_AML_INTERNAL);
815 }
816
817 elements++;
738 } 818 }
739 819
740 return (AE_OK); 820 return (AE_OK);
741 821
742 package_too_small: 822package_too_small:
743 823
744 /* Error exit for the case with an incorrect package count */ 824 /* The sub-package count was smaller than required */
745 825
746 ACPI_WARNING((AE_INFO, "%s: Return Package is too small - " 826 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
747 "found %u, expected %u", pathname, count, 827 "Return Sub-Package[%u] is too small - found %u elements, expected %u",
748 expected_count)); 828 i, sub_package->package.count, expected_count));
749 829
750 return (AE_AML_OPERAND_VALUE); 830 return (AE_AML_OPERAND_VALUE);
751} 831}
@@ -754,7 +834,7 @@ acpi_ns_check_package(char *pathname,
754 * 834 *
755 * FUNCTION: acpi_ns_check_package_elements 835 * FUNCTION: acpi_ns_check_package_elements
756 * 836 *
757 * PARAMETERS: Pathname - Full pathname to the node (for error msgs) 837 * PARAMETERS: Data - Pointer to validation data structure
758 * Elements - Pointer to the package elements array 838 * Elements - Pointer to the package elements array
759 * Type1 - Object type for first group 839 * Type1 - Object type for first group
760 * Count1 - Count for first group 840 * Count1 - Count for first group
@@ -770,7 +850,7 @@ acpi_ns_check_package(char *pathname,
770 ******************************************************************************/ 850 ******************************************************************************/
771 851
772static acpi_status 852static acpi_status
773acpi_ns_check_package_elements(char *pathname, 853acpi_ns_check_package_elements(struct acpi_predefined_data *data,
774 union acpi_operand_object **elements, 854 union acpi_operand_object **elements,
775 u8 type1, 855 u8 type1,
776 u32 count1, 856 u32 count1,
@@ -786,7 +866,7 @@ acpi_ns_check_package_elements(char *pathname,
786 * The second group can have a count of zero. 866 * The second group can have a count of zero.
787 */ 867 */
788 for (i = 0; i < count1; i++) { 868 for (i = 0; i < count1; i++) {
789 status = acpi_ns_check_object_type(pathname, this_element, 869 status = acpi_ns_check_object_type(data, this_element,
790 type1, i + start_index); 870 type1, i + start_index);
791 if (ACPI_FAILURE(status)) { 871 if (ACPI_FAILURE(status)) {
792 return (status); 872 return (status);
@@ -795,7 +875,7 @@ acpi_ns_check_package_elements(char *pathname,
795 } 875 }
796 876
797 for (i = 0; i < count2; i++) { 877 for (i = 0; i < count2; i++) {
798 status = acpi_ns_check_object_type(pathname, this_element, 878 status = acpi_ns_check_object_type(data, this_element,
799 type2, 879 type2,
800 (i + count1 + start_index)); 880 (i + count1 + start_index));
801 if (ACPI_FAILURE(status)) { 881 if (ACPI_FAILURE(status)) {
@@ -811,12 +891,13 @@ acpi_ns_check_package_elements(char *pathname,
811 * 891 *
812 * FUNCTION: acpi_ns_check_object_type 892 * FUNCTION: acpi_ns_check_object_type
813 * 893 *
814 * PARAMETERS: Pathname - Full pathname to the node (for error msgs) 894 * PARAMETERS: Data - Pointer to validation data structure
815 * return_object_ptr - Pointer to the object returned from the 895 * return_object_ptr - Pointer to the object returned from the
816 * evaluation of a method or object 896 * evaluation of a method or object
817 * expected_btypes - Bitmap of expected return type(s) 897 * expected_btypes - Bitmap of expected return type(s)
818 * package_index - Index of object within parent package (if 898 * package_index - Index of object within parent package (if
819 * applicable - ACPI_NOT_PACKAGE otherwise) 899 * applicable - ACPI_NOT_PACKAGE_ELEMENT
900 * otherwise)
820 * 901 *
821 * RETURN: Status 902 * RETURN: Status
822 * 903 *
@@ -826,7 +907,7 @@ acpi_ns_check_package_elements(char *pathname,
826 ******************************************************************************/ 907 ******************************************************************************/
827 908
828static acpi_status 909static acpi_status
829acpi_ns_check_object_type(char *pathname, 910acpi_ns_check_object_type(struct acpi_predefined_data *data,
830 union acpi_operand_object **return_object_ptr, 911 union acpi_operand_object **return_object_ptr,
831 u32 expected_btypes, u32 package_index) 912 u32 expected_btypes, u32 package_index)
832{ 913{
@@ -834,9 +915,6 @@ acpi_ns_check_object_type(char *pathname,
834 acpi_status status = AE_OK; 915 acpi_status status = AE_OK;
835 u32 return_btype; 916 u32 return_btype;
836 char type_buffer[48]; /* Room for 5 types */ 917 char type_buffer[48]; /* Room for 5 types */
837 u32 this_rtype;
838 u32 i;
839 u32 j;
840 918
841 /* 919 /*
842 * If we get a NULL return_object here, it is a NULL package element, 920 * If we get a NULL return_object here, it is a NULL package element,
@@ -849,10 +927,11 @@ acpi_ns_check_object_type(char *pathname,
849 /* A Namespace node should not get here, but make sure */ 927 /* A Namespace node should not get here, but make sure */
850 928
851 if (ACPI_GET_DESCRIPTOR_TYPE(return_object) == ACPI_DESC_TYPE_NAMED) { 929 if (ACPI_GET_DESCRIPTOR_TYPE(return_object) == ACPI_DESC_TYPE_NAMED) {
852 ACPI_WARNING((AE_INFO, 930 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
853 "%s: Invalid return type - Found a Namespace node [%4.4s] type %s", 931 "Invalid return type - Found a Namespace node [%4.4s] type %s",
854 pathname, return_object->node.name.ascii, 932 return_object->node.name.ascii,
855 acpi_ut_get_type_name(return_object->node.type))); 933 acpi_ut_get_type_name(return_object->node.
934 type)));
856 return (AE_AML_OPERAND_TYPE); 935 return (AE_AML_OPERAND_TYPE);
857 } 936 }
858 937
@@ -897,10 +976,11 @@ acpi_ns_check_object_type(char *pathname,
897 976
898 /* Type mismatch -- attempt repair of the returned object */ 977 /* Type mismatch -- attempt repair of the returned object */
899 978
900 status = acpi_ns_repair_object(expected_btypes, package_index, 979 status = acpi_ns_repair_object(data, expected_btypes,
980 package_index,
901 return_object_ptr); 981 return_object_ptr);
902 if (ACPI_SUCCESS(status)) { 982 if (ACPI_SUCCESS(status)) {
903 return (status); 983 return (AE_OK); /* Repair was successful */
904 } 984 }
905 goto type_error_exit; 985 goto type_error_exit;
906 } 986 }
@@ -908,7 +988,7 @@ acpi_ns_check_object_type(char *pathname,
908 /* For reference objects, check that the reference type is correct */ 988 /* For reference objects, check that the reference type is correct */
909 989
910 if (return_object->common.type == ACPI_TYPE_LOCAL_REFERENCE) { 990 if (return_object->common.type == ACPI_TYPE_LOCAL_REFERENCE) {
911 status = acpi_ns_check_reference(pathname, return_object); 991 status = acpi_ns_check_reference(data, return_object);
912 } 992 }
913 993
914 return (status); 994 return (status);
@@ -917,33 +997,19 @@ acpi_ns_check_object_type(char *pathname,
917 997
918 /* Create a string with all expected types for this predefined object */ 998 /* Create a string with all expected types for this predefined object */
919 999
920 j = 1; 1000 acpi_ns_get_expected_types(type_buffer, expected_btypes);
921 type_buffer[0] = 0;
922 this_rtype = ACPI_RTYPE_INTEGER;
923
924 for (i = 0; i < ACPI_NUM_RTYPES; i++) {
925
926 /* If one of the expected types, concatenate the name of this type */
927
928 if (expected_btypes & this_rtype) {
929 ACPI_STRCAT(type_buffer, &acpi_rtype_names[i][j]);
930 j = 0; /* Use name separator from now on */
931 }
932 this_rtype <<= 1; /* Next Rtype */
933 }
934 1001
935 if (package_index == ACPI_NOT_PACKAGE) { 1002 if (package_index == ACPI_NOT_PACKAGE_ELEMENT) {
936 ACPI_WARNING((AE_INFO, 1003 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
937 "%s: Return type mismatch - found %s, expected %s", 1004 "Return type mismatch - found %s, expected %s",
938 pathname, 1005 acpi_ut_get_object_type_name
939 acpi_ut_get_object_type_name(return_object), 1006 (return_object), type_buffer));
940 type_buffer));
941 } else { 1007 } else {
942 ACPI_WARNING((AE_INFO, 1008 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
943 "%s: Return Package type mismatch at index %u - " 1009 "Return Package type mismatch at index %u - "
944 "found %s, expected %s", pathname, package_index, 1010 "found %s, expected %s", package_index,
945 acpi_ut_get_object_type_name(return_object), 1011 acpi_ut_get_object_type_name
946 type_buffer)); 1012 (return_object), type_buffer));
947 } 1013 }
948 1014
949 return (AE_AML_OPERAND_TYPE); 1015 return (AE_AML_OPERAND_TYPE);
@@ -953,7 +1019,7 @@ acpi_ns_check_object_type(char *pathname,
953 * 1019 *
954 * FUNCTION: acpi_ns_check_reference 1020 * FUNCTION: acpi_ns_check_reference
955 * 1021 *
956 * PARAMETERS: Pathname - Full pathname to the node (for error msgs) 1022 * PARAMETERS: Data - Pointer to validation data structure
957 * return_object - Object returned from the evaluation of a 1023 * return_object - Object returned from the evaluation of a
958 * method or object 1024 * method or object
959 * 1025 *
@@ -966,7 +1032,7 @@ acpi_ns_check_object_type(char *pathname,
966 ******************************************************************************/ 1032 ******************************************************************************/
967 1033
968static acpi_status 1034static acpi_status
969acpi_ns_check_reference(char *pathname, 1035acpi_ns_check_reference(struct acpi_predefined_data *data,
970 union acpi_operand_object *return_object) 1036 union acpi_operand_object *return_object)
971{ 1037{
972 1038
@@ -979,94 +1045,46 @@ acpi_ns_check_reference(char *pathname,
979 return (AE_OK); 1045 return (AE_OK);
980 } 1046 }
981 1047
982 ACPI_WARNING((AE_INFO, 1048 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
983 "%s: Return type mismatch - " 1049 "Return type mismatch - unexpected reference object type [%s] %2.2X",
984 "unexpected reference object type [%s] %2.2X", 1050 acpi_ut_get_reference_name(return_object),
985 pathname, acpi_ut_get_reference_name(return_object), 1051 return_object->reference.class));
986 return_object->reference.class));
987 1052
988 return (AE_AML_OPERAND_TYPE); 1053 return (AE_AML_OPERAND_TYPE);
989} 1054}
990 1055
991/******************************************************************************* 1056/*******************************************************************************
992 * 1057 *
993 * FUNCTION: acpi_ns_repair_object 1058 * FUNCTION: acpi_ns_get_expected_types
994 * 1059 *
995 * PARAMETERS: Pathname - Full pathname to the node (for error msgs) 1060 * PARAMETERS: Buffer - Pointer to where the string is returned
996 * package_index - Used to determine if target is in a package 1061 * expected_btypes - Bitmap of expected return type(s)
997 * return_object_ptr - Pointer to the object returned from the
998 * evaluation of a method or object
999 * 1062 *
1000 * RETURN: Status. AE_OK if repair was successful. 1063 * RETURN: Buffer is populated with type names.
1001 * 1064 *
1002 * DESCRIPTION: Attempt to repair/convert a return object of a type that was 1065 * DESCRIPTION: Translate the expected types bitmap into a string of ascii
1003 * not expected. 1066 * names of expected types, for use in warning messages.
1004 * 1067 *
1005 ******************************************************************************/ 1068 ******************************************************************************/
1006 1069
1007static acpi_status 1070static void acpi_ns_get_expected_types(char *buffer, u32 expected_btypes)
1008acpi_ns_repair_object(u32 expected_btypes,
1009 u32 package_index,
1010 union acpi_operand_object **return_object_ptr)
1011{ 1071{
1012 union acpi_operand_object *return_object = *return_object_ptr; 1072 u32 this_rtype;
1013 union acpi_operand_object *new_object; 1073 u32 i;
1014 acpi_size length; 1074 u32 j;
1015
1016 switch (return_object->common.type) {
1017 case ACPI_TYPE_BUFFER:
1018
1019 if (!(expected_btypes & ACPI_RTYPE_STRING)) {
1020 return (AE_AML_OPERAND_TYPE);
1021 }
1022
1023 /*
1024 * Have a Buffer, expected a String, convert. Use a to_string
1025 * conversion, no transform performed on the buffer data. The best
1026 * example of this is the _BIF method, where the string data from
1027 * the battery is often (incorrectly) returned as buffer object(s).
1028 */
1029 length = 0;
1030 while ((length < return_object->buffer.length) &&
1031 (return_object->buffer.pointer[length])) {
1032 length++;
1033 }
1034
1035 /* Allocate a new string object */
1036
1037 new_object = acpi_ut_create_string_object(length);
1038 if (!new_object) {
1039 return (AE_NO_MEMORY);
1040 }
1041 1075
1042 /* 1076 j = 1;
1043 * Copy the raw buffer data with no transform. String is already NULL 1077 buffer[0] = 0;
1044 * terminated at Length+1. 1078 this_rtype = ACPI_RTYPE_INTEGER;
1045 */
1046 ACPI_MEMCPY(new_object->string.pointer,
1047 return_object->buffer.pointer, length);
1048 1079
1049 /* Install the new return object */ 1080 for (i = 0; i < ACPI_NUM_RTYPES; i++) {
1050 1081
1051 acpi_ut_remove_reference(return_object); 1082 /* If one of the expected types, concatenate the name of this type */
1052 *return_object_ptr = new_object;
1053 1083
1054 /* 1084 if (expected_btypes & this_rtype) {
1055 * If the object is a package element, we need to: 1085 ACPI_STRCAT(buffer, &acpi_rtype_names[i][j]);
1056 * 1. Decrement the reference count of the orignal object, it was 1086 j = 0; /* Use name separator from now on */
1057 * incremented when building the package
1058 * 2. Increment the reference count of the new object, it will be
1059 * decremented when releasing the package
1060 */
1061 if (package_index != ACPI_NOT_PACKAGE) {
1062 acpi_ut_remove_reference(return_object);
1063 acpi_ut_add_reference(new_object);
1064 } 1087 }
1065 return (AE_OK); 1088 this_rtype <<= 1; /* Next Rtype */
1066
1067 default:
1068 break;
1069 } 1089 }
1070
1071 return (AE_AML_OPERAND_TYPE);
1072} 1090}
diff --git a/drivers/acpi/acpica/nsrepair.c b/drivers/acpi/acpica/nsrepair.c
new file mode 100644
index 000000000000..db2b2a99c3a8
--- /dev/null
+++ b/drivers/acpi/acpica/nsrepair.c
@@ -0,0 +1,203 @@
1/******************************************************************************
2 *
3 * Module Name: nsrepair - Repair for objects returned by predefined methods
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2009, 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 "acnamesp.h"
47#include "acpredef.h"
48
49#define _COMPONENT ACPI_NAMESPACE
50ACPI_MODULE_NAME("nsrepair")
51
52/*******************************************************************************
53 *
54 * FUNCTION: acpi_ns_repair_object
55 *
56 * PARAMETERS: Data - Pointer to validation data structure
57 * expected_btypes - Object types expected
58 * package_index - Index of object within parent package (if
59 * applicable - ACPI_NOT_PACKAGE_ELEMENT
60 * otherwise)
61 * return_object_ptr - Pointer to the object returned from the
62 * evaluation of a method or object
63 *
64 * RETURN: Status. AE_OK if repair was successful.
65 *
66 * DESCRIPTION: Attempt to repair/convert a return object of a type that was
67 * not expected.
68 *
69 ******************************************************************************/
70acpi_status
71acpi_ns_repair_object(struct acpi_predefined_data *data,
72 u32 expected_btypes,
73 u32 package_index,
74 union acpi_operand_object **return_object_ptr)
75{
76 union acpi_operand_object *return_object = *return_object_ptr;
77 union acpi_operand_object *new_object;
78 acpi_size length;
79
80 switch (return_object->common.type) {
81 case ACPI_TYPE_BUFFER:
82
83 /* Does the method/object legally return a string? */
84
85 if (!(expected_btypes & ACPI_RTYPE_STRING)) {
86 return (AE_AML_OPERAND_TYPE);
87 }
88
89 /*
90 * Have a Buffer, expected a String, convert. Use a to_string
91 * conversion, no transform performed on the buffer data. The best
92 * example of this is the _BIF method, where the string data from
93 * the battery is often (incorrectly) returned as buffer object(s).
94 */
95 length = 0;
96 while ((length < return_object->buffer.length) &&
97 (return_object->buffer.pointer[length])) {
98 length++;
99 }
100
101 /* Allocate a new string object */
102
103 new_object = acpi_ut_create_string_object(length);
104 if (!new_object) {
105 return (AE_NO_MEMORY);
106 }
107
108 /*
109 * Copy the raw buffer data with no transform. String is already NULL
110 * terminated at Length+1.
111 */
112 ACPI_MEMCPY(new_object->string.pointer,
113 return_object->buffer.pointer, length);
114
115 /*
116 * If the original object is a package element, we need to:
117 * 1. Set the reference count of the new object to match the
118 * reference count of the old object.
119 * 2. Decrement the reference count of the original object.
120 */
121 if (package_index != ACPI_NOT_PACKAGE_ELEMENT) {
122 new_object->common.reference_count =
123 return_object->common.reference_count;
124
125 if (return_object->common.reference_count > 1) {
126 return_object->common.reference_count--;
127 }
128
129 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname,
130 data->node_flags,
131 "Converted Buffer to expected String at index %u",
132 package_index));
133 } else {
134 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname,
135 data->node_flags,
136 "Converted Buffer to expected String"));
137 }
138
139 /* Delete old object, install the new return object */
140
141 acpi_ut_remove_reference(return_object);
142 *return_object_ptr = new_object;
143 data->flags |= ACPI_OBJECT_REPAIRED;
144 return (AE_OK);
145
146 default:
147 break;
148 }
149
150 return (AE_AML_OPERAND_TYPE);
151}
152
153/*******************************************************************************
154 *
155 * FUNCTION: acpi_ns_repair_package_list
156 *
157 * PARAMETERS: Data - Pointer to validation data structure
158 * obj_desc_ptr - Pointer to the object to repair. The new
159 * package object is returned here,
160 * overwriting the old object.
161 *
162 * RETURN: Status, new object in *obj_desc_ptr
163 *
164 * DESCRIPTION: Repair a common problem with objects that are defined to return
165 * a variable-length Package of Packages. If the variable-length
166 * is one, some BIOS code mistakenly simply declares a single
167 * Package instead of a Package with one sub-Package. This
168 * function attempts to repair this error by wrapping a Package
169 * object around the original Package, creating the correct
170 * Package with one sub-Package.
171 *
172 * Names that can be repaired in this manner include:
173 * _ALR, _CSD, _HPX, _MLS, _PRT, _PSS, _TRT, TSS
174 *
175 ******************************************************************************/
176
177acpi_status
178acpi_ns_repair_package_list(struct acpi_predefined_data *data,
179 union acpi_operand_object **obj_desc_ptr)
180{
181 union acpi_operand_object *pkg_obj_desc;
182
183 /*
184 * Create the new outer package and populate it. The new package will
185 * have a single element, the lone subpackage.
186 */
187 pkg_obj_desc = acpi_ut_create_package_object(1);
188 if (!pkg_obj_desc) {
189 return (AE_NO_MEMORY);
190 }
191
192 pkg_obj_desc->package.elements[0] = *obj_desc_ptr;
193
194 /* Return the new object in the object pointer */
195
196 *obj_desc_ptr = pkg_obj_desc;
197 data->flags |= ACPI_OBJECT_REPAIRED;
198
199 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
200 "Incorrectly formed Package, attempting repair"));
201
202 return (AE_OK);
203}
diff --git a/drivers/acpi/acpica/nsutils.c b/drivers/acpi/acpica/nsutils.c
index 78277ed08339..ea55ab4f9849 100644
--- a/drivers/acpi/acpica/nsutils.c
+++ b/drivers/acpi/acpica/nsutils.c
@@ -88,7 +88,8 @@ acpi_ns_report_error(const char *module_name,
88 88
89 /* There is a non-ascii character in the name */ 89 /* There is a non-ascii character in the name */
90 90
91 ACPI_MOVE_32_TO_32(&bad_name, internal_name); 91 ACPI_MOVE_32_TO_32(&bad_name,
92 ACPI_CAST_PTR(u32, internal_name));
92 acpi_os_printf("[0x%4.4X] (NON-ASCII)", bad_name); 93 acpi_os_printf("[0x%4.4X] (NON-ASCII)", bad_name);
93 } else { 94 } else {
94 /* Convert path to external format */ 95 /* Convert path to external format */
@@ -836,7 +837,7 @@ acpi_ns_get_node(struct acpi_namespace_node *prefix_node,
836 acpi_status status; 837 acpi_status status;
837 char *internal_path; 838 char *internal_path;
838 839
839 ACPI_FUNCTION_TRACE_PTR(ns_get_node, pathname); 840 ACPI_FUNCTION_TRACE_PTR(ns_get_node, ACPI_CAST_PTR(char, pathname));
840 841
841 if (!pathname) { 842 if (!pathname) {
842 *return_node = prefix_node; 843 *return_node = prefix_node;
diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c
index daf4ad37896d..4929dbdbc8f0 100644
--- a/drivers/acpi/acpica/nsxfeval.c
+++ b/drivers/acpi/acpica/nsxfeval.c
@@ -535,10 +535,11 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
535 acpi_status status; 535 acpi_status status;
536 struct acpi_namespace_node *node; 536 struct acpi_namespace_node *node;
537 u32 flags; 537 u32 flags;
538 struct acpica_device_id hid; 538 struct acpica_device_id *hid;
539 struct acpi_compatible_id_list *cid; 539 struct acpica_device_id_list *cid;
540 u32 i; 540 u32 i;
541 int found; 541 u8 found;
542 int no_match;
542 543
543 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 544 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
544 if (ACPI_FAILURE(status)) { 545 if (ACPI_FAILURE(status)) {
@@ -582,10 +583,14 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
582 return (AE_CTRL_DEPTH); 583 return (AE_CTRL_DEPTH);
583 } 584 }
584 585
585 if (ACPI_STRNCMP(hid.value, info->hid, sizeof(hid.value)) != 0) { 586 no_match = ACPI_STRCMP(hid->string, info->hid);
586 587 ACPI_FREE(hid);
587 /* Get the list of Compatible IDs */
588 588
589 if (no_match) {
590 /*
591 * HID does not match, attempt match within the
592 * list of Compatible IDs (CIDs)
593 */
589 status = acpi_ut_execute_CID(node, &cid); 594 status = acpi_ut_execute_CID(node, &cid);
590 if (status == AE_NOT_FOUND) { 595 if (status == AE_NOT_FOUND) {
591 return (AE_OK); 596 return (AE_OK);
@@ -597,10 +602,8 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
597 602
598 found = 0; 603 found = 0;
599 for (i = 0; i < cid->count; i++) { 604 for (i = 0; i < cid->count; i++) {
600 if (ACPI_STRNCMP(cid->id[i].value, info->hid, 605 if (ACPI_STRCMP(cid->ids[i].string, info->hid)
601 sizeof(struct 606 == 0) {
602 acpi_compatible_id)) ==
603 0) {
604 found = 1; 607 found = 1;
605 break; 608 break;
606 } 609 }
diff --git a/drivers/acpi/acpica/nsxfname.c b/drivers/acpi/acpica/nsxfname.c
index f23593d6add4..ddc84af6336e 100644
--- a/drivers/acpi/acpica/nsxfname.c
+++ b/drivers/acpi/acpica/nsxfname.c
@@ -51,6 +51,11 @@
51#define _COMPONENT ACPI_NAMESPACE 51#define _COMPONENT ACPI_NAMESPACE
52ACPI_MODULE_NAME("nsxfname") 52ACPI_MODULE_NAME("nsxfname")
53 53
54/* Local prototypes */
55static char *acpi_ns_copy_device_id(struct acpica_device_id *dest,
56 struct acpica_device_id *source,
57 char *string_area);
58
54/****************************************************************************** 59/******************************************************************************
55 * 60 *
56 * FUNCTION: acpi_get_handle 61 * FUNCTION: acpi_get_handle
@@ -68,6 +73,7 @@ ACPI_MODULE_NAME("nsxfname")
68 * namespace handle. 73 * namespace handle.
69 * 74 *
70 ******************************************************************************/ 75 ******************************************************************************/
76
71acpi_status 77acpi_status
72acpi_get_handle(acpi_handle parent, 78acpi_get_handle(acpi_handle parent,
73 acpi_string pathname, acpi_handle * ret_handle) 79 acpi_string pathname, acpi_handle * ret_handle)
@@ -210,10 +216,38 @@ ACPI_EXPORT_SYMBOL(acpi_get_name)
210 216
211/****************************************************************************** 217/******************************************************************************
212 * 218 *
219 * FUNCTION: acpi_ns_copy_device_id
220 *
221 * PARAMETERS: Dest - Pointer to the destination DEVICE_ID
222 * Source - Pointer to the source DEVICE_ID
223 * string_area - Pointer to where to copy the dest string
224 *
225 * RETURN: Pointer to the next string area
226 *
227 * DESCRIPTION: Copy a single DEVICE_ID, including the string data.
228 *
229 ******************************************************************************/
230static char *acpi_ns_copy_device_id(struct acpica_device_id *dest,
231 struct acpica_device_id *source,
232 char *string_area)
233{
234 /* Create the destination DEVICE_ID */
235
236 dest->string = string_area;
237 dest->length = source->length;
238
239 /* Copy actual string and return a pointer to the next string area */
240
241 ACPI_MEMCPY(string_area, source->string, source->length);
242 return (string_area + source->length);
243}
244
245/******************************************************************************
246 *
213 * FUNCTION: acpi_get_object_info 247 * FUNCTION: acpi_get_object_info
214 * 248 *
215 * PARAMETERS: Handle - Object Handle 249 * PARAMETERS: Handle - Object Handle
216 * Buffer - Where the info is returned 250 * return_buffer - Where the info is returned
217 * 251 *
218 * RETURN: Status 252 * RETURN: Status
219 * 253 *
@@ -221,33 +255,37 @@ ACPI_EXPORT_SYMBOL(acpi_get_name)
221 * namespace node and possibly by running several standard 255 * namespace node and possibly by running several standard
222 * control methods (Such as in the case of a device.) 256 * control methods (Such as in the case of a device.)
223 * 257 *
258 * For Device and Processor objects, run the Device _HID, _UID, _CID, _STA,
259 * _ADR, _sx_w, and _sx_d methods.
260 *
261 * Note: Allocates the return buffer, must be freed by the caller.
262 *
224 ******************************************************************************/ 263 ******************************************************************************/
264
225acpi_status 265acpi_status
226acpi_get_object_info(acpi_handle handle, struct acpi_buffer * buffer) 266acpi_get_object_info(acpi_handle handle,
267 struct acpi_device_info **return_buffer)
227{ 268{
228 acpi_status status;
229 struct acpi_namespace_node *node; 269 struct acpi_namespace_node *node;
230 struct acpi_device_info *info; 270 struct acpi_device_info *info;
231 struct acpi_device_info *return_info; 271 struct acpica_device_id_list *cid_list = NULL;
232 struct acpi_compatible_id_list *cid_list = NULL; 272 struct acpica_device_id *hid = NULL;
233 acpi_size size; 273 struct acpica_device_id *uid = NULL;
274 char *next_id_string;
275 acpi_object_type type;
276 acpi_name name;
277 u8 param_count = 0;
278 u8 valid = 0;
279 u32 info_size;
280 u32 i;
281 acpi_status status;
234 282
235 /* Parameter validation */ 283 /* Parameter validation */
236 284
237 if (!handle || !buffer) { 285 if (!handle || !return_buffer) {
238 return (AE_BAD_PARAMETER); 286 return (AE_BAD_PARAMETER);
239 } 287 }
240 288
241 status = acpi_ut_validate_buffer(buffer);
242 if (ACPI_FAILURE(status)) {
243 return (status);
244 }
245
246 info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_device_info));
247 if (!info) {
248 return (AE_NO_MEMORY);
249 }
250
251 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 289 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
252 if (ACPI_FAILURE(status)) { 290 if (ACPI_FAILURE(status)) {
253 goto cleanup; 291 goto cleanup;
@@ -256,66 +294,91 @@ acpi_get_object_info(acpi_handle handle, struct acpi_buffer * buffer)
256 node = acpi_ns_map_handle_to_node(handle); 294 node = acpi_ns_map_handle_to_node(handle);
257 if (!node) { 295 if (!node) {
258 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 296 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
259 status = AE_BAD_PARAMETER; 297 return (AE_BAD_PARAMETER);
260 goto cleanup;
261 } 298 }
262 299
263 /* Init return structure */ 300 /* Get the namespace node data while the namespace is locked */
264
265 size = sizeof(struct acpi_device_info);
266 301
267 info->type = node->type; 302 info_size = sizeof(struct acpi_device_info);
268 info->name = node->name.integer; 303 type = node->type;
269 info->valid = 0; 304 name = node->name.integer;
270 305
271 if (node->type == ACPI_TYPE_METHOD) { 306 if (node->type == ACPI_TYPE_METHOD) {
272 info->param_count = node->object->method.param_count; 307 param_count = node->object->method.param_count;
273 } 308 }
274 309
275 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 310 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
276 if (ACPI_FAILURE(status)) { 311 if (ACPI_FAILURE(status)) {
277 goto cleanup; 312 return (status);
278 } 313 }
279 314
280 /* If not a device, we are all done */ 315 if ((type == ACPI_TYPE_DEVICE) || (type == ACPI_TYPE_PROCESSOR)) {
281
282 if (info->type == ACPI_TYPE_DEVICE) {
283 /* 316 /*
284 * Get extra info for ACPI Devices objects only: 317 * Get extra info for ACPI Device/Processor objects only:
285 * Run the Device _HID, _UID, _CID, _STA, _ADR and _sx_d methods. 318 * Run the Device _HID, _UID, and _CID methods.
286 * 319 *
287 * Note: none of these methods are required, so they may or may 320 * Note: none of these methods are required, so they may or may
288 * not be present for this device. The Info->Valid bitfield is used 321 * not be present for this device. The Info->Valid bitfield is used
289 * to indicate which methods were found and ran successfully. 322 * to indicate which methods were found and run successfully.
290 */ 323 */
291 324
292 /* Execute the Device._HID method */ 325 /* Execute the Device._HID method */
293 326
294 status = acpi_ut_execute_HID(node, &info->hardware_id); 327 status = acpi_ut_execute_HID(node, &hid);
295 if (ACPI_SUCCESS(status)) { 328 if (ACPI_SUCCESS(status)) {
296 info->valid |= ACPI_VALID_HID; 329 info_size += hid->length;
330 valid |= ACPI_VALID_HID;
297 } 331 }
298 332
299 /* Execute the Device._UID method */ 333 /* Execute the Device._UID method */
300 334
301 status = acpi_ut_execute_UID(node, &info->unique_id); 335 status = acpi_ut_execute_UID(node, &uid);
302 if (ACPI_SUCCESS(status)) { 336 if (ACPI_SUCCESS(status)) {
303 info->valid |= ACPI_VALID_UID; 337 info_size += uid->length;
338 valid |= ACPI_VALID_UID;
304 } 339 }
305 340
306 /* Execute the Device._CID method */ 341 /* Execute the Device._CID method */
307 342
308 status = acpi_ut_execute_CID(node, &cid_list); 343 status = acpi_ut_execute_CID(node, &cid_list);
309 if (ACPI_SUCCESS(status)) { 344 if (ACPI_SUCCESS(status)) {
310 size += cid_list->size; 345
311 info->valid |= ACPI_VALID_CID; 346 /* Add size of CID strings and CID pointer array */
347
348 info_size +=
349 (cid_list->list_size -
350 sizeof(struct acpica_device_id_list));
351 valid |= ACPI_VALID_CID;
312 } 352 }
353 }
354
355 /*
356 * Now that we have the variable-length data, we can allocate the
357 * return buffer
358 */
359 info = ACPI_ALLOCATE_ZEROED(info_size);
360 if (!info) {
361 status = AE_NO_MEMORY;
362 goto cleanup;
363 }
364
365 /* Get the fixed-length data */
366
367 if ((type == ACPI_TYPE_DEVICE) || (type == ACPI_TYPE_PROCESSOR)) {
368 /*
369 * Get extra info for ACPI Device/Processor objects only:
370 * Run the _STA, _ADR and, sx_w, and _sx_d methods.
371 *
372 * Note: none of these methods are required, so they may or may
373 * not be present for this device. The Info->Valid bitfield is used
374 * to indicate which methods were found and run successfully.
375 */
313 376
314 /* Execute the Device._STA method */ 377 /* Execute the Device._STA method */
315 378
316 status = acpi_ut_execute_STA(node, &info->current_status); 379 status = acpi_ut_execute_STA(node, &info->current_status);
317 if (ACPI_SUCCESS(status)) { 380 if (ACPI_SUCCESS(status)) {
318 info->valid |= ACPI_VALID_STA; 381 valid |= ACPI_VALID_STA;
319 } 382 }
320 383
321 /* Execute the Device._ADR method */ 384 /* Execute the Device._ADR method */
@@ -323,36 +386,100 @@ acpi_get_object_info(acpi_handle handle, struct acpi_buffer * buffer)
323 status = acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR, node, 386 status = acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR, node,
324 &info->address); 387 &info->address);
325 if (ACPI_SUCCESS(status)) { 388 if (ACPI_SUCCESS(status)) {
326 info->valid |= ACPI_VALID_ADR; 389 valid |= ACPI_VALID_ADR;
390 }
391
392 /* Execute the Device._sx_w methods */
393
394 status = acpi_ut_execute_power_methods(node,
395 acpi_gbl_lowest_dstate_names,
396 ACPI_NUM_sx_w_METHODS,
397 info->lowest_dstates);
398 if (ACPI_SUCCESS(status)) {
399 valid |= ACPI_VALID_SXWS;
327 } 400 }
328 401
329 /* Execute the Device._sx_d methods */ 402 /* Execute the Device._sx_d methods */
330 403
331 status = acpi_ut_execute_sxds(node, info->highest_dstates); 404 status = acpi_ut_execute_power_methods(node,
405 acpi_gbl_highest_dstate_names,
406 ACPI_NUM_sx_d_METHODS,
407 info->highest_dstates);
332 if (ACPI_SUCCESS(status)) { 408 if (ACPI_SUCCESS(status)) {
333 info->valid |= ACPI_VALID_SXDS; 409 valid |= ACPI_VALID_SXDS;
334 } 410 }
335 } 411 }
336 412
337 /* Validate/Allocate/Clear caller buffer */ 413 /*
414 * Create a pointer to the string area of the return buffer.
415 * Point to the end of the base struct acpi_device_info structure.
416 */
417 next_id_string = ACPI_CAST_PTR(char, info->compatible_id_list.ids);
418 if (cid_list) {
338 419
339 status = acpi_ut_initialize_buffer(buffer, size); 420 /* Point past the CID DEVICE_ID array */
340 if (ACPI_FAILURE(status)) { 421
341 goto cleanup; 422 next_id_string +=
423 ((acpi_size) cid_list->count *
424 sizeof(struct acpica_device_id));
342 } 425 }
343 426
344 /* Populate the return buffer */ 427 /*
428 * Copy the HID, UID, and CIDs to the return buffer. The variable-length
429 * strings are copied to the reserved area at the end of the buffer.
430 *
431 * For HID and CID, check if the ID is a PCI Root Bridge.
432 */
433 if (hid) {
434 next_id_string = acpi_ns_copy_device_id(&info->hardware_id,
435 hid, next_id_string);
436
437 if (acpi_ut_is_pci_root_bridge(hid->string)) {
438 info->flags |= ACPI_PCI_ROOT_BRIDGE;
439 }
440 }
345 441
346 return_info = buffer->pointer; 442 if (uid) {
347 ACPI_MEMCPY(return_info, info, sizeof(struct acpi_device_info)); 443 next_id_string = acpi_ns_copy_device_id(&info->unique_id,
444 uid, next_id_string);
445 }
348 446
349 if (cid_list) { 447 if (cid_list) {
350 ACPI_MEMCPY(&return_info->compatibility_id, cid_list, 448 info->compatible_id_list.count = cid_list->count;
351 cid_list->size); 449 info->compatible_id_list.list_size = cid_list->list_size;
450
451 /* Copy each CID */
452
453 for (i = 0; i < cid_list->count; i++) {
454 next_id_string =
455 acpi_ns_copy_device_id(&info->compatible_id_list.
456 ids[i], &cid_list->ids[i],
457 next_id_string);
458
459 if (acpi_ut_is_pci_root_bridge(cid_list->ids[i].string)) {
460 info->flags |= ACPI_PCI_ROOT_BRIDGE;
461 }
462 }
352 } 463 }
353 464
465 /* Copy the fixed-length data */
466
467 info->info_size = info_size;
468 info->type = type;
469 info->name = name;
470 info->param_count = param_count;
471 info->valid = valid;
472
473 *return_buffer = info;
474 status = AE_OK;
475
354 cleanup: 476 cleanup:
355 ACPI_FREE(info); 477 if (hid) {
478 ACPI_FREE(hid);
479 }
480 if (uid) {
481 ACPI_FREE(uid);
482 }
356 if (cid_list) { 483 if (cid_list) {
357 ACPI_FREE(cid_list); 484 ACPI_FREE(cid_list);
358 } 485 }
diff --git a/drivers/acpi/acpica/psloop.c b/drivers/acpi/acpica/psloop.c
index c5f6ce19a401..cd7995b3aed4 100644
--- a/drivers/acpi/acpica/psloop.c
+++ b/drivers/acpi/acpica/psloop.c
@@ -86,6 +86,9 @@ static acpi_status
86acpi_ps_complete_final_op(struct acpi_walk_state *walk_state, 86acpi_ps_complete_final_op(struct acpi_walk_state *walk_state,
87 union acpi_parse_object *op, acpi_status status); 87 union acpi_parse_object *op, acpi_status status);
88 88
89static void
90acpi_ps_link_module_code(u8 *aml_start, u32 aml_length, acpi_owner_id owner_id);
91
89/******************************************************************************* 92/*******************************************************************************
90 * 93 *
91 * FUNCTION: acpi_ps_get_aml_opcode 94 * FUNCTION: acpi_ps_get_aml_opcode
@@ -390,6 +393,7 @@ acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
390{ 393{
391 acpi_status status = AE_OK; 394 acpi_status status = AE_OK;
392 union acpi_parse_object *arg = NULL; 395 union acpi_parse_object *arg = NULL;
396 const struct acpi_opcode_info *op_info;
393 397
394 ACPI_FUNCTION_TRACE_PTR(ps_get_arguments, walk_state); 398 ACPI_FUNCTION_TRACE_PTR(ps_get_arguments, walk_state);
395 399
@@ -449,13 +453,11 @@ acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
449 INCREMENT_ARG_LIST(walk_state->arg_types); 453 INCREMENT_ARG_LIST(walk_state->arg_types);
450 } 454 }
451 455
452 /* Special processing for certain opcodes */ 456 /*
453 457 * Handle executable code at "module-level". This refers to
454 /* TBD (remove): Temporary mechanism to disable this code if needed */ 458 * executable opcodes that appear outside of any control method.
455 459 */
456#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE 460 if ((walk_state->pass_number <= ACPI_IMODE_LOAD_PASS2) &&
457
458 if ((walk_state->pass_number <= ACPI_IMODE_LOAD_PASS1) &&
459 ((walk_state->parse_flags & ACPI_PARSE_DISASSEMBLE) == 0)) { 461 ((walk_state->parse_flags & ACPI_PARSE_DISASSEMBLE) == 0)) {
460 /* 462 /*
461 * We want to skip If/Else/While constructs during Pass1 because we 463 * We want to skip If/Else/While constructs during Pass1 because we
@@ -469,6 +471,23 @@ acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
469 case AML_ELSE_OP: 471 case AML_ELSE_OP:
470 case AML_WHILE_OP: 472 case AML_WHILE_OP:
471 473
474 /*
475 * Currently supported module-level opcodes are:
476 * IF/ELSE/WHILE. These appear to be the most common,
477 * and easiest to support since they open an AML
478 * package.
479 */
480 if (walk_state->pass_number ==
481 ACPI_IMODE_LOAD_PASS1) {
482 acpi_ps_link_module_code(aml_op_start,
483 walk_state->
484 parser_state.
485 pkg_end -
486 aml_op_start,
487 walk_state->
488 owner_id);
489 }
490
472 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, 491 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
473 "Pass1: Skipping an If/Else/While body\n")); 492 "Pass1: Skipping an If/Else/While body\n"));
474 493
@@ -480,10 +499,34 @@ acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
480 break; 499 break;
481 500
482 default: 501 default:
502 /*
503 * Check for an unsupported executable opcode at module
504 * level. We must be in PASS1, the parent must be a SCOPE,
505 * The opcode class must be EXECUTE, and the opcode must
506 * not be an argument to another opcode.
507 */
508 if ((walk_state->pass_number ==
509 ACPI_IMODE_LOAD_PASS1)
510 && (op->common.parent->common.aml_opcode ==
511 AML_SCOPE_OP)) {
512 op_info =
513 acpi_ps_get_opcode_info(op->common.
514 aml_opcode);
515 if ((op_info->class ==
516 AML_CLASS_EXECUTE) && (!arg)) {
517 ACPI_WARNING((AE_INFO,
518 "Detected an unsupported executable opcode "
519 "at module-level: [0x%.4X] at table offset 0x%.4X",
520 op->common.aml_opcode,
521 (u32)((aml_op_start - walk_state->parser_state.aml_start)
522 + sizeof(struct acpi_table_header))));
523 }
524 }
483 break; 525 break;
484 } 526 }
485 } 527 }
486#endif 528
529 /* Special processing for certain opcodes */
487 530
488 switch (op->common.aml_opcode) { 531 switch (op->common.aml_opcode) {
489 case AML_METHOD_OP: 532 case AML_METHOD_OP:
@@ -553,6 +596,66 @@ acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
553 596
554/******************************************************************************* 597/*******************************************************************************
555 * 598 *
599 * FUNCTION: acpi_ps_link_module_code
600 *
601 * PARAMETERS: aml_start - Pointer to the AML
602 * aml_length - Length of executable AML
603 * owner_id - owner_id of module level code
604 *
605 * RETURN: None.
606 *
607 * DESCRIPTION: Wrap the module-level code with a method object and link the
608 * object to the global list. Note, the mutex field of the method
609 * object is used to link multiple module-level code objects.
610 *
611 ******************************************************************************/
612
613static void
614acpi_ps_link_module_code(u8 *aml_start, u32 aml_length, acpi_owner_id owner_id)
615{
616 union acpi_operand_object *prev;
617 union acpi_operand_object *next;
618 union acpi_operand_object *method_obj;
619
620 /* Get the tail of the list */
621
622 prev = next = acpi_gbl_module_code_list;
623 while (next) {
624 prev = next;
625 next = next->method.mutex;
626 }
627
628 /*
629 * Insert the module level code into the list. Merge it if it is
630 * adjacent to the previous element.
631 */
632 if (!prev ||
633 ((prev->method.aml_start + prev->method.aml_length) != aml_start)) {
634
635 /* Create, initialize, and link a new temporary method object */
636
637 method_obj = acpi_ut_create_internal_object(ACPI_TYPE_METHOD);
638 if (!method_obj) {
639 return;
640 }
641
642 method_obj->method.aml_start = aml_start;
643 method_obj->method.aml_length = aml_length;
644 method_obj->method.owner_id = owner_id;
645 method_obj->method.flags |= AOPOBJ_MODULE_LEVEL;
646
647 if (!prev) {
648 acpi_gbl_module_code_list = method_obj;
649 } else {
650 prev->method.mutex = method_obj;
651 }
652 } else {
653 prev->method.aml_length += aml_length;
654 }
655}
656
657/*******************************************************************************
658 *
556 * FUNCTION: acpi_ps_complete_op 659 * FUNCTION: acpi_ps_complete_op
557 * 660 *
558 * PARAMETERS: walk_state - Current state 661 * PARAMETERS: walk_state - Current state
diff --git a/drivers/acpi/acpica/psxface.c b/drivers/acpi/acpica/psxface.c
index ff06032c0f06..dd9731c29a79 100644
--- a/drivers/acpi/acpica/psxface.c
+++ b/drivers/acpi/acpica/psxface.c
@@ -280,6 +280,10 @@ acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info)
280 goto cleanup; 280 goto cleanup;
281 } 281 }
282 282
283 if (info->obj_desc->method.flags & AOPOBJ_MODULE_LEVEL) {
284 walk_state->parse_flags |= ACPI_PARSE_MODULE_LEVEL;
285 }
286
283 /* Invoke an internal method if necessary */ 287 /* Invoke an internal method if necessary */
284 288
285 if (info->obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) { 289 if (info->obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) {
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c
index ef7d2c2d8f0b..1f15497f00d1 100644
--- a/drivers/acpi/acpica/tbutils.c
+++ b/drivers/acpi/acpica/tbutils.c
@@ -49,6 +49,12 @@
49ACPI_MODULE_NAME("tbutils") 49ACPI_MODULE_NAME("tbutils")
50 50
51/* Local prototypes */ 51/* Local prototypes */
52static void acpi_tb_fix_string(char *string, acpi_size length);
53
54static void
55acpi_tb_cleanup_table_header(struct acpi_table_header *out_header,
56 struct acpi_table_header *header);
57
52static acpi_physical_address 58static acpi_physical_address
53acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size); 59acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size);
54 60
@@ -161,6 +167,59 @@ u8 acpi_tb_tables_loaded(void)
161 167
162/******************************************************************************* 168/*******************************************************************************
163 * 169 *
170 * FUNCTION: acpi_tb_fix_string
171 *
172 * PARAMETERS: String - String to be repaired
173 * Length - Maximum length
174 *
175 * RETURN: None
176 *
177 * DESCRIPTION: Replace every non-printable or non-ascii byte in the string
178 * with a question mark '?'.
179 *
180 ******************************************************************************/
181
182static void acpi_tb_fix_string(char *string, acpi_size length)
183{
184
185 while (length && *string) {
186 if (!ACPI_IS_PRINT(*string)) {
187 *string = '?';
188 }
189 string++;
190 length--;
191 }
192}
193
194/*******************************************************************************
195 *
196 * FUNCTION: acpi_tb_cleanup_table_header
197 *
198 * PARAMETERS: out_header - Where the cleaned header is returned
199 * Header - Input ACPI table header
200 *
201 * RETURN: Returns the cleaned header in out_header
202 *
203 * DESCRIPTION: Copy the table header and ensure that all "string" fields in
204 * the header consist of printable characters.
205 *
206 ******************************************************************************/
207
208static void
209acpi_tb_cleanup_table_header(struct acpi_table_header *out_header,
210 struct acpi_table_header *header)
211{
212
213 ACPI_MEMCPY(out_header, header, sizeof(struct acpi_table_header));
214
215 acpi_tb_fix_string(out_header->signature, ACPI_NAME_SIZE);
216 acpi_tb_fix_string(out_header->oem_id, ACPI_OEM_ID_SIZE);
217 acpi_tb_fix_string(out_header->oem_table_id, ACPI_OEM_TABLE_ID_SIZE);
218 acpi_tb_fix_string(out_header->asl_compiler_id, ACPI_NAME_SIZE);
219}
220
221/*******************************************************************************
222 *
164 * FUNCTION: acpi_tb_print_table_header 223 * FUNCTION: acpi_tb_print_table_header
165 * 224 *
166 * PARAMETERS: Address - Table physical address 225 * PARAMETERS: Address - Table physical address
@@ -176,6 +235,7 @@ void
176acpi_tb_print_table_header(acpi_physical_address address, 235acpi_tb_print_table_header(acpi_physical_address address,
177 struct acpi_table_header *header) 236 struct acpi_table_header *header)
178{ 237{
238 struct acpi_table_header local_header;
179 239
180 /* 240 /*
181 * The reason that the Address is cast to a void pointer is so that we 241 * The reason that the Address is cast to a void pointer is so that we
@@ -192,6 +252,11 @@ acpi_tb_print_table_header(acpi_physical_address address,
192 252
193 /* RSDP has no common fields */ 253 /* RSDP has no common fields */
194 254
255 ACPI_MEMCPY(local_header.oem_id,
256 ACPI_CAST_PTR(struct acpi_table_rsdp,
257 header)->oem_id, ACPI_OEM_ID_SIZE);
258 acpi_tb_fix_string(local_header.oem_id, ACPI_OEM_ID_SIZE);
259
195 ACPI_INFO((AE_INFO, "RSDP %p %05X (v%.2d %6.6s)", 260 ACPI_INFO((AE_INFO, "RSDP %p %05X (v%.2d %6.6s)",
196 ACPI_CAST_PTR (void, address), 261 ACPI_CAST_PTR (void, address),
197 (ACPI_CAST_PTR(struct acpi_table_rsdp, header)-> 262 (ACPI_CAST_PTR(struct acpi_table_rsdp, header)->
@@ -200,18 +265,21 @@ acpi_tb_print_table_header(acpi_physical_address address,
200 header)->length : 20, 265 header)->length : 20,
201 ACPI_CAST_PTR(struct acpi_table_rsdp, 266 ACPI_CAST_PTR(struct acpi_table_rsdp,
202 header)->revision, 267 header)->revision,
203 ACPI_CAST_PTR(struct acpi_table_rsdp, 268 local_header.oem_id));
204 header)->oem_id));
205 } else { 269 } else {
206 /* Standard ACPI table with full common header */ 270 /* Standard ACPI table with full common header */
207 271
272 acpi_tb_cleanup_table_header(&local_header, header);
273
208 ACPI_INFO((AE_INFO, 274 ACPI_INFO((AE_INFO,
209 "%4.4s %p %05X (v%.2d %6.6s %8.8s %08X %4.4s %08X)", 275 "%4.4s %p %05X (v%.2d %6.6s %8.8s %08X %4.4s %08X)",
210 header->signature, ACPI_CAST_PTR (void, address), 276 local_header.signature, ACPI_CAST_PTR(void, address),
211 header->length, header->revision, header->oem_id, 277 local_header.length, local_header.revision,
212 header->oem_table_id, header->oem_revision, 278 local_header.oem_id, local_header.oem_table_id,
213 header->asl_compiler_id, 279 local_header.oem_revision,
214 header->asl_compiler_revision)); 280 local_header.asl_compiler_id,
281 local_header.asl_compiler_revision));
282
215 } 283 }
216} 284}
217 285
diff --git a/drivers/acpi/acpica/uteval.c b/drivers/acpi/acpica/uteval.c
index 006b16c26017..5d54e36ab453 100644
--- a/drivers/acpi/acpica/uteval.c
+++ b/drivers/acpi/acpica/uteval.c
@@ -44,19 +44,10 @@
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include "accommon.h" 45#include "accommon.h"
46#include "acnamesp.h" 46#include "acnamesp.h"
47#include "acinterp.h"
48 47
49#define _COMPONENT ACPI_UTILITIES 48#define _COMPONENT ACPI_UTILITIES
50ACPI_MODULE_NAME("uteval") 49ACPI_MODULE_NAME("uteval")
51 50
52/* Local prototypes */
53static void
54acpi_ut_copy_id_string(char *destination, char *source, acpi_size max_length);
55
56static acpi_status
57acpi_ut_translate_one_cid(union acpi_operand_object *obj_desc,
58 struct acpi_compatible_id *one_cid);
59
60/* 51/*
61 * Strings supported by the _OSI predefined (internal) method. 52 * Strings supported by the _OSI predefined (internal) method.
62 * 53 *
@@ -78,6 +69,9 @@ static struct acpi_interface_info acpi_interfaces_supported[] = {
78 {"Windows 2001 SP2", ACPI_OSI_WIN_XP_SP2}, /* Windows XP SP2 */ 69 {"Windows 2001 SP2", ACPI_OSI_WIN_XP_SP2}, /* Windows XP SP2 */
79 {"Windows 2001.1 SP1", ACPI_OSI_WINSRV_2003_SP1}, /* Windows Server 2003 SP1 - Added 03/2006 */ 70 {"Windows 2001.1 SP1", ACPI_OSI_WINSRV_2003_SP1}, /* Windows Server 2003 SP1 - Added 03/2006 */
80 {"Windows 2006", ACPI_OSI_WIN_VISTA}, /* Windows Vista - Added 03/2006 */ 71 {"Windows 2006", ACPI_OSI_WIN_VISTA}, /* Windows Vista - Added 03/2006 */
72 {"Windows 2006.1", ACPI_OSI_WINSRV_2008}, /* Windows Server 2008 - Added 09/2009 */
73 {"Windows 2006 SP1", ACPI_OSI_WIN_VISTA_SP1}, /* Windows Vista SP1 - Added 09/2009 */
74 {"Windows 2009", ACPI_OSI_WIN_7}, /* Windows 7 and Server 2008 R2 - Added 09/2009 */
81 75
82 /* Feature Group Strings */ 76 /* Feature Group Strings */
83 77
@@ -213,7 +207,7 @@ acpi_status acpi_osi_invalidate(char *interface)
213 * RETURN: Status 207 * RETURN: Status
214 * 208 *
215 * DESCRIPTION: Evaluates a namespace object and verifies the type of the 209 * DESCRIPTION: Evaluates a namespace object and verifies the type of the
216 * return object. Common code that simplifies accessing objects 210 * return object. Common code that simplifies accessing objects
217 * that have required return objects of fixed types. 211 * that have required return objects of fixed types.
218 * 212 *
219 * NOTE: Internal function, no parameter validation 213 * NOTE: Internal function, no parameter validation
@@ -298,7 +292,7 @@ acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
298 292
299 if ((acpi_gbl_enable_interpreter_slack) && (!expected_return_btypes)) { 293 if ((acpi_gbl_enable_interpreter_slack) && (!expected_return_btypes)) {
300 /* 294 /*
301 * We received a return object, but one was not expected. This can 295 * We received a return object, but one was not expected. This can
302 * happen frequently if the "implicit return" feature is enabled. 296 * happen frequently if the "implicit return" feature is enabled.
303 * Just delete the return object and return AE_OK. 297 * Just delete the return object and return AE_OK.
304 */ 298 */
@@ -340,12 +334,12 @@ acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
340 * 334 *
341 * PARAMETERS: object_name - Object name to be evaluated 335 * PARAMETERS: object_name - Object name to be evaluated
342 * device_node - Node for the device 336 * device_node - Node for the device
343 * Address - Where the value is returned 337 * Value - Where the value is returned
344 * 338 *
345 * RETURN: Status 339 * RETURN: Status
346 * 340 *
347 * DESCRIPTION: Evaluates a numeric namespace object for a selected device 341 * DESCRIPTION: Evaluates a numeric namespace object for a selected device
348 * and stores result in *Address. 342 * and stores result in *Value.
349 * 343 *
350 * NOTE: Internal function, no parameter validation 344 * NOTE: Internal function, no parameter validation
351 * 345 *
@@ -354,7 +348,7 @@ acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
354acpi_status 348acpi_status
355acpi_ut_evaluate_numeric_object(char *object_name, 349acpi_ut_evaluate_numeric_object(char *object_name,
356 struct acpi_namespace_node *device_node, 350 struct acpi_namespace_node *device_node,
357 acpi_integer * address) 351 acpi_integer *value)
358{ 352{
359 union acpi_operand_object *obj_desc; 353 union acpi_operand_object *obj_desc;
360 acpi_status status; 354 acpi_status status;
@@ -369,295 +363,7 @@ acpi_ut_evaluate_numeric_object(char *object_name,
369 363
370 /* Get the returned Integer */ 364 /* Get the returned Integer */
371 365
372 *address = obj_desc->integer.value; 366 *value = obj_desc->integer.value;
373
374 /* On exit, we must delete the return object */
375
376 acpi_ut_remove_reference(obj_desc);
377 return_ACPI_STATUS(status);
378}
379
380/*******************************************************************************
381 *
382 * FUNCTION: acpi_ut_copy_id_string
383 *
384 * PARAMETERS: Destination - Where to copy the string
385 * Source - Source string
386 * max_length - Length of the destination buffer
387 *
388 * RETURN: None
389 *
390 * DESCRIPTION: Copies an ID string for the _HID, _CID, and _UID methods.
391 * Performs removal of a leading asterisk if present -- workaround
392 * for a known issue on a bunch of machines.
393 *
394 ******************************************************************************/
395
396static void
397acpi_ut_copy_id_string(char *destination, char *source, acpi_size max_length)
398{
399
400 /*
401 * Workaround for ID strings that have a leading asterisk. This construct
402 * is not allowed by the ACPI specification (ID strings must be
403 * alphanumeric), but enough existing machines have this embedded in their
404 * ID strings that the following code is useful.
405 */
406 if (*source == '*') {
407 source++;
408 }
409
410 /* Do the actual copy */
411
412 ACPI_STRNCPY(destination, source, max_length);
413}
414
415/*******************************************************************************
416 *
417 * FUNCTION: acpi_ut_execute_HID
418 *
419 * PARAMETERS: device_node - Node for the device
420 * Hid - Where the HID is returned
421 *
422 * RETURN: Status
423 *
424 * DESCRIPTION: Executes the _HID control method that returns the hardware
425 * ID of the device.
426 *
427 * NOTE: Internal function, no parameter validation
428 *
429 ******************************************************************************/
430
431acpi_status
432acpi_ut_execute_HID(struct acpi_namespace_node *device_node,
433 struct acpica_device_id *hid)
434{
435 union acpi_operand_object *obj_desc;
436 acpi_status status;
437
438 ACPI_FUNCTION_TRACE(ut_execute_HID);
439
440 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__HID,
441 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING,
442 &obj_desc);
443 if (ACPI_FAILURE(status)) {
444 return_ACPI_STATUS(status);
445 }
446
447 if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
448
449 /* Convert the Numeric HID to string */
450
451 acpi_ex_eisa_id_to_string((u32) obj_desc->integer.value,
452 hid->value);
453 } else {
454 /* Copy the String HID from the returned object */
455
456 acpi_ut_copy_id_string(hid->value, obj_desc->string.pointer,
457 sizeof(hid->value));
458 }
459
460 /* On exit, we must delete the return object */
461
462 acpi_ut_remove_reference(obj_desc);
463 return_ACPI_STATUS(status);
464}
465
466/*******************************************************************************
467 *
468 * FUNCTION: acpi_ut_translate_one_cid
469 *
470 * PARAMETERS: obj_desc - _CID object, must be integer or string
471 * one_cid - Where the CID string is returned
472 *
473 * RETURN: Status
474 *
475 * DESCRIPTION: Return a numeric or string _CID value as a string.
476 * (Compatible ID)
477 *
478 * NOTE: Assumes a maximum _CID string length of
479 * ACPI_MAX_CID_LENGTH.
480 *
481 ******************************************************************************/
482
483static acpi_status
484acpi_ut_translate_one_cid(union acpi_operand_object *obj_desc,
485 struct acpi_compatible_id *one_cid)
486{
487
488 switch (obj_desc->common.type) {
489 case ACPI_TYPE_INTEGER:
490
491 /* Convert the Numeric CID to string */
492
493 acpi_ex_eisa_id_to_string((u32) obj_desc->integer.value,
494 one_cid->value);
495 return (AE_OK);
496
497 case ACPI_TYPE_STRING:
498
499 if (obj_desc->string.length > ACPI_MAX_CID_LENGTH) {
500 return (AE_AML_STRING_LIMIT);
501 }
502
503 /* Copy the String CID from the returned object */
504
505 acpi_ut_copy_id_string(one_cid->value, obj_desc->string.pointer,
506 ACPI_MAX_CID_LENGTH);
507 return (AE_OK);
508
509 default:
510
511 return (AE_TYPE);
512 }
513}
514
515/*******************************************************************************
516 *
517 * FUNCTION: acpi_ut_execute_CID
518 *
519 * PARAMETERS: device_node - Node for the device
520 * return_cid_list - Where the CID list is returned
521 *
522 * RETURN: Status
523 *
524 * DESCRIPTION: Executes the _CID control method that returns one or more
525 * compatible hardware IDs for the device.
526 *
527 * NOTE: Internal function, no parameter validation
528 *
529 ******************************************************************************/
530
531acpi_status
532acpi_ut_execute_CID(struct acpi_namespace_node * device_node,
533 struct acpi_compatible_id_list ** return_cid_list)
534{
535 union acpi_operand_object *obj_desc;
536 acpi_status status;
537 u32 count;
538 u32 size;
539 struct acpi_compatible_id_list *cid_list;
540 u32 i;
541
542 ACPI_FUNCTION_TRACE(ut_execute_CID);
543
544 /* Evaluate the _CID method for this device */
545
546 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__CID,
547 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING
548 | ACPI_BTYPE_PACKAGE, &obj_desc);
549 if (ACPI_FAILURE(status)) {
550 return_ACPI_STATUS(status);
551 }
552
553 /* Get the number of _CIDs returned */
554
555 count = 1;
556 if (obj_desc->common.type == ACPI_TYPE_PACKAGE) {
557 count = obj_desc->package.count;
558 }
559
560 /* Allocate a worst-case buffer for the _CIDs */
561
562 size = (((count - 1) * sizeof(struct acpi_compatible_id)) +
563 sizeof(struct acpi_compatible_id_list));
564
565 cid_list = ACPI_ALLOCATE_ZEROED((acpi_size) size);
566 if (!cid_list) {
567 return_ACPI_STATUS(AE_NO_MEMORY);
568 }
569
570 /* Init CID list */
571
572 cid_list->count = count;
573 cid_list->size = size;
574
575 /*
576 * A _CID can return either a single compatible ID or a package of
577 * compatible IDs. Each compatible ID can be one of the following:
578 * 1) Integer (32 bit compressed EISA ID) or
579 * 2) String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss")
580 */
581
582 /* The _CID object can be either a single CID or a package (list) of CIDs */
583
584 if (obj_desc->common.type == ACPI_TYPE_PACKAGE) {
585
586 /* Translate each package element */
587
588 for (i = 0; i < count; i++) {
589 status =
590 acpi_ut_translate_one_cid(obj_desc->package.
591 elements[i],
592 &cid_list->id[i]);
593 if (ACPI_FAILURE(status)) {
594 break;
595 }
596 }
597 } else {
598 /* Only one CID, translate to a string */
599
600 status = acpi_ut_translate_one_cid(obj_desc, cid_list->id);
601 }
602
603 /* Cleanup on error */
604
605 if (ACPI_FAILURE(status)) {
606 ACPI_FREE(cid_list);
607 } else {
608 *return_cid_list = cid_list;
609 }
610
611 /* On exit, we must delete the _CID return object */
612
613 acpi_ut_remove_reference(obj_desc);
614 return_ACPI_STATUS(status);
615}
616
617/*******************************************************************************
618 *
619 * FUNCTION: acpi_ut_execute_UID
620 *
621 * PARAMETERS: device_node - Node for the device
622 * Uid - Where the UID is returned
623 *
624 * RETURN: Status
625 *
626 * DESCRIPTION: Executes the _UID control method that returns the hardware
627 * ID of the device.
628 *
629 * NOTE: Internal function, no parameter validation
630 *
631 ******************************************************************************/
632
633acpi_status
634acpi_ut_execute_UID(struct acpi_namespace_node *device_node,
635 struct acpica_device_id *uid)
636{
637 union acpi_operand_object *obj_desc;
638 acpi_status status;
639
640 ACPI_FUNCTION_TRACE(ut_execute_UID);
641
642 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__UID,
643 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING,
644 &obj_desc);
645 if (ACPI_FAILURE(status)) {
646 return_ACPI_STATUS(status);
647 }
648
649 if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
650
651 /* Convert the Numeric UID to string */
652
653 acpi_ex_unsigned_integer_to_string(obj_desc->integer.value,
654 uid->value);
655 } else {
656 /* Copy the String UID from the returned object */
657
658 acpi_ut_copy_id_string(uid->value, obj_desc->string.pointer,
659 sizeof(uid->value));
660 }
661 367
662 /* On exit, we must delete the return object */ 368 /* On exit, we must delete the return object */
663 369
@@ -716,60 +422,64 @@ acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 * flags)
716 422
717/******************************************************************************* 423/*******************************************************************************
718 * 424 *
719 * FUNCTION: acpi_ut_execute_Sxds 425 * FUNCTION: acpi_ut_execute_power_methods
720 * 426 *
721 * PARAMETERS: device_node - Node for the device 427 * PARAMETERS: device_node - Node for the device
722 * Flags - Where the status flags are returned 428 * method_names - Array of power method names
429 * method_count - Number of methods to execute
430 * out_values - Where the power method values are returned
723 * 431 *
724 * RETURN: Status 432 * RETURN: Status, out_values
725 * 433 *
726 * DESCRIPTION: Executes _STA for selected device and stores results in 434 * DESCRIPTION: Executes the specified power methods for the device and returns
727 * *Flags. 435 * the result(s).
728 * 436 *
729 * NOTE: Internal function, no parameter validation 437 * NOTE: Internal function, no parameter validation
730 * 438 *
731 ******************************************************************************/ 439******************************************************************************/
732 440
733acpi_status 441acpi_status
734acpi_ut_execute_sxds(struct acpi_namespace_node *device_node, u8 * highest) 442acpi_ut_execute_power_methods(struct acpi_namespace_node *device_node,
443 const char **method_names,
444 u8 method_count, u8 *out_values)
735{ 445{
736 union acpi_operand_object *obj_desc; 446 union acpi_operand_object *obj_desc;
737 acpi_status status; 447 acpi_status status;
448 acpi_status final_status = AE_NOT_FOUND;
738 u32 i; 449 u32 i;
739 450
740 ACPI_FUNCTION_TRACE(ut_execute_sxds); 451 ACPI_FUNCTION_TRACE(ut_execute_power_methods);
741 452
742 for (i = 0; i < 4; i++) { 453 for (i = 0; i < method_count; i++) {
743 highest[i] = 0xFF; 454 /*
455 * Execute the power method (_sx_d or _sx_w). The only allowable
456 * return type is an Integer.
457 */
744 status = acpi_ut_evaluate_object(device_node, 458 status = acpi_ut_evaluate_object(device_node,
745 ACPI_CAST_PTR(char, 459 ACPI_CAST_PTR(char,
746 acpi_gbl_highest_dstate_names 460 method_names[i]),
747 [i]),
748 ACPI_BTYPE_INTEGER, &obj_desc); 461 ACPI_BTYPE_INTEGER, &obj_desc);
749 if (ACPI_FAILURE(status)) { 462 if (ACPI_SUCCESS(status)) {
750 if (status != AE_NOT_FOUND) { 463 out_values[i] = (u8)obj_desc->integer.value;
751 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
752 "%s on Device %4.4s, %s\n",
753 ACPI_CAST_PTR(char,
754 acpi_gbl_highest_dstate_names
755 [i]),
756 acpi_ut_get_node_name
757 (device_node),
758 acpi_format_exception
759 (status)));
760
761 return_ACPI_STATUS(status);
762 }
763 } else {
764 /* Extract the Dstate value */
765
766 highest[i] = (u8) obj_desc->integer.value;
767 464
768 /* Delete the return object */ 465 /* Delete the return object */
769 466
770 acpi_ut_remove_reference(obj_desc); 467 acpi_ut_remove_reference(obj_desc);
468 final_status = AE_OK; /* At least one value is valid */
469 continue;
771 } 470 }
471
472 out_values[i] = ACPI_UINT8_MAX;
473 if (status == AE_NOT_FOUND) {
474 continue; /* Ignore if not found */
475 }
476
477 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
478 "Failed %s on Device %4.4s, %s\n",
479 ACPI_CAST_PTR(char, method_names[i]),
480 acpi_ut_get_node_name(device_node),
481 acpi_format_exception(status)));
772 } 482 }
773 483
774 return_ACPI_STATUS(AE_OK); 484 return_ACPI_STATUS(final_status);
775} 485}
diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c
index 59e46f257c02..3f2c68f4e959 100644
--- a/drivers/acpi/acpica/utglobal.c
+++ b/drivers/acpi/acpica/utglobal.c
@@ -90,7 +90,15 @@ const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT] = {
90 "\\_S5_" 90 "\\_S5_"
91}; 91};
92 92
93const char *acpi_gbl_highest_dstate_names[4] = { 93const char *acpi_gbl_lowest_dstate_names[ACPI_NUM_sx_w_METHODS] = {
94 "_S0W",
95 "_S1W",
96 "_S2W",
97 "_S3W",
98 "_S4W"
99};
100
101const char *acpi_gbl_highest_dstate_names[ACPI_NUM_sx_d_METHODS] = {
94 "_S1D", 102 "_S1D",
95 "_S2D", 103 "_S2D",
96 "_S3D", 104 "_S3D",
@@ -351,6 +359,7 @@ const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = {
351 "SMBus", 359 "SMBus",
352 "SystemCMOS", 360 "SystemCMOS",
353 "PCIBARTarget", 361 "PCIBARTarget",
362 "IPMI",
354 "DataTable" 363 "DataTable"
355}; 364};
356 365
@@ -798,6 +807,7 @@ acpi_status acpi_ut_init_globals(void)
798 807
799 /* Namespace */ 808 /* Namespace */
800 809
810 acpi_gbl_module_code_list = NULL;
801 acpi_gbl_root_node = NULL; 811 acpi_gbl_root_node = NULL;
802 acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME; 812 acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
803 acpi_gbl_root_node_struct.descriptor_type = ACPI_DESC_TYPE_NAMED; 813 acpi_gbl_root_node_struct.descriptor_type = ACPI_DESC_TYPE_NAMED;
diff --git a/drivers/acpi/acpica/utids.c b/drivers/acpi/acpica/utids.c
new file mode 100644
index 000000000000..52eaae404554
--- /dev/null
+++ b/drivers/acpi/acpica/utids.c
@@ -0,0 +1,382 @@
1/******************************************************************************
2 *
3 * Module Name: utids - support for device IDs - HID, UID, CID
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2009, 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 "acinterp.h"
47
48#define _COMPONENT ACPI_UTILITIES
49ACPI_MODULE_NAME("utids")
50
51/* Local prototypes */
52static void acpi_ut_copy_id_string(char *destination, char *source);
53
54/*******************************************************************************
55 *
56 * FUNCTION: acpi_ut_copy_id_string
57 *
58 * PARAMETERS: Destination - Where to copy the string
59 * Source - Source string
60 *
61 * RETURN: None
62 *
63 * DESCRIPTION: Copies an ID string for the _HID, _CID, and _UID methods.
64 * Performs removal of a leading asterisk if present -- workaround
65 * for a known issue on a bunch of machines.
66 *
67 ******************************************************************************/
68
69static void acpi_ut_copy_id_string(char *destination, char *source)
70{
71
72 /*
73 * Workaround for ID strings that have a leading asterisk. This construct
74 * is not allowed by the ACPI specification (ID strings must be
75 * alphanumeric), but enough existing machines have this embedded in their
76 * ID strings that the following code is useful.
77 */
78 if (*source == '*') {
79 source++;
80 }
81
82 /* Do the actual copy */
83
84 ACPI_STRCPY(destination, source);
85}
86
87/*******************************************************************************
88 *
89 * FUNCTION: acpi_ut_execute_HID
90 *
91 * PARAMETERS: device_node - Node for the device
92 * return_id - Where the string HID is returned
93 *
94 * RETURN: Status
95 *
96 * DESCRIPTION: Executes the _HID control method that returns the hardware
97 * ID of the device. The HID is either an 32-bit encoded EISAID
98 * Integer or a String. A string is always returned. An EISAID
99 * is converted to a string.
100 *
101 * NOTE: Internal function, no parameter validation
102 *
103 ******************************************************************************/
104
105acpi_status
106acpi_ut_execute_HID(struct acpi_namespace_node *device_node,
107 struct acpica_device_id **return_id)
108{
109 union acpi_operand_object *obj_desc;
110 struct acpica_device_id *hid;
111 u32 length;
112 acpi_status status;
113
114 ACPI_FUNCTION_TRACE(ut_execute_HID);
115
116 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__HID,
117 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING,
118 &obj_desc);
119 if (ACPI_FAILURE(status)) {
120 return_ACPI_STATUS(status);
121 }
122
123 /* Get the size of the String to be returned, includes null terminator */
124
125 if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
126 length = ACPI_EISAID_STRING_SIZE;
127 } else {
128 length = obj_desc->string.length + 1;
129 }
130
131 /* Allocate a buffer for the HID */
132
133 hid =
134 ACPI_ALLOCATE_ZEROED(sizeof(struct acpica_device_id) +
135 (acpi_size) length);
136 if (!hid) {
137 status = AE_NO_MEMORY;
138 goto cleanup;
139 }
140
141 /* Area for the string starts after DEVICE_ID struct */
142
143 hid->string = ACPI_ADD_PTR(char, hid, sizeof(struct acpica_device_id));
144
145 /* Convert EISAID to a string or simply copy existing string */
146
147 if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
148 acpi_ex_eisa_id_to_string(hid->string, obj_desc->integer.value);
149 } else {
150 acpi_ut_copy_id_string(hid->string, obj_desc->string.pointer);
151 }
152
153 hid->length = length;
154 *return_id = hid;
155
156cleanup:
157
158 /* On exit, we must delete the return object */
159
160 acpi_ut_remove_reference(obj_desc);
161 return_ACPI_STATUS(status);
162}
163
164/*******************************************************************************
165 *
166 * FUNCTION: acpi_ut_execute_UID
167 *
168 * PARAMETERS: device_node - Node for the device
169 * return_id - Where the string UID is returned
170 *
171 * RETURN: Status
172 *
173 * DESCRIPTION: Executes the _UID control method that returns the unique
174 * ID of the device. The UID is either a 64-bit Integer (NOT an
175 * EISAID) or a string. Always returns a string. A 64-bit integer
176 * is converted to a decimal string.
177 *
178 * NOTE: Internal function, no parameter validation
179 *
180 ******************************************************************************/
181
182acpi_status
183acpi_ut_execute_UID(struct acpi_namespace_node *device_node,
184 struct acpica_device_id **return_id)
185{
186 union acpi_operand_object *obj_desc;
187 struct acpica_device_id *uid;
188 u32 length;
189 acpi_status status;
190
191 ACPI_FUNCTION_TRACE(ut_execute_UID);
192
193 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__UID,
194 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING,
195 &obj_desc);
196 if (ACPI_FAILURE(status)) {
197 return_ACPI_STATUS(status);
198 }
199
200 /* Get the size of the String to be returned, includes null terminator */
201
202 if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
203 length = ACPI_MAX64_DECIMAL_DIGITS + 1;
204 } else {
205 length = obj_desc->string.length + 1;
206 }
207
208 /* Allocate a buffer for the UID */
209
210 uid =
211 ACPI_ALLOCATE_ZEROED(sizeof(struct acpica_device_id) +
212 (acpi_size) length);
213 if (!uid) {
214 status = AE_NO_MEMORY;
215 goto cleanup;
216 }
217
218 /* Area for the string starts after DEVICE_ID struct */
219
220 uid->string = ACPI_ADD_PTR(char, uid, sizeof(struct acpica_device_id));
221
222 /* Convert an Integer to string, or just copy an existing string */
223
224 if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
225 acpi_ex_integer_to_string(uid->string, obj_desc->integer.value);
226 } else {
227 acpi_ut_copy_id_string(uid->string, obj_desc->string.pointer);
228 }
229
230 uid->length = length;
231 *return_id = uid;
232
233cleanup:
234
235 /* On exit, we must delete the return object */
236
237 acpi_ut_remove_reference(obj_desc);
238 return_ACPI_STATUS(status);
239}
240
241/*******************************************************************************
242 *
243 * FUNCTION: acpi_ut_execute_CID
244 *
245 * PARAMETERS: device_node - Node for the device
246 * return_cid_list - Where the CID list is returned
247 *
248 * RETURN: Status, list of CID strings
249 *
250 * DESCRIPTION: Executes the _CID control method that returns one or more
251 * compatible hardware IDs for the device.
252 *
253 * NOTE: Internal function, no parameter validation
254 *
255 * A _CID method can return either a single compatible ID or a package of
256 * compatible IDs. Each compatible ID can be one of the following:
257 * 1) Integer (32 bit compressed EISA ID) or
258 * 2) String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss")
259 *
260 * The Integer CIDs are converted to string format by this function.
261 *
262 ******************************************************************************/
263
264acpi_status
265acpi_ut_execute_CID(struct acpi_namespace_node *device_node,
266 struct acpica_device_id_list **return_cid_list)
267{
268 union acpi_operand_object **cid_objects;
269 union acpi_operand_object *obj_desc;
270 struct acpica_device_id_list *cid_list;
271 char *next_id_string;
272 u32 string_area_size;
273 u32 length;
274 u32 cid_list_size;
275 acpi_status status;
276 u32 count;
277 u32 i;
278
279 ACPI_FUNCTION_TRACE(ut_execute_CID);
280
281 /* Evaluate the _CID method for this device */
282
283 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__CID,
284 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING
285 | ACPI_BTYPE_PACKAGE, &obj_desc);
286 if (ACPI_FAILURE(status)) {
287 return_ACPI_STATUS(status);
288 }
289
290 /*
291 * Get the count and size of the returned _CIDs. _CID can return either
292 * a Package of Integers/Strings or a single Integer or String.
293 * Note: This section also validates that all CID elements are of the
294 * correct type (Integer or String).
295 */
296 if (obj_desc->common.type == ACPI_TYPE_PACKAGE) {
297 count = obj_desc->package.count;
298 cid_objects = obj_desc->package.elements;
299 } else { /* Single Integer or String CID */
300
301 count = 1;
302 cid_objects = &obj_desc;
303 }
304
305 string_area_size = 0;
306 for (i = 0; i < count; i++) {
307
308 /* String lengths include null terminator */
309
310 switch (cid_objects[i]->common.type) {
311 case ACPI_TYPE_INTEGER:
312 string_area_size += ACPI_EISAID_STRING_SIZE;
313 break;
314
315 case ACPI_TYPE_STRING:
316 string_area_size += cid_objects[i]->string.length + 1;
317 break;
318
319 default:
320 status = AE_TYPE;
321 goto cleanup;
322 }
323 }
324
325 /*
326 * Now that we know the length of the CIDs, allocate return buffer:
327 * 1) Size of the base structure +
328 * 2) Size of the CID DEVICE_ID array +
329 * 3) Size of the actual CID strings
330 */
331 cid_list_size = sizeof(struct acpica_device_id_list) +
332 ((count - 1) * sizeof(struct acpica_device_id)) + string_area_size;
333
334 cid_list = ACPI_ALLOCATE_ZEROED(cid_list_size);
335 if (!cid_list) {
336 status = AE_NO_MEMORY;
337 goto cleanup;
338 }
339
340 /* Area for CID strings starts after the CID DEVICE_ID array */
341
342 next_id_string = ACPI_CAST_PTR(char, cid_list->ids) +
343 ((acpi_size) count * sizeof(struct acpica_device_id));
344
345 /* Copy/convert the CIDs to the return buffer */
346
347 for (i = 0; i < count; i++) {
348 if (cid_objects[i]->common.type == ACPI_TYPE_INTEGER) {
349
350 /* Convert the Integer (EISAID) CID to a string */
351
352 acpi_ex_eisa_id_to_string(next_id_string,
353 cid_objects[i]->integer.
354 value);
355 length = ACPI_EISAID_STRING_SIZE;
356 } else { /* ACPI_TYPE_STRING */
357
358 /* Copy the String CID from the returned object */
359
360 acpi_ut_copy_id_string(next_id_string,
361 cid_objects[i]->string.pointer);
362 length = cid_objects[i]->string.length + 1;
363 }
364
365 cid_list->ids[i].string = next_id_string;
366 cid_list->ids[i].length = length;
367 next_id_string += length;
368 }
369
370 /* Finish the CID list */
371
372 cid_list->count = count;
373 cid_list->list_size = cid_list_size;
374 *return_cid_list = cid_list;
375
376cleanup:
377
378 /* On exit, we must delete the _CID return object */
379
380 acpi_ut_remove_reference(obj_desc);
381 return_ACPI_STATUS(status);
382}
diff --git a/drivers/acpi/acpica/utinit.c b/drivers/acpi/acpica/utinit.c
index a54ca84eb362..9d0919ebf7b0 100644
--- a/drivers/acpi/acpica/utinit.c
+++ b/drivers/acpi/acpica/utinit.c
@@ -99,33 +99,19 @@ static void acpi_ut_terminate(void)
99 * 99 *
100 * FUNCTION: acpi_ut_subsystem_shutdown 100 * FUNCTION: acpi_ut_subsystem_shutdown
101 * 101 *
102 * PARAMETERS: none 102 * PARAMETERS: None
103 * 103 *
104 * RETURN: none 104 * RETURN: None
105 * 105 *
106 * DESCRIPTION: Shutdown the various subsystems. Don't delete the mutex 106 * DESCRIPTION: Shutdown the various components. Do not delete the mutex
107 * objects here -- because the AML debugger may be still running. 107 * objects here, because the AML debugger may be still running.
108 * 108 *
109 ******************************************************************************/ 109 ******************************************************************************/
110 110
111void acpi_ut_subsystem_shutdown(void) 111void acpi_ut_subsystem_shutdown(void)
112{ 112{
113
114 ACPI_FUNCTION_TRACE(ut_subsystem_shutdown); 113 ACPI_FUNCTION_TRACE(ut_subsystem_shutdown);
115 114
116 /* Just exit if subsystem is already shutdown */
117
118 if (acpi_gbl_shutdown) {
119 ACPI_ERROR((AE_INFO, "ACPI Subsystem is already terminated"));
120 return_VOID;
121 }
122
123 /* Subsystem appears active, go ahead and shut it down */
124
125 acpi_gbl_shutdown = TRUE;
126 acpi_gbl_startup_flags = 0;
127 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n"));
128
129#ifndef ACPI_ASL_COMPILER 115#ifndef ACPI_ASL_COMPILER
130 116
131 /* Close the acpi_event Handling */ 117 /* Close the acpi_event Handling */
diff --git a/drivers/acpi/acpica/utmisc.c b/drivers/acpi/acpica/utmisc.c
index fbe782348b0b..61f6315fce9f 100644
--- a/drivers/acpi/acpica/utmisc.c
+++ b/drivers/acpi/acpica/utmisc.c
@@ -50,6 +50,11 @@
50#define _COMPONENT ACPI_UTILITIES 50#define _COMPONENT ACPI_UTILITIES
51ACPI_MODULE_NAME("utmisc") 51ACPI_MODULE_NAME("utmisc")
52 52
53/*
54 * Common suffix for messages
55 */
56#define ACPI_COMMON_MSG_SUFFIX \
57 acpi_os_printf(" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, module_name, line_number)
53/******************************************************************************* 58/*******************************************************************************
54 * 59 *
55 * FUNCTION: acpi_ut_validate_exception 60 * FUNCTION: acpi_ut_validate_exception
@@ -120,6 +125,34 @@ const char *acpi_ut_validate_exception(acpi_status status)
120 125
121/******************************************************************************* 126/*******************************************************************************
122 * 127 *
128 * FUNCTION: acpi_ut_is_pci_root_bridge
129 *
130 * PARAMETERS: Id - The HID/CID in string format
131 *
132 * RETURN: TRUE if the Id is a match for a PCI/PCI-Express Root Bridge
133 *
134 * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID.
135 *
136 ******************************************************************************/
137
138u8 acpi_ut_is_pci_root_bridge(char *id)
139{
140
141 /*
142 * Check if this is a PCI root bridge.
143 * ACPI 3.0+: check for a PCI Express root also.
144 */
145 if (!(ACPI_STRCMP(id,
146 PCI_ROOT_HID_STRING)) ||
147 !(ACPI_STRCMP(id, PCI_EXPRESS_ROOT_HID_STRING))) {
148 return (TRUE);
149 }
150
151 return (FALSE);
152}
153
154/*******************************************************************************
155 *
123 * FUNCTION: acpi_ut_is_aml_table 156 * FUNCTION: acpi_ut_is_aml_table
124 * 157 *
125 * PARAMETERS: Table - An ACPI table 158 * PARAMETERS: Table - An ACPI table
@@ -1037,8 +1070,7 @@ acpi_error(const char *module_name, u32 line_number, const char *format, ...)
1037 1070
1038 va_start(args, format); 1071 va_start(args, format);
1039 acpi_os_vprintf(format, args); 1072 acpi_os_vprintf(format, args);
1040 acpi_os_printf(" %8.8X %s-%u\n", ACPI_CA_VERSION, module_name, 1073 ACPI_COMMON_MSG_SUFFIX;
1041 line_number);
1042 va_end(args); 1074 va_end(args);
1043} 1075}
1044 1076
@@ -1052,8 +1084,7 @@ acpi_exception(const char *module_name,
1052 1084
1053 va_start(args, format); 1085 va_start(args, format);
1054 acpi_os_vprintf(format, args); 1086 acpi_os_vprintf(format, args);
1055 acpi_os_printf(" %8.8X %s-%u\n", ACPI_CA_VERSION, module_name, 1087 ACPI_COMMON_MSG_SUFFIX;
1056 line_number);
1057 va_end(args); 1088 va_end(args);
1058} 1089}
1059 1090
@@ -1066,8 +1097,7 @@ acpi_warning(const char *module_name, u32 line_number, const char *format, ...)
1066 1097
1067 va_start(args, format); 1098 va_start(args, format);
1068 acpi_os_vprintf(format, args); 1099 acpi_os_vprintf(format, args);
1069 acpi_os_printf(" %8.8X %s-%u\n", ACPI_CA_VERSION, module_name, 1100 ACPI_COMMON_MSG_SUFFIX;
1070 line_number);
1071 va_end(args); 1101 va_end(args);
1072} 1102}
1073 1103
@@ -1088,3 +1118,46 @@ ACPI_EXPORT_SYMBOL(acpi_error)
1088ACPI_EXPORT_SYMBOL(acpi_exception) 1118ACPI_EXPORT_SYMBOL(acpi_exception)
1089ACPI_EXPORT_SYMBOL(acpi_warning) 1119ACPI_EXPORT_SYMBOL(acpi_warning)
1090ACPI_EXPORT_SYMBOL(acpi_info) 1120ACPI_EXPORT_SYMBOL(acpi_info)
1121
1122/*******************************************************************************
1123 *
1124 * FUNCTION: acpi_ut_predefined_warning
1125 *
1126 * PARAMETERS: module_name - Caller's module name (for error output)
1127 * line_number - Caller's line number (for error output)
1128 * Pathname - Full pathname to the node
1129 * node_flags - From Namespace node for the method/object
1130 * Format - Printf format string + additional args
1131 *
1132 * RETURN: None
1133 *
1134 * DESCRIPTION: Warnings for the predefined validation module. Messages are
1135 * only emitted the first time a problem with a particular
1136 * method/object is detected. This prevents a flood of error
1137 * messages for methods that are repeatedly evaluated.
1138 *
1139******************************************************************************/
1140
1141void ACPI_INTERNAL_VAR_XFACE
1142acpi_ut_predefined_warning(const char *module_name,
1143 u32 line_number,
1144 char *pathname,
1145 u8 node_flags, const char *format, ...)
1146{
1147 va_list args;
1148
1149 /*
1150 * Warning messages for this method/object will be disabled after the
1151 * first time a validation fails or an object is successfully repaired.
1152 */
1153 if (node_flags & ANOBJ_EVALUATED) {
1154 return;
1155 }
1156
1157 acpi_os_printf("ACPI Warning for %s: ", pathname);
1158
1159 va_start(args, format);
1160 acpi_os_vprintf(format, args);
1161 ACPI_COMMON_MSG_SUFFIX;
1162 va_end(args);
1163}
diff --git a/drivers/acpi/acpica/utxface.c b/drivers/acpi/acpica/utxface.c
index 078a22728c6b..b1f5f680bc78 100644
--- a/drivers/acpi/acpica/utxface.c
+++ b/drivers/acpi/acpica/utxface.c
@@ -251,6 +251,16 @@ acpi_status acpi_initialize_objects(u32 flags)
251 } 251 }
252 252
253 /* 253 /*
254 * Execute any module-level code that was detected during the table load
255 * phase. Although illegal since ACPI 2.0, there are many machines that
256 * contain this type of code. Each block of detected executable AML code
257 * outside of any control method is wrapped with a temporary control
258 * method object and placed on a global list. The methods on this list
259 * are executed below.
260 */
261 acpi_ns_exec_module_code_list();
262
263 /*
254 * Initialize the objects that remain uninitialized. This runs the 264 * Initialize the objects that remain uninitialized. This runs the
255 * executable AML that may be part of the declaration of these objects: 265 * executable AML that may be part of the declaration of these objects:
256 * operation_regions, buffer_fields, Buffers, and Packages. 266 * operation_regions, buffer_fields, Buffers, and Packages.
@@ -318,7 +328,7 @@ ACPI_EXPORT_SYMBOL(acpi_initialize_objects)
318 * 328 *
319 * RETURN: Status 329 * RETURN: Status
320 * 330 *
321 * DESCRIPTION: Shutdown the ACPI subsystem. Release all resources. 331 * DESCRIPTION: Shutdown the ACPICA subsystem and release all resources.
322 * 332 *
323 ******************************************************************************/ 333 ******************************************************************************/
324acpi_status acpi_terminate(void) 334acpi_status acpi_terminate(void)
@@ -327,6 +337,19 @@ acpi_status acpi_terminate(void)
327 337
328 ACPI_FUNCTION_TRACE(acpi_terminate); 338 ACPI_FUNCTION_TRACE(acpi_terminate);
329 339
340 /* Just exit if subsystem is already shutdown */
341
342 if (acpi_gbl_shutdown) {
343 ACPI_ERROR((AE_INFO, "ACPI Subsystem is already terminated"));
344 return_ACPI_STATUS(AE_OK);
345 }
346
347 /* Subsystem appears active, go ahead and shut it down */
348
349 acpi_gbl_shutdown = TRUE;
350 acpi_gbl_startup_flags = 0;
351 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n"));
352
330 /* Terminate the AML Debugger if present */ 353 /* Terminate the AML Debugger if present */
331 354
332 ACPI_DEBUGGER_EXEC(acpi_gbl_db_terminate_threads = TRUE); 355 ACPI_DEBUGGER_EXEC(acpi_gbl_db_terminate_threads = TRUE);
@@ -353,6 +376,7 @@ acpi_status acpi_terminate(void)
353} 376}
354 377
355ACPI_EXPORT_SYMBOL(acpi_terminate) 378ACPI_EXPORT_SYMBOL(acpi_terminate)
379
356#ifndef ACPI_ASL_COMPILER 380#ifndef ACPI_ASL_COMPILER
357#ifdef ACPI_FUTURE_USAGE 381#ifdef ACPI_FUTURE_USAGE
358/******************************************************************************* 382/*******************************************************************************
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 2876fc70c3a9..620183f13e5e 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -141,7 +141,7 @@ int acpi_bus_get_status(struct acpi_device *device)
141EXPORT_SYMBOL(acpi_bus_get_status); 141EXPORT_SYMBOL(acpi_bus_get_status);
142 142
143void acpi_bus_private_data_handler(acpi_handle handle, 143void acpi_bus_private_data_handler(acpi_handle handle,
144 u32 function, void *context) 144 void *context)
145{ 145{
146 return; 146 return;
147} 147}
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
index 5f2c3c00a315..642bb305cb65 100644
--- a/drivers/acpi/container.c
+++ b/drivers/acpi/container.c
@@ -202,20 +202,17 @@ container_walk_namespace_cb(acpi_handle handle,
202 u32 lvl, void *context, void **rv) 202 u32 lvl, void *context, void **rv)
203{ 203{
204 char *hid = NULL; 204 char *hid = NULL;
205 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
206 struct acpi_device_info *info; 205 struct acpi_device_info *info;
207 acpi_status status; 206 acpi_status status;
208 int *action = context; 207 int *action = context;
209 208
210 209 status = acpi_get_object_info(handle, &info);
211 status = acpi_get_object_info(handle, &buffer); 210 if (ACPI_FAILURE(status)) {
212 if (ACPI_FAILURE(status) || !buffer.pointer) {
213 return AE_OK; 211 return AE_OK;
214 } 212 }
215 213
216 info = buffer.pointer;
217 if (info->valid & ACPI_VALID_HID) 214 if (info->valid & ACPI_VALID_HID)
218 hid = info->hardware_id.value; 215 hid = info->hardware_id.string;
219 216
220 if (hid == NULL) { 217 if (hid == NULL) {
221 goto end; 218 goto end;
@@ -242,7 +239,7 @@ container_walk_namespace_cb(acpi_handle handle,
242 } 239 }
243 240
244 end: 241 end:
245 kfree(buffer.pointer); 242 kfree(info);
246 243
247 return AE_OK; 244 return AE_OK;
248} 245}
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 9a855669ff12..3a2cfefc71ab 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -233,18 +233,16 @@ static int is_ata(acpi_handle handle)
233static int is_battery(acpi_handle handle) 233static int is_battery(acpi_handle handle)
234{ 234{
235 struct acpi_device_info *info; 235 struct acpi_device_info *info;
236 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
237 int ret = 1; 236 int ret = 1;
238 237
239 if (!ACPI_SUCCESS(acpi_get_object_info(handle, &buffer))) 238 if (!ACPI_SUCCESS(acpi_get_object_info(handle, &info)))
240 return 0; 239 return 0;
241 info = buffer.pointer;
242 if (!(info->valid & ACPI_VALID_HID)) 240 if (!(info->valid & ACPI_VALID_HID))
243 ret = 0; 241 ret = 0;
244 else 242 else
245 ret = !strcmp("PNP0C0A", info->hardware_id.value); 243 ret = !strcmp("PNP0C0A", info->hardware_id.string);
246 244
247 kfree(buffer.pointer); 245 kfree(info);
248 return ret; 246 return ret;
249} 247}
250 248
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index dc36a448de43..c6645f26224b 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -95,15 +95,13 @@ do_acpi_find_child(acpi_handle handle, u32 lvl, void *context, void **rv)
95{ 95{
96 acpi_status status; 96 acpi_status status;
97 struct acpi_device_info *info; 97 struct acpi_device_info *info;
98 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
99 struct acpi_find_child *find = context; 98 struct acpi_find_child *find = context;
100 99
101 status = acpi_get_object_info(handle, &buffer); 100 status = acpi_get_object_info(handle, &info);
102 if (ACPI_SUCCESS(status)) { 101 if (ACPI_SUCCESS(status)) {
103 info = buffer.pointer;
104 if (info->address == find->address) 102 if (info->address == find->address)
105 find->handle = handle; 103 find->handle = handle;
106 kfree(buffer.pointer); 104 kfree(info);
107 } 105 }
108 return AE_OK; 106 return AE_OK;
109} 107}
@@ -123,7 +121,7 @@ EXPORT_SYMBOL(acpi_get_child);
123 121
124/* Link ACPI devices with physical devices */ 122/* Link ACPI devices with physical devices */
125static void acpi_glue_data_handler(acpi_handle handle, 123static void acpi_glue_data_handler(acpi_handle handle,
126 u32 function, void *context) 124 void *context)
127{ 125{
128 /* we provide an empty handler */ 126 /* we provide an empty handler */
129} 127}
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 5699d979596d..297d8b94fbbc 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -60,13 +60,13 @@ static int create_modalias(struct acpi_device *acpi_dev, char *modalias,
60 } 60 }
61 61
62 if (acpi_dev->flags.compatible_ids) { 62 if (acpi_dev->flags.compatible_ids) {
63 struct acpi_compatible_id_list *cid_list; 63 struct acpica_device_id_list *cid_list;
64 int i; 64 int i;
65 65
66 cid_list = acpi_dev->pnp.cid_list; 66 cid_list = acpi_dev->pnp.cid_list;
67 for (i = 0; i < cid_list->count; i++) { 67 for (i = 0; i < cid_list->count; i++) {
68 count = snprintf(&modalias[len], size, "%s:", 68 count = snprintf(&modalias[len], size, "%s:",
69 cid_list->id[i].value); 69 cid_list->ids[i].string);
70 if (count < 0 || count >= size) { 70 if (count < 0 || count >= size) {
71 printk(KERN_ERR PREFIX "%s cid[%i] exceeds event buffer size", 71 printk(KERN_ERR PREFIX "%s cid[%i] exceeds event buffer size",
72 acpi_dev->pnp.device_name, i); 72 acpi_dev->pnp.device_name, i);
@@ -287,14 +287,14 @@ int acpi_match_device_ids(struct acpi_device *device,
287 } 287 }
288 288
289 if (device->flags.compatible_ids) { 289 if (device->flags.compatible_ids) {
290 struct acpi_compatible_id_list *cid_list = device->pnp.cid_list; 290 struct acpica_device_id_list *cid_list = device->pnp.cid_list;
291 int i; 291 int i;
292 292
293 for (id = ids; id->id[0]; id++) { 293 for (id = ids; id->id[0]; id++) {
294 /* compare multiple _CID entries against driver ids */ 294 /* compare multiple _CID entries against driver ids */
295 for (i = 0; i < cid_list->count; i++) { 295 for (i = 0; i < cid_list->count; i++) {
296 if (!strcmp((char*)id->id, 296 if (!strcmp((char*)id->id,
297 cid_list->id[i].value)) 297 cid_list->ids[i].string))
298 return 0; 298 return 0;
299 } 299 }
300 } 300 }
@@ -309,6 +309,10 @@ static void acpi_device_release(struct device *dev)
309 struct acpi_device *acpi_dev = to_acpi_device(dev); 309 struct acpi_device *acpi_dev = to_acpi_device(dev);
310 310
311 kfree(acpi_dev->pnp.cid_list); 311 kfree(acpi_dev->pnp.cid_list);
312 if (acpi_dev->flags.hardware_id)
313 kfree(acpi_dev->pnp.hardware_id);
314 if (acpi_dev->flags.unique_id)
315 kfree(acpi_dev->pnp.unique_id);
312 kfree(acpi_dev); 316 kfree(acpi_dev);
313} 317}
314 318
@@ -687,7 +691,7 @@ acpi_bus_get_ejd(acpi_handle handle, acpi_handle *ejd)
687} 691}
688EXPORT_SYMBOL_GPL(acpi_bus_get_ejd); 692EXPORT_SYMBOL_GPL(acpi_bus_get_ejd);
689 693
690void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context) 694void acpi_bus_data_handler(acpi_handle handle, void *context)
691{ 695{
692 696
693 /* TBD */ 697 /* TBD */
@@ -1000,33 +1004,89 @@ static int acpi_dock_match(struct acpi_device *device)
1000 return acpi_get_handle(device->handle, "_DCK", &tmp); 1004 return acpi_get_handle(device->handle, "_DCK", &tmp);
1001} 1005}
1002 1006
1007static struct acpica_device_id_list*
1008acpi_add_cid(
1009 struct acpi_device_info *info,
1010 struct acpica_device_id *new_cid)
1011{
1012 struct acpica_device_id_list *cid;
1013 char *next_id_string;
1014 acpi_size cid_length;
1015 acpi_size new_cid_length;
1016 u32 i;
1017
1018
1019 /* Allocate new CID list with room for the new CID */
1020
1021 if (!new_cid)
1022 new_cid_length = info->compatible_id_list.list_size;
1023 else if (info->compatible_id_list.list_size)
1024 new_cid_length = info->compatible_id_list.list_size +
1025 new_cid->length + sizeof(struct acpica_device_id);
1026 else
1027 new_cid_length = sizeof(struct acpica_device_id_list) + new_cid->length;
1028
1029 cid = ACPI_ALLOCATE_ZEROED(new_cid_length);
1030 if (!cid) {
1031 return NULL;
1032 }
1033
1034 cid->list_size = new_cid_length;
1035 cid->count = info->compatible_id_list.count;
1036 if (new_cid)
1037 cid->count++;
1038 next_id_string = (char *) cid->ids + (cid->count * sizeof(struct acpica_device_id));
1039
1040 /* Copy all existing CIDs */
1041
1042 for (i = 0; i < info->compatible_id_list.count; i++) {
1043 cid_length = info->compatible_id_list.ids[i].length;
1044 cid->ids[i].string = next_id_string;
1045 cid->ids[i].length = cid_length;
1046
1047 ACPI_MEMCPY(next_id_string, info->compatible_id_list.ids[i].string,
1048 cid_length);
1049
1050 next_id_string += cid_length;
1051 }
1052
1053 /* Append the new CID */
1054
1055 if (new_cid) {
1056 cid->ids[i].string = next_id_string;
1057 cid->ids[i].length = new_cid->length;
1058
1059 ACPI_MEMCPY(next_id_string, new_cid->string, new_cid->length);
1060 }
1061
1062 return cid;
1063}
1064
1003static void acpi_device_set_id(struct acpi_device *device, 1065static void acpi_device_set_id(struct acpi_device *device,
1004 struct acpi_device *parent, acpi_handle handle, 1066 struct acpi_device *parent, acpi_handle handle,
1005 int type) 1067 int type)
1006{ 1068{
1007 struct acpi_device_info *info; 1069 struct acpi_device_info *info = NULL;
1008 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
1009 char *hid = NULL; 1070 char *hid = NULL;
1010 char *uid = NULL; 1071 char *uid = NULL;
1011 struct acpi_compatible_id_list *cid_list = NULL; 1072 struct acpica_device_id_list *cid_list = NULL;
1012 const char *cid_add = NULL; 1073 char *cid_add = NULL;
1013 acpi_status status; 1074 acpi_status status;
1014 1075
1015 switch (type) { 1076 switch (type) {
1016 case ACPI_BUS_TYPE_DEVICE: 1077 case ACPI_BUS_TYPE_DEVICE:
1017 status = acpi_get_object_info(handle, &buffer); 1078 status = acpi_get_object_info(handle, &info);
1018 if (ACPI_FAILURE(status)) { 1079 if (ACPI_FAILURE(status)) {
1019 printk(KERN_ERR PREFIX "%s: Error reading device info\n", __func__); 1080 printk(KERN_ERR PREFIX "%s: Error reading device info\n", __func__);
1020 return; 1081 return;
1021 } 1082 }
1022 1083
1023 info = buffer.pointer;
1024 if (info->valid & ACPI_VALID_HID) 1084 if (info->valid & ACPI_VALID_HID)
1025 hid = info->hardware_id.value; 1085 hid = info->hardware_id.string;
1026 if (info->valid & ACPI_VALID_UID) 1086 if (info->valid & ACPI_VALID_UID)
1027 uid = info->unique_id.value; 1087 uid = info->unique_id.string;
1028 if (info->valid & ACPI_VALID_CID) 1088 if (info->valid & ACPI_VALID_CID)
1029 cid_list = &info->compatibility_id; 1089 cid_list = &info->compatible_id_list;
1030 if (info->valid & ACPI_VALID_ADR) { 1090 if (info->valid & ACPI_VALID_ADR) {
1031 device->pnp.bus_address = info->address; 1091 device->pnp.bus_address = info->address;
1032 device->flags.bus_address = 1; 1092 device->flags.bus_address = 1;
@@ -1077,55 +1137,46 @@ static void acpi_device_set_id(struct acpi_device *device,
1077 } 1137 }
1078 1138
1079 if (hid) { 1139 if (hid) {
1080 strcpy(device->pnp.hardware_id, hid); 1140 device->pnp.hardware_id = ACPI_ALLOCATE_ZEROED(strlen (hid) + 1);
1081 device->flags.hardware_id = 1; 1141 if (device->pnp.hardware_id) {
1142 strcpy(device->pnp.hardware_id, hid);
1143 device->flags.hardware_id = 1;
1144 }
1082 } 1145 }
1146 if (!device->flags.hardware_id)
1147 device->pnp.hardware_id = "";
1148
1083 if (uid) { 1149 if (uid) {
1084 strcpy(device->pnp.unique_id, uid); 1150 device->pnp.unique_id = ACPI_ALLOCATE_ZEROED(strlen (uid) + 1);
1085 device->flags.unique_id = 1; 1151 if (device->pnp.unique_id) {
1152 strcpy(device->pnp.unique_id, uid);
1153 device->flags.unique_id = 1;
1154 }
1086 } 1155 }
1156 if (!device->flags.unique_id)
1157 device->pnp.unique_id = "";
1158
1087 if (cid_list || cid_add) { 1159 if (cid_list || cid_add) {
1088 struct acpi_compatible_id_list *list; 1160 struct acpica_device_id_list *list;
1089 int size = 0; 1161
1090 int count = 0; 1162 if (cid_add) {
1091 1163 struct acpica_device_id cid;
1092 if (cid_list) { 1164 cid.length = strlen (cid_add) + 1;
1093 size = cid_list->size; 1165 cid.string = cid_add;
1094 } else if (cid_add) { 1166
1095 size = sizeof(struct acpi_compatible_id_list); 1167 list = acpi_add_cid(info, &cid);
1096 cid_list = ACPI_ALLOCATE_ZEROED((acpi_size) size); 1168 } else {
1097 if (!cid_list) { 1169 list = acpi_add_cid(info, NULL);
1098 printk(KERN_ERR "Memory allocation error\n");
1099 kfree(buffer.pointer);
1100 return;
1101 } else {
1102 cid_list->count = 0;
1103 cid_list->size = size;
1104 }
1105 } 1170 }
1106 if (cid_add)
1107 size += sizeof(struct acpi_compatible_id);
1108 list = kmalloc(size, GFP_KERNEL);
1109 1171
1110 if (list) { 1172 if (list) {
1111 if (cid_list) {
1112 memcpy(list, cid_list, cid_list->size);
1113 count = cid_list->count;
1114 }
1115 if (cid_add) {
1116 strncpy(list->id[count].value, cid_add,
1117 ACPI_MAX_CID_LENGTH);
1118 count++;
1119 device->flags.compatible_ids = 1;
1120 }
1121 list->size = size;
1122 list->count = count;
1123 device->pnp.cid_list = list; 1173 device->pnp.cid_list = list;
1124 } else 1174 if (cid_add)
1125 printk(KERN_ERR PREFIX "Memory allocation error\n"); 1175 device->flags.compatible_ids = 1;
1176 }
1126 } 1177 }
1127 1178
1128 kfree(buffer.pointer); 1179 kfree(info);
1129} 1180}
1130 1181
1131static int acpi_device_set_context(struct acpi_device *device, int type) 1182static int acpi_device_set_context(struct acpi_device *device, int type)
@@ -1310,10 +1361,8 @@ acpi_add_single_object(struct acpi_device **child,
1310end: 1361end:
1311 if (!result) 1362 if (!result)
1312 *child = device; 1363 *child = device;
1313 else { 1364 else
1314 kfree(device->pnp.cid_list); 1365 acpi_device_release(&device->dev);
1315 kfree(device);
1316 }
1317 1366
1318 return result; 1367 return result;
1319} 1368}