From eda43993dd44522ae609ec1af1629c7051f8d25a Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sat, 4 Jul 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-07-04 --- port/devbit.c | 59 +++++++++++++++++++++++++++++++++++++++++-------- port/devcons.c | 3 +++ port/portfns.h | 1 + ss/faultsparc.c | 12 ++++++++-- 4 files changed, 64 insertions(+), 11 deletions(-) diff --git a/port/devbit.c b/port/devbit.c index df7c14113c81772a76acfb78e1307b8a4ff819ec..94ec62b7e8b497d39e070dd0e1215d5296a7e431 100644 --- a/port/devbit.c +++ b/port/devbit.c @@ -172,6 +172,43 @@ Dirtab bitdir[]={ #define NINFO 8192 /* max chars per subfont; sanity check only */ #define HDR 3 +void +bitdebug(void) +{ + int i; + long l; + Arena *a; + + l = 0; + for(i=0; iwords){ + l += a->nwords; + print("%d: %ld used; %ld total\n", i, + (a->wfree-a->words)*sizeof(ulong), + a->nwords*sizeof(ulong)); + } + } + print("arena: %ld words\n", l*sizeof(ulong)); + l = 0; + for(i=0; iqid[0], bit.subfont[i]->qid[1]); + l++; + } + print("%d subfonts\n", l); +} + void bitreset(void) { @@ -891,8 +928,10 @@ bitwrite(Chan *c, void *va, long n, ulong offset) if(j == i) continue; tf = bit.subfont[j]; - if(tf && tf->qid[0]==f->qid[0] && tf->qid[1]==f->qid[1]) + if(tf && tf->qid[0]==f->qid[0] && tf->qid[1]==f->qid[1]){ f->qid[0] = ~0; /* uncached */ + break; + } } f->ref = 1; v = BGSHORT(p+5); @@ -1173,7 +1212,8 @@ bitwrite(Chan *c, void *va, long n, ulong offset) case 'v': /* - * clear font cache and bitmap + * clear font cache and bitmap. + * if error, font is unchanged. * 'v' 1 * id 2 * ncache 2 @@ -1185,6 +1225,14 @@ bitwrite(Chan *c, void *va, long n, ulong offset) t = BGSHORT(p+3); if(t<0 || v<0 || v>=bit.nfont || (ff=bit.font[v])==0) error(Ebadblt); + x = BGSHORT(p+5); + i = bitalloc(Rect(0, 0, t*x, ff->height), ff->ldepth); + /* now committed */ + if(ff->b) + bitfree(ff->b); + ff->b = bit.map[i]; + bit.map[i] = 0; /* disconnect it from GBitmap space */ + ff->width = x; /* * memset not necessary but helps avoid * confusion if the cache is mishandled by the @@ -1197,13 +1245,6 @@ bitwrite(Chan *c, void *va, long n, ulong offset) ff->cache = smalloc(t*sizeof(ff->cache[0])); ff->ncache = t; } - if(ff->b) - bitfree(ff->b); - ff->width = BGSHORT(p+5); - ff->b = 0; - i = bitalloc(Rect(0, 0, t*ff->width, ff->height), ff->ldepth); - ff->b = bit.map[i]; - bit.map[i] = 0; /* disconnect it from GBitmap space */ p += 7; m -= 7; break; diff --git a/port/devcons.c b/port/devcons.c index de36bde7c5626203d1891dda1f6a6101a14924c4..c60e34841ff490fedcf7277022efa73628e30359 100644 --- a/port/devcons.c +++ b/port/devcons.c @@ -231,6 +231,9 @@ echo(Rune r, char *buf, int n) case 'x': xsummary(); break; + case 'b': + bitdebug(); + break; case 'd': consdebug(); return; diff --git a/port/portfns.h b/port/portfns.h index f6910f293d445cc52c6e7f52b07b028a660bf1c2..bc661b4714f0b00bdc0213bb434c73d713d6edea 100644 --- a/port/portfns.h +++ b/port/portfns.h @@ -2,6 +2,7 @@ void alarmkproc(void*); Block* allocb(ulong); int anyready(void); Image* attachimage(int, Chan*, ulong, ulong); +void bitdebug(void); int blen(Block *); int bround(Block *, int); void buzz(int, int); diff --git a/ss/faultsparc.c b/ss/faultsparc.c index 1a735778438a5e7ede7b8186955c17f14f0f48aa..f0e443cfc055961671a9784529e17a68ecef910c 100644 --- a/ss/faultsparc.c +++ b/ss/faultsparc.c @@ -6,13 +6,20 @@ #include "ureg.h" #include "../port/error.h" +enum +{ + SE_WRITE = 0x8000, + SE_INV = 0x0080, + SE_PROT = 0x0040, +}; + void faultsparc(Ureg *ur) { ulong addr, badvaddr; char buf[ERRLEN]; int user, read; - ulong tbr; + ulong tbr, ser; tbr = (ur->tbr&0xFFF)>>4; addr = ur->pc; /* assume instr. exception */ @@ -22,7 +29,8 @@ faultsparc(Ureg *ur) * According to the book, this isn't good enough. We'll see. */ addr = getw2(SEVAR); - if(getw2(SER) & 0x8000) + ser = getw2(SER); + if(ser&(SE_WRITE|SE_PROT)) read = 0; } spllo();