Sfoglia il codice sorgente

debug GetDeviceInfo

zhangbo 5 anni fa
parent
commit
a709af2ae5

BIN
app/bmc/bmc_app


BIN
app/bmc/bmc_app.gdb


+ 2 - 0
app/common_include/com_IPMI_SDRRecord.h

@@ -23,6 +23,8 @@
 #ifndef IPMI_SDR_RECORD_H
 #define IPMI_SDR_RECORD_H
 
+#include "com_IPMIDefs.h"
+
 #ifndef uint8_t
   #define uint8_t unsigned char
 #endif

BIN
app/goahead-5.1.0/build/linux-arm-static/bin/goahead


BIN
app/goahead-5.1.0/build/linux-arm-static/bin/goahead-test


BIN
app/goahead-5.1.0/build/linux-arm-static/bin/goahead-test.gdb


BIN
app/goahead-5.1.0/build/linux-arm-static/bin/goahead.gdb


BIN
app/goahead-5.1.0/build/linux-arm-static/bin/gopass


BIN
app/goahead-5.1.0/build/linux-arm-static/bin/gopass.gdb


BIN
app/goahead-5.1.0/build/linux-arm-static/bin/libgo.a


BIN
app/goahead-5.1.0/build/linux-arm-static/bin/libgoahead-mbedtls.a


+ 1 - 1
app/goahead-5.1.0/build/linux-arm-static/inc/goahead.h

@@ -3993,7 +3993,7 @@ PUBLIC int websSetSessionVar(Webs *wp, cchar *name, cchar *value);
 //add by lusa
 PUBLIC void personInfoAction(Webs *wp);
 
-PUBLIC void getDeviceInfo(Webs *wp);
+//PUBLIC void getDeviceInfo(Webs *wp);
 
 
 PUBLIC void getDeviceInfoBak(Webs *wp);

+ 1 - 17
app/goahead-5.1.0/projects/goahead-linux-static.mk

@@ -141,8 +141,6 @@ clean:
 	rm -f "$(BUILD)/bin/libgoahead-mbedtls.a"
 	rm -f "$(BUILD)/bin/libmbedtls.a"
 
-<<<<<<< HEAD
-=======
 	rm -f "$(BUILD)/bin/libipmi_session.o"
 	rm -f "$(BUILD)/bin/libipmi_uds_session.o"
 	rm -f "$(BUILD)/bin/libipmi_IPM.o"
@@ -154,7 +152,6 @@ clean:
 	rm -f "$(BUILD)/bin/remote_control.o"
 	rm -f "$(BUILD)/bin/sel.o"
 	rm -f "$(BUILD)/bin/server_health.o"
->>>>>>> 62e2f54f0c6a6c4a634828a115139a52376334ba
 clobber: clean
 	rm -fr ./$(BUILD)
 
@@ -532,7 +529,6 @@ $(BUILD)/obj/libipmi_uds_session.o: \
     src/libipmi/src/libipmi_uds_session.c $(DEPS_USER_C2)
 	@echo '   [Compile] $(BUILD)/obj/libipmi_uds_session.o'
 	$(CC) -c -o $(BUILD)/obj/libipmi_uds_session.o $(LDFLAGS) $(CFLAGS) $(DFLAGS) -D_FILE_OFFSET_BITS=64 -D_FILE_OFFSET_BITS=64 -DMBEDTLS_USER_CONFIG_FILE=\"embedtls.h\" -DME_COM_OPENSSL_PATH=$(ME_COM_OPENSSL_PATH) $(IFLAGS) "-I$(ME_COM_OPENSSL_PATH)/include" src/libipmi/src/libipmi_uds_session.c
-<<<<<<< HEAD
 $(BUILD)/obj/libipmi_IPM.o: \
     src/libipmi/src/libipmi_IPM.c $(DEPS_USER_C2)
 	@echo '   [Compile] $(BUILD)/obj/libipmi_IPM.o'
@@ -586,8 +582,6 @@ $(BUILD)/obj/sensor_helpers.o: \
 		-D_FILE_OFFSET_BITS=64 -D_FILE_OFFSET_BITS=64 -DMBEDTLS_USER_CONFIG_FILE=\"embedtls.h\" \
 		-DME_COM_OPENSSL_PATH=$(ME_COM_OPENSSL_PATH) $(IFLAGS) \
 		"-I$(ME_COM_OPENSSL_PATH)/include" src/libipmi/src/sensor_helpers.c
-=======
->>>>>>> 7ab296de0a831eaa7f47c3239e381bd4b2aeae5a
 
 
 DEPS_USER_C3 += $(BUILD)/inc/goahead.h
@@ -1009,9 +1003,7 @@ DEPS_36 += $(BUILD)/obj/time.o
 DEPS_36 += $(BUILD)/obj/upload.o
 DEPS_36 += $(BUILD)/obj/libipmi_session.o
 DEPS_36 += $(BUILD)/obj/libipmi_uds_session.o
-<<<<<<< HEAD
 
-=======
 DEPS_36 += $(BUILD)/obj/libipmi_IPM.o
 DEPS_36 += $(BUILD)/obj/libipmi_Chassis.o
 DEPS_36 += $(BUILD)/obj/libipmi_fru.o
@@ -1030,15 +1022,11 @@ DEPS_36 += $(BUILD)/obj/fw_update.o
 DEPS_36 += $(BUILD)/obj/remote_control.o
 DEPS_36 += $(BUILD)/obj/sel.o
 DEPS_36 += $(BUILD)/obj/server_health.o
->>>>>>> 62e2f54f0c6a6c4a634828a115139a52376334ba
 
 
 
 $(BUILD)/bin/libgo.a: $(DEPS_36)
 	@echo '      [Link] $(BUILD)/bin/libgo.a'
-<<<<<<< HEAD
-	$(AR) -cr $(BUILD)/bin/libgo.a "$(BUILD)/obj/ResultUtils.o" "$(BUILD)/obj/action.o" "$(BUILD)/obj/alloc.o" "$(BUILD)/obj/auth.o" "$(BUILD)/obj/cgi.o" "$(BUILD)/obj/crypt.o" "$(BUILD)/obj/file.o" "$(BUILD)/obj/fs.o" "$(BUILD)/obj/http.o" "$(BUILD)/obj/js.o" "$(BUILD)/obj/jst.o" "$(BUILD)/obj/options.o" "$(BUILD)/obj/osdep.o" "$(BUILD)/obj/rom.o" "$(BUILD)/obj/route.o" "$(BUILD)/obj/runtime.o" "$(BUILD)/obj/socket.o" "$(BUILD)/obj/time.o" "$(BUILD)/obj/upload.o" "$(BUILD)/obj/cJSON.o" "$(BUILD)/obj/libipmi_session.o" "$(BUILD)/obj/libipmi_uds_session.o" 
-=======
 	$(AR) -cr $(BUILD)/bin/libgo.a "$(BUILD)/obj/ResultUtils.o" "$(BUILD)/obj/action.o" \
 		"$(BUILD)/obj/alloc.o" "$(BUILD)/obj/auth.o" "$(BUILD)/obj/cgi.o" "$(BUILD)/obj/crypt.o" \
 		"$(BUILD)/obj/file.o" "$(BUILD)/obj/fs.o" "$(BUILD)/obj/http.o" "$(BUILD)/obj/js.o" \
@@ -1049,13 +1037,9 @@ $(BUILD)/bin/libgo.a: $(DEPS_36)
 		"$(BUILD)/obj/libipmi_Chassis.o" "$(BUILD)/obj/libipmi_PEF.o" "$(BUILD)/obj/libipmi_sdr.o" \
 		"$(BUILD)/obj/libipmi_sensor.o" "$(BUILD)/obj/libipmi_storlead_OEM.o" "$(BUILD)/obj/sensor_helpers.o"  \
 		"$(BUILD)/obj/config.o" "$(BUILD)/obj/dashboard.o" "$(BUILD)/obj/fan.o" "$(BUILD)/obj/fru.o" \
-<<<<<<< HEAD
 		"$(BUILD)/obj/fw_update.o" "$(BUILD)/obj/remote_control.o" "$(BUILD)/obj/sel.o" \
 		"$(BUILD)/obj/server_health.o" 
-=======
-		"$(BUILD)/obj/fw_update.o" "$(BUILD)/obj/remote_control.o" "$(BUILD)/obj/sel.o" "$(BUILD)/obj/server_health.o" 
->>>>>>> 62e2f54f0c6a6c4a634828a115139a52376334ba
->>>>>>> 7ab296de0a831eaa7f47c3239e381bd4b2aeae5a
+
 
 #
 #   install-certs

+ 34 - 546
app/goahead-5.1.0/src/libipmi/inc/libipmi.h

