FreeBSD/sys/contrib/dev/acpica/compiler/aslpredef.c
/*******************************************************************************
 *
 * FUNCTION:    ApCheckForPredefinedMethod
 *
 * PARAMETERS:  Op              - A parse node of type "METHOD".
 *              MethodInfo      - Saved info about this method
 *
 * RETURN:      None
 *
 * DESCRIPTION: If method is a predefined name, check that the number of
 *              arguments and the return type (returns a value or not)
 *              is correct.
 *
 ******************************************************************************/
ApCheckForPredefinedMethod
PARAMETERS:  Op              - A parse node of type "METHOD".
MethodInfo      - Saved info about this method

None

If method is a predefined name, check that the number of
arguments and the return type (returns a value or not)
is correct.
ApCheckForPredefinedMethod PARAMETERS : Op - A parse node of type " METHOD " . MethodInfo - Saved info about this method None If method is a predefined name check that the number of arguments and the return type ( returns a value or not ) is correct .
BOOLEAN
ApCheckForPredefinedMethod (
    ACPI_PARSE_OBJECT       *Op,
    ASL_METHOD_INFO         *MethodInfo)
{
    UINT32                      Index;
    UINT32                      RequiredArgCount;
    const ACPI_PREDEFINED_INFO  *ThisName;
    Index = ApCheckForPredefinedName (Op, Op->Asl.NameSeg);
    switch (Index)
    {
    case ACPI_NOT_RESERVED_NAME:        
    case ACPI_PREDEFINED_NAME:          
    case ACPI_COMPILER_RESERVED_NAME:   
        return (FALSE);
    case ACPI_EVENT_RESERVED_NAME:      
        Gbl_ReservedMethods++;
        if (MethodInfo->NumArguments != 0)
        {
            sprintf (MsgBuffer, "%s requires %u", Op->Asl.ExternalName, 0);
            AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op,
                MsgBuffer);
        }
        break;
    default:
        Gbl_ReservedMethods++;
        ThisName = &AcpiGbl_PredefinedMethods[Index];
        RequiredArgCount = METHOD_GET_ARG_COUNT (ThisName->Info.ArgumentList);
        if (MethodInfo->NumArguments != RequiredArgCount)
        {
            sprintf (MsgBuffer, "%4.4s requires %u",
                ThisName->Info.Name, RequiredArgCount);
            if (MethodInfo->NumArguments < RequiredArgCount)
            {
                AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_LO, Op,
                    MsgBuffer);
            }
            else if ((MethodInfo->NumArguments > RequiredArgCount) &&
                !(ThisName->Info.ArgumentList & ARG_COUNT_IS_MINIMUM))
            {
                AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op,
                    MsgBuffer);
            }
        }
        if (MethodInfo->NumReturnNoValue &&
            ThisName->Info.ExpectedBtypes)
        {
            AcpiUtGetExpectedReturnTypes (StringBuffer,
                ThisName->Info.ExpectedBtypes);
            sprintf (MsgBuffer, "%s required for %4.4s",
                StringBuffer, ThisName->Info.Name);
            AslError (ASL_WARNING, ASL_MSG_RESERVED_RETURN_VALUE, Op,
                MsgBuffer);
        }
        break;
    }
    return (TRUE);
}
BOOLEAN ApCheckForPredefinedMethod ( ACPI_PARSE_OBJECT * Op , ASL_METHOD_INFO * MethodInfo ) { UINT32 Index ; UINT32 RequiredArgCount ; const ACPI_PREDEFINED_INFO * ThisName ; Index = ApCheckForPredefinedName ( Op , Op -> Asl . NameSeg ) ; switch ( Index ) { case ACPI_NOT_RESERVED_NAME : case ACPI_PREDEFINED_NAME : case ACPI_COMPILER_RESERVED_NAME : return ( FALSE ) ; case ACPI_EVENT_RESERVED_NAME : Gbl_ReservedMethods ++ ; if ( MethodInfo -> NumArguments != 0 ) { sprintf ( MsgBuffer , " " , Op -> Asl . ExternalName , 0 ) ; AslError ( ASL_WARNING , ASL_MSG_RESERVED_ARG_COUNT_HI , Op , MsgBuffer ) ; } break ; default : Gbl_ReservedMethods ++ ; ThisName = & AcpiGbl_PredefinedMethods [ Index ] ; RequiredArgCount = METHOD_GET_ARG_COUNT ( ThisName -> Info . ArgumentList ) ; if ( MethodInfo -> NumArguments != RequiredArgCount ) { sprintf ( MsgBuffer , " " , ThisName -> Info . Name , RequiredArgCount ) ; if ( MethodInfo -> NumArguments < RequiredArgCount ) { AslError ( ASL_WARNING , ASL_MSG_RESERVED_ARG_COUNT_LO , Op , MsgBuffer ) ; } else if ( ( MethodInfo -> NumArguments > RequiredArgCount ) && ! ( ThisName -> Info . ArgumentList & ARG_COUNT_IS_MINIMUM ) ) { AslError ( ASL_WARNING , ASL_MSG_RESERVED_ARG_COUNT_HI , Op , MsgBuffer ) ; } } if ( MethodInfo -> NumReturnNoValue && ThisName -> Info . ExpectedBtypes ) { AcpiUtGetExpectedReturnTypes ( StringBuffer , ThisName -> Info . ExpectedBtypes ) ; sprintf ( MsgBuffer , " " , StringBuffer , ThisName -> Info . Name ) ; AslError ( ASL_WARNING , ASL_MSG_RESERVED_RETURN_VALUE , Op , MsgBuffer ) ; } break ; } return ( TRUE ) ; }
FUNCTION:    ApCheckForPredefinedMethod
 PARAMETERS:  Op              - A parse node of type "METHOD".
FUNCTION : ApCheckForPredefinedMethod PARAMETERS : Op - A parse node of type " METHOD " .
/* Check for a match against the predefined name list */ /* No underscore or _Txx or _xxx name not matched */ /* Resource Name or reserved scope name */ /* A _Txx that was not emitted by compiler */ /* Just return, nothing to do */ /* _Lxx/_Exx/_Wxx/_Qxx methods */ /* NumArguments must be zero for all _Lxx/_Exx/_Wxx/_Qxx methods */ /*
         * Matched a predefined method name - validate the ASL-defined
         * argument count against the ACPI specification.
         *
         * Some methods are allowed to have a "minimum" number of args
         * (_SCP) because their definition in ACPI has changed over time.
         */ /*
         * Check if method returns no value, but the predefined name is
         * required to return a value
         */