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 (
99 * Supported preprocessor directives
100 * Each entry is of the form "Name, ArgumentCount"
102 static const PR_DIRECTIVE_INFO Gbl_DirectiveInfo[] =
105 {"elif", 0}, /* Converted to #else..#if internally */
112 {"include", 0}, /* Argument is not standard format, so just use 0 here */
113 {"includebuffer", 0}, /* Argument is not standard format, so just use 0 here */
122 /* This table must match ordering of above table exactly */
124 enum Gbl_DirectiveIndexes
126 PR_DIRECTIVE_DEFINE = 0,
134 PR_DIRECTIVE_INCLUDE,
135 PR_DIRECTIVE_INCLUDEBUFFER,
139 PR_DIRECTIVE_WARNING,
142 #define ASL_DIRECTIVE_NOT_FOUND -1
145 /*******************************************************************************
147 * FUNCTION: PrInitializePreprocessor
153 * DESCRIPTION: Startup initialization for the Preprocessor.
155 ******************************************************************************/
158 PrInitializePreprocessor (
161 /* Init globals and the list of #defines */
163 PrInitializeGlobals ();
164 Gbl_DefineList = NULL;
168 /*******************************************************************************
170 * FUNCTION: PrInitializeGlobals
176 * DESCRIPTION: Initialize globals for the Preprocessor. Used for startuup
177 * initialization and re-initialization between compiles during
178 * a multiple source file compile.
180 ******************************************************************************/
183 PrInitializeGlobals (
188 Gbl_InputFileList = NULL;
189 Gbl_CurrentLineNumber = 0;
190 Gbl_PreprocessorLineNumber = 1;
191 Gbl_PreprocessorError = FALSE;
193 /* These are used to track #if/#else blocks (possibly nested) */
196 Gbl_IgnoringThisCodeBlock = FALSE;
197 Gbl_DirectiveStack = NULL;
201 /*******************************************************************************
203 * FUNCTION: PrTerminatePreprocessor
209 * DESCRIPTION: Termination of the preprocessor. Delete lists. Keep any
210 * defines that were specified on the command line, in order to
211 * support multiple compiles with a single compiler invocation.
213 ******************************************************************************/
216 PrTerminatePreprocessor (
219 PR_DEFINE_INFO *DefineInfo;
223 * The persistent defines (created on the command line) are always at the
224 * end of the list. We save them.
226 while ((Gbl_DefineList) && (!Gbl_DefineList->Persist))
228 DefineInfo = Gbl_DefineList;
229 Gbl_DefineList = DefineInfo->Next;
231 ACPI_FREE (DefineInfo->Replacement);
232 ACPI_FREE (DefineInfo->Identifier);
233 ACPI_FREE (DefineInfo);
238 /*******************************************************************************
240 * FUNCTION: PrDoPreprocess
246 * DESCRIPTION: Main entry point for the iASL Preprocessor. Input file must
247 * be already open. Handles multiple input files via the
248 * #include directive.
250 ******************************************************************************/
256 BOOLEAN MoreInputFiles;
259 DbgPrint (ASL_DEBUG_OUTPUT, "Starting preprocessing phase\n\n");
262 FlSeekFile (ASL_FILE_INPUT, 0);
263 PrDumpPredefinedNames ();
265 /* Main preprocessor loop, handles include files */
269 PrPreprocessInputFile ();
270 MoreInputFiles = PrPopInputFileStack ();
272 } while (MoreInputFiles);
274 /* Point compiler input to the new preprocessor output file (.i) */
276 FlCloseFile (ASL_FILE_INPUT);
277 Gbl_Files[ASL_FILE_INPUT].Handle = Gbl_Files[ASL_FILE_PREPROCESSOR].Handle;
278 AslCompilerin = Gbl_Files[ASL_FILE_INPUT].Handle;
280 /* Reset globals to allow compiler to run */
282 FlSeekFile (ASL_FILE_INPUT, 0);
283 Gbl_CurrentLineNumber = 1;
285 DbgPrint (ASL_DEBUG_OUTPUT, "Preprocessing phase complete \n\n");
289 /*******************************************************************************
291 * FUNCTION: PrPreprocessInputFile
297 * DESCRIPTION: Preprocess one entire file, line-by-line.
299 * Input: Raw user ASL from ASL_FILE_INPUT
300 * Output: Preprocessed file written to ASL_FILE_PREPROCESSOR
302 ******************************************************************************/
305 PrPreprocessInputFile (
311 PR_DEFINE_INFO *DefineInfo;
312 ACPI_SIZE TokenOffset;
317 /* Scan line-by-line. Comments and blank lines are skipped by this function */
319 while ((Offset = DtGetNextLine (Gbl_Files[ASL_FILE_INPUT].Handle)) != ASL_EOF)
321 /* Need a copy of the input line for strok() */
323 strcpy (Gbl_MainTokenBuffer, Gbl_CurrentLineBuffer);
324 Token = PrGetNextToken (Gbl_MainTokenBuffer, PR_TOKEN_SEPARATORS, &Next);
327 /* All preprocessor directives must begin with '#' */
329 if (Token && (*Token == '#'))
331 if (strlen (Token) == 1)
333 Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, &Next);
337 Token++; /* Skip leading # */
340 /* Execute the directive, do not write line to output file */
342 PrDoDirective (Token, &Next);
347 * If we are currently within the part of an IF/ELSE block that is
348 * FALSE, ignore the line and do not write it to the output file.
349 * This continues until an #else or #endif is encountered.
351 if (Gbl_IgnoringThisCodeBlock)
356 /* Match and replace all #defined names within this source line */
360 DefineInfo = PrMatchDefine (Token);
363 if (DefineInfo->Body)
365 /* This is a macro */
367 DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
368 "Matched Macro: %s->%s\n",
369 Gbl_CurrentLineNumber, DefineInfo->Identifier,
370 DefineInfo->Replacement);
372 PrDoMacroInvocation (Gbl_MainTokenBuffer, Token,
377 ReplaceString = DefineInfo->Replacement;
379 /* Replace the name in the original line buffer */
381 TokenOffset = Token - Gbl_MainTokenBuffer + OffsetAdjust;
383 &Gbl_CurrentLineBuffer[TokenOffset], strlen (Token),
384 ReplaceString, strlen (ReplaceString));
386 /* Adjust for length difference between old and new name length */
388 OffsetAdjust += strlen (ReplaceString) - strlen (Token);
390 DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
391 "Matched #define: %s->%s\n",
392 Gbl_CurrentLineNumber, Token,
393 *ReplaceString ? ReplaceString : "(NULL STRING)");
397 Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, &Next);
401 * Emit a #line directive if necessary, to keep the line numbers in
402 * the (.i) file synchronized with the original source code file, so
403 * that the correct line number appears in any error messages
404 * generated by the actual compiler.
406 if (Gbl_CurrentLineNumber > (Gbl_PreviousLineNumber + 1))
408 FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u\n",
409 Gbl_CurrentLineNumber);
412 Gbl_PreviousLineNumber = Gbl_CurrentLineNumber;
413 Gbl_PreprocessorLineNumber++;
416 * Now we can write the possibly modified source line to the
417 * preprocessor (.i) file
419 FlWriteFile (ASL_FILE_PREPROCESSOR, Gbl_CurrentLineBuffer,
420 strlen (Gbl_CurrentLineBuffer));
425 /*******************************************************************************
427 * FUNCTION: PrDoDirective
429 * PARAMETERS: Directive - Pointer to directive name token
430 * Next - "Next" buffer from GetNextToken
434 * DESCRIPTION: Main processing for all preprocessor directives
436 ******************************************************************************/
440 char *DirectiveToken,
443 char *Token = Gbl_MainTokenBuffer;
447 ACPI_SIZE TokenOffset;
457 Directive = PrMatchDirective (DirectiveToken);
458 if (Directive == ASL_DIRECTIVE_NOT_FOUND)
460 PrError (ASL_ERROR, ASL_MSG_UNKNOWN_DIRECTIVE,
461 THIS_TOKEN_OFFSET (DirectiveToken));
463 DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
464 "#%s: Unknown directive\n",
465 Gbl_CurrentLineNumber, DirectiveToken);
470 * If we are currently ignoring this block and we encounter a #else or
471 * #elif, we must ignore their blocks also if the parent block is also
474 if (Gbl_IgnoringThisCodeBlock)
478 case PR_DIRECTIVE_ELSE:
479 case PR_DIRECTIVE_ELIF:
481 if (Gbl_DirectiveStack && Gbl_DirectiveStack->IgnoringThisCodeBlock)
483 PrDbgPrint ("Ignoring", Gbl_DirectiveInfo[Directive].Name);
494 * Need to always check for #else, #elif, #endif regardless of
495 * whether we are ignoring the current code block, since these
496 * are conditional code block terminators.
500 case PR_DIRECTIVE_ELSE:
502 Gbl_IgnoringThisCodeBlock = !(Gbl_IgnoringThisCodeBlock);
503 PrDbgPrint ("Executing", "else block");
506 case PR_DIRECTIVE_ELIF:
508 Gbl_IgnoringThisCodeBlock = !(Gbl_IgnoringThisCodeBlock);
509 Directive = PR_DIRECTIVE_IF;
511 if (Gbl_IgnoringThisCodeBlock == TRUE)
513 /* Not executing the ELSE part -- all done here */
514 PrDbgPrint ("Ignoring", "elif block");
519 * After this, we will execute the IF part further below.
520 * First, however, pop off the original #if directive.
522 if (ACPI_FAILURE (PrPopDirective ()))
524 PrError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL,
525 THIS_TOKEN_OFFSET (DirectiveToken));
528 PrDbgPrint ("Executing", "elif block");
531 case PR_DIRECTIVE_ENDIF:
533 PrDbgPrint ("Executing", "endif");
535 /* Pop the owning #if/#ifdef/#ifndef */
537 if (ACPI_FAILURE (PrPopDirective ()))
539 PrError (ASL_ERROR, ASL_MSG_ENDIF_MISMATCH,
540 THIS_TOKEN_OFFSET (DirectiveToken));
548 /* Most directives have at least one argument */
550 if (Gbl_DirectiveInfo[Directive].ArgCount >= 1)
552 Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next);
559 if (Gbl_DirectiveInfo[Directive].ArgCount >= 2)
561 Token2 = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next);
569 * At this point, if we are ignoring the current code block,
570 * do not process any more directives (i.e., ignore them also.)
571 * For "if" style directives, open/push a new block anyway. We
572 * must do this to keep track of #endif directives
574 if (Gbl_IgnoringThisCodeBlock)
578 case PR_DIRECTIVE_IF:
579 case PR_DIRECTIVE_IFDEF:
580 case PR_DIRECTIVE_IFNDEF:
582 PrPushDirective (Directive, Token);
583 PrDbgPrint ("Ignoring", Gbl_DirectiveInfo[Directive].Name);
594 * Execute the directive
596 PrDbgPrint ("Begin execution", Gbl_DirectiveInfo[Directive].Name);
600 case PR_DIRECTIVE_IF:
602 TokenOffset = Token - Gbl_MainTokenBuffer;
604 /* Need to expand #define macros in the expression string first */
606 Status = PrResolveIntegerExpression (
607 &Gbl_CurrentLineBuffer[TokenOffset-1], &Value);
608 if (ACPI_FAILURE (Status))
613 PrPushDirective (Directive, Token);
616 Gbl_IgnoringThisCodeBlock = TRUE;
619 DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
620 "Resolved #if: %8.8X%8.8X %s\n",
621 Gbl_CurrentLineNumber, ACPI_FORMAT_UINT64 (Value),
622 Gbl_IgnoringThisCodeBlock ? "<Skipping Block>" : "<Executing Block>");
625 case PR_DIRECTIVE_IFDEF:
627 PrPushDirective (Directive, Token);
628 if (!PrMatchDefine (Token))
630 Gbl_IgnoringThisCodeBlock = TRUE;
633 PrDbgPrint ("Evaluated", "ifdef");
636 case PR_DIRECTIVE_IFNDEF:
638 PrPushDirective (Directive, Token);
639 if (PrMatchDefine (Token))
641 Gbl_IgnoringThisCodeBlock = TRUE;
644 PrDbgPrint ("Evaluated", "ifndef");
647 case PR_DIRECTIVE_DEFINE:
649 * By definition, if first char after the name is a paren,
650 * this is a function macro.
652 TokenOffset = Token - Gbl_MainTokenBuffer + strlen (Token);
653 if (*(&Gbl_CurrentLineBuffer[TokenOffset]) == '(')
655 #ifndef MACROS_SUPPORTED
656 AcpiOsPrintf ("%s ERROR - line %u: #define macros are not supported yet\n",
657 Gbl_CurrentLineBuffer, Gbl_CurrentLineNumber);
660 PrAddMacro (Token, Next);
665 /* Use the remainder of the line for the #define */
670 while ((*Token2 == ' ') || (*Token2 == '\t'))
686 Token2 = PrGetNextToken (NULL, "\n", /*PR_TOKEN_SEPARATORS,*/ Next);
692 DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
693 "New #define: %s->%s\n",
694 Gbl_CurrentLineNumber, Token, Token2);
696 PrAddDefine (Token, Token2, FALSE);
700 case PR_DIRECTIVE_ERROR:
702 /* Note: No macro expansion */
704 PrError (ASL_ERROR, ASL_MSG_ERROR_DIRECTIVE,
705 THIS_TOKEN_OFFSET (Token));
708 Gbl_NextError = Gbl_ErrorLog;
712 case PR_DIRECTIVE_INCLUDE:
714 Token = PrGetNextToken (NULL, " \"<>", Next);
720 DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
721 "Start #include file \"%s\"\n", Gbl_CurrentLineNumber,
722 Token, Gbl_CurrentLineNumber);
724 PrDoIncludeFile (Token);
727 case PR_DIRECTIVE_INCLUDEBUFFER:
729 Token = PrGetNextToken (NULL, " \"<>", Next);
735 Token2 = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next);
741 DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
742 "Start #includebuffer input from file \"%s\", buffer name %s\n",
743 Gbl_CurrentLineNumber, Token, Token2);
745 PrDoIncludeBuffer (Token, Token2);
748 case PR_DIRECTIVE_LINE:
750 TokenOffset = Token - Gbl_MainTokenBuffer;
752 Status = PrResolveIntegerExpression (
753 &Gbl_CurrentLineBuffer[TokenOffset-1], &Value);
754 if (ACPI_FAILURE (Status))
759 DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
760 "User #line invocation %s\n", Gbl_CurrentLineNumber,
763 /* Update local line numbers */
765 Gbl_CurrentLineNumber = (UINT32) Value;
766 Gbl_PreviousLineNumber = 0;
768 /* Emit #line into the preprocessor file */
770 FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\"\n",
771 Gbl_CurrentLineNumber, Gbl_Files[ASL_FILE_INPUT].Filename);
774 case PR_DIRECTIVE_PRAGMA:
776 if (!strcmp (Token, "disable"))
778 Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next);
784 TokenOffset = Token - Gbl_MainTokenBuffer;
785 AslDisableException (&Gbl_CurrentLineBuffer[TokenOffset]);
787 else if (!strcmp (Token, "message"))
789 Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next);
795 TokenOffset = Token - Gbl_MainTokenBuffer;
796 AcpiOsPrintf ("%s\n", &Gbl_CurrentLineBuffer[TokenOffset]);
800 PrError (ASL_ERROR, ASL_MSG_UNKNOWN_PRAGMA,
801 THIS_TOKEN_OFFSET (Token));
807 case PR_DIRECTIVE_UNDEF:
809 DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
810 "#undef: %s\n", Gbl_CurrentLineNumber, Token);
812 PrRemoveDefine (Token);
815 case PR_DIRECTIVE_WARNING:
817 PrError (ASL_WARNING, ASL_MSG_WARNING_DIRECTIVE,
818 THIS_TOKEN_OFFSET (Token));
823 /* Should never get here */
824 DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
825 "Unrecognized directive: %u\n",
826 Gbl_CurrentLineNumber, Directive);
834 PrError (ASL_ERROR, ASL_MSG_DIRECTIVE_SYNTAX,
835 THIS_TOKEN_OFFSET (DirectiveToken));
840 /*******************************************************************************
842 * FUNCTION: PrMatchDirective
844 * PARAMETERS: Directive - Pointer to directive name token
846 * RETURN: Index into command array, -1 if not found
848 * DESCRIPTION: Lookup the incoming directive in the known directives table.
850 ******************************************************************************/
859 if (!Directive || Directive[0] == 0)
861 return (ASL_DIRECTIVE_NOT_FOUND);
864 for (i = 0; Gbl_DirectiveInfo[i].Name; i++)
866 if (!strcmp (Gbl_DirectiveInfo[i].Name, Directive))
872 return (ASL_DIRECTIVE_NOT_FOUND); /* Command not recognized */
876 /*******************************************************************************
878 * FUNCTION: PrPushDirective
880 * PARAMETERS: Directive - Encoded directive ID
881 * Argument - String containing argument to the
886 * DESCRIPTION: Push an item onto the directive stack. Used for processing
887 * nested #if/#else type conditional compilation directives.
888 * Specifically: Used on detection of #if/#ifdef/#ifndef to open
891 ******************************************************************************/
898 DIRECTIVE_INFO *Info;
901 /* Allocate and populate a stack info item */
903 Info = ACPI_ALLOCATE (sizeof (DIRECTIVE_INFO));
905 Info->Next = Gbl_DirectiveStack;
906 Info->Directive = Directive;
907 Info->IgnoringThisCodeBlock = Gbl_IgnoringThisCodeBlock;
908 strncpy (Info->Argument, Argument, MAX_ARGUMENT_LENGTH);
910 DbgPrint (ASL_DEBUG_OUTPUT,
911 "Pr(%.4u) - [%u %s] %*s Pushed [#%s %s]: IgnoreFlag = %s\n",
912 Gbl_CurrentLineNumber, Gbl_IfDepth,
913 Gbl_IgnoringThisCodeBlock ? "I" : "E",
914 Gbl_IfDepth * 4, " ",
915 Gbl_DirectiveInfo[Directive].Name,
916 Argument, Gbl_IgnoringThisCodeBlock ? "TRUE" : "FALSE");
920 Gbl_DirectiveStack = Info;
925 /*******************************************************************************
927 * FUNCTION: PrPopDirective
931 * RETURN: Status. Error if the stack is empty.
933 * DESCRIPTION: Pop an item off the directive stack. Used for processing
934 * nested #if/#else type conditional compilation directives.
935 * Specifically: Used on detection of #elif and #endif to remove
936 * the original #if/#ifdef/#ifndef from the stack and close
939 ******************************************************************************/
945 DIRECTIVE_INFO *Info;
948 /* Check for empty stack */
950 Info = Gbl_DirectiveStack;
956 /* Pop one item, keep globals up-to-date */
959 Gbl_IgnoringThisCodeBlock = Info->IgnoringThisCodeBlock;
960 Gbl_DirectiveStack = Info->Next;
962 DbgPrint (ASL_DEBUG_OUTPUT,
963 "Pr(%.4u) - [%u %s] %*s Popped [#%s %s]: IgnoreFlag now = %s\n",
964 Gbl_CurrentLineNumber, Gbl_IfDepth,
965 Gbl_IgnoringThisCodeBlock ? "I" : "E",
966 Gbl_IfDepth * 4, " ",
967 Gbl_DirectiveInfo[Info->Directive].Name,
968 Info->Argument, Gbl_IgnoringThisCodeBlock ? "TRUE" : "FALSE");
975 /*******************************************************************************
977 * FUNCTION: PrDbgPrint
979 * PARAMETERS: Action - Action being performed
980 * DirectiveName - Directive being processed
984 * DESCRIPTION: Special debug print for directive processing.
986 ******************************************************************************/
994 DbgPrint (ASL_DEBUG_OUTPUT, "Pr(%.4u) - [%u %s] "
995 "%*s %s #%s, IfDepth %u\n",
996 Gbl_CurrentLineNumber, Gbl_IfDepth,
997 Gbl_IgnoringThisCodeBlock ? "I" : "E",
998 Gbl_IfDepth * 4, " ",
999 Action, DirectiveName, Gbl_IfDepth);
1003 /*******************************************************************************
1005 * FUNCTION: PrDoIncludeFile
1007 * PARAMETERS: Pathname - Name of the input file
1011 * DESCRIPTION: Open an include file, from #include.
1013 ******************************************************************************/
1022 (void) PrOpenIncludeFile (Pathname, "r", &FullPathname);
1026 /*******************************************************************************
1028 * FUNCTION: PrDoIncludeBuffer
1030 * PARAMETERS: Pathname - Name of the input binary file
1031 * BufferName - ACPI namepath of the buffer
1035 * DESCRIPTION: Create an ACPI buffer object from a binary file. The contents
1036 * of the file are emitted into the buffer object as ascii
1037 * hex data. From #includebuffer.
1039 ******************************************************************************/
1047 FILE *BinaryBufferFile;
1052 BinaryBufferFile = PrOpenIncludeFile (Pathname, "rb", &FullPathname);
1053 if (!BinaryBufferFile)
1058 /* Emit "Name (XXXX, Buffer() {" header */
1060 FlPrintFile (ASL_FILE_PREPROCESSOR, "Name (%s, Buffer()\n{", BufferName);
1062 /* Dump the entire file in ascii hex format */
1064 while (fread (&c, 1, 1, BinaryBufferFile))
1068 FlPrintFile (ASL_FILE_PREPROCESSOR, "\n ", c);
1071 FlPrintFile (ASL_FILE_PREPROCESSOR, " 0x%2.2X,", c);
1075 DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
1076 "#includebuffer: read %u bytes from %s\n",
1077 Gbl_CurrentLineNumber, i, FullPathname);
1079 /* Close the Name() operator */
1081 FlPrintFile (ASL_FILE_PREPROCESSOR, "\n})\n", BufferName);
1082 fclose (BinaryBufferFile);