## diffname power/bboot.c 1990/0424
## diff -e /dev/null /n/bootesdump/1990/0424/sys/src/9/mips/bboot.c
0a
#include <u.h>
#include <libc.h>
#include <fcall.h>
void error(char *);
char buf[4*1024];
typedef
struct address {
char *name;
char *cmd;
} Address;
Address addr[] = {
{ "bitbootes", "bitconnect" },
{ "ross", "connect 020701005eff" },
{ "bootes", "connect 080069020205" },
{ "helix", "connect 080069020427" },
{ "spindle", "connect 0800690202df" },
{ "r70", "connect 08002b04265d" },
{ 0 }
};
#define DEFFILE "/sys/src/9/mips/9"
char *
lookup(char *arg)
{
Address *a;
if(strcmp(arg, "?")==0 || strcmp(arg, "help")==0){
for(a = addr; a->name; a++)
print("%s\n", a->name);
return 0;
}
for(a = addr; a->name; a++){
if(strcmp(a->name, arg) == 0)
return a->cmd;
}
return 0;
}
/*
* read a segment into memory
*/
int
readseg(int in, int out, long inoff, long outoff, int len)
{
long n;
if(seek(in, inoff, 0) < 0){
error("seeking bootfile");
return -1;
}
if(seek(out, outoff, 0) != outoff){
error("seeking #b/mem");
return -1;
}
for(; len > 0; len -= n){
print(".");
if((n = read(in, buf, sizeof buf)) <= 0){
error("reading bootfile");
return -1;
}
if(write(out, buf, n) != n){
error("writing #b/mem");
return -1;
}
}
return 0;
}
struct a_out_h {
ulong magic; /* magic and sections */
ulong timestamp; /* time and date */
ulong size; /* (HEADR+textsize+datsize) */
ulong symsize; /* nsyms */
ulong opt; /* size of optional hdr and flags */
ulong magicversion; /* magic and version */
ulong text; /* sizes */
ulong data;
ulong bss;
ulong entryva; /* va of entry */
ulong textva; /* va of base of text */
ulong dataca; /* va of base of data */
ulong bssva; /* va of base of bss */
ulong gpregmask; /* gp reg mask */
ulong dummy1;
ulong dummy1;
ulong dummy1;
ulong dummy1;
ulong gpvalue; /* gp value ?? */
ulong mystery; /* complete mystery */
} a_out;
/*
* read the kernel into memory and jump to it
*/
int
readkernel(int fd)
{
int n;
int bfd;
bfd = open("#b/mem", OWRITE);
if(bfd < 0)
error("can't open #b/mem");
n = read(fd, &a_out, sizeof(a_out));
if(n <= 0)
error("can't read boot file");
print("\n%d", a_out.text);
if(readseg(fd, bfd, 20*4, a_out.textva, a_out.text)<0)
error("can't read boot file");
print("+%d", a_out.data);
if(readseg(fd, bfd, 20*4 + a_out.text, a_out.textva + a_out.text, a_out.data)<0)
error("can't read boot file");
print("+%d\n", a_out.bss);
close(bfd);
bfd = open("#b/boot", OWRITE);
if(bfd < 0)
error("can't open #b/boot");
print("entry: %ux\n", a_out.entryva);
sleep(1000);
if(write(bfd, &a_out.entryva, sizeof a_out.entryva) != sizeof a_out.entryva)
error("can't start kernel");
return 0;
}
Fcall hdr;
char srv[100];
main(int argc, char *argv[])
{
int cfd, fd, n, fu, f;
char buf[NAMELEN];
char bootfile[256];
char *scmd;
open("#c/cons", 0);
open("#c/cons", 1);
open("#c/cons", 1);
/*
* get server
*/
do{
do{
print("server[%s]: ", addr[0].name);
n = read(0, srv, sizeof srv);
}while(n==0);
if(n < 0)
error("can't read #c/cons; please reboot");
if(n == 1)
strcpy(srv, addr[0].name);
else
srv[n-1] = 0;
scmd = lookup(srv);
}while(scmd == 0);
/*
* get file. if the user typed cr to the server question, skip
* the file question and just use the default.
*/
if(n != 1){
do{
print("bootfile[%s]: ", DEFFILE);
n = read(0, buf, sizeof buf);
}while(n==0);
if(n < 0)
error("can't read #c/cons; please reboot");
if(n == 1)
strcpy(buf, DEFFILE);
else
buf[n-1] = 0;
strcpy(bootfile, buf);
}else
strcpy(bootfile, DEFFILE);
if(strcmp(scmd, "bitconnect") == 0){
fd = open("#3/bit3", ORDWR);
if(fd < 0)
error("opening #3/bit3");
goto Mesg;
}
/*
* grab a lance channel, make it recognize ether type 0x900,
* and push the nonet ethernet multiplexor onto it.
*/
cfd = open("#l/1/ctl", 2);
if(cfd < 0)
error("opening #l/1/ctl");
if(write(cfd, "connect 0x900", sizeof("connect 0x900")-1)<0)
error("connect 0x900");
if(write(cfd, "push noether", sizeof("push noether")-1)<0)
error("push noether");
/*
* grab a nonet channel and call up the ross file server
*/
fd = open("#n/1/data", 2);
if(fd < 0)
error("opening #n/1/data");
cfd = open("#n/1/ctl", 2);
if(cfd < 0)
error("opening #n/1/ctl");
if(write(cfd, scmd, strlen(scmd))<0)
error(scmd);
Mesg:
print("nop...");
hdr.type = Tnop;
n = convS2M(&hdr, buf);
if(write(fd, buf, n) != n)
error("write nop");
n = read(fd, buf, sizeof buf);
if(n <= 0)
error("read nop");
if(convM2S(buf, &hdr, n) == 0) {
print("n = %d; buf = %.2x %.2x %.2x %.2x\n",
n, buf[0], buf[1], buf[2], buf[3]);
error("format nop");
}
if(hdr.type != Rnop)
error("not Rnop");
print("session...");
hdr.type = Tsession;
hdr.lang = 'v';
n = convS2M(&hdr, buf);
if(write(fd, buf, n) != n)
error("write session");
n = read(fd, buf, sizeof buf);
if(n <= 0)
error("read session");
if(convM2S(buf, &hdr, n) == 0)
error("format session");
if(hdr.type != Rsession)
error("not Rsession");
if(hdr.err){
print("error %d;", hdr.err);
error("remote error");
}
print("mount...");
if(bind("/", "/", MREPL) < 0)
error("bind");
if(mount(fd, "/", MAFTER|MCREATE, "") < 0)
error("mount");
close(fd);
print("open file...");
fd = open(bootfile, OREAD);
if(fd < 0)
error("opening bootfile");
readkernel(fd);
error("couldn't read kernel");
}
void
error(char *s)
{
char buf[64];
errstr(0, buf);
fprint(2, "boot: %s: %s\n", s, buf);
exits(0);
}
.
## diffname power/bboot.c 1990/0427
## diff -e /n/bootesdump/1990/0424/sys/src/9/mips/bboot.c /n/bootesdump/1990/0427/sys/src/9/mips/bboot.c
273a
}
/*
* lookup the address for a system
*/
char *
lookup(char *arg)
{
Address *a;
if(strcmp(arg, "?")==0 || strcmp(arg, "help")==0){
for(a = addr; a->name; a++)
print("%s\n", a->name);
return 0;
}
for(a = addr; a->name; a++){
if(strcmp(a->name, arg) == 0)
return a->cmd;
}
return 0;
}
/*
* read a segment into memory
*/
int
readseg(int in, int out, long inoff, long outoff, int len)
{
long n, i;
ulong sum = 0;
if(seek(in, inoff, 0) < 0){
prerror("seeking bootfile");
return -1;
}
if(seek(out, outoff, 0) != outoff){
prerror("seeking #b/mem");
return -1;
}
for(; len > 0; len -= n){
if((n = read(in, buf, sizeof buf)) <= 0){
prerror("reading bootfile");
return -1;
}
for(i = 0; i < n; i++)
sum += buf[i];
if(sum & 0xf0000000)
sum = (sum & 0xfffffff) + ((sum & 0xf0000000) >> 28);
if(write(out, buf, n) != n){
prerror("writing #b/mem");
return -1;
}
}
print("[%ux]", sum);
return 0;
}
/*
* read the kernel into memory and jump to it
*/
int
readkernel(int fd)
{
int n;
int bfd;
bfd = open("#b/mem", OWRITE);
if(bfd < 0){
prerror("can't open #b/mem");
return;
}
n = read(fd, &a_out, sizeof(a_out));
if(n <= 0){
prerror("can't read boot file");
close(bfd);
return;
}
print("\n%d", a_out.text);
if(readseg(fd, bfd, 20*4, a_out.textva, a_out.text)<0){
prerror("can't read boot file");
close(bfd);
return;
}
print("+%d", a_out.data);
if(readseg(fd, bfd, 20*4 + a_out.text, a_out.textva + a_out.text, a_out.data)<0){
prerror("can't read boot file");
close(bfd);
return;
}
print("+%d\n", a_out.bss);
close(bfd);
bfd = open("#b/boot", OWRITE);
if(bfd < 0){
prerror("can't open #b/boot");
return;
}
print("entry: %ux\n", a_out.entryva);
sleep(1000);
if(write(bfd, &a_out.entryva, sizeof a_out.entryva) != sizeof a_out.entryva){
prerror("can't start kernel");
close(bfd);
}
return;
}
/*
* prompt and get input
*/
int
outin(char *prompt, char *def, char *buf, int len)
{
int n;
do{
print("%s[%s]: ", prompt, def);
n = read(0, buf, len);
}while(n==0);
if(n < 0)
error("can't read #c/cons; please reboot");
if(n == 1)
strcpy(buf, def);
else
buf[n-1] = 0;
return n;
.
266a
prerror(char *s)
{
char buf[64];
errstr(0, buf);
fprint(2, "boot: %s: %s\n", s, buf);
}
/*
* print error and exit
*/
void
.
265a
/*
* print error
*/
.
263c
prerror("couldn't read kernel");
.
259,261c
while((fd = open(bootfile, OREAD)) < 0){
outin("bootfile", DEFFILE, bbuf, sizeof(bbuf));
bootfile = bbuf;
}
.
252,255c
if(bind("/", "/", MREPL) < 0){
prerror("bind");
return;
}
if(mount(fd, "/", MAFTER|MCREATE, "") < 0){
prerror("mount");
return;
}
.
248c
prerror("remote error");
return;
.
240,245c
if(n <= 0){
prerror("read session");
return;
}
if(convM2S(buf, &hdr, n) == 0){
prerror("format session");
return;
}
if(hdr.type != Rsession){
prerror("not Rsession");
return;
}
.
237,238c
if(write(fd, buf, n) != n){
prerror("write session");
return;
}
.
230,231c
if(hdr.type != Rnop){
prerror("not Rnop");
return;
}
.
228c
prerror("format nop");
return;
.
223,224c
if(n <= 0){
prerror("read nop");
return;
}
.
220,221c
if(write(fd, buf, n) != n){
prerror("write nop");
return;
}
.
211,214c
if(cfd < 0){
prerror("opening #n/1/ctl");
return;
}
if(write(cfd, scmd, strlen(scmd))<0){
prerror(scmd);
return;
}
.
208,209c
if(fd < 0) {
prerror("opening #n/1/data");
return;
}
.
197,202c
if(cfd < 0){
prerror("opening #l/1/ctl");
return;
}
if(write(cfd, "connect 0x900", sizeof("connect 0x900")-1)<0){
prerror("connect 0x900");
return;
}
if(write(cfd, "push noether", sizeof("push noether")-1)<0){
prerror("push noether");
return;
}
.
187,188c
if(fd < 0){
prerror("opening #3/bit3");
return;
}
.
170,184d
167,168c
* for the bit, we skip all the ether goo
.
165a
print("Booting %s from server %s\n", bootfile, sys);
.
149,164c
if(!ask)
scmd = lookup(sys);
else {
outin("server", sys, sbuf, sizeof(sbuf));
sys = sbuf;
scmd = lookup(sys);
}
if(scmd == 0){
fprint(2, "boot: %s unknown\n", sys);
return;
}
.
145,147c
if(ask){
outin("bootfile", bootfile, bbuf, sizeof(bbuf));
bootfile = bbuf;
}
.
140,143c
int n;
.
135,138c
void
boot(int ask)
.
122,132c
boot(0);
for(;;){
if(fd > 0)
close(fd);
if(cfd > 0)
close(cfd);
if(efd > 0)
close(efd);
fd = cfd = efd = 0;
boot(1);
}
.
114,120c
sys = DEFSYS;
bootfile = DEFFILE;
switch(argc){
case 1:
bootfile = argv[0];
break;
case 2:
bootfile = argv[0];
sys = argv[1];
break;
}
.
110,112c
argv++;
argc--;
while(argc > 0){
if(argv[0][0] == '-'){
argc--;
argv++;
} else
break;
}
.
106,108c
open("#c/cons", 0);
open("#c/cons", 1);
open("#c/cons", 1);
.
103,104c
int i;
.
100,101c
char *lookup(char *);
int readseg(int, int, long, long, int);
int readkernel(int);
int outin(char *, char *, char *, int);
void prerror(char *);
void error(char *);
void boot(int);
/*
* usage: 9b [-a] [server] [file]
*
* default server is `bitbootes', default file is `/sys/src/9/mips/9'
*/
main(int argc, char *argv[])
.
98c
* predeclared
.
25,73d
8a
int fd;
int cfd;
int efd;
.
6c
#define DEFFILE "/mips/9"
#define DEFSYS "bitbootes"
Fcall hdr;
char *sys;
char *scmd;
char *bootfile;
char sbuf[2*NAMELEN];
char bbuf[5*NAMELEN];
.
## diffname power/bboot.c 1990/0430
## diff -e /n/bootesdump/1990/0427/sys/src/9/mips/bboot.c /n/bootesdump/1990/0430/sys/src/9/mips/bboot.c
340d
331,334d
316d
## diffname power/bboot.c 1990/0504
## diff -e /n/bootesdump/1990/0430/sys/src/9/mips/bboot.c /n/bootesdump/1990/0504/sys/src/9/mips/bboot.c
381c
print(" entry: 0x%ux\n", a_out.entryva);
.
372c
print("+%d", a_out.bss);
.
338a
* set a configuration value
*/
/*
* read the configuration
*/
int
readconf(int fd)
{
int bfd;
int n;
long x;
/*
* read the config file
*/
n = read(fd, buf, sizeof(buf)-1);
if(n <= 0)
return -1;
buf[n] = 0;
/*
* write into 4 meg - 4k
*/
bfd = open("#b/mem", OWRITE);
if(bfd < 0){
prerror("can't open #b/mem");
return;
}
x = 0x80000000 | 4*1024*1024 - 4*1024;
if(seek(bfd, x, 0) != x){
close(bfd);
return -1;
}
if(write(bfd, buf, n+1) != n+1){
close(bfd);
return -1;
}
close(bfd);
return 0;
}
/*
.
257c
outin("bootfile", bootfile, bbuf, sizeof(bbuf));
.
255c
sprint(conffile, "/mips/conf/%s", addr);
print("%s...", conffile);
while((fd = open(conffile, OREAD)) < 0){
outin("conffile", conffile, conffile, sizeof(conffile));
}
if(readconf(fd) < 0)
prerror("readconf");
close(fd);
print("%s...", bootfile);
.
143d
124a
char conffile[128];
.
122c
boot(int ask, char *addr)
.
117c
boot(1, sysname);
.
108c
boot(0, sysname);
.
85a
sysname = argv[0];
.
80a
char *sysname;
.
71c
void boot(int, char *);
.
67a
int readconf(int);
.
22d
## diffname power/bboot.c 1990/0911
## diff -e /n/bootesdump/1990/0504/sys/src/9/mips/bboot.c /n/bootesdump/1990/0911/sys/src/9/mips/bboot.c
316c
return a;
.
304c
Address *
.
188c
prerror("opening #n/2/ctl");
.
186c
cfd = open("#nnonet/2/ctl", 2);
.
183c
prerror("opening #n/2/data");
.
181c
fd = open("#nnonet/2/data", 2);
.
176a
if(write(cfd, "config nonet", sizeof("config nonet")-1)<0){
prerror("config nonet");
return;
}
.
147d
145a
scmd = a->cmd;
.
142c
a = lookup(sys);
if(a == 0){
.
140d
133,137d
128a
Address *a;
.
64c
Address* lookup(char *);
.
29,34c
{ "bitbootes", "bitconnect", "bit!bootes" },
{ "ross", "connect 020701005eff", "nonet!ross" },
{ "bootes", "connect 080069020205", "nonet!bootes" },
{ "helix", "connect 080069020427", "nonet!helix" },
{ "spindle", "connect 0800690202df", "nonet!spindle" },
{ "r70", "connect 08002b04265d", "nonet!r70" },
.
25a
char *srvname;
.
## diffname power/bboot.c 1990/1127
## diff -e /n/bootesdump/1990/0911/sys/src/9/mips/bboot.c /n/bootesdump/1990/1127/sys/src/9/mips/bboot.c
298c
errstr(buf);
.
286c
errstr(buf);
.
254c
if(mount(fd, "/", MAFTER|MCREATE, "", "") < 0){
.
247a
if(hdr.type != Rsession){
prerror("not Rsession");
return;
}
.
243,245c
if(hdr.type == Rerror){
fprint(2, "boot: error %s\n", hdr.ename);
.
239,240c
if(hdr.tag != ~0){
prerror("tag not ~0");
.
224c
hdr.tag = ~0;
.
220a
if(hdr.tag != ~0){
prerror("tag not ~0");
return;
}
.
210a
if(n == 2)
goto reread;
.
205a
reread:
.
202a
print("n = %d\n", n);
.
200a
hdr.tag = ~0;
.
198d
193,194c
sprint(cmd, "connect %s", arg);
if(write(cfd, cmd, strlen(cmd))<0){
close(cfd);
close(fd);
cfd = fd = -1;
prerror(cmd);
return -1;
}
return fd;
}
void
boot(int ask, char *addr)
{
int n, tries;
char conffile[128];
char *srvname;
if(ask){
outin("bootfile", bootfile, bbuf, sizeof(bbuf));
bootfile = bbuf;
outin("server", sys, sbuf, sizeof(sbuf));
sys = sbuf;
}
for(tries = 0; tries < 5; tries++){
fd = -1;
if(strncmp(sys, "bit!", 4) == 0)
fd = bitdial(srvname = &sys[4]);
else if(strncmp(sys, "dk!", 3) == 0)
fd = dkdial(srvname = &sys[3]);
else if(strncmp(sys, "nonet!", 5) == 0)
fd = nonetdial(srvname = &sys[5]);
else
fd = nonetdial(srvname = sys);
if(fd >= 0)
break;
print("can't connect, retrying...\n");
sleep(1000);
}
if(fd < 0){
print("can't connect\n");
.
190,191c
close(fd);
fd = -1;
prerror("opening #kdk/5/ctl");
return -1;
.
188c
cfd = open("#kdk/5/ctl", 2);
.
185,186c
prerror("opening #kdk/5/data");
return -1;
.
183c
fd = open("#kdk/5/data", 2);
.
181c
* grab a datakit channel and call up the file server
.
175,178d
171,173c
return fd;
}
int
dkdial(char *arg)
{
int fd;
char cmd[64];
static int mounted;
if(!mounted){
/*
* grab the hsvme and configure it for a datakit
*/
efd = open("#h/ctl", 2);
if(efd < 0){
prerror("opening #h/ctl");
return -1;
}
if(write(efd, "push dkmux", sizeof("push dkmux")-1)<0){
close(efd);
prerror("push dkmux");
return -1;
}
if(write(efd, "config 4 256 restart dk", sizeof("config 4 256 restart dk")-1)<0){
close(efd);
prerror("config 4 256 restart dk");
return -1;
}
mounted = 1;
sleep(2000); /* wait for things to settle down */
.
167,169c
if(write(cfd, a->cmd, strlen(a->cmd))<0){
close(cfd);
close(fd);
cfd = fd = -1;
prerror(a->cmd);
return -1;
.
164,165c
close(fd);
fd = -1;
prerror("opening #nnonet/2/ctl");
return -1;
.
162c
fd = open("#nnonet/2/data", 2);
if(fd < 0) {
prerror("opening #nnonet/2/data");
return -1;
}
cfd = open("#nnonet/2/ctl", 2);
.
159,160c
* grab a nonet channel and call up the file server
.
155c
if(write(efd, "connect 0x900", sizeof("connect 0x900")-1)<0){
close(efd);
prerror("connect 0x900");
return -1;
}
if(write(efd, "push noether", sizeof("push noether")-1)<0){
close(efd);
prerror("push noether");
return -1;
}
if(write(efd, "config nonet", sizeof("config nonet")-1)<0){
close(efd);
prerror("config nonet");
return -1;
}
mounted = 1;
.
146,153c
if(!mounted){
/*
* grab a lance channel, make it recognize ether type 0x900,
* and push the nonet ethernet multiplexor onto it.
*/
efd = open("#l/1/ctl", 2);
if(efd < 0){
prerror("opening #l/1/ctl");
return -1;
.
144d
138,142c
if(a->name == 0){
print("can't convert nonet address to ether address\n");
return -1;
.
132,136c
for(a = addr; a->name; a++){
if(strcmp(a->name, arg) == 0)
break;
.
130a
static int mounted;
.
128,129c
return open("#3/bit3", ORDWR);
}
int
nonetdial(char *arg)
{
int efd, cfd, fd;
.
125,126c
int
bitdial(char *arg)
.
118,120c
fd = cfd = 0;
.
65c
int dkdial(char *);
int nonetdial(char *);
int bitdial(char *);
.
30,35c
{ "ross", "connect 020701005eff" },
{ "bootes", "connect 080069020205" },
{ "helix", "connect 080069020427" },
{ "spindle", "connect 0800690202df" },
{ "r70", "connect 08002b04265d" },
.
26d
7c
#define DEFSYS "bit!bootes"
.
## diffname power/bboot.c 1990/1202
## diff -e /n/bootesdump/1990/1127/sys/src/9/mips/bboot.c /n/bootesdump/1990/1202/sys/src/9/mips/bboot.c
567a
strcpy(def, buf);
}
.
564,566c
if(n != 1){
.
554c
outin(char *prompt, char *def, int len)
.
372,373c
outin("bootfile", bootfile, sizeof(bootfile));
.
364c
outin("conffile", conffile, sizeof(conffile));
.
274,275c
else if(strncmp(sys, "nonet!", 6) == 0)
fd = nonetdial(srvname = &sys[6]);
.
262,265c
outin("bootfile", bootfile, sizeof(bootfile));
outin("server", sys, sizeof(sys));
.
258d
107,108c
strcpy(bootfile, argv[0]);
strcpy(sys, argv[1]);
.
104c
strcpy(bootfile, argv[0]);
.
100,101c
strcpy(sys, DEFSYS);
strcpy(bootfile, DEFFILE);
.
69c
int outin(char *, char *, int);
.
14,15d
12c
char bootfile[5*NAMELEN];
char conffile[5*NAMELEN];
char sys[NAMELEN];
.
10d
## diffname power/bboot.c 1991/0327
## diff -e /n/bootesdump/1991/0201/sys/src/9/mips/bboot.c /n/bootesdump/1991/0327/sys/src/9/power/bboot.c
29c
{ "bootes", "connect 0800690203f3" },
.
## diffname power/bboot.c 1991/1102
## diff -e /n/bootesdump/1991/0327/sys/src/9/power/bboot.c /n/bootesdump/1991/1102/sys/src/9/power/bboot.c
333,334c
if(hdr.tag != NOTAG){
prerror("tag not NOTAG");
.
318c
hdr.tag = NOTAG;
.
311,312c
if(hdr.tag != NOTAG){
prerror("tag not NOTAG");
.
286c
hdr.tag = NOTAG;
.
6c
#define DEFFILE "/mips/9power"
.
## diffname power/bboot.c 1991/1108
## diff -e /n/bootesdump/1991/1102/sys/src/9/power/bboot.c /n/bootesdump/1991/1108/sys/src/9/power/bboot.c
239c
prerror("opening #k/dk/5/ctl");
.
235c
cfd = open("#k/dk/5/ctl", 2);
.
232c
prerror("opening #k/dk/5/data");
.
230c
fd = open("#k/dk/5/data", 2);
.
## diffname power/bboot.c 1992/0319
## diff -e /n/bootesdump/1991/1108/sys/src/9/power/bboot.c /n/bootesdump/1992/0319/sys/src/9/power/bboot.c
564a
.
563c
if(seek(out, outoff, 0) != outoff){
warning("seeking #b/mem");
return -1;
}
for(; len > 0; len -= n){
if((n = read(in, buf, sizeof buf)) <= 0){
warning("reading bootfile");
return -1;
}
if(write(out, buf, n) != n){
warning("writing #b/mem");
return -1;
}
}
return 0;
.
553,561c
if(seek(in, inoff, 0) < 0){
warning("seeking bootfile");
return -1;
.
551c
long n, i;
.
549c
readseg(int in, int out, long inoff, long outoff, int len)
.
546c
* read a segment into memory
.
537,542c
if(write(bfd, &a_out.entryva, sizeof a_out.entryva) != sizeof a_out.entryva)
fatal("can't start kernel");
.
530,533c
if(bfd < 0)
fatal("can't open #b/boot");
.
521,525c
if(readseg(fd, bfd, 20*4 + a_out.text, a_out.textva + a_out.text, a_out.data)<0)
fatal("can't read boot file");
.
515,519c
if(readseg(fd, bfd, 20*4, a_out.textva, a_out.text)<0)
fatal("can't read boot file");
.
508,512c
if(n <= 0)
fatal("can't read boot file");
.
502,505c
if(bfd < 0)
fatal("can't open #b/mem");
.
495c
void
.
491a
.
475,478c
if(bfd < 0)
fatal("can't open #b/mem");
.
449,453d
427,447d
419,425d
412,416d
386,410c
if(arg)
strcpy(reply, arg);
else
strcpy(reply, method->name);
for(;;){
if(arg == 0 || mflag)
outin(prompt, reply, sizeof(reply));
arg = 0;
for(mp = method; mp->name; mp++)
if(*reply == *mp->name){
cp = strchr(reply, '!');
if(cp)
strcpy(sys, cp+1);
return mp;
}
if(mp->name == 0)
continue;
.
382,384c
mp = method;
n = sprint(prompt, "root is from (%s", mp->name);
for(mp++; mp->name; mp++)
n += sprint(prompt+n, ", %s", mp->name);
sprint(prompt+n, ")");
.
380c
char prompt[256];
char reply[64];
Method *mp;
char *cp;
int n;
.
377,378c
Method*
rootserver(char *arg)
.
375c
* ask user from whence cometh the root file system
.
371c
fatal("couldn't read kernel");
.
369d
367c
while((fd = open(bootfile, OREAD)) < 0)
.
365a
/*
* read in real kernel
*/
.
363c
fatal("readconf");
.
361d
359c
while((fd = open(conffile, OREAD)) < 0)
.
357c
/*
* open the configuration file and read it
* into the kernel
*/
sprint(conffile, "/mips/conf/%s", sysname);
.
253,354c
/*
* create the name space, mount the root fs
*/
if(bind("/", "/", MREPL) < 0)
fatal("bind");
if(mount(fd, "/", MAFTER|MCREATE, "", "") < 0)
fatal("mount");
.
235,251d
230,233c
fd = (*mp->connect)();
if(fd < 0)
fatal("can't connect to file server");
if(!islocal){
nop(fd);
session(fd);
if(cfs)
fd = (*cfs)(fd);
.
228c
* connect to the root file system
.
197,226d
175,195c
mp = rootserver(argc ? *argv : 0);
(*mp->config)(mp);
islocal = strcmp(mp->name, "local") == 0;
.
173c
* pick a method and initialize it
.
122,171d
111,120c
readenv("cputype", cputype, sizeof(cputype));
readenv("terminal", terminal, sizeof(cputype));
readenv("sysname", sysname, sizeof(sysname));
if(argc > 1)
bootfile = argv[1];
else
bootfile = DEFFILE;
.
109c
case 'm':
mflag = 1;
break;
case 'f':
fflag = 1;
break;
}ARGEND
.
105,107c
case 'k':
kflag = 1;
.
89,103c
ARGBEGIN{
case 'u':
strcpy(username, ARGF());
.
87c
open("#c/cons", OREAD);
open("#c/cons", OWRITE);
open("#c/cons", OWRITE);
.
83,85c
sleep(1000);
.
80,81c
int fd;
Method *mp;
char cmd[64];
char flags[6];
int islocal;
char *bootfile;
.
77a
#define DEFFILE "/mips/9power"
void
.
74,76c
* default boot file
.
68,71c
void readkernel(int);
int readseg(int, int, long, long, int);
.
59,66c
typedef struct Net Net;
typedef struct Flavor Flavor;
int printcol;
char cputype[NAMELEN];
char terminal[NAMELEN];
char sys[2*NAMELEN];
char username[NAMELEN];
char conffile[2*NAMELEN];
char sysname[2*NAMELEN];
char buf[8*1024];
int mflag;
int fflag;
int kflag;
int cache(int);
Method *rootserver(char*);
.
4,35d
2a
#include "../boot/boot.h"
.
## diffname power/bboot.c 1992/0322
## diff -e /n/bootesdump/1992/0319/sys/src/9/power/bboot.c /n/bootesdump/1992/0322/sys/src/9/power/bboot.c
171d
169c
if(mflag)
.
93c
strcpy(bootfile, DEFFILE);
.
91c
strcpy(bootfile, argv[1]);
.
64c
char bootfile[NAMELEN];
.
## diffname power/bboot.c 1992/0418
## diff -e /n/bootesdump/1992/0322/sys/src/9/power/bboot.c /n/bootesdump/1992/0418/sys/src/9/power/bboot.c
102a
* set user to none
*/
fd = open("#c/user", OWRITE|OTRUNC);
if(fd >= 0){
if(write(fd, "none", 4) < 0)
warning("write user name");
close(fd);
}else
warning("open #c/user");
/*
.
## diffname power/bboot.c 1992/0522 # deleted
## diff -e /n/bootesdump/1992/0418/sys/src/9/power/bboot.c /n/bootesdump/1992/0522/sys/src/9/power/bboot.c
1,297d
|