^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: nsrepair2 - Repair for objects returned by specific
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * predefined methods
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright (C) 2000 - 2020, Intel Corp.
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <acpi/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "accommon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "acnamesp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #define _COMPONENT ACPI_NAMESPACE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) ACPI_MODULE_NAME("nsrepair2")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * Information structure and handler for ACPI predefined names that can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * be repaired on a per-name basis.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) typedef
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) acpi_status (*acpi_repair_function) (struct acpi_evaluate_info * info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) union acpi_operand_object **
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) return_object_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) typedef struct acpi_repair_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) char name[ACPI_NAMESEG_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) acpi_repair_function repair_function;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) } acpi_repair_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) /* Local prototypes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) static const struct acpi_repair_info *acpi_ns_match_complex_repair(struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) acpi_namespace_node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) *node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) acpi_ns_repair_ALR(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) union acpi_operand_object **return_object_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) acpi_ns_repair_CID(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) union acpi_operand_object **return_object_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) acpi_ns_repair_CST(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) union acpi_operand_object **return_object_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) acpi_ns_repair_FDE(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) union acpi_operand_object **return_object_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) acpi_ns_repair_HID(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) union acpi_operand_object **return_object_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) acpi_ns_repair_PRT(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) union acpi_operand_object **return_object_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) acpi_ns_repair_PSS(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) union acpi_operand_object **return_object_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) acpi_ns_repair_TSS(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) union acpi_operand_object **return_object_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) acpi_ns_check_sorted_list(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) union acpi_operand_object *return_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) u32 start_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) u32 expected_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) u32 sort_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) u8 sort_direction, char *sort_key_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) /* Values for sort_direction above */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) #define ACPI_SORT_ASCENDING 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #define ACPI_SORT_DESCENDING 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) acpi_ns_remove_element(union acpi_operand_object *obj_desc, u32 index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) acpi_ns_sort_list(union acpi_operand_object **elements,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) u32 count, u32 index, u8 sort_direction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * This table contains the names of the predefined methods for which we can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * perform more complex repairs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) * As necessary:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * _ALR: Sort the list ascending by ambient_illuminance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * _CID: Strings: uppercase all, remove any leading asterisk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * _CST: Sort the list ascending by C state type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) * _FDE: Convert Buffer of BYTEs to a Buffer of DWORDs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * _GTM: Convert Buffer of BYTEs to a Buffer of DWORDs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * _HID: Strings: uppercase all, remove any leading asterisk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) * _PRT: Fix reversed source_name and source_index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * _PSS: Sort the list descending by Power
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * _TSS: Sort the list descending by Power
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * Names that must be packages, but cannot be sorted:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * _BCL: Values are tied to the Package index where they appear, and cannot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) * be moved or sorted. These index values are used for _BQC and _BCM.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) * However, we can fix the case where a buffer is returned, by converting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) * it to a Package of integers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) static const struct acpi_repair_info acpi_ns_repairable_names[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) {"_ALR", acpi_ns_repair_ALR},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) {"_CID", acpi_ns_repair_CID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) {"_CST", acpi_ns_repair_CST},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) {"_FDE", acpi_ns_repair_FDE},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) {"_GTM", acpi_ns_repair_FDE}, /* _GTM has same repair as _FDE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) {"_HID", acpi_ns_repair_HID},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) {"_PRT", acpi_ns_repair_PRT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) {"_PSS", acpi_ns_repair_PSS},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) {"_TSS", acpi_ns_repair_TSS},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) {{0, 0, 0, 0}, NULL} /* Table terminator */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) #define ACPI_FDE_FIELD_COUNT 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) #define ACPI_FDE_BYTE_BUFFER_SIZE 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) #define ACPI_FDE_DWORD_BUFFER_SIZE (ACPI_FDE_FIELD_COUNT * (u32) sizeof (u32))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^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) * FUNCTION: acpi_ns_complex_repairs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) * PARAMETERS: info - Method execution information block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) * node - Namespace node for the method/object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) * validate_status - Original status of earlier validation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * return_object_ptr - Pointer to the object returned from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) * evaluation of a method or object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) * RETURN: Status. AE_OK if repair was successful. If name is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) * matched, validate_status is returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) * DESCRIPTION: Attempt to repair/convert a return object of a type that was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) * not expected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) acpi_ns_complex_repairs(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) struct acpi_namespace_node *node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) acpi_status validate_status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) union acpi_operand_object **return_object_ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) const struct acpi_repair_info *predefined;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) /* Check if this name is in the list of repairable names */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) predefined = acpi_ns_match_complex_repair(node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) if (!predefined) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) return (validate_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) status = predefined->repair_function(info, return_object_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) return (status);
^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) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) * FUNCTION: acpi_ns_match_complex_repair
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) * PARAMETERS: node - Namespace node for the method/object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) * RETURN: Pointer to entry in repair table. NULL indicates not found.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) * DESCRIPTION: Check an object name against the repairable object list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) static const struct acpi_repair_info *acpi_ns_match_complex_repair(struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) acpi_namespace_node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) *node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) const struct acpi_repair_info *this_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) /* Search info table for a repairable predefined method/object name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) this_name = acpi_ns_repairable_names;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) while (this_name->repair_function) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) if (ACPI_COMPARE_NAMESEG(node->name.ascii, this_name->name)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) return (this_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) this_name++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) return (NULL); /* Not found */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) * FUNCTION: acpi_ns_repair_ALR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) * PARAMETERS: info - Method execution information block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) * return_object_ptr - Pointer to the object returned from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) * evaluation of a method or object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) * RETURN: Status. AE_OK if object is OK or was repaired successfully
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) * DESCRIPTION: Repair for the _ALR object. If necessary, sort the object list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) * ascending by the ambient illuminance values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) *
^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) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) acpi_ns_repair_ALR(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) union acpi_operand_object **return_object_ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) union acpi_operand_object *return_object = *return_object_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) status = acpi_ns_check_sorted_list(info, return_object, 0, 2, 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) ACPI_SORT_ASCENDING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) "AmbientIlluminance");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) * FUNCTION: acpi_ns_repair_FDE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) * PARAMETERS: info - Method execution information block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) * return_object_ptr - Pointer to the object returned from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) * evaluation of a method or object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) * RETURN: Status. AE_OK if object is OK or was repaired successfully
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) * DESCRIPTION: Repair for the _FDE and _GTM objects. The expected return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) * value is a Buffer of 5 DWORDs. This function repairs a common
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) * problem where the return value is a Buffer of BYTEs, not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) * DWORDs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) acpi_ns_repair_FDE(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) union acpi_operand_object **return_object_ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) union acpi_operand_object *return_object = *return_object_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) union acpi_operand_object *buffer_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) u8 *byte_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) u32 *dword_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) ACPI_FUNCTION_NAME(ns_repair_FDE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) switch (return_object->common.type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) case ACPI_TYPE_BUFFER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) /* This is the expected type. Length should be (at least) 5 DWORDs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) if (return_object->buffer.length >= ACPI_FDE_DWORD_BUFFER_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) /* We can only repair if we have exactly 5 BYTEs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) if (return_object->buffer.length != ACPI_FDE_BYTE_BUFFER_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) ACPI_WARN_PREDEFINED((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) info->full_pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) info->node_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) "Incorrect return buffer length %u, expected %u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) return_object->buffer.length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) ACPI_FDE_DWORD_BUFFER_SIZE));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) return (AE_AML_OPERAND_TYPE);
^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) /* Create the new (larger) buffer object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) buffer_object =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) acpi_ut_create_buffer_object(ACPI_FDE_DWORD_BUFFER_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) if (!buffer_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) return (AE_NO_MEMORY);
^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) /* Expand each byte to a DWORD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) byte_buffer = return_object->buffer.pointer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) dword_buffer = ACPI_CAST_PTR(u32,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) buffer_object->buffer.pointer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) for (i = 0; i < ACPI_FDE_FIELD_COUNT; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) *dword_buffer = (u32) *byte_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) dword_buffer++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) byte_buffer++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) "%s Expanded Byte Buffer to expected DWord Buffer\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) info->full_pathname));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) return (AE_AML_OPERAND_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) /* Delete the original return object, return the new buffer object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) acpi_ut_remove_reference(return_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) *return_object_ptr = buffer_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) info->return_flags |= ACPI_OBJECT_REPAIRED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) * FUNCTION: acpi_ns_repair_CID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) * PARAMETERS: info - Method execution information block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) * return_object_ptr - Pointer to the object returned from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) * evaluation of a method or object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) * RETURN: Status. AE_OK if object is OK or was repaired successfully
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) * DESCRIPTION: Repair for the _CID object. If a string, ensure that all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) * letters are uppercase and that there is no leading asterisk.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) * If a Package, ensure same for all string elements.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) *
^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) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) acpi_ns_repair_CID(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) union acpi_operand_object **return_object_ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) union acpi_operand_object *return_object = *return_object_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) union acpi_operand_object **element_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) union acpi_operand_object *original_element;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) u16 original_ref_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) /* Check for _CID as a simple string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) if (return_object->common.type == ACPI_TYPE_STRING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) status = acpi_ns_repair_HID(info, return_object_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) /* Exit if not a Package */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) if (return_object->common.type != ACPI_TYPE_PACKAGE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) /* Examine each element of the _CID package */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) element_ptr = return_object->package.elements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) for (i = 0; i < return_object->package.count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) original_element = *element_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) original_ref_count = original_element->common.reference_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) status = acpi_ns_repair_HID(info, element_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) if (original_element != *element_ptr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) /* Update reference count of new object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) (*element_ptr)->common.reference_count =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) original_ref_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) element_ptr++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) * FUNCTION: acpi_ns_repair_CST
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) * PARAMETERS: info - Method execution information block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) * return_object_ptr - Pointer to the object returned from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) * evaluation of a method or object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) * RETURN: Status. AE_OK if object is OK or was repaired successfully
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) * DESCRIPTION: Repair for the _CST object:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) * 1. Sort the list ascending by C state type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) * 2. Ensure type cannot be zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) * 3. A subpackage count of zero means _CST is meaningless
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) * 4. Count must match the number of C state subpackages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) acpi_ns_repair_CST(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) union acpi_operand_object **return_object_ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) union acpi_operand_object *return_object = *return_object_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) union acpi_operand_object **outer_elements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) u32 outer_element_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) union acpi_operand_object *obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) u8 removing;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) ACPI_FUNCTION_NAME(ns_repair_CST);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) * Check if the C-state type values are proportional.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) outer_element_count = return_object->package.count - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) while (i < outer_element_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) outer_elements = &return_object->package.elements[i + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) removing = FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) if ((*outer_elements)->package.count == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) ACPI_WARN_PREDEFINED((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) info->full_pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) info->node_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) "SubPackage[%u] - removing entry due to zero count",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) i));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) removing = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) goto remove_element;
^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) obj_desc = (*outer_elements)->package.elements[1]; /* Index1 = Type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) if ((u32)obj_desc->integer.value == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) ACPI_WARN_PREDEFINED((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) info->full_pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) info->node_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) "SubPackage[%u] - removing entry due to invalid Type(0)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) i));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) removing = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) remove_element:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) if (removing) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) acpi_ns_remove_element(return_object, i + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) outer_element_count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) i++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) /* Update top-level package count, Type "Integer" checked elsewhere */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) obj_desc = return_object->package.elements[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) obj_desc->integer.value = outer_element_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) * Entries (subpackages) in the _CST Package must be sorted by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) * C-state type, in ascending order.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) status = acpi_ns_check_sorted_list(info, return_object, 1, 4, 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) ACPI_SORT_ASCENDING, "C-State Type");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) * FUNCTION: acpi_ns_repair_HID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) * PARAMETERS: info - Method execution information block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) * return_object_ptr - Pointer to the object returned from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) * evaluation of a method or object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) * RETURN: Status. AE_OK if object is OK or was repaired successfully
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) * DESCRIPTION: Repair for the _HID object. If a string, ensure that all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) * letters are uppercase and that there is no leading asterisk.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) *
^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) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) acpi_ns_repair_HID(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) union acpi_operand_object **return_object_ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) union acpi_operand_object *return_object = *return_object_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) union acpi_operand_object *new_string;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) char *source;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) char *dest;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) ACPI_FUNCTION_NAME(ns_repair_HID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) /* We only care about string _HID objects (not integers) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) if (return_object->common.type != ACPI_TYPE_STRING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) return (AE_OK);
^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) if (return_object->string.length == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) ACPI_WARN_PREDEFINED((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) info->full_pathname, info->node_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) "Invalid zero-length _HID or _CID string"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) /* Return AE_OK anyway, let driver handle it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) info->return_flags |= ACPI_OBJECT_REPAIRED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) /* It is simplest to always create a new string object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) new_string = acpi_ut_create_string_object(return_object->string.length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) if (!new_string) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) return (AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) * Remove a leading asterisk if present. For some unknown reason, there
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) * are many machines in the field that contains IDs like this.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) * Examples: "*PNP0C03", "*ACPI0003"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) source = return_object->string.pointer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) if (*source == '*') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) source++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) new_string->string.length--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) "%s: Removed invalid leading asterisk\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) info->full_pathname));
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) * Copy and uppercase the string. From the ACPI 5.0 specification:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) * A valid PNP ID must be of the form "AAA####" where A is an uppercase
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) * letter and # is a hex digit. A valid ACPI ID must be of the form
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) * "NNNN####" where N is an uppercase letter or decimal digit, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) * # is a hex digit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) for (dest = new_string->string.pointer; *source; dest++, source++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) *dest = (char)toupper((int)*source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) acpi_ut_remove_reference(return_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) *return_object_ptr = new_string;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) * FUNCTION: acpi_ns_repair_PRT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) * PARAMETERS: info - Method execution information block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) * return_object_ptr - Pointer to the object returned from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) * evaluation of a method or object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) * RETURN: Status. AE_OK if object is OK or was repaired successfully
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) * DESCRIPTION: Repair for the _PRT object. If necessary, fix reversed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) * source_name and source_index field, a common BIOS bug.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) acpi_ns_repair_PRT(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) union acpi_operand_object **return_object_ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) union acpi_operand_object *package_object = *return_object_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) union acpi_operand_object **top_object_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) union acpi_operand_object **sub_object_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) union acpi_operand_object *obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) union acpi_operand_object *sub_package;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) u32 element_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) u32 index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) /* Each element in the _PRT package is a subpackage */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) top_object_list = package_object->package.elements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) element_count = package_object->package.count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) /* Examine each subpackage */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) for (index = 0; index < element_count; index++, top_object_list++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) sub_package = *top_object_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) sub_object_list = sub_package->package.elements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) /* Check for minimum required element count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) if (sub_package->package.count < 4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) * If the BIOS has erroneously reversed the _PRT source_name (index 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) * and the source_index (index 3), fix it. _PRT is important enough to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) * workaround this BIOS error. This also provides compatibility with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) * other ACPI implementations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) obj_desc = sub_object_list[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) if (!obj_desc || (obj_desc->common.type != ACPI_TYPE_INTEGER)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) sub_object_list[3] = sub_object_list[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) sub_object_list[2] = obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) info->return_flags |= ACPI_OBJECT_REPAIRED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) ACPI_WARN_PREDEFINED((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) info->full_pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) info->node_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) "PRT[%X]: Fixed reversed SourceName and SourceIndex",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) index));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) * FUNCTION: acpi_ns_repair_PSS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) * PARAMETERS: info - Method execution information block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) * return_object_ptr - Pointer to the object returned from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) * evaluation of a method or object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) * RETURN: Status. AE_OK if object is OK or was repaired successfully
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) * DESCRIPTION: Repair for the _PSS object. If necessary, sort the object list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) * by the CPU frequencies. Check that the power dissipation values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) * are all proportional to CPU frequency (i.e., sorting by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) * frequency should be the same as sorting by power.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) acpi_ns_repair_PSS(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) union acpi_operand_object **return_object_ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) union acpi_operand_object *return_object = *return_object_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) union acpi_operand_object **outer_elements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) u32 outer_element_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) union acpi_operand_object **elements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) union acpi_operand_object *obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) u32 previous_value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) * Entries (subpackages) in the _PSS Package must be sorted by power
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) * dissipation, in descending order. If it appears that the list is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) * incorrectly sorted, sort it. We sort by cpu_frequency, since this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) * should be proportional to the power.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) status = acpi_ns_check_sorted_list(info, return_object, 0, 6, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) ACPI_SORT_DESCENDING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) "CpuFrequency");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) * We now know the list is correctly sorted by CPU frequency. Check if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) * the power dissipation values are proportional.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) previous_value = ACPI_UINT32_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) outer_elements = return_object->package.elements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) outer_element_count = return_object->package.count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) for (i = 0; i < outer_element_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) elements = (*outer_elements)->package.elements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) obj_desc = elements[1]; /* Index1 = power_dissipation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) if ((u32)obj_desc->integer.value > previous_value) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) ACPI_WARN_PREDEFINED((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) info->full_pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) info->node_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) "SubPackage[%u,%u] - suspicious power dissipation values",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) i - 1, i));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) previous_value = (u32) obj_desc->integer.value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) outer_elements++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) * FUNCTION: acpi_ns_repair_TSS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) * PARAMETERS: info - Method execution information block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) * return_object_ptr - Pointer to the object returned from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) * evaluation of a method or object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) * RETURN: Status. AE_OK if object is OK or was repaired successfully
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) * DESCRIPTION: Repair for the _TSS object. If necessary, sort the object list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) * descending by the power dissipation values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) acpi_ns_repair_TSS(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) union acpi_operand_object **return_object_ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) union acpi_operand_object *return_object = *return_object_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) struct acpi_namespace_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) * We can only sort the _TSS return package if there is no _PSS in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) * same scope. This is because if _PSS is present, the ACPI specification
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) * dictates that the _TSS Power Dissipation field is to be ignored, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) * therefore some BIOSs leave garbage values in the _TSS Power field(s).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) * In this case, it is best to just return the _TSS package as-is.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) * (May, 2011)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) status = acpi_ns_get_node(info->node, "^_PSS",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) ACPI_NS_NO_UPSEARCH, &node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) if (ACPI_SUCCESS(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) status = acpi_ns_check_sorted_list(info, return_object, 0, 5, 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) ACPI_SORT_DESCENDING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) "PowerDissipation");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) * FUNCTION: acpi_ns_check_sorted_list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) * PARAMETERS: info - Method execution information block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) * return_object - Pointer to the top-level returned object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) * start_index - Index of the first subpackage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) * expected_count - Minimum length of each subpackage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) * sort_index - Subpackage entry to sort on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) * sort_direction - Ascending or descending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) * sort_key_name - Name of the sort_index field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) * RETURN: Status. AE_OK if the list is valid and is sorted correctly or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) * has been repaired by sorting the list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) * DESCRIPTION: Check if the package list is valid and sorted correctly by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) * sort_index. If not, then sort the list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) acpi_ns_check_sorted_list(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) union acpi_operand_object *return_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) u32 start_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) u32 expected_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) u32 sort_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) u8 sort_direction, char *sort_key_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) u32 outer_element_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) union acpi_operand_object **outer_elements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) union acpi_operand_object **elements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) union acpi_operand_object *obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) u32 previous_value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) ACPI_FUNCTION_NAME(ns_check_sorted_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) /* The top-level object must be a package */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) if (return_object->common.type != ACPI_TYPE_PACKAGE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) return (AE_AML_OPERAND_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) * NOTE: assumes list of subpackages contains no NULL elements.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) * Any NULL elements should have been removed by earlier call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) * to acpi_ns_remove_null_elements.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) outer_element_count = return_object->package.count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) if (!outer_element_count || start_index >= outer_element_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) return (AE_AML_PACKAGE_LIMIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) outer_elements = &return_object->package.elements[start_index];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) outer_element_count -= start_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) previous_value = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) if (sort_direction == ACPI_SORT_DESCENDING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) previous_value = ACPI_UINT32_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) /* Examine each subpackage */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) for (i = 0; i < outer_element_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) /* Each element of the top-level package must also be a package */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) if ((*outer_elements)->common.type != ACPI_TYPE_PACKAGE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) return (AE_AML_OPERAND_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) /* Each subpackage must have the minimum length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) if ((*outer_elements)->package.count < expected_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) return (AE_AML_PACKAGE_LIMIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) elements = (*outer_elements)->package.elements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) obj_desc = elements[sort_index];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) if (obj_desc->common.type != ACPI_TYPE_INTEGER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) return (AE_AML_OPERAND_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) * The list must be sorted in the specified order. If we detect a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) * discrepancy, sort the entire list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) if (((sort_direction == ACPI_SORT_ASCENDING) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) (obj_desc->integer.value < previous_value)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) ((sort_direction == ACPI_SORT_DESCENDING) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) (obj_desc->integer.value > previous_value))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) acpi_ns_sort_list(&return_object->package.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) elements[start_index],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) outer_element_count, sort_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) sort_direction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) info->return_flags |= ACPI_OBJECT_REPAIRED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) "%s: Repaired unsorted list - now sorted by %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) info->full_pathname, sort_key_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) previous_value = (u32) obj_desc->integer.value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) outer_elements++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) * FUNCTION: acpi_ns_sort_list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) * PARAMETERS: elements - Package object element list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) * count - Element count for above
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) * index - Sort by which package element
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) * sort_direction - Ascending or Descending sort
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) * RETURN: None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) * DESCRIPTION: Sort the objects that are in a package element list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) * NOTE: Assumes that all NULL elements have been removed from the package,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) * and that all elements have been verified to be of type Integer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) acpi_ns_sort_list(union acpi_operand_object **elements,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) u32 count, u32 index, u8 sort_direction)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) union acpi_operand_object *obj_desc1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) union acpi_operand_object *obj_desc2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) union acpi_operand_object *temp_obj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) u32 j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) /* Simple bubble sort */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) for (i = 1; i < count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) for (j = (count - 1); j >= i; j--) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) obj_desc1 = elements[j - 1]->package.elements[index];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) obj_desc2 = elements[j]->package.elements[index];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) if (((sort_direction == ACPI_SORT_ASCENDING) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) (obj_desc1->integer.value >
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) obj_desc2->integer.value))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) || ((sort_direction == ACPI_SORT_DESCENDING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) && (obj_desc1->integer.value <
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) obj_desc2->integer.value))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) temp_obj = elements[j - 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) elements[j - 1] = elements[j];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) elements[j] = temp_obj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) * FUNCTION: acpi_ns_remove_element
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) * PARAMETERS: obj_desc - Package object element list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) * index - Index of element to remove
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) * RETURN: None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) * DESCRIPTION: Remove the requested element of a package and delete it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) acpi_ns_remove_element(union acpi_operand_object *obj_desc, u32 index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) union acpi_operand_object **source;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) union acpi_operand_object **dest;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) u32 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) u32 new_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) ACPI_FUNCTION_NAME(ns_remove_element);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) count = obj_desc->package.count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) new_count = count - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) source = obj_desc->package.elements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) dest = source;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) /* Examine all elements of the package object, remove matched index */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) for (i = 0; i < count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) if (i == index) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) acpi_ut_remove_reference(*source); /* Remove one ref for being in pkg */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) acpi_ut_remove_reference(*source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) *dest = *source;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) dest++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) source++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) /* NULL terminate list and update the package count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) *dest = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) obj_desc->package.count = new_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) }