@@ -426,6 +426,28 @@ choice
bool "medium any code model"
endchoice
+choice
+ prompt "Data endian"
+ default CPU_LITTLE_ENDIAN
+ help
+ Configure the endiannes of data access performed by the CPU.
+ This will require system to be booted from M mode in big endian
+ and the userland to be compiled for the same endian-ness.
+
+config CPU_BIG_ENDIAN
+ bool "Build big-endian kernel"
+ depends on EXPERT
+ help
+ Say Y if you want to run big-endian kernel and userspace
+ Set for expert as this experimental
+
+config CPU_LITTLE_ENDIAN
+ bool "Build little-endian kernel (default)"
+ help
+ Say Y if you want to run little-endian kernel and userspace
+ This is the default for most distributions
+endchoice
+
config MODULE_SECTIONS
bool
select HAVE_MOD_ARCH_SPECIFIC
@@ -21,6 +21,11 @@ else
endif
endif
+ifeq ($(CONFIG_CPU_BIG_ENDIAN),y)
+KBUILD_CPPFLAGS += -mbig-endian -D__RISCVEB__
+CHECKFLAGS += -D__RISCVEB__
+endif
+
ifeq ($(CONFIG_CMODEL_MEDLOW),y)
KBUILD_CFLAGS_MODULE += -mcmodel=medany
endif
@@ -28,13 +33,17 @@ endif
export BITS
ifeq ($(CONFIG_ARCH_RV64I),y)
BITS := 64
- UTS_MACHINE := riscv64
+ ifeq ($(CONFIG_CPU_BIG_ENDIAN),y)
+ UTS_MACHINE := riscv64_be
+ KBUILD_LDFLAGS += -melf64briscv
+ else
+ UTS_MACHINE := riscv64
+ KBUILD_LDFLAGS += -melf64lriscv
+ endif
KBUILD_CFLAGS += -mabi=lp64
KBUILD_AFLAGS += -mabi=lp64
- KBUILD_LDFLAGS += -melf64lriscv
-
KBUILD_RUSTFLAGS += -Ctarget-cpu=generic-rv64 --target=riscv64imac-unknown-none-elf \
-Cno-redzone
else