Răsfoiți Sursa

getSysInfo jimbo ok

zhangbo 5 ani în urmă
părinte
comite
993082f868

+ 1 - 0
.gitignore

@@ -6,3 +6,4 @@ app/goahead-5.1.0/build/
 #ignore switch file
 *~
 *.swp
+gd32450i-eval.uImage

BIN
app/bmc/bmc_app


+ 66 - 10
app/bmc/msghndlr/OemSMMCmds/OemSMMCmds.c

@@ -879,25 +879,81 @@ int SMMExample_7fh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
 }
 
 /********************** storlead oem command ********************************/
-//get MAC
+//get CPU info
 int SMMExample_80h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
 {
-	pRes[0] = CC_NORMAL;
-	getip(&pRes[1]);
-	printf("ip: %s\n", &pRes[1]);
-	return 16;
+	
+	char Title[] = "CPU info";
+	char Text[] = "CPU:Intel;Freq:1 GHZ;Memory:8 GB;Brief:This section test long string. Very very long string. long enough? not long";
+	int len = 0,remainLen = 0;
+	uint16_t offset = (pReq[1]<<8) | pReq[2];
+	int totalLen = 0;
+	char *pStr = NULL;
+	int reqLen = (pReq[3]<<8) | pReq[4];
+	
+	switch(pReq[0])
+	{
+	case 0:	//get Title
+		while(Title[totalLen])
+		{
+			totalLen++;
+		}printf("title total len = %#x\n",totalLen);
+		pStr = Title;
+		break;
+	case 1:
+		while(Text[totalLen])
+		{
+			totalLen++;
+		}
+		printf("text total len = %#x\n", totalLen);
+		pStr = Text;
+		break;
+	default:
+		*pRes = CC_PARAM_OUT_OF_RANGE;
+		return 1;
+	}
+	
+	*pRes= CC_NORMAL;
+
+	if(offset > totalLen)
+	{
+		printf("Invalid offset: %#x\n", offset);
+		*pRes= CC_PARAM_OUT_OF_RANGE;
+		return 1;
+	}
+	
+	if(reqLen == 0)	
+	{
+		len = totalLen - offset;
+	}
+	else
+	{
+		len = (reqLen > (totalLen-offset)) ? (totalLen-offset) : reqLen;
+	}
+	
+	remainLen = totalLen - offset - len;
+	*(pRes+1) = (len>>8)&0xff;
+	*(pRes+2) = len&0xff;
+	*(pRes+3) = (remainLen>>8)&0xff;
+	*(pRes+4) = remainLen&0xff;
+	memcpy(pRes+5, pStr+offset, len);
+
+	// int i;
+	// printf("Example 80h: ");
+	// for(i=0;i<5+len;i++)
+	// 	printf("%#x ", pRes[i]);
+	// printf("\n");
+
+	return 5+len;	
 } 
 
-//get IP
+//
 int SMMExample_81h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
 {
-	pRes[0] = CC_NORMAL;
-	getmac(&pRes[1]);
-	printf("mac: %s\n", &pRes[1]);
 	return 18;
 } 
 
