|
Packit |
857059 |
/* BEGIN_ICS_COPYRIGHT3 ****************************************
|
|
Packit |
857059 |
|
|
Packit |
857059 |
Copyright (c) 2015, Intel Corporation
|
|
Packit |
857059 |
|
|
Packit |
857059 |
Redistribution and use in source and binary forms, with or without
|
|
Packit |
857059 |
modification, are permitted provided that the following conditions are met:
|
|
Packit |
857059 |
|
|
Packit |
857059 |
* Redistributions of source code must retain the above copyright notice,
|
|
Packit |
857059 |
this list of conditions and the following disclaimer.
|
|
Packit |
857059 |
* Redistributions in binary form must reproduce the above copyright
|
|
Packit |
857059 |
notice, this list of conditions and the following disclaimer in the
|
|
Packit |
857059 |
documentation and/or other materials provided with the distribution.
|
|
Packit |
857059 |
* Neither the name of Intel Corporation nor the names of its contributors
|
|
Packit |
857059 |
may be used to endorse or promote products derived from this software
|
|
Packit |
857059 |
without specific prior written permission.
|
|
Packit |
857059 |
|
|
Packit |
857059 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
Packit |
857059 |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
Packit |
857059 |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
Packit |
857059 |
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
|
Packit |
857059 |
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
Packit |
857059 |
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
Packit |
857059 |
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
Packit |
857059 |
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
Packit |
857059 |
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
Packit |
857059 |
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
857059 |
|
|
Packit |
857059 |
** END_ICS_COPYRIGHT3 ****************************************/
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* [ICS VERSION STRING: unknown] */
|
|
Packit |
857059 |
|
|
Packit |
857059 |
#ifndef _IBA_PUBLIC_IRESMGR_H_
|
|
Packit |
857059 |
#define _IBA_PUBLIC_IRESMGR_H_
|
|
Packit |
857059 |
|
|
Packit |
857059 |
#include "iba/public/ilist.h"
|
|
Packit |
857059 |
#include "iba/public/ireqmgr.h"
|
|
Packit |
857059 |
#include "iba/public/iobjmgr.h"
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
#ifdef __cplusplus
|
|
Packit |
857059 |
extern "C"
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
#endif
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* The free pool object provides an asynchronous free pool of available objects.
|
|
Packit |
857059 |
* If no objects are available, it queues a request. A free pool manages
|
|
Packit |
857059 |
* resources but does not create them.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Free pool object definition.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
typedef struct _FREE_POOL
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
/* Available elements in free pool. */
|
|
Packit |
857059 |
STACK m_Stack; /* DO NOT USE!! */
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* Pending requests for elements. */
|
|
Packit |
857059 |
QUEUE m_RequestQueue; /* DO NOT USE!! */
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* Requests are dynamically allocated and added to the stack. */
|
|
Packit |
857059 |
STACK m_FreeRequestStack; /* DO NOT USE!! */
|
|
Packit |
857059 |
|
|
Packit |
857059 |
boolean m_Initialized; /* DO NOT USE!! */
|
|
Packit |
857059 |
|
|
Packit |
857059 |
} FREE_POOL;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Function declarations.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* Create a new free pool. */
|
|
Packit |
857059 |
void
|
|
Packit |
857059 |
FreePoolInitState(
|
|
Packit |
857059 |
IN FREE_POOL* const pFreePool );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
boolean
|
|
Packit |
857059 |
FreePoolInit(
|
|
Packit |
857059 |
IN FREE_POOL* const pFreePool,
|
|
Packit |
857059 |
IN const uint32 MinItems );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
void
|
|
Packit |
857059 |
FreePoolDestroy(
|
|
Packit |
857059 |
IN FREE_POOL* const pFreePool );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* Get/free resources. */
|
|
Packit |
857059 |
boolean
|
|
Packit |
857059 |
FreePoolPut(
|
|
Packit |
857059 |
IN FREE_POOL* const pFreePool,
|
|
Packit |
857059 |
IN void* const pObject );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
boolean
|
|
Packit |
857059 |
FreePoolPutArray(
|
|
Packit |
857059 |
IN FREE_POOL* const pFreePool,
|
|
Packit |
857059 |
IN void* const pArray,
|
|
Packit |
857059 |
IN const uint32 ItemCount,
|
|
Packit |
857059 |
IN const uint32 ItemSize );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
void*
|
|
Packit |
857059 |
FreePoolGet(
|
|
Packit |
857059 |
IN FREE_POOL* const pFreePool);
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* Check the free pool to see if a request can be completed, queue
|
|
Packit |
857059 |
* a request, or get a request that can be completed.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
uint32
|
|
Packit |
857059 |
FreePoolCheck(
|
|
Packit |
857059 |
IN const FREE_POOL* const pFreePool,
|
|
Packit |
857059 |
IN const uint32 Count,
|
|
Packit |
857059 |
IN const boolean PartialOk );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
boolean
|
|
Packit |
857059 |
FreePoolQueueRequest(
|
|
Packit |
857059 |
IN FREE_POOL* const pFreePool,
|
|
Packit |
857059 |
IN const uint32 Count,
|
|
Packit |
857059 |
IN const boolean PartialOk,
|
|
Packit |
857059 |
IN REQ_CALLBACK pfnCallback,
|
|
Packit |
857059 |
IN void* const Context1,
|
|
Packit |
857059 |
IN void* const Context2 );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
boolean
|
|
Packit |
857059 |
FreePoolDequeueRequest(
|
|
Packit |
857059 |
IN FREE_POOL* const pFreePool,
|
|
Packit |
857059 |
OUT REQUEST_OBJECT* const pRequest );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* Return number of objects in the free pool. */
|
|
Packit |
857059 |
uint32
|
|
Packit |
857059 |
FreePoolFreeCount(
|
|
Packit |
857059 |
IN const FREE_POOL* const pFreePool );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* Initialize every object in the resource manager with the specified
|
|
Packit |
857059 |
* function.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
void
|
|
Packit |
857059 |
FreePoolApplyFunc(
|
|
Packit |
857059 |
IN const FREE_POOL* const pFreePool,
|
|
Packit |
857059 |
IN LIST_APPLY_FUNC pfnFunc,
|
|
Packit |
857059 |
IN void* const Context );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* The resource manager object manages the allocation, deallocation, and
|
|
Packit |
857059 |
* distribution of objects.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Resource manager object definition.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
typedef struct _RES_MGR
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
/* Private data structure used by the resource manager object. */
|
|
Packit |
857059 |
/* Users should not access these variables directly. */
|
|
Packit |
857059 |
FREE_POOL m_FreePool; /* DO NOT USE!! */
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* These variables are exposed to the user to allow the memory to be */
|
|
Packit |
857059 |
/* pinned, registered, etc. */
|
|
Packit |
857059 |
uint32 m_ItemCount; /* DO NOT USE!! */
|
|
Packit |
857059 |
void *m_pArray; /* DO NOT USE!! */
|
|
Packit |
857059 |
uint32 m_ArraySize; /* DO NOT USE!! */
|
|
Packit |
857059 |
|
|
Packit |
857059 |
} RES_MGR;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/*
|
|
Packit |
857059 |
* Function declarations.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* Create a new resource manager. */
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* Initializes, Allocates/frees the resources dynamically. */
|
|
Packit |
857059 |
void
|
|
Packit |
857059 |
ResMgrInitState(
|
|
Packit |
857059 |
IN RES_MGR* const pResMgr );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
boolean
|
|
Packit |
857059 |
ResMgrInit(
|
|
Packit |
857059 |
IN RES_MGR* const pResMgr,
|
|
Packit |
857059 |
IN const uint32 ObjectCount,
|
|
Packit |
857059 |
IN uint32 ObjectSize,
|
|
Packit |
857059 |
IN const uint32 ByteAlignment,
|
|
Packit |
857059 |
IN const uint32 AlignmentOffset );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
void
|
|
Packit |
857059 |
ResMgrDestroy(
|
|
Packit |
857059 |
IN RES_MGR* const pResMgr );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* Get/free resources. */
|
|
Packit |
857059 |
boolean
|
|
Packit |
857059 |
ResMgrPut(
|
|
Packit |
857059 |
IN RES_MGR* const pResMgr,
|
|
Packit |
857059 |
IN void* const pObject );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
boolean
|
|
Packit |
857059 |
ResMgrPutArray(
|
|
Packit |
857059 |
IN RES_MGR* const pResMgr,
|
|
Packit |
857059 |
IN void* const pArray,
|
|
Packit |
857059 |
IN const uint32 ItemCount,
|
|
Packit |
857059 |
IN const uint32 ItemSize );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
void*
|
|
Packit |
857059 |
ResMgrGet(
|
|
Packit |
857059 |
IN RES_MGR* const pResMgr );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* Check the free pool to see if a request can be completed, queue
|
|
Packit |
857059 |
* a request, or get a request that can be completed.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
uint32
|
|
Packit |
857059 |
ResMgrCheck(
|
|
Packit |
857059 |
IN const RES_MGR* const pResMgr,
|
|
Packit |
857059 |
IN const uint32 Count,
|
|
Packit |
857059 |
IN const boolean PartialOk );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
boolean
|
|
Packit |
857059 |
ResMgrQueueRequest(
|
|
Packit |
857059 |
IN RES_MGR* const pResMgr,
|
|
Packit |
857059 |
IN const uint32 Count,
|
|
Packit |
857059 |
IN const boolean PartialOk,
|
|
Packit |
857059 |
IN REQ_CALLBACK Callback,
|
|
Packit |
857059 |
IN void* const Context1,
|
|
Packit |
857059 |
IN void* const Context2 );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
boolean
|
|
Packit |
857059 |
ResMgrDequeueRequest(
|
|
Packit |
857059 |
IN RES_MGR* const pResMgr,
|
|
Packit |
857059 |
OUT REQUEST_OBJECT* const pRequest );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* Return number of objects in the free pool. */
|
|
Packit |
857059 |
uint32
|
|
Packit |
857059 |
ResMgrFreeCount(
|
|
Packit |
857059 |
IN const RES_MGR* const pResMgr );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* Initialize every object in the resource manager with the specified
|
|
Packit |
857059 |
* function.
|
|
Packit |
857059 |
*/
|
|
Packit |
857059 |
void
|
|
Packit |
857059 |
ResMgrApplyFunc(
|
|
Packit |
857059 |
IN const RES_MGR* const pResMgr,
|
|
Packit |
857059 |
IN LIST_APPLY_FUNC Func,
|
|
Packit |
857059 |
IN void* const Context );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
#ifdef __cplusplus
|
|
Packit |
857059 |
} /* extern "C" */
|
|
Packit |
857059 |
#endif
|
|
Packit |
857059 |
|
|
Packit |
857059 |
#endif /* _IBA_PUBLIC_IRESMGR_H_ */
|