From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.43]) by mx.groups.io with SMTP id smtpd.web10.101753.1683529433440712481 for ; Mon, 08 May 2023 00:03:53 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=F9aFiOme; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.237.43, mailfrom: abdullateef.attar@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nE8W0NPVmudMuu+3Mo5SutVqQ99MFYo2H/VEvnVjdYFCxvuvnqqHAD1RK6dcD8GkMQntz/Ss4s/EqgcbQO54/xwHX8Fo52Csc+HHbL4y67tjlhFEFjdV6uPFUEeW2hxZS2KQmGViioHTFJfnckL1gKf3aBS+pN37nbU6nsj8Uz3YevC45RTBiTivuIwStKrC12KE4lg7nqzKOMa4JswYiU3fhjqaRmhZAH+t01Ol8kgBhwFEG1VpIELUyR8z8xgjTlQ48RVjEfIyrLAuQ8vZ0LfDbAKwpsD0dgTif+ltLyS6BQbLk29F2Jy3KhOIRpb4/yGnD46JOEJj5Zltfk5asQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=H4WT23s6qys0pplkVGNfOpdYZ8Zeit0O9AnNhYwfbcQ=; b=hxwiTdLMKKrwCpSXjNmNrs6olXs5BejH+UAmUJg1VX8rk7bwhXadHx6+9K5I3uwu+WqUVmXV9H1EX4tn6rpN7iQPsEE/CfuC9DllT2COrthGZLcmbv24XJ0HE8R9zm3gPrICJrYq5xZc2oCRgxnGPA6RVrAcCINIbxqx6bQwQZfVrHAudmTutyuMq5uiH3dlP9Y9Oz3ZyedQhMjTmbEX4gbukwYtrI7Coto1vJJ7XXjb9208GtS4l8hBRuBI6VWZVXXpzLvhJtka+OI2fhRqlYOWsYPmD/j0OW7APjmZJQMz8RnrP9cGKdz27IqVAqc8sEwMG7zJDoj4blgf6wYaYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H4WT23s6qys0pplkVGNfOpdYZ8Zeit0O9AnNhYwfbcQ=; b=F9aFiOme0OVPoMVsHRoGcRfbrAQfpHr5tMTMJ4bCozeNBs3/WzFVW8wg7g5v1QL4gzFpaHow3KUU7CwfBoMvIQ0axPhkcgK3huxR3528YnQFQhm0SV+XOZXtAi3nSaUafiPG0SuM9WCxc/7HG/aiZX125A8RD/EVgbVLZQjVaWs= Received: from BN9PR03CA0169.namprd03.prod.outlook.com (2603:10b6:408:f4::24) by BL1PR12MB5221.namprd12.prod.outlook.com (2603:10b6:208:30b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.32; Mon, 8 May 2023 07:03:51 +0000 Received: from BL02EPF0000C406.namprd05.prod.outlook.com (2603:10b6:408:f4:cafe::6f) by BN9PR03CA0169.outlook.office365.com (2603:10b6:408:f4::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.32 via Frontend Transport; Mon, 8 May 2023 07:03:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BL02EPF0000C406.mail.protection.outlook.com (10.167.241.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6387.18 via Frontend Transport; Mon, 8 May 2023 07:03:50 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 8 May 2023 02:03:43 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 8 May 2023 00:03:23 -0700 Received: from BLR-LAB-SFW01.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Mon, 8 May 2023 02:03:21 -0500 From: "Abdul Lateef Attar" To: CC: Abdul Lateef Attar , Abner Chang Subject: [PATCH v1 1/1] AMD/AmdMinBoardPkg: Implements SpcrDeviceLib library Date: Mon, 8 May 2023 12:33:17 +0530 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Return-Path: AbdulLateef.Attar@amd.com X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0000C406:EE_|BL1PR12MB5221:EE_ X-MS-Office365-Filtering-Correlation-Id: 81dd42d6-156f-429f-940b-08db4f9260c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QEx0B69IqHvIrR97INpUvMSqbxlpcw8DljVZUx6C9aywsRG7ZteAFsu4Ze9eQm5AJSxMjByoqOHHonKhlf8+U04F9c3+axHQjqX0l4w84EqkJw3chwIYCA5NV7Rp/WmJXPI9kZuEgBEM0ZyDLUVpS3E9qX0MvWYRbS5GBctn06gaqEmU7W8S+lqn/KgUpqndnX9JGxwA1qg6bnrqP6wWfOL1EFIfQ98YEOgbzeHAToP+JtjRtdLm1tGifnU6T6qKIa/0trRn8r7tHo3S2DxEKOS5BEI8X8InD2zq/pLUvCZkRX+IU/xqzIkY6BVHJGmEKk2feH3iJxPRMpzSMMIc7XWBZqfYENNUG9YQSZJ5Z/4ImvrMyPEsSKOim5y+Lu7/qepkVLuhxY+ggP8a8u5hk8gz/Ndn+22fxM8agGaiAWXcoZK8Y63NGq4xMuias5qX/HKZIRCQ5EJGeEvgupqwKw7tOKhWLEM5wNaUnaobucQ+yYO98wJc2jVQIqSKzb4xb0Ro1kFZmbeFTc2OIiBAqebMprIL/kkJK4z72BjqjlFjyJ+6vC/hqL1/eCxxESfOVOBUFvSQmC4ZvcjNl0v7NskOSsadAq5r6fNIu9Ow0czolL1hlwMYAe3liPH9v36aa+RFpgJogLZ20qkJow8tmd9+VgRswAXIuE7pn4G0TrqMZa7JRYRqafcjeqXbDua2JqIHCnduSW9w47z5nr5/ZM2iFudOcVjNP8zgmUnvS3M= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(376002)(346002)(396003)(39860400002)(451199021)(40470700004)(36840700001)(46966006)(478600001)(54906003)(2906002)(8936002)(8676002)(316002)(6916009)(4326008)(5660300002)(41300700001)(6666004)(70206006)(70586007)(7696005)(26005)(186003)(356005)(82740400003)(40460700003)(36860700001)(2616005)(36756003)(336012)(47076005)(426003)(82310400005)(40480700001)(81166007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2023 07:03:50.9722 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 81dd42d6-156f-429f-940b-08db4f9260c6 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0000C406.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5221 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain Implements SpcrDeviceLib library for AMD common boards. Cc: Abner Chang Signed-off-by: Abdul Lateef Attar --- .../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/SpcrD= eviceLib.inf create mode 100755 Platform/AMD/AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrD= eviceLib.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 =20 +[LibraryClasses] + SpcrDeviceLib|AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.inf + [LibraryClasses.common.PEIM] SetCacheMtrrLib|AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrrLib.i= nf =20 +[Components] + AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.inf + [Components.IA32] AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrrLib.inf =20 diff --git a/Platform/AMD/AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLi= b.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) de= vice. +# +# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 1.29 + BASE_NAME =3D SpcrDeviceLib + FILE_GUID =3D 9232A55A-45E3-424A-94C6-615AF63C9A6B + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D BASE + LIBRARY_CLASS =3D SpcrDeviceLib + +[Packages] + MdePkg/MdePkg.dec + +[Sources] + SpcrDeviceLib.c diff --git a/Platform/AMD/AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLi= b.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.
+ +SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include + +STATIC EFI_GUID TerminalTypeGuid[] =3D { + 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) =3D=3D= EFI_SUCCESS) { + do { + // Get the Single Device Path + DevicePath =3D GetNextDevicePathInstance (&VarConsole, &Size); + if (DevicePath =3D=3D NULL) { + return NULL; + } + + TmpDevicePath =3D DevicePath; + Found =3D FALSE; + while (!IsDevicePathEnd (TmpDevicePath)) { + // search for terminal type + Vendor =3D (VENDOR_DEVICE_PATH *)TmpDevicePath; + for (Index =3D 0; Index < (sizeof (TerminalTypeGuid) / sizeof (Ter= minalTypeGuid[0])); Index++) { + if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[Index])) { + Found =3D TRUE; + break; + } + } + + if (Found) { + break; + } + + TmpDevicePath =3D NextDevicePathNode (TmpDevicePath); + } + + if (Found) { + return (DevicePath); + } + + FreePool (DevicePath); + } while (VarConsole !=3D NULL); + } + + return NULL; +} --=20 2.25.1