Browse Source

boot now adds kernel parameters to environment.

Updated script to default to tcp boot
maxcores and numtcs are now command line parameters.

Change-Id: Ib929a6311cb40e57fe1d75d5ce7099a479d1cc6d
Signed-off-by: Keith Poole <keith.poole@gmail.com>
Keith Poole 8 years ago
parent
commit
33fd099f6a
3 changed files with 42 additions and 20 deletions
  1. 0 1
      sys/src/9/boot/aux.c
  2. 41 19
      sys/src/9/k10/main.c
  3. 1 0
      util/GO9PRUN

+ 0 - 1
sys/src/9/boot/aux.c

@@ -100,7 +100,6 @@ readfile(char *name, char *buf, int len)
 	if(n >= 0)
 		buf[n] = 0;
 	close(f);
-	print("readfile: success reading %s\n", name);
 	return 0;
 }
 

+ 41 - 19
sys/src/9/k10/main.c

@@ -111,7 +111,9 @@ static void
 options(int argc, char* argv[])
 {
 	char *p;
+	char *env[2];
 	int n, o;
+	char envcopy[256];
 
 	/*
 	 * Process flags.
@@ -120,32 +122,51 @@ options(int argc, char* argv[])
 	 * (no space between flag and level).
 	 * '--' ends flag processing.
 	 */
-	while(--argc > 0 && (*++argv)[0] == '-' && (*argv)[1] != '-'){
-		while(o = *++argv[0]){
-			if(!(o >= 'A' && o <= 'Z') && !(o >= 'a' && o <= 'z'))
-				continue;
-			n = strtol(argv[0]+1, &p, 0);
-			if(p == argv[0]+1 || n < 1 || n > 127)
-				n = 1;
-			argv[0] = p-1;
-			dbgflg[o] = n;
+	while(--argc > 0){
+		char* next = *++argv;
+		if(next[0] =='-' && next[1] != '-'){
+			while(o = *++argv[0]){
+				if(!(o >= 'A' && o <= 'Z') && !(o >= 'a' && o <= 'z'))
+					continue;
+				n = strtol(argv[0]+1, &p, 0);
+				if(p == argv[0]+1 || n < 1 || n > 127)
+					n = 1;
+				argv[0] = p-1;
+				dbgflg[o] = n;
+			}
+		}else{
+			strncpy(envcopy, next, sizeof envcopy);
+			gettokens(envcopy, env, 2, "=");
+			if(strcmp(env[0], "maxcores") == 0){
+				maxcores = strtol(env[1], 0, 0);
+			}
+			if(strcmp(env[0], "numtcs") == 0){
+				numtcs = strtol(env[1], 0, 0);
+			}
 		}
 	}
 	vflag = dbgflg['v'];
-	if(argc > 0){
-		maxcores = strtol(argv[0], 0, 0);
-		argc--;
-		argv++;
-	}
-	if(argc > 0){
-		numtcs = strtol(argv[0], 0, 0);
-		//argc--;
-		//argv++;
-	}
 	// hack.
 	nosmp = dbgflg['n'];
 }
 
+void
+loadenv(int argc, char* argv[])
+{
+	char *env[2];
+
+	/*
+	 * Process command line env options
+	 */
+	while(--argc > 0){
+		char* next = *++argv;
+		if(next[0] !='-'){
+			gettokens(next, env, 2, "=");
+			ksetenv(env[0], env[1], 0);
+		}
+	}
+}
+
 void
 squidboy(int apicno, Mach *mach)
 {
@@ -654,6 +675,7 @@ init0(void)
 
 	if(!waserror()){
 		snprint(buf, sizeof(buf), "%s %s", "AMD64", conffile);
+		loadenv(oargc, oargv);
 		ksetenv("terminal", buf, 0);
 		ksetenv("cputype", cputype, 0);
 		if(cpuserver)

+ 1 - 0
util/GO9PRUN

@@ -10,6 +10,7 @@ sudo qemu-system-x86_64 -s -cpu Opteron_G1 -smp 1 -m 2048  \
 --machine pc \
 -net nic,model=rtl8139 \
 -net user,hostfwd=tcp::5555-:1522 \
+-append "nobootprompt=tcp maxcores=1024" \
 -kernel 9k8cpu.32bit $*
 
 kill $ufspid