Plan 9 from Bell Labs’s /usr/web/sources/extra/9hist/mpc/mmu.c

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


## diffname mpc/mmu.c 1999/0121
## diff -e /dev/null /n/emeliedump/1999/0121/sys/src/brazil/mpc/mmu.c
0a
#include	"u.h"
#include	"../port/lib.h"
#include	"mem.h"
#include	"dat.h"
#include	"fns.h"
#include	"io.h"


static void
taskswitch(ulong pdb, ulong stack)
{
	USED(pdb, stack);
}

void
mmuinit(void)
{
}

void
flushmmu(void)
{
}

static void
mmuptefree(Proc* proc)
{
	USED(proc);
}

void
mmuswitch(Proc* proc)
{
	USED(proc);
}

void
mmurelease(Proc* proc)
{
	USED(proc);
}

static Page*
mmupdballoc(void)
{
}

void
putmmu(ulong va, ulong pa, Page*)
{
	USED(va, pa);
}

static Lock mmukmaplock;

int
mmukmapsync(ulong va)
{
	USED(va);
	return 0;
}

ulong
mmukmap(ulong pa, ulong va, int size)
{
	USED(pa, va, size);
	return 0;
}
.
## diffname mpc/mmu.c 1999/0126
## diff -e /n/emeliedump/1999/0121/sys/src/brazil/mpc/mmu.c /n/emeliedump/1999/0126/sys/src/brazil/mpc/mmu.c
48,68d
43,46d
32,37d
25,30d
22a
	flushmmu();
.
21c
mmuswitch(Proc*)
.
17a
iprint("mmuinit\n");
	kernelmmu();
.
9,14d
## diffname mpc/mmu.c 1999/0127
## diff -e /n/emeliedump/1999/0126/sys/src/brazil/mpc/mmu.c /n/emeliedump/1999/0127/sys/src/brazil/mpc/mmu.c
28a
void
putmmu(ulong va, ulong pa, Page*)
{
	int x, r;
print("putmmu va=%ux pa=%ux\n", va, pa);
	x = splhi();
	r = _putmmu(va, pa);
	splx(x);
}
.
12c
	print("mmuinit\n");
.
## diffname mpc/mmu.c 1999/0128
## diff -e /n/emeliedump/1999/0127/sys/src/brazil/mpc/mmu.c /n/emeliedump/1999/0128/sys/src/brazil/mpc/mmu.c
33c
//print("putmmu va=%ux pa=%ux\n", va, pa);
.
16a
flushmmu(void)
{
//	print("flushmmu()\n");
	_flushmmu();
}

void
.
## diffname mpc/mmu.c 1999/0608
## diff -e /n/emeliedump/1999/0128/sys/src/brazil/mpc/mmu.c /n/emeliedump/1999/0608/sys/src/brazil/mpc/mmu.c
42a

	ctl = &pg->cachectl[m->machno];
	switch(*ctl) {
	default:
		panic("putmmu: %d\n", *ctl);
		break;
	case PG_NOFLUSH:
		break;
	case PG_TXTFLUSH:
		icflush((void*)pg->va, BY2PG);
		*ctl = PG_NOFLUSH;
		break;
	case PG_NEWCOL:
		dcflush((void*)pg->va, BY2PG);
		*ctl = PG_NOFLUSH;
		break;
	}

.
39a
	char *ctl;

//if((va&0x8000000) == 0)
.
37c
putmmu(ulong va, ulong pa, Page *pg)
.
## diffname mpc/mmu.c 2000/0516
## diff -e /n/emeliedump/1999/0608/sys/src/brazil/mpc/mmu.c /n/emeliedump/2000/0516/sys/src/9/mpc/mmu.c
63,64d
59c
print("PG_NEWCOL!!\n");
.
54a
		dcflush((void*)pg->va, BY2PG);
