Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * |
| 3 | * Module Name: utmisc - common utility procedures |
| 4 | * |
| 5 | ******************************************************************************/ |
| 6 | |
| 7 | /* |
Bob Moore | 6c9deb7 | 2007-02-02 19:48:24 +0300 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2007, R. Byron Moore |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [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 | |
Thomas Renninger | be63c92 | 2006-06-02 15:58:00 -0400 | [diff] [blame] | 44 | #include <linux/module.h> |
| 45 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | #include <acpi/acpi.h> |
| 47 | #include <acpi/acnamesp.h> |
| 48 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | #define _COMPONENT ACPI_UTILITIES |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 50 | ACPI_MODULE_NAME("utmisc") |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 51 | |
| 52 | /******************************************************************************* |
| 53 | * |
Bob Moore | 84fb2c9 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 54 | * FUNCTION: acpi_ut_validate_exception |
| 55 | * |
| 56 | * PARAMETERS: Status - The acpi_status code to be formatted |
| 57 | * |
| 58 | * RETURN: A string containing the exception text. NULL if exception is |
| 59 | * not valid. |
| 60 | * |
| 61 | * DESCRIPTION: This function validates and translates an ACPI exception into |
| 62 | * an ASCII string. |
| 63 | * |
| 64 | ******************************************************************************/ |
| 65 | const char *acpi_ut_validate_exception(acpi_status status) |
| 66 | { |
| 67 | acpi_status sub_status; |
| 68 | const char *exception = NULL; |
| 69 | |
| 70 | ACPI_FUNCTION_ENTRY(); |
| 71 | |
| 72 | /* |
| 73 | * Status is composed of two parts, a "type" and an actual code |
| 74 | */ |
| 75 | sub_status = (status & ~AE_CODE_MASK); |
| 76 | |
| 77 | switch (status & AE_CODE_MASK) { |
| 78 | case AE_CODE_ENVIRONMENTAL: |
| 79 | |
| 80 | if (sub_status <= AE_CODE_ENV_MAX) { |
| 81 | exception = acpi_gbl_exception_names_env[sub_status]; |
| 82 | } |
| 83 | break; |
| 84 | |
| 85 | case AE_CODE_PROGRAMMER: |
| 86 | |
| 87 | if (sub_status <= AE_CODE_PGM_MAX) { |
| 88 | exception = |
| 89 | acpi_gbl_exception_names_pgm[sub_status - 1]; |
| 90 | } |
| 91 | break; |
| 92 | |
| 93 | case AE_CODE_ACPI_TABLES: |
| 94 | |
| 95 | if (sub_status <= AE_CODE_TBL_MAX) { |
| 96 | exception = |
| 97 | acpi_gbl_exception_names_tbl[sub_status - 1]; |
| 98 | } |
| 99 | break; |
| 100 | |
| 101 | case AE_CODE_AML: |
| 102 | |
| 103 | if (sub_status <= AE_CODE_AML_MAX) { |
| 104 | exception = |
| 105 | acpi_gbl_exception_names_aml[sub_status - 1]; |
| 106 | } |
| 107 | break; |
| 108 | |
| 109 | case AE_CODE_CONTROL: |
| 110 | |
| 111 | if (sub_status <= AE_CODE_CTRL_MAX) { |
| 112 | exception = |
| 113 | acpi_gbl_exception_names_ctrl[sub_status - 1]; |
| 114 | } |
| 115 | break; |
| 116 | |
| 117 | default: |
| 118 | break; |
| 119 | } |
| 120 | |
| 121 | return (ACPI_CAST_PTR(const char, exception)); |
| 122 | } |
| 123 | |
| 124 | /******************************************************************************* |
| 125 | * |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 126 | * FUNCTION: acpi_ut_is_aml_table |
| 127 | * |
| 128 | * PARAMETERS: Table - An ACPI table |
| 129 | * |
| 130 | * RETURN: TRUE if table contains executable AML; FALSE otherwise |
| 131 | * |
| 132 | * DESCRIPTION: Check ACPI Signature for a table that contains AML code. |
| 133 | * Currently, these are DSDT,SSDT,PSDT. All other table types are |
| 134 | * data tables that do not contain AML code. |
| 135 | * |
| 136 | ******************************************************************************/ |
Bob Moore | 84fb2c9 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 137 | |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 138 | u8 acpi_ut_is_aml_table(struct acpi_table_header *table) |
| 139 | { |
| 140 | |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 141 | /* These are the only tables that contain executable AML */ |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 142 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 143 | if (ACPI_COMPARE_NAME(table->signature, ACPI_SIG_DSDT) || |
| 144 | ACPI_COMPARE_NAME(table->signature, ACPI_SIG_PSDT) || |
| 145 | ACPI_COMPARE_NAME(table->signature, ACPI_SIG_SSDT)) { |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 146 | return (TRUE); |
| 147 | } |
| 148 | |
| 149 | return (FALSE); |
| 150 | } |
| 151 | |
| 152 | /******************************************************************************* |
| 153 | * |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 154 | * FUNCTION: acpi_ut_allocate_owner_id |
| 155 | * |
| 156 | * PARAMETERS: owner_id - Where the new owner ID is returned |
| 157 | * |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 158 | * RETURN: Status |
| 159 | * |
| 160 | * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to |
| 161 | * track objects created by the table or method, to be deleted |
| 162 | * when the method exits or the table is unloaded. |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 163 | * |
| 164 | ******************************************************************************/ |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 165 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 166 | acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 167 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 168 | acpi_native_uint i; |
Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 169 | acpi_native_uint j; |
Bob Moore | 28f55eb | 2005-12-02 18:27:00 -0500 | [diff] [blame] | 170 | acpi_native_uint k; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 171 | acpi_status status; |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 172 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 173 | ACPI_FUNCTION_TRACE(ut_allocate_owner_id); |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 174 | |
Robert Moore | aff8c27 | 2005-09-02 17:24:17 -0400 | [diff] [blame] | 175 | /* Guard against multiple allocations of ID to the same location */ |
| 176 | |
| 177 | if (*owner_id) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 178 | ACPI_ERROR((AE_INFO, "Owner ID [%2.2X] already exists", |
| 179 | *owner_id)); |
Robert Moore | aff8c27 | 2005-09-02 17:24:17 -0400 | [diff] [blame] | 180 | return_ACPI_STATUS(AE_ALREADY_EXISTS); |
| 181 | } |
| 182 | |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 183 | /* Mutex for the global ID mask */ |
| 184 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 185 | status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); |
| 186 | if (ACPI_FAILURE(status)) { |
| 187 | return_ACPI_STATUS(status); |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 188 | } |
| 189 | |
Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 190 | /* |
| 191 | * Find a free owner ID, cycle through all possible IDs on repeated |
Bob Moore | 28f55eb | 2005-12-02 18:27:00 -0500 | [diff] [blame] | 192 | * allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index may have |
| 193 | * to be scanned twice. |
Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 194 | */ |
Bob Moore | 28f55eb | 2005-12-02 18:27:00 -0500 | [diff] [blame] | 195 | for (i = 0, j = acpi_gbl_last_owner_id_index; |
| 196 | i < (ACPI_NUM_OWNERID_MASKS + 1); i++, j++) { |
| 197 | if (j >= ACPI_NUM_OWNERID_MASKS) { |
| 198 | j = 0; /* Wraparound to start of mask array */ |
Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 199 | } |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 200 | |
Bob Moore | 28f55eb | 2005-12-02 18:27:00 -0500 | [diff] [blame] | 201 | for (k = acpi_gbl_next_owner_id_offset; k < 32; k++) { |
| 202 | if (acpi_gbl_owner_id_mask[j] == ACPI_UINT32_MAX) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 203 | |
Bob Moore | 28f55eb | 2005-12-02 18:27:00 -0500 | [diff] [blame] | 204 | /* There are no free IDs in this mask */ |
Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 205 | |
Bob Moore | 28f55eb | 2005-12-02 18:27:00 -0500 | [diff] [blame] | 206 | break; |
| 207 | } |
Bob Moore | a18ecf4 | 2005-08-15 03:42:00 -0800 | [diff] [blame] | 208 | |
Bob Moore | 28f55eb | 2005-12-02 18:27:00 -0500 | [diff] [blame] | 209 | if (!(acpi_gbl_owner_id_mask[j] & (1 << k))) { |
| 210 | /* |
| 211 | * Found a free ID. The actual ID is the bit index plus one, |
| 212 | * making zero an invalid Owner ID. Save this as the last ID |
| 213 | * allocated and update the global ID mask. |
| 214 | */ |
| 215 | acpi_gbl_owner_id_mask[j] |= (1 << k); |
| 216 | |
| 217 | acpi_gbl_last_owner_id_index = (u8) j; |
| 218 | acpi_gbl_next_owner_id_offset = (u8) (k + 1); |
| 219 | |
| 220 | /* |
| 221 | * Construct encoded ID from the index and bit position |
| 222 | * |
| 223 | * Note: Last [j].k (bit 255) is never used and is marked |
| 224 | * permanently allocated (prevents +1 overflow) |
| 225 | */ |
| 226 | *owner_id = |
| 227 | (acpi_owner_id) ((k + 1) + ACPI_MUL_32(j)); |
| 228 | |
| 229 | ACPI_DEBUG_PRINT((ACPI_DB_VALUES, |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 230 | "Allocated OwnerId: %2.2X\n", |
Bob Moore | 28f55eb | 2005-12-02 18:27:00 -0500 | [diff] [blame] | 231 | (unsigned int)*owner_id)); |
| 232 | goto exit; |
| 233 | } |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 234 | } |
Bob Moore | 28f55eb | 2005-12-02 18:27:00 -0500 | [diff] [blame] | 235 | |
| 236 | acpi_gbl_next_owner_id_offset = 0; |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | /* |
Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 240 | * All owner_ids have been allocated. This typically should |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 241 | * not happen since the IDs are reused after deallocation. The IDs are |
| 242 | * allocated upon table load (one per table) and method execution, and |
| 243 | * they are released when a table is unloaded or a method completes |
| 244 | * execution. |
Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 245 | * |
| 246 | * If this error happens, there may be very deep nesting of invoked control |
| 247 | * methods, or there may be a bug where the IDs are not released. |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 248 | */ |
| 249 | status = AE_OWNER_ID_LIMIT; |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 250 | ACPI_ERROR((AE_INFO, |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 251 | "Could not allocate new OwnerId (255 max), AE_OWNER_ID_LIMIT")); |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 252 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 253 | exit: |
| 254 | (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); |
| 255 | return_ACPI_STATUS(status); |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 256 | } |
| 257 | |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 258 | /******************************************************************************* |
| 259 | * |
| 260 | * FUNCTION: acpi_ut_release_owner_id |
| 261 | * |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 262 | * PARAMETERS: owner_id_ptr - Pointer to a previously allocated owner_iD |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 263 | * |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 264 | * RETURN: None. No error is returned because we are either exiting a |
| 265 | * control method or unloading a table. Either way, we would |
| 266 | * ignore any error anyway. |
| 267 | * |
Bob Moore | 28f55eb | 2005-12-02 18:27:00 -0500 | [diff] [blame] | 268 | * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 255 |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 269 | * |
| 270 | ******************************************************************************/ |
| 271 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 272 | void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr) |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 273 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 274 | acpi_owner_id owner_id = *owner_id_ptr; |
| 275 | acpi_status status; |
Bob Moore | 28f55eb | 2005-12-02 18:27:00 -0500 | [diff] [blame] | 276 | acpi_native_uint index; |
| 277 | u32 bit; |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 278 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 279 | ACPI_FUNCTION_TRACE_U32(ut_release_owner_id, owner_id); |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 280 | |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 281 | /* Always clear the input owner_id (zero is an invalid ID) */ |
| 282 | |
| 283 | *owner_id_ptr = 0; |
| 284 | |
| 285 | /* Zero is not a valid owner_iD */ |
| 286 | |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 287 | if (owner_id == 0) { |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 288 | ACPI_ERROR((AE_INFO, "Invalid OwnerId: %2.2X", owner_id)); |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 289 | return_VOID; |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 290 | } |
| 291 | |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 292 | /* Mutex for the global ID mask */ |
| 293 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 294 | status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); |
| 295 | if (ACPI_FAILURE(status)) { |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 296 | return_VOID; |
| 297 | } |
| 298 | |
Robert Moore | aff8c27 | 2005-09-02 17:24:17 -0400 | [diff] [blame] | 299 | /* Normalize the ID to zero */ |
| 300 | |
| 301 | owner_id--; |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 302 | |
Bob Moore | 28f55eb | 2005-12-02 18:27:00 -0500 | [diff] [blame] | 303 | /* Decode ID to index/offset pair */ |
| 304 | |
| 305 | index = ACPI_DIV_32(owner_id); |
| 306 | bit = 1 << ACPI_MOD_32(owner_id); |
| 307 | |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 308 | /* Free the owner ID only if it is valid */ |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 309 | |
Bob Moore | 28f55eb | 2005-12-02 18:27:00 -0500 | [diff] [blame] | 310 | if (acpi_gbl_owner_id_mask[index] & bit) { |
| 311 | acpi_gbl_owner_id_mask[index] ^= bit; |
| 312 | } else { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 313 | ACPI_ERROR((AE_INFO, |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 314 | "Release of non-allocated OwnerId: %2.2X", |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 315 | owner_id + 1)); |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 316 | } |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 317 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 318 | (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 319 | return_VOID; |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 320 | } |
| 321 | |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 322 | /******************************************************************************* |
| 323 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 324 | * FUNCTION: acpi_ut_strupr (strupr) |
| 325 | * |
| 326 | * PARAMETERS: src_string - The source string to convert |
| 327 | * |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 328 | * RETURN: None |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 329 | * |
| 330 | * DESCRIPTION: Convert string to uppercase |
| 331 | * |
| 332 | * NOTE: This is not a POSIX function, so it appears here, not in utclib.c |
| 333 | * |
| 334 | ******************************************************************************/ |
| 335 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 336 | void acpi_ut_strupr(char *src_string) |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 337 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 338 | char *string; |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 339 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 340 | ACPI_FUNCTION_ENTRY(); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 341 | |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 342 | if (!src_string) { |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 343 | return; |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 344 | } |
| 345 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 346 | /* Walk entire string, uppercasing the letters */ |
| 347 | |
| 348 | for (string = src_string; *string; string++) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 349 | *string = (char)ACPI_TOUPPER(*string); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 350 | } |
| 351 | |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 352 | return; |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 353 | } |
| 354 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | /******************************************************************************* |
| 356 | * |
| 357 | * FUNCTION: acpi_ut_print_string |
| 358 | * |
| 359 | * PARAMETERS: String - Null terminated ASCII string |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 360 | * max_length - Maximum output length |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | * |
| 362 | * RETURN: None |
| 363 | * |
| 364 | * DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape |
| 365 | * sequences. |
| 366 | * |
| 367 | ******************************************************************************/ |
| 368 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 369 | void acpi_ut_print_string(char *string, u8 max_length) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 371 | u32 i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | |
| 373 | if (!string) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 374 | acpi_os_printf("<\"NULL STRING PTR\">"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | return; |
| 376 | } |
| 377 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 378 | acpi_os_printf("\""); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | for (i = 0; string[i] && (i < max_length); i++) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 380 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | /* Escape sequences */ |
| 382 | |
| 383 | switch (string[i]) { |
| 384 | case 0x07: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 385 | acpi_os_printf("\\a"); /* BELL */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | break; |
| 387 | |
| 388 | case 0x08: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 389 | acpi_os_printf("\\b"); /* BACKSPACE */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | break; |
| 391 | |
| 392 | case 0x0C: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 393 | acpi_os_printf("\\f"); /* FORMFEED */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | break; |
| 395 | |
| 396 | case 0x0A: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 397 | acpi_os_printf("\\n"); /* LINEFEED */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | break; |
| 399 | |
| 400 | case 0x0D: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 401 | acpi_os_printf("\\r"); /* CARRIAGE RETURN */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | break; |
| 403 | |
| 404 | case 0x09: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 405 | acpi_os_printf("\\t"); /* HORIZONTAL TAB */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | break; |
| 407 | |
| 408 | case 0x0B: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 409 | acpi_os_printf("\\v"); /* VERTICAL TAB */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | break; |
| 411 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 412 | case '\'': /* Single Quote */ |
| 413 | case '\"': /* Double Quote */ |
| 414 | case '\\': /* Backslash */ |
| 415 | acpi_os_printf("\\%c", (int)string[i]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | break; |
| 417 | |
| 418 | default: |
| 419 | |
| 420 | /* Check for printable character or hex escape */ |
| 421 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 422 | if (ACPI_IS_PRINT(string[i])) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | /* This is a normal character */ |
| 424 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 425 | acpi_os_printf("%c", (int)string[i]); |
| 426 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | /* All others will be Hex escapes */ |
| 428 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 429 | acpi_os_printf("\\x%2.2X", (s32) string[i]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | } |
| 431 | break; |
| 432 | } |
| 433 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 434 | acpi_os_printf("\""); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | |
| 436 | if (i == max_length && string[i]) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 437 | acpi_os_printf("..."); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | } |
| 439 | } |
| 440 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | /******************************************************************************* |
| 442 | * |
| 443 | * FUNCTION: acpi_ut_dword_byte_swap |
| 444 | * |
| 445 | * PARAMETERS: Value - Value to be converted |
| 446 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 447 | * RETURN: u32 integer with bytes swapped |
| 448 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes) |
| 450 | * |
| 451 | ******************************************************************************/ |
| 452 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 453 | u32 acpi_ut_dword_byte_swap(u32 value) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | { |
| 455 | union { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 456 | u32 value; |
| 457 | u8 bytes[4]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | } out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | union { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 460 | u32 value; |
| 461 | u8 bytes[4]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | } in; |
| 463 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 464 | ACPI_FUNCTION_ENTRY(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | |
| 466 | in.value = value; |
| 467 | |
| 468 | out.bytes[0] = in.bytes[3]; |
| 469 | out.bytes[1] = in.bytes[2]; |
| 470 | out.bytes[2] = in.bytes[1]; |
| 471 | out.bytes[3] = in.bytes[0]; |
| 472 | |
| 473 | return (out.value); |
| 474 | } |
| 475 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | /******************************************************************************* |
| 477 | * |
| 478 | * FUNCTION: acpi_ut_set_integer_width |
| 479 | * |
| 480 | * PARAMETERS: Revision From DSDT header |
| 481 | * |
| 482 | * RETURN: None |
| 483 | * |
| 484 | * DESCRIPTION: Set the global integer bit width based upon the revision |
| 485 | * of the DSDT. For Revision 1 and 0, Integers are 32 bits. |
| 486 | * For Revision 2 and above, Integers are 64 bits. Yes, this |
| 487 | * makes a difference. |
| 488 | * |
| 489 | ******************************************************************************/ |
| 490 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 491 | void acpi_ut_set_integer_width(u8 revision) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | { |
| 493 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 494 | if (revision < 2) { |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 495 | |
| 496 | /* 32-bit case */ |
| 497 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | acpi_gbl_integer_bit_width = 32; |
| 499 | acpi_gbl_integer_nybble_width = 8; |
| 500 | acpi_gbl_integer_byte_width = 4; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 501 | } else { |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 502 | /* 64-bit case (ACPI 2.0+) */ |
| 503 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 504 | acpi_gbl_integer_bit_width = 64; |
| 505 | acpi_gbl_integer_nybble_width = 16; |
| 506 | acpi_gbl_integer_byte_width = 8; |
| 507 | } |
| 508 | } |
| 509 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | #ifdef ACPI_DEBUG_OUTPUT |
| 511 | /******************************************************************************* |
| 512 | * |
| 513 | * FUNCTION: acpi_ut_display_init_pathname |
| 514 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 515 | * PARAMETERS: Type - Object type of the node |
| 516 | * obj_handle - Handle whose pathname will be displayed |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 517 | * Path - Additional path string to be appended. |
| 518 | * (NULL if no extra path) |
| 519 | * |
| 520 | * RETURN: acpi_status |
| 521 | * |
| 522 | * DESCRIPTION: Display full pathname of an object, DEBUG ONLY |
| 523 | * |
| 524 | ******************************************************************************/ |
| 525 | |
| 526 | void |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 527 | acpi_ut_display_init_pathname(u8 type, |
| 528 | struct acpi_namespace_node *obj_handle, |
| 529 | char *path) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 530 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 531 | acpi_status status; |
| 532 | struct acpi_buffer buffer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 534 | ACPI_FUNCTION_ENTRY(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 535 | |
| 536 | /* Only print the path if the appropriate debug level is enabled */ |
| 537 | |
| 538 | if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) { |
| 539 | return; |
| 540 | } |
| 541 | |
| 542 | /* Get the full pathname to the node */ |
| 543 | |
| 544 | buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 545 | status = acpi_ns_handle_to_pathname(obj_handle, &buffer); |
| 546 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | return; |
| 548 | } |
| 549 | |
| 550 | /* Print what we're doing */ |
| 551 | |
| 552 | switch (type) { |
| 553 | case ACPI_TYPE_METHOD: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 554 | acpi_os_printf("Executing "); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | break; |
| 556 | |
| 557 | default: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 558 | acpi_os_printf("Initializing "); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | break; |
| 560 | } |
| 561 | |
| 562 | /* Print the object type and pathname */ |
| 563 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 564 | acpi_os_printf("%-12s %s", |
| 565 | acpi_ut_get_type_name(type), (char *)buffer.pointer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 566 | |
| 567 | /* Extra path is used to append names like _STA, _INI, etc. */ |
| 568 | |
| 569 | if (path) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 570 | acpi_os_printf(".%s", path); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 572 | acpi_os_printf("\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 574 | ACPI_FREE(buffer.pointer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | } |
| 576 | #endif |
| 577 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 578 | /******************************************************************************* |
| 579 | * |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 580 | * FUNCTION: acpi_ut_valid_acpi_char |
| 581 | * |
| 582 | * PARAMETERS: Char - The character to be examined |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 583 | * Position - Byte position (0-3) |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 584 | * |
| 585 | * RETURN: TRUE if the character is valid, FALSE otherwise |
| 586 | * |
| 587 | * DESCRIPTION: Check for a valid ACPI character. Must be one of: |
| 588 | * 1) Upper case alpha |
| 589 | * 2) numeric |
| 590 | * 3) underscore |
| 591 | * |
| 592 | * We allow a '!' as the last character because of the ASF! table |
| 593 | * |
| 594 | ******************************************************************************/ |
| 595 | |
| 596 | u8 acpi_ut_valid_acpi_char(char character, acpi_native_uint position) |
| 597 | { |
| 598 | |
| 599 | if (!((character >= 'A' && character <= 'Z') || |
| 600 | (character >= '0' && character <= '9') || (character == '_'))) { |
| 601 | |
| 602 | /* Allow a '!' in the last position */ |
| 603 | |
| 604 | if (character == '!' && position == 3) { |
| 605 | return (TRUE); |
| 606 | } |
| 607 | |
| 608 | return (FALSE); |
| 609 | } |
| 610 | |
| 611 | return (TRUE); |
| 612 | } |
| 613 | |
| 614 | /******************************************************************************* |
| 615 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | * FUNCTION: acpi_ut_valid_acpi_name |
| 617 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 618 | * PARAMETERS: Name - The name to be examined |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 620 | * RETURN: TRUE if the name is valid, FALSE otherwise |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | * |
| 622 | * DESCRIPTION: Check for a valid ACPI name. Each character must be one of: |
| 623 | * 1) Upper case alpha |
| 624 | * 2) numeric |
| 625 | * 3) underscore |
| 626 | * |
| 627 | ******************************************************************************/ |
| 628 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 629 | u8 acpi_ut_valid_acpi_name(u32 name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 631 | acpi_native_uint i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 633 | ACPI_FUNCTION_ENTRY(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | |
| 635 | for (i = 0; i < ACPI_NAME_SIZE; i++) { |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 636 | if (!acpi_ut_valid_acpi_char |
| 637 | ((ACPI_CAST_PTR(char, &name))[i], i)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 638 | return (FALSE); |
| 639 | } |
| 640 | } |
| 641 | |
| 642 | return (TRUE); |
| 643 | } |
| 644 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | /******************************************************************************* |
| 646 | * |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 647 | * FUNCTION: acpi_ut_repair_name |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 648 | * |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 649 | * PARAMETERS: Name - The ACPI name to be repaired |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 650 | * |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 651 | * RETURN: Repaired version of the name |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 652 | * |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 653 | * DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and |
| 654 | * return the new name. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | * |
| 656 | ******************************************************************************/ |
| 657 | |
Bob Moore | 3d81b23 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 658 | acpi_name acpi_ut_repair_name(char *name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | { |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 660 | acpi_native_uint i; |
Bob Moore | 3d81b23 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 661 | char new_name[ACPI_NAME_SIZE]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 663 | for (i = 0; i < ACPI_NAME_SIZE; i++) { |
Bob Moore | 3d81b23 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 664 | new_name[i] = name[i]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 666 | /* |
| 667 | * Replace a bad character with something printable, yet technically |
| 668 | * still invalid. This prevents any collisions with existing "good" |
| 669 | * names in the namespace. |
| 670 | */ |
Bob Moore | 3d81b23 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 671 | if (!acpi_ut_valid_acpi_char(name[i], i)) { |
Bob Moore | 793c238 | 2006-03-31 00:00:00 -0500 | [diff] [blame] | 672 | new_name[i] = '*'; |
| 673 | } |
| 674 | } |
| 675 | |
Bob Moore | 3d81b23 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 676 | return (*(u32 *) new_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 677 | } |
| 678 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | /******************************************************************************* |
| 680 | * |
| 681 | * FUNCTION: acpi_ut_strtoul64 |
| 682 | * |
| 683 | * PARAMETERS: String - Null terminated string |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 684 | * Base - Radix of the string: 16 or ACPI_ANY_BASE; |
| 685 | * ACPI_ANY_BASE means 'in behalf of to_integer' |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | * ret_integer - Where the converted integer is returned |
| 687 | * |
| 688 | * RETURN: Status and Converted value |
| 689 | * |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 690 | * DESCRIPTION: Convert a string into an unsigned value. Performs either a |
| 691 | * 32-bit or 64-bit conversion, depending on the current mode |
| 692 | * of the interpreter. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | * NOTE: Does not support Octal strings, not needed. |
| 694 | * |
| 695 | ******************************************************************************/ |
| 696 | |
| 697 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 698 | acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 700 | u32 this_digit = 0; |
| 701 | acpi_integer return_value = 0; |
| 702 | acpi_integer quotient; |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 703 | acpi_integer dividend; |
| 704 | u32 to_integer_op = (base == ACPI_ANY_BASE); |
| 705 | u32 mode32 = (acpi_gbl_integer_byte_width == 4); |
| 706 | u8 valid_digits = 0; |
| 707 | u8 sign_of0x = 0; |
| 708 | u8 term = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 710 | ACPI_FUNCTION_TRACE_STR(ut_stroul64, string); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 711 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 712 | switch (base) { |
| 713 | case ACPI_ANY_BASE: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 714 | case 16: |
| 715 | break; |
| 716 | |
| 717 | default: |
| 718 | /* Invalid Base */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 719 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 720 | } |
| 721 | |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 722 | if (!string) { |
| 723 | goto error_exit; |
| 724 | } |
| 725 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 726 | /* Skip over any white space in the buffer */ |
| 727 | |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 728 | while ((*string) && (ACPI_IS_SPACE(*string) || *string == '\t')) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 729 | string++; |
| 730 | } |
| 731 | |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 732 | if (to_integer_op) { |
| 733 | /* |
| 734 | * Base equal to ACPI_ANY_BASE means 'to_integer operation case'. |
| 735 | * We need to determine if it is decimal or hexadecimal. |
| 736 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 737 | if ((*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) { |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 738 | sign_of0x = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 739 | base = 16; |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 740 | |
| 741 | /* Skip over the leading '0x' */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 742 | string += 2; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 743 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 744 | base = 10; |
| 745 | } |
| 746 | } |
| 747 | |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 748 | /* Any string left? Check that '0x' is not followed by white space. */ |
| 749 | |
| 750 | if (!(*string) || ACPI_IS_SPACE(*string) || *string == '\t') { |
| 751 | if (to_integer_op) { |
| 752 | goto error_exit; |
| 753 | } else { |
| 754 | goto all_done; |
| 755 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 756 | } |
| 757 | |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 758 | /* |
| 759 | * Perform a 32-bit or 64-bit conversion, depending upon the current |
| 760 | * execution mode of the interpreter |
| 761 | */ |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 762 | dividend = (mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 763 | |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 764 | /* Main loop: convert the string to a 32- or 64-bit integer */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 765 | |
| 766 | while (*string) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 767 | if (ACPI_IS_DIGIT(*string)) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 768 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 769 | /* Convert ASCII 0-9 to Decimal value */ |
| 770 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 771 | this_digit = ((u8) * string) - '0'; |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 772 | } else if (base == 10) { |
| 773 | |
| 774 | /* Digit is out of range; possible in to_integer case only */ |
| 775 | |
| 776 | term = 1; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 777 | } else { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 778 | this_digit = (u8) ACPI_TOUPPER(*string); |
| 779 | if (ACPI_IS_XDIGIT((char)this_digit)) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 780 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 781 | /* Convert ASCII Hex char to value */ |
| 782 | |
| 783 | this_digit = this_digit - 'A' + 10; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 784 | } else { |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 785 | term = 1; |
| 786 | } |
| 787 | } |
| 788 | |
| 789 | if (term) { |
| 790 | if (to_integer_op) { |
| 791 | goto error_exit; |
| 792 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 793 | break; |
| 794 | } |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 795 | } else if ((valid_digits == 0) && (this_digit == 0) |
| 796 | && !sign_of0x) { |
| 797 | |
| 798 | /* Skip zeros */ |
| 799 | string++; |
| 800 | continue; |
| 801 | } |
| 802 | |
| 803 | valid_digits++; |
| 804 | |
Len Brown | fd35094 | 2007-05-09 23:34:35 -0400 | [diff] [blame] | 805 | if (sign_of0x && ((valid_digits > 16) |
| 806 | || ((valid_digits > 8) && mode32))) { |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 807 | /* |
| 808 | * This is to_integer operation case. |
| 809 | * No any restrictions for string-to-integer conversion, |
| 810 | * see ACPI spec. |
| 811 | */ |
| 812 | goto error_exit; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 813 | } |
| 814 | |
| 815 | /* Divide the digit into the correct position */ |
| 816 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 817 | (void) |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 818 | acpi_ut_short_divide((dividend - (acpi_integer) this_digit), |
| 819 | base, "ient, NULL); |
| 820 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 821 | if (return_value > quotient) { |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 822 | if (to_integer_op) { |
| 823 | goto error_exit; |
| 824 | } else { |
| 825 | break; |
| 826 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 827 | } |
| 828 | |
| 829 | return_value *= base; |
| 830 | return_value += this_digit; |
| 831 | string++; |
| 832 | } |
| 833 | |
| 834 | /* All done, normal exit */ |
| 835 | |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 836 | all_done: |
| 837 | |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 838 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n", |
| 839 | ACPI_FORMAT_UINT64(return_value))); |
| 840 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 841 | *ret_integer = return_value; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 842 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 843 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 844 | error_exit: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 845 | /* Base was set/validated above */ |
| 846 | |
| 847 | if (base == 10) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 848 | return_ACPI_STATUS(AE_BAD_DECIMAL_CONSTANT); |
| 849 | } else { |
| 850 | return_ACPI_STATUS(AE_BAD_HEX_CONSTANT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 851 | } |
| 852 | } |
| 853 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 854 | /******************************************************************************* |
| 855 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 856 | * FUNCTION: acpi_ut_create_update_state_and_push |
| 857 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 858 | * PARAMETERS: Object - Object to be added to the new state |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 859 | * Action - Increment/Decrement |
| 860 | * state_list - List the state will be added to |
| 861 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 862 | * RETURN: Status |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 863 | * |
| 864 | * DESCRIPTION: Create a new state and push it |
| 865 | * |
| 866 | ******************************************************************************/ |
| 867 | |
| 868 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 869 | acpi_ut_create_update_state_and_push(union acpi_operand_object *object, |
| 870 | u16 action, |
| 871 | union acpi_generic_state **state_list) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 872 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 873 | union acpi_generic_state *state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 874 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 875 | ACPI_FUNCTION_ENTRY(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 876 | |
| 877 | /* Ignore null objects; these are expected */ |
| 878 | |
| 879 | if (!object) { |
| 880 | return (AE_OK); |
| 881 | } |
| 882 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 883 | state = acpi_ut_create_update_state(object, action); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 884 | if (!state) { |
| 885 | return (AE_NO_MEMORY); |
| 886 | } |
| 887 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 888 | acpi_ut_push_generic_state(state_list, state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 889 | return (AE_OK); |
| 890 | } |
| 891 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 892 | /******************************************************************************* |
| 893 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 894 | * FUNCTION: acpi_ut_walk_package_tree |
| 895 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 896 | * PARAMETERS: source_object - The package to walk |
| 897 | * target_object - Target object (if package is being copied) |
| 898 | * walk_callback - Called once for each package element |
| 899 | * Context - Passed to the callback function |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 900 | * |
| 901 | * RETURN: Status |
| 902 | * |
| 903 | * DESCRIPTION: Walk through a package |
| 904 | * |
| 905 | ******************************************************************************/ |
| 906 | |
| 907 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 908 | acpi_ut_walk_package_tree(union acpi_operand_object * source_object, |
| 909 | void *target_object, |
| 910 | acpi_pkg_callback walk_callback, void *context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 911 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 912 | acpi_status status = AE_OK; |
| 913 | union acpi_generic_state *state_list = NULL; |
| 914 | union acpi_generic_state *state; |
| 915 | u32 this_index; |
| 916 | union acpi_operand_object *this_source_obj; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 917 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 918 | ACPI_FUNCTION_TRACE(ut_walk_package_tree); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 919 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 920 | state = acpi_ut_create_pkg_state(source_object, target_object, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 921 | if (!state) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 922 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 923 | } |
| 924 | |
| 925 | while (state) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 926 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 927 | /* Get one element of the package */ |
| 928 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 929 | this_index = state->pkg.index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 930 | this_source_obj = (union acpi_operand_object *) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 931 | state->pkg.source_object->package.elements[this_index]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 932 | |
| 933 | /* |
| 934 | * Check for: |
| 935 | * 1) An uninitialized package element. It is completely |
| 936 | * legal to declare a package and leave it uninitialized |
| 937 | * 2) Not an internal object - can be a namespace node instead |
| 938 | * 3) Any type other than a package. Packages are handled in else |
| 939 | * case below. |
| 940 | */ |
| 941 | if ((!this_source_obj) || |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 942 | (ACPI_GET_DESCRIPTOR_TYPE(this_source_obj) != |
| 943 | ACPI_DESC_TYPE_OPERAND) |
| 944 | || (ACPI_GET_OBJECT_TYPE(this_source_obj) != |
| 945 | ACPI_TYPE_PACKAGE)) { |
| 946 | status = |
| 947 | walk_callback(ACPI_COPY_TYPE_SIMPLE, |
| 948 | this_source_obj, state, context); |
| 949 | if (ACPI_FAILURE(status)) { |
| 950 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 951 | } |
| 952 | |
| 953 | state->pkg.index++; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 954 | while (state->pkg.index >= |
| 955 | state->pkg.source_object->package.count) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 956 | /* |
| 957 | * We've handled all of the objects at this level, This means |
| 958 | * that we have just completed a package. That package may |
| 959 | * have contained one or more packages itself. |
| 960 | * |
| 961 | * Delete this state and pop the previous state (package). |
| 962 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 963 | acpi_ut_delete_generic_state(state); |
| 964 | state = acpi_ut_pop_generic_state(&state_list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 965 | |
| 966 | /* Finished when there are no more states */ |
| 967 | |
| 968 | if (!state) { |
| 969 | /* |
| 970 | * We have handled all of the objects in the top level |
| 971 | * package just add the length of the package objects |
| 972 | * and exit |
| 973 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 974 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 975 | } |
| 976 | |
| 977 | /* |
| 978 | * Go back up a level and move the index past the just |
| 979 | * completed package object. |
| 980 | */ |
| 981 | state->pkg.index++; |
| 982 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 983 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 984 | /* This is a subobject of type package */ |
| 985 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 986 | status = |
| 987 | walk_callback(ACPI_COPY_TYPE_PACKAGE, |
| 988 | this_source_obj, state, context); |
| 989 | if (ACPI_FAILURE(status)) { |
| 990 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 991 | } |
| 992 | |
| 993 | /* |
| 994 | * Push the current state and create a new one |
| 995 | * The callback above returned a new target package object. |
| 996 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 997 | acpi_ut_push_generic_state(&state_list, state); |
| 998 | state = acpi_ut_create_pkg_state(this_source_obj, |
| 999 | state->pkg. |
| 1000 | this_target_obj, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1001 | if (!state) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1002 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1003 | } |
| 1004 | } |
| 1005 | } |
| 1006 | |
| 1007 | /* We should never get here */ |
| 1008 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1009 | return_ACPI_STATUS(AE_AML_INTERNAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1010 | } |
| 1011 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1012 | /******************************************************************************* |
| 1013 | * |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 1014 | * FUNCTION: acpi_ut_error, acpi_ut_warning, acpi_ut_info |
| 1015 | * |
| 1016 | * PARAMETERS: module_name - Caller's module name (for error output) |
| 1017 | * line_number - Caller's line number (for error output) |
| 1018 | * Format - Printf format string + additional args |
| 1019 | * |
| 1020 | * RETURN: None |
| 1021 | * |
| 1022 | * DESCRIPTION: Print message with module/line/version info |
| 1023 | * |
| 1024 | ******************************************************************************/ |
| 1025 | |
| 1026 | void ACPI_INTERNAL_VAR_XFACE |
| 1027 | acpi_ut_error(char *module_name, u32 line_number, char *format, ...) |
| 1028 | { |
| 1029 | va_list args; |
| 1030 | |
| 1031 | acpi_os_printf("ACPI Error (%s-%04d): ", module_name, line_number); |
| 1032 | |
| 1033 | va_start(args, format); |
| 1034 | acpi_os_vprintf(format, args); |
| 1035 | acpi_os_printf(" [%X]\n", ACPI_CA_VERSION); |
Bob Moore | 507f046 | 2008-04-10 19:06:42 +0400 | [diff] [blame^] | 1036 | va_end(args); |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 1037 | } |
| 1038 | |
| 1039 | void ACPI_INTERNAL_VAR_XFACE |
| 1040 | acpi_ut_exception(char *module_name, |
| 1041 | u32 line_number, acpi_status status, char *format, ...) |
| 1042 | { |
| 1043 | va_list args; |
| 1044 | |
| 1045 | acpi_os_printf("ACPI Exception (%s-%04d): %s, ", module_name, |
| 1046 | line_number, acpi_format_exception(status)); |
| 1047 | |
| 1048 | va_start(args, format); |
| 1049 | acpi_os_vprintf(format, args); |
| 1050 | acpi_os_printf(" [%X]\n", ACPI_CA_VERSION); |
| 1051 | } |
Len Brown | fd35094 | 2007-05-09 23:34:35 -0400 | [diff] [blame] | 1052 | |
Thomas Renninger | be63c92 | 2006-06-02 15:58:00 -0400 | [diff] [blame] | 1053 | EXPORT_SYMBOL(acpi_ut_exception); |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 1054 | |
| 1055 | void ACPI_INTERNAL_VAR_XFACE |
| 1056 | acpi_ut_warning(char *module_name, u32 line_number, char *format, ...) |
| 1057 | { |
| 1058 | va_list args; |
| 1059 | |
| 1060 | acpi_os_printf("ACPI Warning (%s-%04d): ", module_name, line_number); |
| 1061 | |
| 1062 | va_start(args, format); |
| 1063 | acpi_os_vprintf(format, args); |
| 1064 | acpi_os_printf(" [%X]\n", ACPI_CA_VERSION); |
Bob Moore | 507f046 | 2008-04-10 19:06:42 +0400 | [diff] [blame^] | 1065 | va_end(args); |
| 1066 | va_end(args); |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 1067 | } |
Len Brown | cece929 | 2006-06-26 23:04:31 -0400 | [diff] [blame] | 1068 | |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 1069 | void ACPI_INTERNAL_VAR_XFACE |
| 1070 | acpi_ut_info(char *module_name, u32 line_number, char *format, ...) |
| 1071 | { |
| 1072 | va_list args; |
| 1073 | |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 1074 | /* |
| 1075 | * Removed module_name, line_number, and acpica version, not needed |
| 1076 | * for info output |
| 1077 | */ |
| 1078 | acpi_os_printf("ACPI: "); |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 1079 | |
| 1080 | va_start(args, format); |
| 1081 | acpi_os_vprintf(format, args); |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 1082 | acpi_os_printf("\n"); |
Bob Moore | 507f046 | 2008-04-10 19:06:42 +0400 | [diff] [blame^] | 1083 | va_end(args); |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 1084 | } |