-/* $OpenBSD: mem.c,v 1.17 2016/08/16 18:17:36 tedu Exp $ */
+/* $OpenBSD: mem.c,v 1.18 2016/08/16 18:21:54 tedu Exp $ */
/* $NetBSD: mem.c,v 1.11 2003/10/16 12:02:58 jdolecek Exp $ */
/*
#endif
return (0);
}
-#define DEV_MEM 0
-#define DEV_KMEM 1
-#define DEV_NULL 2
-#define DEV_ZERO 12
int
mmrw(dev_t dev, struct uio *uio, int flags)
int error = 0;
vm_prot_t prot;
- if (minor(dev) == DEV_MEM) {
+ if (minor(dev) == 0) {
/* lock against other uses of shared vmmap */
error = rw_enter(&physlock, RW_WRITE | RW_INTR);
if (error)
}
switch (minor(dev)) {
- case DEV_MEM:
+ case 0:
v = uio->uio_offset;
prot = uio->uio_rw == UIO_READ ? PROT_READ :
PROT_WRITE;
pmap_update(pmap_kernel());
break;
- case DEV_KMEM:
+ case 1:
v = uio->uio_offset;
c = ulmin(iov->iov_len, MAXPHYS);
if (!uvm_kernacc((caddr_t)v, c,
error = uiomove((caddr_t)v, c, uio);
break;
- case DEV_NULL:
+ case 2:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
- case DEV_ZERO:
+ case 12:
if (uio->uio_rw == UIO_WRITE) {
uio->uio_resid = 0;
return (0);
return (ENXIO);
}
}
- if (minor(dev) == DEV_MEM) {
+ if (minor(dev) == 0) {
rw_exit(&physlock);
}
return (error);
* and /dev/zero is a hack that is handled via the default
* pager in mmap().
*/
- if (minor(dev) != DEV_MEM)
+ if (minor(dev) != 0)
return (-1);
/* minor device 0 is physical memory */
-/* $OpenBSD: mem.c,v 1.7 2016/08/15 22:01:59 tedu Exp $ */
+/* $OpenBSD: mem.c,v 1.8 2016/08/16 18:21:54 tedu Exp $ */
/* $NetBSD: mem.c,v 1.21 2006/07/23 22:06:07 ad Exp $ */
/*
#define mmwrite mmrw
cdev_decl(mm);
-#define DEV_MEM 0
-#define DEV_KMEM 1
-#define DEV_NULL 2
-#define DEV_ZERO 12
int
mmopen(dev_t dev, int flag, int mode, struct proc *p)
{
switch (minor(dev)) {
- case DEV_MEM:
- case DEV_KMEM:
- case DEV_NULL:
- case DEV_ZERO:
+ case 0:
+ case 1:
+ case 2:
+ case 12:
break;
default:
return (ENXIO);
v = uio->uio_offset;
switch (minor(dev)) {
- case DEV_MEM:
+ case 0:
/* Physical address */
if (__mm_mem_addr(v)) {
o = v & PGOFSET;
}
break;
- case DEV_KMEM:
+ case 1:
if (v < SH3_P1SEG_BASE) /* P0 */
return (EFAULT);
if (v < SH3_P2SEG_BASE) { /* P1 */
}
break;
- case DEV_NULL:
+ case 2:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
- case DEV_ZERO:
+ case 12:
if (uio->uio_rw == UIO_WRITE) {
uio->uio_resid = 0;
return (0);
{
struct proc *p = curproc;
- if (minor(dev) != DEV_MEM)
+ if (minor(dev) != 0)
return (-1);
if (__mm_mem_addr((paddr_t)off) == FALSE && suser(p, 0) != 0)