@@ -3,70 +3,66 @@
 #ifndef LIBIPMI_H
 #define LIBIPMI_H
 
-#define u8 	unsigned char
-#define u16	unsigned short int
-#define s32 long int
-
 /*! Return value that indicates a specified sensor is disabled, and cannot be read */
 #define IPMI_SENSOR_DISABLED        ( -3 )
 
 /* IPMI threshold state definitions for monitoring */
-#define THRESH_UNINITIALIZED        ( (u16)0x00 ) /*!< Threshold state on first run */
-#define THRESH_NORMAL               ( (u16)0x01 ) /*!< Sensor is normal (unused in IPMI ) */
-#define THRESH_UP_NONCRIT           ( (u16)0x02 ) /*!< IPMI Upper Non-Critical Threshold */
-#define THRESH_UP_CRITICAL          ( (u16)0x04 ) /*!< IPMI Upper Critical Threshold */
-#define THRESH_LOW_NONCRIT          ( (u16)0x08 ) /*!< IPMI Lower Non-Critical Threshold */
-#define THRESH_LOW_CRITICAL         ( (u16)0x10 ) /*!< IPMI Lower Critical Threshold */
-#define THRESH_ACCESS_FAILED        ( (u16)0x20 ) /*!< Access failed sensor state */
-#define THRESH_UP_NON_RECOV         ( (u16)0x40 ) /*!< IPMI Upper Non-Recoverable Threshold */
-#define THRESH_LOW_NON_RECOV        ( (u16)0x80 ) /*!< IPMI Lower Non-Recoverable Threshold */
+#define THRESH_UNINITIALIZED        ( (uint16_t)0x00 ) /*!< Threshold state on first run */
+#define THRESH_NORMAL               ( (uint16_t)0x01 ) /*!< Sensor is normal (unused in IPMI ) */
+#define THRESH_UP_NONCRIT           ( (uint16_t)0x02 ) /*!< IPMI Upper Non-Critical Threshold */
+#define THRESH_UP_CRITICAL          ( (uint16_t)0x04 ) /*!< IPMI Upper Critical Threshold */
+#define THRESH_LOW_NONCRIT          ( (uint16_t)0x08 ) /*!< IPMI Lower Non-Critical Threshold */
+#define THRESH_LOW_CRITICAL         ( (uint16_t)0x10 ) /*!< IPMI Lower Critical Threshold */
+#define THRESH_ACCESS_FAILED        ( (uint16_t)0x20 ) /*!< Access failed sensor state */
+#define THRESH_UP_NON_RECOV         ( (uint16_t)0x40 ) /*!< IPMI Upper Non-Recoverable Threshold */
+#define THRESH_LOW_NON_RECOV        ( (uint16_t)0x80 ) /*!< IPMI Lower Non-Recoverable Threshold */
 
 /* Macros for converting netfn/lun combos */
-#define NETFN( netfnlun )       ( ( netfnlun & (u8)0xFC ) >> 2 )
-#define NETLUN( netfnlun )      ( ( netfnlun & (u8)0x03 ) )
+#define NETFN( netfnlun )       ( ( netfnlun & (uint8_t)0xFC ) >> 2 )
+#define NETLUN( netfnlun )      ( ( netfnlun & (uint8_t)0x03 ) )
 #define NETFNLUN( netfn,lun )   ( ( netfn << 2 ) | ( lun ) )
 
 /* Macros for converting seq/lun combos */
-#define SEQ( seqlun )           ( ( seqlun & (u8)0xFC ) >> 2 )
-#define SLUN( seqlun )          ( ( seqlun & (u8)0x03 ) )
+#define SEQ( seqlun )           ( ( seqlun & (uint8_t)0xFC ) >> 2 )
+#define SLUN( seqlun )          ( ( seqlun & (uint8_t)0x03 ) )
 #define SEQLUN( seq, lun )      ( ( seq << 2 ) | ( lun ) )
 
 
 /*****                 IPMI Constant Definitions                         *****/
 
 /* Completion Codes */
-#define IPMI_SUCCESS            ( (u8)0x00 )
+#define IPMI_SUCCESS            ( (uint8_t)0x00 )
 
 /* Sensor Data Record types */
-#define SDR_FULL                ( (u8)0x01 ) /**< SDR RecordType for Full Sensor Record */
-#define SDR_COMPACT             ( (u8)0x02 ) /**< SDR RecordType for Compact Sensor Record */
+#define SDR_FULL                ( (uint8_t)0x01 ) /**< SDR RecordType for Full Sensor Record */
+#define SDR_COMPACT             ( (uint8_t)0x02 ) /**< SDR RecordType for Compact Sensor Record */
 
 /* Raw sensor reading numeric format codes */
-#define SDR_READING_UNSIGNED    ( (u8)0 )
-#define SDR_READING_1SCOMP      ( (u8)1 )
-#define SDR_READING_2SCOMP      ( (u8)2 )
-#define SDR_READING_NONANALOG   ( (u8)3 )
+#define SDR_READING_UNSIGNED    ( (uint8_t)0 )
+#define SDR_READING_1SCOMP      ( (uint8_t)1 )
+#define SDR_READING_2SCOMP      ( (uint8_t)2 )
+#define SDR_READING_NONANALOG   ( (uint8_t)3 )
 
 /* Max size of an SDR of type SDR_FULL.  SDR_COMPACT records are smaller. */
 #define SDR_MAX_SIZE            ( 64 )
 
 /* Chassis control codes */
-#define CHASSIS_POWER_DOWN      ( (u8)0x00 )
-#define CHASSIS_POWER_UP        ( (u8)0x01 )
-#define CHASSIS_POWER_CYCLE     ( (u8)0x02 )
-#define CHASSIS_HARD_RESET      ( (u8)0x03 )
-#define CHASSIS_PULSE_DUMP      ( (u8)0x04 )
-#define CHASSIS_ACPI_POWER_DOWN ( (u8)0x05 )
+#define CHASSIS_POWER_DOWN      ( (uint8_t)0x00 )
+#define CHASSIS_POWER_UP        ( (uint8_t)0x01 )
+#define CHASSIS_POWER_CYCLE     ( (uint8_t)0x02 )
+#define CHASSIS_HARD_RESET      ( (uint8_t)0x03 )
+#define CHASSIS_PULSE_DUMP      ( (uint8_t)0x04 )
+#define CHASSIS_ACPI_POWER_DOWN ( (uint8_t)0x05 )
 
 /* Sensor Type Codes */
-#define IPMI_SENSOR_TEMPERATURE     ( (u8)0x01 )
-#define IPMI_SENSOR_VOLTAGE         ( (u8)0x02 )
-#define IPMI_SENSOR_CURRENT         ( (u8)0x03 )
-#define IPMI_SENSOR_FAN             ( (u8)0x04 )
-#define IPMI_SENSOR_POWER_SUPPLY    ( (u8)0x08 )
-#define IPMI_SENSOR_POWER_UNIT      ( (u8)0x09 )
-#define IPMI_SENSOR_COOLING_DEVICE  ( (u8)0x0A )
-#define IPMI_SENSOR_MEMORY          ( (u8)0x0C )
+#define IPMI_SENSOR_TEMPERATURE     ( (uint8_t)0x01 )
+#define IPMI_SENSOR_VOLTAGE         ( (uint8_t)0x02 )
+#define IPMI_SENSOR_CURRENT         ( (uint8_t)0x03 )
+#define IPMI_SENSOR_FAN             ( (uint8_t)0x04 )
+#define IPMI_SENSOR_POWER_SUPPLY    ( (uint8_t)0x08 )
+#define IPMI_SENSOR_POWER_UNIT      ( (uint8_t)0x09 )
+#define IPMI_SENSOR_COOLING_DEVICE  ( (uint8_t)0x0A )
+#define IPMI_SENSOR_MEMORY          ( (uint8_t)0x0C )
 
 /* Sensor Unit Type Codes from the IPMI spec */
 #define IPMI_UNIT_UNSPECIFIED   0
@@ -163,512 +159,4 @@
 
 
 
