Commit e1130f83 authored by Jayan John's avatar Jayan John Committed by Hari Kanigeri

SYSLINK Heapbuf aligned with IPC 50 and Syslink 2_00_00_08 changes

This patch aligns heapbuf code with IPC 50 and Syslink 2_00_00_08 changes.
Signed-off-by: default avatarJayan John <x00jayan@ti.com>
parent e1eddd55
......@@ -23,6 +23,12 @@
#include <heap.h>
#include <listmp.h>
/*!
* @def LISTMP_MODULEID
* @brief Unique module ID.
*/
#define HEAPBUF_MODULEID (0x4cd5)
/*
* Creation of Heap Buf succesful.
*/
......@@ -34,28 +40,52 @@
#define HEAPBUF_VERSION (1)
/*
* Structure defining parameters for the Heap Buf module
* Structure defining config parameters for the HeapBuf module.
*/
struct heapbuf_config {
u32 max_name_len; /* Maximum length of name */
bool use_nameserver; /* To have this module use the NameServer or not */
bool track_max_allocs; /* Track the maximum number of allocated blocks */
};
/*
* Structure defining parameters for the HeapBuf module
*/
struct heapbuf_params {
void *lock_handle;
void *gate;
bool exact; /* Only allocate on exact match of rquested size */
char *name; /* Name when using nameserver */
int resource_id; /* Resource id of the hardware linked list */
bool cache_flag; /* Whether to perform cache coherency calls */
u32 align; /* Alignment (in MAUs, power of 2) of each block */
u32 num_blocks; /* Number of fixed-size blocks */
u32 block_size; /* Size (in MAUs) of each block*/
void *shared_addr; /* Physical address of the shared memory */
u32 shared_addr_size; /* Size of shareAddr */
void *shared_buf; /* Physical address of the shared buffers */
u32 shared_buf_size; /* Size of sharedBuf */
};
/*
* Stats structure for the getExtendedStats API.
*/
struct heapbuf_extended_stats {
u32 max_allocated_blocks;
/* maximum number of blocks allocated from this heap instance */
u32 num_allocated_blocks;
/* total number of blocks currently allocated from this heap instance*/
};
/*
* Function to get default configuration for the heapbuf module
*/
int heapbuf_get_config(struct heap_config *cfgparams);
int heapbuf_get_config(struct heapbuf_config *cfgparams);
/*
* Function to setup the heapbuf module
*/
int heapbuf_setup(const struct heap_config *config);
int heapbuf_setup(const struct heapbuf_config *cfg);
/*
* Function to destroy the heapbuf module
......@@ -75,42 +105,48 @@ void *heapbuf_create(const struct heapbuf_params *params);
/*
* Deletes a instance of heapbuf module
*/
int heapbuf_delete(void **handle);
int heapbuf_delete(void **handle_ptr);
/*
* Opens a created instance of heapbuf module
*/
int heapbuf_open(void **handle, const struct heapbuf_params *params);
int heapbuf_open(void **handle_ptr, struct heapbuf_params *params);
/*
* Closes previously opened/created instance of heapbuf module
*/
int heapbuf_close(void *handle);
int heapbuf_close(void *handle_ptr);
/*
* Returns the amount of shared memory required for creation
* of each instance
*/
int heapbuf_shared_memreq(const struct heapbuf_params *params);
int heapbuf_shared_memreq(const struct heapbuf_params *params, u32 *buf_size);
/*
* Allocate a block
*/
void *heapbuf_alloc(void *handle, u32 size, u32 align);
void *heapbuf_alloc(void *hphandle, u32 size, u32 align);
/*
* Frees the block to this heapbuf
*/
int heapbuf_free(void *handle, void *block, u32 size);
int heapbuf_free(void *hphandle, void *block, u32 size);
/*
* Get memory statistics
*/
int heapbuf_get_stats(void *handle, struct memory_stats *stats);
int heapbuf_get_stats(void *hphandle, struct memory_stats *stats);
/*
* Indicate whether the heap may block during an alloc or free call
*/
bool heapbuf_isblocking(void *handle);
/*
* Get extended statistics
*/
int heapbuf_get_extended_stats(void *handle, struct heap_extended_stats *stats);
#endif /* _HEAPBUF_H_ */
int heapbuf_get_extended_stats(void *hphandle,
struct heapbuf_extended_stats *stats);
#endif /* _HEAPBUF_H_ */
......@@ -135,11 +135,11 @@ union heapbuf_arg {
} params_init;
struct {
struct heap_config *config;
struct heapbuf_config *config;
} get_config;
struct {
struct heap_config *config;
struct heapbuf_config *config;
} setup;
struct {
......@@ -182,12 +182,13 @@ union heapbuf_arg {
struct {
void *handle;
struct heap_extended_stats *stats;
struct heapbuf_extended_stats *stats;
} get_extended_stats;
struct {
void *handle;
struct heapbuf_params *params;
u32 buf_size;
u32 bytes;
} shared_memreq;
};
......
This diff is collapsed.
......@@ -252,7 +252,8 @@ static int heapbuf_ioctl_shared_memreq(struct heapbuf_cmd_args *cargs)
goto exit;
}
bytes = heapbuf_shared_memreq(&params);
bytes = heapbuf_shared_memreq(&params,
&cargs->args.shared_memreq.buf_size);
cargs->args.shared_memreq.bytes = bytes;
cargs->api_status = 0;
......@@ -268,13 +269,13 @@ exit:
*/
static int heapbuf_ioctl_get_config(struct heapbuf_cmd_args *cargs)
{
struct heap_config config;
struct heapbuf_config config;
s32 status = 0;
ulong size;
cargs->api_status = heapbuf_get_config(&config);
size = copy_to_user(cargs->args.get_config.config, &config,
sizeof(struct heap_config));
sizeof(struct heapbuf_config));
if (size)
status = -EFAULT;
......@@ -288,12 +289,12 @@ static int heapbuf_ioctl_get_config(struct heapbuf_cmd_args *cargs)
*/
static int heapbuf_ioctl_setup(struct heapbuf_cmd_args *cargs)
{
struct heap_config config;
struct heapbuf_config config;
s32 status = 0;
ulong size;
size = copy_from_user(&config, cargs->args.setup.config,
sizeof(struct heap_config));
sizeof(struct heapbuf_config));
if (size) {
status = -EFAULT;
goto exit;
......@@ -348,7 +349,7 @@ exit:
*/
static int heapbuf_ioctl_get_extended_stats(struct heapbuf_cmd_args *cargs)
{
struct heap_extended_stats stats;
struct heapbuf_extended_stats stats;
s32 status = 0;
ulong size;
......@@ -358,7 +359,7 @@ static int heapbuf_ioctl_get_extended_stats(struct heapbuf_cmd_args *cargs)
goto exit;
size = copy_to_user(cargs->args.get_extended_stats.stats, &stats,
sizeof(struct heap_extended_stats));
sizeof(struct heapbuf_extended_stats));
if (size)
status = -EFAULT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment