Plan 9 from Bell Labs’s /usr/web/sources/extra/9hist/gnot/bbmalloc.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


## diffname gnot/bbmalloc.c 1991/1222
## diff -e /dev/null /n/bootesdump/1991/1222/sys/src/9/gnot/bbmalloc.c
0a
#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));
}
.
## diffname gnot/bbmalloc.c 1992/0112
## diff -e /n/bootesdump/1991/1222/sys/src/9/gnot/bbmalloc.c /n/bootesdump/1992/0112/sys/src/9/gnot/bbmalloc.c
70a
}

int
bbonstack(void)
{
	if(u)
		return 1;
	return 0;
.
66a
flushvirtpage(void *p)
{
	flushcpucache();
}

void *
.
## diffname gnot/bbmalloc.c 1992/0120
## diff -e /n/bootesdump/1992/0112/sys/src/9/gnot/bbmalloc.c /n/bootesdump/1992/0120/sys/src/9/gnot/bbmalloc.c
76d
72c
void
.
66c
void
.
## diffname gnot/bbmalloc.c 1992/0321
## diff -e /n/bootesdump/1992/0120/sys/src/9/gnot/bbmalloc.c /n/bootesdump/1992/0321/sys/src/9/gnot/bbmalloc.c
2c
#include	"../port/lib.h"
.
## diffname gnot/bbmalloc.c 1992/0711
## diff -e /n/bootesdump/1992/0321/sys/src/9/gnot/bbmalloc.c /n/bootesdump/1992/0711/sys/src/9/gnot/bbmalloc.c
74a
	USED(p, n);
.
68a
	USED(p);
.
56d
## diffname gnot/bbmalloc.c 1993/0501 # deleted
## diff -e /n/bootesdump/1992/0711/sys/src/9/gnot/bbmalloc.c /n/fornaxdump/1993/0501/sys/src/brazil/gnot/bbmalloc.c
1,85d

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].