From owner-svn-src-head@FreeBSD.ORG Thu Apr 4 22:11:32 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id D22AECBD; Thu, 4 Apr 2013 22:11:32 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id C154FC; Thu, 4 Apr 2013 22:11:32 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r34MBWdV021546; Thu, 4 Apr 2013 22:11:32 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r34MBU5T021532; Thu, 4 Apr 2013 22:11:30 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201304042211.r34MBU5T021532@svn.freebsd.org> From: Jung-uk Kim Date: Thu, 4 Apr 2013 22:11:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r249112 - in head: sys/conf sys/contrib/dev/acpica sys/contrib/dev/acpica/common sys/contrib/dev/acpica/compiler sys/contrib/dev/acpica/components/debugger sys/contrib/dev/acpica/compon... X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Apr 2013 22:11:32 -0000 Author: jkim Date: Thu Apr 4 22:11:30 2013 New Revision: 249112 URL: http://svnweb.freebsd.org/changeset/base/249112 Log: Merge ACPICA 20130328. Added: head/sys/contrib/dev/acpica/compiler/asllistsup.c - copied, changed from r249110, vendor-sys/acpica/dist/source/compiler/asllistsup.c head/sys/contrib/dev/acpica/compiler/asloffset.c - copied, changed from r249110, vendor-sys/acpica/dist/source/compiler/asloffset.c head/sys/contrib/dev/acpica/components/utilities/utpredef.c - copied, changed from r249110, vendor-sys/acpica/dist/source/components/utilities/utpredef.c Modified: head/sys/conf/files head/sys/contrib/dev/acpica/changes.txt (contents, props changed) head/sys/contrib/dev/acpica/common/ahpredef.c head/sys/contrib/dev/acpica/compiler/aslcompile.c head/sys/contrib/dev/acpica/compiler/aslcompiler.h head/sys/contrib/dev/acpica/compiler/asldefine.h head/sys/contrib/dev/acpica/compiler/aslerror.c head/sys/contrib/dev/acpica/compiler/aslfiles.c head/sys/contrib/dev/acpica/compiler/aslglobal.h head/sys/contrib/dev/acpica/compiler/asllisting.c head/sys/contrib/dev/acpica/compiler/aslmain.c head/sys/contrib/dev/acpica/compiler/aslpredef.c head/sys/contrib/dev/acpica/compiler/aslprepkg.c head/sys/contrib/dev/acpica/compiler/aslresource.c head/sys/contrib/dev/acpica/compiler/asltypes.h head/sys/contrib/dev/acpica/compiler/aslwalks.c head/sys/contrib/dev/acpica/components/debugger/dbmethod.c head/sys/contrib/dev/acpica/components/debugger/dbnames.c head/sys/contrib/dev/acpica/components/dispatcher/dsopcode.c head/sys/contrib/dev/acpica/components/dispatcher/dswexec.c head/sys/contrib/dev/acpica/components/events/evevent.c head/sys/contrib/dev/acpica/components/executer/exoparg2.c head/sys/contrib/dev/acpica/components/namespace/nseval.c head/sys/contrib/dev/acpica/components/namespace/nspredef.c head/sys/contrib/dev/acpica/components/tables/tbfadt.c head/sys/contrib/dev/acpica/components/tables/tbxface.c head/sys/contrib/dev/acpica/components/utilities/utdelete.c head/sys/contrib/dev/acpica/components/utilities/utmutex.c head/sys/contrib/dev/acpica/components/utilities/utosi.c head/sys/contrib/dev/acpica/components/utilities/utxface.c head/sys/contrib/dev/acpica/include/acglobal.h head/sys/contrib/dev/acpica/include/aclocal.h head/sys/contrib/dev/acpica/include/acnamesp.h head/sys/contrib/dev/acpica/include/acpixf.h head/sys/contrib/dev/acpica/include/acpredef.h head/sys/contrib/dev/acpica/include/acutils.h head/usr.sbin/acpi/acpidb/Makefile head/usr.sbin/acpi/iasl/Makefile Directory Properties: head/sys/contrib/dev/acpica/ (props changed) head/sys/contrib/dev/acpica/common/ (props changed) head/sys/contrib/dev/acpica/compiler/ (props changed) head/sys/contrib/dev/acpica/components/debugger/ (props changed) head/sys/contrib/dev/acpica/components/dispatcher/ (props changed) head/sys/contrib/dev/acpica/components/events/ (props changed) head/sys/contrib/dev/acpica/components/executer/ (props changed) head/sys/contrib/dev/acpica/components/namespace/ (props changed) head/sys/contrib/dev/acpica/components/tables/ (props changed) head/sys/contrib/dev/acpica/components/utilities/ (props changed) head/sys/contrib/dev/acpica/include/ (props changed) Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Thu Apr 4 21:34:22 2013 (r249111) +++ head/sys/conf/files Thu Apr 4 22:11:30 2013 (r249112) @@ -443,6 +443,7 @@ contrib/dev/acpica/components/utilities/ contrib/dev/acpica/components/utilities/utobject.c optional acpi contrib/dev/acpica/components/utilities/utosi.c optional acpi contrib/dev/acpica/components/utilities/utownerid.c optional acpi +contrib/dev/acpica/components/utilities/utpredef.c optional acpi contrib/dev/acpica/components/utilities/utresrc.c optional acpi contrib/dev/acpica/components/utilities/utstate.c optional acpi contrib/dev/acpica/components/utilities/utstring.c optional acpi Modified: head/sys/contrib/dev/acpica/changes.txt ============================================================================== --- head/sys/contrib/dev/acpica/changes.txt Thu Apr 4 21:34:22 2013 (r249111) +++ head/sys/contrib/dev/acpica/changes.txt Thu Apr 4 22:11:30 2013 (r249112) @@ -1,4 +1,79 @@ ---------------------------------------- +28 March 2013. Summary of changes for version 20130328: + +1) ACPICA kernel-resident subsystem: + +Fixed several possible race conditions with the internal object reference +counting mechanism. Some of the external ACPICA interfaces update object +reference counts without holding the interpreter or namespace lock. This +change adds a spinlock to protect reference count updates on the internal +ACPICA objects. Reported by and with assistance from Andriy Gapon +(avg@FreeBSD.org). + +FADT support: Removed an extraneous warning for very large GPE register +sets. This change removes a size mismatch warning if the legacy length +field for a GPE register set is larger than the 64-bit GAS structure can +accommodate. GPE register sets can be larger than the 255-bit width +limitation of the GAS structure. Linn Crosetto (linn@hp.com). + +_OSI Support: handle any errors from AcpiOsAcquireMutex. Check for error +return from this interface. Handles a possible timeout case if +ACPI_WAIT_FOREVER is modified by the host to be a value less than +"forever". Jung-uk Kim. + +Predefined name support: Add allowed/required argument type information to +the master predefined info table. This change adds the infrastructure to +enable typechecking on incoming arguments for all predefined +methods/objects. It does not actually contain the code that will fully +utilize this information, this is still under development. Also condenses +some duplicate code for the predefined names into a new module, +utilities/utpredef.c + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and +has a much larger code and data size. + + Previous Release: + Non-Debug Version: 95.0K Code, 25.9K Data, 120.9K Total + Debug Version: 182.9K Code, 75.6K Data, 258.5K Total + Current Release: + Non-Debug Version: 95.2K Code, 26.4K Data, 121.6K Total + Debug Version: 183.0K Code, 76.0K Data, 259.0K Total + + +2) iASL Compiler/Disassembler and Tools: + +iASL: Implemented a new option to simplify the development of ACPI-related +BIOS code. Adds support for a new "offset table" output file. The -so +option will create a C table containing the AML table offsets of various +named objects in the namespace so that BIOS code can modify them easily at +boot time. This can simplify BIOS runtime code by eliminating expensive +searches for "magic values", enhancing boot times and adding greater +reliability. With assistance from Lee Hamel. + +iASL: Allow additional predefined names to return zero-length packages. +Now, all predefined names that are defined by the ACPI specification to +return a "variable-length package of packages" are allowed to return a +zero length top-level package. This allows the BIOS to tell the host that +the requested feature is not supported, and supports existing BIOS/ASL +code and practices. + +iASL: Changed the "result not used" warning to an error. This is the case +where an ASL operator is effectively a NOOP because the result of the +operation is not stored anywhere. For example: + Add (4, Local0) +There is no target (missing 3rd argument), nor is the function return +value used. This is potentially a very serious problem -- since the code +was probably intended to do something, but for whatever reason, the value +was not stored. Therefore, this issue has been upgraded from a warning to +an error. + +AcpiHelp: Added allowable/required argument types to the predefined names +info display. This feature utilizes the recent update to the predefined +names table (above). + +---------------------------------------- 14 February 2013. Summary of changes for version 20130214: 1) ACPICA Kernel-resident Subsystem: Modified: head/sys/contrib/dev/acpica/common/ahpredef.c ============================================================================== --- head/sys/contrib/dev/acpica/common/ahpredef.c Thu Apr 4 21:34:22 2013 (r249111) +++ head/sys/contrib/dev/acpica/common/ahpredef.c Thu Apr 4 22:11:30 2013 (r249112) @@ -61,7 +61,7 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] = { AH_PREDEF ("_ACx", "Active Cooling", "Returns the active cooling policy threshold values"), - AH_PREDEF ("_ADR", "Address", "Returns the address of a device on its parent bus"), + AH_PREDEF ("_ADR", "Address", "Returns address of a device on parent bus, and resource field"), AH_PREDEF ("_AEI", "ACPI Event Interrupts", "Returns a list of GPIO events to be used as ACPI events"), AH_PREDEF ("_ALC", "Ambient Light Chromaticity", "Returns the ambient light color chromaticity"), AH_PREDEF ("_ALI", "Ambient Light Illuminance", "Returns the ambient light brightness"), @@ -113,7 +113,7 @@ const AH_PREDEFINED_NAME AslPredefine AH_PREDEF ("_DGS", "Display Graphics State", "Return the current state of the output device"), AH_PREDEF ("_DIS", "Disable Device", "Disables a device"), AH_PREDEF ("_DLM", "Device Lock Mutex", "Defines mutex for OS/AML sharing"), - AH_PREDEF ("_DMA", "Direct Memory Access", "Returns a device's current resources for DMA transactions"), + AH_PREDEF ("_DMA", "Direct Memory Access", "Returns device current resources for DMA transactions, and resource field"), AH_PREDEF ("_DOD", "Display Output Devices", "Enumerate all devices attached to the display adapter"), AH_PREDEF ("_DOS", "Disable Output Switching", "Sets the display output switching mode"), AH_PREDEF ("_DPL", "Device Selection Polarity", "Polarity of Device Selection signal, Resource Descriptor field"), Modified: head/sys/contrib/dev/acpica/compiler/aslcompile.c ============================================================================== --- head/sys/contrib/dev/acpica/compiler/aslcompile.c Thu Apr 4 21:34:22 2013 (r249111) +++ head/sys/contrib/dev/acpica/compiler/aslcompile.c Thu Apr 4 22:11:30 2013 (r249112) @@ -126,6 +126,7 @@ AslCompilerSignon ( break; case ASL_FILE_C_SOURCE_OUTPUT: + case ASL_FILE_C_OFFSET_OUTPUT: case ASL_FILE_C_INCLUDE_OUTPUT: Prefix = " * "; @@ -199,6 +200,7 @@ AslCompilerFileHeader ( break; case ASL_FILE_C_SOURCE_OUTPUT: + case ASL_FILE_C_OFFSET_OUTPUT: case ASL_FILE_C_INCLUDE_OUTPUT: Prefix = " * "; @@ -222,6 +224,7 @@ AslCompilerFileHeader ( switch (FileId) { case ASL_FILE_C_SOURCE_OUTPUT: + case ASL_FILE_C_OFFSET_OUTPUT: case ASL_FILE_C_INCLUDE_OUTPUT: FlPrintFile (FileId, " */\n"); break; Modified: head/sys/contrib/dev/acpica/compiler/aslcompiler.h ============================================================================== --- head/sys/contrib/dev/acpica/compiler/aslcompiler.h Thu Apr 4 21:34:22 2013 (r249111) +++ head/sys/contrib/dev/acpica/compiler/aslcompiler.h Thu Apr 4 22:11:30 2013 (r249112) @@ -350,22 +350,65 @@ LsDoListings ( void); void +LsWriteNodeToAsmListing ( + ACPI_PARSE_OBJECT *Op); + +void +LsWriteNode ( + ACPI_PARSE_OBJECT *Op, + UINT32 FileId); + +void +LsDumpParseTree ( + void); + + +/* + * asllistsup - Listing file support utilities + */ +void +LsDumpAscii ( + UINT32 FileId, + UINT32 Count, + UINT8 *Buffer); + +void LsDumpAsciiInComment ( UINT32 FileId, UINT32 Count, UINT8 *Buffer); void -LsWriteNodeToAsmListing ( - ACPI_PARSE_OBJECT *Op); +LsCheckException ( + UINT32 LineNumber, + UINT32 FileId); void -LsWriteNode ( - ACPI_PARSE_OBJECT *Op, +LsFlushListingBuffer ( UINT32 FileId); void -LsDumpParseTree ( +LsWriteListingHexBytes ( + UINT8 *Buffer, + UINT32 Length, + UINT32 FileId); + +void +LsWriteSourceLines ( + UINT32 ToLineNumber, + UINT32 ToLogicalLineNumber, + UINT32 FileId); + +UINT32 +LsWriteOneSourceLine ( + UINT32 FileId); + +void +LsPushNode ( + char *Filename); + +ASL_LISTING_NODE * +LsPopNode ( void); @@ -388,6 +431,24 @@ OpcAmlConstantWalk ( /* + * asloffset - generate C offset file for BIOS support + */ +ACPI_STATUS +LsAmlOffsetWalk ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +void +LsDoOffsetTableHeader ( + UINT32 FileId); + +void +LsDoOffsetTableFooter ( + UINT32 FileId); + + +/* * aslopcodes - generate AML opcodes */ ACPI_STATUS Modified: head/sys/contrib/dev/acpica/compiler/asldefine.h ============================================================================== --- head/sys/contrib/dev/acpica/compiler/asldefine.h Thu Apr 4 21:34:22 2013 (r249111) +++ head/sys/contrib/dev/acpica/compiler/asldefine.h Thu Apr 4 22:11:30 2013 (r249112) @@ -120,6 +120,7 @@ #define FILE_SUFFIX_ASM_INCLUDE "inc" #define FILE_SUFFIX_C_INCLUDE "h" #define FILE_SUFFIX_ASL_CODE "asl" +#define FILE_SUFFIX_C_OFFSET "offset.h" /* Types for input files */ @@ -138,6 +139,11 @@ #define ASL_EOF ACPI_UINT32_MAX +/* Listings */ + +#define ASL_LISTING_LINE_PREFIX ": " + + /* Support for reserved method names */ #define ACPI_VALID_RESERVED_NAME_MAX 0x80000000 Modified: head/sys/contrib/dev/acpica/compiler/aslerror.c ============================================================================== --- head/sys/contrib/dev/acpica/compiler/aslerror.c Thu Apr 4 21:34:22 2013 (r249111) +++ head/sys/contrib/dev/acpica/compiler/aslerror.c Thu Apr 4 22:11:30 2013 (r249112) @@ -302,12 +302,25 @@ AePrintException ( } else { - while (RActual && SourceByte && (SourceByte != '\n') && (Total < 256)) + /* Read/write the source line, up to the maximum line length */ + + while (RActual && SourceByte && (SourceByte != '\n')) { - if (fwrite (&SourceByte, 1, 1, OutputFile) != 1) + if (Total < 256) { - printf ("[*** iASL: Write error on output file ***]\n"); - return; + /* After the max line length, we will just read the line, no write */ + + if (fwrite (&SourceByte, 1, 1, OutputFile) != 1) + { + printf ("[*** iASL: Write error on output file ***]\n"); + return; + } + } + else if (Total == 256) + { + fprintf (OutputFile, + "\n[*** iASL: Very long input line, message below refers to column %u ***]", + Enode->Column); } RActual = fread (&SourceByte, 1, 1, SourceFile); @@ -320,13 +333,6 @@ AePrintException ( } Total++; } - - if (Total >= 256) - { - fprintf (OutputFile, - "\n[*** iASL: Long input line, an error occurred at column %u ***]", - Enode->Column); - } } } } Modified: head/sys/contrib/dev/acpica/compiler/aslfiles.c ============================================================================== --- head/sys/contrib/dev/acpica/compiler/aslfiles.c Thu Apr 4 21:34:22 2013 (r249111) +++ head/sys/contrib/dev/acpica/compiler/aslfiles.c Thu Apr 4 22:11:30 2013 (r249112) @@ -675,6 +675,27 @@ FlOpenMiscOutputFiles ( AslCompilerFileHeader (ASL_FILE_C_SOURCE_OUTPUT); } + /* Create/Open a C code source output file for the offset table if asked */ + + if (Gbl_C_OffsetTableFlag) + { + Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_OFFSET); + if (!Filename) + { + AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, + 0, 0, 0, 0, NULL, NULL); + return (AE_ERROR); + } + + /* Open the C code source file, text mode */ + + FlOpenFile (ASL_FILE_C_OFFSET_OUTPUT, Filename, "w+t"); + + FlPrintFile (ASL_FILE_C_OFFSET_OUTPUT, "/*\n"); + AslCompilerSignon (ASL_FILE_C_OFFSET_OUTPUT); + AslCompilerFileHeader (ASL_FILE_C_OFFSET_OUTPUT); + } + /* Create/Open a assembly include output file if asked */ if (Gbl_AsmIncludeOutputFlag) Modified: head/sys/contrib/dev/acpica/compiler/aslglobal.h ============================================================================== --- head/sys/contrib/dev/acpica/compiler/aslglobal.h Thu Apr 4 21:34:22 2013 (r249111) +++ head/sys/contrib/dev/acpica/compiler/aslglobal.h Thu Apr 4 22:11:30 2013 (r249112) @@ -86,7 +86,8 @@ ASL_FILE_INFO Gbl_ {NULL, NULL, "ASM Source: ", "Assembly Code Output"}, {NULL, NULL, "C Source: ", "C Code Output"}, {NULL, NULL, "ASM Include: ", "Assembly Header Output"}, - {NULL, NULL, "C Include: ", "C Header Output"} + {NULL, NULL, "C Include: ", "C Header Output"}, + {NULL, NULL, "Offset Table: ", "C Offset Table Output"} }; #else @@ -143,6 +144,7 @@ ASL_EXTERN BOOLEAN ASL_ ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DebugFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_AsmOutputFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_C_OutputFlag, FALSE); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_C_OffsetTableFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_AsmIncludeOutputFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_C_IncludeOutputFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_ListingFlag, FALSE); Modified: head/sys/contrib/dev/acpica/compiler/asllisting.c ============================================================================== --- head/sys/contrib/dev/acpica/compiler/asllisting.c Thu Apr 4 21:34:22 2013 (r249111) +++ head/sys/contrib/dev/acpica/compiler/asllisting.c Thu Apr 4 22:11:30 2013 (r249112) @@ -41,896 +41,234 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include "aslcompiler.y.h" #include #include #include -#define _COMPONENT ACPI_COMPILER - ACPI_MODULE_NAME ("aslisting") - -/* Local prototypes */ - -static void -LsDumpAscii ( - UINT32 FileId, - UINT32 Count, - UINT8 *Buffer); - -static ACPI_STATUS -LsAmlListingWalk ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context); - -static void -LsGenerateListing ( - UINT32 FileId); - -static void -LsPushNode ( - char *Filename); - -static ASL_LISTING_NODE * -LsPopNode ( - void); - -static void -LsCheckException ( - UINT32 LineNumber, - UINT32 FileId); - -static void -LsFlushListingBuffer ( - UINT32 FileId); - -static void -LsWriteListingHexBytes ( - UINT8 *Buffer, - UINT32 Length, - UINT32 FileId); - -static UINT32 -LsWriteOneSourceLine ( - UINT32 FileId); - -static void -LsFinishSourceListing ( - UINT32 FileId); - -static void -LsWriteSourceLines ( - UINT32 ToLineNumber, - UINT32 ToLogicalLineNumber, - UINT32 FileId); - -static void -LsWriteNodeToListing ( - ACPI_PARSE_OBJECT *Op, - UINT32 FileId); - -static ACPI_STATUS -LsTreeWriteWalk ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context); - -#define ASL_LISTING_LINE_PREFIX ": " - - -/******************************************************************************* - * - * 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: LsTreeWriteWalk - * - * PARAMETERS: ASL_WALK_CALLBACK - * - * - * RETURN: None - * - * DESCRIPTION: Dump entire parse tree, for compiler debug only - * - ******************************************************************************/ - -static ACPI_STATUS -LsTreeWriteWalk ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context) -{ - - /* Debug output */ - - DbgPrint (ASL_TREE_OUTPUT, - "%5.5d [%2d]", Op->Asl.LogicalLineNumber, Level); - UtPrintFormattedName (Op->Asl.ParseOpcode, Level); - - - DbgPrint (ASL_TREE_OUTPUT, "\n"); - return (AE_OK); -} - - -void -LsDumpParseTree ( - void) -{ - - if (!Gbl_DebugFlag) - { - return; - } - - DbgPrint (ASL_TREE_OUTPUT, "\nOriginal parse tree from parser:\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, - LsTreeWriteWalk, NULL, NULL); -} - - -/******************************************************************************* - * - * FUNCTION: LsDumpAscii - * - * PARAMETERS: FileId - ID of current listing file - * Count - Number of bytes to convert - * Buffer - Buffer of bytes to convert - * - * RETURN: None - * - * DESCRIPTION: Convert hex bytes to ascii - * - ******************************************************************************/ - -static void -LsDumpAscii ( - UINT32 FileId, - UINT32 Count, - UINT8 *Buffer) -{ - UINT8 BufChar; - UINT32 i; - - - FlPrintFile (FileId, " \""); - for (i = 0; i < Count; i++) - { - BufChar = Buffer[i]; - if (isprint (BufChar)) - { - FlPrintFile (FileId, "%c", BufChar); - } - else - { - /* Not a printable character, just put out a dot */ - - FlPrintFile (FileId, "."); - } - } - FlPrintFile (FileId, "\""); -} - - -/******************************************************************************* - * - * FUNCTION: LsDumpAsciiInComment - * - * PARAMETERS: FileId - ID of current listing file - * Count - Number of bytes to convert - * Buffer - Buffer of bytes to convert - * - * RETURN: None - * - * DESCRIPTION: Convert hex bytes to ascii - * - ******************************************************************************/ - -void -LsDumpAsciiInComment ( - UINT32 FileId, - UINT32 Count, - UINT8 *Buffer) -{ - UINT8 BufChar = 0; - UINT8 LastChar; - UINT32 i; - - FlPrintFile (FileId, " \""); - for (i = 0; i < Count; i++) - { - LastChar = BufChar; - BufChar = Buffer[i]; - - if (isprint (BufChar)) - { - /* Handle embedded C comment sequences */ - - if (((LastChar == '*') && (BufChar == '/')) || - ((LastChar == '/') && (BufChar == '*'))) - { - /* Insert a space to break the sequence */ - - FlPrintFile (FileId, ".", BufChar); - } - - FlPrintFile (FileId, "%c", BufChar); - } - else - { - /* Not a printable character, just put out a dot */ - - FlPrintFile (FileId, "."); - } - } - FlPrintFile (FileId, "\""); -} - - -/******************************************************************************* - * - * FUNCTION: LsAmlListingWalk - * - * PARAMETERS: ASL_WALK_CALLBACK - * - * RETURN: Status - * - * DESCRIPTION: Process one node during a listing file generation. - * - ******************************************************************************/ - -static ACPI_STATUS -LsAmlListingWalk ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context) -{ - UINT8 FileByte; - UINT32 i; - UINT32 FileId = (UINT32) ACPI_TO_INTEGER (Context); - - - LsWriteNodeToListing (Op, FileId); - - if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DATA) - { - /* Buffer is a resource template, don't dump the data all at once */ - - return (AE_OK); - } - - /* Write the hex bytes to the listing file(s) (if requested) */ - - for (i = 0; i < Op->Asl.FinalAmlLength; i++) - { - if (ACPI_FAILURE (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1))) - { - FlFileError (ASL_FILE_AML_OUTPUT, ASL_MSG_READ); - AslAbort (); - } - LsWriteListingHexBytes (&FileByte, 1, FileId); - } - - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: LsGenerateListing - * - * PARAMETERS: FileId - ID of listing file - * - * RETURN: None - * - * DESCRIPTION: Generate a listing file. This can be one of the several types - * of "listings" supported. - * - ******************************************************************************/ - -static void -LsGenerateListing ( - UINT32 FileId) -{ - - /* Start at the beginning of both the source and AML files */ - - FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0); - FlSeekFile (ASL_FILE_AML_OUTPUT, 0); - Gbl_SourceLine = 0; - Gbl_CurrentHexColumn = 0; - LsPushNode (Gbl_Files[ASL_FILE_INPUT].Filename); - - /* Process all parse nodes */ - - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, LsAmlListingWalk, - NULL, (void *) ACPI_TO_POINTER (FileId)); - - /* Final processing */ - - LsFinishSourceListing (FileId); -} - - -/******************************************************************************* - * - * FUNCTION: LsPushNode - * - * PARAMETERS: Filename - Pointer to the include filename - * - * RETURN: None - * - * DESCRIPTION: Push a listing node on the listing/include file stack. This - * stack enables tracking of include files (infinitely nested) - * and resumption of the listing of the parent file when the - * include file is finished. - * - ******************************************************************************/ - -static void -LsPushNode ( - char *Filename) -{ - ASL_LISTING_NODE *Lnode; - - - /* Create a new node */ - - Lnode = UtLocalCalloc (sizeof (ASL_LISTING_NODE)); - - /* Initialize */ - - Lnode->Filename = Filename; - Lnode->LineNumber = 0; - - /* Link (push) */ - - Lnode->Next = Gbl_ListingNode; - Gbl_ListingNode = Lnode; -} - - -/******************************************************************************* - * - * FUNCTION: LsPopNode - * - * PARAMETERS: None - * - * RETURN: List head after current head is popped off - * - * DESCRIPTION: Pop the current head of the list, free it, and return the - * next node on the stack (the new current node). - * - ******************************************************************************/ - -static ASL_LISTING_NODE * -LsPopNode ( - void) -{ - ASL_LISTING_NODE *Lnode; - - - /* Just grab the node at the head of the list */ - - Lnode = Gbl_ListingNode; - if ((!Lnode) || - (!Lnode->Next)) - { - AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, NULL, - "Could not pop empty listing stack"); - return (Gbl_ListingNode); - } - - Gbl_ListingNode = Lnode->Next; - ACPI_FREE (Lnode); - - /* New "Current" node is the new head */ - - return (Gbl_ListingNode); -} - - -/******************************************************************************* - * - * FUNCTION: LsCheckException - * - * PARAMETERS: LineNumber - Current logical (cumulative) line # - * FileId - ID of output listing file - * - * RETURN: None - * - * DESCRIPTION: Check if there is an exception for this line, and if there is, - * put it in the listing immediately. Handles multiple errors - * per line. Gbl_NextError points to the next error in the - * sorted (by line #) list of compile errors/warnings. - * - ******************************************************************************/ - -static void -LsCheckException ( - UINT32 LineNumber, - UINT32 FileId) -{ - - if ((!Gbl_NextError) || - (LineNumber < Gbl_NextError->LogicalLineNumber )) - { - return; - } - - /* Handle multiple errors per line */ - - if (FileId == ASL_FILE_LISTING_OUTPUT) - { - while (Gbl_NextError && - (LineNumber >= Gbl_NextError->LogicalLineNumber)) - { - AePrintException (FileId, Gbl_NextError, "\n[****iasl****]\n"); - - Gbl_NextError = Gbl_NextError->Next; - } - - FlPrintFile (FileId, "\n"); - } -} - - -/******************************************************************************* - * - * FUNCTION: LsFlushListingBuffer - * - * PARAMETERS: FileId - ID of the listing file - * - * RETURN: None - * - * DESCRIPTION: Flush out the current contents of the 16-byte hex AML code - * buffer. Usually called at the termination of a single line - * of source code or when the buffer is full. - * - ******************************************************************************/ - -static void -LsFlushListingBuffer ( - UINT32 FileId) -{ - UINT32 i; - - - if (Gbl_CurrentHexColumn == 0) - { - return; - } - - /* Write the hex bytes */ - - switch (FileId) - { - case ASL_FILE_LISTING_OUTPUT: - - for (i = 0; i < Gbl_CurrentHexColumn; i++) - { - FlPrintFile (FileId, "%2.2X ", Gbl_AmlBuffer[i]); - } - - for (i = 0; i < ((HEX_LISTING_LINE_SIZE - Gbl_CurrentHexColumn) * 3); i++) - { - FlWriteFile (FileId, ".", 1); - } - - /* Write the ASCII character associated with each of the bytes */ - - LsDumpAscii (FileId, Gbl_CurrentHexColumn, Gbl_AmlBuffer); - break; - - - case ASL_FILE_ASM_SOURCE_OUTPUT: - - for (i = 0; i < Gbl_CurrentHexColumn; i++) - { - if (i > 0) - { - FlPrintFile (FileId, ","); - } - FlPrintFile (FileId, "0%2.2Xh", Gbl_AmlBuffer[i]); - } - - for (i = 0; i < ((HEX_LISTING_LINE_SIZE - Gbl_CurrentHexColumn) * 5); i++) - { - FlWriteFile (FileId, " ", 1); - } - - FlPrintFile (FileId, " ;%8.8X", - Gbl_CurrentAmlOffset - HEX_LISTING_LINE_SIZE); - - /* Write the ASCII character associated with each of the bytes */ - - LsDumpAscii (FileId, Gbl_CurrentHexColumn, Gbl_AmlBuffer); - break; - - - case ASL_FILE_C_SOURCE_OUTPUT: - - for (i = 0; i < Gbl_CurrentHexColumn; i++) - { - FlPrintFile (FileId, "0x%2.2X,", Gbl_AmlBuffer[i]); - } - - for (i = 0; i < ((HEX_LISTING_LINE_SIZE - Gbl_CurrentHexColumn) * 5); i++) - { - FlWriteFile (FileId, " ", 1); - } - - FlPrintFile (FileId, " /* %8.8X", - Gbl_CurrentAmlOffset - HEX_LISTING_LINE_SIZE); - - /* Write the ASCII character associated with each of the bytes */ - - LsDumpAsciiInComment (FileId, Gbl_CurrentHexColumn, Gbl_AmlBuffer); - FlPrintFile (FileId, " */"); - break; - - default: - /* No other types supported */ - return; - } - - FlPrintFile (FileId, "\n"); - - Gbl_CurrentHexColumn = 0; - Gbl_HexBytesWereWritten = TRUE; -} +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("asllisting") -/******************************************************************************* - * - * FUNCTION: LsWriteListingHexBytes - * - * PARAMETERS: Buffer - AML code buffer - * Length - Number of AML bytes to write - * FileId - ID of current listing file. - * - * RETURN: None - * - * DESCRIPTION: Write the contents of the AML buffer to the listing file via - * the listing buffer. The listing buffer is flushed every 16 - * AML bytes. - * - ******************************************************************************/ +/* Local prototypes */ static void -LsWriteListingHexBytes ( - UINT8 *Buffer, - UINT32 Length, - UINT32 FileId) -{ - UINT32 i; - - - /* Transfer all requested bytes */ - - for (i = 0; i < Length; i++) - { - /* Print line header when buffer is empty */ - - if (Gbl_CurrentHexColumn == 0) - { - if (Gbl_HasIncludeFiles) - { - FlPrintFile (FileId, "%*s", 10, " "); - } - - switch (FileId) - { - case ASL_FILE_LISTING_OUTPUT: - - FlPrintFile (FileId, "%8.8X%s", Gbl_CurrentAmlOffset, - ASL_LISTING_LINE_PREFIX); - break; - - case ASL_FILE_ASM_SOURCE_OUTPUT: - - FlPrintFile (FileId, " db "); - break; - - case ASL_FILE_C_SOURCE_OUTPUT: - *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***