]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/hptmv/hptintf.h
add -n option to suppress clearing the build tree and add -DNO_CLEAN
[FreeBSD/FreeBSD.git] / sys / dev / hptmv / hptintf.h
1 /*
2  * Copyright (c) 2004-2005 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
29 #ifndef HPT_INTF_H
30 #define HPT_INTF_H
31 #pragma pack(1)
32
33 /*
34  * Version of this interface.
35  * The user mode application must first issue a hpt_get_version() call to
36  * check HPT_INTERFACE_VERSION. When an utility using newer version interface
37  * is used with old version drivers, it must call only the functions that
38  * driver supported.
39  * A new version interface should only add ioctl functions; it should implement
40  * all old version functions without change their definition.
41  */
42 #define __this_HPT_INTERFACE_VERSION 0x01010000
43
44 #ifndef HPT_INTERFACE_VERSION
45 #error "You must define HPT_INTERFACE_VERSION you implemented"
46 #endif
47
48 #if HPT_INTERFACE_VERSION > __this_HPT_INTERFACE_VERSION
49 #error "HPT_INTERFACE_VERSION is invalid"
50 #endif
51
52 /*
53  * DEFINITION
54  *   Logical device  --- a device that can be accessed by OS.
55  *   Physical device --- device attached to the controller.
56  *  A logical device can be simply a physical device.
57  *
58  * Each logical and physical device has a 32bit ID. GUI will use this ID
59  * to identify devices.
60  *   1. The ID must be unique.
61  *   2. The ID must be immutable. Once an ID is assigned to a device, it
62  * must not change when system is running and the device exists.
63  *   3. The ID of logical device must be NOT reusable. If a device is
64  * removed, other newly created logical device must not use the same ID.
65  *   4. The ID must not be zero or 0xFFFFFFFF.
66  */
67 typedef DWORD DEVICEID;
68
69 /*
70  * logical device type.
71  * Identify array (logical device) and physical device.
72  */
73 #define LDT_ARRAY   1
74 #define LDT_DEVICE  2
75
76 /*
77  * Array types
78  * GUI will treat all array as 1-level RAID. No RAID0/1 or RAID1/0.
79  * A RAID0/1 device is type AT_RAID1. A RAID1/0 device is type AT_RAID0.
80  * Their members may be another array of type RAID0 or RAID1.
81  */
82 #define AT_UNKNOWN  0
83 #define AT_RAID0    1
84 #define AT_RAID1    2
85 #define AT_RAID5    3
86 #define AT_JBOD     7
87
88 /*
89  * physical device type
90  */
91 #define PDT_UNKNOWN     0
92 #define PDT_HARDDISK    1
93 #define PDT_CDROM       2
94 #define PDT_TAPE        3
95
96 /*
97  * Some constants.
98  */
99 #define MAX_NAME_LENGTH     36
100 #define MAX_ARRAYNAME_LEN   16
101
102 #define MAX_ARRAY_MEMBERS_V1 8
103 #define MAX_ARRAY_MEMBERS_V2 16
104 /* keep definition for source code compatiblity */
105 #define MAX_ARRAY_MEMBERS MAX_ARRAY_MEMBERS_V1
106
107 /*
108  * io commands
109  * GUI use these commands to do IO on logical/physical devices.
110  */
111 #define IO_COMMAND_READ     1
112 #define IO_COMMAND_WRITE    2
113
114 /*
115  * array flags
116  */
117 #define ARRAY_FLAG_DISABLED         0x00000001 /* The array is disabled */
118 #define ARRAY_FLAG_NEEDBUILDING     0x00000002 /* array need synchronizing */
119 #define ARRAY_FLAG_REBUILDING       0x00000004 /* array is in rebuilding process */
120 #define ARRAY_FLAG_BROKEN           0x00000008 /* broken but may still working */
121 #define ARRAY_FLAG_BOOTDISK         0x00000010 /* array has a active partition */
122 #define ARRAY_FLAG_NEWLY_CREATED    0x00000020 /* a newly created array */
123 #define ARRAY_FLAG_BOOTMARK         0x00000040 /* array has boot mark set */
124 #define ARRAY_FLAG_NEED_AUTOREBUILD 0x00000080 /* auto-rebuild should start */
125 #define ARRAY_FLAG_VERIFYING        0x00000100 /* is being verified */
126 #define ARRAY_FLAG_INITIALIZING     0x00000200 /* is being initialized */
127 #define ARRAY_FLAG_RAID15PLUS       0x80000000 /* display this RAID 1 as RAID 1.5 */
128
129 /*
130  * device flags
131  */
132 #define DEVICE_FLAG_DISABLED        0x00000001 /* device is disabled */
133 #define DEVICE_FLAG_BOOTDISK        0x00000002 /* disk has a active partition */
134 #define DEVICE_FLAG_BOOTMARK        0x00000004 /* disk has boot mark set */
135 #define DEVICE_FLAG_WITH_601        0x00000008 /* has HPT601 connected */
136 #define DEVICE_FLAG_SATA            0x00000010 /* S-ATA device */
137 #define DEVICE_FLAG_IS_SPARE        0x80000000 /* is a spare disk */
138
139 /*
140  * array states used by hpt_set_array_state()
141  */
142 /* old defines */
143 #define MIRROR_REBUILD_START    1
144 #define MIRROR_REBUILD_ABORT    2
145 #define MIRROR_REBUILD_COMPLETE 3
146 /* new defines */
147 #define AS_REBUILD_START 1
148 #define AS_REBUILD_ABORT 2
149 #define AS_REBUILD_PAUSE AS_REBUILD_ABORT
150 #define AS_REBUILD_COMPLETE 3
151 #define AS_VERIFY_START 4
152 #define AS_VERIFY_ABORT 5
153 #define AS_VERIFY_COMPLETE 6
154 #define AS_INITIALIZE_START 7
155 #define AS_INITIALIZE_ABORT 8
156 #define AS_INITIALIZE_COMPLETE 9
157 #define AS_VERIFY_FAILED 10
158 #define AS_REBUILD_STOP 11
159 #define AS_SAVE_STATE   12
160 /************************************************************************
161  * ioctl code
162  * It would be better if ioctl code are the same on different platforms,
163  * but we must not conflict with system defined ioctl code.
164  ************************************************************************/
165 #if defined(LINUX) || defined(__FreeBSD_version) || defined(_MACOSX_)
166 #define HPT_CTL_CODE(x) (x+0xFF00)
167 #elif defined(_MS_WIN32_) || defined(WIN32)
168
169 #ifndef CTL_CODE
170 #define CTL_CODE( DeviceType, Function, Method, Access ) \
171                         (((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
172 #endif
173 #define HPT_CTL_CODE(x) CTL_CODE(0x370, 0x900+(x), 0, 0)
174 #define HPT_CTL_CODE_WIN32_TO_I960(x) ((((x) & 0xffff)>>2)-0x900)
175
176 #else 
177 #define HPT_CTL_CODE(x) (x)
178 #endif
179
180 #define HPT_IOCTL_GET_VERSION               HPT_CTL_CODE(0)
181 #define HPT_IOCTL_GET_CONTROLLER_COUNT      HPT_CTL_CODE(1)
182 #define HPT_IOCTL_GET_CONTROLLER_INFO       HPT_CTL_CODE(2)
183 #define HPT_IOCTL_GET_CHANNEL_INFO          HPT_CTL_CODE(3)
184 #define HPT_IOCTL_GET_LOGICAL_DEVICES       HPT_CTL_CODE(4)
185 #define HPT_IOCTL_GET_DEVICE_INFO           HPT_CTL_CODE(5)
186 #define HPT_IOCTL_CREATE_ARRAY              HPT_CTL_CODE(6)
187 #define HPT_IOCTL_DELETE_ARRAY              HPT_CTL_CODE(7)
188 #define HPT_IOCTL_ARRAY_IO                  HPT_CTL_CODE(8)
189 #define HPT_IOCTL_DEVICE_IO                 HPT_CTL_CODE(9)
190 #define HPT_IOCTL_GET_EVENT                 HPT_CTL_CODE(10)
191 #define HPT_IOCTL_REBUILD_MIRROR            HPT_CTL_CODE(11)
192 /* use HPT_IOCTL_REBUILD_DATA_BLOCK from now on */
193 #define HPT_IOCTL_REBUILD_DATA_BLOCK HPT_IOCTL_REBUILD_MIRROR
194 #define HPT_IOCTL_ADD_SPARE_DISK            HPT_CTL_CODE(12)
195 #define HPT_IOCTL_REMOVE_SPARE_DISK         HPT_CTL_CODE(13)
196 #define HPT_IOCTL_ADD_DISK_TO_ARRAY         HPT_CTL_CODE(14)
197 #define HPT_IOCTL_SET_ARRAY_STATE           HPT_CTL_CODE(15)
198 #define HPT_IOCTL_SET_ARRAY_INFO            HPT_CTL_CODE(16)
199 #define HPT_IOCTL_SET_DEVICE_INFO           HPT_CTL_CODE(17)
200 #define HPT_IOCTL_RESCAN_DEVICES            HPT_CTL_CODE(18)
201 #define HPT_IOCTL_GET_DRIVER_CAPABILITIES   HPT_CTL_CODE(19)
202 #define HPT_IOCTL_GET_601_INFO              HPT_CTL_CODE(20)
203 #define HPT_IOCTL_SET_601_INFO              HPT_CTL_CODE(21)
204 #define HPT_IOCTL_LOCK_DEVICE               HPT_CTL_CODE(22)
205 #define HPT_IOCTL_UNLOCK_DEVICE             HPT_CTL_CODE(23)
206 #define HPT_IOCTL_IDE_PASS_THROUGH          HPT_CTL_CODE(24)
207 #define HPT_IOCTL_VERIFY_DATA_BLOCK         HPT_CTL_CODE(25)
208 #define HPT_IOCTL_INITIALIZE_DATA_BLOCK     HPT_CTL_CODE(26)
209 #define HPT_IOCTL_ADD_DEDICATED_SPARE       HPT_CTL_CODE(27)
210 #define HPT_IOCTL_DEVICE_IO_EX              HPT_CTL_CODE(28)
211 #define HPT_IOCTL_SET_BOOT_MARK             HPT_CTL_CODE(29)
212 #define HPT_IOCTL_QUERY_REMOVE              HPT_CTL_CODE(30)
213 #define HPT_IOCTL_REMOVE_DEVICES            HPT_CTL_CODE(31)
214 #define HPT_IOCTL_CREATE_ARRAY_V2           HPT_CTL_CODE(32)
215 #define HPT_IOCTL_GET_DEVICE_INFO_V2        HPT_CTL_CODE(33)
216 #define HPT_IOCTL_SET_DEVICE_INFO_V2        HPT_CTL_CODE(34)
217 #define HPT_IOCTL_REBUILD_DATA_BLOCK_V2     HPT_CTL_CODE(35)
218 #define HPT_IOCTL_VERIFY_DATA_BLOCK_V2      HPT_CTL_CODE(36)
219 #define HPT_IOCTL_INITIALIZE_DATA_BLOCK_V2  HPT_CTL_CODE(37)
220 #define HPT_IOCTL_LOCK_DEVICE_V2            HPT_CTL_CODE(38)
221 #define HPT_IOCTL_DEVICE_IO_V2              HPT_CTL_CODE(39)
222 #define HPT_IOCTL_DEVICE_IO_EX_V2           HPT_CTL_CODE(40)
223
224 /* Windows only */
225 #define HPT_IOCTL_GET_CONTROLLER_IDS        HPT_CTL_CODE(100)
226 #define HPT_IOCTL_GET_DCB                   HPT_CTL_CODE(101)
227 #define HPT_IOCTL_EPROM_IO                  HPT_CTL_CODE(102)
228 #define HPT_IOCTL_GET_CONTROLLER_VENID      HPT_CTL_CODE(103)
229
230 /************************************************************************
231  * shared data structures
232  ************************************************************************/
233
234 /*
235  * Chip Type
236  */
237 #define CHIP_TYPE_HPT366      1
238 #define CHIP_TYPE_HPT368      2
239 #define CHIP_TYPE_HPT370      3
240 #define CHIP_TYPE_HPT370A     4
241 #define CHIP_TYPE_HPT370B     5
242 #define CHIP_TYPE_HPT374      6
243 #define CHIP_TYPE_HPT372      7
244 #define CHIP_TYPE_HPT372A     8
245 #define CHIP_TYPE_HPT302      9
246 #define CHIP_TYPE_HPT371      10
247 #define CHIP_TYPE_HPT372N     11
248 #define CHIP_TYPE_HPT302N     12
249 #define CHIP_TYPE_HPT371N     13
250 #define CHIP_TYPE_SI3112A     14
251 #define CHIP_TYPE_ICH5        15
252 #define CHIP_TYPE_ICH5R       16
253
254 /*
255  * Chip Flags
256  */
257 #define CHIP_SUPPORT_ULTRA_66   0x20
258 #define CHIP_SUPPORT_ULTRA_100  0x40
259 #define CHIP_HPT3XX_DPLL_MODE   0x80
260 #define CHIP_SUPPORT_ULTRA_133  0x01
261 #define CHIP_SUPPORT_ULTRA_150  0x02
262
263 typedef struct _DRIVER_CAPABILITIES {
264         DWORD dwSize;
265
266         UCHAR MaximumControllers;           /* maximum controllers the driver can support */
267         UCHAR SupportCrossControllerRAID;   /* 1-support, 0-not support */
268         UCHAR MinimumBlockSizeShift;        /* minimum block size shift */
269         UCHAR MaximumBlockSizeShift;        /* maximum block size shift */
270
271         UCHAR SupportDiskModeSetting;
272         UCHAR SupportSparePool;
273         UCHAR MaximumArrayNameLength;
274         /* only one byte left here! */
275 #ifdef __BIG_ENDIAN_BITFIELD
276         UCHAR reserved: 4;
277         UCHAR SupportHotSwap: 1;
278         UCHAR HighPerformanceRAID1: 1;
279         UCHAR RebuildProcessInDriver: 1;
280         UCHAR SupportDedicatedSpare: 1;
281 #else 
282         UCHAR SupportDedicatedSpare: 1; /* call hpt_add_dedicated_spare() for dedicated spare. */
283         UCHAR RebuildProcessInDriver: 1; /* Windows only. used by mid layer for rebuild control. */
284         UCHAR HighPerformanceRAID1: 1; /* Support RAID1.5 */
285         UCHAR SupportHotSwap: 1;
286         UCHAR reserved: 4;
287 #endif
288
289         /* SupportedRAIDTypes is an array of bytes, one of each is an array type.
290          * Only non-zero values is valid. Bit0-3 represents the lower(child) level RAID type;
291          * bit4-7 represents the top level. i.e.
292          *     RAID 0/1 is (AT_RAID1<<4) | AT_RAID0
293          *     RAID 5/0 is (AT_RAID0<<4) | AT_RAID5
294          */
295         UCHAR SupportedRAIDTypes[16];
296         /* maximum members in an array corresponding to SupportedRAIDTypes */
297         UCHAR MaximumArrayMembers[16];
298 }
299 DRIVER_CAPABILITIES, *PDRIVER_CAPABILITIES;
300
301 /*
302  * Controller information.
303  */
304 typedef struct _CONTROLLER_INFO {
305         UCHAR ChipType;                     /* chip type */
306         UCHAR InterruptLevel;               /* IRQ level */
307         UCHAR NumBuses;                     /* bus count */
308         UCHAR ChipFlags;
309
310         UCHAR szProductID[MAX_NAME_LENGTH]; /* product name */
311         UCHAR szVendorID[MAX_NAME_LENGTH];  /* vender name */
312
313 } CONTROLLER_INFO, *PCONTROLLER_INFO;
314
315 /*
316  * Channel information.
317  */
318 typedef struct _CHANNEL_INFO {
319         ULONG       IoPort;         /* IDE Base Port Address */
320         ULONG       ControlPort;    /* IDE Control Port Address */
321
322         DEVICEID    Devices[2];     /* device connected to this channel */
323
324 } CHANNEL_INFO, *PCHANNEL_INFO;
325
326 /*
327  * time represented in DWORD format
328  */
329 #ifndef __KERNEL__
330 typedef struct _TIME_RECORD {
331    UINT        seconds:6;      /* 0 - 59 */
332    UINT        minutes:6;      /* 0 - 59 */
333    UINT        month:4;        /* 1 - 12 */
334    UINT        hours:6;        /* 0 - 59 */
335    UINT        day:5;          /* 1 - 31 */
336    UINT        year:5;         /* 0=2000, 31=2031 */
337 } TIME_RECORD;
338 #endif
339
340 /*
341  * Array information.
342  */
343 typedef struct _HPT_ARRAY_INFO {
344         UCHAR       Name[MAX_ARRAYNAME_LEN];/* array name */
345         UCHAR       Description[64];        /* array description */
346         UCHAR       CreateManager[16];      /* who created it */
347         TIME_RECORD CreateTime;             /* when created it */
348
349         UCHAR       ArrayType;              /* array type */
350         UCHAR       BlockSizeShift;         /* stripe size */
351         UCHAR       nDisk;                  /* member count: Number of ID in Members[] */
352         UCHAR       reserved;
353
354         DWORD       Flags;                  /* working flags, see ARRAY_FLAG_XXX */
355         DWORD       Members[MAX_ARRAY_MEMBERS_V1];  /* member array/disks */
356
357         /*
358          * rebuilding progress, xx.xx% = sprintf(s, "%.2f%%", RebuildingProgress/100.0);
359          * only valid if rebuilding is done by driver code.
360          * Member Flags will have ARRAY_FLAG_REBUILDING set at this case.
361          * Verify operation use same fields below, the only difference is
362          * ARRAY_FLAG_VERIFYING is set.
363          */
364         DWORD       RebuildingProgress;
365         DWORD       RebuiltSectors; /* rebuilding point (LBA) for single member */
366
367 } HPT_ARRAY_INFO, *PHPT_ARRAY_INFO;  /*LDX modify ARRAY_INFO TO HPT_ARRAY_INFO to avoid compiling error in Windows*/
368
369 #if HPT_INTERFACE_VERSION>=0x01010000
370 typedef struct _LBA64 {
371         DWORD lo32;
372         DWORD hi32;
373 }
374 LBA64;
375 typedef struct _HPT_ARRAY_INFO_V2 {
376         UCHAR       Name[MAX_ARRAYNAME_LEN];/* array name */
377         UCHAR       Description[64];        /* array description */
378         UCHAR       CreateManager[16];      /* who created it */
379         TIME_RECORD CreateTime;             /* when created it */
380
381         UCHAR       ArrayType;              /* array type */
382         UCHAR       BlockSizeShift;         /* stripe size */
383         UCHAR       nDisk;                  /* member count: Number of ID in Members[] */
384         UCHAR       reserved;
385
386         DWORD       Flags;                  /* working flags, see ARRAY_FLAG_XXX */
387         DWORD       Members[MAX_ARRAY_MEMBERS_V2];  /* member array/disks */
388
389         DWORD       RebuildingProgress;
390         LBA64       RebuiltSectors; /* rebuilding point (LBA) for single member */
391         
392         DWORD       reserve4[4];
393
394 } HPT_ARRAY_INFO_V2, *PHPT_ARRAY_INFO_V2;
395 #endif
396
397 /*
398  * ATA/ATAPI Device identify data without the Reserved4.
399  */
400 #ifndef __KERNEL__
401 typedef struct _IDENTIFY_DATA2 {
402         USHORT GeneralConfiguration;            /* 00 00 */
403         USHORT NumberOfCylinders;               /* 02  1 */
404         USHORT Reserved1;                       /* 04  2 */
405         USHORT NumberOfHeads;                   /* 06  3 */
406         USHORT UnformattedBytesPerTrack;        /* 08  4 */
407         USHORT UnformattedBytesPerSector;       /* 0A  5 */
408         USHORT SectorsPerTrack;                 /* 0C  6 */
409         USHORT VendorUnique1[3];                /* 0E  7-9 */
410         USHORT SerialNumber[10];                /* 14  10-19 */
411         USHORT BufferType;                      /* 28  20 */
412         USHORT BufferSectorSize;                /* 2A  21 */
413         USHORT NumberOfEccBytes;                /* 2C  22 */
414         USHORT FirmwareRevision[4];             /* 2E  23-26 */
415         USHORT ModelNumber[20];                 /* 36  27-46 */
416         UCHAR  MaximumBlockTransfer;            /* 5E  47 */
417         UCHAR  VendorUnique2;                   /* 5F */
418         USHORT DoubleWordIo;                    /* 60  48 */
419         USHORT Capabilities;                    /* 62  49 */
420         USHORT Reserved2;                       /* 64  50 */
421         UCHAR  VendorUnique3;                   /* 66  51 */
422         UCHAR  PioCycleTimingMode;              /* 67 */
423         UCHAR  VendorUnique4;                   /* 68  52 */
424         UCHAR  DmaCycleTimingMode;              /* 69 */
425         USHORT TranslationFieldsValid:1;        /* 6A  53 */
426         USHORT Reserved3:15;
427         USHORT NumberOfCurrentCylinders;        /* 6C  54 */
428         USHORT NumberOfCurrentHeads;            /* 6E  55 */
429         USHORT CurrentSectorsPerTrack;          /* 70  56 */
430         ULONG  CurrentSectorCapacity;           /* 72  57-58 */
431         USHORT CurrentMultiSectorSetting;       /*     59 */
432         ULONG  UserAddressableSectors;          /*     60-61 */
433         USHORT SingleWordDMASupport : 8;        /*     62 */
434         USHORT SingleWordDMAActive : 8;
435         USHORT MultiWordDMASupport : 8;         /*     63 */
436         USHORT MultiWordDMAActive : 8;
437         USHORT AdvancedPIOModes : 8;            /*     64 */
438         USHORT Reserved4 : 8;
439         USHORT MinimumMWXferCycleTime;          /*     65 */
440         USHORT RecommendedMWXferCycleTime;      /*     66 */
441         USHORT MinimumPIOCycleTime;             /*     67 */
442         USHORT MinimumPIOCycleTimeIORDY;        /*     68 */
443         USHORT Reserved5[2];                    /*     69-70 */
444         USHORT ReleaseTimeOverlapped;           /*     71 */
445         USHORT ReleaseTimeServiceCommand;       /*     72 */
446         USHORT MajorRevision;                   /*     73 */
447         USHORT MinorRevision;                   /*     74 */
448 /*    USHORT Reserved6[14];                   //     75-88 */
449 } IDENTIFY_DATA2, *PIDENTIFY_DATA2;
450 #endif
451
452 /*
453  * physical device information.
454  * IdentifyData.ModelNumber[] is byte-swapped from the original identify data.
455  */
456 typedef struct _DEVICE_INFO {
457         UCHAR   ControllerId;           /* controller id */
458         UCHAR   PathId;                 /* bus */
459         UCHAR   TargetId;               /* id */
460         UCHAR   DeviceModeSetting;      /* Current Data Transfer mode: 0-4 PIO 0-4 */
461                                                                         /* 5-7 MW DMA0-2, 8-13 UDMA0-5             */
462         UCHAR   DeviceType;             /* device type */
463         UCHAR   UsableMode;             /* highest usable mode */
464         
465         UCHAR   ReadAheadSupported: 1;
466         UCHAR   ReadAheadEnabled: 1;
467         UCHAR   WriteCacheSupported: 1;
468         UCHAR   WriteCacheEnabled: 1;
469         UCHAR   TCQSupported: 1;
470         UCHAR   TCQEnabled: 1;
471         UCHAR   NCQSupported: 1;
472         UCHAR   NCQEnabled: 1;
473         UCHAR   reserved;
474
475         DWORD   Flags;                  /* working flags, see DEVICE_FLAG_XXX */
476
477         IDENTIFY_DATA2 IdentifyData;    /* Identify Data of this device */
478
479 } DEVICE_INFO, *PDEVICE_INFO;
480
481 /*
482  * HPT601 information
483  */
484 #define HPT601_INFO_DEVICEID      1
485 #define HPT601_INFO_TEMPERATURE   2
486 #define HPT601_INFO_FANSTATUS     4
487 #define HPT601_INFO_BEEPERCONTROL 8
488 #define HPT601_INFO_LED1CONTROL   0x10
489 #define HPT601_INFO_LED2CONTROL   0x20
490 #define HPT601_INFO_POWERSTATUS   0x40
491
492 typedef struct _HPT601_INFO {
493         WORD ValidFields;       /* mark valid fields below */
494         WORD DeviceId;          /* 0x5A3E */
495         WORD Temperature;       /* Read: temperature sensor value. Write: temperature limit */
496         WORD FanStatus;         /* Fan status */
497         WORD BeeperControl;     /* bit4: beeper control bit. bit0-3: frequency bits */
498         WORD LED1Control;       /* bit4: twinkling control bit. bit0-3: frequency bits */
499         WORD LED2Control;       /* bit4: twinkling control bit. bit0-3: frequency bits */
500         WORD PowerStatus;       /* 1: has power 2: no power */
501 } HPT601_INFO, *PHPT601_INFO;
502
503 /*
504  * Logical device information.
505  * Union of ArrayInfo and DeviceInfo.
506  * Common properties will be put in logical device information.
507  */
508 typedef struct _LOGICAL_DEVICE_INFO {
509         UCHAR       Type;                   /* LDT_ARRAY or LDT_DEVICE */
510         UCHAR       reserved[3];
511
512         DWORD       Capacity;               /* array capacity */
513         DEVICEID    ParentArray;
514
515         union {
516                 HPT_ARRAY_INFO array;
517                 DEVICE_INFO device;
518         } u;
519
520 } LOGICAL_DEVICE_INFO, *PLOGICAL_DEVICE_INFO;
521
522 #if HPT_INTERFACE_VERSION>=0x01010000
523 typedef struct _LOGICAL_DEVICE_INFO_V2 {
524         UCHAR       Type;                   /* LDT_ARRAY or LDT_DEVICE */
525         UCHAR       reserved[3];
526
527         LBA64       Capacity;           /* array capacity */
528         DEVICEID    ParentArray;
529
530         union {
531                 HPT_ARRAY_INFO_V2 array;
532                 DEVICE_INFO device;
533         } u;
534
535 } LOGICAL_DEVICE_INFO_V2, *PLOGICAL_DEVICE_INFO_V2;
536 #endif
537
538 /*
539  * ALTERABLE_ARRAY_INFO and ALTERABLE_DEVICE_INFO, used in set_array_info()
540  * and set_device_info().
541  * When set_xxx_info() is called, the ValidFields member indicates which
542  * fields in the structure are valid.
543  */
544 /* field masks */
545 #define AAIF_NAME           1
546 #define AAIF_DESCRIPTION    2
547 #define ADIF_MODE           1
548 #define ADIF_TCQ            2
549 #define ADIF_NCQ            4
550 #define ADIF_WRITE_CACHE    8
551 #define ADIF_READ_AHEAD     0x10
552
553 typedef struct _ALTERABLE_ARRAY_INFO {
554         DWORD   ValidFields;                /* mark valid fields below */
555         UCHAR   Name[MAX_ARRAYNAME_LEN];    /* array name */
556         UCHAR   Description[64];            /* array description */
557 }
558 ALTERABLE_ARRAY_INFO, *PALTERABLE_ARRAY_INFO;
559
560 typedef struct _ALTERABLE_DEVICE_INFO {
561         DWORD   ValidFields;                /* mark valid fields below */
562         UCHAR   DeviceModeSetting;          /* 0-4 PIO 0-4, 5-7 MW DMA0-2, 8-13 UDMA0-5 */
563 }
564 ALTERABLE_DEVICE_INFO, *PALTERABLE_DEVICE_INFO;
565
566 typedef struct _ALTERABLE_DEVICE_INFO_V2 {
567         DWORD   ValidFields;                /* mark valid fields below */
568         UCHAR   DeviceModeSetting;          /* 0-4 PIO 0-4, 5-7 MW DMA0-2, 8-13 UDMA0-5 */
569         UCHAR   TCQEnabled;
570         UCHAR   NCQEnabled;
571         UCHAR   WriteCacheEnabled;
572         UCHAR   ReadAheadEnabled;
573         UCHAR   reserve[3];
574         ULONG   reserve2[13]; /* pad to 64 bytes */
575 }
576 ALTERABLE_DEVICE_INFO_V2, *PALTERABLE_DEVICE_INFO_V2;
577
578 /*
579  * CREATE_ARRAY_PARAMS
580  *  Param structure used to create an array.
581  */
582 typedef struct _CREATE_ARRAY_PARAMS {
583         UCHAR ArrayType;                    /* 1-level array type */
584         UCHAR nDisk;                        /* number of elements in Members[] array */
585         UCHAR BlockSizeShift;               /* Stripe size if ArrayType==AT_RAID0 / AT_RAID5 */
586         UCHAR CreateFlags;                  /* See CAF_xxx */
587
588         UCHAR ArrayName[MAX_ARRAYNAME_LEN]; /* Array name */
589         UCHAR       Description[64];        /* array description */
590         UCHAR       CreateManager[16];      /* who created it */
591         TIME_RECORD CreateTime;             /* when created it */
592
593         DWORD Members[MAX_ARRAY_MEMBERS_V1];/* ID of array members, a member can be an array */
594
595 } CREATE_ARRAY_PARAMS, *PCREATE_ARRAY_PARAMS;
596
597 #if HPT_INTERFACE_VERSION>=0x01010000
598 typedef struct _CREATE_ARRAY_PARAMS_V2 {
599         UCHAR ArrayType;                    /* 1-level array type */
600         UCHAR nDisk;                        /* number of elements in Members[] array */
601         UCHAR BlockSizeShift;               /* Stripe size if ArrayType==AT_RAID0 / AT_RAID5 */
602         UCHAR CreateFlags;                  /* See CAF_xxx */
603
604         UCHAR ArrayName[MAX_ARRAYNAME_LEN]; /* Array name */
605         UCHAR       Description[64];        /* array description */
606         UCHAR       CreateManager[16];      /* who created it */
607         TIME_RECORD CreateTime;             /* when created it */
608         LBA64 Capacity;                     /* specify array capacity (0 for default) */
609
610         DWORD Members[MAX_ARRAY_MEMBERS_V2];/* ID of array members, a member can be an array */
611
612 } CREATE_ARRAY_PARAMS_V2, *PCREATE_ARRAY_PARAMS_V2;
613 #endif
614
615 /*
616  * Flags used for creating an RAID 1 array
617  *
618  * CAF_CREATE_AND_DUPLICATE
619  *    Copy source disk contents to target for RAID 1. If user choose "create and duplicate"
620  *    to create an array, GUI will call CreateArray() with this flag set. Then GUI should
621  *    call hpt_get_device_info() with the returned array ID and check returned flags to
622  *    see if ARRAY_FLAG_REBUILDING is set. If not set, driver does not support rebuilding
623  *    and GUI must do duplication itself.
624  * CAF_DUPLICATE_MUST_DONE
625  *    If the duplication is aborted or fails, do not create the array.
626  */
627 #define CAF_CREATE_AND_DUPLICATE 1
628 #define CAF_DUPLICATE_MUST_DONE  2
629 #define CAF_CREATE_AS_RAID15     4
630 /*
631  * Flags used for creating an RAID 5 array
632  */
633 #define CAF_CREATE_R5_NO_BUILD     1
634 #define CAF_CREATE_R5_ZERO_INIT    2
635 #define CAF_CREATE_R5_BUILD_PARITY 4
636
637 /*
638  * Flags used for deleting an array
639  *
640  * DAF_KEEP_DATA_IF_POSSIBLE
641  *    If this flag is set, deleting a RAID 1 array will not destroy the data on both disks.
642  *    Deleting a JBOD should keep partitions on first disk ( not implement now ).
643  *    Deleting a RAID 0/1 should result as two RAID 0 array ( not implement now ).
644  */
645 #define DAF_KEEP_DATA_IF_POSSIBLE 1
646
647 /*
648  * event types
649  */
650 #define ET_DEVICE_REMOVED   1   /* device removed */
651 #define ET_DEVICE_PLUGGED   2   /* device plugged */
652 #define ET_DEVICE_ERROR     3   /* device I/O error */
653 #define ET_REBUILD_STARTED  4
654 #define ET_REBUILD_ABORTED  5
655 #define ET_REBUILD_FINISHED 6
656 #define ET_SPARE_TOOK_OVER  7
657 #define ET_REBUILD_FAILED   8
658 #define ET_VERIFY_STARTED   9
659 #define ET_VERIFY_ABORTED   10
660 #define ET_VERIFY_FAILED    11
661 #define ET_VERIFY_FINISHED  12
662 #define ET_INITIALIZE_STARTED   13
663 #define ET_INITIALIZE_ABORTED   14
664 #define ET_INITIALIZE_FAILED    15
665 #define ET_INITIALIZE_FINISHED  16
666 #define ET_VERIFY_DATA_ERROR    17
667
668 /*
669  * event structure
670  */
671 typedef struct _HPT_EVENT {
672         TIME_RECORD Time;
673         DEVICEID    DeviceID;
674         UCHAR       EventType;
675         UCHAR       reserved[3];
676
677         UCHAR       Data[32]; /* various data depend on EventType */
678 } HPT_EVENT, *PHPT_EVENT;
679
680 /*
681  * IDE pass-through command. Use it at your own risk!
682  */
683 #ifdef _MSC_VER
684 #pragma warning(disable:4200)
685 #endif
686 typedef struct _IDE_PASS_THROUGH_HEADER {
687         DEVICEID idDisk;           /* disk ID */
688         BYTE     bFeaturesReg;     /* feature register */
689         BYTE     bSectorCountReg;  /* IDE sector count register. */
690         BYTE     bSectorNumberReg; /* IDE sector number register. */
691         BYTE     bCylLowReg;       /* IDE low order cylinder value. */
692         BYTE     bCylHighReg;      /* IDE high order cylinder value. */
693         BYTE     bDriveHeadReg;    /* IDE drive/head register. */
694         BYTE     bCommandReg;      /* Actual IDE command. Checked for validity by driver. */
695         BYTE     reserve1;
696         DWORD    DataSize;         /* data size in bytes, if the command has data transfer */
697 #ifdef _MSC_VER
698         BYTE     DataBuffer[0];    /* data buffer */
699 #endif
700 }
701 IDE_PASS_THROUGH_HEADER, *PIDE_PASS_THROUGH_HEADER;
702
703 /*
704  * device io packet format
705  */
706 typedef struct _DEVICE_IO_EX_PARAMS {
707         DEVICEID idDisk;
708         ULONG    Lba;
709         USHORT   nSectors;
710         UCHAR    Command; /* IO_COMMAD_xxx */
711         UCHAR    BufferType; /* BUFFER_TYPE_xxx, see below */
712         ULONG    BufferPtr;
713 }
714 DEVICE_IO_EX_PARAMS, *PDEVICE_IO_EX_PARAMS;
715
716 #define BUFFER_TYPE_LOGICAL              1 /* logical pointer to buffer */
717 #define BUFFER_TYPE_PHYSICAL             2 /* physical address of buffer */
718 #define BUFFER_TYPE_LOGICAL_LOGICAL_SG   3 /* logical pointer to logical S/G table */
719 #define BUFFER_TYPE_LOGICAL_PHYSICAL_SG  4 /* logical pointer to physical S/G table */
720 #define BUFFER_TYPE_PHYSICAL_LOGICAL_SG  5 /* physical address to logical S/G table */
721 #define BUFFER_TYPE_PHYSICAL_PHYSICAL_SG 6 /* physical address of physical S/G table */
722 #define BUFFER_TYPE_PHYSICAL_PHYSICAL_SG_PIO 7 /* non DMA capable physical address of physical S/G table */
723
724 /*
725  * all ioctl functions should use far pointers. It's not a problem on
726  * 32bit platforms, however, BIOS needs care.
727  */
728
729 /*
730  * ioctl structure
731  */
732 #define HPT_IOCTL_MAGIC 0x1A2B3C4D
733
734 typedef struct _HPT_IOCTL_PARAM {
735         DWORD   Magic;                 /* used to check if it's a valid ioctl packet */
736         DWORD   dwIoControlCode;       /* operation control code */
737         LPVOID  lpInBuffer;            /* input data buffer */
738         DWORD   nInBufferSize;         /* size of input data buffer */
739         LPVOID  lpOutBuffer;           /* output data buffer */
740         DWORD   nOutBufferSize;        /* size of output data buffer */
741         LPDWORD lpBytesReturned;       /* count of bytes returned */
742 }
743 HPT_IOCTL_PARAM, *PHPT_IOCTL_PARAM;
744
745 /* for 64-bit system */
746 typedef struct _HPT_IOCTL_PARAM32 {
747         DWORD   Magic;
748         DWORD   dwIoControlCode;
749         DWORD   lpInBuffer;
750         DWORD   nInBufferSize;
751         DWORD   lpOutBuffer;
752         DWORD   nOutBufferSize;
753         DWORD   lpBytesReturned;
754 }
755 HPT_IOCTL_PARAM32, *PHPT_IOCTL_PARAM32;
756
757 /*
758  * User-mode ioctl parameter passing conventions:
759  *   The ioctl function implementation is platform specific, so we don't
760  * have forced rules for it. However, it's suggested to use a parameter
761  * passing method as below
762  *   1) Put all input data continuously in an input buffer.
763  *   2) Prepare an output buffer with enough size if needed.
764  *   3) Fill a HPT_IOCTL_PARAM structure.
765  *   4) Pass the structure to driver through a platform-specific method.
766  * This is implemented in the mid-layer user-mode library. The UI
767  * programmer needn't care about it.
768  */
769
770 /************************************************************************
771  * User mode functions
772  ************************************************************************/
773 #ifndef __KERNEL__
774 /*
775  * hpt_get_version
776  * Version compatibility: all versions
777  * Parameters:
778  *  None
779  * Returns:
780  *  interface version. 0 when fail.
781  */
782 DWORD hpt_get_version();
783
784 /*-------------------------------------------------------------------------- */
785
786 /*
787  * hpt_get_driver_capabilities
788  * Version compatibility: v1.0.0.2 or later
789  * Parameters:
790  *  Pointer to receive a DRIVE_CAPABILITIES structure. The caller must set
791  *  dwSize member to sizeof(DRIVER_CAPABILITIES). The callee must check this
792  *  member to see if it's correct.
793  * Returns:
794  *  0 - Success
795  */
796 int hpt_get_driver_capabilities(PDRIVER_CAPABILITIES cap);
797
798 /*-------------------------------------------------------------------------- */
799
800 /*
801  * hpt_get_controller_count
802  * Version compatibility: v1.0.0.1 or later
803  * Parameters:
804  *  None
805  * Returns:
806  *  number of controllers
807  */
808 int hpt_get_controller_count();
809
810 /*-------------------------------------------------------------------------- */
811
812 /* hpt_get_controller_info
813  * Version compatibility: v1.0.0.1 or later
814  * Parameters:
815  *  id      Controller id
816  *  pInfo   pointer to CONTROLLER_INFO buffer
817  * Returns:
818  *  0       Success, controller info is put into (*pInfo ).
819  */
820 int hpt_get_controller_info(int id, PCONTROLLER_INFO pInfo);
821
822 /*-------------------------------------------------------------------------- */
823
824 /* hpt_get_channel_info
825  * Version compatibility: v1.0.0.1 or later
826  * Parameters:
827  *  id      Controller id
828  *  bus     bus number
829  *  pInfo   pointer to CHANNEL_INFO buffer
830  * Returns:
831  *  0       Success, channel info is put into (*pInfo ).
832  */
833 int hpt_get_channel_info(int id, int bus, PCHANNEL_INFO pInfo);
834
835 /*-------------------------------------------------------------------------- */
836
837 /* hpt_get_logical_devices
838  * Version compatibility: v1.0.0.1 or later
839  * Parameters:
840  *  pIds        pointer to a DEVICEID array
841  *  nMaxCount   array size
842  * Returns:
843  *  Number of ID returned. All logical device IDs are put into pIds array.
844  *  Note: A spare disk is not a logical device.
845  */
846 int hpt_get_logical_devices(DEVICEID * pIds, int nMaxCount);
847
848 /*-------------------------------------------------------------------------- */
849
850 /* hpt_get_device_info
851  * Version compatibility: v1.0.0.1 or later
852  * Parameters:
853  *  id      logical device id
854  *  pInfo   pointer to HPT_ARRAY_INFO structure
855  * Returns:
856  *  0 - Success
857  */
858 int hpt_get_device_info(DEVICEID id, PLOGICAL_DEVICE_INFO pInfo);
859
860 #if HPT_INTERFACE_VERSION>=0x01010000
861 int hpt_get_device_info_v2(DEVICEID id, PLOGICAL_DEVICE_INFO_V2 pInfo);
862 #endif
863
864 /*-------------------------------------------------------------------------- */
865
866 /* hpt_create_array
867  * Version compatibility: v1.0.0.1 or later
868  * Parameters:
869  *  pParam      pointer to CREATE_ARRAY_PARAMS structure
870  * Returns:
871  *  0   failed
872  *  else return array id
873  */
874 DEVICEID hpt_create_array(PCREATE_ARRAY_PARAMS pParam);
875
876 #if HPT_INTERFACE_VERSION>=0x01010000
877 DEVICEID hpt_create_array_v2(PCREATE_ARRAY_PARAMS_V2 pParam);
878 #endif
879
880 /*-------------------------------------------------------------------------- */
881
882 /* hpt_delete_array
883  * Version compatibility: v1.0.0.1 or later
884  * Parameters:
885  *  id      array id
886  * Returns:
887  *  0   Success
888  */
889 int hpt_delete_array(DEVICEID id, DWORD options);
890
891 /*-------------------------------------------------------------------------- */
892
893 /* hpt_device_io
894  *  Read/write data on array and physcal device.
895  * Version compatibility: v1.0.0.1 or later
896  * Parameters:
897  *  id      device id. If it's an array ID, IO will be performed on the array.
898  *          If it's a physical device ID, IO will be performed on the device.
899  *  cmd     IO_COMMAND_READ or IO_COMMAND_WRITE
900  *  buffer  data buffer
901  *  length  data size
902  * Returns:
903  *  0   Success
904  */
905 int hpt_device_io(DEVICEID id, int cmd, ULONG lba, DWORD nSector, LPVOID buffer);
906
907 #if HPT_INTERFACE_VERSION >= 0x01010000
908 int hpt_device_io_v2(DEVICEID id, int cmd, LBA64 lba, DWORD nSector, LPVOID buffer);
909 #endif
910
911 /* hpt_add_disk_to_array
912  *   Used to dynamicly add a disk to an RAID1, RAID0/1, RAID1/0 or RAID5 array.
913  *   Auto-rebuild will start.
914  * Version compatibility: v1.0.0.1 or later
915  * Parameters:
916  *  idArray     array id
917  *  idDisk      disk id
918  * Returns:
919  *  0   Success
920  */
921 int hpt_add_disk_to_array(DEVICEID idArray, DEVICEID idDisk);
922 /*-------------------------------------------------------------------------- */
923
924 /* hpt_add_spare_disk
925  * Version compatibility: v1.0.0.1 or later
926  *   Add a disk to spare pool.
927  * Parameters:
928  *  idDisk      disk id
929  * Returns:
930  *  0   Success
931  */
932 int hpt_add_spare_disk(DEVICEID idDisk);
933 /*-------------------------------------------------------------------------- */
934
935 /* hpt_add_dedicated_spare
936  * Version compatibility: v1.0.0.3 or later
937  *   Add a spare disk to an array
938  * Parameters:
939  *  idDisk      disk id
940  *  idArray     array id
941  * Returns:
942  *  0   Success
943  */
944 int hpt_add_dedicated_spare(DEVICEID idDisk, DEVICEID idArray);
945 /*-------------------------------------------------------------------------- */
946
947 /* hpt_remove_spare_disk
948  *   remove a disk from spare pool.
949  * Version compatibility: v1.0.0.1 or later
950  * Parameters:
951  *  idDisk      disk id
952  * Returns:
953  *  0   Success
954  */
955 int hpt_remove_spare_disk(DEVICEID idDisk);
956 /*-------------------------------------------------------------------------- */
957
958 /* hpt_get_event
959  *   Used to poll events from driver.
960  * Version compatibility: v1.0.0.1 or later
961  * Parameters:
962  *   pEvent    pointer to HPT_EVENT structure
963  * Returns:
964  *  0   Success, event info is filled in *pEvent
965  */
966 int hpt_get_event(PHPT_EVENT pEvent);
967 /*-------------------------------------------------------------------------- */
968
969 /* hpt_rebuild_data_block
970  *   Used to copy data from source disk and mirror disk.
971  * Version compatibility: v1.0.0.1 or later
972  * Parameters:
973  *   idArray        Array ID (RAID1, 0/1 or RAID5)
974  *   Lba            Start LBA for each array member
975  *   nSector        Number of sectors for each array member (RAID 5 will ignore this parameter)
976  *
977  * Returns:
978  *  0   Success, event info is filled in *pEvent
979  */
980 int hpt_rebuild_data_block(DEVICEID idMirror, DWORD Lba, UCHAR nSector);
981 #define hpt_rebuild_mirror(p1, p2, p3) hpt_rebuild_data_block(p1, p2, p3)
982
983 #if HPT_INTERFACE_VERSION >= 0x01010000
984 int hpt_rebuild_data_block_v2(DEVICEID idArray, LBA64 Lba, USHORT nSector);
985 #endif
986 /*-------------------------------------------------------------------------- */
987
988 /* hpt_set_array_state
989  *   set array state.
990  * Version compatibility: v1.0.0.1 or later
991  * Parameters:
992  *   idArray        Array ID
993  *   state          See above 'array states' constants, possible values are:
994  *     MIRROR_REBUILD_START
995  *        Indicate that GUI wants to rebuild a mirror array
996  *     MIRROR_REBUILD_ABORT
997  *        GUI wants to abort rebuilding an array
998  *     MIRROR_REBUILD_COMPLETE
999  *        GUI finished to rebuild an array. If rebuild is done by driver this
1000  *        state has no use
1001  *
1002  * Returns:
1003  *  0   Success
1004  */
1005 int hpt_set_array_state(DEVICEID idArray, DWORD state);
1006 /*-------------------------------------------------------------------------- */
1007
1008 /* hpt_set_array_info
1009  *   set array info.
1010  * Version compatibility: v1.0.0.1 or later
1011  * Parameters:
1012  *   idArray        Array ID
1013  *   pInfo          pointer to new info
1014  *
1015  * Returns:
1016  *  0   Success
1017  */
1018 int hpt_set_array_info(DEVICEID idArray, PALTERABLE_ARRAY_INFO pInfo);
1019 /*-------------------------------------------------------------------------- */
1020
1021 /* hpt_set_device_info
1022  *   set device info.
1023  * Version compatibility: v1.0.0.1 or later
1024  * Parameters:
1025  *   idDisk         device ID
1026  *   pInfo          pointer to new info
1027  *
1028  * Returns:
1029  *  0   Success
1030  * Additional notes:
1031  *  If idDisk==0, call to this function will stop buzzer on the adapter
1032  *  (if supported by driver).
1033  */
1034 int hpt_set_device_info(DEVICEID idDisk, PALTERABLE_DEVICE_INFO pInfo);
1035
1036 #if HPT_INTERFACE_VERSION >= 0x01000004
1037 int hpt_set_device_info_v2(DEVICEID idDisk, PALTERABLE_DEVICE_INFO_V2 pInfo);
1038 #endif
1039
1040 /*-------------------------------------------------------------------------- */
1041
1042 /* hpt_rescan_devices
1043  *   rescan devices
1044  * Version compatibility: v1.0.0.1 or later
1045  * Parameters:
1046  *   None
1047  * Returns:
1048  *   0  Success
1049  */
1050 int hpt_rescan_devices();
1051 /*-------------------------------------------------------------------------- */
1052
1053 /* hpt_get_601_info
1054  *   Get HPT601 status
1055  * Version compatibiilty: v1.0.0.3 or later
1056  * Parameters:
1057  *   idDisk - Disk handle
1058  *   PHPT601_INFO - pointer to HPT601 info buffer
1059  * Returns:
1060  *   0  Success
1061  */
1062 int hpt_get_601_info(DEVICEID idDisk, PHPT601_INFO pInfo);
1063 /*-------------------------------------------------------------------------- */
1064
1065 /* hpt_set_601_info
1066  *   HPT601 function control
1067  * Version compatibiilty: v1.0.0.3 or later
1068  * Parameters:
1069  *   idDisk - Disk handle
1070  *   PHPT601_INFO - pointer to HPT601 info buffer
1071  * Returns:
1072  *   0  Success
1073  */
1074 int hpt_set_601_info(DEVICEID idDisk, PHPT601_INFO pInfo);
1075 /*-------------------------------------------------------------------------- */
1076
1077 /* hpt_lock_device
1078  *   Lock a block on a device (prevent OS accessing it)
1079  * Version compatibiilty: v1.0.0.3 or later
1080  * Parameters:
1081  *   idDisk - Disk handle
1082  *   Lba - Start LBA
1083  *   nSectors - number of sectors
1084  * Returns:
1085  *   0  Success
1086  */
1087 int hpt_lock_device(DEVICEID idDisk, ULONG Lba, UCHAR nSectors);
1088
1089 #if HPT_INTERFACE_VERSION >= 0x01010000
1090 int hpt_lock_device_v2(DEVICEID idDisk, LBA64 Lba, USHORT nSectors);
1091 #endif
1092 /*-------------------------------------------------------------------------- */
1093
1094 /* hpt_lock_device
1095  *   Unlock a device
1096  * Version compatibiilty: v1.0.0.3 or later
1097  * Parameters:
1098  *   idDisk - Disk handle
1099  * Returns:
1100  *   0  Success
1101  */
1102 int hpt_unlock_device(DEVICEID idDisk);
1103 /*-------------------------------------------------------------------------- */
1104
1105 /* hpt_ide_pass_through
1106  *  directly access controller's command and control registers.
1107  *  Can only call it on physical devices.
1108  * Version compatibility: v1.0.0.3 or later
1109  * Parameters:
1110  *   p - IDE_PASS_THROUGH header pointer
1111  * Returns:
1112  *   0  Success
1113  */
1114 int hpt_ide_pass_through(PIDE_PASS_THROUGH_HEADER p);
1115 /*-------------------------------------------------------------------------- */
1116
1117 /* hpt_verify_data_block
1118  *   verify data block on RAID1 or RAID5.
1119  * Version compatibility: v1.0.0.3 or later
1120  * Parameters:
1121  *   idArray - Array ID
1122  *   Lba - block number (on each array member, not logical block!)
1123  *   nSectors - Sectors for each member (RAID 5 will ignore this parameter)
1124  * Returns:
1125  *   0  Success
1126  *   1  Data compare error
1127  *   2  I/O error
1128  */
1129 int hpt_verify_data_block(DEVICEID idArray, ULONG Lba, UCHAR nSectors);
1130
1131 #if HPT_INTERFACE_VERSION >= 0x01010000
1132 int hpt_verify_data_block_v2(DEVICEID idArray, LBA64 Lba, USHORT nSectors);
1133 #endif
1134 /*-------------------------------------------------------------------------- */
1135
1136 /* hpt_initialize_data_block
1137  *   initialize data block (fill with zero) on RAID5
1138  * Version compatibility: v1.0.0.3 or later
1139  * Parameters:
1140  *   idArray - Array ID
1141  *   Lba - block number (on each array member, not logical block!)
1142  *   nSectors - Sectors for each member (RAID 5 will ignore this parameter)
1143  * Returns:
1144  *   0  Success
1145  */
1146 int hpt_initialize_data_block(DEVICEID idArray, ULONG Lba, UCHAR nSectors);
1147
1148 #if HPT_INTERFACE_VERSION >= 0x01010000
1149 int hpt_initialize_data_block_v2(DEVICEID idArray, LBA64 Lba, USHORT nSectors);
1150 #endif
1151 /*-------------------------------------------------------------------------- */
1152
1153 /* hpt_device_io_ex
1154  *   extended device I/O function
1155  * Version compatibility: v1.0.0.3 or later
1156  * Parameters:
1157  *   idArray - Array ID
1158  *   Lba - block number (on each array member, not logical block!)
1159  *   nSectors - Sectors for each member
1160  *   buffer - I/O buffer or s/g address
1161  * Returns:
1162  *   0  Success
1163  */
1164 int hpt_device_io_ex(PDEVICE_IO_EX_PARAMS param);
1165 #if HPT_INTERFACE_VERSION >= 0x01010000
1166 int hpt_device_io_ex_v2(void * param); /* NOT IMPLEMENTED */
1167 #endif
1168 /*-------------------------------------------------------------------------- */
1169
1170 /* hpt_set_boot_mark
1171  *   select boot device
1172  * Version compatibility: v1.0.0.3 or later
1173  * Parameters:
1174  *   id - logical device ID. If id is 0 the boot mark will be removed.
1175  * Returns:
1176  *   0  Success
1177  */
1178 int hpt_set_boot_mark(DEVICEID id);
1179 /*-------------------------------------------------------------------------- */
1180
1181 /* hpt_query_remove
1182  *  check if device can be removed safely
1183  * Version compatibility: v1.0.0.4 or later
1184  * Parameters:
1185  *  ndev - number of devices
1186  *  pIds - device ID list
1187  * Returns:
1188  *  0  - Success
1189  *  -1 - unknown error
1190  *  n  - the n-th device that can't be removed
1191  */
1192 int hpt_query_remove(DWORD ndev, DEVICEID *pIds);
1193 /*-------------------------------------------------------------------------- */
1194
1195 /* hpt_remove_devices
1196  *  remove a list of devices
1197  * Version compatibility: v1.0.0.4 or later
1198  * Parameters:
1199  *  ndev - number of devices
1200  *  pIds - device ID list
1201  * Returns:
1202  *  0  - Success
1203  *  -1 - unknown error
1204  *  n  - the n-th device that can't be removed
1205  */
1206 int hpt_remove_devices(DWORD ndev, DEVICEID *pIds);
1207 /*-------------------------------------------------------------------------- */
1208
1209 #endif
1210
1211 #pragma pack()
1212 #endif