8 Commits ca50975265 ... 156020572e

Author SHA1 Message Date
  zhangbo 156020572e getSysInfo LSB first 3 years ago
  zhangbo c40be2f1c0 add adctool, gpiotool and i2ctool 3 years ago
  zhangbo 26cb878771 optimize MsgHndlrTask 3 years ago
  zhangbo 8b8b2328f8 backup 3 years ago
  zhangbo 5db258f6de maybe everything is ok 3 years ago
  zhangbo fc0e5f2a29 backup 3 years ago
  zhangbo d9e93c1c99 get sensor history, get run time, chassis identify 3 years ago
  zhangbo ce409b9cf0 history hal ok 3 years ago
78 changed files with 2029 additions and 2342 deletions
  1. 3 0
      GD32F450_BMC_BaseCode.initramfs
  2. BIN
      app/AuthLicense/authlicense
  3. 0 612
      app/AuthLicense/iflash.c
  4. 0 8
      app/AuthLicense/iflash.h
  5. 8 0
      app/Makefile
  6. BIN
      app/NCP81111_Config/ncp81111_cfg
  7. BIN
      app/UpdateFirmware/updateFW_app
  8. 49 0
      app/adctool/Makefile
  9. BIN
      app/adctool/adctool
  10. 42 0
      app/adctool/adctool_main.c
  11. 88 25
      app/bmc/Api.c
  12. 1 0
      app/bmc/Api.h
  13. 4 2
      app/bmc/BmcType.h
  14. 1 1
      app/bmc/Makefile
  15. 8 1
      app/bmc/SysTimer/TimerTask.c
  16. 22 28
      app/bmc/ipmb/IPMBIfc.c
  17. 10 0
      app/bmc/main.c
  18. 1 1
      app/bmc/main.h
  19. 0 1
      app/bmc/message.c
  20. 1 0
      app/bmc/msghndlr/App/AppDevice/AppDevice.c
  21. 5 7
      app/bmc/msghndlr/Chassis/ChassisDevice.c
  22. 1 1
      app/bmc/msghndlr/Chassis/ChassisDevice.h
  23. 30 35
      app/bmc/msghndlr/MsgHndlrTask.c
  24. 2 0
      app/bmc/msghndlr/OemSMMCmds/OemSMMCmds.c
  25. 75 72
      app/bmc/msghndlr/PDKCmds.c
  26. 4 1
      app/bmc/msghndlr/PDKCmds.h
  27. 2 20
      app/bmc/msghndlr/SensorEvent/SensorDevice/SensorMonitor.c
  28. 5 45
      app/bmc/msghndlr/Storage/SELDevice/SEL.c
  29. 158 11
      app/bmc/msghndlr/Storlead/Storlead.c
  30. 3 0
      app/bmc/msghndlr/Storlead/Storlead.h
  31. 0 922
      app/bmc/msghndlr/cmdselect.c
  32. 0 57
      app/bmc/msghndlr/cmdselect.h
  33. 5 1
      app/bmc/readme.txt
  34. 1 1
      app/bmc/sensor_sdr.c
  35. 9 16
      app/bmc/uds/UDSIfc.c
  36. 2 1
      app/common_include/com_BMCCfg.h
  37. 0 11
      app/common_include/com_BmcType.h
  38. 0 7
      app/common_include/com_IPMI_ChassisDevice.h
  39. 23 9
      app/common_include/com_IPMI_SEL.h
  40. 3 0
      app/common_include/com_IPMI_Storlead.h
  41. BIN
      app/driver/InternalFlash/iflash.ko
  42. 1 1
      app/driver/driver.h
  43. 10 10
      app/goahead-3.6.5/src/auth.c
  44. 1 1
      app/goahead-3.6.5/src/cJSON/cJSON.c
  45. 13 28
      app/goahead-3.6.5/src/goahead-mbedtls/goahead-mbedtls.c
  46. 4 4
      app/goahead-3.6.5/src/goahead.c
  47. 4 44
      app/goahead-3.6.5/src/goahead.h
  48. 15 15
      app/goahead-3.6.5/src/http.c
  49. 10 0
      app/goahead-3.6.5/src/libipmi/inc/libipmi_ChassisDevice.h
  50. 6 0
      app/goahead-3.6.5/src/libipmi/inc/libipmi_storlead_OEM.h
  51. 114 44
      app/goahead-3.6.5/src/libipmi/src/libipmi_Chassis.c
  52. 2 4
      app/goahead-3.6.5/src/libipmi/src/libipmi_StorDevice.c
  53. 9 4
      app/goahead-3.6.5/src/libipmi/src/libipmi_session.c
  54. 183 17
      app/goahead-3.6.5/src/libipmi/src/libipmi_storlead_OEM.c
  55. 3 2
      app/goahead-3.6.5/src/libipmi/src/sensor_helpers.c
  56. 4 0
      app/goahead-3.6.5/src/libipmi/src/userinfo.c
  57. 8 8
      app/goahead-3.6.5/src/route.c
  58. 17 17
      app/goahead-3.6.5/src/runtime.c
  59. 4 4
      app/goahead-3.6.5/src/socket.c
  60. 4 5
      app/goahead-3.6.5/src/upload.c
  61. 6 6
      app/goahead-3.6.5/src/utils/gopass.c
  62. 185 22
      app/goahead-3.6.5/src/web_interface/src/config.c
  63. 14 10
      app/goahead-3.6.5/src/web_interface/src/fw_update.c
  64. 58 61
      app/goahead-3.6.5/src/web_interface/src/sel.c
  65. 115 132
      app/goahead-3.6.5/src/web_interface/src/server_health.c
  66. 49 0
      app/gpiotool/Makefile
  67. BIN
      app/gpiotool/adctool
  68. BIN
      app/gpiotool/gpiotool
  69. 280 0
      app/gpiotool/gpiotool_main.c
  70. 7 7
      app/hal_api/hal_spi_interface.c
  71. BIN
      app/i2c_scan/i2c-scan
  72. 49 0
      app/i2ctool/Makefile
  73. BIN
      app/i2ctool/i2ctool
  74. 197 0
      app/i2ctool/i2ctool_main.c
  75. 49 0
      app/spitool/Makefile
  76. BIN
      app/spitool/spitool
  77. 42 0
      app/spitool/spitool_main.c
  78. BIN
      app/test_app/test_app

+ 3 - 0
GD32F450_BMC_BaseCode.initramfs

@@ -163,6 +163,9 @@ file /usr/bin/ncp81111_cfg ${INSTALL_ROOT}/projects/${SAMPLE}/app/NCP81111_Confi
 file /usr/bin/damon.sh ${INSTALL_ROOT}/projects/${SAMPLE}/app/damon.sh 777 0 0
 file /usr/bin/damon.sh ${INSTALL_ROOT}/projects/${SAMPLE}/app/damon.sh 777 0 0
 file /usr/bin/ipmitool ${INSTALL_ROOT}/projects/${SAMPLE}/app/ipmitool-1.8.18/ipmitool 755 0 0
 file /usr/bin/ipmitool ${INSTALL_ROOT}/projects/${SAMPLE}/app/ipmitool-1.8.18/ipmitool 755 0 0
 file /usr/bin/authlicense ${INSTALL_ROOT}/projects/${SAMPLE}/app/AuthLicense/authlicense 755 0 0
 file /usr/bin/authlicense ${INSTALL_ROOT}/projects/${SAMPLE}/app/AuthLicense/authlicense 755 0 0
+file /usr/bin/adctool ${INSTALL_ROOT}/projects/${SAMPLE}/app/adctool/adctool 755 0 0
+file /usr/bin/gpiotool ${INSTALL_ROOT}/projects/${SAMPLE}/app/gpiotool/gpiotool 755 0 0
+file /usr/bin/i2ctool ${INSTALL_ROOT}/projects/${SAMPLE}/app/i2ctool/i2ctool 755 0 0
 
 
 dir /etc/goahead 755 0 0 
 dir /etc/goahead 755 0 0 
 dir /var/www 755 0 0
 dir /var/www 755 0 0

BIN
app/AuthLicense/authlicense


+ 0 - 612
app/AuthLicense/iflash.c

@@ -1,612 +0,0 @@
-
-#include "iflash.h"
-
-enum {RESET = 0, SET = !RESET};
-
-#define     __IO    volatile 
-
-/* Base address of the Flash sectors */ 
-#define ADDR_FLASH_SECTOR_0     ((uint32_t)0x08000000) /* Base address of Sector 0, 16 Kbytes   */
-#define ADDR_FLASH_SECTOR_1     ((uint32_t)0x08004000) /* Base address of Sector 1, 16 Kbytes   */
-#define ADDR_FLASH_SECTOR_2     ((uint32_t)0x08008000) /* Base address of Sector 2, 16 Kbytes   */
-#define ADDR_FLASH_SECTOR_3     ((uint32_t)0x0800C000) /* Base address of Sector 3, 16 Kbytes   */
-#define ADDR_FLASH_SECTOR_4     ((uint32_t)0x08010000) /* Base address of Sector 4, 64 Kbytes   */
-#define ADDR_FLASH_SECTOR_5     ((uint32_t)0x08020000) /* Base address of Sector 5, 128 Kbytes  */
-#define ADDR_FLASH_SECTOR_6     ((uint32_t)0x08040000) /* Base address of Sector 6, 128 Kbytes  */
-#define ADDR_FLASH_SECTOR_7     ((uint32_t)0x08060000) /* Base address of Sector 7, 128 Kbytes  */
-#define ADDR_FLASH_SECTOR_8     ((uint32_t)0x08080000) /* Base address of Sector 8, 128 Kbytes  */
-#define ADDR_FLASH_SECTOR_9     ((uint32_t)0x080A0000) /* Base address of Sector 9, 128 Kbytes  */
-#define ADDR_FLASH_SECTOR_10    ((uint32_t)0x080C0000) /* Base address of Sector 10, 128 Kbytes */
-#define ADDR_FLASH_SECTOR_11    ((uint32_t)0x080E0000) /* Base address of Sector 11, 128 Kbytes */
-
-#define ADDR_FLASH_SECTOR_12     ((uint32_t)0x08100000) /* Base address of Sector 12, 16 Kbytes  */
-#define ADDR_FLASH_SECTOR_13     ((uint32_t)0x08104000) /* Base address of Sector 13, 16 Kbytes  */
-#define ADDR_FLASH_SECTOR_14     ((uint32_t)0x08108000) /* Base address of Sector 14, 16 Kbytes  */
-#define ADDR_FLASH_SECTOR_15     ((uint32_t)0x0810C000) /* Base address of Sector 15, 16 Kbytes  */
-#define ADDR_FLASH_SECTOR_16     ((uint32_t)0x08110000) /* Base address of Sector 16, 64 Kbytes  */
-#define ADDR_FLASH_SECTOR_17     ((uint32_t)0x08120000) /* Base address of Sector 17, 128 Kbytes */
-#define ADDR_FLASH_SECTOR_18     ((uint32_t)0x08140000) /* Base address of Sector 18, 128 Kbytes */
-#define ADDR_FLASH_SECTOR_19     ((uint32_t)0x08160000) /* Base address of Sector 19, 128 Kbytes */
-#define ADDR_FLASH_SECTOR_20     ((uint32_t)0x08180000) /* Base address of Sector 20, 128 Kbytes */
-#define ADDR_FLASH_SECTOR_21     ((uint32_t)0x081A0000) /* Base address of Sector 21, 128 Kbytes */
-#define ADDR_FLASH_SECTOR_22     ((uint32_t)0x081C0000) /* Base address of Sector 22, 128 Kbytes */
-#define ADDR_FLASH_SECTOR_23     ((uint32_t)0x081E0000) /* Base address of Sector 23, 128 Kbytes */
-
-#define SECTOR_MASK               ((uint32_t)0xFFFFFF07)
-
-
-/** @defgroup FLASH_Flags 
-  * @{
-  */ 
-#define FLASH_FLAG_EOP                 ((uint32_t)0x00000001)  /*!< FLASH End of Operation flag               */
-#define FLASH_FLAG_OPERR               ((uint32_t)0x00000002)  /*!< FLASH operation Error flag                */
-#define FLASH_FLAG_WRPERR              ((uint32_t)0x00000010)  /*!< FLASH Write protected error flag          */
-#define FLASH_FLAG_PGAERR              ((uint32_t)0x00000020)  /*!< FLASH Programming Alignment error flag    */
-#define FLASH_FLAG_PGPERR              ((uint32_t)0x00000040)  /*!< FLASH Programming Parallelism error flag  */
-#define FLASH_FLAG_PGSERR              ((uint32_t)0x00000080)  /*!< FLASH Programming Sequence error flag     */
-#define FLASH_FLAG_RDERR               ((uint32_t)0x00000100)  /*!< Read Protection error flag (PCROP)        */
-#define FLASH_FLAG_BSY                 ((uint32_t)0x00010000)  /*!< FLASH Busy flag                           */ 
-
-/** @defgroup FLASH_Sectors
-  * @{
-  */
-#define FLASH_Sector_0     ((uint16_t)0x0000) /*!< Sector Number 0   */
-#define FLASH_Sector_1     ((uint16_t)0x0008) /*!< Sector Number 1   */
-#define FLASH_Sector_2     ((uint16_t)0x0010) /*!< Sector Number 2   */
-#define FLASH_Sector_3     ((uint16_t)0x0018) /*!< Sector Number 3   */
-#define FLASH_Sector_4     ((uint16_t)0x0020) /*!< Sector Number 4   */
-#define FLASH_Sector_5     ((uint16_t)0x0028) /*!< Sector Number 5   */
-#define FLASH_Sector_6     ((uint16_t)0x0030) /*!< Sector Number 6   */
-#define FLASH_Sector_7     ((uint16_t)0x0038) /*!< Sector Number 7   */
-#define FLASH_Sector_8     ((uint16_t)0x0040) /*!< Sector Number 8   */
-#define FLASH_Sector_9     ((uint16_t)0x0048) /*!< Sector Number 9   */
-#define FLASH_Sector_10    ((uint16_t)0x0050) /*!< Sector Number 10  */
-#define FLASH_Sector_11    ((uint16_t)0x0058) /*!< Sector Number 11  */
-#define FLASH_Sector_12    ((uint16_t)0x0080) /*!< Sector Number 12  */
-#define FLASH_Sector_13    ((uint16_t)0x0088) /*!< Sector Number 13  */
-#define FLASH_Sector_14    ((uint16_t)0x0090) /*!< Sector Number 14  */
-#define FLASH_Sector_15    ((uint16_t)0x0098) /*!< Sector Number 15  */
-#define FLASH_Sector_16    ((uint16_t)0x00A0) /*!< Sector Number 16  */
-#define FLASH_Sector_17    ((uint16_t)0x00A8) /*!< Sector Number 17  */
-#define FLASH_Sector_18    ((uint16_t)0x00B0) /*!< Sector Number 18  */
-#define FLASH_Sector_19    ((uint16_t)0x00B8) /*!< Sector Number 19  */
-#define FLASH_Sector_20    ((uint16_t)0x00C0) /*!< Sector Number 20  */
-#define FLASH_Sector_21    ((uint16_t)0x00C8) /*!< Sector Number 21  */
-#define FLASH_Sector_22    ((uint16_t)0x00D0) /*!< Sector Number 22  */
-#define FLASH_Sector_23    ((uint16_t)0x00D8) /*!< Sector Number 23  */
-
-/** 
-  * @brief FLASH Status  
-  */ 
-typedef enum
-{ 
-  FLASH_BUSY = 1,
-  FLASH_ERROR_RD,
-  FLASH_ERROR_PGS,
-  FLASH_ERROR_PGP,
-  FLASH_ERROR_PGA,
-  FLASH_ERROR_WRP,
-  FLASH_ERROR_PROGRAM,
-  FLASH_ERROR_OPERATION,
-  FLASH_COMPLETE
-}FLASH_Status;
-
-
-/** @defgroup FLASH_Voltage_Range 
-  * @{
-  */ 
-#define VoltageRange_1        ((uint8_t)0x00)  /*!< Device operating range: 1.8V to 2.1V */
-#define VoltageRange_2        ((uint8_t)0x01)  /*!<Device operating range: 2.1V to 2.7V */
-#define VoltageRange_3        ((uint8_t)0x02)  /*!<Device operating range: 2.7V to 3.6V */
-#define VoltageRange_4        ((uint8_t)0x03)  /*!<Device operating range: 2.7V to 3.6V + External Vpp */
-
-/** @defgroup FLASH_Program_Parallelism   
-  * @{
-  */
-#define FLASH_PSIZE_BYTE           ((uint32_t)0x00000000)
-#define FLASH_PSIZE_HALF_WORD      ((uint32_t)0x00000100)
-#define FLASH_PSIZE_WORD           ((uint32_t)0x00000200)
-#define FLASH_PSIZE_DOUBLE_WORD    ((uint32_t)0x00000300)
-#define CR_PSIZE_MASK              ((uint32_t)0xFFFFFCFF)
-
-#define PERIPH_BASE           ((uint32_t)0x40000000) 
-#define AHB1PERIPH_BASE       (PERIPH_BASE + 0x00020000)
-#define FLASH_R_BASE          (AHB1PERIPH_BASE + 0x3C00)
-
-/** @defgroup FLASH_Keys 
-  * @{
-  */ 
-
-#define FLASH_KEY1               ((uint32_t)0x45670123)
-#define FLASH_KEY2               ((uint32_t)0xCDEF89AB)
-
-
-typedef struct
-{
-  __IO uint32_t ACR;      /*!< FLASH access control register,   Address offset: 0x00 */
-  __IO uint32_t KEYR;     /*!< FLASH key register,              Address offset: 0x04 */
-  __IO uint32_t OPTKEYR;  /*!< FLASH option key register,       Address offset: 0x08 */
-  __IO uint32_t SR;       /*!< FLASH status register,           Address offset: 0x0C */
-  __IO uint32_t CR;       /*!< FLASH control register,          Address offset: 0x10 */
-  __IO uint32_t OPTCR;    /*!< FLASH option control register ,  Address offset: 0x14 */
-  __IO uint32_t OPTCR1;   /*!< FLASH option control register 1, Address offset: 0x18 */
-} FLASH_TypeDef;
-
-
-
-#define FLASH               ((FLASH_TypeDef *) FLASH_R_BASE)
-
-/*******************  Bits definition for FLASH_CR register  ******************/
-#define FLASH_CR_PG                          ((uint32_t)0x00000001)
-#define FLASH_CR_SER                         ((uint32_t)0x00000002)
-#define FLASH_CR_STRT                        ((uint32_t)0x00010000)
-#define FLASH_CR_LOCK                        ((uint32_t)0x80000000)
-
-
-
-static uint32_t GetSector(uint32_t Address);
-void FLASH_Unlock(void);
-FLASH_Status FLASH_EraseSector(uint32_t FLASH_Sector, uint8_t VoltageRange);
-FLASH_Status FLASH_WaitForLastOperation(void);
-FLASH_Status FLASH_GetStatus(void);
-FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data);
-FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data);
-FLASH_Status FLASH_ProgramByte(uint32_t Address, uint8_t Data);
-void FLASH_Lock(void);
-
-
-
-
-
-/*准备写入的测试数据*/
-#define DATA_32                 ((uint32_t)0x13246578)
-#define BUFLENGTH 32
-uint32_t wrbuf[BUFLENGTH] = {0xabcdef12};  
-
-/* Exported types ------------------------------------------------------------*/
-/* Exported constants --------------------------------------------------------*/
-/* 要擦除内部FLASH的起始地址(含) */
-#define FLASH_USER_START_ADDR   ADDR_FLASH_SECTOR_7   
-/* 要擦除内部FLASH的结束地址(不含) */
-#define FLASH_USER_END_ADDR     ADDR_FLASH_SECTOR_8  
-
-
-// /**
-//   * @brief  InternalFlash_Test,对内部FLASH进行读写测试
-//   * @param  None
-//   * @retval None
-//   */
-// int InternalFlash_Test(void)
-// {
-// 	/*要擦除的起始扇区(包含)及结束扇区(不包含),如8-12,表示擦除8、9、10、11扇区*/
-// 	uint32_t uwStartSector = 0;
-// 	uint32_t uwEndSector = 0;
-	
-// 	uint32_t uwAddress = 0;
-// 	uint32_t uwSectorCounter = 0;
-
-// 	// __IO uint32_t uwData32 = 0;
-// 	__IO uint32_t uwMemoryProgramStatus = 0;
-
-// 	int i = 0;
-	
-//   /* FLASH 解锁 ********************************/
-//   /* 使能访问FLASH控制寄存器 */
-//   FLASH_Unlock();
-    
-//   /* 擦除用户区域 (用户区域指程序本身没有使用的空间,可以自定义)**/
-//   /* 清除各种FLASH的标志位 */  
-// //  FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | 
-// //                  FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR); 
-    
-//     *((volatile uint32_t *)0x40023c0C) = (((uint32_t)0x00000001) | ((uint32_t)0x00000002) | ((uint32_t)0x00000010) | \
-//                                         ((uint32_t)0x00000020) | ((uint32_t)0x00000040) | ((uint32_t)0x00000080));
-    
-
-
-// 	uwStartSector = GetSector(FLASH_USER_START_ADDR);
-// 	uwEndSector = GetSector(FLASH_USER_END_ADDR);
-
-//   /* 开始擦除操作 */
-//   uwSectorCounter = uwStartSector;
-//   while (uwSectorCounter <= uwEndSector) 
-//   {
-//      // VoltageRange_3 以“字”的大小进行操作  
-//     if (FLASH_EraseSector(uwSectorCounter, VoltageRange_3) != FLASH_COMPLETE)
-//     { 
-//       /*擦除出错,返回,实际应用中可加入处理 */
-// 			return -1;
-//     }
-//     /* 计数器指向下一个扇区 */
-//     if (uwSectorCounter == FLASH_Sector_11)
-//     {
-//       uwSectorCounter += 40;
-//     } 
-//     else 
-//     {
-//       uwSectorCounter += 8;
-//     }
-//   }
-
-//   /* 以“字节”的大小为单位写入数据 ********************************/
-//   uwAddress = FLASH_USER_START_ADDR;
-
-
-//   for (i=0;i < BUFLENGTH;i++)
-//   {
-//     uint32_t rr = 0x12345600;//wrbuf[i];
-//     if (FLASH_ProgramWord(uwAddress, rr) == FLASH_COMPLETE)
-//     {
-//       uwAddress = uwAddress + 4;
-//     }
-//     else
-//     { 
-//       /*写入出错,返回,实际应用中可加入处理 */
-// 			break;
-//     }
-//   }
-	
-
-//   /* 给FLASH上锁,防止内容被篡改*/
-//   FLASH_Lock(); 
-
-// }
-
-
-int WriteLicensetoFlash(uint8_t *license )
-{
-    int index=0;
-    uint32_t eraseSector = 0;
-    uint32_t address = ADDR_FLASH_SECTOR_6;
-    uint32_t *ptr = (uint32_t*)license;
-    FLASH_Unlock();
-  /* 清除各种FLASH的标志位 */  
-    *((volatile uint32_t *)0x40023c0C) = (((uint32_t)0x00000001) | ((uint32_t)0x00000002) | ((uint32_t)0x00000010) | \
-                                        ((uint32_t)0x00000020) | ((uint32_t)0x00000040) | ((uint32_t)0x00000080));
-    
-    eraseSector = GetSector(ADDR_FLASH_SECTOR_6);
-    if(FLASH_EraseSector(eraseSector, VoltageRange_3) != FLASH_COMPLETE)
-    {
-      printf("Erase Flash sector 7 failed!\n");
-      FLASH_Lock();
-      return -1;
-    }
-
-    for(index=0;index<32;index++)
-    {
-      FLASH_ProgramWord(address, (uint32_t)0x11223344);
-      address += 4;
-      ptr++;
-    }
-
-    FLASH_Lock(); 
-}
-
-/**
-  * @brief  根据输入的地址给出它所在的sector
-  *					例如:
-						uwStartSector = GetSector(FLASH_USER_START_ADDR);
-						uwEndSector = GetSector(FLASH_USER_END_ADDR);	
-  * @param  Address:地址
-  * @retval 地址所在的sector
-  */
-static uint32_t GetSector(uint32_t Address)
-{
-  uint32_t sector = 0;
-  
-  if((Address < ADDR_FLASH_SECTOR_1) && (Address >= ADDR_FLASH_SECTOR_0))
-  {
-    sector = FLASH_Sector_0;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_2) && (Address >= ADDR_FLASH_SECTOR_1))
-  {
-    sector = FLASH_Sector_1;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_3) && (Address >= ADDR_FLASH_SECTOR_2))
-  {
-    sector = FLASH_Sector_2;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_4) && (Address >= ADDR_FLASH_SECTOR_3))
-  {
-    sector = FLASH_Sector_3;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_5) && (Address >= ADDR_FLASH_SECTOR_4))
-  {
-    sector = FLASH_Sector_4;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_6) && (Address >= ADDR_FLASH_SECTOR_5))
-  {
-    sector = FLASH_Sector_5;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_7) && (Address >= ADDR_FLASH_SECTOR_6))
-  {
-    sector = FLASH_Sector_6;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_8) && (Address >= ADDR_FLASH_SECTOR_7))
-  {
-    sector = FLASH_Sector_7;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_9) && (Address >= ADDR_FLASH_SECTOR_8))
-  {
-    sector = FLASH_Sector_8;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_10) && (Address >= ADDR_FLASH_SECTOR_9))
-  {
-    sector = FLASH_Sector_9;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_11) && (Address >= ADDR_FLASH_SECTOR_10))
-  {
-    sector = FLASH_Sector_10;  
-  }
-  
-
-  else if((Address < ADDR_FLASH_SECTOR_12) && (Address >= ADDR_FLASH_SECTOR_11))
-  {
-    sector = FLASH_Sector_11;  
-  }
-
-  else if((Address < ADDR_FLASH_SECTOR_13) && (Address >= ADDR_FLASH_SECTOR_12))
-  {
-    sector = FLASH_Sector_12;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_14) && (Address >= ADDR_FLASH_SECTOR_13))
-  {
-    sector = FLASH_Sector_13;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_15) && (Address >= ADDR_FLASH_SECTOR_14))
-  {
-    sector = FLASH_Sector_14;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_16) && (Address >= ADDR_FLASH_SECTOR_15))
-  {
-    sector = FLASH_Sector_15;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_17) && (Address >= ADDR_FLASH_SECTOR_16))
-  {
-    sector = FLASH_Sector_16;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_18) && (Address >= ADDR_FLASH_SECTOR_17))
-  {
-    sector = FLASH_Sector_17;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_19) && (Address >= ADDR_FLASH_SECTOR_18))
-  {
-    sector = FLASH_Sector_18;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_20) && (Address >= ADDR_FLASH_SECTOR_19))
-  {
-    sector = FLASH_Sector_19;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_21) && (Address >= ADDR_FLASH_SECTOR_20))
-  {
-    sector = FLASH_Sector_20;  
-  } 
-  else if((Address < ADDR_FLASH_SECTOR_22) && (Address >= ADDR_FLASH_SECTOR_21))
-  {
-    sector = FLASH_Sector_21;  
-  }
-  else if((Address < ADDR_FLASH_SECTOR_23) && (Address >= ADDR_FLASH_SECTOR_22))
-  {
-    sector = FLASH_Sector_22;  
-  }
-  else/*(Address < FLASH_END_ADDR) && (Address >= ADDR_FLASH_SECTOR_23))*/
-  {
-    sector = FLASH_Sector_23;  
-  }
-  return sector;
-}
-
-void FLASH_Unlock(void)
-{
-  if((FLASH->CR & FLASH_CR_LOCK) != RESET)
-  {
-    /* Authorize the FLASH Registers access */
-    FLASH->KEYR = FLASH_KEY1;
-    FLASH->KEYR = FLASH_KEY2;
-  }  
-}
-
-FLASH_Status FLASH_EraseSector(uint32_t FLASH_Sector, uint8_t VoltageRange)
-{
-  uint32_t tmp_psize = 0x0;
-  FLASH_Status status = FLASH_COMPLETE;
-
-//  /* Check the parameters */
-//  assert_param(IS_FLASH_SECTOR(FLASH_Sector));
-//  assert_param(IS_VOLTAGERANGE(VoltageRange));
-  
-  if(VoltageRange == VoltageRange_1)
-  {
-     tmp_psize = FLASH_PSIZE_BYTE;
-  }
-  else if(VoltageRange == VoltageRange_2)
-  {
-    tmp_psize = FLASH_PSIZE_HALF_WORD;
-  }
-  else if(VoltageRange == VoltageRange_3)
-  {
-    tmp_psize = FLASH_PSIZE_WORD;
-  }
-  else
-  {
-    tmp_psize = FLASH_PSIZE_DOUBLE_WORD;
-  }
-  /* Wait for last operation to be completed */
-  status = FLASH_WaitForLastOperation();
-  
-  if(status == FLASH_COMPLETE)
-  { 
-    /* if the previous operation is completed, proceed to erase the sector */
-    FLASH->CR &= CR_PSIZE_MASK;
-    FLASH->CR |= tmp_psize;
-    FLASH->CR &= SECTOR_MASK;
-    FLASH->CR |= FLASH_CR_SER | FLASH_Sector;
-    FLASH->CR |= FLASH_CR_STRT;
-    
-    /* Wait for last operation to be completed */
-    status = FLASH_WaitForLastOperation();
-    
-    /* if the erase operation is completed, disable the SER Bit */
-    FLASH->CR &= (~FLASH_CR_SER);
-    FLASH->CR &= SECTOR_MASK; 
-  }
-  /* Return the Erase Status */
-  return status;
-}
-
-
-FLASH_Status FLASH_WaitForLastOperation(void)
-{ 
-  __IO FLASH_Status status = FLASH_COMPLETE;
-   
-  /* Check for the FLASH Status */
-  status = FLASH_GetStatus();
-
-  /* Wait for the FLASH operation to complete by polling on BUSY flag to be reset.
-     Even if the FLASH operation fails, the BUSY flag will be reset and an error
-     flag will be set */
-  while(status == FLASH_BUSY)
-  {
-    status = FLASH_GetStatus();
-  }
-  /* Return the operation status */
-  return status;
-}
-
-FLASH_Status FLASH_GetStatus(void)
-{
-  FLASH_Status flashstatus = FLASH_COMPLETE;
-  
-  if((FLASH->SR & FLASH_FLAG_BSY) == FLASH_FLAG_BSY) 
-  {
-    flashstatus = FLASH_BUSY;
-  }
-  else 
-  {  
-    if((FLASH->SR & FLASH_FLAG_WRPERR) != (uint32_t)0x00)
-    { 
-      flashstatus = FLASH_ERROR_WRP;
-    }
-    else
-    {
-      if((FLASH->SR & FLASH_FLAG_RDERR) != (uint32_t)0x00)
-      { 
-        flashstatus = FLASH_ERROR_RD;
-      } 
-      else 
-      {
-        if((FLASH->SR & (uint32_t)0xE0) != (uint32_t)0x00)
-        {
-          flashstatus = FLASH_ERROR_PROGRAM; 
-        }
-        else
-        {
-          if((FLASH->SR & FLASH_FLAG_OPERR) != (uint32_t)0x00)
-          {
-            flashstatus = FLASH_ERROR_OPERATION;
-          }
-          else
-          {
-            flashstatus = FLASH_COMPLETE;
-          }
-        }
-      }
-    }
-  }
-  /* Return the FLASH Status */
-  return flashstatus;
-}
-
-FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data)
-{
-//  FLASH_Status status = FLASH_COMPLETE;
-
-//  /* Check the parameters */
-//  assert_param(IS_FLASH_ADDRESS(Address));
-
-  /* Wait for last operation to be completed */
-  // status = FLASH_WaitForLastOperation();
-  
-  // if(status == FLASH_COMPLETE)
-  // {
-    /* if the previous operation is completed, proceed to program the new data */
-    FLASH->CR &= CR_PSIZE_MASK;
-    FLASH->CR |= FLASH_PSIZE_WORD;
-    FLASH->CR |= FLASH_CR_PG;
-  
-    *(__IO uint32_t*)Address = Data;
-        
-  //   /* Wait for last operation to be completed */
-  //   status = FLASH_WaitForLastOperation();
-
-  //   /* if the program operation is completed, disable the PG Bit */
-  //   FLASH->CR &= (~FLASH_CR_PG);
-  // } 
-  /* Return the Program Status */
-  return 0;
-}
-
-FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data)
-{
-  FLASH_Status status = FLASH_COMPLETE;
-
-  // /* Check the parameters */
-  // assert_param(IS_FLASH_ADDRESS(Address));
-
-  /* Wait for last operation to be completed */
-  status = FLASH_WaitForLastOperation();
-  
-  if(status == FLASH_COMPLETE)
-  {
-    /* if the previous operation is completed, proceed to program the new data */
-    FLASH->CR &= CR_PSIZE_MASK;
-    FLASH->CR |= FLASH_PSIZE_HALF_WORD;
-    FLASH->CR |= FLASH_CR_PG;
-  
-    *(__IO uint16_t*)Address = Data;
-        
-    /* Wait for last operation to be completed */
-    status = FLASH_WaitForLastOperation();
-
-    /* if the program operation is completed, disable the PG Bit */
-    FLASH->CR &= (~FLASH_CR_PG);
-  } 
-  /* Return the Program Status */
-  return status;
-}
-
-FLASH_Status FLASH_ProgramByte(uint32_t Address, uint8_t Data)
-{
-  FLASH_Status status = FLASH_COMPLETE;
-
-  // /* Check the parameters */
-  // assert_param(IS_FLASH_ADDRESS(Address));
-
-  /* Wait for last operation to be completed */
-  status = FLASH_WaitForLastOperation();
-  
-  if(status == FLASH_COMPLETE)
-  {
-    /* if the previous operation is completed, proceed to program the new data */
-    FLASH->CR &= CR_PSIZE_MASK;
-    FLASH->CR |= FLASH_PSIZE_BYTE;
-    FLASH->CR |= FLASH_CR_PG;
-  
-    *(__IO uint8_t*)Address = Data;
-        
-    /* Wait for last operation to be completed */
-    status = FLASH_WaitForLastOperation();
-
-    /* if the program operation is completed, disable the PG Bit */
-    FLASH->CR &= (~FLASH_CR_PG);
-  } 
-
-  /* Return the Program Status */
-  return status;
-}
-
-void FLASH_Lock(void)
-{
-  /* Set the LOCK Bit to lock the FLASH Registers access */
-  FLASH->CR |= FLASH_CR_LOCK;
-}

+ 0 - 8
app/AuthLicense/iflash.h

@@ -1,8 +0,0 @@
-#ifndef __IFLASH_H__
-#define __IFLASH_H__
-#include <stdio.h>
-#include <stdint.h>
-
-int WriteLicensetoFlash(uint8_t *license );
-
-#endif /* __IFLASH_H__ */

+ 8 - 0
app/Makefile

@@ -21,12 +21,20 @@ all	:
 	make -C ./NCP81111_Config
 	make -C ./NCP81111_Config
 	make -C ./ipmitool-1.8.18
 	make -C ./ipmitool-1.8.18
 	make -C ./AuthLicense
 	make -C ./AuthLicense
+	make -C ./adctool
+	make -C ./gpiotool
+	make -C ./i2ctool
+	make -C ./spitool
 clean	: 
 clean	: 
 	make -C ./goahead-3.6.5 clean
 	make -C ./goahead-3.6.5 clean
 	make -C ./bmc clean
 	make -C ./bmc clean
 	make -C ./test_app clean
 	make -C ./test_app clean
 	make -C ./ipmitool-1.8.18 clean
 	make -C ./ipmitool-1.8.18 clean
 	make -C ./UpdateFirmware clean
 	make -C ./UpdateFirmware clean
+	make -C ./adctool clean
+	make -C ./gpiotool clean
+	make -C ./i2ctool clean
+	make -C ./spitool clean
 
 
 	make -C ./driver/Platform clean
 	make -C ./driver/Platform clean
 	make -C ./driver/GPIO clean
 	make -C ./driver/GPIO clean

BIN
app/NCP81111_Config/ncp81111_cfg


BIN
app/UpdateFirmware/updateFW_app


+ 49 - 0
app/adctool/Makefile

@@ -0,0 +1,49 @@
+EXEC		= adctool
+
+CFLAGS		:= -Os -mcpu=cortex-m3 -mthumb
+LDFLAGS		:= -mcpu=cortex-m3 -mthumb -L$(INSTALL_ROOT)/A2F/root/usr/lib
+#BUILD_TIME 	= $(shell date +"%Y-%m-%d %H:%M:%S")
+
+
+
+CC	= $(CROSS_COMPILE_APPS)gcc
+
+#source
+SRC	= adctool_main.c
+
+# hal_api
+SRC += $(wildcard ../hal_api/*.c) 
+
+#incldue
+CFLAGS	+= -I$(INSTALL_ROOT)/A2F/root/usr/include
+CFLAGS	+= -I ./
+CFLAGS	+= -I ../common_include
+CFLAGS	+= -I ../driver
+CFLAGS	+= -I ../hal_api
+CFLAGS	+= -I ../driver/STM32F4xx_HAL_Driver
+CFLAGS	+= -I ../driver/STM32F4xx_HAL_Driver/Inc
+CFLAGS	+= -I ../driver/STM32F4xx_HAL_Driver/Inc/Legacy
+
+
+#library
+
+#sub-directory
+#SUBDIR 	= ./sensor
+
+
+
+
+
+
+$(EXEC): $(SRC)
+	#echo $(BUILD_TIME)
+	$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(LIBS) -lpthread
+
+
+#object
+OBJS	= $(SRC:%.c=%.o)
+
+clean:
+	rm -f $(EXEC) $(OBJS)
+	rm -f *.gdb 
+

BIN
app/adctool/adctool


+ 42 - 0
app/adctool/adctool_main.c

@@ -0,0 +1,42 @@
+#include <stdio.h>
+#include <stdint.h>
+#include "driver.h"
+#include "hal_interface_api.h"
+#include <fcntl.h>
+
+/*
+adctool --get-all-channels
+*/
+
+void help()
+{
+	printf("adctool <cmd>\n");
+	printf("    --get-all-channels: read all channels raw data.\n");
+}
+
+int main(int argc, char* argv[])
+{
+	int i;
+	uint16_t buf;
+	if(argc < 2)
+	{
+		help();
+		return -1;
+	}
+
+	if((strcmp(argv[1], "--get-all-channels") == 0) && (argc == 2))
+	{
+		for(i=1;i<=7;i++)
+		{
+			buf = 0;
+			stm32_adc_get_value(i, &buf);
+			printf("ADC%d: %#04x\n", i, buf); 	
+		}
+		
+	}
+	else
+	{
+		help();
+		return -1;
+	}
+}

+ 88 - 25
app/bmc/Api.c

@@ -35,13 +35,13 @@ int PlatformInit(void)
 	GPIO_InitStruct.Pin = GAP_PIN | RACKID1_PIN | RACKID3_PIN | RACKID4_PIN | RACKID5_PIN;
 	GPIO_InitStruct.Pin = GAP_PIN | RACKID1_PIN | RACKID3_PIN | RACKID4_PIN | RACKID5_PIN;
 	stm32_gpio_init(GPIOI, &GPIO_InitStruct);
 	stm32_gpio_init(GPIOI, &GPIO_InitStruct);
 
 
-	//LED灯 D2
-	GPIO_InitStruct.Pin = GPIO1_PIN;
+	//LED灯 
+	GPIO_InitStruct.Pin = IDENTIFY_PIN;
 	GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
 	GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
 	GPIO_InitStruct.Pull = GPIO_NOPULL;
 	GPIO_InitStruct.Pull = GPIO_NOPULL;
 	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 	stm32_gpio_write(IDENTIFY_PORT, IDENTIFY_PIN, GPIO_PIN_RESET);
 	stm32_gpio_write(IDENTIFY_PORT, IDENTIFY_PIN, GPIO_PIN_RESET);
-	stm32_gpio_init(GPIO1_PORT, &GPIO_InitStruct);
+	stm32_gpio_init(IDENTIFY_PORT, &GPIO_InitStruct);
 
 
 	g_BMCInfo.SelfTestByte 	=	0;
 	g_BMCInfo.SelfTestByte 	=	0;
 	g_BMCInfo.SlotID		=	PDK_GetSlotID();
 	g_BMCInfo.SlotID		=	PDK_GetSlotID();
@@ -154,6 +154,7 @@ int PlatformInit(void)
 	g_BMCInfo.CurTimerSecond			=	0;
 	g_BMCInfo.CurTimerSecond			=	0;
 	g_BMCInfo.BootValidMinutes			=	0;
 	g_BMCInfo.BootValidMinutes			=	0;
 	g_BMCInfo.m_Lan_SetInProgress 		=	0;
 	g_BMCInfo.m_Lan_SetInProgress 		=	0;
+	g_BMCInfo.BootValidMinutesCount		=	0;
 
 
 	return 0;
 	return 0;
 }
 }
@@ -240,6 +241,7 @@ int Init_IPMI_FRU_SDR_SEL(void)
 		g_BMCInfo.IpmiConfig.FanControlInterval		=	FAN_CONTROL_INTERVAL;		
 		g_BMCInfo.IpmiConfig.FanControlInterval		=	FAN_CONTROL_INTERVAL;		
 		g_BMCInfo.IpmiConfig.RearmSetSensorThreshold	=	REARM_SET_SENSOR_THRESHOLD;
 		g_BMCInfo.IpmiConfig.RearmSetSensorThreshold	=	REARM_SET_SENSOR_THRESHOLD;
 		g_BMCInfo.IpmiConfig.SELTimeUTCOffset		=	8*60;
 		g_BMCInfo.IpmiConfig.SELTimeUTCOffset		=	8*60;
+		g_BMCInfo.IpmiConfig.totalRunTimeCount		=	0;
 		
 		
 		//IPMB
 		//IPMB
 		g_BMCInfo.IpmiConfig.PrimaryIPMBSupport		=	PRIMARY_IPMB_SUPPORT;
 		g_BMCInfo.IpmiConfig.PrimaryIPMBSupport		=	PRIMARY_IPMB_SUPPORT;
@@ -346,6 +348,8 @@ int Init_IPMI_FRU_SDR_SEL(void)
 		pSetLanInfo->MACAddr[4]	=	0;
 		pSetLanInfo->MACAddr[4]	=	0;
 		pSetLanInfo->MACAddr[5]	=	0;
 		pSetLanInfo->MACAddr[5]	=	0;
 
 
+
+
 		FlushUserInfoTbl();
 		FlushUserInfoTbl();
 		UpdateFlash();
 		UpdateFlash();
 	}
 	}
@@ -441,7 +445,28 @@ int PostEventMessage (uint8_t *EventMsg,uint8_t size)
 
 
 	SelRecord->hdr.Type = 0x02;
 	SelRecord->hdr.Type = 0x02;
 	SelRecord->hdr.TimeStamp = GetSysTime ();
 	SelRecord->hdr.TimeStamp = GetSysTime ();
-	memcpy (SelRecord->GenID, EventMsg, size);
+	memcpy (&SelRecord->body, EventMsg, size);
+	
+	LockedAddSELEntry(SelReq, sizeof (SELEventRecord_T), SelRes);
+
+	return 0;
+}
+
+/*
+	EventMsg共6个字节。
+ */
+int PostOemEventMessage (uint8_t *EventMsg)
+{
+	uint8_t             SelReq [sizeof(SELEventRecord_T)];
+	uint8_t             SelRes [sizeof(AddSELRes_T)];
+	SELEventRecord_T*   SelRecord = ( SELEventRecord_T*) SelReq;
+
+	SelRecord->hdr.Type = 0xC0;		//storlead oem event Record ID
+	SelRecord->hdr.TimeStamp = GetSysTime ();
+	SelRecord->body.oemEventRecord.ManufacturerID[0] = 0x30;
+	SelRecord->body.oemEventRecord.ManufacturerID[1] = 0x30;
+	SelRecord->body.oemEventRecord.ManufacturerID[2] = 0x0f;
+	memcpy (SelRecord->body.oemEventRecord.OEMDefined, EventMsg, 6);
 	
 	
 	LockedAddSELEntry(SelReq, sizeof (SELEventRecord_T), SelRes);
 	LockedAddSELEntry(SelReq, sizeof (SELEventRecord_T), SelRes);
 
 
@@ -501,7 +526,15 @@ uint8_t PDK_GetChassisID(void)
 
 
 int PDK_PowerOffChassis(void)
 int PDK_PowerOffChassis(void)
 {
 {
-	//printf("Api power off chassis\n");
+	printf("Api power off chassis\n");
+	uint8_t EventMsg[6];
+	EventMsg[0] = 1;	//命令类1
+	EventMsg[1] = 2;	//命令,chassis
+	EventMsg[2] = 2;	//power off
+	EventMsg[3] = 2;	//命令来源:BMC CMD
+	EventMsg[4] = 0;	//Reserve
+	EventMsg[5] = 0;	//Reserve
+	PostOemEventMessage (EventMsg);
 	g_BMCInfo.PowerGoodFlag = 0;
 	g_BMCInfo.PowerGoodFlag = 0;
 	printf("Not support power control!\n");
 	printf("Not support power control!\n");
 	return 0;
 	return 0;
@@ -509,7 +542,15 @@ int PDK_PowerOffChassis(void)
 
 
 int PDK_PowerOnChassis(void)
 int PDK_PowerOnChassis(void)
 {
 {
-	//printf("power on chassis\n");
+	printf("power on chassis\n");
+	uint8_t EventMsg[6];
+	EventMsg[0] = 1;	//命令类1
+	EventMsg[1] = 2;	//命令,chassis
+	EventMsg[2] = 1;	//power on
+	EventMsg[3] = 2;	//命令来源:BMC CMD
+	EventMsg[4] = 0;	//Reserve
+	EventMsg[5] = 0;	//Reserve
+	PostOemEventMessage (EventMsg);
 	g_BMCInfo.PowerGoodFlag = 1;
 	g_BMCInfo.PowerGoodFlag = 1;
 	printf("Not support power control!\n");
 	printf("Not support power control!\n");
 }
 }
@@ -524,12 +565,34 @@ int PDK_SoftOffChassis(void)
 int PDK_GetPowerStatus(void)
 int PDK_GetPowerStatus(void)
 {
 {
 	//TODO:
 	//TODO:
+	// if(g_BMCInfo.PowerGoodFlag != retval)
+	// {
+	// 	uint8_t EventMsg[6];
+	// 	EventMsg[0] = 2;	//命令类2
+	// 	EventMsg[1] = 1;	//命令,power good
+	// 	if(retval == 0)	//power down
+	// 		EventMsg[2] = 0;	//power goes down
+	// 	else
+	// 		EventMsg[2] = 1;	//power goes up
+	// 	EventMsg[3] = 0;	//命令来源:BMC CMD
+	// 	EventMsg[4] = 0;	//Reserve
+	// 	EventMsg[5] = 0;	//Reserve
+	// 	PostOemEventMessage (EventMsg);
+	// }
 	return 1;
 	return 1;
 }
 }
 
 
 int PDK_PowerCycleChassis(void)
 int PDK_PowerCycleChassis(void)
 {
 {
 	//printf("power cycle chassis\n");
 	//printf("power cycle chassis\n");
+	// uint8_t EventMsg[6];
+	// EventMsg[0] = 1;	//命令类1
+	// EventMsg[1] = 2;	//命令,chassis
+	// EventMsg[2] = 4;	//power cycle
+	// EventMsg[3] = 2;	//命令来源:BMC CMD
+	// EventMsg[4] = 0;	//Reserve
+	// EventMsg[5] = 0;	//Reserve
+	// PostOemEventMessage (EventMsg);
 	printf("Not support power control!\n");
 	printf("Not support power control!\n");
 	return 0;
 	return 0;
 }
 }
@@ -537,6 +600,14 @@ int PDK_PowerCycleChassis(void)
 int PDK_ResetChassis(void)
 int PDK_ResetChassis(void)
 {
 {
 	//printf("power reset chassis\n");
 	//printf("power reset chassis\n");
+	// uint8_t EventMsg[6];
+	// EventMsg[0] = 1;	//命令类1
+	// EventMsg[1] = 2;	//命令,chassis
+	// EventMsg[2] = 3;	//reset
+	// EventMsg[3] = 2;	//命令来源:BMC CMD
+	// EventMsg[4] = 0;	//Reserve
+	// EventMsg[5] = 0;	//Reserve
+	// PostOemEventMessage (EventMsg);
 	printf("Not support power control!\n");
 	printf("Not support power control!\n");
 	return 0;
 	return 0;
 }
 }
@@ -712,21 +783,12 @@ int API_BridgeInternal(MsgPkt_T* pReqPkt, MsgPkt_T* pResPkt, uint8_t DestAddr, i
 	uint8_t 		PBTbl;
 	uint8_t 		PBTbl;
 	
 	
 	pthread_mutex_lock(&api_bridge_mutex);
 	pthread_mutex_lock(&api_bridge_mutex);
-	//create BRIDGE_QUEUE
-    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);
-        pthread_mutex_unlock(&api_bridge_mutex);
-        return -1;
-    }
+	
     fd_BridgeQue = open (BRIDGE_QUEUE, O_RDWR);
     fd_BridgeQue = open (BRIDGE_QUEUE, O_RDWR);
     if(-1 == fd_BridgeQue)
     if(-1 == fd_BridgeQue)
     {
     {
         printf("%s: Open %s fifo failed! \n", __FUNCTION__, BRIDGE_QUEUE);
         printf("%s: Open %s fifo failed! \n", __FUNCTION__, BRIDGE_QUEUE);
+        close(fd_BridgeQue);
         pthread_mutex_unlock(&api_bridge_mutex);
         pthread_mutex_unlock(&api_bridge_mutex);
         return -1;
         return -1;
     }
     }
@@ -740,7 +802,7 @@ int API_BridgeInternal(MsgPkt_T* pReqPkt, MsgPkt_T* pResPkt, uint8_t DestAddr, i
     else
     else
     {
     {
         printf("Warning: Message Packet to be bridged is NULL\r\n");
         printf("Warning: Message Packet to be bridged is NULL\r\n");
-		remove(BRIDGE_QUEUE);
+        close(fd_BridgeQue);
 		pthread_mutex_unlock(&api_bridge_mutex);
 		pthread_mutex_unlock(&api_bridge_mutex);
         return -1;
         return -1;
     }    
     }    
@@ -751,7 +813,7 @@ int API_BridgeInternal(MsgPkt_T* pReqPkt, MsgPkt_T* pResPkt, uint8_t DestAddr, i
     else
     else
     {
     {
         printf("Warning: Message Packet to be bridged is NULL\r\n");
         printf("Warning: Message Packet to be bridged is NULL\r\n");
-		remove(BRIDGE_QUEUE);
+        close(fd_BridgeQue);
 		pthread_mutex_unlock(&api_bridge_mutex);
 		pthread_mutex_unlock(&api_bridge_mutex);
         return -1;
         return -1;
     }   
     }   
@@ -771,8 +833,8 @@ int API_BridgeInternal(MsgPkt_T* pReqPkt, MsgPkt_T* pResPkt, uint8_t DestAddr, i
     else
     else
     {
     {
         printf ("Warning: Invalid IPMB Channel: %d\r\n", Channel);
         printf ("Warning: Invalid IPMB Channel: %d\r\n", Channel);
-		remove(BRIDGE_QUEUE);
 		pthread_mutex_unlock(&api_bridge_mutex);
 		pthread_mutex_unlock(&api_bridge_mutex);
+		close(fd_BridgeQue);
         return -1;
         return -1;
     }
     }
 	
 	
@@ -822,7 +884,7 @@ int API_BridgeInternal(MsgPkt_T* pReqPkt, MsgPkt_T* pResPkt, uint8_t DestAddr, i
 			if(SeqNum == g_BMCInfo.SendMsgSeqNum)
 			if(SeqNum == g_BMCInfo.SendMsgSeqNum)
 			{
 			{
 				printf ("Warning: Pending Bridge Response Table is full \n");
 				printf ("Warning: Pending Bridge Response Table is full \n");
-				remove(BRIDGE_QUEUE);
+				close(fd_BridgeQue);
 				pthread_mutex_unlock(&api_bridge_mutex);
 				pthread_mutex_unlock(&api_bridge_mutex);
 				return -1;
 				return -1;
 			}
 			}
@@ -848,7 +910,7 @@ int API_BridgeInternal(MsgPkt_T* pReqPkt, MsgPkt_T* pResPkt, uint8_t DestAddr, i
 	else
 	else
 	{
 	{
 		printf("Warning: Invalid Channel %d\n", Channel);
 		printf("Warning: Invalid Channel %d\n", Channel);
-		remove(BRIDGE_QUEUE);
+		close(fd_BridgeQue);
 		pthread_mutex_unlock(&api_bridge_mutex);
 		pthread_mutex_unlock(&api_bridge_mutex);
 		return -1;
 		return -1;
 	}
 	}
@@ -857,14 +919,14 @@ int API_BridgeInternal(MsgPkt_T* pReqPkt, MsgPkt_T* pResPkt, uint8_t DestAddr, i
     if(0 != PostMsg(pReqPkt->SrcQ, pReqPkt) )
     if(0 != PostMsg(pReqPkt->SrcQ, pReqPkt) )
     {
     {
         printf ("Warning: oemApi.c : Error posting message to Queue %p \n", pReqPkt->SrcQ);
         printf ("Warning: oemApi.c : Error posting message to Queue %p \n", pReqPkt->SrcQ);
-		remove(BRIDGE_QUEUE);
+        close(fd_BridgeQue);
 		pthread_mutex_unlock(&api_bridge_mutex);
 		pthread_mutex_unlock(&api_bridge_mutex);
         return -1;
         return -1;
     }
     }
 	
 	
 	m_PendingBridgedResTbl[PBTbl][SeqNum].ResDataOk = 1;
 	m_PendingBridgedResTbl[PBTbl][SeqNum].ResDataOk = 1;
 	
 	
-    RetVal = GetMsg (fd_BridgeQue, pResPkt, 5000);  //3s
+    RetVal = GetMsg (fd_BridgeQue, pResPkt, 3);  //3s
 
 
     // int i;
     // int i;
     // printf("Bridge recv: ");
     // printf("Bridge recv: ");
@@ -874,7 +936,8 @@ int API_BridgeInternal(MsgPkt_T* pReqPkt, MsgPkt_T* pResPkt, uint8_t DestAddr, i
     // }
     // }
     // printf("\n");
     // printf("\n");
 
 
-	remove(BRIDGE_QUEUE);
+	//remove(BRIDGE_QUEUE);
+	close(fd_BridgeQue);
 	pthread_mutex_unlock(&api_bridge_mutex);
 	pthread_mutex_unlock(&api_bridge_mutex);
 	if(RetVal != 0)
 	if(RetVal != 0)
 	{
 	{

+ 1 - 0
app/bmc/Api.h

@@ -13,6 +13,7 @@ long int GetSysTime(void);
 #define GET_SYSTEM_TIME_STAMP GetSysTime
 #define GET_SYSTEM_TIME_STAMP GetSysTime
 
 
 int PostEventMessage (uint8_t *EventMsg,uint8_t size);
 int PostEventMessage (uint8_t *EventMsg,uint8_t size);
+int PostOemEventMessage (uint8_t *EventMsg);
 
 
  uint8_t PDK_GetSlotID(void);
  uint8_t PDK_GetSlotID(void);
  uint8_t PDK_GetChassisID(void);
  uint8_t PDK_GetChassisID(void);

+ 4 - 2
app/bmc/BmcType.h

@@ -77,6 +77,8 @@ typedef struct
 	//lan configuration
 	//lan configuration
 	LanInfo_T 	LanInfo[1];	//方便扩展多个网卡。
 	LanInfo_T 	LanInfo[1];	//方便扩展多个网卡。
 
 
+	uint32_t 	totalRunTimeCount;
+
 	
 	
 } IPMIConfig_T;
 } IPMIConfig_T;
 
 
@@ -90,10 +92,10 @@ typedef struct
 	ChannelInfo_T		ChannelTab[15];							//最大支持15个通道。
 	ChannelInfo_T		ChannelTab[15];							//最大支持15个通道。
 
 
 	//time
 	//time
-    uint32_t 			CurTimerTick;							//uint: 1ms
+    uint32_t 			CurTimerTick;							//uint: 1ms, 暂时未用
 	uint32_t			CurTimerSecond;
 	uint32_t			CurTimerSecond;
 	uint32_t			BootValidMinutes;						//This work time
 	uint32_t			BootValidMinutes;						//This work time
-	uint32_t			TotalBootValidMinutes;					//Total work time
+	uint32_t			BootValidMinutesCount;					//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
 	//chassis

+ 1 - 1
app/bmc/Makefile

@@ -39,7 +39,7 @@ SRC += ./encryption/AuthCode.c
 SRC += ./ChassisTimer/ChassisTimerTask.c
 SRC += ./ChassisTimer/ChassisTimerTask.c
 
 
 SRC += ./msghndlr/MsgHndlrTask.c
 SRC += ./msghndlr/MsgHndlrTask.c
-SRC += ./msghndlr/cmdselect.c
+#SRC += ./msghndlr/cmdselect.c
 SRC += ./msghndlr/PDKCmds.c
 SRC += ./msghndlr/PDKCmds.c
 SRC += ./msghndlr/App/App.c
 SRC += ./msghndlr/App/App.c
 SRC += ./msghndlr/App/AppDevice/AppDevice.c
 SRC += ./msghndlr/App/AppDevice/AppDevice.c

+ 8 - 1
app/bmc/SysTimer/TimerTask.c

@@ -64,10 +64,17 @@ void TimerTask( int signo )	//signal handler
 			g_BMCInfo.SenConfig.SysResetTick++;
 			g_BMCInfo.SenConfig.SysResetTick++;
 		
 		
 		g_BMCInfo.CurTimerSecond++;
 		g_BMCInfo.CurTimerSecond++;
+		g_BMCInfo.CurTimerTick++;
 		if(g_BMCInfo.PowerGoodFlag && (g_BMCInfo.CurTimerSecond%60 == 0))	// 1minute
 		if(g_BMCInfo.PowerGoodFlag && (g_BMCInfo.CurTimerSecond%60 == 0))	// 1minute
 		{
 		{
 			g_BMCInfo.BootValidMinutes++;
 			g_BMCInfo.BootValidMinutes++;
-			g_BMCInfo.TotalBootValidMinutes++;
+			g_BMCInfo.BootValidMinutesCount++;
+			if((g_BMCInfo.BootValidMinutesCount%POH_MINS_PER_COUNT) == 0)
+			{
+				g_BMCInfo.BootValidMinutesCount = 0;
+				g_BMCInfo.IpmiConfig.totalRunTimeCount++;
+				FlushIPMIToFlash();
+			}
 		}
 		}
 
 
 		ProcessTimerReq();
 		ProcessTimerReq();

+ 22 - 28
app/bmc/ipmb/IPMBIfc.c

@@ -167,32 +167,29 @@ void *IPMBIfcTask(void *Param)
         switch(RcvMsgPkt.Param)
         switch(RcvMsgPkt.Param)
 		{
 		{
 			case PARAM_REQUEST:
 			case PARAM_REQUEST:
-                //printf("---> IPMBIfcTask/PARAM_REQUEST\n");
 				ProcessIPMBReq (&RcvMsgPkt);
 				ProcessIPMBReq (&RcvMsgPkt);
 				break;
 				break;
 			case PARAM_BRIDGE:
 			case PARAM_BRIDGE:
-                //printf("---> IPMBIfcTask/PARAM_BRIDGE, channel: %d\n", RcvMsgPkt.Channel);
-                
                 /* Send the response */
                 /* Send the response */
                 if(RcvMsgPkt.Channel == PRIMARY_IPMB_CHANNEL)
                 if(RcvMsgPkt.Channel == PRIMARY_IPMB_CHANNEL)
                 {
                 {
                     RetVal = stm32_i2c_master_write(gFd_Primary, RcvMsgPkt.Data[0], &RcvMsgPkt.Data[1], RcvMsgPkt.Size-1);
                     RetVal = stm32_i2c_master_write(gFd_Primary, RcvMsgPkt.Data[0], &RcvMsgPkt.Data[1], RcvMsgPkt.Size-1);
-                    printf("PriTx: ");
+                    //printf("PriTx: ");
                 }
                 }
                 else if(RcvMsgPkt.Channel == SECONDARY_IPMB_CHANNEL)
                 else if(RcvMsgPkt.Channel == SECONDARY_IPMB_CHANNEL)
                 {
                 {
                     RetVal = stm32_i2c_master_write(gFd_Secondary, RcvMsgPkt.Data[0], &RcvMsgPkt.Data[1], RcvMsgPkt.Size-1);
                     RetVal = stm32_i2c_master_write(gFd_Secondary, RcvMsgPkt.Data[0], &RcvMsgPkt.Data[1], RcvMsgPkt.Size-1);
-                    printf("SecTx: ");
+                    //printf("SecTx: ");
                 }
                 }
                 else
                 else
                 {
                 {
                     printf("IPMBIfc.c: IPMB channel error. %#x\r\n", RcvMsgPkt.Channel);
                     printf("IPMBIfc.c: IPMB channel error. %#x\r\n", RcvMsgPkt.Channel);
                 }
                 }
 
 
-                int i;
-                for(i=0;i<RcvMsgPkt.Size;i++)
-                    printf("%02x ", RcvMsgPkt.Data[i]);
-                printf("\n");
+                // int i;
+                // for(i=0;i<RcvMsgPkt.Size;i++)
+                //     printf("%02x ", RcvMsgPkt.Data[i]);
+                // printf("\n");
 
 
                 if (RetVal < 0)
                 if (RetVal < 0)
                 {
                 {
@@ -306,31 +303,31 @@ ProcessIPMBReq ( MsgPkt_T* pReq)
         return;
         return;
     }
     }
 
 
-   
+    //usleep(2000);
     /* Send the response */
     /* Send the response */
 	if(pReq->Channel == PRIMARY_IPMB_CHANNEL)
 	if(pReq->Channel == PRIMARY_IPMB_CHANNEL)
 	{
 	{
         pthread_mutex_lock(&primary_mutex);
         pthread_mutex_lock(&primary_mutex);
 		RetVal = stm32_i2c_master_write(gFd_Primary, ResPkt.Data[0], &ResPkt.Data[1], ResPkt.Size-1);
 		RetVal = stm32_i2c_master_write(gFd_Primary, ResPkt.Data[0], &ResPkt.Data[1], ResPkt.Size-1);
         pthread_mutex_unlock(&primary_mutex);
         pthread_mutex_unlock(&primary_mutex);
-        printf("PriTx: ");
+        //printf("PriTx: ");
 	}
 	}
 	else if(pReq->Channel == SECONDARY_IPMB_CHANNEL)
 	else if(pReq->Channel == SECONDARY_IPMB_CHANNEL)
 	{
 	{
         pthread_mutex_lock(&secondary_mutex);
         pthread_mutex_lock(&secondary_mutex);
 		RetVal = stm32_i2c_master_write(gFd_Secondary, ResPkt.Data[0], &ResPkt.Data[1], ResPkt.Size-1);
 		RetVal = stm32_i2c_master_write(gFd_Secondary, ResPkt.Data[0], &ResPkt.Data[1], ResPkt.Size-1);
         pthread_mutex_unlock(&secondary_mutex);
         pthread_mutex_unlock(&secondary_mutex);
-        printf("SecTx: ");
+        //printf("SecTx: ");
 	}
 	}
 	else
 	else
 	{
 	{
 		printf("IPMBIfc.c: IPMB channel error. %#x\r\n", pReq->Channel);
 		printf("IPMBIfc.c: IPMB channel error. %#x\r\n", pReq->Channel);
 	}
 	}
 
 
-    int i;
-    for(i=0;i<ResPkt.Size;i++)
-        printf("%02x ", ResPkt.Data[i]);
-    printf("\n");
+    // int i;
+    // for(i=0;i<ResPkt.Size;i++)
+    //     printf("%02x ", ResPkt.Data[i]);
+    // printf("\n");
 	
 	
     if (0 != RetVal)
     if (0 != RetVal)
     {
     {
@@ -471,16 +468,6 @@ static void* RecvIPMBPkt (void *Param)
             IPMBReqPkt.Param    = PARAM_REQUEST;
             IPMBReqPkt.Param    = PARAM_REQUEST;
             IPMBReqPkt.Size     = retval + 1;       /* +1 to include BMC Slave address */
             IPMBReqPkt.Size     = retval + 1;       /* +1 to include BMC Slave address */
 
 
-            int cnt;
-            if(0 == ipmbSelect)
-                printf("\nPriRx: ");
-            else
-                printf("\nSecRx: ");
-
-            for(cnt=0;cnt < IPMBReqPkt.Size; cnt++)
-                printf("%02x ", IPMBReqPkt.Data[cnt]);
-            printf("\n");
-
             /* Post the IPMB Request message to IPMBIfc Queue */
             /* Post the IPMB Request message to IPMBIfc Queue */
             if(ipmbSelect == 0)
             if(ipmbSelect == 0)
             {
             {
@@ -497,9 +484,16 @@ static void* RecvIPMBPkt (void *Param)
                 }
                 }
             }
             }
 
 
-        }
+            // int cnt;
+            // if(0 == ipmbSelect)
+            //     printf("\nPriRx: ");
+            // else
+            //     printf("\nSecRx: ");
 
 
-       
+            // for(cnt=0;cnt < IPMBReqPkt.Size; cnt++)
+            //     printf("%02x ", IPMBReqPkt.Data[cnt]);
+            // printf("\n");
+        }
 	}
 	}
     return (void*)-1;
     return (void*)-1;
 }
 }

+ 10 - 0
app/bmc/main.c

@@ -174,6 +174,16 @@ void main(void)
     new_value.it_interval.tv_usec = 0;
     new_value.it_interval.tv_usec = 0;
     setitimer(ITIMER_REAL, &new_value, NULL);
     setitimer(ITIMER_REAL, &new_value, NULL);
 
 
+    //create BRIDGE_QUEUE
+    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);
+    }
+
 
 
 	/* Create MsgHndlr Task */
 	/* Create MsgHndlr Task */
 	gThreadIndex++;
 	gThreadIndex++;

+ 1 - 1
app/bmc/main.h

@@ -116,7 +116,7 @@ extern int gPendActionIfc;
 extern TLS_T g_tls;
 extern TLS_T g_tls;
 extern PendingBridgedResTbl_T	m_PendingBridgedResTbl[MAX_PENDING_BRIDGE_TBL][MAX_PENDING_BRIDGE_RES];
 extern PendingBridgedResTbl_T	m_PendingBridgedResTbl[MAX_PENDING_BRIDGE_TBL][MAX_PENDING_BRIDGE_RES];
 extern PendingSeqNoTbl_T		m_PendingSeqNoTbl[16][MAX_PENDING_SEQ_NO];
 extern PendingSeqNoTbl_T		m_PendingSeqNoTbl[16][MAX_PENDING_SEQ_NO];
-extern KCSBridgeResInfo_T       m_KCSBridgeResInfo;
+//extern KCSBridgeResInfo_T       m_KCSBridgeResInfo;
 extern TimerTaskTbl_T    		m_TimerTaskTbl [20];
 extern TimerTaskTbl_T    		m_TimerTaskTbl [20];
 
 
 extern BMCInfo_t 			g_BMCInfo;
 extern BMCInfo_t 			g_BMCInfo;

+ 0 - 1
app/bmc/message.c

@@ -35,7 +35,6 @@ PostMsg (int fd, MsgPkt_T* pMsgPkt)
         return -1;
         return -1;
     }             
     }             
 
 
-    //printf("---> PostMsg ok, fd = %d\n", fd);
     return 0;
     return 0;
 }
 }
 
 

+ 1 - 0
app/bmc/msghndlr/App/AppDevice/AppDevice.c

@@ -34,6 +34,7 @@
 #include "PMConfig.h"
 #include "PMConfig.h"
 #include "main.h"
 #include "main.h"
 #include <string.h>
 #include <string.h>
+#include "Api.h"
 
 
 #define USER_ID_ENABLED 	0x01
 #define USER_ID_ENABLED 	0x01
 #define USER_ID_DISABLED 	0x02
 #define USER_ID_DISABLED 	0x02

+ 5 - 7
app/bmc/msghndlr/Chassis/ChassisDevice.c

@@ -295,8 +295,6 @@ GetChassisIdentify ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
 {
 {
      ChassisIdentifyReq_T*    pChassisIdentifyReq =
      ChassisIdentifyReq_T*    pChassisIdentifyReq =
         ( ChassisIdentifyReq_T*) pReq;
         ( ChassisIdentifyReq_T*) pReq;
-     ChassisIdentifyRes_T*    pChassisIdentifyRes =
-        ( ChassisIdentifyRes_T*) pRes;
 
 
     if (ReqLen <= sizeof(ChassisIdentifyReq_T)) 
     if (ReqLen <= sizeof(ChassisIdentifyReq_T)) 
     {
     {
@@ -316,7 +314,7 @@ GetChassisIdentify ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
             /* Check for the reserved bytes should b zero */
             /* Check for the reserved bytes should b zero */
             if  ( 0 !=  (pChassisIdentifyReq->ForceIdentify & RESERVED_BITS_GETCHASSISIDENTIFY ) )
             if  ( 0 !=  (pChassisIdentifyReq->ForceIdentify & RESERVED_BITS_GETCHASSISIDENTIFY ) )
             {
             {
-                pChassisIdentifyRes->CompletionCode = CC_INV_DATA_FIELD;
+                pRes[0] = CC_INV_DATA_FIELD;
                 return sizeof(uint8_t);	
                 return sizeof(uint8_t);	
             }
             }
 
 
@@ -332,14 +330,14 @@ GetChassisIdentify ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
         }
         }
         g_BMCInfo.ChassisIdentify = TRUE;
         g_BMCInfo.ChassisIdentify = TRUE;
 
 
-        pChassisIdentifyRes->CompletionCode = CC_NORMAL;
+        pRes[0] = CC_NORMAL;
     }    	
     }    	
     else 
     else 
     {
     {
-        pChassisIdentifyRes->CompletionCode = CC_REQ_INV_LEN;
+        pRes[0] = CC_REQ_INV_LEN;
     }
     }
     
     
-    return sizeof(ChassisIdentifyRes_T);
+    return 1;
 }
 }
 
 
 
 
@@ -460,7 +458,7 @@ GetPOHCounter ( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
 
 
     pGetPOHCounterRes->CompletionCode    = CC_NORMAL;
     pGetPOHCounterRes->CompletionCode    = CC_NORMAL;
     pGetPOHCounterRes->MinutesPerCount   = POH_MINS_PER_COUNT;
     pGetPOHCounterRes->MinutesPerCount   = POH_MINS_PER_COUNT;
-    pGetPOHCounterRes->POHCounterReading = (g_BMCInfo.BootValidMinutes/60);
+    pGetPOHCounterRes->POHCounterReading = g_BMCInfo.IpmiConfig.totalRunTimeCount;
    
    
     return sizeof(GetPOHCounterRes_T);
     return sizeof(GetPOHCounterRes_T);
 }
 }

+ 1 - 1
app/bmc/msghndlr/Chassis/ChassisDevice.h

@@ -34,7 +34,7 @@
 
 
 #define  CHASSIS_PARAMETER_VERSION                 0x01
 #define  CHASSIS_PARAMETER_VERSION                 0x01
 
 
-#define  POH_MINS_PER_COUNT                        60
+
 
 
 /******************************************************************************
 /******************************************************************************
 *
 *

+ 30 - 35
app/bmc/msghndlr/MsgHndlrTask.c

@@ -25,7 +25,6 @@
 #include "SensorEvent.h"
 #include "SensorEvent.h"
 #include "Chassis.h"
 #include "Chassis.h"
 #include "Storage.h"
 #include "Storage.h"
-#include "cmdselect.h"
 #include "com_IPMI_App.h"
 #include "com_IPMI_App.h"
 #include "com_IPMI_Storage.h"
 #include "com_IPMI_Storage.h"
 #include "com_IPMI_SDR.h"
 #include "com_IPMI_SDR.h"
@@ -48,14 +47,16 @@ MsgHndlrTbl_T m_MsgHndlrTbl [] =	//notice!
 	{ NETFN_SENSOR,                 g_SensorEvent_CmdHndlr          },
 	{ NETFN_SENSOR,                 g_SensorEvent_CmdHndlr          },
 	{ NETFN_STORAGE,                g_Storage_CmdHndlr              },
 	{ NETFN_STORAGE,                g_Storage_CmdHndlr              },
 	{ NETFN_TRANSPORT,              g_Config_CmdHndlr               },
 	{ NETFN_TRANSPORT,              g_Config_CmdHndlr               },
-//	{ NETFN_AMI,                    (CmdHndlrMap_T*)g_AMI_CmdHndlr  },
+	{ NETFN_OEM,               		g_Oem_CmdHndlr      		    },
+    { NETFN_STORLEAD,               g_Storlead_CmdHndlr   			},
 	{	0,							0	},
 	{	0,							0	},
 };
 };
 
 
 
 
 GroupExtnMsgHndlrTbl_T m_GroupExtnMsgHndlrTbl [] =		//jimbo add
 GroupExtnMsgHndlrTbl_T m_GroupExtnMsgHndlrTbl [] =		//jimbo add
 {
 {
-	{0,		0},
+	/*{NetFn,	GroupExtnCode,	CmdHndlrMap} */
+	{0,		0,		0}
 };
 };
 
 
 
 
@@ -85,8 +86,8 @@ TimerTaskTbl_T    m_TimerTaskTbl [20] =
 //PendingBridgedResTbl_T	m_PendingBridgedResTbl[MAX_PENDING_BRIDGE_RES];
 //PendingBridgedResTbl_T	m_PendingBridgedResTbl[MAX_PENDING_BRIDGE_RES];
 
 
 PendingBridgedResTbl_T	m_PendingBridgedResTbl[MAX_PENDING_BRIDGE_TBL][MAX_PENDING_BRIDGE_RES];
 PendingBridgedResTbl_T	m_PendingBridgedResTbl[MAX_PENDING_BRIDGE_TBL][MAX_PENDING_BRIDGE_RES];
-PendingSeqNoTbl_T	m_PendingSeqNoTbl[16][MAX_PENDING_SEQ_NO];
-KCSBridgeResInfo_T       m_KCSBridgeResInfo;
+PendingSeqNoTbl_T		m_PendingSeqNoTbl[16][MAX_PENDING_SEQ_NO];
+//KCSBridgeResInfo_T      m_KCSBridgeResInfo;
 int gFd_MsgHndlrIfc;
 int gFd_MsgHndlrIfc;
 TLS_T g_tls;
 TLS_T g_tls;
 /*!
 /*!
@@ -271,7 +272,13 @@ ValidateMsgHdr (MsgPkt_T* pReq)
 				 }
 				 }
 						
 						
 				 /* Post the data to Destination Interface queue */
 				 /* Post the data to Destination Interface queue */
-//				 printf("===> ValidateMsgHdr post message to %d\n", Queuefd);
+				 //printf("Post2UDS %d: \n", Queuefd);
+				 // int i;
+				 // for(i=0;i<pReq->Size;i++)
+				 // {
+				 // 	printf("%02x ", pReq->Data[i]);
+				 // }
+				 // printf("\n");
 				 PostMsg (Queuefd, pReq);
 				 PostMsg (Queuefd, pReq);
 
 
 				 m_PendingBridgedResTbl[PBTbl][SeqNum].Used = FALSE;
 				 m_PendingBridgedResTbl[PBTbl][SeqNum].Used = FALSE;
@@ -303,7 +310,6 @@ ProcessIPMIReq (MsgPkt_T* pReq, MsgPkt_T* pRes)
 	int8_t 				MsgHndlrMapGot=0;
 	int8_t 				MsgHndlrMapGot=0;
 	uint8_t              PBTbl = PRIMARY_PB_TBL;
 	uint8_t              PBTbl = PRIMARY_PB_TBL;
 	
 	
-//	msgHndlr_dbg_printf ("Processing IPMI Packet.\r\n");
 
 
 	/* Set the Cmd and Net function in response packet */
 	/* Set the Cmd and Net function in response packet */
 	pRes->Cmd		= 	pReq->Cmd;
 	pRes->Cmd		= 	pReq->Cmd;
@@ -316,13 +322,11 @@ ProcessIPMIReq (MsgPkt_T* pReq, MsgPkt_T* pRes)
 	
 	
 	if ((SYS_IFC_CHANNEL != pReq->Channel) && (USB_CHANNEL != pReq->Channel) && (UDS_CHANNEL != pReq->Channel))
 	if ((SYS_IFC_CHANNEL != pReq->Channel) && (USB_CHANNEL != pReq->Channel) && (UDS_CHANNEL != pReq->Channel))
 	{
 	{
-		//printf("log 1, pReq->Channel: %#x\n", pReq->Channel);
 		HdrOffset = sizeof (IPMIMsgHdr_T);
 		HdrOffset = sizeof (IPMIMsgHdr_T);
 		pReq->Size  = pReq->Size - HdrOffset - 1;	//remove header and checksum2
 		pReq->Size  = pReq->Size - HdrOffset - 1;	//remove header and checksum2
 	}
 	}
 	if(UDS_CHANNEL == pReq->Channel)
 	if(UDS_CHANNEL == pReq->Channel)
 	{
 	{
-		//printf("log 2, pReq->Size: %d, HdrOffset: %d\n", pReq->Size, HdrOffset);
 		//UDS数据没有校验,UDSHeader + data
 		//UDS数据没有校验,UDSHeader + data
 		HdrOffset = sizeof(IPMIUDSMsg_T);
 		HdrOffset = sizeof(IPMIUDSMsg_T);
 		pReq->Size = pReq->Size -HdrOffset;
 		pReq->Size = pReq->Size -HdrOffset;
@@ -333,30 +337,28 @@ ProcessIPMIReq (MsgPkt_T* pReq, MsgPkt_T* pRes)
 
 
 	pthread_setspecific(g_tls.CurSessionID,&pReq->SessionID);
 	pthread_setspecific(g_tls.CurSessionID,&pReq->SessionID);
 
 
-	if(IsCommandEnabled(NET_FN(pReq->NetFnLUN), &pReq->Data[HdrOffset], pReq->Cmd) != 0)
-	{
-		pRes->Data [HdrOffset] = CC_INV_CMD;
-		printf ("Invalid Net Function 0x%x or Invalid Command 0x%x\n",NET_FN(pReq->NetFnLUN), pReq->Cmd);
-		pRes->Size;//	+= 2;		//??? why
-		return;
-	}
+	// if(IsCommandEnabled(NET_FN(pReq->NetFnLUN), &pReq->Data[HdrOffset], pReq->Cmd) != 0)
+	// {
+	// 	pRes->Data [HdrOffset] = CC_INV_CMD;
+	// 	printf ("Invalid Net Function 0x%x or Invalid Command 0x%x\n",NET_FN(pReq->NetFnLUN), pReq->Cmd);
+	// 	return;
+	// }
 	
 	
-	//Get oem command map
-	MsgHndlrMapGot = PDKGetOEMMsgHndlrMap(NET_FN(pReq->NetFnLUN),&pCmdHndlrMap);
-	if(MsgHndlrMapGot == 0)
-	{
-		CmdOverride = GetCmdHndlr(pReq,pRes,pCmdHndlrMap,HdrOffset,CmdOverride,&pCmdHndlrMap);
-	}	
-	//get standard ipmi command map
-	if((CmdOverride == 0 || MsgHndlrMapGot == -1) )	//OEM commands have no command map.
-    {
+	// //Get oem command map
+	// MsgHndlrMapGot = PDKGetOEMMsgHndlrMap(NET_FN(pReq->NetFnLUN),&pCmdHndlrMap);
+	// if(MsgHndlrMapGot == 0)
+	// {
+	// 	CmdOverride = GetCmdHndlr(pReq,pRes,pCmdHndlrMap,HdrOffset,CmdOverride,&pCmdHndlrMap);
+	// }	
+	// //get standard ipmi command map
+	// if((CmdOverride == 0 || MsgHndlrMapGot == -1) )	//OEM commands have no command map.
+ //    {
 		if (0 != GetMsgHndlrMap (NET_FN (pReq->NetFnLUN), &pCmdHndlrMap))
 		if (0 != GetMsgHndlrMap (NET_FN (pReq->NetFnLUN), &pCmdHndlrMap))
 		{
 		{
 			if (0 != GroupExtnGetMsgHndlrMap (NET_FN (pReq->NetFnLUN), pReq->Data [HdrOffset], &pCmdHndlrMap) )
 			if (0 != GroupExtnGetMsgHndlrMap (NET_FN (pReq->NetFnLUN), pReq->Data [HdrOffset], &pCmdHndlrMap) )
 			{
 			{
 				pRes->Data [HdrOffset] = CC_INV_CMD;
 				pRes->Data [HdrOffset] = CC_INV_CMD;
 				printf ("MsgHndlr.c : Invalid Net Function 0x%x or Invalid Command 0x%x\n",NET_FN(pReq->NetFnLUN), pReq->Cmd);
 				printf ("MsgHndlr.c : Invalid Net Function 0x%x or Invalid Command 0x%x\n",NET_FN(pReq->NetFnLUN), pReq->Cmd);
-				pRes->Size;//	+= 2;
 				return;
 				return;
 			}			
 			}			
 		}
 		}
@@ -364,10 +366,9 @@ ProcessIPMIReq (MsgPkt_T* pReq, MsgPkt_T* pRes)
 		if(GetCmdHndlr(pReq,pRes,pCmdHndlrMap,HdrOffset,CmdOverride,&pCmdHndlrMap) == FALSE)
 		if(GetCmdHndlr(pReq,pRes,pCmdHndlrMap,HdrOffset,CmdOverride,&pCmdHndlrMap) == FALSE)
 		{
 		{
 			pRes->Data [HdrOffset] = CC_INV_CMD;
 			pRes->Data [HdrOffset] = CC_INV_CMD;
-			pRes->Size;//	+= 2;		//??? why
 			return;
 			return;
 		}
 		}
-   }
+   // }
    
    
 	/* Check for the request size */
 	/* Check for the request size */
 	if (0xff != pCmdHndlrMap->ReqLen)
 	if (0xff != pCmdHndlrMap->ReqLen)
@@ -375,9 +376,8 @@ ProcessIPMIReq (MsgPkt_T* pReq, MsgPkt_T* pRes)
 		/* Check for invalid request size */
 		/* Check for invalid request size */
 		if (pCmdHndlrMap->ReqLen != pReq->Size)
 		if (pCmdHndlrMap->ReqLen != pReq->Size)
 		{	
 		{	
-			printf("Warning: Request data len error, require %d\n", pCmdHndlrMap->ReqLen);
+			printf("Warning: Request data len error, require %d, recv %d\n", pCmdHndlrMap->ReqLen, pReq->Size);
 			pRes->Data [HdrOffset] = CC_REQ_INV_LEN;
 			pRes->Data [HdrOffset] = CC_REQ_INV_LEN;
-			pRes->Size;//	+= 2;	//??? why
 			return;
 			return;
 		}
 		}
 	}
 	}
@@ -601,11 +601,6 @@ void RespondSendMessage ( MsgPkt_T* pReq, uint8_t Status)
 		 (pIPMIReqHdr->Cmd               == m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr.Cmd) &&
 		 (pIPMIReqHdr->Cmd               == m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr.Cmd) &&
 		 (pIPMIReqHdr->ResAddr           == m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr.ResAddr)  )
 		 (pIPMIReqHdr->ResAddr           == m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr.ResAddr)  )
 	{
 	{
-		//printf("---> RespondSendMessage/ m_PendingBridgedResTbl: PBTbl: %d, SeqNum %d, log222\n", PBTbl, SeqNum);
-		// int i;
-		// for(i=0;i<6;i++)
-		// 	printf("%#x ", ((uint8_t*)&m_PendingBridgedResTbl[PBTbl][SeqNum].ResMsgHdr.IPMIMsgHdr)[i]);
-		// printf("\n");
 		uint32_t tcnt = 0;
 		uint32_t tcnt = 0;
 		while(m_PendingBridgedResTbl[PBTbl][SeqNum].ResDataOk == 0)
 		while(m_PendingBridgedResTbl[PBTbl][SeqNum].ResDataOk == 0)
 		{
 		{

+ 2 - 0
app/bmc/msghndlr/OemSMMCmds/OemSMMCmds.c

@@ -24,6 +24,8 @@
 #include "com_BmcType.h"
 #include "com_BmcType.h"
 #include "main.h"
 #include "main.h"
 
 
+extern sensor_tbl_t *getSensorDev(uint8_t sensorNum);
+
 int  SMMExample_0h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
 int  SMMExample_0h(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
 {
 {
 	*pRes= CC_NORMAL;
 	*pRes= CC_NORMAL;

+ 75 - 72
app/bmc/msghndlr/PDKCmds.c

@@ -41,40 +41,40 @@
 		return 	sizeof (*pRes);
 		return 	sizeof (*pRes);
   }   
   }   
 */
 */
-const CmdHndlrMap_T	g_Oem_App_CmdHndlr [] =
-{
-    { 0x00,                 0x00,           0x00,              0x00,                              0x0000 }
-};
+// const CmdHndlrMap_T	g_Oem_App_CmdHndlr [] =
+// {
+//     { 0x00,                 0x00,           0x00,              0x00,                              0x0000 }
+// };
 
 
-/*Netfn - Chasiss OEM Command Handler to override generic IPMI cmd */
-const CmdHndlrMap_T	g_Oem_Chassis_CmdHndlr [] =
-{
-    { 0x00,                 0x00,           0x00,              0x00,                              0x0000 }
-};
+// /*Netfn - Chasiss OEM Command Handler to override generic IPMI cmd */
+// const CmdHndlrMap_T	g_Oem_Chassis_CmdHndlr [] =
+// {
+//     { 0x00,                 0x00,           0x00,              0x00,                              0x0000 }
+// };
 
 
-/*Netfn - Bridging OEM Command Handler to override generic  IPMI cmd */
-const CmdHndlrMap_T	g_Oem_Bridge_CmdHndlr [] =
-{
-    { 0x00,                 0x00,           0x00,              0x00,                              0x0000 }
-};
+// /*Netfn - Bridging OEM Command Handler to override generic  IPMI cmd */
+// const CmdHndlrMap_T	g_Oem_Bridge_CmdHndlr [] =
+// {
+//     { 0x00,                 0x00,           0x00,              0x00,                              0x0000 }
+// };
 
 
-/*Netfn - Sensor OEM Command Handler to override generic IPMI cmd */
-const CmdHndlrMap_T	g_Oem_SensorEvent_CmdHndlr [] =
-{
-    { 0x00,                 0x00,           0x00,              0x00,                              0x0000 }
-};
+// /*Netfn - Sensor OEM Command Handler to override generic IPMI cmd */
+// const CmdHndlrMap_T	g_Oem_SensorEvent_CmdHndlr [] =
+// {
+//     { 0x00,                 0x00,           0x00,              0x00,                              0x0000 }
+// };
 
 
-/*Netfn - Storage OEM Command Handler to override generic IPMI cmd */
-const CmdHndlrMap_T	g_Oem_Storage_CmdHndlr [] =
-{
-    { 0x00,                 0x00,           0x00,              0x00,                              0x0000 }
-};
+// /*Netfn - Storage OEM Command Handler to override generic IPMI cmd */
+// const CmdHndlrMap_T	g_Oem_Storage_CmdHndlr [] =
+// {
+//     { 0x00,                 0x00,           0x00,              0x00,                              0x0000 }
+// };
 
 
-/*Netfn - Transport OEM Command Handler to override generic IPMI cmd */
-const CmdHndlrMap_T	g_Oem_Config_CmdHndlr [] =
-{
-    { 0x00,                 0x00,           0x00,              0x00,                              0x0000 }
-};
+// /*Netfn - Transport OEM Command Handler to override generic IPMI cmd */
+// const CmdHndlrMap_T	g_Oem_Config_CmdHndlr [] =
+// {
+//     { 0x00,                 0x00,           0x00,              0x00,                              0x0000 }
+// };
 
 
 /*Netfn - OEM cmd */
 /*Netfn - OEM cmd */
 const CmdHndlrMap_T	g_Oem_CmdHndlr [] =	//jimbo add
 const CmdHndlrMap_T	g_Oem_CmdHndlr [] =	//jimbo add
@@ -346,58 +346,61 @@ const CmdHndlrMap_T g_Storlead_CmdHndlr [] =
     { CMD_SET_LAN_INFO,      PRIV_USER,      Storlead_SetLanInfo,         0xff,  0xAAAA  ,0xFFFF},
     { CMD_SET_LAN_INFO,      PRIV_USER,      Storlead_SetLanInfo,         0xff,  0xAAAA  ,0xFFFF},
     { CMD_GET_BLADE_INFO,      PRIV_USER,      Storlead_GetBladeInfo,         0xff,  0xAAAA  ,0xFFFF},
     { CMD_GET_BLADE_INFO,      PRIV_USER,      Storlead_GetBladeInfo,         0xff,  0xAAAA  ,0xFFFF},
     { CMD_GET_SENSOR_NAME,      PRIV_USER,      Storlead_GetSensorName,         0xff,  0xAAAA  ,0xFFFF},
     { CMD_GET_SENSOR_NAME,      PRIV_USER,      Storlead_GetSensorName,         0xff,  0xAAAA  ,0xFFFF},
+    { CMD_GET_CURRUNTIME,      PRIV_USER,      Storlead_GetCurRunTime,         0xff,  0xAAAA  ,0xFFFF},    
+    { CMD_SAVE_CONFIG,      PRIV_USER,      Storlead_SaveConfig,         0xff,  0xAAAA  ,0xFFFF},    
+    { CMD_RESTORE_CONFIG,      PRIV_USER,      Storlead_RestoreConfig,         0xff,  0xAAAA  ,0xFFFF},        
      { 0x00,                     0x00,           0x00,                 0x00, 0x0000  ,  0x0000},
      { 0x00,                     0x00,           0x00,                 0x00, 0x0000  ,  0x0000},
 };
 };
 
 
 
 
-/*OEM Message Handler table to override generic IPMI cmd
-  Any OEM specific Netfn and Command Handler can also be
-  added here*/
-const MsgHndlrTbl_T oem_MsgHndlrTbl [] =	
-{
-    // { NETFN_APP,                     g_Oem_App_CmdHndlr             },
-    // { NETFN_CHASSIS,                 g_Oem_Chassis_CmdHndlr         },
-    // { NETFN_BRIDGE,                  g_Oem_Bridge_CmdHndlr          },
-    // { NETFN_SENSOR,                  g_Oem_SensorEvent_CmdHndlr     },
-    // { NETFN_STORAGE,                 g_Oem_Storage_CmdHndlr         },
-    // { NETFN_TRANSPORT,               g_Oem_Config_CmdHndlr          },
-    { NETFN_OEM,               		 g_Oem_CmdHndlr      		     },
-    {NETFN_STORLEAD,                   g_Storlead_CmdHndlr   },
-
-};
+// /*OEM Message Handler table to override generic IPMI cmd
+//   Any OEM specific Netfn and Command Handler can also be
+//   added here*/
+// const MsgHndlrTbl_T oem_MsgHndlrTbl [] =	
+// {
+//     // { NETFN_APP,                     g_Oem_App_CmdHndlr             },
+//     // { NETFN_CHASSIS,                 g_Oem_Chassis_CmdHndlr         },
+//     // { NETFN_BRIDGE,                  g_Oem_Bridge_CmdHndlr          },
+//     // { NETFN_SENSOR,                  g_Oem_SensorEvent_CmdHndlr     },
+//     // { NETFN_STORAGE,                 g_Oem_Storage_CmdHndlr         },
+//     // { NETFN_TRANSPORT,               g_Oem_Config_CmdHndlr          },
+//     { NETFN_OEM,               		 g_Oem_CmdHndlr      		     },
+//     {NETFN_STORLEAD,                   g_Storlead_CmdHndlr   },
 
 
-/**
-*@fn PDKGetOEMMsgHndlrMap 
-*@brief Helps in getting command handler for specific NetFn
-*@parm NetFn -NetFunction
-*@param pCmdHndlrMap - Command Handler for the given NetFn
-*@return Returns 0 on success and -1 on failure
-*/
-int
-PDKGetOEMMsgHndlrMap (uint8_t NetFn, CmdHndlrMap_T ** pCmdHndlrMap)
-{
-    int i;
+// };
+// 
+// /**
+// *@fn PDKGetOEMMsgHndlrMap 
+// *@brief Helps in getting command handler for specific NetFn
+// *@parm NetFn -NetFunction
+// *@param pCmdHndlrMap - Command Handler for the given NetFn
+// *@return Returns 0 on success and -1 on failure
+// */
+// int
+// PDKGetOEMMsgHndlrMap (uint8_t NetFn, CmdHndlrMap_T ** pCmdHndlrMap)
+// {
+//     int i;
 
 
-    /* Get the command handler corresponding to the net function */
-    for (i = 0; i < sizeof (oem_MsgHndlrTbl) / sizeof (oem_MsgHndlrTbl [0]); i++)
-    {
-        if (oem_MsgHndlrTbl [i].NetFn == NetFn) 
-        {
-            break; 
-        }
-    }
+//     /* Get the command handler corresponding to the net function */
+//     for (i = 0; i < sizeof (oem_MsgHndlrTbl) / sizeof (oem_MsgHndlrTbl [0]); i++)
+//     {
+//         if (oem_MsgHndlrTbl [i].NetFn == NetFn) 
+//         {
+//             break; 
+//         }
+//     }
 
 
-    /* Check if we have not found our net function */
-    if (i == sizeof (oem_MsgHndlrTbl) / sizeof (oem_MsgHndlrTbl [0]))
-    {
-        return -1;
-    }
+//     /* Check if we have not found our net function */
+//     if (i == sizeof (oem_MsgHndlrTbl) / sizeof (oem_MsgHndlrTbl [0]))
+//     {
+//         return -1;
+//     }
 
 
-    /* Get the handler corresponding to the command */
-    *pCmdHndlrMap = (CmdHndlrMap_T*)oem_MsgHndlrTbl [i].CmdHndlrMap;
+//     /* Get the handler corresponding to the command */
+//     *pCmdHndlrMap = (CmdHndlrMap_T*)oem_MsgHndlrTbl [i].CmdHndlrMap;
     
     
-    return 0;
-}
+//     return 0;
+// }
 
 
 
 
 
 

+ 4 - 1
app/bmc/msghndlr/PDKCmds.h

@@ -46,6 +46,9 @@ typedef struct
 
 
 } OwnerIDMap_T;
 } OwnerIDMap_T;
 
 
+extern const CmdHndlrMap_T	g_Oem_CmdHndlr [];
+extern const CmdHndlrMap_T g_Storlead_CmdHndlr [];
+
 /**
 /**
 *@fn PDKGetOEMMsgHndlrMap 
 *@fn PDKGetOEMMsgHndlrMap 
 *@brief Helps in getting command handler for particular NetFn
 *@brief Helps in getting command handler for particular NetFn
@@ -54,7 +57,7 @@ typedef struct
 *@param BMCInst - BMC instances
 *@param BMCInst - BMC instances
 *@return Returns 0 on success and -1 for failure
 *@return Returns 0 on success and -1 for failure
 */
 */
-extern int	  PDKGetOEMMsgHndlrMap (uint8_t NetFn, CmdHndlrMap_T ** pCmdHndlrMap);
+//extern int	  PDKGetOEMMsgHndlrMap (uint8_t NetFn, CmdHndlrMap_T ** pCmdHndlrMap);
 
 
 #endif	/* PDKCMDS_H */
 #endif	/* PDKCMDS_H */
 
 

+ 2 - 20
app/bmc/msghndlr/SensorEvent/SensorDevice/SensorMonitor.c

@@ -206,7 +206,6 @@ MonitorTSensors ( SensorInfo_T*     pSensorInfo)
 	int16_t                   CriticalLow;
 	int16_t                   CriticalLow;
 	int16_t                   NonRecoverableHigh;
 	int16_t                   NonRecoverableHigh;
 	int16_t                   NonRecoverableLow;
 	int16_t                   NonRecoverableLow;
-//	uint8_t                   SensorLevel;
 	uint8_t                   SettableThreshMask;
 	uint8_t                   SettableThreshMask;
 	uint8_t		    	 	  SensorReading;
 	uint8_t		    	 	  SensorReading;
 	uint8_t  		    		PSGood = 0;
 	uint8_t  		    		PSGood = 0;
@@ -216,17 +215,10 @@ MonitorTSensors ( SensorInfo_T*     pSensorInfo)
 	uint8_t                       DeassertionHistoryByte1;
 	uint8_t                       DeassertionHistoryByte1;
 	uint8_t                       DeassertionHistoryByte2;
 	uint8_t                       DeassertionHistoryByte2;
 	uint8_t                   OEMField;
 	uint8_t                   OEMField;
-//	uint8_t			    	SensorNum;	
 	uint8_t                	SignedSensor = 0; // 1 if sensor has signed values
 	uint8_t                	SignedSensor = 0; // 1 if sensor has signed values
 	int16_t               	SensorMax = 255;
 	int16_t               	SensorMax = 255;
 	int16_t               	SensorMin = 0;
 	int16_t               	SensorMin = 0;
-	//uint16_t_t              OrgSensorValue;
 	int16_t               	DeassertThreshold;
 	int16_t               	DeassertThreshold;
-	// Added for Sensor Override capability
-//	int                 	Override = 0;
-//	uint8_t 				ReadFlags = 0;
-//	FullSensorRec_T*      	sfs=NULL;
-//	CompactSensorRec_T*   	scs=NULL;
 	int				index,j;
 	int				index,j;
 	
 	
 	PSGood = g_BMCInfo.PowerGoodFlag;
 	PSGood = g_BMCInfo.PowerGoodFlag;
@@ -244,19 +236,10 @@ MonitorTSensors ( SensorInfo_T*     pSensorInfo)
 	else
 	else
 	{
 	{
 		pSensorInfo->Err	=	get_sensor_reading(pSensorInfo->SensorNumber, &SensorReading);
 		pSensorInfo->Err	=	get_sensor_reading(pSensorInfo->SensorNumber, &SensorReading);
-		
-//		if (FULL_SDR_REC == pSensorInfo->SDRRec->Type)
-//		{
-//			sfs = ( FullSensorRec_T*)pSensorInfo->SDRRec;
-//		}
-//		else if (COMPACT_SDR_REC==pSensorInfo->SDRRec->Type)
-//		{
-//			scs = ( CompactSensorRec_T*)pSensorInfo->SDRRec;
-//		}
 		pSensorInfo->SensorReading = SensorReading;
 		pSensorInfo->SensorReading = SensorReading;
 		
 		
 		//keep sensor history
 		//keep sensor history
-		if((g_BMCInfo.CurTimerSecond%180 == 0))	//3 minutes
+		//if((g_BMCInfo.CurTimerSecond%180 == 0))	//3 minutes
 		{
 		{
 			for(index=0; index<SENSOR_NUMBERS;index++)
 			for(index=0; index<SENSOR_NUMBERS;index++)
 			{
 			{
@@ -269,8 +252,7 @@ MonitorTSensors ( SensorInfo_T*     pSensorInfo)
 					gSensorHistoryInfo[index].History[HISTORY_DATA_SIZE-1] = pSensorInfo->SensorReading;
 					gSensorHistoryInfo[index].History[HISTORY_DATA_SIZE-1] = pSensorInfo->SensorReading;
 				}
 				}
 			}
 			}
-		}
-		
+		}		
 	}
 	}
 
 
 
 

+ 5 - 45
app/bmc/msghndlr/Storage/SELDevice/SEL.c

@@ -941,54 +941,14 @@ static uint8_t SELTimeClockSync(uint8_t Action)
     SELEventRecord_T *EventRec = (SELEventRecord_T*)m_SysEventMsg;
     SELEventRecord_T *EventRec = (SELEventRecord_T*)m_SysEventMsg;
     uint8_t pRes[sizeof(AddSELRes_T)];
     uint8_t pRes[sizeof(AddSELRes_T)];
 
 
-    EventRec->SensorNum  = 0xFF;
-    EventRec->EvtDirType = 0x6F;    // Sensor Specific
-    EventRec->EvtData1   = 0x05;    // Offset 05h - Timestamp Clock Sync
-    EventRec->EvtData2   = Action;
-    EventRec->EvtData3   = 0xFF;
+    EventRec->body.sysEventRecord.SensorNum  = 0xFF;
+    EventRec->body.sysEventRecord.EvtDirType = 0x6F;    // Sensor Specific
+    EventRec->body.sysEventRecord.EvtData1   = 0x05;    // Offset 05h - Timestamp Clock Sync
+    EventRec->body.sysEventRecord.EvtData2   = Action;
+    EventRec->body.sysEventRecord.EvtData3   = 0xFF;
 
 
     LockedAddSELEntry((uint8_t*)EventRec, sizeof(SELEventRecord_T), pRes);
     LockedAddSELEntry((uint8_t*)EventRec, sizeof(SELEventRecord_T), pRes);
     
     
     return 0;
     return 0;
 }
 }
 
 
-
-///*---------------------------------------------------------------------------
-// * @fn SetSELPolicy
-// *
-// * @brief This function is invoked when switch SEL policy, make appropriate
-// *        adjustment for environment variables that related to SEL buffer.
-// *
-// * @param   Policy  - Specify Linear SEL policy or Circular SEL policy.
-// * @param   BMCInst - Index of BMC instance.
-// *---------------------------------------------------------------------------*/
-//void
-//SetSELPolicy(uint8_t Policy)
-//{
-////    SELRepository_T* m_sel = NULL;
-
-//	m_sel = (SELRepository_T*)g_BMCInfo.pSEL;
-
-//    switch (Policy)
-//    {
-//        case LINEAR_SEL:
-//            /* Reset LastRecID because GetNextSELEntry func will stop finding the next record if RecID >= LastRecRD,
-//               but RecID may greater than LastRecID in Circular SEL mode. */
-///*            LOCK_BMC_SHARED_MEM(BMCInst);
-//            BMC_GET_SHARED_MEM (BMCInst)->m_LastRecID = m_sel->SELRecord[pBMCInfo->SELConfig.MaxSELRecord].EvtRecord.hdr.ID;
-//            BMC_GET_SHARED_MEM (BMCInst)->m_SELIndex = m_sel->NumRecords;
-//            BMC_GET_SHARED_MEM (BMCInst)->m_FirstRecID = m_sel->SELRecord[0].EvtRecord.hdr.ID;
-//            UNLOCK_BMC_SHARED_MEM(BMCInst);*/
-//            break;
-
-//        case CIRCULAR_SEL:
-//            /*Update the Last and First Record ID when switch back to Circular-linear-Circular cycle */
-////            if(m_sel->NumRecords == g_BMCInfo.SELConfig.MaxSELRecord)
-////            {
-////                FindRecOrder();
-////            }
-//            break;
-//    }
-//}
-
-

+ 158 - 11
app/bmc/msghndlr/Storlead/Storlead.c

@@ -8,16 +8,19 @@
 #include "com_IPMI_SDRRecord.h"
 #include "com_IPMI_SDRRecord.h"
 #include "SDR.h"
 #include "SDR.h"
 #include "SELRecord.h"
 #include "SELRecord.h"
+#include "driver.h"
+#include "fcntl.h"
+#include "Api.h"
 
 
 int  Storlead_GetSysInfo(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
 int  Storlead_GetSysInfo(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
 {
 {
 	char Title[] = "系统信息";
 	char Title[] = "系统信息";
 	char Text[] = "模块名称:多端口光纤接口模块;FPGA型号:XC7VX690T;简介: ";
 	char Text[] = "模块名称:多端口光纤接口模块;FPGA型号:XC7VX690T;简介: ";
 	int len = 0,remainLen = 0;
 	int len = 0,remainLen = 0;
-	uint16_t offset = (pReq[1]<<8) | pReq[2];
+	uint16_t offset = (pReq[2]<<8) | pReq[1];
 	int totalLen = 0;
 	int totalLen = 0;
 	char *pStr = NULL;
 	char *pStr = NULL;
-	int reqLen = (pReq[3]<<8) | pReq[4];
+	int reqLen = (pReq[4]<<8) | pReq[3];
 	
 	
 	switch(pReq[0])
 	switch(pReq[0])
 	{
 	{
@@ -25,7 +28,8 @@ int  Storlead_GetSysInfo(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
 		while(Title[totalLen])
 		while(Title[totalLen])
 		{
 		{
 			totalLen++;
 			totalLen++;
-		}printf("title total len = %#x\n",totalLen);
+		}
+        //printf("title total len = %#x\n",totalLen);
 		pStr = Title;
 		pStr = Title;
 		break;
 		break;
 	case 1:
 	case 1:
@@ -33,7 +37,7 @@ int  Storlead_GetSysInfo(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
 		{
 		{
 			totalLen++;
 			totalLen++;
 		}
 		}
-		printf("text total len = %#x\n", totalLen);
+		//printf("text total len = %#x\n", totalLen);
 		pStr = Text;
 		pStr = Text;
 		break;
 		break;
 	default:
 	default:
@@ -60,10 +64,11 @@ int  Storlead_GetSysInfo(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
 	}
 	}
 	
 	
 	remainLen = totalLen - offset - len;
 	remainLen = totalLen - offset - len;
-	*(pRes+1) = (len>>8)&0xff;
-	*(pRes+2) = len&0xff;
-	*(pRes+3) = (remainLen>>8)&0xff;
-	*(pRes+4) = remainLen&0xff;
+	*(pRes+1) = len&0xff;
+    *(pRes+2) = (len>>8)&0xff;
+	*(pRes+3) = remainLen&0xff;
+    *(pRes+4) = (remainLen>>8)&0xff;
+	
 	memcpy(pRes+5, pStr+offset, len);
 	memcpy(pRes+5, pStr+offset, len);
 
 
 	// int i;
 	// int i;
@@ -77,8 +82,6 @@ int  Storlead_GetSysInfo(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
 
 
 int  Storlead_GetSensorInfo(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
 int  Storlead_GetSensorInfo(uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
 {
 {
-//	printf("Storlead_GetSensorInfo\n" );
-
 	StorleadGetSensorInfoRes_T *pGetSensorInfoRes = (StorleadGetSensorInfoRes_T *)pRes;
 	StorleadGetSensorInfoRes_T *pGetSensorInfoRes = (StorleadGetSensorInfoRes_T *)pRes;
     uint8_t*   		pValidSensor = NULL;
     uint8_t*   		pValidSensor = NULL;
     uint16_t       	SensorIndex = pReq[0];
     uint16_t       	SensorIndex = pReq[0];
@@ -336,7 +339,7 @@ int Storlead_GetSensorHistory(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
     
     
     if(len > (total_len - offset))
     if(len > (total_len - offset))
         len = total_len - offset;
         len = total_len - offset;
-    printf("len = %d, offset = %d, total_len = %d\n", len, offset, total_len);
+    printf("Storlead_GetSensorHistory(): len = %d, offset = %d, total_len = %d\n", len, offset, total_len);
     
     
     *(pRes+1) = len&0xff;
     *(pRes+1) = len&0xff;
     *(pRes+2) = (len>>8)&0xff;
     *(pRes+2) = (len>>8)&0xff;
@@ -492,7 +495,9 @@ int Storlead_RestoreFactorSettings(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
     int i;
     int i;
     pRes[0] = CC_NORMAL;
     pRes[0] = CC_NORMAL;
     //擦除Flash   IpmiConfig
     //擦除Flash   IpmiConfig
+    pthread_mutex_lock(&Flash_Mutex);
     sf_sector_erase(5, CONFIG_FLASH_START);
     sf_sector_erase(5, CONFIG_FLASH_START);
+    pthread_mutex_unlock(&Flash_Mutex);
 
 
     return 1;
     return 1;
 }
 }
@@ -618,4 +623,146 @@ int Storlead_GetSensorName(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
     }
     }
 
 
     return MAX_ID_STR_LEN+1;
     return MAX_ID_STR_LEN+1;
+}
+
+int Storlead_GetCurRunTime(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
+{
+    pRes[0] = CC_NORMAL;
+    pRes[1] = g_BMCInfo.BootValidMinutes&0xff;        //LSB
+    pRes[2] = (g_BMCInfo.BootValidMinutes>>8)&0xff;
+    pRes[3] = (g_BMCInfo.BootValidMinutes>>16)&0xff;
+    pRes[4] = (g_BMCInfo.BootValidMinutes>>24)&0xff;
+    return 5;
+}
+
+int Storlead_SaveConfig(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
+{
+    pRes[0] = CC_NORMAL;
+    int i;
+    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 = 8;
+    ret = ioctl(fd, IFLASH_ERASESECTOR, &iflash_arg);
+    if(ret != 0)
+    {
+        printf("error: ret = %d\n", ret);
+    }
+
+    /**** IpmiConfig + user info + FRU + SDR ****/
+    //IpmiConfig    4KB
+    iflash_arg.address = 0x08080000;
+    iflash_arg.len = sizeof(IPMIConfig_T);  //最大256字节
+    memcpy(iflash_arg.data, &g_BMCInfo.IpmiConfig, sizeof(IPMIConfig_T));
+    ret = ioctl(fd, IFLASH_WRITEBYTE, &iflash_arg);
+    if(ret != 0)
+    {
+        printf("error: ret = %d\n", ret);
+    }
+    //user info     4KB
+    uint8_t usrinfolen = 50;//sizeof(UserInfo_T);
+    for(i=0;i<MAX_USER_NUM;i++)
+    {
+        iflash_arg.address = 0x08081000 + usrinfolen*i;//sizeof(UserInfo_T)*i;
+        iflash_arg.len = usrinfolen;//sizeof(UserInfo_T);  //最大256字节
+        memcpy(iflash_arg.data, &(g_BMCInfo.UserInfoTbl[i]), usrinfolen);
+        ret = ioctl(fd, IFLASH_WRITEBYTE, &iflash_arg);
+        if(ret != 0)
+        {
+            printf("error: ret = %d\n", ret);
+        }
+    }    
+    //FRU           4KB
+    iflash_arg.address = 0x08082000;
+    iflash_arg.len = sizeof(OemFRUData_T);  //最大256字节
+    memcpy(iflash_arg.data, &g_BMCInfo.FRU, sizeof(OemFRUData_T));
+    ret = ioctl(fd, IFLASH_WRITEBYTE, &iflash_arg);
+    if(ret != 0)
+    {
+        printf("error: ret = %d\n", ret);
+    }
+    //SDR           4KB
+    uint32_t    sdrSize =
+        sizeof(SDRRepository_T) + sizeof(HdrMgmtCtrlrDevLocator_T) + sizeof(HdrFullSensorRec_T)*SENSOR_NUMBERS;     
+    uint32_t    writebytes = 0;
+    while(sdrSize>0)
+    {   
+        iflash_arg.address = 0x08083000 + writebytes;
+        if(sdrSize > 256)
+        {            
+            iflash_arg.len = 256;  //最大256字节                                
+            memcpy(iflash_arg.data, g_BMCInfo.pSDR+writebytes, 256);
+            // printf("L1: ");
+            // for(i=0;i<iflash_arg.len;i++)
+            //     printf("%02x ", iflash_arg.data[i]);
+            // printf("\n"); 
+            writebytes += 256;
+            sdrSize -= 256;
+        }
+        else
+        {
+            iflash_arg.len = sdrSize;  //最大256字节                        
+            memcpy(iflash_arg.data, g_BMCInfo.pSDR+writebytes, sdrSize);
+            // printf("L2: ");
+            // for(i=0;i<iflash_arg.len;i++)
+            //     printf("%02x ", iflash_arg.data[i]);
+            // printf("\n"); 
+            writebytes += sdrSize;
+            sdrSize = 0;
+        }
+        
+        ret = ioctl(fd, IFLASH_WRITEBYTE, &iflash_arg);
+        if(ret != 0)
+        {
+            printf("error: ret = %d\n", ret);
+        }
+    }
+
+    ret = ioctl(fd, IFLASH_LOCK, NULL);
+    if(ret != 0)
+    {
+        printf("error: ret = %d\n", ret);
+    }
+    
+    close(fd);
+
+    return 1;
+}
+
+int Storlead_RestoreConfig(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes)
+{
+    pRes[0] = CC_NORMAL;    
+    int i;
+    /**** IpmiConfig + user info + FRU + SDR ****/
+    //IpmiConfig    4KB
+    memcpy(&g_BMCInfo.IpmiConfig, (uint8_t*)0x08080000, sizeof(IPMIConfig_T));
+    FlushIPMIToFlash();
+    //user info     4KB
+    uint8_t usrinfolen = 50;
+    for(i=0;i<MAX_USER_NUM;i++)
+    {
+        memcpy(&(g_BMCInfo.UserInfoTbl[i]), (uint8_t*)0x08081000 + usrinfolen*i, sizeof(UserInfo_T));
+    }
+    FlushUserInfoTbl();
+    //FRU           4KB
+    memcpy(&g_BMCInfo.FRU, (uint8_t*)0x08082000, sizeof(OemFRUData_T));
+    FlushFRUToFlash();
+    //SDR           4KB
+    uint32_t    sdrSize =
+        sizeof(SDRRepository_T) + sizeof(HdrMgmtCtrlrDevLocator_T) + 
+        sizeof(HdrFullSensorRec_T)*SENSOR_NUMBERS;     
+    memcpy(g_BMCInfo.pSDR, (uint8_t*)0x08083000, sdrSize);
+    // printf("read: ");
+    // for(i=0;i<sdrSize;i++)
+    //     printf("%02x ", ((uint8_t*)0x08083000)[i]);
+    // printf("\n"); 
+    FlushSDRToFlash();
+        
+    return 1;
 }
 }

+ 3 - 0
app/bmc/msghndlr/Storlead/Storlead.h

@@ -15,3 +15,6 @@ int Storlead_GetLanInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
 int Storlead_SetLanInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
 int Storlead_SetLanInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
 int Storlead_GetBladeInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
 int Storlead_GetBladeInfo(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
 int Storlead_GetSensorName(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
 int Storlead_GetSensorName(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
+int Storlead_GetCurRunTime(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
+int Storlead_SaveConfig(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);
+int Storlead_RestoreConfig(uint8_t *pReq, uint8_t ReqLen, uint8_t *pRes);

+ 0 - 922
app/bmc/msghndlr/cmdselect.c

@@ -1,922 +0,0 @@
-/******************************************************************
- ******************************************************************
- ***                                                                                                           **
- ***    (C)Copyright 2011, American Megatrends Inc.                                     **
- ***                                                                                                           **
- ***    All Rights Reserved.                                                                          **
- ***                                                                                                           **
- ***    5555 , Oakbrook Pkwy, Norcross,                                                       **
- ***                                                                                                           **
- ***    Georgia - 30093, USA. Phone-(770)-246-8600.                                  **
- ***                                                                                                           **
- ******************************************************************
- ******************************************************************
- ******************************************************************
- *
- * cmdselect.c
- * OEM can enable or disable IPMI Command accoring to requirements
- *
- *  Author: Winston <winstonv@amiindia.co.in>
- ******************************************************************/
-#include <stdio.h>
-#include "com_BmcType.h"
-#include "cmdselect.h"
-
-#include "com_IPMI_App.h"
-#include "com_IPMI_Bridge.h"
-#include "com_IPMI_PICMG.h"
-#include "com_IPMI_Chassis.h"
-#include "com_IPMI_SensorEvent.h"
-#include "com_IPMI_Storage.h"
-#include "OemSMMCmds.h"
-#include "Storlead.h"
-//#include "com_IPMI_Transport.h"
-#include "com_IPMI_DeviceConfig.h"
-//#include "OemSMMCmds.h"
-//#include "main.h"
-
-#define ENABLED 0x1
-#define DISABLED 0xff
-
-const NetFnCmds_T g_App [] = 
-{
-	/* IPM Device Commands */
-	{CMD_GET_DEV_ID                                                 , ENABLED},
-	{CMD_BROADCAST_GET_DEV_ID                             ,DISABLED},
-	{CMD_COLD_RESET                                                 ,ENABLED},
-	{CMD_WARM_RESET                                                ,ENABLED},
-	{CMD_GET_SELF_TEST_RESULTS                              ,ENABLED},
-	{CMD_MFG_TEST_ON                                               ,ENABLED},
-	{CMD_SET_ACPI_PWR_STATE                                  ,ENABLED},
-	{CMD_GET_ACPI_PWR_STATE                                 ,ENABLED},
-	{CMD_GET_DEV_GUID                                            ,ENABLED},
-	{CMD_GET_NETFN_SUP                                           ,ENABLED},
-	{CMD_GET_CMD_SUP                                             ,ENABLED},
-	{CMD_GET_SUBFN_SUP                                          ,DISABLED},
-	{CMD_GET_CONFIG_CMDS                                     ,ENABLED},
-	{CMD_GET_CONFIG_SUB_FNS                                ,DISABLED},
-	{CMD_SET_CMD_ENABLES                                     ,ENABLED},
-	{CMD_GET_CMD_ENABLES                                     ,ENABLED},
-	{CMD_SET_SUBFN_ENABLES                                  ,DISABLED},
-	{CMD_GET_SUBFN_ENABLES                                  ,DISABLED},
-	{CMD_GET_OEM_NETFN_IANA_SUPPORT                 ,ENABLED},
-	/*    WatchDog Timer Commands  */
-	{CMD_RESET_WDT                                               ,ENABLED},
-	{CMD_SET_WDT                                                   ,ENABLED},
-	{CMD_GET_WDT                                                   ,ENABLED},
-
-	/*    BMC Device and Messaging Commands   */
-	{ CMD_SET_BMC_GBL_ENABLES                           ,ENABLED},
-	{ CMD_GET_BMC_GBL_ENABLES                           ,ENABLED},
-	{ CMD_CLR_MSG_FLAGS                                      ,ENABLED},
-	{ CMD_GET_MSG_FLAGS                                      ,ENABLED},
-	{ CMD_ENBL_MSG_CH_RCV                                  ,ENABLED},
-	{ CMD_GET_MSG                                                 ,ENABLED},
-	{ CMD_SEND_MSG                                               ,ENABLED},
-	{ CMD_READ_EVT_MSG_BUFFER                           ,ENABLED},
-	{ CMD_GET_BTIFC_CAP                                       ,ENABLED},
-	{ CMD_GET_SYSTEM_GUID                                  ,ENABLED},
-	{ CMD_GET_CH_AUTH_CAP                                  ,ENABLED},
-	{ CMD_GET_SESSION_CHALLENGE                       ,ENABLED},
-	{ CMD_ACTIVATE_SESSION                                 ,ENABLED},
-	{ CMD_SET_SESSION_PRIV_LEVEL                       ,ENABLED},
-	{ CMD_CLOSE_SESSION                                      ,ENABLED},
-	{ CMD_GET_SESSION_INFO                                 ,ENABLED},
-	{ CMD_GET_AUTH_CODE                                     ,ENABLED},
-	{ CMD_SET_CH_ACCESS                                     ,ENABLED},
-	{ CMD_GET_CH_ACCESS                                     ,ENABLED},
-	{ CMD_GET_CH_INFO                                          ,ENABLED},
-	{ CMD_SET_USER_ACCESS                                 ,ENABLED},
-	{ CMD_GET_USER_ACCESS                                 ,ENABLED},
-	{ CMD_SET_USER_NAME                                     ,ENABLED},
-	{ CMD_GET_USER_NAME                                     ,ENABLED},
-	{ CMD_SET_USER_PASSWORD                            ,ENABLED},
-	{ CMD_MASTER_WRITE_READ                             ,ENABLED},
-	{ CMD_SET_SYSTEM_INFO_PARAM                      ,ENABLED},
-	{ CMD_GET_SYSTEM_INFO_PARAM                      ,ENABLED},
-
-	/*------------------------ IPMI 2.0 specific Commands ------------------*/
-	{ CMD_ACTIVATE_PAYLOAD                               ,ENABLED},
-	{ CMD_DEACTIVATE_PAYLOAD                           ,ENABLED},
-	{ CMD_GET_PAYLD_ACT_STATUS                       ,ENABLED},
-	{ CMD_GET_PAYLD_INST_INFO                          ,ENABLED},
-	{ CMD_SET_USR_PAYLOAD_ACCESS                  ,ENABLED},
-	{ CMD_GET_USR_PAYLOAD_ACCESS                  ,ENABLED},
-	{ CMD_GET_CH_PAYLOAD_SUPPORT                  ,ENABLED},
-	{ CMD_GET_CH_PAYLOAD_VER                          ,ENABLED},
-	{ CMD_GET_CH_OEM_PAYLOAD_INFO                 ,ENABLED},
-	{ CMD_GET_CH_CIPHER_SUITES                        ,ENABLED},
-	{ CMD_SUS_RES_PAYLOAD_ENCRYPT                 ,ENABLED},
-	{ CMD_SET_CH_SECURITY_KEYS                       ,ENABLED},
-	{ CMD_GET_SYS_IFC_CAPS                              ,ENABLED},
-	{0                                                                   ,0            },
-	
-};
-
-const NetFnCmds_T g_Chassis [] =
-{
-	/*--------------------- Chassis Commands ---------------------------------*/
-	{ CMD_GET_CHASSIS_CAPABILITIES                          ,ENABLED},
-	{ CMD_GET_CHASSIS_STATUS                                   ,ENABLED},
-	{ CMD_CHASSIS_CONTROL                                        ,ENABLED},
-	{ CMD_CHASSIS_RESET                                             ,DISABLED},
-	{ CMD_CHASSIS_IDENTIFY                                        ,ENABLED},
-	{ CMD_SET_CHASSIS_CAPABILITIES                          ,ENABLED},
-	{ CMD_SET_POWER_RESTORE_POLICY                        ,ENABLED},
-	{ CMD_GET_SYSTEM_RESTART_CAUSE                        ,ENABLED},
-	{ CMD_SET_SYSTEM_BOOT_OPTIONS                          ,ENABLED},
-	{ CMD_GET_SYSTEM_BOOT_OPTIONS                          ,ENABLED},
-	{ CMD_GET_POH_COUNTER                                         ,ENABLED},
-	{ CMD_SET_FP_BTN_ENABLES                                     ,ENABLED},
-	{ CMD_SET_POWER_CYCLE_INTERVAL                         ,ENABLED},
-	{0,                                                                            0             }
-
-};
-
-const NetFnCmds_T g_Bridge [] = 
-{
-	/*----------------------- Bridge Management Commands --------------------------------*/
-	{ CMD_GET_BRIDGE_STATE                                        ,ENABLED},
-	{ CMD_SET_BRIDGE_STATE                                        ,ENABLED},
-	{ CMD_GET_ICMB_ADDR                                            ,ENABLED},
-	{ CMD_SET_ICMB_ADDR                                            ,ENABLED},
-	{ CMD_SET_BRIDGE_PROXY_ADDR                             ,ENABLED},
-	{ CMD_GET_BRIDGE_STATISTICS                               ,ENABLED},
-	{ CMD_GET_ICMB_CAPABILITIES                                ,ENABLED},
-	{ CMD_CLEAR_BRIDGE_STATISTICS                           ,ENABLED},
-	{ CMD_GET_BRIDGE_PROXY_ADDR                             ,ENABLED},
-	{ CMD_GET_ICMB_CONNECTOR_INFO                          ,ENABLED},
-	{ CMD_GET_ICMB_CONNECTION_ID                            ,DISABLED},
-	{ CMD_SEND_ICMB_CONNECTION_ID                          ,DISABLED},
-
-	/*---------------------- Bridge Discovery Commands -----------------------------------*/
-	{ CMD_PREPARE_FOR_DISCOVERY                              ,ENABLED},
-	{ CMD_GET_ADDRESSES                                            ,ENABLED},
-	{ CMD_SET_DISCOVERED                                           ,ENABLED},
-	{ CMD_GET_CHASSIS_DEVICE_ID                               ,ENABLED},
-	{ CMD_SET_CHASSIS_DEVICE_ID                               ,ENABLED},
-	
-	/*----------------------- Bridging Commands ------------------------------------------*/
-	{ CMD_BRIDGE_REQUEST                                           ,ENABLED},
-	{ CMD_BRIDGE_MESSAGE                                          ,ENABLED},
-	
-	/*---------------------- Bridge Event Commands ---------------------------------------*/
-	{ CMD_GET_EVENT_COUNT                                        ,ENABLED},
-	{ CMD_SET_EVENT_DESTINATION                              ,ENABLED},
-	{ CMD_SET_EVENT_RECEPTION_STATE                      ,ENABLED},
-	{ CMD_SEND_ICMB_EVENT_MESSAGE                        ,ENABLED},
-	{ CMD_GET_EVENT_DESTINATION                             ,ENABLED},
-	{ CMD_GET_EVENT_RECEPTION_STATE                      ,ENABLED},
-	{ 0                                                                           ,0           }
-
-};
-
-const NetFnCmds_T g_Sensor [] = 
-{
-
-	{ CMD_SET_EVENT_RECEIVER                                   ,ENABLED},
-	{ CMD_GET_EVENT_RECEIVER                                   ,ENABLED},
-	{ CMD_PLATFORM_EVENT                                          ,ENABLED},
-
-	{ CMD_GET_PEF_CAPABILITIES                                 ,ENABLED},
-	{ CMD_ARM_PEF_POSTPONE_TIMER                           ,ENABLED},
-	{ CMD_SET_PEF_CONFIG_PARAMS                             ,ENABLED},
-	{ CMD_GET_PEF_CONFIG_PARAMS                             ,ENABLED},
-	{ CMD_SET_LAST_PROCESSED_EVENT_ID                  ,ENABLED},
-	{ CMD_GET_LAST_PROCESSED_EVENT_ID                  ,ENABLED},
-	{ CMD_ALERT_IMMEDIATE                                         ,ENABLED},
-	{ CMD_PET_ACKNOWLEDGE                                      ,ENABLED},
-
-
-	{ CMD_GET_DEV_SDR_INFO                                     ,ENABLED},
-	{ CMD_GET_DEV_SDR                                              ,ENABLED},
-	{ CMD_RESERVE_DEV_SDR_REPOSITORY                  ,ENABLED},
-	{ CMD_GET_SENSOR_READING_FACTORS                 ,ENABLED},
-	{ CMD_SET_SENSOR_HYSTERISIS                             ,ENABLED},
-	{ CMD_GET_SENSOR_HYSTERISIS                             ,ENABLED},
-	{ CMD_SET_SENSOR_THRESHOLDS                           ,ENABLED},
-	{ CMD_GET_SENSOR_THRESHOLDS                           ,ENABLED},
-	{ CMD_SET_SENSOR_EVENT_ENABLE                         ,ENABLED},
-	{ CMD_GET_SENSOR_EVENT_ENABLE                         ,ENABLED},
-	{ CMD_REARM_SENSOR_EVENTS                               ,ENABLED},
-	{ CMD_GET_SENSOR_EVENT_STATUS                        ,ENABLED},
-	{ CMD_GET_SENSOR_READING                                 ,ENABLED},
-	{ CMD_SET_SENSOR_TYPE                                        ,ENABLED},
-	{ CMD_GET_SENSOR_TYPE                                        ,ENABLED},
-	{ CMD_SET_SENSOR_READING                                  ,ENABLED},
-	{0,                                                                           0             }
-};
-
-const NetFnCmds_T g_Storage [] = 
-{
-	/*--------------------- FRU Device Commands ---------------------------------*/
-	{ CMD_FRU_INVENTORY_AREA_INFO                           ,ENABLED},
-	{ CMD_READ_FRU_DATA                                            ,ENABLED},
-	{ CMD_WRITE_FRU_DATA                                           ,ENABLED},
-
-	/*--------------------- SDR Device Commands ---------------------------------*/
-	{ CMD_GET_SDR_REPOSITORY_INFO                           ,ENABLED},
-	{ CMD_GET_SDR_REPOSITORY_ALLOCATION_INFO       ,ENABLED},
-	{ CMD_RESERVE_SDR_REPOSITORY                             ,ENABLED},
-	{ CMD_GET_SDR                                                         ,ENABLED},
-	{ CMD_ADD_SDR                                                        ,ENABLED},
-	{ CMD_PARTIAL_ADD_SDR                                          ,ENABLED},
-	{ CMD_DELETE_SDR                                                    ,DISABLED},
-	{ CMD_CLEAR_SDR_REPOSITORY                                 ,ENABLED},
-	{ CMD_GET_SDR_REPOSITORY_TIME                            ,ENABLED},
-	{ CMD_SET_SDR_REPOSITORY_TIME                            ,DISABLED},
-	{ CMD_ENTER_SDR_REPOSITORY_UPDATE_MODE         ,DISABLED},
-	{ CMD_EXIT_SDR_REPOSITORY_UPDATE_MODE            ,DISABLED},
-	{ CMD_RUN_INITIALIZATION_AGENT                            ,ENABLED},
-
-	/*--------------------- SEL Device Commands ----------------------------------*/
-	{ CMD_GET_SEL_INFO                                                  ,ENABLED},
-	{ CMD_GET_SEL_ALLOCATION_INFO                              ,ENABLED},
-	{ CMD_RESERVE_SEL                                                    ,ENABLED},
-	{ CMD_GET_SEL_ENTRY                                                 ,ENABLED},
-	{ CMD_ADD_SEL_ENTRY                                                ,ENABLED},
-	{ CMD_PARTIAL_ADD_SEL_ENTRY                                  ,ENABLED},
-	{ CMD_DELETE_SEL_ENTRY                                            ,ENABLED},
-	{ CMD_CLEAR_SEL                                                        ,ENABLED},
-	{ CMD_GET_SEL_TIME                                                   ,ENABLED},
-	{ CMD_SET_SEL_TIME                                                   ,ENABLED},
-	{ CMD_GET_AUXILIARY_LOG_STATUS                            ,DISABLED},
-	{ CMD_SET_AUXILIARY_LOG_STATUS                            ,DISABLED},
-	{ CMD_GET_SEL_TIME_UTC_OFFSET                              ,ENABLED},
-	{ CMD_SET_SEL_TIME_UTC_OFFSET                              ,ENABLED},
-	{ 0,                                                                             0             }
-
-};
-
-const NetFnCmds_T g_Transport [] = 
-{
-	/*------------------------- IPM Device Commands --------------------------------------*/
-	{ CMD_SET_LAN_CONFIGURATION_PARAMETERS          ,ENABLED},
-	{ CMD_GET_LAN_CONFIGURATION_PARAMETERS          ,ENABLED},
-	{ CMD_SUSPEND_BMC_ARPS                                       ,ENABLED},
-	{ CMD_GET_IP_UDP_RMCP_STATISTICS                       ,DISABLED},
-
-	/*--------------------- Serial/Modem Device Commands ---------------------------------*/
-	{ CMD_SET_SERIAL_MODEM_CONFIG                           ,ENABLED},
-	{ CMD_GET_SERIAL_MODEM_CONFIG                           ,ENABLED},
-	{ CMD_SET_SERIAL_MODEM_MUX                                ,ENABLED},
-	{ CMD_SERIAL_MODEM_CONNECTION_ACTIVITY          ,DISABLED},
-	{ CMD_CALLBACK                                                       ,ENABLED},
-	{ CMD_SET_USER_CALLBACK_OPTION                         ,ENABLED},
-	{ CMD_GET_USER_CALLBACK_OPTION                         ,ENABLED},
-	{ CMD_GET_TAP_RES_CODES                                      ,ENABLED},
-
-	/*------------------------- Serial Over LAN Commands ---------------------------------*/
-	{ CMD_GET_SOL_CONFIGURATION                              ,ENABLED},
-	{ CMD_SET_SOL_CONFIGURATION                              ,ENABLED},
-	{ 0                                                                            ,0            }
-};
-
-//const NetFnCmds_T g_AMI [] = 
-//{
-//	/* ---------------YAFU Commands -----------------------------*/
-//	{ CMD_AMI_YAFU_SWITCH_FLASH_DEVICE			    ,ENABLED},
-//	{ CMD_AMI_YAFU_RESTORE_FLASH_DEVICE			    ,ENABLED},
-//	{ CMD_AMI_YAFU_GET_FLASH_INFO                           ,ENABLED},
-//	{ CMD_AMI_YAFU_GET_FIRMWARE_INFO                    ,ENABLED},
-//	{ CMD_AMI_YAFU_GET_FMH_INFO                              ,ENABLED},
-//	{ CMD_AMI_YAFU_GET_STATUS                                 ,ENABLED},
-//	{ CMD_AMI_YAFU_ACTIVATE_FLASH                          ,ENABLED},
-//	{ CMD_AMI_YAFU_ALLOCATE_MEMORY                       ,ENABLED},
-//	{ CMD_AMI_YAFU_FREE_MEMORY                               ,ENABLED},
-//	{ CMD_AMI_YAFU_READ_FLASH                                 ,ENABLED},
-//	{ CMD_AMI_YAFU_WRITE_FLASH                                ,ENABLED},
-//	{ CMD_AMI_YAFU_ERASE_FLASH                                ,ENABLED},
-//	{ CMD_AMI_YAFU_PROTECT_FLASH                            ,ENABLED},
-//	{ CMD_AMI_YAFU_ERASE_COPY_FLASH                      ,ENABLED},
-//	{ CMD_AMI_YAFU_VERIFY_FLASH                               ,ENABLED},
-//	{ CMD_AMI_YAFU_READ_MEMORY                              ,ENABLED},
-//	{ CMD_AMI_YAFU_WRITE_MEMORY                             ,ENABLED},
-//	{ CMD_AMI_YAFU_COPY_MEMORY                              ,ENABLED},
-//	{ CMD_AMI_YAFU_COMPARE_MEMORY                        ,ENABLED},
-//	{ CMD_AMI_YAFU_CLEAR_MEMORY                            ,ENABLED},
-//	{ CMD_AMI_YAFU_GET_BOOT_CONFIG                       ,ENABLED},
-//	{ CMD_AMI_YAFU_SET_BOOT_CONFIG                       ,ENABLED},
-//	{ CMD_AMI_YAFU_GET_BOOT_VARS                          ,ENABLED},
-//	{ CMD_AMI_YAFU_DEACTIVATE_FLASH_MODE            ,ENABLED},
-//	{ CMD_AMI_YAFU_RESET_DEVICE                             ,ENABLED},
-//	{ CMD_AMI_YAFU_GET_ECF_STATUS                         ,ENABLED},
-//	{ CMD_AMI_YAFU_GET_VERIFY_STATUS                    ,ENABLED},
-//	{ CMD_AMI_YAFU_DUAL_IMAGE_SUP                        ,ENABLED},
-//	{ CMD_AMI_GET_CHANNEL_NUM                               ,ENABLED},
-//	{ CMD_AMI_GET_ETH_INDEX                                    ,ENABLED},
-//	{ CMD_AMI_YAFU_FIRMWARE_SELECT_FLASH            ,ENABLED},
-//	{ CMD_AMI_YAFU_SIGNIMAGEKEY_REPLACE              ,ENABLED},
-
-//	/*-------------------- AMI Smtp Commands -----------------------*/
-//	{ CMD_SET_SMTP_CONFIG_PARAMS                         ,ENABLED},
-//	{ CMD_GET_SMTP_CONFIG_PARAMS                         ,ENABLED},
-//	{ CMD_AMI_GET_EMAIL_USER                                  ,ENABLED},
-//	{ CMD_AMI_SET_EMAIL_USER                                  ,ENABLED},
-//	{ CMD_AMI_GET_EMAILFORMAT_USER                      ,ENABLED},
-//	{ CMD_AMI_SET_EMAILFORMAT_USER                      ,ENABLED},
-//	{ CMD_AMI_RESET_PASS                                         ,ENABLED},
-//	{ CMD_AMI_RESTORE_DEF                                       ,ENABLED},
-//	{ CMD_AMI_GET_LOG_CONF                                     ,ENABLED},
-//	{ CMD_AMI_SET_LOG_CONF                                     ,ENABLED},
-
-//	/*-------------------- AMI Get Bios Code Commands -----------------------------------------*/
-//	{ CMD_AMI_GET_BIOS_CODE                                   ,ENABLED},
-
-//	/*-------------------- AMI SERVICE Commands -----------------------------------------*/
-//	{ CMD_AMI_GET_SERVICE_CONF                              ,ENABLED},
-//	{ CMD_AMI_SET_SERVICE_CONF                              ,ENABLED},
-//	{ CMD_AMI_LINK_DOWN_RESILENT                           ,ENABLED},
-
-//	/*-------------------- AMI DNS Commands -----------------------------------------*/
-//	{ CMD_AMI_GET_DNS_CONF                                     ,ENABLED},
-//	{ CMD_AMI_SET_DNS_CONF                                     ,ENABLED},
-
-//	/*-------------------- AMI Iface State Commands -----------------------------------------*/
-//	{ CMD_AMI_GET_IFACE_STATE                                 ,ENABLED},
-//	{ CMD_AMI_SET_IFACE_STATE                                 ,ENABLED},
-
-//	{ CMD_AMI_SET_FIREWALL                                      ,ENABLED},
-//	{ CMD_AMI_GET_FIREWALL                                      ,ENABLED},
-//	{ CMD_AMI_GET_FRU_DETAILS                                 ,ENABLED},
-//	{ CMD_AMI_GET_ROOT_USER_ACCESS                     ,ENABLED},
-//	{ CMD_AMI_SET_ROOT_PASSWORD                          ,ENABLED},
-//	{ CMD_AMI_GET_USER_SHELLTYPE                           ,DISABLED},
-//	{ CMD_AMI_SET_USER_SHELLTYPE                           ,DISABLED},
-//	{ CMD_AMI_SET_EXTENDED_PRIV                           ,ENABLED},
-//	{ CMD_AMI_GET_EXTENDED_PRIV                           ,ENABLED},
-//	{ CMD_AMI_SET_TIMEZONE                                   ,ENABLED},
-//	{ CMD_AMI_GET_TIMEZONE                                   ,ENABLED},
-//	{ CMD_AMI_GET_NTP_CFG                                 ,ENABLED},
-//	{ CMD_AMI_SET_NTP_CFG                                 ,ENABLED},
-//	{ CMD_AMI_SET_TRIGGER_EVT                                ,ENABLED},
-//	{ CMD_AMI_GET_TRIGGER_EVT                                ,ENABLED},
-//	{ CMD_AMI_GET_SOL_CONFIG_PARAMS                          ,ENABLED},
-//	{ CMD_AMI_SET_LOGIN_AUDIT_CFG,      ENABLED }, 
-//	{ CMD_AMI_GET_LOGIN_AUDIT_CFG,      ENABLED },
-//	{ CMD_AMI_GET_IPV6_ADDRESS,         ENABLED },
-//	{ CMD_AMI_SET_SNMP_CONF, ENABLED },
-//	{ CMD_AMI_GET_SNMP_CONF, ENABLED },
-//	{ CMD_AMI_SET_PAM_ORDER,            ENABLED },
-//	{ CMD_AMI_GET_PAM_ORDER,            ENABLED },
-//	{ CMD_AMI_GET_CHANNEL_TYPE,         ENABLED }, 
-
-//	/*------------------------------ AMI SEL Commands ------------------------------*/
-//	{ CMD_AMI_GET_SEL_POLICY,           ENABLED },
-//	{ CMD_AMI_SET_SEL_POLICY,           ENABLED },
-//	{ CMD_AMI_SET_PRESERVE_CONF,        ENABLED }, 
-//	{ CMD_AMI_GET_PRESERVE_CONF,        ENABLED }, 
-//	{ CMD_AMI_GET_SEL_ENTIRES,          ENABLED },
-//	{ CMD_AMI_GET_SENSOR_INFO,          ENABLED },
-//	{ CMD_AMI_SET_ALL_PRESERVE_CONF,    ENABLED },
-//	{ CMD_AMI_GET_ALL_PRESERVE_CONF,    ENABLED },
-
-//	/*------------------------------- TFTP Firmware Update -------------------------*/
-//	{ CMD_AMI_START_TFTP_FW_UPDATE,     ENABLED },
-//	{ CMD_AMI_GET_TFTP_FW_PROGRESS_STATUS, ENABLED },
-//	{ CMD_AMI_SET_FW_CONFIGURATION,     ENABLED },
-//	{ CMD_AMI_GET_FW_CONFIGURATION,     ENABLED },
-//	{ CMD_AMI_SET_FW_PROTOCOL,          ENABLED },
-//	{ CMD_AMI_GET_FW_PROTOCOL,          ENABLED },
-//	{ CMD_AMI_GET_IPMI_SESSION_TIMEOUT,  ENABLED},
-//	
-//	/*------------------------------- UDS Channel Info Command ---------------------*/
-//	{ CMD_AMI_GET_UDS_CHANNEL_INFO,     ENABLED },
-//	{ CMD_AMI_GET_UDS_SESSION_INFO,     ENABLED },
-//	
-//	/*-------------------------------AMI Dual Image Support Command-----------------*/
-//	{ CMD_AMI_DUAL_IMG_SUPPORT,            ENABLED },
-
-//	/*---------- Password Encryption Key--------- */
-//	{ CMD_AMI_SET_PWD_ENCRYPTION_KEY,     ENABLED },
-
-//	/*-------------------------------U-Boot Memory Test-----------------------------*/
-//	{ CMD_AMI_SET_UBOOT_MEMTEST,            ENABLED},
-//	{ CMD_AMI_GET_UBOOT_MEMTEST_STATUS,     ENABLED},
-
-//	/*-------------------- AMI Remote Images serviceCommands ----------------------------*/
-//	{ CMD_AMI_GET_RIS_CONF                              ,ENABLED},
-//	{ CMD_AMI_SET_RIS_CONF                              ,ENABLED},
-//	{ CMD_AMI_RIS_START_STOP                              ,ENABLED},
-//	/*---------------------AMI Control Debug Messages Commands-----------------------*/
-//	{ CMD_AMI_CTL_DBG_MSG,                   ENABLED },
-//	{ CMD_AMI_GET_DBG_MSG_STATUS,            ENABLED },
-//	{ CMD_AMI_VIRTUAL_DEVICE_SET_STATUS,	ENABLED },
-//	{ CMD_AMI_VIRTUAL_DEVICE_GET_STATUS,	ENABLED },
-//	
-//	{ CMD_AMI_GET_LICENSE_VALIDITY,                                     ENABLED},
-//	{ CMD_AMI_ADD_LICENSE_KEY,                                          ENABLED},
-//	{0                                                                           ,0            }
-//};
-
-//const NetFnCmds_T g_opma1 [] = 
-//{
-//	{  CMD_OPMA_SET_SENSOR_RD_OFFSET                  ,ENABLED},
-//	{  CMD_OPMA_GET_SENSOR_RD_OFFSET                  ,ENABLED},
-//	{  0                                                                         ,0             }
-
-//};
-
-//const NetFnCmds_T g_opma2 [] =
-//{
-//	{  CMD_OPMA_SET_SYS_TYPE_ID                             ,ENABLED},
-//	{  CMD_OPMA_GET_SYS_TYPE_ID                             ,ENABLED},
-//	{  CMD_OPMA_GET_MCARD_CAP                              ,ENABLED},
-//	{  CMD_OPMA_CLR_CMOS                                        ,ENABLED},
-//	{  CMD_OPMA_SET_LOCAL_LOCKOUT                        ,ENABLED},
-//	{  CMD_OPMA_GET_LOCAL_LOCKOUT                        ,ENABLED},
-//	{  CMD_OPMA_GET_SUPPORTED_HOST_IDS               ,ENABLED},
-//	{  0                                                                          ,0             }
-//};
-
-//const NetFnCmds_T g_apml [] = 
-//{
-//	{CMD_APML_GET_INTERFACE_VERSION                     ,ENABLED },
-//	{CMD_APML_READ_RMI_REG                                     ,ENABLED},
-//	{CMD_APML_WRITE_RMI_REG                                   ,ENABLED},
-//	{CMD_APML_READ_CPUID                                        ,ENABLED},
-//	{CMD_APML_READ_HTC_REG                                    ,ENABLED},
-//	{CMD_APML_WRITE_HTC_REG                                   ,ENABLED},
-//	{CMD_APML_READ_PSTATE                                       ,ENABLED},
-//	{CMD_APML_READ_MAX_PSTATE                               ,ENABLED},
-//	{CMD_APML_READ_PSTATE_LIMIT                             ,ENABLED},
-//	{CMD_APML_WRITE_PSTATE_LIMIT                            ,ENABLED},
-//	{CMD_APML_READ_MCR                                            ,ENABLED},
-//	{CMD_APML_WRITE_MCR                                          ,ENABLED},
-//	{CMD_APML_READ_TSI_REG                                     ,ENABLED},
-//	{CMD_APML_WRITE_TSI_REG                                    ,ENABLED},
-//	{CMD_APML_READ_TDP_LIMIT_REG                               ,ENABLED}, 
-//	{CMD_APML_WRITE_TDP_LIMIT_REG                              ,ENABLED},
-//	{CMD_APML_READ_PROCESSOR_POWER_REG                         ,ENABLED},
-//	{CMD_APML_READ_POWER_AVERAGING_REG                         ,ENABLED},
-//	{CMD_APML_READ_DRAM_THROTTLE_REG                           ,ENABLED},
-//	{CMD_APML_WRITE_DRAM_THROTTLE_REG                          ,ENABLED},
-//	{0                                                                            ,0           }
-
-//};
-
-//const NetFnCmds_T g_dcmi [] = 
-//{
-//	/* DCMI Commands */
-//	{ CMD_GET_DCMI_CAPABILITY_INFO                          ,ENABLED},
-//	{ CMD_GET_POWER_READING                                     ,ENABLED},
-//	{ CMD_GET_POWER_LIMIT                                           ,ENABLED},
-//	{ CMD_SET_POWER_LIMIT                                           ,ENABLED},
-//	{ CMD_ACTIVATE_POWER_LIMIT                                  ,ENABLED},
-//	{ CMD_GET_ASSET_TAG                                              ,ENABLED},
-//	{ CMD_GET_DCMI_SENSOR_INFO                                 ,ENABLED},
-//	{ CMD_SET_ASSET_TAG                                              ,ENABLED},
-//	{ CMD_GET_MANAGEMENT_CONTROLLER_ID_STRING   ,ENABLED},
-//	{ CMD_SET_MANAGEMENT_CONTROLLER_ID_STRING   ,ENABLED},
-//	{CMD_SET_THERMAL_LIMIT                                        ,ENABLED},
-//	{CMD_GET_THERMAL_LIMIT                                        ,ENABLED},
-//	{CMD_GET_TEMPERATURE_READING                           ,ENABLED},
-//	{CMD_SET_DCMI_CONF_PARAMS                                ,ENABLED},
-//	{CMD_GET_DCMI_CONF_PARAMS                                ,ENABLED},
-//	{ 0                                                                             ,0          }
-
-//};
-
-//const NetFnCmds_T g_hpm [] = 
-//{
-//	//PICMG
-//	{CMD_GET_PICMG_PROPERTIES                       ,ENABLED},
-//	{CMD_GET_ADDR_INFO                             	,ENABLED},
-//	{CMD_GET_DEV_LOCATOR_REC_ID                 		,ENABLED},	
-//		
-//	//hpm
-//	{ CMD_GET_TARGET_UPLD_CAPABLITIES,              ENABLED},
-//	{ CMD_GET_COMPONENT_PROPERTIES,                 ENABLED},
-//	{ CMD_INITIATE_UPG_ACTION,                      ENABLED},
-//	{ CMD_QUERY_SELF_TEST_RESULTS,                  ENABLED},
-//	{ CMD_ABORT_FIRMWARE_UPGRADE,                   ENABLED},
-//	{ CMD_UPLOAD_FIRMWARE_BLOCK,                    ENABLED},
-//	{ CMD_FINISH_FIRMWARE_UPLOAD,                   ENABLED},
-//	{ CMD_GET_UPGRADE_STATUS,                       ENABLED},
-//	{ CMD_ACTIVATE_FIRMWARE,                        ENABLED},
-//	{ CMD_QUERY_ROLLBACK_STATUS,                    ENABLED},
-//	{ CMD_INITIATE_MANUAL_ROLLBACK,                 ENABLED},
-//	{ 0,                                            0      }
-
-//};
-
-//const NetFnCmds_T g_pnm [] =
-//{
-//	{CMD_PNM_OEM_GET_READING                                 ,ENABLED},
-//	{CMD_PNM_OEM_ME_POWER_STATE_CHANGE             ,ENABLED},
-//	{0                                                                             ,0           }
-
-//};
-
-//const NetFnCmds_T g_ssi [] =
-//{
-//	{ CMD_SSICB_GET_COMPUTE_BLADE_PROPERTIES,   ENABLED},
-//	{ CMD_SSICB_GET_ADDR_INFO,                  ENABLED},
-//	{ CMD_SSICB_PLATFORM_EVENT_MESSAGE,         ENABLED},
-//	{ CMD_SSICB_MODULE_BMI_CONTROL,             ENABLED},
-//	{ CMD_SSICB_MODULE_PAYLOAD_CONTROL,         ENABLED},
-//	{ CMD_SSICB_SET_SYSTEM_EVENT_LOG_POLICY,    ENABLED},
-//	{ CMD_SSICB_SET_MODULE_ACTIVATION_POLICY,   ENABLED},
-//	{ CMD_SSICB_GET_MODULE_ACTIVATION_POLICY,   ENABLED},
-//	{ CMD_SSICB_SET_MODULE_ACTIVATION,          ENABLED},
-//	{ CMD_SSICB_SET_POWER_LEVEL,                ENABLED},
-//	{ CMD_SSICB_GET_POWER_LEVEL,                ENABLED},
-//	{ CMD_SSICB_RENEGOTIATE_POWER,              ENABLED},
-//	{ CMD_SSICB_GET_SERVICE_INFO,               ENABLED},
-//	{ CMD_SSICB_GET_APPLET_PACKAGE_URI,         ENABLED},
-//	{ CMD_SSICB_GET_SERVICE_ENABLE_STATE,       ENABLED},
-//	{ CMD_SSICB_SET_SERVICE_ENABLE_STATE,       ENABLED},
-//	{ CMD_SSICB_SET_SERVICE_TICKET,             ENABLED},
-//	{ CMD_SSICB_STOP_SERVICE_SESSION,           ENABLED},
-//	{ 0,                                        0}
-//};
-
-const NetFnCmds_T g_oem[] =			//jimbo add
-{
-	{ CMD_EXAMPLE_0h   ,  ENABLED},
-    { CMD_EXAMPLE_1h   ,  ENABLED},
-    { CMD_EXAMPLE_1h   ,  ENABLED},
-    { CMD_EXAMPLE_2h   ,  ENABLED},
-    { CMD_EXAMPLE_3h   ,  ENABLED},
-    { CMD_EXAMPLE_4h   ,  ENABLED},
-    { CMD_EXAMPLE_5h   ,  ENABLED},
-    { CMD_EXAMPLE_6h   ,  ENABLED},
-    { CMD_EXAMPLE_7h   ,  ENABLED},
-    { CMD_EXAMPLE_8h   ,  ENABLED},
-    { CMD_EXAMPLE_9h   ,  ENABLED},
-    { CMD_EXAMPLE_ah   ,  ENABLED},
-    { CMD_EXAMPLE_bh   ,  ENABLED},
-    { CMD_EXAMPLE_ch   ,  ENABLED},
-    { CMD_EXAMPLE_dh   ,  ENABLED},
-    { CMD_EXAMPLE_eh   ,  ENABLED},
-    { CMD_EXAMPLE_fh   ,  ENABLED},
-    { CMD_EXAMPLE_10h   ,  ENABLED},
-    { CMD_EXAMPLE_11h   ,  ENABLED},
-    { CMD_EXAMPLE_12h   ,  ENABLED},
-    { CMD_EXAMPLE_13h   ,  ENABLED},
-    { CMD_EXAMPLE_14h   ,  ENABLED},
-    { CMD_EXAMPLE_15h   ,  ENABLED},
-    { CMD_EXAMPLE_16h   ,  ENABLED},
-    { CMD_EXAMPLE_17h   ,  ENABLED},
-    { CMD_EXAMPLE_18h   ,  ENABLED},
-    { CMD_EXAMPLE_19h   ,  ENABLED},
-    { CMD_EXAMPLE_1ah   ,  ENABLED},
-    { CMD_EXAMPLE_1bh   ,  ENABLED},
-    { CMD_EXAMPLE_1ch   ,  ENABLED},
-    { CMD_EXAMPLE_1dh   ,  ENABLED},
-    { CMD_EXAMPLE_1eh   ,  ENABLED},
-    { CMD_EXAMPLE_1fh   ,  ENABLED},
-    { CMD_EXAMPLE_20h   ,  ENABLED},
-    { CMD_EXAMPLE_21h   ,  ENABLED},
-    { CMD_EXAMPLE_22h   ,  ENABLED},
-    { CMD_EXAMPLE_23h   ,  ENABLED},
-    { CMD_EXAMPLE_24h   ,  ENABLED},
-    { CMD_EXAMPLE_25h   ,  ENABLED},
-    { CMD_EXAMPLE_26h   ,  ENABLED},
-    { CMD_EXAMPLE_27h   ,  ENABLED},
-    { CMD_EXAMPLE_28h   ,  ENABLED},
-    { CMD_EXAMPLE_29h   ,  ENABLED},
-    { CMD_EXAMPLE_2ah   ,  ENABLED},
-    { CMD_EXAMPLE_2bh   ,  ENABLED},
-    { CMD_EXAMPLE_2ch   ,  ENABLED},
-    { CMD_EXAMPLE_2dh   ,  ENABLED},
-    { CMD_EXAMPLE_2eh   ,  ENABLED},
-    { CMD_EXAMPLE_2fh   ,  ENABLED},
-    { CMD_EXAMPLE_30h   ,  ENABLED},
-    { CMD_EXAMPLE_31h   ,  ENABLED},
-    { CMD_EXAMPLE_32h   ,  ENABLED},
-    { CMD_EXAMPLE_33h   ,  ENABLED},
-    { CMD_EXAMPLE_34h   ,  ENABLED},
-    { CMD_EXAMPLE_35h   ,  ENABLED},
-    { CMD_EXAMPLE_36h   ,  ENABLED},
-    { CMD_EXAMPLE_37h   ,  ENABLED},
-    { CMD_EXAMPLE_38h   ,  ENABLED},
-    { CMD_EXAMPLE_39h   ,  ENABLED},
-    { CMD_EXAMPLE_3ah   ,  ENABLED},
-    { CMD_EXAMPLE_3bh   ,  ENABLED},
-    { CMD_EXAMPLE_3ch   ,  ENABLED},
-    { CMD_EXAMPLE_3dh   ,  ENABLED},
-    { CMD_EXAMPLE_3eh   ,  ENABLED},
-    { CMD_EXAMPLE_3fh   ,  ENABLED},
-    { CMD_EXAMPLE_40h   ,  ENABLED},
-    { CMD_EXAMPLE_41h   ,  ENABLED},
-    { CMD_EXAMPLE_42h   ,  ENABLED},
-    { CMD_EXAMPLE_43h   ,  ENABLED},
-    { CMD_EXAMPLE_44h   ,  ENABLED},
-    { CMD_EXAMPLE_45h   ,  ENABLED},
-    { CMD_EXAMPLE_46h   ,  ENABLED},
-    { CMD_EXAMPLE_47h   ,  ENABLED},
-    { CMD_EXAMPLE_48h   ,  ENABLED},
-    { CMD_EXAMPLE_49h   ,  ENABLED},
-    { CMD_EXAMPLE_4ah   ,  ENABLED},
-    { CMD_EXAMPLE_4bh   ,  ENABLED},
-    { CMD_EXAMPLE_4ch   ,  ENABLED},
-    { CMD_EXAMPLE_4dh   ,  ENABLED},
-    { CMD_EXAMPLE_4eh   ,  ENABLED},
-    { CMD_EXAMPLE_4fh   ,  ENABLED},
-    { CMD_EXAMPLE_50h   ,  ENABLED},
-    { CMD_EXAMPLE_51h   ,  ENABLED},
-    { CMD_EXAMPLE_52h   ,  ENABLED},
-    { CMD_EXAMPLE_53h   ,  ENABLED},
-    { CMD_EXAMPLE_54h   ,  ENABLED},
-    { CMD_EXAMPLE_55h   ,  ENABLED},
-    { CMD_EXAMPLE_56h   ,  ENABLED},
-    { CMD_EXAMPLE_57h   ,  ENABLED},
-    { CMD_EXAMPLE_58h   ,  ENABLED},
-    { CMD_EXAMPLE_59h   ,  ENABLED},
-    { CMD_EXAMPLE_5ah   ,  ENABLED},
-    { CMD_EXAMPLE_5bh   ,  ENABLED},
-    { CMD_EXAMPLE_5ch   ,  ENABLED},
-    { CMD_EXAMPLE_5dh   ,  ENABLED},
-    { CMD_EXAMPLE_5eh   ,  ENABLED},
-    { CMD_EXAMPLE_5fh   ,  ENABLED},
-    { CMD_EXAMPLE_60h   ,  ENABLED},
-    { CMD_EXAMPLE_61h   ,  ENABLED},
-    { CMD_EXAMPLE_62h   ,  ENABLED},
-    { CMD_EXAMPLE_63h   ,  ENABLED},
-    { CMD_EXAMPLE_64h   ,  ENABLED},
-    { CMD_EXAMPLE_65h   ,  ENABLED},
-    { CMD_EXAMPLE_66h   ,  ENABLED},
-    { CMD_EXAMPLE_67h   ,  ENABLED},
-    { CMD_EXAMPLE_68h   ,  ENABLED},
-    { CMD_EXAMPLE_69h   ,  ENABLED},
-    { CMD_EXAMPLE_6ah   ,  ENABLED},
-    { CMD_EXAMPLE_6bh   ,  ENABLED},
-    { CMD_EXAMPLE_6ch   ,  ENABLED},
-    { CMD_EXAMPLE_6dh   ,  ENABLED},
-    { CMD_EXAMPLE_6eh   ,  ENABLED},
-    { CMD_EXAMPLE_6fh   ,  ENABLED},
-    { CMD_EXAMPLE_70h   ,  ENABLED},
-    { CMD_EXAMPLE_71h   ,  ENABLED},
-    { CMD_EXAMPLE_72h   ,  ENABLED},
-    { CMD_EXAMPLE_73h   ,  ENABLED},
-    { CMD_EXAMPLE_74h   ,  ENABLED},
-    { CMD_EXAMPLE_75h   ,  ENABLED},
-    { CMD_EXAMPLE_76h   ,  ENABLED},
-    { CMD_EXAMPLE_77h   ,  ENABLED},
-    { CMD_EXAMPLE_78h   ,  ENABLED},
-    { CMD_EXAMPLE_79h   ,  ENABLED},
-    { CMD_EXAMPLE_7ah   ,  ENABLED},
-    { CMD_EXAMPLE_7bh   ,  ENABLED},
-    { CMD_EXAMPLE_7ch   ,  ENABLED},
-    { CMD_EXAMPLE_7dh   ,  ENABLED},
-    { CMD_EXAMPLE_7eh   ,  ENABLED},
-    { CMD_EXAMPLE_7fh   ,  ENABLED},
-/********* storlead oem command ***********/
-    { CMD_EXAMPLE_80h   ,  ENABLED},
-    { CMD_EXAMPLE_81h   ,  ENABLED},
-    { CMD_EXAMPLE_82h   ,  ENABLED},
-    { CMD_EXAMPLE_83h   ,  ENABLED},
-    { CMD_EXAMPLE_84h   ,  ENABLED},
-    { CMD_EXAMPLE_85h   ,  ENABLED},
-    { CMD_EXAMPLE_86h   ,  ENABLED},
-    { CMD_EXAMPLE_87h   ,  ENABLED},
-    { CMD_EXAMPLE_88h   ,  ENABLED},
-    { CMD_EXAMPLE_89h   ,  ENABLED},
-    { CMD_EXAMPLE_8ah   ,  ENABLED},
-    { CMD_EXAMPLE_8bh   ,  ENABLED},
-    { CMD_EXAMPLE_8ch   ,  ENABLED},
-    { CMD_EXAMPLE_8dh   ,  ENABLED},
-    { CMD_EXAMPLE_8eh   ,  ENABLED},
-    { CMD_EXAMPLE_8fh   ,  ENABLED},
-    { CMD_EXAMPLE_90h   ,  ENABLED},
-    { CMD_EXAMPLE_91h   ,  ENABLED},
-    { CMD_EXAMPLE_92h   ,  ENABLED},
-    { CMD_EXAMPLE_93h   ,  ENABLED},
-    { CMD_EXAMPLE_94h   ,  ENABLED},
-    { CMD_EXAMPLE_95h   ,  ENABLED},
-    { CMD_EXAMPLE_96h   ,  ENABLED},
-    { CMD_EXAMPLE_97h   ,  ENABLED},
-    { CMD_EXAMPLE_98h   ,  ENABLED},
-    { CMD_EXAMPLE_99h   ,  ENABLED},
-    { CMD_EXAMPLE_9ah   ,  ENABLED},
-    { CMD_EXAMPLE_9bh   ,  ENABLED},
-    { CMD_EXAMPLE_9ch   ,  ENABLED},
-    { CMD_EXAMPLE_9dh   ,  ENABLED},
-    { CMD_EXAMPLE_9eh   ,  ENABLED},
-    { CMD_EXAMPLE_9fh   ,  ENABLED},
-/************************************************************/
-    { CMD_EXAMPLE_a0h   ,  ENABLED},
-    { CMD_EXAMPLE_a1h   ,  ENABLED},
-    { CMD_EXAMPLE_a2h   ,  ENABLED},
-    { CMD_EXAMPLE_a3h   ,  ENABLED},
-    { CMD_EXAMPLE_a4h   ,  ENABLED},
-    { CMD_EXAMPLE_a5h   ,  ENABLED},
-    { CMD_EXAMPLE_a6h   ,  ENABLED},
-    { CMD_EXAMPLE_a7h   ,  ENABLED},
-    { CMD_EXAMPLE_a8h   ,  ENABLED},
-    { CMD_EXAMPLE_a9h   ,  ENABLED},
-    { CMD_EXAMPLE_aah   ,  ENABLED},
-    { CMD_EXAMPLE_abh   ,  ENABLED},
-    { CMD_EXAMPLE_ach   ,  ENABLED},
-    { CMD_EXAMPLE_adh   ,  ENABLED},
-    { CMD_EXAMPLE_aeh   ,  ENABLED},
-    { CMD_EXAMPLE_afh   ,  ENABLED},
-    { CMD_EXAMPLE_b0h   ,  ENABLED},
-    { CMD_EXAMPLE_b1h   ,  ENABLED},
-    { CMD_EXAMPLE_b2h   ,  ENABLED},
-    { CMD_EXAMPLE_b3h   ,  ENABLED},
-    { CMD_EXAMPLE_b4h   ,  ENABLED},
-    { CMD_EXAMPLE_b5h   ,  ENABLED},
-    { CMD_EXAMPLE_b6h   ,  ENABLED},
-    { CMD_EXAMPLE_b7h   ,  ENABLED},
-    { CMD_EXAMPLE_b8h   ,  ENABLED},
-    { CMD_EXAMPLE_b9h   ,  ENABLED},
-    { CMD_EXAMPLE_bah   ,  ENABLED},
-    { CMD_EXAMPLE_bbh   ,  ENABLED},
-    { CMD_EXAMPLE_bch   ,  ENABLED},
-    { CMD_EXAMPLE_bdh   ,  ENABLED},
-    { CMD_EXAMPLE_beh   ,  ENABLED},
-    { CMD_EXAMPLE_bfh   ,  ENABLED},
-    { CMD_EXAMPLE_c0h   ,  ENABLED},
-    { CMD_EXAMPLE_c1h   ,  ENABLED},
-    { CMD_EXAMPLE_c2h   ,  ENABLED},
-    { CMD_EXAMPLE_c3h   ,  ENABLED},
-    { CMD_EXAMPLE_c4h   ,  ENABLED},
-    { CMD_EXAMPLE_c5h   ,  ENABLED},
-    { CMD_EXAMPLE_c6h   ,  ENABLED},
-    { CMD_EXAMPLE_c7h   ,  ENABLED},
-    { CMD_EXAMPLE_c8h   ,  ENABLED},
-    { CMD_EXAMPLE_c9h   ,  ENABLED},
-    { CMD_EXAMPLE_cah   ,  ENABLED},
-    { CMD_EXAMPLE_cbh   ,  ENABLED},
-    { CMD_EXAMPLE_cch   ,  ENABLED},
-    { CMD_EXAMPLE_cdh   ,  ENABLED},
-    { CMD_EXAMPLE_ceh   ,  ENABLED},
-    { CMD_EXAMPLE_cfh   ,  ENABLED},
-    { CMD_EXAMPLE_d0h   ,  ENABLED},
-    { CMD_EXAMPLE_d1h   ,  ENABLED},
-    { CMD_EXAMPLE_d2h   ,  ENABLED},
-    { CMD_EXAMPLE_d3h   ,  ENABLED},
-    { CMD_EXAMPLE_d4h   ,  ENABLED},
-    { CMD_EXAMPLE_d5h   ,  ENABLED},
-    { CMD_EXAMPLE_d6h   ,  ENABLED},
-    { CMD_EXAMPLE_d7h   ,  ENABLED},
-    { CMD_EXAMPLE_d8h   ,  ENABLED},
-    { CMD_EXAMPLE_d9h   ,  ENABLED},
-    { CMD_EXAMPLE_dah   ,  ENABLED},
-    { CMD_EXAMPLE_dbh   ,  ENABLED},
-    { CMD_EXAMPLE_dch   ,  ENABLED},
-    { CMD_EXAMPLE_ddh   ,  ENABLED},
-    { CMD_EXAMPLE_deh   ,  ENABLED},
-    { CMD_EXAMPLE_dfh   ,  ENABLED},
-    { CMD_EXAMPLE_e0h   ,  ENABLED},
-    { CMD_EXAMPLE_e1h   ,  ENABLED},
-    { CMD_EXAMPLE_e2h   ,  ENABLED},
-    { CMD_EXAMPLE_e3h   ,  ENABLED},
-    { CMD_EXAMPLE_e4h   ,  ENABLED},
-    { CMD_EXAMPLE_e5h   ,  ENABLED},
-    { CMD_EXAMPLE_e6h   ,  ENABLED},
-    { CMD_EXAMPLE_e7h   ,  ENABLED},
-    { CMD_EXAMPLE_e8h   ,  ENABLED},
-    { CMD_EXAMPLE_e9h   ,  ENABLED},
-    { CMD_EXAMPLE_eah   ,  ENABLED},
-    { CMD_EXAMPLE_ebh   ,  ENABLED},
-    { CMD_EXAMPLE_ech   ,  ENABLED},
-    { CMD_EXAMPLE_edh   ,  ENABLED},
-    { CMD_EXAMPLE_eeh   ,  ENABLED},
-    { CMD_EXAMPLE_efh   ,  ENABLED},
-    { CMD_EXAMPLE_f0h   ,  ENABLED},
-    { CMD_EXAMPLE_f1h   ,  ENABLED},
-    { CMD_EXAMPLE_f2h   ,  ENABLED},
-    { CMD_EXAMPLE_f3h   ,  ENABLED},
-    { CMD_EXAMPLE_f4h   ,  ENABLED},
-    { CMD_EXAMPLE_f5h   ,  ENABLED},
-    { CMD_EXAMPLE_f6h   ,  ENABLED},
-    { CMD_EXAMPLE_f7h   ,  ENABLED},
-    { CMD_EXAMPLE_f8h   ,  ENABLED},
-    { CMD_EXAMPLE_f9h   ,  ENABLED},
-    { CMD_EXAMPLE_fah   ,  ENABLED},
-    { CMD_EXAMPLE_fbh   ,  ENABLED},
-    { CMD_EXAMPLE_fch   ,  ENABLED},
-    { CMD_EXAMPLE_fdh   ,  ENABLED},
-    { CMD_EXAMPLE_feh   ,  ENABLED},
-    { CMD_EXAMPLE_ffh   ,  ENABLED},
-	{0,											0}
-};
-
-const NetFnCmds_T g_Storlead [] = 
-{
-	/*------------------------- IPM Device Commands --------------------------------------*/
-	{ CMD_GET_SYS_INFO          ,ENABLED},
-	{ CMD_GET_SENSOR_INFO          ,ENABLED},
-	{ CMD_AUTHOR_VERIFY          ,ENABLED},
-	{ CMD_GET_SENSOR_HISTORY          ,ENABLED},	
-	{ CMD_GET_FAN_INFO          ,ENABLED},	
-	{ CMD_SET_FAN_INFO          ,ENABLED},	
-	{ CMD_GET_ALLBLADE_INFO          ,ENABLED},	
-	{ CMD_RESTORE_FACTORY_SET          ,ENABLED},	
-	{ CMD_GET_LAN_INFO          ,ENABLED},	
-	{ CMD_SET_LAN_INFO          ,ENABLED},	
-	{ CMD_GET_BLADE_INFO          ,ENABLED},	
-	{ CMD_GET_SENSOR_NAME          ,ENABLED},	
-	{0,				0		},
-};
-
-NETFNTable_T Netfntbl [] = 
-{
-	{ NETFN_APP,        GRPEXT_NA,      g_App       },
-	{ NETFN_CHASSIS,    GRPEXT_NA,      g_Chassis   },
-	{ NETFN_BRIDGE,     GRPEXT_NA,      g_Bridge    },
-	{ NETFN_SENSOR,     GRPEXT_NA,      g_Sensor    },
-	{ NETFN_STORAGE,    GRPEXT_NA,      g_Storage   },
-	{ NETFN_STORLEAD,    GRPEXT_NA,      g_Storlead   },
-	{ NETFN_TRANSPORT,  GRPEXT_NA,      g_Transport },
-//	{ NETFN_AMI,        GRPEXT_NA,      g_AMI       },
-//	{ NETFN_OPMA1,      GRPEXT_NA,      g_opma1     },
-//	{ NETFN_OPMA2,      GRPEXT_NA,      g_opma2     },
-//	{ NETFN_APML,       GRPEXT_NA,      g_apml      },
-//	{ NETFN_HPM,        GRPEXT_HPM,     g_hpm       },	//jimbo add picmg
-//	{ NETFN_DCMI,       GRPEXT_DCMI,    g_dcmi      },
-//	{ NETFN_PNM,        GRPEXT_NA,      g_pnm       },
-//	{ NETFN_SSI,        GRPEXT_SSI,     g_ssi       },
-	{ NETFN_OEM,        GRPEXT_NA,     	g_oem       },	//jimbo add
-//	{ NETFN_PICMG,      GRPEXT_PICMG,	g_picmg		}, //jimbo add
-};
-
-/*
-*@fn GetCommanEnabledStatus
-*@brief This function finds whether the command is enabled by the OEM
-*@param NetFunction - Pointer to the structure of NetFnCmds_T
-*@param Cmd - Command Number
-*@return Returns 0 on Enabled commands
-*            Returns -1 on non-Enabled commands
-*/
-int GetCommanEnabledStatus(NETFNTable_T *NetFuntbl,uint8_t Cmd)
-{
-	int i=0;
-
-	while(NetFuntbl->NetFunction[i].Status != 0)
-	{
-		if(NetFuntbl->NetFunction[i].CmdNum == Cmd)
-		{
-			if(NetFuntbl->NetFunction[i].Status == ENABLED)
-			{
-				return 0;
-			}
-			else
-			{
-				return -1;
-			}
-		}
-		i++;
-	}
-	return -1;
-}
-
-/*
-*@fn IsCommandEnabled
-*@brief This function gives the status of Command
-*@param NetFn         - Net Function 
-*@param GroupExtnCode - Group Extension Code
-*@param Cmd           - Command Number
-*@return Returns 0 if the command is Enabled
-*            Returns -1 if the command is Disabled
-*/
-int IsCommandEnabled(uint8_t NetFn,uint8_t* GroupExtnCode,uint8_t Cmd)
-{
-	int i=0;
-
-	while(i<(sizeof(Netfntbl)/sizeof(NETFNTable_T)))
-	{
-		if(NetFn == Netfntbl[i].NetFn)
-		{
-			if (Netfntbl[i].NetFn == NETFN_DCMI)
-			{
-				//printf("---> i=%d, NetFn = %#x\n", i, Netfntbl[i].NetFn);
-				   if(GroupExtnCode != NULL)
-					{
-					  if (Netfntbl[i].GroupExtCode == *GroupExtnCode)
-					   {
-						  //printf("---> i = %d, GroupExtnCode = %#x\n", i, *GroupExtnCode);
-						 break;
-						}
-					 }
-			}
-			else
-			{
-				//printf("---> netfn log\n");
-				break;
-			}
-		}
-		i++;
-	}
-
-	if(i != sizeof(Netfntbl)/sizeof(NETFNTable_T))
-	{
-		if(GetCommanEnabledStatus((NETFNTable_T*)&Netfntbl[i],Cmd) < 0)
-		{
-			printf("Warning: invalid command\n");
-			return -1;
-		}
-	}
-	else
-	{
-		printf("Warning: not find netfn\n");
-		return -1;
-	}
-
-	return 0;
-}
-
-

+ 0 - 57
app/bmc/msghndlr/cmdselect.h

@@ -1,57 +0,0 @@
-/*
-* Brief:	The header file of cmdselect.h.
-			Get cmd is enable or disable.
-* Author:	Jimbo_Zhang@outlook.com
-* Date:		2019-9-13, the Mid-autumn Festival;
-*/
-
-#ifndef __CMD_SELECT_H__
-#define __CMD_SELECT_H__
-
-#include <stdio.h>
-#include <stdint.h>
-
-#define NETFN_SSI       0x2c
-#define NETFN_DCMI      0x2c
-#define NETFN_HPM       0x2c
-
-#define NETFN_PNM       0x30
-#define NETFN_APML      0x36
-
-/*CMM Specific Netfn and GrpExt*/
-#define NETFN_CMM		0x38
-#define NETFN_OBSM		0x2C
-#define GRPEXT_OBSM		0x02
-
-#define GRPEXT_NA       0x00
-#define GRPEXT_HPM      0x00
-#define GRPEXT_SSI      0x02
-#define GRPEXT_DCMI     0xDC
-//#define GRPEXT_PICMG		0x00
-
-typedef struct
-{
-    uint8_t CmdNum;
-    uint8_t Status;
-}NetFnCmds_T;
-
-typedef struct
-{
-    uint8_t NetFn;
-    uint8_t GroupExtCode;
-    const NetFnCmds_T *NetFunction;
-}NETFNTable_T;
-
-/*
-*@fn IsCommandEnabled
-*@brief This function gives the status of Command
-*@param NetFn         - Net Function 
-*@param GroupExtnCode - Group Extension Code
-*@param Cmd           - Command Number
-*@return Returns 0 if the command is Enabled
-*            Returns -1 if the command is Disabled
-*/
-int IsCommandEnabled(uint8_t NetFn, uint8_t* GroupExtnCode,uint8_t Cmd);
-
-
-#endif

+ 5 - 1
app/bmc/readme.txt

@@ -20,4 +20,8 @@
 5. 	机箱内所有刀片的IPMB地址在dashboard.c里定义,在goahead.h里声明。
 5. 	机箱内所有刀片的IPMB地址在dashboard.c里定义,在goahead.h里声明。
 	机箱内所有刀片的IPMB地址在main.c里定义,在main.h里声明。
 	机箱内所有刀片的IPMB地址在main.c里定义,在main.h里声明。
 
 
-6. 机箱管理使能改由前端网页控制,默认是打开的。网页在下发获取机箱信息的时候多下发一个参数,机箱管理是否使能。
+6. 机箱管理使能改由前端网页控制,默认是打开的。网页在下发获取机箱信息的时候多下发一个参数,机箱管理是否使能。
+
+7. GD32F450内部flash:
+		Sector 6 放License											0x08060000~0x0807ffff 128KB
+		Sector 7 放配置信息,IpmiConfig + user info + FRU + SDR 		0x08080000~0x0809ffff 128KB

+ 1 - 1
app/bmc/sensor_sdr.c

@@ -611,7 +611,7 @@ const FullSensorRec_T full_sdr_tbl[] = {
 		*/
 		*/
 		((0x0>>2)&0xC0)+(0x0&0x3F),	//B,Accuracy
 		((0x0>>2)&0xC0)+(0x0&0x3F),	//B,Accuracy
 		((0x0>>2)&0xF0)+(0x0&0x0C)+0x0,	//Accuracy,Accuracy exponent
 		((0x0>>2)&0xF0)+(0x0&0x0C)+0x0,	//Accuracy,Accuracy exponent
-		(0xfc<<4)+(0x0&0x0F),		//R exponent,B exponent 	=== !!!!!!!! ===
+		(0xc<<4)+(0x0&0x0F),		//R exponent,B exponent 	=== !!!!!!!! ===
 		0x0,	//Analog Characteristics Flags
 		0x0,	//Analog Characteristics Flags
 		0x7f,	//Nominal Reading
 		0x7f,	//Nominal Reading
 		0xff,	//Normal Maximum
 		0xff,	//Normal Maximum

+ 9 - 16
app/bmc/uds/UDSIfc.c

@@ -38,29 +38,15 @@
 #include "main.h"
 #include "main.h"
 
 
 /*Function Prototypes*/
 /*Function Prototypes*/
-//void CloseUDSSocket(int Socket );
 static int ProcessUDSReq(MsgPkt_T *pReq );
 static int ProcessUDSReq(MsgPkt_T *pReq );
 int InitUnixDomainSocket(void);
 int InitUnixDomainSocket(void);
 void *RecvUDSPkt(void *pArg);
 void *RecvUDSPkt(void *pArg);
-//int AddUDSSocket (int Socket,uint8_t IsLoopBackSocket, uint8_t IsFixedSocket );
-//int RemoveUDSSocket (int Socket );
 int ReadUDSData(MsgPkt_T *MsgPkt,int Socket );
 int ReadUDSData(MsgPkt_T *MsgPkt,int Socket );
 int SendUDSPkt (MsgPkt_T *pRes );
 int SendUDSPkt (MsgPkt_T *pRes );
-//int SetUDSFd(fd_set *newfd,int *maximum );
 int FillUDSResponsePacket(MsgPkt_T *pReq, MsgPkt_T *pRes,uint8_t UDSCompletionCode );
 int FillUDSResponsePacket(MsgPkt_T *pReq, MsgPkt_T *pRes,uint8_t UDSCompletionCode );
-//static int UpdateUDSTimeout (void);
-//static void*  UDSTimer (void *pArg);
-//int AddUDSInfo(MsgPkt_T *pUDSReq,MsgPkt_T *pUDSRes );
-//uint8_t RemoveUDSSession(SOCKET Socket );
-//int CheckReservedCmd(uint8_t Cmd);
 void *UDSIfcTask(void* pArg);
 void *UDSIfcTask(void* pArg);
 static void ProcessUDSBridgeMsg (  MsgPkt_T* pReq );
 static void ProcessUDSBridgeMsg (  MsgPkt_T* pReq );
 
 
-// static uint8_t ReservedCmd[]={
-//                       CMD_GET_DEV_ID,
-//                       CMD_GET_USER_NAME,
-//                       CMD_SET_USER_PASSWORD};
-
 int gUDSSocket;
 int gUDSSocket;
 int gFdUdsIfc, gFdUdsRes;
 int gFdUdsIfc, gFdUdsRes;
 
 
@@ -139,10 +125,10 @@ void *UDSIfcTask(void* pArg)
             continue;
             continue;
         }
         }
     
     
+        //printf("UDSIfc GetMsg!\n");
         switch(Req.Param)
         switch(Req.Param)
         {
         {
             case UDS_SMB_PARAM:
             case UDS_SMB_PARAM:
-//                printf("---> UDS get request Message\n");
                 ProcessUDSReq(&Req);
                 ProcessUDSReq(&Req);
                 break;
                 break;
             case BRIDGING_REQUEST:
             case BRIDGING_REQUEST:
@@ -225,7 +211,7 @@ void *RecvUDSPkt(void *pArg)
 
 
     while(TRUE)
     while(TRUE)
     {
     {
-        Timeout.tv_sec  =   SESSION_TIMEOUT; 
+        Timeout.tv_sec  =  365*24*60*60;//SESSION_TIMEOUT; 
         Timeout.tv_usec  =   0; 
         Timeout.tv_usec  =   0; 
 
 
         FD_ZERO(&fds);
         FD_ZERO(&fds);
@@ -240,11 +226,13 @@ void *RecvUDSPkt(void *pArg)
         RetVal = select (max, &fds, NULL, NULL, &Timeout);
         RetVal = select (max, &fds, NULL, NULL, &Timeout);
         if (UDS_FAILURE == RetVal)
         if (UDS_FAILURE == RetVal)
         {
         {
+            printf("UDS Recv failed!\n");
             continue;
             continue;
         }
         }
         if (UDS_SUCCESS == RetVal)
         if (UDS_SUCCESS == RetVal)
         {
         {
             /* Its due to timeout - continue */
             /* Its due to timeout - continue */
+            printf("UDS Recv timeout!\n");
             continue;
             continue;
         }
         }
         
         
@@ -372,6 +360,7 @@ static int ProcessUDSReq(MsgPkt_T *pReq )
     memset(&pRes,0,sizeof(MsgPkt_T));
     memset(&pRes,0,sizeof(MsgPkt_T));
     if (UDS_SUCCESS != GetMsg (gFdUdsRes, &pRes, (DEFAULT_TIMEOUT>2)?(DEFAULT_TIMEOUT-2):1))
     if (UDS_SUCCESS != GetMsg (gFdUdsRes, &pRes, (DEFAULT_TIMEOUT>2)?(DEFAULT_TIMEOUT-2):1))
     {
     {
+        printf("UDS GetMsg timeout!\n");
         return UDS_FAILURE;
         return UDS_FAILURE;
     }
     }
 
 
@@ -397,12 +386,16 @@ static int ProcessUDSReq(MsgPkt_T *pReq )
 **/
 **/
 int SendUDSPkt (MsgPkt_T *pRes)
 int SendUDSPkt (MsgPkt_T *pRes)
 {
 {
+    // struct timeval begin;
     // int i;
     // int i;
     // printf("---> server Send size: %d: ", pRes->Size);
     // printf("---> server Send size: %d: ", pRes->Size);
     // for(i=0;i<pRes->Size;i++)
     // for(i=0;i<pRes->Size;i++)
     //     printf("%#x ", pRes->Data[i]);
     //     printf("%#x ", pRes->Data[i]);
     // printf("\n");
     // printf("\n");
+    //printf("Send UDS!\n");
     /* Send the UDS response packet */
     /* Send the UDS response packet */
+    // gettimeofday(&begin,NULL);
+    // printf("UDS send:%ld:%ld\n", begin.tv_sec, begin.tv_usec);
      if(UDS_FAILURE == send(pRes->Socket,pRes->Data,pRes->Size,MSG_NOSIGNAL))
      if(UDS_FAILURE == send(pRes->Socket,pRes->Data,pRes->Size,MSG_NOSIGNAL))
      {
      {
        if((EBADF == errno) || (EPIPE == errno))
        if((EBADF == errno) || (EPIPE == errno))

+ 2 - 1
app/common_include/com_BMCCfg.h

@@ -5,6 +5,7 @@
 #define 	MAX_FAN_NUMS 	10		//该系统最多支持10个风扇
 #define 	MAX_FAN_NUMS 	10		//该系统最多支持10个风扇
 #define 	BLADE_NUMBERS	10
 #define 	BLADE_NUMBERS	10
 #define SENSOR_NUMBERS				(15)
 #define SENSOR_NUMBERS				(15)
+#define  POH_MINS_PER_COUNT                        60
 //r1.4 	网页初步成型,ASSERT NULL的错误解掉了,清除了日志。
 //r1.4 	网页初步成型,ASSERT NULL的错误解掉了,清除了日志。
 #define FW_VERSION_MAJOR			(1)
 #define FW_VERSION_MAJOR			(1)
 #define FW_VERSION_MINOR			(4)
 #define FW_VERSION_MINOR			(4)
@@ -14,7 +15,7 @@ extern uint8_t ChassisSecondaryIPMBAddr[BLADE_NUMBERS];
 
 
 //模块识别相关配置
 //模块识别相关配置
 #define DEFAULT_IDENTIFY_TIMEOUT 	(15)	//15s
 #define DEFAULT_IDENTIFY_TIMEOUT 	(15)	//15s
-#define IDENTIFY_PORT				GPIOC
+#define IDENTIFY_PORT				GPIOD
 #define IDENTIFY_PIN				GPIO_PIN_12
 #define IDENTIFY_PIN				GPIO_PIN_12
 /*
 /*
 0x00 0000 ~ 0x7F FFFF 	7MB		BMC Firmware
 0x00 0000 ~ 0x7F FFFF 	7MB		BMC Firmware

+ 0 - 11
app/common_include/com_BmcType.h

@@ -260,21 +260,10 @@ typedef struct
 **/
 **/
 typedef struct
 typedef struct
 {
 {
-//    uint32_t  ID;
     uint8_t   UserId;
     uint8_t   UserId;
     uint8_t   UserName [MAX_USERNAME_LEN];
     uint8_t   UserName [MAX_USERNAME_LEN];
     uint8_t   UserPassword [MAX_PASSWORD_LEN];
     uint8_t   UserPassword [MAX_PASSWORD_LEN];
-//    uint8_t   MaxPasswordSize;                /**< Maximum password size                  */
-//  uint8_t   ChannelAccess;                /** reserve,Call back, Link Auth, Ipmi Msg, Priv[3:0]. **/
-//    uint8_t   UserShell;                      /**< user shell type                        */      
-//    uint8_t   UserEMailID [EMAIL_ADDR_SIZE];  /**< Email-ID registered for the user       */
-//    uint8_t   MaxSession;                     /**< max No of session allowed for User.    */
-//    uint8_t   CurrentSession;                 /**< No Current session for the User.       */
     uint8_t    UserStatus;                  /**< User Enabled/Disabled Status.          */
     uint8_t    UserStatus;                  /**< User Enabled/Disabled Status.          */
-//    uint32_t    FixedUser:1;                  /**< Is this user name fixed                */
-//    uint8_t  EmailFormat[EMAIL_FORMAT_SIZE]; /** Email Alert format                       */
-//    uint32_t  ExtendedPrivilege;                       /** User Enhanced Privilege Flags           */
-//    uint8_t   UserPasswdConfigured;           /*  Flag to allow default Empty Password  */
 }   UserInfo_T;
 }   UserInfo_T;
 
 
 
 

+ 0 - 7
app/common_include/com_IPMI_ChassisDevice.h

@@ -120,13 +120,6 @@ typedef struct
 
 
 }   ChassisIdentifyReq_T;
 }   ChassisIdentifyReq_T;
 
 
-/* ChassisIdentifyRes_T */
-typedef struct
-{
-    uint8_t   CompletionCode;
-    
-}   ChassisIdentifyRes_T;
-
 /* SetChassisCapabilitiesReq_T */
 /* SetChassisCapabilitiesReq_T */
 typedef struct
 typedef struct
 {
 {

+ 23 - 9
app/common_include/com_IPMI_SEL.h

@@ -43,15 +43,7 @@ typedef struct
 
 
 }   SELRecHdr_T;
 }   SELRecHdr_T;
 
 
-/**
- * @struct SELEventRecord_T
- * @brief SEL Event Record
-**/
-typedef struct
-{
-    /* SEL ENTRY RECORD HEADER */
-    SELRecHdr_T hdr;
-
+typedef struct {
     /* RECORD BODY BYTES */
     /* RECORD BODY BYTES */
     uint8_t   GenID [2];
     uint8_t   GenID [2];
     uint8_t   EvMRev;
     uint8_t   EvMRev;
@@ -61,9 +53,31 @@ typedef struct
     uint8_t   EvtData1;
     uint8_t   EvtData1;
     uint8_t   EvtData2;
     uint8_t   EvtData2;
     uint8_t   EvtData3;
     uint8_t   EvtData3;
+} EventRecord_T;
+
+typedef struct {
+    /* RECORD BODY BYTES */
+    uint8_t   ManufacturerID[3];
+    uint8_t   OEMDefined[6];
+} OemEventRecord_T;
+
+/**
+ * @struct SELEventRecord_T
+ * @brief SEL Event Record
+**/
+typedef struct
+{
+    /* SEL ENTRY RECORD HEADER */
+    SELRecHdr_T hdr;
+
+    union {
+        EventRecord_T sysEventRecord;
+        OemEventRecord_T oemEventRecord;
+    } body;
 
 
 }   SELEventRecord_T;
 }   SELEventRecord_T;
 
 
+
 /**
 /**
  * @struct SELRec_T
  * @struct SELRec_T
  * @brief SEL Record
  * @brief SEL Record

+ 3 - 0
app/common_include/com_IPMI_Storlead.h

@@ -13,6 +13,9 @@
 #define CMD_SET_LAN_INFO		0xD
 #define CMD_SET_LAN_INFO		0xD
 #define CMD_GET_BLADE_INFO		0xE
 #define CMD_GET_BLADE_INFO		0xE
 #define CMD_GET_SENSOR_NAME		0xF
 #define CMD_GET_SENSOR_NAME		0xF
+#define CMD_GET_CURRUNTIME		0x10
+#define CMD_SAVE_CONFIG			0x11
+#define CMD_RESTORE_CONFIG		0x12
 
 
 
 
 #endif /* __COM_IPMI_STORLEAD_H__ */
 #endif /* __COM_IPMI_STORLEAD_H__ */

BIN
app/driver/InternalFlash/iflash.ko


+ 1 - 1
app/driver/driver.h

@@ -151,7 +151,7 @@ typedef struct {
 	uint8_t  sector;
 	uint8_t  sector;
 	uint32_t address;
 	uint32_t address;
 	uint32_t len;
 	uint32_t len;
-	uint8_t  data[256];
+	uint8_t  data[260];
 } iflash_t;
 } iflash_t;
 
 
 #endif /* __DRIVER_H__ */
 #endif /* __DRIVER_H__ */

+ 10 - 10
app/goahead-3.6.5/src/auth.c

@@ -210,7 +210,7 @@ PUBLIC int websWriteAuthFile(char *path)
 
 
     tempFile = websTempFile(NULL, NULL);
     tempFile = websTempFile(NULL, NULL);
     if ((fp = fopen(tempFile, "w" FILE_TEXT)) == 0) {
     if ((fp = fopen(tempFile, "w" FILE_TEXT)) == 0) {
-        error("Cannot open %s", tempFile);
+        printf("Cannot open %s", tempFile);
         wfree(tempFile);
         wfree(tempFile);
         return -1;
         return -1;
     }
     }
@@ -237,7 +237,7 @@ PUBLIC int websWriteAuthFile(char *path)
     fclose(fp);
     fclose(fp);
     unlink(path);
     unlink(path);
     if (rename(tempFile, path) < 0) {
     if (rename(tempFile, path) < 0) {
-        error("Cannot create new %s", path);
+        printf("Cannot create new %s", path);
         wfree(tempFile);
         wfree(tempFile);
         return -1;
         return -1;
     }
     }
@@ -269,11 +269,11 @@ WebsUser *websAddUser(char *username, char *password, char *roles)  //jimbo todo
     WebsUser    *user;
     WebsUser    *user;
 
 
     if (!username) {
     if (!username) {
-        error("User is missing name");
+        printf("User is missing name");
         return 0;
         return 0;
     }
     }
     if (websLookupUser(username)) {
     if (websLookupUser(username)) {
-        error("User %s already exists", username);
+        printf("User %s already exists", username);
         /* Already exists */
         /* Already exists */
         return 0;
         return 0;
     }
     }
@@ -361,7 +361,7 @@ static void computeAbilities(WebsHash abilities, char *role, int depth)
     assert(depth >= 0);
     assert(depth >= 0);
 
 
     if (depth > 20) {
     if (depth > 20) {
-        error("Recursive ability definition for %s", role);
+        printf("Recursive ability definition for %s", role);
         return;
         return;
     }
     }
     if (roles >= 0) {
     if (roles >= 0) {
@@ -397,7 +397,7 @@ static void computeUserAbilities(WebsUser *user)
             printf("%s ", key->name.value.string);
             printf("%s ", key->name.value.string);
             ability = key->name.value.string;
             ability = key->name.value.string;
         }
         }
-        printf("");
+        printf("\n");
     }
     }
 #endif
 #endif
     wfree(roles);
     wfree(roles);
@@ -423,11 +423,11 @@ WebsRole *websAddRole(char *name, WebsHash abilities)
     WebsRole    *rp;
     WebsRole    *rp;
 
 
     if (!name) {
     if (!name) {
-        error("Role is missing name");
+        printf("Role is missing name");
         return 0;
         return 0;
     }
     }
     if (hashLookup(roles, name)) {
     if (hashLookup(roles, name)) {
-        error("Role %s already exists", name);
+        printf("Role %s already exists", name);
         /* Already exists */
         /* Already exists */
         return 0;
         return 0;
     }
     }
@@ -500,12 +500,12 @@ PUBLIC bool websLoginUser(Webs *wp, char *username, char *password)
     wp->password = sclone(password);
     wp->password = sclone(password);
 
 
     if (!(wp->route->verify)(wp)) {
     if (!(wp->route->verify)(wp)) {
-        printf("Password does not match");
+        printf("Password does not match\n");
         return 0;
         return 0;
     }
     }
 
 
     //这一句打印不能去掉,去掉后在登录网页时goahead会重启。
     //这一句打印不能去掉,去掉后在登录网页时goahead会重启。
-    printf("Login successful for %s", username);
+    printf("Login successful for %s\n", username);
 
 
     websCreateSession(wp);
     websCreateSession(wp);
     websSetSessionVar(wp, WEBS_SESSION_USERNAME, wp->username);
     websSetSessionVar(wp, WEBS_SESSION_USERNAME, wp->username);

+ 1 - 1
app/goahead-3.6.5/src/cJSON/cJSON.c

@@ -37,7 +37,7 @@ static const char *ep;
 
 
 void jimboTestcJson(void)
 void jimboTestcJson(void)
 {
 {
-	error("---> This is jimbo test cJSON.c\n");
+	printf("---> This is jimbo test cJSON.c\n");
 }
 }
 
 
 const char *cJSON_GetErrorPtr(void) {return ep;}
 const char *cJSON_GetErrorPtr(void) {return ep;}

+ 13 - 28
app/goahead-3.6.5/src/goahead-mbedtls/goahead-mbedtls.c

@@ -50,7 +50,6 @@ static int  mbedHandshake(Webs *wp);
 static int  parseCert(mbedtls_x509_crt *cert, char *file);
 static int  parseCert(mbedtls_x509_crt *cert, char *file);
 static int  parseCrl(mbedtls_x509_crl *crl, char *path);
 static int  parseCrl(mbedtls_x509_crl *crl, char *path);
 static int  parseKey(mbedtls_pk_context *key, char *path);
 static int  parseKey(mbedtls_pk_context *key, char *path);
-static void merror(int rc, char *fmt, ...);
 static char *replaceHyphen(char *cipher, char from, char to);
 static char *replaceHyphen(char *cipher, char from, char to);
 static void traceMbed(void *context, int level, cchar *file, int line, cchar *str);
 static void traceMbed(void *context, int level, cchar *file, int line, cchar *str);
 
 
@@ -79,7 +78,6 @@ PUBLIC int sslOpen()
     mbedtls_ssl_ticket_init(&cfg.tickets);
     mbedtls_ssl_ticket_init(&cfg.tickets);
 
 
     if ((rc = mbedtls_ctr_drbg_seed(&cfg.ctr, mbedtls_entropy_func, &cfg.entropy, (cuchar*) ME_NAME, slen(ME_NAME))) < 0) {
     if ((rc = mbedtls_ctr_drbg_seed(&cfg.ctr, mbedtls_entropy_func, &cfg.entropy, (cuchar*) ME_NAME, slen(ME_NAME))) < 0) {
-        merror(rc, "Cannot seed rng");
         return -1;
         return -1;
     }
     }
 
 
@@ -121,7 +119,6 @@ PUBLIC int sslOpen()
 
 
     if ((rc = mbedtls_ssl_config_defaults(conf, MBEDTLS_SSL_IS_SERVER, MBEDTLS_SSL_TRANSPORT_STREAM, 
     if ((rc = mbedtls_ssl_config_defaults(conf, MBEDTLS_SSL_IS_SERVER, MBEDTLS_SSL_TRANSPORT_STREAM, 
             MBEDTLS_SSL_PRESET_DEFAULT)) < 0) {
             MBEDTLS_SSL_PRESET_DEFAULT)) < 0) {
-        merror(rc, "Cannot set mbedtls defaults");
         return -1;
         return -1;
     }
     }
     mbedtls_ssl_conf_rng(conf, mbedtls_ctr_drbg_random, &cfg.ctr);
     mbedtls_ssl_conf_rng(conf, mbedtls_ctr_drbg_random, &cfg.ctr);
@@ -130,7 +127,7 @@ PUBLIC int sslOpen()
         Configure larger DH parameters
         Configure larger DH parameters
      */
      */
     if ((rc = mbedtls_ssl_conf_dh_param(conf, MBEDTLS_DHM_RFC5114_MODP_2048_P, MBEDTLS_DHM_RFC5114_MODP_2048_G)) < 0) {
     if ((rc = mbedtls_ssl_conf_dh_param(conf, MBEDTLS_DHM_RFC5114_MODP_2048_P, MBEDTLS_DHM_RFC5114_MODP_2048_G)) < 0) {
-        merror(rc, "Cannot set DH params");
+
         return -1;
         return -1;
     }
     }
 
 
@@ -145,7 +142,7 @@ PUBLIC int sslOpen()
     if (ME_GOAHEAD_SSL_TICKET) {
     if (ME_GOAHEAD_SSL_TICKET) {
         if ((rc = mbedtls_ssl_ticket_setup(&cfg.tickets, mbedtls_ctr_drbg_random, &cfg.ctr,
         if ((rc = mbedtls_ssl_ticket_setup(&cfg.tickets, mbedtls_ctr_drbg_random, &cfg.ctr,
                 MBEDTLS_CIPHER_AES_256_GCM, ME_GOAHEAD_SSL_TIMEOUT)) < 0) {
                 MBEDTLS_CIPHER_AES_256_GCM, ME_GOAHEAD_SSL_TIMEOUT)) < 0) {
-            merror(rc, "Cannot setup ticketing sessions");
+
             return -1;
             return -1;
         }
         }
         mbedtls_ssl_conf_session_tickets_cb(conf, mbedtls_ssl_ticket_write, mbedtls_ssl_ticket_parse, &cfg.tickets);
         mbedtls_ssl_conf_session_tickets_cb(conf, mbedtls_ssl_ticket_write, mbedtls_ssl_ticket_parse, &cfg.tickets);
@@ -177,7 +174,7 @@ PUBLIC int sslOpen()
      */
      */
     if (ME_GOAHEAD_SSL_KEY[0] != '\0' && ME_GOAHEAD_SSL_CERTIFICATE[0] != '\0') {
     if (ME_GOAHEAD_SSL_KEY[0] != '\0' && ME_GOAHEAD_SSL_CERTIFICATE[0] != '\0') {
         if ((rc = mbedtls_ssl_conf_own_cert(conf, &cfg.cert, &cfg.pkey)) < 0) {
         if ((rc = mbedtls_ssl_conf_own_cert(conf, &cfg.cert, &cfg.pkey)) < 0) {
-            merror(rc, "Cannot define certificate and private key");
+
             return -1;
             return -1;
         }
         }
     }
     }
@@ -284,11 +281,11 @@ static int mbedHandshake(Webs *wp)
     if (rc < 0) {
     if (rc < 0) {
         if (rc == MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED && 
         if (rc == MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED && 
                 (ME_GOAHEAD_SSL_KEY[0] == '\0' || ME_GOAHEAD_SSL_CERTIFICATE[0] == '\0')) {
                 (ME_GOAHEAD_SSL_KEY[0] == '\0' || ME_GOAHEAD_SSL_CERTIFICATE[0] == '\0')) {
-            error("Missing required certificate and key");
+            printf("Missing required certificate and key");
         } else {
         } else {
             char ebuf[256];
             char ebuf[256];
             mbedtls_strerror(-rc, ebuf, sizeof(ebuf));
             mbedtls_strerror(-rc, ebuf, sizeof(ebuf));
-            error("%s: error -0x%x", ebuf, -rc);
+            printf("%s: error -0x%x", ebuf, -rc);
         }
         }
         sp->flags |= SOCKET_EOF;
         sp->flags |= SOCKET_EOF;
         errno = EPROTO;
         errno = EPROTO;
@@ -380,7 +377,7 @@ PUBLIC ssize sslRead(Webs *wp, void *buf, ssize len)
                 sp->flags |= SOCKET_EOF;
                 sp->flags |= SOCKET_EOF;
                 return -1;
                 return -1;
             } else {
             } else {
-                printf( "mbedtls: read error -0x%", -rc);
+                printf( "mbedtls: read error %d", rc);
                 sp->flags |= SOCKET_EOF;
                 sp->flags |= SOCKET_EOF;
                 return -1; 
                 return -1; 
             }
             }
@@ -458,7 +455,7 @@ static int *getCipherSuite(char *ciphers, int *len)
     for (i = 0; (cipher = stok(next, ":, \t", &next)) != 0; ) {
     for (i = 0; (cipher = stok(next, ":, \t", &next)) != 0; ) {
         replaceHyphen(cipher, '_', '-');
         replaceHyphen(cipher, '_', '-');
         if ((code = mbedtls_ssl_get_ciphersuite_id(cipher)) <= 0) {
         if ((code = mbedtls_ssl_get_ciphersuite_id(cipher)) <= 0) {
-            error("Unsupported cipher \"%s\"", cipher);
+            printf("Unsupported cipher \"%s\"", cipher);
             continue;
             continue;
         }
         }
         result[i++] = code;
         result[i++] = code;
@@ -477,7 +474,7 @@ static int parseCert(mbedtls_x509_crt *cert, char *path)
     ssize   len;
     ssize   len;
 
 
     if ((buf = websReadWholeFile(path)) == 0) {
     if ((buf = websReadWholeFile(path)) == 0) {
-        error("Unable to read certificate %s", path); 
+        printf("Unable to read certificate %s", path); 
         return -1;
         return -1;
     }
     }
     len = slen(buf);
     len = slen(buf);
@@ -487,7 +484,7 @@ static int parseCert(mbedtls_x509_crt *cert, char *path)
     }
     }
     if (mbedtls_x509_crt_parse(cert, (uchar*) buf, len) != 0) {
     if (mbedtls_x509_crt_parse(cert, (uchar*) buf, len) != 0) {
         memset(buf, 0, len);
         memset(buf, 0, len);
-        error("Unable to parse certificate %s", path); 
+        printf("Unable to parse certificate %s", path); 
         return -1;
         return -1;
     }
     }
     memset(buf, 0, len);
     memset(buf, 0, len);
@@ -502,7 +499,7 @@ static int parseKey(mbedtls_pk_context *key, char *path)
     ssize   len;
     ssize   len;
 
 
     if ((buf = websReadWholeFile(path)) == 0) {
     if ((buf = websReadWholeFile(path)) == 0) {
-        error("Unable to read key %s", path); 
+        printf("Unable to read key %s", path); 
         return -1;
         return -1;
     }
     }
     len = slen(buf);
     len = slen(buf);
@@ -511,7 +508,7 @@ static int parseKey(mbedtls_pk_context *key, char *path)
     }
     }
     if (mbedtls_pk_parse_key(key, (uchar*) buf, len, NULL, 0) != 0) {
     if (mbedtls_pk_parse_key(key, (uchar*) buf, len, NULL, 0) != 0) {
         memset(buf, 0, len);
         memset(buf, 0, len);
-        error("Unable to parse key %s", path); 
+        printf("Unable to parse key %s", path); 
         return -1;
         return -1;
     }
     }
     memset(buf, 0, len);
     memset(buf, 0, len);
@@ -526,7 +523,7 @@ static int parseCrl(mbedtls_x509_crl *crl, char *path)
     ssize   len;
     ssize   len;
 
 
     if ((buf = websReadWholeFile(path)) == 0) {
     if ((buf = websReadWholeFile(path)) == 0) {
-        error("Unable to read crl %s", path); 
+        printf("Unable to read crl %s", path); 
         return -1;
         return -1;
     }
     }
     len = slen(buf);
     len = slen(buf);
@@ -535,7 +532,7 @@ static int parseCrl(mbedtls_x509_crl *crl, char *path)
     }
     }
     if (mbedtls_x509_crl_parse(crl, (uchar*) buf, len) != 0) {
     if (mbedtls_x509_crl_parse(crl, (uchar*) buf, len) != 0) {
         memset(buf, 0, len);
         memset(buf, 0, len);
-        error("Unable to parse crl %s", path); 
+        printf("Unable to parse crl %s", path); 
         return -1;
         return -1;
     }
     }
     memset(buf, 0, len);
     memset(buf, 0, len);
@@ -558,18 +555,6 @@ static void traceMbed(void *context, int level, cchar *file, int line, cchar *st
 }
 }
 
 
 
 
-static void merror(int rc, char *fmt, ...)
-{
-    va_list     ap;
-    char        ebuf[ME_MAX_BUFFER];
-
-    va_start(ap, fmt);
-    mbedtls_strerror(-rc, ebuf, sizeof(ebuf));
-    error("mbedtls", "mbedtls error: 0x%x %s %s", rc, sfmtv(fmt, ap), ebuf);
-    va_end(ap);
-}
-
-
 static char *replaceHyphen(char *cipher, char from, char to)
 static char *replaceHyphen(char *cipher, char from, char to)
 {
 {
     char    *cp;
     char    *cp;

+ 4 - 4
app/goahead-3.6.5/src/goahead.c

@@ -96,7 +96,7 @@ MAIN(goahead, int argc, char **argv, char **envp)
             if (argind >= argc) usage();
             if (argind >= argc) usage();
             home = argv[++argind];
             home = argv[++argind];
             if (chdir(home) < 0) {
             if (chdir(home) < 0) {
-                error("Cannot change directory to %s", home);
+                printf("Cannot change directory to %s", home);
                 exit(-1);
                 exit(-1);
             }
             }
         } else if (smatch(argp, "--log") || smatch(argp, "-l")) {
         } else if (smatch(argp, "--log") || smatch(argp, "-l")) {
@@ -128,12 +128,12 @@ MAIN(goahead, int argc, char **argv, char **envp)
     }
     }
     initPlatform(); //注册信号
     initPlatform(); //注册信号
     if (websOpen(documents, route) < 0) {
     if (websOpen(documents, route) < 0) {
-        error("Cannot initialize server. Exiting.");
+        printf("Cannot initialize server. Exiting.");
         return -1;
         return -1;
     }
     }
 #if ME_GOAHEAD_AUTH
 #if ME_GOAHEAD_AUTH
     if (websLoad(auth) < 0) {
     if (websLoad(auth) < 0) {
-        error("Cannot load %s", auth);
+        printf("Cannot load %s", auth);
         return -1;
         return -1;
     }
     }
 #endif
 #endif
@@ -239,7 +239,7 @@ websDefineAction("web_RestoreConfig", web_RestoreConfig);
     if (websGetBackground()) {
     if (websGetBackground()) {
         printf("---> daemon\n");
         printf("---> daemon\n");
         if (daemon(0, 0) < 0) {
         if (daemon(0, 0) < 0) {
-            error("Cannot run as daemon");
+            printf("Cannot run as daemon");
             return -1;
             return -1;
         }
         }
     }
     }

+ 4 - 44
app/goahead-3.6.5/src/goahead.h

@@ -170,46 +170,6 @@ PUBLIC_DATA int logLevel;
 #define WEBS_RAW_MSG        0x200       /**< Raw message output */
 #define WEBS_RAW_MSG        0x200       /**< Raw message output */
 #define WEBS_TRACE_MSG      0x400       /**< Originated from trace */
 #define WEBS_TRACE_MSG      0x400       /**< Originated from trace */
 
 
-
-// #if ME_GOAHEAD_TRACING && ME_GOAHEAD_LOGGING
-//     #if ME_COMPILER_HAS_MACRO_VARARGS
-//       #define trace(l, ...) if (((l) & WEBS_LEVEL_MASK) <= websGetLogLevel()) { traceProc(l, __VA_ARGS__); } else {}
-//     #else
-//         inline void trace(int level, cchar *fmt, ...) {
-//             WebsLogHandler logHandler = logGetHandler();
-//             if ((level & WEBS_LEVEL_MASK) <= logLevel && logHandler) {
-//                 va_list args; va_start(args, fmt);
-//                 char *message = sfmtv((char*) fmt, args);
-//                 logHandler(level | WEBS_TRACE_MSG, message);
-//                 wfree(message);
-//                 va_end(args);
-//             }
-//         }
-//     #endif
-// #else
-//     #define trace(l, ...) if (1) ; else {}
-// #endif
-
-// #if ME_GOAHEAD_LOGGING
-//     #if ME_COMPILER_HAS_MACRO_VARARGS
-//         #define logmsg(l, ...) if ((l) <= logLevel) { logmsgProc(l, __VA_ARGS__); } else {}
-//     #else
-//         inline void logmsg(int level, cchar *fmt, ...) {
-//             WebsLogHandler logHandler = logGetHandler();
-//             if ((level & WEBS_LEVEL_MASK) <= logLevel && logHandler) {
-//                 va_list args; va_start(args, fmt);
-//                 char *message = sfmtv((char*) fmt, args);
-//                 logHandler(level | WEBS_TRACE_MSG, message);
-//                 wfree(message);
-//                 va_end(args);
-//             }
-//         }
-//     #endif
-// #else
-//     #define logmsg(l, ...) if (1) ; else {}
-// #endif
-
-
 #if DOXYGEN
 #if DOXYGEN
 #undef assert
 #undef assert
 /**
 /**
@@ -248,7 +208,7 @@ typedef void (*WebsLogHandler)(int level, char *msg);
     @return Zero if successful
     @return Zero if successful
     @stability Stable
     @stability Stable
 */
 */
-PUBLIC void error(char *fmt, ...);
+//PUBLIC void error(char *fmt, ...);
 
 
 /**
 /**
     Open the log logging module
     Open the log logging module
@@ -330,12 +290,12 @@ PUBLIC void traceProc(int level, char *fmt, ...);
 
 
 #else /*! ME_GOAHEAD_LOGGING */
 #else /*! ME_GOAHEAD_LOGGING */
     #define assert(C) if (1) ; else {}
     #define assert(C) if (1) ; else {}
-    #define error(l, ...) if (1) ; else {}
-    #define trace(l, ...) if (1) ; else {}
+    //#define error(l, ...) if (1) ; else {}
+    //#define trace(l, ...) if (1) ; else {}
     #define logOpen() if (1) ; else {}
     #define logOpen() if (1) ; else {}
     #define logClose() if (1) ; else {}
     #define logClose() if (1) ; else {}
     #define websGetLogLevel() 0
     #define websGetLogLevel() 0
-    #define logmsg(l, ...) if (1) ; else {}
+    //#define logmsg(l, ...) if (1) ; else {}
     #define logSetPath(p) if (1) ; else {}
     #define logSetPath(p) if (1) ; else {}
 #endif
 #endif
 
 

+ 15 - 15
app/goahead-3.6.5/src/http.c

@@ -280,7 +280,7 @@ PUBLIC int websOpen(char *documents, char *routeFile)
 
 
 #if ME_GOAHEAD_ACCESS_LOG && !ME_ROM
 #if ME_GOAHEAD_ACCESS_LOG && !ME_ROM
     if ((accessFd = open(accessLog, O_CREAT | O_TRUNC | O_APPEND | O_WRONLY, 0666)) < 0) {
     if ((accessFd = open(accessLog, O_CREAT | O_TRUNC | O_APPEND | O_WRONLY, 0666)) < 0) {
-        error("Cannot open access log %s", accessLog);
+        printf("Cannot open access log %s", accessLog);
         return -1;
         return -1;
     }
     }
     /* Some platforms don't implement O_APPEND (VXWORKS) */
     /* Some platforms don't implement O_APPEND (VXWORKS) */
@@ -440,7 +440,7 @@ static void termWebs(Webs *wp, int reuse)
         wp->putfd = -1;
         wp->putfd = -1;
         assert(wp->putname && wp->filename);
         assert(wp->putname && wp->filename);
         if (rename(wp->putname, wp->filename) < 0) {
         if (rename(wp->putname, wp->filename) < 0) {
-            error("Cannot rename PUT file from %s to %s", wp->putname, wp->filename);
+            printf("Cannot rename PUT file from %s to %s", wp->putname, wp->filename);
         }
         }
     }
     }
 #endif
 #endif
@@ -687,7 +687,7 @@ PUBLIC int websAccept(int sid, char *ipaddr, int port, int listenSid)
      */
      */
     len = sizeof(ifAddr);
     len = sizeof(ifAddr);
     if (getsockname(socketPtr(sid)->sock, (struct sockaddr*) &ifAddr, (Socklen*) &len) < 0) {
     if (getsockname(socketPtr(sid)->sock, (struct sockaddr*) &ifAddr, (Socklen*) &len) < 0) {
-        error("Cannot get sockname");
+        printf("Cannot get sockname");
         return -1;
         return -1;
     }
     }
     socketAddress((struct sockaddr*) &ifAddr, (int) len, wp->ifaddr, sizeof(wp->ifaddr), NULL);
     socketAddress((struct sockaddr*) &ifAddr, (int) len, wp->ifaddr, sizeof(wp->ifaddr), NULL);
@@ -714,7 +714,7 @@ PUBLIC int websAccept(int sid, char *ipaddr, int port, int listenSid)
         wp->flags |= WEBS_SECURE;
         wp->flags |= WEBS_SECURE;
         //printf( "Upgrade connection to TLS");
         //printf( "Upgrade connection to TLS");
         if (sslUpgrade(wp) < 0) {
         if (sslUpgrade(wp) < 0) {
-            error("Cannot upgrade to TLS");
+            printf("Cannot upgrade to TLS");
             return -1;
             return -1;
         }
         }
     }
     }
@@ -938,7 +938,7 @@ static bool parseIncoming(Webs *wp)
         wfree(wp->putname);
         wfree(wp->putname);
         wp->putname = websTempFile(ME_GOAHEAD_PUT_DIR, "put");
         wp->putname = websTempFile(ME_GOAHEAD_PUT_DIR, "put");
         if ((wp->putfd = open(wp->putname, O_BINARY | O_WRONLY | O_CREAT | O_BINARY, 0644)) < 0) {
         if ((wp->putfd = open(wp->putname, O_BINARY | O_WRONLY | O_CREAT | O_BINARY, 0644)) < 0) {
-            error("Cannot create PUT filename %s", wp->putname);
+            printf("Cannot create PUT filename %s", wp->putname);
             websError(wp, HTTP_CODE_INTERNAL_SERVER_ERROR, "Cannot create the put URI");
             websError(wp, HTTP_CODE_INTERNAL_SERVER_ERROR, "Cannot create the put URI");
             wfree(wp->putname);
             wfree(wp->putname);
             return 1;
             return 1;
@@ -991,7 +991,7 @@ static void parseFirstLine(Webs *wp)
      */
      */
     host = path = port = query = ext = NULL;
     host = path = port = query = ext = NULL;
     if (websUrlParse(url, &buf, NULL, &host, &port, &path, &ext, NULL, &query) < 0) {
     if (websUrlParse(url, &buf, NULL, &host, &port, &path, &ext, NULL, &query) < 0) {
-        error("Cannot parse URL: %s", url);
+        printf("Cannot parse URL: %s", url);
         websError(wp, HTTP_CODE_BAD_REQUEST | WEBS_CLOSE | WEBS_NOLOG, "Bad URL");
         websError(wp, HTTP_CODE_BAD_REQUEST | WEBS_CLOSE | WEBS_NOLOG, "Bad URL");
         return;
         return;
     }
     }
@@ -1810,7 +1810,7 @@ PUBLIC int websWriteHeader(Webs *wp, char *key, char *fmt, ...)
     if (fmt) {
     if (fmt) {
         va_start(vargs, fmt);
         va_start(vargs, fmt);
         if ((buf = sfmtv(fmt, vargs)) == 0) {
         if ((buf = sfmtv(fmt, vargs)) == 0) {
-            error("websWrite lost data, buffer overflow");
+            printf("websWrite lost data, buffer overflow");
             return -1;
             return -1;
         }
         }
         va_end(vargs);
         va_end(vargs);
@@ -1950,7 +1950,7 @@ PUBLIC ssize websWrite(Webs *wp, char *fmt, ...)
     buf = NULL;
     buf = NULL;
     rc = 0;
     rc = 0;
     if ((buf = sfmtv(fmt, vargs)) == 0) {
     if ((buf = sfmtv(fmt, vargs)) == 0) {
-        error("websWrite lost data, buffer overflow");
+        printf("websWrite lost data, buffer overflow");
     }
     }
     va_end(vargs);
     va_end(vargs);
     assert(buf);
     assert(buf);
@@ -2365,7 +2365,7 @@ static int get_local_ip(const char *eth_inf, char *ip)
     sd = socket(AF_INET, SOCK_DGRAM, 0);
     sd = socket(AF_INET, SOCK_DGRAM, 0);
     if (-1 == sd)
     if (-1 == sd)
     {
     {
-        error("socket error: %s\n", strerror(errno));
+        printf("socket error: %s\n", strerror(errno));
         return -1;
         return -1;
     }
     }
 
 
@@ -2375,7 +2375,7 @@ static int get_local_ip(const char *eth_inf, char *ip)
     // if error: No such device
     // if error: No such device
     if (ioctl(sd, SIOCGIFADDR, &ifr) < 0)
     if (ioctl(sd, SIOCGIFADDR, &ifr) < 0)
     {
     {
-        error("ioctl error: %s\n", strerror(errno));
+        printf("ioctl error: %s\n", strerror(errno));
         close(sd);
         close(sd);
         return -1;
         return -1;
     }
     }
@@ -2523,7 +2523,7 @@ PUBLIC bool websValidUriChars(char *uri)
     }
     }
     pos = strspn(uri, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:/?#[]@!$&'()*+,;=%");
     pos = strspn(uri, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:/?#[]@!$&'()*+,;=%");
     if (pos < slen(uri)) {
     if (pos < slen(uri)) {
-        error("Bad character in URI at \"%s\"", &uri[pos]);
+        printf("Bad character in URI at \"%s\"", &uri[pos]);
         return 0;
         return 0;
     }
     }
     return 1;
     return 1;
@@ -3069,7 +3069,7 @@ WebsSession *websGetSession(Webs *wp, int create)
                 return 0;
                 return 0;
             }
             }
             if (sessionCount > ME_GOAHEAD_LIMIT_SESSION_COUNT) {
             if (sessionCount > ME_GOAHEAD_LIMIT_SESSION_COUNT) {
-                error("Too many sessions %d/%d", sessionCount, ME_GOAHEAD_LIMIT_SESSION_COUNT);
+                printf("Too many sessions %d/%d", sessionCount, ME_GOAHEAD_LIMIT_SESSION_COUNT);
                 wfree(id);
                 wfree(id);
                 return 0;
                 return 0;
             }
             }
@@ -3251,11 +3251,11 @@ PUBLIC int websServer(char *endpoint, char *documents)
     int     finished = 0;
     int     finished = 0;
 
 
     if (websOpen(documents, "route.txt") < 0) {
     if (websOpen(documents, "route.txt") < 0) {
-        error("Cannot initialize server. Exiting.");
+        printf("Cannot initialize server. Exiting.");
         return -1;
         return -1;
     }
     }
     if (websLoad("auth.txt") < 0) {
     if (websLoad("auth.txt") < 0) {
-        error("Cannot load auth.txt");
+        printf("Cannot load auth.txt");
         return -1;
         return -1;
     }
     }
     if (websListen(endpoint) < 0) {
     if (websListen(endpoint) < 0) {
@@ -3295,7 +3295,7 @@ static void setFileLimits()
     } else {
     } else {
         r.rlim_cur = r.rlim_max = limit;
         r.rlim_cur = r.rlim_max = limit;
         if (setrlimit(RLIMIT_NOFILE, &r) < 0) {
         if (setrlimit(RLIMIT_NOFILE, &r) < 0) {
-            error("Cannot set file limit to %d", limit);
+            printf("Cannot set file limit to %d", limit);
         }
         }
     }
     }
     getrlimit(RLIMIT_NOFILE, &r);
     getrlimit(RLIMIT_NOFILE, &r);

+ 10 - 0
app/goahead-3.6.5/src/libipmi/inc/libipmi_ChassisDevice.h

@@ -85,6 +85,16 @@ typedef enum tag_FORCE_CHASSIS_ID
 uint16_t	LIBIPMI_HL_GetSystemBootOptions_BootFlags( IPMI20_UDS_SESSION_T *pUDSSession, BootFlags_T* pBootFlags,int timeout);
 uint16_t	LIBIPMI_HL_GetSystemBootOptions_BootFlags( IPMI20_UDS_SESSION_T *pUDSSession, BootFlags_T* pBootFlags,int timeout);
 uint16_t	LIBIPMI_HL_SetSystemBootOptions_BootFlags( IPMI20_UDS_SESSION_T *pUDSSession, BootFlags_T* pBootFlags,int timeout);
 uint16_t	LIBIPMI_HL_SetSystemBootOptions_BootFlags( IPMI20_UDS_SESSION_T *pUDSSession, BootFlags_T* pBootFlags,int timeout);
 
 
+
+uint16_t	IPMI_GetPOH( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t *min_per_cnt, uint32_t *counts,int timeout);
+uint16_t	IPMC_GetPOH( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint8_t *min_per_cnt, uint32_t *counts,int timeout);
+uint16_t IPMICMD_ChassisIdentify(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IdentifyInterval, uint8_t ForceIdentify, int timeout);
+uint16_t	IPMC_ChassisIdentify(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint8_t IdentifyInterval, uint8_t ForceIdentify, int timeout);
+
+
+
+
+
 #pragma pack()
 #pragma pack()
 
 
 #ifdef  __cplusplus
 #ifdef  __cplusplus

+ 6 - 0
app/goahead-3.6.5/src/libipmi/inc/libipmi_storlead_OEM.h

@@ -117,5 +117,11 @@ int IPMI_GetSensorName(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t sensor_number,
 int IPMC_GetSensorName(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint8_t sensor_number, uint8_t *sensor_name, int timeout);
 int IPMC_GetSensorName(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint8_t sensor_number, uint8_t *sensor_name, int timeout);
 int IPMI_GetSensorHistory(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t sensor_number, uint8_t *history_buf, int timeout);
 int IPMI_GetSensorHistory(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t sensor_number, uint8_t *history_buf, int timeout);
 int IPMC_GetSensorHistory(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint8_t sensor_number, uint16_t offset, uint16_t length, uint8_t *history_buf, int timeout);
 int IPMC_GetSensorHistory(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint8_t sensor_number, uint16_t offset, uint16_t length, uint8_t *history_buf, int timeout);
+uint16_t	IPMI_GetCurRunTime( IPMI20_UDS_SESSION_T *pUDSSession, uint32_t *minutes,int timeout);
+uint16_t	IPMC_GetCurRunTime( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint32_t *minutes,int timeout);
+uint16_t	IPMI_SaveConfig( IPMI20_UDS_SESSION_T *pUDSSession,int timeout);
+uint16_t	IPMC_SaveConfig( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,int timeout);
+uint16_t	IPMI_RestoreConfig( IPMI20_UDS_SESSION_T *pUDSSession,int timeout);
+uint16_t	IPMC_RestoreConfig( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,int timeout);
 #endif /* __LIBIPMI_STORLEAD_OEM_H__ */
 #endif /* __LIBIPMI_STORLEAD_OEM_H__ */
 
 

+ 114 - 44
app/goahead-3.6.5/src/libipmi/src/libipmi_Chassis.c

@@ -170,21 +170,62 @@ uint16_t IPMICMD_SetSystemBootOptions(IPMI20_UDS_SESSION_T *pUDSSession, SetBoot
 
 
 
 
 
 
-uint16_t IPMICMD_ChassisIdentify(IPMI20_UDS_SESSION_T *pUDSSession,int timeout,ChassisIdentifyReq_T* ChassisIdReq)
+uint16_t IPMICMD_ChassisIdentify(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IdentifyInterval, uint8_t ForceIdentify, int timeout)
 {
 {
-	 uint32_t		dwResLen;
-    	 uint16_t		wRet;
-	 ChassisIdentifyRes_T ChassisIdRes = {0};
-	 
-	 dwResLen = sizeof (ChassisIdentifyRes_T);
-	 
-	 wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+	uint32_t		dwResLen;
+   	uint16_t		wRet;
+	uint8_t 		Res[10];
+	uint8_t			Req[10];
+
+	Req[0] = IdentifyInterval;
+	Req[1] = ForceIdentify;
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
 					    NETFNLUN_IPMI_CHASSIS, CMD_CHASSIS_IDENTIFY,
 					    NETFNLUN_IPMI_CHASSIS, CMD_CHASSIS_IDENTIFY,
-					    (uint8_t *)ChassisIdReq,sizeof(ChassisIdentifyReq_T),
-					    (uint8_t*)&ChassisIdRes, &dwResLen,
+					    Req,2,
+					    Res, &dwResLen,
 					    timeout);
 					    timeout);
+
+	if((wRet != 0) || (Res[0] != 0))
+	{
+		printf("ChassisIdentify failed! ccode = %d\n", Res[0]);
+		return -1;
+	}
 					    
 					    
-	return wRet;
+	return 0;
+}
+
+uint16_t	IPMC_ChassisIdentify(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint8_t IdentifyInterval, uint8_t ForceIdentify, int timeout)
+{
+
+	uint16_t 	wRet = 0;
+	uint8_t 	Req[10] = {0};
+	uint8_t		Res[10];
+	uint32_t	dwResLen;
+	
+	//get title
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_CHASSIS;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_CHASSIS_IDENTIFY;	
+	Req[7] = IdentifyInterval;
+	Req[8] = ForceIdentify;
+	Req[9] = 0x100 - (Req[4] + Req[5] + Req[6] + Req[7] + Req[8])&0xff;
+
+	//dwResLen = sizeof(GetDevIDRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 
+											DEFAULT_NET_FN_LUN, CMD_SEND_MSG,
+											Req, 10,
+											Res, &dwResLen,
+											timeout);
+    if((wRet != 0) || (Res[6] != 0))
+	{
+		printf("---> IPMC_ChassisIdentify failed! ccode = %d\n", Res[6]);
+		return -1;
+	}
+	return 0;
 }
 }
 
 
 
 
@@ -296,39 +337,6 @@ uint16_t	IPMC_GetChassisStatus( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbA
     return 0;
     return 0;
 }
 }
 
 
-//will turn chassis identify on or off
-//BlinkTime - Set to TURN_OFF for turning off indefinitely
-//	      Set to Interval in secs for chassis identify to be on for that much time.
-// 	      for indefinite interval set ForceOn to 1.
-// ForceOn - overrides BlinkTime settings if set to 1.Set to 0 if controlling by interval
-uint16_t LIBIPMI_HL_ChassisIdentify(IPMI20_UDS_SESSION_T *pUDSSession, int timeout,uint8_t BlinkTimeSecs,FORCE_CHASSIS_ID ForceOn)
-{
-	uint16_t wRet;
-	
-	ChassisIdentifyReq_T ChassisIdReq = {0};
-	
-	//set interval to blinktimesecs. If caller set it to 0 so be it.
-	//The caller should always give a time to this function . He can Use SPEC_DEFAULT to get default timeout behavior.
-	ChassisIdReq.IdentifyInterval = BlinkTimeSecs;
-	ChassisIdReq.ForceIdentify = ForceOn;
-	
-	printf("id interval and  force in libipmi are %d %d \n",ChassisIdReq.IdentifyInterval,ChassisIdReq.ForceIdentify);
-	
-	wRet = IPMICMD_ChassisIdentify(pUDSSession,timeout,&ChassisIdReq);
-	
-	if(wRet == LIBIPMI_E_SUCCESS)
-	{
-		printf("Chassis identify command success\n");
-	}
-	else
-	{	
-		printf("Chassis Identify failed for the following params : %d %d",BlinkTimeSecs,ForceOn);
-	}
-	
-	return wRet;
-}
-
-
 uint16_t	LIBIPMI_HL_GetSystemBootOptions_BootFlags( IPMI20_UDS_SESSION_T *pUDSSession, BootFlags_T* pBootFlags,int timeout)
 uint16_t	LIBIPMI_HL_GetSystemBootOptions_BootFlags( IPMI20_UDS_SESSION_T *pUDSSession, BootFlags_T* pBootFlags,int timeout)
 {
 {
 	uint16_t wRet;
 	uint16_t wRet;
@@ -399,3 +407,65 @@ uint16_t	LIBIPMI_HL_SetSystemBootOptions_BootFlags( IPMI20_UDS_SESSION_T *pUDSSe
 
 
 	return 0;
 	return 0;
 }
 }
+
+uint16_t	IPMI_GetPOH( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t *min_per_cnt, uint32_t *counts,int timeout)
+{
+    uint32_t		dwResLen;
+    uint16_t		wRet;
+    uint8_t 		Res[10];
+
+
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+					    NETFNLUN_IPMI_CHASSIS, CMD_GET_POH_COUNTER,
+					    NULL, 0 ,
+					    Res, &dwResLen,
+					    timeout);
+    if((wRet != 0) || (Res[0] != 0))
+    {
+    	printf("IPMI_GetPOH failed! ccode = %d\n", Res[0]);
+    	*min_per_cnt = 0;
+    	*counts = 0;
+    	return -1;
+    }
+
+    *min_per_cnt = Res[1];
+    *counts = (Res[5]<<24) | (Res[4]<<16) | (Res[3]<<8) | Res[2];
+    return 0;
+}
+
+uint16_t	IPMC_GetPOH( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint8_t *min_per_cnt, uint32_t *counts,int timeout)
+{
+
+	uint16_t 	wRet = 0;
+	uint8_t 	Req[10] = {0};
+	uint8_t		Res[50];
+	uint32_t	dwResLen;
+	
+
+	//get title
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_CHASSIS;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_GET_POH_COUNTER;	
+	Req[7] = 0x100 - (Req[4] + Req[5] + Req[6])&0xff;
+
+	//dwResLen = sizeof(GetDevIDRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 
+											DEFAULT_NET_FN_LUN, CMD_SEND_MSG,
+											Req, 8,
+											Res, &dwResLen,
+											timeout);
+    if((wRet != 0) || (Res[6] != 0))
+	{
+		printf("---> IPMC_GetPOH failed! ccode = %d\n", Res[6]);
+		return -1;
+	}
+    *min_per_cnt = Res[7];
+    *counts = (Res[11]<<24) | (Res[10]<<16) | (Res[9]<<8) | Res[8];
+        
+    return 0;
+}
+

+ 2 - 4
app/goahead-3.6.5/src/libipmi/src/libipmi_StorDevice.c

@@ -1074,13 +1074,11 @@ uint8_t IPMC_SetSELTimeUTCOffset(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t Ipmb
 	Req[6] = CMD_SET_SEL_TIME_UTC_OFFSET;	
 	Req[6] = CMD_SET_SEL_TIME_UTC_OFFSET;	
 	Req[7] = pSetSELTimeUTCOffsetReq->UTCOffset&0xff;
 	Req[7] = pSetSELTimeUTCOffsetReq->UTCOffset&0xff;
 	Req[8] = (pSetSELTimeUTCOffsetReq->UTCOffset>>8)&0xff;
 	Req[8] = (pSetSELTimeUTCOffsetReq->UTCOffset>>8)&0xff;
-	Req[9] = (pSetSELTimeUTCOffsetReq->UTCOffset>>16)&0xff;
-	Req[10] = (pSetSELTimeUTCOffsetReq->UTCOffset>>24)&0xff;
-	Req[11] = 0x100 - (Req[4] + Req[5] + Req[6] + Req[7] + Req[8] + Req[9] + Req[10])&0xff;
+	Req[9] = 0x100 - (Req[4] + Req[5] + Req[6] + Req[7] + Req[8])&0xff;
 
 
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
 							NETFNLUN_IPMI_APP, CMD_SEND_MSG,
 							NETFNLUN_IPMI_APP, CMD_SEND_MSG,
-							Req, 12,
+							Req, 10,
 							Res,  &dwResLen,
 							Res,  &dwResLen,
 							timeout);
 							timeout);
 	if ((wRet != 0) || (Res[6] != 0))
 	if ((wRet != 0) || (Res[6] != 0))

+ 9 - 4
app/goahead-3.6.5/src/libipmi/src/libipmi_session.c

@@ -116,6 +116,7 @@ uint16_t LIBIPMI_Send_RAW_IPMI2_0_Command(IPMI20_UDS_SESSION_T *pUDSSession,
     fd_set  fds;
     fd_set  fds;
     struct timeval Timeout;
     struct timeval Timeout;
     int max = 0;
     int max = 0;
+    //struct timeval begin;
 
 
     retlen = FillUDSMessagePacket(pUDSSession,pbyIPMIUDSMsgReq,byNetFnLUN,byCommand,pszReqData,dwReqDataLen);
     retlen = FillUDSMessagePacket(pUDSSession,pbyIPMIUDSMsgReq,byNetFnLUN,byCommand,pszReqData,dwReqDataLen);
 
 
@@ -161,8 +162,9 @@ uint16_t LIBIPMI_Send_RAW_IPMI2_0_Command(IPMI20_UDS_SESSION_T *pUDSSession,
         /*Accepting Connection*/
         /*Accepting Connection*/
         if(FD_ISSET(pUDSSession->hUDSInfo.hSocket,&fds))
         if(FD_ISSET(pUDSSession->hUDSInfo.hSocket,&fds))
         {
         {
-            byretval = recv(pUDSSession->hUDSInfo.hSocket,pbyIPMIUDSResData,MAX_RESPONSE_SIZE,0);
-            // printf("UDS Recv1 %d: ", byretval);
+            //这里只能接收10个字节,否则会把UDS Recv2的数据也接收了,导致UDS Recv2接收不到数据。
+            byretval = recv(pUDSSession->hUDSInfo.hSocket,pbyIPMIUDSResData,10,0);
+            //printf("UDS Recv1 %d: \n", byretval);
             // for(i=0;i<byretval;i++)
             // for(i=0;i<byretval;i++)
             //     printf("%#02x ", pbyIPMIUDSResData[i]);
             //     printf("%#02x ", pbyIPMIUDSResData[i]);
             // printf("\n");
             // printf("\n");
@@ -197,6 +199,10 @@ uint16_t LIBIPMI_Send_RAW_IPMI2_0_Command(IPMI20_UDS_SESSION_T *pUDSSession,
     /*Accepting Connection*/
     /*Accepting Connection*/
     if(FD_ISSET(pUDSSession->hUDSInfo.hSocket,&fds))
     if(FD_ISSET(pUDSSession->hUDSInfo.hSocket,&fds))
     {
     {
+        
+        // gettimeofday(&begin,NULL);
+        // printf("UDS Recv2:%ld:%ld\n", begin.tv_sec, begin.tv_usec);
+
         byretval = recv(pUDSSession->hUDSInfo.hSocket,pbyIPMIUDSResData,MAX_RESPONSE_SIZE,0);
         byretval = recv(pUDSSession->hUDSInfo.hSocket,pbyIPMIUDSResData,MAX_RESPONSE_SIZE,0);
         // printf("UDS Recv2 %d: ", byretval);
         // printf("UDS Recv2 %d: ", byretval);
         // for(i=0;i<byretval;i++)
         // for(i=0;i<byretval;i++)
@@ -206,8 +212,7 @@ uint16_t LIBIPMI_Send_RAW_IPMI2_0_Command(IPMI20_UDS_SESSION_T *pUDSSession,
 
 
     if(byretval > 0)
     if(byretval > 0)
     {
     {
-        IPMIUDSMsg_T *pIPMIUDSMsg = (IPMIUDSMsg_T *)&pbyIPMIUDSResData[0];   
-        //TODO:UDS的数据结构在最后多了一个0,找机会要给他去掉。     
+        IPMIUDSMsg_T *pIPMIUDSMsg = (IPMIUDSMsg_T *)&pbyIPMIUDSResData[0];        
         *pdwResDataLen = pIPMIUDSMsg->IPMIMsgLen-sizeof(IPMIUDSMsg_T);  //remove header, 最后多出来的一个0,and checksum
         *pdwResDataLen = pIPMIUDSMsg->IPMIMsgLen-sizeof(IPMIUDSMsg_T);  //remove header, 最后多出来的一个0,and checksum
         memcpy(pszResData,&pbyIPMIUDSResData[sizeof(IPMIUDSMsg_T)],*pdwResDataLen);
         memcpy(pszResData,&pbyIPMIUDSResData[sizeof(IPMIUDSMsg_T)],*pdwResDataLen);
     }
     }

+ 183 - 17
app/goahead-3.6.5/src/libipmi/src/libipmi_storlead_OEM.c

@@ -86,8 +86,8 @@ uint16_t LIBIPMI_HL_GetSysInfo( IPMI20_UDS_SESSION_T *pUDSSession, SysInfo_T *pS
 	Req[0] = 0;
 	Req[0] = 0;
 	Req[1] = 0;
 	Req[1] = 0;
 	Req[2] = 0;
 	Req[2] = 0;
-	Req[3] = (MAX_TITLE_LEN>>8)&0xff;	//max title len
-	Req[4] = MAX_TITLE_LEN&0xff;
+	Req[3] = MAX_TITLE_LEN&0xff;
+	Req[4] = (MAX_TITLE_LEN>>8)&0xff;	//max title len
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,   
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,   
 												NETFNLUN_IPMI_STORLEAD, CMD_GET_SYS_INFO,
 												NETFNLUN_IPMI_STORLEAD, CMD_GET_SYS_INFO,
 												(uint8_t*)Req, 5,
 												(uint8_t*)Req, 5,
@@ -98,16 +98,17 @@ uint16_t LIBIPMI_HL_GetSysInfo( IPMI20_UDS_SESSION_T *pUDSSession, SysInfo_T *pS
 		printf("---> get Title error\n");
 		printf("---> get Title error\n");
 		return -1;
 		return -1;
 	}
 	}
-	strLen = (Res[1]<<8) | Res[2];
-	remainLen = (Res[3]<<8) | Res[4];
+	strLen = (Res[2]<<8) | Res[1];
+	remainLen = (Res[4]<<8) | Res[3];
 	memcpy(pSysInfo->title,&Res[5],strLen);
 	memcpy(pSysInfo->title,&Res[5],strLen);
 
 
 	//get text
 	//get text
 	Req[0] = 1;
 	Req[0] = 1;
 	Req[1] = 0;
 	Req[1] = 0;
 	Req[2] = 0;
 	Req[2] = 0;
-	Req[3] = (MAX_TEXT_LEN>>8)&0xff;	//max text len
-	Req[4] = MAX_TEXT_LEN&0xff;
+	Req[3] = MAX_TEXT_LEN&0xff;
+	Req[4] = (MAX_TEXT_LEN>>8)&0xff;	//max text len
+	
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,   
 	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,   
 												NETFNLUN_IPMI_STORLEAD, CMD_GET_SYS_INFO,
 												NETFNLUN_IPMI_STORLEAD, CMD_GET_SYS_INFO,
 												(uint8_t*)Req, 5,
 												(uint8_t*)Req, 5,
@@ -118,8 +119,8 @@ uint16_t LIBIPMI_HL_GetSysInfo( IPMI20_UDS_SESSION_T *pUDSSession, SysInfo_T *pS
 		printf("---> get Text error\n");
 		printf("---> get Text error\n");
 		return -1;
 		return -1;
 	}
 	}
-	strLen = (Res[1]<<8) | Res[2];
-	remainLen = (Res[3]<<8) | Res[4];
+	strLen = (Res[2]<<8) | Res[1];
+	remainLen = (Res[4]<<8) | Res[3];
 	memcpy(pSysInfo->text,&Res[5],strLen);
 	memcpy(pSysInfo->text,&Res[5],strLen);
 	
 	
 	return 0;
 	return 0;
@@ -146,8 +147,8 @@ uint16_t IPMC_GetSysInfo( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, S
 	Req[7] = 0;
 	Req[7] = 0;
 	Req[8] = 0;
 	Req[8] = 0;
 	Req[9] = 0;
 	Req[9] = 0;
-	Req[10] = (MAX_TITLE_LEN>>8)&0xff;	//max title len
-	Req[11] = MAX_TITLE_LEN&0xff;
+	Req[10] = MAX_TITLE_LEN&0xff;
+	Req[11] = (MAX_TITLE_LEN>>8)&0xff;	//max title len
 	Req[12] = 0x100 - (Req[4] + Req[5] + Req[6] + Req[7] + Req[8] + Req[9] + Req[10] + Req[11])&0xff;
 	Req[12] = 0x100 - (Req[4] + Req[5] + Req[6] + Req[7] + Req[8] + Req[9] + Req[10] + Req[11])&0xff;
 
 
 	//dwResLen = sizeof(GetDevIDRes_T);
 	//dwResLen = sizeof(GetDevIDRes_T);
@@ -162,8 +163,8 @@ uint16_t IPMC_GetSysInfo( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, S
 		printf("---> get Title error\n");
 		printf("---> get Title error\n");
 		return -1;
 		return -1;
 	}
 	}
-	strLen = (Res[7]<<8) | Res[8];
-	remainLen = (Res[9]<<8) | Res[10];
+	strLen = (Res[8]<<8) | Res[7];
+	remainLen = (Res[10]<<8) | Res[9];
 	memcpy(pSysInfo->title,&Res[11],strLen);
 	memcpy(pSysInfo->title,&Res[11],strLen);
 
 
 	//get text
 	//get text
@@ -177,8 +178,8 @@ uint16_t IPMC_GetSysInfo( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, S
 	Req[7] = 1;
 	Req[7] = 1;
 	Req[8] = 0;
 	Req[8] = 0;
 	Req[9] = 0;
 	Req[9] = 0;
-	Req[10] = (MAX_TEXT_LEN>>8)&0xff;	//max text len
-	Req[11] = MAX_TEXT_LEN&0xff;
+	Req[10] = MAX_TEXT_LEN&0xff;
+	Req[11] = (MAX_TEXT_LEN>>8)&0xff;	//max text len
 	Req[12] = 0x100 - (Req[4] + Req[5] + Req[6] + Req[7] + Req[8] + Req[9] + Req[10] + Req[11])&0xff;
 	Req[12] = 0x100 - (Req[4] + Req[5] + Req[6] + Req[7] + Req[8] + Req[9] + Req[10] + Req[11])&0xff;
 
 
 	//dwResLen = sizeof(GetDevIDRes_T);
 	//dwResLen = sizeof(GetDevIDRes_T);
@@ -192,8 +193,8 @@ uint16_t IPMC_GetSysInfo( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, S
 		printf("---> get Text error\n");
 		printf("---> get Text error\n");
 		return -1;
 		return -1;
 	}
 	}
-	strLen = (Res[7]<<8) | Res[8];
-	remainLen = (Res[9]<<8) | Res[10];
+	strLen = (Res[8]<<8) | Res[7];
+	remainLen = (Res[10]<<8) | Res[9];
 	memcpy(pSysInfo->text,&Res[11],strLen);
 	memcpy(pSysInfo->text,&Res[11],strLen);
 	
 	
 	return 0;
 	return 0;
@@ -232,7 +233,7 @@ int LIBIPMI_HL_GetFanInfo(IPMI20_UDS_SESSION_T *pUDSSession, FanInfo_T* pFanInfo
 							(uint8_t*)pRes,  &dwResLen,
 							(uint8_t*)pRes,  &dwResLen,
 							timeout);
 							timeout);
 
 
-	printf("dwResLen %d\n", dwResLen);
+	//printf("dwResLen %d\n", dwResLen);
 	if(( wRet != 0 ) || (pRes[0] != 0))
 	if(( wRet != 0 ) || (pRes[0] != 0))
 	{
 	{
 		printf("Error LIBIPMI_HL_GetFanInfo\n");
 		printf("Error LIBIPMI_HL_GetFanInfo\n");
@@ -559,3 +560,168 @@ int IPMC_GetSensorHistory(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, u
 
 
     return 0;
     return 0;
 }
 }
+
+uint16_t	IPMI_GetCurRunTime( IPMI20_UDS_SESSION_T *pUDSSession, uint32_t *minutes,int timeout)
+{
+    uint32_t		dwResLen;
+    uint16_t		wRet;
+    uint8_t 		Res[10];
+
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+					    NETFNLUN_IPMI_STORLEAD, CMD_GET_CURRUNTIME,
+					    NULL, 0 ,
+					    Res, &dwResLen,
+					    timeout);
+    if((wRet != 0) || (Res[0] != 0))
+    {
+    	printf("IPMI_GetCurRunTime failed! ccode = %d\n", Res[0]);
+    	*minutes = 0;
+    	return -1;
+    }
+    *minutes = (Res[4]<<24) | (Res[3]<<16) | (Res[2]<<8) | Res[1];
+    return 0;
+}
+
+uint16_t	IPMC_GetCurRunTime( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint32_t *minutes,int timeout)
+{
+
+	uint16_t 	wRet = 0;
+	uint8_t 	Req[10] = {0};
+	uint8_t		Res[50];
+	uint32_t	dwResLen;
+	
+
+	//get title
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_STORLEAD;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_GET_CURRUNTIME;	
+	Req[7] = 0x100 - (Req[4] + Req[5] + Req[6])&0xff;
+
+	//dwResLen = sizeof(GetDevIDRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 
+											DEFAULT_NET_FN_LUN, CMD_SEND_MSG,
+											Req, 8,
+											Res, &dwResLen,
+											timeout);
+    if((wRet != 0) || (Res[6] != 0))
+	{
+		printf("---> IPMC_GetCurRunTime failed! ccode = %d\n", Res[6]);
+		*minutes = 0;
+		return -1;
+	}
+    *minutes = (Res[10]<<24) | (Res[9]<<16) | (Res[8]<<8) | Res[7];
+        
+    return 0;
+}
+
+uint16_t	IPMI_SaveConfig( IPMI20_UDS_SESSION_T *pUDSSession,int timeout)
+{
+    uint32_t		dwResLen;
+    uint16_t		wRet;
+    uint8_t 		Res[10];
+
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+					    NETFNLUN_IPMI_STORLEAD, CMD_SAVE_CONFIG,
+					    NULL, 0 ,
+					    Res, &dwResLen,
+					    timeout);
+    if((wRet != 0) || (Res[0] != 0))
+    {
+    	printf("IPMI_SaveConfig failed! ccode = %d\n", Res[0]);
+    	return -1;
+    }
+    printf("IPMI_SaveConfig successful!\n");
+    return 0;
+}
+
+uint16_t	IPMC_SaveConfig( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,int timeout)
+{
+
+	uint16_t 	wRet = 0;
+	uint8_t 	Req[10] = {0};
+	uint8_t		Res[50];
+	uint32_t	dwResLen;
+	
+
+	//get title
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_STORLEAD;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_SAVE_CONFIG;	
+	Req[7] = 0x100 - (Req[4] + Req[5] + Req[6])&0xff;
+
+	//dwResLen = sizeof(GetDevIDRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 
+											DEFAULT_NET_FN_LUN, CMD_SEND_MSG,
+											Req, 8,
+											Res, &dwResLen,
+											timeout);
+    if((wRet != 0) || (Res[6] != 0))
+	{
+		printf("---> IPMC_SaveConfig failed! ccode = %d\n", Res[6]);
+		return -1;
+	}
+    printf("IPMC_SaveConfig successful!\n");
+    return 0;
+}
+
+uint16_t	IPMI_RestoreConfig( IPMI20_UDS_SESSION_T *pUDSSession,int timeout)
+{
+    uint32_t		dwResLen;
+    uint16_t		wRet;
+    uint8_t 		Res[10];
+
+    wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,  
+					    NETFNLUN_IPMI_STORLEAD, CMD_RESTORE_CONFIG,
+					    NULL, 0 ,
+					    Res, &dwResLen,
+					    timeout);
+    if((wRet != 0) || (Res[0] != 0))
+    {
+    	printf("IPMI_RestoreConfig failed! ccode = %d\n", Res[0]);
+    	return -1;
+    }
+    printf("IPMI_RestoreConfig successful!\n");
+    return 0;
+}
+
+uint16_t	IPMC_RestoreConfig( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr,int timeout)
+{
+
+	uint16_t 	wRet = 0;
+	uint8_t 	Req[10] = {0};
+	uint8_t		Res[50];
+	uint32_t	dwResLen;
+	
+
+	//get title
+	Req[0] = 0x40;	//Track | channel 0
+	Req[1] = IpmbAddr;
+	Req[2] = NETFNLUN_IPMI_STORLEAD;
+	Req[3] = 0x100 - (Req[1] + Req[2])&0xff;	//checksum1
+	Req[4] = 0x20;
+	Req[5] = 0x10;
+	Req[6] = CMD_RESTORE_CONFIG;	
+	Req[7] = 0x100 - (Req[4] + Req[5] + Req[6])&0xff;
+
+	//dwResLen = sizeof(GetDevIDRes_T);
+	wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 
+											DEFAULT_NET_FN_LUN, CMD_SEND_MSG,
+											Req, 8,
+											Res, &dwResLen,
+											timeout);
+    if((wRet != 0) || (Res[6] != 0))
+	{
+		printf("IPMC_RestoreConfig failed! ccode = %d\n", Res[6]);
+		return -1;
+	}
+	printf("IPMC_RestoreConfig successful!\n");
+    return 0;
+}

+ 3 - 2
app/goahead-3.6.5/src/libipmi/src/sensor_helpers.c

@@ -1048,7 +1048,7 @@ unsigned char sdr_convert_sensor_value_to_raw(FullSensorRec_T   *sdr_record, dou
     k1 = tos(sdr_record->R_B_Exp & 0x0f, 4);
     k1 = tos(sdr_record->R_B_Exp & 0x0f, 4);
     k2 = tos((sdr_record->R_B_Exp & 0xf0) >> 4, 4);
     k2 = tos((sdr_record->R_B_Exp & 0xf0) >> 4, 4);
 
 
-    printf("---> m: %d, b: %d, k1: %d, k2: %d\n", m, b, k1, k2);
+    printf("---> m: %d, b: %d, k1: %d, k2: %d, val: %0.3f\n", m, b, k1, k2, val);
     
     
     /* only works for analog sensors */
     /* only works for analog sensors */
     if (sdr_record->Units1 >> 6 > 2)
     if (sdr_record->Units1 >> 6 > 2)
@@ -1075,7 +1075,7 @@ unsigned char sdr_convert_sensor_value_to_raw(FullSensorRec_T   *sdr_record, dou
         result += -0.5;
         result += -0.5;
     }
     }
     tmp = (int)result;
     tmp = (int)result;
-    printf("---> result: %f, tmp = %d,", result, tmp);
+    printf("---> result: %f, int = %d,", result, tmp);
 
 
     if (((sdr_record->Units1 & 0xC0) == 0x80) || ((sdr_record->Units1 & 0xC0) == 0x40))    //signed
     if (((sdr_record->Units1 & 0xC0) == 0x80) || ((sdr_record->Units1 & 0xC0) == 0x40))    //signed
     {
     {
@@ -1085,6 +1085,7 @@ unsigned char sdr_convert_sensor_value_to_raw(FullSensorRec_T   *sdr_record, dou
     else
     else
     {
     {
         if(tmp > 255)   tmp = 255;
         if(tmp > 255)   tmp = 255;
+        if(tmp < 0) tmp = 0;
     }
     }
     retVal = (unsigned char)tmp;
     retVal = (unsigned char)tmp;
     printf(" retVal = %#x\n", retVal);
     printf(" retVal = %#x\n", retVal);

+ 4 - 0
app/goahead-3.6.5/src/libipmi/src/userinfo.c

@@ -6,13 +6,17 @@
 
 
 int FlushUserInfoTbl(void)
 int FlushUserInfoTbl(void)
 {
 {
+	pthread_mutex_lock(&Flash_Mutex);
 	sf_sector_erase(5, USERTBL_FLASH_ADDR);
 	sf_sector_erase(5, USERTBL_FLASH_ADDR);
 	sf_write(5, USERTBL_FLASH_ADDR, (uint8_t*)UserInfoTbl, sizeof(UserInfo_T)*MAX_USER_NUM);
 	sf_write(5, USERTBL_FLASH_ADDR, (uint8_t*)UserInfoTbl, sizeof(UserInfo_T)*MAX_USER_NUM);
+	pthread_mutex_unlock(&Flash_Mutex);
 	return 0;
 	return 0;
 }
 }
 
 
 int UpdateUserInfoTble(void)
 int UpdateUserInfoTble(void)
 {
 {
+	pthread_mutex_lock(&Flash_Mutex);
 	sf_read(5, USERTBL_FLASH_ADDR, (uint8_t*)UserInfoTbl, sizeof(UserInfo_T)*MAX_USER_NUM);
 	sf_read(5, USERTBL_FLASH_ADDR, (uint8_t*)UserInfoTbl, sizeof(UserInfo_T)*MAX_USER_NUM);
+	pthread_mutex_unlock(&Flash_Mutex);
 	return 0;
 	return 0;
 }
 }

+ 8 - 8
app/goahead-3.6.5/src/route.c

@@ -129,7 +129,7 @@ PUBLIC void websRouteRequest(Webs *wp)
         }
         }
     }
     }
     if (wp->routeCount >= WEBS_MAX_ROUTE) {
     if (wp->routeCount >= WEBS_MAX_ROUTE) {
-        error("Route loop for %s", wp->url);
+        printf("Route loop for %s", wp->url);
     }
     }
     websError(wp, HTTP_CODE_NOT_FOUND, "Cannot find suitable route for request.");
     websError(wp, HTTP_CODE_NOT_FOUND, "Cannot find suitable route for request.");
     assert(wp->route == 0);
     assert(wp->route == 0);
@@ -287,7 +287,7 @@ WebsRoute *websAddRoute(char *uri, char *handler, int pos)
     WebsKey     *key;
     WebsKey     *key;
 
 
     if (uri == 0 || *uri == '\0') {
     if (uri == 0 || *uri == '\0') {
-        error("Route has bad URI");
+        printf("Route has bad URI");
         return 0;
         return 0;
     }
     }
     if ((route = walloc(sizeof(WebsRoute))) == 0) {
     if ((route = walloc(sizeof(WebsRoute))) == 0) {
@@ -301,7 +301,7 @@ WebsRoute *websAddRoute(char *uri, char *handler, int pos)
         handler = "file";
         handler = "file";
     }
     }
     if ((key = hashLookup(handlers, handler)) == 0) {
     if ((key = hashLookup(handlers, handler)) == 0) {
-        error("Cannot find route handler %s", handler);
+        printf("Cannot find route handler %s", handler);
         wfree(route->prefix);
         wfree(route->prefix);
         wfree(route);
         wfree(route);
         return 0;
         return 0;
@@ -346,7 +346,7 @@ static void growRoutes()
     if (routeCount >= routeMax) {
     if (routeCount >= routeMax) {
         routeMax += 16;
         routeMax += 16;
         if ((routes = wrealloc(routes, sizeof(WebsRoute*) * routeMax)) == 0) {
         if ((routes = wrealloc(routes, sizeof(WebsRoute*) * routeMax)) == 0) {
-            error("Cannot grow routes");
+            printf("Cannot grow routes");
         }
         }
     }
     }
 }
 }
@@ -508,7 +508,7 @@ PUBLIC int websLoad(char *path)
 
 
     rc = 0;
     rc = 0;
     if ((buf = websReadWholeFile(path)) == 0) {
     if ((buf = websReadWholeFile(path)) == 0) {
-        error("Cannot open config file %s", path);
+        printf("Cannot open config file %s", path);
         return -1;
         return -1;
     }
     }
     for (line = stok(buf, "\r\n", &token); line; line = stok(NULL, "\r\n", &token)) {
     for (line = stok(buf, "\r\n", &token); line; line = stok(NULL, "\r\n", &token)) {
@@ -551,7 +551,7 @@ PUBLIC int websLoad(char *path)
                 } else if (smatch(key, "uri")) {
                 } else if (smatch(key, "uri")) {
                     uri = value;
                     uri = value;
                 } else {
                 } else {
-                    error("Bad route keyword %s", key);
+                    printf("Bad route keyword %s", key);
                     continue;
                     continue;
                 }
                 }
             }
             }
@@ -577,7 +577,7 @@ PUBLIC int websLoad(char *path)
                 } else if (smatch(key, "roles")) {
                 } else if (smatch(key, "roles")) {
                     roles = value;
                     roles = value;
                 } else {
                 } else {
-                    error("Bad user keyword %s", key);
+                    printf("Bad user keyword %s", key);
                     continue;
                     continue;
                 }
                 }
             }
             }
@@ -603,7 +603,7 @@ PUBLIC int websLoad(char *path)
             }
             }
 #endif
 #endif
         } else {
         } else {
-            error("Unknown route keyword %s", kind);
+            printf("Unknown route keyword %s", kind);
             rc = -1;
             rc = -1;
             break;
             break;
         }
         }

+ 17 - 17
app/goahead-3.6.5/src/runtime.c

@@ -977,20 +977,20 @@ static void defaultLogHandler(int flags, char *buf)
 }
 }
 
 
 
 
-PUBLIC void error(char *fmt, ...)
-{
-    va_list     args;
-    char        *message;
-
-    if (!logHandler) {
-        return;
-    }
-    va_start(args, fmt);
-    message = sfmtv(fmt, args);
-    va_end(args);
-    logHandler(WEBS_ERROR_MSG, message);
-    wfree(message);
-}
+// PUBLIC void error(char *fmt, ...)
+// {
+//     va_list     args;
+//     char        *message;
+
+//     if (!logHandler) {
+//         return;
+//     }
+//     va_start(args, fmt);
+//     message = sfmtv(fmt, args);
+//     va_end(args);
+//     logHandler(WEBS_ERROR_MSG, message);
+//     wfree(message);
+// }
 
 
 
 
 PUBLIC void assertError(WEBS_ARGS_DEC, char *fmt, ...)
 PUBLIC void assertError(WEBS_ARGS_DEC, char *fmt, ...)
@@ -1750,7 +1750,7 @@ PUBLIC void bufAdjustEnd(WebsBuf *bp, ssize size)
         Flush the queue if the endp pointer is corrupted via a bad size
         Flush the queue if the endp pointer is corrupted via a bad size
      */
      */
     if (bp->endp >= bp->endbuf) {
     if (bp->endp >= bp->endbuf) {
-        error("Bad end pointer");
+        printf("Bad end pointer");
         bufFlush(bp);
         bufFlush(bp);
     }
     }
 }
 }
@@ -1774,7 +1774,7 @@ PUBLIC void bufAdjustStart(WebsBuf *bp, ssize size)
         Flush the queue if the servp pointer is corrupted via a bad size
         Flush the queue if the servp pointer is corrupted via a bad size
      */
      */
     if (bp->servp >= bp->endbuf) {
     if (bp->servp >= bp->endbuf) {
-        error("Bad serv pointer");
+        printf("Bad serv pointer");
         bufFlush(bp);
         bufFlush(bp);
     }
     }
 }
 }
@@ -1844,7 +1844,7 @@ PUBLIC bool bufGrow(WebsBuf *bp, ssize room)
     if (room == 0) {
     if (room == 0) {
         if (bp->maxsize >= 0 && bp->buflen >= bp->maxsize) {
         if (bp->maxsize >= 0 && bp->buflen >= bp->maxsize) {
 #if BLD_DEBUG
 #if BLD_DEBUG
-            error("Cannot grow buf. Needed %d, max %d", room, bp->maxsize);
+            printf("Cannot grow buf. Needed %d, max %d", room, bp->maxsize);
 #endif
 #endif
             return 0;
             return 0;
         }
         }

+ 4 - 4
app/goahead-3.6.5/src/socket.c

@@ -138,19 +138,19 @@ PUBLIC int socketListen(char *ip, int port, SocketAccept accept, int flags)
     enable = 1;
     enable = 1;
 #if ME_UNIX_LIKE || VXWORKS
 #if ME_UNIX_LIKE || VXWORKS
     if (setsockopt(sp->sock, SOL_SOCKET, SO_REUSEADDR, (char*) &enable, sizeof(enable)) != 0) {
     if (setsockopt(sp->sock, SOL_SOCKET, SO_REUSEADDR, (char*) &enable, sizeof(enable)) != 0) {
-        error("Cannot set reuseaddr, errno %d", errno);
+        printf("Cannot set reuseaddr, errno %d", errno);
     }
     }
 #if defined(SO_REUSEPORT) && KEEP
 #if defined(SO_REUSEPORT) && KEEP
     /*
     /*
         This permits multiple servers listening on the same endpoint
         This permits multiple servers listening on the same endpoint
      */
      */
     if (setsockopt(sp->sock, SOL_SOCKET, SO_REUSEPORT, (char*) &enable, sizeof(enable)) != 0) {
     if (setsockopt(sp->sock, SOL_SOCKET, SO_REUSEPORT, (char*) &enable, sizeof(enable)) != 0) {
-        error("Cannot set reuseport, errno %d", errno);
+        printf("Cannot set reuseport, errno %d", errno);
     }
     }
 #endif
 #endif
 #elif ME_WIN_LIKE && defined(SO_EXCLUSIVEADDRUSE)
 #elif ME_WIN_LIKE && defined(SO_EXCLUSIVEADDRUSE)
     if (setsockopt(sp->sock, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char*) &enable, sizeof(enable)) != 0) {
     if (setsockopt(sp->sock, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char*) &enable, sizeof(enable)) != 0) {
-        error("Cannot set exclusiveaddruse, errno %d", WSAGetLastError());
+        printf("Cannot set exclusiveaddruse, errno %d", WSAGetLastError());
     }
     }
 #endif
 #endif
 
 
@@ -170,7 +170,7 @@ PUBLIC int socketListen(char *ip, int port, SocketAccept accept, int flags)
     }
     }
 #endif
 #endif
     if (bind(sp->sock, (struct sockaddr*) &addr, addrlen) == SOCKET_ERROR) {
     if (bind(sp->sock, (struct sockaddr*) &addr, addrlen) == SOCKET_ERROR) {
-        error("Cannot bind to address %s:%d, errno %d", ip ? ip : "*", port, errno);
+        printf("Cannot bind to address %s:%d, errno %d", ip ? ip : "*", port, errno);
         socketFree(sid);
         socketFree(sid);
         return -1;
         return -1;
     }
     }

+ 4 - 5
app/goahead-3.6.5/src/upload.c

@@ -188,7 +188,7 @@ static void processUploadHeader(Webs *wp, char *line)
         wp->uploadState = UPLOAD_CONTENT_DATA;
         wp->uploadState = UPLOAD_CONTENT_DATA;
         return;
         return;
     }
     }
-    printf( "Header line: %s", line);
+    //printf( "Header line: %s", line);
 
 
     headerTok = line;
     headerTok = line;
     stok(line, ": ", &rest);
     stok(line, ": ", &rest);
@@ -318,7 +318,7 @@ static int writeToFile(Webs *wp, char *data, ssize len)
             return -1;
             return -1;
         }
         }
         file->size += len;
         file->size += len;
-        printf( "uploadFilter: Wrote %d bytes to %s", len, wp->uploadTmp);
+        //printf( "uploadFilter: Wrote %d bytes to %s", len, wp->uploadTmp);
     }
     }
     return 0;
     return 0;
 }
 }
@@ -345,7 +345,7 @@ static bool processContentData(Webs *wp)
         return 0;
         return 0;
     }
     }
     if ((bp = getBoundary(wp, content->servp, size)) == 0) {
     if ((bp = getBoundary(wp, content->servp, size)) == 0) {
-        printf( "uploadFilter: Got boundary filename %x", wp->clientFilename);
+        //printf( "uploadFilter: Got boundary filename %x", wp->clientFilename);
         if (wp->clientFilename) {
         if (wp->clientFilename) {
             /*
             /*
                 No signature found yet. probably more data to come. Must handle split boundaries.
                 No signature found yet. probably more data to come. Must handle split boundaries.
@@ -354,7 +354,6 @@ static bool processContentData(Webs *wp)
             nbytes = ((int) (content->endp - data)) - (wp->boundaryLen - 1);
             nbytes = ((int) (content->endp - data)) - (wp->boundaryLen - 1);
             if (writeToFile(wp, content->servp, nbytes) < 0) {
             if (writeToFile(wp, content->servp, nbytes) < 0) {
                 /* Proceed to handle error */
                 /* Proceed to handle error */
-                printf("write >>>>>>>>>>>>>hander error\n");
                 return 1;
                 return 1;
             }
             }
             websConsumeInput(wp, nbytes);
             websConsumeInput(wp, nbytes);
@@ -389,7 +388,7 @@ static bool processContentData(Webs *wp)
                 Normal string form data variables
                 Normal string form data variables
              */
              */
             data[nbytes] = '\0';
             data[nbytes] = '\0';
-            printf( "uploadFilter: form[%s] = %s", wp->uploadVar, data);
+            //printf( "uploadFilter: form[%s] = %s", wp->uploadVar, data);
             websDecodeUrl(wp->uploadVar, wp->uploadVar, -1);
             websDecodeUrl(wp->uploadVar, wp->uploadVar, -1);
             websDecodeUrl(data, data, -1);
             websDecodeUrl(data, data, -1);
             websSetVar(wp, wp->uploadVar, data);
             websSetVar(wp, wp->uploadVar, data);

+ 6 - 6
app/goahead-3.6.5/src/utils/gopass.c

@@ -53,7 +53,7 @@ int main(int argc, char *argv[])
                 } else {
                 } else {
                     cipher = argv[i];
                     cipher = argv[i];
                     if (!smatch(cipher, "md5") && !smatch(cipher, "blowfish")) {
                     if (!smatch(cipher, "md5") && !smatch(cipher, "blowfish")) {
-                        error("Unknown cipher \"%s\". Use \"md5\" or \"blowfish\".", cipher);
+                        printf("Unknown cipher \"%s\". Use \"md5\" or \"blowfish\".", cipher);
                     }
                     }
                     break;
                     break;
                 }
                 }
@@ -107,7 +107,7 @@ int main(int argc, char *argv[])
             exit(2);
             exit(2);
         }
         }
         if (access(authFile, W_OK) < 0) {
         if (access(authFile, W_OK) < 0) {
-            error("Cannot write to %s", authFile);
+            printf("Cannot write to %s", authFile);
             exit(4);
             exit(4);
         }
         }
     }
     }
@@ -151,7 +151,7 @@ static int writeAuthFile(char *path)
 
 
     tempFile = websTempFile(NULL, "gp");
     tempFile = websTempFile(NULL, "gp");
     if ((fp = fopen(tempFile, "w" FILE_TEXT)) == 0) {
     if ((fp = fopen(tempFile, "w" FILE_TEXT)) == 0) {
-        error("Cannot open %s", tempFile);
+        printf("Cannot open %s", tempFile);
         return -1;
         return -1;
     }
     }
     fprintf(fp, "#\n#   %s - Authorization data\n#\n\n", basename(path));
     fprintf(fp, "#\n#   %s - Authorization data\n#\n\n", basename(path));
@@ -179,7 +179,7 @@ static int writeAuthFile(char *path)
     fclose(fp);
     fclose(fp);
     unlink(path);
     unlink(path);
     if (rename(tempFile, path) < 0) {
     if (rename(tempFile, path) < 0) {
-        error("Cannot create new %s", path);
+        printf("Cannot create new %s", path);
         return -1;
         return -1;
     }
     }
     return 0;
     return 0;
@@ -195,7 +195,7 @@ static char *getPassword()
     if (smatch(password, confirm)) {
     if (smatch(password, confirm)) {
         return password;
         return password;
     }
     }
-    error("Password not verified");
+    printf("Password not verified");
     return 0;
     return 0;
 }
 }
 
 
@@ -257,7 +257,7 @@ static char *getpass(char *prompt)
 
 
 static void printUsage()
 static void printUsage()
 {
 {
-    error("usage: gopass [--cipher cipher] [--file path] [--password password] realm user roles...\n"
+    printf("usage: gopass [--cipher cipher] [--file path] [--password password] realm user roles...\n"
         "Options:\n"
         "Options:\n"
         "    --cipher md5|blowfish Select the encryption cipher. Defaults to md5\n"
         "    --cipher md5|blowfish Select the encryption cipher. Defaults to md5\n"
         "    --file filename       Modify the password file\n"
         "    --file filename       Modify the password file\n"

+ 185 - 22
app/goahead-3.6.5/src/web_interface/src/config.c

@@ -47,13 +47,15 @@ void restoreFactorySettings(Webs *wp){
     {
     {
         wRet = IPMC_ResetBMC(&UDSSession, target_addr,DEFAULT_TIMEOUT);
         wRet = IPMC_ResetBMC(&UDSSession, target_addr,DEFAULT_TIMEOUT);
     }
     }
+    LIBIPMI_CloseSession(&UDSSession );
+
 	if(wRet != 0)
 	if(wRet != 0)
 	{
 	{
 		websError(wp, 404, "Reset BMC fail!");
 		websError(wp, 404, "Reset BMC fail!");
+        return;
 	}
 	}
 
 
-	//Close session
-    LIBIPMI_CloseSession(&UDSSession );
+    
 
 
     cJSON * root =  cJSON_CreateObject();
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
@@ -96,14 +98,15 @@ void web_ResetBMC(Webs *wp){
     {
     {
         wRet = IPMC_ResetBMC(&UDSSession, target_addr, DEFAULT_TIMEOUT);
         wRet = IPMC_ResetBMC(&UDSSession, target_addr, DEFAULT_TIMEOUT);
     }
     }
+    //Close session
+    LIBIPMI_CloseSession(&UDSSession );
+
+
 	if(wRet != 0)
 	if(wRet != 0)
 	{
 	{
 		websError(wp, 404, "Reset BMC fail!");
 		websError(wp, 404, "Reset BMC fail!");
+        return;
 	}
 	}
-
-	//Close session
-    LIBIPMI_CloseSession(&UDSSession );
-
 	
 	
     cJSON * root =  cJSON_CreateObject();
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
@@ -154,7 +157,9 @@ void web_GetLanInfo(Webs *wp){
         wRet = IPMICMD_GetLanInfo(&UDSSession, index, &LanInfo, DEFAULT_TIMEOUT);
         wRet = IPMICMD_GetLanInfo(&UDSSession, index, &LanInfo, DEFAULT_TIMEOUT);
         if(wRet != 0)
         if(wRet != 0)
         {
         {
+            LIBIPMI_CloseSession(&UDSSession );
             websError(wp, 404, "Get Lan Info fail!");
             websError(wp, 404, "Get Lan Info fail!");
+            return;
         }
         }
     }
     }
     else
     else
@@ -223,6 +228,7 @@ void web_SetLanInfo(Webs *wp){
     LanInfo_T   LanInfo;
     LanInfo_T   LanInfo;
     uint8_t index = 0;
     uint8_t index = 0;
     uint8_t target_addr;
     uint8_t target_addr;
+    uint8_t isSave = 0;
     
     
     char *EthName = websGetVar(wp, "eth", NULL);    //eth0
     char *EthName = websGetVar(wp, "eth", NULL);    //eth0
     char *strMode = websGetVar(wp, "mode", NULL);   //static DHCP
     char *strMode = websGetVar(wp, "mode", NULL);   //static DHCP
@@ -233,7 +239,14 @@ void web_SetLanInfo(Webs *wp){
     char *strGw = websGetVar(wp, "defaultgw", NULL);        //192.168.0.1
     char *strGw = websGetVar(wp, "defaultgw", NULL);        //192.168.0.1
     char *strSave = websGetVar(wp, "isSave", NULL);         //0 or 1
     char *strSave = websGetVar(wp, "isSave", NULL);         //0 or 1
 
 
-    int  isSave = atoi(strSave);
+    if( strcmp(strSave, "true") == 0)
+    {
+        isSave = 1;
+    }
+    else
+    {
+        isSave = 0;
+    }
 
 
     if(strlen(EthName) > 20)
     if(strlen(EthName) > 20)
     {
     {
@@ -281,12 +294,6 @@ void web_SetLanInfo(Webs *wp){
         LanInfo.MACAddr[3] = mac2hex(strMac, 3);
         LanInfo.MACAddr[3] = mac2hex(strMac, 3);
         LanInfo.MACAddr[4] = mac2hex(strMac, 4);
         LanInfo.MACAddr[4] = mac2hex(strMac, 4);
         LanInfo.MACAddr[5] = mac2hex(strMac, 5);
         LanInfo.MACAddr[5] = mac2hex(strMac, 5);
-
-        //isSave 只能是0和1这两个值。
-        if(isSave != 1)
-        {
-            isSave = 0;
-        }
         
         
         //Create session
         //Create session
         LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
         LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
@@ -294,7 +301,9 @@ void web_SetLanInfo(Webs *wp){
         wRet = IPMICMD_SetLanInfo(&UDSSession, index, isSave, &LanInfo, DEFAULT_TIMEOUT);
         wRet = IPMICMD_SetLanInfo(&UDSSession, index, isSave, &LanInfo, DEFAULT_TIMEOUT);
         if(wRet != 0)
         if(wRet != 0)
         {
         {
+            LIBIPMI_CloseSession(&UDSSession );
             websError(wp, 404, "Reset BMC fail!");
             websError(wp, 404, "Reset BMC fail!");
+            return;
         }
         }
 
 
         //Close session
         //Close session
@@ -329,15 +338,77 @@ void web_GetRunTime(Webs *wp){
     uint16_t    wRet = LIBIPMI_E_SUCCESS;
     uint16_t    wRet = LIBIPMI_E_SUCCESS;
     IPMI20_UDS_SESSION_T    UDSSession;
     IPMI20_UDS_SESSION_T    UDSSession;
     uint8_t target_addr;
     uint8_t target_addr;
-    uint32_t    TotalRunTime = 1000;    //模块总运行时间,单位: 分钟
-    uint32_t    CurRunTime = 50;        //模块本次运行时间,单位: 分钟
+    uint8_t min_per_cnt = 0;
+    uint32_t counts = 0;
+    uint32_t totalhours = 0;
+    uint32_t hours = 0, days = 0, minutes = 0;
+    uint32_t totalsMinutes = 0;
+    char    totalRunTimeStr[50]={0};
+    char    curRunTimeStr[50] = {0};
+
+    LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
+
+    //获取总运行时间
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+        wRet = IPMI_GetPOH( &UDSSession, &min_per_cnt, &counts,DEFAULT_TIMEOUT);
+        if(wRet != 0)
+        {
+            LIBIPMI_CloseSession(&UDSSession );
+            websError(wp, 404, "web_GetRunTime failed!");
+            return;
+        }        
+    }
+    else
+    {
+        wRet = IPMC_GetPOH( &UDSSession, target_addr, &min_per_cnt, &counts, DEFAULT_TIMEOUT);
+        if(wRet != 0)
+        {
+            LIBIPMI_CloseSession(&UDSSession );
+            websError(wp, 404, "web_GetRunTime failed!");
+            return;
+        }
+    }
+    totalhours = counts*min_per_cnt/60;  //hours
+    days = totalhours/24;
+    hours = totalhours%24;
+    sprintf(totalRunTimeStr, "%d days, %d hours", days, hours);
+
+    //获取当前运行时间
+    if(target_addr == 0x20)
+    {
+        wRet = IPMI_GetCurRunTime( &UDSSession, &totalsMinutes, DEFAULT_TIMEOUT);
+        if(wRet != 0)
+        {
+            LIBIPMI_CloseSession(&UDSSession );
+            websError(wp, 404, "web_GetRunTime failed!");
+            return;
+        }        
+    }
+    else
+    {
+        wRet = IPMC_GetCurRunTime( &UDSSession, target_addr, &totalsMinutes, DEFAULT_TIMEOUT);
+        if(wRet != 0)
+        {
+            LIBIPMI_CloseSession(&UDSSession );
+            websError(wp, 404, "web_GetRunTime failed!");
+            return;
+        }
+    }
+    days = totalsMinutes/(24*60);
+    hours = (totalsMinutes%(24*60))/(60);
+    minutes = totalsMinutes%60;
+    sprintf(curRunTimeStr, "%d days, %d hours, %d minutes", days, hours, minutes);
+
+    LIBIPMI_CloseSession(&UDSSession );
    
    
     
     
     cJSON * root =  cJSON_CreateObject();
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON_AddItemToObject(root, "data", data);//根节点下添加
     cJSON_AddItemToObject(root, "data", data);//根节点下添加
-    cJSON_AddStringToObject(data, "TotalRunTime", "129 hour 40 min");
-    cJSON_AddStringToObject(data, "CurRunTime", "1 hour 3 min");
+    cJSON_AddStringToObject(data, "TotalRunTime", totalRunTimeStr);
+    cJSON_AddStringToObject(data, "CurRunTime", curRunTimeStr);
     cJSON_AddStringToObject(root, "msg", "");
     cJSON_AddStringToObject(root, "msg", "");
     cJSON_AddNumberToObject(root, "code", 200);
     cJSON_AddNumberToObject(root, "code", 200);
 
 
@@ -346,7 +417,7 @@ void web_GetRunTime(Webs *wp){
     websSetStatus(wp, 200);
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp); 
     websWriteEndHeaders(wp); 
-    websWrite(wp,"%s", pStr);
+    websWrite(wp, pStr);
     websFlush(wp, 0);
     websFlush(wp, 0);
     websDone(wp);
     websDone(wp);
     //printf("cJSON:%s\n", pStr);
     //printf("cJSON:%s\n", pStr);
@@ -364,30 +435,61 @@ void web_SetModIdentifyOn(Webs *wp){
     char *strTime = websGetVar(wp, "timeSelect", NULL);    //
     char *strTime = websGetVar(wp, "timeSelect", NULL);    //
     int timeSelect = atoi(strTime);
     int timeSelect = atoi(strTime);
     uint8_t identifySec = 0;
     uint8_t identifySec = 0;
+    uint8_t ForceIdentify = 0;
 
 
     switch(timeSelect)
     switch(timeSelect)
     {
     {
         case 0: //15s
         case 0: //15s
             identifySec = 15;
             identifySec = 15;
+            ForceIdentify = 0;
             break;
             break;
         case 1: //30s
         case 1: //30s
             identifySec = 30;
             identifySec = 30;
+            ForceIdentify = 0;
             break;
             break;
         case 2: //60s
         case 2: //60s
             identifySec = 60;
             identifySec = 60;
+            ForceIdentify = 0;
             break;
             break;
         case 3: //120s
         case 3: //120s
             identifySec = 120;
             identifySec = 120;
+            ForceIdentify = 0;
             break;
             break;
         case 4: //forever
         case 4: //forever
             identifySec = 0xff;
             identifySec = 0xff;
+            ForceIdentify = 1;
             break;
             break;
         default:
         default:
             identifySec = 15;
             identifySec = 15;
+            ForceIdentify = 0;
             break;
             break;
     }
     }
 
 
     printf("---> identify on Sec = %d\n", identifySec);
     printf("---> identify on Sec = %d\n", identifySec);
+   
+    //Create session
+    LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
+
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+        wRet = IPMICMD_ChassisIdentify(&UDSSession, identifySec, ForceIdentify, DEFAULT_TIMEOUT);
+        if(wRet != 0)
+        {
+            printf("chassis identify failed! interval %d, force %d!\n", identifySec, ForceIdentify);
+        }
+    }
+    else
+    {
+        wRet = IPMC_ChassisIdentify(&UDSSession, target_addr, identifySec, ForceIdentify, DEFAULT_TIMEOUT);
+        if(wRet != 0)
+        {
+            printf("chassis identify failed! interval %d, force %d!\n", identifySec, ForceIdentify);
+        }
+    }
+
+    LIBIPMI_CloseSession(&UDSSession );
+    
     cJSON * root =  cJSON_CreateObject();
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON_AddItemToObject(root, "data", data);//根节点下添加
     cJSON_AddItemToObject(root, "data", data);//根节点下添加
@@ -399,7 +501,7 @@ void web_SetModIdentifyOn(Webs *wp){
     websSetStatus(wp, 200);
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp); 
     websWriteEndHeaders(wp); 
-    websWrite(wp,"%s", pStr);
+    websWrite(wp, pStr);
     websFlush(wp, 0);
     websFlush(wp, 0);
     websDone(wp);
     websDone(wp);
     //printf("cJSON:%s\n", pStr);
     //printf("cJSON:%s\n", pStr);
@@ -415,9 +517,33 @@ void web_SetModIdentifyOff(Webs *wp){
     IPMI20_UDS_SESSION_T    UDSSession;
     IPMI20_UDS_SESSION_T    UDSSession;
     uint8_t target_addr;
     uint8_t target_addr;
     uint8_t identifySec = 0;
     uint8_t identifySec = 0;
+    uint8_t ForceIdentify = 0;
 
 
 
 
     printf("---> identify off Sec = %d\n", identifySec);
     printf("---> identify off Sec = %d\n", identifySec);
+    //Create session
+    LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
+
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+        wRet = IPMICMD_ChassisIdentify(&UDSSession, identifySec, ForceIdentify, DEFAULT_TIMEOUT);
+        if(wRet != 0)
+        {
+            printf("chassis identify failed! interval %d, force %d!\n", identifySec, ForceIdentify);
+        }
+    }
+    else
+    {
+        wRet = IPMC_ChassisIdentify(&UDSSession, target_addr, identifySec, ForceIdentify, DEFAULT_TIMEOUT);
+        if(wRet != 0)
+        {
+            printf("chassis identify failed! interval %d, force %d!\n", identifySec, ForceIdentify);
+        }
+    }
+
+    LIBIPMI_CloseSession(&UDSSession );
+
     cJSON * root =  cJSON_CreateObject();
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON_AddItemToObject(root, "data", data);//根节点下添加
     cJSON_AddItemToObject(root, "data", data);//根节点下添加
@@ -429,7 +555,7 @@ void web_SetModIdentifyOff(Webs *wp){
     websSetStatus(wp, 200);
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp); 
     websWriteEndHeaders(wp); 
-    websWrite(wp,"%s", pStr);
+    websWrite(wp, pStr);
     websFlush(wp, 0);
     websFlush(wp, 0);
     websDone(wp);
     websDone(wp);
     //printf("cJSON:%s\n", pStr);
     //printf("cJSON:%s\n", pStr);
@@ -444,7 +570,27 @@ void web_SaveConfig(Webs *wp){
     uint16_t    wRet = LIBIPMI_E_SUCCESS;
     uint16_t    wRet = LIBIPMI_E_SUCCESS;
     IPMI20_UDS_SESSION_T    UDSSession;
     IPMI20_UDS_SESSION_T    UDSSession;
     uint8_t target_addr;
     uint8_t target_addr;
-    uint8_t identifySec = 0;
+
+    
+
+    LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+        wRet = IPMI_SaveConfig(&UDSSession, DEFAULT_TIMEOUT);
+    }
+    else
+    {
+        wRet = IPMC_SaveConfig(&UDSSession, target_addr, DEFAULT_TIMEOUT);
+    }
+    LIBIPMI_CloseSession(&UDSSession );
+    
+    if(wRet != 0)
+    {
+        websError(wp, 404, "Save config failed!");
+        return;
+    }
+
 
 
     cJSON * root =  cJSON_CreateObject();
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
@@ -472,7 +618,24 @@ void web_RestoreConfig(Webs *wp){
     uint16_t    wRet = LIBIPMI_E_SUCCESS;
     uint16_t    wRet = LIBIPMI_E_SUCCESS;
     IPMI20_UDS_SESSION_T    UDSSession;
     IPMI20_UDS_SESSION_T    UDSSession;
     uint8_t target_addr;
     uint8_t target_addr;
-    uint8_t identifySec = 0;
+
+    LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
+    target_addr = gIPMBAddr[wp->index];
+    if(target_addr == 0x20)
+    {
+        wRet = IPMI_RestoreConfig(&UDSSession, DEFAULT_TIMEOUT);
+    }
+    else
+    {
+        wRet = IPMC_RestoreConfig(&UDSSession, target_addr, DEFAULT_TIMEOUT);
+    }
+    LIBIPMI_CloseSession(&UDSSession );
+    
+    if(wRet != 0)
+    {
+        websError(wp, 404, "Save config failed!");
+        return;
+    }
 
 
     cJSON * root =  cJSON_CreateObject();
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();

+ 14 - 10
app/goahead-3.6.5/src/web_interface/src/fw_update.c

@@ -27,7 +27,6 @@ static uint8_t target_addr;
 */
 */
 void prepareDevice(Webs *wp)
 void prepareDevice(Webs *wp)
 {
 {
-//    wp->index = TEST_INDEX;
     target_addr = gIPMBAddr[wp->index];
     target_addr = gIPMBAddr[wp->index];
     if(target_addr == 0x20)
     if(target_addr == 0x20)
     {
     {
@@ -79,25 +78,30 @@ void uploadFirmware(Webs *wp)
     char            *upfile;
     char            *upfile;
 
 
 //    wp->index = TEST_INDEX;
 //    wp->index = TEST_INDEX;
+    printf("index %d, target_addr %#x\n", wp->index, target_addr);
     target_addr = gIPMBAddr[wp->index];
     target_addr = gIPMBAddr[wp->index];
-    if(target_addr == 0x20)
+    //if(target_addr == 0x20)
     {
     {
         if (scaselessmatch(wp->method, "POST")) {
         if (scaselessmatch(wp->method, "POST")) {
             for (s = hashFirst(wp->files); s; s = hashNext(wp->files, s)) {
             for (s = hashFirst(wp->files); s; s = hashNext(wp->files, s)) {
                 up = s->content.value.symbol;
                 up = s->content.value.symbol;
                 upfile = sfmt("%s/tmp/%s", websGetDocuments(), "tmp.uImage");
                 upfile = sfmt("%s/tmp/%s", websGetDocuments(), "tmp.uImage");
                 if (rename(up->filename, upfile) < 0) {
                 if (rename(up->filename, upfile) < 0) {
-                    error("Cannot rename uploaded file: %s to %s, errno %d", up->filename, upfile, errno);
+                    printf("Cannot rename uploaded file: %s to %s, errno %d", up->filename, upfile, errno);
+                }
+                else
+                {
+                    printf("Rename uploaded file: %s to %s", up->filename, upfile);  
                 }
                 }
                 wfree(upfile);
                 wfree(upfile);
             }
             }
-          
         }
         }
     }
     }
-    else
-    {
-        //Do nothing
-    }
+    // else
+    // {
+    //     //Do nothing
+    // }
+
 
 
     
     
     cJSON * root =  cJSON_CreateObject();
     cJSON * root =  cJSON_CreateObject();
@@ -243,14 +247,14 @@ void getEraseStatus(Webs *wp)
         if(NULL == fp)
         if(NULL == fp)
         {
         {
             printf("Open Erase.log failed!\n");
             printf("Open Erase.log failed!\n");
-            websError(wp, 200, "Open Erase.log failed!");
+            websError(wp, HTTP_CODE_NO_CONTENT, "Open Erase.log failed!");
             return;
             return;
         }
         }
 
 
         if(NULL == fgets(EraseStr, 13, fp))
         if(NULL == fgets(EraseStr, 13, fp))
         {
         {
             printf("Read Erase.log failed!\n");
             printf("Read Erase.log failed!\n");
-            websError(wp, 200, "Read Erase.log failed!");
+            websError(wp, HTTP_CODE_NO_CONTENT, "Read Erase.log failed!");
             fclose(fp);
             fclose(fp);
             return;
             return;
         }
         }

+ 58 - 61
app/goahead-3.6.5/src/web_interface/src/sel.c

@@ -129,22 +129,9 @@ void GetAllSELEntriesSorted(Webs *wp)
         if(nEntries == 0)
         if(nEntries == 0)
         {
         {
             cJSON_AddItemToObject(root, "data", pJsonArry);
             cJSON_AddItemToObject(root, "data", pJsonArry);
-
-            // char *pStr;
-            // pStr = cJSON_PrintUnformatted(root);
-            // websSetStatus(wp, 200);
-            // websWriteHeaders(wp, -1, 0);
-            // websWriteEndHeaders(wp); 
-            // websWrite(wp, pStr);
             websWrite(wp, "]}");
             websWrite(wp, "]}");
             websFlush(wp, 0);
             websFlush(wp, 0);
             websDone(wp);
             websDone(wp);
-            
-            // if(root)
-            //     cJSON_Delete(root);
-            // if(pStr)
-            //     wfree(pStr);
-
             return;
             return;
         }
         }
 
 
@@ -171,10 +158,7 @@ void GetAllSELEntriesSorted(Webs *wp)
             RecID = 0;  //first record
             RecID = 0;  //first record
             for(i=0;i<nEntries;i++)
             for(i=0;i<nEntries;i++)
             {
             {
-                if(i!=0)
-                {
-                    websWrite(wp, ",");
-                }
+                
                 //获取日志
                 //获取日志
                 GetSelReq.ReservationID = ReserveID;
                 GetSelReq.ReservationID = ReserveID;
                 GetSelReq.RecID = RecID;
                 GetSelReq.RecID = RecID;
@@ -205,62 +189,75 @@ void GetAllSELEntriesSorted(Webs *wp)
                 // cJSON_AddNumberToObject(pJsonsub, "D10", SELEventData.EvtData2);     //EventData2    -> D10
                 // cJSON_AddNumberToObject(pJsonsub, "D10", SELEventData.EvtData2);     //EventData2    -> D10
                 // cJSON_AddNumberToObject(pJsonsub, "D11", SELEventData.EvtData3);     //EventData3    -> D11
                 // cJSON_AddNumberToObject(pJsonsub, "D11", SELEventData.EvtData3);     //EventData3    -> D11
 
 
-                websWrite(wp, "{\"D1\":%d,\"D2\":%d,\"D3\":%d,\"D4\":%d,\"D5\":%d,\"D6\":%d,\"D7\":%d,\"D8\":%d,\"D9\":%d,\"D10\":%d,\"D11\":%d,",
-                    SELEventData.hdr.ID, SELEventData.hdr.Type, SELEventData.hdr.TimeStamp, SELEventData.GenID[0],
-                    SELEventData.GenID[1], SELEventData.EvMRev, SELEventData.SensorType, SELEventData.EvtDirType,
-                    SELEventData.EvtData1, SELEventData.EvtData2, SELEventData.EvtData3);
-                            
-                //获取传感器名称
-                //printf("sensor number %d\n", SELEventData.SensorNum);
-                if((SELEventData.SensorNum != 0xff) && (SELEventData.hdr.Type == 0x02))
+                if(SELEventData.hdr.Type == 0x02)
                 {
                 {
-                    found_flag = 0;
-                    for(i=0;i<MAX_SENSOR_NUMBERS;i++)   //先从之前的缓存里查找传感器名称
+                    if(i!=0)
                     {
                     {
-                        if(senNumNameTab[i].sensor_number == 0xff)  //再往后没有内容了。
-                            break;
-
-                        if(senNumNameTab[i].sensor_number == SELEventData.SensorNum)
-                        {                                                
-                            //cJSON_AddStringToObject(pJsonsub, "D12", senNumNameTab[i].sensor_name);  //SensorName -> D12
-                            websWrite(wp, "\"D12\":\"%s\"}", senNumNameTab[i].sensor_name);
-                            found_flag = 1;
-                            break;
-                        }
+                        websWrite(wp, ",");
                     }
                     }
-
-                    if(found_flag == 0) //在缓存里没有找到
+                    websWrite(wp, "{\"D1\":%d,\"D2\":%d,\"D3\":%d,\"D4\":%d,\"D5\":%d,\"D6\":%d,\"D7\":%d,\"D8\":%d,\"D9\":%d,\"D10\":%d,\"D11\":%d,",
+                        SELEventData.hdr.ID, SELEventData.hdr.Type, SELEventData.hdr.TimeStamp, 
+                        SELEventData.body.sysEventRecord.GenID[0],  SELEventData.body.sysEventRecord.GenID[1], 
+                        SELEventData.body.sysEventRecord.EvMRev, SELEventData.body.sysEventRecord.SensorType, 
+                        SELEventData.body.sysEventRecord.EvtDirType,SELEventData.body.sysEventRecord.EvtData1, 
+                        SELEventData.body.sysEventRecord.EvtData2, SELEventData.body.sysEventRecord.EvtData3);
+                                
+                    //获取传感器名称
+                    //printf("sensor number %d\n", SELEventData.SensorNum);
+                    if(SELEventData.body.sysEventRecord.SensorNum != 0xff)
                     {
                     {
-                        if(target_addr == 0x20)
+                        found_flag = 0;
+                        for(i=0;i<MAX_SENSOR_NUMBERS;i++)   //先从之前的缓存里查找传感器名称
                         {
                         {
-                            wRet = IPMI_GetSensorName(&UDSSession, SELEventData.SensorNum, sensorName, DEFAULT_TIMEOUT);
-                            //printf("---> get sensor name: %s\n", sensorName);
-                        }
-                        else
-                        {
-                            wRet = IPMC_GetSensorName(&UDSSession, target_addr,SELEventData.SensorNum, sensorName, DEFAULT_TIMEOUT);
+                            if(senNumNameTab[i].sensor_number == 0xff)  //再往后没有内容了。
+                                break;
+
+                            if(senNumNameTab[i].sensor_number == SELEventData.body.sysEventRecord.SensorNum)
+                            {                                                
+                                //cJSON_AddStringToObject(pJsonsub, "D12", senNumNameTab[i].sensor_name);  //SensorName -> D12
+                                websWrite(wp, "\"D12\":\"%s\"}", senNumNameTab[i].sensor_name);
+                                found_flag = 1;
+                                break;
+                            }
                         }
                         }
-                        //cJSON_AddStringToObject(pJsonsub, "D12", senNumNameTab[i].sensor_name);     //SensorName->D12
-                        websWrite(wp, "\"D12\":\"%s\"}", senNumNameTab[i].sensor_name);
-                        if(wRet == 0)
+
+                        if(found_flag == 0) //在缓存里没有找到
                         {
                         {
-                            //将得到的传感器名称保存到缓存中
-                            for(i=0;i<MAX_SENSOR_NUMBERS;i++)
+                            if(target_addr == 0x20)
+                            {
+                                wRet = IPMI_GetSensorName(&UDSSession, SELEventData.body.sysEventRecord.SensorNum, sensorName, DEFAULT_TIMEOUT);
+                                //printf("---> get sensor name: %s\n", sensorName);
+                            }
+                            else
+                            {
+                                wRet = IPMC_GetSensorName(&UDSSession, target_addr,SELEventData.body.sysEventRecord.SensorNum, sensorName, DEFAULT_TIMEOUT);
+                            }
+                            //cJSON_AddStringToObject(pJsonsub, "D12", senNumNameTab[i].sensor_name);     //SensorName->D12
+                            websWrite(wp, "\"D12\":\"%s\"}", senNumNameTab[i].sensor_name);
+                            if(wRet == 0)
                             {
                             {
-                                if(senNumNameTab[i].sensor_number == 0xff)
+                                //将得到的传感器名称保存到缓存中
+                                for(i=0;i<MAX_SENSOR_NUMBERS;i++)
                                 {
                                 {
-                                    senNumNameTab[i].sensor_number = SELEventData.SensorNum;
-                                    strcpy(senNumNameTab[i].sensor_name, sensorName);                                
-                                    break;
+                                    if(senNumNameTab[i].sensor_number == 0xff)
+                                    {
+                                        senNumNameTab[i].sensor_number = SELEventData.body.sysEventRecord.SensorNum;
+                                        strcpy(senNumNameTab[i].sensor_name, sensorName);                                
+                                        break;
+                                    }
                                 }
                                 }
-                            }
-                        }    
-                    }                
+                            }    
+                        }                
+                    }
+                    else
+                    {
+                        //cJSON_AddStringToObject(pJsonsub, "D12", "--"); //SensorName -> D12
+                        websWrite(wp, "\"D12\":\"--\"}");
+                    }
                 }
                 }
-                else
+                else if(SELEventData.hdr.Type == 0xC0)
                 {
                 {
-                    //cJSON_AddStringToObject(pJsonsub, "D12", "--"); //SensorName -> D12
-                    websWrite(wp, "\"D12\":\"%s\"}", senNumNameTab[i].sensor_name);
+                    //TODO:
                 }
                 }
 
 
                 if(RecID == 0xffff) //last record
                 if(RecID == 0xffff) //last record

+ 115 - 132
app/goahead-3.6.5/src/web_interface/src/server_health.c

@@ -33,9 +33,7 @@ void setThreshold(Webs *wp){
     int   SensorNumber = atoi(strSensorNumber);
     int   SensorNumber = atoi(strSensorNumber);
     uint8_t target_addr;
     uint8_t target_addr;
 
 
-    // printf(" %s, %s %s %s, %s %s %s = %d, %f %f %f %f %f %f \n", strSensorNumber, strUNC, strUC, strUNR, strLNC, strLC, 
-    // 	strLNR,  SensorNumber, UNC, UC, UNR, LNC, LC, LNR );
-
+    
     uint8_t  *data_buffer = (uint8_t*)walloc(255);
     uint8_t  *data_buffer = (uint8_t*)walloc(255);
     FullSensorRec_T	*sdr_record = (FullSensorRec_T*) data_buffer;
     FullSensorRec_T	*sdr_record = (FullSensorRec_T*) data_buffer;
     uint32_t data_buff_size = 255;//sizeof(data_buffer);
     uint32_t data_buff_size = 255;//sizeof(data_buffer);
@@ -84,7 +82,12 @@ void setThreshold(Webs *wp){
     pReqSetSensorThreshold->LowerNonCritical = sdr_convert_sensor_value_to_raw(sdr_record, LNC);
     pReqSetSensorThreshold->LowerNonCritical = sdr_convert_sensor_value_to_raw(sdr_record, LNC);
     pReqSetSensorThreshold->LowerCritical = sdr_convert_sensor_value_to_raw(sdr_record, LC);
     pReqSetSensorThreshold->LowerCritical = sdr_convert_sensor_value_to_raw(sdr_record, LC);
     pReqSetSensorThreshold->LowerNonRecoverable = sdr_convert_sensor_value_to_raw(sdr_record, LNR);
     pReqSetSensorThreshold->LowerNonRecoverable = sdr_convert_sensor_value_to_raw(sdr_record, LNR);
-    
+    printf("SensorNumber\t| UNC\t| UC\t| UNR\t| LNC\t| LC\t| LNR\n");
+    printf("    %s      \t| %s\t| %s\t| %s\t| %s\t| %s\t| %s\n", strSensorNumber, strUNC, strUC, strUNR, strLNC, strLC, strLNR );
+    printf("    %d      \t|%0.3f\t|%0.3f\t|%0.3f\t|%0.3f\t|%0.3f\t|%0.3f \n", SensorNumber, UNC, UC, UNR, LNC, LC, LNR );
+    printf("    %d      \t| %02x \t| %02x\t| %02x \t| %02x \t| %02x\t| %02x \n", SensorNumber, 
+        pReqSetSensorThreshold->UpperNonCritical,pReqSetSensorThreshold->UpperCritical,pReqSetSensorThreshold->UpperNonRecoverable,
+        pReqSetSensorThreshold->LowerNonCritical,pReqSetSensorThreshold->LowerCritical,pReqSetSensorThreshold->LowerNonRecoverable);
     if(target_addr == 0x20)
     if(target_addr == 0x20)
     {
     {
         wRet = IPMICMD_SetSensorThreshold( &UDSSession, pReqSetSensorThreshold, pResSetSensorThreshold, DEFAULT_TIMEOUT);
         wRet = IPMICMD_SetSensorThreshold( &UDSSession, pReqSetSensorThreshold, pResSetSensorThreshold, DEFAULT_TIMEOUT);
@@ -135,11 +138,11 @@ void webGetSensorHistory(Webs *wp)
     IPMI20_UDS_SESSION_T    UDSSession;
     IPMI20_UDS_SESSION_T    UDSSession;
     int         i = 0,j=0;
     int         i = 0,j=0;
     int         wRet = 0;
     int         wRet = 0;
-    //sensor_history_st *pSensorHistory = (sensor_history_st *)walloc(sizeof(sensor_history_st));
-//    char        tmpBuf[10];
-//    char        *historyBuf = walloc(500);
+    sensor_history_st *pSensorHistory = (sensor_history_st *)walloc(sizeof(sensor_history_st));
+    char        tmpBuf[10];
+    char        *historyBuf = walloc(500);
     uint8_t     target_addr;
     uint8_t     target_addr;
- //   FullSensorRec_T *sdr_record = (FullSensorRec_T*) walloc(100);
+    FullSensorRec_T *sdr_record = (FullSensorRec_T*) walloc(100);
     uint32_t     sdr_buff_size = 0;
     uint32_t     sdr_buff_size = 0;
     float       tmpValue;
     float       tmpValue;
     uint32_t    dwResLen;
     uint32_t    dwResLen;
@@ -147,142 +150,122 @@ void webGetSensorHistory(Webs *wp)
     char *strSensorNumber = websGetVar(wp, "SensorNumber", NULL);
     char *strSensorNumber = websGetVar(wp, "SensorNumber", NULL);
     int   SensorNumber = atoi(strSensorNumber);
     int   SensorNumber = atoi(strSensorNumber);
 
 
-    //memset(pSensorHistory->sensor_history, 0, 480);
+    memset(pSensorHistory->sensor_history, 0, HISTORY_DATA_SIZE);
     
     
-    // //Create session
-    // LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
-
-    // //wp->index = 1;
-    // target_addr = gIPMBAddr[wp->index];
-    // //get factors
-    // if(target_addr == 0x20)
-    // { 
-    //     wRet = LIBIPMI_HL_GetSpecificSDR( &UDSSession, (uint8_t*)sdr_record, &sdr_buff_size, SensorNumber, DEFAULT_TIMEOUT );
-    // }
-    // else
-    // {
-    //     wRet = IPMC_GetSpecificSDR(&UDSSession, target_addr, (uint8_t*)sdr_record, &sdr_buff_size, SensorNumber, DEFAULT_TIMEOUT);   
-    // }
-
-    // if(wRet != 0)
-    // {
-    //     websError(wp, 404, "GetSpecificSDR error!");
-    //     wfree(pSensorHistory);
-    //     wfree(historyBuf);
-    //     wfree(sdr_record);
-    //     return;
-    // }
-
-    // pSensorHistory->sensor_num = SensorNumber;
-    // strcpy(pSensorHistory->sensor_name, sdr_record->IDStr);
+    //Create session
+    LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
 
 
+    target_addr = gIPMBAddr[wp->index];
+    //get factors
+    if(target_addr == 0x20)
+    { 
+        wRet = LIBIPMI_HL_GetSpecificSDR( &UDSSession, (uint8_t*)sdr_record, &sdr_buff_size, SensorNumber, DEFAULT_TIMEOUT );
+    }
+    else
+    {
+        wRet = IPMC_GetSpecificSDR(&UDSSession, target_addr, (uint8_t*)sdr_record, &sdr_buff_size, SensorNumber, DEFAULT_TIMEOUT);   
+    }
 
 
+    if(wRet != 0)
+    {
+        websError(wp, 404, "GetSpecificSDR error!");
+        wfree(pSensorHistory);
+        wfree(historyBuf);
+        wfree(sdr_record);
+        return;
+    }
 
 
+    pSensorHistory->sensor_num = SensorNumber;
+    strcpy(pSensorHistory->sensor_name, sdr_record->IDStr);
     
     
-    // if(target_addr == 0x20)
-    // {
-    //     wRet = IPMI_GetSensorHistory(&UDSSession, SensorNumber, (uint8_t*)historyBuf, DEFAULT_TIMEOUT);
-    //     if(wRet != 0)
-    //     {
-    //         websError(wp, 404, "IPMI_GetSensorHistory error!");
-    //         wfree(pSensorHistory);
-    //         wfree(historyBuf);
-    //         wfree(sdr_record);
-    //         return;
-    //     }
-    //     for(i=0;i<MAX_HISTORY_LEN;i++)
-    //     {
-    //         ipmi_convert_reading( (uint8_t*)sdr_record, (uint8_t)historyBuf[3+i], &tmpValue );   //remove ccode, returnlen_lsb/msb
-    //         pSensorHistory->sensor_history[i] = tmpValue;
-    //     }
-    // }
-    // else
-    // {
-    //     //获取前240字节
-    //     wRet = IPMC_GetSensorHistory(&UDSSession, target_addr, SensorNumber, 0, 240, (uint8_t*)historyBuf, DEFAULT_TIMEOUT);
-    //     if(wRet != 0)
-    //     {
-    //         websError(wp, 404, "IPMC_GetSensorHistory error!");
-    //         wfree(pSensorHistory);
-    //         wfree(historyBuf);
-    //         wfree(sdr_record);
-    //         return;
-    //     }
-    //     for(i=0;i<240;i++)
-    //     {
-    //         ipmi_convert_reading( (uint8_t*)sdr_record, historyBuf[9+i], &tmpValue );   //remove ipmb header and ccode,returnlen_lsb/msb
-    //         pSensorHistory->sensor_history[i] = tmpValue;
-    //     }
-    //     //获取后240字节
-    //     wRet = IPMC_GetSensorHistory(&UDSSession, target_addr, SensorNumber, 240, 240, (uint8_t*)historyBuf, DEFAULT_TIMEOUT);
-    //     if(wRet != 0)
-    //     {
-    //         websError(wp, 404, "IPMC_GetSensorHistory error!");
-    //         wfree(pSensorHistory);
-    //         wfree(historyBuf);
-    //         wfree(sdr_record);
-    //         return;
-    //     }
-    //     for(i=0;i<240;i++)
-    //     {
-    //         ipmi_convert_reading( (uint8_t*)sdr_record, historyBuf[9+i], &tmpValue );   //remove ipmb header and ccode,returnlen_lsb/msb
-    //         pSensorHistory->sensor_history[240+i] = tmpValue;
-    //     }
-    // }
+    if(target_addr == 0x20)
+    {
+        wRet = IPMI_GetSensorHistory(&UDSSession, SensorNumber, (uint8_t*)historyBuf, DEFAULT_TIMEOUT);
+        if(wRet != 0)
+        {
+            websError(wp, 404, "IPMI_GetSensorHistory error!");
+            wfree(pSensorHistory);
+            wfree(historyBuf);
+            wfree(sdr_record);
+            return;
+        }
+        for(i=0;i<HISTORY_DATA_SIZE;i++)
+        {
+            ipmi_convert_reading( (uint8_t*)sdr_record, (uint8_t)historyBuf[3+i], &tmpValue );   //remove ccode, returnlen_lsb/msb
+            pSensorHistory->sensor_history[i] = tmpValue;
+        }
+    }
+    else
+    {
+        //获取前240字节
+        wRet = IPMC_GetSensorHistory(&UDSSession, target_addr, SensorNumber, 0, 240, (uint8_t*)historyBuf, DEFAULT_TIMEOUT);
+        if(wRet != 0)
+        {
+            websError(wp, 404, "IPMC_GetSensorHistory error!");
+            wfree(pSensorHistory);
+            wfree(historyBuf);
+            wfree(sdr_record);
+            return;
+        }
+        for(i=0;i<240;i++)
+        {
+            ipmi_convert_reading( (uint8_t*)sdr_record, historyBuf[9+i], &tmpValue );   //remove ipmb header and ccode,returnlen_lsb/msb
+            pSensorHistory->sensor_history[i] = tmpValue;
+        }
+        //获取后240字节
+        wRet = IPMC_GetSensorHistory(&UDSSession, target_addr, SensorNumber, 240, 240, (uint8_t*)historyBuf, DEFAULT_TIMEOUT);
+        if(wRet != 0)
+        {
+            websError(wp, 404, "IPMC_GetSensorHistory error!");
+            wfree(pSensorHistory);
+            wfree(historyBuf);
+            wfree(sdr_record);
+            return;
+        }
+        for(i=0;i<240;i++)
+        {
+            ipmi_convert_reading( (uint8_t*)sdr_record, historyBuf[9+i], &tmpValue );   //remove ipmb header and ccode,returnlen_lsb/msb
+            pSensorHistory->sensor_history[240+i] = tmpValue;
+        }
+    }
     
     
-    // //Close session
-    // LIBIPMI_CloseSession(&UDSSession );
+    //Close session
+    LIBIPMI_CloseSession(&UDSSession );
     
     
-    // websSetStatus(wp, 200);
-    // websWriteHeaders(wp, -1, 0);
-    // websWriteEndHeaders(wp); 
-    // websWrite(wp, "{\"SensorNum\":%d,\"SensorName\":\"%s\",\"history\":\"", SensorNumber, sdr_record->IDStr);
+    websSetStatus(wp, 200);
+    websWriteHeaders(wp, -1, 0);
+    websWriteEndHeaders(wp); 
+    websWrite(wp, "{\"SensorNum\":%d,\"SensorName\":\"%s\",\"history\":\"", SensorNumber, sdr_record->IDStr);
 
 
-    // //char *strBuf = historyBuf;
-    // for(i=0;i<HISTORY_DATA_SIZE;i++)
-    // {
-    //     sprintf(tmpBuf, "%0.2f", pSensorHistory->sensor_history[i]);
-    //     j = 0;
-    //     while(tmpBuf[j] != '\0')
-    //     {
-    //         j++;
-    //         if(j>=10)
-    //             break;
-    //     }
-    //     if(i < HISTORY_DATA_SIZE-1)
-    //         tmpBuf[j] = ',';    //replace '\0' by ','   
-    //     else
-    //         tmpBuf[j] = '"';    //最后一个串结束符用引号替换
-    //     j++;        //point to next empty
-    //     websWrite(wp,"%s",tmpBuf);
-    //     //sprintf(strBuf, "%s", tmpBuf);
-    //     //strBuf += j;
-    // }
-    // websWrite(wp, "}");
-    //strBuf--;
-    //*strBuf = '\0';
+    //char *strBuf = historyBuf;
+    for(i=0;i<HISTORY_DATA_SIZE;i++)
+    {
+        memset(tmpBuf,0, sizeof(tmpBuf));
+        sprintf(tmpBuf, "%0.2f", pSensorHistory->sensor_history[i]);
+        j = 0;
+        while(tmpBuf[j] != '\0')
+        {
+            j++;
+            if(j>=10)
+                break;
+        }
+        if(i < HISTORY_DATA_SIZE-1)
+            tmpBuf[j] = ',';    //replace '\0' by ','   
+        else
+            tmpBuf[j] = '"';    //最后一个串结束符用引号替换
+        websWrite(wp, tmpBuf);
+    }
+    websWrite(wp, "}");
 
 
-    cJSON * root =  cJSON_CreateObject();
-    cJSON_AddNumberToObject(root, "SensorNum", 1);//pSensorHistory->sensor_num);
-    cJSON_AddStringToObject(root, "SensorName", "test");//pSensorHistory->sensor_name);
-    cJSON_AddStringToObject(root, "history", "");//historyBuf);
-    
-    char *pStr;
-    pStr = cJSON_PrintUnformatted(root);
-    websWrite(wp, "%s", pStr);
     websFlush(wp, 0);
     websFlush(wp, 0);
     websDone(wp);
     websDone(wp);
-    //printf("cJSON:%s\n", pStr);
-
-    if(pStr)
-        wfree(pStr);
-    if(root)
-        cJSON_Delete(root);
 
 
-    // if(historyBuf)
-    //     wfree(historyBuf);
-    // if(pSensorHistory)
-    //     wfree(pSensorHistory);
+    if(historyBuf)
+        wfree(historyBuf);
+    if(pSensorHistory)
+        wfree(pSensorHistory);
+    if(sdr_record)
+        wfree(sdr_record);
 }
 }
 
 
 
 

+ 49 - 0
app/gpiotool/Makefile

@@ -0,0 +1,49 @@
+EXEC		= gpiotool
+
+CFLAGS		:= -Os -mcpu=cortex-m3 -mthumb
+LDFLAGS		:= -mcpu=cortex-m3 -mthumb -L$(INSTALL_ROOT)/A2F/root/usr/lib
+#BUILD_TIME 	= $(shell date +"%Y-%m-%d %H:%M:%S")
+
+
+
+CC	= $(CROSS_COMPILE_APPS)gcc
+
+#source
+SRC	= gpiotool_main.c
+
+# hal_api
+SRC += $(wildcard ../hal_api/*.c) 
+
+#incldue
+CFLAGS	+= -I$(INSTALL_ROOT)/A2F/root/usr/include
+CFLAGS	+= -I ./
+CFLAGS	+= -I ../common_include
+CFLAGS	+= -I ../driver
+CFLAGS	+= -I ../hal_api
+CFLAGS	+= -I ../driver/STM32F4xx_HAL_Driver
+CFLAGS	+= -I ../driver/STM32F4xx_HAL_Driver/Inc
+CFLAGS	+= -I ../driver/STM32F4xx_HAL_Driver/Inc/Legacy
+
+
+#library
+
+#sub-directory
+#SUBDIR 	= ./sensor
+
+
+
+
+
+
+$(EXEC): $(SRC)
+	#echo $(BUILD_TIME)
+	$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(LIBS) -lpthread
+
+
+#object
+OBJS	= $(SRC:%.c=%.o)
+
+clean:
+	rm -f $(EXEC) $(OBJS)
+	rm -f *.gdb 
+

BIN
app/gpiotool/adctool


BIN
app/gpiotool/gpiotool


+ 280 - 0
app/gpiotool/gpiotool_main.c

@@ -0,0 +1,280 @@
+#include <stdio.h>
+#include <stdint.h>
+#include "driver.h"
+#include "hal_interface_api.h"
+#include <fcntl.h>
+
+
+
+
+typedef struct 
+{
+	char 			pinstr[5];
+	GPIO_TypeDef  	*gpioport;
+	uint16_t 		gpiopin;
+} GPIO_TABLE_T;
+
+const GPIO_TABLE_T gpio_map[] = {
+	/**** GPIOA ****/
+	{"PA0",	GPIOA, GPIO_PIN_0},
+	{"PA1",	GPIOA, GPIO_PIN_1},
+	{"PA2",	GPIOA, GPIO_PIN_2},
+	{"PA3",	GPIOA, GPIO_PIN_3},
+	{"PA4",	GPIOA, GPIO_PIN_4},
+	{"PA5",	GPIOA, GPIO_PIN_5},
+	{"PA6",	GPIOA, GPIO_PIN_6},
+	{"PA7",	GPIOA, GPIO_PIN_7},
+	{"PA8",	GPIOA, GPIO_PIN_8},
+	{"PA9",	GPIOA, GPIO_PIN_9},
+	{"PA10",	GPIOA, GPIO_PIN_10},
+	{"PA11",	GPIOA, GPIO_PIN_11},
+	{"PA12",	GPIOA, GPIO_PIN_12},
+	{"PA13",	GPIOA, GPIO_PIN_13},
+	{"PA14",	GPIOA, GPIO_PIN_14},
+	{"PA15",	GPIOA, GPIO_PIN_15},
+	/**** GPIOB ****/
+	{"PB0",	GPIOB, GPIO_PIN_0},
+	{"PB1",	GPIOB, GPIO_PIN_1},
+	{"PB2",	GPIOB, GPIO_PIN_2},
+	{"PB3",	GPIOB, GPIO_PIN_3},
+	{"PB4",	GPIOB, GPIO_PIN_4},
+	{"PB5",	GPIOB, GPIO_PIN_5},
+	{"PB6",	GPIOB, GPIO_PIN_6},
+	{"PB7",	GPIOB, GPIO_PIN_7},
+	{"PB8",	GPIOB, GPIO_PIN_8},
+	{"PB9",	GPIOB, GPIO_PIN_9},
+	{"PB10",	GPIOB, GPIO_PIN_10},
+	{"PB11",	GPIOB, GPIO_PIN_11},
+	{"PB12",	GPIOB, GPIO_PIN_12},
+	{"PB13",	GPIOB, GPIO_PIN_13},
+	{"PB14",	GPIOB, GPIO_PIN_14},
+	{"PB15",	GPIOB, GPIO_PIN_15},
+	/**** GPIOC ****/
+	{"PC0",	GPIOC, GPIO_PIN_0},
+	{"PC1",	GPIOC, GPIO_PIN_1},
+	{"PC2",	GPIOC, GPIO_PIN_2},
+	{"PC3",	GPIOC, GPIO_PIN_3},
+	{"PC4",	GPIOC, GPIO_PIN_4},
+	{"PC5",	GPIOC, GPIO_PIN_5},
+	{"PC6",	GPIOC, GPIO_PIN_6},
+	{"PC7",	GPIOC, GPIO_PIN_7},
+	{"PC8",	GPIOC, GPIO_PIN_8},
+	{"PC9",	GPIOC, GPIO_PIN_9},
+	{"PC10",	GPIOC, GPIO_PIN_10},
+	{"PC11",	GPIOC, GPIO_PIN_11},
+	{"PC12",	GPIOC, GPIO_PIN_12},
+	{"PC13",	GPIOC, GPIO_PIN_13},
+	{"PC14",	GPIOC, GPIO_PIN_14},
+	{"PC15",	GPIOC, GPIO_PIN_15},
+	/**** GPIOD ****/
+	{"PD0",	GPIOD, GPIO_PIN_0},
+	{"PD1",	GPIOD, GPIO_PIN_1},
+	{"PD2",	GPIOD, GPIO_PIN_2},
+	{"PD3",	GPIOD, GPIO_PIN_3},
+	{"PD4",	GPIOD, GPIO_PIN_4},
+	{"PD5",	GPIOD, GPIO_PIN_5},
+	{"PD6",	GPIOD, GPIO_PIN_6},
+	{"PD7",	GPIOD, GPIO_PIN_7},
+	{"PD8",	GPIOD, GPIO_PIN_8},
+	{"PD9",	GPIOD, GPIO_PIN_9},
+	{"PD10",	GPIOD, GPIO_PIN_10},
+	{"PD11",	GPIOD, GPIO_PIN_11},
+	{"PD12",	GPIOD, GPIO_PIN_12},
+	{"PD13",	GPIOD, GPIO_PIN_13},
+	{"PD14",	GPIOD, GPIO_PIN_14},
+	{"PD15",	GPIOD, GPIO_PIN_15},
+	/**** GPIOE ****/
+	{"PE0",	GPIOE, GPIO_PIN_0},
+	{"PE1",	GPIOE, GPIO_PIN_1},
+	{"PE2",	GPIOE, GPIO_PIN_2},
+	{"PE3",	GPIOE, GPIO_PIN_3},
+	{"PE4",	GPIOE, GPIO_PIN_4},
+	{"PE5",	GPIOE, GPIO_PIN_5},
+	{"PE6",	GPIOE, GPIO_PIN_6},
+	{"PE7",	GPIOE, GPIO_PIN_7},
+	{"PE8",	GPIOE, GPIO_PIN_8},
+	{"PE9",	GPIOE, GPIO_PIN_9},
+	{"PE10",	GPIOE, GPIO_PIN_10},
+	{"PE11",	GPIOE, GPIO_PIN_11},
+	{"PE12",	GPIOE, GPIO_PIN_12},
+	{"PE13",	GPIOE, GPIO_PIN_13},
+	{"PE14",	GPIOE, GPIO_PIN_14},
+	{"PE15",	GPIOE, GPIO_PIN_15},
+	/**** GPIOF ****/
+	{"PF0",	GPIOF, GPIO_PIN_0},
+	{"PF1",	GPIOF, GPIO_PIN_1},
+	{"PF2",	GPIOF, GPIO_PIN_2},
+	{"PF3",	GPIOF, GPIO_PIN_3},
+	{"PF4",	GPIOF, GPIO_PIN_4},
+	{"PF5",	GPIOF, GPIO_PIN_5},
+	{"PF6",	GPIOF, GPIO_PIN_6},
+	{"PF7",	GPIOF, GPIO_PIN_7},
+	{"PF8",	GPIOF, GPIO_PIN_8},
+	{"PF9",	GPIOF, GPIO_PIN_9},
+	{"PF10",	GPIOF, GPIO_PIN_10},
+	{"PF11",	GPIOF, GPIO_PIN_11},
+	{"PF12",	GPIOF, GPIO_PIN_12},
+	{"PF13",	GPIOF, GPIO_PIN_13},
+	{"PF14",	GPIOF, GPIO_PIN_14},
+	{"PF15",	GPIOF, GPIO_PIN_15},
+	/**** GPIOG ****/
+	{"PG0",	GPIOG, GPIO_PIN_0},
+	{"PG1",	GPIOG, GPIO_PIN_1},
+	{"PG2",	GPIOG, GPIO_PIN_2},
+	{"PG3",	GPIOG, GPIO_PIN_3},
+	{"PG4",	GPIOG, GPIO_PIN_4},
+	{"PG5",	GPIOG, GPIO_PIN_5},
+	{"PG6",	GPIOG, GPIO_PIN_6},
+	{"PG7",	GPIOG, GPIO_PIN_7},
+	{"PG8",	GPIOG, GPIO_PIN_8},
+	{"PG9",	GPIOG, GPIO_PIN_9},
+	{"PG10",	GPIOG, GPIO_PIN_10},
+	{"PG11",	GPIOG, GPIO_PIN_11},
+	{"PG12",	GPIOG, GPIO_PIN_12},
+	{"PG13",	GPIOG, GPIO_PIN_13},
+	{"PG14",	GPIOG, GPIO_PIN_14},
+	{"PG15",	GPIOG, GPIO_PIN_15},
+	/**** GPIOH ****/
+	{"PH0",	GPIOH, GPIO_PIN_0},
+	{"PH1",	GPIOH, GPIO_PIN_1},
+	{"PH2",	GPIOH, GPIO_PIN_2},
+	{"PH3",	GPIOH, GPIO_PIN_3},
+	{"PH4",	GPIOH, GPIO_PIN_4},
+	{"PH5",	GPIOH, GPIO_PIN_5},
+	{"PH6",	GPIOH, GPIO_PIN_6},
+	{"PH7",	GPIOH, GPIO_PIN_7},
+	{"PH8",	GPIOH, GPIO_PIN_8},
+	{"PH9",	GPIOH, GPIO_PIN_9},
+	{"PH10",	GPIOH, GPIO_PIN_10},
+	{"PH11",	GPIOH, GPIO_PIN_11},
+	{"PH12",	GPIOH, GPIO_PIN_12},
+	{"PH13",	GPIOH, GPIO_PIN_13},
+	{"PH14",	GPIOH, GPIO_PIN_14},
+	{"PH15",	GPIOH, GPIO_PIN_15},
+	/**** GPIOI ****/
+	{"PI0",	GPIOI, GPIO_PIN_0},
+	{"PI1",	GPIOI, GPIO_PIN_1},
+	{"PI2",	GPIOI, GPIO_PIN_2},
+	{"PI3",	GPIOI, GPIO_PIN_3},
+	{"PI4",	GPIOI, GPIO_PIN_4},
+	{"PI5",	GPIOI, GPIO_PIN_5},
+	{"PI6",	GPIOI, GPIO_PIN_6},
+	{"PI7",	GPIOI, GPIO_PIN_7},
+	{"PI8",	GPIOI, GPIO_PIN_8},
+	{"PI9",	GPIOI, GPIO_PIN_9},
+	{"PI10",	GPIOI, GPIO_PIN_10},
+	{"PI11",	GPIOI, GPIO_PIN_11},
+	{"PI12",	GPIOI, GPIO_PIN_12},
+	{"PI13",	GPIOI, GPIO_PIN_13},
+	{"PI14",	GPIOI, GPIO_PIN_14},
+	{"PI15",	GPIOI, GPIO_PIN_15},
+};
+
+void help()
+{
+	printf("gpiotool set <PA0~PI15> <outputpp/outputod/input> <pullup/pulldown/nopull>\n");
+	printf("gpiotool write <PA0~PI15> <high/low>\n");
+	printf("gpiotool read <PA0~PI15>\n");
+}
+
+int main(int argc, char* argv[])
+{
+	int i;
+	uint16_t buf;
+	GPIO_TABLE_T *gpioinfo;
+	GPIO_TypeDef  	*GPIO_PORT;
+	uint16_t		GPIO_PIN;
+	GPIO_InitTypeDef GPIO_InitStruct;
+	uint8_t 		pin_state;
+
+
+	if(argc < 3)
+	{
+		help();
+		return -1;
+	}
+
+	for(i=0;i<sizeof(gpio_map)/sizeof(GPIO_TABLE_T);i++)
+	{
+		if(strcmp(argv[2], gpio_map[i].pinstr) == 0)
+		{
+			GPIO_PORT = gpio_map[i].gpioport;
+			GPIO_PIN = gpio_map[i].gpiopin;
+			break;
+		}
+	}
+
+	if(i == sizeof(gpio_map)/sizeof(GPIO_TABLE_T))
+	{
+		printf("Invalid gpio pin %s \n", argv[2]);
+		help();
+		return -1;
+	}
+
+	if((strcmp(argv[1], "set") == 0) && (argc == 5))
+	{
+		GPIO_InitStruct.Pin = GPIO_PIN;
+		GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+
+		if(strcmp(argv[3], "outputpp") == 0)
+			GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+		else if(strcmp(argv[3], "outputod") == 0)
+			GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
+		else if(strcmp(argv[3], "input") == 0)
+			GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+		else
+		{
+			printf("Invalid dir %s\n", argv[3]);
+			help();
+			return -1;
+		}
+
+		if(strcmp(argv[4], "pullup") == 0)
+			GPIO_InitStruct.Pull = GPIO_PULLUP;
+		else if(strcmp(argv[4], "pulldown") == 0)
+			GPIO_InitStruct.Pull = GPIO_PULLDOWN;
+		else if(strcmp(argv[4], "nopull") == 0)
+			GPIO_InitStruct.Pull = GPIO_NOPULL;
+		else
+		{
+			printf("Invalid pull %s\n", argv[4]);
+			help();
+			return -1;
+		}
+
+		stm32_gpio_init(GPIO_PORT, &GPIO_InitStruct);
+		printf("Set %s %s %s\n", argv[2], argv[3], argv[4]);
+	}
+	else if((strcmp(argv[1], "write") == 0) && (argc == 4))
+	{
+		if(strcmp(argv[3], "high") == 0)
+		{
+			stm32_gpio_write(GPIO_PORT, GPIO_PIN, 1);
+			printf("Set %s high\n", argv[2]);
+		}
+		else if(strcmp(argv[3], "low") == 0)
+		{
+			stm32_gpio_write(GPIO_PORT, GPIO_PIN, 0);
+			printf("Set %s low\n", argv[2]);
+		}
+		else
+		{
+			printf("Invalid pin state %s\n", argv[3]);
+			help();
+			return -1;
+		}
+	}
+	else if((strcmp(argv[1], "read") == 0) && (argc == 3))
+	{
+		pin_state = stm32_gpio_read(GPIO_PORT, GPIO_PIN);
+		if(pin_state)
+			printf("Read %s high\n", argv[2]);
+		else
+			printf("Read %s low\n", argv[2]);
+	}	
+	else
+	{
+		help();
+		return -1;
+	}
+}

+ 7 - 7
app/hal_api/hal_spi_interface.c

@@ -48,7 +48,7 @@ int stm32_spi_master_write(uint8_t spi, uint8_t *pBuf, uint32_t size)
 	fd = open(dev_name, O_RDWR);
 	fd = open(dev_name, O_RDWR);
 	if(fd == -1)
 	if(fd == -1)
 	{
 	{
-		printf("Open %s failed!\n", dev_name);
+		printf("%s %d: Open %s failed!\n", __FILE__, __LINE__, dev_name);
 	}
 	}
 
 
 	// //NSS low
 	// //NSS low
@@ -106,7 +106,7 @@ int stm32_spi_master_read(uint8_t spi, uint8_t *pBuf, uint32_t size)
 	fd = open(dev_name, O_RDWR);
 	fd = open(dev_name, O_RDWR);
 	if(fd == -1)
 	if(fd == -1)
 	{
 	{
-		printf("Open %s failed!\n", DEV_NAME);
+		printf("%s %d: Open %s failed!\n",__FILE__, __LINE__, DEV_NAME);
 	}
 	}
 	
 	
 	spi_arg.Size = size;
 	spi_arg.Size = size;
@@ -158,7 +158,7 @@ int stm32_spi_master_write_read(uint8_t spi, uint8_t *txBuf, uint32_t txSize, ui
 	fd = open(dev_name, O_RDWR);
 	fd = open(dev_name, O_RDWR);
 	if(fd == -1)
 	if(fd == -1)
 	{
 	{
-		printf("Open %s failed!\n", DEV_NAME);
+		printf("%s %d: Open %s failed!\n",__FILE__, __LINE__, DEV_NAME);
 	}
 	}
 
 
 	//Tx
 	//Tx
@@ -276,7 +276,7 @@ int sf_sector_erase(uint8_t spi, uint32_t offset)
 	fd = open(dev_name, O_RDWR);
 	fd = open(dev_name, O_RDWR);
 	if(fd == -1)
 	if(fd == -1)
 	{
 	{
-		printf("Open %s failed!\n", dev_name);
+		printf("%s %d: Open %s failed!\n",__FILE__, __LINE__, dev_name);
 	}
 	}
 
 
 	//Write Enable
 	//Write Enable
@@ -359,7 +359,7 @@ int sf_chip_erase(uint8_t spi)
 	fd = open(dev_name, O_RDWR);
 	fd = open(dev_name, O_RDWR);
 	if(fd == -1)
 	if(fd == -1)
 	{
 	{
-		printf("Open %s failed!\n", dev_name);
+		printf("%s %d: Open %s failed!\n",__FILE__, __LINE__, dev_name);
 	}
 	}
 
 
 	//Write Enable
 	//Write Enable
@@ -505,7 +505,7 @@ int sf_write(uint8_t spi, uint32_t offset, uint8_t *buf, uint32_t size)
 	fd = open(dev_name, O_RDWR);
 	fd = open(dev_name, O_RDWR);
 	if(fd == -1)
 	if(fd == -1)
 	{
 	{
-		printf("Open %s failed!\n", dev_name);
+		printf("%s %d: Open %s failed!\n",__FILE__, __LINE__, dev_name);
 	}
 	}
 
 
 	
 	
@@ -657,7 +657,7 @@ int sf_read(uint8_t spi, uint32_t offset, uint8_t *buf, uint32_t size)
 	fd = open(dev_name, O_RDWR);
 	fd = open(dev_name, O_RDWR);
 	if(fd == -1)
 	if(fd == -1)
 	{
 	{
-		printf("Open %s failed!\n", dev_name);
+		printf("%s %d: Open %s failed!\n",__FILE__, __LINE__, dev_name);
 	}
 	}
 		
 		
 	remain = size;
 	remain = size;

BIN
app/i2c_scan/i2c-scan


+ 49 - 0
app/i2ctool/Makefile

@@ -0,0 +1,49 @@
+EXEC		= i2ctool
+
+CFLAGS		:= -Os -mcpu=cortex-m3 -mthumb
+LDFLAGS		:= -mcpu=cortex-m3 -mthumb -L$(INSTALL_ROOT)/A2F/root/usr/lib
+#BUILD_TIME 	= $(shell date +"%Y-%m-%d %H:%M:%S")
+
+
+
+CC	= $(CROSS_COMPILE_APPS)gcc
+
+#source
+SRC	= i2ctool_main.c
+
+# hal_api
+SRC += $(wildcard ../hal_api/*.c) 
+
+#incldue
+CFLAGS	+= -I$(INSTALL_ROOT)/A2F/root/usr/include
+CFLAGS	+= -I ./
+CFLAGS	+= -I ../common_include
+CFLAGS	+= -I ../driver
+CFLAGS	+= -I ../hal_api
+CFLAGS	+= -I ../driver/STM32F4xx_HAL_Driver
+CFLAGS	+= -I ../driver/STM32F4xx_HAL_Driver/Inc
+CFLAGS	+= -I ../driver/STM32F4xx_HAL_Driver/Inc/Legacy
+
+
+#library
+
+#sub-directory
+#SUBDIR 	= ./sensor
+
+
+
+
+
+
+$(EXEC): $(SRC)
+	#echo $(BUILD_TIME)
+	$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(LIBS) -lpthread
+
+
+#object
+OBJS	= $(SRC:%.c=%.o)
+
+clean:
+	rm -f $(EXEC) $(OBJS)
+	rm -f *.gdb 
+

BIN
app/i2ctool/i2ctool


+ 197 - 0
app/i2ctool/i2ctool_main.c

@@ -0,0 +1,197 @@
+#include <stdio.h>
+#include <stdint.h>
+#include "driver.h"
+#include "hal_interface_api.h"
+#include <fcntl.h>
+#include <string.h>
+
+
+
+void help()
+{
+	printf("i2ctool <cmd>\n");
+	printf("    --scan [channel]: scan i2c bus\n");
+	printf("    --write [channel] -t [target address] -d [data...]: write i2c data.\n");
+}
+
+int str2uint8(char* str, uint8_t *value)
+{
+	uint8_t val = 0;
+	char chr;
+	if(sizeof(str) > 2)		//maybe hex
+	{
+		if((strncmp(str, "0x", 2) == 0) || (strncmp(str, "0X", 2) == 0))
+		{			
+			if(strlen(str) > 4)
+			{
+				printf("Invalid hex %s\n", str);
+				return -1;
+			}
+
+			chr = str[2];
+			if((chr >= '0') && (chr <= '9'))
+			{
+				val = chr - '0';
+			}
+			else if((chr >= 'a') && (chr <= 'f'))
+			{
+				val = chr - 'a' + 10;
+			}
+			else if((chr >= 'A') && (chr <= 'F'))
+			{
+				val = chr - 'A' + 10;
+			}
+			else
+			{
+				printf("Invalid hex %s\n", str);
+				return -1;
+			}
+
+			if(str[3] != '\0')
+			{
+				chr = str[3];
+				val <<= 4; 
+				if((chr >= '0') && (chr <= '9'))
+					val += chr - '0';
+				else if((chr >= 'a') && (chr <= 'f'))
+					val += chr - 'a' + 10;
+				else if((chr >= 'A') && (chr <= 'F'))
+					val += chr - 'A' + 10;
+				else
+				{
+					printf("Invalid hex %s\n", str);
+					return -1;
+				}
+			}
+		}
+		else	//dec
+		{
+			val = atoi(str);
+		}
+	}
+	else	//dec
+	{
+		val = atoi(str);
+	}
+
+	*value = val;
+	return 0;
+}
+
+int main(int argc, char* argv[])
+{
+	int fd;
+	int i;
+	int ret;
+	uint8_t buf[100];
+	uint8_t channel;
+	uint8_t target_addr, start_addr = 2, end_addr = 254;
+	char devname[20] = {0};
+	uint8_t val;
+
+
+	if(argc < 3)
+	{
+		help();
+		return -1;
+	}
+
+	if(strcmp(argv[1], "--scan") == 0)
+	{
+		//Get Channel
+		if(str2uint8(argv[2], &channel) != 0)
+		{
+			printf("Get Channel failed %s\n", argv[2]);
+			return -1;
+		}
+		sprintf(devname, "/dev/i2c%d", channel);
+		printf("\n");
+	 	printf("Find Slave I2C device:\n");
+		for(i=start_addr;i<=end_addr;i+=2)
+		{
+			fd = open(devname, O_RDWR);
+			ret = stm32_i2c_master_write(fd, i, buf, 0);
+			if(ret == 0)
+			{
+				printf("  %#02x\n", i);
+			}
+			close(fd);
+		}
+		printf("\n");
+
+	}
+	else if(strcmp(argv[1], "--write") == 0)
+	{
+		//Get Channel
+		if(str2uint8(argv[2], &channel) != 0)
+		{
+			printf("Get Channel failed %s\n", argv[2]);
+			return -1;
+		}
+		sprintf(devname, "/dev/i2c%d", channel);
+
+		//Get target address
+		if((strcmp(argv[3], "-t") == 0) && (argc >= 5))
+		{
+			if(str2uint8(argv[4], &target_addr) != 0)
+			{
+				printf("Invalid target address %s\n", argv[4]);
+				help();
+				return -1;
+			}
+
+			if(target_addr & 0x01)
+			{
+				printf("target_addr must be write!\n");
+				return -1;
+			}
+		}
+		else
+		{
+			printf("Need -t \n");
+			help();
+			return -1;
+		}
+
+		//Get Datas
+		if((strcmp(argv[5], "-d") == 0) && (argc >= 7)) 
+		{
+			for(i=0;i<argc-6;i++)
+			{
+				if(str2uint8(argv[i+6], &val) != 0)
+				{
+					printf("Invalid data[%d] = %s\n", i, argv[i+6]);
+					return -1;
+				}
+				buf[i] = val;
+			}
+		}
+		else
+		{
+			printf("Need -d\n");
+			help();
+			return -1;
+		}
+		printf("i2c_%d write %#02x: ", channel, target_addr);
+		for(i=0;i<argc-6;i++)
+			printf("%02x ", buf[i]);
+		printf("\n");
+		
+		fd = open(devname, O_RDWR);
+		ret = stm32_i2c_master_write(fd, target_addr, buf, argc-6);
+		if(ret != 0)
+		{
+			printf("i2ctool write %#02x failed!\n", target_addr);
+		}
+		close(fd);
+	}
+	else
+	{
+		printf("Invalid param %s\n", argv[1]);
+		help();
+		return -1;
+	}
+
+	
+	return 0;
+}

+ 49 - 0
app/spitool/Makefile

@@ -0,0 +1,49 @@
+EXEC		= spitool
+
+CFLAGS		:= -Os -mcpu=cortex-m3 -mthumb
+LDFLAGS		:= -mcpu=cortex-m3 -mthumb -L$(INSTALL_ROOT)/A2F/root/usr/lib
+#BUILD_TIME 	= $(shell date +"%Y-%m-%d %H:%M:%S")
+
+
+
+CC	= $(CROSS_COMPILE_APPS)gcc
+
+#source
+SRC	= spitool_main.c
+
+# hal_api
+SRC += $(wildcard ../hal_api/*.c) 
+
+#incldue
+CFLAGS	+= -I$(INSTALL_ROOT)/A2F/root/usr/include
+CFLAGS	+= -I ./
+CFLAGS	+= -I ../common_include
+CFLAGS	+= -I ../driver
+CFLAGS	+= -I ../hal_api
+CFLAGS	+= -I ../driver/STM32F4xx_HAL_Driver
+CFLAGS	+= -I ../driver/STM32F4xx_HAL_Driver/Inc
+CFLAGS	+= -I ../driver/STM32F4xx_HAL_Driver/Inc/Legacy
+
+
+#library
+
+#sub-directory
+#SUBDIR 	= ./sensor
+
+
+
+
+
+
+$(EXEC): $(SRC)
+	#echo $(BUILD_TIME)
+	$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(LIBS) -lpthread
+
+
+#object
+OBJS	= $(SRC:%.c=%.o)
+
+clean:
+	rm -f $(EXEC) $(OBJS)
+	rm -f *.gdb 
+

BIN
app/spitool/spitool


+ 42 - 0
app/spitool/spitool_main.c

@@ -0,0 +1,42 @@
+#include <stdio.h>
+#include <stdint.h>
+#include "driver.h"
+#include "hal_interface_api.h"
+#include <fcntl.h>
+
+/*
+adctool --get-all-channels
+*/
+
+void help()
+{
+	printf("spitool <cmd>\n");
+	printf("    --.\n");
+}
+
+int main(int argc, char* argv[])
+{
+	int i;
+	uint16_t buf;
+	if(argc < 2)
+	{
+		help();
+		return -1;
+	}
+
+	if((strcmp(argv[1], "--get-all-channels") == 0) && (argc == 2))
+	{
+		for(i=1;i<=7;i++)
+		{
+			buf = 0;
+			stm32_adc_get_value(i, &buf);
+			printf("ADC%d: %#04x\n", i, buf); 	
+		}
+		
+	}
+	else
+	{
+		help();
+		return -1;
+	}
+}

BIN
app/test_app/test_app