diff options
Diffstat (limited to 'source/compiler')
41 files changed, 1678 insertions, 910 deletions
diff --git a/source/compiler/aslanalyze.c b/source/compiler/aslanalyze.c index f0ec1af..a80c90d 100644 --- a/source/compiler/aslanalyze.c +++ b/source/compiler/aslanalyze.c @@ -381,6 +381,7 @@ AnIsResultUsed ( return (TRUE); default: + break; } @@ -411,6 +412,7 @@ AnIsResultUsed ( return (FALSE); default: + /* Any other type of parent means that the result is used */ return (TRUE); diff --git a/source/compiler/aslbtypes.c b/source/compiler/aslbtypes.c index b2f7512..f9dc107 100644 --- a/source/compiler/aslbtypes.c +++ b/source/compiler/aslbtypes.c @@ -83,15 +83,19 @@ AnMapArgTypeToBtype ( /* Simple types */ case ARGI_ANYTYPE: + return (ACPI_BTYPE_OBJECTS_AND_REFS); case ARGI_PACKAGE: + return (ACPI_BTYPE_PACKAGE); case ARGI_EVENT: + return (ACPI_BTYPE_EVENT); case ARGI_MUTEX: + return (ACPI_BTYPE_MUTEX); case ARGI_DDBHANDLE: @@ -111,31 +115,36 @@ AnMapArgTypeToBtype ( case ARGI_BUFFER: case ARGI_BUFFER_OR_STRING: case ARGI_COMPUTEDATA: + return (ACPI_BTYPE_COMPUTE_DATA); /* References */ case ARGI_INTEGER_REF: + return (ACPI_BTYPE_INTEGER); case ARGI_OBJECT_REF: + return (ACPI_BTYPE_ALL_OBJECTS); case ARGI_DEVICE_REF: + return (ACPI_BTYPE_DEVICE_OBJECTS); case ARGI_REFERENCE: + return (ACPI_BTYPE_REFERENCE); case ARGI_TARGETREF: case ARGI_FIXED_TARGET: case ARGI_SIMPLE_TARGET: + return (ACPI_BTYPE_OBJECTS_AND_REFS); /* Complex types */ case ARGI_DATAOBJECT: - /* * Buffer, string, package or reference to a Op - * Used only by SizeOf operator @@ -150,6 +159,7 @@ AnMapArgTypeToBtype ( return (ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | ACPI_BTYPE_PACKAGE); case ARGI_REF_OR_STRING: + return (ACPI_BTYPE_STRING | ACPI_BTYPE_REFERENCE); case ARGI_REGION_OR_BUFFER: @@ -159,10 +169,12 @@ AnMapArgTypeToBtype ( return (ACPI_BTYPE_REGION | ACPI_BTYPE_BUFFER | ACPI_BTYPE_FIELD_UNIT); case ARGI_DATAREFOBJ: + return (ACPI_BTYPE_INTEGER |ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | ACPI_BTYPE_PACKAGE | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE); default: + break; } @@ -207,22 +219,28 @@ AnMapEtypeToBtype ( switch (Etype) { case ACPI_TYPE_INTEGER: + return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_DDB_HANDLE); case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: + return (ACPI_BTYPE_COMPUTE_DATA); case ACPI_TYPE_PACKAGE: + return (ACPI_BTYPE_PACKAGE); case ACPI_TYPE_FIELD_UNIT: + return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_FIELD_UNIT); case ACPI_TYPE_BUFFER_FIELD: + return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_BUFFER_FIELD); case ACPI_TYPE_DDB_HANDLE: + return (ACPI_BTYPE_INTEGER | ACPI_BTYPE_DDB_HANDLE); case ACPI_BTYPE_DEBUG_OBJECT: @@ -232,6 +250,7 @@ AnMapEtypeToBtype ( return (0); default: + return (1 << (Etype - 1)); } } @@ -259,6 +278,7 @@ AnMapEtypeToBtype ( return (ACPI_BTYPE_REFERENCE); default: + printf ("Unhandled encoded type: %X\n", Etype); return (0); } @@ -438,51 +458,67 @@ AnMapObjTypeToBtype ( switch (Op->Asl.ParseOpcode) { case PARSEOP_OBJECTTYPE_BFF: /* "BuffFieldObj" */ + return (ACPI_BTYPE_BUFFER_FIELD); case PARSEOP_OBJECTTYPE_BUF: /* "BuffObj" */ + return (ACPI_BTYPE_BUFFER); case PARSEOP_OBJECTTYPE_DDB: /* "DDBHandleObj" */ + return (ACPI_BTYPE_DDB_HANDLE); case PARSEOP_OBJECTTYPE_DEV: /* "DeviceObj" */ + return (ACPI_BTYPE_DEVICE); case PARSEOP_OBJECTTYPE_EVT: /* "EventObj" */ + return (ACPI_BTYPE_EVENT); case PARSEOP_OBJECTTYPE_FLD: /* "FieldUnitObj" */ + return (ACPI_BTYPE_FIELD_UNIT); case PARSEOP_OBJECTTYPE_INT: /* "IntObj" */ + return (ACPI_BTYPE_INTEGER); case PARSEOP_OBJECTTYPE_MTH: /* "MethodObj" */ + return (ACPI_BTYPE_METHOD); case PARSEOP_OBJECTTYPE_MTX: /* "MutexObj" */ + return (ACPI_BTYPE_MUTEX); case PARSEOP_OBJECTTYPE_OPR: /* "OpRegionObj" */ + return (ACPI_BTYPE_REGION); case PARSEOP_OBJECTTYPE_PKG: /* "PkgObj" */ + return (ACPI_BTYPE_PACKAGE); case PARSEOP_OBJECTTYPE_POW: /* "PowerResObj" */ + return (ACPI_BTYPE_POWER); case PARSEOP_OBJECTTYPE_STR: /* "StrObj" */ + return (ACPI_BTYPE_STRING); case PARSEOP_OBJECTTYPE_THZ: /* "ThermalZoneObj" */ + return (ACPI_BTYPE_THERMAL); case PARSEOP_OBJECTTYPE_UNK: /* "UnknownObj" */ + return (ACPI_BTYPE_OBJECTS_AND_REFS); default: + return (0); } } diff --git a/source/compiler/aslcodegen.c b/source/compiler/aslcodegen.c index 1171d34..1230f59 100644 --- a/source/compiler/aslcodegen.c +++ b/source/compiler/aslcodegen.c @@ -284,6 +284,7 @@ CgWriteAmlOpcode ( break; default: + Aml.Opcode = Op->Asl.AmlOpcode; break; } @@ -382,7 +383,9 @@ CgWriteAmlOpcode ( break; default: + /* All data opcodes must appear above */ + break; } } @@ -560,7 +563,9 @@ CgWriteNode ( return; default: + /* Internal data opcodes must all appear above */ + break; } diff --git a/source/compiler/aslcompile.c b/source/compiler/aslcompile.c index 73b6732..bbd8ab9 100644 --- a/source/compiler/aslcompile.c +++ b/source/compiler/aslcompile.c @@ -133,7 +133,9 @@ AslCompilerSignon ( break; default: + /* No other output types supported */ + break; } @@ -207,7 +209,9 @@ AslCompilerFileHeader ( break; default: + /* No other output types supported */ + break; } @@ -226,11 +230,14 @@ AslCompilerFileHeader ( case ASL_FILE_C_SOURCE_OUTPUT: case ASL_FILE_C_OFFSET_OUTPUT: case ASL_FILE_C_INCLUDE_OUTPUT: + FlPrintFile (FileId, " */\n"); break; default: + /* Nothing to do for other output types */ + break; } } diff --git a/source/compiler/aslcompiler.h b/source/compiler/aslcompiler.h index cfe3ecf..1ffbf92 100644 --- a/source/compiler/aslcompiler.h +++ b/source/compiler/aslcompiler.h @@ -291,6 +291,15 @@ AslError ( ACPI_PARSE_OBJECT *Op, char *ExtraMessage); +ACPI_STATUS +AslDisableException ( + char *MessageIdString); + +BOOLEAN +AslIsExceptionDisabled ( + UINT8 Level, + UINT8 MessageId); + void AslCoreSubsystemError ( ACPI_PARSE_OBJECT *Op, @@ -791,6 +800,17 @@ void LkFindUnreferencedObjects ( void); +/* + * aslmain - startup + */ +void +Usage ( + void); + +void +AslFilenameHelp ( + void); + /* * aslnamesp - namespace output file generation @@ -803,6 +823,13 @@ void NsSetupNamespaceListing ( void *Handle); +/* + * asloptions - command line processing + */ +int +AslCommandLine ( + int argc, + char **argv); /* * aslxref - namespace cross reference diff --git a/source/compiler/aslerror.c b/source/compiler/aslerror.c index 5b3b483..0616040 100644 --- a/source/compiler/aslerror.c +++ b/source/compiler/aslerror.c @@ -201,6 +201,7 @@ AePrintException ( switch (Enode->Level) { case ASL_REMARK: + if (!Gbl_DisplayRemarks) { return; @@ -208,6 +209,7 @@ AePrintException ( break; case ASL_OPTIMIZATION: + if (!Gbl_DisplayOptimizations) { return; @@ -215,6 +217,7 @@ AePrintException ( break; default: + break; } } @@ -676,6 +679,113 @@ AslCommonError ( /******************************************************************************* * + * FUNCTION: AslDisableException + * + * PARAMETERS: MessageIdString - ID to be disabled + * + * RETURN: Status + * + * DESCRIPTION: Enter a message ID into the global disabled messages table + * + ******************************************************************************/ + +ACPI_STATUS +AslDisableException ( + char *MessageIdString) +{ + UINT32 MessageId; + + + /* Convert argument to an integer and validate it */ + + MessageId = (UINT32) strtoul (MessageIdString, NULL, 0); + + if ((MessageId < 2000) || (MessageId > 5999)) + { + printf ("\"%s\" is not a valid warning/remark ID\n", + MessageIdString); + return (AE_BAD_PARAMETER); + } + + /* Insert value into the global disabled message array */ + + if (Gbl_DisabledMessagesIndex >= ASL_MAX_DISABLED_MESSAGES) + { + printf ("Too many messages have been disabled (max %u)\n", + ASL_MAX_DISABLED_MESSAGES); + return (AE_LIMIT); + } + + Gbl_DisabledMessages[Gbl_DisabledMessagesIndex] = MessageId; + Gbl_DisabledMessagesIndex++; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AslIsExceptionDisabled + * + * PARAMETERS: Level - Seriousness (Warning/error, etc.) + * MessageId - Index into global message buffer + * + * RETURN: TRUE if exception/message should be ignored + * + * DESCRIPTION: Check if the user has specified options such that this + * exception should be ignored + * + ******************************************************************************/ + +BOOLEAN +AslIsExceptionDisabled ( + UINT8 Level, + UINT8 MessageId) +{ + UINT32 EncodedMessageId; + UINT32 i; + + + switch (Level) + { + case ASL_WARNING2: + case ASL_WARNING3: + + /* Check for global disable via -w1/-w2/-w3 options */ + + if (Level > Gbl_WarningLevel) + { + return (TRUE); + } + /* Fall through */ + + case ASL_WARNING: + case ASL_REMARK: + /* + * Ignore this warning/remark if it has been disabled by + * the user (-vw option) + */ + EncodedMessageId = MessageId + ((Level + 1) * 1000); + for (i = 0; i < Gbl_DisabledMessagesIndex; i++) + { + /* Simple implementation via fixed array */ + + if (EncodedMessageId == Gbl_DisabledMessages[i]) + { + return (TRUE); + } + } + break; + + default: + break; + } + + return (FALSE); +} + + +/******************************************************************************* + * * FUNCTION: AslError * * PARAMETERS: Level - Seriousness (Warning/error, etc.) @@ -698,32 +808,25 @@ AslError ( char *ExtraMessage) { - switch (Level) - { - case ASL_WARNING2: - case ASL_WARNING3: - if (Gbl_WarningLevel < Level) - { - return; - } - break; + /* Check if user wants to ignore this exception */ - default: - break; + if (AslIsExceptionDisabled (Level, MessageId)) + { + return; } if (Op) { AslCommonError (Level, MessageId, Op->Asl.LineNumber, - Op->Asl.LogicalLineNumber, - Op->Asl.LogicalByteOffset, - Op->Asl.Column, - Op->Asl.Filename, ExtraMessage); + Op->Asl.LogicalLineNumber, + Op->Asl.LogicalByteOffset, + Op->Asl.Column, + Op->Asl.Filename, ExtraMessage); } else { AslCommonError (Level, MessageId, 0, - 0, 0, 0, NULL, ExtraMessage); + 0, 0, 0, NULL, ExtraMessage); } } diff --git a/source/compiler/aslfold.c b/source/compiler/aslfold.c index d25c7ff..9a041a5 100644 --- a/source/compiler/aslfold.c +++ b/source/compiler/aslfold.c @@ -441,7 +441,6 @@ OpcAmlConstantWalk ( ACPI_FORMAT_UINT64 (Op->Common.Value.Integer)); break; - case ACPI_TYPE_STRING: Op->Asl.ParseOpcode = PARSEOP_STRING_LITERAL; @@ -455,7 +454,6 @@ OpcAmlConstantWalk ( break; - case ACPI_TYPE_BUFFER: Op->Asl.ParseOpcode = PARSEOP_BUFFER; @@ -493,8 +491,8 @@ OpcAmlConstantWalk ( ObjDesc->Buffer.Length); break; - default: + printf ("Unsupported return type: %s\n", AcpiUtGetObjectTypeName (ObjDesc)); break; @@ -536,27 +534,32 @@ OpcUpdateIntegerNode ( switch (Op->Asl.AmlLength) { case 1: + TrUpdateNode (PARSEOP_BYTECONST, Op); Op->Asl.AmlOpcode = AML_RAW_DATA_BYTE; break; case 2: + TrUpdateNode (PARSEOP_WORDCONST, Op); Op->Asl.AmlOpcode = AML_RAW_DATA_WORD; break; case 4: + TrUpdateNode (PARSEOP_DWORDCONST, Op); Op->Asl.AmlOpcode = AML_RAW_DATA_DWORD; break; case 8: + TrUpdateNode (PARSEOP_QWORDCONST, Op); Op->Asl.AmlOpcode = AML_RAW_DATA_QWORD; break; case 0: default: + OpcSetOptimalIntegerSize (Op); TrUpdateNode (PARSEOP_INTEGER, Op); break; diff --git a/source/compiler/aslglobal.h b/source/compiler/aslglobal.h index c15c669..e1be4ae 100644 --- a/source/compiler/aslglobal.h +++ b/source/compiler/aslglobal.h @@ -110,6 +110,7 @@ extern char *AslCompilertext; #define ASL_DEFAULT_LINE_BUFFER_SIZE (1024 * 32) /* 32K */ #define ASL_MSG_BUFFER_SIZE 4096 +#define ASL_MAX_DISABLED_MESSAGES 32 #define HEX_TABLE_LINE_SIZE 8 #define HEX_LISTING_LINE_SIZE 8 @@ -224,6 +225,7 @@ ASL_EXTERN char *Gbl_TemplateSignature; ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentHexColumn, 0); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentAmlOffset, 0); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentLine, 0); +ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_DisabledMessagesIndex, 0); ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_HexBytesWereWritten, FALSE); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_NumNamespaceObjects, 0); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_ReservedMethods, 0); @@ -250,6 +252,7 @@ ASL_EXTERN UINT8 Gbl_AmlBuffer[HEX_LISTING_LINE_SIZE]; ASL_EXTERN char MsgBuffer[ASL_MSG_BUFFER_SIZE]; ASL_EXTERN char StringBuffer[ASL_MSG_BUFFER_SIZE]; ASL_EXTERN char StringBuffer2[ASL_MSG_BUFFER_SIZE]; +ASL_EXTERN UINT32 Gbl_DisabledMessages[ASL_MAX_DISABLED_MESSAGES]; #endif /* __ASLGLOBAL_H */ diff --git a/source/compiler/aslhex.c b/source/compiler/aslhex.c index 863c0a3..cc2ba6f 100644 --- a/source/compiler/aslhex.c +++ b/source/compiler/aslhex.c @@ -107,7 +107,9 @@ HxDoHexOutput ( break; default: + /* No other output types supported */ + break; } } diff --git a/source/compiler/asllength.c b/source/compiler/asllength.c index fae6768..69d4d22 100644 --- a/source/compiler/asllength.c +++ b/source/compiler/asllength.c @@ -258,6 +258,7 @@ CgGenerateAmlOpcodeLength ( break; default: + /* All data opcodes must be above */ break; } @@ -326,6 +327,7 @@ CgGenerateAmlLengths ( return; default: + break; } diff --git a/source/compiler/asllisting.c b/source/compiler/asllisting.c index 04c5179..c8e2a6e 100644 --- a/source/compiler/asllisting.c +++ b/source/compiler/asllisting.c @@ -157,6 +157,8 @@ LsGenerateListing ( if (FileId == ASL_FILE_C_OFFSET_OUTPUT) { + Gbl_CurrentAmlOffset = 0; + /* Offset table file has a special header and footer */ LsDoOffsetTableHeader (FileId); @@ -265,9 +267,10 @@ LsTreeWriteWalk ( DbgPrint (ASL_TREE_OUTPUT, "%5.5d [%2d]", Op->Asl.LogicalLineNumber, Level); + UtPrintFormattedName (Op->Asl.ParseOpcode, Level); - DbgPrint (ASL_TREE_OUTPUT, "\n"); + DbgPrint (ASL_TREE_OUTPUT, " (%.4X)\n", Op->Asl.ParseOpcode); return (AE_OK); } @@ -319,16 +322,20 @@ LsWriteNodeToListing ( break; default: + switch (OpClass) { case AML_CLASS_NAMED_OBJECT: + switch (Op->Asl.AmlOpcode) { case AML_SCOPE_OP: case AML_ALIAS_OP: + break; default: + if (Op->Asl.ExternalName) { LsFlushListingBuffer (FileId); @@ -339,7 +346,9 @@ LsWriteNodeToListing ( break; default: + /* Don't care about other objects */ + break; } break; @@ -427,7 +436,9 @@ LsWriteNodeToListing ( default: + /* All other opcodes have an AML opcode */ + break; } @@ -443,7 +454,6 @@ LsWriteNodeToListing ( break; - case AML_CLASS_NAMED_OBJECT: switch (Op->Asl.AmlOpcode) @@ -451,7 +461,6 @@ LsWriteNodeToListing ( case AML_FIELD_OP: case AML_INDEX_FIELD_OP: case AML_BANK_FIELD_OP: - /* * For fields, we want to dump all the AML after the * entire definition @@ -479,6 +488,7 @@ LsWriteNodeToListing ( break; default: + LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber, FileId); break; @@ -503,7 +513,6 @@ LsWriteNodeToListing ( case ASL_FILE_C_SOURCE_OUTPUT: case ASL_FILE_ASM_INCLUDE_OUTPUT: case ASL_FILE_C_INCLUDE_OUTPUT: - /* * For named objects, we will create a valid symbol so that the * AML code can be referenced from C or ASM @@ -558,7 +567,9 @@ LsWriteNodeToListing ( break; default: + /* Nothing to do for listing file */ + break; } } @@ -579,6 +590,7 @@ LsWriteNodeToListing ( break; case AML_CLASS_UNKNOWN: + break; } } diff --git a/source/compiler/asllistsup.c b/source/compiler/asllistsup.c index 4156dcc..d3bf39f 100644 --- a/source/compiler/asllistsup.c +++ b/source/compiler/asllistsup.c @@ -251,7 +251,9 @@ LsWriteListingHexBytes ( break; default: + /* No other types supported */ + return; } } @@ -617,7 +619,9 @@ LsFlushListingBuffer ( break; default: + /* No other types supported */ + return; } diff --git a/source/compiler/aslload.c b/source/compiler/aslload.c index e581df2..7f3ce1d 100644 --- a/source/compiler/aslload.c +++ b/source/compiler/aslload.c @@ -177,7 +177,9 @@ LdLoadFieldElements ( break; default: + /* No other opcodes should arrive here */ + return (AE_BAD_PARAMETER); } @@ -374,6 +376,7 @@ LdNamespace1Begin ( default: /* All other opcodes go below */ + break; } @@ -422,7 +425,6 @@ LdNamespace1Begin ( case PARSEOP_EXTERNAL: - /* * "External" simply enters a name and type into the namespace. * We must be careful to not open a new scope, however, no matter @@ -466,7 +468,6 @@ LdNamespace1Begin ( case PARSEOP_SCOPE: - /* * The name referenced by Scope(Name) must already exist at this point. * In other words, forward references for Scope() are not supported. @@ -521,7 +522,6 @@ LdNamespace1Begin ( case ACPI_TYPE_INTEGER: case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: - /* * These types we will allow, but we will change the type. * This enables some existing code of the form: diff --git a/source/compiler/asllookup.c b/source/compiler/asllookup.c index 7db805f..e965f18 100644 --- a/source/compiler/asllookup.c +++ b/source/compiler/asllookup.c @@ -144,9 +144,11 @@ LkIsObjectUsed ( case ACPI_TYPE_PROCESSOR: case ACPI_TYPE_POWER: case ACPI_TYPE_LOCAL_RESOURCE: + return (AE_OK); default: + break; } diff --git a/source/compiler/aslmain.c b/source/compiler/aslmain.c index 4cc63fa..a75a6fd 100644 --- a/source/compiler/aslmain.c +++ b/source/compiler/aslmain.c @@ -41,7 +41,6 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #define _DECLARE_GLOBALS #include "aslcompiler.h" @@ -49,26 +48,11 @@ #include "acdisasm.h" #include <signal.h> -#ifdef _DEBUG -#include <crtdbg.h> -#endif - #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslmain") -/* Local prototypes */ - -static void -Options ( - void); - -static void -FilenameHelp ( - void); -static void -Usage ( - void); +/* Local prototypes */ static void ACPI_SYSTEM_XFACE AslSignalHandler ( @@ -78,34 +62,10 @@ static void AslInitialize ( void); -static int -AslCommandLine ( - int argc, - char **argv); - -static int -AslDoOptions ( - int argc, - char **argv, - BOOLEAN IsResponseFile); - -static void -AslMergeOptionTokens ( - char *InBuffer, - char *OutBuffer); - -static int -AslDoResponseFile ( - char *Filename); - - -#define ASL_TOKEN_SEPARATORS " \t\n" -#define ASL_SUPPORTED_OPTIONS "@:b|c|d^D:e:fgh^i|I:l^m:no|p:P^r:s|t|T:G^v^w|x:z" - /******************************************************************************* * - * FUNCTION: Options + * FUNCTION: Usage * * PARAMETERS: None * @@ -116,10 +76,12 @@ AslDoResponseFile ( * ******************************************************************************/ -static void -Options ( +void +Usage ( void) { + printf ("%s\n\n", ASL_COMPLIANCE); + ACPI_USAGE_HEADER ("iasl [Options] [Files]"); printf ("\nGlobal:\n"); ACPI_OPTION ("-@ <file>", "Specify command file"); @@ -140,6 +102,7 @@ Options ( ACPI_OPTION ("-vo", "Enable optimization comments"); ACPI_OPTION ("-vr", "Disable remarks"); ACPI_OPTION ("-vs", "Disable signon"); + ACPI_OPTION ("-vw <messageid>", "Disable specific warning or remark"); ACPI_OPTION ("-w1 -w2 -w3", "Set warning reporting level"); ACPI_OPTION ("-we", "Report warnings as errors"); @@ -209,8 +172,8 @@ Options ( * ******************************************************************************/ -static void -FilenameHelp ( +void +AslFilenameHelp ( void) { @@ -225,29 +188,6 @@ FilenameHelp ( } -/******************************************************************************* - * - * FUNCTION: Usage - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Display usage and option message - * - ******************************************************************************/ - -static void -Usage ( - void) -{ - - printf ("%s\n\n", ASL_COMPLIANCE); - ACPI_USAGE_HEADER ("iasl [Options] [Files]"); - Options (); -} - - /****************************************************************************** * * FUNCTION: AslSignalHandler @@ -310,11 +250,6 @@ AslInitialize ( UINT32 i; -#ifdef _DEBUG - _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CrtSetDbgFlag(0)); -#endif - - for (i = 0; i < ASL_NUM_FILES; i++) { Gbl_Files[i].Handle = NULL; @@ -326,675 +261,6 @@ AslInitialize ( Gbl_Files[ASL_FILE_STDERR].Handle = stderr; Gbl_Files[ASL_FILE_STDERR].Filename = "STDERR"; - - /* Allocate the line buffer(s) */ - - Gbl_LineBufferSize /= 2; - UtExpandLineBuffers (); -} - - -/******************************************************************************* - * - * FUNCTION: AslMergeOptionTokens - * - * PARAMETERS: InBuffer - Input containing an option string - * OutBuffer - Merged output buffer - * - * RETURN: None - * - * DESCRIPTION: Remove all whitespace from an option string. - * - ******************************************************************************/ - -static void -AslMergeOptionTokens ( - char *InBuffer, - char *OutBuffer) -{ - char *Token; - - - *OutBuffer = 0; - - Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS); - while (Token) - { - strcat (OutBuffer, Token); - Token = strtok (NULL, ASL_TOKEN_SEPARATORS); - } -} - - -/******************************************************************************* - * - * FUNCTION: AslDoResponseFile - * - * PARAMETERS: Filename - Name of the response file - * - * RETURN: Status - * - * DESCRIPTION: Open a response file and process all options within. - * - ******************************************************************************/ - -static int -AslDoResponseFile ( - char *Filename) -{ - char *argv = StringBuffer2; - FILE *ResponseFile; - int OptStatus = 0; - int Opterr; - int Optind; - - - ResponseFile = fopen (Filename, "r"); - if (!ResponseFile) - { - printf ("Could not open command file %s, %s\n", - Filename, strerror (errno)); - return (-1); - } - - /* Must save the current GetOpt globals */ - - Opterr = AcpiGbl_Opterr; - Optind = AcpiGbl_Optind; - - /* - * Process all lines in the response file. There must be one complete - * option per line - */ - while (fgets (StringBuffer, ASL_MSG_BUFFER_SIZE, ResponseFile)) - { - /* Compress all tokens, allowing us to use a single argv entry */ - - AslMergeOptionTokens (StringBuffer, StringBuffer2); - - /* Process the option */ - - AcpiGbl_Opterr = 0; - AcpiGbl_Optind = 0; - - OptStatus = AslDoOptions (1, &argv, TRUE); - if (OptStatus) - { - printf ("Invalid option in command file %s: %s\n", - Filename, StringBuffer); - break; - } - } - - /* Restore the GetOpt globals */ - - AcpiGbl_Opterr = Opterr; - AcpiGbl_Optind = Optind; - - fclose (ResponseFile); - return (OptStatus); -} - - -/******************************************************************************* - * - * FUNCTION: AslDoOptions - * - * PARAMETERS: argc/argv - Standard argc/argv - * IsResponseFile - TRUE if executing a response file. - * - * RETURN: Status - * - * DESCRIPTION: Command line option processing - * - ******************************************************************************/ - -static int -AslDoOptions ( - int argc, - char **argv, - BOOLEAN IsResponseFile) -{ - int j; - ACPI_STATUS Status; - - - /* Get the command line options */ - - while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != EOF) switch (j) - { - case '@': /* Begin a response file */ - - if (IsResponseFile) - { - printf ("Nested command files are not supported\n"); - return (-1); - } - - if (AslDoResponseFile (AcpiGbl_Optarg)) - { - return (-1); - } - break; - - - case 'b': /* Debug output options */ - switch (AcpiGbl_Optarg[0]) - { - case 'f': - AslCompilerdebug = 1; /* same as yydebug */ - DtParserdebug = 1; - PrParserdebug = 1; - break; - - case 't': - break; - - default: - printf ("Unknown option: -b%s\n", AcpiGbl_Optarg); - return (-1); - } - - /* Produce debug output file */ - - Gbl_DebugFlag = TRUE; - break; - - - case 'c': - switch (AcpiGbl_Optarg[0]) - { - case 'r': - Gbl_NoResourceChecking = TRUE; - break; - - default: - printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); - return (-1); - } - break; - - - case 'd': /* Disassembler */ - switch (AcpiGbl_Optarg[0]) - { - case '^': - Gbl_DoCompile = FALSE; - break; - - case 'a': - Gbl_DoCompile = FALSE; - Gbl_DisassembleAll = TRUE; - break; - - case 'b': /* Do not convert buffers to resource descriptors */ - AcpiGbl_NoResourceDisassembly = TRUE; - break; - - case 'c': - break; - - default: - printf ("Unknown option: -d%s\n", AcpiGbl_Optarg); - return (-1); - } - - Gbl_DisasmFlag = TRUE; - break; - - - case 'D': /* Define a symbol */ - PrAddDefine (AcpiGbl_Optarg, NULL, TRUE); - break; - - - case 'e': /* External files for disassembler */ - Status = AcpiDmAddToExternalFileList (AcpiGbl_Optarg); - if (ACPI_FAILURE (Status)) - { - printf ("Could not add %s to external list\n", AcpiGbl_Optarg); - return (-1); - } - break; - - - case 'f': /* Ignore errors and force creation of aml file */ - Gbl_IgnoreErrors = TRUE; - break; - - - case 'G': - Gbl_CompileGeneric = TRUE; - break; - - - case 'g': /* Get all ACPI tables */ - - Gbl_GetAllTables = TRUE; - Gbl_DoCompile = FALSE; - break; - - - case 'h': - switch (AcpiGbl_Optarg[0]) - { - case '^': - Usage (); - exit (0); - - case 'c': - UtDisplayConstantOpcodes (); - exit (0); - - case 'f': - FilenameHelp (); - exit (0); - - case 'r': - /* reserved names */ - - ApDisplayReservedNames (); - exit (0); - - case 't': - UtDisplaySupportedTables (); - exit (0); - - default: - printf ("Unknown option: -h%s\n", AcpiGbl_Optarg); - return (-1); - } - - - case 'I': /* Add an include file search directory */ - FlAddIncludeDirectory (AcpiGbl_Optarg); - break; - - - case 'i': /* Output AML as an include file */ - switch (AcpiGbl_Optarg[0]) - { - case 'a': - - /* Produce assembly code include file */ - - Gbl_AsmIncludeOutputFlag = TRUE; - break; - - case 'c': - - /* Produce C include file */ - - Gbl_C_IncludeOutputFlag = TRUE; - break; - - case 'n': - - /* Compiler/Disassembler: Ignore the NOOP operator */ - - AcpiGbl_IgnoreNoopOperator = TRUE; - break; - - default: - printf ("Unknown option: -i%s\n", AcpiGbl_Optarg); - return (-1); - } - break; - - - case 'l': /* Listing files */ - switch (AcpiGbl_Optarg[0]) - { - case '^': - /* Produce listing file (Mixed source/aml) */ - - Gbl_ListingFlag = TRUE; - break; - - case 'i': - /* Produce preprocessor output file */ - - Gbl_PreprocessorOutputFlag = TRUE; - break; - - case 'n': - /* Produce namespace file */ - - Gbl_NsOutputFlag = TRUE; - break; - - case 's': - /* Produce combined source file */ - - Gbl_SourceOutputFlag = TRUE; - break; - - default: - printf ("Unknown option: -l%s\n", AcpiGbl_Optarg); - return (-1); - } - break; - - - 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; - - - case 'n': /* Parse only */ - Gbl_ParseOnlyFlag = TRUE; - break; - - - case 'o': /* Control compiler AML optimizations */ - switch (AcpiGbl_Optarg[0]) - { - case 'a': - - /* Disable all optimizations */ - - Gbl_FoldConstants = FALSE; - Gbl_IntegerOptimizationFlag = FALSE; - Gbl_ReferenceOptimizationFlag = FALSE; - break; - - case 'f': - - /* Disable folding on "normal" expressions */ - - Gbl_FoldConstants = FALSE; - break; - - case 'i': - - /* Disable integer optimization to constants */ - - Gbl_IntegerOptimizationFlag = FALSE; - break; - - case 'n': - - /* Disable named reference optimization */ - - Gbl_ReferenceOptimizationFlag = FALSE; - break; - - case 't': - - /* Display compile time(s) */ - - Gbl_CompileTimesFlag = TRUE; - break; - - default: - printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); - return (-1); - } - break; - - - case 'P': /* Preprocessor options */ - switch (AcpiGbl_Optarg[0]) - { - case '^': /* Proprocess only, emit (.i) file */ - Gbl_PreprocessOnly = TRUE; - Gbl_PreprocessorOutputFlag = TRUE; - break; - - case 'n': /* Disable preprocessor */ - Gbl_PreprocessFlag = FALSE; - break; - - default: - printf ("Unknown option: -P%s\n", AcpiGbl_Optarg); - return (-1); - } - break; - - - case 'p': /* Override default AML output filename */ - Gbl_OutputFilenamePrefix = AcpiGbl_Optarg; - Gbl_UseDefaultAmlFilename = FALSE; - break; - - - case 'r': /* Override revision found in table header */ - Gbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); - break; - - - case 's': /* Create AML in a source code file */ - switch (AcpiGbl_Optarg[0]) - { - case 'a': - - /* Produce assembly code output file */ - - Gbl_AsmOutputFlag = TRUE; - break; - - case 'c': - - /* Produce C hex output file */ - - Gbl_C_OutputFlag = TRUE; - break; - - case 'o': - - /* Produce AML offset table in C */ - - Gbl_C_OffsetTableFlag = TRUE; - break; - - default: - printf ("Unknown option: -s%s\n", AcpiGbl_Optarg); - return (-1); - } - break; - - - case 't': /* Produce hex table output file */ - switch (AcpiGbl_Optarg[0]) - { - case 'a': - Gbl_HexOutputFlag = HEX_OUTPUT_ASM; - break; - - case 'c': - Gbl_HexOutputFlag = HEX_OUTPUT_C; - break; - - case 's': - Gbl_HexOutputFlag = HEX_OUTPUT_ASL; - break; - - default: - printf ("Unknown option: -t%s\n", AcpiGbl_Optarg); - return (-1); - } - break; - - - case 'T': /* Create a ACPI table template file */ - Gbl_DoTemplates = TRUE; - Gbl_TemplateSignature = AcpiGbl_Optarg; - break; - - - case 'v': /* Version and verbosity settings */ - switch (AcpiGbl_Optarg[0]) - { - case '^': - printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); - exit (0); - - case 'a': - /* Disable All error/warning messages */ - - Gbl_NoErrors = TRUE; - break; - - case 'i': - /* - * Support for integrated development environment(s). - * - * 1) No compiler signon - * 2) Send stderr messages to stdout - * 3) Less verbose error messages (single line only for each) - * 4) Error/warning messages are formatted appropriately to - * be recognized by MS Visual Studio - */ - Gbl_VerboseErrors = FALSE; - Gbl_DoSignon = FALSE; - Gbl_Files[ASL_FILE_STDERR].Handle = stdout; - break; - - case 'o': - Gbl_DisplayOptimizations = TRUE; - break; - - case 'r': - Gbl_DisplayRemarks = FALSE; - break; - - case 's': - Gbl_DoSignon = FALSE; - break; - - case 't': - Gbl_VerboseTemplates = TRUE; - break; - - default: - printf ("Unknown option: -v%s\n", AcpiGbl_Optarg); - return (-1); - } - break; - - - case 'w': /* Set warning levels */ - switch (AcpiGbl_Optarg[0]) - { - case '1': - Gbl_WarningLevel = ASL_WARNING; - break; - - case '2': - Gbl_WarningLevel = ASL_WARNING2; - break; - - case '3': - Gbl_WarningLevel = ASL_WARNING3; - break; - - case 'e': - Gbl_WarningsAsErrors = TRUE; - break; - - default: - printf ("Unknown option: -w%s\n", AcpiGbl_Optarg); - return (-1); - } - break; - - - case 'x': /* Set debug print output level */ - AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16); - break; - - - case 'z': - Gbl_UseOriginalCompilerId = TRUE; - break; - - - default: - return (-1); - } - - return (0); -} - - -/******************************************************************************* - * - * FUNCTION: AslCommandLine - * - * PARAMETERS: argc/argv - * - * RETURN: Last argv index - * - * DESCRIPTION: Command line processing - * - ******************************************************************************/ - -static int -AslCommandLine ( - int argc, - char **argv) -{ - int BadCommandLine = 0; - ACPI_STATUS Status; - - - /* Minimum command line contains at least the command and an input file */ - - if (argc < 2) - { - printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); - Usage (); - exit (1); - } - - /* Process all command line options */ - - BadCommandLine = AslDoOptions (argc, argv, FALSE); - - if (Gbl_DoTemplates) - { - Status = DtCreateTemplates (Gbl_TemplateSignature); - if (ACPI_FAILURE (Status)) - { - exit (-1); - } - exit (1); - } - - /* Next parameter must be the input filename */ - - if (!argv[AcpiGbl_Optind] && - !Gbl_DisasmFlag && - !Gbl_GetAllTables) - { - printf ("Missing input filename\n"); - BadCommandLine = TRUE; - } - - if (Gbl_DoSignon) - { - printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); - if (Gbl_IgnoreErrors) - { - printf ("Ignoring all errors, forcing AML file generation\n\n"); - } - } - - /* Abort if anything went wrong on the command line */ - - if (BadCommandLine) - { - printf ("\n"); - Usage (); - exit (1); - } - - return (AcpiGbl_Optind); } @@ -1021,24 +287,24 @@ main ( int Index2; - signal (SIGINT, AslSignalHandler); + ACPI_DEBUG_INITIALIZE (); /* For debug version only */ + /* Initialize preprocessor and compiler before command line processing */ + + signal (SIGINT, AslSignalHandler); AcpiGbl_ExternalFileList = NULL; AcpiDbgLevel = 0; - -#ifdef _DEBUG - _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF | - _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)); -#endif - - /* Init and command line */ + PrInitializePreprocessor (); + AslInitialize (); Index1 = Index2 = AslCommandLine (argc, argv); - AslInitialize (); - PrInitializePreprocessor (); + /* Allocate the line buffer(s), must be after command line */ + + Gbl_LineBufferSize /= 2; + UtExpandLineBuffers (); - /* Options that have no additional parameters or pathnames */ + /* Perform global actions first/only */ if (Gbl_GetAllTables) { diff --git a/source/compiler/aslmessages.h b/source/compiler/aslmessages.h index 102148d..a104a44 100644 --- a/source/compiler/aslmessages.h +++ b/source/compiler/aslmessages.h @@ -46,17 +46,52 @@ #define __ASLMESSAGES_H -#define ASL_WARNING 0 -#define ASL_WARNING2 1 -#define ASL_WARNING3 2 -#define ASL_ERROR 3 -#define ASL_REMARK 4 -#define ASL_OPTIMIZATION 5 -#define ASL_NUM_REPORT_LEVELS 6 +typedef enum +{ + ASL_OPTIMIZATION = 0, + ASL_REMARK, + ASL_WARNING, + ASL_WARNING2, + ASL_WARNING3, + ASL_ERROR, + ASL_NUM_REPORT_LEVELS + +} ASL_MESSAGE_TYPES; + +#ifdef ASL_EXCEPTIONS + +/* Strings for message reporting levels, must match values above */ +const char *AslErrorLevel [ASL_NUM_REPORT_LEVELS] = { + "Optimize", + "Remark ", + "Warning ", + "Warning ", + "Warning ", + "Error " +}; -/* Values for all compiler messages */ +/* All lowercase versions for IDEs */ +const char *AslErrorLevelIde [ASL_NUM_REPORT_LEVELS] = { + "optimize", + "remark ", + "warning ", + "warning ", + "warning ", + "error " +}; + +#define ASL_ERROR_LEVEL_LENGTH 8 /* Length of strings above */ +#endif + +/* + * Values for all compiler messages. + * + * NOTE: With the introduction of the -vw option to disable specific messages, + * new messages should only be added to the end of this list, so that values + * for existing messages are not disturbed. + */ typedef enum { ASL_MSG_RESERVED = 0, @@ -180,6 +215,7 @@ typedef enum ASL_MSG_SCOPE_TYPE, ASL_MSG_SEEK, ASL_MSG_SERIALIZED, + ASL_MSG_SERIALIZED_REQUIRED, ASL_MSG_SINGLE_NAME_OPTIMIZATION, ASL_MSG_SOME_NO_RETVAL, ASL_MSG_STRING_LENGTH, @@ -235,9 +271,15 @@ typedef enum #ifdef ASL_EXCEPTIONS -/* Actual message strings for each compiler message */ - -char *AslMessages [] = { +/* + * Actual message strings for each compiler message. + * + * NOTE: With the introduction of the -vw option to disable specific messages, + * new messages should only be added to the end of this list, so that values + * for existing messages are not disturbed. + */ +char *AslMessages [] = +{ /* The zeroth message is reserved */ "", /* ASL_MSG_ALIGNMENT */ "Must be a multiple of alignment/granularity value", /* ASL_MSG_ALPHANUMERIC_STRING */ "String must be entirely alphanumeric", @@ -358,6 +400,7 @@ char *AslMessages [] = { /* ASL_MSG_SCOPE_TYPE */ "Existing object has invalid type for Scope operator", /* ASL_MSG_SEEK */ "Could not seek file", /* ASL_MSG_SERIALIZED */ "Control Method marked Serialized", +/* ASL_MSG_SERIALIZED_REQUIRED */ "Control Method should be made Serialized", /* ASL_MSG_SINGLE_NAME_OPTIMIZATION */ "NamePath optimized to NameSeg (uses run-time search path)", /* ASL_MSG_SOME_NO_RETVAL */ "Called method may not always return a value", /* ASL_MSG_STRING_LENGTH */ "String literal too long", @@ -408,27 +451,6 @@ char *AslMessages [] = { /* ASL_MSG_ZERO_VALUE */ "Value must be non-zero" }; - -const char *AslErrorLevel [ASL_NUM_REPORT_LEVELS] = { - "Warning ", - "Warning ", - "Warning ", - "Error ", - "Remark ", - "Optimize" -}; - -const char *AslErrorLevelIde [ASL_NUM_REPORT_LEVELS] = { - "warning ", - "warning ", - "warning ", - "error ", - "remark ", - "optimize" -}; - -#define ASL_ERROR_LEVEL_LENGTH 8 /* Length of strings above */ - #endif /* ASL_EXCEPTIONS */ #endif /* __ASLMESSAGES_H */ diff --git a/source/compiler/aslmethod.c b/source/compiler/aslmethod.c index f191991..94e73d3 100644 --- a/source/compiler/aslmethod.c +++ b/source/compiler/aslmethod.c @@ -44,12 +44,22 @@ #include "aslcompiler.h" #include "aslcompiler.y.h" +#include "acparser.h" +#include "amlcode.h" #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslmethod") +/* Local prototypes */ + +void +MtCheckNamedObjectInMethod ( + ACPI_PARSE_OBJECT *Op, + ASL_METHOD_INFO *MethodInfo); + + /******************************************************************************* * * FUNCTION: MtMethodAnalysisWalkBegin @@ -111,6 +121,8 @@ MtMethodAnalysisWalkBegin ( /* Get the SerializeRule and SyncLevel nodes, ignored here */ Next = Next->Asl.Next; + MethodInfo->ShouldBeSerialized = (UINT8) Next->Asl.Value.Integer; + Next = Next->Asl.Next; ArgNode = Next; @@ -181,7 +193,6 @@ MtMethodAnalysisWalkBegin ( } break; - case PARSEOP_METHODCALL: if (MethodInfo && @@ -191,7 +202,6 @@ MtMethodAnalysisWalkBegin ( } break; - case PARSEOP_LOCAL0: case PARSEOP_LOCAL1: case PARSEOP_LOCAL2: @@ -236,7 +246,6 @@ MtMethodAnalysisWalkBegin ( } break; - case PARSEOP_ARG0: case PARSEOP_ARG1: case PARSEOP_ARG2: @@ -287,7 +296,6 @@ MtMethodAnalysisWalkBegin ( } break; - case PARSEOP_RETURN: if (!MethodInfo) @@ -320,7 +328,6 @@ MtMethodAnalysisWalkBegin ( } break; - case PARSEOP_BREAK: case PARSEOP_CONTINUE: @@ -340,7 +347,6 @@ MtMethodAnalysisWalkBegin ( } break; - case PARSEOP_STALL: /* We can range check if the argument is an integer */ @@ -352,7 +358,6 @@ MtMethodAnalysisWalkBegin ( } break; - case PARSEOP_DEVICE: case PARSEOP_EVENT: case PARSEOP_MUTEX: @@ -372,7 +377,6 @@ MtMethodAnalysisWalkBegin ( } break; - case PARSEOP_NAME: /* Typecheck any predefined names statically defined with Name() */ @@ -410,17 +414,76 @@ MtMethodAnalysisWalkBegin ( } break; - default: + break; } + /* Check for named object creation within a non-serialized method */ + + MtCheckNamedObjectInMethod (Op, MethodInfo); return (AE_OK); } /******************************************************************************* * + * FUNCTION: MtCheckNamedObjectInMethod + * + * PARAMETERS: Op - Current parser op + * MethodInfo - Info for method being parsed + * + * RETURN: None + * + * DESCRIPTION: Detect if a non-serialized method is creating a named object, + * which could possibly cause problems if two threads execute + * the method concurrently. Emit a remark in this case. + * + ******************************************************************************/ + +void +MtCheckNamedObjectInMethod ( + ACPI_PARSE_OBJECT *Op, + ASL_METHOD_INFO *MethodInfo) +{ + const ACPI_OPCODE_INFO *OpInfo; + + + /* We don't care about actual method declarations */ + + if (Op->Asl.AmlOpcode == AML_METHOD_OP) + { + return; + } + + /* Determine if we are creating a named object */ + + OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); + if (OpInfo->Class == AML_CLASS_NAMED_OBJECT) + { + /* + * If we have a named object created within a non-serialized method, + * emit a remark that the method should be serialized. + * + * Reason: If a thread blocks within the method for any reason, and + * another thread enters the method, the method will fail because an + * attempt will be made to create the same object twice. + */ + if (MethodInfo && !MethodInfo->ShouldBeSerialized) + { + AslError (ASL_REMARK, ASL_MSG_SERIALIZED_REQUIRED, MethodInfo->Op, + "due to creation of named objects within"); + + /* Emit message only ONCE per method */ + + MethodInfo->ShouldBeSerialized = TRUE; + } + } +} + + +/******************************************************************************* + * * FUNCTION: MtMethodAnalysisWalkEnd * * PARAMETERS: ASL_WALK_CALLBACK @@ -446,6 +509,7 @@ MtMethodAnalysisWalkEnd ( { case PARSEOP_METHOD: case PARSEOP_RETURN: + if (!MethodInfo) { printf ("No method info for method! [%s]\n", Op->Asl.Namepath); @@ -458,6 +522,7 @@ MtMethodAnalysisWalkEnd ( break; default: + break; } @@ -534,7 +599,6 @@ MtMethodAnalysisWalkEnd ( ACPI_FREE (MethodInfo); break; - case PARSEOP_NAME: /* Special check for two names like _L01 and _E01 in same scope */ @@ -542,7 +606,6 @@ MtMethodAnalysisWalkEnd ( ApCheckForGpeNameConflict (Op); break; - case PARSEOP_RETURN: /* @@ -572,7 +635,6 @@ MtMethodAnalysisWalkEnd ( } break; - case PARSEOP_IF: if ((Op->Asl.CompileFlags & NODE_HAS_NO_EXIT) && @@ -588,7 +650,6 @@ MtMethodAnalysisWalkEnd ( } break; - case PARSEOP_ELSE: if ((Op->Asl.CompileFlags & NODE_HAS_NO_EXIT) && diff --git a/source/compiler/aslnamesp.c b/source/compiler/aslnamesp.c index 724f830..3fc5f39 100644 --- a/source/compiler/aslnamesp.c +++ b/source/compiler/aslnamesp.c @@ -194,7 +194,6 @@ NsDoOneNamespaceObject ( ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); break; - case ACPI_TYPE_STRING: FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, @@ -203,7 +202,9 @@ NsDoOneNamespaceObject ( break; default: + /* Nothing to do for other types */ + break; } @@ -228,7 +229,6 @@ NsDoOneNamespaceObject ( ACPI_FORMAT_UINT64 (Op->Asl.Value.Integer)); break; - case ACPI_TYPE_STRING: if (Op->Asl.ParseOpcode == PARSEOP_NAME) @@ -245,7 +245,6 @@ NsDoOneNamespaceObject ( Op->Asl.Value.String); break; - case ACPI_TYPE_LOCAL_REGION_FIELD: if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || @@ -258,42 +257,47 @@ NsDoOneNamespaceObject ( Op->Asl.Parent->Asl.ExtraValue, (UINT32) Op->Asl.Value.Integer); break; - case ACPI_TYPE_BUFFER_FIELD: switch (Op->Asl.ParseOpcode) { case PARSEOP_CREATEBYTEFIELD: + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [BYTE ( 8 bit)]"); break; case PARSEOP_CREATEDWORDFIELD: + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [DWORD (32 bit)]"); break; case PARSEOP_CREATEQWORDFIELD: + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [QWORD (64 bit)]"); break; case PARSEOP_CREATEWORDFIELD: + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [WORD (16 bit)]"); break; case PARSEOP_CREATEBITFIELD: + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [BIT ( 1 bit)]"); break; case PARSEOP_CREATEFIELD: + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [Arbitrary Bit Field]"); break; default: + break; } break; - case ACPI_TYPE_PACKAGE: if (Op->Asl.ParseOpcode == PARSEOP_NAME) @@ -316,7 +320,6 @@ NsDoOneNamespaceObject ( } break; - case ACPI_TYPE_BUFFER: if (Op->Asl.ParseOpcode == PARSEOP_NAME) @@ -338,7 +341,6 @@ NsDoOneNamespaceObject ( } break; - case ACPI_TYPE_METHOD: FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, @@ -346,14 +348,12 @@ NsDoOneNamespaceObject ( Op->Asl.AmlSubtreeLength); break; - case ACPI_TYPE_LOCAL_RESOURCE: FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [Desc Offset 0x%.4X Bytes]", Node->Value); break; - case ACPI_TYPE_LOCAL_RESOURCE_FIELD: FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, @@ -372,9 +372,10 @@ NsDoOneNamespaceObject ( } break; - default: + /* Nothing to do for other types */ + break; } } diff --git a/source/compiler/asloffset.c b/source/compiler/asloffset.c index 190b92a..25e5b0f 100644 --- a/source/compiler/asloffset.c +++ b/source/compiler/asloffset.c @@ -58,7 +58,6 @@ LsEmitOffsetTableEntry ( UINT32 FileId, ACPI_NAMESPACE_NODE *Node, UINT32 Offset, - UINT32 Length, char *OpName, UINT64 Value, UINT8 AmlOpcode); @@ -77,7 +76,9 @@ LsEmitOffsetTableEntry ( * Three types of objects are currently emitted to the offset table: * 1) Tagged (named) resource descriptors * 2) Named integer objects with constant integer values - * 3) Operation Regions that have constant Offset (address) parameters + * 3) Named package objects + * 4) Operation Regions that have constant Offset (address) parameters + * 5) Control methods * * The offset table allows the BIOS to dynamically update the values of these * objects at boot time. @@ -94,7 +95,7 @@ LsAmlOffsetWalk ( ACPI_NAMESPACE_NODE *Node; UINT32 Length; UINT32 OffsetOfOpcode; - ACPI_PARSE_OBJECT *AddressOp; + ACPI_PARSE_OBJECT *NextOp; /* Ignore actual data blocks for resource descriptors */ @@ -119,13 +120,17 @@ LsAmlOffsetWalk ( (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC)) { LsEmitOffsetTableEntry (FileId, Node, Gbl_CurrentAmlOffset, - Op->Asl.FinalAmlLength, Op->Asl.ParseOpName, 0, Op->Asl.Extra); + Op->Asl.ParseOpName, 0, Op->Asl.Extra); + Gbl_CurrentAmlOffset += Op->Asl.FinalAmlLength; + return (AE_OK); } - /* Named object -- Name (NameString, DataRefObject) */ - - else if (Op->Asl.AmlOpcode == AML_NAME_OP) + switch (Op->Asl.AmlOpcode) { + case AML_NAME_OP: + + /* Named object -- Name (NameString, DataRefObject) */ + if (!Op->Asl.Child) { FlPrintFile (FileId, "%s NO CHILD!\n", MsgBuffer); @@ -154,39 +159,50 @@ LsAmlOffsetWalk ( case AML_DWORD_OP: case AML_QWORD_OP: - /* The +1/-1 is to handle the integer size prefix (opcode) */ + /* The +1 is to handle the integer size prefix (opcode) */ LsEmitOffsetTableEntry (FileId, Node, (Gbl_CurrentAmlOffset + OffsetOfOpcode + 1), - (Op->Asl.FinalAmlLength - 1), Op->Asl.ParseOpName, - Op->Asl.Value.Integer, (UINT8) Op->Asl.AmlOpcode); + Op->Asl.ParseOpName, Op->Asl.Value.Integer, + (UINT8) Op->Asl.AmlOpcode); break; - default: + case AML_PACKAGE_OP: + case AML_VAR_PACKAGE_OP: + + NextOp = Op->Asl.Child; + + LsEmitOffsetTableEntry (FileId, Node, + (Gbl_CurrentAmlOffset + OffsetOfOpcode), + Op->Asl.ParseOpName, + NextOp->Asl.Value.Integer, + (UINT8) Op->Asl.AmlOpcode); break; + + default: + break; } Gbl_CurrentAmlOffset += Length; return (AE_OK); - } - /* OperationRegion (NameString, RegionSpace, RegionOffset, RegionLength) */ + case AML_REGION_OP: + + /* OperationRegion (NameString, RegionSpace, RegionOffset, RegionLength) */ - else if (Op->Asl.AmlOpcode == AML_REGION_OP) - { Length = Op->Asl.FinalAmlLength; /* Get the name/namepath node */ - AddressOp = Op->Asl.Child; - OffsetOfOpcode = Length + AddressOp->Asl.FinalAmlLength + 1; + NextOp = Op->Asl.Child; + OffsetOfOpcode = Length + NextOp->Asl.FinalAmlLength + 1; /* Get the SpaceId node, then the Offset (address) node */ - AddressOp = AddressOp->Asl.Next; - AddressOp = AddressOp->Asl.Next; + NextOp = NextOp->Asl.Next; + NextOp = NextOp->Asl.Next; - switch (AddressOp->Asl.AmlOpcode) + switch (NextOp->Asl.AmlOpcode) { /* * We are only interested in integer constants that can be changed @@ -198,12 +214,10 @@ LsAmlOffsetWalk ( case AML_DWORD_OP: case AML_QWORD_OP: - /* The +1/-1 is to handle the integer size prefix (opcode) */ - LsEmitOffsetTableEntry (FileId, Node, (Gbl_CurrentAmlOffset + OffsetOfOpcode + 1), - (AddressOp->Asl.FinalAmlLength - 1), Op->Asl.ParseOpName, - AddressOp->Asl.Value.Integer, (UINT8) AddressOp->Asl.AmlOpcode); + Op->Asl.ParseOpName, NextOp->Asl.Value.Integer, + (UINT8) NextOp->Asl.AmlOpcode); Gbl_CurrentAmlOffset += Length; return (AE_OK); @@ -211,6 +225,31 @@ LsAmlOffsetWalk ( default: break; } + break; + + case AML_METHOD_OP: + + /* Method (Namepath, ...) */ + + Length = Op->Asl.FinalAmlLength; + + /* Get the NameSeg/NamePath Op */ + + NextOp = Op->Asl.Child; + + /* Point to the *last* nameseg in the namepath */ + + OffsetOfOpcode = NextOp->Asl.FinalAmlLength - ACPI_NAME_SIZE; + + LsEmitOffsetTableEntry (FileId, Node, + (Gbl_CurrentAmlOffset + OffsetOfOpcode + Length), + Op->Asl.ParseOpName, + *((UINT32 *) &NextOp->Asl.Value.Buffer[OffsetOfOpcode]), + (UINT8) Op->Asl.AmlOpcode); + break; + + default: + break; } Gbl_CurrentAmlOffset += Op->Asl.FinalAmlLength; @@ -225,7 +264,6 @@ LsAmlOffsetWalk ( * PARAMETERS: FileId - ID of current listing file * Node - Namespace node associated with the name * Offset - Offset of the value within the AML table - * Length - Length in bytes of the value * OpName - Name of the AML opcode * Value - Current value of the AML field * AmlOpcode - Opcode associated with the field @@ -241,7 +279,6 @@ LsEmitOffsetTableEntry ( UINT32 FileId, ACPI_NAMESPACE_NODE *Node, UINT32 Offset, - UINT32 Length, char *OpName, UINT64 Value, UINT8 AmlOpcode) @@ -293,8 +330,6 @@ LsDoOffsetTableHeader ( UINT32 FileId) { - Gbl_CurrentAmlOffset = 0; - FlPrintFile (FileId, "#ifndef __AML_OFFSET_TABLE_H\n" "#define __AML_OFFSET_TABLE_H\n\n"); @@ -302,14 +337,41 @@ LsDoOffsetTableHeader ( FlPrintFile (FileId, "typedef struct {\n" " char *Pathname;\n" " unsigned long Offset;\n" - " unsigned char AmlOpcode;\n" - " unsigned long long AmlValue;\n" + " unsigned char Opcode;\n" + " unsigned long long Value;\n" "} AML_OFFSET_TABLE_ENTRY;\n\n"); FlPrintFile (FileId, "#endif /* __AML_OFFSET_TABLE_H */\n\n"); FlPrintFile (FileId, + "/*\n" + " * Information about supported object types:\n" + " *\n" + " * Integers:\n" + " * Offset points to the actual integer data\n" + " * Opcode is the integer prefix, indicates length of the data\n" + " * Value is the existing value in the AML\n" + " *\n" + " * Packages:\n" + " * Offset points to the package opcode\n" + " * Opcode is the package or var_package opcode\n" + " * Value is the package element cound\n" + " *\n" + " * Operation Regions:\n" + " * Offset points to the region address data\n" + " * Opcode is the address integer prefix, indicates length of the data\n" + " * Value is the existing address value in the AML\n" + " *\n" + " * Control Methods:\n" + " * Offset points to the first byte of the namepath\n" + " *\n" + " * Resource Descriptors:\n" + " * Offset points to the start of the descriptor\n" + " * Opcode is the descriptor type\n" + " */\n"); + + FlPrintFile (FileId, "AML_OFFSET_TABLE_ENTRY %s_%s_OffsetTable[] =\n{\n", Gbl_TableSignature, Gbl_TableId); } diff --git a/source/compiler/aslopcodes.c b/source/compiler/aslopcodes.c index d3a49f3..332def7 100644 --- a/source/compiler/aslopcodes.c +++ b/source/compiler/aslopcodes.c @@ -266,6 +266,7 @@ OpcSetOptimalIntegerSize ( break; default: + break; } } @@ -811,7 +812,9 @@ OpcGenerateAmlOpcode ( break; default: + /* Nothing to do for other opcodes */ + break; } diff --git a/source/compiler/asloperands.c b/source/compiler/asloperands.c index f281701..deb4bd4 100644 --- a/source/compiler/asloperands.c +++ b/source/compiler/asloperands.c @@ -298,7 +298,6 @@ OpnDoFieldCommon ( /* Nothing additional to do */ break; - case PARSEOP_OFFSET: /* New offset into the field */ @@ -342,7 +341,6 @@ OpnDoFieldCommon ( } break; - case PARSEOP_NAMESEG: case PARSEOP_RESERVED_BYTES: @@ -360,6 +358,7 @@ OpnDoFieldCommon ( case AML_FIELD_ACCESS_BYTE: case AML_FIELD_ACCESS_BUFFER: default: + MinimumLength = 8; break; @@ -380,7 +379,9 @@ OpnDoFieldCommon ( break; default: + /* All supported field opcodes must appear above */ + break; } @@ -610,7 +611,6 @@ OpnDoBuffer ( } break; - case PARSEOP_STRING_LITERAL: /* @@ -624,18 +624,16 @@ OpnDoBuffer ( InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; break; - case PARSEOP_RAW_DATA: /* Buffer nodes are already initialized (e.g. Unicode operator) */ return; - case PARSEOP_DEFAULT_ARG: break; - default: + AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, InitializerOp, "Unknown buffer initializer opcode"); printf ("Unknown buffer initializer opcode [%s]\n", @@ -1092,6 +1090,7 @@ OpnAttachNameToNode ( return; default: + return; } @@ -1130,42 +1129,52 @@ OpnGenerateAmlOperands ( switch (Op->Asl.ParseOpcode) { case PARSEOP_DEFINITIONBLOCK: + OpnDoDefinitionBlock (Op); break; case PARSEOP_METHOD: + OpnDoMethod (Op); break; case PARSEOP_MUTEX: + OpnDoMutex (Op); break; case PARSEOP_FIELD: + OpnDoField (Op); break; case PARSEOP_INDEXFIELD: + OpnDoIndexField (Op); break; case PARSEOP_BANKFIELD: + OpnDoBankField (Op); break; case PARSEOP_BUFFER: + OpnDoBuffer (Op); break; case PARSEOP_LOADTABLE: + OpnDoLoadTable (Op); break; case PARSEOP_OPERATIONREGION: + OpnDoRegion (Op); break; case PARSEOP_RESOURCETEMPLATE: + RsDoResourceTemplate (Op); break; @@ -1173,9 +1182,11 @@ OpnGenerateAmlOperands ( case PARSEOP_NAMESTRING: case PARSEOP_METHODCALL: case PARSEOP_STRING_LITERAL: + break; default: + break; } diff --git a/source/compiler/asloptions.c b/source/compiler/asloptions.c new file mode 100644 index 0000000..bfb3d75 --- /dev/null +++ b/source/compiler/asloptions.c @@ -0,0 +1,791 @@ +/****************************************************************************** + * + * Module Name: asloptions - compiler command line processing + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2013, Intel Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + */ + +#include "aslcompiler.h" +#include "acapps.h" +#include "acdisasm.h" + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("asloption") + + +/* Local prototypes */ + +static int +AslDoOptions ( + int argc, + char **argv, + BOOLEAN IsResponseFile); + +static void +AslMergeOptionTokens ( + char *InBuffer, + char *OutBuffer); + +static int +AslDoResponseFile ( + char *Filename); + + +#define ASL_TOKEN_SEPARATORS " \t\n" +#define ASL_SUPPORTED_OPTIONS "@:b|c|d^D:e:fgh^i|I:l^m:no|p:P^r:s|t|T:G^v^w|x:z" + + +/******************************************************************************* + * + * FUNCTION: AslCommandLine + * + * PARAMETERS: argc/argv + * + * RETURN: Last argv index + * + * DESCRIPTION: Command line processing + * + ******************************************************************************/ + +int +AslCommandLine ( + int argc, + char **argv) +{ + int BadCommandLine = 0; + ACPI_STATUS Status; + + + /* Minimum command line contains at least the command and an input file */ + + if (argc < 2) + { + printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); + Usage (); + exit (1); + } + + /* Process all command line options */ + + BadCommandLine = AslDoOptions (argc, argv, FALSE); + + if (Gbl_DoTemplates) + { + Status = DtCreateTemplates (Gbl_TemplateSignature); + if (ACPI_FAILURE (Status)) + { + exit (-1); + } + exit (1); + } + + /* Next parameter must be the input filename */ + + if (!argv[AcpiGbl_Optind] && + !Gbl_DisasmFlag && + !Gbl_GetAllTables) + { + printf ("Missing input filename\n"); + BadCommandLine = TRUE; + } + + if (Gbl_DoSignon) + { + printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); + if (Gbl_IgnoreErrors) + { + printf ("Ignoring all errors, forcing AML file generation\n\n"); + } + } + + if (BadCommandLine) + { + printf ("\n"); + Usage (); + exit (1); + } + + return (AcpiGbl_Optind); +} + + +/******************************************************************************* + * + * FUNCTION: AslDoOptions + * + * PARAMETERS: argc/argv - Standard argc/argv + * IsResponseFile - TRUE if executing a response file. + * + * RETURN: Status + * + * DESCRIPTION: Command line option processing + * + ******************************************************************************/ + +static int +AslDoOptions ( + int argc, + char **argv, + BOOLEAN IsResponseFile) +{ + ACPI_STATUS Status; + UINT32 j; + + + /* Get the command line options */ + + while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != EOF) switch (j) + { + case '@': /* Begin a response file */ + + if (IsResponseFile) + { + printf ("Nested command files are not supported\n"); + return (-1); + } + + if (AslDoResponseFile (AcpiGbl_Optarg)) + { + return (-1); + } + break; + + case 'b': /* Debug output options */ + + switch (AcpiGbl_Optarg[0]) + { + case 'f': + + AslCompilerdebug = 1; /* same as yydebug */ + DtParserdebug = 1; + PrParserdebug = 1; + break; + + case 't': + + break; + + default: + + printf ("Unknown option: -b%s\n", AcpiGbl_Optarg); + return (-1); + } + + /* Produce debug output file */ + + Gbl_DebugFlag = TRUE; + break; + + case 'c': + + switch (AcpiGbl_Optarg[0]) + { + case 'r': + + Gbl_NoResourceChecking = TRUE; + break; + + default: + + printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); + return (-1); + } + break; + + case 'd': /* Disassembler */ + + switch (AcpiGbl_Optarg[0]) + { + case '^': + + Gbl_DoCompile = FALSE; + break; + + case 'a': + + Gbl_DoCompile = FALSE; + Gbl_DisassembleAll = TRUE; + break; + + case 'b': /* Do not convert buffers to resource descriptors */ + + AcpiGbl_NoResourceDisassembly = TRUE; + break; + + case 'c': + + break; + + default: + + printf ("Unknown option: -d%s\n", AcpiGbl_Optarg); + return (-1); + } + + Gbl_DisasmFlag = TRUE; + break; + + case 'D': /* Define a symbol */ + + PrAddDefine (AcpiGbl_Optarg, NULL, TRUE); + break; + + case 'e': /* External files for disassembler */ + + Status = AcpiDmAddToExternalFileList (AcpiGbl_Optarg); + if (ACPI_FAILURE (Status)) + { + printf ("Could not add %s to external list\n", AcpiGbl_Optarg); + return (-1); + } + break; + + case 'f': /* Ignore errors and force creation of aml file */ + + Gbl_IgnoreErrors = TRUE; + break; + + case 'G': + + Gbl_CompileGeneric = TRUE; + break; + + case 'g': /* Get all ACPI tables */ + + Gbl_GetAllTables = TRUE; + Gbl_DoCompile = FALSE; + break; + + case 'h': + + switch (AcpiGbl_Optarg[0]) + { + case '^': + + Usage (); + exit (0); + + case 'c': + + UtDisplayConstantOpcodes (); + exit (0); + + case 'f': + + AslFilenameHelp (); + exit (0); + + case 'r': + + /* reserved names */ + + ApDisplayReservedNames (); + exit (0); + + case 't': + + UtDisplaySupportedTables (); + exit (0); + + default: + + printf ("Unknown option: -h%s\n", AcpiGbl_Optarg); + return (-1); + } + + case 'I': /* Add an include file search directory */ + + FlAddIncludeDirectory (AcpiGbl_Optarg); + break; + + case 'i': /* Output AML as an include file */ + + switch (AcpiGbl_Optarg[0]) + { + case 'a': + + /* Produce assembly code include file */ + + Gbl_AsmIncludeOutputFlag = TRUE; + break; + + case 'c': + + /* Produce C include file */ + + Gbl_C_IncludeOutputFlag = TRUE; + break; + + case 'n': + + /* Compiler/Disassembler: Ignore the NOOP operator */ + + AcpiGbl_IgnoreNoopOperator = TRUE; + break; + + default: + + printf ("Unknown option: -i%s\n", AcpiGbl_Optarg); + return (-1); + } + break; + + case 'l': /* Listing files */ + + switch (AcpiGbl_Optarg[0]) + { + case '^': + + /* Produce listing file (Mixed source/aml) */ + + Gbl_ListingFlag = TRUE; + break; + + case 'i': + + /* Produce preprocessor output file */ + + Gbl_PreprocessorOutputFlag = TRUE; + break; + + case 'n': + + /* Produce namespace file */ + + Gbl_NsOutputFlag = TRUE; + break; + + case 's': + + /* Produce combined source file */ + + Gbl_SourceOutputFlag = TRUE; + break; + + default: + + printf ("Unknown option: -l%s\n", AcpiGbl_Optarg); + return (-1); + } + break; + + 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; + + case 'n': /* Parse only */ + + Gbl_ParseOnlyFlag = TRUE; + break; + + case 'o': /* Control compiler AML optimizations */ + + switch (AcpiGbl_Optarg[0]) + { + case 'a': + + /* Disable all optimizations */ + + Gbl_FoldConstants = FALSE; + Gbl_IntegerOptimizationFlag = FALSE; + Gbl_ReferenceOptimizationFlag = FALSE; + break; + + case 'f': + + /* Disable folding on "normal" expressions */ + + Gbl_FoldConstants = FALSE; + break; + + case 'i': + + /* Disable integer optimization to constants */ + + Gbl_IntegerOptimizationFlag = FALSE; + break; + + case 'n': + + /* Disable named reference optimization */ + + Gbl_ReferenceOptimizationFlag = FALSE; + break; + + case 't': + + /* Display compile time(s) */ + + Gbl_CompileTimesFlag = TRUE; + break; + + default: + + printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); + return (-1); + } + break; + + case 'P': /* Preprocessor options */ + + switch (AcpiGbl_Optarg[0]) + { + case '^': /* Proprocess only, emit (.i) file */ + + Gbl_PreprocessOnly = TRUE; + Gbl_PreprocessorOutputFlag = TRUE; + break; + + case 'n': /* Disable preprocessor */ + + Gbl_PreprocessFlag = FALSE; + break; + + default: + + printf ("Unknown option: -P%s\n", AcpiGbl_Optarg); + return (-1); + } + break; + + case 'p': /* Override default AML output filename */ + + Gbl_OutputFilenamePrefix = AcpiGbl_Optarg; + Gbl_UseDefaultAmlFilename = FALSE; + break; + + case 'r': /* Override revision found in table header */ + + Gbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); + break; + + case 's': /* Create AML in a source code file */ + + switch (AcpiGbl_Optarg[0]) + { + case 'a': + + /* Produce assembly code output file */ + + Gbl_AsmOutputFlag = TRUE; + break; + + case 'c': + + /* Produce C hex output file */ + + Gbl_C_OutputFlag = TRUE; + break; + + case 'o': + + /* Produce AML offset table in C */ + + Gbl_C_OffsetTableFlag = TRUE; + break; + + default: + + printf ("Unknown option: -s%s\n", AcpiGbl_Optarg); + return (-1); + } + break; + + case 't': /* Produce hex table output file */ + + switch (AcpiGbl_Optarg[0]) + { + case 'a': + + Gbl_HexOutputFlag = HEX_OUTPUT_ASM; + break; + + case 'c': + + Gbl_HexOutputFlag = HEX_OUTPUT_C; + break; + + case 's': + + Gbl_HexOutputFlag = HEX_OUTPUT_ASL; + break; + + default: + + printf ("Unknown option: -t%s\n", AcpiGbl_Optarg); + return (-1); + } + break; + + case 'T': /* Create a ACPI table template file */ + + Gbl_DoTemplates = TRUE; + Gbl_TemplateSignature = AcpiGbl_Optarg; + break; + + case 'v': /* Version and verbosity settings */ + + switch (AcpiGbl_Optarg[0]) + { + case '^': + + printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); + exit (0); + + case 'a': + + /* Disable All error/warning messages */ + + Gbl_NoErrors = TRUE; + break; + + case 'i': + /* + * Support for integrated development environment(s). + * + * 1) No compiler signon + * 2) Send stderr messages to stdout + * 3) Less verbose error messages (single line only for each) + * 4) Error/warning messages are formatted appropriately to + * be recognized by MS Visual Studio + */ + Gbl_VerboseErrors = FALSE; + Gbl_DoSignon = FALSE; + Gbl_Files[ASL_FILE_STDERR].Handle = stdout; + break; + + case 'o': + + Gbl_DisplayOptimizations = TRUE; + break; + + case 'r': + + Gbl_DisplayRemarks = FALSE; + break; + + case 's': + + Gbl_DoSignon = FALSE; + break; + + case 't': + + Gbl_VerboseTemplates = TRUE; + break; + + case 'w': + + /* Get the required argument */ + + if (AcpiGetoptArgument (argc, argv)) + { + return (-1); + } + + Status = AslDisableException (AcpiGbl_Optarg); + if (ACPI_FAILURE (Status)) + { + return (-1); + } + break; + + default: + + printf ("Unknown option: -v%s\n", AcpiGbl_Optarg); + return (-1); + } + break; + + case 'w': /* Set warning levels */ + + switch (AcpiGbl_Optarg[0]) + { + case '1': + + Gbl_WarningLevel = ASL_WARNING; + break; + + case '2': + + Gbl_WarningLevel = ASL_WARNING2; + break; + + case '3': + + Gbl_WarningLevel = ASL_WARNING3; + break; + + case 'e': + + Gbl_WarningsAsErrors = TRUE; + break; + + default: + + printf ("Unknown option: -w%s\n", AcpiGbl_Optarg); + return (-1); + } + break; + + case 'x': /* Set debug print output level */ + + AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16); + break; + + case 'z': + + Gbl_UseOriginalCompilerId = TRUE; + break; + + default: + + return (-1); + } + + return (0); +} + + +/******************************************************************************* + * + * FUNCTION: AslMergeOptionTokens + * + * PARAMETERS: InBuffer - Input containing an option string + * OutBuffer - Merged output buffer + * + * RETURN: None + * + * DESCRIPTION: Remove all whitespace from an option string. + * + ******************************************************************************/ + +static void +AslMergeOptionTokens ( + char *InBuffer, + char *OutBuffer) +{ + char *Token; + + + *OutBuffer = 0; + + Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS); + while (Token) + { + strcat (OutBuffer, Token); + Token = strtok (NULL, ASL_TOKEN_SEPARATORS); + } +} + + +/******************************************************************************* + * + * FUNCTION: AslDoResponseFile + * + * PARAMETERS: Filename - Name of the response file + * + * RETURN: Status + * + * DESCRIPTION: Open a response file and process all options within. + * + ******************************************************************************/ + +static int +AslDoResponseFile ( + char *Filename) +{ + char *argv = StringBuffer2; + FILE *ResponseFile; + int OptStatus = 0; + int Opterr; + int Optind; + + + ResponseFile = fopen (Filename, "r"); + if (!ResponseFile) + { + printf ("Could not open command file %s, %s\n", + Filename, strerror (errno)); + return (-1); + } + + /* Must save the current GetOpt globals */ + + Opterr = AcpiGbl_Opterr; + Optind = AcpiGbl_Optind; + + /* + * Process all lines in the response file. There must be one complete + * option per line + */ + while (fgets (StringBuffer, ASL_MSG_BUFFER_SIZE, ResponseFile)) + { + /* Compress all tokens, allowing us to use a single argv entry */ + + AslMergeOptionTokens (StringBuffer, StringBuffer2); + + /* Process the option */ + + AcpiGbl_Opterr = 0; + AcpiGbl_Optind = 0; + + OptStatus = AslDoOptions (1, &argv, TRUE); + if (OptStatus) + { + printf ("Invalid option in command file %s: %s\n", + Filename, StringBuffer); + break; + } + } + + /* Restore the GetOpt globals */ + + AcpiGbl_Opterr = Opterr; + AcpiGbl_Optind = Optind; + + fclose (ResponseFile); + return (OptStatus); +} diff --git a/source/compiler/aslpredef.c b/source/compiler/aslpredef.c index 3895681..60b5269 100644 --- a/source/compiler/aslpredef.c +++ b/source/compiler/aslpredef.c @@ -310,7 +310,6 @@ ApCheckPredefinedReturnValue ( break; default: - /* * All other ops are very difficult or impossible to typecheck at * compile time. These include all Localx, Argx, and method @@ -379,6 +378,7 @@ ApCheckForPredefinedObject ( return; default: + break; } @@ -624,33 +624,53 @@ ApCheckObjectType ( case PARSEOP_ONE: case PARSEOP_ONES: case PARSEOP_INTEGER: + ReturnBtype = ACPI_RTYPE_INTEGER; TypeName = "Integer"; break; case PARSEOP_STRING_LITERAL: + ReturnBtype = ACPI_RTYPE_STRING; TypeName = "String"; break; case PARSEOP_BUFFER: + ReturnBtype = ACPI_RTYPE_BUFFER; TypeName = "Buffer"; break; case PARSEOP_PACKAGE: case PARSEOP_VAR_PACKAGE: + ReturnBtype = ACPI_RTYPE_PACKAGE; TypeName = "Package"; break; case PARSEOP_NAMESEG: case PARSEOP_NAMESTRING: + /* + * Ignore any named references within a package object. + * + * For Package objects, references are allowed instead of any of the + * standard data types (Integer/String/Buffer/Package). These + * references are resolved at runtime. NAMESEG and NAMESTRING are + * impossible to typecheck at compile time because the type of + * any named object can be changed at runtime (for example, + * CopyObject will change the type of the target object). + */ + if (PackageIndex != ACPI_NOT_PACKAGE_ELEMENT) + { + return (AE_OK); + } + ReturnBtype = ACPI_RTYPE_REFERENCE; TypeName = "Reference"; break; default: + /* Not one of the supported object types */ TypeName = UtGetOpName (Op->Asl.ParseOpcode); diff --git a/source/compiler/aslresource.c b/source/compiler/aslresource.c index 272f9b0..d7f829f 100644 --- a/source/compiler/aslresource.c +++ b/source/compiler/aslresource.c @@ -319,6 +319,7 @@ RsLargeAddressCheck ( case ACPI_RESOURCE_FLAG_MIF: case ACPI_RESOURCE_FLAG_MAF: default: + AslError (ASL_ERROR, ASL_MSG_INVALID_ADDR_FLAGS, LengthOp, NULL); } } @@ -364,6 +365,7 @@ RsLargeAddressCheck ( case (ACPI_RESOURCE_FLAG_MIF | ACPI_RESOURCE_FLAG_MAF): default: + AslError (ASL_ERROR, ASL_MSG_INVALID_ADDR_FLAGS, LengthOp, NULL); } } @@ -655,45 +657,54 @@ RsDoOneResourceDescriptor ( switch (DescriptorTypeOp->Asl.ParseOpcode) { case PARSEOP_DMA: + Rnode = RsDoDmaDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_FIXEDDMA: + Rnode = RsDoFixedDmaDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_DWORDIO: + Rnode = RsDoDwordIoDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_DWORDMEMORY: + Rnode = RsDoDwordMemoryDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_DWORDSPACE: + Rnode = RsDoDwordSpaceDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_ENDDEPENDENTFN: + switch (*State) { case ACPI_RSTATE_NORMAL: + AslError (ASL_ERROR, ASL_MSG_MISSING_STARTDEPENDENT, DescriptorTypeOp, NULL); break; case ACPI_RSTATE_START_DEPENDENT: + AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING, DescriptorTypeOp, NULL); break; case ACPI_RSTATE_DEPENDENT_LIST: default: + break; } @@ -703,89 +714,107 @@ RsDoOneResourceDescriptor ( break; case PARSEOP_ENDTAG: + Rnode = RsDoEndTagDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_EXTENDEDIO: + Rnode = RsDoExtendedIoDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_EXTENDEDMEMORY: + Rnode = RsDoExtendedMemoryDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_EXTENDEDSPACE: + Rnode = RsDoExtendedSpaceDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_FIXEDIO: + Rnode = RsDoFixedIoDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_INTERRUPT: + Rnode = RsDoInterruptDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_IO: + Rnode = RsDoIoDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_IRQ: + Rnode = RsDoIrqDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_IRQNOFLAGS: + Rnode = RsDoIrqNoFlagsDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_MEMORY24: + Rnode = RsDoMemory24Descriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_MEMORY32: + Rnode = RsDoMemory32Descriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_MEMORY32FIXED: + Rnode = RsDoMemory32FixedDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_QWORDIO: + Rnode = RsDoQwordIoDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_QWORDMEMORY: + Rnode = RsDoQwordMemoryDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_QWORDSPACE: + Rnode = RsDoQwordSpaceDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_REGISTER: + Rnode = RsDoGeneralRegisterDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_STARTDEPENDENTFN: + switch (*State) { case ACPI_RSTATE_START_DEPENDENT: + AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING, DescriptorTypeOp, NULL); break; @@ -793,6 +822,7 @@ RsDoOneResourceDescriptor ( case ACPI_RSTATE_NORMAL: case ACPI_RSTATE_DEPENDENT_LIST: default: + break; } @@ -803,9 +833,11 @@ RsDoOneResourceDescriptor ( break; case PARSEOP_STARTDEPENDENTFN_NOPRI: + switch (*State) { case ACPI_RSTATE_START_DEPENDENT: + AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING, DescriptorTypeOp, NULL); break; @@ -813,6 +845,7 @@ RsDoOneResourceDescriptor ( case ACPI_RSTATE_NORMAL: case ACPI_RSTATE_DEPENDENT_LIST: default: + break; } @@ -823,60 +856,72 @@ RsDoOneResourceDescriptor ( break; case PARSEOP_VENDORLONG: + Rnode = RsDoVendorLargeDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_VENDORSHORT: + Rnode = RsDoVendorSmallDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_WORDBUSNUMBER: + Rnode = RsDoWordBusNumberDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_WORDIO: + Rnode = RsDoWordIoDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_WORDSPACE: + Rnode = RsDoWordSpaceDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_GPIO_INT: + Rnode = RsDoGpioIntDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_GPIO_IO: + Rnode = RsDoGpioIoDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_I2C_SERIALBUS: + Rnode = RsDoI2cSerialBusDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_SPI_SERIALBUS: + Rnode = RsDoSpiSerialBusDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_UART_SERIALBUS: + Rnode = RsDoUartSerialBusDescriptor (DescriptorTypeOp, CurrentByteOffset); break; case PARSEOP_DEFAULT_ARG: + /* Just ignore any of these, they are used as fillers/placeholders */ break; default: + printf ("Unknown resource descriptor type [%s]\n", DescriptorTypeOp->Asl.ParseOpName); break; diff --git a/source/compiler/aslrestype1i.c b/source/compiler/aslrestype1i.c index 01fe136..d8a6bd9 100644 --- a/source/compiler/aslrestype1i.c +++ b/source/compiler/aslrestype1i.c @@ -245,6 +245,7 @@ RsDoFixedDmaDescriptor ( break; default: /* Ignore any extra nodes */ + break; } diff --git a/source/compiler/aslrestype2s.c b/source/compiler/aslrestype2s.c index 4bdcef8..a7472b1 100644 --- a/source/compiler/aslrestype2s.c +++ b/source/compiler/aslrestype2s.c @@ -617,7 +617,6 @@ RsDoGpioIoDescriptor ( break; case 9: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ - /* * Always set the VendorOffset even if there is no Vendor Data. * This field is required in order to calculate the length @@ -812,6 +811,7 @@ RsDoI2cSerialBusDescriptor ( break; default: /* Ignore any extra nodes */ + break; } @@ -986,6 +986,7 @@ RsDoSpiSerialBusDescriptor ( break; default: /* Ignore any extra nodes */ + break; } @@ -1177,6 +1178,7 @@ RsDoUartSerialBusDescriptor ( break; default: /* Ignore any extra nodes */ + break; } diff --git a/source/compiler/aslstartup.c b/source/compiler/aslstartup.c index ad9a2bb..0168fd0 100644 --- a/source/compiler/aslstartup.c +++ b/source/compiler/aslstartup.c @@ -534,6 +534,7 @@ AslDoOneFile ( return (AE_ERROR); default: + printf ("Unknown file type %X\n", Gbl_FileType); return (AE_ERROR); } diff --git a/source/compiler/aslsupport.l b/source/compiler/aslsupport.l index 52389ee..e7d2b1f 100644 --- a/source/compiler/aslsupport.l +++ b/source/compiler/aslsupport.l @@ -395,16 +395,19 @@ count ( switch (Type) { case 2: + TotalKeywords++; TotalNamedObjects++; break; case 3: + TotalKeywords++; TotalExecutableOpcodes++; break; default: + break; } @@ -594,6 +597,7 @@ DoCharacter: goto CompletedString; default: + break; } break; @@ -605,34 +609,42 @@ DoCharacter: switch (StringChar) { case 'a': + StringChar = 0x07; /* BELL */ break; case 'b': + StringChar = 0x08; /* BACKSPACE */ break; case 'f': + StringChar = 0x0C; /* FORMFEED */ break; case 'n': + StringChar = 0x0A; /* LINEFEED */ break; case 'r': + StringChar = 0x0D; /* CARRIAGE RETURN*/ break; case 't': + StringChar = 0x09; /* HORIZONTAL TAB */ break; case 'v': + StringChar = 0x0B; /* VERTICAL TAB */ break; case 'x': + State = ASL_HEX_CONSTANT; i = 0; continue; @@ -640,6 +652,7 @@ DoCharacter: case '\'': /* Single Quote */ case '\"': /* Double Quote */ case '\\': /* Backslash */ + break; default: @@ -709,7 +722,6 @@ DoCharacter: i++; continue; - case ASL_HEX_CONSTANT: /* Up to two hex digits allowed */ @@ -755,6 +767,7 @@ DoCharacter: continue; default: + break; } diff --git a/source/compiler/asltransform.c b/source/compiler/asltransform.c index 4617713..c1a2526 100644 --- a/source/compiler/asltransform.c +++ b/source/compiler/asltransform.c @@ -299,15 +299,16 @@ TrTransformSubtree ( switch (Op->Asl.ParseOpcode) { case PARSEOP_DEFINITIONBLOCK: + TrDoDefinitionBlock (Op); break; case PARSEOP_SWITCH: + TrDoSwitch (Op); break; case PARSEOP_METHOD: - /* * TBD: Zero the tempname (_T_x) count. Probably shouldn't be a global, * however @@ -316,7 +317,9 @@ TrTransformSubtree ( break; default: + /* Nothing to do here for other opcodes */ + break; } } @@ -700,18 +703,21 @@ TrDoSwitch ( switch (Btype) { case ACPI_BTYPE_INTEGER: + NewOp2->Asl.Next = TrCreateValuedLeafNode (PARSEOP_ZERO, (UINT64) 0); TrAmlInitLineNumbers (NewOp2->Asl.Next, NewOp); break; case ACPI_BTYPE_STRING: + NewOp2->Asl.Next = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, (UINT64) ACPI_TO_INTEGER ("")); TrAmlInitLineNumbers (NewOp2->Asl.Next, NewOp); break; case ACPI_BTYPE_BUFFER: + (void) TrLinkPeerNode (NewOp2, TrCreateValuedLeafNode (PARSEOP_BUFFER, (UINT64) 0)); Next = NewOp2->Asl.Next; @@ -728,6 +734,7 @@ TrDoSwitch ( break; default: + break; } diff --git a/source/compiler/asltree.c b/source/compiler/asltree.c index f275061..ca88071 100644 --- a/source/compiler/asltree.c +++ b/source/compiler/asltree.c @@ -185,20 +185,24 @@ TrUpdateNode ( switch (ParseOpcode) { case PARSEOP_BYTECONST: + Op->Asl.Value.Integer = ACPI_UINT8_MAX; break; case PARSEOP_WORDCONST: + Op->Asl.Value.Integer = ACPI_UINT16_MAX; break; case PARSEOP_DWORDCONST: + Op->Asl.Value.Integer = ACPI_UINT32_MAX; break; /* Don't need to do the QWORD case */ default: + /* Don't care about others */ break; } @@ -214,22 +218,27 @@ TrUpdateNode ( switch (ParseOpcode) { case PARSEOP_BYTECONST: + UtCheckIntegerRange (Op, 0x00, ACPI_UINT8_MAX); Op->Asl.Value.Integer &= ACPI_UINT8_MAX; break; case PARSEOP_WORDCONST: + UtCheckIntegerRange (Op, 0x00, ACPI_UINT16_MAX); Op->Asl.Value.Integer &= ACPI_UINT16_MAX; break; case PARSEOP_DWORDCONST: + UtCheckIntegerRange (Op, 0x00, ACPI_UINT32_MAX); Op->Asl.Value.Integer &= ACPI_UINT32_MAX; break; default: + /* Don't care about others, don't need to check QWORD */ + break; } @@ -257,54 +266,71 @@ TrGetNodeFlagName ( switch (Flags) { case NODE_VISITED: + return ("NODE_VISITED"); case NODE_AML_PACKAGE: + return ("NODE_AML_PACKAGE"); case NODE_IS_TARGET: + return ("NODE_IS_TARGET"); case NODE_IS_RESOURCE_DESC: + return ("NODE_IS_RESOURCE_DESC"); case NODE_IS_RESOURCE_FIELD: + return ("NODE_IS_RESOURCE_FIELD"); case NODE_HAS_NO_EXIT: + return ("NODE_HAS_NO_EXIT"); case NODE_IF_HAS_NO_EXIT: + return ("NODE_IF_HAS_NO_EXIT"); case NODE_NAME_INTERNALIZED: + return ("NODE_NAME_INTERNALIZED"); case NODE_METHOD_NO_RETVAL: + return ("NODE_METHOD_NO_RETVAL"); case NODE_METHOD_SOME_NO_RETVAL: + return ("NODE_METHOD_SOME_NO_RETVAL"); case NODE_RESULT_NOT_USED: + return ("NODE_RESULT_NOT_USED"); case NODE_METHOD_TYPED: + return ("NODE_METHOD_TYPED"); case NODE_COMPILE_TIME_CONST: + return ("NODE_COMPILE_TIME_CONST"); case NODE_IS_TERM_ARG: + return ("NODE_IS_TERM_ARG"); case NODE_WAS_ONES_OP: + return ("NODE_WAS_ONES_OP"); case NODE_IS_NAME_DECLARATION: + return ("NODE_IS_NAME_DECLARATION"); default: + return ("Multiple Flags (or unknown flag) set"); } } @@ -470,11 +496,13 @@ TrCreateConstantLeafNode ( switch (ParseOpcode) { case PARSEOP___LINE__: + Op = TrAllocateNode (PARSEOP_INTEGER); Op->Asl.Value.Integer = Op->Asl.LineNumber; break; case PARSEOP___PATH__: + Op = TrAllocateNode (PARSEOP_STRING_LITERAL); /* Op.Asl.Filename contains the full pathname to the file */ @@ -483,6 +511,7 @@ TrCreateConstantLeafNode ( break; case PARSEOP___FILE__: + Op = TrAllocateNode (PARSEOP_STRING_LITERAL); /* Get the simple filename from the full path */ @@ -493,6 +522,7 @@ TrCreateConstantLeafNode ( break; case PARSEOP___DATE__: + Op = TrAllocateNode (PARSEOP_STRING_LITERAL); /* Get a copy of the current time */ @@ -507,6 +537,7 @@ TrCreateConstantLeafNode ( break; default: /* This would be an internal error */ + return (NULL); } @@ -551,30 +582,37 @@ TrCreateValuedLeafNode ( switch (ParseOpcode) { case PARSEOP_STRING_LITERAL: + DbgPrint (ASL_PARSE_OUTPUT, "STRING->%s", Value); break; case PARSEOP_NAMESEG: + DbgPrint (ASL_PARSE_OUTPUT, "NAMESEG->%s", Value); break; case PARSEOP_NAMESTRING: + DbgPrint (ASL_PARSE_OUTPUT, "NAMESTRING->%s", Value); break; case PARSEOP_EISAID: + DbgPrint (ASL_PARSE_OUTPUT, "EISAID->%s", Value); break; case PARSEOP_METHOD: + DbgPrint (ASL_PARSE_OUTPUT, "METHOD"); break; case PARSEOP_INTEGER: + DbgPrint (ASL_PARSE_OUTPUT, "INTEGER"); break; default: + break; } @@ -628,20 +666,25 @@ TrCreateNode ( switch (ParseOpcode) { case PARSEOP_DEFINITIONBLOCK: + RootNode = Op; DbgPrint (ASL_PARSE_OUTPUT, "DEFINITION_BLOCK (Tree Completed)->"); break; case PARSEOP_OPERATIONREGION: + DbgPrint (ASL_PARSE_OUTPUT, "OPREGION->"); break; case PARSEOP_OR: + DbgPrint (ASL_PARSE_OUTPUT, "OR->"); break; default: + /* Nothing to do for other opcodes */ + break; } @@ -746,20 +789,25 @@ TrLinkChildren ( switch (Op->Asl.ParseOpcode) { case PARSEOP_DEFINITIONBLOCK: + RootNode = Op; DbgPrint (ASL_PARSE_OUTPUT, "DEFINITION_BLOCK (Tree Completed)->"); break; case PARSEOP_OPERATIONREGION: + DbgPrint (ASL_PARSE_OUTPUT, "OPREGION->"); break; case PARSEOP_OR: + DbgPrint (ASL_PARSE_OUTPUT, "OR->"); break; default: + /* Nothing to do for other opcodes */ + break; } @@ -1106,7 +1154,6 @@ TrWalkParseTree ( } break; - case ASL_WALK_VISIT_UPWARD: while (Op) @@ -1161,7 +1208,6 @@ TrWalkParseTree ( } break; - case ASL_WALK_VISIT_TWICE: while (Op) diff --git a/source/compiler/asltypes.h b/source/compiler/asltypes.h index 6f2fb88..5ca17b3 100644 --- a/source/compiler/asltypes.h +++ b/source/compiler/asltypes.h @@ -81,16 +81,17 @@ typedef struct asl_method_info { - UINT8 NumArguments; - UINT8 LocalInitialized[ACPI_METHOD_NUM_LOCALS]; - UINT8 ArgInitialized[ACPI_METHOD_NUM_ARGS]; + ACPI_PARSE_OBJECT *Op; + struct asl_method_info *Next; UINT32 ValidArgTypes[ACPI_METHOD_NUM_ARGS]; UINT32 ValidReturnTypes; UINT32 NumReturnNoValue; UINT32 NumReturnWithValue; - ACPI_PARSE_OBJECT *Op; - struct asl_method_info *Next; + UINT8 NumArguments; + UINT8 LocalInitialized[ACPI_METHOD_NUM_LOCALS]; + UINT8 ArgInitialized[ACPI_METHOD_NUM_ARGS]; UINT8 HasBeenTyped; + UINT8 ShouldBeSerialized; } ASL_METHOD_INFO; diff --git a/source/compiler/aslutils.c b/source/compiler/aslutils.c index a3690b1..8174eeb 100644 --- a/source/compiler/aslutils.c +++ b/source/compiler/aslutils.c @@ -956,6 +956,7 @@ UtStrtoul64 ( case 8: case 10: case 16: + break; default: @@ -1090,19 +1091,24 @@ ErrorExit: switch (Base) { case 8: + Status = AE_BAD_OCTAL_CONSTANT; break; case 10: + Status = AE_BAD_DECIMAL_CONSTANT; break; case 16: + Status = AE_BAD_HEX_CONSTANT; break; default: + /* Base validated above */ + break; } diff --git a/source/compiler/aslwalks.c b/source/compiler/aslwalks.c index 20adf5e..5abda23 100644 --- a/source/compiler/aslwalks.c +++ b/source/compiler/aslwalks.c @@ -122,6 +122,7 @@ AnMethodTypingWalkEnd ( break; default: + break; } @@ -176,6 +177,7 @@ AnOperandTypecheckWalkEnd ( return (AE_OK); default: + break; } @@ -252,6 +254,7 @@ AnOperandTypecheckWalkEnd ( return (AE_OK); default: + break; } @@ -379,11 +382,13 @@ AnOperandTypecheckWalkEnd ( break; case PARSEOP_DEBUG: + break; case PARSEOP_REFOF: case PARSEOP_INDEX: default: + break; } @@ -391,6 +396,7 @@ AnOperandTypecheckWalkEnd ( case ARGI_INTEGER: default: + break; } @@ -434,6 +440,7 @@ AnOperandTypecheckWalkEnd ( break; default: + break; } @@ -520,9 +527,11 @@ AnOtherSemanticAnalysisWalkBegin ( case PARSEOP_ACQUIRE: case PARSEOP_WAIT: case PARSEOP_LOADTABLE: + break; default: + AslError (ASL_ERROR, ASL_MSG_RESULT_NOT_USED, Op, Op->Asl.ExternalName); break; @@ -661,6 +670,7 @@ AnOtherSemanticAnalysisWalkBegin ( break; default: + break; } diff --git a/source/compiler/aslxref.c b/source/compiler/aslxref.c index 5c98c2a..a04fefb 100644 --- a/source/compiler/aslxref.c +++ b/source/compiler/aslxref.c @@ -533,27 +533,33 @@ XfNamespaceLocateBegin ( break; case AML_CREATE_BIT_FIELD_OP: + FieldBitLength = 1; break; case AML_CREATE_BYTE_FIELD_OP: case AML_INDEX_OP: + FieldBitLength = 8; break; case AML_CREATE_WORD_FIELD_OP: + FieldBitLength = 16; break; case AML_CREATE_DWORD_FIELD_OP: + FieldBitLength = 32; break; case AML_CREATE_QWORD_FIELD_OP: + FieldBitLength = 64; break; default: + FieldBitLength = 0; break; } @@ -595,6 +601,7 @@ XfNamespaceLocateBegin ( break; default: + break; } @@ -728,18 +735,22 @@ XfNamespaceLocateBegin ( case AML_FIELD_ACCESS_BYTE: case AML_FIELD_ACCESS_BUFFER: default: + MinimumLength = 1; break; case AML_FIELD_ACCESS_WORD: + MinimumLength = 2; break; case AML_FIELD_ACCESS_DWORD: + MinimumLength = 4; break; case AML_FIELD_ACCESS_QWORD: + MinimumLength = 8; break; } @@ -784,6 +795,7 @@ XfNamespaceLocateBegin ( default: /* Nothing to do for other address spaces */ + break; } } diff --git a/source/compiler/dtexpress.c b/source/compiler/dtexpress.c index 1120d7b..a3f9c8c 100644 --- a/source/compiler/dtexpress.c +++ b/source/compiler/dtexpress.c @@ -127,18 +127,22 @@ DtDoOperator ( switch (Operator) { case EXPOP_ONES_COMPLIMENT: + Result = ~RightValue; break; case EXPOP_LOGICAL_NOT: + Result = !RightValue; break; case EXPOP_MULTIPLY: + Result = LeftValue * RightValue; break; case EXPOP_DIVIDE: + if (!RightValue) { DtError (ASL_ERROR, ASL_MSG_DIVIDE_BY_ZERO, @@ -149,6 +153,7 @@ DtDoOperator ( break; case EXPOP_MODULO: + if (!RightValue) { DtError (ASL_ERROR, ASL_MSG_DIVIDE_BY_ZERO, @@ -163,58 +168,72 @@ DtDoOperator ( break; case EXPOP_SUBTRACT: + Result = LeftValue - RightValue; break; case EXPOP_SHIFT_RIGHT: + Result = LeftValue >> RightValue; break; case EXPOP_SHIFT_LEFT: + Result = LeftValue << RightValue; break; case EXPOP_LESS: + Result = LeftValue < RightValue; break; case EXPOP_GREATER: + Result = LeftValue > RightValue; break; case EXPOP_LESS_EQUAL: + Result = LeftValue <= RightValue; break; case EXPOP_GREATER_EQUAL: + Result = LeftValue >= RightValue; break; case EXPOP_EQUAL: + Result = LeftValue == RightValue; break; case EXPOP_NOT_EQUAL: + Result = LeftValue != RightValue; break; case EXPOP_AND: + Result = LeftValue & RightValue; break; case EXPOP_XOR: + Result = LeftValue ^ RightValue; break; case EXPOP_OR: + Result = LeftValue | RightValue; break; case EXPOP_LOGICAL_AND: + Result = LeftValue && RightValue; break; case EXPOP_LOGICAL_OR: + Result = LeftValue || RightValue; break; diff --git a/source/compiler/dtfield.c b/source/compiler/dtfield.c index 275f22f..697b277 100644 --- a/source/compiler/dtfield.c +++ b/source/compiler/dtfield.c @@ -104,14 +104,17 @@ DtCompileOneField ( switch (Type) { case DT_FIELD_TYPE_INTEGER: + DtCompileInteger (Buffer, Field, ByteLength, Flags); break; case DT_FIELD_TYPE_STRING: + DtCompileString (Buffer, Field, ByteLength); break; case DT_FIELD_TYPE_UUID: + Status = DtCompileUuid (Buffer, Field, ByteLength); if (ACPI_SUCCESS (Status)) { @@ -121,17 +124,21 @@ DtCompileOneField ( /* Fall through. */ case DT_FIELD_TYPE_BUFFER: + DtCompileBuffer (Buffer, Field->Value, Field, ByteLength); break; case DT_FIELD_TYPE_UNICODE: + DtCompileUnicode (Buffer, Field, ByteLength); break; case DT_FIELD_TYPE_DEVICE_PATH: + break; default: + DtFatal (ASL_MSG_COMPILER_INTERNAL, Field, "Invalid field type"); break; } @@ -382,10 +389,12 @@ DtNormalizeBuffer ( case ']': case ' ': case ',': + Separator = TRUE; break; default: + if (Separator) { /* Insert blank as the standard separator */ diff --git a/source/compiler/dtio.c b/source/compiler/dtio.c index 7876552..c26b2b8 100644 --- a/source/compiler/dtio.c +++ b/source/compiler/dtio.c @@ -426,7 +426,7 @@ DtGetNextLine ( UINT32 State = DT_NORMAL_TEXT; UINT32 CurrentLineOffset; UINT32 i; - char c; + int c; for (i = 0; ;) @@ -440,7 +440,7 @@ DtGetNextLine ( UtExpandLineBuffers (); } - c = (char) getc (Handle); + c = getc (Handle); if (c == EOF) { switch (State) @@ -452,6 +452,7 @@ DtGetNextLine ( break; default: + break; } @@ -479,14 +480,16 @@ DtGetNextLine ( /* Normal text, insert char into line buffer */ - Gbl_CurrentLineBuffer[i] = c; + Gbl_CurrentLineBuffer[i] = (char) c; switch (c) { case '/': + State = DT_START_COMMENT; break; case '"': + State = DT_START_QUOTED_STRING; LineNotAllBlanks = TRUE; i++; @@ -501,6 +504,7 @@ DtGetNextLine ( break; case '\n': + CurrentLineOffset = Gbl_NextLineOffset; Gbl_NextLineOffset = (UINT32) ftell (Handle); Gbl_CurrentLineNumber++; @@ -527,6 +531,7 @@ DtGetNextLine ( break; default: + if (c != ' ') { LineNotAllBlanks = TRUE; @@ -541,26 +546,30 @@ DtGetNextLine ( /* Insert raw chars until end of quoted string */ - Gbl_CurrentLineBuffer[i] = c; + Gbl_CurrentLineBuffer[i] = (char) c; i++; switch (c) { case '"': + State = DT_NORMAL_TEXT; break; case '\\': + State = DT_ESCAPE_SEQUENCE; break; case '\n': + AcpiOsPrintf ("ERROR at line %u: Unterminated quoted string\n", Gbl_CurrentLineNumber++); State = DT_NORMAL_TEXT; break; default: /* Get next character */ + break; } break; @@ -569,7 +578,7 @@ DtGetNextLine ( /* Just copy the escaped character. TBD: sufficient for table compiler? */ - Gbl_CurrentLineBuffer[i] = c; + Gbl_CurrentLineBuffer[i] = (char) c; i++; State = DT_START_QUOTED_STRING; break; @@ -581,21 +590,24 @@ DtGetNextLine ( switch (c) { case '*': + State = DT_SLASH_ASTERISK_COMMENT; break; case '/': + State = DT_SLASH_SLASH_COMMENT; break; default: /* Not a comment */ + i++; /* Save the preceding slash */ if (i >= Gbl_LineBufferSize) { UtExpandLineBuffers (); } - Gbl_CurrentLineBuffer[i] = c; + Gbl_CurrentLineBuffer[i] = (char) c; i++; State = DT_NORMAL_TEXT; break; @@ -609,15 +621,18 @@ DtGetNextLine ( switch (c) { case '\n': + Gbl_NextLineOffset = (UINT32) ftell (Handle); Gbl_CurrentLineNumber++; break; case '*': + State = DT_END_COMMENT; break; default: + break; } break; @@ -642,20 +657,24 @@ DtGetNextLine ( switch (c) { case '/': + State = DT_NORMAL_TEXT; break; case '\n': + CurrentLineOffset = Gbl_NextLineOffset; Gbl_NextLineOffset = (UINT32) ftell (Handle); Gbl_CurrentLineNumber++; break; case '*': + /* Consume all adjacent asterisks */ break; default: + State = DT_SLASH_ASTERISK_COMMENT; break; } @@ -694,6 +713,7 @@ DtGetNextLine ( break; default: + DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, "Unknown input state"); return (ASL_EOF); } diff --git a/source/compiler/dtsubtable.c b/source/compiler/dtsubtable.c index f49c205..275d67a 100644 --- a/source/compiler/dtsubtable.c +++ b/source/compiler/dtsubtable.c @@ -312,14 +312,17 @@ DtGetSubtableLength ( switch (Info->Opcode) { case ACPI_DMT_GAS: + Step = 5; break; case ACPI_DMT_HESTNTFY: + Step = 9; break; default: + Step = 1; break; } diff --git a/source/compiler/dttable.c b/source/compiler/dttable.c index b3ce5de..4236c6c 100644 --- a/source/compiler/dttable.c +++ b/source/compiler/dttable.c @@ -280,26 +280,32 @@ DtCompileAsf ( switch (AsfTable->Header.Type & 0x7F) /* Mask off top bit */ { case ACPI_ASF_TYPE_INFO: + InfoTable = AcpiDmTableInfoAsf0; break; case ACPI_ASF_TYPE_ALERT: + InfoTable = AcpiDmTableInfoAsf1; break; case ACPI_ASF_TYPE_CONTROL: + InfoTable = AcpiDmTableInfoAsf2; break; case ACPI_ASF_TYPE_BOOT: + InfoTable = AcpiDmTableInfoAsf3; break; case ACPI_ASF_TYPE_ADDRESS: + InfoTable = AcpiDmTableInfoAsf4; break; default: + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "ASF!"); return (AE_ERROR); } @@ -316,10 +322,12 @@ DtCompileAsf ( switch (AsfTable->Header.Type & 0x7F) /* Mask off top bit */ { case ACPI_ASF_TYPE_INFO: + DataInfoTable = NULL; break; case ACPI_ASF_TYPE_ALERT: + DataInfoTable = AcpiDmTableInfoAsf1a; DataCount = ACPI_CAST_PTR (ACPI_ASF_ALERT, ACPI_SUB_PTR (UINT8, Subtable->Buffer, @@ -327,6 +335,7 @@ DtCompileAsf ( break; case ACPI_ASF_TYPE_CONTROL: + DataInfoTable = AcpiDmTableInfoAsf2a; DataCount = ACPI_CAST_PTR (ACPI_ASF_REMOTE, ACPI_SUB_PTR (UINT8, Subtable->Buffer, @@ -334,10 +343,12 @@ DtCompileAsf ( break; case ACPI_ASF_TYPE_BOOT: + DataInfoTable = NULL; break; case ACPI_ASF_TYPE_ADDRESS: + DataInfoTable = TableInfoAsfAddress; DataCount = ACPI_CAST_PTR (ACPI_ASF_ADDRESS, ACPI_SUB_PTR (UINT8, Subtable->Buffer, @@ -345,6 +356,7 @@ DtCompileAsf ( break; default: + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "ASF!"); return (AE_ERROR); } @@ -574,18 +586,27 @@ DtCompileDmar ( switch (DmarHeader->Type) { case ACPI_DMAR_TYPE_HARDWARE_UNIT: + InfoTable = AcpiDmTableInfoDmar0; break; + case ACPI_DMAR_TYPE_RESERVED_MEMORY: + InfoTable = AcpiDmTableInfoDmar1; break; + case ACPI_DMAR_TYPE_ATSR: + InfoTable = AcpiDmTableInfoDmar2; break; + case ACPI_DMAR_HARDWARE_AFFINITY: + InfoTable = AcpiDmTableInfoDmar3; break; + default: + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "DMAR"); return (AE_ERROR); } @@ -810,14 +831,17 @@ DtCompileFpdt ( switch (FpdtHeader->Type) { case ACPI_FPDT_TYPE_BOOT: + InfoTable = AcpiDmTableInfoFpdt0; break; case ACPI_FPDT_TYPE_S3PERF: + InfoTable = AcpiDmTableInfoFpdt1; break; default: + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "FPDT"); return (AE_ERROR); break; @@ -884,34 +908,42 @@ DtCompileHest ( switch (Type) { case ACPI_HEST_TYPE_IA32_CHECK: + InfoTable = AcpiDmTableInfoHest0; break; case ACPI_HEST_TYPE_IA32_CORRECTED_CHECK: + InfoTable = AcpiDmTableInfoHest1; break; case ACPI_HEST_TYPE_IA32_NMI: + InfoTable = AcpiDmTableInfoHest2; break; case ACPI_HEST_TYPE_AER_ROOT_PORT: + InfoTable = AcpiDmTableInfoHest6; break; case ACPI_HEST_TYPE_AER_ENDPOINT: + InfoTable = AcpiDmTableInfoHest7; break; case ACPI_HEST_TYPE_AER_BRIDGE: + InfoTable = AcpiDmTableInfoHest8; break; case ACPI_HEST_TYPE_GENERIC_ERROR: + InfoTable = AcpiDmTableInfoHest9; break; default: + /* Cannot continue on unknown type */ DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "HEST"); @@ -933,16 +965,19 @@ DtCompileHest ( switch (Type) { case ACPI_HEST_TYPE_IA32_CHECK: + BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_MACHINE_CHECK, Subtable->Buffer))->NumHardwareBanks; break; case ACPI_HEST_TYPE_IA32_CORRECTED_CHECK: + BankCount = (ACPI_CAST_PTR (ACPI_HEST_IA_CORRECTED, Subtable->Buffer))->NumHardwareBanks; break; default: + break; } @@ -1019,16 +1054,19 @@ DtCompileIvrs ( switch (IvrsHeader->Type) { case ACPI_IVRS_TYPE_HARDWARE: + InfoTable = AcpiDmTableInfoIvrs0; break; case ACPI_IVRS_TYPE_MEMORY1: case ACPI_IVRS_TYPE_MEMORY2: case ACPI_IVRS_TYPE_MEMORY3: + InfoTable = AcpiDmTableInfoIvrs1; break; default: + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "IVRS"); return (AE_ERROR); } @@ -1088,6 +1126,7 @@ DtCompileIvrs ( break; default: + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "IVRS Device Entry"); return (AE_ERROR); @@ -1165,45 +1204,72 @@ DtCompileMadt ( switch (MadtHeader->Type) { case ACPI_MADT_TYPE_LOCAL_APIC: + InfoTable = AcpiDmTableInfoMadt0; break; + case ACPI_MADT_TYPE_IO_APIC: + InfoTable = AcpiDmTableInfoMadt1; break; + case ACPI_MADT_TYPE_INTERRUPT_OVERRIDE: + InfoTable = AcpiDmTableInfoMadt2; break; + case ACPI_MADT_TYPE_NMI_SOURCE: + InfoTable = AcpiDmTableInfoMadt3; break; + case ACPI_MADT_TYPE_LOCAL_APIC_NMI: + InfoTable = AcpiDmTableInfoMadt4; break; + case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE: + InfoTable = AcpiDmTableInfoMadt5; break; + case ACPI_MADT_TYPE_IO_SAPIC: + InfoTable = AcpiDmTableInfoMadt6; break; + case ACPI_MADT_TYPE_LOCAL_SAPIC: + InfoTable = AcpiDmTableInfoMadt7; break; + case ACPI_MADT_TYPE_INTERRUPT_SOURCE: + InfoTable = AcpiDmTableInfoMadt8; break; + case ACPI_MADT_TYPE_LOCAL_X2APIC: + InfoTable = AcpiDmTableInfoMadt9; break; + case ACPI_MADT_TYPE_LOCAL_X2APIC_NMI: + InfoTable = AcpiDmTableInfoMadt10; break; + case ACPI_MADT_TYPE_GENERIC_INTERRUPT: + InfoTable = AcpiDmTableInfoMadt11; break; + case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR: + InfoTable = AcpiDmTableInfoMadt12; break; + default: + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "MADT"); return (AE_ERROR); } @@ -1665,14 +1731,17 @@ DtCompileS3pt ( switch (S3ptHeader->Type) { case ACPI_S3PT_TYPE_RESUME: + InfoTable = AcpiDmTableInfoS3pt0; break; case ACPI_S3PT_TYPE_SUSPEND: + InfoTable = AcpiDmTableInfoS3pt1; break; default: + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "S3PT"); return (AE_ERROR); } @@ -1736,12 +1805,17 @@ DtCompileSlic ( switch (SlicHeader->Type) { case ACPI_SLIC_TYPE_PUBLIC_KEY: + InfoTable = AcpiDmTableInfoSlic0; break; + case ACPI_SLIC_TYPE_WINDOWS_MARKER: + InfoTable = AcpiDmTableInfoSlic1; break; + default: + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SLIC"); return (AE_ERROR); } @@ -1871,15 +1945,22 @@ DtCompileSrat ( switch (SratHeader->Type) { case ACPI_SRAT_TYPE_CPU_AFFINITY: + InfoTable = AcpiDmTableInfoSrat0; break; + case ACPI_SRAT_TYPE_MEMORY_AFFINITY: + InfoTable = AcpiDmTableInfoSrat1; break; + case ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY: + InfoTable = AcpiDmTableInfoSrat2; break; + default: + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "SRAT"); return (AE_ERROR); } diff --git a/source/compiler/dtutils.c b/source/compiler/dtutils.c index 18ea93e..1f4207a 100644 --- a/source/compiler/dtutils.c +++ b/source/compiler/dtutils.c @@ -82,18 +82,11 @@ DtError ( char *ExtraMessage) { - switch (Level) - { - case ASL_WARNING2: - case ASL_WARNING3: - if (Gbl_WarningLevel < Level) - { - return; - } - break; + /* Check if user wants to ignore this exception */ - default: - break; + if (AslIsExceptionDisabled (Level, MessageId)) + { + return; } if (FieldObject) @@ -140,6 +133,7 @@ DtNameError ( { case ASL_WARNING2: case ASL_WARNING3: + if (Gbl_WarningLevel < Level) { return; @@ -147,6 +141,7 @@ DtNameError ( break; default: + break; } @@ -387,6 +382,7 @@ DtGetFieldType ( case ACPI_DMT_FLAGS1: case ACPI_DMT_FLAGS2: case ACPI_DMT_FLAGS4: + Type = DT_FIELD_TYPE_FLAG; break; @@ -395,6 +391,7 @@ DtGetFieldType ( case ACPI_DMT_NAME6: case ACPI_DMT_NAME8: case ACPI_DMT_STRING: + Type = DT_FIELD_TYPE_STRING; break; @@ -403,31 +400,38 @@ DtGetFieldType ( case ACPI_DMT_BUF16: case ACPI_DMT_BUF128: case ACPI_DMT_PCI_PATH: + Type = DT_FIELD_TYPE_BUFFER; break; case ACPI_DMT_GAS: case ACPI_DMT_HESTNTFY: + Type = DT_FIELD_TYPE_INLINE_SUBTABLE; break; case ACPI_DMT_UNICODE: + Type = DT_FIELD_TYPE_UNICODE; break; case ACPI_DMT_UUID: + Type = DT_FIELD_TYPE_UUID; break; case ACPI_DMT_DEVICE_PATH: + Type = DT_FIELD_TYPE_DEVICE_PATH; break; case ACPI_DMT_LABEL: + Type = DT_FIELD_TYPE_LABEL; break; default: + Type = DT_FIELD_TYPE_INTEGER; break; } @@ -517,6 +521,7 @@ DtGetFieldLength ( case ACPI_DMT_FLAGS4: case ACPI_DMT_LABEL: case ACPI_DMT_EXTRA_TEXT: + ByteLength = 0; break; @@ -535,6 +540,7 @@ DtGetFieldLength ( case ACPI_DMT_EINJINST: case ACPI_DMT_ERSTACT: case ACPI_DMT_ERSTINST: + ByteLength = 1; break; @@ -542,10 +548,12 @@ DtGetFieldLength ( case ACPI_DMT_DMAR: case ACPI_DMT_HEST: case ACPI_DMT_PCI_PATH: + ByteLength = 2; break; case ACPI_DMT_UINT24: + ByteLength = 3; break; @@ -553,29 +561,35 @@ DtGetFieldLength ( case ACPI_DMT_NAME4: case ACPI_DMT_SLIC: case ACPI_DMT_SIG: + ByteLength = 4; break; case ACPI_DMT_UINT40: + ByteLength = 5; break; case ACPI_DMT_UINT48: case ACPI_DMT_NAME6: + ByteLength = 6; break; case ACPI_DMT_UINT56: case ACPI_DMT_BUF7: + ByteLength = 7; break; case ACPI_DMT_UINT64: case ACPI_DMT_NAME8: + ByteLength = 8; break; case ACPI_DMT_STRING: + Value = DtGetFieldValue (Field); if (Value) { @@ -591,14 +605,17 @@ DtGetFieldLength ( break; case ACPI_DMT_GAS: + ByteLength = sizeof (ACPI_GENERIC_ADDRESS); break; case ACPI_DMT_HESTNTFY: + ByteLength = sizeof (ACPI_HEST_NOTIFY); break; case ACPI_DMT_BUFFER: + Value = DtGetFieldValue (Field); if (Value) { @@ -615,14 +632,17 @@ DtGetFieldLength ( case ACPI_DMT_BUF16: case ACPI_DMT_UUID: + ByteLength = 16; break; case ACPI_DMT_BUF128: + ByteLength = 128; break; case ACPI_DMT_UNICODE: + Value = DtGetFieldValue (Field); /* TBD: error if Value is NULL? (as below?) */ @@ -631,6 +651,7 @@ DtGetFieldLength ( break; default: + DtFatal (ASL_MSG_COMPILER_INTERNAL, Field, "Invalid table opcode"); return (0); } diff --git a/source/compiler/prscan.c b/source/compiler/prscan.c index f781deb..cc9b3ce 100644 --- a/source/compiler/prscan.c +++ b/source/compiler/prscan.c @@ -477,6 +477,7 @@ PrDoDirective ( switch (Directive) { case PR_DIRECTIVE_ELIF: + *IgnoringThisCodeBlock = !(*IgnoringThisCodeBlock); if (*IgnoringThisCodeBlock == TRUE) { @@ -493,10 +494,12 @@ PrDoDirective ( break; case PR_DIRECTIVE_ELSE: + *IgnoringThisCodeBlock = !(*IgnoringThisCodeBlock); return; case PR_DIRECTIVE_ENDIF: + *IgnoringThisCodeBlock = FALSE; Gbl_IfDepth--; if (Gbl_IfDepth < 0) @@ -508,6 +511,7 @@ PrDoDirective ( return; default: + break; } @@ -590,6 +594,7 @@ PrDoDirective ( break; case PR_DIRECTIVE_ERROR: + /* TBD compiler should abort */ /* Note: No macro expansion */ @@ -598,6 +603,7 @@ PrDoDirective ( break; case PR_DIRECTIVE_IF: + TokenOffset = Token - Gbl_MainTokenBuffer; /* Need to expand #define macros in the expression string first */ @@ -623,6 +629,7 @@ PrDoDirective ( break; case PR_DIRECTIVE_IFDEF: + if (!PrMatchDefine (Token)) { *IgnoringThisCodeBlock = TRUE; @@ -635,6 +642,7 @@ PrDoDirective ( break; case PR_DIRECTIVE_IFNDEF: + if (PrMatchDefine (Token)) { *IgnoringThisCodeBlock = TRUE; @@ -647,6 +655,7 @@ PrDoDirective ( break; case PR_DIRECTIVE_INCLUDE: + Token = PrGetNextToken (NULL, " \"<>", Next); if (!Token) { @@ -661,6 +670,7 @@ PrDoDirective ( break; case PR_DIRECTIVE_LINE: + TokenOffset = Token - Gbl_MainTokenBuffer; Status = PrResolveIntegerExpression ( @@ -686,26 +696,40 @@ PrDoDirective ( break; case PR_DIRECTIVE_PRAGMA: - /* Only "#pragma message" supported at this time */ - if (strcmp (Token, "message")) + if (!strcmp (Token, "disable")) { - PrError (ASL_ERROR, ASL_MSG_UNKNOWN_PRAGMA, - THIS_TOKEN_OFFSET (Token)); - return; + Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next); + if (!Token) + { + goto SyntaxError; + } + + TokenOffset = Token - Gbl_MainTokenBuffer; + AslDisableException (&Gbl_CurrentLineBuffer[TokenOffset]); } + else if (!strcmp (Token, "message")) + { + Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next); + if (!Token) + { + goto SyntaxError; + } - Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next); - if (!Token) + TokenOffset = Token - Gbl_MainTokenBuffer; + AcpiOsPrintf ("%s\n", &Gbl_CurrentLineBuffer[TokenOffset]); + } + else { - goto SyntaxError; + PrError (ASL_ERROR, ASL_MSG_UNKNOWN_PRAGMA, + THIS_TOKEN_OFFSET (Token)); + return; } - TokenOffset = Token - Gbl_MainTokenBuffer; - AcpiOsPrintf ("%s\n", &Gbl_CurrentLineBuffer[TokenOffset]); break; case PR_DIRECTIVE_UNDEF: + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID "#undef: %s\n", Gbl_CurrentLineNumber, Token); @@ -713,11 +737,13 @@ PrDoDirective ( break; case PR_DIRECTIVE_WARNING: + PrError (ASL_WARNING, ASL_MSG_ERROR_DIRECTIVE, THIS_TOKEN_OFFSET (Token)); break; default: + /* Should never get here */ DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID "Unrecognized directive: %u\n", |