2005-06-29 22:56:22 +04:00
|
|
|
|
|
2005-06-29 22:13:19 +04:00
|
|
|
|
/******************************************************************************
|
2005-06-29 22:56:22 +04:00
|
|
|
|
*
|
2005-06-29 22:13:19 +04:00
|
|
|
|
* Module Name: tbutils - Table manipulation utilities
|
|
|
|
|
*
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* 1. Copyright Notice
|
|
|
|
|
*
|
2005-06-29 22:56:22 +04:00
|
|
|
|
* Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
|
|
|
|
|
* reserved.
|
2005-06-29 22:13:19 +04:00
|
|
|
|
*
|
|
|
|
|
* 2. License
|
|
|
|
|
*
|
|
|
|
|
* 2.1. This is your license from Intel Corp. under its intellectual property
|
|
|
|
|
* rights. You may have additional license terms from the party that provided
|
|
|
|
|
* you this software, covering your right to use that party's intellectual
|
|
|
|
|
* property rights.
|
|
|
|
|
*
|
|
|
|
|
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
|
|
|
|
|
* copy of the source code appearing in this file ("Covered Code") an
|
|
|
|
|
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
|
|
|
|
|
* base code distributed originally by Intel ("Original Intel Code") to copy,
|
|
|
|
|
* make derivatives, distribute, use and display any portion of the Covered
|
|
|
|
|
* Code in any form, with the right to sublicense such rights; and
|
|
|
|
|
*
|
|
|
|
|
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
|
|
|
|
|
* license (with the right to sublicense), under only those claims of Intel
|
|
|
|
|
* patents that are infringed by the Original Intel Code, to make, use, sell,
|
|
|
|
|
* offer to sell, and import the Covered Code and derivative works thereof
|
|
|
|
|
* solely to the minimum extent necessary to exercise the above copyright
|
|
|
|
|
* license, and in no event shall the patent license extend to any additions
|
|
|
|
|
* to or modifications of the Original Intel Code. No other license or right
|
|
|
|
|
* is granted directly or by implication, estoppel or otherwise;
|
|
|
|
|
*
|
|
|
|
|
* The above copyright and patent license is granted only if the following
|
|
|
|
|
* conditions are met:
|
|
|
|
|
*
|
2005-06-29 22:56:22 +04:00
|
|
|
|
* 3. Conditions
|
2005-06-29 22:13:19 +04:00
|
|
|
|
*
|
2005-06-29 22:56:22 +04:00
|
|
|
|
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
|
2005-06-29 22:13:19 +04:00
|
|
|
|
* Redistribution of source code of any substantial portion of the Covered
|
|
|
|
|
* Code or modification with rights to further distribute source must include
|
|
|
|
|
* the above Copyright Notice, the above License, this list of Conditions,
|
|
|
|
|
* and the following Disclaimer and Export Compliance provision. In addition,
|
|
|
|
|
* Licensee must cause all Covered Code to which Licensee contributes to
|
|
|
|
|
* contain a file documenting the changes Licensee made to create that Covered
|
|
|
|
|
* Code and the date of any change. Licensee must include in that file the
|
2005-06-29 22:56:22 +04:00
|
|
|
|
* documentation of any changes made by any predecessor Licensee. Licensee
|
2005-06-29 22:13:19 +04:00
|
|
|
|
* must include a prominent statement that the modification is derived,
|
|
|
|
|
* directly or indirectly, from Original Intel Code.
|
|
|
|
|
*
|
2005-06-29 22:56:22 +04:00
|
|
|
|
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
|
2005-06-29 22:13:19 +04:00
|
|
|
|
* Redistribution of source code of any substantial portion of the Covered
|
|
|
|
|
* Code or modification without rights to further distribute source must
|
|
|
|
|
* include the following Disclaimer and Export Compliance provision in the
|
|
|
|
|
* documentation and/or other materials provided with distribution. In
|
|
|
|
|
* addition, Licensee may not authorize further sublicense of source of any
|
|
|
|
|
* portion of the Covered Code, and must include terms to the effect that the
|
|
|
|
|
* license from Licensee to its licensee is limited to the intellectual
|
|
|
|
|
* property embodied in the software Licensee provides to its licensee, and
|
|
|
|
|
* not to intellectual property embodied in modifications its licensee may
|
|
|
|
|
* make.
|
|
|
|
|
*
|
|
|
|
|
* 3.3. Redistribution of Executable. Redistribution in executable form of any
|
|
|
|
|
* substantial portion of the Covered Code or modification must reproduce the
|
|
|
|
|
* above Copyright Notice, and the following Disclaimer and Export Compliance
|
|
|
|
|
* provision in the documentation and/or other materials provided with the
|
|
|
|
|
* distribution.
|
|
|
|
|
*
|
|
|
|
|
* 3.4. Intel retains all right, title, and interest in and to the Original
|
|
|
|
|
* Intel Code.
|
|
|
|
|
*
|
|
|
|
|
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
|
|
|
|
|
* Intel shall be used in advertising or otherwise to promote the sale, use or
|
|
|
|
|
* other dealings in products derived from or relating to the Covered Code
|
|
|
|
|
* without prior written authorization from Intel.
|
|
|
|
|
*
|
|
|
|
|
* 4. Disclaimer and Export Compliance
|
|
|
|
|
*
|
|
|
|
|
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
|
|
|
|
|
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
|
|
|
|
|
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
|
|
|
|
|
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
|
|
|
|
|
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
|
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
|
2005-06-29 22:56:22 +04:00
|
|
|
|
* PARTICULAR PURPOSE.
|
2005-06-29 22:13:19 +04:00
|
|
|
|
*
|
|
|
|
|
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
|
|
|
|
|
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
|
|
|
|
|
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
|
|
|
|
|
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
|
|
|
|
|
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
|
|
|
|
|
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
|
|
|
|
|
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
|
|
|
|
|
* LIMITED REMEDY.
|
|
|
|
|
*
|
|
|
|
|
* 4.3. Licensee shall not export, either directly or indirectly, any of this
|
|
|
|
|
* software or system incorporating such software without first obtaining any
|
|
|
|
|
* required license or other approval from the U. S. Department of Commerce or
|
|
|
|
|
* any other agency or department of the United States Government. In the
|
|
|
|
|
* event Licensee exports any such software from the United States or
|
|
|
|
|
* re-exports any such software from a foreign destination, Licensee shall
|
|
|
|
|
* ensure that the distribution and export/re-export of the software is in
|
|
|
|
|
* compliance with all laws, regulations, orders, or other restrictions of the
|
|
|
|
|
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
|
|
|
|
|
* any of its subsidiaries will export/re-export any technical data, process,
|
|
|
|
|
* software, or service, directly or indirectly, to any country for which the
|
|
|
|
|
* United States government or any agency thereof requires an export license,
|
|
|
|
|
* other governmental approval, or letter of assurance, without first obtaining
|
|
|
|
|
* such license, approval or letter.
|
|
|
|
|
*
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#define __TBUTILS_C__
|
|
|
|
|
|
2005-06-29 22:56:22 +04:00
|
|
|
|
#include <acpi.h>
|
|
|
|
|
#include <tables.h>
|
2005-06-29 22:56:25 +04:00
|
|
|
|
#include <interp.h>
|
2005-06-29 22:13:19 +04:00
|
|
|
|
|
|
|
|
|
|
2005-06-29 22:56:22 +04:00
|
|
|
|
#define _COMPONENT TABLE_MANAGER
|
|
|
|
|
MODULE_NAME ("tbutils");
|
2005-06-29 22:13:19 +04:00
|
|
|
|
|
2005-06-29 22:55:50 +04:00
|
|
|
|
|
2005-06-29 22:56:22 +04:00
|
|
|
|
/*****************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* FUNCTION: TbSystemTablePointer
|
|
|
|
|
*
|
|
|
|
|
* PARAMETERS: *Where - Pointer to be examined
|
|
|
|
|
*
|
|
|
|
|
* RETURN: TRUE if Where is within the AML stream (in one of the ACPI
|
|
|
|
|
* system tables such as the DSDT or an SSDT.)
|
|
|
|
|
* FALSE otherwise
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2005-06-29 22:55:50 +04:00
|
|
|
|
ACPI_STATUS
|
2005-06-29 22:56:22 +04:00
|
|
|
|
TbHandleToObject (
|
2005-06-29 22:55:50 +04:00
|
|
|
|
UINT16 TableId,
|
2005-06-29 22:56:22 +04:00
|
|
|
|
ACPI_TABLE_DESC **TableDesc)
|
|
|
|
|
{
|
|
|
|
|
UINT32 i;
|
|
|
|
|
ACPI_TABLE_DESC *ListHead;
|
2005-06-29 22:55:50 +04:00
|
|
|
|
|
2005-06-29 22:13:19 +04:00
|
|
|
|
|
2005-06-29 22:56:22 +04:00
|
|
|
|
for (i = 0; i < ACPI_TABLE_MAX; i++)
|
|
|
|
|
{
|
|
|
|
|
ListHead = &Gbl_AcpiTables[i];
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
if (ListHead->TableId == TableId)
|
|
|
|
|
{
|
|
|
|
|
*TableDesc = ListHead;
|
|
|
|
|
return AE_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ListHead = ListHead->Next;
|
|
|
|
|
|
|
|
|
|
} while (ListHead != &Gbl_AcpiTables[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEBUG_PRINT (ACPI_ERROR, ("TableId=0x%X does not exist\n", TableId));
|
|
|
|
|
return AE_BAD_PARAMETER;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* FUNCTION: TbSystemTablePointer
|
2005-06-29 22:54:41 +04:00
|
|
|
|
*
|
2005-06-29 22:56:22 +04:00
|
|
|
|
* PARAMETERS: *Where - Pointer to be examined
|
2005-06-29 22:54:41 +04:00
|
|
|
|
*
|
2005-06-29 22:56:22 +04:00
|
|
|
|
* RETURN: TRUE if Where is within the AML stream (in one of the ACPI
|
|
|
|
|
* system tables such as the DSDT or an SSDT.)
|
|
|
|
|
* FALSE otherwise
|
2005-06-29 22:54:41 +04:00
|
|
|
|
*
|
2005-06-29 22:56:22 +04:00
|
|
|
|
****************************************************************************/
|
2005-06-29 22:54:41 +04:00
|
|
|
|
|
2005-06-29 22:56:22 +04:00
|
|
|
|
BOOLEAN
|
|
|
|
|
TbSystemTablePointer (
|
|
|
|
|
void *Where)
|
2005-06-29 22:54:41 +04:00
|
|
|
|
{
|
2005-06-29 22:56:22 +04:00
|
|
|
|
UINT32 i;
|
|
|
|
|
ACPI_TABLE_DESC *TableDesc;
|
|
|
|
|
ACPI_TABLE_HEADER *Table;
|
2005-06-29 22:54:42 +04:00
|
|
|
|
|
2005-06-29 22:54:41 +04:00
|
|
|
|
|
2005-06-29 22:56:22 +04:00
|
|
|
|
/* No function trace, called too often! */
|
2005-06-29 22:55:09 +04:00
|
|
|
|
|
|
|
|
|
|
2005-06-29 22:56:22 +04:00
|
|
|
|
/* Ignore null pointer */
|
2005-06-29 22:54:41 +04:00
|
|
|
|
|
2005-06-29 22:56:22 +04:00
|
|
|
|
if (!Where)
|
2005-06-29 22:54:41 +04:00
|
|
|
|
{
|
2005-06-29 22:56:22 +04:00
|
|
|
|
return (FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-29 22:55:49 +04:00
|
|
|
|
|
2005-06-29 22:56:22 +04:00
|
|
|
|
/* Check for a pointer within the DSDT */
|
|
|
|
|
|
|
|
|
|
if (IS_IN_ACPI_TABLE (Where, Gbl_DSDT))
|
|
|
|
|
{
|
|
|
|
|
return (TRUE);
|
2005-06-29 22:54:41 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-06-29 22:56:22 +04:00
|
|
|
|
/* Check each of the loaded SSDTs (if any)*/
|
|
|
|
|
|
|
|
|
|
TableDesc = &Gbl_AcpiTables[TABLE_SSDT];
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < Gbl_AcpiTables[TABLE_SSDT].Count; i++)
|
2005-06-29 22:54:41 +04:00
|
|
|
|
{
|
2005-06-29 22:56:22 +04:00
|
|
|
|
Table = TableDesc->Pointer;
|
2005-06-29 22:54:42 +04:00
|
|
|
|
|
2005-06-29 22:56:22 +04:00
|
|
|
|
if (IS_IN_ACPI_TABLE (Where, Table))
|
|
|
|
|
{
|
|
|
|
|
return (TRUE);
|
|
|
|
|
}
|
2005-06-29 22:55:49 +04:00
|
|
|
|
|
2005-06-29 22:56:22 +04:00
|
|
|
|
TableDesc = TableDesc->Next;
|
2005-06-29 22:54:41 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-06-29 22:56:22 +04:00
|
|
|
|
/* TBD: Need to check the PSDTs? */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-29 22:56:25 +04:00
|
|
|
|
/******************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* FUNCTION: TbValidateTableHeader
|
|
|
|
|
*
|
|
|
|
|
* PARAMETERS: TableHeader - Logical pointer to the table
|
|
|
|
|
*
|
|
|
|
|
* RETURN: Status
|
|
|
|
|
*
|
|
|
|
|
* DESCRIPTION: Check an ACPI table header for validity
|
|
|
|
|
*
|
|
|
|
|
* NOTE: Table pointers are validated as follows:
|
|
|
|
|
* 1) Table pointer must point to valid physical memory
|
|
|
|
|
* 2) Signature must be 4 ASCII chars, even if we don't recognize the name
|
|
|
|
|
* 3) Table must be readable for length specified in the header
|
|
|
|
|
* 4) Table checksum must be valid (with the exception of the FACS which
|
|
|
|
|
* has no checksum for some odd reason<EFBFBD>)
|
|
|
|
|
*
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
|
|
ACPI_STATUS
|
|
|
|
|
TbValidateTableHeader (
|
|
|
|
|
ACPI_TABLE_HEADER *TableHeader)
|
|
|
|
|
{
|
2005-06-29 22:56:27 +04:00
|
|
|
|
ACPI_NAME Signature;
|
|
|
|
|
|
2005-06-29 22:56:25 +04:00
|
|
|
|
|
|
|
|
|
/* Verify that this is a valid address */
|
|
|
|
|
|
|
|
|
|
if (!OsdReadable (TableHeader, sizeof (ACPI_TABLE_HEADER)))
|
|
|
|
|
{
|
|
|
|
|
DEBUG_PRINT (ACPI_ERROR, ("Cannot read table header at %p\n", TableHeader));
|
|
|
|
|
return AE_BAD_ADDRESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Ensure that the signature is 4 ASCII characters */
|
|
|
|
|
|
2005-06-29 22:56:27 +04:00
|
|
|
|
STORE32 (&Signature, &TableHeader->Signature);
|
|
|
|
|
if (!CmValidAcpiName (Signature))
|
2005-06-29 22:56:25 +04:00
|
|
|
|
{
|
2005-06-29 22:56:26 +04:00
|
|
|
|
DEBUG_PRINT (ACPI_ERROR, ("Table signature at %p [%X] has invalid characters\n",
|
2005-06-29 22:56:27 +04:00
|
|
|
|
TableHeader, &Signature));
|
2005-06-29 22:56:26 +04:00
|
|
|
|
|
2005-06-29 22:56:25 +04:00
|
|
|
|
REPORT_WARNING ("Invalid table signature found");
|
2005-06-29 22:56:26 +04:00
|
|
|
|
DUMP_BUFFER (TableHeader, sizeof (ACPI_TABLE_HEADER));
|
2005-06-29 22:56:25 +04:00
|
|
|
|
return AE_BAD_SIGNATURE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Validate the table length */
|
|
|
|
|
|
2005-06-29 22:56:27 +04:00
|
|
|
|
if (TableHeader->Length < sizeof (ACPI_TABLE_HEADER))
|
2005-06-29 22:56:25 +04:00
|
|
|
|
{
|
2005-06-29 22:56:26 +04:00
|
|
|
|
DEBUG_PRINT (ACPI_ERROR, ("Invalid length in table header %p name %4.4s\n",
|
2005-06-29 22:56:27 +04:00
|
|
|
|
TableHeader, &Signature));
|
2005-06-29 22:56:26 +04:00
|
|
|
|
|
2005-06-29 22:56:25 +04:00
|
|
|
|
REPORT_WARNING ("Invalid table header length found");
|
2005-06-29 22:56:26 +04:00
|
|
|
|
DUMP_BUFFER (TableHeader, sizeof (ACPI_TABLE_HEADER));
|
2005-06-29 22:56:25 +04:00
|
|
|
|
return AE_BAD_HEADER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return AE_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-06-29 22:56:22 +04:00
|
|
|
|
/******************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* FUNCTION: TbMapAcpiTable
|
|
|
|
|
*
|
|
|
|
|
* PARAMETERS: PhysicalAddress - Physical address of table to map
|
|
|
|
|
* *Size - Size of the table. If zero, the size
|
|
|
|
|
* from the table header is used. Actual
|
|
|
|
|
* size is returned here.
|
|
|
|
|
* **LogicalAddress - Logical address of mapped table
|
|
|
|
|
*
|
|
|
|
|
* RETURN: Logical address of the mapped table.
|
|
|
|
|
*
|
|
|
|
|
* DESCRIPTION: Maps the physical address of table into a logical address
|
|
|
|
|
*
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
|
|
ACPI_STATUS
|
|
|
|
|
TbMapAcpiTable (
|
|
|
|
|
void *PhysicalAddress,
|
|
|
|
|
UINT32 *Size,
|
|
|
|
|
void **LogicalAddress)
|
|
|
|
|
{
|
|
|
|
|
ACPI_TABLE_HEADER *Table;
|
|
|
|
|
UINT32 TableSize = *Size;
|
|
|
|
|
ACPI_STATUS Status = AE_OK;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* If size is zero, look at the table header to get the actual size */
|
|
|
|
|
|
2005-06-29 22:56:26 +04:00
|
|
|
|
if ((*Size) == 0)
|
2005-06-29 22:54:41 +04:00
|
|
|
|
{
|
2005-06-29 22:56:22 +04:00
|
|
|
|
/* Get the table header so we can extract the table length */
|
|
|
|
|
|
2005-06-29 22:56:25 +04:00
|
|
|
|
Status = OsdMapMemory (PhysicalAddress, sizeof (ACPI_TABLE_HEADER), (void **)&Table);
|
2005-06-29 22:56:22 +04:00
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
|
{
|
|
|
|
|
return Status;
|
|
|
|
|
}
|
2005-06-29 22:55:49 +04:00
|
|
|
|
|
2005-06-29 22:56:26 +04:00
|
|
|
|
/* Extract the full table length before we delete the mapping */
|
|
|
|
|
|
|
|
|
|
TableSize = Table->Length;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Validate the header and delete the mapping.
|
|
|
|
|
* We will create a mapping for the full table below.
|
|
|
|
|
*/
|
2005-06-29 22:56:25 +04:00
|
|
|
|
|
|
|
|
|
Status = TbValidateTableHeader (Table);
|
2005-06-29 22:56:26 +04:00
|
|
|
|
|
|
|
|
|
/* Always unmap the memory for the header */
|
|
|
|
|
|
|
|
|
|
OsdUnMapMemory (Table, sizeof (ACPI_TABLE_HEADER));
|
|
|
|
|
|
|
|
|
|
/* Exit if header invalid */
|
|
|
|
|
|
2005-06-29 22:56:25 +04:00
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
|
{
|
|
|
|
|
return Status;
|
|
|
|
|
}
|
2005-06-29 22:54:41 +04:00
|
|
|
|
}
|
|
|
|
|
|
2005-06-29 22:56:22 +04:00
|
|
|
|
|
|
|
|
|
/* Map the physical memory for the correct length */
|
|
|
|
|
|
2005-06-29 22:56:25 +04:00
|
|
|
|
Status = OsdMapMemory (PhysicalAddress, TableSize, (void **)&Table);
|
2005-06-29 22:56:22 +04:00
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
|
{
|
|
|
|
|
return Status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DEBUG_PRINT (ACPI_INFO, ("Mapped memory for ACPI table, length=%d(0x%X) at %p\n",
|
|
|
|
|
TableSize, TableSize, Table));
|
|
|
|
|
|
|
|
|
|
*Size = TableSize;
|
|
|
|
|
*LogicalAddress = Table;
|
|
|
|
|
|
|
|
|
|
return Status;
|
2005-06-29 22:54:41 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-06-29 22:56:22 +04:00
|
|
|
|
/******************************************************************************
|
2005-06-29 22:13:19 +04:00
|
|
|
|
*
|
2005-06-29 22:56:22 +04:00
|
|
|
|
* FUNCTION: TbVerifyTableChecksum
|
2005-06-29 22:13:19 +04:00
|
|
|
|
*
|
|
|
|
|
* PARAMETERS: *TableHeader - ACPI table to verify
|
|
|
|
|
*
|
|
|
|
|
* RETURN: 8 bit checksum of table
|
|
|
|
|
*
|
|
|
|
|
* DESCRIPTION: Does an 8 bit checksum of table and returns status. A correct
|
|
|
|
|
* table should have a checksum of 0.
|
|
|
|
|
*
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
|
|
ACPI_STATUS
|
2005-06-29 22:56:22 +04:00
|
|
|
|
TbVerifyTableChecksum (
|
|
|
|
|
void *TableHeader)
|
2005-06-29 22:13:19 +04:00
|
|
|
|
{
|
2005-06-29 22:56:22 +04:00
|
|
|
|
UINT8 CheckSum;
|
2005-06-29 22:54:32 +04:00
|
|
|
|
ACPI_STATUS Status = AE_OK;
|
2005-06-29 22:13:19 +04:00
|
|
|
|
|
|
|
|
|
|
2005-06-29 22:56:22 +04:00
|
|
|
|
FUNCTION_TRACE ("TbVerifyTableChecksum");
|
2005-06-29 22:13:19 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Compute the checksum on the table */
|
|
|
|
|
|
2005-06-29 22:56:22 +04:00
|
|
|
|
CheckSum = TbChecksum (TableHeader,
|
|
|
|
|
(ACPI_SIZE) ((ACPI_TABLE_HEADER *) TableHeader)->Length);
|
2005-06-29 22:13:19 +04:00
|
|
|
|
|
|
|
|
|
/* Return the appropriate exception */
|
|
|
|
|
|
2005-06-29 22:56:22 +04:00
|
|
|
|
if (CheckSum)
|
2005-06-29 22:13:19 +04:00
|
|
|
|
{
|
2005-06-29 22:56:22 +04:00
|
|
|
|
REPORT_ERROR ("Invalid ACPI table checksum");
|
|
|
|
|
DEBUG_PRINT (ACPI_INFO, ("TbVerifyTableChecksum: Invalid checksum (%X)\n", CheckSum));
|
2005-06-29 22:13:19 +04:00
|
|
|
|
|
|
|
|
|
Status = AE_BAD_CHECKSUM;
|
|
|
|
|
}
|
2005-06-29 22:56:22 +04:00
|
|
|
|
|
|
|
|
|
|
2005-06-29 22:13:19 +04:00
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-06-29 22:56:22 +04:00
|
|
|
|
/******************************************************************************
|
2005-06-29 22:13:19 +04:00
|
|
|
|
*
|
2005-06-29 22:56:22 +04:00
|
|
|
|
* FUNCTION: TbChecksum
|
2005-06-29 22:13:19 +04:00
|
|
|
|
*
|
|
|
|
|
* PARAMETERS: Buffer - Buffer to checksum
|
|
|
|
|
* Length - Size of the buffer
|
|
|
|
|
*
|
2005-06-29 22:56:22 +04:00
|
|
|
|
* RETURNS 8 bit checksum of buffer
|
2005-06-29 22:13:19 +04:00
|
|
|
|
*
|
2005-06-29 22:56:22 +04:00
|
|
|
|
* DESCRIPTION: Computes an 8 bit checksum of the buffer(length) and returns it.
|
2005-06-29 22:13:19 +04:00
|
|
|
|
*
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
|
|
UINT8
|
2005-06-29 22:56:22 +04:00
|
|
|
|
TbChecksum (
|
|
|
|
|
void *Buffer,
|
2005-06-29 22:13:19 +04:00
|
|
|
|
UINT32 Length)
|
|
|
|
|
{
|
2005-06-29 22:56:22 +04:00
|
|
|
|
UINT8 *limit;
|
|
|
|
|
UINT8 *rover;
|
2005-06-29 22:13:19 +04:00
|
|
|
|
UINT8 sum = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Buffer && Length)
|
2005-06-29 22:56:22 +04:00
|
|
|
|
{
|
2005-06-29 22:13:19 +04:00
|
|
|
|
/* Buffer and Length are valid */
|
2005-06-29 22:56:22 +04:00
|
|
|
|
|
2005-06-29 22:13:19 +04:00
|
|
|
|
limit = (UINT8 *) Buffer + Length;
|
|
|
|
|
|
|
|
|
|
for (rover = Buffer; rover < limit; rover++)
|
|
|
|
|
{
|
2005-06-29 22:54:35 +04:00
|
|
|
|
sum = (UINT8) (sum + *rover);
|
2005-06-29 22:13:19 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-29 22:56:22 +04:00
|
|
|
|
return sum;
|
|
|
|
|
}
|
2005-06-29 22:55:48 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|