Skip to content

Commit

Permalink
Use XSCOM BAR from Bootloader instead of hardcoded value
Browse files Browse the repository at this point in the history
The memory map can be modified by the SBE such that the XSCOM
BAR is not in the default location.  The BAR value is passed up
through the bootloader into hostboot.

Change-Id: I469b7534d384bce4bb8c72f7cd78d0075ac04632
RTC: 173519
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/41140
Reviewed-by: Martin Gloff <mgloff@us.ibm.com>
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: Christian R. Geddes <crgeddes@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
dcrowell77 committed Jun 7, 2017
1 parent 47f3435 commit e9489e7
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/include/kernel/bltohbdatamgr.H
Expand Up @@ -27,7 +27,6 @@
#define __BLTOHBDATAMANAGER_H

#include <stdint.h>
#include <sys/mm.h>
#include <bootloader/bootloaderif.H>

// BlToHbDataManager class
Expand Down
40 changes: 40 additions & 0 deletions src/include/usr/xscom/xscomif.H
@@ -0,0 +1,40 @@
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/include/usr/xscom/xscomif.H $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2017 */
/* [+] 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. */
/* You may obtain a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
/* implied. See the License for the specific language governing */
/* permissions and limitations under the License. */
/* */
/* IBM_PROLOG_END_TAG */
#ifndef __XSCOMIF_H
#define __XSCOMIF_H

namespace XSCOM
{

/**
* @brief Return the value of the XSCOM BAR that the driver is using
* @return XSCOM BAR physical address
*/
uint64_t get_master_bar( void );


}; // namespace XSCOM

#endif // end __XSCOMIF_H
10 changes: 9 additions & 1 deletion src/usr/targeting/targetservicestart.C
Expand Up @@ -62,6 +62,7 @@
#include <map>
#include <arch/memorymap.H>
#include <lpc/lpcif.H>
#include <xscom/xscomif.H>

#ifdef CONFIG_DRTM
#include <secureboot/drtm.H>
Expand Down Expand Up @@ -597,7 +598,14 @@ static void adjustMemoryMap( TargetService& i_targetService )
LPC::get_lpc_bar() );
TARG_ASSERT( true, "LPC BARs are inconsistent" );
}
//@todo-RTC:173519-Add xscom cross-check
if( l_pMasterProcChip->getAttr<ATTR_XSCOM_BASE_ADDRESS>()
!= XSCOM::get_master_bar() )
{
TARG_ERR( "XSCOM attribute=%.16llX, live=%.16llX",
l_pMasterProcChip->getAttr<ATTR_XSCOM_BASE_ADDRESS>(),
XSCOM::get_master_bar() );
TARG_ASSERT( true, "XSCOM BARs are inconsistent" );
}
}


Expand Down
25 changes: 16 additions & 9 deletions src/usr/xscom/xscom.C
Expand Up @@ -48,6 +48,9 @@
#include <xscom/piberror.H>
#include <arch/pirformat.H>
#include <lpc/lpcif.H>
#include <sys/mm.h>
#include <kernel/bltohbdatamgr.H>
#undef HMER // from securerom/ROM.H

// Trace definition
trace_desc_t* g_trac_xscom = NULL;
Expand Down Expand Up @@ -321,8 +324,8 @@ errlHndl_t getTargetVirtualAddress(TARGETING::Target* i_target,


// If the virtual address equals NULL(default) then this is the
// first XSCOM to this target so we need to calculate
// the virtual address and save it in the xscom address attribute.
// first XSCOM to this target so we need to map in the appropriate
// address
if (o_virtAddr == NULL)
{
uint64_t xscomGroupId = 0;
Expand Down Expand Up @@ -522,13 +525,8 @@ uint64_t* getCpuIdVirtualAddress( XSComBase_t& o_mmioAddr )
{
uint64_t* o_virtAddr = 0;

// Get the CPU core this thread is running on
PIR_t cpuid = task_getcpuid();

// Target's XSCOM Base address
o_mmioAddr = MASTER_PROC_XSCOM_BASE_ADDR +
(MMIO_OFFSET_PER_GROUP * cpuid.groupId) +
(MMIO_OFFSET_PER_GROUP * cpuid.chipId);
// Read the MMIO setup by the SBE
o_mmioAddr = g_BlToHbDataManager.getXscomBAR();

// Target's virtual address
o_virtAddr = static_cast<uint64_t*>
Expand Down Expand Up @@ -843,4 +841,13 @@ errlHndl_t xscomPerformOp(DeviceFW::OperationType i_opType,
return l_err;
}

/**
* @brief Return the value of the XSCOM BAR that the driver is using
*/
uint64_t get_master_bar( void )
{
return mm_virt_to_phys(g_masterProcVirtAddr);
}


} // end namespace
5 changes: 0 additions & 5 deletions src/usr/xscom/xscom.H
Expand Up @@ -33,11 +33,6 @@
#include <limits.h>
#include <arch/memorymap.H>

/**
* @brief The (fixed) base address value for master proc
*/
constexpr uint64_t MASTER_PROC_XSCOM_BASE_ADDR = 0x000603FC00000000;

/**
* @brief Type definition for XSCom address and Base
*/
Expand Down

0 comments on commit e9489e7

Please sign in to comment.