From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web10.434.1680840605983987792 for ; Thu, 06 Apr 2023 21:10:06 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=SH6piSJ1; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: andrei.warkentin@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680840606; x=1712376606; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=74bcTBPBxRjbf1tPgziBuIhlntSaXr+yPwUiIYDjSV0=; b=SH6piSJ1nm2B3KtoH1fpk4Tbi/YybDupObHpKxn+pb8kFQaLwQIl1cEu zU4tZBKyIqSYxMLIr1Hdqvt38FBRZm3/tyygQDGlhqNxrB9fJL2VwImHG XP7Dm/tQHB9lugf1gsFWAFilLq46RuwEc7eIV9x7C8AAdFiVkeIFcPnI3 0gEGNtAj6n935gdVw7GZeKXlq70+ma6xA3kkRpLSck8P39uEpOSa0yiFM rmGnBgNV6+BCsn+qQvJOvk24Aflfz85hmGqK9+stS6o/Gm/TfKDDjwM35 LeNJj8PcmGVus20HyoVt6bd5ayPaL1zrsPrkuUBYegxarMO+AkcuuDdZp w==; X-IronPort-AV: E=McAfee;i="6600,9927,10672"; a="344693634" X-IronPort-AV: E=Sophos;i="5.98,324,1673942400"; d="scan'208";a="344693634" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2023 21:09:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10672"; a="689933157" X-IronPort-AV: E=Sophos;i="5.98,324,1673942400"; d="scan'208";a="689933157" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga007.fm.intel.com with ESMTP; 06 Apr 2023 21:09:49 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 6 Apr 2023 21:09:49 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21 via Frontend Transport; Thu, 6 Apr 2023 21:09:49 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.168) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.21; Thu, 6 Apr 2023 21:09:48 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WVs7njWmu5CkuEM5BTpxvJWT/jy2YLWHHFgCyMrG852FLRyvnorAIzkM17pqbYgbudQDYagYxfvRu3zSgxasWsH16sn+JUiG//koqNAYtUEAvvGjA/9dZlr+GPvx69n8j33Kz3XSYwUngeKzzCqa7pf5OvqhdfNDqr4RYTPjbWm8zHc4gf3/eBZ1RXexkhVpCDMbOz8Ggd/FN8mVNs2BVJbcUsO+aHJ+yalbjOKpMJWll6kRfvDXzWPhyEV+v/DGE6Ttsyjch3bPcfC0VI+JsqzjG0G7+7ZcKXh9a+sQTpbxLsPxC2aSk5/yp7zMLXDGFkX7mrjKfDJ5i8TCUWYq5A== 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=JzDwpq4NeaSG/OezxDRdq1XOEtURcsPKGQUl97bpJTQ=; b=BP9E+Q0oJ9rZfu2wgNMCuXYBHU2fmZHf2hR5sf9ojHM9MXiQeyKH3dXwn9M8JFIlwMj7Y6oYnTQRVLlVMvzPJscuLGV5Dd2Fq6R1Fy2rQ3vLYHBSE3ZSzGD9id0bR5Xz6CdcOPbCRW1PZbb0PQn7ZF3Y/ooJuW075RcUWRxvtGDno9lQAx7nI7+0Wt4OjKoyx//1TGzjjh1NdlUgBSvYvrxtu91Z065VX6TYuYeUbbSTen/rMISfKr9uEmHz5D191LkIrDAcSIDEDf51BdVhEERXGYn+TNwkfwhkENpe0mlYAPyjKEB7KaVc/KDQb488dtMNir9N/1tODVd8JNbwAQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from PH8PR11MB6856.namprd11.prod.outlook.com (2603:10b6:510:22b::7) by PH8PR11MB6901.namprd11.prod.outlook.com (2603:10b6:510:22a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.33; Fri, 7 Apr 2023 04:09:45 +0000 Received: from PH8PR11MB6856.namprd11.prod.outlook.com ([fe80::f794:46bc:90a:c3a3]) by PH8PR11MB6856.namprd11.prod.outlook.com ([fe80::f794:46bc:90a:c3a3%5]) with mapi id 15.20.6277.031; Fri, 7 Apr 2023 04:09:45 +0000 From: "Andrei Warkentin" To: Sunil V L CC: "devel@edk2.groups.io" , Daniel Schaefer , "Kinney, Michael D" , "Gao, Liming" , "Liu, Zhiguang" , Gerd Hoffmann Subject: Re: [PATCH v6 2/3] MdePkg: add SBI-based SerialPortLib for RISC-V Thread-Topic: [PATCH v6 2/3] MdePkg: add SBI-based SerialPortLib for RISC-V Thread-Index: AQHZZxSxfdhHQm80UkaHlN0XV9w7Mq8duzeAgAGEFPA= Date: Fri, 7 Apr 2023 04:09:45 +0000 Message-ID: References: <20230404164359.25852-1-andrei.warkentin@intel.com> <20230404164359.25852-3-andrei.warkentin@intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PH8PR11MB6856:EE_|PH8PR11MB6901:EE_ x-ms-office365-filtering-correlation-id: edf19c8b-1ae9-404b-93ff-08db371dec14 x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: VULV8FdjFq5l/UzzVP0FW2e/5tZnZS/Nc7Y926o/uQ2MrmWGH1WAZ/Rlwu8TiFF+UknIGUVD86zgxUWp1o5W7gSrMU0kIZxOpGMNJuAsm9e9Qy9330zj5KNeM6lXXicq83KW0pSBq6YhUwXnVw5I7mFJ2UiRKGB6I87Rp9MBYbv+/rkRYIv1AjBGTFH+nZqooGFNLAiwG4Sb13CTDNzPh19yZLlfATStzgA81UriFDT80kuhuMPzh1al6zL9qqJuDmxX1k3W4uMoPer31nvrMBN3tpoNv3WKpbNlXzUtppILzjAqQ0otjTTCT+OvwJYLD1EPnqbu8wLAf2d1TPG9UT9if3L0/5cF6saGU+Q4UB16qHtr3656MknQz3JRCgn/xfjRiHpfW/zkfiB5bOHQg5ZrSqIiMqEenrbMnfaVsNbqVxkEY5CaAcy/GUQmurjSscEGKUIXeVYfQifz15VrhBADW0Q7UCe2DarpjGPGA4+lmmcOWCqgQClkcq8AQyt+PGIMW4mTHajXhiKwK+bzxhTTYwU52Syo6fgubSK2hoVUmGcq2wDMjURozOV4VWrluTVIljsW96UO10LfR3waWwSrjZbWBEy0EfJ7fWRBOZ0QfhC+heJVu/Qo9NqEmLRO x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH8PR11MB6856.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(39860400002)(396003)(136003)(376002)(366004)(451199021)(83380400001)(55016003)(6916009)(26005)(66476007)(54906003)(66946007)(66446008)(76116006)(82960400001)(66556008)(4326008)(478600001)(41300700001)(64756008)(8936002)(316002)(52536014)(5660300002)(122000001)(38100700002)(186003)(9686003)(53546011)(71200400001)(7696005)(6506007)(8676002)(33656002)(86362001)(2906002)(38070700005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?CHNJLkwVqvOKGuVE04E/p48WwW3gu1AXR4h1uwywOQnjranZcr7v3UvwDAq9?= =?us-ascii?Q?ymkn5OJo4AVaWBjMRVsc3K4gRhMVqwAAF4ndU6KEEHYqoRtAwUs8qb6YC/3A?= =?us-ascii?Q?evSOjuqhez4vvdoX+08xey7sLkZ7wHumAASA9Aj9xJ8LnGzmuwdb9K+R3dYe?= =?us-ascii?Q?6ARuZj3s8uoJB35dJYMqHjYuO89SSQCxMe8fcWHRP46nsueJZHTFeHwId+ah?= =?us-ascii?Q?g/bpymZnqUIde/pM8RXKWW7A1ddRIw2Hb1WEyoTpB5Lk3ZwofNm6MP3jrjdt?= =?us-ascii?Q?d2cd7orNeUER/b7wfQNIFYAvfC+Sm6QVMcLgOigVuYJNwBOrgoptf/wVykuZ?= =?us-ascii?Q?32cKBzt278sqOkYWkvzRtsEKorm7/WUe2qBtA0D0jWmnlWa5ZsDpWNuz/JgE?= =?us-ascii?Q?w4E+zp3a8w+3qKQdID0FWiYi4Y+5p65WK33KeUKtB/8JQJaPfsGvwnwMorTi?= =?us-ascii?Q?/cyXryEv3XbSx8iQRpBxkfu+Bfye7VjkTBer5XjIYZ+k9TTv2/SxsDRa0+hc?= =?us-ascii?Q?LT+URylBj4j26B9uG3HL9g5CLzp+r0cp3DrK5uG+otUnAX1tnwxEMhOqIwK7?= =?us-ascii?Q?8t2n2mcE5yRgz4pKJEXJ+vMNAHkVXI01fIR63neb76hrutIdnoDMupf8WSYW?= =?us-ascii?Q?upAY8DPHYgZMDsKskHutbGZdaMqO1GnXapAm5NID2ivNrnatiMXxqlI7JW54?= =?us-ascii?Q?8H9xNEDoEERRtWhybl4+fKvruDG3okuxOXAXUoioFCfY74rlUUXCWZjJBIOj?= =?us-ascii?Q?KvRkl9/DsXYjLDQ++CNHWo89Xme9pWHP0EoS03QrXM53UQ4cWR/7PvFDXuIG?= =?us-ascii?Q?SQcucT6E+Af0p/wzva4azAYuGNJLE8q9F0pLM4W6BX+sNuh0wAv90hru9MQG?= =?us-ascii?Q?wUdmDQTvP2wnW6nd3s2Xjvfp1SEF9RgH7UdSUgkbFHIBq+WbxJ7PxX7+trHo?= =?us-ascii?Q?7E/+5XKTwQsMfOHrXYPthzl8poM+VsJcXKRnXjjGDhq1zZmYtNY6tEb38dAH?= =?us-ascii?Q?Czsv7vpLLtJ94Za3bhG8fuGpJKi6wayAqsFXxjDE+IcBfElnMR3PnyoTV5Nf?= =?us-ascii?Q?zwgmgU5cJk+DvTEj0Nbn3XImPq+2FPWHLwA8ajXB0SxBAtHCozchXJbsN8HW?= =?us-ascii?Q?e5de8GFbraNmg1SvVeyE9/T4jbT4KbI8UE9Z7MI4YY/Z4SZbnHB0M/jvVMQG?= =?us-ascii?Q?Ek2APHMRJr9N46e5Wf9yCKu9EjeHyiZFcmiB8DGujPqxaf5sMv8/F1soJF03?= =?us-ascii?Q?ZNA1G10+w3yQWX95t0JOhGuaZHWJd3ZE0qhjIZ/qKV0z93OyJIsBXysmp3de?= =?us-ascii?Q?+ErdUaoytvH5MWJw32ZCoWrqZ/riW91+1QnadfzaGSqUbxqN3UaA6BldSIXj?= =?us-ascii?Q?iEHCFJn/ZPBy48sfMe5uXGKHbWEkBeEjOBoyz2lb7GEcxNtdhIJY4xvy3dca?= =?us-ascii?Q?btiCO/bA7ye4stvpLx1dvQblOSfCE/lXH8ZyAwRTQv4s5UHvOZcKEeylpKG8?= =?us-ascii?Q?oJUsVG3LNg0QzFTLYSJYkceTCfSkkOlVjjAiEWBMQCIwDuXFZqUiRQld5MUi?= =?us-ascii?Q?zYUocT7Lulwp2q/zgC1R3yFcCCwRKnG+g81KwO6W?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH8PR11MB6856.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: edf19c8b-1ae9-404b-93ff-08db371dec14 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Apr 2023 04:09:45.6813 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: lvDrvLyHm6XwsadF0anBKRHpzMnwOaeFPlkPS00itr52LI0KqWytGmsJeRFjrwAwEwqIrRcE2uc1VO0/2X/06vWCmICdDS3bUa6bpy3lqbA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR11MB6901 Return-Path: andrei.warkentin@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thanks Sunil, I have in fact missed your email. Will apply your feedback, retest and resend. A > -----Original Message----- > From: Sunil V L > Sent: Thursday, April 6, 2023 12:00 AM > To: Warkentin, Andrei > Cc: devel@edk2.groups.io; Daniel Schaefer ; > Kinney, Michael D ; Gao, Liming > ; Liu, Zhiguang ; Gerd > Hoffmann > Subject: Re: [PATCH v6 2/3] MdePkg: add SBI-based SerialPortLib for RISC-= V >=20 > Hi Andrei, >=20 > I had couple of questions on previous version of this patch. Adding them > inline again in case you had missed them. Please check if they are valid. >=20 > Also, I think it would be better to have single directory > BaseSerialPortLibRiscVSbiLib and inside that we can have both INF files. > This way we can share UNI files etc between both libraries. >=20 > On Tue, Apr 04, 2023 at 11:43:58AM -0500, Andrei Warkentin wrote: > > These are implementations of SerialPortLib using SBI console services. > > - BaseSerialPortLibRiscVSbiLib is appropriate for SEC/PEI (XIP) > > environments > > - BaseSerialPortLibRiscVSbiLibRam is appropriate for PrePI/DXE > > environments > > > > Tested with: > > - Qemu RiscVVirt (non-DBCN case, backed by UART) > > - TinyEMU + RiscVVirt (non-DBCN case, HTIF) > > - TinyEMU + RiscVVirt (DBCN case, HTIF) > > > > Cc: Daniel Schaefer > > Cc: Sunil V L > > Cc: Michael D Kinney > > Cc: Liming Gao > > Cc: Zhiguang Liu > > Acked-by: Gerd Hoffmann > > Signed-off-by: Andrei Warkentin > > --- > > MdePkg/MdePkg.dsc = | 2 + > > > MdePkg/Library/BaseSerialPortLibRiscVSbiLib/BaseSerialPortLibRiscVSbiLib.= in > f | 39 +++ > > > MdePkg/Library/BaseSerialPortLibRiscVSbiLibRam/BaseSerialPortLibRiscVSbiL > ibRam.inf | 36 +++ > > > MdePkg/Library/BaseSerialPortLibRiscVSbiLib/BaseSerialPortLibRiscVSbiLib.= c > | 233 ++++++++++++++++ > > > MdePkg/Library/BaseSerialPortLibRiscVSbiLibRam/BaseSerialPortLibRiscVSbiL > ibRam.c | 288 ++++++++++++++++++++ > > > MdePkg/Library/BaseSerialPortLibRiscVSbiLib/BaseSerialPortLibRiscVSbiLib.= u > ni | 16 ++ > > > > MdePkg/Library/BaseSerialPortLibRiscVSbiLibRam/BaseSerialPortLibRiscVS > > biLibRam.uni | 16 ++ > > 7 files changed, 630 insertions(+) > > > > diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc index > > 0ac7618b4623..ceccc078ff04 100644 > > --- a/MdePkg/MdePkg.dsc > > +++ b/MdePkg/MdePkg.dsc > > @@ -192,5 +192,7 @@ [Components.ARM, Components.AARCH64] > > > > [Components.RISCV64] > > MdePkg/Library/BaseRiscVSbiLib/BaseRiscVSbiLib.inf > > + > > + MdePkg/Library/BaseSerialPortLibRiscVSbiLib/BaseSerialPortLibRiscVSb > > + iLib.inf > > + MdePkg/Library/BaseSerialPortLibRiscVSbiLibRam/BaseSerialPortLibRisc > > + VSbiLibRam.inf > > > > [BuildOptions] > > diff --git > > a/MdePkg/Library/BaseSerialPortLibRiscVSbiLib/BaseSerialPortLibRiscVSb > > iLib.inf > > b/MdePkg/Library/BaseSerialPortLibRiscVSbiLib/BaseSerialPortLibRiscVSb > > iLib.inf > > new file mode 100644 > > index 000000000000..09cf59f190f6 > > --- /dev/null > > +++ b/MdePkg/Library/BaseSerialPortLibRiscVSbiLib/BaseSerialPortLibRis > > +++ cVSbiLib.inf > > @@ -0,0 +1,39 @@ > > +## @file > > +# Serial Port Library backed by SBI console. > > +# > > +# Meant for SEC and PEI (XIP) environments. > > +# > > +# Due to limitations of SBI console interface and XIP environments # > > +(on use of globals), this library instance does not implement reading > > +# and polling the serial port. See PrePiDxeSerialPortLibRiscVSbi for > > +# the full-featured variant meant for PrePi and DXE environments. > > +# > > +# Copyright (c) 2023, Intel Corporation. All rights reserved.
# > > +# SPDX-License-Identifier: BSD-2-Clause-Patent # # ## > > + > > +[Defines] > > + INF_VERSION =3D 0x0001001B > > + BASE_NAME =3D BaseSerialPortLibRiscVSbiLib > > + MODULE_UNI_FILE =3D BaseSerialPortLibRiscVSbiLib.uni > > + FILE_GUID =3D 639fad38-4bfd-4eb9-9f09-e97c7947d= 480 > > + MODULE_TYPE =3D BASE > > + VERSION_STRING =3D 1.0 > > + LIBRARY_CLASS =3D SerialPortLib | SEC PEI_CORE PEIM > > + > > + > > +# > > +# VALID_ARCHITECTURES =3D RISCV64 > > +# > > + > > +[Sources] > > + BaseSerialPortLibRiscVSbiLib.c > > + > > +[Packages] > > + MdePkg/MdePkg.dec > > + > > +[LibraryClasses] > > + RiscVSbiLib > > diff --git > > a/MdePkg/Library/BaseSerialPortLibRiscVSbiLibRam/BaseSerialPortLibRisc > > VSbiLibRam.inf > > b/MdePkg/Library/BaseSerialPortLibRiscVSbiLibRam/BaseSerialPortLibRisc > > VSbiLibRam.inf > > new file mode 100644 > > index 000000000000..b7ad1548a309 > > --- /dev/null > > +++ b/MdePkg/Library/BaseSerialPortLibRiscVSbiLibRam/BaseSerialPortLib > > +++ RiscVSbiLibRam.inf > > @@ -0,0 +1,36 @@ > > +## @file > > +# Serial Port Library backed by SBI console. > > +# > > +# Meant for PrePi and DXE environments (where globals are allowed). > > +See # BaseSerialPortLibRiscVSbiLib for a reduced variant appropriate > > +for SEC # and PEI (XIP) environments. > > +# > > +# Copyright (c) 2023, Intel Corporation. All rights reserved.
# > > +# SPDX-License-Identifier: BSD-2-Clause-Patent # # ## > > + > > +[Defines] > > + INF_VERSION =3D 0x0001001B > > + BASE_NAME =3D BaseSerialPortLibRiscVSbiLibRam > > + MODULE_UNI_FILE =3D BaseSerialPortLibRiscVSbiLibRam.u= ni > > + FILE_GUID =3D 872af743-ab56-45b4-a065-602567f48= 20c > > + MODULE_TYPE =3D BASE > > + VERSION_STRING =3D 1.0 > > + LIBRARY_CLASS =3D SerialPortLib | SEC DXE_CORE DXE_= DRIVER > DXE_RUNTIME_DRIVER UEFI_DRIVER UEFI_APPLICATION > > + > > + > > +# > > +# VALID_ARCHITECTURES =3D RISCV64 > > +# > > + > > +[Sources] > > + BaseSerialPortLibRiscVSbiLibRam.c > > + > > +[Packages] > > + MdePkg/MdePkg.dec > > + > > +[LibraryClasses] > > + RiscVSbiLib > > diff --git > > a/MdePkg/Library/BaseSerialPortLibRiscVSbiLib/BaseSerialPortLibRiscVSb > > iLib.c > > b/MdePkg/Library/BaseSerialPortLibRiscVSbiLib/BaseSerialPortLibRiscVSb > > iLib.c > > new file mode 100644 > > index 000000000000..0ad5931be3ae > > --- /dev/null > > +++ b/MdePkg/Library/BaseSerialPortLibRiscVSbiLib/BaseSerialPortLibRis > > +++ cVSbiLib.c > > @@ -0,0 +1,233 @@ > > +/** @file > > + Serial Port Library backed by SBI console. > > + > > + Meant for SEC and PEI (XIP) environments. > > + > > + Due to limitations of SBI console interface and XIP environments > > + (on use of globals), this library instance does not implement > > + reading and polling the serial port. See > > + PrePiDxeSerialPortLibRiscVSbi for the full-featured variant meant fo= r > PrePi and DXE environments. > > + > > + Copyright (c) 2023, Intel Corporation. All rights reserved.
> > + SPDX-License-Identifier: BSD-2-Clause-Patent > > + > > +**/ > > + > > +#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_SUCCESS. > > + 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 > > + ) > > +{ > > + return RETURN_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 returne= d. > > + If the return value is less than NumberOfBytes, then the write opera= tion > failed. > > + If Buffer is NULL, then ASSERT(). > > + If NumberOfBytes is zero, then return 0. > > + > > + @param Buffer The pointer to the data buffer to be writte= n. > > + @param 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 d= evice. > > + If this value is less than NumberOfBytes, t= hen the write > operation failed. > > + > > +**/ > > +UINTN > > +EFIAPI > > +SerialPortWrite ( > > + IN UINT8 *Buffer, > > + IN UINTN NumberOfBytes > > + ) > > +{ > > + SBI_RET Ret; > > + UINTN Index; > > + > > + Ret =3D SbiCall (SBI_EXT_BASE, SBI_EXT_BASE_PROBE_EXT, 1, > > + SBI_EXT_DBCN); if ((TranslateError (Ret.Error) =3D=3D EFI_SUCCESS) &= & > > + (Ret.Value !=3D 0)) > > + { > > + Ret =3D SbiCall ( > > + SBI_EXT_DBCN, > > + SBI_EXT_DBCN_WRITE, > > + 3, > > + NumberOfBytes, > > + ((UINTN)Buffer), > > + 0 > > + ); > > + if (TranslateError (Ret.Error) !=3D EFI_SUCCESS) { > > + return 0; > > + } > > + > > + return Ret.Value; > > + } > > + > > + Ret =3D SbiCall (SBI_EXT_BASE, SBI_EXT_BASE_PROBE_EXT, 1, > > + SBI_EXT_0_1_CONSOLE_PUTCHAR); if ((TranslateError (Ret.Error) =3D=3D > EFI_SUCCESS) && > > + (Ret.Value !=3D 0)) > > + { > > + for (Index =3D 0; Index < NumberOfBytes; Index++) { > > + SbiCall (SBI_EXT_0_1_CONSOLE_PUTCHAR, 0, 1, Buffer[Index]); > What happens if it fails? Shouldn't it return immediately instead of > continuing with the loop? >=20 > > + } > > + > > + return Index; > > + } > > + > > + /* > > + * Neither DBCN or legacy extension were present. > > + */ > > + return NumberOfBytes; > Isn't it an error? And for earlier DBCN_WRITE error, 0 is returned. So, > shouldn't we return 0 here also instead of NumberOfBytes? >=20 > Same questions for similar place in other library also.