zhangbo il y a 3 ans
Parent
commit
a698fef254

BIN
app/NCP81111_Config/ncp81111_cfg


BIN
app/UpdateFirmware/updateFW_app


+ 1 - 1
app/bmc/msghndlr/PDKCmds.c

@@ -348,7 +348,7 @@ const CmdHndlrMap_T g_Storlead_CmdHndlr [] =
     { CMD_GET_LAN_INFO,      PRIV_USER,      Storlead_GetLanInfo,         0xff,  0xAAAA  ,0xFFFF},
     { CMD_SET_LAN_INFO,      PRIV_USER,      Storlead_SetLanInfo,         0xff,  0xAAAA  ,0xFFFF},
     { CMD_GET_BLADE_INFO,      PRIV_USER,      Storlead_GetBladeInfo,         0xff,  0xAAAA  ,0xFFFF},
-    
+    { CMD_GET_SENSOR_NAME,      PRIV_USER,      Storlead_GetSensorName,         0xff,  0xAAAA  ,0xFFFF},
      { 0x00,                     0x00,           0x00,                 0x00, 0x0000  ,  0x0000},
 };
 

+ 23 - 0
app/bmc/msghndlr/Storlead/Storlead.c

@@ -632,4 +632,27 @@ int Storlead_GetBladeInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
     pRes[34] = g_BMCInfo.PowerGoodFlag;
 
     return 35;
+}
+
+/*
+    Req[0] : sensor name
+
+*/
+int Storlead_GetSensorName(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
+{
+    int i;
+    SensorInfo_T*           pSensorInfo;
+
+    memset(pRes, 0, MAX_ID_STR_LEN+1);    
+    for(i=0;i<SENSOR_NUMBERS;i++)
+    {
+        pSensorInfo = (SensorInfo_T *)&g_BMCInfo.SensorSharedMem.SensorInfo [i];
+        if(pReq[0] == pSensorInfo->SensorNumber)
+        {
+            memcpy(&pRes[1], ((FullSensorRec_T*)pSensorInfo->SDRRec)->IDStr, MAX_ID_STR_LEN);
+            break;
+        }
+    }
+
+    return MAX_ID_STR_LEN+1;
 }

+ 2 - 1
app/bmc/msghndlr/Storlead/Storlead.h

@@ -17,4 +17,5 @@ int Storlead_GetChassisInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
 int Storlead_RestoreFactorSettings(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
 int Storlead_GetLanInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
 int Storlead_SetLanInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
-int Storlead_GetBladeInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
+int Storlead_GetBladeInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
+int Storlead_GetSensorName(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);

+ 1 - 1
app/bmc/msghndlr/cmdselect.c

@@ -813,7 +813,7 @@ const NetFnCmds_T g_Storlead [] =
 	{ CMD_GET_LAN_INFO          ,ENABLED},	
 	{ CMD_SET_LAN_INFO          ,ENABLED},	
 	{ CMD_GET_BLADE_INFO          ,ENABLED},	
-
+	{ CMD_GET_SENSOR_NAME          ,ENABLED},	
 	{0,				0		},
 };
 

+ 8 - 7
app/common_include/com_BMCCfg.h

@@ -41,14 +41,15 @@ extern uint8_t ChassisSecondaryIPMBAddr[BLADE_NUMBERS];
 ---------------------------------------------
 0x76 0000 ~ 0x7F FFFF 	640KB 	Reserve
 =============================================
+以上改为16MB的Flash
 */
-#define CONFIG_FLASH_START 	0x700000
-#define IPMI_CFG_FLASH_ADDR 0x700000
-#define USERTBL_FLASH_ADDR 	0x710000
-#define FRU_FLASH_ADDR 		0x720000
-#define SDR_FLASH_ADDR 		0x730000
-#define SENSOR_HISTORY_FLASH_ADDR 	0x740000
-#define SEL_FLASH_ADDR 		0x750000
+#define CONFIG_FLASH_START 	0xF00000
+#define IPMI_CFG_FLASH_ADDR 0xF00000
+#define USERTBL_FLASH_ADDR 	0xF10000
+#define FRU_FLASH_ADDR 		0xF20000
+#define SDR_FLASH_ADDR 		0xF30000
+#define SENSOR_HISTORY_FLASH_ADDR 	0xF40000
+#define SEL_FLASH_ADDR 		0xF50000
 
 
 

+ 1 - 0
app/common_include/com_IPMI_Storlead.h

@@ -16,6 +16,7 @@
 #define CMD_GET_LAN_INFO		0xC
 #define CMD_SET_LAN_INFO		0xD
 #define CMD_GET_BLADE_INFO		0xE
+#define CMD_GET_SENSOR_NAME		0xF
 
 
 #endif /* __COM_IPMI_STORLEAD_H__ */

+ 25 - 6
app/goahead-3.6.5/src/libipmi/inc/libipmi_StorDevice.h

@@ -41,11 +41,24 @@ extern "C" {
   uint16_t IPMICMD_ReserveSEL(IPMI20_UDS_SESSION_T *pUDSSession,
 					ReserveSELRes_T* pReserveSelRes,
 					int timeout);
+  uint16_t IPMC_ReserveSEL(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+					ReserveSELRes_T* pReserveSelRes,
+					int timeout);
   uint16_t IPMICMD_GetSELEntry(IPMI20_UDS_SESSION_T *pUDSSession,
 					GetSELReq_T* pGetSELReqData,
 					uint8_t* pGetSELResData,
 					uint32_t ResDataLen,
 					int timeout);
+ uint16_t IPMI_GetSELEntry(IPMI20_UDS_SESSION_T *pUDSSession,
+				GetSELReq_T* pGetSELReqData,
+				SELEventRecord_T* pSELEventData,
+				uint16_t *nextRecID,
+				int timeout);
+ uint16_t IPMC_GetSELEntry(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+				GetSELReq_T* pGetSELReqData,
+				SELEventRecord_T* pSELEventData,
+				uint16_t *nextRecID,
+				int timeout);
   uint16_t IPMICMD_AddSELEntry(IPMI20_UDS_SESSION_T *pUDSSession,
 					SELEventRecord_T* pSELReqData,
 					AddSELRes_T* pSELResData,
@@ -61,12 +74,12 @@ extern "C" {
   uint16_t IPMC_GetNumOfSELEntries(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, 
 					uint16_t* nNumOfSELEntries,
 					int timeout);
-  uint16_t LIBIPMI_HL_GetMaxPossibleSELEntries(IPMI20_UDS_SESSION_T *pUDSSession,
-					uint16_t* nMaxPossibleSELEntries,
-					int timeout);
-  uint16_t IPMC_GetMaxPossibleSELEntries(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
-						uint16_t* nMaxPossibleSELEntries,
-						int timeout);
+  // uint16_t LIBIPMI_HL_GetMaxPossibleSELEntries(IPMI20_UDS_SESSION_T *pUDSSession,
+		// 			uint16_t* nMaxPossibleSELEntries,
+		// 			int timeout);
+  // uint16_t IPMC_GetMaxPossibleSELEntries(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+		// 				uint16_t* nMaxPossibleSELEntries,
+		// 				int timeout);
   uint16_t LIBIPMI_HL_GetAllSELEntries(IPMI20_UDS_SESSION_T *pUDSSession,
 					SELEventRecord_T *pSELEntriesBuffer,
 					int timeout);
@@ -160,6 +173,8 @@ uint8_t libipmi_GetBits(uint8_t orig, uint8_t startbit, uint8_t endbit);
 
   uint8_t IPMICMD_GetSELTime(IPMI20_UDS_SESSION_T *pUDSSession,
 				GetSELTimeRes_T *pGetSELTimeRes, int timeout);
+  uint8_t IPMC_GetSELTime(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+				GetSELTimeRes_T *pGetSELTimeRes, int timeout);
 
   uint8_t IPMICMD_SetSELTime(IPMI20_UDS_SESSION_T *pUDSSession,
 				SetSELTimeReq_T *pSetSELTimeReq, int timeout);
@@ -168,9 +183,13 @@ uint8_t libipmi_GetBits(uint8_t orig, uint8_t startbit, uint8_t endbit);
 
   uint8_t IPMICMD_GetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession,
 				GetSELTimeUTCOffsetRes_T *pGetSELTimeUTCOffsetRes, int timeout);
+  uint8_t IPMC_GetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+				GetSELTimeUTCOffsetRes_T *pGetSELTimeUTCOffsetRes, int timeout);
 
   uint8_t IPMICMD_SetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession,
 				SetSELTimeUTCOffsetReq_T *pSetSELTimeUTCOffsetReq, int timeout);
+  uint8_t IPMC_SetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+				SetSELTimeUTCOffsetReq_T *pSetSELTimeUTCOffsetReq, int timeout);
 
 
 #ifdef  __cplusplus

+ 2 - 0
app/goahead-3.6.5/src/libipmi/inc/libipmi_storlead_OEM.h

