summaryrefslogtreecommitdiffstats
path: root/sys/contrib/dev/acpica/exconvrt.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/dev/acpica/exconvrt.c')
-rw-r--r--sys/contrib/dev/acpica/exconvrt.c166
1 files changed, 74 insertions, 92 deletions
diff --git a/sys/contrib/dev/acpica/exconvrt.c b/sys/contrib/dev/acpica/exconvrt.c
index 6729a27..f5937f1 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: 39 $
+ * $Revision: 44 $
*
*****************************************************************************/
@@ -246,10 +246,15 @@ AcpiExConvertToInteger (
return_ACPI_STATUS (AE_NO_MEMORY);
}
- /* Save the Result, delete original descriptor, store new descriptor */
+ /* Save the Result */
RetDesc->Integer.Value = Result;
+ /*
+ * If we are about to overwrite the original object on the operand stack,
+ * we must remove a reference on the original object because we are
+ * essentially removing it from the stack.
+ */
if (*ResultDesc == ObjDesc)
{
if (WalkState->Opcode != AML_STORE_OP)
@@ -293,81 +298,53 @@ AcpiExConvertToBuffer (
switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
{
+ case ACPI_TYPE_BUFFER:
+
+ /* No conversion necessary */
+
+ *ResultDesc = ObjDesc;
+ return_ACPI_STATUS (AE_OK);
+
+
case ACPI_TYPE_INTEGER:
/*
- * Create a new Buffer object
+ * Create a new Buffer object.
+ * Need enough space for one integer
*/
- RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
+ RetDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth);
if (!RetDesc)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
- /* Need enough space for one integer */
-
- NewBuf = ACPI_MEM_CALLOCATE (AcpiGbl_IntegerByteWidth);
- if (!NewBuf)
- {
- ACPI_REPORT_ERROR
- (("ExConvertToBuffer: Buffer allocation failure\n"));
- AcpiUtRemoveReference (RetDesc);
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
/* Copy the integer to the buffer */
+ NewBuf = RetDesc->Buffer.Pointer;
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 */
-
- *ResultDesc = RetDesc;
break;
case ACPI_TYPE_STRING:
+
/*
* Create a new Buffer object
+ * Size will be the string length
*/
- RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
+ RetDesc = AcpiUtCreateBufferObject (ObjDesc->String.Length);
if (!RetDesc)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
- /* Need enough space for one integer */
-
- NewBuf = ACPI_MEM_CALLOCATE (ObjDesc->String.Length);
- if (!NewBuf)
- {
- ACPI_REPORT_ERROR
- (("ExConvertToBuffer: Buffer allocation failure\n"));
- AcpiUtRemoveReference (RetDesc);
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- ACPI_STRNCPY ((char *) NewBuf, (char *) ObjDesc->String.Pointer, ObjDesc->String.Length);
- RetDesc->Buffer.Flags |= AOPOBJ_DATA_VALID;
- RetDesc->Buffer.Pointer = NewBuf;
- RetDesc->Buffer.Length = ObjDesc->String.Length;
+ /* Copy the string to the buffer */
- /* Return the new buffer descriptor */
-
- *ResultDesc = RetDesc;
- break;
-
-
- case ACPI_TYPE_BUFFER:
- *ResultDesc = ObjDesc;
+ NewBuf = RetDesc->Buffer.Pointer;
+ ACPI_STRNCPY ((char *) NewBuf, (char *) ObjDesc->String.Pointer,
+ ObjDesc->String.Length);
break;
@@ -377,7 +354,22 @@ AcpiExConvertToBuffer (
/* Mark buffer initialized */
- (*ResultDesc)->Common.Flags |= AOPOBJ_DATA_VALID;
+ RetDesc->Common.Flags |= AOPOBJ_DATA_VALID;
+
+ /*
+ * If we are about to overwrite the original object on the operand stack,
+ * we must remove a reference on the original object because we are
+ * essentially removing it from the stack.
+ */
+ if (*ResultDesc == ObjDesc)
+ {
+ if (WalkState->Opcode != AML_STORE_OP)
+ {
+ AcpiUtRemoveReference (ObjDesc);
+ }
+ }
+
+ *ResultDesc = RetDesc;
return_ACPI_STATUS (AE_OK);
}
@@ -522,6 +514,21 @@ AcpiExConvertToString (
switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
{
+ case ACPI_TYPE_STRING:
+
+ if (MaxLength >= ObjDesc->String.Length)
+ {
+ *ResultDesc = ObjDesc;
+ return_ACPI_STATUS (AE_OK);
+ }
+ else
+ {
+ /* Must copy the string first and then truncate it */
+
+ return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
+ }
+
+
case ACPI_TYPE_INTEGER:
StringLength = AcpiGbl_IntegerByteWidth * 2;
@@ -568,18 +575,6 @@ AcpiExConvertToString (
}
RetDesc->Buffer.Pointer = NewBuf;
-
- /* Return the new buffer descriptor */
-
- if (*ResultDesc == ObjDesc)
- {
- if (WalkState->Opcode != AML_STORE_OP)
- {
- AcpiUtRemoveReference (ObjDesc);
- }
- }
-
- *ResultDesc = RetDesc;
break;
@@ -641,42 +636,29 @@ AcpiExConvertToString (
NewBuf [Index-1] = 0;
RetDesc->Buffer.Pointer = NewBuf;
- RetDesc->String.Length = ACPI_STRLEN ((char *) NewBuf);
-
- /* Return the new buffer descriptor */
-
- if (*ResultDesc == ObjDesc)
- {
- if (WalkState->Opcode != AML_STORE_OP)
- {
- AcpiUtRemoveReference (ObjDesc);
- }
- }
-
- *ResultDesc = RetDesc;
+ RetDesc->String.Length = (UINT32) ACPI_STRLEN ((char *) NewBuf);
break;
- case ACPI_TYPE_STRING:
+ default:
+ return_ACPI_STATUS (AE_TYPE);
+ }
- if (MaxLength >= ObjDesc->String.Length)
- {
- *ResultDesc = ObjDesc;
- }
- else
+ /*
+ * If we are about to overwrite the original object on the operand stack,
+ * we must remove a reference on the original object because we are
+ * essentially removing it from the stack.
+ */
+ if (*ResultDesc == ObjDesc)
+ {
+ if (WalkState->Opcode != AML_STORE_OP)
{
- /* Must copy the string first and then truncate it */
-
- return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
+ AcpiUtRemoveReference (ObjDesc);
}
- break;
-
-
- default:
- return_ACPI_STATUS (AE_TYPE);
}
+ *ResultDesc = RetDesc;
return_ACPI_STATUS (AE_OK);
}
@@ -724,7 +706,7 @@ AcpiExConvertToTargetType (
switch (DestinationType)
{
- case INTERNAL_TYPE_REGION_FIELD:
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
/*
* Named field can always handle conversions
*/
@@ -751,8 +733,8 @@ AcpiExConvertToTargetType (
{
case ACPI_TYPE_INTEGER:
case ACPI_TYPE_BUFFER_FIELD:
- case INTERNAL_TYPE_BANK_FIELD:
- case INTERNAL_TYPE_INDEX_FIELD:
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
/*
* These types require an Integer operand. We can convert
* a Buffer or a String to an Integer if necessary.
OpenPOWER on IntegriCloud