#include #include #include #include #include "main.h" #include "Api.h" #include "SDRRecord.h" #include "SELRecord.h" #include "SEL.h" int InitSdrConfig(void) { printf("Init SDR Config...\r\n"); g_BMCInfo.SDRConfig.SDRError = 0; g_BMCInfo.SDRConfig.UpdatingSDR = FALSE; g_BMCInfo.SDRConfig.UpdatingChannel = 0; g_BMCInfo.SDRConfig.TrackPOffset = 0; g_BMCInfo.SDRConfig.TrackRecID = 0; g_BMCInfo.SDRConfig.ReservationID = 0; g_BMCInfo.SDRConfig.IPMB_Seqnum = 0; g_BMCInfo.SDRConfig.PartAddbytes = 0; g_BMCInfo.SDRConfig.LatestRecordID = 0; g_BMCInfo.SDRConfig.NumMarkedRecords = 0; g_BMCInfo.SDRConfig.SDRRAM = (SDRRepository_T*)g_BMCInfo.pSDR; g_BMCInfo.SDRConfig.RepositoryInfo.Version = 0x51; g_BMCInfo.SDRConfig.RepositoryInfo.RecCt = ((SDRRepository_T*)g_BMCInfo.SDRConfig.SDRRAM)->NumRecords; g_BMCInfo.SDRConfig.RepositoryInfo.FreeSpace = 0xffff; g_BMCInfo.SDRConfig.RepositoryInfo.AddTimeStamp = 0; g_BMCInfo.SDRConfig.RepositoryInfo.EraseTimeStamp = 0; g_BMCInfo.SDRConfig.RepositoryInfo.OpSupport = 0x23; //TODO: g_BMCInfo.SDRConfig.RepositoryAllocInfo.NumAllocUnits = 0; g_BMCInfo.SDRConfig.RepositoryAllocInfo.AllocUnitSize = 0; g_BMCInfo.SDRConfig.RepositoryAllocInfo.NumFreeAllocUnits = 0; g_BMCInfo.SDRConfig.RepositoryAllocInfo.LargestFreeBlock = 0; g_BMCInfo.SDRConfig.RepositoryAllocInfo.MaxRecSize = 0; return 0; } int InitSelConfig(void) { g_BMCInfo.SELConfig.SelReservationID = 0;; g_BMCInfo.SELConfig.LastEvtTS = 0; g_BMCInfo.SELConfig.PartialAddRecordID = 0; g_BMCInfo.SELConfig.PartialAddRecOffset = 0; g_BMCInfo.SELConfig.PartialAdd = 0; g_BMCInfo.SELConfig.SenMonSELFlag = 0; g_BMCInfo.SELConfig.MaxSELRecord = MAX_SEL_RECORD; // g_BMCInfo.SELConfig.RsrvIDCancelled = FALSE; g_BMCInfo.SELConfig.SELOverFlow = FALSE; g_BMCInfo.SELConfig.selalmostfull = 0; // SELEventRecord_T SelPartialAddRecord; // g_BMCInfo.SELConfig.SELEventMsg [16]; return 0; } int PlatformInit(void) { uint8_t PrimaryIPMBBusNum, SecondaryIPMBBusNum; printf("Init Platform...\r\n"); g_BMCInfo.SelfTestByte = 0; g_BMCInfo.SlotID = PDK_GetSlotID(); g_BMCInfo.chassisID = PDK_GetChassisID(); // g_BMCInfo.PrimaryIPMBBus = PRIMARY_IPMB; // g_BMCInfo.SecondaryIPMBBus = SECONDARY_IPMB; // g_BMCInfo.PrimaryIPMBAddr = PRIMARY_IPMB_ADDR; // g_BMCInfo.SecondaryIPMBAddr = SECONDARY_IPMB_ADDR; // g_BMCInfo.SendMsgSeqNum = 0; g_BMCInfo.ChassisIdentify = FALSE; //init DevGUID g_BMCInfo.DeviceGUID[0] = 0x01; g_BMCInfo.DeviceGUID[1] = 0x01; g_BMCInfo.DeviceGUID[2] = 0x01; g_BMCInfo.DeviceGUID[3] = 0x01; g_BMCInfo.DeviceGUID[4] = 0x01; g_BMCInfo.DeviceGUID[5] = 0x01; g_BMCInfo.DeviceGUID[6] = 0x01; g_BMCInfo.DeviceGUID[7] = 0x01; g_BMCInfo.DeviceGUID[8] = 0x01; g_BMCInfo.DeviceGUID[9] = 0x01; g_BMCInfo.DeviceGUID[10] = 0x01; g_BMCInfo.DeviceGUID[11] = 0x01; g_BMCInfo.DeviceGUID[12] = 0x01; g_BMCInfo.DeviceGUID[13] = 0x01; g_BMCInfo.DeviceGUID[14] = 0x01; g_BMCInfo.DeviceGUID[15] = 0x01; g_BMCInfo.FwMajorVer = FW_VERSION_MAJOR; g_BMCInfo.FwMinorVer = FW_VERSION_MINOR; // g_BMCInfo.OemFlags.BladeWorkMode = BLADE_IPMC; // g_BMCInfo.OemFlags.chassisManageFnEnable = 0; // g_BMCInfo.OemFlags.thisBladeIndex = 0; // g_BMCInfo.OemFlags.bladeStatus = 1; //0: not present, 1: normal, 2: error, others: reserved. g_BMCInfo.HealthLevel = SENSOR_STATUS_NORMAL; g_BMCInfo.SensorSharedMem.SensorTick= 0; g_BMCInfo.SenConfig.PowerOnTick = 0; g_BMCInfo.SenConfig.SysResetTick = 0; g_BMCInfo.CurTimerTick = 0; g_BMCInfo.CurTimerSecond = 0; g_BMCInfo.BootValidMinutes = 0; g_BMCInfo.pUserInfo = NULL; return 0; } const char FirstPowerOnStr[] = "First power on the bmc"; int Init_IPMI_FRU_SDR_SEL(void) { int i; uint32_t sdrSize = sizeof(SDRRepository_T) + sizeof(HdrMgmtCtrlrDevLocator_T) + sizeof(HdrFullSensorRec_T)*SENSOR_NUMBERS; uint32_t selSize = sizeof(SELRepository_T) + sizeof(SELRec_T)*MAX_SEL_RECORD ; uint8_t* pSDR = NULL; uint8_t* pSEL = NULL; g_BMCInfo.pSDR = malloc(sdrSize); if((g_BMCInfo.pSDR == NULL) && (sdrSize != 0)) { printf("g_BMCInfo.pSDR Malloc failed!\r\n"); } g_BMCInfo.pSEL = malloc(selSize); if((g_BMCInfo.pSDR == NULL) && (selSize != 0)) { printf("g_BMCInfo.pSEL Malloc failed!\r\n"); } // FLASH_GetIPMI(&g_BMCInfo.IpmiConfig); // if(strncmp(g_BMCInfo.IpmiConfig.FirstPowerOnStr, FirstPowerOnStr, sizeof(FirstPowerOnStr)) != 0) if(1) { //first power on printf("BMC first power on!\r\n"); /************************** Init IPMI ******************************/ memcpy(g_BMCInfo.IpmiConfig.FirstPowerOnStr, FirstPowerOnStr, sizeof(FirstPowerOnStr)); g_BMCInfo.IpmiConfig.GrpExtnSupport = GROUP_EXTERN_SUPPORT; g_BMCInfo.IpmiConfig.ChassisTimerInterval = CHASSIS_TIMER_INTERVAL; g_BMCInfo.IpmiConfig.PowerCycleInterval = PWR_CYCLE_INTERVAL; g_BMCInfo.IpmiConfig.FanControlInterval = FAN_CONTROL_INTERVAL; g_BMCInfo.IpmiConfig.RearmSetSensorThreshold = REARM_SET_SENSOR_THRESHOLD; g_BMCInfo.IpmiConfig.SELTimeUTCOffset = 8*60; //IPMB g_BMCInfo.IpmiConfig.PrimaryIPMBSupport = PRIMARY_IPMB_SUPPORT; g_BMCInfo.IpmiConfig.SecondaryIPMBSupport = SECONDARY_IPMB_SUPPORT; g_BMCInfo.IpmiConfig.PrimaryIPMBBus = PRIMARY_IPMB_BUS; g_BMCInfo.IpmiConfig.SecondaryIPMBBus = SECONDARY_IPMB_BUS; g_BMCInfo.IpmiConfig.PrimaryIPMBAddr = PRIMARY_IPMB_ADDR; g_BMCInfo.IpmiConfig.SecondaryIPMBAddr = SECONDARY_IPMB_ADDR; // //set default user // memset(g_BMCInfo.IpmiConfig.UserInfoTbl, 0, sizeof(UserInfo_T)*MAX_USER_NUM); // g_BMCInfo.IpmiConfig.UserInfoTbl[0].ID = USER_ID; // g_BMCInfo.IpmiConfig.UserInfoTbl[0].UserId = 1; // g_BMCInfo.IpmiConfig.UserInfoTbl[0].MaxPasswordSize = 20; // g_BMCInfo.IpmiConfig.UserInfoTbl[0].UserStatus = TRUE; // g_BMCInfo.IpmiConfig.UserInfoTbl[0].ChannelAccess = 0x34; // g_BMCInfo.IpmiConfig.UserInfoTbl[0].MaxPasswordSize = 20; // memcpy(g_BMCInfo.IpmiConfig.UserInfoTbl[0].UserName, USER_NAME, sizeof(USER_NAME)); // memcpy(g_BMCInfo.IpmiConfig.UserInfoTbl[0].UserPassword, PASS_WORD, sizeof(PASS_WORD)); // g_BMCInfo.IpmiConfig.CurrentNoUser = 1; //Init FRU memcpy(&g_BMCInfo.FRU, &Default_FRUData, sizeof(OemFRUData_T)); /************************ Init SDR *************************************/ pSDR = g_BMCInfo.pSDR; //init SDR repository header ((SDRRepository_T*)pSDR)->Signature[0] = 0x00; ((SDRRepository_T*)pSDR)->Signature[1] = 0x11; ((SDRRepository_T*)pSDR)->Signature[2] = 0x22; ((SDRRepository_T*)pSDR)->Signature[3] = 0x33; ((SDRRepository_T*)pSDR)->NumRecords = SENSOR_NUMBERS + 1; ((SDRRepository_T*)pSDR)->Size = sdrSize; ((SDRRepository_T*)pSDR)->AddTimeStamp = 0; ((SDRRepository_T*)pSDR)->EraseTimeStamp = 0; //init MgmtCtrlrDevLocator SDR pSDR += sizeof(SDRRepository_T); ((HdrMgmtCtrlrDevLocator_T*)pSDR)->Valid = 1; ((HdrMgmtCtrlrDevLocator_T*)pSDR)->Len = sizeof(HdrMgmtCtrlrDevLocator_T); memcpy(&(((HdrMgmtCtrlrDevLocator_T*)pSDR)->MgmtCtrlrDevLocator), &bmc_sdr, sizeof(MgmtCtrlrDevLocator_T)); //init FullSensorRec SDR pSDR += sizeof(HdrMgmtCtrlrDevLocator_T); for(i=0;iValid = 1; ((HdrFullSensorRec_T*)pSDR)->Len = sizeof(HdrFullSensorRec_T); memcpy(&(((HdrFullSensorRec_T*)pSDR)->FullSensorRec), &full_sdr_tbl[i], sizeof(FullSensorRec_T)); pSDR += sizeof(HdrFullSensorRec_T); } /******************************* 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)); UpdateFlash(); } else { // //Init FRU // FLASH_GetFRU(&g_BMCInfo.FRU); // //Init SDR // FLASH_GetSDR(g_BMCInfo.pSDR, sdrSize); // //Init SEL // FLASH_GetSEL(g_BMCInfo.pSEL, selSize); } return 0; } int UpdateFlash(void) { //TODO: return 0; } int SetSysTime(uint32_t *timeSecond) { g_BMCInfo.SELTimeSecond = *timeSecond; return 0; } int GetSysTime(void) { return g_BMCInfo.SELTimeSecond; } int PostEventMessage (uint8_t *EventMsg,uint8_t size) { uint8_t SelReq [sizeof(SELEventRecord_T)]; uint8_t SelRes [sizeof(AddSELRes_T)]; SELEventRecord_T* SelRecord = ( SELEventRecord_T*) SelReq; SelRecord->hdr.Type = 0x02; SelRecord->hdr.TimeStamp = GetSysTime (); memcpy (SelRecord->GenID, EventMsg, size); LockedAddSELEntry(SelReq, sizeof (SELEventRecord_T), SelRes); return 0; } uint8_t PDK_GetSlotID(void) { ; } uint8_t PDK_GetChassisID(void) { ; } int PDK_PowerOffChassis(void) { ; } int PDK_PowerOnChassis(void) { ; } int PDK_SoftOffChassis(void) { ; } int PDK_PowerCycleChassis(void) { ; } int PDK_ResetChassis(void) { ; } int PDK_DiagInterruptChassis(void) { ; } int PDK_FanControl(void) { ; }