summaryrefslogtreecommitdiffstats
path: root/src/include/usr/hwpf/fapi
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/usr/hwpf/fapi')
-rw-r--r--src/include/usr/hwpf/fapi/fapiAttributeOverride.H207
-rw-r--r--src/include/usr/hwpf/fapi/fapiAttributeService.H103
2 files changed, 272 insertions, 38 deletions
diff --git a/src/include/usr/hwpf/fapi/fapiAttributeOverride.H b/src/include/usr/hwpf/fapi/fapiAttributeOverride.H
new file mode 100644
index 000000000..2a125a5ec
--- /dev/null
+++ b/src/include/usr/hwpf/fapi/fapiAttributeOverride.H
@@ -0,0 +1,207 @@
+/* IBM_PROLOG_BEGIN_TAG
+ * This is an automatically generated prolog.
+ *
+ * $Source: src/include/usr/hwpf/fapi/fapiAttributeOverride.H $
+ *
+ * IBM CONFIDENTIAL
+ *
+ * COPYRIGHT International Business Machines Corp. 2012
+ *
+ * p1
+ *
+ * Object Code Only (OCO) source materials
+ * Licensed Internal Code Source Materials
+ * IBM HostBoot Licensed Internal Code
+ *
+ * The source code for this program is not published or other-
+ * wise divested of its trade secrets, irrespective of what has
+ * been deposited with the U.S. Copyright Office.
+ *
+ * Origin: 30
+ *
+ * IBM_PROLOG_END_TAG
+ */
+/**
+ * @file fapiAttributeOverride.H
+ *
+ * @brief Defines the AttributeOverrides and AttributeOverride classes. A
+ * platform can choose to use an AttributeOverrides object to store
+ * Attribute Overrides.
+ */
+
+/*
+ * Change Log ******************************************************************
+ * Flag Defect/Feature User Date Description
+ * ------ -------------- ---------- ----------- ----------------------------
+ * mjjones 06/07/2012 Created
+ */
+
+#ifndef FAPIATTROVERRIDE_H_
+#define FAPIATTROVERRIDE_H_
+
+#include <stdint.h>
+#include <list>
+#include <fapiAttributeIds.H>
+#include <fapiTarget.H>
+
+namespace fapi
+{
+
+/**
+ * @enum AttributeOverrideType
+ *
+ * Enumeration of the possible attribute override types
+ */
+enum AttributeOverrideType
+{
+ ATTR_OVERRIDE_CONST = 1, // Not cleared by a FAPI_ATTR_SET
+ ATTR_OVERRIDE_NON_CONST = 2, // Cleared by a FAPI_ATTR_SET
+ ATTR_OVERRIDE_CLEAR_ALL = 3, // Clear all overrides
+};
+
+// Constants for various fields in AttributeOverrides
+const uint16_t ATTR_POS_NA = 0xffff; // iv_pos not applicable
+const uint8_t ATTR_UNIT_POS_NA = 0xff; // iv_unitPos not applicable
+const uint8_t ATTR_ARRAYD_NA = 0xff; // iv_arayX not applicable
+
+/**
+ * @struct AttributeOverride
+ *
+ * This structure defines a single attribute override. In the case of an array
+ * attribute, it is an override for a single element
+ */
+struct AttributeOverride
+{
+ uint64_t iv_overrideVal; // Large enough to hold the biggest attribute size
+ uint32_t iv_attrId; // fapi::AttributeId enum value
+ uint32_t iv_targetType; // fapi::TargetType enum value
+ uint16_t iv_pos; // For chips/dimms the position
+ // For chiplets the parent chip position
+ uint8_t iv_unitPos; // For chiplets the position
+ uint8_t iv_overrideType; // fapi::AttributeOverrideType enum value
+ uint8_t iv_arrayD1; // Applies to element D1 in 1D or more array atts
+ uint8_t iv_arrayD2; // Applies to element D2 in 2D or more array atts
+ uint8_t iv_arrayD3; // Applies to element D3 in 3D or more array atts
+ uint8_t iv_arrayD4; // Applies to element D4 in 4D array atts
+};
+
+/**
+ * @class AttributeOverrides
+ *
+ * This class can be used to set and query attribute overrides
+ */
+class AttributeOverrides
+{
+public:
+ /**
+ * @brief Default constructor
+ */
+ AttributeOverrides();
+
+ /**
+ * @brief Destructor
+ */
+ ~AttributeOverrides();
+
+ /**
+ * @brief Clear all overrides
+ */
+ void clearOverrides();
+
+ /**
+ * @brief Clear any non-const override for a specified ID and Target
+ *
+ * @param[in] i_attrId Attribute ID
+ * @param[in] i_pTarget Pointer to Target (NULL if system)
+ */
+ void clearNonConstOverride(const fapi::AttributeId i_attrId,
+ const fapi::Target * const i_pTarget);
+
+ /**
+ * @brief Set an override
+ *
+ * Note that no checking is done for duplicate overrides (an override on an
+ * attribute that already has an override) for performance. If a duplicate
+ * override is done then getOverride will return the first one.
+ *
+ * @param[in] i_override Reference to override structure, this is copied
+ */
+ void setOverride(const AttributeOverride & i_override);
+
+ /**
+ * @brief Get an override
+ *
+ * Note that for array attributes, this must be called repeatedly, to query
+ * an override for each element of the array
+ *
+ * @param[in] i_attrId Attribute ID
+ * @param[in] i_pTarget Pointer to Target (NULL if system)
+ * @param[out] o_overrideVal Reference that is filled in with the override
+ * @param[in] i_arrayD1 Array dimension 1 if applicable
+ * @param[in] i_arrayD2 Array dimension 2 if applicable
+ * @param[in] i_arrayD3 Array dimension 3 if applicable
+ * @param[in] i_arrayD4 Array dimension 4 if applicable
+ *
+ * return true if override exists and was returned.
+ */
+ bool getOverride(const fapi::AttributeId i_attrId,
+ const fapi::Target * const i_pTarget,
+ uint64_t & o_overrideVal,
+ const uint8_t i_arrayD1 = ATTR_ARRAYD_NA,
+ const uint8_t i_arrayD2 = ATTR_ARRAYD_NA,
+ const uint8_t i_arrayD3 = ATTR_ARRAYD_NA,
+ const uint8_t i_arrayD4 = ATTR_ARRAYD_NA);
+
+ /**
+ * @brief Returns if any overrides exist
+ *
+ * This is only expected to be called by unit test
+ *
+ * return true if any overrides exist
+ */
+ bool overridesExist();
+
+private:
+ // Copy constructor and assignment operator disabled
+ AttributeOverrides(const AttributeOverrides & i_right);
+ AttributeOverrides & operator=(const AttributeOverrides & i_right);
+
+ /**
+ * @brief Returns if the specified override is for the specified
+ * attribute ID and Target
+ *
+ * @param[in] i_attrId Attribute ID
+ * @param[in] i_pTarget Pointer to Target (NULL if system)
+ * @param[in] i_candidate Reference to AttributeOverride
+ *
+ * @return true if the AttributeOverride matches
+ */
+ static bool overrideMatch(const fapi::AttributeId i_attrId,
+ const fapi::Target * const i_pTarget,
+ const AttributeOverride & i_candidate);
+
+ /**
+ * @brief Locks the AttributeOverrides object
+ *
+ * Implemented by the platform
+ */
+ static void platLock();
+
+ /**
+ * @brief Unlocks the AttributeOverrides object
+ *
+ * Implemented by the platform
+ */
+ static void platUnlock();
+
+ // The attribute overrides
+ bool iv_overridesExist;
+ std::list<AttributeOverride *> iv_overrides;
+ typedef std::list<AttributeOverride *>::iterator OverridesItr_t;
+ typedef std::list<AttributeOverride *>::const_iterator OverridesCItr_t;
+
+};
+
+}
+
+#endif // FAPIATTROVERRIDE_H_
diff --git a/src/include/usr/hwpf/fapi/fapiAttributeService.H b/src/include/usr/hwpf/fapi/fapiAttributeService.H
index 35f370c6d..1744d11a6 100644
--- a/src/include/usr/hwpf/fapi/fapiAttributeService.H
+++ b/src/include/usr/hwpf/fapi/fapiAttributeService.H
@@ -1,25 +1,26 @@
-// IBM_PROLOG_BEGIN_TAG
-// This is an automatically generated prolog.
-//
-// $Source: src/include/usr/hwpf/fapi/fapiAttributeService.H $
-//
-// IBM CONFIDENTIAL
-//
-// COPYRIGHT International Business Machines Corp. 2011
-//
-// p1
-//
-// Object Code Only (OCO) source materials
-// Licensed Internal Code Source Materials
-// IBM HostBoot Licensed Internal Code
-//
-// The source code for this program is not published or other-
-// wise divested of its trade secrets, irrespective of what has
-// been deposited with the U.S. Copyright Office.
-//
-// Origin: 30
-//
-// IBM_PROLOG_END
+/* IBM_PROLOG_BEGIN_TAG
+ * This is an automatically generated prolog.
+ *
+ * $Source: src/include/usr/hwpf/fapi/fapiAttributeService.H $
+ *
+ * IBM CONFIDENTIAL
+ *
+ * COPYRIGHT International Business Machines Corp. 2011-2012
+ *
+ * p1
+ *
+ * Object Code Only (OCO) source materials
+ * Licensed Internal Code Source Materials
+ * IBM HostBoot Licensed Internal Code
+ *
+ * The source code for this program is not published or other-
+ * wise divested of its trade secrets, irrespective of what has
+ * been deposited with the U.S. Copyright Office.
+ *
+ * Origin: 30
+ *
+ * IBM_PROLOG_END_TAG
+ */
/**
* @file fapiAttributeService.H
*
@@ -40,6 +41,7 @@
* camvanng 10/20/2011 Changed i_pTarget to "const"
* ptr
* mjjones 04/10/2012 Support for privileged atts
+ * mjjones 06/07/2012 Add attr override support
*/
#ifndef FAPIATTRIBUTESERVICE_H_
@@ -65,33 +67,58 @@
* l_rc = FAPI_ATTR_GET(<ID>, l_pTarget, l_pVal);
* l_rc = FAPI_ATTR_SET(<ID>, l_pTarget, l_pVal);
*
- * The first part of these macros is a call to fapiCheckIdType that will cause a
- * compile failure if the ID or VAL parameters are incorrect.
+ * A priveleged attribute is one that a HWP should not generally access,
+ * examples include ATTR_NAME and ATTR_EC, where usage can lead to a non
+ * data-driven design. A privileged attribute can be accessed with
+ * FAPI_ATTR_GET_PRIVILEGED and FAPI_ATTR_SET_PRIVILEGED
+ *
+ * The non-PRIVILEGED macros first call a template function (compiler will
+ * optimize out) that will cause a compile failure if the attribute is
+ * privileged, they then call a PRIVILEGED macro to get/set the attribute
*
- * For the non-PRIVILEGED macros, the second part is a call to
- * fapiFailIfPrivileged that will cause a compile failure if the attribute is
- * privileged (in general, HWPs should not access privileged attributes.
- * Examples include ATTR_NAME and ATTR_EC, where usage can lead to a non
- * data-driven design).
+ * The PRIVILEGED macros call a template function (compiler will optimize out)
+ * that will cause a compile failure if the ID is not valid or VAL is not the
+ * correct type.
+ * The GET macro calls the FAPI_PLAT_GET_ATTR_OVERRIDE PLAT macro to find if
+ * there is an attribute override value to return (platforms can set this to
+ * false if they do not support attribute override or if they handle it in
+ * the standard <ID>_GETMACRO path), if this returns false then the
+ * <ID>_GETMACRO PLAT macro is called to get the attribute, platforms must
+ * define a _GETMACRO for each attribute.
*
- * The final 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.
+ * The SET macro calls the <ID>_SETMACRO PLAT macro to set the attribute,
+ * platforms must define a _SETMACRO for each attribute. It then calls the
+ * FAPI_PLAT_CLEAR_NON_CONST_ATTR_OVERRIDE to clear any non-const attribute
+ * overrides (platforms can set this to NULL if they do not support
+ * attribute override or if they handle it in the standard <ID>_SETMACRO
+ * path).
+ *
+ * Note that a const attribute override is one that is always returned on a
+ * FAPI_ATTR_GET even if a subsequent FAPI_ATTR_SET is done. A non-const
+ * attribute override is one that is cleared when a FAPI_ATTR_SET is done
*/
#define FAPI_ATTR_GET(ID, PTARGET, VAL) \
- (fapi::fapiCheckIdType<fapi::ID##_Type>(fapi::ID, VAL), \
- fapi::fapiFailIfPrivileged<fapi::ID##_Privileged>(), \
- ID##_GETMACRO(ID, PTARGET, VAL))
+ (fapi::fapiFailIfPrivileged<fapi::ID##_Privileged>(), \
+ fapi::fapiCheckIdType<fapi::ID##_Type>(fapi::ID, VAL), \
+ FAPI_PLAT_GET_ATTR_OVERRIDE(fapi::ID, PTARGET, VAL) ? \
+ fapi::FAPI_RC_SUCCESS \
+ : ID##_GETMACRO(ID, PTARGET, VAL))
+
#define FAPI_ATTR_SET(ID, PTARGET, VAL) \
- (fapi::fapiCheckIdType<fapi::ID##_Type>(fapi::ID, VAL), \
- fapi::fapiFailIfPrivileged<fapi::ID##_Privileged>(), \
+ (fapi::fapiFailIfPrivileged<fapi::ID##_Privileged>(), \
+ fapi::fapiCheckIdType<fapi::ID##_Type>(fapi::ID, VAL), \
+ FAPI_PLAT_CLEAR_NON_CONST_ATTR_OVERRIDE(fapi::ID, PTARGET), \
ID##_SETMACRO(ID, PTARGET, VAL))
#define FAPI_ATTR_GET_PRIVILEGED(ID, PTARGET, VAL) \
(fapi::fapiCheckIdType<fapi::ID##_Type>(fapi::ID, VAL), \
- ID##_GETMACRO(ID, PTARGET, VAL))
+ FAPI_PLAT_GET_ATTR_OVERRIDE(fapi::ID, PTARGET, VAL) ? \
+ fapi::FAPI_RC_SUCCESS \
+ : ID##_GETMACRO(ID, PTARGET, VAL))
+
#define FAPI_ATTR_SET_PRIVILEGED(ID, PTARGET, VAL) \
(fapi::fapiCheckIdType<fapi::ID##_Type>(fapi::ID, VAL), \
+ FAPI_PLAT_CLEAR_NON_CONST_ATTR_OVERRIDE(fapi::ID, PTARGET), \
ID##_SETMACRO(ID, PTARGET, VAL))
namespace fapi
OpenPOWER on IntegriCloud