Annotation of sys/arch/mvme68k/dev/vmel.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: vmel.c,v 1.14 2005/11/24 22:43:16 miod Exp $ */
! 2:
! 3: /*
! 4: * Copyright (c) 1995 Theo de Raadt
! 5: * All rights reserved.
! 6: *
! 7: * Redistribution and use in source and binary forms, with or without
! 8: * modification, are permitted provided that the following conditions
! 9: * are met:
! 10: * 1. Redistributions of source code must retain the above copyright
! 11: * notice, this list of conditions and the following disclaimer.
! 12: * 2. Redistributions in binary form must reproduce the above copyright
! 13: * notice, this list of conditions and the following disclaimer in the
! 14: * documentation and/or other materials provided with the distribution.
! 15: *
! 16: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
! 17: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
! 18: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
! 19: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
! 20: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
! 21: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
! 22: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
! 23: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
! 24: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
! 25: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! 26: */
! 27:
! 28: #include <sys/param.h>
! 29: #include <sys/proc.h>
! 30: #include <sys/user.h>
! 31: #include <sys/systm.h>
! 32: #include <sys/kernel.h>
! 33: #include <sys/device.h>
! 34:
! 35: #include <machine/autoconf.h>
! 36: #include <machine/conf.h>
! 37: #include <machine/cpu.h>
! 38:
! 39: #include <mvme68k/dev/vme.h>
! 40:
! 41: /*
! 42: * The VMEL driver deals with D32 transfers on the VME bus. The number
! 43: * of address bits (A16, A24, A32) is irrelevant since the mapping
! 44: * functions will decide how many address bits are relevant.
! 45: */
! 46:
! 47: void vmelattach(struct device *, struct device *, void *);
! 48: int vmelmatch(struct device *, void *, void *);
! 49:
! 50: int vmelscan(struct device *, void *, void *);
! 51:
! 52: struct cfattach vmel_ca = {
! 53: sizeof(struct vmelsoftc), vmelmatch, vmelattach
! 54: };
! 55:
! 56: struct cfdriver vmel_cd = {
! 57: NULL, "vmel", DV_DULL
! 58: };
! 59:
! 60: int
! 61: vmelmatch(parent, cf, args)
! 62: struct device *parent;
! 63: void *cf, *args;
! 64: {
! 65: return (1);
! 66: }
! 67:
! 68: int
! 69: vmelscan(parent, child, args)
! 70: struct device *parent;
! 71: void *child, *args;
! 72: {
! 73: return (vmescan(parent, child, args, BUS_VMEL));
! 74: }
! 75:
! 76: void
! 77: vmelattach(parent, self, args)
! 78: struct device *parent, *self;
! 79: void *args;
! 80: {
! 81: struct vmelsoftc *sc = (struct vmelsoftc *)self;
! 82:
! 83: printf("\n");
! 84:
! 85: sc->sc_vme = (struct vmesoftc *)parent;
! 86:
! 87: config_search(vmelscan, self, args);
! 88: }
! 89:
! 90: /*ARGSUSED*/
! 91: int
! 92: vmelopen(dev, flag, mode, p)
! 93: dev_t dev;
! 94: int flag, mode;
! 95: struct proc *p;
! 96: {
! 97: if (minor(dev) >= vmel_cd.cd_ndevs ||
! 98: vmel_cd.cd_devs[minor(dev)] == NULL)
! 99: return (ENODEV);
! 100: return (0);
! 101: }
! 102:
! 103: /*ARGSUSED*/
! 104: int
! 105: vmelclose(dev, flag, mode, p)
! 106: dev_t dev;
! 107: int flag, mode;
! 108: struct proc *p;
! 109: {
! 110:
! 111: return (0);
! 112: }
! 113:
! 114: /*ARGSUSED*/
! 115: int
! 116: vmelioctl(dev, cmd, data, flag, p)
! 117: dev_t dev;
! 118: u_long cmd;
! 119: caddr_t data;
! 120: int flag;
! 121: struct proc *p;
! 122: {
! 123: int error = 0;
! 124:
! 125: switch (cmd) {
! 126: default:
! 127: error = ENOTTY;
! 128: break;
! 129: }
! 130: return (error);
! 131: }
! 132:
! 133: int
! 134: vmelread(dev, uio, flags)
! 135: dev_t dev;
! 136: struct uio *uio;
! 137: int flags;
! 138: {
! 139: int unit = minor(dev);
! 140: struct vmelsoftc *sc = (struct vmelsoftc *) vmel_cd.cd_devs[unit];
! 141:
! 142: return (vmerw(sc->sc_vme, uio, flags, BUS_VMEL));
! 143: }
! 144:
! 145: int
! 146: vmelwrite(dev, uio, flags)
! 147: dev_t dev;
! 148: struct uio *uio;
! 149: int flags;
! 150: {
! 151: int unit = minor(dev);
! 152: struct vmelsoftc *sc = (struct vmelsoftc *) vmel_cd.cd_devs[unit];
! 153:
! 154: return (vmerw(sc->sc_vme, uio, flags, BUS_VMEL));
! 155: }
! 156:
! 157: paddr_t
! 158: vmelmmap(dev, off, prot)
! 159: dev_t dev;
! 160: off_t off;
! 161: int prot;
! 162: {
! 163: int unit = minor(dev);
! 164: struct vmelsoftc *sc = (struct vmelsoftc *) vmel_cd.cd_devs[unit];
! 165: paddr_t pa;
! 166:
! 167: pa = vmepmap(sc->sc_vme, (vaddr_t)off, NBPG, BUS_VMEL);
! 168: #ifdef DEBUG
! 169: printf("vmel %llx pa %p\n", off, pa);
! 170: #endif
! 171: if (pa == NULL)
! 172: return (-1);
! 173: return (atop(pa));
! 174: }
CVSweb