From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id 4266F94145E for ; Tue, 14 May 2024 08:16:21 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=sqPf9nPDCf/maK3+s0GsKfeSPoK7mVmNAYOGCxSSCK8=; c=relaxed/simple; d=groups.io; h=Received-SPF:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Received-SPF:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20240206; t=1715674579; v=1; b=j8d+ZySQ0BfmqjhuJao1UlbVKswGzvL/LUUTHutk/yiXWD0DMrzSRXPrK1mW25QgZ+MVLIan 721X5RyHhlh3m3n0UT00POksDzIXY3rSH8klz4D+fhbbkfH+xlvEb4KNpPQlQ8uEEtiFCH9YclW oC8uVQw1PpxRmvlnSX8XVyiEWNMANhIAULDpV25FZiAzvJVBNNZsWBprRfAgxlLXKarynhjCd9U N3XQ+gUELcOaMehlUcDB2xUUVhbTeMCivLx/svrM4+eYAvogvlJirs1l65utqdwXdj6Q3St71bB wMlEJE/IgelT7pndOCns98r62fXbmAsbY8zrIoVdoPaYQ== X-Received: by 127.0.0.2 with SMTP id z3McYY7687511xPy4Z2JLBQR; Tue, 14 May 2024 01:16:19 -0700 X-Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.63]) by mx.groups.io with SMTP id smtpd.web11.10152.1715674578106000450 for ; Tue, 14 May 2024 01:16:18 -0700 X-Received: from DM6PR11CA0032.namprd11.prod.outlook.com (2603:10b6:5:190::45) by MN0PR12MB6149.namprd12.prod.outlook.com (2603:10b6:208:3c7::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55; Tue, 14 May 2024 08:16:13 +0000 X-Received: from DS1PEPF0001708E.namprd03.prod.outlook.com (2603:10b6:5:190:cafe::2a) by DM6PR11CA0032.outlook.office365.com (2603:10b6:5:190::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55 via Frontend Transport; Tue, 14 May 2024 08:16:13 +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 X-Received: from SATLEXMB03.amd.com (165.204.84.17) by DS1PEPF0001708E.mail.protection.outlook.com (10.167.17.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7587.21 via Frontend Transport; Tue, 14 May 2024 08:16:13 +0000 X-Received: from SATLEXMB04.amd.com (10.181.40.145) 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.2507.35; Tue, 14 May 2024 03:16:11 -0500 X-Received: from BLR-LAB-SFW01.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Tue, 14 May 2024 03:16:10 -0500 From: "Abdul Lateef Attar via groups.io" To: CC: Abdul Lateef Attar , Abner Chang , Paul Grimes Subject: [edk2-devel] [PATCH 3/6] AmdPlatformPkg: Implements SerialPortLib for simulator Date: Tue, 14 May 2024 13:45:45 +0530 Message-ID: <2338cae1522b5141f145a738a4f11b6ea0469967.1715674395.git.AbdulLateef.Attar@amd.com> In-Reply-To: References: MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: AbdulLateef.Attar@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001708E:EE_|MN0PR12MB6149:EE_ X-MS-Office365-Filtering-Correlation-Id: 87e4b6b2-5133-4008-5062-08dc73ee1ead X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?VP0PmQCD1ssDg/0Fy2qBCbbpKKM5aetZoaN9KYKZljCGLwxP2VNwQgikWxqd?= =?us-ascii?Q?P/3VQPD/ikuwYwaoft7XUOchA9XNt0IN0F5xnHUt511N1rfVa4P3DQ+gPOHR?= =?us-ascii?Q?cN4ZcEPnv5mdIZNHtdeqDgbMrg6Aa71W+1UPO0bWawUgQRX6TfF8Ax3MN+CW?= =?us-ascii?Q?yh5At2A9tZYTWnmCYAPDDk9P4slpCAOHPvMxw9sNfbss4QmG8EWBOYZlkpHT?= =?us-ascii?Q?ejCPkbmk+A0KEOzuDpHNcQKm1UF7sH+cG4Gg1JsEM7wGtjr+7hGh+C/9mPBn?= =?us-ascii?Q?XI2b+N2eDugQ+B8QKsSCaDJR1E2Ghu8+Jgp3RgdtsmV1nRRinRsWSaIbVGI9?= =?us-ascii?Q?AFx2KKDXs2N28HQbiveorm7gMbFGJA1dc6tUvREt1wVSSlSwdmbUGC69tX9M?= =?us-ascii?Q?AzKv8IBKMj1tZRD5kB7ASTUdLjlRbAfCLAiMPd2lwwUA+wBQLHpEGrVBEtBh?= =?us-ascii?Q?Cn+u2izIuIJeYJdkoJBjqEx99FgQIKwaxAKBpZu30LBHxwD208sOmD9BF7Oy?= =?us-ascii?Q?GG2o0b7CYq+yTCBmojinqkfXJJ210IWPO2//lWrhgqM7BAhn56YLnLne/fA3?= =?us-ascii?Q?uAbYpdDpzId5A195LbKnyb2EGXMTc4Xh2qrUok0OFlo47IBlGrcEv6suVkp8?= =?us-ascii?Q?keppEcWyTPW9AtINZ5dXA/P8T6TwTh+TuRF/B3z9LnBVHh43sdnzlaX9hZ5v?= =?us-ascii?Q?RtNv8VcVJAOYg2ithy34ZCXY7HEgOsBnsXXF5wt0Lxf+wjJ4tnia/AzQEa2K?= =?us-ascii?Q?MdqMOna2WJbVVghUXaoJWJix8rmlX0+2H+Bc/Ue+mT7JKMZIoYu2ZQtb2Odt?= =?us-ascii?Q?D/P75OSBOqnQX0WQPiTIVZKqGezrHrjV4XZ7/b2ei1vJJ6qM/paLjWeYu6hI?= =?us-ascii?Q?gHQx7ZU2GCYRWPHtBL+bSngfOvMMzRL+RPl0lJCsXTVk7blKn3sHLyLODhKq?= =?us-ascii?Q?GCXerW3UTd5z3ZFw7U/ZizfHVYbFn2w9IwiJs4G8vPc6XXJtbYBI7A9hfOFD?= =?us-ascii?Q?yFcFuZi6CTUV9NRbq6/ZEwGvDf4Q2Yoi1i9dNO9i0OF5AfDAB3SydKNH3s2C?= =?us-ascii?Q?DxuKyOzw8Gwm69nOy+lDBILMgFPCqMhKw+9xC4/z38sg5Lw8wmzzookb4x9B?= =?us-ascii?Q?86Yxyszlsq8I3ODnfZGGZSe2ULnV6a27zSd9XpWLh7l4dSgJt0LkD9+6vDgV?= =?us-ascii?Q?qj/WkG/eFpO/w+9T1BVhfN5AV+Pjj+j7RGdUyJN5xdxK48yTsaioFG47hbDX?= =?us-ascii?Q?QIJHa08cKMLK748JUzYvYGQZop8lRifYP4p48n/OOCAtTp5BVnMrnVYXVkXT?= =?us-ascii?Q?YcnBmLEF/eMIk/rSkDOoFvA/wra+jW+KwatLLGxUNVnc1ZXHfeqIZ453teiF?= =?us-ascii?Q?6xCKizJjZoGz1Ob72MrCloNOgL9m?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 May 2024 08:16:13.0572 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 87e4b6b2-5133-4008-5062-08dc73ee1ead 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: DS1PEPF0001708E.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6149 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Tue, 14 May 2024 01:16:18 -0700 Resent-From: AbdulLateef.Attar@amd.com Reply-To: devel@edk2.groups.io,AbdulLateef.Attar@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: k7Ph2q3CDuK7M2ztFaQnlrQVx7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=j8d+ZySQ; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io Implements SerialPortLib library class for simulator. It redirects the output to the port 80. Cc: Abner Chang Cc: Paul Grimes Signed-off-by: Abdul Lateef Attar --- .../AMD/AmdPlatformPkg/AmdPlatformPkg.dsc | 3 +- .../SimulatorSerialPortLibPort80.c | 208 ++++++++++++++++++ .../SimulatorSerialPortLibPort80.inf | 31 +++ 3 files changed, 241 insertions(+), 1 deletion(-) create mode 100644 Platform/AMD/AmdPlatformPkg/Library/SimulatorSerialPort= LibPort80/SimulatorSerialPortLibPort80.c create mode 100644 Platform/AMD/AmdPlatformPkg/Library/SimulatorSerialPort= LibPort80/SimulatorSerialPortLibPort80.inf diff --git a/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dsc b/Platform/AMD/= AmdPlatformPkg/AmdPlatformPkg.dsc index e39ad93c83..2c959fb614 100644 --- a/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dsc +++ b/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dsc @@ -48,6 +48,7 @@ =20 [Components] AmdPlatformPkg/Library/BaseAlwaysFalseDepexLib/BaseAlwaysFalseDepexLib.i= nf + AmdPlatformPkg/Library/SimulatorSerialPortLibPort80/SimulatorSerialPortL= ibPort80.inf AmdPlatformPkg/Universal/LogoDxe/JpegLogoDxe.inf = # Server platform JPEG logo driver AmdPlatformPkg/Universal/LogoDxe/LogoDxe.inf = # Server platfrom Bitmap logo driver - AmdPlatformPkg/Universal/LogoDxe/S3LogoDxe.inf + AmdPlatformPkg/Universal/LogoDxe/S3LogoDxe.inf \ No newline at end of file diff --git a/Platform/AMD/AmdPlatformPkg/Library/SimulatorSerialPortLibPort= 80/SimulatorSerialPortLibPort80.c b/Platform/AMD/AmdPlatformPkg/Library/Sim= ulatorSerialPortLibPort80/SimulatorSerialPortLibPort80.c new file mode 100644 index 0000000000..35842ecddc --- /dev/null +++ b/Platform/AMD/AmdPlatformPkg/Library/SimulatorSerialPortLibPort80/Simu= latorSerialPortLibPort80.c @@ -0,0 +1,208 @@ +/** @file + AMD simulator port80 serial port library functions. + + Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserv= ed. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include + +/** + Initialize the serial device hardware. + + If no initialization is required, then return RETURN_SUCCESS. + If the serial device was successfully initialized, then return RETURN_SU= CCESS. + If the serial device could not be initialized, then return RETURN_DEVICE= _ERROR. + + @retval RETURN_SUCCESS The serial device was initialized. + @retval RETURN_DEVICE_ERROR The serial device could not be initialized= . + +**/ +RETURN_STATUS +EFIAPI +SerialPortInitialize ( + VOID + ) +{ + // Chipset defaults properly decoding port 80 to eSPI + return EFI_SUCCESS; +} + +/** + Write data from buffer to serial device. + + Writes NumberOfBytes data bytes from Buffer to the serial device. + The number of bytes actually written to the serial device is returned. + If the return value is less than NumberOfBytes, then the write operation= failed. + If Buffer is NULL, then ASSERT(). + If NumberOfBytes is zero, then return 0. + + @param[in] Buffer The pointer to the data buffer to be writte= n. + @param[in] NumberOfBytes The number of bytes to written to the seria= l device. + + @retval 0 NumberOfBytes is 0. + @retval >0 The number of bytes written to the serial devic= e. + If this value is less than NumberOfBytes, then = the read operation failed. + +**/ +UINTN +EFIAPI +SerialPortWrite ( + IN UINT8 *Buffer, + IN UINTN NumberOfBytes + ) +{ + UINTN ByteCount; + + if ((Buffer =3D=3D NULL) || (NumberOfBytes =3D=3D 0)) { + return 0; + } + + IoWrite32 (0x80, SIGNATURE_32 ('R', 'T', 'S', '_')); + + ByteCount =3D NumberOfBytes; + for ( ; ByteCount !=3D 0; ByteCount--, Buffer++) { + IoWrite8 (0x80, *Buffer); + } + + IoWrite32 (0x80, SIGNATURE_32 ('D', 'N', 'E', '_')); + + return NumberOfBytes; +} + +/** + Read data from serial device and save the data in buffer. + + Reads NumberOfBytes data bytes from a serial device into the buffer + specified by Buffer. The number of bytes actually read is returned. + If the return value is less than NumberOfBytes, then the rest operation = failed. + If Buffer is NULL, then ASSERT(). + If NumberOfBytes is zero, then return 0. + + @param[out] Buffer The pointer to the data buffer to store th= e data read from the serial device. + @param[in] NumberOfBytes The number of bytes which will be read. + + @retval 0 Read data failed; No data is to be read. + @retval >0 The actual number of bytes read from serial dev= ice. + +**/ +UINTN +EFIAPI +SerialPortRead ( + OUT UINT8 *Buffer, + IN UINTN NumberOfBytes + ) +{ + return 0; +} + +/** + Polls a serial device to see if there is any data waiting to be read. + + Polls a serial device to see if there is any data waiting to be read. + If there is data waiting to be read from the serial device, then TRUE is= returned. + If there is no data waiting to be read from the serial device, then FALS= E is returned. + + @retval TRUE Data is waiting to be read from the serial devi= ce. + @retval FALSE There is no data waiting to be read from the se= rial device. + +**/ +BOOLEAN +EFIAPI +SerialPortPoll ( + VOID + ) +{ + return FALSE; +} + +/** + Sets the control bits on a serial device. + + @param[in] Control Sets the bits of Control that are sett= able. + + @retval RETURN_SUCCESS The new control bits were set on the seria= l device. + @retval RETURN_UNSUPPORTED The serial device does not support this op= eration. + @retval RETURN_DEVICE_ERROR The serial device is not functioning corre= ctly. + +**/ +RETURN_STATUS +EFIAPI +SerialPortSetControl ( + IN UINT32 Control + ) +{ + return RETURN_UNSUPPORTED; +} + +/** + Retrieve the status of the control bits on a serial device. + + @param[out] Control A pointer to return the current contr= ol signals from the serial device. + + @retval RETURN_SUCCESS The control bits were read from the serial= device. + @retval RETURN_UNSUPPORTED The serial device does not support this op= eration. + @retval RETURN_DEVICE_ERROR The serial device is not functioning corre= ctly. + +**/ +RETURN_STATUS +EFIAPI +SerialPortGetControl ( + OUT UINT32 *Control + ) +{ + return RETURN_UNSUPPORTED; +} + +/** + Sets the baud rate, receive FIFO depth, transmit/receive time out, parit= y, + data bits, and stop bits on a serial device. + + @param[in,out] BaudRate The requested baud rate. A BaudRate val= ue of 0 will use the + device's default interface speed. + On output, the value actually set. + @param[in,out] ReceiveFifoDepth The requested depth of the FIFO on the = receive side of the + serial interface. A ReceiveFifoDepth va= lue of 0 will use + the device's default FIFO depth. + On output, the value actually set. + @param[in,out] Timeout The requested time out for a single cha= racter in microseconds. + This timeout applies to both the transm= it and receive side of the + interface. A Timeout value of 0 will us= e the device's default time + out value. + On output, the value actually set. + @param[in,out] Parity The type of parity to use on this seria= l device. A Parity value of + DefaultParity will use the device's def= ault parity value. + On output, the value actually set. + @param[in,out] DataBits The number of data bits to use on the s= erial device. A DataBits + value of 0 will use the device's defaul= t data bit setting. + On output, the value actually set. + @param[in,out] StopBits The number of stop bits to use on this = serial device. A StopBits + value of DefaultStopBits will use the d= evice's default number of + stop bits. + On output, the value actually set. + + @retval RETURN_SUCCESS The new attributes were set on the ser= ial device. + @retval RETURN_UNSUPPORTED The serial device does not support thi= s operation. + @retval RETURN_INVALID_PARAMETER One or more of the attributes has an u= nsupported value. + @retval RETURN_DEVICE_ERROR The serial device is not functioning c= orrectly. + +**/ +RETURN_STATUS +EFIAPI +SerialPortSetAttributes ( + IN OUT UINT64 *BaudRate, + IN OUT UINT32 *ReceiveFifoDepth, + IN OUT UINT32 *Timeout, + IN OUT EFI_PARITY_TYPE *Parity, + IN OUT UINT8 *DataBits, + IN OUT EFI_STOP_BITS_TYPE *StopBits + ) +{ + return RETURN_UNSUPPORTED; +} diff --git a/Platform/AMD/AmdPlatformPkg/Library/SimulatorSerialPortLibPort= 80/SimulatorSerialPortLibPort80.inf b/Platform/AMD/AmdPlatformPkg/Library/S= imulatorSerialPortLibPort80/SimulatorSerialPortLibPort80.inf new file mode 100644 index 0000000000..61e2d77f46 --- /dev/null +++ b/Platform/AMD/AmdPlatformPkg/Library/SimulatorSerialPortLibPort80/Simu= latorSerialPortLibPort80.inf @@ -0,0 +1,31 @@ +## @file +# Simlator port80 instance of serial port library functions. +# +# Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reser= ved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D SimulatorSerialPortLibPort80 + FILE_GUID =3D 35217E20-489E-64F9-4E42-1EAFABE0A86F + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D SerialPortLib + +# +# VALID_ARCHITECTURES =3D IA32 X64 +# + +[Sources] + SimulatorSerialPortLibPort80.c + +[Packages] + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + BaseLib + IoLib --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#118885): https://edk2.groups.io/g/devel/message/118885 Mute This Topic: https://groups.io/mt/106090923/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-