zhangbo 5 éve
szülő
commit
410b7e8418

+ 1 - 1
app/bmc/SysTimer/TimerTask.c

@@ -47,7 +47,7 @@ static void ProcessTimerReq (void);
 
 void TimerTask( int signo )	//signal handler
 {	
-	printf("TimerTask start...\n");
+	//printf("TimerTask start...\n");
 	switch(signo)
 	{
 	case SIGALRM:

BIN
app/bmc/bmc_app


+ 14 - 14
app/bmc/main.c

@@ -140,20 +140,20 @@ void main(void)
         printf("%s: Create LANIfcTask thread failed!\n", __FUNCTION__);
     }
 
-	/* Create IPMB interface */
-	uint8_t primaryIpmbSelect = 0;	//primary
-	gThreadIndex++;
-	if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,IPMBIfcTask,&primaryIpmbSelect))
-  {
-      printf("%s: Create LANIfcTask thread failed!\n", __FUNCTION__);
-  }
-
-  uint8_t secondaryIpmbSelect = 1;	//secondary
-  gThreadIndex++;
-  if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,IPMBIfcTask,&secondaryIpmbSelect))
-  {
-      printf("%s: Create LANIfcTask thread failed!\n", __FUNCTION__);
-  }
+	// /* Create IPMB interface */
+	// uint8_t primaryIpmbSelect = 0;	//primary
+	// gThreadIndex++;
+	// if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,IPMBIfcTask,&primaryIpmbSelect))
+ //  {
+ //      printf("%s: Create LANIfcTask thread failed!\n", __FUNCTION__);
+ //  }
+
+ //  uint8_t secondaryIpmbSelect = 1;	//secondary
+ //  gThreadIndex++;
+ //  if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,IPMBIfcTask,&secondaryIpmbSelect))
+ //  {
+ //      printf("%s: Create LANIfcTask thread failed!\n", __FUNCTION__);
+ //  }
 
 
 	/* Create Update FPGA thread */

+ 2 - 1
app/goahead-3.6.5/src/goahead.c

@@ -210,7 +210,8 @@ websDefineAction("getUpdateProgress", getUpdateProgress);
 websDefineAction("getVerifyStatus", getVerifyStatus);
 websDefineAction("resetBmc", resetBmc);
 
-
+//server_health
+websDefineAction("setThreshold", setThreshold);
 
 
 

+ 13 - 4
app/goahead-3.6.5/src/libipmi/src/libipmi_sdr.c

@@ -531,11 +531,11 @@ static uint16_t ipmb_get_sdr( IPMI20_UDS_SESSION_T *pUDSSession,
                                                 int timeout )
 {
     ReserveSDRRepositoryRes_T ResReserveSDRRepository;
-    uint8_t data_buffer[255];
+    uint8_t *data_buffer = walloc(255);
     FullSensorRec_T	*sdr_record = (FullSensorRec_T*) &data_buffer[sizeof(GetSDRRes_T)];
     GetSDRReq_T ReqGetSDR;
     GetSDRRes_T *pResGetSDR = (GetSDRRes_T *) &data_buffer[0];
-    uint32_t      dwRetLen = sizeof data_buffer;
+    uint32_t      dwRetLen = 255;   //sizeof(data_buffer);
     int wRet = 0;
     
     wRet = IPMICMD_ReserveSDRRepository(pUDSSession, &ResReserveSDRRepository, timeout);
@@ -547,20 +547,29 @@ static uint16_t ipmb_get_sdr( IPMI20_UDS_SESSION_T *pUDSSession,
         ReqGetSDR.RecID = pResGetSDR->NextRecID;
         ReqGetSDR.Offset = 0;
         ReqGetSDR.Size = 0xff;
-        //wRet = IPMICMD_GetSDR(pUDSSession, &ReqGetSDR, pResGetSDR, &dwRetLen, timeout);
+        wRet = IPMICMD_GetSDR(pUDSSession, &ReqGetSDR, pResGetSDR, &dwRetLen, timeout);
         //TODO: IPMICMD_GetSDR replaced by LIBIPMI_HL_GetSDR, by jimbo
-        wRet = LIBIPMI_HL_GetSDR(pUDSSession,	ReqGetSDR.ReservationID, ReqGetSDR.RecID, pResGetSDR, &dwRetLen, timeout );
+        //wRet = LIBIPMI_HL_GetSDR(pUDSSession,	ReqGetSDR.ReservationID, ReqGetSDR.RecID, pResGetSDR, &dwRetLen, timeout );
         if (wRet != LIBIPMI_E_SUCCESS)
+        {
+            printf("Get SDR error!\n");
             break;
+        }
         
         if (sdr_record->SensorNum == SensorNumber)
+        {
+            //printf("Find %d: %s\n", sdr_record->SensorNum , sdr_record->IDStr);
             break;  // found
+        }
     }
     
     dwRetLen -= sizeof(GetSDRRes_T);
     *sdr_buff_size = *sdr_buff_size >= dwRetLen ? dwRetLen : *sdr_buff_size;
     memcpy(sdr_buffer, sdr_record, *sdr_buff_size);
+
+    //printf("sdr_buff_size: %d\n", *sdr_buff_size);
         
+    wfree(data_buffer);
     return wRet;
 }
 

