📄 db_obj.c
字号:
if( db_TradeComBuf( &pComBuf, sizeof( DB_LeCnetTransportStatusType ), bService ) != SUCCESS )
{
goto BailOut;
}
psTransStatus = CB_GetDataPtrComBuf( pComBuf );
UC_SetMem( psTransStatus, 0, sizeof( DB_LeCnetTransportStatusType ) );
psTransStatus->iLeClass1ConTransports =
psTransStatus->iLeClass1ProTransports = UC_iTOiLeConst( CD_NUM_CLASS_1 );
psTransStatus->iLeClass3Transports = UC_iTOiLeConst( CD_NUM_CLASS_3 );
break;
case DB_CMD_GET_EVENT_LOG_COUNTS:
/*
** Get the counts of the various flavors of log entries.
*/
if( db_TradeComBuf( &pComBuf, sizeof( DB_LeLogCountType ), bService ) != SUCCESS )
{
goto BailOut;
}
psLeLogCounts = CB_GetDataPtrComBuf( pComBuf );
psLeLogCounts->lLeTrivial = UC_lTOlLe( gs_sEvents.sNonRetentiveControl.lTotal - gs_sEvents.sNonRetentiveControl.lBadTotal );
psLeLogCounts->lLeWarning = UC_lTOlLe( gs_sEvents.sNonRetentiveControl.lBadTotal );
psLeLogCounts->lLeImportant = UC_lTOlLe( gs_sEvents.sRetentiveControl.lTotal - gs_sEvents.sRetentiveControl.lBadTotal );
psLeLogCounts->lLeSevere = UC_lTOlLe( gs_sEvents.sRetentiveControl.lBadTotal );
psLeLogCounts->lLeFatal = UC_lTOlLeConst( 0L );
break;
case DB_CMD_GET_EVENT_LOG_ENTRY:
/*
** Get the details for one log entry.
*/
eStatus = GS_ReadEvent( bParameters, UC_lLeTOl( upsHeader.EventLog->lLeEventNumber ), &sEventRecord );
if( eStatus != SUCCESS )
{
CB_ClearComBuf( pComBuf );
lSize = 0L;
CB_PrependComBuf( pComBuf, &lSize, sizeof( UINT32 ) );
break;
}
if( db_TradeComBuf( &pComBuf, sizeof( DB_LeEventLogEntryType ) + UC_LenStr( sEventRecord.achSourceFile ), bService ) != SUCCESS )
{
goto BailOut;
}
psLeEventLogEntry = CB_GetDataPtrComBuf( pComBuf );
psLeEventLogEntry->lLeNumber = UC_lTOlLe( sEventRecord.lNumber );
psLeEventLogEntry->iLeStatus = UC_iTOiLe( sEventRecord.eStatus );
psLeEventLogEntry->iLeEventSeverity = UC_iTOiLe( sEventRecord.eEventSeverity );
psLeEventLogEntry->iLeParameter = UC_iTOiLe( sEventRecord.iParameter );
psLeEventLogEntry->lLeParameter = UC_lTOlLe( sEventRecord.pParameter );
psLeEventLogEntry->iLeMSeconds = UC_iTOiLe( sEventRecord.sTimeStamp.iSysMSec );
psLeEventLogEntry->lLeSeconds = UC_lTOlLe( sEventRecord.sTimeStamp.lSysSec );
psLeEventLogEntry->lLeTaskId = UC_lTOlLe( sEventRecord.xTid );
psLeEventLogEntry->achTaskName[ 0 ] = 0;
/* UC_CopyStr( psLeEventLogEntry->achTaskName, sEventRecord. ); */
psLeEventLogEntry->iLeSourceLine = UC_iTOiLe( sEventRecord.iSourceLine );
UC_CopyStr( psLeEventLogEntry->achSourceFile, sEventRecord.achSourceFile );
break;
case DB_CMD_GET_HEAP_BUCKETS:
/*
** If bucket demand is not turned on, return 0 buckets.
*/
if( db_TradeComBuf( &pComBuf, sizeof( DB_LeHeapBucketType ) + ( GS_HEAP_NUM_BUCKETS * sizeof( LeUINT32 ) ), bService ) != SUCCESS )
{
goto BailOut;
}
CB_ClearComBuf( pComBuf );
#ifdef DEBUG_HEAP_BUCKET_DEMAND
/*
** If bucket demand monitoring turned is turned on,
** put the demand counts into the packet in reverse order.
*/
for( i = GS_HEAP_NUM_BUCKETS; i > 0; i-- )
{
l = UC_lTOlLe( gs_sHeap.alHeapBucketDemand[ i - 1 ] );
CB_PrependComBuf( pComBuf, &l, sizeof( UINT32 ) );
}
/*
** Put in the number of buckets last (first in the packet).
*/
i = UC_iTOiLeConst( GS_HEAP_NUM_BUCKETS );
#else
i = 0;
#endif
CB_PrependComBuf( pComBuf, &i, sizeof( UINT16 ) );
break;
case DB_CMD_GET_HEAP_STATUS:
/*
** Get the current heap population sizes and counts.
*/
if( db_TradeComBuf( &pComBuf, sizeof( DB_LeHeapStatusType ) + ( GS_HEAP_NUM_PARTITIONS * sizeof( DB_LeHeapInfoType ) ), bService ) != SUCCESS )
{
goto BailOut;
}
psLeHeapStatus = CB_GetDataPtrComBuf( pComBuf );
psLeHeapStatus->iLeNumPartitions = UC_iTOiLeConst( GS_HEAP_NUM_PARTITIONS );
psLeHeapInfo = (DB_LeHeapInfoType*)(psLeHeapStatus + 1);
for( i = 0; i < GS_HEAP_NUM_PARTITIONS; i++ )
{
psLeHeapInfo->iLePartitionSize = UC_iTOiLe( gs_sHeap.aiHeapPartitionSize[ i ] );
psLeHeapInfo->iLeTotalPopulation = UC_iTOiLe( gs_sHeap.aiHeapPartitionCapacity[ i ] );
psLeHeapInfo->iLePopulation = UC_iTOiLe( gs_sHeap.aiHeapPopulation[ i ] );
psLeHeapInfo->iLeLowWater = UC_iTOiLe( gs_sHeap.aiHeapLowWater[ i ] );
psLeHeapInfo++;
}
break;
case DB_CMD_GET_NODE_TIME:
/*
** Get the elapsed time since node startup.
*/
if( db_TradeComBuf( &pComBuf, sizeof( DB_LeNodeTimeType ), bService ) != SUCCESS )
{
goto BailOut;
}
GS_GetTime( &sTime );
psLeNodeTime = CB_GetDataPtrComBuf( pComBuf );
psLeNodeTime->lLeSeconds = UC_lTOlLe( sTime.lSysSec );
psLeNodeTime->iLeMSeconds = UC_iTOiLe( sTime.iSysMSec );
break;
case DB_CMD_GET_REVISION:
/*
** Get the revision of the debug object.
*/
if( db_TradeComBuf( &pComBuf, sizeof( DB_LeRevisionType ), bService ) != SUCCESS )
{
goto BailOut;
}
psLeRevision = CB_GetDataPtrComBuf( pComBuf );
psLeRevision->iLeRevision = UC_iTOiLeConst( DB_REVISION );
break;
case DB_CMD_GET_STATIC_HEAP_STATUS:
/*
** Get the info on the static portion of the heap.
*/
if( db_TradeComBuf( &pComBuf, sizeof( DB_LeStaticHeapStatusType ), bService ) != SUCCESS )
{
goto BailOut;
}
/*
** Find interesting locations (in native pointer format).
** Convert the interesting locations to flat addresses (if needed)
** so we can do arithmetic to find the static heap sizes.
*/
#ifdef SEGMENTED_ADDRESS
lHeapStart = FD_IntelMakeLinearAddr( AB_s.pHeapBase );
lHeapStaticStart = FD_IntelMakeLinearAddr( gs_sHeap.apHeapPartitionInitPtr[ GS_HEAP_NUM_PARTITIONS ] );
lHeapStaticCurrent = FD_IntelMakeLinearAddr( gs_sHeap.pHeapStaticStart );
#else
lHeapStart = (UINT32) AB_s.pHeapBase;
lHeapStaticStart = (UINT32) gs_sHeap.apHeapPartitionInitPtr[ GS_HEAP_NUM_PARTITIONS ];
lHeapStaticCurrent = (UINT32) gs_sHeap.pHeapStaticStart;
#endif
/*
** Now calculate the total and free static heap sizes.
*/
psLeStaticHeapStatus = CB_GetDataPtrComBuf( pComBuf );
psLeStaticHeapStatus->lLeTotalSize = UC_lTOlLe( ( lHeapStart + AB_s.lHeapSize ) - lHeapStaticStart );
psLeStaticHeapStatus->lLeFree = UC_lTOlLe( lHeapStaticCurrent - lHeapStaticStart );
break;
case DB_CMD_GET_TASK_STATUS:
/*
** Get interesting info for a group of up to 16 tasks.
** (16 is the max we can fit into a CNet packet.)
*/
if( bParameters >= gs_s.bNumTasks )
{
bGRC = CI_GRC_BAD_DATA;
goto BailOut;
}
bNumTasks = UC_Min( gs_s.bNumTasks - bParameters, 12 );
if( db_TradeComBuf( &pComBuf, sizeof( DB_LeTaskStatusType ) + ( bNumTasks * sizeof( DB_LeTaskInfoType ) ), bService ) != SUCCESS )
{
goto BailOut;
}
CB_ClearComBuf( pComBuf );
/*
** Find the starting task in the list.
*/
psTaskData = LL_FirstEntry( &gs_s.sTaskList );
i = bParameters;
while( i )
{
psTaskData = LL_NextEntry( psTaskData );
i--;
}
/*
** Fill the task info into the packet in reverse task order.
*/
for( i = bNumTasks; i > 0; i-- )
{
iTask = bParameters + i - 1;
CB_ExpandComBuf( pComBuf, sizeof( DB_LeTaskInfoType ) );
psLeTaskInfo = CB_GetDataPtrComBuf( pComBuf );
psLeTaskInfo->bTaskNumber = iTask;
psLeTaskInfo->bPad = 0;
psLeTaskInfo->lLeTaskId = UC_lTOlLe( (UINT32)iTask );
UC_CopyStr( psLeTaskInfo->achTaskName, psTaskData->achTaskName );
psLeTaskInfo->iLePriority = UC_iTOiLe( psTaskData->iPriority );
#ifdef CD_EN_OBJECTS
psLeTaskInfo->iLeStackMargin = UC_iTOiLe( OE_GetStackMargin( psTaskData->xTaskId ) );
#endif
if( psTaskData->xQidHi == GS_NO_QUEUE )
{
psLeTaskInfo->bQueueHiCurrent = 0;
psLeTaskInfo->bQueueHiMax = 0;
psLeTaskInfo->lLeQueueHiTotal = 0L;
}
else
{
psLeTaskInfo->bQueueHiCurrent = psTaskData->xQidHi->iDepth;
psLeTaskInfo->bQueueHiMax = psTaskData->xQidHi->iMaxDepth;
psLeTaskInfo->lLeQueueHiTotal = UC_lTOlLe( psTaskData->xQidHi->lTotal );
}
if( psTaskData->xQidLo == GS_NO_QUEUE )
{
psLeTaskInfo->bQueueLoCurrent = 0;
psLeTaskInfo->bQueueLoMax = 0;
psLeTaskInfo->lLeQueueLoTotal = 0L;
}
else
{
psLeTaskInfo->bQueueLoCurrent = psTaskData->xQidLo->iDepth;
psLeTaskInfo->bQueueLoMax = psTaskData->xQidLo->iMaxDepth;
psLeTaskInfo->lLeQueueLoTotal = UC_lTOlLe( psTaskData->xQidLo->lTotal );
}
psLeTaskInfo->iLeMSeconds = 0; /* Get from future OS struct */
psLeTaskInfo->lLeSeconds = 0L; /* Get from future OS struct */
/*
** On to the next task in the list.
*/
psTaskData = LL_NextEntry( psTaskData );
}
/*
** Fill in the total number of tasks defined and the
** number of tasks we've returned data for.
** Fill in the CPU utilization, note 10000 = 100%.
*/
CB_ExpandComBuf( pComBuf, sizeof( DB_LeTaskStatusType ) );
psLeTaskStatus = CB_GetDataPtrComBuf( pComBuf );
psLeTaskStatus->bTotalTasks = gs_s.bNumTasks;
psLeTaskStatus->bNumTasks = bNumTasks;
psLeTaskStatus->iLePercentCpuUsed = UC_iTOiLe( GS_CurrentCPUusage() );
break;
case DB_CMD_GET_VERSIONS:
/*
** Collect all kinds of interesting version information.
*/
if( db_TradeComBuf( &pComBuf, sizeof( DB_LeVersionsType ), bService ) != SUCCESS )
{
goto BailOut;
}
psLeVersions = CB_GetDataPtrComBuf( pComBuf );
psLeVersions->bExClass = AB_CNA_CLASS;
psLeVersions->bExMajor = AB_CNA_MAJOR_REV;
psLeVersions->bExMinor = AB_CNA_MINOR_REV;
psLeVersions->bExReleaseLetter = AB_CNA_RELEASE_LETTER;
psLeVersions->iLeExReleaseNumber = UC_iTOiLeConst( AB_CNA_RELEASE_NUMBER );
psLeVersions->iLeExInternal = UC_iTOiLeConst( AB_CNA_INTERNAL_REV );
psLeVersions->bExDay = AB_CNA_VERSION_DAY;
psLeVersions->bExMonth = AB_CNA_VERSION_MONTH;
psLeVersions->iLeExYear = UC_iTOiLeConst( AB_CNA_VERSION_YEAR );
psLeVersions->bAsicFwClass = 0;
psLeVersions->bAsicFwMajor = 3;
psLeVersions->bAsicFwMinor = 0;
psLeVersions->bAsicFwInternal = 0;
psLeVersions->bAppFwClass = AB_APP_CLASS;
psLeVersions->bAppFwMajor = AB_APP_MAJOR_REV;
psLeVersions->bAppFwMinor = AB_APP_MINOR_REV;
psLeVersions->bAppFwInternal = AB_APP_INTERNAL_REV;
break;
default:
/*
** Unsupported request.
*/
CB_ClearComBuf( pComBuf );
bGRC = CI_GRC_BAD_SERVICE;
break;
}
break;
case DB_SC_READ:
/*
** Extract the address to read and the size
*/
lAddress = UC_lLeTOl( upsHeader.Read->lLeAddress );
lSize = UC_lLeTOl( upsHeader.Read->lLeSize );
/*
** Make sure we can handle the size requested
*/
if( lSize > DB_MAX_READ_BUFFER )
{
bGRC = CI_GRC_REPLY_DATA_TOO_LARGE;
}
else
{
if( db_TradeComBuf( &pComBuf, lSize, bService ) != SUCCESS )
{
goto BailOut;
}
/*
** Do the actual read of data
*/
UC_CopyMem( CB_GetDataPtrComBuf( pComBuf ), ( void * )lAddress, lSize );
}
break;
default:
/*
** Unsupported request.
*/
CB_ClearComBuf( pComBuf );
bGRC = CI_GRC_BAD_SERVICE;
break;
}
/*
** Prepend a good or bad CI reply header.
*/
CI_PrependReplyHeader( pComBuf, bService, bGRC, 0 );
BailOut:
return( pComBuf );
} /* end of db_ProcessRequest() */
/*---------------------------------------------------------------------------
** db_TradeComBuf()
**---------------------------------------------------------------------------
*/
StatusType db_TradeComBuf( CB_ComBufType **ppComBuf, UINT16 iSize, UINT8 bService )
{
CB_ComBufType *pComBufNew;
/*
** Try to get a combuf that's big enough.
** Note that we also need to get header space, and we don't know whether it is
** a successful header, or a failure, so get the larger of the two.
*/
pComBufNew = CB_TradeForBiggerClear( *ppComBuf,
iSize +
UC_Max( sizeof( CI_GoodReplyHeaderType ),
sizeof( CI_LeBadReplyHeaderType ) ) );
if( pComBufNew == NULL )
{
/*
** Unable to get a big enough combuf.
** Build an error reply header in the old combuf & bail out.
*/
CB_ClearComBuf( *ppComBuf );
CI_PrependReplyHeader( *ppComBuf, bService, CI_GRC_NO_RESOURCE, 0 );
return( FAILURE );
}
/*
** Scoot the data pointer in the combuf to the start of the
** available space. Stuff the new pointer back to the caller.
** Note that the buffer has header space in the front.
*/
CB_ExpandComBuf( pComBufNew, iSize );
*ppComBuf = pComBufNew;
return( SUCCESS );
} /* end of db_TradeComBuf() */
#endif /* #ifdef DEBUG_OBJECT */
/****************************************************************************
*****************************************************************************
**
** End of DB_OBJ.C
**
*****************************************************************************
*****************************************************************************
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -