Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | |
| 2 | /****************************************************************************** |
| 3 | * |
| 4 | * Module Name: exutils - interpreter/scanner utilities |
| 5 | * |
| 6 | *****************************************************************************/ |
| 7 | |
| 8 | /* |
Bob Moore | 4a90c7e | 2006-01-13 16:22:00 -0500 | [diff] [blame] | 9 | * Copyright (C) 2000 - 2006, R. Byron Moore |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * All rights reserved. |
| 11 | * |
| 12 | * Redistribution and use in source and binary forms, with or without |
| 13 | * modification, are permitted provided that the following conditions |
| 14 | * are met: |
| 15 | * 1. Redistributions of source code must retain the above copyright |
| 16 | * notice, this list of conditions, and the following disclaimer, |
| 17 | * without modification. |
| 18 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 19 | * substantially similar to the "NO WARRANTY" disclaimer below |
| 20 | * ("Disclaimer") and any redistribution must be conditioned upon |
| 21 | * including a substantially similar Disclaimer requirement for further |
| 22 | * binary redistribution. |
| 23 | * 3. Neither the names of the above-listed copyright holders nor the names |
| 24 | * of any contributors may be used to endorse or promote products derived |
| 25 | * from this software without specific prior written permission. |
| 26 | * |
| 27 | * Alternatively, this software may be distributed under the terms of the |
| 28 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 29 | * Software Foundation. |
| 30 | * |
| 31 | * NO WARRANTY |
| 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 33 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 34 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
| 35 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 36 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 38 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 39 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 40 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 41 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 42 | * POSSIBILITY OF SUCH DAMAGES. |
| 43 | */ |
| 44 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | /* |
| 46 | * DEFINE_AML_GLOBALS is tested in amlcode.h |
| 47 | * to determine whether certain global names should be "defined" or only |
| 48 | * "declared" in the current compilation. This enhances maintainability |
| 49 | * by enabling a single header file to embody all knowledge of the names |
| 50 | * in question. |
| 51 | * |
| 52 | * Exactly one module of any executable should #define DEFINE_GLOBALS |
| 53 | * before #including the header files which use this convention. The |
| 54 | * names in question will be defined and initialized in that module, |
| 55 | * and declared as extern in all other modules which #include those |
| 56 | * header files. |
| 57 | */ |
| 58 | |
| 59 | #define DEFINE_AML_GLOBALS |
| 60 | |
| 61 | #include <acpi/acpi.h> |
| 62 | #include <acpi/acinterp.h> |
| 63 | #include <acpi/amlcode.h> |
| 64 | #include <acpi/acevents.h> |
| 65 | |
| 66 | #define _COMPONENT ACPI_EXECUTER |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 67 | ACPI_MODULE_NAME("exutils") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 69 | /* Local prototypes */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 70 | static u32 acpi_ex_digits_needed(acpi_integer value, u32 base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | |
| 72 | #ifndef ACPI_NO_METHOD_EXECUTION |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | /******************************************************************************* |
| 74 | * |
| 75 | * FUNCTION: acpi_ex_enter_interpreter |
| 76 | * |
| 77 | * PARAMETERS: None |
| 78 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 79 | * RETURN: Status |
| 80 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | * DESCRIPTION: Enter the interpreter execution region. Failure to enter |
| 82 | * the interpreter region is a fatal system error |
| 83 | * |
| 84 | ******************************************************************************/ |
| 85 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 86 | acpi_status acpi_ex_enter_interpreter(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 88 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 90 | ACPI_FUNCTION_TRACE("ex_enter_interpreter"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 92 | status = acpi_ut_acquire_mutex(ACPI_MTX_EXECUTE); |
| 93 | if (ACPI_FAILURE(status)) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 94 | ACPI_ERROR((AE_INFO, "Could not acquire interpreter mutex")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | } |
| 96 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 97 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | } |
| 99 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | /******************************************************************************* |
| 101 | * |
| 102 | * FUNCTION: acpi_ex_exit_interpreter |
| 103 | * |
| 104 | * PARAMETERS: None |
| 105 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 106 | * RETURN: None |
| 107 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | * DESCRIPTION: Exit the interpreter execution region |
| 109 | * |
| 110 | * Cases where the interpreter is unlocked: |
| 111 | * 1) Completion of the execution of a control method |
| 112 | * 2) Method blocked on a Sleep() AML opcode |
| 113 | * 3) Method blocked on an Acquire() AML opcode |
| 114 | * 4) Method blocked on a Wait() AML opcode |
| 115 | * 5) Method blocked to acquire the global lock |
| 116 | * 6) Method blocked to execute a serialized control method that is |
| 117 | * already executing |
| 118 | * 7) About to invoke a user-installed opregion handler |
| 119 | * |
| 120 | ******************************************************************************/ |
| 121 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 122 | void acpi_ex_exit_interpreter(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 124 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 126 | ACPI_FUNCTION_TRACE("ex_exit_interpreter"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 128 | status = acpi_ut_release_mutex(ACPI_MTX_EXECUTE); |
| 129 | if (ACPI_FAILURE(status)) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 130 | ACPI_ERROR((AE_INFO, "Could not release interpreter mutex")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | return_VOID; |
| 134 | } |
| 135 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | /******************************************************************************* |
| 137 | * |
| 138 | * FUNCTION: acpi_ex_truncate_for32bit_table |
| 139 | * |
| 140 | * PARAMETERS: obj_desc - Object to be truncated |
| 141 | * |
| 142 | * RETURN: none |
| 143 | * |
| 144 | * DESCRIPTION: Truncate a number to 32-bits if the currently executing method |
| 145 | * belongs to a 32-bit ACPI table. |
| 146 | * |
| 147 | ******************************************************************************/ |
| 148 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 149 | void acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | { |
| 151 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 152 | ACPI_FUNCTION_ENTRY(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | |
| 154 | /* |
| 155 | * Object must be a valid number and we must be executing |
| 156 | * a control method |
| 157 | */ |
| 158 | if ((!obj_desc) || |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 159 | (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_INTEGER)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | return; |
| 161 | } |
| 162 | |
| 163 | if (acpi_gbl_integer_byte_width == 4) { |
| 164 | /* |
| 165 | * We are running a method that exists in a 32-bit ACPI table. |
| 166 | * Truncate the value to 32 bits by zeroing out the upper 32-bit field |
| 167 | */ |
| 168 | obj_desc->integer.value &= (acpi_integer) ACPI_UINT32_MAX; |
| 169 | } |
| 170 | } |
| 171 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | /******************************************************************************* |
| 173 | * |
| 174 | * FUNCTION: acpi_ex_acquire_global_lock |
| 175 | * |
| 176 | * PARAMETERS: field_flags - Flags with Lock rule: |
| 177 | * always_lock or never_lock |
| 178 | * |
| 179 | * RETURN: TRUE/FALSE indicating whether the lock was actually acquired |
| 180 | * |
| 181 | * DESCRIPTION: Obtain the global lock and keep track of this fact via two |
| 182 | * methods. A global variable keeps the state of the lock, and |
| 183 | * the state is returned to the caller. |
| 184 | * |
| 185 | ******************************************************************************/ |
| 186 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 187 | u8 acpi_ex_acquire_global_lock(u32 field_flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 189 | u8 locked = FALSE; |
| 190 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 192 | ACPI_FUNCTION_TRACE("ex_acquire_global_lock"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | |
| 194 | /* Only attempt lock if the always_lock bit is set */ |
| 195 | |
| 196 | if (field_flags & AML_FIELD_LOCK_RULE_MASK) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame^] | 197 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | /* We should attempt to get the lock, wait forever */ |
| 199 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 200 | status = acpi_ev_acquire_global_lock(ACPI_WAIT_FOREVER); |
| 201 | if (ACPI_SUCCESS(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | locked = TRUE; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 203 | } else { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 204 | ACPI_EXCEPTION((AE_INFO, status, |
| 205 | "Could not acquire Global Lock")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | } |
| 207 | } |
| 208 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 209 | return_UINT8(locked); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | } |
| 211 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | /******************************************************************************* |
| 213 | * |
| 214 | * FUNCTION: acpi_ex_release_global_lock |
| 215 | * |
| 216 | * PARAMETERS: locked_by_me - Return value from corresponding call to |
| 217 | * acquire_global_lock. |
| 218 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 219 | * RETURN: None |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | * |
| 221 | * DESCRIPTION: Release the global lock if it is locked. |
| 222 | * |
| 223 | ******************************************************************************/ |
| 224 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 225 | void acpi_ex_release_global_lock(u8 locked_by_me) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 227 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 229 | ACPI_FUNCTION_TRACE("ex_release_global_lock"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | |
| 231 | /* Only attempt unlock if the caller locked it */ |
| 232 | |
| 233 | if (locked_by_me) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame^] | 234 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | /* OK, now release the lock */ |
| 236 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 237 | status = acpi_ev_release_global_lock(); |
| 238 | if (ACPI_FAILURE(status)) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame^] | 239 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | /* Report the error, but there isn't much else we can do */ |
| 241 | |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 242 | ACPI_EXCEPTION((AE_INFO, status, |
| 243 | "Could not release ACPI Global Lock")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | } |
| 245 | } |
| 246 | |
| 247 | return_VOID; |
| 248 | } |
| 249 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | /******************************************************************************* |
| 251 | * |
| 252 | * FUNCTION: acpi_ex_digits_needed |
| 253 | * |
| 254 | * PARAMETERS: Value - Value to be represented |
| 255 | * Base - Base of representation |
| 256 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 257 | * RETURN: The number of digits. |
| 258 | * |
| 259 | * DESCRIPTION: Calculate the number of digits needed to represent the Value |
| 260 | * in the given Base (Radix) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | * |
| 262 | ******************************************************************************/ |
| 263 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 264 | static u32 acpi_ex_digits_needed(acpi_integer value, u32 base) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 266 | u32 num_digits; |
| 267 | acpi_integer current_value; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 269 | ACPI_FUNCTION_TRACE("ex_digits_needed"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | |
| 271 | /* acpi_integer is unsigned, so we don't worry about a '-' prefix */ |
| 272 | |
| 273 | if (value == 0) { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 274 | return_UINT32(1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | } |
| 276 | |
| 277 | current_value = value; |
| 278 | num_digits = 0; |
| 279 | |
| 280 | /* Count the digits in the requested base */ |
| 281 | |
| 282 | while (current_value) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 283 | (void)acpi_ut_short_divide(current_value, base, ¤t_value, |
| 284 | NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | num_digits++; |
| 286 | } |
| 287 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 288 | return_UINT32(num_digits); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | } |
| 290 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | /******************************************************************************* |
| 292 | * |
| 293 | * FUNCTION: acpi_ex_eisa_id_to_string |
| 294 | * |
| 295 | * PARAMETERS: numeric_id - EISA ID to be converted |
| 296 | * out_string - Where to put the converted string (8 bytes) |
| 297 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 298 | * RETURN: None |
| 299 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | * DESCRIPTION: Convert a numeric EISA ID to string representation |
| 301 | * |
| 302 | ******************************************************************************/ |
| 303 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 304 | void acpi_ex_eisa_id_to_string(u32 numeric_id, char *out_string) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 306 | u32 eisa_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 308 | ACPI_FUNCTION_ENTRY(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | |
| 310 | /* Swap ID to big-endian to get contiguous bits */ |
| 311 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 312 | eisa_id = acpi_ut_dword_byte_swap(numeric_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 314 | out_string[0] = (char)('@' + (((unsigned long)eisa_id >> 26) & 0x1f)); |
| 315 | out_string[1] = (char)('@' + ((eisa_id >> 21) & 0x1f)); |
| 316 | out_string[2] = (char)('@' + ((eisa_id >> 16) & 0x1f)); |
| 317 | out_string[3] = acpi_ut_hex_to_ascii_char((acpi_integer) eisa_id, 12); |
| 318 | out_string[4] = acpi_ut_hex_to_ascii_char((acpi_integer) eisa_id, 8); |
| 319 | out_string[5] = acpi_ut_hex_to_ascii_char((acpi_integer) eisa_id, 4); |
| 320 | out_string[6] = acpi_ut_hex_to_ascii_char((acpi_integer) eisa_id, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | out_string[7] = 0; |
| 322 | } |
| 323 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | /******************************************************************************* |
| 325 | * |
| 326 | * FUNCTION: acpi_ex_unsigned_integer_to_string |
| 327 | * |
| 328 | * PARAMETERS: Value - Value to be converted |
| 329 | * out_string - Where to put the converted string (8 bytes) |
| 330 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 331 | * RETURN: None, string |
| 332 | * |
Robert Moore | 73459f7 | 2005-06-24 00:00:00 -0400 | [diff] [blame] | 333 | * DESCRIPTION: Convert a number to string representation. Assumes string |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 334 | * buffer is large enough to hold the string. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | * |
| 336 | ******************************************************************************/ |
| 337 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 338 | void acpi_ex_unsigned_integer_to_string(acpi_integer value, char *out_string) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 340 | u32 count; |
| 341 | u32 digits_needed; |
| 342 | u32 remainder; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 344 | ACPI_FUNCTION_ENTRY(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 346 | digits_needed = acpi_ex_digits_needed(value, 10); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | out_string[digits_needed] = 0; |
| 348 | |
| 349 | for (count = digits_needed; count > 0; count--) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 350 | (void)acpi_ut_short_divide(value, 10, &value, &remainder); |
| 351 | out_string[count - 1] = (char)('0' + remainder); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | } |
| 353 | } |
| 354 | |
| 355 | #endif |