Bob Moore | 7db5d82 | 2008-12-30 11:04:48 +0800 | [diff] [blame] | 1 | |
| 2 | /****************************************************************************** |
| 3 | * |
| 4 | * Module Name: hwxface - Public ACPICA hardware interfaces |
| 5 | * |
| 6 | *****************************************************************************/ |
| 7 | |
| 8 | /* |
| 9 | * Copyright (C) 2000 - 2008, Intel Corp. |
| 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 | |
| 45 | #include <acpi/acpi.h> |
| 46 | #include <acpi/acnamesp.h> |
| 47 | |
| 48 | #define _COMPONENT ACPI_HARDWARE |
| 49 | ACPI_MODULE_NAME("hwxface") |
| 50 | |
| 51 | /****************************************************************************** |
| 52 | * |
Bob Moore | d3fd902 | 2008-12-30 11:11:57 +0800 | [diff] [blame^] | 53 | * FUNCTION: acpi_reset |
| 54 | * |
| 55 | * PARAMETERS: None |
| 56 | * |
| 57 | * RETURN: Status |
| 58 | * |
| 59 | * DESCRIPTION: Set reset register in memory or IO space. Note: Does not |
| 60 | * support reset register in PCI config space, this must be |
| 61 | * handled separately. |
| 62 | * |
| 63 | ******************************************************************************/ |
| 64 | acpi_status acpi_reset(void) |
| 65 | { |
| 66 | struct acpi_generic_address *reset_reg; |
| 67 | acpi_status status; |
| 68 | |
| 69 | ACPI_FUNCTION_TRACE(acpi_reset); |
| 70 | |
| 71 | reset_reg = &acpi_gbl_FADT.reset_register; |
| 72 | |
| 73 | /* Check if the reset register is supported */ |
| 74 | |
| 75 | if (!(acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER) || |
| 76 | !reset_reg->address) { |
| 77 | return_ACPI_STATUS(AE_NOT_EXIST); |
| 78 | } |
| 79 | |
| 80 | /* Write the reset value to the reset register */ |
| 81 | |
| 82 | status = acpi_write(acpi_gbl_FADT.reset_value, reset_reg); |
| 83 | return_ACPI_STATUS(status); |
| 84 | } |
| 85 | |
| 86 | ACPI_EXPORT_SYMBOL(acpi_reset) |
| 87 | |
| 88 | /****************************************************************************** |
| 89 | * |
Bob Moore | 7db5d82 | 2008-12-30 11:04:48 +0800 | [diff] [blame] | 90 | * FUNCTION: acpi_read |
| 91 | * |
| 92 | * PARAMETERS: Value - Where the value is returned |
| 93 | * Reg - GAS register structure |
| 94 | * |
| 95 | * RETURN: Status |
| 96 | * |
| 97 | * DESCRIPTION: Read from either memory or IO space. |
| 98 | * |
| 99 | ******************************************************************************/ |
| 100 | acpi_status acpi_read(u32 *value, struct acpi_generic_address *reg) |
| 101 | { |
| 102 | u32 width; |
| 103 | u64 address; |
| 104 | acpi_status status; |
| 105 | |
| 106 | ACPI_FUNCTION_NAME(acpi_read); |
| 107 | |
| 108 | /* |
| 109 | * Must have a valid pointer to a GAS structure, and |
| 110 | * a non-zero address within. However, don't return an error |
| 111 | * because the PM1A/B code must not fail if B isn't present. |
| 112 | */ |
| 113 | if (!reg) { |
| 114 | return (AE_OK); |
| 115 | } |
| 116 | |
| 117 | /* Get a local copy of the address. Handles possible alignment issues */ |
| 118 | |
| 119 | ACPI_MOVE_64_TO_64(&address, ®->address); |
| 120 | if (!address) { |
| 121 | return (AE_OK); |
| 122 | } |
| 123 | |
| 124 | /* Supported widths are 8/16/32 */ |
| 125 | |
| 126 | width = reg->bit_width; |
| 127 | if ((width != 8) && (width != 16) && (width != 32)) { |
| 128 | return (AE_SUPPORT); |
| 129 | } |
| 130 | |
| 131 | /* Initialize entire 32-bit return value to zero */ |
| 132 | |
| 133 | *value = 0; |
| 134 | |
| 135 | /* |
| 136 | * Two address spaces supported: Memory or IO. |
| 137 | * PCI_Config is not supported here because the GAS struct is insufficient |
| 138 | */ |
| 139 | switch (reg->space_id) { |
| 140 | case ACPI_ADR_SPACE_SYSTEM_MEMORY: |
| 141 | |
| 142 | status = acpi_os_read_memory((acpi_physical_address) address, |
| 143 | value, width); |
| 144 | break; |
| 145 | |
| 146 | case ACPI_ADR_SPACE_SYSTEM_IO: |
| 147 | |
| 148 | status = |
| 149 | acpi_os_read_port((acpi_io_address) address, value, width); |
| 150 | break; |
| 151 | |
| 152 | default: |
| 153 | ACPI_ERROR((AE_INFO, |
| 154 | "Unsupported address space: %X", reg->space_id)); |
| 155 | return (AE_BAD_PARAMETER); |
| 156 | } |
| 157 | |
| 158 | ACPI_DEBUG_PRINT((ACPI_DB_IO, |
| 159 | "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", |
| 160 | *value, width, ACPI_FORMAT_UINT64(address), |
| 161 | acpi_ut_get_region_name(reg->space_id))); |
| 162 | |
| 163 | return (status); |
| 164 | } |
| 165 | |
| 166 | ACPI_EXPORT_SYMBOL(acpi_read) |
| 167 | |
| 168 | /****************************************************************************** |
| 169 | * |
| 170 | * FUNCTION: acpi_write |
| 171 | * |
| 172 | * PARAMETERS: Value - To be written |
| 173 | * Reg - GAS register structure |
| 174 | * |
| 175 | * RETURN: Status |
| 176 | * |
| 177 | * DESCRIPTION: Write to either memory or IO space. |
| 178 | * |
| 179 | ******************************************************************************/ |
| 180 | acpi_status acpi_write(u32 value, struct acpi_generic_address *reg) |
| 181 | { |
| 182 | u32 width; |
| 183 | u64 address; |
| 184 | acpi_status status; |
| 185 | |
| 186 | ACPI_FUNCTION_NAME(acpi_write); |
| 187 | |
| 188 | /* |
| 189 | * Must have a valid pointer to a GAS structure, and |
| 190 | * a non-zero address within. However, don't return an error |
| 191 | * because the PM1A/B code must not fail if B isn't present. |
| 192 | */ |
| 193 | if (!reg) { |
| 194 | return (AE_OK); |
| 195 | } |
| 196 | |
| 197 | /* Get a local copy of the address. Handles possible alignment issues */ |
| 198 | |
| 199 | ACPI_MOVE_64_TO_64(&address, ®->address); |
| 200 | if (!address) { |
| 201 | return (AE_OK); |
| 202 | } |
| 203 | |
| 204 | /* Supported widths are 8/16/32 */ |
| 205 | |
| 206 | width = reg->bit_width; |
| 207 | if ((width != 8) && (width != 16) && (width != 32)) { |
| 208 | return (AE_SUPPORT); |
| 209 | } |
| 210 | |
| 211 | /* |
| 212 | * Two address spaces supported: Memory or IO. |
| 213 | * PCI_Config is not supported here because the GAS struct is insufficient |
| 214 | */ |
| 215 | switch (reg->space_id) { |
| 216 | case ACPI_ADR_SPACE_SYSTEM_MEMORY: |
| 217 | |
| 218 | status = acpi_os_write_memory((acpi_physical_address) address, |
| 219 | value, width); |
| 220 | break; |
| 221 | |
| 222 | case ACPI_ADR_SPACE_SYSTEM_IO: |
| 223 | |
| 224 | status = acpi_os_write_port((acpi_io_address) address, value, |
| 225 | width); |
| 226 | break; |
| 227 | |
| 228 | default: |
| 229 | ACPI_ERROR((AE_INFO, |
| 230 | "Unsupported address space: %X", reg->space_id)); |
| 231 | return (AE_BAD_PARAMETER); |
| 232 | } |
| 233 | |
| 234 | ACPI_DEBUG_PRINT((ACPI_DB_IO, |
| 235 | "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", |
| 236 | value, width, ACPI_FORMAT_UINT64(address), |
| 237 | acpi_ut_get_region_name(reg->space_id))); |
| 238 | |
| 239 | return (status); |
| 240 | } |
| 241 | |
| 242 | ACPI_EXPORT_SYMBOL(acpi_write) |
| 243 | |
| 244 | /******************************************************************************* |
| 245 | * |
| 246 | * FUNCTION: acpi_get_register_unlocked |
| 247 | * |
| 248 | * PARAMETERS: register_id - ID of ACPI bit_register to access |
| 249 | * return_value - Value that was read from the register |
| 250 | * |
| 251 | * RETURN: Status and the value read from specified Register. Value |
| 252 | * returned is normalized to bit0 (is shifted all the way right) |
| 253 | * |
| 254 | * DESCRIPTION: ACPI bit_register read function. Does not acquire the HW lock. |
| 255 | * |
| 256 | ******************************************************************************/ |
| 257 | acpi_status acpi_get_register_unlocked(u32 register_id, u32 *return_value) |
| 258 | { |
| 259 | u32 register_value = 0; |
| 260 | struct acpi_bit_register_info *bit_reg_info; |
| 261 | acpi_status status; |
| 262 | |
| 263 | ACPI_FUNCTION_TRACE(acpi_get_register_unlocked); |
| 264 | |
| 265 | /* Get the info structure corresponding to the requested ACPI Register */ |
| 266 | |
| 267 | bit_reg_info = acpi_hw_get_bit_register_info(register_id); |
| 268 | if (!bit_reg_info) { |
| 269 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
| 270 | } |
| 271 | |
| 272 | /* Read from the register */ |
| 273 | |
| 274 | status = acpi_hw_register_read(bit_reg_info->parent_register, |
| 275 | ®ister_value); |
| 276 | |
| 277 | if (ACPI_SUCCESS(status)) { |
| 278 | |
| 279 | /* Normalize the value that was read */ |
| 280 | |
| 281 | register_value = |
| 282 | ((register_value & bit_reg_info->access_bit_mask) |
| 283 | >> bit_reg_info->bit_position); |
| 284 | |
| 285 | *return_value = register_value; |
| 286 | |
| 287 | ACPI_DEBUG_PRINT((ACPI_DB_IO, "Read value %8.8X register %X\n", |
| 288 | register_value, |
| 289 | bit_reg_info->parent_register)); |
| 290 | } |
| 291 | |
| 292 | return_ACPI_STATUS(status); |
| 293 | } |
| 294 | |
| 295 | ACPI_EXPORT_SYMBOL(acpi_get_register_unlocked) |
| 296 | |
| 297 | /******************************************************************************* |
| 298 | * |
| 299 | * FUNCTION: acpi_get_register |
| 300 | * |
| 301 | * PARAMETERS: register_id - ID of ACPI bit_register to access |
| 302 | * return_value - Value that was read from the register |
| 303 | * |
| 304 | * RETURN: Status and the value read from specified Register. Value |
| 305 | * returned is normalized to bit0 (is shifted all the way right) |
| 306 | * |
| 307 | * DESCRIPTION: ACPI bit_register read function. |
| 308 | * |
| 309 | ******************************************************************************/ |
| 310 | acpi_status acpi_get_register(u32 register_id, u32 *return_value) |
| 311 | { |
| 312 | acpi_status status; |
| 313 | acpi_cpu_flags flags; |
| 314 | |
| 315 | flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); |
| 316 | status = acpi_get_register_unlocked(register_id, return_value); |
| 317 | acpi_os_release_lock(acpi_gbl_hardware_lock, flags); |
| 318 | |
| 319 | return (status); |
| 320 | } |
| 321 | |
| 322 | ACPI_EXPORT_SYMBOL(acpi_get_register) |
| 323 | |
| 324 | /******************************************************************************* |
| 325 | * |
| 326 | * FUNCTION: acpi_set_register |
| 327 | * |
| 328 | * PARAMETERS: register_id - ID of ACPI bit_register to access |
| 329 | * Value - (only used on write) value to write to the |
| 330 | * Register, NOT pre-normalized to the bit pos |
| 331 | * |
| 332 | * RETURN: Status |
| 333 | * |
| 334 | * DESCRIPTION: ACPI Bit Register write function. |
| 335 | * |
| 336 | ******************************************************************************/ |
| 337 | acpi_status acpi_set_register(u32 register_id, u32 value) |
| 338 | { |
| 339 | u32 register_value = 0; |
| 340 | struct acpi_bit_register_info *bit_reg_info; |
| 341 | acpi_status status; |
| 342 | acpi_cpu_flags lock_flags; |
| 343 | |
| 344 | ACPI_FUNCTION_TRACE_U32(acpi_set_register, register_id); |
| 345 | |
| 346 | /* Get the info structure corresponding to the requested ACPI Register */ |
| 347 | |
| 348 | bit_reg_info = acpi_hw_get_bit_register_info(register_id); |
| 349 | if (!bit_reg_info) { |
| 350 | ACPI_ERROR((AE_INFO, "Bad ACPI HW RegisterId: %X", |
| 351 | register_id)); |
| 352 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
| 353 | } |
| 354 | |
| 355 | lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); |
| 356 | |
| 357 | /* Always do a register read first so we can insert the new bits */ |
| 358 | |
| 359 | status = acpi_hw_register_read(bit_reg_info->parent_register, |
| 360 | ®ister_value); |
| 361 | if (ACPI_FAILURE(status)) { |
| 362 | goto unlock_and_exit; |
| 363 | } |
| 364 | |
| 365 | /* |
| 366 | * Decode the Register ID |
| 367 | * Register ID = [Register block ID] | [bit ID] |
| 368 | * |
| 369 | * Check bit ID to fine locate Register offset. |
| 370 | * Check Mask to determine Register offset, and then read-write. |
| 371 | */ |
| 372 | switch (bit_reg_info->parent_register) { |
| 373 | case ACPI_REGISTER_PM1_STATUS: |
| 374 | |
| 375 | /* |
| 376 | * Status Registers are different from the rest. Clear by |
| 377 | * writing 1, and writing 0 has no effect. So, the only relevant |
| 378 | * information is the single bit we're interested in, all others should |
| 379 | * be written as 0 so they will be left unchanged. |
| 380 | */ |
| 381 | value = ACPI_REGISTER_PREPARE_BITS(value, |
| 382 | bit_reg_info->bit_position, |
| 383 | bit_reg_info-> |
| 384 | access_bit_mask); |
| 385 | if (value) { |
| 386 | status = |
| 387 | acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS, |
| 388 | (u16) value); |
| 389 | register_value = 0; |
| 390 | } |
| 391 | break; |
| 392 | |
| 393 | case ACPI_REGISTER_PM1_ENABLE: |
| 394 | |
| 395 | ACPI_REGISTER_INSERT_VALUE(register_value, |
| 396 | bit_reg_info->bit_position, |
| 397 | bit_reg_info->access_bit_mask, |
| 398 | value); |
| 399 | |
| 400 | status = acpi_hw_register_write(ACPI_REGISTER_PM1_ENABLE, |
| 401 | (u16) register_value); |
| 402 | break; |
| 403 | |
| 404 | case ACPI_REGISTER_PM1_CONTROL: |
| 405 | |
| 406 | /* |
| 407 | * Write the PM1 Control register. |
| 408 | * Note that at this level, the fact that there are actually TWO |
| 409 | * registers (A and B - and B may not exist) is abstracted. |
| 410 | */ |
| 411 | ACPI_DEBUG_PRINT((ACPI_DB_IO, "PM1 control: Read %X\n", |
| 412 | register_value)); |
| 413 | |
| 414 | ACPI_REGISTER_INSERT_VALUE(register_value, |
| 415 | bit_reg_info->bit_position, |
| 416 | bit_reg_info->access_bit_mask, |
| 417 | value); |
| 418 | |
| 419 | status = acpi_hw_register_write(ACPI_REGISTER_PM1_CONTROL, |
| 420 | (u16) register_value); |
| 421 | break; |
| 422 | |
| 423 | case ACPI_REGISTER_PM2_CONTROL: |
| 424 | |
| 425 | status = acpi_hw_register_read(ACPI_REGISTER_PM2_CONTROL, |
| 426 | ®ister_value); |
| 427 | if (ACPI_FAILURE(status)) { |
| 428 | goto unlock_and_exit; |
| 429 | } |
| 430 | |
| 431 | ACPI_DEBUG_PRINT((ACPI_DB_IO, |
| 432 | "PM2 control: Read %X from %8.8X%8.8X\n", |
| 433 | register_value, |
| 434 | ACPI_FORMAT_UINT64(acpi_gbl_FADT. |
| 435 | xpm2_control_block. |
| 436 | address))); |
| 437 | |
| 438 | ACPI_REGISTER_INSERT_VALUE(register_value, |
| 439 | bit_reg_info->bit_position, |
| 440 | bit_reg_info->access_bit_mask, |
| 441 | value); |
| 442 | |
| 443 | ACPI_DEBUG_PRINT((ACPI_DB_IO, |
| 444 | "About to write %4.4X to %8.8X%8.8X\n", |
| 445 | register_value, |
| 446 | ACPI_FORMAT_UINT64(acpi_gbl_FADT. |
| 447 | xpm2_control_block. |
| 448 | address))); |
| 449 | |
| 450 | status = acpi_hw_register_write(ACPI_REGISTER_PM2_CONTROL, |
| 451 | (u8) (register_value)); |
| 452 | break; |
| 453 | |
| 454 | default: |
| 455 | break; |
| 456 | } |
| 457 | |
| 458 | unlock_and_exit: |
| 459 | |
| 460 | acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags); |
| 461 | |
| 462 | /* Normalize the value that was read */ |
| 463 | |
| 464 | ACPI_DEBUG_EXEC(register_value = |
| 465 | ((register_value & bit_reg_info->access_bit_mask) >> |
| 466 | bit_reg_info->bit_position)); |
| 467 | |
| 468 | ACPI_DEBUG_PRINT((ACPI_DB_IO, |
| 469 | "Set bits: %8.8X actual %8.8X register %X\n", value, |
| 470 | register_value, bit_reg_info->parent_register)); |
| 471 | return_ACPI_STATUS(status); |
| 472 | } |
| 473 | |
| 474 | ACPI_EXPORT_SYMBOL(acpi_set_register) |
| 475 | |
| 476 | /******************************************************************************* |
| 477 | * |
| 478 | * FUNCTION: acpi_get_sleep_type_data |
| 479 | * |
| 480 | * PARAMETERS: sleep_state - Numeric sleep state |
| 481 | * *sleep_type_a - Where SLP_TYPa is returned |
| 482 | * *sleep_type_b - Where SLP_TYPb is returned |
| 483 | * |
| 484 | * RETURN: Status - ACPI status |
| 485 | * |
| 486 | * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested sleep |
| 487 | * state. |
| 488 | * |
| 489 | ******************************************************************************/ |
| 490 | acpi_status |
| 491 | acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b) |
| 492 | { |
| 493 | acpi_status status = AE_OK; |
| 494 | struct acpi_evaluate_info *info; |
| 495 | |
| 496 | ACPI_FUNCTION_TRACE(acpi_get_sleep_type_data); |
| 497 | |
| 498 | /* Validate parameters */ |
| 499 | |
| 500 | if ((sleep_state > ACPI_S_STATES_MAX) || !sleep_type_a || !sleep_type_b) { |
| 501 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
| 502 | } |
| 503 | |
| 504 | /* Allocate the evaluation information block */ |
| 505 | |
| 506 | info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info)); |
| 507 | if (!info) { |
| 508 | return_ACPI_STATUS(AE_NO_MEMORY); |
| 509 | } |
| 510 | |
| 511 | info->pathname = |
| 512 | ACPI_CAST_PTR(char, acpi_gbl_sleep_state_names[sleep_state]); |
| 513 | |
| 514 | /* Evaluate the namespace object containing the values for this state */ |
| 515 | |
| 516 | status = acpi_ns_evaluate(info); |
| 517 | if (ACPI_FAILURE(status)) { |
| 518 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
| 519 | "%s while evaluating SleepState [%s]\n", |
| 520 | acpi_format_exception(status), |
| 521 | info->pathname)); |
| 522 | |
| 523 | goto cleanup; |
| 524 | } |
| 525 | |
| 526 | /* Must have a return object */ |
| 527 | |
| 528 | if (!info->return_object) { |
| 529 | ACPI_ERROR((AE_INFO, "No Sleep State object returned from [%s]", |
| 530 | info->pathname)); |
| 531 | status = AE_NOT_EXIST; |
| 532 | } |
| 533 | |
| 534 | /* It must be of type Package */ |
| 535 | |
| 536 | else if (ACPI_GET_OBJECT_TYPE(info->return_object) != ACPI_TYPE_PACKAGE) { |
| 537 | ACPI_ERROR((AE_INFO, |
| 538 | "Sleep State return object is not a Package")); |
| 539 | status = AE_AML_OPERAND_TYPE; |
| 540 | } |
| 541 | |
| 542 | /* |
| 543 | * The package must have at least two elements. NOTE (March 2005): This |
| 544 | * goes against the current ACPI spec which defines this object as a |
| 545 | * package with one encoded DWORD element. However, existing practice |
| 546 | * by BIOS vendors seems to be to have 2 or more elements, at least |
| 547 | * one per sleep type (A/B). |
| 548 | */ |
| 549 | else if (info->return_object->package.count < 2) { |
| 550 | ACPI_ERROR((AE_INFO, |
| 551 | "Sleep State return package does not have at least two elements")); |
| 552 | status = AE_AML_NO_OPERAND; |
| 553 | } |
| 554 | |
| 555 | /* The first two elements must both be of type Integer */ |
| 556 | |
| 557 | else if ((ACPI_GET_OBJECT_TYPE(info->return_object->package.elements[0]) |
| 558 | != ACPI_TYPE_INTEGER) || |
| 559 | (ACPI_GET_OBJECT_TYPE(info->return_object->package.elements[1]) |
| 560 | != ACPI_TYPE_INTEGER)) { |
| 561 | ACPI_ERROR((AE_INFO, |
| 562 | "Sleep State return package elements are not both Integers (%s, %s)", |
| 563 | acpi_ut_get_object_type_name(info->return_object-> |
| 564 | package.elements[0]), |
| 565 | acpi_ut_get_object_type_name(info->return_object-> |
| 566 | package.elements[1]))); |
| 567 | status = AE_AML_OPERAND_TYPE; |
| 568 | } else { |
| 569 | /* Valid _Sx_ package size, type, and value */ |
| 570 | |
| 571 | *sleep_type_a = (u8) |
| 572 | (info->return_object->package.elements[0])->integer.value; |
| 573 | *sleep_type_b = (u8) |
| 574 | (info->return_object->package.elements[1])->integer.value; |
| 575 | } |
| 576 | |
| 577 | if (ACPI_FAILURE(status)) { |
| 578 | ACPI_EXCEPTION((AE_INFO, status, |
| 579 | "While evaluating SleepState [%s], bad Sleep object %p type %s", |
| 580 | info->pathname, info->return_object, |
| 581 | acpi_ut_get_object_type_name(info-> |
| 582 | return_object))); |
| 583 | } |
| 584 | |
| 585 | acpi_ut_remove_reference(info->return_object); |
| 586 | |
| 587 | cleanup: |
| 588 | ACPI_FREE(info); |
| 589 | return_ACPI_STATUS(status); |
| 590 | } |
| 591 | |
| 592 | ACPI_EXPORT_SYMBOL(acpi_get_sleep_type_data) |