zhangbo 5 năm trước cách đây
mục cha
commit
65be6f75e5

+ 9 - 3
app/bmc/Api.c

@@ -328,13 +328,19 @@ int UpdateFlash(void)
 
 int SetSysTime(uint32_t *timeSecond)
 {
-	g_BMCInfo.SELTimeSecond = *timeSecond;
+	time_t tt;
+	tt = *timeSecond;
+	stime(&tt);	//TODO:注意时区
 	return 0;
 }
 
-int GetSysTime(void)
+long int GetSysTime(void)
 {
-	return g_BMCInfo.SELTimeSecond;
+	time_t tt;
+	time(&tt);
+	//TODO: 注意时区
+	//tt += 8*60*60;	UTC+8
+	return tt;
 }
 
 int PostEventMessage (uint8_t *EventMsg,uint8_t size)

+ 1 - 1
app/bmc/Api.h

@@ -10,7 +10,7 @@ int InitTimerTaskTbl(void);
 
 int UpdateFlash(void);
 int SetSysTime(uint32_t *timeSecond);
-int GetSysTime(void);
+long int GetSysTime(void);
 #define SET_SYSTEM_TIME_STAMP(time) SetSysTime(time)
 #define GET_SYSTEM_TIME_STAMP GetSysTime
 

+ 12 - 22
app/bmc/AuthChip/CM_TEST.c

@@ -69,6 +69,7 @@ uint8_t cm_Auth_Encrp_Personal(uint8_t pswMode,uint8_t authMode)
 	{
 		printf("cm_WriteConfigZone 0x26 is error\n");	
 		errorGlobalFlag = 2;
+		return -1;
 	}
 
 	
@@ -81,6 +82,7 @@ uint8_t cm_Auth_Encrp_Personal(uint8_t pswMode,uint8_t authMode)
 	{
 		printf("cm_WriteConfigZone 0x26 is error\n");			
 		errorGlobalFlag = 3;
+		return -1;
 	}
 	
 	
@@ -93,6 +95,7 @@ uint8_t cm_Auth_Encrp_Personal(uint8_t pswMode,uint8_t authMode)
 		printf("cm_WriteConfigZone 0x26 is error\n");	
 		
 		errorGlobalFlag = 4;
+		return -1;
 	}
 	
 	//---------------------------------------------config all user zone use the same password/seed of the set 1 
@@ -113,6 +116,7 @@ uint8_t cm_Auth_Encrp_Personal(uint8_t pswMode,uint8_t authMode)
 		printf("cm_WriteConfigZone 0x20 is error\n");	
 		
 		errorGlobalFlag = 5;
+		return -1;
 	}
 	
 	
@@ -123,6 +127,7 @@ uint8_t cm_Auth_Encrp_Personal(uint8_t pswMode,uint8_t authMode)
 		printf("cm_WriteConfigZone 0x22 is error\n");	
 		
 		errorGlobalFlag = 6;
+		return -1;
 	}
 	
 	// ---------------------------------------------Write Control for user zone 2
@@ -132,6 +137,7 @@ uint8_t cm_Auth_Encrp_Personal(uint8_t pswMode,uint8_t authMode)
 		printf("cm_WriteConfigZone 0x24 is error\n");	
 		
 		errorGlobalFlag = 7;
+		return -1;
 	}
 	
 	
@@ -142,6 +148,7 @@ uint8_t cm_Auth_Encrp_Personal(uint8_t pswMode,uint8_t authMode)
 		printf("cm_WriteConfigZone 0x26 is error\n");	
 		
 		errorGlobalFlag = 8;
+		return -1;
 	}
 	
 
@@ -154,6 +161,7 @@ uint8_t cm_Auth_Encrp_Personal(uint8_t pswMode,uint8_t authMode)
 		printf("cm_WriteConfigZone 0x18 is error\n");
 	
 		errorGlobalFlag = 9;
+		return -1;
 	}
 	
 	
@@ -173,6 +181,7 @@ uint8_t cm_Auth_Encrp_Personal(uint8_t pswMode,uint8_t authMode)
 		printf("cm_WriteConfigZone 0x60 is error\n");
 		
 		errorGlobalFlag = 10;
