Author: jkim
Date: Wed Sep 19 23:25:24 2012
New Revision: 240716
URL: http://svn.freebsd.org/changeset/base/240716

Log:
  Merge ACPICA 20120913.

Modified:
  head/sys/contrib/dev/acpica/changes.txt   (contents, props changed)
  head/sys/contrib/dev/acpica/common/dmrestag.c
  head/sys/contrib/dev/acpica/compiler/aslcompile.c
  head/sys/contrib/dev/acpica/compiler/aslcompiler.h
  head/sys/contrib/dev/acpica/compiler/aslerror.c
  head/sys/contrib/dev/acpica/compiler/aslfiles.c
  head/sys/contrib/dev/acpica/compiler/aslfold.c
  head/sys/contrib/dev/acpica/compiler/aslglobal.h
  head/sys/contrib/dev/acpica/compiler/aslmain.c
  head/sys/contrib/dev/acpica/compiler/aslmessages.h
  head/sys/contrib/dev/acpica/compiler/asloperands.c
  head/sys/contrib/dev/acpica/compiler/aslopt.c
  head/sys/contrib/dev/acpica/compiler/aslstartup.c
  head/sys/contrib/dev/acpica/compiler/aslsupport.l
  head/sys/contrib/dev/acpica/compiler/asltypes.h
  head/sys/contrib/dev/acpica/compiler/aslutils.c
  head/sys/contrib/dev/acpica/compiler/dtio.c
  head/sys/contrib/dev/acpica/compiler/preprocess.h
  head/sys/contrib/dev/acpica/components/debugger/dbexec.c
  head/sys/contrib/dev/acpica/components/debugger/dbinput.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/debugger/dbstats.c
  head/sys/contrib/dev/acpica/components/debugger/dbutils.c
  head/sys/contrib/dev/acpica/components/disassembler/dmopcode.c
  head/sys/contrib/dev/acpica/components/tables/tbinstal.c
  head/sys/contrib/dev/acpica/components/tables/tbxface.c
  head/sys/contrib/dev/acpica/include/acdebug.h
  head/sys/contrib/dev/acpica/include/acpixf.h
  head/sys/contrib/dev/acpica/include/actbl1.h
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/disassembler/   (props changed)
  head/sys/contrib/dev/acpica/components/tables/   (props changed)
  head/sys/contrib/dev/acpica/include/   (props changed)

Modified: head/sys/contrib/dev/acpica/changes.txt
==============================================================================
--- head/sys/contrib/dev/acpica/changes.txt     Wed Sep 19 23:03:54 2012        
(r240715)
+++ head/sys/contrib/dev/acpica/changes.txt     Wed Sep 19 23:25:24 2012        
(r240716)
@@ -1,4 +1,75 @@
 ----------------------------------------
+13 September 2012. Summary of changes for version 20120913:
+
+This release is available at https://www.acpica.org/downloads The ACPI 5.0 
+specification is available at www.acpi.info
+
+1) ACPICA Kernel-resident Subsystem:
+
+ACPI 5.0: Added two new notify types for the Hardware Error Notification 
+Structure within the Hardware Error Source Table (HEST) table -- CMCI(5) and 
+MCE(6).
+ 
+Table Manager: Merged/removed duplicate code in the root table resize 
+functions. One function is external, the other is internal. Lv Zheng, ACPICA 
+BZ 846.
+
+Makefiles: Completely removed the obsolete "Linux" makefiles under 
+acpica/generate/linux. These makefiles are obsolete and have been replaced by 
+the generic unix makefiles under acpica/generate/unix.
+
+Makefiles: Ensure that binary files always copied properly. Minor rule change 
+to ensure that the final binary output files are always copied up to the 
+appropriate binary directory (bin32 or bin64.)
+
+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:  93.8K Code, 25.3K Data, 119.1K Total
+    Debug Version:     175.7K Code, 74.8K Data, 250.5K Total
+  Current Release:
+    Non-Debug Version:  93.7K Code, 25.3K Data, 119.0K Total
+    Debug Version:     175.0K Code, 74.4K Data, 249.4K Total
+
+
+2) iASL Compiler/Disassembler and Tools:
+
+Disassembler: Fixed a possible fault during the disassembly of resource 
+descriptors when a second parse is required because of the invocation of 
+external control methods within the table. With assistance from 
+a...@lidskialf.net. ACPICA BZ 976.
+
+iASL: Fixed a namepath optimization problem. An error can occur if the parse 
+node that contains the namepath to be optimized does not have a parent node 
+that is a named object. This change fixes the problem.
+
+iASL: Fixed a regression where the AML file is not deleted on errors. The AML 
+output file should be deleted if there are any errors during the compiler. The 
+only exception is if the -f (force output) option is used. ACPICA BZ 974.
+
+iASL: Added a feature to automatically increase internal line buffer sizes. 
+Via realloc(), automatically increase the internal line buffer sizes as 
+necessary to support very long source code lines. The current version of the 
+preprocessor requires a buffer long enough to contain full source code lines. 
+This change increases the line buffer(s) if the input lines go beyond the 
+current buffer size. This eliminates errors that occurred when a source code 
+line was longer than the buffer.
+
+iASL: Fixed a problem with constant folding in method declarations. The 
+SyncLevel term is a ByteConstExpr, and incorrect code would be generated if a 
+Type3 opcode was used.
+
+Debugger: Improved command help support. For incorrect argument count, display 
+full help for the command. For help command itself, allow an argument to 
+specify a command.
+
+Test Suites: Several bug fixes for the ASLTS suite reduces the number of 
+errors during execution of the suite. Guan Chao.
+
+----------------------------------------
 16 August 2012. Summary of changes for version 20120816:
 
 This release is available at https://www.acpica.org/downloads

