]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - 6/sys/dev/rr232x/hptintf.h
Clone Kip's Xen on stable/6 tree so that I can work on improving FreeBSD/amd64
[FreeBSD/FreeBSD.git] / 6 / sys / dev / rr232x / hptintf.h
1 #include <dev/rr232x/rr232x_config.h>
2 /* $Id: hptintf.h,v 1.38 2006/02/16 03:29:07 gmm Exp $
3  * Copyright (C) 2004-2005 HighPoint Technologies, Inc. All rights reserved.
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23  * SUCH DAMAGE.
24  *
25  * $FreeBSD$
26  *
27  * File:         hptintf.h
28  * Description:  ioctl interface for HPT RAID driver
29  * Author:       Gu Mingming
30  * History:      2001-2-15 initial code
31  *               2001-4-5  change based on discuss with Dahai and Robin
32  *     v1.0.0.1
33  *               2001-7-17 add option to delete_array
34  *     v1.0.0.2
35  *               2001-12-5 Add hpt_get_driver_capabilities
36  *     v1.0.0.3
37  *               2002-1-11 Add HPT601 interface
38  *               2002-3-7  add hpt_lock/unlock_device
39  *               2002-4-22 S.M.A.R.T. interface
40  *                         RAID5 rebuild/verify
41  *                         Dedicated spare disk
42  *                               2003-3-18 RAID1.5 plus
43  *     Don't change version until all GUI get updated.
44  *               2003-4-23 hotswap capbility
45  *     v1.1.0.0
46  *               2003-11-17 define HPT_INTERFACE_VERSION outside this file;
47  *                          enlarge max array members.
48  *                          64-bit LBA support.
49  *     v2.0.0.0
50  *               2004-11-01 new functions to support OCE/ORLM
51  */
52
53 #ifndef HPT_INTF_H
54 #define HPT_INTF_H
55
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59
60 #ifndef __GNUC__
61 #define __attribute__(x)
62 #endif
63
64 #pragma pack(1)
65
66 /*
67  * Version of this interface.
68  * The user mode application must first issue a hpt_get_version() call to
69  * check HPT_INTERFACE_VERSION. When an utility using newer version interface
70  * is used with old version drivers, it must call only the functions that
71  * driver supported.
72  * A new version interface should only add ioctl functions; it should implement
73  * all old version functions without change their definition.
74  */
75 #define __this_HPT_INTERFACE_VERSION 0x02000000
76
77 #ifndef HPT_INTERFACE_VERSION
78 #error "You must define HPT_INTERFACE_VERSION you implemented"
79 #endif
80
81 #if HPT_INTERFACE_VERSION > __this_HPT_INTERFACE_VERSION
82 #error "HPT_INTERFACE_VERSION is invalid"
83 #endif
84
85 /*
86  * DEFINITION
87  *   Logical device  --- a device that can be accessed by OS.
88  *   Physical device --- device attached to the controller.
89  *  A logical device can be simply a physical device.
90  *
91  * Each logical and physical device has a 32bit ID. GUI will use this ID
92  * to identify devices.
93  *   1. The ID must be unique.
94  *   2. The ID must be immutable. Once an ID is assigned to a device, it
95  * must not change when system is running and the device exists.
96  *   3. The ID of logical device must be NOT reusable. If a device is
97  * removed, other newly created logical device must not use the same ID.
98  *   4. The ID must not be zero or 0xFFFFFFFF.
99  */
100 typedef HPT_U32 DEVICEID;
101
102 /*
103  * logical device type.
104  * Identify array (logical device) and physical device.
105  */
106 #define LDT_ARRAY       1
107 #define LDT_DEVICE      2
108
109 /*
110  * Array types
111  * GUI will treat all array as 1-level RAID. No RAID0/1 or RAID1/0.
112  * A RAID0/1 device is type AT_RAID1. A RAID1/0 device is type AT_RAID0.
113  * Their members may be another array of type RAID0 or RAID1.
114  */
115 #define AT_UNKNOWN      0
116 #define AT_RAID0        1
117 #define AT_RAID1        2
118 #define AT_RAID5        3
119 #define AT_RAID6    4
120 #define AT_JBOD         7
121
122 /*
123  * physical device type
124  */
125 #define PDT_UNKNOWN             0
126 #define PDT_HARDDISK    1
127 #define PDT_CDROM               2
128 #define PDT_TAPE                3
129
130 /*
131  * Some constants.
132  */
133 #define MAX_NAME_LENGTH         36
134 #define MAX_ARRAYNAME_LEN       16
135
136 #define MAX_ARRAY_MEMBERS_V1 8
137
138 #ifndef MAX_ARRAY_MEMBERS_V2
139 #define MAX_ARRAY_MEMBERS_V2 16
140 #endif
141
142 /* keep definition for source code compatiblity */
143 #define MAX_ARRAY_MEMBERS MAX_ARRAY_MEMBERS_V1
144
145 /*
146  * io commands
147  * GUI use these commands to do IO on logical/physical devices.
148  */
149 #define IO_COMMAND_READ         1
150 #define IO_COMMAND_WRITE        2
151
152 /* redundant arrays (RAID1 and RAID5, RAID10) have two creation format:
153  *      1. forground create --- zero all data on the array, and the array should not be reported to os before end of initialization.
154  *                                                      if initializing aborted, turns to background initialize.
155  *  2. backround create --- rebuild all data on the array, and the array can be reported to os just after creation.
156  *
157  *      if an array is in forground creation progress, it has the flag ARRAY_FLAG_NEEDINITIALIZING and ARRAY_FLAG_INITIALIZING,
158  *              GUI sends the INIT ioctl, driver zero the data of the array.
159  *      if an array is in backround creation progress, it has flag ARRAY_FLAG_NEEDINITIALIZING and ARRAY_FLAG_REBUIDING.
160  *              GUI sends the REBUILD ioctl, driver rebuilds the array.
161  */
162
163
164 /*
165  * array flags
166  */
167 #define ARRAY_FLAG_DISABLED                     0x00000001 /* The array is disabled */
168 #define ARRAY_FLAG_NEEDBUILDING         0x00000002 /* array data need to be rebuilt */
169 #define ARRAY_FLAG_REBUILDING           0x00000004 /* array is in rebuilding process */
170 #define ARRAY_FLAG_BROKEN                       0x00000008 /* broken but may still working */
171 #define ARRAY_FLAG_BOOTDISK                     0x00000010 /* array has a active partition */
172
173 #define ARRAY_FLAG_BOOTMARK                     0x00000040 /* array has boot mark set */
174 #define ARRAY_FLAG_NEED_AUTOREBUILD 0x00000080 /* auto-rebuild should start */
175 #define ARRAY_FLAG_VERIFYING        0x00000100 /* is being verified */
176 #define ARRAY_FLAG_INITIALIZING     0x00000200 /* is being initialized */
177 #define ARRAY_FLAG_TRANSFORMING     0x00000400 /* tranform in progress */
178 #define ARRAY_FLAG_NEEDTRANSFORM        0x00000800 /* array need tranform */
179 #define ARRAY_FLAG_NEEDINITIALIZING     0x00001000 /* the array's initialization hasn't finished*/
180 #define ARRAY_FLAG_BROKEN_REDUNDANT 0x00002000 /* broken but redundant (raid6) */
181 #define ARRAY_FLAG_RAID15PLUS           0x80000000 /* display this RAID 1 as RAID 1.5 */
182 /*
183  * device flags
184  */
185 #define DEVICE_FLAG_DISABLED            0x00000001 /* device is disabled */
186 #define DEVICE_FLAG_BOOTDISK            0x00000002 /* disk has a active partition */
187 #define DEVICE_FLAG_BOOTMARK            0x00000004 /* disk has boot mark set */
188 #define DEVICE_FLAG_WITH_601        0x00000008 /* has HPT601 connected */
189 #define DEVICE_FLAG_SATA            0x00000010 /* S-ATA device */
190
191 #define DEVICE_FLAG_UNINITIALIZED       0x00010000 /* device is not initialized, can't be used to create array */
192 #define DEVICE_FLAG_LEGACY                      0x00020000 /* single disk & mbr contains at least one partition */
193
194 #define DEVICE_FLAG_IS_SPARE            0x80000000 /* is a spare disk */
195
196 /*
197  * array states used by hpt_set_array_state()
198  */
199 /* old defines */
200 #define MIRROR_REBUILD_START    1
201 #define MIRROR_REBUILD_ABORT    2
202 #define MIRROR_REBUILD_COMPLETE 3
203 /* new defines */
204 #define AS_REBUILD_START 1
205 #define AS_REBUILD_ABORT 2
206 #define AS_REBUILD_PAUSE AS_REBUILD_ABORT
207 #define AS_REBUILD_COMPLETE 3
208 #define AS_VERIFY_START 4
209 #define AS_VERIFY_ABORT 5
210 #define AS_VERIFY_COMPLETE 6
211 #define AS_INITIALIZE_START 7
212 #define AS_INITIALIZE_ABORT 8
213 #define AS_INITIALIZE_COMPLETE 9
214 #define AS_VERIFY_FAILED 10
215 #define AS_REBUILD_STOP 11
216 #define AS_SAVE_STATE   12
217 #define AS_TRANSFORM_START 13
218 #define AS_TRANSFORM_ABORT 14
219
220 /************************************************************************
221  * ioctl code
222  * It would be better if ioctl code are the same on different platforms,
223  * but we must not conflict with system defined ioctl code.
224  ************************************************************************/
225 #if defined(LINUX) || defined(__FreeBSD_version) || defined(linux)
226 #define HPT_CTL_CODE(x) (x+0xFF00)
227 #define HPT_CTL_CODE_LINUX_TO_IOP(x) ((x)-0xff00)
228 #elif defined(_MS_WIN32_) || defined(WIN32)
229
230 #ifndef CTL_CODE
231 #define CTL_CODE( DeviceType, Function, Method, Access ) \
232                         (((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
233 #endif
234 #define HPT_CTL_CODE(x) CTL_CODE(0x370, 0x900+(x), 0, 0)
235 #define HPT_CTL_CODE_WIN32_TO_IOP(x) ((((x) & 0xffff)>>2)-0x900)
236
237 #else 
238 #define HPT_CTL_CODE(x) (x)
239 #endif
240
241 #define HPT_IOCTL_GET_VERSION                           HPT_CTL_CODE(0)
242 #define HPT_IOCTL_GET_CONTROLLER_COUNT          HPT_CTL_CODE(1)
243 #define HPT_IOCTL_GET_CONTROLLER_INFO           HPT_CTL_CODE(2)
244 #define HPT_IOCTL_GET_CHANNEL_INFO                      HPT_CTL_CODE(3)
245 #define HPT_IOCTL_GET_LOGICAL_DEVICES           HPT_CTL_CODE(4)
246 #define HPT_IOCTL_GET_DEVICE_INFO                       HPT_CTL_CODE(5)
247 #define HPT_IOCTL_CREATE_ARRAY                          HPT_CTL_CODE(6)
248 #define HPT_IOCTL_DELETE_ARRAY                          HPT_CTL_CODE(7)
249 #define HPT_IOCTL_ARRAY_IO                                      HPT_CTL_CODE(8)
250 #define HPT_IOCTL_DEVICE_IO                                     HPT_CTL_CODE(9)
251 #define HPT_IOCTL_GET_EVENT                                     HPT_CTL_CODE(10)
252 #define HPT_IOCTL_REBUILD_MIRROR                        HPT_CTL_CODE(11)
253 /* use HPT_IOCTL_REBUILD_DATA_BLOCK from now on */
254 #define HPT_IOCTL_REBUILD_DATA_BLOCK HPT_IOCTL_REBUILD_MIRROR
255 #define HPT_IOCTL_ADD_SPARE_DISK                        HPT_CTL_CODE(12)
256 #define HPT_IOCTL_REMOVE_SPARE_DISK                     HPT_CTL_CODE(13)
257 #define HPT_IOCTL_ADD_DISK_TO_ARRAY                     HPT_CTL_CODE(14)
258 #define HPT_IOCTL_SET_ARRAY_STATE                       HPT_CTL_CODE(15)
259 #define HPT_IOCTL_SET_ARRAY_INFO                        HPT_CTL_CODE(16)
260 #define HPT_IOCTL_SET_DEVICE_INFO                       HPT_CTL_CODE(17)
261 #define HPT_IOCTL_RESCAN_DEVICES                        HPT_CTL_CODE(18)
262 #define HPT_IOCTL_GET_DRIVER_CAPABILITIES   HPT_CTL_CODE(19)
263 #define HPT_IOCTL_GET_601_INFO              HPT_CTL_CODE(20)
264 #define HPT_IOCTL_SET_601_INFO              HPT_CTL_CODE(21)
265 #define HPT_IOCTL_LOCK_DEVICE               HPT_CTL_CODE(22)
266 #define HPT_IOCTL_UNLOCK_DEVICE             HPT_CTL_CODE(23)
267 #define HPT_IOCTL_IDE_PASS_THROUGH          HPT_CTL_CODE(24)
268 #define HPT_IOCTL_VERIFY_DATA_BLOCK         HPT_CTL_CODE(25)
269 #define HPT_IOCTL_INITIALIZE_DATA_BLOCK     HPT_CTL_CODE(26)
270 #define HPT_IOCTL_ADD_DEDICATED_SPARE       HPT_CTL_CODE(27)
271 #define HPT_IOCTL_DEVICE_IO_EX              HPT_CTL_CODE(28)
272 #define HPT_IOCTL_SET_BOOT_MARK             HPT_CTL_CODE(29)
273 #define HPT_IOCTL_QUERY_REMOVE              HPT_CTL_CODE(30)
274 #define HPT_IOCTL_REMOVE_DEVICES            HPT_CTL_CODE(31)
275 #define HPT_IOCTL_CREATE_ARRAY_V2           HPT_CTL_CODE(32)
276 #define HPT_IOCTL_GET_DEVICE_INFO_V2        HPT_CTL_CODE(33)
277 #define HPT_IOCTL_SET_DEVICE_INFO_V2        HPT_CTL_CODE(34)
278 #define HPT_IOCTL_REBUILD_DATA_BLOCK_V2     HPT_CTL_CODE(35)
279 #define HPT_IOCTL_VERIFY_DATA_BLOCK_V2      HPT_CTL_CODE(36)
280 #define HPT_IOCTL_INITIALIZE_DATA_BLOCK_V2  HPT_CTL_CODE(37)
281 #define HPT_IOCTL_LOCK_DEVICE_V2            HPT_CTL_CODE(38)
282 #define HPT_IOCTL_DEVICE_IO_V2              HPT_CTL_CODE(39)
283 #define HPT_IOCTL_DEVICE_IO_EX_V2           HPT_CTL_CODE(40)
284 #define HPT_IOCTL_CREATE_TRANSFORM              HPT_CTL_CODE(41)
285 #define HPT_IOCTL_STEP_TRANSFORM                HPT_CTL_CODE(42)
286 #define HPT_IOCTL_SET_VDEV_INFO                         HPT_CTL_CODE(43)
287 #define HPT_IOCTL_CALC_MAX_CAPACITY                     HPT_CTL_CODE(44)
288 #define HPT_IOCTL_INIT_DISKS                            HPT_CTL_CODE(45)
289 #define HPT_IOCTL_GET_DEVICE_INFO_V3            HPT_CTL_CODE(46)
290 #define HPT_IOCTL_GET_CONTROLLER_INFO_V2        HPT_CTL_CODE(47)
291 #define HPT_IOCTL_I2C_TRANSACTION           HPT_CTL_CODE(48)
292 #define HPT_IOCTL_GET_PARAMETER_LIST        HPT_CTL_CODE(49)
293 #define HPT_IOCTL_GET_PARAMETER             HPT_CTL_CODE(50)
294 #define HPT_IOCTL_SET_PARAMETER             HPT_CTL_CODE(51)
295
296
297 #define HPT_IOCTL_GET_CONTROLLER_IDS        HPT_CTL_CODE(100)
298 #define HPT_IOCTL_GET_DCB                   HPT_CTL_CODE(101)
299
300 #define HPT_IOCTL_EPROM_IO                  HPT_CTL_CODE(102)
301 #define HPT_IOCTL_GET_CONTROLLER_VENID      HPT_CTL_CODE(103)
302
303 /************************************************************************
304  * shared data structures
305  ************************************************************************/
306
307 /*
308  * Chip Type
309  */
310 #define CHIP_TYPE_HPT366      1
311 #define CHIP_TYPE_HPT368      2
312 #define CHIP_TYPE_HPT370      3
313 #define CHIP_TYPE_HPT370A     4
314 #define CHIP_TYPE_HPT370B     5
315 #define CHIP_TYPE_HPT374      6
316 #define CHIP_TYPE_HPT372      7
317 #define CHIP_TYPE_HPT372A     8
318 #define CHIP_TYPE_HPT302      9
319 #define CHIP_TYPE_HPT371      10
320 #define CHIP_TYPE_HPT372N     11
321 #define CHIP_TYPE_HPT302N     12
322 #define CHIP_TYPE_HPT371N     13
323 #define CHIP_TYPE_SI3112A     14
324 #define CHIP_TYPE_ICH5        15
325 #define CHIP_TYPE_ICH5R       16
326
327 /*
328  * Chip Flags
329  */
330 #define CHIP_SUPPORT_ULTRA_66   0x20
331 #define CHIP_SUPPORT_ULTRA_100  0x40
332 #define CHIP_HPT3XX_DPLL_MODE   0x80
333 #define CHIP_SUPPORT_ULTRA_133  0x01
334 #define CHIP_SUPPORT_ULTRA_150  0x02
335 #define CHIP_MASTER                             0x04
336 #define CHIP_SUPPORT_SATA_300   0x08
337
338 #define HPT_SPIN_UP_MODE_NOSUPPORT 0
339 #define HPT_SPIN_UP_MODE_FULL      1
340 #define HPT_SPIN_UP_MODE_STANDBY   2
341
342 typedef struct _DRIVER_CAPABILITIES {
343         HPT_U32 dwSize;
344
345         HPT_U8 MaximumControllers;           /* maximum controllers the driver can support */
346         HPT_U8 SupportCrossControllerRAID;   /* 1-support, 0-not support */
347         HPT_U8 MinimumBlockSizeShift;        /* minimum block size shift */
348         HPT_U8 MaximumBlockSizeShift;           /* maximum block size shift */
349
350         HPT_U8 SupportDiskModeSetting;
351         HPT_U8 SupportSparePool;
352         HPT_U8 MaximumArrayNameLength;
353         /* only one HPT_U8 left here! */
354 #ifdef __BIG_ENDIAN_BITFIELD
355         HPT_U8 reserved: 4;
356         HPT_U8 SupportHotSwap: 1;
357         HPT_U8 HighPerformanceRAID1: 1;
358         HPT_U8 RebuildProcessInDriver: 1;
359         HPT_U8 SupportDedicatedSpare: 1;
360 #else 
361         HPT_U8 SupportDedicatedSpare: 1; /* call hpt_add_dedicated_spare() for dedicated spare. */
362         HPT_U8 RebuildProcessInDriver: 1; /* Windows only. used by mid layer for rebuild control. */
363         HPT_U8 HighPerformanceRAID1: 1; /* Support RAID1.5 */
364         HPT_U8 SupportHotSwap: 1;
365         HPT_U8 reserved: 4;
366 #endif
367
368         /* SupportedRAIDTypes is an array of bytes, one of each is an array type.
369          * Only non-zero values is valid. Bit0-3 represents the lower(child) level RAID type;
370          * bit4-7 represents the top level. i.e.
371          *     RAID 0/1 is (AT_RAID1<<4) | AT_RAID0
372          *     RAID 5/0 is (AT_RAID0<<4) | AT_RAID5
373          */
374         HPT_U8 SupportedRAIDTypes[16];
375         /* maximum members in an array corresponding to SupportedRAIDTypes */
376         HPT_U8 MaximumArrayMembers[16];
377 }
378 DRIVER_CAPABILITIES, *PDRIVER_CAPABILITIES;
379
380 /*
381  * Controller information.
382  */
383 typedef struct _CONTROLLER_INFO {
384         HPT_U8 ChipType;                                                /* chip type */
385     HPT_U8 InterruptLevel;                              /* IRQ level */
386         HPT_U8 NumBuses;                                                /* bus count */
387         HPT_U8 ChipFlags;
388
389     HPT_U8 szProductID[MAX_NAME_LENGTH];        /* product name */
390     HPT_U8 szVendorID[MAX_NAME_LENGTH];  /* vender name */
391
392 } CONTROLLER_INFO, *PCONTROLLER_INFO;
393
394 #if HPT_INTERFACE_VERSION>=0x01020000
395 typedef struct _CONTROLLER_INFO_V2 {
396         HPT_U8 ChipType;                                                /* chip type */
397     HPT_U8 InterruptLevel;                              /* IRQ level */
398         HPT_U8 NumBuses;                                                /* bus count */
399         HPT_U8 ChipFlags;
400
401     HPT_U8 szProductID[MAX_NAME_LENGTH];        /* product name */
402     HPT_U8 szVendorID[MAX_NAME_LENGTH];  /* vender name */
403
404     HPT_U32 GroupId;                                            /* low 32bit of vbus pointer the controller belongs
405                                                                                  * the master controller has CHIP_MASTER flag set*/
406     HPT_U8      pci_tree;
407     HPT_U8  pci_bus;
408     HPT_U8  pci_device;
409     HPT_U8      pci_function;
410
411     HPT_U32 reserved;
412 } CONTROLLER_INFO_V2, *PCONTROLLER_INFO_V2;
413 #endif
414 /*
415  * Channel information.
416  */
417 typedef struct _CHANNEL_INFO {
418         HPT_U32                 IoPort;                 /* IDE Base Port Address */
419         HPT_U32                 ControlPort;    /* IDE Control Port Address */
420
421         DEVICEID        Devices[2];             /* device connected to this channel */
422
423 } CHANNEL_INFO, *PCHANNEL_INFO;
424
425 /*
426  * time represented in HPT_U32 format
427  */
428 #ifndef __KERNEL__
429 typedef struct _TIME_RECORD {
430    HPT_U32        seconds:6;      /* 0 - 59 */
431    HPT_U32        minutes:6;      /* 0 - 59 */
432    HPT_U32        month:4;        /* 1 - 12 */
433    HPT_U32        hours:6;        /* 0 - 59 */
434    HPT_U32        day:5;          /* 1 - 31 */
435    HPT_U32        year:5;         /* 0=2000, 31=2031 */
436 } TIME_RECORD;
437 #endif
438
439 /*
440  * Array information.
441  */
442 typedef struct _HPT_ARRAY_INFO {
443         HPT_U8          Name[MAX_ARRAYNAME_LEN];/* array name */
444         HPT_U8          Description[64];                /* array description */
445         HPT_U8          CreateManager[16];              /* who created it */
446         TIME_RECORD CreateTime;                         /* when created it */
447
448         HPT_U8          ArrayType;                              /* array type */
449         HPT_U8          BlockSizeShift;                 /* stripe size */
450         HPT_U8          nDisk;                                  /* member count: Number of ID in Members[] */
451         HPT_U8          reserved;
452
453         HPT_U32                 Flags;                                  /* working flags, see ARRAY_FLAG_XXX */
454         HPT_U32         Members[MAX_ARRAY_MEMBERS_V1];  /* member array/disks */
455
456         /*
457          * rebuilding progress, xx.xx% = sprintf(s, "%.2f%%", RebuildingProgress/100.0);
458          * only valid if rebuilding is done by driver code.
459          * Member Flags will have ARRAY_FLAG_REBUILDING set at this case.
460          * Verify operation use same fields below, the only difference is
461          * ARRAY_FLAG_VERIFYING is set.
462          */
463         HPT_U32         RebuildingProgress;
464         HPT_U32       RebuiltSectors; /* rebuilding point (LBA) for single member */
465
466 } HPT_ARRAY_INFO, *PHPT_ARRAY_INFO;  /*LDX modify ARRAY_INFO TO HPT_ARRAY_INFO to avoid compiling error in Windows*/
467
468 #if HPT_INTERFACE_VERSION>=0x01010000
469 typedef struct _HPT_ARRAY_INFO_V2 {
470         HPT_U8          Name[MAX_ARRAYNAME_LEN];/* array name */
471         HPT_U8          Description[64];                /* array description */
472         HPT_U8          CreateManager[16];              /* who created it */
473         TIME_RECORD CreateTime;                         /* when created it */
474
475         HPT_U8          ArrayType;                              /* array type */
476         HPT_U8          BlockSizeShift;                 /* stripe size */
477         HPT_U8          nDisk;                                  /* member count: Number of ID in Members[] */
478         HPT_U8          reserved;
479
480         HPT_U32         Flags;                                  /* working flags, see ARRAY_FLAG_XXX */
481         HPT_U32         Members[MAX_ARRAY_MEMBERS_V2];  /* member array/disks */
482
483         HPT_U32         RebuildingProgress;
484         HPT_U64     RebuiltSectors; /* rebuilding point (LBA) for single member */
485
486         HPT_U32         reserve4[4];
487 } HPT_ARRAY_INFO_V2, *PHPT_ARRAY_INFO_V2;
488 #endif
489
490 #if HPT_INTERFACE_VERSION>=0x01020000
491 typedef struct _HPT_ARRAY_INFO_V3 {
492         HPT_U8          Name[MAX_ARRAYNAME_LEN];/* array name */
493         HPT_U8          Description[64];                /* array description */
494         HPT_U8          CreateManager[16];              /* who created it */
495         TIME_RECORD CreateTime;                         /* when created it */
496
497         HPT_U8          ArrayType;                              /* array type */
498         HPT_U8          BlockSizeShift;                 /* stripe size */
499         HPT_U8          nDisk;                                  /* member count: Number of ID in Members[] */
500         HPT_U8          reserved;
501
502         HPT_U32         Flags;                                  /* working flags, see ARRAY_FLAG_XXX */
503         HPT_U32         Members[MAX_ARRAY_MEMBERS_V2];  /* member array/disks */
504
505         HPT_U32         RebuildingProgress;
506         HPT_U64     RebuiltSectors; /* rebuilding point (LBA) for single member */
507
508         DEVICEID        TransformSource;
509         DEVICEID    TransformTarget;   /* destination device ID */
510         HPT_U32         TransformingProgress;
511         HPT_U32         Signature;                      /* persistent identification*/
512 #if MAX_ARRAY_MEMBERS_V2==16
513         HPT_U16         Critical_Members;       /*bit mask of critical members*/
514         HPT_U16         reserve2;
515         HPT_U32         reserve;
516 #else 
517         HPT_U32     Critical_Members;
518         HPT_U32     reserve;
519 #endif
520 } HPT_ARRAY_INFO_V3, *PHPT_ARRAY_INFO_V3;
521 #endif
522 /*
523  * ATA/ATAPI Device identify data without the Reserved4.
524  */
525 #ifndef __KERNEL__
526 typedef struct _IDENTIFY_DATA2 {
527     HPT_U16 GeneralConfiguration;
528     HPT_U16 NumberOfCylinders;
529     HPT_U16 Reserved1;
530     HPT_U16 NumberOfHeads;
531     HPT_U16 UnformattedBytesPerTrack;
532     HPT_U16 UnformattedBytesPerSector;
533     HPT_U16 SectorsPerTrack;
534     HPT_U16 VendorUnique1[3];
535     HPT_U16 SerialNumber[10];
536     HPT_U16 BufferType;
537     HPT_U16 BufferSectorSize;
538     HPT_U16 NumberOfEccBytes;
539     HPT_U16 FirmwareRevision[4];
540     HPT_U16 ModelNumber[20];
541     HPT_U8  MaximumBlockTransfer;
542     HPT_U8  VendorUnique2;
543     HPT_U16 DoubleWordIo;
544     HPT_U16 Capabilities;
545     HPT_U16 Reserved2;
546     HPT_U8  VendorUnique3;
547     HPT_U8  PioCycleTimingMode;
548     HPT_U8  VendorUnique4;
549     HPT_U8  DmaCycleTimingMode;
550     HPT_U16 TranslationFieldsValid;
551     HPT_U16 NumberOfCurrentCylinders;
552     HPT_U16 NumberOfCurrentHeads;
553     HPT_U16 CurrentSectorsPerTrack;
554     HPT_U32 CurrentSectorCapacity;
555     HPT_U16 CurrentMultiSectorSetting;
556     HPT_U32 UserAddressableSectors;
557     HPT_U8  SingleWordDMASupport;
558     HPT_U8  SingleWordDMAActive;
559     HPT_U8  MultiWordDMASupport;
560     HPT_U8  MultiWordDMAActive;
561     HPT_U8  AdvancedPIOModes;
562     HPT_U8  Reserved4;
563     HPT_U16 MinimumMWXferCycleTime;
564     HPT_U16 RecommendedMWXferCycleTime;
565     HPT_U16 MinimumPIOCycleTime;
566     HPT_U16 MinimumPIOCycleTimeIORDY;
567     HPT_U16 Reserved5[2];
568     HPT_U16 ReleaseTimeOverlapped;
569     HPT_U16 ReleaseTimeServiceCommand;
570     HPT_U16 MajorRevision;
571     HPT_U16 MinorRevision;
572 } IDENTIFY_DATA2, *PIDENTIFY_DATA2;
573 #endif
574
575 /*
576  * physical device information.
577  * IdentifyData.ModelNumber[] is HPT_U8-swapped from the original identify data.
578  */
579 typedef struct _DEVICE_INFO {
580         HPT_U8   ControllerId;                  /* controller id */
581         HPT_U8   PathId;                                        /* bus */
582         HPT_U8   TargetId;                              /* id */
583     HPT_U8   DeviceModeSetting;         /* Current Data Transfer mode: 0-4 PIO 0-4 */
584                                         /* 5-7 MW DMA0-2, 8-13 UDMA0-5             */
585         HPT_U8   DeviceType;                            /* device type */
586         HPT_U8   UsableMode;             /* highest usable mode */
587
588 #ifdef __BIG_ENDIAN_BITFIELD
589         HPT_U8   NCQEnabled: 1;
590         HPT_U8   NCQSupported: 1;
591         HPT_U8   TCQEnabled: 1;
592         HPT_U8   TCQSupported: 1;
593         HPT_U8   WriteCacheEnabled: 1;
594         HPT_U8   WriteCacheSupported: 1;
595         HPT_U8   ReadAheadEnabled: 1;
596         HPT_U8   ReadAheadSupported: 1;
597         HPT_U8   reserved6: 6;
598         HPT_U8   SpinUpMode: 2;
599 #else 
600         HPT_U8   ReadAheadSupported: 1;
601         HPT_U8   ReadAheadEnabled: 1;
602         HPT_U8   WriteCacheSupported: 1;
603         HPT_U8   WriteCacheEnabled: 1;
604         HPT_U8   TCQSupported: 1;
605         HPT_U8   TCQEnabled: 1;
606         HPT_U8   NCQSupported: 1;
607         HPT_U8   NCQEnabled: 1;
608         HPT_U8   SpinUpMode: 2;
609         HPT_U8   reserved6: 6;
610 #endif
611
612         HPT_U32         Flags;                                  /* working flags, see DEVICE_FLAG_XXX */
613
614     IDENTIFY_DATA2 IdentifyData;        /* Identify Data of this device */
615
616 }
617 __attribute__((packed)) DEVICE_INFO, *PDEVICE_INFO;
618
619 #if HPT_INTERFACE_VERSION>=0x01020000
620 #define MAX_PARENTS_PER_DISK    8
621 /*
622  * physical device information.
623  * IdentifyData.ModelNumber[] is HPT_U8-swapped from the original identify data.
624  */
625 typedef struct _DEVICE_INFO_V2 {
626         HPT_U8   ControllerId;                  /* controller id */
627         HPT_U8   PathId;                                        /* bus */
628         HPT_U8   TargetId;                              /* id */
629     HPT_U8   DeviceModeSetting;         /* Current Data Transfer mode: 0-4 PIO 0-4 */
630                                         /* 5-7 MW DMA0-2, 8-13 UDMA0-5             */
631         HPT_U8   DeviceType;                            /* device type */
632         HPT_U8   UsableMode;             /* highest usable mode */
633
634 #ifdef __BIG_ENDIAN_BITFIELD
635         HPT_U8   NCQEnabled: 1;
636         HPT_U8   NCQSupported: 1;
637         HPT_U8   TCQEnabled: 1;
638         HPT_U8   TCQSupported: 1;
639         HPT_U8   WriteCacheEnabled: 1;
640         HPT_U8   WriteCacheSupported: 1;
641         HPT_U8   ReadAheadEnabled: 1;
642         HPT_U8   ReadAheadSupported: 1;
643         HPT_U8   reserved6: 6;
644         HPT_U8   SpinUpMode: 2;
645 #else 
646         HPT_U8   ReadAheadSupported: 1;
647         HPT_U8   ReadAheadEnabled: 1;
648         HPT_U8   WriteCacheSupported: 1;
649         HPT_U8   WriteCacheEnabled: 1;
650         HPT_U8   TCQSupported: 1;
651         HPT_U8   TCQEnabled: 1;
652         HPT_U8   NCQSupported: 1;
653         HPT_U8   NCQEnabled: 1;
654         HPT_U8   SpinUpMode: 2;
655         HPT_U8   reserved6: 6;
656 #endif
657
658         HPT_U32         Flags;                                  /* working flags, see DEVICE_FLAG_XXX */
659
660     IDENTIFY_DATA2 IdentifyData;        /* Identify Data of this device */
661
662     HPT_U64 TotalFree;
663     HPT_U64 MaxFree;
664     HPT_U64 BadSectors;
665     DEVICEID ParentArrays[MAX_PARENTS_PER_DISK];
666
667
668 __attribute__((packed)) DEVICE_INFO_V2, *PDEVICE_INFO_V2;
669
670 /*
671  * HPT601 information
672  */
673 #endif
674 /*
675  * HPT601 information
676  */
677 #define HPT601_INFO_DEVICEID      1
678 #define HPT601_INFO_TEMPERATURE   2
679 #define HPT601_INFO_FANSTATUS     4
680 #define HPT601_INFO_BEEPERCONTROL 8
681 #define HPT601_INFO_LED1CONTROL   0x10
682 #define HPT601_INFO_LED2CONTROL   0x20
683 #define HPT601_INFO_POWERSTATUS   0x40
684
685 typedef struct _HPT601_INFO_ {
686         HPT_U16 ValidFields;       /* mark valid fields below */
687         HPT_U16 DeviceId;                       /* 0x5A3E */
688         HPT_U16 Temperature;       /* Read: temperature sensor value. Write: temperature limit */
689         HPT_U16 FanStatus;         /* Fan status */
690         HPT_U16 BeeperControl;          /* bit4: beeper control bit. bit0-3: frequency bits */
691         HPT_U16 LED1Control;            /* bit4: twinkling control bit. bit0-3: frequency bits */
692         HPT_U16 LED2Control;            /* bit4: twinkling control bit. bit0-3: frequency bits */
693         HPT_U16 PowerStatus;            /* 1: has power 2: no power */
694 } HPT601_INFO, *PHPT601_INFO;
695
696 #if HPT_INTERFACE_VERSION>=0x01010000
697 #ifndef __KERNEL__
698 /* cache policy for each vdev, copied from ldm.h */
699 #define CACHE_POLICY_NONE 0
700 #define CACHE_POLICY_WRITE_THROUGH 1
701 #define CACHE_POLICY_WRITE_BACK 2
702
703 #endif
704 #endif
705 /*
706  * Logical device information.
707  * Union of ArrayInfo and DeviceInfo.
708  * Common properties will be put in logical device information.
709  */
710 typedef struct _LOGICAL_DEVICE_INFO {
711         HPT_U8          Type;                                   /* LDT_ARRAY or LDT_DEVICE */
712         HPT_U8          reserved[3];
713
714         HPT_U32         Capacity;                               /* array capacity */
715         DEVICEID        ParentArray;
716
717         union {
718                 HPT_ARRAY_INFO array;
719                 DEVICE_INFO device;
720         } __attribute__((packed)) u;
721
722 } __attribute__((packed)) LOGICAL_DEVICE_INFO, *PLOGICAL_DEVICE_INFO;
723
724 #if HPT_INTERFACE_VERSION>=0x01010000
725 typedef struct _LOGICAL_DEVICE_INFO_V2 {
726         HPT_U8          Type;                                   /* LDT_ARRAY or LDT_DEVICE */
727         HPT_U8          reserved[3];
728
729         HPT_U64         Capacity;                               /* array capacity */
730         DEVICEID        ParentArray;                    /*for physical device, Please don't use this field.
731                                                                                  * use ParentArrays field in DEVICE_INFO_V2
732                                                                                  */
733
734         union {
735                 HPT_ARRAY_INFO_V2 array;
736                 DEVICE_INFO device;
737         } __attribute__((packed)) u;
738
739 } __attribute__((packed)) LOGICAL_DEVICE_INFO_V2, *PLOGICAL_DEVICE_INFO_V2;
740 #endif
741
742 #if HPT_INTERFACE_VERSION>=0x01020000
743 #define INVALID_TARGET_ID       0xFF
744 #define INVALID_BUS_ID          0xFF
745 typedef struct _LOGICAL_DEVICE_INFO_V3 {
746         HPT_U8          Type;                                   /* LDT_ARRAY or LDT_DEVICE */
747         HPT_U8          CachePolicy;                    /* refer to CACHE_POLICY_xxx */
748         HPT_U8          VBusId;                                 /* vbus sequence in vbus_list*/
749         HPT_U8          TargetId;                               /* 0xFF is invalid target/bus id. otherwise, GUI should show
750                                                                                  * to user:
751                                                                                  *              os name: HPT DISK x_y
752                                                                                  *       where x is vbus_id and y is target_id.
753                                                                                  */
754
755         HPT_U64         Capacity;                               /* array capacity */
756         DEVICEID        ParentArray;                    /*for physical device, Please don't use this field.
757                                                                                  * use ParentArrays field in DEVICE_INFO_V2
758                                                                                  */
759         HPT_U32         TotalIOs;
760         HPT_U32         TobalMBs;
761         HPT_U32         IOPerSec;
762         HPT_U32         MBPerSec;
763
764         union {
765                 HPT_ARRAY_INFO_V3 array;
766                 DEVICE_INFO_V2 device;
767         } __attribute__((packed)) u;
768
769 }
770 __attribute__((packed)) LOGICAL_DEVICE_INFO_V3, *PLOGICAL_DEVICE_INFO_V3;
771 #endif
772
773
774 /*
775  * ALTERABLE_ARRAY_INFO and ALTERABLE_DEVICE_INFO, used in set_array_info()
776  * and set_device_info().
777  * When set_xxx_info() is called, the ValidFields member indicates which
778  * fields in the structure are valid.
779  */
780 /* field masks */
781 #define AAIF_NAME           1
782 #define AAIF_DESCRIPTION    2
783
784 #define ADIF_MODE           1
785 #define ADIF_TCQ            2
786 #define ADIF_NCQ            4
787 #define ADIF_WRITE_CACHE    8
788 #define ADIF_READ_AHEAD     0x10
789 #define ADIF_SPIN_UP_MODE   0x20
790
791 typedef struct _ALTERABLE_ARRAY_INFO {
792         HPT_U32   ValidFields;                          /* mark valid fields below */
793         HPT_U8  Name[MAX_ARRAYNAME_LEN];        /* array name */
794         HPT_U8  Description[64];                        /* array description */
795 }
796 ALTERABLE_ARRAY_INFO, *PALTERABLE_ARRAY_INFO;
797
798 typedef struct _ALTERABLE_DEVICE_INFO {
799         HPT_U32   ValidFields;                          /* mark valid fields below */
800     HPT_U8   DeviceModeSetting;                 /* 0-4 PIO 0-4, 5-7 MW DMA0-2, 8-13 UDMA0-5 */
801 }
802 ALTERABLE_DEVICE_INFO, *PALTERABLE_DEVICE_INFO;
803
804 typedef struct _ALTERABLE_DEVICE_INFO_V2 {
805         HPT_U32   ValidFields;                /* mark valid fields below */
806         HPT_U8   DeviceModeSetting;          /* 0-4 PIO 0-4, 5-7 MW DMA0-2, 8-13 UDMA0-5 */
807         HPT_U8   TCQEnabled;
808         HPT_U8   NCQEnabled;
809         HPT_U8   WriteCacheEnabled;
810         HPT_U8   ReadAheadEnabled;
811         HPT_U8   SpinUpMode;
812         HPT_U8   reserve[2];
813         HPT_U32  reserve2[13]; /* pad to 64 bytes */
814 }
815 ALTERABLE_DEVICE_INFO_V2, *PALTERABLE_DEVICE_INFO_V2;
816
817 #if HPT_INTERFACE_VERSION>=0x01020000
818 /* target type of set_info, this time, we use the type and length alterable param to implement
819  * set_dev_info function for future extension*/
820 #define TARGET_TYPE_DEVICE      0
821 #define TARGET_TYPE_ARRAY       1
822
823 /*which type of information of an array to be changed*/
824 #define AIT_NAME                        0
825 #define AIT_DESCRIPTION         1
826 #define AIT_CACHE_POLICY        2
827 /*which type of information of a device to be changed*/
828 #define DIT_MODE                0
829 #define DIT_READ_AHEAD  1
830 #define DIT_WRITE_CACHE 2
831 #define DIT_TCQ                 3
832 #define DIT_NCQ                 4
833
834 /*param type is determined by target_type and info_type*/
835 typedef struct _SET_DEV_INFO
836 {
837         HPT_U8 target_type;
838         HPT_U8 infor_type;
839         HPT_U16 param_length;
840         #define SET_VDEV_INFO_param(p) ((HPT_U8 *)(p)+sizeof(SET_VDEV_INFO))
841         /* HPT_U8 param[0]; */
842 } SET_VDEV_INFO, * PSET_VDEV_INFO;
843
844 typedef HPT_U8 PARAM_ARRAY_NAME[MAX_ARRAYNAME_LEN] ;
845 typedef HPT_U8 PARAM_ARRAY_DES[64];
846 typedef HPT_U8 PARAM_DEVICE_MODE, PARAM_TCQ, PARAM_NCQ, PARAM_READ_AHEAD, PARAM_WRITE_CACHE, PARAM_CACHE_POLICY;
847
848 #endif
849
850 /*
851  * CREATE_ARRAY_PARAMS
852  *  Param structure used to create an array.
853  */
854 typedef struct _CREATE_ARRAY_PARAMS {
855         HPT_U8 ArrayType;                                       /* 1-level array type */
856         HPT_U8 nDisk;                                           /* number of elements in Members[] array */
857         HPT_U8 BlockSizeShift;                          /* Stripe size if ArrayType==AT_RAID0 / AT_RAID5 */
858         HPT_U8 CreateFlags;                                     /* See CAF_xxx */
859
860         HPT_U8 ArrayName[MAX_ARRAYNAME_LEN]; /* Array name */
861         HPT_U8          Description[64];                /* array description */
862         HPT_U8          CreateManager[16];              /* who created it */
863         TIME_RECORD CreateTime;                         /* when created it */
864
865         HPT_U32 Members[MAX_ARRAY_MEMBERS_V1];/* ID of array members, a member can be an array */
866
867 } CREATE_ARRAY_PARAMS, *PCREATE_ARRAY_PARAMS;
868
869 #if HPT_INTERFACE_VERSION>=0x01010000
870 typedef struct _CREATE_ARRAY_PARAMS_V2 {
871         HPT_U8 ArrayType;                                       /* 1-level array type */
872         HPT_U8 nDisk;                                           /* number of elements in Members[] array */
873         HPT_U8 BlockSizeShift;                          /* Stripe size if ArrayType==AT_RAID0 / AT_RAID5 */
874         HPT_U8 CreateFlags;                                     /* See CAF_xxx */
875
876         HPT_U8 ArrayName[MAX_ARRAYNAME_LEN]; /* Array name */
877         HPT_U8 Description[64];         /* array description */
878         HPT_U8 CreateManager[16];               /* who created it */
879         TIME_RECORD CreateTime;                         /* when created it */
880         HPT_U64 Capacity;
881
882         HPT_U32 Members[MAX_ARRAY_MEMBERS_V2];/* ID of array members, a member can be an array */
883
884 } CREATE_ARRAY_PARAMS_V2, *PCREATE_ARRAY_PARAMS_V2;
885 #endif
886
887 #if HPT_INTERFACE_VERSION < 0x01020000
888 /*
889  * Flags used for creating an RAID 1 array
890  *
891  * CAF_CREATE_AND_DUPLICATE
892  *    Copy source disk contents to target for RAID 1. If user choose "create and duplicate"
893  *    to create an array, GUI will call CreateArray() with this flag set. Then GUI should
894  *    call hpt_get_device_info() with the returned array ID and check returned flags to
895  *    see if ARRAY_FLAG_REBUILDING is set. If not set, driver does not support rebuilding
896  *    and GUI must do duplication itself.
897  * CAF_DUPLICATE_MUST_DONE
898  *    If the duplication is aborted or fails, do not create the array.
899  */
900 #define CAF_CREATE_AND_DUPLICATE 1
901 #define CAF_DUPLICATE_MUST_DONE  2
902 #define CAF_CREATE_AS_RAID15     4
903 /*
904  * Flags used for creating an RAID 5 array
905  */
906 #define CAF_CREATE_R5_NO_BUILD     1
907 #define CAF_CREATE_R5_ZERO_INIT    2
908 #define CAF_CREATE_R5_BUILD_PARITY 4
909
910 #else 
911 /*
912  * Flags used for creating
913  */
914 #define CAF_FOREGROUND_INITIALIZE       1
915 #define CAF_BACKGROUND_INITIALIZE       2
916 #define CAF_CREATE_R5_WRITE_BACK        8
917
918 #endif
919
920 #define CAF_KEEP_DATA_ALWAYS     0x80
921
922 /* Flags used for deleting an array
923  *
924  * DAF_KEEP_DATA_IF_POSSIBLE
925  *    If this flag is set, deleting a RAID 1 array will not destroy the data on both disks.
926  *    Deleting a JBOD should keep partitions on first disk ( not implement now ).
927  *    Deleting a RAID 0/1 should result as two RAID 0 array ( not implement now ).
928  */
929 #define DAF_KEEP_DATA_IF_POSSIBLE 1
930 #define DAF_KEEP_DATA_ALWAYS      2
931
932 /*
933  * event types
934  */
935 #define ET_DEVICE_REMOVED       1       /* device removed */
936 #define ET_DEVICE_PLUGGED       2       /* device plugged */
937 #define ET_DEVICE_ERROR         3       /* device I/O error */
938 #define ET_REBUILD_STARTED  4
939 #define ET_REBUILD_ABORTED  5
940 #define ET_REBUILD_FINISHED 6
941 #define ET_SPARE_TOOK_OVER  7
942 #define ET_REBUILD_FAILED       8
943 #define ET_VERIFY_STARTED   9
944 #define ET_VERIFY_ABORTED   10
945 #define ET_VERIFY_FAILED    11
946 #define ET_VERIFY_FINISHED  12
947 #define ET_INITIALIZE_STARTED   13
948 #define ET_INITIALIZE_ABORTED   14
949 #define ET_INITIALIZE_FAILED    15
950 #define ET_INITIALIZE_FINISHED  16
951 #define ET_VERIFY_DATA_ERROR    17
952 #define ET_TRANSFORM_STARTED    18
953 #define ET_TRANSFORM_ABORTED    19
954 #define ET_TRANSFORM_FAILED             20
955 #define ET_TRANSFORM_FINISHED   21
956 #define ET_SMART_FAILED         22
957 #define ET_SMART_PASSED         23
958 /*
959  * event structure
960  */
961 typedef struct _HPT_EVENT {
962         TIME_RECORD Time;
963         DEVICEID    DeviceID;
964         HPT_U8       EventType;
965         HPT_U8          reserved[3];
966
967         HPT_U8          Data[32]; /* various data depend on EventType */
968 } HPT_EVENT, *PHPT_EVENT;
969
970 /*
971  * IDE pass-through command. Use it at your own risk!
972  */
973 #ifdef _MSC_VER
974 #pragma warning(disable:4200)
975 #endif
976 typedef struct _IDE_PASS_THROUGH_HEADER {
977         DEVICEID idDisk;           /* disk ID */
978         HPT_U8     bFeaturesReg;     /* feature register */
979         HPT_U8     bSectorCountReg;  /* IDE sector count register. */
980         HPT_U8     bLbaLowReg;       /* IDE LBA low value. */
981         HPT_U8     bLbaMidReg;       /* IDE LBA mid register. */
982         HPT_U8     bLbaHighReg;      /* IDE LBA high value. */
983         HPT_U8     bDriveHeadReg;    /* IDE drive/head register. */
984         HPT_U8     bCommandReg;      /* Actual IDE command. Checked for validity by driver. */
985         HPT_U8     nSectors;         /* data size in sectors, if the command has data transfer */
986         HPT_U8     protocol;         /* IO_COMMAND_(READ,WRITE) or zero for non-DATA */
987         HPT_U8     reserve[3];
988         #define IDE_PASS_THROUGH_buffer(p) ((HPT_U8 *)(p) + sizeof(IDE_PASS_THROUGH_HEADER))
989         /* HPT_U8     DataBuffer[0]; */
990 }
991 IDE_PASS_THROUGH_HEADER, *PIDE_PASS_THROUGH_HEADER;
992
993 /*
994  * device io packet format
995  */
996 typedef struct _DEVICE_IO_EX_PARAMS {
997         DEVICEID idDisk;
998         HPT_U32    Lba;
999         HPT_U16   nSectors;
1000         HPT_U8    Command; /* IO_COMMAD_xxx */
1001         HPT_U8    BufferType; /* BUFFER_TYPE_xxx, see below */
1002         HPT_U32    BufferPtr;
1003 }
1004 DEVICE_IO_EX_PARAMS, *PDEVICE_IO_EX_PARAMS;
1005
1006 #define BUFFER_TYPE_LOGICAL                      1 /* logical pointer to buffer */
1007 #define BUFFER_TYPE_PHYSICAL                     2 /* physical address of buffer */
1008 #define BUFFER_TYPE_LOGICAL_LOGICAL_SG   3 /* logical pointer to logical S/G table */
1009 #define BUFFER_TYPE_LOGICAL_PHYSICAL_SG  4 /* logical pointer to physical S/G table */
1010 #define BUFFER_TYPE_PHYSICAL_LOGICAL_SG  5 /* physical address to logical S/G table */
1011 #define BUFFER_TYPE_PHYSICAL_PHYSICAL_SG 6 /* physical address of physical S/G table */
1012 #define BUFFER_TYPE_PHYSICAL_PHYSICAL_SG_PIO 7 /* non DMA capable physical address of physical S/G table */
1013
1014 typedef struct _HPT_DRIVER_PARAMETER {
1015         char    name[32];
1016         HPT_U8  value[32];
1017         HPT_U8  type;        /* HPT_DRIVER_PARAMETER_TYPE_* */
1018         HPT_U8  reserve3[3];
1019         HPT_U8  location;    /* 0 - system */
1020         HPT_U8  controller;
1021         HPT_U8  bus;
1022         HPT_U8  reserve1;
1023         char    desc[128];
1024 }
1025 HPT_DRIVER_PARAMETER, *PHPT_DRIVER_PARAMETER;
1026
1027 #define HPT_DRIVER_PARAMETER_TYPE_INT 1
1028 #define HPT_DRIVER_PARAMETER_TYPE_BOOL 2
1029
1030
1031
1032 /*
1033  * ioctl structure
1034  */
1035 #define HPT_IOCTL_MAGIC32 0x1A2B3C4D
1036 #define HPT_IOCTL_MAGIC   0xA1B2C3D4
1037
1038 typedef struct _HPT_IOCTL_PARAM {
1039         HPT_U32   Magic;                                   /* used to check if it's a valid ioctl packet */
1040         HPT_U32   dwIoControlCode;       /* operation control code */
1041         HPT_PTR   lpInBuffer;            /* input data buffer */
1042         HPT_U32   nInBufferSize;         /* size of input data buffer */
1043         HPT_PTR   lpOutBuffer;           /* output data buffer */
1044         HPT_U32   nOutBufferSize;        /* size of output data buffer */
1045         HPT_PTR   lpBytesReturned;       /* count of HPT_U8s returned */
1046 }
1047 HPT_IOCTL_PARAM, *PHPT_IOCTL_PARAM;
1048
1049 /* for 32-bit app running on 64-bit system */
1050 typedef struct _HPT_IOCTL_PARAM32 {
1051         HPT_U32   Magic;
1052         HPT_U32   dwIoControlCode;
1053         HPT_U32   lpInBuffer;
1054         HPT_U32   nInBufferSize;
1055         HPT_U32   lpOutBuffer;
1056         HPT_U32   nOutBufferSize;
1057         HPT_U32   lpBytesReturned;
1058 }
1059 HPT_IOCTL_PARAM32, *PHPT_IOCTL_PARAM32;
1060
1061 /*
1062  * User-mode ioctl parameter passing conventions:
1063  *   The ioctl function implementation is platform specific, so we don't
1064  * have forced rules for it. However, it's suggested to use a parameter
1065  * passing method as below
1066  *   1) Put all input data continuously in an input buffer.
1067  *   2) Prepare an output buffer with enough size if needed.
1068  *   3) Fill a HPT_IOCTL_PARAM structure.
1069  *   4) Pass the structure to driver through a platform-specific method.
1070  * This is implemented in the mid-layer user-mode library. The UI
1071  * programmer needn't care about it.
1072  */
1073
1074 /************************************************************************
1075  * User mode functions
1076  ************************************************************************/
1077 #if !defined(__KERNEL__) || defined(SIMULATE)
1078 /*
1079  * hpt_get_version
1080  * Version compatibility: all versions
1081  * Parameters:
1082  *      None
1083  * Returns:
1084  *      interface version. 0 when fail.
1085  */
1086 HPT_U32 hpt_get_version(void);
1087
1088 /*
1089  * hpt_get_driver_capabilities
1090  * Version compatibility: v1.0.0.2 or later
1091  * Parameters:
1092  *      Pointer to receive a DRIVE_CAPABILITIES structure. The caller must set
1093  *  dwSize member to sizeof(DRIVER_CAPABILITIES). The callee must check this
1094  *  member to see if it's correct.
1095  * Returns:
1096  *      0 - Success
1097  */
1098 int hpt_get_driver_capabilities(PDRIVER_CAPABILITIES cap);
1099
1100 /*
1101  * hpt_get_controller_count
1102  * Version compatibility: v1.0.0.1 or later
1103  * Parameters:
1104  *      None
1105  * Returns:
1106  *      number of controllers
1107  */
1108 int hpt_get_controller_count(void);
1109
1110 /* hpt_get_controller_info
1111  * Version compatibility: v1.0.0.1 or later
1112  * Parameters:
1113  *      id              Controller id
1114  *      pInfo   pointer to CONTROLLER_INFO buffer
1115  * Returns:
1116  *      0               Success, controller info is put into (*pInfo ).
1117  */
1118 int hpt_get_controller_info(int id, PCONTROLLER_INFO pInfo);
1119
1120 #if HPT_INTERFACE_VERSION>=0x01020000
1121 /* hpt_get_controller_info_v2
1122  * Version compatibility: v2.0.0.0 or later
1123  * Parameters:
1124  *      id              Controller id
1125  *      pInfo   pointer to CONTROLLER_INFO_V2 buffer
1126  * Returns:
1127  *      0               Success, controller info is put into (*pInfo ).
1128  */
1129 int hpt_get_controller_info_v2(int id, PCONTROLLER_INFO_V2 pInfo);
1130 #endif
1131
1132 /* hpt_get_channel_info
1133  * Version compatibility: v1.0.0.1 or later
1134  * Parameters:
1135  *      id              Controller id
1136  *  bus         bus number
1137  *      pInfo   pointer to CHANNEL_INFO buffer
1138  * Returns:
1139  *      0               Success, channel info is put into (*pInfo ).
1140  */
1141 int hpt_get_channel_info(int id, int bus, PCHANNEL_INFO pInfo);
1142
1143 /* hpt_get_logical_devices
1144  * Version compatibility: v1.0.0.1 or later
1145  * Parameters:
1146  *      pIds            pointer to a DEVICEID array
1147  *      nMaxCount       array size
1148  * Returns:
1149  *      Number of ID returned. All logical device IDs are put into pIds array.
1150  *  Note: A spare disk is not a logical device.
1151  */
1152 int hpt_get_logical_devices(DEVICEID * pIds, int nMaxCount);
1153
1154 /* hpt_get_device_info
1155  * Version compatibility: v1.0.0.1 or later
1156  * Parameters:
1157  *      id              logical device id
1158  *      pInfo   pointer to LOGICAL_DEVICE_INFO structure
1159  * Returns:
1160  *      0 - Success
1161  */
1162 int hpt_get_device_info(DEVICEID id, PLOGICAL_DEVICE_INFO pInfo);
1163
1164 /* hpt_create_array
1165  * Version compatibility: v1.0.0.1 or later
1166  * Parameters:
1167  *      pParam          pointer to CREATE_ARRAY_PARAMS structure
1168  * Returns:
1169  *      0       failed
1170  *      else return array id
1171  */
1172 DEVICEID hpt_create_array(PCREATE_ARRAY_PARAMS pParam);
1173
1174 /* hpt_delete_array
1175  * Version compatibility: v1.0.0.1 or later
1176  * Parameters:
1177  *      id              array id
1178  * Returns:
1179  *      0       Success
1180  */
1181 int hpt_delete_array(DEVICEID id, HPT_U32 options);
1182
1183 /* hpt_device_io
1184  *  Read/write data on array and physcal device.
1185  * Version compatibility: v1.0.0.1 or later
1186  * Parameters:
1187  *      id              device id. If it's an array ID, IO will be performed on the array.
1188  *          If it's a physical device ID, IO will be performed on the device.
1189  *      cmd             IO_COMMAND_READ or IO_COMMAND_WRITE
1190  *      buffer  data buffer
1191  *      length  data size
1192  * Returns:
1193  *      0       Success
1194  */
1195 int hpt_device_io(DEVICEID id, int cmd, HPT_U32 lba, HPT_U32 nSector, void * buffer);
1196
1197 /* hpt_add_disk_to_array
1198  *   Used to dynamicly add a disk to an RAID1, RAID0/1, RAID1/0 or RAID5 array.
1199  *   Auto-rebuild will start.
1200  * Version compatibility: v1.0.0.1 or later
1201  * Parameters:
1202  *      idArray         array id
1203  *      idDisk          disk id
1204  * Returns:
1205  *      0       Success
1206  */
1207 int hpt_add_disk_to_array(DEVICEID idArray, DEVICEID idDisk);
1208
1209 /* hpt_add_spare_disk
1210  * Version compatibility: v1.0.0.1 or later
1211  *   Add a disk to spare pool.
1212  * Parameters:
1213  *      idDisk          disk id
1214  * Returns:
1215  *      0       Success
1216  */
1217 int hpt_add_spare_disk(DEVICEID idDisk);
1218
1219 /* hpt_add_dedicated_spare
1220  * Version compatibility: v1.0.0.3 or later
1221  *   Add a spare disk to an array
1222  * Parameters:
1223  *      idDisk          disk id
1224  *  idArray     array id
1225  * Returns:
1226  *      0       Success
1227  */
1228 int hpt_add_dedicated_spare(DEVICEID idDisk, DEVICEID idArray);
1229
1230 /* hpt_remove_spare_disk
1231  *   remove a disk from spare pool.
1232  * Version compatibility: v1.0.0.1 or later
1233  * Parameters:
1234  *      idDisk          disk id
1235  * Returns:
1236  *      0       Success
1237  */
1238 int hpt_remove_spare_disk(DEVICEID idDisk);
1239
1240 /* hpt_get_event
1241  *   Used to poll events from driver.
1242  * Version compatibility: v1.0.0.1 or later
1243  * Parameters:
1244  *   pEvent    pointer to HPT_EVENT structure
1245  * Returns:
1246  *      0       Success, event info is filled in *pEvent
1247  */
1248 int hpt_get_event(PHPT_EVENT pEvent);
1249
1250 /* hpt_rebuild_data_block
1251  *   Used to copy data from source disk and mirror disk.
1252  * Version compatibility: v1.0.0.1 or later
1253  * Parameters:
1254  *   idArray            Array ID (RAID1, 0/1 or RAID5)
1255  *   Lba                        Start LBA for each array member
1256  *       nSector                Number of sectors for each array member (RAID 5 will ignore this parameter)
1257  *
1258  * Returns:
1259  *      0       Success, event info is filled in *pEvent
1260  */
1261 int hpt_rebuild_data_block(DEVICEID idMirror, HPT_U32 Lba, HPT_U8 nSector);
1262 #define hpt_rebuild_mirror(p1, p2, p3) hpt_rebuild_data_block(p1, p2, p3)
1263
1264 /* hpt_set_array_state
1265  *   set array state.
1266  * Version compatibility: v1.0.0.1 or later
1267  * Parameters:
1268  *   idArray            Array ID
1269  *   state                      See above 'array states' constants, possible values are:
1270  *     MIRROR_REBUILD_START
1271  *        Indicate that GUI wants to rebuild a mirror array
1272  *     MIRROR_REBUILD_ABORT
1273  *        GUI wants to abort rebuilding an array
1274  *     MIRROR_REBUILD_COMPLETE
1275  *        GUI finished to rebuild an array. If rebuild is done by driver this
1276  *        state has no use
1277  *
1278  * Returns:
1279  *      0       Success
1280  */
1281 int hpt_set_array_state(DEVICEID idArray, HPT_U32 state);
1282
1283 /* hpt_set_array_info
1284  *   set array info.
1285  * Version compatibility: v1.0.0.1 or later
1286  * Parameters:
1287  *   idArray            Array ID
1288  *   pInfo                      pointer to new info
1289  *
1290  * Returns:
1291  *      0       Success
1292  */
1293 int hpt_set_array_info(DEVICEID idArray, PALTERABLE_ARRAY_INFO pInfo);
1294
1295 /* hpt_set_device_info
1296  *   set device info.
1297  * Version compatibility: v1.0.0.1 or later
1298  * Parameters:
1299  *   idDisk                     device ID
1300  *   pInfo                      pointer to new info
1301  *
1302  * Returns:
1303  *      0       Success
1304  * Additional notes:
1305  *  If idDisk==0, call to this function will stop buzzer on the adapter
1306  *  (if supported by driver).
1307  */
1308 int hpt_set_device_info(DEVICEID idDisk, PALTERABLE_DEVICE_INFO pInfo);
1309
1310 #if HPT_INTERFACE_VERSION >= 0x01000004
1311 int hpt_set_device_info_v2(DEVICEID idDisk, PALTERABLE_DEVICE_INFO_V2 pInfo);
1312 #endif
1313
1314 /* hpt_rescan_devices
1315  *   rescan devices
1316  * Version compatibility: v1.0.0.1 or later
1317  * Parameters:
1318  *       None
1319  * Returns:
1320  *       0      Success
1321  */
1322 int hpt_rescan_devices(void);
1323
1324 /* hpt_get_601_info
1325  *   Get HPT601 status
1326  * Version compatibiilty: v1.0.0.3 or later
1327  * Parameters:
1328  *   idDisk - Disk handle
1329  *   PHPT601_INFO - pointer to HPT601 info buffer
1330  * Returns:
1331  *   0  Success
1332  */
1333 int hpt_get_601_info(DEVICEID idDisk, PHPT601_INFO pInfo);
1334
1335 /* hpt_set_601_info
1336  *   HPT601 function control
1337  * Version compatibiilty: v1.0.0.3 or later
1338  * Parameters:
1339  *   idDisk - Disk handle
1340  *   PHPT601_INFO - pointer to HPT601 info buffer
1341  * Returns:
1342  *   0  Success
1343  */
1344 int hpt_set_601_info(DEVICEID idDisk, PHPT601_INFO pInfo);
1345
1346 /* hpt_lock_device
1347  *   Lock a block on a device (prevent OS accessing it)
1348  * Version compatibiilty: v1.0.0.3 or later
1349  * Parameters:
1350  *   idDisk - Disk handle
1351  *   Lba - Start LBA
1352  *   nSectors - number of sectors
1353  * Returns:
1354  *   0  Success
1355  */
1356 int hpt_lock_device(DEVICEID idDisk, HPT_U32 Lba, HPT_U8 nSectors);
1357
1358 /* hpt_lock_device
1359  *   Unlock a device
1360  * Version compatibiilty: v1.0.0.3 or later
1361  * Parameters:
1362  *   idDisk - Disk handle
1363  * Returns:
1364  *   0  Success
1365  */
1366 int hpt_unlock_device(DEVICEID idDisk);
1367
1368 /* hpt_ide_pass_through
1369  *  directly access controller's command and control registers.
1370  *  Can only call it on physical devices.
1371  * Version compatibility: v1.0.0.3 or later
1372  * Parameters:
1373  *   p - IDE_PASS_THROUGH header pointer
1374  * Returns:
1375  *   0  Success
1376  */
1377 int hpt_ide_pass_through(PIDE_PASS_THROUGH_HEADER p);
1378
1379 /* hpt_verify_data_block
1380  *   verify data block on RAID1 or RAID5.
1381  * Version compatibility: v1.0.0.3 or later
1382  * Parameters:
1383  *   idArray - Array ID
1384  *   Lba - block number (on each array member, not logical block!)
1385  *   nSectors - Sectors for each member (RAID 5 will ignore this parameter)
1386  * Returns:
1387  *   0  Success
1388  *   1  Data compare error
1389  *   2  I/O error
1390  */
1391 int hpt_verify_data_block(DEVICEID idArray, HPT_U32 Lba, HPT_U8 nSectors);
1392
1393 /* hpt_initialize_data_block
1394  *   initialize data block (fill with zero) on RAID5
1395  * Version compatibility: v1.0.0.3 or later
1396  * Parameters:
1397  *   idArray - Array ID
1398  *   Lba - block number (on each array member, not logical block!)
1399  *   nSectors - Sectors for each member (RAID 5 will ignore this parameter)
1400  * Returns:
1401  *   0  Success
1402  */
1403 int hpt_initialize_data_block(DEVICEID idArray, HPT_U32 Lba, HPT_U8 nSectors);
1404
1405 /* hpt_device_io_ex
1406  *   extended device I/O function
1407  * Version compatibility: v1.0.0.3 or later
1408  * Parameters:
1409  *   idArray - Array ID
1410  *   Lba - block number (on each array member, not logical block!)
1411  *   nSectors - Sectors for each member
1412  *   buffer - I/O buffer or s/g address
1413  * Returns:
1414  *   0  Success
1415  */
1416 int hpt_device_io_ex(PDEVICE_IO_EX_PARAMS param);
1417
1418 /* hpt_set_boot_mark
1419  *   select boot device
1420  * Version compatibility: v1.0.0.3 or later
1421  * Parameters:
1422  *   id - logical device ID. If id is 0 the boot mark will be removed.
1423  * Returns:
1424  *   0  Success
1425  */
1426 int hpt_set_boot_mark(DEVICEID id);
1427
1428 /* hpt_query_remove
1429  *  check if device can be removed safely
1430  * Version compatibility: v1.0.0.4 or later
1431  * Parameters:
1432  *  ndev - number of devices
1433  *  pIds - device ID list
1434  * Returns:
1435  *  0  - Success
1436  *  -1 - unknown error
1437  *  n  - the n-th device that can't be removed
1438  */
1439 int hpt_query_remove(HPT_U32 ndev, DEVICEID *pIds);
1440
1441 /* hpt_remove_devices
1442  *  remove a list of devices
1443  * Version compatibility: v1.0.0.4 or later
1444  * Parameters:
1445  *  ndev - number of devices
1446  *  pIds - device ID list
1447  * Returns:
1448  *  0  - Success
1449  *  -1 - unknown error
1450  *  n  - the n-th device that can't be removed
1451  */
1452 int hpt_remove_devices(HPT_U32 ndev, DEVICEID *pIds);
1453
1454 /* hpt_create_array_v2
1455  * Version compatibility: v1.1.0.0 or later
1456  * Parameters:
1457  *      pParam          pointer to CREATE_ARRAY_PARAMS_V2 structure
1458  * Returns:
1459  *      0       failed
1460  *      else return array id
1461  */
1462 #if HPT_INTERFACE_VERSION>=0x01010000
1463 DEVICEID hpt_create_array_v2(PCREATE_ARRAY_PARAMS_V2 pParam);
1464 #endif
1465
1466 /* hpt_get_device_info_v2
1467  * Version compatibility: v1.1.0.0 or later
1468  * Parameters:
1469  *      id              logical device id
1470  *      pInfo   pointer to LOGICAL_DEVICE_INFO_V2 structure
1471  * Returns:
1472  *      0 - Success
1473  */
1474 #if HPT_INTERFACE_VERSION>=0x01010000
1475 int hpt_get_device_info_v2(DEVICEID id, PLOGICAL_DEVICE_INFO_V2 pInfo);
1476 #endif
1477
1478 /* hpt_get_device_info_v3
1479  * Version compatibility: v1.2.0.0 or later
1480  * Parameters:
1481  *      id              logical device id
1482  *      pInfo   pointer to LOGICAL_DEVICE_INFO_V2 structure
1483  * Returns:
1484  *      0 - Success
1485  */
1486 #if HPT_INTERFACE_VERSION>=0x01020000
1487 int hpt_get_device_info_v3(DEVICEID id, PLOGICAL_DEVICE_INFO_V3 pInfo);
1488 #endif
1489
1490 /* hpt_create_transform
1491  *  create a transform instance.
1492  * Version compatibility: v2.0.0.0 or later
1493  * Parameters:
1494  *  idArray - source array
1495  *  destInfo - destination array info
1496  * Returns:
1497  *  destination array id
1498  */
1499 #if HPT_INTERFACE_VERSION>=0x02000000
1500 DEVICEID hpt_create_transform(DEVICEID idArray, PCREATE_ARRAY_PARAMS_V2 destInfo);
1501 #endif
1502
1503 /* hpt_step_transform
1504  *  move a block in a tranform progress.
1505  *  This function is called by mid-layer, not GUI (which uses set_array_state instead).
1506  * Version compatibility: v2.0.0.0 or later
1507  * Parameters:
1508  *  idArray - destination array ID
1509  *            the source ID will be invalid when transform complete.
1510  * Returns:
1511  *  0 - Success
1512  */
1513 #if HPT_INTERFACE_VERSION>=0x02000000
1514 int hpt_step_transform(DEVICEID idArray);
1515 #endif
1516
1517 /* hpt_set_vdev_info
1518  *  set information for disk or array
1519  * Version compatibility: v1.2.0.0 or later
1520  * Parameters:
1521  *  dev - destination device
1522  *
1523  * Returns:
1524  *  0 - Success
1525  */
1526 #if HPT_INTERFACE_VERSION>=0x01020000
1527 int hpt_set_vdev_info(DEVICEID dev, PSET_VDEV_INFO pInfo);
1528 #endif
1529
1530 /* hpt_init_disks
1531  *  initialize disks for use
1532  * Version compatibility: v2.0.0.0 or later
1533  * Parameters:
1534  *  ndev - number of disks to initialize
1535  *      pIds - array of DEVICEID
1536  *
1537  * Returns:
1538  *  0 - Success
1539  */
1540 #if HPT_INTERFACE_VERSION>=0x02000000
1541 int hpt_init_disks(HPT_U32 ndev, DEVICEID * pIds);
1542 #endif
1543
1544 /* hpt_calc_max_array_capacity
1545  *  cap max capacity of the array user want to create or transform
1546  * Version compatibility: v1.2.0.0 or later
1547  * Parameters:
1548  *  source - if transform, this is the source array, otherwise, it should be zero
1549  *      destInfo - target array params
1550  * Returns:
1551  *  0 - Success
1552  *      cap - max capacity of the target array
1553  */
1554 #if HPT_INTERFACE_VERSION>=0x01020000
1555 int hpt_calc_max_array_capacity(DEVICEID source, PCREATE_ARRAY_PARAMS_V2 destInfo, HPT_U64 * cap);
1556 #endif
1557
1558 /* hpt_rebuild_data_block2
1559  *   Used to copy data from source disk and mirror disk.
1560  * Version compatibility: v1.1.0.0 or later
1561  * Parameters:
1562  *   idArray            Array ID (RAID1, 0/1 or RAID5)
1563  *   Lba                        Start LBA for each array member
1564  *       nSector                Number of sectors for each array member (RAID 5 will ignore this parameter)
1565  *
1566  * Returns:
1567  *      0       Success, event info is filled in *pEvent
1568  */
1569 #if HPT_INTERFACE_VERSION>=0x01010000
1570 int hpt_rebuild_data_block_v2(DEVICEID idMirror, HPT_U64 Lba, HPT_U16 nSector);
1571 #endif
1572
1573 /* hpt_verify_data_block2
1574  *   verify data block on RAID1 or RAID5.
1575  * Version compatibility: v1.1.0.0 or later
1576  * Parameters:
1577  *   idArray - Array ID
1578  *   Lba - block number (on each array member, not logical block!)
1579  *   nSectors - Sectors for each member (RAID 5 will ignore this parameter)
1580  * Returns:
1581  *   0  Success
1582  *   1  Data compare error
1583  *   2  I/O error
1584  */
1585 #if HPT_INTERFACE_VERSION>=0x01010000
1586 int hpt_verify_data_block_v2(DEVICEID idArray, HPT_U64 Lba, HPT_U16 nSectors);
1587 #endif
1588
1589 /* hpt_initialize_data_block2
1590  *   initialize data block (fill with zero) on RAID5
1591  * Version compatibility: v1.1.0.0 or later
1592  * Parameters:
1593  *   idArray - Array ID
1594  *   Lba - block number (on each array member, not logical block!)
1595  *   nSectors - Sectors for each member (RAID 5 will ignore this parameter)
1596  * Returns:
1597  *   0  Success
1598  */
1599 #if HPT_INTERFACE_VERSION>=0x01010000
1600 int hpt_initialize_data_block_v2(DEVICEID idArray, HPT_U64 Lba, HPT_U16 nSectors);
1601 #endif
1602
1603 /* hpt_i2c_transaction
1604  *   perform an transaction on i2c bus
1605  * Version compatibility: v2.0.0.0 or later
1606  * Parameters:
1607  *   indata[0] - controller ID
1608  * Returns:
1609  *   0  Success
1610  */
1611 #if HPT_INTERFACE_VERSION>=0x01020000
1612 int hpt_i2c_transaction(HPT_U8 *indata, HPT_U32 inlen, HPT_U8 *outdata, HPT_U32 outlen, HPT_U32 *poutlen);
1613 #endif
1614
1615 /* hpt_get_parameter_list
1616  *   get a list of driver parameters.
1617  * Version compatibility: v1.0.0.0 or later
1618  * Parameters:
1619  *   location - parameter location
1620  *   outBuffer - a buffer to hold the output
1621  *   outBufferSize - size of outBuffer
1622  * Returns:
1623  *   0  Success
1624  *      put in outBuffer a list of zero terminated parameter names. the whole list
1625  *      is terminated with an additional zero byte.
1626  */
1627 int hpt_get_parameter_list(HPT_U32 location, char *outBuffer, HPT_U32 outBufferSize);
1628
1629 /* hpt_{get,set}_parameter
1630  *   get/set a parameter value.
1631  * Version compatibility: v1.0.0.0 or later
1632  * Parameters:
1633  *   pParam - a pointer to HPT_DRIVER_PARAMETER.
1634  * Returns:
1635  *   0  Success
1636  */
1637 int hpt_get_parameter(PHPT_DRIVER_PARAMETER pParam);
1638 int hpt_set_parameter(PHPT_DRIVER_PARAMETER pParam);
1639
1640 #endif
1641
1642 #pragma pack()
1643
1644 #ifdef __cplusplus
1645 }
1646 #endif
1647 #endif