From 8be6d38e85f149b5adb4b8c5c4220a14804f8af5 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Thu, 7 Apr 1994 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1994-04-07 --- carrera/screen.c | 53 +++++++----------------------------------------- carrera/trap.c | 2 +- pc/devvga.c | 10 ++++----- pc/trap.c | 3 ++- port/devproc.c | 6 +++--- port/portdat.h | 4 ++-- port/proc.c | 4 +++- port/systab.h | 2 ++ power/trap.c | 2 +- 9 files changed, 26 insertions(+), 60 deletions(-) diff --git a/carrera/screen.c b/carrera/screen.c index 538d04a12711ffebeb7bdaa9c70514c66bb01dc9..f40afa6771eb3d23b09676c3d7d47a2232f78ed8 100644 --- a/carrera/screen.c +++ b/carrera/screen.c @@ -500,62 +500,23 @@ extern cursorunlock(void); * tile is at location r, first pixel in *data. * tl is length of scan line to insert, * l is amount to advance data after each scan line. + * gscreen.ldepth is known to be >= 3 */ void screenload(Rectangle r, uchar *data, int tl, int l) { uchar *q; - int y, lpart, rpart, mx, m, mr; + int y; if(!rectclip(&r, gscreen.r) || tl<=0) return; lock(&screenlock); - q = gbaddr(&gscreen, r.min); - mx = 7>>gscreen.ldepth; - lpart = (r.min.x & mx) << gscreen.ldepth; - rpart = (r.max.x & mx) << gscreen.ldepth; - m = 0xFF >> lpart; - mr = 0xFF ^ (0xFF >> rpart); - /* may need to do bit insertion on edges */ - if(l == 1){ /* all in one byte */ - if(rpart) - m &= mr; - for(y=r.min.y; y 1) - memmove(q+1, data+1, tl-1); - q += gscreen.width*sizeof(ulong); - data += l; - } - }else if(lpart == 0){ - for(y=r.min.y; y 1) - memmove(q, data, tl-1); - q[tl-1] ^= (data[tl-1]^q[tl-1]) & mr; - q += gscreen.width*sizeof(ulong); - data += l; - } - }else for(y=r.min.y; y 2) - memmove(q+1, data+1, tl-2); - q[tl-1] ^= (data[tl-1]^q[tl-1]) & mr; - q += gscreen.width*sizeof(ulong); - data += l; - } + for(y=r.min.y; yscallnr >= sizeof systab/sizeof systab[0]){ + if(up->scallnr >= nsyscall){ pprint("bad sys call %d pc %lux\n", up->scallnr, ur->pc); postnote(up, 1, "sys: bad sys call", NDebug); error(Ebadarg); diff --git a/pc/devvga.c b/pc/devvga.c index f97ba1839af54f55630501328325b3f19437bfc0..ac0c2b266ee8342c2f743d3159799a17bc54ce46 100644 --- a/pc/devvga.c +++ b/pc/devvga.c @@ -531,7 +531,9 @@ screenload(Rectangle r, uchar *data, int tl, int l) m = 0xFF >> lpart; mr = 0xFF ^ (0xFF >> rpart); /* may need to do bit insertion on edges */ - if(l == 1){ /* all in one byte */ + if(tl <= 0){ + ; + }else if(tl == 1){ /* all in one byte */ if(rpart) m &= mr; for(y=r.min.y; y 1) - memmove(q+1, data+1, tl-1); + memmove(q+1, data+1, tl-1); q += gscreen.width*sizeof(ulong); data += l; } }else if(lpart == 0){ for(y=r.min.y; y 1) - memmove(q, data, tl-1); + memmove(q, data, tl-1); q[tl-1] ^= (data[tl-1]^q[tl-1]) & mr; q += gscreen.width*sizeof(ulong); data += l; diff --git a/pc/trap.c b/pc/trap.c index eaef2c23a67f1a53664ff8997189f4e4c771b327..784bb1c9c4e4ac796a8864d83f649e0a63709475 100644 --- a/pc/trap.c +++ b/pc/trap.c @@ -424,11 +424,12 @@ syscall(Ureg *ur, void *arg) up->nerrlab = 0; ret = -1; if(!waserror()){ - if(up->scallnr >= sizeof systab/BY2WD){ + if(up->scallnr >= nsyscall){ pprint("bad sys call number %d pc %lux\n", up->scallnr, ur->pc); postnote(up, 1, "sys: bad sys call", NDebug); error(Ebadarg); } + up->syscall[up->scallnr]++; if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-(1+MAXSYSARG)*BY2WD)) validaddr(sp, (1+MAXSYSARG)*BY2WD, 0); diff --git a/port/devproc.c b/port/devproc.c index 17af5921c1b95864c574894a2fa66dc52c285d7d..eb244a50ad0baf23b1f7384be91a858596671c73 100644 --- a/port/devproc.c +++ b/port/devproc.c @@ -883,16 +883,16 @@ readcounters(Proc *p, ulong offset, void *va, int n) int i, j, m; extern char *sysctab[]; - bp = smalloc((NSYSCALL+ncounter)*(NAMELEN+8)); + bp = smalloc((nsyscall+ncounter)*(NAMELEN+8)); m = 0; for(i = 0; i < Pcounter; i++) if(counter[i]) m += sprint(bp+m, "%s\t%8d\n", counter[i], p->counter[i]); j = 0; - for(i = 0; i < NSYSCALL; i++) + for(i = 0; i < nsyscall; i++) j += p->syscall[i]; m += sprint(bp+m, "syscall\t%8d\n", j); - for(i = 0; i < NSYSCALL; i++) + for(i = 0; i < nsyscall; i++) if(p->syscall[i]) m += sprint(bp+m, "%s\t%8d\n", sysctab[i], p->syscall[i]); n = readstr(offset, va, n, bp); diff --git a/port/portdat.h b/port/portdat.h index 947c13cd6974d0ba7c38507c50b094b8874dce69..5c287bec0719fd5de14ba779b04a09113879870f 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -487,7 +487,6 @@ enum NERR = 15, NNOTE = 5, - NSYSCALL = 39, /* MUST be equal to the real thing!!!! */ Pcounter = 6, /* per process counters */ CSCNTR = 0, /* sched counter */ FAULTCNTR = 1, /* fault counter */ @@ -579,7 +578,7 @@ struct Proc /* statistics */ ulong counter[Pcounter]; /* specialized per process counters */ - ulong syscall[NSYSCALL]; + ulong *syscall; /* * machine specific MMU @@ -694,3 +693,4 @@ enum extern int mouseshifted; extern int mousetype; extern int mouseswap; +extern int nsyscall; diff --git a/port/proc.c b/port/proc.c index 1695759852b340a949639e87869f287698530bde..edb205b8c01d13ab6e7f671d1bc7ed4ce7044e35 100644 --- a/port/proc.c +++ b/port/proc.c @@ -273,8 +273,10 @@ procinit0(void) /* bad planning - clashes with devproc.c */ procalloc.arena = procalloc.free; p = procalloc.free; - for(i=0; iqnext = p+1; + p->syscall = xalloc(nsyscall * sizeof(ulong)); + } p->qnext = 0; } diff --git a/port/systab.h b/port/systab.h index cfd4f459e5ad7e453688d6d6b735eed02e1c5e3e..c87fe9ddd82010f8b542dce835eb16f36047fb95 100644 --- a/port/systab.h +++ b/port/systab.h @@ -127,3 +127,5 @@ char *sysctab[]={ [WRITE9P] "Write9p", [READ9P] "Read9p", }; + +int nsyscall = (sizeof systab/sizeof systab[0]); diff --git a/power/trap.c b/power/trap.c index c533e044d2f96b1c3af205a03f9cbec66cbc45d4..a5fa9ddbf83dd6e8c96cbd02dc73c30f163f29bd 100644 --- a/power/trap.c +++ b/power/trap.c @@ -512,7 +512,7 @@ syscall(Ureg *aur) sp = ur->sp; ret = -1; if(!waserror()){ - if(up->scallnr >= sizeof systab/sizeof systab[0]) { + if(up->scallnr >= nsyscall) { pprint("bad sys call number %d pc %lux\n", up->scallnr, ur->pc); postnote(up, 1, "sys: bad sys call", NDebug);