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