From 2935ed01dae82a91c1bb4c181fd36cc42b2efaf9 Mon Sep 17 00:00:00 2001 From: Mike Jones Date: Fri, 12 Aug 2011 11:03:30 -0500 Subject: HWPF Error Info Support Change-Id: Ib060599a4b64e768cbc75184a050e851c0a39c4e Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/250 Tested-by: Jenkins Server Reviewed-by: A. Patrick Williams III Reviewed-by: Nicholas E. Bofferding --- src/include/usr/hwpf/fapi/fapi.H | 12 +- src/include/usr/hwpf/fapi/fapiCollectFfdc.H | 50 +++++ src/include/usr/hwpf/fapi/fapiErrorInfo.H | 223 ++++++++++++++++++++++ src/include/usr/hwpf/fapi/fapiErrorInfoMem.H | 87 +++++++++ src/include/usr/hwpf/fapi/fapiHwpExecutor.H | 26 +++ src/include/usr/hwpf/fapi/fapiReturnCode.H | 117 +++++++++--- src/include/usr/hwpf/fapi/fapiReturnCodeDataRef.H | 139 +++++++++++--- src/include/usr/hwpf/fapi/fapiReturnCodes.H | 2 + 8 files changed, 600 insertions(+), 56 deletions(-) create mode 100644 src/include/usr/hwpf/fapi/fapiCollectFfdc.H create mode 100644 src/include/usr/hwpf/fapi/fapiErrorInfo.H create mode 100644 src/include/usr/hwpf/fapi/fapiErrorInfoMem.H create mode 100644 src/include/usr/hwpf/fapi/fapiHwpExecutor.H (limited to 'src/include/usr/hwpf/fapi') diff --git a/src/include/usr/hwpf/fapi/fapi.H b/src/include/usr/hwpf/fapi/fapi.H index cc2066990..a801ba026 100644 --- a/src/include/usr/hwpf/fapi/fapi.H +++ b/src/include/usr/hwpf/fapi/fapi.H @@ -4,6 +4,16 @@ * @brief Includes all the header files necessary for the FAPI interface. */ +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 04/13/2011 Created. + * mjjones 06/07/2011 Added new includes. + * mjjones 08/08/2011 Updated Executor include + * + */ + #ifndef FAPI_H_ #define FAPI_H_ @@ -13,7 +23,7 @@ #include #include #include -#include +#include #include #include // Generated file #include // Generated file diff --git a/src/include/usr/hwpf/fapi/fapiCollectFfdc.H b/src/include/usr/hwpf/fapi/fapiCollectFfdc.H new file mode 100644 index 000000000..ccee96a93 --- /dev/null +++ b/src/include/usr/hwpf/fapi/fapiCollectFfdc.H @@ -0,0 +1,50 @@ +/** + * @file fapiCollectFfdc.H + * + * @brief Defines the fapiCollectFfdc function + */ + +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 08/09/2011 Created. + */ + +#ifndef FAPICOLLECTFFDC_H_ +#define FAPICOLLECTFFDC_H_ + +#include +#include + +namespace fapi +{ + +/** + * @brief Collect FFDC + * + * Collect FFDC. This function should be called by PLAT when it is processing + * a ReturnCode generated by a HWP and the ErrorInfoRepository contains a record + * for the error indicating that FFDC should be collected. This function is + * implemented in the generated fapiCollectFfdc.C file (generated using data + * from the Error Information XML file) + * + * @param[in] i_token FFDC HWP token (retrieved from ErrorInfoRepository) + * @param[in] i_target Reference to Target to collect FFDC from + * @param[out] o_pFfdc Reference to uint8_t pointer. Set to point to a newly + * allocated array containing FFDC data + * @param[out] o_size Reference to uint32_t. Set to the size of the FFDC + * data + * + * @return ReturnCode + * + * @note Caller must delete the data with "delete [] o_pFfdc" + */ +ReturnCode fapiCollectFfdc(const FfdcHwpToken i_token, + const Target & i_target, + uint8_t * & o_pFfdc, + uint32_t & o_size); + +} + +#endif // FAPICOLLECTFFDC_H_ diff --git a/src/include/usr/hwpf/fapi/fapiErrorInfo.H b/src/include/usr/hwpf/fapi/fapiErrorInfo.H new file mode 100644 index 000000000..808a0c0e3 --- /dev/null +++ b/src/include/usr/hwpf/fapi/fapiErrorInfo.H @@ -0,0 +1,223 @@ +/** + * @file fapiErrorInfo.H + * + * @brief Defines the ErrorInfoRepository, ErrorInfoRecord and associated + * classes. + */ + +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 08/09/2011 Created. + */ + +#ifndef FAPIERRORINFO_H_ +#define FAPIERRORINFO_H_ + +#include +#include +#include +#include +#include + +namespace fapi +{ + +/** + * @enum CalloutPriority + * + * This enumeration defines the possible callout priorities + */ +enum CalloutPriority +{ + HIGH = 1, + MEDIUM = 2, + LOW = 3, +}; + +/** + * @struct ErrorInfoCallout + * + * This struct defines a target callout. An ErrorInfoRecord can contain a number + * of these. + */ +struct ErrorInfoCallout +{ + /** + * @brief Constructor. + * + * @param[in] i_targetType The type of the target being called out. If the + * same as the target of the HWP that generated the + * error then that is the target + * @param[in] i_targetPos The position of the target being called out. + * Relative to the target of the HWP that generated + * the error + * @param[in] i_priority The priority of the callout + */ + ErrorInfoCallout(const TargetType i_targetType, + const uint32_t i_targetPos, + const CalloutPriority i_priority); + + // The type of the target being called out. See ctor for details + TargetType iv_targetType; + + // The position of the target being called out. See ctor for details + uint32_t iv_targetPos; + + // The priority of the callout + CalloutPriority iv_priority; +}; + +/** + * @struct ErrorInfoFfdc + * + * This struct defines FFDC collection information. An ErrorInfoRecord can + * contain a number of these. + */ +struct ErrorInfoFfdc +{ + /** + * @brief Constructor. + * + * @param[in] i_targetType The type of the target to collect FFDC from. If + * the same as the target of the HWP that + * generated the error then that is the target + * @param[in] i_targetPos The position of the target to collect FFDC + * from. Relative to the target of the HWP that + * generated the error + * @param[in] i_ffdcHwpToken The token used to identify the HWP to call to + * collect FFDC + */ + ErrorInfoFfdc(const TargetType i_targetType, + const uint32_t i_targetPos, + const FfdcHwpToken i_ffdcHwpToken); + + // The type of the target to collect FFDC from. See ctor for details + TargetType iv_targetType; + + // The position of the target to collect FFDC from. See ctor for details + uint32_t iv_targetPos; + + // The token used to identify the HWP to call to collect FFDC + FfdcHwpToken iv_ffdcHwpToken; +}; + +/** + * @struct ErrorInfoRecord + * + * This struct defines the error information record. This gives information + * about a specific HWP generated ReturnCode value. + */ +struct ErrorInfoRecord +{ + /** + * @brief Default constructor. + */ + ErrorInfoRecord(); + + /** + * @brief Copy constructor. + * + * @param[in] i_right Reference to ErrorInfoRecord to copy + */ + ErrorInfoRecord(const ErrorInfoRecord & i_right); + + /** + * @brief Destructor + */ + ~ErrorInfoRecord(); + + /** + * @brief Assignment operator + * + * @param[in] i_right Reference to ErrorInfoRecord to copy + * + * @return Reference to 'this' ErrorInfoRecord + */ + ErrorInfoRecord & operator=(const ErrorInfoRecord & i_right); + + /** + * @brief Set Description function + * + * @param[in] i_pDesc Pointer to C string that is copied + */ + void setDescription(const char * i_pDescription); + + /** + * @brief Get Description function + * + * @return pointer to description (NULL if no description set) + */ + const char * getDescription(); + + // The Return Code value + uint32_t iv_rc; + + // Vector of target callouts + std::vector iv_callouts; + typedef std::vector::iterator ErrorInfoCalloutItr_t; + + // Vector of FFDC collection information + std::vector iv_ffdcs; + typedef std::vector::iterator ErrorInfoFfdcItr_t; + +private: + // C-String containing the description of the error + char * iv_pDescription; +}; + +/** + * @class ErrorInfoRepository + * + * This class defines the error information repository. It provides an + * ErrorInfoRecord given a ReturnCode value. This is an abstract class that a + * concrete class must derive from. + */ +class ErrorInfoRepository +{ +public: + + /** + * @brief Get the singleton instance. + * + * This function must be implemented by a concrete derived class + */ + static ErrorInfoRepository& Instance(); + + /** + * @brief Default constructor. + */ + ErrorInfoRepository(); + + /** + * @brief Destructor + */ + virtual ~ErrorInfoRepository(); + + /** + * @brief Find Error Information Record for given ReturnCode value + * + * This is a pure virtual function that must be implemented by a concrete + * derived class + * + * @param[in] i_rc The ReturnCode value. User can pass in a ReturnCode + * object and it will be implicitly converted to a + * uint32_t using the ReturnCode conversion operator + * @param[out] o_record Reference to a ErrorInfoRecord. If the record is + * found then it is assigned to o_record, else it is + * not. User should pass an ErrorInfoRecord with a good + * ReturnCode value and then look to see if the value + * was changed to the ReturnCode value to figure out if + * the record was found. + * + * @return ReturnCode. Zero on success else error accessing the repository + */ + virtual ReturnCode find(const uint32_t i_rc, + ErrorInfoRecord & o_record) = 0; + +}; + +} + +#endif // FAPIERRORINFO_H_ diff --git a/src/include/usr/hwpf/fapi/fapiErrorInfoMem.H b/src/include/usr/hwpf/fapi/fapiErrorInfoMem.H new file mode 100644 index 000000000..e30111687 --- /dev/null +++ b/src/include/usr/hwpf/fapi/fapiErrorInfoMem.H @@ -0,0 +1,87 @@ +/** + * @file fapiErrorInfoMem.H + * + * @brief Defines the ErrorInfoRepositoryMem class. + * + * ErrorInfoRepositoryMem is a concrete Error Info repository that stores + * ErrorInfoRecords in heap based memory. A particular platform may choose to + * implement a different repository (in which case it would not compile this + * file) + */ + +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 08/08/2011 Created. + */ + +#ifndef FAPIERRORINFOMEM_H_ +#define FAPIERRORINFOMEM_H_ + +#include +#include +#include +#include + +namespace fapi +{ + +/** + * @class ErrorInfoRepositoryMem + * + * This class defines a concrete error information repository. ErrorInfoRecords + * are stored in heap based memory. + */ +class ErrorInfoRepositoryMem : public ErrorInfoRepository +{ +public: + + /** + * @brief Default constructor. + */ + ErrorInfoRepositoryMem(); + + /** + * @brief Destructor + */ + virtual ~ErrorInfoRepositoryMem(); + + /** + * @brief Find Error Information Record for given ReturnCode value + * + * Implementation of pure virtual function in base ErrorInfoRepository class + * + * @param[in] i_rc The ReturnCode value. User can pass in a ReturnCode + * object and it will be implicitly converted to a + * uint32_t using the ReturnCode conversion operator + * @param[out] o_record Reference to a ErrorInfoRecord. If the record is + * found then it is assigned to o_record, else it is + * not. User should pass an ErrorInfoRecord with a good + * ReturnCode value and then look to see if the value + * was changed to the ReturnCode value to figure out if + * the record was found. + * + * @return ReturnCode. Always success. + */ + virtual ReturnCode find(const uint32_t i_rc, + ErrorInfoRecord & o_record); + +private: + + /** + * @brief Initialize the repository with ErrorInfoRecords + * + * This function is implemented in the generated fapiErrorInfoMemInit.C file + * (generated using data from the Error Information XML file) + */ + void init(); + + // Vector of ErrorInfoRecords + std::vector iv_errorInfoRecords; + typedef std::vector::iterator ErrorInfoRecordItr_t; +}; + +} + +#endif // FAPIERRORINFOMEM_H_ diff --git a/src/include/usr/hwpf/fapi/fapiHwpExecutor.H b/src/include/usr/hwpf/fapi/fapiHwpExecutor.H new file mode 100644 index 000000000..d10e8f4a3 --- /dev/null +++ b/src/include/usr/hwpf/fapi/fapiHwpExecutor.H @@ -0,0 +1,26 @@ +/** + * @file fapiHwpExecutor.H + * + * @brief Defines the FAPI HWP Executor Macro. + * + * The FAPI HWP Executor macro is called when a PLAT invoker function or a HWP + * wants to execute a HWP. + */ + +#ifndef FAPIHWPEXECUTOR_H_ +#define FAPIHWPEXECUTOR_H_ + +#include + +/** + * @brief HWP Executor macro + * + * This macro calls a PLAT macro which will do any platform specific work to + * execute the HWP (e.g. dlopening a shared library) and then calls a function + * on the ReturnCode to store the error target if there is an error + */ +#define FAPI_EXEC_HWP(RC, FUNC, TARGET, _args_...) \ + FAPI_PLAT_EXEC_HWP(RC, FUNC, TARGET, ##_args_); \ + RC.setErrTarget(TARGET) + +#endif // FAPIHWPEXECUTOR_H_ diff --git a/src/include/usr/hwpf/fapi/fapiReturnCode.H b/src/include/usr/hwpf/fapi/fapiReturnCode.H index d7e35b772..7d0511f77 100644 --- a/src/include/usr/hwpf/fapi/fapiReturnCode.H +++ b/src/include/usr/hwpf/fapi/fapiReturnCode.H @@ -9,7 +9,9 @@ * Flag Defect/Feature User Date Description * ------ -------------- ---------- ----------- ---------------------------- * mjjones 04/13/2011 Created. - * mjjones 07/05/2011. Removed const from data + * mjjones 07/05/2011 Removed const from data + * mjjones 07/25/2011 Added support for FFDC and + * Error Target */ #ifndef FAPIRETURNCODE_H_ @@ -17,13 +19,15 @@ #include #include +#include #include namespace fapi { -// Forward declaration -class ReturnCodeDataRef; +// Forward declarations +class ReturnCodePlatDataRef; +class ReturnCodeHwpFfdcRef; /** * @class ReturnCode @@ -32,17 +36,19 @@ class ReturnCodeDataRef; * code value) which is of type uint32_t. A user can treat a ReturnCode just * as if it were a uint32_t. * - * FAPI, PLAT and HWP code can all create a ReturnCode. PLAT can optionally add - * platform specific ReturnCodeData to it. + * FAPI, PLAT and HWP code can all create a ReturnCode. + * PLAT can associate PlatData to it (use-case is an error log). + * HWP can add HwpFfdc to it. + * FAPI can add an error target to it (use-case is to record which target was + * the subject of a HWP that generated an error) * * A ReturnCode is copyable and assignable. Therefore, it cannot be subclassed. * - * When a ReturnCode is copied, any ReturnCodeData is not copied because it may - * be heavyweight. Both ReturnCodes will refer to the same ReturnCodeData. - * ReturnCodeData is only deleted when the last ReturnCode with a reference to - * it is deleted. It is possible for PLAT to get a pointer to the ReturnCodeData - * and to optionally release the data (ReturnCode no longer responsible for - * deleting). This is done using the intermediate ReturnCodeDataRef class. + * When a ReturnCode is copied, any PlatData or HwpFfdc is not copied because it + * may be heavyweight. Both ReturnCodes will refer to the same data. Data is + * only deleted when the last ReturnCode with a reference to it is deleted. It + * is possible for PLAT to get a pointer to the PlatData and to optionally + * release the data (ReturnCode no longer responsible for deleting). * * A ReturnCode object is not thread safe, multiple threads must not use the * same ReturnCode object concurrently. @@ -126,35 +132,59 @@ public: operator uint32_t() const; /** - * @brief Get a pointer to any ReturnCodeData. ReturnCode is still - * responsible for deletion of the data. The caller must not delete + * @brief Get a pointer to any PlatData. ReturnCode is still responsible for + * deletion of the data. The caller must not delete * - * The data pointed to is only meaningful to platform code. + * The data pointed to is only meaningful to platform code. The data pointer + * should be used immediately in the same thread because it may be deleted + * in the future. * - * @return void *. Pointer to any ReturnCodeData. If NULL then no data + * @return void *. Pointer to any PlatData. If NULL then no data */ - void * getData() const; + void * getPlatData() const; /** - * @brief Get a pointer to any ReturnCodeData and release ownership from + * @brief Get a pointer to any PlatData and release ownership from * ReturnCode. The caller is responsible for deletion. * * The data pointed to is only meaningful to platform code. * - * @return void *. Pointer to any ReturnCodeData. If NULL then no data + * @return void *. Pointer to any PlatData. If NULL then no data */ - void * releaseData(); + void * releasePlatData(); /** - * @brief Sets ReturnCodeData. The ReturnCode object takes responsibility - * for deleting the data (platform code actually implements the - * delete function and must know the type and how to delete it). + * @brief Associates heap based PlatData with the ReturnCode. The ReturnCode + * object takes responsibility for deleting the data (platform code + * actually implements the delete function and must know the type and + * how to delete it). * - * The data pointed to is only meaningful to platform code. + * The data pointed to is only meaningful to platform code. This is expected + * to be used to associate a platform error log with the ReturnCode. * - * param[in] i_pData Pointer to ReturnCodeData (on the heap) + * param[in] i_pData Pointer to PlatData (on the heap) */ - void setData(void * i_pData); + void setPlatData(void * i_pData); + + /** + * @brief Get a pointer to any stored HwpFfdc. + * + * The data pointer should be used immediately in the same thread because it + * is a pointer to internal object data. + * + * param[out] o_size Size of the FFDC data in bytes. + * + * @return void *. Pointer to any HwpFfdc. If NULL then no data + */ + const void * getHwpFfdc(uint32_t & o_size) const; + + /** + * @brief Stores a copy of the provided HwpFfdc + * + * param[in] i_pFfdc Pointer to HwpFfdc + * param[in] i_size Size of the FFDC data in bytes + */ + void setHwpFfdc(const void * i_pFfdc, const uint32_t i_size); /** * @brief Gets the creator of the return code @@ -163,18 +193,47 @@ public: */ returnCodeCreator getCreator() const; + /** + * @brief Stores a copy of the provided Target if there is an error and no + * Target is already stored + * + * This is intended to be used by FAPI_EXEC_HWP to record which target was + * the subject of a HWP that generated an error. + * + * param[in] i_target Reference to Target + */ + void setErrTarget(const Target & i_target); + + /** + * @brief Gets the error target + * + * @return Target *. Pointer to Target. If NULL then no error Target + */ + Target * getErrTarget() const; + private: /** - * @brief Removes interest in pointed to ReturnCodeDataRef + * @brief Removes interest in pointed to ReturnCodePlatDataRef + */ + void removePlatData(); + + /** + * @brief Removes interest in pointed to ReturnCodeHwpFfdcRef */ - void removeData(); + void removeHwpFfdc(); // The rcValue uint32_t iv_rcValue; - // Pointer to ReturnCodeDataRef - ReturnCodeDataRef * iv_pDataRef; + // Pointer to ReturnCodePlatDataRef + ReturnCodePlatDataRef * iv_pPlatDataRef; + + // Pointer to ReturnCodeHwpFfdcRef + ReturnCodeHwpFfdcRef * iv_pHwpFfdcRef; + + // Pointer to error Target + Target * iv_pErrTarget; }; } diff --git a/src/include/usr/hwpf/fapi/fapiReturnCodeDataRef.H b/src/include/usr/hwpf/fapi/fapiReturnCodeDataRef.H index 855191b95..65f2f5f50 100644 --- a/src/include/usr/hwpf/fapi/fapiReturnCodeDataRef.H +++ b/src/include/usr/hwpf/fapi/fapiReturnCodeDataRef.H @@ -11,6 +11,7 @@ * ------ -------------- ---------- ----------- ---------------------------- * mjjones 04/13/2011 Created. * mjjones 07/05/2011. Removed const from data + * mjjones 07/25/2011 Added support for FFDC */ #ifndef FAPIRETURNCODEDATAREF_H_ @@ -25,15 +26,9 @@ namespace fapi /** * @class ReturnCodeDataRef * - * This class contains a pointer to platform specific ReturnCodeData and a - * reference count recording how many ReturnCodes have a pointer to itself. - * - * It is used exclusively by the ReturnCode class. Multiple copies of a - * ReturnCode will all point to the same ReturnCodeDataRef. The ReturnCodes - * maintain the reference count, the last ReturnCode to remove its reference - * will delete the ReturnCodeDataRef which in turn deletes the ReturnCodeData. - * The ReturnCodeData pointer is maintained in this class so that releasing the - * data releases it from all ReturnCode copies. + * This class is a simple reference counter. Derived classes are used by a + * ReturnCode object in order to maintain a count of how many ReturnCode objects + * have a reference to the object. * * A ReturnCodeDataRef object is not thread safe, multiple threads must not use * the same ReturnCodeDataRef object concurrently. @@ -44,15 +39,13 @@ public: /** * @brief Constructor - * - * @param[in] i_pData Pointer to platform specific ReturnCodeData */ - explicit ReturnCodeDataRef(void * i_pData); + ReturnCodeDataRef(); /** * @brief Destructor */ - ~ReturnCodeDataRef(); + virtual ~ReturnCodeDataRef(); /** * @brief Increments the ref count @@ -66,49 +59,143 @@ public: */ bool decRefCountCheckZero(); +private: + + // Copy constructor and assignment operator disabled + ReturnCodeDataRef(const ReturnCodeDataRef & i_right); + ReturnCodeDataRef & operator=(const ReturnCodeDataRef & i_right); + + // The reference count (how many ReturnCodes are pointing to this object) + uint32_t iv_refCount; +}; + +/** + * @class ReturnCodePlatDataRef + * + * This class contains a pointer to PlatData and inherits from ReturnCodeDataRef + * for a reference count recording how many ReturnCodes have a pointer to it. + * + * It is used exclusively by the ReturnCode class. Multiple copies of a + * ReturnCode will all point to the same ReturnCodePlatDataRef. The ReturnCodes + * maintain the reference count, the last ReturnCode to remove its reference + * will delete the ReturnCodePlatDataRef which in turn deletes the PlatData. + * The PlatData pointer is maintained in this class so that releasing the data + * releases it from all ReturnCode copies. + * + * A ReturnCodePlatDataRef object is not thread safe, multiple threads must not + * use the same ReturnCodePlatDataRef object concurrently. + */ +class ReturnCodePlatDataRef : public ReturnCodeDataRef +{ +public: + /** - * @brief Get a pointer to ReturnCodeData. ReturnCodeDataRef is still + * @brief Constructor + * + * @param[in] i_pData Pointer to PlatData to associate + */ + explicit ReturnCodePlatDataRef(void * i_pData); + + /** + * @brief Destructor + */ + virtual ~ReturnCodePlatDataRef(); + + /** + * @brief Get a pointer to any PlatData. ReturnCodePlatDataRef is still * responsible for deletion of the data. The caller must not delete * * The pointer is only meaningful to platform code. * - * @return void *. Pointer to ReturnCodeData. If NULL then no data (must - * have been released) + * @return void *. Pointer to PlatData. If NULL then no data (must have been + * released) */ void * getData() const; /** - * @brief Get a pointer to any ReturnCodeData and release ownership from + * @brief Get a pointer to any PlatData and release ownership from * ReturnCodeDataRef. The caller is responsible for deletion. * * The pointer is only meaningful to platform code. * - * @return void *. Pointer to ReturnCodeData. If NULL then no data (must - * have been released) + * @return void *. Pointer to PlatData. If NULL then no data (must have been + * released) */ void * releaseData(); private: // Copy constructor and assignment operator disabled - ReturnCodeDataRef(const ReturnCodeDataRef & i_right); - ReturnCodeDataRef & operator=(const ReturnCodeDataRef & i_right); + ReturnCodePlatDataRef(const ReturnCodePlatDataRef & i_right); + ReturnCodePlatDataRef & operator=(const ReturnCodePlatDataRef & i_right); /** - * @brief Deletes the ReturnCodeData + * @brief Deletes the PlatData * * @note Implemented by platform code because only platform code knows the * type of the data and how to delete it. */ void deleteData(); - // The reference count (how many ReturnCodes are pointing to this object) - uint32_t iv_refCount; - - // Pointer to platform specific ReturnCodeData + // Pointer to PlatData void * iv_pData; }; +/** + * @class ReturnCodeHwpFfdcRef + * + * This class contains HwpFfdc and inherits from ReturnCodeDataRef for a + * reference count recording how many ReturnCodes have a pointer to it. + * + * It is used exclusively by the ReturnCode class. Multiple copies of a + * ReturnCode will all point to the same ReturnCodeHwpFfdcRef. The ReturnCodes + * maintain the reference count, the last ReturnCode to remove its reference + * will delete the ReturnCodeHwpFfdcRef which in turn deletes the contained + * HwpFfdc. + * + * A ReturnCodeHwpFfdcRef object is not thread safe, multiple threads must not + * use the same ReturnCodeHwpFfdcRef object concurrently. + */ +class ReturnCodeHwpFfdcRef : public ReturnCodeDataRef +{ +public: + + /** + * @brief Constructor + * + * @param[in] i_pFfdc Pointer to the FFDC to copy + * @param[in] i_size Size of the FFDC to copy + */ + ReturnCodeHwpFfdcRef(const void * i_pFfdc, + const uint32_t i_size); + + /** + * @brief Destructor + */ + virtual ~ReturnCodeHwpFfdcRef(); + + /** + * @brief Get a pointer to the HwpFfdc. + * + * @param[out] o_size Size of the FFDC data in bytes. + * + * @return void *. Pointer to HwpFfdc. + */ + const void * getData(uint32_t & o_size) const; + +private: + + // Copy constructor and assignment operator disabled + ReturnCodeHwpFfdcRef(const ReturnCodeHwpFfdcRef & i_right); + ReturnCodeHwpFfdcRef & operator=(const ReturnCodeHwpFfdcRef & i_right); + + // Pointer to HwpFfdc + uint8_t * iv_pFfdc; + + // Size of HwpFfdc + uint32_t iv_size; +}; + } #endif // FAPIRETURNCODEDATAREF_H_ diff --git a/src/include/usr/hwpf/fapi/fapiReturnCodes.H b/src/include/usr/hwpf/fapi/fapiReturnCodes.H index 2b761dbde..fd365347d 100644 --- a/src/include/usr/hwpf/fapi/fapiReturnCodes.H +++ b/src/include/usr/hwpf/fapi/fapiReturnCodes.H @@ -11,6 +11,7 @@ * 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 + * mjjones 08/10/2011 Add FAPI_RC_FFDC_HWP_NOT_FOUND * */ @@ -38,6 +39,7 @@ enum // FAPI generated return codes FAPI_RC_NOT_IMPLEMENTED = FAPI_RC_FAPI_MASK | 0x01, FAPI_RC_ATTR_UNIT_TEST_FAIL = FAPI_RC_FAPI_MASK | 0x02, + FAPI_RC_FFDC_HWP_NOT_FOUND = FAPI_RC_FAPI_MASK | 0x03, // PLAT generated return codes FAPI_RC_PLAT_ERR_SEE_DATA = FAPI_RC_PLAT_MASK | 0x01, -- cgit v1.2.1