1 /******************************************************************************
3 * Module Name: prscan - Preprocessor start-up and file scan module
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2015, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
44 #define _DECLARE_PR_GLOBALS
46 #include <contrib/dev/acpica/compiler/aslcompiler.h>
47 #include <contrib/dev/acpica/compiler/dtcompiler.h>
52 * No nested macros, maybe never
53 * Implement ASL "Include" as well as "#include" here?
55 #define _COMPONENT ASL_PREPROCESSOR
56 ACPI_MODULE_NAME ("prscan")
59 /* Local prototypes */
62 PrPreprocessInputFile (
107 * Supported preprocessor directives
108 * Each entry is of the form "Name, ArgumentCount"
110 static const PR_DIRECTIVE_INFO Gbl_DirectiveInfo[] =
113 {"elif", 0}, /* Converted to #else..#if internally */
120 {"include", 0}, /* Argument is not standard format, so just use 0 here */
121 {"includebuffer", 0}, /* Argument is not standard format, so just use 0 here */
130 /* This table must match ordering of above table exactly */
132 enum Gbl_DirectiveIndexes
134 PR_DIRECTIVE_DEFINE = 0,
142 PR_DIRECTIVE_INCLUDE,
143 PR_DIRECTIVE_INCLUDEBUFFER,
147 PR_DIRECTIVE_WARNING,
150 #define ASL_DIRECTIVE_NOT_FOUND -1
153 /*******************************************************************************
155 * FUNCTION: PrInitializePreprocessor
161 * DESCRIPTION: Startup initialization for the Preprocessor.
163 ******************************************************************************/
166 PrInitializePreprocessor (
169 /* Init globals and the list of #defines */
171 PrInitializeGlobals ();
172 Gbl_DefineList = NULL;
176 /*******************************************************************************
178 * FUNCTION: PrInitializeGlobals
184 * DESCRIPTION: Initialize globals for the Preprocessor. Used for startuup
185 * initialization and re-initialization between compiles during
186 * a multiple source file compile.
188 ******************************************************************************/
191 PrInitializeGlobals (
196 Gbl_InputFileList = NULL;
197 Gbl_CurrentLineNumber = 1;
198 Gbl_PreprocessorLineNumber = 1;
199 Gbl_PreprocessorError = FALSE;
201 /* These are used to track #if/#else blocks (possibly nested) */
204 Gbl_IgnoringThisCodeBlock = FALSE;
205 Gbl_DirectiveStack = NULL;
209 /*******************************************************************************
211 * FUNCTION: PrTerminatePreprocessor
217 * DESCRIPTION: Termination of the preprocessor. Delete lists. Keep any
218 * defines that were specified on the command line, in order to
219 * support multiple compiles with a single compiler invocation.
221 ******************************************************************************/
224 PrTerminatePreprocessor (
227 PR_DEFINE_INFO *DefineInfo;
231 * The persistent defines (created on the command line) are always at the
232 * end of the list. We save them.
234 while ((Gbl_DefineList) && (!Gbl_DefineList->Persist))
236 DefineInfo = Gbl_DefineList;
237 Gbl_DefineList = DefineInfo->Next;
239 ACPI_FREE (DefineInfo->Replacement);
240 ACPI_FREE (DefineInfo->Identifier);
241 ACPI_FREE (DefineInfo);
246 /*******************************************************************************
248 * FUNCTION: PrDoPreprocess
254 * DESCRIPTION: Main entry point for the iASL Preprocessor. Input file must
255 * be already open. Handles multiple input files via the
256 * #include directive.
258 ******************************************************************************/
264 BOOLEAN MoreInputFiles;
267 DbgPrint (ASL_DEBUG_OUTPUT, "Starting preprocessing phase\n\n");
270 FlSeekFile (ASL_FILE_INPUT, 0);
271 PrDumpPredefinedNames ();
273 /* Main preprocessor loop, handles include files */
277 PrPreprocessInputFile ();
278 MoreInputFiles = PrPopInputFileStack ();
280 } while (MoreInputFiles);
282 /* Point compiler input to the new preprocessor output file (.pre) */
284 FlCloseFile (ASL_FILE_INPUT);
285 Gbl_Files[ASL_FILE_INPUT].Handle = Gbl_Files[ASL_FILE_PREPROCESSOR].Handle;
286 AslCompilerin = Gbl_Files[ASL_FILE_INPUT].Handle;
288 /* Reset globals to allow compiler to run */
290 FlSeekFile (ASL_FILE_INPUT, 0);
291 if (!Gbl_PreprocessOnly)
293 Gbl_CurrentLineNumber = 0;
296 DbgPrint (ASL_DEBUG_OUTPUT, "Preprocessing phase complete \n\n");
300 /*******************************************************************************
302 * FUNCTION: PrPreprocessInputFile
308 * DESCRIPTION: Preprocess one entire file, line-by-line.
310 * Input: Raw user ASL from ASL_FILE_INPUT
311 * Output: Preprocessed file written to ASL_FILE_PREPROCESSOR and
312 * (optionally) ASL_FILE_PREPROCESSOR_USER
314 ******************************************************************************/
317 PrPreprocessInputFile (
323 PR_DEFINE_INFO *DefineInfo;
324 ACPI_SIZE TokenOffset;
329 PrGetNextLineInit ();
331 /* Scan line-by-line. Comments and blank lines are skipped by this function */
333 while ((Status = PrGetNextLine (Gbl_Files[ASL_FILE_INPUT].Handle)) != ASL_EOF)
335 Gbl_CurrentLineNumber++;
336 Gbl_LogicalLineNumber++;
338 if ((Status == ASL_WITHIN_COMMENT) ||
339 (Status == ASL_BLANK_LINE))
341 goto WriteEntireLine;
344 /* Need a copy of the input line for strok() */
346 strcpy (Gbl_MainTokenBuffer, Gbl_CurrentLineBuffer);
347 Token = PrGetNextToken (Gbl_MainTokenBuffer, PR_TOKEN_SEPARATORS, &Next);
350 /* All preprocessor directives must begin with '#' */
352 if (Token && (*Token == '#'))
354 if (strlen (Token) == 1)
356 Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, &Next);
360 Token++; /* Skip leading # */
363 /* Execute the directive, do not write line to output file */
365 PrDoDirective (Token, &Next);
370 * If we are currently within the part of an IF/ELSE block that is
371 * FALSE, ignore the line and do not write it to the output file.
372 * This continues until an #else or #endif is encountered.
374 if (Gbl_IgnoringThisCodeBlock)
379 /* Match and replace all #defined names within this source line */
383 DefineInfo = PrMatchDefine (Token);
386 if (DefineInfo->Body)
388 /* This is a macro */
390 DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
391 "Matched Macro: %s->%s\n",
392 Gbl_CurrentLineNumber, DefineInfo->Identifier,
393 DefineInfo->Replacement);
395 PrDoMacroInvocation (Gbl_MainTokenBuffer, Token,
400 ReplaceString = DefineInfo->Replacement;
402 /* Replace the name in the original line buffer */
404 TokenOffset = Token - Gbl_MainTokenBuffer + OffsetAdjust;
406 &Gbl_CurrentLineBuffer[TokenOffset], strlen (Token),
407 ReplaceString, strlen (ReplaceString));
409 /* Adjust for length difference between old and new name length */
411 OffsetAdjust += strlen (ReplaceString) - strlen (Token);
413 DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
414 "Matched #define: %s->%s\n",
415 Gbl_CurrentLineNumber, Token,
416 *ReplaceString ? ReplaceString : "(NULL STRING)");
420 Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, &Next);
423 Gbl_PreprocessorLineNumber++;
428 * Now we can write the possibly modified source line to the
429 * preprocessor file(s).
431 FlWriteFile (ASL_FILE_PREPROCESSOR, Gbl_CurrentLineBuffer,
432 strlen (Gbl_CurrentLineBuffer));
437 /*******************************************************************************
439 * FUNCTION: PrDoDirective
441 * PARAMETERS: Directive - Pointer to directive name token
442 * Next - "Next" buffer from GetNextToken
446 * DESCRIPTION: Main processing for all preprocessor directives
448 ******************************************************************************/
452 char *DirectiveToken,
455 char *Token = Gbl_MainTokenBuffer;
459 ACPI_SIZE TokenOffset;
469 Directive = PrMatchDirective (DirectiveToken);
470 if (Directive == ASL_DIRECTIVE_NOT_FOUND)
472 PrError (ASL_ERROR, ASL_MSG_UNKNOWN_DIRECTIVE,
473 THIS_TOKEN_OFFSET (DirectiveToken));
475 DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
476 "#%s: Unknown directive\n",
477 Gbl_CurrentLineNumber, DirectiveToken);
482 * If we are currently ignoring this block and we encounter a #else or
483 * #elif, we must ignore their blocks also if the parent block is also
486 if (Gbl_IgnoringThisCodeBlock)
490 case PR_DIRECTIVE_ELSE:
491 case PR_DIRECTIVE_ELIF:
493 if (Gbl_DirectiveStack && Gbl_DirectiveStack->IgnoringThisCodeBlock)
495 PrDbgPrint ("Ignoring", Gbl_DirectiveInfo[Directive].Name);
506 * Need to always check for #else, #elif, #endif regardless of
507 * whether we are ignoring the current code block, since these
508 * are conditional code block terminators.
512 case PR_DIRECTIVE_ELSE:
514 Gbl_IgnoringThisCodeBlock = !(Gbl_IgnoringThisCodeBlock);
515 PrDbgPrint ("Executing", "else block");
518 case PR_DIRECTIVE_ELIF:
520 Gbl_IgnoringThisCodeBlock = !(Gbl_IgnoringThisCodeBlock);
521 Directive = PR_DIRECTIVE_IF;
523 if (Gbl_IgnoringThisCodeBlock == TRUE)
525 /* Not executing the ELSE part -- all done here */
526 PrDbgPrint ("Ignoring", "elif block");
531 * After this, we will execute the IF part further below.
532 * First, however, pop off the original #if directive.
534 if (ACPI_FAILURE (PrPopDirective ()))
536 PrError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL,
537 THIS_TOKEN_OFFSET (DirectiveToken));
540 PrDbgPrint ("Executing", "elif block");
543 case PR_DIRECTIVE_ENDIF:
545 PrDbgPrint ("Executing", "endif");
547 /* Pop the owning #if/#ifdef/#ifndef */
549 if (ACPI_FAILURE (PrPopDirective ()))
551 PrError (ASL_ERROR, ASL_MSG_ENDIF_MISMATCH,
552 THIS_TOKEN_OFFSET (DirectiveToken));
560 /* Most directives have at least one argument */
562 if (Gbl_DirectiveInfo[Directive].ArgCount >= 1)
564 Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next);
571 if (Gbl_DirectiveInfo[Directive].ArgCount >= 2)
573 Token2 = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next);
581 * At this point, if we are ignoring the current code block,
582 * do not process any more directives (i.e., ignore them also.)
583 * For "if" style directives, open/push a new block anyway. We
584 * must do this to keep track of #endif directives
586 if (Gbl_IgnoringThisCodeBlock)
590 case PR_DIRECTIVE_IF:
591 case PR_DIRECTIVE_IFDEF:
592 case PR_DIRECTIVE_IFNDEF:
594 PrPushDirective (Directive, Token);
595 PrDbgPrint ("Ignoring", Gbl_DirectiveInfo[Directive].Name);
606 * Execute the directive
608 PrDbgPrint ("Begin execution", Gbl_DirectiveInfo[Directive].Name);
612 case PR_DIRECTIVE_IF:
614 TokenOffset = Token - Gbl_MainTokenBuffer;
616 /* Need to expand #define macros in the expression string first */
618 Status = PrResolveIntegerExpression (
619 &Gbl_CurrentLineBuffer[TokenOffset-1], &Value);
620 if (ACPI_FAILURE (Status))
625 PrPushDirective (Directive, Token);
628 Gbl_IgnoringThisCodeBlock = TRUE;
631 DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
632 "Resolved #if: %8.8X%8.8X %s\n",
633 Gbl_CurrentLineNumber, ACPI_FORMAT_UINT64 (Value),
634 Gbl_IgnoringThisCodeBlock ? "<Skipping Block>" : "<Executing Block>");
637 case PR_DIRECTIVE_IFDEF:
639 PrPushDirective (Directive, Token);
640 if (!PrMatchDefine (Token))
642 Gbl_IgnoringThisCodeBlock = TRUE;
645 PrDbgPrint ("Evaluated", "ifdef");
648 case PR_DIRECTIVE_IFNDEF:
650 PrPushDirective (Directive, Token);
651 if (PrMatchDefine (Token))
653 Gbl_IgnoringThisCodeBlock = TRUE;
656 PrDbgPrint ("Evaluated", "ifndef");
659 case PR_DIRECTIVE_DEFINE:
661 * By definition, if first char after the name is a paren,
662 * this is a function macro.
664 TokenOffset = Token - Gbl_MainTokenBuffer + strlen (Token);
665 if (*(&Gbl_CurrentLineBuffer[TokenOffset]) == '(')
667 #ifndef MACROS_SUPPORTED
668 AcpiOsPrintf ("%s ERROR - line %u: #define macros are not supported yet\n",
669 Gbl_CurrentLineBuffer, Gbl_LogicalLineNumber);
672 PrAddMacro (Token, Next);
677 /* Use the remainder of the line for the #define */
682 while ((*Token2 == ' ') || (*Token2 == '\t'))
698 Token2 = PrGetNextToken (NULL, "\n", /*PR_TOKEN_SEPARATORS,*/ Next);
704 DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
705 "New #define: %s->%s\n",
706 Gbl_LogicalLineNumber, Token, Token2);
708 PrAddDefine (Token, Token2, FALSE);
712 case PR_DIRECTIVE_ERROR:
714 /* Note: No macro expansion */
716 PrError (ASL_ERROR, ASL_MSG_ERROR_DIRECTIVE,
717 THIS_TOKEN_OFFSET (Token));
720 Gbl_NextError = Gbl_ErrorLog;
724 case PR_DIRECTIVE_INCLUDE:
726 Token = PrGetNextToken (NULL, " \"<>", Next);
732 DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
733 "Start #include file \"%s\"\n", Gbl_CurrentLineNumber,
734 Token, Gbl_CurrentLineNumber);
736 PrDoIncludeFile (Token);
739 case PR_DIRECTIVE_INCLUDEBUFFER:
741 Token = PrGetNextToken (NULL, " \"<>", Next);
747 Token2 = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next);
753 DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
754 "Start #includebuffer input from file \"%s\", buffer name %s\n",
755 Gbl_CurrentLineNumber, Token, Token2);
757 PrDoIncludeBuffer (Token, Token2);
760 case PR_DIRECTIVE_LINE:
762 TokenOffset = Token - Gbl_MainTokenBuffer;
764 Status = PrResolveIntegerExpression (
765 &Gbl_CurrentLineBuffer[TokenOffset-1], &Value);
766 if (ACPI_FAILURE (Status))
771 DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
772 "User #line invocation %s\n", Gbl_CurrentLineNumber,
775 Gbl_CurrentLineNumber = (UINT32) Value;
777 /* Emit #line into the preprocessor file */
779 FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\"\n",
780 Gbl_CurrentLineNumber, Gbl_Files[ASL_FILE_INPUT].Filename);
783 case PR_DIRECTIVE_PRAGMA:
785 if (!strcmp (Token, "disable"))
787 Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next);
793 TokenOffset = Token - Gbl_MainTokenBuffer;
794 AslDisableException (&Gbl_CurrentLineBuffer[TokenOffset]);
796 else if (!strcmp (Token, "message"))
798 Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next);
804 TokenOffset = Token - Gbl_MainTokenBuffer;
805 AcpiOsPrintf ("%s\n", &Gbl_CurrentLineBuffer[TokenOffset]);
809 PrError (ASL_ERROR, ASL_MSG_UNKNOWN_PRAGMA,
810 THIS_TOKEN_OFFSET (Token));
816 case PR_DIRECTIVE_UNDEF:
818 DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
819 "#undef: %s\n", Gbl_CurrentLineNumber, Token);
821 PrRemoveDefine (Token);
824 case PR_DIRECTIVE_WARNING:
826 PrError (ASL_WARNING, ASL_MSG_WARNING_DIRECTIVE,
827 THIS_TOKEN_OFFSET (Token));
832 /* Should never get here */
833 DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
834 "Unrecognized directive: %u\n",
835 Gbl_CurrentLineNumber, Directive);
843 PrError (ASL_ERROR, ASL_MSG_DIRECTIVE_SYNTAX,
844 THIS_TOKEN_OFFSET (DirectiveToken));
849 /*******************************************************************************
851 * FUNCTION: PrGetNextLine, PrGetNextLineInit
853 * PARAMETERS: Handle - Open file handle for the source file
855 * RETURN: Status of the GetLine operation:
856 * AE_OK - Normal line, OK status
857 * ASL_WITHIN_COMMENT - Line is part of a multi-line comment
858 * ASL_EOF - End-of-file reached
860 * DESCRIPTION: Get the next text line from the input file. Does not strip
863 ******************************************************************************/
865 #define PR_NORMAL_TEXT 0
866 #define PR_WITHIN_COMMENT 1
868 static UINT8 AcpiGbl_LineScanState = PR_NORMAL_TEXT;
874 AcpiGbl_LineScanState = 0;
886 /* Always clear the global line buffer */
888 memset (Gbl_CurrentLineBuffer, 0, Gbl_LineBufferSize);
892 * If line is too long, expand the line buffers. Also increases
893 * Gbl_LineBufferSize.
895 if (i >= Gbl_LineBufferSize)
897 UtExpandLineBuffers ();
907 /* We need to worry about multi-line slash-asterisk comments */
909 /* Check for comment open */
911 if ((AcpiGbl_LineScanState == PR_NORMAL_TEXT) &&
912 (PreviousChar == '/') && (c == '*'))
914 AcpiGbl_LineScanState = PR_WITHIN_COMMENT;
917 /* Check for comment close */
919 if ((AcpiGbl_LineScanState == PR_WITHIN_COMMENT) &&
920 (PreviousChar == '*') && (c == '/'))
922 AcpiGbl_LineScanState = PR_NORMAL_TEXT;
925 /* Always copy the character into line buffer */
927 Gbl_CurrentLineBuffer[i] = (char) c;
930 /* Always exit on end-of-line */
934 /* Handle multi-line comments */
936 if (AcpiGbl_LineScanState == PR_WITHIN_COMMENT)
938 return (ASL_WITHIN_COMMENT);
942 return (ASL_BLANK_LINE);
950 /*******************************************************************************
952 * FUNCTION: PrMatchDirective
954 * PARAMETERS: Directive - Pointer to directive name token
956 * RETURN: Index into command array, -1 if not found
958 * DESCRIPTION: Lookup the incoming directive in the known directives table.
960 ******************************************************************************/
969 if (!Directive || Directive[0] == 0)
971 return (ASL_DIRECTIVE_NOT_FOUND);
974 for (i = 0; Gbl_DirectiveInfo[i].Name; i++)
976 if (!strcmp (Gbl_DirectiveInfo[i].Name, Directive))
982 return (ASL_DIRECTIVE_NOT_FOUND); /* Command not recognized */
986 /*******************************************************************************
988 * FUNCTION: PrPushDirective
990 * PARAMETERS: Directive - Encoded directive ID
991 * Argument - String containing argument to the
996 * DESCRIPTION: Push an item onto the directive stack. Used for processing
997 * nested #if/#else type conditional compilation directives.
998 * Specifically: Used on detection of #if/#ifdef/#ifndef to open
1001 ******************************************************************************/
1008 DIRECTIVE_INFO *Info;
1011 /* Allocate and populate a stack info item */
1013 Info = ACPI_ALLOCATE (sizeof (DIRECTIVE_INFO));
1015 Info->Next = Gbl_DirectiveStack;
1016 Info->Directive = Directive;
1017 Info->IgnoringThisCodeBlock = Gbl_IgnoringThisCodeBlock;
1018 strncpy (Info->Argument, Argument, MAX_ARGUMENT_LENGTH);
1020 DbgPrint (ASL_DEBUG_OUTPUT,
1021 "Pr(%.4u) - [%u %s] %*s Pushed [#%s %s]: IgnoreFlag = %s\n",
1022 Gbl_CurrentLineNumber, Gbl_IfDepth,
1023 Gbl_IgnoringThisCodeBlock ? "I" : "E",
1024 Gbl_IfDepth * 4, " ",
1025 Gbl_DirectiveInfo[Directive].Name,
1026 Argument, Gbl_IgnoringThisCodeBlock ? "TRUE" : "FALSE");
1030 Gbl_DirectiveStack = Info;
1035 /*******************************************************************************
1037 * FUNCTION: PrPopDirective
1041 * RETURN: Status. Error if the stack is empty.
1043 * DESCRIPTION: Pop an item off the directive stack. Used for processing
1044 * nested #if/#else type conditional compilation directives.
1045 * Specifically: Used on detection of #elif and #endif to remove
1046 * the original #if/#ifdef/#ifndef from the stack and close
1049 ******************************************************************************/
1055 DIRECTIVE_INFO *Info;
1058 /* Check for empty stack */
1060 Info = Gbl_DirectiveStack;
1066 /* Pop one item, keep globals up-to-date */
1069 Gbl_IgnoringThisCodeBlock = Info->IgnoringThisCodeBlock;
1070 Gbl_DirectiveStack = Info->Next;
1072 DbgPrint (ASL_DEBUG_OUTPUT,
1073 "Pr(%.4u) - [%u %s] %*s Popped [#%s %s]: IgnoreFlag now = %s\n",
1074 Gbl_CurrentLineNumber, Gbl_IfDepth,
1075 Gbl_IgnoringThisCodeBlock ? "I" : "E",
1076 Gbl_IfDepth * 4, " ",
1077 Gbl_DirectiveInfo[Info->Directive].Name,
1078 Info->Argument, Gbl_IgnoringThisCodeBlock ? "TRUE" : "FALSE");
1085 /*******************************************************************************
1087 * FUNCTION: PrDbgPrint
1089 * PARAMETERS: Action - Action being performed
1090 * DirectiveName - Directive being processed
1094 * DESCRIPTION: Special debug print for directive processing.
1096 ******************************************************************************/
1101 char *DirectiveName)
1104 DbgPrint (ASL_DEBUG_OUTPUT, "Pr(%.4u) - [%u %s] "
1105 "%*s %s #%s, IfDepth %u\n",
1106 Gbl_CurrentLineNumber, Gbl_IfDepth,
1107 Gbl_IgnoringThisCodeBlock ? "I" : "E",
1108 Gbl_IfDepth * 4, " ",
1109 Action, DirectiveName, Gbl_IfDepth);
1113 /*******************************************************************************
1115 * FUNCTION: PrDoIncludeFile
1117 * PARAMETERS: Pathname - Name of the input file
1121 * DESCRIPTION: Open an include file, from #include.
1123 ******************************************************************************/
1132 (void) PrOpenIncludeFile (Pathname, "r", &FullPathname);
1136 /*******************************************************************************
1138 * FUNCTION: PrDoIncludeBuffer
1140 * PARAMETERS: Pathname - Name of the input binary file
1141 * BufferName - ACPI namepath of the buffer
1145 * DESCRIPTION: Create an ACPI buffer object from a binary file. The contents
1146 * of the file are emitted into the buffer object as ascii
1147 * hex data. From #includebuffer.
1149 ******************************************************************************/
1157 FILE *BinaryBufferFile;
1162 BinaryBufferFile = PrOpenIncludeFile (Pathname, "rb", &FullPathname);
1163 if (!BinaryBufferFile)
1168 /* Emit "Name (XXXX, Buffer() {" header */
1170 FlPrintFile (ASL_FILE_PREPROCESSOR, "Name (%s, Buffer()\n{", BufferName);
1172 /* Dump the entire file in ascii hex format */
1174 while (fread (&c, 1, 1, BinaryBufferFile))
1178 FlPrintFile (ASL_FILE_PREPROCESSOR, "\n ", c);
1181 FlPrintFile (ASL_FILE_PREPROCESSOR, " 0x%2.2X,", c);
1185 DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
1186 "#includebuffer: read %u bytes from %s\n",
1187 Gbl_CurrentLineNumber, i, FullPathname);
1189 /* Close the Name() operator */
1191 FlPrintFile (ASL_FILE_PREPROCESSOR, "\n})\n", BufferName);
1192 fclose (BinaryBufferFile);