lusa 5 жил өмнө
parent
commit
943a5f3bb9

+ 30 - 22
app/bmc/Api.c

@@ -92,13 +92,16 @@ int PlatformInit(void)
 
 	g_BMCInfo.SelfTestByte 	=	0;
 	g_BMCInfo.SlotID		=	PDK_GetSlotID();
+
 	g_BMCInfo.ChassisID		=	PDK_GetChassisID();
 
+	//机箱及刀片信息
 	g_BMCInfo.ChassisIdentify		=	FALSE;
 	g_BMCInfo.PowerGoodFlag =  	1;
 	g_BMCInfo.BladeManageEn = 0;
 	g_BMCInfo.isChMC 		= 0;
 	g_BMCInfo.IndexInChassis = 1;
+	gBladeStatus[g_BMCInfo.IndexInChassis].slotID = g_BMCInfo.SlotID;
 	
 	//init DevGUID
 	g_BMCInfo.DeviceGUID[0]	=	0x01;
@@ -135,6 +138,8 @@ int PlatformInit(void)
 	g_BMCInfo.CurTimerSecond			=	0;
 	g_BMCInfo.BootValidMinutes			=	0;
 	g_BMCInfo.m_Lan_SetInProgress 		=	0;
+
+	
 	
 		
 	return 0;
@@ -390,31 +395,34 @@ int PostEventMessage (uint8_t *EventMsg,uint8_t size)
 
 uint8_t PDK_GetSlotID(void)
 {
-	uint8_t SlotID = 0;
-	uint8_t check = 0;
-
-	if(stm32_gpio_read(GA0_PORT, GA0_PIN) == GPIO_PIN_RESET)
-		SlotID |= 0x01;
-	if(stm32_gpio_read(GA1_PORT, GA1_PIN) == GPIO_PIN_RESET)
-		SlotID |= 0x02;
-	if(stm32_gpio_read(GA2_PORT, GA2_PIN) == GPIO_PIN_RESET)
-		SlotID |= 0x04;
-	if(stm32_gpio_read(GA3_PORT, GA3_PIN) == GPIO_PIN_RESET)
-		SlotID |= 0x08;
-	if(stm32_gpio_read(GA4_PORT, GA4_PIN) == GPIO_PIN_RESET)
-		SlotID |= 0x10;
-
-	if(stm32_gpio_read(GAP_PORT, GAP_PIN) == GPIO_PIN_RESET)
-		SlotID |= 0x20;
+	// uint8_t SlotID = 0;
+	// uint8_t check = 0;
 
-	int i;
-	for(i=0;i<6;i++)
-		check ^= (SlotID>>i)&0x01;
+	// if(stm32_gpio_read(GA0_PORT, GA0_PIN) == GPIO_PIN_RESET)
+	// 	SlotID |= 0x01;
+	// if(stm32_gpio_read(GA1_PORT, GA1_PIN) == GPIO_PIN_RESET)
+	// 	SlotID |= 0x02;
+	// if(stm32_gpio_read(GA2_PORT, GA2_PIN) == GPIO_PIN_RESET)
+	// 	SlotID |= 0x04;
+	// if(stm32_gpio_read(GA3_PORT, GA3_PIN) == GPIO_PIN_RESET)
+	// 	SlotID |= 0x08;
+	// if(stm32_gpio_read(GA4_PORT, GA4_PIN) == GPIO_PIN_RESET)
+	// 	SlotID |= 0x10;
+
+	// if(stm32_gpio_read(GAP_PORT, GAP_PIN) == GPIO_PIN_RESET)
+	// 	SlotID |= 0x20;
+
+	// int i;
+	// for(i=0;i<6;i++)
+	// 	check ^= (SlotID>>i)&0x01;
+
+	// if(check == 0)
+	// 	printf("Slot ID check error! GAP = %#x, GA[4:0] = %#x.\n", (SlotID>>5), (SlotID&0x1f));
+
+	// return SlotID&0x1f;
 
-	if(check == 0)
-		printf("Slot ID check error! GAP = %#x, GA[4:0] = %#x.\n", (SlotID>>5), (SlotID&0x1f));
+	return 2;
 
-	return SlotID&0x1f;
 }
 
 uint8_t PDK_GetChassisID(void)

