From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web11.17634.1677660641637173654 for ; Wed, 01 Mar 2023 00:50:41 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=TBxqLwEG; spf=pass (domain: intel.com, ip: 134.134.136.126, 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=1677660641; x=1709196641; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version; bh=exvuSo+xW7lzfqiOg3CKyg6fMBp/fvx1BGmjvlZZa4o=; b=TBxqLwEGcxQRxLljqm9PALVBV/Mdqskwaux9dKZuCG2/LAroibboJnQ/ XuALiqnSRLRzAVkKHYwaB2SmlRLcXmdrqYiu/i3lQW/JI7FPoEAEUfrHp N1xIpOZi0gfP7tI+/I8QVDXllcq2PCc2264A5LLohKGsRvG2SuaOjHzCU Ps2Liml+FXAO+JtXfua5R85b6sFqA2mCHD8gM8r4cqarikhDTzuyZaMXJ aIfa4NqblfFkuKigNXsZl3J6UvkUwgC9UJyvZacNIYH16B/tEjWbzdodA MY6z0+UB9omTWsCyP+Sx0WzLsLQWU8X32ZvUDgJXiSH9Sgf/9OSXIaNli A==; X-IronPort-AV: E=McAfee;i="6500,9779,10635"; a="318157490" X-IronPort-AV: E=Sophos;i="5.98,224,1673942400"; d="scan'208,217";a="318157490" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2023 00:50:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10635"; a="676682795" X-IronPort-AV: E=Sophos;i="5.98,224,1673942400"; d="scan'208,217";a="676682795" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga007.fm.intel.com with ESMTP; 01 Mar 2023 00:50:40 -0800 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Wed, 1 Mar 2023 00:50:40 -0800 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) 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 via Frontend Transport; Wed, 1 Mar 2023 00:50:40 -0800 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.103) 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.16; Wed, 1 Mar 2023 00:50:39 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XuQCgSMNLCGMEsyUnjm+FoznPgP0YWv+LWS9XeS/kpj0RhEx8N/U3eJvG8y4Ki1+YDVgzikW+to838nDDdWodCnO2LXM6C8Uw6vRDQgf4soxwywjol2YR0pkuQ6sgGwi8d6CgHhjUFK+SAlWxMEDFxxy3zB0XkQVTNcc1RwfkR2TT5nEgBG7k8xxXO1Vbjfnha939IKX0fzIs9LijhF4jdk4pDokreLKXa5vXWuv/wM85li6s667XV/h7HX9eh3KgM0LK78bj5YgjG2+i8fm8M+XuCyjlduAXfu++pGKvhGT9Xim9BUWALww4vtZPssvzrIf0kLvUA9qW6JKvMxULg== 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=Uk5xKaQeaBwFI2jwYE2wDlp5ZMejtMXUjF6poCbVtzo=; b=jDIAnUq+PyrfWoB1SfKSxo9Md/6Xxym2HjG+ZPEuvHRNL5eiDIEn0PYqfX85JQ67yemwZ2soboGsu5OFtFouAvts/RlpkOF4gbC8r7LQWm7GZptNZUp+h+wrhcRxLxy+DWZeW7faXFQvwRhXQnLsLYYiU1lUfQxrh6OaZoV+GwItza8clxFeXAXU+JoSdGT/+DYFV0v22GGI0ZC0SfhmKuknxxoKY0OGgK5oRKRQm1BjD4GgUDbZAMBd47Znp2l6eWIoY1o4B9LJhyfyPLBD/zMs1r5IqzevO46CFjWHoBo8e0dz3Xh0B5OQ5eWIzyI/Evcs+geAHR072sMyMx5Ktg== 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 PH0PR11MB5878.namprd11.prod.outlook.com (2603:10b6:510:14c::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.17; Wed, 1 Mar 2023 08:50:38 +0000 Received: from PH8PR11MB6856.namprd11.prod.outlook.com ([fe80::f480:22ed:c915:13f1]) by PH8PR11MB6856.namprd11.prod.outlook.com ([fe80::f480:22ed:c915:13f1%6]) with mapi id 15.20.6134.028; Wed, 1 Mar 2023 08:50:38 +0000 From: "Andrei Warkentin" To: Gerd Hoffmann , "devel@edk2.groups.io" CC: Daniel Schaefer , Sunil V L Subject: Re: [edk2-devel] [edk2 2/2] MdePkg: add BaseSerialPortLibRiscVSbi Thread-Topic: [edk2-devel] [edk2 2/2] MdePkg: add BaseSerialPortLibRiscVSbi Thread-Index: AQHZTBGktsGAlJgxMk25oICBgpdT/K7lk0kAgAAJLs0= Date: Wed, 1 Mar 2023 08:50:38 +0000 Message-ID: References: <20230301074358.26356-1-andrei.warkentin@intel.com> <20230301074358.26356-3-andrei.warkentin@intel.com> <20230301081332.lzb5v7enjfillnfb@sirius.home.kraxel.org> In-Reply-To: <20230301081332.lzb5v7enjfillnfb@sirius.home.kraxel.org> 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_|PH0PR11MB5878:EE_ x-ms-office365-filtering-correlation-id: de3852ac-a7fa-42fe-0a3c-08db1a3207b9 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: rqifu+gCZkdG3xdU2Bbu/RZjaiGeLAx46Z+PK0RCohnERm1heeiixNf5KJPcSwtsoHwvM8AMyzUyd+hWcVvANMWzXGTBUmA+XnpPcYGdQA5aE5V+TmUnlvPci90w9SsmmGPQAkP3yxsMOltxYYIGNhkFTzdgCZRtx81oesIJHCrW4i5CHZ9gTYoCQcg62jinUIv99qaHf4JzQW80HwzH+mTz1AyriteL4B11ngf6l8Ow6sqZWLJrFqiNTAdA48JoWNg0KPGd0uC5U5PG24/6VINSWCgJIh/AHVncDhRLRz6IyLMB4IHSOM23Z/htznGNNENj6AVdckNc/xDcUZ4pfR3CxGFh6XEJdMThTSSBWp9Q1rRfd0igncbciAtgJ9p/kGQIObmErfqcO0KQ2+o1CfM6cQbAI/cLJSGM5ykW3nbufvgDMz7vqCYLE2QxMEqlFqcfVKXn9rGz08bytHXgwYuabfn0K2qUuOrUg3EPbKoK7Z7e9YLeoTbBSIkp7+X5zQpV3PYgDk+zjqXRF58bm4nQ/6NWfxeR93lgn0Nd3PxvyAAbLslFqWsdETWnsqrabCuboLkqVf9E0Eiie2J3MDc8yjmBda0+0Yg799Xjn8W08wUv5uVml744wNG+zP59L11NhkmxLttK9gez82zqSTIfKFaU3E84nQ7x+p8Pc740mTz+HwqkDljDMGmAvs2gn3sK7/K0VoyoAqaxOY5bW7hXRLBBVh9n4RN/s5Nppd5OTVI8deYsV95MkwNVoFI6 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:(13230025)(39860400002)(366004)(396003)(136003)(346002)(376002)(451199018)(5660300002)(478600001)(9686003)(186003)(83380400001)(33656002)(6506007)(38070700005)(86362001)(55016003)(7696005)(71200400001)(2906002)(41300700001)(91956017)(316002)(38100700002)(122000001)(82960400001)(4326008)(8676002)(66476007)(66556008)(66446008)(8936002)(66946007)(110136005)(64756008)(52536014)(54906003)(76116006)(145603002)(213903007);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?koi8-r?Q?3BSkREpJoyHS1K8i1N+V+b43/TGarZmORT738LWrUYEip/Ii2eicnW/WvIANK/?= =?koi8-r?Q?2toUj73bDS+i22fG+L8lSRvXXKpiiMQgAX9bUC6PRIWED3o4dA1ez0DDFU8xgC?= =?koi8-r?Q?B0dHUBvlhKzs8telDuG86IAHWOUo1To5T01kE7kYbF4s0N9Sn0JAnp7qyN1SZb?= =?koi8-r?Q?xVg0URIqAPCXClrDdS1jEVmSYgbModGaiGwFPpjutvDpMxWfThGygn9nti4egC?= =?koi8-r?Q?vMoTm5qmxEpko96Ch4fZhn6G/HusdPUJibWtSXd3Sv8mGnA4SkotTdezinxg9j?= =?koi8-r?Q?/bgTcAxHJ91m6LZOk39n1mIqkKIl8DZG4XnHBujnlIw07xPEEasbtrbLQxh09K?= =?koi8-r?Q?haxuivuVOaq7nzFGqcYcYqAVNEZDitqyPo6a62eDFfQDJA3TNveJqzEhtiEJac?= =?koi8-r?Q?bosPUE0YjiXtUmLc4b8NSPwed/kEwe5ffZ1kno48ZY5X3V7BpFUBDBehvesXPD?= =?koi8-r?Q?yqLBFkOB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DBh9Z16zVt9XeufkVqmUMIbIx6VRijvvgAvNH?= =?koi8-r?Q?8MKpvnQYBun7yMZn/THD/IqJ+d4sDSoRfwoEnheh3SD3vdb5BIYXWcdhLimhU0?= =?koi8-r?Q?IVZWlF1PxgWjuv9UR+QQtn9WlFCwFkqRG6k99h9wIqqxpSsr13ri8dgdC4j8ro?= =?koi8-r?Q?Psd7s80hUqRCi6RPDSyIG5HuuYrbkaejm1dRdQ5kQgB6LLOYa0pBhbe74/kX86?= =?koi8-r?Q?BGHIHdADJ0hbDOoD1E3sYTcdzdOsADXaNckPLs/p0QhWmCq7l6mH?= 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: de3852ac-a7fa-42fe-0a3c-08db1a3207b9 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Mar 2023 08:50:38.2999 (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: qRHIK6sEFIFDywKwPgAhGNOAJNxCwj1iU3OO4TY29DUTf9dCs5szewVY0s+etWjSscMrfRQ8SvZfWqQ0jYMTwSQyAVeFUf+ePtzvCtjf6IE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB5878 Return-Path: andrei.warkentin@intel.com X-OriginatorOrg: intel.com Content-Language: ru-RU Content-Type: multipart/alternative; boundary="_000_PH8PR11MB68563E2FBD725A773B6ABF6583AD9PH8PR11MB6856namp_" --_000_PH8PR11MB68563E2FBD725A773B6ABF6583AD9PH8PR11MB6856namp_ Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: quoted-printable The library caller could call Poll() first, then call Read(), and the expec= tation is the char won't be lost. SBI doesn't have a poll call itself, so b= est you could do is read and stash. So you have to stash it globally. And r= ead must use the stashed char, if it exists, before requesting more data fr= om SBI. At that point, reading is easy to treat as continued polling - just= to keep the code simple. A ________________________________ =EF=D4: Gerd Hoffmann =EF=D4=D0=D2=C1=D7=CC=C5=CE=CF: Wednesday, March 1, 2023 2:13:32 AM =EB=CF=CD=D5: devel@edk2.groups.io ; Warkentin, Andre= i =EB=CF=D0=C9=D1: Daniel Schaefer ; Sunil V L =F4=C5=CD=C1: Re: [edk2-devel] [edk2 2/2] MdePkg: add BaseSerialPortLibRisc= VSbi Hi, > + while ((Index < NumberOfBytes) && SerialPortPoll ()) { > + Buffer[Index++] =3D (UINT8)mLastGetChar; > + mLastGetChar =3D -1; > + } Why do you use a global variable to pass the character? SerialPortPoll could just return it directly ... take care, Gerd --_000_PH8PR11MB68563E2FBD725A773B6ABF6583AD9PH8PR11MB6856namp_ Content-Type: text/html; charset="koi8-r" Content-Transfer-Encoding: quoted-printable
The library caller could call Poll() first, then call Read= (), and the expectation is the char won't be lost. SBI doesn't have a poll = call itself, so best you could do is read and stash. So you have to stash i= t globally. And read must use the stashed char, if it exists, before requesting more data from SBI. At that = point, reading is easy to treat as continued polling - just to keep the cod= e simple.

A

=EF=D4: Gerd Hoffmann <k= raxel@redhat.com>
=EF=D4=D0=D2=C1=D7=CC=C5=CE=CF: Wednesday, March 1, 2023 2:13:32 AM<= br> =EB=CF=CD=D5: devel@edk2.groups.io <devel@edk2.groups.io>; War= kentin, Andrei <andrei.warkentin@intel.com>
=EB=CF=D0=C9=D1: Daniel Schaefer <git@danielschaefer.me>; Suni= l V L <sunilvl@ventanamicro.com>
=F4=C5=CD=C1: Re: [edk2-devel] [edk2 2/2] MdePkg: add BaseSerialPort= LibRiscVSbi
 
  Hi,

> +  while ((Index < NumberOfBytes) && SerialPortPoll ()= ) {
> +    Buffer[Index++] =3D (UINT8)mLastGetChar;
> +    mLastGetChar    =3D -1;
> +  }

Why do you use a global variable to pass the character?  SerialPortPol= l
could just return it directly ...

take care,
  Gerd

--_000_PH8PR11MB68563E2FBD725A773B6ABF6583AD9PH8PR11MB6856namp_--