diff options
-rw-r--r-- | src/include/usr/hwas/common/hwas_reasoncodes.H | 8 | ||||
-rw-r--r-- | src/include/usr/targeting/attrrp.H | 9 | ||||
-rw-r--r-- | src/include/usr/targeting/attrsync.H | 124 | ||||
-rw-r--r-- | src/include/usr/targeting/common/attrsyncdefs.H | 84 | ||||
-rw-r--r-- | src/include/usr/targeting/common/targreasoncodes.H | 18 | ||||
-rw-r--r-- | src/include/usr/targeting/common/trace.H | 47 | ||||
-rw-r--r-- | src/usr/hwas/hostbootIstep.C | 96 | ||||
-rw-r--r-- | src/usr/targeting/attrrp.C | 61 | ||||
-rw-r--r-- | src/usr/targeting/attrsync.C | 332 | ||||
-rw-r--r-- | src/usr/targeting/common/targetservice.C | 5 | ||||
-rw-r--r-- | src/usr/targeting/test/testattrsync.H | 114 |
11 files changed, 743 insertions, 155 deletions
diff --git a/src/include/usr/hwas/common/hwas_reasoncodes.H b/src/include/usr/hwas/common/hwas_reasoncodes.H index 774708cde..e8f08125f 100644 --- a/src/include/usr/hwas/common/hwas_reasoncodes.H +++ b/src/include/usr/hwas/common/hwas_reasoncodes.H @@ -5,7 +5,7 @@ /* */ /* IBM CONFIDENTIAL */ /* */ -/* COPYRIGHT International Business Machines Corp. 2011,2012 */ +/* COPYRIGHT International Business Machines Corp. 2011,2013 */ /* */ /* p1 */ /* */ @@ -27,8 +27,9 @@ namespace HWAS { enum HwasModuleID { - MOD_DECONFIG_GARD = 0x01, - MOD_PROCESS_CALLOUT = 0x02, + MOD_DECONFIG_GARD = 0x01, + MOD_PROCESS_CALLOUT = 0x02, + MOD_HOST_DISCOVER_TARGETS = 0x03, }; enum HwasReasonCode @@ -40,6 +41,7 @@ namespace HWAS RC_GARD_REPOSITORY_FULL = 0x03, RC_TARGET_NOT_FOUND_FOR_GARD_RECORD = 0x04, RC_INVALID_TARGET = 0x05, + RC_TOP_LEVEL_TARGET_NULL = 0x06, // if more are added, modify each hwasPlatError.C file as appropriate. }; }; diff --git a/src/include/usr/targeting/attrrp.H b/src/include/usr/targeting/attrrp.H index 82046b337..80394cb9b 100644 --- a/src/include/usr/targeting/attrrp.H +++ b/src/include/usr/targeting/attrrp.H @@ -5,7 +5,7 @@ /* */ /* IBM CONFIDENTIAL */ /* */ -/* COPYRIGHT International Business Machines Corp. 2011,2012 */ +/* COPYRIGHT International Business Machines Corp. 2011,2013 */ /* */ /* p1 */ /* */ @@ -147,11 +147,12 @@ class AttrRP * * @param[in] i_pages, vector of sectionRefData struct * - * @return void + * @return true successful in writing Section Data + * @return false failed writing Section Data */ - void writeSectionData( - const std::vector <sectionRefData>& i_pages); + bool writeSectionData( + const std::vector <sectionRefData>& i_pages) const; /** * @brief Populates the output vector with the correct information diff --git a/src/include/usr/targeting/attrsync.H b/src/include/usr/targeting/attrsync.H index 274674382..cba459622 100644 --- a/src/include/usr/targeting/attrsync.H +++ b/src/include/usr/targeting/attrsync.H @@ -1,26 +1,25 @@ -/* IBM_PROLOG_BEGIN_TAG - * This is an automatically generated prolog. - * - * $Source: src/include/usr/targeting/attrsync.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 - */ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/targeting/attrsync.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2012,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 */ #ifndef __ATTRSYNC_H_ #define __ATTRSYNC_H_ /** @@ -83,7 +82,7 @@ namespace TARGETING * attribute section. * * @par Detailed Description: - * This funciton will call into the AttRP:: to have the + * This function will call into the AttRP:: to have the * correct attribute section paged into accessable memory. * this function may be called multiple times with different * section names. @@ -106,6 +105,38 @@ namespace TARGETING errlHndl_t syncSectionToFsp( TARGETING::SECTION_TYPE i_section_to_sync ); + /** + * @brief Sends a request to the FSP to sync its data to Hostboot + * for a specific attribute section. Write the data + * received from the FSP to the attribute section. + * + * @par Detailed Description: + * This function will call into the AttRP:: to have the + * correct attribute section updated. This function may be + * called multiple times with different section names. + * + * @pre None: + * + * @post The entire section from the FSP attribute section + * passed in has been synchronized to the HB memory area. + * + * @param[in] i_section_to_sync + * TARGETING::SECTION_TYPE is passed in to + * identify the section to be synced from the + * FSP. + * i_msgQ + * the message queue which FSP will use to send + * the attribute data + * + * @return errlHndl_t + * return errl == NULL -> success + * return errl != NULL -> failure + * + */ + errlHndl_t syncSectionFromFsp( + TARGETING::SECTION_TYPE i_section_to_sync, + msg_q_t i_pMsgQ ); + private: /** @@ -126,13 +157,27 @@ namespace TARGETING * attribute section. * * @par Detailed Description: - * This funciton will call into the AttRP:: to have the + * This function will call into the AttRP:: to have the * correct attribute section paged into accessable memory * */ void getSectionData(); /** + * @brief Write the attribute data received from the FSP to + * the attribute section. + * + * @par Detailed Description: + * This function will call into the AttRP:: to have the + * correct attribute section written + * + * @return ATTR_SYNC_SUCCESS -> success + * ATTR_SYNC_FAILURE -> failure + * + */ + ATTR_SYNC_RC updateSectionData() const; + + /** * @brief Uses the internal mailbox to send a message to the FSP * * @@ -169,6 +214,17 @@ namespace TARGETING */ errlHndl_t sendSyncCompleteMessage(); + /** + * @brief Sends the sync to HB request message to the FSP + * requesting the FSP to sync it's attribute data + * to Hostboot. + * + * @return errlHndl_t + * return errl == NULL -> success + * return errl != NULL -> failure + */ + errlHndl_t sendSyncToHBRequestMessage(); + private: // id of the section being updated @@ -191,7 +247,7 @@ namespace TARGETING /** * @brief Handles synchronization of all RW targeting attributes from - * hostboot to the fsp; the following section are are + * hostboot to the fsp; the following sections are * synchronized. * * 1). SECTION_TYPE_PNOR_RW @@ -205,5 +261,21 @@ namespace TARGETING */ errlHndl_t syncAllAttributesToFsp(); + /** + * @brief Handles synchronization of all RW targeting attributes from + * the fsp to hostboot; the following sections are + * synchronized. + * + * 1). SECTION_TYPE_PNOR_RW + * 2). SECTION_TYPE_HEAP_PNOR_INIT + * 3). SECTION_TYPE_HEAP_PNOR_ZERO_INIT + * + * + * @return errlHndl_t + * return errl == NULL -> success + * return errl != NULL -> failure + */ + errlHndl_t syncAllAttributesFromFsp(); + } // namespace #endif diff --git a/src/include/usr/targeting/common/attrsyncdefs.H b/src/include/usr/targeting/common/attrsyncdefs.H index 74103a268..f435ca2d6 100644 --- a/src/include/usr/targeting/common/attrsyncdefs.H +++ b/src/include/usr/targeting/common/attrsyncdefs.H @@ -1,26 +1,25 @@ -/* IBM_PROLOG_BEGIN_TAG - * This is an automatically generated prolog. - * - * $Source: src/include/usr/targeting/common/attrsyncdefs.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 - */ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/targeting/common/attrsyncdefs.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2012,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 */ #ifndef __ATTRSYNC_DEFS_H__ #define __ATTRSYNC_DEFS_H__ @@ -47,21 +46,43 @@ const uint64_t RETURN_CODE_MASK = 0xFFFF000000000000; ( data0 = ( data0 & ~SECTIONID_MASK) | \ ( static_cast<uint64_t>(sectionId) << 48 ) ) -// used to add the number of the current page to by sync'd. used in the +// used to get the section from the first data word of an attribute sync +// message - only retrieves the first two bytes of the uint64_t +#define ATTR_SYNC_GET_SECTION_ID( data0 ) ( static_cast<SECTION_TYPE>( \ + ( data0 & SECTIONID_MASK ) >> 48 ) ) + +// used to add the number of the current page to be sync'd. used in the // attribute sync message code. Only modifies the second two bytes // of the uint64_t #define ATTR_SYNC_ADD_PAGE_NUMBER( pageNumber, data0 ) \ ( data0 = ( data0 & ~PAGE_NUMBER_MASK) | \ ( static_cast<uint64_t>(pageNumber) << 32 ) ) +// used to get the number of the current page to be sync'd. used in the +// attribute sync message code. Only retrieves the second two bytes +// of the uint64_t +#define ATTR_SYNC_GET_PAGE_NUMBER( data0 ) ( static_cast<uint16_t>( \ + ( data0 & PAGE_NUMBER_MASK ) >> 32 ) ) + // Used in the commit message sent after all the pages of the current section -// oare sent, the macro will add the total page count to the first two bytes +// are sent, the macro will add the total page count to the first two bytes // of the data[0] uint64_t in the mailbox message. #define ATTR_SYNC_ADD_PAGE_COUNT( pageCount, data0 ) \ ( data0 = ( data0 & ~PAGE_COUNT_MASK) | \ ( static_cast<uint64_t>(pageCount) << 48 ) ) -// grabs the return code from the uint64_t returned by the mailbox message +// Used in the commit message sent after all the pages of the current section +// are sent, the macro will extract the total page count from the first two bytes +// of the data[0] uint64_t in the mailbox message. +#define ATTR_SYNC_GET_PAGE_COUNT( data0 ) ( static_cast<uint16_t> ( \ + ( data0 & PAGE_COUNT_MASK ) >> 48 ) ) + +// sets the return code in the first 2 bytes of the mailbox message +#define ATTR_SYNC_ADD_RC( rc, data0 ) \ + ( data0 = (data0 & ~RETURN_CODE_MASK) | \ + ( static_cast<uint64_t>(rc) << 48 ) ) + +// gets the return code from the uint64_t returned by the mailbox message #define ATTR_SYNC_GET_RC( data0 ) ( static_cast<ATTR_SYNC_RC>( \ ( data0 & RETURN_CODE_MASK ) >> 48 )) @@ -71,13 +92,16 @@ namespace TARGETING * @enum TARGETING::ATTR_SYNC_MSG_TYPE * * @brief Targeting attribute sync service message types for use in the - * attribute sync messges between FSP and Hostboot + * attribute sync messages between FSP and Hostboot */ enum ATTR_SYNC_MSG_TYPE { - ATTR_SYNC_NO_MSG = 0, - ATTR_SYNC_SECTION = 0x000000A1, - ATTR_SYNC_COMPLETE = 0x000000A2, + ATTR_SYNC_NO_MSG = 0, + ATTR_SYNC_SECTION_TO_FSP = 0x000000A1, + ATTR_SYNC_COMPLETE_TO_FSP = 0x000000A2, + ATTR_SYNC_REQUEST_TO_HB = 0x000000A3, + ATTR_SYNC_SECTION_TO_HB = 0x000000A4, + ATTR_SYNC_COMPLETE_TO_HB = 0x000000A5, }; diff --git a/src/include/usr/targeting/common/targreasoncodes.H b/src/include/usr/targeting/common/targreasoncodes.H index 804745fc0..fcd45ae95 100644 --- a/src/include/usr/targeting/common/targreasoncodes.H +++ b/src/include/usr/targeting/common/targreasoncodes.H @@ -5,7 +5,7 @@ /* */ /* IBM CONFIDENTIAL */ /* */ -/* COPYRIGHT International Business Machines Corp. 2011,2012 */ +/* COPYRIGHT International Business Machines Corp. 2011,2013 */ /* */ /* p1 */ /* */ @@ -43,13 +43,15 @@ enum TargetingModuleId enum TargetingReasonCode { - TARG_RC_TEST_TARGET_FFDC = TARG_COMP_ID | 0x01, - TARG_RC_BAD_EYECATCH = TARG_COMP_ID | 0x02, - TARG_RC_MM_BLOCK_FAIL = TARG_COMP_ID | 0x03, - TARG_RC_MM_PERM_FAIL = TARG_COMP_ID | 0x04, - TARG_RC_ATTR_MSG_FAIL = TARG_COMP_ID | 0x05, - TARG_RC_UNHANDLED_ATTR_SEC_TYPE = TARG_COMP_ID | 0x06, - TARG_RC_ATTR_SYNC_FAIL = TARG_COMP_ID | 0x07, + TARG_RC_TEST_TARGET_FFDC = TARG_COMP_ID | 0x01, + TARG_RC_BAD_EYECATCH = TARG_COMP_ID | 0x02, + TARG_RC_MM_BLOCK_FAIL = TARG_COMP_ID | 0x03, + TARG_RC_MM_PERM_FAIL = TARG_COMP_ID | 0x04, + TARG_RC_ATTR_MSG_FAIL = TARG_COMP_ID | 0x05, + TARG_RC_UNHANDLED_ATTR_SEC_TYPE = TARG_COMP_ID | 0x06, + TARG_RC_ATTR_SYNC_TO_FSP_FAIL = TARG_COMP_ID | 0x07, + TARG_RC_ATTR_SYNC_REQUEST_TO_HB_FAIL = TARG_COMP_ID | 0x08, + TARG_RC_ATTR_SYNC_TO_HB_FAIL = TARG_COMP_ID | 0x09, }; }; // End TARGETING namespace diff --git a/src/include/usr/targeting/common/trace.H b/src/include/usr/targeting/common/trace.H index c298eb9ab..82a05586b 100644 --- a/src/include/usr/targeting/common/trace.H +++ b/src/include/usr/targeting/common/trace.H @@ -1,25 +1,25 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: src/usr/targeting/trace.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/targeting/common/trace.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2011,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 */ #ifndef __TARGETING_COMMON_TRACE_H #define __TARGETING_COMMON_TRACE_H @@ -59,6 +59,9 @@ #define TARG_INF(args...) \ TRACFCOMP(TARGETING::g_trac_targeting,TARG_TAG " " INFO_MRK " " args) +#define TARG_DBG(args...) \ + TRACDCOMP(TARGETING::g_trac_targeting,TARG_TAG " " INFO_MRK " " args) + #define TARG_BIN(args...) \ TRACFBIN(TARGETING::g_trac_targeting,TARG_TAG " " args) diff --git a/src/usr/hwas/hostbootIstep.C b/src/usr/hwas/hostbootIstep.C index ba76ac6d4..5738e88e9 100644 --- a/src/usr/hwas/hostbootIstep.C +++ b/src/usr/hwas/hostbootIstep.C @@ -1,26 +1,25 @@ -/* IBM_PROLOG_BEGIN_TAG - * This is an automatically generated prolog. - * - * $Source: src/usr/hwas/hostbootIstep.C $ - * - * 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 - */ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/hwas/hostbootIstep.C $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2012,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 */ /** * @file hostbootIstep.C * @@ -29,6 +28,7 @@ #include <hwas/common/hwas.H> #include <hwas/common/hwasCommon.H> +#include <hwas/common/hwas_reasoncodes.H> #include <hwas/hostbootIstep.H> #include <hwas/common/deconfigGard.H> @@ -37,6 +37,8 @@ #include <initservice/taskargs.H> #include <initservice/isteps_trace.H> +#include <targeting/attrsync.H> + namespace HWAS { @@ -79,7 +81,53 @@ void* host_discover_targets( void *io_pArgs ) TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "host_discover_targets entry" ); - errlHndl_t errl = discoverTargets(); + errlHndl_t errl = NULL; + + // Check whether we're in MPIPL mode + using namespace TARGETING; + Target* l_pTopLevel = NULL; + uint8_t l_attrIsMpipl = 0; + + TargetService& l_targetService = targetService(); + l_targetService.getTopLevelTarget( l_pTopLevel ); + + if( l_pTopLevel == NULL ) + { + TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, + "Top level handle was NULL" ); + + /*@ + * @errortype + * @severity ERRORLOG::ERRL_SEV_UNRECOVERABLE + * @moduleid HWAS::MOD_HOST_DISCOVER_TARGETS + * @reasoncode HWAS::RC_TOP_LEVEL_TARGET_NULL + * @devdesc Call to get top level targeting handle + * returned NULL + */ + errl = hwasError( ERRORLOG::ERRL_SEV_UNRECOVERABLE, + HWAS::MOD_HOST_DISCOVER_TARGETS, + HWAS::RC_TOP_LEVEL_TARGET_NULL ); + } + else + { + l_attrIsMpipl = l_pTopLevel->getAttr<ATTR_IS_MPIPL_HB> (); + + if (l_attrIsMpipl) + { + TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, + "MPIPL mode" ); + + // Sync attributes from Fsp + errl = syncAllAttributesFromFsp(); + } + else + { + TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, + "Normal IPL mode" ); + + errl = discoverTargets(); + } + } TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "host_discover_targets exit" ); diff --git a/src/usr/targeting/attrrp.C b/src/usr/targeting/attrrp.C index 7c7b6ecf0..7c6c9e55f 100644 --- a/src/usr/targeting/attrrp.C +++ b/src/usr/targeting/attrrp.C @@ -5,7 +5,7 @@ /* */ /* IBM CONFIDENTIAL */ /* */ -/* COPYRIGHT International Business Machines Corp. 2011,2012 */ +/* COPYRIGHT International Business Machines Corp. 2011,2013 */ /* */ /* p1 */ /* */ @@ -506,11 +506,62 @@ namespace TARGETING return l_errl; } - void AttrRP::writeSectionData( - const std::vector<TARGETING::sectionRefData>& i_pages) + bool AttrRP::writeSectionData( + const std::vector<TARGETING::sectionRefData>& i_pages) const { - // $TODO RTC Story 46672 - assert(0); + 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 ( size_t i = 0; (i < i_pages.size()) && (true == l_rc); i++ ) + { + // search for the section we need + for ( size_t j = 0; j < iv_sectionCount; j++ ) + { + if ( iv_sections[j].type == i_pages[i].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, + i_pages[i].pageNumber); + + // check that page number is within range + uint64_t l_pageOffset = i_pages[i].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, i_pages[i].dataPtr, PAGESIZE ); + break; + } + } + + if (false == l_rc) + { + break; + } + } + + TARG_INF( EXIT_MRK "AttrRP::writeSectionData" ); + return l_rc; } void AttrRP::readSectionData( diff --git a/src/usr/targeting/attrsync.C b/src/usr/targeting/attrsync.C index 4dd43cc55..ca70f8658 100644 --- a/src/usr/targeting/attrsync.C +++ b/src/usr/targeting/attrsync.C @@ -54,6 +54,27 @@ namespace TARGETING TRACDCOMP(g_trac_targeting, "total pages %d", iv_total_pages ); } + ATTR_SYNC_RC AttributeSync::updateSectionData() const + { + TARG_INF( ENTER_MRK "AttributeSync::updateSectionData - " + "section type %u total pages %d", + iv_section_to_sync, iv_total_pages ); + + ATTR_SYNC_RC l_rc = ATTR_SYNC_SUCCESS; + + // call the targeting function here to get context. + TargetService& l_targetService = targetService(); + + // write the section data info into the iv_pages structure + if ( false == l_targetService.writeSectionData( iv_pages ) ) + { + l_rc = ATTR_SYNC_FAILURE; + } + + TARG_INF( EXIT_MRK "AttributeSync::updateSectionData"); + return l_rc; + } + errlHndl_t AttributeSync::syncSectionToFsp( TARGETING::SECTION_TYPE i_section_to_sync ) { @@ -73,7 +94,7 @@ namespace TARGETING { msg = msg_allocate(); - msg->type = ATTR_SYNC_SECTION; + msg->type = ATTR_SYNC_SECTION_TO_FSP; msg->data[0] = 0; @@ -108,7 +129,6 @@ namespace TARGETING } - // if there was no error and there was data to send if(( l_errl == NULL ) && ( iv_total_pages != 0 )) { // tell fsp to commit the last section of data we sent @@ -127,6 +147,186 @@ namespace TARGETING } + errlHndl_t AttributeSync::syncSectionFromFsp( + TARGETING::SECTION_TYPE i_section_to_sync, + msg_q_t i_pMsgQ ) + { + TARG_INF( ENTER_MRK "AttributeSync::syncSectionFromFsp" ); + + errlHndl_t l_errl = NULL; + bool l_sync_complete = false; + ATTR_SYNC_RC l_rc = ATTR_SYNC_FAILURE; + TARGETING::sectionRefData l_page; + + iv_section_to_sync = i_section_to_sync; + memset( &l_page, 0, sizeof(TARGETING::sectionRefData) ); + + do{ + + // send a request to FSP to sync to Hostboot + l_errl = sendSyncToHBRequestMessage(); + if (l_errl) + { + break; + } + + do{ + + // wait for FSP to send the section's attribute data + TARG_DBG( "Wait for message from FSP"); + msg_t * l_pMsg = msg_wait(i_pMsgQ); + + // process message just received + if ( ATTR_SYNC_SECTION_TO_HB == l_pMsg->type ) + { + TARG_DBG( "HB Attribute Sync Section message type received " + "from the FSP"); + + // get the section id + l_page.sectionId = ATTR_SYNC_GET_SECTION_ID(l_pMsg->data[0]); + + // get the page number + l_page.pageNumber = ATTR_SYNC_GET_PAGE_NUMBER(l_pMsg->data[0]); + + // save a pointer to the page + l_page.dataPtr = + reinterpret_cast<uint8_t *> (l_pMsg->extra_data); + + // Validate the data received. Ignore page if + // section id or page size is incorrect or if + // there are no page received since we cannot send + // an error back to the FSP at this point. We will + // check later whether the correct number of valid + // pages for the section was received when FSP send + // us the sync complete message. + + // if no page received + if ( NULL == l_page.dataPtr) + { + TARG_ERR("WARNING: " + "no attribute page received from FSP"); + } + // if it's not the requested section + else if ( iv_section_to_sync != l_page.sectionId ) + { + TARG_ERR("WARNING: " + "section type received from FSP = %u, expecting %u", + l_page.sectionId, iv_section_to_sync); + + //Free the memory + free(l_pMsg->extra_data); + l_pMsg->extra_data = NULL; + } + // page size should always be 4K + else if ( PAGESIZE != l_pMsg->data[1] ) + { + TARG_ERR("WARNING: " + "page size received from FSP = %u, expecting 4K", + l_pMsg->data[1]); + + free(l_pMsg->extra_data); + l_pMsg->extra_data = NULL; + } + else + { + iv_pages.push_back(l_page); + } + } + else if ( ATTR_SYNC_COMPLETE_TO_HB == l_pMsg->type ) + { + TARG_DBG( "HB Attribute Sync Complete message type " + "received from the FSP"); + + l_sync_complete = true; + + iv_total_pages = ATTR_SYNC_GET_PAGE_COUNT( l_pMsg->data[0] ); + + // check that the total # of valid pages received is correct + if ( iv_pages.size() == iv_total_pages ) + { + // write the section to the Attribute virtual address + // space + l_rc = updateSectionData(); + + if (l_rc) + { + TARG_ERR( + "HB failed in writing the attribute section" ); + } + } + else + { + TARG_ERR( "total # of valid pages received = %u, " + "expecting %u", iv_pages.size(), iv_total_pages); + + l_rc = ATTR_SYNC_FAILURE; + } + + if (l_rc) + { + /*@ + * @errortype + * @moduleid TARG_MOD_ATTR_SYNC + * @reasoncode TARG_RC_ATTR_SYNC_TO_HB_FAIL + * @userdata1 return code + * @userdata2 section to sync + * @devdesc The Attribute synchronization from FSP + * failed. + */ + l_errl = new ErrlEntry(ERRL_SEV_UNRECOVERABLE, + TARG_MOD_ATTR_SYNC, + TARG_RC_ATTR_SYNC_TO_HB_FAIL, + l_rc, + iv_section_to_sync); + } + + // send a msg back to FSP indicating success/failure + l_pMsg->data[0] = 0; + ATTR_SYNC_ADD_RC( l_rc, l_pMsg->data[0] ); + int l_respond_rc = msg_respond(i_pMsgQ, l_pMsg); + if (l_respond_rc) + { + // Just output a trace here since FSP should + // handle error case where it doesn't receive + // a response from HB. + TARG_ERR( "WARNING: Bad rc from msg_respond: %d", + l_respond_rc); + msg_free( l_pMsg ); + l_pMsg = NULL; + } + } + else + { + TARG_ERR( "WARNING: Invalid message type [0x%x] received " + "from the FSP, ignoring...", l_pMsg->type); + } + + // Free memory allocated for message + if ( msg_is_async(l_pMsg) ) + { + msg_free( l_pMsg ); + l_pMsg = NULL; + } + + }while (false == l_sync_complete); + + // free memory + if ( iv_pages.size() ) + { + for ( size_t i = 0; i < iv_pages.size(); i++ ) + { + free( iv_pages[i].dataPtr ); + } + + iv_pages.clear(); + } + + }while (0); + + TARG_INF( EXIT_MRK "AttributeSync::syncSectionFromFsp" ); + return l_errl; + } + // send the sync complete message errlHndl_t AttributeSync::sendSyncCompleteMessage( ) { @@ -136,10 +336,10 @@ namespace TARGETING msg_t * msg = msg_allocate(); - // initilaize msg buffer + // initialize msg buffer memset( msg, 0, sizeof(msg_t) ); - msg->type = ATTR_SYNC_COMPLETE; + msg->type = ATTR_SYNC_COMPLETE_TO_FSP; ATTR_SYNC_ADD_PAGE_COUNT( iv_total_pages, msg->data[0] ); @@ -157,7 +357,7 @@ namespace TARGETING /*@ * @errortype * @moduleid TARG_MOD_ATTR_SYNC - * @reasoncode TARG_RC_ATTR_SYNC_FAIL + * @reasoncode TARG_RC_ATTR_SYNC_TO_FSP_FAIL * @userdata1 return code from FSP attribute sync * @userdata2 section ID of for section being sync'd * @@ -167,7 +367,7 @@ namespace TARGETING */ l_err = new ErrlEntry(ERRL_SEV_UNRECOVERABLE, TARG_MOD_ATTR_SYNC, - TARG_RC_ATTR_SYNC_FAIL, + TARG_RC_ATTR_SYNC_TO_FSP_FAIL, return_code, (uint64_t)iv_section_to_sync); } @@ -179,6 +379,66 @@ namespace TARGETING return l_err; } + // send a request to FSP to sync to Hostboot + errlHndl_t AttributeSync::sendSyncToHBRequestMessage() + { + TARG_INF( ENTER_MRK "AttributeSync::sendSyncToHBRequestMessage" ); + + errlHndl_t l_err = NULL; + + // allocate message buffer + // buffer will be initialized to zero by msg_allocate() + msg_t * l_pMsg = msg_allocate(); + + l_pMsg->type = ATTR_SYNC_REQUEST_TO_HB; + + ATTR_SYNC_ADD_SECTION_ID( iv_section_to_sync, l_pMsg->data[0] ); + + l_err = sendMboxMessage( SYNCHRONOUS, l_pMsg ); + + if( l_err == NULL ) + { + // see if there was an error on the other end + ATTR_SYNC_RC return_code = ATTR_SYNC_GET_RC( l_pMsg->data[0] ); + + if ( return_code ) + { + TARG_ERR( + "rc 0x%x received from FSP for Sync to HB request", + return_code ); + + /*@ + * @errortype + * @moduleid TARG_MOD_ATTR_SYNC + * @reasoncode TARG_RC_ATTR_SYNC_REQUEST_TO_HB_FAIL + * @userdata1 return code from FSP + * @userdata2 section to sync + * @devdesc The Attribute synchronization code on the + * FSP side was unable to fulfill the sync to + * HB request. + */ + l_err = new ErrlEntry(ERRL_SEV_UNRECOVERABLE, + TARG_MOD_ATTR_SYNC, + TARG_RC_ATTR_SYNC_REQUEST_TO_HB_FAIL, + return_code, + iv_section_to_sync); + } + } + else + { + TARG_ERR( + "Failed to send request to FSP to sync section type %u " + "to Hostboot.", iv_section_to_sync ); + } + + // for a syncronous message we need to free the message + msg_free( l_pMsg ); + l_pMsg = NULL; + + TARG_INF( EXIT_MRK "AttributeSync::sendSyncToHBRequestMessage" ); + return l_err; + } + errlHndl_t AttributeSync::sendMboxMessage( MBOX_MSG_TYPE type, msg_t * i_msg ) { @@ -254,7 +514,7 @@ namespace TARGETING if( l_errl ) { TRACFCOMP(g_trac_targeting, - "Error returned when syncing section type %d", + "Error returned when syncing section type %d to FSP", section_type[i]); break; } @@ -265,6 +525,64 @@ namespace TARGETING return l_errl; } + errlHndl_t syncAllAttributesFromFsp() + { + TARG_INF( ENTER_MRK "syncAllAttributesFromFsp" ); + + errlHndl_t l_errl = NULL; + + do{ + // if the mailbox is not enabled then skip attribute sync + if( !(MBOX::mailbox_enabled()) ) + { + TARG_INF( "Mailbox is not enabled, skipping attribute sync" ); + break; + } + + // create Hostboot message queue + msg_q_t l_pHbMsgQ = msg_q_create(); + + // register Hostboot message queue with mailbox to receive messages + l_errl = MBOX::msgq_register(MBOX::HB_ATTR_SYNC_MSGQ, l_pHbMsgQ); + if (l_errl) + { + TARG_ERR( "Error registering the Hostboot message queue with " + "mailbox service." ); + break; + } + + // these are the sections we want to sync + SECTION_TYPE section_type[] ={SECTION_TYPE_PNOR_RW, + SECTION_TYPE_HEAP_PNOR_INIT, + SECTION_TYPE_HEAP_ZERO_INIT}; + + size_t section_count = sizeof(section_type)/sizeof(section_type[0]); + + TARG_DBG( "section count = %d", section_count ); + + // pull all attributes from FSP + AttributeSync l_Sync; + + for(uint8_t i = 0; i < section_count; i++) + { + TARG_INF( "syncing section type = %d", section_type[i] ); + l_errl = l_Sync.syncSectionFromFsp( section_type[i], l_pHbMsgQ ); + + if (l_errl) + { + break; + } + } + + // unregister the Hosboot message queue from the mailbox service. + MBOX::msgq_unregister(MBOX::HB_ATTR_SYNC_MSGQ); + + } while (0); + + TARG_INF( EXIT_MRK "syncAllAttributesFromFsp" ); + return l_errl; + } + }; // end namespace diff --git a/src/usr/targeting/common/targetservice.C b/src/usr/targeting/common/targetservice.C index e061b4174..390396ba6 100644 --- a/src/usr/targeting/common/targetservice.C +++ b/src/usr/targeting/common/targetservice.C @@ -5,7 +5,7 @@ /* */ /* IBM CONFIDENTIAL */ /* */ -/* COPYRIGHT International Business Machines Corp. 2011,2012 */ +/* COPYRIGHT International Business Machines Corp. 2011,2013 */ /* */ /* p1 */ /* */ @@ -562,8 +562,7 @@ bool TargetService::writeSectionData( bool l_response = false; if(i_pages.size() != 0) { - TARG_GET_SINGLETON(TARGETING::theAttrRP).writeSectionData(i_pages); - l_response = true; + l_response = TARG_GET_SINGLETON(TARGETING::theAttrRP).writeSectionData(i_pages); } TARG_EXIT(); diff --git a/src/usr/targeting/test/testattrsync.H b/src/usr/targeting/test/testattrsync.H index 69e90004b..dc82566e9 100644 --- a/src/usr/targeting/test/testattrsync.H +++ b/src/usr/targeting/test/testattrsync.H @@ -1,26 +1,25 @@ -/* IBM_PROLOG_BEGIN_TAG - * This is an automatically generated prolog. - * - * $Source: src/usr/targeting/test/testattrsync.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 - */ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/targeting/test/testattrsync.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2012,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 */ #ifndef __TARGETING_TESTATTRSYNC_H #define __TARGETING_TESTATTRSYNC_H @@ -81,6 +80,7 @@ class AttrSyncTestSuite : public CxxTest::TestSuite { TS_FAIL(" Error returned when syncing SECTION_TYPE_PNOR_RW"); } + delete err; err = NULL; } @@ -95,6 +95,7 @@ class AttrSyncTestSuite : public CxxTest::TestSuite { TS_FAIL(" Error returned when syncing SECTION_TYPE_HEAP_PNOR_INIT"); } + delete err; err = NULL; } @@ -109,11 +110,78 @@ class AttrSyncTestSuite : public CxxTest::TestSuite { TS_FAIL(" Error returned when syncing SECTION_TYPE_HEAP_ZERO_INIT"); } + delete err; err = NULL; } } + /** + * @brief Test sync of targeting attributes from FSP + */ + void testAttributeSyncFromFsp() + { + TS_TRACE(ENTER_MRK "testAttributeSyncFromFsp" ); + + using namespace TARGETING; + + AttributeSync l_attrSync; + + errlHndl_t l_errl = NULL; + + do + { + + // create Hostboot message queue + msg_q_t l_hbMsgQ = msg_q_create(); + + // register Hostboot message queue with mailbox to receive messages + l_errl = MBOX::msgq_register(MBOX::HB_ATTR_SYNC_MSGQ, l_hbMsgQ); + if (l_errl) + { + TS_FAIL( "Error registering the Hostboot message queue with " + "mailbox service."); + delete l_errl; + l_errl = NULL; + break; + } + + // these are the sections we want to sync + SECTION_TYPE section_type[] ={SECTION_TYPE_PNOR_RW, + SECTION_TYPE_HEAP_PNOR_INIT, + SECTION_TYPE_HEAP_ZERO_INIT}; + + size_t section_count = sizeof(section_type)/sizeof(section_type[0]); + + // pull all attributes from FSP + AttributeSync l_Sync; + + for(uint8_t i = 0; i < section_count; i++) + { + TS_TRACE( "Syncing section type %d", section_type[i] ); + + l_errl = l_Sync.syncSectionFromFsp( section_type[i], l_hbMsgQ ); + + if (l_errl) + { + if( MBOX::mailbox_enabled() ) + { + TS_FAIL( "Error returned when syncing section type %d " + "from FSP", section_type[i]); + } + + delete l_errl; + l_errl = NULL; + } + } + + // unregister the Hosboot message queue from the mailbox service. + MBOX::msgq_unregister(MBOX::HB_ATTR_SYNC_MSGQ); + + } while (0); + + TS_TRACE(EXIT_MRK "testAttributeSyncFromFsp" ); + } }; #endif // End __TARGETING_TESTTARGETING_H |