2 * Copyright (c) 2004-2005 HighPoint Technologies, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * $FreeBSD: src/sys/dev/hptmv/hptintf.h,v 1.4 2009/04/07 16:38:25 delphij Exp $
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
39 * A new version interface should only add ioctl functions; it should implement
40 * all old version functions without change their definition.
42 #define __this_HPT_INTERFACE_VERSION 0x01010000
44 #ifndef HPT_INTERFACE_VERSION
45 #error "You must define HPT_INTERFACE_VERSION you implemented"
48 #if HPT_INTERFACE_VERSION > __this_HPT_INTERFACE_VERSION
49 #error "HPT_INTERFACE_VERSION is invalid"
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.
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.
67 typedef DWORD DEVICEID;
70 * logical device type.
71 * Identify array (logical device) and physical device.
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.
89 * physical device type
92 #define PDT_HARDDISK 1
99 #define MAX_NAME_LENGTH 36
100 #define MAX_ARRAYNAME_LEN 16
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
109 * GUI use these commands to do IO on logical/physical devices.
111 #define IO_COMMAND_READ 1
112 #define IO_COMMAND_WRITE 2
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 */
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 */
140 * array states used by hpt_set_array_state()
143 #define MIRROR_REBUILD_START 1
144 #define MIRROR_REBUILD_ABORT 2
145 #define MIRROR_REBUILD_COMPLETE 3
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 /************************************************************************
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(__DragonFly_version)
166 #define HPT_CTL_CODE(x) (x+0xFF00)
167 #elif defined(_MS_WIN32_) || defined(WIN32)
170 #define CTL_CODE( DeviceType, Function, Method, Access ) \
171 (((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
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)
177 #define HPT_CTL_CODE(x) (x)
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)
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)
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)
235 /************************************************************************
236 * shared data structures
237 ************************************************************************/
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
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
268 typedef struct _DRIVER_CAPABILITIES {
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 */
276 UCHAR SupportDiskModeSetting;
277 UCHAR SupportSparePool;
278 UCHAR MaximumArrayNameLength;
279 /* only one byte left here! */
280 #ifdef __BIG_ENDIAN_BITFIELD
282 UCHAR SupportHotSwap: 1;
283 UCHAR HighPerformanceRAID1: 1;
284 UCHAR RebuildProcessInDriver: 1;
285 UCHAR SupportDedicatedSpare: 1;
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;
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
300 UCHAR SupportedRAIDTypes[16];
301 /* maximum members in an array corresponding to SupportedRAIDTypes */
302 UCHAR MaximumArrayMembers[16];
304 DRIVER_CAPABILITIES, *PDRIVER_CAPABILITIES;
307 * Controller information.
309 typedef struct _CONTROLLER_INFO {
310 UCHAR ChipType; /* chip type */
311 UCHAR InterruptLevel; /* IRQ level */
312 UCHAR NumBuses; /* bus count */
315 UCHAR szProductID[MAX_NAME_LENGTH]; /* product name */
316 UCHAR szVendorID[MAX_NAME_LENGTH]; /* vender name */
318 } CONTROLLER_INFO, *PCONTROLLER_INFO;
321 * Channel information.
323 typedef struct _CHANNEL_INFO {
324 ULONG IoPort; /* IDE Base Port Address */
325 ULONG ControlPort; /* IDE Control Port Address */
327 DEVICEID Devices[2]; /* device connected to this channel */
329 } CHANNEL_INFO, *PCHANNEL_INFO;
332 * time represented in DWORD format
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 */
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 */
354 UCHAR ArrayType; /* array type */
355 UCHAR BlockSizeShift; /* stripe size */
356 UCHAR nDisk; /* member count: Number of ID in Members[] */
359 DWORD Flags; /* working flags, see ARRAY_FLAG_XXX */
360 DWORD Members[MAX_ARRAY_MEMBERS_V1]; /* member array/disks */
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.
369 DWORD RebuildingProgress;
370 DWORD RebuiltSectors; /* rebuilding point (LBA) for single member */
372 } HPT_ARRAY_INFO, *PHPT_ARRAY_INFO; /*LDX modify ARRAY_INFO TO HPT_ARRAY_INFO to avoid compiling error in Windows*/
374 #if HPT_INTERFACE_VERSION>=0x01010000
375 typedef struct _LBA64 {
376 #ifdef __BIG_ENDIAN_BITFIELD
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 */
391 UCHAR ArrayType; /* array type */
392 UCHAR BlockSizeShift; /* stripe size */
393 UCHAR nDisk; /* member count: Number of ID in Members[] */
396 DWORD Flags; /* working flags, see ARRAY_FLAG_XXX */
397 DWORD Members[MAX_ARRAY_MEMBERS_V2]; /* member array/disks */
399 DWORD RebuildingProgress;
400 LBA64 RebuiltSectors; /* rebuilding point (LBA) for single member */
404 } HPT_ARRAY_INFO_V2, *PHPT_ARRAY_INFO_V2;
408 * ATA/ATAPI Device identify data without the Reserved4.
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 */
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;
463 * physical device information.
464 * IdentifyData.ModelNumber[] is byte-swapped from the original identify data.
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 */
475 UCHAR ReadAheadSupported: 1;
476 UCHAR ReadAheadEnabled: 1;
477 UCHAR WriteCacheSupported: 1;
478 UCHAR WriteCacheEnabled: 1;
479 UCHAR TCQSupported: 1;
481 UCHAR NCQSupported: 1;
485 DWORD Flags; /* working flags, see DEVICE_FLAG_XXX */
487 IDENTIFY_DATA2 IdentifyData; /* Identify Data of this device */
489 } DEVICE_INFO, *PDEVICE_INFO;
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
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;
514 * Logical device information.
515 * Union of ArrayInfo and DeviceInfo.
516 * Common properties will be put in logical device information.
518 typedef struct _LOGICAL_DEVICE_INFO {
519 UCHAR Type; /* LDT_ARRAY or LDT_DEVICE */
522 DWORD Capacity; /* array capacity */
523 DEVICEID ParentArray;
526 HPT_ARRAY_INFO array;
530 } LOGICAL_DEVICE_INFO, *PLOGICAL_DEVICE_INFO;
532 #if HPT_INTERFACE_VERSION>=0x01010000
533 typedef struct _LOGICAL_DEVICE_INFO_V2 {
534 UCHAR Type; /* LDT_ARRAY or LDT_DEVICE */
537 LBA64 Capacity; /* array capacity */
538 DEVICEID ParentArray;
541 HPT_ARRAY_INFO_V2 array;
545 } LOGICAL_DEVICE_INFO_V2, *PLOGICAL_DEVICE_INFO_V2;
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.
556 #define AAIF_DESCRIPTION 2
560 #define ADIF_WRITE_CACHE 8
561 #define ADIF_READ_AHEAD 0x10
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 */
568 ALTERABLE_ARRAY_INFO, *PALTERABLE_ARRAY_INFO;
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 */
574 ALTERABLE_DEVICE_INFO, *PALTERABLE_DEVICE_INFO;
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 */
581 UCHAR WriteCacheEnabled;
582 UCHAR ReadAheadEnabled;
584 ULONG reserve2[13]; /* pad to 64 bytes */
586 ALTERABLE_DEVICE_INFO_V2, *PALTERABLE_DEVICE_INFO_V2;
589 * CREATE_ARRAY_PARAMS
590 * Param structure used to create an array.
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 */
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 */
603 DWORD Members[MAX_ARRAY_MEMBERS_V1];/* ID of array members, a member can be an array */
605 } CREATE_ARRAY_PARAMS, *PCREATE_ARRAY_PARAMS;
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 */
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) */
620 DWORD Members[MAX_ARRAY_MEMBERS_V2];/* ID of array members, a member can be an array */
622 } CREATE_ARRAY_PARAMS_V2, *PCREATE_ARRAY_PARAMS_V2;
626 * Flags used for creating an RAID 1 array
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.
637 #define CAF_CREATE_AND_DUPLICATE 1
638 #define CAF_DUPLICATE_MUST_DONE 2
639 #define CAF_CREATE_AS_RAID15 4
641 * Flags used for creating an RAID 5 array
643 #define CAF_CREATE_R5_NO_BUILD 1
644 #define CAF_CREATE_R5_ZERO_INIT 2
645 #define CAF_CREATE_R5_BUILD_PARITY 4
648 * Flags used for deleting an array
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 ).
655 #define DAF_KEEP_DATA_IF_POSSIBLE 1
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
681 typedef struct _HPT_EVENT {
687 UCHAR Data[32]; /* various data depend on EventType */
688 } HPT_EVENT, *PHPT_EVENT;
691 * IDE pass-through command. Use it at your own risk!
694 #pragma warning(disable:4200)
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 */
708 #define IDE_PASS_THROUGH_buffer(p) ((unsigned char *)(p) + sizeof(IDE_PASS_THROUGH_HEADER))
710 IDE_PASS_THROUGH_HEADER, *PIDE_PASS_THROUGH_HEADER;
713 * device io packet format
715 typedef struct _DEVICE_IO_EX_PARAMS {
719 UCHAR Command; /* IO_COMMAD_xxx */
720 UCHAR BufferType; /* BUFFER_TYPE_xxx, see below */
723 DEVICE_IO_EX_PARAMS, *PDEVICE_IO_EX_PARAMS;
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 */
734 * all ioctl functions should use far pointers. It's not a problem on
735 * 32bit platforms, however, BIOS needs care.
741 #define HPT_IOCTL_MAGIC32 0x1A2B3C4D
742 #define HPT_IOCTL_MAGIC 0xA1B2C3D4
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 */
753 HPT_IOCTL_PARAM, *PHPT_IOCTL_PARAM;
755 /* for 32-bit app running on 64-bit system */
756 typedef struct _HPT_IOCTL_PARAM32 {
758 DWORD dwIoControlCode;
762 DWORD nOutBufferSize;
763 DWORD lpBytesReturned;
765 HPT_IOCTL_PARAM32, *PHPT_IOCTL_PARAM32;
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.
780 /************************************************************************
781 * User mode functions
782 ************************************************************************/
786 * Version compatibility: all versions
790 * interface version. 0 when fail.
792 DWORD hpt_get_version();
794 /*-------------------------------------------------------------------------- */
797 * hpt_get_driver_capabilities
798 * Version compatibility: v1.0.0.2 or later
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.
806 int hpt_get_driver_capabilities(PDRIVER_CAPABILITIES cap);
808 /*-------------------------------------------------------------------------- */
811 * hpt_get_controller_count
812 * Version compatibility: v1.0.0.1 or later
816 * number of controllers
818 int hpt_get_controller_count();
820 /*-------------------------------------------------------------------------- */
822 /* hpt_get_controller_info
823 * Version compatibility: v1.0.0.1 or later
826 * pInfo pointer to CONTROLLER_INFO buffer
828 * 0 Success, controller info is put into (*pInfo ).
830 int hpt_get_controller_info(int id, PCONTROLLER_INFO pInfo);
832 /*-------------------------------------------------------------------------- */
834 /* hpt_get_channel_info
835 * Version compatibility: v1.0.0.1 or later
839 * pInfo pointer to CHANNEL_INFO buffer
841 * 0 Success, channel info is put into (*pInfo ).
843 int hpt_get_channel_info(int id, int bus, PCHANNEL_INFO pInfo);
845 /*-------------------------------------------------------------------------- */
847 /* hpt_get_logical_devices
848 * Version compatibility: v1.0.0.1 or later
850 * pIds pointer to a DEVICEID array
851 * nMaxCount array size
853 * Number of ID returned. All logical device IDs are put into pIds array.
854 * Note: A spare disk is not a logical device.
856 int hpt_get_logical_devices(DEVICEID * pIds, int nMaxCount);
858 /*-------------------------------------------------------------------------- */
860 /* hpt_get_device_info
861 * Version compatibility: v1.0.0.1 or later
863 * id logical device id
864 * pInfo pointer to HPT_ARRAY_INFO structure
868 int hpt_get_device_info(DEVICEID id, PLOGICAL_DEVICE_INFO pInfo);
870 #if HPT_INTERFACE_VERSION>=0x01010000
871 int hpt_get_device_info_v2(DEVICEID id, PLOGICAL_DEVICE_INFO_V2 pInfo);
874 /*-------------------------------------------------------------------------- */
877 * Version compatibility: v1.0.0.1 or later
879 * pParam pointer to CREATE_ARRAY_PARAMS structure
882 * else return array id
884 DEVICEID hpt_create_array(PCREATE_ARRAY_PARAMS pParam);
886 #if HPT_INTERFACE_VERSION>=0x01010000
887 DEVICEID hpt_create_array_v2(PCREATE_ARRAY_PARAMS_V2 pParam);
890 /*-------------------------------------------------------------------------- */
893 * Version compatibility: v1.0.0.1 or later
899 int hpt_delete_array(DEVICEID id, DWORD options);
901 /*-------------------------------------------------------------------------- */
904 * Read/write data on array and physcal device.
905 * Version compatibility: v1.0.0.1 or later
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
915 int hpt_device_io(DEVICEID id, int cmd, ULONG lba, DWORD nSector, LPVOID buffer);
917 #if HPT_INTERFACE_VERSION >= 0x01010000
918 int hpt_device_io_v2(DEVICEID id, int cmd, LBA64 lba, DWORD nSector, LPVOID buffer);
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
931 int hpt_add_disk_to_array(DEVICEID idArray, DEVICEID idDisk);
932 /*-------------------------------------------------------------------------- */
934 /* hpt_add_spare_disk
935 * Version compatibility: v1.0.0.1 or later
936 * Add a disk to spare pool.
942 int hpt_add_spare_disk(DEVICEID idDisk);
943 /*-------------------------------------------------------------------------- */
945 /* hpt_add_dedicated_spare
946 * Version compatibility: v1.0.0.3 or later
947 * Add a spare disk to an array
954 int hpt_add_dedicated_spare(DEVICEID idDisk, DEVICEID idArray);
955 /*-------------------------------------------------------------------------- */
957 /* hpt_remove_spare_disk
958 * remove a disk from spare pool.
959 * Version compatibility: v1.0.0.1 or later
965 int hpt_remove_spare_disk(DEVICEID idDisk);
966 /*-------------------------------------------------------------------------- */
969 * Used to poll events from driver.
970 * Version compatibility: v1.0.0.1 or later
972 * pEvent pointer to HPT_EVENT structure
974 * 0 Success, event info is filled in *pEvent
976 int hpt_get_event(PHPT_EVENT pEvent);
977 /*-------------------------------------------------------------------------- */
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
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)
988 * 0 Success, event info is filled in *pEvent
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)
993 #if HPT_INTERFACE_VERSION >= 0x01010000
994 int hpt_rebuild_data_block_v2(DEVICEID idArray, LBA64 Lba, USHORT nSector);
996 /*-------------------------------------------------------------------------- */
998 /* hpt_set_array_state
1000 * Version compatibility: v1.0.0.1 or later
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
1015 int hpt_set_array_state(DEVICEID idArray, DWORD state);
1016 /*-------------------------------------------------------------------------- */
1018 /* hpt_set_array_info
1020 * Version compatibility: v1.0.0.1 or later
1023 * pInfo pointer to new info
1028 int hpt_set_array_info(DEVICEID idArray, PALTERABLE_ARRAY_INFO pInfo);
1029 /*-------------------------------------------------------------------------- */
1031 /* hpt_set_device_info
1033 * Version compatibility: v1.0.0.1 or later
1036 * pInfo pointer to new info
1041 * If idDisk==0, call to this function will stop buzzer on the adapter
1042 * (if supported by driver).
1044 int hpt_set_device_info(DEVICEID idDisk, PALTERABLE_DEVICE_INFO pInfo);
1046 #if HPT_INTERFACE_VERSION >= 0x01000004
1047 int hpt_set_device_info_v2(DEVICEID idDisk, PALTERABLE_DEVICE_INFO_V2 pInfo);
1050 /*-------------------------------------------------------------------------- */
1052 /* hpt_rescan_devices
1054 * Version compatibility: v1.0.0.1 or later
1060 int hpt_rescan_devices();
1061 /*-------------------------------------------------------------------------- */
1065 * Version compatibiilty: v1.0.0.3 or later
1067 * idDisk - Disk handle
1068 * PHPT601_INFO - pointer to HPT601 info buffer
1072 int hpt_get_601_info(DEVICEID idDisk, PHPT601_INFO pInfo);
1073 /*-------------------------------------------------------------------------- */
1076 * HPT601 function control
1077 * Version compatibiilty: v1.0.0.3 or later
1079 * idDisk - Disk handle
1080 * PHPT601_INFO - pointer to HPT601 info buffer
1084 int hpt_set_601_info(DEVICEID idDisk, PHPT601_INFO pInfo);
1085 /*-------------------------------------------------------------------------- */
1088 * Lock a block on a device (prevent OS accessing it)
1089 * Version compatibiilty: v1.0.0.3 or later
1091 * idDisk - Disk handle
1093 * nSectors - number of sectors
1097 int hpt_lock_device(DEVICEID idDisk, ULONG Lba, UCHAR nSectors);
1099 #if HPT_INTERFACE_VERSION >= 0x01010000
1100 int hpt_lock_device_v2(DEVICEID idDisk, LBA64 Lba, USHORT nSectors);
1102 /*-------------------------------------------------------------------------- */
1106 * Version compatibiilty: v1.0.0.3 or later
1108 * idDisk - Disk handle
1112 int hpt_unlock_device(DEVICEID idDisk);
1113 /*-------------------------------------------------------------------------- */
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
1120 * p - IDE_PASS_THROUGH header pointer
1124 int hpt_ide_pass_through(PIDE_PASS_THROUGH_HEADER p);
1125 /*-------------------------------------------------------------------------- */
1127 /* hpt_verify_data_block
1128 * verify data block on RAID1 or RAID5.
1129 * Version compatibility: v1.0.0.3 or later
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)
1136 * 1 Data compare error
1139 int hpt_verify_data_block(DEVICEID idArray, ULONG Lba, UCHAR nSectors);
1141 #if HPT_INTERFACE_VERSION >= 0x01010000
1142 int hpt_verify_data_block_v2(DEVICEID idArray, LBA64 Lba, USHORT nSectors);
1144 /*-------------------------------------------------------------------------- */
1146 /* hpt_initialize_data_block
1147 * initialize data block (fill with zero) on RAID5
1148 * Version compatibility: v1.0.0.3 or later
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)
1156 int hpt_initialize_data_block(DEVICEID idArray, ULONG Lba, UCHAR nSectors);
1158 #if HPT_INTERFACE_VERSION >= 0x01010000
1159 int hpt_initialize_data_block_v2(DEVICEID idArray, LBA64 Lba, USHORT nSectors);
1161 /*-------------------------------------------------------------------------- */
1164 * extended device I/O function
1165 * Version compatibility: v1.0.0.3 or later
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
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 */
1178 /*-------------------------------------------------------------------------- */
1180 /* hpt_set_boot_mark
1181 * select boot device
1182 * Version compatibility: v1.0.0.3 or later
1184 * id - logical device ID. If id is 0 the boot mark will be removed.
1188 int hpt_set_boot_mark(DEVICEID id);
1189 /*-------------------------------------------------------------------------- */
1192 * check if device can be removed safely
1193 * Version compatibility: v1.0.0.4 or later
1195 * ndev - number of devices
1196 * pIds - device ID list
1199 * -1 - unknown error
1200 * n - the n-th device that can't be removed
1202 int hpt_query_remove(DWORD ndev, DEVICEID *pIds);
1203 /*-------------------------------------------------------------------------- */
1205 /* hpt_remove_devices
1206 * remove a list of devices
1207 * Version compatibility: v1.0.0.4 or later
1209 * ndev - number of devices
1210 * pIds - device ID list
1213 * -1 - unknown error
1214 * n - the n-th device that can't be removed
1216 int hpt_remove_devices(DWORD ndev, DEVICEID *pIds);
1217 /*-------------------------------------------------------------------------- */
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
1224 * p - IDE_PASS_THROUGH header pointer
1228 int hpt_ide_pass_through(PIDE_PASS_THROUGH_HEADER p);
1229 /*-------------------------------------------------------------------------- */