Modified: head/sys/contrib/dev/acpica/common/dmrestag.c
==============================================================================
--- head/sys/contrib/dev/acpica/common/dmrestag.c       Wed Sep 19 23:03:54 
2012        (r240715)
+++ head/sys/contrib/dev/acpica/common/dmrestag.c       Wed Sep 19 23:25:24 
2012        (r240716)
@@ -469,6 +469,11 @@ AcpiDmCheckResourceReference (
     /* Get the Index term, must be an integer constant to convert */
 
     IndexOp = BufferNameOp->Common.Next;
+
+    /* Major cheat: The Node field is also used for the Tag ptr. Clear it now 
*/
+
+    IndexOp->Common.Node = NULL;
+
     OpInfo = AcpiPsGetOpcodeInfo (IndexOp->Common.AmlOpcode);
     if (OpInfo->ObjectType != ACPI_TYPE_INTEGER)
     {

Modified: head/sys/contrib/dev/acpica/compiler/aslcompile.c
==============================================================================
--- head/sys/contrib/dev/acpica/compiler/aslcompile.c   Wed Sep 19 23:03:54 
2012        (r240715)
+++ head/sys/contrib/dev/acpica/compiler/aslcompile.c   Wed Sep 19 23:25:24 
2012        (r240716)
@@ -800,6 +800,7 @@ CmCleanupAndExit (
     void)
 {
     UINT32                  i;
+    BOOLEAN                 DeleteAmlFile = FALSE;
 
 
     AePrintErrorLog (ASL_FILE_STDERR);
@@ -851,6 +852,16 @@ CmCleanupAndExit (
 
     UtDisplaySummary (ASL_FILE_STDOUT);
 
+    /*
+     * We will delete the AML file if there are errors and the
+     * force AML output option has not been used.
+     */
+    if ((Gbl_ExceptionCount[ASL_ERROR] > 0) && (!Gbl_IgnoreErrors) &&
+        Gbl_Files[ASL_FILE_AML_OUTPUT].Handle)
+    {
+        DeleteAmlFile = TRUE;
+    }
+
     /* Close all open files */
 
     Gbl_Files[ASL_FILE_PREPROCESSOR].Handle = NULL; /* the .i file is same as 
source file */
@@ -862,29 +873,17 @@ CmCleanupAndExit (
 
     /* Delete AML file if there are errors */
 
-    if ((Gbl_ExceptionCount[ASL_ERROR] > 0) && (!Gbl_IgnoreErrors) &&
-        Gbl_Files[ASL_FILE_AML_OUTPUT].Handle)
+    if (DeleteAmlFile)
     {
-        if (remove (Gbl_Files[ASL_FILE_AML_OUTPUT].Filename))
-        {
-            printf ("%s: ",
-                Gbl_Files[ASL_FILE_AML_OUTPUT].Filename);
-            perror ("Could not delete AML file");
-        }
+        FlDeleteFile (ASL_FILE_AML_OUTPUT);
     }
 
     /* Delete the preprocessor output file (.i) unless -li flag is set */
 
     if (!Gbl_PreprocessorOutputFlag &&
-        Gbl_PreprocessFlag &&
-        Gbl_Files[ASL_FILE_PREPROCESSOR].Filename)
+        Gbl_PreprocessFlag)
     {
-        if (remove (Gbl_Files[ASL_FILE_PREPROCESSOR].Filename))
-        {
-            printf ("%s: ",
-                Gbl_Files[ASL_FILE_PREPROCESSOR].Filename);
-            perror ("Could not delete preprocessor .i file");
-        }
+        FlDeleteFile (ASL_FILE_PREPROCESSOR);
     }
 
     /*
@@ -901,14 +900,9 @@ CmCleanupAndExit (
      *
      * TBD: SourceOutput should be .TMP, then rename if we want to keep it?
      */
-    if (!Gbl_SourceOutputFlag && Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename)
+    if (!Gbl_SourceOutputFlag)
     {
-        if (remove (Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename))
-        {
-            printf ("%s: ",
-                Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
-            perror ("Could not delete SRC file");
-        }
+        FlDeleteFile (ASL_FILE_SOURCE_OUTPUT);
     }
 }
 

Modified: head/sys/contrib/dev/acpica/compiler/aslcompiler.h
==============================================================================
--- head/sys/contrib/dev/acpica/compiler/aslcompiler.h  Wed Sep 19 23:03:54 
2012        (r240715)
+++ head/sys/contrib/dev/acpica/compiler/aslcompiler.h  Wed Sep 19 23:25:24 
2012        (r240716)
@@ -661,6 +661,10 @@ FlPrintFile (
     ...);
 
 void
+FlDeleteFile (
+    UINT32                  FileId);
+
+void
 FlSetLineNumber (
     UINT32                  LineNumber);
 
@@ -779,6 +783,10 @@ char *
 UtGetStringBuffer (
     UINT32                  Length);
 
+void
+UtExpandLineBuffers (
+    void);
+
 ACPI_STATUS
 UtInternalizeName (
     char                    *ExternalName,

Modified: head/sys/contrib/dev/acpica/compiler/aslerror.c
==============================================================================
--- head/sys/contrib/dev/acpica/compiler/aslerror.c     Wed Sep 19 23:03:54 
2012        (r240715)
+++ head/sys/contrib/dev/acpica/compiler/aslerror.c     Wed Sep 19 23:25:24 
2012        (r240716)
@@ -183,6 +183,7 @@ AePrintException (
     FILE                    *SourceFile = NULL;
     long                    FileSize;
     BOOLEAN                 PrematureEOF = FALSE;
+    UINT32                  Total = 0;
 
 
     if (Gbl_NoErrors)
@@ -300,11 +301,21 @@ AePrintException (
                                     "[*** iASL: Read error on source code temp 
file %s ***]",
                                     
Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);
                             }
-
-                            else while (RActual && SourceByte && (SourceByte 
!= '\n'))
+                            else
                             {
-                                fwrite (&SourceByte, 1, 1, OutputFile);
-                                RActual = fread (&SourceByte, 1, 1, 
SourceFile);
+                                while (RActual && SourceByte && (SourceByte != 
'\n') && (Total < 256))
+                                {
+                                    fwrite (&SourceByte, 1, 1, OutputFile);
+                                    RActual = fread (&SourceByte, 1, 1, 
SourceFile);
+                                    Total++;
+                                }
+
+                                if (Total >= 256)
+                                {
+                                    fprintf (OutputFile,
+                                        "\n[*** iASL: Long input line, an 
error occurred at column %u ***]",
+                                        Enode->Column);
+                                }
                             }
                         }
                     }
@@ -381,20 +392,28 @@ AePrintException (
 
             if (Gbl_VerboseErrors && !PrematureEOF)
             {
-                SourceColumn = Enode->Column + Enode->FilenameLength + 6 + 2;
-                ErrorColumn = ASL_ERROR_LEVEL_LENGTH + 5 + 2 + 1;
-
-                if ((MsgLength + ErrorColumn) < (SourceColumn - 1))
+                if (Total >= 256)
                 {
-                    fprintf (OutputFile, "%*s%s",
-                        (int) ((SourceColumn - 1) - ErrorColumn),
-                        MainMessage, " ^ ");
+                    fprintf (OutputFile, "    %s",
+                        MainMessage);
                 }
                 else
                 {
-                    fprintf (OutputFile, "%*s %s",
-                        (int) ((SourceColumn - ErrorColumn) + 1), "^",
-                        MainMessage);
+                    SourceColumn = Enode->Column + Enode->FilenameLength + 6 + 
2;
+                    ErrorColumn = ASL_ERROR_LEVEL_LENGTH + 5 + 2 + 1;
+
+                    if ((MsgLength + ErrorColumn) < (SourceColumn - 1))
+                    {
+                        fprintf (OutputFile, "%*s%s",
+                            (int) ((SourceColumn - 1) - ErrorColumn),
+                            MainMessage, " ^ ");
+                    }
+                    else
+                    {
+                        fprintf (OutputFile, "%*s %s",
+                            (int) ((SourceColumn - ErrorColumn) + 1), "^",
+                            MainMessage);
+                    }
                 }
             }
             else

Modified: head/sys/contrib/dev/acpica/compiler/aslfiles.c
==============================================================================
--- head/sys/contrib/dev/acpica/compiler/aslfiles.c     Wed Sep 19 23:03:54 
2012        (r240715)
+++ head/sys/contrib/dev/acpica/compiler/aslfiles.c     Wed Sep 19 23:25:24 
2012        (r240716)
@@ -63,6 +63,7 @@ FlParseInputPathname (
 #endif
 
 
+
 
/*******************************************************************************
  *
  * FUNCTION:    AslAbort
@@ -376,6 +377,42 @@ FlCloseFile (
 
 
/*******************************************************************************
  *
+ * 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

Modified: head/sys/contrib/dev/acpica/compiler/aslfold.c
==============================================================================
--- head/sys/contrib/dev/acpica/compiler/aslfold.c      Wed Sep 19 23:03:54 
2012        (r240715)
+++ head/sys/contrib/dev/acpica/compiler/aslfold.c      Wed Sep 19 23:25:24 
2012        (r240716)
@@ -200,6 +200,19 @@ OpcAmlCheckForConstant (
     DbgPrint (ASL_PARSE_OUTPUT, "[%.4d] Opcode: %12.12s ",
                 Op->Asl.LogicalLineNumber, Op->Asl.ParseOpName);
 
+    /*
+     * These opcodes do not appear in the OpcodeInfo table, but
+     * they represent constants, so abort the constant walk now.
+     */
+    if ((WalkState->Opcode == AML_RAW_DATA_BYTE) ||
+        (WalkState->Opcode == AML_RAW_DATA_WORD) ||
+        (WalkState->Opcode == AML_RAW_DATA_DWORD) ||
+        (WalkState->Opcode == AML_RAW_DATA_QWORD))
+    {
+        WalkState->WalkType = ACPI_WALK_CONST_OPTIONAL;
+        return (AE_TYPE);
+    }
+
     if (!(WalkState->OpInfo->Flags & AML_CONSTANT))
     {
         /* The opcode is not a Type 3/4/5 opcode */
@@ -254,8 +267,8 @@ OpcAmlCheckForConstant (
     {
         DbgPrint (ASL_PARSE_OUTPUT, " TERMARG");
     }
-    DbgPrint (ASL_PARSE_OUTPUT, "\n");
 
+    DbgPrint (ASL_PARSE_OUTPUT, "\n");
     return (AE_OK);
 }
 

Modified: head/sys/contrib/dev/acpica/compiler/aslglobal.h
==============================================================================
--- head/sys/contrib/dev/acpica/compiler/aslglobal.h    Wed Sep 19 23:03:54 
2012        (r240715)
+++ head/sys/contrib/dev/acpica/compiler/aslglobal.h    Wed Sep 19 23:25:24 
2012        (r240716)
@@ -63,6 +63,41 @@
 #endif
 
 
+#ifdef _DECLARE_GLOBALS
+UINT32                              Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS] 
= {0,0,0,0,0,0};
+char                                AslHexLookup[] =
+{
+    '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
+};
+
+
+/* Table below must match ASL_FILE_TYPES in asltypes.h */
+
+ASL_FILE_INFO                       Gbl_Files [ASL_NUM_FILES] =
+{
+    {NULL, NULL, "stdout:       ", "Standard Output"},
+    {NULL, NULL, "stderr:       ", "Standard Error"},
+    {NULL, NULL, "Table Input:  ", "Source Input"},
+    {NULL, NULL, "Binary Output:", "AML Output"},
+    {NULL, NULL, "Source Output:", "Source Output"},
+    {NULL, NULL, "Preprocessor: ", "Preprocessor Output"},
+    {NULL, NULL, "Listing File: ", "Listing Output"},
+    {NULL, NULL, "Hex Dump:     ", "Hex Table Output"},
+    {NULL, NULL, "Namespace:    ", "Namespace Output"},
+    {NULL, NULL, "Debug File:   ", "Debug Output"},
+    {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"}
+};
+
+#else
+extern UINT32                       Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS];
+extern char                         AslHexLookup[];
+extern ASL_FILE_INFO                Gbl_Files [ASL_NUM_FILES];
+#endif
+
+
 /*
  * Parser and other externals
  */
@@ -74,21 +109,22 @@ extern int                          PrPa
 extern const ASL_MAPPING_ENTRY      AslKeywordMapping[];
 extern char                         *AslCompilertext;
 
-#define ASL_LINE_BUFFER_SIZE        (4096 * 4) /* 16K */
-#define ASL_MSG_BUFFER_SIZE         4096
-#define HEX_TABLE_LINE_SIZE         8
-#define HEX_LISTING_LINE_SIZE       8
+#define ASL_DEFAULT_LINE_BUFFER_SIZE    (1024 * 32) /* 32K */
+#define ASL_MSG_BUFFER_SIZE             4096
+#define HEX_TABLE_LINE_SIZE             8
+#define HEX_LISTING_LINE_SIZE           8
 
 
 /* Source code buffers and pointers for error reporting */
 
-ASL_EXTERN char                     
Gbl_CurrentLineBuffer[ASL_LINE_BUFFER_SIZE];
+ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_CurrentLineBuffer, 
NULL);
+ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_LineBufPtr, NULL);
+ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_LineBufferSize, 
ASL_DEFAULT_LINE_BUFFER_SIZE);
 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_CurrentColumn, 0);
 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_PreviousLineNumber, 
