Browse Source

riscv: implement setlabel/gotolabel

The riscv docs are still very inconsistent on register naming,
so we guessed.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Ronald G. Minnich 7 years ago
parent
commit
e4cf13e5e8
3 changed files with 28 additions and 71 deletions
  1. 2 69
      sys/src/9/port/riscvport.json
  2. 24 0
      sys/src/9/riscv/asm.S
  3. 2 2
      sys/src/9/riscv/dat.h

+ 2 - 69
sys/src/9/port/riscvport.json

@@ -15,7 +15,6 @@
 			"../port/cache.c",
 			"../port/chan.c",
 			"../port/cpu_buffer.c",
-			"../port/dev.c",
 			"../port/devcap.c",
 			"../port/devcons.c",
 			"../port/devcoreboot.c",
@@ -80,72 +79,6 @@
 			"../port/watermarks.c"
 		],
 		"SourceFiles": [
-			"../port/alarm.c",
-			"../port/allocb.c",
-			"../port/cache.c",
-			"../port/chan.c",
-			"../port/cpu_buffer.c",
-			"../port/dev.c",
-			"../port/devcap.c",
-			"../port/devcons.c",
-			"../port/devcoreboot.c",
-			"../port/devdup.c",
-			"../port/devenv.c",
-			"../port/devfdmux.c",
-			"../port/devkprof.c",
-			"../port/devkbin.c",
-			"../port/devmnt.c",
-			"../port/devmntn.c",
-			"../port/devpipe.c",
-			"../port/devproc.c",
-			"../port/devramfs.c",
-			"../port/devregress.c",
-			"../port/devroot.c",
-			"../port/devsd.c",
-			"../port/devsegment.c",
-			"../port/devsrv.c",
-			"../port/devssl.c",
-			"../port/devtls.c",
-			"../port/devtab.c",
-			"../port/devtrace.c",
-			"../port/devuart.c",
-			"../port/devwd.c",
-			"../port/devws.c",
-			"../port/edf.c",
-			"../port/elf64.c",
-			"../port/ethermii.c",
-			"../port/fault.c",
-			"../port/fortuna.c",
-			"../port/getput.c",
-			"../port/hexdump.c",
-			"../port/image.c",
-			"../port/kdebug.c",
-		        "../port/ipchecksum.c",
-			"../port/mul64fract.c",
-			"../port/netif.c",
-			"../port/page.c",
-			"../port/pager.c",
-			"../port/parse.c",
-			"../port/pgrp.c",
-			"../port/portclock.c",
-			"../port/print.c",
-			"../port/proc.c",
-			"../port/ps.c",
-			"../port/qio.c",
-			"../port/qlock.c",
-			"../port/random.c",
-			"../port/rebootcmd.c",
-			"../port/rmap.c",
-			"../port/sdscsi.c",
-			"../port/segment.c",
-			"../port/sysauth.c",
-			"../port/syscallfmt.c",
-			"../port/sysfile.c",
-			"../port/sysproc.c",
-			"../port/sysseg.c",
-			"../port/taslock.c",
-			"../port/tod.c",
-			"../port/watermarks.c"
-		]
-	}
+			"../port/qio.c"
+		] }
 }

+ 24 - 0
sys/src/9/riscv/asm.S

@@ -10,3 +10,27 @@ startmach:
 machp:
 	csrr	a0,sscratch
 	ret
+
+/*
+ * Label consists of a stack pointer and a programme counter
+ * 0(%rdi) is the SP, 8(%rdi) is the PC
+ */
+.global gotolabel
+gotolabel:
+	LD	sp,0(a0)
+	LD	x2,16(a0)
+	LD	a0,8(a0)
+	MV	ra,a0
+	RET
+
+	/* save all registers on this stack, the save stack
+	* in the label struct.
+	*/
+.global slim_setlabel
+slim_setlabel:
+	SD	sp,0(a0)
+	SD	ra,8(a0)
+	SD	x2,16(a0)
+	RET
+
+	

+ 2 - 2
sys/src/9/riscv/dat.h

@@ -78,10 +78,10 @@ struct Lock
 
 struct Label
 {
+	/* order known to assembly */
 	uintptr_t	sp;
 	uintptr_t	pc;
-	// TODO: how many?
-	uintptr_t	regs[64];
+	uintptr_t       fp;
 };
 
 struct Fxsave {