- Use DEV_ constants, instead of documenting the numbers!

- Delete cdev_decl(mm); where appropriate, and other hand-crufting [hi powerpc!]
This commit is contained in:
christos 2002-02-27 01:20:51 +00:00
parent 6b030ee036
commit e8116a8f5b
26 changed files with 241 additions and 386 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.30 2001/07/12 23:25:39 thorpej Exp $ */
/* $NetBSD: mem.c,v 1.31 2002/02/27 01:20:51 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -46,7 +46,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.30 2001/07/12 23:25:39 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.31 2002/02/27 01:20:51 christos Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@ -62,10 +62,6 @@ __KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.30 2001/07/12 23:25:39 thorpej Exp $");
#include <uvm/uvm_extern.h>
#define mmread mmrw
#define mmwrite mmrw
cdev_decl(mm);
caddr_t zeropage;
extern int firstusablepage, lastusablepage;
extern caddr_t msgbufaddr;
@ -115,8 +111,7 @@ mmrw(dev, uio, flags)
}
switch (minor(dev)) {
/* minor device 0 is physical memory */
case 0:
case DEV_MEM:
v = uio->uio_offset;
kmemphys:
if (v >= ALPHA_K0SEG_TO_PHYS((vaddr_t)msgbufaddr)) {
@ -140,8 +135,7 @@ kmemphys:
uiomove((caddr_t)ALPHA_PHYS_TO_K0SEG(v), c, uio);
break;
/* minor device 1 is kernel memory */
case 1:
case DEV_KMEM:
v = uio->uio_offset;
if (v >= ALPHA_K0SEG_BASE && v <= ALPHA_K0SEG_END) {
@ -156,14 +150,12 @@ kmemphys:
error = uiomove((caddr_t)v, c, uio);
break;
/* minor device 2 is EOF/rathole */
case 2:
case DEV_NULL:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
/* minor device 12 (/dev/zero) is source of nulls on read, rathole on write */
case 12:
case DEV_ZERO:
if (uio->uio_rw == UIO_WRITE) {
uio->uio_resid = 0;
return (0);
@ -202,7 +194,7 @@ mmmmap(dev, off, prot)
* and /dev/zero is a hack that is handled via the default
* pager in mmap().
*/
if (minor(dev) != 0)
if (minor(dev) != DEV_MEM)
return (-1);
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.32 2002/01/28 09:56:47 aymeric Exp $ */
/* $NetBSD: mem.c,v 1.33 2002/02/27 01:20:51 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.32 2002/01/28 09:56:47 aymeric Exp $");
__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.33 2002/02/27 01:20:51 christos Exp $");
/*
* Memory special file
@ -59,10 +59,6 @@ __KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.32 2002/01/28 09:56:47 aymeric Exp $");
#include <uvm/uvm_extern.h>
#define mmread mmrw
#define mmwrite mmrw
cdev_decl(mm);
extern int kernel_reload_write(struct uio *uio);
extern u_int lowram;
static caddr_t devzeropage;
@ -103,7 +99,7 @@ mmrw(dev, uio, flags)
static int physlock;
vm_prot_t prot;
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
/* lock against other uses of shared vmmap */
while (physlock > 0) {
physlock++;
@ -126,7 +122,7 @@ mmrw(dev, uio, flags)
switch (minor(dev)) {
/* minor device 0 is physical memory */
case 0:
case DEV_MEM:
v = uio->uio_offset;
#ifndef DEBUG
/* allow reads only in RAM (except for DEBUG) */
@ -148,8 +144,7 @@ mmrw(dev, uio, flags)
pmap_update(pmap_kernel());
continue;
/* minor device 1 is kernel memory */
case 1:
case DEV_KMEM:
v = uio->uio_offset;
c = min(iov->iov_len, MAXPHYS);
if (!uvm_kernacc((caddr_t)v, c,
@ -178,7 +173,7 @@ mmrw(dev, uio, flags)
continue;
/* minor device 2 is EOF/RATHOLE */
case 2:
case DEV_NULL:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
@ -187,7 +182,7 @@ mmrw(dev, uio, flags)
* minor device 12 (/dev/zero) is source of nulls on read,
* rathole on write
*/
case 12:
case DEV_ZERO:
if (uio->uio_rw == UIO_WRITE) {
c = iov->iov_len;
break;
@ -201,12 +196,7 @@ mmrw(dev, uio, flags)
error = uiomove(devzeropage, c, uio);
continue;
/*
* minor device 20 (/dev/reload) represents magic memory
* which you can write a kernel image to, causing a reboot
* into that kernel
*/
case 20:
case DEV_RELOAD:
if (uio->uio_rw == UIO_READ)
return 0;
error = kernel_reload_write(uio);
@ -222,7 +212,7 @@ mmrw(dev, uio, flags)
uio->uio_offset += c;
uio->uio_resid -= c;
}
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
#ifndef DEBUG
unlock:
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.4 2002/01/05 17:02:22 chris Exp $ */
/* $NetBSD: mem.c,v 1.5 2002/02/27 01:20:51 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.4 2002/01/05 17:02:22 chris Exp $");
__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.5 2002/02/27 01:20:51 christos Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@ -63,6 +63,7 @@ extern char *memhook; /* poor name! */
caddr_t zeropage;
int physlock;
/*ARGSUSED*/
int
mmopen(dev, flag, mode, p)
@ -101,7 +102,7 @@ mmrw(dev, uio, flags)
int error = 0;
vm_prot_t prot;
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
/* lock against other uses of shared vmmap */
while (physlock > 0) {
physlock++;
@ -123,8 +124,7 @@ mmrw(dev, uio, flags)
}
switch (minor(dev)) {
/* minor device 0 is physical memory */
case 0:
case DEV_MEM:
v = uio->uio_offset;
prot = uio->uio_rw == UIO_READ ? VM_PROT_READ :
VM_PROT_WRITE;
@ -139,8 +139,7 @@ mmrw(dev, uio, flags)
pmap_update(pmap_kernel());
break;
/* minor device 1 is kernel memory */
case 1:
case DEV_KMEM:
v = uio->uio_offset;
c = min(iov->iov_len, MAXPHYS);
if (!uvm_kernacc((caddr_t)v, c,
@ -149,14 +148,12 @@ mmrw(dev, uio, flags)
error = uiomove((caddr_t)v, c, uio);
break;
/* minor device 2 is EOF/rathole */
case 2:
case DEV_NULL:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
/* minor device 3 (/dev/zero) is source of nulls on read, rathole on write */
case 3:
case DEV_ZERO:
if (uio->uio_rw == UIO_WRITE) {
uio->uio_resid = 0;
return (0);
@ -174,7 +171,7 @@ mmrw(dev, uio, flags)
return (ENXIO);
}
}
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
/*unlock:*/
if (physlock > 1)
wakeup((caddr_t)&physlock);
@ -199,7 +196,7 @@ mmmmap(dev, off, prot)
* and /dev/zero is a hack that is handled via the default
* pager in mmap().
*/
if (minor(dev) != 0)
if (minor(dev) != DEV_MEM)
return (-1);
/* minor device 0 is physical memory */

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.4 2001/02/12 23:29:08 bjh21 Exp $ */
/* $NetBSD: mem.c,v 1.5 2002/02/27 01:20:51 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -59,10 +59,6 @@
caddr_t zeropage;
int physlock;
#define mmread mmrw
#define mmwrite mmrw
cdev_decl(mm);
/*ARGSUSED*/
int
mmopen(dev, flag, mode, p)
@ -111,8 +107,7 @@ mmrw(dev, uio, flags)
}
switch (minor(dev)) {
/* minor device 0 is physical memory */
case 0:
case DEV_MEM:
/*
* On arm26, there's no need to map in the
* relevant page, as we've got physical memory
@ -129,8 +124,7 @@ mmrw(dev, uio, flags)
uio->uio_resid, uio);
continue;
/* minor device 1 is kernel memory */
case 1:
case DEV_KMEM:
v = uio->uio_offset;
c = min(iov->iov_len, MAXPHYS);
/* Allow reading from physically mapped space. */
@ -145,14 +139,12 @@ mmrw(dev, uio, flags)
return (EFAULT);
continue;
/* minor device 2 is EOF/RATHOLE */
case 2:
case DEV_NULL:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
/* minor device 3 (/dev/zero) is source of nulls on read, rathole on write */
case 3:
case DEV_ZERO:
if (uio->uio_rw == UIO_WRITE) {
c = iov->iov_len;
break;
@ -176,7 +168,7 @@ mmrw(dev, uio, flags)
uio->uio_offset += c;
uio->uio_resid -= c;
}
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
/*unlock:*/
if (physlock > 1)
wakeup((caddr_t)&physlock);
@ -201,14 +193,14 @@ mmmmap(dev, off, prot)
* and /dev/zero is a hack that is handled via the default
* pager in mmap().
*/
if (minor(dev) != 0)
if (minor(dev) != DEV_MEM)
return (-1);
/* minor device 0 is physical memory */
/* XXX This may botch our cacheing assumptions. Do we care? */
ppn = atop(off);
if (ppn >= 0 && ppn < physmem )
if (ppn >= 0 && ppn < physmem)
return ppn;
return -1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.22 2001/09/10 21:19:11 chris Exp $ */
/* $NetBSD: mem.c,v 1.23 2002/02/27 01:20:52 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -60,10 +60,6 @@
#include "nvr.h"
#define mmread mmrw
#define mmwrite mmrw
cdev_decl(mm);
extern u_int lowram;
static caddr_t devzeropage;
@ -104,7 +100,7 @@ mmrw(dev, uio, flags)
static int physlock;
vm_prot_t prot;
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
/* lock against other uses of shared vmmap */
while (physlock > 0) {
physlock++;
@ -126,7 +122,7 @@ mmrw(dev, uio, flags)
}
switch (minor(dev)) {
case 0: /* minor device 0 is physical memory */
case DEV_MEM:
v = uio->uio_offset;
/*
@ -153,7 +149,7 @@ mmrw(dev, uio, flags)
pmap_update(pmap_kernel());
break;
case 1: /* minor device 1 is kernel memory */
case DEV_KMEM:
v = uio->uio_offset;
c = min(iov->iov_len, MAXPHYS);
if (!uvm_kernacc((caddr_t)v, c,
@ -162,12 +158,12 @@ mmrw(dev, uio, flags)
error = uiomove((caddr_t)v, c, uio);
break;
case 2: /* minor device 2 is EOF/RATHOLE */
case DEV_NULL:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
case 11: /* minor device 11 (/dev/nvram) */
case DEV_NVRAM:
#if NNVR > 0
error = nvram_uio(uio);
return (error);
@ -175,7 +171,7 @@ mmrw(dev, uio, flags)
return (ENXIO);
#endif
case 12: /* minor device 12 (/dev/zero) */
case DEV_ZERO:
if (uio->uio_rw == UIO_WRITE) {
c = iov->iov_len;
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.1 2001/05/14 18:23:02 drochner Exp $ */
/* $NetBSD: mem.c,v 1.2 2002/02/27 01:20:52 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -56,10 +56,6 @@
#include <uvm/uvm_extern.h>
#define mmread mmrw
#define mmwrite mmrw
cdev_decl(mm);
extern u_int lowram;
extern char *extiobase;
static caddr_t devzeropage;
@ -100,7 +96,7 @@ mmrw(dev, uio, flags)
static int physlock;
vm_prot_t prot;
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
/* lock against other uses of shared vmmap */
while (physlock > 0) {
physlock++;
@ -122,8 +118,7 @@ mmrw(dev, uio, flags)
}
switch (minor(dev)) {
/* minor device 0 is physical memory */
case 0:
case DEV_MEM:
v = uio->uio_offset;
/*
@ -145,8 +140,7 @@ mmrw(dev, uio, flags)
(vm_offset_t)vmmap + NBPG);
continue;
/* minor device 1 is kernel memory */
case 1:
case DEV_KMEM:
v = uio->uio_offset;
c = min(iov->iov_len, MAXPHYS);
if (!uvm_kernacc((caddr_t)v, c,
@ -167,14 +161,12 @@ mmrw(dev, uio, flags)
error = uiomove((caddr_t)v, c, uio);
continue;
/* minor device 2 is EOF/RATHOLE */
case 2:
case DEV_NULL:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
/* minor device 12 (/dev/zero) is source of nulls on read, rathole on write */
case 12:
case DEV_ZERO:
if (uio->uio_rw == UIO_WRITE) {
c = iov->iov_len;
break;
@ -202,7 +194,7 @@ mmrw(dev, uio, flags)
uio->uio_offset += c;
uio->uio_resid -= c;
}
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
unlock:
if (physlock > 1)
wakeup((caddr_t)&physlock);
@ -225,7 +217,7 @@ mmmmap(dev, off, prot)
* and /dev/zero is a hack that is handled via the default
* pager in mmap().
*/
if (minor(dev) != 0)
if (minor(dev) != DEV_MEM)
return (-1);
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.34 2001/12/08 03:55:23 gmcgarry Exp $ */
/* $NetBSD: mem.c,v 1.35 2002/02/27 01:20:52 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -56,10 +56,6 @@
#include <uvm/uvm_extern.h>
#define mmread mmrw
#define mmwrite mmrw
cdev_decl(mm);
extern u_int lowram;
extern char *extiobase;
static caddr_t devzeropage;
@ -100,7 +96,7 @@ mmrw(dev, uio, flags)
static int physlock;
vm_prot_t prot;
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
/* lock against other uses of shared vmmap */
while (physlock > 0) {
physlock++;
@ -122,8 +118,7 @@ mmrw(dev, uio, flags)
}
switch (minor(dev)) {
/* minor device 0 is physical memory */
case 0:
case DEV_MEM:
v = uio->uio_offset;
/*
@ -147,8 +142,7 @@ mmrw(dev, uio, flags)
pmap_update(pmap_kernel());
continue;
/* minor device 1 is kernel memory */
case 1:
case DEV_KMEM:
v = uio->uio_offset;
c = min(iov->iov_len, MAXPHYS);
if (!uvm_kernacc((caddr_t)v, c,
@ -168,14 +162,12 @@ mmrw(dev, uio, flags)
error = uiomove((caddr_t)v, c, uio);
continue;
/* minor device 2 is EOF/RATHOLE */
case 2:
case DEV_NULL:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
/* minor device 12 (/dev/zero) is source of nulls on read, rathole on write */
case 12:
case DEV_ZERO:
if (uio->uio_rw == UIO_WRITE) {
c = iov->iov_len;
break;
@ -226,7 +218,7 @@ mmmmap(dev, off, prot)
* and /dev/zero is a hack that is handled via the default
* pager in mmap().
*/
if (minor(dev) != 0)
if (minor(dev) != DEV_MEM)
return (-1);
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.5 2001/09/10 21:19:37 chris Exp $ */
/* $NetBSD: mem.c,v 1.6 2002/02/27 01:20:52 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -95,7 +95,7 @@ mmrw(dev, uio, flags)
int error = 0;
vm_prot_t prot;
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
/* lock against other uses of shared vmmap */
while (physlock > 0) {
physlock++;
@ -117,8 +117,7 @@ mmrw(dev, uio, flags)
}
switch (minor(dev)) {
/* minor device 0 is physical memory */
case 0:
case DEV_MEM:
v = uio->uio_offset;
prot = uio->uio_rw == UIO_READ ? VM_PROT_READ :
VM_PROT_WRITE;
@ -133,8 +132,7 @@ mmrw(dev, uio, flags)
pmap_update(pmap_kernel());
continue;
/* minor device 1 is kernel memory */
case 1:
case DEV_KMEM:
v = uio->uio_offset;
c = min(iov->iov_len, MAXPHYS);
if (!uvm_kernacc((caddr_t)v, c,
@ -143,14 +141,12 @@ mmrw(dev, uio, flags)
error = uiomove((caddr_t)v, c, uio);
continue;
/* minor device 2 is EOF/RATHOLE */
case 2:
case DEV_NULL:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
/* minor device 3 (/dev/zero) is source of nulls on read, rathole on write */
case 3:
case DEV_ZERO:
if (uio->uio_rw == UIO_WRITE) {
c = iov->iov_len;
break;
@ -174,7 +170,7 @@ mmrw(dev, uio, flags)
uio->uio_offset += c;
uio->uio_resid -= c;
}
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
/*unlock:*/
if (physlock > 1)
wakeup((caddr_t)&physlock);
@ -199,7 +195,7 @@ mmmmap(dev, off, prot)
* and /dev/zero is a hack that is handled via the default
* pager in mmap().
*/
if (minor(dev) != 0)
if (minor(dev) != DEV_MEM)
return (-1);
/* minor device 0 is physical memory */

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.50 2001/11/15 07:03:30 lukem Exp $ */
/* $NetBSD: mem.c,v 1.51 2002/02/27 01:20:53 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -45,7 +45,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.50 2001/11/15 07:03:30 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.51 2002/02/27 01:20:53 christos Exp $");
#include "opt_compat_netbsd.h"
@ -76,7 +76,7 @@ mmopen(dev, flag, mode, p)
switch (minor(dev)) {
#ifdef COMPAT_10
/* This is done by i386_iopl(3) now. */
case 14:
case DEV_IO:
if (flag & FWRITE) {
struct trapframe *fp;
fp = curproc->p_md.md_regs;
@ -116,7 +116,7 @@ mmrw(dev, uio, flags)
static int physlock;
vm_prot_t prot;
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
/* lock against other uses of shared vmmap */
while (physlock > 0) {
physlock++;
@ -137,9 +137,7 @@ mmrw(dev, uio, flags)
continue;
}
switch (minor(dev)) {
/* minor device 0 is physical memory */
case 0:
case DEV_MEM:
v = uio->uio_offset;
prot = uio->uio_rw == UIO_READ ? VM_PROT_READ :
VM_PROT_WRITE;
@ -154,8 +152,7 @@ mmrw(dev, uio, flags)
pmap_update(pmap_kernel());
break;
/* minor device 1 is kernel memory */
case 1:
case DEV_KMEM:
v = uio->uio_offset;
c = min(iov->iov_len, MAXPHYS);
if (!uvm_kernacc((caddr_t)v, c,
@ -164,14 +161,12 @@ mmrw(dev, uio, flags)
error = uiomove((caddr_t)v, c, uio);
break;
/* minor device 2 is EOF/rathole */
case 2:
case DEV_NULL:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
/* minor device 12 (/dev/zero) is source of nulls on read, rathole on write */
case 12:
case DEV_ZERO:
if (uio->uio_rw == UIO_WRITE) {
uio->uio_resid = 0;
return (0);
@ -189,7 +184,7 @@ mmrw(dev, uio, flags)
return (ENXIO);
}
}
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
if (physlock > 1)
wakeup((caddr_t)&physlock);
physlock = 0;
@ -213,7 +208,7 @@ mmmmap(dev, off, prot)
* and /dev/zero is a hack that is handled via the default
* pager in mmap().
*/
if (minor(dev) != 0)
if (minor(dev) != DEV_MEM)
return (-1);
if ((u_int)off > ctob(physmem) && suser(p->p_ucred, &p->p_acflag) != 0)

View File

@ -1,5 +1,5 @@
/* $NetBSD: mem.c,v 1.5 2001/09/10 21:19:32 chris Exp $ */
/* $NetBSD: mem.c,v 1.5 2001/09/10 21:19:32 chris Exp $ */
/* $NetBSD: mem.c,v 1.6 2002/02/27 01:20:53 christos Exp $ */
/* $NetBSD: mem.c,v 1.6 2002/02/27 01:20:53 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -43,7 +43,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.5 2001/09/10 21:19:32 chris Exp $");
__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.6 2002/02/27 01:20:53 christos Exp $");
/*
* Memory special file
@ -61,10 +61,6 @@ __KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.5 2001/09/10 21:19:32 chris Exp $");
#include <uvm/uvm_extern.h>
#define mmread mmrw
#define mmwrite mmrw
cdev_decl(mm);
extern u_int lowram;
static caddr_t devzeropage;
@ -104,7 +100,7 @@ mmrw(dev, uio, flags)
static int physlock;
vm_prot_t prot;
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
/* lock against other uses of shared vmmap */
while (physlock > 0) {
physlock++;
@ -126,8 +122,7 @@ mmrw(dev, uio, flags)
}
switch (minor(dev)) {
/* minor device 0 is physical memory */
case 0:
case DEV_MEM:
v = uio->uio_offset;
#ifndef DEBUG
/* allow reads only in RAM (except for DEBUG) */
@ -149,8 +144,7 @@ mmrw(dev, uio, flags)
pmap_update(pmap_kernel());
continue;
/* minor device 1 is kernel memory */
case 1:
case DEV_KMEM:
v = uio->uio_offset;
c = min(iov->iov_len, MAXPHYS);
if (!uvm_kernacc((caddr_t)v, c,
@ -159,14 +153,12 @@ mmrw(dev, uio, flags)
error = uiomove((caddr_t)v, c, uio);
continue;
/* minor device 2 is EOF/RATHOLE */
case 2:
case DEV_NULL:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
/* minor device 12 (/dev/zero) is source of nulls on read, rathole on write */
case 12:
case DEV_ZERO:
if (uio->uio_rw == UIO_WRITE) {
c = iov->iov_len;
break;
@ -194,7 +186,7 @@ mmrw(dev, uio, flags)
uio->uio_offset += c;
uio->uio_resid -= c;
}
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
#ifndef DEBUG
unlock:
#endif
@ -219,7 +211,7 @@ mmmmap(dev, off, prot)
* and /dev/zero is a hack that is handled via the default
* pager in mmap().
*/
if (minor(dev) != 0)
if (minor(dev) != DEV_MEM)
return (-1);
/*
* Allow access only in RAM.

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.29 2001/09/10 21:19:17 chris Exp $ */
/* $NetBSD: mem.c,v 1.30 2002/02/27 01:20:53 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -59,10 +59,6 @@
extern u_long maxaddr;
static caddr_t devzeropage;
#define mmread mmrw
#define mmwrite mmrw
cdev_decl(mm);
/*ARGSUSED*/
int
mmopen(dev, flag, mode, p)
@ -99,7 +95,7 @@ mmrw(dev, uio, flags)
static int physlock;
vm_prot_t prot;
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
/* lock against other uses of shared vmmap */
while (physlock > 0) {
physlock++;
@ -121,8 +117,7 @@ mmrw(dev, uio, flags)
}
switch (minor(dev)) {
/* minor device 0 is physical memory */
case 0:
case DEV_MEM:
v = uio->uio_offset;
/*
@ -146,8 +141,7 @@ mmrw(dev, uio, flags)
pmap_update(pmap_kernel());
continue;
/* minor device 1 is kernel memory */
case 1:
case DEV_KMEM:
v = uio->uio_offset;
c = min(iov->iov_len, MAXPHYS);
if (!uvm_kernacc((caddr_t)v, c,
@ -156,14 +150,12 @@ mmrw(dev, uio, flags)
error = uiomove((caddr_t)v, c, uio);
continue;
/* minor device 2 is EOF/RATHOLE */
case 2:
case DEV_NULL:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
/* minor device 12 (/dev/zero) is source of nulls on read, rathole on write */
case 12:
case DEV_ZERO:
if (uio->uio_rw == UIO_WRITE) {
c = iov->iov_len;
break;
@ -191,7 +183,7 @@ mmrw(dev, uio, flags)
uio->uio_offset += c;
uio->uio_resid -= c;
}
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
unlock:
if (physlock > 1)
wakeup((caddr_t)&physlock);
@ -214,7 +206,7 @@ mmmmap(dev, off, prot)
* and /dev/zero is a hack that is handled via the default
* pager in mmap().
*/
if (minor(dev) != 0)
if (minor(dev) != DEV_MEM)
return (-1);
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.23 2000/06/29 08:11:27 mrg Exp $ */
/* $NetBSD: mem.c,v 1.24 2002/02/27 01:20:53 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -56,10 +56,6 @@
#include <uvm/uvm_extern.h>
#define mmread mmrw
#define mmwrite mmrw
cdev_decl(mm);
extern paddr_t avail_end;
void *zeropage;
@ -108,8 +104,7 @@ mmrw(dev, uio, flags)
}
switch (minor(dev)) {
/* minor device 0 is physical memory */
case 0:
case DEV_MEM:
v = uio->uio_offset;
c = iov->iov_len;
/*
@ -121,8 +116,7 @@ mmrw(dev, uio, flags)
error = uiomove((void *)v, c, uio);
continue;
/* minor device 1 is kernel memory */
case 1:
case DEV_KMEM:
v = uio->uio_offset;
c = min(iov->iov_len, MAXPHYS);
if (v < MIPS_KSEG0_START)
@ -136,14 +130,12 @@ mmrw(dev, uio, flags)
error = uiomove((void *)v, c, uio);
continue;
/* minor device 2 is EOF/RATHOLE */
case 2:
case DEV_NULL:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
/* minor device 12 (/dev/zero) is source of nulls on read, rathole on write */
case 12:
case DEV_ZERO:
if (uio->uio_rw == UIO_WRITE) {
c = iov->iov_len;
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.17 2001/09/10 21:19:19 chris Exp $ */
/* $NetBSD: mem.c,v 1.18 2002/02/27 01:20:54 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -56,9 +56,6 @@
#include <uvm/uvm_extern.h>
#define mmread mmrw
cdev_decl(mm);
extern u_int lowram;
static caddr_t devzeropage;
@ -98,7 +95,7 @@ mmrw(dev, uio, flags)
static int physlock;
vm_prot_t prot;
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
/* lock against other uses of shared vmmap */
while (physlock > 0) {
physlock++;
@ -120,8 +117,7 @@ mmrw(dev, uio, flags)
}
switch (minor(dev)) {
/* minor device 0 is physical memory */
case 0:
case DEV_MEM:
v = uio->uio_offset;
#ifndef DEBUG
/* allow reads only in RAM (except for DEBUG) */
@ -143,8 +139,7 @@ mmrw(dev, uio, flags)
pmap_update(pmap_kernel());
continue;
/* minor device 1 is kernel memory */
case 1:
case DEV_KMEM:
v = uio->uio_offset;
c = min(iov->iov_len, MAXPHYS);
if (!uvm_kernacc((caddr_t)v, c,
@ -153,14 +148,12 @@ mmrw(dev, uio, flags)
error = uiomove((caddr_t)v, c, uio);
continue;
/* minor device 2 is EOF/RATHOLE */
case 2:
case DEV_NULL:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
/* minor device 12 (/dev/zero) is source of nulls on read, rathole on write */
case 12:
case DEV_ZERO:
if (uio->uio_rw == UIO_WRITE) {
c = iov->iov_len;
break;
@ -190,7 +183,7 @@ mmrw(dev, uio, flags)
uio->uio_offset += c;
uio->uio_resid -= c;
}
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
#ifndef DEBUG
unlock:
#endif
@ -215,7 +208,7 @@ mmmmap(dev, off, prot)
* and /dev/zero is a hack that is handled via the default
* pager in mmap().
*/
if (minor(dev) != 0)
if (minor(dev) != DEV_MEM)
return (-1);
/*
* Allow access only in RAM.

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.9 2001/12/16 04:17:02 tsutsui Exp $ */
/* $NetBSD: mem.c,v 1.10 2002/02/27 01:20:54 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -58,10 +58,6 @@
extern u_int lowram;
static caddr_t devzeropage;
#define mmread mmrw
#define mmwrite mmrw
cdev_decl(mm);
/*ARGSUSED*/
int
mmopen(dev, flag, mode, p)
@ -98,7 +94,7 @@ mmrw(dev, uio, flags)
static int physlock;
vm_prot_t prot;
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
/* lock against other uses of shared vmmap */
while (physlock > 0) {
physlock++;
@ -120,8 +116,7 @@ mmrw(dev, uio, flags)
}
switch (minor(dev)) {
/* minor device 0 is physical memory */
case 0:
case DEV_MEM:
v = uio->uio_offset;
/*
@ -145,8 +140,7 @@ mmrw(dev, uio, flags)
pmap_update(pmap_kernel());
continue;
/* minor device 1 is kernel memory */
case 1:
case DEV_KMEM:
v = uio->uio_offset;
c = min(iov->iov_len, MAXPHYS);
if (!uvm_kernacc((caddr_t)v, c,
@ -164,14 +158,12 @@ mmrw(dev, uio, flags)
error = uiomove((caddr_t)v, c, uio);
continue;
/* minor device 2 is EOF/RATHOLE */
case 2:
case DEV_NULL:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
/* minor device 12 (/dev/zero) is source of nulls on read, rathole on write */
case 12:
case DEV_ZERO:
if (uio->uio_rw == UIO_WRITE) {
c = iov->iov_len;
break;
@ -197,7 +189,7 @@ mmrw(dev, uio, flags)
uio->uio_offset += c;
uio->uio_resid -= c;
}
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
unlock:
if (physlock > 1)
wakeup((caddr_t)&physlock);
@ -220,7 +212,7 @@ mmmmap(dev, off, prot)
* and /dev/zero is a hack that is handled via the default
* pager in mmap().
*/
if (minor(dev) != 0)
if (minor(dev) != DEV_MEM)
return (-1);
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.15 2001/09/10 21:19:21 chris Exp $ */
/* $NetBSD: mem.c,v 1.16 2002/02/27 01:20:54 christos Exp $ */
/*
* This file was taken from mvme68k/mvme68k/mem.c
@ -63,10 +63,6 @@
#include <uvm/uvm_extern.h>
#define mmread mmrw
#define mmwrite mmrw
cdev_decl(mm);
extern u_int lowram;
static caddr_t devzeropage;
@ -106,7 +102,7 @@ mmrw(dev, uio, flags)
static int physlock;
vm_prot_t prot;
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
/* lock against other uses of shared vmmap */
while (physlock > 0) {
physlock++;
@ -127,8 +123,7 @@ mmrw(dev, uio, flags)
}
switch (minor(dev)) {
/* minor device 0 is physical memory */
case 0:
case DEV_MEM:
v = uio->uio_offset;
#ifndef DEBUG
/* allow reads only in RAM (except for DEBUG) */
@ -150,8 +145,7 @@ mmrw(dev, uio, flags)
pmap_update(pmap_kernel());
continue;
/* minor device 1 is kernel memory */
case 1:
case DEV_KMEM:
v = uio->uio_offset;
c = min(iov->iov_len, MAXPHYS);
if (!uvm_kernacc((caddr_t)v, c,
@ -160,14 +154,12 @@ mmrw(dev, uio, flags)
error = uiomove((caddr_t)v, c, uio);
continue;
/* minor device 2 is EOF/RATHOLE */
case 2:
case DEV_NULL:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
/* minor device 12 (/dev/zero) is source of nulls on read, rathole on write */
case 12:
case DEV_ZERO:
if (uio->uio_rw == UIO_WRITE) {
c = iov->iov_len;
break;
@ -197,7 +189,7 @@ mmrw(dev, uio, flags)
uio->uio_offset += c;
uio->uio_resid -= c;
}
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
#ifndef DEBUG
unlock:
#endif
@ -222,7 +214,7 @@ mmmmap(dev, off, prot)
* and /dev/zero is a hack that is handled via the default
* pager in mmap().
*/
if (minor(dev) != 0)
if (minor(dev) != DEV_MEM)
return (-1);
/*
* Allow access only in RAM.

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.29 2001/09/10 21:19:22 chris Exp $ */
/* $NetBSD: mem.c,v 1.30 2002/02/27 01:20:54 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -94,7 +94,7 @@ mmrw(dev, uio, flags)
static int physlock;
vm_prot_t prot;
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
/* lock against other uses of shared vmmap */
while (physlock > 0) {
physlock++;
@ -116,8 +116,7 @@ mmrw(dev, uio, flags)
}
switch (minor(dev)) {
/* minor device 0 is physical memory */
case 0:
case DEV_MEM:
v = uio->uio_offset;
prot = uio->uio_rw == UIO_READ ? VM_PROT_READ :
VM_PROT_WRITE;
@ -132,8 +131,7 @@ mmrw(dev, uio, flags)
pmap_update(pmap_kernel());
break;
/* minor device 1 is kernel memory */
case 1:
case DEV_KMEM:
v = uio->uio_offset;
c = min(iov->iov_len, MAXPHYS);
if (!uvm_kernacc((caddr_t)v, c,
@ -142,14 +140,12 @@ mmrw(dev, uio, flags)
error = uiomove((caddr_t)v, c, uio);
break;
/* minor device 2 is EOF/rathole */
case 2:
case DEV_NULL:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
/* minor device 12 (/dev/zero) is source of nulls on read, rathole on write */
case 12:
case DEV_ZERO:
if (uio->uio_rw == UIO_WRITE) {
uio->uio_resid = 0;
return (0);
@ -167,7 +163,7 @@ mmrw(dev, uio, flags)
return (ENXIO);
}
}
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
if (physlock > 1)
wakeup((caddr_t)&physlock);
physlock = 0;
@ -191,7 +187,7 @@ mmmmap(dev, off, prot)
* and /dev/zero is a hack that is handled via the default
* pager in mmap().
*/
if (minor(dev) != 0)
if (minor(dev) != DEV_MEM)
return (-1);
if ((u_int)off > ctob(physmem) && suser(p->p_ucred, &p->p_acflag) != 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.13 2001/11/30 07:53:13 chs Exp $ */
/* $NetBSD: mem.c,v 1.14 2002/02/27 01:20:54 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -51,15 +51,10 @@
#include <sys/uio.h>
#include <sys/malloc.h>
#include <sys/proc.h>
#include <sys/conf.h>
#include <uvm/uvm_extern.h>
/* These should be defined in a header somewhere */
int mmopen __P((dev_t, int, int));
int mmclose __P((dev_t, int, int));
int mmrw __P((dev_t, struct uio *, int));
paddr_t mmmmap __P((dev_t, off_t, int));
/*ARGSUSED*/
int
mmopen(dev, flag, mode)
@ -103,28 +98,24 @@ mmrw(dev, uio, flags)
}
switch (minor(dev)) {
/* minor device 0 is physical memory */
case 0:
case DEV_KMEM:
v = uio->uio_offset;
c = uio->uio_resid;
error = uiomove((caddr_t)v, c, uio);
break;
/* minor device 1 is kernel memory */
case 1:
case DEV_KMEM:
v = uio->uio_offset;
c = min(iov->iov_len, MAXPHYS);
error = uiomove((caddr_t)v, c, uio);
break;
/* minor device 2 is EOF/RATHOLE */
case 2:
case DEV_NULl:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
/* minor device 12 (/dev/zero) is source of nulls on read, rathole on write */
case 12:
case DEV_ZERO:
if (uio->uio_rw == UIO_WRITE) {
uio->uio_resid = 0;
return (0);
@ -153,7 +144,7 @@ mmmmap(dev, off, prot)
{
struct proc *p = curproc;
if (minor(dev) != 0)
if (minor(dev) != DEV_MEM)
return (-1);
if (atop(off) >= physmem && suser(p->p_ucred, &p->p_acflag) != 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.8 2002/02/12 15:26:50 uch Exp $ */
/* $NetBSD: mem.c,v 1.9 2002/02/27 01:20:55 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -95,7 +95,7 @@ mmrw(dev_t dev, struct uio *uio, int flags)
static int physlock;
vm_prot_t prot;
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
/* lock against other uses of shared vmmap */
while (physlock > 0) {
physlock++;
@ -117,8 +117,7 @@ mmrw(dev_t dev, struct uio *uio, int flags)
}
switch (minor(dev)) {
/* minor device 0 is physical memory */
case 0:
case DEV_MEM:
v = uio->uio_offset;
prot = uio->uio_rw == UIO_READ ? VM_PROT_READ :
VM_PROT_WRITE;
@ -133,8 +132,7 @@ mmrw(dev_t dev, struct uio *uio, int flags)
pmap_update(pmap_kernel());
break;
/* minor device 1 is kernel memory */
case 1:
case DEV_KMEM:
v = uio->uio_offset;
c = min(iov->iov_len, MAXPHYS);
if (v < SH3_P1SEG_BASE)
@ -146,14 +144,12 @@ mmrw(dev_t dev, struct uio *uio, int flags)
error = uiomove((caddr_t)v, c, uio);
break;
/* minor device 2 is EOF/rathole */
case 2:
case DEV_NULL:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
/* minor device 12 (/dev/zero) is source of nulls on read, rathole on write */
case 12:
case DEV_ZERO:
if (uio->uio_rw == UIO_WRITE) {
uio->uio_resid = 0;
return (0);
@ -171,7 +167,7 @@ mmrw(dev_t dev, struct uio *uio, int flags)
return (ENXIO);
}
}
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
if (physlock > 1)
wakeup((caddr_t)&physlock);
physlock = 0;
@ -192,7 +188,7 @@ mmmmap(dev_t dev, off_t off, int prot)
* and /dev/zero is a hack that is handled via the default
* pager in mmap().
*/
if (minor(dev) != 0)
if (minor(dev) != DEV_MEM)
return (-1);
if ((u_int)off > ctob(physmem) && suser(p->p_ucred, &p->p_acflag) != 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.29 2001/12/04 00:05:07 darrenr Exp $ */
/* $NetBSD: mem.c,v 1.30 2002/02/27 01:20:55 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -101,7 +101,7 @@ mmrw(dev, uio, flags)
vm_prot_t prot;
extern caddr_t vmmap;
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
/* lock against other uses of shared vmmap */
while (physlock > 0) {
physlock++;
@ -128,8 +128,7 @@ mmrw(dev, uio, flags)
switch (minor(dev)) {
/* minor device 0 is physical memory */
case 0:
case DEV_MEM:
pa = (paddr_t)uio->uio_offset;
if (!pmap_pa_exists(pa)) {
error = EFAULT;
@ -148,8 +147,7 @@ mmrw(dev, uio, flags)
pmap_update(pmap_kernel());
break;
/* minor device 1 is kernel memory */
case 1:
case DEV_KMEM:
va = (vaddr_t)uio->uio_offset;
if (va >= MSGBUF_VA && va < MSGBUF_VA+NBPG) {
c = min(iov->iov_len, 4096);
@ -166,8 +164,7 @@ mmrw(dev, uio, flags)
error = uiomove((void *)va, c, uio);
break;
/* minor device 2 is EOF/RATHOLE */
case 2:
case DEV_NULL:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
@ -175,11 +172,7 @@ mmrw(dev, uio, flags)
/* XXX should add sbus, etc */
#if defined(SUN4)
/*
* minor device 11 (/dev/eeprom) is the old-style
* (a'la Sun 3) EEPROM.
*/
case 11:
case DEV_EEPROM:
if (cputyp == CPU_SUN4)
error = eeprom_uio(uio);
else
@ -188,11 +181,7 @@ mmrw(dev, uio, flags)
break;
#endif /* SUN4 */
/*
* minor device 12 (/dev/zero) is source of nulls on read,
* rathole on write.
*/
case 12:
case DEV_ZERO:
if (uio->uio_rw == UIO_WRITE) {
uio->uio_resid = 0;
return(0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.19 2001/09/10 21:19:26 chris Exp $ */
/* $NetBSD: mem.c,v 1.20 2002/02/27 01:20:55 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -101,7 +101,7 @@ mmrw(dev, uio, flags)
extern caddr_t vmmap;
vsize_t msgbufsz;
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
/* lock against other uses of shared vmmap */
while (physlock > 0) {
physlock++;
@ -128,8 +128,7 @@ mmrw(dev, uio, flags)
switch (minor(dev)) {
/* minor device 0 is physical memory */
case 0:
case DEV_MEM:
#if 1
v = uio->uio_offset;
if (!pmap_pa_exists(v)) {
@ -213,8 +212,7 @@ mmrw(dev, uio, flags)
break;
#endif
/* minor device 1 is kernel memory */
case 1:
case DEV_KMEM:
v = uio->uio_offset;
msgbufsz = msgbufp->msg_bufs +
offsetof(struct kern_msgbuf, msg_bufc);
@ -236,19 +234,14 @@ mmrw(dev, uio, flags)
error = uiomove((caddr_t)v, c, uio);
break;
/* minor device 2 is EOF/RATHOLE */
case 2:
case DEV_NULL:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
/* XXX should add sbus, etc */
/*
* minor device 12 (/dev/zero) is source of nulls on read,
* rathole on write.
*/
case 12:
case DEV_ZERO:
if (uio->uio_rw == UIO_WRITE) {
uio->uio_resid = 0;
return(0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.5 2001/11/30 18:06:55 fredette Exp $ */
/* $NetBSD: mem.c,v 1.6 2002/02/27 01:20:55 christos Exp $ */
/*
* Copyright (c) 1994, 1995 Gordon W. Ross
@ -64,8 +64,6 @@
#include <sun2/sun2/machdep.h>
#define mmread mmrw
cdev_decl(mm);
static int promacc __P((caddr_t, int, int));
static caddr_t devzeropage;
@ -106,7 +104,7 @@ mmrw(dev, uio, flags)
static int physlock;
vm_prot_t prot;
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
if (vmmap == 0)
return (EIO);
/* lock against other uses of shared vmmap */
@ -130,7 +128,7 @@ mmrw(dev, uio, flags)
}
switch (minor(dev)) {
case 0: /* /dev/mem */
case DEV_MEM:
v = uio->uio_offset;
/* allow reads only in RAM */
if (v >= avail_end) {
@ -171,7 +169,7 @@ mmrw(dev, uio, flags)
pmap_update(pmap_kernel());
break;
case 1: /* /dev/kmem */
case DEV_KMEM:
v = uio->uio_offset;
use_kmem:
/*
@ -197,12 +195,12 @@ mmrw(dev, uio, flags)
error = uiomove((caddr_t)v, c, uio);
break;
case 2: /* /dev/null */
case DEV_NULL:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
case 12: /* /dev/zero */
case DEV_ZERO:
/* Write to /dev/zero is ignored. */
if (uio->uio_rw == UIO_WRITE) {
uio->uio_resid = 0;
@ -221,7 +219,7 @@ mmrw(dev, uio, flags)
error = uiomove(devzeropage, c, uio);
break;
case 13: /* /dev/leds */
case DEV_LEDS:
error = leds_uio(uio);
/* Yes, return (not break) so EOF works. */
return (error);
@ -237,7 +235,7 @@ mmrw(dev, uio, flags)
* redirection above jumps here on error to do its unlock.
*/
unlock:
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
if (physlock > 1)
wakeup((caddr_t)&physlock);
physlock = 0;
@ -259,18 +257,18 @@ mmmmap(dev, off, prot)
switch (minor(dev)) {
case 0: /* dev/mem */
case DEV_MEM:
/* Allow access only in "managed" RAM. */
if (off < avail_start || off >= avail_end)
break;
return (off);
case 5: /* dev/vme16d16 */
case DEV_VME16D16:
if (off & 0xffff0000)
break;
off |= 0xff0000;
/* fall through */
case 6: /* dev/vme24d16 */
case DEV_VME24D16:
if (off & 0xff000000)
break;
return (off | (off & 0x800000 ? PMAP_VME8: PMAP_VME0));

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.41 2001/09/10 21:19:27 chris Exp $ */
/* $NetBSD: mem.c,v 1.42 2002/02/27 01:20:55 christos Exp $ */
/*
* Copyright (c) 1994, 1995 Gordon W. Ross
@ -52,6 +52,7 @@
#include <sys/conf.h>
#include <sys/malloc.h>
#include <sys/proc.h>
#include <sys/ioctl.h>
#include <sys/uio.h>
#include <uvm/uvm_extern.h>
@ -65,8 +66,15 @@
#include <sun3/sun3/machdep.h>
#define mmread mmrw
cdev_decl(mm);
#define DEV_VME16D16 5 /* minor device 5 is /dev/vme16d16 */
#define DEV_VME24D16 6 /* minor device 6 is /dev/vme24d16 */
#define DEV_VME32D16 7 /* minor device 7 is /dev/vme32d16 */
#define DEV_VME16D32 8 /* minor device 8 is /dev/vme16d32 */
#define DEV_VME24D32 9 /* minor device 9 is /dev/vme24d32 */
#define DEV_VME32D32 10 /* minor device 10 is /dev/vme32d32 */
#define DEV_EEPROM 11 /* minor device 11 is eeprom */
#define DEV_LEDS 13 /* minor device 13 is leds */
static int promacc __P((caddr_t, int, int));
static caddr_t devzeropage;
@ -107,7 +115,7 @@ mmrw(dev, uio, flags)
static int physlock;
vm_prot_t prot;
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
if (vmmap == 0)
return (EIO);
/* lock against other uses of shared vmmap */
@ -131,7 +139,7 @@ mmrw(dev, uio, flags)
}
switch (minor(dev)) {
case 0: /* /dev/mem */
case DEV_MEM:
v = uio->uio_offset;
/* allow reads only in RAM */
if (v >= avail_end) {
@ -168,7 +176,7 @@ mmrw(dev, uio, flags)
pmap_update(pmap_kernel());
break;
case 1: /* /dev/kmem */
case DEV_KMEM:
v = uio->uio_offset;
use_kmem:
/*
@ -194,17 +202,17 @@ mmrw(dev, uio, flags)
error = uiomove((caddr_t)v, c, uio);
break;
case 2: /* /dev/null */
case DEV_NULL:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
case 11: /* /dev/eeprom */
case DEV_EEPROM:
error = eeprom_uio(uio);
/* Yes, return (not break) so EOF works. */
return (error);
case 12: /* /dev/zero */
case DEV_ZERO:
/* Write to /dev/zero is ignored. */
if (uio->uio_rw == UIO_WRITE) {
uio->uio_resid = 0;
@ -223,7 +231,7 @@ mmrw(dev, uio, flags)
error = uiomove(devzeropage, c, uio);
break;
case 13: /* /dev/leds */
case DEV_LEDS:
error = leds_uio(uio);
/* Yes, return (not break) so EOF works. */
return (error);
@ -239,7 +247,7 @@ mmrw(dev, uio, flags)
* redirection above jumps here on error to do its unlock.
*/
unlock:
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
if (physlock > 1)
wakeup((caddr_t)&physlock);
physlock = 0;
@ -261,36 +269,36 @@ mmmmap(dev, off, prot)
switch (minor(dev)) {
case 0: /* dev/mem */
case DEV_MEM:
/* Allow access only in "managed" RAM. */
if (off < avail_start || off >= avail_end)
break;
return (off);
case 5: /* dev/vme16d16 */
case DEV_VME16D16:
if (off & 0xffff0000)
break;
off |= 0xff0000;
/* fall through */
case 6: /* dev/vme24d16 */
case DEV_VME24D16:
if (off & 0xff000000)
break;
off |= 0xff000000;
/* fall through */
case 7: /* dev/vme32d16 */
case DEV_VME32D16:
return (off | PMAP_VME16);
case 8: /* dev/vme16d32 */
case DEV_VME16D32:
if (off & 0xffff0000)
break;
off |= 0xff0000;
/* fall through */
case 9: /* dev/vme24d32 */
case DEV_VME24D32:
if (off & 0xff000000)
break;
off |= 0xff000000;
/* fall through */
case 10: /* dev/vme32d32 */
case DEV_VME32D32:
return (off | PMAP_VME32);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.22 2001/09/10 21:19:28 chris Exp $ */
/* $NetBSD: mem.c,v 1.23 2002/02/27 01:20:56 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -63,11 +63,18 @@
#include <sun3/sun3/machdep.h>
#define DEV_VME16D16 5 /* minor device 5 is /dev/vme16d16 */
#define DEV_VME24D16 6 /* minor device 6 is /dev/vme24d16 */
#define DEV_VME32D16 7 /* minor device 7 is /dev/vme32d16 */
#define DEV_VME16D32 8 /* minor device 8 is /dev/vme16d32 */
#define DEV_VME24D32 9 /* minor device 9 is /dev/vme24d32 */
#define DEV_VME32D32 10 /* minor device 10 is /dev/vme32d32 */
#define DEV_EEPROM 11 /* minor device 11 is eeprom */
#define DEV_LEDS 13 /* minor device 13 is leds */
/* XXX - Put this in pmap_pvt.h or something? */
extern paddr_t avail_start;
#define mmread mmrw
cdev_decl(mm);
static int promacc __P((caddr_t, int, int));
static caddr_t devzeropage;
@ -108,7 +115,7 @@ mmrw(dev, uio, flags)
static int physlock;
vm_prot_t prot;
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
if (vmmap == 0)
return (EIO);
/* lock against other uses of shared vmmap */
@ -132,7 +139,7 @@ mmrw(dev, uio, flags)
}
switch (minor(dev)) {
case 0: /* /dev/mem */
case DEV_MEM:
v = uio->uio_offset;
/* allow reads only in RAM */
if (!pmap_pa_exists(v)) {
@ -163,7 +170,7 @@ mmrw(dev, uio, flags)
pmap_update(pmap_kernel());
break;
case 1: /* /dev/kmem */
case DEV_KMEM:
v = uio->uio_offset;
use_kmem:
/*
@ -183,17 +190,17 @@ mmrw(dev, uio, flags)
error = uiomove((caddr_t)v, c, uio);
break;
case 2: /* /dev/null */
case DEV_NULL:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
case 11: /* /dev/eeprom */
case DEV_EEPROM:
error = eeprom_uio(uio);
/* Yes, return (not break) so EOF works. */
return (error);
case 12: /* /dev/zero */
case DEL_ZERO:
/* Write to /dev/zero is ignored. */
if (uio->uio_rw == UIO_WRITE) {
uio->uio_resid = 0;
@ -212,7 +219,7 @@ mmrw(dev, uio, flags)
error = uiomove(devzeropage, c, uio);
break;
case 13: /* /dev/leds */
case DEV_LEDS:
error = leds_uio(uio);
/* Yes, return (not break) so EOF works. */
return (error);
@ -228,7 +235,7 @@ mmrw(dev, uio, flags)
* redirection above jumps here on error to do its unlock.
*/
unlock:
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
if (physlock > 1)
wakeup((caddr_t)&physlock);
physlock = 0;
@ -250,7 +257,7 @@ mmmmap(dev, off, prot)
switch (minor(dev)) {
case 0: /* dev/mem */
case DEV_MEM: /* dev/mem */
/* Allow access only in valid memory. */
if (!pmap_pa_exists(off))
break;
@ -258,30 +265,30 @@ mmmmap(dev, off, prot)
#if 0 /* XXX - NOTYET */
/* XXX - Move this to bus_subr.c? */
case 5: /* dev/vme16d16 */
case DEV_VME16D16:
if (off & 0xffff0000)
break;
off |= 0xff0000;
/* fall through */
case 6: /* dev/vme24d16 */
case DEV_VME24D16:
if (off & 0xff000000)
break;
off |= 0xff000000;
/* fall through */
case 7: /* dev/vme32d16 */
case DEV_VME32D16:
return (off | PMAP_VME16);
case 8: /* dev/vme16d32 */
case DEV_VME16D32:
if (off & 0xffff0000)
break;
off |= 0xff0000;
/* fall through */
case 9: /* dev/vme24d32 */
case DEV_VME24D32:
if (off & 0xff000000)
break;
off |= 0xff000000;
/* fall through */
case 10: /* dev/vme32d32 */
case DEV_VME32D32:
return (off | PMAP_VME32);
#endif /* XXX */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.21 2001/02/18 10:44:22 ragge Exp $ */
/* $NetBSD: mem.c,v 1.22 2002/02/27 01:20:56 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -58,9 +58,7 @@
#include "leds.h"
#define mmread mmrw
#define mmwrite mmrw
cdev_decl(mm);
#define DEV_LEDS 13 /* minor device 13 is leds */
extern unsigned int avail_end;
static caddr_t zeropage;
@ -101,8 +99,7 @@ mmrw(dev_t dev, struct uio *uio, int flags)
}
switch (minor(dev)) {
/* minor device 0 is physical memory */
case 0:
case DEV_MEM:
v = uio->uio_offset;
if (v < 0 || v >= avail_end) {
return (EFAULT);
@ -111,8 +108,7 @@ mmrw(dev_t dev, struct uio *uio, int flags)
c = min(iov->iov_len, MAXPHYS);
error = uiomove((caddr_t)v + KERNBASE, c, uio);
continue;
/* minor device 1 is kernel memory */
case 1:
case DEV_KMEM:
v = uio->uio_offset;
c = min(iov->iov_len, MAXPHYS);
if (!uvm_kernacc((caddr_t)v, c,
@ -121,14 +117,12 @@ mmrw(dev_t dev, struct uio *uio, int flags)
error = uiomove((caddr_t)v, c, uio);
continue;
/* minor device 2 is EOF/RATHOLE */
case 2:
case DEV_NULL:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
/* minor device 12 (/dev/zero) is source of nulls on read, rathole on write */
case 12:
case DEV_ZERO:
if (uio->uio_rw == UIO_WRITE) {
c = iov->iov_len;
break;
@ -142,7 +136,7 @@ mmrw(dev_t dev, struct uio *uio, int flags)
error = uiomove(zeropage, c, uio);
continue;
#if NLEDS
case 13: /* /dev/leds */
case DEV_LEDS:
error = leds_uio(uio);
/* Yes, return (not break) so EOF works. */
return (error);

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.26 2001/09/10 21:19:30 chris Exp $ */
/* $NetBSD: mem.c,v 1.27 2002/02/27 01:20:56 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -59,10 +59,6 @@
extern caddr_t Segtabzero;
static caddr_t devzeropage;
#define mmread mmrw
#define mmwrite mmrw
cdev_decl(mm);
/*ARGSUSED*/
int
mmopen(dev, flag, mode, p)
@ -101,7 +97,7 @@ mmrw(dev, uio, flags)
static int physlock;
vm_prot_t prot;
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
/* lock against other uses of shared vmmap */
while (physlock > 0) {
physlock++;
@ -123,8 +119,7 @@ mmrw(dev, uio, flags)
}
switch (minor(dev)) {
/* minor device 0 is physical memory */
case 0:
case DEV_MEM:
v = uio->uio_offset;
#ifndef DEBUG
/* allow reads only in RAM (except for DEBUG) */
@ -146,8 +141,7 @@ mmrw(dev, uio, flags)
pmap_update(pmap_kernel());
continue;
/* minor device 1 is kernel memory */
case 1:
case DEV_KMEM:
v = uio->uio_offset;
c = min(iov->iov_len, MAXPHYS);
if (!uvm_kernacc((caddr_t)v, c,
@ -156,14 +150,12 @@ mmrw(dev, uio, flags)
error = uiomove((caddr_t)v, c, uio);
continue;
/* minor device 2 is EOF/RATHOLE */
case 2:
case DEV_NULL:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
/* minor device 12 (/dev/zero) is source of nulls on read, rathole on write */
case 12:
case DEV_ZERO:
if (uio->uio_rw == UIO_WRITE) {
c = iov->iov_len;
break;
@ -192,7 +184,7 @@ mmrw(dev, uio, flags)
uio->uio_offset += c;
uio->uio_resid -= c;
}
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
#ifndef DEBUG
unlock:
#endif
@ -217,7 +209,7 @@ mmmmap(dev, off, prot)
* and /dev/zero is a hack that is handled via the default
* pager in mmap().
*/
if (minor(dev) != 0)
if (minor(dev) != DEV_MEM)
return (-1);
/*
* Allow access only in RAM.

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.1 2001/06/19 00:21:17 fvdl Exp $ */
/* $NetBSD: mem.c,v 1.2 2002/02/27 01:20:56 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -98,7 +98,7 @@ mmrw(dev, uio, flags)
static int physlock;
vm_prot_t prot;
if (minor(dev) == 0) {
if (minor(dev) == DEV_MEM) {
/* lock against other uses of shared vmmap */
while (physlock > 0) {
physlock++;
@ -120,8 +120,7 @@ mmrw(dev, uio, flags)
}
switch (minor(dev)) {
/* minor device 0 is physical memory */
case 0:
case DEV_MEM:
v = uio->uio_offset;
prot = uio->uio_rw == UIO_READ ? VM_PROT_READ :
VM_PROT_WRITE;
@ -134,8 +133,7 @@ mmrw(dev, uio, flags)
(vaddr_t)vmmap + PAGE_SIZE);
break;
/* minor device 1 is kernel memory */
case 1:
case DEV_KMEM:
v = uio->uio_offset;
c = min(iov->iov_len, MAXPHYS);
if (!uvm_kernacc((caddr_t)v, c,
@ -144,14 +142,12 @@ mmrw(dev, uio, flags)
error = uiomove((caddr_t)v, c, uio);
break;
/* minor device 2 is EOF/rathole */
case 2:
case DEV_NULL:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
/* minor device 12 (/dev/zero) is source of nulls on read, rathole on write */
case 12:
case DEV_ZERO:
if (uio->uio_rw == UIO_WRITE) {
uio->uio_resid = 0;
return (0);
@ -193,7 +189,7 @@ mmmmap(dev, off, prot)
* and /dev/zero is a hack that is handled via the default
* pager in mmap().
*/
if (minor(dev) != 0)
if (minor(dev) != DEV_MEM)
return (-1);
if (off > ctob(physmem) && suser(p->p_ucred, &p->p_acflag) != 0)