summaryrefslogtreecommitdiffstats
path: root/sys/contrib/dev/acpica/tbxfroot.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/dev/acpica/tbxfroot.c')
-rw-r--r--sys/contrib/dev/acpica/tbxfroot.c475
1 files changed, 265 insertions, 210 deletions
diff --git a/sys/contrib/dev/acpica/tbxfroot.c b/sys/contrib/dev/acpica/tbxfroot.c
index e9a3e84..8a2e147 100644
--- a/sys/contrib/dev/acpica/tbxfroot.c
+++ b/sys/contrib/dev/acpica/tbxfroot.c
@@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: tbxfroot - Find the root ACPI table (RSDT)
- * $Revision: 52 $
+ * $Revision: 58 $
*
*****************************************************************************/
@@ -9,7 +9,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
@@ -117,236 +117,70 @@
#define __TBXFROOT_C__
#include "acpi.h"
-#include "achware.h"
#include "actables.h"
#define _COMPONENT ACPI_TABLES
- MODULE_NAME ("tbxfroot")
-
-#define RSDP_CHECKSUM_LENGTH 20
+ ACPI_MODULE_NAME ("tbxfroot")
/*******************************************************************************
*
- * FUNCTION: AcpiFindRootPointer
+ * FUNCTION: AcpiTbFindTable
*
- * PARAMETERS: **RsdpPhysicalAddress - Where to place the RSDP address
- * Flags - Logical/Physical addressing
+ * PARAMETERS: Signature - String with ACPI table signature
+ * OemId - String with the table OEM ID
+ * OemTableId - String with the OEM Table ID.
*
- * RETURN: Status, Physical address of the RSDP
+ * RETURN: Status
*
- * DESCRIPTION: Find the RSDP
+ * DESCRIPTION: Find an ACPI table (in the RSDT/XSDT) that matches the
+ * Signature, OEM ID and OEM Table ID.
*
******************************************************************************/
ACPI_STATUS
-AcpiFindRootPointer (
- UINT32 Flags,
- ACPI_PHYSICAL_ADDRESS *RsdpPhysicalAddress)
+AcpiTbFindTable (
+ NATIVE_CHAR *Signature,
+ NATIVE_CHAR *OemId,
+ NATIVE_CHAR *OemTableId,
+ ACPI_TABLE_HEADER **TablePtr)
{
- ACPI_TABLE_DESC TableInfo;
ACPI_STATUS Status;
+ ACPI_TABLE_HEADER *Table;
- FUNCTION_TRACE ("AcpiFindRootPointer");
-
-
- /* Get the RSDP */
-
- Status = AcpiTbFindRsdp (&TableInfo, Flags);
- if (ACPI_FAILURE (Status))
- {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "RSDP structure not found\n"));
- return_ACPI_STATUS (AE_NO_ACPI_TABLES);
- }
-
- *RsdpPhysicalAddress = TableInfo.PhysicalAddress;
-
- return_ACPI_STATUS (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbScanMemoryForRsdp
- *
- * PARAMETERS: StartAddress - Starting pointer for search
- * Length - Maximum length to search
- *
- * RETURN: Pointer to the RSDP if found, otherwise NULL.
- *
- * DESCRIPTION: Search a block of memory for the RSDP signature
- *
- ******************************************************************************/
-
-UINT8 *
-AcpiTbScanMemoryForRsdp (
- UINT8 *StartAddress,
- UINT32 Length)
-{
- UINT32 Offset;
- UINT8 *MemRover;
-
-
- FUNCTION_TRACE ("TbScanMemoryForRsdp");
+ ACPI_FUNCTION_TRACE ("TbFindTable");
- /* Search from given start addr for the requested length */
+ /* Validate string lengths */
- for (Offset = 0, MemRover = StartAddress;
- Offset < Length;
- Offset += RSDP_SCAN_STEP, MemRover += RSDP_SCAN_STEP)
+ if ((ACPI_STRLEN (Signature) > 4) ||
+ (ACPI_STRLEN (OemId) > 6) ||
+ (ACPI_STRLEN (OemTableId) > 8))
{
-
- /* The signature and checksum must both be correct */
-
- if (STRNCMP ((NATIVE_CHAR *) MemRover,
- RSDP_SIG, sizeof (RSDP_SIG)-1) == 0 &&
- AcpiTbChecksum (MemRover, RSDP_CHECKSUM_LENGTH) == 0)
- {
- /* If so, we have found the RSDP */
-
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
- "RSDP located at physical address %p\n",MemRover));
- return_PTR (MemRover);
- }
+ return_ACPI_STATUS (AE_AML_STRING_LIMIT);
}
- /* Searched entire block, no RSDP was found */
-
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO,"Searched entire block, no RSDP was found.\n"));
-
- return_PTR (NULL);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiTbFindRsdp
- *
- * PARAMETERS: *TableInfo - Where the table info is returned
- * Flags - Current memory mode (logical vs.
- * physical addressing)
- *
- * RETURN: Status
- *
- * DESCRIPTION: Search lower 1Mbyte of memory for the root system descriptor
- * pointer structure. If it is found, set *RSDP to point to it.
- *
- * NOTE: The RSDP must be either in the first 1K of the Extended
- * BIOS Data Area or between E0000 and FFFFF (ACPI 1.0 section
- * 5.2.2; assertion #421).
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiTbFindRsdp (
- ACPI_TABLE_DESC *TableInfo,
- UINT32 Flags)
-{
- UINT8 *TablePtr;
- UINT8 *MemRover;
- UINT64 PhysAddr;
- ACPI_STATUS Status = AE_OK;
-
-
- FUNCTION_TRACE ("TbFindRsdp");
-
+ /* Find the table */
- /*
- * Scan supports either 1) Logical addressing or 2) Physical addressing
- */
- if ((Flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING)
+ Status = AcpiGetFirmwareTable (Signature, 1,
+ ACPI_LOGICAL_ADDRESSING, &Table);
+ if (ACPI_FAILURE (Status))
{
- /*
- * 1) Search EBDA (low memory) paragraphs
- */
- Status = AcpiOsMapMemory (LO_RSDP_WINDOW_BASE, LO_RSDP_WINDOW_SIZE,
- (void **) &TablePtr);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- MemRover = AcpiTbScanMemoryForRsdp (TablePtr, LO_RSDP_WINDOW_SIZE);
- AcpiOsUnmapMemory (TablePtr, LO_RSDP_WINDOW_SIZE);
-
- if (MemRover)
- {
- /* Found it, return the physical address */
-
- PhysAddr = LO_RSDP_WINDOW_BASE;
- PhysAddr += (MemRover - TablePtr);
-
- TableInfo->PhysicalAddress = PhysAddr;
-
- return_ACPI_STATUS (AE_OK);
- }
-
- /*
- * 2) Search upper memory: 16-byte boundaries in E0000h-F0000h
- */
- Status = AcpiOsMapMemory (HI_RSDP_WINDOW_BASE, HI_RSDP_WINDOW_SIZE,
- (void **) &TablePtr);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- MemRover = AcpiTbScanMemoryForRsdp (TablePtr, HI_RSDP_WINDOW_SIZE);
- AcpiOsUnmapMemory (TablePtr, HI_RSDP_WINDOW_SIZE);
-
- if (MemRover)
- {
- /* Found it, return the physical address */
-
- PhysAddr = HI_RSDP_WINDOW_BASE;
- PhysAddr += (MemRover - TablePtr);
-
- TableInfo->PhysicalAddress = PhysAddr;
-
- return_ACPI_STATUS (AE_OK);
- }
+ return_ACPI_STATUS (Status);
}
+ /* Check OemId and OemTableId */
- /*
- * Physical addressing
- */
- else
+ if ((OemId[0] && ACPI_STRCMP (OemId, Table->OemId)) ||
+ (OemTableId[0] && ACPI_STRCMP (OemTableId, Table->OemTableId)))
{
- /*
- * 1) Search EBDA (low memory) paragraphs
- */
- MemRover = AcpiTbScanMemoryForRsdp ((UINT8 *) LO_RSDP_WINDOW_BASE,
- LO_RSDP_WINDOW_SIZE);
- if (MemRover)
- {
- /* Found it, return the physical address */
-
- TableInfo->PhysicalAddress = (ACPI_TBLPTR) MemRover;
- return_ACPI_STATUS (AE_OK);
- }
-
- /*
- * 2) Search upper memory: 16-byte boundaries in E0000h-F0000h
- */
- MemRover = AcpiTbScanMemoryForRsdp ((UINT8 *) HI_RSDP_WINDOW_BASE,
- HI_RSDP_WINDOW_SIZE);
- if (MemRover)
- {
- /* Found it, return the physical address */
-
- TableInfo->PhysicalAddress = (ACPI_TBLPTR) MemRover;
- return_ACPI_STATUS (AE_OK);
- }
+ return_ACPI_STATUS (AE_AML_NAME_NOT_FOUND);
}
-
- /* RSDP signature was not found */
-
- return_ACPI_STATUS (AE_NOT_FOUND);
+ *TablePtr = Table;
+ return_ACPI_STATUS (AE_OK);
}
@@ -390,7 +224,7 @@ AcpiGetFirmwareTable (
UINT32 j;
- FUNCTION_TRACE ("AcpiGetFirmwareTable");
+ ACPI_FUNCTION_TRACE ("AcpiGetFirmwareTable");
/*
@@ -432,13 +266,13 @@ AcpiGetFirmwareTable (
}
else
{
- AcpiGbl_RSDP = (void *) (NATIVE_UINT) PhysicalAddress;
+ AcpiGbl_RSDP = ACPI_PHYSADDR_TO_PTR (PhysicalAddress);
}
/*
* The signature and checksum must both be correct
*/
- if (STRNCMP ((NATIVE_CHAR *) AcpiGbl_RSDP, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0)
+ if (ACPI_STRNCMP ((NATIVE_CHAR *) AcpiGbl_RSDP, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0)
{
/* Nope, BAD Signature */
@@ -446,7 +280,7 @@ AcpiGetFirmwareTable (
goto Cleanup;
}
- if (AcpiTbChecksum (AcpiGbl_RSDP, RSDP_CHECKSUM_LENGTH) != 0)
+ if (AcpiTbChecksum (AcpiGbl_RSDP, ACPI_RSDP_CHECKSUM_LENGTH) != 0)
{
/* Nope, BAD Checksum */
@@ -455,12 +289,11 @@ AcpiGetFirmwareTable (
}
}
-
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"RSDP located at %p, RSDT physical=%8.8X%8.8X \n",
- AcpiGbl_RSDP, HIDWORD(AcpiGbl_RSDP->RsdtPhysicalAddress),
- LODWORD(AcpiGbl_RSDP->RsdtPhysicalAddress)));
-
+ AcpiGbl_RSDP,
+ ACPI_HIDWORD (AcpiGbl_RSDP->RsdtPhysicalAddress),
+ ACPI_LODWORD (AcpiGbl_RSDP->RsdtPhysicalAddress)));
/* Get the RSDT and validate it */
@@ -477,7 +310,6 @@ AcpiGetFirmwareTable (
goto Cleanup;
}
-
/* Get the number of table pointers within the RSDT */
TableCount = AcpiTbGetTableCount (AcpiGbl_RSDP, RsdtPtr);
@@ -493,7 +325,8 @@ AcpiGetFirmwareTable (
if (AcpiGbl_RSDP->Revision < 2)
{
- PhysicalAddress = ((RSDT_DESCRIPTOR *) RsdtPtr)->TableOffsetEntry[i];
+ PhysicalAddress = (ACPI_PHYSICAL_ADDRESS)
+ ((RSDT_DESCRIPTOR *) RsdtPtr)->TableOffsetEntry[i];
}
else
{
@@ -511,7 +344,7 @@ AcpiGetFirmwareTable (
/* Compare table signatures and table instance */
- if (!STRNCMP ((char *) TablePtr, Signature, STRLEN (Signature)))
+ if (!ACPI_STRNCMP ((char *) TablePtr, Signature, ACPI_STRLEN (Signature)))
{
/* An instance of the table was found */
@@ -548,3 +381,225 @@ Cleanup:
}
+/* TBD: Move to a new file */
+
+#ifndef _IA16
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiFindRootPointer
+ *
+ * PARAMETERS: **RsdpPhysicalAddress - Where to place the RSDP address
+ * Flags - Logical/Physical addressing
+ *
+ * RETURN: Status, Physical address of the RSDP
+ *
+ * DESCRIPTION: Find the RSDP
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiFindRootPointer (
+ UINT32 Flags,
+ ACPI_PHYSICAL_ADDRESS *RsdpPhysicalAddress)
+{
+ ACPI_TABLE_DESC TableInfo;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiFindRootPointer");
+
+
+ /* Get the RSDP */
+
+ Status = AcpiTbFindRsdp (&TableInfo, Flags);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "RSDP structure not found\n"));
+ return_ACPI_STATUS (AE_NO_ACPI_TABLES);
+ }
+
+ *RsdpPhysicalAddress = TableInfo.PhysicalAddress;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbScanMemoryForRsdp
+ *
+ * PARAMETERS: StartAddress - Starting pointer for search
+ * Length - Maximum length to search
+ *
+ * RETURN: Pointer to the RSDP if found, otherwise NULL.
+ *
+ * DESCRIPTION: Search a block of memory for the RSDP signature
+ *
+ ******************************************************************************/
+
+UINT8 *
+AcpiTbScanMemoryForRsdp (
+ UINT8 *StartAddress,
+ UINT32 Length)
+{
+ UINT32 Offset;
+ UINT8 *MemRover;
+
+
+ ACPI_FUNCTION_TRACE ("TbScanMemoryForRsdp");
+
+
+ /* Search from given start addr for the requested length */
+
+ for (Offset = 0, MemRover = StartAddress;
+ Offset < Length;
+ Offset += RSDP_SCAN_STEP, MemRover += RSDP_SCAN_STEP)
+ {
+
+ /* The signature and checksum must both be correct */
+
+ if (ACPI_STRNCMP ((NATIVE_CHAR *) MemRover,
+ RSDP_SIG, sizeof (RSDP_SIG)-1) == 0 &&
+ AcpiTbChecksum (MemRover, ACPI_RSDP_CHECKSUM_LENGTH) == 0)
+ {
+ /* If so, we have found the RSDP */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "RSDP located at physical address %p\n",MemRover));
+ return_PTR (MemRover);
+ }
+ }
+
+ /* Searched entire block, no RSDP was found */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,"Searched entire block, no RSDP was found.\n"));
+ return_PTR (NULL);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbFindRsdp
+ *
+ * PARAMETERS: *TableInfo - Where the table info is returned
+ * Flags - Current memory mode (logical vs.
+ * physical addressing)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Search lower 1Mbyte of memory for the root system descriptor
+ * pointer structure. If it is found, set *RSDP to point to it.
+ *
+ * NOTE: The RSDP must be either in the first 1K of the Extended
+ * BIOS Data Area or between E0000 and FFFFF (ACPI 1.0 section
+ * 5.2.2; assertion #421).
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiTbFindRsdp (
+ ACPI_TABLE_DESC *TableInfo,
+ UINT32 Flags)
+{
+ UINT8 *TablePtr;
+ UINT8 *MemRover;
+ UINT64 PhysAddr;
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE ("TbFindRsdp");
+
+
+ /*
+ * Scan supports either 1) Logical addressing or 2) Physical addressing
+ */
+ if ((Flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING)
+ {
+ /*
+ * 1) Search EBDA (low memory) paragraphs
+ */
+ Status = AcpiOsMapMemory ((UINT64) LO_RSDP_WINDOW_BASE, LO_RSDP_WINDOW_SIZE,
+ (void **) &TablePtr);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ MemRover = AcpiTbScanMemoryForRsdp (TablePtr, LO_RSDP_WINDOW_SIZE);
+ AcpiOsUnmapMemory (TablePtr, LO_RSDP_WINDOW_SIZE);
+
+ if (MemRover)
+ {
+ /* Found it, return the physical address */
+
+ PhysAddr = LO_RSDP_WINDOW_BASE;
+ PhysAddr += (MemRover - TablePtr);
+
+ TableInfo->PhysicalAddress = PhysAddr;
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /*
+ * 2) Search upper memory: 16-byte boundaries in E0000h-F0000h
+ */
+ Status = AcpiOsMapMemory ((UINT64) HI_RSDP_WINDOW_BASE, HI_RSDP_WINDOW_SIZE,
+ (void **) &TablePtr);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ MemRover = AcpiTbScanMemoryForRsdp (TablePtr, HI_RSDP_WINDOW_SIZE);
+ AcpiOsUnmapMemory (TablePtr, HI_RSDP_WINDOW_SIZE);
+
+ if (MemRover)
+ {
+ /* Found it, return the physical address */
+
+ PhysAddr = HI_RSDP_WINDOW_BASE;
+ PhysAddr += (MemRover - TablePtr);
+
+ TableInfo->PhysicalAddress = PhysAddr;
+ return_ACPI_STATUS (AE_OK);
+ }
+ }
+
+ /*
+ * Physical addressing
+ */
+ else
+ {
+ /*
+ * 1) Search EBDA (low memory) paragraphs
+ */
+ MemRover = AcpiTbScanMemoryForRsdp (ACPI_PHYSADDR_TO_PTR (LO_RSDP_WINDOW_BASE),
+ LO_RSDP_WINDOW_SIZE);
+ if (MemRover)
+ {
+ /* Found it, return the physical address */
+
+ TableInfo->PhysicalAddress = ACPI_TO_INTEGER (MemRover);
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /*
+ * 2) Search upper memory: 16-byte boundaries in E0000h-F0000h
+ */
+ MemRover = AcpiTbScanMemoryForRsdp (ACPI_PHYSADDR_TO_PTR (HI_RSDP_WINDOW_BASE),
+ HI_RSDP_WINDOW_SIZE);
+ if (MemRover)
+ {
+ /* Found it, return the physical address */
+
+ TableInfo->PhysicalAddress = ACPI_TO_INTEGER (MemRover);
+ return_ACPI_STATUS (AE_OK);
+ }
+ }
+
+ /* RSDP signature was not found */
+
+ return_ACPI_STATUS (AE_NOT_FOUND);
+}
+
+#endif
+
OpenPOWER on IntegriCloud