2019-06-02 03:14:06 +08:00
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
//
|
|
|
|
// Copyright(c) 2018 Intel Corporation. All rights reserved.
|
|
|
|
//
|
|
|
|
// Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
|
|
|
|
// Liam Girdwood <liam.r.girdwood@linux.intel.com>
|
|
|
|
// Keyon Jie <yang.jie@linux.intel.com>
|
|
|
|
// Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
|
2018-06-01 10:29:05 +08:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
2018-12-14 05:24:32 +08:00
|
|
|
#include <malloc.h>
|
2019-07-17 02:31:41 +08:00
|
|
|
#include <sof/lib/alloc.h>
|
2020-03-20 01:34:36 +08:00
|
|
|
#include <sof/lib/mm_heap.h>
|
2019-04-29 18:32:03 +08:00
|
|
|
#include "testbench/common_test.h"
|
2018-06-01 10:29:05 +08:00
|
|
|
|
|
|
|
/* testbench mem alloc definition */
|
|
|
|
|
2020-03-23 19:12:33 +08:00
|
|
|
void *rmalloc(enum mem_zone zone, uint32_t flags, uint32_t caps, size_t bytes)
|
2018-06-01 10:29:05 +08:00
|
|
|
{
|
|
|
|
return malloc(bytes);
|
|
|
|
}
|
|
|
|
|
2020-03-23 19:12:33 +08:00
|
|
|
void *rzalloc(enum mem_zone zone, uint32_t flags, uint32_t caps, size_t bytes)
|
2018-06-01 10:29:05 +08:00
|
|
|
{
|
2018-06-28 11:57:39 +08:00
|
|
|
return calloc(bytes, 1);
|
2018-06-01 10:29:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void rfree(void *ptr)
|
|
|
|
{
|
|
|
|
free(ptr);
|
|
|
|
}
|
|
|
|
|
2020-03-23 19:12:33 +08:00
|
|
|
void *rballoc_align(uint32_t flags, uint32_t caps, size_t bytes,
|
|
|
|
uint32_t alignment)
|
2018-06-01 10:29:05 +08:00
|
|
|
{
|
|
|
|
return malloc(bytes);
|
|
|
|
}
|
2018-12-14 05:24:32 +08:00
|
|
|
|
2020-03-23 19:12:33 +08:00
|
|
|
void *rbrealloc_align(void *ptr, uint32_t flags, uint32_t caps, size_t bytes,
|
2020-04-07 01:00:32 +08:00
|
|
|
size_t old_bytes, uint32_t alignment)
|
2019-06-12 21:40:43 +08:00
|
|
|
{
|
|
|
|
return realloc(ptr, bytes);
|
|
|
|
}
|
|
|
|
|
2018-12-14 05:24:32 +08:00
|
|
|
void heap_trace(struct mm_heap *heap, int size)
|
|
|
|
{
|
|
|
|
malloc_info(0, stdout);
|
|
|
|
}
|
|
|
|
|
|
|
|
void heap_trace_all(int force)
|
|
|
|
{
|
|
|
|
heap_trace(NULL, 0);
|
|
|
|
}
|