^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Module Name: nsrepair - Repair for objects returned by predefined methods
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2000 - 2020, Intel Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <acpi/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include "accommon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "acnamesp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "acinterp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "acpredef.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "amlresrc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define _COMPONENT ACPI_NAMESPACE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) ACPI_MODULE_NAME("nsrepair")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * This module attempts to repair or convert objects returned by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * predefined methods to an object type that is expected, as per the ACPI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * specification. The need for this code is dictated by the many machines that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * return incorrect types for the standard predefined methods. Performing these
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * conversions here, in one place, eliminates the need for individual ACPI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * device drivers to do the same. Note: Most of these conversions are different
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * than the internal object conversion routines used for implicit object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * conversion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * The following conversions can be performed as necessary:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * Integer -> String
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * Integer -> Buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * String -> Integer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * String -> Buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * Buffer -> Integer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * Buffer -> String
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * Buffer -> Package of Integers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * Package -> Package of one Package
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * Additional conversions that are available:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * Convert a null return or zero return value to an end_tag descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * Convert an ASCII string to a Unicode buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * An incorrect standalone object is wrapped with required outer package
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * Additional possible repairs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * Required package elements that are NULL replaced by Integer/String/Buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) /* Local prototypes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) static const struct acpi_simple_repair_info *acpi_ns_match_simple_repair(struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) acpi_namespace_node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) *node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) return_btype,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) package_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * Special but simple repairs for some names.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * 2nd argument: Unexpected types that can be repaired
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) static const struct acpi_simple_repair_info acpi_object_repair_info[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) /* Resource descriptor conversions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) {"_CRS",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) ACPI_RTYPE_NONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) ACPI_NOT_PACKAGE_ELEMENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) acpi_ns_convert_to_resource},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) {"_DMA",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) ACPI_RTYPE_NONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) ACPI_NOT_PACKAGE_ELEMENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) acpi_ns_convert_to_resource},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) {"_PRS",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) ACPI_RTYPE_NONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) ACPI_NOT_PACKAGE_ELEMENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) acpi_ns_convert_to_resource},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) /* Object reference conversions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) {"_DEP", ACPI_RTYPE_STRING, ACPI_ALL_PACKAGE_ELEMENTS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) acpi_ns_convert_to_reference},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) /* Unicode conversions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) {"_MLS", ACPI_RTYPE_STRING, 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) acpi_ns_convert_to_unicode},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) {"_STR", ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) ACPI_NOT_PACKAGE_ELEMENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) acpi_ns_convert_to_unicode},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) {{0, 0, 0, 0}, 0, 0, NULL} /* Table terminator */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * FUNCTION: acpi_ns_simple_repair
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * PARAMETERS: info - Method execution information block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * expected_btypes - Object types expected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) * package_index - Index of object within parent package (if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * applicable - ACPI_NOT_PACKAGE_ELEMENT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) * otherwise)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * return_object_ptr - Pointer to the object returned from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) * evaluation of a method or object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) * RETURN: Status. AE_OK if repair was successful.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) * DESCRIPTION: Attempt to repair/convert a return object of a type that was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) * not expected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) acpi_ns_simple_repair(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) u32 expected_btypes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) u32 package_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) union acpi_operand_object **return_object_ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) union acpi_operand_object *return_object = *return_object_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) union acpi_operand_object *new_object = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) const struct acpi_simple_repair_info *predefined;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) ACPI_FUNCTION_NAME(ns_simple_repair);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) * Special repairs for certain names that are in the repair table.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) * Check if this name is in the list of repairable names.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) predefined = acpi_ns_match_simple_repair(info->node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) info->return_btype,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) package_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) if (predefined) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) if (!return_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) ACPI_WARN_ALWAYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) "Missing expected return value"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) status = predefined->object_converter(info->node, return_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) &new_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) /* A fatal error occurred during a conversion */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) ACPI_EXCEPTION((AE_INFO, status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) "During return object analysis"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) if (new_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) goto object_repaired;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) * Do not perform simple object repair unless the return type is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) * expected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) if (info->return_btype & expected_btypes) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) * At this point, we know that the type of the returned object was not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) * one of the expected types for this predefined name. Attempt to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) * repair the object by converting it to one of the expected object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) * types for this predefined name.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) * If there is no return value, check if we require a return value for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) * this predefined name. Either one return value is expected, or none,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) * for both methods and other objects.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) * Try to fix if there was no return object. Warning if failed to fix.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) if (!return_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) if (expected_btypes && (!(expected_btypes & ACPI_RTYPE_NONE))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) if (package_index != ACPI_NOT_PACKAGE_ELEMENT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) ACPI_WARN_PREDEFINED((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) info->full_pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) ACPI_WARN_ALWAYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) "Found unexpected NULL package element"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) acpi_ns_repair_null_element(info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) expected_btypes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) package_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) return_object_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) if (ACPI_SUCCESS(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) return (AE_OK); /* Repair was successful */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) ACPI_WARN_PREDEFINED((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) info->full_pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) ACPI_WARN_ALWAYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) "Missing expected return value"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) return (AE_AML_NO_RETURN_VALUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) if (expected_btypes & ACPI_RTYPE_INTEGER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) status = acpi_ns_convert_to_integer(return_object, &new_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) if (ACPI_SUCCESS(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) goto object_repaired;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) if (expected_btypes & ACPI_RTYPE_STRING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) status = acpi_ns_convert_to_string(return_object, &new_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) if (ACPI_SUCCESS(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) goto object_repaired;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) if (expected_btypes & ACPI_RTYPE_BUFFER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) status = acpi_ns_convert_to_buffer(return_object, &new_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) if (ACPI_SUCCESS(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) goto object_repaired;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) if (expected_btypes & ACPI_RTYPE_PACKAGE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) * A package is expected. We will wrap the existing object with a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) * new package object. It is often the case that if a variable-length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) * package is required, but there is only a single object needed, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) * BIOS will return that object instead of wrapping it with a Package
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) * object. Note: after the wrapping, the package will be validated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) * for correct contents (expected object type or types).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) acpi_ns_wrap_with_package(info, return_object, &new_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) if (ACPI_SUCCESS(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) * The original object just had its reference count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) * incremented for being inserted into the new package.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) *return_object_ptr = new_object; /* New Package object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) info->return_flags |= ACPI_OBJECT_REPAIRED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) /* We cannot repair this object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) return (AE_AML_OPERAND_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) object_repaired:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) /* Object was successfully repaired */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) if (package_index != ACPI_NOT_PACKAGE_ELEMENT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) /* Update reference count of new object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) if (!(info->return_flags & ACPI_OBJECT_WRAPPED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) new_object->common.reference_count =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) return_object->common.reference_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) "%s: Converted %s to expected %s at Package index %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) info->full_pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) acpi_ut_get_object_type_name(return_object),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) acpi_ut_get_object_type_name(new_object),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) package_index));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) "%s: Converted %s to expected %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) info->full_pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) acpi_ut_get_object_type_name(return_object),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) acpi_ut_get_object_type_name(new_object)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) /* Delete old object, install the new return object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) acpi_ut_remove_reference(return_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) *return_object_ptr = new_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) info->return_flags |= ACPI_OBJECT_REPAIRED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) * FUNCTION: acpi_ns_match_simple_repair
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) * PARAMETERS: node - Namespace node for the method/object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) * return_btype - Object type that was returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) * package_index - Index of object within parent package (if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) * applicable - ACPI_NOT_PACKAGE_ELEMENT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) * otherwise)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) * RETURN: Pointer to entry in repair table. NULL indicates not found.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) * DESCRIPTION: Check an object name against the repairable object list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) static const struct acpi_simple_repair_info *acpi_ns_match_simple_repair(struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) acpi_namespace_node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) *node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) return_btype,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) package_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) const struct acpi_simple_repair_info *this_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) /* Search info table for a repairable predefined method/object name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) this_name = acpi_object_repair_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) while (this_name->object_converter) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) if (ACPI_COMPARE_NAMESEG(node->name.ascii, this_name->name)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) /* Check if we can actually repair this name/type combination */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) if ((return_btype & this_name->unexpected_btypes) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) (this_name->package_index ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) ACPI_ALL_PACKAGE_ELEMENTS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) || package_index == this_name->package_index)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) return (this_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) return (NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) this_name++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) return (NULL); /* Name was not found in the repair table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) * FUNCTION: acpi_ns_repair_null_element
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) * PARAMETERS: info - Method execution information block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) * expected_btypes - Object types expected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) * package_index - Index of object within parent package (if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) * applicable - ACPI_NOT_PACKAGE_ELEMENT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) * otherwise)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) * return_object_ptr - Pointer to the object returned from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) * evaluation of a method or object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) * RETURN: Status. AE_OK if repair was successful.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) * DESCRIPTION: Attempt to repair a NULL element of a returned Package object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) acpi_ns_repair_null_element(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) u32 expected_btypes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) u32 package_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) union acpi_operand_object **return_object_ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) union acpi_operand_object *return_object = *return_object_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) union acpi_operand_object *new_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) ACPI_FUNCTION_NAME(ns_repair_null_element);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) /* No repair needed if return object is non-NULL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) if (return_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) * Attempt to repair a NULL element of a Package object. This applies to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) * predefined names that return a fixed-length package and each element
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) * is required. It does not apply to variable-length packages where NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) * elements are allowed, especially at the end of the package.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) if (expected_btypes & ACPI_RTYPE_INTEGER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) /* Need an integer - create a zero-value integer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) new_object = acpi_ut_create_integer_object((u64)0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) } else if (expected_btypes & ACPI_RTYPE_STRING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) /* Need a string - create a NULL string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) new_object = acpi_ut_create_string_object(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) } else if (expected_btypes & ACPI_RTYPE_BUFFER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) /* Need a buffer - create a zero-length buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) new_object = acpi_ut_create_buffer_object(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) /* Error for all other expected types */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) return (AE_AML_OPERAND_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) if (!new_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) return (AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) /* Set the reference count according to the parent Package object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) new_object->common.reference_count =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) info->parent_package->common.reference_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) "%s: Converted NULL package element to expected %s at index %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) info->full_pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) acpi_ut_get_object_type_name(new_object),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) package_index));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) *return_object_ptr = new_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) info->return_flags |= ACPI_OBJECT_REPAIRED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) * FUNCTION: acpi_ns_remove_null_elements
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) * PARAMETERS: info - Method execution information block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) * package_type - An acpi_return_package_types value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) * obj_desc - A Package object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) * RETURN: None.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) * DESCRIPTION: Remove all NULL package elements from packages that contain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) * a variable number of subpackages. For these types of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) * packages, NULL elements can be safely removed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) acpi_ns_remove_null_elements(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) u8 package_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) union acpi_operand_object *obj_desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) union acpi_operand_object **source;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) union acpi_operand_object **dest;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) u32 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) u32 new_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) ACPI_FUNCTION_NAME(ns_remove_null_elements);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) * We can safely remove all NULL elements from these package types:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) * PTYPE1_VAR packages contain a variable number of simple data types.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) * PTYPE2 packages contain a variable number of subpackages.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) switch (package_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) case ACPI_PTYPE1_VAR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) case ACPI_PTYPE2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) case ACPI_PTYPE2_COUNT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) case ACPI_PTYPE2_PKG_COUNT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) case ACPI_PTYPE2_FIXED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) case ACPI_PTYPE2_MIN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) case ACPI_PTYPE2_REV_FIXED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) case ACPI_PTYPE2_FIX_VAR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) case ACPI_PTYPE2_VAR_VAR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) case ACPI_PTYPE1_FIXED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) case ACPI_PTYPE1_OPTION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) count = obj_desc->package.count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) new_count = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) source = obj_desc->package.elements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) dest = source;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) /* Examine all elements of the package object, remove nulls */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) for (i = 0; i < count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) if (!*source) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) new_count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) *dest = *source;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) dest++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) source++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) /* Update parent package if any null elements were removed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) if (new_count < count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) "%s: Found and removed %u NULL elements\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) info->full_pathname, (count - new_count)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) /* NULL terminate list and update the package count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) *dest = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) obj_desc->package.count = new_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) * FUNCTION: acpi_ns_wrap_with_package
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) * PARAMETERS: info - Method execution information block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) * original_object - Pointer to the object to repair.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) * obj_desc_ptr - The new package object is returned here
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) * RETURN: Status, new object in *obj_desc_ptr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) * DESCRIPTION: Repair a common problem with objects that are defined to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) * return a variable-length Package of sub-objects. If there is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) * only one sub-object, some BIOS code mistakenly simply declares
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) * the single object instead of a Package with one sub-object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) * This function attempts to repair this error by wrapping a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) * Package object around the original object, creating the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) * correct and expected Package with one sub-object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) * Names that can be repaired in this manner include:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) * _ALR, _CSD, _HPX, _MLS, _PLD, _PRT, _PSS, _TRT, _TSS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) * _BCL, _DOD, _FIX, _Sx
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) acpi_ns_wrap_with_package(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) union acpi_operand_object *original_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) union acpi_operand_object **obj_desc_ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) union acpi_operand_object *pkg_obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) ACPI_FUNCTION_NAME(ns_wrap_with_package);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) * Create the new outer package and populate it. The new
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) * package will have a single element, the lone sub-object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) pkg_obj_desc = acpi_ut_create_package_object(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) if (!pkg_obj_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) return (AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) pkg_obj_desc->package.elements[0] = original_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) "%s: Wrapped %s with expected Package object\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) info->full_pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) acpi_ut_get_object_type_name(original_object)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) /* Return the new object in the object pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) *obj_desc_ptr = pkg_obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) info->return_flags |= ACPI_OBJECT_REPAIRED | ACPI_OBJECT_WRAPPED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) }