Better I/O error handling

date	2001.04.18.22.49.00;	author rmoore1;	state Exp;
This commit is contained in:
aystarik 2005-06-29 15:42:03 +00:00
parent f81d0bd717
commit d59b66bd36
4 changed files with 925 additions and 883 deletions

View File

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: aslcodegen - AML code generation
* $Revision: 1.30 $
* $Revision: 1.31 $
*
*****************************************************************************/
@ -146,22 +146,17 @@ CgGenerateAmlOutput (void)
DbgPrint (ASL_DEBUG_OUTPUT, "\nWriting AML\n\n");
// if (Gbl_SourceOutputFlag || Gbl_ListingFlag)
// {
fseek (Gbl_SourceOutputFile, 0, SEEK_SET);
// }
FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0);
Gbl_SourceLine = 0;
LsPushNode (Gbl_InputFilename);
Gbl_NextError = Gbl_ErrorLog;
TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, CgAmlWriteWalk, NULL, NULL);
if (Gbl_ListingFlag)
{
LsFinishSourceListing ();
fprintf (Gbl_ListingOutputFile, "\n\nTable header with final checksum:\n\n");
FlPrintFile (ASL_FILE_LISTING_OUTPUT, "\n\nTable header with final checksum:\n\n");
}
CgCloseTable ();
@ -250,9 +245,10 @@ CgLocalWriteAmlData (
UINT32 Length)
{
/* Write the raw data to the AML file */
fwrite ((char *) Buffer, Length, 1, Gbl_AmlOutputFile);
FlWriteFile (ASL_FILE_AML_OUTPUT, Buffer, Length);
/* Write the hex bytes to the listing file (if requested) */
@ -504,10 +500,10 @@ CgCloseTable (void)
/* Calculate the checksum over the entire file */
fseek (Gbl_AmlOutputFile, 0, SEEK_SET);
FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
Sum = 0;
while (fread (&FileByte, 1, 1, Gbl_AmlOutputFile))
while (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1) == AE_OK)
{
Sum += FileByte;
}
@ -516,7 +512,7 @@ CgCloseTable (void)
TableHeader.Checksum = (0 - Sum);
fseek (Gbl_AmlOutputFile, 0, SEEK_SET);
FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
CgLocalWriteAmlData (&TableHeader, sizeof (ACPI_TABLE_HEADER));
}

