OpenSBI Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Rahul Pathak <rpathak@ventanamicro.com>
To: opensbi@lists.infradead.org
Subject: [PATCH v2 3/3] include: types: Add typedefs for endianness
Date: Thu,  2 Feb 2023 10:14:27 +0530	[thread overview]
Message-ID: <20230202044427.1253816-4-rpathak@ventanamicro.com> (raw)
In-Reply-To: <20230202044427.1253816-1-rpathak@ventanamicro.com>

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>
---
 include/sbi/sbi_types.h       | 7 +++++++
 lib/utils/libfdt/libfdt_env.h | 6 +++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/include/sbi/sbi_types.h b/include/sbi/sbi_types.h
index 9c1fef3b8dc6..def88bbad2c3 100644
--- a/include/sbi/sbi_types.h
+++ b/include/sbi/sbi_types.h
@@ -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
 
diff --git a/lib/utils/libfdt/libfdt_env.h b/lib/utils/libfdt/libfdt_env.h
index e5ad7698efca..6ebbae01b514 100644
--- a/lib/utils/libfdt/libfdt_env.h
+++ b/lib/utils/libfdt/libfdt_env.h
@@ -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)
 {
-- 
2.34.1



  parent reply	other threads:[~2023-02-02  4:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-02  4:44 [PATCH v2 0/3] Add endianness conversion support Rahul Pathak
2023-02-02  4:44 ` [PATCH v2 1/3] include: Add support for byteorder/endianness conversion Rahul Pathak
2023-02-08 12:46   ` Anup Patel
2023-02-09  0:28   ` Samuel Holland
2023-02-09  3:25     ` Anup Patel
2023-02-02  4:44 ` [PATCH v2 2/3] lib: utils/fdt: Use byteorder conversion functions in libfdt_env.h Rahul Pathak
2023-02-08 12:53   ` Anup Patel
2023-02-02  4:44 ` Rahul Pathak [this message]
2023-02-08 12:56   ` [PATCH v2 3/3] include: types: Add typedefs for endianness Anup Patel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230202044427.1253816-4-rpathak@ventanamicro.com \
    --to=rpathak@ventanamicro.com \
    --cc=opensbi@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox