public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: Leif Lindholm <leif.lindholm@linaro.org>
Cc: edk2-devel@lists.01.org, ard.biesheuvel@linaro.org,
	Liming Gao <liming.gao@intel.com>,
	Michael D Kinney <michael.d.kinney@intel.com>
Subject: Re: [RFC PATCH] MdePkg: add byte-swapping MMIO BaseIoLibSwap
Date: Wed, 21 Feb 2018 16:56:53 +0100	[thread overview]
Message-ID: <29ec5d11-f1be-6058-8d7f-1f4548be8fe8@redhat.com> (raw)
In-Reply-To: <20180221152525.23449-1-leif.lindholm@linaro.org>

On 02/21/18 16:25, Leif Lindholm wrote:
> When performing MMIO to a destination of the opposite endianness to the
> executing processor, this library provides automatic byte order reversal
> on inputs and outputs.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> ---
> 
> As promised in the dark and distant past:
> https://www.mail-archive.com/edk2-devel@lists.01.org/msg33447.html
> 
> This starts out as a clone of MdePkg/Include/Library/IoLib.h,
> implementing simple wrappers that depend on an IoLib instance to perform
> any actual accesses.
> 
> Comments are mostly nonsense, since they've not been changed from their
> originals in IoLib.h. If people feel this library is a sensible approach,
> I'll fix that up before I send a v1.
> 
> I have explicitly excluded:
> - non-MMIO accesses (could you really end up with mixed endianness in
>   such a system?)
> - bitfields (would either require duplicating code or merging this all
>   into the BaseIoLibIntrinsic module, which is already a bit on the
>   bloated side)
> - buffers operations (let's avoid those until we find we need them)
> 
> MdePkg/Include/Library/IoLibSwap.h             | 395 ++++++++++++++++++++
>  MdePkg/Library/BaseIoLibSwap/BaseIoLibSwap.inf |  44 +++
>  MdePkg/Library/BaseIoLibSwap/BaseIoLibSwap.uni |  23 ++
>  MdePkg/Library/BaseIoLibSwap/IoLibSwap.c       | 491 +++++++++++++++++++++++++
>  MdePkg/MdePkg.dec                              |   3 +
>  MdePkg/MdePkg.dsc                              |   1 +
>  6 files changed, 957 insertions(+)
>  create mode 100644 MdePkg/Include/Library/IoLibSwap.h
>  create mode 100644 MdePkg/Library/BaseIoLibSwap/BaseIoLibSwap.inf
>  create mode 100644 MdePkg/Library/BaseIoLibSwap/BaseIoLibSwap.uni
>  create mode 100644 MdePkg/Library/BaseIoLibSwap/IoLibSwap.c

UEFI drivers are supposed to go through PciIo instances in order to
access config space and MMIO registers of PCI devices (and I assume most
devices are PCI), and the related PciIo member functions are LE-only.
Thus, in such device drivers (for the exceptional(?) PCI device that has
custom BE registers), the byte swapping will have to occur at the call
sites (or at least higher-level wrapper functions).

Which makes me think that this library is primarily for BE platform
devices that are exposed via DXE drivers or (maybe) PEIMs. Is that
corect? If so, can you please state it in the commit message?

Also I would suggest calling the new functions "BE" or "BigEndian" or
something similar -- once we turn this into a lib class, byte swapping
becomes an implementation detail. The API should reflect the goal, which
is "talking to BE platform devices".

The @file comments should be updated similarly, IMO; "non-native
endianness" should simply be "big endian", and the swapping language
should be dropped -- for PI/UEFI, only LE is native (it is hard-coded by
the spec(s), IIRC).

... Another superficial comment: in the INF file, there's a commented
out DebugLib entry under [LibraryClasses]; I guess that's unintended.

To clarify, I'm neutral on this library, I'd just like its documentation
to be clear on when someone should consider using it.

Thanks!
Laszlo


  reply	other threads:[~2018-02-21 15:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-21 15:25 [RFC PATCH] MdePkg: add byte-swapping MMIO BaseIoLibSwap Leif Lindholm
2018-02-21 15:56 ` Laszlo Ersek [this message]
2018-02-21 18:09 ` Ard Biesheuvel
2018-02-22  4:51   ` 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=29ec5d11-f1be-6058-8d7f-1f4548be8fe8@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