diff mbox series

[v1,1/7] include: sbi: Introduce common endianess conversion macro

Message ID 20231219112856.3865827-2-hchauhan@ventanamicro.com
State Superseded
Headers show
Series Introduce support for SBI Debug Trigger Extension | expand

Commit Message

Himanshu Chauhan Dec. 19, 2023, 11:28 a.m. UTC
Introduct cpu_to_lle and lle_to_cpu macros which invoke
correct word length cpu_to_le<64/32> conversion based on
__riscv_xlen.

Signed-off-by: Himanshu Chauhan <hchauhan@ventanamicro.com>
---
 include/sbi/sbi_byteorder.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Anup Patel Jan. 5, 2024, 4:10 p.m. UTC | #1
On Tue, Dec 19, 2023 at 4:59 PM Himanshu Chauhan
<hchauhan@ventanamicro.com> wrote:
>
> Introduct cpu_to_lle and lle_to_cpu macros which invoke

s/Introduct/Introduce/

> correct word length cpu_to_le<64/32> conversion based on
> __riscv_xlen.
>
> Signed-off-by: Himanshu Chauhan <hchauhan@ventanamicro.com>

Otherwise, it looks good to me.

Reviewed-by: Anup Patel <anup@brainfault.org>

Regards,
Anup

> ---
>  include/sbi/sbi_byteorder.h | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/include/sbi/sbi_byteorder.h b/include/sbi/sbi_byteorder.h
> index 15107e1..db6eb2b 100644
> --- a/include/sbi/sbi_byteorder.h
> +++ b/include/sbi/sbi_byteorder.h
> @@ -58,4 +58,14 @@
>  #define le64_to_cpu(x)         ((uint64_t)BSWAP64(x))
>  #endif
>
> +#if __riscv_xlen == 64
> +#define cpu_to_lle             cpu_to_le64
> +#define lle_to_cpu             le64_to_cpu
> +#elif __riscv_xlen == 32
> +#define cpu_to_lle             cpu_to_le32
> +#define lle_to_cpu             le32_to_cpu
> +#else
> +#error "Unknown __riscv_xlen"
> +#endif
> +
>  #endif /* __SBI_BYTEORDER_H__ */
> --
> 2.34.1
>
>
> --
> opensbi mailing list
> opensbi@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi
diff mbox series

Patch

diff --git a/include/sbi/sbi_byteorder.h b/include/sbi/sbi_byteorder.h
index 15107e1..db6eb2b 100644
--- a/include/sbi/sbi_byteorder.h
+++ b/include/sbi/sbi_byteorder.h
@@ -58,4 +58,14 @@ 
 #define le64_to_cpu(x)		((uint64_t)BSWAP64(x))
 #endif
 
+#if __riscv_xlen == 64
+#define cpu_to_lle		cpu_to_le64
+#define lle_to_cpu		le64_to_cpu
+#elif __riscv_xlen == 32
+#define cpu_to_lle		cpu_to_le32
+#define lle_to_cpu		le32_to_cpu
+#else
+#error "Unknown __riscv_xlen"
+#endif
+
 #endif /* __SBI_BYTEORDER_H__ */