+		return -1;
 	}
 	
 	
@@ -193,6 +202,7 @@ uint8_t cm_Auth_Encrp_Personal(uint8_t pswMode,uint8_t authMode)
 		printf("cm_WriteConfigZone 0x98 is error\n");
 		
 		errorGlobalFlag = 11;
+		return -1;
 	}
 	
 	
@@ -213,30 +223,10 @@ uint8_t cm_Auth_Encrp_Personal(uint8_t pswMode,uint8_t authMode)
 		printf("cm_WriteConfigZone 0xB8 is error\n");
 		
 		errorGlobalFlag = 12;
+		return -1;
 	}
 	
-#if 0
-	//---------------------ATTENTION------------------------ change password write 7,then the config zone must input correct secret while not the default secret,in's effect same to burn fuse
-	// user must set and remember this secret for password for write/read.then must be same whih cm_Auth_Encrp_rw before access to user zone for write or read .
-	pwData[0] = 0xFF;
-	pwData[1] = 'S';
-	pwData[2] = 'T';
-	pwData[3] = 'R';
-	pwData[4] = 0xFF;
-	pwData[5] = 0xFF;
-	pwData[6] = 0xFF;
-	pwData[7] = 0xFF;
-	ucReturn = cm_WriteConfigZone(0xE8, pwData, 8, FALSE);
-	if (ucReturn != SUCCESS) 
-	{
-		printf("cm_WriteConfigZone 0xB8 is error\n");
-		
-		errorGlobalFlag = 12;
-	}
-#endif
-	
-	
-#if 0
+#if 1
 	ucReturn = cm_BurnFuse(fab_id);
 	if (ucReturn != SUCCESS) 
 	{

+ 1 - 1
app/bmc/BmcType.h

@@ -85,7 +85,7 @@ typedef struct
 	uint32_t			CurTimerSecond;
 	uint32_t			BootValidMinutes;						//This work time
 	uint32_t			TotalBootValidMinutes;					//Total work time
-	uint32_t			SELTimeSecond;							//seconds from 1970-1-1 00:00:00, UTC
+//	uint32_t			SELTimeSecond;							//seconds from 1970-1-1 00:00:00, UTC
 	
 	//chassis
     uint8_t             SlotID;

+ 39 - 7
app/bmc/SysTimer/TimerTask.c

@@ -9,18 +9,50 @@
 #include "time.h"
 #include <stdint.h>
 #include "main.h"
+#include <signal.h>
 
 static void ProcessTimerReq (void);
 
 //g_BMCInfo.CurTimerTick increment in port.c/xPortSysTickHandler().
-void *TimerTask( void *pvParameters )
+// void *TimerTask( void *pvParameters )
+// {	
+// 	uint32_t preTimerTick = g_BMCInfo.CurTimerTick;
+// 	printf("TimerTask start...\n");
+// 	while(1)
+// 	{
+// 		preTimerTick = g_BMCInfo.CurTimerTick;
+// 		g_BMCInfo.SELTimeSecond++;
+	
+// 		if(g_BMCInfo.SensorSharedMem.SensorTick < 0xffffffff)	
+// 			g_BMCInfo.SensorSharedMem.SensorTick++;
+		
+// 		if(g_BMCInfo.SenConfig.PowerOnTick < 0xffffffff)
+// 			g_BMCInfo.SenConfig.PowerOnTick++;
+		
+// 		if(g_BMCInfo.SenConfig.SysResetTick < 0xffffffff)
+// 			g_BMCInfo.SenConfig.SysResetTick++;
+		
+// 		g_BMCInfo.CurTimerSecond++;
+// 		if(g_BMCInfo.PowerGoodFlag && (g_BMCInfo.CurTimerSecond%60 == 0))	// 1minute
+// 		{
+// 			g_BMCInfo.BootValidMinutes++;
+// 			g_BMCInfo.TotalBootValidMinutes++;
+// 		}
+
+// 		ProcessTimerReq();
+
+// 		sleep(1);
+// 	}
+// }
+
+void TimerTask( int signo )	//signal handler
 {	
-	uint32_t preTimerTick = g_BMCInfo.CurTimerTick;
 	printf("TimerTask start...\n");
-	while(1)
+	switch(signo)
 	{
-		preTimerTick = g_BMCInfo.CurTimerTick;
-		g_BMCInfo.SELTimeSecond++;
+	case SIGALRM:
+		//preTimerTick = g_BMCInfo.CurTimerTick;
+		//g_BMCInfo.SELTimeSecond++;
 	
 		if(g_BMCInfo.SensorSharedMem.SensorTick < 0xffffffff)	
 			g_BMCInfo.SensorSharedMem.SensorTick++;
@@ -39,12 +71,12 @@ void *TimerTask( void *pvParameters )
 		}
 
 		ProcessTimerReq();
-
-		sleep(1);
+		break;
 	}
 }
 
 
