Browse Source

Removed awk madness from generating the boot executable

The awk script has now been replaced by a section in mksys,
the boot types are now in sysconf.json.

Change-Id: Ic794d3fb46ecb322d9fc1e7b8df44b7824646b1e
Signed-off-by: Keith Poole <keith.poole@gmail.com>
Keith Poole 8 years ago
parent
commit
916b82f074

+ 1 - 0
.gitignore

@@ -18,6 +18,7 @@ sys/src/9/k10/sipi.h
 sys/src/9/port/error.h
 sys/src/9/k10/systab.c
 sys/src/9/root/nvram
+sys/src/9/boot/bootk8cpu.c
 
 *.orig
 *_orig

+ 5 - 1
sys/src/9/boot/boot.json

@@ -15,6 +15,10 @@
 		"-fno-builtin",
 		"-mcmodel=small"
 	],
+        "Pre": [
+                "mksys -o bootk8cpu.c -mode=bootk8cpu.c $HARVEY/sys/src/sysconf.json",
+                "[ ! -f bootk8cpu.elf.out ] || rm *.elf.out"
+        ],
 	"Include": [
 		"/sys/src/lib.json"
 	],
@@ -27,10 +31,10 @@
 		"boot.c",
 		"bootcache.c",
 		"bootip.c",
+		"bootk8cpu.c",
 		"console.c",
 		"embed.c",
 		"local.c",
-		"hack.c",
 		"paq.c",
 		"sac.c",
 		"settime.c"

+ 0 - 4
sys/src/9/boot/bootconf.json

@@ -17,10 +17,6 @@
 		"rm *.o *.a",
 		"../../../../util/data2c ramfs_bootk8cpu_ ../boot/bootk8cpu.elf.out >> ../k10/k8cpu.c"
 	],
-	"Pre": [
-		"[ ! -f bootk8cpu.elf.out ] || rm *.elf.out",
-		"awk -f ../mk/parse -- -mkbootconf ../k10/k8cpu \u003e bootk8cpu.c"
-	],
 	"Program": "bootk8cpu.elf.out",
 	"Projects": [
 		"boot.json"

+ 0 - 18
sys/src/9/boot/hack.c

@@ -1,18 +0,0 @@
-/*
- * This file is part of the UCB release of Plan 9. It is subject to the license
- * terms in the LICENSE file found in the top-level directory of this
- * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
- * part of the UCB release of Plan 9, including this file, may be copied,
- * modified, propagated, or distributed except according to the terms contained
- * in the LICENSE file.
- */
-#include <u.h>
-#include <libc.h>
-#include "boot.h"
-char* bootdisk = "disk";
-char* rootdir = "/";
-
-Method method[] = {
-	{ "tcp", configtcp, connecttcp, nil},
-	{nil, nil, nil, nil}
-};

+ 8 - 0
sys/src/sysconf.json

@@ -916,5 +916,13 @@
 			"Name": "Eunmount",
 			"String": "not mounted"
 		}
+	],
+	"Bootmethods": [
+		{
+			"Name": "tcp",
+			"Config": "configtcp",
+			"Connect": "connecttcp",
+			"Arg": ""
+		}
 	]
 }

+ 37 - 0
util/src/harvey/cmd/mksys/mksys.go

@@ -40,9 +40,17 @@ type Syserror struct {
 	Id     uint32
 }
 
+type Bootmethods struct {
+	Name    string
+	Config  string
+	Connect string
+	Arg	string
+}
+
 type Sysconf struct {
 	Syscalls  []Syscall
 	Syserrors []Syserror
+	Bootmethods []Bootmethods
 }
 
 var mode = flag.String("mode", "", "must be one of: sys.h, sysdecl.h, syscallfiles, systab.c, error.h, errstr.h, sys_harvey.s, sysnum.go")
@@ -85,6 +93,7 @@ func main() {
 
 	syscalls := sysconf.Syscalls
 	syserrors := sysconf.Syserrors
+	bootmethods := sysconf.Bootmethods
 	for i := range syscalls {
 		if syscalls[i].Define == "" {
 			syscalls[i].Define = strings.ToUpper(syscalls[i].Name)
@@ -283,6 +292,34 @@ int nsyscall = nelem(systab);
 		if err != nil {
 			log.Fatal(err)
 		}
+	case "bootk8cpu.c":
+		tmpl, err := template.New("bootk8cpu.c").Parse(`/* automatically generated by mksys */
+#include <u.h>
+#include <libc.h>
+
+#include "../boot/boot.h"
+
+Method method[] = {
+{{ range . }}{ "{{.Name}}", {{.Config}}, {{.Connect}}, "{{.Arg}}", },
+{{ end }}
+	{ nil },
+};
 
+int cpuflag = 1;
+char* rootdir = "/root";
+char* bootdisk = "#S/sdC0/";
+extern void boot(int, char**);
+
+void
+main(int argc, char **argv)
+{
+		boot(argc, argv);
+}
+int (*cfs)(int) = 0;
+`)
+		err = tmpl.Execute(outfile, bootmethods)
+		if err != nil {
+			log.Fatal(err)
+		}
 	}
 }