<commit_before>// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.h"

#include "base/utf_string_conversions.h"
#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
#include "chrome/browser/google/google_util.h"
#include "chrome/browser/infobars/infobar_tab_helper.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"

using content::OpenURLParams;
using content::Referrer;
using content::UserMetricsAction;

RegisterProtocolHandlerInfoBarDelegate::RegisterProtocolHandlerInfoBarDelegate(
    InfoBarTabHelper* infobar_helper,
    ProtocolHandlerRegistry* registry,
    const ProtocolHandler& handler)
    : ConfirmInfoBarDelegate(infobar_helper),
      registry_(registry),
      handler_(handler) {
}

bool RegisterProtocolHandlerInfoBarDelegate::ShouldExpire(
    const content::LoadCommittedDetails& details) const {
  // The user has submitted a form, causing the page to navigate elsewhere. We
  // don't want the infobar to be expired at this point, because the user won't
  // get a chance to answer the question.
  return false;
}

InfoBarDelegate::Type
RegisterProtocolHandlerInfoBarDelegate::GetInfoBarType() const {
  return PAGE_ACTION_TYPE;
}

string16 RegisterProtocolHandlerInfoBarDelegate::GetMessageText() const {
  ProtocolHandler old_handler = registry_->GetHandlerFor(handler_.protocol());
  return !old_handler.IsEmpty() ?
      l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM_REPLACE,
          handler_.title(), UTF8ToUTF16(handler_.url().host()),
          GetProtocolName(handler_), old_handler.title()) :
      l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM,
          handler_.title(), UTF8ToUTF16(handler_.url().host()),
          GetProtocolName(handler_));
}

string16 RegisterProtocolHandlerInfoBarDelegate::GetProtocolName(
    const ProtocolHandler& handler) const {
  if (handler.protocol() == "mailto")
    return l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_MAILTO_NAME);
  if (handler.protocol() == "webcal")
    return l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_WEBCAL_NAME);
  return UTF8ToUTF16(handler.protocol());
}

string16 RegisterProtocolHandlerInfoBarDelegate::GetButtonLabel(
    InfoBarButton button) const {
  return (button == BUTTON_OK) ?
      l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_ACCEPT,
                                 handler_.title()) :
      l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_DENY);
}

bool RegisterProtocolHandlerInfoBarDelegate::NeedElevation(
    InfoBarButton button) const {
  return button == BUTTON_OK;
}

bool RegisterProtocolHandlerInfoBarDelegate::Accept() {
  content::RecordAction(
      UserMetricsAction("RegisterProtocolHandler.Infobar_Accept"));
  registry_->OnAcceptRegisterProtocolHandler(handler_);
  return true;
}

bool RegisterProtocolHandlerInfoBarDelegate::Cancel() {
  content::RecordAction(
      UserMetricsAction("RegisterProtocolHandler.InfoBar_Deny"));
  registry_->OnIgnoreRegisterProtocolHandler(handler_);
  return true;
}

string16 RegisterProtocolHandlerInfoBarDelegate::GetLinkText() const {
  return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
}

bool RegisterProtocolHandlerInfoBarDelegate::LinkClicked(
    WindowOpenDisposition disposition) {
  content::RecordAction(
      UserMetricsAction("RegisterProtocolHandler.InfoBar_LearnMore"));
  OpenURLParams params(
      google_util::AppendGoogleLocaleParam(GURL(
          chrome::kLearnMoreRegisterProtocolHandlerURL)),
      Referrer(),
      (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
      content::PAGE_TRANSITION_LINK,
      false);
  owner()->web_contents()->OpenURL(params);
  return false;
}
<commit_msg>Dismiss registerProtocolHandlers infobars on navigation to prevent zombie bars.<commit_after>// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.h"

#include "base/utf_string_conversions.h"
#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
#include "chrome/browser/google/google_util.h"
#include "chrome/browser/infobars/infobar_tab_helper.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"

using content::OpenURLParams;
using content::Referrer;
using content::UserMetricsAction;

RegisterProtocolHandlerInfoBarDelegate::RegisterProtocolHandlerInfoBarDelegate(
    InfoBarTabHelper* infobar_helper,
    ProtocolHandlerRegistry* registry,
    const ProtocolHandler& handler)
    : ConfirmInfoBarDelegate(infobar_helper),
      registry_(registry),
      handler_(handler) {
}

bool RegisterProtocolHandlerInfoBarDelegate::ShouldExpire(
    const content::LoadCommittedDetails& details) const {
  // We expire the infobar on navigation because otherwise we can get multiple
  // infobars stacked up.
  return true;
}

InfoBarDelegate::Type
RegisterProtocolHandlerInfoBarDelegate::GetInfoBarType() const {
  return PAGE_ACTION_TYPE;
}

string16 RegisterProtocolHandlerInfoBarDelegate::GetMessageText() const {
  ProtocolHandler old_handler = registry_->GetHandlerFor(handler_.protocol());
  return !old_handler.IsEmpty() ?
      l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM_REPLACE,
          handler_.title(), UTF8ToUTF16(handler_.url().host()),
          GetProtocolName(handler_), old_handler.title()) :
      l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM,
          handler_.title(), UTF8ToUTF16(handler_.url().host()),
          GetProtocolName(handler_));
}

string16 RegisterProtocolHandlerInfoBarDelegate::GetProtocolName(
    const ProtocolHandler& handler) const {
  if (handler.protocol() == "mailto")
    return l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_MAILTO_NAME);
  if (handler.protocol() == "webcal")
    return l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_WEBCAL_NAME);
  return UTF8ToUTF16(handler.protocol());
}

string16 RegisterProtocolHandlerInfoBarDelegate::GetButtonLabel(
    InfoBarButton button) const {
  return (button == BUTTON_OK) ?
      l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_ACCEPT,
                                 handler_.title()) :
      l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_DENY);
}

bool RegisterProtocolHandlerInfoBarDelegate::NeedElevation(
    InfoBarButton button) const {
  return button == BUTTON_OK;
}

bool RegisterProtocolHandlerInfoBarDelegate::Accept() {
  content::RecordAction(
      UserMetricsAction("RegisterProtocolHandler.Infobar_Accept"));
  registry_->OnAcceptRegisterProtocolHandler(handler_);
  return true;
}

bool RegisterProtocolHandlerInfoBarDelegate::Cancel() {
  content::RecordAction(
      UserMetricsAction("RegisterProtocolHandler.InfoBar_Deny"));
  registry_->OnIgnoreRegisterProtocolHandler(handler_);
  return true;
}

string16 RegisterProtocolHandlerInfoBarDelegate::GetLinkText() const {
  return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
}

