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 <[email protected]> > --- > > As promised in the dark and distant past: > https://www.mail-archive.com/[email protected]/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 _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