@@ -114,5 +114,7 @@ uint16_t IPMICMD_GetLanInfo(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t index, La
 uint16_t IPMICMD_restoreFactorySettings(IPMI20_UDS_SESSION_T *pUDSSession, int timeout);
 uint16_t IPMC_restoreFactorySettings(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, int timeout);
 int LIBIPMI_IPMC_GetDeviceID(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, GetDevIDRes_T *DevIDRes, int timeout);
+int IPMI_GetSensorName(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t sensor_number, uint8_t *sensor_name, int timeout);
+int IPMC_GetSensorName(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint8_t sensor_number, uint8_t *sensor_name, int timeout);
 #endif /* __LIBIPMI_STORLEAD_OEM_H__ */
 

+ 270 - 152
app/goahead-3.6.5/src/libipmi/src/libipmi_StorDevice.c

@@ -49,25 +49,6 @@ uint8_t libipmi_GetBits(uint8_t orig, uint8_t startbit, uint8_t endbit)
 /*****************************************************************************
 	System Event Log
 ******************************************************************************/
-uint16_t IPMICMD_GetSELInfo(IPMI20_UDS_SESSION_T *pUDSSession,
-				SELInfo_T *pResGetSELInfo,
-				int timeout)
-{
-	uint16_t	wRet;
-	uint32_t	dwResLen;
-	uint8_t	DummyReqData[8];
-	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
-
-	dwResLen = sizeof(SELInfo_T);
-	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_GET_SEL_INFO,
-						(uint8_t*)DummyReqData, 0,
-						(uint8_t *)pResGetSELInfo, &dwResLen,
-						timeout);
-	return wRet;
-}
-
-
 
 uint16_t IPMICMD_GetSELAllocationInfo(IPMI20_UDS_SESSION_T *pUDSSession,
 					SELAllocInfo_T *pResGetSELAllocInfo,
@@ -76,11 +57,10 @@ uint16_t IPMICMD_GetSELAllocationInfo(IPMI20_UDS_SESSION_T *pUDSSession,
 	uint16_t	wRet;
 	uint32_t	dwResLen;
 	uint8_t	DummyReqData[8];
-	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(SELAllocInfo_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_GET_SEL_ALLOCATION_INFO,
+						NETFNLUN_IPMI_APP, CMD_GET_SEL_ALLOCATION_INFO,
 						(uint8_t*)DummyReqData, 0,
 						(uint8_t *)pResGetSELAllocInfo, &dwResLen,
 						timeout);
@@ -96,28 +76,65 @@ uint16_t IPMICMD_ReserveSEL(IPMI20_UDS_SESSION_T *pUDSSession,
 	uint32_t	dwResLen = 0;
 
 	memset(pReserveSelRes, 0, sizeof(ReserveSELRes_T));
-
-	dwResLen = sizeof(ReserveSELRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						(NETFN_STORAGE << 2), CMD_RESERVE_SEL,
+						NETFNLUN_IPMI_APP, CMD_RESERVE_SEL,
 						NULL, 0,
 						(uint8_t *)pReserveSelRes, &dwResLen,
 						timeout);
 
-	if ( (wRet != 0) && (pReserveSelRes->CompletionCode != CC_INV_CMD) )
+	/* If ReserveSEL command is not implemented, return 0x0000 as reservation ID */
+	if ( pReserveSelRes->CompletionCode == CC_INV_CMD )
+	{
+		pReserveSelRes->ReservationID = 0x0000;
+		return 0;
+	}
+
+	if(wRet != 0) 
 	{
 		printf("Could not get SEL reservation!!\n");
 		return wRet;
 	}
+	return 0;
+}
+
+uint16_t IPMC_ReserveSEL(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+					ReserveSELRes_T* pReserveSelRes,
+					int timeout)
+{
+	int wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t 	Req[50] = {0};
+	uint8_t		Res[50] = {0};
+
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_APP;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_RESERVE_SEL;	
+	Req[7] = 0x100 - (Req[4] + Req[5] + Req[6])&0xff;
+
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+							NETFNLUN_IPMI_APP, CMD_SEND_MSG,
+							Req, 8,
+							Res,  &dwResLen,
+							timeout);
 
+	memcpy(pReserveSelRes, &Res[6], sizeof(ReserveSELRes_T));
 	/* If ReserveSEL command is not implemented, return 0x0000 as reservation ID */
 	if ( pReserveSelRes->CompletionCode == CC_INV_CMD )
 	{
 		pReserveSelRes->ReservationID = 0x0000;
-		wRet = 0;
+		return 0;
 	}
 
-	return wRet;
+	if(wRet != 0) 
+	{
+		printf("Could not get SEL reservation!!\n");
+		return wRet;
+	}
+	return 0;
 }
 
 /* This function gets an entry from SEL. */
@@ -128,16 +145,94 @@ uint16_t IPMICMD_GetSELEntry(IPMI20_UDS_SESSION_T *pUDSSession,
 				int timeout)
 {
 	uint16_t wRet = 0;
-	uint8_t NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_GET_SEL_ENTRY,
+						NETFNLUN_IPMI_APP, CMD_GET_SEL_ENTRY,
 						(uint8_t*)pGetSELReqData, sizeof(GetSELReq_T),
 						(uint8_t *)pGetSELResData, &ResDataLen,
 						timeout);
 	return wRet;
 }
 
