1ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore/****************************************************************************** 2ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 3ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * Module Name: nsrepair2 - Repair for objects returned by specific 4ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * predefined methods 5ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 6ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore *****************************************************************************/ 7ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 8ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore/* 9fbb7a2dc2be493c87399550bdc2ddaa510cdf450Bob Moore * Copyright (C) 2000 - 2014, Intel Corp. 10ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * All rights reserved. 11ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 12ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * Redistribution and use in source and binary forms, with or without 13ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * modification, are permitted provided that the following conditions 14ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * are met: 15ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 1. Redistributions of source code must retain the above copyright 16ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * notice, this list of conditions, and the following disclaimer, 17ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * without modification. 18ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 2. Redistributions in binary form must reproduce at minimum a disclaimer 19ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * substantially similar to the "NO WARRANTY" disclaimer below 20ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * ("Disclaimer") and any redistribution must be conditioned upon 21ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * including a substantially similar Disclaimer requirement for further 22ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * binary redistribution. 23ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 3. Neither the names of the above-listed copyright holders nor the names 24ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * of any contributors may be used to endorse or promote products derived 25ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * from this software without specific prior written permission. 26ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 27ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * Alternatively, this software may be distributed under the terms of the 28ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * GNU General Public License ("GPL") version 2 as published by the Free 29ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * Software Foundation. 30ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 31ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * NO WARRANTY 32ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 33ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 34ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 35ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 36ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 38ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 39ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 40ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 41ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 42ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * POSSIBILITY OF SUCH DAMAGES. 43ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore */ 44ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 45ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore#include <acpi/acpi.h> 46ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore#include "accommon.h" 47ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore#include "acnamesp.h" 48ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 49ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore#define _COMPONENT ACPI_NAMESPACE 50ad5babeed8d3082406c5b67ae558b95a479ddb6fBob MooreACPI_MODULE_NAME("nsrepair2") 51ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 52ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore/* 53ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * Information structure and handler for ACPI predefined names that can 54ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * be repaired on a per-name basis. 55ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore */ 56ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Mooretypedef 5729a241cc02110b8b2259fd72719b8cadc03909beBob Mooreacpi_status(*acpi_repair_function) (struct acpi_evaluate_info * info, 583e8214e5c2bd449b30109d4a098597ab1b7c9fb9Lv Zheng union acpi_operand_object 593e8214e5c2bd449b30109d4a098597ab1b7c9fb9Lv Zheng **return_object_ptr); 60ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 61ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Mooretypedef struct acpi_repair_info { 62ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore char name[ACPI_NAME_SIZE]; 63ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore acpi_repair_function repair_function; 64ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 65ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore} acpi_repair_info; 66ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 67ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore/* Local prototypes */ 68ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 69d5a36100f62fa6db5541344e08b361b34e9114c5Bob Moorestatic const struct acpi_repair_info *acpi_ns_match_complex_repair(struct 70d5a36100f62fa6db5541344e08b361b34e9114c5Bob Moore acpi_namespace_node 71d5a36100f62fa6db5541344e08b361b34e9114c5Bob Moore *node); 72ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 73ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moorestatic acpi_status 7429a241cc02110b8b2259fd72719b8cadc03909beBob Mooreacpi_ns_repair_ALR(struct acpi_evaluate_info *info, 75ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore union acpi_operand_object **return_object_ptr); 76ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 77ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moorestatic acpi_status 7829a241cc02110b8b2259fd72719b8cadc03909beBob Mooreacpi_ns_repair_CID(struct acpi_evaluate_info *info, 7977b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore union acpi_operand_object **return_object_ptr); 8077b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 8177b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moorestatic acpi_status 825a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zhengacpi_ns_repair_CST(struct acpi_evaluate_info *info, 835a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng union acpi_operand_object **return_object_ptr); 845a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng 855a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zhengstatic acpi_status 8629a241cc02110b8b2259fd72719b8cadc03909beBob Mooreacpi_ns_repair_FDE(struct acpi_evaluate_info *info, 8734c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore union acpi_operand_object **return_object_ptr); 8834c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore 8934c39c755347c1ca3d06284bad2273c6a9c3108aBob Moorestatic acpi_status 9029a241cc02110b8b2259fd72719b8cadc03909beBob Mooreacpi_ns_repair_HID(struct acpi_evaluate_info *info, 9177b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore union acpi_operand_object **return_object_ptr); 9277b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 9377b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moorestatic acpi_status 94aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zhengacpi_ns_repair_PRT(struct acpi_evaluate_info *info, 95aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng union acpi_operand_object **return_object_ptr); 96aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng 97aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zhengstatic acpi_status 9829a241cc02110b8b2259fd72719b8cadc03909beBob Mooreacpi_ns_repair_PSS(struct acpi_evaluate_info *info, 99ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore union acpi_operand_object **return_object_ptr); 100ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 101ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moorestatic acpi_status 10229a241cc02110b8b2259fd72719b8cadc03909beBob Mooreacpi_ns_repair_TSS(struct acpi_evaluate_info *info, 103ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore union acpi_operand_object **return_object_ptr); 104ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 105ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moorestatic acpi_status 10629a241cc02110b8b2259fd72719b8cadc03909beBob Mooreacpi_ns_check_sorted_list(struct acpi_evaluate_info *info, 107ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore union acpi_operand_object *return_object, 1085a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng u32 start_index, 109ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore u32 expected_count, 110ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore u32 sort_index, 111ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore u8 sort_direction, char *sort_key_name); 112ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 113ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore/* Values for sort_direction above */ 114ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 115ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore#define ACPI_SORT_ASCENDING 0 116ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore#define ACPI_SORT_DESCENDING 1 117ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 1185a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zhengstatic void 1195a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zhengacpi_ns_remove_element(union acpi_operand_object *obj_desc, u32 index); 1205a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng 1215a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zhengstatic void 1225a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zhengacpi_ns_sort_list(union acpi_operand_object **elements, 1235a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng u32 count, u32 index, u8 sort_direction); 1245a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng 125ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore/* 126ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * This table contains the names of the predefined methods for which we can 127ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * perform more complex repairs. 128ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 12934c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore * As necessary: 13034c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore * 13134c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore * _ALR: Sort the list ascending by ambient_illuminance 13277b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * _CID: Strings: uppercase all, remove any leading asterisk 1335a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng * _CST: Sort the list ascending by C state type 13443420bbb892268b5fc42cb80c3bc31dedbad3ac9Bob Moore * _FDE: Convert Buffer of BYTEs to a Buffer of DWORDs 13543420bbb892268b5fc42cb80c3bc31dedbad3ac9Bob Moore * _GTM: Convert Buffer of BYTEs to a Buffer of DWORDs 13677b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * _HID: Strings: uppercase all, remove any leading asterisk 137aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng * _PRT: Fix reversed source_name and source_index 13834c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore * _PSS: Sort the list descending by Power 13934c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore * _TSS: Sort the list descending by Power 140aa9d36060fb7480a5907660b7ba61c3fda20fc61Bob Moore * 141aa9d36060fb7480a5907660b7ba61c3fda20fc61Bob Moore * Names that must be packages, but cannot be sorted: 142aa9d36060fb7480a5907660b7ba61c3fda20fc61Bob Moore * 143aa9d36060fb7480a5907660b7ba61c3fda20fc61Bob Moore * _BCL: Values are tied to the Package index where they appear, and cannot 144aa9d36060fb7480a5907660b7ba61c3fda20fc61Bob Moore * be moved or sorted. These index values are used for _BQC and _BCM. 145aa9d36060fb7480a5907660b7ba61c3fda20fc61Bob Moore * However, we can fix the case where a buffer is returned, by converting 146aa9d36060fb7480a5907660b7ba61c3fda20fc61Bob Moore * it to a Package of integers. 147ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore */ 148ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moorestatic const struct acpi_repair_info acpi_ns_repairable_names[] = { 149ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore {"_ALR", acpi_ns_repair_ALR}, 15077b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore {"_CID", acpi_ns_repair_CID}, 1515a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng {"_CST", acpi_ns_repair_CST}, 15234c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore {"_FDE", acpi_ns_repair_FDE}, 15334c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore {"_GTM", acpi_ns_repair_FDE}, /* _GTM has same repair as _FDE */ 15477b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore {"_HID", acpi_ns_repair_HID}, 155aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng {"_PRT", acpi_ns_repair_PRT}, 156ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore {"_PSS", acpi_ns_repair_PSS}, 157ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore {"_TSS", acpi_ns_repair_TSS}, 158ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore {{0, 0, 0, 0}, NULL} /* Table terminator */ 159ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore}; 160ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 16134c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore#define ACPI_FDE_FIELD_COUNT 5 16234c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore#define ACPI_FDE_BYTE_BUFFER_SIZE 5 16334c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore#define ACPI_FDE_DWORD_BUFFER_SIZE (ACPI_FDE_FIELD_COUNT * sizeof (u32)) 16434c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore 165ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore/****************************************************************************** 166ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 167ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * FUNCTION: acpi_ns_complex_repairs 168ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 16929a241cc02110b8b2259fd72719b8cadc03909beBob Moore * PARAMETERS: info - Method execution information block 170ba494beeaa69bc0fb01eb89464ad5d57d26e3901Bob Moore * node - Namespace node for the method/object 171ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * validate_status - Original status of earlier validation 172ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * return_object_ptr - Pointer to the object returned from the 173ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * evaluation of a method or object 174ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 175ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * RETURN: Status. AE_OK if repair was successful. If name is not 176ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * matched, validate_status is returned. 177ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 178ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * DESCRIPTION: Attempt to repair/convert a return object of a type that was 179ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * not expected. 180ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 181ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore *****************************************************************************/ 182ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 183ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Mooreacpi_status 18429a241cc02110b8b2259fd72719b8cadc03909beBob Mooreacpi_ns_complex_repairs(struct acpi_evaluate_info *info, 185ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore struct acpi_namespace_node *node, 186ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore acpi_status validate_status, 187ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore union acpi_operand_object **return_object_ptr) 188ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore{ 189ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore const struct acpi_repair_info *predefined; 190ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore acpi_status status; 191ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 192ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore /* Check if this name is in the list of repairable names */ 193ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 194d5a36100f62fa6db5541344e08b361b34e9114c5Bob Moore predefined = acpi_ns_match_complex_repair(node); 195ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore if (!predefined) { 196ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore return (validate_status); 197ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore } 198ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 19929a241cc02110b8b2259fd72719b8cadc03909beBob Moore status = predefined->repair_function(info, return_object_ptr); 200ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore return (status); 201ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore} 202ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 203ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore/****************************************************************************** 204ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 205d5a36100f62fa6db5541344e08b361b34e9114c5Bob Moore * FUNCTION: acpi_ns_match_complex_repair 206ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 207ba494beeaa69bc0fb01eb89464ad5d57d26e3901Bob Moore * PARAMETERS: node - Namespace node for the method/object 208ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 209ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * RETURN: Pointer to entry in repair table. NULL indicates not found. 210ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 211ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * DESCRIPTION: Check an object name against the repairable object list. 212ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 213ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore *****************************************************************************/ 214ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 215d5a36100f62fa6db5541344e08b361b34e9114c5Bob Moorestatic const struct acpi_repair_info *acpi_ns_match_complex_repair(struct 216d5a36100f62fa6db5541344e08b361b34e9114c5Bob Moore acpi_namespace_node 217d5a36100f62fa6db5541344e08b361b34e9114c5Bob Moore *node) 218ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore{ 219ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore const struct acpi_repair_info *this_name; 220ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 221ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore /* Search info table for a repairable predefined method/object name */ 222ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 223ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore this_name = acpi_ns_repairable_names; 224ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore while (this_name->repair_function) { 225ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore if (ACPI_COMPARE_NAME(node->name.ascii, this_name->name)) { 226ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore return (this_name); 227ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore } 228ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore this_name++; 229ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore } 230ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 231ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore return (NULL); /* Not found */ 232ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore} 233ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 234ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore/****************************************************************************** 235ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 236ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * FUNCTION: acpi_ns_repair_ALR 237ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 23829a241cc02110b8b2259fd72719b8cadc03909beBob Moore * PARAMETERS: info - Method execution information block 239ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * return_object_ptr - Pointer to the object returned from the 240ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * evaluation of a method or object 241ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 242ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * RETURN: Status. AE_OK if object is OK or was repaired successfully 243ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 244ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * DESCRIPTION: Repair for the _ALR object. If necessary, sort the object list 245ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * ascending by the ambient illuminance values. 246ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 247ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore *****************************************************************************/ 248ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 249ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moorestatic acpi_status 25029a241cc02110b8b2259fd72719b8cadc03909beBob Mooreacpi_ns_repair_ALR(struct acpi_evaluate_info *info, 251ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore union acpi_operand_object **return_object_ptr) 252ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore{ 253ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore union acpi_operand_object *return_object = *return_object_ptr; 254ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore acpi_status status; 255ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 2565a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng status = acpi_ns_check_sorted_list(info, return_object, 0, 2, 1, 257ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore ACPI_SORT_ASCENDING, 258ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore "AmbientIlluminance"); 259ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 260ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore return (status); 261ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore} 262ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 263ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore/****************************************************************************** 264ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 26534c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore * FUNCTION: acpi_ns_repair_FDE 26634c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore * 26729a241cc02110b8b2259fd72719b8cadc03909beBob Moore * PARAMETERS: info - Method execution information block 26834c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore * return_object_ptr - Pointer to the object returned from the 26934c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore * evaluation of a method or object 27034c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore * 27134c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore * RETURN: Status. AE_OK if object is OK or was repaired successfully 27234c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore * 27334c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore * DESCRIPTION: Repair for the _FDE and _GTM objects. The expected return 27443420bbb892268b5fc42cb80c3bc31dedbad3ac9Bob Moore * value is a Buffer of 5 DWORDs. This function repairs a common 27543420bbb892268b5fc42cb80c3bc31dedbad3ac9Bob Moore * problem where the return value is a Buffer of BYTEs, not 27643420bbb892268b5fc42cb80c3bc31dedbad3ac9Bob Moore * DWORDs. 27734c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore * 27834c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore *****************************************************************************/ 27934c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore 28034c39c755347c1ca3d06284bad2273c6a9c3108aBob Moorestatic acpi_status 28129a241cc02110b8b2259fd72719b8cadc03909beBob Mooreacpi_ns_repair_FDE(struct acpi_evaluate_info *info, 28234c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore union acpi_operand_object **return_object_ptr) 28334c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore{ 28434c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore union acpi_operand_object *return_object = *return_object_ptr; 28534c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore union acpi_operand_object *buffer_object; 28634c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore u8 *byte_buffer; 28734c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore u32 *dword_buffer; 28834c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore u32 i; 28934c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore 2903a58176e4fa47d8232e04131b023f3f2ecd7084bBob Moore ACPI_FUNCTION_NAME(ns_repair_FDE); 2913a58176e4fa47d8232e04131b023f3f2ecd7084bBob Moore 29234c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore switch (return_object->common.type) { 29334c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore case ACPI_TYPE_BUFFER: 29434c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore 29534c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore /* This is the expected type. Length should be (at least) 5 DWORDs */ 29634c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore 29734c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore if (return_object->buffer.length >= ACPI_FDE_DWORD_BUFFER_SIZE) { 29834c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore return (AE_OK); 29934c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore } 30034c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore 30134c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore /* We can only repair if we have exactly 5 BYTEs */ 30234c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore 30334c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore if (return_object->buffer.length != ACPI_FDE_BYTE_BUFFER_SIZE) { 30429a241cc02110b8b2259fd72719b8cadc03909beBob Moore ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, 30529a241cc02110b8b2259fd72719b8cadc03909beBob Moore info->node_flags, 30634c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore "Incorrect return buffer length %u, expected %u", 30734c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore return_object->buffer.length, 30834c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore ACPI_FDE_DWORD_BUFFER_SIZE)); 30934c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore 31034c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore return (AE_AML_OPERAND_TYPE); 31134c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore } 31234c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore 31334c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore /* Create the new (larger) buffer object */ 31434c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore 31534c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore buffer_object = 31634c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore acpi_ut_create_buffer_object(ACPI_FDE_DWORD_BUFFER_SIZE); 31734c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore if (!buffer_object) { 31834c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore return (AE_NO_MEMORY); 31934c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore } 32034c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore 32134c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore /* Expand each byte to a DWORD */ 32234c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore 32334c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore byte_buffer = return_object->buffer.pointer; 32434c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore dword_buffer = 32534c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore ACPI_CAST_PTR(u32, buffer_object->buffer.pointer); 32634c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore 32734c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore for (i = 0; i < ACPI_FDE_FIELD_COUNT; i++) { 32834c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore *dword_buffer = (u32) *byte_buffer; 32934c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore dword_buffer++; 33034c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore byte_buffer++; 33134c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore } 33234c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore 3333a58176e4fa47d8232e04131b023f3f2ecd7084bBob Moore ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, 3343a58176e4fa47d8232e04131b023f3f2ecd7084bBob Moore "%s Expanded Byte Buffer to expected DWord Buffer\n", 33529a241cc02110b8b2259fd72719b8cadc03909beBob Moore info->full_pathname)); 33634c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore break; 33734c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore 33834c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore default: 3391d1ea1b723d9f239f736b8cf284327cbbf9d15d1Chao Guan 34034c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore return (AE_AML_OPERAND_TYPE); 34134c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore } 34234c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore 34334c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore /* Delete the original return object, return the new buffer object */ 34434c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore 34534c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore acpi_ut_remove_reference(return_object); 34634c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore *return_object_ptr = buffer_object; 34734c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore 34829a241cc02110b8b2259fd72719b8cadc03909beBob Moore info->return_flags |= ACPI_OBJECT_REPAIRED; 34934c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore return (AE_OK); 35077b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore} 35177b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 35277b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore/****************************************************************************** 35377b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * 35477b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * FUNCTION: acpi_ns_repair_CID 35577b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * 35629a241cc02110b8b2259fd72719b8cadc03909beBob Moore * PARAMETERS: info - Method execution information block 35777b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * return_object_ptr - Pointer to the object returned from the 35877b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * evaluation of a method or object 35977b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * 36077b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * RETURN: Status. AE_OK if object is OK or was repaired successfully 36177b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * 36277b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * DESCRIPTION: Repair for the _CID object. If a string, ensure that all 36377b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * letters are uppercase and that there is no leading asterisk. 36477b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * If a Package, ensure same for all string elements. 36577b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * 36677b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore *****************************************************************************/ 36777b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 36877b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moorestatic acpi_status 36929a241cc02110b8b2259fd72719b8cadc03909beBob Mooreacpi_ns_repair_CID(struct acpi_evaluate_info *info, 37077b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore union acpi_operand_object **return_object_ptr) 37177b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore{ 37277b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore acpi_status status; 37377b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore union acpi_operand_object *return_object = *return_object_ptr; 37477b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore union acpi_operand_object **element_ptr; 37577b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore union acpi_operand_object *original_element; 37677b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore u16 original_ref_count; 37777b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore u32 i; 37877b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 37977b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore /* Check for _CID as a simple string */ 38077b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 38177b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore if (return_object->common.type == ACPI_TYPE_STRING) { 38229a241cc02110b8b2259fd72719b8cadc03909beBob Moore status = acpi_ns_repair_HID(info, return_object_ptr); 38377b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore return (status); 38477b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore } 38577b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 38677b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore /* Exit if not a Package */ 38777b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 38877b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore if (return_object->common.type != ACPI_TYPE_PACKAGE) { 38977b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore return (AE_OK); 39077b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore } 39177b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 39277b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore /* Examine each element of the _CID package */ 39377b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 39477b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore element_ptr = return_object->package.elements; 39577b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore for (i = 0; i < return_object->package.count; i++) { 39677b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore original_element = *element_ptr; 39777b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore original_ref_count = original_element->common.reference_count; 39877b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 39929a241cc02110b8b2259fd72719b8cadc03909beBob Moore status = acpi_ns_repair_HID(info, element_ptr); 40077b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore if (ACPI_FAILURE(status)) { 40177b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore return (status); 40277b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore } 40377b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 40477b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore /* Take care with reference counts */ 40577b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 40677b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore if (original_element != *element_ptr) { 40777b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 40877b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore /* Element was replaced */ 40977b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 41077b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore (*element_ptr)->common.reference_count = 41177b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore original_ref_count; 41277b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 41377b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore acpi_ut_remove_reference(original_element); 41477b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore } 41577b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 41677b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore element_ptr++; 41777b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore } 41877b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 41977b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore return (AE_OK); 42077b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore} 42177b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 42277b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore/****************************************************************************** 42377b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * 4245a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng * FUNCTION: acpi_ns_repair_CST 4255a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng * 4265a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng * PARAMETERS: info - Method execution information block 4275a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng * return_object_ptr - Pointer to the object returned from the 4285a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng * evaluation of a method or object 4295a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng * 4305a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng * RETURN: Status. AE_OK if object is OK or was repaired successfully 4315a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng * 4325a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng * DESCRIPTION: Repair for the _CST object: 4335a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng * 1. Sort the list ascending by C state type 4345a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng * 2. Ensure type cannot be zero 4350a16d12a8e8df523022b458dae33dc4288d18dd1Bob Moore * 3. A subpackage count of zero means _CST is meaningless 4360a16d12a8e8df523022b458dae33dc4288d18dd1Bob Moore * 4. Count must match the number of C state subpackages 4375a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng * 4385a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng *****************************************************************************/ 4395a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng 4405a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zhengstatic acpi_status 4415a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zhengacpi_ns_repair_CST(struct acpi_evaluate_info *info, 4425a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng union acpi_operand_object **return_object_ptr) 4435a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng{ 4445a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng union acpi_operand_object *return_object = *return_object_ptr; 4455a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng union acpi_operand_object **outer_elements; 4465a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng u32 outer_element_count; 4475a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng union acpi_operand_object *obj_desc; 4485a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng acpi_status status; 4495a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng u8 removing; 4505a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng u32 i; 4515a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng 4525a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng ACPI_FUNCTION_NAME(ns_repair_CST); 4535a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng 4545a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng /* 455341e7ba1a9a48c50b46a1ebf305823f883c85d4fLv Zheng * Check if the C-state type values are proportional. 4565a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng */ 4575a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng outer_element_count = return_object->package.count - 1; 4585a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng i = 0; 4595a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng while (i < outer_element_count) { 4605a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng outer_elements = &return_object->package.elements[i + 1]; 4615a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng removing = FALSE; 4625a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng 4635a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng if ((*outer_elements)->package.count == 0) { 4645a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, 4655a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng info->node_flags, 4665a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng "SubPackage[%u] - removing entry due to zero count", 4675a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng i)); 4685a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng removing = TRUE; 4695a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng goto remove_element; 4705a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng } 4715a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng 4725a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng obj_desc = (*outer_elements)->package.elements[1]; /* Index1 = Type */ 4735a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng if ((u32)obj_desc->integer.value == 0) { 4745a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, 4755a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng info->node_flags, 4765a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng "SubPackage[%u] - removing entry due to invalid Type(0)", 4775a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng i)); 4785a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng removing = TRUE; 4795a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng } 4805a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng 48110622bf8ce432e6a53fd3c37163e99e99c9e43eeLv Zhengremove_element: 4825a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng if (removing) { 4835a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng acpi_ns_remove_element(return_object, i + 1); 4845a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng outer_element_count--; 4855a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng } else { 4865a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng i++; 4875a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng } 4885a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng } 4895a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng 4905a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng /* Update top-level package count, Type "Integer" checked elsewhere */ 4915a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng 4925a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng obj_desc = return_object->package.elements[0]; 4935a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng obj_desc->integer.value = outer_element_count; 494341e7ba1a9a48c50b46a1ebf305823f883c85d4fLv Zheng 495341e7ba1a9a48c50b46a1ebf305823f883c85d4fLv Zheng /* 496341e7ba1a9a48c50b46a1ebf305823f883c85d4fLv Zheng * Entries (subpackages) in the _CST Package must be sorted by the 497341e7ba1a9a48c50b46a1ebf305823f883c85d4fLv Zheng * C-state type, in ascending order. 498341e7ba1a9a48c50b46a1ebf305823f883c85d4fLv Zheng */ 499341e7ba1a9a48c50b46a1ebf305823f883c85d4fLv Zheng status = acpi_ns_check_sorted_list(info, return_object, 1, 4, 1, 500341e7ba1a9a48c50b46a1ebf305823f883c85d4fLv Zheng ACPI_SORT_ASCENDING, "C-State Type"); 501341e7ba1a9a48c50b46a1ebf305823f883c85d4fLv Zheng if (ACPI_FAILURE(status)) { 502341e7ba1a9a48c50b46a1ebf305823f883c85d4fLv Zheng return (status); 503341e7ba1a9a48c50b46a1ebf305823f883c85d4fLv Zheng } 504341e7ba1a9a48c50b46a1ebf305823f883c85d4fLv Zheng 5055a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng return (AE_OK); 5065a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng} 5075a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng 5085a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng/****************************************************************************** 5095a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng * 51077b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * FUNCTION: acpi_ns_repair_HID 51177b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * 51229a241cc02110b8b2259fd72719b8cadc03909beBob Moore * PARAMETERS: info - Method execution information block 51377b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * return_object_ptr - Pointer to the object returned from the 51477b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * evaluation of a method or object 51577b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * 51677b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * RETURN: Status. AE_OK if object is OK or was repaired successfully 51777b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * 51877b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * DESCRIPTION: Repair for the _HID object. If a string, ensure that all 51977b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * letters are uppercase and that there is no leading asterisk. 52077b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * 52177b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore *****************************************************************************/ 52277b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 52377b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moorestatic acpi_status 52429a241cc02110b8b2259fd72719b8cadc03909beBob Mooreacpi_ns_repair_HID(struct acpi_evaluate_info *info, 52577b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore union acpi_operand_object **return_object_ptr) 52677b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore{ 52777b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore union acpi_operand_object *return_object = *return_object_ptr; 52877b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore union acpi_operand_object *new_string; 52977b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore char *source; 53077b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore char *dest; 53177b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 53277b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore ACPI_FUNCTION_NAME(ns_repair_HID); 53377b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 53477b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore /* We only care about string _HID objects (not integers) */ 53577b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 53677b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore if (return_object->common.type != ACPI_TYPE_STRING) { 53777b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore return (AE_OK); 53877b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore } 53977b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 54077b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore if (return_object->string.length == 0) { 54129a241cc02110b8b2259fd72719b8cadc03909beBob Moore ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, 54229a241cc02110b8b2259fd72719b8cadc03909beBob Moore info->node_flags, 54377b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore "Invalid zero-length _HID or _CID string")); 54477b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 54577b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore /* Return AE_OK anyway, let driver handle it */ 54677b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 54729a241cc02110b8b2259fd72719b8cadc03909beBob Moore info->return_flags |= ACPI_OBJECT_REPAIRED; 54877b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore return (AE_OK); 54977b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore } 55077b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 55177b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore /* It is simplest to always create a new string object */ 55277b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 55377b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore new_string = acpi_ut_create_string_object(return_object->string.length); 55477b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore if (!new_string) { 55577b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore return (AE_NO_MEMORY); 55677b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore } 55777b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 55877b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore /* 55977b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * Remove a leading asterisk if present. For some unknown reason, there 56077b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * are many machines in the field that contains IDs like this. 56177b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * 56277b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * Examples: "*PNP0C03", "*ACPI0003" 56377b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore */ 56477b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore source = return_object->string.pointer; 56577b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore if (*source == '*') { 56677b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore source++; 56777b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore new_string->string.length--; 56877b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 56977b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, 57077b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore "%s: Removed invalid leading asterisk\n", 57129a241cc02110b8b2259fd72719b8cadc03909beBob Moore info->full_pathname)); 57277b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore } 57377b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 57477b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore /* 5757fce7a4b0db7d90db553faf568853d56cd908c39Bob Moore * Copy and uppercase the string. From the ACPI 5.0 specification: 57677b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * 57777b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * A valid PNP ID must be of the form "AAA####" where A is an uppercase 57877b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore * letter and # is a hex digit. A valid ACPI ID must be of the form 5797fce7a4b0db7d90db553faf568853d56cd908c39Bob Moore * "NNNN####" where N is an uppercase letter or decimal digit, and 5807fce7a4b0db7d90db553faf568853d56cd908c39Bob Moore * # is a hex digit. 58177b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore */ 58277b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore for (dest = new_string->string.pointer; *source; dest++, source++) { 58377b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore *dest = (char)ACPI_TOUPPER(*source); 58477b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore } 58577b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore 58677b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore acpi_ut_remove_reference(return_object); 58777b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore *return_object_ptr = new_string; 58877b23f712bc40a65160e7d02b045f1562bb43ff1Bob Moore return (AE_OK); 58934c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore} 59034c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore 59134c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore/****************************************************************************** 59234c39c755347c1ca3d06284bad2273c6a9c3108aBob Moore * 593aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng * FUNCTION: acpi_ns_repair_PRT 594ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 59529a241cc02110b8b2259fd72719b8cadc03909beBob Moore * PARAMETERS: info - Method execution information block 596ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * return_object_ptr - Pointer to the object returned from the 597ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * evaluation of a method or object 598ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 599ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * RETURN: Status. AE_OK if object is OK or was repaired successfully 600ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 601aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng * DESCRIPTION: Repair for the _PRT object. If necessary, fix reversed 602aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng * source_name and source_index field, a common BIOS bug. 603ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 604ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore *****************************************************************************/ 605ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 606ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moorestatic acpi_status 607aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zhengacpi_ns_repair_PRT(struct acpi_evaluate_info *info, 608ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore union acpi_operand_object **return_object_ptr) 609ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore{ 610aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng union acpi_operand_object *package_object = *return_object_ptr; 611aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng union acpi_operand_object **top_object_list; 612aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng union acpi_operand_object **sub_object_list; 613aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng union acpi_operand_object *obj_desc; 6141c3c2a545dc06e606c6cbbcb7ab722bf3b2cb668Bob Moore union acpi_operand_object *sub_package; 615aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng u32 element_count; 616aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng u32 index; 6178f9c91273e36e5762c617c23e4fd48d5172e0dacFenghua Yu 618aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng /* Each element in the _PRT package is a subpackage */ 619ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 620aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng top_object_list = package_object->package.elements; 621aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng element_count = package_object->package.count; 622ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 62369e6bb6898df3589bde7655aae26e254792a2d80Bob Moore /* Examine each subpackage */ 62469e6bb6898df3589bde7655aae26e254792a2d80Bob Moore 62569e6bb6898df3589bde7655aae26e254792a2d80Bob Moore for (index = 0; index < element_count; index++, top_object_list++) { 6261c3c2a545dc06e606c6cbbcb7ab722bf3b2cb668Bob Moore sub_package = *top_object_list; 6271c3c2a545dc06e606c6cbbcb7ab722bf3b2cb668Bob Moore sub_object_list = sub_package->package.elements; 6281c3c2a545dc06e606c6cbbcb7ab722bf3b2cb668Bob Moore 62969e6bb6898df3589bde7655aae26e254792a2d80Bob Moore /* Check for minimum required element count */ 63069e6bb6898df3589bde7655aae26e254792a2d80Bob Moore 63169e6bb6898df3589bde7655aae26e254792a2d80Bob Moore if (sub_package->package.count < 4) { 63269e6bb6898df3589bde7655aae26e254792a2d80Bob Moore continue; 6331c3c2a545dc06e606c6cbbcb7ab722bf3b2cb668Bob Moore } 634aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng 635aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng /* 636aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng * If the BIOS has erroneously reversed the _PRT source_name (index 2) 637aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng * and the source_index (index 3), fix it. _PRT is important enough to 638aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng * workaround this BIOS error. This also provides compatibility with 639aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng * other ACPI implementations. 640aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng */ 641aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng obj_desc = sub_object_list[3]; 642aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng if (!obj_desc || (obj_desc->common.type != ACPI_TYPE_INTEGER)) { 643aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng sub_object_list[3] = sub_object_list[2]; 644aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng sub_object_list[2] = obj_desc; 645aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng info->return_flags |= ACPI_OBJECT_REPAIRED; 646aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng 64769e6bb6898df3589bde7655aae26e254792a2d80Bob Moore ACPI_WARN_PREDEFINED((AE_INFO, 64869e6bb6898df3589bde7655aae26e254792a2d80Bob Moore info->full_pathname, 649aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng info->node_flags, 650aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng "PRT[%X]: Fixed reversed SourceName and SourceIndex", 651aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng index)); 652aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng } 653aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng } 654aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng 655aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng return (AE_OK); 656ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore} 657ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 658ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore/****************************************************************************** 659ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 660ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * FUNCTION: acpi_ns_repair_PSS 661ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 66229a241cc02110b8b2259fd72719b8cadc03909beBob Moore * PARAMETERS: info - Method execution information block 663ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * return_object_ptr - Pointer to the object returned from the 664ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * evaluation of a method or object 665ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 666ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * RETURN: Status. AE_OK if object is OK or was repaired successfully 667ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 668ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * DESCRIPTION: Repair for the _PSS object. If necessary, sort the object list 669ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * by the CPU frequencies. Check that the power dissipation values 670ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * are all proportional to CPU frequency (i.e., sorting by 671ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * frequency should be the same as sorting by power.) 672ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 673ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore *****************************************************************************/ 674ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 675ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moorestatic acpi_status 67629a241cc02110b8b2259fd72719b8cadc03909beBob Mooreacpi_ns_repair_PSS(struct acpi_evaluate_info *info, 677ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore union acpi_operand_object **return_object_ptr) 678ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore{ 679ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore union acpi_operand_object *return_object = *return_object_ptr; 680ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore union acpi_operand_object **outer_elements; 681ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore u32 outer_element_count; 682ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore union acpi_operand_object **elements; 683ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore union acpi_operand_object *obj_desc; 684ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore u32 previous_value; 685ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore acpi_status status; 686ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore u32 i; 687ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 688ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore /* 6890a16d12a8e8df523022b458dae33dc4288d18dd1Bob Moore * Entries (subpackages) in the _PSS Package must be sorted by power 690ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * dissipation, in descending order. If it appears that the list is 691ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * incorrectly sorted, sort it. We sort by cpu_frequency, since this 692ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * should be proportional to the power. 693ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore */ 6945a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng status = acpi_ns_check_sorted_list(info, return_object, 0, 6, 0, 695ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore ACPI_SORT_DESCENDING, 696ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore "CpuFrequency"); 697ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore if (ACPI_FAILURE(status)) { 698ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore return (status); 699ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore } 700ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 701ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore /* 702ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * We now know the list is correctly sorted by CPU frequency. Check if 703ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * the power dissipation values are proportional. 704ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore */ 705ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore previous_value = ACPI_UINT32_MAX; 706ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore outer_elements = return_object->package.elements; 707ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore outer_element_count = return_object->package.count; 708ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 709ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore for (i = 0; i < outer_element_count; i++) { 710ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore elements = (*outer_elements)->package.elements; 711ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore obj_desc = elements[1]; /* Index1 = power_dissipation */ 712ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 713ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore if ((u32) obj_desc->integer.value > previous_value) { 71429a241cc02110b8b2259fd72719b8cadc03909beBob Moore ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, 71529a241cc02110b8b2259fd72719b8cadc03909beBob Moore info->node_flags, 716ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore "SubPackage[%u,%u] - suspicious power dissipation values", 717ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore i - 1, i)); 718ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore } 719ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 720ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore previous_value = (u32) obj_desc->integer.value; 721ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore outer_elements++; 722ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore } 723ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 724ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore return (AE_OK); 725ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore} 726ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 727ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore/****************************************************************************** 728ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 729aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng * FUNCTION: acpi_ns_repair_TSS 730aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng * 731aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng * PARAMETERS: info - Method execution information block 732aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng * return_object_ptr - Pointer to the object returned from the 733aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng * evaluation of a method or object 734aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng * 735aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng * RETURN: Status. AE_OK if object is OK or was repaired successfully 736aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng * 737aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng * DESCRIPTION: Repair for the _TSS object. If necessary, sort the object list 738aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng * descending by the power dissipation values. 739aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng * 740aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng *****************************************************************************/ 741aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng 742aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zhengstatic acpi_status 743aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zhengacpi_ns_repair_TSS(struct acpi_evaluate_info *info, 744aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng union acpi_operand_object **return_object_ptr) 745aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng{ 746aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng union acpi_operand_object *return_object = *return_object_ptr; 747aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng acpi_status status; 748aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng struct acpi_namespace_node *node; 749aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng 750aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng /* 751aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng * We can only sort the _TSS return package if there is no _PSS in the 752aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng * same scope. This is because if _PSS is present, the ACPI specification 753aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng * dictates that the _TSS Power Dissipation field is to be ignored, and 754aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng * therefore some BIOSs leave garbage values in the _TSS Power field(s). 755aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng * In this case, it is best to just return the _TSS package as-is. 756aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng * (May, 2011) 757aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng */ 758aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng status = acpi_ns_get_node(info->node, "^_PSS", 759aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng ACPI_NS_NO_UPSEARCH, &node); 760aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng if (ACPI_SUCCESS(status)) { 761aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng return (AE_OK); 762aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng } 763aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng 7645a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng status = acpi_ns_check_sorted_list(info, return_object, 0, 5, 1, 765aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng ACPI_SORT_DESCENDING, 766aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng "PowerDissipation"); 767aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng 768aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng return (status); 769aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng} 770aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng 771aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng/****************************************************************************** 772aa6329c44bccedbd8b17094c1c1aee1d9a9de461Lv Zheng * 773ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * FUNCTION: acpi_ns_check_sorted_list 774ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 77529a241cc02110b8b2259fd72719b8cadc03909beBob Moore * PARAMETERS: info - Method execution information block 776ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * return_object - Pointer to the top-level returned object 7770a16d12a8e8df523022b458dae33dc4288d18dd1Bob Moore * start_index - Index of the first subpackage 7780a16d12a8e8df523022b458dae33dc4288d18dd1Bob Moore * expected_count - Minimum length of each subpackage 7790a16d12a8e8df523022b458dae33dc4288d18dd1Bob Moore * sort_index - Subpackage entry to sort on 780ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * sort_direction - Ascending or descending 781ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * sort_key_name - Name of the sort_index field 782ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 783ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * RETURN: Status. AE_OK if the list is valid and is sorted correctly or 784ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * has been repaired by sorting the list. 785ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 786ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * DESCRIPTION: Check if the package list is valid and sorted correctly by the 787ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * sort_index. If not, then sort the list. 788ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 789ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore *****************************************************************************/ 790ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 791ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moorestatic acpi_status 79229a241cc02110b8b2259fd72719b8cadc03909beBob Mooreacpi_ns_check_sorted_list(struct acpi_evaluate_info *info, 793ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore union acpi_operand_object *return_object, 7945a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng u32 start_index, 795ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore u32 expected_count, 796ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore u32 sort_index, 797ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore u8 sort_direction, char *sort_key_name) 798ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore{ 799ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore u32 outer_element_count; 800ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore union acpi_operand_object **outer_elements; 801ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore union acpi_operand_object **elements; 802ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore union acpi_operand_object *obj_desc; 803ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore u32 i; 804ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore u32 previous_value; 805ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 8063a58176e4fa47d8232e04131b023f3f2ecd7084bBob Moore ACPI_FUNCTION_NAME(ns_check_sorted_list); 8073a58176e4fa47d8232e04131b023f3f2ecd7084bBob Moore 808ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore /* The top-level object must be a package */ 809ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 810ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore if (return_object->common.type != ACPI_TYPE_PACKAGE) { 811ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore return (AE_AML_OPERAND_TYPE); 812ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore } 813ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 814ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore /* 8150a16d12a8e8df523022b458dae33dc4288d18dd1Bob Moore * NOTE: assumes list of subpackages contains no NULL elements. 816d4085a3ffee8828f7f1bae7fa3cf5e58f59ba627Bob Moore * Any NULL elements should have been removed by earlier call 817d4085a3ffee8828f7f1bae7fa3cf5e58f59ba627Bob Moore * to acpi_ns_remove_null_elements. 818ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore */ 819ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore outer_element_count = return_object->package.count; 8205a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng if (!outer_element_count || start_index >= outer_element_count) { 821ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore return (AE_AML_PACKAGE_LIMIT); 822ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore } 823ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 8245a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng outer_elements = &return_object->package.elements[start_index]; 8255a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng outer_element_count -= start_index; 8265a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng 827ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore previous_value = 0; 828ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore if (sort_direction == ACPI_SORT_DESCENDING) { 829ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore previous_value = ACPI_UINT32_MAX; 830ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore } 831ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 832ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore /* Examine each subpackage */ 833ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 834ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore for (i = 0; i < outer_element_count; i++) { 835ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 836ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore /* Each element of the top-level package must also be a package */ 837ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 838ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore if ((*outer_elements)->common.type != ACPI_TYPE_PACKAGE) { 839ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore return (AE_AML_OPERAND_TYPE); 840ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore } 841ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 8420a16d12a8e8df523022b458dae33dc4288d18dd1Bob Moore /* Each subpackage must have the minimum length */ 843ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 844ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore if ((*outer_elements)->package.count < expected_count) { 845ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore return (AE_AML_PACKAGE_LIMIT); 846ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore } 847ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 848ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore elements = (*outer_elements)->package.elements; 849ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore obj_desc = elements[sort_index]; 850ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 851ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore if (obj_desc->common.type != ACPI_TYPE_INTEGER) { 852ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore return (AE_AML_OPERAND_TYPE); 853ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore } 854ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 855ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore /* 856ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * The list must be sorted in the specified order. If we detect a 8572147d3f00f85c9e993786863d8138694672da01bBob Moore * discrepancy, sort the entire list. 858ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore */ 859ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore if (((sort_direction == ACPI_SORT_ASCENDING) && 860ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore (obj_desc->integer.value < previous_value)) || 861ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore ((sort_direction == ACPI_SORT_DESCENDING) && 862ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore (obj_desc->integer.value > previous_value))) { 8635a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng acpi_ns_sort_list(&return_object->package. 8645a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng elements[start_index], 8652147d3f00f85c9e993786863d8138694672da01bBob Moore outer_element_count, sort_index, 8662147d3f00f85c9e993786863d8138694672da01bBob Moore sort_direction); 867ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 86829a241cc02110b8b2259fd72719b8cadc03909beBob Moore info->return_flags |= ACPI_OBJECT_REPAIRED; 869ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 8703a58176e4fa47d8232e04131b023f3f2ecd7084bBob Moore ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, 8713a58176e4fa47d8232e04131b023f3f2ecd7084bBob Moore "%s: Repaired unsorted list - now sorted by %s\n", 87229a241cc02110b8b2259fd72719b8cadc03909beBob Moore info->full_pathname, sort_key_name)); 873ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore return (AE_OK); 874ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore } 875ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 876ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore previous_value = (u32) obj_desc->integer.value; 877ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore outer_elements++; 878ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore } 879ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 880ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore return (AE_OK); 881ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore} 882ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 883ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore/****************************************************************************** 884ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 885ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * FUNCTION: acpi_ns_sort_list 886ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 887ba494beeaa69bc0fb01eb89464ad5d57d26e3901Bob Moore * PARAMETERS: elements - Package object element list 888ba494beeaa69bc0fb01eb89464ad5d57d26e3901Bob Moore * count - Element count for above 889ba494beeaa69bc0fb01eb89464ad5d57d26e3901Bob Moore * index - Sort by which package element 890ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * sort_direction - Ascending or Descending sort 891ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 8922147d3f00f85c9e993786863d8138694672da01bBob Moore * RETURN: None 893ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 894ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * DESCRIPTION: Sort the objects that are in a package element list. 895ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 8962147d3f00f85c9e993786863d8138694672da01bBob Moore * NOTE: Assumes that all NULL elements have been removed from the package, 8972147d3f00f85c9e993786863d8138694672da01bBob Moore * and that all elements have been verified to be of type Integer. 898ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore * 899ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore *****************************************************************************/ 900ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 9012147d3f00f85c9e993786863d8138694672da01bBob Moorestatic void 902ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Mooreacpi_ns_sort_list(union acpi_operand_object **elements, 903ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore u32 count, u32 index, u8 sort_direction) 904ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore{ 905ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore union acpi_operand_object *obj_desc1; 906ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore union acpi_operand_object *obj_desc2; 907ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore union acpi_operand_object *temp_obj; 908ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore u32 i; 909ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore u32 j; 910ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 911ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore /* Simple bubble sort */ 912ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 913ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore for (i = 1; i < count; i++) { 914ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore for (j = (count - 1); j >= i; j--) { 915ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore obj_desc1 = elements[j - 1]->package.elements[index]; 916ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore obj_desc2 = elements[j]->package.elements[index]; 917ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore 918ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore if (((sort_direction == ACPI_SORT_ASCENDING) && 919ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore (obj_desc1->integer.value > 920ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore obj_desc2->integer.value)) 921ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore || ((sort_direction == ACPI_SORT_DESCENDING) 922ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore && (obj_desc1->integer.value < 923ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore obj_desc2->integer.value))) { 924ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore temp_obj = elements[j - 1]; 925ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore elements[j - 1] = elements[j]; 926ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore elements[j] = temp_obj; 927ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore } 928ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore } 929ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore } 930ad5babeed8d3082406c5b67ae558b95a479ddb6fBob Moore} 9315a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng 9325a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng/****************************************************************************** 9335a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng * 9345a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng * FUNCTION: acpi_ns_remove_element 9355a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng * 9365a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng * PARAMETERS: obj_desc - Package object element list 9375a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng * index - Index of element to remove 9385a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng * 9395a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng * RETURN: None 9405a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng * 9415a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng * DESCRIPTION: Remove the requested element of a package and delete it. 9425a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng * 9435a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng *****************************************************************************/ 9445a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng 9455a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zhengstatic void 9465a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zhengacpi_ns_remove_element(union acpi_operand_object *obj_desc, u32 index) 9475a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng{ 9485a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng union acpi_operand_object **source; 9495a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng union acpi_operand_object **dest; 9505a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng u32 count; 9515a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng u32 new_count; 9525a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng u32 i; 9535a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng 9545a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng ACPI_FUNCTION_NAME(ns_remove_element); 9555a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng 9565a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng count = obj_desc->package.count; 9575a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng new_count = count - 1; 9585a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng 9595a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng source = obj_desc->package.elements; 9605a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng dest = source; 9615a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng 9625a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng /* Examine all elements of the package object, remove matched index */ 9635a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng 9645a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng for (i = 0; i < count; i++) { 9655a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng if (i == index) { 9665a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng acpi_ut_remove_reference(*source); /* Remove one ref for being in pkg */ 9675a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng acpi_ut_remove_reference(*source); 9685a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng } else { 9695a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng *dest = *source; 9705a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng dest++; 9715a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng } 9725a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng source++; 9735a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng } 9745a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng 9755a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng /* NULL terminate list and update the package count */ 9765a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng 9775a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng *dest = NULL; 9785a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng obj_desc->package.count = new_count; 9795a9792f3be74bfad2985b3f4c7afc9e6f6a3f798Lv Zheng} 980