diff options
-rw-r--r-- | src/build/img_defs.mk | 7 | ||||
-rw-r--r-- | src/import/chips/common/utils/imageProcs/common_ringId.H | 53 | ||||
-rw-r--r-- | src/import/chips/p9/utils/imageProcs/p9_tor.C | 133 | ||||
-rw-r--r-- | src/import/chips/p9/utils/imageProcs/p9_tor.H | 18 | ||||
-rw-r--r-- | src/import/chips/p9/xip/Makefile | 8 | ||||
-rw-r--r-- | src/import/chips/p9/xip/p9_xip_image.C | 75 | ||||
-rw-r--r-- | src/import/chips/p9/xip/p9_xip_image.h | 8 | ||||
-rw-r--r-- | src/import/chips/p9/xip/p9_xip_tool.C | 102 | ||||
-rw-r--r-- | src/import/tools/imageProcs/p9_ipl_build.C | 144 | ||||
-rw-r--r-- | src/import/tools/imageProcs/p9_ipl_build.H | 9 | ||||
-rw-r--r-- | src/tools/image/Makefile | 7 | ||||
-rw-r--r-- | src/tools/iplbuild/Makefile | 8 |
12 files changed, 353 insertions, 219 deletions
diff --git a/src/build/img_defs.mk b/src/build/img_defs.mk index 189a3104..3403ca59 100644 --- a/src/build/img_defs.mk +++ b/src/build/img_defs.mk @@ -390,12 +390,6 @@ ifdef __FAPI_DELAY_SIM__ GCC-DEFS += -D__FAPI_DELAY_SIM__=1 endif -ifdef __AWAN_SIM_ENV__ -GCC-DEFS += -D__FAPI_DELAY_SIM__=1 -# allow invalid scoms in AWAN run to let regression test cases run -GCC-DEFS += -D__ALLOW_INVALID_SCOMS__=1 -endif - # Generate a 16bit trace string hash prefix value based on the name of this image. This will form # the upper 16 bits of the 32 bit trace hash values. ifndef PK_TRACE_HASH_PREFIX @@ -462,7 +456,6 @@ INCLUDES += -I$(BUILDDATA_SRCDIR) INCLUDES += -I$(PK_SRCDIR)/trace INCLUDES += -I$(PPETRACEPP_DIR) INCLUDES += -I$(IMPORT_COMMON_DIR)/include -#INCLUDES += -I$(IMPORT_UTILS_DIR)/imageProcs INCLUDES += -I$(IMPORT_UTILS_DIR)/ INCLUDES += -I$(IMPORT_SRCDIR)/tools/imageProcs diff --git a/src/import/chips/common/utils/imageProcs/common_ringId.H b/src/import/chips/common/utils/imageProcs/common_ringId.H index 2f55d2d6..d68e2672 100644 --- a/src/import/chips/common/utils/imageProcs/common_ringId.H +++ b/src/import/chips/common/utils/imageProcs/common_ringId.H @@ -29,9 +29,11 @@ #include <stdint.h> #include <stddef.h> +#define TORV3_SUPPORT -//////////////////////////////////////////////////////////////////////////////// -// Declare assumptions - Begin +/////////////////////////////////////////////////////////////////////////////// +// Declare assumptions - Begin // +// // // // Various data type defs for enums. Serves following purposes: @@ -48,40 +50,49 @@ typedef uint8_t ChipType_t; // Type for ChipType enum typedef uint8_t RingType_t; // Type for RingType enum typedef uint8_t RingVariant_t; // Type for RingVariant enum typedef uint32_t TorCpltOffset_t; // Type for offset value to chiplet's CMN or INST section +typedef uint8_t myBoolean_t; // false:0, true:1, undefined:UNDEFINED_BOOLEAN #define UNDEFINED_RING_ID (RingId_t)0xffff #define INVALID_RING_TYPE (RingType_t)0xff #define INVALID_CHIPLET_TYPE (ChipletType_t)0xff +#define UNDEFINED_PPE_TYPE (PpeType_t)0xff #define UNDEFINED_CHIP_TYPE (ChipType_t)0xff #define MAX_TOR_RING_OFFSET (uint16_t)(256*256-1) // Max val of uint16 #define MAX_RING_NAME_LENGTH (uint8_t)50 #define UNDEFINED_DD_LEVEL (uint8_t)0xff +#define UNDEFINED_BOOLEAN (myBoolean_t)0xff -// -// Declare assumptions - End +// // +// Declare assumptions - End // /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -// TOR layout definitions - Begin -// +// TOR layout definitions - Begin // +// // // // TOR header field (appears in top of every HW, SBE, CEN, OVRD, etc ring section) // typedef struct { - uint32_t magic; - uint8_t version; + uint32_t magic; // =TOR_MAGIC_xyz + uint8_t version; // =TOR_VERSION ChipType_t chipType; // Value from ChipType enum +#ifdef TORV3_SUPPORT uint8_t ddLevel; // =0xff if MAGIC_HW, >0 all other MAGICs uint8_t numDdLevels; // >0 if MAGIC_HW, =1 all other MAGICs - uint32_t size; // Size of the TOR ringSection. +#else + uint8_t ddLevel; // Actual DD level of ringSection + uint8_t undefined; +#endif + uint32_t size; // Size of ringSection. } TorHeader_t; // // Subsequent TOR fields (listed in order they appear in TOR ringSections) // +#ifdef TORV3_SUPPORT typedef struct { uint32_t offset; @@ -89,6 +100,7 @@ typedef struct uint8_t ddLevel; uint8_t reserved[3]; } TorDdBlock_t; +#endif typedef struct { @@ -104,16 +116,19 @@ typedef struct typedef uint16_t TorRingOffset_t; // Offset value to actual ring -// -// TOR layout definitions - End +// // +// TOR layout definitions - End // /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -// Key TOR constants - Begin -// +// Key TOR constants - Begin // +// // -#define TOR_VERSION 4 +//#define TOR_VERSION 1 // Initial version. Large RS4 header. +//#define TOR_VERSION 2 // Reduced RS4 header. +//#define TOR_VERSION 3 // Added TOR magic header. +#define TOR_VERSION 4 // TOR API code restructuring. // TOR Magic values for top-level TOR ringSection and sub-ringSections enum TorMagicNum @@ -128,8 +143,8 @@ enum TorMagicNum TOR_MAGIC_CEN = (uint32_t)0x544F524E, // "TORN" }; -// -// Key TOR constants - End +// // +// Key TOR constants - End // /////////////////////////////////////////////////////////////////////////////// @@ -192,9 +207,9 @@ typedef struct // order with which they appear in the HW image's .rings section. enum PpeType { - PT_SBE = 0x00, - PT_CME = 0x01, - PT_SGPE = 0x02, + PT_SBE = 0x00, + PT_CME = 0x01, + PT_SGPE = 0x02, NUM_PPE_TYPES = 0x03 }; diff --git a/src/import/chips/p9/utils/imageProcs/p9_tor.C b/src/import/chips/p9/utils/imageProcs/p9_tor.C index e573fa9b..45726b2e 100644 --- a/src/import/chips/p9/utils/imageProcs/p9_tor.C +++ b/src/import/chips/p9/utils/imageProcs/p9_tor.C @@ -297,6 +297,7 @@ int tor_access_ring( void* i_ringSection, // Ring section ptr int rc = 0; uint32_t torMagic; TorHeader_t* torHeader; +#ifdef TORV3_SUPPORT TorDdBlock_t* torDdBlock; uint32_t ddLevelCount = 0; uint32_t ddLevelOffset = 0; @@ -304,7 +305,8 @@ int tor_access_ring( void* i_ringSection, // Ring section ptr void* ddBlockStart = NULL; uint8_t bDdCheck = 0; uint32_t ddLevel = 0; - +#endif + uint8_t* postHeaderStart = (uint8_t*)i_ringSection + sizeof(TorHeader_t); if (i_dbgl > 1) { @@ -314,7 +316,9 @@ int tor_access_ring( void* i_ringSection, // Ring section ptr torHeader = (TorHeader_t*)i_ringSection; torMagic = be32toh(torHeader->magic); - if (torMagic == TOR_MAGIC_HW) +#ifdef TORV3_SUPPORT + + if (torMagic == TOR_MAGIC_HW && torHeader->version < 5) { ddLevelCount = torHeader->numDdLevels; @@ -374,31 +378,53 @@ int tor_access_ring( void* i_ringSection, // Ring section ptr } else { +#endif + if ( i_ddLevel != torHeader->ddLevel && i_ddLevel != UNDEFINED_DD_LEVEL ) { - MY_ERR("Requested DD level (=0x%x) doesn't match TOR header DD level (=0x%x) nor UNDEFINED_DD_LEVEL\n", - i_ddLevel, torHeader->ddLevel); + MY_ERR("Requested DD level (=0x%x) doesn't match TOR header DD level (=0x%x) nor UNDEFINED_DD_LEVEL (=0x%x) \n", + i_ddLevel, torHeader->ddLevel, UNDEFINED_DD_LEVEL); return TOR_DD_LEVEL_NOT_FOUND; } + +#ifdef TORV3_SUPPORT } +#endif + if ( ( i_ringBlockType == GET_SINGLE_RING ) || // All Magics supported for GET ( i_ringBlockType == PUT_SINGLE_RING && // Can only append to SBE,CME,SGPE ( torMagic == TOR_MAGIC_SBE || torMagic == TOR_MAGIC_CME || torMagic == TOR_MAGIC_SGPE ) ) ) { + void* l_ringSection = i_ringSection; + if ( torMagic == TOR_MAGIC_HW ) { - // Update i_ringSection: - // Extract the offset to the specified ppeType's ring section TOR header and update i_ringSection + // Update l_ringSection: + // Extract the offset to the specified ppeType's ring section TOR header and update l_ringSection TorPpeBlock_t* torPpeBlock; - torPpeBlock = (TorPpeBlock_t*)((uint8_t*)ddBlockStart + i_ppeType * sizeof(TorPpeBlock_t)); - i_ringSection = (void*)((uint8_t*)ddBlockStart + be32toh(torPpeBlock->offset)); +#ifdef TORV3_SUPPORT + + if (torHeader->version < 5) + { + torPpeBlock = (TorPpeBlock_t*)((uint8_t*)ddBlockStart + i_ppeType * sizeof(TorPpeBlock_t)); + l_ringSection = (void*)((uint8_t*)ddBlockStart + be32toh(torPpeBlock->offset)); + } + else + { +#endif + torPpeBlock = (TorPpeBlock_t*)(postHeaderStart + i_ppeType * sizeof(TorPpeBlock_t)); + l_ringSection = (void*)(postHeaderStart + be32toh(torPpeBlock->offset)); +#ifdef TORV3_SUPPORT + } + +#endif } - rc = get_ring_from_ring_section( i_ringSection, + rc = get_ring_from_ring_section( l_ringSection, i_ringId, i_ringVariant, io_instanceId, @@ -410,8 +436,11 @@ int tor_access_ring( void* i_ringSection, // Ring section ptr return rc; } + +#ifdef TORV3_SUPPORT else if ( i_ringBlockType == GET_DD_LEVEL_RINGS && - torMagic == TOR_MAGIC_HW ) + torMagic == TOR_MAGIC_HW && + torHeader->version < 5 ) { if (io_ringBlockSize >= ddBlockSize) { @@ -438,6 +467,8 @@ int tor_access_ring( void* i_ringSection, // Ring section ptr return TOR_BUFFER_TOO_SMALL; } } + +#endif else if ( i_ringBlockType == GET_PPE_LEVEL_RINGS && torMagic == TOR_MAGIC_HW && (i_ppeType == PT_SBE || i_ppeType == PT_CME || i_ppeType == PT_SGPE) ) @@ -445,14 +476,42 @@ int tor_access_ring( void* i_ringSection, // Ring section ptr TorPpeBlock_t* torPpeBlock; uint32_t ppeSize; - torPpeBlock = (TorPpeBlock_t*)((uint8_t*)ddBlockStart + i_ppeType * sizeof(TorPpeBlock_t)); +#ifdef TORV3_SUPPORT + + if (torHeader->version < 5) + { + torPpeBlock = (TorPpeBlock_t*)((uint8_t*)ddBlockStart + i_ppeType * sizeof(TorPpeBlock_t)); + } + else + { +#endif + torPpeBlock = (TorPpeBlock_t*)(postHeaderStart + i_ppeType * sizeof(TorPpeBlock_t)); +#ifdef TORV3_SUPPORT + } + +#endif ppeSize = be32toh(torPpeBlock->size); if (io_ringBlockSize >= ppeSize) { - memcpy( (uint8_t*)(*io_ringBlockPtr), - (uint8_t*)ddBlockStart + be32toh(torPpeBlock->offset), - ppeSize ); +#ifdef TORV3_SUPPORT + + if (torHeader->version < 5) + { + memcpy( (uint8_t*)(*io_ringBlockPtr), + (uint8_t*)ddBlockStart + be32toh(torPpeBlock->offset), + ppeSize ); + } + else + { +#endif + memcpy( (uint8_t*)(*io_ringBlockPtr), + postHeaderStart + be32toh(torPpeBlock->offset), + ppeSize ); +#ifdef TORV3_SUPPORT + } + +#endif io_ringBlockSize = ppeSize; return TOR_SUCCESS; @@ -572,7 +631,10 @@ int tor_get_block_of_rings ( void* i_ringSection, // Ring section if ( torMagic == TOR_MAGIC_HW && chipType != CT_CEN ) { - if (i_ppeType == NUM_PPE_TYPES) +#ifdef TORV3_SUPPORT + + if ( i_ppeType == NUM_PPE_TYPES && + torHeader->version < 5 ) { // Get DD level block of rings rc = tor_access_ring( i_ringSection, @@ -587,27 +649,28 @@ int tor_get_block_of_rings ( void* i_ringSection, // Ring section i_ringName, i_dbgl ); } - else if (i_ppeType == PT_SBE || i_ppeType == PT_CME || i_ppeType == PT_SGPE) - { - // Get block of rings specific to a PPE type - rc = tor_access_ring( i_ringSection, - UNDEFINED_RING_ID, - i_ddLevel, - i_ppeType, - i_ringVariant, - l_instanceId, - GET_PPE_LEVEL_RINGS, - io_ringBlockPtr, - io_ringBlockSize, - i_ringName, - i_dbgl ); - - } else - { - MY_ERR("tor_get_block_of_rings(): Ambiguous API parameters\n"); - return TOR_AMBIGUOUS_API_PARMS; - } +#endif + if (i_ppeType == PT_SBE || i_ppeType == PT_CME || i_ppeType == PT_SGPE) + { + // Get specific PPE block of rings + rc = tor_access_ring( i_ringSection, + UNDEFINED_RING_ID, + i_ddLevel, + i_ppeType, + i_ringVariant, + l_instanceId, + GET_PPE_LEVEL_RINGS, + io_ringBlockPtr, + io_ringBlockSize, + i_ringName, + i_dbgl ); + } + else + { + MY_ERR("tor_get_block_of_rings(): Ambiguous API parameters\n"); + return TOR_AMBIGUOUS_API_PARMS; + } } else { diff --git a/src/import/chips/p9/utils/imageProcs/p9_tor.H b/src/import/chips/p9/utils/imageProcs/p9_tor.H index 12817067..45bf83f6 100644 --- a/src/import/chips/p9/utils/imageProcs/p9_tor.H +++ b/src/import/chips/p9/utils/imageProcs/p9_tor.H @@ -30,10 +30,12 @@ // Different options to extract data using tor_access_ring API typedef enum RingBlockType { - GET_SINGLE_RING = 0x00, - GET_DD_LEVEL_RINGS = 0x01, - GET_PPE_LEVEL_RINGS = 0x02, - PUT_SINGLE_RING = 0x03 + GET_SINGLE_RING = 0x00, +#ifdef TORV3_SUPPORT + GET_DD_LEVEL_RINGS = 0x01, +#endif + GET_PPE_LEVEL_RINGS = 0x02, + PUT_SINGLE_RING = 0x03 } RingBlockType_t; /// @@ -67,7 +69,6 @@ typedef enum RingBlockType /// \param[in] i_RingVariant A enum to indicate type of operation performed /// by TOR API Option: /// GET_SINGLE_RING indicates to extract single ring container. -/// GET_DD_LEVEL_RINGS indicates to extract specific DD level TOR and rings /// GET_PPE_LEVEL_RINGS indcates to extract specific PPE level TOR and rings /// PUT_SINGLE_RING indicates to extract ring absolute memory addres for /// ringTorSlot location @@ -97,13 +98,6 @@ typedef enum RingBlockType /// \a io_ringBlockPtr contains RS4 container \a io_ringBlockSize contains size /// of data copied into io_ringBlockPtr. \a o_ringName returns ring string name. /// -/// GET_DD_LEVEL_RINGS (\a i_ringVariant) - traverse on \a i_ringSection -/// buffer based on \a i_ddLevel which gives dd spec (used only for HW image -/// /optional for other image) On return, \a io_ringBlockPtr contains DD level -/// specific ring section and \a io_ringBlockSize contains size of the data -/// copied into io_ringBlockPtr. \a Other params are optional. -/// This ringVariant works on HW image. -/// /// GET_PPE_LEVEL_RINGS (\a i_ringVariant) - traverse on \a i_ringSection /// buffer based on \a i_ppeType which gives ppe type info and \a i_ddLevel which /// gives dd spec used only for HW image/optional for other image) On return, diff --git a/src/import/chips/p9/xip/Makefile b/src/import/chips/p9/xip/Makefile index 6a5204db..b663367f 100644 --- a/src/import/chips/p9/xip/Makefile +++ b/src/import/chips/p9/xip/Makefile @@ -5,7 +5,7 @@ # # OpenPOWER sbe Project # -# Contributors Listed Below - COPYRIGHT 2015,2017 +# Contributors Listed Below - COPYRIGHT 2015,2018 # [+] International Business Machines Corp. # # @@ -36,6 +36,7 @@ INCLUDES += -I. INCLUDES += -I../../../hwpf/fapi2/include/plat INCLUDES += -I../utils/imageProcs INCLUDES += -I../../common/utils/imageProcs +INCLUDES += -I../../p9/utils/imageProcs ifeq ($(PROJECT_NAME),sbe) XIP_FLAGS+=-D__PPE__ @@ -69,13 +70,16 @@ all: $(OBJ_DIR) $(XIP_EXECUTABLES) $(OBJ_DIR): mkdir -p $(OBJ_DIR) +$(OBJ_DIR)/%.o: $(IMAGEPROCS_P9_SRCDIR)/%.c + $(CXX) $(CXX_FLAGS) $(INCLUDES) $(XIP_FLAGS) -c -o $@ $< + $(OBJ_DIR)/%.o: %.c $(CXX) $(CXX_FLAGS) $(INCLUDES) $(XIP_FLAGS) -c -o $@ $< $(OBJ_DIR)/%.o: %.C $(CXX) $(CXX_FLAGS) $(INCLUDES) $(XIP_FLAGS) -c -o $@ $< -$(OBJ_DIR)/p9_xip_tool: $(OBJ_DIR)/p9_xip_image.o $(OBJ_DIR)/p9_xip_tool.o +$(OBJ_DIR)/p9_xip_tool: $(OBJ_DIR)/p9_xip_image.o $(OBJ_DIR)/p9_xip_tool.o $(OBJ_DIR)/p9_dd_container.o $(CXX) -o $@ $^ clean: diff --git a/src/import/chips/p9/xip/p9_xip_image.C b/src/import/chips/p9/xip/p9_xip_image.C index 874c0417..c7e493c8 100644 --- a/src/import/chips/p9/xip/p9_xip_image.C +++ b/src/import/chips/p9/xip/p9_xip_image.C @@ -45,12 +45,10 @@ #include <stdint.h> #include <endian.h> #endif -#ifndef __PPE__ - #include "p9_dd_container.h" -#endif #include <stdlib.h> #include <string.h> #include "p9_xip_image.h" +#include "p9_dd_container.h" //////////////////////////////////////////////////////////////////////////// // Local Functions @@ -164,7 +162,7 @@ dumpSectionTable(const void* i_image) for (i = 0; i < P9_XIP_SECTIONS; i++) { - rc = p9_xip_get_section(i_image, i, §ion); + rc = p9_xip_get_section(i_image, i, §ion, UNDEFINED_DD_LEVEL); if (rc) { @@ -615,7 +613,7 @@ xipImage2Section(const void* i_image, for (sectionId = 0; sectionId < P9_XIP_SECTIONS; sectionId++) { - rc = p9_xip_get_section(i_image, sectionId, §ion); + rc = p9_xip_get_section(i_image, sectionId, §ion, UNDEFINED_DD_LEVEL); if (rc) { @@ -687,7 +685,7 @@ xipDeleteLastSection(void* io_image, break; } - rc = p9_xip_get_section(io_image, final, §ion); + rc = p9_xip_get_section(io_image, final, §ion, UNDEFINED_DD_LEVEL); if (rc) { @@ -720,7 +718,7 @@ p9_xip_get_toc(void* i_image, do { - rc = p9_xip_get_section(i_image, P9_XIP_SECTION_TOC, &tocSection); + rc = p9_xip_get_section(i_image, P9_XIP_SECTION_TOC, &tocSection, UNDEFINED_DD_LEVEL); if (rc) { @@ -728,7 +726,7 @@ p9_xip_get_toc(void* i_image, } rc = p9_xip_get_section(i_image, P9_XIP_SECTION_STRINGS, - &stringsSection); + &stringsSection, UNDEFINED_DD_LEVEL); if (rc) { @@ -1174,7 +1172,7 @@ xipDecodeToc(void* i_image, o_item->iv_type = hostToc.iv_type; o_item->iv_elements = hostToc.iv_elements; - p9_xip_get_section(i_image, P9_XIP_SECTION_STRINGS, &stringsSection); + p9_xip_get_section(i_image, P9_XIP_SECTION_STRINGS, &stringsSection, UNDEFINED_DD_LEVEL); o_item->iv_id = (char*)i_image + stringsSection.iv_offset + hostToc.iv_id; @@ -1184,7 +1182,7 @@ xipDecodeToc(void* i_image, // even though the section has been removed from the image, so this // case needs to be covered. - rc = p9_xip_get_section(i_image, hostToc.iv_section, &dataSection); + rc = p9_xip_get_section(i_image, hostToc.iv_section, &dataSection, UNDEFINED_DD_LEVEL); if (rc) { @@ -1237,7 +1235,7 @@ p9_xip_decode_toc_dump(void* i_image, void* i_dump, o_item->iv_type = hostToc.iv_type; o_item->iv_elements = hostToc.iv_elements; - p9_xip_get_section(i_image, P9_XIP_SECTION_STRINGS, &stringsSection); + p9_xip_get_section(i_image, P9_XIP_SECTION_STRINGS, &stringsSection, UNDEFINED_DD_LEVEL); o_item->iv_id = (char*)i_image + stringsSection.iv_offset + hostToc.iv_id; @@ -1355,7 +1353,7 @@ xipGetFixedToc(void* io_image, int rc; P9XipSection section; - rc = p9_xip_get_section(io_image, P9_XIP_SECTION_FIXED_TOC, §ion); + rc = p9_xip_get_section(io_image, P9_XIP_SECTION_FIXED_TOC, §ion, UNDEFINED_DD_LEVEL); if (!rc) { @@ -1429,7 +1427,7 @@ xipFixedFind(void* i_image, const char* i_id, P9XipItem* o_item) o_item->iv_type = toc->iv_type; o_item->iv_elements = toc->iv_elements; - rc = p9_xip_get_section(i_image, P9_XIP_SECTION_FIXED, &fixedSection); + rc = p9_xip_get_section(i_image, P9_XIP_SECTION_FIXED, &fixedSection, UNDEFINED_DD_LEVEL); if (rc) { @@ -1541,7 +1539,7 @@ xipHeaderFind(void* i_image, const char* i_id, P9XipItem* o_item) o_item->iv_elements = 1; /* True for now... */ rc = p9_xip_get_section(i_image, P9_XIP_SECTION_HEADER, - &headerSection); + &headerSection, UNDEFINED_DD_LEVEL); if (rc) { @@ -1982,7 +1980,7 @@ p9_xip_normalize(void* io_image) for (i = 0; i < P9_XIP_SECTIONS; i++) { - rc = p9_xip_get_section(io_image, i, §ion); + rc = p9_xip_get_section(io_image, i, §ion, UNDEFINED_DD_LEVEL); if (rc) { @@ -2025,27 +2023,6 @@ p9_xip_image_size(void* io_image, uint32_t* o_size) } -#if defined(__PPE__) -int -p9_xip_get_section(const void* i_image, - const int i_sectionId, - P9XipSection* o_hostSection) -{ - int rc; - P9XipSection* imageSection; - - rc = xipGetSectionPointer(i_image, i_sectionId, &imageSection); - - if (!rc) - { - xipTranslateSection(o_hostSection, imageSection); - } - - return rc; -} - -#else - int p9_xip_get_section(const void* i_image, const int i_sectionId, @@ -2117,7 +2094,6 @@ p9_xip_get_section(const void* i_image, return rc; } -#endif // If the 'big' TOC is not present, search the mini-TOCs that only index the @@ -2623,7 +2599,7 @@ p9_xip_delete_section(void* io_image, // the final section of the image. Update the sizes and re-establish // the final image alignment. - rc = p9_xip_get_section(io_image, i_sectionId, §ion); + rc = p9_xip_get_section(io_image, i_sectionId, §ion, UNDEFINED_DD_LEVEL); if (rc) { @@ -2722,7 +2698,7 @@ p9_xip_delete_section(void* io_image, { orderIdx--; - rc = p9_xip_get_section(o_imageBuf, sectionOrder[orderIdx], §ion); + rc = p9_xip_get_section(o_imageBuf, sectionOrder[orderIdx], §ion, UNDEFINED_DD_LEVEL); if (rc) { @@ -2788,7 +2764,7 @@ p9_xip_duplicate_section(const void* i_image, break; } - rc = p9_xip_get_section(i_image, i_sectionId, §ion); + rc = p9_xip_get_section(i_image, i_sectionId, §ion, UNDEFINED_DD_LEVEL); if (rc) { @@ -2865,7 +2841,7 @@ p9_xip_append(void* io_image, break; } - rc = p9_xip_get_section(io_image, i_sectionId, §ion); + rc = p9_xip_get_section(io_image, i_sectionId, §ion, UNDEFINED_DD_LEVEL); if (rc) { @@ -3016,7 +2992,7 @@ p9_xip_section2image(const void* i_image, break; } - rc = p9_xip_get_section(i_image, i_sectionId, §ion); + rc = p9_xip_get_section(i_image, i_sectionId, §ion, UNDEFINED_DD_LEVEL); if (rc) { @@ -3257,33 +3233,28 @@ p9_xip_map_toc(void* io_image, } -#if !defined(__PPE__) // // Inform caller if specified sectionId has DD support // int p9_xip_dd_section_support(const void* i_image, const int i_sectionId, - bool& o_bDdSupport) + myBoolean_t* o_bDdSupport) { int rc; P9XipSection section; - rc = p9_xip_get_section(i_image, i_sectionId, §ion); + rc = p9_xip_get_section(i_image, i_sectionId, §ion, UNDEFINED_DD_LEVEL); if (!rc) { - if (section.iv_ddSupport == 0 || section.iv_ddSupport == 1) - { - o_bDdSupport = (bool)section.iv_ddSupport; - } - else + *o_bDdSupport = (myBoolean_t)section.iv_ddSupport; + + if (section.iv_ddSupport != true && section.iv_ddSupport != false) { // iv_ddSupport is uninitialized or corrupted - o_bDdSupport = false; rc = P9_XIP_IMAGE_ERROR; } } return rc; } -#endif diff --git a/src/import/chips/p9/xip/p9_xip_image.h b/src/import/chips/p9/xip/p9_xip_image.h index a78befa1..9b139b98 100644 --- a/src/import/chips/p9/xip/p9_xip_image.h +++ b/src/import/chips/p9/xip/p9_xip_image.h @@ -707,10 +707,10 @@ p9_xip_image_size(void* i_image, uint32_t* o_size); int p9_xip_get_section(const void* i_image, const int i_sectionId, + P9XipSection* o_hostSection, #if defined(__PPE__) - P9XipSection* o_hostSection); + uint8_t i_ddLevel); #else - P9XipSection* o_hostSection, uint8_t i_ddLevel=UNDEFINED_DD_LEVEL); #endif @@ -1388,12 +1388,10 @@ p9_xip_get_toc(void* i_image, /// \retval 0 Success /// /// \retval non-0 See \ref p9_xip_image_errors -#if !defined(__PPE__) int p9_xip_dd_section_support(const void* i_image, const int i_sectionId, - bool& o_bDdSupport); -#endif + myBoolean_t* o_bDdSupport); /// \brief Decode a TOC entry from dump file diff --git a/src/import/chips/p9/xip/p9_xip_tool.C b/src/import/chips/p9/xip/p9_xip_tool.C index 48749db3..935867fe 100644 --- a/src/import/chips/p9/xip/p9_xip_tool.C +++ b/src/import/chips/p9/xip/p9_xip_tool.C @@ -576,7 +576,14 @@ dumpHeader(void* i_image, image_section_type_t i_imageSectionType) printf("Chip type : 0x%02x \"%s\"\n", torHeader->chipType, CHIP_TYPE_LIST[torHeader->chipType].name); printf("DD level : 0x%02x\n", torHeader->ddLevel); - printf("Number DD levels : %d\n", torHeader->numDdLevels); +#ifdef TORV3_SUPPORT + + if (torHeader->version < 5) + { + fprintf(stdout, "Number DD levels : %d\n", torHeader->numDdLevels); + } + +#endif printf("Image size : 0x%08x (%d)\n", be32toh(torHeader->size), be32toh(torHeader->size)); @@ -1408,11 +1415,7 @@ extract(const char* i_imageFile, const int i_imageFd, void* io_image, // return a list of supported DD levels. } -#ifdef __PPE__ - rc = p9_xip_get_section( io_image, sectionId, &xDdSection); -#else rc = p9_xip_get_section( io_image, sectionId, &xDdSection, ddLevel); -#endif switch (rc) { @@ -1776,7 +1779,7 @@ TEST(void* io_image, const int i_argc, const char** i_argv) // Try p9_xip_get_section against the translated header p9_xip_translate_header(&header, (P9XipHeader*)io_image); - rc = p9_xip_get_section(io_image, P9_XIP_SECTION_TOC, §ion); + rc = p9_xip_get_section(io_image, P9_XIP_SECTION_TOC, §ion, UNDEFINED_DD_LEVEL); BOMB_IF_RC; BOMB_IF((section.iv_size != header.iv_section[P9_XIP_SECTION_TOC].iv_size)); @@ -1885,15 +1888,18 @@ int dissectRingSectionTor( uint8_t* i_ringSection, RingId_t numRingIds = 0; uint32_t torMagic = 0xffffffff; // Undefined value ChipType_t chipType = UNDEFINED_CHIP_TYPE; +#ifdef TORV3_SUPPORT uint32_t numDdLevels = 0; // Undefined value - uint8_t iDdLevel, ddLevel = UNDEFINED_DD_LEVEL; +#endif + uint8_t iDdLevel; + uint8_t ddLevel = UNDEFINED_DD_LEVEL; PpeType_t ppeType; RingId_t ringId; RingVariant_t ringVariant; uint8_t instanceId; void* ringBlockPtr; uint32_t ringBlockSize; - char ringName[50]; + char ringName[MAX_RING_NAME_LENGTH]; uint32_t ringSeqNo = 0; // Ring sequence number CompressedScanData* rs4 = NULL; CompressedScanData* rs4ForDisplay = NULL; @@ -1912,15 +1918,37 @@ int dissectRingSectionTor( uint8_t* i_ringSection, uint8_t cmskRingIteration = 0; char ringSuffix = ' '; - TorHeader_t* torHeader = reinterpret_cast<TorHeader_t*>(i_ringSection); // // Get TOR header fields // + TorHeader_t* torHeader = reinterpret_cast<TorHeader_t*>(i_ringSection); torMagic = be32toh(torHeader->magic); chipType = torHeader->chipType; ddLevel = torHeader->ddLevel; - numDdLevels = torHeader->numDdLevels; + +#ifdef TORV3_SUPPORT + TorDdBlock_t* torDdBlock = NULL; + + if (torMagic == TOR_MAGIC_HW) + { + if (torHeader->version < 5) + { + numDdLevels = torHeader->numDdLevels; + // move past the tor header to the tor blocks + torDdBlock = reinterpret_cast<TorDdBlock_t*>(i_ringSection + sizeof(TorHeader_t)); + } + else + { + numDdLevels = 1; + } + } + else + { + numDdLevels = 1; + } + +#endif // // Make some ChipType specific data translations @@ -1997,21 +2025,24 @@ int dissectRingSectionTor( uint8_t* i_ringSection, bool bRingsFound = true; bool bPrintHeader = true; - // Needed if TOR_MAGIC_HW - TorDdBlock_t* torDdBlock = reinterpret_cast<TorDdBlock_t*>(i_ringSection + sizeof(TorHeader_t)); - +#ifdef TORV3_SUPPORT //---------------- // DD level loop. for (iDdLevel = 0; iDdLevel < numDdLevels; iDdLevel++) { - if (torMagic == TOR_MAGIC_HW) + if ( torMagic == TOR_MAGIC_HW && torHeader->version < 5 ) { ddLevel = torDdBlock->ddLevel; //point to the next DD block torDdBlock++; } + else + { + ddLevel = torHeader->ddLevel; + } +#endif // assume no rings will be found so on the next loop so we can print // the info bRingsFound = false; @@ -2347,8 +2378,12 @@ int dissectRingSectionTor( uint8_t* i_ringSection, fprintf(stdout, "No rings for DD level: 0x%x\n", ddLevel); } +#ifdef TORV3_SUPPORT + } // End of for(iDdLevel) +#endif + if (i_listingModeId == LMID_TABLE) { fprintf(stdout, "------------------------------------------------------------------------------\n"); @@ -2397,7 +2432,7 @@ dissectRingSection(void* i_image, P9XipHeader hostHeader; P9XipSection hostSection; image_section_type_t l_imageSectionType = IST_UNDEFINED; - bool bEcLvlSupported = false; + myBoolean_t bEcLvlSupported = UNDEFINED_BOOLEAN; void* ringSection = NULL; std::vector<void*>ringSectionPtrs; @@ -2494,7 +2529,13 @@ dissectRingSection(void* i_image, // Determine if XIP section has DD support // - rc = p9_xip_dd_section_support( i_image, sectionId, bEcLvlSupported ); + rc = p9_xip_dd_section_support( i_image, sectionId, &bEcLvlSupported ); + + if (rc) + { + fprintf(stderr, "p9_xip_dd_section_support() failed w/rc=0x%08x (1)\n", (uint32_t)rc ); + exit(EXIT_FAILURE); + } if( bEcLvlSupported ) { @@ -2814,9 +2855,34 @@ int check_sbe_ring_section_size( void* i_hwImage, void** l_blockPtr = NULL; uint32_t l_blockSize = 0; + myBoolean_t l_bDdSupport = UNDEFINED_BOOLEAN; + + // Determine if there's rings dd support + rc = p9_xip_dd_section_support(i_hwImage, P9_XIP_SECTION_HW_RINGS, &l_bDdSupport); + + if (rc) + { + fprintf(stderr, "p9_xip_dd_section_support() failed w/rc=0x%08x (2)\n", (uint32_t)rc ); + return rc; + } - // Get the full .rings section from the HW image - rc = p9_xip_get_section(i_hwImage, P9_XIP_SECTION_HW_RINGS, &l_ringsSection); + if (l_bDdSupport) + { + rc = p9_xip_get_section(i_hwImage, P9_XIP_SECTION_HW_RINGS, &l_ringsSection, i_ddLevel); + + if (rc) + { + fprintf(stderr, "ERROR: p9_xip_get_section() failed w/rc=0x%x while getting " + "DD (=0x%x) specific ring section.\n", + (uint32_t)rc, i_ddLevel); + exit (EXIT_FAILURE); + } + } + else + { + // Get the full .rings section from the HW image + rc = p9_xip_get_section(i_hwImage, P9_XIP_SECTION_HW_RINGS, &l_ringsSection); + } if (!rc) { diff --git a/src/import/tools/imageProcs/p9_ipl_build.C b/src/import/tools/imageProcs/p9_ipl_build.C index 48d277a1..7e742ddc 100644 --- a/src/import/tools/imageProcs/p9_ipl_build.C +++ b/src/import/tools/imageProcs/p9_ipl_build.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER sbe Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2016,2017 */ +/* Contributors Listed Below - COPYRIGHT 2016,2018 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -74,83 +74,105 @@ int get_dd_level_rings_from_hw_image( char* i_hwImage, P9XipSection l_ringsSection; *o_ringBlock = NULL; o_blockSize = 0; + myBoolean_t l_bDdSupport = UNDEFINED_BOOLEAN; - // Get the block of rings from the HW image - rc = p9_xip_get_section(i_hwImage, P9_XIP_SECTION_HW_RINGS, &l_ringsSection); + // Determine if there's rings dd support + rc = p9_xip_dd_section_support(i_hwImage, P9_XIP_SECTION_HW_RINGS, &l_bDdSupport); if (rc) { - MY_ERR("Call to p9_xip_get_section ID(%d) failed rc=%d\n", P9_XIP_SECTION_HW_RINGS, rc); - rc = IMGBUILD_ERR_GET_SECTION; + MY_ERR("p9_xip_dd_section_support() failed w/rc=0x%08x.\n", (uint32_t)rc ); + rc = IMGBUILD_ERR_XIP_DD_SUPPORT; + return rc; } - else + + if (l_bDdSupport) { - // Check if any content in .rings - if (l_ringsSection.iv_size == 0) + rc = p9_xip_get_section(i_hwImage, P9_XIP_SECTION_HW_RINGS, &l_ringsSection, i_ddLevel); + + if (rc) { - MY_ERR("Ring section size in HW image is zero. No TOR. We need rings here.\n"); - rc = IMGBUILD_EMPTY_RING_SECTION; + MY_ERR("ERROR: error getting dd (=%x) specific ring section w/rc=0x%08x.\n", + i_ddLevel, (uint32_t)rc); + rc = IMGBUILD_ERR_XIP_GET_SECTION; return rc; } + } + else + { + // Get the block of rings from the HW image + rc = p9_xip_get_section(i_hwImage, P9_XIP_SECTION_HW_RINGS, &l_ringsSection); - // Make a pointer to the start of the rings section - void* ringsSection = i_hwImage + l_ringsSection.iv_offset; - - do + if (rc) { + MY_ERR("Call to p9_xip_get_section ID(%d) failed rc=%d\n", P9_XIP_SECTION_HW_RINGS, rc); + rc = IMGBUILD_ERR_XIP_GET_SECTION; + return rc; + } + } - // Call the first time to get a size of the pending section - rc = tor_get_block_of_rings( ringsSection, - i_ddLevel, - PT_SBE, - NOT_VALID, - o_ringBlock, - o_blockSize ); + // Check if any content in .rings + if (l_ringsSection.iv_size == 0) + { + MY_ERR("Ring section size in HW image is zero. No TOR. We need rings here.\n"); + rc = IMGBUILD_EMPTY_RING_SECTION; + return rc; + } - if(rc) - { - MY_ERR("error calling tor API rc = %d\n", rc); - rc = IMGBUILD_ERR_SECTION_SIZING; - break; - } + // Make a pointer to the start of the rings section + void* ringsSection = i_hwImage + l_ringsSection.iv_offset; - if( o_blockSize == 0 ) - { - rc = IMGBUILD_NO_RINGS_FOUND; - MY_INF("No rings for dd_level %#02x found\n", i_ddLevel); - break; - } + // Call the first time to get a size of the pending section + rc = tor_get_block_of_rings( ringsSection, + i_ddLevel, + PT_SBE, + NOT_VALID, + o_ringBlock, + o_blockSize ); - // *o_ringBlock is freed by caller - *o_ringBlock = malloc(o_blockSize); + if(rc) + { + MY_ERR("error calling tor API rc = %d\n", rc); + rc = IMGBUILD_ERR_SECTION_SIZING; + return rc; + } - if (o_ringBlock != NULL) - { - rc = tor_get_block_of_rings( ringsSection, - i_ddLevel, - PT_SBE, - NOT_VALID, - o_ringBlock, - o_blockSize ); - - if(rc) - { - MY_ERR("error calling tor API rc = %d\n", rc); - rc = IMGBUILD_ERR_RING_SEARCH; - } - } - else - { - MY_ERR("failed to allocate memory for ring block\n"); - rc = IMGBUILD_ERR_MEMORY; - } + if( o_blockSize == 0 ) + { + rc = IMGBUILD_NO_RINGS_FOUND; + MY_INF("No rings for dd_level %#02x found\n", i_ddLevel); + return rc; + } - MY_DBG("o_blockSize = %d\n", o_blockSize); - MY_DBG("o_ringBlock = %p\n", o_ringBlock); + // *o_ringBlock is freed by caller of this function + *o_ringBlock = malloc(o_blockSize); + if (*o_ringBlock != NULL) + { + rc = tor_get_block_of_rings( ringsSection, + i_ddLevel, + PT_SBE, + NOT_VALID, + o_ringBlock, + o_blockSize ); + + if(rc) + { + MY_ERR("error calling tor API rc = %d\n", rc); + free(*o_ringBlock); + rc = IMGBUILD_ERR_RING_SEARCH; + return rc; } - while(0); } + else + { + MY_ERR("failed to allocate memory for ring block\n"); + rc = IMGBUILD_ERR_MEMORY; + return rc; + } + + MY_DBG("o_blockSize = %d\n", o_blockSize); + MY_DBG("*o_ringBlock = %p\n", *o_ringBlock); return rc; }; @@ -192,7 +214,7 @@ int append_ring_block_to_image( char* io_sbeImage, if(rc) { MY_ERR("error appending ring section = %d\n", rc); - rc = IMGBUILD_ERR_APPEND; + rc = IMGBUILD_ERR_XIP_APPEND; } MY_DBG("i_ringBlock = %p\n", i_ringBlock); @@ -261,7 +283,7 @@ int ipl_build( char* i_fnSbeImage, if(rc) { MY_ERR("The SBE image failed validation w/rc = %d", rc); - rc = IMGBUILD_INVALID_IMAGE; + rc = IMGBUILD_XIP_INVALID_IMAGE; break; } @@ -394,7 +416,7 @@ int main( int argc, char* argv[]) if (rc) { MY_ERR("p9_xip_validate() of HW image failed: rc=%d\n", rc); - rc = IMGBUILD_INVALID_IMAGE; + rc = IMGBUILD_XIP_INVALID_IMAGE; break; } diff --git a/src/import/tools/imageProcs/p9_ipl_build.H b/src/import/tools/imageProcs/p9_ipl_build.H index 3d67c4b7..3f251673 100644 --- a/src/import/tools/imageProcs/p9_ipl_build.H +++ b/src/import/tools/imageProcs/p9_ipl_build.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER sbe Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2016 */ +/* Contributors Listed Below - COPYRIGHT 2016,2018 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -34,10 +34,11 @@ #define IMGBUILD_NO_RINGS_FOUND 5 // Successful img build but no rings found. #define IMGBUILD_EMPTY_RING_SECTION 6 // Successful img build but empty ring section. #define IMGBUILD_ERR_MEMORY 7 // Memory allocation error. -#define IMGBUILD_INVALID_IMAGE 10 // Invalid image. +#define IMGBUILD_XIP_INVALID_IMAGE 10 // Invalid image. #define IMGBUILD_ERR_RING_SEARCH 33 // Err assoc w/ring retrieval. -#define IMGBUILD_ERR_GET_SECTION 49 // Err assoc w/getting section ID. +#define IMGBUILD_ERR_XIP_GET_SECTION 49 // Err assoc w/getting section ID. #define IMGBUILD_ERR_SECTION_SIZING 48 // Err assoc w/section sizing. -#define IMGBUILD_ERR_APPEND 51 // Err assoc w/appending to ELF section. +#define IMGBUILD_ERR_XIP_APPEND 51 // Err assoc w/appending to XIP section. +#define IMGBUILD_ERR_XIP_DD_SUPPORT 52 // Err assoc w/getting dd section ID. #endif diff --git a/src/tools/image/Makefile b/src/tools/image/Makefile index 11a7ba30..1385d20b 100644 --- a/src/tools/image/Makefile +++ b/src/tools/image/Makefile @@ -5,7 +5,7 @@ # # OpenPOWER sbe Project # -# Contributors Listed Below - COPYRIGHT 2015,2017 +# Contributors Listed Below - COPYRIGHT 2015,2018 # [+] International Business Machines Corp. # # @@ -65,10 +65,13 @@ utilities: $(IMG_DIR)/sbe_default_tool CXXFLAGS+=-DFAPI2_NO_FFDC +$(BASE_OBJDIR)/tools/image/%.o: $(IMAGEPROCS_P9_SRCDIR)/%.c + $(CXX) $(INCLUDES) $(CXXFLAGS) -c -o $@ $< + $(BASE_OBJDIR)/tools/image/%.o: %.c $(CXX) $(INCLUDES) $(CXXFLAGS) -c -o $@ $< -$(IMG_DIR)/sbe_default_tool: $(P9_XIP_BINDIR)/p9_xip_image.o $(BASE_OBJDIR)/tools/image/sbe_default_tool.o +$(IMG_DIR)/sbe_default_tool: $(P9_XIP_BINDIR)/p9_xip_image.o $(BASE_OBJDIR)/tools/image/sbe_default_tool.o $(BASE_OBJDIR)/tools/image/p9_dd_container.o $(CXX) $(CXXFLAGS) ${INCLUDES} -o $@ $^ clean: diff --git a/src/tools/iplbuild/Makefile b/src/tools/iplbuild/Makefile index 40581605..d96ffaff 100644 --- a/src/tools/iplbuild/Makefile +++ b/src/tools/iplbuild/Makefile @@ -5,7 +5,7 @@ # # OpenPOWER sbe Project # -# Contributors Listed Below - COPYRIGHT 2015,2017 +# Contributors Listed Below - COPYRIGHT 2015,2018 # [+] International Business Machines Corp. # # @@ -55,6 +55,7 @@ OBJS = $(P9_XIP_BINDIR)/p9_xip_image.o \ $(BASE_OBJDIR)/tools/iplbuild/cen_ringId.o \ $(BASE_OBJDIR)/tools/iplbuild/p9_tor.o \ $(BASE_OBJDIR)/tools/iplbuild/p9_ipl_build.o \ + $(BASE_OBJDIR)/tools/iplbuild/p9_dd_container.o \ all:objdir utilities @@ -66,7 +67,10 @@ utilities: $(IMG_DIR)/p9_ipl_build CXXFLAGS =-DFAPI2_NO_FFDC $(P9_XIP_BINDIR)/%.o: %.c - $(CXX) $(INCLUDES) $(CXXFLAGS) -c -o $@ $< + $(CXX) $(INCLUDES) $(CXXFLAGS) -c -o $@ $< + +$(BASE_OBJDIR)/tools/iplbuild/%.o: $(IMAGEPROCS_P9_SRCDIR)/%.c + $(CXX) $(INCLUDES) $(CXXFLAGS) -c -o $@ $< $(BASE_OBJDIR)/tools/iplbuild/%.o: %.C $(CXX) $(INCLUDES) $(CXXFLAGS) -c -o $@ $< |