From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=66.187.233.73; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C836521F2E185 for ; Tue, 17 Apr 2018 02:57:45 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 18C8D7CBBA; Tue, 17 Apr 2018 09:57:45 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-161.rdu2.redhat.com [10.10.120.161]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A3F5111DCEB; Tue, 17 Apr 2018 09:57:43 +0000 (UTC) To: Michael Brown Cc: "Kinney, Michael D" , Leif Lindholm , "edk2-devel@lists.01.org" , "Gao, Liming" References: <20180413174211.858-1-leif.lindholm@linaro.org> <20180413193143.t45tua3yi7sopk4d@bivouac.eciton.net> <20180416100712.6v642ycksvmoffvt@bivouac.eciton.net> <52ea5684-380d-0519-2545-6ef7f62198ae@ipxe.org> <09cc135a-c3b7-bcbd-1a71-6454e3ba7623@redhat.com> <52f131ae-ed51-9276-ac91-e3dded7472e2@ipxe.org> <56ad661e-3f48-3889-0641-ae64e8da178a@redhat.com> <260807ce-5a94-f07e-3121-32fbf70712a8@ipxe.org> From: Laszlo Ersek Message-ID: Date: Tue, 17 Apr 2018 11:57:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <260807ce-5a94-f07e-3121-32fbf70712a8@ipxe.org> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 17 Apr 2018 09:57:45 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 17 Apr 2018 09:57:45 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lersek@redhat.com' RCPT:'' Subject: Re: [PATCH] MdePkg: add big-endian MMIO BaseBeIoLib X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Apr 2018 09:57:46 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit On 04/17/18 10:24, Michael Brown wrote: > On 17/04/18 09:01, Laszlo Ersek wrote: >> The thing is, the BeIoLib and LeIoLib classes are already good for this >> -- they can be implemented as you suggest. So no need to call the >> function SwapIfNeededForBigEndianDeviceMmioRead16(), just call it >> BeMmioRead16(). > > I know.  I thought that suggesting a 40-character function name Yes, I noticed that (and commented on it). > and a > runtime check in case the CPU endianness changed mid-execution would be > sufficiently obviously ridiculous, Linking BaseBeIoLib (and BaseLeIoLib) against both IoLib and IoSwapLib, and then deciding with an "if" in the code which one to call, would not expect the CPU to change endianness mid-execution. The controlling expression of the "if" would be evaluable at compile time, and then link-time optimization at the latest could fully eliminate one of IoLib / IoSwapLib. This was discussed last time the topic was alive: http://mid.mail-archive.com/2a1fa56f-98db-a1c1-d973-7e84cc7dc1fa@redhat.com // // at file scope // STATIC CONST UINT16 mOne = 1; // // at function scope // if (*(CONST UINT8 *)&mOne == 1) { Keeping the "if" in genuine C source code provides better source code coverage (for compiling anyway) than conditional compilation via macros (this is a practice the SeaBIOS project follows as well). > but I fear that it may have sounded > too plausible for EDK2. Please don't troll? I've spent some time on this because I was asked for my opinion. You may find the edk2 coding practices ridiculous (and we're totally not blind to their shortcomings either), and/or my thoughts on the matter painfully naive, but trolling just wastes our time. I guess I'm out of this thread. Laszlo