From f3ed7ed7170f0286215ba6ffe62c8d3494de6cbd Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Tue, 24 Apr 1990 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1990-04-24 --- port/devboot.c | 134 ++++++++++ port/devproc.c | 5 +- port/proc.c | 2 +- port/sturp.c | 5 +- power/bboot.c | 274 ++++++++++++++++++++ power/boot.h | 666 +++++++++++++++++++++++++------------------------ power/conf.h | 18 ++ power/fns.h | 3 +- power/l.s | 3 + power/main.c | 51 ++-- 10 files changed, 809 insertions(+), 352 deletions(-) create mode 100644 port/devboot.c create mode 100644 power/bboot.c create mode 100644 power/conf.h diff --git a/port/devboot.c b/port/devboot.c new file mode 100644 index 0000000000000000000000000000000000000000..5b9809d73b559ca595f87542fb1058b83412ca04 --- /dev/null +++ b/port/devboot.c @@ -0,0 +1,134 @@ +#include "u.h" +#include "lib.h" +#include "mem.h" +#include "dat.h" +#include "fns.h" +#include "errno.h" +#include "devtab.h" + +enum{ + Qdir, + Qboot, + Qmem, +}; + +Dirtab bootdir[]={ + "boot", Qboot, 0, 0666, + "mem", Qmem, 0, 0666, +}; + +#define NBOOT (sizeof bootdir/sizeof(Dirtab)) + +void +bootreset(void) +{ +} + +void +bootinit(void) +{ +} + +Chan* +bootattach(char *spec) +{ + return devattach('b', spec); +} + +Chan* +bootclone(Chan *c, Chan *nc) +{ + return devclone(c, nc); +} + +int +bootwalk(Chan *c, char *name) +{ + return devwalk(c, name, bootdir, NBOOT, devgen); +} + +void +bootstat(Chan *c, char *dp) +{ + devstat(c, dp, bootdir, NBOOT, devgen); +} + +Chan* +bootopen(Chan *c, int omode) +{ + return devopen(c, omode, bootdir, NBOOT, devgen); +} + +void +bootcreate(Chan *c, char *name, int omode, ulong perm) +{ + error(0, Eperm); +} + +/* + * sysremove() knows this is a nop + */ +void +bootclose(Chan *c) +{ +} + +long +bootread(Chan *c, void *buf, long n) +{ + switch(c->qid & ~CHDIR){ + case Qdir: + return devdirread(c, buf, n, bootdir, NBOOT, devgen); + } + + error(0, Egreg); +} + +long +bootwrite(Chan *c, void *buf, long n) +{ + ulong pc; + + switch(c->qid & ~CHDIR){ + case Qmem: + /* kernel memory. BUG: shouldn't be so easygoing. BUG: mem mapping? */ + if(c->offset>=KZERO && c->offsetoffset, n);/**/ + if(c->offset+n > KZERO+conf.npage*BY2PG) + n = KZERO+conf.npage*BY2PG - c->offset; + memcpy((char*)c->offset, buf, n); + return n; + } + error(0, Ebadarg); + + case Qboot: + pc = *(ulong*)buf; + splhi(); + gotopc(pc); + } + error(0, Ebadarg); +} + +void +bootremove(Chan *c) +{ + error(0, Eperm); +} + +void +bootwstat(Chan *c, char *dp) +{ + error(0, Eperm); +} + +void +bootuserstr(Error *e, char *buf) +{ + consuserstr(e, buf); +} + +void +booterrstr(Error *e, char *buf) +{ + rooterrstr(e, buf); +} diff --git a/port/devproc.c b/port/devproc.c index 5b6c56fad09f6b6e6cd3cd7671fdafd2adf33411..60f72d4646aedde575ea53222ace95dc5c102ef3 100644 --- a/port/devproc.c +++ b/port/devproc.c @@ -147,12 +147,15 @@ procopen(Chan *c, int omode) case Qnote: break; case Qdir: - case Qmem: case Qproc: case Qstatus: if(omode!=OREAD) error(0, Eperm); break; + case Qmem: + if(omode!=OREAD) + error(0, Eperm); + break; default: pprint("unknown qid in devopen\n"); error(0, Egreg); diff --git a/port/proc.c b/port/proc.c index a10fc544ea0c33ddbb8fb098b2875b434c6a1268..31e819395ae26bc4c8fb4072b4f047627aa3e67c 100644 --- a/port/proc.c +++ b/port/proc.c @@ -539,8 +539,8 @@ kproc(char *name, void (*func)(void *), void *arg) Proc *p; int n; ulong upa; - int lastvar; /* used to compute stack address */ User *up; + int lastvar; /* used to compute stack address */ /* * Kernel stack diff --git a/port/sturp.c b/port/sturp.c index a603045da1475471dcdb23064756469d7eda0d95..95e2846e28ac523080ecc6c8a2e322b5350f3736 100644 --- a/port/sturp.c +++ b/port/sturp.c @@ -370,8 +370,8 @@ urpiput(Queue *q, Block *bp) * queue the block(s) */ if(BLEN(bp) > 0){ + bp->flags &= ~S_DELIM; putq(q, bp); - q->last->flags &= ~S_DELIM; if(q->len > 4*1024){ flushinput(up); return; @@ -472,7 +472,8 @@ urpiput(Queue *q, Block *bp) PUTNEXT(q, bp); } else { bp = allocb(0); - bp->flags |= S_DELIM; + if(up->trbuf[0] != BOTM) + bp->flags |= S_DELIM; PUTNEXT(q, bp); } up->trx = 0; diff --git a/power/bboot.c b/power/bboot.c new file mode 100644 index 0000000000000000000000000000000000000000..2863440ab132a75951d0bcbb4415e34ed01d66db --- /dev/null +++ b/power/bboot.c @@ -0,0 +1,274 @@ +#include +#include + +#include + +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); +} diff --git a/power/boot.h b/power/boot.h index 73080eae857e7881936e45605738608d7b35ee62..2cfa8772e98718dd89258649b20a4dad065e6027 100644 --- a/power/boot.h +++ b/power/boot.h @@ -1,6 +1,6 @@ ulong bootcode[]={ 0x00000407, - 0x00003ed0, + 0x00003f00, 0x000004f0, 0x00000198, 0x00000000, @@ -963,7 +963,7 @@ ulong bootcode[]={ 0xafa10004, 0x24810008, 0xafa10008, - 0x0c0012ea, + 0x0c0012f6, 0xafa6000c, 0x8fa10010, 0x2002001c, @@ -974,7 +974,7 @@ ulong bootcode[]={ 0x00000027, 0x24210024, 0xafa10008, - 0x0c0012ea, + 0x0c0012f6, 0xafa2000c, 0x8fa10010, 0x8fa2001c, @@ -1084,7 +1084,7 @@ ulong bootcode[]={ 0xafa20004, 0x2482000c, 0xafa20008, - 0x0c0012ea, + 0x0c0012f6, 0xafa6000c, 0x8fa20010, 0x00000027, @@ -1126,7 +1126,7 @@ ulong bootcode[]={ 0xafa10004, 0x2481000c, 0xafa10008, - 0x0c0012ea, + 0x0c0012f6, 0xafa6000c, 0x8fa60018, 0x8fa10010, @@ -1226,7 +1226,7 @@ ulong bootcode[]={ 0x00000027, 0xafa20008, 0x8c81000c, - 0x0c0012ea, + 0x0c0012f6, 0xafa1000c, 0x8fa20018, 0x8fa10010, @@ -1267,7 +1267,7 @@ ulong bootcode[]={ 0x00000027, 0xafa10008, 0x8c82000c, - 0x0c0012ea, + 0x0c0012f6, 0xafa2000c, 0x8fa10018, 0x8fa20010, @@ -1409,7 +1409,7 @@ ulong bootcode[]={ 0xafa20004, 0x24820008, 0xafa20008, - 0x0c0012ea, + 0x0c0012f6, 0xafa7000c, 0x8fa20010, 0x00000027, @@ -1439,7 +1439,7 @@ ulong bootcode[]={ 0xafa20004, 0x24820008, 0xafa20008, - 0x0c0012ea, + 0x0c0012f6, 0xafa7000c, 0x8fa20010, 0x00000027, @@ -1506,7 +1506,7 @@ ulong bootcode[]={ 0xafa20004, 0x24820008, 0xafa20008, - 0x0c0012ea, + 0x0c0012f6, 0xafa6000c, 0x8fa20010, 0x00000027, @@ -1557,7 +1557,7 @@ ulong bootcode[]={ 0xafa20004, 0x24820008, 0xafa20008, - 0x0c0012ea, + 0x0c0012f6, 0xafa7000c, 0x8fa20010, 0x00000027, @@ -1620,7 +1620,7 @@ ulong bootcode[]={ 0x00000027, 0xafa20008, 0x8c81000c, - 0x0c0012ea, + 0x0c0012f6, 0xafa1000c, 0x8fa20018, 0x8fa10010, @@ -1662,7 +1662,7 @@ ulong bootcode[]={ 0x00000027, 0xafa10008, 0x8c82000c, - 0x0c0012ea, + 0x0c0012f6, 0xafa2000c, 0x8fa10018, 0x8fa20010, @@ -1685,7 +1685,7 @@ ulong bootcode[]={ 0x8fa10018, 0x00000027, 0xafa10008, - 0x0c0012ea, + 0x0c0012f6, 0xafa2000c, 0x8fa30018, 0x8fa10010, @@ -1890,7 +1890,7 @@ ulong bootcode[]={ 0xafa20004, 0xafa40010, 0xafa40008, - 0x0c0012ea, + 0x0c0012f6, 0xafa6000c, 0x8fa10010, 0x8fa2001c, @@ -1900,7 +1900,7 @@ ulong bootcode[]={ 0xafa40010, 0xafa40008, 0x2002001c, - 0x0c0012ea, + 0x0c0012f6, 0xafa2000c, 0x8fa10010, 0x08000b44, @@ -1977,7 +1977,7 @@ ulong bootcode[]={ 0xafa20004, 0xafa40010, 0xafa40008, - 0x0c0012ea, + 0x0c0012f6, 0xafa6000c, 0x8fa10010, 0x08000b44, @@ -2011,7 +2011,7 @@ ulong bootcode[]={ 0xafa20004, 0xafa40010, 0xafa40008, - 0x0c0012ea, + 0x0c0012f6, 0xafa6000c, 0x8fa5001c, 0x8fa10010, @@ -2201,7 +2201,7 @@ ulong bootcode[]={ 0xafa10004, 0xafa40010, 0xafa40008, - 0x0c0012ea, + 0x0c0012f6, 0xafa7000c, 0x8fa20010, 0x08000b44, @@ -2222,7 +2222,7 @@ ulong bootcode[]={ 0xafa20004, 0xafa40010, 0xafa40008, - 0x0c0012ea, + 0x0c0012f6, 0xafa7000c, 0x8fa10010, 0x08000b44, @@ -2272,7 +2272,7 @@ ulong bootcode[]={ 0xafa20004, 0xafa40010, 0xafa40008, - 0x0c0012ea, + 0x0c0012f6, 0xafa6000c, 0x8fa10010, 0x08000b44, @@ -2306,7 +2306,7 @@ ulong bootcode[]={ 0xafa20004, 0xafa40010, 0xafa40008, - 0x0c0012ea, + 0x0c0012f6, 0xafa7000c, 0x8fa10010, 0x08000b44, @@ -2385,7 +2385,7 @@ ulong bootcode[]={ 0xafa40010, 0xafa40008, 0x2001001c, - 0x0c0012ea, + 0x0c0012f6, 0xafa1000c, 0x8fa4001c, 0x8fa20010, @@ -2591,28 +2591,31 @@ ulong bootcode[]={ 0x23bd0014, 0x23bdffd0, 0xafbf0000, - 0x8fa5003c, + 0x8fa6003c, + 0x200b000a, + 0x8fa50040, + 0x00003825, 0x8fc180c2, 0x00000027, 0xafa10018, 0x8fc2800a, 0x00000027, 0xafa20014, - 0x8fa80034, + 0x8faa0034, 0x00000027, - 0xafc880c2, + 0xafca80c2, 0x8fa20038, 0x00000027, 0x2442ffff, 0xafc2800a, - 0x00052025, + 0x00062025, 0x80840000, 0x20010025, - 0x1081002a, - 0x24a50001, + 0x10810028, + 0x24c60001, 0x1480000c, 0x00000027, - 0xa1000000, + 0xa1400000, 0x8fa10018, 0x00000027, 0xafc180c2, @@ -2622,76 +2625,65 @@ ulong bootcode[]={ 0x8fa20000, 0x23bd0030, 0x00400008, - 0x00080825, + 0x000a0825, 0x8fc1800a, 0x00000027, - 0x0101182b, + 0x0141182b, 0x10600005, 0x00000027, - 0x00081025, - 0x25080001, - 0xafc880c2, + 0x000a1025, + 0x254a0001, + 0xafca80c2, 0xa0440000, 0x8fc18006, 0x00000027, 0x24210001, + 0x148b0003, 0xafc18006, - 0x2001000a, - 0x14810003, - 0x00000027, - 0x08000e2e, - 0xafc08006, + 0x08000e31, + 0xafc78006, 0x20010009, - 0x1481ffda, + 0x1481ffdc, 0x00000027, 0x8fc28006, 0x00000027, 0x24420007, 0x201cfff8, 0x005c1024, - 0x08000e2e, + 0x08000e31, 0xafc28006, - 0x00004825, - 0x00052025, - 0x24a50001, - 0xafa5003c, + 0x00075025, + 0x00062025, + 0x24c60001, + 0xafa6003c, 0x80840000, - 0x2006ffff, - 0x00004025, - 0x2002002d, - 0x14820006, - 0x00003825, - 0x00052025, - 0x24a50001, - 0xafa5003c, + 0x2008ffff, + 0x2002002a, + 0x14820058, + 0x00074825, + 0x8ca90000, + 0x24a50004, + 0x00062025, + 0x24c60001, + 0xafa6003c, 0x80840000, - 0x20080001, - 0x28820030, - 0x14400005, 0x00000027, - 0x20010039, - 0x0024182a, - 0x1060004c, - 0x00000027, - 0x11000002, - 0x00000027, - 0x00073823, - 0x2001002e, - 0x1081002b, + 0x2002002e, + 0x1082002b, 0x00000027, 0x14800003, 0x00000027, - 0x24a2ffff, + 0x24c2ffff, 0xafa2003c, - 0x8fa20040, + 0xafa50040, + 0xafa50004, + 0xafa9002c, + 0xafa90008, + 0xafa80028, + 0xafa8000c, + 0xafaa0024, + 0xafaa0010, 0x23c1846e, - 0xafa20004, - 0xafa7002c, - 0xafa70008, - 0xafa60028, - 0xafa6000c, - 0xafa90024, - 0xafa90010, 0x3082007f, 0x00220821, 0x80210000, @@ -2702,99 +2694,129 @@ ulong bootcode[]={ 0x00000027, 0x0020f809, 0x00000027, - 0x8fc880c2, - 0x8fa7002c, - 0x8fa60028, - 0x8fa5003c, - 0x04210009, + 0x8fca80c2, + 0x8fa9002c, + 0x8fa80028, + 0x00003825, + 0x8fa6003c, + 0x8fa50040, 0x00012025, + 0x04210009, + 0x200b000a, 0x8fa30024, - 0x00040823, - 0x00052025, - 0x24a50001, - 0xafa5003c, + 0x00e40823, + 0x00062025, + 0x24c60001, + 0xafa6003c, 0x80840000, - 0x08000e78, - 0x00614825, - 0x8fa10040, - 0x00000027, - 0x00240821, - 0x08000e2e, - 0xafa10040, - 0x00052025, - 0x24a50001, - 0xafa5003c, + 0x08000e70, + 0x00615025, + 0x08000e31, + 0x00a42821, + 0x00062025, + 0x24c60001, + 0xafa6003c, 0x80840000, + 0x2001002a, + 0x14810008, 0x00000027, + 0x8ca80000, + 0x00062025, + 0x24c60001, + 0xafa6003c, + 0x80840000, + 0x08000e70, + 0x24a50004, 0x28820030, - 0x1440ffcf, + 0x1440ffc6, 0x00000027, 0x20010039, 0x0024182a, 0x10600003, 0x00000027, - 0x08000e78, + 0x08000e70, 0x00000027, - 0x04c10002, + 0x05010002, 0x00000027, - 0x00003025, - 0x2002000a, - 0x00c20018, + 0x00074025, + 0x010b0018, 0x00000812, 0x00240821, - 0x00052025, - 0x24a50001, - 0xafa5003c, + 0x00062025, + 0x24c60001, + 0xafa6003c, 0x80840000, - 0x08000ea7, - 0x2426ffd0, - 0x2001000a, - 0x00e10018, - 0x00001012, - 0x00441021, - 0x00052025, - 0x24a50001, - 0xafa5003c, + 0x08000ea8, + 0x2428ffd0, + 0x2001002d, + 0x14810006, + 0x00076025, + 0x00062025, + 0x24c60001, + 0xafa6003c, 0x80840000, - 0x08000e6b, - 0x2447ffd0, + 0x200c0001, + 0x28810030, + 0x14200005, + 0x00000027, + 0x20020039, + 0x0044182a, + 0x10600005, + 0x00000027, + 0x1180ffa0, + 0x00000027, + 0x08000e6d, + 0x00e94823, + 0x012b0018, + 0x00000812, + 0x00240821, + 0x00062025, + 0x24c60001, + 0xafa6003c, + 0x80840000, + 0x08000ec5, + 0x2429ffd0, 0x23bdffb4, 0xafbf0000, - 0x8fa6005c, - 0x8fa40050, + 0x8fae005c, + 0x200d0001, + 0x8fa50050, + 0x00003025, + 0x200a0039, + 0x23a9002c, 0x8fa80060, + 0x20040004, 0x8fa70058, - 0x00005025, - 0x30c2000f, + 0x200b001e, + 0x00006025, + 0x31c2000f, 0x2441fffb, - 0x1c20005b, - 0x23a9002c, - 0x10200055, + 0x1c200053, + 0x200f001c, + 0x1020004e, 0x00000027, 0x38410001, - 0x1020004e, + 0x10200048, 0x00000027, 0x38410002, - 0x10200041, + 0x1020003d, 0x00000027, 0x38410004, - 0x1020003a, + 0x10200037, 0x00000027, - 0x8c850000, - 0x20010004, - 0xafa1001c, - 0x30c20004, + 0x8ca50000, + 0xafa4001c, + 0x31c20004, 0x14400003, 0x00000027, - 0x04a0002f, + 0x04a0002d, 0x00000027, 0xa3a00049, - 0x2004001c, + 0x000f2025, 0x00a8001b, 0x00001010, 0x24460030, - 0x20010039, - 0x0026182a, + 0x0146182a, 0x10600002, 0x00000027, 0x24c60027, @@ -2802,7 +2824,7 @@ ulong bootcode[]={ 0x28820002, 0x10400013, 0xa0260000, - 0x11400005, + 0x11800005, 0x00000027, 0x2484ffff, 0x01240821, @@ -2813,7 +2835,7 @@ ulong bootcode[]={ 0x8fa20054, 0x2001ffff, 0xafa20008, - 0x0c000f62, + 0x0c000f6e, 0xafa1000c, 0x8fa1001c, 0x8fa20000, @@ -2821,65 +2843,58 @@ ulong bootcode[]={ 0x00400008, 0x23bd004c, 0x00a8001b, - 0x04e00006, + 0x04e00005, 0x00002812, - 0x2002001e, - 0x00471023, + 0x01671023, 0x0082082a, 0x10200005, 0x00000027, 0x1ca00003, 0x00000027, - 0x08000ef3, + 0x08000f09, 0x00000027, - 0x08000ee7, + 0x08000efe, 0x2484ffff, - 0x200a0001, - 0x08000ee5, - 0x00052823, - 0x8c850000, - 0x20010004, - 0x08000ee0, - 0xafa1001c, - 0x8c820000, - 0x00000027, - 0x00022400, - 0x00042403, - 0x00040c00, + 0x000d6025, + 0x08000efc, + 0x00c52823, + 0x8ca50000, + 0x08000ef7, + 0xafa4001c, + 0x8ca20000, + 0xafa4001c, + 0x00022c00, + 0x00052c03, + 0x00050c00, 0x00010c03, - 0x20020004, - 0xafa2001c, - 0x08000ee0, + 0x08000ef7, 0x00012825, - 0x8c850000, - 0x20010004, - 0x08000ee0, - 0xafa1001c, - 0x8c850000, - 0x20010004, - 0x08000ee0, - 0xafa1001c, + 0x8ca50000, + 0x08000ef7, + 0xafa4001c, + 0x8ca50000, + 0x08000ef7, + 0xafa4001c, 0x38410006, - 0x1020002b, + 0x10200029, 0x00000027, 0x38410009, 0x10200003, 0x00000027, - 0x08000edd, + 0x08000ef5, + 0x00000027, + 0x8ca50000, 0x00000027, - 0x8c850000, - 0x20010004, 0x04a10003, - 0xafa1001c, - 0x00052823, - 0x200a0001, + 0xafa4001c, + 0x00c52823, + 0x000d6025, 0xa3a00049, - 0x2004001c, + 0x000f2025, 0x00a8001a, 0x00000810, 0x24260030, - 0x20020039, - 0x0046182a, + 0x0146182a, 0x10600002, 0x00000027, 0x24c60027, @@ -2888,75 +2903,74 @@ ulong bootcode[]={ 0x28820002, 0x10400003, 0x00000027, - 0x08000ef3, + 0x08000f09, 0x00000027, 0x00a8001a, - 0x04e00006, + 0x04e00005, 0x00002812, - 0x2002001e, - 0x00471023, + 0x01671023, 0x0082082a, 0x10200005, 0x00000027, 0x1ca00003, 0x00000027, - 0x08000ef3, + 0x08000f09, 0x00000027, - 0x08000f3c, + 0x08000f4c, 0x2484ffff, - 0x8c810000, - 0x00000027, - 0x00012400, - 0x00042403, - 0x3082ffff, - 0x20010004, - 0xafa1001c, - 0x08000ee0, + 0x8ca10000, + 0xafa4001c, + 0x00012c00, + 0x00052c03, + 0x30a2ffff, + 0x08000ef7, 0x00022825, 0x23bdfff0, 0x8faa0014, - 0x8fab0018, - 0x8fa9001c, - 0x8fc8800a, + 0x00006825, + 0x8fac0018, + 0x200b0020, + 0x8fc9800a, + 0x8fa8001c, 0x8fc78006, 0x8fc580c2, + 0x00002025, 0x000a3025, 0x00060825, 0x80210000, 0x24c60001, 0x10200006, - 0x00002025, + 0x200e000a, 0x00060825, 0x80210000, 0x24c60001, 0x1420fffc, 0x24840001, - 0x05600011, + 0x05800010, 0x00000027, - 0x008b182a, - 0x1060000e, + 0x008c182a, + 0x1060000d, 0x00000027, - 0x00a8182b, - 0x10600006, + 0x00a9182b, + 0x10600005, 0x00000027, 0x00051025, 0x24a50001, 0xafc580c2, - 0x20030020, - 0xa0430000, + 0xa04b0000, 0x24e70001, 0x24840001, - 0x008b182a, - 0x1460fff4, + 0x008c182a, + 0x1460fff5, 0xafc78006, 0x000a3025, 0x80c60000, 0x00000027, - 0x10c00015, + 0x10c00014, 0x254a0001, - 0x1120fffa, + 0x1100fffa, 0x00000027, - 0x00a8182b, + 0x00a9182b, 0x10600005, 0x00000027, 0x00051025, @@ -2964,44 +2978,42 @@ ulong bootcode[]={ 0xafc580c2, 0xa0460000, 0x24e70001, - 0x2001000a, - 0x14c1001d, + 0x14ce001c, 0xafc78006, - 0x00003825, - 0xafc08006, + 0x000d3825, + 0xafcd8006, 0x000a3025, 0x80c60000, 0x254a0001, - 0x14c0ffed, - 0x2529ffff, - 0x05610012, + 0x14c0ffee, + 0x2508ffff, + 0x05810011, 0x00000027, - 0x000b3023, + 0x01ac3023, 0x0086182a, - 0x1060000e, + 0x1060000d, 0x00000027, - 0x00a8182b, - 0x10600006, + 0x00a9182b, + 0x10600005, 0x00000027, 0x00051025, 0x24a50001, 0xafc580c2, - 0x20030020, - 0xa0430000, + 0xa04b0000, 0x24e70001, 0x24840001, 0x0086182a, - 0x1460fff4, + 0x1460fff5, 0xafc78006, 0x03e00008, 0x23bd0010, 0x20010009, - 0x14c1ffe4, + 0x14c1ffe5, 0x00000027, 0x24e20007, 0x201cfff8, 0x005c3824, - 0x08000f9a, + 0x08000fa7, 0xafc78006, 0x23bdfff0, 0xafbf0000, @@ -3009,7 +3021,7 @@ ulong bootcode[]={ 0xafa10004, 0xafa00008, 0x2002ffff, - 0x0c000f62, + 0x0c000f6e, 0xafa2000c, 0x8fa20000, 0x23bd0010, @@ -3027,7 +3039,7 @@ ulong bootcode[]={ 0x8fa1001c, 0x2002ffff, 0xafa10008, - 0x0c000f62, + 0x0c000f6e, 0xafa2000c, 0x8fa20000, 0x23bd0014, @@ -3047,7 +3059,7 @@ ulong bootcode[]={ 0x8fa20028, 0x2003000a, 0xafa20010, - 0x0c000ec7, + 0x0c000ed9, 0xafa30014, 0x8fa20000, 0x00000027, @@ -3083,7 +3095,7 @@ ulong bootcode[]={ 0x8fa30028, 0x20020008, 0xafa30010, - 0x0c000ec7, + 0x0c000ed9, 0xafa20014, 0x8fa20000, 0x00000027, @@ -3100,7 +3112,7 @@ ulong bootcode[]={ 0x00000027, 0xafa20008, 0x8fa1001c, - 0x0c000f62, + 0x0c000f6e, 0xafa1000c, 0x8fa20000, 0x23bd0010, @@ -3124,7 +3136,7 @@ ulong bootcode[]={ 0x8fa30028, 0x20020010, 0xafa30010, - 0x0c000ec7, + 0x0c000ed9, 0xafa20014, 0x8fa20000, 0x00000027, @@ -3147,16 +3159,16 @@ ulong bootcode[]={ 0x23bdff70, 0xafbf0000, 0x8fad00a8, - 0x8fa900a0, - 0x23a80040, + 0x8faa00a0, + 0x23a90068, 0xafa0001c, 0xc7a10094, 0xc7a00098, - 0x00000027, + 0x23a80040, 0x4620c03e, 0x00000027, 0x4501000b, - 0x23ac0068, + 0x00007025, 0xc7a30094, 0xc7a20098, 0x00000027, @@ -3167,7 +3179,7 @@ ulong bootcode[]={ 0x00000027, 0x24210001, 0xafa1001c, - 0xafa0002c, + 0xafae002c, 0xc7a10094, 0xc7a00098, 0x00000027, @@ -3180,7 +3192,7 @@ ulong bootcode[]={ 0x23a1002c, 0xe7a10004, 0xe7a00008, - 0x0c00124e, + 0x0c00125a, 0xafa1000c, 0xc7c1801e, 0xc7c08022, @@ -3195,7 +3207,7 @@ ulong bootcode[]={ 0x00012843, 0xafa50028, 0x00050823, - 0x0c001224, + 0x0c001230, 0xafa10004, 0xc7a30094, 0xc7a20098, @@ -3207,16 +3219,16 @@ ulong bootcode[]={ 0x8fa2002c, 0x00000027, 0x00220823, - 0x0c001224, + 0x0c001230, 0xafa10004, 0x8fad00a8, - 0x23ac0068, - 0x8fa900a0, - 0x23a80040, + 0x00007025, + 0x8faa00a0, + 0x23a90068, 0x46200086, 0xc7a10030, 0xc7a00034, - 0x00000027, + 0x23a80040, 0x46220102, 0x4624e03e, 0x00000027, @@ -3230,17 +3242,17 @@ ulong bootcode[]={ 0x8fa2002c, 0x00000027, 0x00220823, - 0x0c001224, + 0x0c001230, 0xafa10004, 0x8fad00a8, - 0x8fa900a0, - 0x23a80040, + 0x8faa00a0, + 0x23a90068, 0xc7a30030, 0xc7a20034, - 0x00000027, + 0x23a80040, 0x46201102, - 0x08001093, - 0x23ac0068, + 0x0800109f, + 0x00007025, 0xc7c1800e, 0xc7c08012, 0x00000027, @@ -3256,34 +3268,34 @@ ulong bootcode[]={ 0x8fa2002c, 0x00000027, 0x00220823, - 0x0c001224, + 0x0c001230, 0xafa10004, 0x8fad00a8, - 0x8fa900a0, - 0x23a80040, + 0x8faa00a0, + 0x23a90068, 0xc7a30030, 0xc7a20034, - 0x00000027, + 0x23a80040, 0x46201102, - 0x080010aa, - 0x23ac0068, - 0x05210002, + 0x080010b6, + 0x00007025, + 0x05410002, 0x00000027, - 0x20090008, + 0x200a0008, 0x20020067, 0x15a20003, 0x00000027, - 0x1d20010f, + 0x1d40010f, 0x00000027, 0x2002001e, - 0x0049182a, + 0x004a182a, 0x10600002, 0x00000027, - 0x2009001e, - 0x25250002, + 0x200a001e, + 0x25450002, 0x20020066, 0x15a20008, - 0xafa900a0, + 0xafaa00a0, 0x8fa1002c, 0x00000027, 0x00a12821, @@ -3297,12 +3309,12 @@ ulong bootcode[]={ 0x20010065, 0x15a10003, 0x00000027, - 0x2009ffff, - 0xafa900a0, + 0x200affff, + 0xafaa00a0, 0x200d0065, - 0x08001060, + 0x0800106c, 0xafad00a8, - 0x00003825, + 0x000e3825, 0x00e5182a, 0x10600018, 0x00000027, @@ -3318,7 +3330,7 @@ ulong bootcode[]={ 0x00000027, 0x24c6ffff, 0x44860000, - 0x00ec0821, + 0x00e90821, 0x46800021, 0x46202101, 0x24c30030, @@ -3333,46 +3345,46 @@ ulong bootcode[]={ 0x24a5ffff, 0x04a00013, 0x00000027, - 0x00ac0821, + 0x00a90821, 0x80220001, 0x00000027, 0x00461821, 0xa0230001, - 0x00ac0821, + 0x00a90821, 0x80210001, 0x20020039, 0x0041182a, 0x10600006, - 0x00003025, - 0x00ac0821, + 0x000e3025, + 0x00a90821, 0x80230001, 0x24c60001, 0x2463fff6, 0xa0230001, - 0x08001104, + 0x08001110, 0x24a5ffff, 0x10c00007, - 0x200a0001, + 0x200b0001, 0x20020031, 0xa3a20068, 0x8fa1002c, - 0x00005025, + 0x000e5825, 0x24210001, 0xafa1002c, 0x8fa2001c, 0x00000027, 0x10400006, - 0x00002825, + 0x000e2825, 0x00051025, 0x24a50001, 0x01020821, 0x2002002d, 0xa0220000, - 0x25270001, - 0x00095825, + 0x25470001, + 0x000a6025, 0x20020067, 0x15a2000b, - 0x00003025, + 0x000e3025, 0x8fa1002c, 0x00000027, 0x2822fffb, @@ -3380,7 +3392,7 @@ ulong bootcode[]={ 0x00000027, 0x8fa2002c, 0x00000027, - 0x0122182a, + 0x0142182a, 0x10600099, 0x00000027, 0x20010066, @@ -3388,11 +3400,11 @@ ulong bootcode[]={ 0x00000027, 0x8fa1002c, 0x00000027, - 0x00013023, + 0x01c13023, 0x04c10002, 0x00000027, - 0x00003025, - 0x0126182a, + 0x000e3025, + 0x0146182a, 0x10600002, 0x00000027, 0x00073025, @@ -3401,11 +3413,11 @@ ulong bootcode[]={ 0x00e13821, 0x04e10002, 0x00000027, - 0x00003825, + 0x000e3825, 0x18c00010, 0x00000027, 0x00c71021, - 0x144b0006, + 0x144c0006, 0x00000027, 0x00051025, 0x24a50001, @@ -3417,12 +3429,12 @@ ulong bootcode[]={ 0x20020030, 0xa0220000, 0x24c6ffff, - 0x0800114b, + 0x08001157, 0x24a50001, 0x18e00013, 0x00000027, 0x00c70821, - 0x142b0006, + 0x142c0006, 0x00000027, 0x00051025, 0x24a50001, @@ -3431,13 +3443,13 @@ ulong bootcode[]={ 0xa0220000, 0x00051025, 0x01020821, - 0x000a1825, - 0x01831021, + 0x000b1825, + 0x01231021, 0x80420000, - 0x254a0001, + 0x256b0001, 0xa0220000, 0x24e7ffff, - 0x0800115c, + 0x08001168, 0x24a50001, 0x20010067, 0x11a10046, @@ -3457,7 +3469,7 @@ ulong bootcode[]={ 0x8fa1009c, 0x2002ffff, 0xafa10008, - 0x0c000f62, + 0x0c000f6e, 0xafa2000c, 0x8fa20000, 0x23bd0090, @@ -3477,7 +3489,7 @@ ulong bootcode[]={ 0x00a81021, 0x2003002d, 0xa043ffff, - 0x00063023, + 0x01c63023, 0x28c10064, 0x1420000e, 0x00000027, @@ -3509,44 +3521,44 @@ ulong bootcode[]={ 0x00000810, 0x24210030, 0xa0410000, - 0x0800117c, + 0x08001188, 0x24a50001, - 0x24a7ffff, - 0x04e00006, + 0x24a6ffff, + 0x04c00006, 0x00000027, - 0x01070821, + 0x01060821, 0x80210000, 0x20020030, 0x1022000f, 0x00000027, - 0x00073025, - 0x04c0ffb4, + 0x00063825, + 0x04e0ffb4, 0x00000027, - 0x01061021, + 0x01071021, 0x80420000, 0x2001002e, 0x14410005, 0x00000027, - 0x10c7ffad, - 0x00072825, - 0x08001176, + 0x10e6ffad, + 0x00062825, + 0x08001182, 0x24a50001, - 0x080011c1, - 0x24c6ffff, - 0x080011b9, + 0x080011cd, 0x24e7ffff, + 0x080011c5, + 0x24c6ffff, 0x8fa1002c, 0x2002ffff, 0x00413023, 0x04c10002, 0x00000027, - 0x00003025, + 0x000e3025, 0x8fa1002c, 0x200d0068, - 0x08001138, - 0x01215823, - 0x080010cc, - 0x2529ffff, + 0x08001144, + 0x01416023, + 0x080010d8, + 0x254affff, 0x23bdffe4, 0xafbf0000, 0x8fa20020, @@ -3565,7 +3577,7 @@ ulong bootcode[]={ 0x8fa2002c, 0x20030065, 0xafa20014, - 0x0c001049, + 0x0c001055, 0xafa30018, 0x8fa20000, 0x00000027, @@ -3589,7 +3601,7 @@ ulong bootcode[]={ 0x8fa2002c, 0x20030066, 0xafa20014, - 0x0c001049, + 0x0c001055, 0xafa30018, 0x8fa20000, 0x00000027, @@ -3613,7 +3625,7 @@ ulong bootcode[]={ 0x8fa2002c, 0x20030067, 0xafa20014, - 0x0c001049, + 0x0c001055, 0xafa30018, 0x8fa20000, 0x00000027, @@ -3626,7 +3638,7 @@ ulong bootcode[]={ 0x04610008, 0x00000027, 0x00030823, - 0x0c001224, + 0x0c001230, 0xafa10004, 0x8fa20000, 0x23bd0014, @@ -3648,12 +3660,12 @@ ulong bootcode[]={ 0x00032043, 0xafa40010, 0x00641023, - 0x0c001224, + 0x0c001230, 0xafa20004, 0xe7a10008, 0xe7a0000c, 0x8fa10010, - 0x0c001224, + 0x0c001230, 0xafa10004, 0xc7a30008, 0xc7a2000c, @@ -3731,14 +3743,14 @@ ulong bootcode[]={ 0x45010008, 0x00000027, 0x2001ffff, - 0x0c001381, + 0x0c00138d, 0xafa10004, 0x8fa20000, 0x00000027, 0x00400008, 0x23bd0010, 0x20020001, - 0x0c001381, + 0x0c00138d, 0xafa20004, 0x8fa20000, 0x00000027, @@ -3815,7 +3827,7 @@ ulong bootcode[]={ 0x8fa3000c, 0x00000027, 0x00610824, - 0x080012d2, + 0x080012de, 0xafa1000c, 0x23bdfffc, 0x8fa30010, @@ -3927,7 +3939,7 @@ ulong bootcode[]={ 0x00000027, 0xa0c8ffff, 0x24c6ffff, - 0x08001351, + 0x0800135d, 0x24e7ffff, 0x23bdfff4, 0x3c017ff0, @@ -3956,7 +3968,7 @@ ulong bootcode[]={ 0x00000825, 0xe7a50004, 0xe7a40008, - 0x0c001392, + 0x0c00139e, 0xafa0000c, 0x14200005, 0x00000027, @@ -4078,19 +4090,19 @@ ulong bootcode[]={ 0x00000000, 0x001fffff, 0x7fffffff, - 0x00003ef0, 0x00003f20, - 0x00003f68, - 0x00003fb8, - 0x00003fc8, + 0x00003f50, + 0x00003f98, + 0x00003fe8, 0x00003ff8, - 0x00004048, - 0x0000408c, - 0x0000409c, - 0x000040ec, - 0x00004770, - 0x000047d0, - 0x00004830, + 0x00004028, + 0x00004078, + 0x000040bc, + 0x000040cc, + 0x0000411c, + 0x000047a0, + 0x00004800, + 0x00004860, 0x00000000, 0x00000000, 0x00000000, @@ -4343,8 +4355,8 @@ ulong bootcode[]={ 0x08000000, 0x00000000, 0x00000000, - 0x00043e0, + 0x0004410, 0x, - 0x00043e0, + 0x0004410, 0x, }; diff --git a/power/conf.h b/power/conf.h new file mode 100644 index 0000000000000000000000000000000000000000..72864628be0891b751d47b5bd826f49de39a099e --- /dev/null +++ b/power/conf.h @@ -0,0 +1,18 @@ + conf.nmach = 4 ; + conf.nmod = 2000 ; + conf.nalarm = 10000 ; + conf.norig = 500 ; + conf.nchan = 500 ; + conf.nenv = 400 ; + conf.nenvchar = 20000 ; + conf.npgenv = 400 ; + conf.nmtab = 100 ; + conf.nmount = 500 ; + conf.nmntdev = 30 ; + conf.nmntbuf = 60 ; + conf.nmnthdr = 60 ; + conf.nstream = 512 ; + conf.nsrv = 32 ; + conf.nproc = 193 ; + conf.npgrp = 100 ; + diff --git a/power/fns.h b/power/fns.h index a5cd30d2a902cdeea2e70117d30a29208071f4e2..cd4f9c3ad348999346605baaa2c54d825a495766 100644 --- a/power/fns.h +++ b/power/fns.h @@ -2,6 +2,7 @@ Alarm *alarm(int, void (*)(Alarm*), void*); void alarminit(void); Block *allocb(ulong); void append(List**, List*); +void arginit(void); void cancel(Alarm*); int canlock(Lock*); int canqlock(QLock*); @@ -64,7 +65,7 @@ Block *getq(Queue*); void gettlb(int, ulong*); ulong gettlbvirt(int); void gotolabel(Label*); -void gotopc(void*); +void gotopc(ulong); void growpte(Orig*, ulong); void *ialloc(ulong, int); int incref(Ref*); diff --git a/power/l.s b/power/l.s index e17d3b82d2e3af9b6b5eddb5b1b6adc453bd0915..324bb3d3eadabcac0c4d98f431186ab54bba6169 100644 --- a/power/l.s +++ b/power/l.s @@ -50,6 +50,9 @@ clrbss: ADDU $1, R1 BNE R1, R2, clrbss + MOVW R4, _argc(SB) + MOVW R5, _argv(SB) + MOVW R6, _env(SB) JAL main(SB) JMP (R0) diff --git a/power/main.c b/power/main.c index 9317bd0af4f08bc269225c1703d4918cbc300aed..46a40b55ae05e7502d6b7500bd2910bc24a157a2 100644 --- a/power/main.c +++ b/power/main.c @@ -7,11 +7,22 @@ #include "ureg.h" #include "init.h" +/* + * args passed by boot process + */ +int _argc; char **_argv; char **_env; + +char *argv[5]; +char argx[4][64]; + void main(void) { + int i; + active.exiting = 0; active.machs = 1; + arginit(); machinit(); confinit(); lockinit(); @@ -32,6 +43,20 @@ main(void) schedinit(); } +void +arginit(void) +{ + int i; + + if(_argc > 5) + _argc = 5; + + for(i = 1; i < _argc; i++){ + strcpy(argx[i-1], _argv[i]); + argv[i-1] = &(argx[i-1][0]); + } +} + void machinit(void) { @@ -142,12 +167,14 @@ launchinit(void) void init0(void) { + int i; + m->proc = u->p; u->p->state = Running; u->p->mach = m; spllo(); chandevinit(); - + u->slash = (*devtab[0].attach)(0); u->dot = clone(u->slash, 0); @@ -352,11 +379,10 @@ confinit(void) { long x, i, j, *l; - conf.nmach = 4; +#include "conf.h" + if(conf.nmach > MAXMACH) panic("confinit"); - conf.nproc = 193; - conf.npgrp = 100; x = 0x12345678; for(i=4; i<128; i+=4){ @@ -369,22 +395,7 @@ confinit(void) x += 0x3141526; } conf.npage = i*1024/4; - - conf.npte = 4*conf.npage; - conf.nmod = 2000; - conf.nalarm = 10000; - conf.norig = 500; - conf.nchan = 500; - conf.nenv = 400; - conf.nenvchar = 20000; - conf.npgenv = 400; - conf.nmtab = 100; - conf.nmount = 500; - conf.nmntdev = 30; - conf.nmntbuf = 60; - conf.nmnthdr = 60; - conf.nstream = 512; + conf.npte = 4 * conf.npage; conf.nqueue = 5 * conf.nstream; conf.nblock = 16 * conf.nstream; - conf.nsrv = 32; }