diff options
author | Bob Moore <robert.moore@intel.com> | 2013-01-11 07:08:51 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-01-11 07:08:51 -0500 |
commit | 42f8fb75c43cc67f06424f991009b3af674f93eb (patch) | |
tree | 01821d5eca5f97d474bee62e7f92fe481adb31b8 /drivers/acpi/acpica | |
parent | 4f8429166818dd615891990040ce13373893ee9a (diff) |
ACPICA: Source restructuring: split large files into 8 new files.
Created logical splits for eight new files. Improves modularity
and configurability.
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/acpica')
-rw-r--r-- | drivers/acpi/acpica/Makefile | 8 | ||||
-rw-r--r-- | drivers/acpi/acpica/acdebug.h | 17 | ||||
-rw-r--r-- | drivers/acpi/acpica/acevents.h | 21 | ||||
-rw-r--r-- | drivers/acpi/acpica/acnamesp.h | 12 | ||||
-rw-r--r-- | drivers/acpi/acpica/acparser.h | 23 | ||||
-rw-r--r-- | drivers/acpi/acpica/acresrc.h | 6 | ||||
-rw-r--r-- | drivers/acpi/acpica/acutils.h | 50 | ||||
-rw-r--r-- | drivers/acpi/acpica/evhandler.c | 529 | ||||
-rw-r--r-- | drivers/acpi/acpica/evregion.c | 582 | ||||
-rw-r--r-- | drivers/acpi/acpica/nspredef.c | 581 | ||||
-rw-r--r-- | drivers/acpi/acpica/nsprepkg.c | 621 | ||||
-rw-r--r-- | drivers/acpi/acpica/psloop.c | 622 | ||||
-rw-r--r-- | drivers/acpi/acpica/psobject.c | 647 | ||||
-rw-r--r-- | drivers/acpi/acpica/psopcode.c | 172 | ||||
-rw-r--r-- | drivers/acpi/acpica/psopinfo.c | 223 | ||||
-rw-r--r-- | drivers/acpi/acpica/rsdump.c | 409 | ||||
-rw-r--r-- | drivers/acpi/acpica/rsdumpinfo.c | 454 | ||||
-rw-r--r-- | drivers/acpi/acpica/utmisc.c | 828 | ||||
-rw-r--r-- | drivers/acpi/acpica/utownerid.c | 218 | ||||
-rw-r--r-- | drivers/acpi/acpica/utstring.c | 574 |
20 files changed, 3494 insertions, 3103 deletions
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile index bc7a03ded064..a1b9bf5085a2 100644 --- a/drivers/acpi/acpica/Makefile +++ b/drivers/acpi/acpica/Makefile | |||
@@ -31,6 +31,7 @@ acpi-y += \ | |||
31 | evgpeinit.o \ | 31 | evgpeinit.o \ |
32 | evgpeutil.o \ | 32 | evgpeutil.o \ |
33 | evglock.o \ | 33 | evglock.o \ |
34 | evhandler.o \ | ||
34 | evmisc.o \ | 35 | evmisc.o \ |
35 | evregion.o \ | 36 | evregion.o \ |
36 | evrgnini.o \ | 37 | evrgnini.o \ |
@@ -90,6 +91,7 @@ acpi-y += \ | |||
90 | nsobject.o \ | 91 | nsobject.o \ |
91 | nsparse.o \ | 92 | nsparse.o \ |
92 | nspredef.o \ | 93 | nspredef.o \ |
94 | nsprepkg.o \ | ||
93 | nsrepair.o \ | 95 | nsrepair.o \ |
94 | nsrepair2.o \ | 96 | nsrepair2.o \ |
95 | nssearch.o \ | 97 | nssearch.o \ |
@@ -104,7 +106,9 @@ acpi-$(ACPI_FUTURE_USAGE) += nsdumpdv.o | |||
104 | acpi-y += \ | 106 | acpi-y += \ |
105 | psargs.o \ | 107 | psargs.o \ |
106 | psloop.o \ | 108 | psloop.o \ |
109 | psobject.o \ | ||
107 | psopcode.o \ | 110 | psopcode.o \ |
111 | psopinfo.o \ | ||
108 | psparse.o \ | 112 | psparse.o \ |
109 | psscope.o \ | 113 | psscope.o \ |
110 | pstree.o \ | 114 | pstree.o \ |
@@ -126,7 +130,7 @@ acpi-y += \ | |||
126 | rsutils.o \ | 130 | rsutils.o \ |
127 | rsxface.o | 131 | rsxface.o |
128 | 132 | ||
129 | acpi-$(ACPI_FUTURE_USAGE) += rsdump.o | 133 | acpi-$(ACPI_FUTURE_USAGE) += rsdump.o rsdumpinfo.o |
130 | 134 | ||
131 | acpi-y += \ | 135 | acpi-y += \ |
132 | tbfadt.o \ | 136 | tbfadt.o \ |
@@ -155,8 +159,10 @@ acpi-y += \ | |||
155 | utmutex.o \ | 159 | utmutex.o \ |
156 | utobject.o \ | 160 | utobject.o \ |
157 | utosi.o \ | 161 | utosi.o \ |
162 | utownerid.o \ | ||
158 | utresrc.o \ | 163 | utresrc.o \ |
159 | utstate.o \ | 164 | utstate.o \ |
165 | utstring.o \ | ||
160 | utxface.o \ | 166 | utxface.o \ |
161 | utxfinit.o \ | 167 | utxfinit.o \ |
162 | utxferror.o \ | 168 | utxferror.o \ |
diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h index 432a318c9ed1..c8dea18ccdc8 100644 --- a/drivers/acpi/acpica/acdebug.h +++ b/drivers/acpi/acpica/acdebug.h | |||
@@ -115,6 +115,21 @@ ACPI_HW_DEPENDENT_RETURN_VOID(void | |||
115 | char *block_arg)) | 115 | char *block_arg)) |
116 | 116 | ||
117 | /* | 117 | /* |
118 | * dbconvert - miscellaneous conversion routines | ||
119 | */ | ||
120 | acpi_status acpi_db_hex_char_to_value(int hex_char, u8 *return_value); | ||
121 | |||
122 | acpi_status acpi_db_convert_to_package(char *string, union acpi_object *object); | ||
123 | |||
124 | acpi_status | ||
125 | acpi_db_convert_to_object(acpi_object_type type, | ||
126 | char *string, union acpi_object *object); | ||
127 | |||
128 | u8 *acpi_db_encode_pld_buffer(struct acpi_pld_info *pld_info); | ||
129 | |||
130 | void acpi_db_dump_pld_buffer(union acpi_object *obj_desc); | ||
131 | |||
132 | /* | ||
118 | * dbmethod - control method commands | 133 | * dbmethod - control method commands |
119 | */ | 134 | */ |
120 | void | 135 | void |
@@ -191,6 +206,8 @@ void | |||
191 | acpi_db_create_execution_threads(char *num_threads_arg, | 206 | acpi_db_create_execution_threads(char *num_threads_arg, |
192 | char *num_loops_arg, char *method_name_arg); | 207 | char *num_loops_arg, char *method_name_arg); |
193 | 208 | ||
209 | void acpi_db_delete_objects(u32 count, union acpi_object *objects); | ||
210 | |||
194 | #ifdef ACPI_DBG_TRACK_ALLOCATIONS | 211 | #ifdef ACPI_DBG_TRACK_ALLOCATIONS |
195 | u32 acpi_db_get_cache_info(struct acpi_memory_list *cache); | 212 | u32 acpi_db_get_cache_info(struct acpi_memory_list *cache); |
196 | #endif | 213 | #endif |
diff --git a/drivers/acpi/acpica/acevents.h b/drivers/acpi/acpica/acevents.h index e975c6720448..35a2cbce467b 100644 --- a/drivers/acpi/acpica/acevents.h +++ b/drivers/acpi/acpica/acevents.h | |||
@@ -158,10 +158,23 @@ acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info, | |||
158 | void *context); | 158 | void *context); |
159 | 159 | ||
160 | /* | 160 | /* |
161 | * evregion - Address Space handling | 161 | * evhandler - Address space handling |
162 | */ | 162 | */ |
163 | u8 | ||
164 | acpi_ev_has_default_handler(struct acpi_namespace_node *node, | ||
165 | acpi_adr_space_type space_id); | ||
166 | |||
163 | acpi_status acpi_ev_install_region_handlers(void); | 167 | acpi_status acpi_ev_install_region_handlers(void); |
164 | 168 | ||
169 | acpi_status | ||
170 | acpi_ev_install_space_handler(struct acpi_namespace_node *node, | ||
171 | acpi_adr_space_type space_id, | ||
172 | acpi_adr_space_handler handler, | ||
173 | acpi_adr_space_setup setup, void *context); | ||
174 | |||
175 | /* | ||
176 | * evregion - Operation region support | ||
177 | */ | ||
165 | acpi_status acpi_ev_initialize_op_regions(void); | 178 | acpi_status acpi_ev_initialize_op_regions(void); |
166 | 179 | ||
167 | acpi_status | 180 | acpi_status |
@@ -180,12 +193,6 @@ acpi_ev_detach_region(union acpi_operand_object *region_obj, | |||
180 | u8 acpi_ns_is_locked); | 193 | u8 acpi_ns_is_locked); |
181 | 194 | ||
182 | acpi_status | 195 | acpi_status |
183 | acpi_ev_install_space_handler(struct acpi_namespace_node *node, | ||
184 | acpi_adr_space_type space_id, | ||
185 | acpi_adr_space_handler handler, | ||
186 | acpi_adr_space_setup setup, void *context); | ||
187 | |||
188 | acpi_status | ||
189 | acpi_ev_execute_reg_methods(struct acpi_namespace_node *node, | 196 | acpi_ev_execute_reg_methods(struct acpi_namespace_node *node, |
190 | acpi_adr_space_type space_id); | 197 | acpi_adr_space_type space_id); |
191 | 198 | ||
diff --git a/drivers/acpi/acpica/acnamesp.h b/drivers/acpi/acpica/acnamesp.h index b826d9c7aa73..bbfcd1b72b3b 100644 --- a/drivers/acpi/acpica/acnamesp.h +++ b/drivers/acpi/acpica/acnamesp.h | |||
@@ -218,6 +218,18 @@ acpi_ns_check_parameter_count(char *pathname, | |||
218 | u32 user_param_count, | 218 | u32 user_param_count, |
219 | const union acpi_predefined_info *info); | 219 | const union acpi_predefined_info *info); |
220 | 220 | ||
221 | acpi_status | ||
222 | acpi_ns_check_object_type(struct acpi_predefined_data *data, | ||
223 | union acpi_operand_object **return_object_ptr, | ||
224 | u32 expected_btypes, u32 package_index); | ||
225 | |||
226 | /* | ||
227 | * nsprepkg - Validation of predefined name packages | ||
228 | */ | ||
229 | acpi_status | ||
230 | acpi_ns_check_package(struct acpi_predefined_data *data, | ||
231 | union acpi_operand_object **return_object_ptr); | ||
232 | |||
221 | /* | 233 | /* |
222 | * nsnames - Name and Scope manipulation | 234 | * nsnames - Name and Scope manipulation |
223 | */ | 235 | */ |
diff --git a/drivers/acpi/acpica/acparser.h b/drivers/acpi/acpica/acparser.h index 24a59056eee1..e8f5726a1ab3 100644 --- a/drivers/acpi/acpica/acparser.h +++ b/drivers/acpi/acpica/acparser.h | |||
@@ -105,7 +105,28 @@ union acpi_parse_object *acpi_ps_find_name(union acpi_parse_object *scope, | |||
105 | union acpi_parse_object *acpi_ps_get_parent(union acpi_parse_object *op); | 105 | union acpi_parse_object *acpi_ps_get_parent(union acpi_parse_object *op); |
106 | 106 | ||
107 | /* | 107 | /* |
108 | * psopcode - AML Opcode information | 108 | * psobject - support for parse object processing |
109 | */ | ||
110 | acpi_status | ||
111 | acpi_ps_build_named_op(struct acpi_walk_state *walk_state, | ||
112 | u8 *aml_op_start, | ||
113 | union acpi_parse_object *unnamed_op, | ||
114 | union acpi_parse_object **op); | ||
115 | |||
116 | acpi_status | ||
117 | acpi_ps_create_op(struct acpi_walk_state *walk_state, | ||
118 | u8 *aml_op_start, union acpi_parse_object **new_op); | ||
119 | |||
120 | acpi_status | ||
121 | acpi_ps_complete_op(struct acpi_walk_state *walk_state, | ||
122 | union acpi_parse_object **op, acpi_status status); | ||
123 | |||
124 | acpi_status | ||
125 | acpi_ps_complete_final_op(struct acpi_walk_state *walk_state, | ||
126 | union acpi_parse_object *op, acpi_status status); | ||
127 | |||
128 | /* | ||
129 | * psopinfo - AML Opcode information | ||
109 | */ | 130 | */ |
110 | const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode); | 131 | const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode); |
111 | 132 | ||
diff --git a/drivers/acpi/acpica/acresrc.h b/drivers/acpi/acpica/acresrc.h index 0347d0993497..89bc3aa99ede 100644 --- a/drivers/acpi/acpica/acresrc.h +++ b/drivers/acpi/acpica/acresrc.h | |||
@@ -347,18 +347,21 @@ extern struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[]; | |||
347 | extern struct acpi_rsdump_info *acpi_gbl_dump_serial_bus_dispatch[]; | 347 | extern struct acpi_rsdump_info *acpi_gbl_dump_serial_bus_dispatch[]; |
348 | 348 | ||
349 | /* | 349 | /* |
350 | * rsdump | 350 | * rsdumpinfo |
351 | */ | 351 | */ |
352 | extern struct acpi_rsdump_info acpi_rs_dump_irq[]; | 352 | extern struct acpi_rsdump_info acpi_rs_dump_irq[]; |
353 | extern struct acpi_rsdump_info acpi_rs_dump_prt[]; | ||
353 | extern struct acpi_rsdump_info acpi_rs_dump_dma[]; | 354 | extern struct acpi_rsdump_info acpi_rs_dump_dma[]; |
354 | extern struct acpi_rsdump_info acpi_rs_dump_start_dpf[]; | 355 | extern struct acpi_rsdump_info acpi_rs_dump_start_dpf[]; |
355 | extern struct acpi_rsdump_info acpi_rs_dump_end_dpf[]; | 356 | extern struct acpi_rsdump_info acpi_rs_dump_end_dpf[]; |
356 | extern struct acpi_rsdump_info acpi_rs_dump_io[]; | 357 | extern struct acpi_rsdump_info acpi_rs_dump_io[]; |
358 | extern struct acpi_rsdump_info acpi_rs_dump_io_flags[]; | ||
357 | extern struct acpi_rsdump_info acpi_rs_dump_fixed_io[]; | 359 | extern struct acpi_rsdump_info acpi_rs_dump_fixed_io[]; |
358 | extern struct acpi_rsdump_info acpi_rs_dump_vendor[]; | 360 | extern struct acpi_rsdump_info acpi_rs_dump_vendor[]; |
359 | extern struct acpi_rsdump_info acpi_rs_dump_end_tag[]; | 361 | extern struct acpi_rsdump_info acpi_rs_dump_end_tag[]; |
360 | extern struct acpi_rsdump_info acpi_rs_dump_memory24[]; | 362 | extern struct acpi_rsdump_info acpi_rs_dump_memory24[]; |
361 | extern struct acpi_rsdump_info acpi_rs_dump_memory32[]; | 363 | extern struct acpi_rsdump_info acpi_rs_dump_memory32[]; |
364 | extern struct acpi_rsdump_info acpi_rs_dump_memory_flags[]; | ||
362 | extern struct acpi_rsdump_info acpi_rs_dump_fixed_memory32[]; | 365 | extern struct acpi_rsdump_info acpi_rs_dump_fixed_memory32[]; |
363 | extern struct acpi_rsdump_info acpi_rs_dump_address16[]; | 366 | extern struct acpi_rsdump_info acpi_rs_dump_address16[]; |
364 | extern struct acpi_rsdump_info acpi_rs_dump_address32[]; | 367 | extern struct acpi_rsdump_info acpi_rs_dump_address32[]; |
@@ -372,6 +375,7 @@ extern struct acpi_rsdump_info acpi_rs_dump_common_serial_bus[]; | |||
372 | extern struct acpi_rsdump_info acpi_rs_dump_i2c_serial_bus[]; | 375 | extern struct acpi_rsdump_info acpi_rs_dump_i2c_serial_bus[]; |
373 | extern struct acpi_rsdump_info acpi_rs_dump_spi_serial_bus[]; | 376 | extern struct acpi_rsdump_info acpi_rs_dump_spi_serial_bus[]; |
374 | extern struct acpi_rsdump_info acpi_rs_dump_uart_serial_bus[]; | 377 | extern struct acpi_rsdump_info acpi_rs_dump_uart_serial_bus[]; |
378 | extern struct acpi_rsdump_info acpi_rs_dump_general_flags[]; | ||
375 | #endif | 379 | #endif |
376 | 380 | ||
377 | #endif /* __ACRESRC_H__ */ | 381 | #endif /* __ACRESRC_H__ */ |
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h index 6e51d193c3eb..4e952111ca5a 100644 --- a/drivers/acpi/acpica/acutils.h +++ b/drivers/acpi/acpica/acutils.h | |||
@@ -483,39 +483,17 @@ acpi_ut_short_divide(u64 in_dividend, | |||
483 | /* | 483 | /* |
484 | * utmisc | 484 | * utmisc |
485 | */ | 485 | */ |
486 | void ut_convert_backslashes(char *pathname); | ||
487 | |||
488 | const char *acpi_ut_validate_exception(acpi_status status); | 486 | const char *acpi_ut_validate_exception(acpi_status status); |
489 | 487 | ||
490 | u8 acpi_ut_is_pci_root_bridge(char *id); | 488 | u8 acpi_ut_is_pci_root_bridge(char *id); |
491 | 489 | ||
492 | u8 acpi_ut_is_aml_table(struct acpi_table_header *table); | 490 | u8 acpi_ut_is_aml_table(struct acpi_table_header *table); |
493 | 491 | ||
494 | acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id); | ||
495 | |||
496 | void acpi_ut_release_owner_id(acpi_owner_id * owner_id); | ||
497 | |||
498 | acpi_status | 492 | acpi_status |
499 | acpi_ut_walk_package_tree(union acpi_operand_object *source_object, | 493 | acpi_ut_walk_package_tree(union acpi_operand_object *source_object, |
500 | void *target_object, | 494 | void *target_object, |
501 | acpi_pkg_callback walk_callback, void *context); | 495 | acpi_pkg_callback walk_callback, void *context); |
502 | 496 | ||
503 | void acpi_ut_strupr(char *src_string); | ||
504 | |||
505 | void acpi_ut_strlwr(char *src_string); | ||
506 | |||
507 | int acpi_ut_stricmp(char *string1, char *string2); | ||
508 | |||
509 | void acpi_ut_print_string(char *string, u8 max_length); | ||
510 | |||
511 | u8 acpi_ut_valid_acpi_name(u32 name); | ||
512 | |||
513 | void acpi_ut_repair_name(char *name); | ||
514 | |||
515 | u8 acpi_ut_valid_acpi_char(char character, u32 position); | ||
516 | |||
517 | acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer); | ||
518 | |||
519 | /* Values for Base above (16=Hex, 10=Decimal) */ | 497 | /* Values for Base above (16=Hex, 10=Decimal) */ |
520 | 498 | ||
521 | #define ACPI_ANY_BASE 0 | 499 | #define ACPI_ANY_BASE 0 |
@@ -532,6 +510,13 @@ acpi_ut_display_init_pathname(u8 type, | |||
532 | #endif | 510 | #endif |
533 | 511 | ||
534 | /* | 512 | /* |
513 | * utownerid - Support for Table/Method Owner IDs | ||
514 | */ | ||
515 | acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id); | ||
516 | |||
517 | void acpi_ut_release_owner_id(acpi_owner_id * owner_id); | ||
518 | |||
519 | /* | ||
535 | * utresrc | 520 | * utresrc |
536 | */ | 521 | */ |
537 | acpi_status | 522 | acpi_status |
@@ -557,6 +542,27 @@ acpi_status | |||
557 | acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc, u8 **end_tag); | 542 | acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc, u8 **end_tag); |
558 | 543 | ||
559 | /* | 544 | /* |
545 | * utstring - String and character utilities | ||
546 | */ | ||
547 | void acpi_ut_strupr(char *src_string); | ||
548 | |||
549 | void acpi_ut_strlwr(char *src_string); | ||
550 | |||
551 | int acpi_ut_stricmp(char *string1, char *string2); | ||
552 | |||
553 | acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer); | ||
554 | |||
555 | void acpi_ut_print_string(char *string, u8 max_length); | ||
556 | |||
557 | void ut_convert_backslashes(char *pathname); | ||
558 | |||
559 | u8 acpi_ut_valid_acpi_name(u32 name); | ||
560 | |||
561 | u8 acpi_ut_valid_acpi_char(char character, u32 position); | ||
562 | |||
563 | void acpi_ut_repair_name(char *name); | ||
564 | |||
565 | /* | ||
560 | * utmutex - mutex support | 566 | * utmutex - mutex support |
561 | */ | 567 | */ |
562 | acpi_status acpi_ut_mutex_initialize(void); | 568 | acpi_status acpi_ut_mutex_initialize(void); |
diff --git a/drivers/acpi/acpica/evhandler.c b/drivers/acpi/acpica/evhandler.c new file mode 100644 index 000000000000..95e52585bb9b --- /dev/null +++ b/drivers/acpi/acpica/evhandler.c | |||
@@ -0,0 +1,529 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: evhandler - Support for Address Space handlers | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2012, 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 "acevents.h" | ||
47 | #include "acnamesp.h" | ||
48 | #include "acinterp.h" | ||
49 | |||
50 | #define _COMPONENT ACPI_EVENTS | ||
51 | ACPI_MODULE_NAME("evhandler") | ||
52 | |||
53 | /* Local prototypes */ | ||
54 | static acpi_status | ||
55 | acpi_ev_install_handler(acpi_handle obj_handle, | ||
56 | u32 level, void *context, void **return_value); | ||
57 | |||
58 | /* These are the address spaces that will get default handlers */ | ||
59 | |||
60 | u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = { | ||
61 | ACPI_ADR_SPACE_SYSTEM_MEMORY, | ||
62 | ACPI_ADR_SPACE_SYSTEM_IO, | ||
63 | ACPI_ADR_SPACE_PCI_CONFIG, | ||
64 | ACPI_ADR_SPACE_DATA_TABLE | ||
65 | }; | ||
66 | |||
67 | /******************************************************************************* | ||
68 | * | ||
69 | * FUNCTION: acpi_ev_install_region_handlers | ||
70 | * | ||
71 | * PARAMETERS: None | ||
72 | * | ||
73 | * RETURN: Status | ||
74 | * | ||
75 | * DESCRIPTION: Installs the core subsystem default address space handlers. | ||
76 | * | ||
77 | ******************************************************************************/ | ||
78 | |||
79 | acpi_status acpi_ev_install_region_handlers(void) | ||
80 | { | ||
81 | acpi_status status; | ||
82 | u32 i; | ||
83 | |||
84 | ACPI_FUNCTION_TRACE(ev_install_region_handlers); | ||
85 | |||
86 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); | ||
87 | if (ACPI_FAILURE(status)) { | ||
88 | return_ACPI_STATUS(status); | ||
89 | } | ||
90 | |||
91 | /* | ||
92 | * All address spaces (PCI Config, EC, SMBus) are scope dependent and | ||
93 | * registration must occur for a specific device. | ||
94 | * | ||
95 | * In the case of the system memory and IO address spaces there is | ||
96 | * currently no device associated with the address space. For these we | ||
97 | * use the root. | ||
98 | * | ||
99 | * We install the default PCI config space handler at the root so that | ||
100 | * this space is immediately available even though the we have not | ||
101 | * enumerated all the PCI Root Buses yet. This is to conform to the ACPI | ||
102 | * specification which states that the PCI config space must be always | ||
103 | * available -- even though we are nowhere near ready to find the PCI root | ||
104 | * buses at this point. | ||
105 | * | ||
106 | * NOTE: We ignore AE_ALREADY_EXISTS because this means that a handler | ||
107 | * has already been installed (via acpi_install_address_space_handler). | ||
108 | * Similar for AE_SAME_HANDLER. | ||
109 | */ | ||
110 | for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) { | ||
111 | status = acpi_ev_install_space_handler(acpi_gbl_root_node, | ||
112 | acpi_gbl_default_address_spaces | ||
113 | [i], | ||
114 | ACPI_DEFAULT_HANDLER, | ||
115 | NULL, NULL); | ||
116 | switch (status) { | ||
117 | case AE_OK: | ||
118 | case AE_SAME_HANDLER: | ||
119 | case AE_ALREADY_EXISTS: | ||
120 | |||
121 | /* These exceptions are all OK */ | ||
122 | |||
123 | status = AE_OK; | ||
124 | break; | ||
125 | |||
126 | default: | ||
127 | |||
128 | goto unlock_and_exit; | ||
129 | } | ||
130 | } | ||
131 | |||
132 | unlock_and_exit: | ||
133 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | ||
134 | return_ACPI_STATUS(status); | ||
135 | } | ||
136 | |||
137 | /******************************************************************************* | ||
138 | * | ||
139 | * FUNCTION: acpi_ev_has_default_handler | ||
140 | * | ||
141 | * PARAMETERS: node - Namespace node for the device | ||
142 | * space_id - The address space ID | ||
143 | * | ||
144 | * RETURN: TRUE if default handler is installed, FALSE otherwise | ||
145 | * | ||
146 | * DESCRIPTION: Check if the default handler is installed for the requested | ||
147 | * space ID. | ||
148 | * | ||
149 | ******************************************************************************/ | ||
150 | |||
151 | u8 | ||
152 | acpi_ev_has_default_handler(struct acpi_namespace_node *node, | ||
153 | acpi_adr_space_type space_id) | ||
154 | { | ||
155 | union acpi_operand_object *obj_desc; | ||
156 | union acpi_operand_object *handler_obj; | ||
157 | |||
158 | /* Must have an existing internal object */ | ||
159 | |||
160 | obj_desc = acpi_ns_get_attached_object(node); | ||
161 | if (obj_desc) { | ||
162 | handler_obj = obj_desc->device.handler; | ||
163 | |||
164 | /* Walk the linked list of handlers for this object */ | ||
165 | |||
166 | while (handler_obj) { | ||
167 | if (handler_obj->address_space.space_id == space_id) { | ||
168 | if (handler_obj->address_space.handler_flags & | ||
169 | ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) { | ||
170 | return (TRUE); | ||
171 | } | ||
172 | } | ||
173 | |||
174 | handler_obj = handler_obj->address_space.next; | ||
175 | } | ||
176 | } | ||
177 | |||
178 | return (FALSE); | ||
179 | } | ||
180 | |||
181 | /******************************************************************************* | ||
182 | * | ||
183 | * FUNCTION: acpi_ev_install_handler | ||
184 | * | ||
185 | * PARAMETERS: walk_namespace callback | ||
186 | * | ||
187 | * DESCRIPTION: This routine installs an address handler into objects that are | ||
188 | * of type Region or Device. | ||
189 | * | ||
190 | * If the Object is a Device, and the device has a handler of | ||
191 | * the same type then the search is terminated in that branch. | ||
192 | * | ||
193 | * This is because the existing handler is closer in proximity | ||
194 | * to any more regions than the one we are trying to install. | ||
195 | * | ||
196 | ******************************************************************************/ | ||
197 | |||
198 | static acpi_status | ||
199 | acpi_ev_install_handler(acpi_handle obj_handle, | ||
200 | u32 level, void *context, void **return_value) | ||
201 | { | ||
202 | union acpi_operand_object *handler_obj; | ||
203 | union acpi_operand_object *next_handler_obj; | ||
204 | union acpi_operand_object *obj_desc; | ||
205 | struct acpi_namespace_node *node; | ||
206 | acpi_status status; | ||
207 | |||
208 | ACPI_FUNCTION_NAME(ev_install_handler); | ||
209 | |||
210 | handler_obj = (union acpi_operand_object *)context; | ||
211 | |||
212 | /* Parameter validation */ | ||
213 | |||
214 | if (!handler_obj) { | ||
215 | return (AE_OK); | ||
216 | } | ||
217 | |||
218 | /* Convert and validate the device handle */ | ||
219 | |||
220 | node = acpi_ns_validate_handle(obj_handle); | ||
221 | if (!node) { | ||
222 | return (AE_BAD_PARAMETER); | ||
223 | } | ||
224 | |||
225 | /* | ||
226 | * We only care about regions and objects that are allowed to have | ||
227 | * address space handlers | ||
228 | */ | ||
229 | if ((node->type != ACPI_TYPE_DEVICE) && | ||
230 | (node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) { | ||
231 | return (AE_OK); | ||
232 | } | ||
233 | |||
234 | /* Check for an existing internal object */ | ||
235 | |||
236 | obj_desc = acpi_ns_get_attached_object(node); | ||
237 | if (!obj_desc) { | ||
238 | |||
239 | /* No object, just exit */ | ||
240 | |||
241 | return (AE_OK); | ||
242 | } | ||
243 | |||
244 | /* Devices are handled different than regions */ | ||
245 | |||
246 | if (obj_desc->common.type == ACPI_TYPE_DEVICE) { | ||
247 | |||
248 | /* Check if this Device already has a handler for this address space */ | ||
249 | |||
250 | next_handler_obj = obj_desc->device.handler; | ||
251 | while (next_handler_obj) { | ||
252 | |||
253 | /* Found a handler, is it for the same address space? */ | ||
254 | |||
255 | if (next_handler_obj->address_space.space_id == | ||
256 | handler_obj->address_space.space_id) { | ||
257 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, | ||
258 | "Found handler for region [%s] in device %p(%p) " | ||
259 | "handler %p\n", | ||
260 | acpi_ut_get_region_name | ||
261 | (handler_obj->address_space. | ||
262 | space_id), obj_desc, | ||
263 | next_handler_obj, | ||
264 | handler_obj)); | ||
265 | |||
266 | /* | ||
267 | * Since the object we found it on was a device, then it | ||
268 | * means that someone has already installed a handler for | ||
269 | * the branch of the namespace from this device on. Just | ||
270 | * bail out telling the walk routine to not traverse this | ||
271 | * branch. This preserves the scoping rule for handlers. | ||
272 | */ | ||
273 | return (AE_CTRL_DEPTH); | ||
274 | } | ||
275 | |||
276 | /* Walk the linked list of handlers attached to this device */ | ||
277 | |||
278 | next_handler_obj = next_handler_obj->address_space.next; | ||
279 | } | ||
280 | |||
281 | /* | ||
282 | * As long as the device didn't have a handler for this space we | ||
283 | * don't care about it. We just ignore it and proceed. | ||
284 | */ | ||
285 | return (AE_OK); | ||
286 | } | ||
287 | |||
288 | /* Object is a Region */ | ||
289 | |||
290 | if (obj_desc->region.space_id != handler_obj->address_space.space_id) { | ||
291 | |||
292 | /* This region is for a different address space, just ignore it */ | ||
293 | |||
294 | return (AE_OK); | ||
295 | } | ||
296 | |||
297 | /* | ||
298 | * Now we have a region and it is for the handler's address space type. | ||
299 | * | ||
300 | * First disconnect region for any previous handler (if any) | ||
301 | */ | ||
302 | acpi_ev_detach_region(obj_desc, FALSE); | ||
303 | |||
304 | /* Connect the region to the new handler */ | ||
305 | |||
306 | status = acpi_ev_attach_region(handler_obj, obj_desc, FALSE); | ||
307 | return (status); | ||
308 | } | ||
309 | |||
310 | /******************************************************************************* | ||
311 | * | ||
312 | * FUNCTION: acpi_ev_install_space_handler | ||
313 | * | ||
314 | * PARAMETERS: node - Namespace node for the device | ||
315 | * space_id - The address space ID | ||
316 | * handler - Address of the handler | ||
317 | * setup - Address of the setup function | ||
318 | * context - Value passed to the handler on each access | ||
319 | * | ||
320 | * RETURN: Status | ||
321 | * | ||
322 | * DESCRIPTION: Install a handler for all op_regions of a given space_id. | ||
323 | * Assumes namespace is locked | ||
324 | * | ||
325 | ******************************************************************************/ | ||
326 | |||
327 | acpi_status | ||
328 | acpi_ev_install_space_handler(struct acpi_namespace_node * node, | ||
329 | acpi_adr_space_type space_id, | ||
330 | acpi_adr_space_handler handler, | ||
331 | acpi_adr_space_setup setup, void *context) | ||
332 | { | ||
333 | union acpi_operand_object *obj_desc; | ||
334 | union acpi_operand_object *handler_obj; | ||
335 | acpi_status status; | ||
336 | acpi_object_type type; | ||
337 | u8 flags = 0; | ||
338 | |||
339 | ACPI_FUNCTION_TRACE(ev_install_space_handler); | ||
340 | |||
341 | /* | ||
342 | * This registration is valid for only the types below and the root. This | ||
343 | * is where the default handlers get placed. | ||
344 | */ | ||
345 | if ((node->type != ACPI_TYPE_DEVICE) && | ||
346 | (node->type != ACPI_TYPE_PROCESSOR) && | ||
347 | (node->type != ACPI_TYPE_THERMAL) && (node != acpi_gbl_root_node)) { | ||
348 | status = AE_BAD_PARAMETER; | ||
349 | goto unlock_and_exit; | ||
350 | } | ||
351 | |||
352 | if (handler == ACPI_DEFAULT_HANDLER) { | ||
353 | flags = ACPI_ADDR_HANDLER_DEFAULT_INSTALLED; | ||
354 | |||
355 | switch (space_id) { | ||
356 | case ACPI_ADR_SPACE_SYSTEM_MEMORY: | ||
357 | handler = acpi_ex_system_memory_space_handler; | ||
358 | setup = acpi_ev_system_memory_region_setup; | ||
359 | break; | ||
360 | |||
361 | case ACPI_ADR_SPACE_SYSTEM_IO: | ||
362 | handler = acpi_ex_system_io_space_handler; | ||
363 | setup = acpi_ev_io_space_region_setup; | ||
364 | break; | ||
365 | |||
366 | case ACPI_ADR_SPACE_PCI_CONFIG: | ||
367 | handler = acpi_ex_pci_config_space_handler; | ||
368 | setup = acpi_ev_pci_config_region_setup; | ||
369 | break; | ||
370 | |||
371 | case ACPI_ADR_SPACE_CMOS: | ||
372 | handler = acpi_ex_cmos_space_handler; | ||
373 | setup = acpi_ev_cmos_region_setup; | ||
374 | break; | ||
375 | |||
376 | case ACPI_ADR_SPACE_PCI_BAR_TARGET: | ||
377 | handler = acpi_ex_pci_bar_space_handler; | ||
378 | setup = acpi_ev_pci_bar_region_setup; | ||
379 | break; | ||
380 | |||
381 | case ACPI_ADR_SPACE_DATA_TABLE: | ||
382 | handler = acpi_ex_data_table_space_handler; | ||
383 | setup = NULL; | ||
384 | break; | ||
385 | |||
386 | default: | ||
387 | status = AE_BAD_PARAMETER; | ||
388 | goto unlock_and_exit; | ||
389 | } | ||
390 | } | ||
391 | |||
392 | /* If the caller hasn't specified a setup routine, use the default */ | ||
393 | |||
394 | if (!setup) { | ||
395 | setup = acpi_ev_default_region_setup; | ||
396 | } | ||
397 | |||
398 | /* Check for an existing internal object */ | ||
399 | |||
400 | obj_desc = acpi_ns_get_attached_object(node); | ||
401 | if (obj_desc) { | ||
402 | /* | ||
403 | * The attached device object already exists. Make sure the handler | ||
404 | * is not already installed. | ||
405 | */ | ||
406 | handler_obj = obj_desc->device.handler; | ||
407 | |||
408 | /* Walk the handler list for this device */ | ||
409 | |||
410 | while (handler_obj) { | ||
411 | |||
412 | /* Same space_id indicates a handler already installed */ | ||
413 | |||
414 | if (handler_obj->address_space.space_id == space_id) { | ||
415 | if (handler_obj->address_space.handler == | ||
416 | handler) { | ||
417 | /* | ||
418 | * It is (relatively) OK to attempt to install the SAME | ||
419 | * handler twice. This can easily happen with the | ||
420 | * PCI_Config space. | ||
421 | */ | ||
422 | status = AE_SAME_HANDLER; | ||
423 | goto unlock_and_exit; | ||
424 | } else { | ||
425 | /* A handler is already installed */ | ||
426 | |||
427 | status = AE_ALREADY_EXISTS; | ||
428 | } | ||
429 | goto unlock_and_exit; | ||
430 | } | ||
431 | |||
432 | /* Walk the linked list of handlers */ | ||
433 | |||
434 | handler_obj = handler_obj->address_space.next; | ||
435 | } | ||
436 | } else { | ||
437 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, | ||
438 | "Creating object on Device %p while installing handler\n", | ||
439 | node)); | ||
440 | |||
441 | /* obj_desc does not exist, create one */ | ||
442 | |||
443 | if (node->type == ACPI_TYPE_ANY) { | ||
444 | type = ACPI_TYPE_DEVICE; | ||
445 | } else { | ||
446 | type = node->type; | ||
447 | } | ||
448 | |||
449 | obj_desc = acpi_ut_create_internal_object(type); | ||
450 | if (!obj_desc) { | ||
451 | status = AE_NO_MEMORY; | ||
452 | goto unlock_and_exit; | ||
453 | } | ||
454 | |||
455 | /* Init new descriptor */ | ||
456 | |||
457 | obj_desc->common.type = (u8)type; | ||
458 | |||
459 | /* Attach the new object to the Node */ | ||
460 | |||
461 | status = acpi_ns_attach_object(node, obj_desc, type); | ||
462 | |||
463 | /* Remove local reference to the object */ | ||
464 | |||
465 | acpi_ut_remove_reference(obj_desc); | ||
466 | |||
467 | if (ACPI_FAILURE(status)) { | ||
468 | goto unlock_and_exit; | ||
469 | } | ||
470 | } | ||
471 | |||
472 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, | ||
473 | "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n", | ||
474 | acpi_ut_get_region_name(space_id), space_id, | ||
475 | acpi_ut_get_node_name(node), node, obj_desc)); | ||
476 | |||
477 | /* | ||
478 | * Install the handler | ||
479 | * | ||
480 | * At this point there is no existing handler. Just allocate the object | ||
481 | * for the handler and link it into the list. | ||
482 | */ | ||
483 | handler_obj = | ||
484 | acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_ADDRESS_HANDLER); | ||
485 | if (!handler_obj) { | ||
486 | status = AE_NO_MEMORY; | ||
487 | goto unlock_and_exit; | ||
488 | } | ||
489 | |||
490 | /* Init handler obj */ | ||
491 | |||
492 | handler_obj->address_space.space_id = (u8)space_id; | ||
493 | handler_obj->address_space.handler_flags = flags; | ||
494 | handler_obj->address_space.region_list = NULL; | ||
495 | handler_obj->address_space.node = node; | ||
496 | handler_obj->address_space.handler = handler; | ||
497 | handler_obj->address_space.context = context; | ||
498 | handler_obj->address_space.setup = setup; | ||
499 | |||
500 | /* Install at head of Device.address_space list */ | ||
501 | |||
502 | handler_obj->address_space.next = obj_desc->device.handler; | ||
503 | |||
504 | /* | ||
505 | * The Device object is the first reference on the handler_obj. | ||
506 | * Each region that uses the handler adds a reference. | ||
507 | */ | ||
508 | obj_desc->device.handler = handler_obj; | ||
509 | |||
510 | /* | ||
511 | * Walk the namespace finding all of the regions this | ||
512 | * handler will manage. | ||
513 | * | ||
514 | * Start at the device and search the branch toward | ||
515 | * the leaf nodes until either the leaf is encountered or | ||
516 | * a device is detected that has an address handler of the | ||
517 | * same type. | ||
518 | * | ||
519 | * In either case, back up and search down the remainder | ||
520 | * of the branch | ||
521 | */ | ||
522 | status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX, | ||
523 | ACPI_NS_WALK_UNLOCK, | ||
524 | acpi_ev_install_handler, NULL, | ||
525 | handler_obj, NULL); | ||
526 | |||
527 | unlock_and_exit: | ||
528 | return_ACPI_STATUS(status); | ||
529 | } | ||
diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c index 0cc6a16fedc7..d1fa91d0b5b1 100644 --- a/drivers/acpi/acpica/evregion.c +++ b/drivers/acpi/acpica/evregion.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /****************************************************************************** | 1 | /****************************************************************************** |
2 | * | 2 | * |
3 | * Module Name: evregion - ACPI address_space (op_region) handler dispatch | 3 | * Module Name: evregion - Operation Region support |
4 | * | 4 | * |
5 | *****************************************************************************/ | 5 | *****************************************************************************/ |
6 | 6 | ||
@@ -50,10 +50,9 @@ | |||
50 | #define _COMPONENT ACPI_EVENTS | 50 | #define _COMPONENT ACPI_EVENTS |
51 | ACPI_MODULE_NAME("evregion") | 51 | ACPI_MODULE_NAME("evregion") |
52 | 52 | ||
53 | extern u8 acpi_gbl_default_address_spaces[]; | ||
54 | |||
53 | /* Local prototypes */ | 55 | /* Local prototypes */ |
54 | static u8 | ||
55 | acpi_ev_has_default_handler(struct acpi_namespace_node *node, | ||
56 | acpi_adr_space_type space_id); | ||
57 | 56 | ||
58 | static void acpi_ev_orphan_ec_reg_method(void); | 57 | static void acpi_ev_orphan_ec_reg_method(void); |
59 | 58 | ||
@@ -61,135 +60,6 @@ static acpi_status | |||
61 | acpi_ev_reg_run(acpi_handle obj_handle, | 60 | acpi_ev_reg_run(acpi_handle obj_handle, |
62 | u32 level, void *context, void **return_value); | 61 | u32 level, void *context, void **return_value); |
63 | 62 | ||
64 | static acpi_status | ||
65 | acpi_ev_install_handler(acpi_handle obj_handle, | ||
66 | u32 level, void *context, void **return_value); | ||
67 | |||
68 | /* These are the address spaces that will get default handlers */ | ||
69 | |||
70 | #define ACPI_NUM_DEFAULT_SPACES 4 | ||
71 | |||
72 | static u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = { | ||
73 | ACPI_ADR_SPACE_SYSTEM_MEMORY, | ||
74 | ACPI_ADR_SPACE_SYSTEM_IO, | ||
75 | ACPI_ADR_SPACE_PCI_CONFIG, | ||
76 | ACPI_ADR_SPACE_DATA_TABLE | ||
77 | }; | ||
78 | |||
79 | /******************************************************************************* | ||
80 | * | ||
81 | * FUNCTION: acpi_ev_install_region_handlers | ||
82 | * | ||
83 | * PARAMETERS: None | ||
84 | * | ||
85 | * RETURN: Status | ||
86 | * | ||
87 | * DESCRIPTION: Installs the core subsystem default address space handlers. | ||
88 | * | ||
89 | ******************************************************************************/ | ||
90 | |||
91 | acpi_status acpi_ev_install_region_handlers(void) | ||
92 | { | ||
93 | acpi_status status; | ||
94 | u32 i; | ||
95 | |||
96 | ACPI_FUNCTION_TRACE(ev_install_region_handlers); | ||
97 | |||
98 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); | ||
99 | if (ACPI_FAILURE(status)) { | ||
100 | return_ACPI_STATUS(status); | ||
101 | } | ||
102 | |||
103 | /* | ||
104 | * All address spaces (PCI Config, EC, SMBus) are scope dependent and | ||
105 | * registration must occur for a specific device. | ||
106 | * | ||
107 | * In the case of the system memory and IO address spaces there is | ||
108 | * currently no device associated with the address space. For these we | ||
109 | * use the root. | ||
110 | * | ||
111 | * We install the default PCI config space handler at the root so that | ||
112 | * this space is immediately available even though the we have not | ||
113 | * enumerated all the PCI Root Buses yet. This is to conform to the ACPI | ||
114 | * specification which states that the PCI config space must be always | ||
115 | * available -- even though we are nowhere near ready to find the PCI root | ||
116 | * buses at this point. | ||
117 | * | ||
118 | * NOTE: We ignore AE_ALREADY_EXISTS because this means that a handler | ||
119 | * has already been installed (via acpi_install_address_space_handler). | ||
120 | * Similar for AE_SAME_HANDLER. | ||
121 | */ | ||
122 | for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) { | ||
123 | status = acpi_ev_install_space_handler(acpi_gbl_root_node, | ||
124 | acpi_gbl_default_address_spaces | ||
125 | [i], | ||
126 | ACPI_DEFAULT_HANDLER, | ||
127 | NULL, NULL); | ||
128 | switch (status) { | ||
129 | case AE_OK: | ||
130 | case AE_SAME_HANDLER: | ||
131 | case AE_ALREADY_EXISTS: | ||
132 | |||
133 | /* These exceptions are all OK */ | ||
134 | |||
135 | status = AE_OK; | ||
136 | break; | ||
137 | |||
138 | default: | ||
139 | |||
140 | goto unlock_and_exit; | ||
141 | } | ||
142 | } | ||
143 | |||
144 | unlock_and_exit: | ||
145 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | ||
146 | return_ACPI_STATUS(status); | ||
147 | } | ||
148 | |||
149 | /******************************************************************************* | ||
150 | * | ||
151 | * FUNCTION: acpi_ev_has_default_handler | ||
152 | * | ||
153 | * PARAMETERS: node - Namespace node for the device | ||
154 | * space_id - The address space ID | ||
155 | * | ||
156 | * RETURN: TRUE if default handler is installed, FALSE otherwise | ||
157 | * | ||
158 | * DESCRIPTION: Check if the default handler is installed for the requested | ||
159 | * space ID. | ||
160 | * | ||
161 | ******************************************************************************/ | ||
162 | |||
163 | static u8 | ||
164 | acpi_ev_has_default_handler(struct acpi_namespace_node *node, | ||
165 | acpi_adr_space_type space_id) | ||
166 | { | ||
167 | union acpi_operand_object *obj_desc; | ||
168 | union acpi_operand_object *handler_obj; | ||
169 | |||
170 | /* Must have an existing internal object */ | ||
171 | |||
172 | obj_desc = acpi_ns_get_attached_object(node); | ||
173 | if (obj_desc) { | ||
174 | handler_obj = obj_desc->device.handler; | ||
175 | |||
176 | /* Walk the linked list of handlers for this object */ | ||
177 | |||
178 | while (handler_obj) { | ||
179 | if (handler_obj->address_space.space_id == space_id) { | ||
180 | if (handler_obj->address_space.handler_flags & | ||
181 | ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) { | ||
182 | return (TRUE); | ||
183 | } | ||
184 | } | ||
185 | |||
186 | handler_obj = handler_obj->address_space.next; | ||
187 | } | ||
188 | } | ||
189 | |||
190 | return (FALSE); | ||
191 | } | ||
192 | |||
193 | /******************************************************************************* | 63 | /******************************************************************************* |
194 | * | 64 | * |
195 | * FUNCTION: acpi_ev_initialize_op_regions | 65 | * FUNCTION: acpi_ev_initialize_op_regions |
@@ -241,91 +111,6 @@ acpi_status acpi_ev_initialize_op_regions(void) | |||
241 | 111 | ||
242 | /******************************************************************************* | 112 | /******************************************************************************* |
243 | * | 113 | * |
244 | * FUNCTION: acpi_ev_execute_reg_method | ||
245 | * | ||
246 | * PARAMETERS: region_obj - Region object | ||
247 | * function - Passed to _REG: On (1) or Off (0) | ||
248 | * | ||
249 | * RETURN: Status | ||
250 | * | ||
251 | * DESCRIPTION: Execute _REG method for a region | ||
252 | * | ||
253 | ******************************************************************************/ | ||
254 | |||
255 | acpi_status | ||
256 | acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function) | ||
257 | { | ||
258 | struct acpi_evaluate_info *info; | ||
259 | union acpi_operand_object *args[3]; | ||
260 | union acpi_operand_object *region_obj2; | ||
261 | acpi_status status; | ||
262 | |||
263 | ACPI_FUNCTION_TRACE(ev_execute_reg_method); | ||
264 | |||
265 | region_obj2 = acpi_ns_get_secondary_object(region_obj); | ||
266 | if (!region_obj2) { | ||
267 | return_ACPI_STATUS(AE_NOT_EXIST); | ||
268 | } | ||
269 | |||
270 | if (region_obj2->extra.method_REG == NULL) { | ||
271 | return_ACPI_STATUS(AE_OK); | ||
272 | } | ||
273 | |||
274 | /* Allocate and initialize the evaluation information block */ | ||
275 | |||
276 | info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info)); | ||
277 | if (!info) { | ||
278 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
279 | } | ||
280 | |||
281 | info->prefix_node = region_obj2->extra.method_REG; | ||
282 | info->pathname = NULL; | ||
283 | info->parameters = args; | ||
284 | info->flags = ACPI_IGNORE_RETURN_VALUE; | ||
285 | |||
286 | /* | ||
287 | * The _REG method has two arguments: | ||
288 | * | ||
289 | * arg0 - Integer: | ||
290 | * Operation region space ID Same value as region_obj->Region.space_id | ||
291 | * | ||
292 | * arg1 - Integer: | ||
293 | * connection status 1 for connecting the handler, 0 for disconnecting | ||
294 | * the handler (Passed as a parameter) | ||
295 | */ | ||
296 | args[0] = | ||
297 | acpi_ut_create_integer_object((u64) region_obj->region.space_id); | ||
298 | if (!args[0]) { | ||
299 | status = AE_NO_MEMORY; | ||
300 | goto cleanup1; | ||
301 | } | ||
302 | |||
303 | args[1] = acpi_ut_create_integer_object((u64) function); | ||
304 | if (!args[1]) { | ||
305 | status = AE_NO_MEMORY; | ||
306 | goto cleanup2; | ||
307 | } | ||
308 | |||
309 | args[2] = NULL; /* Terminate list */ | ||
310 | |||
311 | /* Execute the method, no return value */ | ||
312 | |||
313 | ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname | ||
314 | (ACPI_TYPE_METHOD, info->prefix_node, NULL)); | ||
315 | |||
316 | status = acpi_ns_evaluate(info); | ||
317 | acpi_ut_remove_reference(args[1]); | ||
318 | |||
319 | cleanup2: | ||
320 | acpi_ut_remove_reference(args[0]); | ||
321 | |||
322 | cleanup1: | ||
323 | ACPI_FREE(info); | ||
324 | return_ACPI_STATUS(status); | ||
325 | } | ||
326 | |||
327 | /******************************************************************************* | ||
328 | * | ||
329 | * FUNCTION: acpi_ev_address_space_dispatch | 114 | * FUNCTION: acpi_ev_address_space_dispatch |
330 | * | 115 | * |
331 | * PARAMETERS: region_obj - Internal region object | 116 | * PARAMETERS: region_obj - Internal region object |
@@ -709,351 +494,86 @@ acpi_ev_attach_region(union acpi_operand_object *handler_obj, | |||
709 | 494 | ||
710 | /******************************************************************************* | 495 | /******************************************************************************* |
711 | * | 496 | * |
712 | * FUNCTION: acpi_ev_install_handler | 497 | * FUNCTION: acpi_ev_execute_reg_method |
713 | * | ||
714 | * PARAMETERS: walk_namespace callback | ||
715 | * | ||
716 | * DESCRIPTION: This routine installs an address handler into objects that are | ||
717 | * of type Region or Device. | ||
718 | * | ||
719 | * If the Object is a Device, and the device has a handler of | ||
720 | * the same type then the search is terminated in that branch. | ||
721 | * | ||
722 | * This is because the existing handler is closer in proximity | ||
723 | * to any more regions than the one we are trying to install. | ||
724 | * | ||
725 | ******************************************************************************/ | ||
726 | |||
727 | static acpi_status | ||
728 | acpi_ev_install_handler(acpi_handle obj_handle, | ||
729 | u32 level, void *context, void **return_value) | ||
730 | { | ||
731 | union acpi_operand_object *handler_obj; | ||
732 | union acpi_operand_object *next_handler_obj; | ||
733 | union acpi_operand_object *obj_desc; | ||
734 | struct acpi_namespace_node *node; | ||
735 | acpi_status status; | ||
736 | |||
737 | ACPI_FUNCTION_NAME(ev_install_handler); | ||
738 | |||
739 | handler_obj = (union acpi_operand_object *)context; | ||
740 | |||
741 | /* Parameter validation */ | ||
742 | |||
743 | if (!handler_obj) { | ||
744 | return (AE_OK); | ||
745 | } | ||
746 | |||
747 | /* Convert and validate the device handle */ | ||
748 | |||
749 | node = acpi_ns_validate_handle(obj_handle); | ||
750 | if (!node) { | ||
751 | return (AE_BAD_PARAMETER); | ||
752 | } | ||
753 | |||
754 | /* | ||
755 | * We only care about regions and objects that are allowed to have | ||
756 | * address space handlers | ||
757 | */ | ||
758 | if ((node->type != ACPI_TYPE_DEVICE) && | ||
759 | (node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) { | ||
760 | return (AE_OK); | ||
761 | } | ||
762 | |||
763 | /* Check for an existing internal object */ | ||
764 | |||
765 | obj_desc = acpi_ns_get_attached_object(node); | ||
766 | if (!obj_desc) { | ||
767 | |||
768 | /* No object, just exit */ | ||
769 | |||
770 | return (AE_OK); | ||
771 | } | ||
772 | |||
773 | /* Devices are handled different than regions */ | ||
774 | |||
775 | if (obj_desc->common.type == ACPI_TYPE_DEVICE) { | ||
776 | |||
777 | /* Check if this Device already has a handler for this address space */ | ||
778 | |||
779 | next_handler_obj = obj_desc->device.handler; | ||
780 | while (next_handler_obj) { | ||
781 | |||
782 | /* Found a handler, is it for the same address space? */ | ||
783 | |||
784 | if (next_handler_obj->address_space.space_id == | ||
785 | handler_obj->address_space.space_id) { | ||
786 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, | ||
787 | "Found handler for region [%s] in device %p(%p) " | ||
788 | "handler %p\n", | ||
789 | acpi_ut_get_region_name | ||
790 | (handler_obj->address_space. | ||
791 | space_id), obj_desc, | ||
792 | next_handler_obj, | ||
793 | handler_obj)); | ||
794 | |||
795 | /* | ||
796 | * Since the object we found it on was a device, then it | ||
797 | * means that someone has already installed a handler for | ||
798 | * the branch of the namespace from this device on. Just | ||
799 | * bail out telling the walk routine to not traverse this | ||
800 | * branch. This preserves the scoping rule for handlers. | ||
801 | */ | ||
802 | return (AE_CTRL_DEPTH); | ||
803 | } | ||
804 | |||
805 | /* Walk the linked list of handlers attached to this device */ | ||
806 | |||
807 | next_handler_obj = next_handler_obj->address_space.next; | ||
808 | } | ||
809 | |||
810 | /* | ||
811 | * As long as the device didn't have a handler for this space we | ||
812 | * don't care about it. We just ignore it and proceed. | ||
813 | */ | ||
814 | return (AE_OK); | ||
815 | } | ||
816 | |||
817 | /* Object is a Region */ | ||
818 | |||
819 | if (obj_desc->region.space_id != handler_obj->address_space.space_id) { | ||
820 | |||
821 | /* This region is for a different address space, just ignore it */ | ||
822 | |||
823 | return (AE_OK); | ||
824 | } | ||
825 | |||
826 | /* | ||
827 | * Now we have a region and it is for the handler's address space type. | ||
828 | * | ||
829 | * First disconnect region for any previous handler (if any) | ||
830 | */ | ||
831 | acpi_ev_detach_region(obj_desc, FALSE); | ||
832 | |||
833 | /* Connect the region to the new handler */ | ||
834 | |||
835 | status = acpi_ev_attach_region(handler_obj, obj_desc, FALSE); | ||
836 | return (status); | ||
837 | } | ||
838 | |||
839 | /******************************************************************************* | ||
840 | * | ||
841 | * FUNCTION: acpi_ev_install_space_handler | ||
842 | * | 498 | * |
843 | * PARAMETERS: node - Namespace node for the device | 499 | * PARAMETERS: region_obj - Region object |
844 | * space_id - The address space ID | 500 | * function - Passed to _REG: On (1) or Off (0) |
845 | * handler - Address of the handler | ||
846 | * setup - Address of the setup function | ||
847 | * context - Value passed to the handler on each access | ||
848 | * | 501 | * |
849 | * RETURN: Status | 502 | * RETURN: Status |
850 | * | 503 | * |
851 | * DESCRIPTION: Install a handler for all op_regions of a given space_id. | 504 | * DESCRIPTION: Execute _REG method for a region |
852 | * Assumes namespace is locked | ||
853 | * | 505 | * |
854 | ******************************************************************************/ | 506 | ******************************************************************************/ |
855 | 507 | ||
856 | acpi_status | 508 | acpi_status |
857 | acpi_ev_install_space_handler(struct acpi_namespace_node * node, | 509 | acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function) |
858 | acpi_adr_space_type space_id, | ||
859 | acpi_adr_space_handler handler, | ||
860 | acpi_adr_space_setup setup, void *context) | ||
861 | { | 510 | { |
862 | union acpi_operand_object *obj_desc; | 511 | struct acpi_evaluate_info *info; |
863 | union acpi_operand_object *handler_obj; | 512 | union acpi_operand_object *args[3]; |
513 | union acpi_operand_object *region_obj2; | ||
864 | acpi_status status; | 514 | acpi_status status; |
865 | acpi_object_type type; | ||
866 | u8 flags = 0; | ||
867 | 515 | ||
868 | ACPI_FUNCTION_TRACE(ev_install_space_handler); | 516 | ACPI_FUNCTION_TRACE(ev_execute_reg_method); |
869 | |||
870 | /* | ||
871 | * This registration is valid for only the types below and the root. This | ||
872 | * is where the default handlers get placed. | ||
873 | */ | ||
874 | if ((node->type != ACPI_TYPE_DEVICE) && | ||
875 | (node->type != ACPI_TYPE_PROCESSOR) && | ||
876 | (node->type != ACPI_TYPE_THERMAL) && (node != acpi_gbl_root_node)) { | ||
877 | status = AE_BAD_PARAMETER; | ||
878 | goto unlock_and_exit; | ||
879 | } | ||
880 | 517 | ||
881 | if (handler == ACPI_DEFAULT_HANDLER) { | 518 | region_obj2 = acpi_ns_get_secondary_object(region_obj); |
882 | flags = ACPI_ADDR_HANDLER_DEFAULT_INSTALLED; | 519 | if (!region_obj2) { |
883 | 520 | return_ACPI_STATUS(AE_NOT_EXIST); | |
884 | switch (space_id) { | ||
885 | case ACPI_ADR_SPACE_SYSTEM_MEMORY: | ||
886 | handler = acpi_ex_system_memory_space_handler; | ||
887 | setup = acpi_ev_system_memory_region_setup; | ||
888 | break; | ||
889 | |||
890 | case ACPI_ADR_SPACE_SYSTEM_IO: | ||
891 | handler = acpi_ex_system_io_space_handler; | ||
892 | setup = acpi_ev_io_space_region_setup; | ||
893 | break; | ||
894 | |||
895 | case ACPI_ADR_SPACE_PCI_CONFIG: | ||
896 | handler = acpi_ex_pci_config_space_handler; | ||
897 | setup = acpi_ev_pci_config_region_setup; | ||
898 | break; | ||
899 | |||
900 | case ACPI_ADR_SPACE_CMOS: | ||
901 | handler = acpi_ex_cmos_space_handler; | ||
902 | setup = acpi_ev_cmos_region_setup; | ||
903 | break; | ||
904 | |||
905 | case ACPI_ADR_SPACE_PCI_BAR_TARGET: | ||
906 | handler = acpi_ex_pci_bar_space_handler; | ||
907 | setup = acpi_ev_pci_bar_region_setup; | ||
908 | break; | ||
909 | |||
910 | case ACPI_ADR_SPACE_DATA_TABLE: | ||
911 | handler = acpi_ex_data_table_space_handler; | ||
912 | setup = NULL; | ||
913 | break; | ||
914 | |||
915 | default: | ||
916 | status = AE_BAD_PARAMETER; | ||
917 | goto unlock_and_exit; | ||
918 | } | ||
919 | } | 521 | } |
920 | 522 | ||
921 | /* If the caller hasn't specified a setup routine, use the default */ | 523 | if (region_obj2->extra.method_REG == NULL) { |
922 | 524 | return_ACPI_STATUS(AE_OK); | |
923 | if (!setup) { | ||
924 | setup = acpi_ev_default_region_setup; | ||
925 | } | 525 | } |
926 | 526 | ||
927 | /* Check for an existing internal object */ | 527 | /* Allocate and initialize the evaluation information block */ |
928 | |||
929 | obj_desc = acpi_ns_get_attached_object(node); | ||
930 | if (obj_desc) { | ||
931 | /* | ||
932 | * The attached device object already exists. Make sure the handler | ||
933 | * is not already installed. | ||
934 | */ | ||
935 | handler_obj = obj_desc->device.handler; | ||
936 | |||
937 | /* Walk the handler list for this device */ | ||
938 | |||
939 | while (handler_obj) { | ||
940 | |||
941 | /* Same space_id indicates a handler already installed */ | ||
942 | |||
943 | if (handler_obj->address_space.space_id == space_id) { | ||
944 | if (handler_obj->address_space.handler == | ||
945 | handler) { | ||
946 | /* | ||
947 | * It is (relatively) OK to attempt to install the SAME | ||
948 | * handler twice. This can easily happen with the | ||
949 | * PCI_Config space. | ||
950 | */ | ||
951 | status = AE_SAME_HANDLER; | ||
952 | goto unlock_and_exit; | ||
953 | } else { | ||
954 | /* A handler is already installed */ | ||
955 | |||
956 | status = AE_ALREADY_EXISTS; | ||
957 | } | ||
958 | goto unlock_and_exit; | ||
959 | } | ||
960 | |||
961 | /* Walk the linked list of handlers */ | ||
962 | |||
963 | handler_obj = handler_obj->address_space.next; | ||
964 | } | ||
965 | } else { | ||
966 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, | ||
967 | "Creating object on Device %p while installing handler\n", | ||
968 | node)); | ||
969 | |||
970 | /* obj_desc does not exist, create one */ | ||
971 | |||
972 | if (node->type == ACPI_TYPE_ANY) { | ||
973 | type = ACPI_TYPE_DEVICE; | ||
974 | } else { | ||
975 | type = node->type; | ||
976 | } | ||
977 | |||
978 | obj_desc = acpi_ut_create_internal_object(type); | ||
979 | if (!obj_desc) { | ||
980 | status = AE_NO_MEMORY; | ||
981 | goto unlock_and_exit; | ||
982 | } | ||
983 | |||
984 | /* Init new descriptor */ | ||
985 | |||
986 | obj_desc->common.type = (u8) type; | ||
987 | |||
988 | /* Attach the new object to the Node */ | ||
989 | |||
990 | status = acpi_ns_attach_object(node, obj_desc, type); | ||
991 | |||
992 | /* Remove local reference to the object */ | ||
993 | |||
994 | acpi_ut_remove_reference(obj_desc); | ||
995 | 528 | ||
996 | if (ACPI_FAILURE(status)) { | 529 | info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info)); |
997 | goto unlock_and_exit; | 530 | if (!info) { |
998 | } | 531 | return_ACPI_STATUS(AE_NO_MEMORY); |
999 | } | 532 | } |
1000 | 533 | ||
1001 | ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, | 534 | info->prefix_node = region_obj2->extra.method_REG; |
1002 | "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n", | 535 | info->pathname = NULL; |
1003 | acpi_ut_get_region_name(space_id), space_id, | 536 | info->parameters = args; |
1004 | acpi_ut_get_node_name(node), node, obj_desc)); | 537 | info->flags = ACPI_IGNORE_RETURN_VALUE; |
1005 | 538 | ||
1006 | /* | 539 | /* |
1007 | * Install the handler | 540 | * The _REG method has two arguments: |
541 | * | ||
542 | * arg0 - Integer: | ||
543 | * Operation region space ID Same value as region_obj->Region.space_id | ||
1008 | * | 544 | * |
1009 | * At this point there is no existing handler. Just allocate the object | 545 | * arg1 - Integer: |
1010 | * for the handler and link it into the list. | 546 | * connection status 1 for connecting the handler, 0 for disconnecting |
547 | * the handler (Passed as a parameter) | ||
1011 | */ | 548 | */ |
1012 | handler_obj = | 549 | args[0] = |
1013 | acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_ADDRESS_HANDLER); | 550 | acpi_ut_create_integer_object((u64)region_obj->region.space_id); |
1014 | if (!handler_obj) { | 551 | if (!args[0]) { |
1015 | status = AE_NO_MEMORY; | 552 | status = AE_NO_MEMORY; |
1016 | goto unlock_and_exit; | 553 | goto cleanup1; |
1017 | } | 554 | } |
1018 | 555 | ||
1019 | /* Init handler obj */ | 556 | args[1] = acpi_ut_create_integer_object((u64)function); |
557 | if (!args[1]) { | ||
558 | status = AE_NO_MEMORY; | ||
559 | goto cleanup2; | ||
560 | } | ||
1020 | 561 | ||
1021 | handler_obj->address_space.space_id = (u8) space_id; | 562 | args[2] = NULL; /* Terminate list */ |
1022 | handler_obj->address_space.handler_flags = flags; | ||
1023 | handler_obj->address_space.region_list = NULL; | ||
1024 | handler_obj->address_space.node = node; | ||
1025 | handler_obj->address_space.handler = handler; | ||
1026 | handler_obj->address_space.context = context; | ||
1027 | handler_obj->address_space.setup = setup; | ||
1028 | 563 | ||
1029 | /* Install at head of Device.address_space list */ | 564 | /* Execute the method, no return value */ |
1030 | 565 | ||
1031 | handler_obj->address_space.next = obj_desc->device.handler; | 566 | ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname |
567 | (ACPI_TYPE_METHOD, info->prefix_node, NULL)); | ||
1032 | 568 | ||
1033 | /* | 569 | status = acpi_ns_evaluate(info); |
1034 | * The Device object is the first reference on the handler_obj. | 570 | acpi_ut_remove_reference(args[1]); |
1035 | * Each region that uses the handler adds a reference. | ||
1036 | */ | ||
1037 | obj_desc->device.handler = handler_obj; | ||
1038 | 571 | ||
1039 | /* | 572 | cleanup2: |
1040 | * Walk the namespace finding all of the regions this | 573 | acpi_ut_remove_reference(args[0]); |
1041 | * handler will manage. | ||
1042 | * | ||
1043 | * Start at the device and search the branch toward | ||
1044 | * the leaf nodes until either the leaf is encountered or | ||
1045 | * a device is detected that has an address handler of the | ||
1046 | * same type. | ||
1047 | * | ||
1048 | * In either case, back up and search down the remainder | ||
1049 | * of the branch | ||
1050 | */ | ||
1051 | status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX, | ||
1052 | ACPI_NS_WALK_UNLOCK, | ||
1053 | acpi_ev_install_handler, NULL, | ||
1054 | handler_obj, NULL); | ||
1055 | 574 | ||
1056 | unlock_and_exit: | 575 | cleanup1: |
576 | ACPI_FREE(info); | ||
1057 | return_ACPI_STATUS(status); | 577 | return_ACPI_STATUS(status); |
1058 | } | 578 | } |
1059 | 579 | ||
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c index 1f0e93401436..909520923fbe 100644 --- a/drivers/acpi/acpica/nspredef.c +++ b/drivers/acpi/acpica/nspredef.c | |||
@@ -73,27 +73,6 @@ ACPI_MODULE_NAME("nspredef") | |||
73 | ******************************************************************************/ | 73 | ******************************************************************************/ |
74 | /* Local prototypes */ | 74 | /* Local prototypes */ |
75 | static acpi_status | 75 | static acpi_status |
76 | acpi_ns_check_package(struct acpi_predefined_data *data, | ||
77 | union acpi_operand_object **return_object_ptr); | ||
78 | |||
79 | static acpi_status | ||
80 | acpi_ns_check_package_list(struct acpi_predefined_data *data, | ||
81 | const union acpi_predefined_info *package, | ||
82 | union acpi_operand_object **elements, u32 count); | ||
83 | |||
84 | static acpi_status | ||
85 | acpi_ns_check_package_elements(struct acpi_predefined_data *data, | ||
86 | union acpi_operand_object **elements, | ||
87 | u8 type1, | ||
88 | u32 count1, | ||
89 | u8 type2, u32 count2, u32 start_index); | ||
90 | |||
91 | static acpi_status | ||
92 | acpi_ns_check_object_type(struct acpi_predefined_data *data, | ||
93 | union acpi_operand_object **return_object_ptr, | ||
94 | u32 expected_btypes, u32 package_index); | ||
95 | |||
96 | static acpi_status | ||
97 | acpi_ns_check_reference(struct acpi_predefined_data *data, | 76 | acpi_ns_check_reference(struct acpi_predefined_data *data, |
98 | union acpi_operand_object *return_object); | 77 | union acpi_operand_object *return_object); |
99 | 78 | ||
@@ -407,564 +386,6 @@ const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct | |||
407 | 386 | ||
408 | /******************************************************************************* | 387 | /******************************************************************************* |
409 | * | 388 | * |
410 | * FUNCTION: acpi_ns_check_package | ||
411 | * | ||
412 | * PARAMETERS: data - Pointer to validation data structure | ||
413 | * return_object_ptr - Pointer to the object returned from the | ||
414 | * evaluation of a method or object | ||
415 | * | ||
416 | * RETURN: Status | ||
417 | * | ||
418 | * DESCRIPTION: Check a returned package object for the correct count and | ||
419 | * correct type of all sub-objects. | ||
420 | * | ||
421 | ******************************************************************************/ | ||
422 | |||
423 | static acpi_status | ||
424 | acpi_ns_check_package(struct acpi_predefined_data *data, | ||
425 | union acpi_operand_object **return_object_ptr) | ||
426 | { | ||
427 | union acpi_operand_object *return_object = *return_object_ptr; | ||
428 | const union acpi_predefined_info *package; | ||
429 | union acpi_operand_object **elements; | ||
430 | acpi_status status = AE_OK; | ||
431 | u32 expected_count; | ||
432 | u32 count; | ||
433 | u32 i; | ||
434 | |||
435 | ACPI_FUNCTION_NAME(ns_check_package); | ||
436 | |||
437 | /* The package info for this name is in the next table entry */ | ||
438 | |||
439 | package = data->predefined + 1; | ||
440 | |||
441 | ACPI_DEBUG_PRINT((ACPI_DB_NAMES, | ||
442 | "%s Validating return Package of Type %X, Count %X\n", | ||
443 | data->pathname, package->ret_info.type, | ||
444 | return_object->package.count)); | ||
445 | |||
446 | /* | ||
447 | * For variable-length Packages, we can safely remove all embedded | ||
448 | * and trailing NULL package elements | ||
449 | */ | ||
450 | acpi_ns_remove_null_elements(data, package->ret_info.type, | ||
451 | return_object); | ||
452 | |||
453 | /* Extract package count and elements array */ | ||
454 | |||
455 | elements = return_object->package.elements; | ||
456 | count = return_object->package.count; | ||
457 | |||
458 | /* The package must have at least one element, else invalid */ | ||
459 | |||
460 | if (!count) { | ||
461 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | ||
462 | "Return Package has no elements (empty)")); | ||
463 | |||
464 | return (AE_AML_OPERAND_VALUE); | ||
465 | } | ||
466 | |||
467 | /* | ||
468 | * Decode the type of the expected package contents | ||
469 | * | ||
470 | * PTYPE1 packages contain no subpackages | ||
471 | * PTYPE2 packages contain sub-packages | ||
472 | */ | ||
473 | switch (package->ret_info.type) { | ||
474 | case ACPI_PTYPE1_FIXED: | ||
475 | |||
476 | /* | ||
477 | * The package count is fixed and there are no sub-packages | ||
478 | * | ||
479 | * If package is too small, exit. | ||
480 | * If package is larger than expected, issue warning but continue | ||
481 | */ | ||
482 | expected_count = | ||
483 | package->ret_info.count1 + package->ret_info.count2; | ||
484 | if (count < expected_count) { | ||
485 | goto package_too_small; | ||
486 | } else if (count > expected_count) { | ||
487 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, | ||
488 | "%s: Return Package is larger than needed - " | ||
489 | "found %u, expected %u\n", | ||
490 | data->pathname, count, | ||
491 | expected_count)); | ||
492 | } | ||
493 | |||
494 | /* Validate all elements of the returned package */ | ||
495 | |||
496 | status = acpi_ns_check_package_elements(data, elements, | ||
497 | package->ret_info. | ||
498 | object_type1, | ||
499 | package->ret_info. | ||
500 | count1, | ||
501 | package->ret_info. | ||
502 | object_type2, | ||
503 | package->ret_info. | ||
504 | count2, 0); | ||
505 | break; | ||
506 | |||
507 | case ACPI_PTYPE1_VAR: | ||
508 | |||
509 | /* | ||
510 | * The package count is variable, there are no sub-packages, and all | ||
511 | * elements must be of the same type | ||
512 | */ | ||
513 | for (i = 0; i < count; i++) { | ||
514 | status = acpi_ns_check_object_type(data, elements, | ||
515 | package->ret_info. | ||
516 | object_type1, i); | ||
517 | if (ACPI_FAILURE(status)) { | ||
518 | return (status); | ||
519 | } | ||
520 | elements++; | ||
521 | } | ||
522 | break; | ||
523 | |||
524 | case ACPI_PTYPE1_OPTION: | ||
525 | |||
526 | /* | ||
527 | * The package count is variable, there are no sub-packages. There are | ||
528 | * a fixed number of required elements, and a variable number of | ||
529 | * optional elements. | ||
530 | * | ||
531 | * Check if package is at least as large as the minimum required | ||
532 | */ | ||
533 | expected_count = package->ret_info3.count; | ||
534 | if (count < expected_count) { | ||
535 | goto package_too_small; | ||
536 | } | ||
537 | |||
538 | /* Variable number of sub-objects */ | ||
539 | |||
540 | for (i = 0; i < count; i++) { | ||
541 | if (i < package->ret_info3.count) { | ||
542 | |||
543 | /* These are the required package elements (0, 1, or 2) */ | ||
544 | |||
545 | status = | ||
546 | acpi_ns_check_object_type(data, elements, | ||
547 | package-> | ||
548 | ret_info3. | ||
549 | object_type[i], | ||
550 | i); | ||
551 | if (ACPI_FAILURE(status)) { | ||
552 | return (status); | ||
553 | } | ||
554 | } else { | ||
555 | /* These are the optional package elements */ | ||
556 | |||
557 | status = | ||
558 | acpi_ns_check_object_type(data, elements, | ||
559 | package-> | ||
560 | ret_info3. | ||
561 | tail_object_type, | ||
562 | i); | ||
563 | if (ACPI_FAILURE(status)) { | ||
564 | return (status); | ||
565 | } | ||
566 | } | ||
567 | elements++; | ||
568 | } | ||
569 | break; | ||
570 | |||
571 | case ACPI_PTYPE2_REV_FIXED: | ||
572 | |||
573 | /* First element is the (Integer) revision */ | ||
574 | |||
575 | status = acpi_ns_check_object_type(data, elements, | ||
576 | ACPI_RTYPE_INTEGER, 0); | ||
577 | if (ACPI_FAILURE(status)) { | ||
578 | return (status); | ||
579 | } | ||
580 | |||
581 | elements++; | ||
582 | count--; | ||
583 | |||
584 | /* Examine the sub-packages */ | ||
585 | |||
586 | status = | ||
587 | acpi_ns_check_package_list(data, package, elements, count); | ||
588 | break; | ||
589 | |||
590 | case ACPI_PTYPE2_PKG_COUNT: | ||
591 | |||
592 | /* First element is the (Integer) count of sub-packages to follow */ | ||
593 | |||
594 | status = acpi_ns_check_object_type(data, elements, | ||
595 | ACPI_RTYPE_INTEGER, 0); | ||
596 | if (ACPI_FAILURE(status)) { | ||
597 | return (status); | ||
598 | } | ||
599 | |||
600 | /* | ||
601 | * Count cannot be larger than the parent package length, but allow it | ||
602 | * to be smaller. The >= accounts for the Integer above. | ||
603 | */ | ||
604 | expected_count = (u32) (*elements)->integer.value; | ||
605 | if (expected_count >= count) { | ||
606 | goto package_too_small; | ||
607 | } | ||
608 | |||
609 | count = expected_count; | ||
610 | elements++; | ||
611 | |||
612 | /* Examine the sub-packages */ | ||
613 | |||
614 | status = | ||
615 | acpi_ns_check_package_list(data, package, elements, count); | ||
616 | break; | ||
617 | |||
618 | case ACPI_PTYPE2: | ||
619 | case ACPI_PTYPE2_FIXED: | ||
620 | case ACPI_PTYPE2_MIN: | ||
621 | case ACPI_PTYPE2_COUNT: | ||
622 | case ACPI_PTYPE2_FIX_VAR: | ||
623 | |||
624 | /* | ||
625 | * These types all return a single Package that consists of a | ||
626 | * variable number of sub-Packages. | ||
627 | * | ||
628 | * First, ensure that the first element is a sub-Package. If not, | ||
629 | * the BIOS may have incorrectly returned the object as a single | ||
630 | * package instead of a Package of Packages (a common error if | ||
631 | * there is only one entry). We may be able to repair this by | ||
632 | * wrapping the returned Package with a new outer Package. | ||
633 | */ | ||
634 | if (*elements | ||
635 | && ((*elements)->common.type != ACPI_TYPE_PACKAGE)) { | ||
636 | |||
637 | /* Create the new outer package and populate it */ | ||
638 | |||
639 | status = | ||
640 | acpi_ns_wrap_with_package(data, return_object, | ||
641 | return_object_ptr); | ||
642 | if (ACPI_FAILURE(status)) { | ||
643 | return (status); | ||
644 | } | ||
645 | |||
646 | /* Update locals to point to the new package (of 1 element) */ | ||
647 | |||
648 | return_object = *return_object_ptr; | ||
649 | elements = return_object->package.elements; | ||
650 | count = 1; | ||
651 | } | ||
652 | |||
653 | /* Examine the sub-packages */ | ||
654 | |||
655 | status = | ||
656 | acpi_ns_check_package_list(data, package, elements, count); | ||
657 | break; | ||
658 | |||
659 | default: | ||
660 | |||
661 | /* Should not get here if predefined info table is correct */ | ||
662 | |||
663 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | ||
664 | "Invalid internal return type in table entry: %X", | ||
665 | package->ret_info.type)); | ||
666 | |||
667 | return (AE_AML_INTERNAL); | ||
668 | } | ||
669 | |||
670 | return (status); | ||
671 | |||
672 | package_too_small: | ||
673 | |||
674 | /* Error exit for the case with an incorrect package count */ | ||
675 | |||
676 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | ||
677 | "Return Package is too small - found %u elements, expected %u", | ||
678 | count, expected_count)); | ||
679 | |||
680 | return (AE_AML_OPERAND_VALUE); | ||
681 | } | ||
682 | |||
683 | /******************************************************************************* | ||
684 | * | ||
685 | * FUNCTION: acpi_ns_check_package_list | ||
686 | * | ||
687 | * PARAMETERS: data - Pointer to validation data structure | ||
688 | * package - Pointer to package-specific info for method | ||
689 | * elements - Element list of parent package. All elements | ||
690 | * of this list should be of type Package. | ||
691 | * count - Count of subpackages | ||
692 | * | ||
693 | * RETURN: Status | ||
694 | * | ||
695 | * DESCRIPTION: Examine a list of subpackages | ||
696 | * | ||
697 | ******************************************************************************/ | ||
698 | |||
699 | static acpi_status | ||
700 | acpi_ns_check_package_list(struct acpi_predefined_data *data, | ||
701 | const union acpi_predefined_info *package, | ||
702 | union acpi_operand_object **elements, u32 count) | ||
703 | { | ||
704 | union acpi_operand_object *sub_package; | ||
705 | union acpi_operand_object **sub_elements; | ||
706 | acpi_status status; | ||
707 | u32 expected_count; | ||
708 | u32 i; | ||
709 | u32 j; | ||
710 | |||
711 | /* | ||
712 | * Validate each sub-Package in the parent Package | ||
713 | * | ||
714 | * NOTE: assumes list of sub-packages contains no NULL elements. | ||
715 | * Any NULL elements should have been removed by earlier call | ||
716 | * to acpi_ns_remove_null_elements. | ||
717 | */ | ||
718 | for (i = 0; i < count; i++) { | ||
719 | sub_package = *elements; | ||
720 | sub_elements = sub_package->package.elements; | ||
721 | data->parent_package = sub_package; | ||
722 | |||
723 | /* Each sub-object must be of type Package */ | ||
724 | |||
725 | status = acpi_ns_check_object_type(data, &sub_package, | ||
726 | ACPI_RTYPE_PACKAGE, i); | ||
727 | if (ACPI_FAILURE(status)) { | ||
728 | return (status); | ||
729 | } | ||
730 | |||
731 | /* Examine the different types of expected sub-packages */ | ||
732 | |||
733 | data->parent_package = sub_package; | ||
734 | switch (package->ret_info.type) { | ||
735 | case ACPI_PTYPE2: | ||
736 | case ACPI_PTYPE2_PKG_COUNT: | ||
737 | case ACPI_PTYPE2_REV_FIXED: | ||
738 | |||
739 | /* Each subpackage has a fixed number of elements */ | ||
740 | |||
741 | expected_count = | ||
742 | package->ret_info.count1 + package->ret_info.count2; | ||
743 | if (sub_package->package.count < expected_count) { | ||
744 | goto package_too_small; | ||
745 | } | ||
746 | |||
747 | status = | ||
748 | acpi_ns_check_package_elements(data, sub_elements, | ||
749 | package->ret_info. | ||
750 | object_type1, | ||
751 | package->ret_info. | ||
752 | count1, | ||
753 | package->ret_info. | ||
754 | object_type2, | ||
755 | package->ret_info. | ||
756 | count2, 0); | ||
757 | if (ACPI_FAILURE(status)) { | ||
758 | return (status); | ||
759 | } | ||
760 | break; | ||
761 | |||
762 | case ACPI_PTYPE2_FIX_VAR: | ||
763 | /* | ||
764 | * Each subpackage has a fixed number of elements and an | ||
765 | * optional element | ||
766 | */ | ||
767 | expected_count = | ||
768 | package->ret_info.count1 + package->ret_info.count2; | ||
769 | if (sub_package->package.count < expected_count) { | ||
770 | goto package_too_small; | ||
771 | } | ||
772 | |||
773 | status = | ||
774 | acpi_ns_check_package_elements(data, sub_elements, | ||
775 | package->ret_info. | ||
776 | object_type1, | ||
777 | package->ret_info. | ||
778 | count1, | ||
779 | package->ret_info. | ||
780 | object_type2, | ||
781 | sub_package->package. | ||
782 | count - | ||
783 | package->ret_info. | ||
784 | count1, 0); | ||
785 | if (ACPI_FAILURE(status)) { | ||
786 | return (status); | ||
787 | } | ||
788 | break; | ||
789 | |||
790 | case ACPI_PTYPE2_FIXED: | ||
791 | |||
792 | /* Each sub-package has a fixed length */ | ||
793 | |||
794 | expected_count = package->ret_info2.count; | ||
795 | if (sub_package->package.count < expected_count) { | ||
796 | goto package_too_small; | ||
797 | } | ||
798 | |||
799 | /* Check the type of each sub-package element */ | ||
800 | |||
801 | for (j = 0; j < expected_count; j++) { | ||
802 | status = | ||
803 | acpi_ns_check_object_type(data, | ||
804 | &sub_elements[j], | ||
805 | package-> | ||
806 | ret_info2. | ||
807 | object_type[j], | ||
808 | j); | ||
809 | if (ACPI_FAILURE(status)) { | ||
810 | return (status); | ||
811 | } | ||
812 | } | ||
813 | break; | ||
814 | |||
815 | case ACPI_PTYPE2_MIN: | ||
816 | |||
817 | /* Each sub-package has a variable but minimum length */ | ||
818 | |||
819 | expected_count = package->ret_info.count1; | ||
820 | if (sub_package->package.count < expected_count) { | ||
821 | goto package_too_small; | ||
822 | } | ||
823 | |||
824 | /* Check the type of each sub-package element */ | ||
825 | |||
826 | status = | ||
827 | acpi_ns_check_package_elements(data, sub_elements, | ||
828 | package->ret_info. | ||
829 | object_type1, | ||
830 | sub_package->package. | ||
831 | count, 0, 0, 0); | ||
832 | if (ACPI_FAILURE(status)) { | ||
833 | return (status); | ||
834 | } | ||
835 | break; | ||
836 | |||
837 | case ACPI_PTYPE2_COUNT: | ||
838 | |||
839 | /* | ||
840 | * First element is the (Integer) count of elements, including | ||
841 | * the count field (the ACPI name is num_elements) | ||
842 | */ | ||
843 | status = acpi_ns_check_object_type(data, sub_elements, | ||
844 | ACPI_RTYPE_INTEGER, | ||
845 | 0); | ||
846 | if (ACPI_FAILURE(status)) { | ||
847 | return (status); | ||
848 | } | ||
849 | |||
850 | /* | ||
851 | * Make sure package is large enough for the Count and is | ||
852 | * is as large as the minimum size | ||
853 | */ | ||
854 | expected_count = (u32)(*sub_elements)->integer.value; | ||
855 | if (sub_package->package.count < expected_count) { | ||
856 | goto package_too_small; | ||
857 | } | ||
858 | if (sub_package->package.count < | ||
859 | package->ret_info.count1) { | ||
860 | expected_count = package->ret_info.count1; | ||
861 | goto package_too_small; | ||
862 | } | ||
863 | if (expected_count == 0) { | ||
864 | /* | ||
865 | * Either the num_entries element was originally zero or it was | ||
866 | * a NULL element and repaired to an Integer of value zero. | ||
867 | * In either case, repair it by setting num_entries to be the | ||
868 | * actual size of the subpackage. | ||
869 | */ | ||
870 | expected_count = sub_package->package.count; | ||
871 | (*sub_elements)->integer.value = expected_count; | ||
872 | } | ||
873 | |||
874 | /* Check the type of each sub-package element */ | ||
875 | |||
876 | status = | ||
877 | acpi_ns_check_package_elements(data, | ||
878 | (sub_elements + 1), | ||
879 | package->ret_info. | ||
880 | object_type1, | ||
881 | (expected_count - 1), | ||
882 | 0, 0, 1); | ||
883 | if (ACPI_FAILURE(status)) { | ||
884 | return (status); | ||
885 | } | ||
886 | break; | ||
887 | |||
888 | default: /* Should not get here, type was validated by caller */ | ||
889 | |||
890 | return (AE_AML_INTERNAL); | ||
891 | } | ||
892 | |||
893 | elements++; | ||
894 | } | ||
895 | |||
896 | return (AE_OK); | ||
897 | |||
898 | package_too_small: | ||
899 | |||
900 | /* The sub-package count was smaller than required */ | ||
901 | |||
902 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | ||
903 | "Return Sub-Package[%u] is too small - found %u elements, expected %u", | ||
904 | i, sub_package->package.count, expected_count)); | ||
905 | |||
906 | return (AE_AML_OPERAND_VALUE); | ||
907 | } | ||
908 | |||
909 | /******************************************************************************* | ||
910 | * | ||
911 | * FUNCTION: acpi_ns_check_package_elements | ||
912 | * | ||
913 | * PARAMETERS: data - Pointer to validation data structure | ||
914 | * elements - Pointer to the package elements array | ||
915 | * type1 - Object type for first group | ||
916 | * count1 - Count for first group | ||
917 | * type2 - Object type for second group | ||
918 | * count2 - Count for second group | ||
919 | * start_index - Start of the first group of elements | ||
920 | * | ||
921 | * RETURN: Status | ||
922 | * | ||
923 | * DESCRIPTION: Check that all elements of a package are of the correct object | ||
924 | * type. Supports up to two groups of different object types. | ||
925 | * | ||
926 | ******************************************************************************/ | ||
927 | |||
928 | static acpi_status | ||
929 | acpi_ns_check_package_elements(struct acpi_predefined_data *data, | ||
930 | union acpi_operand_object **elements, | ||
931 | u8 type1, | ||
932 | u32 count1, | ||
933 | u8 type2, u32 count2, u32 start_index) | ||
934 | { | ||
935 | union acpi_operand_object **this_element = elements; | ||
936 | acpi_status status; | ||
937 | u32 i; | ||
938 | |||
939 | /* | ||
940 | * Up to two groups of package elements are supported by the data | ||
941 | * structure. All elements in each group must be of the same type. | ||
942 | * The second group can have a count of zero. | ||
943 | */ | ||
944 | for (i = 0; i < count1; i++) { | ||
945 | status = acpi_ns_check_object_type(data, this_element, | ||
946 | type1, i + start_index); | ||
947 | if (ACPI_FAILURE(status)) { | ||
948 | return (status); | ||
949 | } | ||
950 | this_element++; | ||
951 | } | ||
952 | |||
953 | for (i = 0; i < count2; i++) { | ||
954 | status = acpi_ns_check_object_type(data, this_element, | ||
955 | type2, | ||
956 | (i + count1 + start_index)); | ||
957 | if (ACPI_FAILURE(status)) { | ||
958 | return (status); | ||
959 | } | ||
960 | this_element++; | ||
961 | } | ||
962 | |||
963 | return (AE_OK); | ||
964 | } | ||
965 | |||
966 | /******************************************************************************* | ||
967 | * | ||
968 | * FUNCTION: acpi_ns_check_object_type | 389 | * FUNCTION: acpi_ns_check_object_type |
969 | * | 390 | * |
970 | * PARAMETERS: data - Pointer to validation data structure | 391 | * PARAMETERS: data - Pointer to validation data structure |
@@ -982,7 +403,7 @@ acpi_ns_check_package_elements(struct acpi_predefined_data *data, | |||
982 | * | 403 | * |
983 | ******************************************************************************/ | 404 | ******************************************************************************/ |
984 | 405 | ||
985 | static acpi_status | 406 | acpi_status |
986 | acpi_ns_check_object_type(struct acpi_predefined_data *data, | 407 | acpi_ns_check_object_type(struct acpi_predefined_data *data, |
987 | union acpi_operand_object **return_object_ptr, | 408 | union acpi_operand_object **return_object_ptr, |
988 | u32 expected_btypes, u32 package_index) | 409 | u32 expected_btypes, u32 package_index) |
diff --git a/drivers/acpi/acpica/nsprepkg.c b/drivers/acpi/acpica/nsprepkg.c new file mode 100644 index 000000000000..c27be70f69bf --- /dev/null +++ b/drivers/acpi/acpica/nsprepkg.c | |||
@@ -0,0 +1,621 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: nsprepkg - Validation of package objects for predefined names | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2012, 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 | ||
50 | ACPI_MODULE_NAME("nsprepkg") | ||
51 | |||
52 | /* Local prototypes */ | ||
53 | static acpi_status | ||
54 | acpi_ns_check_package_list(struct acpi_predefined_data *data, | ||
55 | const union acpi_predefined_info *package, | ||
56 | union acpi_operand_object **elements, u32 count); | ||
57 | |||
58 | static acpi_status | ||
59 | acpi_ns_check_package_elements(struct acpi_predefined_data *data, | ||
60 | union acpi_operand_object **elements, | ||
61 | u8 type1, | ||
62 | u32 count1, | ||
63 | u8 type2, u32 count2, u32 start_index); | ||
64 | |||
65 | /******************************************************************************* | ||
66 | * | ||
67 | * FUNCTION: acpi_ns_check_package | ||
68 | * | ||
69 | * PARAMETERS: data - Pointer to validation data structure | ||
70 | * return_object_ptr - Pointer to the object returned from the | ||
71 | * evaluation of a method or object | ||
72 | * | ||
73 | * RETURN: Status | ||
74 | * | ||
75 | * DESCRIPTION: Check a returned package object for the correct count and | ||
76 | * correct type of all sub-objects. | ||
77 | * | ||
78 | ******************************************************************************/ | ||
79 | |||
80 | acpi_status | ||
81 | acpi_ns_check_package(struct acpi_predefined_data *data, | ||
82 | union acpi_operand_object **return_object_ptr) | ||
83 | { | ||
84 | union acpi_operand_object *return_object = *return_object_ptr; | ||
85 | const union acpi_predefined_info *package; | ||
86 | union acpi_operand_object **elements; | ||
87 | acpi_status status = AE_OK; | ||
88 | u32 expected_count; | ||
89 | u32 count; | ||
90 | u32 i; | ||
91 | |||
92 | ACPI_FUNCTION_NAME(ns_check_package); | ||
93 | |||
94 | /* The package info for this name is in the next table entry */ | ||
95 | |||
96 | package = data->predefined + 1; | ||
97 | |||
98 | ACPI_DEBUG_PRINT((ACPI_DB_NAMES, | ||
99 | "%s Validating return Package of Type %X, Count %X\n", | ||
100 | data->pathname, package->ret_info.type, | ||
101 | return_object->package.count)); | ||
102 | |||
103 | /* | ||
104 | * For variable-length Packages, we can safely remove all embedded | ||
105 | * and trailing NULL package elements | ||
106 | */ | ||
107 | acpi_ns_remove_null_elements(data, package->ret_info.type, | ||
108 | return_object); | ||
109 | |||
110 | /* Extract package count and elements array */ | ||
111 | |||
112 | elements = return_object->package.elements; | ||
113 | count = return_object->package.count; | ||
114 | |||
115 | /* The package must have at least one element, else invalid */ | ||
116 | |||
117 | if (!count) { | ||
118 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | ||
119 | "Return Package has no elements (empty)")); | ||
120 | |||
121 | return (AE_AML_OPERAND_VALUE); | ||
122 | } | ||
123 | |||
124 | /* | ||
125 | * Decode the type of the expected package contents | ||
126 | * | ||
127 | * PTYPE1 packages contain no subpackages | ||
128 | * PTYPE2 packages contain sub-packages | ||
129 | */ | ||
130 | switch (package->ret_info.type) { | ||
131 | case ACPI_PTYPE1_FIXED: | ||
132 | |||
133 | /* | ||
134 | * The package count is fixed and there are no sub-packages | ||
135 | * | ||
136 | * If package is too small, exit. | ||
137 | * If package is larger than expected, issue warning but continue | ||
138 | */ | ||
139 | expected_count = | ||
140 | package->ret_info.count1 + package->ret_info.count2; | ||
141 | if (count < expected_count) { | ||
142 | goto package_too_small; | ||
143 | } else if (count > expected_count) { | ||
144 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, | ||
145 | "%s: Return Package is larger than needed - " | ||
146 | "found %u, expected %u\n", | ||
147 | data->pathname, count, | ||
148 | expected_count)); | ||
149 | } | ||
150 | |||
151 | /* Validate all elements of the returned package */ | ||
152 | |||
153 | status = acpi_ns_check_package_elements(data, elements, | ||
154 | package->ret_info. | ||
155 | object_type1, | ||
156 | package->ret_info. | ||
157 | count1, | ||
158 | package->ret_info. | ||
159 | object_type2, | ||
160 | package->ret_info. | ||
161 | count2, 0); | ||
162 | break; | ||
163 | |||
164 | case ACPI_PTYPE1_VAR: | ||
165 | |||
166 | /* | ||
167 | * The package count is variable, there are no sub-packages, and all | ||
168 | * elements must be of the same type | ||
169 | */ | ||
170 | for (i = 0; i < count; i++) { | ||
171 | status = acpi_ns_check_object_type(data, elements, | ||
172 | package->ret_info. | ||
173 | object_type1, i); | ||
174 | if (ACPI_FAILURE(status)) { | ||
175 | return (status); | ||
176 | } | ||
177 | elements++; | ||
178 | } | ||
179 | break; | ||
180 | |||
181 | case ACPI_PTYPE1_OPTION: | ||
182 | |||
183 | /* | ||
184 | * The package count is variable, there are no sub-packages. There are | ||
185 | * a fixed number of required elements, and a variable number of | ||
186 | * optional elements. | ||
187 | * | ||
188 | * Check if package is at least as large as the minimum required | ||
189 | */ | ||
190 | expected_count = package->ret_info3.count; | ||
191 | if (count < expected_count) { | ||
192 | goto package_too_small; | ||
193 | } | ||
194 | |||
195 | /* Variable number of sub-objects */ | ||
196 | |||
197 | for (i = 0; i < count; i++) { | ||
198 | if (i < package->ret_info3.count) { | ||
199 | |||
200 | /* These are the required package elements (0, 1, or 2) */ | ||
201 | |||
202 | status = | ||
203 | acpi_ns_check_object_type(data, elements, | ||
204 | package-> | ||
205 | ret_info3. | ||
206 | object_type[i], | ||
207 | i); | ||
208 | if (ACPI_FAILURE(status)) { | ||
209 | return (status); | ||
210 | } | ||
211 | } else { | ||
212 | /* These are the optional package elements */ | ||
213 | |||
214 | status = | ||
215 | acpi_ns_check_object_type(data, elements, | ||
216 | package-> | ||
217 | ret_info3. | ||
218 | tail_object_type, | ||
219 | i); | ||
220 | if (ACPI_FAILURE(status)) { | ||
221 | return (status); | ||
222 | } | ||
223 | } | ||
224 | elements++; | ||
225 | } | ||
226 | break; | ||
227 | |||
228 | case ACPI_PTYPE2_REV_FIXED: | ||
229 | |||
230 | /* First element is the (Integer) revision */ | ||
231 | |||
232 | status = acpi_ns_check_object_type(data, elements, | ||
233 | ACPI_RTYPE_INTEGER, 0); | ||
234 | if (ACPI_FAILURE(status)) { | ||
235 | return (status); | ||
236 | } | ||
237 | |||
238 | elements++; | ||
239 | count--; | ||
240 | |||
241 | /* Examine the sub-packages */ | ||
242 | |||
243 | status = | ||
244 | acpi_ns_check_package_list(data, package, elements, count); | ||
245 | break; | ||
246 | |||
247 | case ACPI_PTYPE2_PKG_COUNT: | ||
248 | |||
249 | /* First element is the (Integer) count of sub-packages to follow */ | ||
250 | |||
251 | status = acpi_ns_check_object_type(data, elements, | ||
252 | ACPI_RTYPE_INTEGER, 0); | ||
253 | if (ACPI_FAILURE(status)) { | ||
254 | return (status); | ||
255 | } | ||
256 | |||
257 | /* | ||
258 | * Count cannot be larger than the parent package length, but allow it | ||
259 | * to be smaller. The >= accounts for the Integer above. | ||
260 | */ | ||
261 | expected_count = (u32)(*elements)->integer.value; | ||
262 | if (expected_count >= count) { | ||
263 | goto package_too_small; | ||
264 | } | ||
265 | |||
266 | count = expected_count; | ||
267 | elements++; | ||
268 | |||
269 | /* Examine the sub-packages */ | ||
270 | |||
271 | status = | ||
272 | acpi_ns_check_package_list(data, package, elements, count); | ||
273 | break; | ||
274 | |||
275 | case ACPI_PTYPE2: | ||
276 | case ACPI_PTYPE2_FIXED: | ||
277 | case ACPI_PTYPE2_MIN: | ||
278 | case ACPI_PTYPE2_COUNT: | ||
279 | case ACPI_PTYPE2_FIX_VAR: | ||
280 | |||
281 | /* | ||
282 | * These types all return a single Package that consists of a | ||
283 | * variable number of sub-Packages. | ||
284 | * | ||
285 | * First, ensure that the first element is a sub-Package. If not, | ||
286 | * the BIOS may have incorrectly returned the object as a single | ||
287 | * package instead of a Package of Packages (a common error if | ||
288 | * there is only one entry). We may be able to repair this by | ||
289 | * wrapping the returned Package with a new outer Package. | ||
290 | */ | ||
291 | if (*elements | ||
292 | && ((*elements)->common.type != ACPI_TYPE_PACKAGE)) { | ||
293 | |||
294 | /* Create the new outer package and populate it */ | ||
295 | |||
296 | status = | ||
297 | acpi_ns_wrap_with_package(data, return_object, | ||
298 | return_object_ptr); | ||
299 | if (ACPI_FAILURE(status)) { | ||
300 | return (status); | ||
301 | } | ||
302 | |||
303 | /* Update locals to point to the new package (of 1 element) */ | ||
304 | |||
305 | return_object = *return_object_ptr; | ||
306 | elements = return_object->package.elements; | ||
307 | count = 1; | ||
308 | } | ||
309 | |||
310 | /* Examine the sub-packages */ | ||
311 | |||
312 | status = | ||
313 | acpi_ns_check_package_list(data, package, elements, count); | ||
314 | break; | ||
315 | |||
316 | default: | ||
317 | |||
318 | /* Should not get here if predefined info table is correct */ | ||
319 | |||
320 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | ||
321 | "Invalid internal return type in table entry: %X", | ||
322 | package->ret_info.type)); | ||
323 | |||
324 | return (AE_AML_INTERNAL); | ||
325 | } | ||
326 | |||
327 | return (status); | ||
328 | |||
329 | package_too_small: | ||
330 | |||
331 | /* Error exit for the case with an incorrect package count */ | ||
332 | |||
333 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | ||
334 | "Return Package is too small - found %u elements, expected %u", | ||
335 | count, expected_count)); | ||
336 | |||
337 | return (AE_AML_OPERAND_VALUE); | ||
338 | } | ||
339 | |||
340 | /******************************************************************************* | ||
341 | * | ||
342 | * FUNCTION: acpi_ns_check_package_list | ||
343 | * | ||
344 | * PARAMETERS: data - Pointer to validation data structure | ||
345 | * package - Pointer to package-specific info for method | ||
346 | * elements - Element list of parent package. All elements | ||
347 | * of this list should be of type Package. | ||
348 | * count - Count of subpackages | ||
349 | * | ||
350 | * RETURN: Status | ||
351 | * | ||
352 | * DESCRIPTION: Examine a list of subpackages | ||
353 | * | ||
354 | ******************************************************************************/ | ||
355 | |||
356 | static acpi_status | ||
357 | acpi_ns_check_package_list(struct acpi_predefined_data *data, | ||
358 | const union acpi_predefined_info *package, | ||
359 | union acpi_operand_object **elements, u32 count) | ||
360 | { | ||
361 | union acpi_operand_object *sub_package; | ||
362 | union acpi_operand_object **sub_elements; | ||
363 | acpi_status status; | ||
364 | u32 expected_count; | ||
365 | u32 i; | ||
366 | u32 j; | ||
367 | |||
368 | /* | ||
369 | * Validate each sub-Package in the parent Package | ||
370 | * | ||
371 | * NOTE: assumes list of sub-packages contains no NULL elements. | ||
372 | * Any NULL elements should have been removed by earlier call | ||
373 | * to acpi_ns_remove_null_elements. | ||
374 | */ | ||
375 | for (i = 0; i < count; i++) { | ||
376 | sub_package = *elements; | ||
377 | sub_elements = sub_package->package.elements; | ||
378 | data->parent_package = sub_package; | ||
379 | |||
380 | /* Each sub-object must be of type Package */ | ||
381 | |||
382 | status = acpi_ns_check_object_type(data, &sub_package, | ||
383 | ACPI_RTYPE_PACKAGE, i); | ||
384 | if (ACPI_FAILURE(status)) { | ||
385 | return (status); | ||
386 | } | ||
387 | |||
388 | /* Examine the different types of expected sub-packages */ | ||
389 | |||
390 | data->parent_package = sub_package; | ||
391 | switch (package->ret_info.type) { | ||
392 | case ACPI_PTYPE2: | ||
393 | case ACPI_PTYPE2_PKG_COUNT: | ||
394 | case ACPI_PTYPE2_REV_FIXED: | ||
395 | |||
396 | /* Each subpackage has a fixed number of elements */ | ||
397 | |||
398 | expected_count = | ||
399 | package->ret_info.count1 + package->ret_info.count2; | ||
400 | if (sub_package->package.count < expected_count) { | ||
401 | goto package_too_small; | ||
402 | } | ||
403 | |||
404 | status = | ||
405 | acpi_ns_check_package_elements(data, sub_elements, | ||
406 | package->ret_info. | ||
407 | object_type1, | ||
408 | package->ret_info. | ||
409 | count1, | ||
410 | package->ret_info. | ||
411 | object_type2, | ||
412 | package->ret_info. | ||
413 | count2, 0); | ||
414 | if (ACPI_FAILURE(status)) { | ||
415 | return (status); | ||
416 | } | ||
417 | break; | ||
418 | |||
419 | case ACPI_PTYPE2_FIX_VAR: | ||
420 | /* | ||
421 | * Each subpackage has a fixed number of elements and an | ||
422 | * optional element | ||
423 | */ | ||
424 | expected_count = | ||
425 | package->ret_info.count1 + package->ret_info.count2; | ||
426 | if (sub_package->package.count < expected_count) { | ||
427 | goto package_too_small; | ||
428 | } | ||
429 | |||
430 | status = | ||
431 | acpi_ns_check_package_elements(data, sub_elements, | ||
432 | package->ret_info. | ||
433 | object_type1, | ||
434 | package->ret_info. | ||
435 | count1, | ||
436 | package->ret_info. | ||
437 | object_type2, | ||
438 | sub_package->package. | ||
439 | count - | ||
440 | package->ret_info. | ||
441 | count1, 0); | ||
442 | if (ACPI_FAILURE(status)) { | ||
443 | return (status); | ||
444 | } | ||
445 | break; | ||
446 | |||
447 | case ACPI_PTYPE2_FIXED: | ||
448 | |||
449 | /* Each sub-package has a fixed length */ | ||
450 | |||
451 | expected_count = package->ret_info2.count; | ||
452 | if (sub_package->package.count < expected_count) { | ||
453 | goto package_too_small; | ||
454 | } | ||
455 | |||
456 | /* Check the type of each sub-package element */ | ||
457 | |||
458 | for (j = 0; j < expected_count; j++) { | ||
459 | status = | ||
460 | acpi_ns_check_object_type(data, | ||
461 | &sub_elements[j], | ||
462 | package-> | ||
463 | ret_info2. | ||
464 | object_type[j], | ||
465 | j); | ||
466 | if (ACPI_FAILURE(status)) { | ||
467 | return (status); | ||
468 | } | ||
469 | } | ||
470 | break; | ||
471 | |||
472 | case ACPI_PTYPE2_MIN: | ||
473 | |||
474 | /* Each sub-package has a variable but minimum length */ | ||
475 | |||
476 | expected_count = package->ret_info.count1; | ||
477 | if (sub_package->package.count < expected_count) { | ||
478 | goto package_too_small; | ||
479 | } | ||
480 | |||
481 | /* Check the type of each sub-package element */ | ||
482 | |||
483 | status = | ||
484 | acpi_ns_check_package_elements(data, sub_elements, | ||
485 | package->ret_info. | ||
486 | object_type1, | ||
487 | sub_package->package. | ||
488 | count, 0, 0, 0); | ||
489 | if (ACPI_FAILURE(status)) { | ||
490 | return (status); | ||
491 | } | ||
492 | break; | ||
493 | |||
494 | case ACPI_PTYPE2_COUNT: | ||
495 | |||
496 | /* | ||
497 | * First element is the (Integer) count of elements, including | ||
498 | * the count field (the ACPI name is num_elements) | ||
499 | */ | ||
500 | status = acpi_ns_check_object_type(data, sub_elements, | ||
501 | ACPI_RTYPE_INTEGER, | ||
502 | 0); | ||
503 | if (ACPI_FAILURE(status)) { | ||
504 | return (status); | ||
505 | } | ||
506 | |||
507 | /* | ||
508 | * Make sure package is large enough for the Count and is | ||
509 | * is as large as the minimum size | ||
510 | */ | ||
511 | expected_count = (u32)(*sub_elements)->integer.value; | ||
512 | if (sub_package->package.count < expected_count) { | ||
513 | goto package_too_small; | ||
514 | } | ||
515 | if (sub_package->package.count < | ||
516 | package->ret_info.count1) { | ||
517 | expected_count = package->ret_info.count1; | ||
518 | goto package_too_small; | ||
519 | } | ||
520 | if (expected_count == 0) { | ||
521 | /* | ||
522 | * Either the num_entries element was originally zero or it was | ||
523 | * a NULL element and repaired to an Integer of value zero. | ||
524 | * In either case, repair it by setting num_entries to be the | ||
525 | * actual size of the subpackage. | ||
526 | */ | ||
527 | expected_count = sub_package->package.count; | ||
528 | (*sub_elements)->integer.value = expected_count; | ||
529 | } | ||
530 | |||
531 | /* Check the type of each sub-package element */ | ||
532 | |||
533 | status = | ||
534 | acpi_ns_check_package_elements(data, | ||
535 | (sub_elements + 1), | ||
536 | package->ret_info. | ||
537 | object_type1, | ||
538 | (expected_count - 1), | ||
539 | 0, 0, 1); | ||
540 | if (ACPI_FAILURE(status)) { | ||
541 | return (status); | ||
542 | } | ||
543 | break; | ||
544 | |||
545 | default: /* Should not get here, type was validated by caller */ | ||
546 | |||
547 | return (AE_AML_INTERNAL); | ||
548 | } | ||
549 | |||
550 | elements++; | ||
551 | } | ||
552 | |||
553 | return (AE_OK); | ||
554 | |||
555 | package_too_small: | ||
556 | |||
557 | /* The sub-package count was smaller than required */ | ||
558 | |||
559 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | ||
560 | "Return Sub-Package[%u] is too small - found %u elements, expected %u", | ||
561 | i, sub_package->package.count, expected_count)); | ||
562 | |||
563 | return (AE_AML_OPERAND_VALUE); | ||
564 | } | ||
565 | |||
566 | /******************************************************************************* | ||
567 | * | ||
568 | * FUNCTION: acpi_ns_check_package_elements | ||
569 | * | ||
570 | * PARAMETERS: data - Pointer to validation data structure | ||
571 | * elements - Pointer to the package elements array | ||
572 | * type1 - Object type for first group | ||
573 | * count1 - Count for first group | ||
574 | * type2 - Object type for second group | ||
575 | * count2 - Count for second group | ||
576 | * start_index - Start of the first group of elements | ||
577 | * | ||
578 | * RETURN: Status | ||
579 | * | ||
580 | * DESCRIPTION: Check that all elements of a package are of the correct object | ||
581 | * type. Supports up to two groups of different object types. | ||
582 | * | ||
583 | ******************************************************************************/ | ||
584 | |||
585 | static acpi_status | ||
586 | acpi_ns_check_package_elements(struct acpi_predefined_data *data, | ||
587 | union acpi_operand_object **elements, | ||
588 | u8 type1, | ||
589 | u32 count1, | ||
590 | u8 type2, u32 count2, u32 start_index) | ||
591 | { | ||
592 | union acpi_operand_object **this_element = elements; | ||
593 | acpi_status status; | ||
594 | u32 i; | ||
595 | |||
596 | /* | ||
597 | * Up to two groups of package elements are supported by the data | ||
598 | * structure. All elements in each group must be of the same type. | ||
599 | * The second group can have a count of zero. | ||
600 | */ | ||
601 | for (i = 0; i < count1; i++) { | ||
602 | status = acpi_ns_check_object_type(data, this_element, | ||
603 | type1, i + start_index); | ||
604 | if (ACPI_FAILURE(status)) { | ||
605 | return (status); | ||
606 | } | ||
607 | this_element++; | ||
608 | } | ||
609 | |||
610 | for (i = 0; i < count2; i++) { | ||
611 | status = acpi_ns_check_object_type(data, this_element, | ||
612 | type2, | ||
613 | (i + count1 + start_index)); | ||
614 | if (ACPI_FAILURE(status)) { | ||
615 | return (status); | ||
616 | } | ||
617 | this_element++; | ||
618 | } | ||
619 | |||
620 | return (AE_OK); | ||
621 | } | ||
diff --git a/drivers/acpi/acpica/psloop.c b/drivers/acpi/acpica/psloop.c index a6f8592c9ae5..4261c5fe4718 100644 --- a/drivers/acpi/acpica/psloop.c +++ b/drivers/acpi/acpica/psloop.c | |||
@@ -58,353 +58,17 @@ | |||
58 | #define _COMPONENT ACPI_PARSER | 58 | #define _COMPONENT ACPI_PARSER |
59 | ACPI_MODULE_NAME("psloop") | 59 | ACPI_MODULE_NAME("psloop") |
60 | 60 | ||
61 | static u32 acpi_gbl_depth = 0; | ||
62 | |||
63 | /* Local prototypes */ | 61 | /* Local prototypes */ |
64 | |||
65 | static acpi_status acpi_ps_get_aml_opcode(struct acpi_walk_state *walk_state); | ||
66 | |||
67 | static acpi_status | ||
68 | acpi_ps_build_named_op(struct acpi_walk_state *walk_state, | ||
69 | u8 * aml_op_start, | ||
70 | union acpi_parse_object *unnamed_op, | ||
71 | union acpi_parse_object **op); | ||
72 | |||
73 | static acpi_status | ||
74 | acpi_ps_create_op(struct acpi_walk_state *walk_state, | ||
75 | u8 * aml_op_start, union acpi_parse_object **new_op); | ||
76 | |||
77 | static acpi_status | 62 | static acpi_status |
78 | acpi_ps_get_arguments(struct acpi_walk_state *walk_state, | 63 | acpi_ps_get_arguments(struct acpi_walk_state *walk_state, |
79 | u8 * aml_op_start, union acpi_parse_object *op); | 64 | u8 * aml_op_start, union acpi_parse_object *op); |
80 | 65 | ||
81 | static acpi_status | ||
82 | acpi_ps_complete_op(struct acpi_walk_state *walk_state, | ||
83 | union acpi_parse_object **op, acpi_status status); | ||
84 | |||
85 | static acpi_status | ||
86 | acpi_ps_complete_final_op(struct acpi_walk_state *walk_state, | ||
87 | union acpi_parse_object *op, acpi_status status); | ||
88 | |||
89 | static void | 66 | static void |
90 | acpi_ps_link_module_code(union acpi_parse_object *parent_op, | 67 | acpi_ps_link_module_code(union acpi_parse_object *parent_op, |
91 | u8 *aml_start, u32 aml_length, acpi_owner_id owner_id); | 68 | u8 *aml_start, u32 aml_length, acpi_owner_id owner_id); |
92 | 69 | ||
93 | /******************************************************************************* | 70 | /******************************************************************************* |
94 | * | 71 | * |
95 | * FUNCTION: acpi_ps_get_aml_opcode | ||
96 | * | ||
97 | * PARAMETERS: walk_state - Current state | ||
98 | * | ||
99 | * RETURN: Status | ||
100 | * | ||
101 | * DESCRIPTION: Extract the next AML opcode from the input stream. | ||
102 | * | ||
103 | ******************************************************************************/ | ||
104 | |||
105 | static acpi_status acpi_ps_get_aml_opcode(struct acpi_walk_state *walk_state) | ||
106 | { | ||
107 | |||
108 | ACPI_FUNCTION_TRACE_PTR(ps_get_aml_opcode, walk_state); | ||
109 | |||
110 | walk_state->aml_offset = | ||
111 | (u32) ACPI_PTR_DIFF(walk_state->parser_state.aml, | ||
112 | walk_state->parser_state.aml_start); | ||
113 | walk_state->opcode = acpi_ps_peek_opcode(&(walk_state->parser_state)); | ||
114 | |||
115 | /* | ||
116 | * First cut to determine what we have found: | ||
117 | * 1) A valid AML opcode | ||
118 | * 2) A name string | ||
119 | * 3) An unknown/invalid opcode | ||
120 | */ | ||
121 | walk_state->op_info = acpi_ps_get_opcode_info(walk_state->opcode); | ||
122 | |||
123 | switch (walk_state->op_info->class) { | ||
124 | case AML_CLASS_ASCII: | ||
125 | case AML_CLASS_PREFIX: | ||
126 | /* | ||
127 | * Starts with a valid prefix or ASCII char, this is a name | ||
128 | * string. Convert the bare name string to a namepath. | ||
129 | */ | ||
130 | walk_state->opcode = AML_INT_NAMEPATH_OP; | ||
131 | walk_state->arg_types = ARGP_NAMESTRING; | ||
132 | break; | ||
133 | |||
134 | case AML_CLASS_UNKNOWN: | ||
135 | |||
136 | /* The opcode is unrecognized. Complain and skip unknown opcodes */ | ||
137 | |||
138 | if (walk_state->pass_number == 2) { | ||
139 | ACPI_ERROR((AE_INFO, | ||
140 | "Unknown opcode 0x%.2X at table offset 0x%.4X, ignoring", | ||
141 | walk_state->opcode, | ||
142 | (u32)(walk_state->aml_offset + | ||
143 | sizeof(struct acpi_table_header)))); | ||
144 | |||
145 | ACPI_DUMP_BUFFER((walk_state->parser_state.aml - 16), | ||
146 | 48); | ||
147 | |||
148 | #ifdef ACPI_ASL_COMPILER | ||
149 | /* | ||
150 | * This is executed for the disassembler only. Output goes | ||
151 | * to the disassembled ASL output file. | ||
152 | */ | ||
153 | acpi_os_printf | ||
154 | ("/*\nError: Unknown opcode 0x%.2X at table offset 0x%.4X, context:\n", | ||
155 | walk_state->opcode, | ||
156 | (u32)(walk_state->aml_offset + | ||
157 | sizeof(struct acpi_table_header))); | ||
158 | |||
159 | /* Dump the context surrounding the invalid opcode */ | ||
160 | |||
161 | acpi_ut_dump_buffer(((u8 *)walk_state->parser_state. | ||
162 | aml - 16), 48, DB_BYTE_DISPLAY, | ||
163 | (walk_state->aml_offset + | ||
164 | sizeof(struct acpi_table_header) - | ||
165 | 16)); | ||
166 | acpi_os_printf(" */\n"); | ||
167 | #endif | ||
168 | } | ||
169 | |||
170 | /* Increment past one-byte or two-byte opcode */ | ||
171 | |||
172 | walk_state->parser_state.aml++; | ||
173 | if (walk_state->opcode > 0xFF) { /* Can only happen if first byte is 0x5B */ | ||
174 | walk_state->parser_state.aml++; | ||
175 | } | ||
176 | |||
177 | return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE); | ||
178 | |||
179 | default: | ||
180 | |||
181 | /* Found opcode info, this is a normal opcode */ | ||
182 | |||
183 | walk_state->parser_state.aml += | ||
184 | acpi_ps_get_opcode_size(walk_state->opcode); | ||
185 | walk_state->arg_types = walk_state->op_info->parse_args; | ||
186 | break; | ||
187 | } | ||
188 | |||
189 | return_ACPI_STATUS(AE_OK); | ||
190 | } | ||
191 | |||
192 | /******************************************************************************* | ||
193 | * | ||
194 | * FUNCTION: acpi_ps_build_named_op | ||
195 | * | ||
196 | * PARAMETERS: walk_state - Current state | ||
197 | * aml_op_start - Begin of named Op in AML | ||
198 | * unnamed_op - Early Op (not a named Op) | ||
199 | * op - Returned Op | ||
200 | * | ||
201 | * RETURN: Status | ||
202 | * | ||
203 | * DESCRIPTION: Parse a named Op | ||
204 | * | ||
205 | ******************************************************************************/ | ||
206 | |||
207 | static acpi_status | ||
208 | acpi_ps_build_named_op(struct acpi_walk_state *walk_state, | ||
209 | u8 * aml_op_start, | ||
210 | union acpi_parse_object *unnamed_op, | ||
211 | union acpi_parse_object **op) | ||
212 | { | ||
213 | acpi_status status = AE_OK; | ||
214 | union acpi_parse_object *arg = NULL; | ||
215 | |||
216 | ACPI_FUNCTION_TRACE_PTR(ps_build_named_op, walk_state); | ||
217 | |||
218 | unnamed_op->common.value.arg = NULL; | ||
219 | unnamed_op->common.arg_list_length = 0; | ||
220 | unnamed_op->common.aml_opcode = walk_state->opcode; | ||
221 | |||
222 | /* | ||
223 | * Get and append arguments until we find the node that contains | ||
224 | * the name (the type ARGP_NAME). | ||
225 | */ | ||
226 | while (GET_CURRENT_ARG_TYPE(walk_state->arg_types) && | ||
227 | (GET_CURRENT_ARG_TYPE(walk_state->arg_types) != ARGP_NAME)) { | ||
228 | status = | ||
229 | acpi_ps_get_next_arg(walk_state, | ||
230 | &(walk_state->parser_state), | ||
231 | GET_CURRENT_ARG_TYPE(walk_state-> | ||
232 | arg_types), &arg); | ||
233 | if (ACPI_FAILURE(status)) { | ||
234 | return_ACPI_STATUS(status); | ||
235 | } | ||
236 | |||
237 | acpi_ps_append_arg(unnamed_op, arg); | ||
238 | INCREMENT_ARG_LIST(walk_state->arg_types); | ||
239 | } | ||
240 | |||
241 | /* | ||
242 | * Make sure that we found a NAME and didn't run out of arguments | ||
243 | */ | ||
244 | if (!GET_CURRENT_ARG_TYPE(walk_state->arg_types)) { | ||
245 | return_ACPI_STATUS(AE_AML_NO_OPERAND); | ||
246 | } | ||
247 | |||
248 | /* We know that this arg is a name, move to next arg */ | ||
249 | |||
250 | INCREMENT_ARG_LIST(walk_state->arg_types); | ||
251 | |||
252 | /* | ||
253 | * Find the object. This will either insert the object into | ||
254 | * the namespace or simply look it up | ||
255 | */ | ||
256 | walk_state->op = NULL; | ||
257 | |||
258 | status = walk_state->descending_callback(walk_state, op); | ||
259 | if (ACPI_FAILURE(status)) { | ||
260 | ACPI_EXCEPTION((AE_INFO, status, "During name lookup/catalog")); | ||
261 | return_ACPI_STATUS(status); | ||
262 | } | ||
263 | |||
264 | if (!*op) { | ||
265 | return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE); | ||
266 | } | ||
267 | |||
268 | status = acpi_ps_next_parse_state(walk_state, *op, status); | ||
269 | if (ACPI_FAILURE(status)) { | ||
270 | if (status == AE_CTRL_PENDING) { | ||
271 | return_ACPI_STATUS(AE_CTRL_PARSE_PENDING); | ||
272 | } | ||
273 | return_ACPI_STATUS(status); | ||
274 | } | ||
275 | |||
276 | acpi_ps_append_arg(*op, unnamed_op->common.value.arg); | ||
277 | acpi_gbl_depth++; | ||
278 | |||
279 | if ((*op)->common.aml_opcode == AML_REGION_OP || | ||
280 | (*op)->common.aml_opcode == AML_DATA_REGION_OP) { | ||
281 | /* | ||
282 | * Defer final parsing of an operation_region body, because we don't | ||
283 | * have enough info in the first pass to parse it correctly (i.e., | ||
284 | * there may be method calls within the term_arg elements of the body.) | ||
285 | * | ||
286 | * However, we must continue parsing because the opregion is not a | ||
287 | * standalone package -- we don't know where the end is at this point. | ||
288 | * | ||
289 | * (Length is unknown until parse of the body complete) | ||
290 | */ | ||
291 | (*op)->named.data = aml_op_start; | ||
292 | (*op)->named.length = 0; | ||
293 | } | ||
294 | |||
295 | return_ACPI_STATUS(AE_OK); | ||
296 | } | ||
297 | |||
298 | /******************************************************************************* | ||
299 | * | ||
300 | * FUNCTION: acpi_ps_create_op | ||
301 | * | ||
302 | * PARAMETERS: walk_state - Current state | ||
303 | * aml_op_start - Op start in AML | ||
304 | * new_op - Returned Op | ||
305 | * | ||
306 | * RETURN: Status | ||
307 | * | ||
308 | * DESCRIPTION: Get Op from AML | ||
309 | * | ||
310 | ******************************************************************************/ | ||
311 | |||
312 | static acpi_status | ||
313 | acpi_ps_create_op(struct acpi_walk_state *walk_state, | ||
314 | u8 * aml_op_start, union acpi_parse_object **new_op) | ||
315 | { | ||
316 | acpi_status status = AE_OK; | ||
317 | union acpi_parse_object *op; | ||
318 | union acpi_parse_object *named_op = NULL; | ||
319 | union acpi_parse_object *parent_scope; | ||
320 | u8 argument_count; | ||
321 | const struct acpi_opcode_info *op_info; | ||
322 | |||
323 | ACPI_FUNCTION_TRACE_PTR(ps_create_op, walk_state); | ||
324 | |||
325 | status = acpi_ps_get_aml_opcode(walk_state); | ||
326 | if (status == AE_CTRL_PARSE_CONTINUE) { | ||
327 | return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE); | ||
328 | } | ||
329 | |||
330 | /* Create Op structure and append to parent's argument list */ | ||
331 | |||
332 | walk_state->op_info = acpi_ps_get_opcode_info(walk_state->opcode); | ||
333 | op = acpi_ps_alloc_op(walk_state->opcode); | ||
334 | if (!op) { | ||
335 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
336 | } | ||
337 | |||
338 | if (walk_state->op_info->flags & AML_NAMED) { | ||
339 | status = | ||
340 | acpi_ps_build_named_op(walk_state, aml_op_start, op, | ||
341 | &named_op); | ||
342 | acpi_ps_free_op(op); | ||
343 | if (ACPI_FAILURE(status)) { | ||
344 | return_ACPI_STATUS(status); | ||
345 | } | ||
346 | |||
347 | *new_op = named_op; | ||
348 | return_ACPI_STATUS(AE_OK); | ||
349 | } | ||
350 | |||
351 | /* Not a named opcode, just allocate Op and append to parent */ | ||
352 | |||
353 | if (walk_state->op_info->flags & AML_CREATE) { | ||
354 | /* | ||
355 | * Backup to beginning of create_XXXfield declaration | ||
356 | * body_length is unknown until we parse the body | ||
357 | */ | ||
358 | op->named.data = aml_op_start; | ||
359 | op->named.length = 0; | ||
360 | } | ||
361 | |||
362 | if (walk_state->opcode == AML_BANK_FIELD_OP) { | ||
363 | /* | ||
364 | * Backup to beginning of bank_field declaration | ||
365 | * body_length is unknown until we parse the body | ||
366 | */ | ||
367 | op->named.data = aml_op_start; | ||
368 | op->named.length = 0; | ||
369 | } | ||
370 | |||
371 | parent_scope = acpi_ps_get_parent_scope(&(walk_state->parser_state)); | ||
372 | acpi_ps_append_arg(parent_scope, op); | ||
373 | |||
374 | if (parent_scope) { | ||
375 | op_info = | ||
376 | acpi_ps_get_opcode_info(parent_scope->common.aml_opcode); | ||
377 | if (op_info->flags & AML_HAS_TARGET) { | ||
378 | argument_count = | ||
379 | acpi_ps_get_argument_count(op_info->type); | ||
380 | if (parent_scope->common.arg_list_length > | ||
381 | argument_count) { | ||
382 | op->common.flags |= ACPI_PARSEOP_TARGET; | ||
383 | } | ||
384 | } else if (parent_scope->common.aml_opcode == AML_INCREMENT_OP) { | ||
385 | op->common.flags |= ACPI_PARSEOP_TARGET; | ||
386 | } | ||
387 | } | ||
388 | |||
389 | if (walk_state->descending_callback != NULL) { | ||
390 | /* | ||
391 | * Find the object. This will either insert the object into | ||
392 | * the namespace or simply look it up | ||
393 | */ | ||
394 | walk_state->op = *new_op = op; | ||
395 | |||
396 | status = walk_state->descending_callback(walk_state, &op); | ||
397 | status = acpi_ps_next_parse_state(walk_state, op, status); | ||
398 | if (status == AE_CTRL_PENDING) { | ||
399 | status = AE_CTRL_PARSE_PENDING; | ||
400 | } | ||
401 | } | ||
402 | |||
403 | return_ACPI_STATUS(status); | ||
404 | } | ||
405 | |||
406 | /******************************************************************************* | ||
407 | * | ||
408 | * FUNCTION: acpi_ps_get_arguments | 72 | * FUNCTION: acpi_ps_get_arguments |
409 | * | 73 | * |
410 | * PARAMETERS: walk_state - Current state | 74 | * PARAMETERS: walk_state - Current state |
@@ -712,288 +376,6 @@ acpi_ps_link_module_code(union acpi_parse_object *parent_op, | |||
712 | 376 | ||
713 | /******************************************************************************* | 377 | /******************************************************************************* |
714 | * | 378 | * |
715 | * FUNCTION: acpi_ps_complete_op | ||
716 | * | ||
717 | * PARAMETERS: walk_state - Current state | ||
718 | * op - Returned Op | ||
719 | * status - Parse status before complete Op | ||
720 | * | ||
721 | * RETURN: Status | ||
722 | * | ||
723 | * DESCRIPTION: Complete Op | ||
724 | * | ||
725 | ******************************************************************************/ | ||
726 | |||
727 | static acpi_status | ||
728 | acpi_ps_complete_op(struct acpi_walk_state *walk_state, | ||
729 | union acpi_parse_object **op, acpi_status status) | ||
730 | { | ||
731 | acpi_status status2; | ||
732 | |||
733 | ACPI_FUNCTION_TRACE_PTR(ps_complete_op, walk_state); | ||
734 | |||
735 | /* | ||
736 | * Finished one argument of the containing scope | ||
737 | */ | ||
738 | walk_state->parser_state.scope->parse_scope.arg_count--; | ||
739 | |||
740 | /* Close this Op (will result in parse subtree deletion) */ | ||
741 | |||
742 | status2 = acpi_ps_complete_this_op(walk_state, *op); | ||
743 | if (ACPI_FAILURE(status2)) { | ||
744 | return_ACPI_STATUS(status2); | ||
745 | } | ||
746 | |||
747 | *op = NULL; | ||
748 | |||
749 | switch (status) { | ||
750 | case AE_OK: | ||
751 | break; | ||
752 | |||
753 | case AE_CTRL_TRANSFER: | ||
754 | |||
755 | /* We are about to transfer to a called method */ | ||
756 | |||
757 | walk_state->prev_op = NULL; | ||
758 | walk_state->prev_arg_types = walk_state->arg_types; | ||
759 | return_ACPI_STATUS(status); | ||
760 | |||
761 | case AE_CTRL_END: | ||
762 | |||
763 | acpi_ps_pop_scope(&(walk_state->parser_state), op, | ||
764 | &walk_state->arg_types, | ||
765 | &walk_state->arg_count); | ||
766 | |||
767 | if (*op) { | ||
768 | walk_state->op = *op; | ||
769 | walk_state->op_info = | ||
770 | acpi_ps_get_opcode_info((*op)->common.aml_opcode); | ||
771 | walk_state->opcode = (*op)->common.aml_opcode; | ||
772 | |||
773 | status = walk_state->ascending_callback(walk_state); | ||
774 | status = | ||
775 | acpi_ps_next_parse_state(walk_state, *op, status); | ||
776 | |||
777 | status2 = acpi_ps_complete_this_op(walk_state, *op); | ||
778 | if (ACPI_FAILURE(status2)) { | ||
779 | return_ACPI_STATUS(status2); | ||
780 | } | ||
781 | } | ||
782 | |||
783 | status = AE_OK; | ||
784 | break; | ||
785 | |||
786 | case AE_CTRL_BREAK: | ||
787 | case AE_CTRL_CONTINUE: | ||
788 | |||
789 | /* Pop off scopes until we find the While */ | ||
790 | |||
791 | while (!(*op) || ((*op)->common.aml_opcode != AML_WHILE_OP)) { | ||
792 | acpi_ps_pop_scope(&(walk_state->parser_state), op, | ||
793 | &walk_state->arg_types, | ||
794 | &walk_state->arg_count); | ||
795 | } | ||
796 | |||
797 | /* Close this iteration of the While loop */ | ||
798 | |||
799 | walk_state->op = *op; | ||
800 | walk_state->op_info = | ||
801 | acpi_ps_get_opcode_info((*op)->common.aml_opcode); | ||
802 | walk_state->opcode = (*op)->common.aml_opcode; | ||
803 | |||
804 | status = walk_state->ascending_callback(walk_state); | ||
805 | status = acpi_ps_next_parse_state(walk_state, *op, status); | ||
806 | |||
807 | status2 = acpi_ps_complete_this_op(walk_state, *op); | ||
808 | if (ACPI_FAILURE(status2)) { | ||
809 | return_ACPI_STATUS(status2); | ||
810 | } | ||
811 | |||
812 | status = AE_OK; | ||
813 | break; | ||
814 | |||
815 | case AE_CTRL_TERMINATE: | ||
816 | |||
817 | /* Clean up */ | ||
818 | do { | ||
819 | if (*op) { | ||
820 | status2 = | ||
821 | acpi_ps_complete_this_op(walk_state, *op); | ||
822 | if (ACPI_FAILURE(status2)) { | ||
823 | return_ACPI_STATUS(status2); | ||
824 | } | ||
825 | |||
826 | acpi_ut_delete_generic_state | ||
827 | (acpi_ut_pop_generic_state | ||
828 | (&walk_state->control_state)); | ||
829 | } | ||
830 | |||
831 | acpi_ps_pop_scope(&(walk_state->parser_state), op, | ||
832 | &walk_state->arg_types, | ||
833 | &walk_state->arg_count); | ||
834 | |||
835 | } while (*op); | ||
836 | |||
837 | return_ACPI_STATUS(AE_OK); | ||
838 | |||
839 | default: /* All other non-AE_OK status */ | ||
840 | |||
841 | do { | ||
842 | if (*op) { | ||
843 | status2 = | ||
844 | acpi_ps_complete_this_op(walk_state, *op); | ||
845 | if (ACPI_FAILURE(status2)) { | ||
846 | return_ACPI_STATUS(status2); | ||
847 | } | ||
848 | } | ||
849 | |||
850 | acpi_ps_pop_scope(&(walk_state->parser_state), op, | ||
851 | &walk_state->arg_types, | ||
852 | &walk_state->arg_count); | ||
853 | |||
854 | } while (*op); | ||
855 | |||
856 | #if 0 | ||
857 | /* | ||
858 | * TBD: Cleanup parse ops on error | ||
859 | */ | ||
860 | if (*op == NULL) { | ||
861 | acpi_ps_pop_scope(parser_state, op, | ||
862 | &walk_state->arg_types, | ||
863 | &walk_state->arg_count); | ||
864 | } | ||
865 | #endif | ||
866 | walk_state->prev_op = NULL; | ||
867 | walk_state->prev_arg_types = walk_state->arg_types; | ||
868 | return_ACPI_STATUS(status); | ||
869 | } | ||
870 | |||
871 | /* This scope complete? */ | ||
872 | |||
873 | if (acpi_ps_has_completed_scope(&(walk_state->parser_state))) { | ||
874 | acpi_ps_pop_scope(&(walk_state->parser_state), op, | ||
875 | &walk_state->arg_types, | ||
876 | &walk_state->arg_count); | ||
877 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "Popped scope, Op=%p\n", *op)); | ||
878 | } else { | ||
879 | *op = NULL; | ||
880 | } | ||
881 | |||
882 | return_ACPI_STATUS(AE_OK); | ||
883 | } | ||
884 | |||
885 | /******************************************************************************* | ||
886 | * | ||
887 | * FUNCTION: acpi_ps_complete_final_op | ||
888 | * | ||
889 | * PARAMETERS: walk_state - Current state | ||
890 | * op - Current Op | ||
891 | * status - Current parse status before complete last | ||
892 | * Op | ||
893 | * | ||
894 | * RETURN: Status | ||
895 | * | ||
896 | * DESCRIPTION: Complete last Op. | ||
897 | * | ||
898 | ******************************************************************************/ | ||
899 | |||
900 | static acpi_status | ||
901 | acpi_ps_complete_final_op(struct acpi_walk_state *walk_state, | ||
902 | union acpi_parse_object *op, acpi_status status) | ||
903 | { | ||
904 | acpi_status status2; | ||
905 | |||
906 | ACPI_FUNCTION_TRACE_PTR(ps_complete_final_op, walk_state); | ||
907 | |||
908 | /* | ||
909 | * Complete the last Op (if not completed), and clear the scope stack. | ||
910 | * It is easily possible to end an AML "package" with an unbounded number | ||
911 | * of open scopes (such as when several ASL blocks are closed with | ||
912 | * sequential closing braces). We want to terminate each one cleanly. | ||
913 | */ | ||
914 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "AML package complete at Op %p\n", | ||
915 | op)); | ||
916 | do { | ||
917 | if (op) { | ||
918 | if (walk_state->ascending_callback != NULL) { | ||
919 | walk_state->op = op; | ||
920 | walk_state->op_info = | ||
921 | acpi_ps_get_opcode_info(op->common. | ||
922 | aml_opcode); | ||
923 | walk_state->opcode = op->common.aml_opcode; | ||
924 | |||
925 | status = | ||
926 | walk_state->ascending_callback(walk_state); | ||
927 | status = | ||
928 | acpi_ps_next_parse_state(walk_state, op, | ||
929 | status); | ||
930 | if (status == AE_CTRL_PENDING) { | ||
931 | status = | ||
932 | acpi_ps_complete_op(walk_state, &op, | ||
933 | AE_OK); | ||
934 | if (ACPI_FAILURE(status)) { | ||
935 | return_ACPI_STATUS(status); | ||
936 | } | ||
937 | } | ||
938 | |||
939 | if (status == AE_CTRL_TERMINATE) { | ||
940 | status = AE_OK; | ||
941 | |||
942 | /* Clean up */ | ||
943 | do { | ||
944 | if (op) { | ||
945 | status2 = | ||
946 | acpi_ps_complete_this_op | ||
947 | (walk_state, op); | ||
948 | if (ACPI_FAILURE | ||
949 | (status2)) { | ||
950 | return_ACPI_STATUS | ||
951 | (status2); | ||
952 | } | ||
953 | } | ||
954 | |||
955 | acpi_ps_pop_scope(& | ||
956 | (walk_state-> | ||
957 | parser_state), | ||
958 | &op, | ||
959 | &walk_state-> | ||
960 | arg_types, | ||
961 | &walk_state-> | ||
962 | arg_count); | ||
963 | |||
964 | } while (op); | ||
965 | |||
966 | return_ACPI_STATUS(status); | ||
967 | } | ||
968 | |||
969 | else if (ACPI_FAILURE(status)) { | ||
970 | |||
971 | /* First error is most important */ | ||
972 | |||
973 | (void) | ||
974 | acpi_ps_complete_this_op(walk_state, | ||
975 | op); | ||
976 | return_ACPI_STATUS(status); | ||
977 | } | ||
978 | } | ||
979 | |||
980 | status2 = acpi_ps_complete_this_op(walk_state, op); | ||
981 | if (ACPI_FAILURE(status2)) { | ||
982 | return_ACPI_STATUS(status2); | ||
983 | } | ||
984 | } | ||
985 | |||
986 | acpi_ps_pop_scope(&(walk_state->parser_state), &op, | ||
987 | &walk_state->arg_types, | ||
988 | &walk_state->arg_count); | ||
989 | |||
990 | } while (op); | ||
991 | |||
992 | return_ACPI_STATUS(status); | ||
993 | } | ||
994 | |||
995 | /******************************************************************************* | ||
996 | * | ||
997 | * FUNCTION: acpi_ps_parse_loop | 379 | * FUNCTION: acpi_ps_parse_loop |
998 | * | 380 | * |
999 | * PARAMETERS: walk_state - Current state | 381 | * PARAMETERS: walk_state - Current state |
@@ -1178,10 +560,6 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state) | |||
1178 | walk_state->op_info = | 560 | walk_state->op_info = |
1179 | acpi_ps_get_opcode_info(op->common.aml_opcode); | 561 | acpi_ps_get_opcode_info(op->common.aml_opcode); |
1180 | if (walk_state->op_info->flags & AML_NAMED) { | 562 | if (walk_state->op_info->flags & AML_NAMED) { |
1181 | if (acpi_gbl_depth) { | ||
1182 | acpi_gbl_depth--; | ||
1183 | } | ||
1184 | |||
1185 | if (op->common.aml_opcode == AML_REGION_OP || | 563 | if (op->common.aml_opcode == AML_REGION_OP || |
1186 | op->common.aml_opcode == AML_DATA_REGION_OP) { | 564 | op->common.aml_opcode == AML_DATA_REGION_OP) { |
1187 | /* | 565 | /* |
diff --git a/drivers/acpi/acpica/psobject.c b/drivers/acpi/acpica/psobject.c new file mode 100644 index 000000000000..2f461e4dddff --- /dev/null +++ b/drivers/acpi/acpica/psobject.c | |||
@@ -0,0 +1,647 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: psobject - Support for parse objects | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2012, 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 "acparser.h" | ||
47 | #include "amlcode.h" | ||
48 | |||
49 | #define _COMPONENT ACPI_PARSER | ||
50 | ACPI_MODULE_NAME("psobject") | ||
51 | |||
52 | /* Local prototypes */ | ||
53 | static acpi_status acpi_ps_get_aml_opcode(struct acpi_walk_state *walk_state); | ||
54 | |||
55 | /******************************************************************************* | ||
56 | * | ||
57 | * FUNCTION: acpi_ps_get_aml_opcode | ||
58 | * | ||
59 | * PARAMETERS: walk_state - Current state | ||
60 | * | ||
61 | * RETURN: Status | ||
62 | * | ||
63 | * DESCRIPTION: Extract the next AML opcode from the input stream. | ||
64 | * | ||
65 | ******************************************************************************/ | ||
66 | |||
67 | static acpi_status acpi_ps_get_aml_opcode(struct acpi_walk_state *walk_state) | ||
68 | { | ||
69 | |||
70 | ACPI_FUNCTION_TRACE_PTR(ps_get_aml_opcode, walk_state); | ||
71 | |||
72 | walk_state->aml_offset = | ||
73 | (u32)ACPI_PTR_DIFF(walk_state->parser_state.aml, | ||
74 | walk_state->parser_state.aml_start); | ||
75 | walk_state->opcode = acpi_ps_peek_opcode(&(walk_state->parser_state)); | ||
76 | |||
77 | /* | ||
78 | * First cut to determine what we have found: | ||
79 | * 1) A valid AML opcode | ||
80 | * 2) A name string | ||
81 | * 3) An unknown/invalid opcode | ||
82 | */ | ||
83 | walk_state->op_info = acpi_ps_get_opcode_info(walk_state->opcode); | ||
84 | |||
85 | switch (walk_state->op_info->class) { | ||
86 | case AML_CLASS_ASCII: | ||
87 | case AML_CLASS_PREFIX: | ||
88 | /* | ||
89 | * Starts with a valid prefix or ASCII char, this is a name | ||
90 | * string. Convert the bare name string to a namepath. | ||
91 | */ | ||
92 | walk_state->opcode = AML_INT_NAMEPATH_OP; | ||
93 | walk_state->arg_types = ARGP_NAMESTRING; | ||
94 | break; | ||
95 | |||
96 | case AML_CLASS_UNKNOWN: | ||
97 | |||
98 | /* The opcode is unrecognized. Complain and skip unknown opcodes */ | ||
99 | |||
100 | if (walk_state->pass_number == 2) { | ||
101 | ACPI_ERROR((AE_INFO, | ||
102 | "Unknown opcode 0x%.2X at table offset 0x%.4X, ignoring", | ||
103 | walk_state->opcode, | ||
104 | (u32)(walk_state->aml_offset + | ||
105 | sizeof(struct acpi_table_header)))); | ||
106 | |||
107 | ACPI_DUMP_BUFFER((walk_state->parser_state.aml - 16), | ||
108 | 48); | ||
109 | |||
110 | #ifdef ACPI_ASL_COMPILER | ||
111 | /* | ||
112 | * This is executed for the disassembler only. Output goes | ||
113 | * to the disassembled ASL output file. | ||
114 | */ | ||
115 | acpi_os_printf | ||
116 | ("/*\nError: Unknown opcode 0x%.2X at table offset 0x%.4X, context:\n", | ||
117 | walk_state->opcode, | ||
118 | (u32)(walk_state->aml_offset + | ||
119 | sizeof(struct acpi_table_header))); | ||
120 | |||
121 | /* Dump the context surrounding the invalid opcode */ | ||
122 | |||
123 | acpi_ut_dump_buffer(((u8 *)walk_state->parser_state. | ||
124 | aml - 16), 48, DB_BYTE_DISPLAY, | ||
125 | (walk_state->aml_offset + | ||
126 | sizeof(struct acpi_table_header) - | ||
127 | 16)); | ||
128 | acpi_os_printf(" */\n"); | ||
129 | #endif | ||
130 | } | ||
131 | |||
132 | /* Increment past one-byte or two-byte opcode */ | ||
133 | |||
134 | walk_state->parser_state.aml++; | ||
135 | if (walk_state->opcode > 0xFF) { /* Can only happen if first byte is 0x5B */ | ||
136 | walk_state->parser_state.aml++; | ||
137 | } | ||
138 | |||
139 | return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE); | ||
140 | |||
141 | default: | ||
142 | |||
143 | /* Found opcode info, this is a normal opcode */ | ||
144 | |||
145 | walk_state->parser_state.aml += | ||
146 | acpi_ps_get_opcode_size(walk_state->opcode); | ||
147 | walk_state->arg_types = walk_state->op_info->parse_args; | ||
148 | break; | ||
149 | } | ||
150 | |||
151 | return_ACPI_STATUS(AE_OK); | ||
152 | } | ||
153 | |||
154 | /******************************************************************************* | ||
155 | * | ||
156 | * FUNCTION: acpi_ps_build_named_op | ||
157 | * | ||
158 | * PARAMETERS: walk_state - Current state | ||
159 | * aml_op_start - Begin of named Op in AML | ||
160 | * unnamed_op - Early Op (not a named Op) | ||
161 | * op - Returned Op | ||
162 | * | ||
163 | * RETURN: Status | ||
164 | * | ||
165 | * DESCRIPTION: Parse a named Op | ||
166 | * | ||
167 | ******************************************************************************/ | ||
168 | |||
169 | acpi_status | ||
170 | acpi_ps_build_named_op(struct acpi_walk_state *walk_state, | ||
171 | u8 *aml_op_start, | ||
172 | union acpi_parse_object *unnamed_op, | ||
173 | union acpi_parse_object **op) | ||
174 | { | ||
175 | acpi_status status = AE_OK; | ||
176 | union acpi_parse_object *arg = NULL; | ||
177 | |||
178 | ACPI_FUNCTION_TRACE_PTR(ps_build_named_op, walk_state); | ||
179 | |||
180 | unnamed_op->common.value.arg = NULL; | ||
181 | unnamed_op->common.arg_list_length = 0; | ||
182 | unnamed_op->common.aml_opcode = walk_state->opcode; | ||
183 | |||
184 | /* | ||
185 | * Get and append arguments until we find the node that contains | ||
186 | * the name (the type ARGP_NAME). | ||
187 | */ | ||
188 | while (GET_CURRENT_ARG_TYPE(walk_state->arg_types) && | ||
189 | (GET_CURRENT_ARG_TYPE(walk_state->arg_types) != ARGP_NAME)) { | ||
190 | status = | ||
191 | acpi_ps_get_next_arg(walk_state, | ||
192 | &(walk_state->parser_state), | ||
193 | GET_CURRENT_ARG_TYPE(walk_state-> | ||
194 | arg_types), &arg); | ||
195 | if (ACPI_FAILURE(status)) { | ||
196 | return_ACPI_STATUS(status); | ||
197 | } | ||
198 | |||
199 | acpi_ps_append_arg(unnamed_op, arg); | ||
200 | INCREMENT_ARG_LIST(walk_state->arg_types); | ||
201 | } | ||
202 | |||
203 | /* | ||
204 | * Make sure that we found a NAME and didn't run out of arguments | ||
205 | */ | ||
206 | if (!GET_CURRENT_ARG_TYPE(walk_state->arg_types)) { | ||
207 | return_ACPI_STATUS(AE_AML_NO_OPERAND); | ||
208 | } | ||
209 | |||
210 | /* We know that this arg is a name, move to next arg */ | ||
211 | |||
212 | INCREMENT_ARG_LIST(walk_state->arg_types); | ||
213 | |||
214 | /* | ||
215 | * Find the object. This will either insert the object into | ||
216 | * the namespace or simply look it up | ||
217 | */ | ||
218 | walk_state->op = NULL; | ||
219 | |||
220 | status = walk_state->descending_callback(walk_state, op); | ||
221 | if (ACPI_FAILURE(status)) { | ||
222 | ACPI_EXCEPTION((AE_INFO, status, "During name lookup/catalog")); | ||
223 | return_ACPI_STATUS(status); | ||
224 | } | ||
225 | |||
226 | if (!*op) { | ||
227 | return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE); | ||
228 | } | ||
229 | |||
230 | status = acpi_ps_next_parse_state(walk_state, *op, status); | ||
231 | if (ACPI_FAILURE(status)) { | ||
232 | if (status == AE_CTRL_PENDING) { | ||
233 | return_ACPI_STATUS(AE_CTRL_PARSE_PENDING); | ||
234 | } | ||
235 | return_ACPI_STATUS(status); | ||
236 | } | ||
237 | |||
238 | acpi_ps_append_arg(*op, unnamed_op->common.value.arg); | ||
239 | |||
240 | if ((*op)->common.aml_opcode == AML_REGION_OP || | ||
241 | (*op)->common.aml_opcode == AML_DATA_REGION_OP) { | ||
242 | /* | ||
243 | * Defer final parsing of an operation_region body, because we don't | ||
244 | * have enough info in the first pass to parse it correctly (i.e., | ||
245 | * there may be method calls within the term_arg elements of the body.) | ||
246 | * | ||
247 | * However, we must continue parsing because the opregion is not a | ||
248 | * standalone package -- we don't know where the end is at this point. | ||
249 | * | ||
250 | * (Length is unknown until parse of the body complete) | ||
251 | */ | ||
252 | (*op)->named.data = aml_op_start; | ||
253 | (*op)->named.length = 0; | ||
254 | } | ||
255 | |||
256 | return_ACPI_STATUS(AE_OK); | ||
257 | } | ||
258 | |||
259 | /******************************************************************************* | ||
260 | * | ||
261 | * FUNCTION: acpi_ps_create_op | ||
262 | * | ||
263 | * PARAMETERS: walk_state - Current state | ||
264 | * aml_op_start - Op start in AML | ||
265 | * new_op - Returned Op | ||
266 | * | ||
267 | * RETURN: Status | ||
268 | * | ||
269 | * DESCRIPTION: Get Op from AML | ||
270 | * | ||
271 | ******************************************************************************/ | ||
272 | |||
273 | acpi_status | ||
274 | acpi_ps_create_op(struct acpi_walk_state *walk_state, | ||
275 | u8 *aml_op_start, union acpi_parse_object **new_op) | ||
276 | { | ||
277 | acpi_status status = AE_OK; | ||
278 | union acpi_parse_object *op; | ||
279 | union acpi_parse_object *named_op = NULL; | ||
280 | union acpi_parse_object *parent_scope; | ||
281 | u8 argument_count; | ||
282 | const struct acpi_opcode_info *op_info; | ||
283 | |||
284 | ACPI_FUNCTION_TRACE_PTR(ps_create_op, walk_state); | ||
285 | |||
286 | status = acpi_ps_get_aml_opcode(walk_state); | ||
287 | if (status == AE_CTRL_PARSE_CONTINUE) { | ||
288 | return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE); | ||
289 | } | ||
290 | |||
291 | /* Create Op structure and append to parent's argument list */ | ||
292 | |||
293 | walk_state->op_info = acpi_ps_get_opcode_info(walk_state->opcode); | ||
294 | op = acpi_ps_alloc_op(walk_state->opcode); | ||
295 | if (!op) { | ||
296 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
297 | } | ||
298 | |||
299 | if (walk_state->op_info->flags & AML_NAMED) { | ||
300 | status = | ||
301 | acpi_ps_build_named_op(walk_state, aml_op_start, op, | ||
302 | &named_op); | ||
303 | acpi_ps_free_op(op); | ||
304 | if (ACPI_FAILURE(status)) { | ||
305 | return_ACPI_STATUS(status); | ||
306 | } | ||
307 | |||
308 | *new_op = named_op; | ||
309 | return_ACPI_STATUS(AE_OK); | ||
310 | } | ||
311 | |||
312 | /* Not a named opcode, just allocate Op and append to parent */ | ||
313 | |||
314 | if (walk_state->op_info->flags & AML_CREATE) { | ||
315 | /* | ||
316 | * Backup to beginning of create_XXXfield declaration | ||
317 | * body_length is unknown until we parse the body | ||
318 | */ | ||
319 | op->named.data = aml_op_start; | ||
320 | op->named.length = 0; | ||
321 | } | ||
322 | |||
323 | if (walk_state->opcode == AML_BANK_FIELD_OP) { | ||
324 | /* | ||
325 | * Backup to beginning of bank_field declaration | ||
326 | * body_length is unknown until we parse the body | ||
327 | */ | ||
328 | op->named.data = aml_op_start; | ||
329 | op->named.length = 0; | ||
330 | } | ||
331 | |||
332 | parent_scope = acpi_ps_get_parent_scope(&(walk_state->parser_state)); | ||
333 | acpi_ps_append_arg(parent_scope, op); | ||
334 | |||
335 | if (parent_scope) { | ||
336 | op_info = | ||
337 | acpi_ps_get_opcode_info(parent_scope->common.aml_opcode); | ||
338 | if (op_info->flags & AML_HAS_TARGET) { | ||
339 | argument_count = | ||
340 | acpi_ps_get_argument_count(op_info->type); | ||
341 | if (parent_scope->common.arg_list_length > | ||
342 | argument_count) { | ||
343 | op->common.flags |= ACPI_PARSEOP_TARGET; | ||
344 | } | ||
345 | } else if (parent_scope->common.aml_opcode == AML_INCREMENT_OP) { | ||
346 | op->common.flags |= ACPI_PARSEOP_TARGET; | ||
347 | } | ||
348 | } | ||
349 | |||
350 | if (walk_state->descending_callback != NULL) { | ||
351 | /* | ||
352 | * Find the object. This will either insert the object into | ||
353 | * the namespace or simply look it up | ||
354 | */ | ||
355 | walk_state->op = *new_op = op; | ||
356 | |||
357 | status = walk_state->descending_callback(walk_state, &op); | ||
358 | status = acpi_ps_next_parse_state(walk_state, op, status); | ||
359 | if (status == AE_CTRL_PENDING) { | ||
360 | status = AE_CTRL_PARSE_PENDING; | ||
361 | } | ||
362 | } | ||
363 | |||
364 | return_ACPI_STATUS(status); | ||
365 | } | ||
366 | |||
367 | /******************************************************************************* | ||
368 | * | ||
369 | * FUNCTION: acpi_ps_complete_op | ||
370 | * | ||
371 | * PARAMETERS: walk_state - Current state | ||
372 | * op - Returned Op | ||
373 | * status - Parse status before complete Op | ||
374 | * | ||
375 | * RETURN: Status | ||
376 | * | ||
377 | * DESCRIPTION: Complete Op | ||
378 | * | ||
379 | ******************************************************************************/ | ||
380 | |||
381 | acpi_status | ||
382 | acpi_ps_complete_op(struct acpi_walk_state *walk_state, | ||
383 | union acpi_parse_object **op, acpi_status status) | ||
384 | { | ||
385 | acpi_status status2; | ||
386 | |||
387 | ACPI_FUNCTION_TRACE_PTR(ps_complete_op, walk_state); | ||
388 | |||
389 | /* | ||
390 | * Finished one argument of the containing scope | ||
391 | */ | ||
392 | walk_state->parser_state.scope->parse_scope.arg_count--; | ||
393 | |||
394 | /* Close this Op (will result in parse subtree deletion) */ | ||
395 | |||
396 | status2 = acpi_ps_complete_this_op(walk_state, *op); | ||
397 | if (ACPI_FAILURE(status2)) { | ||
398 | return_ACPI_STATUS(status2); | ||
399 | } | ||
400 | |||
401 | *op = NULL; | ||
402 | |||
403 | switch (status) { | ||
404 | case AE_OK: | ||
405 | break; | ||
406 | |||
407 | case AE_CTRL_TRANSFER: | ||
408 | |||
409 | /* We are about to transfer to a called method */ | ||
410 | |||
411 | walk_state->prev_op = NULL; | ||
412 | walk_state->prev_arg_types = walk_state->arg_types; | ||
413 | return_ACPI_STATUS(status); | ||
414 | |||
415 | case AE_CTRL_END: | ||
416 | |||
417 | acpi_ps_pop_scope(&(walk_state->parser_state), op, | ||
418 | &walk_state->arg_types, | ||
419 | &walk_state->arg_count); | ||
420 | |||
421 | if (*op) { | ||
422 | walk_state->op = *op; | ||
423 | walk_state->op_info = | ||
424 | acpi_ps_get_opcode_info((*op)->common.aml_opcode); | ||
425 | walk_state->opcode = (*op)->common.aml_opcode; | ||
426 | |||
427 | status = walk_state->ascending_callback(walk_state); | ||
428 | status = | ||
429 | acpi_ps_next_parse_state(walk_state, *op, status); | ||
430 | |||
431 | status2 = acpi_ps_complete_this_op(walk_state, *op); | ||
432 | if (ACPI_FAILURE(status2)) { | ||
433 | return_ACPI_STATUS(status2); | ||
434 | } | ||
435 | } | ||
436 | |||
437 | status = AE_OK; | ||
438 | break; | ||
439 | |||
440 | case AE_CTRL_BREAK: | ||
441 | case AE_CTRL_CONTINUE: | ||
442 | |||
443 | /* Pop off scopes until we find the While */ | ||
444 | |||
445 | while (!(*op) || ((*op)->common.aml_opcode != AML_WHILE_OP)) { | ||
446 | acpi_ps_pop_scope(&(walk_state->parser_state), op, | ||
447 | &walk_state->arg_types, | ||
448 | &walk_state->arg_count); | ||
449 | } | ||
450 | |||
451 | /* Close this iteration of the While loop */ | ||
452 | |||
453 | walk_state->op = *op; | ||
454 | walk_state->op_info = | ||
455 | acpi_ps_get_opcode_info((*op)->common.aml_opcode); | ||
456 | walk_state->opcode = (*op)->common.aml_opcode; | ||
457 | |||
458 | status = walk_state->ascending_callback(walk_state); | ||
459 | status = acpi_ps_next_parse_state(walk_state, *op, status); | ||
460 | |||
461 | status2 = acpi_ps_complete_this_op(walk_state, *op); | ||
462 | if (ACPI_FAILURE(status2)) { | ||
463 | return_ACPI_STATUS(status2); | ||
464 | } | ||
465 | |||
466 | status = AE_OK; | ||
467 | break; | ||
468 | |||
469 | case AE_CTRL_TERMINATE: | ||
470 | |||
471 | /* Clean up */ | ||
472 | do { | ||
473 | if (*op) { | ||
474 | status2 = | ||
475 | acpi_ps_complete_this_op(walk_state, *op); | ||
476 | if (ACPI_FAILURE(status2)) { | ||
477 | return_ACPI_STATUS(status2); | ||
478 | } | ||
479 | |||
480 | acpi_ut_delete_generic_state | ||
481 | (acpi_ut_pop_generic_state | ||
482 | (&walk_state->control_state)); | ||
483 | } | ||
484 | |||
485 | acpi_ps_pop_scope(&(walk_state->parser_state), op, | ||
486 | &walk_state->arg_types, | ||
487 | &walk_state->arg_count); | ||
488 | |||
489 | } while (*op); | ||
490 | |||
491 | return_ACPI_STATUS(AE_OK); | ||
492 | |||
493 | default: /* All other non-AE_OK status */ | ||
494 | |||
495 | do { | ||
496 | if (*op) { | ||
497 | status2 = | ||
498 | acpi_ps_complete_this_op(walk_state, *op); | ||
499 | if (ACPI_FAILURE(status2)) { | ||
500 | return_ACPI_STATUS(status2); | ||
501 | } | ||
502 | } | ||
503 | |||
504 | acpi_ps_pop_scope(&(walk_state->parser_state), op, | ||
505 | &walk_state->arg_types, | ||
506 | &walk_state->arg_count); | ||
507 | |||
508 | } while (*op); | ||
509 | |||
510 | #if 0 | ||
511 | /* | ||
512 | * TBD: Cleanup parse ops on error | ||
513 | */ | ||
514 | if (*op == NULL) { | ||
515 | acpi_ps_pop_scope(parser_state, op, | ||
516 | &walk_state->arg_types, | ||
517 | &walk_state->arg_count); | ||
518 | } | ||
519 | #endif | ||
520 | walk_state->prev_op = NULL; | ||
521 | walk_state->prev_arg_types = walk_state->arg_types; | ||
522 | return_ACPI_STATUS(status); | ||
523 | } | ||
524 | |||
525 | /* This scope complete? */ | ||
526 | |||
527 | if (acpi_ps_has_completed_scope(&(walk_state->parser_state))) { | ||
528 | acpi_ps_pop_scope(&(walk_state->parser_state), op, | ||
529 | &walk_state->arg_types, | ||
530 | &walk_state->arg_count); | ||
531 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "Popped scope, Op=%p\n", *op)); | ||
532 | } else { | ||
533 | *op = NULL; | ||
534 | } | ||
535 | |||
536 | return_ACPI_STATUS(AE_OK); | ||
537 | } | ||
538 | |||
539 | /******************************************************************************* | ||
540 | * | ||
541 | * FUNCTION: acpi_ps_complete_final_op | ||
542 | * | ||
543 | * PARAMETERS: walk_state - Current state | ||
544 | * op - Current Op | ||
545 | * status - Current parse status before complete last | ||
546 | * Op | ||
547 | * | ||
548 | * RETURN: Status | ||
549 | * | ||
550 | * DESCRIPTION: Complete last Op. | ||
551 | * | ||
552 | ******************************************************************************/ | ||
553 | |||
554 | acpi_status | ||
555 | acpi_ps_complete_final_op(struct acpi_walk_state *walk_state, | ||
556 | union acpi_parse_object *op, acpi_status status) | ||
557 | { | ||
558 | acpi_status status2; | ||
559 | |||
560 | ACPI_FUNCTION_TRACE_PTR(ps_complete_final_op, walk_state); | ||
561 | |||
562 | /* | ||
563 | * Complete the last Op (if not completed), and clear the scope stack. | ||
564 | * It is easily possible to end an AML "package" with an unbounded number | ||
565 | * of open scopes (such as when several ASL blocks are closed with | ||
566 | * sequential closing braces). We want to terminate each one cleanly. | ||
567 | */ | ||
568 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "AML package complete at Op %p\n", | ||
569 | op)); | ||
570 | do { | ||
571 | if (op) { | ||
572 | if (walk_state->ascending_callback != NULL) { | ||
573 | walk_state->op = op; | ||
574 | walk_state->op_info = | ||
575 | acpi_ps_get_opcode_info(op->common. | ||
576 | aml_opcode); | ||
577 | walk_state->opcode = op->common.aml_opcode; | ||
578 | |||
579 | status = | ||
580 | walk_state->ascending_callback(walk_state); | ||
581 | status = | ||
582 | acpi_ps_next_parse_state(walk_state, op, | ||
583 | status); | ||
584 | if (status == AE_CTRL_PENDING) { | ||
585 | status = | ||
586 | acpi_ps_complete_op(walk_state, &op, | ||
587 | AE_OK); | ||
588 | if (ACPI_FAILURE(status)) { | ||
589 | return_ACPI_STATUS(status); | ||
590 | } | ||
591 | } | ||
592 | |||
593 | if (status == AE_CTRL_TERMINATE) { | ||
594 | status = AE_OK; | ||
595 | |||
596 | /* Clean up */ | ||
597 | do { | ||
598 | if (op) { | ||
599 | status2 = | ||
600 | acpi_ps_complete_this_op | ||
601 | (walk_state, op); | ||
602 | if (ACPI_FAILURE | ||
603 | (status2)) { | ||
604 | return_ACPI_STATUS | ||
605 | (status2); | ||
606 | } | ||
607 | } | ||
608 | |||
609 | acpi_ps_pop_scope(& | ||
610 | (walk_state-> | ||
611 | parser_state), | ||
612 | &op, | ||
613 | &walk_state-> | ||
614 | arg_types, | ||
615 | &walk_state-> | ||
616 | arg_count); | ||
617 | |||
618 | } while (op); | ||
619 | |||
620 | return_ACPI_STATUS(status); | ||
621 | } | ||
622 | |||
623 | else if (ACPI_FAILURE(status)) { | ||
624 | |||
625 | /* First error is most important */ | ||
626 | |||
627 | (void) | ||
628 | acpi_ps_complete_this_op(walk_state, | ||
629 | op); | ||
630 | return_ACPI_STATUS(status); | ||
631 | } | ||
632 | } | ||
633 | |||
634 | status2 = acpi_ps_complete_this_op(walk_state, op); | ||
635 | if (ACPI_FAILURE(status2)) { | ||
636 | return_ACPI_STATUS(status2); | ||
637 | } | ||
638 | } | ||
639 | |||
640 | acpi_ps_pop_scope(&(walk_state->parser_state), &op, | ||
641 | &walk_state->arg_types, | ||
642 | &walk_state->arg_count); | ||
643 | |||
644 | } while (op); | ||
645 | |||
646 | return_ACPI_STATUS(status); | ||
647 | } | ||
diff --git a/drivers/acpi/acpica/psopcode.c b/drivers/acpi/acpica/psopcode.c index 1793d934aa30..0fcee880d25c 100644 --- a/drivers/acpi/acpica/psopcode.c +++ b/drivers/acpi/acpica/psopcode.c | |||
@@ -43,16 +43,12 @@ | |||
43 | 43 | ||
44 | #include <acpi/acpi.h> | 44 | #include <acpi/acpi.h> |
45 | #include "accommon.h" | 45 | #include "accommon.h" |
46 | #include "acparser.h" | ||
47 | #include "acopcode.h" | 46 | #include "acopcode.h" |
48 | #include "amlcode.h" | 47 | #include "amlcode.h" |
49 | 48 | ||
50 | #define _COMPONENT ACPI_PARSER | 49 | #define _COMPONENT ACPI_PARSER |
51 | ACPI_MODULE_NAME("psopcode") | 50 | ACPI_MODULE_NAME("psopcode") |
52 | 51 | ||
53 | static const u8 acpi_gbl_argument_count[] = | ||
54 | { 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 6 }; | ||
55 | |||
56 | /******************************************************************************* | 52 | /******************************************************************************* |
57 | * | 53 | * |
58 | * NAME: acpi_gbl_aml_op_info | 54 | * NAME: acpi_gbl_aml_op_info |
@@ -63,7 +59,6 @@ static const u8 acpi_gbl_argument_count[] = | |||
63 | * the operand type. | 59 | * the operand type. |
64 | * | 60 | * |
65 | ******************************************************************************/ | 61 | ******************************************************************************/ |
66 | |||
67 | /* | 62 | /* |
68 | * Summary of opcode types/flags | 63 | * Summary of opcode types/flags |
69 | * | 64 | * |
@@ -181,7 +176,6 @@ static const u8 acpi_gbl_argument_count[] = | |||
181 | AML_CREATE_QWORD_FIELD_OP | 176 | AML_CREATE_QWORD_FIELD_OP |
182 | 177 | ||
183 | ******************************************************************************/ | 178 | ******************************************************************************/ |
184 | |||
185 | /* | 179 | /* |
186 | * Master Opcode information table. A summary of everything we know about each | 180 | * Master Opcode information table. A summary of everything we know about each |
187 | * opcode, all in one place. | 181 | * opcode, all in one place. |
@@ -656,169 +650,3 @@ const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = { | |||
656 | 650 | ||
657 | /*! [End] no source code translation !*/ | 651 | /*! [End] no source code translation !*/ |
658 | }; | 652 | }; |
659 | |||
660 | /* | ||
661 | * This table is directly indexed by the opcodes, and returns an | ||
662 | * index into the table above | ||
663 | */ | ||
664 | static const u8 acpi_gbl_short_op_index[256] = { | ||
665 | /* 0 1 2 3 4 5 6 7 */ | ||
666 | /* 8 9 A B C D E F */ | ||
667 | /* 0x00 */ 0x00, 0x01, _UNK, _UNK, _UNK, _UNK, 0x02, _UNK, | ||
668 | /* 0x08 */ 0x03, _UNK, 0x04, 0x05, 0x06, 0x07, 0x6E, _UNK, | ||
669 | /* 0x10 */ 0x08, 0x09, 0x0a, 0x6F, 0x0b, _UNK, _UNK, _UNK, | ||
670 | /* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
671 | /* 0x20 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
672 | /* 0x28 */ _UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX, | ||
673 | /* 0x30 */ 0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, 0x7D, | ||
674 | /* 0x38 */ 0x7F, 0x80, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
675 | /* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, | ||
676 | /* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, | ||
677 | /* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, | ||
678 | /* 0x58 */ _ASC, _ASC, _ASC, _UNK, _PFX, _UNK, _PFX, _ASC, | ||
679 | /* 0x60 */ 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, | ||
680 | /* 0x68 */ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, _UNK, | ||
681 | /* 0x70 */ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, | ||
682 | /* 0x78 */ 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, | ||
683 | /* 0x80 */ 0x2b, 0x2c, 0x2d, 0x2e, 0x70, 0x71, 0x2f, 0x30, | ||
684 | /* 0x88 */ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x72, | ||
685 | /* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x73, 0x74, | ||
686 | /* 0x98 */ 0x75, 0x76, _UNK, _UNK, 0x77, 0x78, 0x79, 0x7A, | ||
687 | /* 0xA0 */ 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x60, 0x61, | ||
688 | /* 0xA8 */ 0x62, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
689 | /* 0xB0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
690 | /* 0xB8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
691 | /* 0xC0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
692 | /* 0xC8 */ _UNK, _UNK, _UNK, _UNK, 0x44, _UNK, _UNK, _UNK, | ||
693 | /* 0xD0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
694 | /* 0xD8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
695 | /* 0xE0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
696 | /* 0xE8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
697 | /* 0xF0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
698 | /* 0xF8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45, | ||
699 | }; | ||
700 | |||
701 | /* | ||
702 | * This table is indexed by the second opcode of the extended opcode | ||
703 | * pair. It returns an index into the opcode table (acpi_gbl_aml_op_info) | ||
704 | */ | ||
705 | static const u8 acpi_gbl_long_op_index[NUM_EXTENDED_OPCODE] = { | ||
706 | /* 0 1 2 3 4 5 6 7 */ | ||
707 | /* 8 9 A B C D E F */ | ||
708 | /* 0x00 */ _UNK, 0x46, 0x47, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
709 | /* 0x08 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
710 | /* 0x10 */ _UNK, _UNK, 0x48, 0x49, _UNK, _UNK, _UNK, _UNK, | ||
711 | /* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x7B, | ||
712 | /* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, | ||
713 | /* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
714 | /* 0x30 */ 0x55, 0x56, 0x57, 0x7e, _UNK, _UNK, _UNK, _UNK, | ||
715 | /* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
716 | /* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
717 | /* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
718 | /* 0x50 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
719 | /* 0x58 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
720 | /* 0x60 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
721 | /* 0x68 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
722 | /* 0x70 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
723 | /* 0x78 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
724 | /* 0x80 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, | ||
725 | /* 0x88 */ 0x7C, | ||
726 | }; | ||
727 | |||
728 | /******************************************************************************* | ||
729 | * | ||
730 | * FUNCTION: acpi_ps_get_opcode_info | ||
731 | * | ||
732 | * PARAMETERS: opcode - The AML opcode | ||
733 | * | ||
734 | * RETURN: A pointer to the info about the opcode. | ||
735 | * | ||
736 | * DESCRIPTION: Find AML opcode description based on the opcode. | ||
737 | * NOTE: This procedure must ALWAYS return a valid pointer! | ||
738 | * | ||
739 | ******************************************************************************/ | ||
740 | |||
741 | const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode) | ||
742 | { | ||
743 | ACPI_FUNCTION_NAME(ps_get_opcode_info); | ||
744 | |||
745 | /* | ||
746 | * Detect normal 8-bit opcode or extended 16-bit opcode | ||
747 | */ | ||
748 | if (!(opcode & 0xFF00)) { | ||
749 | |||
750 | /* Simple (8-bit) opcode: 0-255, can't index beyond table */ | ||
751 | |||
752 | return (&acpi_gbl_aml_op_info | ||
753 | [acpi_gbl_short_op_index[(u8) opcode]]); | ||
754 | } | ||
755 | |||
756 | if (((opcode & 0xFF00) == AML_EXTENDED_OPCODE) && | ||
757 | (((u8) opcode) <= MAX_EXTENDED_OPCODE)) { | ||
758 | |||
759 | /* Valid extended (16-bit) opcode */ | ||
760 | |||
761 | return (&acpi_gbl_aml_op_info | ||
762 | [acpi_gbl_long_op_index[(u8) opcode]]); | ||
763 | } | ||
764 | |||
765 | /* Unknown AML opcode */ | ||
766 | |||
767 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | ||
768 | "Unknown AML opcode [%4.4X]\n", opcode)); | ||
769 | |||
770 | return (&acpi_gbl_aml_op_info[_UNK]); | ||
771 | } | ||
772 | |||
773 | /******************************************************************************* | ||
774 | * | ||
775 | * FUNCTION: acpi_ps_get_opcode_name | ||
776 | * | ||
777 | * PARAMETERS: opcode - The AML opcode | ||
778 | * | ||
779 | * RETURN: A pointer to the name of the opcode (ASCII String) | ||
780 | * Note: Never returns NULL. | ||
781 | * | ||
782 | * DESCRIPTION: Translate an opcode into a human-readable string | ||
783 | * | ||
784 | ******************************************************************************/ | ||
785 | |||
786 | char *acpi_ps_get_opcode_name(u16 opcode) | ||
787 | { | ||
788 | #if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT) | ||
789 | |||
790 | const struct acpi_opcode_info *op; | ||
791 | |||
792 | op = acpi_ps_get_opcode_info(opcode); | ||
793 | |||
794 | /* Always guaranteed to return a valid pointer */ | ||
795 | |||
796 | return (op->name); | ||
797 | |||
798 | #else | ||
799 | return ("OpcodeName unavailable"); | ||
800 | |||
801 | #endif | ||
802 | } | ||
803 | |||
804 | /******************************************************************************* | ||
805 | * | ||
806 | * FUNCTION: acpi_ps_get_argument_count | ||
807 | * | ||
808 | * PARAMETERS: op_type - Type associated with the AML opcode | ||
809 | * | ||
810 | * RETURN: Argument count | ||
811 | * | ||
812 | * DESCRIPTION: Obtain the number of expected arguments for an AML opcode | ||
813 | * | ||
814 | ******************************************************************************/ | ||
815 | |||
816 | u8 acpi_ps_get_argument_count(u32 op_type) | ||
817 | { | ||
818 | |||
819 | if (op_type <= AML_TYPE_EXEC_6A_0T_1R) { | ||
820 | return (acpi_gbl_argument_count[op_type]); | ||
821 | } | ||
822 | |||
823 | return (0); | ||
824 | } | ||
diff --git a/drivers/acpi/acpica/psopinfo.c b/drivers/acpi/acpica/psopinfo.c new file mode 100644 index 000000000000..d870e6293f7f --- /dev/null +++ b/drivers/acpi/acpica/psopinfo.c | |||
@@ -0,0 +1,223 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: psopinfo - AML opcode information functions and dispatch tables | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2012, 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 "acparser.h" | ||
47 | #include "acopcode.h" | ||
48 | #include "amlcode.h" | ||
49 | |||
50 | #define _COMPONENT ACPI_PARSER | ||
51 | ACPI_MODULE_NAME("psopinfo") | ||
52 | |||
53 | extern const u8 acpi_gbl_short_op_index[]; | ||
54 | extern const u8 acpi_gbl_long_op_index[]; | ||
55 | |||
56 | static const u8 acpi_gbl_argument_count[] = | ||
57 | { 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 6 }; | ||
58 | |||
59 | /******************************************************************************* | ||
60 | * | ||
61 | * FUNCTION: acpi_ps_get_opcode_info | ||
62 | * | ||
63 | * PARAMETERS: opcode - The AML opcode | ||
64 | * | ||
65 | * RETURN: A pointer to the info about the opcode. | ||
66 | * | ||
67 | * DESCRIPTION: Find AML opcode description based on the opcode. | ||
68 | * NOTE: This procedure must ALWAYS return a valid pointer! | ||
69 | * | ||
70 | ******************************************************************************/ | ||
71 | |||
72 | const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode) | ||
73 | { | ||
74 | ACPI_FUNCTION_NAME(ps_get_opcode_info); | ||
75 | |||
76 | /* | ||
77 | * Detect normal 8-bit opcode or extended 16-bit opcode | ||
78 | */ | ||
79 | if (!(opcode & 0xFF00)) { | ||
80 | |||
81 | /* Simple (8-bit) opcode: 0-255, can't index beyond table */ | ||
82 | |||
83 | return (&acpi_gbl_aml_op_info | ||
84 | [acpi_gbl_short_op_index[(u8)opcode]]); | ||
85 | } | ||
86 | |||
87 | if (((opcode & 0xFF00) == AML_EXTENDED_OPCODE) && | ||
88 | (((u8)opcode) <= MAX_EXTENDED_OPCODE)) { | ||
89 | |||
90 | /* Valid extended (16-bit) opcode */ | ||
91 | |||
92 | return (&acpi_gbl_aml_op_info | ||
93 | [acpi_gbl_long_op_index[(u8)opcode]]); | ||
94 | } | ||
95 | |||
96 | /* Unknown AML opcode */ | ||
97 | |||
98 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | ||
99 | "Unknown AML opcode [%4.4X]\n", opcode)); | ||
100 | |||
101 | return (&acpi_gbl_aml_op_info[_UNK]); | ||
102 | } | ||
103 | |||
104 | /******************************************************************************* | ||
105 | * | ||
106 | * FUNCTION: acpi_ps_get_opcode_name | ||
107 | * | ||
108 | * PARAMETERS: opcode - The AML opcode | ||
109 | * | ||
110 | * RETURN: A pointer to the name of the opcode (ASCII String) | ||
111 | * Note: Never returns NULL. | ||
112 | * | ||
113 | * DESCRIPTION: Translate an opcode into a human-readable string | ||
114 | * | ||
115 | ******************************************************************************/ | ||
116 | |||
117 | char *acpi_ps_get_opcode_name(u16 opcode) | ||
118 | { | ||
119 | #if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT) | ||
120 | |||
121 | const struct acpi_opcode_info *op; | ||
122 | |||
123 | op = acpi_ps_get_opcode_info(opcode); | ||
124 | |||
125 | /* Always guaranteed to return a valid pointer */ | ||
126 | |||
127 | return (op->name); | ||
128 | |||
129 | #else | ||
130 | return ("OpcodeName unavailable"); | ||
131 | |||
132 | #endif | ||
133 | } | ||
134 | |||
135 | /******************************************************************************* | ||
136 | * | ||
137 | * FUNCTION: acpi_ps_get_argument_count | ||
138 | * | ||
139 | * PARAMETERS: op_type - Type associated with the AML opcode | ||
140 | * | ||
141 | * RETURN: Argument count | ||
142 | * | ||
143 | * DESCRIPTION: Obtain the number of expected arguments for an AML opcode | ||
144 | * | ||
145 | ******************************************************************************/ | ||
146 | |||
147 | u8 acpi_ps_get_argument_count(u32 op_type) | ||
148 | { | ||
149 | |||
150 | if (op_type <= AML_TYPE_EXEC_6A_0T_1R) { | ||
151 | return (acpi_gbl_argument_count[op_type]); | ||
152 | } | ||
153 | |||
154 | return (0); | ||
155 | } | ||
156 | |||
157 | /* | ||
158 | * This table is directly indexed by the opcodes It returns | ||
159 | * an index into the opcode table (acpi_gbl_aml_op_info) | ||
160 | */ | ||
161 | const u8 acpi_gbl_short_op_index[256] = { | ||
162 | /* 0 1 2 3 4 5 6 7 */ | ||
163 | /* 8 9 A B C D E F */ | ||
164 | /* 0x00 */ 0x00, 0x01, _UNK, _UNK, _UNK, _UNK, 0x02, _UNK, | ||
165 | /* 0x08 */ 0x03, _UNK, 0x04, 0x05, 0x06, 0x07, 0x6E, _UNK, | ||
166 | /* 0x10 */ 0x08, 0x09, 0x0a, 0x6F, 0x0b, _UNK, _UNK, _UNK, | ||
167 | /* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
168 | /* 0x20 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
169 | /* 0x28 */ _UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX, | ||
170 | /* 0x30 */ 0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, 0x7D, | ||
171 | /* 0x38 */ 0x7F, 0x80, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
172 | /* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, | ||
173 | /* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, | ||
174 | /* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, | ||
175 | /* 0x58 */ _ASC, _ASC, _ASC, _UNK, _PFX, _UNK, _PFX, _ASC, | ||
176 | /* 0x60 */ 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, | ||
177 | /* 0x68 */ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, _UNK, | ||
178 | /* 0x70 */ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, | ||
179 | /* 0x78 */ 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, | ||
180 | /* 0x80 */ 0x2b, 0x2c, 0x2d, 0x2e, 0x70, 0x71, 0x2f, 0x30, | ||
181 | /* 0x88 */ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x72, | ||
182 | /* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x73, 0x74, | ||
183 | /* 0x98 */ 0x75, 0x76, _UNK, _UNK, 0x77, 0x78, 0x79, 0x7A, | ||
184 | /* 0xA0 */ 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x60, 0x61, | ||
185 | /* 0xA8 */ 0x62, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
186 | /* 0xB0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
187 | /* 0xB8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
188 | /* 0xC0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
189 | /* 0xC8 */ _UNK, _UNK, _UNK, _UNK, 0x44, _UNK, _UNK, _UNK, | ||
190 | /* 0xD0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
191 | /* 0xD8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
192 | /* 0xE0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
193 | /* 0xE8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
194 | /* 0xF0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
195 | /* 0xF8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45, | ||
196 | }; | ||
197 | |||
198 | /* | ||
199 | * This table is indexed by the second opcode of the extended opcode | ||
200 | * pair. It returns an index into the opcode table (acpi_gbl_aml_op_info) | ||
201 | */ | ||
202 | const u8 acpi_gbl_long_op_index[NUM_EXTENDED_OPCODE] = { | ||
203 | /* 0 1 2 3 4 5 6 7 */ | ||
204 | /* 8 9 A B C D E F */ | ||
205 | /* 0x00 */ _UNK, 0x46, 0x47, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
206 | /* 0x08 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
207 | /* 0x10 */ _UNK, _UNK, 0x48, 0x49, _UNK, _UNK, _UNK, _UNK, | ||
208 | /* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x7B, | ||
209 | /* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, | ||
210 | /* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
211 | /* 0x30 */ 0x55, 0x56, 0x57, 0x7e, _UNK, _UNK, _UNK, _UNK, | ||
212 | /* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
213 | /* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
214 | /* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
215 | /* 0x50 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
216 | /* 0x58 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
217 | /* 0x60 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
218 | /* 0x68 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
219 | /* 0x70 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
220 | /* 0x78 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, | ||
221 | /* 0x80 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, | ||
222 | /* 0x88 */ 0x7C, | ||
223 | }; | ||
diff --git a/drivers/acpi/acpica/rsdump.c b/drivers/acpi/acpica/rsdump.c index 203b4aea53cd..6e8f9bd08fc1 100644 --- a/drivers/acpi/acpica/rsdump.c +++ b/drivers/acpi/acpica/rsdump.c | |||
@@ -77,419 +77,16 @@ static void acpi_rs_dump_address_common(union acpi_resource_data *resource); | |||
77 | static void | 77 | static void |
78 | acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table); | 78 | acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table); |
79 | 79 | ||
80 | #define ACPI_RSD_OFFSET(f) (u8) ACPI_OFFSET (union acpi_resource_data,f) | ||
81 | #define ACPI_PRT_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_pci_routing_table,f) | ||
82 | #define ACPI_RSD_TABLE_SIZE(name) (sizeof(name) / sizeof (struct acpi_rsdump_info)) | ||
83 | |||
84 | /******************************************************************************* | ||
85 | * | ||
86 | * Resource Descriptor info tables | ||
87 | * | ||
88 | * Note: The first table entry must be a Title or Literal and must contain | ||
89 | * the table length (number of table entries) | ||
90 | * | ||
91 | ******************************************************************************/ | ||
92 | |||
93 | struct acpi_rsdump_info acpi_rs_dump_irq[7] = { | ||
94 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_irq), "IRQ", NULL}, | ||
95 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(irq.descriptor_length), | ||
96 | "Descriptor Length", NULL}, | ||
97 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.triggering), "Triggering", | ||
98 | acpi_gbl_he_decode}, | ||
99 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.polarity), "Polarity", | ||
100 | acpi_gbl_ll_decode}, | ||
101 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(irq.sharable), "Sharing", | ||
102 | acpi_gbl_shr_decode}, | ||
103 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(irq.interrupt_count), | ||
104 | "Interrupt Count", NULL}, | ||
105 | {ACPI_RSD_SHORTLIST, ACPI_RSD_OFFSET(irq.interrupts[0]), | ||
106 | "Interrupt List", NULL} | ||
107 | }; | ||
108 | |||
109 | struct acpi_rsdump_info acpi_rs_dump_dma[6] = { | ||
110 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_dma), "DMA", NULL}, | ||
111 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.type), "Speed", | ||
112 | acpi_gbl_typ_decode}, | ||
113 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(dma.bus_master), "Mastering", | ||
114 | acpi_gbl_bm_decode}, | ||
115 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.transfer), "Transfer Type", | ||
116 | acpi_gbl_siz_decode}, | ||
117 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(dma.channel_count), "Channel Count", | ||
118 | NULL}, | ||
119 | {ACPI_RSD_SHORTLIST, ACPI_RSD_OFFSET(dma.channels[0]), "Channel List", | ||
120 | NULL} | ||
121 | }; | ||
122 | |||
123 | struct acpi_rsdump_info acpi_rs_dump_start_dpf[4] = { | ||
124 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_start_dpf), | ||
125 | "Start-Dependent-Functions", NULL}, | ||
126 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(start_dpf.descriptor_length), | ||
127 | "Descriptor Length", NULL}, | ||
128 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(start_dpf.compatibility_priority), | ||
129 | "Compatibility Priority", acpi_gbl_config_decode}, | ||
130 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(start_dpf.performance_robustness), | ||
131 | "Performance/Robustness", acpi_gbl_config_decode} | ||
132 | }; | ||
133 | |||
134 | struct acpi_rsdump_info acpi_rs_dump_end_dpf[1] = { | ||
135 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_end_dpf), | ||
136 | "End-Dependent-Functions", NULL} | ||
137 | }; | ||
138 | |||
139 | struct acpi_rsdump_info acpi_rs_dump_io[6] = { | ||
140 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io), "I/O", NULL}, | ||
141 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(io.io_decode), "Address Decoding", | ||
142 | acpi_gbl_io_decode}, | ||
143 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(io.minimum), "Address Minimum", NULL}, | ||
144 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(io.maximum), "Address Maximum", NULL}, | ||
145 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(io.alignment), "Alignment", NULL}, | ||
146 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(io.address_length), "Address Length", | ||
147 | NULL} | ||
148 | }; | ||
149 | |||
150 | struct acpi_rsdump_info acpi_rs_dump_fixed_io[3] = { | ||
151 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_io), | ||
152 | "Fixed I/O", NULL}, | ||
153 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_io.address), "Address", NULL}, | ||
154 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(fixed_io.address_length), | ||
155 | "Address Length", NULL} | ||
156 | }; | ||
157 | |||
158 | struct acpi_rsdump_info acpi_rs_dump_vendor[3] = { | ||
159 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_vendor), | ||
160 | "Vendor Specific", NULL}, | ||
161 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(vendor.byte_length), "Length", NULL}, | ||
162 | {ACPI_RSD_LONGLIST, ACPI_RSD_OFFSET(vendor.byte_data[0]), "Vendor Data", | ||
163 | NULL} | ||
164 | }; | ||
165 | |||
166 | struct acpi_rsdump_info acpi_rs_dump_end_tag[1] = { | ||
167 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_end_tag), "EndTag", | ||
168 | NULL} | ||
169 | }; | ||
170 | |||
171 | struct acpi_rsdump_info acpi_rs_dump_memory24[6] = { | ||
172 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory24), | ||
173 | "24-Bit Memory Range", NULL}, | ||
174 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(memory24.write_protect), | ||
175 | "Write Protect", acpi_gbl_rw_decode}, | ||
176 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.minimum), "Address Minimum", | ||
177 | NULL}, | ||
178 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.maximum), "Address Maximum", | ||
179 | NULL}, | ||
180 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.alignment), "Alignment", | ||
181 | NULL}, | ||
182 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.address_length), | ||
183 | "Address Length", NULL} | ||
184 | }; | ||
185 | |||
186 | struct acpi_rsdump_info acpi_rs_dump_memory32[6] = { | ||
187 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory32), | ||
188 | "32-Bit Memory Range", NULL}, | ||
189 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(memory32.write_protect), | ||
190 | "Write Protect", acpi_gbl_rw_decode}, | ||
191 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.minimum), "Address Minimum", | ||
192 | NULL}, | ||
193 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.maximum), "Address Maximum", | ||
194 | NULL}, | ||
195 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.alignment), "Alignment", | ||
196 | NULL}, | ||
197 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.address_length), | ||
198 | "Address Length", NULL} | ||
199 | }; | ||
200 | |||
201 | struct acpi_rsdump_info acpi_rs_dump_fixed_memory32[4] = { | ||
202 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_memory32), | ||
203 | "32-Bit Fixed Memory Range", NULL}, | ||
204 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(fixed_memory32.write_protect), | ||
205 | "Write Protect", acpi_gbl_rw_decode}, | ||
206 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(fixed_memory32.address), "Address", | ||
207 | NULL}, | ||
208 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(fixed_memory32.address_length), | ||
209 | "Address Length", NULL} | ||
210 | }; | ||
211 | |||
212 | struct acpi_rsdump_info acpi_rs_dump_address16[8] = { | ||
213 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address16), | ||
214 | "16-Bit WORD Address Space", NULL}, | ||
215 | {ACPI_RSD_ADDRESS, 0, NULL, NULL}, | ||
216 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.granularity), "Granularity", | ||
217 | NULL}, | ||
218 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.minimum), "Address Minimum", | ||
219 | NULL}, | ||
220 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.maximum), "Address Maximum", | ||
221 | NULL}, | ||
222 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.translation_offset), | ||
223 | "Translation Offset", NULL}, | ||
224 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address_length), | ||
225 | "Address Length", NULL}, | ||
226 | {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address16.resource_source), NULL, NULL} | ||
227 | }; | ||
228 | |||
229 | struct acpi_rsdump_info acpi_rs_dump_address32[8] = { | ||
230 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address32), | ||
231 | "32-Bit DWORD Address Space", NULL}, | ||
232 | {ACPI_RSD_ADDRESS, 0, NULL, NULL}, | ||
233 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.granularity), "Granularity", | ||
234 | NULL}, | ||
235 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.minimum), "Address Minimum", | ||
236 | NULL}, | ||
237 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.maximum), "Address Maximum", | ||
238 | NULL}, | ||
239 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.translation_offset), | ||
240 | "Translation Offset", NULL}, | ||
241 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address_length), | ||
242 | "Address Length", NULL}, | ||
243 | {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address32.resource_source), NULL, NULL} | ||
244 | }; | ||
245 | |||
246 | struct acpi_rsdump_info acpi_rs_dump_address64[8] = { | ||
247 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address64), | ||
248 | "64-Bit QWORD Address Space", NULL}, | ||
249 | {ACPI_RSD_ADDRESS, 0, NULL, NULL}, | ||
250 | {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.granularity), "Granularity", | ||
251 | NULL}, | ||
252 | {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.minimum), "Address Minimum", | ||
253 | NULL}, | ||
254 | {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.maximum), "Address Maximum", | ||
255 | NULL}, | ||
256 | {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.translation_offset), | ||
257 | "Translation Offset", NULL}, | ||
258 | {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address_length), | ||
259 | "Address Length", NULL}, | ||
260 | {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address64.resource_source), NULL, NULL} | ||
261 | }; | ||
262 | |||
263 | struct acpi_rsdump_info acpi_rs_dump_ext_address64[8] = { | ||
264 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_ext_address64), | ||
265 | "64-Bit Extended Address Space", NULL}, | ||
266 | {ACPI_RSD_ADDRESS, 0, NULL, NULL}, | ||
267 | {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.granularity), | ||
268 | "Granularity", NULL}, | ||
269 | {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.minimum), | ||
270 | "Address Minimum", NULL}, | ||
271 | {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.maximum), | ||
272 | "Address Maximum", NULL}, | ||
273 | {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.translation_offset), | ||
274 | "Translation Offset", NULL}, | ||
275 | {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address_length), | ||
276 | "Address Length", NULL}, | ||
277 | {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.type_specific), | ||
278 | "Type-Specific Attribute", NULL} | ||
279 | }; | ||
280 | |||
281 | struct acpi_rsdump_info acpi_rs_dump_ext_irq[8] = { | ||
282 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_ext_irq), | ||
283 | "Extended IRQ", NULL}, | ||
284 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.producer_consumer), | ||
285 | "Type", acpi_gbl_consume_decode}, | ||
286 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.triggering), | ||
287 | "Triggering", acpi_gbl_he_decode}, | ||
288 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.polarity), "Polarity", | ||
289 | acpi_gbl_ll_decode}, | ||
290 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(extended_irq.sharable), "Sharing", | ||
291 | acpi_gbl_shr_decode}, | ||
292 | {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(extended_irq.resource_source), NULL, | ||
293 | NULL}, | ||
294 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(extended_irq.interrupt_count), | ||
295 | "Interrupt Count", NULL}, | ||
296 | {ACPI_RSD_DWORDLIST, ACPI_RSD_OFFSET(extended_irq.interrupts[0]), | ||
297 | "Interrupt List", NULL} | ||
298 | }; | ||
299 | |||
300 | struct acpi_rsdump_info acpi_rs_dump_generic_reg[6] = { | ||
301 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_generic_reg), | ||
302 | "Generic Register", NULL}, | ||
303 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.space_id), "Space ID", | ||
304 | NULL}, | ||
305 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.bit_width), "Bit Width", | ||
306 | NULL}, | ||
307 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.bit_offset), "Bit Offset", | ||
308 | NULL}, | ||
309 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.access_size), | ||
310 | "Access Size", NULL}, | ||
311 | {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(generic_reg.address), "Address", NULL} | ||
312 | }; | ||
313 | |||
314 | struct acpi_rsdump_info acpi_rs_dump_gpio[16] = { | ||
315 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_gpio), "GPIO", NULL}, | ||
316 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.revision_id), "RevisionId", NULL}, | ||
317 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.connection_type), | ||
318 | "ConnectionType", acpi_gbl_ct_decode}, | ||
319 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(gpio.producer_consumer), | ||
320 | "ProducerConsumer", acpi_gbl_consume_decode}, | ||
321 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.pin_config), "PinConfig", | ||
322 | acpi_gbl_ppc_decode}, | ||
323 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.sharable), "Sharing", | ||
324 | acpi_gbl_shr_decode}, | ||
325 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.io_restriction), | ||
326 | "IoRestriction", acpi_gbl_ior_decode}, | ||
327 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(gpio.triggering), "Triggering", | ||
328 | acpi_gbl_he_decode}, | ||
329 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.polarity), "Polarity", | ||
330 | acpi_gbl_ll_decode}, | ||
331 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.drive_strength), "DriveStrength", | ||
332 | NULL}, | ||
333 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.debounce_timeout), | ||
334 | "DebounceTimeout", NULL}, | ||
335 | {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(gpio.resource_source), | ||
336 | "ResourceSource", NULL}, | ||
337 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.pin_table_length), | ||
338 | "PinTableLength", NULL}, | ||
339 | {ACPI_RSD_WORDLIST, ACPI_RSD_OFFSET(gpio.pin_table), "PinTable", NULL}, | ||
340 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.vendor_length), "VendorLength", | ||
341 | NULL}, | ||
342 | {ACPI_RSD_SHORTLISTX, ACPI_RSD_OFFSET(gpio.vendor_data), "VendorData", | ||
343 | NULL}, | ||
344 | }; | ||
345 | |||
346 | struct acpi_rsdump_info acpi_rs_dump_fixed_dma[4] = { | ||
347 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_dma), | ||
348 | "FixedDma", NULL}, | ||
349 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_dma.request_lines), | ||
350 | "RequestLines", NULL}, | ||
351 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_dma.channels), "Channels", | ||
352 | NULL}, | ||
353 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(fixed_dma.width), "TransferWidth", | ||
354 | acpi_gbl_dts_decode}, | ||
355 | }; | ||
356 | |||
357 | #define ACPI_RS_DUMP_COMMON_SERIAL_BUS \ | ||
358 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.revision_id), "RevisionId", NULL}, \ | ||
359 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.type), "Type", acpi_gbl_sbt_decode}, \ | ||
360 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (common_serial_bus.producer_consumer), "ProducerConsumer", acpi_gbl_consume_decode}, \ | ||
361 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (common_serial_bus.slave_mode), "SlaveMode", acpi_gbl_sm_decode}, \ | ||
362 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.type_revision_id), "TypeRevisionId", NULL}, \ | ||
363 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (common_serial_bus.type_data_length), "TypeDataLength", NULL}, \ | ||
364 | {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (common_serial_bus.resource_source), "ResourceSource", NULL}, \ | ||
365 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (common_serial_bus.vendor_length), "VendorLength", NULL}, \ | ||
366 | {ACPI_RSD_SHORTLISTX,ACPI_RSD_OFFSET (common_serial_bus.vendor_data), "VendorData", NULL}, | ||
367 | |||
368 | struct acpi_rsdump_info acpi_rs_dump_common_serial_bus[10] = { | ||
369 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_common_serial_bus), | ||
370 | "Common Serial Bus", NULL}, | ||
371 | ACPI_RS_DUMP_COMMON_SERIAL_BUS | ||
372 | }; | ||
373 | |||
374 | struct acpi_rsdump_info acpi_rs_dump_i2c_serial_bus[13] = { | ||
375 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_i2c_serial_bus), | ||
376 | "I2C Serial Bus", NULL}, | ||
377 | ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_1BITFLAG, | ||
378 | ACPI_RSD_OFFSET(i2c_serial_bus. | ||
379 | access_mode), | ||
380 | "AccessMode", acpi_gbl_am_decode}, | ||
381 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(i2c_serial_bus.connection_speed), | ||
382 | "ConnectionSpeed", NULL}, | ||
383 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(i2c_serial_bus.slave_address), | ||
384 | "SlaveAddress", NULL}, | ||
385 | }; | ||
386 | |||
387 | struct acpi_rsdump_info acpi_rs_dump_spi_serial_bus[17] = { | ||
388 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_spi_serial_bus), | ||
389 | "Spi Serial Bus", NULL}, | ||
390 | ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_1BITFLAG, | ||
391 | ACPI_RSD_OFFSET(spi_serial_bus. | ||
392 | wire_mode), "WireMode", | ||
393 | acpi_gbl_wm_decode}, | ||
394 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(spi_serial_bus.device_polarity), | ||
395 | "DevicePolarity", acpi_gbl_dp_decode}, | ||
396 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.data_bit_length), | ||
397 | "DataBitLength", NULL}, | ||
398 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.clock_phase), | ||
399 | "ClockPhase", acpi_gbl_cph_decode}, | ||
400 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.clock_polarity), | ||
401 | "ClockPolarity", acpi_gbl_cpo_decode}, | ||
402 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(spi_serial_bus.device_selection), | ||
403 | "DeviceSelection", NULL}, | ||
404 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(spi_serial_bus.connection_speed), | ||
405 | "ConnectionSpeed", NULL}, | ||
406 | }; | ||
407 | |||
408 | struct acpi_rsdump_info acpi_rs_dump_uart_serial_bus[19] = { | ||
409 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_uart_serial_bus), | ||
410 | "Uart Serial Bus", NULL}, | ||
411 | ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_2BITFLAG, | ||
412 | ACPI_RSD_OFFSET(uart_serial_bus. | ||
413 | flow_control), | ||
414 | "FlowControl", acpi_gbl_fc_decode}, | ||
415 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.stop_bits), | ||
416 | "StopBits", acpi_gbl_sb_decode}, | ||
417 | {ACPI_RSD_3BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.data_bits), | ||
418 | "DataBits", acpi_gbl_bpb_decode}, | ||
419 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.endian), "Endian", | ||
420 | acpi_gbl_ed_decode}, | ||
421 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(uart_serial_bus.parity), "Parity", | ||
422 | acpi_gbl_pt_decode}, | ||
423 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(uart_serial_bus.lines_enabled), | ||
424 | "LinesEnabled", NULL}, | ||
425 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(uart_serial_bus.rx_fifo_size), | ||
426 | "RxFifoSize", NULL}, | ||
427 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(uart_serial_bus.tx_fifo_size), | ||
428 | "TxFifoSize", NULL}, | ||
429 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(uart_serial_bus.default_baud_rate), | ||
430 | "ConnectionSpeed", NULL}, | ||
431 | }; | ||
432 | |||
433 | /* | ||
434 | * Tables used for common address descriptor flag fields | ||
435 | */ | ||
436 | static struct acpi_rsdump_info acpi_rs_dump_general_flags[5] = { | ||
437 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_general_flags), NULL, | ||
438 | NULL}, | ||
439 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.producer_consumer), | ||
440 | "Consumer/Producer", acpi_gbl_consume_decode}, | ||
441 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.decode), "Address Decode", | ||
442 | acpi_gbl_dec_decode}, | ||
443 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.min_address_fixed), | ||
444 | "Min Relocatability", acpi_gbl_min_decode}, | ||
445 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.max_address_fixed), | ||
446 | "Max Relocatability", acpi_gbl_max_decode} | ||
447 | }; | ||
448 | |||
449 | static struct acpi_rsdump_info acpi_rs_dump_memory_flags[5] = { | ||
450 | {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory_flags), | ||
451 | "Resource Type", (void *)"Memory Range"}, | ||
452 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.write_protect), | ||
453 | "Write Protect", acpi_gbl_rw_decode}, | ||
454 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.caching), | ||
455 | "Caching", acpi_gbl_mem_decode}, | ||
456 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.range_type), | ||
457 | "Range Type", acpi_gbl_mtp_decode}, | ||
458 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.translation), | ||
459 | "Translation", acpi_gbl_ttp_decode} | ||
460 | }; | ||
461 | |||
462 | static struct acpi_rsdump_info acpi_rs_dump_io_flags[4] = { | ||
463 | {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io_flags), | ||
464 | "Resource Type", (void *)"I/O Range"}, | ||
465 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.io.range_type), | ||
466 | "Range Type", acpi_gbl_rng_decode}, | ||
467 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation), | ||
468 | "Translation", acpi_gbl_ttp_decode}, | ||
469 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation_type), | ||
470 | "Translation Type", acpi_gbl_trs_decode} | ||
471 | }; | ||
472 | |||
473 | /* | ||
474 | * Table used to dump _PRT contents | ||
475 | */ | ||
476 | static struct acpi_rsdump_info acpi_rs_dump_prt[5] = { | ||
477 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_prt), NULL, NULL}, | ||
478 | {ACPI_RSD_UINT64, ACPI_PRT_OFFSET(address), "Address", NULL}, | ||
479 | {ACPI_RSD_UINT32, ACPI_PRT_OFFSET(pin), "Pin", NULL}, | ||
480 | {ACPI_RSD_STRING, ACPI_PRT_OFFSET(source[0]), "Source", NULL}, | ||
481 | {ACPI_RSD_UINT32, ACPI_PRT_OFFSET(source_index), "Source Index", NULL} | ||
482 | }; | ||
483 | |||
484 | /******************************************************************************* | 80 | /******************************************************************************* |
485 | * | 81 | * |
486 | * FUNCTION: acpi_rs_dump_descriptor | 82 | * FUNCTION: acpi_rs_dump_descriptor |
487 | * | 83 | * |
488 | * PARAMETERS: Resource | 84 | * PARAMETERS: resource - Buffer containing the resource |
85 | * table - Table entry to decode the resource | ||
489 | * | 86 | * |
490 | * RETURN: None | 87 | * RETURN: None |
491 | * | 88 | * |
492 | * DESCRIPTION: | 89 | * DESCRIPTION: Dump a resource descriptor based on a dump table entry. |
493 | * | 90 | * |
494 | ******************************************************************************/ | 91 | ******************************************************************************/ |
495 | 92 | ||
diff --git a/drivers/acpi/acpica/rsdumpinfo.c b/drivers/acpi/acpica/rsdumpinfo.c new file mode 100644 index 000000000000..63a68c96a8ac --- /dev/null +++ b/drivers/acpi/acpica/rsdumpinfo.c | |||
@@ -0,0 +1,454 @@ | |||
1 | /******************************************************************************* | ||
2 | * | ||
3 | * Module Name: rsdumpinfo - Tables used to display resource descriptors. | ||
4 | * | ||
5 | ******************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2012, 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 "acresrc.h" | ||
47 | |||
48 | #define _COMPONENT ACPI_RESOURCES | ||
49 | ACPI_MODULE_NAME("rsdumpinfo") | ||
50 | |||
51 | #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) | ||
52 | #define ACPI_RSD_OFFSET(f) (u8) ACPI_OFFSET (union acpi_resource_data,f) | ||
53 | #define ACPI_PRT_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_pci_routing_table,f) | ||
54 | #define ACPI_RSD_TABLE_SIZE(name) (sizeof(name) / sizeof (struct acpi_rsdump_info)) | ||
55 | /******************************************************************************* | ||
56 | * | ||
57 | * Resource Descriptor info tables | ||
58 | * | ||
59 | * Note: The first table entry must be a Title or Literal and must contain | ||
60 | * the table length (number of table entries) | ||
61 | * | ||
62 | ******************************************************************************/ | ||
63 | struct acpi_rsdump_info acpi_rs_dump_irq[7] = { | ||
64 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_irq), "IRQ", NULL}, | ||
65 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(irq.descriptor_length), | ||
66 | "Descriptor Length", NULL}, | ||
67 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.triggering), "Triggering", | ||
68 | acpi_gbl_he_decode}, | ||
69 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.polarity), "Polarity", | ||
70 | acpi_gbl_ll_decode}, | ||
71 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(irq.sharable), "Sharing", | ||
72 | acpi_gbl_shr_decode}, | ||
73 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(irq.interrupt_count), | ||
74 | "Interrupt Count", NULL}, | ||
75 | {ACPI_RSD_SHORTLIST, ACPI_RSD_OFFSET(irq.interrupts[0]), | ||
76 | "Interrupt List", NULL} | ||
77 | }; | ||
78 | |||
79 | struct acpi_rsdump_info acpi_rs_dump_dma[6] = { | ||
80 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_dma), "DMA", NULL}, | ||
81 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.type), "Speed", | ||
82 | acpi_gbl_typ_decode}, | ||
83 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(dma.bus_master), "Mastering", | ||
84 | acpi_gbl_bm_decode}, | ||
85 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.transfer), "Transfer Type", | ||
86 | acpi_gbl_siz_decode}, | ||
87 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(dma.channel_count), "Channel Count", | ||
88 | NULL}, | ||
89 | {ACPI_RSD_SHORTLIST, ACPI_RSD_OFFSET(dma.channels[0]), "Channel List", | ||
90 | NULL} | ||
91 | }; | ||
92 | |||
93 | struct acpi_rsdump_info acpi_rs_dump_start_dpf[4] = { | ||
94 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_start_dpf), | ||
95 | "Start-Dependent-Functions", NULL}, | ||
96 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(start_dpf.descriptor_length), | ||
97 | "Descriptor Length", NULL}, | ||
98 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(start_dpf.compatibility_priority), | ||
99 | "Compatibility Priority", acpi_gbl_config_decode}, | ||
100 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(start_dpf.performance_robustness), | ||
101 | "Performance/Robustness", acpi_gbl_config_decode} | ||
102 | }; | ||
103 | |||
104 | struct acpi_rsdump_info acpi_rs_dump_end_dpf[1] = { | ||
105 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_end_dpf), | ||
106 | "End-Dependent-Functions", NULL} | ||
107 | }; | ||
108 | |||
109 | struct acpi_rsdump_info acpi_rs_dump_io[6] = { | ||
110 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io), "I/O", NULL}, | ||
111 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(io.io_decode), "Address Decoding", | ||
112 | acpi_gbl_io_decode}, | ||
113 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(io.minimum), "Address Minimum", NULL}, | ||
114 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(io.maximum), "Address Maximum", NULL}, | ||
115 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(io.alignment), "Alignment", NULL}, | ||
116 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(io.address_length), "Address Length", | ||
117 | NULL} | ||
118 | }; | ||
119 | |||
120 | struct acpi_rsdump_info acpi_rs_dump_fixed_io[3] = { | ||
121 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_io), | ||
122 | "Fixed I/O", NULL}, | ||
123 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_io.address), "Address", NULL}, | ||
124 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(fixed_io.address_length), | ||
125 | "Address Length", NULL} | ||
126 | }; | ||
127 | |||
128 | struct acpi_rsdump_info acpi_rs_dump_vendor[3] = { | ||
129 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_vendor), | ||
130 | "Vendor Specific", NULL}, | ||
131 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(vendor.byte_length), "Length", NULL}, | ||
132 | {ACPI_RSD_LONGLIST, ACPI_RSD_OFFSET(vendor.byte_data[0]), "Vendor Data", | ||
133 | NULL} | ||
134 | }; | ||
135 | |||
136 | struct acpi_rsdump_info acpi_rs_dump_end_tag[1] = { | ||
137 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_end_tag), "EndTag", | ||
138 | NULL} | ||
139 | }; | ||
140 | |||
141 | struct acpi_rsdump_info acpi_rs_dump_memory24[6] = { | ||
142 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory24), | ||
143 | "24-Bit Memory Range", NULL}, | ||
144 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(memory24.write_protect), | ||
145 | "Write Protect", acpi_gbl_rw_decode}, | ||
146 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.minimum), "Address Minimum", | ||
147 | NULL}, | ||
148 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.maximum), "Address Maximum", | ||
149 | NULL}, | ||
150 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.alignment), "Alignment", | ||
151 | NULL}, | ||
152 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.address_length), | ||
153 | "Address Length", NULL} | ||
154 | }; | ||
155 | |||
156 | struct acpi_rsdump_info acpi_rs_dump_memory32[6] = { | ||
157 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory32), | ||
158 | "32-Bit Memory Range", NULL}, | ||
159 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(memory32.write_protect), | ||
160 | "Write Protect", acpi_gbl_rw_decode}, | ||
161 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.minimum), "Address Minimum", | ||
162 | NULL}, | ||
163 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.maximum), "Address Maximum", | ||
164 | NULL}, | ||
165 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.alignment), "Alignment", | ||
166 | NULL}, | ||
167 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.address_length), | ||
168 | "Address Length", NULL} | ||
169 | }; | ||
170 | |||
171 | struct acpi_rsdump_info acpi_rs_dump_fixed_memory32[4] = { | ||
172 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_memory32), | ||
173 | "32-Bit Fixed Memory Range", NULL}, | ||
174 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(fixed_memory32.write_protect), | ||
175 | "Write Protect", acpi_gbl_rw_decode}, | ||
176 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(fixed_memory32.address), "Address", | ||
177 | NULL}, | ||
178 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(fixed_memory32.address_length), | ||
179 | "Address Length", NULL} | ||
180 | }; | ||
181 | |||
182 | struct acpi_rsdump_info acpi_rs_dump_address16[8] = { | ||
183 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address16), | ||
184 | "16-Bit WORD Address Space", NULL}, | ||
185 | {ACPI_RSD_ADDRESS, 0, NULL, NULL}, | ||
186 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.granularity), "Granularity", | ||
187 | NULL}, | ||
188 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.minimum), "Address Minimum", | ||
189 | NULL}, | ||
190 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.maximum), "Address Maximum", | ||
191 | NULL}, | ||
192 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.translation_offset), | ||
193 | "Translation Offset", NULL}, | ||
194 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address_length), | ||
195 | "Address Length", NULL}, | ||
196 | {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address16.resource_source), NULL, NULL} | ||
197 | }; | ||
198 | |||
199 | struct acpi_rsdump_info acpi_rs_dump_address32[8] = { | ||
200 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address32), | ||
201 | "32-Bit DWORD Address Space", NULL}, | ||
202 | {ACPI_RSD_ADDRESS, 0, NULL, NULL}, | ||
203 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.granularity), "Granularity", | ||
204 | NULL}, | ||
205 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.minimum), "Address Minimum", | ||
206 | NULL}, | ||
207 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.maximum), "Address Maximum", | ||
208 | NULL}, | ||
209 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.translation_offset), | ||
210 | "Translation Offset", NULL}, | ||
211 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address_length), | ||
212 | "Address Length", NULL}, | ||
213 | {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address32.resource_source), NULL, NULL} | ||
214 | }; | ||
215 | |||
216 | struct acpi_rsdump_info acpi_rs_dump_address64[8] = { | ||
217 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address64), | ||
218 | "64-Bit QWORD Address Space", NULL}, | ||
219 | {ACPI_RSD_ADDRESS, 0, NULL, NULL}, | ||
220 | {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.granularity), "Granularity", | ||
221 | NULL}, | ||
222 | {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.minimum), "Address Minimum", | ||
223 | NULL}, | ||
224 | {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.maximum), "Address Maximum", | ||
225 | NULL}, | ||
226 | {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.translation_offset), | ||
227 | "Translation Offset", NULL}, | ||
228 | {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address_length), | ||
229 | "Address Length", NULL}, | ||
230 | {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address64.resource_source), NULL, NULL} | ||
231 | }; | ||
232 | |||
233 | struct acpi_rsdump_info acpi_rs_dump_ext_address64[8] = { | ||
234 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_ext_address64), | ||
235 | "64-Bit Extended Address Space", NULL}, | ||
236 | {ACPI_RSD_ADDRESS, 0, NULL, NULL}, | ||
237 | {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.granularity), | ||
238 | "Granularity", NULL}, | ||
239 | {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.minimum), | ||
240 | "Address Minimum", NULL}, | ||
241 | {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.maximum), | ||
242 | "Address Maximum", NULL}, | ||
243 | {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.translation_offset), | ||
244 | "Translation Offset", NULL}, | ||
245 | {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address_length), | ||
246 | "Address Length", NULL}, | ||
247 | {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.type_specific), | ||
248 | "Type-Specific Attribute", NULL} | ||
249 | }; | ||
250 | |||
251 | struct acpi_rsdump_info acpi_rs_dump_ext_irq[8] = { | ||
252 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_ext_irq), | ||
253 | "Extended IRQ", NULL}, | ||
254 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.producer_consumer), | ||
255 | "Type", acpi_gbl_consume_decode}, | ||
256 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.triggering), | ||
257 | "Triggering", acpi_gbl_he_decode}, | ||
258 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.polarity), "Polarity", | ||
259 | acpi_gbl_ll_decode}, | ||
260 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(extended_irq.sharable), "Sharing", | ||
261 | acpi_gbl_shr_decode}, | ||
262 | {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(extended_irq.resource_source), NULL, | ||
263 | NULL}, | ||
264 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(extended_irq.interrupt_count), | ||
265 | "Interrupt Count", NULL}, | ||
266 | {ACPI_RSD_DWORDLIST, ACPI_RSD_OFFSET(extended_irq.interrupts[0]), | ||
267 | "Interrupt List", NULL} | ||
268 | }; | ||
269 | |||
270 | struct acpi_rsdump_info acpi_rs_dump_generic_reg[6] = { | ||
271 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_generic_reg), | ||
272 | "Generic Register", NULL}, | ||
273 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.space_id), "Space ID", | ||
274 | NULL}, | ||
275 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.bit_width), "Bit Width", | ||
276 | NULL}, | ||
277 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.bit_offset), "Bit Offset", | ||
278 | NULL}, | ||
279 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.access_size), | ||
280 | "Access Size", NULL}, | ||
281 | {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(generic_reg.address), "Address", NULL} | ||
282 | }; | ||
283 | |||
284 | struct acpi_rsdump_info acpi_rs_dump_gpio[16] = { | ||
285 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_gpio), "GPIO", NULL}, | ||
286 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.revision_id), "RevisionId", NULL}, | ||
287 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.connection_type), | ||
288 | "ConnectionType", acpi_gbl_ct_decode}, | ||
289 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(gpio.producer_consumer), | ||
290 | "ProducerConsumer", acpi_gbl_consume_decode}, | ||
291 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.pin_config), "PinConfig", | ||
292 | acpi_gbl_ppc_decode}, | ||
293 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.sharable), "Sharing", | ||
294 | acpi_gbl_shr_decode}, | ||
295 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.io_restriction), | ||
296 | "IoRestriction", acpi_gbl_ior_decode}, | ||
297 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(gpio.triggering), "Triggering", | ||
298 | acpi_gbl_he_decode}, | ||
299 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.polarity), "Polarity", | ||
300 | acpi_gbl_ll_decode}, | ||
301 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.drive_strength), "DriveStrength", | ||
302 | NULL}, | ||
303 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.debounce_timeout), | ||
304 | "DebounceTimeout", NULL}, | ||
305 | {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(gpio.resource_source), | ||
306 | "ResourceSource", NULL}, | ||
307 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.pin_table_length), | ||
308 | "PinTableLength", NULL}, | ||
309 | {ACPI_RSD_WORDLIST, ACPI_RSD_OFFSET(gpio.pin_table), "PinTable", NULL}, | ||
310 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.vendor_length), "VendorLength", | ||
311 | NULL}, | ||
312 | {ACPI_RSD_SHORTLISTX, ACPI_RSD_OFFSET(gpio.vendor_data), "VendorData", | ||
313 | NULL}, | ||
314 | }; | ||
315 | |||
316 | struct acpi_rsdump_info acpi_rs_dump_fixed_dma[4] = { | ||
317 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_dma), | ||
318 | "FixedDma", NULL}, | ||
319 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_dma.request_lines), | ||
320 | "RequestLines", NULL}, | ||
321 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_dma.channels), "Channels", | ||
322 | NULL}, | ||
323 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(fixed_dma.width), "TransferWidth", | ||
324 | acpi_gbl_dts_decode}, | ||
325 | }; | ||
326 | |||
327 | #define ACPI_RS_DUMP_COMMON_SERIAL_BUS \ | ||
328 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.revision_id), "RevisionId", NULL}, \ | ||
329 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.type), "Type", acpi_gbl_sbt_decode}, \ | ||
330 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (common_serial_bus.producer_consumer), "ProducerConsumer", acpi_gbl_consume_decode}, \ | ||
331 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (common_serial_bus.slave_mode), "SlaveMode", acpi_gbl_sm_decode}, \ | ||
332 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.type_revision_id), "TypeRevisionId", NULL}, \ | ||
333 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (common_serial_bus.type_data_length), "TypeDataLength", NULL}, \ | ||
334 | {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (common_serial_bus.resource_source), "ResourceSource", NULL}, \ | ||
335 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (common_serial_bus.vendor_length), "VendorLength", NULL}, \ | ||
336 | {ACPI_RSD_SHORTLISTX,ACPI_RSD_OFFSET (common_serial_bus.vendor_data), "VendorData", NULL}, | ||
337 | |||
338 | struct acpi_rsdump_info acpi_rs_dump_common_serial_bus[10] = { | ||
339 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_common_serial_bus), | ||
340 | "Common Serial Bus", NULL}, | ||
341 | ACPI_RS_DUMP_COMMON_SERIAL_BUS | ||
342 | }; | ||
343 | |||
344 | struct acpi_rsdump_info acpi_rs_dump_i2c_serial_bus[13] = { | ||
345 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_i2c_serial_bus), | ||
346 | "I2C Serial Bus", NULL}, | ||
347 | ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_1BITFLAG, | ||
348 | ACPI_RSD_OFFSET(i2c_serial_bus. | ||
349 | access_mode), | ||
350 | "AccessMode", acpi_gbl_am_decode}, | ||
351 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(i2c_serial_bus.connection_speed), | ||
352 | "ConnectionSpeed", NULL}, | ||
353 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(i2c_serial_bus.slave_address), | ||
354 | "SlaveAddress", NULL}, | ||
355 | }; | ||
356 | |||
357 | struct acpi_rsdump_info acpi_rs_dump_spi_serial_bus[17] = { | ||
358 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_spi_serial_bus), | ||
359 | "Spi Serial Bus", NULL}, | ||
360 | ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_1BITFLAG, | ||
361 | ACPI_RSD_OFFSET(spi_serial_bus. | ||
362 | wire_mode), "WireMode", | ||
363 | acpi_gbl_wm_decode}, | ||
364 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(spi_serial_bus.device_polarity), | ||
365 | "DevicePolarity", acpi_gbl_dp_decode}, | ||
366 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.data_bit_length), | ||
367 | "DataBitLength", NULL}, | ||
368 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.clock_phase), | ||
369 | "ClockPhase", acpi_gbl_cph_decode}, | ||
370 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.clock_polarity), | ||
371 | "ClockPolarity", acpi_gbl_cpo_decode}, | ||
372 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(spi_serial_bus.device_selection), | ||
373 | "DeviceSelection", NULL}, | ||
374 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(spi_serial_bus.connection_speed), | ||
375 | "ConnectionSpeed", NULL}, | ||
376 | }; | ||
377 | |||
378 | struct acpi_rsdump_info acpi_rs_dump_uart_serial_bus[19] = { | ||
379 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_uart_serial_bus), | ||
380 | "Uart Serial Bus", NULL}, | ||
381 | ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_2BITFLAG, | ||
382 | ACPI_RSD_OFFSET(uart_serial_bus. | ||
383 | flow_control), | ||
384 | "FlowControl", acpi_gbl_fc_decode}, | ||
385 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.stop_bits), | ||
386 | "StopBits", acpi_gbl_sb_decode}, | ||
387 | {ACPI_RSD_3BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.data_bits), | ||
388 | "DataBits", acpi_gbl_bpb_decode}, | ||
389 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.endian), "Endian", | ||
390 | acpi_gbl_ed_decode}, | ||
391 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(uart_serial_bus.parity), "Parity", | ||
392 | acpi_gbl_pt_decode}, | ||
393 | {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(uart_serial_bus.lines_enabled), | ||
394 | "LinesEnabled", NULL}, | ||
395 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(uart_serial_bus.rx_fifo_size), | ||
396 | "RxFifoSize", NULL}, | ||
397 | {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(uart_serial_bus.tx_fifo_size), | ||
398 | "TxFifoSize", NULL}, | ||
399 | {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(uart_serial_bus.default_baud_rate), | ||
400 | "ConnectionSpeed", NULL}, | ||
401 | }; | ||
402 | |||
403 | /* | ||
404 | * Tables used for common address descriptor flag fields | ||
405 | */ | ||
406 | struct acpi_rsdump_info acpi_rs_dump_general_flags[5] = { | ||
407 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_general_flags), NULL, | ||
408 | NULL}, | ||
409 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.producer_consumer), | ||
410 | "Consumer/Producer", acpi_gbl_consume_decode}, | ||
411 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.decode), "Address Decode", | ||
412 | acpi_gbl_dec_decode}, | ||
413 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.min_address_fixed), | ||
414 | "Min Relocatability", acpi_gbl_min_decode}, | ||
415 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.max_address_fixed), | ||
416 | "Max Relocatability", acpi_gbl_max_decode} | ||
417 | }; | ||
418 | |||
419 | struct acpi_rsdump_info acpi_rs_dump_memory_flags[5] = { | ||
420 | {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory_flags), | ||
421 | "Resource Type", (void *)"Memory Range"}, | ||
422 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.write_protect), | ||
423 | "Write Protect", acpi_gbl_rw_decode}, | ||
424 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.caching), | ||
425 | "Caching", acpi_gbl_mem_decode}, | ||
426 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.range_type), | ||
427 | "Range Type", acpi_gbl_mtp_decode}, | ||
428 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.translation), | ||
429 | "Translation", acpi_gbl_ttp_decode} | ||
430 | }; | ||
431 | |||
432 | struct acpi_rsdump_info acpi_rs_dump_io_flags[4] = { | ||
433 | {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io_flags), | ||
434 | "Resource Type", (void *)"I/O Range"}, | ||
435 | {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.io.range_type), | ||
436 | "Range Type", acpi_gbl_rng_decode}, | ||
437 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation), | ||
438 | "Translation", acpi_gbl_ttp_decode}, | ||
439 | {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation_type), | ||
440 | "Translation Type", acpi_gbl_trs_decode} | ||
441 | }; | ||
442 | |||
443 | /* | ||
444 | * Table used to dump _PRT contents | ||
445 | */ | ||
446 | struct acpi_rsdump_info acpi_rs_dump_prt[5] = { | ||
447 | {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_prt), NULL, NULL}, | ||
448 | {ACPI_RSD_UINT64, ACPI_PRT_OFFSET(address), "Address", NULL}, | ||
449 | {ACPI_RSD_UINT32, ACPI_PRT_OFFSET(pin), "Pin", NULL}, | ||
450 | {ACPI_RSD_STRING, ACPI_PRT_OFFSET(source[0]), "Source", NULL}, | ||
451 | {ACPI_RSD_UINT32, ACPI_PRT_OFFSET(source_index), "Source Index", NULL} | ||
452 | }; | ||
453 | |||
454 | #endif | ||
diff --git a/drivers/acpi/acpica/utmisc.c b/drivers/acpi/acpica/utmisc.c index 28819929863c..7ebf4e49266a 100644 --- a/drivers/acpi/acpica/utmisc.c +++ b/drivers/acpi/acpica/utmisc.c | |||
@@ -48,36 +48,6 @@ | |||
48 | #define _COMPONENT ACPI_UTILITIES | 48 | #define _COMPONENT ACPI_UTILITIES |
49 | ACPI_MODULE_NAME("utmisc") | 49 | ACPI_MODULE_NAME("utmisc") |
50 | 50 | ||
51 | #if defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP | ||
52 | /******************************************************************************* | ||
53 | * | ||
54 | * FUNCTION: ut_convert_backslashes | ||
55 | * | ||
56 | * PARAMETERS: pathname - File pathname string to be converted | ||
57 | * | ||
58 | * RETURN: Modifies the input Pathname | ||
59 | * | ||
60 | * DESCRIPTION: Convert all backslashes (0x5C) to forward slashes (0x2F) within | ||
61 | * the entire input file pathname string. | ||
62 | * | ||
63 | ******************************************************************************/ | ||
64 | void ut_convert_backslashes(char *pathname) | ||
65 | { | ||
66 | |||
67 | if (!pathname) { | ||
68 | return; | ||
69 | } | ||
70 | |||
71 | while (*pathname) { | ||
72 | if (*pathname == '\\') { | ||
73 | *pathname = '/'; | ||
74 | } | ||
75 | |||
76 | pathname++; | ||
77 | } | ||
78 | } | ||
79 | #endif | ||
80 | |||
81 | /******************************************************************************* | 51 | /******************************************************************************* |
82 | * | 52 | * |
83 | * FUNCTION: acpi_ut_is_pci_root_bridge | 53 | * FUNCTION: acpi_ut_is_pci_root_bridge |
@@ -89,7 +59,6 @@ void ut_convert_backslashes(char *pathname) | |||
89 | * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID. | 59 | * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID. |
90 | * | 60 | * |
91 | ******************************************************************************/ | 61 | ******************************************************************************/ |
92 | |||
93 | u8 acpi_ut_is_pci_root_bridge(char *id) | 62 | u8 acpi_ut_is_pci_root_bridge(char *id) |
94 | { | 63 | { |
95 | 64 | ||
@@ -136,362 +105,6 @@ u8 acpi_ut_is_aml_table(struct acpi_table_header *table) | |||
136 | 105 | ||
137 | /******************************************************************************* | 106 | /******************************************************************************* |
138 | * | 107 | * |
139 | * FUNCTION: acpi_ut_allocate_owner_id | ||
140 | * | ||
141 | * PARAMETERS: owner_id - Where the new owner ID is returned | ||
142 | * | ||
143 | * RETURN: Status | ||
144 | * | ||
145 | * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to | ||
146 | * track objects created by the table or method, to be deleted | ||
147 | * when the method exits or the table is unloaded. | ||
148 | * | ||
149 | ******************************************************************************/ | ||
150 | |||
151 | acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) | ||
152 | { | ||
153 | u32 i; | ||
154 | u32 j; | ||
155 | u32 k; | ||
156 | acpi_status status; | ||
157 | |||
158 | ACPI_FUNCTION_TRACE(ut_allocate_owner_id); | ||
159 | |||
160 | /* Guard against multiple allocations of ID to the same location */ | ||
161 | |||
162 | if (*owner_id) { | ||
163 | ACPI_ERROR((AE_INFO, "Owner ID [0x%2.2X] already exists", | ||
164 | *owner_id)); | ||
165 | return_ACPI_STATUS(AE_ALREADY_EXISTS); | ||
166 | } | ||
167 | |||
168 | /* Mutex for the global ID mask */ | ||
169 | |||
170 | status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); | ||
171 | if (ACPI_FAILURE(status)) { | ||
172 | return_ACPI_STATUS(status); | ||
173 | } | ||
174 | |||
175 | /* | ||
176 | * Find a free owner ID, cycle through all possible IDs on repeated | ||
177 | * allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index may have | ||
178 | * to be scanned twice. | ||
179 | */ | ||
180 | for (i = 0, j = acpi_gbl_last_owner_id_index; | ||
181 | i < (ACPI_NUM_OWNERID_MASKS + 1); i++, j++) { | ||
182 | if (j >= ACPI_NUM_OWNERID_MASKS) { | ||
183 | j = 0; /* Wraparound to start of mask array */ | ||
184 | } | ||
185 | |||
186 | for (k = acpi_gbl_next_owner_id_offset; k < 32; k++) { | ||
187 | if (acpi_gbl_owner_id_mask[j] == ACPI_UINT32_MAX) { | ||
188 | |||
189 | /* There are no free IDs in this mask */ | ||
190 | |||
191 | break; | ||
192 | } | ||
193 | |||
194 | if (!(acpi_gbl_owner_id_mask[j] & (1 << k))) { | ||
195 | /* | ||
196 | * Found a free ID. The actual ID is the bit index plus one, | ||
197 | * making zero an invalid Owner ID. Save this as the last ID | ||
198 | * allocated and update the global ID mask. | ||
199 | */ | ||
200 | acpi_gbl_owner_id_mask[j] |= (1 << k); | ||
201 | |||
202 | acpi_gbl_last_owner_id_index = (u8)j; | ||
203 | acpi_gbl_next_owner_id_offset = (u8)(k + 1); | ||
204 | |||
205 | /* | ||
206 | * Construct encoded ID from the index and bit position | ||
207 | * | ||
208 | * Note: Last [j].k (bit 255) is never used and is marked | ||
209 | * permanently allocated (prevents +1 overflow) | ||
210 | */ | ||
211 | *owner_id = | ||
212 | (acpi_owner_id) ((k + 1) + ACPI_MUL_32(j)); | ||
213 | |||
214 | ACPI_DEBUG_PRINT((ACPI_DB_VALUES, | ||
215 | "Allocated OwnerId: %2.2X\n", | ||
216 | (unsigned int)*owner_id)); | ||
217 | goto exit; | ||
218 | } | ||
219 | } | ||
220 | |||
221 | acpi_gbl_next_owner_id_offset = 0; | ||
222 | } | ||
223 | |||
224 | /* | ||
225 | * All owner_ids have been allocated. This typically should | ||
226 | * not happen since the IDs are reused after deallocation. The IDs are | ||
227 | * allocated upon table load (one per table) and method execution, and | ||
228 | * they are released when a table is unloaded or a method completes | ||
229 | * execution. | ||
230 | * | ||
231 | * If this error happens, there may be very deep nesting of invoked control | ||
232 | * methods, or there may be a bug where the IDs are not released. | ||
233 | */ | ||
234 | status = AE_OWNER_ID_LIMIT; | ||
235 | ACPI_ERROR((AE_INFO, | ||
236 | "Could not allocate new OwnerId (255 max), AE_OWNER_ID_LIMIT")); | ||
237 | |||
238 | exit: | ||
239 | (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); | ||
240 | return_ACPI_STATUS(status); | ||
241 | } | ||
242 | |||
243 | /******************************************************************************* | ||
244 | * | ||
245 | * FUNCTION: acpi_ut_release_owner_id | ||
246 | * | ||
247 | * PARAMETERS: owner_id_ptr - Pointer to a previously allocated owner_ID | ||
248 | * | ||
249 | * RETURN: None. No error is returned because we are either exiting a | ||
250 | * control method or unloading a table. Either way, we would | ||
251 | * ignore any error anyway. | ||
252 | * | ||
253 | * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 255 | ||
254 | * | ||
255 | ******************************************************************************/ | ||
256 | |||
257 | void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr) | ||
258 | { | ||
259 | acpi_owner_id owner_id = *owner_id_ptr; | ||
260 | acpi_status status; | ||
261 | u32 index; | ||
262 | u32 bit; | ||
263 | |||
264 | ACPI_FUNCTION_TRACE_U32(ut_release_owner_id, owner_id); | ||
265 | |||
266 | /* Always clear the input owner_id (zero is an invalid ID) */ | ||
267 | |||
268 | *owner_id_ptr = 0; | ||
269 | |||
270 | /* Zero is not a valid owner_ID */ | ||
271 | |||
272 | if (owner_id == 0) { | ||
273 | ACPI_ERROR((AE_INFO, "Invalid OwnerId: 0x%2.2X", owner_id)); | ||
274 | return_VOID; | ||
275 | } | ||
276 | |||
277 | /* Mutex for the global ID mask */ | ||
278 | |||
279 | status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); | ||
280 | if (ACPI_FAILURE(status)) { | ||
281 | return_VOID; | ||
282 | } | ||
283 | |||
284 | /* Normalize the ID to zero */ | ||
285 | |||
286 | owner_id--; | ||
287 | |||
288 | /* Decode ID to index/offset pair */ | ||
289 | |||
290 | index = ACPI_DIV_32(owner_id); | ||
291 | bit = 1 << ACPI_MOD_32(owner_id); | ||
292 | |||
293 | /* Free the owner ID only if it is valid */ | ||
294 | |||
295 | if (acpi_gbl_owner_id_mask[index] & bit) { | ||
296 | acpi_gbl_owner_id_mask[index] ^= bit; | ||
297 | } else { | ||
298 | ACPI_ERROR((AE_INFO, | ||
299 | "Release of non-allocated OwnerId: 0x%2.2X", | ||
300 | owner_id + 1)); | ||
301 | } | ||
302 | |||
303 | (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); | ||
304 | return_VOID; | ||
305 | } | ||
306 | |||
307 | /******************************************************************************* | ||
308 | * | ||
309 | * FUNCTION: acpi_ut_strupr (strupr) | ||
310 | * | ||
311 | * PARAMETERS: src_string - The source string to convert | ||
312 | * | ||
313 | * RETURN: None | ||
314 | * | ||
315 | * DESCRIPTION: Convert string to uppercase | ||
316 | * | ||
317 | * NOTE: This is not a POSIX function, so it appears here, not in utclib.c | ||
318 | * | ||
319 | ******************************************************************************/ | ||
320 | |||
321 | void acpi_ut_strupr(char *src_string) | ||
322 | { | ||
323 | char *string; | ||
324 | |||
325 | ACPI_FUNCTION_ENTRY(); | ||
326 | |||
327 | if (!src_string) { | ||
328 | return; | ||
329 | } | ||
330 | |||
331 | /* Walk entire string, uppercasing the letters */ | ||
332 | |||
333 | for (string = src_string; *string; string++) { | ||
334 | *string = (char)ACPI_TOUPPER(*string); | ||
335 | } | ||
336 | |||
337 | return; | ||
338 | } | ||
339 | |||
340 | #ifdef ACPI_ASL_COMPILER | ||
341 | /******************************************************************************* | ||
342 | * | ||
343 | * FUNCTION: acpi_ut_strlwr (strlwr) | ||
344 | * | ||
345 | * PARAMETERS: src_string - The source string to convert | ||
346 | * | ||
347 | * RETURN: None | ||
348 | * | ||
349 | * DESCRIPTION: Convert string to lowercase | ||
350 | * | ||
351 | * NOTE: This is not a POSIX function, so it appears here, not in utclib.c | ||
352 | * | ||
353 | ******************************************************************************/ | ||
354 | |||
355 | void acpi_ut_strlwr(char *src_string) | ||
356 | { | ||
357 | char *string; | ||
358 | |||
359 | ACPI_FUNCTION_ENTRY(); | ||
360 | |||
361 | if (!src_string) { | ||
362 | return; | ||
363 | } | ||
364 | |||
365 | /* Walk entire string, lowercasing the letters */ | ||
366 | |||
367 | for (string = src_string; *string; string++) { | ||
368 | *string = (char)ACPI_TOLOWER(*string); | ||
369 | } | ||
370 | |||
371 | return; | ||
372 | } | ||
373 | |||
374 | /****************************************************************************** | ||
375 | * | ||
376 | * FUNCTION: acpi_ut_stricmp | ||
377 | * | ||
378 | * PARAMETERS: string1 - first string to compare | ||
379 | * string2 - second string to compare | ||
380 | * | ||
381 | * RETURN: int that signifies string relationship. Zero means strings | ||
382 | * are equal. | ||
383 | * | ||
384 | * DESCRIPTION: Implementation of the non-ANSI stricmp function (compare | ||
385 | * strings with no case sensitivity) | ||
386 | * | ||
387 | ******************************************************************************/ | ||
388 | |||
389 | int acpi_ut_stricmp(char *string1, char *string2) | ||
390 | { | ||
391 | int c1; | ||
392 | int c2; | ||
393 | |||
394 | do { | ||
395 | c1 = tolower((int)*string1); | ||
396 | c2 = tolower((int)*string2); | ||
397 | |||
398 | string1++; | ||
399 | string2++; | ||
400 | } | ||
401 | while ((c1 == c2) && (c1)); | ||
402 | |||
403 | return (c1 - c2); | ||
404 | } | ||
405 | #endif | ||
406 | |||
407 | /******************************************************************************* | ||
408 | * | ||
409 | * FUNCTION: acpi_ut_print_string | ||
410 | * | ||
411 | * PARAMETERS: string - Null terminated ASCII string | ||
412 | * max_length - Maximum output length | ||
413 | * | ||
414 | * RETURN: None | ||
415 | * | ||
416 | * DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape | ||
417 | * sequences. | ||
418 | * | ||
419 | ******************************************************************************/ | ||
420 | |||
421 | void acpi_ut_print_string(char *string, u8 max_length) | ||
422 | { | ||
423 | u32 i; | ||
424 | |||
425 | if (!string) { | ||
426 | acpi_os_printf("<\"NULL STRING PTR\">"); | ||
427 | return; | ||
428 | } | ||
429 | |||
430 | acpi_os_printf("\""); | ||
431 | for (i = 0; string[i] && (i < max_length); i++) { | ||
432 | |||
433 | /* Escape sequences */ | ||
434 | |||
435 | switch (string[i]) { | ||
436 | case 0x07: | ||
437 | acpi_os_printf("\\a"); /* BELL */ | ||
438 | break; | ||
439 | |||
440 | case 0x08: | ||
441 | acpi_os_printf("\\b"); /* BACKSPACE */ | ||
442 | break; | ||
443 | |||
444 | case 0x0C: | ||
445 | acpi_os_printf("\\f"); /* FORMFEED */ | ||
446 | break; | ||
447 | |||
448 | case 0x0A: | ||
449 | acpi_os_printf("\\n"); /* LINEFEED */ | ||
450 | break; | ||
451 | |||
452 | case 0x0D: | ||
453 | acpi_os_printf("\\r"); /* CARRIAGE RETURN */ | ||
454 | break; | ||
455 | |||
456 | case 0x09: | ||
457 | acpi_os_printf("\\t"); /* HORIZONTAL TAB */ | ||
458 | break; | ||
459 | |||
460 | case 0x0B: | ||
461 | acpi_os_printf("\\v"); /* VERTICAL TAB */ | ||
462 | break; | ||
463 | |||
464 | case '\'': /* Single Quote */ | ||
465 | case '\"': /* Double Quote */ | ||
466 | case '\\': /* Backslash */ | ||
467 | acpi_os_printf("\\%c", (int)string[i]); | ||
468 | break; | ||
469 | |||
470 | default: | ||
471 | |||
472 | /* Check for printable character or hex escape */ | ||
473 | |||
474 | if (ACPI_IS_PRINT(string[i])) { | ||
475 | /* This is a normal character */ | ||
476 | |||
477 | acpi_os_printf("%c", (int)string[i]); | ||
478 | } else { | ||
479 | /* All others will be Hex escapes */ | ||
480 | |||
481 | acpi_os_printf("\\x%2.2X", (s32) string[i]); | ||
482 | } | ||
483 | break; | ||
484 | } | ||
485 | } | ||
486 | acpi_os_printf("\""); | ||
487 | |||
488 | if (i == max_length && string[i]) { | ||
489 | acpi_os_printf("..."); | ||
490 | } | ||
491 | } | ||
492 | |||
493 | /******************************************************************************* | ||
494 | * | ||
495 | * FUNCTION: acpi_ut_dword_byte_swap | 108 | * FUNCTION: acpi_ut_dword_byte_swap |
496 | * | 109 | * |
497 | * PARAMETERS: value - Value to be converted | 110 | * PARAMETERS: value - Value to be converted |
@@ -559,379 +172,6 @@ void acpi_ut_set_integer_width(u8 revision) | |||
559 | } | 172 | } |
560 | } | 173 | } |
561 | 174 | ||
562 | #ifdef ACPI_DEBUG_OUTPUT | ||
563 | /******************************************************************************* | ||
564 | * | ||
565 | * FUNCTION: acpi_ut_display_init_pathname | ||
566 | * | ||
567 | * PARAMETERS: type - Object type of the node | ||
568 | * obj_handle - Handle whose pathname will be displayed | ||
569 | * path - Additional path string to be appended. | ||
570 | * (NULL if no extra path) | ||
571 | * | ||
572 | * RETURN: acpi_status | ||
573 | * | ||
574 | * DESCRIPTION: Display full pathname of an object, DEBUG ONLY | ||
575 | * | ||
576 | ******************************************************************************/ | ||
577 | |||
578 | void | ||
579 | acpi_ut_display_init_pathname(u8 type, | ||
580 | struct acpi_namespace_node *obj_handle, | ||
581 | char *path) | ||
582 | { | ||
583 | acpi_status status; | ||
584 | struct acpi_buffer buffer; | ||
585 | |||
586 | ACPI_FUNCTION_ENTRY(); | ||
587 | |||
588 | /* Only print the path if the appropriate debug level is enabled */ | ||
589 | |||
590 | if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) { | ||
591 | return; | ||
592 | } | ||
593 | |||
594 | /* Get the full pathname to the node */ | ||
595 | |||
596 | buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; | ||
597 | status = acpi_ns_handle_to_pathname(obj_handle, &buffer); | ||
598 | if (ACPI_FAILURE(status)) { | ||
599 | return; | ||
600 | } | ||
601 | |||
602 | /* Print what we're doing */ | ||
603 | |||
604 | switch (type) { | ||
605 | case ACPI_TYPE_METHOD: | ||
606 | acpi_os_printf("Executing "); | ||
607 | break; | ||
608 | |||
609 | default: | ||
610 | acpi_os_printf("Initializing "); | ||
611 | break; | ||
612 | } | ||
613 | |||
614 | /* Print the object type and pathname */ | ||
615 | |||
616 | acpi_os_printf("%-12s %s", | ||
617 | acpi_ut_get_type_name(type), (char *)buffer.pointer); | ||
618 | |||
619 | /* Extra path is used to append names like _STA, _INI, etc. */ | ||
620 | |||
621 | if (path) { | ||
622 | acpi_os_printf(".%s", path); | ||
623 | } | ||
624 | acpi_os_printf("\n"); | ||
625 | |||
626 | ACPI_FREE(buffer.pointer); | ||
627 | } | ||
628 | #endif | ||
629 | |||
630 | /******************************************************************************* | ||
631 | * | ||
632 | * FUNCTION: acpi_ut_valid_acpi_char | ||
633 | * | ||
634 | * PARAMETERS: char - The character to be examined | ||
635 | * position - Byte position (0-3) | ||
636 | * | ||
637 | * RETURN: TRUE if the character is valid, FALSE otherwise | ||
638 | * | ||
639 | * DESCRIPTION: Check for a valid ACPI character. Must be one of: | ||
640 | * 1) Upper case alpha | ||
641 | * 2) numeric | ||
642 | * 3) underscore | ||
643 | * | ||
644 | * We allow a '!' as the last character because of the ASF! table | ||
645 | * | ||
646 | ******************************************************************************/ | ||
647 | |||
648 | u8 acpi_ut_valid_acpi_char(char character, u32 position) | ||
649 | { | ||
650 | |||
651 | if (!((character >= 'A' && character <= 'Z') || | ||
652 | (character >= '0' && character <= '9') || (character == '_'))) { | ||
653 | |||
654 | /* Allow a '!' in the last position */ | ||
655 | |||
656 | if (character == '!' && position == 3) { | ||
657 | return (TRUE); | ||
658 | } | ||
659 | |||
660 | return (FALSE); | ||
661 | } | ||
662 | |||
663 | return (TRUE); | ||
664 | } | ||
665 | |||
666 | /******************************************************************************* | ||
667 | * | ||
668 | * FUNCTION: acpi_ut_valid_acpi_name | ||
669 | * | ||
670 | * PARAMETERS: name - The name to be examined | ||
671 | * | ||
672 | * RETURN: TRUE if the name is valid, FALSE otherwise | ||
673 | * | ||
674 | * DESCRIPTION: Check for a valid ACPI name. Each character must be one of: | ||
675 | * 1) Upper case alpha | ||
676 | * 2) numeric | ||
677 | * 3) underscore | ||
678 | * | ||
679 | ******************************************************************************/ | ||
680 | |||
681 | u8 acpi_ut_valid_acpi_name(u32 name) | ||
682 | { | ||
683 | u32 i; | ||
684 | |||
685 | ACPI_FUNCTION_ENTRY(); | ||
686 | |||
687 | for (i = 0; i < ACPI_NAME_SIZE; i++) { | ||
688 | if (!acpi_ut_valid_acpi_char | ||
689 | ((ACPI_CAST_PTR(char, &name))[i], i)) { | ||
690 | return (FALSE); | ||
691 | } | ||
692 | } | ||
693 | |||
694 | return (TRUE); | ||
695 | } | ||
696 | |||
697 | /******************************************************************************* | ||
698 | * | ||
699 | * FUNCTION: acpi_ut_repair_name | ||
700 | * | ||
701 | * PARAMETERS: name - The ACPI name to be repaired | ||
702 | * | ||
703 | * RETURN: Repaired version of the name | ||
704 | * | ||
705 | * DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and | ||
706 | * return the new name. NOTE: the Name parameter must reside in | ||
707 | * read/write memory, cannot be a const. | ||
708 | * | ||
709 | * An ACPI Name must consist of valid ACPI characters. We will repair the name | ||
710 | * if necessary because we don't want to abort because of this, but we want | ||
711 | * all namespace names to be printable. A warning message is appropriate. | ||
712 | * | ||
713 | * This issue came up because there are in fact machines that exhibit | ||
714 | * this problem, and we want to be able to enable ACPI support for them, | ||
715 | * even though there are a few bad names. | ||
716 | * | ||
717 | ******************************************************************************/ | ||
718 | |||
719 | void acpi_ut_repair_name(char *name) | ||
720 | { | ||
721 | u32 i; | ||
722 | u8 found_bad_char = FALSE; | ||
723 | u32 original_name; | ||
724 | |||
725 | ACPI_FUNCTION_NAME(ut_repair_name); | ||
726 | |||
727 | ACPI_MOVE_NAME(&original_name, name); | ||
728 | |||
729 | /* Check each character in the name */ | ||
730 | |||
731 | for (i = 0; i < ACPI_NAME_SIZE; i++) { | ||
732 | if (acpi_ut_valid_acpi_char(name[i], i)) { | ||
733 | continue; | ||
734 | } | ||
735 | |||
736 | /* | ||
737 | * Replace a bad character with something printable, yet technically | ||
738 | * still invalid. This prevents any collisions with existing "good" | ||
739 | * names in the namespace. | ||
740 | */ | ||
741 | name[i] = '*'; | ||
742 | found_bad_char = TRUE; | ||
743 | } | ||
744 | |||
745 | if (found_bad_char) { | ||
746 | |||
747 | /* Report warning only if in strict mode or debug mode */ | ||
748 | |||
749 | if (!acpi_gbl_enable_interpreter_slack) { | ||
750 | ACPI_WARNING((AE_INFO, | ||
751 | "Invalid character(s) in name (0x%.8X), repaired: [%4.4s]", | ||
752 | original_name, name)); | ||
753 | } else { | ||
754 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
755 | "Invalid character(s) in name (0x%.8X), repaired: [%4.4s]", | ||
756 | original_name, name)); | ||
757 | } | ||
758 | } | ||
759 | } | ||
760 | |||
761 | /******************************************************************************* | ||
762 | * | ||
763 | * FUNCTION: acpi_ut_strtoul64 | ||
764 | * | ||
765 | * PARAMETERS: string - Null terminated string | ||
766 | * base - Radix of the string: 16 or ACPI_ANY_BASE; | ||
767 | * ACPI_ANY_BASE means 'in behalf of to_integer' | ||
768 | * ret_integer - Where the converted integer is returned | ||
769 | * | ||
770 | * RETURN: Status and Converted value | ||
771 | * | ||
772 | * DESCRIPTION: Convert a string into an unsigned value. Performs either a | ||
773 | * 32-bit or 64-bit conversion, depending on the current mode | ||
774 | * of the interpreter. | ||
775 | * NOTE: Does not support Octal strings, not needed. | ||
776 | * | ||
777 | ******************************************************************************/ | ||
778 | |||
779 | acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer) | ||
780 | { | ||
781 | u32 this_digit = 0; | ||
782 | u64 return_value = 0; | ||
783 | u64 quotient; | ||
784 | u64 dividend; | ||
785 | u32 to_integer_op = (base == ACPI_ANY_BASE); | ||
786 | u32 mode32 = (acpi_gbl_integer_byte_width == 4); | ||
787 | u8 valid_digits = 0; | ||
788 | u8 sign_of0x = 0; | ||
789 | u8 term = 0; | ||
790 | |||
791 | ACPI_FUNCTION_TRACE_STR(ut_stroul64, string); | ||
792 | |||
793 | switch (base) { | ||
794 | case ACPI_ANY_BASE: | ||
795 | case 16: | ||
796 | break; | ||
797 | |||
798 | default: | ||
799 | /* Invalid Base */ | ||
800 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
801 | } | ||
802 | |||
803 | if (!string) { | ||
804 | goto error_exit; | ||
805 | } | ||
806 | |||
807 | /* Skip over any white space in the buffer */ | ||
808 | |||
809 | while ((*string) && (ACPI_IS_SPACE(*string) || *string == '\t')) { | ||
810 | string++; | ||
811 | } | ||
812 | |||
813 | if (to_integer_op) { | ||
814 | /* | ||
815 | * Base equal to ACPI_ANY_BASE means 'ToInteger operation case'. | ||
816 | * We need to determine if it is decimal or hexadecimal. | ||
817 | */ | ||
818 | if ((*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) { | ||
819 | sign_of0x = 1; | ||
820 | base = 16; | ||
821 | |||
822 | /* Skip over the leading '0x' */ | ||
823 | string += 2; | ||
824 | } else { | ||
825 | base = 10; | ||
826 | } | ||
827 | } | ||
828 | |||
829 | /* Any string left? Check that '0x' is not followed by white space. */ | ||
830 | |||
831 | if (!(*string) || ACPI_IS_SPACE(*string) || *string == '\t') { | ||
832 | if (to_integer_op) { | ||
833 | goto error_exit; | ||
834 | } else { | ||
835 | goto all_done; | ||
836 | } | ||
837 | } | ||
838 | |||
839 | /* | ||
840 | * Perform a 32-bit or 64-bit conversion, depending upon the current | ||
841 | * execution mode of the interpreter | ||
842 | */ | ||
843 | dividend = (mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX; | ||
844 | |||
845 | /* Main loop: convert the string to a 32- or 64-bit integer */ | ||
846 | |||
847 | while (*string) { | ||
848 | if (ACPI_IS_DIGIT(*string)) { | ||
849 | |||
850 | /* Convert ASCII 0-9 to Decimal value */ | ||
851 | |||
852 | this_digit = ((u8)*string) - '0'; | ||
853 | } else if (base == 10) { | ||
854 | |||
855 | /* Digit is out of range; possible in to_integer case only */ | ||
856 | |||
857 | term = 1; | ||
858 | } else { | ||
859 | this_digit = (u8)ACPI_TOUPPER(*string); | ||
860 | if (ACPI_IS_XDIGIT((char)this_digit)) { | ||
861 | |||
862 | /* Convert ASCII Hex char to value */ | ||
863 | |||
864 | this_digit = this_digit - 'A' + 10; | ||
865 | } else { | ||
866 | term = 1; | ||
867 | } | ||
868 | } | ||
869 | |||
870 | if (term) { | ||
871 | if (to_integer_op) { | ||
872 | goto error_exit; | ||
873 | } else { | ||
874 | break; | ||
875 | } | ||
876 | } else if ((valid_digits == 0) && (this_digit == 0) | ||
877 | && !sign_of0x) { | ||
878 | |||
879 | /* Skip zeros */ | ||
880 | string++; | ||
881 | continue; | ||
882 | } | ||
883 | |||
884 | valid_digits++; | ||
885 | |||
886 | if (sign_of0x | ||
887 | && ((valid_digits > 16) | ||
888 | || ((valid_digits > 8) && mode32))) { | ||
889 | /* | ||
890 | * This is to_integer operation case. | ||
891 | * No any restrictions for string-to-integer conversion, | ||
892 | * see ACPI spec. | ||
893 | */ | ||
894 | goto error_exit; | ||
895 | } | ||
896 | |||
897 | /* Divide the digit into the correct position */ | ||
898 | |||
899 | (void)acpi_ut_short_divide((dividend - (u64)this_digit), | ||
900 | base, "ient, NULL); | ||
901 | |||
902 | if (return_value > quotient) { | ||
903 | if (to_integer_op) { | ||
904 | goto error_exit; | ||
905 | } else { | ||
906 | break; | ||
907 | } | ||
908 | } | ||
909 | |||
910 | return_value *= base; | ||
911 | return_value += this_digit; | ||
912 | string++; | ||
913 | } | ||
914 | |||
915 | /* All done, normal exit */ | ||
916 | |||
917 | all_done: | ||
918 | |||
919 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n", | ||
920 | ACPI_FORMAT_UINT64(return_value))); | ||
921 | |||
922 | *ret_integer = return_value; | ||
923 | return_ACPI_STATUS(AE_OK); | ||
924 | |||
925 | error_exit: | ||
926 | /* Base was set/validated above */ | ||
927 | |||
928 | if (base == 10) { | ||
929 | return_ACPI_STATUS(AE_BAD_DECIMAL_CONSTANT); | ||
930 | } else { | ||
931 | return_ACPI_STATUS(AE_BAD_HEX_CONSTANT); | ||
932 | } | ||
933 | } | ||
934 | |||
935 | /******************************************************************************* | 175 | /******************************************************************************* |
936 | * | 176 | * |
937 | * FUNCTION: acpi_ut_create_update_state_and_push | 177 | * FUNCTION: acpi_ut_create_update_state_and_push |
@@ -1097,3 +337,71 @@ acpi_ut_walk_package_tree(union acpi_operand_object *source_object, | |||
1097 | 337 | ||
1098 | return_ACPI_STATUS(AE_AML_INTERNAL); | 338 | return_ACPI_STATUS(AE_AML_INTERNAL); |
1099 | } | 339 | } |
340 | |||
341 | #ifdef ACPI_DEBUG_OUTPUT | ||
342 | /******************************************************************************* | ||
343 | * | ||
344 | * FUNCTION: acpi_ut_display_init_pathname | ||
345 | * | ||
346 | * PARAMETERS: type - Object type of the node | ||
347 | * obj_handle - Handle whose pathname will be displayed | ||
348 | * path - Additional path string to be appended. | ||
349 | * (NULL if no extra path) | ||
350 | * | ||
351 | * RETURN: acpi_status | ||
352 | * | ||
353 | * DESCRIPTION: Display full pathname of an object, DEBUG ONLY | ||
354 | * | ||
355 | ******************************************************************************/ | ||
356 | |||
357 | void | ||
358 | acpi_ut_display_init_pathname(u8 type, | ||
359 | struct acpi_namespace_node *obj_handle, | ||
360 | char *path) | ||
361 | { | ||
362 | acpi_status status; | ||
363 | struct acpi_buffer buffer; | ||
364 | |||
365 | ACPI_FUNCTION_ENTRY(); | ||
366 | |||
367 | /* Only print the path if the appropriate debug level is enabled */ | ||
368 | |||
369 | if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) { | ||
370 | return; | ||
371 | } | ||
372 | |||
373 | /* Get the full pathname to the node */ | ||
374 | |||
375 | buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; | ||
376 | status = acpi_ns_handle_to_pathname(obj_handle, &buffer); | ||
377 | if (ACPI_FAILURE(status)) { | ||
378 | return; | ||
379 | } | ||
380 | |||
381 | /* Print what we're doing */ | ||
382 | |||
383 | switch (type) { | ||
384 | case ACPI_TYPE_METHOD: | ||
385 | acpi_os_printf("Executing "); | ||
386 | break; | ||
387 | |||
388 | default: | ||
389 | acpi_os_printf("Initializing "); | ||
390 | break; | ||
391 | } | ||
392 | |||
393 | /* Print the object type and pathname */ | ||
394 | |||
395 | acpi_os_printf("%-12s %s", | ||
396 | acpi_ut_get_type_name(type), (char *)buffer.pointer); | ||
397 | |||
398 | /* Extra path is used to append names like _STA, _INI, etc. */ | ||
399 | |||
400 | if (path) { | ||
401 | acpi_os_printf(".%s", path); | ||
402 | } | ||
403 | acpi_os_printf("\n"); | ||
404 | |||
405 | ACPI_FREE(buffer.pointer); | ||
406 | } | ||
407 | #endif | ||
diff --git a/drivers/acpi/acpica/utownerid.c b/drivers/acpi/acpica/utownerid.c new file mode 100644 index 000000000000..6b42e6330164 --- /dev/null +++ b/drivers/acpi/acpica/utownerid.c | |||
@@ -0,0 +1,218 @@ | |||
1 | /******************************************************************************* | ||
2 | * | ||
3 | * Module Name: utownerid - Support for Table/Method Owner IDs | ||
4 | * | ||
5 | ******************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2012, 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 | |||
48 | #define _COMPONENT ACPI_UTILITIES | ||
49 | ACPI_MODULE_NAME("utownerid") | ||
50 | |||
51 | /******************************************************************************* | ||
52 | * | ||
53 | * FUNCTION: acpi_ut_allocate_owner_id | ||
54 | * | ||
55 | * PARAMETERS: owner_id - Where the new owner ID is returned | ||
56 | * | ||
57 | * RETURN: Status | ||
58 | * | ||
59 | * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to | ||
60 | * track objects created by the table or method, to be deleted | ||
61 | * when the method exits or the table is unloaded. | ||
62 | * | ||
63 | ******************************************************************************/ | ||
64 | acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) | ||
65 | { | ||
66 | u32 i; | ||
67 | u32 j; | ||
68 | u32 k; | ||
69 | acpi_status status; | ||
70 | |||
71 | ACPI_FUNCTION_TRACE(ut_allocate_owner_id); | ||
72 | |||
73 | /* Guard against multiple allocations of ID to the same location */ | ||
74 | |||
75 | if (*owner_id) { | ||
76 | ACPI_ERROR((AE_INFO, "Owner ID [0x%2.2X] already exists", | ||
77 | *owner_id)); | ||
78 | return_ACPI_STATUS(AE_ALREADY_EXISTS); | ||
79 | } | ||
80 | |||
81 | /* Mutex for the global ID mask */ | ||
82 | |||
83 | status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); | ||
84 | if (ACPI_FAILURE(status)) { | ||
85 | return_ACPI_STATUS(status); | ||
86 | } | ||
87 | |||
88 | /* | ||
89 | * Find a free owner ID, cycle through all possible IDs on repeated | ||
90 | * allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index may have | ||
91 | * to be scanned twice. | ||
92 | */ | ||
93 | for (i = 0, j = acpi_gbl_last_owner_id_index; | ||
94 | i < (ACPI_NUM_OWNERID_MASKS + 1); i++, j++) { | ||
95 | if (j >= ACPI_NUM_OWNERID_MASKS) { | ||
96 | j = 0; /* Wraparound to start of mask array */ | ||
97 | } | ||
98 | |||
99 | for (k = acpi_gbl_next_owner_id_offset; k < 32; k++) { | ||
100 | if (acpi_gbl_owner_id_mask[j] == ACPI_UINT32_MAX) { | ||
101 | |||
102 | /* There are no free IDs in this mask */ | ||
103 | |||
104 | break; | ||
105 | } | ||
106 | |||
107 | if (!(acpi_gbl_owner_id_mask[j] & (1 << k))) { | ||
108 | /* | ||
109 | * Found a free ID. The actual ID is the bit index plus one, | ||
110 | * making zero an invalid Owner ID. Save this as the last ID | ||
111 | * allocated and update the global ID mask. | ||
112 | */ | ||
113 | acpi_gbl_owner_id_mask[j] |= (1 << k); | ||
114 | |||
115 | acpi_gbl_last_owner_id_index = (u8)j; | ||
116 | acpi_gbl_next_owner_id_offset = (u8)(k + 1); | ||
117 | |||
118 | /* | ||
119 | * Construct encoded ID from the index and bit position | ||
120 | * | ||
121 | * Note: Last [j].k (bit 255) is never used and is marked | ||
122 | * permanently allocated (prevents +1 overflow) | ||
123 | */ | ||
124 | *owner_id = | ||
125 | (acpi_owner_id) ((k + 1) + ACPI_MUL_32(j)); | ||
126 | |||
127 | ACPI_DEBUG_PRINT((ACPI_DB_VALUES, | ||
128 | "Allocated OwnerId: %2.2X\n", | ||
129 | (unsigned int)*owner_id)); | ||
130 | goto exit; | ||
131 | } | ||
132 | } | ||
133 | |||
134 | acpi_gbl_next_owner_id_offset = 0; | ||
135 | } | ||
136 | |||
137 | /* | ||
138 | * All owner_ids have been allocated. This typically should | ||
139 | * not happen since the IDs are reused after deallocation. The IDs are | ||
140 | * allocated upon table load (one per table) and method execution, and | ||
141 | * they are released when a table is unloaded or a method completes | ||
142 | * execution. | ||
143 | * | ||
144 | * If this error happens, there may be very deep nesting of invoked control | ||
145 | * methods, or there may be a bug where the IDs are not released. | ||
146 | */ | ||
147 | status = AE_OWNER_ID_LIMIT; | ||
148 | ACPI_ERROR((AE_INFO, | ||
149 | "Could not allocate new OwnerId (255 max), AE_OWNER_ID_LIMIT")); | ||
150 | |||
151 | exit: | ||
152 | (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); | ||
153 | return_ACPI_STATUS(status); | ||
154 | } | ||
155 | |||
156 | /******************************************************************************* | ||
157 | * | ||
158 | * FUNCTION: acpi_ut_release_owner_id | ||
159 | * | ||
160 | * PARAMETERS: owner_id_ptr - Pointer to a previously allocated owner_ID | ||
161 | * | ||
162 | * RETURN: None. No error is returned because we are either exiting a | ||
163 | * control method or unloading a table. Either way, we would | ||
164 | * ignore any error anyway. | ||
165 | * | ||
166 | * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 255 | ||
167 | * | ||
168 | ******************************************************************************/ | ||
169 | |||
170 | void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr) | ||
171 | { | ||
172 | acpi_owner_id owner_id = *owner_id_ptr; | ||
173 | acpi_status status; | ||
174 | u32 index; | ||
175 | u32 bit; | ||
176 | |||
177 | ACPI_FUNCTION_TRACE_U32(ut_release_owner_id, owner_id); | ||
178 | |||
179 | /* Always clear the input owner_id (zero is an invalid ID) */ | ||
180 | |||
181 | *owner_id_ptr = 0; | ||
182 | |||
183 | /* Zero is not a valid owner_ID */ | ||
184 | |||
185 | if (owner_id == 0) { | ||
186 | ACPI_ERROR((AE_INFO, "Invalid OwnerId: 0x%2.2X", owner_id)); | ||
187 | return_VOID; | ||
188 | } | ||
189 | |||
190 | /* Mutex for the global ID mask */ | ||
191 | |||
192 | status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); | ||
193 | if (ACPI_FAILURE(status)) { | ||
194 | return_VOID; | ||
195 | } | ||
196 | |||
197 | /* Normalize the ID to zero */ | ||
198 | |||
199 | owner_id--; | ||
200 | |||
201 | /* Decode ID to index/offset pair */ | ||
202 | |||
203 | index = ACPI_DIV_32(owner_id); | ||
204 | bit = 1 << ACPI_MOD_32(owner_id); | ||
205 | |||
206 | /* Free the owner ID only if it is valid */ | ||
207 | |||
208 | if (acpi_gbl_owner_id_mask[index] & bit) { | ||
209 | acpi_gbl_owner_id_mask[index] ^= bit; | ||
210 | } else { | ||
211 | ACPI_ERROR((AE_INFO, | ||
212 | "Release of non-allocated OwnerId: 0x%2.2X", | ||
213 | owner_id + 1)); | ||
214 | } | ||
215 | |||
216 | (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); | ||
217 | return_VOID; | ||
218 | } | ||
diff --git a/drivers/acpi/acpica/utstring.c b/drivers/acpi/acpica/utstring.c new file mode 100644 index 000000000000..41702658c45b --- /dev/null +++ b/drivers/acpi/acpica/utstring.c | |||
@@ -0,0 +1,574 @@ | |||
1 | /******************************************************************************* | ||
2 | * | ||
3 | * Module Name: utstring - Common functions for strings and characters | ||
4 | * | ||
5 | ******************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2012, 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 | |||
48 | #define _COMPONENT ACPI_UTILITIES | ||
49 | ACPI_MODULE_NAME("utstring") | ||
50 | |||
51 | /* | ||
52 | * Non-ANSI C library functions - strlwr, strupr, stricmp, and a 64-bit | ||
53 | * version of strtoul. | ||
54 | */ | ||
55 | #ifdef ACPI_ASL_COMPILER | ||
56 | /******************************************************************************* | ||
57 | * | ||
58 | * FUNCTION: acpi_ut_strlwr (strlwr) | ||
59 | * | ||
60 | * PARAMETERS: src_string - The source string to convert | ||
61 | * | ||
62 | * RETURN: None | ||
63 | * | ||
64 | * DESCRIPTION: Convert string to lowercase | ||
65 | * | ||
66 | * NOTE: This is not a POSIX function, so it appears here, not in utclib.c | ||
67 | * | ||
68 | ******************************************************************************/ | ||
69 | void acpi_ut_strlwr(char *src_string) | ||
70 | { | ||
71 | char *string; | ||
72 | |||
73 | ACPI_FUNCTION_ENTRY(); | ||
74 | |||
75 | if (!src_string) { | ||
76 | return; | ||
77 | } | ||
78 | |||
79 | /* Walk entire string, lowercasing the letters */ | ||
80 | |||
81 | for (string = src_string; *string; string++) { | ||
82 | *string = (char)ACPI_TOLOWER(*string); | ||
83 | } | ||
84 | |||
85 | return; | ||
86 | } | ||
87 | |||
88 | /****************************************************************************** | ||
89 | * | ||
90 | * FUNCTION: acpi_ut_stricmp (stricmp) | ||
91 | * | ||
92 | * PARAMETERS: string1 - first string to compare | ||
93 | * string2 - second string to compare | ||
94 | * | ||
95 | * RETURN: int that signifies string relationship. Zero means strings | ||
96 | * are equal. | ||
97 | * | ||
98 | * DESCRIPTION: Implementation of the non-ANSI stricmp function (compare | ||
99 | * strings with no case sensitivity) | ||
100 | * | ||
101 | ******************************************************************************/ | ||
102 | |||
103 | int acpi_ut_stricmp(char *string1, char *string2) | ||
104 | { | ||
105 | int c1; | ||
106 | int c2; | ||
107 | |||
108 | do { | ||
109 | c1 = tolower((int)*string1); | ||
110 | c2 = tolower((int)*string2); | ||
111 | |||
112 | string1++; | ||
113 | string2++; | ||
114 | } | ||
115 | while ((c1 == c2) && (c1)); | ||
116 | |||
117 | return (c1 - c2); | ||
118 | } | ||
119 | #endif | ||
120 | |||
121 | /******************************************************************************* | ||
122 | * | ||
123 | * FUNCTION: acpi_ut_strupr (strupr) | ||
124 | * | ||
125 | * PARAMETERS: src_string - The source string to convert | ||
126 | * | ||
127 | * RETURN: None | ||
128 | * | ||
129 | * DESCRIPTION: Convert string to uppercase | ||
130 | * | ||
131 | * NOTE: This is not a POSIX function, so it appears here, not in utclib.c | ||
132 | * | ||
133 | ******************************************************************************/ | ||
134 | |||
135 | void acpi_ut_strupr(char *src_string) | ||
136 | { | ||
137 | char *string; | ||
138 | |||
139 | ACPI_FUNCTION_ENTRY(); | ||
140 | |||
141 | if (!src_string) { | ||
142 | return; | ||
143 | } | ||
144 | |||
145 | /* Walk entire string, uppercasing the letters */ | ||
146 | |||
147 | for (string = src_string; *string; string++) { | ||
148 | *string = (char)ACPI_TOUPPER(*string); | ||
149 | } | ||
150 | |||
151 | return; | ||
152 | } | ||
153 | |||
154 | /******************************************************************************* | ||
155 | * | ||
156 | * FUNCTION: acpi_ut_strtoul64 | ||
157 | * | ||
158 | * PARAMETERS: string - Null terminated string | ||
159 | * base - Radix of the string: 16 or ACPI_ANY_BASE; | ||
160 | * ACPI_ANY_BASE means 'in behalf of to_integer' | ||
161 | * ret_integer - Where the converted integer is returned | ||
162 | * | ||
163 | * RETURN: Status and Converted value | ||
164 | * | ||
165 | * DESCRIPTION: Convert a string into an unsigned value. Performs either a | ||
166 | * 32-bit or 64-bit conversion, depending on the current mode | ||
167 | * of the interpreter. | ||
168 | * NOTE: Does not support Octal strings, not needed. | ||
169 | * | ||
170 | ******************************************************************************/ | ||
171 | |||
172 | acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer) | ||
173 | { | ||
174 | u32 this_digit = 0; | ||
175 | u64 return_value = 0; | ||
176 | u64 quotient; | ||
177 | u64 dividend; | ||
178 | u32 to_integer_op = (base == ACPI_ANY_BASE); | ||
179 | u32 mode32 = (acpi_gbl_integer_byte_width == 4); | ||
180 | u8 valid_digits = 0; | ||
181 | u8 sign_of0x = 0; | ||
182 | u8 term = 0; | ||
183 | |||
184 | ACPI_FUNCTION_TRACE_STR(ut_stroul64, string); | ||
185 | |||
186 | switch (base) { | ||
187 | case ACPI_ANY_BASE: | ||
188 | case 16: | ||
189 | break; | ||
190 | |||
191 | default: | ||
192 | /* Invalid Base */ | ||
193 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
194 | } | ||
195 | |||
196 | if (!string) { | ||
197 | goto error_exit; | ||
198 | } | ||
199 | |||
200 | /* Skip over any white space in the buffer */ | ||
201 | |||
202 | while ((*string) && (ACPI_IS_SPACE(*string) || *string == '\t')) { | ||
203 | string++; | ||
204 | } | ||
205 | |||
206 | if (to_integer_op) { | ||
207 | /* | ||
208 | * Base equal to ACPI_ANY_BASE means 'ToInteger operation case'. | ||
209 | * We need to determine if it is decimal or hexadecimal. | ||
210 | */ | ||
211 | if ((*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) { | ||
212 | sign_of0x = 1; | ||
213 | base = 16; | ||
214 | |||
215 | /* Skip over the leading '0x' */ | ||
216 | string += 2; | ||
217 | } else { | ||
218 | base = 10; | ||
219 | } | ||
220 | } | ||
221 | |||
222 | /* Any string left? Check that '0x' is not followed by white space. */ | ||
223 | |||
224 | if (!(*string) || ACPI_IS_SPACE(*string) || *string == '\t') { | ||
225 | if (to_integer_op) { | ||
226 | goto error_exit; | ||
227 | } else { | ||
228 | goto all_done; | ||
229 | } | ||
230 | } | ||
231 | |||
232 | /* | ||
233 | * Perform a 32-bit or 64-bit conversion, depending upon the current | ||
234 | * execution mode of the interpreter | ||
235 | */ | ||
236 | dividend = (mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX; | ||
237 | |||
238 | /* Main loop: convert the string to a 32- or 64-bit integer */ | ||
239 | |||
240 | while (*string) { | ||
241 | if (ACPI_IS_DIGIT(*string)) { | ||
242 | |||
243 | /* Convert ASCII 0-9 to Decimal value */ | ||
244 | |||
245 | this_digit = ((u8)*string) - '0'; | ||
246 | } else if (base == 10) { | ||
247 | |||
248 | /* Digit is out of range; possible in to_integer case only */ | ||
249 | |||
250 | term = 1; | ||
251 | } else { | ||
252 | this_digit = (u8)ACPI_TOUPPER(*string); | ||
253 | if (ACPI_IS_XDIGIT((char)this_digit)) { | ||
254 | |||
255 | /* Convert ASCII Hex char to value */ | ||
256 | |||
257 | this_digit = this_digit - 'A' + 10; | ||
258 | } else { | ||
259 | term = 1; | ||
260 | } | ||
261 | } | ||
262 | |||
263 | if (term) { | ||
264 | if (to_integer_op) { | ||
265 | goto error_exit; | ||
266 | } else { | ||
267 | break; | ||
268 | } | ||
269 | } else if ((valid_digits == 0) && (this_digit == 0) | ||
270 | && !sign_of0x) { | ||
271 | |||
272 | /* Skip zeros */ | ||
273 | string++; | ||
274 | continue; | ||
275 | } | ||
276 | |||
277 | valid_digits++; | ||
278 | |||
279 | if (sign_of0x | ||
280 | && ((valid_digits > 16) | ||
281 | || ((valid_digits > 8) && mode32))) { | ||
282 | /* | ||
283 | * This is to_integer operation case. | ||
284 | * No any restrictions for string-to-integer conversion, | ||
285 | * see ACPI spec. | ||
286 | */ | ||
287 | goto error_exit; | ||
288 | } | ||
289 | |||
290 | /* Divide the digit into the correct position */ | ||
291 | |||
292 | (void)acpi_ut_short_divide((dividend - (u64)this_digit), | ||
293 | base, "ient, NULL); | ||
294 | |||
295 | if (return_value > quotient) { | ||
296 | if (to_integer_op) { | ||
297 | goto error_exit; | ||
298 | } else { | ||
299 | break; | ||
300 | } | ||
301 | } | ||
302 | |||
303 | return_value *= base; | ||
304 | return_value += this_digit; | ||
305 | string++; | ||
306 | } | ||
307 | |||
308 | /* All done, normal exit */ | ||
309 | |||
310 | all_done: | ||
311 | |||
312 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n", | ||
313 | ACPI_FORMAT_UINT64(return_value))); | ||
314 | |||
315 | *ret_integer = return_value; | ||
316 | return_ACPI_STATUS(AE_OK); | ||
317 | |||
318 | error_exit: | ||
319 | /* Base was set/validated above */ | ||
320 | |||
321 | if (base == 10) { | ||
322 | return_ACPI_STATUS(AE_BAD_DECIMAL_CONSTANT); | ||
323 | } else { | ||
324 | return_ACPI_STATUS(AE_BAD_HEX_CONSTANT); | ||
325 | } | ||
326 | } | ||
327 | |||
328 | /******************************************************************************* | ||
329 | * | ||
330 | * FUNCTION: acpi_ut_print_string | ||
331 | * | ||
332 | * PARAMETERS: string - Null terminated ASCII string | ||
333 | * max_length - Maximum output length | ||
334 | * | ||
335 | * RETURN: None | ||
336 | * | ||
337 | * DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape | ||
338 | * sequences. | ||
339 | * | ||
340 | ******************************************************************************/ | ||
341 | |||
342 | void acpi_ut_print_string(char *string, u8 max_length) | ||
343 | { | ||
344 | u32 i; | ||
345 | |||
346 | if (!string) { | ||
347 | acpi_os_printf("<\"NULL STRING PTR\">"); | ||
348 | return; | ||
349 | } | ||
350 | |||
351 | acpi_os_printf("\""); | ||
352 | for (i = 0; string[i] && (i < max_length); i++) { | ||
353 | |||
354 | /* Escape sequences */ | ||
355 | |||
356 | switch (string[i]) { | ||
357 | case 0x07: | ||
358 | acpi_os_printf("\\a"); /* BELL */ | ||
359 | break; | ||
360 | |||
361 | case 0x08: | ||
362 | acpi_os_printf("\\b"); /* BACKSPACE */ | ||
363 | break; | ||
364 | |||
365 | case 0x0C: | ||
366 | acpi_os_printf("\\f"); /* FORMFEED */ | ||
367 | break; | ||
368 | |||
369 | case 0x0A: | ||
370 | acpi_os_printf("\\n"); /* LINEFEED */ | ||
371 | break; | ||
372 | |||
373 | case 0x0D: | ||
374 | acpi_os_printf("\\r"); /* CARRIAGE RETURN */ | ||
375 | break; | ||
376 | |||
377 | case 0x09: | ||
378 | acpi_os_printf("\\t"); /* HORIZONTAL TAB */ | ||
379 | break; | ||
380 | |||
381 | case 0x0B: | ||
382 | acpi_os_printf("\\v"); /* VERTICAL TAB */ | ||
383 | break; | ||
384 | |||
385 | case '\'': /* Single Quote */ | ||
386 | case '\"': /* Double Quote */ | ||
387 | case '\\': /* Backslash */ | ||
388 | acpi_os_printf("\\%c", (int)string[i]); | ||
389 | break; | ||
390 | |||
391 | default: | ||
392 | |||
393 | /* Check for printable character or hex escape */ | ||
394 | |||
395 | if (ACPI_IS_PRINT(string[i])) { | ||
396 | /* This is a normal character */ | ||
397 | |||
398 | acpi_os_printf("%c", (int)string[i]); | ||
399 | } else { | ||
400 | /* All others will be Hex escapes */ | ||
401 | |||
402 | acpi_os_printf("\\x%2.2X", (s32) string[i]); | ||
403 | } | ||
404 | break; | ||
405 | } | ||
406 | } | ||
407 | acpi_os_printf("\""); | ||
408 | |||
409 | if (i == max_length && string[i]) { | ||
410 | acpi_os_printf("..."); | ||
411 | } | ||
412 | } | ||
413 | |||
414 | /******************************************************************************* | ||
415 | * | ||
416 | * FUNCTION: acpi_ut_valid_acpi_char | ||
417 | * | ||
418 | * PARAMETERS: char - The character to be examined | ||
419 | * position - Byte position (0-3) | ||
420 | * | ||
421 | * RETURN: TRUE if the character is valid, FALSE otherwise | ||
422 | * | ||
423 | * DESCRIPTION: Check for a valid ACPI character. Must be one of: | ||
424 | * 1) Upper case alpha | ||
425 | * 2) numeric | ||
426 | * 3) underscore | ||
427 | * | ||
428 | * We allow a '!' as the last character because of the ASF! table | ||
429 | * | ||
430 | ******************************************************************************/ | ||
431 | |||
432 | u8 acpi_ut_valid_acpi_char(char character, u32 position) | ||
433 | { | ||
434 | |||
435 | if (!((character >= 'A' && character <= 'Z') || | ||
436 | (character >= '0' && character <= '9') || (character == '_'))) { | ||
437 | |||
438 | /* Allow a '!' in the last position */ | ||
439 | |||
440 | if (character == '!' && position == 3) { | ||
441 | return (TRUE); | ||
442 | } | ||
443 | |||
444 | return (FALSE); | ||
445 | } | ||
446 | |||
447 | return (TRUE); | ||
448 | } | ||
449 | |||
450 | /******************************************************************************* | ||
451 | * | ||
452 | * FUNCTION: acpi_ut_valid_acpi_name | ||
453 | * | ||
454 | * PARAMETERS: name - The name to be examined | ||
455 | * | ||
456 | * RETURN: TRUE if the name is valid, FALSE otherwise | ||
457 | * | ||
458 | * DESCRIPTION: Check for a valid ACPI name. Each character must be one of: | ||
459 | * 1) Upper case alpha | ||
460 | * 2) numeric | ||
461 | * 3) underscore | ||
462 | * | ||
463 | ******************************************************************************/ | ||
464 | |||
465 | u8 acpi_ut_valid_acpi_name(u32 name) | ||
466 | { | ||
467 | u32 i; | ||
468 | |||
469 | ACPI_FUNCTION_ENTRY(); | ||
470 | |||
471 | for (i = 0; i < ACPI_NAME_SIZE; i++) { | ||
472 | if (!acpi_ut_valid_acpi_char | ||
473 | ((ACPI_CAST_PTR(char, &name))[i], i)) { | ||
474 | return (FALSE); | ||
475 | } | ||
476 | } | ||
477 | |||
478 | return (TRUE); | ||
479 | } | ||
480 | |||
481 | /******************************************************************************* | ||
482 | * | ||
483 | * FUNCTION: acpi_ut_repair_name | ||
484 | * | ||
485 | * PARAMETERS: name - The ACPI name to be repaired | ||
486 | * | ||
487 | * RETURN: Repaired version of the name | ||
488 | * | ||
489 | * DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and | ||
490 | * return the new name. NOTE: the Name parameter must reside in | ||
491 | * read/write memory, cannot be a const. | ||
492 | * | ||
493 | * An ACPI Name must consist of valid ACPI characters. We will repair the name | ||
494 | * if necessary because we don't want to abort because of this, but we want | ||
495 | * all namespace names to be printable. A warning message is appropriate. | ||
496 | * | ||
497 | * This issue came up because there are in fact machines that exhibit | ||
498 | * this problem, and we want to be able to enable ACPI support for them, | ||
499 | * even though there are a few bad names. | ||
500 | * | ||
501 | ******************************************************************************/ | ||
502 | |||
503 | void acpi_ut_repair_name(char *name) | ||
504 | { | ||
505 | u32 i; | ||
506 | u8 found_bad_char = FALSE; | ||
507 | u32 original_name; | ||
508 | |||
509 | ACPI_FUNCTION_NAME(ut_repair_name); | ||
510 | |||
511 | ACPI_MOVE_NAME(&original_name, name); | ||
512 | |||
513 | /* Check each character in the name */ | ||
514 | |||
515 | for (i = 0; i < ACPI_NAME_SIZE; i++) { | ||
516 | if (acpi_ut_valid_acpi_char(name[i], i)) { | ||
517 | continue; | ||
518 | } | ||
519 | |||
520 | /* | ||
521 | * Replace a bad character with something printable, yet technically | ||
522 | * still invalid. This prevents any collisions with existing "good" | ||
523 | * names in the namespace. | ||
524 | */ | ||
525 | name[i] = '*'; | ||
526 | found_bad_char = TRUE; | ||
527 | } | ||
528 | |||
529 | if (found_bad_char) { | ||
530 | |||
531 | /* Report warning only if in strict mode or debug mode */ | ||
532 | |||
533 | if (!acpi_gbl_enable_interpreter_slack) { | ||
534 | ACPI_WARNING((AE_INFO, | ||
535 | "Invalid character(s) in name (0x%.8X), repaired: [%4.4s]", | ||
536 | original_name, name)); | ||
537 | } else { | ||
538 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
539 | "Invalid character(s) in name (0x%.8X), repaired: [%4.4s]", | ||
540 | original_name, name)); | ||
541 | } | ||
542 | } | ||
543 | } | ||
544 | |||
545 | #if defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP | ||
546 | /******************************************************************************* | ||
547 | * | ||
548 | * FUNCTION: ut_convert_backslashes | ||
549 | * | ||
550 | * PARAMETERS: pathname - File pathname string to be converted | ||
551 | * | ||
552 | * RETURN: Modifies the input Pathname | ||
553 | * | ||
554 | * DESCRIPTION: Convert all backslashes (0x5C) to forward slashes (0x2F) within | ||
555 | * the entire input file pathname string. | ||
556 | * | ||
557 | ******************************************************************************/ | ||
558 | |||
559 | void ut_convert_backslashes(char *pathname) | ||
560 | { | ||
561 | |||
562 | if (!pathname) { | ||
563 | return; | ||
564 | } | ||
565 | |||
566 | while (*pathname) { | ||
567 | if (*pathname == '\\') { | ||
568 | *pathname = '/'; | ||
569 | } | ||
570 | |||
571 | pathname++; | ||
572 | } | ||
573 | } | ||
574 | #endif | ||