Leif, Yes. I think the single swap lib is sufficient for the specific use case.
We can wait until there is a request to add support for a BE CPU to look at a more complete solution to reusing the same module sources for all combinations of CPU and I/O endianness. Thanks, Mike > -----Original Message----- > From: Leif Lindholm [mailto:leif.lindh...@linaro.org] > Sent: Tuesday, April 17, 2018 6:27 AM > To: Kinney, Michael D <michael.d.kin...@intel.com>; > Gao, Liming <liming....@intel.com>; Laszlo Ersek > <ler...@redhat.com> > Cc: email@example.com > Subject: Re: [edk2] [PATCH] MdePkg: add big-endian MMIO > BaseBeIoLib > > On Mon, Apr 16, 2018 at 10:42:26PM +0200, Laszlo Ersek > wrote: > > On 04/16/18 16:34, Michael Brown wrote: > > > On 16/04/18 15:10, Kinney, Michael D wrote: > > >> I agree that the opposite use case is a BE CPU > > >> needing a LE operation. > > >> > > >> I think we only need a single lib class and lib > > >> Instance that does the byte swap and we should > > >> not use Le or Be in any of the names of the class, > > >> instance, or APIs. Just "Swap". > > > > > > I may have misunderstood, but wouldn't using "Swap" > within the API names > > > effectively encode knowledge of the endianness of > the _build_ platform > > > into the source code? This would prevent the same > source code being > > > built for both little-endian and big-endian CPUs. > > > > Under this scenario, all drivers meant to be portable > to both byte > > orders would have to: > > - link against both IoLib and IoSwapLib, > > - determine at device binding time, from CPU > endianness and device > > endianness combined, whether swapping was needed > for that device, > > - call the IoLib or IoSwapLib APIs through wrapper > functions, or > > function pointers. > > Yes. I'm thinking that is a good enough solution for > this type of > situation and I overcomplicated things. Apologies for > that. > > We are talking about the relatively unusual situation > where an > otherwise driver-compatible device can in some > platforms be of a > different endianness than in others. > > So, Mike, Liming - would you be OK with a solution > similar to > https://www.mail-archive.com/edk2- > de...@lists.01.org/msg36520.html. > > / > Leif _______________________________________________ edk2-devel mailing list firstname.lastname@example.org https://lists.01.org/mailman/listinfo/edk2-devel