| 1 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 2 |
|
| 3 |
File: oct6100_tsi_cnct.c |
| 4 |
|
| 5 |
Copyright (c) 2001-2007 Octasic Inc. |
| 6 |
|
| 7 |
Description: |
| 8 |
|
| 9 |
This file contains functions used to open and close TSI connections |
| 10 |
|
| 11 |
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is |
| 12 |
free software; you can redistribute it and/or modify it under the terms of |
| 13 |
the GNU General Public License as published by the Free Software Foundation; |
| 14 |
either version 2 of the License, or (at your option) any later version. |
| 15 |
|
| 16 |
The OCT6100 GPL API is distributed in the hope that it will be useful, but |
| 17 |
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 18 |
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 19 |
for more details. |
| 20 |
|
| 21 |
You should have received a copy of the GNU General Public License |
| 22 |
along with the OCT6100 GPL API; if not, write to the Free Software |
| 23 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 24 |
|
| 25 |
$Octasic_Release: OCT612xAPI-01.00-PR49 $ |
| 26 |
|
| 27 |
$Octasic_Revision: 38 $ |
| 28 |
|
| 29 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 30 |
|
| 31 |
|
| 32 |
/***************************** INCLUDE FILES *******************************/ |
| 33 |
|
| 34 |
#include "octdef.h" |
| 35 |
|
| 36 |
#include "oct6100api/oct6100_defines.h" |
| 37 |
#include "oct6100api/oct6100_errors.h" |
| 38 |
#include "oct6100api/oct6100_apiud.h" |
| 39 |
|
| 40 |
#include "apilib/octapi_llman.h" |
| 41 |
|
| 42 |
#include "oct6100api/oct6100_tlv_inst.h" |
| 43 |
#include "oct6100api/oct6100_chip_open_inst.h" |
| 44 |
#include "oct6100api/oct6100_chip_stats_inst.h" |
| 45 |
#include "oct6100api/oct6100_interrupts_inst.h" |
| 46 |
#include "oct6100api/oct6100_channel_inst.h" |
| 47 |
#include "oct6100api/oct6100_remote_debug_inst.h" |
| 48 |
#include "oct6100api/oct6100_debug_inst.h" |
| 49 |
#include "oct6100api/oct6100_api_inst.h" |
| 50 |
#include "oct6100api/oct6100_tsi_cnct_inst.h" |
| 51 |
|
| 52 |
#include "oct6100api/oct6100_interrupts_pub.h" |
| 53 |
#include "oct6100api/oct6100_chip_open_pub.h" |
| 54 |
#include "oct6100api/oct6100_channel_pub.h" |
| 55 |
#include "oct6100api/oct6100_tsi_cnct_pub.h" |
| 56 |
|
| 57 |
#include "oct6100_chip_open_priv.h" |
| 58 |
#include "oct6100_miscellaneous_priv.h" |
| 59 |
#include "oct6100_memory_priv.h" |
| 60 |
#include "oct6100_tsst_priv.h" |
| 61 |
#include "oct6100_channel_priv.h" |
| 62 |
#include "oct6100_tsi_cnct_priv.h" |
| 63 |
|
| 64 |
/**************************** PUBLIC FUNCTIONS ****************************/ |
| 65 |
|
| 66 |
|
| 67 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 68 |
|
| 69 |
Function: Oct6100TsiCnctOpen |
| 70 |
|
| 71 |
Description: This function opens a TSI connection between two TDM timeslots. |
| 72 |
|
| 73 |
------------------------------------------------------------------------------- |
| 74 |
| Argument | Description |
| 75 |
------------------------------------------------------------------------------- |
| 76 |
f_pApiInstance Pointer to API instance. This memory is used to keep the |
| 77 |
present state of the chip and all its resources. |
| 78 |
|
| 79 |
f_pTsiCnctOpen Pointer to TSI connection open structure. |
| 80 |
|
| 81 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 82 |
#if !SKIP_Oct6100TsiCnctOpenDef |
| 83 |
UINT32 Oct6100TsiCnctOpenDef( |
| 84 |
tPOCT6100_TSI_CNCT_OPEN f_pTsiCnctOpen ) |
| 85 |
{ |
| 86 |
f_pTsiCnctOpen->pulTsiCnctHndl = NULL; |
| 87 |
|
| 88 |
f_pTsiCnctOpen->ulInputTimeslot = cOCT6100_INVALID_TIMESLOT; |
| 89 |
f_pTsiCnctOpen->ulInputStream = cOCT6100_INVALID_STREAM; |
| 90 |
f_pTsiCnctOpen->ulOutputTimeslot = cOCT6100_INVALID_TIMESLOT; |
| 91 |
f_pTsiCnctOpen->ulOutputStream = cOCT6100_INVALID_STREAM; |
| 92 |
|
| 93 |
return cOCT6100_ERR_OK; |
| 94 |
} |
| 95 |
#endif |
| 96 |
|
| 97 |
#if !SKIP_Oct6100TsiCnctOpen |
| 98 |
UINT32 Oct6100TsiCnctOpen( |
| 99 |
tPOCT6100_INSTANCE_API f_pApiInstance, |
| 100 |
tPOCT6100_TSI_CNCT_OPEN f_pTsiCnctOpen ) |
| 101 |
{ |
| 102 |
tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj; |
| 103 |
tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj; |
| 104 |
UINT32 ulSerRes = cOCT6100_ERR_OK; |
| 105 |
UINT32 ulFncRes = cOCT6100_ERR_OK; |
| 106 |
|
| 107 |
/* Set the process context of the serialize structure. */ |
| 108 |
SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext; |
| 109 |
ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext; |
| 110 |
|
| 111 |
/* Seize all list semaphores needed by this function. */ |
| 112 |
SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj; |
| 113 |
SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY; |
| 114 |
ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj ); |
| 115 |
if ( ulSerRes == cOCT6100_ERR_OK ) |
| 116 |
{ |
| 117 |
/* Call the serialized function. */ |
| 118 |
ulFncRes = Oct6100TsiCnctOpenSer( f_pApiInstance, f_pTsiCnctOpen ); |
| 119 |
} |
| 120 |
else |
| 121 |
{ |
| 122 |
return ulSerRes; |
| 123 |
} |
| 124 |
|
| 125 |
/* Release the seized semaphores. */ |
| 126 |
ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj; |
| 127 |
ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj ); |
| 128 |
|
| 129 |
/* If an error occured then return the error code. */ |
| 130 |
if ( ulSerRes != cOCT6100_ERR_OK ) |
| 131 |
return ulSerRes; |
| 132 |
if ( ulFncRes != cOCT6100_ERR_OK ) |
| 133 |
return ulFncRes; |
| 134 |
|
| 135 |
return cOCT6100_ERR_OK; |
| 136 |
} |
| 137 |
#endif |
| 138 |
|
| 139 |
|
| 140 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 141 |
|
| 142 |
Function: Oct6100TsiCnctClose |
| 143 |
|
| 144 |
Description: This function closes a TSI connection. |
| 145 |
|
| 146 |
------------------------------------------------------------------------------- |
| 147 |
| Argument | Description |
| 148 |
------------------------------------------------------------------------------- |
| 149 |
f_pApiInstance Pointer to API instance. This memory is used to keep the |
| 150 |
present state of the chip and all its resources. |
| 151 |
|
| 152 |
f_pTsiCnctClose Pointer to TSI connection close structure. |
| 153 |
|
| 154 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 155 |
#if !SKIP_Oct6100TsiCnctCloseDef |
| 156 |
UINT32 Oct6100TsiCnctCloseDef( |
| 157 |
tPOCT6100_TSI_CNCT_CLOSE f_pTsiCnctClose ) |
| 158 |
{ |
| 159 |
f_pTsiCnctClose->ulTsiCnctHndl = cOCT6100_INVALID_HANDLE; |
| 160 |
|
| 161 |
return cOCT6100_ERR_OK; |
| 162 |
} |
| 163 |
#endif |
| 164 |
|
| 165 |
#if !SKIP_Oct6100TsiCnctClose |
| 166 |
UINT32 Oct6100TsiCnctClose( |
| 167 |
tPOCT6100_INSTANCE_API f_pApiInstance, |
| 168 |
tPOCT6100_TSI_CNCT_CLOSE f_pTsiCnctClose ) |
| 169 |
{ |
| 170 |
tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj; |
| 171 |
tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj; |
| 172 |
UINT32 ulSerRes = cOCT6100_ERR_OK; |
| 173 |
UINT32 ulFncRes = cOCT6100_ERR_OK; |
| 174 |
|
| 175 |
/* Set the process context of the serialize structure. */ |
| 176 |
SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext; |
| 177 |
ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext; |
| 178 |
|
| 179 |
/* Seize all list semaphores needed by this function. */ |
| 180 |
SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj; |
| 181 |
SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY; |
| 182 |
ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj ); |
| 183 |
if ( ulSerRes == cOCT6100_ERR_OK ) |
| 184 |
{ |
| 185 |
/* Call the serialized function. */ |
| 186 |
ulFncRes = Oct6100TsiCnctCloseSer( f_pApiInstance, f_pTsiCnctClose ); |
| 187 |
} |
| 188 |
else |
| 189 |
{ |
| 190 |
return ulSerRes; |
| 191 |
} |
| 192 |
|
| 193 |
/* Release the seized semaphores. */ |
| 194 |
ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj; |
| 195 |
ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj ); |
| 196 |
|
| 197 |
/* If an error occured then return the error code. */ |
| 198 |
if ( ulSerRes != cOCT6100_ERR_OK ) |
| 199 |
return ulSerRes; |
| 200 |
if ( ulFncRes != cOCT6100_ERR_OK ) |
| 201 |
return ulFncRes; |
| 202 |
|
| 203 |
return cOCT6100_ERR_OK; |
| 204 |
} |
| 205 |
#endif |
| 206 |
|
| 207 |
|
| 208 |
/**************************** PRIVATE FUNCTIONS ****************************/ |
| 209 |
|
| 210 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 211 |
|
| 212 |
Function: Oct6100ApiGetTsiCnctSwSizes |
| 213 |
|
| 214 |
Description: Gets the sizes of all portions of the API instance pertinent |
| 215 |
to the management the TSI memory. |
| 216 |
|
| 217 |
------------------------------------------------------------------------------- |
| 218 |
| Argument | Description |
| 219 |
------------------------------------------------------------------------------- |
| 220 |
f_pOpenChip Pointer to chip configuration struct. |
| 221 |
f_pInstSizes Pointer to struct containing instance sizes. |
| 222 |
|
| 223 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 224 |
#if !SKIP_Oct6100ApiGetTsiCnctSwSizes |
| 225 |
UINT32 Oct6100ApiGetTsiCnctSwSizes( |
| 226 |
IN tPOCT6100_CHIP_OPEN f_pOpenChip, |
| 227 |
OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes ) |
| 228 |
{ |
| 229 |
UINT32 ulTempVar; |
| 230 |
UINT32 ulResult; |
| 231 |
|
| 232 |
/* Determine the amount of memory required for the API TSI connection list. */ |
| 233 |
f_pInstSizes->ulTsiCnctList = f_pOpenChip->ulMaxTsiCncts * sizeof( tOCT6100_API_TSI_CNCT ); |
| 234 |
|
| 235 |
if ( f_pOpenChip->ulMaxTsiCncts > 0 ) |
| 236 |
{ |
| 237 |
/* Calculate memory needed for TSI memory allocation. */ |
| 238 |
ulResult = OctapiLlmAllocGetSize( f_pOpenChip->ulMaxTsiCncts, &f_pInstSizes->ulTsiCnctAlloc ); |
| 239 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 240 |
return cOCT6100_ERR_FATAL_48; |
| 241 |
} |
| 242 |
else |
| 243 |
{ |
| 244 |
f_pInstSizes->ulTsiCnctAlloc = 0; |
| 245 |
} |
| 246 |
|
| 247 |
mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulTsiCnctList, ulTempVar ) |
| 248 |
mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulTsiCnctAlloc, ulTempVar ) |
| 249 |
|
| 250 |
return cOCT6100_ERR_OK; |
| 251 |
} |
| 252 |
#endif |
| 253 |
|
| 254 |
|
| 255 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 256 |
|
| 257 |
Function: Oct6100ApiTsiCnctSwInit |
| 258 |
|
| 259 |
Description: Initializes all elements of the instance structure associated |
| 260 |
to the TSI memory. |
| 261 |
|
| 262 |
------------------------------------------------------------------------------- |
| 263 |
| Argument | Description |
| 264 |
------------------------------------------------------------------------------- |
| 265 |
f_pApiInstance Pointer to API instance. This memory is used to keep |
| 266 |
the present state of the chip and all its resources. |
| 267 |
|
| 268 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 269 |
#if !SKIP_Oct6100ApiTsiCnctSwInit |
| 270 |
UINT32 Oct6100ApiTsiCnctSwInit( |
| 271 |
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance ) |
| 272 |
{ |
| 273 |
tPOCT6100_API_TSI_CNCT pChannelsTsiList; |
| 274 |
tPOCT6100_SHARED_INFO pSharedInfo; |
| 275 |
UINT32 ulMaxTsiChannels; |
| 276 |
PVOID pTsiChannelsAlloc; |
| 277 |
UINT32 ulResult; |
| 278 |
|
| 279 |
/* Get local pointer to shared portion of instance. */ |
| 280 |
pSharedInfo = f_pApiInstance->pSharedInfo; |
| 281 |
|
| 282 |
/* Initialize the TSI connections API list. */ |
| 283 |
ulMaxTsiChannels = pSharedInfo->ChipConfig.usMaxTsiCncts; |
| 284 |
|
| 285 |
mOCT6100_GET_TSI_CNCT_LIST_PNT( pSharedInfo, pChannelsTsiList ) |
| 286 |
|
| 287 |
/* Clear the memory. */ |
| 288 |
Oct6100UserMemSet( pChannelsTsiList, 0x00, sizeof(tOCT6100_API_TSI_CNCT) * ulMaxTsiChannels ); |
| 289 |
|
| 290 |
/* Set all entries in the TSI connections list to unused. */ |
| 291 |
if ( ulMaxTsiChannels > 0 ) |
| 292 |
{ |
| 293 |
mOCT6100_GET_TSI_CNCT_ALLOC_PNT( pSharedInfo, pTsiChannelsAlloc ) |
| 294 |
|
| 295 |
ulResult = OctapiLlmAllocInit( &pTsiChannelsAlloc, ulMaxTsiChannels ); |
| 296 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 297 |
return cOCT6100_ERR_FATAL_49; |
| 298 |
} |
| 299 |
|
| 300 |
return cOCT6100_ERR_OK; |
| 301 |
} |
| 302 |
#endif |
| 303 |
|
| 304 |
|
| 305 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 306 |
|
| 307 |
Function: Oct6100TsiCnctOpenSer |
| 308 |
|
| 309 |
Description: Opens a TSI connection. |
| 310 |
|
| 311 |
------------------------------------------------------------------------------- |
| 312 |
| Argument | Description |
| 313 |
------------------------------------------------------------------------------- |
| 314 |
f_pApiInstance Pointer to API instance. This memory is used to keep the |
| 315 |
present state of the chip and all its resources. |
| 316 |
|
| 317 |
f_pTsiCnctOpen Pointer to a tOCT6100_TSI_CNCT_OPEN structure. |
| 318 |
|
| 319 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 320 |
#if !SKIP_Oct6100TsiCnctOpenSer |
| 321 |
UINT32 Oct6100TsiCnctOpenSer( |
| 322 |
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, |
| 323 |
IN OUT tPOCT6100_TSI_CNCT_OPEN f_pTsiCnctOpen ) |
| 324 |
{ |
| 325 |
UINT16 usTsiChanIndex; |
| 326 |
UINT16 usTsiMemIndex; |
| 327 |
UINT16 usInputTsstIndex; |
| 328 |
UINT16 usOutputTsstIndex; |
| 329 |
UINT32 ulResult; |
| 330 |
|
| 331 |
/* Check the user's configuration of the TSI connection open structure for errors. */ |
| 332 |
ulResult = Oct6100ApiCheckTsiParams( f_pApiInstance, f_pTsiCnctOpen ); |
| 333 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 334 |
return ulResult; |
| 335 |
|
| 336 |
/* Reserve all resources needed by the TSI connection. */ |
| 337 |
ulResult = Oct6100ApiReserveTsiResources( f_pApiInstance, f_pTsiCnctOpen, &usTsiChanIndex, &usTsiMemIndex, &usInputTsstIndex, &usOutputTsstIndex ); |
| 338 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 339 |
return ulResult; |
| 340 |
|
| 341 |
/* Write all necessary structures to activate the TSI connection. */ |
| 342 |
ulResult = Oct6100ApiWriteTsiStructs( f_pApiInstance, f_pTsiCnctOpen, usTsiMemIndex, usInputTsstIndex, usOutputTsstIndex ); |
| 343 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 344 |
return ulResult; |
| 345 |
|
| 346 |
/* Update the TSI connection entry in the API list. */ |
| 347 |
ulResult = Oct6100ApiUpdateTsiEntry( f_pApiInstance, f_pTsiCnctOpen, usTsiChanIndex, usTsiMemIndex, usInputTsstIndex, usOutputTsstIndex ); |
| 348 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 349 |
return ulResult; |
| 350 |
|
| 351 |
return cOCT6100_ERR_OK; |
| 352 |
} |
| 353 |
#endif |
| 354 |
|
| 355 |
|
| 356 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 357 |
|
| 358 |
Function: Oct6100ApiCheckTsiParams |
| 359 |
|
| 360 |
Description: Checks the user's TSI connection open configuration for errors. |
| 361 |
|
| 362 |
------------------------------------------------------------------------------- |
| 363 |
| Argument | Description |
| 364 |
------------------------------------------------------------------------------- |
| 365 |
f_pApiInstance Pointer to API instance. This memory is used to keep the |
| 366 |
present state of the chip and all its resources. |
| 367 |
|
| 368 |
f_pTsiCnctOpen Pointer to TSI connection open configuration structure. |
| 369 |
|
| 370 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 371 |
#if !SKIP_Oct6100ApiCheckTsiParams |
| 372 |
UINT32 Oct6100ApiCheckTsiParams( |
| 373 |
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, |
| 374 |
IN tPOCT6100_TSI_CNCT_OPEN f_pTsiCnctOpen ) |
| 375 |
{ |
| 376 |
UINT32 ulResult; |
| 377 |
|
| 378 |
/* Check for errors. */ |
| 379 |
if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxTsiCncts == 0 ) |
| 380 |
return cOCT6100_ERR_TSI_CNCT_DISABLED; |
| 381 |
|
| 382 |
if ( f_pTsiCnctOpen->pulTsiCnctHndl == NULL ) |
| 383 |
return cOCT6100_ERR_TSI_CNCT_INVALID_HANDLE; |
| 384 |
|
| 385 |
/* Check the input TDM streams, timeslots component for errors. */ |
| 386 |
ulResult = Oct6100ApiValidateTsst( f_pApiInstance, |
| 387 |
cOCT6100_NUMBER_TSSTS_1, |
| 388 |
f_pTsiCnctOpen->ulInputTimeslot, |
| 389 |
f_pTsiCnctOpen->ulInputStream, |
| 390 |
cOCT6100_INPUT_TSST ); |
| 391 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 392 |
{ |
| 393 |
if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT ) |
| 394 |
{ |
| 395 |
return cOCT6100_ERR_TSI_CNCT_INPUT_TIMESLOT; |
| 396 |
} |
| 397 |
else if ( ulResult == cOCT6100_ERR_TSST_STREAM ) |
| 398 |
{ |
| 399 |
return cOCT6100_ERR_TSI_CNCT_INPUT_STREAM; |
| 400 |
} |
| 401 |
else |
| 402 |
{ |
| 403 |
return ulResult; |
| 404 |
} |
| 405 |
} |
| 406 |
|
| 407 |
/* Check the output TDM streams, timeslots component for errors. */ |
| 408 |
ulResult = Oct6100ApiValidateTsst( f_pApiInstance, |
| 409 |
cOCT6100_NUMBER_TSSTS_1, |
| 410 |
f_pTsiCnctOpen->ulOutputTimeslot, |
| 411 |
f_pTsiCnctOpen->ulOutputStream, |
| 412 |
cOCT6100_OUTPUT_TSST ); |
| 413 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 414 |
{ |
| 415 |
if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT ) |
| 416 |
{ |
| 417 |
return cOCT6100_ERR_TSI_CNCT_OUTPUT_TIMESLOT; |
| 418 |
} |
| 419 |
else if ( ulResult == cOCT6100_ERR_TSST_STREAM ) |
| 420 |
{ |
| 421 |
return cOCT6100_ERR_TSI_CNCT_OUTPUT_STREAM; |
| 422 |
} |
| 423 |
else |
| 424 |
{ |
| 425 |
return ulResult; |
| 426 |
} |
| 427 |
} |
| 428 |
|
| 429 |
return cOCT6100_ERR_OK; |
| 430 |
} |
| 431 |
#endif |
| 432 |
|
| 433 |
|
| 434 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 435 |
|
| 436 |
Function: Oct6100ApiReserveTsiResources |
| 437 |
|
| 438 |
Description: Reserves all resources needed for the new TSI connection. |
| 439 |
|
| 440 |
------------------------------------------------------------------------------- |
| 441 |
| Argument | Description |
| 442 |
------------------------------------------------------------------------------- |
| 443 |
f_pApiInstance Pointer to API instance. This memory is used to keep the |
| 444 |
present state of the chip and all its resources. |
| 445 |
|
| 446 |
f_pTsiCnctOpen Pointer to tsi channel configuration structure. |
| 447 |
f_pusTsiChanIndex Allocated entry in TSI channel list. |
| 448 |
f_pusTsiMemIndex Allocated entry in the TSI control memory. |
| 449 |
f_pusInputTsstIndex TSST memory index of the input samples. |
| 450 |
f_pusOutputTsstIndex TSST memory index of the output samples. |
| 451 |
|
| 452 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 453 |
#if !SKIP_Oct6100ApiReserveTsiResources |
| 454 |
UINT32 Oct6100ApiReserveTsiResources( |
| 455 |
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, |
| 456 |
IN tPOCT6100_TSI_CNCT_OPEN f_pTsiCnctOpen, |
| 457 |
OUT PUINT16 f_pusTsiChanIndex, |
| 458 |
OUT PUINT16 f_pusTsiMemIndex, |
| 459 |
OUT PUINT16 f_pusInputTsstIndex, |
| 460 |
OUT PUINT16 f_pusOutputTsstIndex ) |
| 461 |
{ |
| 462 |
tPOCT6100_SHARED_INFO pSharedInfo; |
| 463 |
UINT32 ulResult; |
| 464 |
UINT32 ulTempVar; |
| 465 |
BOOL fTsiChanEntry = FALSE; |
| 466 |
BOOL fTsiMemEntry = FALSE; |
| 467 |
BOOL fInputTsst = FALSE; |
| 468 |
|
| 469 |
/* Obtain local pointer to shared portion of instance. */ |
| 470 |
pSharedInfo = f_pApiInstance->pSharedInfo; |
| 471 |
|
| 472 |
/* Reserve an entry in the TSI connection list. */ |
| 473 |
ulResult = Oct6100ApiReserveTsiCnctEntry( f_pApiInstance, f_pusTsiChanIndex ); |
| 474 |
if ( ulResult == cOCT6100_ERR_OK ) |
| 475 |
{ |
| 476 |
fTsiChanEntry = TRUE; |
| 477 |
|
| 478 |
/* Find a TSI memory entry. */ |
| 479 |
ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance, f_pusTsiMemIndex ); |
| 480 |
if ( ulResult == cOCT6100_ERR_OK ) |
| 481 |
{ |
| 482 |
fTsiMemEntry = TRUE; |
| 483 |
|
| 484 |
/* Reserve the input TSST entry. */ |
| 485 |
ulResult = Oct6100ApiReserveTsst( f_pApiInstance, |
| 486 |
f_pTsiCnctOpen->ulInputTimeslot, |
| 487 |
f_pTsiCnctOpen->ulInputStream, |
| 488 |
cOCT6100_NUMBER_TSSTS_1, |
| 489 |
cOCT6100_INPUT_TSST, |
| 490 |
f_pusInputTsstIndex, |
| 491 |
NULL ); |
| 492 |
if ( ulResult == cOCT6100_ERR_OK ) |
| 493 |
{ |
| 494 |
fInputTsst = TRUE; |
| 495 |
|
| 496 |
/* Reserve the output TSST entry. */ |
| 497 |
ulResult = Oct6100ApiReserveTsst( f_pApiInstance, |
| 498 |
f_pTsiCnctOpen->ulOutputTimeslot, |
| 499 |
f_pTsiCnctOpen->ulOutputStream, |
| 500 |
cOCT6100_NUMBER_TSSTS_1, |
| 501 |
cOCT6100_OUTPUT_TSST, |
| 502 |
f_pusOutputTsstIndex, |
| 503 |
NULL ); |
| 504 |
} |
| 505 |
} |
| 506 |
else |
| 507 |
{ |
| 508 |
/* Return an error other then a fatal. */ |
| 509 |
ulResult = cOCT6100_ERR_TSI_CNCT_NO_MORE_TSI_AVAILABLE; |
| 510 |
} |
| 511 |
} |
| 512 |
|
| 513 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 514 |
{ |
| 515 |
if( fTsiChanEntry == TRUE ) |
| 516 |
{ |
| 517 |
ulTempVar = Oct6100ApiReleaseTsiCnctEntry( f_pApiInstance, *f_pusTsiChanIndex ); |
| 518 |
if ( ulTempVar != cOCT6100_ERR_OK ) |
| 519 |
return ulTempVar; |
| 520 |
} |
| 521 |
|
| 522 |
if( fTsiMemEntry == TRUE ) |
| 523 |
{ |
| 524 |
ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, *f_pusTsiMemIndex ); |
| 525 |
if ( ulTempVar != cOCT6100_ERR_OK ) |
| 526 |
return ulTempVar; |
| 527 |
} |
| 528 |
|
| 529 |
if( fInputTsst == TRUE ) |
| 530 |
{ |
| 531 |
ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance, |
| 532 |
f_pTsiCnctOpen->ulInputTimeslot, |
| 533 |
f_pTsiCnctOpen->ulInputStream, |
| 534 |
cOCT6100_NUMBER_TSSTS_1, |
| 535 |
cOCT6100_INPUT_TSST, |
| 536 |
cOCT6100_INVALID_INDEX ); |
| 537 |
if ( ulTempVar != cOCT6100_ERR_OK ) |
| 538 |
return ulTempVar; |
| 539 |
} |
| 540 |
|
| 541 |
return ulResult; |
| 542 |
} |
| 543 |
|
| 544 |
return cOCT6100_ERR_OK; |
| 545 |
} |
| 546 |
#endif |
| 547 |
|
| 548 |
|
| 549 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 550 |
|
| 551 |
Function: Oct6100ApiWriteTsiStructs |
| 552 |
|
| 553 |
Description: Performs all the required structure writes to configure the |
| 554 |
new TSI connection. |
| 555 |
|
| 556 |
------------------------------------------------------------------------------- |
| 557 |
| Argument | Description |
| 558 |
------------------------------------------------------------------------------- |
| 559 |
f_pApiInstance Pointer to API instance. This memory is used to keep the |
| 560 |
present state of the chip and all its resources. |
| 561 |
|
| 562 |
f_pTsiCnctOpen Pointer to tsi connection open structure. |
| 563 |
f_usTsiMemIndex Allocated entry in the TSI control memory. |
| 564 |
f_usInputTsstIndex TSST memory index of the input samples. |
| 565 |
f_usOutputTsstIndex TSST memory index of the output samples. |
| 566 |
|
| 567 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 568 |
#if !SKIP_Oct6100ApiWriteTsiStructs |
| 569 |
UINT32 Oct6100ApiWriteTsiStructs( |
| 570 |
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, |
| 571 |
IN tPOCT6100_TSI_CNCT_OPEN f_pTsiCnctOpen, |
| 572 |
IN UINT16 f_usTsiMemIndex, |
| 573 |
IN UINT16 f_usInputTsstIndex, |
| 574 |
IN UINT16 f_usOutputTsstIndex ) |
| 575 |
{ |
| 576 |
tPOCT6100_SHARED_INFO pSharedInfo; |
| 577 |
tOCT6100_WRITE_PARAMS WriteParams; |
| 578 |
UINT32 ulResult; |
| 579 |
|
| 580 |
/* Obtain local pointer to shared portion of instance. */ |
| 581 |
pSharedInfo = f_pApiInstance->pSharedInfo; |
| 582 |
|
| 583 |
WriteParams.pProcessContext = f_pApiInstance->pProcessContext; |
| 584 |
|
| 585 |
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; |
| 586 |
|
| 587 |
/*==================================================================================*/ |
| 588 |
/* Configure the TSST control memory.*/ |
| 589 |
|
| 590 |
/* Set the input TSST control entry.*/ |
| 591 |
ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance, |
| 592 |
f_usInputTsstIndex, |
| 593 |
f_usTsiMemIndex, |
| 594 |
cOCT6100_PCM_U_LAW ); |
| 595 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 596 |
return ulResult; |
| 597 |
|
| 598 |
/* Set the output TSST control entry. */ |
| 599 |
ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance, |
| 600 |
f_usOutputTsstIndex, |
| 601 |
cOCT6100_ADPCM_IN_LOW_BITS, |
| 602 |
1, |
| 603 |
f_usTsiMemIndex ); |
| 604 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 605 |
return ulResult; |
| 606 |
|
| 607 |
/*==================================================================================*/ |
| 608 |
|
| 609 |
return cOCT6100_ERR_OK; |
| 610 |
} |
| 611 |
#endif |
| 612 |
|
| 613 |
|
| 614 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 615 |
|
| 616 |
Function: Oct6100ApiUpdateTsiEntry |
| 617 |
|
| 618 |
Description: Updates the new TSI connection in the TSI connection list. |
| 619 |
|
| 620 |
------------------------------------------------------------------------------- |
| 621 |
| Argument | Description |
| 622 |
------------------------------------------------------------------------------- |
| 623 |
f_pApiInstance Pointer to API instance. This memory is used to keep |
| 624 |
the present state of the chip and all its resources. |
| 625 |
|
| 626 |
f_pTsiCnctOpen Pointer to TSI connection open configuration structure. |
| 627 |
f_usTsiMemIndex Allocated entry in TSI chariot memory. |
| 628 |
f_usTsiChanIndex Allocated entry in the TSI channel list. |
| 629 |
f_usInputTsstIndex TSST control memory index of the input TSST. |
| 630 |
f_usOutputTsstIndex TSST control memory index of the output TSST. |
| 631 |
|
| 632 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 633 |
#if !SKIP_Oct6100ApiUpdateTsiEntry |
| 634 |
UINT32 Oct6100ApiUpdateTsiEntry( |
| 635 |
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, |
| 636 |
IN OUT tPOCT6100_TSI_CNCT_OPEN f_pTsiCnctOpen, |
| 637 |
IN UINT16 f_usTsiChanIndex, |
| 638 |
IN UINT16 f_usTsiMemIndex, |
| 639 |
IN UINT16 f_usInputTsstIndex, |
| 640 |
IN UINT16 f_usOutputTsstIndex ) |
| 641 |
{ |
| 642 |
tPOCT6100_API_TSI_CNCT pTsiCnctEntry; |
| 643 |
|
| 644 |
/*================================================================================*/ |
| 645 |
/* Obtain a pointer to the new TSI connection's list entry. */ |
| 646 |
|
| 647 |
mOCT6100_GET_TSI_CNCT_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsiCnctEntry, f_usTsiChanIndex ) |
| 648 |
|
| 649 |
/* Copy the TSI's configuration and allocated resources. */ |
| 650 |
pTsiCnctEntry->usInputTimeslot = (UINT16)( f_pTsiCnctOpen->ulInputTimeslot & 0xFFFF ); |
| 651 |
pTsiCnctEntry->usInputStream = (UINT16)( f_pTsiCnctOpen->ulInputStream & 0xFFFF ); |
| 652 |
|
| 653 |
pTsiCnctEntry->usOutputTimeslot = (UINT16)( f_pTsiCnctOpen->ulOutputTimeslot & 0xFFFF ); |
| 654 |
pTsiCnctEntry->usOutputStream = (UINT16)( f_pTsiCnctOpen->ulOutputStream & 0xFFFF ); |
| 655 |
|
| 656 |
/* Store hardware related information. */ |
| 657 |
pTsiCnctEntry->usTsiMemIndex = f_usTsiMemIndex; |
| 658 |
pTsiCnctEntry->usInputTsstIndex = f_usInputTsstIndex; |
| 659 |
pTsiCnctEntry->usOutputTsstIndex = f_usOutputTsstIndex; |
| 660 |
|
| 661 |
/* Form handle returned to user. */ |
| 662 |
*f_pTsiCnctOpen->pulTsiCnctHndl = cOCT6100_HNDL_TAG_TSI_CNCT | (pTsiCnctEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_usTsiChanIndex; |
| 663 |
|
| 664 |
/* Finally, mark the connection as opened. */ |
| 665 |
pTsiCnctEntry->fReserved = TRUE; |
| 666 |
|
| 667 |
/* Increment the number of TSI connection opened. */ |
| 668 |
f_pApiInstance->pSharedInfo->ChipStats.usNumberTsiCncts++; |
| 669 |
|
| 670 |
/*================================================================================*/ |
| 671 |
|
| 672 |
return cOCT6100_ERR_OK; |
| 673 |
} |
| 674 |
#endif |
| 675 |
|
| 676 |
|
| 677 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 678 |
|
| 679 |
Function: Oct6100TsiCnctCloseSer |
| 680 |
|
| 681 |
Description: Closes a TSI connection. |
| 682 |
|
| 683 |
------------------------------------------------------------------------------- |
| 684 |
| Argument | Description |
| 685 |
------------------------------------------------------------------------------- |
| 686 |
f_pApiInstance Pointer to API instance. This memory is used to keep the |
| 687 |
present state of the chip and all its resources. |
| 688 |
|
| 689 |
f_pTsiCnctClose Pointer to TSI connection close structure. |
| 690 |
|
| 691 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 692 |
#if !SKIP_Oct6100TsiCnctCloseSer |
| 693 |
UINT32 Oct6100TsiCnctCloseSer( |
| 694 |
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, |
| 695 |
IN OUT tPOCT6100_TSI_CNCT_CLOSE f_pTsiCnctClose ) |
| 696 |
{ |
| 697 |
UINT16 usTsiChanIndex; |
| 698 |
UINT16 usTsiMemIndex; |
| 699 |
UINT16 usInputTsstIndex; |
| 700 |
UINT16 usOutputTsstIndex; |
| 701 |
UINT32 ulResult; |
| 702 |
|
| 703 |
/* Verify that all the parameters given match the state of the API. */ |
| 704 |
ulResult = Oct6100ApiAssertTsiParams( f_pApiInstance, f_pTsiCnctClose, &usTsiChanIndex, &usTsiMemIndex, &usInputTsstIndex, &usOutputTsstIndex ); |
| 705 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 706 |
return ulResult; |
| 707 |
|
| 708 |
/* Release all resources associated to the TSI channel. */ |
| 709 |
ulResult = Oct6100ApiInvalidateTsiStructs( f_pApiInstance, usInputTsstIndex, usOutputTsstIndex ); |
| 710 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 711 |
return ulResult; |
| 712 |
|
| 713 |
/* Release all resources associated to the TSI connection. */ |
| 714 |
ulResult = Oct6100ApiReleaseTsiResources( f_pApiInstance, usTsiChanIndex, usTsiMemIndex ); |
| 715 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 716 |
return ulResult; |
| 717 |
|
| 718 |
/* Invalidate the handle. */ |
| 719 |
f_pTsiCnctClose->ulTsiCnctHndl = cOCT6100_INVALID_HANDLE; |
| 720 |
|
| 721 |
return cOCT6100_ERR_OK; |
| 722 |
} |
| 723 |
#endif |
| 724 |
|
| 725 |
|
| 726 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 727 |
|
| 728 |
Function: Oct6100ApiAssertTsiParams |
| 729 |
|
| 730 |
Description: Validate the handle given by the user and verify the state of |
| 731 |
the TSI connection about to be closed. |
| 732 |
Also returns all required information to deactivate the connection. |
| 733 |
|
| 734 |
------------------------------------------------------------------------------- |
| 735 |
| Argument | Description |
| 736 |
------------------------------------------------------------------------------- |
| 737 |
f_pApiInstance Pointer to API instance. This memory is used to keep the |
| 738 |
present state of the chip and all its resources. |
| 739 |
|
| 740 |
f_pTsiCnctClose Pointer to TSI connection close structure. |
| 741 |
f_pusTsiChanIndex Index of the TSI connection structure in the API list. |
| 742 |
f_pusTsiMemIndex Index of the TSI entry within the TSI chariot memory |
| 743 |
f_pusInputTsstIndex Index of the input entry in the TSST control memory. |
| 744 |
f_pusOutputTsstIndex Index of the output entry in the TSST control memory. |
| 745 |
|
| 746 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 747 |
#if !SKIP_Oct6100ApiAssertTsiParams |
| 748 |
UINT32 Oct6100ApiAssertTsiParams( |
| 749 |
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, |
| 750 |
IN tPOCT6100_TSI_CNCT_CLOSE f_pTsiCnctClose, |
| 751 |
OUT PUINT16 f_pusTsiChanIndex, |
| 752 |
OUT PUINT16 f_pusTsiMemIndex, |
| 753 |
OUT PUINT16 f_pusInputTsstIndex, |
| 754 |
OUT PUINT16 f_pusOutputTsstIndex ) |
| 755 |
{ |
| 756 |
tPOCT6100_SHARED_INFO pSharedInfo; |
| 757 |
tPOCT6100_API_TSI_CNCT pTsiEntry; |
| 758 |
UINT32 ulEntryOpenCnt; |
| 759 |
|
| 760 |
/* Get local pointer(s). */ |
| 761 |
pSharedInfo = f_pApiInstance->pSharedInfo; |
| 762 |
|
| 763 |
/* Check the provided handle. */ |
| 764 |
if ( (f_pTsiCnctClose->ulTsiCnctHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_TSI_CNCT ) |
| 765 |
return cOCT6100_ERR_TSI_CNCT_INVALID_HANDLE; |
| 766 |
|
| 767 |
*f_pusTsiChanIndex = (UINT16)( f_pTsiCnctClose->ulTsiCnctHndl & cOCT6100_HNDL_INDEX_MASK ); |
| 768 |
|
| 769 |
if ( *f_pusTsiChanIndex >= pSharedInfo->ChipConfig.usMaxTsiCncts ) |
| 770 |
return cOCT6100_ERR_TSI_CNCT_INVALID_HANDLE; |
| 771 |
|
| 772 |
/*=======================================================================*/ |
| 773 |
/* Get a pointer to the channel's list entry. */ |
| 774 |
|
| 775 |
mOCT6100_GET_TSI_CNCT_ENTRY_PNT( pSharedInfo, pTsiEntry, *f_pusTsiChanIndex ) |
| 776 |
|
| 777 |
/* Extract the entry open count from the provided handle. */ |
| 778 |
ulEntryOpenCnt = (f_pTsiCnctClose->ulTsiCnctHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK; |
| 779 |
|
| 780 |
/* Check for errors. */ |
| 781 |
if ( pTsiEntry->fReserved != TRUE ) |
| 782 |
return cOCT6100_ERR_TSI_CNCT_NOT_OPEN; |
| 783 |
if ( ulEntryOpenCnt != pTsiEntry->byEntryOpenCnt ) |
| 784 |
return cOCT6100_ERR_TSI_CNCT_INVALID_HANDLE; |
| 785 |
|
| 786 |
/* Return info needed to close the channel and release all resources. */ |
| 787 |
*f_pusInputTsstIndex = pTsiEntry->usInputTsstIndex; |
| 788 |
*f_pusOutputTsstIndex = pTsiEntry->usOutputTsstIndex; |
| 789 |
*f_pusTsiMemIndex = pTsiEntry->usTsiMemIndex; |
| 790 |
|
| 791 |
/*=======================================================================*/ |
| 792 |
|
| 793 |
return cOCT6100_ERR_OK; |
| 794 |
} |
| 795 |
#endif |
| 796 |
|
| 797 |
|
| 798 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 799 |
|
| 800 |
Function: Oct6100ApiInvalidateTsiStructs |
| 801 |
|
| 802 |
Description: This function closes a TSI connection. |
| 803 |
|
| 804 |
------------------------------------------------------------------------------- |
| 805 |
| Argument | Description |
| 806 |
------------------------------------------------------------------------------- |
| 807 |
f_pApiInstance Pointer to API instance. This memory is used to keep the |
| 808 |
present state of the chip and all its resources. |
| 809 |
|
| 810 |
f_usInputTsstIndex Index of the input entry in the TSST control memory. |
| 811 |
f_usOutputTsstIndex Index of the output entry in the TSST control memory. |
| 812 |
|
| 813 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 814 |
#if !SKIP_Oct6100ApiInvalidateTsiStructs |
| 815 |
UINT32 Oct6100ApiInvalidateTsiStructs( |
| 816 |
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, |
| 817 |
IN UINT16 f_usInputTsstIndex, |
| 818 |
IN UINT16 f_usOutputTsstIndex ) |
| 819 |
{ |
| 820 |
tPOCT6100_SHARED_INFO pSharedInfo; |
| 821 |
tOCT6100_WRITE_PARAMS WriteParams; |
| 822 |
UINT32 ulResult; |
| 823 |
|
| 824 |
/* Obtain local pointer to shared portion of instance. */ |
| 825 |
pSharedInfo = f_pApiInstance->pSharedInfo; |
| 826 |
|
| 827 |
WriteParams.pProcessContext = f_pApiInstance->pProcessContext; |
| 828 |
|
| 829 |
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; |
| 830 |
|
| 831 |
/*==================================================================================*/ |
| 832 |
/* Deactivate the TSST control memory. */ |
| 833 |
|
| 834 |
/* Set the input TSST control entry to unused. */ |
| 835 |
WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( f_usInputTsstIndex * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE ); |
| 836 |
|
| 837 |
WriteParams.usWriteData = 0x0000; |
| 838 |
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); |
| 839 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 840 |
return ulResult; |
| 841 |
|
| 842 |
/* Set the output TSST control entry to unused. */ |
| 843 |
WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( f_usOutputTsstIndex * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE ); |
| 844 |
|
| 845 |
WriteParams.usWriteData = 0x0000; |
| 846 |
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); |
| 847 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 848 |
return ulResult; |
| 849 |
|
| 850 |
/*==================================================================================*/ |
| 851 |
|
| 852 |
return cOCT6100_ERR_OK; |
| 853 |
} |
| 854 |
#endif |
| 855 |
|
| 856 |
|
| 857 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 858 |
|
| 859 |
Function: Oct6100ApiReleaseTsiResources |
| 860 |
|
| 861 |
Description: Release and clear the API entry associated to the TSI channel. |
| 862 |
|
| 863 |
------------------------------------------------------------------------------- |
| 864 |
| Argument | Description |
| 865 |
------------------------------------------------------------------------------- |
| 866 |
f_pApiInstance Pointer to API instance. This memory is used to keep the |
| 867 |
present state of the chip and all its resources. |
| 868 |
|
| 869 |
f_usTsiChanIndex Index of the TSI connection in the API list. |
| 870 |
|
| 871 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 872 |
#if !SKIP_Oct6100ApiReleaseTsiResources |
| 873 |
UINT32 Oct6100ApiReleaseTsiResources( |
| 874 |
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, |
| 875 |
IN UINT16 f_usTsiChanIndex, |
| 876 |
IN UINT16 f_usTsiMemIndex ) |
| 877 |
{ |
| 878 |
tPOCT6100_SHARED_INFO pSharedInfo; |
| 879 |
tPOCT6100_API_TSI_CNCT pTsiEntry; |
| 880 |
UINT32 ulResult; |
| 881 |
|
| 882 |
/* Obtain local pointer to shared portion of instance. */ |
| 883 |
pSharedInfo = f_pApiInstance->pSharedInfo; |
| 884 |
|
| 885 |
mOCT6100_GET_TSI_CNCT_ENTRY_PNT( pSharedInfo, pTsiEntry, f_usTsiChanIndex ); |
| 886 |
|
| 887 |
/* Release the entry in the TSI connection list. */ |
| 888 |
ulResult = Oct6100ApiReleaseTsiCnctEntry( f_pApiInstance, f_usTsiChanIndex ); |
| 889 |
if ( ulResult == cOCT6100_ERR_OK ) |
| 890 |
{ |
| 891 |
ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, f_usTsiMemIndex ); |
| 892 |
if ( ulResult == cOCT6100_ERR_OK ) |
| 893 |
{ |
| 894 |
/* Release the input entry. */ |
| 895 |
ulResult = Oct6100ApiReleaseTsst( f_pApiInstance, |
| 896 |
pTsiEntry->usInputTimeslot, |
| 897 |
pTsiEntry->usInputStream, |
| 898 |
cOCT6100_NUMBER_TSSTS_1, |
| 899 |
cOCT6100_INPUT_TSST, |
| 900 |
cOCT6100_INVALID_INDEX ); |
| 901 |
if ( ulResult == cOCT6100_ERR_OK ) |
| 902 |
{ |
| 903 |
/* Release the output TSST entry. */ |
| 904 |
ulResult = Oct6100ApiReleaseTsst( f_pApiInstance, |
| 905 |
pTsiEntry->usOutputTimeslot, |
| 906 |
pTsiEntry->usOutputStream, |
| 907 |
cOCT6100_NUMBER_TSSTS_1, |
| 908 |
cOCT6100_OUTPUT_TSST, |
| 909 |
cOCT6100_INVALID_INDEX ); |
| 910 |
} |
| 911 |
} |
| 912 |
} |
| 913 |
|
| 914 |
/* Check if an error occured while releasing the reserved resources. */ |
| 915 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 916 |
{ |
| 917 |
if ( ulResult >= cOCT6100_ERR_FATAL ) |
| 918 |
return ulResult; |
| 919 |
else |
| 920 |
return cOCT6100_ERR_FATAL_4A; |
| 921 |
} |
| 922 |
|
| 923 |
/*=============================================================*/ |
| 924 |
/* Update the TSI connection's list entry. */ |
| 925 |
|
| 926 |
/* Mark the connection as closed. */ |
| 927 |
pTsiEntry->fReserved = FALSE; |
| 928 |
pTsiEntry->byEntryOpenCnt++; |
| 929 |
|
| 930 |
/* Decrement the number of TSI connection opened. */ |
| 931 |
f_pApiInstance->pSharedInfo->ChipStats.usNumberTsiCncts--; |
| 932 |
|
| 933 |
/*=============================================================*/ |
| 934 |
|
| 935 |
return cOCT6100_ERR_OK; |
| 936 |
} |
| 937 |
#endif |
| 938 |
|
| 939 |
|
| 940 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 941 |
|
| 942 |
Function: Oct6100ApiReserveTsiCnctEntry |
| 943 |
|
| 944 |
Description: Reserves one of the TSI connection API entry. |
| 945 |
|
| 946 |
------------------------------------------------------------------------------- |
| 947 |
| Argument | Description |
| 948 |
------------------------------------------------------------------------------- |
| 949 |
f_pApiInstance Pointer to API instance. This memory is used to keep |
| 950 |
the present state of the chip and all its resources. |
| 951 |
|
| 952 |
f_pusTsiChanIndex Resulting index reserved in the TSI channel list. |
| 953 |
|
| 954 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 955 |
#if !SKIP_Oct6100ApiReserveTsiCnctEntry |
| 956 |
UINT32 Oct6100ApiReserveTsiCnctEntry( |
| 957 |
IN tPOCT6100_INSTANCE_API f_pApiInstance, |
| 958 |
OUT PUINT16 f_pusTsiChanIndex ) |
| 959 |
{ |
| 960 |
tPOCT6100_SHARED_INFO pSharedInfo; |
| 961 |
PVOID pTsiChanAlloc; |
| 962 |
UINT32 ulResult; |
| 963 |
UINT32 ulTsiIndex; |
| 964 |
|
| 965 |
/* Get local pointer to shared portion of instance. */ |
| 966 |
pSharedInfo = f_pApiInstance->pSharedInfo; |
| 967 |
|
| 968 |
mOCT6100_GET_TSI_CNCT_ALLOC_PNT( pSharedInfo, pTsiChanAlloc ) |
| 969 |
|
| 970 |
ulResult = OctapiLlmAllocAlloc( pTsiChanAlloc, &ulTsiIndex ); |
| 971 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 972 |
{ |
| 973 |
if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT ) |
| 974 |
return cOCT6100_ERR_TSI_CNCT_ALL_CHANNELS_ARE_OPENED; |
| 975 |
else |
| 976 |
return cOCT6100_ERR_FATAL_4B; |
| 977 |
} |
| 978 |
|
| 979 |
*f_pusTsiChanIndex = (UINT16)( ulTsiIndex & 0xFFFF ); |
| 980 |
|
| 981 |
return cOCT6100_ERR_OK; |
| 982 |
} |
| 983 |
#endif |
| 984 |
|
| 985 |
|
| 986 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 987 |
|
| 988 |
Function: Oct6100ApiReleaseTsiCnctEntry |
| 989 |
|
| 990 |
Description: Releases the specified TSI connection API entry. |
| 991 |
|
| 992 |
------------------------------------------------------------------------------- |
| 993 |
| Argument | Description |
| 994 |
------------------------------------------------------------------------------- |
| 995 |
f_pApiInstance Pointer to API instance. This memory is used to keep |
| 996 |
the present state of the chip and all its resources. |
| 997 |
|
| 998 |
f_usTsiChanIndex Index reserved in the TSI channel list. |
| 999 |
|
| 1000 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 1001 |
#if !SKIP_Oct6100ApiReleaseTsiCnctEntry |
| 1002 |
UINT32 Oct6100ApiReleaseTsiCnctEntry( |
| 1003 |
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, |
| 1004 |
IN UINT16 f_usTsiChanIndex ) |
| 1005 |
{ |
| 1006 |
tPOCT6100_SHARED_INFO pSharedInfo; |
| 1007 |
PVOID pTsiChanAlloc; |
| 1008 |
UINT32 ulResult; |
| 1009 |
|
| 1010 |
/* Get local pointer to shared portion of instance. */ |
| 1011 |
pSharedInfo = f_pApiInstance->pSharedInfo; |
| 1012 |
|
| 1013 |
mOCT6100_GET_TSI_CNCT_ALLOC_PNT( pSharedInfo, pTsiChanAlloc ) |
| 1014 |
|
| 1015 |
ulResult = OctapiLlmAllocDealloc( pTsiChanAlloc, f_usTsiChanIndex ); |
| 1016 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 1017 |
{ |
| 1018 |
return cOCT6100_ERR_FATAL_4C; |
| 1019 |
} |
| 1020 |
|
| 1021 |
return cOCT6100_ERR_OK; |
| 1022 |
} |
| 1023 |
#endif |