vx32

Local 9vx git repository for patches.
git clone git://r-36.net/vx32
Log | Files | Refs

commit 01f2a48bfb68f456f7b27c9061f59f069793003d
parent e2951a5c94a02f06dc14b9a9b904d62bb62a59d8
Author: Jesus Galan Lopez (yiyus) <yiyu.jgl@gmail.com>
Date:   Fri,  3 Sep 2010 01:50:43 +0200

automatic generation of bootcode.9

Diffstat:
src/9vx/boot/aux.ed | 3+++
src/9vx/boot/boot.ed | 14++++++++++++++
src/9vx/boot/boot.h.ed | 3+++
src/9vx/boot/bootip.ed | 7+++++++
src/9vx/boot/local.ed | 31+++++++++++++++++++++++++++++++
src/9vx/boot/mkbootcode | 36++++++++++++++++++++++++++++++++++++
src/9vx/bootboot.ed | 62--------------------------------------------------------------
7 files changed, 94 insertions(+), 62 deletions(-)

diff --git a/src/9vx/boot/aux.ed b/src/9vx/boot/aux.ed @@ -0,0 +1,3 @@ +/exits/-1;/exits/c + exits(smprint("boot: %s: %s\n", s, buf)); +. diff --git a/src/9vx/boot/boot.ed b/src/9vx/boot/boot.ed @@ -0,0 +1,14 @@ +//a +char* localroot; +. +/fd = \(\*mp->connect\)/a + if(localroot){ + bind(localroot, "/", MAFTER); + srvcreate("boot", fd); + goto Init; + } +. +/cmd = getenv/i +Init: + cpuflag = (strcmp(getenv("service"), "cpu") == 0); +. diff --git a/src/9vx/boot/boot.h.ed b/src/9vx/boot/boot.h.ed @@ -0,0 +1,3 @@ +/extern/a +extern char* localroot; +. diff --git a/src/9vx/boot/bootip.ed b/src/9vx/boot/bootip.ed @@ -0,0 +1,7 @@ +/if\(w->msg\[0\] \!= 0\)/i +/* +. +/fatal(w->msg)/a +*/ +. + diff --git a/src/9vx/boot/local.ed b/src/9vx/boot/local.ed @@ -0,0 +1,31 @@ +/fatal\("open \/net\/ipifc\/clone for loopback"\)/s,[^ ],// , +a/ + return; +. +/fd = connectlocal\(/i +connectlocalroot(void) +{ + int fd; + char buf[1024]; + + snprint(buf, sizeof buf, "%s/%s/bin/rc", disk, cputype); + if(stat(buf, statbuf, sizeof statbuf) < 0) + return -1; + localroot = disk; + + /* create working fd for /srv/boot */ + fd = open("#~/mntloop", ORDWR); + if(fd < 0){ + print("open #~/mntloop: %r\n"); + return -1; + } + write(fd, disk, strlen(disk)); + return fd; +} + +int +. +/fd = connectlocalfossil/i + if((fd = connectlocalroot()) < 0) +. +/connectlocalkfs/s,[^ ],// , diff --git a/src/9vx/boot/mkbootcode b/src/9vx/boot/mkbootcode @@ -0,0 +1,36 @@ +#!/bin/rc +#mkbootcode + +if(uname >/dev/null >[2=1]){ + echo 'run from 9vx to generate bootcode.9' + exit +} + +if(! test -f `{basename $0}){ + echo 'mkbootcode must be run from its own directory' + exit +} + +cwd=`{pwd} +bind -bc . /sys/src/9/boot +cd /sys/src/9/boot + +for(f in *.ed) { + new=`{echo $f | sed 's/.ed$//'} + orig=$new.orig + if(! test -f $orig) + new=$new.c + if(! test -f $orig) + cp $new $orig + { + echo w $new + echo q + cat $f + } | ed $orig 2>/dev/null +} + +cd ../pc +CONF='pcf' mk bootpcf.out && cp bootpcf.out ../boot/bootcode.9 + +cd $cwd +unmount /sys/src/9/boot diff --git a/src/9vx/bootboot.ed b/src/9vx/bootboot.ed @@ -1,62 +0,0 @@ -diff -e plan9/sys/src/9//boot/aux.c 9vx/sys/src/9//boot/aux.c -73,74c - exits(smprint("boot: %s: %s\n", s, buf)); -. -diff -e plan9/sys/src/9//boot/boot.c 9vx/sys/src/9//boot/boot.c -154a -Init: - cpuflag = (strcmp(getenv("service"), "cpu") == 0); -. -92a - if(localroot){ - bind(localroot, "/", MAFTER); - srvcreate("boot", fd); - goto Init; - } -. -6a -char* localroot; -. -diff -e plan9/sys/src/9//boot/boot.h 9vx/sys/src/9//boot/boot.h -16a -extern char* localroot; -. -diff -e plan9/sys/src/9//boot/bootip.c 9vx/sys/src/9//boot/bootip.c -76,77c - // if(w->msg[0] != 0) - // fatal(w->msg); -. -diff -e plan9/sys/src/9//boot/local.c 9vx/sys/src/9//boot/local.c -278c - // if((fd = connectlocalkfs()) < 0) -. -276a - if((fd = connectlocalroot()) < 0) -. -264a -connectlocalroot(void) -{ - int fd; - char buf[1024]; - - snprint(buf, sizeof buf, "%s/%s/bin/rc", disk, cputype); - if(stat(buf, statbuf, sizeof statbuf) < 0) - return -1; - localroot = disk; - - /* create working fd for /srv/boot */ - fd = open("#~/mntloop", ORDWR); - if(fd < 0){ - print("open #~/mntloop: %r\n"); - return -1; - } - write(fd, disk, strlen(disk)); - return fd; -} - -int -. -171c - //fatal("open /net/ipifc/clone for loopback"); - return; -.