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/hptrr/os_bsd.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) HighPoint Technologies, Inc.
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   24  * SUCH DAMAGE.
   25  *
   26  * $FreeBSD$
   27  */
   28 #include <dev/hptrr/hptrr_config.h>
   29 /* $Id: os_bsd.h,v 1.18 2006/04/11 08:19:02 gmm Exp $
   30  *
   31  * HighPoint RAID Driver for FreeBSD
   32  * Copyright (C) 2005 HighPoint Technologies, Inc. All Rights Reserved.
   33  */
   34 
   35 #ifndef _OS_BSD_H
   36 #define _OS_BSD_H
   37 
   38 #ifndef DBG
   39 #define  DBG    0
   40 #endif
   41 
   42 #include <sys/param.h>
   43 #include <sys/types.h>
   44 #include <sys/cons.h>
   45 #if (__FreeBSD_version >= 500000) 
   46 #include <sys/time.h>
   47 #include <sys/systm.h> 
   48 #else 
   49 #include <machine/clock.h>      /*to support DELAY function under 4.x BSD versions*/
   50 #endif
   51 
   52 #include <sys/stat.h>
   53 #include <sys/malloc.h>
   54 #include <sys/conf.h>
   55 #include <sys/libkern.h>
   56 #include <sys/kernel.h>
   57 
   58 #if (__FreeBSD_version >= 500000)
   59 #include <sys/kthread.h>
   60 #include <sys/mutex.h>
   61 #include <sys/module.h>
   62 #endif
   63 
   64 #include <sys/eventhandler.h>
   65 #include <sys/bus.h>
   66 #include <sys/taskqueue.h>
   67 #include <sys/ioccom.h>
   68 
   69 #include <machine/resource.h>
   70 #include <machine/bus.h>
   71 #include <machine/stdarg.h>
   72 #include <sys/rman.h>
   73 
   74 #include <vm/vm.h>
   75 #include <vm/pmap.h>
   76 
   77 #if (__FreeBSD_version >= 500000)
   78 #include <dev/pci/pcireg.h>
   79 #include <dev/pci/pcivar.h>
   80 #else 
   81 #include <pci/pcivar.h>
   82 #include <pci/pcireg.h>
   83 #endif
   84 
   85 #if (__FreeBSD_version <= 500043)
   86 #include <sys/devicestat.h>
   87 #endif
   88 
   89 #include <cam/cam.h>
   90 #include <cam/cam_ccb.h>
   91 #include <cam/cam_sim.h>
   92 #include <cam/cam_xpt_sim.h>
   93 #include <cam/cam_debug.h>
   94 #include <cam/cam_xpt_periph.h>
   95 #include <cam/cam_periph.h>
   96 #include <cam/scsi/scsi_all.h>
   97 #include <cam/scsi/scsi_message.h>
   98 
   99 #if (__FreeBSD_version < 500043)
  100 #include <sys/bus_private.h>
  101 #endif
  102 
  103 
  104 typedef struct _INQUIRYDATA {
  105         u_char DeviceType : 5;
  106         u_char DeviceTypeQualifier : 3;
  107         u_char DeviceTypeModifier : 7;
  108         u_char RemovableMedia : 1;
  109         u_char Versions;
  110         u_char ResponseDataFormat;
  111         u_char AdditionalLength;
  112         u_char Reserved[2];
  113         u_char SoftReset : 1;
  114         u_char CommandQueue : 1;
  115         u_char Reserved2 : 1;
  116         u_char LinkedCommands : 1;
  117         u_char Synchronous : 1;
  118         u_char Wide16Bit : 1;
  119         u_char Wide32Bit : 1;
  120         u_char RelativeAddressing : 1;
  121         u_char VendorId[8];
  122         u_char ProductId[16];
  123         u_char ProductRevisionLevel[4];
  124         u_char VendorSpecific[20];
  125         u_char Reserved3[40];
  126 } 
  127 __attribute__((packed))
  128 INQUIRYDATA, *PINQUIRYDATA;
  129 
  130 #endif
  131 
  132 /* private headers */
  133 
  134 #include <dev/hptrr/osm.h>
  135 #include <dev/hptrr/him.h>
  136 #include <dev/hptrr/ldm.h>
  137 
  138 /* driver parameters */
  139 extern char driver_name[];
  140 extern char driver_name_long[];
  141 extern char driver_ver[];
  142 extern int  osm_max_targets;
  143 
  144 /*
  145  * adapter/vbus extensions:
  146  * each physical controller has an adapter_ext, passed to him.create_adapter()
  147  * each vbus has a vbus_ext passed to ldm_create_vbus().
  148  */
  149 #define EXT_TYPE_HBA  1
  150 #define EXT_TYPE_VBUS 2
  151 
  152 typedef struct _hba {
  153         int               ext_type;
  154         LDM_ADAPTER       ldm_adapter;
  155         device_t          pcidev;
  156         PCI_ADDRESS       pciaddr;
  157         struct _vbus_ext *vbus_ext;
  158         struct _hba      *next;
  159         
  160         struct {
  161                 struct resource *res;
  162                 int type;
  163                 int rid;
  164                 void *base;
  165         }
  166         pcibar[6];
  167 
  168         struct resource  *irq_res;
  169         void             *irq_handle;
  170 }
  171 HBA, *PHBA;
  172 
  173 typedef struct _os_cmdext {
  174         struct _vbus_ext  *vbus_ext;
  175         struct _os_cmdext *next;
  176         union ccb         *ccb;
  177         bus_dmamap_t       dma_map;
  178         SG                 psg[os_max_sg_descriptors];
  179 }
  180 OS_CMDEXT, *POS_CMDEXT;
  181 
  182 typedef struct _vbus_ext {
  183         int               ext_type;
  184         struct _vbus_ext *next;
  185         PHBA              hba_list;
  186         struct freelist  *freelist_head;
  187         struct freelist  *freelist_dma_head;
  188         
  189         struct cam_sim   *sim;    /* sim for this vbus */
  190         struct cam_path  *path;   /* peripheral, path, tgt, lun with this vbus */
  191 #if (__FreeBSD_version >= 500000)
  192         struct mtx        lock; /* general purpose lock */
  193 #else 
  194         int                     hpt_splx;
  195 #endif
  196         bus_dma_tag_t     io_dmat; /* I/O buffer DMA tag */
  197         
  198         POS_CMDEXT        cmdext_list;
  199 
  200         OSM_TASK         *tasks;
  201         struct task       worker;
  202         
  203         struct callout_handle timer;
  204 
  205         eventhandler_tag  shutdown_eh;
  206         
  207         /* the LDM vbus instance continues */
  208         unsigned long vbus[0] __attribute__((aligned(sizeof(unsigned long))));
  209 }
  210 VBUS_EXT, *PVBUS_EXT;
  211 
  212 #if __FreeBSD_version >= 500000
  213 #define hpt_lock_vbus(vbus_ext)   mtx_lock(&(vbus_ext)->lock)
  214 #define hpt_unlock_vbus(vbus_ext) mtx_unlock(&(vbus_ext)->lock)
  215 #else 
  216 static __inline void    hpt_lock_vbus(PVBUS_EXT vbus_ext)
  217 {
  218         vbus_ext->hpt_splx = splcam();
  219 }
  220 static __inline void    hpt_unlock_vbus(PVBUS_EXT vbus_ext)
  221 {
  222         splx(vbus_ext->hpt_splx);
  223 }
  224 #endif
  225 
  226 
  227 #define HPT_OSM_TIMEOUT (20*hz)  /* timeout value for OS commands */
  228 
  229 #define HPT_DO_IOCONTROL        _IOW('H', 0, HPT_IOCTL_PARAM)
  230 
  231 #define HPT_SCAN_BUS            _IO('H', 1)
  232 
  233 #if __FreeBSD_version >= 501000
  234 #define TASK_ENQUEUE(task)      taskqueue_enqueue(taskqueue_swi_giant,(task));
  235 #else 
  236 #define TASK_ENQUEUE(task)      taskqueue_enqueue(taskqueue_swi,(task));
  237 #endif
  238 
  239 #if __FreeBSD_version >= 500000
  240 static  __inline        int hpt_sleep(PVBUS_EXT vbus_ext, void *ident, int priority, const char *wmesg, int timo)
  241 {
  242         return  msleep(ident, &vbus_ext->lock, priority, wmesg, timo);
  243 }
  244 #else 
  245 static  __inline        int hpt_sleep(PVBUS_EXT vbus_ext, void *ident, int priority, const char *wmesg, int timo)
  246 {
  247         int retval = 0;
  248         
  249         asleep(ident, priority, wmesg, timo);
  250         hpt_unlock_vbus(vbus_ext);
  251         retval = await(priority, timo);
  252         hpt_lock_vbus(vbus_ext);
  253         
  254         return retval;
  255 }
  256 #endif
  257 
  258 #if __FreeBSD_version < 501000
  259 #define READ_16                         0x88
  260 #define WRITE_16                        0x8a
  261 #define SERVICE_ACTION_IN       0x9e
  262 #endif
  263 
  264 #define HPT_DEV_MAJOR   200

Cache object: dd6687205b9f170c29a326603bd581ee


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