-/** \name IPMI Functions */
-/** \{ */
-
-/** \brief Send the IPMI Get Sensor Reading command and get the response
- *
- *  Send the GetSensorReading command to the specified slave with \a sensor as
- *  the sensor number, and get the response.
- *
- *  \param slave The slave address of the IPMI device (8-bit format)
- *  \param sensor The sensor number on the IPMI device
- *  \param reading The address of a u8 that will be filled with the sensor
- *  reading.  Note that this is a raw sensor value which must be converted
- *  by use of the \ref ipmi_convert_reading function.
- *  \param response The address of a \ref GetSensorReadingResponseStruct
- *  if you want the entire sensor response, not just the sensor reading.
- *  Pass \c NULL if you just want the sensor reading.
- *
- *  \retval "IPMI response code" Success
- *  \retval HHM_FAILURE The sensor reading could not be retrieved.
- *
- *  \note For almost all sensors, the IPMI response code should be 0x00.
- *  Some devices might return other completion codes to convey OEM specific
- *  information, or just to be contrary.  If the behaviour of a particular
- *  device is not well known with respect to completion codes, assume that if
- *  a completion code other than 0x00 is returned, the value in \a reading
- *  is invalid.
- */
-
-/*@external@*/extern int
-ipmi_get_sensor_reading( u8 slave, u8 sensor, /*@out@*/u8 *reading,
-                         /*@null@*//*@out@*/GetSensorReadingResponseStruct *response )
-/*@globals fileSystem@*/
-/*@modifies *reading,fileSystem,response@*/;
-
-/** \brief Get a reservation to access the SDR repository
- *
- *  This is required for certain IPMI commands, such as GetSDR when doing
- *  partial reads and from non-zero offsets, as well as other commands.
- *  See the IPMI spec for details.
- *
- *  \param slave The slave address of the IPMI device (8-bit format)
- *  \param response A pointer to an \ref IPMBReserveSDRRepositoryStruct that
- *  this function fills in
- *
- *  \retval "IPMI Completion Code" Success
- *  \retval HHM_FAILURE Failure, errno set
- *
- *  \note For almost all sensors, the IPMI response code should be 0x00.
- *  Some devices might return other completion codes to convey OEM specific
- *  information, or just to be contrary.  If the behaviour of a particular
- *  device is not well known with respect to completion codes, assume that if
- *  a completion code other than 0x00 is returned, the value in \a reading
- *  is invalid.
- */
-
-/*@external@*/extern int
-ipmi_reserve_sdr_repository( u8 slave, /*@out@*/IPMBReserveSDRRepositoryStruct *response )
-/*@globals fileSystem@*/
-/*@modifies *response,fileSystem@*/;
-
-
-/** \brief Get a reservation to access the SEL
- *
- *  Get a reservation to access the SEL.  This is required for
- *  certain IPMI commands  See the IPMI spec for details.
- *
- *  \param slave The slave address of the IPMI device (8-bit format)
- *  \param response An \ref ReserveSELResponseStruct that this
- *  function fills in.
- *  
- *  \retval "IPMI Completion Code" Success
- *  \retval HHM_FAILURE Failure, errno set
- *
- *  \note For almost all sensors, the IPMI response code should be 0x00.
- *  Some devices might return other completion codes to convey OEM specific
- *  information, or just to be contrary.  If the behaviour of a particular
- *  device is not well known with respect to completion codes, assume that if
- *  a completion code other than 0x00 is returned, the value in \a reading
- *  is invalid.
- */
-
-/*@external@*/extern int
-ipmi_reserve_sel_repository( u8 slave, /*@out@*/ReserveSELResponseStruct *response )	//jimbo notice!
-/*@globals fileSystem@*/
-/*@modifies *response,fileSystem@*/;
-
-
-/** \brief Read an SDR entry or part of an SDR entry from an IPMI device
- *
- *  Read an SDR entry from the SDR repository.  Usually only BMCs have SDR
- *  repositories.  SDR entries have useful info such as sensor numbers,
- *  sensor types, and data conversion equations, and can be used to determine
- *  the type of sensors available, and how to monitor them.
- *  This is probably not the function you are looking for.  This function is
- *  a raw interface to the GetSDR function, suitable for performing partial
- *  reads and testing.  If you just want to read the entire SDR entry, use
- *  \ref ipmi_get_sdr_full which is much easier to use.
- *
- *  \param slave The slave address of the IPMI device (8-bit format)
- *  \param reservation_id An SDR reservation ID obtained from the 
- *  \ref ipmi_reserve_sdr_repository command, or zero if not doing a partial
- *  read and \a offset_into_record is zero.
- *  \param record_id The SDR record ID to read
- *  \param bytes_to_read The number of bytes to read from the record. Pass
- *  0xFF to read the entire record.   Be aware, however, that most BMCs do not
- *  support sending a response large enough to contain the entire record.
- *  \param offset_into_record The starting point for the SDR read operation in
- *  the record.  If this is not 0, you need to call
- *  \ref ipmi_reserve_sdr_repository before this function.
- *  \param record_data A buffer that will be filled in with the entire GetSDR
- *  response (cast this buffer to an \ref IPMBGetSDRResponseStruct after
- *  calling).  The length of the SDR entry is variable, so the data buffer
- *  should be ~255 bytes long to be safe.
- *
- *  \retval "Length of the SDR read" Success.  The IPMI completion code is 
- *  contained within the \ref IPMBGetSDRResponseStruct returned in
- *  \a record_data
- *  \retval HHM_FAILURE Failure, errno set
- *
- *  \note For almost all sensors, the IPMI response code should be 0x00.
- *  Some devices might return other completion codes to convey OEM specific
- *  information, or just to be contrary.  If the behaviour of a particular
- *  device is not well known with respect to completion codes, assume that if
- *  a completion code other than 0x00 is returned, the value in \a reading
- *  is invalid.
- */
-/*@external@*/extern int
-ipmi_get_sdr( u8 slave, u16 reservation_id, u16 record_id,
-              u8 offset_into_record, u8 bytes_to_read, /*@out@*/u8 *record_data )
-/*@globals fileSystem@*/
-/*@modifies *record_data,fileSystem@*/;
-
-
-/** \brief Read an entire SDR entry from an IPMI device
- *
- *  Like \ref ipmi_get_sdr, but this command always reads the entire SDR entry,
- *  even if it needs to break the operation down into a series of partial
- *  reads.  Like \ref ipmi_get_sdr, \a record_data should be able to accomodate
- *  255 bytes.
- *
- *  \param slave The slave address of the IPMI device (8-bit format)
- *  \param record_id The SDR record to read
- *  \param record_data A buffer the function fills in that will contain the
- *  \ref IPMBGetSDRResponseStruct and the entire SDR entry specified in 
- *  \a record_id
- *
- *  \retval "Length of the SDR read" Success.  The completion code is contained
- *  within the \ref IPMBGetSDRResponseStruct returned in \a record_data
- *  \retval HHM_FAILURE Failure, errno set
- *
- *  \note For almost all sensors, the IPMI response code should be 0x00.
- *  Some devices might return other completion codes to convey OEM specific
- *  information, or just to be contrary.  If the behaviour of a particular
- *  device is not well known with respect to completion codes, assume that if
- *  a completion code other than 0x00 is returned, the value in \a reading
- *  is invalid.
- */
-/*@external@*/extern int
-ipmi_get_sdr_full( u8 slave, u16 record_id, /*@out@*/u8 *record_data )
-/*@globals fileSystem@*/
-/*@modifies *record_data,fileSystem@*/;
-
-
-/** \brief Get an SEL entry from an IPMI device
- *
- *  Read an SEL entry from the SEL.  Usually only BMCs have an SEL.  This is
- *  probably not the function you are looking for.  This function is a raw
- *  interface to the GetSEL function, suitable for performing partial reads
- *  and testing.  If you just want to read the entire SEL entry, use
- *  \ref ipmi_get_sel_full, which is much easier to use.
- *
- *  \param slave The slave address of the IPMI device (8-bit format)
- *  \param reservation_id An SEL reservation ID obtained from the
- *  \ref ipmi_reserve_sel_repository command, or zero if not doing a partial
- *  read and \a offset_into_record is zero.
- *  \param record_id The SEL record ID to read.
- *  \param offset_into_record The offset into the specified record to read
- *  from.  Zero for the beginning of the record.
- *  \param bytes_to_read The number of bytes to read from the record. Pass
- *  0xFF to read the entire record.   Be aware, however, that most BMCs do
- *  not support sending a response large enough to contain the entire record
- *  \param response A \ref GetSELEntryResponseStruct that will be filled in
- *  with the entire GetSEL response.
- *
- *  \retval "IPMI Completion Code" Success
- *  \retval HHM_FAILURE Failure, errno set
- *
- *  \note For almost all sensors, the IPMI response code should be 0x00.
- *  Some devices might return other completion codes to convey OEM specific
- *  information, or just to be contrary.  If the behaviour of a particular
- *  device is not well known with respect to completion codes, assume that if
- *  a completion code other than 0x00 is returned, the value in \a reading
- *  is invalid.
- */
-///*@external@*/extern int
-//ipmi_get_sel_entry( u8 slave, u16 reservation_id, u16 record_id,
-//                    u8 offset_into_record, u8 bytes_to_read,
-//                    /*@out@*/GetSELEntryResponseStruct *response )
-/*@globals fileSystem@*/
-/*@modifies *response,fileSystem@*/;
-
-
-/** \brief Get an entire SEL entry from an IPMI device
- *
- *  Like \ref ipmi_get_sel_entry, but this command always reads the entire SEL
- *  entry, even if it needs to break the operation down into a series of
- *  partial reads
- *
- *  \param slave The slave address of the IPMI device (8-bit format)
- *  \param record_id The SEL entry to read
- *  \param response A \ref GetSELEntryResponseStruct pointer which will
- *  be filled in by this function.
- *
- *  \retval "IPMI Completion Code" Success
- *  \retval HHM_FAILURE Failure, errno set
- */
-///*@external@*/extern int
-//ipmi_get_sel_full( u8 slave, u16 record_id, /*@out@*/GetSELEntryResponseStruct *response )
-///*@globals fileSystem@*/
-///*@modifies *response,fileSystem@*/;
-
-
-/** \brief Send the IPMI Get Device ID command and get the response
- *
- *  Send the get device ID IPMI command to a slave address on the I2C bus, and
- *  receive the response.
- *
- *  \param slave Slave address of the IPMI device (8-bit format)
- *  \param response The above slave's complete response to the get device
- *  ID command.
- *
- *  \retval "IPMI Completion Code" Succes
- *  \retval HHM_FAILURE Failure, errno set
- *
- *  \note For almost all sensors, the IPMI response code should be 0x00.
- *  Some devices might return other completion codes to convey OEM specific
- *  information, or just to be contrary.  If the behaviour of a particular
- *  device is not well known with respect to completion codes, assume that if
- *  a completion code other than 0x00 is returned, the value in \a reading
- *  is invalid.
- */
-///*@external@*/extern int
-//ipmi_get_device_id( u8 slave, /*@out@*/IPMBGetDeviceIDResponseStruct *response )
-///*@globals fileSystem@*/
-///*@modifies *response,fileSystem@*/;
-
-
-/** \brief Send the IPMI Chassis Power Down command
- *
- *  \param slave Slave address of the IPMI device (8-bit format)
- *
- *  \retval "IPMI Completion Code" Success
- *  \retval HHM_FAILURE Failure, errno set
- *
- *  \note For almost all sensors, the IPMI response code should be 0x00.
- *  Some devices might return other completion codes to convey OEM specific
- *  information, or just to be contrary.  If the behaviour of a particular
- *  device is not well known with respect to completion codes, assume that if
- *  a completion code other than 0x00 is returned, the value in \a reading
- *  is invalid.
- */
-/*@external@*/extern int
-ipmi_chassis_power_down( u8 slave )
-/*@globals fileSystem@*//*@modifies fileSystem@*/;
-
-
-/** \brief Send the IPMI Chassis Power Up command
- *
- *  \param slave Slave address of the IPMI device (8-bit format)
- *
- *  \retval "IPMI Completion Code" Success
- *  \retval HHM_FAILURE Failure, errno set
- *
- *  \note For almost all sensors, the IPMI response code should be 0x00.
- *  Some devices might return other completion codes to convey OEM specific
- *  information, or just to be contrary.  If the behaviour of a particular
- *  device is not well known with respect to completion codes, assume that if
- *  a completion code other than 0x00 is returned, the value in \a reading
- *  is invalid.
- */
-/*@external@*/extern int
-ipmi_chassis_power_up( u8 slave )
-/*@globals fileSystem@*//*@modifies fileSystem@*/;
-
-
-/** \brief Send the IPMI Chassis Power Cycle command
- *
- *  \param slave Slave address of the IPMI device (8-bit format)
- *
- *  \retval "IPMI Completion Code" Success
- *  \retval HHM_FAILURE Failure, errno set
- *
- *  \note For almost all sensors, the IPMI response code should be 0x00.
- *  Some devices might return other completion codes to convey OEM specific
- *  information, or just to be contrary.  If the behaviour of a particular
- *  device is not well known with respect to completion codes, assume that if
- *  a completion code other than 0x00 is returned, the value in \a reading
- *  is invalid.
- */
-/*@external@*/extern int
-ipmi_chassis_power_cycle( u8 slave )
-/*@globals fileSystem@*//*@modifies fileSystem@*/;
-
-
-/** \brief Send the IPMI Chassis Hard Reset command
- *
- *  \param slave Slave address of the IPMI device (8-bit format)
- *
- *  \retval "IPMI Completion Code" Success
- *  \retval HHM_FAILURE Failure, errno set
- *
- *  \note For almost all sensors, the IPMI response code should be 0x00.
- *  Some devices might return other completion codes to convey OEM specific
- *  information, or just to be contrary.  If the behaviour of a particular
- *  device is not well known with respect to completion codes, assume that if
- *  a completion code other than 0x00 is returned, the value in \a reading
- *  is invalid.
- */
-/*@external@*/extern int
-ipmi_chassis_hard_reset( u8 slave )
-/*@globals fileSystem@*//*@modifies fileSystem@*/;
-
-
-/** \brief Send the IPMI Chassis ACPI Power Down command
- *
- *  \param slave Slave address of the IPMI device (8-bit format)
- *
- *  \retval "IPMI Completion Code" Success
- *  \retval HHM_FAILURE Failure, errno set
- *
- *  \note For almost all sensors, the IPMI response code should be 0x00.
- *  Some devices might return other completion codes to convey OEM specific
- *  information, or just to be contrary.  If the behaviour of a particular
- *  device is not well known with respect to completion codes, assume that if
- *  a completion code other than 0x00 is returned, the value in \a reading
- *  is invalid.
- */
-/*@external@*/extern int
-ipmi_chassis_acpi_power_down( u8 slave )
-/*@globals fileSystem@*//*@modifies fileSystem@*/;
-
-
-/** \brief Send an arbitrary IPMI command, and get the response
- *
- *  Send any IPMI command your heart desires to any I2C/LUN combo and receive
- *  the response.  See the IPMI spec for further info.
- *
- *  \param slave Slave address of the IPMI device (8-bit format)
- *  \param netFn The net function of the command to send
- *  \param targetLUN The LUN of the IPMI device
- *  \param command A buffer containing the command number, and any extra data
- *  which is needed for the command.
- *  \param cmd_len The length of the command buffer
- *  \param response_buffer The buffer which will be filled with the response
- *  to your ipmi command.
- *  \param response_len The size of the buffer to which
- *  \a response_buffer points
- *
- *  \retval "Length of the IPMI response" Success
- *  \retval HHM_FAILURE Failure, errno set
- */
-/*@external@*/extern int
-ipmi_generic_command( u8 slave, u8 netFn, u8 targetLUN, u8 *command,
-                      size_t cmd_len, /*@out@*/u8 *response_buffer,
-                      size_t response_len )
-/*@globals fileSystem@*/
-/*@modifies *response_buffer,fileSystem@*/;
-
-
-/** \brief Convert a raw sensor reading to its final reading using an SDR
- *
- *  Use the standard IPMI method and SDR data to convert a raw sensor reading
- *  into its converted value.  See the IPMI spec for further info on this
- *  conversion.
- *
- *  \param sdr_buffer A pointer to a complete SDR entry which contains reading
- *  conversion data.  IE, it is a Full SDR entry.
- *  \param raw_reading The raw sensor reading you want to convert
- *  \param converted_reading Pointer to an s32 that will be assigned the
- *  converted reading on success.
- *
- *  \retval 0 Success, or sensor out of IPMI sensor min/max reading range, with
- *  0 in \a converted_reading
- *  \retval HHM_FAILURE Not enough information to perform the conversion
- */
-/*@external@*/extern int
-ipmi_convert_reading( u8 *sdr_buffer, u8 raw_reading, /*@out@*/float *converted_reading )
-/*@modifies *converted_reading@*/;
-
-
-/** \brief Use an SDR entry to read the corresponding sensor
- *
- *  Use a (usually saved) SDR entry to read the current value of
- *  a sensor.  The reading is performed as specified by the SDR
- *  entry passed in \a sdr_buffer.  The reading obtained is the
- *  final, converted sensor reading
- *
- *  \param sdr_buffer Pointer to a complete SDR buffer that contains
- *  information on accessing a sensor.
- *  \param raw_reading The raw sensor reading fresh from the BMC.
- *  \param reading The converted sensor reading read and converted
- *  as specified by the SDR entry.
- *  \param discrete Pointer to a u8 used as a boolean, indicates if
- *  the sensor read is a discrete sensor instead of an analog sensor
- *
- *  \retval HHM_FAILURE Failure
- *  \retval IPMI_SENSOR_DISABLED Reading is invalid, this sensor is disabled
- *  \retval 0 Success
- */
-/*@external@*/extern int
-hhm_access_sdr_sensors( u8 *sdr_buffer, /*@out@*/u8 *raw_reading,
-                        /*@out@*/float *reading, /*@out@*/u8 *discrete )
-/*@globals fileSystem@*/
-/*@modifies *raw_reading,*reading,fileSystem,discrete@*/;
-
-/** \} */
-
-/** \brief Extract a descriptive string from an SDR entry
- *
- *  Read the text description field from the provided SDR, convert it
- *  to a nice standard ascii string, and copy it into \a description.
- *
- *  \param sdr_buffer Pointer to a buffer containing an SDR
- *  \param description Pointer to a buffer that will be filled with the
- *  description of this SDR.  \a Description should have 17 bytes of storage,
- *  to account for the 16 possible bytes of description defined by IPMI, and
- *  the \c NULL terminator.
- *
- *  \retval 0 Success
- *  \retval HHM_FAILURE Failure, errno set
- */
-/*@external@*/extern int
-extract_sdr_id( u8 *sdr_buffer, /*@out@*/char *description )
-/*@modifies *description@*/;
-
-
-/** \brief Convert an IPMI (or AMI OEM) unit type code to a descriptive string
- *
- *  Convert an IPMI or AMI OEM unit type code into a string suitable for
- *  display.  This function could (for example), convert the unit type 0x01 to
- *  the string "degrees C".
- *
- *  \param unit_type_code An IPMI (or AMI OEM) unit type code
- *  \param unit_type_string A char buffer that will contain the unit string
- *  on completion.
- *  \param unit_string_len The length of the unit string.  Expect around 20
- *  chars at most, but there is no internal limit to any particular size.
- *
- *  \retval 0 Success
- *  \retval HHM_FAILURE Failure, errno set, "Unrecognized" is set in
- *  \a unit_type_string.
- */
-/*@external@*/extern int
-sdk_unit_to_string( u8 unit_type_code, /*@out@*/char *unit_type_string,
-                    size_t unit_string_len )
-/*@modifies unit_type_string@*/;
-
-
-/** \brief Generate a string corresponding to a discrete reading code
- *
- *  Convert a discrete state (supplied in \a reading) into a string using the
- *  \a reading_type_code and the IPMI table of discrete states.
- *
- *  \param reading The sensor reading (discrete state)
- *  \param reading_type_code The reading type code from the SDR
- *  \param sensor_type The sensor type code from the SDR
- *  \param discrete_string Pointer to a buffer we will fill with text
- *  describing the discrete state
- *  \param string_size The amount of storage at \a discrete_string
- *
- *  \retval 0 Success
- *  \retval HHM_FAILURE Failure, errno set
- */
-/*@external@*/extern int
-ipmi_discrete_reading_string( s32 reading, u8 reading_type_code,
-                              u8 sensor_type,
-                              /*@out@*/char *discrete_string,
-                              size_t string_size )
-/*@modifies discrete_string@*/;
-
-
-/** \brief Get the threshold state of a sensor based on its SDR
- *
- *  Determine the state of a given sensor based on threshold information
- *  from its SDR.  This state is a bitfield with individual bits indicating
- *  which thresholds have been passed.  A bit is set to 1 when the threshold
- *  it represents has been passed.  This function also handles threshold
- *  hysteresis values correctly.
- *
- *  \param sensor_reading A raw, unconverted sensor reading
- *  \param sdr_buffer A pointer to a buffer containing an SDR
- *  \param last_state The previous state of the sensor, obtained from a prior
- *  call to this function.  Pass \ref THRESH_UNINITIALIZED if there is no
- *  \a last_state because this is the first call to \ref get_sdr_sensor_state
- *  for this sensor.
- *  \param current_state Variable that will be filled with the current state
- *  of the sensor, based on information passed in \a sensor_reading and 
- *  \a sdr_buffer.  See \ref THRESH_UP_NONCRIT for an example of a state
- *  bitfield.
- *
- *  \retval 0 Success
- *  \retval HHM_FAILURE Failure, errno set
- */
-/*@external@*/extern int
-get_sdr_sensor_state( u8 sensor_reading, u8 *sdr_buffer, u16 last_state,
-                      /*@out@*/u16 *current_state )
-/*@modifies *current_state@*/;
-
 #endif

