diff options
-rw-r--r-- | src/include/usr/targeting/attrrp.H | 32 | ||||
-rw-r--r-- | src/include/usr/targeting/targplatreasoncodes.H | 3 | ||||
-rw-r--r-- | src/usr/devtree/bld_devtree.C | 79 | ||||
-rw-r--r-- | src/usr/targeting/attrrp.C | 49 | ||||
-rw-r--r-- | src/usr/targeting/attrrp_common.C | 8 | ||||
-rw-r--r-- | src/usr/targeting/common/targetservice.C | 4 | ||||
-rw-r--r-- | src/usr/targeting/runtime/attrrp_rt.C | 118 | ||||
-rw-r--r-- | src/usr/targeting/runtime/start_rt.C | 13 | ||||
-rw-r--r-- | src/usr/targeting/targplatutil.C | 4 | ||||
-rw-r--r-- | src/usr/testcore/rtloader/loader.H | 34 |
10 files changed, 289 insertions, 55 deletions
diff --git a/src/include/usr/targeting/attrrp.H b/src/include/usr/targeting/attrrp.H index af27b6359..abd21ee8f 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,2013 */ +/* COPYRIGHT International Business Machines Corp. 2011,2014 */ /* */ /* p1 */ /* */ @@ -105,9 +105,13 @@ class AttrRP void* translateAddr( void* i_pAddress, const Target* i_pUnused) +#ifndef __HOSTBOOT_RUNTIME { return i_pAddress; } +#else + ; +#endif /** * @brief Translates given address, according to the resource @@ -129,11 +133,14 @@ class AttrRP void* translateAddr( void* i_pAddress, const TARGETING::NODE_ID i_unused) +#ifndef __HOSTBOOT_RUNTIME { return i_pAddress; } +#else + ; +#endif -#ifndef __HOSTBOOT_RUNTIME /** * @brief Initializes and starts the AttrRP daemon. * @@ -147,6 +154,21 @@ class AttrRP * service. */ static void init(errlHndl_t& io_taskRetErrl); + +#ifndef __HOSTBOOT_RUNTIME + /** + * @brief Copies all present attribute sections to memory. + * + * The copy will grow down from the input address. + * + * @param[in,out] i_addr + * Physical address at the top of the desired region to + * place. After function will be the address at the bottom of + * the region. + * + * @return Virtual address to the region. + */ + static void* save(uint64_t& io_addr); #endif protected: @@ -211,7 +233,6 @@ class AttrRP private: -#ifndef __HOSTBOOT_RUNTIME /** * @brief Performs the startup of the daemon instance. * @@ -227,6 +248,8 @@ class AttrRP */ void startup(errlHndl_t& io_taskRetErrl); +#ifndef __HOSTBOOT_RUNTIME + /** * @brief Processes daemon messages * @@ -264,6 +287,9 @@ class AttrRP */ errlHndl_t createVmmSections(); + /** Internal implementation of save function. */ + void* _save(uint64_t&); + /** * @brief Starts the attribute provider's message processor * diff --git a/src/include/usr/targeting/targplatreasoncodes.H b/src/include/usr/targeting/targplatreasoncodes.H index 1f3d18dbc..4895bd8db 100644 --- a/src/include/usr/targeting/targplatreasoncodes.H +++ b/src/include/usr/targeting/targplatreasoncodes.H @@ -5,7 +5,7 @@ /* */ /* IBM CONFIDENTIAL */ /* */ -/* COPYRIGHT International Business Machines Corp. 2013 */ +/* COPYRIGHT International Business Machines Corp. 2013,2014 */ /* */ /* p1 */ /* */ @@ -53,6 +53,7 @@ enum PlatTargetingModuleId { TARG_MOD_QUERY_MASTER_PROC_CHIP = 0x80, TARG_MOD_SET_MASTER_NODE = 0x81, + TARG_MOD_ATTRRP_RT = 0x82, }; /** diff --git a/src/usr/devtree/bld_devtree.C b/src/usr/devtree/bld_devtree.C index 64dcfcbeb..fe04fd985 100644 --- a/src/usr/devtree/bld_devtree.C +++ b/src/usr/devtree/bld_devtree.C @@ -5,7 +5,7 @@ /* */ /* IBM CONFIDENTIAL */ /* */ -/* COPYRIGHT International Business Machines Corp. 2013 */ +/* COPYRIGHT International Business Machines Corp. 2013,2014 */ /* */ /* p1 */ /* */ @@ -39,6 +39,7 @@ $ */ #include <targeting/common/target.H> #include <targeting/common/targetservice.H> #include <targeting/common/utilFilter.H> +#include <targeting/attrrp.H> #include <devtree/devtree_reasoncodes.H> #include <devtree/devtreeif.H> #include "devtree.H" @@ -451,7 +452,10 @@ uint32_t bld_intr_node(devTree * i_dt, dtOffset_t & i_parentNode, void add_reserved_mem(devTree * i_dt, uint64_t i_homerAddr[], size_t i_num, - uint64_t i_vpd_addr) + uint64_t i_extraAddr[], + uint64_t i_extraSize[], + const char* i_extraStr[], + uint64_t i_extraCnt) { /* * The reserved-names and reserve-names properties work hand in hand. @@ -477,12 +481,11 @@ void add_reserved_mem(devTree * i_dt, dtOffset_t rootNode = i_dt->findNode("/"); const char* homerStr = "ibm,slw-occ-image"; - const char* vpdStr = "ibm,hbrt-vpd-image"; - const char* reserve_strs[i_num+2]; - uint64_t ranges[i_num+1][2]; + const char* reserve_strs[i_num+i_extraCnt+1]; + uint64_t ranges[i_num+i_extraCnt][2]; uint64_t cell_count = sizeof(ranges) / sizeof(uint64_t); - uint64_t res_mem_addrs[i_num+1]; - uint64_t res_mem_sizes[i_num+1]; + uint64_t res_mem_addrs[i_num+i_extraCnt]; + uint64_t res_mem_sizes[i_num+i_extraCnt]; for(size_t i = 0; i<i_num; i++) { @@ -493,22 +496,28 @@ void add_reserved_mem(devTree * i_dt, res_mem_sizes[i] = VMM_HOMER_INSTANCE_SIZE; } - if(i_vpd_addr) + for(size_t i = 0; i < i_extraCnt; i++) { - reserve_strs[i_num] = vpdStr; - ranges[i_num][0] = i_vpd_addr; - ranges[i_num][1] = VMM_RT_VPD_SIZE; + if (i_extraAddr[i]) + { + TRACFCOMP( g_trac_devtree, "Reserved Region %s @ %lx, %lx", + i_extraStr[i], i_extraAddr[i], i_extraSize[i]); - res_mem_addrs[i_num] = i_vpd_addr; - res_mem_sizes[i_num] = VMM_RT_VPD_SIZE; + reserve_strs[i_num] = i_extraStr[i]; + ranges[i_num][0] = i_extraAddr[i]; + ranges[i_num][1] = i_extraSize[i]; - reserve_strs[i_num+1] = NULL; - } - else - { - reserve_strs[i_num] = NULL; - cell_count -= sizeof(ranges[0]); + res_mem_addrs[i_num] = i_extraAddr[i]; + res_mem_sizes[i_num] = i_extraSize[i]; + + i_num++; + } + else + { + cell_count -= sizeof(ranges[0]); + } } + reserve_strs[i_num] = NULL; i_dt->addPropertyStrings(rootNode, "reserved-names", reserve_strs); i_dt->addPropertyCells64(rootNode, "reserved-ranges", @@ -517,7 +526,7 @@ void add_reserved_mem(devTree * i_dt, // added per comment from Dean Sanner // cell_count has limit of DT_MAX_MEM_RESERVE = 16. Is this enough - // for all processors + 1 vpd area? + // for all processors + 1 vpd area + 1 target area? i_dt->populateReservedMem(res_mem_addrs, res_mem_sizes, cell_count); } @@ -535,13 +544,13 @@ errlHndl_t bld_fdt_cpu(devTree * i_dt) i_dt->addPropertyCell32(cpusNode, "#size-cells", 0); // Get all functional proc chip targets - TARGETING::TargetHandleList l_cpuTargetList; - getAllChips(l_cpuTargetList, TYPE_PROC); - uint64_t l_homerAddr[l_cpuTargetList.size()]; + TARGETING::TargetHandleList l_procTargetList; + getAllChips(l_procTargetList, TYPE_PROC); + uint64_t l_homerAddr[l_procTargetList.size()]; - for ( size_t proc = 0; (!errhdl) && (proc < l_cpuTargetList.size()); proc++) + for (size_t proc = 0; (!errhdl) && (proc < l_procTargetList.size()); proc++) { - const TARGETING::Target * l_pProc = l_cpuTargetList[proc]; + const TARGETING::Target * l_pProc = l_procTargetList[proc]; uint32_t l_chipid = getProcChipId(l_pProc); @@ -593,12 +602,26 @@ errlHndl_t bld_fdt_cpu(devTree * i_dt) errhdl = VPD::vpd_load_rt_image(l_vpd_addr); + // Targeting + uint64_t l_targ_addr = l_vpd_addr; + TARGETING::AttrRP::save(l_targ_addr); + + + uint64_t l_extra_addrs[] = { l_vpd_addr, l_targ_addr }; + uint64_t l_extra_sizes[] = { VMM_RT_VPD_SIZE, l_vpd_addr - l_targ_addr }; + const char* l_extra_addrs_str[] = + { "ibm,hbrt-vpd-image" , + "ibm,hbrt-target-image" }; + size_t l_extra_addr_cnt = sizeof(l_extra_addrs) / sizeof(uint64_t); - //Add in reserved memory for HOMER images and VPD image + //Add in reserved memory for HOMER images and HBRT sections. add_reserved_mem(i_dt, l_homerAddr, - l_cpuTargetList.size(), - l_vpd_addr); + l_procTargetList.size(), + l_extra_addrs, + l_extra_sizes, + l_extra_addrs_str, + l_extra_addr_cnt); return errhdl; } 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<AttrRP>::instance().startup(io_taskRetErrl); - } - void* AttrRP::getBaseAddress(const NODE_ID i_nodeIdUnused) { return reinterpret_cast<void*>(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<AttrRP>::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<void*>(io_addr), + l_size); + uint8_t* pointer = reinterpret_cast<uint8_t*>(region); + + // Copy content. + for (size_t i = 0; i < iv_sectionCount; ++i) + { + memcpy(pointer, + reinterpret_cast<void*>(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<AttrRP>::instance().startup(io_taskRetErrl); + } + bool AttrRP::writeSectionData( const std::vector<TARGETING::sectionRefData>& 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 <targeting/attrrp.H> #include <targeting/common/trace.H> #include <util/align.H> +#include <runtime/interface.h> +#include <errl/errlentry.H> +#include <targeting/common/targreasoncodes.H> +#include <targeting/targplatreasoncodes.H> #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<TargetingHeader*>( + 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<uint64_t>(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<TargetingSection*>( + reinterpret_cast<uint64_t>(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<uint64_t>( + TARG_TO_PLAT_PTR(l_header->vmmBaseAddress)) + + l_header->vmmSectionOffset*i; + iv_sections[i].pnorAddress = + reinterpret_cast<uint64_t>(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<void*>(VMM_VADDR_ATTR_RP); + return reinterpret_cast<void*>(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<uint64_t>(i_pAddress)) + { + l_address = reinterpret_cast<void*>( + iv_sections[i].pnorAddress + + reinterpret_cast<uint64_t>(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<Target*>(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 <targeting/common/commontargeting.H> #include <targeting/common/targetservice.H> +#include <targeting/attrrp.H> 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; } diff --git a/src/usr/testcore/rtloader/loader.H b/src/usr/testcore/rtloader/loader.H index c2935d769..eacb2b2af 100644 --- a/src/usr/testcore/rtloader/loader.H +++ b/src/usr/testcore/rtloader/loader.H @@ -28,6 +28,7 @@ #include <sys/mm.h> #include <targeting/common/targetservice.H> #include <targeting/common/attributes.H> +#include <targeting/attrrp.H> #include <targeting/common/utilFilter.H> #include <errl/errlmanager.H> #include <util/utillidmgr.H> @@ -304,6 +305,8 @@ class RuntimeLoaderTest : public CxxTest::TestSuite { if (0 == strcmp(i_region, "ibm,hbrt-vpd-image")) return rt_get_vpd(); + else if (0 == strcmp(i_region, "ibm,hbrt-target-image")) + return rt_get_targ(); else return 0; } @@ -318,15 +321,13 @@ class RuntimeLoaderTest : public CxxTest::TestSuite // runtime VPD area not setup yet. // Need to map the area into virtual memory - - uint64_t phys_addr = 0; - errlHndl_t err = VPD::vpd_load_rt_image(phys_addr); + errlHndl_t err = VPD::vpd_load_rt_image(cv_vpd_phys_addr); if(!err) { uint8_t * vpd_ptr = - reinterpret_cast<uint8_t *>(phys_addr); + reinterpret_cast<uint8_t *>(cv_vpd_phys_addr); void * vptr = mm_block_map(vpd_ptr, VMM_RT_VPD_SIZE); @@ -346,13 +347,38 @@ class RuntimeLoaderTest : public CxxTest::TestSuite } + static uint64_t rt_get_targ() + { + if (cv_targ_addr != 0) + { + return cv_targ_addr; + } + + // Ensure cv_vpd_phys_addr is primed. + rt_get_vpd(); + + cv_targ_phys_addr = cv_vpd_phys_addr; + cv_targ_addr = reinterpret_cast<uint64_t>( + TARGETING::AttrRP::save(cv_targ_phys_addr)); + + return cv_targ_addr; + } + static uint64_t cv_vpd_addr; + static uint64_t cv_vpd_phys_addr; + static uint64_t cv_targ_addr; + static uint64_t cv_targ_phys_addr; }; RuntimeLoaderTest::SCOM_MAP RuntimeLoaderTest::cv_scomMap; std::map<void*, UtilLidMgr*> RuntimeLoaderTest::cv_loadedLids; uint64_t RuntimeLoaderTest::cv_vpd_addr = 0; +uint64_t RuntimeLoaderTest::cv_vpd_phys_addr = 0; +uint64_t RuntimeLoaderTest::cv_targ_addr = 0; +uint64_t RuntimeLoaderTest::cv_targ_phys_addr = 0; + + #endif |