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: utpredef - support functions 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 "acpredef.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #define _COMPONENT          ACPI_UTILITIES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) ACPI_MODULE_NAME("utpredef")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * Names for the types that can be returned by the predefined objects.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * Used for warning messages. Must be in the same order as the ACPI_RTYPEs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) static const char *ut_rtype_names[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	"/Integer",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	"/String",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	"/Buffer",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	"/Package",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	"/Reference",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * FUNCTION:    acpi_ut_get_next_predefined_method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  * PARAMETERS:  this_name           - Entry in the predefined method/name table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  * RETURN:      Pointer to next entry in predefined table.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * DESCRIPTION: Get the next entry in the predefine method table. Handles the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  *              cases where a package info entry follows a method name that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  *              returns a package.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) const union acpi_predefined_info *acpi_ut_get_next_predefined_method(const union
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 								     acpi_predefined_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 								     *this_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) {
^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) 	 * Skip next entry in the table if this name returns a Package
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	 * (next entry contains the package info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	if ((this_name->info.expected_btypes & ACPI_RTYPE_PACKAGE) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	    (this_name->info.expected_btypes != ACPI_RTYPE_ALL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		this_name++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	this_name++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	return (this_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  * FUNCTION:    acpi_ut_match_predefined_method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)  * PARAMETERS:  name                - Name to find
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)  * RETURN:      Pointer to entry in predefined table. NULL indicates not found.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  * DESCRIPTION: Check an object name against the predefined object list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) const union acpi_predefined_info *acpi_ut_match_predefined_method(char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	const union acpi_predefined_info *this_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	/* Quick check for a predefined name, first character must be underscore */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	if (name[0] != '_') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		return (NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	/* Search info table for a predefined method/object name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	this_name = acpi_gbl_predefined_methods;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	while (this_name->info.name[0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		if (ACPI_COMPARE_NAMESEG(name, this_name->info.name)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 			return (this_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		this_name = acpi_ut_get_next_predefined_method(this_name);
^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) 	return (NULL);		/* Not found */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)  * FUNCTION:    acpi_ut_get_expected_return_types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)  * PARAMETERS:  buffer              - Where the formatted string is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)  *              expected_Btypes     - Bitfield of expected data types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  * RETURN:      Formatted string in Buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  * DESCRIPTION: Format the expected object types into a printable string.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) void acpi_ut_get_expected_return_types(char *buffer, u32 expected_btypes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	u32 this_rtype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	u32 j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	if (!expected_btypes) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		strcpy(buffer, "NONE");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	j = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	buffer[0] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	this_rtype = ACPI_RTYPE_INTEGER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	for (i = 0; i < ACPI_NUM_RTYPES; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		/* If one of the expected types, concatenate the name of this type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		if (expected_btypes & this_rtype) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 			strcat(buffer, &ut_rtype_names[i][j]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 			j = 0;	/* Use name separator from now on */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		this_rtype <<= 1;	/* Next Rtype */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)  * The remaining functions are used by iASL and acpi_help only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) #if (defined ACPI_ASL_COMPILER || defined ACPI_HELP_APP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) /* Local prototypes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) static u32 acpi_ut_get_argument_types(char *buffer, u16 argument_types);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) /* Types that can be returned externally by a predefined name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) static const char *ut_external_type_names[] =	/* Indexed by ACPI_TYPE_* */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	", Type_ANY",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	", Integer",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	", String",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	", Buffer",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	", Package"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) /* Bit widths for resource descriptor predefined names */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) static const char *ut_resource_type_names[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	"/1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	"/2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	"/3",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	"/8",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	"/16",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	"/32",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	"/64",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	"/variable",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) };
^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)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)  * FUNCTION:    acpi_ut_match_resource_name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)  * PARAMETERS:  name                - Name to find
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)  * RETURN:      Pointer to entry in the resource table. NULL indicates not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)  *              found.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)  * DESCRIPTION: Check an object name against the predefined resource
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)  *              descriptor object list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) const union acpi_predefined_info *acpi_ut_match_resource_name(char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	const union acpi_predefined_info *this_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	 * Quick check for a predefined name, first character must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	 * be underscore
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	if (name[0] != '_') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		return (NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	/* Search info table for a predefined method/object name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	this_name = acpi_gbl_resource_names;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	while (this_name->info.name[0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		if (ACPI_COMPARE_NAMESEG(name, this_name->info.name)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 			return (this_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		this_name++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	return (NULL);		/* Not found */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) }
^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)  * FUNCTION:    acpi_ut_display_predefined_method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)  * PARAMETERS:  buffer              - Scratch buffer for this function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)  *              this_name           - Entry in the predefined method/name table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)  *              multi_line          - TRUE if output should be on >1 line
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)  * DESCRIPTION: Display information about a predefined method. Number and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)  *              type of the input arguments, and expected type(s) for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)  *              return value, if any.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)  *
^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) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) acpi_ut_display_predefined_method(char *buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 				  const union acpi_predefined_info *this_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 				  u8 multi_line)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	u32 arg_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	 * Get the argument count and the string buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	 * containing all argument types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	arg_count = acpi_ut_get_argument_types(buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 					       this_name->info.argument_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	if (multi_line) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		printf("      ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	printf("%4.4s    Requires %s%u argument%s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	       this_name->info.name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	       (this_name->info.argument_list & ARG_COUNT_IS_MINIMUM) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	       "(at least) " : "", arg_count, arg_count != 1 ? "s" : "");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	/* Display the types for any arguments */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	if (arg_count > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		printf(" (%s)", buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	if (multi_line) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		printf("\n    ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	/* Get the return value type(s) allowed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	if (this_name->info.expected_btypes) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 		acpi_ut_get_expected_return_types(buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 						  this_name->info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 						  expected_btypes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 		printf("  Return value types: %s\n", buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		printf("  No return value\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)  * FUNCTION:    acpi_ut_get_argument_types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)  * PARAMETERS:  buffer              - Where to return the formatted types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)  *              argument_types      - Types field for this method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)  * RETURN:      count - the number of arguments required for this method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)  * DESCRIPTION: Format the required data types for this method (Integer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)  *              String, Buffer, or Package) and return the required argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)  *              count.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) static u32 acpi_ut_get_argument_types(char *buffer, u16 argument_types)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	u16 this_argument_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	u16 sub_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	u16 arg_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	*buffer = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	sub_index = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	/* First field in the types list is the count of args to follow */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	arg_count = METHOD_GET_ARG_COUNT(argument_types);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	if (arg_count > METHOD_PREDEF_ARGS_MAX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 		printf("**** Invalid argument count (%u) "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 		       "in predefined info structure\n", arg_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 		return (arg_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	/* Get each argument from the list, convert to ascii, store to buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	for (i = 0; i < arg_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 		this_argument_type = METHOD_GET_NEXT_TYPE(argument_types);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 		if (this_argument_type > METHOD_MAX_ARG_TYPE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 			printf("**** Invalid argument type (%u) "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 			       "in predefined info structure\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 			       this_argument_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 			return (arg_count);
^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) 		strcat(buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 		       ut_external_type_names[this_argument_type] + sub_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 		sub_index = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	return (arg_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)  * FUNCTION:    acpi_ut_get_resource_bit_width
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)  * PARAMETERS:  buffer              - Where the formatted string is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)  *              types               - Bitfield of expected data types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)  * RETURN:      Count of return types. Formatted string in Buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)  * DESCRIPTION: Format the resource bit widths into a printable string.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) u32 acpi_ut_get_resource_bit_width(char *buffer, u16 types)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	u16 sub_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	u32 found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	*buffer = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	sub_index = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	found = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	for (i = 0; i < NUM_RESOURCE_WIDTHS; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 		if (types & 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 			strcat(buffer, &(ut_resource_type_names[i][sub_index]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 			sub_index = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 			found++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 		types >>= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 	return (found);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) #endif