コード例 #1
0
ファイル: PMTimer.cs プロジェクト: Paul1nh0/Singularity
 public static PMTimer Create(Fadt fadt)
 {
     if ((fadt.Flags & (uint)FadtFlags.TMR_VAL_EXT) == 0)
     {
         return(new PMTimer(fadt.PM_TMR_BLK, 24));
     }
     return(new PMTimer(fadt.PM_TMR_BLK, 32));
 }
コード例 #2
0
        public static void Parse()
        {
            UIntPtr rsdpBase = GetRsdpBase();

            if (rsdpBase == UIntPtr.Zero)
            {
                VerboseOut.Print("ACPI RSDP not found\n");
            }

#if DUMP_ACPI_TABLES_UUENCODED
            UuencodeDumpRegion("RSDP.dmp",
                               IoMemory.MapPhysicalMemory(
                                   rsdpBase, 36u,
                                   true, false));
#endif
            Rsdp rsdp = Rsdp.Parse(rsdpBase, 36u);

            VerboseOut.Print("ACPI RSDP OemId is {0:x8}\n",
                             __arglist(rsdp.OemId));
            VerboseOut.Print("ACPI RSDP revision is {0:x8}\n",
                             __arglist(rsdp.Revision));

            if (rsdp.Revision == 2)
            {
                rsdtHeader = SystemTableHeader.Create(rsdp.XsdtAddress);
#if DUMP_ACPI_TABLES_UUENCODED
                UuencodeDumpRegion("XSDT.dmp",
                                   IoMemory.MapPhysicalMemory(
                                       rsdtHeader.Address, rsdtHeader.FullTableLength,
                                       true, false));
#endif
                rsdt = Xsdt.Create(rsdtHeader);
            }
            else
            {
                rsdtHeader = SystemTableHeader.Create(rsdp.RsdtAddress);
#if DUMP_ACPI_TABLES_UUENCODED
                UuencodeDumpRegion("RSDT.dmp",
                                   IoMemory.MapPhysicalMemory(
                                       rsdtHeader.Address, rsdtHeader.FullTableLength,
                                       true, false));
#endif
                rsdt = Rsdt.Create(rsdtHeader);
            }

            VerboseOut.Print("ACPI RSDT/XSDT OemTableId is {0}\n",
                             __arglist(rsdtHeader.OemTableId));
            VerboseOut.Print("ACPI RSDT/XSDT Revision is {0:x8}\n",
                             __arglist(rsdtHeader.Revision));
            VerboseOut.Print("ACPI RSDT/XSDT CreatorId is {0:x8}\n",
                             __arglist(rsdtHeader.CreatorId));
            VerboseOut.Print("ACPI RSDT/XSDT CreatorRevision is {0:x8}\n",
                             __arglist(rsdtHeader.CreatorRevision));

            VerboseOut.Print("RSDT contains:\n");
            for (int i = 0; i < rsdt.EntryCount; i++)
            {
                SystemTableHeader header = rsdt.GetTableHeader(i);
                VerboseOut.Print("    {0:x8}\n", __arglist(header.Signature));
                if (header.Signature == Fadt.Signature)
                {
                    fadt = Fadt.Create(header);
                }
                else if (header.Signature == Madt.Signature)
                {
                    madt = Madt.Create(header);
                }
                else if (header.Signature == Ssdt.Signature)
                {
                    ssdt = Ssdt.Create(header);
                }
                // Srat, Slit
                else if (header.Signature == Srat.Signature)
                {
                    srat = Srat.Create(header);
                    srat.ParseSratStructure();

                    // srat.DumpSratOffsets();
                    // srat.DumpSratImportantFields();
                    // srat.DumpSratStructure();
                }
            }

            SystemTableHeader dsdtHeader = null;

            if (fadt != null)
            {
                pmTimer = PMTimer.Create(fadt);
                VerboseOut.Print("PMTimer Value={0} Width={1}\n",
                                 __arglist(pmTimer.Value, pmTimer.Width));
                uint t0    = pmTimer.Value;
                uint t1    = pmTimer.Value;
                uint t2    = pmTimer.Value;
                uint delta = (t2 >= t1) ? t2 - t1 : ((t1 | 0xff000000) - t2);
                VerboseOut.Print("Read cost {0} ticks\n", __arglist(delta));

                if (fadt.DSDT != 0)
                {
                    dsdtHeader = SystemTableHeader.Create(fadt.DSDT);
                    dsdt       = Dsdt.Create(dsdtHeader);
                }
            }

            VerboseOut.Print("Parsing and loading AML\n");

#if DUMP_ACPI_TABLES_UUENCODED
            if (dsdtHeader != null)
            {
                UuencodeDumpRegion("ACPI.DSDT.dmp",
                                   IoMemory.MapPhysicalMemory(
                                       dsdtHeader.Address, dsdtHeader.FullTableLength,
                                       true, false));
            }

            for (int i = 0; i < rsdt.EntryCount; i++)
            {
                SystemTableHeader header = rsdt.GetTableHeader(i);
                UuencodeDumpRegion("ACPI." + header.Signature + "." + header.OemTableId + ".dmp",
                                   IoMemory.MapPhysicalMemory(
                                       header.Address, header.FullTableLength,
                                       true, false));
            }
#endif // DUMP_ACPI_TABLES_UUENCODED
        }