bool RegisterProtocolHandlerInfoBarDelegate::LinkClicked(
    WindowOpenDisposition disposition) {
  content::RecordAction(
      UserMetricsAction("RegisterProtocolHandler.InfoBar_LearnMore"));
  OpenURLParams params(
      google_util::AppendGoogleLocaleParam(GURL(
          chrome::kLearnMoreRegisterProtocolHandlerURL)),
      Referrer(),
      (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
      content::PAGE_TRANSITION_LINK,
      false);
  owner()->web_contents()->OpenURL(params);
  return false;
}
<|endoftext|>


<commit_before>/*
 * This file is part of the Yildiz-Engine project, licenced under the MIT License  (MIT)
 *
 * Copyright (c) 2019 Grégory Van den Borre
 *
 * More infos available: https://engine.yildiz-games.be
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
 * documentation files (the "Software"), to deal in the Software without restriction, including without
 * limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or substantial
 * portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
 * OR COPYRIGHT  HOLDERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE  SOFTWARE.
 */

#include <OgreArchive.h>
#include <OgreString.h>
#include <yz_physfs_File.hpp>
#include <yz_physfs_Wrapper.hpp>

namespace yz {

namespace ogre {

namespace vfs {

/**
* Ogre Archive implementation for a VFS.
*@author Grégory Van den Borre
*/
class Archive: public Ogre::Archive {

public:

    Archive(const yz::physfs::Wrapper* vfs, const Ogre::String& name, const Ogre::String& type) : Ogre::Archive(name, type), vfs(vfs) {
        LOG_FUNCTION
    }

    /** PhysFS is case sensitive in general */
    bool isCaseSensitive() const {
        LOG_FUNCTION
        return true;
    }

    /**
     * Loading is handled by the VFS.
     */
    void load() {
        LOG_FUNCTION
    }

    /**
     * Unloading is handled by the VFS.
     */
    void unload() {
        LOG_FUNCTION
    }

    inline time_t getModifiedTime(const Ogre::String& file) const {
        LOG_FUNCTION
        return this->vfs->getLastModTime(file);
    }

    Ogre::DataStreamPtr open(const Ogre::String& filename, bool append) const;

    Ogre::StringVectorPtr list(bool recursive = true, bool dirs = false) const;

    Ogre::FileInfoListPtr listFileInfo(bool recursive = true, bool dirs = false) const;

    Ogre::StringVectorPtr find(const Ogre::String& pattern, bool recursive = true, bool dirs = false) const;

    bool exists(const Ogre::String& filename) const;

    Ogre::FileInfoListPtr findFileInfo(const Ogre::String& pattern, bool recursive = true, bool dirs = false) const;

private:

    void listInfoRecursive(const Ogre::String& base, bool recursive, bool dirs, Ogre::FileInfoListPtr fileInfoList) const;

    void listRecursive(const Ogre::String& base, bool recursive, bool dirs, Ogre::StringVectorPtr fileList) const;

    const yz::physfs::Wrapper* vfs;
};
}}}
<commit_msg>Update yz_ogre_vfs_Archive.hpp<commit_after>/*
 * This file is part of the Yildiz-Engine project, licenced under the MIT License  (MIT)
 *
 * Copyright (c) 2019 Grégory Van den Borre
 *
 * More infos available: https://engine.yildiz-games.be
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
 * documentation files (the "Software"), to deal in the Software without restriction, including without
 * limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or substantial
 * portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
 * OR COPYRIGHT  HOLDERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE  SOFTWARE.
 */

#include <OgreArchive.h>
#include <OgreString.h>
#include <yz_physfs_File.hpp>
#include <yz_physfs_Wrapper.hpp>
#include "stdafx.h"

namespace yz {

namespace ogre {

namespace vfs {

/**
* Ogre Archive implementation for a VFS.
*@author Grégory Van den Borre
*/
class Archive: public Ogre::Archive {

public:

    Archive(const yz::physfs::Wrapper* vfs, const Ogre::String& name, const Ogre::String& type) : Ogre::Archive(name, type), vfs(vfs) {
        LOG_FUNCTION
    }

    /** PhysFS is case sensitive in general */
    bool isCaseSensitive() const {
        LOG_FUNCTION
        return true;
    }

    /**
     * Loading is handled by the VFS.
     */
    void load() {
        LOG_FUNCTION
    }

    /**
     * Unloading is handled by the VFS.
     */
    void unload() {
        LOG_FUNCTION
    }

    inline time_t getModifiedTime(const Ogre::String& file) const {
        LOG_FUNCTION
        return this->vfs->getLastModTime(file);
    }

    Ogre::DataStreamPtr open(const Ogre::String& filename, bool append) const;

    Ogre::StringVectorPtr list(bool recursive = true, bool dirs = false) const;

    Ogre::FileInfoListPtr listFileInfo(bool recursive = true, bool dirs = false) const;

    Ogre::StringVectorPtr find(const Ogre::String& pattern, bool recursive = true, bool dirs = false) const;

    bool exists(const Ogre::String& filename) const;

    Ogre::FileInfoListPtr findFileInfo(const Ogre::String& pattern, bool recursive = true, bool dirs = false) const;

private:

    void listInfoRecursive(const Ogre::String& base, bool recursive, bool dirs, Ogre::FileInfoListPtr fileInfoList) const;

    void listRecursive(const Ogre::String& base, bool recursive, bool dirs, Ogre::StringVectorPtr fileList) const;

    const yz::physfs::Wrapper* vfs;
};
}}}
<|endoftext|>


<commit_before>#include <string>
#include <iostream>
using namespace std;

#include "StudentTestScores.h"

int main(){
	StudentTestScores * scores;
	fstream inFile;
	string filePath;
	int numStudents=0;
//-	Prompt user for input filepath name.
	cout << "Where is the file located?" << endl;
	cin >> filePath;
	inFile.open(filePath, ios::in);

	if(!inFile){
		cout << "Error! Missing File! Please enter a proper filepath."
		return 0;
	}
	else	{
		inFile >> numStudents;
		scores = new StudentTestScores[numStudents];
		inFile.get();

		cout << "here we input scores from file" << endl;
		for(int i = 0; i < numStudents; i++){
			inFile >> scores[i];
			inFile.get();
		}

		cout << "here we have finished inputting scores from file" << endl;
		cin.get();
	}
		cout << "here parse scores from file and generate the report" << endl;
		cin.get();
//-	Read file data to program.
//o	Create fstream variable
	//fstream variable >> scores;
//-	Generate Report & Output to standard output
//o	For each student in the array, generate an average score to determine the letter grade
//o	Then output according to instructions.
	for(int i=0; i<numStudents; i++){
		scores[i].display();
	}
	return 0;
}

/*
istream &operator >>(istream &inFile , StudentTestScores &student)
 {
 	cin.ignore();
 	char line[50];
 	inFile.getline( line, 50, '\t' );
 	student.studentName = line;
 	cout << line;

 	inFile >> student.numTestScores;
 	cout << "\t" << student.numTestScores << "\t";

 	double *temp;
 	temp = new double[student.numTestScores];

 	for (int i = 0; i < student.numTestScores; i++)
 	{

 	 inFile >> temp[i] ;
 	 cout << temp[i] << '\t';

 	}
 student.testScores = temp;
 	return inFile;
 }

 fstream inFile;
 StudentTestScores *students;
 string file;
 char answer;

 cout << "Enter Document name(Case sensitive): " ;
 cin >> file;
 file = file + ".txt";

 inFile.open(file, ios::in);

 if(!inFile)
 {	cout << "Error! Missing File!" << endl << endl;
 	cin.get();
 	cout << "Would you like to create it? (y/n):" ;
 	cin >> answer;
 	if (answer == 'y')
 	 inFile.open(file,ios::out);
 	else if(answer == 'n')
 	 {cout << "Thanks!" << endl;}
 	inFile.close();
 	cin.get();

 }
 else
 {
 	int tempNum;
 	inFile >> tempNum;
 	students = new StudentTestScores[tempNum];

 	for(int i = 0; i < tempNum; i++)
 	{
 	 inFile >> students[i];
 	}

 }
 cin.get();
 cin.get();

 return 0;
}
 */<commit_msg>Update test.cpp<commit_after>#include <string>
#include <iostream>
#include <fstream>
using namespace std;

#include "StudentTestScores.h"

int main(){
	StudentTestScores * scores;
	fstream inFile;
	string filePath;
	int numStudents=0;
//-	Prompt user for input filepath name.
	cout << "Where is the file located?" << endl;
	cin >> filePath;
	cin.get();
	inFile.open(filePath, ios::in);

	if(!inFile){
		cout << "Error! Missing File! Please enter a proper filepath.";
		return 0;
	}
	else	{
		inFile >> numStudents;
		scores = new StudentTestScores[numStudents];
		inFile.get();
		for(int i = 0; i < numStudents; i++){
			inFile >> scores[i];
			inFile.get();
		}
	}
//-	Read file data to program.
//o	Create fstream variable
	//fstream variable >> scores;
//-	Generate Report & Output to standard output
//o	For each student in the array, generate an average score to determine the letter grade
//o	Then output according to instructions.
	for(int i=0; i<numStudents; i++){
		scores[i].Display();
	}
	cin.get();
	return 0;
}
<|endoftext|>


<commit_before>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/plat/pegasus/prdfLaneRepair.C $      */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2013                   */
/*                                                                        */
/* p1                                                                     */
/*                                                                        */
/* Object Code Only (OCO) source materials                                */
/* Licensed Internal Code Source Materials                                */
/* IBM HostBoot Licensed Internal Code                                    */
/*                                                                        */
/* The source code for this program is not published or otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* Origin: 30                                                             */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */

/** @file prdfLaneRepair.C */

#include <prdfLaneRepair.H>

// Framework includes
#include <prdfPlatServices.H>
#include <iipconst.h>
#include <prdfGlobal.H>
#include <iipSystem.h>
#include <iipServiceDataCollector.h>
#include <prdfExtensibleChip.H>
#include <UtilHash.H>

// Pegasus includes
#include <prdfCalloutUtil.H>
#include <prdfCenMembufDataBundle.H>
#include <prdfP8McsDataBundle.H>

using namespace TARGETING;

namespace PRDF
{
using namespace PlatServices;

namespace LaneRepair
{

int32_t handleLaneRepairEvent( ExtensibleChip * i_chip,
                               TYPE i_busType,
                               uint32_t i_busPos,
                               STEP_CODE_DATA_STRUCT & i_sc,
                               bool i_spareDeployed )
{
    #define PRDF_FUNC "[LaneRepair::handleLaneRepairEvent] "

    int32_t l_rc = SUCCESS;
    TargetHandle_t rxBusTgt = NULL;
    TargetHandle_t txBusTgt = NULL;
    bool thrExceeded = true;
    std::vector<uint8_t> rx_lanes;
    std::vector<uint8_t> rx_vpdLanes;
    std::vector<uint8_t> tx_vpdLanes;
    BitStringBuffer l_vpdLaneMap0to63(64);
    BitStringBuffer l_vpdLaneMap64to127(64);
    BitStringBuffer l_newLaneMap0to63(64);
    BitStringBuffer l_newLaneMap64to127(64);

    do
    {
        // Get RX bus target
        TYPE iChipType = getTargetType(i_chip->GetChipHandle());

        if (iChipType == TYPE_MEMBUF)
        {
            rxBusTgt = i_chip->GetChipHandle();
        }
        else if (iChipType == TYPE_PROC)
        {
            // i_chip is a Proc, Get connected XBUS, ABUS, or MCS target
            rxBusTgt = getConnectedChild( i_chip->GetChipHandle(),
                                          i_busType, i_busPos );
            if ( NULL == rxBusTgt )
            {
                PRDF_ERR( PRDF_FUNC"Could not find RX connected bus" );
                l_rc = FAIL; break;
            }
        }
        else
        {
            PRDF_ERR( PRDF_FUNC"i_chip is not of type MEMBUF or PROC" );
            l_rc = FAIL; break;
        }

        // Call io_read_erepair
        l_rc = readErepair(rxBusTgt, rx_lanes);
        if (SUCCESS != l_rc)
        {
            PRDF_ERR( PRDF_FUNC"readErepair() failed: rxBusTgt=0x%08x",
                      getHuid(rxBusTgt) );
            break;
        }

        // Add newly failed lanes to capture data
        for (std::vector<uint8_t>::iterator lane = rx_lanes.begin();
             lane != rx_lanes.end(); ++lane)
        {
            if (*lane < 64)
                l_newLaneMap0to63.Set(*lane);
            else if (*lane < 127)
                l_newLaneMap64to127.Set(*lane - 64);
            else
            {
                PRDF_ERR( PRDF_FUNC"Invalid lane number %d: rxBusTgt=0x%08x",
                          *lane, getHuid(rxBusTgt) );
                l_rc = FAIL; break;
            }
        }
        if ( SUCCESS != l_rc ) break;

        // Add failed lane capture data to errorlog
        i_sc.service_data->GetCaptureData().Add(i_chip->GetChipHandle(),
                                Util::hashString("NEW_FAILED_LANES_0TO63"),
                                l_newLaneMap0to63);
        i_sc.service_data->GetCaptureData().Add(i_chip->GetChipHandle(),
                                Util::hashString("NEW_FAILED_LANES_64TO127"),
                                l_newLaneMap64to127);

        if (!mfgMode()) // Don't read/write VPD in mfg mode
        {
            // Read Failed Lanes from VPD
            l_rc = getVpdFailedLanes(rxBusTgt, rx_vpdLanes, tx_vpdLanes);
            if (SUCCESS != l_rc)
            {
                PRDF_ERR( PRDF_FUNC"getVpdFailedLanes() failed: "
                          "rxBusTgt=0x%08x", getHuid(rxBusTgt) );
                break;
            }

            // Add VPD lanes to capture data
            for (std::vector<uint8_t>::iterator lane = rx_vpdLanes.begin();
                 lane != rx_vpdLanes.end(); ++lane)
            {
                if (*lane < 64)
                    l_vpdLaneMap0to63.Set(*lane);
                else if (*lane < 127)
                    l_vpdLaneMap64to127.Set(*lane - 64);
                else
                {
                    PRDF_ERR( PRDF_FUNC"Invalid VPD lane number %d: "
                              "rxBusTgt=0x%08x", *lane, getHuid(rxBusTgt) );
                    l_rc = FAIL; break;
                }
            }
            if ( SUCCESS != l_rc ) break;

            // Add failed lane capture data to errorlog
            i_sc.service_data->GetCaptureData().Add(i_chip->GetChipHandle(),
                                Util::hashString("VPD_FAILED_LANES_0TO63"),
                                l_vpdLaneMap0to63);
            i_sc.service_data->GetCaptureData().Add(i_chip->GetChipHandle(),
                                Util::hashString("VPD_FAILED_LANES_64TO127"),
                                l_vpdLaneMap64to127);

            if (i_spareDeployed)
            {
                // Get TX bus target
                if (i_busType == TYPE_XBUS || i_busType == TYPE_ABUS)
                {
                    txBusTgt = getConnectedPeerTarget(rxBusTgt);
                }
                else if (i_busType == TYPE_MEMBUF)
                {
                    txBusTgt = getConnectedParent(rxBusTgt, TYPE_MCS);
                }
                else if (i_busType == TYPE_MCS)
                {
                    txBusTgt = getConnectedChild(rxBusTgt, TYPE_MEMBUF, 0);
                }

                if ( NULL == txBusTgt )
                {
                    PRDF_ERR( PRDF_FUNC"Could not find TX connected bus: "
                              "rxBusTgt: 0x%08x", getHuid(rxBusTgt) );
                    l_rc = FAIL; break;
                }

                // Call Erepair to update VPD
                l_rc = setVpdFailedLanes(rxBusTgt, txBusTgt,
                                         rx_lanes, thrExceeded);
                if (SUCCESS != l_rc)
                {
                    PRDF_ERR( PRDF_FUNC"setVpdFailedLanes() failed: "
                              "rxBusTgt=0x%08x txBusTgt=0x%08x",
                              getHuid(rxBusTgt), getHuid(txBusTgt) );
                    break;
                }
            }
        }

        if (i_spareDeployed && !thrExceeded)
        {
            // Update lists of lanes from VPD
            rx_vpdLanes.clear(); tx_vpdLanes.clear();
            l_rc = getVpdFailedLanes(rxBusTgt, rx_vpdLanes, tx_vpdLanes);
            if (SUCCESS != l_rc)
            {
                PRDF_ERR( PRDF_FUNC"getVpdFailedLanes() before power down "
                          "failed: rxBusTgt=0x%08x", getHuid(rxBusTgt) );
                break;
            }

            // Power down all lanes that have been saved in VPD
            l_rc = powerDownLanes(rxBusTgt, rx_vpdLanes, tx_vpdLanes);
            if (SUCCESS != l_rc)
            {
                PRDF_ERR( PRDF_FUNC"powerDownLanes() failed: rxBusTgt=0x%08x",
                          getHuid(rxBusTgt) );
                break;
            }
        }
        else
        {
            // Make predictive
            i_sc.service_data->SetServiceCall();
        }

    } while (0);

    // Clear FIRs
    if (rxBusTgt)
    {
        l_rc |= erepairFirIsolation(rxBusTgt);
        l_rc |= clearIOFirs(rxBusTgt);
    }

    if ( i_spareDeployed )
    {
        l_rc |= cleanupSecondaryFirBits( i_chip, i_busType, i_busPos );
    }

    // This return code gets returned by the plugin code back to the rule code.
    // So, we do not want to give a return code that the rule code does not
    // understand. So far, there is no need return a special code, so always
    // return SUCCESS.
    if ( SUCCESS != l_rc )
    {
        PRDF_ERR( PRDF_FUNC"i_chip: 0x%08x i_busType:%d i_busPos:%d",
                  i_chip->GetId(), i_busType, i_busPos );

        CalloutUtil::defaultError( i_sc );
    }

    return SUCCESS;

    #undef PRDF_FUNC
}

//-----------------------------------------------------------------------------

bool isSpareBitOnDMIBus( ExtensibleChip * i_mcsChip, ExtensibleChip * i_mbChip )
{
    bool bitOn = false;

    do
    {
        // If any of these object is NULL, spare bit should not be on.
        if ( ( NULL == i_mcsChip ) || ( NULL == i_mbChip ))
            break;

        // check spare deployed bit on Centaur side
        SCAN_COMM_REGISTER_CLASS * dmiFir = i_mbChip->getRegister( "DMIFIR" );
        int32_t rc = dmiFir->Read();
        if ( SUCCESS != rc )
        {
            PRDF_ERR("isSpareBitOnDMIBus() : Failed to read DMIFIR."
                      "MEMBUF: 0x%08X", getHuid( i_mbChip->GetChipHandle()) );
            break;
        }
        if ( dmiFir->IsBitSet( 9 ))
        {
            bitOn = true;
            break;
        }

        // check spare deployed bit on Proc side
        TargetHandle_t mcsTgt = i_mcsChip->GetChipHandle();
        TargetHandle_t procTgt = getConnectedParent( mcsTgt, TYPE_PROC );
        ExtensibleChip * procChip =
                        ( ExtensibleChip * )systemPtr->GetChip( procTgt );

        uint32_t mcsPos = getTargetPosition( mcsTgt );

        const char * regStr = ( 4 > mcsPos) ? "IOMCFIR_0" : "IOMCFIR_1";
        SCAN_COMM_REGISTER_CLASS * iomcFir = procChip->getRegister( regStr );
        rc = iomcFir->Read();
        if ( SUCCESS != rc )
        {
            PRDF_ERR("isSpareBitOnDMIBus() : Failed to read %s."
                      "MCS: 0x%08X", regStr, getHuid(mcsTgt) );
            break;
        }
        // Bit 9, 17, 25 and 33 are for spare deployed.
        // Check bit corrosponding to MCS position
        uint8_t bitPos = 9 + ( mcsPos % 4 ) *8;
        if ( iomcFir->IsBitSet(bitPos))
        {
            bitOn = true;
        }

    }while(0);

    return bitOn;
}

//-----------------------------------------------------------------------------

int32_t cleanupSecondaryFirBits( ExtensibleChip * i_chip,
                       TYPE i_busType,
                       uint32_t i_busPos )
{
    int32_t l_rc = SUCCESS;
    TargetHandle_t mcsTgt = NULL;
    TargetHandle_t mbTgt = NULL;
    ExtensibleChip * mcsChip = NULL;
    ExtensibleChip * mbChip = NULL;

    //In case of spare deployed attention for DMI bus, we need to clear
    // secondary MBIFIR[10] and MCIFIR[10] bits.
    if ( i_busType == TYPE_MCS )
    {
        mcsTgt = getConnectedChild( i_chip->GetChipHandle(),
                                      TYPE_MCS,
                                      i_busPos);
        mcsChip = ( ExtensibleChip * )systemPtr->GetChip( mcsTgt );
        mbChip =  getMcsDataBundle( mcsChip )->getMembChip();
        if (mbChip)
            mbTgt =   mbChip->GetChipHandle();

    }
    else if ( i_busType == TYPE_MEMBUF )
    {
        mbTgt = i_chip->GetChipHandle();
        mcsChip = getMembufDataBundle( i_chip )->getMcsChip();
        if (mcsChip)
            mcsTgt  = mcsChip->GetChipHandle();
        mbChip = i_chip;
    }

    if ( ( NULL != mcsChip ) && ( NULL != mbChip ))
    {
        SCAN_COMM_REGISTER_CLASS * mciFir =
                                    mcsChip->getRegister( "MCIFIR" );
        int32_t rc = mciFir->Read();
        if ( SUCCESS != rc )
        {
            PRDF_ERR("cleanupSecondaryFirBits() : Failed to read MCIFIR."
                     "MCS: 0x%08X", getHuid(mcsTgt) );
            l_rc |= rc;
        }
        else if ( mciFir->IsBitSet(10))
        {
            mciFir->ClearBit(10);
            l_rc |= mciFir->Write();
        }

        SCAN_COMM_REGISTER_CLASS * mbiFir =
                                    mbChip->getRegister( "MBIFIR" );
        rc = mbiFir->Read();
        if ( SUCCESS != rc )
        {
            PRDF_ERR("cleanupSecondaryFirBits() : Failed to read MBIFIR."
                     "MEMBUF: 0x%08X", getHuid(mbTgt) );
            l_rc |= rc;
        }
        else if ( mbiFir->IsBitSet(10))
        {
            mbiFir->ClearBit(10);
            l_rc |= mbiFir->Write();
        }
    }
    return l_rc;
}

} // end namespace LaneRepair
} // end namespace PRDF
<commit_msg>PRD: Added some null checks in cleanupSecondaryFirBits<commit_after>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/plat/pegasus/prdfLaneRepair.C $      */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2013                   */
/*                                                                        */
/* p1                                                                     */
/*                                                                        */
/* Object Code Only (OCO) source materials                                */
/* Licensed Internal Code Source Materials                                */
/* IBM HostBoot Licensed Internal Code                                    */
/*                                                                        */
/* The source code for this program is not published or otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* Origin: 30                                                             */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */

/** @file prdfLaneRepair.C */

#include <prdfLaneRepair.H>

// Framework includes
#include <prdfPlatServices.H>
#include <iipconst.h>
#include <prdfGlobal.H>
#include <iipSystem.h>
#include <iipServiceDataCollector.h>
#include <prdfExtensibleChip.H>
#include <UtilHash.H>

// Pegasus includes
#include <prdfCalloutUtil.H>
#include <prdfCenMembufDataBundle.H>
#include <prdfP8McsDataBundle.H>

using namespace TARGETING;

namespace PRDF
{
using namespace PlatServices;

namespace LaneRepair
{

int32_t handleLaneRepairEvent( ExtensibleChip * i_chip,
                               TYPE i_busType,
                               uint32_t i_busPos,
                               STEP_CODE_DATA_STRUCT & i_sc,
                               bool i_spareDeployed )
{
    #define PRDF_FUNC "[LaneRepair::handleLaneRepairEvent] "

    int32_t l_rc = SUCCESS;
    TargetHandle_t rxBusTgt = NULL;
    TargetHandle_t txBusTgt = NULL;
    bool thrExceeded = true;
    std::vector<uint8_t> rx_lanes;
    std::vector<uint8_t> rx_vpdLanes;
    std::vector<uint8_t> tx_vpdLanes;
    BitStringBuffer l_vpdLaneMap0to63(64);
    BitStringBuffer l_vpdLaneMap64to127(64);
    BitStringBuffer l_newLaneMap0to63(64);
    BitStringBuffer l_newLaneMap64to127(64);

    do
    {
        // Get RX bus target
        TYPE iChipType = getTargetType(i_chip->GetChipHandle());

        if (iChipType == TYPE_MEMBUF)
        {
            rxBusTgt = i_chip->GetChipHandle();
        }
        else if (iChipType == TYPE_PROC)
        {
            // i_chip is a Proc, Get connected XBUS, ABUS, or MCS target
            rxBusTgt = getConnectedChild( i_chip->GetChipHandle(),
                                          i_busType, i_busPos );
            if ( NULL == rxBusTgt )
            {
                PRDF_ERR( PRDF_FUNC"Could not find RX connected bus" );
                l_rc = FAIL; break;
            }
        }
        else
        {
            PRDF_ERR( PRDF_FUNC"i_chip is not of type MEMBUF or PROC" );
            l_rc = FAIL; break;
        }

        // Call io_read_erepair
        l_rc = readErepair(rxBusTgt, rx_lanes);
        if (SUCCESS != l_rc)
        {
            PRDF_ERR( PRDF_FUNC"readErepair() failed: rxBusTgt=0x%08x",
                      getHuid(rxBusTgt) );
            break;
        }

        // Add newly failed lanes to capture data
        for (std::vector<uint8_t>::iterator lane = rx_lanes.begin();
             lane != rx_lanes.end(); ++lane)
        {
            if (*lane < 64)
                l_newLaneMap0to63.Set(*lane);
            else if (*lane < 127)
                l_newLaneMap64to127.Set(*lane - 64);
            else
            {
                PRDF_ERR( PRDF_FUNC"Invalid lane number %d: rxBusTgt=0x%08x",
                          *lane, getHuid(rxBusTgt) );
                l_rc = FAIL; break;
            }
        }
        if ( SUCCESS != l_rc ) break;

        // Add failed lane capture data to errorlog
        i_sc.service_data->GetCaptureData().Add(i_chip->GetChipHandle(),
                                Util::hashString("NEW_FAILED_LANES_0TO63"),
                                l_newLaneMap0to63);
        i_sc.service_data->GetCaptureData().Add(i_chip->GetChipHandle(),
                                Util::hashString("NEW_FAILED_LANES_64TO127"),
                                l_newLaneMap64to127);

        if (!mfgMode()) // Don't read/write VPD in mfg mode
        {
            // Read Failed Lanes from VPD
            l_rc = getVpdFailedLanes(rxBusTgt, rx_vpdLanes, tx_vpdLanes);
            if (SUCCESS != l_rc)
            {
                PRDF_ERR( PRDF_FUNC"getVpdFailedLanes() failed: "
                          "rxBusTgt=0x%08x", getHuid(rxBusTgt) );
                break;
            }

            // Add VPD lanes to capture data
            for (std::vector<uint8_t>::iterator lane = rx_vpdLanes.begin();
                 lane != rx_vpdLanes.end(); ++lane)
            {
                if (*lane < 64)
                    l_vpdLaneMap0to63.Set(*lane);
                else if (*lane < 127)
                    l_vpdLaneMap64to127.Set(*lane - 64);
                else
                {
                    PRDF_ERR( PRDF_FUNC"Invalid VPD lane number %d: "
                              "rxBusTgt=0x%08x", *lane, getHuid(rxBusTgt) );
                    l_rc = FAIL; break;
                }
            }
            if ( SUCCESS != l_rc ) break;

            // Add failed lane capture data to errorlog
            i_sc.service_data->GetCaptureData().Add(i_chip->GetChipHandle(),
                                Util::hashString("VPD_FAILED_LANES_0TO63"),
                                l_vpdLaneMap0to63);
            i_sc.service_data->GetCaptureData().Add(i_chip->GetChipHandle(),
                                Util::hashString("VPD_FAILED_LANES_64TO127"),
                                l_vpdLaneMap64to127);

            if (i_spareDeployed)
            {
                // Get TX bus target
                if (i_busType == TYPE_XBUS || i_busType == TYPE_ABUS)
                {
                    txBusTgt = getConnectedPeerTarget(rxBusTgt);
                }
                else if (i_busType == TYPE_MEMBUF)
                {
                    txBusTgt = getConnectedParent(rxBusTgt, TYPE_MCS);
                }
                else if (i_busType == TYPE_MCS)
                {
                    txBusTgt = getConnectedChild(rxBusTgt, TYPE_MEMBUF, 0);
                }

                if ( NULL == txBusTgt )
                {
                    PRDF_ERR( PRDF_FUNC"Could not find TX connected bus: "
                              "rxBusTgt: 0x%08x", getHuid(rxBusTgt) );
                    l_rc = FAIL; break;
                }

                // Call Erepair to update VPD
                l_rc = setVpdFailedLanes(rxBusTgt, txBusTgt,
                                         rx_lanes, thrExceeded);
                if (SUCCESS != l_rc)
                {
                    PRDF_ERR( PRDF_FUNC"setVpdFailedLanes() failed: "
                              "rxBusTgt=0x%08x txBusTgt=0x%08x",
                              getHuid(rxBusTgt), getHuid(txBusTgt) );
                    break;
                }
            }
        }

        if (i_spareDeployed && !thrExceeded)
        {
            // Update lists of lanes from VPD
            rx_vpdLanes.clear(); tx_vpdLanes.clear();
            l_rc = getVpdFailedLanes(rxBusTgt, rx_vpdLanes, tx_vpdLanes);
            if (SUCCESS != l_rc)
            {
                PRDF_ERR( PRDF_FUNC"getVpdFailedLanes() before power down "
                          "failed: rxBusTgt=0x%08x", getHuid(rxBusTgt) );
                break;
            }

            // Power down all lanes that have been saved in VPD
            l_rc = powerDownLanes(rxBusTgt, rx_vpdLanes, tx_vpdLanes);
            if (SUCCESS != l_rc)
            {
                PRDF_ERR( PRDF_FUNC"powerDownLanes() failed: rxBusTgt=0x%08x",
                          getHuid(rxBusTgt) );
                break;
            }
        }
        else
        {
            // Make predictive
            i_sc.service_data->SetServiceCall();
        }

    } while (0);

    // Clear FIRs
    if (rxBusTgt)
    {
        l_rc |= erepairFirIsolation(rxBusTgt);
        l_rc |= clearIOFirs(rxBusTgt);
    }

    if ( i_spareDeployed )
    {
        l_rc |= cleanupSecondaryFirBits( i_chip, i_busType, i_busPos );
    }

    // This return code gets returned by the plugin code back to the rule code.
    // So, we do not want to give a return code that the rule code does not
    // understand. So far, there is no need return a special code, so always
    // return SUCCESS.
    if ( SUCCESS != l_rc )
    {
        PRDF_ERR( PRDF_FUNC"i_chip: 0x%08x i_busType:%d i_busPos:%d",
                  i_chip->GetId(), i_busType, i_busPos );

        CalloutUtil::defaultError( i_sc );
    }

    return SUCCESS;

    #undef PRDF_FUNC
}

//-----------------------------------------------------------------------------

bool isSpareBitOnDMIBus( ExtensibleChip * i_mcsChip, ExtensibleChip * i_mbChip )
{
    bool bitOn = false;

    do
    {
        // If any of these object is NULL, spare bit should not be on.
        if ( ( NULL == i_mcsChip ) || ( NULL == i_mbChip ))
            break;

        // check spare deployed bit on Centaur side
        SCAN_COMM_REGISTER_CLASS * dmiFir = i_mbChip->getRegister( "DMIFIR" );
        int32_t rc = dmiFir->Read();
        if ( SUCCESS != rc )
        {
            PRDF_ERR("isSpareBitOnDMIBus() : Failed to read DMIFIR."
                      "MEMBUF: 0x%08X", getHuid( i_mbChip->GetChipHandle()) );
            break;
        }
        if ( dmiFir->IsBitSet( 9 ))
        {
            bitOn = true;
            break;
        }

        // check spare deployed bit on Proc side
        TargetHandle_t mcsTgt = i_mcsChip->GetChipHandle();
        TargetHandle_t procTgt = getConnectedParent( mcsTgt, TYPE_PROC );
        ExtensibleChip * procChip =
                        ( ExtensibleChip * )systemPtr->GetChip( procTgt );

        uint32_t mcsPos = getTargetPosition( mcsTgt );

        const char * regStr = ( 4 > mcsPos) ? "IOMCFIR_0" : "IOMCFIR_1";
        SCAN_COMM_REGISTER_CLASS * iomcFir = procChip->getRegister( regStr );
        rc = iomcFir->Read();
        if ( SUCCESS != rc )
        {
            PRDF_ERR("isSpareBitOnDMIBus() : Failed to read %s."
                      "MCS: 0x%08X", regStr, getHuid(mcsTgt) );
            break;
        }
        // Bit 9, 17, 25 and 33 are for spare deployed.
        // Check bit corrosponding to MCS position
        uint8_t bitPos = 9 + ( mcsPos % 4 ) *8;
        if ( iomcFir->IsBitSet(bitPos))
        {
            bitOn = true;
        }

    }while(0);

    return bitOn;
}

//-----------------------------------------------------------------------------

int32_t cleanupSecondaryFirBits( ExtensibleChip * i_chip,
                       TYPE i_busType,
                       uint32_t i_busPos )
{
    int32_t l_rc = SUCCESS;
    TargetHandle_t mcsTgt = NULL;
    TargetHandle_t mbTgt = NULL;
    ExtensibleChip * mcsChip = NULL;
    ExtensibleChip * mbChip = NULL;

    //In case of spare deployed attention for DMI bus, we need to clear
    // secondary MBIFIR[10] and MCIFIR[10] bits.
    do
    {
        if ( i_busType == TYPE_MCS )
        {
            mcsTgt = getConnectedChild( i_chip->GetChipHandle(),
                                        TYPE_MCS,
                                        i_busPos);
            if (!mcsTgt) break;
            mcsChip = ( ExtensibleChip * )systemPtr->GetChip( mcsTgt );
            if (!mcsChip) break;
            mbChip =  getMcsDataBundle( mcsChip )->getMembChip();
            if (!mbChip) break;
            mbTgt =   mbChip->GetChipHandle();
            if (!mbTgt) break;
        }
        else if ( i_busType == TYPE_MEMBUF )
        {
            mbTgt = i_chip->GetChipHandle();
            if (!mbTgt) break;
            mcsChip = getMembufDataBundle( i_chip )->getMcsChip();
            if (!mcsChip) break;
            mcsTgt  = mcsChip->GetChipHandle();
            if (!mcsTgt) break;
            mbChip = i_chip;
        }

        SCAN_COMM_REGISTER_CLASS * mciFir =
          mcsChip->getRegister( "MCIFIR" );
        int32_t rc = mciFir->Read();
        if ( SUCCESS != rc )
        {
            PRDF_ERR("cleanupSecondaryFirBits() : Failed to read MCIFIR."
                     "MCS: 0x%08X", getHuid(mcsTgt) );
            l_rc |= rc;
        }
        else if ( mciFir->IsBitSet(10))
        {
            mciFir->ClearBit(10);
            l_rc |= mciFir->Write();
        }

        SCAN_COMM_REGISTER_CLASS * mbiFir =
          mbChip->getRegister( "MBIFIR" );
        rc = mbiFir->Read();
        if ( SUCCESS != rc )
        {
            PRDF_ERR("cleanupSecondaryFirBits() : Failed to read MBIFIR."
                     "MEMBUF: 0x%08X", getHuid(mbTgt) );
            l_rc |= rc;
        }
        else if ( mbiFir->IsBitSet(10))
        {
            mbiFir->ClearBit(10);
            l_rc |= mbiFir->Write();
        }
    } while (0);
    return l_rc;
}

} // end namespace LaneRepair
} // end namespace PRDF
<|endoftext|>


<commit_before>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/isteps/istep10/call_host_secureboot_lockdown.C $      */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2020,2021                        */
/* [+] 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                                                     */
/**
   @file call_host_secureboot_lockdown.C
 *
 *  Support file for IStep: host_secureboot_lockdown
 *    This istep will do these things (not necessarily in this order):
 *      1) Check for TPM policies are valid
 *      2) Check for secureboot consistency between procs
 *      3) Set the SUL security bit so that SBE image cannot be updated
 *      4) Ensure that the SAB security bit is read only
 *      5) If a TPM is non functional, set the TDP (TPM Deconfig Protection)
 *         to prevent attack vector
 *      6) Check for a reason, such as a Key Clear Request, to re-IPL the
 *         system so the system owner can assert physical presence
 *      7) Check Scratch Regiser 11 (0x50182) to see if SBE is reporting a previous fail.
 *
 */

// For istep and error logging support
#include <isteps/hwpisteperror.H>
#include <isteps/istep_reasoncodes.H>
#include <initservice/initserviceif.H>
#include <initservice/mboxRegs.H>
#include <istepHelperFuncs.H>
#include <errl/errlentry.H>
#include <errl/errlmanager.H>
#include <errl/errludlogregister.H>
#include <targeting/common/targetservice.H>

// For Secureboot, Trustedboot support
#include <secureboot/service.H>
#include <secureboot/phys_presence_if.H>
#include <secureboot/service_ext.H>
#include <secureboot/trustedbootif.H>

// Secureboot lockdown HWP
#include <plat_hwp_invoker.H>
#include <p10_update_security_ctrl.H>

// PHyp/OPAL loads
#include <targeting/common/mfgFlagAccessors.H>

namespace ISTEP_10
{

void* call_host_secureboot_lockdown (void *io_pArgs)
{
    TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                ENTER_MRK"call_host_secureboot_lockdown");

    ISTEP_ERROR::IStepError l_istepError;
#ifndef CONFIG_VPO_COMPILE
    errlHndl_t l_err = nullptr;

    do {

    // Attempt to initialize the backup TPM.
    TRUSTEDBOOT::initBackupTpm();

    // Always poison the backup TPM because we want to ensure
    // it varies from the primary.
    l_err = TRUSTEDBOOT::poisonBackupTpm();

    if(l_err)
    {
        TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                  "call_host_secureboot_lockdown: poisonBackupTpm returned an error"
                  TRACE_ERR_FMT,
                  TRACE_ERR_ARGS(l_err));
        l_istepError.addErrorDetails(l_err);
        TARGETING::Target * backup_tpm = nullptr;
        TRUSTEDBOOT::getBackupTpm(backup_tpm);
        assert(backup_tpm != nullptr, "call_host_secureboot_lockdown: poisonBackupTpm returned an error when no backup tpm available");
        // tpmMarkFailed will ensure there is at minimum a deconfig callout for the backup
        // TPM and also set the deconfig bit to force fencing if security is enabled
        TRUSTEDBOOT::tpmMarkFailed(backup_tpm, l_err);
    }

#ifdef CONFIG_SECUREBOOT

    if(SECUREBOOT::enabled())
    {
        TARGETING::TargetHandleList l_procList;
        TARGETING::TargetHandleList l_tpmList;

        getAllChips(l_procList,TARGETING::TYPE_PROC);
        getAllChips(l_tpmList,TARGETING::TYPE_TPM,false);

        TARGETING::Target* boot_proc = nullptr;
        l_err = TARGETING::targetService().queryMasterProcChipTargetHandle(boot_proc);
        if(l_err)
        {
            TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                      "call_host_secureboot_lockdown: FAIL getting boot proc"
                      TRACE_ERR_FMT,
                      TRACE_ERR_ARGS(l_err));

            captureError(l_err, l_istepError, HWPF_COMP_ID);

            // If targeting can't get the boot proc, then it's broke, so break here
            break;
        }

        for(const auto& l_proc : l_procList)
        {

            bool l_notInMrw = true;
            // check if processor has a TPM according to the mrw
            // for each TPM in the list compare SPI master path with
            // the path of the current processor
            for (auto itpm : l_tpmList)
            {
                auto l_physPath = l_proc->getAttr<TARGETING::ATTR_PHYS_PATH>();

                auto l_tpmInfo = itpm->getAttr<TARGETING::ATTR_SPI_TPM_INFO>();

                if (l_tpmInfo.spiMasterPath == l_physPath)
                {
                    l_notInMrw = false;
                    break;
                }
            }
            if (l_notInMrw)
            {
                uint8_t l_protectTpm = 1;
                l_proc->setAttr<
                    TARGETING::ATTR_SECUREBOOT_PROTECT_DECONFIGURED_TPM
                                                                    >(l_protectTpm);
            }

            // Check that the SBE did not use Scratch Register 11 (0x50182) to pass FFDC
            // on a secureboot validation error up to hostboot to log an error
            uint64_t scomData = 0x0;
            size_t op_size = sizeof(scomData);

            // For boot proc read from attribute that was saved off at the start of the IPL
            if (l_proc == boot_proc)
            {
                const auto l_scratchRegs = TARGETING::UTIL::assertGetToplevelTarget()->
                                             getAttrAsStdArr<TARGETING::ATTR_MASTER_MBOX_SCRATCH>();

                // Write to uint64_t scomData even though MboxScratch11_t::REG_IDX is a uint32_t
                // This will preserve the scomData != 0 check below for all processors
                scomData = l_scratchRegs[INITSERVICE::SPLESS::MboxScratch11_t::REG_IDX];

            }
            // For non-boot procs read Scratch Register 11 (0x50182) directly from HW
            else
            {
                l_err = deviceRead(
                            l_proc,
                            &scomData,
                            op_size,
                            DEVICE_SCOM_ADDRESS(INITSERVICE::SPLESS::MboxScratch11_t::REG_ADDR));
                if(l_err)
                {
                    TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                              "call_host_secureboot_lockdown: SCOM Read of MAILBOX_SCRATCH_REG_11 "
                              "(0x%X) failed for Proc HUID 0x%08x "
                              TRACE_ERR_FMT,
                              INITSERVICE::SPLESS::MboxScratch11_t::REG_ADDR,
                              TARGETING::get_huid(l_proc),
                              TRACE_ERR_ARGS(l_err));

                    // Among other things, this will add the proc target to the log
                    captureError(l_err, l_istepError, HWPF_COMP_ID, l_proc);

                    // Try to run the HWP on all procs regardless of error.
                    continue;
                }
            }

            if (scomData != 0x0)
            {
                TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                          "call_host_secureboot_lockdown: SBE reported FFDC Data in Scratch Reg 11 "
                          "(addr=0x%X) for Proc HUID 0x%08X: data = 0x%.16llX "
                          TRACE_ERR_FMT,
                          INITSERVICE::SPLESS::MboxScratch11_t::REG_ADDR,
                          TARGETING::get_huid(l_proc), scomData,
                          TRACE_ERR_ARGS(l_err));

               /*@
                 * @errortype
                 * @moduleid    ISTEP::MOD_SECUREBOOT_LOCKDOWN
                 * @reasoncode  ISTEP::RC_SBE_REPORTED_FFDC
                 * @userdata1   HUID of Processor Target target
                 * @userdata2   Scom Data
                 * @devdesc     SBE put FFDC data into Scratch Register 11
                 * @custdesc    A problem occurred during the IPL of the
                 *              system and the system will reboot.
                 */
                l_err = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                ISTEP::MOD_SECUREBOOT_LOCKDOWN,
                                ISTEP::RC_SBE_REPORTED_FFDC,
                                TARGETING::get_huid(l_proc),
                                scomData);

                l_err->addHwCallout( l_proc,
                                     HWAS::SRCI_PRIORITY_HIGH,
                                     HWAS::DELAYED_DECONFIG,
                                     HWAS::GARD_NULL );

                // Add the register to the log
                ERRORLOG::ErrlUserDetailsLogRegister(l_proc,
                              &scomData,
                              op_size,
                              DEVICE_SCOM_ADDRESS(INITSERVICE::SPLESS::MboxScratch11_t::REG_ADDR))
                                  .addToLog(l_err);

                // Among other things, this will add the proc target to the log
                captureError(l_err, l_istepError, HWPF_COMP_ID, l_proc);

                // Try to run the HWP on all procs regardless of error.
                continue;
            }

            const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>l_fapiProc(l_proc);
            const bool DO_NOT_FORCE_SECURITY = false; // No need to force security
            const bool DO_NOT_LOCK_ABUS_MAILBOXES = false; // Do not lock abus mailboxes
            FAPI_INVOKE_HWP(l_err,
                            p10_update_security_ctrl,
                            l_fapiProc,
                            DO_NOT_FORCE_SECURITY,
                            DO_NOT_LOCK_ABUS_MAILBOXES);
            if(l_err)
            {
                TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                          "call_host_secureboot_lockdown: p10_update_security_ctrl failed for Proc HUID 0x%08x "
                          TRACE_ERR_FMT, TARGETING::get_huid(l_proc),
                          TRACE_ERR_ARGS(l_err));
                l_istepError.addErrorDetails(l_err);
                ERRORLOG::errlCommit(l_err, ISTEP_COMP_ID);
                // Try to run the HWP on all procs regardless of error.
            }
            // Lock OPAL keystore if in PHyp boot
            if (TARGETING::is_phyp_load())
            {
                l_err = SECUREBOOT::setSecuritySwitchBits({ SECUREBOOT::ProcSecurity::KsOpalBank0WrLock,
                    SECUREBOOT::ProcSecurity::KsOpalBank0RdLock,
                    SECUREBOOT::ProcSecurity::KsOpalBank1WrLock,
                    SECUREBOOT::ProcSecurity::KsOpalBank1RdLock,
                    SECUREBOOT::ProcSecurity::KsOpalQueueWrLock,
                    SECUREBOOT::ProcSecurity::KsOpalQueueRdLock },
                    l_proc);
                if (l_err)
                {
                    TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                        "call_host_secureboot_lockdown: "
                        "Cannot lock OPAL keystore on PROC 0x%08x ",
                        TRACE_ERR_FMT, TARGETING::get_huid(l_proc),
                        TRACE_ERR_ARGS(l_err));
                    l_istepError.addErrorDetails(l_err);
                    ERRORLOG::errlCommit(l_err, ISTEP_COMP_ID);
                }
            }
            else
            {
                // Lock Phyp keystore if in OPAL boot
                l_err = SECUREBOOT::setSecuritySwitchBits({ SECUREBOOT::ProcSecurity::KsPhypWrLock,
                    SECUREBOOT::ProcSecurity::KsPhypRdLock },
                    l_proc);
                if (l_err)
                {
                    TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                        "call_host_secureboot_lockdown: "
                        "Cannot lock PHyp keystore on PROC 0x%08x ",
                        TRACE_ERR_FMT, TARGETING::get_huid(l_proc),
                        TRACE_ERR_ARGS(l_err));
                    l_istepError.addErrorDetails(l_err);
                    ERRORLOG::errlCommit(l_err, ISTEP_COMP_ID);
                }
            }
        } // end of loop on procs
    } // end of SECUREBOOT::enabled() check
    if(l_istepError.getErrorHandle())
    {
        break;
    }

    SECUREBOOT::validateSecuritySettings();
