shithub: riscv

Download patch

ref: 2099e63a2fc4a1f7c5167ffbfe6d9d27cd5656d1
parent: fc968ae333c3e34f3b3b4cc36a3b856f0078ed16
author: moody <moody@sakuya>
date: Sat May 24 16:06:22 EDT 2025

libmach: work with kernel binary for our riscv64 qemu kernel

--- a/sys/src/libmach/executable.c
+++ b/sys/src/libmach/executable.c
@@ -245,7 +245,7 @@
 		sizeof(Exec)+8,
 		nil,
 		commonllp64 },
-	{ B_MAGIC,
+	{ B_MAGIC,			/* RISCV64 j.out & boot image */
 		"riscv64 plan 9 executable",
 		"riscv64 plan 9 dlm",
 		FRISCV64,
@@ -405,6 +405,12 @@
 		fp->txtaddr = fp->entry;
 		fp->name = "power64 plan 9 boot image";
 		fp->dataddr = fp->txtaddr+fp->txtsz;
+		break;
+	case FRISCV64:
+		fp->type = FRISCV64B;
+		fp->txtaddr = fp->entry;
+		fp->name = "riscv64 plan 9 boot image";
+		fp->dataddr = _round(fp->txtaddr+fp->txtsz, mach->pgsize);
 		break;
 	default:
 		return;
--- a/sys/src/libmach/j.c
+++ b/sys/src/libmach/j.c
@@ -103,9 +103,9 @@
 	0,		/* static base register value */
 	0x1000,		/* page size */
 	/* these are Sv39 values */
-	0xffffffc000000000ULL,	/* kernel base */
-	0xffffffc000000000ULL,	/* kernel text mask for Sv39 and above */
-	0x0000003fffffffffULL,	/* user stack top */
+	0xffffffffc0000000,	/* kernel base */
+	0xfffffffff0000000,	/* kernel text mask for Sv39 and above */
+	0x0000003fffffffff,	/* user stack top */
 	2,		/* quantization of pc */
 	8,		/* szaddr */
 	8,		/* szreg */
--