0);
 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_CurrentLineNumber, 1);
 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_LogicalLineNumber, 1);
 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_CurrentLineOffset, 0);
-ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_LineBufPtr, 
Gbl_CurrentLineBuffer);
 
 /* Exception reporting */
 
@@ -135,18 +171,16 @@ ASL_EXTERN BOOLEAN                  ASL_
 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_CompileGeneric, 
FALSE);
 
 
-#define HEX_OUTPUT_NONE         0
-#define HEX_OUTPUT_C            1
-#define HEX_OUTPUT_ASM          2
-#define HEX_OUTPUT_ASL          3
+#define HEX_OUTPUT_NONE             0
+#define HEX_OUTPUT_C                1
+#define HEX_OUTPUT_ASM              2
+#define HEX_OUTPUT_ASL              3
 
 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_HexOutputFlag, 
HEX_OUTPUT_NONE);
 
 
 /* Files */
 
-ASL_EXTERN ASL_FILE_INFO            Gbl_Files [ASL_NUM_FILES];
-
 ASL_EXTERN char                     *Gbl_DirectoryPath;
 ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_IncludeFilename, 
NULL);
 ASL_EXTERN char                     ASL_INIT_GLOBAL 
(*Gbl_OutputFilenamePrefix, NULL);
@@ -203,7 +237,6 @@ ASL_EXTERN FILE                     *Acp
 
 ASL_EXTERN ASL_ANALYSIS_WALK_INFO   AnalysisWalkInfo;
 ASL_EXTERN ACPI_TABLE_HEADER        TableHeader;
