~kris/9p

9hist

d7ed191f811e8267a57e4c2eb03e7b33e3e90a54 — David du Colombier 33 years ago db4f318
Plan 9 from Bell Labs 1993-01-20
M gnot/segment.h => gnot/segment.h +5 -5
@@ 9,11 9,11 @@ struct Physseg
	char	*name;			/* Attach name */
	ulong	pa;			/* Physical address */
	ulong	size;			/* Maximum segment size in pages */
	Page	*(*pgalloc)(ulong);	/* Allocation if we need it */
	Page	*(*pgalloc)(Segment*, ulong);	/* Allocation if we need it */
	void	(*pgfree)(Page*);
}physseg[] = {
	{ SG_SHARED,	"lock",		0,	SEGMAXSIZE,	snewpage, 	putpage },
	{ SG_SHARED,	"shared",	0,	SEGMAXSIZE,	snewpage, 	putpage },
	{ SG_BSS,	"memory",	0,	SEGMAXSIZE,	snewpage,	putpage },
	{ 0,		0,		0,	0,		0,		0 	},
	{ SG_SHARED,	"lock",		0,	SEGMAXSIZE,	0, 	0 },
	{ SG_SHARED,	"shared",	0,	SEGMAXSIZE,	0, 	0 },
	{ SG_BSS,	"memory",	0,	SEGMAXSIZE,	0,	0 },
	{ 0,		0,		0,	0,		0,	0 },
};

M pc/fns.h => pc/fns.h +2 -0
@@ 9,8 9,10 @@ void	clockinit(void);
void	config(int);
int	cpuspeed(int);
void	delay(int);
void	dsegfree(Page*);
void	dmaend(int);
long	dmasetup(int, void*, long, int);
Page*	dsegalloc(Segment*, ulong);
#define	evenaddr(x)		/* 386 doesn't care */
void	fault386(Ureg*);
void	faultinit(void);

M pc/mmu.c => pc/mmu.c +28 -0
@@ 351,3 351,31 @@ isamem(int len)
	unlock(&isamemalloc);
	return a;
}

/*
 *  mapping for user access to d segment (access to TARGA)
 */
Page*
dsegalloc(Segment *s, ulong va)
{
	Page *pg;

	pg = smalloc(sizeof(Page));
	memset(pg, 0, sizeof(Page));
	pg->va = va;
	pg->pa = 0xd0000 + (va - s->base);
	pg->ref = 1;
	return pg;
}

void
dsegfree(Page *pg)
{
	int x;

	lock(pg);
	x = --pg->ref;
	unlock(pg);
	if(x <= 0)
		free(pg);
}

M pc/segment.h => pc/segment.h +6 -8
@@ 2,8 2,6 @@
 * Attach segment types
 */

#define PCMEM (KZERO|0xd0000)

typedef struct Physseg Physseg;
struct Physseg
{


@@ 11,12 9,12 @@ struct Physseg
	char	*name;			/* Attach name */
	ulong	pa;			/* Physical address */
	ulong	size;			/* Maximum segment size in pages */
	Page	*(*pgalloc)(ulong);	/* Allocation if we need it */
	Page	*(*pgalloc)(Segment*, ulong);	/* Allocation if we need it */
	void	(*pgfree)(Page*);
}physseg[] = {
	{ SG_SHARED,	"lock",		0,	SEGMAXSIZE,	snewpage, 	putpage },
	{ SG_SHARED,	"shared",	0,	SEGMAXSIZE,	snewpage, 	putpage },
	{ SG_PHYSICAL,	"pcmem",	PCMEM,	64*1024,	0,		0,	},
	{ SG_BSS,	"memory",	0,	SEGMAXSIZE,	snewpage,	putpage },
	{ 0,		0,		0,	0,		0,		0 	},
	{ SG_SHARED,	"lock",		0,	SEGMAXSIZE,	0, 	0 },
	{ SG_SHARED,	"shared",	0,	SEGMAXSIZE,	0, 	0 },
	{ SG_PHYSICAL,	"dseg",		0xd0000, 64*1024,	dsegalloc,	dsegfree, },
	{ SG_BSS,	"memory",	0,	SEGMAXSIZE,	0,	0 },
	{ 0,		0,		0,	0,		0,	0 },
};

M port/alloc.c => port/alloc.c +8 -8
@@ 263,7 263,7 @@ malloc(ulong size)
	int pow, n;
	Bucket *bp, *nbp;

	for(pow = 3; pow <= Maxpow; pow++)
	for(pow = 3; pow < Maxpow; pow++)
		if(size <= (1<<pow))
			goto good;



