Beispiel #1
0
void *
_cm_allocate (
	u32                     size,
	u32                     component,
	NATIVE_CHAR             *module,
	u32                     line)
{
	void                    *address = NULL;
	DEBUG_ONLY_MEMBERS (\
	ACPI_STATUS             status)


	/* Check for an inadvertent size of zero bytes */

	if (!size) {
		_REPORT_ERROR (module, line, component,
				("Cm_allocate: Attempt to allocate zero bytes\n"));
		size = 1;
	}

	address = acpi_os_allocate (size);
	if (!address) {
		/* Report allocation error */

		_REPORT_ERROR (module, line, component,
				("Cm_allocate: Could not allocate size %X\n", size));

		return (NULL);
	}


	return (address);
}
Beispiel #2
0
void *
AcpiUtAllocate (
    UINT32                  Size,
    UINT32                  Component,
    NATIVE_CHAR             *Module,
    UINT32                  Line)
{
    ACPI_DEBUG_MEM_BLOCK    *Address;
    ACPI_STATUS             Status;


    FUNCTION_TRACE_U32 ("UtAllocate", Size);


    /* Check for an inadvertent size of zero bytes */

    if (!Size)
    {
        _REPORT_ERROR (Module, Line, Component,
                ("UtAllocate: Attempt to allocate zero bytes\n"));
        Size = 1;
    }

    Address = AcpiOsAllocate (Size + sizeof (ACPI_DEBUG_MEM_BLOCK));
    if (!Address)
    {
        /* Report allocation error */

        _REPORT_ERROR (Module, Line, Component,
                ("UtAllocate: Could not allocate size %X\n", Size));

        return_PTR (NULL);
    }

    Status = AcpiUtAddElementToAllocList (ACPI_MEM_LIST_GLOBAL, Address, Size,
                    MEM_MALLOC, Component, Module, Line);
    if (ACPI_FAILURE (Status))
    {
        AcpiOsFree (Address);
        return_PTR (NULL);
    }

    AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].TotalAllocated++;
    AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].CurrentTotalSize += Size;

    ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n", Address, Size));

    return_PTR ((void *) &Address->UserSpace);
}
void *
acpi_ut_allocate_object_desc_dbg (
	NATIVE_CHAR             *module_name,
	u32                     line_number,
	u32                     component_id)
{
	acpi_operand_object     *object;


	FUNCTION_TRACE ("Ut_allocate_object_desc_dbg");


	object = acpi_ut_acquire_from_cache (ACPI_MEM_LIST_OPERAND);
	if (!object) {
		_REPORT_ERROR (module_name, line_number, component_id,
				  ("Could not allocate an object descriptor\n"));

		return_PTR (NULL);
	}


	/* Mark the descriptor type */

	object->common.data_type = ACPI_DESC_TYPE_INTERNAL;

	ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n",
			object, sizeof (acpi_operand_object)));

	return_PTR (object);
}
Beispiel #4
0
void
AcpiUtFree (
    void                    *Address,
    UINT32                  Component,
    NATIVE_CHAR             *Module,
    UINT32                  Line)
{
    ACPI_DEBUG_MEM_BLOCK    *DebugBlock;


    FUNCTION_TRACE_PTR ("UtFree", Address);


    if (NULL == Address)
    {
        _REPORT_ERROR (Module, Line, Component,
            ("AcpiUtFree: Trying to delete a NULL address\n"));

        return_VOID;
    }

    DebugBlock = (ACPI_DEBUG_MEM_BLOCK *)
                    (((char *) Address) - sizeof (ACPI_DEBUG_MEM_HEADER));

    AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].TotalFreed++;
    AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].CurrentTotalSize -= DebugBlock->Size;

    AcpiUtDeleteElementFromAllocList (ACPI_MEM_LIST_GLOBAL, DebugBlock,
            Component, Module, Line);
    AcpiOsFree (DebugBlock);

    ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", Address));

    return_VOID;
}
Beispiel #5
0
void *
AcpiUtAllocateObjectDescDbg (
    NATIVE_CHAR             *ModuleName,
    UINT32                  LineNumber,
    UINT32                  ComponentId)
{
    ACPI_OPERAND_OBJECT     *Object;


    FUNCTION_TRACE ("UtAllocateObjectDescDbg");


    Object = AcpiUtAcquireFromCache (ACPI_MEM_LIST_OPERAND);
    if (!Object)
    {
        _REPORT_ERROR (ModuleName, LineNumber, ComponentId,
                        ("Could not allocate an object descriptor\n"));

        return_PTR (NULL);
    }


    /* Mark the descriptor type */

    Object->Common.DataType = ACPI_DESC_TYPE_INTERNAL;

    ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n",
            Object, sizeof (ACPI_OPERAND_OBJECT)));

    return_PTR (Object);
}
Beispiel #6
0
ACPI_STATUS
AcpiUtDeleteElementFromAllocList (
    UINT32                  ListId,
    ACPI_DEBUG_MEM_BLOCK    *Address,
    UINT32                  Component,
    NATIVE_CHAR             *Module,
    UINT32                  Line)
{
    ACPI_MEMORY_LIST        *MemList;


    FUNCTION_TRACE ("UtDeleteElementFromAllocList");


    if (ListId > ACPI_MEM_LIST_MAX)
    {
        return_ACPI_STATUS (AE_BAD_PARAMETER);
    }

    MemList = &AcpiGbl_MemoryLists[ListId];
    if (NULL == MemList->ListHead)
    {
        /* No allocations! */

        _REPORT_ERROR (Module, Line, Component,
                ("UtDeleteElementFromAllocList: Empty allocation list, nothing to free!\n"));

        return_ACPI_STATUS (AE_OK);
    }


    AcpiUtAcquireMutex (ACPI_MTX_MEMORY);

    /* Unlink */

    if (Address->Previous)
    {
        (Address->Previous)->Next = Address->Next;
    }
    else
    {
        MemList->ListHead = Address->Next;
    }

    if (Address->Next)
    {
        (Address->Next)->Previous = Address->Previous;
    }


    /* Mark the segment as deleted */

    MEMSET (&Address->UserSpace, 0xEA, Address->Size);

    ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size %X\n", Address->Size));

    AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
    return_ACPI_STATUS (AE_OK);
}
Beispiel #7
0
void
_cm_free (
	void                    *address,
	u32                     component,
	NATIVE_CHAR             *module,
	u32                     line)
{

	if (NULL == address) {
		_REPORT_ERROR (module, line, component,
			("_Cm_free: Trying to delete a NULL address\n"));

		return;
	}


	acpi_os_free (address);

	return;
}