#endif

#ifdef CONFIG_PHYS_PRES_PWR_BUTTON
    // Check to see if a Physical Presence Window should be opened,
    // and if so, open it.  This could result in the system being shutdown
    // to allow the system administrator to assert physical presence
    l_err = SECUREBOOT::handlePhysPresenceWindow();
    if (l_err)
    {
        TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                   "call_host_secureboot_lockdown: Error back from "
                   "SECUREBOOT::handlePhysPresence: "
                   TRACE_ERR_FMT,
                   TRACE_ERR_ARGS(l_err));
        l_istepError.addErrorDetails(l_err);
        ERRORLOG::errlCommit(l_err, ISTEP_COMP_ID);
        break;
    }
#endif
    }while(0);

#endif // CONFIG_VPO_COMPILE

    TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                EXIT_MRK"call_host_secureboot_lockdown");

    return l_istepError.getErrorHandle();
}

};
<commit_msg>Fence all non-functional TPMs at Processor-level<commit_after>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/isteps/istep10/call_host_secureboot_lockdown.C $      */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2020,2021                        */
/* [+] 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                                                     */
/**
   @file call_host_secureboot_lockdown.C
 *
 *  Support file for IStep: host_secureboot_lockdown
 *    This istep will do these things (not necessarily in this order):
 *      1) Check for TPM policies are valid
 *      2) Check for secureboot consistency between procs
 *      3) Set the SUL security bit so that SBE image cannot be updated
 *      4) Ensure that the SAB security bit is read only
 *      5) If a TPM is non functional, set the TDP (TPM Deconfig Protection)
 *         to prevent attack vector
 *      6) Check for a reason, such as a Key Clear Request, to re-IPL the
 *         system so the system owner can assert physical presence
 *      7) Check Scratch Regiser 11 (0x50182) to see if SBE is reporting a previous fail.
 *
 */