+ 10 - 10
app/goahead-5.1.0/src/libipmi/inc/libipmi_sensor.h

@@ -136,16 +136,16 @@ struct sensor_info
     float high_non_recov_thresh;   /*!< High non-recoverable threshold */
 };
 
-/* IPMI threshold state definitions for monitoring */
-#define THRESH_UNINITIALIZED        ( (u16)0x00 )
-#define THRESH_NORMAL               ( (u16)0x01 )
-#define THRESH_UP_NONCRIT           ( (u16)0x02 )
-#define THRESH_UP_CRITICAL          ( (u16)0x04 )
-#define THRESH_LOW_NONCRIT          ( (u16)0x08 )
-#define THRESH_LOW_CRITICAL         ( (u16)0x10 )
-#define THRESH_ACCESS_FAILED        ( (u16)0x20 )
-#define THRESH_UP_NON_RECOV         ( (u16)0x40 )
-#define THRESH_LOW_NON_RECOV        ( (u16)0x80 )
+// /* IPMI threshold state definitions for monitoring */
+// #define THRESH_UNINITIALIZED        ( (u16)0x00 )
+// #define THRESH_NORMAL               ( (u16)0x01 )
+// #define THRESH_UP_NONCRIT           ( (u16)0x02 )
+// #define THRESH_UP_CRITICAL          ( (u16)0x04 )
+// #define THRESH_LOW_NONCRIT          ( (u16)0x08 )
+// #define THRESH_LOW_CRITICAL         ( (u16)0x10 )
+// #define THRESH_ACCESS_FAILED        ( (u16)0x20 )
+// #define THRESH_UP_NON_RECOV         ( (u16)0x40 )
+// #define THRESH_LOW_NON_RECOV        ( (u16)0x80 )
 
 #define SENSOR_NOT_AVAILABLE        0xD5
 #define UNABLE_TO_READ_SENSOR       0x20

