diff options
-rw-r--r-- | hwpf/plat/include/fapi2.H | 1 | ||||
-rw-r--r-- | hwpf/plat/include/fapi2_target.H | 118 | ||||
-rw-r--r-- | hwpf/plat/include/plat_target.H | 4 | ||||
-rw-r--r-- | hwpf/plat/include/plat_target_parms.H | 42 | ||||
-rw-r--r-- | hwpf/plat/include/plat_target_utils.H | 48 | ||||
-rw-r--r-- | hwpf/plat/include/target.H | 190 | ||||
-rw-r--r-- | hwpf/plat/include/target_types.H | 66 | ||||
-rw-r--r-- | hwpf/plat/src/fapi2ppefiles.mk | 8 | ||||
-rw-r--r-- | hwpf/plat/src/target.C | 142 | ||||
-rw-r--r-- | importtemp/xml/attribute_info/perv_attributes.xml | 658 | ||||
-rw-r--r-- | importtemp/xml/p9_ppe_attributes.xml | 189 | ||||
-rw-r--r-- | sbe/image/Makefile | 25 | ||||
-rw-r--r-- | sbe/image/img_defs.mk | 5 | ||||
-rw-r--r-- | sbe/image/sbe_main.C | 364 | ||||
-rw-r--r-- | sbe/image/sbe_xip_image.c | 156 | ||||
-rw-r--r-- | sbe/image/topfiles.mk | 4 | ||||
-rw-r--r-- | tools/image/sbe_xip_tool.c | 876 | ||||
-rwxr-xr-x | tools/scripts/ppeParseAttributeInfo.pl | 26 | ||||
-rwxr-xr-x | tools/scripts/ppeParseProcSbeFixed.pl | 2 |
19 files changed, 2282 insertions, 642 deletions
diff --git a/hwpf/plat/include/fapi2.H b/hwpf/plat/include/fapi2.H index a3dd4fbe..178860fc 100644 --- a/hwpf/plat/include/fapi2.H +++ b/hwpf/plat/include/fapi2.H @@ -32,6 +32,7 @@ #include <error_scope.H> #include <set_sbe_error.H> // Generated file #include <plat_attributes.H> +#include <plat_target_utils.H> #include <hwp_executor.H> diff --git a/hwpf/plat/include/fapi2_target.H b/hwpf/plat/include/fapi2_target.H index 5c753e9e..47b6d55a 100644 --- a/hwpf/plat/include/fapi2_target.H +++ b/hwpf/plat/include/fapi2_target.H @@ -14,6 +14,13 @@ namespace fapi2 { + + + /// + /// @brief Typedef for chiplet number values + /// + typedef uint8_t ChipletNumber_t; + /// /// @brief Class representing a FAPI2 Target /// @tparam K the type (Kind) of target @@ -153,31 +160,6 @@ namespace fapi2 return iv_type; } -#ifdef __PPE__ - - /// Need to optimize PPE Target resoulution in a cheap manner - /// Brian: not sure if the this is the place for this as - /// this is plaform specific. - - /// - /// @brief Get address overlay to reduce runtime processing - /// @return Overlay as a type V - /// - inline V getAddressOverlay(void) const - { - return this->iv_handle.fields.address_overlay; - } - - /// - /// @brief Get address overlay to reduce runtime processing - /// @return Overlay as a type V - /// - inline uint32_t getTargetNumber(void) const - { - return static_cast<uint32_t>(this->iv_handle.fields.type_target_num); - } -#endif - /// /// @brief Get this target's immediate parent /// @tparam T The type of the parent @@ -266,6 +248,90 @@ namespace fapi2 "unable to cast to specialized Target"); } +#ifdef __PPE__ + + /// + /// @brief Get the target present setting + /// @return Bool whether present + /// + inline bool getPresent(void) const + { + return (this->iv_handle.fields.present ? true : false); + } + + /// + /// @brief Get the target functional setting + /// @return Bool whether functional + /// + inline bool getFunctional(void) const + { + return (this->iv_handle.fields.functional ? true : false); + } + + /// + /// @brief Set the target present setting + /// @return Bool whether present + /// + inline void setPresent(void) const + { + this->iv_handle.fields.present = 1; + return; + } + + /// + /// @brief Set the target functional setting + /// @return Bool whether functional + /// + inline void setFunctional(void) const + { + this->iv_handle.fields.functional = 1; + return; + } + + + /// Need to optimize PPE Target resoulution in a cheap manner + /// Brian: not sure if the this is the place for this as + /// this is plaform specific. + + /// + /// @brief Get address overlay to reduce runtime processing + /// @return Overlay as a type V + /// + inline V getAddressOverlay(void) const + { + return this->iv_handle.fields.address_overlay; + } + + /// + /// @brief Get target number + /// @return Overlay as a type V + /// + inline uint32_t getTargetNumber(void) const + { + return static_cast<uint32_t>(this->iv_handle.fields.type_target_num); + } + + /// + /// @brief Get target type directly from the handle + /// @return Overlay as a type V + /// + inline TargetTypes_t getTargetType(void) const + { + return static_cast<TargetTypes_t>(this->iv_handle.fields.type); + } + + /// + /// @brief Get chiplet number from the handle + /// @return ChipletNumber_t Chiplet Number + /// + inline ChipletNumber_t getChipletNumber(void) const + { + return static_cast<ChipletNumber_t>(this->iv_handle.fields.chiplet_num); + } + +#endif + + private: // Don't use enums here as it makes it hard to assign // in the platform target cast constructor. @@ -296,7 +362,7 @@ namespace fapi2 // iv_handle(V i_value = 0):value(i_value) {} } iv_handle; }; - + // EX threads map to CORE threads: // t0 / t2 / t4 / t6 fused = t0 / t1 / t2 / t3 normal (c0) // t1 / t3 / t5 / t7 fused = t0 / t1 / t2 / t3 normal (c1) diff --git a/hwpf/plat/include/plat_target.H b/hwpf/plat/include/plat_target.H index 86c70465..1e6a5b70 100644 --- a/hwpf/plat/include/plat_target.H +++ b/hwpf/plat/include/plat_target.H @@ -30,6 +30,8 @@ #ifndef __FAPI2_PLAT_TARGET__ #define __FAPI2_PLAT_TARGET__ +#include <return_code.H> + // // Define what a platform handle looks like. For Hostboot, // for example, this might be a void*. For the SBE, this @@ -38,6 +40,6 @@ namespace fapi2 { typedef uint64_t plat_target_handle_t; -} +} #endif diff --git a/hwpf/plat/include/plat_target_parms.H b/hwpf/plat/include/plat_target_parms.H index 6056dcf5..bbe4b8ba 100644 --- a/hwpf/plat/include/plat_target_parms.H +++ b/hwpf/plat/include/plat_target_parms.H @@ -32,30 +32,40 @@ #include "fapi_sbe_common.H" -CONST_UINT64_T(CHIPLET_COUNT, 0x38); -CONST_UINT64_T(CHIP_TARGET_COUNT , 1); -CONST_UINT64_T(CHIP_TARGET_OFFSET, 0); +CONST_UINT32_T(CHIP_TARGET_OFFSET, 0); +CONST_UINT32_T(CHIP_TARGET_COUNT , 1); -CONST_UINT64_T(PERV_TARGET_OFFSET, CHIP_TARGET_OFFSET + CHIP_TARGET_COUNT); -CONST_UINT64_T(PERV_CHIPLET_OFFSET, 0x1); -CONST_UINT64_T(PERV_TARGET_COUNT, 15); -CONST_UINT64_T(EQ_TARGET_OFFSET, PERV_TARGET_OFFSET + PERV_TARGET_COUNT); -CONST_UINT64_T( EQ_CHIPLET_OFFSET, 0x10); -CONST_UINT64_T(EQ_TARGET_COUNT, 6); +CONST_UINT32_T(PERV_TARGET_OFFSET, CHIP_TARGET_OFFSET + CHIP_TARGET_COUNT); +CONST_UINT32_T(PERV_CHIPLET_OFFSET, 0x1); +CONST_UINT32_T(PERV_TARGET_COUNT, 15); -CONST_UINT64_T( CORE_TARGET_OFFSET, EQ_TARGET_OFFSET + EQ_TARGET_COUNT); -CONST_UINT64_T( CORE_CHIPLET_OFFSET, 0x20); -CONST_UINT64_T(CORE_TARGET_COUNT, 24); +CONST_UINT32_T(EQ_TARGET_OFFSET, PERV_TARGET_OFFSET + PERV_TARGET_COUNT); +CONST_UINT32_T(EQ_CHIPLET_OFFSET, 0x10); +CONST_UINT32_T(EQ_TARGET_COUNT, 6); -CONST_UINT64_T( EX_TARGET_OFFSET, CORE_TARGET_OFFSET + CORE_TARGET_COUNT); -CONST_UINT64_T( EX_CHIPLET_OFFSET, 0x10); -CONST_UINT64_T(EX_TARGET_COUNT, 12); +CONST_UINT32_T(CORE_TARGET_OFFSET, EQ_TARGET_OFFSET + EQ_TARGET_COUNT); +CONST_UINT32_T(CORE_CHIPLET_OFFSET, 0x20); +CONST_UINT32_T(CORE_TARGET_COUNT, 24); +CONST_UINT32_T(MCS_TARGET_OFFSET, CORE_TARGET_OFFSET + CORE_TARGET_COUNT); +CONST_UINT32_T(MCS_CHIPLET_OFFSET, 0x7); +CONST_UINT32_T(MCS_TARGET_COUNT, 2); -CONST_UINT64_T(TARGET_COUNT, EX_TARGET_OFFSET + EX_TARGET_COUNT); +CONST_UINT32_T(EX_TARGET_OFFSET, MCS_TARGET_OFFSET + MCS_TARGET_COUNT); +CONST_UINT32_T(EX_CHIPLET_OFFSET, 0x10); +CONST_UINT32_T(EX_TARGET_COUNT, 12); +//CONST_UINT32_T(TARGET_COUNT, EX_TARGET_OFFSET + EX_TARGET_COUNT); + +CONST_UINT32_T(TARGET_COUNT, CHIP_TARGET_COUNT + + PERV_TARGET_COUNT + + EQ_TARGET_COUNT + + CORE_TARGET_COUNT + + MCS_TARGET_COUNT + + EX_TARGET_COUNT); + #endif // __FAPI2_PPE_TARGET_PARMS__ diff --git a/hwpf/plat/include/plat_target_utils.H b/hwpf/plat/include/plat_target_utils.H new file mode 100644 index 00000000..e1e360c0 --- /dev/null +++ b/hwpf/plat/include/plat_target_utils.H @@ -0,0 +1,48 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2012,2014 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +/** + * @file plat_target_util.H + * @brief platform utility definitions for fapi2 targets + */ + +#ifndef __FAPI2_PLAT_TARGET_UTIL__ +#define __FAPI2_PLAT_TARGET_UTIL__ + +// +// Platform Utility functions.. +// +namespace fapi2 +{ + + /// @brief Function to initialize the G_targets vector based on partial good + /// attributes + ReturnCode plat_TargetsInit(); + + /// @brief Function to initialize the G_targets vector based on partial good + /// attributes + Target<TARGET_TYPE_PROC_CHIP> plat_getChipTarget(); + +} +#endif diff --git a/hwpf/plat/include/target.H b/hwpf/plat/include/target.H index e2fe550b..cce4e86e 100644 --- a/hwpf/plat/include/target.H +++ b/hwpf/plat/include/target.H @@ -33,11 +33,19 @@ #include <plat_target.H> #include <plat_target_parms.H> #include <fapi2_target.H> +#include <plat_trace.H> #include <utils.H> #include <stdio.h> +#include <stdint.h> +#include <vector> + +extern "C" +{ + extern std::vector<fapi2::plat_target_handle_t> G_vec_targets; +} namespace fapi2 -{ +{ /// @brief Create a Target, with a value /// @param[in] Value the value (i.e., specific element this /// target represents, or pointer) @@ -51,20 +59,20 @@ namespace fapi2 static_assert( ((K == TARGET_TYPE_CORE) & (K == TARGET_TYPE_EQ) ) != true, "TARGET_TYPE_CORE and TARGET_TYPE_EQ cannot be specified at the same time"); - + this->iv_handle.value = 0; if(K & TARGET_TYPE_PROC_CHIP) { - this->iv_handle.fields.chiplet_num = Value; + this->iv_handle.fields.chiplet_num = 0; this->iv_handle.fields.type = TARGET_TYPE_PROC_CHIP; - this->iv_handle.fields.type_target_num = Value; // TODO: check this + this->iv_handle.fields.type_target_num = 0; } if(K & TARGET_TYPE_PERV) { this->iv_handle.fields.chiplet_num = Value; - this->iv_handle.fields.type = TARGET_TYPE_PERV | TARGET_TYPE_PROC_CHIP; - this->iv_handle.fields.type_target_num = Value; // TODO: check this + this->iv_handle.fields.type = TARGET_TYPE_PERV; + this->iv_handle.fields.type_target_num = Value; } if(K & TARGET_TYPE_CORE) @@ -77,89 +85,97 @@ namespace fapi2 } */ this->iv_handle.fields.chiplet_num = Value + CORE_CHIPLET_OFFSET; - this->iv_handle.fields.type = TARGET_TYPE_CORE; - this->iv_handle.fields.type_target_num = Value; + this->iv_handle.fields.type = TARGET_TYPE_CORE | TARGET_TYPE_PERV; + this->iv_handle.fields.type_target_num = Value; } if(K & TARGET_TYPE_EQ) { this->iv_handle.fields.chiplet_num = Value + EQ_CHIPLET_OFFSET; - this->iv_handle.fields.type = TARGET_TYPE_EQ; - this->iv_handle.fields.type_target_num = Value; + this->iv_handle.fields.type = TARGET_TYPE_EQ | TARGET_TYPE_PERV; + this->iv_handle.fields.type_target_num = Value; } - + if(K & TARGET_TYPE_EX) - { - - this->iv_handle.fields.chiplet_num = (Value / 2) + EX_CHIPLET_OFFSET; - this->iv_handle.fields.type = TARGET_TYPE_EX; + { + + this->iv_handle.fields.chiplet_num = (Value / 2) + EX_CHIPLET_OFFSET; + this->iv_handle.fields.type = TARGET_TYPE_EX | TARGET_TYPE_PERV; this->iv_handle.fields.type_target_num = Value; - this->iv_handle.fields.present = 1; } - + + if(K & TARGET_TYPE_MCS) + { + + this->iv_handle.fields.chiplet_num = Value + MCS_CHIPLET_OFFSET; + this->iv_handle.fields.type = TARGET_TYPE_MCS | TARGET_TYPE_PERV; + this->iv_handle.fields.type_target_num = Value; + } + // if(K & TARGET_TYPE_EQ_MC_WRITE) // { -// this->iv_handle.fields.chiplet_num = -// (((MC_ENABLE) | +// this->iv_handle.fields.chiplet_num = +// (((MC_ENABLE) | // ((MC_WRITE << 3) | (Value & 0x07))) & // BITS(57,7)); // this->iv_handle.fields.type = TARGET_TYPE_EQ_MC_WRITE; // } -// +// // if(K & TARGET_TYPE_EQ_MC_READOR) // { -// this->iv_handle.fields.chiplet_num = -// (((MC_ENABLE) | +// this->iv_handle.fields.chiplet_num = +// (((MC_ENABLE) | // ((MC_READ_OR << 3) | (Value & 0x07))) & // BITS(57,7)); // this->iv_handle.fields.type = TARGET_TYPE_EQ_MC_READOR; // } -// +// // if(K & TARGET_TYPE_EQ_MC_READAND) // { -// this->iv_handle.fields.chiplet_num = -// (((MC_ENABLE) | +// this->iv_handle.fields.chiplet_num = +// (((MC_ENABLE) | // ((MC_READ_AND << 3) | (Value & 0x07))) & // BITS(57,7)); -// this->iv_handle.fields.type = TARGET_TYPE_EQ_MC_READAND; +// this->iv_handle.fields.type = TARGET_TYPE_EQ_MC_READAND; // } -// +// // if(K & TARGET_TYPE_CORE_MC_WRITE) // { -// this->iv_handle.fields.chiplet_num = -// (((MC_ENABLE) | +// this->iv_handle.fields.chiplet_num = +// (((MC_ENABLE) | // ((MC_WRITE << 3) | (Value & 0x07))) & // BITS(57,7)); // this->iv_handle.fields.type = TARGET_TYPE_CORE_MC_WRITE; // } -// +// // if(K & TARGET_TYPE_CORE_MC_READOR) // { -// this->iv_handle.fields.chiplet_num = -// (((MC_ENABLE) | +// this->iv_handle.fields.chiplet_num = +// (((MC_ENABLE) | // ((MC_READ_OR << 3) | (Value & 0x07))) & // BITS(57,7)); // this->iv_handle.fields.type = TARGET_TYPE_CORE_MC_READOR; // } -// +// // if(K & TARGET_TYPE_CORE_MC_READAND) // { -// this->iv_handle.fields.chiplet_num = -// (((MC_ENABLE) | +// this->iv_handle.fields.chiplet_num = +// (((MC_ENABLE) | // ((MC_READ_AND << 3) | (Value & 0x07))) & // BITS(57,7)); // this->iv_handle.fields.type = TARGET_TYPE_CORE_MC_READAND; // } - + if(K == TARGET_TYPE_ALL) { this->iv_handle.fields.chiplet_num = Value; this->iv_handle.fields.type = TARGET_TYPE_ALL; - } + } this->iv_handle.fields.present = 1; - this->iv_handle.fields.address_overlay = - this->iv_handle.fields.chiplet_num << 24; - + this->iv_handle.fields.functional = 1; + this->iv_handle.fields.address_overlay = + (this->iv_handle.fields.chiplet_num << 24); + } /// @@ -172,7 +188,7 @@ namespace fapi2 { this->iv_handle.value = i_right->iv_handle.value; return *this; - } + } /// /// @brief Equality Comparison Operator /// @param[in] i_right Reference to Target to compare. @@ -231,10 +247,94 @@ namespace fapi2 inline std::vector<Target<T> > Target<K, V>::getChildren(const TargetState i_state) const { - // To keep the compiler quiet about unused variables - static_cast<void>(i_state); - // For testing - return {Target<T>(), Target<T>()}; +#define INVALID_CHILD(PARENT, CHILD) \ + static_assert(!((K == PARENT) && (T == CHILD)), \ + #CHILD " is not a child of " #PARENT ); + + // invalid children for proc +// INVALID_CHILD(fapi2::TARGET_TYPE_PROC_CHIP, fapi2::TARGET_TYPE_NONE) +// INVALID_CHILD(fapi2::TARGET_TYPE_PROC_CHIP, fapi2::TARGET_TYPE_SYSTEM) +// INVALID_CHILD(fapi2::TARGET_TYPE_PROC_CHIP, fapi2::TARGET_TYPE_DIMM) +// INVALID_CHILD(fapi2::TARGET_TYPE_PROC_CHIP, fapi2::TARGET_TYPE_PROC_CHIP) +// INVALID_CHILD(fapi2::TARGET_TYPE_PROC_CHIP, fapi2::TARGET_TYPE_MEMBUF_CHIP) +// INVALID_CHILD(fapi2::TARGET_TYPE_PROC_CHIP, fapi2::TARGET_TYPE_MBA) +#undef INVALID_CHILD + +#define INVALID_PARENT(PARENT) \ + static_assert(!((K == PARENT)), \ + #PARENT "is not supported on PPE platforms"); + + // invalid parents +// INVALID_PARENT(fapi2::TARGET_TYPE_SYSTEM) +// INVALID_PARENT(fapi2::TARGET_TYPE_MEMBUF_CHIP) +// INVALID_PARENT(fapi2::TARGET_TYPE_L4) +// INVALID_PARENT(fapi2::TARGET_TYPE_DIMM) +// INVALID_PARENT(fapi2::TARGET_TYPE_MCA) +// INVALID_PARENT(fapi2::TARGET_TYPE_MBA) +// INVALID_PARENT(fapi2::TARGET_TYPE_MI) +// INVALID_PARENT(fapi2::TARGET_TYPE_MCBIST) +// INVALID_PARENT(fapi2::TARGET_TYPE_DMI) +#undef INVALID_PARENT + + // valid children for EQ + // EQ -> CORE + // EQ -> EX + static_assert(!((K == fapi2::TARGET_TYPE_EQ) && + (T != fapi2::TARGET_TYPE_CORE) && + (T != fapi2::TARGET_TYPE_EX)), + "improper child of fapi2::TARGET_TYPE_EQ"); + + // valid children for EX + // EX -> CORE + static_assert(!((K == fapi2::TARGET_TYPE_EX) && + (T != fapi2::TARGET_TYPE_CORE)), + "improper child of fapi2::TARGET_TYPE_EX"); + + // Nimbus Memory + // valid children for MCS + // MCS -> MCA +// static_assert(!((K == fapi2::TARGET_TYPE_MCS) && +// (T != fapi2::TARGET_TYPE_MCA)), +// "improper child of fapi2::TARGET_TYPE_MCS"); + + + std::vector<fapi2::plat_target_handle_t>::iterator l_iter; + FAPI_DBG("getChildren: initializing children vector"); + std::vector<Target<T> > l_children; + + + + uint32_t c = 0; + for (l_iter = G_vec_targets.begin(); l_iter != G_vec_targets.end(); ++l_iter) + { + + Target<T> * l_temp = reinterpret_cast< Target<T>* >(l_iter); + if (((*l_temp).getTargetType() & T) == T) + { + switch (i_state) + { + case TARGET_STATE_PRESENT: + if ((*l_temp).getPresent()) + { + l_children.push_back((*l_temp)); +// FAPI_DBG("Pushing getChildren present 0x%08X", (uint32_t)(((*l_temp)).get()>>32)); + } + break; + case TARGET_STATE_FUNCTIONAL: + if ((*l_temp).getFunctional()) + { + l_children.push_back((*l_temp)); +// FAPI_DBG("Pushing getChildren functional 0x%08X", (uint32_t)(((*l_temp)).get()>>32)); + } + break; + default: + FAPI_ERR("Coming error ASSERT for illegal i_state = %u", i_state); + } + } + ++c; + } + + return l_children; } /// diff --git a/hwpf/plat/include/target_types.H b/hwpf/plat/include/target_types.H index 4db4cf26..352e4732 100644 --- a/hwpf/plat/include/target_types.H +++ b/hwpf/plat/include/target_types.H @@ -57,50 +57,34 @@ namespace fapi2 TARGET_TYPE_MCAST = 0x80, ///< Multicast type TARGET_TYPE_ALL = 0xFF, ///< Any/All types - - -// TARGET_TYPE_NONE = 0x00000000, ///< No type -// TARGET_TYPE_SYSTEM = 0x00000001, ///< System type -// TARGET_TYPE_DIMM = 0x00000002, ///< DIMM type -// TARGET_TYPE_PROC_CHIP = 0x00000004, ///< Processor type -// TARGET_TYPE_MEMBUF_CHIP = 0x00000008, ///< Membuf type -// TARGET_TYPE_EX = 0x00000010, ///< Ex type -// TARGET_TYPE_MBA = 0x00000020, ///< MBA type -// TARGET_TYPE_MCS = 0x00000040, ///< MCS type -// TARGET_TYPE_XBUS = 0x00000080, ///< XBUS type -// TARGET_TYPE_ABUS = 0x00000100, ///< ABUS type -// TARGET_TYPE_L4 = 0x00000200, ///< L4 type -// TARGET_TYPE_CORE = 0x00000400, ///< Core type -// TARGET_TYPE_EQ = 0x00000800, ///< EQ type -// TARGET_TYPE_MCA = 0x00001000, ///< MCA type -// TARGET_TYPE_MCBIST = 0x00002000, ///< MCBIST type -// TARGET_TYPE_MIA = 0x00004000, ///< MIA type -// TARGET_TYPE_MIS = 0x00008000, ///< MIS type -// TARGET_TYPE_DMI = 0x00010000, ///< DMI type -// TARGET_TYPE_OBUS = 0x00020000, ///< OBUS type -// TARGET_TYPE_NV = 0x00040000, ///< NV bus type -// TARGET_TYPE_SBE = 0x00080000, ///< SBE type -// TARGET_TYPE_PPE = 0x00100000, ///< PPE type -// TARGET_TYPE_PERV = 0x00200000, ///< Pervasive type -// TARGET_TYPE_PEC = 0x00400000, ///< PEC type -// TARGET_TYPE_PHB = 0x00800000, ///< PHB type -// TARGET_TYPE_EQ_MC_WRITE = 0x01000000, ///< EQ Multicast Type -// TARGET_TYPE_EQ_MC_READAND = 0x02000000, ///< EQ Multicast Read AND Type -// TARGET_TYPE_EQ_MC_READOR = 0x04000000, ///< EQ Multicast Read OR Type -// TARGET_TYPE_CORE_MC_WRITE = 0x08000000, ///< Core Multicast Type -// TARGET_TYPE_CORE_MC_READAND = 0x10000000, ///< Core Multicast Read AND Type -// TARGET_TYPE_CORE_MC_READOR = 0x20000000, ///< Core Multicast Read OR Type -// TARGET_TYPE_CME_CORE0 = 0x40000000, ///< CME Core0 (CME only) -// TARGET_TYPE_CME_CORE1 = 0x80000000, ///< CME Core1 (CME only) -// TARGET_TYPE_ADDRESS = 0xAAAAAAAA, ///< Address Overlay Type -// TARGET_TYPE_ALL = 0xFFFFFFFF, ///< Any/All types + + // The following are actually illegal targets on PPE platforms +// TARGET_TYPE_SYSTEM = 0xFE, ///< System type +// TARGET_TYPE_DIMM = 0xFD, ///< DIMM type +// TARGET_TYPE_MEMBUF_CHIP = 0xFC, ///< Membuf type +// TARGET_TYPE_MBA = 0xFB, ///< MBA type +// TARGET_TYPE_XBUS = 0xFA, ///< XBUS type +// TARGET_TYPE_ABUS = 0xF9, ///< ABUS type +// TARGET_TYPE_L4 = 0xF8, ///< L4 type +// TARGET_TYPE_MCA = 0xF7, ///< MCA type +// TARGET_TYPE_MCBIST = 0xF6, ///< MCBIST type +// TARGET_TYPE_MIA = 0xF5, ///< MIA type +// TARGET_TYPE_MIS = 0xF4, ///< MIS type +// TARGET_TYPE_DMI = 0xF3, ///< DMI type +// TARGET_TYPE_OBUS = 0xF2, ///< OBUS type +// TARGET_TYPE_NV = 0xF1, ///< NV bus type +// TARGET_TYPE_SBE = 0xF0, ///< SBE type +// TARGET_TYPE_PPE = 0xEF, ///< PPE type +// TARGET_TYPE_PEC = 0xEE, ///< PEC type +// TARGET_TYPE_PHB = 0xED, ///< PHB type +// TARGET_TYPE_MI = 0xEC, ///< MI type // Mappings to target types found in the error xml files TARGET_TYPE_EX_CHIPLET = TARGET_TYPE_EX, -// TARGET_TYPE_MBA_CHIPLET = TARGET_TYPE_MBA, -// TARGET_TYPE_MCS_CHIPLET = TARGET_TYPE_MCS, -// TARGET_TYPE_XBUS_ENDPOINT = TARGET_TYPE_XBUS, -// TARGET_TYPE_ABUS_ENDPOINT = TARGET_TYPE_ABUS, +// TARGET_TYPE_MBA_CHIPLET = TARGET_TYPE_MBA, + TARGET_TYPE_MCS_CHIPLET = TARGET_TYPE_MCS, +// TARGET_TYPE_XBUS_ENDPOINT = TARGET_TYPE_XBUS, +// TARGET_TYPE_ABUS_ENDPOINT = TARGET_TYPE_ABUS, }; /// diff --git a/hwpf/plat/src/fapi2ppefiles.mk b/hwpf/plat/src/fapi2ppefiles.mk index 1f913872..f2e72670 100644 --- a/hwpf/plat/src/fapi2ppefiles.mk +++ b/hwpf/plat/src/fapi2ppefiles.mk @@ -18,11 +18,13 @@ ########################################################################## -FAPI2-C-SOURCES += fapi2PlatAttributeService.C -FAPI2-C-SOURCES += plat_utils.C +FAPI2-CPP-SOURCES += fapi2PlatAttributeService.C +FAPI2-CPP-SOURCES += target.C +FAPI2-CPP-SOURCES += plat_utils.C FAPI2-S-SOURCES = -FAPI2LIB_OBJECTS += $(FAPI2-C-SOURCES:.C=.o) $(FAPI2-S-SOURCES:.S=.o) +FAPI2LIB_OBJECTS += $(FAPI2-CPP-SOURCES:.C=.o) +FAPI2LIB_OBJECTS += $(FAPI2-S-SOURCES:.S=.o) diff --git a/hwpf/plat/src/target.C b/hwpf/plat/src/target.C index fc5f4392..4b422f3c 100644 --- a/hwpf/plat/src/target.C +++ b/hwpf/plat/src/target.C @@ -24,12 +24,150 @@ /* IBM_PROLOG_END_TAG */ #include <target.H> +#include <new> +#include <utility> // For move +// Global Vector containing ALL targets. This structure is referenced by +// fapi2::getChildren to produce the resultant returned vector from that +// call. +std::vector<fapi2::plat_target_handle_t> G_vec_targets; namespace fapi2 { - std::vector Target::getChildren(void) const -}; + #ifndef __noRC__ + ReturnCode current_err; + #endif + + /// @brief Function to initialize the G_targets vector based on partial good + /// attributes /// this will move to plat_target.H formally + fapi2::ReturnCode plat_TargetsInit() + { + + // This is workaround. Currently we do not have code to initialise + // global objects. So initializing global objects against using local + // initialized object + std::vector<fapi2::plat_target_handle_t> targets1; + G_vec_targets = std::move(targets1); + std::vector<fapi2::plat_target_handle_t>::iterator tgt_iter; + uint32_t l_beginning_offset; + + FAPI_DBG("Platform target initialization. Target Count = %u", TARGET_COUNT); + // Initialize all entries to NULL + for (uint32_t i = 0; i < TARGET_COUNT; ++i) + { + G_vec_targets.push_back((fapi2::plat_target_handle_t)0x0); + FAPI_DBG("Nulling G_vec_targets[%u] hi value=0x%08X", + i, (uint32_t)(G_vec_targets.at(i)>>32)); + // FAPI_DBG("Nulling G_vec_targets[%u] lo value=0x%08X", + // i, (uint32_t)(G_vec_targets.at(i)&0x00000000ffffffffull)); + } + FAPI_DBG("Vector size: %u", G_vec_targets.size()); + + // Chip Target is the first one + FAPI_DBG("Chip Target info: CHIP_TARGET_OFFSET %u CHIP_TARGET_COUNT %u ", + CHIP_TARGET_OFFSET,CHIP_TARGET_COUNT); + + + l_beginning_offset = CHIP_TARGET_OFFSET; + FAPI_DBG("Chip beginning offset =%u", l_beginning_offset); + for (uint32_t i = 0; i < CHIP_TARGET_COUNT; ++i) + { + fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> target_name((fapi2::plat_target_handle_t)i); + G_vec_targets.at(l_beginning_offset+i) = revle64((fapi2::plat_target_handle_t)(target_name.get())); + // FAPI_DBG("Chip Target initialization: %u G_vec_targets[%u] value=0x%08X", + // i, + // (l_beginning_offset+i), + // (uint32_t)(G_vec_targets.at(l_beginning_offset+i)>>32)); + } + + // Chip Level Pervasive Targets + FAPI_DBG("Pervasive Target info: PERV_TARGET_OFFSET %u PERV_TARGET_COUNT %u", + PERV_TARGET_OFFSET, PERV_TARGET_COUNT); + + l_beginning_offset = PERV_TARGET_OFFSET; + FAPI_DBG("Perv beginning offset =%u", l_beginning_offset); + for (uint32_t i = 0; i < PERV_TARGET_COUNT; ++i) + { + fapi2::Target<fapi2::TARGET_TYPE_PERV> target_name((fapi2::plat_target_handle_t)i); + FAPI_DBG("target_name hi word = 0x%08X", (uint32_t)(target_name.get()>>32)); + + G_vec_targets.at(l_beginning_offset+i) = revle64((fapi2::plat_target_handle_t)(target_name.get())); + // FAPI_DBG("Pervasive Target initialization: %u G_vec_targets[%u] value=0x%08X", + // i, + // (l_beginning_offset+i), + // (uint32_t)(G_vec_targets.at(l_beginning_offset+i)>>32)); + } + // Cache (EQ) Targets + FAPI_DBG("EQ Target info: EQ_TARGET_OFFSET %u EQ_TARGET_COUNT %u", + EQ_TARGET_OFFSET, EQ_TARGET_COUNT); + l_beginning_offset = EQ_TARGET_OFFSET; + FAPI_DBG("EQ beginning offset =%u", l_beginning_offset); + for (uint32_t i = 0; i < EQ_TARGET_COUNT; ++i) + { + fapi2::Target<fapi2::TARGET_TYPE_EQ> target_name((fapi2::plat_target_handle_t)i); + FAPI_DBG("target_name hi word = 0x%08X", (uint32_t)(target_name.get()>>32)); + G_vec_targets.at(l_beginning_offset+i) = revle64((fapi2::plat_target_handle_t)(target_name.get())); + // FAPI_DBG("EQ Target initialization: %u G_vec_targets[%u] value=%16llX", + // i, + // (l_beginning_offset+i), + // revle64((uint64_t)G_vec_targets[l_beginning_offset+i])); + } + // Core (EC) Targets + FAPI_DBG("Core Target info: CORE_TARGET_OFFSET %u CORE_TARGET_COUNT %u", + CORE_TARGET_OFFSET, CORE_TARGET_COUNT); + + l_beginning_offset = CORE_TARGET_OFFSET; + FAPI_DBG("Core beginning offset =%u", l_beginning_offset); + for (uint32_t i = 0; i < CORE_TARGET_COUNT; ++i) + { + fapi2::Target<fapi2::TARGET_TYPE_CORE> target_name((fapi2::plat_target_handle_t)i); + FAPI_DBG("target_name hi word = 0x%08X", (uint32_t)(target_name.get()>>32)); + G_vec_targets.at(l_beginning_offset+i) = revle64((fapi2::plat_target_handle_t)(target_name.get())); + // FAPI_DBG("Core Target initialization: %u G_vec_targets[%u] value=0x%08X", + // i, + // (l_beginning_offset+i), + // (uint32_t)(G_vec_targets.at(l_beginning_offset+i)>>32)); + } + + // Memroy Controller Synchronous (MCS) Targets + FAPI_DBG("MCS Target info: MCS_TARGET_OFFSET %u MCS_TARGET_COUNT %u", + MCS_TARGET_OFFSET, MCS_TARGET_COUNT); + + l_beginning_offset = MCS_TARGET_OFFSET; + FAPI_DBG("MCS beginning offset =%u", l_beginning_offset); + for (uint32_t i = 0; i < MCS_TARGET_COUNT; ++i) + { + fapi2::Target<fapi2::TARGET_TYPE_MCS> target_name((fapi2::plat_target_handle_t)i); + FAPI_DBG("target_name hi word = 0x%08X", (uint32_t)(target_name.get()>>32)); + G_vec_targets.at(l_beginning_offset+i) = revle64((fapi2::plat_target_handle_t)(target_name.get())); + // FAPI_DBG("MCS Target initialization: %u G_vec_targets[%u] value=0x%08X", + // i, + // (l_beginning_offset+i), + // (uint32_t)(G_vec_targets.at(l_beginning_offset+i)>>32)); + } + + // Trace all entries + uint32_t c = 0; + for (tgt_iter = G_vec_targets.begin(); tgt_iter != G_vec_targets.end(); ++tgt_iter) + { + FAPI_DBG("Trace hi word G_vec_targets[%u] value=%08X", + c, (uint32_t)((*tgt_iter)>>32)); + ++c; + } + + return fapi2::current_err; + } + + /// @brief Function to initialize the G_targets vector based on partial good + /// attributes + fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> plat_getChipTarget() + { + + // Get the chip specific target + return ((fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>)G_vec_targets.at(0)); + } + +}; diff --git a/importtemp/xml/attribute_info/perv_attributes.xml b/importtemp/xml/attribute_info/perv_attributes.xml index 50c0f835..64638a39 100644 --- a/importtemp/xml/attribute_info/perv_attributes.xml +++ b/importtemp/xml/attribute_info/perv_attributes.xml @@ -41,4 +41,662 @@ <persistRuntime/> </attribute> <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_FSI</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for FSI chiplet. A 0 indicates a GOOD subregion. + bit 4: fsi0 + bit 5: fsi1 + bit 6: fsia + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_PRV</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Pervasive chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: net + bit 6: pib + bit 7: occ + bit 8: anperv + bit 14: pllnest + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_N0</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Nest0 chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: nx + bit 6: cxa0 + bit 7: pbioe0 + bit 8: pbioe1 + bit 9: pbioe2 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_N1</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Nest1 chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: mcd + bit 6: va + bit 7: pbioo0 + bit 8: pbioo1 + bit 9: mcs23 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_N2</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Nest2 chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: cxa1 + bit 6: pcis0 + bit 7: pcis1 + bit 8: pcis2 + bit 9: iopsi + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_N3</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Nest3 chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: pb + bit 6: br + bit 7: npu + bit 8: mm + bit 9: int + bit 10: mcs01 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_XB</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for XBus chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: iox0 + bit 6: iox1 + bit 7: iox2 + bit 8: pbiox0 + bit 9: pbiox1 + bit 10: pbiox2 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_MC01</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for MC01 chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: mca01 + bit 6: iom01 + bit 7: iom23 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_MC23</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for MC23 chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: mca23 + bit 6: iom45 + bit 7: iom67 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_OB0</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for OBus0 chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: pbiooa0 + bit 6: ioo0 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_OB1</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for OBus1 chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: pbiooa1 + bit 6: ioo1 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_OB2</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for OBus2 chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: pbiooa2 + bit 6: ioo2 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_OB3</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for OBus3 chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + pbiooa3 ioo3 + + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_PCI0</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for PCI0 chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: pci00 + bit 6: iopci0 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_PCI1</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for PCI1 chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: pci11 + bit 6: pci12 + bit 7: iopci1 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_PCI2</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for PCI2 chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: pci23 + bit 6: pci24 + bit 7: pci25 + bit 8: iopci2 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EQ0</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for EQ0 chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: eqpb + bit 6: l30 + bit 7: l31 + bit 8: l20 + bit 9: l21 + bit 10: an + bit 13: refr + bit 14: dpll + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EQ1</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for EQ1 chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: eqpb + bit 6: l30 + bit 7: l31 + bit 8: l20 + bit 9: l21 + bit 10: an + bit 13: refr + bit 14: dpll + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EQ2</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for EQ2 chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: eqpb + bit 6: l30 + bit 7: l31 + bit 8: l20 + bit 9: l21 + bit 10: an + bit 13: refr + bit 14: dpll + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EQ3</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for EQ3 chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: eqpb + bit 6: l30 + bit 7: l31 + bit 8: l20 + bit 9: l21 + bit 10: an + bit 13: refr + bit 14: dpll + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EQ4</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for EQ4 chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: eqpb + bit 6: l30 + bit 7: l31 + bit 8: l20 + bit 9: l21 + bit 10: an + bit 13: refr + bit 14: dpll + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EQ5</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for EQ5 chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: eqpb + bit 6: l30 + bit 7: l31 + bit 8: l20 + bit 9: l21 + bit 10: an + bit 13: refr + bit 14: dpll + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EC00</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Core (EC00) chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: c00 + bit 6: c01 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EC01</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Core (EC01) chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: c00 + bit 6: c01 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EC02</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Core (EC02) chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: c00 + bit 6: c01 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EC03</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Core (EC03) chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: c00 + bit 6: c01 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EC04</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Core (EC04) chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: c00 + bit 6: c01 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EC05</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Core (EC05) chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: c00 + bit 6: c01 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EC06</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Core (EC06) chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: c00 + bit 6: c01 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EC07</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Core (EC07) chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: c00 + bit 6: c01 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EC08</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Core (EC08) chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: c00 + bit 6: c01 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EC09</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Core (EC09) chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: c00 + bit 6: c01 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EC10</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Core (EC10) chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: c00 + bit 6: c01 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EC11</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Core (EC11) chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: c00 + bit 6: c01 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EC12</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Core (EC12) chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: c00 + bit 6: c01 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EC13</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Core (EC13) chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: c00 + bit 6: c01 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EC14</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Core (EC14) chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: c00 + bit 6: c01 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EC15</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Core (EC15) chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: c00 + bit 6: c01 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EC16</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Core (EC16) chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: c00 + bit 6: c01 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EC17</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Core (EC17) chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: c00 + bit 6: c01 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EC18</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Core (EC18) chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: c00 + bit 6: c01 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EC19</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Core (EC19) chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: c00 + bit 6: c01 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EC20</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Core (EC20) chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: c00 + bit 6: c01 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EC21</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Core (EC21) chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: c00 + bit 6: c01 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EC22</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Core (EC22) chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: c00 + bit 6: c01 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_PG_EC23</id> + <targetType>TARGET_TYPE_PROC_CHIP</targetType> + <description> + Partial good mask for Core (EC23) chiplet. A 0 indicates a GOOD subregion. + bit 3: vital + bit 4: perv + bit 5: c00 + bit 6: c01 + </description> + <valueType>uint16</valueType> + </attribute> + <!-- ********************************************************************* --> </attributes> diff --git a/importtemp/xml/p9_ppe_attributes.xml b/importtemp/xml/p9_ppe_attributes.xml index 34679d04..7ae5e48e 100644 --- a/importtemp/xml/p9_ppe_attributes.xml +++ b/importtemp/xml/p9_ppe_attributes.xml @@ -1,5 +1,5 @@ -<!-- $Id: p9_ppe_attributes.xml,v 1.11 2013/11/07 21:51:13 rembold Exp $ --> -<!-- p9_ppe_attributes.xml --> +<!-- $Id: p9_ppe_entryibutes.xml,v 1.11 2013/11/07 21:51:13 rembold Exp $ --> +<!-- p9_ppe_entryibutes.xml --> <entries> <!-- ********************************************************************* --> <entry> @@ -90,4 +90,189 @@ <entry> <name>ATTR_DPLL_RING</name> </entry> + <entry> + <name>ATTR_PG_FSI</name> + <value>0xF1FF</value> + </entry> + <entry> + <name>ATTR_PG_PRV</name> + <value>0xF07D</value> + </entry> + <entry> + <name>ATTR_PG_N0</name> + <value>0xF03F</value> + </entry> + <entry> + <name>ATTR_PG_N1</name> + <value>0xF03F</value> + </entry> + <entry> + <name>ATTR_PG_N2</name> + <value>0xF03F</value> + </entry> + <entry> + <name>ATTR_PG_N3</name> + <value>0xF01F</value> + </entry> + <entry> + <name>ATTR_PG_XB</name> + <value>0xF01D</value> + </entry> + <entry> + <name>ATTR_PG_MC01</name> + <value>0xF0FD</value> + </entry> + <entry> + <name>ATTR_PG_MC23</name> + <value>0xF0FD</value> + </entry> + <entry> + <name>ATTR_PG_OB0</name> + <value>0xF1FD</value> + </entry> + <entry> + <name>ATTR_PG_OB1</name> + <value>0xF1FD</value> + </entry> + <entry> + <name>ATTR_PG_OB2</name> + <value>0xF1FD</value> + </entry> + <entry> + <name>ATTR_PG_OB3</name> + <value>0xF1FD</value> + </entry> + <entry> + <name>ATTR_PG_PCI0</name> + <value>0xF1FD</value> + </entry> + <entry> + <name>ATTR_PG_PCI1</name> + <value>0xF0FD</value> + </entry> + <entry> + <name>ATTR_PG_PCI2</name> + <value>0xF07D</value> + </entry> + <entry> + <name>ATTR_PG_EQ0</name> + <value>0xF019</value> + </entry> + <entry> + <name>ATTR_PG_EQ1</name> + <value>0xF019</value> + </entry> + <entry> + <name>ATTR_PG_EQ2</name> + <value>0xF019</value> + </entry> + <entry> + <name>ATTR_PG_EQ3</name> + <value>0xF019</value> + </entry> + <entry> + <name>ATTR_PG_EQ4</name> + <value>0xF019</value> + </entry> + <entry> + <name>ATTR_PG_EQ5</name> + <value>0xF019</value> + </entry> + <entry> + <name>ATTR_PG_EC00</name> + <value>0xF1FF</value> + </entry> + <entry> + <name>ATTR_PG_EC01</name> + <value>0xF1FF</value> + </entry> + <entry> + <name>ATTR_PG_EC02</name> + <value>0xF1FF</value> + </entry> + <entry> + <name>ATTR_PG_EC03</name> + <value>0xF1FF</value> + </entry> + <entry> + <name>ATTR_PG_EC04</name> + <value>0xF1FF</value> + </entry> + <entry> + <name>ATTR_PG_EC05</name> + <value>0xF1FF</value> + </entry> + <entry> + <name>ATTR_PG_EC06</name> + <value>0xF1FF</value> + </entry> + <entry> + <name>ATTR_PG_EC07</name> + <value>0xF1FF</value> + </entry> + <entry> + <name>ATTR_PG_EC08</name> + <value>0xF1FF</value> + </entry> + <entry> + <name>ATTR_PG_EC09</name> + <value>0xF1FF</value> + </entry> + <entry> + <name>ATTR_PG_EC10</name> + <value>0xF1FF</value> + </entry> + + <entry> + <name>ATTR_PG_EC11</name> + <value>0xF1FF</value> + </entry> + <entry> + <name>ATTR_PG_EC12</name> + <value>0xF1FF</value> + </entry> + <entry> + <name>ATTR_PG_EC13</name> + <value>0xF1FF</value> + </entry> + <entry> + <name>ATTR_PG_EC14</name> + <value>0xF1FF</value> + </entry> + <entry> + <name>ATTR_PG_EC15</name> + <value>0xF1FF</value> + </entry> + <entry> + <name>ATTR_PG_EC16</name> + <value>0xF1FF</value> + </entry> + <entry> + <name>ATTR_PG_EC17</name> + <value>0xF1FF</value> + </entry> + <entry> + <name>ATTR_PG_EC18</name> + <value>0xF1FF</value> + </entry> + <entry> + <name>ATTR_PG_EC19</name> + <value>0xF1FF</value> + </entry> + <entry> + <name>ATTR_PG_EC20</name> + <value>0xF1FF</value> + </entry> + <entry> + <name>ATTR_PG_EC21</name> + <value>0xF1FF</value> + </entry> + <entry> + <name>ATTR_PG_EC22</name> + <value>0xF1FF</value> + </entry> + <entry> + <name>ATTR_PG_EC23</name> + <value>0xF1FF</value> + </entry> </entries> diff --git a/sbe/image/Makefile b/sbe/image/Makefile index 9ba3dab7..576602db 100644 --- a/sbe/image/Makefile +++ b/sbe/image/Makefile @@ -30,7 +30,7 @@ LLIBS += -lpk SBEFW_MAKE_DIR := ../sbefw LIB_DIRS += -L$(OBJDIR)/sbefw SBEFWLIB := $(OBJDIR)/sbefw/libsbefw.a -#LLIBS += -lsbefw +LLIBS += -lsbefw SAMPLE_MAKE_DIR := ../sample LIB_DIRS += -L$(OBJDIR)/sample @@ -108,8 +108,6 @@ $(OBJDIR)/$(IMAGE_SEEPROM_NAME).out: $(LINK_OBJS) $(LINK_SCRIPT_SEEPROM) $(LINK_SCRIPT_SEEPROM): linkseeprom.cmd $(CPP) -E -x c++ -P $(DEFS) linkseeprom.cmd -o $(LINK_SCRIPT_SEEPROM) - - #default target is to make a binary pibmem image #This removes all unecessary headers from the ELF executable $(OBJDIR)/$(IMAGE_SBE_NAME).bin $(OBJDIR)/$(IMAGE_SBE_NAME).dis: $(OBJDIR)/$(IMAGE_SBE_NAME).out @@ -118,7 +116,7 @@ $(OBJDIR)/$(IMAGE_SBE_NAME).bin $(OBJDIR)/$(IMAGE_SBE_NAME).dis: $(OBJDIR)/$(IMA #create a linked ELF executable $(OBJDIR)/$(IMAGE_SBE_NAME).out: $(OBJDIR)/base_sbe_fixed.o $(LINK_OBJS) $(LINK_SCRIPT_SBE) - $(LD) -e __system_reset -T$(LINK_SCRIPT_SBE) -Map $(OBJDIR)/$(IMAGE_SBE_NAME).map -Bstatic -o $(OBJDIR)/$(IMAGE_SBE_NAME).out $(LIB_DIRS) $(OBJDIR)/base_sbe_fixed.o --start-group $(SBEFWLIB) $(LLIBS) --end-group + $(LD) -e __system_reset -T$(LINK_SCRIPT_SBE) -Map $(OBJDIR)/$(IMAGE_SBE_NAME).map -Bstatic -o $(OBJDIR)/$(IMAGE_SBE_NAME).out $(LIB_DIRS) $(OBJDIR)/base_sbe_fixed.o --start-group $(LLIBS) --end-group #pass the link command file through the C preprocessor to evaluate macros and remove comments $(LINK_SCRIPT_SBE): linksbe.cmd @@ -144,6 +142,8 @@ $(LINK_SCRIPT_LOADER): linkloader.cmd all: $(OBJDIR)/$(IMAGE_SEEPROM_NAME).bin $(OBJDIR)/$(IMAGE_SBE_NAME).bin $(OBJDIR)/$(IMAGE_LOADER_NAME).bin $(SBE_TOOLS) normalize defaultset $(OBJDIR)/fixed.bin appendbase appendloader +generic: $(OBJDIR)/$(IMAGE_SEEPROM_NAME).bin $(SBE_TOOLS) normalize defaultset $(OBJDIR)/fixed.bin + #Create an obj directory if needed $(LINK_OBJS) $(OBJS) $(OBJS:.o=.d) $(OBJDIR)/base_sbe_fixed.o $(OBJDIR)/base_sbe_fixed.d: | $(OBJDIR) @@ -162,6 +162,8 @@ $(OBJDIR): .PHONY: clean topfixedheaders $(PKLIB) $(P2PLIB) $(PPELIB) $(FAPI2LIB) $(CACHELIB) $(CORELIB) $(PERVLIB) $(NESTLIB) $(HWPLIB) +#errxml: topfixedheaders attrids platattr attrserv + topfixedheaders: $(TOOLS_ATTR_DIR)/ppeParseProcSbeFixed.pl . $(IMPORT_XML_DIR)/p9_ppe_attributes.xml $(ATTRFILES) @@ -183,10 +185,6 @@ $(PKLIB): $(SBEFWLIB): $(MAKE) -I $(IMAGE_SRCDIR) -C $(SBEFW_MAKE_DIR) -f Makefile -sbefw: - $(MAKE) -I $(IMAGE_SRCDIR) -C $(SBEFW_MAKE_DIR) -f Makefile - - #Build the code that is common for all processors (PPEs and 405) $(PPELIB): @echo "Processing ppelibmakefile" @@ -269,15 +267,14 @@ dump: objdump -s $(OBJDIR)/$(IMAGE_SEEPROM_NAME).out > $(IMAGE_SEEPROM_NAME).dump objdump -s $(OBJDIR)/$(IMAGE_SBE_NAME).out > $(IMAGE_SBE_NAME).dump -# load and run the SBE image in a GPE simics environment -runseeprom: $(OBJDIR)/$(IMAGE_SEEPROM_NAME).out +.PHONY : run_spgpe run_pmgpe +# load and run the SBE SeeProm image in a GPE simics environment +run_spgpe: $(OBJDIR)/$(IMAGE_SEEPROM_NAME).out $(SIMICS_WS)/simics \ -e '$$occ_gpe0_binary_to_load=$(OBJDIR)/$(IMAGE_SEEPROM_NAME).out' modelsetup.simics - - -# load and run the SBE image in a GPE simics environment -runsbe: $(OBJDIR)/$(IMAGE_SBE_NAME).out +# load and run the SBE PibMem image in a GPE simics environment +run_pmgpe: $(OBJDIR)/$(IMAGE_NAME).out $(SIMICS_WS)/simics \ -e '$$occ_gpe0_binary_to_load=$(OBJDIR)/$(IMAGE_SBE_NAME).out' modelsetup.simics diff --git a/sbe/image/img_defs.mk b/sbe/image/img_defs.mk index 2a1c4685..640d3be8 100644 --- a/sbe/image/img_defs.mk +++ b/sbe/image/img_defs.mk @@ -36,7 +36,9 @@ IMAGE_SEEPROM_NAME := seeprom_main IMAGE_SBE_NAME := sbe_main IMAGE_LOADER_NAME := loader_main +ifndef PPE_TYPE PPE_TYPE := std +endif ifndef IMAGE_SRCDIR export IMAGE_SRCDIR = $(abspath .) @@ -184,6 +186,8 @@ GCC-DEFS += -D__PK__=1 GCC-DEFS += -D__SBE__=1 GCC-DEFS += -D__PPE__=1 GCC-DEFS += -DFAPI2_NO_FFDC=1 +GCC-DEFS += -DPK_TRACE_SZ=512 + DEFS += $(GCC-DEFS) export LD_LIBRARY_PATH = /afs/awd.austin.ibm.com/proj/p3/cte/tools/gcc405lin/vol1/usr/lib @@ -213,6 +217,7 @@ PIPE-CFLAGS = -pipe -Wa,-m405 GCC-CFLAGS += -Wall -Werror -Wno-unused-label GCC-CFLAGS += -msoft-float -mcpu=405 -mmulhw GCC-CFLAGS += -meabi -msdata=eabi +GCC-CFLAGS += -gpubnames -gdwarf-3 GCC-CFLAGS += -ffreestanding GCC-CFLAGS += -fno-common GCC-CFLAGS += -fno-exceptions diff --git a/sbe/image/sbe_main.C b/sbe/image/sbe_main.C new file mode 100644 index 00000000..3f859e86 --- /dev/null +++ b/sbe/image/sbe_main.C @@ -0,0 +1,364 @@ +//----------------------------------------------------------------------------- +// *! (C) Copyright International Business Machines Corp. 2014 +// *! All Rights Reserved -- Property of IBM +// *! *** IBM Confidential *** +//----------------------------------------------------------------------------- + +/// \file sample_main.c +/// \brief Sample program that creates and starts a thread +/// +/// This file demonstrates how to create a thread and run it. It also provides +/// an example of how to add traces to the code. +#include <fapi2.H> +//#include <p9_sbe_perv.H> + +#include <vector> + + + + +extern "C" +{ + +#include "pk.h" +#include "pk_trace.h" +//#include "pk_trace_wrap.h" +//#include "common_scom_addresses.H" +//#include "p9_sbe_perv.H" +#include "p9_hcd_cache.H" +#include "p9_hcd_core.H" +#include "proc_sbe_fixed.H" +#include "trac_interface.h" + +} + +namespace fapi2attr +{ + +extern ProcChipAttributes_t* G_proc_chip_attributes asm("G_proc_chip_attributes") __attribute__ ((section (".fixed"))); +extern PervAttributes_t* G_perv_attributes asm("G_perv_attributes") __attribute__ ((section (".fixed"))); +extern CoreAttributes_t* G_core_attributes asm("G_core_attributes") __attribute__ ((section (".fixed"))); +extern EQAttributes_t* G_eq_attributes asm("G_eq_attributes") __attribute__ ((section (".fixed"))); +extern EXAttributes_t* G_ex_attributes asm("G_ex_attributes") __attribute__ ((section (".fixed"))); + +} + +extern "C" { + + +#define KERNEL_STACK_SIZE 256 +#define MAIN_THREAD_STACK_SIZE 256 + +// Necessary Kernel Structures +uint8_t G_kernel_stack[KERNEL_STACK_SIZE]; +uint8_t G_main_thread_stack[MAIN_THREAD_STACK_SIZE]; +PkThread G_main_thread; + + +fapi2::ReturnCode +hwp_chip(const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> & i_target); + +fapi2::ReturnCode +hwp_chip2(const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> & i_target); + + +fapi2::ReturnCode +hwp_core(const fapi2::Target<fapi2::TARGET_TYPE_CORE> & i_target); + +fapi2::ReturnCode +hwp_eq(const fapi2::Target<fapi2::TARGET_TYPE_EQ> & i_target); + +fapi2::ReturnCode +hwp_perv(const fapi2::Target<fapi2::TARGET_TYPE_PERV> & i_target); + + +//--------------------------------------------------------------------------- + + +void main_thread(void* arg) +{ + + // This is workaround. Currently we do not have code to initialise + // global objects. So initializing global objects against using local + // initialized object + FAPI_DBG("Workaround temporary allocation of Global Vector"); + std::vector<fapi2::plat_target_handle_t> targets1; + G_vec_targets = std::move(targets1); + + // Intialize the targets + fapi2::plat_TargetsInit(); + + // Get a specific target + fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>chip_target_new = + fapi2::plat_getChipTarget(); + + FAPI_DBG("chip_target_new = 0x%08X", (uint32_t)(chip_target_new.get()>>32)); + + FAPI_TRY(hwp_chip(chip_target_new)); + + FAPI_TRY(hwp_chip2(chip_target_new)); + + /// +#ifndef __noRC__ + // PIB Errors are masked for platforms like SBE where + // explict error code checking is to occur + fapi2::setPIBErrorMask(0b11111111); +#else + // PIB Errors are unmaskd for platforms that desire to take machine + // check interrupts + fapi2::setPIBErrorMask(0b00000000); +#endif + +// FAPI_TRY(hwp_chip(chip_target_new)); + +// FAPI_TRY(p9_sbe_attr_setup(chip_target)); +// FAPI_TRY(p9_sbe_check_master(chip_target)); +// FAPI_TRY(p9_sbe_setup_evid(chip_target)); + + +fapi_try_exit: + return; + +} + +// A Chip try +fapi2::ReturnCode +hwp_chip(const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> & i_target) +{ + + FAPI_DBG("i_target = 0x%08X", (uint32_t)(i_target.get()>>32)); + + auto l_perv_functional_vector = + i_target.getChildren<fapi2::TARGET_TYPE_PERV> + (fapi2::TARGET_STATE_PRESENT); + + // Get the TPChiplet target + uint32_t i = 0; + for (auto it: l_perv_functional_vector) + { + + FAPI_DBG("Perv Functional Target %u value=%08X chiplet %02X", + i, + (uint32_t)(it.get()>>32), + (uint32_t)(it.getChipletNumber())); + + ++i; + } + + auto l_core_functional_vector = + i_target.getChildren<fapi2::TARGET_TYPE_CORE> + (fapi2::TARGET_STATE_PRESENT); + + // Get the Core Chiplet targets + uint32_t j = 0; + for (auto it: l_core_functional_vector) + { + + FAPI_DBG("Core Functional Target %u value=%08X chiplet %02X", + j, + (uint32_t)(it.get()>>32), + (uint32_t)(it.getChipletNumber())); + + ++j; + } + + + fapi2::buffer<uint64_t> data = 0; + const uint32_t address = 0x0006d010; + + FAPI_INF("hwp_chip %u", address); + + uint64_t databuffer; + getscom_abs(address, &databuffer); + + databuffer = 0xDEAD000000000000ull; + + putscom_abs(address, databuffer); + + data = 0xBADC0DE800000000ull; + FAPI_TRY(fapi2::putScom(i_target, address, data)); + + + FAPI_TRY(fapi2::getScom(i_target, address, data)); + FAPI_DBG("First getSCOM: data = %016llX", revle64(data)); + + data.setBit<0, 16>(); + FAPI_TRY(fapi2::putScom(i_target, 0x0006d010, data)); + + return fapi2::FAPI2_RC_SUCCESS; + +fapi_try_exit: + return fapi2::FAPI2_RC_PLAT_ERR_SEE_DATA; +} + +// A Chip try +fapi2::ReturnCode +hwp_chip2(const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> & i_target) +{ + + FAPI_DBG("i_target = 0x%08X", (uint32_t)(i_target.get()>>32)); + + + auto l_eq_functional_vector = + i_target.getChildren<fapi2::TARGET_TYPE_EQ> + (fapi2::TARGET_STATE_PRESENT); + + // Get the EQ Chiplet target + uint32_t k = 0; + for (auto it: l_eq_functional_vector) + { + + FAPI_DBG("EQ Functional Target %u value=%08X chiplet %02X", + k, + (uint32_t)(it.get()>>32), + (uint32_t)(it.getChipletNumber())); + + ++k; + } + + + auto l_mcs_functional_vector = + i_target.getChildren<fapi2::TARGET_TYPE_MCS> + (fapi2::TARGET_STATE_PRESENT); + + // Get the MCS Chiplet target + uint32_t m = 0; + for (auto it: l_mcs_functional_vector) + { + + FAPI_DBG("MCS Functional Target %u value=%08X chiplet %02X", + m, + (uint32_t)(it.get()>>32), + (uint32_t)(it.getChipletNumber())); + + ++m; + } + + + return fapi2::FAPI2_RC_SUCCESS; + +fapi_try_exit: + return fapi2::FAPI2_RC_PLAT_ERR_SEE_DATA; +} + +// A Core try +fapi2::ReturnCode +hwp_core(const fapi2::Target<fapi2::TARGET_TYPE_CORE> & i_target) +{ + + // Temporary target that pulls out only the chiplet overly. This keeps + // from having to compute this for each SCOM operation. +// fapi2::Target<fapi2::TARGET_TYPE_ADDRESS> iv_target (i_target.getAddressOverlay()); + + fapi2::buffer<uint64_t> data = 0; + fapi2::buffer<uint64_t> mask; + + uint32_t address = 0x200F5678; + FAPI_TRY(fapi2::getScom(i_target, address, data)); + + FAPI_TRY(fapi2::putScom(i_target, 0x20006789, data)); + + data = 0xBADC0DEBADC0DEBAull; + FAPI_TRY(fapi2::putScom(i_target, 0x0000AAAA, data)); + + FAPI_TRY(fapi2::getScom(i_target, address, data)); + + FAPI_TRY(fapi2::modifyScom(i_target, address, data, fapi2::CHIP_OP_MODIFY_MODE_OR)); + + + mask = BITS(4,4); + FAPI_TRY(fapi2::putScomUnderMask(i_target, address, data, mask)); + + return fapi2::FAPI2_RC_SUCCESS; + +fapi_try_exit: + + return fapi2::FAPI2_RC_PLAT_ERR_SEE_DATA; +} + +// An EQ try +fapi2::ReturnCode +hwp_eq(const fapi2::Target<fapi2::TARGET_TYPE_EQ> & i_target) +{ + fapi2::buffer<uint64_t> data = 0; + + uint64_t address = 0x1000F2222; + FAPI_TRY(fapi2::getScom(i_target, address, data)); + + + FAPI_TRY(fapi2::putScom(i_target, 0x10006789, data)); + + data = 0xDEADBEEFDEADBEEFull; + FAPI_TRY(fapi2::putScom(i_target, 0x1000ABCD, data)); + + return fapi2::FAPI2_RC_SUCCESS; + +fapi_try_exit: + + return fapi2::FAPI2_RC_PLAT_ERR_SEE_DATA; +} + +// A Perv try +fapi2::ReturnCode +hwp_perv(const fapi2::Target<fapi2::TARGET_TYPE_PERV> & i_target) +{ + fapi2::buffer<uint64_t> data = 0;; + + uint64_t address = 0x00005678; + + for (uint32_t i = 0; i < 5; i++) + { + FAPI_TRY(fapi2::getScom(i_target, address+i, data)); + + data.setBit<4>(); + + FAPI_TRY(fapi2::putScom(i_target, address+i, data)); + + data = 0xDEADBEEFDEADBEEFull; + FAPI_TRY(fapi2::putScom(i_target, address+(2*i), data)); + } + + return fapi2::FAPI2_RC_SUCCESS; + +fapi_try_exit: + + return fapi2::FAPI2_RC_PLAT_ERR_SEE_DATA; +} + + + +// The main function is called by the boot code (after initializing some +// registers) +int main(int argc, char **argv) +{ + // initializes kernel data (stack, threads, timebase, timers, etc.) + pk_initialize((PkAddress)G_kernel_stack, + KERNEL_STACK_SIZE, + 0, + 500000000); + + PK_TRACE("Kernel init completed"); + + //Initialize the thread control block for G_main_thread + pk_thread_create(&G_main_thread, + (PkThreadRoutine)main_thread, + (void*)NULL, + (PkAddress)G_main_thread_stack, + (size_t)MAIN_THREAD_STACK_SIZE, + (PkThreadPriority)1); + + PK_TRACE_BIN("G_main_thread", &G_main_thread, sizeof(G_main_thread)); + + //Make G_main_thread runnable + pk_thread_resume(&G_main_thread); + + PK_TRACE("Starting thread(s)"); + + // Start running the highest priority thread. + // This function never returns + pk_start_threads(); + + return 0; +} + +} // extern C diff --git a/sbe/image/sbe_xip_image.c b/sbe/image/sbe_xip_image.c index 270b450d..91576d50 100644 --- a/sbe/image/sbe_xip_image.c +++ b/sbe/image/sbe_xip_image.c @@ -1,3 +1,5 @@ +// $Id: sbe_xip_image.c,v 1.28 2013/12/11 00:12:41 bcbrock Exp $ + /// \file sbe_xip_image.c /// \brief APIs for validating, normalizing, searching and manipulating /// SBE-XIP images. @@ -1733,6 +1735,115 @@ sbe_xip_find(void* i_image, } +int +sbe_xip_map_halt(void* io_image, + int (*i_fn)(void* io_image, + const uint64_t i_imageAddress, + const char* i_rcString, + void* io_arg), + void* io_arg) +{ + int rc; + SbeXipSection haltSection; + SbeXipHalt *halt; + uint32_t size; + uint32_t actualSize; + + do { + rc = xipQuickCheck(io_image, 0); + if (rc) break; + + rc = sbe_xip_get_section(io_image, SBE_XIP_SECTION_HALT, &haltSection); + if (rc) break; + + halt = (SbeXipHalt*)((unsigned long)io_image + haltSection.iv_offset); + size = haltSection.iv_size; + + while (size) { + + rc = i_fn(io_image, + xipRevLe64(halt->iv_address), + halt->iv_string, + io_arg); + if (rc) break; + + // The SbeXipHalt structure claims a 4-character string. The + // computation below computes the actual record size based on the + // actual length of the string, including the 0-byte termination. + + actualSize = 8 + (((strlen(halt->iv_string) + 4) / 4) * 4); + + if (size < actualSize) { + rc = TRACE_ERRORX(SBE_XIP_IMAGE_ERROR, + "The .halt section is improperly formed\n"); + break; + } + + size -= actualSize; + halt = (SbeXipHalt*)((unsigned long)halt + actualSize); + }; + + if (rc) break; + + } while (0); + + return rc; +} + + +typedef struct { + uint64_t iv_address; + const char* iv_string; +} GetHaltStruct; + + +XIP_STATIC int +xipGetHaltMap(void* io_image, + const uint64_t i_imageAddress, + const char* i_rcString, + void* io_arg) +{ + int rc; + + GetHaltStruct* s = (GetHaltStruct*)io_arg; + + if (i_imageAddress == s->iv_address) { + s->iv_string = i_rcString; + rc = -1; + } else { + rc = 0; + } + + return rc; +} + + +int +sbe_xip_get_halt(void* io_image, + const uint64_t i_imageAddress, + const char** o_rcString) +{ + int rc; + GetHaltStruct s; + + s.iv_address = i_imageAddress; + do { + rc = xipQuickCheck(io_image, 0); + if (rc) break; + + rc = sbe_xip_map_halt(io_image, xipGetHaltMap, &s); + if (rc == 0) { + rc = TRACE_ERRORX(SBE_XIP_ITEM_NOT_FOUND, + "sbe_xip_get_halt: No HALT code is associated " + "with address " F0x012llx "\n", i_imageAddress); + } else if (rc < 0) { + *o_rcString = s.iv_string; + rc = 0; + } + } while (0); + + return rc; +} int @@ -1747,27 +1858,12 @@ sbe_xip_get_scalar(void *i_image, const char* i_id, uint64_t* o_data) case SBE_XIP_UINT8: *o_data = *((uint8_t*)(item.iv_imageData)); break; - case SBE_XIP_UINT16: - *o_data = xipRevLe16(*((uint16_t*)(item.iv_imageData))); - break; case SBE_XIP_UINT32: *o_data = xipRevLe32(*((uint32_t*)(item.iv_imageData))); break; case SBE_XIP_UINT64: *o_data = xipRevLe64(*((uint64_t*)(item.iv_imageData))); break; - case SBE_XIP_INT8: - *o_data = *((int8_t*)(item.iv_imageData)); - break; - case SBE_XIP_INT16: - *o_data = xipRevLe16(*((int16_t*)(item.iv_imageData))); - break; - case SBE_XIP_INT32: - *o_data = xipRevLe32(*((int32_t*)(item.iv_imageData))); - break; - case SBE_XIP_INT64: - *o_data = xipRevLe64(*((int64_t*)(item.iv_imageData))); - break; case SBE_XIP_ADDRESS: *o_data = item.iv_address; break; @@ -1802,27 +1898,12 @@ sbe_xip_get_element(void *i_image, case SBE_XIP_UINT8: *o_data = ((uint8_t*)(item.iv_imageData))[i_index]; break; - case SBE_XIP_UINT16: - *o_data = xipRevLe16(((uint16_t*)(item.iv_imageData))[i_index]); - break; case SBE_XIP_UINT32: *o_data = xipRevLe32(((uint32_t*)(item.iv_imageData))[i_index]); break; case SBE_XIP_UINT64: *o_data = xipRevLe64(((uint64_t*)(item.iv_imageData))[i_index]); break; - case SBE_XIP_INT8: - *o_data = ((int8_t*)(item.iv_imageData))[i_index]; - break; - case SBE_XIP_INT16: - *o_data = xipRevLe16(((int16_t*)(item.iv_imageData))[i_index]); - break; - case SBE_XIP_INT32: - *o_data = xipRevLe32(((int32_t*)(item.iv_imageData))[i_index]); - break; - case SBE_XIP_INT64: - *o_data = xipRevLe64(((int64_t*)(item.iv_imageData))[i_index]); - break; default: rc = TRACE_ERROR(SBE_XIP_TYPE_ERROR); break; @@ -1895,27 +1976,12 @@ sbe_xip_set_scalar(void* io_image, const char* i_id, const uint64_t i_data) case SBE_XIP_UINT8: *((uint8_t*)(item.iv_imageData)) = (uint8_t)i_data; break; - case SBE_XIP_UINT16: - *((uint16_t*)(item.iv_imageData)) = xipRevLe16((uint16_t)i_data); - break; case SBE_XIP_UINT32: *((uint32_t*)(item.iv_imageData)) = xipRevLe32((uint32_t)i_data); break; case SBE_XIP_UINT64: *((uint64_t*)(item.iv_imageData)) = xipRevLe64((uint64_t)i_data); break; - case SBE_XIP_INT8: - *((int8_t*)(item.iv_imageData)) = (int8_t)i_data; - break; - case SBE_XIP_INT16: - *((int16_t*)(item.iv_imageData)) = xipRevLe16((int16_t)i_data); - break; - case SBE_XIP_INT32: - *((int32_t*)(item.iv_imageData)) = xipRevLe32((int32_t)i_data); - break; - case SBE_XIP_INT64: - *((int64_t*)(item.iv_imageData)) = xipRevLe64((int64_t)i_data); - break; default: rc = TRACE_ERROR(SBE_XIP_TYPE_ERROR); break; diff --git a/sbe/image/topfiles.mk b/sbe/image/topfiles.mk index 88c11bee..36e541e8 100644 --- a/sbe/image/topfiles.mk +++ b/sbe/image/topfiles.mk @@ -1,5 +1,5 @@ -TOP-C-SOURCES = base_ppe_demo.c sbe_loader.c -TOP-CPP-SOURCES = +TOP-C-SOURCES = +TOP-CPP-SOURCES = sbe_main.C sbe_loader.c TOP-S-SOURCES = base_ppe_header.S TOP-FIXED-HEADERS += $(IMAGE_SRCDIR)/proc_sbe_fixed_perv.H diff --git a/tools/image/sbe_xip_tool.c b/tools/image/sbe_xip_tool.c index 75448a25..195a29ef 100644 --- a/tools/image/sbe_xip_tool.c +++ b/tools/image/sbe_xip_tool.c @@ -77,9 +77,13 @@ // // The 'report' command prints a report including a dump of the header and // section table, a listing of the types and values of all items that appear -// in the TOC. The TOC listing includes the +// in the TOC, and a dump of the .halt section. The TOC listing includes the // sequence number of the entry in the TOC, the item name, the item type and -// the item value. +// the item value. The .halt listing displays a map of HALT PC values to the +// string form of the halt code associated with the HALT address. The optional +// <regex> expression, if present, is a POSIX Basic Regular Expression. If +// <regex> is specified, then no header, section table or .halt dumps are +// provided, and only the TOC entries matching <regex> will be listed. // // The 'append' command either creates or extends the section named by the // section argument, by appending the contents of the named file verbatim. @@ -154,9 +158,13 @@ const char* g_usage = "\n" "The 'report' command prints a report including a dump of the header and\n" "section table, a listing of the types and values of all items that appear\n" -"in the TOC. The TOC listing includes the\n" +"in the TOC, and a dump of the .halt section. The TOC listing includes the\n" "sequence number of the entry in the TOC, the item name, the item type and\n" -"the item value.\n" +"the item value. The .halt listing displays a map of HALT PC values to the\n" +"string form of the halt code associated with the HALT address. The optional\n" +"<regex> expression, if present, is a POSIX Basic Regular Expression. If\n" +"<regex> is specified, then no header, section table or .halt dumps are\n" +"provided, and only the TOC entries matching <regex> will be listed.\n" "\n" "The 'append' command either creates or extends the section named by the\n" "section argument, by appending the contents of the named file verbatim.\n" @@ -324,41 +332,16 @@ tocListing(void* io_image, if (rc) break; printf("0x%02x", (uint8_t)data); break; - case SBE_XIP_INT8: - rc = sbe_xip_get_scalar(io_image, i_item->iv_id, &data); - if (rc) break; - printf("%d", (int8_t)data); - break; - case SBE_XIP_UINT16: - rc = sbe_xip_get_scalar(io_image, i_item->iv_id, &data); - if (rc) break; - printf("0x%08x", (uint16_t)data); - break; - case SBE_XIP_INT16: - rc = sbe_xip_get_scalar(io_image, i_item->iv_id, &data); - if (rc) break; - printf("%d", (int16_t)data); - break; case SBE_XIP_UINT32: rc = sbe_xip_get_scalar(io_image, i_item->iv_id, &data); if (rc) break; printf("0x%08x", (uint32_t)data); break; - case SBE_XIP_INT32: - rc = sbe_xip_get_scalar(io_image, i_item->iv_id, &data); - if (rc) break; - printf("%d", (int32_t)data); - break; case SBE_XIP_UINT64: rc = sbe_xip_get_scalar(io_image, i_item->iv_id, &data); if (rc) break; printf("0x%016llx", data); break; - case SBE_XIP_INT64: - rc = sbe_xip_get_scalar(io_image, i_item->iv_id, &data); - if (rc) break; - printf("%d", (int64_t)data); - break; case SBE_XIP_STRING: rc = sbe_xip_get_string(io_image, i_item->iv_id, &s); if (rc) break; @@ -372,7 +355,6 @@ tocListing(void* io_image, (uint32_t)(data & 0xffffffff)); break; default: - printf("unknown type\n"); rc = SBE_XIP_BUG; break; } @@ -439,6 +421,19 @@ dumpHeader(void* i_image) } +// Dump an entry from .halt + +int +haltListing(void* io_image, + const uint64_t i_homerAddress, + const char* i_rcString, + void* io_arg) +{ + printf("%016llx : %s\n", i_homerAddress, i_rcString); + return 0; +} + + // Print a report int @@ -480,6 +475,17 @@ report(void* io_image, const int i_argc, const char** i_argv) rc = sbe_xip_map_toc(io_image, tocListing, (void*)(&control)); if (rc) break; + // Dump the .halt section + + if (i_argc == 0) { + printf("\nHALT report\n\n"); + rc = sbe_xip_map_halt(io_image, haltListing, 0); + if (rc == SBE_XIP_ITEM_NOT_FOUND) { + rc = 0; + } + if (rc) break; + } + } while (0); return rc; @@ -544,7 +550,6 @@ set(void* io_image, const int i_argc, const char** i_argv, int i_setv) switch (item.iv_type) { case SBE_XIP_UINT8: - case SBE_XIP_UINT16: case SBE_XIP_UINT32: case SBE_XIP_UINT64: @@ -581,15 +586,6 @@ set(void* io_image, const int i_argc, const char** i_argv, int i_setv) } break; - case SBE_XIP_UINT16: - if ((uint16_t)newValue != newValue) { - fprintf(stderr, - "Value 0x%016llx too large for 16-bit type\n", - newValue); - exit(1); - } - break; - case SBE_XIP_UINT32: if ((uint32_t)newValue != newValue) { fprintf(stderr, @@ -620,18 +616,7 @@ set(void* io_image, const int i_argc, const char** i_argv, int i_setv) rc = sbe_xip_set_string(io_image, key, (char*)value); if (rc) rc = SBE_XIP_BUG; break; - case SBE_XIP_INT8: - case SBE_XIP_INT16: - case SBE_XIP_INT32: - case SBE_XIP_INT64: - fprintf(stderr, - "Item %s has int type %s, " - "which is not supported for '%s'.\n", - i_argv[arg], - SBE_XIP_TYPE_STRING(g_typeStrings, item.iv_type), - (i_setv ? "setv" : "set")); - exit(1); - break; + default: fprintf(stderr, "Item %s has type %s, " @@ -728,7 +713,6 @@ get(void* i_image, const int i_argc, const char** i_argv, int i_getv) switch (item.iv_type) { case SBE_XIP_UINT8: - case SBE_XIP_UINT16: case SBE_XIP_UINT32: case SBE_XIP_UINT64: rc = sbe_xip_get_element(i_image, key, index_val, &data); @@ -740,9 +724,6 @@ get(void* i_image, const int i_argc, const char** i_argv, int i_getv) case SBE_XIP_UINT8: printf("0x%02x\n", (uint8_t)data); break; - case SBE_XIP_UINT16: - printf("0x%04x\n", (uint16_t)data); - break; case SBE_XIP_UINT32: printf("0x%08x\n", (uint32_t)data); break; @@ -781,14 +762,7 @@ get(void* i_image, const int i_argc, const char** i_argv, int i_getv) } printf("%s\n", s); break; - case SBE_XIP_INT8: - case SBE_XIP_INT16: - case SBE_XIP_INT32: - case SBE_XIP_INT64: - fprintf(stderr, "%s%d : Bug, int types not implemented %d\n", - __FILE__, __LINE__, item.iv_type); - exit(1); - break; + default: fprintf(stderr, "%s%d : Bug, unexpected type %d\n", __FILE__, __LINE__, item.iv_type); @@ -1358,6 +1332,18 @@ TEST(void* io_image, const int i_argc, const char** i_argv) BOMB_IF(sbe_xip_find(io_image, "proc_sbe_ex_dpll_initf", 0) != 0); } + // Run the embedded delete and append tests. This assumes that the + // test image does not contain the .fit and .ffdc sections. We just + // append zeros here, we're mostly interested in whether we can handle + // errors and return the image back to its original state. + + BOMB_IF((deleteAppendImage = malloc(imageSize + 2000)) == 0); + memcpy(deleteAppendImage, io_image, imageSize); + + BOMB_IF(sbe_xip_append(deleteAppendImage, SBE_XIP_SECTION_FIT, + 0, 973, imageSize + 2000, 0) != 0); + BOMB_IF(sbe_xip_append(deleteAppendImage, SBE_XIP_SECTION_FFDC, + 0, 973, imageSize + 2000, 0) != 0); #ifdef DEBUG_SBE_XIP_IMAGE printf("\nYou will see an expected warning below " @@ -1365,6 +1351,14 @@ TEST(void* io_image, const int i_argc, const char** i_argv) "It means the TEST is working (not failing)\n\n"); #endif + BOMB_IF(sbe_xip_append(deleteAppendImage, SBE_XIP_SECTION_FFDC, + 0, 973, imageSize + 2000, 0) == 0); + + BOMB_IF(sbe_xip_delete_section(deleteAppendImage, SBE_XIP_SECTION_FFDC) != 0); + BOMB_IF(sbe_xip_delete_section(deleteAppendImage, SBE_XIP_SECTION_FIT) != 0); + + memcpy(io_image, deleteAppendImage, imageSize); + // Finally compare against the original BOMB_IF(memcmp(io_image, originalImage, imageSize)); @@ -1479,432 +1473,440 @@ int disassembleSection(void *i_image, int i_argc, const char **i_argv) { - int rc=0, rcSet=0; - uint32_t rcCount=0; - char *disList=NULL; - uint32_t sizeSection=0, nextLinkOffsetBlock=0; - uint32_t sizeBlock=0, sizeData=0, sizeCode=0, sizeData2=0; - uint32_t sizeDisLine=0, sizeList=0, sizeListMax=0; - uint32_t offsetCode=0; - uint8_t typeRingsSection=0; // 0: RS4 1: Wiggle-Flip - uint8_t bSummary=0, bFoundInToc=0; - uint32_t sectionId; - uint64_t backPtr=0, fwdPtr=0; - PairingInfo pairingInfo; - const char *sectionName; + int rc=0, rcSet=0; + uint32_t rcCount=0; + char *disList=NULL; + uint32_t sizeSection=0, nextLinkOffsetBlock=0; + uint32_t sizeBlock=0, sizeData=0, sizeCode=0, sizeData2=0; + uint32_t sizeDisLine=0, sizeList=0, sizeListMax=0; + uint32_t offsetCode=0; + uint8_t typeRingsSection=0; // 0: RS4 1: Wiggle-Flip + uint8_t bSummary=0, bFoundInToc=0; + uint32_t sectionId; + uint64_t backPtr=0, fwdPtr=0; + PairingInfo pairingInfo; + const char *sectionName; char *ringName; uint32_t ringSeqNo=0; // Ring sequence location counter. uint8_t vectorPos,overRidable; - void *nextBlock, *nextSection; - SbeXipHeader hostHeader; - SbeXipSection hostSection; - ImageInlineContext ctx; - ImageInlineDisassembly dis; - char lineDis[LISTING_STRING_SIZE]; - void *hostRs4Container; - uint32_t compressedBits=0, ringLength=0; - double compressionPct=0; - - if (i_argc != 1) { - fprintf(stderr, g_usage); - exit(1); - } - sectionName = i_argv[0]; - - // Determine SBE-XIP section ID from the section name, e.g. - // .loader_text => SBE_XIP_SECTION_LOADER_TEXT - // .text => SBE_XIP_SECTION_TEXT - // .rings => SBE_XIP_SECTION_RINGS - if (strcmp(sectionName, ".header")==0) - sectionId = SBE_XIP_SECTION_HEADER; - else - if (strcmp(sectionName, ".fixed")==0) - sectionId = SBE_XIP_SECTION_FIXED; - else - if (strcmp(sectionName, ".fixed_toc")==0) - sectionId = SBE_XIP_SECTION_FIXED_TOC; - else - if (strcmp(sectionName, ".loader_text")==0) - sectionId = SBE_XIP_SECTION_LOADER_TEXT; - else - if (strcmp(sectionName, ".loader_data")==0) - sectionId = SBE_XIP_SECTION_LOADER_DATA; - else - if (strcmp(sectionName, ".text")==0) - sectionId = SBE_XIP_SECTION_TEXT; - else - if (strcmp(sectionName, ".data")==0) - sectionId = SBE_XIP_SECTION_DATA; - else - if (strcmp(sectionName, ".toc")==0) - sectionId = SBE_XIP_SECTION_TOC; - else - if (strcmp(sectionName, ".strings")==0) - sectionId = SBE_XIP_SECTION_STRINGS; - else - if (strcmp(sectionName, ".base")==0) - sectionId = SBE_XIP_SECTION_BASE; - else - if (strcmp(sectionName, ".baseloader")==0) - sectionId = SBE_XIP_SECTION_BASELOADER; - else - if (strcmp(sectionName, ".rings")==0) - sectionId = SBE_XIP_SECTION_RINGS; - else - if (strcmp(sectionName, ".rings_summary")==0) { - sectionId = SBE_XIP_SECTION_RINGS; - bSummary = 1; - } - else - if (strcmp(sectionName, ".overlays")==0) - sectionId = SBE_XIP_SECTION_OVERLAYS; - else { - fprintf(stderr,"ERROR : %s is an invalid section name.\n",sectionName); - fprintf(stderr,"Valid <section> names for the 'dis' function are:\n"); - fprintf(stderr,"\t.header\n"); - fprintf(stderr,"\t.fixed\n"); - fprintf(stderr,"\t.fixed_toc\n"); - fprintf(stderr,"\t.loader_text\n"); - fprintf(stderr,"\t.loader_data\n"); - fprintf(stderr,"\t.text\n"); - fprintf(stderr,"\t.data\n"); - fprintf(stderr,"\t.toc\n"); - fprintf(stderr,"\t.strings\n"); - fprintf(stderr,"\t.base\n"); - fprintf(stderr,"\t.baseloader\n"); - fprintf(stderr,"\t.overlays\n"); - fprintf(stderr,"\t.rings\n"); - fprintf(stderr,"\t.rings_summary\n"); - exit(1); - } - - // Get host header and section pointer. - // - sbe_xip_translate_header( &hostHeader, (SbeXipHeader*)i_image); - rc = sbe_xip_get_section( i_image, sectionId, &hostSection); - if (rc) { - fprintf( stderr, "sbe_xip_get_section() failed : %s\n", SBE_XIP_ERROR_STRING(g_errorStrings, rc)); - return SBE_XIP_DISASSEMBLER_ERROR; - } - sizeSection = hostSection.iv_size; - nextBlock = (void*)(hostSection.iv_offset + (uintptr_t)i_image); - nextSection = (void*)((uint64_t)nextBlock + (uint64_t)sizeSection); + void *nextBlock, *nextSection; + SbeXipHeader hostHeader; + SbeXipSection hostSection; + ImageInlineContext ctx; + ImageInlineDisassembly dis; + char lineDis[LISTING_STRING_SIZE]; + void *hostRs4Container; + uint32_t compressedBits=0, ringLength=0; + double compressionPct=0; + + if (i_argc != 1) { + fprintf(stderr, g_usage); + exit(1); + } + sectionName = i_argv[0]; + + // Determine SBE-XIP section ID from the section name, e.g. + // .ipl_text => SBE_XIP_SECTION_IPL_TEXT + // .text => SBE_XIP_SECTION_TEXT + // .rings => SBE_XIP_SECTION_RINGS + if (strcmp(sectionName, ".header")==0) + sectionId = SBE_XIP_SECTION_HEADER; + else + if (strcmp(sectionName, ".fixed")==0) + sectionId = SBE_XIP_SECTION_FIXED; + else + if (strcmp(sectionName, ".fixed_toc")==0) + sectionId = SBE_XIP_SECTION_FIXED_TOC; + else + if (strcmp(sectionName, ".ipl_text")==0) + sectionId = SBE_XIP_SECTION_IPL_TEXT; + else + if (strcmp(sectionName, ".ipl_data")==0) + sectionId = SBE_XIP_SECTION_IPL_DATA; + else + if (strcmp(sectionName, ".text")==0) + sectionId = SBE_XIP_SECTION_TEXT; + else + if (strcmp(sectionName, ".data")==0) + sectionId = SBE_XIP_SECTION_DATA; + else + if (strcmp(sectionName, ".toc")==0) + sectionId = SBE_XIP_SECTION_TOC; + else + if (strcmp(sectionName, ".strings")==0) + sectionId = SBE_XIP_SECTION_STRINGS; + else + if (strcmp(sectionName, ".pibmem0")==0) + sectionId = SBE_XIP_SECTION_PIBMEM0; + else + if (strcmp(sectionName, ".rings")==0) + sectionId = SBE_XIP_SECTION_RINGS; + else + if (strcmp(sectionName, ".rings_summary")==0) { + sectionId = SBE_XIP_SECTION_RINGS; + bSummary = 1; + } + else + if (strcmp(sectionName, ".dcrings")==0) + sectionId = SBE_XIP_SECTION_DCRINGS; + else + if (strcmp(sectionName, ".halt")==0) + sectionId = SBE_XIP_SECTION_HALT; + else + if (strcmp(sectionName, ".slw")==0) + sectionId = SBE_XIP_SECTION_SLW; + else + if (strcmp(sectionName, ".ffdc")==0) + sectionId = SBE_XIP_SECTION_FFDC; + else { + fprintf(stderr,"ERROR : %s is an invalid section name.\n",sectionName); + fprintf(stderr,"Valid <section> names for the 'dis' function are:\n"); + fprintf(stderr,"\t.header\n"); + fprintf(stderr,"\t.fixed\n"); + fprintf(stderr,"\t.fixed_toc\n"); + fprintf(stderr,"\t.ipl_text\n"); + fprintf(stderr,"\t.ipl_data\n"); + fprintf(stderr,"\t.text\n"); + fprintf(stderr,"\t.data\n"); + fprintf(stderr,"\t.toc\n"); + fprintf(stderr,"\t.strings\n"); + fprintf(stderr,"\t.pibmem0\n"); + fprintf(stderr,"\t.rings\n"); + fprintf(stderr,"\t.rings_summary\n"); + fprintf(stderr,"\t.dcrings\n"); + fprintf(stderr,"\t.halt\n"); + fprintf(stderr,"\t.slw\n"); + fprintf(stderr,"\t.ffdc\n"); + exit(1); + } + + // Get host header and section pointer. + // + sbe_xip_translate_header( &hostHeader, (SbeXipHeader*)i_image); + rc = sbe_xip_get_section( i_image, sectionId, &hostSection); + if (rc) { + fprintf( stderr, "sbe_xip_get_section() failed : %s\n", SBE_XIP_ERROR_STRING(g_errorStrings, rc)); + return SBE_XIP_DISASSEMBLER_ERROR; + } + sizeSection = hostSection.iv_size; + nextBlock = (void*)(hostSection.iv_offset + (uintptr_t)i_image); + nextSection = (void*)((uint64_t)nextBlock + (uint64_t)sizeSection); - // Relocatable offset of section at hand. - nextLinkOffsetBlock = (uint32_t)hostHeader.iv_linkAddress + hostSection.iv_offset; + // Relocatable offset of section at hand. + nextLinkOffsetBlock = (uint32_t)hostHeader.iv_linkAddress + hostSection.iv_offset; + + // Allocate buffer to hold disassembled listing. (Start out with minimum 10k buffer size.) + // + if (sizeSection>10000) + sizeListMax = sizeSection; // Just to use something as an initial guess. + else + sizeListMax = 10000; + disList = (char*)malloc(sizeListMax); + if (disList==NULL) { + fprintf( stderr, "ERROR : malloc() failed.\n"); + fprintf( stderr, "\tMore info: %s\n", DIS_ERROR_STRING(g_errorStringsDis, DIS_MEMORY_ERROR)); + return SBE_XIP_DISASSEMBLER_ERROR; + } + *disList = '\0'; // Make sure the buffer is NULL terminated (though probably not needed.) + sizeList = 0; + + // Create context and point it to image section. + // + rc = image_inline_context_create( &ctx, + nextBlock, + sizeSection, + nextLinkOffsetBlock, + 0); + if (rc) { + fprintf( stderr, "ERROR : %s (rc=%i)\n",image_inline_error_strings[rc],rc); + fprintf( stderr, "\tMore info: %s\n", DIS_ERROR_STRING(g_errorStringsDis, DIS_DISASM_ERROR)); + return SBE_XIP_DISASSEMBLER_ERROR; + } - // Allocate buffer to hold disassembled listing. (Start out with minimum 10k buffer size.) - // - if (sizeSection>10000) - sizeListMax = sizeSection; // Just to use something as an initial guess. - else - sizeListMax = 10000; - disList = (char*)malloc(sizeListMax); - if (disList==NULL) { - fprintf( stderr, "ERROR : malloc() failed.\n"); - fprintf( stderr, "\tMore info: %s\n", DIS_ERROR_STRING(g_errorStringsDis, DIS_MEMORY_ERROR)); - return SBE_XIP_DISASSEMBLER_ERROR; - } - *disList = '\0'; // Make sure the buffer is NULL terminated (though probably not needed.) - sizeList = 0; + while ((uint64_t)nextBlock<(uint64_t)nextSection) { - // Create context and point it to image section. + // Disassemble sections based on their types and intents. // - rc = image_inline_context_create( &ctx, - nextBlock, - sizeSection, - nextLinkOffsetBlock, - 0); - if (rc) { - fprintf( stderr, "ERROR : %s (rc=%i)\n",image_inline_error_strings[rc],rc); - fprintf( stderr, "\tMore info: %s\n", DIS_ERROR_STRING(g_errorStringsDis, DIS_DISASM_ERROR)); - return SBE_XIP_DISASSEMBLER_ERROR; - } - - while ((uint64_t)nextBlock<(uint64_t)nextSection) { - - // Disassemble sections based on their types and intents. - // - if (sectionId==SBE_XIP_SECTION_RINGS || sectionId==SBE_XIP_SECTION_OVERLAYS) { - // Ring section (with a mix of data and code.) - // ...use BaseRingLayout structure to decode each ring block. - offsetCode = (uint32_t)myRev64(((BaseRingLayout*)nextBlock)->entryOffset); - sizeBlock = myRev32(((BaseRingLayout*)nextBlock)->sizeOfThis); - // ...determine ring type, either RS4 or Wiggle-flip. - if (offsetCode-(myRev32(((BaseRingLayout*)nextBlock)->sizeOfMeta)+3)/4*4>28) { - typeRingsSection = 0; // RS4 w/32-byte header. - sizeData2 = sizeBlock - offsetCode - ASM_RS4_LAUNCH_BUF_SIZE; - } - else - typeRingsSection = 1; // Wiggle-flip w/24-byte header. - // ...get the backPtr and fwdPtr and put at top of disasm listing. - backPtr = myRev64(((BaseRingLayout*)nextBlock)->backItemPtr); - sbe_xip_read_uint64(i_image, - backPtr, - &fwdPtr); + if (sectionId==SBE_XIP_SECTION_RINGS || sectionId==SBE_XIP_SECTION_DCRINGS) { + // Ring section (with a mix of data and code.) + // ...use BaseRingLayout structure to decode each ring block. + offsetCode = (uint32_t)myRev64(((BaseRingLayout*)nextBlock)->entryOffset); + sizeBlock = myRev32(((BaseRingLayout*)nextBlock)->sizeOfThis); + // ...determine ring type, either RS4 or Wiggle-flip. + if (offsetCode-(myRev32(((BaseRingLayout*)nextBlock)->sizeOfMeta)+3)/4*4>28) { + typeRingsSection = 0; // RS4 w/32-byte header. + sizeData2 = sizeBlock - offsetCode - ASM_RS4_LAUNCH_BUF_SIZE; + } + else + typeRingsSection = 1; // Wiggle-flip w/24-byte header. + // ...get the backPtr and fwdPtr and put at top of disasm listing. + backPtr = myRev64(((BaseRingLayout*)nextBlock)->backItemPtr); + sbe_xip_read_uint64(i_image, + backPtr, + &fwdPtr); - // Calculate RS4 compression efficiency if RS4 rings. - if (typeRingsSection==0) { - hostRs4Container = (void*)( (uintptr_t)nextBlock + - offsetCode + ASM_RS4_LAUNCH_BUF_SIZE ); - compressedBits = myRev32(((CompressedScanData*)hostRs4Container)->iv_algorithmReserved) * 4; - ringLength = myRev32(((CompressedScanData*)hostRs4Container)->iv_length); - compressionPct = (double)compressedBits / (double)ringLength * 100.0; + // Calculate RS4 compression efficiency if RS4 rings. + if (typeRingsSection==0) { + hostRs4Container = (void*)( (uintptr_t)nextBlock + + offsetCode + ASM_RS4_LAUNCH_BUF_SIZE ); + compressedBits = myRev32(((CompressedScanData*)hostRs4Container)->iv_algorithmReserved) * 4; + ringLength = myRev32(((CompressedScanData*)hostRs4Container)->iv_length); + compressionPct = (double)compressedBits / (double)ringLength * 100.0; } - // + // // Map over TOC or do a targeted search of FIXED_TOC to pair backPtr addr // with ring name and override and/or vector position (i.e. multi-chiplet). // - sbe_xip_get_section( i_image, SBE_XIP_SECTION_TOC, &hostSection); + sbe_xip_get_section( i_image, SBE_XIP_SECTION_TOC, &hostSection); if (hostSection.iv_offset) { - // TOC exists. - pairingInfo.address = backPtr; + // TOC exists. + pairingInfo.address = backPtr; // Search for pairing. First exhaust base position (pos=0), then next, then next, ... for (pairingInfo.vectorpos=0;pairingInfo.vectorpos<32;pairingInfo.vectorpos++) { - rc = sbe_xip_map_toc( i_image, pairRingNameAndAddr, (void*)(&pairingInfo)); + rc = sbe_xip_map_toc( i_image, pairRingNameAndAddr, (void*)(&pairingInfo)); if (rc) break; } - if (rc==DIS_RING_NAME_ADDR_MATCH_FAILURE) { - fprintf( stderr,"ERROR : Error associated with sbe_xip_map_toc().\n"); - fprintf( stderr, "\tMore info: %s\n", DIS_ERROR_STRING(g_errorStringsDis, DIS_RING_NAME_ADDR_MATCH_FAILURE)); - return SBE_XIP_DISASSEMBLER_ERROR; - } - ringSeqNo++; + if (rc==DIS_RING_NAME_ADDR_MATCH_FAILURE) { + fprintf( stderr,"ERROR : Error associated with sbe_xip_map_toc().\n"); + fprintf( stderr, "\tMore info: %s\n", DIS_ERROR_STRING(g_errorStringsDis, DIS_RING_NAME_ADDR_MATCH_FAILURE)); + return SBE_XIP_DISASSEMBLER_ERROR; + } + ringSeqNo++; if (rc==DIS_RING_NAME_ADDR_MATCH_SUCCESS) { bFoundInToc = 1; - ringName = pairingInfo.name; // The ring name matched in pairRingNameAndAddr() + ringName = pairingInfo.name; // The ring name matched in pairRingNameAndAddr() vectorPos = pairingInfo.vectorpos; // The vector position matched in pairRingNameAndAddr() overRidable = pairingInfo.overridable; // Whether the ring supports on override ring. - if (pairingInfo.override) { - sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE, - "# ------------------------------\n# %i.\n# ringName = %s (override)\n# vectorPos = %i\n# overRidable = %i\n# backPtr = 0x%08x\n# fwdPtr = 0x%08x\n# Compressed Bits = %u\n# Ring Length Bits = %u\n# Compression = %0.2f%%\n", - ringSeqNo, ringName,vectorPos,overRidable,(uint32_t)backPtr,(uint32_t)fwdPtr,compressedBits,ringLength,compressionPct); - } - else { - sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE, - "# ------------------------------\n# %i.\n# ringName = %s (base)\n# vectorPos = %i\n# overRidable = %i\n# backPtr = 0x%08x\n# fwdPtr = 0x%08x\n# Compressed Bits = %u\n# Ring Length Bits = %u\n# Compression = %0.2f%%\n", - ringSeqNo,ringName,vectorPos,overRidable,(uint32_t)backPtr,(uint32_t)fwdPtr,compressedBits,ringLength,compressionPct); - } + if (pairingInfo.override) { + sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE, + "# ------------------------------\n# %i.\n# ringName = %s (override)\n# vectorPos = %i\n# overRidable = %i\n# backPtr = 0x%08x\n# fwdPtr = 0x%08x\n# Compressed Bits = %u\n# Ring Length Bits = %u\n# Compression = %0.2f%%\n", + ringSeqNo, ringName,vectorPos,overRidable,(uint32_t)backPtr,(uint32_t)fwdPtr,compressedBits,ringLength,compressionPct); + } + else { + sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE, + "# ------------------------------\n# %i.\n# ringName = %s (base)\n# vectorPos = %i\n# overRidable = %i\n# backPtr = 0x%08x\n# fwdPtr = 0x%08x\n# Compressed Bits = %u\n# Ring Length Bits = %u\n# Compression = %0.2f%%\n", + ringSeqNo,ringName,vectorPos,overRidable,(uint32_t)backPtr,(uint32_t)fwdPtr,compressedBits,ringLength,compressionPct); + } } - else { - sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE, - "# ------------------------------\n# %i.\n# ringName = Not found (but TOC's available)\n# backPtr = 0x%08x\n# fwdPtr = 0x%08x\n", - ringSeqNo,(uint32_t)backPtr,(uint32_t)fwdPtr); + else { + sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE, + "# ------------------------------\n# %i.\n# ringName = Not found (but TOC's available)\n# backPtr = 0x%08x\n# fwdPtr = 0x%08x\n", + ringSeqNo,(uint32_t)backPtr,(uint32_t)fwdPtr); } - } + } else { - // TOC doesn't exist. First try targeted search of MVPD ring names in FIXED_TOC. - bFoundInToc = 0; // If we find in fixed_toc, then change to 1. + // TOC doesn't exist. First try targeted search of MVPD ring names in FIXED_TOC. + bFoundInToc = 0; // If we find in fixed_toc, then change to 1. // 2012-11-13: CMO TBD. Try using pairRingNameAndAddr by enabling a sequential - // traversing of each of the MVPD lists inside that function. You'll - // need to call pairRing manually from right here (or from a - // sbe_xip_search_fixed_toc()-like function). Maybe you can add a + // traversing of each of the MVPD lists inside that function. You'll + // need to call pairRing manually from right here (or from a + // sbe_xip_search_fixed_toc()-like function). Maybe you can add a // 4th arg to pairRing that is zero by default, meaning it is to be // used by xip_map_toc(). But if non-zero, it is to be used in a // traversing manner. Or you could add another member to the - // PairingInfo struct to indirectly pass this info to the function. + // PairingInfo struct to indirectly pass this info to the function. // You'd also need to pass two more arguments to get_vpd_ring_list_ - // entry() to indicate sequence number and the MVPD keyword. - // rc = pairRingNameAndAddr(); + // entry() to indicate sequence number and the MVPD keyword. + // rc = pairRingNameAndAddr(); // if (rc==DIS_RING_NAME_ADDR_MATCH_SUCCESS) { - // bFoundInToc = 1; - // // Do same as in TOC section above. - // break; - // } - // // OK, so ring name wasn't in TOC nor in FIXED_TOC. That happens if the ring - // // is a non-Mvpd ring and the TOC has been removed, such as in an IPL or - // // Seeprom image. - ringSeqNo++; - if (typeRingsSection==0) { - // RS4 header, which has override info - if (((Rs4RingLayout*)nextBlock)->override==0) { - sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE, - "# ------------------------------\n# %i.\n# ringName = Not available (base)\n# backPtr = 0x%08x\n# fwdPtr = 0x%08x\n# Compressed Bits = %u\n# Ring Length Bits = %u\n# Compression = %0.2f%%\n", - ringSeqNo,(uint32_t)backPtr,(uint32_t)fwdPtr,compressedBits,ringLength,compressionPct); - } + // bFoundInToc = 1; + // // Do same as in TOC section above. + // break; + // } + // // OK, so ring name wasn't in TOC nor in FIXED_TOC. That happens if the ring + // // is a non-Mvpd ring and the TOC has been removed, such as in an IPL or + // // Seeprom image. + ringSeqNo++; + if (typeRingsSection==0) { + // RS4 header, which has override info + if (((Rs4RingLayout*)nextBlock)->override==0) { + sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE, + "# ------------------------------\n# %i.\n# ringName = Not available (base)\n# backPtr = 0x%08x\n# fwdPtr = 0x%08x\n# Compressed Bits = %u\n# Ring Length Bits = %u\n# Compression = %0.2f%%\n", + ringSeqNo,(uint32_t)backPtr,(uint32_t)fwdPtr,compressedBits,ringLength,compressionPct); + } else { - sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE, - "# ------------------------------\n# %i.\n# ringName = Not available (override)\n# backPtr = 0x%08x\n# fwdPtr = 0x%08x\n# Compressed Bits = %u\n# Ring Length Bits = %u\n# Compression = %0.2f%%\n", - ringSeqNo,(uint32_t)backPtr,(uint32_t)fwdPtr,compressedBits,ringLength,compressionPct); + sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE, + "# ------------------------------\n# %i.\n# ringName = Not available (override)\n# backPtr = 0x%08x\n# fwdPtr = 0x%08x\n# Compressed Bits = %u\n# Ring Length Bits = %u\n# Compression = %0.2f%%\n", + ringSeqNo,(uint32_t)backPtr,(uint32_t)fwdPtr,compressedBits,ringLength,compressionPct); } - } + } else { - // WF header, which doesn't have override info - sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE, - "# ------------------------------\n# %i.\n# ringName and override = Not available\n# backPtr = 0x%08x\n# fwdPtr = 0x%08x\n", - ringSeqNo,(uint32_t)backPtr,(uint32_t)fwdPtr); + // WF header, which doesn't have override info + sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE, + "# ------------------------------\n# %i.\n# ringName and override = Not available\n# backPtr = 0x%08x\n# fwdPtr = 0x%08x\n", + ringSeqNo,(uint32_t)backPtr,(uint32_t)fwdPtr); } - } - sizeList = sizeList + sizeDisLine; - disList = strcat(disList,lineDis); + } + sizeList = sizeList + sizeDisLine; + disList = strcat(disList,lineDis); } - else if ( sectionId==SBE_XIP_SECTION_LOADER_TEXT || - sectionId==SBE_XIP_SECTION_TEXT) { - // Sections that have only code. - offsetCode = 0; - sizeBlock = sizeSection; - } - else { - // Sections that have only data. - offsetCode = sizeSection; - sizeBlock = sizeSection; - } - sizeData = offsetCode; - sizeCode = sizeBlock - offsetCode - sizeData2; - - if (sectionId==SBE_XIP_SECTION_RINGS && bSummary) { - // - // Summarize rings section. - - if (typeRingsSection==0) { // RS4 header. - sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE, - "# ddLevel = 0x%02x\n# override= %i\n# sysPhase= %i\n# Block size= %i\n", - myRev32(((Rs4RingLayout*)nextBlock)->ddLevel), - ((Rs4RingLayout*)nextBlock)->override, - ((Rs4RingLayout*)nextBlock)->sysPhase, - sizeBlock); - } - else { // WF header. + else if ( sectionId==SBE_XIP_SECTION_IPL_TEXT || + sectionId==SBE_XIP_SECTION_TEXT) { + // Sections that have only code. + offsetCode = 0; + sizeBlock = sizeSection; + } + else { + // Sections that have only data. + offsetCode = sizeSection; + sizeBlock = sizeSection; + } + sizeData = offsetCode; + sizeCode = sizeBlock - offsetCode - sizeData2; + + if (sectionId==SBE_XIP_SECTION_RINGS && bSummary) { + // + // Summarize rings section. + + if (typeRingsSection==0) { // RS4 header. + sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE, + "# ddLevel = 0x%02x\n# override= %i\n# sysPhase= %i\n# Block size= %i\n", + myRev32(((Rs4RingLayout*)nextBlock)->ddLevel), + ((Rs4RingLayout*)nextBlock)->override, + ((Rs4RingLayout*)nextBlock)->sysPhase, + sizeBlock); + } + else { // WF header. if (bFoundInToc) { - sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE, - "# override= %i\n# Block size= %i\n", - pairingInfo.override, sizeBlock); + sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE, + "# override= %i\n# Block size= %i\n", + pairingInfo.override, sizeBlock); } else { - sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE, - "# override= Not available\n# Block size= %i\n", - sizeBlock); + sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE, + "# override= Not available\n# Block size= %i\n", + sizeBlock); } - } + } + sizeList = sizeList + sizeDisLine; + disList = strcat(disList,lineDis); + // Readjust list buffer size, if needed. + if (sizeList > sizeListMax-1000) { + sizeListMax = 2*sizeListMax; + disList = (char*)realloc( (void*)(disList), sizeListMax); + } + + } + else { + // + // Do disassembly. + + // ...data disassembly + if (sizeData>0) { + ctx.options = IMAGE_INLINE_LISTING_MODE | IMAGE_INLINE_DISASSEMBLE_DATA; + do { + rc = image_inline_disassemble( &ctx, &dis); + sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE,"%s\n",dis.s); + sizeList = sizeList + sizeDisLine; + disList = strcat(disList,lineDis); + if (rc) { + rcSet = rcSet | 0x1; + sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE, + "WARNING: %s (rc=%i) -> Stopping disasm. Check code and sectionID=%i.\n", + image_inline_error_strings[rc],rc,sectionId); sizeList = sizeList + sizeDisLine; disList = strcat(disList,lineDis); - // Readjust list buffer size, if needed. - if (sizeList > sizeListMax-1000) { - sizeListMax = 2*sizeListMax; - disList = (char*)realloc( (void*)(disList), sizeListMax); + } + // Readjust list buffer size, if needed. + if (sizeList > sizeListMax-1000) { + sizeListMax = 2*sizeListMax; + disList = (char*)realloc( (void*)(disList), sizeListMax); + } + } while (rc==0 && ctx.lc<nextLinkOffsetBlock+sizeData); + } + if (rcSet) + rc = 0; + + // ...code disassembly + if (sizeCode>0) { + ctx.options = IMAGE_INLINE_LISTING_MODE; + do { + rc = image_inline_disassemble( &ctx, &dis); + ctx.options = IMAGE_INLINE_LISTING_MODE; + sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE,"%s\n",dis.s); + sizeList = sizeList + sizeDisLine; + disList = strcat(disList,lineDis); + if (rc && rcCount<100) { + rcSet = rcSet | 0x2; + rcCount++; + if (sectionId==SBE_XIP_SECTION_RINGS) { + sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE, + "WARNING: %s (rc=%i) -> Trying data disasm mode. Check code, xyzRingLayout structures and image section.\n", + image_inline_error_strings[rc],rc); } - - } - else { - // - // Do disassembly. - - // ...data disassembly - if (sizeData>0) { - ctx.options = IMAGE_INLINE_LISTING_MODE | IMAGE_INLINE_DISASSEMBLE_DATA; - do { - rc = image_inline_disassemble( &ctx, &dis); - sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE,"%s\n",dis.s); - sizeList = sizeList + sizeDisLine; - disList = strcat(disList,lineDis); - if (rc) { - rcSet = rcSet | 0x1; - sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE, - "WARNING: %s (rc=%i) -> Stopping disasm. Check code and sectionID=%i.\n", - image_inline_error_strings[rc],rc,sectionId); - sizeList = sizeList + sizeDisLine; - disList = strcat(disList,lineDis); - } - // Readjust list buffer size, if needed. - if (sizeList > sizeListMax-1000) { - sizeListMax = 2*sizeListMax; - disList = (char*)realloc( (void*)(disList), sizeListMax); - } - } while (rc==0 && ctx.lc<nextLinkOffsetBlock+sizeData); + else { + sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE, + "WARNING: %s (rc=%i) -> Trying data disasm mode.\n", + image_inline_error_strings[rc],rc); } - if (rcSet) - rc = 0; - - // ...code disassembly - if (sizeCode>0) { - ctx.options = IMAGE_INLINE_LISTING_MODE; - do { - rc = image_inline_disassemble( &ctx, &dis); - ctx.options = IMAGE_INLINE_LISTING_MODE; - sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE,"%s\n",dis.s); - sizeList = sizeList + sizeDisLine; - disList = strcat(disList,lineDis); - if (rc && rcCount<100) { - rcSet = rcSet | 0x2; - rcCount++; - if (sectionId==SBE_XIP_SECTION_RINGS) { - sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE, - "WARNING: %s (rc=%i) -> Trying data disasm mode. Check code, xyzRingLayout structures and image section.\n", - image_inline_error_strings[rc],rc); - } - else { - sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE, - "WARNING: %s (rc=%i) -> Trying data disasm mode.\n", - image_inline_error_strings[rc],rc); - } - sizeList = sizeList + sizeDisLine; - disList = strcat(disList,lineDis); - ctx.options = IMAGE_INLINE_LISTING_MODE | IMAGE_INLINE_DISASSEMBLE_DATA; - rc = 0; - } - else { - if (rc && rcCount>=1000) { - fprintf(stderr, "Too many disasm warnings. Check output listing.\n"); - fprintf( stderr, "\tMore info: %s\n", DIS_ERROR_STRING(g_errorStringsDis, DIS_TOO_MANY_DISASM_WARNINGS)); - return SBE_XIP_DISASSEMBLER_ERROR; - } - } - // Readjust list buffer size, if needed. - if (sizeList > sizeListMax-1000) { - sizeListMax = 2*sizeListMax; - disList = (char*)realloc( (void*)(disList), sizeListMax); - } - } while (rc==0 && ctx.lc<nextLinkOffsetBlock+sizeData+sizeCode); + sizeList = sizeList + sizeDisLine; + disList = strcat(disList,lineDis); + ctx.options = IMAGE_INLINE_LISTING_MODE | IMAGE_INLINE_DISASSEMBLE_DATA; + rc = 0; + } + else { + if (rc && rcCount>=1000) { + fprintf(stderr, "Too many disasm warnings. Check output listing.\n"); + fprintf( stderr, "\tMore info: %s\n", DIS_ERROR_STRING(g_errorStringsDis, DIS_TOO_MANY_DISASM_WARNINGS)); + return SBE_XIP_DISASSEMBLER_ERROR; } - if (rcSet) - rc = 0; + } + // Readjust list buffer size, if needed. + if (sizeList > sizeListMax-1000) { + sizeListMax = 2*sizeListMax; + disList = (char*)realloc( (void*)(disList), sizeListMax); + } + } while (rc==0 && ctx.lc<nextLinkOffsetBlock+sizeData+sizeCode); + } + if (rcSet) + rc = 0; - // ...data2 disassembly (only done for rings section if RS4 type.) - if (sizeData2>0) { - ctx.options = IMAGE_INLINE_LISTING_MODE | IMAGE_INLINE_DISASSEMBLE_DATA; - do { - rc = image_inline_disassemble( &ctx, &dis); - sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE,"%s\n",dis.s); - sizeList = sizeList + sizeDisLine; - disList = strcat(disList,lineDis); - if (rc) { - rcSet = rcSet | 0x4; - sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE, - "WARNING: %s (rc=%i) -> Stopping disasm. Check code and sectionID=%i.\n", - image_inline_error_strings[rc],rc,sectionId); - sizeList = sizeList + sizeDisLine; - disList = strcat(disList,lineDis); - } - // Readjust list buffer size, if needed. - if (sizeList > sizeListMax-1000) { - sizeListMax = 2*sizeListMax; - disList = (char*)realloc( (void*)(disList), sizeListMax); - } - } while (rc==0 && ctx.lc<nextLinkOffsetBlock+sizeBlock); - } - if (rcSet) - rc = 0; + // ...data2 disassembly (only done for rings section if RS4 type.) + if (sizeData2>0) { + ctx.options = IMAGE_INLINE_LISTING_MODE | IMAGE_INLINE_DISASSEMBLE_DATA; + do { + rc = image_inline_disassemble( &ctx, &dis); + sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE,"%s\n",dis.s); + sizeList = sizeList + sizeDisLine; + disList = strcat(disList,lineDis); + if (rc) { + rcSet = rcSet | 0x4; + sizeDisLine = snprintf(lineDis,LISTING_STRING_SIZE, + "WARNING: %s (rc=%i) -> Stopping disasm. Check code and sectionID=%i.\n", + image_inline_error_strings[rc],rc,sectionId); + sizeList = sizeList + sizeDisLine; + disList = strcat(disList,lineDis); + } + // Readjust list buffer size, if needed. + if (sizeList > sizeListMax-1000) { + sizeListMax = 2*sizeListMax; + disList = (char*)realloc( (void*)(disList), sizeListMax); + } + } while (rc==0 && ctx.lc<nextLinkOffsetBlock+sizeBlock); + } + if (rcSet) + rc = 0; - } // End of if (bSummary) condition. + } // End of if (bSummary) condition. - nextBlock = (void*)((uint64_t)nextBlock + (uint64_t)sizeBlock); - nextLinkOffsetBlock = nextLinkOffsetBlock + sizeBlock; + nextBlock = (void*)((uint64_t)nextBlock + (uint64_t)sizeBlock); + nextLinkOffsetBlock = nextLinkOffsetBlock + sizeBlock; - } // End of while(nextBlock...) loop. + } // End of while(nextBlock...) loop. - // Adjust final buffer size, add 1 for NULL char and print it. - if (disList) { - disList = (char*)realloc( (void*)(disList), sizeList+1); - fprintf(stdout,"%s\n",disList); - free(disList); - } + // Adjust final buffer size, add 1 for NULL char and print it. + if (disList) { + disList = (char*)realloc( (void*)(disList), sizeList+1); + fprintf(stdout,"%s\n",disList); + free(disList); + } - if (rcSet) - fprintf( stderr, "INFO : There were some hickups: %s\n", DIS_ERROR_STRING(g_errorStringsDis, DIS_DISASM_TROUBLES)); + if (rcSet) + fprintf( stderr, "INFO : There were some hickups: %s\n", DIS_ERROR_STRING(g_errorStringsDis, DIS_DISASM_TROUBLES)); - return 0; + return 0; } #endif diff --git a/tools/scripts/ppeParseAttributeInfo.pl b/tools/scripts/ppeParseAttributeInfo.pl index f7be641b..34e13edb 100755 --- a/tools/scripts/ppeParseAttributeInfo.pl +++ b/tools/scripts/ppeParseAttributeInfo.pl @@ -234,14 +234,14 @@ foreach my $argnum (2 .. $#ARGV) #---------------------------------------------------------------------- if (! exists $attr->{id}) { - print ("fapiParseAttributeInfo.pl ERROR. Att 'id' missing\n"); + print ("fapiParseAttributeInfo.pl ERROR. Attribute 'id' missing in $infile\n"); exit(1); } if (exists($attrIdHash{$attr->{id}})) { # Two different attributes with the same id! - print ("fapiParseAttributeInfo.pl ERROR. Duplicate attr id $attr->{id} \n"); + print ("fapiParseAttributeInfo.pl ERROR. Duplicate Attribute id $attr->{id} in $infile\\n"); exit(1); } @@ -255,7 +255,7 @@ foreach my $argnum (2 .. $#ARGV) if (exists($attrValHash{$attrHash28Bit})) { # Two different attributes generate the same hash-value! - print ("fapiParseAttributeInfo.pl ERROR. Duplicate attr id hash value for $attr->{id} \n"); + print ("fapiParseAttributeInfo.pl ERROR. Duplicate attr id hash value for $attr->{id} in $infile\ \n"); exit(1); } @@ -318,7 +318,7 @@ foreach my $argnum (2 .. $#ARGV) #---------------------------------------------------------------------- if (! exists $attr->{description}) { - print ("fapiParseAttributeInfo.pl ERROR. Att 'description' missing\n"); + print ("fapiParseAttributeInfo.pl ERROR. Attribute 'description' missing for $attr->{id} in $infile\n"); exit(1); } @@ -358,7 +358,7 @@ foreach my $argnum (2 .. $#ARGV) { if (! exists $attr->{valueType}) { - print ("fapiParseAttributeInfo.pl ERROR. Att 'valueType' missing\n"); + print ("fapiParseAttributeInfo.pl ERROR. Att 'valueType' missing for $attr->{id} in $infile\n"); exit(1); } @@ -366,6 +366,12 @@ foreach my $argnum (2 .. $#ARGV) { print AIFILE "typedef uint8_t $attr->{id}_Type$arrayDimensions;\n"; print ITFILE "$attr->{id},$attr->{id},0x$attrIdHash{$attr->{id}},u8" . + "$arrayDimensions\n"; + } + elsif ($attr->{valueType} eq 'uint16') + { + print AIFILE "typedef uint16_t $attr->{id}_Type$arrayDimensions;\n"; + print ITFILE "$attr->{id},$attr->{id},0x$attrIdHash{$attr->{id}},u8" . "$arrayDimensions\n"; } elsif ($attr->{valueType} eq 'uint32') @@ -386,6 +392,12 @@ foreach my $argnum (2 .. $#ARGV) print ITFILE "$attr->{id},$attr->{id},0x$attrIdHash{$attr->{id}},8" . "$arrayDimensions\n"; } + elsif ($attr->{valueType} eq 'int16') + { + print AIFILE "typedef int16_t $attr->{id}_Type$arrayDimensions;\n"; + print ITFILE "$attr->{id},$attr->{id},0x$attrIdHash{$attr->{id}},32" . + "$arrayDimensions\n"; + } elsif ($attr->{valueType} eq 'int32') { print AIFILE "typedef int32_t $attr->{id}_Type$arrayDimensions;\n"; @@ -401,7 +413,7 @@ foreach my $argnum (2 .. $#ARGV) else { print ("fapi2ParseAttributeInfo.pl ERROR. valueType not recognized: "); - print $attr->{valueType}, "\n"; + print $attr->{valueType}, " for $attr->{id} in $infile\n"; exit(1); } } @@ -423,7 +435,7 @@ foreach my $argnum (2 .. $#ARGV) #---------------------------------------------------------------------- if (! exists $attr->{targetType}) { - print ("fapiParseAttributeInfo.pl ERROR. Att 'targetType' missing\n"); + print ("fapiParseAttributeInfo.pl ERROR. Att 'targetType' missing for $attr->{id} in $infile\n"); exit(1); } diff --git a/tools/scripts/ppeParseProcSbeFixed.pl b/tools/scripts/ppeParseProcSbeFixed.pl index c4d6ea82..e963bb50 100755 --- a/tools/scripts/ppeParseProcSbeFixed.pl +++ b/tools/scripts/ppeParseProcSbeFixed.pl @@ -145,7 +145,7 @@ foreach my $entr (@{$entries->{entry}}) { } else { - print ("ppeParseProcSbeFixed.pl ERROR. Wrong attribute type: $attr->{targetType}\n"); + print ("ppeParseProcSbeFixed.pl ERROR. Wrong attribute type: $attr->{targetType} for attribute $attr->{id} in $infile\n"); exit(1); } |