// For istep and error logging support
#include <isteps/hwpisteperror.H>
#include <isteps/istep_reasoncodes.H>
#include <initservice/initserviceif.H>
#include <initservice/mboxRegs.H>
#include <istepHelperFuncs.H>
#include <errl/errlentry.H>
#include <errl/errlmanager.H>
#include <errl/errludlogregister.H>
#include <targeting/common/targetservice.H>

// For Secureboot, Trustedboot support
#include <secureboot/service.H>
#include <secureboot/phys_presence_if.H>
#include <secureboot/service_ext.H>
#include <secureboot/trustedbootif.H>

// Secureboot lockdown HWP
#include <plat_hwp_invoker.H>
#include <p10_update_security_ctrl.H>

// PHyp/OPAL loads
#include <targeting/common/mfgFlagAccessors.H>

namespace ISTEP_10
{

void* call_host_secureboot_lockdown (void *io_pArgs)
{
    TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                ENTER_MRK"call_host_secureboot_lockdown");

    ISTEP_ERROR::IStepError l_istepError;
#ifndef CONFIG_VPO_COMPILE
    errlHndl_t l_err = nullptr;

    do {

    // Attempt to initialize the backup TPM.
    TRUSTEDBOOT::initBackupTpm();

    // Always poison the backup TPM because we want to ensure
    // it varies from the primary.
    l_err = TRUSTEDBOOT::poisonBackupTpm();

    if(l_err)
    {
        TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                  "call_host_secureboot_lockdown: poisonBackupTpm returned an error"
                  TRACE_ERR_FMT,
                  TRACE_ERR_ARGS(l_err));
        l_istepError.addErrorDetails(l_err);
        TARGETING::Target * backup_tpm = nullptr;
        TRUSTEDBOOT::getBackupTpm(backup_tpm);
        assert(backup_tpm != nullptr, "call_host_secureboot_lockdown: poisonBackupTpm returned an error when no backup tpm available");
        // tpmMarkFailed will ensure there is at minimum a deconfig callout for the backup
        // TPM and also set the deconfig bit to force fencing if security is enabled
        TRUSTEDBOOT::tpmMarkFailed(backup_tpm, l_err);
    }

#ifdef CONFIG_SECUREBOOT