+ 10 - 10
app/goahead-5.1.0/src/libipmi/inc/libsensor.h

@@ -12,16 +12,16 @@
 
 #include "libipmi_session.h"
 
-/* IPMI threshold state definitions for monitoring */
-#define THRESH_UNINITIALIZED        ( (u16)0x00 )
-#define THRESH_NORMAL               ( (u16)0x01 )
-#define THRESH_UP_NONCRIT           ( (u16)0x02 )
-#define THRESH_UP_CRITICAL          ( (u16)0x04 )
-#define THRESH_LOW_NONCRIT          ( (u16)0x08 )
-#define THRESH_LOW_CRITICAL         ( (u16)0x10 )
-#define THRESH_ACCESS_FAILED        ( (u16)0x20 )
-#define THRESH_UP_NON_RECOV         ( (u16)0x40 )
-#define THRESH_LOW_NON_RECOV        ( (u16)0x80 )
+// /* IPMI threshold state definitions for monitoring */
+// #define THRESH_UNINITIALIZED        ( (u16)0x00 )
+// #define THRESH_NORMAL               ( (u16)0x01 )
+// #define THRESH_UP_NONCRIT           ( (u16)0x02 )
+// #define THRESH_UP_CRITICAL          ( (u16)0x04 )
+// #define THRESH_LOW_NONCRIT          ( (u16)0x08 )
+// #define THRESH_LOW_CRITICAL         ( (u16)0x10 )
+// #define THRESH_ACCESS_FAILED        ( (u16)0x20 )
+// #define THRESH_UP_NON_RECOV         ( (u16)0x40 )
+// #define THRESH_LOW_NON_RECOV        ( (u16)0x80 )
 
 //#pragma pack(1)
 struct sensor_data

+ 41 - 40
app/goahead-5.1.0/src/libipmi/src/sensor_helpers.c

@@ -28,6 +28,7 @@
 
 #include "com_BmcType.h"
 #include "com_IPMIDefs.h"
+#include "libipmi.h"
 
 #if 0
 /* A bunch of defines that SDRRecord needs.  We don't care about the actual */
@@ -66,7 +67,7 @@ static uint8_t lessthan( uint8_t x, uint8_t y, number_type format )
             if( x < y )
                 return( TRUE );
             else
-                return( FALSE );
+                return( 0 );
             
             /*@-unreachable@*/
             break;
@@ -87,7 +88,7 @@ static uint8_t lessthan( uint8_t x, uint8_t y, number_type format )
             if( signed_x < signed_y )
                 return( TRUE );
             else
-                return( FALSE );
+                return( 0 );
             
             /*@-unreachable@*/
             break;
@@ -100,9 +101,9 @@ static uint8_t lessthan( uint8_t x, uint8_t y, number_type format )
             signed_y = (int)*( (char *)&y );
             
             if( signed_x < signed_y )