-extern char                         AslHexLookup[];
 
 /* Event timing */
 
@@ -220,11 +253,5 @@ ASL_EXTERN char                     Stri
 ASL_EXTERN char                     StringBuffer2[ASL_MSG_BUFFER_SIZE];
 
 
-#ifdef _DECLARE_GLOBALS
-UINT32                              Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS] 
= {0,0,0,0,0,0};
-#else
-extern UINT32                       Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS];
-#endif
-
 #endif /* __ASLGLOBAL_H */
 

Modified: head/sys/contrib/dev/acpica/compiler/aslmain.c
==============================================================================
--- head/sys/contrib/dev/acpica/compiler/aslmain.c      Wed Sep 19 23:03:54 
2012        (r240715)
+++ head/sys/contrib/dev/acpica/compiler/aslmain.c      Wed Sep 19 23:25:24 
2012        (r240716)
@@ -48,6 +48,7 @@
 #include <contrib/dev/acpica/compiler/aslcompiler.h>
 #include <contrib/dev/acpica/include/acapps.h>
 #include <contrib/dev/acpica/include/acdisasm.h>
+#include <signal.h>
 
 #ifdef _DEBUG
 #include <crtdbg.h>
@@ -70,6 +71,10 @@ static void
 Usage (
     void);
 
+static void ACPI_SYSTEM_XFACE
+AslSignalHandler (
+    int                     Sig);
+
 static void
 AslInitialize (
     void);