+uint16_t IPMI_GetSELEntry(IPMI20_UDS_SESSION_T *pUDSSession,
+				GetSELReq_T* pGetSELReqData,
+				SELEventRecord_T* pSELEventData,
+				uint16_t *nextRecID,
+				int timeout)
+{
+	uint16_t 	wRet = 0;
+	uint8_t 	Res[50];
+	uint32_t	dwResLen;
+
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+						NETFNLUN_IPMI_STORAGE, CMD_GET_SEL_ENTRY,
+						(uint8_t*)pGetSELReqData, sizeof(GetSELReq_T),
+						Res, &dwResLen,
+						timeout);
+	// printf("---> Res ");
+	// int i;
+	// for(i=0;i<17;i++)
+	// 	printf("%02x ", Res[i]);
+	// printf("\n");
+	if((wRet != 0) || (Res[0] != 0))
+	{
+		printf("IPMI_GetSELEntry failed\n");
+		*nextRecID = 0xffff;
+		memset(pSELEventData, 0, sizeof(SELEventRecord_T));
+		return wRet;
+	}
+
+	*nextRecID = (Res[2]<<8) | Res[1];
+	memcpy(pSELEventData, &Res[3], sizeof(SELEventRecord_T));
+
+	return 0;
+}
+
+uint16_t IPMC_GetSELEntry(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+				GetSELReq_T* pGetSELReqData,
+				SELEventRecord_T* pSELEventData,
+				uint16_t *nextRecID,
+				int timeout)
+{
+	int wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t 	Req[50] = {0};
+	uint8_t		Res[50] = {0};
+
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_STORAGE;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_GET_SEL_ENTRY;	
+	Req[7] = pGetSELReqData->ReservationID&0xff;
+	Req[8] = (pGetSELReqData->ReservationID>>8)&0xff;
+	Req[9] = pGetSELReqData->RecID&0xff;
+	Req[10] = (pGetSELReqData->RecID>>8)&0xff;
+	Req[11] = pGetSELReqData->Offset;
+	Req[12] = pGetSELReqData->Size;
+	Req[13] = 0x100 - (Req[4] + Req[5] + Req[6] + Req[7] + Req[8] + Req[9] + Req[10] + Req[11] + Req[12])&0xff;
+
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+							NETFNLUN_IPMI_APP, CMD_SEND_MSG,
+							Req, 14,
+							Res,  &dwResLen,
+							timeout);
+	if((wRet != 0) || (Res[6] != 0))
+	{
+		printf("IPMI_GetSELEntry failed\n");
+		*nextRecID = 0xffff;
+		memset(pSELEventData, 0, sizeof(SELEventRecord_T));
+		return wRet;
+	}
+
+	*nextRecID = (Res[8]<<8) | Res[7];
+	memcpy(pSELEventData, &Res[9], sizeof(SELEventRecord_T));
+
+	return 0;
+}
+
 /* This function adds an entry into SEL. */
 uint16_t IPMICMD_AddSELEntry(IPMI20_UDS_SESSION_T *pUDSSession,
 				SELEventRecord_T* pSELReqData,
@@ -146,11 +241,10 @@ uint16_t IPMICMD_AddSELEntry(IPMI20_UDS_SESSION_T *pUDSSession,
 {
 	uint16_t wRet = 0;
 	uint32_t	dwResLen;
-	uint8_t NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(AddSELRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_ADD_SEL_ENTRY,
+						NETFNLUN_IPMI_APP, CMD_ADD_SEL_ENTRY,
 						(uint8_t*)pSELReqData, sizeof(SELEventRecord_T),
 						(uint8_t *)pSELResData, &dwResLen,
 						timeout);
@@ -175,7 +269,7 @@ uint16_t IPMICMD_DeleteSELEntry(IPMI20_UDS_SESSION_T *pUDSSession,
 	//first do a SEL reservation
 	dwResLen = sizeof(ReserveSELRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						(NETFN_STORAGE << 2), CMD_RESERVE_SEL,
+						NETFNLUN_IPMI_APP, CMD_RESERVE_SEL,
 						NULL, 0,
 						(uint8_t *)&ReserveSelRes, &dwResLen,
 						timeout);
@@ -199,7 +293,7 @@ uint16_t IPMICMD_DeleteSELEntry(IPMI20_UDS_SESSION_T *pUDSSession,
 	DeleteSELReqData.RecID = RecordID;
 
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						(NETFN_STORAGE << 2), CMD_DELETE_SEL_ENTRY,
+						NETFNLUN_IPMI_APP, CMD_DELETE_SEL_ENTRY,
 						(uint8_t*)&DeleteSELReqData, sizeof(DeleteSELReqData),
 						(uint8_t *)&DeleteSELResData, &dwResLen,
 						timeout);
@@ -217,12 +311,10 @@ uint16_t IPMICMD_ClearSEL(IPMI20_UDS_SESSION_T *pUDSSession,
 
 	uint8_t DummyReqData[8];
 
-	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
-
 	//first do a SEL reservation
  	dwResLen = sizeof(ReserveSELRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_RESERVE_SEL,
+						NETFNLUN_IPMI_APP, CMD_RESERVE_SEL,
 						(uint8_t*)DummyReqData, 0,
 						(uint8_t *)&ReserveSelRes, &dwResLen,
 						timeout);
@@ -251,7 +343,7 @@ uint16_t IPMICMD_ClearSEL(IPMI20_UDS_SESSION_T *pUDSSession,
 
 	dwResLen = sizeof(ClearSELRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_CLEAR_SEL,
+						NETFNLUN_IPMI_APP, CMD_CLEAR_SEL,
 						(uint8_t*)&ClearSelReq, sizeof(ClearSELReq_T),
 						(uint8_t *)&ClearSelRes, &dwResLen,
 						timeout);
@@ -340,17 +432,25 @@ uint16_t LIBIPMI_HL_GetNumOfSELEntries(IPMI20_UDS_SESSION_T *pUDSSession,
 					uint16_t* nNumOfSELEntries,
 					int timeout)
 {
-	uint16_t wRet = 0;
 	SELInfo_T SELInfo;
+	uint16_t	wRet;
+	uint32_t	dwResLen;
+	uint8_t	DummyReqData[8];
 
-	wRet =  IPMICMD_GetSELInfo(pUDSSession,&SELInfo,timeout);
-	if(wRet != 0)
+	dwResLen = sizeof(SELInfo_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+						NETFNLUN_IPMI_STORAGE, CMD_GET_SEL_INFO,
+						(uint8_t*)DummyReqData, 0,
+						(uint8_t *)&SELInfo, &dwResLen,
+						timeout);
+	if((wRet != 0) || (SELInfo.CompletionCode != 0))
 	{
 		printf("LIBIPMI_HL_GetNumOfSELEntries: Error getting SEL info\n");
+		*nNumOfSELEntries = 0;
 		return wRet;
 	}
 	*nNumOfSELEntries =  (SELInfo.RecCt);
-	return wRet;
+	return 0;
 }
 
 uint16_t IPMC_GetNumOfSELEntries(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, 
@@ -388,63 +488,9 @@ uint16_t IPMC_GetNumOfSELEntries(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t Ipmb
 	pSELInfo = (SELInfo_T *)&Res[6];
 	*nNumOfSELEntries =  (pSELInfo->RecCt);
 
-	return wRet;
+	return 0;
 }
 
-/* This function returns max possible number of SEL entries in the system at any time */
-uint16_t LIBIPMI_HL_GetMaxPossibleSELEntries(IPMI20_UDS_SESSION_T *pUDSSession,
-						uint16_t* nMaxPossibleSELEntries,
-						int timeout)
-{
-	uint16_t wRet = 0;
-	SELAllocInfo_T SELAllocInfo;
-
-	wRet =  IPMICMD_GetSELAllocationInfo(pUDSSession,&SELAllocInfo,timeout);
-	if(wRet != 0)
-	{
-		printf("LIBIPMI_HL_GetMaxPossibleSELEntries: Error getting SEL Alloc info\n");
-		return wRet;
-	}
-	*nMaxPossibleSELEntries =  (SELAllocInfo.NumAllocUnits);
-	return wRet;
-}
-
-uint16_t IPMC_GetMaxPossibleSELEntries(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
-						uint16_t* nMaxPossibleSELEntries,
-						int timeout)
-{
-	int wRet = 0;
-	uint32_t	dwResLen;
-	uint8_t 	Req[50] = {0};
-	uint8_t		Res[50] = {0};
-	SELAllocInfo_T *pSELAllocInfo;
-
-	Req[0] = 0x40;	//Track | channel 0
-	Req[1] = IpmbAddr;
-	Req[2] = NETFNLUN_IPMI_STORAGE;
-	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
-	Req[4] = 0x20;
-	Req[5] = 0x10;
-	Req[6] = CMD_GET_SEL_ALLOCATION_INFO;	
-	Req[7] = 0x100 - (Req[4] + Req[5] + Req[6])&0xff;
-
-	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-							NETFNLUN_IPMI_APP, CMD_SEND_MSG,
-							Req, 8,
-							Res,  &dwResLen,
-							timeout);
-
-	if ( (wRet != 0) || (Res[6] != 0) )
-	{
-		printf("Get SEL Number failed!\n");
-		*nMaxPossibleSELEntries = 0;
-		return wRet;
-	}
-
-	pSELAllocInfo = (SELAllocInfo_T*)&Res[6];
-	*nMaxPossibleSELEntries =  (pSELAllocInfo->NumAllocUnits);
-	return wRet;
-}
 
 /* This function returns total number of SEL entries present in the system at that time.
    IMPORTANT:
@@ -928,11 +974,10 @@ uint16_t IPMICMD_GetFRUInventoryAreaInfo(IPMI20_UDS_SESSION_T *pUDSSession,
 {
 	uint16_t	wRet,tmp;
 	uint32_t	dwResLen;
-	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(FRUInventoryAreaInfoRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_FRU_INVENTORY_AREA_INFO,
+						NETFNLUN_IPMI_APP, CMD_FRU_INVENTORY_AREA_INFO,
 						(uint8_t *)pReqFRUInventoryAreaInfo, sizeof(FRUInventoryAreaInfoReq_T),
 						(uint8_t *)pResFRUInventoryAreaInfo, &dwResLen,
 						timeout);
@@ -949,11 +994,10 @@ uint16_t IPMICMD_ReadFRUData(IPMI20_UDS_SESSION_T *pUDSSession,
 {
 	uint16_t wRet = 0;
 	uint32_t	dwResLen;
-	uint8_t NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(FRUReadRes_T) + (pFRUReadReqData->CountToRead);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_READ_FRU_DATA,
+						NETFNLUN_IPMI_APP, CMD_READ_FRU_DATA,
 						(uint8_t *)pFRUReadReqData, sizeof(FRUReadReq_T),
 						(uint8_t *)pFRUReadResData, &dwResLen,
 						timeout);
@@ -968,11 +1012,10 @@ uint16_t IPMICMD_WriteFRUData(IPMI20_UDS_SESSION_T *pUDSSession,
 {
 	uint16_t wRet = 0;
 	uint32_t	dwResLen;
-	uint8_t NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(FRUWriteRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_WRITE_FRU_DATA,
+						NETFNLUN_IPMI_APP, CMD_WRITE_FRU_DATA,
 						(uint8_t *)pFRUWriteReqData, ReqDataLen,
 						(uint8_t *)pFRUWriteResData, &dwResLen,
 						timeout);
@@ -1109,11 +1152,10 @@ uint8_t IPMICMD_GetSELTime(IPMI20_UDS_SESSION_T *pUDSSession,
 	uint16_t	wRet;
 	uint32_t	dwResLen;
 	uint8_t	DummyReqData[8];
-	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(GetSELTimeRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_GET_SEL_TIME,
+						NETFNLUN_IPMI_APP, CMD_GET_SEL_TIME,
 						(uint8_t*)DummyReqData, 0,
 						(uint8_t *)pGetSELTimeRes, &dwResLen,
 						timeout);
@@ -1124,17 +1166,49 @@ uint8_t IPMICMD_GetSELTime(IPMI20_UDS_SESSION_T *pUDSSession,
 	return wRet;
 }
 
+uint8_t IPMC_GetSELTime(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+				GetSELTimeRes_T *pGetSELTimeRes, int timeout)
+{
+	int wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t 	Req[50] = {0};
+	uint8_t		Res[50] = {0};
+
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_APP;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_GET_SEL_TIME;	
+	Req[7] = 0x100 - (Req[4] + Req[5] + Req[6])&0xff;
+
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+							NETFNLUN_IPMI_APP, CMD_SEND_MSG,
+							Req, 8,
+							Res,  &dwResLen,
+							timeout);
+	if ((wRet != 0) || (Res[6] != 0))
+	{
+		printf("Error getting SEL Time::%x\n",wRet);
+		pGetSELTimeRes->CompletionCode = Res[6];
+		pGetSELTimeRes->Time = 0;
+		return wRet;
+	}
+	memcpy(pGetSELTimeRes, &Res[6], sizeof(GetSELTimeRes_T));
+	return 0;
+}
+
 uint8_t IPMICMD_SetSELTime(IPMI20_UDS_SESSION_T *pUDSSession,
 				SetSELTimeReq_T *pSetSELTimeReq, int timeout)
 {
 	uint16_t	wRet;
 	uint32_t	dwResLen;
 	uint8_t	DummyResData[8];
-	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(uint8_t);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_SET_SEL_TIME,
+						NETFNLUN_IPMI_APP, CMD_SET_SEL_TIME,
 						(uint8_t *)pSetSELTimeReq, sizeof(SetSELTimeReq_T),
 						(uint8_t *)DummyResData, &dwResLen,
 						timeout);
@@ -1148,54 +1222,33 @@ uint8_t IPMICMD_SetSELTime(IPMI20_UDS_SESSION_T *pUDSSession,
 uint8_t IPMC_SetSELTime(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
 				SetSELTimeReq_T *pSetSELTimeReq, int timeout)
 {
-	uint16_t	wRet;
+	int wRet = 0;
 	uint32_t	dwResLen;
-	uint8_t	DummyResData[8];
-	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
+	uint8_t 	Req[50] = {0};
+	uint8_t		Res[50] = {0};
+
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_APP;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_SET_SEL_TIME;	
+	Req[7] = pSetSELTimeReq->Time&0xff;
+	Req[8] = (pSetSELTimeReq->Time>>8)&0xff;
+	Req[9] = (pSetSELTimeReq->Time>>16)&0xff;
+	Req[10] = (pSetSELTimeReq->Time>>24)&0xff;
+	Req[11] = 0x100 - (Req[4] + Req[5] + Req[6] + Req[7] + Req[8] + Req[9] + Req[10])&0xff;
 
-	dwResLen = sizeof(uint8_t);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_SET_SEL_TIME,
-						(uint8_t *)pSetSELTimeReq, sizeof(SetSELTimeReq_T),
-						(uint8_t *)DummyResData, &dwResLen,
-						timeout);
-	if (wRet != 0)
+							NETFNLUN_IPMI_APP, CMD_SEND_MSG,
+							Req, 12,
+							Res,  &dwResLen,
+							timeout);
+	if ((wRet != 0) || (Res[6] != 0))
 	{
 		printf("Error setting SEL Time::%x\n",wRet);
 	}
-
-	// int wRet = 0;
- //    uint32_t    dwResLen;
- //    uint8_t     Req[50] = {0};
- //    uint8_t     Res[50] = {0};
-
- //    Req[0] = 0x40;  //Track | channel 0
- //    Req[1] = IpmbAddr;
- //    Req[2] = NETFNLUN_IPMI_STORAGE;
- //    Req[3] = 0x100 - (Req[1] + Req[2])&0xff;    //checksum1
- //    Req[4] = 0x20;
- //    Req[5] = 0x10;
- //    Req[6] = CMD_SET_SEL_TIME;  
- //    Req[7] =  (pSetSELTimeReq->Time)&0xff;
- //    Req[8] =  (pSetSELTimeReq->Time>>8)&0xff;
- //    Req[9] =  (pSetSELTimeReq->Time>>16)&0xff;
- //    Req[10] =  (pSetSELTimeReq->Time>>24)&0xff;
- //    Req[11] = 0x100 - (Req[4] + Req[5] + Req[6] + Req[7] + Req[8] + Req[9] + Req[10])&0xff;
-
- //    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
- //                            NETFNLUN_IPMI_APP, CMD_SEND_MSG,
- //                            Req, 8,
- //                            Res,  &dwResLen,
- //                            timeout);
-
- //    if((wRet != 0) || (Res[6] != 0))
- //    {
- //        printf("IPMC_SetSELTime failed!\n");
- //        return -1;
- //    }
-
-
-
 	return wRet;
 }
 
@@ -1205,11 +1258,10 @@ uint8_t IPMICMD_GetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession,
 	uint16_t	wRet;
 	uint32_t	dwResLen;
 	uint8_t	DummyReqData[8];
-	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(GetSELTimeUTCOffsetRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_GET_SEL_TIME_UTC_OFFSET,
+						NETFNLUN_IPMI_APP, CMD_GET_SEL_TIME_UTC_OFFSET,
 						(uint8_t*)DummyReqData, 0,
 						(uint8_t *)pGetSELTimeUTCOffsetRes, &dwResLen,
 						timeout);
@@ -1220,17 +1272,49 @@ uint8_t IPMICMD_GetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession,
 	return wRet;
 }
 
+uint8_t IPMC_GetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+				GetSELTimeUTCOffsetRes_T *pGetSELTimeUTCOffsetRes, int timeout)
+{
+	int wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t 	Req[50] = {0};
+	uint8_t		Res[50] = {0};
+
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_APP;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_GET_SEL_TIME_UTC_OFFSET;	
+	Req[7] = 0x100 - (Req[4] + Req[5] + Req[6])&0xff;
+
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+							NETFNLUN_IPMI_APP, CMD_SEND_MSG,
+							Req, 8,
+							Res,  &dwResLen,
+							timeout);
+	if ((wRet != 0) || (Res[6] != 0))
+	{
+		printf("Error getting SEL Time UTC Offset::%x\n",wRet);
+		pGetSELTimeUTCOffsetRes->CompletionCode;
+		pGetSELTimeUTCOffsetRes->UTCOffset = 0;
+		return wRet;
+	}
+	memcpy(pGetSELTimeUTCOffsetRes, &Res[6], sizeof(GetSELTimeUTCOffsetRes_T));
+	return 0;
+}
+
 uint8_t IPMICMD_SetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession,
 				SetSELTimeUTCOffsetReq_T *pSetSELTimeUTCOffsetReq, int timeout)
 {
 	uint16_t	wRet;
 	uint32_t	dwResLen;
 	SetSELTimeUTCOffsetRes_T pSetSELTimeUTCOffsetRes;
-	uint8_t	NetFnLunStorage = (NETFN_STORAGE << 2);
 
 	dwResLen = sizeof(SetSELTimeUTCOffsetRes_T);
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
-						NetFnLunStorage, CMD_SET_SEL_TIME_UTC_OFFSET,
+						NETFNLUN_IPMI_APP, CMD_SET_SEL_TIME_UTC_OFFSET,
 						(uint8_t *)pSetSELTimeUTCOffsetReq, sizeof(SetSELTimeUTCOffsetReq_T),
 						(uint8_t *)&pSetSELTimeUTCOffsetRes, &dwResLen,
 						timeout);
@@ -1240,3 +1324,37 @@ uint8_t IPMICMD_SetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession,
 	}
 	return wRet;
 }
+
+uint8_t IPMC_SetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,
+				SetSELTimeUTCOffsetReq_T *pSetSELTimeUTCOffsetReq, int timeout)
+{
+	int wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t 	Req[50] = {0};
+	uint8_t		Res[50] = {0};
+
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_APP;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_SET_SEL_TIME_UTC_OFFSET;	
+	Req[7] = pSetSELTimeUTCOffsetReq->UTCOffset&0xff;
+	Req[8] = (pSetSELTimeUTCOffsetReq->UTCOffset>>8)&0xff;
+	Req[9] = (pSetSELTimeUTCOffsetReq->UTCOffset>>16)&0xff;
+	Req[10] = (pSetSELTimeUTCOffsetReq->UTCOffset>>24)&0xff;
+	Req[11] = 0x100 - (Req[4] + Req[5] + Req[6] + Req[7] + Req[8] + Req[9] + Req[10])&0xff;
+
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+							NETFNLUN_IPMI_APP, CMD_SEND_MSG,
+							Req, 12,
+							Res,  &dwResLen,
+							timeout);
+	if ((wRet != 0) || (Res[6] != 0))
+	{
+		printf("Error setting SEL Time UTC Offset::%x\n",wRet);
+		return wRet;
+	}
+	return 0;
+}

Fichier diff supprimé car celui-ci est trop grand
+ 2 - 1103
app/goahead-3.6.5/src/libipmi/src/libipmi_fru.c


+ 90 - 43
app/goahead-3.6.5/src/libipmi/src/libipmi_storlead_OEM.c

@@ -753,57 +753,46 @@ uint16_t Storlead_AMIGetSELEntires(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t Ip
 	{
 		if(LastRecID != 0xFFFF)
 		{
-			if(IpmbAddr == 0x20)
+			if(LastRecID > MAX_SEL_RECORD)
 			{
-				wRet = LIBIPMI_HL_GetMaxPossibleSELEntries(pUDSSession,&MaxSELEntries,timeout);
-			}
-			else
-			{
-				wRet = IPMC_GetMaxPossibleSELEntries(pUDSSession,IpmbAddr, &MaxSELEntries,timeout);
-			}
-			if(wRet == LIBIPMI_E_SUCCESS)
-			{
-				 if(LastRecID > MaxSELEntries)
+				for(i = 0; i < *nNumSelEntries; i++)
 				{
-					for(i = 0; i < *nNumSelEntries; i++)
+					if(pSELEntriesBuffer[i].EventRecord.EvtRecord.hdr.ID == LastRecID)
 					{
-						if(pSELEntriesBuffer[i].EventRecord.EvtRecord.hdr.ID == LastRecID)
-						{
-							recindex = i;
-							break;
-						}
+						recindex = i;
+						break;
 					}
-	
-					/* Last Record is not found if reached till end of SEL Entries*/
-					if(i == *nNumSelEntries)
+				}
+
+				/* Last Record is not found if reached till end of SEL Entries*/
+				if(i == *nNumSelEntries)
+				{
+					wRet = 0xFF;
+					return wRet;
+				}
+
+				/*SEL Records added lastely will be displayed first */
+				CircSELEntries = (SELEventRecordWithSensorName_T *)walloc (sizeof(SELEventRecordWithSensorName_T) * (*nNumSelEntries));
+				if(CircSELEntries != NULL)
+				{
+					memset(CircSELEntries,0,sizeof(SELEventRecordWithSensorName_T) * (*nNumSelEntries));
+					j = recindex; i = 0;
+					while(j >= 0)
 					{
-						wRet = 0xFF;
-						return wRet;
+						memcpy((uint8_t *)&CircSELEntries[i],(uint8_t*)&pSELEntriesBuffer[j],sizeof(SELEventRecordWithSensorName_T));
+						j--;i++;
 					}
-	
-					/*SEL Records added lastely will be displayed first */
-					CircSELEntries = (SELEventRecordWithSensorName_T *)walloc (sizeof(SELEventRecordWithSensorName_T) * (*nNumSelEntries));
-					if(CircSELEntries != NULL)
+
+					for(j = recindex + 1,i = 1; j < *nNumSelEntries; j++,i++)
+					{
+						memcpy((uint8_t*)&CircSELEntries[j],(uint8_t*)&pSELEntriesBuffer[*nNumSelEntries - i ],sizeof(SELEventRecordWithSensorName_T));
+					}
+
+					for(i = 0,j=1;i< *nNumSelEntries; i++,j++)
 					{
-						memset(CircSELEntries,0,sizeof(SELEventRecordWithSensorName_T) * (*nNumSelEntries));
-						j = recindex; i = 0;
-						while(j >= 0)
-						{
-							memcpy((uint8_t *)&CircSELEntries[i],(uint8_t*)&pSELEntriesBuffer[j],sizeof(SELEventRecordWithSensorName_T));
-							j--;i++;
-						}
-	
-						for(j = recindex + 1,i = 1; j < *nNumSelEntries; j++,i++)
-						{
-							memcpy((uint8_t*)&CircSELEntries[j],(uint8_t*)&pSELEntriesBuffer[*nNumSelEntries - i ],sizeof(SELEventRecordWithSensorName_T));
-						}
-	
-						for(i = 0,j=1;i< *nNumSelEntries; i++,j++)
-						{
-							memcpy((uint8_t*)&pSELEntriesBuffer[i],(uint8_t*)&CircSELEntries[*nNumSelEntries - j],sizeof(SELEventRecordWithSensorName_T));
-						}
-						wfree(CircSELEntries);
+						memcpy((uint8_t*)&pSELEntriesBuffer[i],(uint8_t*)&CircSELEntries[*nNumSelEntries - j],sizeof(SELEventRecordWithSensorName_T));
 					}
+					wfree(CircSELEntries);
 				}
 			}
 		}
@@ -976,5 +965,63 @@ int LIBIPMI_IPMC_GetDeviceID(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr
 			return -1;
 	}
 		
+	return 0;
+}
+
+int IPMI_GetSensorName(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t sensor_number, uint8_t *sensor_name, int timeout)
+{
+	int wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t 	Req[10] = {0};
+	uint8_t		Res[50] = {0};
+
+	Req[0] = sensor_number;
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+							NETFNLUN_IPMI_STORLEAD, CMD_GET_SENSOR_NAME,
+							Req, 1,
+							Res,  &dwResLen,
+							timeout);
+	if((wRet != 0) || (Res[0] != 0))
+	{
+		printf("IPMI_GetSensorName failed!\n");
+		memset(sensor_name, 0, MAX_ID_STR_LEN);
+		return -1;
+	}
+
+	memcpy(sensor_name, &Res[1], MAX_ID_STR_LEN);
+	return 0;
+}
+
+int IPMC_GetSensorName(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint8_t sensor_number, uint8_t *sensor_name, int timeout)
+{
+	int wRet = 0;
+	uint32_t	dwResLen;
+	uint8_t 	Req[10] = {0};
+	uint8_t		Res[50] = {0};
+
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_STORLEAD;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_GET_SENSOR_NAME;	
+	Req[7] = sensor_number;
+	Req[8] = 0x100 - (Req[4] + Req[5] + Req[6] + Req[7])&0xff;
+
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+							NETFNLUN_IPMI_APP, CMD_SEND_MSG,
+							Req, 9,
+							Res,  &dwResLen,
+							timeout);
+
+	if((wRet != 0) || (Res[6] != 0))
+	{
+		printf("IPMI_GetSensorName failed!\n");
+		memset(sensor_name, 0, MAX_ID_STR_LEN);
+		return -1;
+	}
+
+	memcpy(sensor_name, &Res[7], MAX_ID_STR_LEN);
 	return 0;
 }

