From 2b4fb1362e000598f8cbe65b7db8d186afa38eb6 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Mon, 20 Jul 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-07-20 --- gnot/main.c | 7 +++++-- port/alloc.c | 41 ++++++++++++++++++++++++++++++++++------- port/devbit.c | 28 ++++++++++++++++++++++++---- port/devip.c | 3 ++- port/sysfile.c | 20 ++++++++++---------- port/systab.h | 19 ++++++++++--------- ss/main.c | 1 + ss/trap.c | 1 - 8 files changed, 86 insertions(+), 34 deletions(-) diff --git a/gnot/main.c b/gnot/main.c index 0a153d173015d5e7f38b995d47dbdfdf4a764aa9..08a35fc5c9f583d8abc9c60327babea8b5b8b24d 100644 --- a/gnot/main.c +++ b/gnot/main.c @@ -302,7 +302,7 @@ Conf conf; void confinit(void) { - int mul; + int mul, pcnt; ulong ktop; conf.nmach = 1; @@ -315,7 +315,10 @@ confinit(void) conf.npage1 = (bank[1]*MB)/BY2PG; conf.base1 = 16*MB; conf.npage = conf.npage0+conf.npage1; - conf.upages = (conf.npage*70)/100; + + pcnt = screenbits()-1; /* Calculate % of memory for page pool */ + pcnt = 70 - (pcnt*10); + conf.upages = (conf.npage*pcnt)/100; ktop = PGROUND((ulong)end); ktop = PADDR(ktop); diff --git a/port/alloc.c b/port/alloc.c index b3dae245f2a757f664c52a3d87040f79fd956452..513312322d2e32d68d37a919b5eaaca59e6bc5fd 100644 --- a/port/alloc.c +++ b/port/alloc.c @@ -21,6 +21,7 @@ enum { Maxpow = 18, + CUTOFF = 12, Nhole = 128, Magichole = 0xDeadBabe, Magic2n = 0xFeedBeef, @@ -134,7 +135,7 @@ xspanalloc(ulong size, int align, ulong span) for(i = 0; i < Spanlist; i++) { p = (ulong)xalloc(size+align); if(p == 0) - panic("xspanalloc: size %d align %d span %lux", size, align, span); + panic("xspanalloc: %d %d %lux", size, align, span); a = p+align; a &= ~(align-1); @@ -256,8 +257,9 @@ xhole(ulong addr, ulong size) void* malloc(ulong size) { - int pow; - Bucket *bp; + ulong next; + int pow, n; + Bucket *bp, *nbp; for(pow = 3; pow <= Maxpow; pow++) if(size <= (1<data, 0, size); return bp->data; } - arena.nbuck[pow]++; unlock(&arena); + size = sizeof(Bucket)+(1<next = (Bucket*)next; + nbp->size = pow; + nbp = nbp->next; + } + nbp->size = pow; + unlock(&arena); + } + else { + bp = xalloc(size); + if(bp == nil) + return nil; + } bp->size = pow; bp->magic = Magic2n; diff --git a/port/devbit.c b/port/devbit.c index cd95bd0ecda6dd0de1b5f9946d939426e1156ef1..9efd84b75bcfac563fa2ae164e8069ea8d50a190 100644 --- a/port/devbit.c +++ b/port/devbit.c @@ -75,6 +75,7 @@ struct int nsubfont; /* number allocated */ Arena *arena; /* array */ int narena; /* number allocated */ + int mouseopen; /* flag: mouse open */ int bid; /* last allocated bitmap id */ int subfid; /* last allocated subfont id */ int cacheid; /* last cached subfont id */ @@ -326,10 +327,22 @@ bitopen(Chan *c, int omode) { GBitmap *b; - if(c->qid.path == CHDIR){ + switch(c->qid.path){ + case CHDIR: if(omode != OREAD) error(Eperm); - }else if(c->qid.path == Qbitblt){ + break; + case Qmouse: + lock(&bit); + if(bit.mouseopen){ + unlock(&bit); + error(Einuse); + } + bit.mouseopen = 1; + bit.ref++; + unlock(&bit); + break; + case Qbitblt: lock(&bit); if(bit.ref){ unlock(&bit); @@ -352,8 +365,10 @@ bitopen(Chan *c, int omode) bit.ref = 1; Cursortocursor(&arrow); unlock(&bit); - }else + break; + default: incref(&bit); + } c->mode = openmode(omode); c->flag |= COPEN; c->offset = 0; @@ -390,6 +405,8 @@ bitclose(Chan *c) if(c->qid.path!=CHDIR && (c->flag&COPEN)){ lock(&bit); + if(c->qid.path == Qmouse) + bit.mouseopen = 0; if(--bit.ref == 0){ ebp = &bit.map[bit.nmap]; for(bp = bit.map; bptop; rect.max.y = c->bottom; - } + }else if(c->left > 0) + gbitblt(bp, pt, f->b, + Rect(pt.x, pt.y, pt.x+c->left, pt.y+f->height), + fc==S? 0 : F); rect.min.x = c->x; rect.max.x = c->xright; gbitblt(bp, Pt(pt.x+c->left, pt.y+rect.min.y), f->b, rect, fc); diff --git a/port/devip.c b/port/devip.c index 7e6e207b04cbb7deeb7419a74d4553bc8eff45ca..e616750400b22496a0fde0096a4314967d328744 100644 --- a/port/devip.c +++ b/port/devip.c @@ -745,7 +745,8 @@ ipstatusfill(Chan *c, char *buf, int len) ilstate[cp->ilctl.state], cp->ilctl.rtt, cp->ifc ? cp->ifc->chkerrs : 0); else - sprint(buf, "%s/%d %d\n", cp->ifc->protop->name, connection, cp->ref); + sprint(buf, "%s/%d %d Datagram\n", + cp->ifc->protop->name, connection, cp->ref); } int diff --git a/port/sysfile.c b/port/sysfile.c index 38c73c936baef8809b7435afe62629559e40925f..46dd443a12ae3e2c047800d3b905df7e6b7c4670 100644 --- a/port/sysfile.c +++ b/port/sysfile.c @@ -26,7 +26,7 @@ newfd(Chan *c) } unlock(f); exhausted("file descriptors"); - return 0; /* not reached */ + return 0; } Chan* @@ -194,10 +194,11 @@ sysclose(ulong *arg) long unionread(Chan *c, void *va, long n) { - Chan *nc; - Pgrp *pg = u->p->pgrp; long nr; + Chan *nc; + Pgrp *pg; + pg = u->p->pgrp; rlock(&pg->ns); for(;;) { @@ -208,17 +209,17 @@ unionread(Chan *c, void *va, long n) nc = clone(c->mnt->to, 0); poperror(); - if(c->mountid != c->mnt->mountid){ + if(c->mountid != c->mnt->mountid) { pprint("unionread: changed underfoot?\n"); runlock(&pg->ns); close(nc); return 0; } - if(waserror()){ - runlock(&pg->ns); + /* Error causes component of union to be skipped */ + if(waserror()) { close(nc); - nexterror(); + goto next; } nc = (*devtab[nc->type].open)(nc, OREAD); @@ -233,9 +234,8 @@ unionread(Chan *c, void *va, long n) runlock(&pg->ns); return nr; } - /* - * Advance to next element - */ + /* Advance to next element */ + next: c->mnt = c->mnt->next; if(c->mnt == 0) break; diff --git a/port/systab.h b/port/systab.h index 5de5f87af2f72b19fb5e650303eb951ce6cc72be..0c89c102c0f9806f2b8593aa0bfe3a37e578e2e6 100644 --- a/port/systab.h +++ b/port/systab.h @@ -12,8 +12,8 @@ Syscall sysdup; Syscall sysalarm; Syscall sysexec; Syscall sysexits; -Syscall sysdeath; -Syscall sysdeath; +Syscall sys_x1; +Syscall sys_x2; Syscall sysfstat; Syscall syssegbrk; Syscall sysmount; @@ -26,7 +26,7 @@ Syscall sysrfork; Syscall syswrite; Syscall syspipe; Syscall syscreate; -Syscall sysdeath; +Syscall sys_x3; Syscall sysbrk_; Syscall sysremove; Syscall syswstat; @@ -40,6 +40,7 @@ Syscall syssegflush; Syscall sysrendezvous; Syscall sysunmount; Syscall syswait; +Syscall sysdeath; Syscall *systab[]={ [SYSR1] sysr1, @@ -51,8 +52,8 @@ Syscall *systab[]={ [ALARM] sysalarm, [EXEC] sysexec, [EXITS] sysexits, - [__FORK__] sysdeath, - [__FORKPGRP__] sysdeath, + [_X1] sysdeath, + [_X2] sysdeath, [FSTAT] sysfstat, [SEGBRK] syssegbrk, [MOUNT] sysmount, @@ -65,7 +66,7 @@ Syscall *systab[]={ [WRITE] syswrite, [PIPE] syspipe, [CREATE] syscreate, - [__RFORK__] sysdeath, + [_X3] sysdeath, [BRK_] sysbrk_, [REMOVE] sysremove, [WSTAT] syswstat, @@ -91,8 +92,8 @@ char *sysctab[]={ [ALARM] "Alarm", [EXEC] "Exec", [EXITS] "Exits", - [__FORK__] "__fork_", - [__FORKPGRP__] "__forkpgrp_", + [_X1] "_x1", + [_X2] "_x2", [FSTAT] "Fstat", [SEGBRK] "Segbrk", [MOUNT] "Mount", @@ -105,7 +106,7 @@ char *sysctab[]={ [WRITE] "Write", [PIPE] "Pipe", [CREATE] "Create", - [__RFORK__] "__rfork_", + [_X3] "_x3", [BRK_] "Brk", [REMOVE] "Remove", [WSTAT] "Wstat", diff --git a/ss/main.c b/ss/main.c index 39dbb9d7143b835b183064f70fb072a5fc976117..0fe0cf597592c90e2ef585eeb341b4bc3e60651d 100644 --- a/ss/main.c +++ b/ss/main.c @@ -133,6 +133,7 @@ userinit(void) strcpy(p->text, "*init*"); strcpy(p->user, eve); savefpregs(&initfp); +/* initfp.fsr |= 0x1E << 23; /* trap on all but INEXACT */ p->fpstate = FPinit; /* diff --git a/ss/trap.c b/ss/trap.c index 5045a33ebe1a5db799064a20dce74a6792efe3b5..834f8afc391efe41c3264f032b5dffdbf8006b29 100644 --- a/ss/trap.c +++ b/ss/trap.c @@ -346,7 +346,6 @@ noted(Ureg **urp, ulong arg0) long syscall(Ureg *aur) { - int i; long ret; ulong sp; Ureg *ur;