Deleted Added
full compact
dmextern.c (245582) dmextern.c (246849)
1/******************************************************************************
2 *
3 * Module Name: dmextern - Support for External() ASL statements
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2013, Intel Corp.

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

41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <contrib/dev/acpica/include/acpi.h>
45#include <contrib/dev/acpica/include/accommon.h>
46#include <contrib/dev/acpica/include/amlcode.h>
47#include <contrib/dev/acpica/include/acnamesp.h>
48#include <contrib/dev/acpica/include/acdisasm.h>
1/******************************************************************************
2 *
3 * Module Name: dmextern - Support for External() ASL statements
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2013, Intel Corp.

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

41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <contrib/dev/acpica/include/acpi.h>
45#include <contrib/dev/acpica/include/accommon.h>
46#include <contrib/dev/acpica/include/amlcode.h>
47#include <contrib/dev/acpica/include/acnamesp.h>
48#include <contrib/dev/acpica/include/acdisasm.h>
49#include <stdio.h>
49
50
51/*
52 * This module is used for application-level code (iASL disassembler) only.
53 *
54 * It contains the code to create and emit any necessary External() ASL
55 * statements for the module being disassembled.
56 */

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

368 UINT32 Value)
369{
370 char *ExternalPath;
371 char *Fullpath = NULL;
372 ACPI_EXTERNAL_LIST *NewExternal;
373 ACPI_EXTERNAL_LIST *NextExternal;
374 ACPI_EXTERNAL_LIST *PrevExternal = NULL;
375 ACPI_STATUS Status;
50
51
52/*
53 * This module is used for application-level code (iASL disassembler) only.
54 *
55 * It contains the code to create and emit any necessary External() ASL
56 * statements for the module being disassembled.
57 */

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

369 UINT32 Value)
370{
371 char *ExternalPath;
372 char *Fullpath = NULL;
373 ACPI_EXTERNAL_LIST *NewExternal;
374 ACPI_EXTERNAL_LIST *NextExternal;
375 ACPI_EXTERNAL_LIST *PrevExternal = NULL;
376 ACPI_STATUS Status;
377 BOOLEAN Resolved = FALSE;
376
377
378 if (!Path)
379 {
380 return;
381 }
382
378
379
380 if (!Path)
381 {
382 return;
383 }
384
385 if (Type == ACPI_TYPE_METHOD)
386 {
387 if (Value & 0x80)
388 {
389 Resolved = TRUE;
390 }
391 Value &= 0x07;
392 }
393
383 /*
384 * We don't want External() statements to contain a leading '\'.
385 * This prevents duplicate external statements of the form:
386 *
387 * External (\ABCD)
388 * External (ABCD)
389 *
390 * This would cause a compile time error when the disassembled

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

459 {
460 ACPI_FREE (ExternalPath);
461 return;
462 }
463
464 NewExternal->Path = ExternalPath;
465 NewExternal->Type = Type;
466 NewExternal->Value = Value;
394 /*
395 * We don't want External() statements to contain a leading '\'.
396 * This prevents duplicate external statements of the form:
397 *
398 * External (\ABCD)
399 * External (ABCD)
400 *
401 * This would cause a compile time error when the disassembled

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

470 {
471 ACPI_FREE (ExternalPath);
472 return;
473 }
474
475 NewExternal->Path = ExternalPath;
476 NewExternal->Type = Type;
477 NewExternal->Value = Value;
478 NewExternal->Resolved = Resolved;
467 NewExternal->Length = (UINT16) ACPI_STRLEN (ExternalPath);
468
469 /* Was the external path with parent prefix normalized to a fullpath? */
470
471 if (Fullpath == ExternalPath)
472 {
473 /* Get new internal path */
474

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

679
680
681 if (!AcpiGbl_ExternalList)
682 {
683 return;
684 }
685
686 /*
479 NewExternal->Length = (UINT16) ACPI_STRLEN (ExternalPath);
480
481 /* Was the external path with parent prefix normalized to a fullpath? */
482
483 if (Fullpath == ExternalPath)
484 {
485 /* Get new internal path */
486

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

691
692
693 if (!AcpiGbl_ExternalList)
694 {
695 return;
696 }
697
698 /*
699 * Determine the number of control methods in the external list, and
700 * also how many of those externals were resolved via the namespace.
701 */
702 NextExternal = AcpiGbl_ExternalList;
703 while (NextExternal)
704 {
705 if (NextExternal->Type == ACPI_TYPE_METHOD)
706 {
707 AcpiGbl_NumExternalMethods++;
708 if (NextExternal->Resolved)
709 {
710 AcpiGbl_ResolvedExternalMethods++;
711 }
712 }
713
714 NextExternal = NextExternal->Next;
715 }
716
717 /* Check if any control methods were unresolved */
718
719 AcpiDmUnresolvedWarning (1);
720
721 /*
687 * Walk the list of externals (unresolved references)
688 * found during the AML parsing
689 */
690 while (AcpiGbl_ExternalList)
691 {
692 AcpiOsPrintf (" External (%s%s",
693 AcpiGbl_ExternalList->Path,
694 AcpiDmGetObjectTypeName (AcpiGbl_ExternalList->Type));
695
696 if (AcpiGbl_ExternalList->Type == ACPI_TYPE_METHOD)
697 {
722 * Walk the list of externals (unresolved references)
723 * found during the AML parsing
724 */
725 while (AcpiGbl_ExternalList)
726 {
727 AcpiOsPrintf (" External (%s%s",
728 AcpiGbl_ExternalList->Path,
729 AcpiDmGetObjectTypeName (AcpiGbl_ExternalList->Type));
730
731 if (AcpiGbl_ExternalList->Type == ACPI_TYPE_METHOD)
732 {
698 AcpiOsPrintf (") // %u Arguments\n",
699 AcpiGbl_ExternalList->Value);
733 if (AcpiGbl_ExternalList->Resolved)
734 {
735 AcpiOsPrintf (") // %u Arguments\n",
736 AcpiGbl_ExternalList->Value);
737 }
738 else
739 {
740 AcpiOsPrintf (") // Warning: unresolved Method, "
741 "assuming %u arguments (may be incorrect, see warning above)\n",
742 AcpiGbl_ExternalList->Value);
743 }
700 }
701 else
702 {
703 AcpiOsPrintf (")\n");
704 }
705
706 /* Free this external info block and move on to next external */
707

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

713
714 ACPI_FREE (AcpiGbl_ExternalList->Path);
715 ACPI_FREE (AcpiGbl_ExternalList);
716 AcpiGbl_ExternalList = NextExternal;
717 }
718
719 AcpiOsPrintf ("\n");
720}
744 }
745 else
746 {
747 AcpiOsPrintf (")\n");
748 }
749
750 /* Free this external info block and move on to next external */
751

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

757
758 ACPI_FREE (AcpiGbl_ExternalList->Path);
759 ACPI_FREE (AcpiGbl_ExternalList);
760 AcpiGbl_ExternalList = NextExternal;
761 }
762
763 AcpiOsPrintf ("\n");
764}
765
766
767/*******************************************************************************
768 *
769 * FUNCTION: AcpiDmUnresolvedWarning
770 *
771 * PARAMETERS: Type - Where to output the warning.
772 * 0 means write to stderr
773 * 1 means write to AcpiOsPrintf
774 *
775 * RETURN: None
776 *
777 * DESCRIPTION: Issue warning message if there are unresolved external control
778 * methods within the disassembly.
779 *
780 ******************************************************************************/
781
782#if 0
783Summary of the external control method problem:
784
785When the -e option is used with disassembly, the various SSDTs are simply
786loaded into a global namespace for the disassembler to use in order to
787resolve control method references (invocations).
788
789The disassembler tracks any such references, and will emit an External()
790statement for these types of methods, with the proper number of arguments .
791
792Without the SSDTs, the AML does not contain enough information to properly
793disassemble the control method invocation -- because the disassembler does
794not know how many arguments to parse.
795
796An example: Assume we have two control methods. ABCD has one argument, and
797EFGH has zero arguments. Further, we have two additional control methods
798that invoke ABCD and EFGH, named T1 and T2:
799
800 Method (ABCD, 1)
801 {
802 }
803 Method (EFGH, 0)
804 {
805 }
806 Method (T1)
807 {
808 ABCD (Add (2, 7, Local0))
809 }
810 Method (T2)
811 {
812 EFGH ()
813 Add (2, 7, Local0)
814 }
815
816Here is the AML code that is generated for T1 and T2:
817
818 185: Method (T1)
819
8200000034C: 14 10 54 31 5F 5F 00 ... "..T1__."
821
822 186: {
823 187: ABCD (Add (2, 7, Local0))
824
82500000353: 41 42 43 44 ............ "ABCD"
82600000357: 72 0A 02 0A 07 60 ...... "r....`"
827
828 188: }
829
830 190: Method (T2)
831
8320000035D: 14 10 54 32 5F 5F 00 ... "..T2__."
833
834 191: {
835 192: EFGH ()
836
83700000364: 45 46 47 48 ............ "EFGH"
838
839 193: Add (2, 7, Local0)
840
84100000368: 72 0A 02 0A 07 60 ...... "r....`"
842 194: }
843
844Note that the AML code for T1 and T2 is essentially identical. When
845disassembling this code, the methods ABCD and EFGH must be known to the
846disassembler, otherwise it does not know how to handle the method invocations.
847
848In other words, if ABCD and EFGH are actually external control methods
849appearing in an SSDT, the disassembler does not know what to do unless
850the owning SSDT has been loaded via the -e option.
851#endif
852
853void
854AcpiDmUnresolvedWarning (
855 UINT8 Type)
856{
857
858 if (!AcpiGbl_NumExternalMethods)
859 {
860 return;
861 }
862
863 if (Type)
864 {
865 if (!AcpiGbl_ExternalFileList)
866 {
867 /* The -e option was not specified */
868
869 AcpiOsPrintf (" /*\n"
870 " * iASL Warning: There were %u external control methods found during\n"
871 " * disassembly, but additional ACPI tables to resolve these externals\n"
872 " * were not specified. This resulting disassembler output file may not\n"
873 " * compile because the disassembler did not know how many arguments\n"
874 " * to assign to these methods. To specify the tables needed to resolve\n"
875 " * external control method references, use the one of the following\n"
876 " * example iASL invocations:\n"
877 " * iasl -e <ssdt1.aml,ssdt2.aml...> -d <dsdt.aml>\n"
878 " * iasl -e <dsdt.aml,ssdt2.aml...> -d <ssdt1.aml>\n"
879 " */\n",
880 AcpiGbl_NumExternalMethods);
881 }
882 else if (AcpiGbl_NumExternalMethods != AcpiGbl_ResolvedExternalMethods)
883 {
884 /* The -e option was specified, but there are still some unresolved externals */
885
886 AcpiOsPrintf (" /*\n"
887 " * iASL Warning: There were %u external control methods found during\n"
888 " * disassembly, but only %u %s resolved (%u unresolved). Additional\n"
889 " * ACPI tables are required to properly disassemble the code. This\n"
890 " * resulting disassembler output file may not compile because the\n"
891 " * disassembler did not know how many arguments to assign to the\n"
892 " * unresolved methods.\n"
893 " */\n",
894 AcpiGbl_NumExternalMethods, AcpiGbl_ResolvedExternalMethods,
895 (AcpiGbl_ResolvedExternalMethods > 1 ? "were" : "was"),
896 (AcpiGbl_NumExternalMethods - AcpiGbl_ResolvedExternalMethods));
897 }
898 }
899 else
900 {
901 if (!AcpiGbl_ExternalFileList)
902 {
903 /* The -e option was not specified */
904
905 fprintf (stderr, "\n"
906 "iASL Warning: There were %u external control methods found during\n"
907 "disassembly, but additional ACPI tables to resolve these externals\n"
908 "were not specified. The resulting disassembler output file may not\n"
909 "compile because the disassembler did not know how many arguments\n"
910 "to assign to these methods. To specify the tables needed to resolve\n"
911 "external control method references, use the one of the following\n"
912 "example iASL invocations:\n"
913 " iasl -e <ssdt1.aml,ssdt2.aml...> -d <dsdt.aml>\n"
914 " iasl -e <dsdt.aml,ssdt2.aml...> -d <ssdt1.aml>\n",
915 AcpiGbl_NumExternalMethods);
916 }
917 else if (AcpiGbl_NumExternalMethods != AcpiGbl_ResolvedExternalMethods)
918 {
919 /* The -e option was specified, but there are still some unresolved externals */
920
921 fprintf (stderr, "\n"
922 "iASL Warning: There were %u external control methods found during\n"
923 "disassembly, but only %u %s resolved (%u unresolved). Additional\n"
924 "ACPI tables are required to properly disassemble the code. The\n"
925 "resulting disassembler output file may not compile because the\n"
926 "disassembler did not know how many arguments to assign to the\n"
927 "unresolved methods.\n",
928 AcpiGbl_NumExternalMethods, AcpiGbl_ResolvedExternalMethods,
929 (AcpiGbl_ResolvedExternalMethods > 1 ? "were" : "was"),
930 (AcpiGbl_NumExternalMethods - AcpiGbl_ResolvedExternalMethods));
931 }
932 }
933
934}