From: Ahmad Fatoum <ah...@a3f.at>

We shouldn't have any physical addresses exceeding 32-bit on 64-bit
systems, especially as barebox doesn't implement ARM32 LPAE.

Add helpers to convert between the types to be able to drop casts and
checks in the code.

Signed-off-by: Ahmad Fatoum <a.fat...@barebox.org>
---
 include/efi/types.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/include/efi/types.h b/include/efi/types.h
index c845d08d62b6..85aaf32f8f1d 100644
--- a/include/efi/types.h
+++ b/include/efi/types.h
@@ -2,7 +2,11 @@
 #ifndef _EFI_TYPES_H_
 #define _EFI_TYPES_H_
 
+#ifndef __ASSEMBLY__
+
 #include <linux/types.h>
+#include <linux/limits.h>
+#include <linux/stddef.h>
 #include <linux/compiler.h>
 #include <linux/uuid.h>
 
@@ -65,4 +69,17 @@ union efi_ip_address {
        struct efi_ipv6_address v6;
 };
 
+static inline void *efi_phys_to_virt(efi_physical_addr_t addr)
+{
+       if (addr > UINTPTR_MAX)
+               __builtin_trap();
+
+       return (void *)(uintptr_t)addr;
+}
+
+static inline efi_physical_addr_t efi_virt_to_phys(const void *addr)
+{
+       return (uintptr_t)addr;
+}
+
 #endif
-- 
2.39.5


Reply via email to