public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v1 0/1] AMD/AmdMinBoardPkg: Implements SpcrDeviceLib library
@ 2023-05-08  7:03 Abdul Lateef Attar
  2023-05-08  7:03 ` [PATCH v1 1/1] " Abdul Lateef Attar
  2023-05-09  6:41 ` [PATCH v1 0/1] " Chang, Abner
  0 siblings, 2 replies; 3+ messages in thread
From: Abdul Lateef Attar @ 2023-05-08  7:03 UTC (permalink / raw)
  To: devel; +Cc: Abdul Lateef Attar, Abner Chang

PR: https://github.com/tianocore/edk2-platforms/pull/81

Implements SpcrDeviceLib for AmdMinBoardPkg.

Cc: Abner Chang <abner.chang@amd.com>
Cc: Abdul Lateef Attar <abdattar@amd.com>


Abdul Lateef Attar (1):
  AMD/AmdMinBoardPkg: Implements SpcrDeviceLib library

 .../AMD/AmdMinBoardPkg/AmdMinBoardPkg.dsc     |  6 ++
 .../Library/SpcrDeviceLib/SpcrDeviceLib.inf   | 23 +++++
 .../Library/SpcrDeviceLib/SpcrDeviceLib.c     | 84 +++++++++++++++++++
 3 files changed, 113 insertions(+)
 create mode 100755 Platform/AMD/AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.inf
 create mode 100755 Platform/AMD/AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.c

-- 
2.25.1


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

* [PATCH v1 1/1] AMD/AmdMinBoardPkg: Implements SpcrDeviceLib library
  2023-05-08  7:03 [PATCH v1 0/1] AMD/AmdMinBoardPkg: Implements SpcrDeviceLib library Abdul Lateef Attar
@ 2023-05-08  7:03 ` Abdul Lateef Attar
  2023-05-09  6:41 ` [PATCH v1 0/1] " Chang, Abner
  1 sibling, 0 replies; 3+ messages in thread
From: Abdul Lateef Attar @ 2023-05-08  7:03 UTC (permalink / raw)
  To: devel; +Cc: Abdul Lateef Attar, Abner Chang

Implements SpcrDeviceLib library for AMD common boards.

Cc: Abner Chang <abner.chang@amd.com>
Signed-off-by: Abdul Lateef Attar <abdattar@amd.com>
---
 .../AMD/AmdMinBoardPkg/AmdMinBoardPkg.dsc     |  6 ++
 .../Library/SpcrDeviceLib/SpcrDeviceLib.inf   | 23 +++++
 .../Library/SpcrDeviceLib/SpcrDeviceLib.c     | 84 +++++++++++++++++++
 3 files changed, 113 insertions(+)
 create mode 100755 Platform/AMD/AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.inf
 create mode 100755 Platform/AMD/AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.c

diff --git a/Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dsc b/Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dsc
index 2f17db5df5fb..273cd74f7842 100644
--- a/Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dsc
+++ b/Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dsc
@@ -22,9 +22,15 @@ [Packages]
   MinPlatformPkg/MinPlatformPkg.dec
   UefiCpuPkg/UefiCpuPkg.dec
 
+[LibraryClasses]
+  SpcrDeviceLib|AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.inf
+
 [LibraryClasses.common.PEIM]
   SetCacheMtrrLib|AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrrLib.inf
 