.
47a
if(0)print("putmmu tp=%d h=%d va=%ux pa=%ux ctl=%x\n", tp, h,va, pa, *ctl);
.
46a
	tp = up->pidonmach[m->machno];
	if(tp == 0) {
		tp = newtlbpid(up);
		putcasid(tp);
	}

	h = ((va>>12)^(va>>24)^(tp<<8)) & 0xfff;
	m->stb[h].virt = va|tp;
	m->stb[h].phys = pa;
	tlbflush(va);

	qunlock(&m->stlblk);

.
42,45c
	qlock(&m->stlblk);
.
40a
	int tp;
	ulong h;
.
39d
35a
if(0)print("purgetlb: pid = %d\n", pid);
	m->tlbpurge++;
	/*
	 * find all pid entries that are no longer used by processes
	 */
	mno = m->machno;
	pidproc = m->pidproc;
	for(i=1; i<NTLBPID; i++) {
		sp = pidproc[i];
		if(sp && sp->pidonmach[mno] != i)
			pidproc[i] = 0;
	}

	/*
	 * shoot down the one we want
	 */
	sp = pidproc[pid];
	if(sp != 0)
		sp->pidonmach[mno] = 0;
	pidproc[pid] = 0;

	/*
	 * clean out all dead pids from the stlb;
	 */
	entry = m->stb;
	for(etab = &entry[STLBSIZE]; entry < etab; entry++)
		if(pidproc[TLBPID(entry->virt)] == 0)
			entry->virt = TLBINVLAID;

	/*
	 * clean up the hardware
	 */
	tlbflushall();
}

int
newtlbpid(Proc *p)
{
	int i, s;
	Proc **h;

	i = m->lastpid;
	h = m->pidproc;
	for(s = 0; s < NTLBPID; s++) {
		i++;
		if(i >= NTLBPID)
			i = 1;
		if(h[i] == 0)
			break;
	}

	if(h[i]) {
		i = m->purgepid+1;
		if(i >= NTLBPID)
			i = 1;
		 m->purgepid = i;
		purgetlb(i);
	}

	if(h[i] != 0)
		panic("newtlb");

	m->pidproc[i] = p;
	p->pidonmach[m->machno] = i;
	m->lastpid = i;
if(0)print("newtlbpid: pid=%d = tlbpid = %d\n", p->pid, i);
	return i;
}

.
34a
void
purgetlb(int pid)
{
	int i, mno;
	Proc *sp, **pidproc;
	Softtlb *entry, *etab;
.
32c
if(0)print("mmurelease(%d)\n", p->pid);
	memset(p->pidonmach, 0, sizeof p->pidonmach);
.
30c
mmurelease(Proc* p)
.
26c
	int tp;

if(0)print("mmuswitch()\n");
	if(p->newtlb) {
		memset(p->pidonmach, 0, sizeof p->pidonmach);
		p->newtlb = 0;
	}
	tp = p->pidonmach[m->machno];
	putcasid(tp);
.
24c
mmuswitch(Proc *p)
.
22a
/*
 * called with splhi
 */
.
19,20c
	int x;

if(0)print("flushmmu(%d)\n", up->pid);
	x = splhi();
	up->newtlb = 1;
	mmuswitch(up);
	splx(x);
.
13c
	for(i=0; i<STLBSIZE; i++)
		m->stb[i].virt = TLBINVLAID;
.
11a
	int i;

.
7a
#define TLBINVLAID	KZERO
.
## diffname mpc/mmu.c 2000/0521
## diff -e /n/emeliedump/2000/0516/sys/src/9/mpc/mmu.c /n/emeliedump/2000/0521/sys/src/9/mpc/mmu.c
155c
if(0)print("putmmu tp=%d h=%ld va=%lux pa=%lux ctl=%x\n", tp, h,va, pa, *ctl);
.
128c
if(0)print("newtlbpid: pid=%ld = tlbpid = %d\n", p->pid, i);
.
52c
if(0)print("mmurelease(%ld)\n", p->pid);
.
25c
if(0)print("flushmmu(%ld)\n", up->pid);
.
## diffname mpc/mmu.c 2001/0527 # deleted
## diff -e /n/emeliedump/2000/0521/sys/src/9/mpc/mmu.c /n/emeliedump/2001/0527/sys/src/9/mpc/mmu.c
1,172d

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