[edk2] [PATCH edk2-platforms 01/41] Silicon/NXP: Add Library to return Mmio APIs pointer

Meenakshi Aggarwal meenakshi.aggarwal at nxp.com
Tue Dec 25 21:00:32 PST 2018


Thank you Ard and Leif for all the comments, we  will work on your review comments and share the next version soon.

> -----Original Message-----
> From: Leif Lindholm <leif.lindholm at linaro.org>
> Sent: Saturday, December 22, 2018 12:48 AM
> To: Meenakshi Aggarwal <meenakshi.aggarwal at nxp.com>
> Cc: ard.biesheuvel at linaro.org; michael.d.kinney at intel.com; edk2-
> devel at lists.01.org; Udit Kumar <udit.kumar at nxp.com>; Varun Sethi
> <V.Sethi at nxp.com>
> Subject: Re: [PATCH edk2-platforms 01/41] Silicon/NXP: Add Library to return
> Mmio APIs pointer
> 
> On Wed, Nov 28, 2018 at 08:31:15PM +0530, Meenakshi Aggarwal wrote:
> > This library add supports to return pointer to MMIO APIs on basis of
> > Swap flag.
> > If Flag is True then MMION APIs returened in which data swapped after
> > reading from MMIO and before write using MMIO.
> 
> I conspicuously left this one for last.
> 
> First thing I would like to see is splitting the setting up of function pointers bit
> from the actual I/O accesses (separate patches).
> 
> The I/O functions belong in edk2 MdeModulePkg (or possibly EmbeddedPkg, of
> for some reason they don't want it in MdePkg).
> But regardless, please send that as a separate patch, preceding the edk2-
> platforms set.
> 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal at nxp.com>
> > ---
> >  Silicon/NXP/Include/Library/IoAccessLib.h       | 332 +++++++++++++++++++
> >  Silicon/NXP/Library/IoAccessLib/IoAccessLib.c   | 410
> ++++++++++++++++++++++++
> >  Silicon/NXP/Library/IoAccessLib/IoAccessLib.inf |  32 ++
> >  3 files changed, 774 insertions(+)
> >  create mode 100644 Silicon/NXP/Include/Library/IoAccessLib.h
> >  create mode 100644 Silicon/NXP/Library/IoAccessLib/IoAccessLib.c
> >  create mode 100644 Silicon/NXP/Library/IoAccessLib/IoAccessLib.inf
> >
> > diff --git a/Silicon/NXP/Include/Library/IoAccessLib.h
> > b/Silicon/NXP/Include/Library/IoAccessLib.h
> > new file mode 100644
> > index 0000000..f7372a5
> > --- /dev/null
> > +++ b/Silicon/NXP/Include/Library/IoAccessLib.h
> > @@ -0,0 +1,332 @@
> > +/** @file
> > + *
> > + *  Copyright 2017 NXP
> > + *
> > + *  This program and the accompanying materials
> > + *  are licensed and made available under the terms and conditions of
> > +the BSD License
> > + *  which accompanies this distribution.  The full text of the
> > +license may be found at
> > + *
> > +https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fope
> > +nsource.org%2Flicenses%2Fbsd-
> license.php&data=02%7C01%7Cmeenakshi
> >
> +.aggarwal%40nxp.com%7C7d85cd38d02e4e6bbdc208d6677905c6%7C686ea1d
> 3bc2b
> >
> +4c6fa92cd99c5c301635%7C0%7C0%7C636810166817008412&sdata=OU
> EJ2URy5
> > +LX7wpvNs9f%2BK01Q1nahX2nWPNO67yOT57M%3D&reserved=0
> > + *
> > + *  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> > +BASIS,
> > + *  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> > + *
> > + **/
> > +
> > +#ifndef __IO_ACCESS_LIB_H__
> > +#define __IO_ACCESS_LIB_H__
> > +
> > +#include <Base.h>
> > +
> > +///
> > +///  Structure to have pointer to R/W ///  Mmio operations for 16
> > +bits.
> > +///
> > +typedef struct _MMIO_OPERATIONS_16 {
> > +  UINT16 (*Read) (UINTN Address);
> > +  UINT16 (*Write) (UINTN Address, UINT16 Value);
> > +  UINT16 (*Or) (UINTN Address, UINT16 Or);
> > +  UINT16 (*And) (UINTN Address, UINT16 AND);
> > +  UINT16 (*AndThenOr) (UINTN Address, UINT16 And, UINT16 Or); }
> > +MMIO_OPERATIONS_16;
> 
> I have sort of hinted at this in earlier comments on this set:
> 
> Why separate structs for different access sizes?
> I don't expect there will be a noticeable image size or performance difference if
> they are all put into one structure. And if there is. we can conditionalise the
> inclusion of different widths with FixedPcds.
> 
> So I would like for just a single GetMmioOperations() function that returns a
> single struct. And I would like for the member functions to have the access size
> as the suffix to their names, just like the regular IoLib functions.
> 
> > +
> > +///
> > +///  Structure to have pointer to R/W ///  Mmio operations for 32
> > +bits.
> > +///
> > +typedef struct _MMIO_OPERATIONS_32 {
> > +  UINT32 (*Read) (UINTN Address);
> > +  UINT32 (*Write) (UINTN Address, UINT32 Value);
> > +  UINT32 (*Or) (UINTN Address, UINT32 Or);
> > +  UINT32 (*And) (UINTN Address, UINT32 AND);
> > +  UINT32 (*AndThenOr) (UINTN Address, UINT32 And, UINT32 Or); }
> > +MMIO_OPERATIONS_32;
> > +
> > +///
> > +///  Structure to have pointer to R/W ///  Mmio operations for 64
> > +bits.
> > +///
> > +typedef struct _MMIO_OPERATIONS_64 {
> > +  UINT64 (*Read) (UINTN Address);
> > +  UINT64 (*Write) (UINTN Address, UINT64 Value);
> > +  UINT64 (*Or) (UINTN Address, UINT64 Or);
> > +  UINT64 (*And) (UINTN Address, UINT64 AND);
> > +  UINT64 (*AndThenOr) (UINTN Address, UINT64 And, UINT64 Or); }
> > +MMIO_OPERATIONS_64;
> > +
> > +/**
> > +  Function to return pointer to 16 bit Mmio operations.
> > +
> > +  @param  Swap  Flag to tell if Swap is needed or not
> > +                on Mmio Operations.
> > +
> > +  @return       Pointer to Mmio Operations.
> > +
> > +**/
> > +MMIO_OPERATIONS_16 *
> > +GetMmioOperations16  (
> > +  IN  BOOLEAN  Swap
> > +  );
> > +
> > +/**
> > +  Function to return pointer to 32 bit Mmio operations.
> > +
> > +  @param  Swap  Flag to tell if Swap is needed or not
> > +                on Mmio Operations.
> > +
> > +  @return       Pointer to Mmio Operations.
> > +
> > +**/
> > +MMIO_OPERATIONS_32 *
> > +GetMmioOperations32  (
> > +  IN  BOOLEAN  Swap
> > +  );
> > +
> > +/**
> > +  Function to return pointer to 64 bit Mmio operations.
> > +
> > +  @param  Swap  Flag to tell if Swap is needed or not
> > +                on Mmio Operations.
> > +
> > +  @return       Pointer to Mmio Operations.
> > +
> > +**/
> > +MMIO_OPERATIONS_64 *
> > +GetMmioOperations64  (
> > +  IN  BOOLEAN  Swap
> > +  );
> > +
> > +/**
> > +  MmioRead16 for Big-Endian modules.
> 
> There is nothing inherently Big-Endian about this.
> It is byte-swapping.
> 
> This concludes my review of this set, and I will now disappear on holiday until 7
> January.
> 
> Best Regards,
> 
> Leif
> 
> > +
> > +  @param  Address The MMIO register to read.
> > +
> > +  @return The value read.
> > +
> > +**/
> > +UINT16
> > +EFIAPI
> > +SwapMmioRead16 (
> > +  IN  UINTN     Address
> > +  );
> > +
> > +/**
> > +  MmioRead32 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to read.
> > +
> > +  @return The value read.
> > +
> > +**/
> > +UINT32
> > +EFIAPI
> > +SwapMmioRead32 (
> > +  IN  UINTN     Address
> > +  );
> > +
> > +/**
> > +  MmioRead64 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to read.
> > +
> > +  @return The value read.
> > +
> > +**/
> > +UINT64
> > +EFIAPI
> > +SwapMmioRead64 (
> > +  IN  UINTN     Address
> > +  );
> > +
> > +/**
> > +  MmioWrite16 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  Value   The value to write to the MMIO register.
> > +
> > +**/
> > +UINT16
> > +EFIAPI
> > +SwapMmioWrite16 (
> > +  IN  UINTN     Address,
> > +  IN  UINT16    Value
> > +  );
> > +
> > +/**
> > +  MmioWrite32 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  Value   The value to write to the MMIO register.
> > +
> > +**/
> > +UINT32
> > +EFIAPI
> > +SwapMmioWrite32 (
> > +  IN  UINTN     Address,
> > +  IN  UINT32    Value
> > +  );
> > +
> > +/**
> > +  MmioWrite64 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  Value   The value to write to the MMIO register.
> > +
> > +**/
> > +UINT64
> > +EFIAPI
> > +SwapMmioWrite64 (
> > +  IN  UINTN     Address,
> > +  IN  UINT64    Value
> > +  );
> > +
> > +/**
> > +  MmioAndThenOr16 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  AndData The value to AND with the read value from the MMIO
> register.
> > +  @param  OrData  The value to OR with the result of the AND operation.
> > +
> > +  @return The value written back to the MMIO register.
> > +
> > +**/
> > +UINT16
> > +EFIAPI
> > +SwapMmioAndThenOr16 (
> > +  IN  UINTN     Address,
> > +  IN  UINT16    AndData,
> > +  IN  UINT16    OrData
> > +  );
> > +
> > +/**
> > +  MmioAndThenOr32 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  AndData The value to AND with the read value from the MMIO
> register.
> > +  @param  OrData  The value to OR with the result of the AND operation.
> > +
> > +  @return The value written back to the MMIO register.
> > +
> > +**/
> > +UINT32
> > +EFIAPI
> > +SwapMmioAndThenOr32 (
> > +  IN  UINTN     Address,
> > +  IN  UINT32    AndData,
> > +  IN  UINT32    OrData
> > +  );
> > +
> > +/**
> > +  MmioAndThenOr64 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  AndData The value to AND with the read value from the MMIO
> register.
> > +  @param  OrData  The value to OR with the result of the AND operation.
> > +
> > +  @return The value written back to the MMIO register.
> > +
> > +**/
> > +UINT64
> > +EFIAPI
> > +SwapMmioAndThenOr64 (
> > +  IN  UINTN     Address,
> > +  IN  UINT64    AndData,
> > +  IN  UINT64    OrData
> > +  );
> > +
> > +/**
> > +  MmioOr16 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  OrData  The value to OR with the read value from the MMIO
> register.
> > +
> > +  @return The value written back to the MMIO register.
> > +
> > +**/
> > +UINT16
> > +EFIAPI
> > +SwapMmioOr16 (
> > +  IN  UINTN     Address,
> > +  IN  UINT16    OrData
> > +  );
> > +
> > +/**
> > +  MmioOr32 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  OrData  The value to OR with the read value from the MMIO
> register.
> > +
> > +  @return The value written back to the MMIO register.
> > +
> > +**/
> > +UINT32
> > +EFIAPI
> > +SwapMmioOr32 (
> > +  IN  UINTN     Address,
> > +  IN  UINT32    OrData
> > +  );
> > +
> > +/**
> > +  MmioOr64 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  OrData  The value to OR with the read value from the MMIO
> register.
> > +
> > +  @return The value written back to the MMIO register.
> > +
> > +**/
> > +UINT64
> > +EFIAPI
> > +SwapMmioOr64 (
> > +  IN  UINTN     Address,
> > +  IN  UINT64    OrData
> > +  );
> > +
> > +/**
> > +  MmioAnd16 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  AndData The value to AND with the read value from the MMIO
> register.
> > +
> > +  @return The value written back to the MMIO register.
> > +
> > +**/
> > +UINT16
> > +EFIAPI
> > +SwapMmioAnd16 (
> > +  IN  UINTN     Address,
> > +  IN  UINT16    AndData
> > +  );
> > +
> > +/**
> > +  MmioAnd32 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  AndData The value to AND with the read value from the MMIO
> register.
> > +
> > +  @return The value written back to the MMIO register.
> > +
> > +**/
> > +UINT32
> > +EFIAPI
> > +SwapMmioAnd32 (
> > +  IN  UINTN     Address,
> > +  IN  UINT32    AndData
> > +  );
> > +
> > +/**
> > +  MmioAnd64 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  AndData The value to AND with the read value from the MMIO
> register.
> > +
> > +  @return The value written back to the MMIO register.
> > +
> > +**/
> > +UINT64
> > +EFIAPI
> > +SwapMmioAnd64 (
> > +  IN  UINTN     Address,
> > +  IN  UINT64    AndData
> > +  );
> > +
> > +#endif /* __IO_ACCESS_LIB_H__ */
> > diff --git a/Silicon/NXP/Library/IoAccessLib/IoAccessLib.c
> > b/Silicon/NXP/Library/IoAccessLib/IoAccessLib.c
> > new file mode 100644
> > index 0000000..0260777
> > --- /dev/null
> > +++ b/Silicon/NXP/Library/IoAccessLib/IoAccessLib.c
> > @@ -0,0 +1,410 @@
> > +/** IoAccessLib.c
> > +
> > +  Provide MMIO APIs for BE modules.
> > +
> > +  Copyright 2017 NXP
> > +
> > +  This program and the accompanying materials  are licensed and made
> > + available under the terms and conditions of the BSD License  which
> > + accompanies this distribution.  The full text of the license may be
> > + found at
> > +
> > + https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fop
> > + ensource.org%2Flicenses%2Fbsd-
> license.php&data=02%7C01%7Cmeenaks
> > +
> hi.aggarwal%40nxp.com%7C7d85cd38d02e4e6bbdc208d6677905c6%7C686ea1
> d3b
> > +
> c2b4c6fa92cd99c5c301635%7C0%7C0%7C636810166817008412&sdata=O
> UEJ2
> > + URy5LX7wpvNs9f%2BK01Q1nahX2nWPNO67yOT57M%3D&reserved=0
> > +
> > +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> > + BASIS,  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND,
> EITHER EXPRESS OR IMPLIED.
> > +
> > +**/
> > +
> > +#include <Base.h>
> > +#include <Library/BaseLib.h>
> > +#include <Library/IoAccessLib.h>
> > +#include <Library/IoLib.h>
> > +
> > +/**
> > +  MmioRead16 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to read.
> > +
> > +  @return The value read.
> > +
> > +**/
> > +UINT16
> > +EFIAPI
> > +SwapMmioRead16 (
> > +  IN  UINTN     Address
> > +  )
> > +{
> > +  return SwapBytes16 (MmioRead16 (Address)); }
> > +
> > +/**
> > +  MmioRead32 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to read.
> > +
> > +  @return The value read.
> > +
> > +**/
> > +UINT32
> > +EFIAPI
> > +SwapMmioRead32 (
> > +  IN  UINTN     Address
> > +  )
> > +{
> > +  return SwapBytes32 (MmioRead32 (Address)); }
> > +
> > +/**
> > +  MmioRead64 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to read.
> > +
> > +  @return The value read.
> > +
> > +**/
> > +UINT64
> > +EFIAPI
> > +SwapMmioRead64 (
> > +  IN  UINTN     Address
> > +  )
> > +{
> > +  return SwapBytes64 (MmioRead64 (Address)); }
> > +
> > +/**
> > +  MmioWrite16 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  Value   The value to write to the MMIO register.
> > +
> > +**/
> > +UINT16
> > +EFIAPI
> > +SwapMmioWrite16 (
> > +  IN  UINTN     Address,
> > +  IN  UINT16    Value
> > +  )
> > +{
> > +  return MmioWrite16 (Address, SwapBytes16 (Value)); }
> > +
> > +/**
> > +  MmioWrite32 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  Value   The value to write to the MMIO register.
> > +
> > +**/
> > +UINT32
> > +EFIAPI
> > +SwapMmioWrite32 (
> > +  IN  UINTN     Address,
> > +  IN  UINT32    Value
> > +  )
> > +{
> > +  return MmioWrite32 (Address, SwapBytes32 (Value)); }
> > +
> > +/**
> > +  MmioWrite64 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  Value   The value to write to the MMIO register.
> > +
> > +**/
> > +UINT64
> > +EFIAPI
> > +SwapMmioWrite64 (
> > +  IN  UINTN     Address,
> > +  IN  UINT64    Value
> > +  )
> > +{
> > +  return MmioWrite64 (Address, SwapBytes64 (Value)); }
> > +
> > +/**
> > +  MmioAndThenOr16 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  AndData The value to AND with the read value from the MMIO
> register.
> > +  @param  OrData  The value to OR with the result of the AND operation.
> > +
> > +  @return The value written back to the MMIO register.
> > +
> > +**/
> > +UINT16
> > +EFIAPI
> > +SwapMmioAndThenOr16 (
> > +  IN  UINTN     Address,
> > +  IN  UINT16    AndData,
> > +  IN  UINT16    OrData
> > +  )
> > +{
> > +  AndData = SwapBytes16 (AndData);
> > +  OrData = SwapBytes16 (OrData);
> > +
> > +  return MmioAndThenOr16 (Address, AndData, OrData); }
> > +
> > +/**
> > +  MmioAndThenOr32 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  AndData The value to AND with the read value from the MMIO
> register.
> > +  @param  OrData  The value to OR with the result of the AND operation.
> > +
> > +  @return The value written back to the MMIO register.
> > +
> > +**/
> > +UINT32
> > +EFIAPI
> > +SwapMmioAndThenOr32 (
> > +  IN  UINTN     Address,
> > +  IN  UINT32    AndData,
> > +  IN  UINT32    OrData
> > +  )
> > +{
> > +  AndData = SwapBytes32 (AndData);
> > +  OrData = SwapBytes32 (OrData);
> > +
> > +  return MmioAndThenOr32 (Address, AndData, OrData); }
> > +
> > +/**
> > +  MmioAndThenOr64 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  AndData The value to AND with the read value from the MMIO
> register.
> > +  @param  OrData  The value to OR with the result of the AND operation.
> > +
> > +  @return The value written back to the MMIO register.
> > +
> > +**/
> > +UINT64
> > +EFIAPI
> > +SwapMmioAndThenOr64 (
> > +  IN  UINTN     Address,
> > +  IN  UINT64    AndData,
> > +  IN  UINT64    OrData
> > +  )
> > +{
> > +  AndData = SwapBytes64 (AndData);
> > +  OrData = SwapBytes64 (OrData);
> > +
> > +  return MmioAndThenOr64 (Address, AndData, OrData); }
> > +
> > +/**
> > +  MmioOr16 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  OrData  The value to OR with the read value from the MMIO
> register.
> > +
> > +  @return The value written back to the MMIO register.
> > +
> > +**/
> > +UINT16
> > +EFIAPI
> > +SwapMmioOr16 (
> > +  IN  UINTN     Address,
> > +  IN  UINT16    OrData
> > +  )
> > +{
> > +  return MmioOr16 (Address, SwapBytes16 (OrData)); }
> > +
> > +/**
> > +  MmioOr32 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  OrData  The value to OR with the read value from the MMIO
> register.
> > +
> > +  @return The value written back to the MMIO register.
> > +
> > +**/
> > +UINT32
> > +EFIAPI
> > +SwapMmioOr32 (
> > +  IN  UINTN     Address,
> > +  IN  UINT32    OrData
> > +  )
> > +{
> > +  return MmioOr32 (Address, SwapBytes32 (OrData)); }
> > +
> > +/**
> > +  MmioOr64 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  OrData  The value to OR with the read value from the MMIO
> register.
> > +
> > +  @return The value written back to the MMIO register.
> > +
> > +**/
> > +UINT64
> > +EFIAPI
> > +SwapMmioOr64 (
> > +  IN  UINTN     Address,
> > +  IN  UINT64    OrData
> > +  )
> > +{
> > +  return MmioOr64 (Address, SwapBytes64 (OrData)); }
> > +
> > +/**
> > +  MmioAnd16 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  AndData The value to AND with the read value from the MMIO
> register.
> > +
> > +  @return The value written back to the MMIO register.
> > +
> > +**/
> > +UINT16
> > +EFIAPI
> > +SwapMmioAnd16 (
> > +  IN  UINTN     Address,
> > +  IN  UINT16    AndData
> > +  )
> > +{
> > +  return MmioAnd16 (Address, SwapBytes16 (AndData)); }
> > +
> > +/**
> > +  MmioAnd32 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  AndData The value to AND with the read value from the MMIO
> register.
> > +
> > +  @return The value written back to the MMIO register.
> > +
> > +**/
> > +UINT32
> > +EFIAPI
> > +SwapMmioAnd32 (
> > +  IN  UINTN     Address,
> > +  IN  UINT32    AndData
> > +  )
> > +{
> > +  return MmioAnd32 (Address, SwapBytes32 (AndData)); }
> > +
> > +/**
> > +  MmioAnd64 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  AndData The value to AND with the read value from the MMIO
> register.
> > +
> > +  @return The value written back to the MMIO register.
> > +
> > +**/
> > +UINT64
> > +EFIAPI
> > +SwapMmioAnd64 (
> > +  IN  UINTN     Address,
> > +  IN  UINT64    AndData
> > +  )
> > +{
> > +  return MmioAnd64 (Address, SwapBytes64 (AndData)); }
> > +
> > +STATIC MMIO_OPERATIONS_16 SwappingFunctions16 = {
> > +  SwapMmioRead16,
> > +  SwapMmioWrite16,
> > +  SwapMmioOr16,
> > +  SwapMmioAnd16,
> > +  SwapMmioAndThenOr16,
> > +};
> > +
> > +STATIC MMIO_OPERATIONS_16 NonSwappingFunctions16 = {
> > +  MmioRead16,
> > +  MmioWrite16,
> > +  MmioOr16,
> > +  MmioAnd16,
> > +  MmioAndThenOr16,
> > +};
> > +
> > +STATIC MMIO_OPERATIONS_32 SwappingFunctions32 = {
> > +  SwapMmioRead32,
> > +  SwapMmioWrite32,
> > +  SwapMmioOr32,
> > +  SwapMmioAnd32,
> > +  SwapMmioAndThenOr32,
> > +};
> > +
> > +STATIC MMIO_OPERATIONS_32 NonSwappingFunctions32 = {
> > +  MmioRead32,
> > +  MmioWrite32,
> > +  MmioOr32,
> > +  MmioAnd32,
> > +  MmioAndThenOr32,
> > +};
> > +
> > +STATIC MMIO_OPERATIONS_64 SwappingFunctions64 = {
> > +  SwapMmioRead64,
> > +  SwapMmioWrite64,
> > +  SwapMmioOr64,
> > +  SwapMmioAnd64,
> > +  SwapMmioAndThenOr64,
> > +};
> > +
> > +STATIC MMIO_OPERATIONS_64 NonSwappingFunctions64 = {
> > +  MmioRead64,
> > +  MmioWrite64,
> > +  MmioOr64,
> > +  MmioAnd64,
> > +  MmioAndThenOr64,
> > +};
> > +
> > +/**
> > +  Function to return pointer to 16 bit Mmio operations.
> > +
> > +  @param  Swap  Flag to tell if Swap is needed or not
> > +                on Mmio Operations.
> > +
> > +  @return       Pointer to Mmio Operations.
> > +
> > +**/
> > +MMIO_OPERATIONS_16 *
> > +GetMmioOperations16 (BOOLEAN Swap) {
> > +  if (Swap) {
> > +    return &SwappingFunctions16;
> > +  } else {
> > +    return &NonSwappingFunctions16;
> > +  }
> > +}
> > +
> > +/**
> > +  Function to return pointer to 32 bit Mmio operations.
> > +
> > +  @param  Swap  Flag to tell if Swap is needed or not
> > +                on Mmio Operations.
> > +
> > +  @return       Pointer to Mmio Operations.
> > +
> > +**/
> > +MMIO_OPERATIONS_32 *
> > +GetMmioOperations32 (BOOLEAN Swap) {
> > +  if (Swap) {
> > +    return &SwappingFunctions32;
> > +  } else {
> > +    return &NonSwappingFunctions32;
> > +  }
> > +}
> > +
> > +/**
> > +  Function to return pointer to 64 bit Mmio operations.
> > +
> > +  @param  Swap  Flag to tell if Swap is needed or not
> > +                on Mmio Operations.
> > +
> > +  @return       Pointer to Mmio Operations.
> > +
> > +**/
> > +MMIO_OPERATIONS_64 *
> > +GetMmioOperations64 (BOOLEAN Swap) {
> > +  if (Swap) {
> > +    return &SwappingFunctions64;
> > +  } else {
> > +    return &NonSwappingFunctions64;
> > +  }
> > +}
> > diff --git a/Silicon/NXP/Library/IoAccessLib/IoAccessLib.inf
> > b/Silicon/NXP/Library/IoAccessLib/IoAccessLib.inf
> > new file mode 100644
> > index 0000000..e2e7606
> > --- /dev/null
> > +++ b/Silicon/NXP/Library/IoAccessLib/IoAccessLib.inf
> > @@ -0,0 +1,32 @@
> > +## @IoAccessLib.inf
> > +
> > +#  Copyright 2017 NXP
> > +#
> > +#  This program and the accompanying materials #  are licensed and
> > +made available under the terms and conditions of the BSD License #
> > +which accompanies this distribution.  The full text of the license
> > +may be found at #
> > +https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fope
> > +nsource.org%2Flicenses%2Fbsd-
> license.php&data=02%7C01%7Cmeenakshi
> >
> +.aggarwal%40nxp.com%7C7d85cd38d02e4e6bbdc208d6677905c6%7C686ea1d
> 3bc2b
> >
> +4c6fa92cd99c5c301635%7C0%7C0%7C636810166817008412&sdata=OU
> EJ2URy5
> > +LX7wpvNs9f%2BK01Q1nahX2nWPNO67yOT57M%3D&reserved=0
> > +#
> > +#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> > +BASIS, #  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND,
> EITHER EXPRESS OR IMPLIED.
> > +#
> > +##
> > +
> > +[Defines]
> > +  INF_VERSION                    = 0x0001001A
> > +  BASE_NAME                      = IoAccessLib
> > +  FILE_GUID                      = 28d77333-77eb-4faf-8735-130e5eb3e343
> > +  MODULE_TYPE                    = BASE
> > +  VERSION_STRING                 = 1.0
> > +  LIBRARY_CLASS                  = IoAccessLib
> > +
> > +[Sources.common]
> > +  IoAccessLib.c
> > +
> > +[Packages]
> > +  MdeModulePkg/MdeModulePkg.dec
> > +  MdePkg/MdePkg.dec
> > +  Silicon/NXP/NxpQoriqLs.dec
> > +
> > +[LibraryClasses]
> > +  IoLib
> > --
> > 1.9.1
> >


More information about the edk2-devel mailing list