+[Components]
+  AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.inf
+
 [Components.IA32]
   AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrrLib.inf
 
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.inf b/Platform/AMD/AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.inf
new file mode 100755
index 000000000000..d9b77e586aa8
--- /dev/null
+++ b/Platform/AMD/AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.inf
@@ -0,0 +1,23 @@
+## @file
+# Implementation for SpcrDeviceLib Library.
+# SpcrDeviceLib is usd for Serial Port Console Redirection Table (SPCR) device.
+#
+# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION                    = 1.29
+  BASE_NAME                      = SpcrDeviceLib
+  FILE_GUID                      = 9232A55A-45E3-424A-94C6-615AF63C9A6B
+  VERSION_STRING                 = 1.0
+  MODULE_TYPE                    = BASE
+  LIBRARY_CLASS                  = SpcrDeviceLib
+
+[Packages]
+  MdePkg/MdePkg.dec
+
+[Sources]
+  SpcrDeviceLib.c
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.c b/Platform/AMD/AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.c
new file mode 100755
index 000000000000..0762f16fb360
--- /dev/null
+++ b/Platform/AMD/AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.c
@@ -0,0 +1,84 @@
+/** @file
+
+Implements SpcrDeviceLib library functions.
+This library implementation is for AMD processor based platforms.
+
+Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Include/Uefi.h>
+#include <Protocol/DevicePath.h>
+#include <Library/UefiLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+
+STATIC EFI_GUID  TerminalTypeGuid[] = {
+  DEVICE_PATH_MESSAGING_PC_ANSI,
+  DEVICE_PATH_MESSAGING_VT_100,
+  DEVICE_PATH_MESSAGING_VT_100_PLUS,
+  DEVICE_PATH_MESSAGING_VT_UTF8
+};
+
+/**
+  Get a Serial Port device for SPCR.
+
+  @retval NULL       Fails to get the DevicePath
+          DevicePath If success
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+EFIAPI
+GetSpcrDevice (
+  VOID
+  )
+{
+  EFI_DEVICE_PATH_PROTOCOL  *VarConsole;
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
+  EFI_DEVICE_PATH_PROTOCOL  *TmpDevicePath;
+  VENDOR_DEVICE_PATH        *Vendor;
+  UINTN                     Size;
+  BOOLEAN                   Found;
+  UINTN                     Index;
+
+  // look for supported terminal type GUID in the device path
+  if (GetEfiGlobalVariable2 (L"ConOut", (VOID **)&VarConsole, NULL) == EFI_SUCCESS) {
+    do {
+      // Get the Single Device Path
+      DevicePath = GetNextDevicePathInstance (&VarConsole, &Size);
+      if (DevicePath == NULL) {
+        return NULL;
+      }
+
+      TmpDevicePath = DevicePath;
+      Found         = FALSE;
+      while (!IsDevicePathEnd (TmpDevicePath)) {
+        // search for terminal type
+        Vendor = (VENDOR_DEVICE_PATH *)TmpDevicePath;
+        for (Index = 0; Index < (sizeof (TerminalTypeGuid) / sizeof (TerminalTypeGuid[0])); Index++) {
+          if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[Index])) {
+            Found = TRUE;
+            break;
+          }
+        }
+
+        if (Found) {
+          break;
+        }
+
+        TmpDevicePath = NextDevicePathNode (TmpDevicePath);
+      }
+
+      if (Found) {
+        return (DevicePath);
+      }
+
+      FreePool (DevicePath);
+    } while (VarConsole != NULL);
+  }
+
+  return NULL;
+}
-- 
2.25.1


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

* Re: [PATCH v1 0/1] AMD/AmdMinBoardPkg: Implements SpcrDeviceLib library
  2023-05-08  7:03 [PATCH v1 0/1] AMD/AmdMinBoardPkg: Implements SpcrDeviceLib library Abdul Lateef Attar
  2023-05-08  7:03 ` [PATCH v1 1/1] " Abdul Lateef Attar
@ 2023-05-09  6:41 ` Chang, Abner
  1 sibling, 0 replies; 3+ messages in thread
From: Chang, Abner @ 2023-05-09  6:41 UTC (permalink / raw)
  To: Attar, AbdulLateef (Abdul Lateef), devel@edk2.groups.io
  Cc: Attar, AbdulLateef (Abdul Lateef)

[AMD Official Use Only - General]

Reviewed-by: Abner Chang <abner.chang@amd.com>

> -----Original Message-----
> From: Abdul Lateef Attar <abdattar@amd.com>
> Sent: Monday, May 8, 2023 3:03 PM
> To: devel@edk2.groups.io
> Cc: Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@amd.com>; Chang,
> Abner <Abner.Chang@amd.com>
> Subject: [PATCH v1 0/1] AMD/AmdMinBoardPkg: Implements SpcrDeviceLib
> library
> 
> PR: https://github.com/tianocore/edk2-platforms/pull/81
> 
> Implements SpcrDeviceLib for AmdMinBoardPkg.
> 
> Cc: Abner Chang <abner.chang@amd.com>
> Cc: Abdul Lateef Attar <abdattar@amd.com>
> 
> 
> Abdul Lateef Attar (1):
>   AMD/AmdMinBoardPkg: Implements SpcrDeviceLib library
> 
>  .../AMD/AmdMinBoardPkg/AmdMinBoardPkg.dsc     |  6 ++
>  .../Library/SpcrDeviceLib/SpcrDeviceLib.inf   | 23 +++++
>  .../Library/SpcrDeviceLib/SpcrDeviceLib.c     | 84 +++++++++++++++++++
>  3 files changed, 113 insertions(+)
>  create mode 100755
> Platform/AMD/AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.inf
>  create mode 100755
> Platform/AMD/AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.c
> 
> --
> 2.25.1

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

end of thread, other threads:[~2023-05-09  6:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-08  7:03 [PATCH v1 0/1] AMD/AmdMinBoardPkg: Implements SpcrDeviceLib library Abdul Lateef Attar
2023-05-08  7:03 ` [PATCH v1 1/1] " Abdul Lateef Attar
2023-05-09  6:41 ` [PATCH v1 0/1] " Chang, Abner

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