A gnot/bbmalloc.c => gnot/bbmalloc.c +71 -0
@@ 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));
+}
M gnot/screen.c => gnot/screen.c +1 -1
@@ 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);
}
}
M gnot/screen.h => gnot/screen.h +1 -1
@@ 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
M power/main.c => power/main.c +1 -2
@@ 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
M ss/main.c => ss/main.c +1 -1
@@ 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