include: types: Add typedefs for endianness
authorRahul Pathak <rpathak@ventanamicro.com>
Thu, 2 Feb 2023 04:44:27 +0000 (10:14 +0530)
committerAnup Patel <anup@brainfault.org>
Wed, 8 Feb 2023 12:54:13 +0000 (18:24 +0530)
If any variable/memory-location follows certain
endianness then its important to annotate it properly
so that proper conversion can be done before read/write
from that variable/memory.

Also, use these new typedefs in libfdt_env.h for deriving
its own custom fdtX_t types

Signed-off-by: Rahul Pathak <rpathak@ventanamicro.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
include/sbi/sbi_types.h
lib/utils/libfdt/libfdt_env.h

index 9c1fef3b8dc6d05aeea1374ab1cf290124ace61c..def88bbad2c333f9eac8b5afa33fd3ed2ab8f1a0 100644 (file)
@@ -54,6 +54,13 @@ typedef unsigned long                virtual_size_t;
 typedef unsigned long          physical_addr_t;
 typedef unsigned long          physical_size_t;
 
+typedef uint16_t               le16_t;
+typedef uint16_t               be16_t;
+typedef uint32_t               le32_t;
+typedef uint32_t               be32_t;
+typedef uint64_t               le64_t;
+typedef uint64_t               be64_t;
+
 #define true                   1
 #define false                  0
 
index e5ad7698efca410106ea041dcfb7410993441675..6ebbae01b5149e0ad99e66c96e236a1854d47e23 100644 (file)
@@ -38,9 +38,9 @@
 #define strlen         sbi_strlen
 #define strnlen                sbi_strnlen
 
-typedef uint16_t FDT_BITWISE fdt16_t;
-typedef uint32_t FDT_BITWISE fdt32_t;
-typedef uint64_t FDT_BITWISE fdt64_t;
+typedef be16_t FDT_BITWISE fdt16_t;
+typedef be32_t FDT_BITWISE fdt32_t;
+typedef be64_t FDT_BITWISE fdt64_t;
 
 static inline uint16_t fdt16_to_cpu(fdt16_t x)
 {