+ 55 - 397
app/goahead-3.6.5/src/web_interface/src/fru.c

@@ -23,10 +23,11 @@ void getFruChassisInfo(Webs *wp)
 {
 	int wRet = 0;
 	uint32_t fru_size;
-	OemFRUChassisInfo_T chassis_data;
+	OemFRUChassisInfo_T *pChassis_data = walloc(sizeof(OemFRUChassisInfo_T));
 	uint8_t fruIndex = 1;	//FRUDeviceID
 	char *pTmpStr = NULL;
 	uint8_t strLen = 0;
+	uint8_t target_addr;
 
 	char *_chassisPartNum=NULL;
 	char *_chassisSerialNum=NULL;
@@ -36,7 +37,17 @@ void getFruChassisInfo(Webs *wp)
 
 	//Create session
 	LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
-	wRet = LIBIPMI_HL_GetFRUChassisData(&UDSSession,fruIndex,&fru_size,&chassis_data,DEFAULT_TIMEOUT);
+	wp->index = TEST_INDEX;
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+		wRet = LIBIPMI_HL_GetFRUChassisData(&UDSSession,fruIndex,&fru_size,pChassis_data,DEFAULT_TIMEOUT);
+	}
+	else
+	{
+		wRet = IPMC_GetFRUChassisData(&UDSSession,target_addr, fruIndex,&fru_size,pChassis_data,DEFAULT_TIMEOUT);
+	}
+
 	if(wRet==FRU_INVALID_HEADER_VERSION)
 	{
 		printf("Invalid FRU Header Version for ID : %d\n", fruIndex);
@@ -52,15 +63,9 @@ void getFruChassisInfo(Webs *wp)
     //Close session
     LIBIPMI_CloseSession(&UDSSession );
 
-    int i;
-    uint8_t *pDebug = (uint8_t*)&chassis_data;
-    printf("chassis_info %d: ", fru_size);
-    for(i=0;i<fru_size;i++)
-    	printf("%#x ", pDebug[i]);
-    printf("\n");
 	//_chassisPartNum
-	strLen = chassis_data.Data[0] & 0x3F;
-	pTmpStr = &chassis_data.Data[1];
+	strLen = pChassis_data->Data[0] & 0x3F;
+	pTmpStr = &pChassis_data->Data[1];
 	_chassisPartNum = walloc(strLen+1);
 	memset(_chassisPartNum, 0, strLen+1);
 	strncpy(_chassisPartNum, pTmpStr, strLen);
@@ -84,7 +89,7 @@ void getFruChassisInfo(Webs *wp)
 	//_chassisType
 	_chassisType = walloc(30);
 	memset(_chassisType, 0, 30);
-	switch(chassis_data.ChassisType)
+	switch(pChassis_data->ChassisType)
 	{
 	case Other:
 		strcpy(_chassisType, "Other");
@@ -152,7 +157,7 @@ void getFruChassisInfo(Webs *wp)
 	}		
 
 
-	char *pStr;
+	
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON_AddItemToObject(root, "data", data);
@@ -165,19 +170,15 @@ void getFruChassisInfo(Webs *wp)
     cJSON_AddStringToObject(data, "SN", _chassisSerialNum);
     cJSON_AddStringToObject(data, "OEM", _chassisCustomField);
 
+    char *pStr;
     pStr = cJSON_PrintUnformatted(root);
-    
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);	//Set length to -1 if unknown and transfer-chunk-encoding will be employed.
     websWriteEndHeaders(wp);
