From: Jan Kiszka <[email protected]>

Avoids the open-coding in drivers.

Signed-off-by: Jan Kiszka <[email protected]>
---
 include/mmio.h | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 include/mmio.h

diff --git a/include/mmio.h b/include/mmio.h
new file mode 100644
index 0000000..90c17de
--- /dev/null
+++ b/include/mmio.h
@@ -0,0 +1,45 @@
+/*
+ * EFI Boot Guard
+ *
+ * Copyright (c) Siemens AG, 2021
+ *
+ * Authors:
+ *  Jan Kiszka <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <efi.h>
+
+static inline UINT8 readb(UINTN addr)
+{
+       return *(volatile UINT8 *)addr;
+}
+
+static inline UINT16 readw(UINTN addr)
+{
+       return *(volatile UINT16 *)addr;
+}
+
+static inline UINT32 readl(UINTN addr)
+{
+       return *(volatile UINT32 *)addr;
+}
+
+static inline void writeb(UINT8 value, UINTN addr)
+{
+       *(volatile UINT8 *)addr = value;
+}
+
+static inline void writew(UINT16 value, UINTN addr)
+{
+       *(volatile UINT16 *)addr = value;
+}
+
+static inline void writel(UINT32 value, UINTN addr)
+{
+       *(volatile UINT32 *)addr = value;
+}
-- 
2.26.2

-- 
You received this message because you are subscribed to the Google Groups "EFI 
Boot Guard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/efibootguard-dev/88b4d6403c10d90294c586c35f4d8b1f1081fc56.1622448429.git.jan.kiszka%40siemens.com.

Reply via email to