From 046a682f1e967a19227240f48d4036ee157ac7fb Mon Sep 17 00:00:00 2001 From: Claudio Carvalho Date: Wed, 28 Sep 2016 05:01:22 -0300 Subject: libstb/tss: implement TSS required functions Hostboot shares the TSS code with phyp and skiboot, but the functions declared in trustedbootUtils.H are hostboot specific and must be implemented by the TSS downstream consumers. This implements the trustedbootUtils.H functions. Signed-off-by: Claudio Carvalho Signed-off-by: Stewart Smith --- libstb/tss/trustedbootUtils.C | 115 ++++++++++++------------------------------ libstb/tss/trustedbootUtils.H | 1 + 2 files changed, 32 insertions(+), 84 deletions(-) (limited to 'libstb/tss') diff --git a/libstb/tss/trustedbootUtils.C b/libstb/tss/trustedbootUtils.C index 9091503..ba6667f 100644 --- a/libstb/tss/trustedbootUtils.C +++ b/libstb/tss/trustedbootUtils.C @@ -1,97 +1,44 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/usr/secureboot/trusted/trustedbootUtils.C $ */ -/* */ -/* OpenPOWER HostBoot Project */ -/* */ -/* Contributors Listed Below - COPYRIGHT 2015,2016 */ -/* [+] 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 trustedbootUtils.C +/* Copyright 2013-2016 IBM Corp. * - * @brief Trusted boot utility functions + * 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. */ -// ---------------------------------------------- -// Includes -// ---------------------------------------------- -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "trustedbootUtils.H" -#include "trustedbootCmds.H" #include "trustedboot.H" -#include "trustedTypes.H" - +#include +#include -namespace TRUSTEDBOOT +errlHndl_t tpmTransmit(TpmTarget * io_target, uint8_t* io_buffer, + size_t i_cmdSize, size_t i_bufsize ) { + errlHndl_t err = NULL; + err = io_target->driver->transmit(io_target->dev, + io_buffer, + i_cmdSize, + &i_bufsize); + return err; +} -errlHndl_t tpmTransmit(TpmTarget * io_target, - uint8_t* io_buffer, - size_t i_cmdSize, - size_t i_bufsize ) +errlHndl_t tpmCreateErrorLog(const uint8_t i_modId, const uint16_t i_reasonCode, + const uint64_t i_user1, const uint64_t i_user2) { - errlHndl_t err = NULL; - - do - { - // Send to the TPM - err = deviceRead(io_target->tpmTarget, - io_buffer, - i_bufsize, - DEVICE_TPM_ADDRESS(TPMDD::TPM_OP_TRANSMIT, - i_cmdSize)); - if (NULL != err) - { - break; - } - - - } while ( 0 ); - - return err; + prlog(PR_ERR,"TSS: Error Log %d %d %d %d\n", + i_modId, i_reasonCode, (int)i_user1, (int)i_user2); + return (i_modId << 16) | i_reasonCode; } -errlHndl_t tpmCreateErrorLog(const uint8_t i_modId, - const uint16_t i_reasonCode, - const uint64_t i_user1, - const uint64_t i_user2) +void tpmMarkFailed(TpmTarget *io_target) { - errlHndl_t err = new ERRORLOG::ErrlEntry( ERRORLOG::ERRL_SEV_UNRECOVERABLE, - i_modId, - i_reasonCode, - i_user1, - i_user2, - true /*Add HB SW Callout*/ ); - err->collectTrace( SECURE_COMP_NAME ); - return err; + prlog(PR_ERR, "TSS: %s called for %d\n", __func__, io_target->id); } - -} // end TRUSTEDBOOT diff --git a/libstb/tss/trustedbootUtils.H b/libstb/tss/trustedbootUtils.H index 73bc387..7b8bb61 100644 --- a/libstb/tss/trustedbootUtils.H +++ b/libstb/tss/trustedbootUtils.H @@ -40,6 +40,7 @@ // Includes // ----------------------------------------------- #include "trustedTypes.H" +#include "../tpm_chip.h" #ifdef __cplusplus namespace TRUSTEDBOOT -- cgit v1.1