diff options
-rw-r--r-- | src/include/usr/vpd/vpd_if.H | 27 | ||||
-rw-r--r-- | src/usr/fsi/fsipres.C | 129 | ||||
-rw-r--r-- | src/usr/vpd/cvpd.C | 14 | ||||
-rw-r--r-- | src/usr/vpd/ipvpd.C | 149 | ||||
-rw-r--r-- | src/usr/vpd/ipvpd.H | 33 | ||||
-rw-r--r-- | src/usr/vpd/mvpd.C | 10 |
6 files changed, 199 insertions, 163 deletions
diff --git a/src/include/usr/vpd/vpd_if.H b/src/include/usr/vpd/vpd_if.H index 6e36eddbd..6c216edcf 100644 --- a/src/include/usr/vpd/vpd_if.H +++ b/src/include/usr/vpd/vpd_if.H @@ -5,7 +5,9 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* COPYRIGHT International Business Machines Corp. 2013,2014 */ +/* Contributors Listed Below - COPYRIGHT 2013,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. */ @@ -23,6 +25,7 @@ #if !defined(__VPD_IF_H) #define __VPD_IF_H + namespace VPD { /** @@ -31,5 +34,25 @@ namespace VPD * @return error handle if there was an error */ errlHndl_t vpd_load_rt_image(uint64_t & o_vpd_addr); -}; + + /** + * @brief this function checks to see if the given mvpd target + * is present + * + * @param[in] i_target - Target device to search for mvpd + * + * @return bool - true if mvpd is present, false if it is not. + */ + bool mvpdPresent ( TARGETING::Target * i_target ); + + /** + * @brief this function checks to see if the given cvpd target + * is present + * + * @param[in] i_target - Target device to search for cvpd + * + * @return bool - true if cvpd is present, false if it is not. + */ + bool cvpdPresent ( TARGETING::Target * i_target ); +}; //end vpd namespace #endif diff --git a/src/usr/fsi/fsipres.C b/src/usr/fsi/fsipres.C index c4ac77ce0..dfc74c6a6 100644 --- a/src/usr/fsi/fsipres.C +++ b/src/usr/fsi/fsipres.C @@ -29,6 +29,7 @@ #include <fsi/fsi_reasoncodes.H> #include <vpd/mvpdenums.H> #include <vpd/cvpdenums.H> +#include <vpd/vpd_if.H> #include <errl/errlmanager.H> #include <hwas/common/hwasCallout.H> #include <targeting/common/predicates/predicatectm.H> @@ -68,7 +69,6 @@ errlHndl_t procPresenceDetect(DeviceFW::OperationType i_opType, va_list i_args) { errlHndl_t l_errl = NULL; - uint32_t l_saved_plid = 0; if (unlikely(io_buflen < sizeof(bool))) { @@ -115,64 +115,10 @@ errlHndl_t procPresenceDetect(DeviceFW::OperationType i_opType, #endif // CONFIG_MVPD_READ_FROM_HW bool mvpd_present = false; - size_t theSize = 0; if ( check_for_mvpd ) { - l_errl = deviceRead( i_target, - NULL, - theSize, - DEVICE_MVPD_ADDRESS( MVPD::CP00, - MVPD::VD ) ); - if( l_errl ) - { - if( fsi_present ) - { - // Save this plid to use later - l_saved_plid = l_errl->plid(); - - // commit this log because we expected to have VPD - errlCommit( l_errl, - FSI_COMP_ID ); - } - else - { - // just delete this - delete l_errl; - } - } - - if( theSize > 0 ) - { - uint8_t theData[theSize]; - l_errl = deviceRead( i_target, - theData, - theSize, - DEVICE_MVPD_ADDRESS( MVPD::CP00, - MVPD::VD ) ); - if( l_errl ) - { - if( fsi_present ) - { - - // Save this plid to use later - l_saved_plid = l_errl->plid(); - - // commit this log because we expected to have VPD - errlCommit( l_errl, - FSI_COMP_ID ); - } - else - { - // just delete this - delete l_errl; - } - } - else - { - mvpd_present = true; - } - } + mvpd_present = VPD::mvpdPresent( i_target ); } @@ -206,11 +152,6 @@ errlHndl_t procPresenceDetect(DeviceFW::OperationType i_opType, HWAS::NO_DECONFIG, HWAS::GARD_NULL ); - // if there is a saved PLID, apply it to this error log - if (l_saved_plid) - { - l_errl->plid(l_saved_plid); - } // Add FFDC for the target to an error log getFsiFFDC( FFDC_PRESENCE_FAIL, l_errl, i_target); @@ -259,7 +200,6 @@ errlHndl_t membPresenceDetect(DeviceFW::OperationType i_opType, va_list i_args) { errlHndl_t l_errl = NULL; - uint32_t l_saved_plid = 0; if (unlikely(io_buflen < sizeof(bool))) { @@ -293,66 +233,10 @@ errlHndl_t membPresenceDetect(DeviceFW::OperationType i_opType, #endif // CONFIG_CVPD_READ_FROM_HW bool cvpd_present = false; - size_t theSize = 0; - + if ( check_for_cvpd ) { - l_errl = deviceRead( i_target, - NULL, - theSize, - DEVICE_CVPD_ADDRESS( CVPD::VEIR, - CVPD::PF ) ); - - if( l_errl ) - { - - if( fsi_present ) - { - // Save this plid to use later - l_saved_plid = l_errl->plid(); - - // commit this log because we expected to have VPD - errlCommit( l_errl, - FSI_COMP_ID ); - } - else - { - // just delete this - delete l_errl; - } - } - - if( theSize > 0 ) - { - uint8_t theData[theSize]; - l_errl = deviceRead( i_target, - theData, - theSize, - DEVICE_CVPD_ADDRESS( CVPD::VEIR, - CVPD::PF ) ); - if( l_errl ) - { - - if( fsi_present ) - { - // Save this plid to use later - l_saved_plid = l_errl->plid(); - - // commit this log because we expected to have VPD - errlCommit( l_errl, - FSI_COMP_ID ); - } - else - { - // just delete this - delete l_errl; - } - } - else - { - cvpd_present = true; - } - } + cvpd_present = VPD::cvpdPresent( i_target ); } // Finally compare the 2 methods @@ -386,11 +270,6 @@ errlHndl_t membPresenceDetect(DeviceFW::OperationType i_opType, HWAS::NO_DECONFIG, HWAS::GARD_NULL ); - // if there is a saved PLID, apply it to this error log - if (l_saved_plid) - { - l_errl->plid(l_saved_plid); - } // Add FFDC for the target to an error log getFsiFFDC( FFDC_PRESENCE_FAIL, l_errl, i_target); diff --git a/src/usr/vpd/cvpd.C b/src/usr/vpd/cvpd.C index a21eaaa62..4abc9bdf8 100644 --- a/src/usr/vpd/cvpd.C +++ b/src/usr/vpd/cvpd.C @@ -36,6 +36,7 @@ #include <vfs/vfs.H> #include <vpd/vpdreasoncodes.H> #include <vpd/cvpdenums.H> +#include <vpd/vpd_if.H> #include <config.h> #include "cvpd.H" #include "vpd.H" @@ -183,6 +184,19 @@ namespace CVPD }; // end namespace CVPD +// -------------------------------------------------------- +// Presence Detection +//--------------------------------------------------------- +bool VPD::cvpdPresent( TARGETING::Target * i_target ) +{ + return Singleton<CvpdFacade>::instance().hasVpdPresent( i_target, + CVPD::VEIR, + CVPD::PF ); +} + + + + //CVPD Class Functions /** * @brief Constructor diff --git a/src/usr/vpd/ipvpd.C b/src/usr/vpd/ipvpd.C index 22504f672..ed61de47a 100644 --- a/src/usr/vpd/ipvpd.C +++ b/src/usr/vpd/ipvpd.C @@ -38,6 +38,7 @@ #include <i2c/eepromif.H> #include <vfs/vfs.H> #include <vpd/vpdreasoncodes.H> +#include <vpd/vpd_if.H> #include <config.h> #include "vpd.H" @@ -429,23 +430,76 @@ errlHndl_t IpVpdFacade::findRecordOffset ( const char * i_record, return NULL; } + + // ------------------------------------------------------------------ -// IpVpdFacade::findRecordOffsetPnor +// IpVpdFacade::hasVpdPresent // ------------------------------------------------------------------ -errlHndl_t IpVpdFacade::findRecordOffsetPnor ( const char * i_record, - uint16_t & o_offset, - TARGETING::Target * i_target, - input_args_t i_args ) +bool IpVpdFacade::hasVpdPresent( TARGETING::Target * i_target, + uint64_t i_record, + uint64_t i_keyword ) +{ + errlHndl_t err = NULL; + uint16_t recordOffset = 0x0; + input_args_t i_args; + bool vpdPresent = false; + const char * recordName = NULL; + const char * keywordName = NULL; + + i_args.record = i_record; + i_args.keyword = i_keyword; + + do + { + //get the Recod/Keyword names + err = translateRecord( i_args.record, + recordName ); + + if( err ) + { + TRACFCOMP( g_trac_vpd, ERR_MRK"Error occured during translateRecord\ + - IpVpdFacade::hasVpdPresent"); + break; + } + + err = translateKeyword( i_args.keyword, + keywordName ); + + if( err ) + { + TRACFCOMP( g_trac_vpd, ERR_MRK"Error occured during \ + translateKeyword - IpVpdFacade::hasVpdPresent" ); + break; + } + + vpdPresent = recordPresent( recordName, + recordOffset, + i_target ); + + }while( 0 ); + + if( err ) + { + errlCommit( err, VPD_COMP_ID ); + return false; + } + + + return vpdPresent; +} + +// ------------------------------------------------------------------ +// IpVpdFacade::recordPresent +// ------------------------------------------------------------------ +bool IpVpdFacade::recordPresent( const char * i_record, + uint16_t & o_offset, + TARGETING::Target * i_target ) { errlHndl_t err = NULL; uint64_t tmpOffset = 0x0; char record[RECORD_BYTE_SIZE] = { '\0' }; - uint16_t offset = 0x0; bool matchFound = false; - TRACSSCOMP( g_trac_vpd, - ENTER_MRK"IpVpdFacade::findRecordOffset()" ); - do { // -------------------------------------- @@ -462,50 +516,73 @@ errlHndl_t IpVpdFacade::findRecordOffsetPnor ( const char * i_record, while( ( tmpOffset < IPVPD_TOC_SIZE ) && !matchFound ) { - TRACDCOMP( g_trac_vpd, - INFO_MRK"IpVpdFacade::findRecordOffset: read offset: 0x%08x", - tmpOffset ); - - // Read Record Name - err = fetchData( tmpOffset, - RECORD_BYTE_SIZE, - record, - i_target ); - tmpOffset += RECORD_BYTE_SIZE; - - if( err ) - { - break; - } - - if( !(memcmp( record, i_record, RECORD_BYTE_SIZE )) ) - { - matchFound = true; - - // Read the matching records offset + //Read Record Name err = fetchData( tmpOffset, - RECORD_ADDR_BYTE_SIZE, - &offset, + RECORD_BYTE_SIZE, + record, i_target ); + tmpOffset += RECORD_BYTE_SIZE; if( err ) { break; } - } - tmpOffset += (RECORD_ADDR_BYTE_SIZE + RECORD_TOC_UNUSED); + + if( !(memcmp(record, i_record, RECORD_BYTE_SIZE )) ) + { + matchFound = true; + + // Read the matching record's offset + err = fetchData( tmpOffset, + RECORD_ADDR_BYTE_SIZE, + &o_offset, + i_target ); + if( err ) + { + break; + } + } + tmpOffset += (RECORD_ADDR_BYTE_SIZE + RECORD_TOC_UNUSED); } if( err ) { break; } - } while( 0 ); + }while( 0 ); + + if( err ) + { + errlCommit( err, VPD_COMP_ID ); + return false; + } + return matchFound; +} + +// ------------------------------------------------------------------ +// IpVpdFacade::findRecordOffsetPnor +// ------------------------------------------------------------------ +errlHndl_t IpVpdFacade::findRecordOffsetPnor ( const char * i_record, + uint16_t & o_offset, + TARGETING::Target * i_target, + input_args_t i_args ) +{ + errlHndl_t err = NULL; + uint16_t offset = 0x0; + bool matchFound = false; + + TRACSSCOMP( g_trac_vpd, + ENTER_MRK"IpVpdFacade::findRecordOffset()" ); + + matchFound = recordPresent( i_record, + offset, + i_target ); if( !matchFound ) { TRACFCOMP( g_trac_vpd, - ERR_MRK"IpVpdFacade::findRecordOffset: No matching Record (%s) found in TOC!", + ERR_MRK"IpVpdFacade::findRecordOffset: No matching\ + Record (%s) found in TOC!", i_record ); /*@ diff --git a/src/usr/vpd/ipvpd.H b/src/usr/vpd/ipvpd.H index 95f110ef0..d59e84608 100644 --- a/src/usr/vpd/ipvpd.H +++ b/src/usr/vpd/ipvpd.H @@ -28,6 +28,7 @@ #include <pnor/pnorif.H> +#include <devicefw/driverif.H> #include "vpd.H" /** @file ipvpd.H @@ -209,6 +210,19 @@ class IpVpdFacade size_t & io_buflen, input_args_t i_args ); + /** + * @brief this function checks to see if the given target + * is present. + * + * @param[in] i_target - target VPD to search for. + * + * @return - bool - true if vpd is present, false if it is not. + */ + bool hasVpdPresent ( TARGETING::Target * i_target, + uint64_t record, + uint64_t keyword ); + + protected: /** @@ -262,6 +276,25 @@ class IpVpdFacade input_args_t i_args ); /** + * @brief This function searches for the VPD record and returns + * True if it is there, False otherwise. This function works similarly + * to findRecordOffsetPnor except it does not create error logs if + * the record was not found. This will replace some of the code in + * findRecordOffsetPnor + * + * @param[in] i_record - String value for the record to look for. + * + * @param[out] offset - The offset where the record is located. + * + * @param[in] i_target - The target to retrieve the data for. + * + * @return bool - True if the record is found, False otherwise. + */ + bool recordPresent( const char * i_record, + uint16_t & offset, + TARGETING::Target * i_target ); + + /** * @brief This function will read the VPD TOC to find the offset where the * given record is located within the chunk of data. * diff --git a/src/usr/vpd/mvpd.C b/src/usr/vpd/mvpd.C index b9d411298..0e9801984 100644 --- a/src/usr/vpd/mvpd.C +++ b/src/usr/vpd/mvpd.C @@ -36,6 +36,7 @@ #include <vfs/vfs.H> #include <vpd/vpdreasoncodes.H> #include <vpd/mvpdenums.H> +#include <vpd/vpd_if.H> #include <config.h> #include "mvpd.H" @@ -179,6 +180,15 @@ namespace MVPD }; // end MVPD namespace +// --------------------------------------------------------- +// Presence Detection +// --------------------------------------------------------- +bool VPD::mvpdPresent( TARGETING::Target * i_target ) +{ + return Singleton<MvpdFacade>::instance().hasVpdPresent( i_target, + MVPD::CP00, + MVPD::VD ); +} //MVPD Class Functions |