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/gpibvar.h

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: gpibvar.h,v 1.1 2003/06/02 03:45:42 gmcgarry Exp $     */
    2 
    3 /*-
    4  * Copyright (c) 2003 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Gregory McGarry.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  * 3. All advertising materials mentioning features or use of this software
   19  *    must display the following acknowledgement:
   20  *        This product includes software developed by the NetBSD
   21  *        Foundation, Inc. and its contributors.
   22  * 4. Neither the name of The NetBSD Foundation nor the names of its
   23  *    contributors may be used to endorse or promote products derived
   24  *    from this software without specific prior written permission.
   25  *
   26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   36  * POSSIBILITY OF SUCH DAMAGE.
   37  */
   38 
   39 #include <sys/queue.h>
   40 
   41 #define GPIB_NDEVS              30      /* max address */
   42 #define GPIB_ADDRMASK           0x1f    /* address mask */
   43 #define GPIB_BROADCAST_ADDR     31      /* GPIB broadcast address */
   44 
   45 /*
   46  * GPIB commands
   47  */
   48 
   49 /* Universal command group (UCG) [0x10] */
   50 #define GPIBCMD_LLO             0x11    /* local lockout */
   51 #define GPIBCMD_DCL             0x14    /* universal device clear */
   52 #define GPIBCMD_PPU             0x15    /* parallel poll unconfigure */
   53 #define GPIBCMD_SPE             0x18
   54 #define GPIBCMD_SPD             0x19
   55 
   56 /* Addressed command group (ACG) [0x00] */
   57 #define GPIBCMD_GTL             0x01
   58 #define GPIBCMD_SDC             0x04    /* selected device clear */
   59 #define GPIBCMD_PPC             0x05    /* parallel poll clear */
   60 #define GPIBCMD_GET             0x08
   61 #define GPIBCMD_TCT             0x09
   62 
   63 #define GPIBCMD_LAG             0x20    /* listener address group commands */
   64 #define GPIBCMD_UNL             0x3f    /* universal unlisten */
   65 #define GPIBCMD_TAG             0x40    /* talker address group commands */
   66 #define GPIBCMD_UNA             0x5e    /* unaddress (master talk address?) */
   67 #define GPIBCMD_UNT             0x5f    /* universal untalk */
   68 #define GPIBCMD_SCG             0x60    /* secondary group commands */
   69 #define GPIBCMD_PPD             0x70
   70 #define GPIBCMD_DEL             0x7f
   71 
   72 struct gpib_softc;
   73 
   74 struct gpib_chipset_tag {
   75         void    (*reset)(void *);
   76         int     (*send)(void *, int, int, void *, int);
   77         int     (*recv)(void *, int, int, void *, int);
   78         int     (*pptest)(void *, int);
   79         void    (*ppwatch)(void *, int);
   80         void    (*ppclear)(void *);
   81         void    (*xfer)(void *, int, int, void *, int, int, int);
   82         int     (*tc)(void *, int);
   83         int     (*gts)(void *);
   84         void    (*ifc)(void *);
   85         int     (*sendcmds)(void *, void *, int);
   86         int     (*senddata)(void *, void *, int);
   87         int     (*recvdata)(void *, void *, int);
   88         void    *cookie;
   89         struct gpib_softc *bus;
   90 };
   91 typedef struct gpib_chipset_tag *gpib_chipset_tag_t;
   92 
   93 /*
   94  * Wrapper functions that go directly to the hardware driver.
   95  */
   96 #define gpibreset(ic)                                                   \
   97         (*((ic)->reset))((ic)->cookie)
   98 #define gpibpptest(ic, slave)                                           \
   99         (*((ic)->pptest))((ic)->cookie, (slave))
  100 #define gpibppclear(ic)                                                 \
  101         (*((ic)->ppclear))((ic)->cookie)
  102 #define gpibxfer(ic, slave, sec, buf, cnt, rw, timo)                    \
  103         (*((ic)->xfer))((ic)->cookie, (slave), (sec), (buf), (cnt),     \
  104             (rw), (timo))
  105 
  106 /*
  107  * An GPIB job queue entry.  Slave drivers have one of these used
  108  * to queue requests with the controller.
  109  */
  110 typedef void (*gpib_callback_t)(void *, int); 
  111 struct gpibqueue {
  112         TAILQ_ENTRY(gpibqueue) hq_list; /* entry on queue */
  113         void    *hq_softc;              /* slave's softc */
  114         int     hq_slave;               /* slave on bus */
  115         gpib_callback_t hq_callback;    /* slave's callback function */
  116 };
  117 typedef struct gpibqueue *gpib_handle_t;
  118 
  119 int     _gpibregister(struct gpib_softc *, int, void (*cb)(void *, int),
  120             void *, gpib_handle_t *);
  121 int     _gpibrequest(struct gpib_softc *, gpib_handle_t);
  122 void    _gpibrelease(struct gpib_softc *, gpib_handle_t);
  123 int     _gpibswait(struct gpib_softc *, int);
  124 void    _gpibawait(struct gpib_softc *);
  125 int     _gpibsend(struct gpib_softc *, int, int, void *, int);
  126 int     _gpibrecv(struct gpib_softc *, int, int, void *, int);
  127 
  128 #define gpibsend(ic, slave, sec, addr, cnt)                             \
  129         _gpibsend((ic)->bus, (slave), (sec), (addr), (cnt))
  130 #define gpibrecv(ic, slave, sec, addr, cnt)                             \
  131         _gpibrecv((ic)->bus, (slave), (sec), (addr), (cnt))
  132 #define gpibregister(ic, slave, callback, arg, hdlp)            \
  133         _gpibregister((ic)->bus, (slave), (callback), (arg), (hdlp))
  134 #define gpibrequest(ic, hdl)                                    \
  135         _gpibrequest((ic)->bus, hdl)
  136 #define gpibrelease(ic, hdl)                                    \
  137         _gpibrelease((ic)->bus, hdl)
  138 #define gpibawait(ic)                                           \
  139         _gpibawait((ic)->bus)
  140 #define gpibswait(ic, slave)                                    \
  141         _gpibswait((ic)->bus, (slave))
  142 
  143 int     gpib_alloc(struct gpib_softc *, u_int8_t);
  144 int     gpib_isalloc(struct gpib_softc *, u_int8_t);
  145 void    gpib_dealloc(struct gpib_softc *, u_int8_t);
  146 
  147 /* called from controller drivers only */
  148 int     gpibintr(void *);
  149 int     gpibdevprint(void *, const char *);
  150 
  151 /* callback flags */
  152 #define GPIBCBF_START           1
  153 #define GPIBCBF_INTR            2
  154 
  155 /* gpibxfer dir(ection) parameter */
  156 #define GPIB_READ               1
  157 #define GPIB_WRITE              2
  158 
  159 /*
  160  * Attach devices
  161  */
  162 struct gpib_attach_args {
  163         gpib_chipset_tag_t ga_ic;               /* GPIB chipset tag */
  164         int ga_address;                         /* device GPIB address */
  165 };
  166 
  167 /*
  168  * Attach a GPIB to controller.
  169  */
  170 struct gpibdev_attach_args {
  171         gpib_chipset_tag_t ga_ic;               /* GPIB chipset tag */
  172         int ga_address;                         /* host GPIB address */
  173 };
  174 
  175 /*
  176  * Software state per GPIB bus.
  177  */
  178 struct gpib_softc {
  179         struct device sc_dev;                   /* generic device glue */
  180         gpib_chipset_tag_t sc_ic;               /* GPIB chipset tag */
  181         u_int8_t sc_myaddr;                     /* my (host) GPIB address */
  182         int sc_flags;
  183 #define GPIBF_ACTIVE    0x01
  184         u_int32_t sc_rmap;                      /* resource map */
  185         TAILQ_HEAD(, gpibqueue) sc_queue;       /* GPIB job queue */
  186 };

Cache object: f29336fb05f83bc6e2051b0de0135b4b


[ 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.