/**
 * @file exo_ral_mem_management.c
 *
 * @brief This file contains abstracted function definitions for memory management.
 *
 * @copyright Copyright 2023 Antaris, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "exo_ral_mem_management.h"
#include "exo_os_common.h"
typedef struct
{
    size_t free_heapsize;
    size_t used_heapsize;
    size_t total_heapsize;
}heap_memory_info_s;


void get_heap_mem_info(heap_memory_info_s *mem_data);

/*!
 *  @brief This function is used for allocating a block of memory in eram
 */
void* ral_malloc_eram(uint32_t  byte_size)
{
	void* ret_ptr =NULL;
	ret_ptr = (void*)ral_common_mem_alloc_eram(byte_size);
    return(ret_ptr);
}

/*!
 *  @brief This function is used for allocating a block of memory
 */
void* ral_malloc(uint32_t  byte_size)
{
	void* ret_ptr =NULL;
	ret_ptr = (void*)ral_common_mem_alloc(byte_size);
    return(ret_ptr);
}

/*!
 *  @brief This API use to release the allocated memory
 */
void ral_free(void* ptr)
{
	ral_common_mem_free(ptr);
}

/*!
 * @brief This API use to load the memory block with given value
 */
void* ral_memset(void *ptr, int val, size_t num_bytes )
{
	return(memset(ptr, val, num_bytes));
}

/*!
 * @brief This API to copy data from one memory location to another
 *        memory location
 */
void* ral_memcpy(void* destination_ptr, const void * src_ptr, size_t num_bytes)
{
	return(memcpy(destination_ptr,src_ptr, num_bytes));
}

/*!
 * @brief This API get the heap memory information
 */
void get_ral_heap_mem_info(ral_heap_memory_info_s *mem_data)
{
#ifndef LINUX_TEMP_PORT
	get_heap_mem_info((heap_memory_info_s*)mem_data);
#endif
}

