2 * Copyright (c) 2003-2004 HighPoint Technologies, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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
31 #include <dev/hptmv/mvOs.h>
32 #include <dev/hptmv/mvSata.h>
33 #include <dev/hptmv/mvStorageDev.h>
35 #define COMPANY "HighPoint Technologies, Inc."
36 #define COPYRIGHT "(c) 2000-2004. HighPoint Technologies, Inc."
37 #define DRIVER_NAME "RocketRAID 182x SATA Controller driver"
38 #define CONTROLLER_NAME "RocketRAID 182x SATA Controller"
39 #define PROC_DIR_NAME hptmv
41 #define HPT_INTERFACE_VERSION 0x01000003
42 #define SUPPORT_48BIT_LBA
44 #define SUPPORT_RAID5 1
46 #define MAX_QUEUE_COMM 32
47 #define MAX_SG_DESCRIPTORS 17
49 * One vbus per adapter in mv linux driver,
50 * MAX_VBUS is defined for share code and can not be 1
53 #define SET_VBUS_FOR_EACH_CONTROLLER
55 #define MAX_ARRAY_NAME 16
56 #define MAX_VDEVICE_PER_VBUS 8
57 #define MAX_ARRAY_DEVICE MAX_ARRAY_PER_VBUS
58 #define MAX_CHIP_IN_VBUS 1
61 #define SUPPORT_FAIL_LED
63 typedef void * PChipInstance;
64 typedef void * PChannel;
65 typedef struct _VDevice *PVDevice;
66 typedef struct _VBus *PVBus;
67 typedef struct _ArrayDescript *PArrayDescript;
68 typedef struct _ArrayDescriptV2 *PArrayDescriptV2;
69 typedef struct _Command *PCommand;
71 typedef struct _Device {
74 UCHAR df_removable_drive;
78 UCHAR df_tcq: 1; /* enable TCQ */
80 UCHAR df_ncq: 1; /* enable NCQ */
81 UCHAR df_write_cache_set: 1;
82 UCHAR df_write_cache: 1; /* enable write cache */
83 UCHAR df_read_ahead_set: 1;
84 UCHAR df_read_ahead: 1; /* enable read ahead */
90 UCHAR df_user_mode_set;
91 UCHAR bDeModeSetting; /* Current Data Transfer mode: 0-4 PIO 0-4 */
92 UCHAR bDeUsable_Mode; /* actual maximum data transfer mode */
93 UCHAR bDeUserSelectMode;
96 ULONG dDeRealCapacity;
103 typedef struct _SCAT_GATH {
104 ULONG_PTR dSgAddress;
107 } SCAT_GATH, FAR *FPSCAT_GATH;
110 typedef struct _VDevice_Ext {
111 #if defined(WIN95) && defined(SUPPORT_HOTSWAP)
114 UCHAR gui_locked; /* the device is locked by GUI */
116 } VDevice_Ext, *PVDevice_Ext;
119 #define SG_FLAG_SKIP 0x4000
120 #define SG_FLAG_EOT 0x8000
122 #if 0 /* MAX_VBUS==1 */
124 #define _VBUS_ARG0 void
127 #define _VBUS_INST(x)
130 #define _VBUS_ARG0 PVBus _vbus_p
131 #define _VBUS_ARG PVBus _vbus_p,
132 #define _VBUS_P _vbus_p,
133 #define _VBUS_P0 _vbus_p
134 #define _VBUS_INST(x) PVBus _vbus_p = x;
135 #define _vbus_(x) (_vbus_p->x)
138 /*************************************************************************
139 * arithmetic functions
140 *************************************************************************/
141 #define LongRShift(x, y) (x >> y)
142 #define LongLShift(x, y) (x << y)
143 #define LongDiv(x, y) (x / (UINT)(y))
144 #define LongRem(x, y) (x % (UINT)(y))
145 #define LongMul(x, y) (x * y)
146 /* Minimum and maximum macros */
147 #if (__FreeBSD_version < 501000)
148 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
149 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
152 /*************************************************************************
154 *************************************************************************/
155 int HPTLIBAPI os_memcmp(const void *cs, const void *ct, unsigned len);
156 void HPTLIBAPI os_memcpy(void *to, const void *from, unsigned len);
157 void HPTLIBAPI os_memset(void *s, char c, unsigned len);
158 unsigned HPTLIBAPI os_strlen(const char *s);
160 #define memcmp os_memcmp
161 #define memcpy os_memcpy
162 #define memset os_memset
163 #define strlen os_strlen
164 #elif (__FreeBSD_version <= 410000)
165 #define memcpy(d, s, len) bcopy((s),(d),(len))
166 #define memset(d, s, len) bzero((d),(len))
168 #define ZeroMemory(a, b) memset((char *)a, 0, b)
169 #define MemoryCopy(a,b,c) memcpy((char *)(a), (char *)(b), (UINT)(c))
170 #define farMemoryCopy(a,b,c) memcpy((char *)(a), (char *)(b), (UINT)c)
171 #define StrLen strlen
174 * we don't want whole hptintf.h in shared code...
175 * some constants must match that in hptintf.h!
177 enum _driver_events_t {
191 ET_INITIALIZE_STARTED,
192 ET_INITIALIZE_ABORTED,
193 ET_INITIALIZE_FAILED,
194 ET_INITIALIZE_FINISHED,
195 ET_VERIFY_DATA_ERROR,
198 extern void HPTLIBAPI ioctl_ReportEvent(UCHAR event, PVOID param);
199 #define StallExec(x) mvMicroSecondsDelay(x)
200 #define fNotifyGUI(WhatHappen, pVDevice) \
201 ioctl_ReportEvent(WhatHappen, pVDevice)
202 #define DECLARE_BUFFER(type, ptr) \
203 UCHAR ptr##__buf[512]; \
204 type ptr=(type)ptr##__buf
206 #include <dev/hptmv/atapi.h>
207 #include <dev/hptmv/command.h>
208 #include <dev/hptmv/array.h>
209 #include <dev/hptmv/raid5n.h>
210 #include <dev/hptmv/vdevice.h>
212 int HPTLIBAPI fDeReadWrite(PDevice pDev, ULONG Lba, UCHAR Cmd, void *tmpBuffer);
213 void HPTLIBAPI fDeSelectMode(PDevice pDev, UCHAR NewMode);
216 #define ArrayTables(i) ((PVDevice)&_vbus_(_ArrayTables)[i*ARRAY_VDEV_SIZE])