Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Module Name: nspredef - Validation of ACPI predefined methods and objects |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 4 | * |
| 5 | *****************************************************************************/ |
| 6 | |
| 7 | /* |
Bob Moore | 25f044e | 2013-01-25 05:38:56 +0000 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2013, Intel Corp. |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 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 | |
Bob Moore | 999e08f | 2009-08-13 14:30:16 +0800 | [diff] [blame] | 44 | #define ACPI_CREATE_PREDEFINED_TABLE |
| 45 | |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 46 | #include <acpi/acpi.h> |
Len Brown | e2f7a77 | 2009-01-09 00:30:03 -0500 | [diff] [blame] | 47 | #include "accommon.h" |
| 48 | #include "acnamesp.h" |
| 49 | #include "acpredef.h" |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 50 | |
| 51 | #define _COMPONENT ACPI_NAMESPACE |
| 52 | ACPI_MODULE_NAME("nspredef") |
| 53 | |
| 54 | /******************************************************************************* |
| 55 | * |
| 56 | * This module validates predefined ACPI objects that appear in the namespace, |
| 57 | * at the time they are evaluated (via acpi_evaluate_object). The purpose of this |
| 58 | * validation is to detect problems with BIOS-exposed predefined ACPI objects |
| 59 | * before the results are returned to the ACPI-related drivers. |
| 60 | * |
| 61 | * There are several areas that are validated: |
| 62 | * |
| 63 | * 1) The number of input arguments as defined by the method/object in the |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 64 | * ASL is validated against the ACPI specification. |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 65 | * 2) The type of the return object (if any) is validated against the ACPI |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 66 | * specification. |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 67 | * 3) For returned package objects, the count of package elements is |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 68 | * validated, as well as the type of each package element. Nested |
| 69 | * packages are supported. |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 70 | * |
| 71 | * For any problems found, a warning message is issued. |
| 72 | * |
| 73 | ******************************************************************************/ |
| 74 | /* Local prototypes */ |
| 75 | static acpi_status |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 76 | acpi_ns_check_reference(struct acpi_evaluate_info *info, |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 77 | union acpi_operand_object *return_object); |
| 78 | |
Bob Moore | d5a3610 | 2013-03-08 09:23:03 +0000 | [diff] [blame] | 79 | static u32 acpi_ns_get_bitmapped_type(union acpi_operand_object *return_object); |
| 80 | |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 81 | /******************************************************************************* |
| 82 | * |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 83 | * FUNCTION: acpi_ns_check_return_value |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 84 | * |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 85 | * PARAMETERS: node - Namespace node for the method/object |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 86 | * info - Method execution information block |
Bob Moore | 0444e8f | 2009-06-24 13:38:02 +0800 | [diff] [blame] | 87 | * user_param_count - Number of parameters actually passed |
| 88 | * return_status - Status from the object evaluation |
Bob Moore | a647b5c | 2008-11-14 08:44:39 +0800 | [diff] [blame] | 89 | * return_object_ptr - Pointer to the object returned from the |
| 90 | * evaluation of a method or object |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 91 | * |
| 92 | * RETURN: Status |
| 93 | * |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 94 | * DESCRIPTION: Check the value returned from a predefined name. |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 95 | * |
| 96 | ******************************************************************************/ |
| 97 | |
| 98 | acpi_status |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 99 | acpi_ns_check_return_value(struct acpi_namespace_node *node, |
| 100 | struct acpi_evaluate_info *info, |
| 101 | u32 user_param_count, |
| 102 | acpi_status return_status, |
| 103 | union acpi_operand_object **return_object_ptr) |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 104 | { |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 105 | acpi_status status; |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 106 | const union acpi_predefined_info *predefined; |
Bob Moore | eeb4437 | 2008-11-13 11:19:24 +0800 | [diff] [blame] | 107 | |
| 108 | /* If not a predefined name, we cannot validate the return object */ |
| 109 | |
Bob Moore | 43e5318 | 2013-05-30 10:00:53 +0800 | [diff] [blame] | 110 | predefined = info->predefined; |
Bob Moore | eeb4437 | 2008-11-13 11:19:24 +0800 | [diff] [blame] | 111 | if (!predefined) { |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 112 | return (AE_OK); |
Bob Moore | eeb4437 | 2008-11-13 11:19:24 +0800 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | /* |
Bob Moore | 0444e8f | 2009-06-24 13:38:02 +0800 | [diff] [blame] | 116 | * If the method failed or did not actually return an object, we cannot |
| 117 | * validate the return object |
Bob Moore | eeb4437 | 2008-11-13 11:19:24 +0800 | [diff] [blame] | 118 | */ |
Bob Moore | 0444e8f | 2009-06-24 13:38:02 +0800 | [diff] [blame] | 119 | if ((return_status != AE_OK) && (return_status != AE_CTRL_RETURN_VALUE)) { |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 120 | return (AE_OK); |
Bob Moore | eeb4437 | 2008-11-13 11:19:24 +0800 | [diff] [blame] | 121 | } |
| 122 | |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 123 | /* |
Bob Moore | d57b23a | 2011-07-04 08:24:03 +0000 | [diff] [blame] | 124 | * Return value validation and possible repair. |
Bob Moore | 307a042 | 2009-09-03 09:55:40 +0800 | [diff] [blame] | 125 | * |
Bob Moore | d57b23a | 2011-07-04 08:24:03 +0000 | [diff] [blame] | 126 | * 1) Don't perform return value validation/repair if this feature |
| 127 | * has been disabled via a global option. |
| 128 | * |
| 129 | * 2) We have a return value, but if one wasn't expected, just exit, |
| 130 | * this is not a problem. For example, if the "Implicit Return" |
| 131 | * feature is enabled, methods will always return a value. |
| 132 | * |
| 133 | * 3) If the return value can be of any type, then we cannot perform |
| 134 | * any validation, just exit. |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 135 | */ |
Bob Moore | d57b23a | 2011-07-04 08:24:03 +0000 | [diff] [blame] | 136 | if (acpi_gbl_disable_auto_repair || |
| 137 | (!predefined->info.expected_btypes) || |
Bob Moore | 307a042 | 2009-09-03 09:55:40 +0800 | [diff] [blame] | 138 | (predefined->info.expected_btypes == ACPI_RTYPE_ALL)) { |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 139 | return (AE_OK); |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | /* |
Bob Moore | 465da9e | 2009-12-11 15:26:13 +0800 | [diff] [blame] | 143 | * Check that the type of the main return object is what is expected |
| 144 | * for this predefined name |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 145 | */ |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 146 | status = acpi_ns_check_object_type(info, return_object_ptr, |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 147 | predefined->info.expected_btypes, |
Bob Moore | 0444e8f | 2009-06-24 13:38:02 +0800 | [diff] [blame] | 148 | ACPI_NOT_PACKAGE_ELEMENT); |
Bob Moore | 465da9e | 2009-12-11 15:26:13 +0800 | [diff] [blame] | 149 | if (ACPI_FAILURE(status)) { |
| 150 | goto exit; |
| 151 | } |
| 152 | |
| 153 | /* |
Bob Moore | bf0dd26 | 2013-08-08 15:29:38 +0800 | [diff] [blame] | 154 | * |
| 155 | * 4) If there is no return value and it is optional, just return |
| 156 | * AE_OK (_WAK). |
| 157 | */ |
| 158 | if (!(*return_object_ptr)) { |
| 159 | goto exit; |
| 160 | } |
| 161 | |
| 162 | /* |
Bob Moore | 465da9e | 2009-12-11 15:26:13 +0800 | [diff] [blame] | 163 | * For returned Package objects, check the type of all sub-objects. |
| 164 | * Note: Package may have been newly created by call above. |
| 165 | */ |
| 166 | if ((*return_object_ptr)->common.type == ACPI_TYPE_PACKAGE) { |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 167 | info->parent_package = *return_object_ptr; |
| 168 | status = acpi_ns_check_package(info, return_object_ptr); |
Bob Moore | 465da9e | 2009-12-11 15:26:13 +0800 | [diff] [blame] | 169 | if (ACPI_FAILURE(status)) { |
Lv Zheng | aa6329c | 2013-06-08 09:01:01 +0800 | [diff] [blame] | 170 | |
Lv Zheng | 5a9792f | 2013-06-08 09:01:07 +0800 | [diff] [blame] | 171 | /* We might be able to fix some errors */ |
Lv Zheng | aa6329c | 2013-06-08 09:01:01 +0800 | [diff] [blame] | 172 | |
Lv Zheng | 5a9792f | 2013-06-08 09:01:07 +0800 | [diff] [blame] | 173 | if ((status != AE_AML_OPERAND_TYPE) && |
| 174 | (status != AE_AML_OPERAND_VALUE)) { |
Lv Zheng | aa6329c | 2013-06-08 09:01:01 +0800 | [diff] [blame] | 175 | goto exit; |
| 176 | } |
Bob Moore | 34c39c7 | 2009-12-11 14:53:11 +0800 | [diff] [blame] | 177 | } |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 178 | } |
| 179 | |
Bob Moore | ad5babe | 2009-11-12 09:44:06 +0800 | [diff] [blame] | 180 | /* |
Bob Moore | 465da9e | 2009-12-11 15:26:13 +0800 | [diff] [blame] | 181 | * The return object was OK, or it was successfully repaired above. |
| 182 | * Now make some additional checks such as verifying that package |
| 183 | * objects are sorted correctly (if required) or buffer objects have |
| 184 | * the correct data width (bytes vs. dwords). These repairs are |
| 185 | * performed on a per-name basis, i.e., the code is specific to |
| 186 | * particular predefined names. |
Bob Moore | ad5babe | 2009-11-12 09:44:06 +0800 | [diff] [blame] | 187 | */ |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 188 | status = acpi_ns_complex_repairs(info, node, status, return_object_ptr); |
Bob Moore | ad5babe | 2009-11-12 09:44:06 +0800 | [diff] [blame] | 189 | |
Bob Moore | 465da9e | 2009-12-11 15:26:13 +0800 | [diff] [blame] | 190 | exit: |
Bob Moore | 0444e8f | 2009-06-24 13:38:02 +0800 | [diff] [blame] | 191 | /* |
| 192 | * If the object validation failed or if we successfully repaired one |
| 193 | * or more objects, mark the parent node to suppress further warning |
| 194 | * messages during the next evaluation of the same method/object. |
| 195 | */ |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 196 | if (ACPI_FAILURE(status) || (info->return_flags & ACPI_OBJECT_REPAIRED)) { |
Bob Moore | 0444e8f | 2009-06-24 13:38:02 +0800 | [diff] [blame] | 197 | node->flags |= ANOBJ_EVALUATED; |
| 198 | } |
Bob Moore | 0444e8f | 2009-06-24 13:38:02 +0800 | [diff] [blame] | 199 | |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 200 | return (status); |
| 201 | } |
| 202 | |
| 203 | /******************************************************************************* |
| 204 | * |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 205 | * FUNCTION: acpi_ns_check_object_type |
| 206 | * |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 207 | * PARAMETERS: info - Method execution information block |
Bob Moore | a647b5c | 2008-11-14 08:44:39 +0800 | [diff] [blame] | 208 | * return_object_ptr - Pointer to the object returned from the |
| 209 | * evaluation of a method or object |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 210 | * expected_btypes - Bitmap of expected return type(s) |
| 211 | * package_index - Index of object within parent package (if |
Bob Moore | 0444e8f | 2009-06-24 13:38:02 +0800 | [diff] [blame] | 212 | * applicable - ACPI_NOT_PACKAGE_ELEMENT |
| 213 | * otherwise) |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 214 | * |
| 215 | * RETURN: Status |
| 216 | * |
| 217 | * DESCRIPTION: Check the type of the return object against the expected object |
| 218 | * type(s). Use of Btype allows multiple expected object types. |
| 219 | * |
| 220 | ******************************************************************************/ |
| 221 | |
Bob Moore | 42f8fb7 | 2013-01-11 13:08:51 +0100 | [diff] [blame] | 222 | acpi_status |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 223 | acpi_ns_check_object_type(struct acpi_evaluate_info *info, |
Bob Moore | a647b5c | 2008-11-14 08:44:39 +0800 | [diff] [blame] | 224 | union acpi_operand_object **return_object_ptr, |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 225 | u32 expected_btypes, u32 package_index) |
| 226 | { |
Bob Moore | a647b5c | 2008-11-14 08:44:39 +0800 | [diff] [blame] | 227 | union acpi_operand_object *return_object = *return_object_ptr; |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 228 | acpi_status status = AE_OK; |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 229 | char type_buffer[48]; /* Room for 5 types */ |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 230 | |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 231 | /* A Namespace node should not get here, but make sure */ |
| 232 | |
Bob Moore | d5a3610 | 2013-03-08 09:23:03 +0000 | [diff] [blame] | 233 | if (return_object && |
| 234 | ACPI_GET_DESCRIPTOR_TYPE(return_object) == ACPI_DESC_TYPE_NAMED) { |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 235 | ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, |
| 236 | info->node_flags, |
Bob Moore | 0444e8f | 2009-06-24 13:38:02 +0800 | [diff] [blame] | 237 | "Invalid return type - Found a Namespace node [%4.4s] type %s", |
| 238 | return_object->node.name.ascii, |
| 239 | acpi_ut_get_type_name(return_object->node. |
| 240 | type))); |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 241 | return (AE_AML_OPERAND_TYPE); |
| 242 | } |
| 243 | |
| 244 | /* |
| 245 | * Convert the object type (ACPI_TYPE_xxx) to a bitmapped object type. |
| 246 | * The bitmapped type allows multiple possible return types. |
| 247 | * |
| 248 | * Note, the cases below must handle all of the possible types returned |
| 249 | * from all of the predefined names (including elements of returned |
| 250 | * packages) |
| 251 | */ |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 252 | info->return_btype = acpi_ns_get_bitmapped_type(return_object); |
| 253 | if (info->return_btype == ACPI_RTYPE_ANY) { |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 254 | |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 255 | /* Not one of the supported objects, must be incorrect */ |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 256 | goto type_error_exit; |
| 257 | } |
| 258 | |
Bob Moore | d5a3610 | 2013-03-08 09:23:03 +0000 | [diff] [blame] | 259 | /* For reference objects, check that the reference type is correct */ |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 260 | |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 261 | if ((info->return_btype & expected_btypes) == ACPI_RTYPE_REFERENCE) { |
| 262 | status = acpi_ns_check_reference(info, return_object); |
Bob Moore | 2147d3f | 2010-01-21 09:08:31 +0800 | [diff] [blame] | 263 | return (status); |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 264 | } |
| 265 | |
Bob Moore | d5a3610 | 2013-03-08 09:23:03 +0000 | [diff] [blame] | 266 | /* Attempt simple repair of the returned object if necessary */ |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 267 | |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 268 | status = acpi_ns_simple_repair(info, expected_btypes, |
Bob Moore | 2147d3f | 2010-01-21 09:08:31 +0800 | [diff] [blame] | 269 | package_index, return_object_ptr); |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 270 | if (ACPI_SUCCESS(status)) { |
| 271 | return (AE_OK); /* Successful repair */ |
| 272 | } |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 273 | |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 274 | type_error_exit: |
| 275 | |
| 276 | /* Create a string with all expected types for this predefined object */ |
| 277 | |
Bob Moore | c34c82b | 2013-04-12 00:24:22 +0000 | [diff] [blame] | 278 | acpi_ut_get_expected_return_types(type_buffer, expected_btypes); |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 279 | |
Bob Moore | bf0dd26 | 2013-08-08 15:29:38 +0800 | [diff] [blame] | 280 | if (!return_object) { |
| 281 | ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, |
| 282 | info->node_flags, |
| 283 | "Expected return object of type %s", |
| 284 | type_buffer)); |
| 285 | } else if (package_index == ACPI_NOT_PACKAGE_ELEMENT) { |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 286 | ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, |
| 287 | info->node_flags, |
Bob Moore | 0444e8f | 2009-06-24 13:38:02 +0800 | [diff] [blame] | 288 | "Return type mismatch - found %s, expected %s", |
| 289 | acpi_ut_get_object_type_name |
| 290 | (return_object), type_buffer)); |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 291 | } else { |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 292 | ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, |
| 293 | info->node_flags, |
Bob Moore | 0444e8f | 2009-06-24 13:38:02 +0800 | [diff] [blame] | 294 | "Return Package type mismatch at index %u - " |
| 295 | "found %s, expected %s", package_index, |
| 296 | acpi_ut_get_object_type_name |
| 297 | (return_object), type_buffer)); |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | return (AE_AML_OPERAND_TYPE); |
| 301 | } |
| 302 | |
| 303 | /******************************************************************************* |
| 304 | * |
| 305 | * FUNCTION: acpi_ns_check_reference |
| 306 | * |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 307 | * PARAMETERS: info - Method execution information block |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 308 | * return_object - Object returned from the evaluation of a |
| 309 | * method or object |
| 310 | * |
| 311 | * RETURN: Status |
| 312 | * |
| 313 | * DESCRIPTION: Check a returned reference object for the correct reference |
| 314 | * type. The only reference type that can be returned from a |
| 315 | * predefined method is a named reference. All others are invalid. |
| 316 | * |
| 317 | ******************************************************************************/ |
| 318 | |
| 319 | static acpi_status |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 320 | acpi_ns_check_reference(struct acpi_evaluate_info *info, |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 321 | union acpi_operand_object *return_object) |
| 322 | { |
| 323 | |
| 324 | /* |
| 325 | * Check the reference object for the correct reference type (opcode). |
| 326 | * The only type of reference that can be converted to an union acpi_object is |
| 327 | * a reference to a named object (reference class: NAME) |
| 328 | */ |
| 329 | if (return_object->reference.class == ACPI_REFCLASS_NAME) { |
| 330 | return (AE_OK); |
| 331 | } |
| 332 | |
Bob Moore | 29a241c | 2013-05-30 10:00:01 +0800 | [diff] [blame] | 333 | ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, info->node_flags, |
Bob Moore | 0444e8f | 2009-06-24 13:38:02 +0800 | [diff] [blame] | 334 | "Return type mismatch - unexpected reference object type [%s] %2.2X", |
| 335 | acpi_ut_get_reference_name(return_object), |
| 336 | return_object->reference.class)); |
Bob Moore | e8707b3 | 2008-09-28 15:26:17 +0800 | [diff] [blame] | 337 | |
| 338 | return (AE_AML_OPERAND_TYPE); |
| 339 | } |
Bob Moore | a647b5c | 2008-11-14 08:44:39 +0800 | [diff] [blame] | 340 | |
| 341 | /******************************************************************************* |
| 342 | * |
Bob Moore | d5a3610 | 2013-03-08 09:23:03 +0000 | [diff] [blame] | 343 | * FUNCTION: acpi_ns_get_bitmapped_type |
| 344 | * |
| 345 | * PARAMETERS: return_object - Object returned from method/obj evaluation |
| 346 | * |
| 347 | * RETURN: Object return type. ACPI_RTYPE_ANY indicates that the object |
| 348 | * type is not supported. ACPI_RTYPE_NONE indicates that no |
| 349 | * object was returned (return_object is NULL). |
| 350 | * |
| 351 | * DESCRIPTION: Convert object type into a bitmapped object return type. |
| 352 | * |
| 353 | ******************************************************************************/ |
| 354 | |
| 355 | static u32 acpi_ns_get_bitmapped_type(union acpi_operand_object *return_object) |
| 356 | { |
| 357 | u32 return_btype; |
| 358 | |
| 359 | if (!return_object) { |
| 360 | return (ACPI_RTYPE_NONE); |
| 361 | } |
| 362 | |
| 363 | /* Map acpi_object_type to internal bitmapped type */ |
| 364 | |
| 365 | switch (return_object->common.type) { |
| 366 | case ACPI_TYPE_INTEGER: |
Chao Guan | 1d1ea1b | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 367 | |
Bob Moore | d5a3610 | 2013-03-08 09:23:03 +0000 | [diff] [blame] | 368 | return_btype = ACPI_RTYPE_INTEGER; |
| 369 | break; |
| 370 | |
| 371 | case ACPI_TYPE_BUFFER: |
Chao Guan | 1d1ea1b | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 372 | |
Bob Moore | d5a3610 | 2013-03-08 09:23:03 +0000 | [diff] [blame] | 373 | return_btype = ACPI_RTYPE_BUFFER; |
| 374 | break; |
| 375 | |
| 376 | case ACPI_TYPE_STRING: |
Chao Guan | 1d1ea1b | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 377 | |
Bob Moore | d5a3610 | 2013-03-08 09:23:03 +0000 | [diff] [blame] | 378 | return_btype = ACPI_RTYPE_STRING; |
| 379 | break; |
| 380 | |
| 381 | case ACPI_TYPE_PACKAGE: |
Chao Guan | 1d1ea1b | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 382 | |
Bob Moore | d5a3610 | 2013-03-08 09:23:03 +0000 | [diff] [blame] | 383 | return_btype = ACPI_RTYPE_PACKAGE; |
| 384 | break; |
| 385 | |
| 386 | case ACPI_TYPE_LOCAL_REFERENCE: |
Chao Guan | 1d1ea1b | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 387 | |
Bob Moore | d5a3610 | 2013-03-08 09:23:03 +0000 | [diff] [blame] | 388 | return_btype = ACPI_RTYPE_REFERENCE; |
| 389 | break; |
| 390 | |
| 391 | default: |
Chao Guan | 1d1ea1b | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 392 | |
Bob Moore | d5a3610 | 2013-03-08 09:23:03 +0000 | [diff] [blame] | 393 | /* Not one of the supported objects, must be incorrect */ |
| 394 | |
| 395 | return_btype = ACPI_RTYPE_ANY; |
| 396 | break; |
| 397 | } |
| 398 | |
| 399 | return (return_btype); |
| 400 | } |