aboutsummaryrefslogtreecommitdiff
path: root/source/compiler/aslutils.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/compiler/aslutils.c')
-rw-r--r--source/compiler/aslutils.c105
1 files changed, 59 insertions, 46 deletions
diff --git a/source/compiler/aslutils.c b/source/compiler/aslutils.c
index 7dc0697236b8..c9a9fac6d75d 100644
--- a/source/compiler/aslutils.c
+++ b/source/compiler/aslutils.c
@@ -41,7 +41,6 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
-
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "acdisasm.h"
@@ -243,37 +242,6 @@ UtEndEvent (
/*******************************************************************************
*
- * FUNCTION: UtHexCharToValue
- *
- * PARAMETERS: HexChar - Hex character in Ascii
- *
- * RETURN: The binary value of the hex character
- *
- * DESCRIPTION: Perform ascii-to-hex translation
- *
- ******************************************************************************/
-
-UINT8
-UtHexCharToValue (
- int HexChar)
-{
-
- if (HexChar <= 0x39)
- {
- return ((UINT8) (HexChar - 0x30));
- }
-
- if (HexChar <= 0x46)
- {
- return ((UINT8) (HexChar - 0x37));
- }
-
- return ((UINT8) (HexChar - 0x57));
-}
-
-
-/*******************************************************************************
- *
* FUNCTION: UtConvertByteToHex
*
* PARAMETERS: RawByte - Binary data
@@ -296,8 +264,8 @@ UtConvertByteToHex (
Buffer[0] = '0';
Buffer[1] = 'x';
- Buffer[2] = (UINT8) AslHexLookup[(RawByte >> 4) & 0xF];
- Buffer[3] = (UINT8) AslHexLookup[RawByte & 0xF];
+ Buffer[2] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 4);
+ Buffer[3] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 0);
}
@@ -312,7 +280,7 @@ UtConvertByteToHex (
* RETURN: Ascii hex byte is stored in Buffer.
*
* DESCRIPTION: Perform hex-to-ascii translation. The return data is prefixed
- * with "0x"
+ * with '0', and a trailing 'h' is added.
*
******************************************************************************/
@@ -323,8 +291,8 @@ UtConvertByteToAsmHex (
{
Buffer[0] = '0';
- Buffer[1] = (UINT8) AslHexLookup[(RawByte >> 4) & 0xF];
- Buffer[2] = (UINT8) AslHexLookup[RawByte & 0xF];
+ Buffer[1] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 4);
+ Buffer[2] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 0);
Buffer[3] = 'h';
}
@@ -585,7 +553,7 @@ UtCheckIntegerRange (
/*******************************************************************************
*
- * FUNCTION: UtGetStringBuffer
+ * FUNCTION: UtStringCacheCalloc
*
* PARAMETERS: Length - Size of buffer requested
*
@@ -598,22 +566,42 @@ UtCheckIntegerRange (
******************************************************************************/
char *
-UtGetStringBuffer (
+UtStringCacheCalloc (
UINT32 Length)
{
char *Buffer;
+ ASL_CACHE_INFO *Cache;
+ if (Length > ASL_STRING_CACHE_SIZE)
+ {
+ Buffer = UtLocalCalloc (Length);
+ return (Buffer);
+ }
+
if ((Gbl_StringCacheNext + Length) >= Gbl_StringCacheLast)
{
- Gbl_StringCacheNext = UtLocalCalloc (ASL_STRING_CACHE_SIZE + Length);
- Gbl_StringCacheLast = Gbl_StringCacheNext + ASL_STRING_CACHE_SIZE +
- Length;
+ /* Allocate a new buffer */
+
+ Cache = UtLocalCalloc (sizeof (Cache->Next) +
+ ASL_STRING_CACHE_SIZE);
+
+ /* Link new cache buffer to head of list */
+
+ Cache->Next = Gbl_StringCacheList;
+ Gbl_StringCacheList = Cache;
+
+ /* Setup cache management pointers */
+
+ Gbl_StringCacheNext = Cache->Buffer;
+ Gbl_StringCacheLast = Gbl_StringCacheNext + ASL_STRING_CACHE_SIZE;
}
+ Gbl_StringCount++;
+ Gbl_StringSize += Length;
+
Buffer = Gbl_StringCacheNext;
Gbl_StringCacheNext += Length;
-
return (Buffer);
}
@@ -646,7 +634,8 @@ UtExpandLineBuffers (
NewSize = Gbl_LineBufferSize * 2;
if (Gbl_CurrentLineBuffer)
{
- DbgPrint (ASL_DEBUG_OUTPUT,"Increasing line buffer size from %u to %u\n",
+ DbgPrint (ASL_DEBUG_OUTPUT,
+ "Increasing line buffer size from %u to %u\n",
Gbl_LineBufferSize, NewSize);
}
@@ -691,6 +680,30 @@ ErrorExit:
}
+/******************************************************************************
+ *
+ * FUNCTION: UtFreeLineBuffers
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Free all line buffers
+ *
+ *****************************************************************************/
+
+void
+UtFreeLineBuffers (
+ void)
+{
+
+ free (Gbl_CurrentLineBuffer);
+ free (Gbl_MainTokenBuffer);
+ free (Gbl_MacroTokenBuffer);
+ free (Gbl_ExpressionTokenBuffer);
+}
+
+
/*******************************************************************************
*
* FUNCTION: UtInternalizeName
@@ -723,9 +736,9 @@ UtInternalizeName (
Info.ExternalName = ExternalName;
AcpiNsGetInternalNameLength (&Info);
- /* We need a segment to store the internal name */
+ /* We need a segment to store the internal name */
- Info.InternalName = UtGetStringBuffer (Info.Length);
+ Info.InternalName = UtStringCacheCalloc (Info.Length);
if (!Info.InternalName)
{
return (AE_NO_MEMORY);