diff options
author | Christian Geddes <crgeddes@us.ibm.com> | 2019-02-19 22:02:31 -0600 |
---|---|---|
committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2019-03-04 13:57:47 -0600 |
commit | 3452fbd959890a33371a3314412265d7d2b516d0 (patch) | |
tree | dcaf31b4c65b7c5f70e1883a8f509a25f02de794 /src/usr/i2c | |
parent | d505fea7f1690043cd276cbb5dc1311d6cb40c34 (diff) | |
download | talos-hostboot-3452fbd959890a33371a3314412265d7d2b516d0.tar.gz talos-hostboot-3452fbd959890a33371a3314412265d7d2b516d0.zip |
Allow for nullptr io_buffer in eecache read
If the user passes a nullptr as the io_buffer it is assumed that
they want the size of the eeprom they are looking up. So just
return the size in io_buflen. This commit also adds useful debug
traces to the eepromdd.C file.
Change-Id: Ia38c5045e2a8fde331b4801e2e356be5ac6dee22
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/72166
Reviewed-by: Matt Derksen <mderkse1@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/usr/i2c')
-rw-r--r-- | src/usr/i2c/eepromCache.C | 38 | ||||
-rw-r--r-- | src/usr/i2c/eepromCache.H | 6 | ||||
-rwxr-xr-x | src/usr/i2c/eepromdd.C | 2 |
3 files changed, 36 insertions, 10 deletions
diff --git a/src/usr/i2c/eepromCache.C b/src/usr/i2c/eepromCache.C index dc8bb15db..a1231ad98 100644 --- a/src/usr/i2c/eepromCache.C +++ b/src/usr/i2c/eepromCache.C @@ -80,6 +80,17 @@ uint64_t lookupEepromAddr(const eepromRecordHeader& i_eepromRecordHeader) { l_vaddr = l_it->second; } + + if(l_vaddr == 0) + { + TRACSSCOMP( g_trac_eeprom, "lookupEepromAddr() failed to find I2CM Huid: 0x%.08X, Port: 0x%.02X, Engine: 0x%.02X, Dev Addr: 0x%.02X, Mux Select: 0x%.02X, Size: 0x%.08X in g_cachedEeproms", + i_eepromRecordHeader.completeRecord.i2c_master_huid, + i_eepromRecordHeader.completeRecord.port, + i_eepromRecordHeader.completeRecord.engine, + i_eepromRecordHeader.completeRecord.devAddr, + i_eepromRecordHeader.completeRecord.mux_select, + i_eepromRecordHeader.completeRecord.cache_copy_size); + } return l_vaddr; } @@ -647,8 +658,8 @@ DEVICE_REGISTER_ROUTE( DeviceFW::READ, errlHndl_t eepromPerformOpCache(DeviceFW::OperationType i_opType, TARGETING::Target * i_target, - void * io_buffer, - size_t i_buflen, + void * io_buffer, + size_t& io_buflen, eeprom_addr_t &i_eepromInfo) { errlHndl_t l_errl = nullptr; @@ -673,14 +684,25 @@ errlHndl_t eepromPerformOpCache(DeviceFW::OperationType i_opType, // Ensure that a copy of the eeprom exists in our map of cached eeproms if(l_eepromCacheVaddr) { + // First check if io_buffer is a nullptr, if so then assume user is + // requesting size back in io_bufferlen + if(io_buffer == nullptr) + { + io_buflen = l_eepromRecordHeader.completeRecord.cache_copy_size * KILOBYTE; + TRACSSCOMP( g_trac_eeprom, "eepromPerformOpCache() " + "io_buffer == nullptr , returning io_buflen as 0x%lx", + io_buflen); + break; + } + TRACSSCOMP( g_trac_eeprom, "eepromPerformOpCache() " "Performing %s on target 0x%.08X offset 0x%lx length 0x%x vaddr 0x%lx", (i_opType == DeviceFW::READ) ? "READ" : "WRITE", TARGETING::get_huid(i_target), - i_eepromInfo.offset, i_buflen, l_eepromCacheVaddr); + i_eepromInfo.offset, io_buflen, l_eepromCacheVaddr); // Make sure that offset + buflen are less than the total size of the eeprom - if(i_eepromInfo.offset + i_buflen > (l_eepromRecordHeader.completeRecord.cache_copy_size * KILOBYTE)) + if(i_eepromInfo.offset + io_buflen > (l_eepromRecordHeader.completeRecord.cache_copy_size * KILOBYTE)) { TRACFCOMP(g_trac_eeprom, ERR_MRK"eepromPerformOpCache: i_eepromInfo.offset + i_offset is greater than size of eeprom (0x%x KB)", @@ -698,7 +720,7 @@ errlHndl_t eepromPerformOpCache(DeviceFW::OperationType i_opType, ERRORLOG::ERRL_SEV_UNRECOVERABLE, EEPROM_CACHE_PERFORM_OP, EEPROM_OVERFLOW_ERROR, - TO_UINT64(i_buflen), + TO_UINT64(io_buflen), TO_UINT64(i_eepromInfo.offset), ERRORLOG::ErrlEntry::ADD_SW_CALLOUT); ERRORLOG::ErrlUserDetailsTarget(i_target).addToLog(l_errl); @@ -709,18 +731,18 @@ errlHndl_t eepromPerformOpCache(DeviceFW::OperationType i_opType, if(i_opType == DeviceFW::READ) { - memcpy(io_buffer, reinterpret_cast<void *>(l_eepromCacheVaddr + i_eepromInfo.offset), i_buflen); + memcpy(io_buffer, reinterpret_cast<void *>(l_eepromCacheVaddr + i_eepromInfo.offset), io_buflen); } else if(i_opType == DeviceFW::WRITE) { - memcpy(reinterpret_cast<void *>(l_eepromCacheVaddr + i_eepromInfo.offset), io_buffer, i_buflen); + memcpy(reinterpret_cast<void *>(l_eepromCacheVaddr + i_eepromInfo.offset), io_buffer, io_buflen); #ifndef __HOSTBOOT_RUNTIME // Perform flush to ensure pnor is updated int rc = mm_remove_pages( FLUSH, reinterpret_cast<void *>(l_eepromCacheVaddr + i_eepromInfo.offset), - i_buflen ); + io_buflen ); if( rc ) { TRACFCOMP(g_trac_eeprom,ERR_MRK"eepromPerformOpCache: Error from mm_remove_pages trying for flush contents write to pnor! rc=%d",rc); diff --git a/src/usr/i2c/eepromCache.H b/src/usr/i2c/eepromCache.H index 0e0be7368..5cad475ba 100644 --- a/src/usr/i2c/eepromCache.H +++ b/src/usr/i2c/eepromCache.H @@ -46,9 +46,11 @@ namespace EEPROM * device. * OUTPUT: Pointer to the data that was read from the target device. * -* @param[in] i_buflen +* @param[in] io_buflen * INPUT: Length of the buffer to be written to target device or * length of buffer to be read from target device. +* Output: If io_buffer is passed in as nullptr size will be set in +* io_buflen as an out param * * @param [in] i_eepromInfo struct containing information needed to perform * operation on the given i2c eeprom. NOTE It is expected that @@ -62,7 +64,7 @@ namespace EEPROM errlHndl_t eepromPerformOpCache(DeviceFW::OperationType i_opType, TARGETING::Target * i_target, void * io_buffer, - size_t i_buflen, + size_t & io_buflen, eeprom_addr_t &i_eepromInfo); /** diff --git a/src/usr/i2c/eepromdd.C b/src/usr/i2c/eepromdd.C index 7e56aa6b7..74b6d3692 100755 --- a/src/usr/i2c/eepromdd.C +++ b/src/usr/i2c/eepromdd.C @@ -91,10 +91,12 @@ errlHndl_t resolveSource(TARGETING::Target * i_target, // then we know it exists in cache somewhere if(lookupEepromAddr(l_eepromRecordHeader)) { + TRACFCOMP(g_trac_eeprom,"Eeprom found in cache, looking at eecache"); o_source = EEPROM::CACHE; } else { + TRACFCOMP(g_trac_eeprom,"Eeprom not found in cache, looking at hardware"); o_source = EEPROM::HARDWARE; } |