shithub: riscv

Download patch

ref: 0653e52f4b861946eb99714413b26475646865de
parent: 856aeaf3333408c62b7627144e2bfd39fdf525d7
author: cinap_lenrek <cinap_lenrek@localhost>
date: Fri Apr 15 04:31:19 EDT 2011

add clear command to 9boot to reset configuration

--- a/sys/src/boot/pc/sub.c
+++ b/sys/src/boot/pc/sub.c
@@ -85,50 +85,6 @@
 	return p - (uchar*)data;
 }
 
-static ushort
-beswab(ushort s)
-{
-	uchar *p;
-
-	p = (uchar*)&s;
-	return (p[0]<<8) | p[1];
-}
-
-static ulong
-beswal(ulong l)
-{
-	uchar *p;
-
-	p = (uchar*)&l;
-	return (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3];
-}
-
-char*
-bootkern(void *f)
-{
-	uchar *e, *d;
-	Exec ex;
-	int n;
-
-	a20();
-	if(readn(f, &ex, sizeof(ex)) != sizeof(ex))
-		return "bad header";
-	if(beswal(ex.magic) != I_MAGIC)
-		return "bad magic";
-	e = (uchar*)(beswal(ex.entry) & ~0xF0000000UL);
-	n = beswal(ex.text);
-	if(readn(f, e, n) != n)
-		goto err;
-	d = (uchar*)(((ulong)e + n + 0xFFF) & ~0xFFFUL);
-	n = beswal(ex.data);
-	if(readn(f, d, n) != n)
-		goto err;
-	close(f);
-	jump(e);
-err:		
-	return "i/o error";
-}
-
 static int
 readline(void *f, char buf[64])
 {
@@ -169,6 +125,7 @@
 	char line[64], *p, *kern;
 	int inblock, n;
 
+Clear:
 	kern = 0;
 	inblock = 0;
 	p = (char*)((CONFADDR + 64) & ~0xF0000000UL);
@@ -180,6 +137,10 @@
 			inblock = memcmp("[common]", line, 8);
 			continue;
 		}
+		if(memcmp("clear", line, 6) == 0){
+			print("ok\r\n");
+			goto Clear;
+		}
 		if(memcmp("boot", line, 5) == 0)
 			break;
 		if(inblock || !strrchr(line, '='))
@@ -205,4 +166,49 @@
 	if(p = strrchr(kern, '!'))
 		kern = p+1;
 	return kern;
+}
+
+
+static ushort
+beswab(ushort s)
+{
+	uchar *p;
+
+	p = (uchar*)&s;
+	return (p[0]<<8) | p[1];
+}
+
+static ulong
+beswal(ulong l)
+{
+	uchar *p;
+
+	p = (uchar*)&l;
+	return (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3];
+}
+
+char*
+bootkern(void *f)
+{
+	uchar *e, *d;
+	Exec ex;
+	int n;
+
+	a20();
+	if(readn(f, &ex, sizeof(ex)) != sizeof(ex))
+		return "bad header";
+	if(beswal(ex.magic) != I_MAGIC)
+		return "bad magic";
+	e = (uchar*)(beswal(ex.entry) & ~0xF0000000UL);
+	n = beswal(ex.text);
+	if(readn(f, e, n) != n)
+		goto Error;
+	d = (uchar*)(((ulong)e + n + 0xFFF) & ~0xFFFUL);
+	n = beswal(ex.data);
+	if(readn(f, d, n) != n)
+		goto Error;
+	close(f);
+	jump(e);
+Error:		
+	return "i/o error";
 }