aboutsummaryrefslogtreecommitdiff
path: root/sys/ia64
diff options
context:
space:
mode:
Diffstat (limited to 'sys/ia64')
-rw-r--r--sys/ia64/conf/GENERIC2
-rw-r--r--sys/ia64/ia64/mem.c171
-rw-r--r--sys/ia64/include/memdev.h38
3 files changed, 61 insertions, 150 deletions
diff --git a/sys/ia64/conf/GENERIC b/sys/ia64/conf/GENERIC
index 859cd9d43713..f19dfc327530 100644
--- a/sys/ia64/conf/GENERIC
+++ b/sys/ia64/conf/GENERIC
@@ -140,6 +140,8 @@ device loop # Network loopback
device md # Memory "disks"
device pty # Pseudo-ttys (telnet etc)
device puc # Multi I/O cards and multi-channel UARTs
+device null # Null and zero devices
+device mem # Memory and kernel memory devices
device random # Entropy device
device tun # Packet tunnel.
device uart # Serial port (UART)
diff --git a/sys/ia64/ia64/mem.c b/sys/ia64/ia64/mem.c
index d03051f58e99..79c97ee3777f 100644
--- a/sys/ia64/ia64/mem.c
+++ b/sys/ia64/ia64/mem.c
@@ -34,9 +34,11 @@
*
* from: Utah $Hdr: mem.c 1.13 89/10/08$
* from: @(#)mem.c 7.2 (Berkeley) 5/9/91
- * $FreeBSD$
*/
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
/*
* Memory special file
*/
@@ -58,38 +60,12 @@
#include <machine/cpu.h>
#include <machine/frame.h>
-#ifdef PERFMON
-#include <machine/perfmon.h>
-#endif
#include <vm/vm.h>
#include <vm/pmap.h>
#include <vm/vm_extern.h>
-static struct cdev *memdev, *kmemdev;
-#ifdef PERFMON
-static struct cdev *perfdev;
-#endif /* PERFMON */
-
-static d_open_t mmopen;
-static d_close_t mmclose;
-static d_read_t mmrw;
-static d_ioctl_t mmioctl;
-static d_mmap_t memmmap;
-
-#define CDEV_MAJOR 2
-static struct cdevsw mem_cdevsw = {
- .d_version = D_VERSION,
- .d_open = mmopen,
- .d_close = mmclose,
- .d_read = mmrw,
- .d_write = mmrw,
- .d_ioctl = mmioctl,
- .d_mmap = memmmap,
- .d_name = "mem",
- .d_maj = CDEV_MAJOR,
- .d_flags = D_MEM | D_NEEDGIANT,
-};
+#include <machine/memdev.h>
struct mem_range_softc mem_range_softc;
@@ -99,49 +75,9 @@ ia64_pa_access(vm_offset_t pa)
return (VM_PROT_READ|VM_PROT_WRITE);
}
-static int
-mmclose(struct cdev *dev, int flags, int fmt, struct thread *td)
-{
- switch (minor(dev)) {
-#ifdef PERFMON
- case 32:
- return perfmon_close(dev, flags, fmt, td);
-#endif
- default:
- break;
- }
- return (0);
-}
-
-static int
-mmopen(struct cdev *dev, int flags, int fmt, struct thread *td)
-{
- int error;
-
- switch (minor(dev)) {
- case 0:
- case 1:
- if (flags & FWRITE) {
- error = securelevel_gt(td->td_ucred, 0);
- if (error)
- return error;
- }
- break;
- case 32:
-#ifdef PERFMON
- return perfmon_open(dev, flags, fmt, td);
-#else
- return ENODEV;
-#endif
- default:
- break;
- }
- return (0);
-}
-
-/*ARGSUSED*/
-static int
-mmrw(struct cdev *dev, struct uio *uio, int flags)
+/* ARGSUSED */
+int
+memrw(strct cdev *dev, struct uio *uio, int flags)
{
struct iovec *iov;
vm_offset_t addr, eaddr, o, v;
@@ -154,14 +90,11 @@ mmrw(struct cdev *dev, struct uio *uio, int flags)
uio->uio_iov++;
uio->uio_iovcnt--;
if (uio->uio_iovcnt < 0)
- panic("mmrw");
+ panic("memrw");
continue;
}
- switch (minor(dev)) {
-
-/* minor device 0 is physical memory */
- case 0:
+ if (minor(dev) == CDEV_MINOR_MEM) {
v = uio->uio_offset;
kmemphys:
/* Allow reads only in RAM. */
@@ -177,9 +110,8 @@ kmemphys:
c = min(uio->uio_resid, (int)(PAGE_SIZE - o));
error = uiomove((caddr_t)IA64_PHYS_TO_RR7(v), c, uio);
continue;
-
-/* minor device 1 is kernel memory */
- case 1:
+ }
+ else if (minor(dev) == CDEV_MINOR_KMEM) {
v = uio->uio_offset;
if (v >= IA64_RR_BASE(6)) {
@@ -205,27 +137,18 @@ kmemphys:
return (EFAULT);
error = uiomove((caddr_t)v, c, uio);
continue;
-
- default:
- return (ENODEV);
}
-
- if (error)
- break;
- iov->iov_base = (char *)iov->iov_base + c;
- iov->iov_len -= c;
- uio->uio_offset += c;
- uio->uio_resid -= c;
+ /* else panic! */
}
return (error);
}
-/*******************************************************\
-* allow user processes to MMAP some memory sections *
-* instead of going through read/write *
-\*******************************************************/
-static int
-memmmap(struct cdev *dev, vm_offset_t offset, vm_paddr_t *paddr, int prot)
+/*
+ * allow user processes to MMAP some memory sections
+ * instead of going through read/write
+ */
+int
+memmmap(strct cdev *dev, vm_offset_t offset, vm_paddr_t *paddr, int prot)
{
/*
* /dev/mem is the only one that makes sense through this
@@ -233,7 +156,7 @@ memmmap(struct cdev *dev, vm_offset_t offset, vm_paddr_t *paddr, int prot)
* could be transient and hence incorrect or invalid at
* a later time.
*/
- if (minor(dev) != 0)
+ if (minor(dev) != CDEV_MINOR_MEM)
return (-1);
/*
@@ -245,59 +168,7 @@ memmmap(struct cdev *dev, vm_offset_t offset, vm_paddr_t *paddr, int prot)
return (0);
}
-static int
-mmioctl(struct cdev *dev, u_long cmd, caddr_t cmdarg, int flags, struct thread *td)
+void
+dev_mem_md_init(void)
{
- switch(minor(dev)) {
-#ifdef PERFMON
- case 32:
- return perfmon_ioctl(dev, cmd, cmdarg, flags, td);
-#endif
- default:
- return ENODEV;
- }
-
- return (0);
}
-
-static int
-mem_modevent(module_t mod, int type, void *data)
-{
- switch(type) {
- case MOD_LOAD:
- if (bootverbose)
- printf("mem: <memory & I/O>\n");
-/* XXX - ??? */
-#if 0
- /* Initialise memory range handling */
- if (mem_range_softc.mr_op != NULL)
- mem_range_softc.mr_op->init(&mem_range_softc);
-#endif
-
- memdev = make_dev(&mem_cdevsw, 0, UID_ROOT, GID_KMEM,
- 0640, "mem");
- kmemdev = make_dev(&mem_cdevsw, 1, UID_ROOT, GID_KMEM,
- 0640, "kmem");
-#ifdef PERFMON
- perfdev = make_dev(&mem_cdevsw, 32, UID_ROOT, GID_KMEM,
- 0640, "perfmon");
-#endif /* PERFMON */
- return 0;
-
- case MOD_UNLOAD:
- destroy_dev(memdev);
- destroy_dev(kmemdev);
-#ifdef PERFMON
- destroy_dev(perfdev);
-#endif /* PERFMON */
- return 0;
-
- case MOD_SHUTDOWN:
- return 0;
-
- default:
- return EOPNOTSUPP;
- }
-}
-
-DEV_MODULE(mem, mem_modevent, NULL);
diff --git a/sys/ia64/include/memdev.h b/sys/ia64/include/memdev.h
new file mode 100644
index 000000000000..e2ec4918bd91
--- /dev/null
+++ b/sys/ia64/include/memdev.h
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2004 Mark R V Murray
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in this position and unchanged.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#define CDEV_MAJOR 2
+#define CDEV_MINOR_MEM 0
+#define CDEV_MINOR_KMEM 1
+
+d_open_t memopen;
+d_read_t memrw;
+#define memioctl (d_ioctl_t *)NULL;
+d_mmap_t memmmap;
+
+void dev_mem_md_init(void);