Browse Source

riscv: pull over riscv include files and build changes

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

+ 5 - 0
riscv/include/cflags.json

@@ -1,6 +1,7 @@
 {
 	"buildflags": {
 		"Cflags": [
+			"-mcmodel=medany",
 			"-ffreestanding",
 			"-fno-builtin",
 			"-fno-omit-frame-pointer",
@@ -13,6 +14,10 @@
 			"-Wno-missing-braces",
 			"-Wno-parentheses",
 			"-Wno-unknown-pragmas"
+		],
+		"Oflags": [
+			"-T","/$ARCH/include/prog.ld",
+			"--no-relax"
 		]
 	}
 }

+ 2 - 1
riscv/include/klib.json

@@ -12,7 +12,8 @@
 			"-g"
 		],
 		"Oflags": [
-			"-static"
+			"-static",
+			"--no-relax"
 		],
 		"Post": [
 			"rm *.o"

+ 36 - 0
riscv/include/prog.ld

@@ -0,0 +1,36 @@
+OUTPUT_ARCH("riscv")
+ENTRY(main)
+
+SECTIONS
+{
+	. = 0x200000;
+	.text : {
+		*(.text .stub .text.* .gnu.linkonce.t.*)
+	}
+	PROVIDE(etext = .);	/* Define the 'etext' symbol to this value */
+
+	.rodata : {
+		*(.rodata .rodata.* .gnu.linkonce.r.*)
+	}
+
+	/* Adjust the address for the data segment to the next page */
+	. = ALIGN(0x200000);
+
+	/* The data segment */
+	.data : {
+		*(.data)
+	}
+
+	PROVIDE(edata = .);
+
+
+	.bss : {
+		*(.bss)
+		*(COMMON)
+	}
+
+	PROVIDE(end = .);
+	/DISCARD/ : {
+		*(.eh_frame .note.GNU-stack)
+	}
+}

+ 6 - 4
riscv/include/ureg.h

@@ -9,7 +9,6 @@
 
 struct Ureg {
 	uintptr_t ip;
-	uintptr_t ra;
 	uintptr_t sp;
 	uintptr_t gp;
 	uintptr_t tp;
@@ -41,9 +40,12 @@ struct Ureg {
 	uintptr_t t5;
 	uintptr_t t6;
 	/* Supervisor CSRs */
-	uintptr_t sstatus;
-	uintptr_t sbadaddr;
-	uintptr_t scause;
+	uintptr_t status;
+	uintptr_t epc;
+	uintptr_t badaddr;
+	uintptr_t cause;
+	uintptr_t insnn;
 	uintptr_t bp; // BOGUS: need a real frame pointer here. 
+	uintptr_t ftype;
 };
 

+ 3 - 0
util/src/harvey/cmd/build/build.go

@@ -89,6 +89,9 @@ func (bf *buildfile) UnmarshalJSON(s []byte) error {
 		b.Projects = adjust(b.Projects)
 		b.Libs = adjust(b.Libs)
 		b.Cflags = adjust(b.Cflags)
+		b.Oflags = adjust(b.Oflags)
+		b.SourceFiles = adjust(b.SourceFiles)
+		b.SourceFilesCmd = adjust(b.SourceFilesCmd)
 		b.ObjectFiles = adjust(b.ObjectFiles)
 		b.Include = adjust(b.Include)
 		b.Install = fromRoot(b.Install)