aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/dev/acpica/exconvrt.c
diff options
context:
space:
mode:
authorMitsuru IWASAKI <iwasaki@FreeBSD.org>2002-07-09 17:51:31 +0000
committerMitsuru IWASAKI <iwasaki@FreeBSD.org>2002-07-09 17:51:31 +0000
commit7174287062b13041257019f445469f00eaaf9c76 (patch)
treeea70a54a7d2f53270d0147b285a5fa912b760051 /sys/contrib/dev/acpica/exconvrt.c
parent3f12fee6bc6478d15b9d7d5228e3d71e1c6e9af4 (diff)
Vendor import of the Intel ACPI CA 20020611 drop.
Notes
Notes: svn path=/vendor-sys/acpica/dist/; revision=99679
Diffstat (limited to 'sys/contrib/dev/acpica/exconvrt.c')
-rw-r--r--sys/contrib/dev/acpica/exconvrt.c130
1 files changed, 52 insertions, 78 deletions
diff --git a/sys/contrib/dev/acpica/exconvrt.c b/sys/contrib/dev/acpica/exconvrt.c
index 9b38e905a474..c3c8f988efb5 100644
--- a/sys/contrib/dev/acpica/exconvrt.c
+++ b/sys/contrib/dev/acpica/exconvrt.c
@@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: exconvrt - Object conversion routines
- * $Revision: 32 $
+ * $Revision: 37 $
*
*****************************************************************************/
@@ -118,12 +118,8 @@
#define __EXCONVRT_C__
#include "acpi.h"
-#include "acparser.h"
-#include "acnamesp.h"
#include "acinterp.h"
-#include "acevents.h"
#include "amlcode.h"
-#include "acdispat.h"
#define _COMPONENT ACPI_EXECUTER
@@ -153,27 +149,27 @@ AcpiExConvertToInteger (
UINT32 i;
ACPI_OPERAND_OBJECT *RetDesc;
UINT32 Count;
- char *Pointer;
+ UINT8 *Pointer;
ACPI_INTEGER Result;
- UINT32 IntegerSize = sizeof (ACPI_INTEGER);
+ ACPI_STATUS Status;
ACPI_FUNCTION_TRACE_PTR ("ExConvertToInteger", ObjDesc);
- switch (ObjDesc->Common.Type)
+ switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
{
case ACPI_TYPE_INTEGER:
*ResultDesc = ObjDesc;
return_ACPI_STATUS (AE_OK);
case ACPI_TYPE_STRING:
- Pointer = ObjDesc->String.Pointer;
+ Pointer = (UINT8 *) ObjDesc->String.Pointer;
Count = ObjDesc->String.Length;
break;
case ACPI_TYPE_BUFFER:
- Pointer = (char *) ObjDesc->Buffer.Pointer;
+ Pointer = ObjDesc->Buffer.Pointer;
Count = ObjDesc->Buffer.Length;
break;
@@ -182,26 +178,6 @@ AcpiExConvertToInteger (
}
/*
- * Create a new integer
- */
- RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
- if (!RetDesc)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- /* Handle both ACPI 1.0 and ACPI 2.0 Integer widths */
-
- if (WalkState->MethodNode->Flags & ANOBJ_DATA_WIDTH_32)
- {
- /*
- * We are running a method that exists in a 32-bit ACPI table.
- * Truncate the value to 32 bits by zeroing out the upper 32-bit field
- */
- IntegerSize = sizeof (UINT32);
- }
-
- /*
* Convert the buffer/string to an integer. Note that both buffers and
* strings are treated as raw data - we don't convert ascii to hex for
* strings.
@@ -214,25 +190,27 @@ AcpiExConvertToInteger (
/* Transfer no more than an integer's worth of data */
- if (Count > IntegerSize)
+ if (Count > AcpiGbl_IntegerByteWidth)
{
- Count = IntegerSize;
+ Count = AcpiGbl_IntegerByteWidth;
}
/*
* String conversion is different than Buffer conversion
*/
- switch (ObjDesc->Common.Type)
+ switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
{
case ACPI_TYPE_STRING:
- /* TBD: Need to use 64-bit ACPI_STRTOUL */
-
/*
* Convert string to an integer
* String must be hexadecimal as per the ACPI specification
*/
- Result = ACPI_STRTOUL (Pointer, NULL, 16);
+ Status = AcpiUtStrtoul64 ((char *) Pointer, 16, &Result);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
break;
@@ -252,6 +230,20 @@ AcpiExConvertToInteger (
Result |= (((ACPI_INTEGER) Pointer[i]) << (i * 8));
}
break;
+
+
+ default:
+ /* No other types can get here */
+ break;
+ }
+
+ /*
+ * Create a new integer
+ */
+ RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!RetDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
}
/* Save the Result, delete original descriptor, store new descriptor */
@@ -293,19 +285,18 @@ AcpiExConvertToBuffer (
{
ACPI_OPERAND_OBJECT *RetDesc;
UINT32 i;
- UINT32 IntegerSize = sizeof (ACPI_INTEGER);
UINT8 *NewBuf;
ACPI_FUNCTION_TRACE_PTR ("ExConvertToBuffer", ObjDesc);
- switch (ObjDesc->Common.Type)
+ switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
{
case ACPI_TYPE_INTEGER:
/*
- * Create a new Buffer
+ * Create a new Buffer object
*/
RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
if (!RetDesc)
@@ -313,21 +304,9 @@ AcpiExConvertToBuffer (
return_ACPI_STATUS (AE_NO_MEMORY);
}
- /* Handle both ACPI 1.0 and ACPI 2.0 Integer widths */
-
- if (WalkState->MethodNode->Flags & ANOBJ_DATA_WIDTH_32)
- {
- /*
- * We are running a method that exists in a 32-bit ACPI table.
- * Use only 32 bits of the Integer for conversion.
- */
- IntegerSize = sizeof (UINT32);
- }
-
/* Need enough space for one integer */
- RetDesc->Buffer.Length = IntegerSize;
- NewBuf = ACPI_MEM_CALLOCATE (IntegerSize);
+ NewBuf = ACPI_MEM_CALLOCATE (AcpiGbl_IntegerByteWidth);
if (!NewBuf)
{
ACPI_REPORT_ERROR
@@ -338,11 +317,16 @@ AcpiExConvertToBuffer (
/* Copy the integer to the buffer */
- for (i = 0; i < IntegerSize; i++)
+ for (i = 0; i < AcpiGbl_IntegerByteWidth; i++)
{
NewBuf[i] = (UINT8) (ObjDesc->Integer.Value >> (i * 8));
}
+
+ /* Complete buffer object initialization */
+
+ RetDesc->Buffer.Flags |= AOPOBJ_DATA_VALID;
RetDesc->Buffer.Pointer = NewBuf;
+ RetDesc->Buffer.Length = AcpiGbl_IntegerByteWidth;
/* Return the new buffer descriptor */
@@ -392,7 +376,7 @@ AcpiExConvertToAscii (
UINT32 i;
UINT32 j;
UINT32 k = 0;
- UINT8 HexDigit;
+ char HexDigit;
ACPI_INTEGER Digit;
UINT32 Remainder;
UINT32 Length = sizeof (ACPI_INTEGER);
@@ -414,7 +398,7 @@ AcpiExConvertToAscii (
Digit = Integer;
for (j = 1; j < i; j++)
{
- AcpiUtShortDivide (&Digit, 10, &Digit, &Remainder);
+ (void) AcpiUtShortDivide (&Digit, 10, &Digit, &Remainder);
}
/* Create the decimal digit */
@@ -447,7 +431,7 @@ AcpiExConvertToAscii (
if (!LeadingZero)
{
- String[k] = HexDigit;
+ String[k] = (UINT8) HexDigit;
k++;
}
}
@@ -500,7 +484,6 @@ AcpiExConvertToString (
UINT32 i;
UINT32 Index;
UINT32 StringLength;
- UINT32 IntegerSize = sizeof (ACPI_INTEGER);
UINT8 *NewBuf;
UINT8 *Pointer;
@@ -508,22 +491,11 @@ AcpiExConvertToString (
ACPI_FUNCTION_TRACE_PTR ("ExConvertToString", ObjDesc);
- switch (ObjDesc->Common.Type)
+ switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
{
case ACPI_TYPE_INTEGER:
- /* Handle both ACPI 1.0 and ACPI 2.0 Integer widths */
-
- if (WalkState->MethodNode->Flags & ANOBJ_DATA_WIDTH_32)
- {
- /*
- * We are running a method that exists in a 32-bit ACPI table.
- * Use only 32 bits of the Integer
- */
- IntegerSize = sizeof (UINT32);
- }
-
- StringLength = IntegerSize * 2;
+ StringLength = AcpiGbl_IntegerByteWidth * 2;
if (Base == 10)
{
StringLength = ACPI_MAX_DECIMAL_DIGITS;
@@ -540,7 +512,7 @@ AcpiExConvertToString (
/* Need enough space for one ASCII integer plus null terminator */
- NewBuf = ACPI_MEM_CALLOCATE (StringLength + 1);
+ NewBuf = ACPI_MEM_CALLOCATE ((ACPI_SIZE) StringLength + 1);
if (!NewBuf)
{
ACPI_REPORT_ERROR
@@ -549,7 +521,6 @@ AcpiExConvertToString (
return_ACPI_STATUS (AE_NO_MEMORY);
}
-
/* Convert */
i = AcpiExConvertToAscii (ObjDesc->Integer.Value, Base, NewBuf);
@@ -615,7 +586,7 @@ AcpiExConvertToString (
StringLength = MaxLength;
}
- NewBuf = ACPI_MEM_CALLOCATE (StringLength + 1);
+ NewBuf = ACPI_MEM_CALLOCATE ((ACPI_SIZE) StringLength + 1);
if (!NewBuf)
{
ACPI_REPORT_ERROR
@@ -631,7 +602,7 @@ AcpiExConvertToString (
Index = 0;
for (i = 0, Index = 0; i < ObjDesc->Buffer.Length; i++)
{
- Index = AcpiExConvertToAscii (Pointer[i], Base, &NewBuf[Index]);
+ Index = AcpiExConvertToAscii ((ACPI_INTEGER) Pointer[i], Base, &NewBuf[Index]);
NewBuf[Index] = ' ';
Index++;
@@ -643,7 +614,6 @@ AcpiExConvertToString (
RetDesc->Buffer.Pointer = NewBuf;
RetDesc->String.Length = ACPI_STRLEN ((char *) NewBuf);
-
/* Return the new buffer descriptor */
if (*ResultDesc == ObjDesc)
@@ -734,11 +704,11 @@ AcpiExConvertToTargetType (
default:
/* No conversion allowed for these types */
- if (DestinationType != SourceDesc->Common.Type)
+ if (DestinationType != ACPI_GET_OBJECT_TYPE (SourceDesc))
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Target does not allow conversion of type %s to %s\n",
- AcpiUtGetTypeName ((SourceDesc)->Common.Type),
+ AcpiUtGetObjectTypeName (SourceDesc),
AcpiUtGetTypeName (DestinationType)));
Status = AE_TYPE;
}
@@ -780,6 +750,11 @@ AcpiExConvertToTargetType (
*/
Status = AcpiExConvertToBuffer (SourceDesc, ResultDesc, WalkState);
break;
+
+
+ default:
+ Status = AE_AML_INTERNAL;
+ break;
}
break;
@@ -800,7 +775,6 @@ AcpiExConvertToTargetType (
Status = AE_AML_INTERNAL;
}
-
/*
* Source-to-Target conversion semantics:
*