From 2945f0e32ffcc47309a45613a90e8e86a67d2074 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 18 Jun 1999 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1999-06-18 --- boot/key.c | 3 +++ boot/sac.c | 8 +------- ip/esp.c | 10 +++++----- mpc/devrtc.c | 2 +- mpc/main.c | 41 ++++++++++++++++++++++------------------- mpc/mem.h | 2 +- port/devtinyfs.c | 12 ++++++------ port/portdat.h | 2 +- 8 files changed, 40 insertions(+), 40 deletions(-) diff --git a/boot/key.c b/boot/key.c index 3a894adb3feda010944dfbd3c1c00c131ac11799..b05bd463a5956f4151a931ea1348db43c3da7893 100644 --- a/boot/key.c +++ b/boot/key.c @@ -83,6 +83,9 @@ key(int islocal, Method *mp) } close(fd); +//fprint(2, "hostowner = %s\n", safe->authid); +//fprint(2, "hostdomain = %s\n", safe->authdom); + /* set host's key */ if(writefile("#c/key", safe->machkey, DESKEYLEN) < 0) fatal("#c/key"); diff --git a/boot/sac.c b/boot/sac.c index da7c724b29e093b4e111b399b9fb7629d09fa2cc..5cd225b8e65a9f88e103fb1bc2b518a9c2962b56 100644 --- a/boot/sac.c +++ b/boot/sac.c @@ -15,7 +15,6 @@ configsac(Method *mp) USED(mp); -print("configsac\n"); /* * create the name space, mount the root fs */ @@ -24,6 +23,7 @@ print("configsac\n"); if(bind("#C", "/", MAFTER) < 0) fatal("bind /"); + // fixed sysname - enables correct namespace file fd = open("#c/sysname", OWRITE); if(fd < 0) fatal("open sysname"); @@ -36,12 +36,6 @@ print("configsac\n"); write(fd, "brick", 5); close(fd); - bargc = parsefields("-n 135.104.9.69 255.255.255.0 135.104.9.1 " - "135.104.9.69 135.104.9.69", bargv, Nbarg-1, " "); - configip("ether0"); - - // fixed sysname - enables correct cpurc and namespace files - // to be used sprint(cmd, "/%s/init", cputype); execl(cmd, "init", "-c", 0); diff --git a/ip/esp.c b/ip/esp.c index 166d4e82aa67706057ce2b26426008725b79c98e..81300ddd3b9d934371b1f76e50bc3f3190c38fde 100644 --- a/ip/esp.c +++ b/ip/esp.c @@ -352,7 +352,7 @@ espiput(Proto *esp, uchar*, Block *bp) bp = concatblock(bp); if(BLEN(bp) < EsphdrSize + ecb->espivlen + EsptailSize + ecb->ahlen) { - qunlock(esp); + qunlock(c); netlog(f, Logesp, "esp: short block %I -> %I!%d\n", raddr, laddr, spi); freeb(bp); @@ -362,7 +362,7 @@ espiput(Proto *esp, uchar*, Block *bp) eh = (Esphdr*)(bp->rp); auth = bp->wp - ecb->ahlen; if(!ecb->auth(ecb, eh->espspi, auth-eh->espspi, auth)) { - qunlock(esp); + qunlock(c); print("esp: bad auth %I -> %I!%ld\n", raddr, laddr, spi); netlog(f, Logesp, "esp: bad auth %I -> %I!%d\n", raddr, laddr, spi); @@ -372,14 +372,14 @@ print("esp: bad auth %I -> %I!%ld\n", raddr, laddr, spi); payload = BLEN(bp)-EsphdrSize-ecb->ahlen; if(payload<=0 || payload%4 != 0 || payload%ecb->espblklen!=0) { - qunlock(esp); + qunlock(c); netlog(f, Logesp, "esp: bad length %I -> %I!%d payload=%d BLEN=%d\n", raddr, laddr, spi, payload, BLEN(bp)); freeb(bp); return; } if(!ecb->cipher(ecb, bp->rp+EsphdrSize, payload)) { - qunlock(esp); + qunlock(c); print("esp: cipher failed %I -> %I!%ld: %r\n", raddr, laddr, spi); netlog(f, Logesp, "esp: cipher failed %I -> %I!%d: %r\n", raddr, laddr, spi); @@ -392,7 +392,7 @@ print("esp: cipher failed %I -> %I!%ld: %r\n", raddr, laddr, spi); payload -= et->pad + ecb->espivlen; nexthdr = et->nexthdr; if(payload <= 0) { - qunlock(esp); + qunlock(c); netlog(f, Logesp, "esp: short packet after decrypt %I -> %I!%d\n", raddr, laddr, spi); freeb(bp); diff --git a/mpc/devrtc.c b/mpc/devrtc.c index 82bcf109e18ad812f88388c28a97aa1189188956..718de8eb44ae2a2da16457fab6426cb22898070a 100644 --- a/mpc/devrtc.c +++ b/mpc/devrtc.c @@ -22,7 +22,7 @@ enum{ Nvoff= 4*1024, /* where usable nvram lives */ Nvsize= 4*1024, - Nvoff2= 8*1024, /* where usable nvram lives */ + Nvoff2= 8*1024, /* where second usable nvram lives */ Nvsize2= 4*1024, }; diff --git a/mpc/main.c b/mpc/main.c index 6d8929318f67a8770a20d0b65daeebf645c17a1c..19e4e6fe5ccd6d78fd10343a4488f15efdba57a9 100644 --- a/mpc/main.c +++ b/mpc/main.c @@ -15,6 +15,14 @@ int nconf; int predawn = 1; +typedef struct Bootargs Bootargs; + +struct Bootargs +{ + char args[1000]; + uchar chksum; +}; + Conf conf; static void options(void); @@ -31,22 +39,10 @@ main(void) cpminit(); uartinstall(); mmuinit(); -if(0) { - predawn = 0; - print("spllo() = %ux\n", spllo()); - for(;;) { - print("hello\n"); - delay(1000); - } -} + // turn on pcmcia *(uchar*)(NVRAMMEM+0x100001) |= 0x60; -//print("sr1=%ux sr2=%ux\n", *(uchar*)(NVRAMMEM+0x100000), *(uchar*)(NVRAMMEM+0x100001)); -//print("sccr=%ulx\n", m->iomem->sccr); -print("%ux %ux\n", m->iomem->memc[0].base, m->iomem->memc[7].base); -print("%ux %ux\n", m->iomem->memc[0].option, m->iomem->memc[7].option); -print("%ux\n", *(uchar*)(0xff000000)); pageinit(); procinit0(); initseg(); @@ -81,8 +77,10 @@ machinit(void) *(ushort*)&(io->memc[4].base) = 0x8060; // *(ushort*)&(io->memc[7].option) = 0xffe0; *(ushort*)&(io->memc[7].base) = 0xff00; + } + void bootargs(ulong base) { @@ -278,7 +276,7 @@ confinit(void) conf.npage = conf.npage0 + conf.npage1; - conf.upages = (conf.npage*50)/100; + conf.upages = (conf.npage*60)/100; conf.ialloc = ((conf.npage-conf.upages)/2)*BY2PG; /* set up other configuration parameters */ @@ -312,10 +310,7 @@ getcfields(char* lp, char** fields, int n, char* sep) static char BOOTARGS[] = "ether0=type=SCC port=1 ea=08003e27df94\r\n" - "ether1=type=589E port=0x300\r\n" - "vgasize=640x480x8\r\n" - "kernelpercent=40\r\n" - "console=0 lcd\r\nbaud=9600\r\n"; + "ether1=type=589E port=0x300\r\n"; static void options(void) @@ -323,11 +318,18 @@ options(void) long i, n; char *cp, *p, *q; char *line[MAXCONF]; + Bootargs *ba; /* * parse configuration args from dos file plan9.ini */ - cp = BOOTARGS; /* where b.com leaves its config */ + ba = (Bootargs*)(NVRAMMEM+ 4*1024); + if(ba->chksum == nvcsum(ba->args, sizeof(ba->args))) { + cp = smalloc(strlen(ba->args)+1); + memmove(cp, ba->args, strlen(ba->args)+1); + } else + cp = BOOTARGS; +print("bootargs = %s\n", cp); /* * Strip out '\r', change '\t' -> ' '. @@ -435,3 +437,4 @@ cistrcmp(char *a, char *b) } return 0; } + diff --git a/mpc/mem.h b/mpc/mem.h index ac05753f9e996112db78b717e1d76d92345ab3e1..be4e875a60f6761e035cbaf9ded084624e1f6e3a 100644 --- a/mpc/mem.h +++ b/mpc/mem.h @@ -176,7 +176,7 @@ #define INTMEM 0x80000000 #define ISAMEM 0x80100000 #define FLASHMEM 0xff000000 -#define SACMEM FLASHMEM + 0x40000 +#define SACMEM FLASHMEM + 0x80000 #define NVRAMMEM 0x80600000 #define DRAMMEM 0xff800000 /* to 0xffffffff: 8 Meg */ diff --git a/port/devtinyfs.c b/port/devtinyfs.c index 39ca3b8c34f0f6c1de06b0f59607db19f3cd7277..054cf8cec594bab6b5aab9ab38170e2492be2b76 100644 --- a/port/devtinyfs.c +++ b/port/devtinyfs.c @@ -460,7 +460,7 @@ tinyfsgen(Chan *c, Dirtab *tab, int ntab, int i, Dir *dp) return 0; qid.path = i; qid.vers = 0; - devdir(c, qid, f->name, f->length, eve, 0664, dp); + devdir(c, qid, f->name, f->length, eve, 0775, dp); return 1; } @@ -480,13 +480,12 @@ tinyfsattach(void *spec) Tfs *fs; Chan *c; volatile struct { Chan *cc; } rock; - int i, fd; + int i; + char buf[NAMELEN*2]; - fd = atoi(spec); - if(fd < 0) - error("bad specifier"); + snprint(buf, sizeof(buf), "/dev/%s", spec); + rock.cc = namec(buf, Aopen, ORDWR, 0); - rock.cc = fdtochan(fd, ORDWR, 0, 1); if(waserror()){ cclose(rock.cc); nexterror(); @@ -594,6 +593,7 @@ tinyfsopen(Chan *c, int omode) c->qid.path = f - rock.fs->f; break; case OREAD: + case OEXEC: break; default: error(Eperm); diff --git a/port/portdat.h b/port/portdat.h index 4c35a2c8fa3defd3036dc6c3ce443eb992b7cbdf..bb86ea00c7181b8b10415797bbe533a563e4bcf9 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -744,7 +744,7 @@ struct Logflag { struct Cmdbuf { - char buf[64]; + char buf[256]; char *f[16]; int nf; };