summaryrefslogtreecommitdiff
path: root/target
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2023-01-09 16:55:58 +0100
committerWaldemar Brodkorb <wbx@openadk.org>2023-01-19 03:47:13 +0100
commitcee21cdad9a4686842ccb54ef3b4485dcb4ab1f7 (patch)
tree0eebfd9ff4a95e9dd0d968f1c396206ba07a176a /target
parenta27d69db62e3f87affc00e5df02fd9cb678ae5a5 (diff)
riscv32: add basic nommu support
Diffstat (limited to 'target')
-rw-r--r--target/config/Config.in.binfmt3
-rw-r--r--target/config/Config.in.cpu3
-rw-r--r--target/config/Config.in.libc1
-rw-r--r--target/linux/patches/6.0.15/riscv32.patch49
-rw-r--r--target/riscv32/Makefile3
-rw-r--r--target/riscv32/kernel/qemu-riscv3222
6 files changed, 65 insertions, 16 deletions
diff --git a/target/config/Config.in.binfmt b/target/config/Config.in.binfmt
index 0986c6f23..7da792992 100644
--- a/target/config/Config.in.binfmt
+++ b/target/config/Config.in.binfmt
@@ -16,7 +16,8 @@ config ADK_TARGET_BINFMT_FLAT
depends on ADK_TARGET_LIB_UCLIBC_NG
depends on !ADK_TARGET_WITH_MMU
depends on ADK_TARGET_ARCH_ARM || ADK_TARGET_ARCH_M68K || ADK_TARGET_ARCH_SH || ADK_TARGET_ARCH_XTENSA \
- || ADK_TARGET_ARCH_H8300 || ADK_TARGET_ARCH_LM32 || ADK_TARGET_ARCH_BFIN || ADK_TARGET_ARCH_RISCV64
+ || ADK_TARGET_ARCH_H8300 || ADK_TARGET_ARCH_LM32 || ADK_TARGET_ARCH_BFIN || ADK_TARGET_ARCH_RISCV64 \
+ || ADK_TARGET_ARCH_RISCV32
config ADK_TARGET_BINFMT_FDPIC
bool "FDPIC"
diff --git a/target/config/Config.in.cpu b/target/config/Config.in.cpu
index 56befd8ef..eaf0eea02 100644
--- a/target/config/Config.in.cpu
+++ b/target/config/Config.in.cpu
@@ -1146,7 +1146,6 @@ config ADK_TARGET_CPU_RISCV32_RV32IMAC
bool "rv32imac"
select ADK_TARGET_SUPPORTS_THREADS
select ADK_TARGET_SUPPORTS_NPTL
- select ADK_TARGET_WITH_MMU
select ADK_TARGET_ABI_ILP32
depends on ADK_TARGET_ARCH_RISCV32
@@ -1154,7 +1153,6 @@ config ADK_TARGET_CPU_RISCV32_RV32IMAFC
bool "rv32imafc"
select ADK_TARGET_SUPPORTS_THREADS
select ADK_TARGET_SUPPORTS_NPTL
- select ADK_TARGET_WITH_MMU
select ADK_TARGET_ABI_ILP32F
depends on ADK_TARGET_ARCH_RISCV32
@@ -1162,7 +1160,6 @@ config ADK_TARGET_CPU_RISCV32_RV32IMADC
bool "rv32imadc"
select ADK_TARGET_SUPPORTS_THREADS
select ADK_TARGET_SUPPORTS_NPTL
- select ADK_TARGET_WITH_MMU
select ADK_TARGET_ABI_ILP32D
depends on ADK_TARGET_ARCH_RISCV32
diff --git a/target/config/Config.in.libc b/target/config/Config.in.libc
index 477dcd10a..5a75cdb1c 100644
--- a/target/config/Config.in.libc
+++ b/target/config/Config.in.libc
@@ -34,6 +34,7 @@ config ADK_TARGET_LIB_UCLIBC_NG
ADK_TARGET_ARCH_NIOS2 || \
ADK_TARGET_ARCH_OR1K || \
ADK_TARGET_ARCH_PPC || \
+ ADK_TARGET_ARCH_RISCV32 || \
ADK_TARGET_ARCH_RISCV64 || \
ADK_TARGET_ARCH_SH || \
ADK_TARGET_ARCH_SPARC || \
diff --git a/target/linux/patches/6.0.15/riscv32.patch b/target/linux/patches/6.0.15/riscv32.patch
new file mode 100644
index 000000000..648b0de4d
--- /dev/null
+++ b/target/linux/patches/6.0.15/riscv32.patch
@@ -0,0 +1,49 @@
+diff -Nur linux-6.0.15.orig/arch/riscv/include/uapi/asm/unistd.h linux-6.0.15/arch/riscv/include/uapi/asm/unistd.h
+--- linux-6.0.15.orig/arch/riscv/include/uapi/asm/unistd.h 2022-12-21 17:41:16.000000000 +0100
++++ linux-6.0.15/arch/riscv/include/uapi/asm/unistd.h 2023-01-09 11:28:16.590796198 +0100
+@@ -15,9 +15,14 @@
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+-#if defined(__LP64__) && !defined(__SYSCALL_COMPAT)
++#ifndef __SYSCALL_COMPAT
+ #define __ARCH_WANT_NEW_STAT
+ #define __ARCH_WANT_SET_GET_RLIMIT
++#endif /* __SYSCALL_COMPAT */
++
++#ifndef __LP64__
++#define __ARCH_WANT_STAT64
++#define __ARCH_WANT_TIME32_SYSCALLS
+ #endif /* __LP64__ */
+
+ #define __ARCH_WANT_SYS_CLONE3
+diff -Nur linux-6.0.15.orig/arch/riscv/Kconfig linux-6.0.15/arch/riscv/Kconfig
+--- linux-6.0.15.orig/arch/riscv/Kconfig 2022-12-21 17:41:16.000000000 +0100
++++ linux-6.0.15/arch/riscv/Kconfig 2023-01-09 14:27:16.560750598 +0100
+@@ -163,8 +163,9 @@
+
+ config PAGE_OFFSET
+ hex
+- default 0xC0000000 if 32BIT
++ default 0xC0000000 if 32BIT && MMU
+ default 0x80000000 if 64BIT && !MMU
++ default 0x80000000 if !MMU
+ default 0xff60000000000000 if 64BIT
+
+ config KASAN_SHADOW_OFFSET
+@@ -262,7 +263,6 @@
+ select GENERIC_LIB_ASHRDI3
+ select GENERIC_LIB_LSHRDI3
+ select GENERIC_LIB_UCMPDI2
+- select MMU
+
+ config ARCH_RV64I
+ bool "RV64I"
+@@ -670,7 +670,6 @@
+ default !NONPORTABLE
+ select EFI
+ select OF
+- select MMU
+
+ menu "Power management options"
+
diff --git a/target/riscv32/Makefile b/target/riscv32/Makefile
index 577ef3f15..08d4d57ba 100644
--- a/target/riscv32/Makefile
+++ b/target/riscv32/Makefile
@@ -7,6 +7,9 @@ include $(ADK_TOPDIR)/mk/image.mk
KERNEL:=$(LINUX_DIR)/arch/riscv/boot/Image
QEMU_ARGS:=-M virt -m 512 -nographic
+ifeq ($(ADK_TARGET_LIB_UCLIBC_NG),y)
+QEMU_ARGS+=-bios none
+endif
ifeq ($(ADK_TARGET_QEMU_WITH_VIRTIO),y)
QEMU_ARGS+=-netdev user,id=eth0 -device virtio-net-device,netdev=eth0
endif
diff --git a/target/riscv32/kernel/qemu-riscv32 b/target/riscv32/kernel/qemu-riscv32
index a1ef83228..8fa8b13ac 100644
--- a/target/riscv32/kernel/qemu-riscv32
+++ b/target/riscv32/kernel/qemu-riscv32
@@ -1,14 +1,12 @@
CONFIG_RISCV=y
-CONFIG_ARCH_RV32I=y
-CONFIG_CMODEL_MEDANY=y
-CONFIG_CPU_RV_GENERIC=y
-CONFIG_RV_SYSRISCV_ATOMIC=y
-CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
CONFIG_32BIT=y
-CONFIG_HVC_DRIVER=y
-CONFIG_HVC_RISCV_SBI=y
-CONFIG_SERIAL_EARLYCON_RISCV_SBI=y
-CONFIG_CMDLINE_BOOL=y
-CONFIG_SOC_SIFIVE=y
-CONFIG_SERIAL_SIFIVE=y
-CONFIG_SERIAL_SIFIVE_CONSOLE=y
+CONFIG_COMPAT_32BIT_TIME=y
+CONFIG_ARCH_RV32I=y
+CONFIG_SOC_VIRT=y
+CONFIG_NONPORTABLE=y
+CONFIG_VIRTIO_BLK=y
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_OF_PLATFORM=y
+CONFIG_VIRTIO_MMIO=y
+CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y