summaryrefslogtreecommitdiff
path: root/source/components/utilities
diff options
context:
space:
mode:
Diffstat (limited to 'source/components/utilities')
-rw-r--r--source/components/utilities/utclib.c2
-rw-r--r--source/components/utilities/uthex.c4
-rw-r--r--source/components/utilities/utmath.c261
-rw-r--r--source/components/utilities/utmisc.c13
-rw-r--r--source/components/utilities/utobject.c4
-rw-r--r--source/components/utilities/utprint.c8
-rw-r--r--source/components/utilities/utresrc.c11
-rw-r--r--source/components/utilities/utstate.c2
-rw-r--r--source/components/utilities/utstrtoul64.c8
-rw-r--r--source/components/utilities/uttrack.c10
10 files changed, 289 insertions, 34 deletions
diff --git a/source/components/utilities/utclib.c b/source/components/utilities/utclib.c
index 2e9cb5cf022d..e9cb1bee4ade 100644
--- a/source/components/utilities/utclib.c
+++ b/source/components/utilities/utclib.c
@@ -762,7 +762,7 @@ strstr (
char *String1,
char *String2)
{
- UINT32 Length;
+ ACPI_SIZE Length;
Length = strlen (String2);
diff --git a/source/components/utilities/uthex.c b/source/components/utilities/uthex.c
index 7f507697b6ca..8c7bcccc2f4e 100644
--- a/source/components/utilities/uthex.c
+++ b/source/components/utilities/uthex.c
@@ -183,8 +183,10 @@ AcpiUtHexToAsciiChar (
UINT64 Integer,
UINT32 Position)
{
+ UINT64 Index;
- return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]);
+ AcpiUtShortShiftRight (Integer, Position, &Index);
+ return (AcpiGbl_HexToAscii[Index & 0xF]);
}
diff --git a/source/components/utilities/utmath.c b/source/components/utilities/utmath.c
index 1da5f9adf064..4aa940251d18 100644
--- a/source/components/utilities/utmath.c
+++ b/source/components/utilities/utmath.c
@@ -156,16 +156,6 @@
#define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME ("utmath")
-/*
- * Optional support for 64-bit double-precision integer divide. This code
- * is configurable and is implemented in order to support 32-bit kernel
- * environments where a 64-bit double-precision math library is not available.
- *
- * Support for a more normal 64-bit divide/modulo (with check for a divide-
- * by-zero) appears after this optional section of code.
- */
-#ifndef ACPI_USE_NATIVE_DIVIDE
-
/* Structures used only for 64-bit divide */
typedef struct uint64_struct
@@ -182,6 +172,257 @@ typedef union uint64_overlay
} UINT64_OVERLAY;
+/*
+ * Optional support for 64-bit double-precision integer multiply and shift.
+ * This code is configurable and is implemented in order to support 32-bit
+ * kernel environments where a 64-bit double-precision math library is not
+ * available.
+ */
+#ifndef ACPI_USE_NATIVE_MATH64
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtShortMultiply
+ *
+ * PARAMETERS: Multiplicand - 64-bit multiplicand
+ * Multiplier - 32-bit multiplier
+ * OutProduct - Pointer to where the product is returned
+ *
+ * DESCRIPTION: Perform a short multiply.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtShortMultiply (
+ UINT64 Multiplicand,
+ UINT32 Multiplier,
+ UINT64 *OutProduct)
+{
+ UINT64_OVERLAY MultiplicandOvl;
+ UINT64_OVERLAY Product;
+ UINT32 Carry32;
+
+
+ ACPI_FUNCTION_TRACE (UtShortMultiply);
+
+
+ MultiplicandOvl.Full = Multiplicand;
+
+ /*
+ * The Product is 64 bits, the carry is always 32 bits,
+ * and is generated by the second multiply.
+ */
+ ACPI_MUL_64_BY_32 (0, MultiplicandOvl.Part.Hi, Multiplier,
+ Product.Part.Hi, Carry32);
+
+ ACPI_MUL_64_BY_32 (0, MultiplicandOvl.Part.Lo, Multiplier,
+ Product.Part.Lo, Carry32);
+
+ Product.Part.Hi += Carry32;
+
+ /* Return only what was requested */
+
+ if (OutProduct)
+ {
+ *OutProduct = Product.Full;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtShortShiftLeft
+ *
+ * PARAMETERS: Operand - 64-bit shift operand
+ * Count - 32-bit shift count
+ * OutResult - Pointer to where the result is returned
+ *
+ * DESCRIPTION: Perform a short left shift.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtShortShiftLeft (
+ UINT64 Operand,
+ UINT32 Count,
+ UINT64 *OutResult)
+{
+ UINT64_OVERLAY OperandOvl;
+
+
+ ACPI_FUNCTION_TRACE (UtShortShiftLeft);
+
+
+ OperandOvl.Full = Operand;
+
+ if ((Count & 63) >= 32)
+ {
+ OperandOvl.Part.Hi = OperandOvl.Part.Lo;
+ OperandOvl.Part.Lo ^= OperandOvl.Part.Lo;
+ Count = (Count & 63) - 32;
+ }
+ ACPI_SHIFT_LEFT_64_BY_32 (OperandOvl.Part.Hi,
+ OperandOvl.Part.Lo, Count);
+
+ /* Return only what was requested */
+
+ if (OutResult)
+ {
+ *OutResult = OperandOvl.Full;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtShortShiftRight
+ *
+ * PARAMETERS: Operand - 64-bit shift operand
+ * Count - 32-bit shift count
+ * OutResult - Pointer to where the result is returned
+ *
+ * DESCRIPTION: Perform a short right shift.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtShortShiftRight (
+ UINT64 Operand,
+ UINT32 Count,
+ UINT64 *OutResult)
+{
+ UINT64_OVERLAY OperandOvl;
+
+
+ ACPI_FUNCTION_TRACE (UtShortShiftRight);
+
+
+ OperandOvl.Full = Operand;
+
+ if ((Count & 63) >= 32)
+ {
+ OperandOvl.Part.Lo = OperandOvl.Part.Hi;
+ OperandOvl.Part.Hi ^= OperandOvl.Part.Hi;
+ Count = (Count & 63) - 32;
+ }
+ ACPI_SHIFT_RIGHT_64_BY_32 (OperandOvl.Part.Hi,
+ OperandOvl.Part.Lo, Count);
+
+ /* Return only what was requested */
+
+ if (OutResult)
+ {
+ *OutResult = OperandOvl.Full;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+#else
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtShortMultiply
+ *
+ * PARAMETERS: See function headers above
+ *
+ * DESCRIPTION: Native version of the UtShortMultiply function.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtShortMultiply (
+ UINT64 Multiplicand,
+ UINT32 Multiplier,
+ UINT64 *OutProduct)
+{
+
+ ACPI_FUNCTION_TRACE (UtShortMultiply);
+
+
+ /* Return only what was requested */
+
+ if (OutProduct)
+ {
+ *OutProduct = Multiplicand * Multiplier;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtShortShiftLeft
+ *
+ * PARAMETERS: See function headers above
+ *
+ * DESCRIPTION: Native version of the UtShortShiftLeft function.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtShortShiftLeft (
+ UINT64 Operand,
+ UINT32 Count,
+ UINT64 *OutResult)
+{
+
+ ACPI_FUNCTION_TRACE (UtShortShiftLeft);
+
+
+ /* Return only what was requested */
+
+ if (OutResult)
+ {
+ *OutResult = Operand << Count;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtShortShiftRight
+ *
+ * PARAMETERS: See function headers above
+ *
+ * DESCRIPTION: Native version of the UtShortShiftRight function.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtShortShiftRight (
+ UINT64 Operand,
+ UINT32 Count,
+ UINT64 *OutResult)
+{
+
+ ACPI_FUNCTION_TRACE (UtShortShiftRight);
+
+
+ /* Return only what was requested */
+
+ if (OutResult)
+ {
+ *OutResult = Operand >> Count;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+#endif
+
+/*
+ * Optional support for 64-bit double-precision integer divide. This code
+ * is configurable and is implemented in order to support 32-bit kernel
+ * environments where a 64-bit double-precision math library is not available.
+ *
+ * Support for a more normal 64-bit divide/modulo (with check for a divide-
+ * by-zero) appears after this optional section of code.
+ */
+#ifndef ACPI_USE_NATIVE_DIVIDE
+
/*******************************************************************************
*
diff --git a/source/components/utilities/utmisc.c b/source/components/utilities/utmisc.c
index 33e51f5c2b8f..7280bca7e4c6 100644
--- a/source/components/utilities/utmisc.c
+++ b/source/components/utilities/utmisc.c
@@ -363,7 +363,7 @@ AcpiUtCreateUpdateStateAndPush (
*
* RETURN: Status
*
- * DESCRIPTION: Walk through a package
+ * DESCRIPTION: Walk through a package, including subpackages
*
******************************************************************************/
@@ -377,8 +377,8 @@ AcpiUtWalkPackageTree (
ACPI_STATUS Status = AE_OK;
ACPI_GENERIC_STATE *StateList = NULL;
ACPI_GENERIC_STATE *State;
- UINT32 ThisIndex;
ACPI_OPERAND_OBJECT *ThisSourceObj;
+ UINT32 ThisIndex;
ACPI_FUNCTION_TRACE (UtWalkPackageTree);
@@ -395,8 +395,10 @@ AcpiUtWalkPackageTree (
/* Get one element of the package */
ThisIndex = State->Pkg.Index;
- ThisSourceObj = (ACPI_OPERAND_OBJECT *)
+ ThisSourceObj =
State->Pkg.SourceObject->Package.Elements[ThisIndex];
+ State->Pkg.ThisTargetObj =
+ &State->Pkg.SourceObject->Package.Elements[ThisIndex];
/*
* Check for:
@@ -412,7 +414,7 @@ AcpiUtWalkPackageTree (
(ThisSourceObj->Common.Type != ACPI_TYPE_PACKAGE))
{
Status = WalkCallback (ACPI_COPY_TYPE_SIMPLE, ThisSourceObj,
- State, Context);
+ State, Context);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
@@ -485,6 +487,9 @@ AcpiUtWalkPackageTree (
/* We should never get here */
+ ACPI_ERROR ((AE_INFO,
+ "State list did not terminate correctly"));
+
return_ACPI_STATUS (AE_AML_INTERNAL);
}
diff --git a/source/components/utilities/utobject.c b/source/components/utilities/utobject.c
index a94c882eddba..65aae85f6d53 100644
--- a/source/components/utilities/utobject.c
+++ b/source/components/utilities/utobject.c
@@ -651,6 +651,10 @@ AcpiUtGetSimpleObjectSize (
{
/* A namespace node should never get here */
+ ACPI_ERROR ((AE_INFO,
+ "Received a namespace node [%4.4s] "
+ "where an operand object is required",
+ ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, InternalObject)->Name.Ascii));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
diff --git a/source/components/utilities/utprint.c b/source/components/utilities/utprint.c
index 500f7a5fe546..b656af336791 100644
--- a/source/components/utilities/utprint.c
+++ b/source/components/utilities/utprint.c
@@ -331,7 +331,7 @@ AcpiUtScanNumber (
while (isdigit ((int) *String))
{
- Number *= 10;
+ AcpiUtShortMultiply (Number, 10, &Number);
Number += *(String++) - '0';
}
@@ -463,7 +463,7 @@ AcpiUtFormatNumber (
/* Generate full string in reverse order */
Pos = AcpiUtPutNumber (ReversedString, Number, Base, Upper);
- i = ACPI_PTR_DIFF (Pos, ReversedString);
+ i = (INT32) ACPI_PTR_DIFF (Pos, ReversedString);
/* Printing 100 using %2d gives "100", not "00" */
@@ -695,7 +695,7 @@ vsnprintf (
{
s = "<NULL>";
}
- Length = AcpiUtBoundStringLength (s, Precision);
+ Length = (INT32) AcpiUtBoundStringLength (s, Precision);
if (!(Type & ACPI_FORMAT_LEFT))
{
while (Length < Width--)
@@ -815,7 +815,7 @@ vsnprintf (
}
}
- return (ACPI_PTR_DIFF (Pos, String));
+ return ((int) ACPI_PTR_DIFF (Pos, String));
}
diff --git a/source/components/utilities/utresrc.c b/source/components/utilities/utresrc.c
index e34662c809d1..da4fdc4366a6 100644
--- a/source/components/utilities/utresrc.c
+++ b/source/components/utilities/utresrc.c
@@ -360,14 +360,11 @@ AcpiUtWalkAmlResources (
}
/*
- * The EndTag opcode must be followed by a zero byte.
- * Although this byte is technically defined to be a checksum,
- * in practice, all ASL compilers set this byte to zero.
+ * Don't attempt to perform any validation on the 2nd byte.
+ * Although all known ASL compilers insert a zero for the 2nd
+ * byte, it can also be a checksum (as per the ACPI spec),
+ * and this is occasionally seen in the field. July 2017.
*/
- if (*(Aml + 1) != 0)
- {
- return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
- }
/* Return the pointer to the EndTag if requested */
diff --git a/source/components/utilities/utstate.c b/source/components/utilities/utstate.c
index 2d75c89422ab..8effe5baa368 100644
--- a/source/components/utilities/utstate.c
+++ b/source/components/utilities/utstate.c
@@ -363,7 +363,7 @@ ACPI_GENERIC_STATE *
AcpiUtCreatePkgState (
void *InternalObject,
void *ExternalObject,
- UINT16 Index)
+ UINT32 Index)
{
ACPI_GENERIC_STATE *State;
diff --git a/source/components/utilities/utstrtoul64.c b/source/components/utilities/utstrtoul64.c
index a3c52b9e7010..d91e9084264c 100644
--- a/source/components/utilities/utstrtoul64.c
+++ b/source/components/utilities/utstrtoul64.c
@@ -419,8 +419,8 @@ AcpiUtStrtoulBase10 (
/* Convert and insert (add) the decimal digit */
- NextValue =
- (ReturnValue * 10) + (AsciiDigit - ACPI_ASCII_ZERO);
+ AcpiUtShortMultiply (ReturnValue, 10, &NextValue);
+ NextValue += (AsciiDigit - ACPI_ASCII_ZERO);
/* Check for overflow (32 or 64 bit) - return current converted value */
@@ -486,8 +486,8 @@ AcpiUtStrtoulBase16 (
/* Convert and insert the hex digit */
- ReturnValue =
- (ReturnValue << 4) | AcpiUtAsciiCharToHex (AsciiDigit);
+ AcpiUtShortShiftLeft (ReturnValue, 4, &ReturnValue);
+ ReturnValue |= AcpiUtAsciiCharToHex (AsciiDigit);
String++;
ValidDigits++;
diff --git a/source/components/utilities/uttrack.c b/source/components/utilities/uttrack.c
index 3ac6a3815649..a88a4a3de880 100644
--- a/source/components/utilities/uttrack.c
+++ b/source/components/utilities/uttrack.c
@@ -776,6 +776,11 @@ AcpiUtDumpAllocations (
return_VOID;
}
+ if (!AcpiGbl_GlobalList)
+ {
+ goto Exit;
+ }
+
Element = AcpiGbl_GlobalList->ListHead;
while (Element)
{
@@ -787,7 +792,7 @@ AcpiUtDumpAllocations (
if (Element->Size < sizeof (ACPI_COMMON_DESCRIPTOR))
{
- AcpiOsPrintf ("%p Length 0x%04X %9.9s-%u "
+ AcpiOsPrintf ("%p Length 0x%04X %9.9s-%4.4u "
"[Not a Descriptor - too small]\n",
Descriptor, Element->Size, Element->Module,
Element->Line);
@@ -799,7 +804,7 @@ AcpiUtDumpAllocations (
if (ACPI_GET_DESCRIPTOR_TYPE (Descriptor) !=
ACPI_DESC_TYPE_CACHED)
{
- AcpiOsPrintf ("%p Length 0x%04X %9.9s-%u [%s] ",
+ AcpiOsPrintf ("%p Length 0x%04X %9.9s-%4.4u [%s] ",
Descriptor, Element->Size, Element->Module,
Element->Line, AcpiUtGetDescriptorName (Descriptor));
@@ -875,6 +880,7 @@ AcpiUtDumpAllocations (
Element = Element->Next;
}
+Exit:
(void) AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
/* Print summary */