From 135a573359f57ac2c7895be94367603f057723d4 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sun, 2 Sep 1990 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1990-09-02 --- gnot/l.s | 5 ++++ gnot/proc.c | 12 +++++++++ gnot/screen.c | 16 ++++++------ gnot/vec.s | 2 +- port/devbit.c | 68 +++++++++++++++++++++++++-------------------------- 5 files changed, 60 insertions(+), 43 deletions(-) diff --git a/gnot/l.s b/gnot/l.s index a4f7436699937812f00d2b6f03a096055ea1681f..c010e18879fbf7df402520b3615f4661a8cbf717 100644 --- a/gnot/l.s +++ b/gnot/l.s @@ -70,6 +70,11 @@ TEXT flushcpucache(SB), $0 MOVL R0, CACR RTS +TEXT cacrtrap(SB), $0 /* user entry point to control cache, e.g. flush */ + + MOVL R0, CACR + RTE + TEXT setlabel(SB), $0 MOVL sr+0(FP), A0 diff --git a/gnot/proc.c b/gnot/proc.c index 434071271cbbd515fb38d3597d29720538d3ac47..16230e9fcd58a080e2500b35988322739b5e65d9 100644 --- a/gnot/proc.c +++ b/gnot/proc.c @@ -5,6 +5,8 @@ #include "fns.h" #include "errno.h" +#include + struct { Lock; @@ -79,15 +81,23 @@ sched(void) ulong tlbvirt, tlbphys; void (*f)(ulong); long fpnull = 0; + Balu balu; if(u){ splhi(); + fpsave(&u->fpsave); if(u->fpsave.type){ fpregsave(u->fpsave.reg); u->p->fpstate = FPactive; m->fpstate = FPdirty; } + if(BALU->cr0 != 0xFFFFFFFF) /* balu busy */ + memcpy(&balu, BALU, sizeof balu); + else{ + balu.cr0 = 0xFFFFFFFF; + BALU->cr0 = 0xFFFFFFFF; + } if(setlabel(&u->p->sched)){ /* woke up */ if(u->p->mach)panic("mach non zero"); p = u->p; @@ -105,6 +115,8 @@ if(u->p->mach)panic("mach non zero"); m->fpstate = FPdirty; } } + if(balu.cr0 != 0xFFFFFFFF) /* balu busy */ + memcpy(BALU, &balu, sizeof balu); spllo(); return; } diff --git a/gnot/screen.c b/gnot/screen.c index d754b0ecdc4197f7fa22899d6b6f919a8f2a018b..c20646fb98f41a09eba16b7b5e31f84d2de216ad 100644 --- a/gnot/screen.c +++ b/gnot/screen.c @@ -7,13 +7,13 @@ #include "ureg.h" #include "errno.h" -#include "gnot.h" +#include #define MINX 8 -extern Font defont0; -extern Font defont1; -Font *defont; +extern GFont defont0; +extern GFont defont1; +GFont *defont; struct{ Point pos; @@ -24,7 +24,7 @@ void duartinit(void); int duartacr; int duartimr; -Bitmap screen = +GBitmap screen = { (ulong*)((4*1024*1024-256*1024)|KZERO), /* BUG */ 0, @@ -46,7 +46,7 @@ screeninit(void) defont = &defont1; }else defont = &defont0; - bitblt(&screen, Pt(0, 0), &screen, screen.r, 0); + gbitblt(&screen, Pt(0, 0), &screen, screen.r, 0); out.pos.x = MINX; out.pos.y = 0; out.bwid = defont0.info[' '].width; @@ -63,7 +63,7 @@ screenputc(int c) out.pos.y += defont0.height; if(out.pos.y > screen.r.max.y-defont0.height) out.pos.y = screen.r.min.y; - bitblt(&screen, Pt(0, out.pos.y), &screen, + gbitblt(&screen, Pt(0, out.pos.y), &screen, Rect(0, out.pos.y, screen.r.max.x, out.pos.y+2*defont0.height), 0); }else if(c == '\t'){ out.pos.x += (8-((out.pos.x-MINX)/out.bwid&7))*out.bwid; @@ -80,7 +80,7 @@ screenputc(int c) screenputc('\n'); buf[0] = c&0x7F; buf[1] = 0; - out.pos = string(&screen, out.pos, defont, buf, S); + out.pos = gstring(&screen, out.pos, defont, buf, S); } } diff --git a/gnot/vec.s b/gnot/vec.s index 87215255b1dd4134c3d26cbd69bf4adaa6ca9fb4..5ea0e2b41222f73f2c2c1fcb66b635a1db64fef9 100644 --- a/gnot/vec.s +++ b/gnot/vec.s @@ -39,7 +39,7 @@ TEXT vectors0<>(SB), $0 LONG illegal(SB) /* level 7 autovector */ /* origin 0080, vector 32 */ LONG systrap(SB) /* trap #0 */ - LONG illegal(SB) /* trap #1 */ + LONG cacrtrap(SB) /* trap #1 */ LONG illegal(SB) /* trap #2 */ LONG illegal(SB) /* trap #3 */ LONG illegal(SB) /* trap #4 */ diff --git a/port/devbit.c b/port/devbit.c index 20a94049fe993c94913a066e0f5204f8ae39efc1..935cc5728e5d2f9a8d25d1f2fa6ca1f205b81bd6 100644 --- a/port/devbit.c +++ b/port/devbit.c @@ -7,9 +7,9 @@ #include "devtab.h" -#include "gnot.h" +#include -extern Font *defont; +extern GFont *defont; /* * Device (#b/bitblt) is exclusive use on open, so no locks are necessary @@ -17,7 +17,7 @@ extern Font *defont; */ /* - * Some fields in Bitmaps are overloaded: + * Some fields in GBitmaps are overloaded: * ldepth = -1 means free. * base is next pointer when free. * Arena is a word containing N, followed by a pointer to its bitmap, @@ -27,12 +27,12 @@ extern Font *defont; struct { Ref; - Bitmap *map; /* arena */ - Bitmap *free; /* free list */ + GBitmap *map; /* arena */ + GBitmap *free; /* free list */ ulong *words; /* storage */ ulong nwords; /* total in arena */ ulong *wfree; /* pointer to next free word */ - Font *font; /* arena; looked up linearly BUG */ + GFont *font; /* arena; looked up linearly BUG */ int lastid; /* last allocated bitmap id */ int lastfid; /* last allocated font id */ int init; /* freshly opened; init message pending */ @@ -43,8 +43,8 @@ struct #define FREE 0x80000000 void bitcompact(void); -void bitfree(Bitmap*); -extern Bitmap screen; +void bitfree(GBitmap*); +extern GBitmap screen; struct{ /* @@ -82,7 +82,7 @@ struct{ }cursor; ulong setbits[16]; -Bitmap set = +GBitmap set = { setbits, 0, @@ -92,7 +92,7 @@ Bitmap set = }; ulong clrbits[16]; -Bitmap clr = +GBitmap clr = { clrbits, 0, @@ -102,7 +102,7 @@ Bitmap clr = }; ulong cursorbackbits[16]; -Bitmap cursorback = +GBitmap cursorback = { cursorbackbits, 0, @@ -136,9 +136,9 @@ void bitreset(void) { int i; - Bitmap *bp; + GBitmap *bp; - bit.map = ialloc(conf.nbitmap * sizeof(Bitmap), 0); + bit.map = ialloc(conf.nbitmap * sizeof(GBitmap), 0); for(i=0,bp=bit.map; ildepth = -1; bp->base = (ulong*)(bp+1); @@ -152,7 +152,7 @@ bitreset(void) bit.words = ialloc(conf.nbitbyte, 0); bit.nwords = conf.nbitbyte/sizeof(ulong); bit.wfree = bit.words; - bit.font = ialloc(conf.nfont * sizeof(Font), 0); + bit.font = ialloc(conf.nfont * sizeof(GFont), 0); bit.font[0] = *defont; for(i=1; iqid!=CHDIR && (c->flag&COPEN)){ lock(&bit); @@ -281,7 +281,7 @@ bitread(Chan *c, void *va, long n) ulong l, nw, ws; int off, j; Fontchar *i; - Bitmap *src; + GBitmap *src; if(c->qid & CHDIR) return devdirread(c, va, n, bitdir, NBIT, devgen); @@ -476,8 +476,8 @@ bitwrite(Chan *c, void *va, long n) Rectangle rect; Cursor curs; Fontchar *fcp; - Bitmap *bp, *src, *dst; - Font *f; + GBitmap *bp, *src, *dst; + GFont *f; if(c->qid == CHDIR) error(0, Eisdir); @@ -533,7 +533,7 @@ bitwrite(Chan *c, void *va, long n) error(0, Enobitstore); } bp = bit.free; - bit.free = (Bitmap*)(bp->base); + bit.free = (GBitmap*)(bp->base); *bit.wfree++ = nw; *bit.wfree++ = (ulong)bp; bp->base = bit.wfree; @@ -590,7 +590,7 @@ bitwrite(Chan *c, void *va, long n) cursoroff(1); isoff = 1; } - bitblt(dst, pt, src, rect, v); + gbitblt(dst, pt, src, rect, v); m -= 31; p += 31; break; @@ -750,7 +750,7 @@ bitwrite(Chan *c, void *va, long n) cursoroff(1); isoff = 1; } - segment(dst, pt1, pt2, t, v); + gsegment(dst, pt1, pt2, t, v); m -= 22; p += 22; break; @@ -782,7 +782,7 @@ bitwrite(Chan *c, void *va, long n) cursoroff(1); isoff = 1; } - point(dst, pt1, t, v); + gpoint(dst, pt1, t, v); m -= 14; p += 14; break; @@ -847,7 +847,7 @@ bitwrite(Chan *c, void *va, long n) cursoroff(1); isoff = 1; } - string(dst, pt, f, (char*)p, v); + gstring(dst, pt, f, (char*)p, v); q++; m -= q-p; p = q; @@ -884,7 +884,7 @@ bitwrite(Chan *c, void *va, long n) v = GSHORT(p+21); { int i; - Texture t; + GTexture t; for(i=0; i<16; i++) t.bits[i] = src->base[i]>>16; @@ -892,7 +892,7 @@ bitwrite(Chan *c, void *va, long n) cursoroff(1); isoff = 1; } - texture(dst, rect, &t, v); + gtexture(dst, rect, &t, v); } m -= 23; p += 23; @@ -983,7 +983,7 @@ biterrstr(Error *e, char *buf) } void -bitfree(Bitmap *bp) +bitfree(GBitmap *bp) { bp->base[-1] = 0; bp->ldepth = -1; @@ -993,10 +993,10 @@ bitfree(Bitmap *bp) QLock bitlock; -Bitmap * +GBitmap * id2bit(int k) { - Bitmap *bp; + GBitmap *bp; bp = &bit.map[k]; if(k<0 || k>=conf.nbitmap || bp->ldepth < 0) error(0, Ebadbitmap); @@ -1017,7 +1017,7 @@ bitcompact(void) } if(p1 != p2){ memcpy(p1, p2, (2+p2[0])*sizeof(ulong)); - ((Bitmap*)p1[1])->base = p1+2; + ((GBitmap*)p1[1])->base = p1+2; } p2 += 2 + p1[0]; p1 += 2 + p1[0]; @@ -1049,10 +1049,10 @@ cursoron(int dolock) cursor.r.min = mouse.xy; cursor.r.max = add(mouse.xy, Pt(16, 16)); cursor.r = raddp(cursor.r, cursor.offset); - bitblt(&cursorback, Pt(0, 0), &screen, cursor.r, S); - bitblt(&screen, add(mouse.xy, cursor.offset), + gbitblt(&cursorback, Pt(0, 0), &screen, cursor.r, S); + gbitblt(&screen, add(mouse.xy, cursor.offset), &clr, Rect(0, 0, 16, 16), D&~S); - bitblt(&screen, add(mouse.xy, cursor.offset), + gbitblt(&screen, add(mouse.xy, cursor.offset), &set, Rect(0, 0, 16, 16), S|D); } if(dolock) @@ -1065,7 +1065,7 @@ cursoroff(int dolock) if(dolock) lock(&cursor); if(--cursor.visible == 0) - bitblt(&screen, cursor.r.min, &cursorback, Rect(0, 0, 16, 16), S); + gbitblt(&screen, cursor.r.min, &cursorback, Rect(0, 0, 16, 16), S); if(dolock) unlock(&cursor); }