|
@@ -15,6 +15,7 @@
|
|
|
#include "SELRecord.h"
|
|
|
#include "SEL.h"
|
|
|
#include "MsgHndlr.h"
|
|
|
+#include "driver.h"
|
|
|
|
|
|
pthread_mutex_t Flash_Mutex;
|
|
|
|
|
@@ -223,7 +224,6 @@ int Init_IPMI_FRU_SDR_SEL(void)
|
|
|
|
|
|
GetIPMIFromFlash();
|
|
|
if(strncmp(g_BMCInfo.IpmiConfig.FirstPowerOnStr, FirstPowerOnStr, sizeof(FirstPowerOnStr)) != 0)
|
|
|
-// if(1)
|
|
|
{
|
|
|
//first power on
|
|
|
printf("\n\n*** BMC first power on! ***\n\n");
|
|
@@ -283,20 +283,7 @@ int Init_IPMI_FRU_SDR_SEL(void)
|
|
|
|
|
|
|
|
|
|
|
|
- /******************************* Init SEL *************************************/
|
|
|
- pSEL = g_BMCInfo.pSEL;
|
|
|
- ((SELRepository_T*)pSEL)->Signature[0] = 0x00;
|
|
|
- ((SELRepository_T*)pSEL)->Signature[1] = 0x11;
|
|
|
- ((SELRepository_T*)pSEL)->Signature[2] = 0x22;
|
|
|
- ((SELRepository_T*)pSEL)->Signature[3] = 0x33;
|
|
|
- ((SELRepository_T*)pSEL)->NumRecords = 0;
|
|
|
- ((SELRepository_T*)pSEL)->Padding = 0;
|
|
|
- ((SELRepository_T*)pSEL)->AddTimeStamp = 0;
|
|
|
- ((SELRepository_T*)pSEL)->EraseTimeStamp = 0;
|
|
|
- ((SELRepository_T*)pSEL)->FirstRecID = 0;
|
|
|
- ((SELRepository_T*)pSEL)->LastRecID = 0;
|
|
|
- ((SELRepository_T*)pSEL)->SELIndex = 0;
|
|
|
- ((SELRepository_T*)pSEL)->SELRecord = (SELRec_T*)(pSEL + sizeof(SELRepository_T));
|
|
|
+
|
|
|
|
|
|
g_BMCInfo.IpmiConfig.SELConfig.SelReservationID = 0;;
|
|
|
g_BMCInfo.IpmiConfig.SELConfig.LastEvtTS = 0;
|
|
@@ -361,9 +348,9 @@ int Init_IPMI_FRU_SDR_SEL(void)
|
|
|
//Init SDR
|
|
|
GetSDRFromFlash();
|
|
|
|
|
|
- //Init SEL
|
|
|
- GetSELFromFlash();
|
|
|
- ((SELRepository_T*)g_BMCInfo.pSEL)->SELRecord = (SELRec_T*)(g_BMCInfo.pSEL + sizeof(SELRepository_T));
|
|
|
+ // //Init SEL
|
|
|
+ // GetSELFromFlash();
|
|
|
+ // ((SELRepository_T*)g_BMCInfo.pSEL)->SELRecord = (SELRec_T*)(g_BMCInfo.pSEL + sizeof(SELRepository_T));
|
|
|
|
|
|
|
|
|
|
|
@@ -391,6 +378,31 @@ int Init_IPMI_FRU_SDR_SEL(void)
|
|
|
g_BMCInfo.pUserInfo = NULL;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ //Init sel
|
|
|
+ GetSELFromFlash();
|
|
|
+ ((SELRepository_T*)g_BMCInfo.pSEL)->SELRecord = (SELRec_T*)(g_BMCInfo.pSEL + sizeof(SELRepository_T));
|
|
|
+ if( (((SELRepository_T*)g_BMCInfo.pSEL)->Signature[0] != 0x00) ||
|
|
|
+ (((SELRepository_T*)g_BMCInfo.pSEL)->Signature[1] != 0x11) ||
|
|
|
+ (((SELRepository_T*)g_BMCInfo.pSEL)->Signature[2] != 0x22) ||
|
|
|
+ (((SELRepository_T*)g_BMCInfo.pSEL)->Signature[3] != 0x33) )
|
|
|
+ {
|
|
|
+ /******************************* Init SEL *************************************/
|
|
|
+ pSEL = g_BMCInfo.pSEL;
|
|
|
+ ((SELRepository_T*)pSEL)->Signature[0] = 0x00;
|
|
|
+ ((SELRepository_T*)pSEL)->Signature[1] = 0x11;
|
|
|
+ ((SELRepository_T*)pSEL)->Signature[2] = 0x22;
|
|
|
+ ((SELRepository_T*)pSEL)->Signature[3] = 0x33;
|
|
|
+ ((SELRepository_T*)pSEL)->NumRecords = 0;
|
|
|
+ ((SELRepository_T*)pSEL)->Padding = 0;
|
|
|
+ ((SELRepository_T*)pSEL)->AddTimeStamp = 0;
|
|
|
+ ((SELRepository_T*)pSEL)->EraseTimeStamp = 0;
|
|
|
+ ((SELRepository_T*)pSEL)->FirstRecID = 0;
|
|
|
+ ((SELRepository_T*)pSEL)->LastRecID = 0;
|
|
|
+ ((SELRepository_T*)pSEL)->SELIndex = 0;
|
|
|
+ FlushSELToFlash();
|
|
|
+ }
|
|
|
+
|
|
|
g_BMCInfo.IpmiConfig.SDRConfig.UpdatingSDR = FALSE;
|
|
|
g_BMCInfo.IpmiConfig.SDRConfig.UpdatingChannel = 0;
|
|
|
g_BMCInfo.IpmiConfig.SDRConfig.TrackPOffset = 0;
|
|
@@ -994,29 +1006,65 @@ int FlushSELToFlash()
|
|
|
uint32_t offset = 0;
|
|
|
uint32_t selSize = sizeof(SELRepository_T) + sizeof(SELRec_T)*MAX_SEL_RECORD ;
|
|
|
|
|
|
- pthread_mutex_lock(&Flash_Mutex);
|
|
|
+ iflash_t iflash_arg;
|
|
|
+ int ret = 0;
|
|
|
+ int fd = open("/dev/iflash", O_RDWR);
|
|
|
+ ret = ioctl(fd, IFLASH_UNLOCK, NULL);
|
|
|
+ if(ret != 0)
|
|
|
+ {
|
|
|
+ printf("error: ret = %d\n", ret);
|
|
|
+ }
|
|
|
+
|
|
|
+ iflash_arg.sector = 6;
|
|
|
+ ret = ioctl(fd, IFLASH_ERASESECTOR, &iflash_arg);
|
|
|
+ if(ret != 0)
|
|
|
+ {
|
|
|
+ printf("error: ret = %d\n", ret);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**** SEL ****/
|
|
|
+ //pthread_mutex_lock(&Flash_Mutex);
|
|
|
while(selSize > 0)
|
|
|
{
|
|
|
- if(selSize > 4*1024)
|
|
|
- writeLen = 4*1024;
|
|
|
+ if(selSize > 256)
|
|
|
+ writeLen = 256;
|
|
|
else
|
|
|
writeLen = selSize;
|
|
|
|
|
|
- sf_sector_erase(5, SEL_FLASH_ADDR+offset);
|
|
|
- sf_write(5, SEL_FLASH_ADDR+offset, g_BMCInfo.pSEL+offset, writeLen);
|
|
|
+ iflash_arg.address = 0x08040000+offset;
|
|
|
+ iflash_arg.len = writeLen;
|
|
|
+ memcpy(iflash_arg.data, (uint8_t*)g_BMCInfo.pSEL+offset, writeLen);
|
|
|
+ ret = ioctl(fd, IFLASH_WRITEBYTE, &iflash_arg);
|
|
|
+ if(ret != 0)
|
|
|
+ {
|
|
|
+ printf("error: ret = %d\n", ret);
|
|
|
+ }
|
|
|
+
|
|
|
+ // sf_sector_erase(5, SEL_FLASH_ADDR+offset);
|
|
|
+ // sf_write(5, SEL_FLASH_ADDR+offset, g_BMCInfo.pSEL+offset, writeLen);
|
|
|
offset += writeLen;
|
|
|
selSize -= writeLen;
|
|
|
}
|
|
|
- pthread_mutex_unlock(&Flash_Mutex);
|
|
|
+ //pthread_mutex_unlock(&Flash_Mutex);
|
|
|
+ ret = ioctl(fd, IFLASH_LOCK, NULL);
|
|
|
+ if(ret != 0)
|
|
|
+ {
|
|
|
+ printf("error: ret = %d\n", ret);
|
|
|
+ }
|
|
|
+
|
|
|
+ close(fd);
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
int GetSELFromFlash()
|
|
|
{
|
|
|
uint32_t selSize = sizeof(SELRepository_T) + sizeof(SELRec_T)*MAX_SEL_RECORD ;
|
|
|
- pthread_mutex_lock(&Flash_Mutex);
|
|
|
- sf_read(5, SEL_FLASH_ADDR, g_BMCInfo.pSEL, selSize);
|
|
|
- pthread_mutex_unlock(&Flash_Mutex);
|
|
|
+
|
|
|
+ // pthread_mutex_lock(&Flash_Mutex);
|
|
|
+ // sf_read(5, SEL_FLASH_ADDR, g_BMCInfo.pSEL, selSize);
|
|
|
+ // pthread_mutex_unlock(&Flash_Mutex);
|
|
|
+ memcpy(g_BMCInfo.pSEL, (uint8_t*)0x08040000, selSize);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -1125,7 +1173,7 @@ int UpdateUserInfoTble(void)
|
|
|
int UpdateFlash(void)
|
|
|
{
|
|
|
FlushSDRToFlash();
|
|
|
- FlushSELToFlash();
|
|
|
+ //FlushSELToFlash();
|
|
|
FlushIPMIToFlash();
|
|
|
FlushFRUToFlash();
|
|
|
return 0;
|