コード例 #1
0
ファイル: dbfileio.c プロジェクト: LauraBerry/A2cpsc457
ACPI_STATUS
AcpiDbGetTableFromFile (
    char                    *Filename,
    ACPI_TABLE_HEADER       **ReturnTable)
{
#ifdef ACPI_APPLICATION
    ACPI_STATUS             Status;
    ACPI_TABLE_HEADER       *Table;
    BOOLEAN                 IsAmlTable = TRUE;


    Status = AcpiUtReadTableFromFile (Filename, &Table);
    if (ACPI_FAILURE (Status))
    {
        return (Status);
    }

#ifdef ACPI_DATA_TABLE_DISASSEMBLY
    IsAmlTable = AcpiUtIsAmlTable (Table);
#endif

    if (IsAmlTable)
    {
        /* Attempt to recognize and install the table */

        Status = AeLocalLoadTable (Table);
        if (ACPI_FAILURE (Status))
        {
            if (Status == AE_ALREADY_EXISTS)
            {
                AcpiOsPrintf ("Table %4.4s is already installed\n",
                    Table->Signature);
            }
            else
            {
                AcpiOsPrintf ("Could not install table, %s\n",
                    AcpiFormatException (Status));
            }

            return (Status);
        }

        AcpiTbPrintTableHeader (0, Table);

        fprintf (stderr,
            "Acpi table [%4.4s] successfully installed and loaded\n",
            Table->Signature);
    }

    AcpiGbl_AcpiHardwarePresent = FALSE;
    if (ReturnTable)
    {
        *ReturnTable = Table;
    }


#endif  /* ACPI_APPLICATION */
    return (AE_OK);
}
コード例 #2
0
ファイル: dbfileio.c プロジェクト: JamesLinus/ChaiOS
ACPI_STATUS
AcpiDbGetTableFromFile (
    char                    *Filename,
    ACPI_TABLE_HEADER       **ReturnTable,
    BOOLEAN                 MustBeAmlFile)
{
#ifdef ACPI_APPLICATION
    ACPI_STATUS             Status;
    ACPI_TABLE_HEADER       *Table;
    BOOLEAN                 IsAmlTable = TRUE;


    Status = AcpiUtReadTableFromFile (Filename, &Table);
    if (ACPI_FAILURE (Status))
    {
        return (Status);
    }

    if (MustBeAmlFile)
    {
        IsAmlTable = AcpiUtIsAmlTable (Table);
        if (!IsAmlTable)
        {
            ACPI_EXCEPTION ((AE_INFO, AE_OK,
                "Input for -e is not an AML table: "
                "\"%4.4s\" (must be DSDT/SSDT)",
                Table->Signature));
            return (AE_TYPE);
        }
    }

    if (IsAmlTable)
    {
        /* Attempt to recognize and install the table */

        Status = AeLocalLoadTable (Table);
        if (ACPI_FAILURE (Status))
        {
            if (Status == AE_ALREADY_EXISTS)
            {
                AcpiOsPrintf ("Table %4.4s is already installed\n",
                    Table->Signature);
            }
            else
            {
                AcpiOsPrintf ("Could not install table, %s\n",
                    AcpiFormatException (Status));
            }

            return (Status);
        }

        AcpiTbPrintTableHeader (0, Table);

        fprintf (stderr,
            "Acpi table [%4.4s] successfully installed and loaded\n",
            Table->Signature);
    }

    AcpiGbl_AcpiHardwarePresent = FALSE;
    if (ReturnTable)
    {
        *ReturnTable = Table;
    }


#endif  /* ACPI_APPLICATION */
    return (AE_OK);
}
コード例 #3
0
ファイル: aemain.c プロジェクト: LlsDimple/acpica
int ACPI_SYSTEM_XFACE
main (
    int                     argc,
    char                    **argv)
{
    ACPI_STATUS             Status;
    UINT32                  InitFlags;
    ACPI_TABLE_HEADER       *Table = NULL;
    UINT32                  TableCount;
    AE_TABLE_DESC           *TableDesc;


    ACPI_DEBUG_INITIALIZE (); /* For debug version only */
    signal (SIGINT, AeCtrlCHandler);

    /* Init debug globals */

    AcpiDbgLevel = ACPI_NORMAL_DEFAULT;
    AcpiDbgLayer = 0xFFFFFFFF;

    /* Init ACPICA and start debugger thread */

    Status = AcpiInitializeSubsystem ();
    AE_CHECK_OK (AcpiInitializeSubsystem, Status);
    if (ACPI_FAILURE (Status))
    {
        goto ErrorExit;
    }

    printf (ACPI_COMMON_SIGNON (ACPIEXEC_NAME));
    if (argc < 2)
    {
        usage ();
        (void) AcpiOsTerminate ();
        return (0);
    }

    /* Get the command line options */

    if (AeDoOptions (argc, argv))
    {
        goto ErrorExit;
    }

    /* The remaining arguments are filenames for ACPI tables */

    if (!argv[AcpiGbl_Optind])
    {
        goto EnterDebugger;
    }

    AcpiGbl_DbOpt_tables = TRUE;
    AcpiGbl_CstyleDisassembly = FALSE; /* Not supported for AcpiExec */
    TableCount = 0;

    /* Get each of the ACPI table files on the command line */

    while (argv[AcpiGbl_Optind])
    {
        /* Get one entire table */

        Status = AcpiUtReadTableFromFile (argv[AcpiGbl_Optind], &Table);
        if (ACPI_FAILURE (Status))
        {
            printf ("**** Could not get table from file %s, %s\n",
                argv[AcpiGbl_Optind], AcpiFormatException (Status));
            goto ErrorExit;
        }

        /* Ignore non-AML tables, we can't use them. Except for an FADT */

        if (!ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FADT) &&
            !AcpiUtIsAmlTable (Table))
        {
            ACPI_INFO ((AE_INFO,
                "Table [%4.4s] is not an AML table, ignoring",
                Table->Signature));
            AcpiOsFree (Table);
        }
        else
        {
            /* Allocate and link a table descriptor */

            TableDesc = AcpiOsAllocate (sizeof (AE_TABLE_DESC));
            TableDesc->Table = Table;
            TableDesc->Next = AeTableListHead;
            AeTableListHead = TableDesc;

            TableCount++;
        }

        AcpiGbl_Optind++;
    }

    printf ("\n");

    /* Build a local RSDT with all tables and let ACPICA process the RSDT */

    Status = AeBuildLocalTables (TableCount, AeTableListHead);
    if (ACPI_FAILURE (Status))
    {
        goto ErrorExit;
    }

    Status = AeInstallTables ();
    if (ACPI_FAILURE (Status))
    {
        printf ("**** Could not load ACPI tables, %s\n",
            AcpiFormatException (Status));
        goto EnterDebugger;
    }

    /*
     * Install most of the handlers.
     * Override some default region handlers, especially SystemMemory
     */
    Status = AeInstallEarlyHandlers ();
    if (ACPI_FAILURE (Status))
    {
        goto EnterDebugger;
    }

    /* Setup initialization flags for ACPICA */

    InitFlags = (ACPI_NO_HANDLER_INIT | ACPI_NO_ACPI_ENABLE);
    if (!AcpiGbl_DbOpt_ini_methods)
    {
        InitFlags |= (ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT);
    }

    /*
     * Main initialization for ACPICA subsystem
     * TBD: Need a way to call this after the ACPI table "LOAD" command
     */
    Status = AcpiEnableSubsystem (InitFlags);
    if (ACPI_FAILURE (Status))
    {
        printf ("**** Could not EnableSubsystem, %s\n",
            AcpiFormatException (Status));
        goto EnterDebugger;
    }

    /*
     * Install handlers for "device driver" space IDs (EC,SMBus, etc.)
     * and fixed event handlers
     */
    AeInstallLateHandlers ();

    /* Finish the ACPICA initialization */

    Status = AcpiInitializeObjects (InitFlags);
    if (ACPI_FAILURE (Status))
    {
        printf ("**** Could not InitializeObjects, %s\n",
            AcpiFormatException (Status));
        goto EnterDebugger;
    }

    AeMiscellaneousTests ();