+ 0 - 10
app/goahead-3.6.5/src/libipmi/src/libipmi_sensor.c

@@ -32,16 +32,6 @@
 #include "com_IPMIDefs.h"
 #include "com_IPMI_Storlead.h"
 
-#if 0
-/* A bunch of defines that SDRRecord needs.  We don't care about the actual */
-/* values, since we don't really use them, but I pulled these from the      */
-/* Rules.make for the IPMI stack                                            */
-#define MAX_NUM_USERS           ( 20 )
-#define NUM_USER_PER_CHANNEL    ( 10 )
-#define SDR_DEVICE_SIZE         ( 3 )
-#include "SDRRecord.h"
-#endif
-
 
 #define PACKED __attribute__ ((packed))
 

+ 1 - 1
app/goahead-3.6.5/src/web_interface/inc/server_health.h

@@ -2,6 +2,6 @@
 #define __SERVER_HEALTH_H__
 
 #include "goahead.h"
-
+void setThreshold(Webs *wp);
 
 #endif /* __SERVER_HEALTH_H__ */

+ 123 - 0
app/goahead-3.6.5/src/web_interface/src/server_health.c

@@ -0,0 +1,123 @@
+#include    "goahead.h"
+#include    "libipmi_IPM.h"
+#include    "com_IPMIDefs.h"
+#include    "ResultUtils.h"
+#include    "cJSON.h"
+#include    "libipmi_storlead_OEM.h"
+#include    "libsensor.h"
+#include 	"libipmi_sdr.h"
+#include 	"libipmi_sensor.h"
+#include    <stdio.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+
+void setThreshold(Webs *wp){
+    uint16_t    wRet = LIBIPMI_E_SUCCESS;
+    IPMI20_UDS_SESSION_T    UDSSession;
+    char *strUNC = websGetVar(wp, "UNC", NULL);
+    char *strUC = websGetVar(wp, "UC", NULL);
+    char *strUNR = websGetVar(wp, "UNR", NULL);
+    char *strLNC = websGetVar(wp, "LNC", NULL);
+    char *strLC = websGetVar(wp, "LC", NULL);
+    char *strLNR = websGetVar(wp, "LNR", NULL);
+    char *strSensorNumber = websGetVar(wp, "SensorNumber", NULL);
+    float UNC = atof(strUNC);
+    float UC = atof(strUC);
+    float UNR = atof(strUNR);
+    float LNC = atof(strLNC);
+    float LC = atof(strLC);
+    float LNR = atof(strLNR);
+    int   SensorNumber = atoi(strSensorNumber);
+
+    printf(" %s, %s %s %s, %s %s %s = %d, %f %f %f %f %f %f \n", strSensorNumber, strUNC, strUC, strUNR, strLNC, strLC, 
+    	strLNR,  SensorNumber, UNC, UC, UNR, LNC, LC, LNR );
+
+    uint8_t  *data_buffer = (uint8_t*)walloc(255);
+    FullSensorRec_T	*sdr_record = (FullSensorRec_T*) data_buffer;
+    uint32_t data_buff_size = 255;//sizeof(data_buffer);
+    double val;
+    SetSensorThresholdReq_T* pReqSetSensorThreshold;
+    SetSensorThresholdRes_T* pResSetSensorThreshold;
+    
+    pReqSetSensorThreshold = (SetSensorThresholdReq_T*)walloc(sizeof(SetSensorThresholdReq_T));
+    if(pReqSetSensorThreshold == NULL)
+    {
+    	printf("Malloc error!\n");
+        wRet = -1;
+        websError(wp, 404, "Malloc error!");
+    }
+    memset(pReqSetSensorThreshold, 0, sizeof(SetSensorThresholdReq_T));
+
+    pResSetSensorThreshold = (SetSensorThresholdRes_T*)walloc(sizeof(SetSensorThresholdRes_T));
+    if(pResSetSensorThreshold == NULL)
+    {
+    	printf("Malloc error!\n");
+        wRet = -1;
+        websError(wp, 404, "Malloc error!");
+    }
+    memset(pResSetSensorThreshold, 0, sizeof(pResSetSensorThreshold));
+    
+    //Create session
+    LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
+
+    wRet = LIBIPMI_HL_GetSpecificSDR(&UDSSession, data_buffer, &data_buff_size, SensorNumber, DEFAULT_TIMEOUT);
+    
+    pReqSetSensorThreshold->SensorNum = SensorNumber;
+    
+    // Follow IPMI Spec. 2.0 Session 35.8, 0x3F for all thresholds
+    pReqSetSensorThreshold->SetFlags = 0x3f;    
+    pReqSetSensorThreshold->UpperNonCritical = sdr_convert_sensor_value_to_raw(sdr_record, UNC);    
+    pReqSetSensorThreshold->UpperCritical = sdr_convert_sensor_value_to_raw(sdr_record, UC);    
+    pReqSetSensorThreshold->UpperNonRecoverable = sdr_convert_sensor_value_to_raw(sdr_record, UNR);    
+    pReqSetSensorThreshold->LowerNonCritical = sdr_convert_sensor_value_to_raw(sdr_record, LNC);
+    pReqSetSensorThreshold->LowerCritical = sdr_convert_sensor_value_to_raw(sdr_record, LC);
+    pReqSetSensorThreshold->LowerNonRecoverable = sdr_convert_sensor_value_to_raw(sdr_record, LNR);
+    
+    printf("---> Num %d, Name: %s, raw: %d, %d, %d, %d, %d, %d\n", 
+    	pReqSetSensorThreshold->SensorNum, sdr_record->IDStr,
+    	pReqSetSensorThreshold->UpperNonCritical, pReqSetSensorThreshold->UpperCritical, 
+    	pReqSetSensorThreshold->UpperNonRecoverable, pReqSetSensorThreshold->LowerNonCritical, 
+    	pReqSetSensorThreshold->LowerCritical, pReqSetSensorThreshold->LowerNonRecoverable);
+
+    wRet = IPMICMD_SetSensorThreshold( &UDSSession, pReqSetSensorThreshold, pResSetSensorThreshold, DEFAULT_TIMEOUT);
+
+    //Close session
+    LIBIPMI_CloseSession(&UDSSession );
+
+	char *pStr;
+    cJSON * root =  cJSON_CreateObject();
+    cJSON * data =  cJSON_CreateObject();
+    cJSON_AddItemToObject(root, "data", data);//根节点下添加
+    cJSON_AddStringToObject(root, "msg", "");
+    cJSON_AddNumberToObject(root, "code", 200);
+    
+   
+    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);
+
+    if(pStr)
+        wfree(pStr);
+    if(root)
+        cJSON_Delete(root);
+
+
+
+    if(pReqSetSensorThreshold != NULL)
+        wfree(pReqSetSensorThreshold);
+    if(pResSetSensorThreshold != NULL)
+        wfree(pResSetSensorThreshold);
+    if(data_buffer)
+    	wfree(data_buffer);
+
+}
+

