-/* $OpenBSD: mem.c,v 1.28 2015/09/08 04:28:34 semarie Exp $ */
+/* $OpenBSD: mem.c,v 1.29 2016/07/27 21:13:39 tedu Exp $ */
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1982, 1986, 1990, 1993
#endif
-/*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)
{
}
switch (minor(dev)) {
-/* minor device 0 is physical memory */
+ /* minor device 0 is physical memory */
case 0:
v = PMAP_DIRECT_MAP(uio->uio_offset);
error = uiomove((caddr_t)v, uio->uio_resid, uio);
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;
break;
}
if (zeropage == NULL)
- zeropage = (caddr_t)
+ zeropage =
malloc(PAGE_SIZE, M_TEMP, M_WAITOK|M_ZERO);
c = ulmin(iov->iov_len, PAGE_SIZE);
error = uiomove(zeropage, c, uio);
struct proc *p = curproc; /* XXX */
switch (minor(dev)) {
-/* minor device 0 is physical memory */
+ /* minor device 0 is physical memory */
case 0:
if (suser(p, 0) != 0 && amd64_pa_used(off))
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)
return (mem_range_softc.mr_op->set(&mem_range_softc, mrd, arg));
}
-
#endif /* MTRR */
-