^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: nsarguments - Validation of args for ACPI predefined methods
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2000 - 2020, Intel Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <acpi/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include "accommon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "acnamesp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "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("nsarguments")
^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) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * FUNCTION: acpi_ns_check_argument_types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * PARAMETERS: info - Method execution information block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * RETURN: None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * DESCRIPTION: Check the incoming argument count and all argument types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * against the argument type list for a predefined name.
^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) void acpi_ns_check_argument_types(struct acpi_evaluate_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) u16 arg_type_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) u8 arg_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) u8 arg_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) u8 user_arg_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * If not a predefined name, cannot typecheck args, because
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * we have no idea what argument types are expected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * Also, ignore typecheck if warnings/errors if this method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * has already been evaluated at least once -- in order
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * to suppress repetitive messages.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) if (!info->predefined || (info->node->flags & ANOBJ_EVALUATED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) return;
^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) arg_type_list = info->predefined->info.argument_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) arg_count = METHOD_GET_ARG_COUNT(arg_type_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) /* Typecheck all arguments */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) for (i = 0; ((i < arg_count) && (i < info->param_count)); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) arg_type = METHOD_GET_NEXT_TYPE(arg_type_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) user_arg_type = info->parameters[i]->common.type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) /* No typechecking for ACPI_TYPE_ANY */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) if ((user_arg_type != arg_type) && (arg_type != ACPI_TYPE_ANY)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) ACPI_WARN_ALWAYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) "Argument #%u type mismatch - "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) "Found [%s], ACPI requires [%s]",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) (i + 1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) acpi_ut_get_type_name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) (user_arg_type),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) acpi_ut_get_type_name(arg_type)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) /* Prevent any additional typechecking for this method */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) info->node->flags |= ANOBJ_EVALUATED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * FUNCTION: acpi_ns_check_acpi_compliance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * PARAMETERS: pathname - Full pathname to the node (for error msgs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * node - Namespace node for the method/object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * predefined - Pointer to entry in predefined name table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) * RETURN: None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) * DESCRIPTION: Check that the declared parameter count (in ASL/AML) for a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) * predefined name is what is expected (matches what is defined in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) * the ACPI specification for this predefined name.)
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) acpi_ns_check_acpi_compliance(char *pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) struct acpi_namespace_node *node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) const union acpi_predefined_info *predefined)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) u32 aml_param_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) u32 required_param_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) if (!predefined || (node->flags & ANOBJ_EVALUATED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) /* Get the ACPI-required arg count from the predefined info table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) required_param_count =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) METHOD_GET_ARG_COUNT(predefined->info.argument_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) * If this object is not a control method, we can check if the ACPI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) * spec requires that it be a method.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) if (node->type != ACPI_TYPE_METHOD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) if (required_param_count > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) /* Object requires args, must be implemented as a method */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) ACPI_BIOS_ERROR_PREDEFINED((AE_INFO, pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) ACPI_WARN_ALWAYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) "Object (%s) must be a control method with %u arguments",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) acpi_ut_get_type_name(node->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) type),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) required_param_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) } else if (!required_param_count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) && !predefined->info.expected_btypes) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) /* Object requires no args and no return value, must be a method */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) ACPI_BIOS_ERROR_PREDEFINED((AE_INFO, pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) ACPI_WARN_ALWAYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) "Object (%s) must be a control method "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) "with no arguments and no return value",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) acpi_ut_get_type_name(node->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) type)));
^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) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) * This is a control method.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) * Check that the ASL/AML-defined parameter count for this method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) * matches the ACPI-required parameter count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) * Some methods are allowed to have a "minimum" number of args (_SCP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) * because their definition in ACPI has changed over time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) * Note: These are BIOS errors in the declaration of the object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) aml_param_count = node->object->method.param_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) if (aml_param_count < required_param_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) ACPI_BIOS_ERROR_PREDEFINED((AE_INFO, pathname, ACPI_WARN_ALWAYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) "Insufficient arguments - "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) "ASL declared %u, ACPI requires %u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) aml_param_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) required_param_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) } else if ((aml_param_count > required_param_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) && !(predefined->info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) argument_list & ARG_COUNT_IS_MINIMUM)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) ACPI_BIOS_ERROR_PREDEFINED((AE_INFO, pathname, ACPI_WARN_ALWAYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) "Excess arguments - "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) "ASL declared %u, ACPI requires %u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) aml_param_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) required_param_count));
^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) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) * FUNCTION: acpi_ns_check_argument_count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) * PARAMETERS: pathname - Full pathname to the node (for error msgs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) * node - Namespace node for the method/object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) * user_param_count - Number of args passed in by the caller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) * predefined - Pointer to entry in predefined name table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) * RETURN: None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) * DESCRIPTION: Check that incoming argument count matches the declared
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) * parameter count (in the ASL/AML) for an object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) acpi_ns_check_argument_count(char *pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) struct acpi_namespace_node *node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) u32 user_param_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) const union acpi_predefined_info *predefined)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) u32 aml_param_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) u32 required_param_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) if (node->flags & ANOBJ_EVALUATED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) if (!predefined) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) * Not a predefined name. Check the incoming user argument count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) * against the count that is specified in the method/object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) if (node->type != ACPI_TYPE_METHOD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) if (user_param_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) ACPI_INFO_PREDEFINED((AE_INFO, pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) ACPI_WARN_ALWAYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) "%u arguments were passed to a non-method ACPI object (%s)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) user_param_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) acpi_ut_get_type_name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) (node->type)));
^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) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) * This is a control method. Check the parameter count.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) * We can only check the incoming argument count against the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) * argument count declared for the method in the ASL/AML.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) * Emit a message if too few or too many arguments have been passed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) * by the caller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) * Note: Too many arguments will not cause the method to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) * fail. However, the method will fail if there are too few
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) * arguments and the method attempts to use one of the missing ones.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) aml_param_count = node->object->method.param_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) if (user_param_count < aml_param_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) ACPI_WARN_PREDEFINED((AE_INFO, pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) ACPI_WARN_ALWAYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) "Insufficient arguments - "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) "Caller passed %u, method requires %u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) user_param_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) aml_param_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) } else if (user_param_count > aml_param_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) ACPI_INFO_PREDEFINED((AE_INFO, pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) ACPI_WARN_ALWAYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) "Excess arguments - "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) "Caller passed %u, method requires %u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) user_param_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) aml_param_count));
^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) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) * This is a predefined name. Validate the user-supplied parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) * count against the ACPI specification. We don't validate against
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) * the method itself because what is important here is that the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) * caller is in conformance with the spec. (The arg count for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) * method was checked against the ACPI spec earlier.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) * Some methods are allowed to have a "minimum" number of args (_SCP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) * because their definition in ACPI has changed over time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) required_param_count =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) METHOD_GET_ARG_COUNT(predefined->info.argument_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) if (user_param_count < required_param_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) ACPI_WARN_PREDEFINED((AE_INFO, pathname, ACPI_WARN_ALWAYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) "Insufficient arguments - "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) "Caller passed %u, ACPI requires %u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) user_param_count, required_param_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) } else if ((user_param_count > required_param_count) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) !(predefined->info.argument_list & ARG_COUNT_IS_MINIMUM)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) ACPI_INFO_PREDEFINED((AE_INFO, pathname, ACPI_WARN_ALWAYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) "Excess arguments - "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) "Caller passed %u, ACPI requires %u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) user_param_count, required_param_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) }