+ 5 - 5
local/rc

@@ -11,7 +11,7 @@ ifconfig lo 127.0.0.1
 ################### install module #####################
 #insmod /usr/bin/test_module.ko
 insmod /usr/bin/gpio.ko 
-insmod /usr/bin/i2c.ko
+#insmod /usr/bin/i2c.ko
 #insmod /usr/bin/fmc.ko
 insmod /usr/bin/platform.ko
 #insmod /usr/bin/adc.ko
@@ -21,9 +21,9 @@ insmod /usr/bin/platform.ko
 #################### create node ########################
 #mknod /dev/test_module c 99 0
 mknod /dev/platform c 100 0
-mknod /dev/i2c1 c 101 0
-mknod /dev/i2c2 c 101 1
-mknod /dev/i2c3 c 101 2
+#mknod /dev/i2c1 c 101 0
+#mknod /dev/i2c2 c 101 1
+#mknod /dev/i2c3 c 101 2
 #mknod /dev/fmc_cpld c 102 0
 mknod /dev/gpio c 103 0 
 #mknod /dev/adc1 c 105 0
@@ -37,4 +37,4 @@ mknod /dev/gpio c 103 0
 /usr/bin/bmc_app & 
 #sleep 3
 #/usr/bin/test_app 
-#/usr/bin/goahead-3.6.5 -v --home /etc/goahead &
+/usr/bin/goahead-3.6.5 -v --home /etc/goahead &