-                return( TRUE );
+                return( 1 );
             else
-                return( FALSE );
+                return( 0 );
 
             /*@-unreachable@*/
             break;
@@ -111,11 +112,11 @@ static uint8_t lessthan( uint8_t x, uint8_t y, number_type format )
         default:
             printf( "Attempted numeric comparison of "
                    "non-numeric sensor readings\n" );
-            return( FALSE );
+            return( 0 );
     }
     
     printf( "Programmer failure in lessthan()\n" );
-    return( FALSE );
+    return( 1 );
 }
 
 
@@ -129,9 +130,9 @@ static uint8_t greaterthan( uint8_t x, uint8_t y, number_type format )
         case Unsigned:
             /* Numbers are already unsigned, just compare */
             if( x > y )
-                return( TRUE );
+                return( 1 );
             else
-                return( FALSE );
+                return( 0 );
             
             /*@-unreachable@*/
             break;
@@ -150,9 +151,9 @@ static uint8_t greaterthan( uint8_t x, uint8_t y, number_type format )
                 signed_y = (int)y;
 
             if( signed_x > signed_y )
-                return( TRUE );
+                return( 1 );
             else
-                return( FALSE );
+                return( 0 );
             
             /*@-unreachable@*/
             break;
@@ -165,9 +166,9 @@ static uint8_t greaterthan( uint8_t x, uint8_t y, number_type format )
             signed_y = (int)*( (char *)&y );
             
             if( signed_x > signed_y )
-                return( TRUE );
+                return( 1 );
             else
-                return( FALSE );
+                return( 0 );
 
             /*@-unreachable@*/
             break;
@@ -176,11 +177,11 @@ static uint8_t greaterthan( uint8_t x, uint8_t y, number_type format )
         default:
             printf( "Attempted numeric comparison of "
                    "non-numeric sensor readings\n" );
-            return( FALSE );
+            return( 0 );
     }
 
     printf( "Programmer failure in greaterthan()\n" );
-    return( FALSE );
+    return( 0 );
 }
 
 
