From 8d2d06a050b1a5de0c5139733ae5216a8a8f2632 Mon Sep 17 00:00:00 2001 From: Octasic Inc Date: Fri, 11 Sep 2009 14:38:52 +0300 Subject: importing OCT612x-01.03.00 --- .../oct6100api/oct6100_api/oct6100_debug.c | 386 ++++++++++++++++++++- 1 file changed, 367 insertions(+), 19 deletions(-) (limited to 'software/octdeviceapi/oct6100api/oct6100_api/oct6100_debug.c') diff --git a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_debug.c b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_debug.c index 2b9ad20..9fbb269 100644 --- a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_debug.c +++ b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_debug.c @@ -22,9 +22,9 @@ You should have received a copy of the GNU General Public License along with the OCT6100 GPL API; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -$Octasic_Release: OCT612xAPI-01.02.04 $ +$Octasic_Release: OCT612xAPI-01.03.00 $ -$Octasic_Revision: 66 $ +$Octasic_Revision: 74 $ \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ @@ -37,6 +37,8 @@ $Octasic_Revision: 66 $ #include "oct6100api/oct6100_errors.h" #include "oct6100api/oct6100_apiud.h" +#include "apilib/octapi_largmath.h" + #include "oct6100api/oct6100_apiud.h" #include "oct6100api/oct6100_tlv_inst.h" #include "oct6100api/oct6100_chip_open_inst.h" @@ -49,10 +51,12 @@ $Octasic_Revision: 66 $ #include "oct6100api/oct6100_interrupts_pub.h" #include "oct6100api/oct6100_chip_open_pub.h" +#include "oct6100api/oct6100_chip_stats_pub.h" #include "oct6100api/oct6100_channel_pub.h" #include "oct6100api/oct6100_debug_pub.h" #include "oct6100_chip_open_priv.h" +#include "oct6100_chip_stats_priv.h" #include "oct6100_channel_priv.h" #include "oct6100_miscellaneous_priv.h" #include "oct6100_memory_priv.h" @@ -289,8 +293,6 @@ UINT32 Oct6100DebugSelectChannelSer( return ulResult; } pTempChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX; - - /* XXX: What about the silence TSI usSinSilenceEventIndex ?? */ } pTempChanEntry->usExtraSinTsiDependencyCnt--; @@ -352,8 +354,6 @@ UINT32 Oct6100DebugSelectChannelSer( if ( ulResult != cOCT6100_ERR_OK ) return ulResult; } - - /* XXX: What about the silence TSI usSinSilenceEventIndex ?? */ } @@ -479,7 +479,6 @@ UINT32 Oct6100DebugGetDataSer( IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, IN OUT tPOCT6100_DEBUG_GET_DATA f_pGetData ) { - tPOCT6100_SHARED_INFO pSharedInfo; tPOCT6100_API_CHANNEL pChanEntry = NULL; tOCT6100_READ_PARAMS ReadParams; @@ -561,7 +560,8 @@ UINT32 Oct6100DebugGetDataSer( if ( ( f_pGetData->ulGetDataMode != cOCT6100_DEBUG_GET_DATA_MODE_16S_LITE ) && ( f_pGetData->ulGetDataMode != cOCT6100_DEBUG_GET_DATA_MODE_120S_LITE ) && ( f_pGetData->ulGetDataMode != cOCT6100_DEBUG_GET_DATA_MODE_16S ) - && ( f_pGetData->ulGetDataMode != cOCT6100_DEBUG_GET_DATA_MODE_120S ) ) + && ( f_pGetData->ulGetDataMode != cOCT6100_DEBUG_GET_DATA_MODE_120S ) + && ( f_pGetData->ulGetDataMode != cOCT6100_DEBUG_GET_DATA_MODE_CORE_DUMP ) ) return cOCT6100_ERR_DEBUG_GET_DATA_MODE; /* Check dump content. */ @@ -571,6 +571,11 @@ UINT32 Oct6100DebugGetDataSer( && ( f_pGetData->ulGetDataContent != cOCT6100_DEBUG_GET_DATA_CONTENT_SOUT_PCM ) ) return cOCT6100_ERR_DEBUG_GET_DATA_CONTENT; + /* The core dump mode does not support the xxx_PCM data contents. */ + if ( ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_CORE_DUMP ) + && ( f_pGetData->ulGetDataContent != cOCT6100_DEBUG_GET_DATA_CONTENT_COMPLETE ) ) + return cOCT6100_ERR_DEBUG_GET_DATA_CONTENT; + /* Check if can accomodate the 120 seconds dump. */ if ( ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S_LITE ) || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) ) @@ -593,8 +598,6 @@ UINT32 Oct6100DebugGetDataSer( if ( pChanEntry->byEchoOperationMode == cOCT6100_ECHO_OP_MODE_POWER_DOWN ) return cOCT6100_ERR_DEBUG_CHANNEL_IN_POWER_DOWN; - pSharedInfo->DebugInfo.fDebugDataBeingDumped = TRUE; - /* Flag the hot channel that it must stop recording. The data is being transfered. */ /* This also tells the remote client not to do anything right now. */ @@ -679,9 +682,12 @@ UINT32 Oct6100DebugGetDataSer( } + /* If the user only requested the last 16 seconds, cap the number of events. */ if ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S - || f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S_LITE ) + || f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S_LITE + || ( ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_CORE_DUMP ) + && ( pSharedInfo->DebugInfo.ulDebugEventSize != 0x100 ) ) ) { /* x events to get the last 16 seconds. */ if ( pSharedInfo->DebugInfo.usNumEvents > ( 16000 / ( pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize / 8 ) ) ) @@ -757,7 +763,8 @@ UINT32 Oct6100DebugGetDataSer( /* In heavy mode, the AF log pointer is retrieved. */ if ( ( pSharedInfo->DebugInfo.usNumEvents >= 2 ) && ( ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S ) - || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) ) ) + || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) + || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_CORE_DUMP ) ) ) { /* The latest AF log write pointer is at the latest matrix event. */ ReadParams.ulReadAddress = pSharedInfo->DebugInfo.ulMatrixBaseAddress + ( ( pSharedInfo->DebugInfo.usChipDebugEventWritePtr & pSharedInfo->DebugInfo.usMatrixCBMask ) * 1024 ); @@ -793,6 +800,9 @@ UINT32 Oct6100DebugGetDataSer( /* Remember the data mode for later checks. Also, the user cannot change this "mode". */ pSharedInfo->DebugInfo.ulCurrentGetDataMode = f_pGetData->ulGetDataMode; + + /* Remember that we are currently dumping. */ + pSharedInfo->DebugInfo.fDebugDataBeingDumped = TRUE; } else { @@ -845,6 +855,11 @@ UINT32 Oct6100DebugGetDataSer( pSharedInfo->DebugInfo.fImageVersionCopied = FALSE; pSharedInfo->DebugInfo.fApiVersionCopied = FALSE; + /* The core dump flag has not been set yet. */ + pSharedInfo->DebugInfo.fCoreDumped = FALSE; + pSharedInfo->DebugInfo.ulLastMemoryOffset = 0; + + /* Estimate the total size of the buffer that will be returned. */ f_pGetData->ulTotalNumBytes = ulUserBufWriteIndex; @@ -853,7 +868,8 @@ UINT32 Oct6100DebugGetDataSer( { /* Add the matrix events. */ if ( ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S ) - || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) ) + || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) + || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_CORE_DUMP ) ) { /* Heavy mode! Grab everything! */ f_pGetData->ulTotalNumBytes += pSharedInfo->DebugInfo.usNumEvents * pSharedInfo->DebugInfo.ulDebugChanStatsByteSize; @@ -869,7 +885,8 @@ UINT32 Oct6100DebugGetDataSer( /* If requested, add the AF log events. */ if ( ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S ) - || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) ) + || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) + || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_CORE_DUMP ) ) { f_pGetData->ulTotalNumBytes += (UINT32)( ( pSharedInfo->DebugInfo.usAfLogWritePtr - pSharedInfo->DebugInfo.usLastAfLogReadPtr ) & 0xFFFF ) * 16; } @@ -882,6 +899,18 @@ UINT32 Oct6100DebugGetDataSer( /* Add the API version string. */ f_pGetData->ulTotalNumBytes += sizeof( cOCT6100_API_VERSION ); + + /* If core dumping, must add the size of the memory regions that will be returned to the user. */ + if ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_CORE_DUMP ) + { + /* Internal memories. */ + f_pGetData->ulTotalNumBytes += 0x300000; + + /* External memory. */ + f_pGetData->ulTotalNumBytes += ( pSharedInfo->MemoryMap.ulFreeMemBaseAddress - cOCT6100_EXTERNAL_MEM_BASE_ADDRESS ); + + + } } else /* if ( f_pGetData->ulGetDataContent != cOCT6100_DEBUG_GET_DATA_CONTENT_COMPLETE ) */ { @@ -918,7 +947,8 @@ UINT32 Oct6100DebugGetDataSer( /* Check if we are in light or heavy mode. The burst size is not the same. */ if ( ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S ) - || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) ) + || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) + || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_CORE_DUMP ) ) { if ( ( f_pGetData->ulMaxBytes - ulUserBufWriteIndex ) >= pSharedInfo->DebugInfo.ulDebugChanStatsByteSize ) ulNumReads = pSharedInfo->DebugInfo.ulDebugChanStatsByteSize / 2; @@ -967,7 +997,8 @@ UINT32 Oct6100DebugGetDataSer( /* Increment index. */ if ( ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S ) - || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) ) + || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) + || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_CORE_DUMP ) ) { ulUserBufWriteIndex += pSharedInfo->DebugInfo.ulDebugChanStatsByteSize; } @@ -1115,7 +1146,8 @@ UINT32 Oct6100DebugGetDataSer( /* Go for the AF events. The AF events are only copied in heavy mode. */ if ( ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_16S ) - || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) ) + || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_120S ) + || ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_CORE_DUMP ) ) { while ( pSharedInfo->DebugInfo.usLastAfLogReadPtr != pSharedInfo->DebugInfo.usAfLogWritePtr ) { @@ -1201,6 +1233,9 @@ UINT32 Oct6100DebugGetDataSer( { if ( ( f_pGetData->ulMaxBytes - ulUserBufWriteIndex ) >= 512 ) { + tOCT6100_CHIP_STATS ChipStats; + UINT32 ulTempIndex; + Oct6100UserMemCopy( &f_pGetData->pbyData[ ulUserBufWriteIndex ], pSharedInfo->ImageInfo.szVersionNumber, 512 ); /* Get PLL jitter count from external memory. */ @@ -1232,6 +1267,61 @@ UINT32 Oct6100DebugGetDataSer( f_pGetData->pbyData[ ulUserBufWriteIndex + 510 ] |= 0x80; } + + + /* Set the hardware revision number. */ + ulTempIndex = 509; + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ( pSharedInfo->MiscVars.usChipRevision ) & 0xFF ); + + Oct6100ChipGetStatsDef( &ChipStats ); + ulResult = Oct6100ChipGetStatsSer( f_pApiInstance, &ChipStats ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ChipStats.ulNumberChannels & 0xFF ); + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ( ChipStats.ulNumberChannels >> 8 ) & 0xFF ); + + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( f_pApiInstance->pSharedInfo->MiscVars.ulNumActiveChannels & 0xFF ); + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ( f_pApiInstance->pSharedInfo->MiscVars.ulNumActiveChannels >> 8 ) & 0xFF ); + + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ChipStats.ulNumberTsiCncts & 0xFF ); + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ( ChipStats.ulNumberTsiCncts >> 8 ) & 0xFF ); + + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ChipStats.ulNumberConfBridges & 0xFF ); + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ( ChipStats.ulNumberConfBridges >> 8 ) & 0xFF ); + + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ChipStats.ulNumberPlayoutBuffers & 0xFF ); + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ( ChipStats.ulNumberPlayoutBuffers >> 8 ) & 0xFF ); + + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ChipStats.ulPlayoutFreeMemSize & 0xFF ); + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ( ChipStats.ulPlayoutFreeMemSize >> 8 ) & 0xFF ); + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ( ChipStats.ulPlayoutFreeMemSize >> 16 ) & 0xFF ); + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ( ChipStats.ulPlayoutFreeMemSize >> 24 ) & 0xFF ); + + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ChipStats.ulNumberPhasingTssts & 0xFF ); + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ( ChipStats.ulNumberPhasingTssts >> 8 ) & 0xFF ); + + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ChipStats.ulNumberAdpcmChannels & 0xFF ); + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ( ChipStats.ulNumberAdpcmChannels >> 8 ) & 0xFF ); + + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ChipStats.ulInternalReadTimeoutCount & 0xFF ); + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ( ChipStats.ulInternalReadTimeoutCount >> 8 ) & 0xFF ); + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ( ChipStats.ulInternalReadTimeoutCount >> 16 ) & 0xFF ); + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ( ChipStats.ulInternalReadTimeoutCount >> 24 ) & 0xFF ); + + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ChipStats.ulSdramRefreshTooLateCount & 0xFF ); + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ( ChipStats.ulSdramRefreshTooLateCount >> 8 ) & 0xFF ); + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ( ChipStats.ulSdramRefreshTooLateCount >> 16 ) & 0xFF ); + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ( ChipStats.ulSdramRefreshTooLateCount >> 24 ) & 0xFF ); + + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ChipStats.ulPllJitterErrorCount & 0xFF ); + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ( ChipStats.ulPllJitterErrorCount >> 8 ) & 0xFF ); + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ( ChipStats.ulPllJitterErrorCount >> 16 ) & 0xFF ); + f_pGetData->pbyData[ ulUserBufWriteIndex + ulTempIndex-- ] = (UINT8)( ( ChipStats.ulPllJitterErrorCount >> 24 ) & 0xFF ); + + ulTempIndex -= 5; + + /* Update write pointer. */ ulUserBufWriteIndex += 512; /* The version has been copied. */ @@ -1254,14 +1344,38 @@ UINT32 Oct6100DebugGetDataSer( } } } + + /* Check for the core dump content. */ + if ( pSharedInfo->DebugInfo.fApiVersionCopied == TRUE ) + { + if ( f_pGetData->ulGetDataMode == cOCT6100_DEBUG_GET_DATA_MODE_CORE_DUMP ) + { + if ( pSharedInfo->DebugInfo.fCoreDumped == FALSE ) + { + ulResult = Oct6100DebugCoreDump( f_pApiInstance, f_pGetData, &ulUserBufWriteIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + } + else + { + /* Even though it was not requested, set the flag to pass through the next gate. */ + pSharedInfo->DebugInfo.fCoreDumped = TRUE; + } + } } + + /* Check if we are done! */ - if ( pSharedInfo->DebugInfo.fApiVersionCopied == TRUE ) + if ( ( pSharedInfo->DebugInfo.fApiVersionCopied == TRUE ) + && ( pSharedInfo->DebugInfo.fCoreDumped == TRUE ) + + ) { /* Done dumping. */ - /* Reset data being dumpped flag. */ + /* Reset data being dumped flag. */ pSharedInfo->DebugInfo.fDebugDataBeingDumped = FALSE; /* Reset data recording in the chip. */ @@ -1302,3 +1416,237 @@ UINT32 Oct6100DebugGetDataSer( return cOCT6100_ERR_OK; } + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100DebugCoreDump + +Description: Called to generate debug core dump information. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pGetData Pointer to a tOCT6100_DEBUG_GET_DATA structure. + +f_pulUserBufWriteIndex User buffer write index. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +UINT32 Oct6100DebugCoreDump( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_DEBUG_GET_DATA f_pGetData, + IN OUT PUINT32 f_pulUserBufWriteIndex ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tOCT6100_READ_BURST_PARAMS ReadBurstParams; + tOCT6100_READ_PARAMS ReadParams; + + UINT32 ulResult; + UINT32 ulNumReads; + UINT32 ulTempIndex; + + /* Get local pointer(s). */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + ReadBurstParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadBurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + ReadParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + /* All registers. */ + if ( pSharedInfo->DebugInfo.ulLastMemoryOffset < 0x800 ) + { + /* Here we assume cOCT6100_INTERNAL_SUPER_ARRAY_SIZE can contain all the registers. */ + /* Check if must retrieve data from the hardware. */ + if ( pSharedInfo->DebugInfo.ulLastMemoryOffset == 0 ) + { + /* Clear whole array */ + Oct6100UserMemSet( pSharedInfo->MiscVars.ausSuperArray, 0, sizeof( pSharedInfo->MiscVars.ausSuperArray ) ); + + /* Retrieve all registers data from the hardware. */ + /* Start at the CPU registers (0x100). */ + ReadParams.ulReadAddress = 0x100; + + /* As much as we can for the burst. */ + ulTempIndex = 0x100 / 2; /* Start indexing at the CPU registers (0x100) */ + ulNumReads = 0x380; /* Up to 0x800 */ + + while ( ulNumReads != 0 ) + { + /* Set pointer where to write data. */ + ReadParams.pusReadData = &pSharedInfo->MiscVars.ausSuperArray[ ulTempIndex ]; + + mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Update indexes, temp variables, addresses. */ + ulNumReads--; + ulTempIndex++; + ReadParams.ulReadAddress += 2; + + /* Skip range 0x400 to 0x500 -- Cannot read between 0x400 & 0x500. */ + if ( ReadParams.ulReadAddress == 0x400 ) + { + ReadParams.ulReadAddress += 0x100; + ulTempIndex += 0x80; + ulNumReads -= 0x80; + } + } + } + + for ( ; pSharedInfo->DebugInfo.ulLastMemoryOffset < 0x800; pSharedInfo->DebugInfo.ulLastMemoryOffset +=2 ) + { + /* Check if enough room for this word. */ + if ( ( f_pGetData->ulMaxBytes - *f_pulUserBufWriteIndex ) < 2 ) + break; + + /* Copy data byte per byte to avoid endianess problems. */ + f_pGetData->pbyData[ *f_pulUserBufWriteIndex ] = (UINT8)( pSharedInfo->MiscVars.ausSuperArray[ ( pSharedInfo->DebugInfo.ulLastMemoryOffset / 2 ) % cOCT6100_INTERNAL_SUPER_ARRAY_SIZE ] & 0xFF ); + f_pGetData->pbyData[ *f_pulUserBufWriteIndex + 1 ] = (UINT8)( ( pSharedInfo->MiscVars.ausSuperArray[ ( pSharedInfo->DebugInfo.ulLastMemoryOffset / 2 ) % cOCT6100_INTERNAL_SUPER_ARRAY_SIZE ] >> 8 ) & 0xFF ); + + /* Update indexes. */ + *f_pulUserBufWriteIndex += 2; + } + } + + /* All internal memories */ + if ( pSharedInfo->DebugInfo.ulLastMemoryOffset < 0x300000 ) + { + ulResult = Oct6100DebugCoreDumpMemory( f_pApiInstance, f_pGetData, f_pulUserBufWriteIndex, 0x800, 0x300000 ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* All external memory, up until the beginning of the free memory pool. */ + if ( pSharedInfo->DebugInfo.ulLastMemoryOffset < pSharedInfo->MemoryMap.ulFreeMemBaseAddress ) + { + /* External memory. */ + ulResult = Oct6100DebugCoreDumpMemory( f_pApiInstance, f_pGetData, f_pulUserBufWriteIndex, cOCT6100_EXTERNAL_MEM_BASE_ADDRESS, pSharedInfo->MemoryMap.ulFreeMemBaseAddress ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + if ( pSharedInfo->DebugInfo.ulLastMemoryOffset >= pSharedInfo->MemoryMap.ulFreeMemBaseAddress ) + { + /* Done here. */ + pSharedInfo->DebugInfo.fCoreDumped = TRUE; + } + + return cOCT6100_ERR_OK; +} + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100DebugCoreDumpMemory + +Description: Called to read a memory region. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep the + present state of the chip and all its resources. + +f_pGetData Pointer to a tOCT6100_DEBUG_GET_DATA structure. + +f_pulUserBufWriteIndex User buffer write index. + +f_ulMemOffsetBottom Memory address, bottom. + +f_ulMemOffsetTop Memory address, top. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +UINT32 Oct6100DebugCoreDumpMemory( + IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, + IN OUT tPOCT6100_DEBUG_GET_DATA f_pGetData, + IN OUT PUINT32 f_pulUserBufWriteIndex, + IN UINT32 f_ulMemOffsetBottom, + IN UINT32 f_ulMemOffsetTop ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tOCT6100_READ_BURST_PARAMS ReadBurstParams; + + UINT32 ulResult; + UINT32 ulNumReads; + UINT32 ulTempIndex; + + /* Get local pointer(s). */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + ReadBurstParams.pProcessContext = f_pApiInstance->pProcessContext; + + ReadBurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + /* Check if enough room for at least 1 word. */ + if ( ( f_pGetData->ulMaxBytes - *f_pulUserBufWriteIndex ) < 2 ) + return cOCT6100_ERR_OK; + + /* Make sure we are starting at the right offset.. Sometimes memory regions are not continuous. */ + if ( pSharedInfo->DebugInfo.ulLastMemoryOffset < f_ulMemOffsetBottom ) + pSharedInfo->DebugInfo.ulLastMemoryOffset = f_ulMemOffsetBottom; + + for ( ; pSharedInfo->DebugInfo.ulLastMemoryOffset < f_ulMemOffsetTop; pSharedInfo->DebugInfo.ulLastMemoryOffset +=2 ) + { + /* Check if enough room for this word. */ + if ( ( f_pGetData->ulMaxBytes - *f_pulUserBufWriteIndex ) < 2 ) + break; + + /* Check if must retrieve data from the hardware. */ + if ( ( pSharedInfo->DebugInfo.ulLastMemoryOffset / 2 ) % cOCT6100_INTERNAL_SUPER_ARRAY_SIZE == 0 ) + { + ReadBurstParams.ulReadAddress = pSharedInfo->DebugInfo.ulLastMemoryOffset; + + /* Some internal memory regions cannot be read. Check for these here. */ + if ( ( ReadBurstParams.ulReadAddress >= 0xF0000 ) + && ( ReadBurstParams.ulReadAddress < 0x100000 ) ) + { + /* Region cannot be read. */ + Oct6100UserMemSet( pSharedInfo->MiscVars.ausSuperArray, 0, cOCT6100_INTERNAL_SUPER_ARRAY_SIZE * sizeof( UINT16 ) ); + } + else + { + /* As much as we can for the burst. */ + ulTempIndex = 0x0; + ulNumReads = cOCT6100_INTERNAL_SUPER_ARRAY_SIZE; + + while ( ulNumReads != 0 ) + { + /* Set read burst size. */ + if ( ulNumReads >= pSharedInfo->ChipConfig.usMaxRwAccesses ) + ReadBurstParams.ulReadLength = pSharedInfo->ChipConfig.usMaxRwAccesses; + else + ReadBurstParams.ulReadLength = ulNumReads; + + /* Set pointer where to write data. */ + ReadBurstParams.pusReadData = &pSharedInfo->MiscVars.ausSuperArray[ ulTempIndex ]; + + mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Update indexes, temp variables, addresses. */ + ulNumReads -= ReadBurstParams.ulReadLength; + ulTempIndex += ReadBurstParams.ulReadLength; + ReadBurstParams.ulReadAddress += ReadBurstParams.ulReadLength * 2; + } + } + } + + /* Copy data byte per byte to avoid endianness problems. */ + f_pGetData->pbyData[ *f_pulUserBufWriteIndex ] = (UINT8)( pSharedInfo->MiscVars.ausSuperArray[ ( pSharedInfo->DebugInfo.ulLastMemoryOffset / 2 ) % cOCT6100_INTERNAL_SUPER_ARRAY_SIZE ] & 0xFF ); + f_pGetData->pbyData[ *f_pulUserBufWriteIndex + 1 ] = (UINT8)( ( pSharedInfo->MiscVars.ausSuperArray[ ( pSharedInfo->DebugInfo.ulLastMemoryOffset / 2 ) % cOCT6100_INTERNAL_SUPER_ARRAY_SIZE ] >> 8 ) & 0xFF ); + + /* Update indexes. */ + *f_pulUserBufWriteIndex += 2; + } + + return cOCT6100_ERR_OK; +} + + -- cgit v1.2.3