diff options
| author | Himanshu Chauhan <[email protected]> | 2024-01-09 22:30:13 +0530 |
|---|---|---|
| committer | Anup Patel <[email protected]> | 2024-01-10 09:43:28 +0530 |
| commit | b752099da8e37ec9749245fde918e9f7dbd9957e (patch) | |
| tree | ecee214101c7c6a1128a6bf8452e56679b306e97 | |
| parent | a2b255b88918715173942f2c5e1f97ac9e90c877 (diff) | |
include: sbi: Introduce common endianess conversion macro
Introduce 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 <[email protected]>
Reviewed-by: Anup Patel <[email protected]>
| -rw-r--r-- | include/sbi/sbi_byteorder.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/sbi/sbi_byteorder.h b/include/sbi/sbi_byteorder.h index 15107e1e..db6eb2b9 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__ */ |
