Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^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: nsprepkg - Validation of package objects for predefined names
^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 "acpredef.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("nsprepkg")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) /* Local prototypes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) acpi_ns_check_package_list(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 			   const union acpi_predefined_info *package,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 			   union acpi_operand_object **elements, u32 count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) acpi_ns_check_package_elements(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 			       union acpi_operand_object **elements,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 			       u8 type1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 			       u32 count1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 			       u8 type2, u32 count2, u32 start_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) acpi_ns_custom_package(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 		       union acpi_operand_object **elements, u32 count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * FUNCTION:    acpi_ns_check_package
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  * PARAMETERS:  info                - Method execution information block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  *              return_object_ptr   - Pointer to the object returned from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  *                                    evaluation of a method or object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  * DESCRIPTION: Check a returned package object for the correct count and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  *              correct type of all sub-objects.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) acpi_ns_check_package(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 		      union acpi_operand_object **return_object_ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	union acpi_operand_object *return_object = *return_object_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	const union acpi_predefined_info *package;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	union acpi_operand_object **elements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	u32 expected_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	u32 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	ACPI_FUNCTION_NAME(ns_check_package);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	/* The package info for this name is in the next table entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	package = info->predefined + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 			  "%s Validating return Package of Type %X, Count %X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 			  info->full_pathname, package->ret_info.type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 			  return_object->package.count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	 * For variable-length Packages, we can safely remove all embedded
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	 * and trailing NULL package elements
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	acpi_ns_remove_null_elements(info, package->ret_info.type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 				     return_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	/* Extract package count and elements array */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	elements = return_object->package.elements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	count = return_object->package.count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	 * Most packages must have at least one element. The only exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	 * is the variable-length package (ACPI_PTYPE1_VAR).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	if (!count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		if (package->ret_info.type == ACPI_PTYPE1_VAR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 			return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 				      info->node_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 				      "Return Package has no elements (empty)"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		return (AE_AML_OPERAND_VALUE);
^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) 	 * Decode the type of the expected package contents
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	 * PTYPE1 packages contain no subpackages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	 * PTYPE2 packages contain subpackages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	switch (package->ret_info.type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	case ACPI_PTYPE_CUSTOM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		status = acpi_ns_custom_package(info, elements, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	case ACPI_PTYPE1_FIXED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		 * The package count is fixed and there are no subpackages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		 * If package is too small, exit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		 * If package is larger than expected, issue warning but continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		expected_count =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		    package->ret_info.count1 + package->ret_info.count2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		if (count < expected_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 			goto package_too_small;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		} else if (count > expected_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 			ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 					  "%s: Return Package is larger than needed - "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 					  "found %u, expected %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 					  info->full_pathname, count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 					  expected_count));
^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) 		/* Validate all elements of the returned package */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		status = acpi_ns_check_package_elements(info, elements,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 							package->ret_info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 							object_type1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 							package->ret_info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 							count1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 							package->ret_info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 							object_type2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 							package->ret_info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 							count2, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	case ACPI_PTYPE1_VAR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		 * The package count is variable, there are no subpackages, and all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		 * elements must be of the same type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		for (i = 0; i < count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 			status = acpi_ns_check_object_type(info, elements,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 							   package->ret_info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 							   object_type1, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 			if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 				return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 			elements++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	case ACPI_PTYPE1_OPTION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		 * The package count is variable, there are no subpackages. There are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		 * a fixed number of required elements, and a variable number of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		 * optional elements.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		 * Check if package is at least as large as the minimum required
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		expected_count = package->ret_info3.count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		if (count < expected_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 			goto package_too_small;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		/* Variable number of sub-objects */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		for (i = 0; i < count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 			if (i < package->ret_info3.count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 				/* These are the required package elements (0, 1, or 2) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 				status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 				    acpi_ns_check_object_type(info, elements,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 							      package->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 							      ret_info3.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 							      object_type[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 							      i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 				if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 					return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 			} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 				/* These are the optional package elements */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 				status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 				    acpi_ns_check_object_type(info, elements,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 							      package->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 							      ret_info3.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 							      tail_object_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 							      i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 				if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 					return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 			elements++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	case ACPI_PTYPE2_REV_FIXED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		/* First element is the (Integer) revision */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		    acpi_ns_check_object_type(info, elements,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 					      ACPI_RTYPE_INTEGER, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 			return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		elements++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		/* Examine the subpackages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		    acpi_ns_check_package_list(info, package, elements, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	case ACPI_PTYPE2_PKG_COUNT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		/* First element is the (Integer) count of subpackages to follow */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		    acpi_ns_check_object_type(info, elements,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 					      ACPI_RTYPE_INTEGER, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 			return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		 * Count cannot be larger than the parent package length, but allow it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		 * to be smaller. The >= accounts for the Integer above.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		expected_count = (u32)(*elements)->integer.value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		if (expected_count >= count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 			goto package_too_small;
^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) 		count = expected_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		elements++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		/* Examine the subpackages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 		status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		    acpi_ns_check_package_list(info, package, elements, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	case ACPI_PTYPE2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	case ACPI_PTYPE2_FIXED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	case ACPI_PTYPE2_MIN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	case ACPI_PTYPE2_COUNT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	case ACPI_PTYPE2_FIX_VAR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 		 * These types all return a single Package that consists of a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 		 * variable number of subpackages.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 		 * First, ensure that the first element is a subpackage. If not,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		 * the BIOS may have incorrectly returned the object as a single
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 		 * package instead of a Package of Packages (a common error if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 		 * there is only one entry). We may be able to repair this by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		 * wrapping the returned Package with a new outer Package.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 		if (*elements
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 		    && ((*elements)->common.type != ACPI_TYPE_PACKAGE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 			/* Create the new outer package and populate it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 			status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 			    acpi_ns_wrap_with_package(info, return_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 						      return_object_ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 			if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 				return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 			/* Update locals to point to the new package (of 1 element) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 			return_object = *return_object_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 			elements = return_object->package.elements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 			count = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 		/* Examine the subpackages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 		status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 		    acpi_ns_check_package_list(info, package, elements, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	case ACPI_PTYPE2_VAR_VAR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 		 * Returns a variable list of packages, each with a variable list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 		 * of objects.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	case ACPI_PTYPE2_UUID_PAIR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 		/* The package must contain pairs of (UUID + type) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 		if (count & 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 			expected_count = count + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 			goto package_too_small;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 		while (count > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 			status = acpi_ns_check_object_type(info, elements,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 							   package->ret_info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 							   object_type1, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 			if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 				return (status);
^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) 			/* Validate length of the UUID buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 			if ((*elements)->buffer.length != 16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 				ACPI_WARN_PREDEFINED((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 						      info->full_pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 						      info->node_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 						      "Invalid length for UUID Buffer"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 				return (AE_AML_OPERAND_VALUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 			status = acpi_ns_check_object_type(info, elements + 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 							   package->ret_info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 							   object_type2, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 			if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 				return (status);
^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) 			elements += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 			count -= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 		/* Should not get here if predefined info table is correct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 		ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 				      info->node_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 				      "Invalid internal return type in table entry: %X",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 				      package->ret_info.type));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 		return (AE_AML_INTERNAL);
^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) 	return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) package_too_small:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	/* Error exit for the case with an incorrect package count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 	ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, info->node_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 			      "Return Package is too small - found %u elements, expected %u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 			      count, expected_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	return (AE_AML_OPERAND_VALUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)  * FUNCTION:    acpi_ns_check_package_list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373)  * PARAMETERS:  info            - Method execution information block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)  *              package         - Pointer to package-specific info for method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)  *              elements        - Element list of parent package. All elements
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)  *                                of this list should be of type Package.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)  *              count           - Count of subpackages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)  * DESCRIPTION: Examine a list of subpackages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) acpi_ns_check_package_list(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 			   const union acpi_predefined_info *package,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 			   union acpi_operand_object **elements, u32 count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	union acpi_operand_object *sub_package;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	union acpi_operand_object **sub_elements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	u32 expected_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	u32 j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	 * Validate each subpackage in the parent Package
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	 * NOTE: assumes list of subpackages contains no NULL elements.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	 * Any NULL elements should have been removed by earlier call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	 * to acpi_ns_remove_null_elements.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	for (i = 0; i < count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 		sub_package = *elements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 		sub_elements = sub_package->package.elements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 		info->parent_package = sub_package;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 		/* Each sub-object must be of type Package */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 		status = acpi_ns_check_object_type(info, &sub_package,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 						   ACPI_RTYPE_PACKAGE, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 			return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 		/* Examine the different types of expected subpackages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 		info->parent_package = sub_package;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 		switch (package->ret_info.type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 		case ACPI_PTYPE2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 		case ACPI_PTYPE2_PKG_COUNT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 		case ACPI_PTYPE2_REV_FIXED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 			/* Each subpackage has a fixed number of elements */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 			expected_count =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 			    package->ret_info.count1 + package->ret_info.count2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 			if (sub_package->package.count < expected_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 				goto package_too_small;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 			status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 			    acpi_ns_check_package_elements(info, sub_elements,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 							   package->ret_info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 							   object_type1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 							   package->ret_info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 							   count1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 							   package->ret_info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 							   object_type2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 							   package->ret_info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 							   count2, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 			if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 				return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 		case ACPI_PTYPE2_FIX_VAR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 			 * Each subpackage has a fixed number of elements and an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 			 * optional element
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 			expected_count =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 			    package->ret_info.count1 + package->ret_info.count2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 			if (sub_package->package.count < expected_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 				goto package_too_small;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 			status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 			    acpi_ns_check_package_elements(info, sub_elements,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 							   package->ret_info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 							   object_type1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 							   package->ret_info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 							   count1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 							   package->ret_info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 							   object_type2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 							   sub_package->package.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 							   count -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 							   package->ret_info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 							   count1, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 			if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 				return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 		case ACPI_PTYPE2_VAR_VAR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 			 * Each subpackage has a fixed or variable number of elements
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 		case ACPI_PTYPE2_FIXED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 			/* Each subpackage has a fixed length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 			expected_count = package->ret_info2.count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 			if (sub_package->package.count < expected_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 				goto package_too_small;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 			/* Check the type of each subpackage element */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 			for (j = 0; j < expected_count; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 				status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 				    acpi_ns_check_object_type(info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 							      &sub_elements[j],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 							      package->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 							      ret_info2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 							      object_type[j],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 							      j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 				if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 					return (status);
^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) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 		case ACPI_PTYPE2_MIN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 			/* Each subpackage has a variable but minimum length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 			expected_count = package->ret_info.count1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 			if (sub_package->package.count < expected_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 				goto package_too_small;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 			/* Check the type of each subpackage element */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 			status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 			    acpi_ns_check_package_elements(info, sub_elements,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 							   package->ret_info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 							   object_type1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 							   sub_package->package.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 							   count, 0, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 			if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 				return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 		case ACPI_PTYPE2_COUNT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 			 * First element is the (Integer) count of elements, including
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 			 * the count field (the ACPI name is num_elements)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 			status = acpi_ns_check_object_type(info, sub_elements,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 							   ACPI_RTYPE_INTEGER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 							   0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 			if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 				return (status);
^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) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 			 * Make sure package is large enough for the Count and is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 			 * is as large as the minimum size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 			expected_count = (u32)(*sub_elements)->integer.value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 			if (sub_package->package.count < expected_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 				goto package_too_small;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 			if (sub_package->package.count <
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 			    package->ret_info.count1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 				expected_count = package->ret_info.count1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 				goto package_too_small;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 			if (expected_count == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 				/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 				 * Either the num_entries element was originally zero or it was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 				 * a NULL element and repaired to an Integer of value zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 				 * In either case, repair it by setting num_entries to be the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 				 * actual size of the subpackage.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 				 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 				expected_count = sub_package->package.count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 				(*sub_elements)->integer.value = expected_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 			/* Check the type of each subpackage element */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 			status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 			    acpi_ns_check_package_elements(info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 							   (sub_elements + 1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 							   package->ret_info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 							   object_type1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 							   (expected_count - 1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 							   0, 0, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 			if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 				return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 		default:	/* Should not get here, type was validated by caller */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 			ACPI_ERROR((AE_INFO, "Invalid Package type: %X",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 				    package->ret_info.type));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 			return (AE_AML_INTERNAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 		elements++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 	return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) package_too_small:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 	/* The subpackage count was smaller than required */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 	ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, info->node_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 			      "Return SubPackage[%u] is too small - found %u elements, expected %u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 			      i, sub_package->package.count, expected_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 	return (AE_AML_OPERAND_VALUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606)  * FUNCTION:    acpi_ns_custom_package
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608)  * PARAMETERS:  info                - Method execution information block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609)  *              elements            - Pointer to the package elements array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610)  *              count               - Element count for the package
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614)  * DESCRIPTION: Check a returned package object for the correct count and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615)  *              correct type of all sub-objects.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617)  * NOTE: Currently used for the _BIX method only. When needed for two or more
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618)  * methods, probably a detect/dispatch mechanism will be required.
^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) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) acpi_ns_custom_package(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 		       union acpi_operand_object **elements, u32 count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) 	u32 expected_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) 	u32 version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) 	acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) 	ACPI_FUNCTION_NAME(ns_custom_package);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) 	/* Get version number, must be Integer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) 	if ((*elements)->common.type != ACPI_TYPE_INTEGER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) 		ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) 				      info->node_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 				      "Return Package has invalid object type for version number"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) 		return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
^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) 	version = (u32)(*elements)->integer.value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 	expected_count = 21;	/* Version 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) 	if (version == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 		expected_count = 20;	/* Version 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) 	if (count < expected_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) 		ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) 				      info->node_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) 				      "Return Package is too small - found %u elements, expected %u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 				      count, expected_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) 		return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 	} else if (count > expected_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) 		ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) 				  "%s: Return Package is larger than needed - "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) 				  "found %u, expected %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) 				  info->full_pathname, count, expected_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) 	/* Validate all elements of the returned package */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) 	status = acpi_ns_check_package_elements(info, elements,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) 						ACPI_RTYPE_INTEGER, 16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) 						ACPI_RTYPE_STRING, 4, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) 	/* Version 1 has a single trailing integer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) 	if (version > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) 		status = acpi_ns_check_package_elements(info, elements + 20,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) 							ACPI_RTYPE_INTEGER, 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) 							0, 0, 20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683)  * FUNCTION:    acpi_ns_check_package_elements
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685)  * PARAMETERS:  info            - Method execution information block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686)  *              elements        - Pointer to the package elements array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687)  *              type1           - Object type for first group
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688)  *              count1          - Count for first group
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689)  *              type2           - Object type for second group
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690)  *              count2          - Count for second group
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691)  *              start_index     - Start of the first group of elements
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695)  * DESCRIPTION: Check that all elements of a package are of the correct object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696)  *              type. Supports up to two groups of different object types.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) acpi_ns_check_package_elements(struct acpi_evaluate_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) 			       union acpi_operand_object **elements,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) 			       u8 type1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) 			       u32 count1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) 			       u8 type2, u32 count2, u32 start_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) 	union acpi_operand_object **this_element = elements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) 	 * Up to two groups of package elements are supported by the data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) 	 * structure. All elements in each group must be of the same type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) 	 * The second group can have a count of zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) 	for (i = 0; i < count1; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) 		status = acpi_ns_check_object_type(info, this_element,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) 						   type1, i + start_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) 			return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) 		this_element++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) 	for (i = 0; i < count2; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) 		status = acpi_ns_check_object_type(info, this_element,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) 						   type2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) 						   (i + count1 + start_index));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) 			return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) 		this_element++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) 	return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) }