From 871d02a4e2c66e7c0501812abd86a27009cc73e0 Mon Sep 17 00:00:00 2001 From: Claus Michael Olsen Date: Wed, 5 Apr 2017 05:16:51 -0500 Subject: Code restruct: TOR API Key_Cronus_Test=XIP_REGRESS Code restructuring aiming at: - utilizing TOR magic header info - enforce a common approach for - extracting metadata for all image,chipType combinations - traversing images for all image,chipType combinations - shrinking code size by reusing common code segments - improve readability by - separating more clearly metadata extraction and image traversal - slight rearrange of certain code segments - remove leftover hardcoded assumptions about ring/TOR data and structs - variables appropriately renamed and now all using camel style Change-Id: I50ace8b2fdb340a97ce6d74ce545c5e1acd21c40 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/38863 Tested-by: HWSV CI Tested-by: PPE CI Tested-by: Jenkins Server Tested-by: Cronus HW CI Tested-by: FSP CI Jenkins Tested-by: Hostboot CI Reviewed-by: GIRISANKAR PAULRAJ Reviewed-by: Thi N. Tran Reviewed-by: Jennifer A. Stofer Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/43250 Reviewed-by: Hostboot Team Reviewed-by: Sachin Gupta --- src/import/chips/p9/xip/p9_xip_tool.C | 57 ++++++++++++++--------------------- 1 file changed, 23 insertions(+), 34 deletions(-) (limited to 'src/import/chips/p9/xip/p9_xip_tool.C') diff --git a/src/import/chips/p9/xip/p9_xip_tool.C b/src/import/chips/p9/xip/p9_xip_tool.C index f5317915..0a38fb46 100644 --- a/src/import/chips/p9/xip/p9_xip_tool.C +++ b/src/import/chips/p9/xip/p9_xip_tool.C @@ -43,10 +43,10 @@ #undef P9_XIP_TOOL_VERBOSE #include "p9_xip_image.h" +#include "common_ringId.H" #ifndef __PPE__ // Needed on ppe side to avoid having to include various APIs #include "p9_tor.H" #include "p9_scan_compression.H" -#include "p9_infrastruct_help.H" namespace P9_RID { #include "p9_ringId.H" @@ -56,7 +56,7 @@ namespace CEN_RID #include "cen_ringId.H" } #include -#include +#include "p9_dd_container.h" #include #endif #include "p9_infrastruct_help.H" @@ -1864,9 +1864,6 @@ TEST(void* io_image, const int i_argc, const char** i_argv) #ifndef __PPE__ // Needed on the ppe side to avoid TOR API -//@FIXME: This should be improved. Probably defined somewhere else. -#define CHIPLET_ID_MAX (uint8_t)0x37 - /// Function: dissectRingSectionTor() /// /// Brief: Dissects and summarizes content of a ring section. @@ -1887,12 +1884,11 @@ int dissectRingSectionTor( uint8_t* i_ringSection, uint32_t i; RingId_t numRingIds = 0; uint32_t torMagic = 0xffffffff; // Undefined value - ChipType_t chipType = 0xff; // Undefined value + ChipType_t chipType = UNDEFINED_CHIP_TYPE; // Undefined value uint32_t numDdLevels = 0; // Undefined value uint8_t iDdLevel, ddLevel = 0xff; // Undefined value PpeType_t ppeType; RingId_t ringId; - RingType_t ringType; RingVariant_t ringVariant; uint8_t instanceId; void* ringBlockPtr; @@ -2038,12 +2034,12 @@ int dissectRingSectionTor( uint8_t* i_ringSection, //-------------------- // Ring variant loop. - // - Base, cache, risk, override, overlay + // - Base, cache, risk or just "base" if no ring variant for (ringVariant = 0; ringVariant < OVERRIDE; ringVariant++) { - if ( (torMagic == TOR_MAGIC_OVRD && ringVariant != BASE) || - (torMagic == TOR_MAGIC_OVLY && ringVariant != BASE) || - (torMagic == TOR_MAGIC_CEN && ringVariant == CC) ) + if ((torMagic == TOR_MAGIC_OVRD && ringVariant != BASE) || + (torMagic == TOR_MAGIC_OVLY && ringVariant != BASE) || + (torMagic == TOR_MAGIC_CEN && ringVariant == CC)) { continue; } @@ -2053,13 +2049,19 @@ int dissectRingSectionTor( uint8_t* i_ringSection, for (ringId = 0; ringId < numRingIds; ringId++) { - ringType = 0xff; - //--------------------------- // Chiplet instance ID loop. - // - Only loop once if ringId is a common ring. - for (instanceId = 0; instanceId <= CHIPLET_ID_MAX && ringType != COMMON_RING; instanceId++) + // - Only loop once if ringId is a common ring. Determine this by + // comparing the returned value of instanceId in tor_access_ring() + // with the input value of instanceId, instanceInputId. + // - Start looping safely from 0 so that if instanceId is adjusted + // in tor_access_ring, i.e. in case it's an instance ring, it will + // return a non-zeor value for instanceId. + uint8_t instanceInputId; + + for (instanceId = 0; instanceId <= INSTANCE_ID_MAX; instanceId++) { + instanceInputId = instanceId; #ifdef P9_XIP_TOOL_VERBOSE fprintf( stderr, "Processing: " "DD=0x%02x " @@ -2075,7 +2077,6 @@ int dissectRingSectionTor( uint8_t* i_ringSection, ringId, ddLevel, ppeType, - ringType, // IO parm ringVariant, instanceId, // IO parm GET_SINGLE_RING, @@ -2086,7 +2087,7 @@ int dissectRingSectionTor( uint8_t* i_ringSection, // Gather ring details and print it. // - if (rc == TOR_RING_FOUND) + if (rc == TOR_SUCCESS) { if(bPrintHeader == true ) { @@ -2307,6 +2308,10 @@ int dissectRingSectionTor( uint8_t* i_ringSection, } while (cmskRingIteration); + if (instanceId != instanceInputId) + { + break; + } } else if (rc == TOR_RING_NOT_FOUND || rc == TOR_INVALID_INSTANCE_ID || @@ -2315,9 +2320,6 @@ int dissectRingSectionTor( uint8_t* i_ringSection, rc == TOR_AMBIGUOUS_API_PARMS || rc == TOR_INVALID_RING_ID) { -#ifdef P9_XIP_TOOL_VERBOSE - fprintf(stderr, "tor_access_ring() returned error code rc=%d\n", rc); -#endif // All these errors are acceptable in the context of xip_tool dissect. rc = INFRASTRUCT_RC_SUCCESS; } @@ -2332,14 +2334,6 @@ int dissectRingSectionTor( uint8_t* i_ringSection, exit(EXIT_FAILURE); } - if (rc && ringType == 255) - { - // So here we were unsuccessful in tor_access_ring and never even found a - // ring name match, or ring variant match, or chiplet match. So we can - // safely break the instanceId loop. - break; - } - } // End of for(instanceId) } // End of for(ringId) @@ -2818,9 +2812,6 @@ int check_sbe_ring_section_size( void* i_hwImage, P9XipSection l_ringsSection; - RingType_t l_ringType = ALLRING; - - uint8_t unused_parm = 0; void** l_blockPtr = NULL; uint32_t l_blockSize = 0; @@ -2847,9 +2838,7 @@ int check_sbe_ring_section_size( void* i_hwImage, rc = tor_get_block_of_rings( ringsSection, i_ddLevel, PT_SBE, - l_ringType, - BASE, - unused_parm, + NOT_VALID, l_blockPtr, l_blockSize); -- cgit v1.2.1