diff options
author | Simon Que <sque@ti.com> | 2010-03-19 16:55:57 -0600 |
---|---|---|
committer | Hari Kanigeri <h-kanigeri2@ti.com> | 2010-07-09 17:57:31 -0500 |
commit | a017f9f8a2f8c1950086f2eb6f83e52ee41762a3 (patch) | |
tree | d1faef346ee1bc7ff7a986612cf3d875e900cdbb /arch/arm | |
parent | 013cae6745961d2d01939bd75758e410b8fc9aaf (diff) |
SYSLINK: ipc - created heapmemmp module
Created a new heapmemmp module for SysLink-2.0. This module is a
shared memory heap that allows allocation of variable-sized blocks, in
contrast to heapbufmp, which allows fixed-size blocks.
In addition to the new feature of variable-length allocation, heapmemmp also
incorporates generic changes common to all modules in SysLink 2.0 like:
- heapmemmp_module pointer to heapmemmp_state object.
- More user-friendly APIs.
- heapmemmp_open opens by name.
- heapmemmp_open_by_addr opens by shared memory address.
- create() function calls post_init() function at the end.
Signed-off-by: Simon Que <sque@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/plat-omap/include/syslink/heapmemmp.h | 252 | ||||
-rw-r--r-- | arch/arm/plat-omap/include/syslink/heapmemmp_ioctl.h | 243 |
2 files changed, 495 insertions, 0 deletions
diff --git a/arch/arm/plat-omap/include/syslink/heapmemmp.h b/arch/arm/plat-omap/include/syslink/heapmemmp.h new file mode 100644 index 000000000000..bfce85be4b5b --- /dev/null +++ b/arch/arm/plat-omap/include/syslink/heapmemmp.h @@ -0,0 +1,252 @@ +/* + * heapmemmp.h + * + * Heap module manages fixed size buffers that can be used + * in a multiprocessor system with shared memory. + * + * Copyright (C) 2008-2009 Texas Instruments, Inc. + * + * This package is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +#ifndef _HEAPMEMMP_H_ +#define _HEAPMEMMP_H_ + +#include <linux/types.h> +#include <heap.h> +#include <listmp.h> + +/*! + * @def LISTMP_MODULEID + * @brief Unique module ID. + */ +#define HEAPMEMMP_MODULEID (0x4cd7) + +/* + * Creation of Heap Buf succesful. +*/ +#define HEAPMEMMP_CREATED (0x07041776) + +/* + * Version. + */ +#define HEAPMEMMP_VERSION (1) + +/* ============================================================================= + * All success and failure codes for the module + * ============================================================================= + */ + +/*! + * @def HEAPMEMMP_S_BUSY + * @brief The resource is still in use + */ +#define HEAPMEMMP_S_BUSY 2 + +/*! + * @def HEAPMEMMP_S_ALREADYSETUP + * @brief The module has been already setup + */ +#define HEAPMEMMP_S_ALREADYSETUP 1 + +/*! + * @def HEAPMEMMP_S_SUCCESS + * @brief Operation is successful. + */ +#define HEAPMEMMP_S_SUCCESS 0 + +/*! + * @def HEAPMEMMP_E_FAIL + * @brief Generic failure. + */ +#define HEAPMEMMP_E_FAIL -1 + +/*! + * @def HEAPMEMMP_E_INVALIDARG + * @brief Argument passed to function is invalid. + */ +#define HEAPMEMMP_E_INVALIDARG -2 + +/*! + * @def HEAPMEMMP_E_MEMORY + * @brief Operation resulted in memory failure. + */ +#define HEAPMEMMP_E_MEMORY -3 + +/*! + * @def HEAPMEMMP_E_ALREADYEXISTS + * @brief The specified entity already exists. + */ +#define HEAPMEMMP_E_ALREADYEXISTS -4 + +/*! + * @def HEAPMEMMP_E_NOTFOUND + * @brief Unable to find the specified entity. + */ +#define HEAPMEMMP_E_NOTFOUND -5 + +/*! + * @def HEAPMEMMP_E_TIMEOUT + * @brief Operation timed out. + */ +#define HEAPMEMMP_E_TIMEOUT -6 + +/*! + * @def HEAPMEMMP_E_INVALIDSTATE + * @brief Module is not initialized. + */ +#define HEAPMEMMP_E_INVALIDSTATE -7 + +/*! + * @def HEAPMEMMP_E_OSFAILURE + * @brief A failure occurred in an OS-specific call */ +#define HEAPMEMMP_E_OSFAILURE -8 + +/*! + * @def HEAPMEMMP_E_RESOURCE + * @brief Specified resource is not available */ +#define HEAPMEMMP_E_RESOURCE -9 + +/*! + * @def HEAPMEMMP_E_RESTART + * @brief Operation was interrupted. Please restart the operation */ +#define HEAPMEMMP_E_RESTART -10 + + +/* ============================================================================= + * Macros + * ============================================================================= + */ + + +/* ============================================================================= + * Structures & Enums + * ============================================================================= + */ + +/* + * Structure defining config parameters for the HeapBuf module. + */ +struct heapmemmp_config { + u32 max_name_len; /* Maximum length of name */ + u32 max_runtime_entries; /* Maximum number of heapmemmp instances */ + /* that can be created */ +}; + +/* + * Structure defining parameters for the HeapBuf module + */ +struct heapmemmp_params { + char *name; /* Name of this instance */ + u16 region_id; /* Shared region ID */ + void *shared_addr; /* Physical address of the shared memory */ + u32 shared_buf_size; /* Size of shared buffer */ + void *gate; /* GateMP used for critical region management of the */ + /* shared memory */ +}; + +/* + * Stats structure for the getExtendedStats API. + */ +struct heapmemmp_extended_stats { + void *buf; + /* Local address of the shared buffer */ + + u32 size; + /* Size of the shared buffer */ +}; + +/* ============================================================================= + * APIs + * ============================================================================= + */ + +/* + * Function to get default configuration for the heapmemmp module + */ +int heapmemmp_get_config(struct heapmemmp_config *cfgparams); + +/* + * Function to setup the heapmemmp module + */ +int heapmemmp_setup(const struct heapmemmp_config *cfg); + +/* + * Function to destroy the heapmemmp module + */ +int heapmemmp_destroy(void); + +/* Initialize this config-params structure with supplier-specified + * defaults before instance creation + */ +void heapmemmp_params_init(struct heapmemmp_params *params); + +/* + * Creates a new instance of heapmemmp module + */ +void *heapmemmp_create(const struct heapmemmp_params *params); + +/* + * Deletes a instance of heapmemmp module + */ +int heapmemmp_delete(void **handle_ptr); + +/* + * Opens a created instance of heapmemmp module by name + */ +int heapmemmp_open(char *name, void **handle_ptr); + +/* + * Opens a created instance of heapmemmp module by address + */ +int heapmemmp_open_by_addr(void *shared_addr, void **handle_ptr); + +/* + * Closes previously opened/created instance of heapmemmp module + */ +int heapmemmp_close(void **handle_ptr); + +/* + * Returns the amount of shared memory required for creation + * of each instance + */ +int heapmemmp_shared_mem_req(const struct heapmemmp_params *params); + +/* + * Allocate a block + */ +void *heapmemmp_alloc(void *hphandle, u32 size, u32 align); + +/* + * Frees the block to this heapmemmp + */ +int heapmemmp_free(void *hphandle, void *block, u32 size); + +/* + * Get memory statistics + */ +void heapmemmp_get_stats(void *hphandle, struct memory_stats *stats); + +/* + * Indicate whether the heap may block during an alloc or free call + */ +bool heapmemmp_isblocking(void *handle); + +/* + * Get extended statistics + */ +void heapmemmp_get_extended_stats(void *hphandle, + struct heapmemmp_extended_stats *stats); +/* + * Restore an instance to it's original created state. + */ +void heapmemmp_restore(void *handle); + +#endif /* _HEAPMEMMP_H_ */ diff --git a/arch/arm/plat-omap/include/syslink/heapmemmp_ioctl.h b/arch/arm/plat-omap/include/syslink/heapmemmp_ioctl.h new file mode 100644 index 000000000000..f95dad36c45b --- /dev/null +++ b/arch/arm/plat-omap/include/syslink/heapmemmp_ioctl.h @@ -0,0 +1,243 @@ +/* + * heapmemmp_ioctl.h + * + * Heap module manages fixed size buffers that can be used + * in a multiprocessor system with shared memory. + * + * Copyright (C) 2008-2009 Texas Instruments, Inc. + * + * This package is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +#ifndef _HEAPMEMMP_IOCTL_ +#define _HEAPMEMMP_IOCTL_ + +#include <linux/types.h> + +#include <ipc_ioctl.h> +#include <heapmemmp.h> + + +enum CMD_HEAPMEM { + HEAPMEMMP_GETCONFIG = HEAPMEMMP_BASE_CMD, + HEAPMEMMP_SETUP, + HEAPMEMMP_DESTROY, + HEAPMEMMP_PARAMS_INIT, + HEAPMEMMP_CREATE, + HEAPMEMMP_DELETE, + HEAPMEMMP_OPEN, + HEAPMEMMP_OPENBYADDR, + HEAPMEMMP_CLOSE, + HEAPMEMMP_ALLOC, + HEAPMEMMP_FREE, + HEAPMEMMP_SHAREDMEMREQ, + HEAPMEMMP_GETSTATS, + HEAPMEMMP_GETEXTENDEDSTATS, + HEAPMEMMP_RESTORE +}; + +/* + * Command for heapmemmp_get_config + */ +#define CMD_HEAPMEMMP_GETCONFIG _IOWR(IPC_IOC_MAGIC, \ + HEAPMEMMP_GETCONFIG,\ + struct heapmemmp_cmd_args) + +/* + * Command for heapmemmp_setup + */ +#define CMD_HEAPMEMMP_SETUP _IOWR(IPC_IOC_MAGIC, \ + HEAPMEMMP_SETUP, \ + struct heapmemmp_cmd_args) +/* + * Command for heapmemmp_destroy + */ +#define CMD_HEAPMEMMP_DESTROY _IOWR(IPC_IOC_MAGIC, \ + HEAPMEMMP_DESTROY, \ + struct heapmemmp_cmd_args) + +/* + * Command for heapmemmp_prams_init + */ +#define CMD_HEAPMEMMP_PARAMS_INIT _IOWR(IPC_IOC_MAGIC, \ + HEAPMEMMP_PARAMS_INIT, \ + struct heapmemmp_cmd_args) + +/* + * Command for heapmemmp_create + */ +#define CMD_HEAPMEMMP_CREATE _IOWR(IPC_IOC_MAGIC, \ + HEAPMEMMP_CREATE, \ + struct heapmemmp_cmd_args) + +/* + * Command for heapmemmp_delete + */ +#define CMD_HEAPMEMMP_DELETE _IOWR(IPC_IOC_MAGIC, \ + HEAPMEMMP_DELETE, \ + struct heapmemmp_cmd_args) + +/* + * Command for heapmemmp_open + */ +#define CMD_HEAPMEMMP_OPEN _IOWR(IPC_IOC_MAGIC, \ + HEAPMEMMP_OPEN, \ + struct heapmemmp_cmd_args) + +/* + * Command for heapmemmp_open_by_addr + */ +#define CMD_HEAPMEMMP_OPENBYADDR _IOWR(IPC_IOC_MAGIC, \ + HEAPMEMMP_OPENBYADDR, \ + struct heapmemmp_cmd_args) + +/* + * Command for heapmemmp_close + */ +#define CMD_HEAPMEMMP_CLOSE _IOWR(IPC_IOC_MAGIC, \ + HEAPMEMMP_CLOSE, \ + struct heapmemmp_cmd_args) + +/* + * Command for heapmemmp_alloc + */ +#define CMD_HEAPMEMMP_ALLOC _IOWR(IPC_IOC_MAGIC, \ + HEAPMEMMP_ALLOC, \ + struct heapmemmp_cmd_args) + +/* + * Command for heapmemmp_free + */ +#define CMD_HEAPMEMMP_FREE _IOWR(IPC_IOC_MAGIC, \ + HEAPMEMMP_FREE, \ + struct heapmemmp_cmd_args) + +/* + * Command for heapmemmp_shared_mem_req + */ +#define CMD_HEAPMEMMP_SHAREDMEMREQ _IOWR(IPC_IOC_MAGIC, \ + HEAPMEMMP_SHAREDMEMREQ, \ + struct heapmemmp_cmd_args) + +/* + * Command for heapmemmp_get_stats + */ +#define CMD_HEAPMEMMP_GETSTATS _IOWR(IPC_IOC_MAGIC, \ + HEAPMEMMP_GETSTATS, \ + struct heapmemmp_cmd_args) + +/* + * Command for heapmemmp_get_extended_stats + */ +#define CMD_HEAPMEMMP_GETEXTENDEDSTATS _IOWR(IPC_IOC_MAGIC, \ + HEAPMEMMP_GETEXTENDEDSTATS, \ + struct heapmemmp_cmd_args) + +/* + * Command for heapmemmp_restore + */ +#define CMD_HEAPMEMMP_RESTORE _IOWR(IPC_IOC_MAGIC, \ + HEAPMEMMP_RESTORE, \ + struct heapmemmp_cmd_args) + + +/* + * Command arguments for heapmem + */ +union heapmemmp_arg { + struct { + struct heapmemmp_params *params; + } params_init; + + struct { + struct heapmemmp_config *config; + } get_config; + + struct { + struct heapmemmp_config *config; + } setup; + + struct { + void *handle; + struct heapmemmp_params *params; + u32 name_len; + u32 *shared_addr_srptr; + u32 *shared_buf_srptr; + void *knl_gate; + } create; + + struct { + void *handle; + } delete; + + struct { + void *handle; + char *name; + u32 name_len; + } open; + + struct { + void *handle; + u32 *shared_addr_srptr; + } open_by_addr; + + struct { + void *handle; + } close; + + struct { + void *handle; + u32 size; + u32 align; + u32 *block_srptr; + } alloc; + + struct { + void *handle; + u32 *block_srptr; + u32 size; + } free; + + struct { + void *handle; + struct memory_stats *stats; + } get_stats; + + struct { + void *handle; + } restore; + + struct { + void *handle; + struct heapmemmp_extended_stats *stats; + } get_extended_stats; + + struct { + struct heapmemmp_params *params; + u32 *shared_addr_srptr; + u32 bytes; + } shared_mem_req; +}; + +/* + * Command arguments for heapmem + */ +struct heapmemmp_cmd_args{ + union heapmemmp_arg args; + s32 api_status; +}; + +/* + * This ioctl interface for heapmem module + */ +int heapmemmp_ioctl(struct inode *pinode, struct file *filp, + unsigned int cmd, unsigned long args); + +#endif /* _HEAPMEMMP_IOCTL_ */ |