The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/gpib/hil_gpib.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: hil_gpib.c,v 1.2 2003/07/14 15:40:04 lukem Exp $       */
    2 
    3 #include <sys/cdefs.h>
    4 __KERNEL_RCSID(0, "$NetBSD: hil_gpib.c,v 1.2 2003/07/14 15:40:04 lukem Exp $");
    5 
    6 #include <sys/param.h>
    7 #include <sys/systm.h>
    8 #include <sys/callout.h>
    9 #include <sys/conf.h>
   10 #include <sys/device.h>
   11 
   12 #include <dev/gpib/gpibvar.h>
   13 
   14 #ifdef DEBUG
   15 int     hildebug = 0;
   16 #define HDB_FOLLOW      0x01
   17 #define HDB_MMAP        0x02
   18 #define HDB_MASK        0x04
   19 #define HDB_CONFIG      0x08
   20 #define HDB_KEYBOARD    0x10
   21 #define HDB_IDMODULE    0x20
   22 #define HDB_EVENTS      0x80
   23 #define DPRINTF(mask, str)      if (hildebug & (mask)) printf str
   24 #else
   25 #define DPRINTF(mask, str)      /* nothing */
   26 #endif
   27 
   28 struct  hil_softc {
   29         struct device sc_dev;
   30         gpib_chipset_tag_t sc_ic;
   31         gpib_handle_t sc_hdl;
   32 
   33         int     sc_address;              /* GPIB address */
   34         int     sc_flags;
   35 #define HILF_ALIVE      0x01    
   36 #define HILF_OPEN       0x02    
   37 #define HILF_UIO        0x04
   38 #define HILF_TIMO       0x08
   39 #define HILF_DELAY      0x10
   40 };
   41 
   42 int     hilmatch(struct device *, struct cfdata *, void *);
   43 void    hilattach(struct device *, struct device *, void *);
   44 
   45 const struct cfattach hil_ca = {
   46         sizeof(struct hil_softc), hilmatch, hilattach,
   47 };
   48 
   49 void    hilcallback(void *, int);
   50 void    hilstart(void *);
   51 
   52 int
   53 hilmatch(parent, match, aux)
   54         struct device *parent;
   55         struct cfdata *match;
   56         void *aux;
   57 {
   58         struct gpib_attach_args *ga = aux;
   59         u_int8_t *cmd = "SE;";
   60         u_int8_t stat;
   61 
   62         if (gpibsend(ga->ga_ic, ga->ga_address, -1, cmd, 3) != 3)
   63                 return (0);
   64         if (gpibrecv(ga->ga_ic, ga->ga_address, -1, &stat, 1) != 1)
   65                 return (0);
   66         printf("hilmatch: enable status byte 0x%x\n", stat);
   67         return (1);
   68 }
   69 
   70 void
   71 hilattach(parent, self, aux)
   72         struct device *parent, *self;
   73         void *aux;
   74 {
   75         struct hil_softc *sc = (struct hil_softc *)self;
   76         struct gpib_attach_args *ga = aux;
   77 
   78         printf("\n");
   79 
   80         sc->sc_ic = ga->ga_ic;
   81         sc->sc_address = ga->ga_address;
   82 
   83         if (gpibregister(sc->sc_ic, sc->sc_address, hilcallback, sc,
   84             &sc->sc_hdl)) {
   85                 printf("%s: can't register callback\n", sc->sc_dev.dv_xname);
   86                 return;
   87         }
   88 
   89         sc->sc_flags = HILF_ALIVE;
   90 }
   91 
   92 void
   93 hilcallback(v, action)
   94         void *v;
   95         int action;
   96 {
   97         struct hil_softc *sc = v;
   98 
   99         DPRINTF(HDB_FOLLOW, ("hilcallback: v=%p, action=%d\n", v, action));
  100 
  101         switch (action) {
  102         case GPIBCBF_START:
  103                 hilstart(sc);
  104         case GPIBCBF_INTR:
  105                 /* no-op */
  106                 break;
  107 #ifdef DEBUG
  108         default:
  109                 DPRINTF(HDB_FOLLOW, ("hilcallback: unknown action %d\n",
  110                     action));
  111                 break;
  112 #endif
  113         }
  114 }
  115 
  116 void
  117 hilstart(v)
  118         void *v;
  119 {
  120         struct hil_softc *sc = v;
  121 
  122         DPRINTF(HDB_FOLLOW, ("hilstart(%x)\n", sc->sc_dev.dv_unit));
  123 
  124         sc->sc_flags &= ~HILF_DELAY;
  125 }

Cache object: 8d5ceb2fd5e6cb9abcb079595aa9cc69


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.