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/twe/twe_compat.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 /*-
    2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
    3  *
    4  * Copyright (c) 2000 Michael Smith
    5  * Copyright (c) 2003 Paul Saab
    6  * Copyright (c) 2003 Vinod Kashyap
    7  * Copyright (c) 2000 BSDi
    8  * All rights reserved.
    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  *
   19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   29  * SUCH DAMAGE.
   30  *
   31  * $FreeBSD$
   32  */
   33 /*
   34  * Portability and compatibility interfaces.
   35  */
   36 
   37 #ifdef __FreeBSD__
   38 /******************************************************************************
   39  * FreeBSD
   40  */
   41 #define TWE_SUPPORTED_PLATFORM
   42 
   43 #include <sys/param.h>
   44 #include <sys/endian.h>
   45 #include <sys/systm.h>
   46 #include <sys/malloc.h>
   47 #include <sys/kernel.h>
   48 #include <sys/lock.h>
   49 #include <sys/module.h>
   50 #include <sys/mutex.h>
   51 #include <sys/sysctl.h>
   52 #include <sys/sx.h>
   53 
   54 #include <sys/bio.h>
   55 #include <sys/bus.h>
   56 #include <sys/conf.h>
   57 #include <sys/disk.h>
   58 #include <sys/stat.h>
   59 
   60 #include <machine/bus.h>
   61 #include <machine/resource.h>
   62 #include <sys/rman.h>
   63 
   64 #include <dev/pci/pcireg.h>
   65 #include <dev/pci/pcivar.h>
   66 
   67 #include <geom/geom_disk.h>
   68 
   69 #define TWE_DRIVER_NAME         twe
   70 #define TWED_DRIVER_NAME        twed
   71 #define TWE_MALLOC_CLASS        M_TWE
   72 
   73 /* 
   74  * Wrappers for bus-space actions
   75  */
   76 #define TWE_CONTROL(sc, val)            bus_write_4((sc)->twe_io, 0x0, (u_int32_t)val)
   77 #define TWE_STATUS(sc)                  (u_int32_t)bus_read_4((sc)->twe_io, 0x4)
   78 #define TWE_COMMAND_QUEUE(sc, val)      bus_write_4((sc)->twe_io, 0x8, (u_int32_t)val)
   79 #define TWE_RESPONSE_QUEUE(sc)          (TWE_Response_Queue)bus_read_4((sc)->twe_io, 0xc)
   80 
   81 /*
   82  * FreeBSD-specific softc elements
   83  */
   84 #define TWE_PLATFORM_SOFTC                                                              \
   85     bus_dmamap_t                twe_cmdmap;     /* DMA map for command */                               \
   86     u_int32_t                   twe_cmdphys;    /* address of command in controller space */            \
   87     device_t                    twe_dev;                /* bus device */                \
   88     struct cdev *twe_dev_t;             /* control device */            \
   89     struct resource             *twe_io;                /* register interface window */ \
   90     bus_dma_tag_t               twe_parent_dmat;        /* parent DMA tag */            \
   91     bus_dma_tag_t               twe_buffer_dmat;        /* data buffer DMA tag */       \
   92     bus_dma_tag_t               twe_cmd_dmat;           /* command buffer DMA tag */    \
   93     bus_dma_tag_t               twe_immediate_dmat;     /* command buffer DMA tag */    \
   94     struct resource             *twe_irq;               /* interrupt */                 \
   95     void                        *twe_intr;              /* interrupt handle */          \
   96     struct intr_config_hook     twe_ich;                /* delayed-startup hook */      \
   97     void                        *twe_cmd;               /* command structures */        \
   98     void                        *twe_immediate;         /* immediate commands */        \
   99     bus_dmamap_t                twe_immediate_map;                                      \
  100     struct mtx                  twe_io_lock;                                            \
  101     struct sx                   twe_config_lock;
  102 
  103 /*
  104  * FreeBSD-specific request elements
  105  */
  106 #define TWE_PLATFORM_REQUEST                                                                            \
  107     bus_dmamap_t                tr_dmamap;      /* DMA map for data */                                  \
  108     u_int32_t                   tr_dataphys;    /* data buffer base address in controller space */
  109 
  110 /*
  111  * Output identifying the controller/disk
  112  */
  113 #define twe_printf(sc, fmt, args...)    device_printf(sc->twe_dev, fmt , ##args)
  114 #define twed_printf(twed, fmt, args...) device_printf(twed->twed_dev, fmt , ##args)
  115 
  116 #define TWE_IO_LOCK(sc)                 mtx_lock(&(sc)->twe_io_lock)
  117 #define TWE_IO_UNLOCK(sc)               mtx_unlock(&(sc)->twe_io_lock)
  118 #define TWE_IO_ASSERT_LOCKED(sc)        mtx_assert(&(sc)->twe_io_lock, MA_OWNED)
  119 #define TWE_CONFIG_LOCK(sc)             sx_xlock(&(sc)->twe_config_lock)
  120 #define TWE_CONFIG_UNLOCK(sc)           sx_xunlock(&(sc)->twe_config_lock)
  121 #define TWE_CONFIG_ASSERT_LOCKED(sc)    sx_assert(&(sc)->twe_config_lock, SA_XLOCKED)
  122 
  123 #endif /* FreeBSD */
  124 
  125 #ifndef TWE_SUPPORTED_PLATFORM
  126 #error platform not supported
  127 #endif

Cache object: 2d5276edba930f6a6b065ae597e309f2


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