aslstartup.c (e5e1f58a87fc8cfe8597a1cf14ee4de2c7c16dd8) aslstartup.c (44b0f624aee0d43179bf3874c70e03b6ae49a4db)
1/******************************************************************************
2 *
3 * Module Name: aslstartup - Compiler startup routines, called from main
4 *
5 *****************************************************************************/
6
7/******************************************************************************
8 *

--- 151 unchanged lines hidden (view full) ---

160
161
162/* Local prototypes */
163
164static UINT8
165AslDetectSourceFileType (
166 ASL_FILE_INFO *Info);
167
1/******************************************************************************
2 *
3 * Module Name: aslstartup - Compiler startup routines, called from main
4 *
5 *****************************************************************************/
6
7/******************************************************************************
8 *

--- 151 unchanged lines hidden (view full) ---

160
161
162/* Local prototypes */
163
164static UINT8
165AslDetectSourceFileType (
166 ASL_FILE_INFO *Info);
167
168static ACPI_STATUS
169AslDoDisassembly (
170 void);
171
168
172
173/* Globals */
174
175static BOOLEAN AslToFile = TRUE;
176
177
178/*******************************************************************************
179 *
180 * FUNCTION: AslInitializeGlobals

--- 41 unchanged lines hidden (view full) ---

222 AslGbl_TotalFolds = 0;
223
224 AslGbl_NextEvent = 0;
225 for (i = 0; i < ASL_NUM_REPORT_LEVELS; i++)
226 {
227 AslGbl_ExceptionCount[i] = 0;
228 }
229
169/* Globals */
170
171static BOOLEAN AslToFile = TRUE;
172
173
174/*******************************************************************************
175 *
176 * FUNCTION: AslInitializeGlobals

--- 41 unchanged lines hidden (view full) ---

218 AslGbl_TotalFolds = 0;
219
220 AslGbl_NextEvent = 0;
221 for (i = 0; i < ASL_NUM_REPORT_LEVELS; i++)
222 {
223 AslGbl_ExceptionCount[i] = 0;
224 }
225
230 for (i = ASL_FILE_INPUT; i <= ASL_MAX_FILE_TYPE; i++)
231 {
232 AslGbl_Files[i].Handle = NULL;
233 AslGbl_Files[i].Filename = NULL;
234 }
235
236 if (AcpiGbl_CaptureComments)
237 {
238 AslGbl_CommentState.SpacesBefore = 0;
239 AslGbl_CommentState.CommentType = 1;
240 AslGbl_CommentState.LatestParseOp = NULL;
241 AslGbl_CommentState.ParsingParenBraceNode = NULL;
242 AslGbl_CommentState.CaptureComments = TRUE;
243 }

--- 94 unchanged lines hidden (view full) ---

338 *
339 * FUNCTION: AslDoDisassembly
340 *
341 * PARAMETERS: None
342 *
343 * RETURN: Status
344 *
345 * DESCRIPTION: Initiate AML file disassembly. Uses ACPICA subsystem to build
226 if (AcpiGbl_CaptureComments)
227 {
228 AslGbl_CommentState.SpacesBefore = 0;
229 AslGbl_CommentState.CommentType = 1;
230 AslGbl_CommentState.LatestParseOp = NULL;
231 AslGbl_CommentState.ParsingParenBraceNode = NULL;
232 AslGbl_CommentState.CaptureComments = TRUE;
233 }

--- 94 unchanged lines hidden (view full) ---

328 *
329 * FUNCTION: AslDoDisassembly
330 *
331 * PARAMETERS: None
332 *
333 * RETURN: Status
334 *
335 * DESCRIPTION: Initiate AML file disassembly. Uses ACPICA subsystem to build
346 * namespace.
336 * namespace. This function assumes that the ACPI subsystem has
337 * been initialized. The caller of the initialization will also
338 * terminate the ACPI subsystem.
347 *
348 ******************************************************************************/
349
339 *
340 ******************************************************************************/
341
350static ACPI_STATUS
342ACPI_STATUS
351AslDoDisassembly (
352 void)
353{
354 ACPI_STATUS Status;
355
356
343AslDoDisassembly (
344 void)
345{
346 ACPI_STATUS Status;
347
348
357 /* ACPICA subsystem initialization */
358
359 Status = AdInitialize ();
360 if (ACPI_FAILURE (Status))
361 {
362 return (Status);
363 }
364
365 Status = AcpiAllocateRootTable (4);
366 if (ACPI_FAILURE (Status))
367 {
368 AcpiOsPrintf ("Could not initialize ACPI Table Manager, %s\n",
369 AcpiFormatException (Status));
370 return (Status);
371 }
372
349 Status = AcpiAllocateRootTable (4);
350 if (ACPI_FAILURE (Status))
351 {
352 AcpiOsPrintf ("Could not initialize ACPI Table Manager, %s\n",
353 AcpiFormatException (Status));
354 return (Status);
355 }
356
373 /* Handle additional output files for disassembler */
374
375 AslGbl_FileType = ASL_INPUT_TYPE_BINARY_ACPI_TABLE;
376 Status = FlOpenMiscOutputFiles (AslGbl_OutputFilenamePrefix);
377
378 /* This is where the disassembly happens */
379
380 AcpiGbl_DmOpt_Disasm = TRUE;
381 Status = AdAmlDisassemble (AslToFile,
382 AslGbl_Files[ASL_FILE_INPUT].Filename, AslGbl_OutputFilenamePrefix,
383 &AslGbl_Files[ASL_FILE_INPUT].Filename);
384 if (ACPI_FAILURE (Status))
385 {
386 return (Status);
387 }
388
389 /* Check if any control methods were unresolved */
390
391 AcpiDmUnresolvedWarning (0);
392
357 /* This is where the disassembly happens */
358
359 AcpiGbl_DmOpt_Disasm = TRUE;
360 Status = AdAmlDisassemble (AslToFile,
361 AslGbl_Files[ASL_FILE_INPUT].Filename, AslGbl_OutputFilenamePrefix,
362 &AslGbl_Files[ASL_FILE_INPUT].Filename);
363 if (ACPI_FAILURE (Status))
364 {
365 return (Status);
366 }
367
368 /* Check if any control methods were unresolved */
369
370 AcpiDmUnresolvedWarning (0);
371
393 /* Shutdown compiler and ACPICA subsystem */
372 /* Clear Error log */
394
395 AeClearErrorLog ();
373
374 AeClearErrorLog ();
396 (void) AcpiTerminate ();
397
398 /*
399 * AslGbl_Files[ASL_FILE_INPUT].Filename was replaced with the
400 * .DSL disassembly file, which can now be compiled if requested
401 */
402 if (AslGbl_DoCompile)
403 {
404 AcpiOsPrintf ("\nCompiling \"%s\"\n",
405 AslGbl_Files[ASL_FILE_INPUT].Filename);
406 return (AE_CTRL_CONTINUE);
407 }
408
375
376 /*
377 * AslGbl_Files[ASL_FILE_INPUT].Filename was replaced with the
378 * .DSL disassembly file, which can now be compiled if requested
379 */
380 if (AslGbl_DoCompile)
381 {
382 AcpiOsPrintf ("\nCompiling \"%s\"\n",
383 AslGbl_Files[ASL_FILE_INPUT].Filename);
384 return (AE_CTRL_CONTINUE);
385 }
386
409 /* No need to free the filename string */
410
411 AslGbl_Files[ASL_FILE_INPUT].Filename = NULL;
412
413 UtDeleteLocalCaches ();
414 return (AE_OK);
415}
416
417
418/*******************************************************************************
419 *
420 * FUNCTION: AslDoOneFile
421 *

--- 5 unchanged lines hidden (view full) ---

427 *
428 ******************************************************************************/
429
430ACPI_STATUS
431AslDoOneFile (
432 char *Filename)
433{
434 ACPI_STATUS Status;
387 return (AE_OK);
388}
389
390
391/*******************************************************************************
392 *
393 * FUNCTION: AslDoOneFile
394 *

--- 5 unchanged lines hidden (view full) ---

400 *
401 ******************************************************************************/
402
403ACPI_STATUS
404AslDoOneFile (
405 char *Filename)
406{
407 ACPI_STATUS Status;
408 UINT8 Event;
409 ASL_GLOBAL_FILE_NODE *FileNode;
435
436
437 /* Re-initialize "some" compiler/preprocessor globals */
438
439 AslInitializeGlobals ();
440 PrInitializeGlobals ();
441
442 /*
443 * Extract the directory path. This path is used for possible include
444 * files and the optional AML filename embedded in the input file
445 * DefinitionBlock declaration.
446 */
447 Status = FlSplitInputPathname (Filename, &AslGbl_DirectoryPath, NULL);
448 if (ACPI_FAILURE (Status))
449 {
450 return (Status);
451 }
452
410
411
412 /* Re-initialize "some" compiler/preprocessor globals */
413
414 AslInitializeGlobals ();
415 PrInitializeGlobals ();
416
417 /*
418 * Extract the directory path. This path is used for possible include
419 * files and the optional AML filename embedded in the input file
420 * DefinitionBlock declaration.
421 */
422 Status = FlSplitInputPathname (Filename, &AslGbl_DirectoryPath, NULL);
423 if (ACPI_FAILURE (Status))
424 {
425 return (Status);
426 }
427
428 /*
429 * There was an input file detected at this point. Each input ASL file is
430 * associated with one global file node consisting of the input file and
431 * all output files associated with it. This is useful when compiling
432 * multiple files in one command.
433 */
434 Status = FlInitOneFile(Filename);
435 if (ACPI_FAILURE (Status))
436 {
437 return (AE_ERROR);
438 }
439
453 /* Take a copy of the input filename, convert any backslashes */
454
455 AslGbl_Files[ASL_FILE_INPUT].Filename =
456 UtLocalCacheCalloc (strlen (Filename) + 1);
457
458 strcpy (AslGbl_Files[ASL_FILE_INPUT].Filename, Filename);
459 UtConvertBackslashes (AslGbl_Files[ASL_FILE_INPUT].Filename);
460
461 /*
440 /* Take a copy of the input filename, convert any backslashes */
441
442 AslGbl_Files[ASL_FILE_INPUT].Filename =
443 UtLocalCacheCalloc (strlen (Filename) + 1);
444
445 strcpy (AslGbl_Files[ASL_FILE_INPUT].Filename, Filename);
446 UtConvertBackslashes (AslGbl_Files[ASL_FILE_INPUT].Filename);
447
448 /*
462 * AML Disassembly (Optional)
463 */
464 if (AcpiGbl_DisasmFlag)
465 {
466 Status = AslDoDisassembly ();
467 if (Status != AE_CTRL_CONTINUE)
468 {
469 return (Status);
470 }
471 }
472
473 /*
474 * Open the input file. Here, this should be an ASCII source file,
475 * either an ASL file or a Data Table file
476 */
477 Status = FlOpenInputFile (AslGbl_Files[ASL_FILE_INPUT].Filename);
478 if (ACPI_FAILURE (Status))
479 {
480 AePrintErrorLog (ASL_FILE_STDERR);
481 return (AE_ERROR);
482 }
483
449 * Open the input file. Here, this should be an ASCII source file,
450 * either an ASL file or a Data Table file
451 */
452 Status = FlOpenInputFile (AslGbl_Files[ASL_FILE_INPUT].Filename);
453 if (ACPI_FAILURE (Status))
454 {
455 AePrintErrorLog (ASL_FILE_STDERR);
456 return (AE_ERROR);
457 }
458
484 AslGbl_OriginalInputFileSize = FlGetFileSize (ASL_FILE_INPUT);
459 FileNode = FlGetCurrentFileNode();
460 if (!FileNode)
461 {
462 return (AE_ERROR);
463 }
485
464
465 FileNode->OriginalInputFileSize = FlGetFileSize (ASL_FILE_INPUT);
466
486 /* Determine input file type */
487
488 AslGbl_FileType = AslDetectSourceFileType (&AslGbl_Files[ASL_FILE_INPUT]);
489 if (AslGbl_FileType == ASL_INPUT_TYPE_BINARY)
490 {
491 return (AE_ERROR);
492 }
493
494 /*
495 * If -p not specified, we will use the input filename as the
496 * output filename prefix
497 */
498 if (AslGbl_UseDefaultAmlFilename)
499 {
500 AslGbl_OutputFilenamePrefix = AslGbl_Files[ASL_FILE_INPUT].Filename;
501 }
502
467 /* Determine input file type */
468
469 AslGbl_FileType = AslDetectSourceFileType (&AslGbl_Files[ASL_FILE_INPUT]);
470 if (AslGbl_FileType == ASL_INPUT_TYPE_BINARY)
471 {
472 return (AE_ERROR);
473 }
474
475 /*
476 * If -p not specified, we will use the input filename as the
477 * output filename prefix
478 */
479 if (AslGbl_UseDefaultAmlFilename)
480 {
481 AslGbl_OutputFilenamePrefix = AslGbl_Files[ASL_FILE_INPUT].Filename;
482 }
483
484 /*
485 * Open the output file. Note: by default, the name of this file comes from
486 * the table descriptor within the input file.
487 */
488 if (AslGbl_FileType == ASL_INPUT_TYPE_ASCII_ASL)
489 {
490 Event = UtBeginEvent ("Open AML output file");
491 Status = FlOpenAmlOutputFile (AslGbl_OutputFilenamePrefix);
492 UtEndEvent (Event);
493 if (ACPI_FAILURE (Status))
494 {
495 AePrintErrorLog (ASL_FILE_STDERR);
496 return (AE_ERROR);
497 }
498 }
499
503 /* Open the optional output files (listings, etc.) */
504
505 Status = FlOpenMiscOutputFiles (AslGbl_OutputFilenamePrefix);
506 if (ACPI_FAILURE (Status))
507 {
508 AePrintErrorLog (ASL_FILE_STDERR);
509 return (AE_ERROR);
510 }

--- 34 unchanged lines hidden (view full) ---

545 PrTerminatePreprocessor ();
546 return (Status);
547
548 /*
549 * ASL Compilation
550 */
551 case ASL_INPUT_TYPE_ASCII_ASL:
552
500 /* Open the optional output files (listings, etc.) */
501
502 Status = FlOpenMiscOutputFiles (AslGbl_OutputFilenamePrefix);
503 if (ACPI_FAILURE (Status))
504 {
505 AePrintErrorLog (ASL_FILE_STDERR);
506 return (AE_ERROR);
507 }

--- 34 unchanged lines hidden (view full) ---

542 PrTerminatePreprocessor ();
543 return (Status);
544
545 /*
546 * ASL Compilation
547 */
548 case ASL_INPUT_TYPE_ASCII_ASL:
549
553 /* ACPICA subsystem initialization */
554
555 Status = AdInitialize ();
550 Status = CmDoCompile ();
556 if (ACPI_FAILURE (Status))
557 {
558 return (Status);
559 }
560
551 if (ACPI_FAILURE (Status))
552 {
553 return (Status);
554 }
555
561 (void) CmDoCompile ();
562 (void) AcpiTerminate ();
563
564 /* Check if any errors occurred during compile */
565
566 Status = AslCheckForErrorExit ();
567 if (ACPI_FAILURE (Status))
568 {
569 return (Status);
570 }
571
572 /* Cleanup (for next source file) and exit */
573
574 AeClearErrorLog ();
575 PrTerminatePreprocessor ();
576
556 /* Cleanup (for next source file) and exit */
557
558 AeClearErrorLog ();
559 PrTerminatePreprocessor ();
560
577 /* ASL-to-ASL+ conversion - Perform immediate disassembly */
578
579 if (AslGbl_DoAslConversion)
580 {
581 /*
582 * New input file is the output AML file from above.
583 * New output is from the input ASL file from above.
584 */
585 AslGbl_OutputFilenamePrefix = AslGbl_Files[ASL_FILE_INPUT].Filename;
586 CvDbgPrint ("OUTPUTFILENAME: %s\n", AslGbl_OutputFilenamePrefix);
587 AslGbl_Files[ASL_FILE_INPUT].Filename =
588 AslGbl_Files[ASL_FILE_AML_OUTPUT].Filename;
589 AcpiGbl_DisasmFlag = TRUE;
590 fprintf (stderr, "\n");
591 AslDoDisassembly ();
592
593 /* delete the AML file. This AML file should never be utilized by AML interpreters. */
594
595 FlDeleteFile (ASL_FILE_AML_OUTPUT);
596 }
597
561 /*
562 * At this point, we know how many lines are in the input file. Save it
563 * to display for post-compilation summary.
564 */
565 FileNode->TotalLineCount = AslGbl_CurrentLineNumber;
598 return (AE_OK);
599
600 /*
601 * Binary ACPI table was auto-detected, disassemble it
602 */
603 case ASL_INPUT_TYPE_BINARY_ACPI_TABLE:
604
605 /* We have what appears to be an ACPI table, disassemble it */

--- 50 unchanged lines hidden (view full) ---

656 /* Optionally treat warnings as errors */
657
658 if (AslGbl_WarningsAsErrors)
659 {
660 if ((AslGbl_ExceptionCount[ASL_WARNING] > 0) ||
661 (AslGbl_ExceptionCount[ASL_WARNING2] > 0) ||
662 (AslGbl_ExceptionCount[ASL_WARNING3] > 0))
663 {
566 return (AE_OK);
567
568 /*
569 * Binary ACPI table was auto-detected, disassemble it
570 */
571 case ASL_INPUT_TYPE_BINARY_ACPI_TABLE:
572
573 /* We have what appears to be an ACPI table, disassemble it */

--- 50 unchanged lines hidden (view full) ---

624 /* Optionally treat warnings as errors */
625
626 if (AslGbl_WarningsAsErrors)
627 {
628 if ((AslGbl_ExceptionCount[ASL_WARNING] > 0) ||
629 (AslGbl_ExceptionCount[ASL_WARNING2] > 0) ||
630 (AslGbl_ExceptionCount[ASL_WARNING3] > 0))
631 {
632 AslError (ASL_ERROR, ASL_MSG_WARNING_AS_ERROR, NULL,
633 "(reporting warnings as errors)");
664 return (AE_ERROR);
665 }
666 }
667 }
668
669 return (AE_OK);
670}
634 return (AE_ERROR);
635 }
636 }
637 }
638
639 return (AE_OK);
640}