main.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * bmc_app application main code.
  3. */
  4. #include <stdio.h>
  5. #include <stdint.h>
  6. #include <sys/prctl.h>
  7. #include <semaphore.h>
  8. #include <pthread.h>
  9. #include "com_BmcType.h"
  10. #include "com_IPMIDefs.h"
  11. #include "com_Message.h"
  12. #include "BmcType.h"
  13. #include "main.h"
  14. #include "Session.h"
  15. #include "LANIfc.h"
  16. #include "UDSIfc.h"
  17. #include "IPMBIfc.h"
  18. #include "MsgHndlrTask.h"
  19. #include "ChassisTimerTask.h"
  20. #include "TimerTask.h"
  21. /* gloabl varible */
  22. BMCInfo_t g_BMCInfo;
  23. pthread_t gThreadIDs[256];
  24. uint8_t gThreadIndex = 0;
  25. void main(void)
  26. {
  27. PlatformInit();
  28. Init_IPMI_FRU_SDR_SEL();
  29. InitSdrConfig();
  30. InitSelConfig();
  31. printf("\tChassisID %#02x, SlotID %#02x\r\n", g_BMCInfo.chassisID, g_BMCInfo.SlotID);
  32. if(g_BMCInfo.IpmiConfig.PrimaryIPMBSupport)
  33. {
  34. printf("\tPrimaryIPMBBus: %d, channel %d, Addr %#02x\n", g_BMCInfo.IpmiConfig.PrimaryIPMBBus,
  35. PRIMARY_IPMB_CHANNEL, g_BMCInfo.IpmiConfig.PrimaryIPMBAddr);
  36. }
  37. if(g_BMCInfo.IpmiConfig.SecondaryIPMBSupport)
  38. {
  39. printf("\tSecondaryIPMBBus %d, Channel %d, Addr %#02x\n", g_BMCInfo.IpmiConfig.SecondaryIPMBBus,
  40. SECONDARY_IPMB_CHANNEL, g_BMCInfo.IpmiConfig.SecondaryIPMBAddr);
  41. }
  42. /* Create TimerTask */
  43. gThreadIndex = 0;
  44. if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,TimerTask,NULL))
  45. {
  46. printf("%s: Create TimerTask thread failed!\n", __FUNCTION__);
  47. }
  48. /* Create MsgHndlr Task */
  49. gThreadIndex++;
  50. if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,MsgHndlrTask,NULL))
  51. {
  52. printf("%s: Create MsgHndlrTask thread failed!\n", __FUNCTION__);
  53. }
  54. /* Create ChassisTimerTask */
  55. gThreadIndex++;
  56. if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,ChassisTimerTask,NULL))
  57. {
  58. printf("%s: Create ChassisTimerTask thread failed!\n", __FUNCTION__);
  59. }
  60. /* Create SensorMonitorTask */
  61. gThreadIndex++;
  62. if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,SensorMonitorTask,NULL))
  63. {
  64. printf("%s: Create SensorMonitorTask thread failed!\n", __FUNCTION__);
  65. }
  66. /* Create UDS interface */
  67. gThreadIndex++;
  68. if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,UDSIfcTask,NULL))
  69. {
  70. printf("%s: Create UDSIfcTask thread failed!\n", __FUNCTION__);
  71. }
  72. /* Create LAN interface */
  73. gThreadIndex++;
  74. if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,LANIfcTask,NULL))
  75. {
  76. printf("%s: Create LANIfcTask thread failed!\n", __FUNCTION__);
  77. }
  78. /* Create IPMB interface */
  79. uint8_t primaryIpmbSelect = 0; //primary
  80. gThreadIndex++;
  81. if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,IPMBIfcTask,&primaryIpmbSelect))
  82. {
  83. printf("%s: Create LANIfcTask thread failed!\n", __FUNCTION__);
  84. }
  85. uint8_t secondaryIpmbSelect = 1; //secondary
  86. gThreadIndex++;
  87. if(0 != pthread_create(&gThreadIDs[gThreadIndex],NULL,IPMBIfcTask,&secondaryIpmbSelect))
  88. {
  89. printf("%s: Create LANIfcTask thread failed!\n", __FUNCTION__);
  90. }
  91. /* Create Update FPGA thread */
  92. /* Create UDS interface */
  93. /* Create UDS interface */
  94. /* Create UDS interface */
  95. UpdateUserInfoTable();
  96. while(1)
  97. {
  98. sleep(100);
  99. //printf("Hello...\n");
  100. }
  101. }