public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel][PATCH v2] IntelFsp2Pkg: BaseFspDebugLibSerialPort Support for X64
@ 2022-03-14  2:32 Kuo, Ted
  2022-03-15  2:46 ` Chiu, Chasel
  0 siblings, 1 reply; 2+ messages in thread
From: Kuo, Ted @ 2022-03-14  2:32 UTC (permalink / raw)
  To: devel; +Cc: Chasel Chiu, Nate DeSimone, Star Zeng, Ashraf Ali S

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3833
Add BaseFspDebugLibSerialPort Support for X64.

Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Ashraf Ali S <ashraf.ali.s@intel.com>
Cc: Ted Kuo <ted.kuo@intel.com>
Signed-off-by: Ted Kuo <ted.kuo@intel.com>
---
 .../BaseFspDebugLibSerialPort.inf                  |  5 ++-
 .../Library/BaseFspDebugLibSerialPort/DebugLib.c   | 39 +++++++++++++---------
 .../BaseFspDebugLibSerialPort/X64/FspDebug.nasm    | 25 ++++++++++++++
 3 files changed, 53 insertions(+), 16 deletions(-)
 create mode 100644 IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/X64/FspDebug.nasm

diff --git a/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/BaseFspDebugLibSerialPort.inf b/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/BaseFspDebugLibSerialPort.inf
index 14b1899e6c..395def57c3 100644
--- a/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/BaseFspDebugLibSerialPort.inf
+++ b/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/BaseFspDebugLibSerialPort.inf
@@ -16,7 +16,7 @@
   LIBRARY_CLASS                  = DebugLib
 
 #
-#  VALID_ARCHITECTURES           = IA32
+#  VALID_ARCHITECTURES           = IA32 X64
 #
 
 [Sources]
@@ -25,6 +25,9 @@
 [Sources.Ia32]
   Ia32/FspDebug.nasm
 
+[Sources.X64]
+  X64/FspDebug.nasm
+
 [Packages]
   MdePkg/MdePkg.dec
   IntelFsp2Pkg/IntelFsp2Pkg.dec
diff --git a/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/DebugLib.c b/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/DebugLib.c
index c8824cde7f..cb2317bfb2 100644
--- a/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/DebugLib.c
+++ b/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/DebugLib.c
@@ -33,7 +33,7 @@ VA_LIST  mVaListNull;
 
   @return StackFramePointer  stack frame pointer of function call.
 **/
-UINT32 *
+UINTN *
 EFIAPI
 GetStackFramePointer (
   VOID
@@ -193,13 +193,13 @@ DebugBPrint (
 **/
 VOID
 FillHex (
-  UINT32  Value,
+  UINTN   Value,
   CHAR8   *Buffer
   )
 {
   INTN  Idx;
 
-  for (Idx = 7; Idx >= 0; Idx--) {
+  for (Idx = (sizeof (UINTN) * 2) - 1; Idx >= 0; Idx--) {
     Buffer[Idx] = mHexTable[Value & 0x0F];
     Value     >>= 4;
   }
@@ -228,26 +228,35 @@ DebugAssertInternal (
   )
 {
   CHAR8   Buffer[MAX_DEBUG_MESSAGE_LENGTH];
-  UINT32  *Frame;
+  UINTN   *Frame;
 
-  Frame = (UINT32 *)GetStackFramePointer ();
+  Frame = (UINTN *)GetStackFramePointer ();
 
   //
   // Generate the ASSERT() message in Ascii format
   //
-  AsciiStrnCpyS (
-    Buffer,
-    sizeof (Buffer) / sizeof (CHAR8),
-    "-> EBP:0x00000000  EIP:0x00000000\n",
-    sizeof (Buffer) / sizeof (CHAR8) - 1
-    );
+  if (sizeof (UINTN) == sizeof (UINT32)) {
+    AsciiStrnCpyS (
+      Buffer,
+      sizeof (Buffer) / sizeof (CHAR8),
+      "-> EBP:0x00000000  EIP:0x00000000\n",
+      sizeof (Buffer) / sizeof (CHAR8) - 1
+      );
+  } else {
+    AsciiStrnCpyS (
+      Buffer,
+      sizeof (Buffer) / sizeof (CHAR8),
+      "-> RBP:0x0000000000000000  RIP:0x0000000000000000\n",
+      sizeof (Buffer) / sizeof (CHAR8) - 1
+      );
+  }
   SerialPortWrite ((UINT8 *)"ASSERT DUMP:\n", 13);
   while (Frame != NULL) {
-    FillHex ((UINT32)Frame, Buffer + 9);
-    FillHex (Frame[1], Buffer + 9 + 8 + 8);
+    FillHex ((UINTN)Frame, Buffer + 9);
+    FillHex (Frame[1], Buffer + 9 + (sizeof (UINTN) * 2) + 8);
     SerialPortWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer));
-    if ((Frame[0] > (UINT32)Frame) && (Frame[0] < (UINT32)Frame + 0x00100000)) {
-      Frame = (UINT32 *)Frame[0];
+    if ((Frame[0] > (UINTN)Frame) && (Frame[0] < (UINTN)Frame + 0x00100000)) {
+      Frame = (UINTN *)Frame[0];
     } else {
       Frame = NULL;
     }
diff --git a/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/X64/FspDebug.nasm b/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/X64/FspDebug.nasm
new file mode 100644
index 0000000000..6cf0f0af8b
--- /dev/null
+++ b/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/X64/FspDebug.nasm
@@ -0,0 +1,25 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+; Abstract:
+;
+;   FSP Debug functions
+;
+;------------------------------------------------------------------------------
+
+    SECTION .text
+
+;------------------------------------------------------------------------------
+; UINT32 *
+; EFIAPI
+; GetStackFramePointer (
+;   VOID
+;   );
+;------------------------------------------------------------------------------
+global ASM_PFX(GetStackFramePointer)
+ASM_PFX(GetStackFramePointer):
+    mov     rax, rbp
+    ret
+
-- 
2.16.2.windows.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [edk2-devel][PATCH v2] IntelFsp2Pkg: BaseFspDebugLibSerialPort Support for X64
  2022-03-14  2:32 [edk2-devel][PATCH v2] IntelFsp2Pkg: BaseFspDebugLibSerialPort Support for X64 Kuo, Ted
@ 2022-03-15  2:46 ` Chiu, Chasel
  0 siblings, 0 replies; 2+ messages in thread
