diff options
author | Richard J. Knight <rjknight@us.ibm.com> | 2012-08-06 14:09:37 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2012-08-13 13:16:54 -0500 |
commit | 5023b07888935148844de78239f07d6fa371d9e8 (patch) | |
tree | b5295ced4bdf6ada2a778c196ec3c7bf75910df8 /src/usr | |
parent | 11c8a7dc6e0ec3c31f081d1e30a04a6e7038f918 (diff) | |
download | talos-hostboot-5023b07888935148844de78239f07d6fa371d9e8.tar.gz talos-hostboot-5023b07888935148844de78239f07d6fa371d9e8.zip |
Implement attribute sync from hostboot to fsp
RTC: 41245
Change-Id: Icb7eac8cdcc6a9bc4d19bd2e307f352b835f2df9
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/1485
Reviewed-by: MIKE J. JONES <mjjones@us.ibm.com>
Tested-by: Jenkins Server
Reviewed-by: Richard J. Knight <rjknight@us.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr')
-rw-r--r-- | src/usr/hwpf/hwp/core_activate/core_activate.C | 27 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/core_activate/core_activate.H | 47 | ||||
-rw-r--r-- | src/usr/mbox/mailboxsp.C | 19 | ||||
-rw-r--r-- | src/usr/targeting/attrrp.C | 62 | ||||
-rw-r--r-- | src/usr/targeting/attrsync.C | 270 | ||||
-rw-r--r-- | src/usr/targeting/common/targetservice.C | 41 | ||||
-rw-r--r-- | src/usr/targeting/makefile | 3 | ||||
-rw-r--r-- | src/usr/targeting/test/makefile | 9 | ||||
-rw-r--r-- | src/usr/targeting/test/testattrsync.H | 119 |
9 files changed, 557 insertions, 40 deletions
diff --git a/src/usr/hwpf/hwp/core_activate/core_activate.C b/src/usr/hwpf/hwp/core_activate/core_activate.C index 7e50c93e3..0cecf46d3 100644 --- a/src/usr/hwpf/hwp/core_activate/core_activate.C +++ b/src/usr/hwpf/hwp/core_activate/core_activate.C @@ -49,6 +49,7 @@ #include <targeting/common/commontargeting.H> #include <targeting/common/utilFilter.H> #include <targeting/namedtarget.H> +#include <targeting/attrsync.H> // fapi support #include <fapi.H> @@ -107,9 +108,10 @@ using namespace ISTEP; // cast OUR type of target to a FAPI type of target. const fapi::Target l_fapi_cpu_target( - TARGET_TYPE_PROC_CHIP, - reinterpret_cast<void *> - (const_cast<TARGETING::Target*>(l_cpu_target)) ); + TARGET_TYPE_PROC_CHIP, + reinterpret_cast<void *> + (const_cast<TARGETING::Target*>(l_cpu_target)) + ); #if 1 @@ -343,18 +345,25 @@ void call_host_ipl_complete( void *io_pArgs ) // @@@@@ END CUSTOM BLOCK: @@@@@ #endif - // Send Sync Point to Fsp - TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, - INFO_MRK"Send SYNC_POINT_REACHED msg to Fsp" ); - l_errl = INITSERVICE::sendSyncPoint(); + // Sync attributes to Fsp + l_errl = syncAllAttributesToFsp(); + if( l_errl ) { break; } + + // Send Sync Point to Fsp + TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, + INFO_MRK"Send SYNC_POINT_REACHED msg to Fsp" ); + l_errl = INITSERVICE::sendSyncPoint(); + + } while( 0 ); - TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace, - "call_host_ipl_complete exit" ); + TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, + "call_host_ipl_complete exit elog ptr = %p", l_errl ); + // end task, returning any errorlogs to IStepDisp task_end2( l_errl ); diff --git a/src/usr/hwpf/hwp/core_activate/core_activate.H b/src/usr/hwpf/hwp/core_activate/core_activate.H index 412b9f0cb..e886e3e3f 100644 --- a/src/usr/hwpf/hwp/core_activate/core_activate.H +++ b/src/usr/hwpf/hwp/core_activate/core_activate.H @@ -1,26 +1,26 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: src/usr/hwpf/hwp/core_activate/core_activate.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 - +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/hwpf/hwp/core_activate/core_activate.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 + */ #ifndef __CORE_ACTIVATE_CORE_ACTIVATE_H #define __CORE_ACTIVATE_CORE_ACTIVATE_H @@ -115,7 +115,6 @@ void call_host_activate_slave_cores( void *io_pArgs ); */ void call_host_ipl_complete( void *io_pArgs ); - }; // end namespace #endif diff --git a/src/usr/mbox/mailboxsp.C b/src/usr/mbox/mailboxsp.C index 5312e6c16..414c68173 100644 --- a/src/usr/mbox/mailboxsp.C +++ b/src/usr/mbox/mailboxsp.C @@ -1441,5 +1441,24 @@ msg_q_t MBOX::msgq_unregister(queue_id_t i_queue_id) return msgQ; } +bool MBOX::mailbox_enabled() +{ + bool enabled = false; + + TARGETING::Target * sys = NULL; + + TARGETING::targetService().getTopLevelTarget( sys ); + + TARGETING::SpFunctions spfuncs; + + if( sys && + sys->tryGetAttr<TARGETING::ATTR_SP_FUNCTIONS>(spfuncs) && + spfuncs.mailboxEnabled) + { + enabled = true; + } + + return enabled; +} diff --git a/src/usr/targeting/attrrp.C b/src/usr/targeting/attrrp.C index 4e54d4f8a..1c5bbab7b 100644 --- a/src/usr/targeting/attrrp.C +++ b/src/usr/targeting/attrrp.C @@ -43,6 +43,7 @@ #include <targeting/attrrp.H> #include <targeting/common/trace.H> #include <initservice/initserviceif.H> +#include <util/align.H> using namespace INITSERVICE; using namespace ERRORLOG; @@ -495,4 +496,65 @@ namespace TARGETING return l_errl; } + void AttrRP::writeSectionData( + const std::vector<TARGETING::sectionRefData>& i_pages) + { + // $TODO RTC Story 46672 + assert(0); + } + + void AttrRP::readSectionData( + std::vector<TARGETING::sectionRefData>& o_pages, + const TARGETING::SECTION_TYPE i_sectionId) + { + sectionRefData sectionData = {0}; + 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?? + } + }; diff --git a/src/usr/targeting/attrsync.C b/src/usr/targeting/attrsync.C new file mode 100644 index 000000000..ca5da0140 --- /dev/null +++ b/src/usr/targeting/attrsync.C @@ -0,0 +1,270 @@ +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/targeting/attrsync.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 + */ +#include <targeting/attrsync.H> +#include <targeting/common/targreasoncodes.H> +#include <targeting/common/trace.H> + +using namespace ERRORLOG; + +namespace TARGETING +{ + + AttributeSync::AttributeSync() + :iv_section_to_sync(SECTION_TYPE_PNOR_RW),iv_total_pages(0),iv_current_page(0) + {}; + + AttributeSync::~AttributeSync() + {}; + + void AttributeSync::getSectionData() + { + // make sure we have a clean slate + iv_total_pages = 0; + iv_current_page = 0; + iv_pages.clear(); + + // call the targeting function here to get context. + TargetService& l_targetService = targetService(); + + // read the section data info into the iv_pages structure + l_targetService.readSectionData( iv_pages, iv_section_to_sync ); + + iv_total_pages = iv_pages.size(); + + TRACDCOMP(g_trac_targeting, "total pages %d", iv_total_pages ); + } + + errlHndl_t AttributeSync::syncSectionToFsp( + TARGETING::SECTION_TYPE i_section_to_sync ) + { + errlHndl_t l_errl = NULL; + msg_t * msg = NULL; + + iv_section_to_sync = i_section_to_sync; + + + do{ + + // set up the pointers to the data area + getSectionData(); + + for( iv_current_page = 0; + iv_current_page < iv_total_pages; iv_current_page++ ) + { + msg = msg_allocate(); + + msg->type = ATTR_SYNC_SECTION; + + msg->data[0] = 0; + + ATTR_SYNC_ADD_SECTION_ID( iv_section_to_sync, msg->data[0] ); + + ATTR_SYNC_ADD_PAGE_NUMBER( iv_current_page, msg->data[0] ); + + // set the 2nd data word to the buffer size + msg->data[1] = PAGESIZE; + + // allocated storage will always be 4k + msg->extra_data = malloc( PAGESIZE ); + + // copy the attributes from mem to our buffer. + memcpy( msg->extra_data, + iv_pages[iv_current_page].dataPtr, PAGESIZE ); + + TRACFCOMP(g_trac_targeting, + "syncSectionToFsp() - copy %d bytes from %p to %p", + PAGESIZE, iv_pages[iv_current_page].dataPtr, + msg->extra_data); + + // mailbox code will free both the msg and the extra data + // we allocated above for an async message. + l_errl = sendMboxMessage( ASYNCHRONOUS, msg ); + + if( l_errl ) + { + TRACFCOMP(g_trac_targeting, "failed sending sync message"); + break; + } + + } + + if( l_errl == NULL ) + { + // tell fsp to commit the last section of data we sent + l_errl = sendSyncCompleteMessage(); + + if( l_errl ) + { + TRACFCOMP(g_trac_targeting, + "failed sending sync complete message"); + } + } + + }while(0); + + return l_errl; + + } + + // send the sync complete message + errlHndl_t AttributeSync::sendSyncCompleteMessage( ) + { + TRACFCOMP(g_trac_targeting, "sending sync complete message"); + + errlHndl_t l_err = NULL; + + msg_t * msg = msg_allocate(); + + // initilaize msg buffer + memset( msg, 0, sizeof(msg_t) ); + + msg->type = ATTR_SYNC_COMPLETE; + + ATTR_SYNC_ADD_PAGE_COUNT( iv_total_pages, msg->data[0] ); + + l_err = sendMboxMessage( SYNCHRONOUS, msg ); + + if( l_err == NULL ) + { + // see if there was an error on the other end + ATTR_SYNC_RC return_code = ATTR_SYNC_GET_RC( msg->data[0] ); + + if ( return_code ) + { + TRACFCOMP(g_trac_targeting, "return code: 0x%x", return_code ); + + /*@ + * @errortype + * @moduleid TARG_MOD_ATTR_SYNC + * @reasoncode TARG_RC_ATTR_SYNC_FAIL + * @userdata1 return code from FSP attribute sync + * @userdata2 section ID of for section being sync'd + * + * @devdesc The Attribute synchronization code on the + * FSP side was unable to complete the sync + * operation successfully. + */ + l_err = new ErrlEntry(ERRL_SEV_UNRECOVERABLE, + TARG_MOD_ATTR_SYNC, + TARG_RC_ATTR_SYNC_FAIL, + return_code, + (uint64_t)iv_section_to_sync); + } + } + + // for a syncronous message we need to free the message + msg_free( msg ); + + return l_err; + } + + errlHndl_t AttributeSync::sendMboxMessage( MBOX_MSG_TYPE type, + msg_t * i_msg ) + { + errlHndl_t l_errl = NULL; + + TRACDCOMP(g_trac_targeting, "type: 0x%04x", i_msg->type ); + TRACDCOMP(g_trac_targeting, "data0: 0x%016llx",i_msg->data[0] ); + TRACDCOMP(g_trac_targeting, "data1: 0x%016llx",i_msg->data[1] ); + TRACDCOMP(g_trac_targeting, "extra_data: %p",i_msg->extra_data ); + + // determine if its an async message or if we should wait + // for a response + if( type == ASYNCHRONOUS ) + { + TRACDCOMP(g_trac_targeting, + "sendMboxMessage() - sending async mbox msg" ); + l_errl = MBOX::send( MBOX::FSP_ATTR_SYNC_MSGQ, i_msg ); + } + else + { + TRACDCOMP(g_trac_targeting, + "sendMboxMessage() - sending sync mbox msg" ); + l_errl = MBOX::sendrecv( MBOX::FSP_ATTR_SYNC_MSGQ, i_msg ); + + } + + if( l_errl ) + { + TRACFCOMP(g_trac_targeting, + "sendMboxMessage() - failed sending mbox msg" ); + + // if the send failed and the message is still valid, check + // and free the extra data if it exists. + if( i_msg != NULL && i_msg->extra_data != NULL ) + { + free( i_msg->extra_data ); + } + } + + return l_errl; + } + + + errlHndl_t syncAllAttributesToFsp() + { + errlHndl_t l_errl = NULL; + + do{ + // if the mailbox is not enabled then skip attribute sync + // let the test case force message creation/sending + if( !(MBOX::mailbox_enabled()) ) + { + break; + } + + 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]); + + TRACFCOMP(g_trac_targeting,"section count = %d", section_count ); + + // push down all attributes to FSP + AttributeSync l_Sync; + + uint8_t i = 0; + + for(; i < section_count; i++) + { + l_errl = l_Sync.syncSectionToFsp( section_type[i] ); + + if( l_errl ) + { + TRACFCOMP(g_trac_targeting, + "Error returned when syncing section type %d", + section_type[i]); + break; + } + } + + } while (0); + + return l_errl; + } + +}; // end namespace + + diff --git a/src/usr/targeting/common/targetservice.C b/src/usr/targeting/common/targetservice.C index c38bb5cbf..d920ae07d 100644 --- a/src/usr/targeting/common/targetservice.C +++ b/src/usr/targeting/common/targetservice.C @@ -531,13 +531,52 @@ void TargetService::dump() const #undef TARG_FN } + +//****************************************************************************** +// TargetService::writeSectionData +//****************************************************************************** +bool TargetService::writeSectionData( + const std::vector<sectionRefData>& i_pages) +{ + #define TARG_FN "writeSectionData(...)" + TARG_ENTER(); + bool l_response = false; + if(i_pages.size() != 0) + { + TARG_GET_SINGLETON(TARGETING::theAttrRP).writeSectionData(i_pages); + l_response = true; + } + TARG_EXIT(); + + return l_response; + #undef TARG_FN +} + +//****************************************************************************** +// TargetService::readSectionData +//****************************************************************************** +void TargetService::readSectionData( + std::vector <sectionRefData>& o_pages, + const SECTION_TYPE i_sectionId) +{ + #define TARG_FN "readSectionData(...)" + TARG_ENTER(); + + TARG_GET_SINGLETON(TARGETING::theAttrRP).readSectionData( + o_pages, i_sectionId); + + TARG_EXIT(); + + #undef TARG_FN +} + //****************************************************************************** // TargetService::_configureTargetPool //****************************************************************************** void TargetService::_configureTargetPool() { - #define TARG_FN "_configureTargetPool(...)" +#define TARG_FN "_configureTargetPool(...)" TARG_ENTER(); diff --git a/src/usr/targeting/makefile b/src/usr/targeting/makefile index 09d170818..150d48185 100644 --- a/src/usr/targeting/makefile +++ b/src/usr/targeting/makefile @@ -42,7 +42,8 @@ VPATH = \ ${addprefix ${COMMON_TARGETING_REL_PATH}/, ${COMMON_TARGETING_SUBDIRS}} ATTR_RP_OBJS = \ - attrrp.o + attrrp.o \ + attrsync.o ENTRY_POINT_OBJS = \ targetservicestart.o diff --git a/src/usr/targeting/test/makefile b/src/usr/targeting/test/makefile index dc33093bc..018effea2 100644 --- a/src/usr/targeting/test/makefile +++ b/src/usr/targeting/test/makefile @@ -1,11 +1,11 @@ -# IBM_PROLOG_BEGIN_TAG +# IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # $Source: src/usr/targeting/test/makefile $ # # IBM CONFIDENTIAL # -# COPYRIGHT International Business Machines Corp. 2011 +# COPYRIGHT International Business Machines Corp. 2011-2012 # # p1 # @@ -19,8 +19,7 @@ # # Origin: 30 # -# IBM_PROLOG_END - +# IBM_PROLOG_END_TAG ################################################################################ # # @file src/usr/targeting/test/makefile @@ -63,7 +62,7 @@ MODULE = testtargeting COMMON_TESTCASE_REL_PATHS = \ $(addprefix ${COMMON_TARGETING_REL_PATH}/test/,${COMMON_TESTCASES}) -TESTS = testtargeting.H ${COMMON_TESTCASE_REL_PATHS} +TESTS = testtargeting.H testattrsync.H ${COMMON_TESTCASE_REL_PATHS} OBJS = attributestrings.o diff --git a/src/usr/targeting/test/testattrsync.H b/src/usr/targeting/test/testattrsync.H new file mode 100644 index 000000000..69e90004b --- /dev/null +++ b/src/usr/targeting/test/testattrsync.H @@ -0,0 +1,119 @@ +/* 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 + */ +#ifndef __TARGETING_TESTATTRSYNC_H +#define __TARGETING_TESTATTRSYNC_H + +/** + * @file targeting/test/testattrsync.H + * + * @brief All unit tests which test attribute sync + */ + +//****************************************************************************** +// Includes +//****************************************************************************** + +// STD +#include <stdio.h> +#include <sys/time.h> + +// CXXTEST +#include <cxxtest/TestSuite.H> +#include <errl/errlmanager.H> + +// This component +#include <targeting/common/attributes.H> +#include <targeting/common/entitypath.H> +#include <targeting/common/target.H> +#include <targeting/common/targetservice.H> +#include <targeting/common/iterators/rangefilter.H> +#include <targeting/common/predicates/predicatectm.H> +#include <targeting/common/predicates/predicatepostfixexpr.H> +#include <targeting/attrsync.H> +#include <errl/errludtarget.H> +#include <targeting/common/trace.H> +#include <kernel/console.H> + +class AttrSyncTestSuite : public CxxTest::TestSuite +{ + public: + + /** + * @brief Test sync of targeting attributes to FSP + */ + void testAttributeSync() + { + TS_TRACE(ENTER_MRK "testAttributeSync" ); + + using namespace TARGETING; + + AttributeSync l_attrSync; + + TS_TRACE( "Sync PNOR RW" ); + + errlHndl_t err = l_attrSync.syncSectionToFsp( + TARGETING::SECTION_TYPE_PNOR_RW ); + + if( err ) + { + if( MBOX::mailbox_enabled() ) + { + TS_FAIL(" Error returned when syncing SECTION_TYPE_PNOR_RW"); + } + err = NULL; + } + + TS_TRACE("Sync PNOR INIT " ); + + err = l_attrSync.syncSectionToFsp( + TARGETING::SECTION_TYPE_HEAP_PNOR_INIT ); + + if( err ) + { + if( MBOX::mailbox_enabled() ) + { + TS_FAIL(" Error returned when syncing SECTION_TYPE_HEAP_PNOR_INIT"); + } + err = NULL; + } + + TS_TRACE( "Sync PNOR ZERO INIT" ); + + err = l_attrSync.syncSectionToFsp( + TARGETING::SECTION_TYPE_HEAP_ZERO_INIT ); + + if( err ) + { + if( MBOX::mailbox_enabled() ) + { + TS_FAIL(" Error returned when syncing SECTION_TYPE_HEAP_ZERO_INIT"); + } + err = NULL; + } + + } + +}; + +#endif // End __TARGETING_TESTTARGETING_H |