+ 32 - 0
app/bmc/main.c

@@ -95,6 +95,38 @@ void main(void)
 	InitTimerTaskTbl();
 	Init_UserInfoTbl();
 
+	//初始化系统时间
+	system("date -s 2020.05.12-00:00:00");
+
+	//Initialize IP
+	char cmdStr[100];
+	LanInfo_T *pSetLanInfo = &g_BMCInfo.IpmiConfig.LanInfo[0];
+	//down
+	sprintf(cmdStr, "ifconfig %s down", pSetLanInfo->EthName);
+	printf("%s\n", cmdStr);
+	system(cmdStr);
+	//set mac
+	sprintf(cmdStr, "ifconfig %s hw ether %02x:%02x:%02x:%02x:%02x:%02x", 
+		pSetLanInfo->EthName, pSetLanInfo->MACAddr[0], pSetLanInfo->MACAddr[1],
+		pSetLanInfo->MACAddr[2], pSetLanInfo->MACAddr[3], 
+		pSetLanInfo->MACAddr[4], pSetLanInfo->MACAddr[5]);
+	printf("%s\n", cmdStr);
+	system(cmdStr);
+	//ip, broadcast, netmask
+	sprintf(cmdStr, "ifconfig %s %d.%d.%d.%d broadcast %d.%d.%d.%d netmask %d.%d.%d.%d up",
+		pSetLanInfo->EthName, pSetLanInfo->IPAddr[0], pSetLanInfo->IPAddr[1],
+		pSetLanInfo->IPAddr[2], pSetLanInfo->IPAddr[3], pSetLanInfo->BroadCast[0],
+		pSetLanInfo->BroadCast[1], pSetLanInfo->BroadCast[2], pSetLanInfo->BroadCast[3],
+		pSetLanInfo->NetMask[0], pSetLanInfo->NetMask[1], pSetLanInfo->NetMask[2],
+		pSetLanInfo->NetMask[3]);
+	printf("%s\n", cmdStr);
+	system(cmdStr);
+	//default gw
+	sprintf(cmdStr, "route add default gw %d.%d.%d.%d", pSetLanInfo->DefaultGW[0],
+		pSetLanInfo->DefaultGW[1],pSetLanInfo->DefaultGW[2],pSetLanInfo->DefaultGW[3]);
+	printf("%s\n", cmdStr);
+	system(cmdStr);
+
 	printf("\tChassisID %#02x, SlotID %#02x\r\n", g_BMCInfo.ChassisID, g_BMCInfo.SlotID);
 	if(g_BMCInfo.IpmiConfig.PrimaryIPMBSupport)
 	{

+ 11 - 11
app/bmc/sensor_driver.c

@@ -35,7 +35,7 @@ int sensor_1_read(uint8_t *reading)
 //	close(fd);
 	//printf("read sensor 1: %#x!\n", buf);
 	//*reading = buf;
-	*reading = i++;
+	*reading = 0x80;
 	return 0;
 }
 
@@ -64,7 +64,7 @@ int sensor_2_read(uint8_t *reading)
 //	stm32_i2c_master_read(fd, 0xAA, &buf, 1);
 //	close(fd);
 	//*reading = buf;
-	*reading = i;
+	*reading = 0x80;
 	return 0;
 }
 
@@ -93,7 +93,7 @@ int sensor_3_read(uint8_t *reading)
 //	stm32_i2c_master_read(fd, 0x98, &buf, 1);
 //	close(fd);
 	//*reading = buf;
-	*reading = i;
+	*reading = 0xf0;
 	return 0;
 }
 
