svn commit: r252118 - in projects/altix2/sys/tests: . busdma
Marcel Moolenaar
marcel at FreeBSD.org
Sun Jun 23 16:59:00 UTC 2013
Author: marcel
Date: Sun Jun 23 16:58:59 2013
New Revision: 252118
URL: http://svnweb.freebsd.org/changeset/base/252118
Log:
Save the beginnings of a busdma unit test driver. The driver is to
synthesize devices with different DMA characteristics in order to test
the proper operation of the busdma infrastructure. Devices include:
1. host controller -- this component will be focussng on platform
properties, such as cache alignment, bounce buffering,
deferred DMA.
2. bridge -- this component will be focussing on mappings between CPU
(physical) addresses and bus addresses and I/O MMUs.
3. peripheral device -- this component will be checking the actual DMA
operation from an endpoint device's point of view and
subject to a wide range of constraints.
I suspect this will need some support from the busdma instrastructure
itself (via hooks or callbacks) so that the test driver has visibilty
in operations a typical device doesn't get to see. Think cache sync
operations, etc...
There's nothing here yet. Only a skeleton... and an idea.
Added:
projects/altix2/sys/tests/
projects/altix2/sys/tests/busdma/
projects/altix2/sys/tests/busdma/Makefile (contents, props changed)
projects/altix2/sys/tests/busdma/busdma.c (contents, props changed)
Added: projects/altix2/sys/tests/busdma/Makefile
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ projects/altix2/sys/tests/busdma/Makefile Sun Jun 23 16:58:59 2013 (r252118)
@@ -0,0 +1,12 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../../tests/busdma
+
+KMOD= busdma
+SRCS= busdma.c
+
+SRCS+= bus_if.h device_if.h
+
+MFILES= kern/bus_if.m kern/device_if.m
+
+.include <bsd.kmod.mk>
Added: projects/altix2/sys/tests/busdma/busdma.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ projects/altix2/sys/tests/busdma/busdma.c Sun Jun 23 16:58:59 2013 (r252118)
@@ -0,0 +1,114 @@
+/*-
+ * Copyright (c) 2012-2013 Marcel Moolenaar
+ * 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.
+ * 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 AUTHOR ``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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/uio.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/module.h>
+#include <sys/priv.h>
+#include <sys/disk.h>
+#include <sys/bus.h>
+#include <sys/filio.h>
+
+#include <machine/bus.h>
+#include <machine/vmparam.h>
+
+#define BUSDMA_VERSION 1
+
+static const char busdma_name[] = "busdma";
+
+/* For use with destroy_dev(9). */
+static struct cdev *busdma_dev;
+
+static d_read_t busdma_read;
+static d_write_t busdma_write;
+static d_ioctl_t busdma_ioctl;
+
+static struct cdevsw busdma_cdevsw = {
+ .d_version = D_VERSION,
+ .d_read = busdma_read,
+ .d_write = busdma_write,
+ .d_ioctl = busdma_ioctl,
+ .d_name = busdma_name,
+};
+
+static int
+busdma_read(struct cdev *dev __unused, struct uio *uio, int flags __unused)
+{
+
+ return (ENXIO);
+}
+
+static int
+busdma_write(struct cdev *dev __unused, struct uio *uio, int flags __unused)
+{
+
+ return (ENXIO);
+}
+
+static int
+busdma_ioctl(struct cdev *dev __unused, u_long cmd, caddr_t data __unused,
+ int flags __unused, struct thread *td)
+{
+
+ return (ENOIOCTL);
+}
+
+static int
+busdma_modevent(module_t mod __unused, int type, void *data __unused)
+{
+
+ switch(type) {
+ case MOD_LOAD:
+ printf("%s: <BUSDMA unit test driver, version %u>\n",
+ busdma_name, BUSDMA_VERSION);
+ busdma_dev = make_dev_credf(MAKEDEV_ETERNAL_KLD,
+ &busdma_cdevsw, 0, NULL, UID_ROOT, GID_WHEEL, 0666,
+ busdma_name);
+ break;
+
+ case MOD_UNLOAD:
+ destroy_dev(busdma_dev);
+ break;
+
+ case MOD_SHUTDOWN:
+ break;
+
+ default:
+ return (EOPNOTSUPP);
+ }
+
+ return (0);
+}
+
+DEV_MODULE(busdma, busdma_modevent, NULL);
+MODULE_VERSION(busdma, BUSDMA_VERSION);
More information about the svn-src-projects
mailing list