+
 /**
 *@fn ProcessTimerReq
 *@brief Executes Timer task function for every one second

+ 2 - 1
app/bmc/SysTimer/TimerTask.h

@@ -1,6 +1,7 @@
 #ifndef __TIMER_TASK_H__
 #define __TIMER_TASK_H__
 
-void *TimerTask( void *pvParameters );
+//void *TimerTask( void *pvParameters );
+void TimerTask( int signo );
 
 #endif

BIN
app/bmc/bmc_app


+ 17 - 11
app/bmc/main.c

@@ -10,6 +10,8 @@
 #include <semaphore.h>
 #include <pthread.h>
 #include <fcntl.h>
+#include <signal.h>
+#include <sys/time.h>
 
 #include "com_BmcType.h"
 #include "com_IPMIDefs.h"
@@ -44,7 +46,6 @@ uint8_t		gThreadIndex = 0;
 static int tmp_fd;
 void main(void)
 {
-	// printf("---> log1\n");
 	// if(0 != cm_Auth_Encrp_Init(1, 1, TRUE))
 	// {
 	// 	printf("Initialize AT88SC0104C failed!\n");
@@ -52,7 +53,6 @@ void main(void)
 	// 	return;
 	// }
 
-	// printf("---> log2\n");
 	// if(0 != cm_Auth_Encrp_Personal(1, 1))
 	// {
 	// 	printf("Personal AT88SC0104C failed!\n");
@@ -60,7 +60,6 @@ void main(void)
 	// 	return ;
 	// }
 
-	// printf("---> log3\n");
 	// if(0 != test_cryptomem())
 	// {
 	// 	while(1)
@@ -70,8 +69,6 @@ void main(void)
 	// 	}
 	// }
 
-	
-
 	PlatformInit();
 	Init_IPMI_FRU_SDR_SEL();
 	InitSdrConfig();
@@ -93,11 +90,20 @@ void main(void)
 	}
 
 	/* Create TimerTask */
-	gThreadIndex = 0;
-	if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,TimerTask,NULL))
-    {
-        printf("%s: Create TimerTask thread failed!\n", __FUNCTION__);
-    }
+	// gThreadIndex = 0;
+	// if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,TimerTask,NULL))
+ //    {
+ //        printf("%s: Create TimerTask thread failed!\n", __FUNCTION__);
+ //    }
+	signal(SIGALRM, TimerTask);
+
+    struct itimerval new_value;
+    new_value.it_value.tv_sec = 0;
+    new_value.it_value.tv_usec = 1;
+    new_value.it_interval.tv_sec = 1;
+    new_value.it_interval.tv_usec = 0;
+    setitimer(ITIMER_REAL, &new_value, NULL);
+
 
 	/* Create MsgHndlr Task */
 	gThreadIndex++;
@@ -163,7 +169,7 @@ void main(void)
     // uint8_t buf[7] = {0x20, 0xb8, 0x8, 0x20, 0x4, 0x1, 0xdb };
     // gThreadIndex++;
     // pthread_create(&gThreadIDs[gThreadIndex],NULL,test_thread,NULL);
-	while(1)
+	while(1)	//在这里实现各线程的健康状态检测,发现出错的线程就重启它。
 	{
 		// if(test_flag)
 		// {