    if(SECUREBOOT::enabled())
    {
        TARGETING::TargetHandleList l_procList;
        TARGETING::TargetHandleList l_tpmList;

        getAllChips(l_procList,TARGETING::TYPE_PROC);
        getAllChips(l_tpmList,TARGETING::TYPE_TPM,false);

        TARGETING::Target* boot_proc = nullptr;
        l_err = TARGETING::targetService().queryMasterProcChipTargetHandle(boot_proc);
        if(l_err)
        {
            TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                      "call_host_secureboot_lockdown: FAIL getting boot proc"
                      TRACE_ERR_FMT,
                      TRACE_ERR_ARGS(l_err));

            captureError(l_err, l_istepError, HWPF_COMP_ID);

            // If targeting can't get the boot proc, then it's broke, so break here
            break;
        }

        for(const auto& l_proc : l_procList)
        {
            // Check if processor has a TPM that needs to be protected by setting the TDP bit
            // Stage 0: Assume the proc does NOT have a TPM connected to it
            //          - If a proc is not connected to a TPM then set its TDP bit
            // Stage 1: See if the proc has a TPM assigned to it according to the MRW
            //          - for each TPM in the list compare SPI master path with
            //            the path of the current processor to see if they are connected
            // Stage 2: If they are connected and the TPM is functional then there is no need
            //          to protect it.  Otherwise, the TPM needs to be protected.
            bool l_protectTpm = true; // Stage 0 assumption
            for (auto itpm : l_tpmList)
            {
                auto l_physPath = l_proc->getAttr<TARGETING::ATTR_PHYS_PATH>();

                auto l_tpmInfo = itpm->getAttr<TARGETING::ATTR_SPI_TPM_INFO>();

                if (l_tpmInfo.spiMasterPath == l_physPath) // Stage 1 check
                {
                    auto hwasState = itpm->getAttr<TARGETING::ATTR_HWAS_STATE>();

                    if (hwasState.functional == true) // Stage 2 check
                    {
                        l_protectTpm = false;
                    }

                    // Only one possible TPM per processor so break from the TPM loop here
                    break;
                }
            }
            if (l_protectTpm)
            {
                uint8_t l_set_protectTpm = 1;
                l_proc->setAttr<
                    TARGETING::ATTR_SECUREBOOT_PROTECT_DECONFIGURED_TPM
                                                                    >(l_set_protectTpm);
            }

            // Check that the SBE did not use Scratch Register 11 (0x50182) to pass FFDC
            // on a secureboot validation error up to hostboot to log an error
            uint64_t scomData = 0x0;
            size_t op_size = sizeof(scomData);

            // For boot proc read from attribute that was saved off at the start of the IPL
            if (l_proc == boot_proc)
            {
                const auto l_scratchRegs = TARGETING::UTIL::assertGetToplevelTarget()->
                                             getAttrAsStdArr<TARGETING::ATTR_MASTER_MBOX_SCRATCH>();

                // Write to uint64_t scomData even though MboxScratch11_t::REG_IDX is a uint32_t
                // This will preserve the scomData != 0 check below for all processors
                scomData = l_scratchRegs[INITSERVICE::SPLESS::MboxScratch11_t::REG_IDX];

            }
            // For non-boot procs read Scratch Register 11 (0x50182) directly from HW
            else
            {
                l_err = deviceRead(
                            l_proc,
                            &scomData,
                            op_size,
                            DEVICE_SCOM_ADDRESS(INITSERVICE::SPLESS::MboxScratch11_t::REG_ADDR));
                if(l_err)
                {
                    TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                              "call_host_secureboot_lockdown: SCOM Read of MAILBOX_SCRATCH_REG_11 "
                              "(0x%X) failed for Proc HUID 0x%08x "
                              TRACE_ERR_FMT,
                              INITSERVICE::SPLESS::MboxScratch11_t::REG_ADDR,
                              TARGETING::get_huid(l_proc),
                              TRACE_ERR_ARGS(l_err));

                    // Among other things, this will add the proc target to the log
                    captureError(l_err, l_istepError, HWPF_COMP_ID, l_proc);

                    // Try to run the HWP on all procs regardless of error.
                    continue;
                }
            }

