Commit c34c82bc authored by Bob Moore's avatar Bob Moore Committed by Rafael J. Wysocki

ACPICA: Predefine names: Add allowed argument types to master info table

This change adds the infrastructure to enable typechecking
on incoming arguments for the predefined methods/objects. It
does not actually contain the code that will fully utilize this
information. Also condenses some duplicate code for the predefined
names into a new module, utilities/utpredef.c
Signed-off-by: default avatarBob Moore <robert.moore@intel.com>
Signed-off-by: default avatarLv Zheng <lv.zheng@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent f084dbb9
...@@ -161,6 +161,7 @@ acpi-y += \ ...@@ -161,6 +161,7 @@ acpi-y += \
utobject.o \ utobject.o \
utosi.o \ utosi.o \
utownerid.o \ utownerid.o \
utpredef.o \
utresrc.o \ utresrc.o \
utstate.o \ utstate.o \
utstring.o \ utstring.o \
......
...@@ -294,6 +294,8 @@ acpi_status(*acpi_internal_method) (struct acpi_walk_state * walk_state); ...@@ -294,6 +294,8 @@ acpi_status(*acpi_internal_method) (struct acpi_walk_state * walk_state);
#define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */ #define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */
#define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF #define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF
#pragma pack(1)
/* /*
* Information structure for ACPI predefined names. * Information structure for ACPI predefined names.
* Each entry in the table contains the following items: * Each entry in the table contains the following items:
...@@ -304,7 +306,7 @@ acpi_status(*acpi_internal_method) (struct acpi_walk_state * walk_state); ...@@ -304,7 +306,7 @@ acpi_status(*acpi_internal_method) (struct acpi_walk_state * walk_state);
*/ */
struct acpi_name_info { struct acpi_name_info {
char name[ACPI_NAME_SIZE]; char name[ACPI_NAME_SIZE];
u8 param_count; u16 argument_list;
u8 expected_btypes; u8 expected_btypes;
}; };
...@@ -327,7 +329,7 @@ struct acpi_package_info { ...@@ -327,7 +329,7 @@ struct acpi_package_info {
u8 count1; u8 count1;
u8 object_type2; u8 object_type2;
u8 count2; u8 count2;
u8 reserved; u16 reserved;
}; };
/* Used for ACPI_PTYPE2_FIXED */ /* Used for ACPI_PTYPE2_FIXED */
...@@ -336,6 +338,7 @@ struct acpi_package_info2 { ...@@ -336,6 +338,7 @@ struct acpi_package_info2 {
u8 type; u8 type;
u8 count; u8 count;
u8 object_type[4]; u8 object_type[4];
u8 reserved;
}; };
/* Used for ACPI_PTYPE1_OPTION */ /* Used for ACPI_PTYPE1_OPTION */
...@@ -345,7 +348,7 @@ struct acpi_package_info3 { ...@@ -345,7 +348,7 @@ struct acpi_package_info3 {
u8 count; u8 count;
u8 object_type[2]; u8 object_type[2];
u8 tail_object_type; u8 tail_object_type;
u8 reserved; u16 reserved;
}; };
union acpi_predefined_info { union acpi_predefined_info {
...@@ -355,6 +358,10 @@ union acpi_predefined_info { ...@@ -355,6 +358,10 @@ union acpi_predefined_info {
struct acpi_package_info3 ret_info3; struct acpi_package_info3 ret_info3;
}; };
/* Reset to default packing */
#pragma pack()
/* Data block used during object validation */ /* Data block used during object validation */
struct acpi_predefined_data { struct acpi_predefined_data {
......
...@@ -231,10 +231,6 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node, ...@@ -231,10 +231,6 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
acpi_status return_status, acpi_status return_status,
union acpi_operand_object **return_object); union acpi_operand_object **return_object);
const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct
acpi_namespace_node
*node);
void void
acpi_ns_check_parameter_count(char *pathname, acpi_ns_check_parameter_count(char *pathname,
struct acpi_namespace_node *node, struct acpi_namespace_node *node,
......
This diff is collapsed.
...@@ -431,6 +431,26 @@ struct acpi_interface_info *acpi_ut_get_interface(acpi_string interface_name); ...@@ -431,6 +431,26 @@ struct acpi_interface_info *acpi_ut_get_interface(acpi_string interface_name);
acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state); acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state);
/*
* utpredef - support for predefined names
*/
const union acpi_predefined_info *acpi_ut_get_next_predefined_method(const union
acpi_predefined_info
*this_name);
const union acpi_predefined_info *acpi_ut_match_predefined_method(char *name);
const union acpi_predefined_info *acpi_ut_match_resource_name(char *name);
void
acpi_ut_display_predefined_method(char *buffer,
const union acpi_predefined_info *this_name,
u8 multi_line);
void acpi_ut_get_expected_return_types(char *buffer, u32 expected_btypes);
u32 acpi_ut_get_resource_bit_width(char *buffer, u16 types);
/* /*
* utstate - Generic state creation/cache routines * utstate - Generic state creation/cache routines
*/ */
......
...@@ -98,18 +98,22 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info) ...@@ -98,18 +98,22 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
info->return_object = NULL; info->return_object = NULL;
info->param_count = 0; info->param_count = 0;
if (!info->resolved_node) {
/* /*
* Get the actual namespace node for the target object. Handles these cases: * Get the actual namespace node for the target object if we need to.
* Handles these cases:
* *
* 1) Null node, Pathname (absolute path) * 1) Null node, Pathname (absolute path)
* 2) Node, Pathname (path relative to Node) * 2) Node, Pathname (path relative to Node)
* 3) Node, Null Pathname * 3) Node, Null Pathname
*/ */
status = acpi_ns_get_node(info->prefix_node, info->pathname, status = acpi_ns_get_node(info->prefix_node, info->pathname,
ACPI_NS_NO_UPSEARCH, &info->resolved_node); ACPI_NS_NO_UPSEARCH,
&info->resolved_node);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status); return_ACPI_STATUS(status);
} }
}
/* /*
* For a method alias, we must grab the actual method node so that proper * For a method alias, we must grab the actual method node so that proper
......
...@@ -76,22 +76,8 @@ static acpi_status ...@@ -76,22 +76,8 @@ static acpi_status
acpi_ns_check_reference(struct acpi_predefined_data *data, acpi_ns_check_reference(struct acpi_predefined_data *data,
union acpi_operand_object *return_object); union acpi_operand_object *return_object);
static void acpi_ns_get_expected_types(char *buffer, u32 expected_btypes);
static u32 acpi_ns_get_bitmapped_type(union acpi_operand_object *return_object); static u32 acpi_ns_get_bitmapped_type(union acpi_operand_object *return_object);
/*
* Names for the types that can be returned by the predefined objects.
* Used for warning messages. Must be in the same order as the ACPI_RTYPEs
*/
static const char *acpi_rtype_names[] = {
"/Integer",
"/String",
"/Buffer",
"/Package",
"/Reference",
};
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_ns_check_predefined_names * FUNCTION: acpi_ns_check_predefined_names
...@@ -121,7 +107,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node, ...@@ -121,7 +107,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
/* Match the name for this method/object against the predefined list */ /* Match the name for this method/object against the predefined list */
predefined = acpi_ns_check_for_predefined_name(node); predefined = acpi_ut_match_predefined_method(node->name.ascii);
/* Get the full pathname to the object, for use in warning messages */ /* Get the full pathname to the object, for use in warning messages */
...@@ -292,8 +278,10 @@ acpi_ns_check_parameter_count(char *pathname, ...@@ -292,8 +278,10 @@ acpi_ns_check_parameter_count(char *pathname,
* Validate the user-supplied parameter count. * Validate the user-supplied parameter count.
* Allow two different legal argument counts (_SCP, etc.) * Allow two different legal argument counts (_SCP, etc.)
*/ */
required_params_current = predefined->info.param_count & 0x0F; required_params_current =
required_params_old = predefined->info.param_count >> 4; predefined->info.argument_list & METHOD_ARG_MASK;
required_params_old =
predefined->info.argument_list >> METHOD_ARG_BIT_WIDTH;
if (user_param_count != ACPI_UINT32_MAX) { if (user_param_count != ACPI_UINT32_MAX) {
if ((user_param_count != required_params_current) && if ((user_param_count != required_params_current) &&
...@@ -320,52 +308,6 @@ acpi_ns_check_parameter_count(char *pathname, ...@@ -320,52 +308,6 @@ acpi_ns_check_parameter_count(char *pathname,
} }
} }
/*******************************************************************************
*
* FUNCTION: acpi_ns_check_for_predefined_name
*
* PARAMETERS: node - Namespace node for the method/object
*
* RETURN: Pointer to entry in predefined table. NULL indicates not found.
*
* DESCRIPTION: Check an object name against the predefined object list.
*
******************************************************************************/
const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct
acpi_namespace_node
*node)
{
const union acpi_predefined_info *this_name;
/* Quick check for a predefined name, first character must be underscore */
if (node->name.ascii[0] != '_') {
return (NULL);
}
/* Search info table for a predefined method/object name */
this_name = predefined_names;
while (this_name->info.name[0]) {
if (ACPI_COMPARE_NAME(node->name.ascii, this_name->info.name)) {
return (this_name);
}
/*
* Skip next entry in the table if this name returns a Package
* (next entry contains the package info)
*/
if (this_name->info.expected_btypes & ACPI_RTYPE_PACKAGE) {
this_name++;
}
this_name++;
}
return (NULL); /* Not found */
}
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_ns_check_object_type * FUNCTION: acpi_ns_check_object_type
...@@ -438,7 +380,7 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data, ...@@ -438,7 +380,7 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data,
/* Create a string with all expected types for this predefined object */ /* Create a string with all expected types for this predefined object */
acpi_ns_get_expected_types(type_buffer, expected_btypes); acpi_ut_get_expected_return_types(type_buffer, expected_btypes);
if (package_index == ACPI_NOT_PACKAGE_ELEMENT) { if (package_index == ACPI_NOT_PACKAGE_ELEMENT) {
ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
...@@ -548,39 +490,3 @@ static u32 acpi_ns_get_bitmapped_type(union acpi_operand_object *return_object) ...@@ -548,39 +490,3 @@ static u32 acpi_ns_get_bitmapped_type(union acpi_operand_object *return_object)
return (return_btype); return (return_btype);
} }
/*******************************************************************************
*
* FUNCTION: acpi_ns_get_expected_types
*
* PARAMETERS: buffer - Pointer to where the string is returned
* expected_btypes - Bitmap of expected return type(s)
*
* RETURN: Buffer is populated with type names.
*
* DESCRIPTION: Translate the expected types bitmap into a string of ascii
* names of expected types, for use in warning messages.
*
******************************************************************************/
static void acpi_ns_get_expected_types(char *buffer, u32 expected_btypes)
{
u32 this_rtype;
u32 i;
u32 j;
j = 1;
buffer[0] = 0;
this_rtype = ACPI_RTYPE_INTEGER;
for (i = 0; i < ACPI_NUM_RTYPES; i++) {
/* If one of the expected types, concatenate the name of this type */
if (expected_btypes & this_rtype) {
ACPI_STRCAT(buffer, &acpi_rtype_names[i][j]);
j = 0; /* Use name separator from now on */
}
this_rtype <<= 1; /* Next Rtype */
}
}
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment