mirror of
https://github.com/thead-yocto-mirror/meta-riscv
synced 2026-09-07 09:14:51 +02:00
musl: Add risc-v port
This will be merged soon, but lets try it out from fork and ensure all testing is done for upstreaming Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,51 @@
|
||||
From d471b10ce2abe4f3dfec6d24ad0f8ef1fe1070b3 Mon Sep 17 00:00:00 2001
|
||||
From: Drew DeVault <sir@cmpwn.com>
|
||||
Date: Sun, 16 Dec 2018 10:55:09 -0500
|
||||
Subject: [PATCH 2/5] RISC-V: Add cache flush syscall
|
||||
|
||||
---
|
||||
arch/riscv32/bits/syscall.h.in | 1 +
|
||||
arch/riscv64/bits/syscall.h.in | 1 +
|
||||
src/linux/cache.c | 9 +++++++++
|
||||
3 files changed, 11 insertions(+)
|
||||
|
||||
diff --git a/arch/riscv32/bits/syscall.h.in b/arch/riscv32/bits/syscall.h.in
|
||||
index 3c81c107..11393c29 100644
|
||||
--- a/arch/riscv32/bits/syscall.h.in
|
||||
+++ b/arch/riscv32/bits/syscall.h.in
|
||||
@@ -275,4 +275,5 @@
|
||||
#define __NR_pkey_alloc 289
|
||||
#define __NR_pkey_free 290
|
||||
#define __NR_sysriscv __NR_arch_specific_syscall
|
||||
+#define __NR_riscv_flush_icache (__NR_sysriscv + 15)
|
||||
|
||||
diff --git a/arch/riscv64/bits/syscall.h.in b/arch/riscv64/bits/syscall.h.in
|
||||
index 3c81c107..11393c29 100644
|
||||
--- a/arch/riscv64/bits/syscall.h.in
|
||||
+++ b/arch/riscv64/bits/syscall.h.in
|
||||
@@ -275,4 +275,5 @@
|
||||
#define __NR_pkey_alloc 289
|
||||
#define __NR_pkey_free 290
|
||||
#define __NR_sysriscv __NR_arch_specific_syscall
|
||||
+#define __NR_riscv_flush_icache (__NR_sysriscv + 15)
|
||||
|
||||
diff --git a/src/linux/cache.c b/src/linux/cache.c
|
||||
index 84a138a4..4ce919cf 100644
|
||||
--- a/src/linux/cache.c
|
||||
+++ b/src/linux/cache.c
|
||||
@@ -15,3 +15,12 @@ int __cachectl(void *addr, int len, int op)
|
||||
}
|
||||
weak_alias(__cachectl, cachectl);
|
||||
#endif
|
||||
+
|
||||
+#ifdef SYS_riscv_flush_icache
|
||||
+int __riscv_flush_icache(void *start, void *end, unsigned long int flags)
|
||||
+{
|
||||
+ // TODO: Use vdso
|
||||
+ return syscall(SYS_riscv_flush_icache, start, end, flags);
|
||||
+}
|
||||
+weak_alias(__riscv_flush_icache, riscv_flush_icache);
|
||||
+#endif
|
||||
--
|
||||
2.20.1
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
From e257365645012bc47a4273eeb2224451b656a3ad Mon Sep 17 00:00:00 2001
|
||||
From: Drew DeVault <sir@cmpwn.com>
|
||||
Date: Fri, 14 Dec 2018 20:32:12 -0500
|
||||
Subject: [PATCH 3/5] RISC-V: Fix syscall_cp on riscv64/32
|
||||
|
||||
Thanks to Rich Felker for pointing out this error on the musl list. In
|
||||
addition to fixing the labels, this loads the cancel flag with lw
|
||||
instead of ld.
|
||||
---
|
||||
src/thread/riscv32/syscall_cp.s | 4 ++--
|
||||
src/thread/riscv64/syscall_cp.s | 6 +++---
|
||||
2 files changed, 5 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/src/thread/riscv32/syscall_cp.s b/src/thread/riscv32/syscall_cp.s
|
||||
index 71bf6d3e..9c450402 100644
|
||||
--- a/src/thread/riscv32/syscall_cp.s
|
||||
+++ b/src/thread/riscv32/syscall_cp.s
|
||||
@@ -23,7 +23,7 @@ __cp_begin:
|
||||
lw a6, 0(sp)
|
||||
mv a7, t0
|
||||
scall
|
||||
-__cp_cancel:
|
||||
- ret
|
||||
__cp_end:
|
||||
+ ret
|
||||
+__cp_cancel:
|
||||
j __cancel
|
||||
diff --git a/src/thread/riscv64/syscall_cp.s b/src/thread/riscv64/syscall_cp.s
|
||||
index c745b328..65cf722f 100644
|
||||
--- a/src/thread/riscv64/syscall_cp.s
|
||||
+++ b/src/thread/riscv64/syscall_cp.s
|
||||
@@ -10,7 +10,7 @@
|
||||
.type __syscall_cp_asm, %function
|
||||
__syscall_cp_asm:
|
||||
__cp_begin:
|
||||
- ld t0, 0(a0)
|
||||
+ lw t0, 0(a0)
|
||||
bnez t0, __cp_cancel
|
||||
|
||||
mv t0, a1
|
||||
@@ -23,7 +23,7 @@ __cp_begin:
|
||||
ld a6, 0(sp)
|
||||
mv a7, t0
|
||||
scall
|
||||
-__cp_cancel:
|
||||
- ret
|
||||
__cp_end:
|
||||
+ ret
|
||||
+__cp_cancel:
|
||||
j __cancel
|
||||
--
|
||||
2.20.1
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
From fc003fe211ae03e911c0a4d1f823788bbbce1900 Mon Sep 17 00:00:00 2001
|
||||
From: Nick Kossifidis <mickflemm@gmail.com>
|
||||
Date: Mon, 29 Oct 2018 12:36:18 +0200
|
||||
Subject: [PATCH 4/5] Use the generic fcntl.h header Currently the fcntl.h
|
||||
|
||||
header uses different macros from those on upstream Linux. On upstream Linux there is no arch-specific fcntl.h, the generic one is used. As a result various syscalls using these macros fail, an example being BusyBox where any call to opendir() will fail because O_DIRECTORY id is different between the headers used here (probably coming from arm64) and the generic headers used by the kernel. Simple delete the arch-specific fcntl.h and let musl use the generic header as well.
|
||||
---
|
||||
arch/riscv32/bits/fcntl.h | 38 --------------------------------------
|
||||
arch/riscv64/bits/fcntl.h | 38 --------------------------------------
|
||||
2 files changed, 76 deletions(-)
|
||||
delete mode 100644 arch/riscv32/bits/fcntl.h
|
||||
delete mode 100644 arch/riscv64/bits/fcntl.h
|
||||
|
||||
diff --git a/arch/riscv32/bits/fcntl.h b/arch/riscv32/bits/fcntl.h
|
||||
deleted file mode 100644
|
||||
index 92787976..00000000
|
||||
--- a/arch/riscv32/bits/fcntl.h
|
||||
+++ /dev/null
|
||||
@@ -1,38 +0,0 @@
|
||||
-#define O_CREAT 0100
|
||||
-#define O_EXCL 0200
|
||||
-#define O_NOCTTY 0400
|
||||
-#define O_TRUNC 01000
|
||||
-#define O_APPEND 02000
|
||||
-#define O_NONBLOCK 04000
|
||||
-#define O_DSYNC 010000
|
||||
-#define O_SYNC 04010000
|
||||
-#define O_RSYNC 04010000
|
||||
-#define O_DIRECTORY 040000
|
||||
-#define O_NOFOLLOW 0100000
|
||||
-#define O_CLOEXEC 02000000
|
||||
-
|
||||
-#define O_ASYNC 020000
|
||||
-#define O_DIRECT 0200000
|
||||
-#define O_LARGEFILE 0400000
|
||||
-#define O_NOATIME 01000000
|
||||
-#define O_PATH 010000000
|
||||
-#define O_TMPFILE 020040000
|
||||
-#define O_NDELAY O_NONBLOCK
|
||||
-
|
||||
-#define F_DUPFD 0
|
||||
-#define F_GETFD 1
|
||||
-#define F_SETFD 2
|
||||
-#define F_GETFL 3
|
||||
-#define F_SETFL 4
|
||||
-#define F_GETLK 5
|
||||
-#define F_SETLK 6
|
||||
-#define F_SETLKW 7
|
||||
-#define F_SETOWN 8
|
||||
-#define F_GETOWN 9
|
||||
-#define F_SETSIG 10
|
||||
-#define F_GETSIG 11
|
||||
-
|
||||
-#define F_SETOWN_EX 15
|
||||
-#define F_GETOWN_EX 16
|
||||
-
|
||||
-#define F_GETOWNER_UIDS 17
|
||||
diff --git a/arch/riscv64/bits/fcntl.h b/arch/riscv64/bits/fcntl.h
|
||||
deleted file mode 100644
|
||||
index 92787976..00000000
|
||||
--- a/arch/riscv64/bits/fcntl.h
|
||||
+++ /dev/null
|
||||
@@ -1,38 +0,0 @@
|
||||
-#define O_CREAT 0100
|
||||
-#define O_EXCL 0200
|
||||
-#define O_NOCTTY 0400
|
||||
-#define O_TRUNC 01000
|
||||
-#define O_APPEND 02000
|
||||
-#define O_NONBLOCK 04000
|
||||
-#define O_DSYNC 010000
|
||||
-#define O_SYNC 04010000
|
||||
-#define O_RSYNC 04010000
|
||||
-#define O_DIRECTORY 040000
|
||||
-#define O_NOFOLLOW 0100000
|
||||
-#define O_CLOEXEC 02000000
|
||||
-
|
||||
-#define O_ASYNC 020000
|
||||
-#define O_DIRECT 0200000
|
||||
-#define O_LARGEFILE 0400000
|
||||
-#define O_NOATIME 01000000
|
||||
-#define O_PATH 010000000
|
||||
-#define O_TMPFILE 020040000
|
||||
-#define O_NDELAY O_NONBLOCK
|
||||
-
|
||||
-#define F_DUPFD 0
|
||||
-#define F_GETFD 1
|
||||
-#define F_SETFD 2
|
||||
-#define F_GETFL 3
|
||||
-#define F_SETFL 4
|
||||
-#define F_GETLK 5
|
||||
-#define F_SETLK 6
|
||||
-#define F_SETLKW 7
|
||||
-#define F_SETOWN 8
|
||||
-#define F_GETOWN 9
|
||||
-#define F_SETSIG 10
|
||||
-#define F_GETSIG 11
|
||||
-
|
||||
-#define F_SETOWN_EX 15
|
||||
-#define F_GETOWN_EX 16
|
||||
-
|
||||
-#define F_GETOWNER_UIDS 17
|
||||
--
|
||||
2.20.1
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
From 6731272acf55de3bb82d186c0c7690211feb064a Mon Sep 17 00:00:00 2001
|
||||
From: Nick Kossifidis <mickflemm@gmail.com>
|
||||
Date: Sun, 4 Nov 2018 20:38:48 +0200
|
||||
Subject: [PATCH 5/5] Fix missing macros from fcntl.h
|
||||
|
||||
This fixes file locking, tested with busybox
|
||||
---
|
||||
arch/generic/bits/fcntl.h | 10 ++++++----
|
||||
include/fcntl.h | 2 ++
|
||||
2 files changed, 8 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/arch/generic/bits/fcntl.h b/arch/generic/bits/fcntl.h
|
||||
index ae233cc0..d9e779a6 100644
|
||||
--- a/arch/generic/bits/fcntl.h
|
||||
+++ b/arch/generic/bits/fcntl.h
|
||||
@@ -24,15 +24,17 @@
|
||||
#define F_SETFD 2
|
||||
#define F_GETFL 3
|
||||
#define F_SETFL 4
|
||||
-
|
||||
+#define F_GETLK 5
|
||||
+#define F_SETLK 6
|
||||
+#define F_SETLKW 7
|
||||
#define F_SETOWN 8
|
||||
#define F_GETOWN 9
|
||||
#define F_SETSIG 10
|
||||
#define F_GETSIG 11
|
||||
|
||||
-#define F_GETLK 12
|
||||
-#define F_SETLK 13
|
||||
-#define F_SETLKW 14
|
||||
+#define F_GETLK64 12
|
||||
+#define F_SETLK64 13
|
||||
+#define F_SETLKW64 14
|
||||
|
||||
#define F_SETOWN_EX 15
|
||||
#define F_GETOWN_EX 16
|
||||
diff --git a/include/fcntl.h b/include/fcntl.h
|
||||
index 4d91338b..c34de91f 100644
|
||||
--- a/include/fcntl.h
|
||||
+++ b/include/fcntl.h
|
||||
@@ -187,9 +187,11 @@ ssize_t tee(int, int, size_t, unsigned);
|
||||
#endif
|
||||
|
||||
#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
|
||||
+#ifndef F_GETLK64
|
||||
#define F_GETLK64 F_GETLK
|
||||
#define F_SETLK64 F_SETLK
|
||||
#define F_SETLKW64 F_SETLKW
|
||||
+#endif
|
||||
#define flock64 flock
|
||||
#define open64 open
|
||||
#define openat64 openat
|
||||
--
|
||||
2.20.1
|
||||
|
||||
12
recipes-core/musl/musl_%.bbappend
Normal file
12
recipes-core/musl/musl_%.bbappend
Normal file
@@ -0,0 +1,12 @@
|
||||
# Copyright (C) 2019 Khem Raj <raj.khem@gmail.com>
|
||||
# Released under the MIT license (see COPYING.MIT for the terms)
|
||||
|
||||
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
|
||||
|
||||
SRC_URI += "\
|
||||
file://0001-RISC-V-add-riscv32-and-riscv64-architecture-support.patch \
|
||||
file://0002-RISC-V-Add-cache-flush-syscall.patch \
|
||||
file://0003-RISC-V-Fix-syscall_cp-on-riscv64-32.patch \
|
||||
file://0004-Use-the-generic-fcntl.h-header-Currently-the-fcntl.h.patch \
|
||||
file://0005-Fix-missing-macros-from-fcntl.h.patch \
|
||||
"
|
||||
Reference in New Issue
Block a user