            if (scomData != 0x0)
            {
                TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                          "call_host_secureboot_lockdown: SBE reported FFDC Data in Scratch Reg 11 "
                          "(addr=0x%X) for Proc HUID 0x%08X: data = 0x%.16llX "
                          TRACE_ERR_FMT,
                          INITSERVICE::SPLESS::MboxScratch11_t::REG_ADDR,
                          TARGETING::get_huid(l_proc), scomData,
                          TRACE_ERR_ARGS(l_err));

               /*@
                 * @errortype
                 * @moduleid    ISTEP::MOD_SECUREBOOT_LOCKDOWN
                 * @reasoncode  ISTEP::RC_SBE_REPORTED_FFDC
                 * @userdata1   HUID of Processor Target target
                 * @userdata2   Scom Data
                 * @devdesc     SBE put FFDC data into Scratch Register 11
                 * @custdesc    A problem occurred during the IPL of the
                 *              system and the system will reboot.
                 */
                l_err = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                ISTEP::MOD_SECUREBOOT_LOCKDOWN,
                                ISTEP::RC_SBE_REPORTED_FFDC,
                                TARGETING::get_huid(l_proc),
                                scomData);

                l_err->addHwCallout( l_proc,
                                     HWAS::SRCI_PRIORITY_HIGH,
                                     HWAS::DELAYED_DECONFIG,
                                     HWAS::GARD_NULL );

                // Add the register to the log
                ERRORLOG::ErrlUserDetailsLogRegister(l_proc,
                              &scomData,
                              op_size,
                              DEVICE_SCOM_ADDRESS(INITSERVICE::SPLESS::MboxScratch11_t::REG_ADDR))
                                  .addToLog(l_err);

                // Among other things, this will add the proc target to the log
                captureError(l_err, l_istepError, HWPF_COMP_ID, l_proc);

                // Try to run the HWP on all procs regardless of error.
                continue;
            }

            const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>l_fapiProc(l_proc);
            const bool DO_NOT_FORCE_SECURITY = false; // No need to force security
            const bool DO_NOT_LOCK_ABUS_MAILBOXES = false; // Do not lock abus mailboxes
            FAPI_INVOKE_HWP(l_err,
                            p10_update_security_ctrl,
                            l_fapiProc,
                            DO_NOT_FORCE_SECURITY,
                            DO_NOT_LOCK_ABUS_MAILBOXES);
            if(l_err)
            {
                TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                          "call_host_secureboot_lockdown: p10_update_security_ctrl failed for Proc HUID 0x%08x "
                          TRACE_ERR_FMT, TARGETING::get_huid(l_proc),
                          TRACE_ERR_ARGS(l_err));
                l_istepError.addErrorDetails(l_err);
                ERRORLOG::errlCommit(l_err, ISTEP_COMP_ID);
                // Try to run the HWP on all procs regardless of error.
            }
            // Lock OPAL keystore if in PHyp boot
            if (TARGETING::is_phyp_load())
            {
                l_err = SECUREBOOT::setSecuritySwitchBits({ SECUREBOOT::ProcSecurity::KsOpalBank0WrLock,
                    SECUREBOOT::ProcSecurity::KsOpalBank0RdLock,
                    SECUREBOOT::ProcSecurity::KsOpalBank1WrLock,
                    SECUREBOOT::ProcSecurity::KsOpalBank1RdLock,
                    SECUREBOOT::ProcSecurity::KsOpalQueueWrLock,
                    SECUREBOOT::ProcSecurity::KsOpalQueueRdLock },
                    l_proc);
                if (l_err)
                {
                    TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                        "call_host_secureboot_lockdown: "
                        "Cannot lock OPAL keystore on PROC 0x%08x ",
                        TRACE_ERR_FMT, TARGETING::get_huid(l_proc),
                        TRACE_ERR_ARGS(l_err));
                    l_istepError.addErrorDetails(l_err);
                    ERRORLOG::errlCommit(l_err, ISTEP_COMP_ID);
                }
            }
            else
            {
                // Lock Phyp keystore if in OPAL boot
                l_err = SECUREBOOT::setSecuritySwitchBits({ SECUREBOOT::ProcSecurity::KsPhypWrLock,
                    SECUREBOOT::ProcSecurity::KsPhypRdLock },
                    l_proc);
                if (l_err)
                {
                    TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                        "call_host_secureboot_lockdown: "
                        "Cannot lock PHyp keystore on PROC 0x%08x ",
                        TRACE_ERR_FMT, TARGETING::get_huid(l_proc),
                        TRACE_ERR_ARGS(l_err));
                    l_istepError.addErrorDetails(l_err);
                    ERRORLOG::errlCommit(l_err, ISTEP_COMP_ID);
                }
            }
        } // end of loop on procs
    } // end of SECUREBOOT::enabled() check
    if(l_istepError.getErrorHandle())
    {
        break;
    }

    SECUREBOOT::validateSecuritySettings();
#endif

#ifdef CONFIG_PHYS_PRES_PWR_BUTTON
    // Check to see if a Physical Presence Window should be opened,
    // and if so, open it.  This could result in the system being shutdown
    // to allow the system administrator to assert physical presence
    l_err = SECUREBOOT::handlePhysPresenceWindow();
    if (l_err)
    {
        TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                   "call_host_secureboot_lockdown: Error back from "
                   "SECUREBOOT::handlePhysPresence: "
                   TRACE_ERR_FMT,
                   TRACE_ERR_ARGS(l_err));
        l_istepError.addErrorDetails(l_err);
        ERRORLOG::errlCommit(l_err, ISTEP_COMP_ID);
        break;
    }
#endif
    }while(0);

#endif // CONFIG_VPO_COMPILE

    TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                EXIT_MRK"call_host_secureboot_lockdown");

    return l_istepError.getErrorHandle();
}

};
<|endoftext|>