From fe372b80a09ce301e02dcc0bf0059f057a042be1 Mon Sep 17 00:00:00 2001 From: Santosh Puranik Date: Thu, 18 Feb 2016 06:30:40 -0600 Subject: Some changes to reduce image size 1) Force get/put scom plat functions to be inline 2) Inline ATTR get/set functions 3) FAPI RC is now 32-bit 4) Enable selective trace levels RTC: 141492 Change-Id: Ie8a5bce597751b5484b2e9c89d614999a555f366 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/21023 Tested-by: Jenkins Server Reviewed-by: Sachin Gupta Reviewed-by: AMIT J. TENDOLKAR Reviewed-by: Gregory S. Still --- hwpf/include/plat/plat_trace.H | 31 ++++++++++- hwpf/include/return_code.H | 12 ++--- hwpf/src/plat/target.C | 10 +--- sbe/hwpf/include/fapi2_hw_access.H | 6 ++- sbe/hwpf/include/hw_access.H | 2 + sbe/image/img_defs.mk | 6 +++ sbe/sbefw/sbeSpMsg.H | 12 ++--- tools/scripts/ppeCreateAttrGetSetMacros.pl | 82 ++++++++++++------------------ 8 files changed, 86 insertions(+), 75 deletions(-) diff --git a/hwpf/include/plat/plat_trace.H b/hwpf/include/plat/plat_trace.H index d3d553ee..cc044066 100644 --- a/hwpf/include/plat/plat_trace.H +++ b/hwpf/include/plat/plat_trace.H @@ -65,21 +65,50 @@ namespace fapi2 PK_TRACE("%s: %s:%d ", _id_, __FUNCTION__, __LINE__); \ PK_TRACE(_fmt_, ##_args_); */ - +// FAPI_TRACE_LEVEL controls what traces are included in the code build +// 0 == No tracing +// 1 == ERR traces only +// 2 == ERR and IMP only +// 3 == ERR, IMP and INF only. This is the default in Makefile +// > 4 == All traces (ERR, IMP, INF, DBG, SCAN, MFG) +#if (FAPI_TRACE_LEVEL >= 3) #define FAPI_INF(_fmt_, _args_...) FAPI_TRACE("inf", _fmt_, ##_args_) +#else +#define FAPI_INF(_fmt_, _args_...) +#endif // Important traces (go into slow trace buffer that should not wrap often) +#if (FAPI_TRACE_LEVEL >= 2) #define FAPI_IMP(_fmt_, _args_...) FAPI_TRACE("imp", _fmt_, ##_args_) +#else +#define FAPI_IMP(_fmt_, _args_...) +#endif // Error traces (go into slow trace buffer that should not wrap often) +#if (FAPI_TRACE_LEVEL >= 1) #define FAPI_ERR(_fmt_, _args_...) FAPI_TRACE("err", _fmt_, ##_args_) +#else +#define FAPI_ERR(_fmt_, _args_...) +#endif // Debug traces (go into fast trace buffer that can wrap often) +#if (FAPI_TRACE_LEVEL >= 4) #define FAPI_DBG(_fmt_, _args_...) FAPI_TRACE("dbg", _fmt_, ##_args_) +#else +#define FAPI_DBG(_fmt_, _args_...) +#endif // Scan traces +#if (FAPI_TRACE_LEVEL >= 4) #define FAPI_SCAN(_fmt_, _args_...) FAPI_TRACE("scan", _fmt_, ##_args_) +#else +#define FAPI_SCAN(_fmt_, _args_...) +#endif +#if (FAPI_TRACE_LEVEL >= 4) #define FAPI_MFG(_fmt_, _args_...) FAPI_TRACE("mfg", _fmt_, ##_args_) +#else +#define FAPI_MFG(_fmt_, _args_...) +#endif #endif // FAPI2_PLATTRACE_H_ diff --git a/hwpf/include/return_code.H b/hwpf/include/return_code.H index fd2f7c29..1ad46c9e 100644 --- a/hwpf/include/return_code.H +++ b/hwpf/include/return_code.H @@ -56,7 +56,7 @@ namespace fapi2 /// @brief Constructor. /// @param[in] i_rc the rc to set /// - ReturnCode(const uint64_t i_rc = FAPI2_RC_SUCCESS): + ReturnCode(const uint32_t i_rc = FAPI2_RC_SUCCESS): iv_rc(i_rc) {}; @@ -64,7 +64,7 @@ namespace fapi2 /// @brief integral type conversion function. Returns the error code /// @return The error code /// - inline operator uint64_t() const { return iv_rc; } + inline operator uint32_t() const { return iv_rc; } /// /// @brief Returns true iff iv_rc == SUCCESS @@ -76,24 +76,24 @@ namespace fapi2 /// @brief Assignement operator /// #ifdef DOXYGEN - inline ReturnCode& operator=(const uint64_t& rhs) + inline ReturnCode& operator=(const uint32_t& rhs) inline ReturnCode& operator=(const ReturnCodes& rhs) #endif - inline bool operator==(const uint64_t& rhs) const + inline bool operator==(const uint32_t& rhs) const { return rhs == iv_rc; } inline bool operator==(const ReturnCodes& rhs) const { return rhs == iv_rc; } - inline bool operator!=(const uint64_t& rhs) const + inline bool operator!=(const uint32_t& rhs) const { return rhs != iv_rc; } inline bool operator!=(const ReturnCodes& rhs) const { return rhs != iv_rc; } private: - uint64_t iv_rc; + uint32_t iv_rc; }; /// This implementation assumes no exception handling and leverages thread-local diff --git a/hwpf/src/plat/target.C b/hwpf/src/plat/target.C index a1c6ca38..fea3a6f7 100644 --- a/hwpf/src/plat/target.C +++ b/hwpf/src/plat/target.C @@ -295,7 +295,6 @@ fapi_try_exit: fapi2::ReturnCode plat_TargetsInit() { bool b_present = false; - uint32_t c = 0; // Initialise global attribute pointers G_system_attributes_ptr = &G_system_attributes; @@ -405,14 +404,6 @@ fapi_try_exit: G_vec_targets.at(l_beginning_offset+i) = revle64((fapi2::plat_target_handle_t)(target_name.get())); } - // Trace all entries - for (auto tgt_iter : G_vec_targets) - { - FAPI_DBG("G_vec_targets[%u] value=%08X", - c, (uint32_t)(tgt_iter)); - ++c; - } - fapi_try_exit: return fapi2::current_err; } @@ -466,6 +457,7 @@ fapi_try_exit: { if((l_mask >> l_idx) & (l_ecGards)) { + FAPI_DBG("Making %d'th EC non-functional", l_idx); // EC chiplet l_idx is to be marked non-functional fapi2::Target l_target = G_vec_targets.at(l_idx + CORE_TARGET_OFFSET); l_target.setFunctional(false); diff --git a/sbe/hwpf/include/fapi2_hw_access.H b/sbe/hwpf/include/fapi2_hw_access.H index 7ce2af37..f1e60b52 100644 --- a/sbe/hwpf/include/fapi2_hw_access.H +++ b/sbe/hwpf/include/fapi2_hw_access.H @@ -91,8 +91,9 @@ namespace fapi2 /// @param[out] o_data Buffer that holds data read from HW target. /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. template< TargetType K > + __attribute__((always_inline)) inline ReturnCode getScom(const Target& i_target, const uint64_t i_address, - buffer& o_data); + buffer& o_data); /// @brief Writes a SCOM register on a chip. /// @tparam K template parameter, passed in target. @@ -101,8 +102,9 @@ namespace fapi2 /// @param[in] i_data Buffer that holds data to write into address. /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. template< TargetType K > + __attribute__((always_inline)) inline ReturnCode putScom(const Target& i_target, const uint64_t i_address, - const buffer i_data); + const buffer i_data); /// @brief Writes a SCOM register under mask on a chip /// @tparam K template parameter, passed in target. diff --git a/sbe/hwpf/include/hw_access.H b/sbe/hwpf/include/hw_access.H index af688421..00079797 100644 --- a/sbe/hwpf/include/hw_access.H +++ b/sbe/hwpf/include/hw_access.H @@ -100,6 +100,7 @@ namespace fapi2 /// @param[out] o_data Buffer that holds data read from HW target. /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. template< TargetType K > + __attribute__((always_inline)) inline ReturnCode getScom(const Target& i_target, const uint64_t i_address, buffer& o_data) { @@ -119,6 +120,7 @@ namespace fapi2 /// @param[in] i_data Buffer that holds data to write into address. /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. template< TargetType K > + __attribute__((always_inline)) inline ReturnCode putScom(const Target& i_target, const uint64_t i_address, const buffer i_data) { diff --git a/sbe/image/img_defs.mk b/sbe/image/img_defs.mk index 339b10d0..ba883473 100644 --- a/sbe/image/img_defs.mk +++ b/sbe/image/img_defs.mk @@ -213,6 +213,11 @@ GCC-O-LEVEL = -Os endif endif +FAPI_TRACE_LEVEL_DEF = 3 +ifdef FAPI_TRACE_LEVEL_ENV +FAPI_TRACE_LEVEL_DEF = $(FAPI_TRACE_LEVEL_ENV) +endif + GCC-DEFS += -DIMAGE_NAME=$(IMAGE_SEEPROM_NAME) GCC-DEFS += -DPK_TIMER_SUPPORT=$(PK_TIMER_SUPPORT) GCC-DEFS += -DPK_THREAD_SUPPORT=$(PK_THREAD_SUPPORT) @@ -223,6 +228,7 @@ GCC-DEFS += -D__PK__=1 GCC-DEFS += -D__SBE__=1 GCC-DEFS += -D__PPE__=1 GCC-DEFS += -DFAPI2_NO_FFDC=1 +GCC-DEFS += -DFAPI_TRACE_LEVEL=$(FAPI_TRACE_LEVEL_DEF) # use the default settings in the code unless a size is defined ifdef PK_TRACE_SZ GCC-DEFS += -DPK_TRACE_SZ=$(PK_TRACE_SZ) diff --git a/sbe/sbefw/sbeSpMsg.H b/sbe/sbefw/sbeSpMsg.H index 57a00f98..8c021184 100644 --- a/sbe/sbefw/sbeSpMsg.H +++ b/sbe/sbefw/sbeSpMsg.H @@ -88,7 +88,7 @@ typedef struct sbeResponseFfdc { uint32_t magicBytes:16; uint32_t lenInWords:16; // length in word( 4 byte ) - uint32_t hiFapiRc; + uint32_t hiFapiRc; // Unused since FAPI RC is 32 bit on the SBE uint32_t lowFapiRc; /** @@ -98,10 +98,9 @@ typedef struct sbeResponseFfdc * * @return */ - void setRc(const uint64_t i_rc) + void setRc(const uint32_t i_rc) { - lowFapiRc = uint32_t(i_rc); - hiFapiRc = uint32_t(i_rc>>32); + lowFapiRc = i_rc; } /** @@ -109,10 +108,9 @@ typedef struct sbeResponseFfdc * * @return fapiRc */ - uint64_t getRc() + uint32_t getRc() { - uint64_t temp = ( (uint64_t)hiFapiRc << 32) | lowFapiRc; - return temp; + return lowFapiRc; } /** diff --git a/tools/scripts/ppeCreateAttrGetSetMacros.pl b/tools/scripts/ppeCreateAttrGetSetMacros.pl index 7ac64372..c5f4a61f 100755 --- a/tools/scripts/ppeCreateAttrGetSetMacros.pl +++ b/tools/scripts/ppeCreateAttrGetSetMacros.pl @@ -33,7 +33,6 @@ my %targetMacros; my $fapiAttributeIdsFile = "fapi2AttributeIds.H"; my $fapiPlatAttributeServiceFile= "fapi2PlatAttributeService.H"; -my $fapiPlatAttributeServiceImpl= "fapi2PlatAttributeService.C"; my $includePath = "./"; @@ -263,7 +262,7 @@ for my $attribute (sort keys %{$enums{AttributeId}}) { if(defined $targetMacro) { - my $targetFunction = "template<> void __get ( const fapi2::Target& i_ptarget, const fapi2attr::$macroTarget* object, const fapi2::AttributeId attrid, $type* o_pvalue )"; + my $targetFunction = "template<> inline void __get ( const fapi2::Target& i_ptarget, const fapi2attr::$macroTarget* object, const fapi2::AttributeId attrid, $type* o_pvalue )"; push(@newTargetDefines, $targetFunction . ";"); my $targetImplementation = ""; @@ -291,7 +290,7 @@ $targetImplementation .= "\n" . $targetFunction . "\n{\n uint32_t index = i_pt if(defined $targetMacro) { - my $targetFunction = "template<> void __set ( const fapi2::Target& i_ptarget, fapi2attr::$macroTarget* object, const fapi2::AttributeId attrid, const $type& i_pvalue )"; + my $targetFunction = "template<> inline void __set ( const fapi2::Target& i_ptarget, fapi2attr::$macroTarget* object, const fapi2::AttributeId attrid, const $type& i_pvalue )"; push(@newTargetDefines, $targetFunction . ";"); my $targetImplementation = ""; @@ -339,6 +338,36 @@ if (@newAttributeDefines != 0) { foreach my $targetDefine (@newTargetDefines) { print OUTFILE "$targetDefine\n"; if ($VERBOSE) { print "INFO:: adding getter setter method\n"; } + } + print OUTFILE " + __attribute__((always_inline)) inline uint32_t getPervAttrIndex(const fapi2::Target &i_target) + { + uint32_t l_index = i_target.getTargetNumber(); + if(TARGET_TYPE_EQ & i_target.getTargetType()) + { + l_index += (EQ_TARGET_OFFSET); + } + else if(TARGET_TYPE_CORE & i_target.getTargetType()) + { + l_index += (CORE_TARGET_OFFSET); + } + else if(TARGET_TYPE_MCS & i_target.getTargetType()) + { + l_index += (MCS_TARGET_OFFSET); + } + else + { + l_index += (NEST_GROUP1_TARGET_OFFSET); + } + return (l_index - NEST_GROUP1_TARGET_OFFSET); + } + "; + + + foreach my $impl (@newTargetImplementations) { + + print OUTFILE $impl; + } } @@ -355,53 +384,6 @@ if (@newAttributeDefines != 0) { # copy new file over the old one system("mv $updatedFapiPlatAttributeServiceFile $includePath/$fapiPlatAttributeServiceFile"); } - - - my $updatedFapiPlatAttributeServiceImpl = $srcPath . "/" . $fapiPlatAttributeServiceImpl; - open (OUTFILE, ">$updatedFapiPlatAttributeServiceImpl") or die "ERROR:: could not open $updatedFapiPlatAttributeServiceImpl\n"; - - print OUTFILE "// $fapiPlatAttributeServiceImpl\n"; - print OUTFILE "// This file is generated by perl script ppeCreateAttrGetSetMacros.pl\n\n"; - - print OUTFILE "#include \n"; - print OUTFILE "#include \n"; - print OUTFILE "#include \"proc_sbe_fixed.H\"\n"; - print OUTFILE "#include \"plat_target_parms.H\"\n\n"; - print OUTFILE "namespace fapi2 {\n"; - print OUTFILE " -uint32_t getPervAttrIndex(const fapi2::Target &i_target) -{ - uint32_t l_index = i_target.getTargetNumber(); - if(TARGET_TYPE_EQ & i_target.getTargetType()) - { - l_index += (EQ_TARGET_OFFSET); - } - else if(TARGET_TYPE_CORE & i_target.getTargetType()) - { - l_index += (CORE_TARGET_OFFSET); - } - else if(TARGET_TYPE_MCS & i_target.getTargetType()) - { - l_index += (MCS_TARGET_OFFSET); - } - else - { - l_index += (NEST_GROUP1_TARGET_OFFSET); - } - return (l_index - NEST_GROUP1_TARGET_OFFSET); -} -"; - - foreach my $impl (@newTargetImplementations) { - - print OUTFILE $impl; - - } - - print OUTFILE "\n} // namespace fapi2\n"; - - - close (OUTFILE); } -- cgit v1.2.1