@@ -188,7 +189,7 @@ static float power( int base, int power )
 {
     int i;
     float retval = 1;
-    uint8_t invert = false;
+    uint8_t invert = 0;
 
     if( power == 0 )
         return( (float)1 );
@@ -196,7 +197,7 @@ static float power( int base, int power )
     if( power < 0 )
     {
         power = -power;
-        invert = true;
+        invert = 1;
     }
 
     for( i = 1; i <= power; i++ )
@@ -324,7 +325,7 @@ int ipmi_convert_reading( uint8_t *sdr_buffer, uint8_t raw_reading, float *conve
 {
     SDRRecHdr_T *header = (SDRRecHdr_T *)sdr_buffer;
     FullSensorRec_T *record = (FullSensorRec_T *)sdr_buffer;
-    uint8 L;
+    uint8_t L;
     int M, B, K1, K2;
     int raw_number;
     int sensor_min, sensor_max;
@@ -411,13 +412,13 @@ int ipmi_convert_reading( uint8_t *sdr_buffer, uint8_t raw_reading, float *conve
     if( ( record->M_Tolerance & (uint8_t)0x80 ) != (uint8_t)0 )
     {
         /* Number is negative */
-        M = M + ( ( (u16)record->M_Tolerance & (u16)0xC0 ) << 2 );
+        M = M + ( ( (uint16_t)record->M_Tolerance & (uint16_t)0xC0 ) << 2 );
         M = -( ( ~M & 0x1ff ) + 1 );
     }
     else
     {
         /* Number is positive */
-        M = M + ( ( (u16)record->M_Tolerance & (u16)0xC0 ) << 2 );
+        M = M + ( ( (uint16_t)record->M_Tolerance & (uint16_t)0xC0 ) << 2 );
     }
 
     /* Convert B from split 10 bit 2s-complement to our int format */
@@ -425,13 +426,13 @@ int ipmi_convert_reading( uint8_t *sdr_buffer, uint8_t raw_reading, float *conve
     if( ( record->B_Accuracy & (uint8_t)0x80 ) != (uint8_t)0 )
     {
         /* Number is negative */
-        B = B + ( ( (u16)record->B_Accuracy & (u16)0xC0 ) << 2 );
+        B = B + ( ( (uint16_t)record->B_Accuracy & (uint16_t)0xC0 ) << 2 );
         B = -( ( ~B & 0x1ff ) + 1 );
     }
     else
     {
         /* Number is positive */
-        B = B + ( ( (u16)record->B_Accuracy & (u16)0xC0 ) << 2 );
+        B = B + ( ( (uint16_t)record->B_Accuracy & (uint16_t)0xC0 ) << 2 );
     }
 
     /* Convert K1 from 4 bit 2s-complement to our int format */
@@ -454,7 +455,7 @@ int ipmi_convert_reading( uint8_t *sdr_buffer, uint8_t raw_reading, float *conve
 }
 
 
-int get_sdr_sensor_state( uint8_t sensor_reading, uint8_t *sdr_buffer, u16 *current_state )
+int get_sdr_sensor_state( uint8_t sensor_reading, uint8_t *sdr_buffer, uint16_t *current_state )
 {
     SDRRecHdr_T *header = (SDRRecHdr_T *)sdr_buffer;
     number_type reading_format = Unsigned;
@@ -516,7 +517,7 @@ int get_sdr_sensor_state( uint8_t sensor_reading, uint8_t *sdr_buffer, u16 *curr
         else
         {
             /* This sensor is discrete */
-            *current_state = (u16)sensor_reading;
+            *current_state = (uint16_t)sensor_reading;
         }
     }
     else if( header->Type == COMPACT_SDR_REC )
@@ -524,7 +525,7 @@ int get_sdr_sensor_state( uint8_t sensor_reading, uint8_t *sdr_buffer, u16 *curr
         CompactSensorRec_T *record = (CompactSensorRec_T *)sdr_buffer;
 
         if( record->EventTypeCode > (uint8_t)1 )
-            *current_state = (u16)sensor_reading;
+            *current_state = (uint16_t)sensor_reading;
         else
             *current_state = THRESH_UNINITIALIZED;
     }
@@ -537,8 +538,8 @@ int get_sdr_sensor_state( uint8_t sensor_reading, uint8_t *sdr_buffer, u16 *curr
     return( 0 );
 }
 
-int GetSensorState(IPMI20_SESSION_T *pSession, INT8U sensor_reading, 
-	uint8_t *sdr_buffer, u16 *current_state, int timeout  )
+int GetSensorState(IPMI20_SESSION_T *pSession, uint8_t sensor_reading, 
+	uint8_t *sdr_buffer, uint16_t *current_state, int timeout  )
 {
 	SDRRecHdr_T *header = (SDRRecHdr_T *)sdr_buffer;
 	//number_type reading_format = Unsigned;
@@ -619,7 +620,7 @@ int GetSensorState(IPMI20_SESSION_T *pSession, INT8U sensor_reading,
 	   else
 	   {
 			/* This sensor is discrete */
-			*current_state = (u16)sensor_reading;
+			*current_state = (uint16_t)sensor_reading;
 	   }
 	}
 	else if( header->Type == COMPACT_SDR_REC )
@@ -627,7 +628,7 @@ int GetSensorState(IPMI20_SESSION_T *pSession, INT8U sensor_reading,
 		CompactSensorRec_T *record = (CompactSensorRec_T *)sdr_buffer;
 
 		if( record->EventTypeCode > (uint8_t)1 )
-		*current_state = (u16)sensor_reading;
+		*current_state = (uint16_t)sensor_reading;
 		else
 		*current_state = THRESH_UNINITIALIZED;
 	}
@@ -644,11 +645,11 @@ int GetSensorState(IPMI20_SESSION_T *pSession, INT8U sensor_reading,
 int read_sensor_sdrs( IPMI20_SESSION_T *pSession, struct sensor_info **sensor_list,
                       int timeout )
 {
-    uint16 wRet;
+    uint16_t wRet;
     SDRRepositoryAllocInfo_T alloc_info;
     SDRRepositoryInfo_T repo_info;
     int max_sdr_len;
-    uint8 *sdr_buffer;
+    uint8_t *sdr_buffer;
     int buffer_len;
     int i;
     struct sensor_info *sensor_buffer = NULL;
@@ -732,12 +733,12 @@ int read_sensor_sdrs( IPMI20_SESSION_T *pSession, struct sensor_info **sensor_li
             /* Only full records contain sensor conversion data */
             if( header->Type == FULL_SDR_REC )
             {
-                uint8_t inverse_linear = false;
+                uint8_t inverse_linear = 0;
                 FullSensorRec_T *record = (FullSensorRec_T *)( sdr_buffer + ( i * max_sdr_len ) );
                 float converted_threshold;
 
                 if( record->Linearization == 7 )
-                inverse_linear = true;
+                inverse_linear = 1;
 
                 /* Save Low Non-recoverable sensor threshold */
                 ipmi_convert_reading( (uint8_t *)record, record->LowerNonRecoverable,
@@ -815,7 +816,7 @@ int read_sensor_sdrs( IPMI20_SESSION_T *pSession, struct sensor_info **sensor_li
 //Min = 0x00, Max=0xff, Units1=0x00,Lin=0x00,Mval=25, Bval=0,M_Tol=0,B_Acc=0, R_B_Ex=0xfc
 int ipmi_conv_reading(uint8_t SDRType, uint8_t raw_reading, float *converted_reading ,uint8_t Min,uint8_t Max,uint8_t Units1,uint8_t Lin,uint8_t Mval,uint8_t Bval,uint8_t M_Tol,uint8_t B_Acc,uint8_t R_B_Ex)
 {
-    uint8 L;
+    uint8_t L;
     int M, B, K1, K2;
     int raw_number;
     int sensor_min, sensor_max;
@@ -905,13 +906,13 @@ int ipmi_conv_reading(uint8_t SDRType, uint8_t raw_reading, float *converted_rea
     if( ( M_Tol & (uint8_t)0x80 ) != (uint8_t)0 )
     {
         /* Number is negative */
-        M = M + ( ( (u16)M_Tol & (u16)0xC0 ) << 2 );
+        M = M + ( ( (uint16_t)M_Tol & (uint16_t)0xC0 ) << 2 );
         M = -( ( ~M & 0x1ff ) + 1 );
     }
     else
     {
         /* Number is positive */
-        M = M + ( ( (u16)M_Tol & (u16)0xC0 ) << 2 );
+        M = M + ( ( (uint16_t)M_Tol & (uint16_t)0xC0 ) << 2 );
     }
 
     /* Convert B from split 10 bit 2s-complement to our int format */
@@ -919,13 +920,13 @@ int ipmi_conv_reading(uint8_t SDRType, uint8_t raw_reading, float *converted_rea
     if( ( B_Acc & (uint8_t)0x80 ) != (uint8_t)0 )
     {
         /* Number is negative */
-        B = B + ( ( (u16)B_Acc & (u16)0xC0 ) << 2 );
+        B = B + ( ( (uint16_t)B_Acc & (uint16_t)0xC0 ) << 2 );
         B = -( ( ~B & 0x1ff ) + 1 );
     }
     else
     {
         /* Number is positive */
-        B = B + ( ( (u16)B_Acc & (u16)0xC0 ) << 2 );
+        B = B + ( ( (uint16_t)B_Acc & (uint16_t)0xC0 ) << 2 );
     }
 
     /* Convert K1 from 4 bit 2s-complement to our int format */
@@ -953,7 +954,7 @@ int ipmi_conv_reading(uint8_t SDRType, uint8_t raw_reading, float *converted_rea
  * @params SensorReading,SensorState,SDRType[in],Linear fn,SensorUnits1,SensorEvtType,AssertionEvtbyte1,AssertionEvtbyte2,DeaasertionEvtbyte1,DeassertionEvtbyte2
  * @returns Sensor state for FULL SDR Record
  */
-int SensorState( INT8U sensor_reading, u16 *current_state,uint8_t SDRType,uint8_t Lin,uint8_t Units1,uint8_t EvtType,uint8_t AssertEvt1,uint8_t AssertEvt2,uint8_t DeassertEvt1,uint8_t DeassertEvt2)
+int SensorState( uint8_t sensor_reading, uint16_t *current_state,uint8_t SDRType,uint8_t Lin,uint8_t Units1,uint8_t EvtType,uint8_t AssertEvt1,uint8_t AssertEvt2,uint8_t DeassertEvt1,uint8_t DeassertEvt2)
 {
   //  number_type reading_format = Unsigned;
 
@@ -1006,13 +1007,13 @@ int SensorState( INT8U sensor_reading, u16 *current_state,uint8_t SDRType,uint8_
         else
         {
             /* This sensor is discrete */
-            *current_state = (u16)sensor_reading;
+            *current_state = (uint16_t)sensor_reading;
         }
     }
     else if( SDRType == COMPACT_SDR_REC )
     {
         if( EvtType > (uint8_t)1 )
-        *current_state = (u16)sensor_reading;
+        *current_state = (uint16_t)sensor_reading;
         else
         *current_state = THRESH_UNINITIALIZED;
     }

+ 0 - 86
app/goahead-5.1.0/src/route.c

@@ -84,92 +84,6 @@ void personInfoAction(Webs *wp)
 }
 
 
-/*获取设备信息*/
-void getDeviceInfo(Webs *wp){
-    logmsg(2, "--------------------ggggggggg----------------");
-
-    uint16_t    wRet = LIBIPMI_E_SUCCESS;
-    GetDevIDRes_T   DeviceID;
-    char BuildTime[30] = {0};
-    char FwVersion[10] = {0};
-    //Create session
-    LIBIPMI_CreateSession(&wp->ipmi_session, 10);
-    sprintf(BuildTime, "%s %s", __DATE__, __TIME__);
-    wRet = IPMICMD_GetDeviceID( &wp->ipmi_session, &DeviceID, DEFAULT_TIMEOUT);
-    if (wRet == LIBIPMI_E_SUCCESS)
-    {
-        sprintf(FwVersion, "%d.%d", DeviceID.FirmwareRevision1, DeviceID.FirmwareRevision2);
-    }
-    printf("BuildTime: %s\n", BuildTime);
-    printf("FwVersion: %s\n", FwVersion);
-    //Close session
-    LIBIPMI_CloseSession(&wp->ipmi_session );
-    char *pStr;
-    int code = 200;
-    cJSON * root =  cJSON_CreateObject();
-    cJSON * data =  cJSON_CreateObject();
-    // cJSON * next =  cJSON_CreateObject();
-    cJSON_AddItemToObject(root, "data", data);//根节点下添加
-    cJSON_AddItemToObject(root, "msg", cJSON_CreateString(""));
-    cJSON_AddItemToObject(root, "code", cJSON_CreateString("200"));
-    cJSON_AddStringToObject(data, "BuildTime", BuildTime);
-    cJSON_AddStringToObject(data, "FwVersion", FwVersion);
-
-    pStr = cJSON_Print(root);
-
-    printf("first json:\n%s\n", pStr);
-    logmsg(2, "-----------------------jso1n----------------------%s", pStr);
-    websSetStatus(wp, 200);
-    websWriteHeaders(wp, -1, 0);
-    websWriteEndHeaders(wp); 
-    websWrite(wp, "[ {\"name\":\"kangkang\",\"age\":\"12\",\"gender\":\"male\"}, {\"name\":\"Jane\",\"age\":\"14\",\"gender\":\"female\"}]");
-    websDone(wp);
-    // retrun 1;
-}
-/*获取设备信息*/
-void getDeviceInfoBak(Webs *wp){
-    logmsg(2, "--------------------ggggggggg----------------");
-
-    uint16_t    wRet = LIBIPMI_E_SUCCESS;
-    GetDevIDRes_T   DeviceID;
-    char BuildTime[30] = {0};
-    char FwVersion[10] = {0};
-    //Create session
-    LIBIPMI_CreateSession(&wp->ipmi_session, 10);
-    sprintf(BuildTime, "%s %s", __DATE__, __TIME__);
-    wRet = IPMICMD_GetDeviceID( &wp->ipmi_session, &DeviceID, DEFAULT_TIMEOUT);
-    if (wRet == LIBIPMI_E_SUCCESS)
-    {
-        sprintf(FwVersion, "%d.%d", DeviceID.FirmwareRevision1, DeviceID.FirmwareRevision2);
-    }
-    printf("BuildTime: %s\n", BuildTime);
-    printf("FwVersion: %s\n", FwVersion);
-    //Close session
-    LIBIPMI_CloseSession(&wp->ipmi_session );
-    cchar *pStr;
-    int code = 200;
-    cJSON * root =  cJSON_CreateObject();
-    cJSON * data =  cJSON_CreateObject();
-    // cJSON * next =  cJSON_CreateObject();
-    cJSON_AddItemToObject(root, "data", data);//根节点下添加
-    cJSON_AddItemToObject(root, "msg", cJSON_CreateString(""));
-    cJSON_AddItemToObject(root, "code", cJSON_CreateString("200"));
-    cJSON_AddStringToObject(data, "BuildTime", BuildTime);
-    cJSON_AddStringToObject(data, "FwVersion", FwVersion);
-
-    pStr = cJSON_Print(root);
-
-    printf("first json:\n%s\n", pStr);
-    logmsg(2, "-----------------------jso1n----------------------%s", pStr);
-
-    websSetStatus(wp, 200);
-    websWriteHeaders(wp, -1, 0);
-    websWriteEndHeaders(wp); 
-    websWrite(wp, "[ {\"name\":\"kangkang\",\"age\":\"12\",\"gender\":\"male\"}, {\"name\":\"Jane\",\"age\":\"14\",\"gender\":\"female\"}]");
-    websFlush(wp, 0);
-    websDone(wp);
-}
-
 
 
 

+ 152 - 6
app/goahead-5.1.0/src/web_interface/src/dashboard.c

@@ -1,10 +1,55 @@
 #include    "goahead.h"
 #include    "libipmi_IPM.h"
 #include    "com_IPMIDefs.h"
+#include    "cJSON.h"
 
 /*获取设备信息*/
 void getDeviceInfo(Webs *wp){
-    int    wRet = LIBIPMI_E_SUCCESS;
+    logmsg(2, "--------------------ggggggggg----------------");
+
+    uint16_t    wRet = LIBIPMI_E_SUCCESS;
+    GetDevIDRes_T   DeviceID;
+    char BuildTime[30] = {0};
+    char FwVersion[10] = {0};
+    //Create session
+    LIBIPMI_CreateSession(&wp->ipmi_session, 10);
+    sprintf(BuildTime, "%s %s", __DATE__, __TIME__);
+    wRet = IPMICMD_GetDeviceID( &wp->ipmi_session, &DeviceID, DEFAULT_TIMEOUT);
+    if (wRet == LIBIPMI_E_SUCCESS)
+    {
+        sprintf(FwVersion, "%d.%d", DeviceID.FirmwareRevision1, DeviceID.FirmwareRevision2);
+    }
+    printf("BuildTime: %s\n", BuildTime);
+    printf("FwVersion: %s\n", FwVersion);
+    //Close session
+    LIBIPMI_CloseSession(&wp->ipmi_session );
+    char *pStr;
+    int code = 200;
+    cJSON * root =  cJSON_CreateObject();
+    cJSON * data =  cJSON_CreateObject();
+    // cJSON * next =  cJSON_CreateObject();
+    cJSON_AddItemToObject(root, "data", data);//根节点下添加
+    cJSON_AddItemToObject(root, "msg", cJSON_CreateString(""));
+    cJSON_AddItemToObject(root, "code", cJSON_CreateString("200"));
+    cJSON_AddStringToObject(data, "BuildTime", BuildTime);
+    cJSON_AddStringToObject(data, "FwVersion", FwVersion);
+
+    pStr = cJSON_Print(root);
+
+    printf("first json:\n%s\n", pStr);
+    logmsg(2, "-----------------------jso1n----------------------%s", pStr);
+    websSetStatus(wp, 200);
+    websWriteHeaders(wp, -1, 0);
+    websWriteEndHeaders(wp); 
+    websWrite(wp, "[ {\"name\":\"kangkang\",\"age\":\"12\",\"gender\":\"male\"}, {\"name\":\"Jane\",\"age\":\"14\",\"gender\":\"female\"}]");
+    websDone(wp);
+    // retrun 1;
+}
+/*获取设备信息*/
+void getDeviceInfoBak(Webs *wp){
+    logmsg(2, "--------------------ggggggggg----------------");
+
+    uint16_t    wRet = LIBIPMI_E_SUCCESS;
     GetDevIDRes_T   DeviceID;
     struct ifreq ifreq;
     int sock;
@@ -14,6 +59,8 @@ void getDeviceInfo(Webs *wp){
     char FwVersion[10] = {0};
     char MacAddr[18] = {0};
     char IpAddr[16] = {0};
+    
+
     //Create session
     LIBIPMI_CreateSession(&wp->ipmi_session, 10);
 
@@ -72,12 +119,111 @@ void getDeviceInfo(Webs *wp){
         }
     }
     close(sock);
-
     printf("BuildTime: %s\n", BuildTime);
     printf("FwVersion: %s\n", FwVersion);
-    printf("MacAddr: %s\n", MacAddr);
-    printf("IpAddr: %s\n", IpAddr);
-
     //Close session
     LIBIPMI_CloseSession(&wp->ipmi_session );
-}
+    cchar *pStr;
+    int code = 200;
+    cJSON * root =  cJSON_CreateObject();
+    cJSON * data =  cJSON_CreateObject();
+    // cJSON * next =  cJSON_CreateObject();
+    cJSON_AddItemToObject(root, "data", data);//根节点下添加
+    cJSON_AddItemToObject(root, "msg", cJSON_CreateString(""));
+    cJSON_AddItemToObject(root, "code", cJSON_CreateString("200"));
+    cJSON_AddStringToObject(data, "BuildTime", BuildTime);
+    cJSON_AddStringToObject(data, "FwVersion", FwVersion);
+
+    pStr = cJSON_Print(root);
+
+    printf("first json:\n%s\n", pStr);
+    logmsg(2, "-----------------------jso1n----------------------%s", pStr);
+
+    websSetStatus(wp, 200);
+    websWriteHeaders(wp, -1, 0);
+    websWriteEndHeaders(wp); 
+    websWrite(wp, "[ {\"name\":\"kangkang\",\"age\":\"12\",\"gender\":\"male\"}, {\"name\":\"Jane\",\"age\":\"14\",\"gender\":\"female\"}]");
+    websFlush(wp, 0);
+    websDone(wp);
+}
+
+
+// /*获取设备信息*/
+// void getDeviceInfo(Webs *wp){
+//     int    wRet = LIBIPMI_E_SUCCESS;
+//     GetDevIDRes_T   DeviceID;
+//     struct ifreq ifreq;
+//     int sock;
+//     struct sockaddr_in *myaddr;
+
+//     char BuildTime[30] = {0};
+//     char FwVersion[10] = {0};
+//     char MacAddr[18] = {0};
+//     char IpAddr[16] = {0};
+//     //Create session
+//     LIBIPMI_CreateSession(&wp->ipmi_session, 10);
+
+//     //get build time
+//     sprintf(BuildTime, "%s %s", __DATE__, __TIME__);
+
+//     //get firmware version
+//     wRet = IPMICMD_GetDeviceID( &wp->ipmi_session, &DeviceID, DEFAULT_TIMEOUT);
+//     if (wRet == LIBIPMI_E_SUCCESS)
+//     {
+//         sprintf(FwVersion, "%d.%d", DeviceID.FirmwareRevision1, DeviceID.FirmwareRevision2);
+//     }
+
+//     //get mac address
+//     if((sock=socket(AF_INET,SOCK_STREAM,0))<0)
+//     {
+//         printf("Get mac address socket fail!\n");
+//     }
+//     else
+//     {
+//         strcpy(ifreq.ifr_name,"eth0");
+//         if(ioctl(sock,SIOCGIFHWADDR,&ifreq)<0)
+//         {
+//             printf("Get mac address ioctl fail!\n");
+//         }
+//         else
+//         {
+//             sprintf(MacAddr, "%02x:%02x:%02x:%02x:%02x:%02x\n",
+//                     (unsigned char)ifreq.ifr_hwaddr.sa_data[0],
+//                     (unsigned char)ifreq.ifr_hwaddr.sa_data[1],
+//                     (unsigned char)ifreq.ifr_hwaddr.sa_data[2],
+//                     (unsigned char)ifreq.ifr_hwaddr.sa_data[3],
+//                     (unsigned char)ifreq.ifr_hwaddr.sa_data[4],
+//                     (unsigned char)ifreq.ifr_hwaddr.sa_data[5]);
+//         }
+//     }
+//     close(sock);
+
+//     //get ip address
+//     strcpy(ifreq.ifr_name, "eth0");
+//     if((sock=socket(AF_INET, SOCK_STREAM, 0))<0)
+//     {
+//         printf("Get ip address socket fail!\n");
+//     }
+//     else
+//     {
+//         wRet = ioctl(sock, SIOCGIFADDR, &ifreq);
+//         if(wRet < 0)
+//         {
+//             printf("Get ip address ioctl fail!\n");
+//         }
+//         else
+//         {
+//             myaddr = (struct sockaddr_in *)&(ifreq.ifr_addr);
+//             strcpy(IpAddr, inet_ntoa(myaddr->sin_addr));   
+//         }
+//     }
+//     close(sock);
+
+//     printf("BuildTime: %s\n", BuildTime);
+//     printf("FwVersion: %s\n", FwVersion);
+//     printf("MacAddr: %s\n", MacAddr);
+//     printf("IpAddr: %s\n", IpAddr);
+
+//     //Close session
+//     LIBIPMI_CloseSession(&wp->ipmi_session );
+// }

BIN
gd32450i-eval.uImage