[edk2] [PATCH 03/10] Platform/NXP: Add support for Big Endian Mmio APIs

Meenakshi Aggarwal posted 10 patches 7 years, 1 month ago
[edk2] [PATCH 03/10] Platform/NXP: Add support for Big Endian Mmio APIs
Posted by Meenakshi Aggarwal 7 years, 1 month ago
This library add supports for BE read/write and other
MMIO helper function.
In this data swapped after reading from MMIO and before
write using MMIO.
It can be used by any module with BE address space.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
---
 Platform/NXP/Include/Library/BeIoLib.h   | 332 +++++++++++++++++++++++++
 Platform/NXP/Library/BeIoLib/BeIoLib.c   | 400 +++++++++++++++++++++++++++++++
 Platform/NXP/Library/BeIoLib/BeIoLib.inf |  31 +++
 3 files changed, 763 insertions(+)
 create mode 100644 Platform/NXP/Include/Library/BeIoLib.h
 create mode 100644 Platform/NXP/Library/BeIoLib/BeIoLib.c
 create mode 100644 Platform/NXP/Library/BeIoLib/BeIoLib.inf

diff --git a/Platform/NXP/Include/Library/BeIoLib.h b/Platform/NXP/Include/Library/BeIoLib.h
new file mode 100644
index 0000000..209262d
--- /dev/null
+++ b/Platform/NXP/Include/Library/BeIoLib.h
@@ -0,0 +1,332 @@
+/** BeIoLib.h
+ *
+ *  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
+ *  http://opensource.org/licenses/bsd-license.php
+ *
+ *  HE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ *
+ **/
+
+#ifndef __BE_IOLIB_H__
+#define __BE_IOLIB_H__
+
+#include <Base.h>
+
+/**
+  MmioRead8 for Big-Endian modules.
+
+  @param  Address The MMIO register to read.
+
+  @return The value read.
+
+**/
+UINT8
+EFIAPI
+BeMmioRead8 (
+  IN  UINTN     Address
+  );
+
+/**
+  MmioRead16 for Big-Endian modules.
+
+  @param  Address The MMIO register to read.
+
+  @return The value read.
+
+**/
+UINT16
+EFIAPI
+BeMmioRead16 (
+  IN  UINTN     Address
+  );
+
+/**
+  MmioRead32 for Big-Endian modules.
+
+  @param  Address The MMIO register to read.
+
+  @return The value read.
+
+**/
+UINT32
+EFIAPI
+BeMmioRead32 (
+  IN  UINTN     Address
+  );
+
+/**
+  MmioRead64 for Big-Endian modules.
+
+  @param  Address The MMIO register to read.
+
+  @return The value read.
+
+**/
+UINT64
+EFIAPI
+BeMmioRead64 (
+  IN  UINTN     Address
+  );
+
+/**
+  MmioWrite8 for Big-Endian modules.
+
+  @param  Address The MMIO register to write.
+  @param  Value   The value to write to the MMIO register.
+
+**/
+UINT8
+EFIAPI
+BeMmioWrite8 (
+  IN  UINTN     Address,
+  IN  UINT8     Value
+  );
+
+/**
+  MmioWrite16 for Big-Endian modules.
+
+  @param  Address The MMIO register to write.
+  @param  Value   The value to write to the MMIO register.
+
+**/
+UINT16
+EFIAPI
+BeMmioWrite16 (
+  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
+BeMmioWrite32 (
+  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
+BeMmioWrite64 (
+  IN  UINTN     Address,
+  IN  UINT64    Value
+  );
+
+/**
+  MmioAndThenOr8 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.
+
+**/
+UINT8
+EFIAPI
+BeMmioAndThenOr8 (
+  IN  UINTN     Address,
+  IN  UINT8     AndData,
+  IN  UINT8     OrData
+  );
+
+/**
+  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
+BeMmioAndThenOr16 (
+  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
+BeMmioAndThenOr32 (
+  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
+BeMmioAndThenOr64 (
+  IN  UINTN     Address,
+  IN  UINT64    AndData,
+  IN  UINT64    OrData
+  );
+
+/**
+  MmioOr8 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.
+
+**/
+UINT8
+EFIAPI
+BeMmioOr8 (
+  IN  UINTN     Address,
+  IN  UINT8     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
+BeMmioOr16 (
+  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
+BeMmioOr32 (
+  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
+BeMmioOr64 (
+  IN  UINTN     Address,
+  IN  UINT64    OrData
+  );
+
+/**
+  MmioAnd8 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.
+
+**/
+UINT8
+EFIAPI
+BeMmioAnd8 (
+  IN  UINTN     Address,
+  IN  UINT8     AndData
+  );
+
+/**
+  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
+BeMmioAnd16 (
+  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
+BeMmioAnd32 (
+  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
+BeMmioAnd64 (
+  IN  UINTN     Address,
+  IN  UINT64    AndData
+  );
+
+#endif /* _BE_IOLIB_H */
diff --git a/Platform/NXP/Library/BeIoLib/BeIoLib.c b/Platform/NXP/Library/BeIoLib/BeIoLib.c
new file mode 100644
index 0000000..b4e7c90
--- /dev/null
+++ b/Platform/NXP/Library/BeIoLib/BeIoLib.c
@@ -0,0 +1,400 @@
+/** BeIoLib.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
+  http://opensource.org/licenses/bsd-license.php
+
+  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/IoLib.h>
+
+/**
+  MmioRead8 for Big-Endian modules.
+
+  @param  Address The MMIO register to read.
+
+  @return The value read.
+
+**/
+UINT8
+EFIAPI
+BeMmioRead8 (
+  IN  UINTN     Address
+  )
+{
+  return MmioRead8(Address);
+}
+
+/**
+  MmioRead16 for Big-Endian modules.
+
+  @param  Address The MMIO register to read.
+
+  @return The value read.
+
+**/
+UINT16
+EFIAPI
+BeMmioRead16 (
+  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
+BeMmioRead32 (
+  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
+BeMmioRead64 (
+  IN  UINTN     Address
+  )
+{
+  return SwapBytes64(MmioRead64(Address));
+}
+
+/**
+  MmioWrite8 for Big-Endian modules.
+
+  @param  Address The MMIO register to write.
+  @param  Value   The value to write to the MMIO register.
+
+**/
+UINT8
+EFIAPI
+BeMmioWrite8 (
+  IN  UINTN     Address,
+  IN  UINT8     Value
+  )
+{
+  return MmioWrite8(Address, Value);
+}
+
+/**
+  MmioWrite16 for Big-Endian modules.
+
+  @param  Address The MMIO register to write.
+  @param  Value   The value to write to the MMIO register.
+
+**/
+UINT16
+EFIAPI
+BeMmioWrite16 (
+  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
+BeMmioWrite32 (
+  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
+BeMmioWrite64 (
+  IN  UINTN     Address,
+  IN  UINT64    Value
+  )
+{
+  return MmioWrite64(Address, SwapBytes64(Value));
+}
+
+/**
+  MmioAndThenOr8 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.
+
+**/
+UINT8
+EFIAPI
+BeMmioAndThenOr8 (
+  IN  UINTN     Address,
+  IN  UINT8     AndData,
+  IN  UINT8     OrData
+  )
+{
+  return MmioAndThenOr8(Address, AndData, OrData);
+}
+
+/**
+  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
+BeMmioAndThenOr16 (
+  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
+BeMmioAndThenOr32 (
+  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
+BeMmioAndThenOr64 (
+  IN  UINTN     Address,
+  IN  UINT64    AndData,
+  IN  UINT64    OrData
+  )
+{
+  AndData = SwapBytes64(AndData);
+  OrData = SwapBytes64(OrData);
+
+  return MmioAndThenOr64(Address, AndData, OrData);
+}
+
+/**
+  MmioOr8 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.
+
+**/
+UINT8
+EFIAPI
+BeMmioOr8 (
+  IN  UINTN     Address,
+  IN  UINT8     OrData
+  )
+{
+  return MmioOr8(Address, 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
+BeMmioOr16 (
+  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
+BeMmioOr32 (
+  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
+BeMmioOr64 (
+  IN  UINTN     Address,
+  IN  UINT64    OrData
+  )
+{
+  return MmioOr64(Address, SwapBytes64(OrData));
+}
+
+/**
+  MmioAnd8 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.
+
+**/
+UINT8
+EFIAPI
+BeMmioAnd8 (
+  IN  UINTN     Address,
+  IN  UINT8     AndData
+  )
+{
+  return MmioAnd8(Address, AndData);
+}
+
+/**
+  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
+BeMmioAnd16 (
+  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
+BeMmioAnd32 (
+  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
+BeMmioAnd64 (
+  IN  UINTN     Address,
+  IN  UINT64    AndData
+  )
+{
+  return MmioAnd64(Address, SwapBytes64(AndData));
+}
diff --git a/Platform/NXP/Library/BeIoLib/BeIoLib.inf b/Platform/NXP/Library/BeIoLib/BeIoLib.inf
new file mode 100644
index 0000000..ca64d8f
--- /dev/null
+++ b/Platform/NXP/Library/BeIoLib/BeIoLib.inf
@@ -0,0 +1,31 @@
+## @BeIoLib.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
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  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                    = 0x00010005
+  BASE_NAME                      = BeIoLib
+  FILE_GUID                      = 28d77333-77eb-4faf-8735-130e5eb3e343
+  MODULE_TYPE                    = BASE
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = BeIoLib
+
+[Packages]
+  MdeModulePkg/MdeModulePkg.dec
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  IoLib
+
+[Sources.common]
+  BeIoLib.c
-- 
1.9.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH 03/10] Platform/NXP: Add support for Big Endian Mmio APIs
Posted by Ard Biesheuvel 7 years, 1 month ago
On 7 November 2017 at 14:42, Meenakshi Aggarwal
<meenakshi.aggarwal@nxp.com> wrote:
> This library add supports for BE read/write and other
> MMIO helper function.
> In this data swapped after reading from MMIO and before
> write using MMIO.
> It can be used by any module with BE address space.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> ---
>  Platform/NXP/Include/Library/BeIoLib.h   | 332 +++++++++++++++++++++++++
>  Platform/NXP/Library/BeIoLib/BeIoLib.c   | 400 +++++++++++++++++++++++++++++++
>  Platform/NXP/Library/BeIoLib/BeIoLib.inf |  31 +++
>  3 files changed, 763 insertions(+)
>  create mode 100644 Platform/NXP/Include/Library/BeIoLib.h
>  create mode 100644 Platform/NXP/Library/BeIoLib/BeIoLib.c
>  create mode 100644 Platform/NXP/Library/BeIoLib/BeIoLib.inf
>
> diff --git a/Platform/NXP/Include/Library/BeIoLib.h b/Platform/NXP/Include/Library/BeIoLib.h
> new file mode 100644
> index 0000000..209262d
> --- /dev/null
> +++ b/Platform/NXP/Include/Library/BeIoLib.h
> @@ -0,0 +1,332 @@
> +/** BeIoLib.h
> + *
> + *  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
> + *  http://opensource.org/licenses/bsd-license.php
> + *
> + *  HE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,

Missing T ^^^

> + *  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> + *
> + **/
> +
> +#ifndef __BE_IOLIB_H__
> +#define __BE_IOLIB_H__
> +
> +#include <Base.h>
> +
> +/**
> +  MmioRead8 for Big-Endian modules.
> +
> +  @param  Address The MMIO register to read.
> +
> +  @return The value read.
> +
> +**/
> +UINT8
> +EFIAPI
> +BeMmioRead8 (
> +  IN  UINTN     Address
> +  );
> +
> +/**
> +  MmioRead16 for Big-Endian modules.
> +
> +  @param  Address The MMIO register to read.
> +
> +  @return The value read.
> +
> +**/
> +UINT16
> +EFIAPI
> +BeMmioRead16 (
> +  IN  UINTN     Address
> +  );
> +
> +/**
> +  MmioRead32 for Big-Endian modules.
> +
> +  @param  Address The MMIO register to read.
> +
> +  @return The value read.
> +
> +**/
> +UINT32
> +EFIAPI
> +BeMmioRead32 (
> +  IN  UINTN     Address
> +  );
> +
> +/**
> +  MmioRead64 for Big-Endian modules.
> +
> +  @param  Address The MMIO register to read.
> +
> +  @return The value read.
> +
> +**/
> +UINT64
> +EFIAPI
> +BeMmioRead64 (
> +  IN  UINTN     Address
> +  );
> +
> +/**
> +  MmioWrite8 for Big-Endian modules.
> +
> +  @param  Address The MMIO register to write.
> +  @param  Value   The value to write to the MMIO register.
> +
> +**/
> +UINT8
> +EFIAPI
> +BeMmioWrite8 (
> +  IN  UINTN     Address,
> +  IN  UINT8     Value
> +  );
> +
> +/**
> +  MmioWrite16 for Big-Endian modules.
> +
> +  @param  Address The MMIO register to write.
> +  @param  Value   The value to write to the MMIO register.
> +
> +**/
> +UINT16
> +EFIAPI
> +BeMmioWrite16 (
> +  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
> +BeMmioWrite32 (
> +  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
> +BeMmioWrite64 (
> +  IN  UINTN     Address,
> +  IN  UINT64    Value
> +  );
> +
> +/**
> +  MmioAndThenOr8 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.
> +
> +**/
> +UINT8
> +EFIAPI
> +BeMmioAndThenOr8 (
> +  IN  UINTN     Address,
> +  IN  UINT8     AndData,
> +  IN  UINT8     OrData
> +  );
> +
> +/**
> +  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
> +BeMmioAndThenOr16 (
> +  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
> +BeMmioAndThenOr32 (
> +  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
> +BeMmioAndThenOr64 (
> +  IN  UINTN     Address,
> +  IN  UINT64    AndData,
> +  IN  UINT64    OrData
> +  );
> +
> +/**
> +  MmioOr8 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.
> +
> +**/
> +UINT8
> +EFIAPI
> +BeMmioOr8 (
> +  IN  UINTN     Address,
> +  IN  UINT8     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
> +BeMmioOr16 (
> +  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
> +BeMmioOr32 (
> +  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
> +BeMmioOr64 (
> +  IN  UINTN     Address,
> +  IN  UINT64    OrData
> +  );
> +
> +/**
> +  MmioAnd8 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.
> +
> +**/
> +UINT8
> +EFIAPI
> +BeMmioAnd8 (
> +  IN  UINTN     Address,
> +  IN  UINT8     AndData
> +  );
> +
> +/**
> +  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
> +BeMmioAnd16 (
> +  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
> +BeMmioAnd32 (
> +  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
> +BeMmioAnd64 (
> +  IN  UINTN     Address,
> +  IN  UINT64    AndData
> +  );
> +
> +#endif /* _BE_IOLIB_H */
> diff --git a/Platform/NXP/Library/BeIoLib/BeIoLib.c b/Platform/NXP/Library/BeIoLib/BeIoLib.c
> new file mode 100644
> index 0000000..b4e7c90
> --- /dev/null
> +++ b/Platform/NXP/Library/BeIoLib/BeIoLib.c
> @@ -0,0 +1,400 @@
> +/** BeIoLib.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
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  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/IoLib.h>
> +
> +/**
> +  MmioRead8 for Big-Endian modules.
> +
> +  @param  Address The MMIO register to read.
> +
> +  @return The value read.
> +
> +**/
> +UINT8
> +EFIAPI
> +BeMmioRead8 (
> +  IN  UINTN     Address
> +  )
> +{
> +  return MmioRead8(Address);

Please put a space before (

> +}
> +
> +/**
> +  MmioRead16 for Big-Endian modules.
> +
> +  @param  Address The MMIO register to read.
> +
> +  @return The value read.
> +
> +**/
> +UINT16
> +EFIAPI
> +BeMmioRead16 (
> +  IN  UINTN     Address
> +  )
> +{
> +  return SwapBytes16(MmioRead16(Address));

and here (2x)

> +}
> +
> +/**
> +  MmioRead32 for Big-Endian modules.
> +
> +  @param  Address The MMIO register to read.
> +
> +  @return The value read.
> +
> +**/
> +UINT32
> +EFIAPI
> +BeMmioRead32 (
> +  IN  UINTN     Address
> +  )
> +{
> +  return SwapBytes32(MmioRead32(Address));

etc etc

> +}
> +
> +/**
> +  MmioRead64 for Big-Endian modules.
> +
> +  @param  Address The MMIO register to read.
> +
> +  @return The value read.
> +
> +**/
> +UINT64
> +EFIAPI
> +BeMmioRead64 (
> +  IN  UINTN     Address
> +  )
> +{
> +  return SwapBytes64(MmioRead64(Address));
> +}
> +
> +/**
> +  MmioWrite8 for Big-Endian modules.
> +
> +  @param  Address The MMIO register to write.
> +  @param  Value   The value to write to the MMIO register.
> +
> +**/
> +UINT8
> +EFIAPI
> +BeMmioWrite8 (
> +  IN  UINTN     Address,
> +  IN  UINT8     Value
> +  )
> +{
> +  return MmioWrite8(Address, Value);
> +}
> +
> +/**
> +  MmioWrite16 for Big-Endian modules.
> +
> +  @param  Address The MMIO register to write.
> +  @param  Value   The value to write to the MMIO register.
> +
> +**/
> +UINT16
> +EFIAPI
> +BeMmioWrite16 (
> +  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
> +BeMmioWrite32 (
> +  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
> +BeMmioWrite64 (
> +  IN  UINTN     Address,
> +  IN  UINT64    Value
> +  )
> +{
> +  return MmioWrite64(Address, SwapBytes64(Value));
> +}
> +
> +/**
> +  MmioAndThenOr8 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.
> +
> +**/
> +UINT8
> +EFIAPI
> +BeMmioAndThenOr8 (
> +  IN  UINTN     Address,
> +  IN  UINT8     AndData,
> +  IN  UINT8     OrData
> +  )
> +{
> +  return MmioAndThenOr8(Address, AndData, OrData);
> +}
> +
> +/**
> +  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
> +BeMmioAndThenOr16 (
> +  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
> +BeMmioAndThenOr32 (
> +  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
> +BeMmioAndThenOr64 (
> +  IN  UINTN     Address,
> +  IN  UINT64    AndData,
> +  IN  UINT64    OrData
> +  )
> +{
> +  AndData = SwapBytes64(AndData);
> +  OrData = SwapBytes64(OrData);
> +
> +  return MmioAndThenOr64(Address, AndData, OrData);
> +}
> +
> +/**
> +  MmioOr8 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.
> +
> +**/
> +UINT8
> +EFIAPI
> +BeMmioOr8 (
> +  IN  UINTN     Address,
> +  IN  UINT8     OrData
> +  )
> +{
> +  return MmioOr8(Address, 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
> +BeMmioOr16 (
> +  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
> +BeMmioOr32 (
> +  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
> +BeMmioOr64 (
> +  IN  UINTN     Address,
> +  IN  UINT64    OrData
> +  )
> +{
> +  return MmioOr64(Address, SwapBytes64(OrData));
> +}
> +
> +/**
> +  MmioAnd8 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.
> +
> +**/
> +UINT8
> +EFIAPI
> +BeMmioAnd8 (
> +  IN  UINTN     Address,
> +  IN  UINT8     AndData
> +  )
> +{
> +  return MmioAnd8(Address, AndData);
> +}
> +
> +/**
> +  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
> +BeMmioAnd16 (
> +  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
> +BeMmioAnd32 (
> +  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
> +BeMmioAnd64 (
> +  IN  UINTN     Address,
> +  IN  UINT64    AndData
> +  )
> +{
> +  return MmioAnd64(Address, SwapBytes64(AndData));
> +}
> diff --git a/Platform/NXP/Library/BeIoLib/BeIoLib.inf b/Platform/NXP/Library/BeIoLib/BeIoLib.inf
> new file mode 100644
> index 0000000..ca64d8f
> --- /dev/null
> +++ b/Platform/NXP/Library/BeIoLib/BeIoLib.inf
> @@ -0,0 +1,31 @@
> +## @BeIoLib.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
> +#  http://opensource.org/licenses/bsd-license.php
> +#
> +#  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                    = 0x00010005

0x0001001A

> +  BASE_NAME                      = BeIoLib
> +  FILE_GUID                      = 28d77333-77eb-4faf-8735-130e5eb3e343
> +  MODULE_TYPE                    = BASE
> +  VERSION_STRING                 = 1.0
> +  LIBRARY_CLASS                  = BeIoLib
> +
> +[Packages]
> +  MdeModulePkg/MdeModulePkg.dec
> +  MdePkg/MdePkg.dec
> +
> +[LibraryClasses]
> +  IoLib
> +
> +[Sources.common]
> +  BeIoLib.c
> --
> 1.9.1
>
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH 03/10] Platform/NXP: Add support for Big Endian Mmio APIs
Posted by Meenakshi Aggarwal 7 years, 1 month ago

> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> Sent: Monday, November 13, 2017 5:56 PM
> To: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> Cc: Leif Lindholm <leif.lindholm@linaro.org>; Kinney, Michael D
> <michael.d.kinney@intel.com>; edk2-devel@lists.01.org; Udit Kumar
> <udit.kumar@nxp.com>; Varun Sethi <V.Sethi@nxp.com>
> Subject: Re: [PATCH 03/10] Platform/NXP: Add support for Big Endian Mmio
> APIs
> 
> On 7 November 2017 at 14:42, Meenakshi Aggarwal
> <meenakshi.aggarwal@nxp.com> wrote:
> > This library add supports for BE read/write and other MMIO helper
> > function.
> > In this data swapped after reading from MMIO and before write using
> > MMIO.
> > It can be used by any module with BE address space.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> > ---
> >  Platform/NXP/Include/Library/BeIoLib.h   | 332
> +++++++++++++++++++++++++
> >  Platform/NXP/Library/BeIoLib/BeIoLib.c   | 400
> +++++++++++++++++++++++++++++++
> >  Platform/NXP/Library/BeIoLib/BeIoLib.inf |  31 +++
> >  3 files changed, 763 insertions(+)
> >  create mode 100644 Platform/NXP/Include/Library/BeIoLib.h
> >  create mode 100644 Platform/NXP/Library/BeIoLib/BeIoLib.c
> >  create mode 100644 Platform/NXP/Library/BeIoLib/BeIoLib.inf
> >
> > diff --git a/Platform/NXP/Include/Library/BeIoLib.h
> > b/Platform/NXP/Include/Library/BeIoLib.h
> > new file mode 100644
> > index 0000000..209262d
> > --- /dev/null
> > +++ b/Platform/NXP/Include/Library/BeIoLib.h
> > @@ -0,0 +1,332 @@
> > +/** BeIoLib.h
> > + *
> > + *  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
> e
> > +nsource.org%2Flicenses%2Fbsd-
> license.php&data=02%7C01%7Cmeenakshi.agg
> >
> +arwal%40nxp.com%7Cd233bd96ea6c4c16416a08d52a91bdca%7C686ea1d3b
> c2b4c6f
> >
> +a92cd99c5c301635%7C0%7C0%7C636461727802004484&sdata=kL%2FOMen
> 61jeQlPG
> > +3YK2wA2oWgHFrykVMxLQcRNA63Ks%3D&reserved=0
> > + *
> > + *  HE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> > +BASIS,
> 
> Missing T ^^^
> 
Thanks for catching this.

> > + *  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> > + *
> > + **/
> > +
> > +#ifndef __BE_IOLIB_H__
> > +#define __BE_IOLIB_H__
> > +
> > +#include <Base.h>
> > +
> > +/**
> > +  MmioRead8 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to read.
> > +
> > +  @return The value read.
> > +
> > +**/
> > +UINT8
> > +EFIAPI
> > +BeMmioRead8 (
> > +  IN  UINTN     Address
> > +  );
> > +
> > +/**
> > +  MmioRead16 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to read.
> > +
> > +  @return The value read.
> > +
> > +**/
> > +UINT16
> > +EFIAPI
> > +BeMmioRead16 (
> > +  IN  UINTN     Address
> > +  );
> > +
> > +/**
> > +  MmioRead32 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to read.
> > +
> > +  @return The value read.
> > +
> > +**/
> > +UINT32
> > +EFIAPI
> > +BeMmioRead32 (
> > +  IN  UINTN     Address
> > +  );
> > +
> > +/**
> > +  MmioRead64 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to read.
> > +
> > +  @return The value read.
> > +
> > +**/
> > +UINT64
> > +EFIAPI
> > +BeMmioRead64 (
> > +  IN  UINTN     Address
> > +  );
> > +
> > +/**
> > +  MmioWrite8 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  Value   The value to write to the MMIO register.
> > +
> > +**/
> > +UINT8
> > +EFIAPI
> > +BeMmioWrite8 (
> > +  IN  UINTN     Address,
> > +  IN  UINT8     Value
> > +  );
> > +
> > +/**
> > +  MmioWrite16 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  Value   The value to write to the MMIO register.
> > +
> > +**/
> > +UINT16
> > +EFIAPI
> > +BeMmioWrite16 (
> > +  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
> > +BeMmioWrite32 (
> > +  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
> > +BeMmioWrite64 (
> > +  IN  UINTN     Address,
> > +  IN  UINT64    Value
> > +  );
> > +
> > +/**
> > +  MmioAndThenOr8 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.
> > +
> > +**/
> > +UINT8
> > +EFIAPI
> > +BeMmioAndThenOr8 (
> > +  IN  UINTN     Address,
> > +  IN  UINT8     AndData,
> > +  IN  UINT8     OrData
> > +  );
> > +
> > +/**
> > +  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
> > +BeMmioAndThenOr16 (
> > +  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
> > +BeMmioAndThenOr32 (
> > +  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
> > +BeMmioAndThenOr64 (
> > +  IN  UINTN     Address,
> > +  IN  UINT64    AndData,
> > +  IN  UINT64    OrData
> > +  );
> > +
> > +/**
> > +  MmioOr8 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.
> > +
> > +**/
> > +UINT8
> > +EFIAPI
> > +BeMmioOr8 (
> > +  IN  UINTN     Address,
> > +  IN  UINT8     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
> > +BeMmioOr16 (
> > +  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
> > +BeMmioOr32 (
> > +  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
> > +BeMmioOr64 (
> > +  IN  UINTN     Address,
> > +  IN  UINT64    OrData
> > +  );
> > +
> > +/**
> > +  MmioAnd8 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.
> > +
> > +**/
> > +UINT8
> > +EFIAPI
> > +BeMmioAnd8 (
> > +  IN  UINTN     Address,
> > +  IN  UINT8     AndData
> > +  );
> > +
> > +/**
> > +  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
> > +BeMmioAnd16 (
> > +  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
> > +BeMmioAnd32 (
> > +  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
> > +BeMmioAnd64 (
> > +  IN  UINTN     Address,
> > +  IN  UINT64    AndData
> > +  );
> > +
> > +#endif /* _BE_IOLIB_H */
> > diff --git a/Platform/NXP/Library/BeIoLib/BeIoLib.c
> > b/Platform/NXP/Library/BeIoLib/BeIoLib.c
> > new file mode 100644
> > index 0000000..b4e7c90
> > --- /dev/null
> > +++ b/Platform/NXP/Library/BeIoLib/BeIoLib.c
> > @@ -0,0 +1,400 @@
> > +/** BeIoLib.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%7Cmeenakshi.a
> > +
> ggarwal%40nxp.com%7Cd233bd96ea6c4c16416a08d52a91bdca%7C686ea1d3
> bc2b4
> > +
> c6fa92cd99c5c301635%7C0%7C0%7C636461727802004484&sdata=kL%2FOMe
> n61je
> > + QlPG3YK2wA2oWgHFrykVMxLQcRNA63Ks%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/IoLib.h>
> > +
> > +/**
> > +  MmioRead8 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to read.
> > +
> > +  @return The value read.
> > +
> > +**/
> > +UINT8
> > +EFIAPI
> > +BeMmioRead8 (
> > +  IN  UINTN     Address
> > +  )
> > +{
> > +  return MmioRead8(Address);
> 
> Please put a space before (
> 
OK

> > +}
> > +
> > +/**
> > +  MmioRead16 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to read.
> > +
> > +  @return The value read.
> > +
> > +**/
> > +UINT16
> > +EFIAPI
> > +BeMmioRead16 (
> > +  IN  UINTN     Address
> > +  )
> > +{
> > +  return SwapBytes16(MmioRead16(Address));
> 
> and here (2x)
> 
> > +}
> > +
> > +/**
> > +  MmioRead32 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to read.
> > +
> > +  @return The value read.
> > +
> > +**/
> > +UINT32
> > +EFIAPI
> > +BeMmioRead32 (
> > +  IN  UINTN     Address
> > +  )
> > +{
> > +  return SwapBytes32(MmioRead32(Address));
> 
> etc etc
> 
> > +}
> > +
> > +/**
> > +  MmioRead64 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to read.
> > +
> > +  @return The value read.
> > +
> > +**/
> > +UINT64
> > +EFIAPI
> > +BeMmioRead64 (
> > +  IN  UINTN     Address
> > +  )
> > +{
> > +  return SwapBytes64(MmioRead64(Address)); }
> > +
> > +/**
> > +  MmioWrite8 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  Value   The value to write to the MMIO register.
> > +
> > +**/
> > +UINT8
> > +EFIAPI
> > +BeMmioWrite8 (
> > +  IN  UINTN     Address,
> > +  IN  UINT8     Value
> > +  )
> > +{
> > +  return MmioWrite8(Address, Value);
> > +}
> > +
> > +/**
> > +  MmioWrite16 for Big-Endian modules.
> > +
> > +  @param  Address The MMIO register to write.
> > +  @param  Value   The value to write to the MMIO register.
> > +
> > +**/
> > +UINT16
> > +EFIAPI
> > +BeMmioWrite16 (
> > +  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
> > +BeMmioWrite32 (
> > +  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
> > +BeMmioWrite64 (
> > +  IN  UINTN     Address,
> > +  IN  UINT64    Value
> > +  )
> > +{
> > +  return MmioWrite64(Address, SwapBytes64(Value)); }
> > +
> > +/**
> > +  MmioAndThenOr8 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.
> > +
> > +**/
> > +UINT8
> > +EFIAPI
> > +BeMmioAndThenOr8 (
> > +  IN  UINTN     Address,
> > +  IN  UINT8     AndData,
> > +  IN  UINT8     OrData
> > +  )
> > +{
> > +  return MmioAndThenOr8(Address, AndData, OrData); }
> > +
> > +/**
> > +  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
> > +BeMmioAndThenOr16 (
> > +  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
> > +BeMmioAndThenOr32 (
> > +  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
> > +BeMmioAndThenOr64 (
> > +  IN  UINTN     Address,
> > +  IN  UINT64    AndData,
> > +  IN  UINT64    OrData
> > +  )
> > +{
> > +  AndData = SwapBytes64(AndData);
> > +  OrData = SwapBytes64(OrData);
> > +
> > +  return MmioAndThenOr64(Address, AndData, OrData); }
> > +
> > +/**
> > +  MmioOr8 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.
> > +
> > +**/
> > +UINT8
> > +EFIAPI
> > +BeMmioOr8 (
> > +  IN  UINTN     Address,
> > +  IN  UINT8     OrData
> > +  )
> > +{
> > +  return MmioOr8(Address, 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
> > +BeMmioOr16 (
> > +  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
> > +BeMmioOr32 (
> > +  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
> > +BeMmioOr64 (
> > +  IN  UINTN     Address,
> > +  IN  UINT64    OrData
> > +  )
> > +{
> > +  return MmioOr64(Address, SwapBytes64(OrData)); }
> > +
> > +/**
> > +  MmioAnd8 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.
> > +
> > +**/
> > +UINT8
> > +EFIAPI
> > +BeMmioAnd8 (
> > +  IN  UINTN     Address,
> > +  IN  UINT8     AndData
> > +  )
> > +{
> > +  return MmioAnd8(Address, AndData);
> > +}
> > +
> > +/**
> > +  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
> > +BeMmioAnd16 (
> > +  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
> > +BeMmioAnd32 (
> > +  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
> > +BeMmioAnd64 (
> > +  IN  UINTN     Address,
> > +  IN  UINT64    AndData
> > +  )
> > +{
> > +  return MmioAnd64(Address, SwapBytes64(AndData)); }
> > diff --git a/Platform/NXP/Library/BeIoLib/BeIoLib.inf
> > b/Platform/NXP/Library/BeIoLib/BeIoLib.inf
> > new file mode 100644
> > index 0000000..ca64d8f
> > --- /dev/null
> > +++ b/Platform/NXP/Library/BeIoLib/BeIoLib.inf
> > @@ -0,0 +1,31 @@
> > +## @BeIoLib.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%2Fop
> e
> > +nsource.org%2Flicenses%2Fbsd-
> license.php&data=02%7C01%7Cmeenakshi.agg
> >
> +arwal%40nxp.com%7Cd233bd96ea6c4c16416a08d52a91bdca%7C686ea1d3b
> c2b4c6f
> >
> +a92cd99c5c301635%7C0%7C0%7C636461727802004484&sdata=kL%2FOMen
> 61jeQlPG
> > +3YK2wA2oWgHFrykVMxLQcRNA63Ks%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                    = 0x00010005
> 
> 0x0001001A
> 
OK, will correct in all patches.

> > +  BASE_NAME                      = BeIoLib
> > +  FILE_GUID                      = 28d77333-77eb-4faf-8735-130e5eb3e343
> > +  MODULE_TYPE                    = BASE
> > +  VERSION_STRING                 = 1.0
> > +  LIBRARY_CLASS                  = BeIoLib
> > +
> > +[Packages]
> > +  MdeModulePkg/MdeModulePkg.dec
> > +  MdePkg/MdePkg.dec
> > +
> > +[LibraryClasses]
> > +  IoLib
> > +
> > +[Sources.common]
> > +  BeIoLib.c
> > --
> > 1.9.1
> >
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel