From owner-svn-src-projects@FreeBSD.ORG Sun Jun 23 16:59:00 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id C4883255; Sun, 23 Jun 2013 16:59:00 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id A885615D9; Sun, 23 Jun 2013 16:59:00 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5NGx0hK006933; Sun, 23 Jun 2013 16:59:00 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r5NGx0BP006931; Sun, 23 Jun 2013 16:59:00 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <201306231659.r5NGx0BP006931@svn.freebsd.org> From: Marcel Moolenaar Date: Sun, 23 Jun 2013 16:59:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r252118 - in projects/altix2/sys/tests: . busdma X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Jun 2013 16:59:00 -0000 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 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#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: \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);