diff options
Diffstat (limited to 'src/include')
-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 |
8 files changed, 144 insertions, 378 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_ |