Debian Codegraph @

xpp/oct612x/octdeviceapi/oct6100api/oct6100_api/oct6100_debug.c

raw
1 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2
3 File: oct6100_debug.c
4
5 Copyright (c) 2001-2007 Octasic Inc.
6
7 Description:
8
9 This file contains functions used to debug the OCT6100.
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: 65 $
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 "oct6100api/oct6100_apiud.h"
41 #include "oct6100api/oct6100_tlv_inst.h"
42 #include "oct6100api/oct6100_chip_open_inst.h"
43 #include "oct6100api/oct6100_chip_stats_inst.h"
44 #include "oct6100api/oct6100_interrupts_inst.h"
45 #include "oct6100api/oct6100_remote_debug_inst.h"
46 #include "oct6100api/oct6100_debug_inst.h"
47 #include "oct6100api/oct6100_api_inst.h"
48 #include "oct6100api/oct6100_channel_inst.h"
49
50 #include "oct6100api/oct6100_interrupts_pub.h"
51 #include "oct6100api/oct6100_chip_open_pub.h"
52 #include "oct6100api/oct6100_channel_pub.h"
53 #include "oct6100api/oct6100_debug_pub.h"
54
55 #include "oct6100_chip_open_priv.h"
56 #include "oct6100_channel_priv.h"
57 #include "oct6100_miscellaneous_priv.h"
58 #include "oct6100_memory_priv.h"
59 #include "oct6100_debug_priv.h"
60 #include "oct6100_version.h"
61
62
63 /**************************** PUBLIC FUNCTIONS ****************************/
64
65
66 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
67
68 Function: Oct6100DebugSelectChannel
69
70 Description: This function sets the current debug channel.
71
72 -------------------------------------------------------------------------------
73 | Argument | Description
74 -------------------------------------------------------------------------------
75 f_pApiInstance Pointer to API instance. This memory is used to keep the
76 present state of the chip and all its resources.
77
78 f_pSelectDebugChan Pointer to select debug channel structure.
79
80 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
81 #if !SKIP_Oct6100DebugSelectChannelDef
82 UINT32 Oct6100DebugSelectChannelDef(
83 tPOCT6100_DEBUG_SELECT_CHANNEL f_pSelectDebugChan )
84 {
85 f_pSelectDebugChan->ulChannelHndl = cOCT6100_INVALID_VALUE;
86
87 return cOCT6100_ERR_OK;
88 }
89 #endif
90
91 #if !SKIP_Oct6100DebugSelectChannel
92 UINT32 Oct6100DebugSelectChannel(
93 tPOCT6100_INSTANCE_API f_pApiInstance,
94 tPOCT6100_DEBUG_SELECT_CHANNEL f_pSelectDebugChan )
95 {
96 tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
97 tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
98 UINT32 ulSerRes = cOCT6100_ERR_OK;
99 UINT32 ulFncRes = cOCT6100_ERR_OK;
100
101 /* Set the process context of the serialize structure. */
102 SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
103 ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
104
105 /* Seize all list semaphores needed by this function. */
106 SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
107 SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
108 ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
109 if ( ulSerRes == cOCT6100_ERR_OK )
110 {
111 /* Call the serialized function. */
112 ulFncRes = Oct6100DebugSelectChannelSer( f_pApiInstance, f_pSelectDebugChan, TRUE );
113 }
114 else
115 {
116 return ulSerRes;
117 }
118
119 /* Release the seized semaphores. */
120 ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
121 ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
122
123 /* If an error occured then return the error code. */
124 if ( ulSerRes != cOCT6100_ERR_OK )
125 return ulSerRes;
126 if ( ulFncRes != cOCT6100_ERR_OK )
127 return ulFncRes;
128
129 return cOCT6100_ERR_OK;
130 }
131 #endif
132
133
134 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
135
136 Function: Oct6100DebugGetData
137
138 Description: This function retrieves the last recorded debug data.
139
140 -------------------------------------------------------------------------------
141 | Argument | Description
142 -------------------------------------------------------------------------------
143 f_pApiInstance Pointer to API instance. This memory is used to keep the
144 present state of the chip and all its resources.
145
146 f_pGetData Pointer to debug get data structure.
147
148 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
149 #if !SKIP_Oct6100DebugGetDataDef
150 UINT32 Oct6100DebugGetDataDef(
151 tPOCT6100_DEBUG_GET_DATA f_pGetData )
152 {
153 f_pGetData->ulGetDataMode = cOCT6100_DEBUG_GET_DATA_MODE_120S_LITE;
154 f_pGetData->ulGetDataContent = cOCT6100_DEBUG_GET_DATA_CONTENT_COMPLETE;
155 f_pGetData->ulRemainingNumBytes = cOCT6100_INVALID_VALUE;
156 f_pGetData->ulTotalNumBytes = cOCT6100_INVALID_VALUE;
157 f_pGetData->ulMaxBytes = cOCT6100_INVALID_VALUE;
158 f_pGetData->ulValidNumBytes = cOCT6100_INVALID_VALUE;
159 f_pGetData->pbyData = NULL;
160
161 return cOCT6100_ERR_OK;
162 }
163 #endif
164
165 #if !SKIP_Oct6100DebugGetData
166 UINT32 Oct6100DebugGetData(
167 tPOCT6100_INSTANCE_API f_pApiInstance,
168 tPOCT6100_DEBUG_GET_DATA f_pGetData )
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 = Oct6100DebugGetDataSer( f_pApiInstance, f_pGetData );
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: Oct6100DebugSelectChannelSer
213
214 Description: This function sets the debug channel.
215
216 -------------------------------------------------------------------------------
217 | Argument | Description
218 -------------------------------------------------------------------------------
219 f_pApiInstance Pointer to API instance. This memory is used to keep the
220 present state of the chip and all its resources.
221
222 f_pSelectDebugChan Pointer to a tOCT6100_DEBUG_SELECT_CHANNEL structure.
223 f_fCheckChannelRecording Check if channel recording is enabled or not.
224
225 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
226 #if !SKIP_Oct6100DebugSelectChannelSer
227 UINT32 Oct6100DebugSelectChannelSer(
228 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
229 IN tPOCT6100_DEBUG_SELECT_CHANNEL f_pSelectDebugChan,
230 IN BOOL f_fCheckChannelRecording )
231 {
232 tPOCT6100_SHARED_INFO pSharedInfo;
233 tPOCT6100_API_CHANNEL pChanEntry = NULL;
234 tPOCT6100_API_CHANNEL pTempChanEntry;
235 tOCT6100_CHANNEL_OPEN TempChanOpen;
236 tOCT6100_WRITE_BURST_PARAMS BurstParams;
237 UINT16 usChanIndex = 0;
238 UINT32 ulEntryOpenCnt;
239 UINT16 ausWriteData[ 2 ];
240 UINT32 ulResult;
241
242 /* Get local pointer(s). */
243 pSharedInfo = f_pApiInstance->pSharedInfo;
244
245 BurstParams.pProcessContext = f_pApiInstance->pProcessContext;
246
247 BurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
248 BurstParams.pusWriteData = ausWriteData;
249
250 /* First release the resources reserved for the channel that was previously debugged. */
251 if ( pSharedInfo->DebugInfo.usCurrentDebugChanIndex != cOCT6100_INVALID_INDEX &&
252 pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE )
253 {
254 /*=======================================================================*/
255 /* Get a pointer to the channel's list entry. */
256
257 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempChanEntry, pSharedInfo->DebugInfo.usCurrentDebugChanIndex )
258
259 /* Release the extra TSI memory entry and reprogram the TSST control memory if required. */
260 if ( pTempChanEntry->usExtraSinTsiDependencyCnt >= 1 )
261 {
262 /*=======================================================================*/
263 /* Clear memcpy operations. */
264
265 BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pSharedInfo->MixerInfo.usRecordCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
266 BurstParams.ulWriteLength = 2;
267
268 ausWriteData[ 0 ] = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
269 ausWriteData[ 1 ] = 0x0;
270
271 mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
272 if ( ulResult != cOCT6100_ERR_OK )
273 return ulResult;
274
275 BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pSharedInfo->MixerInfo.usRecordSinEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
276
277 mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
278 if ( ulResult != cOCT6100_ERR_OK )
279 return ulResult;
280
281 /*=======================================================================*/
282
283 /* If we are the last dependency using the extra Sin TSI, release it */
284 if ( pTempChanEntry->usExtraSinTsiDependencyCnt == 1 )
285 {
286 ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pTempChanEntry->usExtraSinTsiMemIndex );
287 if ( ulResult != cOCT6100_ERR_OK )
288 return ulResult;
289
290 /* Do not forget to reprogram the TSST control memory. */
291 if ( pTempChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
292 {
293 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
294 pTempChanEntry->usSinTsstIndex,
295 pTempChanEntry->usSinSoutTsiMemIndex,
296 pTempChanEntry->TdmConfig.bySinPcmLaw );
297 if ( ulResult != cOCT6100_ERR_OK )
298 return ulResult;
299 }
300 pTempChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX;
301
302 /* XXX: What about the silence TSI usSinSilenceEventIndex ?? */
303 }
304
305 pTempChanEntry->usExtraSinTsiDependencyCnt--;
306
307 }
308 }
309
310 /* Set the new parameters. */
311 if ( f_pSelectDebugChan->ulChannelHndl != cOCT6100_INVALID_HANDLE )
312 {
313 /* Check the provided handle. */
314 if ( (f_pSelectDebugChan->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
315 return cOCT6100_ERR_DEBUG_CHANNEL_INVALID_HANDLE;
316
317 usChanIndex = (UINT16)( f_pSelectDebugChan->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
318 if ( usChanIndex >= pSharedInfo->ChipConfig.usMaxChannels )
319 return cOCT6100_ERR_DEBUG_CHANNEL_INVALID_HANDLE;
320
321 if ( f_fCheckChannelRecording == TRUE )
322 {
323 if ( pSharedInfo->ChipConfig.fEnableChannelRecording == FALSE )
324 return cOCT6100_ERR_DEBUG_CHANNEL_RECORDING_DISABLED;
325 }
326
327 /*=======================================================================*/
328 /* Get a pointer to the channel's list entry. */
329
330 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, usChanIndex );
331
332 /* Extract the entry open count from the provided handle. */
333 ulEntryOpenCnt = ( f_pSelectDebugChan->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
334
335 /* Check for errors. */
336 if ( pChanEntry->fReserved != TRUE )
337 return cOCT6100_ERR_CHANNEL_NOT_OPEN;
338 if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt )
339 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
340
341 /*=======================================================================*/
342
343 /* First program the mixer entry if the user wants to record. */
344 /* Check if the API needs to reserve an extra TSI memory to load the SIN signal. */
345 if ( pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE )
346 {
347 /* Reserve the extra Sin TSI memory if it was not already reserved. */
348 if ( pChanEntry->usExtraSinTsiMemIndex == cOCT6100_INVALID_INDEX )
349 {
350 ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance, &pChanEntry->usExtraSinTsiMemIndex );
351 if ( ulResult != cOCT6100_ERR_OK )
352 return ulResult;
353
354 /* Reprogram the TSST control memory accordingly. */
355 if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
356 {
357 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
358 pChanEntry->usSinTsstIndex,
359 pChanEntry->usExtraSinTsiMemIndex,
360 pChanEntry->TdmConfig.bySinPcmLaw );
361 if ( ulResult != cOCT6100_ERR_OK )
362 return ulResult;
363 }
364
365 /* XXX: What about the silence TSI usSinSilenceEventIndex ?? */
366 }
367
368
369 /*=======================================================================*/
370 /* Program the Sout Copy event. */
371 BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pSharedInfo->MixerInfo.usRecordCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
372 BurstParams.ulWriteLength = 2;
373
374 ausWriteData[ 0 ] = cOCT6100_MIXER_CONTROL_MEM_COPY;
375 ausWriteData[ 0 ] |= pChanEntry->usSinSoutTsiMemIndex;
376 ausWriteData[ 0 ] |= pChanEntry->TdmConfig.bySinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
377 ausWriteData[ 1 ] = (UINT16)( pSharedInfo->DebugInfo.usRecordRinRoutTsiMemIndex );
378
379 mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
380 if ( ulResult != cOCT6100_ERR_OK )
381 return ulResult;
382 /*=======================================================================*/
383
384 /*=======================================================================*/
385 /* Program the Sin copy event. */
386 BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pSharedInfo->MixerInfo.usRecordSinEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
387 BurstParams.ulWriteLength = 2;
388
389 ausWriteData[ 0 ] = cOCT6100_MIXER_CONTROL_MEM_COPY;
390 ausWriteData[ 0 ] |= pChanEntry->usExtraSinTsiMemIndex;
391 ausWriteData[ 0 ] |= pChanEntry->TdmConfig.bySinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
392 ausWriteData[ 1 ] = pChanEntry->usSinSoutTsiMemIndex;
393
394 mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
395 if ( ulResult != cOCT6100_ERR_OK )
396 return ulResult;
397 /*=======================================================================*/
398
399 pChanEntry->usExtraSinTsiDependencyCnt++;
400 }
401 }
402 else
403 {
404 /* Set the index to invalid to deactivate the recording. */
405 usChanIndex = cOCT6100_INVALID_INDEX;
406 }
407
408 /* Set law of newly selected hot channel. */
409 if ( ( pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE )
410 && ( f_pSelectDebugChan->ulChannelHndl != cOCT6100_INVALID_HANDLE )
411 && ( pChanEntry != NULL ) )
412 {
413 /* Set the PCM law of the debug channel. */
414 /* Let's program the channel memory. */
415 Oct6100ChannelOpenDef( &TempChanOpen );
416
417 TempChanOpen.ulEchoOperationMode = cOCT6100_ECHO_OP_MODE_HT_RESET; /* Activate the channel. */
418 TempChanOpen.VqeConfig.fEnableNlp = FALSE;
419 TempChanOpen.VqeConfig.ulComfortNoiseMode = cOCT6100_COMFORT_NOISE_NORMAL;
420 TempChanOpen.VqeConfig.fSinDcOffsetRemoval = FALSE;
421 TempChanOpen.VqeConfig.fRinDcOffsetRemoval = FALSE;
422 TempChanOpen.VqeConfig.lDefaultErlDb = 0;
423
424 /* Use the law of the channel being recorded. */
425 TempChanOpen.TdmConfig.ulRinPcmLaw = pChanEntry->TdmConfig.byRinPcmLaw;
426 TempChanOpen.TdmConfig.ulSinPcmLaw = pChanEntry->TdmConfig.bySinPcmLaw;
427 TempChanOpen.TdmConfig.ulRoutPcmLaw = pChanEntry->TdmConfig.byRoutPcmLaw;
428 TempChanOpen.TdmConfig.ulSoutPcmLaw = pChanEntry->TdmConfig.bySoutPcmLaw;
429
430 ulResult = Oct6100ApiWriteDebugChanMemory( f_pApiInstance,
431 &TempChanOpen.TdmConfig,
432 &TempChanOpen.VqeConfig,
433 &TempChanOpen,
434 pSharedInfo->DebugInfo.usRecordChanIndex,
435 pSharedInfo->DebugInfo.usRecordMemIndex,
436 pSharedInfo->DebugInfo.usRecordRinRoutTsiMemIndex,
437 pSharedInfo->DebugInfo.usRecordSinSoutTsiMemIndex );
438 if ( ulResult != cOCT6100_ERR_OK )
439 return ulResult;
440 }
441
442 ausWriteData[ 0 ] = 0x0;
443 ausWriteData[ 1 ] = (UINT16)(( usChanIndex >> 0) & 0xFFFF);
444
445 /* Write the channel number into the Matrix hot channel field.*/
446 BurstParams.ulWriteAddress = pSharedInfo->DebugInfo.ulHotChannelSelectBaseAddress;
447 BurstParams.pusWriteData = ausWriteData;
448 BurstParams.ulWriteLength = 2;
449
450 mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
451 if ( ulResult != cOCT6100_ERR_OK )
452 return ulResult;
453
454 pSharedInfo->DebugInfo.usCurrentDebugChanIndex = usChanIndex;
455
456 /* Cancel data dump request, if there was one. */
457 pSharedInfo->DebugInfo.fDebugDataBeingDumped = FALSE;
458 pSharedInfo->DebugInfo.ulDebugDataTotalNumBytes = cOCT6100_INVALID_VALUE;
459
460 /* Call from remote client. */
461 if ( f_fCheckChannelRecording == FALSE )
462 {
463 /* If the user has not activated recording, let the remote client know. */
464 if ( pSharedInfo->ChipConfig.fEnableChannelRecording == FALSE )
465 return cOCT6100_ERR_DEBUG_RC_CHANNEL_RECORDING_DISABLED;
466 }
467
468 return cOCT6100_ERR_OK;
469 }
470 #endif
471
472
473 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
474
475 Function: Oct6100DebugGetDataSer
476
477 Description: This function retrieves the latest recorded debug data.
478
479 -------------------------------------------------------------------------------
480 | Argument | Description
481 -------------------------------------------------------------------------------
482 f_pApiInstance Pointer to API instance. This memory is used to keep the
483 present state of the chip and all its resources.
484
485 f_pGetData Pointer to a tOCT6100_DEBUG_GET_DATA structure.
486
487 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
488 #if !SKIP_Oct6100DebugGetDataSer
489 UINT32 Oct6100DebugGetDataSer(
490 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
491 IN OUT tPOCT6100_DEBUG_GET_DATA f_pGetData )
492 {
493
494 tPOCT6100_SHARED_INFO pSharedInfo;
495 tPOCT6100_API_CHANNEL pChanEntry = NULL;
496 tOCT6100_READ_PARAMS ReadParams;
497 tOCT6100_WRITE_PARAMS WriteParams;
498 tOCT6100_READ_BURST_PARAMS ReadBurstParams;
499 tOCT6100_WRITE_BURST_PARAMS WriteBurstParams;
500
501 UINT16 ausWriteData[ 2 ];
502 UINT16 usReadData;
503 UINT16 usDebugEventReadPtr;
504 UINT16 usTempNumEvents;
505
506 UINT32 ulResult;
507 UINT32 ulToneEventIndex;
508 UINT32 ulReadPointer;
509 UINT32 ulUserBufWriteIndex = 0;
510 UINT32 ulTimestamp;
511 UINT32 ulDebugEventIndex = 0;
512 UINT32 ulStreamIndex;
513 UINT32 ulPcmSampleIndex;
514 UINT32 ulNumAfEvents;
515 UINT32 ulNumReads = 0;
516 UINT32 ulTempIndex;
517 UINT32 ulCopyIndex;
518 UINT32 ulFeatureBytesOffset;
519 UINT32 ulFeatureBitOffset;
520 UINT32 ulFeatureFieldLength;
521 UINT32 ulStreamIndexMin;
522 UINT32 ulStreamIndexMax;
523 UINT32 ulTempData;
524 UINT32 ulMask;
525 BOOL fResetRemainingDataFlag = FALSE;
526
527 /* Get local pointer(s). */
528 pSharedInfo = f_pApiInstance->pSharedInfo;
529
530 ReadBurstParams.pProcessContext = f_pApiInstance->pProcessContext;
531
532 ReadBurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
533
534 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
535
536 ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
537
538 WriteBurstParams.pProcessContext = f_pApiInstance->pProcessContext;
539
540 WriteBurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
541
542 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
543
544 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
545
546 /* Check all user parameters. */
547
548 /* Check if channel recording is enabled. */
549 if ( pSharedInfo->ChipConfig.fEnableChannelRecording == FALSE )
550 return cOCT6100_ERR_DEBUG_CHANNEL_RECORDING_DISABLED;
551
552 /* Check if a current debugging channel has been selected. */
553 /* If not, the user has not yet called Oct6100DebugSelectChannel. */
554 if ( pSharedInfo->DebugInfo.usCurrentDebugChanIndex == cOCT6100_INVALID_INDEX )
555 return cOCT6100_ERR_DEBUG_RECORD_NO_CHAN_SELECTED;
556
557 /* Check that the user supplied a valid max bytes value. */
558 if ( f_pGetData->ulMaxBytes == cOCT6100_INVALID_VALUE )
559 return cOCT6100_ERR_DEBUG_GET_DATA_MAX_BYTES;
560
561 /* Data buffer must be aligned on 1024 bytes. */
562 if ( ( f_pGetData->ulMaxBytes % 1024 ) != 0 )
563 return cOCT6100_ERR_DEBUG_GET_DATA_MAX_BYTES;
564
565 /* Check that the user provided the required memory to transfer the information. */
566 if ( f_pGetData->pbyData == NULL )
567 return cOCT6100_ERR_DEBUG_GET_DATA_PTR_INVALID;
568
569 /* Check dump type. */
570 if ( ( f_pGetData->ulGetDataMode != cOCT6100_DEBUG_GET_DATA_MODE_16S_LITE )
571 && ( f_pGetData->ulGetDataMode != cOCT6100_DEBUG_GET_DATA_MODE_120S_LITE )
572 && ( f_pGetData->ulGetDataMode != cOCT6100_DEBUG_GET_DATA_MODE_16S )
573 && ( f_pGetData->ulGetDataMode != cOCT6100_DEBUG_GET_DATA_MODE_120S ) )
574 return cOCT6100_ERR_DEBUG_GET_DATA_MODE;
575
576 /* Check dump content. */
577 if ( ( f_pGetData->ulGetDataContent != cOCT6100_DEBUG_GET_DATA_CONTENT_COMPLETE )
578 && ( f_pGetData->ulGetDataContent != cOCT6100_DEBUG_GET_DATA_CONTENT_RIN_PCM )
579 && ( f_pGetData->ulGetDataContent != cOCT6100_DEBUG_GET_DATA_CONTENT_SIN_PCM )
580 && ( f_pGetData->ulGetDataContent != cOCT6100_DEBUG_GET_DATA_CONTENT_SOUT_PCM ) )
581 return cOCT6100_ERR_DEBUG_GET_DATA_CONTENT;
582
583 /* Check if can accomodate the 120 seconds dump. */
584 if ( ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S_LITE )
585 || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) )
586 {
587 if ( pSharedInfo->DebugInfo.ulDebugEventSize != 0x100 )
588 return cOCT6100_ERR_NOT_SUPPORTED_DEBUG_DATA_MODE_120S;
589 }
590
591 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, pSharedInfo->DebugInfo.usCurrentDebugChanIndex )
592
593 /* Lets go dump the requested data. */
594
595 usDebugEventReadPtr = 0;
596
597 /* Check if this is the first time this function is called since the hot channel was set. */
598 if ( pSharedInfo->DebugInfo.fDebugDataBeingDumped == FALSE )
599 {
600 /* Check that the channel is not in POWER_DOWN. When the channel is in POWER_DOWN, */
601 /* the debug events are not recorded correctly in external memory. */
602 if ( pChanEntry->byEchoOperationMode == cOCT6100_ECHO_OP_MODE_POWER_DOWN )
603 return cOCT6100_ERR_DEBUG_CHANNEL_IN_POWER_DOWN;
604
605 pSharedInfo->DebugInfo.fDebugDataBeingDumped = TRUE;
606
607 /* Flag the hot channel that it must stop recording. The data is being transfered. */
608 /* This also tells the remote client not to do anything right now. */
609
610 ReadBurstParams.ulReadAddress = pSharedInfo->DebugInfo.ulHotChannelSelectBaseAddress;
611 ReadBurstParams.ulReadLength = 2;
612 ReadBurstParams.pusReadData = pSharedInfo->DebugInfo.ausHotChannelData;
613
614 mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult );
615 if ( ulResult != cOCT6100_ERR_OK )
616 return ulResult;
617
618 WriteBurstParams.pusWriteData = ausWriteData;
619 WriteBurstParams.ulWriteAddress = pSharedInfo->DebugInfo.ulHotChannelSelectBaseAddress;
620 WriteBurstParams.ulWriteLength = 2;
621
622 WriteBurstParams.pusWriteData[ 0 ] = 0xFFFF;
623 WriteBurstParams.pusWriteData[ 1 ] = 0xFFFF;
624
625 mOCT6100_DRIVER_WRITE_BURST_API( WriteBurstParams, ulResult );
626 if ( ulResult != cOCT6100_ERR_OK )
627 return ulResult;
628
629 /* Get the maximum number of events this firmware supports from the TLVs. */
630 pSharedInfo->DebugInfo.usMatrixCBMask = (UINT16)( pSharedInfo->DebugInfo.ulDebugEventSize & 0xFFFF );
631 pSharedInfo->DebugInfo.usMatrixCBMask -= 1;
632
633 /* Find out the chip log write pointer. */
634
635 /* Now get the current write pointer for matrix events. */
636 ReadParams.pusReadData = &pSharedInfo->DebugInfo.usChipDebugEventWritePtr;
637 ReadParams.ulReadAddress = pSharedInfo->DebugInfo.ulMatrixWpBaseAddress + 2;
638
639 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
640 if ( ulResult != cOCT6100_ERR_OK )
641 return ulResult;
642
643 ReadParams.pusReadData = &usReadData;
644
645 /* This write pointer might have wrapped, but we don't know for sure. */
646 /* To be confident, the chip frame timestamp is read. */
647 ReadParams.ulReadAddress = pSharedInfo->DebugInfo.ulMatrixTimestampBaseAddress;
648
649 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
650 if ( ulResult != cOCT6100_ERR_OK )
651 return ulResult;
652
653 ulTimestamp = usReadData << 16;
654
655 ReadParams.ulReadAddress += 2;
656
657 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
658 if ( ulResult != cOCT6100_ERR_OK )
659 return ulResult;
660
661 ulTimestamp |= usReadData;
662
663 ulTimestamp >>= 12; /* TDM time for 1 event (512 ms) */
664
665 /* There is a probability here (once very 6.2 days) that the timestamp is close */
666 /* to 0, because it has wrapped. But still, we need a way to workaround the highly */
667 /* occuring case of the chip just being opened. This will fix this problem. */
668 if ( ulTimestamp < (UINT32)( pSharedInfo->DebugInfo.usMatrixCBMask + 1 ) )
669 {
670 if ( pSharedInfo->DebugInfo.usChipDebugEventWritePtr >= 2 )
671 {
672 /* Must trash the first 2 events. The chip is not yet ready. */
673 pSharedInfo->DebugInfo.usNumEvents = (UINT16)( pSharedInfo->DebugInfo.usChipDebugEventWritePtr - 2 );
674 }
675 else
676 {
677 pSharedInfo->DebugInfo.usNumEvents = 0x0;
678 }
679 }
680 else
681 {
682 pSharedInfo->DebugInfo.usNumEvents = (UINT16)( pSharedInfo->DebugInfo.usMatrixCBMask + 1 );
683
684 /* Account for event being created right now while the chip is running. */
685 /* The event at the write pointer will be discarded. */
686 if ( pSharedInfo->DebugInfo.usNumEvents > 0 )
687 pSharedInfo->DebugInfo.usNumEvents--;
688 }
689
690
691 /* If the user only requested the last 16 seconds, cap the number of events. */
692 if ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S
693 || f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S_LITE )
694 {
695 /* x events to get the last 16 seconds. */
696 if ( pSharedInfo->DebugInfo.usNumEvents > ( 16000 / ( pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize / 8 ) ) )
697 pSharedInfo->DebugInfo.usNumEvents = (UINT16)( ( 16000 / ( pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize / 8 ) ) & 0xFFFF );
698 }
699
700 /* Make sure that all the events are pertaining to the current hot channel. */
701 /* Calculate the event read pointer. */
702 ulReadPointer = ( ( pSharedInfo->DebugInfo.usChipDebugEventWritePtr - pSharedInfo->DebugInfo.usNumEvents ) & pSharedInfo->DebugInfo.usMatrixCBMask ) * pSharedInfo->DebugInfo.ulDebugChanStatsByteSize;
703 ulReadPointer %= ( ( pSharedInfo->DebugInfo.usMatrixCBMask + 1 ) * pSharedInfo->DebugInfo.ulDebugChanStatsByteSize );
704
705 /* Travel through the events and throw away the bad events. */
706 usTempNumEvents = pSharedInfo->DebugInfo.usNumEvents;
707 pSharedInfo->DebugInfo.usNumEvents = 0;
708 for ( ulDebugEventIndex = 0; ulDebugEventIndex < usTempNumEvents; ulDebugEventIndex ++ )
709 {
710 /* The HOT channel index for the event is stored at offset 0xF2 (word offset) */
711
712 ReadParams.ulReadAddress = pSharedInfo->DebugInfo.ulMatrixBaseAddress + ulReadPointer;
713 ReadParams.ulReadAddress += 0xF2 * sizeof(UINT16);
714 ReadParams.pusReadData = &usReadData;
715
716 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
717 if ( ulResult != cOCT6100_ERR_OK )
718 return ulResult;
719
720 /* Check if the current debug index is the same as the one found in the event. */
721 if ( usReadData != pSharedInfo->DebugInfo.usCurrentDebugChanIndex )
722 pSharedInfo->DebugInfo.usNumEvents = 0; /* As soon as we hit another channel, we reset the number of valid events. */
723 else
724 pSharedInfo->DebugInfo.usNumEvents++;
725
726 /* Increment read pointer to get next event. */
727 ulReadPointer = ( ulReadPointer + pSharedInfo->DebugInfo.ulDebugChanStatsByteSize ) % ( ( pSharedInfo->DebugInfo.usMatrixCBMask + 1 ) * pSharedInfo->DebugInfo.ulDebugChanStatsByteSize );
728 }
729
730 /* In heavy mode, the AF log pointer is retrieved. */
731 if ( ( pSharedInfo->DebugInfo.usNumEvents >= 2 )
732 && ( ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S )
733 || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) ) )
734 {
735 /* The latest AF log write pointer is at the latest matrix event. */
736 ReadParams.ulReadAddress = pSharedInfo->DebugInfo.ulMatrixBaseAddress + ( ( pSharedInfo->DebugInfo.usChipDebugEventWritePtr & pSharedInfo->DebugInfo.usMatrixCBMask ) * 1024 );
737
738 /* To get the AF log write pointer, which is at offset pSharedInfo->ImageInfo.ulAfWritePtrByteOffset. */
739 ReadParams.ulReadAddress += pSharedInfo->DebugInfo.ulAfWritePtrByteOffset;
740 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
741 if ( ulResult != cOCT6100_ERR_OK )
742 return ulResult;
743
744 pSharedInfo->DebugInfo.usAfLogWritePtr = usReadData;
745
746 /* The AF event read pointer is the AF write pointer +4096 */
747 /* This will make sure we do not get mixed up and fetch events that have */
748 /* just been written, but we think are old. */
749
750 /* To get the exact AF log pointer, the API would have to wait 512 milliseconds to make */
751 /* sure logging had stopped. This is not required since missing a few last events is not */
752 /* important at this point (the user knows that valid data has already been recorded). */
753 pSharedInfo->DebugInfo.usLastAfLogReadPtr = (UINT16)( ( pSharedInfo->DebugInfo.usAfLogWritePtr + 4096 ) & 0xFFFF );
754
755 /* Note that if the chip has just been booted, some of the AF events might not be initialized. */
756 }
757 else
758 {
759 pSharedInfo->DebugInfo.usLastAfLogReadPtr = 0;
760 pSharedInfo->DebugInfo.usAfLogWritePtr = 0;
761 }
762
763 /* To be aligned correctly for the bursts. */
764 while ( ( pSharedInfo->DebugInfo.usLastAfLogReadPtr % ( cOCT6100_INTERNAL_SUPER_ARRAY_SIZE / 8 ) ) != 0 )
765 pSharedInfo->DebugInfo.usLastAfLogReadPtr++;
766
767 /* Remember the data mode for later checks. Also, the user cannot change this "mode". */
768 pSharedInfo->DebugInfo.ulCurrentGetDataMode = f_pGetData->ulGetDataMode;
769 }
770 else
771 {
772 /* Check that the user did not change the current data mode. */
773 if ( pSharedInfo->DebugInfo.ulCurrentGetDataMode != f_pGetData->ulGetDataMode )
774 return cOCT6100_ERR_DEBUG_GET_DATA_MODE_CANNOT_CHANGE;
775 }
776
777 /* Check if this is the first pass here. */
778 if ( pSharedInfo->DebugInfo.ulDebugDataTotalNumBytes == cOCT6100_INVALID_VALUE )
779 {
780 /* Calculate how many bytes of data will be returned with respect to the selected data content. */
781
782 /* Check what content type the user requested. */
783 if ( f_pGetData->ulGetDataContent == cOCT6100_DEBUG_GET_DATA_CONTENT_COMPLETE )
784 {
785 /* Remember first AF Event Read Pointer. */
786 f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( ( pSharedInfo->DebugInfo.usLastAfLogReadPtr ) & 0xFF );
787 f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( ( pSharedInfo->DebugInfo.usLastAfLogReadPtr >> 8 ) & 0xFF );
788
789 /* Remember the AF Event Write Pointer. */
790 f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( ( pSharedInfo->DebugInfo.usAfLogWritePtr ) & 0xFF );
791 f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( ( pSharedInfo->DebugInfo.usAfLogWritePtr >> 8 ) & 0xFF );
792
793 /* Remember law and hot channel */
794 f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( pChanEntry->TdmConfig.bySinPcmLaw | ( ( pSharedInfo->DebugInfo.usCurrentDebugChanIndex >> 2 ) & 0xFE ) );
795 f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( pChanEntry->TdmConfig.bySoutPcmLaw );
796
797 /* Insert light or heavy mode in array. */
798 if ( ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S_LITE )
799 || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S_LITE ) )
800 {
801 f_pGetData->pbyData[ ulUserBufWriteIndex - 1 ] |= 0x80;
802 }
803 f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( pChanEntry->TdmConfig.byRinPcmLaw | ( ( pSharedInfo->DebugInfo.usCurrentDebugChanIndex & 0x1F ) << 3 ) );
804
805 /* Remember usNumEvents */
806 f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( ( pSharedInfo->DebugInfo.usNumEvents ) & 0xFF );
807 f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( ( pSharedInfo->DebugInfo.usNumEvents >> 8 ) & 0xFF );
808 }
809
810 /* Last indexes set to '0'! */
811 pSharedInfo->DebugInfo.usLastDebugEventIndex = 0;
812 pSharedInfo->DebugInfo.ulLastPcmSampleIndex = 0;
813
814 /* No tone event has been retrieved. */
815 pSharedInfo->DebugInfo.usLastToneEventIndex = 0;
816
817 /* The version strings have not yet been copied. */
818 pSharedInfo->DebugInfo.fImageVersionCopied = FALSE;
819 pSharedInfo->DebugInfo.fApiVersionCopied = FALSE;
820
821 /* Estimate the total size of the buffer that will be returned. */
822 f_pGetData->ulTotalNumBytes = ulUserBufWriteIndex;
823
824 /* If the full content is requested, add all the debug data. */
825 if ( f_pGetData->ulGetDataContent == cOCT6100_DEBUG_GET_DATA_CONTENT_COMPLETE )
826 {
827 /* Add the matrix events. */
828 if ( ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S )
829 || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) )
830 {
831 /* Heavy mode! Grab everything! */
832 f_pGetData->ulTotalNumBytes += pSharedInfo->DebugInfo.usNumEvents * pSharedInfo->DebugInfo.ulDebugChanStatsByteSize;
833 }
834 else
835 {
836 /* Lite mode! Only the most important stuff. */
837 f_pGetData->ulTotalNumBytes += pSharedInfo->DebugInfo.usNumEvents * pSharedInfo->DebugInfo.ulDebugChanLiteStatsByteSize;
838 }
839
840 /* Add the PCM samples. */
841 f_pGetData->ulTotalNumBytes += pSharedInfo->DebugInfo.usNumEvents * pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize * 3;
842
843 /* If requested, add the AF log events. */
844 if ( ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S )
845 || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) )
846 {
847 f_pGetData->ulTotalNumBytes += (UINT32)( ( pSharedInfo->DebugInfo.usAfLogWritePtr - pSharedInfo->DebugInfo.usLastAfLogReadPtr ) & 0xFFFF ) * 16;
848 }
849
850 /* Add the tone events strings. */
851 f_pGetData->ulTotalNumBytes += cOCT6100_TLV_MAX_TONE_NAME_SIZE * pSharedInfo->ImageInfo.byNumToneDetectors;
852
853 /* Add the image version string. */
854 f_pGetData->ulTotalNumBytes += 512;
855
856 /* Add the API version string. */
857 f_pGetData->ulTotalNumBytes += sizeof( cOCT6100_API_VERSION );
858 }
859 else /* if ( f_pGetData->ulGetDataContent != cOCT6100_DEBUG_GET_DATA_CONTENT_COMPLETE ) */
860 {
861 /* Add one PCM stream. */
862 f_pGetData->ulTotalNumBytes += pSharedInfo->DebugInfo.usNumEvents * pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize;
863 }
864
865 /* Save this in the instance for further calls. */
866 pSharedInfo->DebugInfo.ulDebugDataTotalNumBytes = f_pGetData->ulTotalNumBytes;
867
868 /* Calculate remaining bytes. All the bytes for now! */
869 f_pGetData->ulRemainingNumBytes = f_pGetData->ulTotalNumBytes;
870
871 /* Save this in the instance for the next calls. */
872 pSharedInfo->DebugInfo.ulDebugDataRemainingNumBytes = f_pGetData->ulRemainingNumBytes;
873 }
874 else
875 {
876 f_pGetData->ulTotalNumBytes = pSharedInfo->DebugInfo.ulDebugDataTotalNumBytes;
877 }
878
879 /* Calculate the event read pointer. */
880 ulReadPointer = ( ( pSharedInfo->DebugInfo.usChipDebugEventWritePtr - pSharedInfo->DebugInfo.usNumEvents ) & pSharedInfo->DebugInfo.usMatrixCBMask ) * pSharedInfo->DebugInfo.ulDebugChanStatsByteSize;
881
882 ulReadPointer += pSharedInfo->DebugInfo.ulDebugChanStatsByteSize * pSharedInfo->DebugInfo.usLastDebugEventIndex;
883 ulReadPointer %= ( ( pSharedInfo->DebugInfo.usMatrixCBMask + 1 ) * pSharedInfo->DebugInfo.ulDebugChanStatsByteSize );
884
885 if ( f_pGetData->ulGetDataContent == cOCT6100_DEBUG_GET_DATA_CONTENT_COMPLETE )
886 {
887 /* Copy the debug events in the user buffer. */
888 for( ulDebugEventIndex = pSharedInfo->DebugInfo.usLastDebugEventIndex; ulDebugEventIndex < pSharedInfo->DebugInfo.usNumEvents; ulDebugEventIndex ++ )
889 {
890 ReadBurstParams.ulReadAddress = pSharedInfo->DebugInfo.ulMatrixBaseAddress + ulReadPointer;
891
892 /* Check if we are in light or heavy mode. The burst size is not the same. */
893 if ( ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S )
894 || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) )
895 {
896 if ( ( f_pGetData->ulMaxBytes - ulUserBufWriteIndex ) >= pSharedInfo->DebugInfo.ulDebugChanStatsByteSize )
897 ulNumReads = pSharedInfo->DebugInfo.ulDebugChanStatsByteSize / 2;
898 else
899 break;
900 }
901 else
902 {
903 if ( ( f_pGetData->ulMaxBytes - ulUserBufWriteIndex ) >= pSharedInfo->DebugInfo.ulDebugChanLiteStatsByteSize )
904 ulNumReads = pSharedInfo->DebugInfo.ulDebugChanLiteStatsByteSize / 2;
905 else
906 break;
907 }
908
909 ulTempIndex = 0;
910 while ( ulNumReads != 0 )
911 {
912 if ( ulNumReads >= pSharedInfo->ChipConfig.usMaxRwAccesses )
913 ReadBurstParams.ulReadLength = pSharedInfo->ChipConfig.usMaxRwAccesses;
914 else
915 ReadBurstParams.ulReadLength = ulNumReads;
916
917 /* Set pointer where to write data. */
918 ReadBurstParams.pusReadData = pSharedInfo->MiscVars.ausSuperArray;
919
920 mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult );
921 if ( ulResult != cOCT6100_ERR_OK )
922 return ulResult;
923
924 /* Copy data byte per byte to avoid endianess problems. */
925 for ( ulCopyIndex = 0; ulCopyIndex < ReadBurstParams.ulReadLength; ulCopyIndex ++ )
926 {
927 f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex + ( 2 * ulCopyIndex ) ] = (UINT8)( ReadBurstParams.pusReadData[ ulCopyIndex ] & 0xFF );
928 f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex + ( 2 * ulCopyIndex ) + 1 ] = (UINT8)( ( ReadBurstParams.pusReadData[ ulCopyIndex ] >> 8 ) & 0xFF );
929 }
930
931 /* Update indexes, temp variables, addresses. */
932 ulNumReads -= ReadBurstParams.ulReadLength;
933 ulTempIndex += ReadBurstParams.ulReadLength * 2;
934 ReadBurstParams.ulReadAddress += ReadBurstParams.ulReadLength * 2;
935 }
936
937 /* Store register 0x202 in the event structure. */
938 f_pGetData->pbyData[ ulUserBufWriteIndex + 255 ] = (UINT8)( pSharedInfo->IntrptManage.usRegister202h & 0xFF );
939 f_pGetData->pbyData[ ulUserBufWriteIndex + 256 ] = (UINT8)( ( pSharedInfo->IntrptManage.usRegister202h >> 8 ) & 0xFF );
940
941 /* Increment index. */
942 if ( ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S )
943 || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) )
944 {
945 ulUserBufWriteIndex += pSharedInfo->DebugInfo.ulDebugChanStatsByteSize;
946 }
947 else
948 {
949 ulUserBufWriteIndex += pSharedInfo->DebugInfo.ulDebugChanLiteStatsByteSize;
950 }
951
952 /* Increment read pointer to get next event. */
953 ulReadPointer = ( ulReadPointer + pSharedInfo->DebugInfo.ulDebugChanStatsByteSize ) % ( ( pSharedInfo->DebugInfo.usMatrixCBMask + 1 ) * pSharedInfo->DebugInfo.ulDebugChanStatsByteSize );
954
955 /* Save in the instance that one of the events was dumped. */
956 pSharedInfo->DebugInfo.usLastDebugEventIndex ++;
957 }
958 }
959
960 /* Check if all debug events have been transfered. */
961 if ( ( ulDebugEventIndex == pSharedInfo->DebugInfo.usNumEvents )
962 || ( f_pGetData->ulGetDataContent != cOCT6100_DEBUG_GET_DATA_CONTENT_COMPLETE ) )
963 {
964 /* Fetch all streams per event. */
965 for ( ulPcmSampleIndex = pSharedInfo->DebugInfo.ulLastPcmSampleIndex; ulPcmSampleIndex < ( (UINT32)pSharedInfo->DebugInfo.usNumEvents * pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize ); ulPcmSampleIndex ++ )
966 {
967 /* Check if enough room for this sample. */
968 if ( f_pGetData->ulGetDataContent != cOCT6100_DEBUG_GET_DATA_CONTENT_COMPLETE )
969 {
970 if ( ( f_pGetData->ulMaxBytes - ulUserBufWriteIndex ) < 1 )
971 break;
972 }
973 else /* if ( f_pGetData->ulGetDataContent == cOCT6100_DEBUG_GET_DATA_CONTENT_COMPLETE ) */
974 {
975 if ( ( f_pGetData->ulMaxBytes - ulUserBufWriteIndex ) < 3 )
976 break;
977 }
978
979 /* Check if must retrieve data from external memory. */
980 if ( ( ulPcmSampleIndex % ( cOCT6100_INTERNAL_SUPER_ARRAY_SIZE * 2 ) ) == 0x0 )
981 {
982 ulReadPointer = ( ( ( pSharedInfo->DebugInfo.usChipDebugEventWritePtr - pSharedInfo->DebugInfo.usNumEvents ) * pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize ) & ( pSharedInfo->DebugInfo.usMatrixCBMask * pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize ) );
983 ulReadPointer += ( ulPcmSampleIndex / pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize ) * pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize;
984 ulReadPointer &= ( pSharedInfo->DebugInfo.usMatrixCBMask * pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize );
985 ulReadPointer += ulPcmSampleIndex % pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize;
986
987 /* Retrieve more data from external memory. */
988 switch ( f_pGetData->ulGetDataContent )
989 {
990 case cOCT6100_DEBUG_GET_DATA_CONTENT_RIN_PCM:
991 ulStreamIndexMin = 0;
992 ulStreamIndexMax = 1;
993 break;
994 case cOCT6100_DEBUG_GET_DATA_CONTENT_SIN_PCM:
995 ulStreamIndexMin = 1;
996 ulStreamIndexMax = 2;
997 break;
998 case cOCT6100_DEBUG_GET_DATA_CONTENT_SOUT_PCM:
999 ulStreamIndexMin = 2;
1000 ulStreamIndexMax = 3;
1001 break;
1002 case cOCT6100_DEBUG_GET_DATA_CONTENT_COMPLETE:
1003 default:
1004 ulStreamIndexMin = 0;
1005 ulStreamIndexMax = 3;
1006 break;
1007 }
1008
1009 for ( ulStreamIndex = ulStreamIndexMin; ulStreamIndex < ulStreamIndexMax; ulStreamIndex ++ )
1010 {
1011 ReadBurstParams.ulReadAddress = pSharedInfo->MemoryMap.ulChanMainMemBase;
1012 /* To get right channel information. */
1013 ReadBurstParams.ulReadAddress += ( ( pSharedInfo->DebugInfo.usRecordMemIndex + 2 ) * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->DebugInfo.ulAfEventCbByteSize;
1014 /* To get correct stream. */
1015 ReadBurstParams.ulReadAddress += ( ( pSharedInfo->DebugInfo.usMatrixCBMask + 1 ) * pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize * ulStreamIndex );
1016 /* PCM sample pointer in that stream. */
1017 ReadBurstParams.ulReadAddress += ulReadPointer;
1018
1019 /* As much as we can for the burst. */
1020 ulTempIndex = 0;
1021 ulNumReads = cOCT6100_INTERNAL_SUPER_ARRAY_SIZE;
1022 while ( ulNumReads != 0 )
1023 {
1024 if ( ulNumReads >= pSharedInfo->ChipConfig.usMaxRwAccesses )
1025 ReadBurstParams.ulReadLength = pSharedInfo->ChipConfig.usMaxRwAccesses;
1026 else
1027 ReadBurstParams.ulReadLength = ulNumReads;
1028
1029 /* Set pointer where to write data. */
1030 if ( ulStreamIndex == 0 )
1031 ReadBurstParams.pusReadData = &pSharedInfo->MiscVars.ausSuperArray[ ulTempIndex ];
1032 else if ( ulStreamIndex == 1 )
1033 ReadBurstParams.pusReadData = &pSharedInfo->MiscVars.ausSuperArray1[ ulTempIndex ];
1034 else /* if ( ulStreamIndex == 2 ) */
1035 ReadBurstParams.pusReadData = &pSharedInfo->MiscVars.ausSuperArray2[ ulTempIndex ];
1036
1037 mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult );
1038 if ( ulResult != cOCT6100_ERR_OK )
1039 return ulResult;
1040
1041 /* Update indexes, temp variables, addresses. */
1042 ulNumReads -= ReadBurstParams.ulReadLength;
1043 ulTempIndex += ReadBurstParams.ulReadLength;
1044 ReadBurstParams.ulReadAddress += ReadBurstParams.ulReadLength * 2;
1045 }
1046 }
1047 }
1048
1049 /* We now have the stream data for all streams for 1 event. */
1050 /* Return what we can to the user. */
1051 if ( ( ulPcmSampleIndex % 2 ) == 0 )
1052 {
1053 if ( ( f_pGetData->ulGetDataContent == cOCT6100_DEBUG_GET_DATA_CONTENT_COMPLETE )
1054 || ( f_pGetData->ulGetDataContent == cOCT6100_DEBUG_GET_DATA_CONTENT_RIN_PCM ) )
1055 f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( ( pSharedInfo->MiscVars.ausSuperArray[ ( ulPcmSampleIndex / 2 ) % ( cOCT6100_INTERNAL_SUPER_ARRAY_SIZE ) ] >> 8 ) & 0xFF );
1056
1057 if ( ( f_pGetData->ulGetDataContent == cOCT6100_DEBUG_GET_DATA_CONTENT_COMPLETE )
1058 || ( f_pGetData->ulGetDataContent == cOCT6100_DEBUG_GET_DATA_CONTENT_SIN_PCM ) )
1059 f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( ( pSharedInfo->MiscVars.ausSuperArray1[ ( ulPcmSampleIndex / 2 ) % ( cOCT6100_INTERNAL_SUPER_ARRAY_SIZE ) ] >> 8 ) & 0xFF );
1060
1061 if ( ( f_pGetData->ulGetDataContent == cOCT6100_DEBUG_GET_DATA_CONTENT_COMPLETE )
1062 || ( f_pGetData->ulGetDataContent == cOCT6100_DEBUG_GET_DATA_CONTENT_SOUT_PCM ) )
1063 f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( ( pSharedInfo->MiscVars.ausSuperArray2[ ( ulPcmSampleIndex / 2 ) % ( cOCT6100_INTERNAL_SUPER_ARRAY_SIZE ) ] >> 8 ) & 0xFF );
1064 }
1065 else /* if ( ulPcmSampleIndex % 2 == 1 ) */
1066 {
1067 if ( ( f_pGetData->ulGetDataContent == cOCT6100_DEBUG_GET_DATA_CONTENT_COMPLETE )
1068 || ( f_pGetData->ulGetDataContent == cOCT6100_DEBUG_GET_DATA_CONTENT_RIN_PCM ) )
1069 f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( ( pSharedInfo->MiscVars.ausSuperArray[ ( ulPcmSampleIndex / 2 ) % ( cOCT6100_INTERNAL_SUPER_ARRAY_SIZE ) ] >> 0 ) & 0xFF );
1070
1071 if ( ( f_pGetData->ulGetDataContent == cOCT6100_DEBUG_GET_DATA_CONTENT_COMPLETE )
1072 || ( f_pGetData->ulGetDataContent == cOCT6100_DEBUG_GET_DATA_CONTENT_SIN_PCM ) )
1073 f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( ( pSharedInfo->MiscVars.ausSuperArray1[ ( ulPcmSampleIndex / 2 ) % ( cOCT6100_INTERNAL_SUPER_ARRAY_SIZE ) ] >> 0 ) & 0xFF );
1074
1075 if ( ( f_pGetData->ulGetDataContent == cOCT6100_DEBUG_GET_DATA_CONTENT_COMPLETE )
1076 || ( f_pGetData->ulGetDataContent == cOCT6100_DEBUG_GET_DATA_CONTENT_SOUT_PCM ) )
1077 f_pGetData->pbyData[ ulUserBufWriteIndex++ ] = (UINT8)( ( pSharedInfo->MiscVars.ausSuperArray2[ ( ulPcmSampleIndex / 2 ) % ( cOCT6100_INTERNAL_SUPER_ARRAY_SIZE ) ] >> 0 ) & 0xFF );
1078 }
1079
1080 pSharedInfo->DebugInfo.ulLastPcmSampleIndex++;
1081 }
1082
1083 /* Check if we are done dumping the PCM samples! */
1084 if ( pSharedInfo->DebugInfo.ulLastPcmSampleIndex == ( (UINT32)pSharedInfo->DebugInfo.usNumEvents * pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize ) )
1085 {
1086 if ( f_pGetData->ulGetDataContent == cOCT6100_DEBUG_GET_DATA_CONTENT_COMPLETE )
1087 {
1088
1089 /* Go for the AF events. The AF events are only copied in heavy mode. */
1090 if ( ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S )
1091 || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) )
1092 {
1093 while ( pSharedInfo->DebugInfo.usLastAfLogReadPtr != pSharedInfo->DebugInfo.usAfLogWritePtr )
1094 {
1095 /* Check if enough room for an event. */
1096 if ( ( f_pGetData->ulMaxBytes - ulUserBufWriteIndex ) < 16 )
1097 break;
1098
1099 /* Check if must fill our buffer. */
1100 if ( ( pSharedInfo->DebugInfo.usLastAfLogReadPtr % ( cOCT6100_INTERNAL_SUPER_ARRAY_SIZE / 8 ) ) == 0x0 )
1101 {
1102 ulNumAfEvents = ( pSharedInfo->DebugInfo.usAfLogWritePtr - pSharedInfo->DebugInfo.usLastAfLogReadPtr ) & 0xFFFF;
1103
1104 /* Check for the size of the available buffer. */
1105 if ( ulNumAfEvents > ( cOCT6100_INTERNAL_SUPER_ARRAY_SIZE / 8 ) )
1106 ulNumAfEvents = ( cOCT6100_INTERNAL_SUPER_ARRAY_SIZE / 8 );
1107
1108 /* Start at channel main base address. */
1109 ReadBurstParams.ulReadAddress = pSharedInfo->MemoryMap.ulChanMainMemBase;
1110 /* To get right channel information. */
1111 ReadBurstParams.ulReadAddress += ( ( pSharedInfo->DebugInfo.usRecordMemIndex + 2 ) * pSharedInfo->MemoryMap.ulChanMainMemSize );
1112 /* To get the right AF log. */
1113 ReadBurstParams.ulReadAddress += ( pSharedInfo->DebugInfo.usLastAfLogReadPtr * 16 );
1114
1115 ulTempIndex = 0;
1116 ulNumReads = ulNumAfEvents * 8;
1117
1118 while ( ulNumReads != 0 )
1119 {
1120 if ( ulNumReads >= pSharedInfo->ChipConfig.usMaxRwAccesses )
1121 ReadBurstParams.ulReadLength = pSharedInfo->ChipConfig.usMaxRwAccesses;
1122 else
1123 ReadBurstParams.ulReadLength = ulNumReads;
1124
1125 /* Set pointer where to write data. */
1126 ReadBurstParams.pusReadData = &pSharedInfo->MiscVars.ausSuperArray[ ulTempIndex ];
1127
1128 mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult );
1129 if ( ulResult != cOCT6100_ERR_OK )
1130 return ulResult;
1131
1132 /* Update indexes, temp variables, addresses. */
1133 ulNumReads -= ReadBurstParams.ulReadLength;
1134 ulTempIndex += ReadBurstParams.ulReadLength;
1135 ReadBurstParams.ulReadAddress += ReadBurstParams.ulReadLength * 2;
1136 }
1137 }
1138
1139 /* Copy data byte per byte to avoid endianess problems. */
1140 for ( ulCopyIndex = 0; ulCopyIndex < 8; ulCopyIndex ++ )
1141 {
1142 f_pGetData->pbyData[ ulUserBufWriteIndex + ( 2 * ulCopyIndex ) ] = (UINT8)( pSharedInfo->MiscVars.ausSuperArray[ ( ( pSharedInfo->DebugInfo.usLastAfLogReadPtr % ( cOCT6100_INTERNAL_SUPER_ARRAY_SIZE / 8 ) ) * 8 ) + ulCopyIndex ] & 0xFF );
1143 f_pGetData->pbyData[ ulUserBufWriteIndex + ( 2 * ulCopyIndex ) + 1 ] = (UINT8)( ( pSharedInfo->MiscVars.ausSuperArray[ ( ( pSharedInfo->DebugInfo.usLastAfLogReadPtr % ( cOCT6100_INTERNAL_SUPER_ARRAY_SIZE / 8 ) ) * 8 ) + ulCopyIndex ] >> 8 ) & 0xFF );
1144 }
1145
1146 ulUserBufWriteIndex += 16;
1147
1148 /* Increment AF log read ptr. */
1149 pSharedInfo->DebugInfo.usLastAfLogReadPtr = (UINT16)(( pSharedInfo->DebugInfo.usLastAfLogReadPtr + 1 ) & 0xFFFF );
1150 }
1151 }
1152
1153 /* Check if we are done with the AF events. */
1154 if ( pSharedInfo->DebugInfo.usLastAfLogReadPtr == pSharedInfo->DebugInfo.usAfLogWritePtr )
1155 {
1156 /* Insert the tone event information. */
1157 for ( ulToneEventIndex = pSharedInfo->DebugInfo.usLastToneEventIndex; ulToneEventIndex < pSharedInfo->ImageInfo.byNumToneDetectors; ulToneEventIndex++ )
1158 {
1159 if ( ( f_pGetData->ulMaxBytes - ulUserBufWriteIndex ) < cOCT6100_TLV_MAX_TONE_NAME_SIZE )
1160 break;
1161
1162 Oct6100UserMemCopy( &f_pGetData->pbyData[ ulUserBufWriteIndex ], pSharedInfo->ImageInfo.aToneInfo[ ulToneEventIndex ].aszToneName, cOCT6100_TLV_MAX_TONE_NAME_SIZE );
1163
1164 ulUserBufWriteIndex += cOCT6100_TLV_MAX_TONE_NAME_SIZE;
1165
1166 pSharedInfo->DebugInfo.usLastToneEventIndex++;
1167 }
1168
1169 /* If all the tone information has been copied. */
1170 if ( ulToneEventIndex == pSharedInfo->ImageInfo.byNumToneDetectors )
1171 {
1172 /* Copy the image version. */
1173 if ( pSharedInfo->DebugInfo.fImageVersionCopied == FALSE )
1174 {
1175 if ( ( f_pGetData->ulMaxBytes - ulUserBufWriteIndex ) >= 512 )
1176 {
1177 Oct6100UserMemCopy( &f_pGetData->pbyData[ ulUserBufWriteIndex ], pSharedInfo->ImageInfo.szVersionNumber, 512 );
1178
1179 /* Get PLL jitter count from external memory. */
1180 if ( pSharedInfo->DebugInfo.fPouchCounter == TRUE )
1181 {
1182 ulFeatureBytesOffset = pSharedInfo->MemoryMap.PouchCounterFieldOfst.usDwordOffset * 4;
1183 ulFeatureBitOffset = pSharedInfo->MemoryMap.PouchCounterFieldOfst.byBitOffset;
1184 ulFeatureFieldLength = pSharedInfo->MemoryMap.PouchCounterFieldOfst.byFieldSize;
1185
1186 ulResult = Oct6100ApiReadDword( f_pApiInstance,
1187 cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
1188 &ulTempData );
1189
1190 /* Create the mask to retrieve the appropriate value. */
1191 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
1192
1193 /* Mask data. */
1194 ulTempData &= ulMask;
1195 /* Move to right position. */
1196 ulTempData = ulTempData >> ulFeatureBitOffset;
1197
1198 f_pGetData->pbyData[ ulUserBufWriteIndex + 510 ] = (UINT8)( ( ulTempData >> 8 ) & 0xFF );
1199 f_pGetData->pbyData[ ulUserBufWriteIndex + 511 ] = (UINT8)( ( ulTempData >> 0 ) & 0xFF );
1200 }
1201
1202 /* Add "ISR is not called" bit. */
1203 if ( pSharedInfo->IntrptManage.fIsrCalled == FALSE )
1204 {
1205 f_pGetData->pbyData[ ulUserBufWriteIndex + 510 ] |= 0x80;
1206 }
1207
1208 ulUserBufWriteIndex += 512;
1209
1210 /* The version has been copied. */
1211 pSharedInfo->DebugInfo.fImageVersionCopied = TRUE;
1212 }
1213 }
1214
1215 /* If the image version has been copied, proceed with the API version. */
1216 if ( pSharedInfo->DebugInfo.fImageVersionCopied == TRUE )
1217 {
1218 if ( pSharedInfo->DebugInfo.fApiVersionCopied == FALSE )
1219 {
1220 if ( ( f_pGetData->ulMaxBytes - ulUserBufWriteIndex ) >= sizeof(cOCT6100_API_VERSION) )
1221 {
1222 Oct6100UserMemCopy( &f_pGetData->pbyData[ ulUserBufWriteIndex ], cOCT6100_API_VERSION, sizeof(cOCT6100_API_VERSION) );
1223 ulUserBufWriteIndex += sizeof(cOCT6100_API_VERSION);
1224
1225 /* The API version has been copied. */
1226 pSharedInfo->DebugInfo.fApiVersionCopied = TRUE;
1227 }
1228 }
1229 }
1230 }
1231
1232 /* Check if we are done! */
1233 if ( pSharedInfo->DebugInfo.fApiVersionCopied == TRUE )
1234 {
1235 /* Done dumping. */
1236
1237 /* Reset data being dumpped flag. */
1238 pSharedInfo->DebugInfo.fDebugDataBeingDumped = FALSE;
1239
1240 /* Reset data recording in the chip. */
1241 WriteBurstParams.ulWriteAddress = pSharedInfo->DebugInfo.ulHotChannelSelectBaseAddress;
1242 WriteBurstParams.ulWriteLength = 2;
1243 WriteBurstParams.pusWriteData = pSharedInfo->DebugInfo.ausHotChannelData;
1244
1245 mOCT6100_DRIVER_WRITE_BURST_API( WriteBurstParams, ulResult );
1246 if ( ulResult != cOCT6100_ERR_OK )
1247 return ulResult;
1248
1249 fResetRemainingDataFlag = TRUE;
1250 }
1251 }
1252 }
1253 else /* if ( f_pGetData->ulGetDataContent != cOCT6100_DEBUG_GET_DATA_CONTENT_COMPLETE ) */
1254 {
1255 fResetRemainingDataFlag = TRUE;
1256 }
1257 }
1258 }
1259
1260 /* Return number of valid bytes in buffer to user. */
1261 f_pGetData->ulValidNumBytes = ulUserBufWriteIndex;
1262
1263 /* Update remaining bytes. */
1264 pSharedInfo->DebugInfo.ulDebugDataRemainingNumBytes -= ulUserBufWriteIndex;
1265
1266 /* Return remaining bytes. */
1267 f_pGetData->ulRemainingNumBytes = pSharedInfo->DebugInfo.ulDebugDataRemainingNumBytes;
1268
1269 /* Return total number of bytes. */
1270 f_pGetData->ulTotalNumBytes = pSharedInfo->DebugInfo.ulDebugDataTotalNumBytes;
1271
1272 /* Check if we are done dump the requested content. */
1273 if ( fResetRemainingDataFlag == TRUE )
1274 pSharedInfo->DebugInfo.ulDebugDataTotalNumBytes = cOCT6100_INVALID_VALUE;
1275
1276 return cOCT6100_ERR_OK;
1277 }
1278 #endif