root/dev/usb/usb_port.h

/* [<][>][^][v][top][bottom][index][help] */
    1 /*      $OpenBSD: usb_port.h,v 1.96 2007/06/17 07:53:11 mbalmer Exp $ */
    2 /*      $NetBSD: usb_port.h,v 1.62 2003/02/15 18:33:30 augustss Exp $   */
    3 /*      $FreeBSD: src/sys/dev/usb/usb_port.h,v 1.21 1999/11/17 22:33:47 n_hibma Exp $   */
    4 
    5 /*
    6  * Copyright (c) 1998 The NetBSD Foundation, Inc.
    7  * All rights reserved.
    8  *
    9  * This code is derived from software contributed to The NetBSD Foundation
   10  * by Lennart Augustsson (lennart@augustsson.net) at
   11  * Carlstedt Research & Technology.
   12  *
   13  * Redistribution and use in source and binary forms, with or without
   14  * modification, are permitted provided that the following conditions
   15  * are met:
   16  * 1. Redistributions of source code must retain the above copyright
   17  *    notice, this list of conditions and the following disclaimer.
   18  * 2. Redistributions in binary form must reproduce the above copyright
   19  *    notice, this list of conditions and the following disclaimer in the
   20  *    documentation and/or other materials provided with the distribution.
   21  * 3. All advertising materials mentioning features or use of this software
   22  *    must display the following acknowledgement:
   23  *        This product includes software developed by the NetBSD
   24  *        Foundation, Inc. and its contributors.
   25  * 4. Neither the name of The NetBSD Foundation nor the names of its
   26  *    contributors may be used to endorse or promote products derived
   27  *    from this software without specific prior written permission.
   28  *
   29  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   30  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   31  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   32  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   33  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   34  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   35  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   36  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   37  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   38  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   39  * POSSIBILITY OF SUCH DAMAGE.
   40  */
   41 
   42 #ifndef _USB_PORT_H
   43 #define _USB_PORT_H
   44 
   45 /*
   46  * Macros to ease the import of USB drivers from other operating systems, e.g.
   47  * NetBSD or FreeBSD.
   48  */
   49 
   50 #ifdef __HAVE_GENERIC_SOFT_INTERRUPTS
   51 #define USB_USE_SOFTINTR
   52 #else
   53 #undef USB_USE_SOFTINTR
   54 #endif
   55 
   56 #define Static
   57 
   58 #define UMASS_ATAPISTR          "atapiscsi"
   59 
   60 /* periph_quirks */
   61 #define PQUIRK_NOSENSE          ADEV_NOSENSE    /* can't REQUEST SENSE */
   62 #define PQUIRK_ONLYBIG          SDEV_ONLYBIG
   63 
   64 #define sel_klist si_note
   65 
   66 typedef struct proc *usb_proc_ptr;
   67 
   68 #define UCOMBUSCF_PORTNO                0
   69 #define UCOMBUSCF_PORTNO_DEFAULT        -1
   70 #define UHIDBUSCF_REPORTID              0
   71 #define UHIDBUSCF_REPORTID_DEFAULT      -1
   72 
   73 #define mstohz(ms) ((ms) * hz / 1000)
   74 
   75 #define sel_klist si_note
   76 
   77 typedef int usb_malloc_type;
   78 
   79 #define if_deactivate(x)
   80 #define IF_INPUT(ifp, m) ether_input_mbuf((ifp), (m))
   81 
   82 #define swap_bytes_change_sign16_le swap_bytes_change_sign16
   83 #define change_sign16_swap_bytes_le change_sign16_swap_bytes
   84 #define change_sign16_le change_sign16
   85 
   86 #define ulinear8_to_slinear16_le ulinear8_to_linear16_le
   87 #define ulinear8_to_slinear16_be ulinear8_to_linear16_be
   88 #define slinear16_to_ulinear8_le linear16_to_ulinear8_le
   89 #define slinear16_to_ulinear8_be linear16_to_ulinear8_be
   90 
   91 typedef struct device *device_ptr_t;
   92 #define USBBASEDEVICE struct device
   93 #define USBDEV(bdev) (&(bdev))
   94 #define USBDEVNAME(bdev) ((bdev).dv_xname)
   95 #define USBDEVUNIT(bdev) ((bdev).dv_unit)
   96 #define USBDEVPTRNAME(bdevptr) ((bdevptr)->dv_xname)
   97 #define USBGETSOFTC(d) ((void *)(d))
   98 
   99 #define DECLARE_USB_DMA_T \
  100         struct usb_dma_block; \
  101         typedef struct { \
  102                 struct usb_dma_block *block; \
  103                 u_int offs; \
  104         } usb_dma_t
  105 
  106 typedef struct timeout usb_callout_t;
  107 #define usb_callout_init(h)     timeout_set(&(h), NULL, NULL)
  108 #define usb_callout(h, t, f, d) \
  109         do { \
  110                 timeout_del(&(h)); \
  111                 timeout_set(&(h), (f), (d)); \
  112                 timeout_add(&(h), (t)); \
  113         } while (0)
  114 #define usb_callout_pending(h)  timeout_pending(&(h))
  115 #define usb_uncallout(h, f, d) timeout_del(&(h))
  116 
  117 #define USB_DECLARE_DRIVER_CLASS(dname, devclass)  \
  118 int __CONCAT(dname,_match)(struct device *, void *, void *); \
  119 void __CONCAT(dname,_attach)(struct device *, struct device *, void *); \
  120 int __CONCAT(dname,_detach)(struct device *, int); \
  121 int __CONCAT(dname,_activate)(struct device *, enum devact); \
  122 \
  123 struct cfdriver __CONCAT(dname,_cd) = { \
  124         NULL, #dname, devclass \
  125 }; \
  126 \
  127 const struct cfattach __CONCAT(dname,_ca) = { \
  128         sizeof(struct __CONCAT(dname,_softc)), \
  129         __CONCAT(dname,_match), \
  130         __CONCAT(dname,_attach), \
  131         __CONCAT(dname,_detach), \
  132         __CONCAT(dname,_activate), \
  133 }
  134 
  135 #define USB_DECLARE_DRIVER(dname) USB_DECLARE_DRIVER_CLASS(dname, DV_DULL)
  136 
  137 #define USB_MATCH(dname) \
  138 int \
  139 __CONCAT(dname,_match)(parent, match, aux) \
  140         struct device *parent; \
  141         void *match; \
  142         void *aux;
  143 
  144 #define USB_MATCH_START(dname, uaa) \
  145         struct usb_attach_arg *uaa = aux
  146 
  147 #define USB_ATTACH(dname) \
  148 void \
  149 __CONCAT(dname,_attach)(parent, self, aux) \
  150         struct device *parent; \
  151         struct device *self; \
  152         void *aux;
  153 
  154 #define USB_ATTACH_START(dname, sc, uaa) \
  155         struct __CONCAT(dname,_softc) *sc = \
  156                 (struct __CONCAT(dname,_softc) *)self; \
  157         struct usb_attach_arg *uaa = aux
  158 
  159 /* Returns from attach */
  160 #define USB_ATTACH_ERROR_RETURN return
  161 #define USB_ATTACH_SUCCESS_RETURN       return
  162 
  163 #define USB_ATTACH_SETUP printf("\n")
  164 
  165 #define USB_DETACH(dname) \
  166 int \
  167 __CONCAT(dname,_detach)(self, flags) \
  168         struct device *self; \
  169         int flags;
  170 
  171 #define USB_DETACH_START(dname, sc) \
  172         struct __CONCAT(dname,_softc) *sc = \
  173                 (struct __CONCAT(dname,_softc) *)self
  174 
  175 #define USB_GET_SC_OPEN(dname, unit, sc) \
  176         if (unit >= __CONCAT(dname,_cd).cd_ndevs) \
  177                 return (ENXIO); \
  178         sc = __CONCAT(dname,_cd).cd_devs[unit]; \
  179         if (sc == NULL) \
  180                 return (ENXIO)
  181 
  182 #define USB_GET_SC(dname, unit, sc) \
  183         sc = __CONCAT(dname,_cd).cd_devs[unit]
  184 
  185 #define USB_DO_ATTACH(dev, bdev, parent, args, print, sub) \
  186         (config_found_sm(parent, args, print, sub))
  187 
  188 #endif /* _USB_PORT_H */

/* [<][>][^][v][top][bottom][index][help] */