Browse Source

riscv: relocate some files that are architecture-dependent; fix mksys.go for riscv syscalls

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Ronald G. Minnich 8 years ago
parent
commit
a1b4e29f2a

+ 0 - 0
sys/src/klib.json → amd64/include/klib.json


+ 21 - 0
riscv/include/cflags.json

@@ -0,0 +1,21 @@
+{
+	"buildflags": {
+		"Cflags": [
+			"-ffreestanding",
+			"-fno-builtin",
+			"-fno-omit-frame-pointer",
+			"-fplan9-extensions",
+			"-fvar-tracking",
+			"-fvar-tracking-assignments",
+			"-g",
+			"-gdwarf-2",
+			"-ggdb",
+			"-O0",
+			"-static",
+			"-Wall",
+			"-Wno-missing-braces",
+			"-Wno-parentheses",
+			"-Wno-unknown-pragmas"
+		]
+	}
+}

+ 25 - 0
riscv/include/klib.json

@@ -0,0 +1,25 @@
+{
+	"KernelLibs": {
+		"Cflags": [
+			"-O0",
+			"-fplan9-extensions",
+			"-ffreestanding",
+			"-fno-builtin",
+			"-Wall",
+			"-Wno-missing-braces",
+			"-Wno-parentheses",
+			"-Wno-unknown-pragmas",
+			"-Wuninitialized",
+			"-g"
+		],
+		"Oflags": [
+			"-static"
+		],
+		"Post": [
+			"rm *.o"
+		],
+		"Pre": [
+			"rm -f *.o *.tag.*"
+		]
+	}
+}

+ 1 - 1
sys/src/libc/klibc.json

@@ -5,7 +5,7 @@
 			"-Werror"
 		],
 		"Include": [
-			"../klib.json"
+			"/$ARCH/include/klib.json"
 		],
 		"Install": "/$ARCH/lib/",
 		"Library": "klibc.a",

+ 1 - 1
sys/src/libdraw/klibdraw.json

@@ -1,7 +1,7 @@
 {
 	"KernelLibdraw": {
 		"Include": [
-			"../klib.json"
+			"/$ARCH/include/klib.json"
 		],
 		"Install": "/$ARCH/lib/",
 		"Library": "klibdraw.a",

+ 1 - 1
sys/src/libip/klibip.json

@@ -1,7 +1,7 @@
 {
 	"KernelLibip": {
 		"Include": [
-			"../klib.json"
+			"/$ARCH/include/klib.json"
 		],
 		"Install": "/$ARCH/lib/",
 		"Library": "klibip.a",

+ 1 - 1
sys/src/libmemdraw/klibmemdraw.json

@@ -1,7 +1,7 @@
 {
 	"KernelLibmemdraw": {
 		"Include": [
-			"../klib.json"
+			"/$ARCH/include/klib.json"
 		],
 		"Install": "/$ARCH/lib/",
 		"Library": "klibmemdraw.a",

+ 1 - 1
sys/src/libmemlayer/klibmemlayer.json

@@ -1,7 +1,7 @@
 {
 	"KernelLibmemlayer": {
 		"Include": [
-			"../klib.json"
+			"/$ARCH/include/klib.json"
 		],
 		"Install": "/$ARCH/lib/",
 		"Library": "klibmemlayer.a",

+ 1 - 1
sys/src/libsec/klibsec.json

@@ -1,7 +1,7 @@
 {
 	"Kernellibsec": {
 		"Include": [
-			"../klib.json"
+			"/$ARCH/include/klib.json"
 		],
 		"Install": "/$ARCH/lib/",
 		"Library": "klibsec.a",

+ 17 - 6
util/src/harvey/cmd/mksys/mksys.go

@@ -171,15 +171,12 @@ TEXT runtime·{{ .Libname }}(SB),NOSPLIT,$0
 		}
 
 	case "syscallfiles":
+		var tmpl *template.Template
+		var err error
 		a := os.Getenv("ARCH")
 		switch a {
 		case "amd64":
-		case "riscv":
-			usage("riscv support is incomplete")
-		default: 
-			usage(a + " is not supported.")
-		}
-		tmpl, err := template.New("syscall.s").Parse(`/* automatically generated by mksys */
+		tmpl, err = template.New("syscall.s").Parse(`/* automatically generated by mksys */
 .globl	{{ .Libname }}
 {{ .Libname }}:
 	movq %rcx, %r10 /* rcx gets smashed by systenter. Use r10.*/
@@ -190,6 +187,20 @@ TEXT runtime·{{ .Libname }}(SB),NOSPLIT,$0
 		if err != nil {
 			log.Fatal(err)
 		}
+		case "riscv":
+		tmpl, err = template.New("syscall.s").Parse(`/* automatically generated by mksys */
+.globl	{{ .Libname }}
+{{ .Libname }}:
+	/*movq ${{ .Id }},%rax  * Put the system call into rax, just like linux. */
+	scall
+	ret
+`)
+		if err != nil {
+			log.Fatal(err)
+		}
+		default: 
+			usage(a + " is not supported for system call generation.")
+		}
 
 		for i := range syscalls {