-    int ret;
     websWrite(wp, "%s", pStr); 
-    //printf("---> cJSON Str: %d \n%s\n", strlen(pStr), pStr);
-    ret = websFlush(wp, 1);	//wait for all data to be written to the socket 
-    if(ret != 1)
-    	printf("websFlush ret = %d\n", ret);
-    
+    websFlush(wp, 0);	//wait for all data to be written to the socket 
     websDone(wp);
+    printf("---> cJSON Str: %d \n%s\n", strlen(pStr), pStr);
 
     if(pStr)
         wfree(pStr);
@@ -188,8 +189,8 @@ void getFruChassisInfo(Webs *wp)
 	if(_chassisSerialNum) 		wfree(_chassisSerialNum);
 	if(_chassisType) 			wfree(_chassisType);
 	if(_chassisCustomField) 	wfree(_chassisCustomField);
+	if(pChassis_data)			wfree(pChassis_data);
 	
-	printf("getFruChassisInfo over!\n");
 }
 
 void getFruBoardInfo(Webs *wp)
@@ -201,7 +202,8 @@ void getFruBoardInfo(Webs *wp)
 	char *pTmpStr = NULL;
 	uint8_t strLen = 0;
 	time_t tval;
-	//char *mfrdate = NULL;
+	uint8_t target_addr;
+	
 	static const uint32_t  secs_from_1970_1996 = 820450800;
 
 	char *_boardMfr=NULL;
@@ -215,7 +217,18 @@ void getFruBoardInfo(Webs *wp)
 
 	//Create session
 	LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
-	wRet = LIBIPMI_HL_GetFRUBoardData(&UDSSession,fruIndex,&fru_size,&board_data,DEFAULT_TIMEOUT);
+
+	wp->index = TEST_INDEX;
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+		wRet = LIBIPMI_HL_GetFRUBoardData(&UDSSession,fruIndex,&fru_size,&board_data,DEFAULT_TIMEOUT);
+	}
+	else
+	{
+		wRet = IPMC_GetFRUBoardData(&UDSSession,target_addr, fruIndex,&fru_size,&board_data,DEFAULT_TIMEOUT);
+	}
+
 	if(wRet==FRU_INVALID_HEADER_VERSION)
 	{
 		printf("Invalid FRU Header Version for ID : %d\n", fruIndex);
@@ -281,7 +294,7 @@ void getFruBoardInfo(Webs *wp)
 	tval = tval + secs_from_1970_1996;
 	_MfrDate = asctime(localtime(&tval));
 
-	char *pStr;
+	
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON_AddItemToObject(root, "data", data);
@@ -296,19 +309,15 @@ void getFruBoardInfo(Webs *wp)
     cJSON_AddStringToObject(data, "PN", _boardPartNum);
     cJSON_AddStringToObject(data, "OEM", _boardCustomField);
 
+    char *pStr;
     pStr = cJSON_PrintUnformatted(root);
-    
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);	//Set length to -1 if unknown and transfer-chunk-encoding will be employed.
     websWriteEndHeaders(wp);
-    int ret;
-    websWrite(wp, "%s", pStr); 
-    //printf("---> cJSON Str: %d \n%s\n", strlen(pStr), pStr);
-    ret = websFlush(wp, 1);	//wait for all data to be written to the socket 
-    if(ret != 1)
-    	printf("websFlush ret = %d\n", ret);
-    
+    websWrite(wp, "%s", pStr);     
+    websFlush(wp, 0);	//wait for all data to be written to the socket 
     websDone(wp);
+    printf("---> cJSON Str: %d \n%s\n", strlen(pStr), pStr);
 
     if(pStr)
         wfree(pStr);
@@ -321,8 +330,6 @@ void getFruBoardInfo(Webs *wp)
 	if(_boardPartNum) 			wfree(_boardPartNum);
 	if(_boardCustomField) 		wfree(_boardCustomField);
 	if(_MfrDate) 				wfree(_MfrDate);
-	
-	printf("getFruChassisInfo over!\n");
 
 }
 
@@ -334,6 +341,7 @@ void getFruProductInfo(Webs *wp)
 	uint8_t fruIndex = 1;	//FRUDeviceID
 	char *pTmpStr = NULL;
 	uint8_t strLen = 0;
+	uint8_t target_addr;
 	
 	char *_ProductName=NULL;
 	char *_ProductPartNum=NULL;
@@ -345,7 +353,16 @@ void getFruProductInfo(Webs *wp)
 
 	//Create session
 	LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
-	wRet = LIBIPMI_HL_GetFRUProductData(&UDSSession,fruIndex,&fru_size,&product_data,DEFAULT_TIMEOUT);
+	wp->index = TEST_INDEX;
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+		wRet = LIBIPMI_HL_GetFRUProductData(&UDSSession,fruIndex,&fru_size,&product_data,DEFAULT_TIMEOUT);
+	}
+	else
+	{
+		wRet = IPMC_GetFRUProductData(&UDSSession,target_addr, fruIndex,&fru_size,&product_data,DEFAULT_TIMEOUT);	
+	}
 	if(wRet==FRU_INVALID_HEADER_VERSION)
 	{
 		printf("Invalid FRU Header Version for ID : %d\n", fruIndex);
@@ -404,17 +421,11 @@ void getFruProductInfo(Webs *wp)
 	pTmpStr += strLen;
 	strLen = pTmpStr[0] & 0x3F;
 	pTmpStr++;
-	// _AssetTag = walloc(strLen+1);
-	// memset(_AssetTag, 0, strLen+1);
-	// strncpy(_AssetTag, pTmpStr, strLen);
 
 	//File ID
 	pTmpStr += strLen;
 	strLen = pTmpStr[0] & 0x3F;
 	pTmpStr++;
-	// _FRUFileID = walloc(strLen+1);
-	// memset(_FRUFileID, 0, strLen+1);
-	// strncpy(_FRUFileID, pTmpStr, strLen);
 
 	//Extra info
 	pTmpStr += strLen;
@@ -424,7 +435,6 @@ void getFruProductInfo(Webs *wp)
 	memset(_productCustomField, 0, strLen+1);
 	strncpy(_productCustomField, pTmpStr, strLen);
 
-	char *pStr;
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON_AddItemToObject(root, "data", data);
@@ -436,19 +446,16 @@ void getFruProductInfo(Webs *wp)
     cJSON_AddStringToObject(data, "Ver", _ProductVersion);
     cJSON_AddStringToObject(data, "SN", _ProductSerialNum);
     cJSON_AddStringToObject(data, "OEM", _productCustomField);
+
+    char *pStr;
     pStr = cJSON_PrintUnformatted(root);
-    
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);	//Set length to -1 if unknown and transfer-chunk-encoding will be employed.
     websWriteEndHeaders(wp);
-    int ret;
     websWrite(wp, "%s", pStr); 
-    //printf("---> cJSON Str: %d \n%s\n", strlen(pStr), pStr);
-    ret = websFlush(wp, 1);	//wait for all data to be written to the socket 
-    if(ret != 1)
-    	printf("websFlush ret = %d\n", ret);
-    
+    websFlush(wp, 0);	
     websDone(wp);
+    printf("---> cJSON Str: %d \n%s\n", strlen(pStr), pStr);
 
     if(pStr)
         wfree(pStr);
@@ -461,354 +468,5 @@ void getFruProductInfo(Webs *wp)
 	if(_ProductVersion) 		wfree(_ProductVersion);
 	if(_ProductSerialNum) 		wfree(_ProductSerialNum);
 	if(_productCustomField) 	wfree(_productCustomField);
-	
-	printf("getFruChassisInfo over!\n");
-
 }
 
