summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2002-08-02 15:53:04 +0000
committerphk <phk@FreeBSD.org>2002-08-02 15:53:04 +0000
commit950d3e303cff2134dc7568fdd6922af8d478f2b2 (patch)
tree64f424aec108d22673fbee478a742abcec1e83de /sys
parent087e19f81f8eb2b32400a7352caded81bcf56ebb (diff)
downloadFreeBSD-src-950d3e303cff2134dc7568fdd6922af8d478f2b2.zip
FreeBSD-src-950d3e303cff2134dc7568fdd6922af8d478f2b2.tar.gz
Add the minimalist elan-mmcr device driver.
This driver allows a userland program to mmap the MMCR of the AMD Elan sc520 CPU.
Diffstat (limited to 'sys')
-rw-r--r--sys/conf/files.i3861
-rw-r--r--sys/i386/conf/NOTES4
-rw-r--r--sys/i386/i386/elan-mmcr.c82
3 files changed, 87 insertions, 0 deletions
diff --git a/sys/conf/files.i386 b/sys/conf/files.i386
index 883e084..b2feccd 100644
--- a/sys/conf/files.i386
+++ b/sys/conf/files.i386
@@ -192,6 +192,7 @@ i386/i386/db_disasm.c optional ddb
i386/i386/db_interface.c optional ddb
i386/i386/db_trace.c optional ddb
i386/i386/dump_machdep.c standard
+i366/i386/elan-mmcr.c optional elan-mmcr
i386/i386/elf_machdep.c standard
i386/i386/exception.s standard
i386/i386/i386-gdbstub.c optional ddb
diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES
index d74576b..ad6e6ec 100644
--- a/sys/i386/conf/NOTES
+++ b/sys/i386/conf/NOTES
@@ -183,6 +183,10 @@ options GPL_MATH_EMULATE #Support for x87 emulation via
#
options PERFMON
+#
+# Stuff specific to the AMD Elan Sc520 cpu.
+device elan-mmcr # Support mapping MMCR in userland.
+
#####################################################################
# NETWORKING OPTIONS
diff --git a/sys/i386/i386/elan-mmcr.c b/sys/i386/i386/elan-mmcr.c
new file mode 100644
index 0000000..28e8769
--- /dev/null
+++ b/sys/i386/i386/elan-mmcr.c
@@ -0,0 +1,82 @@
+/*
+ * ----------------------------------------------------------------------------
+ * "THE BEER-WARE LICENSE" (Revision 42):
+ * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
+ * can do whatever you want with this stuff. If we meet some day, and you think
+ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
+ * ----------------------------------------------------------------------------
+ *
+ * $FreeBSD$
+ *
+ */
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/conf.h>
+
+#include <machine/md_var.h>
+
+/*
+ * Device driver initialization stuff
+ */
+
+static d_open_t elan_open;
+static d_close_t elan_close;
+static d_ioctl_t elan_ioctl;
+static d_mmap_t elan_mmap;
+
+#define CDEV_MAJOR 100 /* Share with xrpu */
+static struct cdevsw elan_cdevsw = {
+ /* open */ elan_open,
+ /* close */ elan_close,
+ /* read */ noread,
+ /* write */ nowrite,
+ /* ioctl */ elan_ioctl,
+ /* poll */ nopoll,
+ /* mmap */ elan_mmap,
+ /* strategy */ nostrategy,
+ /* name */ "elan",
+ /* maj */ CDEV_MAJOR,
+ /* dump */ nodump,
+ /* psize */ nopsize,
+ /* flags */ 0,
+};
+
+static int
+elan_open(dev_t dev, int flag, int mode, struct thread *td)
+{
+ return (0);
+}
+
+static int
+elan_close(dev_t dev, int flag, int mode, struct thread *td)
+{
+ return (0);
+}
+
+static int
+elan_mmap(dev_t dev, vm_offset_t offset, int nprot)
+{
+ if (offset >= 0x1000)
+ return (-1);
+ return (i386_btop(0xfffef000));
+}
+
+static int
+elan_ioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct thread *tdr)
+{
+ return(ENOENT);
+}
+
+static void
+elan_drvinit(void)
+{
+
+ if (elan_mmcr == NULL)
+ return;
+ make_dev(&elan_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "elan-mmcr");
+ return;
+}
+
+
+SYSINIT(elan, SI_SUB_DRIVERS, SI_ORDER_MIDDLE+CDEV_MAJOR,elan_drvinit,NULL);
OpenPOWER on IntegriCloud