diff options
author | Prachi Gupta <pragupta@us.ibm.com> | 2015-01-23 14:18:43 -0600 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2015-02-24 15:36:10 -0600 |
commit | b908135a569ed584b12262a020664d0150e4d933 (patch) | |
tree | 695a74c1598415beefc984d27f8a7fd9713ccf2f /src/usr/pnor/pnor_common.C | |
parent | b03dc1b8e4b20a8039775e474bd9ebf2503bf48c (diff) | |
download | talos-hostboot-b908135a569ed584b12262a020664d0150e4d933.tar.gz talos-hostboot-b908135a569ed584b12262a020664d0150e4d933.zip |
determine the toc locations in pnorrp and rt_pnor code
RTC: 120733
Change-Id: I5372a102ce9761a514a6f7245ca206a2226f1f3b
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/15456
Tested-by: Jenkins Server
Reviewed-by: STEPHEN M. CPREK <smcprek@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/pnor/pnor_common.C')
-rw-r--r-- | src/usr/pnor/pnor_common.C | 74 |
1 files changed, 73 insertions, 1 deletions
diff --git a/src/usr/pnor/pnor_common.C b/src/usr/pnor/pnor_common.C index c8c1e14b3..6844984e5 100644 --- a/src/usr/pnor/pnor_common.C +++ b/src/usr/pnor/pnor_common.C @@ -91,6 +91,71 @@ uint32_t PNOR::pnor_ffs_checksum(void* data, size_t size) return checksum; } +/* + * @brief determine the physical offset of the ffs entry + * (to be used before readTOC is called) + */ +void PNOR::findPhysicalOffset(ffs_hdr* i_tocAddress, + const char* i_entryName, + uint64_t & o_offset) +{ + for(uint32_t i = 0; i < i_tocAddress->entry_count; i++) + { + ffs_entry* l_curEntry = (&i_tocAddress->entries[i]); + if(strcmp(i_entryName,l_curEntry->name) == 0) + { + o_offset = ((uint64_t)l_curEntry->base)*PAGESIZE; + break; + } + } +} + +/* + * @brief used to translate mmio offset stored in mbox scratch 2 + * to physical offset of HBB Image + */ +errlHndl_t PNOR::mmioToPhysicalOffset(uint64_t& o_hbbAddress) +{ + errlHndl_t l_err = NULL; + do + { + uint64_t l_hbbMMIO = 0; + size_t l_size = sizeof(uint64_t); + TARGETING::Target* l_masterProc = + TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL; + + //MBOX_SCRATCH_REG2 = 0x5003A + l_err = DeviceFW::deviceRead(l_masterProc, &l_hbbMMIO,l_size, + DEVICE_SCOM_ADDRESS(SPLESS::MBOX_SCRATCH_REG2)); + if (l_err) + { + TRACFCOMP(g_trac_pnor,"PNOR::mmioToPhysicalOffset: Failed to read" + " HB MMIO offset"); + break; + } + //All SCOMS are 64-bit, HB MMIO is stored in higher 32-bits. + //ANDing with TOP_OF_FLASH to maskout anything in the higher bits + l_hbbMMIO = (l_hbbMMIO >> 32) & PNOR::LPC_TOP_OF_FLASH_OFFSET; + o_hbbAddress = ((9*l_hbbMMIO) - (9*PNOR::LPC_SFC_MMIO_OFFSET) + - PNOR::PNOR_SIZE) /8; + } while (0); + return l_err; +} + +/* + * @brief used to translate HBB Address to MMIO offset + */ +void PNOR::physicalToMmioOffset(uint64_t i_hbbAddress, + uint64_t& o_mmioOffset) +{ + o_mmioOffset = (PNOR::LPC_SFC_MMIO_OFFSET + i_hbbAddress + + ((PNOR::PNOR_SIZE - i_hbbAddress)/9)) & 0xFFFFFFF; +} + +/* + * @brief: parse the TOCs read from memory and store section information + * from one of the verified TOCs + */ errlHndl_t PNOR::parseTOC(uint8_t* i_toc0Buffer, uint8_t* i_toc1Buffer, TOCS & o_TOC_used, SectionData_t * o_TOC, uint64_t i_baseVAddr) { @@ -398,7 +463,7 @@ errlHndl_t PNOR::parseTOC(uint8_t* i_toc0Buffer, uint8_t* i_toc1Buffer, break; } -# ifndef __HOSTBOOT_RUNTIME +#ifndef __HOSTBOOT_RUNTIME // Handle section permissions if (o_TOC[secId].misc & FFS_MISC_READ_ONLY) { @@ -495,6 +560,13 @@ errlHndl_t PNOR::parseTOC(uint8_t* i_toc0Buffer, uint8_t* i_toc1Buffer, { break; } + if (!TOC_0_failed) + { + //if we find a working TOC we don't need to loop again. + //In runtime case, OPAL returns a working TOC. + //So, we don't want to look at the second one. + break; + } } // For TOC's if (l_errhdl) { |