View File

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: aslcompile - top level compile module
* $Revision: 1.5 $
* $Revision: 1.22 $
*
*****************************************************************************/
@ -10,8 +10,8 @@
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
* reserved.
* Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
* All rights reserved.
*
* 2. License
*
@ -116,17 +116,77 @@
*****************************************************************************/
#include "AslCompiler.h"
#include "aslcompiler.h"
#include "acnamesp.h"
#include "acdebug.h"
#include <time.h>
#define _COMPONENT ACPI_COMPILER
MODULE_NAME ("aslcompile")
#undef HIWORD
#undef LOWORD
#undef HIBYTE
#undef LOBYTE
#include <time.h>
#ifdef WIN32
#include <windows.h>
#include <winbase.h>
#endif
struct tm *NewTime;
time_t Aclock;
#ifdef WIN32
SYSTEMTIME SysTime;
#endif
typedef struct
{
time_t StartTime;
time_t EndTime;
char *EventName;
} ASL_EVENT_INFO;
ASL_EVENT_INFO AslGbl_Events[20];
#ifdef WIN32
#define ASL_START_EVENT(a,b) {AslGbl_Events[a].StartTime = AnGetTimeMs();\
AslGbl_Events[a].EventName = b;}
#define ASL_END_EVENT(a) {AslGbl_Events[a].EndTime = AnGetTimeMs();}
UINT32
AnGetTimeMs (void)
{
GetSystemTime (&SysTime);
return ((SysTime.wMinute * 60000) +
(SysTime.wSecond * 1000) +
SysTime.wMilliseconds);
}
#else
#define ASL_START_EVENT(a,b)
#define ASL_END_EVENT(a)
#endif
/*
* Stubs
* Stubs to simplify linkage to the
* ACPI Namespace Manager (Unused functions).
*/
void
AcpiAmlUnlinkMutex (
ACPI_OPERAND_OBJECT *ObjDesc)
{
}
void
AcpiTbDeleteAcpiTables (void)
{
@ -161,12 +221,9 @@ AcpiAmlDumpOperand (
}
struct tm *NewTime;
time_t Aclock;
/*******************************************************************************
*
* FUNCTION: Signon and FileHeader
* FUNCTION: AslCompilerSignon
*
* PARAMETERS: None
*
@ -178,102 +235,186 @@ time_t Aclock;
void
AslCompilerSignon (
FILE *Where)
UINT32 FileId)
{
time (&Aclock);
NewTime = localtime (&Aclock);
fprintf (Where, "\n%s [Version %s, %s]\n\n", CompilerId, CompilerVersion, __DATE__);
}
void
AslCompilerFileHeader (
FILE *Where)
{
fprintf (Where, "Compilation of \"%s\" - %s\n", Gbl_InputFilename, asctime (NewTime));
FlPrintFile (FileId,
"\n%s %s [%s]\n%s\nSupports ACPI Specification Revision 2.0\n\n",
CompilerId, CompilerVersion, __DATE__, CompilerCopyright);
}
/*******************************************************************************
*
* FUNCTION:
* FUNCTION: AslCompilerFileHeader
*
* PARAMETERS:
* PARAMETERS: None
*
* RETURN:
* RETURN: None
*
* DESCRIPTION:
* DESCRIPTION: Header used at the beginning of output files
*
******************************************************************************/
void
AslCompilerFileHeader (
UINT32 FileId)
{
time (&Aclock);
NewTime = localtime (&Aclock);
FlPrintFile (FileId,
"Compilation of \"%s\" - %s\n", Gbl_InputFilename, asctime (NewTime));
}
/*******************************************************************************
*
* FUNCTION: CmDoCompile
*
* PARAMETERS: None
*
* RETURN: Status (0 = OK)
*
* DESCRIPTION: This procedure performs the entire compile
*
******************************************************************************/
int
CmDoCompile (void)
{
ACPI_STATUS Status;
ACPI_STATUS Status;
ASL_START_EVENT (12, "Total Compile time");
ASL_START_EVENT (0, "Open files");
/* Open the required input and output files */
Status = FlOpenInputFile (Gbl_InputFilename);
if (ACPI_FAILURE (Status))
{
AePrintErrorLog (stderr);
return -1;
}
Status = FlOpenMiscOutputFiles (Gbl_InputFilename);
if (ACPI_FAILURE (Status))
{
AePrintErrorLog (stderr);
AePrintErrorLog (ASL_FILE_STDERR);
return -1;
}
Status = FlOpenMiscOutputFiles (Gbl_OutputFilenamePrefix);
if (ACPI_FAILURE (Status))
{
AePrintErrorLog (ASL_FILE_STDERR);
return -1;
}
ASL_END_EVENT (0);
/* ACPI CA subsystem initialization */
ASL_START_EVENT (1, "ACPI CA Init");
AcpiCmInitGlobals ();
AcpiCmMutexInitialize ();
AcpiNsRootInitialize ();
ASL_END_EVENT (1);
/* Build the parse tree */
ASL_START_EVENT (2, "Build parse tree");
AslCompilerparse();
ASL_END_EVENT (2);
/* Generate AML opcodes corresponding to the parse tokens */
DbgPrint ("\nGenerating AML opcodes\n\n");
TrWalkParseTree (ASL_WALK_VISIT_UPWARD, NULL, OpcAmlOpcodeWalk, NULL);
ASL_START_EVENT (3, "Generate AML opcodes");
DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating AML opcodes\n\n");
TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, OpcAmlOpcodeWalk, NULL);
ASL_END_EVENT (3);
/* Calculate all AML package lengths */
DbgPrint ("\nGenerating Package lengths\n\n");
TrWalkParseTree (ASL_WALK_VISIT_UPWARD, NULL, LnPackageLengthWalk, NULL);
ASL_START_EVENT (4, "Generate AML package lengths");
DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n");
TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, LnPackageLengthWalk, NULL);
ASL_END_EVENT (4);
/* Semantic error checking */
AnalysisWalkInfo.MethodStack = NULL;
if (Gbl_ParseOnlyFlag)
{
AePrintErrorLog (ASL_FILE_STDOUT);
UtDisplaySummary (ASL_FILE_STDOUT);
if (Gbl_DebugFlag)
{
/* Print error summary to the debug file */
DbgPrint ("\nSemantic analysis\n\n");
TrWalkParseTree (ASL_WALK_VISIT_TWICE, AnSemanticAnalysisWalkBegin,
AnSemanticAnalysisWalkEnd, &AnalysisWalkInfo);
AePrintErrorLog (ASL_FILE_STDERR);
UtDisplaySummary (ASL_FILE_STDERR);
}
return 0;
}
/*
* Create an internal namespace and use it as a symbol table
*/
/* Namespace loading */
ASL_START_EVENT (5, "Load ACPI Namespace");
LdLoadNamespace ();
ASL_END_EVENT (5);
/* Namespace lookup */
ASL_START_EVENT (6, "Cross reference ACPI Namespace");
LkCrossReferenceNamespace ();
ASL_END_EVENT (6);
/*
* Semantic error checking. This must happen only after the
* namespace has been loaded and cross-referenced.
*
* part one - check control methods
*/
ASL_START_EVENT (7, "Check method return types");
AnalysisWalkInfo.MethodStack = NULL;
DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method analysis\n\n");
TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, AnMethodAnalysisWalkBegin,
AnMethodAnalysisWalkEnd, &AnalysisWalkInfo);
ASL_END_EVENT (7);
/* Semantic error checking part two - typing of method returns */
ASL_START_EVENT (8, "Determine type(s) returned by methods");
DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method typing \n\n");
TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, AnMethodTypingWalkBegin,
AnMethodTypingWalkEnd, NULL);
ASL_END_EVENT (8);
/* Semantic error checking part three - operand type checking */
ASL_START_EVENT (9, "Operand type checking");
DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Operand type checking \n\n");
TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, AnSemanticAnalysisWalkBegin,
AnSemanticAnalysisWalkEnd, &AnalysisWalkInfo);
ASL_END_EVENT (9);
/* Calculate all AML package lengths */
DbgPrint ("\nGenerating Package lengths\n\n");
TrWalkParseTree (ASL_WALK_VISIT_UPWARD, NULL, LnInitLengthsWalk, NULL);
TrWalkParseTree (ASL_WALK_VISIT_UPWARD, NULL, LnPackageLengthWalk, NULL);
ASL_START_EVENT (10, "Finish AML package length generation");
DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n");
TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, LnInitLengthsWalk, NULL);
TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, LnPackageLengthWalk, NULL);
ASL_END_EVENT (10);
/*
@ -281,27 +422,21 @@ CmDoCompile (void)
* Note: by default, the name of this file comes from the table descriptor
* within the input file.
*/
Status = FlOpenAmlOutputFile (Gbl_InputFilename);
Status = FlOpenAmlOutputFile (Gbl_OutputFilenamePrefix);
if (ACPI_FAILURE (Status))
{
AePrintErrorLog (stderr);
AePrintErrorLog (ASL_FILE_STDERR);
return -1;
}
/* Code generation - emit the AML */
ASL_START_EVENT (11, "AML code generation");
CgGenerateAmlOutput ();
ASL_END_EVENT (11);
AePrintErrorLog (stdout);
if (Gbl_DebugFlag)
{
/* Print error summary to the debug file */
AePrintErrorLog (stderr);
}
/* Dump the AML as hex if requested */
LsDoHexOutput ();
@ -309,25 +444,77 @@ CmDoCompile (void)
/* Dump the namespace to the .nsp file if requested */
LsDisplayNamespace ();
ASL_END_EVENT (12);
/* Close all open files */
FlCloseListingFile ();
FlCloseSourceOutputFile ();
FlCloseHexOutputFile ();
fclose (Gbl_AmlOutputFile);
if ((Gbl_ExceptionCount[ASL_ERROR] > 0) && (!Gbl_IgnoreErrors))
{
unlink (Gbl_OutputFilename);
}
UtDisplaySummary ();
CmCleanupAndExit ();
return 0;
}
/*******************************************************************************
*
* FUNCTION: CmCleanupAndExit
*
* PARAMETERS: None
*
* RETURN: None.
*
* DESCRIPTION: Close all open files and exit the compiler
*
******************************************************************************/
void
CmCleanupAndExit (void)
{
UINT32 i;
AePrintErrorLog (ASL_FILE_STDOUT);
if (Gbl_DebugFlag)
{
/* Print error summary to the debug file */
AePrintErrorLog (ASL_FILE_STDERR);
}
DbgPrint (ASL_DEBUG_OUTPUT, "\n\nElapsed time for major events\n\n");
for (i = 0; i < 13; i++)
{
DbgPrint (ASL_DEBUG_OUTPUT, "%8.8X - %s\n",
AslGbl_Events[i].EndTime -
AslGbl_Events[i].StartTime,
AslGbl_Events[i].EventName);
}
if (Gbl_NsLookupCount)
{
DbgPrint (ASL_DEBUG_OUTPUT, "\n\nMiscellaneous compile statistics\n\n");
DbgPrint (ASL_DEBUG_OUTPUT, "%32s : %d\n", "Total Namespace searches", Gbl_NsLookupCount);
DbgPrint (ASL_DEBUG_OUTPUT, "%32s : %d\n", "Time per search",
((AslGbl_Events[7].EndTime - AslGbl_Events[7].StartTime) * 1000) /
Gbl_NsLookupCount);
}
/* Close all open files */
for (i = 2; i < ASL_MAX_FILE; i++)
{
FlCloseFile (i);
}
if ((Gbl_ExceptionCount[ASL_ERROR] > 0) && (!Gbl_IgnoreErrors))
{
unlink (Gbl_Files[ASL_FILE_AML_OUTPUT].Filename);
}
UtDisplaySummary (ASL_FILE_STDOUT);
exit (0);
}

