123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302 |
- #include <stdio.h>
- #include <stdint.h>
- #include <sys/prctl.h>
- #include <semaphore.h>
- #include <pthread.h>
- #include <stdlib.h>
- #include "linux/fcntl.h"
- #include <signal.h>
- #include <sys/time.h>
- #include "com_BmcType.h"
- #include "com_IPMIDefs.h"
- #include "com_Message.h"
- #include "BmcType.h"
- #include "main.h"
- #include "Session.h"
- #include "LANIfc.h"
- #include "UDSIfc.h"
- #include "IPMBIfc.h"
- #include "MsgHndlrTask.h"
- #include "ChassisTimerTask.h"
- #include "TimerTask.h"
- #include "CM_LIB.h"
- #include "stm32f429xx.h"
- #include "com_gpio.h"
- #include "hal_interface_api.h"
- #include "com_BMCCfg.h"
- #include "PendActionTask.h"
- #include "Api.h"
- #include "driver.h"
- #include "sensor_tbl.h"
- #include "com_IPMI_SDRRecord.h"
- #include "AuthLicense.h"
- BMCInfo_t g_BMCInfo;
- pthread_t gThreadIDs[256];
- uint8_t gThreadIndex = 0;
- uint8_t gChassisIPMBAddr[BLADE_NUMBERS] = {0x82, 0x84, 0x86, 0x88, 0x8A, 0x8C,
- 0x8E, 0x90, 0x92, 0x94};
- SensorHistoryInfo_T gSensorHistoryInfo[SENSOR_NUMBERS];
- FanInfo_T gFanInfo[FAN_NUMBERS] = {
-
- {0, {"Fan1"}, 0, 0, 0 },
- {1, {"Fan2"}, 0, 0, 0 },
- {2, {"Fan3"}, 0, 0, 0 },
- {3, {"Fan4"}, 0, 0, 0 },
- };
- BladeStatus_T gBladeStatus[BLADE_NUMBERS] = {
-
- { 0, 0, "---", 0, 0},
- { 0, 0, "---", 0, 0},
- { 0, 0, "---", 0, 0},
- { 0, 0, "---", 0, 0},
- { 0, 0, "---", 0, 0},
- { 0, 0, "---", 0, 0},
- { 0, 0, "---", 0, 0},
- { 0, 0, "---", 0, 0},
- { 0, 0, "---", 0, 0},
- { 0, 0, "---", 0, 0},
- };
- static int tmp_fd;
- void main(void)
- {
-
- if(CheckLicense() != 0)
- {
- system("killall -9 damon.sh");
- exit(0);
- }
- PlatformInit();
- Init_IPMI_FRU_SDR_SEL();
- Init_SessionTbl();
- InitTimerTaskTbl();
- InitChannelTab();
- pthread_mutex_init(&api_bridge_mutex, NULL);
- pthread_mutex_init(&Flash_Mutex, NULL);
-
- system("date -s 2020.05.12-00:00:00");
-
- char cmdStr[100];
- LanInfo_T *pSetLanInfo = &g_BMCInfo.IpmiConfig.LanInfo[0];
-
-
-
-
-
-
-
-
-
-
-
-
- sprintf(cmdStr, "ifconfig eth0 %d.%d.%d.%d broadcast %d.%d.%d.%d netmask %d.%d.%d.%d up",
- 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);
- printf("\tChassisID %#02x, SlotID %#02x\r\n", g_BMCInfo.ChassisID, g_BMCInfo.SlotID);
- if(g_BMCInfo.IpmiConfig.PrimaryIPMBSupport)
- {
- printf("\tPrimaryIPMBBus: %d, channel %d, Addr %#02x\n", g_BMCInfo.IpmiConfig.PrimaryIPMBBus,
- PRIMARY_IPMB_CHANNEL, g_BMCInfo.PrimaryIPMBAddr);
- }
- if(g_BMCInfo.IpmiConfig.SecondaryIPMBSupport)
- {
- printf("\tSecondaryIPMBBus %d, Channel %d, Addr %#02x\n", g_BMCInfo.IpmiConfig.SecondaryIPMBBus,
- SECONDARY_IPMB_CHANNEL, g_BMCInfo.SecondaryIPMBAddr);
- }
-
- 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);
-
- if(-1 != access(BRIDGE_QUEUE, F_OK))
- {
- remove(BRIDGE_QUEUE);
- }
- if(0 != mkfifo (BRIDGE_QUEUE, 0777))
- {
- printf("%s: Create %s fifo failed! \n", __FUNCTION__, BRIDGE_QUEUE);
- }
-
- gThreadIndex++;
- if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,MsgHndlrTask,NULL))
- {
- printf("%s: Create MsgHndlrTask thread failed!\n", __FUNCTION__);
- }
-
- gThreadIndex++;
- if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,ChassisTimerTask,NULL))
- {
- printf("%s: Create ChassisTimerTask thread failed!\n", __FUNCTION__);
- }
-
- gThreadIndex++;
- if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,SensorMonitorTask,NULL))
- {
- printf("%s: Create SensorMonitorTask thread failed!\n", __FUNCTION__);
- }
-
- gThreadIndex++;
- if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,UDSIfcTask,NULL))
- {
- printf("%s: Create UDSIfcTask thread failed!\n", __FUNCTION__);
- }
-
- gThreadIndex++;
- if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,LANIfcTask,NULL))
- {
- printf("%s: Create LANIfcTask thread failed!\n", __FUNCTION__);
- }
-
- uint8_t primaryIpmbSelect = 0;
- gThreadIndex++;
- if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,IPMBIfcTask,&primaryIpmbSelect))
- {
- printf("%s: Create LANIfcTask thread failed!\n", __FUNCTION__);
- }
- uint8_t secondaryIpmbSelect = 1;
- gThreadIndex++;
- if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,IPMBIfcTask,&secondaryIpmbSelect))
- {
- printf("%s: Create LANIfcTask thread failed!\n", __FUNCTION__);
- }
-
- gThreadIndex++;
- if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,PendActionTask,NULL))
- {
- printf("%s: Create PendActionTask thread failed!\n", __FUNCTION__);
- }
-
-
-
-
-
-
-
-
-
-
-
-
- while(1)
- {
-
-
-
-
-
- sleep(10);
- }
- }
|