@@ -123,7 +123,7 @@ int sensor_4_read(uint8_t *reading)
 //	stm32_i2c_master_read(fd, 0x98, &buf, 1);
 //	close(fd);
 	//*reading = buf;
-	*reading = i;
+	*reading = 0x21;
 	return 0;
 }
 
@@ -147,7 +147,7 @@ int sensor_5_read(uint8_t *reading)
 //	uint16_t buf;
 //	stm32_adc_get_value(1, &buf);
 	//*reading = buf>>4;
-	*reading = i;
+	*reading = 0x80;
 	return 0;
 }
 
@@ -171,7 +171,7 @@ int sensor_6_read(uint8_t *reading)
 //	uint16_t buf;
 //	stm32_adc_get_value(2, &buf);
 	//*reading = buf>>4;
-	*reading = i;
+	*reading = 0x80;
 	return 0;
 }
 
@@ -195,7 +195,7 @@ int sensor_7_read(uint8_t *reading)
 //	uint16_t buf;
 //	stm32_adc_get_value(3, &buf);
 	//*reading = buf>>4;
-	*reading = i;
+	*reading = 0x80;
 	return 0;
 }
 
@@ -219,7 +219,7 @@ int sensor_8_read(uint8_t *reading)
 //	uint16_t buf;
 //	stm32_adc_get_value(4, &buf);
 	//*reading = buf>>4;
-	*reading = i;
+	*reading = 0x80;
 	return 0;
 }
 
@@ -243,7 +243,7 @@ int sensor_9_read(uint8_t *reading)
 //	uint16_t buf;
 //	stm32_adc_get_value(5, &buf);
 	//*reading = buf>>4;
-	*reading = i;
+	*reading = 0x80;
 	return 0;
 }
 
@@ -267,7 +267,7 @@ int sensor_10_read(uint8_t *reading)
 //	uint16_t buf;
 //	stm32_adc_get_value(6, &buf);
 	//*reading = buf>>4;
-	*reading = i;
+	*reading = 0x80;
 	return 0;
 }
 
@@ -291,7 +291,7 @@ int sensor_11_read(uint8_t *reading)
 //	uint16_t buf;
 //	stm32_adc_get_value(7, &buf);
 	//*reading = buf>>4;
-	*reading = i;
+	*reading = 0x80;
 	return 0;
 }
 

+ 7 - 3
app/common_include/com_BMCCfg.h

@@ -23,9 +23,12 @@
 ...
 0x83 F000 ~ 0x83 FFFF	4KB 	IpmiConfig_n
 ---------------------------------------------
-0x84 0000 ~ 0x84 FFFF 	64KB	SEL
+0x84 0000 ~ 0x84 7FFF 	32KB 	SensorHistory
+0x84 8000 ~ 0x84 8FFF 	32kB 	Reserve
 ---------------------------------------------
-0x85 0000 ~ 0x8F FFFF 	704KB 	Reserve
+0x85 0000 ~ 0x85 FFFF 	64KB	SEL
+---------------------------------------------
+0x86 0000 ~ 0x8F FFFF 	640KB 	Reserve
 =============================================
 0x90 0000 ~ 0xFF FFFF 	7MB 	Reserve
 */
@@ -34,7 +37,8 @@
 #define FRU_FLASH_ADDR 		0x810000
 #define SDR_FLASH_ADDR 		0x820000
 #define IPMI_CFG_FLASH_ADDR 0x830000
-#define SEL_FLASH_ADDR 		0x840000
+#define SENSOR_HISTORY_FLASH_ADDR 	0x840000
+#define SEL_FLASH_ADDR 		0x850000
 
 
 

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

@@ -46,6 +46,8 @@ struct sensor_data
     float high_non_crit_thresh;
     float high_crit_thresh;
     float high_non_recov_thresh;
