iASL: Warn if reserved method incorrectly returns a value.

Many predefined names are defined such that they do not return
a value. If implemented as a method, issue a warning if such
a name returns a value. ACPICA BZ 855.
This commit is contained in:
Robert Moore 2011-01-27 13:45:46 -08:00
parent 26e99b0d83
commit ac3a38aaf5
3 changed files with 78 additions and 4 deletions

View File

@ -260,6 +260,7 @@ typedef enum
ASL_MSG_HID_LENGTH,
ASL_MSG_NULL_STRING,
ASL_MSG_LEADING_ASTERISK,
ASL_MSG_RESERVED_NO_RETURN_VAL,
ASL_MSG_INVALID_FIELD_NAME,
ASL_MSG_INTEGER_SIZE,
@ -411,6 +412,7 @@ char *AslMessages [] = {
/* ASL_MSG_HID_LENGTH */ "_HID string must be exactly 7 or 8 characters",
/* ASL_MSG_NULL_STRING */ "Invalid zero-length (null) string",
/* ASL_MSG_LEADING_ASTERISK */ "Invalid leading asterisk",
/* ASL_MSG_RESERVED_NO_RETURN_VAL */ "Reserved method should not return a value",
/* These messages are used by the data table compiler only */

View File

@ -126,6 +126,11 @@
/* Local prototypes */
static void
ApCheckForUnexpectedReturnValue (
ACPI_PARSE_OBJECT *Op,
ASL_METHOD_INFO *MethodInfo);
static UINT32
ApCheckForSpecialName (
ACPI_PARSE_OBJECT *Op,
@ -308,6 +313,53 @@ ApCheckForPredefinedMethod (
}
/*******************************************************************************
*
* FUNCTION: ApCheckForUnexpectedReturnValue
*
* PARAMETERS: Op - A parse node of type "RETURN".
* MethodInfo - Saved info about this method
*
* RETURN: None
*
* DESCRIPTION: Check for an unexpected return value from a predefined method.
* Invoked for predefined methods that are defined to not return
* any value. If there is a return value, issue a remark, since
* the ASL writer may be confused as to the method definition
* and/or functionality.
*
* Note: We ignore all return values of "Zero", since this is what a standalone
* Return() statement will always generate -- so we ignore it here --
* i.e., there is no difference between Return() and Return(Zero).
* Also, a null Return() will be disassembled to return(Zero) -- so, we
* don't want to generate extraneous remarks/warnings for a disassembled
* ASL file.
*
******************************************************************************/
static void
ApCheckForUnexpectedReturnValue (
ACPI_PARSE_OBJECT *Op,
ASL_METHOD_INFO *MethodInfo)
{
ACPI_PARSE_OBJECT *ReturnValueOp;
/* Ignore Return() and Return(Zero) (they are the same) */
ReturnValueOp = Op->Asl.Child;
if (ReturnValueOp->Asl.ParseOpcode == PARSEOP_ZERO)
{
return;
}
/* We have a valid return value, but the reserved name did not expect it */
AslError (ASL_WARNING, ASL_MSG_RESERVED_NO_RETURN_VAL,
Op, MethodInfo->Op->Asl.ExternalName);
}
/*******************************************************************************
*
* FUNCTION: ApCheckPredefinedReturnValue
@ -321,7 +373,9 @@ ApCheckForPredefinedMethod (
* value. Only "static" types can be validated - a simple return
* of an integer/string/buffer/package or a named reference to
* a static object. Values such as a Localx or Argx or a control
* method invocation are not checked.
* method invocation are not checked. Issue a warning if there is
* a valid return value, but the reserved method defines no
* return value.
*
******************************************************************************/
@ -341,20 +395,27 @@ ApCheckPredefinedReturnValue (
switch (Index)
{
case ACPI_EVENT_RESERVED_NAME: /* _Lxx/_Exx/_Wxx/_Qxx methods */
/* No return value expected, warn if there is one */
ApCheckForUnexpectedReturnValue (Op, MethodInfo);
return;
case ACPI_NOT_RESERVED_NAME: /* No underscore or _Txx or _xxx name not matched */
case ACPI_PREDEFINED_NAME: /* Resource Name or reserved scope name */
case ACPI_COMPILER_RESERVED_NAME: /* A _Txx that was not emitted by compiler */
case ACPI_EVENT_RESERVED_NAME: /* _Lxx/_Exx/_Wxx/_Qxx methods */
/* Just return, nothing to do */
return;
default: /* A standard predefined ACPI name */
/* Exit if no return value expected */
if (!PredefinedNames[Index].Info.ExpectedBtypes)
{
/* No return value expected, warn if there is one */
ApCheckForUnexpectedReturnValue (Op, MethodInfo);
return;
}

View File

@ -165,6 +165,17 @@ DefinitionBlock ("badcode.aml", "DSDT", 1, "Intel", "Example", 0x00000001)
Name (_INI, 1)
Name (_PTP, 2)
// Predefined names that should not have a return value
Method (_FDM, 1)
{
Return (Buffer(1){0x33})
}
Method (_Q22)
{
Return ("Unexpected Return Value")
}
/*
* Resource Descriptor error checking
*/