summaryrefslogtreecommitdiffstats
path: root/sys/contrib/dev/acpica/utalloc.c
diff options
context:
space:
mode:
authormsmith <msmith@FreeBSD.org>2001-05-29 19:52:40 +0000
committermsmith <msmith@FreeBSD.org>2001-05-29 19:52:40 +0000
commitbc4d4229dc8150c1877e8673fb6be5be18487b6d (patch)
treea1bc1b7537f2d89240bd2e92ac027e82c5efeb6c /sys/contrib/dev/acpica/utalloc.c
parent3c0029a0e89e19ec6ede20d15284dabefb4466b0 (diff)
downloadFreeBSD-src-bc4d4229dc8150c1877e8673fb6be5be18487b6d.zip
FreeBSD-src-bc4d4229dc8150c1877e8673fb6be5be18487b6d.tar.gz
Import the 20010518 Intel ACPI CA release. Note that Intel's directory layout
keeps changing, so to reduce repository thrash everything has been moved into a single directory. (repo copy involved)
Diffstat (limited to 'sys/contrib/dev/acpica/utalloc.c')
-rw-r--r--sys/contrib/dev/acpica/utalloc.c190
1 files changed, 91 insertions, 99 deletions
diff --git a/sys/contrib/dev/acpica/utalloc.c b/sys/contrib/dev/acpica/utalloc.c
index 243ee21..ecef385 100644
--- a/sys/contrib/dev/acpica/utalloc.c
+++ b/sys/contrib/dev/acpica/utalloc.c
@@ -1,7 +1,7 @@
/******************************************************************************
*
- * Module Name: cmalloc - local memory allocation routines
- * $Revision: 84 $
+ * Module Name: utalloc - local memory allocation routines
+ * $Revision: 90 $
*
*****************************************************************************/
@@ -114,7 +114,7 @@
*
*****************************************************************************/
-#define __CMALLOC_C__
+#define __UTALLOC_C__
#include "acpi.h"
#include "acparser.h"
@@ -122,8 +122,8 @@
#include "acnamesp.h"
#include "acglobal.h"
-#define _COMPONENT MISCELLANEOUS
- MODULE_NAME ("cmalloc")
+#define _COMPONENT ACPI_UTILITIES
+ MODULE_NAME ("utalloc")
#ifdef ACPI_DEBUG_TRACK_ALLOCATIONS
@@ -133,14 +133,14 @@
* gets compiled out when the ACPI_DEBUG flag is not set.
* Every memory allocation is kept track of in a doubly linked list. Each
* element contains the caller's component, module name, function name, and
- * line number. _CmAllocate and _CmCallocate call AcpiCmAddElementToAllocList
- * to add an element to the list; deletion occurs in the bosy of _CmFree.
+ * line number. _UtAllocate and _UtCallocate call AcpiUtAddElementToAllocList
+ * to add an element to the list; deletion occurs in the bosy of _UtFree.
*/
-/*****************************************************************************
+/*******************************************************************************
*
- * FUNCTION: AcpiCmSearchAllocList
+ * FUNCTION: AcpiUtSearchAllocList
*
* PARAMETERS: Address - Address of allocated memory
*
@@ -148,13 +148,13 @@
*
* DESCRIPTION: Searches for an element in the global allocation tracking list.
*
- ****************************************************************************/
+ ******************************************************************************/
-ALLOCATION_INFO *
-AcpiCmSearchAllocList (
+ACPI_ALLOCATION_INFO *
+AcpiUtSearchAllocList (
void *Address)
{
- ALLOCATION_INFO *Element = AcpiGbl_HeadAllocPtr;
+ ACPI_ALLOCATION_INFO *Element = AcpiGbl_HeadAllocPtr;
/* Search for the address. */
@@ -173,9 +173,9 @@ AcpiCmSearchAllocList (
}
-/*****************************************************************************
+/*******************************************************************************
*
- * FUNCTION: AcpiCmAddElementToAllocList
+ * FUNCTION: AcpiUtAddElementToAllocList
*
* PARAMETERS: Address - Address of allocated memory
* Size - Size of the allocation
@@ -188,10 +188,10 @@ AcpiCmSearchAllocList (
*
* DESCRIPTION: Inserts an element into the global allocation tracking list.
*
- ****************************************************************************/
+ ******************************************************************************/
ACPI_STATUS
-AcpiCmAddElementToAllocList (
+AcpiUtAddElementToAllocList (
void *Address,
UINT32 Size,
UINT8 AllocType,
@@ -199,14 +199,14 @@ AcpiCmAddElementToAllocList (
NATIVE_CHAR *Module,
UINT32 Line)
{
- ALLOCATION_INFO *Element;
+ ACPI_ALLOCATION_INFO *Element;
ACPI_STATUS Status = AE_OK;
- FUNCTION_TRACE_PTR ("CmAddElementToAllocList", Address);
+ FUNCTION_TRACE_PTR ("UtAddElementToAllocList", Address);
- AcpiCmAcquireMutex (ACPI_MTX_MEMORY);
+ AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
/* Keep track of the running total of all allocations. */
@@ -230,13 +230,10 @@ AcpiCmAddElementToAllocList (
if (NULL == AcpiGbl_HeadAllocPtr)
{
- AcpiGbl_HeadAllocPtr =
- (ALLOCATION_INFO *) AcpiOsCallocate (sizeof (ALLOCATION_INFO));
-
+ AcpiGbl_HeadAllocPtr = AcpiOsCallocate (sizeof (ACPI_ALLOCATION_INFO));
if (!AcpiGbl_HeadAllocPtr)
{
- DEBUG_PRINT (ACPI_ERROR,
- ("Could not allocate memory info block\n"));
+ DEBUG_PRINTP (ACPI_ERROR, ("Could not allocate mem info block\n"));
Status = AE_NO_MEMORY;
goto UnlockAndExit;
}
@@ -246,12 +243,10 @@ AcpiCmAddElementToAllocList (
else
{
- AcpiGbl_TailAllocPtr->Next =
- (ALLOCATION_INFO *) AcpiOsCallocate (sizeof (ALLOCATION_INFO));
+ AcpiGbl_TailAllocPtr->Next = AcpiOsCallocate (sizeof (ACPI_ALLOCATION_INFO));
if (!AcpiGbl_TailAllocPtr->Next)
{
- DEBUG_PRINT (ACPI_ERROR,
- ("Could not allocate memory info block\n"));
+ DEBUG_PRINTP (ACPI_ERROR, ("Could not allocate mem info block\n"));
Status = AE_NO_MEMORY;
goto UnlockAndExit;
}
@@ -267,13 +262,13 @@ AcpiCmAddElementToAllocList (
* This will catch several kinds of problems.
*/
- Element = AcpiCmSearchAllocList (Address);
+ Element = AcpiUtSearchAllocList (Address);
if (Element)
{
- REPORT_ERROR (("CmAddElementToAllocList: Address already present in list! (%p)\n",
+ REPORT_ERROR (("UtAddElementToAllocList: Address already present in list! (%p)\n",
Address));
- DEBUG_PRINT (ACPI_ERROR, ("Element %p Address %p\n", Element, Address));
+ DEBUG_PRINTP (ACPI_ERROR, ("Element %p Address %p\n", Element, Address));
BREAKPOINT3;
}
@@ -290,14 +285,14 @@ AcpiCmAddElementToAllocList (
UnlockAndExit:
- AcpiCmReleaseMutex (ACPI_MTX_MEMORY);
+ AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
return_ACPI_STATUS (Status);
}
-/*****************************************************************************
+/*******************************************************************************
*
- * FUNCTION: AcpiCmDeleteElementFromAllocList
+ * FUNCTION: AcpiUtDeleteElementFromAllocList
*
* PARAMETERS: Address - Address of allocated memory
* Component - Component type of caller
@@ -308,36 +303,36 @@ UnlockAndExit:
*
* DESCRIPTION: Deletes an element from the global allocation tracking list.
*
- ****************************************************************************/
+ ******************************************************************************/
void
-AcpiCmDeleteElementFromAllocList (
+AcpiUtDeleteElementFromAllocList (
void *Address,
UINT32 Component,
NATIVE_CHAR *Module,
UINT32 Line)
{
- ALLOCATION_INFO *Element;
+ ACPI_ALLOCATION_INFO *Element;
UINT32 *DwordPtr;
UINT32 DwordLen;
UINT32 Size;
UINT32 i;
- FUNCTION_TRACE ("CmDeleteElementFromAllocList");
+ FUNCTION_TRACE ("UtDeleteElementFromAllocList");
if (NULL == AcpiGbl_HeadAllocPtr)
{
/* Boy we got problems. */
_REPORT_ERROR (Module, Line, Component,
- ("CmDeleteElementFromAllocList: Empty allocation list, nothing to free!\n"));
+ ("UtDeleteElementFromAllocList: Empty allocation list, nothing to free!\n"));
return_VOID;
}
- AcpiCmAcquireMutex (ACPI_MTX_MEMORY);
+ AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
/* Keep track of the amount of memory allocated. */
@@ -349,7 +344,7 @@ AcpiCmDeleteElementFromAllocList (
if (Address != AcpiGbl_HeadAllocPtr->Address)
{
_REPORT_ERROR (Module, Line, Component,
- ("CmDeleteElementFromAllocList: Deleting non-allocated memory\n"));
+ ("UtDeleteElementFromAllocList: Deleting non-allocated memory\n"));
goto Cleanup;
}
@@ -360,8 +355,8 @@ AcpiCmDeleteElementFromAllocList (
AcpiGbl_HeadAllocPtr = NULL;
AcpiGbl_TailAllocPtr = NULL;
- DEBUG_PRINT (TRACE_ALLOCATIONS,
- ("_CmFree: Allocation list deleted. There are no outstanding allocations\n"));
+ DEBUG_PRINTP (TRACE_ALLOCATIONS,
+ ("Allocation list deleted. There are no outstanding allocations\n"));
goto Cleanup;
}
@@ -369,7 +364,7 @@ AcpiCmDeleteElementFromAllocList (
/* Search list for this address */
- Element = AcpiCmSearchAllocList (Address);
+ Element = AcpiUtSearchAllocList (Address);
if (Element)
{
/* cases: head, tail, other */
@@ -419,16 +414,17 @@ AcpiCmDeleteElementFromAllocList (
Size = Element->Size;
- MEMSET (Element, 0xEA, sizeof (ALLOCATION_INFO));
+ MEMSET (Element, 0xEA, sizeof (ACPI_ALLOCATION_INFO));
if (Size == sizeof (ACPI_OPERAND_OBJECT))
{
- DEBUG_PRINT (TRACE_ALLOCATIONS, ("CmDelete: Freeing size %X (ACPI_OPERAND_OBJECT)\n", Size));
+ DEBUG_PRINTP (TRACE_ALLOCATIONS,
+ ("Freeing size %X (ACPI_OPERAND_OBJECT)\n", Size));
}
else
{
- DEBUG_PRINT (TRACE_ALLOCATIONS, ("CmDelete: Freeing size %X\n", Size));
+ DEBUG_PRINTP (TRACE_ALLOCATIONS, ("Freeing size %X\n", Size));
}
AcpiOsFree (Element);
@@ -437,11 +433,10 @@ AcpiCmDeleteElementFromAllocList (
else
{
_REPORT_ERROR (Module, Line, Component,
- ("_CmFree: Entry not found in list\n"));
- DEBUG_PRINT (ACPI_ERROR,
- ("_CmFree: Entry %p was not found in allocation list\n",
+ ("_UtFree: Entry not found in list\n"));
+ DEBUG_PRINTP (ACPI_ERROR, ("Entry %p was not found in allocation list\n",
Address));
- AcpiCmReleaseMutex (ACPI_MTX_MEMORY);
+ AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
return_VOID;
}
@@ -449,15 +444,15 @@ AcpiCmDeleteElementFromAllocList (
Cleanup:
AcpiGbl_CurrentAllocSize -= Size;
- AcpiCmReleaseMutex (ACPI_MTX_MEMORY);
+ AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
return_VOID;
}
-/*****************************************************************************
+/*******************************************************************************
*
- * FUNCTION: AcpiCmDumpAllocationInfo
+ * FUNCTION: AcpiUtDumpAllocationInfo
*
* PARAMETERS:
*
@@ -465,13 +460,13 @@ Cleanup:
*
* DESCRIPTION: Print some info about the outstanding allocations.
*
- ****************************************************************************/
+ ******************************************************************************/
void
-AcpiCmDumpAllocationInfo (
+AcpiUtDumpAllocationInfo (
void)
{
- FUNCTION_TRACE ("CmDumpAllocationInfo");
+ FUNCTION_TRACE ("UtDumpAllocationInfo");
DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
@@ -518,9 +513,9 @@ AcpiCmDumpAllocationInfo (
}
-/*****************************************************************************
+/*******************************************************************************
*
- * FUNCTION: AcpiCmDumpCurrentAllocations
+ * FUNCTION: AcpiUtDumpCurrentAllocations
*
* PARAMETERS: Component - Component(s) to dump info for.
* Module - Module to dump info for. NULL means all.
@@ -529,18 +524,18 @@ AcpiCmDumpAllocationInfo (
*
* DESCRIPTION: Print a list of all outstanding allocations.
*
- ****************************************************************************/
+ ******************************************************************************/
void
-AcpiCmDumpCurrentAllocations (
+AcpiUtDumpCurrentAllocations (
UINT32 Component,
NATIVE_CHAR *Module)
{
- ALLOCATION_INFO *Element = AcpiGbl_HeadAllocPtr;
+ ACPI_ALLOCATION_INFO *Element = AcpiGbl_HeadAllocPtr;
UINT32 i;
- FUNCTION_TRACE ("CmDumpCurrentAllocations");
+ FUNCTION_TRACE ("UtDumpCurrentAllocations");
if (Element == NULL)
@@ -555,7 +550,7 @@ AcpiCmDumpCurrentAllocations (
* Walk the allocation list.
*/
- AcpiCmAcquireMutex (ACPI_MTX_MEMORY);
+ AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
("Outstanding allocations:\n"));
@@ -578,7 +573,7 @@ AcpiCmDumpCurrentAllocations (
case ACPI_DESC_TYPE_INTERNAL:
DEBUG_PRINT_RAW (TRACE_ALLOCATIONS | TRACE_TABLES,
(" ObjType %s",
- AcpiCmGetTypeName (((ACPI_OPERAND_OBJECT *)(Element->Address))->Common.Type)));
+ AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *)(Element->Address))->Common.Type)));
break;
case ACPI_DESC_TYPE_PARSER:
@@ -610,7 +605,7 @@ AcpiCmDumpCurrentAllocations (
Element = Element->Next;
}
- AcpiCmReleaseMutex (ACPI_MTX_MEMORY);
+ AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
("Total number of unfreed allocations = %d(%X)\n", i,i));
@@ -621,9 +616,9 @@ AcpiCmDumpCurrentAllocations (
}
#endif /* #ifdef ACPI_DEBUG_TRACK_ALLOCATIONS */
-/*****************************************************************************
+/*******************************************************************************
*
- * FUNCTION: _CmAllocate
+ * FUNCTION: _UtAllocate
*
* PARAMETERS: Size - Size of the allocation
* Component - Component type of caller
@@ -634,10 +629,10 @@ AcpiCmDumpCurrentAllocations (
*
* DESCRIPTION: The subsystem's equivalent of malloc.
*
- ****************************************************************************/
+ ******************************************************************************/
void *
-_CmAllocate (
+_UtAllocate (
UINT32 Size,
UINT32 Component,
NATIVE_CHAR *Module,
@@ -646,7 +641,7 @@ _CmAllocate (
void *Address = NULL;
- FUNCTION_TRACE_U32 ("_CmAllocate", Size);
+ FUNCTION_TRACE_U32 ("_UtAllocate", Size);
/* Check for an inadvertent size of zero bytes */
@@ -654,7 +649,7 @@ _CmAllocate (
if (!Size)
{
_REPORT_ERROR (Module, Line, Component,
- ("CmAllocate: Attempt to allocate zero bytes\n"));
+ ("UtAllocate: Attempt to allocate zero bytes\n"));
Size = 1;
}
@@ -664,31 +659,30 @@ _CmAllocate (
/* Report allocation error */
_REPORT_ERROR (Module, Line, Component,
- ("CmAllocate: Could not allocate size %X\n", Size));
+ ("UtAllocate: Could not allocate size %X\n", Size));
- return_VALUE (NULL);
+ return_PTR (NULL);
}
#ifdef ACPI_DEBUG_TRACK_ALLOCATIONS
- if (ACPI_FAILURE (AcpiCmAddElementToAllocList (Address, Size, MEM_MALLOC,
+ if (ACPI_FAILURE (AcpiUtAddElementToAllocList (Address, Size, MEM_MALLOC,
Component, Module, Line)))
{
AcpiOsFree (Address);
return_PTR (NULL);
}
- DEBUG_PRINT (TRACE_ALLOCATIONS,
- ("CmAllocate: %p Size %X\n", Address, Size));
+ DEBUG_PRINTP (TRACE_ALLOCATIONS, ("%p Size %X\n", Address, Size));
#endif
return_PTR (Address);
}
-/*****************************************************************************
+/*******************************************************************************
*
- * FUNCTION: _CmCallocate
+ * FUNCTION: _UtCallocate
*
* PARAMETERS: Size - Size of the allocation
* Component - Component type of caller
@@ -699,10 +693,10 @@ _CmAllocate (
*
* DESCRIPTION: Subsystem equivalent of calloc.
*
- ****************************************************************************/
+ ******************************************************************************/
void *
-_CmCallocate (
+_UtCallocate (
UINT32 Size,
UINT32 Component,
NATIVE_CHAR *Module,
@@ -711,7 +705,7 @@ _CmCallocate (
void *Address = NULL;
- FUNCTION_TRACE_U32 ("_CmCallocate", Size);
+ FUNCTION_TRACE_U32 ("_UtCallocate", Size);
/* Check for an inadvertent size of zero bytes */
@@ -719,25 +713,24 @@ _CmCallocate (
if (!Size)
{
_REPORT_ERROR (Module, Line, Component,
- ("CmCallocate: Attempt to allocate zero bytes\n"));
- return_VALUE (NULL);
+ ("UtCallocate: Attempt to allocate zero bytes\n"));
+ return_PTR (NULL);
}
Address = AcpiOsCallocate (Size);
-
if (!Address)
{
/* Report allocation error */
_REPORT_ERROR (Module, Line, Component,
- ("CmCallocate: Could not allocate size %X\n", Size));
- return_VALUE (NULL);
+ ("UtCallocate: Could not allocate size %X\n", Size));
+ return_PTR (NULL);
}
#ifdef ACPI_DEBUG_TRACK_ALLOCATIONS
- if (ACPI_FAILURE (AcpiCmAddElementToAllocList (Address, Size, MEM_CALLOC,
+ if (ACPI_FAILURE (AcpiUtAddElementToAllocList (Address, Size, MEM_CALLOC,
Component,Module, Line)))
{
AcpiOsFree (Address);
@@ -745,16 +738,15 @@ _CmCallocate (
}
#endif
- DEBUG_PRINT (TRACE_ALLOCATIONS,
- ("CmCallocate: %p Size %X\n", Address, Size));
+ DEBUG_PRINTP (TRACE_ALLOCATIONS, ("%p Size %X\n", Address, Size));
return_PTR (Address);
}
-/*****************************************************************************
+/*******************************************************************************
*
- * FUNCTION: _CmFree
+ * FUNCTION: _UtFree
*
* PARAMETERS: Address - Address of the memory to deallocate
* Component - Component type of caller
@@ -765,33 +757,33 @@ _CmCallocate (
*
* DESCRIPTION: Frees the memory at Address
*
- ****************************************************************************/
+ ******************************************************************************/
void
-_CmFree (
+_UtFree (
void *Address,
UINT32 Component,
NATIVE_CHAR *Module,
UINT32 Line)
{
- FUNCTION_TRACE_PTR ("_CmFree", Address);
+ FUNCTION_TRACE_PTR ("_UtFree", Address);
if (NULL == Address)
{
_REPORT_ERROR (Module, Line, Component,
- ("_CmFree: Trying to delete a NULL address\n"));
+ ("_UtFree: Trying to delete a NULL address\n"));
return_VOID;
}
#ifdef ACPI_DEBUG_TRACK_ALLOCATIONS
- AcpiCmDeleteElementFromAllocList (Address, Component, Module, Line);
+ AcpiUtDeleteElementFromAllocList (Address, Component, Module, Line);
#endif
AcpiOsFree (Address);
- DEBUG_PRINT (TRACE_ALLOCATIONS, ("CmFree: %p freed\n", Address));
+ DEBUG_PRINTP (TRACE_ALLOCATIONS, ("%p freed\n", Address));
return_VOID;
}
OpenPOWER on IntegriCloud