EnterDebugger:

    /* Exit if error above and we are in one of the batch modes */

    if (ACPI_FAILURE (Status) && (AcpiGbl_ExecutionMode > 0))
    {
        goto ErrorExit;
    }

    /* Run a batch command or enter the command loop */

    switch (AcpiGbl_ExecutionMode)
    {
    default:
    case AE_MODE_COMMAND_LOOP:

        AcpiDbUserCommands (ACPI_DEBUGGER_COMMAND_PROMPT, NULL);
        break;

    case AE_MODE_BATCH_MULTIPLE:

        AcpiDbRunBatchMode ();
        break;

    case AE_MODE_BATCH_SINGLE:

        AcpiDbExecute (BatchBuffer, NULL, NULL, EX_NO_SINGLE_STEP);
        Status = AcpiTerminate ();
        break;
    }

    return (0);


ErrorExit:
    (void) AcpiOsTerminate ();
    return (-1);
}
コード例 #4
0
static int
NsDumpEntireNamespace (
    char                    *AmlFilename)
{
    ACPI_STATUS             Status;
    ACPI_TABLE_HEADER       *Table = NULL;
    UINT32                  TableCount = 0;
    AE_TABLE_DESC           *TableDesc;
    ACPI_HANDLE             Handle;


    /* Open the binary AML file and read the entire table */

    Status = AcpiUtReadTableFromFile (AmlFilename, &Table);
    if (ACPI_FAILURE (Status))
    {
        printf ("**** Could not get input table %s, %s\n", AmlFilename,
            AcpiFormatException (Status));
        return (-1);
    }

    /* Table must be a DSDT. SSDTs are not currently supported */

    if (!ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT))
    {
        printf ("**** Input table signature is [%4.4s], must be [DSDT]\n",
            Table->Signature);
        return (-1);
    }

    /*
     * Allocate and link a table descriptor (allows for future expansion to
     * multiple input files)
     */
    TableDesc = AcpiOsAllocate (sizeof (AE_TABLE_DESC));
    TableDesc->Table = Table;
    TableDesc->Next = AeTableListHead;
    AeTableListHead = TableDesc;

    TableCount++;

    /*
     * Build a local XSDT with all tables. Normally, here is where the
     * RSDP search is performed to find the ACPI tables
     */
    Status = AeBuildLocalTables (TableCount, AeTableListHead);
    if (ACPI_FAILURE (Status))
    {
        return (-1);
    }

    /* Initialize table manager, get XSDT */

    Status = AcpiInitializeTables (Tables, ACPI_MAX_INIT_TABLES, TRUE);
    if (ACPI_FAILURE (Status))
    {
        printf ("**** Could not initialize ACPI table manager, %s\n",
            AcpiFormatException (Status));
        return (-1);
    }

    /* Reallocate root table to dynamic memory */

    Status = AcpiReallocateRootTable ();
    if (ACPI_FAILURE (Status))
    {
        printf ("**** Could not reallocate root table, %s\n",
            AcpiFormatException (Status));
        return (-1);
    }

    /* Load the ACPI namespace */

    Status = AcpiLoadTables ();
    if (ACPI_FAILURE (Status))
    {
        printf ("**** Could not load ACPI tables, %s\n",
            AcpiFormatException (Status));
        return (-1);
    }

    /*
     * Enable ACPICA. These calls don't do much for this
     * utility, since we only dump the namespace. There is no
     * hardware or event manager code underneath.
     */
    Status = AcpiEnableSubsystem (
                ACPI_NO_ACPI_ENABLE |
                ACPI_NO_ADDRESS_SPACE_INIT |
                ACPI_NO_EVENT_INIT |
                ACPI_NO_HANDLER_INIT);
    if (ACPI_FAILURE (Status))
    {
        printf ("**** Could not EnableSubsystem, %s\n",
            AcpiFormatException (Status));
        return (-1);
    }

    Status = AcpiInitializeObjects (
                ACPI_NO_ADDRESS_SPACE_INIT |
                ACPI_NO_DEVICE_INIT |
                ACPI_NO_EVENT_INIT);
    if (ACPI_FAILURE (Status))
    {
        printf ("**** Could not InitializeObjects, %s\n",
            AcpiFormatException (Status));
        return (-1);
    }

    /*
     * Perform a namespace walk to dump the contents
     */
    AcpiOsPrintf ("\nACPI Namespace:\n");

    AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, ACPI_UINT32_MAX,
        ACPI_OWNER_ID_MAX, AcpiGbl_RootNode);


    /* Example: get a handle to the _GPE scope */

    Status = AcpiGetHandle (NULL, "\\_GPE", &Handle);
    AE_CHECK_OK (AcpiGetHandle, Status);

    return (0);
}