-
-// /*获取FRU信息*/
-// void getFruInfo(Webs *wp)
-// {
-// 	int wRet = 0;
-// 	uint32_t fru_size;
-// 	OemFRUData_T fru_data;
-// 	uint8_t fruIndex = 1;	//FRUDeviceID
-// 	char *pTmpStr = NULL;
-// 	uint8_t strLen = 0;
-
-// 	time_t tval;
-// 	//char *mfrdate = NULL;
-// 	static const uint32_t  secs_from_1970_1996 = 820450800;
-
-// 	char *_chassisPartNum=NULL;
-// 	char *_chassisSerialNum=NULL;
-// 	char *_chassisType=NULL;
-// 	char *_chassisCustomField=NULL;
-// 	char *_boardMfr=NULL;
-// 	char *_boardProductName=NULL;
-// 	char *_boardSerialNum=NULL;
-// 	char *_boardPartNum=NULL;
-// 	char *_boardCustomField=NULL;
-// 	char *_MfrName=NULL;
-// 	char *_MfrDate = NULL;
-// 	char *_ProductName=NULL;
-// 	char *_ProductPartNum=NULL;
-// 	char *_ProductVersion=NULL;
-// 	char *_ProductSerialNum=NULL;
-// 	char *_productCustomField=NULL;
-// 	IPMI20_UDS_SESSION_T    UDSSession;
-
-// 	//Create session
-// 	LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
-// 	wRet = LIBIPMI_HL_GetFRUData(&UDSSession,fruIndex,&fru_size,&fru_data,DEFAULT_TIMEOUT);
-// 	if(wRet==FRU_INVALID_HEADER_VERSION)
-// 	{
-// 		printf("Invalid FRU Header Version for ID : %d\n", fruIndex);
-// 	}
-// 	if(wRet==FRU_INVALID_AREA)
-// 	{
-// 		printf("FRU Invalid Area for ID : %d\n", fruIndex);
-// 	}
-// 	if(wRet!=0)
-// 	{
-// 		printf("Device not present for ID : %d\n", fruIndex);
-// 	}
-//     //Close session
-//     LIBIPMI_CloseSession(&UDSSession );
-
-// 	//Get ChassisInfo
-// 	if(fru_data.CommonHeader.ChassisInfoAreaStartOffset != 0)
-// 	{
-// 		//_chassisPartNum
-// 		strLen = fru_data.ChassisInfo.Data[0] & 0x3F;
-// 		pTmpStr = &fru_data.ChassisInfo.Data[1];
-// 		_chassisPartNum = walloc(strLen+1);
-// 		memset(_chassisPartNum, 0, strLen+1);
-// 		strncpy(_chassisPartNum, pTmpStr, strLen);
-		
-// 		//_chassisSerialNum
-// 		pTmpStr += strLen;
-// 		strLen = pTmpStr[0] & 0x3F;
-// 		pTmpStr++;
-// 		_chassisSerialNum = walloc(strLen+1);
-// 		memset(_chassisSerialNum, 0, strLen+1);
-// 		strncpy(_chassisSerialNum, pTmpStr, strLen);
-		
-// 		//extra info
-// 		pTmpStr += strLen;
-// 		strLen = pTmpStr[0] & 0x3F;
-// 		pTmpStr++;
-// 		_chassisCustomField = walloc(strLen+1);
-// 		memset(_chassisCustomField, 0, strLen+1);
-// 		strncpy(_chassisCustomField, pTmpStr, strLen);
-
-// 		//_chassisType
-// 		_chassisType = walloc(30);
-// 		memset(_chassisType, 0, 30);
-// 		switch(fru_data.ChassisInfo.ChassisType)
-// 		{
-// 		case Other:
-// 			strcpy(_chassisType, "Other");
-// 			break;
-//     	case ChassisUnknown:
-// 			strcpy(_chassisType, "ChassisUnknown");
-// 			break;
-//     	case Desktop:
-// 			strcpy(_chassisType, "Desktop");
-// 			break;
-//     	case LowProfileDesktop:
-// 			strcpy(_chassisType, "LowProfileDesktop");
-// 			break;
-//     	case MiniTower:
-// 			strcpy(_chassisType, "MiniTower");
-// 			break;
-//     	case Tower:
-// 			strcpy(_chassisType, "Tower");
-// 			break;
-//     	case Portable:
-// 			strcpy(_chassisType, "Portable");
-// 			break;
-//     	case Notebook:
-// 			strcpy(_chassisType, "Notebook");
-// 			break;
-//     	case HandHeld:
-// 			strcpy(_chassisType, "HandHeld");
-// 			break;
-//     	case DockingStation:
-// 			strcpy(_chassisType, "DockingStation");
-// 			break;
-//     	case AllinOne:
-// 			strcpy(_chassisType, "AllinOne");
-// 			break;
-//     	case SubNotebook:
-// 			strcpy(_chassisType, "SubNotebook");
-// 			break;
-//     	case SpaceSaving:
-// 			strcpy(_chassisType, "SpaceSaving");
-// 			break;
-//     	case LunchBox:
-// 			strcpy(_chassisType, "LunchBox");
-// 			break;
-//     	case MainServerChassis:
-// 			strcpy(_chassisType, "MainServerChassis");
-// 			break;
-//     	case SubChassis:
-// 			strcpy(_chassisType, "SubChassis");
-// 			break;
-//     	case BusExpansionChassis:
-// 			strcpy(_chassisType, "BusExpansionChassis");
-// 			break;
-//     	case PeripheralChassis:
-// 			strcpy(_chassisType, "PeripheralChassis");
-// 			break;
-//     	case RAIDChassis:
-// 			strcpy(_chassisType, "RAIDChassis");
-// 			break;
-//     	case RackMountChassis:
-// 			strcpy(_chassisType, "RackMountChassis");
-// 			break;
-// 		default:
-// 			strcpy(_chassisType, "Unknown");
-// 			break;
-// 		}		
-// 	}
-	
-// 	//Get BoardInfo
-// 	if(fru_data.CommonHeader.BoardInfoAreaStartOffset != 0)
-// 	{
-// 		//Manufactor
-// 		strLen = fru_data.BoardInfo.Data[0] & 0x3F;
-// 		pTmpStr = &fru_data.BoardInfo.Data[1];
-// 		_boardMfr = walloc(strLen+1);
-// 		memset(_boardMfr, 0, strLen+1);
-// 		strncpy(_boardMfr, pTmpStr, strLen);
-
-// 		//Product name
-// 		pTmpStr += strLen;
-// 		strLen = pTmpStr[0] & 0x3F;
-// 		pTmpStr++;
-// 		_boardProductName = walloc(strLen+1);
-// 		memset(_boardProductName, 0, strLen+1);
-// 		strncpy(_boardProductName, pTmpStr, strLen);
-
-// 		//Serial number
-// 		pTmpStr += strLen;
-// 		strLen = pTmpStr[0] & 0x3F;
-// 		pTmpStr++;
-// 		_boardSerialNum = walloc(strLen+1);
-// 		memset(_boardSerialNum, 0, strLen+1);
-// 		strncpy(_boardSerialNum, pTmpStr, strLen);
-
-// 		//Part number
-// 		pTmpStr += strLen;
-// 		strLen = pTmpStr[0] & 0x3F;
-// 		pTmpStr++;
-// 		_boardPartNum = walloc(strLen+1);
-// 		memset(_boardPartNum, 0, strLen+1);
-// 		strncpy(_boardPartNum, pTmpStr, strLen);
-
-// 		//FILE ID
-// 		pTmpStr += strLen;
-// 		strLen = pTmpStr[0] & 0x3F;
-// 		pTmpStr++;
-
-// 		//Extra Info
-// 		pTmpStr += strLen;
-// 		strLen = pTmpStr[0] & 0x3F;
-// 		pTmpStr++;
-// 		_boardCustomField = walloc(strLen+1);
-// 		memset(_boardCustomField, 0, strLen+1);
-// 		strncpy(_boardCustomField, pTmpStr, strLen);
-
-// 		//Date
-// 		tval = ((fru_data.BoardInfo.MfgDateTime[2] << 16) + (fru_data.BoardInfo.MfgDateTime[1] << 8) + (fru_data.BoardInfo.MfgDateTime[0]));
-// 		tval = tval * 60;
-// 		tval = tval + secs_from_1970_1996;
-// 		_MfrDate = asctime(localtime(&tval));
-// 	}
-
-// 	//Get Product Info
-// 	if(fru_data.CommonHeader.ProductInfoAreaStartOffset != 0)
-// 	{
-// 		//Manufactor
-// 		strLen = fru_data.ProductInfo.Data[0] & 0x3F;
-// 		pTmpStr = &fru_data.ProductInfo.Data[1];
-// 		_MfrName = walloc(strLen+1);
-// 		memset(_MfrName, 0, strLen+1);
-// 		strncpy(_MfrName, pTmpStr, strLen);
-
-// 		//Product Name
-// 		pTmpStr += strLen;
-// 		strLen = pTmpStr[0] & 0x3F;
-// 		pTmpStr++;
-// 		_ProductName = walloc(strLen+1);
-// 		memset(_ProductName, 0, strLen+1);
-// 		strncpy(_ProductName, pTmpStr, strLen);
-
-// 		//Part Number
-// 		pTmpStr += strLen;
-// 		strLen = pTmpStr[0] & 0x3F;
-// 		pTmpStr++;
-// 		_ProductPartNum = walloc(strLen+1);
-// 		memset(_ProductPartNum, 0, strLen+1);
-// 		strncpy(_ProductPartNum, pTmpStr, strLen);
-
-// 		//Version
-// 		pTmpStr += strLen;
-// 		strLen = pTmpStr[0] & 0x3F;
-// 		pTmpStr++;
-// 		_ProductVersion = walloc(strLen+1);
-// 		memset(_ProductVersion, 0, strLen+1);
-// 		strncpy(_ProductVersion, pTmpStr, strLen);
-
-// 		//Serial Number
-// 		pTmpStr += strLen;
-// 		strLen = pTmpStr[0] & 0x3F;
-// 		pTmpStr++;
-// 		_ProductSerialNum = walloc(strLen+1);
-// 		memset(_ProductSerialNum, 0, strLen+1);
-// 		strncpy(_ProductSerialNum, pTmpStr, strLen);
-
-// 		//Assert Tag
-// 		pTmpStr += strLen;
-// 		strLen = pTmpStr[0] & 0x3F;
-// 		pTmpStr++;
-// 		// _AssetTag = walloc(strLen+1);
-// 		// memset(_AssetTag, 0, strLen+1);
-// 		// strncpy(_AssetTag, pTmpStr, strLen);
-
-// 		//File ID
-// 		pTmpStr += strLen;
-// 		strLen = pTmpStr[0] & 0x3F;
-// 		pTmpStr++;
-// 		// _FRUFileID = walloc(strLen+1);
-// 		// memset(_FRUFileID, 0, strLen+1);
-// 		// strncpy(_FRUFileID, pTmpStr, strLen);
-
-// 		//Extra info
-// 		pTmpStr += strLen;
-// 		strLen = pTmpStr[0] & 0x3F;
-// 		pTmpStr++;
-// 		_productCustomField = walloc(strLen+1);
-// 		memset(_productCustomField, 0, strLen+1);
-// 		strncpy(_productCustomField, pTmpStr, strLen);
-// 	}
-
-// 	char *pStr1, *pStr2, *pStr3;
-//     cJSON * chassis =  cJSON_CreateObject();
-//     cJSON * board =  cJSON_CreateObject();
-//     cJSON * product =  cJSON_CreateObject();
-//     //chassis
-//     cJSON_AddStringToObject(chassis, "Type", _chassisType);
-//     cJSON_AddStringToObject(chassis, "PN", _chassisPartNum);
-//     cJSON_AddStringToObject(chassis, "SN", _chassisSerialNum);
-//     cJSON_AddStringToObject(chassis, "OEM", _chassisCustomField);
-
-//     //board
-//     cJSON_AddStringToObject(board, "Date", _MfrDate);
-//     cJSON_AddStringToObject(board, "Mfr", _boardMfr);
-//     cJSON_AddStringToObject(board, "Name", _boardProductName);
-//     cJSON_AddStringToObject(board, "SN", _boardSerialNum);
-//     cJSON_AddStringToObject(board, "PN", _boardPartNum);
-//     cJSON_AddStringToObject(board, "OEM", _boardCustomField);
-
-//     //product
-//     cJSON_AddStringToObject(product, "Mfr", _MfrName);
-//     cJSON_AddStringToObject(product, "Name", _ProductName);
-//     cJSON_AddStringToObject(product, "PN", _ProductPartNum);
-//     cJSON_AddStringToObject(product, "Ver", _ProductVersion);
-//     cJSON_AddStringToObject(product, "SN", _ProductSerialNum);
-//     cJSON_AddStringToObject(product, "OEM", _productCustomField);
-
-//     pStr1 = cJSON_PrintUnformatted(chassis);
-//     pStr2 = cJSON_PrintUnformatted(board);
-//     pStr3 = cJSON_PrintUnformatted(product);
-    
-//     websSetStatus(wp, 200);
-//     websWriteHeaders(wp, -1, 0);	//Set length to -1 if unknown and transfer-chunk-encoding will be employed.
-//     websWriteEndHeaders(wp);
-//     int ret;
-//     //websWrite(wp, "{\n");
-//     websWrite(wp, "%s", pStr1); printf("---> cJSON Str1: %d \n%s\n", strlen(pStr1), pStr1);
-//     //websWrite(wp, "%s", pStr2); printf("---> cJSON Str2: %d \n%s\n", strlen(pStr2), pStr2);
-//     //websWrite(wp, "%s", pStr3); printf("---> cJSON Str3: %d \n%s\n", strlen(pStr3), pStr3);
-//     //websWrite(wp, "msg:\"\",\ncode:200\n}");
-    
-//     ret = websFlush(wp, 1);	//wait for all data to be written to the socket 
-//     //if(ret != 1)
-//     	printf("websFlush ret = %d\n", ret);
-    
-//     websDone(wp);
-
-//     if(pStr1)
-//         wfree(pStr1);
-//     if(pStr2)
-//         wfree(pStr2);
-//     if(pStr3)
-//         wfree(pStr3);
-//     if(chassis)
-//         cJSON_Delete(chassis);
-//     if(board)
-//         cJSON_Delete(board);
-//     if(product)
-//         cJSON_Delete(product);
-
-//     if(_chassisPartNum) 		wfree(_chassisPartNum);
-// 	if(_chassisSerialNum) 		wfree(_chassisSerialNum);
-// 	if(_chassisType) 			wfree(_chassisType);
-// 	if(_chassisCustomField) 	wfree(_chassisCustomField);
-// 	if(_boardMfr) 				wfree(_boardMfr);
-// 	if(_boardProductName) 		wfree(_boardProductName);
-// 	if(_boardSerialNum) 		wfree(_boardSerialNum);
-// 	if(_boardPartNum) 			wfree(_boardPartNum);
-// 	if(_boardCustomField) 		wfree(_boardCustomField);
-// 	if(_MfrName) 				wfree(_MfrName);
-// 	if(_MfrDate) 				wfree(_MfrDate);
-// 	if(_ProductName) 			wfree(_ProductName);
-// 	if(_ProductPartNum) 		wfree(_ProductPartNum);
-// 	if(_ProductVersion) 		wfree(_ProductVersion);
-// 	if(_ProductSerialNum) 		wfree(_ProductSerialNum);
-// 	if(_productCustomField) 	wfree(_productCustomField);
-// 	printf("getFruInfo over!\n");
-// }

