From b58b48bed8ea5143df93704f27949298f2d54429 Mon Sep 17 00:00:00 2001 From: msmith Date: Sat, 23 Feb 2002 05:10:40 +0000 Subject: Vendor import of the Intel ACPI CA 20020217 drop. --- sys/contrib/dev/acpica/tbxface.c | 99 +++++++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 41 deletions(-) (limited to 'sys/contrib/dev/acpica/tbxface.c') diff --git a/sys/contrib/dev/acpica/tbxface.c b/sys/contrib/dev/acpica/tbxface.c index 457c634..7ff0f63 100644 --- a/sys/contrib/dev/acpica/tbxface.c +++ b/sys/contrib/dev/acpica/tbxface.c @@ -2,7 +2,7 @@ * * Module Name: tbxface - Public interfaces to the ACPI subsystem * ACPI table oriented interfaces - * $Revision: 45 $ + * $Revision: 51 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. * All rights reserved. * * 2. License @@ -124,7 +124,7 @@ #define _COMPONENT ACPI_TABLES - MODULE_NAME ("tbxface") + ACPI_MODULE_NAME ("tbxface") /******************************************************************************* @@ -148,7 +148,7 @@ AcpiLoadTables (void) UINT32 NumberOfTables = 0; - FUNCTION_TRACE ("AcpiLoadTables"); + ACPI_FUNCTION_TRACE ("AcpiLoadTables"); /* Get the RSDP */ @@ -157,7 +157,7 @@ AcpiLoadTables (void) &RsdpPhysicalAddress); if (ACPI_FAILURE (Status)) { - REPORT_ERROR (("AcpiLoadTables: Could not get RSDP, %s\n", + ACPI_REPORT_ERROR (("AcpiLoadTables: Could not get RSDP, %s\n", AcpiFormatException (Status))); goto ErrorExit; } @@ -167,7 +167,7 @@ AcpiLoadTables (void) Status = AcpiTbVerifyRsdp (RsdpPhysicalAddress); if (ACPI_FAILURE (Status)) { - REPORT_ERROR (("AcpiLoadTables: RSDP Failed validation: %s\n", + ACPI_REPORT_ERROR (("AcpiLoadTables: RSDP Failed validation: %s\n", AcpiFormatException (Status))); goto ErrorExit; } @@ -177,7 +177,7 @@ AcpiLoadTables (void) Status = AcpiTbGetTableRsdt (&NumberOfTables); if (ACPI_FAILURE (Status)) { - REPORT_ERROR (("AcpiLoadTables: Could not load RSDT: %s\n", + ACPI_REPORT_ERROR (("AcpiLoadTables: Could not load RSDT: %s\n", AcpiFormatException (Status))); goto ErrorExit; } @@ -187,7 +187,7 @@ AcpiLoadTables (void) Status = AcpiTbGetAllTables (NumberOfTables, NULL); if (ACPI_FAILURE (Status)) { - REPORT_ERROR (("AcpiLoadTables: Error getting required tables (DSDT/FADT/FACS): %s\n", + ACPI_REPORT_ERROR (("AcpiLoadTables: Error getting required tables (DSDT/FADT/FACS): %s\n", AcpiFormatException (Status))); goto ErrorExit; } @@ -200,7 +200,7 @@ AcpiLoadTables (void) Status = AcpiNsLoadNamespace (); if (ACPI_FAILURE (Status)) { - REPORT_ERROR (("AcpiLoadTables: Could not load namespace: %s\n", + ACPI_REPORT_ERROR (("AcpiLoadTables: Could not load namespace: %s\n", AcpiFormatException (Status))); goto ErrorExit; } @@ -209,7 +209,7 @@ AcpiLoadTables (void) ErrorExit: - REPORT_ERROR (("AcpiLoadTables: Could not load tables: %s\n", + ACPI_REPORT_ERROR (("AcpiLoadTables: Could not load tables: %s\n", AcpiFormatException (Status))); return_ACPI_STATUS (Status); @@ -240,7 +240,7 @@ AcpiLoadTable ( ACPI_TABLE_DESC TableInfo; - FUNCTION_TRACE ("AcpiLoadTable"); + ACPI_FUNCTION_TRACE ("AcpiLoadTable"); if (!TablePtr) @@ -267,17 +267,34 @@ AcpiLoadTable ( return_ACPI_STATUS (Status); } + /* Convert the table to common format if necessary */ + + switch (TableInfo.Type) + { + case ACPI_TABLE_FADT: + + Status = AcpiTbConvertTableFadt (); + break; + + case ACPI_TABLE_FACS: + + Status = AcpiTbBuildCommonFacs (&TableInfo); + break; + + default: + /* Load table into namespace if it contains executable AML */ + + Status = AcpiNsLoadTable (TableInfo.InstalledDesc, AcpiGbl_RootNode); + break; + } - Status = AcpiNsLoadTable (TableInfo.InstalledDesc, AcpiGbl_RootNode); if (ACPI_FAILURE (Status)) { /* Uninstall table and free the buffer */ AcpiTbUninstallTable (TableInfo.InstalledDesc); - return_ACPI_STATUS (Status); } - return_ACPI_STATUS (Status); } @@ -301,7 +318,7 @@ AcpiUnloadTable ( ACPI_TABLE_DESC *ListHead; - FUNCTION_TRACE ("AcpiUnloadTable"); + ACPI_FUNCTION_TRACE ("AcpiUnloadTable"); /* Parameter validation */ @@ -366,7 +383,7 @@ AcpiGetTableHeader ( ACPI_STATUS Status; - FUNCTION_TRACE ("AcpiGetTableHeader"); + ACPI_FUNCTION_TRACE ("AcpiGetTableHeader"); if ((Instance == 0) || @@ -379,7 +396,7 @@ AcpiGetTableHeader ( /* Check the table type and instance */ if ((TableType > ACPI_TABLE_MAX) || - (IS_SINGLE_TABLE (AcpiGbl_AcpiTableData[TableType].Flags) && + (ACPI_IS_SINGLE_TABLE (AcpiGbl_AcpiTableData[TableType].Flags) && Instance > 1)) { return_ACPI_STATUS (AE_BAD_PARAMETER); @@ -405,7 +422,7 @@ AcpiGetTableHeader ( /* * Copy the header to the caller's buffer */ - MEMCPY ((void *) OutTableHeader, (void *) TblPtr, + ACPI_MEMCPY ((void *) OutTableHeader, (void *) TblPtr, sizeof (ACPI_TABLE_HEADER)); return_ACPI_STATUS (Status); @@ -443,26 +460,29 @@ AcpiGetTable ( { ACPI_TABLE_HEADER *TblPtr; ACPI_STATUS Status; - UINT32 RetBufLen; + UINT32 TableLength; - FUNCTION_TRACE ("AcpiGetTable"); + ACPI_FUNCTION_TRACE ("AcpiGetTable"); - /* - * If we have a buffer, we must have a length too - */ - if ((Instance == 0) || - (!RetBuffer) || - ((!RetBuffer->Pointer) && (RetBuffer->Length))) + /* Parameter validation */ + + if (Instance == 0) { return_ACPI_STATUS (AE_BAD_PARAMETER); } + Status = AcpiUtValidateBuffer (RetBuffer); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + /* Check the table type and instance */ if ((TableType > ACPI_TABLE_MAX) || - (IS_SINGLE_TABLE (AcpiGbl_AcpiTableData[TableType].Flags) && + (ACPI_IS_SINGLE_TABLE (AcpiGbl_AcpiTableData[TableType].Flags) && Instance > 1)) { return_ACPI_STATUS (AE_BAD_PARAMETER); @@ -486,34 +506,31 @@ AcpiGetTable ( return_ACPI_STATUS (AE_NOT_EXIST); } - /* - * Got a table ptr, assume it's ok and copy it to the user's buffer - */ + /* Get the table length */ + if (TableType == ACPI_TABLE_RSDP) { /* * RSD PTR is the only "table" without a header */ - RetBufLen = sizeof (RSDP_DESCRIPTOR); + TableLength = sizeof (RSDP_DESCRIPTOR); } else { - RetBufLen = TblPtr->Length; + TableLength = TblPtr->Length; } - /* - * Verify we have space in the caller's buffer for the table - */ - if (RetBuffer->Length < RetBufLen) + /* Validate/Allocate/Clear caller buffer */ + + Status = AcpiUtInitializeBuffer (RetBuffer, TableLength); + if (ACPI_FAILURE (Status)) { - RetBuffer->Length = RetBufLen; - return_ACPI_STATUS (AE_BUFFER_OVERFLOW); + return_ACPI_STATUS (Status); } - RetBuffer->Length = RetBufLen; - - MEMCPY ((void *) RetBuffer->Pointer, (void *) TblPtr, RetBufLen); + /* Copy the table to the buffer */ + ACPI_MEMCPY ((void *) RetBuffer->Pointer, (void *) TblPtr, TableLength); return_ACPI_STATUS (AE_OK); } -- cgit v1.1