sys/dev/raid/hpt27xx/os_bsd.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | /*- * Copyright (c) 2011 HighPoint Technologies, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/hpt27xx/os_bsd.h,v 1.1 2011/12/28 23:26:58 delphij Exp $ */ #include <dev/raid/hpt27xx/hpt27xx_config.h> #ifndef _OS_BSD_H #define _OS_BSD_H #ifndef DBG #define DBG 0 #endif #include <sys/param.h> #include <sys/types.h> #include <sys/cons.h> #include <sys/time.h> #include <sys/systm.h> #include <sys/stat.h> #include <sys/malloc.h> #include <sys/conf.h> #include <sys/kernel.h> #include <sys/kthread.h> #include <sys/module.h> #include <sys/eventhandler.h> #include <sys/bus.h> #include <sys/taskqueue.h> #include <sys/ioccom.h> #include <sys/mplock2.h> #include <sys/device.h> #include <bus/pci/pci_cfgreg.h> #include <machine/stdarg.h> #include <sys/rman.h> #include <vm/vm.h> #include <vm/pmap.h> #include <bus/pci/pcireg.h> #include <bus/pci/pcivar.h> #include <bus/cam/cam.h> #include <bus/cam/cam_ccb.h> #include <bus/cam/cam_sim.h> #include <bus/cam/cam_xpt_sim.h> #include <bus/cam/cam_debug.h> #include <bus/cam/cam_xpt_periph.h> #include <bus/cam/cam_periph.h> #include <bus/cam/scsi/scsi_all.h> #include <bus/cam/scsi/scsi_message.h> typedef struct _INQUIRYDATA { u_char DeviceType : 5; u_char DeviceTypeQualifier : 3; u_char DeviceTypeModifier : 7; u_char RemovableMedia : 1; u_char Versions; u_char ResponseDataFormat; u_char AdditionalLength; u_char Reserved[2]; u_char SoftReset : 1; u_char CommandQueue : 1; u_char Reserved2 : 1; u_char LinkedCommands : 1; u_char Synchronous : 1; u_char Wide16Bit : 1; u_char Wide32Bit : 1; u_char RelativeAddressing : 1; u_char VendorId[8]; u_char ProductId[16]; u_char ProductRevisionLevel[4]; u_char VendorSpecific[20]; u_char Reserved3[40]; } __attribute__((packed)) INQUIRYDATA, *PINQUIRYDATA; #endif /* private headers */ #include <dev/raid/hpt27xx/osm.h> #include <dev/raid/hpt27xx/him.h> #include <dev/raid/hpt27xx/ldm.h> /* driver parameters */ extern char driver_name[]; extern char driver_name_long[]; extern char driver_ver[]; extern int osm_max_targets; /* * adapter/vbus extensions: * each physical controller has an adapter_ext, passed to him.create_adapter() * each vbus has a vbus_ext passed to ldm_create_vbus(). */ #define EXT_TYPE_HBA 1 #define EXT_TYPE_VBUS 2 typedef struct _hba { int ext_type; LDM_ADAPTER ldm_adapter; device_t pcidev; PCI_ADDRESS pciaddr; struct _vbus_ext *vbus_ext; struct _hba *next; struct { struct resource *res; int type; int rid; void *base; } pcibar[6]; struct resource *irq_res; void *irq_handle; } HBA, *PHBA; typedef struct _os_cmdext { struct _vbus_ext *vbus_ext; struct _os_cmdext *next; union ccb *ccb; bus_dmamap_t dma_map; SG psg[os_max_sg_descriptors]; } OS_CMDEXT, *POS_CMDEXT; typedef struct _vbus_ext { int ext_type; struct _vbus_ext *next; PHBA hba_list; struct freelist *freelist_head; struct freelist *freelist_dma_head; struct cam_sim *sim; /* sim for this vbus */ struct cam_path *path; /* peripheral, path, tgt, lun with this vbus */ struct lock lock; /* general purpose lock */ bus_dma_tag_t io_dmat; /* I/O buffer DMA tag */ POS_CMDEXT cmdext_list; OSM_TASK *tasks; struct task worker; struct callout timer; eventhandler_tag shutdown_eh; /* the LDM vbus instance continues */ unsigned long vbus[0] __attribute__((aligned(sizeof(unsigned long)))); } VBUS_EXT, *PVBUS_EXT; #define hpt_lock_vbus(vbus_ext) lockmgr(&(vbus_ext)->lock, LK_EXCLUSIVE) #define hpt_unlock_vbus(vbus_ext) lockmgr(&(vbus_ext)->lock, LK_RELEASE) #define HPT27XX_DFLTPHYS (64 * 1024) #define HPT_OSM_TIMEOUT (20*hz) /* timeout value for OS commands */ #define HPT_DO_IOCONTROL _IOW('H', 0, HPT_IOCTL_PARAM) #define HPT_SCAN_BUS _IO('H', 1) #define TASK_ENQUEUE(task) taskqueue_enqueue(taskqueue_swi,(task)); static __inline int hpt_sleep(PVBUS_EXT vbus_ext, void *ident, int priority, const char *wmesg, int timo) { return lksleep(ident, &vbus_ext->lock, priority, wmesg, timo); } |