From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=xianhuix.liu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 891BF21B00DC0 for ; Thu, 9 Nov 2017 23:23:15 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Nov 2017 23:27:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,373,1505804400"; d="scan'208";a="6087454" Received: from xianhu2x-mobl.ccr.corp.intel.com ([10.239.196.68]) by orsmga002.jf.intel.com with ESMTP; 09 Nov 2017 23:27:16 -0800 From: xianhu2x To: edk2-devel@lists.01.org Date: Fri, 10 Nov 2017 15:27:10 +0800 Message-Id: <20171110072710.15988-1-xianhuix.liu@intel.com> X-Mailer: git-send-email 2.14.1.windows.1 Subject: [Patch][edk2-platforms/devel-MinnowBoard3-UDK2017] fTPM X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Nov 2017 07:23:15 -0000 Boot failed after PTT is enabled with gcc-built image Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: xianhu2x --- .../Txe/Library/PeiDxePttPtpLib/PeiDxePttPtpLib.c | 44 ++++++++++++++-------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/Silicon/BroxtonSoC/BroxtonSiPkg/Txe/Library/PeiDxePttPtpLib/PeiDxePttPtpLib.c b/Silicon/BroxtonSoC/BroxtonSiPkg/Txe/Library/PeiDxePttPtpLib/PeiDxePttPtpLib.c index 24e8c5bb6..89251fa19 100644 --- a/Silicon/BroxtonSoC/BroxtonSiPkg/Txe/Library/PeiDxePttPtpLib/PeiDxePttPtpLib.c +++ b/Silicon/BroxtonSoC/BroxtonSiPkg/Txe/Library/PeiDxePttPtpLib/PeiDxePttPtpLib.c @@ -228,6 +228,8 @@ PttHciSend( { UINT32 ControlStatus; UINT32 WaitTime; + UINTN StartAddress; + UINT32 *ReturnBuffer; // // Make sure that previous command was in fact completed if not, must not @@ -290,12 +292,15 @@ PttHciSend( DataLength += (4 - (DataLength % 4)); DEBUG ((DEBUG_INFO, "to %d\n", DataLength)); } - - MmioWriteBuffer32 ((UINTN) R_PTT_HCI_BASE_ADDRESS + + ReturnBuffer = (UINT32 *)PttBuffer; + StartAddress = (UINTN) R_PTT_HCI_BASE_ADDRESS + ( TPM_LOCALITY_0 * TPM_LOCALITY_BUFFER_SIZE )+ - 0x80, - DataLength, - (UINT32 *) PttBuffer ); + 0x80; + while (DataLength != 0) { + MmioWrite32 ((UINTN) StartAddress, *(ReturnBuffer++)); + StartAddress += sizeof (UINT32); + DataLength-= sizeof (UINT32); + } // // Trigger Command processing by writing to start register @@ -334,6 +339,9 @@ PttHciReceive ( UINT16 Data16; UINT32 Data32; EFI_STATUS Status; + UINT32 *ReturnBuffer; + UINTN StartAddress; + UINT32 DataLength; Status = EFI_SUCCESS; DEBUG ((DEBUG_INFO, "PTT: PttHciReceive start\n")); @@ -365,11 +373,14 @@ PttHciReceive ( // // Read the response data header // - MmioReadBuffer32 ((UINTN) R_PTT_HCI_BASE_ADDRESS + - ( TPM_LOCALITY_0 * TPM_LOCALITY_BUFFER_SIZE )+ - 0x80, - PTT_HCI_RESPONSE_HEADER_SIZE, - (UINT32 *) PttBuffer); + ReturnBuffer = (UINT32 *)PttBuffer; + StartAddress = (UINTN) R_PTT_HCI_BASE_ADDRESS + ( TPM_LOCALITY_0 * TPM_LOCALITY_BUFFER_SIZE ) + 0x80; + DataLength = PTT_HCI_RESPONSE_HEADER_SIZE; + while (DataLength != 0) { + *(ReturnBuffer ++) = MmioRead32 (StartAddress); + StartAddress += sizeof (UINT32); + DataLength -= sizeof (UINT32); + } // // Check the reponse data header (tag, parasize and returncode) @@ -411,11 +422,14 @@ PttHciReceive ( // // Read the entire response data header // - MmioReadBuffer32 ((UINTN) R_PTT_HCI_BASE_ADDRESS + - (TPM_LOCALITY_0 * TPM_LOCALITY_BUFFER_SIZE)+ - 0x80, - *RespSize, - (UINT32 *) PttBuffer); + ReturnBuffer = (UINT32 *)PttBuffer; + StartAddress = (UINTN) R_PTT_HCI_BASE_ADDRESS + ( TPM_LOCALITY_0 * TPM_LOCALITY_BUFFER_SIZE ) + 0x80; + DataLength = *RespSize; + while (DataLength != 0) { + *(ReturnBuffer ++) = MmioRead32 (StartAddress); + StartAddress += sizeof (UINT32); + DataLength -= sizeof (UINT32); + } Exit: return Status; -- 2.14.1.windows.1