SysIII/usr/src/uts/vax/io/mem.c

Compare this file to the similar file:
Show the results in this format:

/*
 *	Memory special file
 *	minor device 0 is physical memory
 *	minor device 1 is kernel memory
 *	minor device 2 is EOF/NULL
 */

#include "sys/param.h"
#include "sys/dir.h"
#include "sys/user.h"
#include "sys/buf.h"
#include "sys/systm.h"
#include "sys/page.h"
#include "sys/mtpr.h"
extern int mmap[];
extern char vmmap[];

mmread(dev)
{
	register unsigned n;
	register c;

	while(u.u_error==0 && u.u_count!=0) {
		n = min(u.u_count, BSIZE);
		if (dev == 0) {
			c = (u.u_offset >> 9) & PG_PFNUM;
			*mmap = c | PG_V | PG_KR;
			mtpr(TBIS, vmmap);
			c = u.u_offset & 0x1ff;
			n = min(n, 512-c);
			if (copyout(vmmap + c, u.u_base, n))
				u.u_error = ENXIO;
		} else if (dev == 1) {
			if (copyout(u.u_offset|0x80000000, u.u_base, n))
				u.u_error = ENXIO;
		} else
			return;
		u.u_offset += n;
		u.u_base += n;
		u.u_count -= n;
	}
}

mmwrite(dev)
{
	register unsigned n;
	register c;

	while(u.u_error==0 && u.u_count!=0) {
		n = min(u.u_count, BSIZE);
		if (dev == 0) {
			c = (u.u_offset >> 9) & PG_PFNUM;
			*mmap = c | PG_V | PG_KW;
			mtpr(TBIS, vmmap);
			c = u.u_offset & 0x1ff;
			n = min(n, 512-c);
			if (copyin(u.u_base, vmmap + c, n))
				u.u_error = ENXIO;
		} else if (dev == 1) {
		  	if (copyin(u.u_base,u.u_offset|0x80000000,n))
				u.u_error = ENXIO;
		}
		u.u_offset += n;
		u.u_base += n;
		u.u_count -= n;
	}
}