diff options
author | Nick Bofferding <bofferdn@us.ibm.com> | 2011-06-08 08:11:59 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2011-06-17 16:02:44 -0500 |
commit | 36d3996114b47cac0f12f16bf5a5c51a2f5f2ecf (patch) | |
tree | 8a8175b9d1bb5f6ef76a1d32eb2226fc6067eb98 /src/usr/targeting/target.C | |
parent | cdaabfdbec148d9ce85f422507c596a8ae6ced08 (diff) | |
download | talos-hostboot-36d3996114b47cac0f12f16bf5a5c51a2f5f2ecf.tar.gz talos-hostboot-36d3996114b47cac0f12f16bf5a5c51a2f5f2ecf.zip |
Added support for base targeting infrastructure
Change-Id: Ie32d18b421b63f067eaf49a3592368f4adc444aa
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/139
Tested-by: Jenkins Server
Reviewed-by: MIKE J. JONES <mjjones@us.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/targeting/target.C')
-rw-r--r-- | src/usr/targeting/target.C | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/src/usr/targeting/target.C b/src/usr/targeting/target.C new file mode 100644 index 000000000..590fc66bc --- /dev/null +++ b/src/usr/targeting/target.C @@ -0,0 +1,123 @@ + +/** + * @file target.C + * + * @brief Implementation of the Target class + */ + +//****************************************************************************** +// Includes +//****************************************************************************** + +// STD +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +// This component +#include <targeting/target.H> +#include "trace.H" + +namespace TARGETING +{ + +#define TARG_NAMESPACE "TARGETING::" +#define TARG_CLASS "Target::" + +//****************************************************************************** +// Target::~Target +//****************************************************************************** + +Target::~Target() +{ + #define TARG_FN "~Target()" + + #undef TARG_FN +} + +//****************************************************************************** +// Target::_tryGetAttr +//****************************************************************************** + +bool Target::_tryGetAttr( + const ATTRIBUTE_ID i_attr, + const uint32_t i_size, + void* const io_pAttrData) const +{ + #define TARG_FN "_tryGetAttr()" + + void* l_pAttrData = NULL; + (void) _getAttrPtr(i_attr, l_pAttrData); + if (l_pAttrData) + { + memcpy(io_pAttrData, l_pAttrData, i_size); + } + return (l_pAttrData != NULL); + + #undef TARG_FN +} + +//****************************************************************************** +// Target::_trySetAttr +//****************************************************************************** + +bool Target::_trySetAttr( + const ATTRIBUTE_ID i_attr, + const uint32_t i_size, + const void* const i_pAttrData) const +{ + #define TARG_FN "_trySetAttr()" + + void* l_pAttrData = NULL; + (void) _getAttrPtr(i_attr, l_pAttrData); + if (l_pAttrData) + { + memcpy(l_pAttrData, i_pAttrData, i_size); + } + return (l_pAttrData != NULL); + + #undef TARG_FN +} + +//****************************************************************************** +// Target::_getAttrPtr +//****************************************************************************** + +void Target::_getAttrPtr( + const ATTRIBUTE_ID i_attr, + void*& o_pAttr) const +{ + #define TARG_FN "_getAttrPtr()" + + void* l_pAttr = NULL; + for (uint32_t i = 0; i < iv_attrs; ++i) + { + if ((*iv_pAttrNames)[i] == i_attr) + { + l_pAttr = (*iv_pAttrValues)[i]; + } + } + o_pAttr = l_pAttr; + + #undef TARG_FN +} + +//****************************************************************************** +// Target::Target +//****************************************************************************** + +Target::Target() +{ + #define TARG_FN "Target()" + + // Note there is no intialization of a target, since it's mapped to memory + // directly. + + #undef TARG_FN +} + +#undef TARG_CLASS + +#undef TARG_NAMESPACE + +} // End namespace TARGETING |