diff options
author | Jung-uk Kim <jkim@FreeBSD.org> | 2016-12-23 04:35:14 +0000 |
---|---|---|
committer | Jung-uk Kim <jkim@FreeBSD.org> | 2016-12-23 04:35:14 +0000 |
commit | f2e6c39316f68b7ccc7abb766f82ed421c8e22b4 (patch) | |
tree | 2c9acd96afc9afb47a31a88c97ac4907faee46d9 /source/tools | |
parent | a56e3c255d5c5dfa4dd3a2fda4705a1607a6b7f3 (diff) |
Notes
Diffstat (limited to 'source/tools')
-rw-r--r-- | source/tools/acpiexec/aemain.c | 65 | ||||
-rw-r--r-- | source/tools/acpihelp/acpihelp.h | 74 | ||||
-rw-r--r-- | source/tools/acpihelp/ahaml.c | 349 | ||||
-rw-r--r-- | source/tools/acpihelp/ahamlops.c | 2 | ||||
-rw-r--r-- | source/tools/acpihelp/ahasl.c | 319 | ||||
-rw-r--r-- | source/tools/acpihelp/ahaslkey.c | 4 | ||||
-rw-r--r-- | source/tools/acpihelp/ahaslops.c | 2 | ||||
-rw-r--r-- | source/tools/acpihelp/ahdecode.c | 732 | ||||
-rw-r--r-- | source/tools/acpihelp/ahgrammar.c | 2 | ||||
-rw-r--r-- | source/tools/acpihelp/ahmain.c | 2 | ||||
-rw-r--r-- | source/tools/efihello/efihello.c | 124 |
11 files changed, 932 insertions, 743 deletions
diff --git a/source/tools/acpiexec/aemain.c b/source/tools/acpiexec/aemain.c index 826d60df1364..1f236f22440f 100644 --- a/source/tools/acpiexec/aemain.c +++ b/source/tools/acpiexec/aemain.c @@ -66,10 +66,6 @@ AeDoOptions ( int argc, char **argv); -static void -AcpiDbRunBatchMode ( - void); - #define AE_BUFFER_SIZE 1024 #define ASL_MAX_FILES 256 @@ -663,12 +659,12 @@ EnterDebugger: default: case AE_MODE_COMMAND_LOOP: - AcpiDbUserCommands (ACPI_DEBUGGER_COMMAND_PROMPT, NULL); + AcpiRunDebugger (NULL); break; case AE_MODE_BATCH_MULTIPLE: - AcpiDbRunBatchMode (); + AcpiRunDebugger (BatchBuffer); break; case AE_MODE_BATCH_SINGLE: @@ -679,12 +675,7 @@ EnterDebugger: /* Shut down the debugger and ACPICA */ -#if 0 - - /* Temporarily removed */ AcpiTerminateDebugger (); - (void) AcpiTerminate (); -#endif NormalExit: ExitCode = 0; @@ -693,55 +684,3 @@ ErrorExit: (void) AcpiOsTerminate (); return (ExitCode); } - - -/****************************************************************************** - * - * FUNCTION: AcpiDbRunBatchMode - * - * PARAMETERS: BatchCommandLine - A semicolon separated list of commands - * to be executed. - * Use only commas to separate elements of - * particular command. - * RETURN: None - * - * DESCRIPTION: For each command of list separated by ';' prepare the command - * buffer and pass it to AcpiDbCommandDispatch. - * - *****************************************************************************/ - -static void -AcpiDbRunBatchMode ( - void) -{ - char *Ptr = BatchBuffer; - char *Cmd = Ptr; - UINT8 Run = 0; - - - AcpiGbl_MethodExecuting = FALSE; - AcpiGbl_StepToNextCall = FALSE; - - while (*Ptr) - { - if (*Ptr == ',') - { - /* Convert commas to spaces */ - *Ptr = ' '; - } - else if (*Ptr == ';') - { - *Ptr = '\0'; - Run = 1; - } - - Ptr++; - - if (Run || (*Ptr == '\0')) - { - (void) AcpiDbCommandDispatch (Cmd, NULL, NULL); - Run = 0; - Cmd = Ptr; - } - } -} diff --git a/source/tools/acpihelp/acpihelp.h b/source/tools/acpihelp/acpihelp.h index 20055674762d..eb0c38d39bb3 100644 --- a/source/tools/acpihelp/acpihelp.h +++ b/source/tools/acpihelp/acpihelp.h @@ -56,6 +56,50 @@ #endif +/* + * Global variables. Defined in ahmain.c only, externed in all other files + */ +#undef ACPI_GLOBAL +#undef ACPI_INIT_GLOBAL + +#ifdef DEFINE_AHELP_GLOBALS +#define ACPI_GLOBAL(type,name) \ + extern type name; \ + type name + +#define ACPI_INIT_GLOBAL(type,name,value) \ + type name=value + +#else +#ifndef ACPI_GLOBAL +#define ACPI_GLOBAL(type,name) \ + extern type name +#endif + +#ifndef ACPI_INIT_GLOBAL +#define ACPI_INIT_GLOBAL(type,name,value) \ + extern type name +#endif +#endif + + +#define AH_BUFFER_LENGTH 128 +#define AH_LINE_BUFFER_LENGTH 512 +#define AH_MAX_ASL_LINE_LENGTH 70 +#define AH_MAX_AML_LINE_LENGTH 100 + +ACPI_GLOBAL (char, Gbl_Buffer[AH_BUFFER_LENGTH]); +ACPI_GLOBAL (char, Gbl_LineBuffer[AH_LINE_BUFFER_LENGTH]); + + +#define AH_DISPLAY_EXCEPTION(Status, Name) \ + printf ("%.4X: %s\n", Status, Name) + +#define AH_DISPLAY_EXCEPTION_TEXT(Status, Exception) \ + printf ("%.4X: %-28s (%s)\n", Status,\ + Exception->Name, Exception->Description) + + typedef enum { AH_DECODE_DEFAULT = 0, @@ -75,10 +119,6 @@ typedef enum } AH_OPTION_TYPES; -#define AH_MAX_ASL_LINE_LENGTH 70 -#define AH_MAX_AML_LINE_LENGTH 100 - - typedef struct ah_aml_opcode { UINT16 OpcodeRangeStart; @@ -122,14 +162,17 @@ typedef struct ah_directive_info } AH_DIRECTIVE_INFO; -extern const AH_AML_OPCODE AmlOpcodeInfo[]; -extern const AH_AML_TYPE AmlTypesInfo[]; -extern const AH_ASL_OPERATOR AslOperatorInfo[]; -extern const AH_ASL_KEYWORD AslKeywordInfo[]; -extern const AH_UUID AcpiUuids[]; -extern const AH_DIRECTIVE_INFO PreprocessorDirectives[]; -extern const AH_TABLE AcpiSupportedTables[]; -extern BOOLEAN AhDisplayAll; + +/* Externals for various data tables */ + +extern const AH_AML_OPCODE Gbl_AmlOpcodeInfo[]; +extern const AH_AML_TYPE Gbl_AmlTypesInfo[]; +extern const AH_ASL_OPERATOR Gbl_AslOperatorInfo[]; +extern const AH_ASL_KEYWORD Gbl_AslKeywordInfo[]; +extern const AH_UUID Gbl_AcpiUuids[]; +extern const AH_DIRECTIVE_INFO Gbl_PreprocessorDirectives[]; +extern const AH_TABLE Gbl_AcpiSupportedTables[]; + void AhFindAmlOpcode ( @@ -183,4 +226,11 @@ void AhDisplayDirectives ( void); +void +AhPrintOneField ( + UINT32 Indent, + UINT32 CurrentPosition, + UINT32 MaxPosition, + const char *Field); + #endif /* __ACPIHELP_H */ diff --git a/source/tools/acpihelp/ahaml.c b/source/tools/acpihelp/ahaml.c new file mode 100644 index 000000000000..dcd425815159 --- /dev/null +++ b/source/tools/acpihelp/ahaml.c @@ -0,0 +1,349 @@ +/****************************************************************************** + * + * Module Name: ahaml - AML opcode decoding for acpihelp utility + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, 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 "acpihelp.h" + + +/* Local prototypes */ + +static void +AhDisplayAmlOpcode ( + const AH_AML_OPCODE *Op); + +static void +AhDisplayAmlType ( + const AH_AML_TYPE *Op); + + +/******************************************************************************* + * + * FUNCTION: AhFindAmlOpcode (entry point for AML opcode name search) + * + * PARAMETERS: Name - Name or prefix for an AML opcode. + * NULL means "find all" + * + * RETURN: None + * + * DESCRIPTION: Find all AML opcodes that match the input Name or name + * prefix. + * + ******************************************************************************/ + +void +AhFindAmlOpcode ( + char *Name) +{ + const AH_AML_OPCODE *Op; + BOOLEAN Found = FALSE; + + + AcpiUtStrupr (Name); + + /* Find/display all opcode names that match the input name prefix */ + + for (Op = Gbl_AmlOpcodeInfo; Op->OpcodeString; Op++) + { + if (!Op->OpcodeName) /* Unused opcodes */ + { + continue; + } + + if (!Name || (Name[0] == '*')) + { + AhDisplayAmlOpcode (Op); + Found = TRUE; + continue; + } + + /* Upper case the opcode name before substring compare */ + + strcpy (Gbl_Buffer, Op->OpcodeName); + AcpiUtStrupr (Gbl_Buffer); + + if (strstr (Gbl_Buffer, Name) == Gbl_Buffer) + { + AhDisplayAmlOpcode (Op); + Found = TRUE; + } + } + + if (!Found) + { + printf ("%s, no matching AML operators\n", Name); + } +} + + +/******************************************************************************* + * + * FUNCTION: AhDecodeAmlOpcode (entry point for AML opcode search) + * + * PARAMETERS: OpcodeString - String version of AML opcode + * + * RETURN: None + * + * DESCRIPTION: Display information about the input AML opcode + * + ******************************************************************************/ + +void +AhDecodeAmlOpcode ( + char *OpcodeString) +{ + const AH_AML_OPCODE *Op; + UINT32 Opcode; + UINT8 Prefix; + + + if (!OpcodeString) + { + AhFindAmlOpcode (NULL); + return; + } + + Opcode = strtoul (OpcodeString, NULL, 16); + if (Opcode > ACPI_UINT16_MAX) + { + printf ("Invalid opcode (more than 16 bits)\n"); + return; + } + + /* Only valid opcode extension is 0x5B */ + + Prefix = (Opcode & 0x0000FF00) >> 8; + if (Prefix && (Prefix != 0x5B)) + { + printf ("Invalid opcode (invalid extension prefix 0x%X)\n", + Prefix); + return; + } + + /* Find/Display the opcode. May fall within an opcode range */ + + for (Op = Gbl_AmlOpcodeInfo; Op->OpcodeString; Op++) + { + if ((Opcode >= Op->OpcodeRangeStart) && + (Opcode <= Op->OpcodeRangeEnd)) + { + AhDisplayAmlOpcode (Op); + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AhDisplayAmlOpcode + * + * PARAMETERS: Op - An opcode info struct + * + * RETURN: None + * + * DESCRIPTION: Display the contents of an AML opcode information struct + * + ******************************************************************************/ + +static void +AhDisplayAmlOpcode ( + const AH_AML_OPCODE *Op) +{ + + if (!Op->OpcodeName) + { + printf ("%18s: Opcode=%-9s\n", "Reserved opcode", Op->OpcodeString); + return; + } + + /* Opcode name and value(s) */ + + printf ("%18s: Opcode=%-9s Type (%s)", + Op->OpcodeName, Op->OpcodeString, Op->Type); + + /* Optional fixed/static arguments */ + + if (Op->FixedArguments) + { + printf (" FixedArgs ("); + AhPrintOneField (37, 36 + 7 + strlen (Op->Type) + 12, + AH_MAX_AML_LINE_LENGTH, Op->FixedArguments); + printf (")"); + } + + /* Optional variable-length argument list */ + + if (Op->VariableArguments) + { + if (Op->FixedArguments) + { + printf ("\n%*s", 36, " "); + } + printf (" VariableArgs ("); + AhPrintOneField (37, 15, AH_MAX_AML_LINE_LENGTH, Op->VariableArguments); + printf (")"); + } + printf ("\n"); + + /* Grammar specification */ + + if (Op->Grammar) + { + AhPrintOneField (37, 0, AH_MAX_AML_LINE_LENGTH, Op->Grammar); + printf ("\n"); + } +} + + +/******************************************************************************* + * + * FUNCTION: AhFindAmlTypes (entry point for AML grammar keyword search) + * + * PARAMETERS: Name - Name or prefix for an AML grammar element. + * NULL means "find all" + * + * RETURN: None + * + * DESCRIPTION: Find all AML grammar keywords that match the input Name or name + * prefix. + * + ******************************************************************************/ + +void +AhFindAmlTypes ( + char *Name) +{ + const AH_AML_TYPE *Keyword; + BOOLEAN Found = FALSE; + + + AcpiUtStrupr (Name); + + for (Keyword = Gbl_AmlTypesInfo; Keyword->Name; Keyword++) + { + if (!Name) + { + printf (" %s\n", Keyword->Name); + Found = TRUE; + continue; + } + + if (*Name == '*') + { + AhDisplayAmlType (Keyword); + Found = TRUE; + continue; + } + + /* Upper case the operator name before substring compare */ + + strcpy (Gbl_Buffer, Keyword->Name); + AcpiUtStrupr (Gbl_Buffer); + + if (strstr (Gbl_Buffer, Name) == Gbl_Buffer) + { + AhDisplayAmlType (Keyword); + Found = TRUE; + } + } + + if (!Found) + { + printf ("%s, no matching AML grammar type\n", Name); + } +} + + +/******************************************************************************* + * + * FUNCTION: AhDisplayAmlType + * + * PARAMETERS: Op - Pointer to AML grammar info + * + * RETURN: None + * + * DESCRIPTION: Format and display info for an AML grammar element. + * + ******************************************************************************/ + +static void +AhDisplayAmlType ( + const AH_AML_TYPE *Op) +{ + char *Description; + + + Description = Op->Description; + printf ("%4s", " "); /* Primary indent */ + + /* Emit the entire description string */ + + while (*Description) + { + /* Description can be multiple lines, must indent each */ + + while (*Description != '\n') + { + printf ("%c", *Description); + Description++; + } + + printf ("\n"); + Description++; + + /* Do indent */ + + if (*Description) + { + printf ("%8s", " "); /* Secondary indent */ + + /* Index extra for a comment */ + + if ((Description[0] == '/') && + (Description[1] == '/')) + { + printf ("%4s", " "); + } + } + } + + printf ("\n"); +} diff --git a/source/tools/acpihelp/ahamlops.c b/source/tools/acpihelp/ahamlops.c index 57a0963c1f29..b2d7c8f0176f 100644 --- a/source/tools/acpihelp/ahamlops.c +++ b/source/tools/acpihelp/ahamlops.c @@ -48,7 +48,7 @@ * AML opcodes with related syntax and grammar information. * This table was extracted from the ACPI specification. */ -const AH_AML_OPCODE AmlOpcodeInfo[] = +const AH_AML_OPCODE Gbl_AmlOpcodeInfo[] = { {0x00, 0x00, "0x00", "ZeroOp", "DataObject", NULL, NULL, NULL}, diff --git a/source/tools/acpihelp/ahasl.c b/source/tools/acpihelp/ahasl.c new file mode 100644 index 000000000000..c9fd3a672e85 --- /dev/null +++ b/source/tools/acpihelp/ahasl.c @@ -0,0 +1,319 @@ +/****************************************************************************** + * + * Module Name: ahasl - ASL operator decoding for acpihelp utility + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, 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 "acpihelp.h" + + +/* Local prototypes */ + +static void +AhDisplayAslOperator ( + const AH_ASL_OPERATOR *Op); + +static void +AhDisplayOperatorKeywords ( + const AH_ASL_OPERATOR *Op); + +static void +AhDisplayAslKeyword ( + const AH_ASL_KEYWORD *Op); + + +/******************************************************************************* + * + * FUNCTION: AhFindAslKeywords (entry point for ASL keyword search) + * + * PARAMETERS: Name - Name or prefix for an ASL keyword. + * NULL means "find all" + * + * RETURN: None + * + * DESCRIPTION: Find all ASL keywords that match the input Name or name + * prefix. + * + ******************************************************************************/ + +void +AhFindAslKeywords ( + char *Name) +{ + const AH_ASL_KEYWORD *Keyword; + BOOLEAN Found = FALSE; + + + AcpiUtStrupr (Name); + + for (Keyword = Gbl_AslKeywordInfo; Keyword->Name; Keyword++) + { + if (!Name || (Name[0] == '*')) + { + AhDisplayAslKeyword (Keyword); + Found = TRUE; + continue; + } + + /* Upper case the operator name before substring compare */ + + strcpy (Gbl_Buffer, Keyword->Name); + AcpiUtStrupr (Gbl_Buffer); + + if (strstr (Gbl_Buffer, Name) == Gbl_Buffer) + { + AhDisplayAslKeyword (Keyword); + Found = TRUE; + } + } + + if (!Found) + { + printf ("%s, no matching ASL keywords\n", Name); + } +} + + +/******************************************************************************* + * + * FUNCTION: AhDisplayAslKeyword + * + * PARAMETERS: Op - Pointer to ASL keyword with syntax info + * + * RETURN: None + * + * DESCRIPTION: Format and display syntax info for an ASL keyword. Splits + * long lines appropriately for reading. + * + ******************************************************************************/ + +static void +AhDisplayAslKeyword ( + const AH_ASL_KEYWORD *Op) +{ + + /* ASL keyword name and description */ + + printf ("%22s: %s\n", Op->Name, Op->Description); + if (!Op->KeywordList) + { + return; + } + + /* List of actual keywords */ + + AhPrintOneField (24, 0, AH_MAX_ASL_LINE_LENGTH, Op->KeywordList); + printf ("\n"); +} + + +/******************************************************************************* + * + * FUNCTION: AhFindAslAndAmlOperators + * + * PARAMETERS: Name - Name or prefix for an ASL operator. + * NULL means "find all" + * + * RETURN: None + * + * DESCRIPTION: Find all ASL operators that match the input Name or name + * prefix. Also displays the AML information if only one entry + * matches. + * + ******************************************************************************/ + +void +AhFindAslAndAmlOperators ( + char *Name) +{ + UINT32 MatchCount; + + + MatchCount = AhFindAslOperators (Name); + if (MatchCount == 1) + { + AhFindAmlOpcode (Name); + } +} + + +/******************************************************************************* + * + * FUNCTION: AhFindAslOperators (entry point for ASL operator search) + * + * PARAMETERS: Name - Name or prefix for an ASL operator. + * NULL means "find all" + * + * RETURN: Number of operators that matched the name prefix. + * + * DESCRIPTION: Find all ASL operators that match the input Name or name + * prefix. + * + ******************************************************************************/ + +UINT32 +AhFindAslOperators ( + char *Name) +{ + const AH_ASL_OPERATOR *Operator; + BOOLEAN MatchCount = 0; + + + AcpiUtStrupr (Name); + + /* Find/display all names that match the input name prefix */ + + for (Operator = Gbl_AslOperatorInfo; Operator->Name; Operator++) + { + if (!Name || (Name[0] == '*')) + { + AhDisplayAslOperator (Operator); + MatchCount++; + continue; + } + + /* Upper case the operator name before substring compare */ + + strcpy (Gbl_Buffer, Operator->Name); + AcpiUtStrupr (Gbl_Buffer); + + if (strstr (Gbl_Buffer, Name) == Gbl_Buffer) + { + AhDisplayAslOperator (Operator); + MatchCount++; + } + } + + if (!MatchCount) + { + printf ("%s, no matching ASL operators\n", Name); + } + + return (MatchCount); +} + + +/******************************************************************************* + * + * FUNCTION: AhDisplayAslOperator + * + * PARAMETERS: Op - Pointer to ASL operator with syntax info + * + * RETURN: None + * + * DESCRIPTION: Format and display syntax info for an ASL operator. Splits + * long lines appropriately for reading. + * + ******************************************************************************/ + +static void +AhDisplayAslOperator ( + const AH_ASL_OPERATOR *Op) +{ + + /* ASL operator name and description */ + + printf ("%16s: %s\n", Op->Name, Op->Description); + if (!Op->Syntax) + { + return; + } + + /* Syntax for the operator */ + + AhPrintOneField (18, 0, AH_MAX_ASL_LINE_LENGTH, Op->Syntax); + printf ("\n"); + + AhDisplayOperatorKeywords (Op); + printf ("\n"); +} + + +/******************************************************************************* + * + * FUNCTION: AhDisplayOperatorKeywords + * + * PARAMETERS: Op - Pointer to ASL keyword with syntax info + * + * RETURN: None + * + * DESCRIPTION: Display any/all keywords that are associated with the ASL + * operator. + * + ******************************************************************************/ + +static void +AhDisplayOperatorKeywords ( + const AH_ASL_OPERATOR *Op) +{ + char *Token; + char *Separators = "(){}, "; + BOOLEAN FirstKeyword = TRUE; + + + if (!Op || !Op->Syntax) + { + return; + } + + /* + * Find all parameters that have the word "keyword" within, and then + * display the info about that keyword + */ + strcpy (Gbl_LineBuffer, Op->Syntax); + Token = strtok (Gbl_LineBuffer, Separators); + while (Token) + { + if (strstr (Token, "Keyword")) + { + if (FirstKeyword) + { + printf ("\n"); + FirstKeyword = FALSE; + } + + /* Found a keyword, display keyword information */ + + AhFindAslKeywords (Token); + } + + Token = strtok (NULL, Separators); + } +} diff --git a/source/tools/acpihelp/ahaslkey.c b/source/tools/acpihelp/ahaslkey.c index 62791801f0c8..37d3ee9c52e6 100644 --- a/source/tools/acpihelp/ahaslkey.c +++ b/source/tools/acpihelp/ahaslkey.c @@ -48,7 +48,7 @@ * ASL Keyword types and associated actual keywords. * This table was extracted from the ACPI specification. */ -const AH_ASL_KEYWORD AslKeywordInfo[] = +const AH_ASL_KEYWORD Gbl_AslKeywordInfo[] = { {"AccessAttribKeyword", "Serial Bus Attributes (with legacy SMBus aliases)", ":= AttribQuick (SMBusQuick) | AttribSendReceive (SMBusSendReceive) | " @@ -151,7 +151,7 @@ const AH_ASL_KEYWORD AslKeywordInfo[] = /* Preprocessor directives */ -const AH_DIRECTIVE_INFO PreprocessorDirectives[] = +const AH_DIRECTIVE_INFO Gbl_PreprocessorDirectives[] = { {"#include \"Filename\"", "Standard include of an ASCII ASL source code file"}, {"#include <Filename>", "Alternate syntax for #include, alternate search path"}, diff --git a/source/tools/acpihelp/ahaslops.c b/source/tools/acpihelp/ahaslops.c index 39abc31b44f5..7437fccd6379 100644 --- a/source/tools/acpihelp/ahaslops.c +++ b/source/tools/acpihelp/ahaslops.c @@ -48,7 +48,7 @@ * Note: All tokens require a space separator. * Long lines are automatically split during output. */ -const AH_ASL_OPERATOR AslOperatorInfo[] = +const AH_ASL_OPERATOR Gbl_AslOperatorInfo[] = { {"AccessAs", "(AccessType, AccessAttribKeyword | " "ExtendedAttribKeyword (AccessLength))", diff --git a/source/tools/acpihelp/ahdecode.c b/source/tools/acpihelp/ahdecode.c index 5f422904a53c..c1ac74c3c0ed 100644 --- a/source/tools/acpihelp/ahdecode.c +++ b/source/tools/acpihelp/ahdecode.c @@ -1,6 +1,6 @@ /****************************************************************************** * - * Module Name: ahdecode - Operator/Opcode decoding for acpihelp utility + * Module Name: ahdecode - Miscellaneous decoding for acpihelp utility * *****************************************************************************/ @@ -48,19 +48,6 @@ #include "acpredef.h" -#define AH_DISPLAY_EXCEPTION(Status, Name) \ - printf ("%.4X: %s\n", Status, Name) - -#define AH_DISPLAY_EXCEPTION_TEXT(Status, Exception) \ - printf ("%.4X: %-28s (%s)\n", Status, Exception->Name, Exception->Description) - -#define BUFFER_LENGTH 128 -#define LINE_BUFFER_LENGTH 512 - -static char Gbl_Buffer[BUFFER_LENGTH]; -static char Gbl_LineBuffer[LINE_BUFFER_LENGTH]; - - /* Local prototypes */ static BOOLEAN @@ -76,32 +63,77 @@ static void AhDisplayResourceName ( const ACPI_PREDEFINED_INFO *ThisName); -static void -AhDisplayAmlOpcode ( - const AH_AML_OPCODE *Op); - -static void -AhDisplayAmlType ( - const AH_AML_TYPE *Op); - -static void -AhDisplayAslOperator ( - const AH_ASL_OPERATOR *Op); - -static void -AhDisplayOperatorKeywords ( - const AH_ASL_OPERATOR *Op); -static void -AhDisplayAslKeyword ( - const AH_ASL_KEYWORD *Op); +/******************************************************************************* + * + * FUNCTION: AhPrintOneField + * + * PARAMETERS: Indent - Indent length for new line(s) + * CurrentPosition - Position on current line + * MaxPosition - Max allowed line length + * Field - Data to output + * + * RETURN: Line position after field is written + * + * DESCRIPTION: Split long lines appropriately for ease of reading. + * + ******************************************************************************/ -static void +void AhPrintOneField ( UINT32 Indent, UINT32 CurrentPosition, UINT32 MaxPosition, - const char *Field); + const char *Field) +{ + UINT32 Position; + UINT32 TokenLength; + const char *This; + const char *Next; + const char *Last; + + + This = Field; + Position = CurrentPosition; + + if (Position == 0) + { + printf ("%*s", (int) Indent, " "); + Position = Indent; + } + + Last = This + strlen (This); + while ((Next = strpbrk (This, " "))) + { + TokenLength = Next - This; + Position += TokenLength; + + /* Split long lines */ + + if (Position > MaxPosition) + { + printf ("\n%*s", (int) Indent, " "); + Position = TokenLength; + } + + printf ("%.*s ", (int) TokenLength, This); + This = Next + 1; + } + + /* Handle last token on the input line */ + + TokenLength = Last - This; + if (TokenLength > 0) + { + Position += TokenLength; + if (Position > MaxPosition) + { + printf ("\n%*s", (int) Indent, " "); + } + + printf ("%s", This); + } +} /******************************************************************************* @@ -125,7 +157,7 @@ AhDisplayDirectives ( printf ("iASL Preprocessor Directives\n\n"); - for (Info = PreprocessorDirectives; Info->Name; Info++) + for (Info = Gbl_PreprocessorDirectives; Info->Name; Info++) { printf (" %-36s : %s\n", Info->Name, Info->Description); } @@ -329,632 +361,6 @@ AhDisplayResourceName ( /******************************************************************************* * - * FUNCTION: AhFindAmlOpcode (entry point for AML opcode name search) - * - * PARAMETERS: Name - Name or prefix for an AML opcode. - * NULL means "find all" - * - * RETURN: None - * - * DESCRIPTION: Find all AML opcodes that match the input Name or name - * prefix. - * - ******************************************************************************/ - -void -AhFindAmlOpcode ( - char *Name) -{ - const AH_AML_OPCODE *Op; - BOOLEAN Found = FALSE; - - - AcpiUtStrupr (Name); - - /* Find/display all opcode names that match the input name prefix */ - - for (Op = AmlOpcodeInfo; Op->OpcodeString; Op++) - { - if (!Op->OpcodeName) /* Unused opcodes */ - { - continue; - } - - if (!Name || (Name[0] == '*')) - { - AhDisplayAmlOpcode (Op); - Found = TRUE; - continue; - } - - /* Upper case the opcode name before substring compare */ - - strcpy (Gbl_Buffer, Op->OpcodeName); - AcpiUtStrupr (Gbl_Buffer); - - if (strstr (Gbl_Buffer, Name) == Gbl_Buffer) - { - AhDisplayAmlOpcode (Op); - Found = TRUE; - } - } - - if (!Found) - { - printf ("%s, no matching AML operators\n", Name); - } -} - - -/******************************************************************************* - * - * FUNCTION: AhDecodeAmlOpcode (entry point for AML opcode search) - * - * PARAMETERS: OpcodeString - String version of AML opcode - * - * RETURN: None - * - * DESCRIPTION: Display information about the input AML opcode - * - ******************************************************************************/ - -void -AhDecodeAmlOpcode ( - char *OpcodeString) -{ - const AH_AML_OPCODE *Op; - UINT32 Opcode; - UINT8 Prefix; - - - if (!OpcodeString) - { - AhFindAmlOpcode (NULL); - return; - } - - Opcode = strtoul (OpcodeString, NULL, 16); - if (Opcode > ACPI_UINT16_MAX) - { - printf ("Invalid opcode (more than 16 bits)\n"); - return; - } - - /* Only valid opcode extension is 0x5B */ - - Prefix = (Opcode & 0x0000FF00) >> 8; - if (Prefix && (Prefix != 0x5B)) - { - printf ("Invalid opcode (invalid extension prefix 0x%X)\n", - Prefix); - return; - } - - /* Find/Display the opcode. May fall within an opcode range */ - - for (Op = AmlOpcodeInfo; Op->OpcodeString; Op++) - { - if ((Opcode >= Op->OpcodeRangeStart) && - (Opcode <= Op->OpcodeRangeEnd)) - { - AhDisplayAmlOpcode (Op); - } - } -} - - -/******************************************************************************* - * - * FUNCTION: AhDisplayAmlOpcode - * - * PARAMETERS: Op - An opcode info struct - * - * RETURN: None - * - * DESCRIPTION: Display the contents of an AML opcode information struct - * - ******************************************************************************/ - -static void -AhDisplayAmlOpcode ( - const AH_AML_OPCODE *Op) -{ - - if (!Op->OpcodeName) - { - printf ("%18s: Opcode=%-9s\n", "Reserved opcode", Op->OpcodeString); - return; - } - - /* Opcode name and value(s) */ - - printf ("%18s: Opcode=%-9s Type (%s)", - Op->OpcodeName, Op->OpcodeString, Op->Type); - - /* Optional fixed/static arguments */ - - if (Op->FixedArguments) - { - printf (" FixedArgs ("); - AhPrintOneField (37, 36 + 7 + strlen (Op->Type) + 12, - AH_MAX_AML_LINE_LENGTH, Op->FixedArguments); - printf (")"); - } - - /* Optional variable-length argument list */ - - if (Op->VariableArguments) - { - if (Op->FixedArguments) - { - printf ("\n%*s", 36, " "); - } - printf (" VariableArgs ("); - AhPrintOneField (37, 15, AH_MAX_AML_LINE_LENGTH, Op->VariableArguments); - printf (")"); - } - printf ("\n"); - - /* Grammar specification */ - - if (Op->Grammar) - { - AhPrintOneField (37, 0, AH_MAX_AML_LINE_LENGTH, Op->Grammar); - printf ("\n"); - } -} - - -/******************************************************************************* - * - * FUNCTION: AhFindAmlTypes (entry point for AML grammar keyword search) - * - * PARAMETERS: Name - Name or prefix for an AML grammar element. - * NULL means "find all" - * - * RETURN: None - * - * DESCRIPTION: Find all AML grammar keywords that match the input Name or name - * prefix. - * - ******************************************************************************/ - -void -AhFindAmlTypes ( - char *Name) -{ - const AH_AML_TYPE *Keyword; - BOOLEAN Found = FALSE; - - - AcpiUtStrupr (Name); - - for (Keyword = AmlTypesInfo; Keyword->Name; Keyword++) - { - if (!Name) - { - printf (" %s\n", Keyword->Name); - Found = TRUE; - continue; - } - - if (*Name == '*') - { - AhDisplayAmlType (Keyword); - Found = TRUE; - continue; - } - - /* Upper case the operator name before substring compare */ - - strcpy (Gbl_Buffer, Keyword->Name); - AcpiUtStrupr (Gbl_Buffer); - - if (strstr (Gbl_Buffer, Name) == Gbl_Buffer) - { - AhDisplayAmlType (Keyword); - Found = TRUE; - } - } - - if (!Found) - { - printf ("%s, no matching AML grammar type\n", Name); - } -} - - -/******************************************************************************* - * - * FUNCTION: AhDisplayAmlType - * - * PARAMETERS: Op - Pointer to AML grammar info - * - * RETURN: None - * - * DESCRIPTION: Format and display info for an AML grammar element. - * - ******************************************************************************/ - -static void -AhDisplayAmlType ( - const AH_AML_TYPE *Op) -{ - char *Description; - - - Description = Op->Description; - printf ("%4s", " "); /* Primary indent */ - - /* Emit the entire description string */ - - while (*Description) - { - /* Description can be multiple lines, must indent each */ - - while (*Description != '\n') - { - printf ("%c", *Description); - Description++; - } - - printf ("\n"); - Description++; - - /* Do indent */ - - if (*Description) - { - printf ("%8s", " "); /* Secondary indent */ - - /* Index extra for a comment */ - - if ((Description[0] == '/') && - (Description[1] == '/')) - { - printf ("%4s", " "); - } - } - } - - printf ("\n"); -} - - -/******************************************************************************* - * - * FUNCTION: AhFindAslKeywords (entry point for ASL keyword search) - * - * PARAMETERS: Name - Name or prefix for an ASL keyword. - * NULL means "find all" - * - * RETURN: None - * - * DESCRIPTION: Find all ASL keywords that match the input Name or name - * prefix. - * - ******************************************************************************/ - -void -AhFindAslKeywords ( - char *Name) -{ - const AH_ASL_KEYWORD *Keyword; - BOOLEAN Found = FALSE; - - - AcpiUtStrupr (Name); - - for (Keyword = AslKeywordInfo; Keyword->Name; Keyword++) - { - if (!Name || (Name[0] == '*')) - { - AhDisplayAslKeyword (Keyword); - Found = TRUE; - continue; - } - - /* Upper case the operator name before substring compare */ - - strcpy (Gbl_Buffer, Keyword->Name); - AcpiUtStrupr (Gbl_Buffer); - - if (strstr (Gbl_Buffer, Name) == Gbl_Buffer) - { - AhDisplayAslKeyword (Keyword); - Found = TRUE; - } - } - - if (!Found) - { - printf ("%s, no matching ASL keywords\n", Name); - } -} - - -/******************************************************************************* - * - * FUNCTION: AhDisplayAslKeyword - * - * PARAMETERS: Op - Pointer to ASL keyword with syntax info - * - * RETURN: None - * - * DESCRIPTION: Format and display syntax info for an ASL keyword. Splits - * long lines appropriately for reading. - * - ******************************************************************************/ - -static void -AhDisplayAslKeyword ( - const AH_ASL_KEYWORD *Op) -{ - - /* ASL keyword name and description */ - - printf ("%22s: %s\n", Op->Name, Op->Description); - if (!Op->KeywordList) - { - return; - } - - /* List of actual keywords */ - - AhPrintOneField (24, 0, AH_MAX_ASL_LINE_LENGTH, Op->KeywordList); - printf ("\n"); -} - - -/******************************************************************************* - * - * FUNCTION: AhFindAslAndAmlOperators - * - * PARAMETERS: Name - Name or prefix for an ASL operator. - * NULL means "find all" - * - * RETURN: None - * - * DESCRIPTION: Find all ASL operators that match the input Name or name - * prefix. Also displays the AML information if only one entry - * matches. - * - ******************************************************************************/ - -void -AhFindAslAndAmlOperators ( - char *Name) -{ - UINT32 MatchCount; - - - MatchCount = AhFindAslOperators (Name); - if (MatchCount == 1) - { - AhFindAmlOpcode (Name); - } -} - - -/******************************************************************************* - * - * FUNCTION: AhFindAslOperators (entry point for ASL operator search) - * - * PARAMETERS: Name - Name or prefix for an ASL operator. - * NULL means "find all" - * - * RETURN: Number of operators that matched the name prefix. - * - * DESCRIPTION: Find all ASL operators that match the input Name or name - * prefix. - * - ******************************************************************************/ - -UINT32 -AhFindAslOperators ( - char *Name) -{ - const AH_ASL_OPERATOR *Operator; - BOOLEAN MatchCount = 0; - - - AcpiUtStrupr (Name); - - /* Find/display all names that match the input name prefix */ - - for (Operator = AslOperatorInfo; Operator->Name; Operator++) - { - if (!Name || (Name[0] == '*')) - { - AhDisplayAslOperator (Operator); - MatchCount++; - continue; - } - - /* Upper case the operator name before substring compare */ - - strcpy (Gbl_Buffer, Operator->Name); - AcpiUtStrupr (Gbl_Buffer); - - if (strstr (Gbl_Buffer, Name) == Gbl_Buffer) - { - AhDisplayAslOperator (Operator); - MatchCount++; - } - } - - if (!MatchCount) - { - printf ("%s, no matching ASL operators\n", Name); - } - - return (MatchCount); -} - - -/******************************************************************************* - * - * FUNCTION: AhDisplayAslOperator - * - * PARAMETERS: Op - Pointer to ASL operator with syntax info - * - * RETURN: None - * - * DESCRIPTION: Format and display syntax info for an ASL operator. Splits - * long lines appropriately for reading. - * - ******************************************************************************/ - -static void -AhDisplayAslOperator ( - const AH_ASL_OPERATOR *Op) -{ - - /* ASL operator name and description */ - - printf ("%16s: %s\n", Op->Name, Op->Description); - if (!Op->Syntax) - { - return; - } - - /* Syntax for the operator */ - - AhPrintOneField (18, 0, AH_MAX_ASL_LINE_LENGTH, Op->Syntax); - printf ("\n"); - - AhDisplayOperatorKeywords (Op); - printf ("\n"); -} - - -/******************************************************************************* - * - * FUNCTION: AhDisplayOperatorKeywords - * - * PARAMETERS: Op - Pointer to ASL keyword with syntax info - * - * RETURN: None - * - * DESCRIPTION: Display any/all keywords that are associated with the ASL - * operator. - * - ******************************************************************************/ - -static void -AhDisplayOperatorKeywords ( - const AH_ASL_OPERATOR *Op) -{ - char *Token; - char *Separators = "(){}, "; - BOOLEAN FirstKeyword = TRUE; - - - if (!Op || !Op->Syntax) - { - return; - } - - /* - * Find all parameters that have the word "keyword" within, and then - * display the info about that keyword - */ - strcpy (Gbl_LineBuffer, Op->Syntax); - Token = strtok (Gbl_LineBuffer, Separators); - while (Token) - { - if (strstr (Token, "Keyword")) - { - if (FirstKeyword) - { - printf ("\n"); - FirstKeyword = FALSE; - } - - /* Found a keyword, display keyword information */ - - AhFindAslKeywords (Token); - } - - Token = strtok (NULL, Separators); - } -} - - -/******************************************************************************* - * - * FUNCTION: AhPrintOneField - * - * PARAMETERS: Indent - Indent length for new line(s) - * CurrentPosition - Position on current line - * MaxPosition - Max allowed line length - * Field - Data to output - * - * RETURN: Line position after field is written - * - * DESCRIPTION: Split long lines appropriately for ease of reading. - * - ******************************************************************************/ - -static void -AhPrintOneField ( - UINT32 Indent, - UINT32 CurrentPosition, - UINT32 MaxPosition, - const char *Field) -{ - UINT32 Position; - UINT32 TokenLength; - const char *This; - const char *Next; - const char *Last; - - - This = Field; - Position = CurrentPosition; - - if (Position == 0) - { - printf ("%*s", (int) Indent, " "); - Position = Indent; - } - - Last = This + strlen (This); - while ((Next = strpbrk (This, " "))) - { - TokenLength = Next - This; - Position += TokenLength; - - /* Split long lines */ - - if (Position > MaxPosition) - { - printf ("\n%*s", (int) Indent, " "); - Position = TokenLength; - } - - printf ("%.*s ", (int) TokenLength, This); - This = Next + 1; - } - - /* Handle last token on the input line */ - - TokenLength = Last - This; - if (TokenLength > 0) - { - Position += TokenLength; - if (Position > MaxPosition) - { - printf ("\n%*s", (int) Indent, " "); - } - - printf ("%s", This); - } -} - - -/******************************************************************************* - * * FUNCTION: AhDisplayDeviceIds * * PARAMETERS: Name - Device Hardware ID string. @@ -1049,7 +455,7 @@ AhDisplayUuids ( /* Display entire table of known ACPI-related UUIDs/GUIDs */ - for (Info = AcpiUuids; Info->Description; Info++) + for (Info = Gbl_AcpiUuids; Info->Description; Info++) { if (!Info->String) /* Null UUID string means group description */ { @@ -1096,7 +502,7 @@ AhDisplayTables ( printf ("Known ACPI tables:\n"); - for (Info = AcpiSupportedTables; Info->Signature; Info++) + for (Info = Gbl_AcpiSupportedTables; Info->Signature; Info++) { printf ("%8s : %s\n", Info->Signature, Info->Description); i++; diff --git a/source/tools/acpihelp/ahgrammar.c b/source/tools/acpihelp/ahgrammar.c index 1e0d54974689..d345893a1fb7 100644 --- a/source/tools/acpihelp/ahgrammar.c +++ b/source/tools/acpihelp/ahgrammar.c @@ -43,7 +43,7 @@ #include "acpihelp.h" -const AH_AML_TYPE AmlTypesInfo[] = +const AH_AML_TYPE Gbl_AmlTypesInfo[] = { {"ComputationalData", "ComputationalData :=\n" diff --git a/source/tools/acpihelp/ahmain.c b/source/tools/acpihelp/ahmain.c index 1c45e436269e..b62ec62f5eb1 100644 --- a/source/tools/acpihelp/ahmain.c +++ b/source/tools/acpihelp/ahmain.c @@ -41,6 +41,7 @@ * POSSIBILITY OF SUCH DAMAGES. */ +#define DEFINE_AHELP_GLOBALS #include "acpihelp.h" @@ -61,6 +62,7 @@ AhDisplayUsage ( #define ACPI_OPTION(Name, Description) \ AcpiOsPrintf (" %-24s%s\n", Name, Description); + /****************************************************************************** * * FUNCTION: AhDisplayUsage diff --git a/source/tools/efihello/efihello.c b/source/tools/efihello/efihello.c new file mode 100644 index 000000000000..ac7a64ce715b --- /dev/null +++ b/source/tools/efihello/efihello.c @@ -0,0 +1,124 @@ +/****************************************************************************** + * + * Module Name: efihello - very simple ACPICA/EFI integration example + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 - 2016, 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 "acpi.h" +#include "accommon.h" +#include "acapps.h" + + +#define LINE_SIZE 256 +static char LineBuffer[LINE_SIZE]; + +/****************************************************************************** + * + * FUNCTION: main + * + * PARAMETERS: argc/argv - Standard argc/argv + * + * RETURN: Status + * + * DESCRIPTION: C main function for efihello + * + ******************************************************************************/ + +#ifndef _GNU_EFI +int ACPI_SYSTEM_XFACE +main ( + int argc, + char *argv[]) +#else +int ACPI_SYSTEM_XFACE +acpi_main ( + int argc, + char *argv[]) +#endif +{ + ACPI_FILE File; + BOOLEAN DoCloseFile = FALSE; + char *Result; + + + AcpiOsInitialize (); + + printf ("argc=%d\n", argc); + + if (argc > 1) + { + File = fopen (argv[1], "r"); + if (!File) + { + printf ("Failed to open %s.\n", argv[1]); + return (-1); + } + DoCloseFile = TRUE; + } + else + { + File = stdin; + } + + while (1) + { + Result = fgets (LineBuffer, LINE_SIZE, File); + if (!Result) + { + printf ("Failed to read %s.\n", argv[1]); + fclose (File); + return (-2); + } + + printf ("%s", LineBuffer); + + if (strncmp (Result, "exit", 4) == 0) + { + break; + } + } + + + if (DoCloseFile) + { + fclose (File); + } + return (0); +} |