@@ 296,18 296,16 @@ good:
		if(bp == nil)
			return nil;

		next = (ulong)bp+size;
		nbp = (Bucket*)next;
		nbp = bp;
		lock(&arena);
		arena.btab[pow] = nbp;
		arena.nbuck[pow] += n;
		for(n -= 2; n; n--) {
		while(--n) {
			next = (ulong)nbp+size;
			nbp->next = (Bucket*)next;
			nbp = (Bucket*)next;
			nbp->size = pow;
			nbp = nbp->next;
			nbp->next = arena.btab[pow];
			arena.btab[pow] = nbp;
		}
		nbp->size = pow;
		unlock(&arena);
	}
	else {


@@ 315,7 313,9 @@ good:
		if(bp == nil)
			return nil;

		lock(&arena);
		arena.nbuck[pow]++;
		unlock(&arena);
	}

	bp->size = pow;

M port/devcons.c => port/devcons.c +1 -0
@@ 170,6 170,7 @@ panic(char *fmt, ...)
	n = doprint(buf+strlen(buf), buf+sizeof(buf), fmt, (&fmt+1)) - buf;
	buf[n] = '\n';
	putstrn(buf, n+1);
	xsummary();
	dumpstack();
	exit(1);
}

M port/fault.c => port/fault.c +1 -1
@@ 131,7 131,7 @@ fixfault(Segment *s, ulong addr, int read, int doputmmu)

	case SG_PHYSICAL:
		if(*pg == 0)
			*pg = (*s->pgalloc)(addr);
			*pg = (*s->pgalloc)(s, addr);

		mmuphys = PPN((*pg)->pa) | PTEWRITE|PTEUNCACHED|PTEVALID;
		(*pg)->modref = PG_MOD|PG_REF;

M port/portdat.h => port/portdat.h +1 -1
@@ 423,7 423,7 @@ struct Segment
	ulong	flen;			/* length of segment in file */
	int	flushme;		/* maintain consistent icache for this segment */
	Image	*image;			/* text in file attached to this segment */
	Page	*(*pgalloc)(ulong addr);/* SG_PHYSICAL page allocator */
	Page	*(*pgalloc)(Segment*, ulong);/* SG_PHYSICAL page allocator */
	void	(*pgfree)(Page *);	/* SG_PHYSICAL page free */
	Pte	*map[SEGMAPSIZE];	/* segment pte map */
};

M port/segment.c => port/segment.c +1 -8
@@ 5,8 5,7 @@
#include	"fns.h"
#include	"../port/error.h"

Page *lkpage(ulong addr);
Page *snewpage(ulong addr);
Page *lkpage(Segment*, ulong);
void lkpgfree(Page*);
void imagereclaim(void);



@@ 487,9 486,3 @@ done:
	flushmmu();
	return 0;
}

Page*
snewpage(ulong addr)
{
	return newpage(1, 0, addr);
}

M power/lock.c => power/lock.c +2 -1
@@ 48,12 48,13 @@ lockinit(void)

/* equivalent of newpage for pages of hardware locks */
Page*
lkpage(ulong va)
lkpage(Segment *s, ulong va)
{
	uchar *p, *top;
	Page *pg;
	int i;

	USED(s);
	lock(&semalloc.lock);
	if(--semalloc.ulockpg < 0) {
		semalloc.ulockpg++;

M power/segment.h => power/segment.h +4 -4
@@ 9,11 9,11 @@ struct Physseg
	char	*name;			/* Attach name */
	ulong	pa;			/* Physical address */
	ulong	size;			/* Maximum segment size in pages */
	Page	*(*pgalloc)(ulong);	/* Allocation if we need it */
	Page	*(*pgalloc)(Segment*, ulong);	/* Allocation if we need it */
	void	(*pgfree)(Page*);
}physseg[] = {
	{ SG_PHYSICAL,	"lock",		0,	1024*BY2PG,	lkpage,		lkpgfree },
	{ SG_SHARED,	"shared",	0,	SEGMAXSIZE,	snewpage, 	putpage },
	{ SG_BSS,	"memory",	0,	SEGMAXSIZE,	snewpage,	putpage },
	{ 0,		0,		0,	0,		0,		0 	},
	{ SG_SHARED,	"shared",	0,	SEGMAXSIZE,	0, 	0 },
	{ SG_BSS,	"memory",	0,	SEGMAXSIZE,	0,	0 },
	{ 0,		0,		0,	0,		0,	0 },
};

M ss/segment.h => ss/segment.h +1 -1
@@ 9,7 9,7 @@ struct Physseg
	char	*name;			/* Attach name */
	ulong	pa;			/* Physical address */
	ulong	size;			/* Maximum segment size in pages */
	Page	*(*pgalloc)(ulong);	/* Allocation if we need it */
	Page	*(*pgalloc)(Segment*, ulong);	/* Allocation if we need it */
	void	(*pgfree)(Page*);
}physseg[] = {
	{ SG_SHARED,	"shared",	0,	SEGMAXSIZE,	0, 	0 },