Skip to content

Commit

Permalink
Fix tracing for Bootloader hangs if it can't find first TOC
Browse files Browse the repository at this point in the history
Limit how many traces are done by recovery loop that walks back
through PNOR to find a valid TOC.
Use page aligned MMIO addresses.

Change-Id: Icdd41fe36fc597769af57d54049c3e457b790594
RTC: 175243
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/41398
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Reviewed-by: Matt Derksen <mderkse1@us.ibm.com>
Reviewed-by: Corey V. Swenson <cswenson@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
mgloff authored and dcrowell77 committed Jun 15, 2017
1 parent cf636ad commit 74ca835
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 2 deletions.
27 changes: 27 additions & 0 deletions src/bootloader/bl_pnorAccess.C
Expand Up @@ -27,6 +27,7 @@
#include <bootloader/bootloader_trace.H>
#include <bootloader/hbblreasoncodes.H>
#include <util/singleton.H>
#include <util/align.H>
#include <bootloader/bootloader.H>
#include <lpc_const.H>
#ifdef PNORUTILSTEST_H
Expand Down Expand Up @@ -196,6 +197,7 @@ void bl_pnorAccess::findTOC(uint64_t i_pnorEnd, PNOR::SectionData_t * o_TOC,

//The first TOC is 1 TOC size + 1 page back from the end of the flash (+ 1)
uint64_t l_mmioAddr = i_pnorEnd - PNOR::TOC_OFFSET_FROM_TOP_OF_FLASH;
l_mmioAddr = ALIGN_PAGE_DOWN(l_mmioAddr);

do
{
Expand Down Expand Up @@ -224,12 +226,37 @@ void bl_pnorAccess::findTOC(uint64_t i_pnorEnd, PNOR::SectionData_t * o_TOC,
// Use PNOR start address for next MMIO
BOOTLOADER_TRACE(BTLDR_TRC_PA_FINDTOC_USE_PNOR_START);
l_mmioAddr = o_pnorStart;

// Reset saved trace index
Bootloader::g_blData->bl_trace_index_saved =
BOOTLOADER_TRACE_SIZE;
}
else
{
// Check if a trace index is not saved
if(Bootloader::g_blData->bl_trace_index_saved >=
BOOTLOADER_TRACE_SIZE)
{
// Save trace index for future passes through loop
Bootloader::g_blData->bl_trace_index_saved =
Bootloader::g_blData->bl_trace_index;

// Save this PNOR MMIO address
Bootloader::g_blData->bl_first_pnor_mmio = l_mmioAddr;
}
else // A trace index was saved
{
// Replace trace index, reuse trace entries for this loop
Bootloader::g_blData->bl_trace_index =
Bootloader::g_blData->bl_trace_index_saved;
}

// Adjust to new location in PNOR flash for next MMIO
BOOTLOADER_TRACE(BTLDR_TRC_PA_FINDTOC_ADJUST_PNOR_ADDR);
l_mmioAddr -= PAGESIZE;

// Increment loop counter
Bootloader::g_blData->bl_pnor_loop_count++;
}

// Check that address is still in FW space
Expand Down
1 change: 1 addition & 0 deletions src/bootloader/bootloader.C
Expand Up @@ -280,6 +280,7 @@ namespace Bootloader{
// Initialization
g_blData = reinterpret_cast<blData_t *>(HBBL_DATA_ADDR);
g_blData->bl_trace_index = 0;
g_blData->bl_trace_index_saved = BOOTLOADER_TRACE_SIZE;
BOOTLOADER_TRACE(BTLDR_TRC_MAIN_START);

//Set core scratch 3 to say bootloader is active
Expand Down
36 changes: 36 additions & 0 deletions src/build/debug/Hostboot/BlData.pm
Expand Up @@ -104,6 +104,42 @@ sub main
::userDisplay "\n\n--------------------------------------------\n";


my $savedAddr = $dataAddr + 66;
my $savedAddrStr = sprintf("0x%08X", $savedAddr);
my $saved = ::read8($savedAddr);
my $savedStr = sprintf("0x%02X", $saved);

::userDisplay "\nSaved Trace Index Address: ";
::userDisplay $savedAddrStr;
::userDisplay "\n\nSaved Trace Index: ";
::userDisplay $savedStr;
::userDisplay "\n\n--------------------------------------------\n";


my $loopCntAddr = $dataAddr + 68;
my $loopCntAddrStr = sprintf("0x%08X", $loopCntAddr);
my $loopCnt = ::read32($loopCntAddr);
my $loopCntStr = sprintf("0x%08X", $loopCnt);

::userDisplay "\nPNOR Loop Counter Address: ";
::userDisplay $loopCntAddrStr;
::userDisplay "\n\nPNOR Loop Counter: ";
::userDisplay $loopCntStr;
::userDisplay "\n\n--------------------------------------------\n";


my $pnorMmioAddr = $dataAddr + 72;
my $pnorMmioAddrStr = sprintf("0x%08X", $pnorMmioAddr);
my $pnorMmio = ::read64($pnorMmioAddr);
my $pnorMmioStr = sprintf("0x%016llX", $pnorMmio);

::userDisplay "\nFirst PNOR MMIO Address: ";
::userDisplay $pnorMmioAddrStr;
::userDisplay "\n\nFirst PNOR MMIO: ";
::userDisplay $pnorMmioStr;
::userDisplay "\n\n--------------------------------------------\n";


my $tiDataAreaAddr = $dataAddr + 80;
my $tiDataAreaAddrStr = sprintf("0x%08X", $tiDataAreaAddr);
::sendIPCMsg("read-data", "$tiDataAreaAddr,48"); # TI Data Area is 48 bytes
Expand Down
20 changes: 18 additions & 2 deletions src/include/bootloader/bootloader_data.H
Expand Up @@ -53,7 +53,23 @@ namespace Bootloader{
// @brief Index for Bootloader Trace entries
// One-byte index for next entry to use in bootloader_trace.
uint8_t bl_trace_index;
uint8_t bl_reserved1[15];
uint8_t bl_reserved1[1];

// @name bl_trace_index_saved
// @brief Saved index for Bootloader Trace entries
// One-byte index for a saved bootloader_trace entry.
uint8_t bl_trace_index_saved;
uint8_t bl_reserved2[1];

// @name bl_pnor_loop_count
// @brief Bootloader loop counter
// Counter for loop that walks PNOR to find a valid TOC.
uint32_t bl_pnor_loop_count;

// @name bl_first_pnor_mmio
// @brief Address used by first PNOR MMIO
// Address used on first attempt to read TOC from PNOR.
uint64_t bl_first_pnor_mmio;

// Instance of the TI Data Area
HB_TI_DataArea bl_TIDataArea;
Expand All @@ -63,7 +79,7 @@ namespace Bootloader{

// Bool indicating if the secureROM is valid. Toggles verification.
bool secureRomValid;
uint8_t bl_reserved2[15];
uint8_t bl_reserved3[15];

// Object that will be stored where the SBE HB structure indicates
BlToHbData blToHbData;
Expand Down

0 comments on commit 74ca835

Please sign in to comment.