diff options
| author | Jung-uk Kim <jkim@FreeBSD.org> | 2013-01-02 19:01:21 +0000 | 
|---|---|---|
| committer | Jung-uk Kim <jkim@FreeBSD.org> | 2013-01-02 19:01:21 +0000 | 
| commit | b28e481ae9b051dab150e9b5a89730cdc1103a9c (patch) | |
| tree | 434e706ece73a93073f350c91cd35ed7d7e98811 /source/compiler | |
| parent | c2463a8709e5b3a5ce54c09d35b4820a756b0fc5 (diff) | |
Diffstat (limited to 'source/compiler')
| -rw-r--r-- | source/compiler/aslcompile.c | 16 | ||||
| -rw-r--r-- | source/compiler/aslcompiler.h | 47 | ||||
| -rw-r--r-- | source/compiler/aslcompiler.y | 15 | ||||
| -rw-r--r-- | source/compiler/aslfileio.c | 393 | ||||
| -rw-r--r-- | source/compiler/aslfiles.c | 348 | ||||
| -rw-r--r-- | source/compiler/aslhex.c | 401 | ||||
| -rw-r--r-- | source/compiler/asllisting.c | 445 | ||||
| -rw-r--r-- | source/compiler/asllookup.c | 1236 | ||||
| -rw-r--r-- | source/compiler/aslmessages.h | 4 | ||||
| -rw-r--r-- | source/compiler/aslmethod.c | 619 | ||||
| -rw-r--r-- | source/compiler/aslnamesp.c | 422 | ||||
| -rw-r--r-- | source/compiler/aslopcodes.c | 8 | ||||
| -rw-r--r-- | source/compiler/aslopt.c | 6 | ||||
| -rw-r--r-- | source/compiler/aslstartup.c | 2 | ||||
| -rw-r--r-- | source/compiler/aslutils.c | 3 | ||||
| -rw-r--r-- | source/compiler/aslwalks.c | 571 | ||||
| -rw-r--r-- | source/compiler/aslxref.c | 874 | ||||
| -rw-r--r-- | source/compiler/dtcompile.c | 10 | ||||
| -rw-r--r-- | source/compiler/dtcompiler.h | 15 | ||||
| -rw-r--r-- | source/compiler/dtio.c | 153 | ||||
| -rw-r--r-- | source/compiler/dtsubtable.c | 1 | ||||
| -rw-r--r-- | source/compiler/dttable.c | 88 | ||||
| -rw-r--r-- | source/compiler/dttemplate.h | 57 | 
23 files changed, 3154 insertions, 2580 deletions
| diff --git a/source/compiler/aslcompile.c b/source/compiler/aslcompile.c index 269c1bffaf6d..941dd5d0fdea 100644 --- a/source/compiler/aslcompile.c +++ b/source/compiler/aslcompile.c @@ -617,7 +617,7 @@ CmDoCompile (      /* Namespace cross-reference */      AslGbl_NamespaceEvent = UtBeginEvent ("Cross reference parse tree and Namespace"); -    Status = LkCrossReferenceNamespace (); +    Status = XfCrossReferenceNamespace ();      if (ACPI_FAILURE (Status))      {          goto ErrorExit; @@ -639,8 +639,8 @@ CmDoCompile (      DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method analysis\n\n");      TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, -        AnMethodAnalysisWalkBegin, -        AnMethodAnalysisWalkEnd, &AnalysisWalkInfo); +        MtMethodAnalysisWalkBegin, +        MtMethodAnalysisWalkEnd, &AnalysisWalkInfo);      UtEndEvent (Event);      /* Semantic error checking part two - typing of method returns */ @@ -719,11 +719,11 @@ CmDoOutputFiles (      /* Create listings and hex files */      LsDoListings (); -    LsDoHexOutput (); +    HxDoHexOutput ();      /* Dump the namespace to the .nsp file if requested */ -    (void) LsDisplayNamespace (); +    (void) NsDisplayNamespace ();  } @@ -766,12 +766,12 @@ CmDumpAllEvents (              Delta = (UINT32) (Event->EndTime - Event->StartTime); -            USec = Delta / 10; -            MSec = Delta / 10000; +            USec = Delta / ACPI_100NSEC_PER_USEC; +            MSec = Delta / ACPI_100NSEC_PER_MSEC;              /* Round milliseconds up */ -            if ((USec - (MSec * 1000)) >= 500) +            if ((USec - (MSec * ACPI_USEC_PER_MSEC)) >= 500)              {                  MSec++;              } diff --git a/source/compiler/aslcompiler.h b/source/compiler/aslcompiler.h index d591b46e4a3a..6ef1f55f2110 100644 --- a/source/compiler/aslcompiler.h +++ b/source/compiler/aslcompiler.h @@ -188,19 +188,23 @@ AnOperandTypecheckWalkEnd (      void                    *Context);  ACPI_STATUS -AnMethodAnalysisWalkBegin ( +AnMethodTypingWalkEnd (      ACPI_PARSE_OBJECT       *Op,      UINT32                  Level,      void                    *Context); + +/* + * aslmethod - Control method analysis walk + */  ACPI_STATUS -AnMethodAnalysisWalkEnd ( +MtMethodAnalysisWalkBegin (      ACPI_PARSE_OBJECT       *Op,      UINT32                  Level,      void                    *Context);  ACPI_STATUS -AnMethodTypingWalkEnd ( +MtMethodAnalysisWalkEnd (      ACPI_PARSE_OBJECT       *Op,      UINT32                  Level,      void                    *Context); @@ -342,6 +346,12 @@ LsDoListings (      void);  void +LsDumpAsciiInComment ( +    UINT32                  FileId, +    UINT32                  Count, +    UINT8                   *Buffer); + +void  LsWriteNodeToAsmListing (      ACPI_PARSE_OBJECT       *Op); @@ -351,13 +361,18 @@ LsWriteNode (      UINT32                  FileId);  void -LsDoHexOutput ( +LsDumpParseTree (      void); + +/* + * aslhex - generate all "hex" output files (C, ASM, ASL) + */  void -LsDumpParseTree ( +HxDoHexOutput (      void); +  /*   * aslfold - constant folding   */ @@ -689,26 +704,34 @@ LdLoadNamespace (  /* - * asllookup - namespace cross reference + * asllookup - namespace lookup functions   */ -ACPI_STATUS -LkCrossReferenceNamespace ( -    void); -  void  LkFindUnreferencedObjects (      void); + +/* + * aslnamesp - namespace output file generation + */  ACPI_STATUS -LsDisplayNamespace ( +NsDisplayNamespace (      void);  void -LsSetupNsList ( +NsSetupNamespaceListing (      void                    *Handle);  /* + * aslxref - namespace cross reference + */ +ACPI_STATUS +XfCrossReferenceNamespace ( +    void); + + +/*   * aslutils - common compiler utilites   */  void diff --git a/source/compiler/aslcompiler.y b/source/compiler/aslcompiler.y index d1f47da3a3a5..f8c5cbbb8c71 100644 --- a/source/compiler/aslcompiler.y +++ b/source/compiler/aslcompiler.y @@ -661,6 +661,7 @@ void *                      AslLocalAllocate (unsigned int Size);  /* Types */  %type <n> SuperName +%type <n> ObjectTypeName  %type <n> ArgTerm  %type <n> LocalTerm  %type <n> DebugTerm @@ -1991,7 +1992,7 @@ NotTerm  ObjectTypeTerm      : PARSEOP_OBJECTTYPE '('        {$<n>$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE);} -        SuperName +        ObjectTypeName          ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}      | PARSEOP_OBJECTTYPE '('          error ')'                   {$$ = AslDoError(); yyclearin;} @@ -2439,6 +2440,18 @@ SuperName      | LocalTerm                     {}      | DebugTerm                     {}      | Type6Opcode                   {} + +/* For ObjectType: SuperName except for UserTerm (method invocation) */ + +ObjectTypeName +    : NameString                    {} +    | ArgTerm                       {} +    | LocalTerm                     {} +    | DebugTerm                     {} +    | RefOfTerm                     {} +    | DerefOfTerm                   {} +    | IndexTerm                     {} +  /*    | UserTerm                      {} */  /* Caused reduce/reduce with Type6Opcode->UserTerm */      ; diff --git a/source/compiler/aslfileio.c b/source/compiler/aslfileio.c new file mode 100644 index 000000000000..4c25399e6051 --- /dev/null +++ b/source/compiler/aslfileio.c @@ -0,0 +1,393 @@ +/****************************************************************************** + * + * Module Name: aslfileio - File I/O support + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2012, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *    notice, this list of conditions, and the following disclaimer, + *    without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + *    substantially similar to the "NO WARRANTY" disclaimer below + *    ("Disclaimer") and any redistribution must be conditioned upon + *    including a substantially similar Disclaimer requirement for further + *    binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + *    of any contributors may be used to endorse or promote products derived + *    from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include "aslcompiler.h" + +#define _COMPONENT          ACPI_COMPILER +        ACPI_MODULE_NAME    ("aslfileio") + + +/******************************************************************************* + * + * FUNCTION:    AslAbort + * + * PARAMETERS:  None + * + * RETURN:      None + * + * DESCRIPTION: Dump the error log and abort the compiler. Used for serious + *              I/O errors. + * + ******************************************************************************/ + +void +AslAbort ( +    void) +{ + +    AePrintErrorLog (ASL_FILE_STDERR); +    if (Gbl_DebugFlag) +    { +        /* Print error summary to stdout also */ + +        AePrintErrorLog (ASL_FILE_STDOUT); +    } + +    exit (1); +} + + +/******************************************************************************* + * + * FUNCTION:    FlFileError + * + * PARAMETERS:  FileId              - Index into file info array + *              ErrorId             - Index into error message array + * + * RETURN:      None + * + * DESCRIPTION: Decode errno to an error message and add the entire error + *              to the error log. + * + ******************************************************************************/ + +void +FlFileError ( +    UINT32                  FileId, +    UINT8                   ErrorId) +{ + +    sprintf (MsgBuffer, "\"%s\" (%s)", Gbl_Files[FileId].Filename, +        strerror (errno)); +    AslCommonError (ASL_ERROR, ErrorId, 0, 0, 0, 0, NULL, MsgBuffer); +} + + +/******************************************************************************* + * + * FUNCTION:    FlOpenFile + * + * PARAMETERS:  FileId              - Index into file info array + *              Filename            - file pathname to open + *              Mode                - Open mode for fopen + * + * RETURN:      None + * + * DESCRIPTION: Open a file. + *              NOTE: Aborts compiler on any error. + * + ******************************************************************************/ + +void +FlOpenFile ( +    UINT32                  FileId, +    char                    *Filename, +    char                    *Mode) +{ +    FILE                    *File; + + +    File = fopen (Filename, Mode); +    if (!File) +    { +        FlFileError (FileId, ASL_MSG_OPEN); +        AslAbort (); +    } + +    Gbl_Files[FileId].Filename = Filename; +    Gbl_Files[FileId].Handle   = File; +} + + +/******************************************************************************* + * + * FUNCTION:    FlGetFileSize + * + * PARAMETERS:  FileId              - Index into file info array + * + * RETURN:      File Size + * + * DESCRIPTION: Get current file size. Uses seek-to-EOF. File must be open. + * + ******************************************************************************/ + +UINT32 +FlGetFileSize ( +    UINT32                  FileId) +{ +    FILE                    *fp; +    UINT32                  FileSize; +    long                    Offset; + + +    fp = Gbl_Files[FileId].Handle; +    Offset = ftell (fp); + +    fseek (fp, 0, SEEK_END); +    FileSize = (UINT32) ftell (fp); + +    /* Restore file pointer */ + +    fseek (fp, Offset, SEEK_SET); +    return (FileSize); +} + + +/******************************************************************************* + * + * FUNCTION:    FlReadFile + * + * PARAMETERS:  FileId              - Index into file info array + *              Buffer              - Where to place the data + *              Length              - Amount to read + * + * RETURN:      Status. AE_ERROR indicates EOF. + * + * DESCRIPTION: Read data from an open file. + *              NOTE: Aborts compiler on any error. + * + ******************************************************************************/ + +ACPI_STATUS +FlReadFile ( +    UINT32                  FileId, +    void                    *Buffer, +    UINT32                  Length) +{ +    UINT32                  Actual; + + +    /* Read and check for error */ + +    Actual = fread (Buffer, 1, Length, Gbl_Files[FileId].Handle); +    if (Actual < Length) +    { +        if (feof (Gbl_Files[FileId].Handle)) +        { +            /* End-of-file, just return error */ + +            return (AE_ERROR); +        } + +        FlFileError (FileId, ASL_MSG_READ); +        AslAbort (); +    } + +    return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION:    FlWriteFile + * + * PARAMETERS:  FileId              - Index into file info array + *              Buffer              - Data to write + *              Length              - Amount of data to write + * + * RETURN:      None + * + * DESCRIPTION: Write data to an open file. + *              NOTE: Aborts compiler on any error. + * + ******************************************************************************/ + +void +FlWriteFile ( +    UINT32                  FileId, +    void                    *Buffer, +    UINT32                  Length) +{ +    UINT32                  Actual; + + +    /* Write and check for error */ + +    Actual = fwrite ((char *) Buffer, 1, Length, Gbl_Files[FileId].Handle); +    if (Actual != Length) +    { +        FlFileError (FileId, ASL_MSG_WRITE); +        AslAbort (); +    } +} + + +/******************************************************************************* + * + * FUNCTION:    FlPrintFile + * + * PARAMETERS:  FileId              - Index into file info array + *              Format              - Printf format string + *              ...                 - Printf arguments + * + * RETURN:      None + * + * DESCRIPTION: Formatted write to an open file. + *              NOTE: Aborts compiler on any error. + * + ******************************************************************************/ + +void +FlPrintFile ( +    UINT32                  FileId, +    char                    *Format, +    ...) +{ +    INT32                   Actual; +    va_list                 Args; + + +    va_start (Args, Format); + +    Actual = vfprintf (Gbl_Files[FileId].Handle, Format, Args); +    va_end (Args); + +    if (Actual == -1) +    { +        FlFileError (FileId, ASL_MSG_WRITE); +        AslAbort (); +    } +} + + +/******************************************************************************* + * + * FUNCTION:    FlSeekFile + * + * PARAMETERS:  FileId              - Index into file info array + *              Offset              - Absolute byte offset in file + * + * RETURN:      None + * + * DESCRIPTION: Seek to absolute offset. + *              NOTE: Aborts compiler on any error. + * + ******************************************************************************/ + +void +FlSeekFile ( +    UINT32                  FileId, +    long                    Offset) +{ +    int                     Error; + + +    Error = fseek (Gbl_Files[FileId].Handle, Offset, SEEK_SET); +    if (Error) +    { +        FlFileError (FileId, ASL_MSG_SEEK); +        AslAbort (); +    } +} + + +/******************************************************************************* + * + * FUNCTION:    FlCloseFile + * + * PARAMETERS:  FileId              - Index into file info array + * + * RETURN:      None + * + * DESCRIPTION: Close an open file. Aborts compiler on error + * + ******************************************************************************/ + +void +FlCloseFile ( +    UINT32                  FileId) +{ +    int                     Error; + + +    if (!Gbl_Files[FileId].Handle) +    { +        return; +    } + +    Error = fclose (Gbl_Files[FileId].Handle); +    if (Error) +    { +        FlFileError (FileId, ASL_MSG_CLOSE); +        AslAbort (); +    } + +    Gbl_Files[FileId].Handle = NULL; +    return; +} + + +/******************************************************************************* + * + * FUNCTION:    FlDeleteFile + * + * PARAMETERS:  FileId              - Index into file info array + * + * RETURN:      None + * + * DESCRIPTION: Delete a file. + * + ******************************************************************************/ + +void +FlDeleteFile ( +    UINT32                  FileId) +{ +    ASL_FILE_INFO           *Info = &Gbl_Files[FileId]; + + +    if (!Info->Filename) +    { +        return; +    } + +    if (remove (Info->Filename)) +    { +        printf ("%s (%s file) ", +            Info->Filename, Info->Description); +        perror ("Could not delete"); +    } + +    Info->Filename = NULL; +    return; +} diff --git a/source/compiler/aslfiles.c b/source/compiler/aslfiles.c index f63504af4540..142b5a335c71 100644 --- a/source/compiler/aslfiles.c +++ b/source/compiler/aslfiles.c @@ -1,6 +1,6 @@  /******************************************************************************   * - * Module Name: aslfiles - file I/O suppoert + * Module Name: aslfiles - File support functions   *   *****************************************************************************/ @@ -64,352 +64,6 @@ FlParseInputPathname (  /*******************************************************************************   * - * FUNCTION:    AslAbort - * - * PARAMETERS:  None - * - * RETURN:      None - * - * DESCRIPTION: Dump the error log and abort the compiler. Used for serious - *              I/O errors - * - ******************************************************************************/ - -void -AslAbort ( -    void) -{ - -    AePrintErrorLog (ASL_FILE_STDERR); -    if (Gbl_DebugFlag) -    { -        /* Print error summary to stdout also */ - -        AePrintErrorLog (ASL_FILE_STDOUT); -    } - -    exit (1); -} - - -/******************************************************************************* - * - * FUNCTION:    FlFileError - * - * PARAMETERS:  FileId              - Index into file info array - *              ErrorId             - Index into error message array - * - * RETURN:      None - * - * DESCRIPTION: Decode errno to an error message and add the entire error - *              to the error log. - * - ******************************************************************************/ - -void -FlFileError ( -    UINT32                  FileId, -    UINT8                   ErrorId) -{ - -    sprintf (MsgBuffer, "\"%s\" (%s)", Gbl_Files[FileId].Filename, -        strerror (errno)); -    AslCommonError (ASL_ERROR, ErrorId, 0, 0, 0, 0, NULL, MsgBuffer); -} - - -/******************************************************************************* - * - * FUNCTION:    FlOpenFile - * - * PARAMETERS:  FileId              - Index into file info array - *              Filename            - file pathname to open - *              Mode                - Open mode for fopen - * - * RETURN:      None - * - * DESCRIPTION: Open a file. - *              NOTE: Aborts compiler on any error. - * - ******************************************************************************/ - -void -FlOpenFile ( -    UINT32                  FileId, -    char                    *Filename, -    char                    *Mode) -{ -    FILE                    *File; - - -    File = fopen (Filename, Mode); -    if (!File) -    { -        FlFileError (FileId, ASL_MSG_OPEN); -        AslAbort (); -    } - -    Gbl_Files[FileId].Filename = Filename; -    Gbl_Files[FileId].Handle   = File; -} - - -/******************************************************************************* - * - * FUNCTION:    FlGetFileSize - * - * PARAMETERS:  FileId              - Index into file info array - * - * RETURN:      File Size - * - * DESCRIPTION: Get current file size. Uses seek-to-EOF. File must be open. - * - ******************************************************************************/ - -UINT32 -FlGetFileSize ( -    UINT32                  FileId) -{ -    FILE                    *fp; -    UINT32                  FileSize; -    long                    Offset; - - -    fp = Gbl_Files[FileId].Handle; -    Offset = ftell (fp); - -    fseek (fp, 0, SEEK_END); -    FileSize = (UINT32) ftell (fp); - -    /* Restore file pointer */ - -    fseek (fp, Offset, SEEK_SET); -    return (FileSize); -} - - -/******************************************************************************* - * - * FUNCTION:    FlReadFile - * - * PARAMETERS:  FileId              - Index into file info array - *              Buffer              - Where to place the data - *              Length              - Amount to read - * - * RETURN:      Status. AE_ERROR indicates EOF. - * - * DESCRIPTION: Read data from an open file. - *              NOTE: Aborts compiler on any error. - * - ******************************************************************************/ - -ACPI_STATUS -FlReadFile ( -    UINT32                  FileId, -    void                    *Buffer, -    UINT32                  Length) -{ -    UINT32                  Actual; - - -    /* Read and check for error */ - -    Actual = fread (Buffer, 1, Length, Gbl_Files[FileId].Handle); -    if (Actual < Length) -    { -        if (feof (Gbl_Files[FileId].Handle)) -        { -            /* End-of-file, just return error */ - -            return (AE_ERROR); -        } - -        FlFileError (FileId, ASL_MSG_READ); -        AslAbort (); -    } - -    return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION:    FlWriteFile - * - * PARAMETERS:  FileId              - Index into file info array - *              Buffer              - Data to write - *              Length              - Amount of data to write - * - * RETURN:      None - * - * DESCRIPTION: Write data to an open file. - *              NOTE: Aborts compiler on any error. - * - ******************************************************************************/ - -void -FlWriteFile ( -    UINT32                  FileId, -    void                    *Buffer, -    UINT32                  Length) -{ -    UINT32                  Actual; - - -    /* Write and check for error */ - -    Actual = fwrite ((char *) Buffer, 1, Length, Gbl_Files[FileId].Handle); -    if (Actual != Length) -    { -        FlFileError (FileId, ASL_MSG_WRITE); -        AslAbort (); -    } -} - - -/******************************************************************************* - * - * FUNCTION:    FlPrintFile - * - * PARAMETERS:  FileId              - Index into file info array - *              Format              - Printf format string - *              ...                 - Printf arguments - * - * RETURN:      None - * - * DESCRIPTION: Formatted write to an open file. - *              NOTE: Aborts compiler on any error. - * - ******************************************************************************/ - -void -FlPrintFile ( -    UINT32                  FileId, -    char                    *Format, -    ...) -{ -    INT32                   Actual; -    va_list                 Args; - - -    va_start (Args, Format); - -    Actual = vfprintf (Gbl_Files[FileId].Handle, Format, Args); -    va_end (Args); - -    if (Actual == -1) -    { -        FlFileError (FileId, ASL_MSG_WRITE); -        AslAbort (); -    } -} - - -/******************************************************************************* - * - * FUNCTION:    FlSeekFile - * - * PARAMETERS:  FileId              - Index into file info array - *              Offset              - Absolute byte offset in file - * - * RETURN:      None - * - * DESCRIPTION: Seek to absolute offset - *              NOTE: Aborts compiler on any error. - * - ******************************************************************************/ - -void -FlSeekFile ( -    UINT32                  FileId, -    long                    Offset) -{ -    int                     Error; - - -    Error = fseek (Gbl_Files[FileId].Handle, Offset, SEEK_SET); -    if (Error) -    { -        FlFileError (FileId, ASL_MSG_SEEK); -        AslAbort (); -    } -} - - -/******************************************************************************* - * - * FUNCTION:    FlCloseFile - * - * PARAMETERS:  FileId              - Index into file info array - * - * RETURN:      None - * - * DESCRIPTION: Close an open file. Aborts compiler on error - * - ******************************************************************************/ - -void -FlCloseFile ( -    UINT32                  FileId) -{ -    int                     Error; - - -    if (!Gbl_Files[FileId].Handle) -    { -        return; -    } - -    Error = fclose (Gbl_Files[FileId].Handle); -    if (Error) -    { -        FlFileError (FileId, ASL_MSG_CLOSE); -        AslAbort (); -    } - -    Gbl_Files[FileId].Handle = NULL; -    return; -} - - -/******************************************************************************* - * - * FUNCTION:    FlDeleteFile - * - * PARAMETERS:  FileId              - Index into file info array - * - * RETURN:      None - * - * DESCRIPTION: Delete a file. - * - ******************************************************************************/ - -void -FlDeleteFile ( -    UINT32                  FileId) -{ -    ASL_FILE_INFO           *Info = &Gbl_Files[FileId]; - - -    if (!Info->Filename) -    { -        return; -    } - -    if (remove (Info->Filename)) -    { -        printf ("%s (%s file) ", -            Info->Filename, Info->Description); -        perror ("Could not delete"); -    } - -    Info->Filename = NULL; -    return; -} - - -/******************************************************************************* - *   * FUNCTION:    FlSetLineNumber   *   * PARAMETERS:  Op        - Parse node for the LINE asl statement diff --git a/source/compiler/aslhex.c b/source/compiler/aslhex.c new file mode 100644 index 000000000000..fb97b7724775 --- /dev/null +++ b/source/compiler/aslhex.c @@ -0,0 +1,401 @@ +/****************************************************************************** + * + * Module Name: aslhex - ASCII hex output file generation (C, ASM, and ASL) + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2012, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *    notice, this list of conditions, and the following disclaimer, + *    without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + *    substantially similar to the "NO WARRANTY" disclaimer below + *    ("Disclaimer") and any redistribution must be conditioned upon + *    including a substantially similar Disclaimer requirement for further + *    binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + *    of any contributors may be used to endorse or promote products derived + *    from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + + +#include "aslcompiler.h" + +#define _COMPONENT          ACPI_COMPILER +        ACPI_MODULE_NAME    ("ashex") + +/* + * This module emits ASCII hex output files in either C, ASM, or ASL format + */ + + +/* Local prototypes */ + +static void +HxDoHexOutputC ( +    void); + +static void +HxDoHexOutputAsl ( +    void); + +static void +HxDoHexOutputAsm ( +    void); + +static UINT32 +HxReadAmlOutputFile ( +    UINT8                   *Buffer); + + +/******************************************************************************* + * + * FUNCTION:    HxDoHexOutput + * + * PARAMETERS:  None + * + * RETURN:      None + * + * DESCRIPTION: Create the hex output file. Note: data is obtained by reading + *              the entire AML output file that was previously generated. + * + ******************************************************************************/ + +void +HxDoHexOutput ( +    void) +{ + +    switch (Gbl_HexOutputFlag) +    { +    case HEX_OUTPUT_C: + +        HxDoHexOutputC (); +        break; + +    case HEX_OUTPUT_ASM: + +        HxDoHexOutputAsm (); +        break; + +    case HEX_OUTPUT_ASL: + +        HxDoHexOutputAsl (); +        break; + +    default: +        /* No other output types supported */ +        break; +    } +} + + +/******************************************************************************* + * + * FUNCTION:    HxReadAmlOutputFile + * + * PARAMETERS:  Buffer              - Where to return data + * + * RETURN:      None + * + * DESCRIPTION: Read a line of the AML output prior to formatting the data + * + ******************************************************************************/ + +static UINT32 +HxReadAmlOutputFile ( +    UINT8                   *Buffer) +{ +    UINT32                  Actual; + + +    Actual = fread (Buffer, 1, HEX_TABLE_LINE_SIZE, +        Gbl_Files[ASL_FILE_AML_OUTPUT].Handle); + +    if (ferror (Gbl_Files[ASL_FILE_AML_OUTPUT].Handle)) +    { +        FlFileError (ASL_FILE_AML_OUTPUT, ASL_MSG_READ); +        AslAbort (); +    } + +    return (Actual); +} + + +/******************************************************************************* + * + * FUNCTION:    HxDoHexOutputC + * + * PARAMETERS:  None + * + * RETURN:      None + * + * DESCRIPTION: Create the hex output file. This is the same data as the AML + *              output file, but formatted into hex/ascii bytes suitable for + *              inclusion into a C source file. + * + ******************************************************************************/ + +static void +HxDoHexOutputC ( +    void) +{ +    UINT8                   FileData[HEX_TABLE_LINE_SIZE]; +    UINT32                  LineLength; +    UINT32                  Offset = 0; +    UINT32                  AmlFileSize; +    UINT32                  i; + + +    /* Get AML size, seek back to start */ + +    AmlFileSize = FlGetFileSize (ASL_FILE_AML_OUTPUT); +    FlSeekFile (ASL_FILE_AML_OUTPUT, 0); + +    FlPrintFile (ASL_FILE_HEX_OUTPUT, " * C source code output\n"); +    FlPrintFile (ASL_FILE_HEX_OUTPUT, " * AML code block contains 0x%X bytes\n *\n */\n", +        AmlFileSize); +    FlPrintFile (ASL_FILE_HEX_OUTPUT, "unsigned char AmlCode[] =\n{\n"); + +    while (Offset < AmlFileSize) +    { +        /* Read enough bytes needed for one output line */ + +        LineLength = HxReadAmlOutputFile (FileData); +        if (!LineLength) +        { +            break; +        } + +        FlPrintFile (ASL_FILE_HEX_OUTPUT, "    "); + +        for (i = 0; i < LineLength; i++) +        { +            /* +             * Print each hex byte. +             * Add a comma until the very last byte of the AML file +             * (Some C compilers complain about a trailing comma) +             */ +            FlPrintFile (ASL_FILE_HEX_OUTPUT, "0x%2.2X", FileData[i]); +            if ((Offset + i + 1) < AmlFileSize) +            { +                FlPrintFile (ASL_FILE_HEX_OUTPUT, ","); +            } +            else +            { +                FlPrintFile (ASL_FILE_HEX_OUTPUT, " "); +            } +        } + +        /* Add fill spaces if needed for last line */ + +        if (LineLength < HEX_TABLE_LINE_SIZE) +        { +            FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s", +                5 * (HEX_TABLE_LINE_SIZE - LineLength), " "); +        } + +        /* Emit the offset and ascii dump for the entire line */ + +        FlPrintFile (ASL_FILE_HEX_OUTPUT, "  /* %8.8X", Offset); +        LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData); +        FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s*/\n", +            HEX_TABLE_LINE_SIZE - LineLength + 1, " "); + +        Offset += LineLength; +    } + +    FlPrintFile (ASL_FILE_HEX_OUTPUT, "};\n"); +} + + +/******************************************************************************* + * + * FUNCTION:    HxDoHexOutputAsl + * + * PARAMETERS:  None + * + * RETURN:      None + * + * DESCRIPTION: Create the hex output file. This is the same data as the AML + *              output file, but formatted into hex/ascii bytes suitable for + *              inclusion into a C source file. + * + ******************************************************************************/ + +static void +HxDoHexOutputAsl ( +    void) +{ +    UINT8                   FileData[HEX_TABLE_LINE_SIZE]; +    UINT32                  LineLength; +    UINT32                  Offset = 0; +    UINT32                  AmlFileSize; +    UINT32                  i; + + +    /* Get AML size, seek back to start */ + +    AmlFileSize = FlGetFileSize (ASL_FILE_AML_OUTPUT); +    FlSeekFile (ASL_FILE_AML_OUTPUT, 0); + +    FlPrintFile (ASL_FILE_HEX_OUTPUT, " * ASL source code output\n"); +    FlPrintFile (ASL_FILE_HEX_OUTPUT, " * AML code block contains 0x%X bytes\n *\n */\n", +        AmlFileSize); +    FlPrintFile (ASL_FILE_HEX_OUTPUT, "    Name (BUF1, Buffer()\n    {\n"); + +    while (Offset < AmlFileSize) +    { +        /* Read enough bytes needed for one output line */ + +        LineLength = HxReadAmlOutputFile (FileData); +        if (!LineLength) +        { +            break; +        } + +        FlPrintFile (ASL_FILE_HEX_OUTPUT, "        "); + +        for (i = 0; i < LineLength; i++) +        { +            /* +             * Print each hex byte. +             * Add a comma until the very last byte of the AML file +             * (Some C compilers complain about a trailing comma) +             */ +            FlPrintFile (ASL_FILE_HEX_OUTPUT, "0x%2.2X", FileData[i]); +            if ((Offset + i + 1) < AmlFileSize) +            { +                FlPrintFile (ASL_FILE_HEX_OUTPUT, ","); +            } +            else +            { +                FlPrintFile (ASL_FILE_HEX_OUTPUT, " "); +            } +        } + +        /* Add fill spaces if needed for last line */ + +        if (LineLength < HEX_TABLE_LINE_SIZE) +        { +            FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s", +                5 * (HEX_TABLE_LINE_SIZE - LineLength), " "); +        } + +        /* Emit the offset and ascii dump for the entire line */ + +        FlPrintFile (ASL_FILE_HEX_OUTPUT, "  /* %8.8X", Offset); +        LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData); +        FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s*/\n", +            HEX_TABLE_LINE_SIZE - LineLength + 1, " "); + +        Offset += LineLength; +    } + +    FlPrintFile (ASL_FILE_HEX_OUTPUT, "    })\n"); +} + + +/******************************************************************************* + * + * FUNCTION:    HxDoHexOutputAsm + * + * PARAMETERS:  None + * + * RETURN:      None + * + * DESCRIPTION: Create the hex output file. This is the same data as the AML + *              output file, but formatted into hex/ascii bytes suitable for + *              inclusion into a ASM source file. + * + ******************************************************************************/ + +static void +HxDoHexOutputAsm ( +    void) +{ +    UINT8                   FileData[HEX_TABLE_LINE_SIZE]; +    UINT32                  LineLength; +    UINT32                  Offset = 0; +    UINT32                  AmlFileSize; +    UINT32                  i; + + +    /* Get AML size, seek back to start */ + +    AmlFileSize = FlGetFileSize (ASL_FILE_AML_OUTPUT); +    FlSeekFile (ASL_FILE_AML_OUTPUT, 0); + +    FlPrintFile (ASL_FILE_HEX_OUTPUT, "; Assembly code source output\n"); +    FlPrintFile (ASL_FILE_HEX_OUTPUT, "; AML code block contains 0x%X bytes\n;\n", +        AmlFileSize); + +    while (Offset < AmlFileSize) +    { +        /* Read enough bytes needed for one output line */ + +        LineLength = HxReadAmlOutputFile (FileData); +        if (!LineLength) +        { +            break; +        } + +        FlPrintFile (ASL_FILE_HEX_OUTPUT, "  db  "); + +        for (i = 0; i < LineLength; i++) +        { +            /* +             * Print each hex byte. +             * Add a comma until the last byte of the line +             */ +            FlPrintFile (ASL_FILE_HEX_OUTPUT, "0%2.2Xh", FileData[i]); +            if ((i + 1) < LineLength) +            { +                FlPrintFile (ASL_FILE_HEX_OUTPUT, ","); +            } +        } + +        FlPrintFile (ASL_FILE_HEX_OUTPUT, " "); + +        /* Add fill spaces if needed for last line */ + +        if (LineLength < HEX_TABLE_LINE_SIZE) +        { +            FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s", +                5 * (HEX_TABLE_LINE_SIZE - LineLength), " "); +        } + +        /* Emit the offset and ascii dump for the entire line */ + +        FlPrintFile (ASL_FILE_HEX_OUTPUT, "  ; %8.8X", Offset); +        LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData); +        FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n"); + +        Offset += LineLength; +    } + +    FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n"); +} diff --git a/source/compiler/asllisting.c b/source/compiler/asllisting.c index b70bcf8ab8d5..5bf50e2d5371 100644 --- a/source/compiler/asllisting.c +++ b/source/compiler/asllisting.c @@ -59,12 +59,6 @@ LsDumpAscii (      UINT32                  Count,      UINT8                   *Buffer); -static void -LsDumpAsciiInComment ( -    UINT32                  FileId, -    UINT32                  Count, -    UINT8                   *Buffer); -  static ACPI_STATUS  LsAmlListingWalk (      ACPI_PARSE_OBJECT       *Op, @@ -117,27 +111,55 @@ LsWriteNodeToListing (      ACPI_PARSE_OBJECT       *Op,      UINT32                  FileId); -static void -LsDoHexOutputC ( -    void); - -static void -LsDoHexOutputAsm ( -    void); - -static void -LsDoHexOutputAsl ( -    void); -  static ACPI_STATUS  LsTreeWriteWalk (      ACPI_PARSE_OBJECT       *Op,      UINT32                  Level,      void                    *Context); -static UINT32 -LsReadAmlOutputFile ( -    UINT8                   *Buffer); + +/******************************************************************************* + * + * FUNCTION:    LsDoListings + * + * PARAMETERS:  None + * + * RETURN:      None + * + * DESCRIPTION: Generate all requested listing files. + * + ******************************************************************************/ + +void +LsDoListings ( +    void) +{ + +    if (Gbl_C_OutputFlag) +    { +        LsGenerateListing (ASL_FILE_C_SOURCE_OUTPUT); +    } + +    if (Gbl_ListingFlag) +    { +        LsGenerateListing (ASL_FILE_LISTING_OUTPUT); +    } + +    if (Gbl_AsmOutputFlag) +    { +        LsGenerateListing (ASL_FILE_ASM_SOURCE_OUTPUT); +    } + +    if (Gbl_C_IncludeOutputFlag) +    { +        LsGenerateListing (ASL_FILE_C_INCLUDE_OUTPUT); +    } + +    if (Gbl_AsmIncludeOutputFlag) +    { +        LsGenerateListing (ASL_FILE_ASM_INCLUDE_OUTPUT); +    } +}  /******************************************************************************* @@ -147,7 +169,7 @@ LsReadAmlOutputFile (   * PARAMETERS:  ASL_WALK_CALLBACK   *   * - * RETURN:      None. + * RETURN:      None   *   * DESCRIPTION: Dump entire parse tree, for compiler debug only   * @@ -196,7 +218,7 @@ LsDumpParseTree (   *              Count           - Number of bytes to convert   *              Buffer          - Buffer of bytes to convert   * - * RETURN:      None. + * RETURN:      None   *   * DESCRIPTION: Convert hex bytes to ascii   * @@ -239,13 +261,13 @@ LsDumpAscii (   *              Count           - Number of bytes to convert   *              Buffer          - Buffer of bytes to convert   * - * RETURN:      None. + * RETURN:      None   *   * DESCRIPTION: Convert hex bytes to ascii   *   ******************************************************************************/ -static void +void  LsDumpAsciiInComment (      UINT32                  FileId,      UINT32                  Count, @@ -374,50 +396,6 @@ LsGenerateListing (  /*******************************************************************************   * - * FUNCTION:    LsDoListings - * - * PARAMETERS:  None. - * - * RETURN:      None - * - * DESCRIPTION: Generate all requested listing files. - * - ******************************************************************************/ - -void -LsDoListings ( -    void) -{ - -    if (Gbl_C_OutputFlag) -    { -        LsGenerateListing (ASL_FILE_C_SOURCE_OUTPUT); -    } - -    if (Gbl_ListingFlag) -    { -        LsGenerateListing (ASL_FILE_LISTING_OUTPUT); -    } - -    if (Gbl_AsmOutputFlag) -    { -        LsGenerateListing (ASL_FILE_ASM_SOURCE_OUTPUT); -    } - -    if (Gbl_C_IncludeOutputFlag) -    { -        LsGenerateListing (ASL_FILE_C_INCLUDE_OUTPUT); -    } - -    if (Gbl_AsmIncludeOutputFlag) -    { -        LsGenerateListing (ASL_FILE_ASM_INCLUDE_OUTPUT); -    } -} - - -/******************************************************************************* - *   * FUNCTION:    LsPushNode   *   * PARAMETERS:  Filename        - Pointer to the include filename @@ -1241,332 +1219,3 @@ LsWriteNodeToListing (          break;      }  } - - -/******************************************************************************* - * - * FUNCTION:    LsDoHexOutput - * - * PARAMETERS:  None - * - * RETURN:      None. - * - * DESCRIPTION: Create the hex output file. - * - ******************************************************************************/ - -void -LsDoHexOutput ( -    void) -{ - -    switch (Gbl_HexOutputFlag) -    { -    case HEX_OUTPUT_C: - -        LsDoHexOutputC (); -        break; - -    case HEX_OUTPUT_ASM: - -        LsDoHexOutputAsm (); -        break; - -    case HEX_OUTPUT_ASL: - -        LsDoHexOutputAsl (); -        break; - -    default: -        /* No other output types supported */ -        break; -    } -} - - -/******************************************************************************* - * - * FUNCTION:    LsReadAmlOutputFile - * - * PARAMETERS:  Buffer              - Where to return data - * - * RETURN:      None. - * - * DESCRIPTION: Read a line of the AML output prior to formatting the data - * - ******************************************************************************/ - -static UINT32 -LsReadAmlOutputFile ( -    UINT8                   *Buffer) -{ -    UINT32                  Actual; - - -    Actual = fread (Buffer, 1, HEX_TABLE_LINE_SIZE, -        Gbl_Files[ASL_FILE_AML_OUTPUT].Handle); - -    if (ferror (Gbl_Files[ASL_FILE_AML_OUTPUT].Handle)) -    { -        FlFileError (ASL_FILE_AML_OUTPUT, ASL_MSG_READ); -        AslAbort (); -    } - -    return (Actual); -} - - -/******************************************************************************* - * - * FUNCTION:    LsDoHexOutputC - * - * PARAMETERS:  None - * - * RETURN:      None. - * - * DESCRIPTION: Create the hex output file. This is the same data as the AML - *              output file, but formatted into hex/ascii bytes suitable for - *              inclusion into a C source file. - * - ******************************************************************************/ - -static void -LsDoHexOutputC ( -    void) -{ -    UINT8                   FileData[HEX_TABLE_LINE_SIZE]; -    UINT32                  LineLength; -    UINT32                  Offset = 0; -    UINT32                  AmlFileSize; -    UINT32                  i; - - -    /* Get AML size, seek back to start */ - -    AmlFileSize = FlGetFileSize (ASL_FILE_AML_OUTPUT); -    FlSeekFile (ASL_FILE_AML_OUTPUT, 0); - -    FlPrintFile (ASL_FILE_HEX_OUTPUT, " * C source code output\n"); -    FlPrintFile (ASL_FILE_HEX_OUTPUT, " * AML code block contains 0x%X bytes\n *\n */\n", -        AmlFileSize); -    FlPrintFile (ASL_FILE_HEX_OUTPUT, "unsigned char AmlCode[] =\n{\n"); - -    while (Offset < AmlFileSize) -    { -        /* Read enough bytes needed for one output line */ - -        LineLength = LsReadAmlOutputFile (FileData); -        if (!LineLength) -        { -            break; -        } - -        FlPrintFile (ASL_FILE_HEX_OUTPUT, "    "); - -        for (i = 0; i < LineLength; i++) -        { -            /* -             * Print each hex byte. -             * Add a comma until the very last byte of the AML file -             * (Some C compilers complain about a trailing comma) -             */ -            FlPrintFile (ASL_FILE_HEX_OUTPUT, "0x%2.2X", FileData[i]); -            if ((Offset + i + 1) < AmlFileSize) -            { -                FlPrintFile (ASL_FILE_HEX_OUTPUT, ","); -            } -            else -            { -                FlPrintFile (ASL_FILE_HEX_OUTPUT, " "); -            } -        } - -        /* Add fill spaces if needed for last line */ - -        if (LineLength < HEX_TABLE_LINE_SIZE) -        { -            FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s", -                5 * (HEX_TABLE_LINE_SIZE - LineLength), " "); -        } - -        /* Emit the offset and ascii dump for the entire line */ - -        FlPrintFile (ASL_FILE_HEX_OUTPUT, "  /* %8.8X", Offset); -        LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData); -        FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s*/\n", -            HEX_TABLE_LINE_SIZE - LineLength + 1, " "); - -        Offset += LineLength; -    } - -    FlPrintFile (ASL_FILE_HEX_OUTPUT, "};\n"); -} - - -/******************************************************************************* - * - * FUNCTION:    LsDoHexOutputAsl - * - * PARAMETERS:  None - * - * RETURN:      None. - * - * DESCRIPTION: Create the hex output file. This is the same data as the AML - *              output file, but formatted into hex/ascii bytes suitable for - *              inclusion into a C source file. - * - ******************************************************************************/ - -static void -LsDoHexOutputAsl ( -    void) -{ -    UINT8                   FileData[HEX_TABLE_LINE_SIZE]; -    UINT32                  LineLength; -    UINT32                  Offset = 0; -    UINT32                  AmlFileSize; -    UINT32                  i; - - -    /* Get AML size, seek back to start */ - -    AmlFileSize = FlGetFileSize (ASL_FILE_AML_OUTPUT); -    FlSeekFile (ASL_FILE_AML_OUTPUT, 0); - -    FlPrintFile (ASL_FILE_HEX_OUTPUT, " * ASL source code output\n"); -    FlPrintFile (ASL_FILE_HEX_OUTPUT, " * AML code block contains 0x%X bytes\n *\n */\n", -        AmlFileSize); -    FlPrintFile (ASL_FILE_HEX_OUTPUT, "    Name (BUF1, Buffer()\n    {\n"); - -    while (Offset < AmlFileSize) -    { -        /* Read enough bytes needed for one output line */ - -        LineLength = LsReadAmlOutputFile (FileData); -        if (!LineLength) -        { -            break; -        } - -        FlPrintFile (ASL_FILE_HEX_OUTPUT, "        "); - -        for (i = 0; i < LineLength; i++) -        { -            /* -             * Print each hex byte. -             * Add a comma until the very last byte of the AML file -             * (Some C compilers complain about a trailing comma) -             */ -            FlPrintFile (ASL_FILE_HEX_OUTPUT, "0x%2.2X", FileData[i]); -            if ((Offset + i + 1) < AmlFileSize) -            { -                FlPrintFile (ASL_FILE_HEX_OUTPUT, ","); -            } -            else -            { -                FlPrintFile (ASL_FILE_HEX_OUTPUT, " "); -            } -        } - -        /* Add fill spaces if needed for last line */ - -        if (LineLength < HEX_TABLE_LINE_SIZE) -        { -            FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s", -                5 * (HEX_TABLE_LINE_SIZE - LineLength), " "); -        } - -        /* Emit the offset and ascii dump for the entire line */ - -        FlPrintFile (ASL_FILE_HEX_OUTPUT, "  /* %8.8X", Offset); -        LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData); -        FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s*/\n", -            HEX_TABLE_LINE_SIZE - LineLength + 1, " "); - -        Offset += LineLength; -    } - -    FlPrintFile (ASL_FILE_HEX_OUTPUT, "    })\n"); -} - - -/******************************************************************************* - * - * FUNCTION:    LsDoHexOutputAsm - * - * PARAMETERS:  None - * - * RETURN:      None. - * - * DESCRIPTION: Create the hex output file. This is the same data as the AML - *              output file, but formatted into hex/ascii bytes suitable for - *              inclusion into a ASM source file. - * - ******************************************************************************/ - -static void -LsDoHexOutputAsm ( -    void) -{ -    UINT8                   FileData[HEX_TABLE_LINE_SIZE]; -    UINT32                  LineLength; -    UINT32                  Offset = 0; -    UINT32                  AmlFileSize; -    UINT32                  i; - - -    /* Get AML size, seek back to start */ - -    AmlFileSize = FlGetFileSize (ASL_FILE_AML_OUTPUT); -    FlSeekFile (ASL_FILE_AML_OUTPUT, 0); - -    FlPrintFile (ASL_FILE_HEX_OUTPUT, "; Assembly code source output\n"); -    FlPrintFile (ASL_FILE_HEX_OUTPUT, "; AML code block contains 0x%X bytes\n;\n", -        AmlFileSize); - -    while (Offset < AmlFileSize) -    { -        /* Read enough bytes needed for one output line */ - -        LineLength = LsReadAmlOutputFile (FileData); -        if (!LineLength) -        { -            break; -        } - -        FlPrintFile (ASL_FILE_HEX_OUTPUT, "  db  "); - -        for (i = 0; i < LineLength; i++) -        { -            /* -             * Print each hex byte. -             * Add a comma until the last byte of the line -             */ -            FlPrintFile (ASL_FILE_HEX_OUTPUT, "0%2.2Xh", FileData[i]); -            if ((i + 1) < LineLength) -            { -                FlPrintFile (ASL_FILE_HEX_OUTPUT, ","); -            } -        } - -        FlPrintFile (ASL_FILE_HEX_OUTPUT, " "); - -        /* Add fill spaces if needed for last line */ - -        if (LineLength < HEX_TABLE_LINE_SIZE) -        { -            FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s", -                5 * (HEX_TABLE_LINE_SIZE - LineLength), " "); -        } - -        /* Emit the offset and ascii dump for the entire line */ - -        FlPrintFile (ASL_FILE_HEX_OUTPUT, "  ; %8.8X", Offset); -        LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData); -        FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n"); - -        Offset += LineLength; -    } - -    FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n"); -} diff --git a/source/compiler/asllookup.c b/source/compiler/asllookup.c index f051879b3bfa..1de4dea03a69 100644 --- a/source/compiler/asllookup.c +++ b/source/compiler/asllookup.c @@ -1,6 +1,6 @@  /******************************************************************************   * - * Module Name: asllookup- Namespace lookup + * Module Name: asllookup- Namespace lookup functions   *   *****************************************************************************/ @@ -44,7 +44,6 @@  #include "aslcompiler.h"  #include "aslcompiler.y.h" -  #include "acparser.h"  #include "amlcode.h"  #include "acnamesp.h" @@ -57,57 +56,12 @@  /* Local prototypes */  static ACPI_STATUS -LsCompareOneNamespaceObject ( -    ACPI_HANDLE             ObjHandle, -    UINT32                  Level, -    void                    *Context, -    void                    **ReturnValue); - -static ACPI_STATUS -LsDoOneNamespaceObject ( -    ACPI_HANDLE             ObjHandle, -    UINT32                  Level, -    void                    *Context, -    void                    **ReturnValue); - -static BOOLEAN -LkObjectExists ( -    char                    *Name); - -static void -LkCheckFieldRange ( -    ACPI_PARSE_OBJECT       *Op, -    UINT32                  RegionBitLength, -    UINT32                  FieldBitOffset, -    UINT32                  FieldBitLength, -    UINT32                  AccessBitWidth); - -static ACPI_STATUS -LkNamespaceLocateBegin ( -    ACPI_PARSE_OBJECT       *Op, -    UINT32                  Level, -    void                    *Context); - -static ACPI_STATUS -LkNamespaceLocateEnd ( -    ACPI_PARSE_OBJECT       *Op, -    UINT32                  Level, -    void                    *Context); - -static ACPI_STATUS  LkIsObjectUsed (      ACPI_HANDLE             ObjHandle,      UINT32                  Level,      void                    *Context,      void                    **ReturnValue); -static ACPI_STATUS -LsDoOnePathname ( -    ACPI_HANDLE             ObjHandle, -    UINT32                  Level, -    void                    *Context, -    void                    **ReturnValue); -  static ACPI_PARSE_OBJECT *  LkGetNameOp (      ACPI_PARSE_OBJECT       *Op); @@ -115,480 +69,28 @@ LkGetNameOp (  /*******************************************************************************   * - * FUNCTION:    LsDoOneNamespaceObject - * - * PARAMETERS:  ACPI_WALK_CALLBACK - * - * RETURN:      Status - * - * DESCRIPTION: Dump a namespace object to the namespace output file. - *              Called during the walk of the namespace to dump all objects. - * - ******************************************************************************/ - -static ACPI_STATUS -LsDoOneNamespaceObject ( -    ACPI_HANDLE             ObjHandle, -    UINT32                  Level, -    void                    *Context, -    void                    **ReturnValue) -{ -    ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; -    ACPI_OPERAND_OBJECT     *ObjDesc; -    ACPI_PARSE_OBJECT       *Op; - - -    Gbl_NumNamespaceObjects++; - -    FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "%5u  [%u]  %*s %4.4s - %s", -        Gbl_NumNamespaceObjects, Level, (Level * 3), " ", -        &Node->Name, -        AcpiUtGetTypeName (Node->Type)); - -    Op = Node->Op; -    ObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Node->Object); - -    if (!Op) -    { -        FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "\n"); -        return (AE_OK); -    } - - -    if ((ObjDesc) && -        (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND)) -    { -        switch (Node->Type) -        { -        case ACPI_TYPE_INTEGER: - -            FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, -                "       [Initial Value   0x%8.8X%8.8X]", -                ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); -            break; - - -        case ACPI_TYPE_STRING: - -            FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, -                "        [Initial Value   \"%s\"]", -                ObjDesc->String.Pointer); -            break; - -        default: -            /* Nothing to do for other types */ -            break; -        } - -    } -    else -    { -        switch (Node->Type) -        { -        case ACPI_TYPE_INTEGER: - -            if (Op->Asl.ParseOpcode == PARSEOP_NAME) -            { -                Op = Op->Asl.Child; -            } -            if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG)  || -                (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) -            { -                Op = Op->Asl.Next; -            } -            FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, -                "       [Initial Value   0x%8.8X%8.8X]", -                ACPI_FORMAT_UINT64 (Op->Asl.Value.Integer)); -            break; - - -        case ACPI_TYPE_STRING: - -            if (Op->Asl.ParseOpcode == PARSEOP_NAME) -            { -                Op = Op->Asl.Child; -            } -            if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG)  || -                (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) -            { -                Op = Op->Asl.Next; -            } -            FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, -                "        [Initial Value   \"%s\"]", -                Op->Asl.Value.String); -            break; - - -        case ACPI_TYPE_LOCAL_REGION_FIELD: - -            if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG)  || -                (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) -            { -                Op = Op->Asl.Child; -            } -            FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, -                "   [Offset 0x%04X   Length 0x%04X bits]", -                Op->Asl.Parent->Asl.ExtraValue, (UINT32) Op->Asl.Value.Integer); -            break; - - -        case ACPI_TYPE_BUFFER_FIELD: - -            switch (Op->Asl.ParseOpcode) -            { -            case PARSEOP_CREATEBYTEFIELD: -                FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "   [BYTE  ( 8 bit)]"); -                break; - -            case PARSEOP_CREATEDWORDFIELD: -                FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "   [DWORD (32 bit)]"); -                break; - -            case PARSEOP_CREATEQWORDFIELD: -                FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "   [QWORD (64 bit)]"); -                break; - -            case PARSEOP_CREATEWORDFIELD: -                FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "   [WORD  (16 bit)]"); -                break; - -            case PARSEOP_CREATEBITFIELD: -                FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "   [BIT   ( 1 bit)]"); -                break; - -            case PARSEOP_CREATEFIELD: -                FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "   [Arbitrary Bit Field]"); -                break; - -            default: -                break; - -            } -            break; - - -        case ACPI_TYPE_PACKAGE: - -            if (Op->Asl.ParseOpcode == PARSEOP_NAME) -            { -                Op = Op->Asl.Child; -            } -            if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG)  || -                (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) -            { -                Op = Op->Asl.Next; -            } -            Op = Op->Asl.Child; - -            if ((Op->Asl.ParseOpcode == PARSEOP_BYTECONST) || -                (Op->Asl.ParseOpcode == PARSEOP_RAW_DATA)) -            { -                FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, -                    "       [Initial Length  0x%.2X elements]", -                    Op->Asl.Value.Integer); -            } -            break; - - -        case ACPI_TYPE_BUFFER: - -            if (Op->Asl.ParseOpcode == PARSEOP_NAME) -            { -                Op = Op->Asl.Child; -            } -            if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG)  || -                (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) -            { -                Op = Op->Asl.Next; -            } -            Op = Op->Asl.Child; - -            if (Op && (Op->Asl.ParseOpcode == PARSEOP_INTEGER)) -            { -                FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, -                    "        [Initial Length  0x%.2X bytes]", -                    Op->Asl.Value.Integer); -            } -            break; - - -        case ACPI_TYPE_METHOD: - -            FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, -                "        [Code Length     0x%.4X bytes]", -                Op->Asl.AmlSubtreeLength); -            break; - - -        case ACPI_TYPE_LOCAL_RESOURCE: - -            FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, -                "  [Desc Offset     0x%.4X Bytes]", Node->Value); -            break; - - -        case ACPI_TYPE_LOCAL_RESOURCE_FIELD: - -            FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, -                "   [Field Offset    0x%.4X Bits 0x%.4X Bytes] ", -                Node->Value, Node->Value / 8); - -            if (Node->Flags & ANOBJ_IS_REFERENCED) -            { -                FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, -                    "Referenced"); -            } -            else -            { -                FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, -                    "Name not referenced"); -            } -            break; - - -        default: -            /* Nothing to do for other types */ -            break; -        } -    } - -    FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "\n"); -    return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION:    LsSetupNsList + * FUNCTION:    LkFindUnreferencedObjects   * - * PARAMETERS:  Handle          - local file handle + * PARAMETERS:  None   *   * RETURN:      None   * - * DESCRIPTION: Set the namespace output file to the input handle + * DESCRIPTION: Namespace walk to find objects that are not referenced in any + *              way. Must be called after the namespace has been cross + *              referenced.   *   ******************************************************************************/  void -LsSetupNsList ( -    void                    *Handle) -{ - -    Gbl_NsOutputFlag = TRUE; -    Gbl_Files[ASL_FILE_NAMESPACE_OUTPUT].Handle = Handle; -} - - -/******************************************************************************* - * - * FUNCTION:    LsDoOnePathname - * - * PARAMETERS:  ACPI_WALK_CALLBACK - * - * RETURN:      Status - * - * DESCRIPTION: Print the full pathname for a namespace node. - * - ******************************************************************************/ - -static ACPI_STATUS -LsDoOnePathname ( -    ACPI_HANDLE             ObjHandle, -    UINT32                  Level, -    void                    *Context, -    void                    **ReturnValue) -{ -    ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; -    ACPI_STATUS             Status; -    ACPI_BUFFER             TargetPath; - - -    TargetPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER; -    Status = AcpiNsHandleToPathname (Node, &TargetPath); -    if (ACPI_FAILURE (Status)) -    { -        return (Status); -    } - -    FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "%s\n", TargetPath.Pointer); -    ACPI_FREE (TargetPath.Pointer); - -    return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION:    LsDisplayNamespace - * - * PARAMETERS:  None - * - * RETURN:      Status - * - * DESCRIPTION: Walk the namespace an display information about each node - *              in the tree. Information is written to the optional - *              namespace output file. - * - ******************************************************************************/ - -ACPI_STATUS -LsDisplayNamespace ( +LkFindUnreferencedObjects (      void)  { -    ACPI_STATUS             Status; - - -    if (!Gbl_NsOutputFlag) -    { -        return (AE_OK); -    } - -    Gbl_NumNamespaceObjects = 0; - -    /* File header */ - -    FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "Contents of ACPI Namespace\n\n"); -    FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "Count  Depth    Name - Type\n\n"); - -    /* Walk entire namespace from the root */ - -    Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, -                ACPI_UINT32_MAX, FALSE, LsDoOneNamespaceObject, NULL, -                NULL, NULL); - -    /* Print the full pathname for each namespace node */ - -    FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "\nNamespace pathnames\n\n"); - -    Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, -                ACPI_UINT32_MAX, FALSE, LsDoOnePathname, NULL, -                NULL, NULL); - -    return (Status); -} - - -/******************************************************************************* - * - * FUNCTION:    LsCompareOneNamespaceObject - * - * PARAMETERS:  ACPI_WALK_CALLBACK - * - * RETURN:      Status - * - * DESCRIPTION: Compare name of one object. - * - ******************************************************************************/ - -static ACPI_STATUS -LsCompareOneNamespaceObject ( -    ACPI_HANDLE             ObjHandle, -    UINT32                  Level, -    void                    *Context, -    void                    **ReturnValue) -{ -    ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; - - -    /* Simply check the name */ - -    if (*((UINT32 *) (Context)) == Node->Name.Integer) -    { -        /* Abort walk if we found one instance */ - -        return (AE_CTRL_TRUE); -    } - -    return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION:    LkObjectExists - * - * PARAMETERS:  Name            - 4 char ACPI name - * - * RETURN:      TRUE if name exists in namespace - * - * DESCRIPTION: Walk the namespace to find an object - * - ******************************************************************************/ - -static BOOLEAN -LkObjectExists ( -    char                    *Name) -{ -    ACPI_STATUS             Status; -      /* Walk entire namespace from the supplied root */ -    Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, -                ACPI_UINT32_MAX, FALSE, LsCompareOneNamespaceObject, NULL, -                Name, NULL); -    if (Status == AE_CTRL_TRUE) -    { -        /* At least one instance of the name was found */ - -        return (TRUE); -    } - -    return (FALSE); -} - - -/******************************************************************************* - * - * FUNCTION:    LkGetNameOp - * - * PARAMETERS:  Op              - Current Op - * - * RETURN:      NameOp associated with the input op - * - * DESCRIPTION: Find the name declaration op associated with the operator - * - ******************************************************************************/ - -static ACPI_PARSE_OBJECT * -LkGetNameOp ( -    ACPI_PARSE_OBJECT       *Op) -{ -    const ACPI_OPCODE_INFO  *OpInfo; -    ACPI_PARSE_OBJECT       *NameOp = Op; - - -    OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); - - -    /* Get the NamePath from the appropriate place */ - -    if (OpInfo->Flags & AML_NAMED) -    { -        /* For nearly all NAMED operators, the name reference is the first child */ - -        NameOp = Op->Asl.Child; -        if (Op->Asl.AmlOpcode == AML_ALIAS_OP) -        { -            /* -             * ALIAS is the only oddball opcode, the name declaration -             * (alias name) is the second operand -             */ -            NameOp = Op->Asl.Child->Asl.Next; -        } -    } -    else if (OpInfo->Flags & AML_CREATE) -    { -        /* Name must appear as the last parameter */ - -        NameOp = Op->Asl.Child; -        while (!(NameOp->Asl.CompileFlags & NODE_IS_NAME_DECLARATION)) -        { -            NameOp = NameOp->Asl.Next; -        } -    } - -    return (NameOp); +    (void) AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, +                ACPI_UINT32_MAX, FALSE, LkIsObjectUsed, NULL, +                NULL, NULL);  } @@ -660,232 +162,26 @@ LkIsObjectUsed (  /*******************************************************************************   * - * FUNCTION:    LkFindUnreferencedObjects - * - * PARAMETERS:  None - * - * RETURN:      None - * - * DESCRIPTION: Namespace walk to find objects that are not referenced in any - *              way. Must be called after the namespace has been cross - *              referenced. - * - ******************************************************************************/ - -void -LkFindUnreferencedObjects ( -    void) -{ - -    /* Walk entire namespace from the supplied root */ - -    (void) AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, -                ACPI_UINT32_MAX, FALSE, LkIsObjectUsed, NULL, -                NULL, NULL); -} - - -/******************************************************************************* - * - * FUNCTION:    LkCrossReferenceNamespace - * - * PARAMETERS:  None - * - * RETURN:      Status - * - * DESCRIPTION: Perform a cross reference check of the parse tree against the - *              namespace. Every named referenced within the parse tree - *              should be get resolved with a namespace lookup. If not, the - *              original reference in the ASL code is invalid -- i.e., refers - *              to a non-existent object. - * - * NOTE:  The ASL "External" operator causes the name to be inserted into the - *        namespace so that references to the external name will be resolved - *        correctly here. - * - ******************************************************************************/ - -ACPI_STATUS -LkCrossReferenceNamespace ( -    void) -{ -    ACPI_WALK_STATE         *WalkState; - - -    DbgPrint (ASL_DEBUG_OUTPUT, "\nCross referencing namespace\n\n"); - -    /* -     * Create a new walk state for use when looking up names -     * within the namespace (Passed as context to the callbacks) -     */ -    WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); -    if (!WalkState) -    { -        return (AE_NO_MEMORY); -    } - -    /* Walk the entire parse tree */ - -    TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, LkNamespaceLocateBegin, -                        LkNamespaceLocateEnd, WalkState); -    return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION:    LkCheckFieldRange - * - * PARAMETERS:  RegionBitLength     - Length of entire parent region - *              FieldBitOffset      - Start of the field unit (within region) - *              FieldBitLength      - Entire length of field unit - *              AccessBitWidth      - Access width of the field unit - * - * RETURN:      None - * - * DESCRIPTION: Check one field unit to make sure it fits in the parent - *              op region. - * - * Note: AccessBitWidth must be either 8,16,32, or 64 - * - ******************************************************************************/ - -static void -LkCheckFieldRange ( -    ACPI_PARSE_OBJECT       *Op, -    UINT32                  RegionBitLength, -    UINT32                  FieldBitOffset, -    UINT32                  FieldBitLength, -    UINT32                  AccessBitWidth) -{ -    UINT32                  FieldEndBitOffset; - - -    /* -     * Check each field unit against the region size. The entire -     * field unit (start offset plus length) must fit within the -     * region. -     */ -    FieldEndBitOffset = FieldBitOffset + FieldBitLength; - -    if (FieldEndBitOffset > RegionBitLength) -    { -        /* Field definition itself is beyond the end-of-region */ - -        AslError (ASL_ERROR, ASL_MSG_FIELD_UNIT_OFFSET, Op, NULL); -        return; -    } - -    /* -     * Now check that the field plus AccessWidth doesn't go beyond -     * the end-of-region. Assumes AccessBitWidth is a power of 2 -     */ -    FieldEndBitOffset = ACPI_ROUND_UP (FieldEndBitOffset, AccessBitWidth); - -    if (FieldEndBitOffset > RegionBitLength) -    { -        /* Field definition combined with the access is beyond EOR */ - -        AslError (ASL_ERROR, ASL_MSG_FIELD_UNIT_ACCESS_WIDTH, Op, NULL); -    } -} - -/******************************************************************************* - * - * FUNCTION:    LkNamespaceLocateBegin - * - * PARAMETERS:  ASL_WALK_CALLBACK + * FUNCTION:    LkGetNameOp   * - * RETURN:      Status + * PARAMETERS:  Op              - Current Op   * - * DESCRIPTION: Descending callback used during cross-reference. For named - *              object references, attempt to locate the name in the - *              namespace. + * RETURN:      NameOp associated with the input op   * - * NOTE: ASL references to named fields within resource descriptors are - *       resolved to integer values here. Therefore, this step is an - *       important part of the code generation. We don't know that the - *       name refers to a resource descriptor until now. + * DESCRIPTION: Find the name declaration op associated with the operator   *   ******************************************************************************/ -static ACPI_STATUS -LkNamespaceLocateBegin ( -    ACPI_PARSE_OBJECT       *Op, -    UINT32                  Level, -    void                    *Context) +static ACPI_PARSE_OBJECT * +LkGetNameOp ( +    ACPI_PARSE_OBJECT       *Op)  { -    ACPI_WALK_STATE         *WalkState = (ACPI_WALK_STATE *) Context; -    ACPI_NAMESPACE_NODE     *Node; -    ACPI_STATUS             Status; -    ACPI_OBJECT_TYPE        ObjectType; -    char                    *Path; -    UINT8                   PassedArgs; -    ACPI_PARSE_OBJECT       *NextOp; -    ACPI_PARSE_OBJECT       *OwningOp; -    ACPI_PARSE_OBJECT       *SpaceIdOp; -    UINT32                  MinimumLength; -    UINT32                  Offset; -    UINT32                  FieldBitLength; -    UINT32                  TagBitLength; -    UINT8                   Message = 0;      const ACPI_OPCODE_INFO  *OpInfo; -    UINT32                  Flags; - - -    ACPI_FUNCTION_TRACE_PTR (LkNamespaceLocateBegin, Op); - -    /* -     * If this node is the actual declaration of a name -     * [such as the XXXX name in "Method (XXXX)"], -     * we are not interested in it here. We only care about names that are -     * references to other objects within the namespace and the parent objects -     * of name declarations -     */ -    if (Op->Asl.CompileFlags & NODE_IS_NAME_DECLARATION) -    { -        return (AE_OK); -    } +    ACPI_PARSE_OBJECT       *NameOp = Op; -    /* We are only interested in opcodes that have an associated name */      OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); -    if ((!(OpInfo->Flags & AML_NAMED)) && -        (!(OpInfo->Flags & AML_CREATE)) && -        (Op->Asl.ParseOpcode != PARSEOP_NAMESTRING) && -        (Op->Asl.ParseOpcode != PARSEOP_NAMESEG)    && -        (Op->Asl.ParseOpcode != PARSEOP_METHODCALL)) -    { -        return (AE_OK); -    } - -    /* -     * One special case: CondRefOf operator - we don't care if the name exists -     * or not at this point, just ignore it, the point of the operator is to -     * determine if the name exists at runtime. -     */ -    if ((Op->Asl.Parent) && -        (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)) -    { -        return (AE_OK); -    } - -    /* -     * We must enable the "search-to-root" for single NameSegs, but -     * we have to be very careful about opening up scopes -     */ -    Flags = ACPI_NS_SEARCH_PARENT; -    if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || -        (Op->Asl.ParseOpcode == PARSEOP_NAMESEG)    || -        (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)) -    { -        /* -         * These are name references, do not push the scope stack -         * for them. -         */ -        Flags |= ACPI_NS_DONT_OPEN_SCOPE; -    }      /* Get the NamePath from the appropriate place */ @@ -893,510 +189,26 @@ LkNamespaceLocateBegin (      {          /* For nearly all NAMED operators, the name reference is the first child */ -        Path = Op->Asl.Child->Asl.Value.String; +        NameOp = Op->Asl.Child;          if (Op->Asl.AmlOpcode == AML_ALIAS_OP)          {              /*               * ALIAS is the only oddball opcode, the name declaration               * (alias name) is the second operand               */ -            Path = Op->Asl.Child->Asl.Next->Asl.Value.String; +            NameOp = Op->Asl.Child->Asl.Next;          }      }      else if (OpInfo->Flags & AML_CREATE)      {          /* Name must appear as the last parameter */ -        NextOp = Op->Asl.Child; -        while (!(NextOp->Asl.CompileFlags & NODE_IS_NAME_DECLARATION)) -        { -            NextOp = NextOp->Asl.Next; -        } -        Path = NextOp->Asl.Value.String; -    } -    else -    { -        Path = Op->Asl.Value.String; -    } - -    ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); -    ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, -        "Type=%s\n", AcpiUtGetTypeName (ObjectType))); - -    /* -     * Lookup the name in the namespace. Name must exist at this point, or it -     * is an invalid reference. -     * -     * The namespace is also used as a lookup table for references to resource -     * descriptors and the fields within them. -     */ -    Gbl_NsLookupCount++; - -    Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, -                ACPI_IMODE_EXECUTE, Flags, WalkState, &(Node)); -    if (ACPI_FAILURE (Status)) -    { -        if (Status == AE_NOT_FOUND) -        { -            /* -             * We didn't find the name reference by path -- we can qualify this -             * a little better before we print an error message -             */ -            if (strlen (Path) == ACPI_NAME_SIZE) -            { -                /* A simple, one-segment ACPI name */ - -                if (LkObjectExists (Path)) -                { -                    /* -                     * There exists such a name, but we couldn't get to it -                     * from this scope -                     */ -                    AslError (ASL_ERROR, ASL_MSG_NOT_REACHABLE, Op, -                        Op->Asl.ExternalName); -                } -                else -                { -                    /* The name doesn't exist, period */ - -                    AslError (ASL_ERROR, ASL_MSG_NOT_EXIST, -                        Op, Op->Asl.ExternalName); -                } -            } -            else -            { -                /* Check for a fully qualified path */ - -                if (Path[0] == AML_ROOT_PREFIX) -                { -                    /* Gave full path, the object does not exist */ - -                    AslError (ASL_ERROR, ASL_MSG_NOT_EXIST, Op, -                        Op->Asl.ExternalName); -                } -                else -                { -                    /* -                     * We can't tell whether it doesn't exist or just -                     * can't be reached. -                     */ -                    AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op, -                        Op->Asl.ExternalName); -                } -            } - -            Status = AE_OK; -        } -        return (Status); -    } - -    /* Check for a reference vs. name declaration */ - -    if (!(OpInfo->Flags & AML_NAMED) && -        !(OpInfo->Flags & AML_CREATE)) -    { -        /* This node has been referenced, mark it for reference check */ - -        Node->Flags |= ANOBJ_IS_REFERENCED; -    } - -    /* Attempt to optimize the NamePath */ - -    OptOptimizeNamePath (Op, OpInfo->Flags, WalkState, Path, Node); - -    /* -     * 1) Dereference an alias (A name reference that is an alias) -     *    Aliases are not nested, the alias always points to the final object -     */ -    if ((Op->Asl.ParseOpcode != PARSEOP_ALIAS) && -        (Node->Type == ACPI_TYPE_LOCAL_ALIAS)) -    { -        /* This node points back to the original PARSEOP_ALIAS */ - -        NextOp = Node->Op; - -        /* The first child is the alias target op */ - -        NextOp = NextOp->Asl.Child; - -        /* That in turn points back to original target alias node */ - -        if (NextOp->Asl.Node) -        { -            Node = NextOp->Asl.Node; -        } - -        /* Else - forward reference to alias, will be resolved later */ -    } - -    /* 2) Check for a reference to a resource descriptor */ - -    if ((Node->Type == ACPI_TYPE_LOCAL_RESOURCE_FIELD) || -        (Node->Type == ACPI_TYPE_LOCAL_RESOURCE)) -    { -        /* -         * This was a reference to a field within a resource descriptor. -         * Extract the associated field offset (either a bit or byte -         * offset depending on the field type) and change the named -         * reference into an integer for AML code generation -         */ -        Offset = Node->Value; -        TagBitLength = Node->Length; - -        /* -         * If a field is being created, generate the length (in bits) of -         * the field. Note: Opcodes other than CreateXxxField and Index -         * can come through here. For other opcodes, we just need to -         * convert the resource tag reference to an integer offset. -         */ -        switch (Op->Asl.Parent->Asl.AmlOpcode) -        { -        case AML_CREATE_FIELD_OP: /* Variable "Length" field, in bits */ -            /* -             * We know the length operand is an integer constant because -             * we know that it contains a reference to a resource -             * descriptor tag. -             */ -            FieldBitLength = (UINT32) Op->Asl.Next->Asl.Value.Integer; -            break; - -        case AML_CREATE_BIT_FIELD_OP: -            FieldBitLength = 1; -            break; - -        case AML_CREATE_BYTE_FIELD_OP: -        case AML_INDEX_OP: -            FieldBitLength = 8; -            break; - -        case AML_CREATE_WORD_FIELD_OP: -            FieldBitLength = 16; -            break; - -        case AML_CREATE_DWORD_FIELD_OP: -            FieldBitLength = 32; -            break; - -        case AML_CREATE_QWORD_FIELD_OP: -            FieldBitLength = 64; -            break; - -        default: -            FieldBitLength = 0; -            break; -        } - -        /* Check the field length against the length of the resource tag */ - -        if (FieldBitLength) -        { -            if (TagBitLength < FieldBitLength) -            { -                Message = ASL_MSG_TAG_SMALLER; -            } -            else if (TagBitLength > FieldBitLength) -            { -                Message = ASL_MSG_TAG_LARGER; -            } - -            if (Message) -            { -                sprintf (MsgBuffer, "Size mismatch, Tag: %u bit%s, Field: %u bit%s", -                    TagBitLength, (TagBitLength > 1) ? "s" : "", -                    FieldBitLength, (FieldBitLength > 1) ? "s" : ""); - -                AslError (ASL_WARNING, Message, Op, MsgBuffer); -            } -        } - -        /* Convert the BitOffset to a ByteOffset for certain opcodes */ - -        switch (Op->Asl.Parent->Asl.AmlOpcode) -        { -        case AML_CREATE_BYTE_FIELD_OP: -        case AML_CREATE_WORD_FIELD_OP: -        case AML_CREATE_DWORD_FIELD_OP: -        case AML_CREATE_QWORD_FIELD_OP: -        case AML_INDEX_OP: - -            Offset = ACPI_DIV_8 (Offset); -            break; - -        default: -            break; -        } - -        /* Now convert this node to an integer whose value is the field offset */ - -        Op->Asl.AmlLength = 0; -        Op->Asl.ParseOpcode = PARSEOP_INTEGER; -        Op->Asl.Value.Integer = (UINT64) Offset; -        Op->Asl.CompileFlags |= NODE_IS_RESOURCE_FIELD; - -        OpcGenerateAmlOpcode (Op); -    } - -    /* 3) Check for a method invocation */ - -    else if ((((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || (Op->Asl.ParseOpcode == PARSEOP_NAMESEG)) && -                (Node->Type == ACPI_TYPE_METHOD) && -                (Op->Asl.Parent) && -                (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_METHOD))   || - -                (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)) -    { - -        /* -         * A reference to a method within one of these opcodes is not an -         * invocation of the method, it is simply a reference to the method. -         */ -        if ((Op->Asl.Parent) && -           ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_REFOF)      || -            (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_DEREFOF)    || -            (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_OBJECTTYPE))) -        { -            return (AE_OK); -        } -        /* -         * There are two types of method invocation: -         * 1) Invocation with arguments -- the parser recognizes this -         *    as a METHODCALL. -         * 2) Invocation with no arguments --the parser cannot determine that -         *    this is a method invocation, therefore we have to figure it out -         *    here. -         */ -        if (Node->Type != ACPI_TYPE_METHOD) -        { -            sprintf (MsgBuffer, "%s is a %s", -                    Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type)); - -            AslError (ASL_ERROR, ASL_MSG_NOT_METHOD, Op, MsgBuffer); -            return (AE_OK); -        } - -        /* Save the method node in the caller's op */ - -        Op->Asl.Node = Node; -        if (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF) -        { -            return (AE_OK); -        } - -        /* -         * This is a method invocation, with or without arguments. -         * Count the number of arguments, each appears as a child -         * under the parent node -         */ -        Op->Asl.ParseOpcode = PARSEOP_METHODCALL; -        UtSetParseOpName (Op); - -        PassedArgs = 0; -        NextOp     = Op->Asl.Child; - -        while (NextOp) -        { -            PassedArgs++; -            NextOp = NextOp->Asl.Next; -        } - -        if (Node->Value != ASL_EXTERNAL_METHOD) -        { -            /* -             * Check the parsed arguments with the number expected by the -             * method declaration itself -             */ -            if (PassedArgs != Node->Value) -            { -                sprintf (MsgBuffer, "%s requires %u", Op->Asl.ExternalName, -                            Node->Value); - -                if (PassedArgs < Node->Value) -                { -                    AslError (ASL_ERROR, ASL_MSG_ARG_COUNT_LO, Op, MsgBuffer); -                } -                else -                { -                    AslError (ASL_ERROR, ASL_MSG_ARG_COUNT_HI, Op, MsgBuffer); -                } -            } -        } -    } - -    /* 4) Check for an ASL Field definition */ - -    else if ((Op->Asl.Parent) && -            ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_FIELD)     || -             (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_BANKFIELD))) -    { -        /* -         * Offset checking for fields. If the parent operation region has a -         * constant length (known at compile time), we can check fields -         * defined in that region against the region length. This will catch -         * fields and field units that cannot possibly fit within the region. -         * -         * Note: Index fields do not directly reference an operation region, -         * thus they are not included in this check. -         */ -        if (Op == Op->Asl.Parent->Asl.Child) -        { -            /* -             * This is the first child of the field node, which is -             * the name of the region. Get the parse node for the -             * region -- which contains the length of the region. -             */ -            OwningOp = Node->Op; -            Op->Asl.Parent->Asl.ExtraValue = -                ACPI_MUL_8 ((UINT32) OwningOp->Asl.Value.Integer); - -            /* Examine the field access width */ - -            switch ((UINT8) Op->Asl.Parent->Asl.Value.Integer) -            { -            case AML_FIELD_ACCESS_ANY: -            case AML_FIELD_ACCESS_BYTE: -            case AML_FIELD_ACCESS_BUFFER: -            default: -                MinimumLength = 1; -                break; - -            case AML_FIELD_ACCESS_WORD: -                MinimumLength = 2; -                break; - -            case AML_FIELD_ACCESS_DWORD: -                MinimumLength = 4; -                break; - -            case AML_FIELD_ACCESS_QWORD: -                MinimumLength = 8; -                break; -            } - -            /* -             * Is the region at least as big as the access width? -             * Note: DataTableRegions have 0 length -             */ -            if (((UINT32) OwningOp->Asl.Value.Integer) && -                ((UINT32) OwningOp->Asl.Value.Integer < MinimumLength)) -            { -                AslError (ASL_ERROR, ASL_MSG_FIELD_ACCESS_WIDTH, Op, NULL); -            } - -            /* -             * Check EC/CMOS/SMBUS fields to make sure that the correct -             * access type is used (BYTE for EC/CMOS, BUFFER for SMBUS) -             */ -            SpaceIdOp = OwningOp->Asl.Child->Asl.Next; -            switch ((UINT32) SpaceIdOp->Asl.Value.Integer) -            { -            case ACPI_ADR_SPACE_EC: -            case ACPI_ADR_SPACE_CMOS: -            case ACPI_ADR_SPACE_GPIO: - -                if ((UINT8) Op->Asl.Parent->Asl.Value.Integer != AML_FIELD_ACCESS_BYTE) -                { -                    AslError (ASL_ERROR, ASL_MSG_REGION_BYTE_ACCESS, Op, NULL); -                } -                break; - -            case ACPI_ADR_SPACE_SMBUS: -            case ACPI_ADR_SPACE_IPMI: -            case ACPI_ADR_SPACE_GSBUS: - -                if ((UINT8) Op->Asl.Parent->Asl.Value.Integer != AML_FIELD_ACCESS_BUFFER) -                { -                    AslError (ASL_ERROR, ASL_MSG_REGION_BUFFER_ACCESS, Op, NULL); -                } -                break; - -            default: - -                /* Nothing to do for other address spaces */ -                break; -            } -        } -        else +        NameOp = Op->Asl.Child; +        while (!(NameOp->Asl.CompileFlags & NODE_IS_NAME_DECLARATION))          { -            /* -             * This is one element of the field list. Check to make sure -             * that it does not go beyond the end of the parent operation region. -             * -             * In the code below: -             *    Op->Asl.Parent->Asl.ExtraValue      - Region Length (bits) -             *    Op->Asl.ExtraValue                  - Field start offset (bits) -             *    Op->Asl.Child->Asl.Value.Integer32  - Field length (bits) -             *    Op->Asl.Child->Asl.ExtraValue       - Field access width (bits) -             */ -            if (Op->Asl.Parent->Asl.ExtraValue && Op->Asl.Child) -            { -                LkCheckFieldRange (Op, -                            Op->Asl.Parent->Asl.ExtraValue, -                            Op->Asl.ExtraValue, -                            (UINT32) Op->Asl.Child->Asl.Value.Integer, -                            Op->Asl.Child->Asl.ExtraValue); -            } +            NameOp = NameOp->Asl.Next;          }      } -    Op->Asl.Node = Node; -    return (Status); -} - - -/******************************************************************************* - * - * FUNCTION:    LkNamespaceLocateEnd - * - * PARAMETERS:  ASL_WALK_CALLBACK - * - * RETURN:      Status - * - * DESCRIPTION: Ascending callback used during cross reference. We only - *              need to worry about scope management here. - * - ******************************************************************************/ - -static ACPI_STATUS -LkNamespaceLocateEnd ( -    ACPI_PARSE_OBJECT       *Op, -    UINT32                  Level, -    void                    *Context) -{ -    ACPI_WALK_STATE         *WalkState = (ACPI_WALK_STATE *) Context; -    const ACPI_OPCODE_INFO  *OpInfo; - - -    ACPI_FUNCTION_TRACE (LkNamespaceLocateEnd); - - -    /* We are only interested in opcodes that have an associated name */ - -    OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); -    if (!(OpInfo->Flags & AML_NAMED)) -    { -        return (AE_OK); -    } - -    /* Not interested in name references, we did not open a scope for them */ - -    if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || -        (Op->Asl.ParseOpcode == PARSEOP_NAMESEG)    || -        (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)) -    { -        return (AE_OK); -    } - -    /* Pop the scope stack if necessary */ - -    if (AcpiNsOpensScope (AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode))) -    { - -        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, -            "%s: Popping scope for Op %p\n", -            AcpiUtGetTypeName (OpInfo->ObjectType), Op)); - -        (void) AcpiDsScopeStackPop (WalkState); -    } - -    return (AE_OK); +    return (NameOp);  } diff --git a/source/compiler/aslmessages.h b/source/compiler/aslmessages.h index 07758efd0184..5ab1cc448637 100644 --- a/source/compiler/aslmessages.h +++ b/source/compiler/aslmessages.h @@ -190,6 +190,7 @@ typedef enum      ASL_MSG_TAG_SMALLER,      ASL_MSG_TIMEOUT,      ASL_MSG_TOO_MANY_TEMPS, +    ASL_MSG_TRUNCATION,      ASL_MSG_UNKNOWN_RESERVED_NAME,      ASL_MSG_UNREACHABLE_CODE,      ASL_MSG_UNSUPPORTED, @@ -274,7 +275,7 @@ char                        *AslMessages [] = {  /*    ASL_MSG_HID_SUFFIX */                 "_HID suffix must be all hex digits",  /*    ASL_MSG_INCLUDE_FILE_OPEN */          "Could not open include file",  /*    ASL_MSG_INPUT_FILE_OPEN */            "Could not open input file", -/*    ASL_MSG_INTEGER_LENGTH */             "64-bit integer in 32-bit table, truncating", +/*    ASL_MSG_INTEGER_LENGTH */             "64-bit integer in 32-bit table, truncating (DSDT version < 2)",  /*    ASL_MSG_INTEGER_OPTIMIZATION */       "Integer optimized to single-byte AML opcode",  /*    ASL_MSG_INTERRUPT_LIST */             "Too many interrupts (16 max)",  /*    ASL_MSG_INTERRUPT_NUMBER */           "Invalid interrupt number (must be 0-15)", @@ -366,6 +367,7 @@ char                        *AslMessages [] = {  /*    ASL_MSG_TAG_SMALLER */                "ResourceTag smaller than Field",  /*    ASL_MSG_TIMEOUT */                    "Result is not used, possible operator timeout will be missed",  /*    ASL_MSG_TOO_MANY_TEMPS */             "Method requires too many temporary variables (_T_x)", +/*    ASL_MSG_TRUNCATION */                 "64-bit return value will be truncated to 32 bits (DSDT version < 2)",  /*    ASL_MSG_UNKNOWN_RESERVED_NAME */      "Unknown reserved name",  /*    ASL_MSG_UNREACHABLE_CODE */           "Statement is unreachable",  /*    ASL_MSG_UNSUPPORTED */                "Unsupported feature", diff --git a/source/compiler/aslmethod.c b/source/compiler/aslmethod.c new file mode 100644 index 000000000000..b9e6d6feefe1 --- /dev/null +++ b/source/compiler/aslmethod.c @@ -0,0 +1,619 @@ +/****************************************************************************** + * + * Module Name: aslmethod.c - Control method analysis walk + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2012, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *    notice, this list of conditions, and the following disclaimer, + *    without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + *    substantially similar to the "NO WARRANTY" disclaimer below + *    ("Disclaimer") and any redistribution must be conditioned upon + *    including a substantially similar Disclaimer requirement for further + *    binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + *    of any contributors may be used to endorse or promote products derived + *    from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + + +#include "aslcompiler.h" +#include "aslcompiler.y.h" + + +#define _COMPONENT          ACPI_COMPILER +        ACPI_MODULE_NAME    ("aslmethod") + + +/******************************************************************************* + * + * FUNCTION:    MtMethodAnalysisWalkBegin + * + * PARAMETERS:  ASL_WALK_CALLBACK + * + * RETURN:      Status + * + * DESCRIPTION: Descending callback for the analysis walk. Check methods for: + *              1) Initialized local variables + *              2) Valid arguments + *              3) Return types + * + ******************************************************************************/ + +ACPI_STATUS +MtMethodAnalysisWalkBegin ( +    ACPI_PARSE_OBJECT       *Op, +    UINT32                  Level, +    void                    *Context) +{ +    ASL_ANALYSIS_WALK_INFO  *WalkInfo = (ASL_ANALYSIS_WALK_INFO *) Context; +    ASL_METHOD_INFO         *MethodInfo = WalkInfo->MethodStack; +    ACPI_PARSE_OBJECT       *Next; +    UINT32                  RegisterNumber; +    UINT32                  i; +    char                    LocalName[] = "Local0"; +    char                    ArgName[] = "Arg0"; +    ACPI_PARSE_OBJECT       *ArgNode; +    ACPI_PARSE_OBJECT       *NextType; +    ACPI_PARSE_OBJECT       *NextParamType; +    UINT8                   ActualArgs = 0; + + +    switch (Op->Asl.ParseOpcode) +    { +    case PARSEOP_METHOD: + +        TotalMethods++; + +        /* Create and init method info */ + +        MethodInfo       = UtLocalCalloc (sizeof (ASL_METHOD_INFO)); +        MethodInfo->Next = WalkInfo->MethodStack; +        MethodInfo->Op = Op; + +        WalkInfo->MethodStack = MethodInfo; + +        /* Get the name node, ignored here */ + +        Next = Op->Asl.Child; + +        /* Get the NumArguments node */ + +        Next = Next->Asl.Next; +        MethodInfo->NumArguments = (UINT8) +            (((UINT8) Next->Asl.Value.Integer) & 0x07); + +        /* Get the SerializeRule and SyncLevel nodes, ignored here */ + +        Next = Next->Asl.Next; +        Next = Next->Asl.Next; +        ArgNode = Next; + +        /* Get the ReturnType node */ + +        Next = Next->Asl.Next; + +        NextType = Next->Asl.Child; +        while (NextType) +        { +            /* Get and map each of the ReturnTypes */ + +            MethodInfo->ValidReturnTypes |= AnMapObjTypeToBtype (NextType); +            NextType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; +            NextType = NextType->Asl.Next; +        } + +        /* Get the ParameterType node */ + +        Next = Next->Asl.Next; + +        NextType = Next->Asl.Child; +        while (NextType) +        { +            if (NextType->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) +            { +                NextParamType = NextType->Asl.Child; +                while (NextParamType) +                { +                    MethodInfo->ValidArgTypes[ActualArgs] |= AnMapObjTypeToBtype (NextParamType); +                    NextParamType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; +                    NextParamType = NextParamType->Asl.Next; +                } +            } +            else +            { +                MethodInfo->ValidArgTypes[ActualArgs] = +                    AnMapObjTypeToBtype (NextType); +                NextType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; +                ActualArgs++; +            } + +            NextType = NextType->Asl.Next; +        } + +        if ((MethodInfo->NumArguments) && +            (MethodInfo->NumArguments != ActualArgs)) +        { +            /* error: Param list did not match number of args */ +        } + +        /* Allow numarguments == 0 for Function() */ + +        if ((!MethodInfo->NumArguments) && (ActualArgs)) +        { +            MethodInfo->NumArguments = ActualArgs; +            ArgNode->Asl.Value.Integer |= ActualArgs; +        } + +        /* +         * Actual arguments are initialized at method entry. +         * All other ArgX "registers" can be used as locals, so we +         * track their initialization. +         */ +        for (i = 0; i < MethodInfo->NumArguments; i++) +        { +            MethodInfo->ArgInitialized[i] = TRUE; +        } +        break; + + +    case PARSEOP_METHODCALL: + +        if (MethodInfo && +           (Op->Asl.Node == MethodInfo->Op->Asl.Node)) +        { +            AslError (ASL_REMARK, ASL_MSG_RECURSION, Op, Op->Asl.ExternalName); +        } +        break; + + +    case PARSEOP_LOCAL0: +    case PARSEOP_LOCAL1: +    case PARSEOP_LOCAL2: +    case PARSEOP_LOCAL3: +    case PARSEOP_LOCAL4: +    case PARSEOP_LOCAL5: +    case PARSEOP_LOCAL6: +    case PARSEOP_LOCAL7: + +        if (!MethodInfo) +        { +            /* +             * Local was used outside a control method, or there was an error +             * in the method declaration. +             */ +            AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD, Op, Op->Asl.ExternalName); +            return (AE_ERROR); +        } + +        RegisterNumber = (Op->Asl.AmlOpcode & 0x000F); + +        /* +         * If the local is being used as a target, mark the local +         * initialized +         */ +        if (Op->Asl.CompileFlags & NODE_IS_TARGET) +        { +            MethodInfo->LocalInitialized[RegisterNumber] = TRUE; +        } + +        /* +         * Otherwise, this is a reference, check if the local +         * has been previously initialized. +         * +         * The only operator that accepts an uninitialized value is ObjectType() +         */ +        else if ((!MethodInfo->LocalInitialized[RegisterNumber]) && +                 (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_OBJECTTYPE)) +        { +            LocalName[strlen (LocalName) -1] = (char) (RegisterNumber + 0x30); +            AslError (ASL_ERROR, ASL_MSG_LOCAL_INIT, Op, LocalName); +        } +        break; + + +    case PARSEOP_ARG0: +    case PARSEOP_ARG1: +    case PARSEOP_ARG2: +    case PARSEOP_ARG3: +    case PARSEOP_ARG4: +    case PARSEOP_ARG5: +    case PARSEOP_ARG6: + +        if (!MethodInfo) +        { +            /* +             * Arg was used outside a control method, or there was an error +             * in the method declaration. +             */ +            AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD, Op, Op->Asl.ExternalName); +            return (AE_ERROR); +        } + +        RegisterNumber = (Op->Asl.AmlOpcode & 0x000F) - 8; +        ArgName[strlen (ArgName) -1] = (char) (RegisterNumber + 0x30); + +        /* +         * If the Arg is being used as a target, mark the local +         * initialized +         */ +        if (Op->Asl.CompileFlags & NODE_IS_TARGET) +        { +            MethodInfo->ArgInitialized[RegisterNumber] = TRUE; +        } + +        /* +         * Otherwise, this is a reference, check if the Arg +         * has been previously initialized. +         * +         * The only operator that accepts an uninitialized value is ObjectType() +         */ +        else if ((!MethodInfo->ArgInitialized[RegisterNumber]) && +                 (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_OBJECTTYPE)) +        { +            AslError (ASL_ERROR, ASL_MSG_ARG_INIT, Op, ArgName); +        } + +        /* Flag this arg if it is not a "real" argument to the method */ + +        if (RegisterNumber >= MethodInfo->NumArguments) +        { +            AslError (ASL_REMARK, ASL_MSG_NOT_PARAMETER, Op, ArgName); +        } +        break; + + +    case PARSEOP_RETURN: + +        if (!MethodInfo) +        { +            /* +             * Probably was an error in the method declaration, +             * no additional error here +             */ +            ACPI_WARNING ((AE_INFO, "%p, No parent method", Op)); +            return (AE_ERROR); +        } + +        /* +         * A child indicates a possible return value. A simple Return or +         * Return() is marked with NODE_IS_NULL_RETURN by the parser so +         * that it is not counted as a "real" return-with-value, although +         * the AML code that is actually emitted is Return(0). The AML +         * definition of Return has a required parameter, so we are +         * forced to convert a null return to Return(0). +         */ +        if ((Op->Asl.Child) && +            (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && +            (!(Op->Asl.Child->Asl.CompileFlags & NODE_IS_NULL_RETURN))) +        { +            MethodInfo->NumReturnWithValue++; +        } +        else +        { +            MethodInfo->NumReturnNoValue++; +        } +        break; + + +    case PARSEOP_BREAK: +    case PARSEOP_CONTINUE: + +        Next = Op->Asl.Parent; +        while (Next) +        { +            if (Next->Asl.ParseOpcode == PARSEOP_WHILE) +            { +                break; +            } +            Next = Next->Asl.Parent; +        } + +        if (!Next) +        { +            AslError (ASL_ERROR, ASL_MSG_NO_WHILE, Op, NULL); +        } +        break; + + +    case PARSEOP_STALL: + +        /* We can range check if the argument is an integer */ + +        if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) && +            (Op->Asl.Child->Asl.Value.Integer > ACPI_UINT8_MAX)) +        { +            AslError (ASL_ERROR, ASL_MSG_INVALID_TIME, Op, NULL); +        } +        break; + + +    case PARSEOP_DEVICE: +    case PARSEOP_EVENT: +    case PARSEOP_MUTEX: +    case PARSEOP_OPERATIONREGION: +    case PARSEOP_POWERRESOURCE: +    case PARSEOP_PROCESSOR: +    case PARSEOP_THERMALZONE: + +        /* +         * The first operand is a name to be created in the namespace. +         * Check against the reserved list. +         */ +        i = ApCheckForPredefinedName (Op, Op->Asl.NameSeg); +        if (i < ACPI_VALID_RESERVED_NAME_MAX) +        { +            AslError (ASL_ERROR, ASL_MSG_RESERVED_USE, Op, Op->Asl.ExternalName); +        } +        break; + + +    case PARSEOP_NAME: + +        /* Typecheck any predefined names statically defined with Name() */ + +        ApCheckForPredefinedObject (Op, Op->Asl.NameSeg); + +        /* Special typechecking for _HID */ + +        if (!ACPI_STRCMP (METHOD_NAME__HID, Op->Asl.NameSeg)) +        { +            Next = Op->Asl.Child->Asl.Next; +            AnCheckId (Next, ASL_TYPE_HID); +        } + +        /* Special typechecking for _CID */ + +        else if (!ACPI_STRCMP (METHOD_NAME__CID, Op->Asl.NameSeg)) +        { +            Next = Op->Asl.Child->Asl.Next; + +            if ((Next->Asl.ParseOpcode == PARSEOP_PACKAGE) || +                (Next->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE)) +            { +                Next = Next->Asl.Child; +                while (Next) +                { +                    AnCheckId (Next, ASL_TYPE_CID); +                    Next = Next->Asl.Next; +                } +            } +            else +            { +                AnCheckId (Next, ASL_TYPE_CID); +            } +        } +        break; + + +    default: +        break; +    } + +    return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION:    MtMethodAnalysisWalkEnd + * + * PARAMETERS:  ASL_WALK_CALLBACK + * + * RETURN:      Status + * + * DESCRIPTION: Ascending callback for analysis walk. Complete method + *              return analysis. + * + ******************************************************************************/ + +ACPI_STATUS +MtMethodAnalysisWalkEnd ( +    ACPI_PARSE_OBJECT       *Op, +    UINT32                  Level, +    void                    *Context) +{ +    ASL_ANALYSIS_WALK_INFO  *WalkInfo = (ASL_ANALYSIS_WALK_INFO *) Context; +    ASL_METHOD_INFO         *MethodInfo = WalkInfo->MethodStack; + + +    switch (Op->Asl.ParseOpcode) +    { +    case PARSEOP_METHOD: +    case PARSEOP_RETURN: +        if (!MethodInfo) +        { +            printf ("No method info for method! [%s]\n", Op->Asl.Namepath); +            AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, +                "No method info for this method"); + +            CmCleanupAndExit (); +            return (AE_AML_INTERNAL); +        } +        break; + +    default: +        break; +    } + +    switch (Op->Asl.ParseOpcode) +    { +    case PARSEOP_METHOD: + +        WalkInfo->MethodStack = MethodInfo->Next; + +        /* +         * Check if there is no return statement at the end of the +         * method AND we can actually get there -- i.e., the execution +         * of the method can possibly terminate without a return statement. +         */ +        if ((!AnLastStatementIsReturn (Op)) && +            (!(Op->Asl.CompileFlags & NODE_HAS_NO_EXIT))) +        { +            /* +             * No return statement, and execution can possibly exit +             * via this path. This is equivalent to Return () +             */ +            MethodInfo->NumReturnNoValue++; +        } + +        /* +         * Check for case where some return statements have a return value +         * and some do not. Exit without a return statement is a return with +         * no value +         */ +        if (MethodInfo->NumReturnNoValue && +            MethodInfo->NumReturnWithValue) +        { +            AslError (ASL_WARNING, ASL_MSG_RETURN_TYPES, Op, +                Op->Asl.ExternalName); +        } + +        /* +         * If there are any RETURN() statements with no value, or there is a +         * control path that allows the method to exit without a return value, +         * we mark the method as a method that does not return a value. This +         * knowledge can be used to check method invocations that expect a +         * returned value. +         */ +        if (MethodInfo->NumReturnNoValue) +        { +            if (MethodInfo->NumReturnWithValue) +            { +                Op->Asl.CompileFlags |= NODE_METHOD_SOME_NO_RETVAL; +            } +            else +            { +                Op->Asl.CompileFlags |= NODE_METHOD_NO_RETVAL; +            } +        } + +        /* +         * Check predefined method names for correct return behavior +         * and correct number of arguments. Also, some special checks +         * For GPE and _REG methods. +         */ +        if (ApCheckForPredefinedMethod (Op, MethodInfo)) +        { +            /* Special check for two names like _L01 and _E01 in same scope */ + +            ApCheckForGpeNameConflict (Op); + +            /* +             * Special check for _REG: Must have an operation region definition +             * within the same scope! +             */ +            ApCheckRegMethod (Op); +        } + +        ACPI_FREE (MethodInfo); +        break; + + +    case PARSEOP_NAME: + +         /* Special check for two names like _L01 and _E01 in same scope */ + +        ApCheckForGpeNameConflict (Op); +        break; + + +    case PARSEOP_RETURN: + +        /* +         * If the parent is a predefined method name, attempt to typecheck +         * the return value. Only static types can be validated. +         */ +        ApCheckPredefinedReturnValue (Op, MethodInfo); + +        /* +         * The parent block does not "exit" and continue execution -- the +         * method is terminated here with the Return() statement. +         */ +        Op->Asl.Parent->Asl.CompileFlags |= NODE_HAS_NO_EXIT; + +        /* Used in the "typing" pass later */ + +        Op->Asl.ParentMethod = MethodInfo->Op; + +        /* +         * If there is a peer node after the return statement, then this +         * node is unreachable code -- i.e., it won't be executed because of +         * the preceding Return() statement. +         */ +        if (Op->Asl.Next) +        { +            AslError (ASL_WARNING, ASL_MSG_UNREACHABLE_CODE, Op->Asl.Next, NULL); +        } +        break; + + +    case PARSEOP_IF: + +        if ((Op->Asl.CompileFlags & NODE_HAS_NO_EXIT) && +            (Op->Asl.Next) && +            (Op->Asl.Next->Asl.ParseOpcode == PARSEOP_ELSE)) +        { +            /* +             * This IF has a corresponding ELSE. The IF block has no exit, +             * (it contains an unconditional Return) +             * mark the ELSE block to remember this fact. +             */ +            Op->Asl.Next->Asl.CompileFlags |= NODE_IF_HAS_NO_EXIT; +        } +        break; + + +    case PARSEOP_ELSE: + +        if ((Op->Asl.CompileFlags & NODE_HAS_NO_EXIT) && +            (Op->Asl.CompileFlags & NODE_IF_HAS_NO_EXIT)) +        { +            /* +             * This ELSE block has no exit and the corresponding IF block +             * has no exit either. Therefore, the parent node has no exit. +             */ +            Op->Asl.Parent->Asl.CompileFlags |= NODE_HAS_NO_EXIT; +        } +        break; + + +    default: + +        if ((Op->Asl.CompileFlags & NODE_HAS_NO_EXIT) && +            (Op->Asl.Parent)) +        { +            /* If this node has no exit, then the parent has no exit either */ + +            Op->Asl.Parent->Asl.CompileFlags |= NODE_HAS_NO_EXIT; +        } +        break; +    } + +    return (AE_OK); +} diff --git a/source/compiler/aslnamesp.c b/source/compiler/aslnamesp.c new file mode 100644 index 000000000000..825251e74cfe --- /dev/null +++ b/source/compiler/aslnamesp.c @@ -0,0 +1,422 @@ +/****************************************************************************** + * + * Module Name: aslnamesp - Namespace output file generation + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2012, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *    notice, this list of conditions, and the following disclaimer, + *    without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + *    substantially similar to the "NO WARRANTY" disclaimer below + *    ("Disclaimer") and any redistribution must be conditioned upon + *    including a substantially similar Disclaimer requirement for further + *    binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + *    of any contributors may be used to endorse or promote products derived + *    from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + + +#include "aslcompiler.h" +#include "aslcompiler.y.h" +#include "acnamesp.h" + + +#define _COMPONENT          ACPI_COMPILER +        ACPI_MODULE_NAME    ("aslnamesp") + +/* Local prototypes */ + +static ACPI_STATUS +NsDoOneNamespaceObject ( +    ACPI_HANDLE             ObjHandle, +    UINT32                  Level, +    void                    *Context, +    void                    **ReturnValue); + +static ACPI_STATUS +NsDoOnePathname ( +    ACPI_HANDLE             ObjHandle, +    UINT32                  Level, +    void                    *Context, +    void                    **ReturnValue); + + +/******************************************************************************* + * + * FUNCTION:    NsSetupNamespaceListing + * + * PARAMETERS:  Handle          - local file handle + * + * RETURN:      None + * + * DESCRIPTION: Set the namespace output file to the input handle + * + ******************************************************************************/ + +void +NsSetupNamespaceListing ( +    void                    *Handle) +{ + +    Gbl_NsOutputFlag = TRUE; +    Gbl_Files[ASL_FILE_NAMESPACE_OUTPUT].Handle = Handle; +} + + +/******************************************************************************* + * + * FUNCTION:    NsDisplayNamespace + * + * PARAMETERS:  None + * + * RETURN:      Status + * + * DESCRIPTION: Walk the namespace an display information about each node + *              in the tree. Information is written to the optional + *              namespace output file. + * + ******************************************************************************/ + +ACPI_STATUS +NsDisplayNamespace ( +    void) +{ +    ACPI_STATUS             Status; + + +    if (!Gbl_NsOutputFlag) +    { +        return (AE_OK); +    } + +    Gbl_NumNamespaceObjects = 0; + +    /* File header */ + +    FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "Contents of ACPI Namespace\n\n"); +    FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "Count  Depth    Name - Type\n\n"); + +    /* Walk entire namespace from the root */ + +    Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, +                ACPI_UINT32_MAX, FALSE, NsDoOneNamespaceObject, NULL, +                NULL, NULL); + +    /* Print the full pathname for each namespace node */ + +    FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "\nNamespace pathnames\n\n"); + +    Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, +                ACPI_UINT32_MAX, FALSE, NsDoOnePathname, NULL, +                NULL, NULL); + +    return (Status); +} + + +/******************************************************************************* + * + * FUNCTION:    NsDoOneNamespaceObject + * + * PARAMETERS:  ACPI_WALK_CALLBACK + * + * RETURN:      Status + * + * DESCRIPTION: Dump a namespace object to the namespace output file. + *              Called during the walk of the namespace to dump all objects. + * + ******************************************************************************/ + +static ACPI_STATUS +NsDoOneNamespaceObject ( +    ACPI_HANDLE             ObjHandle, +    UINT32                  Level, +    void                    *Context, +    void                    **ReturnValue) +{ +    ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; +    ACPI_OPERAND_OBJECT     *ObjDesc; +    ACPI_PARSE_OBJECT       *Op; + + +    Gbl_NumNamespaceObjects++; + +    FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "%5u  [%u]  %*s %4.4s - %s", +        Gbl_NumNamespaceObjects, Level, (Level * 3), " ", +        &Node->Name, +        AcpiUtGetTypeName (Node->Type)); + +    Op = Node->Op; +    ObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Node->Object); + +    if (!Op) +    { +        FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "\n"); +        return (AE_OK); +    } + + +    if ((ObjDesc) && +        (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND)) +    { +        switch (Node->Type) +        { +        case ACPI_TYPE_INTEGER: + +            FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, +                "       [Initial Value   0x%8.8X%8.8X]", +                ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); +            break; + + +        case ACPI_TYPE_STRING: + +            FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, +                "        [Initial Value   \"%s\"]", +                ObjDesc->String.Pointer); +            break; + +        default: +            /* Nothing to do for other types */ +            break; +        } + +    } +    else +    { +        switch (Node->Type) +        { +        case ACPI_TYPE_INTEGER: + +            if (Op->Asl.ParseOpcode == PARSEOP_NAME) +            { +                Op = Op->Asl.Child; +            } +            if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG)  || +                (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) +            { +                Op = Op->Asl.Next; +            } +            FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, +                "       [Initial Value   0x%8.8X%8.8X]", +                ACPI_FORMAT_UINT64 (Op->Asl.Value.Integer)); +            break; + + +        case ACPI_TYPE_STRING: + +            if (Op->Asl.ParseOpcode == PARSEOP_NAME) +            { +                Op = Op->Asl.Child; +            } +            if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG)  || +                (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) +            { +                Op = Op->Asl.Next; +            } +            FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, +                "        [Initial Value   \"%s\"]", +                Op->Asl.Value.String); +            break; + + +        case ACPI_TYPE_LOCAL_REGION_FIELD: + +            if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG)  || +                (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) +            { +                Op = Op->Asl.Child; +            } +            FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, +                "   [Offset 0x%04X   Length 0x%04X bits]", +                Op->Asl.Parent->Asl.ExtraValue, (UINT32) Op->Asl.Value.Integer); +            break; + + +        case ACPI_TYPE_BUFFER_FIELD: + +            switch (Op->Asl.ParseOpcode) +            { +            case PARSEOP_CREATEBYTEFIELD: +                FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "   [BYTE  ( 8 bit)]"); +                break; + +            case PARSEOP_CREATEDWORDFIELD: +                FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "   [DWORD (32 bit)]"); +                break; + +            case PARSEOP_CREATEQWORDFIELD: +                FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "   [QWORD (64 bit)]"); +                break; + +            case PARSEOP_CREATEWORDFIELD: +                FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "   [WORD  (16 bit)]"); +                break; + +            case PARSEOP_CREATEBITFIELD: +                FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "   [BIT   ( 1 bit)]"); +                break; + +            case PARSEOP_CREATEFIELD: +                FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "   [Arbitrary Bit Field]"); +                break; + +            default: +                break; + +            } +            break; + + +        case ACPI_TYPE_PACKAGE: + +            if (Op->Asl.ParseOpcode == PARSEOP_NAME) +            { +                Op = Op->Asl.Child; +            } +            if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG)  || +                (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) +            { +                Op = Op->Asl.Next; +            } +            Op = Op->Asl.Child; + +            if ((Op->Asl.ParseOpcode == PARSEOP_BYTECONST) || +                (Op->Asl.ParseOpcode == PARSEOP_RAW_DATA)) +            { +                FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, +                    "       [Initial Length  0x%.2X elements]", +                    Op->Asl.Value.Integer); +            } +            break; + + +        case ACPI_TYPE_BUFFER: + +            if (Op->Asl.ParseOpcode == PARSEOP_NAME) +            { +                Op = Op->Asl.Child; +            } +            if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG)  || +                (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) +            { +                Op = Op->Asl.Next; +            } +            Op = Op->Asl.Child; + +            if (Op && (Op->Asl.ParseOpcode == PARSEOP_INTEGER)) +            { +                FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, +                    "        [Initial Length  0x%.2X bytes]", +                    Op->Asl.Value.Integer); +            } +            break; + + +        case ACPI_TYPE_METHOD: + +            FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, +                "        [Code Length     0x%.4X bytes]", +                Op->Asl.AmlSubtreeLength); +            break; + + +        case ACPI_TYPE_LOCAL_RESOURCE: + +            FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, +                "  [Desc Offset     0x%.4X Bytes]", Node->Value); +            break; + + +        case ACPI_TYPE_LOCAL_RESOURCE_FIELD: + +            FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, +                "   [Field Offset    0x%.4X Bits 0x%.4X Bytes] ", +                Node->Value, Node->Value / 8); + +            if (Node->Flags & ANOBJ_IS_REFERENCED) +            { +                FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, +                    "Referenced"); +            } +            else +            { +                FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, +                    "Name not referenced"); +            } +            break; + + +        default: +            /* Nothing to do for other types */ +            break; +        } +    } + +    FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "\n"); +    return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION:    NsDoOnePathname + * + * PARAMETERS:  ACPI_WALK_CALLBACK + * + * RETURN:      Status + * + * DESCRIPTION: Print the full pathname for a namespace node. + * + ******************************************************************************/ + +static ACPI_STATUS +NsDoOnePathname ( +    ACPI_HANDLE             ObjHandle, +    UINT32                  Level, +    void                    *Context, +    void                    **ReturnValue) +{ +    ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; +    ACPI_STATUS             Status; +    ACPI_BUFFER             TargetPath; + + +    TargetPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER; +    Status = AcpiNsHandleToPathname (Node, &TargetPath); +    if (ACPI_FAILURE (Status)) +    { +        return (Status); +    } + +    FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "%s\n", TargetPath.Pointer); +    ACPI_FREE (TargetPath.Pointer); + +    return (AE_OK); +} diff --git a/source/compiler/aslopcodes.c b/source/compiler/aslopcodes.c index bd16cb5eb528..d5882ebf2827 100644 --- a/source/compiler/aslopcodes.c +++ b/source/compiler/aslopcodes.c @@ -802,6 +802,14 @@ OpcGenerateAmlOpcode (          Op->Asl.Child->Asl.Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;          break; +    case PARSEOP_TIMER: + +        if (AcpiGbl_IntegerBitWidth == 32) +        { +            AslError (ASL_REMARK, ASL_MSG_TRUNCATION, Op, NULL); +        } +        break; +      default:          /* Nothing to do for other opcodes */          break; diff --git a/source/compiler/aslopt.c b/source/compiler/aslopt.c index fedc5ff0dc1d..1a5e87d84e1f 100644 --- a/source/compiler/aslopt.c +++ b/source/compiler/aslopt.c @@ -305,7 +305,7 @@ OptBuildShortestPath (      for (i = 0; i < NumCarats; i++)      { -        NewPathExternal[i] = '^'; +        NewPathExternal[i] = AML_PARENT_PREFIX;      }      /* @@ -329,7 +329,7 @@ OptBuildShortestPath (          if (Op->Asl.AmlOpcode == AML_SCOPE_OP)          { -            NewPathExternal[i] = '^'; +            NewPathExternal[i] = AML_PARENT_PREFIX;              i++;              ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "(EXTRA ^)"));          } @@ -448,7 +448,7 @@ OptOptimizeNameDeclaration (      if (((CurrentNode == AcpiGbl_RootNode) ||          (Op->Common.Parent->Asl.ParseOpcode == PARSEOP_DEFINITIONBLOCK)) && -            (AmlNameString[0] == '\\')) +            (ACPI_IS_ROOT_PREFIX (AmlNameString[0])))      {          /*           * The current scope is the root, and the namepath has a root prefix diff --git a/source/compiler/aslstartup.c b/source/compiler/aslstartup.c index fbc005c74053..ae6fb8296d38 100644 --- a/source/compiler/aslstartup.c +++ b/source/compiler/aslstartup.c @@ -341,7 +341,7 @@ AslDoOneFile (          /* TBD: Handle additional output files for disassembler */          Status = FlOpenMiscOutputFiles (Gbl_OutputFilenamePrefix); -        LsDisplayNamespace (); +        NsDisplayNamespace ();  #endif          /* Shutdown compiler and ACPICA subsystem */ diff --git a/source/compiler/aslutils.c b/source/compiler/aslutils.c index ac749c44716b..d2a70d74afd4 100644 --- a/source/compiler/aslutils.c +++ b/source/compiler/aslutils.c @@ -826,7 +826,8 @@ UtAttachNameseg (          /* No dots in the namepath, there is only a single nameseg. */          /* Handle prefixes */ -        while ((*Name == '\\') || (*Name == '^')) +        while (ACPI_IS_ROOT_PREFIX (*Name) || +               ACPI_IS_PARENT_PREFIX (*Name))          {              Name++;          } diff --git a/source/compiler/aslwalks.c b/source/compiler/aslwalks.c index dce037e7706e..2168aec69e8e 100644 --- a/source/compiler/aslwalks.c +++ b/source/compiler/aslwalks.c @@ -1,6 +1,6 @@  /******************************************************************************   * - * Module Name: aslwalks.c - major analytical parse tree walks + * Module Name: aslwalks.c - Miscellaneous analytical parse tree walks   *   *****************************************************************************/ @@ -54,575 +54,6 @@  /*******************************************************************************   * - * FUNCTION:    AnMethodAnalysisWalkBegin - * - * PARAMETERS:  ASL_WALK_CALLBACK - * - * RETURN:      Status - * - * DESCRIPTION: Descending callback for the analysis walk. Check methods for: - *              1) Initialized local variables - *              2) Valid arguments - *              3) Return types - * - ******************************************************************************/ - -ACPI_STATUS -AnMethodAnalysisWalkBegin ( -    ACPI_PARSE_OBJECT       *Op, -    UINT32                  Level, -    void                    *Context) -{ -    ASL_ANALYSIS_WALK_INFO  *WalkInfo = (ASL_ANALYSIS_WALK_INFO *) Context; -    ASL_METHOD_INFO         *MethodInfo = WalkInfo->MethodStack; -    ACPI_PARSE_OBJECT       *Next; -    UINT32                  RegisterNumber; -    UINT32                  i; -    char                    LocalName[] = "Local0"; -    char                    ArgName[] = "Arg0"; -    ACPI_PARSE_OBJECT       *ArgNode; -    ACPI_PARSE_OBJECT       *NextType; -    ACPI_PARSE_OBJECT       *NextParamType; -    UINT8                   ActualArgs = 0; - - -    switch (Op->Asl.ParseOpcode) -    { -    case PARSEOP_METHOD: - -        TotalMethods++; - -        /* Create and init method info */ - -        MethodInfo       = UtLocalCalloc (sizeof (ASL_METHOD_INFO)); -        MethodInfo->Next = WalkInfo->MethodStack; -        MethodInfo->Op = Op; - -        WalkInfo->MethodStack = MethodInfo; - -        /* Get the name node, ignored here */ - -        Next = Op->Asl.Child; - -        /* Get the NumArguments node */ - -        Next = Next->Asl.Next; -        MethodInfo->NumArguments = (UINT8) -            (((UINT8) Next->Asl.Value.Integer) & 0x07); - -        /* Get the SerializeRule and SyncLevel nodes, ignored here */ - -        Next = Next->Asl.Next; -        Next = Next->Asl.Next; -        ArgNode = Next; - -        /* Get the ReturnType node */ - -        Next = Next->Asl.Next; - -        NextType = Next->Asl.Child; -        while (NextType) -        { -            /* Get and map each of the ReturnTypes */ - -            MethodInfo->ValidReturnTypes |= AnMapObjTypeToBtype (NextType); -            NextType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; -            NextType = NextType->Asl.Next; -        } - -        /* Get the ParameterType node */ - -        Next = Next->Asl.Next; - -        NextType = Next->Asl.Child; -        while (NextType) -        { -            if (NextType->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) -            { -                NextParamType = NextType->Asl.Child; -                while (NextParamType) -                { -                    MethodInfo->ValidArgTypes[ActualArgs] |= AnMapObjTypeToBtype (NextParamType); -                    NextParamType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; -                    NextParamType = NextParamType->Asl.Next; -                } -            } -            else -            { -                MethodInfo->ValidArgTypes[ActualArgs] = -                    AnMapObjTypeToBtype (NextType); -                NextType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; -                ActualArgs++; -            } - -            NextType = NextType->Asl.Next; -        } - -        if ((MethodInfo->NumArguments) && -            (MethodInfo->NumArguments != ActualArgs)) -        { -            /* error: Param list did not match number of args */ -        } - -        /* Allow numarguments == 0 for Function() */ - -        if ((!MethodInfo->NumArguments) && (ActualArgs)) -        { -            MethodInfo->NumArguments = ActualArgs; -            ArgNode->Asl.Value.Integer |= ActualArgs; -        } - -        /* -         * Actual arguments are initialized at method entry. -         * All other ArgX "registers" can be used as locals, so we -         * track their initialization. -         */ -        for (i = 0; i < MethodInfo->NumArguments; i++) -        { -            MethodInfo->ArgInitialized[i] = TRUE; -        } -        break; - - -    case PARSEOP_METHODCALL: - -        if (MethodInfo && -           (Op->Asl.Node == MethodInfo->Op->Asl.Node)) -        { -            AslError (ASL_REMARK, ASL_MSG_RECURSION, Op, Op->Asl.ExternalName); -        } -        break; - - -    case PARSEOP_LOCAL0: -    case PARSEOP_LOCAL1: -    case PARSEOP_LOCAL2: -    case PARSEOP_LOCAL3: -    case PARSEOP_LOCAL4: -    case PARSEOP_LOCAL5: -    case PARSEOP_LOCAL6: -    case PARSEOP_LOCAL7: - -        if (!MethodInfo) -        { -            /* -             * Local was used outside a control method, or there was an error -             * in the method declaration. -             */ -            AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD, Op, Op->Asl.ExternalName); -            return (AE_ERROR); -        } - -        RegisterNumber = (Op->Asl.AmlOpcode & 0x000F); - -        /* -         * If the local is being used as a target, mark the local -         * initialized -         */ -        if (Op->Asl.CompileFlags & NODE_IS_TARGET) -        { -            MethodInfo->LocalInitialized[RegisterNumber] = TRUE; -        } - -        /* -         * Otherwise, this is a reference, check if the local -         * has been previously initialized. -         * -         * The only operator that accepts an uninitialized value is ObjectType() -         */ -        else if ((!MethodInfo->LocalInitialized[RegisterNumber]) && -                 (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_OBJECTTYPE)) -        { -            LocalName[strlen (LocalName) -1] = (char) (RegisterNumber + 0x30); -            AslError (ASL_ERROR, ASL_MSG_LOCAL_INIT, Op, LocalName); -        } -        break; - - -    case PARSEOP_ARG0: -    case PARSEOP_ARG1: -    case PARSEOP_ARG2: -    case PARSEOP_ARG3: -    case PARSEOP_ARG4: -    case PARSEOP_ARG5: -    case PARSEOP_ARG6: - -        if (!MethodInfo) -        { -            /* -             * Arg was used outside a control method, or there was an error -             * in the method declaration. -             */ -            AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD, Op, Op->Asl.ExternalName); -            return (AE_ERROR); -        } - -        RegisterNumber = (Op->Asl.AmlOpcode & 0x000F) - 8; -        ArgName[strlen (ArgName) -1] = (char) (RegisterNumber + 0x30); - -        /* -         * If the Arg is being used as a target, mark the local -         * initialized -         */ -        if (Op->Asl.CompileFlags & NODE_IS_TARGET) -        { -            MethodInfo->ArgInitialized[RegisterNumber] = TRUE; -        } - -        /* -         * Otherwise, this is a reference, check if the Arg -         * has been previously initialized. -         * -         * The only operator that accepts an uninitialized value is ObjectType() -         */ -        else if ((!MethodInfo->ArgInitialized[RegisterNumber]) && -                 (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_OBJECTTYPE)) -        { -            AslError (ASL_ERROR, ASL_MSG_ARG_INIT, Op, ArgName); -        } - -        /* Flag this arg if it is not a "real" argument to the method */ - -        if (RegisterNumber >= MethodInfo->NumArguments) -        { -            AslError (ASL_REMARK, ASL_MSG_NOT_PARAMETER, Op, ArgName); -        } -        break; - - -    case PARSEOP_RETURN: - -        if (!MethodInfo) -        { -            /* -             * Probably was an error in the method declaration, -             * no additional error here -             */ -            ACPI_WARNING ((AE_INFO, "%p, No parent method", Op)); -            return (AE_ERROR); -        } - -        /* -         * A child indicates a possible return value. A simple Return or -         * Return() is marked with NODE_IS_NULL_RETURN by the parser so -         * that it is not counted as a "real" return-with-value, although -         * the AML code that is actually emitted is Return(0). The AML -         * definition of Return has a required parameter, so we are -         * forced to convert a null return to Return(0). -         */ -        if ((Op->Asl.Child) && -            (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && -            (!(Op->Asl.Child->Asl.CompileFlags & NODE_IS_NULL_RETURN))) -        { -            MethodInfo->NumReturnWithValue++; -        } -        else -        { -            MethodInfo->NumReturnNoValue++; -        } -        break; - - -    case PARSEOP_BREAK: -    case PARSEOP_CONTINUE: - -        Next = Op->Asl.Parent; -        while (Next) -        { -            if (Next->Asl.ParseOpcode == PARSEOP_WHILE) -            { -                break; -            } -            Next = Next->Asl.Parent; -        } - -        if (!Next) -        { -            AslError (ASL_ERROR, ASL_MSG_NO_WHILE, Op, NULL); -        } -        break; - - -    case PARSEOP_STALL: - -        /* We can range check if the argument is an integer */ - -        if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) && -            (Op->Asl.Child->Asl.Value.Integer > ACPI_UINT8_MAX)) -        { -            AslError (ASL_ERROR, ASL_MSG_INVALID_TIME, Op, NULL); -        } -        break; - - -    case PARSEOP_DEVICE: -    case PARSEOP_EVENT: -    case PARSEOP_MUTEX: -    case PARSEOP_OPERATIONREGION: -    case PARSEOP_POWERRESOURCE: -    case PARSEOP_PROCESSOR: -    case PARSEOP_THERMALZONE: - -        /* -         * The first operand is a name to be created in the namespace. -         * Check against the reserved list. -         */ -        i = ApCheckForPredefinedName (Op, Op->Asl.NameSeg); -        if (i < ACPI_VALID_RESERVED_NAME_MAX) -        { -            AslError (ASL_ERROR, ASL_MSG_RESERVED_USE, Op, Op->Asl.ExternalName); -        } -        break; - - -    case PARSEOP_NAME: - -        /* Typecheck any predefined names statically defined with Name() */ - -        ApCheckForPredefinedObject (Op, Op->Asl.NameSeg); - -        /* Special typechecking for _HID */ - -        if (!ACPI_STRCMP (METHOD_NAME__HID, Op->Asl.NameSeg)) -        { -            Next = Op->Asl.Child->Asl.Next; -            AnCheckId (Next, ASL_TYPE_HID); -        } - -        /* Special typechecking for _CID */ - -        else if (!ACPI_STRCMP (METHOD_NAME__CID, Op->Asl.NameSeg)) -        { -            Next = Op->Asl.Child->Asl.Next; - -            if ((Next->Asl.ParseOpcode == PARSEOP_PACKAGE) || -                (Next->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE)) -            { -                Next = Next->Asl.Child; -                while (Next) -                { -                    AnCheckId (Next, ASL_TYPE_CID); -                    Next = Next->Asl.Next; -                } -            } -            else -            { -                AnCheckId (Next, ASL_TYPE_CID); -            } -        } -        break; - - -    default: -        break; -    } - -    return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION:    AnMethodAnalysisWalkEnd - * - * PARAMETERS:  ASL_WALK_CALLBACK - * - * RETURN:      Status - * - * DESCRIPTION: Ascending callback for analysis walk. Complete method - *              return analysis. - * - ******************************************************************************/ - -ACPI_STATUS -AnMethodAnalysisWalkEnd ( -    ACPI_PARSE_OBJECT       *Op, -    UINT32                  Level, -    void                    *Context) -{ -    ASL_ANALYSIS_WALK_INFO  *WalkInfo = (ASL_ANALYSIS_WALK_INFO *) Context; -    ASL_METHOD_INFO         *MethodInfo = WalkInfo->MethodStack; - - -    switch (Op->Asl.ParseOpcode) -    { -    case PARSEOP_METHOD: -    case PARSEOP_RETURN: -        if (!MethodInfo) -        { -            printf ("No method info for method! [%s]\n", Op->Asl.Namepath); -            AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, -                "No method info for this method"); - -            CmCleanupAndExit (); -            return (AE_AML_INTERNAL); -        } -        break; - -    default: -        break; -    } - -    switch (Op->Asl.ParseOpcode) -    { -    case PARSEOP_METHOD: - -        WalkInfo->MethodStack = MethodInfo->Next; - -        /* -         * Check if there is no return statement at the end of the -         * method AND we can actually get there -- i.e., the execution -         * of the method can possibly terminate without a return statement. -         */ -        if ((!AnLastStatementIsReturn (Op)) && -            (!(Op->Asl.CompileFlags & NODE_HAS_NO_EXIT))) -        { -            /* -             * No return statement, and execution can possibly exit -             * via this path. This is equivalent to Return () -             */ -            MethodInfo->NumReturnNoValue++; -        } - -        /* -         * Check for case where some return statements have a return value -         * and some do not. Exit without a return statement is a return with -         * no value -         */ -        if (MethodInfo->NumReturnNoValue && -            MethodInfo->NumReturnWithValue) -        { -            AslError (ASL_WARNING, ASL_MSG_RETURN_TYPES, Op, -                Op->Asl.ExternalName); -        } - -        /* -         * If there are any RETURN() statements with no value, or there is a -         * control path that allows the method to exit without a return value, -         * we mark the method as a method that does not return a value. This -         * knowledge can be used to check method invocations that expect a -         * returned value. -         */ -        if (MethodInfo->NumReturnNoValue) -        { -            if (MethodInfo->NumReturnWithValue) -            { -                Op->Asl.CompileFlags |= NODE_METHOD_SOME_NO_RETVAL; -            } -            else -            { -                Op->Asl.CompileFlags |= NODE_METHOD_NO_RETVAL; -            } -        } - -        /* -         * Check predefined method names for correct return behavior -         * and correct number of arguments. Also, some special checks -         * For GPE and _REG methods. -         */ -        if (ApCheckForPredefinedMethod (Op, MethodInfo)) -        { -            /* Special check for two names like _L01 and _E01 in same scope */ - -            ApCheckForGpeNameConflict (Op); - -            /* -             * Special check for _REG: Must have an operation region definition -             * within the same scope! -             */ -            ApCheckRegMethod (Op); -        } - -        ACPI_FREE (MethodInfo); -        break; - - -    case PARSEOP_NAME: - -         /* Special check for two names like _L01 and _E01 in same scope */ - -        ApCheckForGpeNameConflict (Op); -        break; - - -    case PARSEOP_RETURN: - -        /* -         * If the parent is a predefined method name, attempt to typecheck -         * the return value. Only static types can be validated. -         */ -        ApCheckPredefinedReturnValue (Op, MethodInfo); - -        /* -         * The parent block does not "exit" and continue execution -- the -         * method is terminated here with the Return() statement. -         */ -        Op->Asl.Parent->Asl.CompileFlags |= NODE_HAS_NO_EXIT; - -        /* Used in the "typing" pass later */ - -        Op->Asl.ParentMethod = MethodInfo->Op; - -        /* -         * If there is a peer node after the return statement, then this -         * node is unreachable code -- i.e., it won't be executed because of -         * the preceding Return() statement. -         */ -        if (Op->Asl.Next) -        { -            AslError (ASL_WARNING, ASL_MSG_UNREACHABLE_CODE, Op->Asl.Next, NULL); -        } -        break; - - -    case PARSEOP_IF: - -        if ((Op->Asl.CompileFlags & NODE_HAS_NO_EXIT) && -            (Op->Asl.Next) && -            (Op->Asl.Next->Asl.ParseOpcode == PARSEOP_ELSE)) -        { -            /* -             * This IF has a corresponding ELSE. The IF block has no exit, -             * (it contains an unconditional Return) -             * mark the ELSE block to remember this fact. -             */ -            Op->Asl.Next->Asl.CompileFlags |= NODE_IF_HAS_NO_EXIT; -        } -        break; - - -    case PARSEOP_ELSE: - -        if ((Op->Asl.CompileFlags & NODE_HAS_NO_EXIT) && -            (Op->Asl.CompileFlags & NODE_IF_HAS_NO_EXIT)) -        { -            /* -             * This ELSE block has no exit and the corresponding IF block -             * has no exit either. Therefore, the parent node has no exit. -             */ -            Op->Asl.Parent->Asl.CompileFlags |= NODE_HAS_NO_EXIT; -        } -        break; - - -    default: - -        if ((Op->Asl.CompileFlags & NODE_HAS_NO_EXIT) && -            (Op->Asl.Parent)) -        { -            /* If this node has no exit, then the parent has no exit either */ - -            Op->Asl.Parent->Asl.CompileFlags |= NODE_HAS_NO_EXIT; -        } -        break; -    } - -    return (AE_OK); -} - - -/******************************************************************************* - *   * FUNCTION:    AnMethodTypingWalkEnd   *   * PARAMETERS:  ASL_WALK_CALLBACK diff --git a/source/compiler/aslxref.c b/source/compiler/aslxref.c new file mode 100644 index 000000000000..11d016453026 --- /dev/null +++ b/source/compiler/aslxref.c @@ -0,0 +1,874 @@ +/****************************************************************************** + * + * Module Name: aslxref - Namespace cross-reference + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2012, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *    notice, this list of conditions, and the following disclaimer, + *    without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + *    substantially similar to the "NO WARRANTY" disclaimer below + *    ("Disclaimer") and any redistribution must be conditioned upon + *    including a substantially similar Disclaimer requirement for further + *    binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + *    of any contributors may be used to endorse or promote products derived + *    from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + + +#include "aslcompiler.h" +#include "aslcompiler.y.h" +#include "acparser.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acdispat.h" + + +#define _COMPONENT          ACPI_COMPILER +        ACPI_MODULE_NAME    ("aslxref") + +/* Local prototypes */ + +static ACPI_STATUS +XfNamespaceLocateBegin ( +    ACPI_PARSE_OBJECT       *Op, +    UINT32                  Level, +    void                    *Context); + +static ACPI_STATUS +XfNamespaceLocateEnd ( +    ACPI_PARSE_OBJECT       *Op, +    UINT32                  Level, +    void                    *Context); + +static BOOLEAN +XfObjectExists ( +    char                    *Name); + +static ACPI_STATUS +XfCompareOneNamespaceObject ( +    ACPI_HANDLE             ObjHandle, +    UINT32                  Level, +    void                    *Context, +    void                    **ReturnValue); + +static void +XfCheckFieldRange ( +    ACPI_PARSE_OBJECT       *Op, +    UINT32                  RegionBitLength, +    UINT32                  FieldBitOffset, +    UINT32                  FieldBitLength, +    UINT32                  AccessBitWidth); + + +/******************************************************************************* + * + * FUNCTION:    XfCrossReferenceNamespace + * + * PARAMETERS:  None + * + * RETURN:      Status + * + * DESCRIPTION: Perform a cross reference check of the parse tree against the + *              namespace. Every named referenced within the parse tree + *              should be get resolved with a namespace lookup. If not, the + *              original reference in the ASL code is invalid -- i.e., refers + *              to a non-existent object. + * + * NOTE:  The ASL "External" operator causes the name to be inserted into the + *        namespace so that references to the external name will be resolved + *        correctly here. + * + ******************************************************************************/ + +ACPI_STATUS +XfCrossReferenceNamespace ( +    void) +{ +    ACPI_WALK_STATE         *WalkState; + + +    DbgPrint (ASL_DEBUG_OUTPUT, "\nCross referencing namespace\n\n"); + +    /* +     * Create a new walk state for use when looking up names +     * within the namespace (Passed as context to the callbacks) +     */ +    WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); +    if (!WalkState) +    { +        return (AE_NO_MEMORY); +    } + +    /* Walk the entire parse tree */ + +    TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, XfNamespaceLocateBegin, +                        XfNamespaceLocateEnd, WalkState); +    return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION:    XfObjectExists + * + * PARAMETERS:  Name            - 4 char ACPI name + * + * RETURN:      TRUE if name exists in namespace + * + * DESCRIPTION: Walk the namespace to find an object + * + ******************************************************************************/ + +static BOOLEAN +XfObjectExists ( +    char                    *Name) +{ +    ACPI_STATUS             Status; + + +    /* Walk entire namespace from the supplied root */ + +    Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, +                ACPI_UINT32_MAX, FALSE, XfCompareOneNamespaceObject, NULL, +                Name, NULL); +    if (Status == AE_CTRL_TRUE) +    { +        /* At least one instance of the name was found */ + +        return (TRUE); +    } + +    return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION:    XfCompareOneNamespaceObject + * + * PARAMETERS:  ACPI_WALK_CALLBACK + * + * RETURN:      Status + * + * DESCRIPTION: Compare name of one object. + * + ******************************************************************************/ + +static ACPI_STATUS +XfCompareOneNamespaceObject ( +    ACPI_HANDLE             ObjHandle, +    UINT32                  Level, +    void                    *Context, +    void                    **ReturnValue) +{ +    ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + + +    /* Simply check the name */ + +    if (*((UINT32 *) (Context)) == Node->Name.Integer) +    { +        /* Abort walk if we found one instance */ + +        return (AE_CTRL_TRUE); +    } + +    return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION:    XfCheckFieldRange + * + * PARAMETERS:  RegionBitLength     - Length of entire parent region + *              FieldBitOffset      - Start of the field unit (within region) + *              FieldBitLength      - Entire length of field unit + *              AccessBitWidth      - Access width of the field unit + * + * RETURN:      None + * + * DESCRIPTION: Check one field unit to make sure it fits in the parent + *              op region. + * + * Note: AccessBitWidth must be either 8,16,32, or 64 + * + ******************************************************************************/ + +static void +XfCheckFieldRange ( +    ACPI_PARSE_OBJECT       *Op, +    UINT32                  RegionBitLength, +    UINT32                  FieldBitOffset, +    UINT32                  FieldBitLength, +    UINT32                  AccessBitWidth) +{ +    UINT32                  FieldEndBitOffset; + + +    /* +     * Check each field unit against the region size. The entire +     * field unit (start offset plus length) must fit within the +     * region. +     */ +    FieldEndBitOffset = FieldBitOffset + FieldBitLength; + +    if (FieldEndBitOffset > RegionBitLength) +    { +        /* Field definition itself is beyond the end-of-region */ + +        AslError (ASL_ERROR, ASL_MSG_FIELD_UNIT_OFFSET, Op, NULL); +        return; +    } + +    /* +     * Now check that the field plus AccessWidth doesn't go beyond +     * the end-of-region. Assumes AccessBitWidth is a power of 2 +     */ +    FieldEndBitOffset = ACPI_ROUND_UP (FieldEndBitOffset, AccessBitWidth); + +    if (FieldEndBitOffset > RegionBitLength) +    { +        /* Field definition combined with the access is beyond EOR */ + +        AslError (ASL_ERROR, ASL_MSG_FIELD_UNIT_ACCESS_WIDTH, Op, NULL); +    } +} + +/******************************************************************************* + * + * FUNCTION:    XfNamespaceLocateBegin + * + * PARAMETERS:  ASL_WALK_CALLBACK + * + * RETURN:      Status + * + * DESCRIPTION: Descending callback used during cross-reference. For named + *              object references, attempt to locate the name in the + *              namespace. + * + * NOTE: ASL references to named fields within resource descriptors are + *       resolved to integer values here. Therefore, this step is an + *       important part of the code generation. We don't know that the + *       name refers to a resource descriptor until now. + * + ******************************************************************************/ + +static ACPI_STATUS +XfNamespaceLocateBegin ( +    ACPI_PARSE_OBJECT       *Op, +    UINT32                  Level, +    void                    *Context) +{ +    ACPI_WALK_STATE         *WalkState = (ACPI_WALK_STATE *) Context; +    ACPI_NAMESPACE_NODE     *Node; +    ACPI_STATUS             Status; +    ACPI_OBJECT_TYPE        ObjectType; +    char                    *Path; +    UINT8                   PassedArgs; +    ACPI_PARSE_OBJECT       *NextOp; +    ACPI_PARSE_OBJECT       *OwningOp; +    ACPI_PARSE_OBJECT       *SpaceIdOp; +    UINT32                  MinimumLength; +    UINT32                  Offset; +    UINT32                  FieldBitLength; +    UINT32                  TagBitLength; +    UINT8                   Message = 0; +    const ACPI_OPCODE_INFO  *OpInfo; +    UINT32                  Flags; + + +    ACPI_FUNCTION_TRACE_PTR (XfNamespaceLocateBegin, Op); + +    /* +     * If this node is the actual declaration of a name +     * [such as the XXXX name in "Method (XXXX)"], +     * we are not interested in it here. We only care about names that are +     * references to other objects within the namespace and the parent objects +     * of name declarations +     */ +    if (Op->Asl.CompileFlags & NODE_IS_NAME_DECLARATION) +    { +        return (AE_OK); +    } + +    /* We are only interested in opcodes that have an associated name */ + +    OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); + +    if ((!(OpInfo->Flags & AML_NAMED)) && +        (!(OpInfo->Flags & AML_CREATE)) && +        (Op->Asl.ParseOpcode != PARSEOP_NAMESTRING) && +        (Op->Asl.ParseOpcode != PARSEOP_NAMESEG)    && +        (Op->Asl.ParseOpcode != PARSEOP_METHODCALL)) +    { +        return (AE_OK); +    } + +    /* +     * One special case: CondRefOf operator - we don't care if the name exists +     * or not at this point, just ignore it, the point of the operator is to +     * determine if the name exists at runtime. +     */ +    if ((Op->Asl.Parent) && +        (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)) +    { +        return (AE_OK); +    } + +    /* +     * We must enable the "search-to-root" for single NameSegs, but +     * we have to be very careful about opening up scopes +     */ +    Flags = ACPI_NS_SEARCH_PARENT; +    if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || +        (Op->Asl.ParseOpcode == PARSEOP_NAMESEG)    || +        (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)) +    { +        /* +         * These are name references, do not push the scope stack +         * for them. +         */ +        Flags |= ACPI_NS_DONT_OPEN_SCOPE; +    } + +    /* Get the NamePath from the appropriate place */ + +    if (OpInfo->Flags & AML_NAMED) +    { +        /* For nearly all NAMED operators, the name reference is the first child */ + +        Path = Op->Asl.Child->Asl.Value.String; +        if (Op->Asl.AmlOpcode == AML_ALIAS_OP) +        { +            /* +             * ALIAS is the only oddball opcode, the name declaration +             * (alias name) is the second operand +             */ +            Path = Op->Asl.Child->Asl.Next->Asl.Value.String; +        } +    } +    else if (OpInfo->Flags & AML_CREATE) +    { +        /* Name must appear as the last parameter */ + +        NextOp = Op->Asl.Child; +        while (!(NextOp->Asl.CompileFlags & NODE_IS_NAME_DECLARATION)) +        { +            NextOp = NextOp->Asl.Next; +        } +        Path = NextOp->Asl.Value.String; +    } +    else +    { +        Path = Op->Asl.Value.String; +    } + +    ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); +    ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, +        "Type=%s\n", AcpiUtGetTypeName (ObjectType))); + +    /* +     * Lookup the name in the namespace. Name must exist at this point, or it +     * is an invalid reference. +     * +     * The namespace is also used as a lookup table for references to resource +     * descriptors and the fields within them. +     */ +    Gbl_NsLookupCount++; + +    Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, +                ACPI_IMODE_EXECUTE, Flags, WalkState, &(Node)); +    if (ACPI_FAILURE (Status)) +    { +        if (Status == AE_NOT_FOUND) +        { +            /* +             * We didn't find the name reference by path -- we can qualify this +             * a little better before we print an error message +             */ +            if (strlen (Path) == ACPI_NAME_SIZE) +            { +                /* A simple, one-segment ACPI name */ + +                if (XfObjectExists (Path)) +                { +                    /* +                     * There exists such a name, but we couldn't get to it +                     * from this scope +                     */ +                    AslError (ASL_ERROR, ASL_MSG_NOT_REACHABLE, Op, +                        Op->Asl.ExternalName); +                } +                else +                { +                    /* The name doesn't exist, period */ + +                    AslError (ASL_ERROR, ASL_MSG_NOT_EXIST, +                        Op, Op->Asl.ExternalName); +                } +            } +            else +            { +                /* Check for a fully qualified path */ + +                if (Path[0] == AML_ROOT_PREFIX) +                { +                    /* Gave full path, the object does not exist */ + +                    AslError (ASL_ERROR, ASL_MSG_NOT_EXIST, Op, +                        Op->Asl.ExternalName); +                } +                else +                { +                    /* +                     * We can't tell whether it doesn't exist or just +                     * can't be reached. +                     */ +                    AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op, +                        Op->Asl.ExternalName); +                } +            } + +            Status = AE_OK; +        } +        return (Status); +    } + +    /* Check for a reference vs. name declaration */ + +    if (!(OpInfo->Flags & AML_NAMED) && +        !(OpInfo->Flags & AML_CREATE)) +    { +        /* This node has been referenced, mark it for reference check */ + +        Node->Flags |= ANOBJ_IS_REFERENCED; +    } + +    /* Attempt to optimize the NamePath */ + +    OptOptimizeNamePath (Op, OpInfo->Flags, WalkState, Path, Node); + +    /* +     * 1) Dereference an alias (A name reference that is an alias) +     *    Aliases are not nested, the alias always points to the final object +     */ +    if ((Op->Asl.ParseOpcode != PARSEOP_ALIAS) && +        (Node->Type == ACPI_TYPE_LOCAL_ALIAS)) +    { +        /* This node points back to the original PARSEOP_ALIAS */ + +        NextOp = Node->Op; + +        /* The first child is the alias target op */ + +        NextOp = NextOp->Asl.Child; + +        /* That in turn points back to original target alias node */ + +        if (NextOp->Asl.Node) +        { +            Node = NextOp->Asl.Node; +        } + +        /* Else - forward reference to alias, will be resolved later */ +    } + +    /* 2) Check for a reference to a resource descriptor */ + +    if ((Node->Type == ACPI_TYPE_LOCAL_RESOURCE_FIELD) || +        (Node->Type == ACPI_TYPE_LOCAL_RESOURCE)) +    { +        /* +         * This was a reference to a field within a resource descriptor. +         * Extract the associated field offset (either a bit or byte +         * offset depending on the field type) and change the named +         * reference into an integer for AML code generation +         */ +        Offset = Node->Value; +        TagBitLength = Node->Length; + +        /* +         * If a field is being created, generate the length (in bits) of +         * the field. Note: Opcodes other than CreateXxxField and Index +         * can come through here. For other opcodes, we just need to +         * convert the resource tag reference to an integer offset. +         */ +        switch (Op->Asl.Parent->Asl.AmlOpcode) +        { +        case AML_CREATE_FIELD_OP: /* Variable "Length" field, in bits */ +            /* +             * We know the length operand is an integer constant because +             * we know that it contains a reference to a resource +             * descriptor tag. +             */ +            FieldBitLength = (UINT32) Op->Asl.Next->Asl.Value.Integer; +            break; + +        case AML_CREATE_BIT_FIELD_OP: +            FieldBitLength = 1; +            break; + +        case AML_CREATE_BYTE_FIELD_OP: +        case AML_INDEX_OP: +            FieldBitLength = 8; +            break; + +        case AML_CREATE_WORD_FIELD_OP: +            FieldBitLength = 16; +            break; + +        case AML_CREATE_DWORD_FIELD_OP: +            FieldBitLength = 32; +            break; + +        case AML_CREATE_QWORD_FIELD_OP: +            FieldBitLength = 64; +            break; + +        default: +            FieldBitLength = 0; +            break; +        } + +        /* Check the field length against the length of the resource tag */ + +        if (FieldBitLength) +        { +            if (TagBitLength < FieldBitLength) +            { +                Message = ASL_MSG_TAG_SMALLER; +            } +            else if (TagBitLength > FieldBitLength) +            { +                Message = ASL_MSG_TAG_LARGER; +            } + +            if (Message) +            { +                sprintf (MsgBuffer, "Size mismatch, Tag: %u bit%s, Field: %u bit%s", +                    TagBitLength, (TagBitLength > 1) ? "s" : "", +                    FieldBitLength, (FieldBitLength > 1) ? "s" : ""); + +                AslError (ASL_WARNING, Message, Op, MsgBuffer); +            } +        } + +        /* Convert the BitOffset to a ByteOffset for certain opcodes */ + +        switch (Op->Asl.Parent->Asl.AmlOpcode) +        { +        case AML_CREATE_BYTE_FIELD_OP: +        case AML_CREATE_WORD_FIELD_OP: +        case AML_CREATE_DWORD_FIELD_OP: +        case AML_CREATE_QWORD_FIELD_OP: +        case AML_INDEX_OP: + +            Offset = ACPI_DIV_8 (Offset); +            break; + +        default: +            break; +        } + +        /* Now convert this node to an integer whose value is the field offset */ + +        Op->Asl.AmlLength = 0; +        Op->Asl.ParseOpcode = PARSEOP_INTEGER; +        Op->Asl.Value.Integer = (UINT64) Offset; +        Op->Asl.CompileFlags |= NODE_IS_RESOURCE_FIELD; + +        OpcGenerateAmlOpcode (Op); +    } + +    /* 3) Check for a method invocation */ + +    else if ((((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || (Op->Asl.ParseOpcode == PARSEOP_NAMESEG)) && +                (Node->Type == ACPI_TYPE_METHOD) && +                (Op->Asl.Parent) && +                (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_METHOD))   || + +                (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)) +    { + +        /* +         * A reference to a method within one of these opcodes is not an +         * invocation of the method, it is simply a reference to the method. +         */ +        if ((Op->Asl.Parent) && +           ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_REFOF)      || +            (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_DEREFOF)    || +            (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_OBJECTTYPE))) +        { +            return (AE_OK); +        } +        /* +         * There are two types of method invocation: +         * 1) Invocation with arguments -- the parser recognizes this +         *    as a METHODCALL. +         * 2) Invocation with no arguments --the parser cannot determine that +         *    this is a method invocation, therefore we have to figure it out +         *    here. +         */ +        if (Node->Type != ACPI_TYPE_METHOD) +        { +            sprintf (MsgBuffer, "%s is a %s", +                    Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type)); + +            AslError (ASL_ERROR, ASL_MSG_NOT_METHOD, Op, MsgBuffer); +            return (AE_OK); +        } + +        /* Save the method node in the caller's op */ + +        Op->Asl.Node = Node; +        if (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF) +        { +            return (AE_OK); +        } + +        /* +         * This is a method invocation, with or without arguments. +         * Count the number of arguments, each appears as a child +         * under the parent node +         */ +        Op->Asl.ParseOpcode = PARSEOP_METHODCALL; +        UtSetParseOpName (Op); + +        PassedArgs = 0; +        NextOp     = Op->Asl.Child; + +        while (NextOp) +        { +            PassedArgs++; +            NextOp = NextOp->Asl.Next; +        } + +        if (Node->Value != ASL_EXTERNAL_METHOD) +        { +            /* +             * Check the parsed arguments with the number expected by the +             * method declaration itself +             */ +            if (PassedArgs != Node->Value) +            { +                sprintf (MsgBuffer, "%s requires %u", Op->Asl.ExternalName, +                            Node->Value); + +                if (PassedArgs < Node->Value) +                { +                    AslError (ASL_ERROR, ASL_MSG_ARG_COUNT_LO, Op, MsgBuffer); +                } +                else +                { +                    AslError (ASL_ERROR, ASL_MSG_ARG_COUNT_HI, Op, MsgBuffer); +                } +            } +        } +    } + +    /* 4) Check for an ASL Field definition */ + +    else if ((Op->Asl.Parent) && +            ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_FIELD)     || +             (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_BANKFIELD))) +    { +        /* +         * Offset checking for fields. If the parent operation region has a +         * constant length (known at compile time), we can check fields +         * defined in that region against the region length. This will catch +         * fields and field units that cannot possibly fit within the region. +         * +         * Note: Index fields do not directly reference an operation region, +         * thus they are not included in this check. +         */ +        if (Op == Op->Asl.Parent->Asl.Child) +        { +            /* +             * This is the first child of the field node, which is +             * the name of the region. Get the parse node for the +             * region -- which contains the length of the region. +             */ +            OwningOp = Node->Op; +            Op->Asl.Parent->Asl.ExtraValue = +                ACPI_MUL_8 ((UINT32) OwningOp->Asl.Value.Integer); + +            /* Examine the field access width */ + +            switch ((UINT8) Op->Asl.Parent->Asl.Value.Integer) +            { +            case AML_FIELD_ACCESS_ANY: +            case AML_FIELD_ACCESS_BYTE: +            case AML_FIELD_ACCESS_BUFFER: +            default: +                MinimumLength = 1; +                break; + +            case AML_FIELD_ACCESS_WORD: +                MinimumLength = 2; +                break; + +            case AML_FIELD_ACCESS_DWORD: +                MinimumLength = 4; +                break; + +            case AML_FIELD_ACCESS_QWORD: +                MinimumLength = 8; +                break; +            } + +            /* +             * Is the region at least as big as the access width? +             * Note: DataTableRegions have 0 length +             */ +            if (((UINT32) OwningOp->Asl.Value.Integer) && +                ((UINT32) OwningOp->Asl.Value.Integer < MinimumLength)) +            { +                AslError (ASL_ERROR, ASL_MSG_FIELD_ACCESS_WIDTH, Op, NULL); +            } + +            /* +             * Check EC/CMOS/SMBUS fields to make sure that the correct +             * access type is used (BYTE for EC/CMOS, BUFFER for SMBUS) +             */ +            SpaceIdOp = OwningOp->Asl.Child->Asl.Next; +            switch ((UINT32) SpaceIdOp->Asl.Value.Integer) +            { +            case ACPI_ADR_SPACE_EC: +            case ACPI_ADR_SPACE_CMOS: +            case ACPI_ADR_SPACE_GPIO: + +                if ((UINT8) Op->Asl.Parent->Asl.Value.Integer != AML_FIELD_ACCESS_BYTE) +                { +                    AslError (ASL_ERROR, ASL_MSG_REGION_BYTE_ACCESS, Op, NULL); +                } +                break; + +            case ACPI_ADR_SPACE_SMBUS: +            case ACPI_ADR_SPACE_IPMI: +            case ACPI_ADR_SPACE_GSBUS: + +                if ((UINT8) Op->Asl.Parent->Asl.Value.Integer != AML_FIELD_ACCESS_BUFFER) +                { +                    AslError (ASL_ERROR, ASL_MSG_REGION_BUFFER_ACCESS, Op, NULL); +                } +                break; + +            default: + +                /* Nothing to do for other address spaces */ +                break; +            } +        } +        else +        { +            /* +             * This is one element of the field list. Check to make sure +             * that it does not go beyond the end of the parent operation region. +             * +             * In the code below: +             *    Op->Asl.Parent->Asl.ExtraValue      - Region Length (bits) +             *    Op->Asl.ExtraValue                  - Field start offset (bits) +             *    Op->Asl.Child->Asl.Value.Integer32  - Field length (bits) +             *    Op->Asl.Child->Asl.ExtraValue       - Field access width (bits) +             */ +            if (Op->Asl.Parent->Asl.ExtraValue && Op->Asl.Child) +            { +                XfCheckFieldRange (Op, +                            Op->Asl.Parent->Asl.ExtraValue, +                            Op->Asl.ExtraValue, +                            (UINT32) Op->Asl.Child->Asl.Value.Integer, +                            Op->Asl.Child->Asl.ExtraValue); +            } +        } +    } + +    Op->Asl.Node = Node; +    return (Status); +} + + +/******************************************************************************* + * + * FUNCTION:    XfNamespaceLocateEnd + * + * PARAMETERS:  ASL_WALK_CALLBACK + * + * RETURN:      Status + * + * DESCRIPTION: Ascending callback used during cross reference. We only + *              need to worry about scope management here. + * + ******************************************************************************/ + +static ACPI_STATUS +XfNamespaceLocateEnd ( +    ACPI_PARSE_OBJECT       *Op, +    UINT32                  Level, +    void                    *Context) +{ +    ACPI_WALK_STATE         *WalkState = (ACPI_WALK_STATE *) Context; +    const ACPI_OPCODE_INFO  *OpInfo; + + +    ACPI_FUNCTION_TRACE (XfNamespaceLocateEnd); + + +    /* We are only interested in opcodes that have an associated name */ + +    OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); +    if (!(OpInfo->Flags & AML_NAMED)) +    { +        return (AE_OK); +    } + +    /* Not interested in name references, we did not open a scope for them */ + +    if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || +        (Op->Asl.ParseOpcode == PARSEOP_NAMESEG)    || +        (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)) +    { +        return (AE_OK); +    } + +    /* Pop the scope stack if necessary */ + +    if (AcpiNsOpensScope (AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode))) +    { + +        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, +            "%s: Popping scope for Op %p\n", +            AcpiUtGetTypeName (OpInfo->ObjectType), Op)); + +        (void) AcpiDsScopeStackPop (WalkState); +    } + +    return (AE_OK); +} diff --git a/source/compiler/dtcompile.c b/source/compiler/dtcompile.c index e67f3e68f84f..96e2b418ca0f 100644 --- a/source/compiler/dtcompile.c +++ b/source/compiler/dtcompile.c @@ -165,7 +165,7 @@ DtDoCompile (      /* Write the binary, then the optional hex file */      DtOutputBinary (Gbl_RootTable); -    LsDoHexOutput (); +    HxDoHexOutput ();      DtWriteTableToListing ();  CleanupAndExit: @@ -284,6 +284,7 @@ DtCompileDataTable (      char                    *Signature;      ACPI_TABLE_HEADER       *AcpiTableHeader;      ACPI_STATUS             Status; +    DT_FIELD                *RootField = *FieldList;      /* Verify that we at least have a table signature and save it */ @@ -354,7 +355,7 @@ DtCompileDataTable (      if (!TableData || Gbl_CompileGeneric)      {          DtCompileGeneric ((void **) FieldList); -        goto Out; +        goto FinishHeader;      }      /* Dispatch to per-table compile */ @@ -391,7 +392,8 @@ DtCompileDataTable (          return (AE_ERROR);      } -Out: +FinishHeader: +      /* Set the final table length and then the checksum */      DtSetTableLength (); @@ -399,6 +401,8 @@ Out:          ACPI_TABLE_HEADER, Gbl_RootTable->Buffer);      DtSetTableChecksum (&AcpiTableHeader->Checksum); +    DtDumpFieldList (RootField); +    DtDumpSubtableList ();      return (AE_OK);  } diff --git a/source/compiler/dtcompiler.h b/source/compiler/dtcompiler.h index 84b916acc4c9..4ac86c4a3579 100644 --- a/source/compiler/dtcompiler.h +++ b/source/compiler/dtcompiler.h @@ -113,6 +113,7 @@ typedef struct dt_subtable      UINT32                  Length;      UINT32                  TotalLength;      UINT32                  SizeOfLengthField; +    UINT16                  Depth;      UINT8                   Flags;  } DT_SUBTABLE; @@ -168,6 +169,14 @@ DtOutputBinary (      DT_SUBTABLE             *RootTable);  void +DtDumpSubtableList ( +    void); + +void +DtDumpFieldList ( +    DT_FIELD                *Field); + +void  DtWriteFieldToListing (      UINT8                   *Buffer,      DT_FIELD                *Field, @@ -387,6 +396,10 @@ DtCompileCpep (      void                    **PFieldList);  ACPI_STATUS +DtCompileCsrt ( +    void                    **PFieldList); + +ACPI_STATUS  DtCompileDmar (      void                    **PFieldList); @@ -481,6 +494,7 @@ extern const unsigned char  TemplateBoot[];  extern const unsigned char  TemplateBert[];  extern const unsigned char  TemplateBgrt[];  extern const unsigned char  TemplateCpep[]; +extern const unsigned char  TemplateCsrt[];  extern const unsigned char  TemplateDbgp[];  extern const unsigned char  TemplateDmar[];  extern const unsigned char  TemplateEcdt[]; @@ -507,6 +521,7 @@ extern const unsigned char  TemplateSpcr[];  extern const unsigned char  TemplateSpmi[];  extern const unsigned char  TemplateSrat[];  extern const unsigned char  TemplateTcpa[]; +extern const unsigned char  TemplateTpm2[];  extern const unsigned char  TemplateUefi[];  extern const unsigned char  TemplateWaet[];  extern const unsigned char  TemplateWdat[]; diff --git a/source/compiler/dtio.c b/source/compiler/dtio.c index 9d1bcb2f3284..3571c39a0d26 100644 --- a/source/compiler/dtio.c +++ b/source/compiler/dtio.c @@ -79,6 +79,18 @@ DtDumpBuffer (      UINT32                  Offset,      UINT32                  Length); +static void +DtDumpSubtableInfo ( +    DT_SUBTABLE             *Subtable, +    void                    *Context, +    void                    *ReturnValue); + +static void +DtDumpSubtableTree ( +    DT_SUBTABLE             *Subtable, +    void                    *Context, +    void                    *ReturnValue); +  /* States for DtGetNextLine */ @@ -708,7 +720,6 @@ DtScanFile (  {      ACPI_STATUS             Status;      UINT32                  Offset; -    DT_FIELD                *Next;      ACPI_FUNCTION_NAME (DtScanFile); @@ -738,28 +749,7 @@ DtScanFile (      /* Dump the parse tree if debug enabled */ -    if (Gbl_DebugFlag) -    { -        Next = Gbl_FieldList; -        DbgPrint (ASL_DEBUG_OUTPUT, "Tree:  %32s %32s %8s %8s %8s %8s %8s %8s\n\n", -            "Name", "Value", "Line", "ByteOff", "NameCol", "Column", "TableOff", "Flags"); - -        while (Next) -        { -            DbgPrint (ASL_DEBUG_OUTPUT, "Field: %32.32s %32.32s %.8X %.8X %.8X %.8X %.8X %.8X\n", -                Next->Name, -                Next->Value, -                Next->Line, -                Next->ByteOffset, -                Next->NameColumn, -                Next->Column, -                Next->TableOffset, -                Next->Flags); - -            Next = Next->Next; -        } -    } - +    DtDumpFieldList (Gbl_FieldList);      return (Gbl_FieldList);  } @@ -913,6 +903,123 @@ DtDumpBuffer (  /******************************************************************************   * + * FUNCTION:    DtDumpFieldList + * + * PARAMETERS:  Field               - Root field + * + * RETURN:      None + * + * DESCRIPTION: Dump the entire field list + * + *****************************************************************************/ + +void +DtDumpFieldList ( +    DT_FIELD                *Field) +{ + +    if (!Gbl_DebugFlag || !Field) +    { +        return; +    } + +    DbgPrint (ASL_DEBUG_OUTPUT,  "\nField List:\n" +        "LineNo   ByteOff  NameCol  Column   TableOff " +        "Flags    %32s : %s\n\n", "Name", "Value"); +    while (Field) +    { +        DbgPrint (ASL_DEBUG_OUTPUT, +            "%.08X %.08X %.08X %.08X %.08X %.08X %32s : %s\n", +            Field->Line, Field->ByteOffset, Field->NameColumn, +            Field->Column, Field->TableOffset, Field->Flags, +            Field->Name, Field->Value); + +        Field = Field->Next; +    } + +    DbgPrint (ASL_DEBUG_OUTPUT,  "\n\n"); +} + + +/****************************************************************************** + * + * FUNCTION:    DtDumpSubtableInfo, DtDumpSubtableTree + * + * PARAMETERS:  DT_WALK_CALLBACK + * + * RETURN:      None + * + * DESCRIPTION: Info - dump a subtable tree entry with extra information. + *              Tree - dump a subtable tree formatted by depth indentation. + * + *****************************************************************************/ + +static void +DtDumpSubtableInfo ( +    DT_SUBTABLE             *Subtable, +    void                    *Context, +    void                    *ReturnValue) +{ + +    DbgPrint (ASL_DEBUG_OUTPUT, +        "[%.04X] %.08X %.08X %.08X %.08X %.08X %p %p %p\n", +        Subtable->Depth, Subtable->Length, Subtable->TotalLength, +        Subtable->SizeOfLengthField, Subtable->Flags, Subtable, +        Subtable->Parent, Subtable->Child, Subtable->Peer); +} + +static void +DtDumpSubtableTree ( +    DT_SUBTABLE             *Subtable, +    void                    *Context, +    void                    *ReturnValue) +{ + +    DbgPrint (ASL_DEBUG_OUTPUT, +        "[%.04X] %*s%08X (%.02X) - (%.02X)\n", +        Subtable->Depth, (4 * Subtable->Depth), " ", +        Subtable, Subtable->Length, Subtable->TotalLength); +} + + +/****************************************************************************** + * + * FUNCTION:    DtDumpSubtableList + * + * PARAMETERS:  None + * + * RETURN:      None + * + * DESCRIPTION: Dump the raw list of subtables with information, and also + *              dump the subtable list in formatted tree format. Assists with + *              the development of new table code. + * + *****************************************************************************/ + +void +DtDumpSubtableList ( +    void) +{ + +    if (!Gbl_DebugFlag || !Gbl_RootTable) +    { +        return; +    } + +    DbgPrint (ASL_DEBUG_OUTPUT, +        "Subtable Info:\n" +        "Depth  Length   TotalLen LenSize  Flags    " +        "This     Parent   Child    Peer\n\n"); +    DtWalkTableTree (Gbl_RootTable, DtDumpSubtableInfo, NULL, NULL); + +    DbgPrint (ASL_DEBUG_OUTPUT, +        "\nSubtable Tree: (Depth, Subtable, Length, TotalLength)\n\n"); +    DtWalkTableTree (Gbl_RootTable, DtDumpSubtableTree, NULL, NULL); +} + + +/****************************************************************************** + *   * FUNCTION:    DtWriteFieldToListing   *   * PARAMETERS:  Buffer              - Contains the compiled data diff --git a/source/compiler/dtsubtable.c b/source/compiler/dtsubtable.c index 27d09cae2ee3..f7280855456e 100644 --- a/source/compiler/dtsubtable.c +++ b/source/compiler/dtsubtable.c @@ -112,6 +112,7 @@ DtInsertSubtable (      Subtable->Peer = NULL;      Subtable->Parent = ParentTable; +    Subtable->Depth = ParentTable->Depth + 1;      /* Link the new entry into the child list */ diff --git a/source/compiler/dttable.c b/source/compiler/dttable.c index 2e8ac0abd0a0..95110a757ac7 100644 --- a/source/compiler/dttable.c +++ b/source/compiler/dttable.c @@ -420,6 +420,94 @@ DtCompileCpep (  /******************************************************************************   * + * FUNCTION:    DtCompileCsrt + * + * PARAMETERS:  List                - Current field list pointer + * + * RETURN:      Status + * + * DESCRIPTION: Compile CSRT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileCsrt ( +    void                    **List) +{ +    ACPI_STATUS             Status = AE_OK; +    DT_SUBTABLE             *Subtable; +    DT_SUBTABLE             *ParentTable; +    DT_FIELD                **PFieldList = (DT_FIELD **) List; +    UINT32                  DescriptorCount; +    UINT32                  GroupLength; + + +    /* Sub-tables (Resource Groups) */ + +    while (*PFieldList) +    { +        /* Resource group subtable */ + +        Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt0, +                    &Subtable, TRUE); +        if (ACPI_FAILURE (Status)) +        { +            return (Status); +        } + +        /* Compute the number of resource descriptors */ + +        GroupLength = +            (ACPI_CAST_PTR (ACPI_CSRT_GROUP, +                Subtable->Buffer))->Length - +            (ACPI_CAST_PTR (ACPI_CSRT_GROUP, +                Subtable->Buffer))->SharedInfoLength - +            sizeof (ACPI_CSRT_GROUP); + +        DescriptorCount = (GroupLength  / +            sizeof (ACPI_CSRT_DESCRIPTOR)); + +        ParentTable = DtPeekSubtable (); +        DtInsertSubtable (ParentTable, Subtable); +        DtPushSubtable (Subtable); + +        /* Shared info subtable (One per resource group) */ + +        Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt1, +                    &Subtable, TRUE); +        if (ACPI_FAILURE (Status)) +        { +            return (Status); +        } + +        ParentTable = DtPeekSubtable (); +        DtInsertSubtable (ParentTable, Subtable); + +        /* Sub-Subtables (Resource Descriptors) */ + +        while (*PFieldList && DescriptorCount) +        { +            Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt2, +                        &Subtable, TRUE); +            if (ACPI_FAILURE (Status)) +            { +                return (Status); +            } + +            ParentTable = DtPeekSubtable (); +            DtInsertSubtable (ParentTable, Subtable); +            DescriptorCount--; +        } + +        DtPopSubtable (); +    } + +    return (Status); +} + + +/****************************************************************************** + *   * FUNCTION:    DtCompileDmar   *   * PARAMETERS:  List                - Current field list pointer diff --git a/source/compiler/dttemplate.h b/source/compiler/dttemplate.h index 1a817cd886c1..8dba95793b36 100644 --- a/source/compiler/dttemplate.h +++ b/source/compiler/dttemplate.h @@ -128,6 +128,52 @@ const unsigned char TemplateCpep[] =      0x00,0x00,0x00,0x00                       /* 00000030    "...."     */  }; +const unsigned char TemplateCsrt[] = +{ +    0x43,0x53,0x52,0x54,0x4C,0x01,0x00,0x00,  /* 00000000    "CSRTL..." */ +    0x01,0x0D,0x49,0x4E,0x54,0x45,0x4C,0x20,  /* 00000008    "..INTEL " */ +    0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45,  /* 00000010    "TEMPLATE" */ +    0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */ +    0x14,0x11,0x12,0x20,0x88,0x00,0x00,0x00,  /* 00000020    "... ...." */ +    0x49,0x4E,0x54,0x4C,0x00,0x00,0x00,0x00,  /* 00000028    "INTL...." */ +    0x60,0x9C,0x00,0x00,0x02,0x00,0x00,0x00,  /* 00000030    "`......." */ +    0x1C,0x00,0x00,0x00,0x01,0x00,0x00,0x00,  /* 00000038    "........" */ +    0x00,0x00,0xA0,0xB3,0x00,0x00,0x00,0x00,  /* 00000040    "........" */ +    0x2A,0x00,0x00,0x00,0x02,0x00,0x06,0x20,  /* 00000048    "*...... " */ +    0x00,0x00,0x10,0x00,0xFF,0x0F,0x00,0x00,  /* 00000050    "........" */ +    0x0C,0x00,0x00,0x00,0x03,0x00,0x01,0x00,  /* 00000058    "........" */ +    0x53,0x50,0x49,0x20,0x0C,0x00,0x00,0x00,  /* 00000060    "SPI ...." */ +    0x03,0x00,0x00,0x00,0x43,0x48,0x41,0x30,  /* 00000068    "....CHA0" */ +    0x0C,0x00,0x00,0x00,0x03,0x00,0x00,0x00,  /* 00000070    "........" */ +    0x43,0x48,0x41,0x31,0x0C,0x00,0x00,0x00,  /* 00000078    "CHA1...." */ +    0x03,0x00,0x00,0x00,0x43,0x48,0x41,0x32,  /* 00000080    "....CHA2" */ +    0x0C,0x00,0x00,0x00,0x03,0x00,0x00,0x00,  /* 00000088    "........" */ +    0x43,0x48,0x41,0x33,0x0C,0x00,0x00,0x00,  /* 00000090    "CHA3...." */ +    0x03,0x00,0x00,0x00,0x43,0x48,0x41,0x34,  /* 00000098    "....CHA4" */ +    0x0C,0x00,0x00,0x00,0x03,0x00,0x00,0x00,  /* 000000A0    "........" */ +    0x43,0x48,0x41,0x35,0xA0,0x00,0x00,0x00,  /* 000000A8    "CHA5...." */ +    0x49,0x4E,0x54,0x4C,0x00,0x00,0x00,0x00,  /* 000000B0    "INTL...." */ +    0x60,0x9C,0x00,0x00,0x03,0x00,0x00,0x00,  /* 000000B8    "`......." */ +    0x1C,0x00,0x00,0x00,0x01,0x00,0x00,0x00,  /* 000000C0    "........" */ +    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000C8    "........" */ +    0x2B,0x00,0x00,0x00,0x02,0x00,0x08,0x20,  /* 000000D0    "+...... " */ +    0x10,0x00,0x10,0x00,0xFF,0x0F,0x00,0x00,  /* 000000D8    "........" */ +    0x0C,0x00,0x00,0x00,0x03,0x00,0x01,0x00,  /* 000000E0    "........" */ +    0x49,0x32,0x43,0x20,0x0C,0x00,0x00,0x00,  /* 000000E8    "I2C ...." */ +    0x03,0x00,0x00,0x00,0x43,0x48,0x41,0x30,  /* 000000F0    "....CHA0" */ +    0x0C,0x00,0x00,0x00,0x03,0x00,0x00,0x00,  /* 000000F8    "........" */ +    0x43,0x48,0x41,0x31,0x0C,0x00,0x00,0x00,  /* 00000100    "CHA1...." */ +    0x03,0x00,0x00,0x00,0x43,0x48,0x41,0x32,  /* 00000108    "....CHA2" */ +    0x0C,0x00,0x00,0x00,0x03,0x00,0x00,0x00,  /* 00000110    "........" */ +    0x43,0x48,0x41,0x33,0x0C,0x00,0x00,0x00,  /* 00000118    "CHA3...." */ +    0x03,0x00,0x00,0x00,0x43,0x48,0x41,0x34,  /* 00000120    "....CHA4" */ +    0x0C,0x00,0x00,0x00,0x03,0x00,0x00,0x00,  /* 00000128    "........" */ +    0x43,0x48,0x41,0x35,0x0C,0x00,0x00,0x00,  /* 00000130    "CHA5...." */ +    0x03,0x00,0x00,0x00,0x43,0x48,0x41,0x36,  /* 00000138    "....CHA6" */ +    0x0C,0x00,0x00,0x00,0x03,0x00,0x00,0x00,  /* 00000140    "........" */ +    0x43,0x48,0x41,0x37                       /* 00000148    "CHA7"     */ +}; +  const unsigned char TemplateDbgp[] =  {      0x44,0x42,0x47,0x50,0x34,0x00,0x00,0x00,  /* 00000000    "DBGP4..." */ @@ -825,6 +871,17 @@ const unsigned char TemplateTcpa[] =      0x00,0x00                                 /* 00000030    ".."       */  }; +const unsigned char TemplateTpm2[] = +{ +    0x54,0x50,0x4D,0x32,0x34,0x00,0x00,0x00,  /* 00000000    "TPM24..." */ +    0x03,0x42,0x49,0x4E,0x54,0x45,0x4C,0x20,  /* 00000008    ".BINTEL " */ +    0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45,  /* 00000010    "TEMPLATE" */ +    0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */ +    0x14,0x11,0x12,0x20,0x00,0x00,0x00,0x00,  /* 00000020    "... ...." */ +    0x77,0x66,0x55,0x44,0x33,0x22,0x11,0x00,  /* 00000028    "wfUD3".." */ +    0x01,0x00,0x00,0x00                       /* 00000030    "...."     */ +}; +  const unsigned char TemplateUefi[] =  {      0x55,0x45,0x46,0x49,0x36,0x00,0x00,0x00,  /* 00000000    "UEFI6..." */ | 
