summaryrefslogtreecommitdiffstats
path: root/source/components/utilities
diff options
context:
space:
mode:
Diffstat (limited to 'source/components/utilities')
-rw-r--r--source/components/utilities/utalloc.c131
-rw-r--r--source/components/utilities/utdebug.c1
-rw-r--r--source/components/utilities/utexcep.c1
-rw-r--r--source/components/utilities/utglobal.c1
-rw-r--r--source/components/utilities/utstring.c75
-rw-r--r--source/components/utilities/uttrack.c29
-rw-r--r--source/components/utilities/utxface.c2
-rw-r--r--source/components/utilities/utxferror.c1
-rw-r--r--source/components/utilities/utxfinit.c6
9 files changed, 147 insertions, 100 deletions
diff --git a/source/components/utilities/utalloc.c b/source/components/utilities/utalloc.c
index 2169fe8..51eee97 100644
--- a/source/components/utilities/utalloc.c
+++ b/source/components/utilities/utalloc.c
@@ -51,6 +51,45 @@
ACPI_MODULE_NAME ("utalloc")
+#if !defined (USE_NATIVE_ALLOCATE_ZEROED)
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiOsAllocateZeroed
+ *
+ * PARAMETERS: Size - Size of the allocation
+ *
+ * RETURN: Address of the allocated memory on success, NULL on failure.
+ *
+ * DESCRIPTION: Subsystem equivalent of calloc. Allocate and zero memory.
+ * This is the default implementation. Can be overridden via the
+ * USE_NATIVE_ALLOCATE_ZEROED flag.
+ *
+ ******************************************************************************/
+
+void *
+AcpiOsAllocateZeroed (
+ ACPI_SIZE Size)
+{
+ void *Allocation;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ Allocation = AcpiOsAllocate (Size);
+ if (Allocation)
+ {
+ /* Clear the memory block */
+
+ ACPI_MEMSET (Allocation, 0, Size);
+ }
+
+ return (Allocation);
+}
+
+#endif /* !USE_NATIVE_ALLOCATE_ZEROED */
+
+
/*******************************************************************************
*
* FUNCTION: AcpiUtCreateCaches
@@ -321,95 +360,3 @@ AcpiUtInitializeBuffer (
ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength);
return (AE_OK);
}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtAllocate
- *
- * PARAMETERS: Size - Size of the allocation
- * Component - Component type of caller
- * Module - Source file name of caller
- * Line - Line number of caller
- *
- * RETURN: Address of the allocated memory on success, NULL on failure.
- *
- * DESCRIPTION: Subsystem equivalent of malloc.
- *
- ******************************************************************************/
-
-void *
-AcpiUtAllocate (
- ACPI_SIZE Size,
- UINT32 Component,
- const char *Module,
- UINT32 Line)
-{
- void *Allocation;
-
-
- ACPI_FUNCTION_TRACE_U32 (UtAllocate, Size);
-
-
- /* Check for an inadvertent size of zero bytes */
-
- if (!Size)
- {
- ACPI_WARNING ((Module, Line,
- "Attempt to allocate zero bytes, allocating 1 byte"));
- Size = 1;
- }
-
- Allocation = AcpiOsAllocate (Size);
- if (!Allocation)
- {
- /* Report allocation error */
-
- ACPI_WARNING ((Module, Line,
- "Could not allocate size %u", (UINT32) Size));
-
- return_PTR (NULL);
- }
-
- return_PTR (Allocation);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: AcpiUtAllocateZeroed
- *
- * PARAMETERS: Size - Size of the allocation
- * Component - Component type of caller
- * Module - Source file name of caller
- * Line - Line number of caller
- *
- * RETURN: Address of the allocated memory on success, NULL on failure.
- *
- * DESCRIPTION: Subsystem equivalent of calloc. Allocate and zero memory.
- *
- ******************************************************************************/
-
-void *
-AcpiUtAllocateZeroed (
- ACPI_SIZE Size,
- UINT32 Component,
- const char *Module,
- UINT32 Line)
-{
- void *Allocation;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- Allocation = AcpiUtAllocate (Size, Component, Module, Line);
- if (Allocation)
- {
- /* Clear the memory block */
-
- ACPI_MEMSET (Allocation, 0, Size);
- }
-
- return (Allocation);
-}
diff --git a/source/components/utilities/utdebug.c b/source/components/utilities/utdebug.c
index 712c188..ab16236 100644
--- a/source/components/utilities/utdebug.c
+++ b/source/components/utilities/utdebug.c
@@ -42,6 +42,7 @@
*/
#define __UTDEBUG_C__
+#define EXPORT_ACPI_INTERFACES
#include "acpi.h"
#include "accommon.h"
diff --git a/source/components/utilities/utexcep.c b/source/components/utilities/utexcep.c
index 75258d9..2c35386 100644
--- a/source/components/utilities/utexcep.c
+++ b/source/components/utilities/utexcep.c
@@ -43,6 +43,7 @@
#define __UTEXCEP_C__
+#define EXPORT_ACPI_INTERFACES
#define ACPI_DEFINE_EXCEPTION_TABLE
#include "acpi.h"
diff --git a/source/components/utilities/utglobal.c b/source/components/utilities/utglobal.c
index ff24515..70ad3f4 100644
--- a/source/components/utilities/utglobal.c
+++ b/source/components/utilities/utglobal.c
@@ -42,6 +42,7 @@
*/
#define __UTGLOBAL_C__
+#define EXPORT_ACPI_INTERFACES
#define DEFINE_ACPI_GLOBALS
#include "acpi.h"
diff --git a/source/components/utilities/utstring.c b/source/components/utilities/utstring.c
index 9798700..282869c 100644
--- a/source/components/utilities/utstring.c
+++ b/source/components/utilities/utstring.c
@@ -685,3 +685,78 @@ UtConvertBackslashes (
}
}
#endif
+
+#if defined (ACPI_DEBUGGER) || defined (ACPI_APPLICATION)
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtSafeStrcpy, AcpiUtSafeStrcat, AcpiUtSafeStrncat
+ *
+ * PARAMETERS: Adds a "DestSize" parameter to each of the standard string
+ * functions. This is the size of the Destination buffer.
+ *
+ * RETURN: TRUE if the operation would overflow the destination buffer.
+ *
+ * DESCRIPTION: Safe versions of standard Clib string functions. Ensure that
+ * the result of the operation will not overflow the output string
+ * buffer.
+ *
+ * NOTE: These functions are typically only helpful for processing
+ * user input and command lines. For most ACPICA code, the
+ * required buffer length is precisely calculated before buffer
+ * allocation, so the use of these functions is unnecessary.
+ *
+ ******************************************************************************/
+
+BOOLEAN
+AcpiUtSafeStrcpy (
+ char *Dest,
+ ACPI_SIZE DestSize,
+ char *Source)
+{
+
+ if (ACPI_STRLEN (Source) >= DestSize)
+ {
+ return (TRUE);
+ }
+
+ ACPI_STRCPY (Dest, Source);
+ return (FALSE);
+}
+
+BOOLEAN
+AcpiUtSafeStrcat (
+ char *Dest,
+ ACPI_SIZE DestSize,
+ char *Source)
+{
+
+ if ((ACPI_STRLEN (Dest) + ACPI_STRLEN (Source)) >= DestSize)
+ {
+ return (TRUE);
+ }
+
+ ACPI_STRCAT (Dest, Source);
+ return (FALSE);
+}
+
+BOOLEAN
+AcpiUtSafeStrncat (
+ char *Dest,
+ ACPI_SIZE DestSize,
+ char *Source,
+ ACPI_SIZE MaxTransferLength)
+{
+ ACPI_SIZE ActualTransferLength;
+
+
+ ActualTransferLength = ACPI_MIN (MaxTransferLength, ACPI_STRLEN (Source));
+
+ if ((ACPI_STRLEN (Dest) + ActualTransferLength) >= DestSize)
+ {
+ return (TRUE);
+ }
+
+ ACPI_STRNCAT (Dest, Source, MaxTransferLength);
+ return (FALSE);
+}
+#endif
diff --git a/source/components/utilities/uttrack.c b/source/components/utilities/uttrack.c
index 6cf9bdf..70d4585 100644
--- a/source/components/utilities/uttrack.c
+++ b/source/components/utilities/uttrack.c
@@ -151,10 +151,23 @@ AcpiUtAllocateAndTrack (
ACPI_STATUS Status;
- Allocation = AcpiUtAllocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER),
- Component, Module, Line);
+ /* Check for an inadvertent size of zero bytes */
+
+ if (!Size)
+ {
+ ACPI_WARNING ((Module, Line,
+ "Attempt to allocate zero bytes, allocating 1 byte"));
+ Size = 1;
+ }
+
+ Allocation = AcpiOsAllocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER));
if (!Allocation)
{
+ /* Report allocation error */
+
+ ACPI_WARNING ((Module, Line,
+ "Could not allocate size %u", (UINT32) Size));
+
return (NULL);
}
@@ -204,8 +217,16 @@ AcpiUtAllocateZeroedAndTrack (
ACPI_STATUS Status;
- Allocation = AcpiUtAllocateZeroed (Size + sizeof (ACPI_DEBUG_MEM_HEADER),
- Component, Module, Line);
+ /* Check for an inadvertent size of zero bytes */
+
+ if (!Size)
+ {
+ ACPI_WARNING ((Module, Line,
+ "Attempt to allocate zero bytes, allocating 1 byte"));
+ Size = 1;
+ }
+
+ Allocation = AcpiOsAllocateZeroed (Size + sizeof (ACPI_DEBUG_MEM_HEADER));
if (!Allocation)
{
/* Report allocation error */
diff --git a/source/components/utilities/utxface.c b/source/components/utilities/utxface.c
index 021a462..3087d67 100644
--- a/source/components/utilities/utxface.c
+++ b/source/components/utilities/utxface.c
@@ -114,7 +114,7 @@ AcpiTerminate (
return_ACPI_STATUS (Status);
}
-ACPI_EXPORT_SYMBOL (AcpiTerminate)
+ACPI_EXPORT_SYMBOL_INIT (AcpiTerminate)
#ifndef ACPI_ASL_COMPILER
diff --git a/source/components/utilities/utxferror.c b/source/components/utilities/utxferror.c
index a01b5b0..366eae1 100644
--- a/source/components/utilities/utxferror.c
+++ b/source/components/utilities/utxferror.c
@@ -42,6 +42,7 @@
*/
#define __UTXFERROR_C__
+#define EXPORT_ACPI_INTERFACES
#include "acpi.h"
#include "accommon.h"
diff --git a/source/components/utilities/utxfinit.c b/source/components/utilities/utxfinit.c
index 5312681..a9d9251 100644
--- a/source/components/utilities/utxfinit.c
+++ b/source/components/utilities/utxfinit.c
@@ -134,7 +134,7 @@ AcpiInitializeSubsystem (
return_ACPI_STATUS (Status);
}
-ACPI_EXPORT_SYMBOL (AcpiInitializeSubsystem)
+ACPI_EXPORT_SYMBOL_INIT (AcpiInitializeSubsystem)
/*******************************************************************************
@@ -256,7 +256,7 @@ AcpiEnableSubsystem (
return_ACPI_STATUS (Status);
}
-ACPI_EXPORT_SYMBOL (AcpiEnableSubsystem)
+ACPI_EXPORT_SYMBOL_INIT (AcpiEnableSubsystem)
/*******************************************************************************
@@ -355,4 +355,4 @@ AcpiInitializeObjects (
return_ACPI_STATUS (Status);
}
-ACPI_EXPORT_SYMBOL (AcpiInitializeObjects)
+ACPI_EXPORT_SYMBOL_INIT (AcpiInitializeObjects)
OpenPOWER on IntegriCloud