View File

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: aslcompiler.h - common include file
* $Revision: 1.31 $
* $Revision: 1.51 $
*
*****************************************************************************/
@ -10,8 +10,8 @@
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
* reserved.
* Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
* All rights reserved.
*
* 2. License
*
@ -126,344 +126,119 @@
#include <stdarg.h>
#include <string.h>
#define ACPI_USE_SYSTEM_CLIBRARY
#define ACPI_DEBUG
#define ACPI_APPLICATION
#include "acpi.h"
#include "acdebug.h"
#define CompilerVersion "X205"
#define CompilerCreatorRevision 0x00020205 /* Acpi 2.0, Version# */
#define CompilerId "ACPI Component Architecture ASL Compiler"
#define CompilerName "iasl"
#define CompilerCreatorId "IASL"
#include "asltypes.h"
#include "aslglobal.h"
typedef struct asl_method_info
{
UINT8 NumArguments;
UINT8 LocalInitialized[8];
UINT32 NumReturnNoValue;
UINT32 NumReturnWithValue;
struct asl_method_info *Next;
/*
* Compiler versions and names
*/
} ASL_METHOD_INFO;
#define CompilerVersion "X2017"
#define CompilerCreatorRevision 0x02002017 /* Acpi 2.0, Version # */
typedef struct asl_analysis_walk_info
{
ASL_METHOD_INFO *MethodStack;
#define CompilerId "Intel ACPI Component Architecture ASL Compiler"
#define CompilerCopyright "Copyright (C) 2000, 2001 Intel Corporation"
#define CompilerCompliance "ACPI 2.0"
#define CompilerName "iasl"
#define CompilerCreatorId "INTL"
} ASL_ANALYSIS_WALK_INFO;
/* Configuration constants */
#define ASL_MAX_ERROR_COUNT 200
/*
* Macros
*/
#define ASL_OFFSET_OF(s,m) ((UINT32) &(((s *)0)->m))
#define ASL_RESDESC_OFFSET(m) ASL_OFFSET_OF (ASL_RESOURCE_DESC, m)
#define ASL_PTR_DIFF(a,b) ((UINT8 *)(b) - (UINT8 *)(a))
#define ASL_PTR_ADD(a,b) ((UINT8 *)(a) = ((UINT8 *)(a) + (b)))
#define ASL_GET_CHILD_NODE(a) (a)->Child
#define ASL_GET_PEER_NODE(a) (a)->Peer
#define OP_TABLE_ENTRY(a,b,c,d) {b,d,a,c}
#define ASL_PARSE_OPCODE_BASE ACCESSAS /* First Lex type */
/* TBD: Is this a real opcode? */
#define AML_CONCAT_TPL_OP (UINT16) 0x00FE
/* Internal opcodes */
#define AML_RAW_DATA_BYTE (UINT16) 0xAA01
#define AML_RAW_DATA_WORD (UINT16) 0xAA02
#define AML_RAW_DATA_DWORD (UINT16) 0xAA04
#define AML_RAW_DATA_QWORD (UINT16) 0xAA08
#define AML_RAW_DATA_BUFFER (UINT16) 0xAA0B
#define AML_RAW_DATA_CHAIN (UINT16) 0xAA0C
/* Internal AML opcodes */
#define AML_RAW_DATA_BYTE (UINT16) 0xAA01 /* write one raw byte */
#define AML_RAW_DATA_WORD (UINT16) 0xAA02 /* write 2 raw bytes */
#define AML_RAW_DATA_DWORD (UINT16) 0xAA04 /* write 4 raw bytes */
#define AML_RAW_DATA_QWORD (UINT16) 0xAA08 /* write 8 raw bytes */
#define AML_RAW_DATA_BUFFER (UINT16) 0xAA0B /* raw buffer with length */
#define AML_RAW_DATA_CHAIN (UINT16) 0xAA0C /* chain of raw buffers */
#define AML_PACKAGE_LENGTH (UINT16) 0xAA10
#define AML_UNASSIGNED_OPCODE (UINT16) 0xEEEE
#define AML_DEFAULT_ARG_OP (UINT16) 0xDDDD
#define NODE_VISITED 0x01
#define NODE_AML_PACKAGE 0x02
#define NODE_IS_TARGET 0x04
#define NODE_IS_RESOURCE_DESC 0x08
#define NODE_IS_RESOURCE_FIELD 0x10
#define NODE_HAS_NO_EXIT 0x20
#define NODE_IF_HAS_NO_EXIT 0x40
#define NODE_NAME_INTERNALIZED 0x80
#define ASL_WALK_VISIT_DOWNWARD 0x01
#define ASL_WALK_VISIT_UPWARD 0x02
#define ASL_WALK_VISIT_TWICE 0x03
/* TBD: Is this a real opcode? */
#define AML_CONCAT_TPL_OP (UINT16) 0x00FE
#define OP_TABLE_ENTRY(a,b,c) {b,a,c}
/* filename suffixes for output files */
typedef struct asl_mapping_entry
{
UINT32 Value;
UINT16 AmlOpcode;
UINT8 Flags;
} ASL_MAPPING_ENTRY;
typedef union asl_node_value
{
UINT64 Integer; /* Generic integer is largest integer */
UINT64 Integer64;
UINT32 Integer32;
UINT16 Integer16;
UINT8 Integer8;
void *Pointer;
char *String;
} ASL_NODE_VALUE;
typedef struct asl_parse_node
{
struct asl_parse_node *Parent;
struct asl_parse_node *Peer;
struct asl_parse_node *Child;
ACPI_NAMESPACE_NODE *NsNode;
union asl_node_value Value;
char *Filename;
char *ExternalName;
char *Namepath;
UINT32 LineNumber;
UINT32 LogicalLineNumber;
UINT32 EndLine;
UINT32 EndLogicalLine;
UINT16 AmlOpcode;
UINT16 ParseOpcode;
UINT32 AmlLength;
UINT32 AmlSubtreeLength;
UINT8 AmlOpcodeLength;
UINT8 AmlPkgLenBytes;
UINT8 Flags;
char ParseOpName[12];
char AmlOpName[12];
} ASL_PARSE_NODE;
#define FILE_SUFFIX_AML_CODE "aml"
#define FILE_SUFFIX_LISTING "lst"
#define FILE_SUFFIX_HEX_DUMP "hex"
#define FILE_SUFFIX_DEBUG "txt"
#define FILE_SUFFIX_SOURCE "src"
#define FILE_SUFFIX_NAMESPACE "nsp"
typedef struct asl_walk_info
{
ASL_PARSE_NODE **NodePtr;
UINT32 *LevelPtr;
} ASL_WALK_INFO;
/*******************************************************************************
*
* Compiler prototypes
*
******************************************************************************/
typedef struct asl_error_msg
{
UINT32 LineNumber;
UINT32 LogicalLineNumber;
UINT32 Column;
char *Message;
struct asl_error_msg *Next;
char *Filename;
UINT8 MessageId;
UINT8 Level;
} ASL_ERROR_MSG;
void
end_stmt (void);
typedef struct asl_listing_node
{
char *Filename;
UINT32 LineNumber;
struct asl_listing_node *Next;
/* parser */
} ASL_LISTING_NODE;
int
AslCompilerparse(
void);
ASL_PARSE_NODE *
AslDoError (
void);
#define ASL_RSVD_RETURN_VALUE 0x01
int
AslCompilererror(
char *s);
typedef struct
{
char *Name;
UINT8 NumArguments;
UINT8 Flags;
int
AslCompilerlex();
} ASL_RESERVED_INFO;
typedef
void (*ASL_WALK_CALLBACK) (
ASL_PARSE_NODE *Node,
UINT32 Level,
void *Context);
/*
* Global variables. Declared in aslmain.c only
*/
#ifdef _DECLARE_GLOBALS
#define EXTERN
#define INIT_GLOBAL(a,b) a=b
#else
#define EXTERN extern
#define INIT_GLOBAL(a,b) a
#endif
extern int optind;
extern char *optarg;
extern FILE *AslCompilerin;
extern int AslCompilerparse(void);
extern int AslCompilerdebug;
extern ASL_MAPPING_ENTRY AslKeywordMapping[];
extern int yydebug;
extern char *AslCompilertext;
extern FILE *AslCompilerin;
extern char hex[];
extern char MsgBuffer[];
#define ASL_LINE_BUFFER_SIZE 1024
/* Source code buffers and pointers for error reporting */
EXTERN char Gbl_CurrentLineBuffer[ASL_LINE_BUFFER_SIZE];
EXTERN int INIT_GLOBAL (Gbl_CurrentColumn, 0);
EXTERN int INIT_GLOBAL (Gbl_CurrentLineNumber, 1);
EXTERN int INIT_GLOBAL (Gbl_LogicalLineNumber, 1);
EXTERN char INIT_GLOBAL (*Gbl_LineBufPtr, Gbl_CurrentLineBuffer);
/* Exception reporting */
EXTERN ASL_ERROR_MSG INIT_GLOBAL (*Gbl_ErrorLog,NULL);
EXTERN ASL_ERROR_MSG INIT_GLOBAL (*Gbl_NextError,NULL);
extern UINT32 Gbl_ExceptionCount[];
/* Option flags */
EXTERN BOOLEAN INIT_GLOBAL (Gbl_UseDefaultAmlFilename, TRUE);
EXTERN BOOLEAN INIT_GLOBAL (Gbl_NsOutputFlag, FALSE);
EXTERN BOOLEAN INIT_GLOBAL (Gbl_DebugFlag, FALSE);
EXTERN BOOLEAN INIT_GLOBAL (Gbl_HexOutputFlag, FALSE);
EXTERN BOOLEAN INIT_GLOBAL (Gbl_ListingFlag, FALSE);
EXTERN BOOLEAN INIT_GLOBAL (Gbl_IgnoreErrors, FALSE);
EXTERN BOOLEAN INIT_GLOBAL (Gbl_SourceOutputFlag, FALSE);
/* Files */
EXTERN char *Gbl_DirectoryPath;
EXTERN char INIT_GLOBAL (*Gbl_NamespaceOutputFilename, NULL);
EXTERN char INIT_GLOBAL (*Gbl_InputFilename, NULL);
EXTERN char INIT_GLOBAL (*Gbl_IncludeFilename, NULL);
EXTERN char INIT_GLOBAL (*Gbl_SourceOutputFilename, NULL);
EXTERN char INIT_GLOBAL (*Gbl_OutputFilename, NULL);
EXTERN char INIT_GLOBAL (*Gbl_ListingOutputFilename, NULL);
EXTERN char INIT_GLOBAL (*Gbl_DebugOutputFilename, NULL);
EXTERN char INIT_GLOBAL (*Gbl_HexOutputFilename, NULL);
EXTERN FILE *Gbl_AslInputFile;
EXTERN FILE *Gbl_AmlOutputFile;
EXTERN FILE *Gbl_DebugOutputFile;
EXTERN FILE *Gbl_ListingOutputFile;
EXTERN FILE *Gbl_HexOutputFile;
EXTERN FILE *Gbl_NamespaceOutputFile;
EXTERN FILE *Gbl_SourceOutputFile;
EXTERN BOOLEAN INIT_GLOBAL (Gbl_HasIncludeFiles, FALSE);
EXTERN char *Gbl_CurrentInputFilename;
/* Statistics */
EXTERN UINT32 INIT_GLOBAL (Gbl_InputByteCount, 0);
EXTERN UINT32 INIT_GLOBAL (TotalKeywords, 0);
EXTERN UINT32 INIT_GLOBAL (TotalNamedObjects, 0);
EXTERN UINT32 INIT_GLOBAL (TotalExecutableOpcodes, 0);
/* Misc */
EXTERN ASL_PARSE_NODE INIT_GLOBAL (*RootNode, NULL);
EXTERN UINT32 INIT_GLOBAL (Gbl_TableLength, 0);
EXTERN UINT32 INIT_GLOBAL (Gbl_SourceLine, 0);
EXTERN ASL_LISTING_NODE INIT_GLOBAL (*Gbl_ListingNode, NULL);
EXTERN UINT32 INIT_GLOBAL (Gbl_CurrentHexColumn, 0);
EXTERN UINT32 INIT_GLOBAL (Gbl_CurrentAmlOffset, 0);
EXTERN UINT32 INIT_GLOBAL (Gbl_CurrentLine, 0);
EXTERN UINT8 INIT_GLOBAL (Gbl_HexBytesWereWritten, FALSE);
EXTERN UINT32 INIT_GLOBAL (Gbl_NumNamespaceObjects, 0);
EXTERN UINT32 INIT_GLOBAL (Gbl_ReservedMethods, 0);
EXTERN UINT8 INIT_GLOBAL (AcpiGbl_DbOutputFlags, DB_CONSOLE_OUTPUT);
EXTERN FILE *DebugFile; /* Placeholder for oswinxf only */
/* Static structures */
EXTERN ASL_ANALYSIS_WALK_INFO AnalysisWalkInfo;
EXTERN ACPI_TABLE_HEADER TableHeader;
EXTERN ASL_RESERVED_INFO ReservedMethods[];
extern char hex[];
/* Scratch buffers */
EXTERN UINT8 Gbl_AmlBuffer[16];
EXTERN char MsgBuffer[256];
EXTERN char StringBuffer[256];
#define ASL_ERROR 0
#define ASL_WARNING 1
typedef enum
{
ASL_MSG_NULL = 0,
ASL_MSG_MEMORY_ALLOCATION,
ASL_MSG_INPUT_FILE_OPEN,
ASL_MSG_OUTPUT_FILENAME,
ASL_MSG_OUTPUT_FILE_OPEN,
ASL_MSG_LISTING_FILENAME,
ASL_MSG_LISTING_FILE_OPEN,
ASL_MSG_DEBUG_FILENAME,
ASL_MSG_DEBUG_FILE_OPEN,
ASL_MSG_INCLUDE_FILE_OPEN,
ASL_MSG_ENCODING_LENGTH,
ASL_MSG_INVALID_PRIORITY,
ASL_MSG_INVALID_PERFORMANCE,
ASL_MSG_LOCAL_INIT,
ASL_MSG_ARG_INVALID,
ASL_MSG_UNSUPPORTED,
ASL_MSG_RESERVED_WORD,
ASL_MSG_BUFFER_LENGTH,
ASL_MSG_PACKAGE_LENGTH,
ASL_MSG_RETURN_TYPES,
ASL_MSG_NOT_FOUND,
ASL_MSG_NESTED_COMMENT,
ASL_MSG_RESERVED_ARG_COUNT,
ASL_MSG_RESERVED_RETURN_VALUE,
} ASL_MESSAGE_IDS;
char
*AslCompilertext;
void
ResetCurrentLineBuffer (
void);
/* aslmain */
void
AslCompilerSignon (
FILE *Where);
UINT32 FileId);
void
AslCompilerFileHeader (
FILE *Where);
UINT32 FileId);
void
AslDoSourceOutputFile (
@ -480,8 +255,14 @@ AslPushInputFileStack (
int
AslCompilererror(char *s);
#define ASL_DEBUG_OUTPUT 0
#define ASL_PARSE_OUTPUT 1
#define ASL_TREE_OUTPUT 2
int
DbgPrint (
UINT32 Type,
char *Format,
...);
@ -499,6 +280,9 @@ ErrorContext (void);
int
CmDoCompile (void);
void
CmCleanupAndExit (void);
/* aslerror */
@ -515,17 +299,19 @@ AslCommonError (
UINT8 MessageId,
UINT32 CurrentLineNumber,
UINT32 LogicalLineNumber,
UINT32 LogicalByteOffset,
UINT32 Column,
char *Filename,
char *ExtraMessage);
void
AePrintException (
FILE *Where,
UINT32 FileId,
ASL_ERROR_MSG *Enode);
void
AePrintErrorLog (
FILE *Where);
UINT32 FileId);
/* asllisting */
@ -594,23 +380,6 @@ RsDoResourceTemplate (
ASL_PARSE_NODE *Node);
void
CgGenerateAmlOutput (void);
void
@ -644,7 +413,6 @@ CgAmlWriteWalk (
void *Context);
void
CgGenerateOutput(
void);
@ -658,19 +426,25 @@ CgWriteNode (
ASL_PARSE_NODE *Node);
/*
/*
* asltree - parse tree support
*/
void
TrWalkParseTree (
ASL_PARSE_NODE *Node,
UINT32 Visitation,
ASL_WALK_CALLBACK DescendingCallback,
ASL_WALK_CALLBACK AscendingCallback,
void *Context);
/* Values for "Visitation" parameter above */
#define ASL_WALK_VISIT_DOWNWARD 0x01
#define ASL_WALK_VISIT_UPWARD 0x02
#define ASL_WALK_VISIT_TWICE 0x03
char *
TrAddNode (
void *Thing);
@ -693,7 +467,7 @@ TrCreateLeafNode (
ASL_PARSE_NODE *
TrCreateValuedLeafNode (
UINT32 ParseOpcode,
void *Value);
ACPI_INTEGER Value);
ASL_PARSE_NODE *
TrLinkChildren (
@ -733,15 +507,77 @@ TrLinkPeerNodes (
void
AnSemanticAnalysisWalkBegin (
ASL_PARSE_NODE *Node,
UINT32 Level,
void *Context);
ASL_PARSE_NODE *Node,
UINT32 Level,
void *Context);
void
AnSemanticAnalysisWalkEnd (
ASL_PARSE_NODE *Node,
UINT32 Level,
void *Context);
ASL_PARSE_NODE *Node,
UINT32 Level,
void *Context);
void
AnMethodAnalysisWalkBegin (
ASL_PARSE_NODE *Node,
UINT32 Level,
void *Context);
void
AnMethodAnalysisWalkEnd (
ASL_PARSE_NODE *Node,
UINT32 Level,
void *Context);
void
AnMethodTypingWalkBegin (
ASL_PARSE_NODE *Node,
UINT32 Level,
void *Context);
void
AnMethodTypingWalkEnd (
ASL_PARSE_NODE *Node,
UINT32 Level,
void *Context);
/*
* aslfiles - File I/O support
*/
FILE *
FlOpenFile (
UINT32 FileId,
char *Filename,
char *Mode);
ACPI_STATUS
FlReadFile (
UINT32 FileId,
void *Buffer,
UINT32 Length);
ACPI_STATUS
FlWriteFile (
UINT32 FileId,
void *Buffer,
UINT32 Length);
ACPI_STATUS
FlSeekFile (
UINT32 FileId,
UINT32 Offset);
ACPI_STATUS
FlCloseFile (
UINT32 FileId);
void
FlPrintFile (
UINT32 FileId,
char *Format,
...);
void
@ -761,12 +597,6 @@ FlOpenMiscOutputFiles (
char *InputFilename);
void
FlCloseListingFile (void);
void
FlCloseSourceOutputFile (void);
void
FlCloseHexOutputFile (void);
/* Load */
@ -776,15 +606,15 @@ LdLoadNamespace (void);
ACPI_STATUS
LdNamespace1Begin (
ASL_PARSE_NODE *PsNode,
UINT32 Level,
void *Context);
ASL_PARSE_NODE *PsNode,
UINT32 Level,
void *Context);
ACPI_STATUS
LdNamespace1End (
ASL_PARSE_NODE *PsNode,
UINT32 Level,
void *Context);
ASL_PARSE_NODE *PsNode,
UINT32 Level,
void *Context);
/* Lookup */
@ -794,15 +624,15 @@ LkCrossReferenceNamespace (void);
ACPI_STATUS
LkNamespaceLocateBegin (
ASL_PARSE_NODE *PsNode,
UINT32 Level,
void *Context);
ASL_PARSE_NODE *PsNode,
UINT32 Level,
void *Context);
ACPI_STATUS
LkNamespaceLocateEnd (
ASL_PARSE_NODE *PsNode,
UINT32 Level,
void *Context);
ASL_PARSE_NODE *PsNode,
UINT32 Level,
void *Context);
ACPI_STATUS
LsDisplayNamespace (void);
@ -814,14 +644,6 @@ void *
UtLocalCalloc (
UINT32 Size);
void *
UtLocalRealloc (
void *Previous,
UINT32 OldSize,
UINT32 Size);
void
UtPrintFormattedName (
UINT16 ParseOpcode,
@ -829,8 +651,7 @@ UtPrintFormattedName (
void
UtDisplaySummary (
void);
UINT32 FileId);
UINT8
UtHexCharToValue (
@ -845,7 +666,6 @@ char *
UtGetOpName (
UINT32 ParseOpcode);
ASL_PARSE_NODE *
UtGetArg (
ASL_PARSE_NODE *Op,
@ -856,6 +676,18 @@ UtAttachNamepathToOwner (
ASL_PARSE_NODE *Node,
ASL_PARSE_NODE *NameNode);
ASL_PARSE_NODE *
UtCheckIntegerRange (
ASL_PARSE_NODE *Node,
UINT32 LowValue,
UINT32 HighValue);
ACPI_INTEGER
UtStrtoul64 (
NATIVE_CHAR *String,
NATIVE_CHAR **Terminator,
UINT32 Base);
/* Find */
@ -865,5 +697,5 @@ LnAdjustLengthToRoot (
UINT32 LengthDelta);
#endif
#endif /* __ASLCOMPILER_H */

File diff suppressed because it is too large Load Diff