shithub: riscv

Download patch

ref: c612f9c41fd876c181f89472861245404cef65c5
parent: c03913c62ddb751d2992e8a3d70e945229ed8e15
author: aiju <[email protected]>
date: Fri Jul 13 14:52:39 EDT 2012

multiboot: use initrd for config

--- a/sys/src/9/pc/l.s
+++ b/sys/src/9/pc/l.s
@@ -52,6 +52,10 @@
 	LONG	$0				/* height */
 	LONG	$0				/* depth */
 
+/* 
+ * the kernel expects the data segment to be page-aligned
+ * multiboot bootloaders put the data segment right behind text
+ */
 TEXT _multibootentry(SB), $0
 	MOVL	$etext-KZERO(SB), SI
 	MOVL	SI, DI
@@ -64,9 +68,15 @@
 	STD
 	REP; MOVSB
 	CLD
+	ADDL	$KZERO, BX
+	MOVL	BX, multiboot-KZERO(SB)
 	MOVL	$_startPADDR(SB), AX
 	ANDL	$~KZERO, AX
 	JMP*	AX
+
+/* multiboot structure pointer */
+TEXT multiboot(SB), $0
+	LONG	$0
 
 /*
  * In protected mode with paging turned off and segment registers setup
--- a/sys/src/9/pc/main.c
+++ b/sys/src/9/pc/main.c
@@ -37,6 +37,22 @@
 {
 	long i, n;
 	char *cp, *line[MAXCONF], *p, *q;
+	ulong *m, l;
+	extern ulong *multiboot;
+
+	if(multiboot != nil){
+		cp = BOOTARGS;
+		*cp = 0;
+		if((*multiboot & 8) != 0 && multiboot[5] > 0){
+			m = KADDR(multiboot[6]);
+			l = m[1] - m[0];
+			m = KADDR(m[0]);
+			if(l >= BOOTARGSLEN)
+				l = BOOTARGSLEN - 1;
+			memmove(cp, m, l);
+			cp[l] = 0;
+		}
+	}
 
 	/*
 	 *  parse configuration args from dos file plan9.ini