From 6454fc5ee6f30a98202f1595c458f32b26393f70 Mon Sep 17 00:00:00 2001 From: Patrick Williams Date: Tue, 14 Jan 2014 18:58:57 -0600 Subject: HBRT: Support full targeting in Sapphire. Change-Id: Ib8119e3c11cfa1171b76f2260871d2de5e99d502 RTC: 87716 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/8145 Tested-by: Jenkins Server Reviewed-by: Douglas R. Gilbert Reviewed-by: Daniel M. Crowell Reviewed-by: A. Patrick Williams III --- src/usr/targeting/attrrp.C | 49 +++++++++++-- src/usr/targeting/attrrp_common.C | 8 ++- src/usr/targeting/common/targetservice.C | 4 +- src/usr/targeting/runtime/attrrp_rt.C | 118 ++++++++++++++++++++++++++++++- src/usr/targeting/runtime/start_rt.C | 13 +++- src/usr/targeting/targplatutil.C | 4 +- 6 files changed, 177 insertions(+), 19 deletions(-) (limited to 'src/usr/targeting') diff --git a/src/usr/targeting/attrrp.C b/src/usr/targeting/attrrp.C index bb1f82eee..d51dcc422 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,2013 */ +/* COPYRIGHT International Business Machines Corp. 2011,2014 */ /* */ /* p1 */ /* */ @@ -51,12 +51,6 @@ using namespace ERRORLOG; namespace TARGETING { - void AttrRP::init(errlHndl_t &io_taskRetErrl) - { - // Call startup on singleton instance. - Singleton::instance().startup(io_taskRetErrl); - } - void* AttrRP::getBaseAddress(const NODE_ID i_nodeIdUnused) { return reinterpret_cast(VMM_VADDR_ATTR_RP); @@ -478,4 +472,45 @@ namespace TARGETING return l_errl; } + void* AttrRP::save(uint64_t& io_addr) + { + // Call save on singleton instance. + return Singleton::instance()._save(io_addr); + } + + void* AttrRP::_save(uint64_t& io_addr) + { + TRACDCOMP(g_trac_targeting, "AttrRP::save: top @ 0x%lx", io_addr); + io_addr = ALIGN_PAGE_DOWN(io_addr); + + // Find total size of the sections. + uint64_t l_size = 0; + for(size_t i = 0; i < iv_sectionCount; ++i) + { + l_size += ALIGN_PAGE(iv_sections[i].size); + } + + // Determine bottom of the address region. + io_addr = io_addr - l_size; + + + // Map in region. + void* region = mm_block_map(reinterpret_cast(io_addr), + l_size); + uint8_t* pointer = reinterpret_cast(region); + + // Copy content. + for (size_t i = 0; i < iv_sectionCount; ++i) + { + memcpy(pointer, + reinterpret_cast(iv_sections[i].vmmAddress), + iv_sections[i].size); + + pointer = &pointer[ALIGN_PAGE(iv_sections[i].size)]; + } + + TRACFCOMP(g_trac_targeting, "AttrRP::save: bottom @ 0x%lx", io_addr); + return region; + } + }; diff --git a/src/usr/targeting/attrrp_common.C b/src/usr/targeting/attrrp_common.C index 84f864b10..3d013005b 100644 --- a/src/usr/targeting/attrrp_common.C +++ b/src/usr/targeting/attrrp_common.C @@ -5,7 +5,7 @@ /* */ /* IBM CONFIDENTIAL */ /* */ -/* COPYRIGHT International Business Machines Corp. 2013 */ +/* COPYRIGHT International Business Machines Corp. 2013,2014 */ /* */ /* p1 */ /* */ @@ -57,6 +57,12 @@ namespace TARGETING TARG_ASSERT(false); } + void AttrRP::init(errlHndl_t &io_taskRetErrl) + { + // Call startup on singleton instance. + Singleton::instance().startup(io_taskRetErrl); + } + bool AttrRP::writeSectionData( const std::vector& i_pages) const { diff --git a/src/usr/targeting/common/targetservice.C b/src/usr/targeting/common/targetservice.C index b6b94be1e..487536c07 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,2013 */ +/* COPYRIGHT International Business Machines Corp. 2011,2014 */ /* */ /* p1 */ /* */ @@ -634,9 +634,7 @@ void TargetService::masterProcChipTargetHandle( { /* Error is already traced w.r.t api called, not repeating here*/ TARG_ERR("Not able to find the Master Proc Chip Target Handle"); -#ifndef __HOSTBOOT_RUNTIME // TODO: RTC 87716 delete pError; -#endif pError = NULL; o_masterProcChipTargetHandle = NULL; } diff --git a/src/usr/targeting/runtime/attrrp_rt.C b/src/usr/targeting/runtime/attrrp_rt.C index 4cf168133..7aa705471 100644 --- a/src/usr/targeting/runtime/attrrp_rt.C +++ b/src/usr/targeting/runtime/attrrp_rt.C @@ -5,7 +5,7 @@ /* */ /* IBM CONFIDENTIAL */ /* */ -/* COPYRIGHT International Business Machines Corp. 2013 */ +/* COPYRIGHT International Business Machines Corp. 2013,2014 */ /* */ /* p1 */ /* */ @@ -23,15 +23,129 @@ #include #include #include +#include +#include +#include +#include #include "../attrrp_common.C" +using namespace ERRORLOG; namespace TARGETING { + void AttrRP::startup(errlHndl_t& io_taskRetErrl) + { + errlHndl_t l_errl = NULL; + + do + { + TargetingHeader* l_header = reinterpret_cast( + g_hostInterfaces->get_reserved_mem("ibm,hbrt-target-image")); + + if ((NULL == l_header) || + (l_header->eyeCatcher != PNOR_TARG_EYE_CATCHER)) + { + /*@ + * @errortype + * @moduleid TARG_MOD_ATTRRP_RT + * @reasoncode TARG_RC_BAD_EYECATCH + * @userdata1 Observed Header Eyecatch Value + * @userdata2 Memory address referenced. + * + * @devdesc The eyecatch value observed in memory does not + * match the expected value of + * PNOR_TARG_EYE_CATCHER and therefore the + * contents of the Attribute sections are + * unable to be parsed. + */ + l_errl = new ErrlEntry(ERRL_SEV_UNRECOVERABLE, + TARG_MOD_ATTRRP_RT, + TARG_RC_BAD_EYECATCH, + NULL == l_header ? + 0 : l_header->eyeCatcher, + reinterpret_cast(l_header)); + break; + } + + // Allocate section structures based on section count in header. + iv_sectionCount = l_header->numSections; + iv_sections = new AttrRP_Section[iv_sectionCount](); + + // Find start to the first section: + // (header address + size of header + offset in header) + TargetingSection* l_section = + reinterpret_cast( + reinterpret_cast(l_header) + + sizeof(TargetingHeader) + l_header->offsetToSections + ); + + uint64_t l_offset = 0; + + for (size_t i = 0; i < iv_sectionCount; ++i, ++l_section) + { + iv_sections[i].type = l_section->sectionType; + iv_sections[i].size = l_section->sectionSize; + + iv_sections[i].vmmAddress = + static_cast( + TARG_TO_PLAT_PTR(l_header->vmmBaseAddress)) + + l_header->vmmSectionOffset*i; + iv_sections[i].pnorAddress = + reinterpret_cast(l_header) + l_offset; + + l_offset += ALIGN_PAGE(iv_sections[i].size); + + TRACFCOMP(g_trac_targeting, + "Decoded Attribute Section: %d, 0x%lx, 0x%lx, 0x%lx", + iv_sections[i].type, + iv_sections[i].vmmAddress, + iv_sections[i].pnorAddress, + iv_sections[i].size); + } + + } while(false); + + if (l_errl) + { + l_errl->setSev(ERRORLOG::ERRL_SEV_UNRECOVERABLE); + } + + io_taskRetErrl = l_errl; + } + void* AttrRP::getBaseAddress(const NODE_ID i_nodeIdUnused) { - return reinterpret_cast(VMM_VADDR_ATTR_RP); + return reinterpret_cast(iv_sections[0].pnorAddress); } + void* AttrRP::translateAddr(void* i_pAddress, + const Target* i_pUnused) + { + void* l_address = NULL; + + for (size_t i = 0; i < iv_sectionCount; ++i) + { + if ((iv_sections[i].vmmAddress + iv_sections[i].size) >= + reinterpret_cast(i_pAddress)) + { + l_address = reinterpret_cast( + iv_sections[i].pnorAddress + + reinterpret_cast(i_pAddress) - + iv_sections[i].vmmAddress); + break; + } + } + + TRACDCOMP(g_trac_targeting, "Translated 0x%p to 0x%p", + i_pAddress, l_address); + + return l_address; + } + + void* AttrRP::translateAddr(void* i_pAddress, + const TARGETING::NODE_ID i_unused) + { + return translateAddr(i_pAddress, static_cast(NULL)); + } } diff --git a/src/usr/targeting/runtime/start_rt.C b/src/usr/targeting/runtime/start_rt.C index d0cef38a7..5efea7888 100644 --- a/src/usr/targeting/runtime/start_rt.C +++ b/src/usr/targeting/runtime/start_rt.C @@ -5,7 +5,7 @@ /* */ /* IBM CONFIDENTIAL */ /* */ -/* COPYRIGHT International Business Machines Corp. 2013 */ +/* COPYRIGHT International Business Machines Corp. 2013,2014 */ /* */ /* p1 */ /* */ @@ -22,14 +22,21 @@ /* IBM_PROLOG_END_TAG */ #include #include +#include namespace TARGETING { static void initTargeting() __attribute__((constructor)); static void initTargeting() { - //@TODO: RTC 87716: Init attr RP. - //AttrRP::init(); + errlHndl_t l_errl = NULL; + + AttrRP::init(l_errl); + if (l_errl) + { + errlCommit(l_errl, TARG_COMP_ID); + assert(false); + } TargetService& l_targetService = targetService(); (void)l_targetService.init(); diff --git a/src/usr/targeting/targplatutil.C b/src/usr/targeting/targplatutil.C index 677da78bb..f619c5e91 100644 --- a/src/usr/targeting/targplatutil.C +++ b/src/usr/targeting/targplatutil.C @@ -5,7 +5,7 @@ /* */ /* IBM CONFIDENTIAL */ /* */ -/* COPYRIGHT International Business Machines Corp. 2013 */ +/* COPYRIGHT International Business Machines Corp. 2013,2014 */ /* */ /* p1 */ /* */ @@ -62,7 +62,6 @@ void createTracingError( const uint32_t i_userData4, errlHndl_t& io_pError) { -#ifndef __HOSTBOOT_RUNTIME // TODO: RTC 87716 errlHndl_t pNewError = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_INFORMATIONAL, i_modId, @@ -82,7 +81,6 @@ void createTracingError( io_pError = pNewError; pNewError = NULL; } -#endif return; } -- cgit v1.2.1