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 087DE740034 for ; Wed, 15 May 2024 03:52:04 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=rbRITYO1JsdUUnvkfgwniFMb05bGkOzArw7xKtXn+no=; c=relaxed/simple; d=groups.io; h=Received-SPF:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version: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=1715745123; v=1; b=hM5SdAeL43hKtWCsBzREjAWL0MK8yXSo9bF5/yuuIcuxNBsULGX4vbT37wgMebHijyqvVm1f vcPapXJuPp9zmWKDzIZDMqw/foXbp5YPKUkEEviBJ/es581eEs3XkaWJFITjiyocNWTgv444Cvw erv2OMU9iB8V8guGL8OV8tHosy1pJEZGPRe03Rtm2/VmAGi8hohb1LzKljZ9Mf36Z3w+qX4+p6v 2fn6cDzUzg29otEOPvkMzmUfDHMe/Z/A6fVzm2W0nECMmbWhfP6ZOAEUNdXci26nFSh7Z0vN7K8 gLZFw3GNSPRa+ctisLrvHgOpjDLJkfIHYTabaJ0XnQKqw== X-Received: by 127.0.0.2 with SMTP id zF2VYY7687511xtRBiRyz5Rv; Tue, 14 May 2024 20:52:03 -0700 X-Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.47]) by mx.groups.io with SMTP id smtpd.web10.6395.1715745122654905149 for ; Tue, 14 May 2024 20:52:02 -0700 X-Received: from BN9PR03CA0533.namprd03.prod.outlook.com (2603:10b6:408:131::28) by SJ2PR12MB8062.namprd12.prod.outlook.com (2603:10b6:a03:4c8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55; Wed, 15 May 2024 03:52:00 +0000 X-Received: from BN2PEPF00004FC0.namprd04.prod.outlook.com (2603:10b6:408:131:cafe::16) by BN9PR03CA0533.outlook.office365.com (2603:10b6:408:131::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55 via Frontend Transport; Wed, 15 May 2024 03:51:59 +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=SATLEXMB04.amd.com; pr=C X-Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF00004FC0.mail.protection.outlook.com (10.167.243.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7587.21 via Frontend Transport; Wed, 15 May 2024 03:51:59 +0000 X-Received: from SATLEXMB06.amd.com (10.181.40.147) 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; Tue, 14 May 2024 22:51:56 -0500 X-Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) 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 22:51:56 -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 22:51:54 -0500 From: "Abdul Lateef Attar via groups.io" To: CC: Abdul Lateef Attar , Abner Chang , Paul Grimes Subject: [edk2-devel] [RESEND 3/7] AmdPlatformPkg: Implements SerialPortLib for simulator Date: Wed, 15 May 2024 09:20:21 +0530 Message-ID: <2338cae1522b5141f145a738a4f11b6ea0469967.1715744867.git.AbdulLateef.Attar@amd.com> In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF00004FC0:EE_|SJ2PR12MB8062:EE_ X-MS-Office365-Filtering-Correlation-Id: 332b8b3c-69d0-4c69-ffe1-08dc74925f63 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?35UX7lDI/R4NI88pljk3gmQUSyRoOVCFQsYj6IPaJ60YDc/EIzDf/DnoA4vm?= =?us-ascii?Q?CGoZKNAIvWyd+R8PszdLBEo5rLlepzY5ERL9UxOJYdbKBTe9jxPks+S5CPuh?= =?us-ascii?Q?/s8+l6b5pbjXuGcIwMhaRX2zxR7VcClgMEayjaHILe93hEt4s7tL9lb5axyo?= =?us-ascii?Q?PLeqvyGU9zpd8/61zQomY8Wa0TwW3jUSp/JX397hpGcsuVTcE03X8yxDpbiV?= =?us-ascii?Q?LcPttY2g1dzb74WNJbWufUNmAB1HEeEVIT5pbR9DalimdgIpOYMRaceUmhdI?= =?us-ascii?Q?3OG7wjc4vODE9hr5e2CHMMzvqyJ6FasJtixt1FKMLKUatqkMzj3EMTpxop6d?= =?us-ascii?Q?OaugnYwc1r9HfwtRAvPn2xSoDCZlXVgpuzHYzilMNwo3hVy0Ew+1kXOxxzoA?= =?us-ascii?Q?miazkhGPK1mZDFZn56auXJuj8j1YPgx07P6Hk7dLGLcn8ZP8JarTryKlmq2M?= =?us-ascii?Q?fPm3JOGQe7tUBb1kbyKEV+w7e9zFUyjklLFQAUwnkWBMvbyTLRno3UO0vRWI?= =?us-ascii?Q?MgNAtGAr0jkgKwlT643zFj8fkqxSV+x1qCAbaJ/bFMOoKnjwldh03bVut21A?= =?us-ascii?Q?HgBNC/19gjUcjd8xZQwYEqnP5SCD+w/83Zx1k6SAry4POg9zDMhUkpaV/TX5?= =?us-ascii?Q?EFLRmrphzMpFgvVNn7opTEbbE4CRAoYvHrBllzPEV2vklLcarZerlocmfu4H?= =?us-ascii?Q?fnEIvc3baEQ+1t4JLTt1GuQLr8TT9+jGU5Z7hguv3tHlJIC3XunnTsx4ZkBD?= =?us-ascii?Q?YMG6m6sMJpcE1icHa65N04zr+voEOSD8imuuMUt5kk5JW8BLxqtGc5eTzo3z?= =?us-ascii?Q?n3FV2ha2A1llE5CGBNJGywDroB0waC2RrNIWEj7jGYaJDHrl01oUuLkVwTn4?= =?us-ascii?Q?MNnM3mHmJHzmfiJztLNlam5PBSkmAL2ZCqQuN+Mz8oz3ZwiM+4VONZVH/UUq?= =?us-ascii?Q?txNaj8H9vtKfOjeZun9qDKhS4pbg0ZOsUioGrr07Y8wFG+BpWdqHHYrZSAqB?= =?us-ascii?Q?zBHQjheT+T3NpG/yL2QLDWxbxJi7K0UxcqTosupwODksbt1gDakUW8aiGa1X?= =?us-ascii?Q?cPV84dLrw7W3+9/4VdEW0EUN+b9hEGb5Hc04wCnnDMYBQBupHSK+hywbBI46?= =?us-ascii?Q?jY6hov3DlK7KPc/bwfRUhGHF4KGoNg49noc9od7p5n6zrMnyhwDg9Zq38qGh?= =?us-ascii?Q?uSAG8Mqo+EqXXrnRO6PeAgpMOYuPk0HBb4vEfGzvDBUBuLgmhi+Ode39nI7J?= =?us-ascii?Q?HFRFESOLXWbz3wXC1iR45T5U3gNQRgx938gvga60oWt1PGDs2UuivTzbNG+2?= =?us-ascii?Q?Gq4hYC6/T3SCXM4gnc93E7qg+0IF2a1MPhB6Gozi3NsWiyv1jRnvBSrW7BJl?= =?us-ascii?Q?NX5Jbg+kE8N7hy9ZO0cckgEy8uhT?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2024 03:51:59.3735 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 332b8b3c-69d0-4c69-ffe1-08dc74925f63 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF00004FC0.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8062 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 20:52:02 -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: 9tK2nHFbqt27nFZWdFz8QJgPx7686176AA= 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=hM5SdAeL; 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 (#118902): https://edk2.groups.io/g/devel/message/118902 Mute This Topic: https://groups.io/mt/106108331/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-