From: Chiu, Chasel @ 2022-03-15  2:46 UTC (permalink / raw)
  To: Kuo, Ted, devel@edk2.groups.io
  Cc: Desimone, Nathaniel L, Zeng, Star, S, Ashraf Ali


Thanks Ted for updating patch!
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>


> -----Original Message-----
> From: Kuo, Ted <ted.kuo@intel.com>
> Sent: Monday, March 14, 2022 10:33 AM
> To: devel@edk2.groups.io
> Cc: Chiu, Chasel <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>; Zeng, Star <star.zeng@intel.com>; S, Ashraf
> Ali <ashraf.ali.s@intel.com>
> Subject: [edk2-devel][PATCH v2] IntelFsp2Pkg: BaseFspDebugLibSerialPort
> Support for X64
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3833
> Add BaseFspDebugLibSerialPort Support for X64.
> 
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Ashraf Ali S <ashraf.ali.s@intel.com>
> Cc: Ted Kuo <ted.kuo@intel.com>
> Signed-off-by: Ted Kuo <ted.kuo@intel.com>
> ---
>  .../BaseFspDebugLibSerialPort.inf                  |  5 ++-
>  .../Library/BaseFspDebugLibSerialPort/DebugLib.c   | 39 +++++++++++++---------
>  .../BaseFspDebugLibSerialPort/X64/FspDebug.nasm    | 25 ++++++++++++++
>  3 files changed, 53 insertions(+), 16 deletions(-)  create mode 100644
> IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/X64/FspDebug.nasm
> 
> diff --git
> a/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/BaseFspDebugLibSerialPort.i
> nf
> b/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/BaseFspDebugLibSerialPort.i
> nf
> index 14b1899e6c..395def57c3 100644
> ---
> a/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/BaseFspDebugLibSerialPort.i
> nf
> +++ b/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/BaseFspDebugLibSeri
> +++ alPort.inf
> @@ -16,7 +16,7 @@
>    LIBRARY_CLASS                  = DebugLib
> 
>  #
> -#  VALID_ARCHITECTURES           = IA32
> +#  VALID_ARCHITECTURES           = IA32 X64
>  #
> 
>  [Sources]
> @@ -25,6 +25,9 @@
>  [Sources.Ia32]
>    Ia32/FspDebug.nasm
> 
> +[Sources.X64]
> +  X64/FspDebug.nasm
> +
>  [Packages]
>    MdePkg/MdePkg.dec
>    IntelFsp2Pkg/IntelFsp2Pkg.dec
> diff --git a/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/DebugLib.c
> b/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/DebugLib.c
> index c8824cde7f..cb2317bfb2 100644
> --- a/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/DebugLib.c
> +++ b/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/DebugLib.c
> @@ -33,7 +33,7 @@ VA_LIST  mVaListNull;
> 
>    @return StackFramePointer  stack frame pointer of function call.
>  **/
> -UINT32 *
> +UINTN *
>  EFIAPI
>  GetStackFramePointer (
>    VOID
> @@ -193,13 +193,13 @@ DebugBPrint (
>  **/
>  VOID
>  FillHex (
> -  UINT32  Value,
> +  UINTN   Value,
>    CHAR8   *Buffer
>    )
>  {
>    INTN  Idx;
> 
> -  for (Idx = 7; Idx >= 0; Idx--) {
> +  for (Idx = (sizeof (UINTN) * 2) - 1; Idx >= 0; Idx--) {
>      Buffer[Idx] = mHexTable[Value & 0x0F];
>      Value     >>= 4;
>    }
> @@ -228,26 +228,35 @@ DebugAssertInternal (
>    )
>  {
>    CHAR8   Buffer[MAX_DEBUG_MESSAGE_LENGTH];
> -  UINT32  *Frame;
> +  UINTN   *Frame;
> 
> -  Frame = (UINT32 *)GetStackFramePointer ();
> +  Frame = (UINTN *)GetStackFramePointer ();
> 
>    //
>    // Generate the ASSERT() message in Ascii format
>    //
> -  AsciiStrnCpyS (
> -    Buffer,
> -    sizeof (Buffer) / sizeof (CHAR8),
> -    "-> EBP:0x00000000  EIP:0x00000000\n",
> -    sizeof (Buffer) / sizeof (CHAR8) - 1
> -    );
> +  if (sizeof (UINTN) == sizeof (UINT32)) {
> +    AsciiStrnCpyS (
> +      Buffer,
> +      sizeof (Buffer) / sizeof (CHAR8),
> +      "-> EBP:0x00000000  EIP:0x00000000\n",
> +      sizeof (Buffer) / sizeof (CHAR8) - 1
> +      );
> +  } else {
> +    AsciiStrnCpyS (
> +      Buffer,
> +      sizeof (Buffer) / sizeof (CHAR8),
> +      "-> RBP:0x0000000000000000  RIP:0x0000000000000000\n",
> +      sizeof (Buffer) / sizeof (CHAR8) - 1
> +      );
> +  }
>    SerialPortWrite ((UINT8 *)"ASSERT DUMP:\n", 13);
>    while (Frame != NULL) {
> -    FillHex ((UINT32)Frame, Buffer + 9);
> -    FillHex (Frame[1], Buffer + 9 + 8 + 8);
> +    FillHex ((UINTN)Frame, Buffer + 9);
> +    FillHex (Frame[1], Buffer + 9 + (sizeof (UINTN) * 2) + 8);
>      SerialPortWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer));
> -    if ((Frame[0] > (UINT32)Frame) && (Frame[0] < (UINT32)Frame +
> 0x00100000)) {
> -      Frame = (UINT32 *)Frame[0];
> +    if ((Frame[0] > (UINTN)Frame) && (Frame[0] < (UINTN)Frame + 0x00100000))
> {
> +      Frame = (UINTN *)Frame[0];
>      } else {
>        Frame = NULL;
>      }
> diff --git
> a/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/X64/FspDebug.nasm
> b/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/X64/FspDebug.nasm
> new file mode 100644
> index 0000000000..6cf0f0af8b
> --- /dev/null
> +++ b/IntelFsp2Pkg/Library/BaseFspDebugLibSerialPort/X64/FspDebug.nasm
> @@ -0,0 +1,25 @@
> +;----------------------------------------------------------------------
> +--------
> +;
> +; Copyright (c) 2022, Intel Corporation. All rights reserved.<BR> ;
> +SPDX-License-Identifier: BSD-2-Clause-Patent ; ; Abstract:
> +;
> +;   FSP Debug functions
> +;
> +;----------------------------------------------------------------------
> +--------
> +
> +    SECTION .text
> +
> +;----------------------------------------------------------------------
> +--------
> +; UINT32 *
> +; EFIAPI
> +; GetStackFramePointer (
> +;   VOID
> +;   );
> +;----------------------------------------------------------------------
> +--------
> +global ASM_PFX(GetStackFramePointer)
> +ASM_PFX(GetStackFramePointer):
> +    mov     rax, rbp
> +    ret
> +
> --
> 2.16.2.windows.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-15  2:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-14  2:32 [edk2-devel][PATCH v2] IntelFsp2Pkg: BaseFspDebugLibSerialPort Support for X64 Kuo, Ted
2022-03-15  2:46 ` Chiu, Chasel

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