+ 177 - 73
app/goahead-3.6.5/src/web_interface/src/sel.c

@@ -34,13 +34,9 @@ void Web_ClearSEL(Webs *wp)
         wRet = IPMC_ClearSEL( &UDSSession, target_addr, DEFAULT_TIMEOUT);
     }
 
-    if(wRet != 0)
-        printf("Error trying to clear SEL!! %x\n", wRet);
     //Close session
     LIBIPMI_CloseSession(&UDSSession );
 
-
-    char *pStr;
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON_AddItemToObject(root, "data", data);//根节点下添加
@@ -52,15 +48,16 @@ void Web_ClearSEL(Webs *wp)
     else
         cJSON_AddStringToObject(data, "status", "success");
 
+    char *pStr;
     pStr = cJSON_PrintUnformatted(root);
 
-//    printf("---> cJSON Str:\n%s\n", pStr);
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp);
     websWrite(wp, "%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
+    printf("---> cJSON Str:\n%s\n", pStr);
 
     if(pStr)
         wfree(pStr);
@@ -68,22 +65,41 @@ void Web_ClearSEL(Webs *wp)
         cJSON_Delete(root);
 }
 
+typedef struct {
+    uint8_t sensor_number;
+    uint8_t sensor_name[MAX_ID_STR_LEN+1];
+} SensorNumNameTab_T;
+
 void GetAllSELEntriesSorted(Webs *wp)
 {
     int wRet = 0;
     unsigned short nEntries = 0;
     SELEventRecordWithSensorName_T *pSELBuff = NULL;
-    //uint8 *pStartBuff = NULL;
-    uint16 nMaxEntries = 0;
+    int i;
     IPMI20_UDS_SESSION_T    UDSSession;
-    uint8_t target_addr;
+    uint8_t         target_addr;
+    SensorNumNameTab_T senNumNameTab[MAX_SENSOR_NUMBERS];   //之前获取到的传感器名称暂存在这里,避免反复获取,浪费总线带宽。
+    GetSELReq_T     GetSelReq;
+    uint16_t        ReserveID;
+    ReserveSELRes_T ReserveSelRes;
+    uint16_t        RecID = 0;
+    uint8_t         Res[50];
+    SELEventRecord_T   SELEventData;
+    uint8_t         sensorName[MAX_ID_STR_LEN+1];
+    int             found_flag = 0;
     
-
-    char *pStr;
     int code = 200;
     cJSON * root =  cJSON_CreateObject();
     cJSON  *pJsonArry,*pJsonsub;
     pJsonArry=cJSON_CreateArray();   /*创建数组*/
+    cJSON_AddItemToArray(pJsonArry,pJsonsub=cJSON_CreateObject()); /* 给创建的数组增加对对象*/
+
+    //初始化传感器序号和名称对应表
+    for(i=0;i<MAX_SENSOR_NUMBERS;i++)
+    {
+        senNumNameTab[i].sensor_number = 0xff;
+        senNumNameTab[i].sensor_name[0] = '\0';
+    }
 
     //Create session
     LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
@@ -107,81 +123,153 @@ void GetAllSELEntriesSorted(Webs *wp)
     }
     else
     {
-        printf("success getting num of sel recods: %d\n",nEntries);
-        /* Now get all sel records */
-        //now find maximum possible sel entries and allocate that much
-        if(target_addr == 0x20)
+        //printf("---> nEntries %d\n", nEntries);
+        if(nEntries > MAX_SEL_RECORD)   nEntries = MAX_SEL_RECORD;  //最大只能显示这么多日志
+        if(nEntries == 0)
         {
-              wRet = LIBIPMI_HL_GetMaxPossibleSELEntries(&UDSSession,&nMaxEntries,DEFAULT_TIMEOUT);
+            cJSON_AddItemToObject(root, "data", pJsonArry);
+
+            char *pStr;
+            pStr = cJSON_PrintUnformatted(root);
+            websSetStatus(wp, 200);
+            websWriteHeaders(wp, -1, 0);
+            websWriteEndHeaders(wp); 
+            websWrite(wp, pStr);
+            websFlush(wp, 0);
+            websDone(wp);
+            printf("---> pStr %d: %s\n", strlen(pStr), pStr);
+            
+            if(root)
+                cJSON_Delete(root);
+            if(pStr)
+                wfree(pStr);
+
+            return;
         }
-        else
+
+        /* Allocate the buffer to hold SEL entries */
+        pSELBuff = (SELEventRecordWithSensorName_T *) walloc(nEntries * sizeof(SELEventRecordWithSensorName_T) + 10);   //margin 10
+        if(pSELBuff == NULL)
         {
-            wRet = IPMC_GetMaxPossibleSELEntries(&UDSSession, target_addr, &nMaxEntries,DEFAULT_TIMEOUT);
+            goto error_out;
         }
 
-        if(wRet != 0)
+        //Reserve SEL
+        if(target_addr == 0x20)
         {
-            printf("Error getting maximum no of entries..assuming 1024\n");
-            nMaxEntries = 1024;
+            wRet = IPMICMD_ReserveSEL(&UDSSession, &ReserveSelRes, DEFAULT_TIMEOUT);
         }
         else
         {
-            printf("MAX Possible SEL entries : %d\n",nMaxEntries);
+            wRet = IPMC_ReserveSEL(&UDSSession, target_addr, &ReserveSelRes, DEFAULT_TIMEOUT);
         }
 
-        /* Allocate the buffer to hold SEL entries */
-        pSELBuff = (SELEventRecordWithSensorName_T *) walloc(nMaxEntries * sizeof(SELEventRecordWithSensorName_T));
-        if(pSELBuff == NULL)
-        {
-            goto error_out;
-        }
-        //pStartBuff = (uint8 *)pSELBuff;
-
-        printf("before get all sel entried\n");
-        /* Now pass this buffer pointer to the function to get all SEL entries */
-        wRet = Storlead_GetAllSelEntriesWithSensorNames(&UDSSession, target_addr, pSELBuff, DEFAULT_TIMEOUT);
         if(wRet == 0)
         {
-            /* Write entries here */
-            while(nEntries)
+            ReserveID = ReserveSelRes.ReservationID;
+            RecID = 0;  //first record
+            for(i=0;i<nEntries;i++)
             {
-                if(pSELBuff[nEntries-1].EventRecord.Valid != 0xA5)
+                //获取日志
+                GetSelReq.ReservationID = ReserveID;
+                GetSelReq.RecID = RecID;
+                GetSelReq.Offset = 0;
+                GetSelReq.Size = 0xff;  //FFh means read entire record.
+                if(target_addr == 0x20)
                 {
-                    cJSON_AddItemToArray(pJsonArry,pJsonsub=cJSON_CreateObject()); /* 给创建的数组增加对对象*/
-                    cJSON_AddNumberToObject(pJsonsub, "RecordID", pSELBuff[nEntries-1].EventRecord.EvtRecord.hdr.ID);
-                    cJSON_AddNumberToObject(pJsonsub, "RecordType", pSELBuff[nEntries-1].EventRecord.EvtRecord.hdr.Type);
-                    cJSON_AddNumberToObject(pJsonsub, "TimeStamp", pSELBuff[nEntries-1].EventRecord.EvtRecord.hdr.TimeStamp);
-                    cJSON_AddNumberToObject(pJsonsub, "GenID1", pSELBuff[nEntries-1].EventRecord.EvtRecord.GenID[0]);
-                    cJSON_AddNumberToObject(pJsonsub, "GenID2", pSELBuff[nEntries-1].EventRecord.EvtRecord.GenID[1]);
-                    cJSON_AddNumberToObject(pJsonsub, "EvmRev", pSELBuff[nEntries-1].EventRecord.EvtRecord.EvMRev);
-                    cJSON_AddNumberToObject(pJsonsub, "SensorType", pSELBuff[nEntries-1].EventRecord.EvtRecord.SensorType);
-                    cJSON_AddStringToObject(pJsonsub, "SensorName", pSELBuff[nEntries-1].SensorName);
-                    cJSON_AddNumberToObject(pJsonsub, "EventDirType", pSELBuff[nEntries-1].EventRecord.EvtRecord.EvtDirType);
-                    cJSON_AddNumberToObject(pJsonsub, "EventData1", pSELBuff[nEntries-1].EventRecord.EvtRecord.EvtData1);
-                    cJSON_AddNumberToObject(pJsonsub, "EventData2", pSELBuff[nEntries-1].EventRecord.EvtRecord.EvtData2);
-                    cJSON_AddNumberToObject(pJsonsub, "EventData3", pSELBuff[nEntries-1].EventRecord.EvtRecord.EvtData3);                           
+                    wRet = IPMI_GetSELEntry(&UDSSession, &GetSelReq,  &SELEventData, &RecID, DEFAULT_TIMEOUT);
+                }
+                else
+                {
+                    wRet = IPMC_GetSELEntry(&UDSSession, target_addr, &GetSelReq,  &SELEventData, &RecID, DEFAULT_TIMEOUT);
+                }
+                if((wRet != 0))
+                {
+                    break;
+                }
+                cJSON_AddNumberToObject(pJsonsub, "1", SELEventData.hdr.ID);
+                cJSON_AddNumberToObject(pJsonsub, "2", SELEventData.hdr.Type);
+                cJSON_AddNumberToObject(pJsonsub, "3", SELEventData.hdr.TimeStamp);
+                cJSON_AddNumberToObject(pJsonsub, "4", SELEventData.GenID[0]);
+                cJSON_AddNumberToObject(pJsonsub, "5", SELEventData.GenID[1]);
+                cJSON_AddNumberToObject(pJsonsub, "6", SELEventData.EvMRev);
+                cJSON_AddNumberToObject(pJsonsub, "7", SELEventData.SensorType);
+                cJSON_AddNumberToObject(pJsonsub, "8", SELEventData.EvtDirType);
+                cJSON_AddNumberToObject(pJsonsub, "9", SELEventData.EvtData1);
+                cJSON_AddNumberToObject(pJsonsub, "a", SELEventData.EvtData2);
+                cJSON_AddNumberToObject(pJsonsub, "b", SELEventData.EvtData3);
+                //获取传感器名称
+                //printf("sensor number %d\n", SELEventData.SensorNum);
+                if((SELEventData.SensorNum != 0xff) && (SELEventData.hdr.Type == 0x02))
+                {
+                    found_flag = 0;
+                    for(i=0;i<MAX_SENSOR_NUMBERS;i++)   //先从之前的缓存里查找传感器名称
+                    {
+                        if(senNumNameTab[i].sensor_number == 0xff)  //再往后没有内容了。
+                            break;
+
+                        if(senNumNameTab[i].sensor_number == SELEventData.SensorNum)
+                        {
+                            //printf("---> get sensor name from cache: %s\n", senNumNameTab[i].sensor_name);
+                            cJSON_AddStringToObject(pJsonsub, "c", senNumNameTab[i].sensor_name);
+                            found_flag = 1;
+                            break;
+                        }
+                    }
+
+                    if(found_flag == 0) //在缓存里没有找到
+                    {
+                        if(target_addr == 0x20)
+                        {
+                            wRet = IPMI_GetSensorName(&UDSSession, SELEventData.SensorNum, sensorName, DEFAULT_TIMEOUT);
+                            //printf("---> get sensor name: %s\n", sensorName);
+                        }
+                        else
+                        {
+                            wRet = IPMC_GetSensorName(&UDSSession, target_addr,SELEventData.SensorNum, sensorName, DEFAULT_TIMEOUT);
+                        }
+                        cJSON_AddStringToObject(pJsonsub, "c", sensorName);
+                        if(wRet == 0)
+                        {
+                            //将得到的传感器名称保存到缓存中
+                            for(i=0;i<MAX_SENSOR_NUMBERS;i++)
+                            {
+                                if(senNumNameTab[i].sensor_number == 0xff)
+                                {
+                                    //printf("---> keep sensor name\n");
+                                    senNumNameTab[i].sensor_number = SELEventData.SensorNum;
+                                    strcpy(senNumNameTab[i].sensor_name, sensorName);                                
+                                    break;
+                                }
+                            }
+                        }    
+                    }                
+                }
+                else
+                {
+                    cJSON_AddStringToObject(pJsonsub, "SensorName", "--");
                 }
-                nEntries--;
-            }
-
-            cJSON_AddItemToObject(root, "data", pJsonArry);
-            pStr = cJSON_PrintUnformatted(root);
-            //printf("---> pStr %d: %s\n", strlen(pStr), pStr);
-
-            websSetStatus(wp, 200);
-            websWriteHeaders(wp, -1, 0);
-            websWriteEndHeaders(wp); 
-            websWrite(wp, pStr);
-            websDone(wp);
 
-            
-        } else {
-            printf("Error reading All SEL entries\n");
-        }       
+                if(RecID == 0xffff) //last record
+                    break;
+            }
+        }
     }
 
     //Close session
     LIBIPMI_CloseSession(&UDSSession );