@@ -96,7 +101,7 @@ AslDoResponseFile (
 
 
 #define ASL_TOKEN_SEPARATORS    " \t\n"
-#define ASL_SUPPORTED_OPTIONS   
"@:2b|c|d^D:e:fgh^i|I:l^mno|p:P^r:s|t|T:G^v^w|x:z"
+#define ASL_SUPPORTED_OPTIONS   
"@:2b|c|d^D:e:fgh^i|I:l^m:no|p:P^r:s|t|T:G^v^w|x:z"
 
 
 
/*******************************************************************************
@@ -163,10 +168,10 @@ Options (
     printf ("\nAML Disassembler:\n");
     ACPI_OPTION ("-d  [file]",      "Disassemble or decode binary ACPI table 
to file (*.dsl)");
     ACPI_OPTION ("-da [f1,f2]",     "Disassemble multiple tables from single 
namespace");
+    ACPI_OPTION ("-db",             "Do not translate Buffers to Resource 
Templates");
     ACPI_OPTION ("-dc [file]",      "Disassemble AML and immediately compile 
it");
     ACPI_OPTION ("",                "(Obtain DSDT from current system if no 
input file)");
     ACPI_OPTION ("-e  [f1,f2]",     "Include ACPI table(s) for external symbol 
resolution");
-    ACPI_OPTION ("-m",              "Do not translate Buffers to Resource 
Templates");
     ACPI_OPTION ("-2",              "Emit ACPI 2.0 compatible ASL code");
     ACPI_OPTION ("-g",              "Get ACPI tables and write to files 
(*.dat)");
 
@@ -238,6 +243,49 @@ Usage (
 }
 
 
+/******************************************************************************
+ *
+ * FUNCTION:    AslSignalHandler
+ *
+ * PARAMETERS:  Sig                 - Signal that invoked this handler
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Control-C handler. Delete any intermediate files and any
+ *              output files that may be left in an indeterminate state.
+ *
+ *****************************************************************************/
+
+static void ACPI_SYSTEM_XFACE
+AslSignalHandler (
+    int                     Sig)
+{
+    UINT32                  i;
+
+
+    signal (Sig, SIG_IGN);
+    printf ("Aborting\n\n");
+
+    /* Close all open files */
+
+    Gbl_Files[ASL_FILE_PREPROCESSOR].Handle = NULL; /* the .i file is same as 
source file */
+
+    for (i = ASL_FILE_INPUT; i < ASL_MAX_FILE_TYPE; i++)
+    {
+        FlCloseFile (i);
+    }
+
+    /* Delete any output files */
+
+    for (i = ASL_FILE_AML_OUTPUT; i < ASL_MAX_FILE_TYPE; i++)
+    {
+        FlDeleteFile (i);
+    }
+
+    exit (0);
+}
+
+
 
/*******************************************************************************
  *
  * FUNCTION:    AslInitialize
@@ -261,7 +309,6 @@ AslInitialize (
     _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CrtSetDbgFlag(0));
 #endif
 
-    AcpiDbgLevel = 0;
 
     for (i = 0; i < ASL_NUM_FILES; i++)
     {
@@ -274,6 +321,11 @@ AslInitialize (
 
     Gbl_Files[ASL_FILE_STDERR].Handle   = stderr;
     Gbl_Files[ASL_FILE_STDERR].Filename = "STDERR";
+
+    /* Allocate the line buffer(s) */
+
+    Gbl_LineBufferSize /= 2;
+    UtExpandLineBuffers ();
 }
 
 
