FreeBSD/sys/contrib/dev/acpica/compiler/aslanalyze.c
/*******************************************************************************
 *
 * FUNCTION:    ApCheckForGpeNameConflict
 *
 * PARAMETERS:  Op                  - Current parse op
 *
 * RETURN:      None
 *
 * DESCRIPTION: Check for a conflict between GPE names within this scope.
 *              Conflict means two GPE names with the same GPE number, but
 *              different types -- such as _L1C and _E1C.
 *
 ******************************************************************************/
ApCheckForGpeNameConflict
PARAMETERS:  Op                  - Current parse op

None

Check for a conflict between GPE names within this scope.
Conflict means two GPE names with the same GPE number, but
different types -- such as _L1C and _E1C.
ApCheckForGpeNameConflict PARAMETERS : Op - Current parse op None Check for a conflict between GPE names within this scope . Conflict means two GPE names with the same GPE number but different types -- such as _L1C and _E1C .
void
ApCheckForGpeNameConflict (
    ACPI_PARSE_OBJECT       *Op)
{
    ACPI_PARSE_OBJECT       *NextOp;
    UINT32                  GpeNumber;
    char                    Name[ACPI_NAME_SIZE + 1];
    char                    Target[ACPI_NAME_SIZE];
    ACPI_MOVE_32_TO_32 (Name, &Op->Asl.NameSeg);
    Name[ACPI_NAME_SIZE] = 0;
    if ((Name[0] != '_') ||
       ((Name[1] != 'L') && (Name[1] != 'E')))
    {
        return;
    }
    GpeNumber = strtoul (&Name[2], NULL, 16);
    if (GpeNumber == ACPI_UINT32_MAX)
    {
        return;
    }
    ACPI_MOVE_32_TO_32 (Target, Name);
    if (Name[1] == 'L')
    {
        Target[1] = 'E';
    }
    else 
    {
        Target[1] = 'L';
    }
    NextOp = Op->Asl.Next;
    while (NextOp)
    {
        if ((NextOp->Asl.ParseOpcode == PARSEOP_METHOD) ||
            (NextOp->Asl.ParseOpcode == PARSEOP_NAME))
        {
            if (ACPI_COMPARE_NAME (Target, NextOp->Asl.NameSeg))
            {
                AslError (ASL_ERROR, ASL_MSG_GPE_NAME_CONFLICT, NextOp,
                    Name);
                return;
            }
        }
        NextOp = NextOp->Asl.Next;
    }
    return;
}
void ApCheckForGpeNameConflict ( ACPI_PARSE_OBJECT * Op ) { ACPI_PARSE_OBJECT * NextOp ; UINT32 GpeNumber ; char Name [ ACPI_NAME_SIZE + 1 ] ; char Target [ ACPI_NAME_SIZE ] ; ACPI_MOVE_32_TO_32 ( Name , & Op -> Asl . NameSeg ) ; Name [ ACPI_NAME_SIZE ] = 0 ; if ( ( Name [ 0 ] != ' ' ) || ( ( Name [ 1 ] != ' ' ) && ( Name [ 1 ] != ' ' ) ) ) { return ; } GpeNumber = strtoul ( & Name [ 2 ] , NULL , 16 ) ; if ( GpeNumber == ACPI_UINT32_MAX ) { return ; } ACPI_MOVE_32_TO_32 ( Target , Name ) ; if ( Name [ 1 ] == ' ' ) { Target [ 1 ] = ' ' ; } else { Target [ 1 ] = ' ' ; } NextOp = Op -> Asl . Next ; while ( NextOp ) { if ( ( NextOp -> Asl . ParseOpcode == PARSEOP_METHOD ) || ( NextOp -> Asl . ParseOpcode == PARSEOP_NAME ) ) { if ( ACPI_COMPARE_NAME ( Target , NextOp -> Asl . NameSeg ) ) { AslError ( ASL_ERROR , ASL_MSG_GPE_NAME_CONFLICT , NextOp , Name ) ; return ; } } NextOp = NextOp -> Asl . Next ; } return ; }
FUNCTION:    ApCheckForGpeNameConflict
 PARAMETERS:  Op                  - Current parse op
FUNCTION : ApCheckForGpeNameConflict PARAMETERS : Op - Current parse op
/* Need a null-terminated string version of NameSeg */ /*
     * For a GPE method:
     * 1st char must be underscore
     * 2nd char must be L or E
     * 3rd/4th chars must be a hex number
     */ /* Verify 3rd/4th chars are a valid hex value */ /*
     * We are now sure we have an _Lxx or _Exx.
     * Create the target name that would cause collision (Flip E/L)
     */ /* Inject opposite letter ("L" versus "E") */ /* Name[1] == 'E' */ /* Search all peers (objects within this scope) for target match */ /*
         * We mostly care about methods, but check Name() constructs also,
         * even though they will get another error for not being a method.
         * All GPE names must be defined as control methods.
         */ /* Found both _Exy and _Lxy in the same scope, error */ /* OK, no conflict found */