summaryrefslogtreecommitdiffstats
path: root/src/usr/targeting/attrrp_common.C
diff options
context:
space:
mode:
authorPatrick Williams <iawillia@us.ibm.com>2013-09-17 16:05:23 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2013-10-17 11:18:29 -0500
commit63245d62a4ffe99ad2eaf6b4f1a88862065ceedf (patch)
tree96d359d201573efda392b6ed89287c458cd34acc /src/usr/targeting/attrrp_common.C
parentd3c269a1dcc30483654ae1f3ec37e842880c7db4 (diff)
downloadtalos-hostboot-63245d62a4ffe99ad2eaf6b4f1a88862065ceedf.tar.gz
talos-hostboot-63245d62a4ffe99ad2eaf6b4f1a88862065ceedf.zip
Port Targeting to Hostboot Runtime.
Change-Id: I29ce91dce52d1c6ff6df131ae0b94bf3c4ab99f2 RTC: 79408 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/6262 Tested-by: Jenkins Server Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/targeting/attrrp_common.C')
-rw-r--r--src/usr/targeting/attrrp_common.C177
1 files changed, 177 insertions, 0 deletions
diff --git a/src/usr/targeting/attrrp_common.C b/src/usr/targeting/attrrp_common.C
new file mode 100644
index 000000000..84f864b10
--- /dev/null
+++ b/src/usr/targeting/attrrp_common.C
@@ -0,0 +1,177 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/targeting/attrrp_common.C $ */
+/* */
+/* IBM CONFIDENTIAL */
+/* */
+/* COPYRIGHT International Business Machines Corp. 2013 */
+/* */
+/* 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 otherwise */
+/* divested of its trade secrets, irrespective of what has been */
+/* deposited with the U.S. Copyright Office. */
+/* */
+/* Origin: 30 */
+/* */
+/* IBM_PROLOG_END_TAG */
+#include <targeting/attrrp.H>
+#include <targeting/common/trace.H>
+#include <util/align.H>
+
+namespace TARGETING
+{
+ /** @struct AttrRP_Section
+ * @brief Contains parsed information about each attribute section.
+ */
+ struct AttrRP_Section
+ {
+ // Section type
+ SECTION_TYPE type;
+
+ // Desired address in Attribute virtual address space
+ uint64_t vmmAddress;
+
+ // Location in PNOR virtual address space
+ uint64_t pnorAddress;
+
+ // Section size
+ uint64_t size;
+ };
+
+ AttrRP::~AttrRP()
+ {
+ if (iv_sections)
+ {
+ delete[] iv_sections;
+ }
+#ifndef __HOSTBOOT_RUNTIME
+ msg_q_destroy(iv_msgQ);
+#endif
+
+ TARG_ASSERT(false);
+ }
+
+ bool AttrRP::writeSectionData(
+ const std::vector<TARGETING::sectionRefData>& i_pages) const
+ {
+ TARG_INF(ENTER_MRK "AttrRP::writeSectionData");
+
+ uint8_t * l_dataPtr = NULL; // ptr to Attribute virtual address space
+ bool l_rc = true; // true if write to section is successful
+
+ // for each page
+ for (std::vector<TARGETING::sectionRefData>::const_iterator
+ pageIter = i_pages.begin();
+ (pageIter != i_pages.end()) && (true == l_rc);
+ ++pageIter)
+ {
+ // search for the section we need
+ for ( size_t j = 0; j < iv_sectionCount; ++j )
+ {
+ if ( iv_sections[j].type == (*pageIter).sectionId )
+ {
+ // found it..
+ TARG_DBG( "Writing Attribute Section: ID: %u, "
+ "address: 0x%lx size: 0x%lx page: %u",
+ iv_sections[j].type,
+ iv_sections[j].vmmAddress,
+ iv_sections[j].size,
+ (*pageIter).pageNumber);
+
+ // check that page number is within range
+ uint64_t l_pageOffset = (*pageIter).pageNumber * PAGESIZE;
+ if ( iv_sections[j].size < (l_pageOffset + PAGESIZE) )
+ {
+ TARG_ERR("page offset 0x%lx is greater than "
+ "size 0x%lx of section %u",
+ l_pageOffset,
+ iv_sections[j].size,
+ iv_sections[j].type);
+
+ l_rc = false;
+ break;
+ }
+
+ // adjust the pointer out by page size * page number
+ l_dataPtr =
+ reinterpret_cast<uint8_t *>
+ (iv_sections[j].vmmAddress) + l_pageOffset;
+
+ memcpy( l_dataPtr, (*pageIter).dataPtr, PAGESIZE );
+ break;
+ }
+ }
+
+ if (false == l_rc)
+ {
+ break;
+ }
+ }
+
+ TARG_INF( EXIT_MRK "AttrRP::writeSectionData" );
+ return l_rc;
+ }
+
+ void AttrRP::readSectionData(
+ std::vector<TARGETING::sectionRefData>& o_pages,
+ const TARGETING::SECTION_TYPE i_sectionId,
+ const NODE_ID i_nodeId) const
+ {
+ sectionRefData sectionData;
+ uint16_t count = 0;
+ uint16_t pages = 0;
+
+ // search for the section we need
+ for (size_t i = 0; i < iv_sectionCount; ++i )
+ {
+ if ( iv_sections[i].type == i_sectionId )
+ {
+ // found it..
+ // now figure out how many pages - rounding up to the
+ // the next full page and dividing by the page size
+ pages = ALIGN_PAGE( iv_sections[i].size )/PAGESIZE;
+
+ TRACFCOMP(g_trac_targeting,
+ "Reading Attribute Section: ID: %d, \
+ address: 0x%lx size: 0x%lx pages: %d",
+ iv_sections[i].type,
+ iv_sections[i].vmmAddress,
+ iv_sections[i].size,
+ pages);
+
+ // populate and push the structure for each page
+ while( count != pages )
+ {
+ // duplicate the same section id in each structure
+ sectionData.sectionId = i_sectionId;
+
+ // update the current page number
+ sectionData.pageNumber = count;
+
+ // addjust the pointer out by page size * count each
+ // iteration
+ sectionData.dataPtr =
+ reinterpret_cast<uint8_t *>
+ (iv_sections[i].vmmAddress) + (count * PAGESIZE );
+
+ count++;
+
+ // pushing the actual structure to the vector
+ o_pages.push_back( sectionData );
+
+ }
+
+ break;
+ }
+ }
+ // $TODO what if we dont find it??
+ }
+
+
+}
OpenPOWER on IntegriCloud