2018-03-07 20:57:14 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
|
|
|
*
|
2018-05-26 01:49:13 +08:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2018-03-07 20:57:14 +08:00
|
|
|
*/
|
|
|
|
|
2018-09-29 15:46:27 +08:00
|
|
|
#ifndef MEM_MGT_H
|
|
|
|
#define MEM_MGT_H
|
2018-03-07 20:57:14 +08:00
|
|
|
|
|
|
|
/* Macros */
|
2018-07-02 14:05:58 +08:00
|
|
|
#define BITMAP_WORD_SIZE 32U
|
2018-03-07 20:57:14 +08:00
|
|
|
|
|
|
|
struct mem_pool {
|
|
|
|
void *start_addr; /* Start Address of Memory Pool */
|
|
|
|
spinlock_t spinlock; /* To protect Memory Allocation */
|
|
|
|
uint32_t size; /* Size of Memory Pool in Bytes */
|
|
|
|
uint32_t buff_size; /* Size of one Buffer in Bytes */
|
|
|
|
uint32_t total_buffs; /* Total Buffers in Memory Pool */
|
|
|
|
uint32_t bmp_size; /* Size of Bitmap Array */
|
|
|
|
uint32_t *bitmap; /* Pointer to allocation bitmap */
|
|
|
|
uint32_t *contiguity_bitmap; /* Pointer to contiguity bitmap */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* APIs exposing memory allocation/deallocation abstractions */
|
2018-12-08 00:06:59 +08:00
|
|
|
void *malloc(uint32_t num_bytes);
|
|
|
|
void *calloc(uint32_t num_elements, uint32_t element_size);
|
2018-10-23 11:45:29 +08:00
|
|
|
void free(const void *ptr);
|
2018-03-07 20:57:14 +08:00
|
|
|
|
2018-09-29 15:46:27 +08:00
|
|
|
#endif /* MEM_MGT_H */
|