-/* $OpenBSD: mem.c,v 1.29 2016/08/01 15:58:22 tedu Exp $ */
+/* $OpenBSD: mem.c,v 1.30 2016/08/15 22:01:59 tedu Exp $ */
/* $NetBSD: mem.c,v 1.26 2000/03/29 03:48:20 simonb Exp $ */
/*
/* authorize only one simultaneous open() unless
* allowaperture=3 */
if (ap_open_count > 0 && allowaperture < 3)
- return(EPERM);
+ return (EPERM);
ap_open_count++;
return (0);
#endif
}
switch (minor(dev)) {
-/* minor device 0 is physical memory */
+ /* minor device 0 is physical memory */
case 0:
v = uio->uio_offset;
kmemphys:
error = uiomove((caddr_t)v, c, uio);
break;
-/* minor device 2 is EOF/rathole */
+ /* minor device 2 is /dev/null */
case 2:
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 */
+ /* minor device 12 is /dev/zero */
case 12:
if (uio->uio_rw == UIO_WRITE) {
uio->uio_resid = 0;
{
switch (minor(dev)) {
case 0:
- /*
- * /dev/mem is the only one that makes sense through this
- * interface. For /dev/kmem any physaddr we return here
- * could be transient and hence incorrect or invalid at
- * a later time. /dev/null just doesn't make any sense
- * and /dev/zero is a hack that is handled via the default
- * pager in mmap().
- */
-
- /*
- * Allow access only in RAM.
- */
+ /*
+ * /dev/mem is the only one that makes sense through this
+ * interface. For /dev/kmem any physaddr we return here
+ * could be transient and hence incorrect or invalid at
+ * a later time. /dev/null just doesn't make any sense
+ * and /dev/zero is a hack that is handled via the default
+ * pager in mmap().
+ */
+
+ /*
+ * Allow access only in RAM.
+ */
if ((prot & alpha_pa_access(atop(off))) != prot)
return (-1);
return off;
-/* $OpenBSD: mem.c,v 1.29 2016/07/27 21:13:39 tedu Exp $ */
+/* $OpenBSD: mem.c,v 1.30 2016/08/15 22:01:59 tedu Exp $ */
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1982, 1986, 1990, 1993
/* authorize only one simultaneous open() unless
* allowaperture=3 */
if (ap_open_count > 0 && allowaperture < 3)
- return(EPERM);
+ return (EPERM);
ap_open_count++;
break;
#endif
-/* $OpenBSD: mem.c,v 1.15 2016/08/01 15:58:22 tedu Exp $ */
+/* $OpenBSD: mem.c,v 1.16 2016/08/15 22:01:59 tedu Exp $ */
/* $NetBSD: mem.c,v 1.11 2003/10/16 12:02:58 jdolecek Exp $ */
/*
/* authorize only one simultaneous open() unless
* allowaperture=3 */
if (ap_open_count > 0 && allowaperture < 3)
- return(EPERM);
+ return (EPERM);
ap_open_count++;
break;
#endif
}
}
if (minor(dev) == DEV_MEM) {
-/*unlock:*/
if (physlock > 1)
wakeup((caddr_t)&physlock);
physlock = 0;
/* $NetBSD: mem.c,v 1.31 1996/05/03 19:42:19 christos Exp $ */
-/* $OpenBSD: mem.c,v 1.48 2016/07/28 16:08:56 tedu Exp $ */
+/* $OpenBSD: mem.c,v 1.49 2016/08/15 22:01:59 tedu Exp $ */
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1982, 1986, 1990, 1993
return (0);
}
-/*ARGSUSED*/
int
mmrw(dev_t dev, struct uio *uio, int flags)
{
}
switch (minor(dev)) {
-/* minor device 0 is physical memory */
+ /* minor device 0 is physical memory */
case 0:
v = uio->uio_offset;
pmap_enter(pmap_kernel(), (vaddr_t)vmmap,
pmap_update(pmap_kernel());
continue;
-/* minor device 1 is kernel memory */
+ /* minor device 1 is kernel memory */
case 1:
v = uio->uio_offset;
c = ulmin(iov->iov_len, MAXPHYS);
error = uiomove((caddr_t)v, c, uio);
continue;
-/* minor device 2 is EOF/RATHOLE */
+ /* minor device 2 is /dev/null */
case 2:
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 */
+ /* minor device 12 is /dev/zero */
case 12:
if (uio->uio_rw == UIO_WRITE) {
c = iov->iov_len;
struct proc *p = curproc; /* XXX */
switch (minor(dev)) {
-/* minor device 0 is physical memory */
+ /* minor device 0 is physical memory */
case 0:
if ((u_int)off > ptoa(physmem) && suser(p, 0) != 0)
return -1;
return off;
#ifdef APERTURE
-/* minor device 4 is aperture driver */
+ /* minor device 4 is aperture driver */
case 4:
/* Check if a write combining mapping is requested. */
if (off >= MEMRANGE_WC_RANGE)
}
#endif /* MTRR */
-
-/* $OpenBSD: mem.c,v 1.22 2015/09/06 16:24:19 deraadt Exp $ */
+/* $OpenBSD: mem.c,v 1.23 2016/08/15 22:01:59 tedu Exp $ */
/* $NetBSD: mem.c,v 1.1 1996/09/30 16:34:50 ws Exp $ */
/*
#endif /* SMALL_KERNEL */
-/*ARGSUSED*/
int
mmopen(dev_t dev, int flag, int mode, struct proc *p)
{
/* authorize only one simultaneous open() unless
* allowaperture=3 */
if (ap_open_count > 0 && allowaperture < 3)
- return(EPERM);
+ return (EPERM);
ap_open_count++;
break;
#endif
return (0);
}
-/*ARGSUSED*/
int
mmclose(dev_t dev, int flag, int mode, struct proc *p)
{
return 0;
}
-/*ARGSUSED*/
int
mmrw(dev_t dev, struct uio *uio, int flags)
{
error = uiomove((caddr_t)v, c, uio);
continue;
- /* minor device 2 is EOF/RATHOLE */
+ /* minor device 2 is /dev/null */
case 2:
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
- */
+ /* minor device 12 is /dev/zero */
case 12:
if (uio->uio_rw == UIO_WRITE) {
c = iov->iov_len;
return (-1);
}
-/*ARGSUSED*/
int
mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p)
{
-/* $OpenBSD: mem.c,v 1.6 2015/02/10 22:44:35 miod Exp $ */
+/* $OpenBSD: mem.c,v 1.7 2016/08/15 22:01:59 tedu Exp $ */
/* $NetBSD: mem.c,v 1.21 2006/07/23 22:06:07 ad Exp $ */
/*
#define DEV_NULL 2
#define DEV_ZERO 12
-/* ARGSUSED */
int
mmopen(dev_t dev, int flag, int mode, struct proc *p)
{
return (0);
}
-/*ARGSUSED*/
int
mmclose(dev_t dev, int flag, int mode, struct proc *p)
{
return (0);
}
-/*ARGSUSED*/
int
mmrw(dev_t dev, struct uio *uio, int flags)
{
return (error);
}
-/*ARGSUSED*/
paddr_t
mmmmap(dev_t dev, off_t off, int prot)
{
return ((paddr_t)off);
}
-/*ARGSUSED*/
int
mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p)
{
-/* $OpenBSD: mem.c,v 1.4 2015/02/10 22:44:35 miod Exp $ */
+/* $OpenBSD: mem.c,v 1.5 2016/08/15 22:01:59 tedu Exp $ */
/* $NetBSD: mem.c,v 1.1 1996/09/30 16:34:50 ws Exp $ */
/*
#include <machine/conf.h>
-/*ARGSUSED*/
int
mmopen(dev_t dev, int flag, int mode, struct proc *p)
{
return (0);
}
-/*ARGSUSED*/
int
mmclose(dev_t dev, int flag, int mode, struct proc *p)
{
return 0;
}
-/*ARGSUSED*/
int
mmrw(dev_t dev, struct uio *uio, int flags)
{
error = uiomove((caddr_t)v, c, uio);
continue;
- /* minor device 2 is EOF/RATHOLE */
+ /* minor device 2 is /dev/null */
case 2:
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
- */
+ /* minor device 12 is /dev/zero */
case 12:
if (uio->uio_rw == UIO_WRITE) {
c = iov->iov_len;
return (-1);
}
-/*ARGSUSED*/
int
mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p)
{
-/* $OpenBSD: mem.c,v 1.26 2016/07/27 15:12:36 tedu Exp $ */
+/* $OpenBSD: mem.c,v 1.27 2016/08/15 22:01:59 tedu Exp $ */
/* $NetBSD: mem.c,v 1.13 1996/03/30 21:12:16 christos Exp $ */
/*
error = uiomove((caddr_t)va, c, uio);
continue;
- /* minor device 2 is EOF/RATHOLE */
+ /* minor device 2 is /dev/null */
case 2:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
#if defined(SUN4)
-/* minor device 11 (/dev/eeprom) is the old-style (a'la Sun 3) EEPROM */
+ /* minor device 11 is /dev/eeprom */
case 11:
if (cputyp == CPU_SUN4)
error = eeprom_uio(uio);
continue;
#endif /* SUN4 */
-/* minor device 12 (/dev/zero) is source of nulls on read, rathole on write */
+ /* minor device 12 is /dev/zero */
case 12:
if (uio->uio_rw == UIO_WRITE) {
uio->uio_resid = 0;
-/* $OpenBSD: mem.c,v 1.15 2016/07/27 15:12:36 tedu Exp $ */
+/* $OpenBSD: mem.c,v 1.16 2016/08/15 22:01:59 tedu Exp $ */
/* $NetBSD: mem.c,v 1.18 2001/04/24 04:31:12 thorpej Exp $ */
/*
error = uiomove((caddr_t)v, c, uio);
break;
- /* minor device 2 is EOF/RATHOLE */
+ /* minor device 2 is /dev/null */
case 2:
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.
- */
+ /* minor device 12 is /dev/zero */
case 12:
if (uio->uio_rw == UIO_WRITE) {
uio->uio_resid = 0;