Annotation of sys/arch/mvme68k/dev/fooip.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: fooip.c,v 1.9 2004/07/30 22:29:44 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: /*
! 29: * A sample framework for writing an IP module driver.
! 30: */
! 31: #include <sys/param.h>
! 32: #include <sys/conf.h>
! 33: #include <sys/ioctl.h>
! 34: #include <sys/proc.h>
! 35: #include <sys/user.h>
! 36: #include <sys/tty.h>
! 37: #include <sys/uio.h>
! 38: #include <sys/systm.h>
! 39: #include <sys/kernel.h>
! 40: #include <sys/syslog.h>
! 41: #include <sys/fcntl.h>
! 42: #include <sys/device.h>
! 43: #include <machine/autoconf.h>
! 44: #include <machine/cpu.h>
! 45: #include <mvme68k/dev/ipicreg.h>
! 46:
! 47: struct fooipregs {
! 48: volatile u_char fooip_reg1;
! 49: volatile u_char fooip_vec;
! 50: };
! 51:
! 52: struct fooipsoftc {
! 53: struct device sc_dev;
! 54: struct ipicsoftc *sc_ipicsc;
! 55: struct intrhand sc_ih;
! 56:
! 57: int sc_slot;
! 58: struct fooipregs *sc_regs;
! 59: };
! 60:
! 61: void fooipattach(struct device *, struct device *, void *);
! 62: int fooipmatch(struct device *, void *, void *);
! 63:
! 64: struct cfattach fooip_ca = {
! 65: sizeof(struct fooipsoftc), fooipmatch, fooipattach
! 66: };
! 67:
! 68: struct cfdriver fooip_cd = {
! 69: NULL, "fooip", DV_DULL
! 70: };
! 71:
! 72: int fooipintr(void *);
! 73:
! 74: int
! 75: fooipmatch(parent, cf, args)
! 76: struct device *parent;
! 77: void *cf;
! 78: void *args;
! 79: {
! 80: return (1);
! 81: }
! 82:
! 83: void
! 84: fooipattach(parent, self, args)
! 85: struct device *parent, *self;
! 86: void *args;
! 87: {
! 88: struct fooipsoftc *sc = (struct fooipsoftc *)self;
! 89: struct confargs *ca = args;
! 90:
! 91: sc->sc_ipicsc = (struct ipicsoftc *)parent;
! 92: sc->sc_regs = (struct fooipregs *)(ca->ca_vaddr +
! 93: IPIC_IP_REGOFFSET);
! 94: sc->sc_slot = ca->ca_offset;
! 95:
! 96: /* this device uses only one interrupt */
! 97: sc->sc_ih.ih_fn = fooipintr;
! 98: sc->sc_ih.ih_arg = sc;
! 99: sc->sc_ih.ih_ipl = ca->ca_ipl;
! 100: ipicintr_establish(ca->ca_vec, &sc->sc_ih, self->dv_xname);
! 101:
! 102: sc->sc_regs->fooip_vec = ca->ca_vec;
! 103: sc->sc_ipicsc->sc_ipic->ipic_irq[sc->sc_slot][0] = ca->ca_ipl |
! 104: IPIC_IRQ_ICLR | IPIC_IRQ_IEN;
! 105:
! 106: printf("\n");
! 107: }
! 108:
! 109: int
! 110: fooipintr(arg)
! 111: void *arg;
! 112: {
! 113: struct fooipsoftc *sc = arg;
! 114:
! 115: if (sc->sc_ipicsc->sc_ipic->ipic_irq[sc->sc_slot][0] & IPIC_IRQ_INT) {
! 116: /* clear interrupt on device */
! 117: return (1);
! 118: }
! 119: return (0);
! 120: }
CVSweb