From b4332373ab225bb7ee66a6683e3afa9630265a6a Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sun, 22 Dec 1991 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1991-12-22 --- gnot/bbmalloc.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++ gnot/screen.c | 2 +- gnot/screen.h | 2 +- power/main.c | 3 +-- ss/main.c | 2 +- 5 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 gnot/bbmalloc.c diff --git a/gnot/bbmalloc.c b/gnot/bbmalloc.c new file mode 100644 index 0000000000000000000000000000000000000000..30f1edb78c60bf8a6b928554a959d8c6992e5b0b --- /dev/null +++ b/gnot/bbmalloc.c @@ -0,0 +1,71 @@ +#include "u.h" +#include "lib.h" +#include "mem.h" +#include "dat.h" +#include "fns.h" +#include "io.h" + +/* + * Allocate memory for use in kernel bitblts. + * The allocated memory must have a flushed instruction + * cache, and the data cache must be flushed by bbdflush(). + * To avoid the need for frequent cache flushes, the memory + * is allocated out of an arena, and the i-cache is only + * flushed when it has to be reused. By returning an + * address in non-cached space, the need for flushing the + * d-cache is avoided. + * + * This code will have to be interlocked if we ever get + * a multiprocessor with a bitmapped display. + */ + +/* a 0->3 bitblt can take 800 longs */ +enum { + narena=2, /* put interrupt time stuff in separate arena */ + nbbarena=4096 /* number of words in an arena */ +}; + +static ulong bbarena[narena][nbbarena]; +static ulong *bbcur[narena] = {&bbarena[0][0], &bbarena[1][0]}; +static ulong *bblast[narena] = {0, 0}; + +#define INTLEVEL(v) ((v)&0x700) +void * +bbmalloc(int nbytes) +{ + int nw, a; + int s; + ulong *ans; + + nw = nbytes/sizeof(long); + s = splhi(); + a = INTLEVEL(s)? 1 : 0; + if(bbcur[a] + nw > &bbarena[a][nbbarena]) + ans = bbarena[a]; + else + ans = bbcur[a]; + bbcur[a] = ans + nw; + splx(s); + bblast[a] = ans; + return ans; +} + +void +bbfree(void *p, int n) +{ + ulong *up; + int a, s; + + s = splhi(); + a = INTLEVEL(s)? 1 : 0; + if(p == bblast[a]) + bbcur[a] = (ulong *)(((char *)bblast[a]) + n); + splx(s); +} + +void * +bbdflush(void *p, int n) +{ + flushcpucache(); + return (void *)(((ulong)p)); +} diff --git a/gnot/screen.c b/gnot/screen.c index c6c79cf28f7fd6ec0b3000287f6fa1573eaec91f..99f738555a8ac5c9124dcabd5939e319c399d8f0 100644 --- a/gnot/screen.c +++ b/gnot/screen.c @@ -74,7 +74,7 @@ screenputc(int c) screenputc('\n'); buf[0] = c&0x7F; buf[1] = 0; - out.pos = gbitbltstring(&gscreen, out.pos, defont, buf, S); + out.pos = gstring(&gscreen, out.pos, defont, buf, S); } } diff --git a/gnot/screen.h b/gnot/screen.h index 4fd92d336c661a0dd8759b7da095c92e15da3dc9..45d3e2938c0e831ba69f83aa307f1717bfdb5102 100644 --- a/gnot/screen.h +++ b/gnot/screen.h @@ -32,4 +32,4 @@ extern void mouseupdate(int); * kernel mustn't use balu; user (/dev/bitblt) can */ #define kbitblt gbitblt -#define ubitblt balubitblt +#define ubitblt gbitblt diff --git a/power/main.c b/power/main.c index 4803fa206cd96ffbecdf701b25303d27e3723769..6acba6103c0aab7e9d5e87832aaf827bab07582d 100644 --- a/power/main.c +++ b/power/main.c @@ -222,7 +222,6 @@ init0(void) */ u->slash = (*devtab[0].attach)(0); u->dot = clone(u->slash, 0); - chandevinit(); if(!waserror()){ @@ -265,7 +264,7 @@ userinit(void) */ p->sched.pc = (ulong)init0; p->sched.sp = USERADDR+BY2PG-(1+MAXSYSARG)*BY2WD; - p->upage = newpage(0, 0, USERADDR|(p->pid&0xFFFF)); + p->upage = newpage(1, 0, USERADDR|(p->pid&0xFFFF)); /* * User diff --git a/ss/main.c b/ss/main.c index 20cb47c9aa841e9de4cb933422131c97f344fff3..8dc04bb461d72af6206641f6028e13c1530dacf3 100644 --- a/ss/main.c +++ b/ss/main.c @@ -143,7 +143,7 @@ userinit(void) */ p->sched.pc = (((ulong)init0) - 8); /* 8 because of RETURN in gotolabel */ p->sched.sp = USERADDR+BY2PG-(1+MAXSYSARG)*BY2WD; - p->upage = newpage(0, 0, USERADDR|(p->pid&0xFFFF)); + p->upage = newpage(1, 0, USERADDR|(p->pid&0xFFFF)); /* * User