diff options
author | Mike Jones <mjjones@us.ibm.com> | 2011-06-30 16:45:59 -0500 |
---|---|---|
committer | MIKE J. JONES <mjjones@us.ibm.com> | 2011-07-05 09:27:10 -0500 |
commit | 6c77e26e9454c6753d989f33430c4e361f6ff003 (patch) | |
tree | 063625734d8cf35214df22c0e1c76ac8a6c020d7 | |
parent | a62f6ced825e39e2f96ea207818c6a75b75744ab (diff) | |
download | talos-hostboot-6c77e26e9454c6753d989f33430c4e361f6ff003.tar.gz talos-hostboot-6c77e26e9454c6753d989f33430c4e361f6ff003.zip |
Adding Attribute Support to HWPF and some minor HWPF updates.
Change-Id: I278c782f98439f26e8535dfda026542b7bbfd641
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/163
Tested-by: Jenkins Server
Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com>
Reviewed-by: Andrew J. Geissler <andrewg@us.ibm.com>
-rw-r--r-- | src/include/usr/hwpf/fapi/fapiAttributeService.H | 401 | ||||
-rw-r--r-- | src/include/usr/hwpf/fapi/fapiHwAccess.H | 17 | ||||
-rw-r--r-- | src/include/usr/hwpf/fapi/fapiReturnCodes.H | 13 | ||||
-rw-r--r-- | src/include/usr/hwpf/fapi/fapiTarget.H | 13 | ||||
-rw-r--r-- | src/include/usr/hwpf/fapi/fapiUtil.H | 11 | ||||
-rw-r--r-- | src/include/usr/hwpf/hwp/fapiTestHwp.H | 12 | ||||
-rwxr-xr-x | src/include/usr/hwpf/hwp/fapiTestHwpAttr.H | 33 | ||||
-rwxr-xr-x | src/include/usr/hwpf/plat/fapiPlatAttributeService.H | 22 | ||||
-rw-r--r-- | src/usr/hwpf/fapi/fapiAttributeService.C | 187 | ||||
-rwxr-xr-x | src/usr/hwpf/fapi/fapiParseAttributeInfo.pl | 255 | ||||
-rw-r--r-- | src/usr/hwpf/fapi/fapiReturnCodeDataRef.C | 11 | ||||
-rw-r--r-- | src/usr/hwpf/fapi/makefile | 3 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/fapiHwpAttributeInfo.xml | 60 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/fapiTestHwp.C | 73 | ||||
-rwxr-xr-x | src/usr/hwpf/hwp/fapiTestHwpAttr.C | 513 | ||||
-rw-r--r-- | src/usr/hwpf/plat/fapiPlatUtil.C | 3 |
16 files changed, 921 insertions, 706 deletions
diff --git a/src/include/usr/hwpf/fapi/fapiAttributeService.H b/src/include/usr/hwpf/fapi/fapiAttributeService.H index 52981318a..e335be33a 100644 --- a/src/include/usr/hwpf/fapi/fapiAttributeService.H +++ b/src/include/usr/hwpf/fapi/fapiAttributeService.H @@ -2,22 +2,29 @@ * @file fapiAttributeService.H * * @brief Defines the FAPI_ATTR_GET and FAPI_ATTR_SET macros that a user calls - * to get/set attributes and the AttributeService functions that the - * macros use to get/set attributes + * to get/set attributes and a check function that the macros use to + * verify correct usage + */ + +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 06/06/2011 Created. + * mjjones 06/22/2011 Major updates */ #ifndef FAPIATTRIBUTESERVICE_H_ #define FAPIATTRIBUTESERVICE_H_ #include <stdint.h> #include <fapiAttributeIds.H> -#include <fapiReturnCode.H> -#include <fapiTarget.H> +#include <fapiPlatAttributeService.H> /** * @brief Macros called by user to get/set attributes * - * @note The user must use these macros rather than use the AttributeService - * _get/_set functions so that the type can be checked at compile time + * @note The user must use these macros rather than any AttributeService + * functions. * * Code must have a pointer to a Target and an attribute ID (from XML file): * fapi::ReturnCode l_rc; @@ -42,385 +49,39 @@ * uint32_t l_pVal[4] = {0}; * l_rc = FAPI_ATTR_GET(l_id, l_pTarget, l_pVal); * l_rc = FAPI_ATTR_SET(l_id, l_pTarget, l_pVal); + * + * The first part of these macros is a call to checkIdType that will cause a + * compile failure if the ID or VAL parameters are incorrect. + * + * The second part of these macros calls a macro named <ID>_GET/SETMACRO. This + * macro is defined by PLAT and must do the work of getting/setting the + * attribute. */ #define FAPI_ATTR_GET(ID, PTARGET, VAL) \ - fapi::AttributeService::_get<fapi::ID##_Type>(fapi::ID, PTARGET, VAL) + (fapi::AttributeCheck::checkIdType<fapi::ID##_Type>(fapi::ID, VAL), \ + ID##_GETMACRO(ID, PTARGET, VAL)) #define FAPI_ATTR_SET(ID, PTARGET, VAL) \ - fapi::AttributeService::_set<fapi::ID##_Type>(fapi::ID, PTARGET, VAL) + (fapi::AttributeCheck::checkIdType<fapi::ID##_Type>(fapi::ID, VAL), \ + ID##_SETMACRO(ID, PTARGET, VAL)) namespace fapi { -/** - * @namespace AttributeService - * - * This class defines the attribute access functions. These functions must not - * be accessed directly, they should only be called by the FAPI_ATTR_GET and - * FAPI_ATTR_SET macros. - * - * Each function comes in two parts. If the caller of FAPI_ATTR_GET attempts to - * get an incorrect type then the normal template function will be instantiated - * and the construction of the undefined InvalidTypeRequestedForAttribute class - * will cause a compile failure. Only if the caller attempts to get the correct - * type will the specialized function be called which will work. - */ -namespace AttributeService -{ - -/** - * @brief Forward declaration of class that will never be defined - */ -class InvalidTypeRequestedForAttribute; - -/** - * @brief Get a copy of a string attribute - * - * @param[in] i_id Attribute ID - * @param[in] i_pTarget Pointer to Target that the attribute is associated with - * (NULL if system attribute) - * @param[out] o_pValue Reference to pointer that will be set to point to newly - * allocated memory holding the attribute value - * - * @return ReturnCode. Zero on success, else error. - * - * @note The caller must free the data with "delete [] o_pValue" - */ -template<typename T> -ReturnCode _get(const AttributeId i_id, - const Target * const i_pTarget, - char * & o_pValue) -{ - InvalidTypeRequestedForAttribute(); - return FAPI_RC_SUCCESS; -} -template<> // Specialized template function defined in fapiAttributeService.C -ReturnCode _get<char *> (const AttributeId i_id, - const Target * const i_pTarget, - char * & o_value); - -/** - * @brief Get a copy of a uint8_t attribute - * - * @param[in] i_id Attribute ID - * @param[in] i_pTarget Pointer to Target that the attribute is associated with - * (NULL if system attribute) - * @param[out] o_value Reference to data that will be set to the attribute val - * - * @return ReturnCode. Zero on success, else error. - */ -template<typename T> -ReturnCode _get(const AttributeId i_id, - const Target * const i_pTarget, - uint8_t& o_value) -{ - InvalidTypeRequestedForAttribute(); - return FAPI_RC_SUCCESS; -} -template<> // Specialized template function defined in fapiAttributeService.C -ReturnCode _get<uint8_t> (const AttributeId i_id, - const Target * const i_pTarget, - uint8_t & o_value); - -/** - * @brief Get a copy of a uint32_t attribute - * - * @param[in] i_id Attribute ID - * @param[in] i_pTarget Pointer to Target that the attribute is associated with - * (NULL if system attribute) - * @param[out] o_value Reference to data that will be set to the attribute val - * - * @return ReturnCode. Zero on success, else error. - */ -template<typename T> -ReturnCode _get(const AttributeId i_id, - const Target * const i_pTarget, - uint32_t& o_value) -{ - InvalidTypeRequestedForAttribute(); - return FAPI_RC_SUCCESS; -} -template<> // Specialized template function defined in fapiAttributeService.C -ReturnCode _get<uint32_t> (const AttributeId i_id, - const Target * const i_pTarget, - uint32_t & o_value); - -/** - * @brief Get a copy of a uint64_t attribute - * - * @param[in] i_id Attribute ID - * @param[in] i_pTarget Pointer to Target that the attribute is associated with - * (NULL if system attribute) - * @param[out] o_value Reference to data that will be set to the attribute val - * - * @return ReturnCode. Zero on success, else error. - */ -template<typename T> -ReturnCode _get(const AttributeId i_id, - const Target * const i_pTarget, - uint64_t& o_value) +namespace AttributeCheck { - InvalidTypeRequestedForAttribute(); - return FAPI_RC_SUCCESS; -} -template<> // Specialized template function defined in fapiAttributeService.C -ReturnCode _get<uint64_t> (const AttributeId i_id, - const Target * const i_pTarget, - uint64_t & o_value); /** - * @brief Get a copy of a uint8_t array attribute - * - * @param[in] i_id Attribute ID - * @param[in] i_pTarget Pointer to Target that the attribute is associated with - * (NULL if system attribute) - * @param[out] o_pValues Pointer to data that will be set to the attribute value - * - * @return ReturnCode. Zero on success, else error. + * @brief Check the ID and VAL * - * @note The caller's o_pValues pointer must point to memory large enough to - * hold the attribute. + * This is called by FAPI_ATTR_GET/SET to check at compile time that the ID and + * VAL macro parameters are correct. If the ID is not an AttributeId or the VAL + * is not the type specified in the attribute XML file then no function will be + * found. */ -template<typename T> -ReturnCode _get(const AttributeId i_id, - const Target * const i_pTarget, - uint8_t * const o_pValues) -{ - InvalidTypeRequestedForAttribute(); - return FAPI_RC_SUCCESS; -} -template<> // Specialized template function defined in fapiAttributeService.C -ReturnCode _get<uint8_t *> (const AttributeId i_id, - const Target * const i_pTarget, - uint8_t * const o_pValues); +template<typename T> void checkIdType(AttributeId, T &) {} -/** - * @brief Get a copy of a uint32_t array attribute - * - * @param[in] i_id Attribute ID - * @param[in] i_pTarget Pointer to Target that the attribute is associated with - * (NULL if system attribute) - * @param[out] o_pValues Pointer to data that will be set to the attribute value - * - * @return ReturnCode. Zero on success, else error. - * - * @note The caller's o_pValues pointer must point to memory large enough to - * hold the attribute. - */ -template<typename T> -ReturnCode _get(const AttributeId i_id, - const Target * const i_pTarget, - uint32_t * const o_pValues) -{ - InvalidTypeRequestedForAttribute(); - return FAPI_RC_SUCCESS; } -template<> // Specialized template function defined in fapiAttributeService.C -ReturnCode _get<uint32_t *> (const AttributeId i_id, - const Target * const i_pTarget, - uint32_t * const o_pValues); -/** - * @brief Get a copy of a uint64_t array attribute - * - * @param[in] i_id Attribute ID - * @param[in] i_pTarget Pointer to Target that the attribute is associated with - * (NULL if system attribute) - * @param[out] o_pValues Pointer to data that will be set to the attribute value - * - * @return ReturnCode. Zero on success, else error. - * - * @note The caller's o_pValues pointer must point to memory large enough to - * hold the attribute. - */ -template<typename T> -ReturnCode _get(const AttributeId i_id, - const Target * const i_pTarget, - uint64_t * const o_pValues) -{ - InvalidTypeRequestedForAttribute(); - return FAPI_RC_SUCCESS; } -template<> // Specialized template function defined in fapiAttributeService.C -ReturnCode _get<uint64_t *> (const AttributeId i_id, - const Target * const i_pTarget, - uint64_t * const o_pValues); - -/** - * @brief Set a string attribute - * - * @param[in] i_id Attribute ID - * @param[in] i_pTarget Pointer to Target that the attribute is associated with - * (NULL if system attribute) - * @param[in] i_pValue Pointer to string containing the attribute value to set - * - * @return ReturnCode. Zero on success, else error. - */ -template<typename T> -ReturnCode _set(const AttributeId i_id, - const Target * const i_pTarget, - const char * const i_pValue) -{ - InvalidTypeRequestedForAttribute(); - return FAPI_RC_SUCCESS; -} -template<> // Specialized template function defined in fapiAttributeService.C -ReturnCode _set<char *> (const AttributeId i_id, - const Target * const i_pTarget, - const char * const i_pValue); - -/** - * @brief Set a uint8_t attribute - * - * @param[in] i_id Attribute ID - * @param[in] i_pTarget Pointer to Target that the attribute is associated with - * (NULL if system attribute) - * @param[in] i_value Attribute value to set - * - * @return ReturnCode. Zero on success, else error. - */ -template<typename T> -ReturnCode _set(const AttributeId i_id, - const Target * const i_pTarget, - const uint8_t i_value) -{ - InvalidTypeRequestedForAttribute(); - return FAPI_RC_SUCCESS; -} -template<> // Specialized template function defined in fapiAttributeService.C -ReturnCode _set<uint8_t> (const AttributeId i_id, - const Target * const i_pTarget, - const uint8_t i_value); - -/** - * @brief Set a uint32_t attribute - * - * @param[in] i_id Attribute ID - * @param[in] i_pTarget Pointer to Target that the attribute is associated with - * (NULL if system attribute) - * @param[in] i_value Attribute value to set - * - * @return ReturnCode. Zero on success, else error. - */ -template<typename T> -ReturnCode _set(const AttributeId i_id, - const Target * const i_pTarget, - const uint32_t i_value) -{ - InvalidTypeRequestedForAttribute(); - return FAPI_RC_SUCCESS; -} -template<> // Specialized template function defined in fapiAttributeService.C -ReturnCode _set<uint32_t> (const AttributeId i_id, - const Target * const i_pTarget, - const uint32_t i_value); - -/** - * @brief Set a uint64_t attribute - * - * @param[in] i_id Attribute ID - * @param[in] i_pTarget Pointer to Target that the attribute is associated with - * (NULL if system attribute) - * @param[in] i_value Attribute value to set - * - * @return ReturnCode. Zero on success, else error. - */ -template<typename T> -ReturnCode _set(const AttributeId i_id, - const Target * const i_pTarget, - const uint64_t i_value) -{ - InvalidTypeRequestedForAttribute(); - return FAPI_RC_SUCCESS; -} -template<> // Specialized template function defined in fapiAttributeService.C -ReturnCode _set<uint64_t> (const AttributeId i_id, - const Target * const i_pTarget, - const uint64_t i_value); - -/** - * @brief Set a uint8_t array attribute - * - * @param[in] i_id Attribute ID - * @param[in] i_pTarget Pointer to Target that the attribute is associated - * with (NULL if system attribute) - * @param[out] i_pValues Pointer to array containing the attribute values to - * set - * - * @return ReturnCode. Zero on success, else error. - * - * @note The caller's o_pValues pointer must point to memory large enough to - * hold the attribute. - */ -template<typename T> -ReturnCode _set(const AttributeId i_id, - const Target * const i_pTarget, - const uint8_t * const i_pValues) -{ - InvalidTypeRequestedForAttribute(); - return FAPI_RC_SUCCESS; -} -template<> // Specialized template function defined in fapiAttributeService.C -ReturnCode _set<uint8_t *> (const AttributeId i_id, - const Target * const i_pTarget, - const uint8_t * const i_pValues); - -/** - * @brief Set a uint32_t array attribute - * - * @param[in] i_id Attribute ID - * @param[in] i_pTarget Pointer to Target that the attribute is associated - * with (NULL if system attribute) - * @param[out] i_pValues Pointer to array containing the attribute values to - * set - * - * @return ReturnCode. Zero on success, else error. - * - * @note The caller's o_pValues pointer must point to memory large enough to - * hold the attribute. - */ -template<typename T> -ReturnCode _set(const AttributeId i_id, - const Target * const i_pTarget, - const uint32_t * const i_pValues) -{ - InvalidTypeRequestedForAttribute(); - return FAPI_RC_SUCCESS; -} -template<> // Specialized template function defined in fapiAttributeService.C -ReturnCode _set<uint32_t *> (const AttributeId i_id, - const Target * const i_pTarget, - const uint32_t * const i_pValues); - -/** - * @brief Set a uint64_t array attribute - * - * @param[in] i_id Attribute ID - * @param[in] i_pTarget Pointer to Target that the attribute is associated - * with (NULL if system attribute) - * @param[out] i_pValues Pointer to array containing the attribute values to - * set - * - * @return ReturnCode. Zero on success, else error. - * - * @note The caller's o_pValues pointer must point to memory large enough to - * hold the attribute. - */ -template<typename T> -ReturnCode _set(const AttributeId i_id, - const Target * const i_pTarget, - const uint64_t * const i_pValues) -{ - InvalidTypeRequestedForAttribute(); - return FAPI_RC_SUCCESS; -} -template<> // Specialized template function defined in fapiAttributeService.C -ReturnCode _set<uint64_t *> (const AttributeId i_id, - const Target * const i_pTarget, - const uint64_t * const i_pValues); - - -} // namespace AttributeService - -} // namespace fapi #endif // FAPIATTRIBUTESERVICE_H_ diff --git a/src/include/usr/hwpf/fapi/fapiHwAccess.H b/src/include/usr/hwpf/fapi/fapiHwAccess.H index 948d4feb0..9ed1ea16c 100644 --- a/src/include/usr/hwpf/fapi/fapiHwAccess.H +++ b/src/include/usr/hwpf/fapi/fapiHwAccess.H @@ -2,16 +2,29 @@ * @file fapiHwAccess.H * * @brief Defines the hardware access functions that platform code must - * implement. It is a HWP requirement that these be "C" functions. + * implement. It is a HWP requirement that these be "C" functions + * because it simplifies language bindings for non-C languages, + * such as perl + */ + +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 04/13/2011 Created. Copied from Hlava's code. + * mjjones 06/02/2011 Scom addresses should be uint64_t + * use ecmdDataBufferBase + * mjjones 06/30/2011 Updated comment + * */ #ifndef FAPIHWACCESS_H_ #define FAPIHWACCESS_H_ #include <stdint.h> +#include <ecmdDataBuffer.H> #include <fapiReturnCode.H> #include <fapiTarget.H> -#include <ecmdDataBuffer.H> namespace fapi { diff --git a/src/include/usr/hwpf/fapi/fapiReturnCodes.H b/src/include/usr/hwpf/fapi/fapiReturnCodes.H index 4d3cc7db2..2b761dbde 100644 --- a/src/include/usr/hwpf/fapi/fapiReturnCodes.H +++ b/src/include/usr/hwpf/fapi/fapiReturnCodes.H @@ -4,6 +4,16 @@ * @brief Defines the returns codes generated by HWPF code. */ +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 04/13/2011 Created. + * mjjones 06/07/2011 Add FAPI_RC_NOT_IMPLEMENTED + * mjjones 06/30/2011 Add FAPI_RC_ATTR_UNIT_TEST_FAIL + * + */ + #ifndef FAPIRETURNCODES_H_ #define FAPIRETURNCODES_H_ @@ -26,7 +36,8 @@ enum FAPI_RC_ECMD_MASK = ECMD_ERR_ECMD, // ECMD generated error (0x01000000) // FAPI generated return codes - FAPI_RC_NOT_IMPLEMENTED = FAPI_RC_FAPI_MASK | 0x01, + FAPI_RC_NOT_IMPLEMENTED = FAPI_RC_FAPI_MASK | 0x01, + FAPI_RC_ATTR_UNIT_TEST_FAIL = FAPI_RC_FAPI_MASK | 0x02, // PLAT generated return codes FAPI_RC_PLAT_ERR_SEE_DATA = FAPI_RC_PLAT_MASK | 0x01, diff --git a/src/include/usr/hwpf/fapi/fapiTarget.H b/src/include/usr/hwpf/fapi/fapiTarget.H index af22137b9..d79beee4f 100644 --- a/src/include/usr/hwpf/fapi/fapiTarget.H +++ b/src/include/usr/hwpf/fapi/fapiTarget.H @@ -5,6 +5,15 @@ * Procedure operation. */ +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 04/13/2011 Created. Based on Hlava prototype + * mjjones 06/29/2011 Removed incorrect MSB from 2 enums + * + */ + #ifndef FAPITARGET_H_ #define FAPITARGET_H_ @@ -26,8 +35,8 @@ enum TargetType TARGET_TYPE_MEMBUF_CHIP = 0x00000008, TARGET_TYPE_EX_CHIPLET = 0x00000010, TARGET_TYPE_MBA_CHIPLET = 0x00000020, - TARGET_TYPE_MBS_CHIPLET = 0x80000040, - TARGET_TYPE_MCS_CHIPLET = 0x80000080, + TARGET_TYPE_MBS_CHIPLET = 0x00000040, + TARGET_TYPE_MCS_CHIPLET = 0x00000080, }; /** diff --git a/src/include/usr/hwpf/fapi/fapiUtil.H b/src/include/usr/hwpf/fapi/fapiUtil.H index 291410454..843465142 100644 --- a/src/include/usr/hwpf/fapi/fapiUtil.H +++ b/src/include/usr/hwpf/fapi/fapiUtil.H @@ -4,12 +4,21 @@ * @brief Defines utility functions that the platform code must implement. */ +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 04/13/2011 Created. + * camvanng 05/31/2011 Removed fapiOutputx macros + * mjjones 06/30/2011 Removed #include + * + */ + #ifndef FAPIUTIL_H_ #define FAPIUTIL_H_ #include <stdint.h> #include <stddef.h> -#include <fapi.H> namespace fapi diff --git a/src/include/usr/hwpf/hwp/fapiTestHwp.H b/src/include/usr/hwpf/hwp/fapiTestHwp.H index db619737f..5deb60246 100644 --- a/src/include/usr/hwpf/hwp/fapiTestHwp.H +++ b/src/include/usr/hwpf/hwp/fapiTestHwp.H @@ -1,8 +1,16 @@ /** * @file fapiTestHwp.H * - * @brief Defines test Hardware Procedures that are intended to test out the - * Hardware Procedure Framework + * @brief Defines a simple test Hardware Procedure + */ + +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 04/21/2011 Created. + * mjjones 06/28/2011 Updated comment + * */ #ifndef FAPITESTHWPROC_H_ diff --git a/src/include/usr/hwpf/hwp/fapiTestHwpAttr.H b/src/include/usr/hwpf/hwp/fapiTestHwpAttr.H new file mode 100755 index 000000000..d24fe748e --- /dev/null +++ b/src/include/usr/hwpf/hwp/fapiTestHwpAttr.H @@ -0,0 +1,33 @@ +/** + * @file fapiTestHwpAttr.H + * + * @brief Defines a test Hardware Procedure that exercises the test attributes + */ + +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 06/30/2011 Created. + */ + +#ifndef FAPITESTHWPATTR_H_ +#define FAPITESTHWPATTR_H_ + +#include <fapi.H> + +// HWPs are defined as C functions because platforms may wish to package them +// in linux shared libraries which are DL-Opened +extern "C" +{ + +/** + * @brief HWP that exercises attributes + * + * @return ReturnCode + */ +fapi::ReturnCode hwpTestAttributes(); + +} // extern "C" + +#endif // FAPITESTHWPATTR_H_ diff --git a/src/include/usr/hwpf/plat/fapiPlatAttributeService.H b/src/include/usr/hwpf/plat/fapiPlatAttributeService.H new file mode 100755 index 000000000..3f0db5dd7 --- /dev/null +++ b/src/include/usr/hwpf/plat/fapiPlatAttributeService.H @@ -0,0 +1,22 @@ +/** + * @file fapiPlatAttributeService.H + * + * @brief Defines the PLAT attribute access macros and defines which macro + * handles each attribute. + * + * Note that platform code must provide the code. + */ + +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 06/27/2011 Created. + */ + +#ifndef FAPIPLATATTRIBUTESERVICE_H_ +#define FAPIPLATATTRIBUTESERVICE_H_ +#include <stdint.h> +#include <fapiAttributeIds.H> + +#endif // FAPIPLATATTRIBUTESERVICE_H_ diff --git a/src/usr/hwpf/fapi/fapiAttributeService.C b/src/usr/hwpf/fapi/fapiAttributeService.C deleted file mode 100644 index c48557398..000000000 --- a/src/usr/hwpf/fapi/fapiAttributeService.C +++ /dev/null @@ -1,187 +0,0 @@ -/** - * @file fapiAttributeService.C - * - * @brief Implements the AttributeService functions. - */ - -#include <stdio.h> -#include <fapiAttributeService.H> -#include <fapiPlatTrace.H> - -namespace fapi -{ - -namespace AttributeService -{ - -//****************************************************************************** -// Get string -//****************************************************************************** -template<> -ReturnCode _get<char *> (const AttributeId i_id, - const Target * const i_pTarget, - char * & o_value) -{ - FAPI_ERR("Get string attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -//****************************************************************************** -// Get uint8_t -//****************************************************************************** -template<> -ReturnCode _get<uint8_t> (const AttributeId i_id, - const Target * const i_pTarget, - uint8_t & o_value) -{ - FAPI_ERR("Get uint8 attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -//****************************************************************************** -// Get uint32_t -//****************************************************************************** -template<> -ReturnCode _get<uint32_t> (const AttributeId i_id, - const Target * const i_pTarget, - uint32_t & o_value) -{ - FAPI_ERR("Get uint32 attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -//****************************************************************************** -// Get uint64_t -//****************************************************************************** -template<> -ReturnCode _get<uint64_t> (const AttributeId i_id, - const Target * const i_pTarget, - uint64_t & o_value) -{ - FAPI_ERR("Get uint64 attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -//****************************************************************************** -// Get uint8_t array -//****************************************************************************** -template<> -ReturnCode _get<uint8_t *> (const AttributeId i_id, - const Target * const i_pTarget, - uint8_t * const o_pValues) -{ - FAPI_ERR("Get uint8 array attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -//****************************************************************************** -// Get uint32_t array -//****************************************************************************** -template<> -ReturnCode _get<uint32_t *> (const AttributeId i_id, - const Target * const i_pTarget, - uint32_t * const o_pValues) -{ - FAPI_ERR("Get uint32 array attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -//****************************************************************************** -// Get uint64_t array -//****************************************************************************** -template<> -ReturnCode _get<uint64_t *> (const AttributeId i_id, - const Target * const i_pTarget, - uint64_t * const o_pValues) -{ - FAPI_ERR("Get uint64 array attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -//****************************************************************************** -// Set string -//****************************************************************************** -template<> -ReturnCode _set<char *> (const AttributeId i_id, - const Target * const i_pTarget, - const char * const i_pValue) -{ - FAPI_ERR("Set string attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -//****************************************************************************** -// Set uint8_t -//****************************************************************************** -template<> -ReturnCode _set<uint8_t> (const AttributeId i_id, - const Target * const i_pTarget, - const uint8_t i_value) -{ - FAPI_ERR("Set uint8 attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -//****************************************************************************** -// Set uint32_t -//****************************************************************************** -template<> -ReturnCode _set<uint32_t> (const AttributeId i_id, - const Target * const i_pTarget, - const uint32_t i_value) -{ - FAPI_ERR("Set uint32 attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -//****************************************************************************** -// Set uint64_t -//****************************************************************************** -template<> -ReturnCode _set<uint64_t> (const AttributeId i_id, - const Target * const i_pTarget, - const uint64_t i_value) -{ - FAPI_ERR("Set uint64 attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -//****************************************************************************** -// Set uint8_t array -//****************************************************************************** -template<> -ReturnCode _set<uint8_t *> (const AttributeId i_id, - const Target * const i_pTarget, - const uint8_t * const i_pValues) -{ - FAPI_ERR("Set uint8 array attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -//****************************************************************************** -// Set uint32_t array -//****************************************************************************** -template<> -ReturnCode _set<uint32_t *> (const AttributeId i_id, - const Target * const i_pTarget, - const uint32_t * const i_pValues) -{ - FAPI_ERR("Set uint32 array attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -//****************************************************************************** -// Set uint64_t array -//****************************************************************************** -template<> -ReturnCode _set<uint64_t *> (const AttributeId i_id, - const Target * const i_pTarget, - const uint64_t * const i_pValues) -{ - FAPI_ERR("Set uint64 array attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -} // namespace AttributeService - -} // namespace fapi diff --git a/src/usr/hwpf/fapi/fapiParseAttributeInfo.pl b/src/usr/hwpf/fapi/fapiParseAttributeInfo.pl index 8151b0ef6..0153bfb2f 100755 --- a/src/usr/hwpf/fapi/fapiParseAttributeInfo.pl +++ b/src/usr/hwpf/fapi/fapiParseAttributeInfo.pl @@ -1,144 +1,279 @@ #!/usr/bin/perl # +# Purpose: This perl script will parse HWP Attribute XML files +# and add attribute information to a file called fapiAttributeIds.H +# +# Author: CamVan Nguyen +# Last Updated: 06/23/2011 +# +# Version: 1.0 +# +# Change Log ********************************************************** +# +# Flag Track# Userid Date Description +# ---- -------- -------- -------- ----------- +# camvanng 06/03/11 Created +# mjjones 06/06/11 Minor updates for integration +# mjjones 06/10/11 Added "use strict;" +# mjjones 06/23/11 Parse more info +# +# End Change Log ****************************************************** + +# # Usage: # fapiParseAttributeInfo.pl <filename1> <filename2> .... <filenameN> use strict; +#------------------------------------------------------------------------------ +# Print Command Line Help +#------------------------------------------------------------------------------ my $numArgs = $#ARGV + 1; -#print $numArgs, "\n"; - if ($numArgs < 1) { print ("Usage: fapiParseAttributeInfo.pl <filename1> <filename2> .... <filenameN>\n"); - print (" This perl script will parse attribute XML files,\n"); - print (" pull out the attribute IDs/types and create a header file\n"); - print (" fapiAttributeIds.H containing the information.\n"); + print (" This perl script will parse attribute XML files and add\n"); + print (" attribute information to a file called fapiAttributeIds.H\n"); exit(1); } - - -# use module +#------------------------------------------------------------------------------ +# Specify perl modules to use +#------------------------------------------------------------------------------ use XML::Simple; +my $xml = new XML::Simple (KeyAttr=>[]); + +# Uncomment to enable debug output #use Data::Dumper; -#open output file for writing +#------------------------------------------------------------------------------ +# Open output file for writing +#------------------------------------------------------------------------------ open(OUTFILE, ">fapiAttributeIds.H"); + +#------------------------------------------------------------------------------ +# Print Start of file information +#------------------------------------------------------------------------------ print OUTFILE "// fapiAttributeIds.H\n"; print OUTFILE "// This file is generated by perl script fapiParseAttributeInfo.pl\n\n"; print OUTFILE "#ifndef FAPIATTRIBUTEIDS_H_\n"; print OUTFILE "#define FAPIATTRIBUTEIDS_H_\n\n"; print OUTFILE "namespace fapi\n"; print OUTFILE "{\n\n"; + +#------------------------------------------------------------------------------ +# Print AttributeId enumeration start +#------------------------------------------------------------------------------ print OUTFILE "\/**\n"; print OUTFILE " * \@brief Enumeration of attribute IDs\n"; print OUTFILE " *\/\n"; -print OUTFILE "enum AttributeId\n"; -print OUTFILE "{\n"; +print OUTFILE "enum AttributeId\n{\n"; -# create object -my $xml = new XML::Simple (KeyAttr=>[]); - -#for each Hwp Attribute XML file +#------------------------------------------------------------------------------ +# For each XML file +#------------------------------------------------------------------------------ my $infile; foreach $infile(@ARGV) { - #print filename - #print $ifile, "\n\n"; - # read XML file my $attributes = $xml->XMLin($infile); - # print output - #print Dumper($attributes); - #print "\n"; + # Uncomment to get debug output of all attributes + #print "\nFile: ", $infile, "\n", Dumper($attributes), "\n"; - # print attribute id to file - my $attr; - foreach $attr (@{$attributes->{attribute}}) + #-------------------------------------------------------------------------- + # For each Attribute + #-------------------------------------------------------------------------- + foreach my $attr (@{$attributes->{attribute}}) { - if ($attr->{id}) - { - print OUTFILE " ", $attr->{id}, ",\n"; - } - else + #---------------------------------------------------------------------- + # Print the AttributeId + #---------------------------------------------------------------------- + if (!$attr->{id}) { - print ("fapiParseAttributeInfo.pl ERROR. Attribute ID missing\n"); + print ("fapiParseAttributeInfo.pl ERROR. Att 'id' missing\n"); exit(1); } + + print OUTFILE " ", $attr->{id}, ",\n"; }; } +#------------------------------------------------------------------------------ +# Print AttributeId enumeration end +#------------------------------------------------------------------------------ print OUTFILE "};\n\n"; +#------------------------------------------------------------------------------ +# Print Attribute Information comment +#------------------------------------------------------------------------------ print OUTFILE "\/**\n"; -print OUTFILE " * \@brief Typedefs for the attribute value types\n"; +print OUTFILE " * \@brief Attribute Information\n"; print OUTFILE " *\/\n"; -#for each Hwp Attribute XML file +#------------------------------------------------------------------------------ +# For each XML file +#------------------------------------------------------------------------------ foreach $infile(@ARGV) { # read XML file my $attributes = $xml->XMLin($infile); - # print attribute id to file - my $attr; - foreach $attr (@{$attributes->{attribute}}) + #-------------------------------------------------------------------------- + # For each Attribute + #-------------------------------------------------------------------------- + foreach my $attr (@{$attributes->{attribute}}) { - print OUTFILE "typedef "; + #---------------------------------------------------------------------- + # Print a comment with the attribute description + #---------------------------------------------------------------------- + if ($attr->{description}) + { + print OUTFILE "// ", $attr->{id}, ": ", $attr->{description}, "\n"; + } - if ($attr->{valueType} eq 'uint8') + #---------------------------------------------------------------------- + # Figure out the attribute array dimensions (if arry) + #---------------------------------------------------------------------- + my $arrayDimensions = ""; + if ($attr->{array}) { - if ($attr->{array}) + # Figure out the array dimensions + my @vals = split(' ', $attr->{array}); + + foreach my $val (@vals) { - print OUTFILE "uint8_t * "; + $arrayDimensions .= "["; + $arrayDimensions .= ${val}; + $arrayDimensions .= "]"; } - else + } + + #---------------------------------------------------------------------- + # Print the typedef for each attribute's value type + #---------------------------------------------------------------------- + if (!$attr->{valueType}) + { + print ("fapiParseAttributeInfo.pl ERROR. Att 'valueType' missing\n"); + exit(1); + } + + print OUTFILE "typedef "; + my $attrDefaultValType; + + if ($attr->{valueType} eq 'uint8') + { + $attrDefaultValType = "uint8_t"; + print OUTFILE "uint8_t ", $attr->{id}, "_Type", $arrayDimensions, ";\n"; + } + elsif ($attr->{valueType} eq 'uint32') + { + $attrDefaultValType = "uint32_t"; + print OUTFILE "uint32_t ", $attr->{id}, "_Type", $arrayDimensions, ";\n"; + } + elsif ($attr->{valueType} eq 'uint64') + { + $attrDefaultValType = "uint64_t"; + print OUTFILE "uint64_t ", $attr->{id}, "_Type", $arrayDimensions, ";\n"; + } + elsif ($attr->{valueType} eq 'string') + { + $attrDefaultValType = "char *"; + print OUTFILE "char * ", $attr->{id}, "_Type;\n"; + } + else + { + print ("fapiParseAttributeInfo.pl ERROR. valueType not recognized: "); + print $attr->{valueType}, "\n"; + exit(1); + } + + #---------------------------------------------------------------------- + # Print the value enumeration (if it is specified) + #---------------------------------------------------------------------- + if ($attr->{enum}) + { + print OUTFILE "enum ", $attr->{id}, "_Enum\n{\n"; + + # Values must be separated by white space + my @vals = split(' ', $attr->{enum}); + + foreach my $val (@vals) { - print OUTFILE "uint8_t "; + print OUTFILE " ", $attr->{id}, "_", ${val}, ",\n"; } + + print OUTFILE "};\n"; } - elsif ($attr->{valueType} eq 'uint32') + + #---------------------------------------------------------------------- + # Print the default value information + #---------------------------------------------------------------------- + print OUTFILE "const bool ", $attr->{id}, "_HASDEFAULTVAL = "; + + if ($attr->{defaultValue}) { - if ($attr->{array}) + print OUTFILE "true;\n"; + + if ($attr->{valueType} eq 'string') { - print OUTFILE "uint32_t * "; + print OUTFILE "const char * const ", $attr->{id}; + print OUTFILE "_DEFAULTVAL = \"", $attr->{defaultValue}; + print OUTFILE "\";\n"; + } + elsif ($attr->{enum}) + { + print OUTFILE "const ", $attrDefaultValType, " ", $attr->{id}; + print OUTFILE "_DEFAULTVAL = ", $attr->{id}, "_"; + print OUTFILE $attr->{defaultValue}, ";\n"; } else { - print OUTFILE "uint32_t "; + print OUTFILE "const ", $attrDefaultValType, " ", $attr->{id}; + print OUTFILE "_DEFAULTVAL = ", $attr->{defaultValue}, ";\n"; } } - elsif ($attr->{valueType} eq 'uint64') + else { - if ($attr->{array}) + print OUTFILE "false;\n"; + + if ($attr->{valueType} eq 'string') { - print OUTFILE "uint64_t * "; + print OUTFILE "const char * const ", $attr->{id}; + print OUTFILE "_DEFAULTVAL = \"\";\n"; } else { - print OUTFILE "uint64_t "; + print OUTFILE "const ", $attrDefaultValType, " ", $attr->{id}; + print OUTFILE "_DEFAULTVAL = 0;\n"; } } - elsif ($attr->{valueType} eq 'string') - { - print OUTFILE "char * "; - } - else + + #---------------------------------------------------------------------- + # If the attribute is read-only then define the _SETMACRO to something + # that will cause a compile failure + #---------------------------------------------------------------------- + if (!$attr->{writeable}) { - print ("fapiParseAttributeInfo.pl ERROR. valueType not recognized: "); - print $attr->{valueType}, "\n"; - exit(1); + print OUTFILE "#define ", $attr->{id}; + print OUTFILE "_SETMACRO ATTRIBUTE_NOT_WRITABLE\n"; } - print OUTFILE $attr->{id}, "_Type;\n"; + #---------------------------------------------------------------------- + # Print newline between each attribute's information + #---------------------------------------------------------------------- + print OUTFILE "\n"; }; } -print OUTFILE "\n}\n\n"; +#------------------------------------------------------------------------------ +# Print End of file information +#------------------------------------------------------------------------------ +print OUTFILE "}\n\n"; print OUTFILE "#endif\n"; -#close output file +#------------------------------------------------------------------------------ +# Close output file +#------------------------------------------------------------------------------ close(OUTFILE); diff --git a/src/usr/hwpf/fapi/fapiReturnCodeDataRef.C b/src/usr/hwpf/fapi/fapiReturnCodeDataRef.C index 910d1653e..9aaa16381 100644 --- a/src/usr/hwpf/fapi/fapiReturnCodeDataRef.C +++ b/src/usr/hwpf/fapi/fapiReturnCodeDataRef.C @@ -4,8 +4,19 @@ * @brief Implements the FAPI part of the ReturnCodeDataRef class. */ +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 04/13/2011 Created. + * camvanng 05/31/2011 Added debug traces + * mjjones 06/30/2011 Added #include + * + */ + #include <fapiReturnCodeDataRef.H> #include <fapiUtil.H> +#include <fapiPlatTrace.H> namespace fapi { diff --git a/src/usr/hwpf/fapi/makefile b/src/usr/hwpf/fapi/makefile index 59df28b20..4e6e58995 100644 --- a/src/usr/hwpf/fapi/makefile +++ b/src/usr/hwpf/fapi/makefile @@ -5,8 +5,7 @@ EXTRAINCDIR += ${ROOTPATH}/src/include/usr/ecmddatabuffer EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/fapi EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/plat -OBJS = fapiAttributeService.o \ - fapiReturnCode.o \ +OBJS = fapiReturnCode.o \ fapiReturnCodeDataRef.o \ fapiTarget.o diff --git a/src/usr/hwpf/hwp/fapiHwpAttributeInfo.xml b/src/usr/hwpf/hwp/fapiHwpAttributeInfo.xml index d1316bc0f..ce0a63042 100644 --- a/src/usr/hwpf/hwp/fapiHwpAttributeInfo.xml +++ b/src/usr/hwpf/hwp/fapiHwpAttributeInfo.xml @@ -2,49 +2,77 @@ <!-- This is just the initial test version. HWPs will replace with an official version. --> <attributes> - <!-- *********************************************************************** --> + <!-- ********************************************************************* --> <attribute> <id>ATTR_TEST_UINT8</id> - <description>Test Attribute UINT8</description> + <targetType>TARGET_TYPE_SYSTEM</targetType> + <description>Test Attr UINT8. DefaultVal 6</description> <valueType>uint8</valueType> + <defaultValue>6</defaultValue> + <writeable/> </attribute> - <!-- *********************************************************************** --> + <!-- ********************************************************************* --> <attribute> <id>ATTR_TEST_UINT32</id> - <description>Test Attribute UINT32</description> + <targetType>TARGET_TYPE_SYSTEM</targetType> + <description>Test Attr UINT32. PLAT (sets val to 3). RO</description> <valueType>uint32</valueType> + <platInit/> </attribute> - <!-- *********************************************************************** --> + <!-- ********************************************************************* --> <attribute> <id>ATTR_TEST_UINT64</id> - <description>Test Attribute UINT64</description> + <targetType>TARGET_TYPE_SYSTEM</targetType> + <description>Test Attr UINT64. Enum. DefaultVal VALB</description> <valueType>uint64</valueType> + <defaultValue>VALB</defaultValue> + <enum>VALA VALB VALC</enum> + <writeable/> </attribute> - <!-- *********************************************************************** --> + <!-- ********************************************************************* --> <attribute> <id>ATTR_TEST_UINT8_ARRAY</id> - <description>Test Attribute UINT8 ARRAY</description> + <targetType>TARGET_TYPE_SYSTEM</targetType> + <description>Test Attr UINT8 ARRAY[3]. DefaultVal 2</description> <valueType>uint8</valueType> + <defaultValue>2</defaultValue> <array>3</array> + <writeable/> </attribute> - <!-- *********************************************************************** --> + <!-- ********************************************************************* --> <attribute> <id>ATTR_TEST_UINT32_ARRAY</id> - <description>Test Attribute UINT32 ARRAY</description> + <targetType>TARGET_TYPE_SYSTEM</targetType> + <description>Test Attr UINT32 ARRAY[2][3][4]. DefaultVal 8</description> <valueType>uint32</valueType> - <array>4</array> + <defaultValue>8</defaultValue> + <array>2 3 4</array> + <writeable/> </attribute> - <!-- *********************************************************************** --> + <!-- ********************************************************************* --> <attribute> <id>ATTR_TEST_UINT64_ARRAY</id> - <description>Test Attribute UINT64 ARRAY</description> + <targetType>TARGET_TYPE_SYSTEM</targetType> + <description>Test Attr UINT64 ARRAY[5]. PLAT (sets vals to 4). RO</description> <valueType>uint64</valueType> + <platInit/> <array>5</array> </attribute> - <!-- *********************************************************************** --> + <!-- ********************************************************************* --> <attribute> - <id>ATTR_TEST_STRING</id> - <description>Test Attribute STRING</description> + <id>ATTR_TEST_STRING1</id> + <targetType>TARGET_TYPE_SYSTEM</targetType> + <description>Test Attr STRING1. DefaultVal 'mike'</description> <valueType>string</valueType> + <defaultValue>mike</defaultValue> + <writeable/> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_TEST_STRING2</id> + <targetType>TARGET_TYPE_SYSTEM</targetType> + <description>Test Attr STRING2. PLAT (sets val to 'platString')</description> + <valueType>string</valueType> + <writeable/> </attribute> </attributes> diff --git a/src/usr/hwpf/hwp/fapiTestHwp.C b/src/usr/hwpf/hwp/fapiTestHwp.C index 54dff5a66..14292864f 100644 --- a/src/usr/hwpf/hwp/fapiTestHwp.C +++ b/src/usr/hwpf/hwp/fapiTestHwp.C @@ -1,7 +1,17 @@ /** * @file fapiTestHwp.C * - * @brief Implements test Hardware Procedures. + * @brief Implements a simple test Hardware Procedure + */ + +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 04/21/2011 Created. + * mjjones 06/02/2011 Use ecmdDataBufferBase + * mjjones 06/28/2011 Removed attribute tests + * */ #include <fapiTestHwp.H> @@ -22,66 +32,6 @@ fapi::ReturnCode hwpIsP7EM0ChipletClockOn(const fapi::Target & i_chip, // Attempt to call the attribute get/set functions for the test attributes fapi::ReturnCode l_rc; - // Test getting and setting attributes - { - char * l_pString = NULL; - uint8_t l_uint8 = 0; - uint32_t l_uint32 = 0; - uint64_t l_uint64 = 0; - uint8_t l_pUint8Array[3] = {0}; - uint32_t l_pUint32Array[4] = {0}; - uint64_t l_pUint64Array[5] = {0}; - - // All of the following should currently compile (not checking RC which - // should be FAPI_RC_NOT_IMPLEMENTED). The get/set functions do not - // currently do anything so passing NULL will work. - l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING, &i_chip, l_pString); - l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT8, &i_chip, l_uint8); - l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT32, &i_chip, l_uint32); - l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64, &i_chip, l_uint64); - l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT8_ARRAY, &i_chip, l_pUint8Array); - l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT32_ARRAY, &i_chip, l_pUint32Array); - l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64_ARRAY, &i_chip, l_pUint64Array); - - l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING, &i_chip, l_pString); - l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING, &i_chip, "test-string"); - l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT8, &i_chip, l_uint8); - l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT32, &i_chip, l_uint32); - l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64, &i_chip, l_uint64); - l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT8_ARRAY, &i_chip, l_pUint8Array); - l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT32_ARRAY, &i_chip, l_pUint32Array); - l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64_ARRAY, &i_chip, l_pUint64Array); - - // All of the following should not compile due to wrong types used - //l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING, &i_chip, l_uint8); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING, &i_chip, l_uint32); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING, &i_chip, l_uint64); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING, &i_chip, l_pUint8Array); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT8, &i_chip, l_pString); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT32, &i_chip, l_uint8); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64, &i_chip, l_pUint8Array); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64, &i_chip, l_pUint64Array); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT8_ARRAY, &i_chip, l_pString); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT32_ARRAY, &i_chip, l_uint8); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64_ARRAY, &i_chip, l_uint64); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64_ARRAY, &i_chip, l_pUint32Array); - - //l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING, &i_chip, l_uint8); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING, &i_chip, l_uint32); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING, &i_chip, l_uint64); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING, &i_chip, l_pUint64Array); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT8, &i_chip, l_pString); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT32, &i_chip, l_uint64); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64, &i_chip, l_pUint32Array); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64, &i_chip, l_pUint64Array); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT8_ARRAY, &i_chip, l_pString); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT32_ARRAY, &i_chip, l_uint8); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64_ARRAY, &i_chip, l_uint64); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64_ARRAY, &i_chip, l_pUint8Array); - - l_rc = fapi::FAPI_RC_SUCCESS; - } - // Constants const uint64_t EM_CLOCK_STATUS_MASK = 0xEEC0000000000000ULL; const uint32_t EM0_CHIPLET_BASE_ADDR = 0x06000000; @@ -117,5 +67,4 @@ fapi::ReturnCode hwpIsP7EM0ChipletClockOn(const fapi::Target & i_chip, return l_rc; } - } // extern "C" diff --git a/src/usr/hwpf/hwp/fapiTestHwpAttr.C b/src/usr/hwpf/hwp/fapiTestHwpAttr.C new file mode 100755 index 000000000..493bec8de --- /dev/null +++ b/src/usr/hwpf/hwp/fapiTestHwpAttr.C @@ -0,0 +1,513 @@ +/** + * @file fapiTestHwpAttr.C + * + * @brief Implements the test Hardware Procedure that exercises the test + * attributes + */ + +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 06/30/2011 Created. + * + */ + +#include <fapiTestHwpAttr.H> + +extern "C" +{ + +//****************************************************************************** +// hwpTestAttributes function +//****************************************************************************** +fapi::ReturnCode hwpTestAttributes() +{ + // Attempt to call the attribute get/set functions for the test attributes + fapi::ReturnCode l_rc; + + // Test getting and setting the test attributes + do + { + //---------------------------------------------------------------------- + // Test ATTR_TEST_UINT8 (DefaultVal 6) + //---------------------------------------------------------------------- + uint8_t l_uint8 = 0; + + // Test get + l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT8, NULL, l_uint8); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8. Error from GET"); + break; + } + + // Check value + if (l_uint8 != 6) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8. GET returned %d", + l_uint8); + break; + } + + // Test set + l_uint8 = 7; + l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT8, NULL, l_uint8); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8. Error from SET"); + break; + } + + // Test get + l_uint8 = 8; + l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT8, NULL, l_uint8); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8. Error from GET (2)"); + break; + } + + // Check value + if (l_uint8 != 7) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8. GET returned %d (2)", + l_uint8); + break; + } + + //---------------------------------------------------------------------- + // Test ATTR_TEST_UINT32 (PLAT (sets val to 3). RO) + //---------------------------------------------------------------------- + uint32_t l_uint32 = 0; + + // Test get + l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT32, NULL, l_uint32); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT32. Error from GET"); + break; + } + + // Check value + if (l_uint32 != 3) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT32. GET returned %d", + l_uint32); + break; + } + + // Cannot set read-only attribute + + //---------------------------------------------------------------------- + // Test ATTR_TEST_UINT64 (Enum. DefaultVal VALB) + //---------------------------------------------------------------------- + uint64_t l_uint64 = 0; + + // Test get + l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64, NULL, l_uint64); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT64. Error from GET"); + break; + } + + // Check value + if (l_uint64 != fapi::ATTR_TEST_UINT64_VALB) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT64. GET returned %d", + static_cast<uint32_t>(l_uint64)); + break; + } + + // Test set + l_uint64 = fapi::ATTR_TEST_UINT64_VALA; + l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64, NULL, l_uint64); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT64. Error from SET"); + break; + } + + // Test get + l_uint64 = fapi::ATTR_TEST_UINT64_VALC; + l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64, NULL, l_uint64); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT64. Error from GET (2)"); + break; + } + + if (l_uint64 != fapi::ATTR_TEST_UINT64_VALA) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT64. GET returned %d (2)", + static_cast<uint32_t>(l_uint64)); + break; + } + + //---------------------------------------------------------------------- + // Test ATTR_TEST_UINT8_ARRAY ([3], DefaultVal 2) + //---------------------------------------------------------------------- + uint8_t l_uint8Array[3]; + + // Test get + l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT8_ARRAY, NULL, l_uint8Array); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8_ARRAY. Error from GET"); + break; + } + + // Check values + for (uint32_t i = 0; i < 3; i++) + { + if (l_uint8Array[i] != 2) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8_ARRAY GET " + "returned %d in index %d", l_uint8Array[i], i); + break; + } + } + + if (l_rc) + { + break; + } + + // Test set + l_uint8Array[0] = 0; + l_uint8Array[1] = 1; + l_uint8Array[2] = 2; + + l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT8_ARRAY, NULL, l_uint8Array); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8_ARRAY. Error from SET"); + break; + } + + // Test get + l_uint8Array[0] = 6; + l_uint8Array[1] = 7; + l_uint8Array[2] = 8; + l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT8_ARRAY, NULL, l_uint8Array); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8_ARRAY. Error from GET (2)"); + break; + } + + // Check values + for (uint32_t i = 0; i < 3; i++) + { + if (l_uint8Array[i] != i) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8_ARRAY. GET " + "returned %d in index %d", l_uint8Array[i], i); + break; + } + } + + if (l_rc) + { + break; + } + + //---------------------------------------------------------------------- + // Test ATTR_TEST_UINT32_ARRAY ([2][3][4], DefaultVal 8) + //---------------------------------------------------------------------- + uint32_t l_uint32Array[2][3][4]; + + // Test get + l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT32_ARRAY, NULL, l_uint32Array); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT32_ARRAY. Error from GET"); + break; + } + + // Check values + for (uint32_t i = 0; i < 2; i++) + { + for (uint32_t j = 0; j < 3; j++) + { + for (uint32_t k = 0; k < 4; k++) + { + if (l_uint32Array[i][j][k] != 8) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT32_ARRAY. " + "GET returned %d in index %d:%d:%d", + l_uint32Array[i][j][j], i, j, k); + break; + } + } + + if (l_rc) + { + break; + } + } + + if (l_rc) + { + break; + } + } + + if (l_rc) + { + break; + } + + // Test set + uint32_t l_val = 0; + for (uint32_t i = 0; i < 2; i++) + { + for (uint32_t j = 0; j < 3; j++) + { + for (uint32_t k = 0; k < 4; k++) + { + l_uint32Array[i][j][k] = l_val++; + } + } + } + + l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT32_ARRAY, NULL, l_uint32Array); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT32_ARRAY. Error from SET"); + break; + } + + // Test get + for (uint32_t i = 0; i < 2; i++) + { + for (uint32_t j = 0; j < 3; j++) + { + for (uint32_t k = 0; k < 4; k++) + { + l_uint32Array[i][j][k] = 32; + } + } + } + + l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT32_ARRAY, NULL, l_uint32Array); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: Error from GET uint32 array (2)"); + break; + } + + // Check values + l_val = 0; + for (uint32_t i = 0; i < 2; i++) + { + for (uint32_t j = 0; j < 3; j++) + { + for (uint32_t k = 0; k < 4; k++) + { + if (l_uint32Array[i][j][k] != l_val) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT32_ARRAY. " + "GET returned %d in index %d:%d:%d (2)", + l_uint32Array[i][j][j], i, j, k); + break; + } + l_val++; + } + + if (l_rc) + { + break; + } + } + + if (l_rc) + { + break; + } + } + + if (l_rc) + { + break; + } + + //---------------------------------------------------------------------- + // Test ATTR_TEST_UINT64_ARRAY ([5]. PLAT (sets vals to 4). RO) + //---------------------------------------------------------------------- + uint64_t l_uint64Array[5]; + + // Test get + l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64_ARRAY, NULL, l_uint64Array); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT64_ARRAY. Error from GET"); + break; + } + + // Check values + for (uint32_t i = 0; i < 5; i++) + { + if (l_uint64Array[i] != 4) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT64_ARRAY. GET " + "returned %d in index %d", + static_cast<uint32_t>(l_uint64Array[i]), i); + break; + } + } + + if (l_rc) + { + break; + } + + // Cannot set read-only attribute + + //---------------------------------------------------------------------- + // Test ATTR_TEST_STRING1 (DefaultVal 'mike') + //---------------------------------------------------------------------- + char * l_pString1 = NULL; + + // Test get + l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING1, NULL, l_pString1); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING1. Error from GET"); + break; + } + + // Check value + if (l_pString1 == NULL) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING1. GET returned NULL"); + break; + } + + if (strcmp(l_pString1, "mike") != 0) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING1. GET returned %s", + l_pString1); + break; + } + + delete [] l_pString1; + + // Test set + l_pString1 = "test1"; + + l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING1, NULL, l_pString1); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING1. Error from SET"); + break; + } + + l_pString1 = NULL; + + // Test get + l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING1, NULL, l_pString1); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING1. Error from GET (2)"); + break; + } + + // Check value + if (l_pString1 == NULL) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING1. GET returned NULL (2)"); + break; + } + + if (strcmp(l_pString1, "test1") != 0) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING1. GET returned %s (2)", + l_pString1); + break; + } + + delete [] l_pString1; + + //---------------------------------------------------------------------- + // Test ATTR_TEST_STRING2 (PLAT (sets val to 'platString')) + //---------------------------------------------------------------------- + char * l_pString2 = NULL; + + // Test get + l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING2, NULL, l_pString2); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING2. Error from GET"); + break; + } + + // Check value + if (l_pString2 == NULL) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING2. GET returned NULL"); + break; + } + + if (strcmp(l_pString2, "platString") != 0) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING2. GET returned %s", + l_pString2); + break; + } + + + // All of the following should not compile due to setting read-only + // attributes + //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT32, NULL, l_uint32); + //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64_ARRAY, NULL, l_uint64Array); + + // All of the following should not compile due to wrong types used + //l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING1, NULL, l_uint8); + //l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING2, NULL, l_uint32); + //l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING1, NULL, l_uint64); + //l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING2, NULL, l_uint8Array); + //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT8, NULL, l_pString1); + //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT32, NULL, l_uint8); + //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64, NULL, l_uint8Array); + //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64, NULL, l_uint64Array); + //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT8_ARRAY, NULL, l_pString1); + //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT32_ARRAY, NULL, l_uint8); + //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64_ARRAY, NULL, l_uint64); + //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64_ARRAY, NULL, &l_uint32Array[0][0][0]); + + //l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING1, NULL, l_uint8); + //l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING2, NULL, l_uint32); + //l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING1, NULL, l_uint64); + //l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING2, NULL, l_uint64Array); + //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT8, NULL, l_pString1); + //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT32, NULL, l_uint64); + //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64, NULL, &l_uint32Array[0][0][0]); + //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64, NULL, l_uint64Array); + //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT8_ARRAY, NULL, l_pString2); + //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT32_ARRAY, NULL, l_uint8); + //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64_ARRAY, NULL, l_uint64); + + } while (0); + + return l_rc; +} + +} // extern "C" diff --git a/src/usr/hwpf/plat/fapiPlatUtil.C b/src/usr/hwpf/plat/fapiPlatUtil.C index b8d47619a..8a3e22bf9 100644 --- a/src/usr/hwpf/plat/fapiPlatUtil.C +++ b/src/usr/hwpf/plat/fapiPlatUtil.C @@ -6,8 +6,9 @@ * Note that platform code must provide the implementation. */ +#include <assert.h> #include <trace/interface.H> -#include <fapi.H> +#include <fapiPlatTrace.H> //****************************************************************************** // Trace descriptors |