/* * Copyright (c) 2012-2013, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** ============================================================================ * @file HeapBufMP.h * * @brief Multi-processor fixed-size buffer heap implementation * * Heap implementation that manages fixed size buffers that can be used * in a multiprocessor system with shared memory. * * The HeapBufMP manager provides functions to allocate and free storage from a * heap of type HeapBufMP which inherits from IHeap. HeapBufMP manages a single * fixed-size buffer, split into equally sized allocatable blocks. * * The HeapBufMP manager is intended as a very fast memory * manager which can only allocate blocks of a single size. It is ideal for * managing a heap that is only used for allocating a single type of object, * or for objects that have very similar sizes. * * The HeapBufMP module uses a NameServer instance to * store instance information when an instance is created. The name supplied * must be unique for all HeapBufMP instances. * * The #HeapBufMP_create call initializes the shared memory as needed. Once an * instance is created, a #HeapBufMP_open can be performed. The * open is used to gain access to the same HeapBufMP instance. * Generally an instance is created on one processor and opened on the * other processor(s). * * The open returns a HeapBufMP instance handle like the create, * however the open does not modify the shared memory. * * The HeapBufMP header should be included in an application as follows: * @code * #include * @endcode * * @version 0.00.01 */ #ifndef ti_ipc_HeapBufMP__include #define ti_ipc_HeapBufMP__include #if defined (__cplusplus) extern "C" { #endif #include /* ============================================================================= * All success and failure codes for the module * ============================================================================= */ /*! * @def HeapBufMP_S_BUSY * @brief The resource is still in use */ #define HeapBufMP_S_BUSY 2 /*! * @def HeapBufMP_S_ALREADYSETUP * @brief The module has been already setup */ #define HeapBufMP_S_ALREADYSETUP 1 /*! * @def HeapBufMP_S_SUCCESS * @brief Operation is successful. */ #define HeapBufMP_S_SUCCESS 0 /*! * @def HeapBufMP_E_FAIL * @brief Generic failure. */ #define HeapBufMP_E_FAIL -1 /*! * @def HeapBufMP_E_INVALIDARG * @brief Argument passed to function is invalid. */ #define HeapBufMP_E_INVALIDARG -2 /*! * @def HeapBufMP_E_MEMORY * @brief Operation resulted in memory failure. */ #define HeapBufMP_E_MEMORY -3 /*! * @def HeapBufMP_E_ALREADYEXISTS * @brief The specified entity already exists. */ #define HeapBufMP_E_ALREADYEXISTS -4 /*! * @def HeapBufMP_E_NOTFOUND * @brief Unable to find the specified entity. */ #define HeapBufMP_E_NOTFOUND -5 /*! * @def HeapBufMP_E_TIMEOUT * @brief Operation timed out. */ #define HeapBufMP_E_TIMEOUT -6 /*! * @def HeapBufMP_E_INVALIDSTATE * @brief Module is not initialized. */ #define HeapBufMP_E_INVALIDSTATE -7 /*! * @def HeapBufMP_E_OSFAILURE * @brief A failure occurred in an OS-specific call */ #define HeapBufMP_E_OSFAILURE -8 /*! * @def HeapBufMP_E_RESOURCE * @brief Specified resource is not available */ #define HeapBufMP_E_RESOURCE -9 /*! * @def HeapBufMP_E_RESTART * @brief Operation was interrupted. Please restart the operation */ #define HeapBufMP_E_RESTART -10 /* ============================================================================= * Structures & Enums * ============================================================================= */ /*! * @brief HeapBufMP_Handle type */ typedef struct HeapBufMP_Object *HeapBufMP_Handle; /*! * @brief Structure defining parameters for the HeapBufMP module. */ typedef struct HeapBufMP_Params { String name; /*!< Name of this instance. * * The name (if not NULL) must be unique among all HeapBufMP * instances in the entire system. When creating a new * heap, it is necessary to supply an instance name. * * The name does not have to be persistent. The supplied string is copied * into persistent memory. */ UInt16 regionId; /*!< Shared region ID * * The index corresponding to the shared region from which shared memory * will be allocated. */ /*! @cond */ Ptr sharedAddr; /*!< Physical address of the shared memory * * This value can be left as 'null' unless it is required to place the * heap at a specific location in shared memory. If sharedAddr is null, * then shared memory for a new instance will be allocated from the * heap belonging to the region identified by #HeapBufMP_Params::regionId. */ /*! @endcond */ SizeT blockSize; /*!< Size (in MAUs) of each block. * * HeapBufMP will round the blockSize up to the nearest multiple of the * alignment, so the actual blockSize may be larger. When creating a * HeapBufMP dynamically, this needs to be taken into account to determine * the proper buffer size to pass in. * * Required parameter. * * The default size of the blocks is 0 MAUs. */ UInt numBlocks; /*!