+    float max_reading;
+    float min_reading;
     int SensorAccessibleFlags;
     uint16_t Settable_Readable_ThreshMask;    
 } ;

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

@@ -933,6 +933,20 @@ LIBIPMI_HL_GetAllSensorReadings( IPMI20_UDS_SESSION_T *pUDSSession, struct senso
 	                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
 	        	sensor_list[i].high_non_recov_thresh = tmp_float;
 
+	        	//MAX reading
+	        	if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT5)
+	            ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->MaxReading, &tmp_float, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1, 
+	                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
+	        	sensor_list[i].max_reading = tmp_float;
+
+	        	//MIN reading
+	        	if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT5)
+	            ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->MinReading, &tmp_float, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1, 
+	                                    pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
+	        	sensor_list[i].min_reading = tmp_float;
+
+	        	
+
 	            /*Get the Sensor state*/
 	            SensorState(pSensorBuff->SensorReading,&tmp_hw,pSensorBuff->hdr.Type,pSensorBuff->Linearization,pSensorBuff->Units1,pSensorBuff->EventTypeCode,pSensorBuff->AssertionEventByte1,pSensorBuff->AssertionEventByte2,pSensorBuff->DeassertionEventByte1,pSensorBuff->DeassertionEventByte2);
 	            sensor_list[i].sensor_state = tmp_hw;

+ 6 - 0
app/goahead-3.6.5/src/libipmi/src/libipmi_usermgmt.c

@@ -58,6 +58,12 @@ uint16_t LIBIPMI_SetUser( IPMI20_UDS_SESSION_T *pUDSSession, char *pszUsername,
 											(uint8_t*)&UserInfo, sizeof(SetUser_T),
 											byRes, &dwResLen,
 											timeout);
+	if(byRes[0] != 0)
+	{
+		printf("Delete user fail!\n");
+		return -1;
+	}
+	
 	if(wRet == LIBIPMI_E_SUCCESS)
 		return STATUS_CODE(LIBIPMI_STATUS_SUCCESS, byRes[0]);
 	

+ 5 - 0
app/goahead-3.6.5/src/web_interface/src/dashboard.c

@@ -203,6 +203,7 @@ void getSensorInfo(Webs *wp){
     int         SensorAccessibleFlags;
     struct sensor_data *pSensorBuff = NULL;
     char reading[10], lownr[10],lowct[10],lownc[10],highnc[10],highct[10],highnr[10];
+    char maxReading[10], minReading[10];
     unsigned char *pStartBuff = NULL;
     IPMI20_UDS_SESSION_T    UDSSession;
     
@@ -266,6 +267,8 @@ void getSensorInfo(Webs *wp){
                 sprintf(highnc, "%.3f", pSensorBuff->high_non_crit_thresh);
                 sprintf(highct, "%.3f", pSensorBuff->high_crit_thresh);
                 sprintf(highnr, "%.3f", pSensorBuff->high_non_recov_thresh);
+                sprintf(maxReading, "%.3f", pSensorBuff->max_reading);
+                sprintf(minReading, "%.3f", pSensorBuff->min_reading);
 
                 cJSON_AddItemToArray(pJsonArry,pJsonsub=cJSON_CreateObject()); /* 给创建的数组增加对对象*/
                 cJSON_AddNumberToObject(pJsonsub, "sensorNum", pSensorBuff->sensor_num); 
@@ -289,6 +292,8 @@ void getSensorInfo(Webs *wp){
                 cJSON_AddStringToObject(pJsonsub, "highnc", highnc);                 
                 cJSON_AddStringToObject(pJsonsub, "highct", highct);   
                 cJSON_AddStringToObject(pJsonsub, "highnr", highnr);  
+                cJSON_AddStringToObject(pJsonsub, "maxReading", maxReading);  
+                cJSON_AddStringToObject(pJsonsub, "minReading", minReading);  
 
                 switch(pSensorBuff->sensor_units[1])    //sensorUinits2
                 {