FreeBSD/sys/contrib/dev/acpica/common/adisasm.c
/******************************************************************************
 *
 * FUNCTION:    AdDisassembleOneTable
 *
 * PARAMETERS:  Table               - Raw AML table
 *              File                - Pointer for the input file
 *              Filename            - AML input filename
 *              DisasmFilename      - Output filename
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Disassemble a single ACPI table. AML or data table.
 *
 *****************************************************************************/
AdDisassembleOneTable
PARAMETERS:  Table               - Raw AML table
File                - Pointer for the input file
Filename            - AML input filename
DisasmFilename      - Output filename

Status

Disassemble a single ACPI table. AML or data table.
AdDisassembleOneTable PARAMETERS : Table - Raw AML table File - Pointer for the input file Filename - AML input filename DisasmFilename - Output filename Status Disassemble a single ACPI table . AML or data table .
static ACPI_STATUS
AdDisassembleOneTable (
    ACPI_TABLE_HEADER       *Table,
    FILE                    *File,
    char                    *Filename,
    char                    *DisasmFilename)
{
    ACPI_STATUS             Status;
    ACPI_OWNER_ID           OwnerId;
    if (!AcpiGbl_ForceAmlDisassembly && !AcpiUtIsAmlTable (Table))
    {
        AdDisassemblerHeader (Filename, ACPI_IS_DATA_TABLE);
        AcpiOsPrintf (" * ACPI Data Table [%4.4s]\n *\n",
            Table->Signature);
        AcpiOsPrintf (" * Format: [HexOffset DecimalOffset ByteLength]  "
            "FieldName : FieldValue\n */\n\n");
        AcpiDmDumpDataTable (Table);
        fprintf (stderr, "Acpi Data Table [%4.4s] decoded\n",
            Table->Signature);
        if (File)
        {
            fprintf (stderr, "Formatted output:  %s - %u bytes\n",
                DisasmFilename, CmGetFileSize (File));
        }
        return (AE_OK);
    }
    Status = AdParseTable (Table, &OwnerId, TRUE, FALSE);
    if (ACPI_FAILURE (Status))
    {
        AcpiOsPrintf ("Could not parse ACPI tables, %s\n",
            AcpiFormatException (Status));
        return (Status);
    }
    if (AslCompilerdebug && File)
    {
        AcpiOsPrintf ("/**** Before second load\n");
        NsSetupNamespaceListing (File);
        NsDisplayNamespace ();
        AcpiOsPrintf ("*****/\n");
    }
    AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot,
        AcpiGbl_RootNode, OwnerId);
    AcpiDmCrossReferenceNamespace (AcpiGbl_ParseOpRoot,
        AcpiGbl_RootNode, OwnerId);
    if (AslCompilerdebug)
    {
        AcpiDmDumpTree (AcpiGbl_ParseOpRoot);
    }
    AcpiDmFindOrphanMethods (AcpiGbl_ParseOpRoot);
    if (AcpiDmGetExternalMethodCount ())
    {
        Status = AdReparseOneTable (Table, File, OwnerId);
        if (ACPI_FAILURE (Status))
        {
            return (Status);
        }
    }
    AcpiDmConvertResourceIndexes (AcpiGbl_ParseOpRoot, AcpiGbl_RootNode);
    if (AcpiGbl_DmOpt_Disasm)
    {
        AdDisplayTables (Filename, Table);
        AcpiDmDumpDataTable (Table);
        fprintf (stderr, "Disassembly completed\n");
        if (File)
        {
            fprintf (stderr, "ASL Output:    %s - %u bytes\n",
                DisasmFilename, CmGetFileSize (File));
        }
        if (Gbl_MapfileFlag)
        {
            fprintf (stderr, "%14s %s - %u bytes\n",
                Gbl_Files[ASL_FILE_MAP_OUTPUT].ShortDescription,
                Gbl_Files[ASL_FILE_MAP_OUTPUT].Filename,
                FlGetFileSize (ASL_FILE_MAP_OUTPUT));
        }
    }
    return (AE_OK);
}
static ACPI_STATUS AdDisassembleOneTable ( ACPI_TABLE_HEADER * Table , FILE * File , char * Filename , char * DisasmFilename ) { ACPI_STATUS Status ; ACPI_OWNER_ID OwnerId ; if ( ! AcpiGbl_ForceAmlDisassembly && ! AcpiUtIsAmlTable ( Table ) ) { AdDisassemblerHeader ( Filename , ACPI_IS_DATA_TABLE ) ; AcpiOsPrintf ( " \n \n " , Table -> Signature ) ; AcpiOsPrintf ( " " " \n \n \n " ) ; AcpiDmDumpDataTable ( Table ) ; fprintf ( stderr , " \n " , Table -> Signature ) ; if ( File ) { fprintf ( stderr , " \n " , DisasmFilename , CmGetFileSize ( File ) ) ; } return ( AE_OK ) ; } Status = AdParseTable ( Table , & OwnerId , TRUE , FALSE ) ; if ( ACPI_FAILURE ( Status ) ) { AcpiOsPrintf ( " \n " , AcpiFormatException ( Status ) ) ; return ( Status ) ; } if ( AslCompilerdebug && File ) { AcpiOsPrintf ( " \n " ) ; NsSetupNamespaceListing ( File ) ; NsDisplayNamespace ( ) ; AcpiOsPrintf ( " \n " ) ; } AcpiDmFinishNamespaceLoad ( AcpiGbl_ParseOpRoot , AcpiGbl_RootNode , OwnerId ) ; AcpiDmCrossReferenceNamespace ( AcpiGbl_ParseOpRoot , AcpiGbl_RootNode , OwnerId ) ; if ( AslCompilerdebug ) { AcpiDmDumpTree ( AcpiGbl_ParseOpRoot ) ; } AcpiDmFindOrphanMethods ( AcpiGbl_ParseOpRoot ) ; if ( AcpiDmGetExternalMethodCount ( ) ) { Status = AdReparseOneTable ( Table , File , OwnerId ) ; if ( ACPI_FAILURE ( Status ) ) { return ( Status ) ; } } AcpiDmConvertResourceIndexes ( AcpiGbl_ParseOpRoot , AcpiGbl_RootNode ) ; if ( AcpiGbl_DmOpt_Disasm ) { AdDisplayTables ( Filename , Table ) ; AcpiDmDumpDataTable ( Table ) ; fprintf ( stderr , " \n " ) ; if ( File ) { fprintf ( stderr , " \n " , DisasmFilename , CmGetFileSize ( File ) ) ; } if ( Gbl_MapfileFlag ) { fprintf ( stderr , " \n " , Gbl_Files [ ASL_FILE_MAP_OUTPUT ] . ShortDescription , Gbl_Files [ ASL_FILE_MAP_OUTPUT ] . Filename , FlGetFileSize ( ASL_FILE_MAP_OUTPUT ) ) ; } } return ( AE_OK ) ; }
FUNCTION:    AdDisassembleOneTable
 PARAMETERS:  Table               - Raw AML table
              File                - Pointer for the input file
              Filename            - AML input filename
              DisasmFilename      - Output filename
FUNCTION : AdDisassembleOneTable PARAMETERS : Table - Raw AML table File - Pointer for the input file Filename - AML input filename DisasmFilename - Output filename
/* ForceAmlDisassembly means to assume the table contains valid AML */ /* This is a "Data Table" (non-AML table) */ /*
     * This is an AML table (DSDT or SSDT).
     * Always parse the tables, only option is what to display
     */ /* Debug output, namespace and parse tree */ /* Load namespace from names created within control methods */ /*
     * Cross reference the namespace here, in order to
     * generate External() statements
     */ /* Find possible calls to external control methods */ /*
     * If we found any external control methods, we must reparse
     * the entire tree with the new information (namely, the
     * number of arguments per method)
     */ /*
     * Now that the namespace is finalized, we can perform namespace
     * transforms.
     *
     * 1) Convert fixed-offset references to resource descriptors
     *    to symbolic references (Note: modifies namespace)
     */ /* Optional displays */ /* This is the real disassembly */ /* Dump hex table if requested (-vt) */