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/raid/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  * Copyright (c) 2000 Michael Smith
    3  * Copyright (c) 2003 Paul Saab
    4  * Copyright (c) 2003 Vinod Kashyap
    5  * Copyright (c) 2000 BSDi
    6  * All rights reserved.
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   27  * SUCH DAMAGE.
   28  *
   29  * $FreeBSD: src/sys/dev/twe/twe_compat.h,v 1.17 2012/11/17 01:52:19 svnexp Exp $
   30  */
   31 /*
   32  * Portability and compatibility interfaces.
   33  */
   34 
   35 #include <sys/param.h>
   36 #include <sys/systm.h>
   37 #include <sys/malloc.h>
   38 #include <sys/kernel.h>
   39 #include <sys/lock.h>
   40 #include <sys/sysctl.h>
   41 #include <sys/buf2.h>
   42 #include <sys/bus.h>
   43 #include <sys/conf.h>
   44 #include <sys/disk.h>
   45 #include <sys/stat.h>
   46 #include <sys/rman.h>
   47 #include <sys/devicestat.h>
   48 
   49 #include <bus/pci/pcireg.h>
   50 #include <bus/pci/pcivar.h>
   51 
   52 #define TWE_DRIVER_NAME         twe
   53 #define TWED_DRIVER_NAME        twed
   54 #define TWE_MALLOC_CLASS        M_TWE
   55 
   56 /* 
   57  * Wrappers for bus-space actions
   58  */
   59 #define TWE_CONTROL(sc, val)            bus_write_4((sc)->twe_io, 0x0, (u_int32_t)val)
   60 #define TWE_STATUS(sc)                  (u_int32_t)bus_read_4((sc)->twe_io, 0x4)
   61 #define TWE_COMMAND_QUEUE(sc, val)      bus_write_4((sc)->twe_io, 0x8, (u_int32_t)val)
   62 #define TWE_RESPONSE_QUEUE(sc)          bus_read_4((sc)->twe_io, 0xc)
   63 
   64 /*
   65  * FreeBSD-specific softc elements
   66  */
   67 #define TWE_PLATFORM_SOFTC                                                              \
   68     bus_dmamap_t                twe_cmdmap;     /* DMA map for command */                               \
   69     u_int32_t                   twe_cmdphys;    /* address of command in controller space */            \
   70     device_t                    twe_dev;                /* bus device */                \
   71     cdev_t                      twe_dev_t;              /* control device */            \
   72     struct resource             *twe_io;                /* register interface window */ \
   73     bus_dma_tag_t               twe_parent_dmat;        /* parent DMA tag */            \
   74     bus_dma_tag_t               twe_buffer_dmat;        /* data buffer DMA tag */       \
   75     bus_dma_tag_t               twe_cmd_dmat;           /* command buffer DMA tag */    \
   76     bus_dma_tag_t               twe_immediate_dmat;     /* command buffer DMA tag */    \
   77     struct resource             *twe_irq;               /* interrupt */                 \
   78     void                        *twe_intr;              /* interrupt handle */          \
   79     struct intr_config_hook     twe_ich;                /* delayed-startup hook */      \
   80     void                        *twe_cmd;               /* command structures */        \
   81     void                        *twe_immediate;         /* immediate commands */        \
   82     bus_dmamap_t                twe_immediate_map;                                      \
   83     struct sysctl_ctx_list      sysctl_ctx;                                             \
   84     struct sysctl_oid           *sysctl_tree;                                           \
   85     struct lock                 twe_io_lock;                                            \
   86     struct lock                 twe_config_lock;
   87 
   88 /*
   89  * FreeBSD-specific request elements
   90  */
   91 #define TWE_PLATFORM_REQUEST                                                                            \
   92     bus_dmamap_t                tr_dmamap;      /* DMA map for data */                                  \
   93     u_int32_t                   tr_dataphys;    /* data buffer base address in controller space */
   94 
   95 /*
   96  * Output identifying the controller/disk
   97  */
   98 #define twe_printf(sc, fmt, args...)    device_printf(sc->twe_dev, fmt , ##args)
   99 #define twed_printf(twed, fmt, args...) device_printf(twed->twed_dev, fmt , ##args)
  100 
  101 #define TWE_IO_LOCK(sc)                 lockmgr(&(sc)->twe_io_lock, LK_EXCLUSIVE)
  102 #define TWE_IO_UNLOCK(sc)               lockmgr(&(sc)->twe_io_lock, LK_RELEASE)
  103 #define TWE_CONFIG_LOCK(sc)             lockmgr(&(sc)->twe_config_lock, LK_EXCLUSIVE)
  104 #define TWE_CONFIG_UNLOCK(sc)           lockmgr(&(sc)->twe_config_lock, LK_RELEASE)
  105 #define TWE_CONFIG_ASSERT_LOCKED(sc)    KKASSERT(lockowned(&(sc)->twe_config_lock))
  106 
  107 /*
  108  * XXX
  109  *
  110  * Mimics FreeBSD's mtx_assert() behavior.
  111  * We might want a global lockassert() function in the future.
  112  */
  113 static __inline void
  114 twe_lockassert(struct lock *lockp)
  115 {
  116         if (panicstr == NULL && !dumping)
  117                 KKASSERT(lockstatus(lockp, curthread) != 0);
  118 }

Cache object: eb2e7a1e9295c829b0e07332a00a441a


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