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