|
Packit |
857059 |
/* BEGIN_ICS_COPYRIGHT5 ****************************************
|
|
Packit |
857059 |
|
|
Packit |
857059 |
Copyright (c) 2015-2017, 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_COPYRIGHT5 ****************************************/
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/***********************************************************************
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* FILE NAME
|
|
Packit |
857059 |
* vs_pool_common.c
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* DESCRIPTION
|
|
Packit |
857059 |
* This file contains vs_pool common routines.
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* DATA STRUCTURES
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* FUNCTIONS
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* DEPENDENCIES
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* HISTORY
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* NAME DATE REMARKS
|
|
Packit |
857059 |
* DKJ 03/06/02 Initial creation of file.
|
|
Packit |
857059 |
* DKJ 03/26/02 LINT cleanup
|
|
Packit |
857059 |
* DKJ 04/01/02 PR1676. OS API 2.0g updates
|
|
Packit |
857059 |
***********************************************************************/
|
|
Packit |
857059 |
#include <cs_g.h>
|
|
Packit |
857059 |
#include "cs_log.h"
|
|
Packit |
857059 |
#define function __FUNCTION__
|
|
Packit |
857059 |
#ifdef LOCAL_MOD_ID
|
|
Packit |
857059 |
#undef LOCAL_MOD_ID
|
|
Packit |
857059 |
#endif
|
|
Packit |
857059 |
#define LOCAL_MOD_ID VIEO_CS_MOD_ID
|
|
Packit |
857059 |
extern Status_t vs_implpool_create (Pool_t *, uint32_t,
|
|
Packit |
857059 |
unsigned char *, void *, size_t);
|
|
Packit |
857059 |
extern Status_t vs_implpool_delete (Pool_t *);
|
|
Packit |
857059 |
extern Status_t vs_implpool_alloc (Pool_t *, size_t, void **);
|
|
Packit |
857059 |
extern Status_t vs_implpool_free (Pool_t *, void *);
|
|
Packit |
857059 |
extern Status_t vs_implpool_size (Pool_t *, uint64_t *);
|
|
Packit |
857059 |
|
|
Packit |
857059 |
#define VSPOOL_MAGIC ((uint32_t) 0xDCADFEEDU)
|
|
Packit |
857059 |
/**********************************************************************
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* FUNCTION
|
|
Packit |
857059 |
* vs_pool_create
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* DESCRIPTION
|
|
Packit |
857059 |
* Does fundamental common validation for vs_pool_create
|
|
Packit |
857059 |
* parameters and invokes environment specific implmentation.
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* INPUTS
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* OUTPUTS
|
|
Packit |
857059 |
* Status_t - On success VSTATUS_OK is returned, otherwise
|
|
Packit |
857059 |
* the cause of the error.
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* HISTORY
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* NAME DATE REMARKS
|
|
Packit |
857059 |
* DKJ 03/07/02 Initial creation of function.
|
|
Packit |
857059 |
* DKJ 03/21/02 Updated prototype
|
|
Packit |
857059 |
**********************************************************************/
|
|
Packit |
857059 |
Status_t
|
|
Packit |
857059 |
vs_pool_create (Pool_t * handle, uint32_t options,
|
|
Packit |
857059 |
unsigned char * name, void *address, size_t size)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
Status_t rc;
|
|
Packit |
857059 |
size_t namesize;
|
|
Packit |
857059 |
const uint32_t valid_options = 0;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
IB_ENTER (function, (unint) handle, options, (unint) address,
|
|
Packit |
857059 |
(uint32_t) size);
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if (handle == 0)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
IB_LOG_ERROR0 ("handle is null");
|
|
Packit |
857059 |
IB_EXIT (function, VSTATUS_ILLPARM);
|
|
Packit |
857059 |
return VSTATUS_ILLPARM;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
(void) memset (handle, 0, sizeof (Pool_t));
|
|
Packit |
857059 |
|
|
Packit |
857059 |
#if USE_POOL_LOCK
|
|
Packit |
857059 |
rc = vs_lock_init (&handle->lock, VLOCK_LOCKED, VLOCK_THREAD);
|
|
Packit |
857059 |
if (rc != VSTATUS_OK)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
IB_LOG_ERRORRC("vs_lock_init failed rc:", rc);
|
|
Packit |
857059 |
IB_EXIT (function, VSTATUS_NOMEM);
|
|
Packit |
857059 |
return VSTATUS_NOMEM;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
#endif /* USE_POOL_LOCK */
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if (name == 0)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
#if USE_POOL_LOCK
|
|
Packit |
857059 |
(void) vs_unlock (&handle->lock);
|
|
Packit |
857059 |
(void) vs_lock_delete (&handle->lock);
|
|
Packit |
857059 |
#endif /* USE_POOL_LOCK */
|
|
Packit |
857059 |
IB_LOG_ERROR0 ("name is null");
|
|
Packit |
857059 |
IB_EXIT (function, VSTATUS_ILLPARM);
|
|
Packit |
857059 |
return VSTATUS_ILLPARM;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
for (namesize = (size_t) 0U; namesize < sizeof (handle->name); namesize++)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
handle->name[namesize] = name[namesize];
|
|
Packit |
857059 |
if (name[namesize] == (unsigned char) 0x00U)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
break;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if (namesize >= sizeof (handle->name))
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
#if USE_POOL_LOCK
|
|
Packit |
857059 |
(void) vs_unlock (&handle->lock);
|
|
Packit |
857059 |
(void) vs_lock_delete (&handle->lock);
|
|
Packit |
857059 |
#endif /* USE_POOL_LOCK */
|
|
Packit |
857059 |
IB_LOG_ERROR0 ("name doesn't contain a terminator");
|
|
Packit |
857059 |
IB_EXIT (function, VSTATUS_ILLPARM);
|
|
Packit |
857059 |
return VSTATUS_ILLPARM;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if ((options & ~valid_options) != (uint32_t) 0x00U)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
#if USE_POOL_LOCK
|
|
Packit |
857059 |
(void) vs_unlock (&handle->lock);
|
|
Packit |
857059 |
(void) vs_lock_delete (&handle->lock);
|
|
Packit |
857059 |
#endif /* USE_POOL_LOCK */
|
|
Packit |
857059 |
IB_LOG_ERROR ("Invalid options specified: ", options);
|
|
Packit |
857059 |
IB_EXIT (function, VSTATUS_ILLPARM);
|
|
Packit |
857059 |
return VSTATUS_ILLPARM;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
handle->options = options;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if (size == (size_t) 0x00U)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
#if USE_POOL_LOCK
|
|
Packit |
857059 |
(void) vs_unlock (&handle->lock);
|
|
Packit |
857059 |
(void) vs_lock_delete (&handle->lock);
|
|
Packit |
857059 |
#endif /* USE_POOL_LOCK */
|
|
Packit |
857059 |
IB_LOG_ERROR0 ("Pool size is zero");
|
|
Packit |
857059 |
IB_EXIT (function, VSTATUS_ILLPARM);
|
|
Packit |
857059 |
return VSTATUS_ILLPARM;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
#ifdef __VXWORKS__
|
|
Packit |
857059 |
/* cap size on VxWorks only */
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if (size > (size_t) 0xFFFFFFF0U)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
#if USE_POOL_LOCK
|
|
Packit |
857059 |
(void) vs_unlock (&handle->lock);
|
|
Packit |
857059 |
(void) vs_lock_delete (&handle->lock);
|
|
Packit |
857059 |
#endif /* USE_POOL_LOCK */
|
|
Packit |
857059 |
IB_LOG_ERROR ("Pool size is too big: high:", (uint32_t) (size));
|
|
Packit |
857059 |
IB_LOG_ERROR ("Pool size is too big: low:", (uint32_t) (size));
|
|
Packit |
857059 |
IB_EXIT (function, VSTATUS_ILLPARM);
|
|
Packit |
857059 |
return VSTATUS_ILLPARM;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
#endif
|
|
Packit |
857059 |
|
|
Packit |
857059 |
handle->pagesize = vs_pool_page_size ();
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if ((options & VMEM_PAGE) == VMEM_PAGE)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
if (size < handle->pagesize)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
#if USE_POOL_LOCK
|
|
Packit |
857059 |
(void) vs_unlock (&handle->lock);
|
|
Packit |
857059 |
(void) vs_lock_delete (&handle->lock);
|
|
Packit |
857059 |
#endif /* USE_POOL_LOCK */
|
|
Packit |
857059 |
IB_LOG_ERROR ("size is less than pagesize:", size);
|
|
Packit |
857059 |
IB_EXIT (function, VSTATUS_NOMEM);
|
|
Packit |
857059 |
return VSTATUS_NOMEM;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
rc = vs_implpool_create (handle, options, name, address, size);
|
|
Packit |
857059 |
if (rc == VSTATUS_OK)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
handle->magic = VSPOOL_MAGIC;
|
|
Packit |
857059 |
#if USE_POOL_LOCK
|
|
Packit |
857059 |
(void) vs_unlock (&handle->lock);
|
|
Packit |
857059 |
#endif /* USE_POOL_LOCK */
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
else
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
#if USE_POOL_LOCK
|
|
Packit |
857059 |
(void) vs_unlock (&handle->lock);
|
|
Packit |
857059 |
(void) vs_lock_delete (&handle->lock);
|
|
Packit |
857059 |
#endif /* USE_POOL_LOCK */
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
IB_EXIT (function, rc);
|
|
Packit |
857059 |
return rc;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/**********************************************************************
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* FUNCTION
|
|
Packit |
857059 |
* vs_pool_delete
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* DESCRIPTION
|
|
Packit |
857059 |
* Does fundamental common validation for vs_pool_delete
|
|
Packit |
857059 |
* parameters and invokes environment specific implmentation.
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* INPUTS
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* OUTPUTS
|
|
Packit |
857059 |
* Status_t - On success VSTATUS_OK is returned, otherwise
|
|
Packit |
857059 |
* the cause of the error.
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* HISTORY
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* NAME DATE REMARKS
|
|
Packit |
857059 |
* DKJ 03/07/02 Initial creation of function.
|
|
Packit |
857059 |
**********************************************************************/
|
|
Packit |
857059 |
Status_t
|
|
Packit |
857059 |
vs_pool_delete (Pool_t * handle)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
Status_t rc;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
IB_ENTER (function, (unint) handle, (uint32_t) 0U, (uint32_t) 0U,
|
|
Packit |
857059 |
(uint32_t) 0U);
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if (handle == 0)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
IB_LOG_ERROR0 ("handle is null");
|
|
Packit |
857059 |
IB_EXIT (function, VSTATUS_ILLPARM);
|
|
Packit |
857059 |
return VSTATUS_ILLPARM;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if (handle->magic != VSPOOL_MAGIC)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
IB_LOG_ERRORX ("invalid handle magic:", handle->magic);
|
|
Packit |
857059 |
IB_EXIT (function, VSTATUS_ILLPARM);
|
|
Packit |
857059 |
return VSTATUS_ILLPARM;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
#if USE_POOL_LOCK
|
|
Packit |
857059 |
rc = vs_lock (&handle->lock);
|
|
Packit |
857059 |
if (rc != VSTATUS_OK)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
IB_LOG_ERRORRC("vs_lock failed rc:", rc);
|
|
Packit |
857059 |
IB_EXIT (function, VSTATUS_NXIO);
|
|
Packit |
857059 |
return VSTATUS_NXIO;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
#endif /* USE_POOL_LOCK */
|
|
Packit |
857059 |
|
|
Packit |
857059 |
rc = vs_implpool_delete (handle);
|
|
Packit |
857059 |
if (rc == VSTATUS_OK)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
handle->magic = ~VSPOOL_MAGIC;
|
|
Packit |
857059 |
#if USE_POOL_LOCK
|
|
Packit |
857059 |
(void) vs_unlock (&handle->lock);
|
|
Packit |
857059 |
(void) vs_lock_delete (&handle->lock);
|
|
Packit |
857059 |
#endif /* USE_POOL_LOCK */
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
else
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
#if USE_POOL_LOCK
|
|
Packit |
857059 |
(void) vs_unlock (&handle->lock);
|
|
Packit |
857059 |
#endif /* USE_POOL_LOCK */
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
(void) memset (handle, 0, sizeof (Pool_t));
|
|
Packit |
857059 |
|
|
Packit |
857059 |
IB_EXIT (function, rc);
|
|
Packit |
857059 |
return rc;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/**********************************************************************
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* FUNCTION
|
|
Packit |
857059 |
* vs_pool_alloc
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* DESCRIPTION
|
|
Packit |
857059 |
* Does fundamental common validation for vs_pool_alloc
|
|
Packit |
857059 |
* parameters and invokes environment specific implmentation.
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* INPUTS
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* OUTPUTS
|
|
Packit |
857059 |
* Status_t - On success VSTATUS_OK is returned, otherwise
|
|
Packit |
857059 |
* the cause of the error.
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* HISTORY
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* NAME DATE REMARKS
|
|
Packit |
857059 |
* DKJ 03/07/02 Initial creation of function.
|
|
Packit |
857059 |
**********************************************************************/
|
|
Packit |
857059 |
Status_t
|
|
Packit |
857059 |
vs_pool_alloc (Pool_t * handle, size_t length, void **loc)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
Status_t rc;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
IB_ENTER (function, (unint) handle, (uint32_t) length, (unint) loc,
|
|
Packit |
857059 |
(uint32_t) 0U);
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if (handle == 0)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
IB_LOG_ERROR0 ("handle is null");
|
|
Packit |
857059 |
IB_EXIT (function, VSTATUS_ILLPARM);
|
|
Packit |
857059 |
return VSTATUS_ILLPARM;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if (handle->magic != VSPOOL_MAGIC)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
IB_LOG_ERRORX ("invalid handle magic:", handle->magic);
|
|
Packit |
857059 |
IB_EXIT (function, VSTATUS_ILLPARM);
|
|
Packit |
857059 |
return VSTATUS_ILLPARM;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if (loc == 0)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
IB_LOG_ERROR0 ("loc is null");
|
|
Packit |
857059 |
IB_EXIT (function, VSTATUS_ILLPARM);
|
|
Packit |
857059 |
return VSTATUS_ILLPARM;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if (length == (size_t) 0x00U)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
IB_LOG_ERROR0 ("length is zero");
|
|
Packit |
857059 |
IB_EXIT (function, VSTATUS_ILLPARM);
|
|
Packit |
857059 |
return VSTATUS_ILLPARM;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
#if USE_POOL_LOCK
|
|
Packit |
857059 |
rc = vs_lock (&handle->lock);
|
|
Packit |
857059 |
if (rc != VSTATUS_OK)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
IB_LOG_ERRORRC("vs_lock failed rc:", rc);
|
|
Packit |
857059 |
IB_EXIT (function, VSTATUS_NXIO);
|
|
Packit |
857059 |
return VSTATUS_NXIO;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
#endif /* USE_POOL_LOCK */
|
|
Packit |
857059 |
|
|
Packit |
857059 |
rc = vs_implpool_alloc (handle, length, loc);
|
|
Packit |
857059 |
|
|
Packit |
857059 |
#if USE_POOL_LOCK
|
|
Packit |
857059 |
(void) vs_unlock (&handle->lock);
|
|
Packit |
857059 |
#endif /* USE_POOL_LOCK */
|
|
Packit |
857059 |
IB_EXIT (function, rc);
|
|
Packit |
857059 |
return rc;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/**********************************************************************
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* FUNCTION
|
|
Packit |
857059 |
* vs_pool_free
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* DESCRIPTION
|
|
Packit |
857059 |
* Does fundamental common validation for vs_pool_free
|
|
Packit |
857059 |
* parameters and invokes environment specific implmentation.
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* INPUTS
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* OUTPUTS
|
|
Packit |
857059 |
* Status_t - On success VSTATUS_OK is returned, otherwise
|
|
Packit |
857059 |
* the cause of the error.
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* HISTORY
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* NAME DATE REMARKS
|
|
Packit |
857059 |
* DKJ 03/07/02 Initial creation of function.
|
|
Packit |
857059 |
**********************************************************************/
|
|
Packit |
857059 |
Status_t
|
|
Packit |
857059 |
vs_pool_free (Pool_t * handle, void *loc)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
Status_t rc;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
IB_ENTER (function, (unint) handle, (unint) loc, (uint32_t) 0U,
|
|
Packit |
857059 |
(uint32_t) 0U);
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if (handle == 0)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
IB_LOG_ERROR0 ("handle is null");
|
|
Packit |
857059 |
IB_EXIT (function, VSTATUS_ILLPARM);
|
|
Packit |
857059 |
return VSTATUS_ILLPARM;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if (handle->magic != VSPOOL_MAGIC)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
IB_LOG_ERRORX ("invalid handle magic:", handle->magic);
|
|
Packit |
857059 |
IB_EXIT (function, VSTATUS_ILLPARM);
|
|
Packit |
857059 |
return VSTATUS_ILLPARM;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if (loc == 0)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
IB_LOG_ERROR0 ("loc is null");
|
|
Packit |
857059 |
IB_EXIT (function, VSTATUS_ILLPARM);
|
|
Packit |
857059 |
return VSTATUS_ILLPARM;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
#if USE_POOL_LOCK
|
|
Packit |
857059 |
rc = vs_lock (&handle->lock);
|
|
Packit |
857059 |
if (rc != VSTATUS_OK)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
IB_LOG_ERRORRC("vs_lock failed rc:", rc);
|
|
Packit |
857059 |
IB_EXIT (function, VSTATUS_NXIO);
|
|
Packit |
857059 |
return VSTATUS_NXIO;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
#endif /* USE_POOL_LOCK */
|
|
Packit |
857059 |
|
|
Packit |
857059 |
rc = vs_implpool_free (handle, loc);
|
|
Packit |
857059 |
|
|
Packit |
857059 |
#if USE_POOL_LOCK
|
|
Packit |
857059 |
(void) vs_unlock (&handle->lock);
|
|
Packit |
857059 |
#endif /* USE_POOL_LOCK */
|
|
Packit |
857059 |
IB_EXIT (function, rc);
|
|
Packit |
857059 |
return rc;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/**********************************************************************
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* FUNCTION
|
|
Packit |
857059 |
* vs_pool_size
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* DESCRIPTION
|
|
Packit |
857059 |
* Does fundamental common validation for vs_pool_size
|
|
Packit |
857059 |
* parameters and invokes environment specific implmentation.
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* INPUTS
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* OUTPUTS
|
|
Packit |
857059 |
* number of bytes allocated from pool.
|
|
Packit |
857059 |
**********************************************************************/
|
|
Packit |
857059 |
Status_t
|
|
Packit |
857059 |
vs_pool_size (Pool_t * handle, uint64_t *numBytesAlloc)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
Status_t rc;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
IB_ENTER (function, (unint) handle, 0, 0, 0);
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if (handle == 0)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
IB_LOG_ERROR0 ("handle is null");
|
|
Packit |
857059 |
IB_EXIT (function, VSTATUS_ILLPARM);
|
|
Packit |
857059 |
return VSTATUS_ILLPARM;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if (handle->magic != VSPOOL_MAGIC)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
IB_LOG_ERRORX ("invalid handle magic:", handle->magic);
|
|
Packit |
857059 |
IB_EXIT (function, VSTATUS_ILLPARM);
|
|
Packit |
857059 |
return VSTATUS_ILLPARM;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if (numBytesAlloc == 0)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
IB_LOG_ERROR0 ("numBytesAlloc is null");
|
|
Packit |
857059 |
IB_EXIT (function, VSTATUS_ILLPARM);
|
|
Packit |
857059 |
return VSTATUS_ILLPARM;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
#if USE_POOL_LOCK
|
|
Packit |
857059 |
rc = vs_lock (&handle->lock);
|
|
Packit |
857059 |
if (rc != VSTATUS_OK)
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
IB_LOG_ERRORRC("vs_lock failed rc:", rc);
|
|
Packit |
857059 |
*numBytesAlloc = 0;
|
|
Packit |
857059 |
IB_EXIT (function, VSTATUS_NXIO);
|
|
Packit |
857059 |
return VSTATUS_NXIO;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
#endif /* USE_POOL_LOCK */
|
|
Packit |
857059 |
|
|
Packit |
857059 |
rc = vs_implpool_size (handle, numBytesAlloc);
|
|
Packit |
857059 |
|
|
Packit |
857059 |
#if USE_POOL_LOCK
|
|
Packit |
857059 |
(void) vs_unlock (&handle->lock);
|
|
Packit |
857059 |
#endif /* USE_POOL_LOCK */
|
|
Packit |
857059 |
IB_EXIT (function, rc);
|
|
Packit |
857059 |
return rc;
|
|
Packit |
857059 |
}
|