|
@@ -696,274 +696,6 @@ uint16_t LIBIPMI_HL_GetSensorName(IPMI20_UDS_SESSION_T *pUDSSession,
|
|
|
return wRet;
|
|
|
}
|
|
|
|
|
|
-/*this function wants to be nice to all nice people in the world who display
|
|
|
-sensor information. Instead of letting them go nuts getting all sel entires first
|
|
|
-an then looping thru all sel entires to go get all the sensor names and then each time to
|
|
|
-get a sensor name read SDR
|
|
|
-it just does that for them
|
|
|
-GetAllSelEntires
|
|
|
-Also GetAllSDR stuff once
|
|
|
-then loop and fill it all up internally*/
|
|
|
-uint16_t Storlead_GetAllSelEntriesWithSensorNames(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
|
|
|
- SELEventRecordWithSensorName_T *pSELEntriesBuffer,
|
|
|
- int timeout)
|
|
|
-{
|
|
|
- uint16_t wRet = 0;
|
|
|
- SDRRepositoryAllocInfo_T SDRAllocationInfo;
|
|
|
- SDRRepositoryInfo_T SDRReposInfo;
|
|
|
- int MaxSDRLen = 0;
|
|
|
- int i,SDRCount = 0;
|
|
|
- uint8_t *pSDRBuff = NULL;
|
|
|
- SDRHeader *pSDRHeader = NULL;
|
|
|
- uint8_t *pSDRStart = NULL;
|
|
|
- uint32_t nNumSelEntries = 0;
|
|
|
- int q = 0;
|
|
|
-
|
|
|
-
|
|
|
- /***********************************Get all Sel Entries now*********************************************/
|
|
|
- /* We want to read full records */
|
|
|
- //DataLen = sizeof(GetSELRes_T) + sizeof(SELEventRecord_T);
|
|
|
-
|
|
|
- wRet = Storlead_AMIGetSELEntires(pUDSSession, IpmbAddr, pSELEntriesBuffer,&nNumSelEntries,timeout);
|
|
|
- if(wRet != LIBIPMI_E_SUCCESS)
|
|
|
- {
|
|
|
- printf("LIBIPMI_HL_AMIGetSELEntires : Error getting SEL Entries \n");
|
|
|
- return wRet;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /*************************************Get The SDR once so that we can get sensor names*******************/
|
|
|
- /* Get max buffer size to be allocated to read all SDRs in the system */
|
|
|
- if(IpmbAddr == 0x20)
|
|
|
- {
|
|
|
- wRet = IPMICMD_GetSDRRepositoryAllocInfo(pUDSSession, &SDRAllocationInfo, timeout);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- wRet = IPMC_GetSDRRepositoryAllocInfo(pUDSSession, IpmbAddr, &SDRAllocationInfo, timeout);
|
|
|
- }
|
|
|
- if( wRet != 0 )
|
|
|
- {
|
|
|
- printf("Error getting SDR Repository Allocation Info\n");
|
|
|
- return wRet;
|
|
|
- }
|
|
|
- printf("---> NumAllocUnits: %d, AllocUnitSize: %d, NumFreeAllocUnits: %d, LargestFreeBlock: %d, MaxRecSize: %d\n", \
|
|
|
- SDRAllocationInfo.NumAllocUnits, SDRAllocationInfo.AllocUnitSize, SDRAllocationInfo.NumFreeAllocUnits, \
|
|
|
- SDRAllocationInfo.LargestFreeBlock, SDRAllocationInfo.MaxRecSize);
|
|
|
-
|
|
|
- /* Get repository information */
|
|
|
- if(IpmbAddr == 0x20)
|
|
|
- {
|
|
|
- wRet = IPMICMD_GetSDRRepositoryInfo(pUDSSession, &SDRReposInfo,timeout);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- wRet = IPMC_GetSDRRepositoryInfo(pUDSSession, IpmbAddr, &SDRReposInfo,timeout);
|
|
|
- }
|
|
|
- if( wRet != 0 )
|
|
|
- {
|
|
|
- printf("Error getting SDR Repository Info\n");
|
|
|
- return wRet;
|
|
|
- }
|
|
|
-
|
|
|
- /* Determine max SDR entry length */
|
|
|
- MaxSDRLen = SDRAllocationInfo.MaxRecSize * ( SDRAllocationInfo.AllocUnitSize );
|
|
|
-
|
|
|
- /* Determine total number of SDRs stored */
|
|
|
- SDRCount = ( SDRReposInfo.RecCt );
|
|
|
- printf("---> SDRCount: %d, MaxSDRLen: %d\n", SDRCount, MaxSDRLen);
|
|
|
-
|
|
|
- /* Allocate the buffer */
|
|
|
- pSDRBuff = (uint8_t *) walloc(MaxSDRLen * SDRCount);
|
|
|
- if(!pSDRBuff)
|
|
|
- {
|
|
|
- printf("Error allocating memopry for SDRs in GetAllEventsWithSensorNames\n");
|
|
|
- wRet = STATUS_CODE(IPMI_ERROR_FLAG,CC_OUT_OF_SPACE);
|
|
|
- return wRet;
|
|
|
- }
|
|
|
- pSDRStart = pSDRBuff;
|
|
|
-
|
|
|
- /* Call the function to read all the SDRs into this buffer */
|
|
|
- wRet = Storlead_GetAllSDRs(pUDSSession, IpmbAddr,
|
|
|
- pSDRBuff,(MaxSDRLen * SDRCount),
|
|
|
- timeout*4);
|
|
|
-
|
|
|
- /*************************************Get The SDR once so that we can get sensor names*******************/
|
|
|
- /******************Now parse through sensor headers and get names corresponding to each event************/
|
|
|
- for(q=0;q<nNumSelEntries;q++)
|
|
|
- {
|
|
|
-
|
|
|
- strcpy((char*)pSELEntriesBuffer[q].SensorName,(char*)"Unknown");
|
|
|
-
|
|
|
- pSDRBuff = pSDRStart;
|
|
|
- for( i = 0; i < SDRCount; i++)
|
|
|
- {
|
|
|
- pSDRHeader = (SDRHeader *) pSDRBuff;
|
|
|
- if((pSDRHeader->RecordType >= 0x01) && (pSDRHeader->RecordType <= 0x03))
|
|
|
- {
|
|
|
- /* Compare SlaveAdd and LUNid fields */
|
|
|
- uint8_t *pTmp = pSDRBuff + sizeof(SDRHeader);
|
|
|
- uint8_t len = 0;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if((pSELEntriesBuffer[q].EventRecord.EvtRecord.GenID[0] == *pTmp) && (pSELEntriesBuffer[q].EventRecord.EvtRecord.GenID[1] == *(pTmp+1)))
|
|
|
- {
|
|
|
-
|
|
|
- /* Now compare the sensor number */
|
|
|
- if(pSELEntriesBuffer[q].EventRecord.EvtRecord.SensorNum == *(pTmp+2))
|
|
|
- {
|
|
|
- /* Get the Name and return */
|
|
|
- if(pSDRHeader->RecordType == 0x01)
|
|
|
- pTmp = pSDRBuff + sizeof(SDRHeader) + 42;
|
|
|
- else if(pSDRHeader->RecordType == 0x02)
|
|
|
- pTmp = pSDRBuff + sizeof(SDRHeader) + 26;
|
|
|
- else
|
|
|
- pTmp = pSDRBuff + sizeof(SDRHeader) + 11;
|
|
|
-
|
|
|
- len = GetBits(*pTmp,5,0);
|
|
|
- if(len)
|
|
|
- {
|
|
|
- pTmp++;
|
|
|
-
|
|
|
- memcpy(pSELEntriesBuffer[q].SensorName,pTmp,len);
|
|
|
- pSELEntriesBuffer[q].SensorName[len] = 0;
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- strcpy((char*)pSELEntriesBuffer[q].SensorName,(char*)"Unknown");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- pSDRBuff += MaxSDRLen;
|
|
|
- }
|
|
|
- }
|
|
|
- wfree(pSDRStart);
|
|
|
- return wRet;
|
|
|
-}
|
|
|
-
|
|
|
-uint16_t IPMC_GetAllSelEntriesWithSensorNames(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
|
|
|
- SELEventRecordWithSensorName_T *pSELEntriesBuffer,
|
|
|
- int timeout)
|
|
|
-{
|
|
|
- uint16_t wRet = 0;
|
|
|
- SDRRepositoryAllocInfo_T SDRAllocationInfo;
|
|
|
- SDRRepositoryInfo_T SDRReposInfo;
|
|
|
- int MaxSDRLen = 0;
|
|
|
- int i,SDRCount = 0;
|
|
|
- uint8_t *pSDRBuff = NULL;
|
|
|
- SDRHeader *pSDRHeader = NULL;
|
|
|
- uint8_t *pSDRStart = NULL;
|
|
|
- uint32_t nNumSelEntries = 0;
|
|
|
- int q = 0;
|
|
|
-
|
|
|
-
|
|
|
- /***********************************Get all Sel Entries now*********************************************/
|
|
|
- /* We want to read full records */
|
|
|
- //DataLen = sizeof(GetSELRes_T) + sizeof(SELEventRecord_T);
|
|
|
-
|
|
|
- wRet = Storlead_AMIGetSELEntires(pUDSSession, 0x20, pSELEntriesBuffer,&nNumSelEntries,timeout);
|
|
|
- if(wRet != LIBIPMI_E_SUCCESS)
|
|
|
- {
|
|
|
- printf("LIBIPMI_HL_AMIGetSELEntires : Error getting SEL Entries \n");
|
|
|
- return wRet;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /*************************************Get The SDR once so that we can get sensor names*******************/
|
|
|
- /* Get max buffer size to be allocated to read all SDRs in the system */
|
|
|
- wRet = IPMICMD_GetSDRRepositoryAllocInfo(pUDSSession, &SDRAllocationInfo, timeout);
|
|
|
- if( wRet != 0 )
|
|
|
- {
|
|
|
- printf("Error getting SDR Repository Allocation Info\n");
|
|
|
- return wRet;
|
|
|
- }
|
|
|
- printf("---> NumAllocUnits: %d, AllocUnitSize: %d, NumFreeAllocUnits: %d, LargestFreeBlock: %d, MaxRecSize: %d\n", \
|
|
|
- SDRAllocationInfo.NumAllocUnits, SDRAllocationInfo.AllocUnitSize, SDRAllocationInfo.NumFreeAllocUnits, \
|
|
|
- SDRAllocationInfo.LargestFreeBlock, SDRAllocationInfo.MaxRecSize);
|
|
|
-
|
|
|
- /* Get repository information */
|
|
|
- wRet = IPMICMD_GetSDRRepositoryInfo(pUDSSession, &SDRReposInfo,timeout);
|
|
|
- if( wRet != 0 )
|
|
|
- {
|
|
|
- printf("Error getting SDR Repository Info\n");
|
|
|
- return wRet;
|
|
|
- }
|
|
|
-
|
|
|
- /* Determine max SDR entry length */
|
|
|
- MaxSDRLen = SDRAllocationInfo.MaxRecSize * ( SDRAllocationInfo.AllocUnitSize );
|
|
|
-
|
|
|
- /* Determine total number of SDRs stored */
|
|
|
- SDRCount = ( SDRReposInfo.RecCt );
|
|
|
- printf("---> SDRCount: %d, MaxSDRLen: %d\n", SDRCount, MaxSDRLen);
|
|
|
-
|
|
|
- /* Allocate the buffer */
|
|
|
- pSDRBuff = (uint8_t *) walloc(MaxSDRLen * SDRCount);
|
|
|
- if(!pSDRBuff)
|
|
|
- {
|
|
|
- printf("Error allocating memopry for SDRs in GetAllEventsWithSensorNames\n");
|
|
|
- wRet = STATUS_CODE(IPMI_ERROR_FLAG,CC_OUT_OF_SPACE);
|
|
|
- return wRet;
|
|
|
- }
|
|
|
- pSDRStart = pSDRBuff;
|
|
|
-
|
|
|
- /* Call the function to read all the SDRs into this buffer */
|
|
|
- wRet = Storlead_GetAllSDRs(pUDSSession, 0x20,
|
|
|
- pSDRBuff,(MaxSDRLen * SDRCount),
|
|
|
- timeout*4);
|
|
|
-
|
|
|
- /*************************************Get The SDR once so that we can get sensor names*******************/
|
|
|
- /******************Now parse through sensor headers and get names corresponding to each event************/
|
|
|
- for(q=0;q<nNumSelEntries;q++)
|
|
|
- {
|
|
|
-
|
|
|
- strcpy((char*)pSELEntriesBuffer[q].SensorName,(char*)"Unknown");
|
|
|
-
|
|
|
- pSDRBuff = pSDRStart;
|
|
|
- for( i = 0; i < SDRCount; i++)
|
|
|
- {
|
|
|
- pSDRHeader = (SDRHeader *) pSDRBuff;
|
|
|
- if((pSDRHeader->RecordType >= 0x01) && (pSDRHeader->RecordType <= 0x03))
|
|
|
- {
|
|
|
- /* Compare SlaveAdd and LUNid fields */
|
|
|
- uint8_t *pTmp = pSDRBuff + sizeof(SDRHeader);
|
|
|
- uint8_t len = 0;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if((pSELEntriesBuffer[q].EventRecord.EvtRecord.GenID[0] == *pTmp) && (pSELEntriesBuffer[q].EventRecord.EvtRecord.GenID[1] == *(pTmp+1)))
|
|
|
- {
|
|
|
- /* Now compare the sensor number */
|
|
|
- if(pSELEntriesBuffer[q].EventRecord.EvtRecord.SensorNum == *(pTmp+2))
|
|
|
- {
|
|
|
- /* Get the Name and return */
|
|
|
- if(pSDRHeader->RecordType == 0x01)
|
|
|
- pTmp = pSDRBuff + sizeof(SDRHeader) + 42;
|
|
|
- else if(pSDRHeader->RecordType == 0x02)
|
|
|
- pTmp = pSDRBuff + sizeof(SDRHeader) + 26;
|
|
|
- else
|
|
|
- pTmp = pSDRBuff + sizeof(SDRHeader) + 11;
|
|
|
-
|
|
|
- len = GetBits(*pTmp,5,0);
|
|
|
- if(len)
|
|
|
- {
|
|
|
- pTmp++;
|
|
|
-
|
|
|
- memcpy(pSELEntriesBuffer[q].SensorName,pTmp,len);
|
|
|
- pSELEntriesBuffer[q].SensorName[len] = 0;
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- strcpy((char*)pSELEntriesBuffer[q].SensorName,(char*)"Unknown");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- pSDRBuff += MaxSDRLen;
|
|
|
- }
|
|
|
- }
|
|
|
- wfree(pSDRStart);
|
|
|
- return wRet;
|
|
|
-}
|
|
|
/*****************************************************************************
|
|
|
Field Replacement Unit (FRU)
|
|
|
******************************************************************************/
|