From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web10.22272.1647225193856931418 for ; Sun, 13 Mar 2022 19:33:14 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=V7DXrZ5F; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: ted.kuo@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1647225193; x=1678761193; h=from:to:cc:subject:date:message-id; bh=ojlVM7TI0hxVjgSNTgx+z8S96RfVTcJYvur+iZch6Dk=; b=V7DXrZ5Ft+0EV4nJpom4hwunhz1sZuZFJchORJRT7GkeDAyUZ3lbCvfB HgsvXb3GSbfTyvxL57+kRXA7OCqSEuM+H+zN5v1uF35KwE7hWafjo7fjI rH1IxWQWtUgr0yc3PbqzDaW6fekrG63WN1V2G3B/ovmb46WvNGdBUsjGn RJbFdDcNjnGop2kh4+JkhvlFS+uUfC+lOY7iZ2PCCJp5QnHjrW82T/wRZ B6IfEjd0ruz7ZL23/xmWekx9R6YK9D1o0vm24wvpUG9Qd6RRljg5qdiDN ZqnMbup2rd0ZsMMowEztEi0rlhj0bm9JTQ9HNboBZWxBYUxFujcCBz2l4 Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10285"; a="243368607" X-IronPort-AV: E=Sophos;i="5.90,179,1643702400"; d="scan'208";a="243368607" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2022 19:33:13 -0700 X-IronPort-AV: E=Sophos;i="5.90,179,1643702400"; d="scan'208";a="634032961" Received: from tedkuo1-win10.gar.corp.intel.com ([10.5.215.13]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2022 19:33:11 -0700 From: "Kuo, Ted" To: devel@edk2.groups.io Cc: Chasel Chiu , Nate DeSimone , Star Zeng , Ashraf Ali S Subject: [edk2-devel][PATCH v2] IntelFsp2Pkg: BaseFspDebugLibSerialPort Support for X64 Date: Mon, 14 Mar 2022 10:32:42 +0800 Message-Id: <36aaf49894b82a5db9f359e08e10057f9ea14922.1647225139.git.ted.kuo@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3833 Add BaseFspDebugLibSerialPort Support for X64. Cc: Chasel Chiu Cc: Nate DeSimone Cc: Star Zeng Cc: Ashraf Ali S Cc: Ted Kuo Signed-off-by: Ted Kuo --- .../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.
+; 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