-//GetIPMCCapability
+//
 int SMMExample_82h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
 {	
 	return 1;

+ 4 - 3
app/common_include/com_IPMIDefs.h

@@ -212,9 +212,10 @@
 /* (0x6 << 2) == 0x18 */
 #define DEFAULT_NET_FN_LUN					0x18
 #define NETFNLUN_IPMI_APP					0x18
-#define NETFNLUN_IPMI_SENSOR					0x10
-#define NETFNLUN_IPMI_STORAGE					0x28
-#define NETFNLUN_IPMI_CHASSIS                   0x00
+#define NETFNLUN_IPMI_SENSOR				0x10
+#define NETFNLUN_IPMI_STORAGE				0x28
+#define NETFNLUN_IPMI_CHASSIS               0x00
+#define NETFNLUN_IPMI_OEM					0xB8
 
 
 

+ 1 - 1
app/goahead-5.1.0/src/goahead.c

@@ -171,7 +171,7 @@ MAIN(goahead, int argc, char **argv, char **envp)
 //add by lusa start 
         websDefineAction("buy", buy);
 
-        websDefineAction("getCPUInfo", getCPUInfo);
+        websDefineAction("getCPUInfo", getSysInfo);
          websDefineAction("getCardInfo", getCardInfo);
          websDefineAction("actionTest", actionTest);
         websDefineAction("deviceinfo", getDeviceInfo);

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

@@ -33,7 +33,7 @@ typedef struct{
 typedef struct{
 	char *title;
 	char *text;
-}ExtraInfo_T;
+}SysInfo_T;
 
 
 typedef struct{
@@ -108,7 +108,7 @@ extern OemWebFlags_T g_OemWebFlags;
 
 uint16_t LIBIPMI_HL_FanCtrol( IPMI20_SESSION_T *pSession, uint8_t fanIndex, uint8_t fanMode, uint8_t fanLevel, int timeout);
 int LIBIPMI_HL_GetFanStatus( IPMI20_SESSION_T *pSession, uint8_t fanIndex, OemFanStatus_T *pFanStatus, int timeout);
-uint16_t LIBIPMI_HL_GetExtraInfo( IPMI20_SESSION_T *pSession, ExtraInfo_T *extraInfo, int timeout);
+uint16_t LIBIPMI_HL_GetSysInfo( IPMI20_SESSION_T *pSession, SysInfo_T *pSysInfo, int timeout);
 uint16_t LIBIPMI_HL_GetSensorHistory( IPMI20_SESSION_T *pSession, sensor_history_st *pSensorHistory_st, int card_index, int sensor_number, int IPMB_ADDR);
 uint16_t LIBIPMI_HL_GetAllCards(IPMI20_SESSION_T *pSession, CardStatus_T*	pResBladeSts, int timeout);
 int	 LIBIPMI_HL_GetChassisInfo(IPMI20_SESSION_T *pSession, OemChassisInfo_T* pBladeInfo, int timeout);

+ 14 - 14
app/goahead-5.1.0/src/libipmi/src/libipmi_sdr.c

@@ -321,8 +321,8 @@ static uint16_t ipmb_get_sdr( IPMI20_SESSION_T *pSession,
 	output_buffer = (uint8_t *)pGetSDRRes;
 	
 	/* Find the record length first */
-	get_sdr_req.ReservationID = htoipmi_u16(reservation_id);
-	get_sdr_req.RecID = htoipmi_u16( record_id );
+	get_sdr_req.ReservationID =  (reservation_id);
+	get_sdr_req.RecID =  ( record_id );
 	get_sdr_req.Offset = 0;
 	get_sdr_req.Size = sizeof(SDRRecHdr_T);
 	dwRetLen = sizeof(SDRRecHdr_T) + sizeof(GetSDRRes_T);
@@ -344,8 +344,8 @@ static uint16_t ipmb_get_sdr( IPMI20_SESSION_T *pSession,
 	do {
 		bytes_to_read = (remaining_bytes > IPMB_SDR_MAX_SINGLE_READ)? IPMB_SDR_MAX_SINGLE_READ : remaining_bytes;
 		
-		get_sdr_req.ReservationID = htoipmi_u16(reservation_id);
-		get_sdr_req.RecID = htoipmi_u16( record_id );
+		get_sdr_req.ReservationID =  (reservation_id);
+		get_sdr_req.RecID =  ( record_id );
 		get_sdr_req.Offset = offset;
 		get_sdr_req.Size = bytes_to_read;
 		dwRetLen = bytes_to_read + sizeof(GetSDRRes_T);
@@ -391,8 +391,8 @@ static uint16_t ipmb_get_sdr( IPMI20_SESSION_T *pSession,
 	{
 		GetSDRReq_T get_sdr_req;
 			
-		get_sdr_req.ReservationID = htoipmi_u16(reservation_id);
-		get_sdr_req.RecID = htoipmi_u16( record_id );
+		get_sdr_req.ReservationID =  (reservation_id);
+		get_sdr_req.RecID =  ( record_id );
 		get_sdr_req.Offset = 0;
 		get_sdr_req.Size = 0xff;
     		wRet = IPMICMD_GetSDR( pSession, &get_sdr_req, pGetSDRRes,
@@ -425,7 +425,7 @@ static uint16_t ipmb_get_sdr( IPMI20_SESSION_T *pSession,
     reservation.ReservationID = 0; //Setting reservation ID as zero as we are trying to get complete SDR.
     
     /* Determine max SDR entry length */
-    max_sdr_len = alloc_info.MaxRecSize * ipmitoh_u16( alloc_info.AllocUnitSize );
+    max_sdr_len = alloc_info.MaxRecSize *  ( alloc_info.AllocUnitSize );
 
     /* Make sure the calling function has space for this thing */
     if( buffer_len < (size_t) max_sdr_len )
@@ -444,7 +444,7 @@ static uint16_t ipmb_get_sdr( IPMI20_SESSION_T *pSession,
 
 #if 0        
     get_sdr_req.ReservationID = reservation.ReservationID;
-    get_sdr_req.RecID = htoipmi_u16( record_id );
+    get_sdr_req.RecID =  ( record_id );
     get_sdr_req.Offset = 0;
     get_sdr_req.Size = 0xff;
 
@@ -452,7 +452,7 @@ static uint16_t ipmb_get_sdr( IPMI20_SESSION_T *pSession,
     wRet = IPMICMD_GetSDR( pSession, &get_sdr_req, (GetSDRRes_T *)temp_buffer,
                            &blen, timeout );
 #endif
-    wRet = LIBIPMI_HL_GetSDR(pSession, ipmitoh_u16(reservation.ReservationID),
+    wRet = LIBIPMI_HL_GetSDR(pSession,  (reservation.ReservationID),
     					record_id, (GetSDRRes_T *)temp_buffer, &blen, timeout);
     if( wRet != LIBIPMI_E_SUCCESS )
     {
@@ -460,7 +460,7 @@ static uint16_t ipmb_get_sdr( IPMI20_SESSION_T *pSession,
         return( wRet );
     }
 
-    *next_record_id = ipmitoh_u16( get_sdr_res->NextRecID );
+    *next_record_id =  ( get_sdr_res->NextRecID );
 
     memcpy( sdr_buffer, temp_buffer + sizeof( GetSDRRes_T ), blen );
     free( temp_buffer );
@@ -492,10 +492,10 @@ static uint16_t ipmb_get_sdr( IPMI20_SESSION_T *pSession,
         return( -1 );
 
     /* Determine max SDR entry length */
-    max_sdr_len = alloc_info.MaxRecSize * ipmitoh_u16( alloc_info.AllocUnitSize );
+    max_sdr_len = alloc_info.MaxRecSize *  ( alloc_info.AllocUnitSize );
 
     /* Determine total number of SDRs stored */
-    sdr_count = ipmitoh_u16( repo_info.RecCt );
+    sdr_count =  ( repo_info.RecCt );
 
     /* Make sure the passed buffer is large enough */
     if( buffer_len < (size_t) ( max_sdr_len * sdr_count ) )
@@ -519,7 +519,7 @@ static uint16_t ipmb_get_sdr( IPMI20_SESSION_T *pSession,
     return( wRet );
 }
 
-int CacheGetAllSDRS(IPMI20_SESSION_T* pSession,uint8_t* sdr_buffer,uint32_t* buff_size,uint32_t* max_sdr_len,uint32_t* sdr_count);
+//int CacheGetAllSDRS(IPMI20_SESSION_T* pSession,uint8_t* sdr_buffer,uint32_t* buff_size,uint32_t* max_sdr_len,uint32_t* sdr_count);
 
   uint16_t LIBIPMI_HL_GetAllSDRs_Cached( IPMI20_SESSION_T *pSession,
                                           uint8_t *sdr_buffer, 
@@ -530,7 +530,7 @@ int CacheGetAllSDRS(IPMI20_SESSION_T* pSession,uint8_t* sdr_buffer,uint32_t* buf
 {
 	uint16_t wRet;
 
-	wRet = CacheGetAllSDRS(pSession,sdr_buffer,sdr_buff_size,max_sdr_len,sdr_count);
+//	wRet = CacheGetAllSDRS(pSession,sdr_buffer,sdr_buff_size,max_sdr_len,sdr_count);
 
     
 	return wRet;

+ 38 - 89
app/goahead-5.1.0/src/libipmi/src/libipmi_storlead_OEM.c

@@ -260,7 +260,7 @@ int LIBIPMI_HL_GetFanStatus( IPMI20_SESSION_T *pSession, uint8_t fanIndex, OemFa
 	return 0;	
 }
 
-uint16_t LIBIPMI_HL_GetExtraInfo( IPMI20_SESSION_T *pSession, ExtraInfo_T *extraInfo, int timeout)
+uint16_t LIBIPMI_HL_GetSysInfo( IPMI20_SESSION_T *pSession, SysInfo_T *pSysInfo, int timeout)
 {
 	
 	uint16_t wRet = 0;
@@ -270,96 +270,45 @@ uint16_t LIBIPMI_HL_GetExtraInfo( IPMI20_SESSION_T *pSession, ExtraInfo_T *extra
 	uint16_t strLen, remainLen;
 	uint16_t offset = 0;
 
-	if(pSession->byMediumType == UDS_MEDIUM)
+	//get title
+	Req[0] = 0;
+	Req[1] = 0;
+	Req[2] = 0;
+	Req[3] = (MAX_TITLE_LEN>>8)&0xff;	//max title len
+	Req[4] = MAX_TITLE_LEN&0xff;
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession,   
+												NETFNLUN_IPMI_OEM, 0x80,
+												(uint8_t*)Req, 5,
+												(uint8_t *)Res, &dwResLen,
+												timeout);
+	if((wRet != 0) || (Res[0] != 0))
 	{
-		//get title
-		Req[0] = 0;
-		Req[1] = 0;
-		Req[2] = 0;
-		Req[3] = (MAX_TITLE_LEN>>8)&0xff;	//max title len
-		Req[4] = MAX_TITLE_LEN&0xff;
-		wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession,   0x2e<<2, 0x83,
-																(uint8_t*)Req, 5,
-																(uint8_t *)Res, &dwResLen,
-																timeout);
-		if((wRet != 0) || (Res[0] != 0))
-		{
-			printf("---> get Title error\n");
-			return -1;
-		}
-		strLen = (Res[1]<<8) | Res[2];
-		remainLen = (Res[3]<<8) | Res[4];
-		memcpy(extraInfo->title,&Res[5],strLen);
-		
-		//get text
-		Req[0] = 1;
-		Req[1] = 0;
-		Req[2] = 0;
-		Req[3] = (MAX_TEXT_LEN>>8)&0xff;	//max text len
-		Req[4] = MAX_TEXT_LEN&0xff;
-		wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession,   0x2e<<2, 0x83,
-																(uint8_t*)Req, 5,
-																(uint8_t *)Res, &dwResLen,
-																timeout);
-		if((wRet != 0) || (Res[0] != 0))
-		{
-			printf("---> get Text error\n");
-			return -1;
-		}
-		strLen = (Res[1]<<8) | Res[2];
-		remainLen = (Res[3]<<8) | Res[4];
-		memcpy(extraInfo->text,&Res[5],strLen);
+		printf("---> get Title error\n");
+		return -1;
 	}
-	// else if(pSession->byMediumType == IPMB_MEDIUM)
-	// {
-	// 	//get title
-	// 	do{
-	// 		Req[0] = 0;
-	// 		Req[1] = (offset>>8)&0xff;
-	// 		Req[2] = offset&0xff;
-	// 		Req[3] = 0;	
-	// 		Req[4] = 25;	//32 bytes - ipmb message header - response - checksum2
-	// 		wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession,   0x2e<<2, 0x83,
-	// 																(uint8_t*)Req, 5,
-	// 																(uint8_t *)Res, &dwResLen,
-	// 																timeout);
-	// 		if((wRet != 0) || (Res[0] != 0))
-	// 		{
-	// 			printf("---> get Title error\n");
-	// 			return -1;
-	// 		}
-	// 		strLen = (Res[1]<<8) | Res[2];
-	// 		remainLen = (Res[3]<<8) | Res[4];
-			
-	// 		memcpy(extraInfo->title + offset,&Res[5],strLen);
-	// 		offset += strLen;
-	// 	}while(remainLen > 0);
-		
-	// 	//get text
-	// 	offset = 0;
-	// 	do{
-			
-	// 		Req[0] = 1;
-	// 		Req[1] = (offset>>8)&0xff;
-	// 		Req[2] = offset&0xff;
-	// 		Req[3] = 0;	
-	// 		Req[4] = 20;	//32 bytes - ipmb message header - response header - checksum2
-	// 		wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession,   0x2e<<2, 0x83,
-	// 																(uint8_t*)Req, 5,
-	// 																(uint8_t *)Res, &dwResLen,
-	// 																timeout);
-	// 		if((wRet != 0) || (Res[0] != 0))
-	// 		{
-	// 			printf("---> get Text error\n");
-	// 			return -1;
-	// 		}
-	// 		strLen = (Res[1]<<8) | Res[2];
-	// 		remainLen = (Res[3]<<8) | Res[4];
-			
-	// 		memcpy(extraInfo->text + offset,&Res[5],strLen);
-	// 		offset += strLen;
-	// 	}while(remainLen > 0);
-	// }
+	strLen = (Res[1]<<8) | Res[2];
+	remainLen = (Res[3]<<8) | Res[4];
+	memcpy(pSysInfo->title,&Res[5],strLen);
+
+	//get text
+	Req[0] = 1;
+	Req[1] = 0;
+	Req[2] = 0;
+	Req[3] = (MAX_TEXT_LEN>>8)&0xff;	//max text len
+	Req[4] = MAX_TEXT_LEN&0xff;
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession,   
+												NETFNLUN_IPMI_OEM, 0x80,
+												(uint8_t*)Req, 5,
+												(uint8_t *)Res, &dwResLen,
+												timeout);
+	if((wRet != 0) || (Res[0] != 0))
+	{
+		printf("---> get Text error\n");
+		return -1;
+	}
+	strLen = (Res[1]<<8) | Res[2];
+	remainLen = (Res[3]<<8) | Res[4];
+	memcpy(pSysInfo->text,&Res[5],strLen);
 	
 	return 0;
 }

+ 12 - 12
app/goahead-5.1.0/src/libipmi/src/libipmi_uds_session.c

@@ -135,7 +135,7 @@ uint32_t FillUDSMessagePacket(IPMI20_SESSION_T *pSession, uint8_t *Buffer,
 
     memcpy(pUDSMsg->UserName, pSession->hUDSSession->szUName, MAX_USERNAME_LEN);
     memcpy(pUDSMsg->IPAddr, pSession->hUDSSession->abyIPAddr, IP6_ADDR_LEN);
-    printf("---> FillUDSMessagePacket log2\n");
+//    printf("---> FillUDSMessagePacket log2\n");
     pUDSMsg->ProcessID = getpid();
     pUDSMsg->ThreadID = gettid();
     memcpy(pbyIPMIUDSData, pbyReqData, dwReqDataLen);
@@ -208,11 +208,11 @@ uint8_t UDS_ReceiveData( UDS_CHANNEL_T *UDSInfo, char *szBuffer, uint32_t* pdwSi
                 return LIBIPMI_MEDIUM_E_RECV_DATA_FAILURE;
             }
 
-            int i;
-            printf("---> client recv %#x: ", nBytesRecvd);
-            for(i=0;i<nBytesRecvd;i++)
-                printf("%#x ", szBuffer[totalrecvd+i]);
-            printf("\n");
+            // int i;
+            // printf("---> client recv %#x: ", nBytesRecvd);
+            // for(i=0;i<nBytesRecvd;i++)
+            //     printf("%#x ", szBuffer[totalrecvd+i]);
+            // printf("\n");
 
             totalrecvd += nBytesRecvd;
 
@@ -296,12 +296,12 @@ TCPSendUDSDataSelect:
             nBytesSent = send (UDSInfo->hSocket,szBuffer+nTotalBytesSent,dwsize, MSG_NOSIGNAL);
             
             int i=0;
-            printf("---> client Send %#x: ",  nBytesSent);
-            for (i = 0; i < nBytesSent; ++i)
-            {
-                printf("%#x ", szBuffer[nTotalBytesSent+i]);
-            }
-            printf("\n");
+            // printf("---> client Send %#x: ",  nBytesSent);
+            // for (i = 0; i < nBytesSent; ++i)
+            // {
+            //     printf("%#x ", szBuffer[nTotalBytesSent+i]);
+            // }
+            // printf("\n");
 
             /* send failure */
             if ((nBytesSent == -1) && ((EBADF == errno) || (EPIPE == errno)))

+ 2 - 2
app/goahead-5.1.0/src/libipmi/src/sensor_helpers.c

@@ -668,11 +668,11 @@ int read_sensor_sdrs( IPMI20_SESSION_T *pSession, struct sensor_info **sensor_li
         return( -1 );
 
     /* Determine max SDR entry length */
-    max_sdr_len = alloc_info.MaxRecSize * ipmitoh_u16( alloc_info.AllocUnitSize );
+    max_sdr_len = alloc_info.MaxRecSize * ( alloc_info.AllocUnitSize );
     printf("max sdr len is %d\n",max_sdr_len);
 
     /* Determine total number of SDRs stored */
-    sdr_count = ipmitoh_u16( repo_info.RecCt );
+    sdr_count = ( repo_info.RecCt );
     printf("sdr_count is %d\n",sdr_count);
 
     /* Maximum size needed to store all the SDRs */

+ 2 - 2
app/goahead-5.1.0/src/web_interface/inc/dashboard.h

@@ -5,9 +5,9 @@
 /*获取设备信息*/
 void getDeviceInfo(Webs *wp);
 /*获取cpu信息*/
-void getCPUInfo();
+void getSysInfo(Webs *wp);
 /*获取刀片信息*/
-void getCardInfo();
+void getCardInfo(Webs *wp);
 
 
 

+ 46 - 3
app/goahead-5.1.0/src/web_interface/src/dashboard.c

@@ -3,6 +3,7 @@
 #include    "com_IPMIDefs.h"
 #include    "ResultUtils.h"
 #include    "cJSON.h"
+#include    "libipmi_storlead_OEM.h"
 /*获取设备信息*/
 
 /*获取设备信息*/
@@ -117,14 +118,56 @@ void getDeviceInfo(Webs *wp){
 }
 
 
-/*获取cpu信息*/
-void getCPUInfo(){
+/*获取系统信息*/
+void getSysInfo(Webs *wp){
+    int wRet;
+    SysInfo_T sysInfo;
+    uint8_t Req[5] = {0,0,0,0,0};
+    uint8_t Res[MAX_TEXT_LEN+5];
+    int dwResLen;
+
+
+    sysInfo.title = malloc(MAX_TITLE_LEN);
+    if(sysInfo.title == NULL)
+    {
+        printf("---> title malloc error!\n");
+        goto sys_info_end;
+    }
+    else
+        memset(sysInfo.title, 0, MAX_TITLE_LEN);
+    
+    sysInfo.text = malloc(MAX_TEXT_LEN);
+    if(sysInfo.text == NULL)
+    {
+        printf("---> text malloc error!\n");
+        goto sys_info_end;
+    }
+    else
+        memset(sysInfo.text, 0, MAX_TEXT_LEN);
+
+    //Create session
+    wRet = LIBIPMI_CreateSession(&wp->ipmi_session, 10);
+    
+    LIBIPMI_HL_GetSysInfo(&wp->ipmi_session, &sysInfo, DEFAULT_TIMEOUT);
+
+    //Close session
+    LIBIPMI_CloseSession(&wp->ipmi_session );
+
+    printf("Title: %s\n", sysInfo.title);
+    printf("Text: %s\n", sysInfo.text);
+
+    sleep(1);
+sys_info_end: 
+    if(sysInfo.title)
+        free(sysInfo.title);
+    if(sysInfo.text)
+        free(sysInfo.text);
 
 }
 
 
 /*获取刀片信息*/
-void getCardInfo(){
+void getCardInfo(Webs *web){
 
 }