Example #1
0
int
ApDumpTableByAddress (
    char                    *AsciiAddress)
{
    ACPI_PHYSICAL_ADDRESS   Address;
    ACPI_TABLE_HEADER       *Table;
    ACPI_STATUS             Status;
    int                     TableStatus;
    UINT64                  LongAddress;


    /* Convert argument to an integer physical address */

    Status = AcpiUtStrtoul64 (AsciiAddress, 0, &LongAddress);
    if (ACPI_FAILURE (Status))
    {
        AcpiLogError ("%s: Could not convert to a physical address\n",
            AsciiAddress);
        return (-1);
    }

    Address = (ACPI_PHYSICAL_ADDRESS) LongAddress;
    Status = AcpiOsGetTableByAddress (Address, &Table);
    if (ACPI_FAILURE (Status))
    {
        AcpiLogError ("Could not get table at 0x%8.8X%8.8X, %s\n",
            ACPI_FORMAT_UINT64 (Address),
            AcpiFormatException (Status));
        return (-1);
    }

    TableStatus = ApDumpTableBuffer (Table, 0, Address);
    ACPI_FREE (Table);
    return (TableStatus);
}
ACPI_STATUS
AcpiOsGetTableByIndex (
    UINT32                  Index,
    ACPI_TABLE_HEADER       **Table,
    UINT32                  *Instance,
    ACPI_PHYSICAL_ADDRESS   *Address)
{
    OSL_TABLE_INFO          *Info;
    ACPI_STATUS             Status;
    UINT32                  i;


    /* Initialize main tables */

    Status = OslTableInitialize ();
    if (ACPI_FAILURE (Status))
    {
        return (Status);
    }

    /* Add all tables to list */

    Status = OslAddTablesToList ();
    if (ACPI_FAILURE (Status))
    {
        return (Status);
    }

    /* Validate Index */

    if (Index >= Gbl_TableListHead->Instance)
    {
        return (AE_LIMIT);
    }

    /* Point to the table list entry specified by the Index argument */

    Info = Gbl_TableListHead;
    for (i = 0; i <= Index; i++)
    {
        Info = Info->Next;
    }

    /* Now we can just get the table via the address or name */

    if (Info->Address)
    {
        Status = AcpiOsGetTableByAddress (Info->Address, Table);
        if (ACPI_SUCCESS (Status))
        {
            *Address = Info->Address;
        }
    }
    else
    {
        Status = AcpiOsGetTableByName (Info->Signature, Info->Instance,
            Table, Address);
    }

    if (ACPI_SUCCESS (Status))
    {
        *Instance = Info->Instance;
    }
    return (Status);
}