summaryrefslogtreecommitdiffstats
path: root/sys/contrib/dev/acpica/exnames.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/exnames.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/exnames.c')
-rw-r--r--sys/contrib/dev/acpica/exnames.c87
1 files changed, 58 insertions, 29 deletions
diff --git a/sys/contrib/dev/acpica/exnames.c b/sys/contrib/dev/acpica/exnames.c
index 0f096d7..e45bcb3 100644
--- a/sys/contrib/dev/acpica/exnames.c
+++ b/sys/contrib/dev/acpica/exnames.c
@@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: exnames - interpreter/scanner name load/execute
- * $Revision: 95 $
+ * $Revision: 1.103 $
*
*****************************************************************************/
@@ -10,7 +10,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
@@ -124,13 +124,17 @@
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exnames")
+/* Local prototypes */
-/* AML Package Length encodings */
+static char *
+AcpiExAllocateNameString (
+ UINT32 PrefixCount,
+ UINT32 NumNameSegs);
-#define ACPI_AML_PACKAGE_TYPE1 0x40
-#define ACPI_AML_PACKAGE_TYPE2 0x4000
-#define ACPI_AML_PACKAGE_TYPE3 0x400000
-#define ACPI_AML_PACKAGE_TYPE4 0x40000000
+static ACPI_STATUS
+AcpiExNameSegment (
+ UINT8 **InAmlAddress,
+ char *NameString);
/*******************************************************************************
@@ -138,7 +142,7 @@
* FUNCTION: AcpiExAllocateNameString
*
* PARAMETERS: PrefixCount - Count of parent levels. Special cases:
- * (-1) = root, 0 = none
+ * (-1)==root, 0==none
* NumNameSegs - count of 4-character name segments
*
* RETURN: A pointer to the allocated string segment. This segment must
@@ -149,7 +153,7 @@
*
******************************************************************************/
-char *
+static char *
AcpiExAllocateNameString (
UINT32 PrefixCount,
UINT32 NumNameSegs)
@@ -162,7 +166,7 @@ AcpiExAllocateNameString (
/*
- * Allow room for all \ and ^ prefixes, all segments, and a MultiNamePrefix.
+ * Allow room for all \ and ^ prefixes, all segments and a MultiNamePrefix.
* Also, one byte for the null terminator.
* This may actually be somewhat longer than needed.
*/
@@ -184,7 +188,8 @@ AcpiExAllocateNameString (
NameString = ACPI_MEM_ALLOCATE (SizeNeeded);
if (!NameString)
{
- ACPI_REPORT_ERROR (("ExAllocateNameString: Could not allocate size %d\n", SizeNeeded));
+ ACPI_REPORT_ERROR ((
+ "ExAllocateNameString: Could not allocate size %d\n", SizeNeeded));
return_PTR (NULL);
}
@@ -234,15 +239,17 @@ AcpiExAllocateNameString (
*
* FUNCTION: AcpiExNameSegment
*
- * PARAMETERS: InterpreterMode - Current running mode (load1/Load2/Exec)
+ * PARAMETERS: InAmlAddress - Pointer to the name in the AML code
+ * NameString - Where to return the name. The name is appended
+ * to any existing string to form a namepath
*
* RETURN: Status
*
- * DESCRIPTION: Execute a name segment (4 bytes)
+ * DESCRIPTION: Extract an ACPI name (4 bytes) from the AML byte stream
*
******************************************************************************/
-ACPI_STATUS
+static ACPI_STATUS
AcpiExNameSegment (
UINT8 **InAmlAddress,
char *NameString)
@@ -291,12 +298,12 @@ AcpiExNameSegment (
{
ACPI_STRCAT (NameString, CharBuf);
ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
- "Appended to - %s \n", NameString));
+ "Appended to - %s\n", NameString));
}
else
{
ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
- "No Name string - %s \n", CharBuf));
+ "No Name string - %s\n", CharBuf));
}
}
else if (Index == 0)
@@ -312,10 +319,13 @@ AcpiExNameSegment (
}
else
{
- /* Segment started with one or more valid characters, but fewer than 4 */
-
+ /*
+ * Segment started with one or more valid characters, but fewer than
+ * the required 4
+ */
Status = AE_AML_BAD_NAME;
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Bad character %02x in name, at %p\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Bad character %02x in name, at %p\n",
*AmlAddress, AmlAddress));
}
@@ -328,11 +338,16 @@ AcpiExNameSegment (
*
* FUNCTION: AcpiExGetNameString
*
- * PARAMETERS: DataType - Data type to be associated with this name
+ * PARAMETERS: DataType - Object type to be associated with this
+ * name
+ * InAmlAddress - Pointer to the namestring in the AML code
+ * OutNameString - Where the namestring is returned
+ * OutNameLength - Length of the returned string
*
- * RETURN: Status
+ * RETURN: Status, namestring and length
*
- * DESCRIPTION: Get a name, including any prefixes.
+ * DESCRIPTION: Extract a full namepath from the AML byte stream,
+ * including any prefixes.
*
******************************************************************************/
@@ -380,7 +395,8 @@ AcpiExGetNameString (
{
case AML_ROOT_PREFIX:
- ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "RootPrefix(\\) at %p\n", AmlAddress));
+ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "RootPrefix(\\) at %p\n",
+ AmlAddress));
/*
* Remember that we have a RootPrefix --
@@ -398,7 +414,8 @@ AcpiExGetNameString (
do
{
- ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "ParentPrefix (^) at %p\n", AmlAddress));
+ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "ParentPrefix (^) at %p\n",
+ AmlAddress));
AmlAddress++;
PrefixCount++;
@@ -416,14 +433,14 @@ AcpiExGetNameString (
break;
}
-
/* Examine first character of name for name segment prefix operator */
switch (*AmlAddress)
{
case AML_DUAL_NAME_PREFIX:
- ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "DualNamePrefix at %p\n", AmlAddress));
+ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "DualNamePrefix at %p\n",
+ AmlAddress));
AmlAddress++;
NameString = AcpiExAllocateNameString (PrefixCount, 2);
@@ -447,7 +464,8 @@ AcpiExGetNameString (
case AML_MULTI_NAME_PREFIX_OP:
- ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "MultiNamePrefix at %p\n", AmlAddress));
+ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "MultiNamePrefix at %p\n",
+ AmlAddress));
/* Fetch count of segments remaining in name path */
@@ -467,7 +485,8 @@ AcpiExGetNameString (
HasPrefix = TRUE;
while (NumSegments &&
- (Status = AcpiExNameSegment (&AmlAddress, NameString)) == AE_OK)
+ (Status = AcpiExNameSegment (&AmlAddress, NameString)) ==
+ AE_OK)
{
NumSegments--;
}
@@ -481,7 +500,8 @@ AcpiExGetNameString (
if (PrefixCount == ACPI_UINT32_MAX)
{
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "NameSeg is \"\\\" followed by NULL\n"));
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "NameSeg is \"\\\" followed by NULL\n"));
}
/* Consume the NULL byte */
@@ -522,6 +542,15 @@ AcpiExGetNameString (
Status = AE_AML_BAD_NAME;
}
+ if (ACPI_FAILURE (Status))
+ {
+ if (NameString)
+ {
+ ACPI_MEM_FREE (NameString);
+ }
+ return_ACPI_STATUS (Status);
+ }
+
*OutNameString = NameString;
*OutNameLength = (UINT32) (AmlAddress - InAmlAddress);
OpenPOWER on IntegriCloud