public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch][edk2-platforms/devel-MinnowBoard3-UDK2017] fTPM
@ 2017-11-10  7:27 xianhu2x
  0 siblings, 0 replies; only message in thread
From: xianhu2x @ 2017-11-10  7:27 UTC (permalink / raw)
  To: edk2-devel

Boot failed after PTT is enabled with gcc-built image

Contributed-under: TianoCore Contribution Agreement 1.1

Signed-off-by: xianhu2x <xianhuix.liu@intel.com>
---
 .../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



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-11-10  7:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-10  7:27 [Patch][edk2-platforms/devel-MinnowBoard3-UDK2017] fTPM xianhu2x

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox