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