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

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


## diffname ss/bbmalloc.c 1991/0723
## diff -e /dev/null /n/bootesdump/1991/0723/sys/src/9/slc/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.
 *
 * Currently, the only kernel users of bitblt are devbit,
 * print, and the cursor stuff in devbit.  The cursor
 * can get drawn at clock interrupt time, so it might need
 * to bbmalloc while another bitblt is going on.
 *
 * This code will have to be interlocked if we ever get
 * a multiprocessor with a bitmapped display.
 */

/* a 0->3 bitblt can take 900 words */
enum {
	nbbarena=8192	/* number of words in an arena */
};

static ulong	bbarena[nbbarena];
static ulong	*bbcur = bbarena;
static ulong	*bblast = 0;

void *
bbmalloc(int nbytes)
{
	int nw;
	int s;
	ulong *ans;

	nw = nbytes/sizeof(long);
	s = splhi();
	if(bbcur + nw > &bbarena[nbbarena])
		ans = bbarena;
	else
		ans = bbcur;
	bbcur = ans + nw;
	splx(s);
/*
	if(ans == bbarena)
		icflush(ans, sizeof(bbarena));
*/
	bblast = ans;
	ans = (void *)ans;
	return ans;
}

void
bbfree(void *p, int n)
{
	ulong *up;

	if(p == bblast)
		bbcur = (ulong *)(((char *)bblast) + n);
}

void *
bbdflush(void *p, int n)
{
	return p;
}
.
## diffname ss/bbmalloc.c 1992/0116
## diff -e /n/bootesdump/1991/0723/sys/src/9/slc/bbmalloc.c /n/bootesdump/1992/0116/sys/src/9/slc/bbmalloc.c
72c
	if(u)
		return 1;
	return 0;
.
69,70c
int
bbonstack(void)
.
51,54d
10,24d
## diffname ss/bbmalloc.c 1992/0321
## diff -e /n/bootesdump/1992/0116/sys/src/9/slc/bbmalloc.c /n/bootesdump/1992/0321/sys/src/9/slc/bbmalloc.c
2c
#include	"../port/lib.h"
.
## diffname ss/bbmalloc.c 1992/0711
## diff -e /n/bootesdump/1992/0321/sys/src/9/slc/bbmalloc.c /n/bootesdump/1992/0711/sys/src/9/slc/bbmalloc.c
44,45d
## diffname ss/bbmalloc.c 1993/0501 # deleted
## diff -e /n/bootesdump/1992/0807/sys/src/9/slc/bbmalloc.c /n/fornaxdump/1993/0501/sys/src/brazil/ss/bbmalloc.c
1,54d

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].