+
+    cJSON_AddItemToObject(root, "data", pJsonArry);
+
+    char *pStr;
+    pStr = cJSON_PrintUnformatted(root);
+    websSetStatus(wp, 200);
+    websWriteHeaders(wp, -1, 0);
+    websWriteEndHeaders(wp); 
+    websWrite(wp, pStr);
+    websFlush(wp, 0);
+    websDone(wp);
+    printf("---> pStr %d: %s\n", strlen(pStr), pStr);
     
     if(root)
         cJSON_Delete(root);
@@ -234,7 +322,7 @@ void SetTime(Webs *wp)
     }
     else
     {
-
+        wRet = IPMC_SetSELTime(&UDSSession, target_addr, &SetSELTimeReq, DEFAULT_TIMEOUT);
     }
     if(wRet != 0)
     {
@@ -243,15 +331,14 @@ void SetTime(Webs *wp)
         LIBIPMI_CloseSession(&UDSSession );
         return;
     }
-    wp->index = TEST_INDEX;
-    target_addr = gIPMBAddr[wp->index];
+
     if(target_addr == 0x20)
     {
         wRet = IPMICMD_SetSELTimeUTCOffset(&UDSSession, &SetSELTimeUTCOffsetReq, DEFAULT_TIMEOUT);
     }
     else
     {
-        
+        wRet = IPMC_SetSELTimeUTCOffset(&UDSSession, target_addr, &SetSELTimeUTCOffsetReq, DEFAULT_TIMEOUT);
     }
     if(wRet != 0)
     {
@@ -295,10 +382,21 @@ void GetTime(Webs *wp)
     IPMI20_UDS_SESSION_T    UDSSession;
     GetSELTimeRes_T GetSELTimeRes;
     GetSELTimeUTCOffsetRes_T GetSELTimeUTCOffsetRes;
+    uint8_t target_addr;
   
     //Create session
     LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
-    wRet = IPMICMD_GetSELTime(&UDSSession, &GetSELTimeRes, DEFAULT_TIMEOUT);
+
+    wp->index = TEST_INDEX;
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+        wRet = IPMICMD_GetSELTime(&UDSSession, &GetSELTimeRes, DEFAULT_TIMEOUT);
+    }
+    else
+    {
+        wRet = IPMC_GetSELTime(&UDSSession, target_addr, &GetSELTimeRes, DEFAULT_TIMEOUT);
+    }
     if(wRet != 0)
     {
         websError(wp, 404, "Get sel time fail!");
@@ -306,7 +404,14 @@ void GetTime(Webs *wp)
         LIBIPMI_CloseSession(&UDSSession );
         return;
     }
-    wRet = IPMICMD_GetSELTimeUTCOffset(&UDSSession, &GetSELTimeUTCOffsetRes, DEFAULT_TIMEOUT);
+    if(target_addr == 0x20)
+    {
+        wRet = IPMICMD_GetSELTimeUTCOffset(&UDSSession, &GetSELTimeUTCOffsetRes, DEFAULT_TIMEOUT);
+    }
+    else
+    {
+        wRet = IPMC_GetSELTimeUTCOffset(&UDSSession, target_addr, &GetSELTimeUTCOffsetRes, DEFAULT_TIMEOUT);
+    }
     if(wRet != 0)
     {
         websError(wp, 404, "Get time UTC offset fail!");
@@ -317,7 +422,7 @@ void GetTime(Webs *wp)
     //Close session
     LIBIPMI_CloseSession(&UDSSession );
     
-    char *pStr;
+    
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON_AddItemToObject(root, "data", data);//根节点下添加
@@ -327,9 +432,8 @@ void GetTime(Webs *wp)
     cJSON_AddNumberToObject(data, "time", GetSELTimeRes.Time);  //据1970年的秒数,UTC时间
     cJSON_AddNumberToObject(data, "UTCOffset", GetSELTimeUTCOffsetRes.UTCOffset);   //时区
 
-  
+    char *pStr;
     pStr = cJSON_PrintUnformatted(root);
-
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp); 

BIN
app/i2c_scan/i2c-scan


BIN
app/ipmitool-1.8.18/ipmitool


BIN
app/test_app/test_app


Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff