1 /* 2 * Copyright (c) 2015-2017, Intel Corporation 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included 12 * in all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 21 */ 22 //! 23 //! \file mhw_memory_pool.h 24 //! \brief This modules implements simple memory pool infrastructure for MHW 25 //! 26 #ifndef __MHW_MEMORY_POOL_H__ 27 #define __MHW_MEMORY_POOL_H__ 28 29 #include "mos_os.h" 30 31 typedef struct _MHW_MEMORY_POOL_ENTRY *PMHW_MEMORY_POOL_ENTRY; 32 typedef struct MHW_MEMORY_POOL *PMHW_MEMORY_POOL; 33 34 struct MHW_MEMORY_POOL 35 { 36 37 PMHW_MEMORY_POOL_ENTRY m_pFirst; //!< First pool 38 PMHW_MEMORY_POOL_ENTRY m_pLast; //!< Last pool 39 uint32_t m_dwCount; //!< Number of pools 40 uint32_t m_dwSize; //!< Total memory in all pool objects 41 uint32_t m_dwObjSize; //!< Object size 42 uint32_t m_dwObjAlignment; //!< Object alignment 43 uint32_t m_dwObjCount; //!< Total number of objects in all pools 44 45 //! 46 //! \brief Constructor of MHW_MEMORY_POOL 47 //! \details Constructor of MHW_BLOCK_MANAGER which initializes all members 48 //! \param [in] dwObjSize 49 //! Size of object 50 //! \param [in] dwObjAlignment 51 //! Alignment of object 52 //! 53 MHW_MEMORY_POOL(uint32_t dwObjSize, uint32_t dwObjAlignment); 54 55 //! 56 //! \brief Destructor of MHW_MEMORY_POOL 57 //! \details Destructor of MHW_MEMORY_POOL which releases all the elements in the list 58 //! 59 ~MHW_MEMORY_POOL(); 60 61 //! 62 //! \brief Allocate objects 63 //! \details Allocate objects and insert them into list 64 //! \param [in] dwObjCount 65 //! Count of objects need to be allocated 66 //! 67 void *Allocate(uint32_t dwObjCount); 68 69 } ; 70 71 #endif // __MHW_MEMORY_POOL_H__ 72