@@ -475,6 +527,10 @@ AslDoOptions (
             Gbl_DisassembleAll = TRUE;
             break;
 
+        case 'b':   /* Do not convert buffers to resource descriptors */
+            AcpiGbl_NoResourceDisassembly = TRUE;
+            break;
+
         case 'c':
             break;
 
@@ -613,8 +669,13 @@ AslDoOptions (
         break;
 
 
-    case 'm':   /* Do not convert buffers to resource descriptors */
-        AcpiGbl_NoResourceDisassembly = TRUE;
+    case 'm':   /* Set line buffer size */
+        Gbl_LineBufferSize = (UINT32) strtoul (AcpiGbl_Optarg, NULL, 0) * 1024;
+        if (Gbl_LineBufferSize < ASL_DEFAULT_LINE_BUFFER_SIZE)
+        {
+            Gbl_LineBufferSize = ASL_DEFAULT_LINE_BUFFER_SIZE;
+        }
+        printf ("Line Buffer Size: %u\n", Gbl_LineBufferSize);
         break;
 
 
@@ -946,7 +1007,10 @@ main (
     int                     Index2;
 
 
+    signal (SIGINT, AslSignalHandler);
+
     AcpiGbl_ExternalFileList = NULL;
+    AcpiDbgLevel = 0;
 
 #ifdef _DEBUG
     _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF |
@@ -955,9 +1019,10 @@ main (
 
     /* Init and command line */
 
+    Index1 = Index2 = AslCommandLine (argc, argv);
+
     AslInitialize ();
     PrInitializePreprocessor ();
-    Index1 = Index2 = AslCommandLine (argc, argv);
 
     /* Options that have no additional parameters or pathnames */
 

Modified: head/sys/contrib/dev/acpica/compiler/aslmessages.h
==============================================================================
--- head/sys/contrib/dev/acpica/compiler/aslmessages.h  Wed Sep 19 23:03:54 
2012        (r240715)
+++ head/sys/contrib/dev/acpica/compiler/aslmessages.h  Wed Sep 19 23:25:24 
2012        (r240716)
@@ -198,6 +198,7 @@ typedef enum
     ASL_MSG_VENDOR_LIST,
     ASL_MSG_WRITE,
     ASL_MSG_RANGE,
+    ASL_MSG_BUFFER_ALLOCATION,
 
     /* These messages are used by the Preprocessor only */
 
@@ -373,6 +374,7 @@ char                        *AslMessages
 /*    ASL_MSG_VENDOR_LIST */                "Too many vendor data bytes (7 
max)",
 /*    ASL_MSG_WRITE */                      "Could not write file",
 /*    ASL_MSG_RANGE */                      "Constant out of range",
+/*    ASL_MSG_BUFFER_ALLOCATION */          "Could not allocate line buffer",
 
 /* Preprocessor */
 

Modified: head/sys/contrib/dev/acpica/compiler/asloperands.c
==============================================================================
--- head/sys/contrib/dev/acpica/compiler/asloperands.c  Wed Sep 19 23:03:54 
2012        (r240715)
+++ head/sys/contrib/dev/acpica/compiler/asloperands.c  Wed Sep 19 23:25:24 
2012        (r240716)
@@ -182,6 +182,10 @@ OpnDoMethod (
     Next = Next->Asl.Next;
     if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
     {
+        /* This is a ByteConstExpr, so eval the constant now */
+
+        OpcAmlConstantWalk (Next, 0, NULL);
+
         if (Next->Asl.Value.Integer > 15)
         {
             AslError (ASL_ERROR, ASL_MSG_SYNC_LEVEL, Next, NULL);

Modified: head/sys/contrib/dev/acpica/compiler/aslopt.c
==============================================================================
--- head/sys/contrib/dev/acpica/compiler/aslopt.c       Wed Sep 19 23:03:54 
2012        (r240715)
+++ head/sys/contrib/dev/acpica/compiler/aslopt.c       Wed Sep 19 23:25:24 
2012        (r240716)
@@ -441,7 +441,6 @@ OptOptimizeNameDeclaration (
 {
     ACPI_STATUS             Status;
     char                    *NewPathExternal;
-    ACPI_GENERIC_STATE      ScopeInfo;
     ACPI_NAMESPACE_NODE     *Node;
 
 
@@ -473,9 +472,10 @@ OptOptimizeNameDeclaration (
          * Check to make sure that the optimization finds the node we are
          * looking for.  This is simply a sanity check on the new
          * path that has been created.
+         *
+         * We know that we are at the root, so NULL is used for the scope.
          */
-        ScopeInfo.Scope.Node = CurrentNode;
-        Status = AcpiNsLookup (&ScopeInfo, *NewPath,
+        Status = AcpiNsLookup (NULL, *NewPath,
                         ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
                         ACPI_NS_DONT_OPEN_SCOPE, WalkState, &(Node));
         if (ACPI_SUCCESS (Status))
@@ -624,11 +624,21 @@ OptOptimizeNamePath (
         ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "NAME"));
 
         /*
-         * The node of interest is the parent of this node
-         * (the containing scope)
+         * The node of interest is the parent of this node (the containing
+         * scope). The actual namespace node may be up more than one level
+         * of parse op or it may not exist at all (if we traverse back
+         * up to the root.)
          */
-        CurrentNode = Op->Asl.Parent->Asl.Node;
-        if (!CurrentNode)
+        NextOp = Op->Asl.Parent;
+        while (NextOp && (!NextOp->Asl.Node))
+        {
+            NextOp = NextOp->Asl.Parent;
+        }
+        if (NextOp && NextOp->Asl.Node)
+        {
+            CurrentNode = NextOp->Asl.Node;
+        }
+        else
         {
             CurrentNode = AcpiGbl_RootNode;
         }

Modified: head/sys/contrib/dev/acpica/compiler/aslstartup.c
==============================================================================
--- head/sys/contrib/dev/acpica/compiler/aslstartup.c   Wed Sep 19 23:03:54 
2012        (r240715)
+++ head/sys/contrib/dev/acpica/compiler/aslstartup.c   Wed Sep 19 23:25:24 
2012        (r240716)
@@ -239,7 +239,7 @@ AslDetectSourceFileType (
      * File is ASCII. Determine if this is an ASL file or an ACPI data
      * table file.
      */
-    while (fgets (Gbl_CurrentLineBuffer, ASL_LINE_BUFFER_SIZE, Info->Handle))
+    while (fgets (Gbl_CurrentLineBuffer, Gbl_LineBufferSize, Info->Handle))
     {
         /* Uppercase the buffer for caseless compare */
 

Modified: head/sys/contrib/dev/acpica/compiler/aslsupport.l
==============================================================================
--- head/sys/contrib/dev/acpica/compiler/aslsupport.l   Wed Sep 19 23:03:54 
2012        (r240715)
+++ head/sys/contrib/dev/acpica/compiler/aslsupport.l   Wed Sep 19 23:25:24 
2012        (r240716)
@@ -343,14 +343,14 @@ AslInsertLineBuffer (
         *Gbl_LineBufPtr = (UINT8) SourceChar;
         Gbl_LineBufPtr++;
 
-        if (Gbl_LineBufPtr > (Gbl_CurrentLineBuffer + (ASL_LINE_BUFFER_SIZE - 
1)))
+        if (Gbl_LineBufPtr > (Gbl_CurrentLineBuffer + (Gbl_LineBufferSize - 
1)))
         {
 #if 0
             /*
              * Warning if we have split a long source line.
              * <Probably overkill>
              */
-            sprintf (MsgBuffer, "Max %u", ASL_LINE_BUFFER_SIZE);
+            sprintf (MsgBuffer, "Max %u", Gbl_LineBufferSize);
             AslCommonError (ASL_WARNING, ASL_MSG_LONG_LINE,
                             Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
                             Gbl_CurrentLineOffset, Gbl_CurrentColumn,

Modified: head/sys/contrib/dev/acpica/compiler/asltypes.h
==============================================================================
--- head/sys/contrib/dev/acpica/compiler/asltypes.h     Wed Sep 19 23:03:54 
2012        (r240715)
+++ head/sys/contrib/dev/acpica/compiler/asltypes.h     Wed Sep 19 23:25:24 
2012        (r240716)
@@ -133,6 +133,8 @@ typedef struct asl_file_info
 {
     FILE                        *Handle;
     char                        *Filename;
+    const char                  *ShortDescription;
+    const char                  *Description;
 
 } ASL_FILE_INFO;
 
@@ -146,14 +148,14 @@ typedef struct asl_file_status
 
 /*
  * File types. Note: Any changes to this table must also be reflected
- * in the AslFileTypeNames array.
+ * in the Gbl_Files array.
  */
 typedef enum
 {
     ASL_FILE_STDOUT             = 0,
     ASL_FILE_STDERR,
-    ASL_FILE_INPUT,             /* Don't move these first 3 file types */
-    ASL_FILE_AML_OUTPUT,
+    ASL_FILE_INPUT,
+    ASL_FILE_AML_OUTPUT,        /* Don't move these first 4 file types */
     ASL_FILE_SOURCE_OUTPUT,
     ASL_FILE_PREPROCESSOR,
     ASL_FILE_LISTING_OUTPUT,

Modified: head/sys/contrib/dev/acpica/compiler/aslutils.c
==============================================================================
--- head/sys/contrib/dev/acpica/compiler/aslutils.c     Wed Sep 19 23:03:54 
2012        (r240715)
+++ head/sys/contrib/dev/acpica/compiler/aslutils.c     Wed Sep 19 23:25:24 
2012        (r240716)
@@ -54,31 +54,6 @@
         ACPI_MODULE_NAME    ("aslutils")
 
 
-char                        AslHexLookup[] =
-{
-    '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
-};
-
-/* Table below must match ASL_FILE_TYPES in asltypes.h */
-
-static const char       *AslFileTypeNames [ASL_NUM_FILES] =
-{
-    "stdout:       ",
-    "stderr:       ",
-    "Table Input:  ",
-    "Binary Output:",
-    "Source Output:",
-    "Preprocessor: ",
-    "Listing File: ",
-    "Hex Dump:     ",
-    "Namespace:    ",
-    "Debug File:   ",
-    "ASM Source:   ",
-    "C Source:     ",
-    "ASM Include:  ",
-    "C Include:    "
-};
-
 
 /* Local prototypes */
 
@@ -547,7 +522,7 @@ UtDisplaySummary (
         }
 
         FlPrintFile (FileId, "%14s %s - %u bytes\n",
-            AslFileTypeNames [i],
+            Gbl_Files[i].ShortDescription,
             Gbl_Files[i].Filename, FlGetFileSize (i));
     }
 
@@ -646,6 +621,79 @@ UtGetStringBuffer (
 }
 
 
+/******************************************************************************
+ *
+ * FUNCTION:    UtExpandLineBuffers
+ *
+ * PARAMETERS:  None. Updates global line buffer pointers.
+ *
+ * RETURN:      None. Reallocates the global line buffers
+ *
+ * DESCRIPTION: Called if the current line buffer becomes filled. Reallocates
+ *              all global line buffers and updates Gbl_LineBufferSize. NOTE:
+ *              Also used for the initial allocation of the buffers, when
+ *              all of the buffer pointers are NULL. Initial allocations are
+ *              of size ASL_DEFAULT_LINE_BUFFER_SIZE
+ *
+ *****************************************************************************/
+
+void
+UtExpandLineBuffers (
+    void)
+{
+    UINT32                  NewSize;
+
+
+    /* Attempt to double the size of all line buffers */
+
+    NewSize = Gbl_LineBufferSize * 2;
+    if (Gbl_CurrentLineBuffer)
+    {
+        DbgPrint (ASL_DEBUG_OUTPUT,"Increasing line buffer size from %u to 
%u\n",
+            Gbl_LineBufferSize, NewSize);
+    }
+
+    Gbl_CurrentLineBuffer = realloc (Gbl_CurrentLineBuffer, NewSize);
+    Gbl_LineBufPtr = Gbl_CurrentLineBuffer;
+    if (!Gbl_CurrentLineBuffer)
+    {
+        goto ErrorExit;
+    }
+
+    Gbl_MainTokenBuffer = realloc (Gbl_MainTokenBuffer, NewSize);
+    if (!Gbl_MainTokenBuffer)
+    {
+        goto ErrorExit;
+    }
+
+    Gbl_MacroTokenBuffer = realloc (Gbl_MacroTokenBuffer, NewSize);
+    if (!Gbl_MacroTokenBuffer)
+    {
+        goto ErrorExit;
+    }
+
+    Gbl_ExpressionTokenBuffer = realloc (Gbl_ExpressionTokenBuffer, NewSize);
+    if (!Gbl_ExpressionTokenBuffer)
+    {
+        goto ErrorExit;
+    }
+
+    Gbl_LineBufferSize = NewSize;
+    return;
+
+
+    /* On error above, simply issue error messages and abort, cannot continue 
*/
+
+ErrorExit:
+    printf ("Could not increase line buffer size from %u to %u\n",
+        Gbl_LineBufferSize, Gbl_LineBufferSize * 2);
+
+    AslError (ASL_ERROR, ASL_MSG_BUFFER_ALLOCATION,
+        NULL, NULL);
+    AslAbort ();
+}
+
+
 
/*******************************************************************************
  *
  * FUNCTION:    UtInternalizeName

Modified: head/sys/contrib/dev/acpica/compiler/dtio.c
==============================================================================
--- head/sys/contrib/dev/acpica/compiler/dtio.c Wed Sep 19 23:03:54 2012        
(r240715)
+++ head/sys/contrib/dev/acpica/compiler/dtio.c Wed Sep 19 23:25:24 2012        
(r240716)
@@ -413,13 +413,21 @@ DtGetNextLine (
     BOOLEAN                 LineNotAllBlanks = FALSE;
     UINT32                  State = DT_NORMAL_TEXT;
     UINT32                  CurrentLineOffset;
-    UINT32                  BeyondBufferCount;
     UINT32                  i;
     char                    c;
 
 
-    for (i = 0; i < ASL_LINE_BUFFER_SIZE;)
+    for (i = 0; ;)
     {
+        /*
+         * If line is too long, expand the line buffers. Also increases
+         * Gbl_LineBufferSize.
+         */
+        if (i >= Gbl_LineBufferSize)
+        {
+            UtExpandLineBuffers ();
+        }
+
         c = (char) getc (Handle);
         if (c == EOF)
         {
@@ -491,6 +499,11 @@ DtGetNextLine (
                  */
                 if ((i != 0) && LineNotAllBlanks)
                 {
+                    if ((i + 1) >= Gbl_LineBufferSize)
+                    {
+                        UtExpandLineBuffers ();
+                    }
+
                     Gbl_CurrentLineBuffer[i+1] = 0; /* Terminate string */
                     return (CurrentLineOffset);
                 }
@@ -565,6 +578,11 @@ DtGetNextLine (
 
             default:    /* Not a comment */
                 i++;    /* Save the preceeding slash */
+                if (i >= Gbl_LineBufferSize)
+                {
+                    UtExpandLineBuffers ();
+                }
+
                 Gbl_CurrentLineBuffer[i] = c;
                 i++;
                 State = DT_NORMAL_TEXT;
@@ -668,21 +686,6 @@ DtGetNextLine (
             return (ASL_EOF);
         }
     }
-
-    /* Line is too long for internal buffer. Determine actual length */
-
-    BeyondBufferCount = 1;
-    c = (char) getc (Handle);
-    while (c != '\n')
-    {
-        c = (char) getc (Handle);
-        BeyondBufferCount++;
-    }
-
-    printf ("ERROR - At %u: Input line (%u bytes) is too long (max %u)\n",
-        Gbl_CurrentLineNumber++, ASL_LINE_BUFFER_SIZE + BeyondBufferCount,
-        ASL_LINE_BUFFER_SIZE);
-    return (ASL_EOF);
 }
 
 

Modified: head/sys/contrib/dev/acpica/compiler/preprocess.h
==============================================================================
--- head/sys/contrib/dev/acpica/compiler/preprocess.h   Wed Sep 19 23:03:54 
2012        (r240715)
+++ head/sys/contrib/dev/acpica/compiler/preprocess.h   Wed Sep 19 23:25:24 
2012        (r240716)
@@ -128,10 +128,13 @@ typedef struct pr_file_node
 /*
  * Globals
  */
-PR_EXTERN char                  XXXEvalBuffer[ASL_LINE_BUFFER_SIZE];
-PR_EXTERN char                  Gbl_MainTokenBuffer[ASL_LINE_BUFFER_SIZE];
-PR_EXTERN char                  Gbl_MacroTokenBuffer[ASL_LINE_BUFFER_SIZE];
-PR_EXTERN char                  
Gbl_ExpressionTokenBuffer[ASL_LINE_BUFFER_SIZE];
+#if 0 /* TBD for macros */
+PR_EXTERN char                  PR_INIT_GLOBAL (*XXXEvalBuffer, NULL); /* 
[ASL_LINE_BUFFER_SIZE]; */
+#endif
+
+PR_EXTERN char                  PR_INIT_GLOBAL (*Gbl_MainTokenBuffer, NULL); 
/* [ASL_LINE_BUFFER_SIZE]; */
+PR_EXTERN char                  PR_INIT_GLOBAL (*Gbl_MacroTokenBuffer, NULL); 
/* [ASL_LINE_BUFFER_SIZE]; */
+PR_EXTERN char                  PR_INIT_GLOBAL (*Gbl_ExpressionTokenBuffer, 
NULL); /* [ASL_LINE_BUFFER_SIZE]; */
 
 PR_EXTERN PR_FILE_NODE          *Gbl_InputFileList;
 PR_EXTERN PR_DEFINE_INFO        PR_INIT_GLOBAL (*Gbl_DefineList, NULL);

Modified: head/sys/contrib/dev/acpica/components/debugger/dbexec.c
==============================================================================
--- head/sys/contrib/dev/acpica/components/debugger/dbexec.c    Wed Sep 19 
23:03:54 2012        (r240715)
+++ head/sys/contrib/dev/acpica/components/debugger/dbexec.c    Wed Sep 19 
23:25:24 2012        (r240716)
@@ -607,7 +607,7 @@ AcpiDbExecuteSetup (
     AcpiDbPrepNamestring (Info->Pathname);
 
     AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
-    AcpiOsPrintf ("Executing %s\n", Info->Pathname);
+    AcpiOsPrintf ("Evaluating %s\n", Info->Pathname);
 
     if (Info->Flags & EX_SINGLE_STEP)
     {
@@ -701,7 +701,7 @@ AcpiDbExecutionWalk (
     ReturnObj.Pointer = NULL;
     ReturnObj.Length = ACPI_ALLOCATE_BUFFER;

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to