M port/devbit.c => port/devbit.c +50 -9
@@ 173,6 173,43 @@ Dirtab bitdir[]={
#define HDR 3
void
+bitdebug(void)
+{
+ int i;
+ long l;
+ Arena *a;
+
+ l = 0;
+ for(i=0; i<bit.narena; i++){
+ a = &bit.arena[i];
+ if(a->words){
+ 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; i<bit.nmap; i++)
+ if(bit.map[i])
+ l++;
+ print("%d bitmaps ", l);
+ l = 0;
+ for(i=0; i<bit.nfont; i++)
+ if(bit.font[i])
+ l++;
+ print("%d fonts ", l);
+ l = 0;
+ for(i=0; i<bit.nsubfont; i++)
+ if(bit.subfont[i]){
+ print("%d: %lux %lux ", i, bit.subfont[i]->qid[0], bit.subfont[i]->qid[1]);
+ l++;
+ }
+ print("%d subfonts\n", l);
+}
+
+void
bitreset(void)
{
int i;
@@ 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;
M port/devcons.c => port/devcons.c +3 -0
@@ 231,6 231,9 @@ echo(Rune r, char *buf, int n)
case 'x':
xsummary();
break;
+ case 'b':
+ bitdebug();
+ break;
case 'd':
consdebug();
return;
M port/portfns.h => port/portfns.h +1 -0
@@ 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);
M ss/faultsparc.c => ss/faultsparc.c +10 -2
@@ 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();