summaryrefslogtreecommitdiffstats
path: root/sys/contrib/dev/acpica/dmresrc.c
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2005-11-01 22:11:18 +0000
committerjkim <jkim@FreeBSD.org>2005-11-01 22:11:18 +0000
commit5f6a2493ddea1cf36a4dcd58b865c4148427e0a2 (patch)
tree4450b2c84d749dd8a8425a8feb88b084809f6ef0 /sys/contrib/dev/acpica/dmresrc.c
parent50133a977cb75b3f52603d4b351a8cf45bb556c8 (diff)
downloadFreeBSD-src-5f6a2493ddea1cf36a4dcd58b865c4148427e0a2.zip
FreeBSD-src-5f6a2493ddea1cf36a4dcd58b865c4148427e0a2.tar.gz
Vendor import of Intel ACPI-CA 20051021
Diffstat (limited to 'sys/contrib/dev/acpica/dmresrc.c')
-rw-r--r--sys/contrib/dev/acpica/dmresrc.c438
1 files changed, 226 insertions, 212 deletions
diff --git a/sys/contrib/dev/acpica/dmresrc.c b/sys/contrib/dev/acpica/dmresrc.c
index ca4dec3..1bbea38 100644
--- a/sys/contrib/dev/acpica/dmresrc.c
+++ b/sys/contrib/dev/acpica/dmresrc.c
@@ -1,7 +1,7 @@
/*******************************************************************************
*
* Module Name: dmresrc.c - Resource Descriptor disassembly
- * $Revision: 13 $
+ * $Revision: 1.26 $
*
******************************************************************************/
@@ -9,7 +9,7 @@
*
* 1. Copyright Notice
*
- * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp.
+ * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
* All rights reserved.
*
* 2. License
@@ -125,6 +125,150 @@
ACPI_MODULE_NAME ("dbresrc")
+/* Dispatch tables for Resource disassembly functions */
+
+typedef
+void (*ACPI_RESOURCE_HANDLER) (
+ AML_RESOURCE *Resource,
+ UINT32 Length,
+ UINT32 Level);
+
+static ACPI_RESOURCE_HANDLER AcpiGbl_SmResourceDispatch [] =
+{
+ NULL, /* 0x00, Reserved */
+ NULL, /* 0x01, Reserved */
+ NULL, /* 0x02, Reserved */
+ NULL, /* 0x03, Reserved */
+ AcpiDmIrqDescriptor, /* 0x04, ACPI_RESOURCE_NAME_IRQ_FORMAT */
+ AcpiDmDmaDescriptor, /* 0x05, ACPI_RESOURCE_NAME_DMA_FORMAT */
+ AcpiDmStartDependentDescriptor, /* 0x06, ACPI_RESOURCE_NAME_START_DEPENDENT */
+ AcpiDmEndDependentDescriptor, /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */
+ AcpiDmIoDescriptor, /* 0x08, ACPI_RESOURCE_NAME_IO_PORT */
+ AcpiDmFixedIoDescriptor, /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO_PORT */
+ NULL, /* 0x0A, Reserved */
+ NULL, /* 0x0B, Reserved */
+ NULL, /* 0x0C, Reserved */
+ NULL, /* 0x0D, Reserved */
+ AcpiDmVendorSmallDescriptor, /* 0x0E, ACPI_RESOURCE_NAME_SMALL_VENDOR */
+ NULL /* 0x0F, ACPI_RESOURCE_NAME_END_TAG (not used) */
+};
+
+static ACPI_RESOURCE_HANDLER AcpiGbl_LgResourceDispatch [] =
+{
+ NULL, /* 0x00, Reserved */
+ AcpiDmMemory24Descriptor, /* 0x01, ACPI_RESOURCE_NAME_MEMORY_24 */
+ AcpiDmGenericRegisterDescriptor,/* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */
+ NULL, /* 0x03, Reserved */
+ AcpiDmVendorLargeDescriptor, /* 0x04, ACPI_RESOURCE_NAME_LARGE_VENDOR */
+ AcpiDmMemory32Descriptor, /* 0x05, ACPI_RESOURCE_NAME_MEMORY_32 */
+ AcpiDmFixedMemory32Descriptor, /* 0x06, ACPI_RESOURCE_NAME_FIXED_MEMORY_32 */
+ AcpiDmDwordDescriptor, /* 0x07, ACPI_RESOURCE_NAME_DWORD_ADDRESS_SPACE */
+ AcpiDmWordDescriptor, /* 0x08, ACPI_RESOURCE_NAME_WORD_ADDRESS_SPACE */
+ AcpiDmInterruptDescriptor, /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_XRUPT */
+ AcpiDmQwordDescriptor, /* 0x0A, ACPI_RESOURCE_NAME_QWORD_ADDRESS_SPACE */
+ AcpiDmExtendedDescriptor /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS_SPACE */
+};
+
+
+/* Local prototypes */
+
+static ACPI_RESOURCE_HANDLER
+AcpiDmGetResourceHandler (
+ UINT8 ResourceType);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmDumpInteger*
+ *
+ * PARAMETERS: Value - Value to emit
+ * Name - Associated name (emitted as a comment)
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Integer output helper functions
+ *
+ ******************************************************************************/
+
+void
+AcpiDmDumpInteger8 (
+ UINT8 Value,
+ char *Name)
+{
+ AcpiOsPrintf ("0x%2.2X, // %s\n", Value, Name);
+}
+
+void
+AcpiDmDumpInteger16 (
+ UINT16 Value,
+ char *Name)
+{
+ AcpiOsPrintf ("0x%4.4X, // %s\n", Value, Name);
+}
+
+void
+AcpiDmDumpInteger32 (
+ UINT32 Value,
+ char *Name)
+{
+ AcpiOsPrintf ("0x%8.8X, // %s\n", Value, Name);
+}
+
+void
+AcpiDmDumpInteger64 (
+ UINT64 Value,
+ char *Name)
+{
+ AcpiOsPrintf ("0x%8.8X%8.8X, // %s\n",
+ ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Value)), Name);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmGetResourceHandler
+ *
+ * PARAMETERS: ResourceType - Byte 0 of a resource descriptor
+ *
+ * RETURN: Pointer to the resource conversion handler. NULL is returned
+ * if the ResourceType is invalid.
+ *
+ * DESCRIPTION: Return the handler associated with this resource type.
+ * May also be used to validate a ResourceType.
+ *
+ ******************************************************************************/
+
+static ACPI_RESOURCE_HANDLER
+AcpiDmGetResourceHandler (
+ UINT8 ResourceType)
+{
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Determine if this is a small or large resource */
+
+ if (ResourceType & ACPI_RESOURCE_NAME_LARGE)
+ {
+ /* Large Resource Type -- bits 6:0 contain the name */
+
+ if (ResourceType > ACPI_RESOURCE_NAME_LARGE_MAX)
+ {
+ return (NULL);
+ }
+
+ return (AcpiGbl_LgResourceDispatch [
+ (ResourceType & ACPI_RESOURCE_NAME_LARGE_MASK)]);
+ }
+ else
+ {
+ /* Small Resource Type -- bits 6:3 contain the name */
+
+ return (AcpiGbl_SmResourceDispatch [
+ ((ResourceType & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3)]);
+ }
+}
+
+
/*******************************************************************************
*
* FUNCTION: AcpiDmBitList
@@ -148,7 +292,7 @@ AcpiDmBitList (
/* Open the initializer list */
- AcpiOsPrintf (") {");
+ AcpiOsPrintf ("{");
/* Examine each bit */
@@ -177,7 +321,7 @@ AcpiDmBitList (
/*******************************************************************************
*
- * FUNCTION: AcpiDmResourceDescriptor
+ * FUNCTION: AcpiDmResourceTemplate
*
* PARAMETERS: Info - Curent parse tree walk info
* ByteData - Pointer to the byte list data
@@ -185,67 +329,46 @@ AcpiDmBitList (
*
* RETURN: None
*
- * DESCRIPTION: Dump the contents of one ResourceTemplate descriptor.
+ * DESCRIPTION: Dump the contents of a Resource Template containing a set of
+ * Resource Descriptors.
*
******************************************************************************/
void
-AcpiDmResourceDescriptor (
+AcpiDmResourceTemplate (
ACPI_OP_WALK_INFO *Info,
UINT8 *ByteData,
UINT32 ByteCount)
{
ACPI_NATIVE_UINT CurrentByteOffset;
- UINT8 CurrentByte;
- UINT8 DescriptorId;
- UINT32 Length;
+ UINT8 ResourceType;
+ UINT32 ResourceLength;
void *DescriptorBody;
UINT32 Level;
BOOLEAN DependentFns = FALSE;
+ ACPI_RESOURCE_HANDLER Handler;
Level = Info->Level;
for (CurrentByteOffset = 0; CurrentByteOffset < ByteCount; )
{
- CurrentByte = ByteData[CurrentByteOffset];
- DescriptorBody = &ByteData[CurrentByteOffset];
-
- if (CurrentByte & ACPI_RDESC_TYPE_LARGE)
- {
- DescriptorId = CurrentByte;
- Length = (* (ACPI_CAST_PTR (UINT16, &ByteData[CurrentByteOffset + 1])));
- CurrentByteOffset += 3;
- }
- else
- {
- DescriptorId = (UINT8) (CurrentByte & 0xF8);
- Length = (ByteData[CurrentByteOffset] & 0x7);
- CurrentByteOffset += 1;
- }
-
- CurrentByteOffset += (ACPI_NATIVE_UINT) Length;
+ /* Get the descriptor type and length */
- /* Determine type of resource */
-
- switch (DescriptorId)
- {
- /*
- * "Small" type descriptors
- */
- case ACPI_RDESC_TYPE_IRQ_FORMAT:
-
- AcpiDmIrqDescriptor (DescriptorBody, Length, Level);
- break;
+ DescriptorBody = &ByteData[CurrentByteOffset];
+ ResourceType = AcpiUtGetResourceType (DescriptorBody);
+ ResourceLength = AcpiUtGetResourceLength (DescriptorBody);
- case ACPI_RDESC_TYPE_DMA_FORMAT:
+ /* Point to next descriptor */
- AcpiDmDmaDescriptor (DescriptorBody, Length, Level);
- break;
+ CurrentByteOffset += AcpiUtGetDescriptorLength (DescriptorBody);
+ /* Descriptor pre-processing */
- case ACPI_RDESC_TYPE_START_DEPENDENT:
+ switch (ResourceType)
+ {
+ case ACPI_RESOURCE_NAME_START_DEPENDENT:
/* Finish a previous StartDependentFns */
@@ -255,139 +378,75 @@ AcpiDmResourceDescriptor (
AcpiDmIndent (Level);
AcpiOsPrintf ("}\n");
}
-
- AcpiDmStartDependentDescriptor (DescriptorBody, Length, Level);
- DependentFns = TRUE;
- Level++;
break;
-
- case ACPI_RDESC_TYPE_END_DEPENDENT:
+ case ACPI_RESOURCE_NAME_END_DEPENDENT:
Level--;
DependentFns = FALSE;
- AcpiDmEndDependentDescriptor (DescriptorBody, Length, Level);
- break;
-
-
- case ACPI_RDESC_TYPE_IO_PORT:
-
- AcpiDmIoDescriptor (DescriptorBody, Length, Level);
- break;
-
-
- case ACPI_RDESC_TYPE_FIXED_IO_PORT:
-
- AcpiDmFixedIoDescriptor (DescriptorBody, Length, Level);
- break;
-
-
- case ACPI_RDESC_TYPE_SMALL_VENDOR:
-
- AcpiDmVendorSmallDescriptor (DescriptorBody, Length, Level);
break;
+ case ACPI_RESOURCE_NAME_END_TAG:
- case ACPI_RDESC_TYPE_END_TAG:
+ /* Normal exit, the resource list is finished */
if (DependentFns)
{
/*
- * Close an open StartDependentDescriptor. This indicates a missing
- * EndDependentDescriptor.
+ * Close an open StartDependentDescriptor. This indicates a
+ * missing EndDependentDescriptor.
*/
Level--;
DependentFns = FALSE;
- AcpiDmIndent (Level);
- AcpiOsPrintf ("}\n");
- AcpiDmIndent (Level);
- AcpiOsPrintf ("/*** Missing EndDependentFunctions descriptor */");
+ /* Go ahead and insert EndDependentFn() */
- /*
- * We could fix the problem, but then the ASL would not match the AML
- * So, we don't do this:
- * AcpiDmEndDependentDescriptor (DescriptorBody, Length, Level);
- */
+ AcpiDmEndDependentDescriptor (DescriptorBody, ResourceLength, Level);
+
+ AcpiDmIndent (Level);
+ AcpiOsPrintf (
+ "/*** Disassembler: inserted missing EndDependentFn () ***/\n");
}
return;
-
- /*
- * "Large" type descriptors
- */
- case ACPI_RDESC_TYPE_MEMORY_24:
-
- AcpiDmMemory24Descriptor (DescriptorBody, Length, Level);
- break;
-
-
- case ACPI_RDESC_TYPE_GENERAL_REGISTER:
-
- AcpiDmGenericRegisterDescriptor (DescriptorBody, Length, Level);
- break;
-
-
- case ACPI_RDESC_TYPE_LARGE_VENDOR:
-
- AcpiDmVendorLargeDescriptor (DescriptorBody, Length, Level);
- break;
-
-
- case ACPI_RDESC_TYPE_MEMORY_32:
-
- AcpiDmMemory32Descriptor (DescriptorBody, Length, Level);
- break;
-
-
- case ACPI_RDESC_TYPE_FIXED_MEMORY_32:
-
- AcpiDmFixedMem32Descriptor (DescriptorBody, Length, Level);
- break;
-
-
- case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE:
-
- AcpiDmDwordDescriptor (DescriptorBody, Length, Level);
- break;
-
-
- case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE:
-
- AcpiDmWordDescriptor (DescriptorBody, Length, Level);
- break;
-
-
- case ACPI_RDESC_TYPE_EXTENDED_XRUPT:
-
- AcpiDmInterruptDescriptor (DescriptorBody, Length, Level);
- break;
-
-
- case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE:
-
- AcpiDmQwordDescriptor (DescriptorBody, Length, Level);
+ default:
break;
+ }
+ /* Get the handler associated with this Descriptor Type */
- default:
+ Handler = AcpiDmGetResourceHandler (ResourceType);
+ if (!Handler)
+ {
/*
- * Anything else is unrecognized.
+ * Invalid Descriptor Type.
*
- * Since the entire resource buffer has been already walked and
+ * Since the entire resource buffer has been previously walked and
* validated, this is a very serious error indicating that someone
* overwrote the buffer.
*/
- AcpiOsPrintf ("/* Unknown Resource type (%X) */\n", DescriptorId);
+ AcpiOsPrintf ("/*** Unknown Resource type (%X) ***/\n", ResourceType);
return;
}
+
+ /* Disassemble the resource structure */
+
+ Handler (DescriptorBody, ResourceLength, Level);
+
+ /* Descriptor post-processing */
+
+ if (ResourceType == ACPI_RESOURCE_NAME_START_DEPENDENT)
+ {
+ DependentFns = TRUE;
+ Level++;
+ }
}
}
/*******************************************************************************
*
- * FUNCTION: AcpiDmIsResourceDescriptor
+ * FUNCTION: AcpiDmIsResourceTemplate
*
* PARAMETERS: Op - Buffer Op to be examined
*
@@ -400,16 +459,15 @@ AcpiDmResourceDescriptor (
******************************************************************************/
BOOLEAN
-AcpiDmIsResourceDescriptor (
+AcpiDmIsResourceTemplate (
ACPI_PARSE_OBJECT *Op)
{
UINT8 *ByteData;
UINT32 ByteCount;
ACPI_PARSE_OBJECT *NextOp;
ACPI_NATIVE_UINT CurrentByteOffset;
- UINT8 CurrentByte;
- UINT8 DescriptorId;
- UINT32 Length;
+ UINT8 ResourceType;
+ void *DescriptorBody;
/* This op must be a buffer */
@@ -433,96 +491,53 @@ AcpiDmIsResourceDescriptor (
ByteCount = (UINT32) NextOp->Common.Value.Integer;
ByteData = NextOp->Named.Data;
- /* Absolute minimum descriptor is an END_TAG (2 bytes) */
-
- if (ByteCount < 2)
+ /*
+ * The absolute minimum resource template is an END_TAG (2 bytes),
+ * and the list must be terminated by a valid 2-byte END_TAG
+ */
+ if ((ByteCount < 2) ||
+ (ByteData[ByteCount - 2] != (ACPI_RESOURCE_NAME_END_TAG | 1)))
{
return (FALSE);
}
- /* The list must have a valid 2-byte END_TAG */
+ /* Walk the byte list, abort on any invalid descriptor ID or length */
- if (ByteData[ByteCount-2] != (ACPI_RDESC_TYPE_END_TAG | 1))
- {
- return FALSE;
- }
-
- /*
- * Walk the byte list. Abort on any invalid descriptor ID or
- * or length
- */
for (CurrentByteOffset = 0; CurrentByteOffset < ByteCount;)
{
- CurrentByte = ByteData[CurrentByteOffset];
+ /* Get the descriptor type and length */
- /* Large or small resource? */
+ DescriptorBody = &ByteData[CurrentByteOffset];
+ ResourceType = AcpiUtGetResourceType (DescriptorBody);
- if (CurrentByte & ACPI_RDESC_TYPE_LARGE)
- {
- DescriptorId = CurrentByte;
- Length = (* (ACPI_CAST_PTR (UINT16, (&ByteData[CurrentByteOffset + 1]))));
- CurrentByteOffset += 3;
- }
- else
- {
- DescriptorId = (UINT8) (CurrentByte & 0xF8);
- Length = (ByteData[CurrentByteOffset] & 0x7);
- CurrentByteOffset += 1;
- }
+ /* Point to next descriptor */
- CurrentByteOffset += (ACPI_NATIVE_UINT) Length;
+ CurrentByteOffset += AcpiUtGetDescriptorLength (DescriptorBody);
- /* Determine type of resource */
+ /* END_TAG terminates the descriptor list */
- switch (DescriptorId)
+ if (ResourceType == ACPI_RESOURCE_NAME_END_TAG)
{
- /*
- * "Small" type descriptors
- */
- case ACPI_RDESC_TYPE_IRQ_FORMAT:
- case ACPI_RDESC_TYPE_DMA_FORMAT:
- case ACPI_RDESC_TYPE_START_DEPENDENT:
- case ACPI_RDESC_TYPE_END_DEPENDENT:
- case ACPI_RDESC_TYPE_IO_PORT:
- case ACPI_RDESC_TYPE_FIXED_IO_PORT:
- case ACPI_RDESC_TYPE_SMALL_VENDOR:
-
- /*
- * "Large" type descriptors
- */
- case ACPI_RDESC_TYPE_MEMORY_24:
- case ACPI_RDESC_TYPE_GENERAL_REGISTER:
- case ACPI_RDESC_TYPE_LARGE_VENDOR:
- case ACPI_RDESC_TYPE_MEMORY_32:
- case ACPI_RDESC_TYPE_FIXED_MEMORY_32:
- case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE:
- case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE:
- case ACPI_RDESC_TYPE_EXTENDED_XRUPT:
- case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE:
-
- /* Valid descriptor ID, keep going */
-
- break;
-
-
- case ACPI_RDESC_TYPE_END_TAG:
-
- /* We must be at the end of the ByteList */
-
+ /*
+ * For the resource template to be valid, one END_TAG must appear
+ * at the very end of the ByteList, not before
+ */
if (CurrentByteOffset != ByteCount)
{
return (FALSE);
}
- /* All descriptors/lengths valid, this is a valid descriptor */
-
+ /*
+ * All resource descriptor types and lengths are valid,
+ * this list appears to be a valid resource template
+ */
return (TRUE);
+ }
+ /* Validate the resource name (must be after check for END_TAG) */
- default:
-
- /* Bad descriptor, abort */
-
+ if (!AcpiDmGetResourceHandler (ResourceType))
+ {
return (FALSE);
}
}
@@ -532,5 +547,4 @@ AcpiDmIsResourceDescriptor (
return (FALSE);
}
-
#endif
OpenPOWER on IntegriCloud