public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: Michael Brown <mcb30@ipxe.org>
Cc: "Kinney, Michael D" <michael.d.kinney@intel.com>,
	Leif Lindholm <leif.lindholm@linaro.org>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
	"Gao, Liming" <liming.gao@intel.com>
Subject: Re: [PATCH] MdePkg: add big-endian MMIO BaseBeIoLib
Date: Tue, 17 Apr 2018 11:57:43 +0200	[thread overview]
Message-ID: <ff427aa2-eb08-fc4d-c772-e69e56aead46@redhat.com> (raw)
In-Reply-To: <260807ce-5a94-f07e-3121-32fbf70712a8@ipxe.org>

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


  reply	other threads:[~2018-04-17  9:57 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-13 17:42 [PATCH] MdePkg: add big-endian MMIO BaseBeIoLib Leif Lindholm
2018-04-13 19:24 ` Kinney, Michael D
2018-04-13 19:31   ` Leif Lindholm
2018-04-13 23:32     ` Kinney, Michael D
2018-04-16 10:07       ` Leif Lindholm
2018-04-16 14:10         ` Kinney, Michael D
2018-04-16 14:34           ` Michael Brown
2018-04-16 20:42             ` Laszlo Ersek
2018-04-16 22:14               ` Michael Brown
2018-04-17  8:01                 ` Laszlo Ersek
2018-04-17  8:24                   ` Michael Brown
2018-04-17  9:57                     ` Laszlo Ersek [this message]
2018-04-17 13:26               ` Leif Lindholm
2018-04-17 15:20                 ` Kinney, Michael D
2018-04-17  6:57           ` Udit Kumar
2018-04-16 19:32         ` Laszlo Ersek
2018-04-17  8:15           ` Udit Kumar
2018-04-17  9:42             ` Laszlo Ersek
2018-04-17 10:32               ` Udit Kumar
2018-04-17 13:55           ` (spawning off more style discussion) Leif Lindholm
2018-04-18  8:51             ` Laszlo Ersek
2018-04-16  4:39 ` [PATCH] MdePkg: add big-endian MMIO BaseBeIoLib Udit Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ff427aa2-eb08-fc4d-c772-e69e56aead46@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox