xref: /freebsd/sys/dev/hptmv/hptintf.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1718cf2ccSPedro F. Giffuni /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3718cf2ccSPedro F. Giffuni  *
4d2bd3ab9SScott Long  * Copyright (c) 2004-2005 HighPoint Technologies, Inc.
51713e81bSScott Long  * All rights reserved.
61713e81bSScott Long  *
71713e81bSScott Long  * Redistribution and use in source and binary forms, with or without
81713e81bSScott Long  * modification, are permitted provided that the following conditions
91713e81bSScott Long  * are met:
101713e81bSScott Long  * 1. Redistributions of source code must retain the above copyright
111713e81bSScott Long  *    notice, this list of conditions and the following disclaimer.
121713e81bSScott Long  * 2. Redistributions in binary form must reproduce the above copyright
131713e81bSScott Long  *    notice, this list of conditions and the following disclaimer in the
141713e81bSScott Long  *    documentation and/or other materials provided with the distribution.
151713e81bSScott Long  *
161713e81bSScott Long  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
171713e81bSScott Long  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
181713e81bSScott Long  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
191713e81bSScott Long  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
201713e81bSScott Long  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
211713e81bSScott Long  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
221713e81bSScott Long  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
231713e81bSScott Long  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
241713e81bSScott Long  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
251713e81bSScott Long  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
261713e81bSScott Long  * SUCH DAMAGE.
271713e81bSScott Long  */
281713e81bSScott Long 
291713e81bSScott Long #ifndef HPT_INTF_H
301713e81bSScott Long #define HPT_INTF_H
311713e81bSScott Long #pragma pack(1)
321713e81bSScott Long 
331713e81bSScott Long /*
341713e81bSScott Long  * Version of this interface.
351713e81bSScott Long  * The user mode application must first issue a hpt_get_version() call to
361713e81bSScott Long  * check HPT_INTERFACE_VERSION. When an utility using newer version interface
371713e81bSScott Long  * is used with old version drivers, it must call only the functions that
381713e81bSScott Long  * driver supported.
391713e81bSScott Long  * A new version interface should only add ioctl functions; it should implement
401713e81bSScott Long  * all old version functions without change their definition.
411713e81bSScott Long  */
421713e81bSScott Long #define __this_HPT_INTERFACE_VERSION 0x01010000
431713e81bSScott Long 
441713e81bSScott Long #ifndef HPT_INTERFACE_VERSION
451713e81bSScott Long #error "You must define HPT_INTERFACE_VERSION you implemented"
461713e81bSScott Long #endif
471713e81bSScott Long 
481713e81bSScott Long #if HPT_INTERFACE_VERSION > __this_HPT_INTERFACE_VERSION
491713e81bSScott Long #error "HPT_INTERFACE_VERSION is invalid"
501713e81bSScott Long #endif
511713e81bSScott Long 
521713e81bSScott Long /*
531713e81bSScott Long  * DEFINITION
541713e81bSScott Long  *   Logical device  --- a device that can be accessed by OS.
551713e81bSScott Long  *   Physical device --- device attached to the controller.
561713e81bSScott Long  *  A logical device can be simply a physical device.
571713e81bSScott Long  *
581713e81bSScott Long  * Each logical and physical device has a 32bit ID. GUI will use this ID
591713e81bSScott Long  * to identify devices.
601713e81bSScott Long  *   1. The ID must be unique.
611713e81bSScott Long  *   2. The ID must be immutable. Once an ID is assigned to a device, it
621713e81bSScott Long  * must not change when system is running and the device exists.
631713e81bSScott Long  *   3. The ID of logical device must be NOT reusable. If a device is
641713e81bSScott Long  * removed, other newly created logical device must not use the same ID.
651713e81bSScott Long  *   4. The ID must not be zero or 0xFFFFFFFF.
661713e81bSScott Long  */
671713e81bSScott Long typedef DWORD DEVICEID;
681713e81bSScott Long 
691713e81bSScott Long /*
701713e81bSScott Long  * logical device type.
711713e81bSScott Long  * Identify array (logical device) and physical device.
721713e81bSScott Long  */
731713e81bSScott Long #define LDT_ARRAY   1
741713e81bSScott Long #define LDT_DEVICE  2
751713e81bSScott Long 
761713e81bSScott Long /*
771713e81bSScott Long  * Array types
781713e81bSScott Long  * GUI will treat all array as 1-level RAID. No RAID0/1 or RAID1/0.
791713e81bSScott Long  * A RAID0/1 device is type AT_RAID1. A RAID1/0 device is type AT_RAID0.
801713e81bSScott Long  * Their members may be another array of type RAID0 or RAID1.
811713e81bSScott Long  */
821713e81bSScott Long #define AT_UNKNOWN  0
831713e81bSScott Long #define AT_RAID0    1
841713e81bSScott Long #define AT_RAID1    2
851713e81bSScott Long #define AT_RAID5    3
861713e81bSScott Long #define AT_JBOD     7
871713e81bSScott Long 
881713e81bSScott Long /*
891713e81bSScott Long  * physical device type
901713e81bSScott Long  */
911713e81bSScott Long #define PDT_UNKNOWN     0
921713e81bSScott Long #define PDT_HARDDISK    1
931713e81bSScott Long #define PDT_CDROM       2
941713e81bSScott Long #define PDT_TAPE        3
951713e81bSScott Long 
961713e81bSScott Long /*
971713e81bSScott Long  * Some constants.
981713e81bSScott Long  */
991713e81bSScott Long #define MAX_NAME_LENGTH     36
1001713e81bSScott Long #define MAX_ARRAYNAME_LEN   16
1011713e81bSScott Long 
1021713e81bSScott Long #define MAX_ARRAY_MEMBERS_V1 8
1031713e81bSScott Long #define MAX_ARRAY_MEMBERS_V2 16
104453130d9SPedro F. Giffuni /* keep definition for source code compatibility */
1051713e81bSScott Long #define MAX_ARRAY_MEMBERS MAX_ARRAY_MEMBERS_V1
1061713e81bSScott Long 
1071713e81bSScott Long /*
1081713e81bSScott Long  * io commands
1091713e81bSScott Long  * GUI use these commands to do IO on logical/physical devices.
1101713e81bSScott Long  */
1111713e81bSScott Long #define IO_COMMAND_READ     1
1121713e81bSScott Long #define IO_COMMAND_WRITE    2
1131713e81bSScott Long 
1141713e81bSScott Long /*
1151713e81bSScott Long  * array flags
1161713e81bSScott Long  */
1171713e81bSScott Long #define ARRAY_FLAG_DISABLED         0x00000001 /* The array is disabled */
1181713e81bSScott Long #define ARRAY_FLAG_NEEDBUILDING     0x00000002 /* array need synchronizing */
1191713e81bSScott Long #define ARRAY_FLAG_REBUILDING       0x00000004 /* array is in rebuilding process */
1201713e81bSScott Long #define ARRAY_FLAG_BROKEN           0x00000008 /* broken but may still working */
1211713e81bSScott Long #define ARRAY_FLAG_BOOTDISK         0x00000010 /* array has a active partition */
1221713e81bSScott Long #define ARRAY_FLAG_NEWLY_CREATED    0x00000020 /* a newly created array */
1231713e81bSScott Long #define ARRAY_FLAG_BOOTMARK         0x00000040 /* array has boot mark set */
1241713e81bSScott Long #define ARRAY_FLAG_NEED_AUTOREBUILD 0x00000080 /* auto-rebuild should start */
1251713e81bSScott Long #define ARRAY_FLAG_VERIFYING        0x00000100 /* is being verified */
1261713e81bSScott Long #define ARRAY_FLAG_INITIALIZING     0x00000200 /* is being initialized */
1271713e81bSScott Long #define ARRAY_FLAG_RAID15PLUS       0x80000000 /* display this RAID 1 as RAID 1.5 */
1281713e81bSScott Long 
1291713e81bSScott Long /*
1301713e81bSScott Long  * device flags
1311713e81bSScott Long  */
1321713e81bSScott Long #define DEVICE_FLAG_DISABLED        0x00000001 /* device is disabled */
1331713e81bSScott Long #define DEVICE_FLAG_BOOTDISK        0x00000002 /* disk has a active partition */
1341713e81bSScott Long #define DEVICE_FLAG_BOOTMARK        0x00000004 /* disk has boot mark set */
1351713e81bSScott Long #define DEVICE_FLAG_WITH_601        0x00000008 /* has HPT601 connected */
1361713e81bSScott Long #define DEVICE_FLAG_SATA            0x00000010 /* S-ATA device */
1371713e81bSScott Long #define DEVICE_FLAG_IS_SPARE        0x80000000 /* is a spare disk */
1381713e81bSScott Long 
1391713e81bSScott Long /*
1401713e81bSScott Long  * array states used by hpt_set_array_state()
1411713e81bSScott Long  */
1421713e81bSScott Long /* old defines */
1431713e81bSScott Long #define MIRROR_REBUILD_START    1
1441713e81bSScott Long #define MIRROR_REBUILD_ABORT    2
1451713e81bSScott Long #define MIRROR_REBUILD_COMPLETE 3
1461713e81bSScott Long /* new defines */
1471713e81bSScott Long #define AS_REBUILD_START 1
1481713e81bSScott Long #define AS_REBUILD_ABORT 2
1491713e81bSScott Long #define AS_REBUILD_PAUSE AS_REBUILD_ABORT
1501713e81bSScott Long #define AS_REBUILD_COMPLETE 3
1511713e81bSScott Long #define AS_VERIFY_START 4
1521713e81bSScott Long #define AS_VERIFY_ABORT 5
1531713e81bSScott Long #define AS_VERIFY_COMPLETE 6
1541713e81bSScott Long #define AS_INITIALIZE_START 7
1551713e81bSScott Long #define AS_INITIALIZE_ABORT 8
1561713e81bSScott Long #define AS_INITIALIZE_COMPLETE 9
1571713e81bSScott Long #define AS_VERIFY_FAILED 10
1581713e81bSScott Long #define AS_REBUILD_STOP 11
1591713e81bSScott Long #define AS_SAVE_STATE	12
1601713e81bSScott Long /************************************************************************
1611713e81bSScott Long  * ioctl code
1621713e81bSScott Long  * It would be better if ioctl code are the same on different platforms,
1631713e81bSScott Long  * but we must not conflict with system defined ioctl code.
1641713e81bSScott Long  ************************************************************************/
16564470755SXin LI #if defined(LINUX) || defined(__FreeBSD_version)
1661713e81bSScott Long #define HPT_CTL_CODE(x) (x+0xFF00)
1671713e81bSScott Long #elif defined(_MS_WIN32_) || defined(WIN32)
1681713e81bSScott Long 
1691713e81bSScott Long #ifndef CTL_CODE
1701713e81bSScott Long #define CTL_CODE( DeviceType, Function, Method, Access ) \
1711713e81bSScott Long 			(((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
1721713e81bSScott Long #endif
1731713e81bSScott Long #define HPT_CTL_CODE(x) CTL_CODE(0x370, 0x900+(x), 0, 0)
1741713e81bSScott Long #define HPT_CTL_CODE_WIN32_TO_I960(x) ((((x) & 0xffff)>>2)-0x900)
1751713e81bSScott Long 
1761713e81bSScott Long #else
1771713e81bSScott Long #define HPT_CTL_CODE(x) (x)
1781713e81bSScott Long #endif
1791713e81bSScott Long 
1801713e81bSScott Long #define HPT_IOCTL_GET_VERSION               HPT_CTL_CODE(0)
1811713e81bSScott Long #define HPT_IOCTL_GET_CONTROLLER_COUNT      HPT_CTL_CODE(1)
1821713e81bSScott Long #define HPT_IOCTL_GET_CONTROLLER_INFO       HPT_CTL_CODE(2)
1831713e81bSScott Long #define HPT_IOCTL_GET_CHANNEL_INFO          HPT_CTL_CODE(3)
1841713e81bSScott Long #define HPT_IOCTL_GET_LOGICAL_DEVICES       HPT_CTL_CODE(4)
1851713e81bSScott Long #define HPT_IOCTL_GET_DEVICE_INFO           HPT_CTL_CODE(5)
1861713e81bSScott Long #define HPT_IOCTL_CREATE_ARRAY              HPT_CTL_CODE(6)
1871713e81bSScott Long #define HPT_IOCTL_DELETE_ARRAY              HPT_CTL_CODE(7)
1881713e81bSScott Long #define HPT_IOCTL_ARRAY_IO                  HPT_CTL_CODE(8)
1891713e81bSScott Long #define HPT_IOCTL_DEVICE_IO                 HPT_CTL_CODE(9)
1901713e81bSScott Long #define HPT_IOCTL_GET_EVENT                 HPT_CTL_CODE(10)
1911713e81bSScott Long #define HPT_IOCTL_REBUILD_MIRROR            HPT_CTL_CODE(11)
1921713e81bSScott Long /* use HPT_IOCTL_REBUILD_DATA_BLOCK from now on */
1931713e81bSScott Long #define HPT_IOCTL_REBUILD_DATA_BLOCK HPT_IOCTL_REBUILD_MIRROR
1941713e81bSScott Long #define HPT_IOCTL_ADD_SPARE_DISK            HPT_CTL_CODE(12)
1951713e81bSScott Long #define HPT_IOCTL_REMOVE_SPARE_DISK         HPT_CTL_CODE(13)
1961713e81bSScott Long #define HPT_IOCTL_ADD_DISK_TO_ARRAY         HPT_CTL_CODE(14)
1971713e81bSScott Long #define HPT_IOCTL_SET_ARRAY_STATE           HPT_CTL_CODE(15)
1981713e81bSScott Long #define HPT_IOCTL_SET_ARRAY_INFO            HPT_CTL_CODE(16)
1991713e81bSScott Long #define HPT_IOCTL_SET_DEVICE_INFO           HPT_CTL_CODE(17)
2001713e81bSScott Long #define HPT_IOCTL_RESCAN_DEVICES            HPT_CTL_CODE(18)
2011713e81bSScott Long #define HPT_IOCTL_GET_DRIVER_CAPABILITIES   HPT_CTL_CODE(19)
2021713e81bSScott Long #define HPT_IOCTL_GET_601_INFO              HPT_CTL_CODE(20)
2031713e81bSScott Long #define HPT_IOCTL_SET_601_INFO              HPT_CTL_CODE(21)
2041713e81bSScott Long #define HPT_IOCTL_LOCK_DEVICE               HPT_CTL_CODE(22)
2051713e81bSScott Long #define HPT_IOCTL_UNLOCK_DEVICE             HPT_CTL_CODE(23)
2061713e81bSScott Long #define HPT_IOCTL_IDE_PASS_THROUGH          HPT_CTL_CODE(24)
2071713e81bSScott Long #define HPT_IOCTL_VERIFY_DATA_BLOCK         HPT_CTL_CODE(25)
2081713e81bSScott Long #define HPT_IOCTL_INITIALIZE_DATA_BLOCK     HPT_CTL_CODE(26)
2091713e81bSScott Long #define HPT_IOCTL_ADD_DEDICATED_SPARE       HPT_CTL_CODE(27)
2101713e81bSScott Long #define HPT_IOCTL_DEVICE_IO_EX              HPT_CTL_CODE(28)
2111713e81bSScott Long #define HPT_IOCTL_SET_BOOT_MARK             HPT_CTL_CODE(29)
2121713e81bSScott Long #define HPT_IOCTL_QUERY_REMOVE              HPT_CTL_CODE(30)
2131713e81bSScott Long #define HPT_IOCTL_REMOVE_DEVICES            HPT_CTL_CODE(31)
2141713e81bSScott Long #define HPT_IOCTL_CREATE_ARRAY_V2           HPT_CTL_CODE(32)
2151713e81bSScott Long #define HPT_IOCTL_GET_DEVICE_INFO_V2        HPT_CTL_CODE(33)
2161713e81bSScott Long #define HPT_IOCTL_SET_DEVICE_INFO_V2        HPT_CTL_CODE(34)
2171713e81bSScott Long #define HPT_IOCTL_REBUILD_DATA_BLOCK_V2     HPT_CTL_CODE(35)
2181713e81bSScott Long #define HPT_IOCTL_VERIFY_DATA_BLOCK_V2      HPT_CTL_CODE(36)
2191713e81bSScott Long #define HPT_IOCTL_INITIALIZE_DATA_BLOCK_V2  HPT_CTL_CODE(37)
2201713e81bSScott Long #define HPT_IOCTL_LOCK_DEVICE_V2            HPT_CTL_CODE(38)
2211713e81bSScott Long #define HPT_IOCTL_DEVICE_IO_V2              HPT_CTL_CODE(39)
2221713e81bSScott Long #define HPT_IOCTL_DEVICE_IO_EX_V2           HPT_CTL_CODE(40)
2231713e81bSScott Long 
22464470755SXin LI #define HPT_IOCTL_I2C_TRANSACTION           HPT_CTL_CODE(48)
22564470755SXin LI #define HPT_IOCTL_GET_PARAMETER_LIST        HPT_CTL_CODE(49)
22664470755SXin LI #define HPT_IOCTL_GET_PARAMETER             HPT_CTL_CODE(50)
22764470755SXin LI #define HPT_IOCTL_SET_PARAMETER             HPT_CTL_CODE(51)
22864470755SXin LI 
2291713e81bSScott Long /* Windows only */
2301713e81bSScott Long #define HPT_IOCTL_GET_CONTROLLER_IDS        HPT_CTL_CODE(100)
2311713e81bSScott Long #define HPT_IOCTL_GET_DCB                   HPT_CTL_CODE(101)
2321713e81bSScott Long #define	HPT_IOCTL_EPROM_IO                  HPT_CTL_CODE(102)
2331713e81bSScott Long #define	HPT_IOCTL_GET_CONTROLLER_VENID      HPT_CTL_CODE(103)
2341713e81bSScott Long 
2351713e81bSScott Long /************************************************************************
2361713e81bSScott Long  * shared data structures
2371713e81bSScott Long  ************************************************************************/
2381713e81bSScott Long 
2391713e81bSScott Long /*
2401713e81bSScott Long  * Chip Type
2411713e81bSScott Long  */
2421713e81bSScott Long #define CHIP_TYPE_HPT366      1
2431713e81bSScott Long #define CHIP_TYPE_HPT368      2
2441713e81bSScott Long #define CHIP_TYPE_HPT370      3
2451713e81bSScott Long #define CHIP_TYPE_HPT370A     4
2461713e81bSScott Long #define CHIP_TYPE_HPT370B     5
2471713e81bSScott Long #define CHIP_TYPE_HPT374      6
2481713e81bSScott Long #define CHIP_TYPE_HPT372      7
2491713e81bSScott Long #define CHIP_TYPE_HPT372A     8
2501713e81bSScott Long #define CHIP_TYPE_HPT302      9
2511713e81bSScott Long #define CHIP_TYPE_HPT371      10
2521713e81bSScott Long #define CHIP_TYPE_HPT372N     11
2531713e81bSScott Long #define CHIP_TYPE_HPT302N     12
2541713e81bSScott Long #define CHIP_TYPE_HPT371N     13
2551713e81bSScott Long #define CHIP_TYPE_SI3112A     14
2561713e81bSScott Long #define CHIP_TYPE_ICH5        15
2571713e81bSScott Long #define CHIP_TYPE_ICH5R       16
2581713e81bSScott Long 
2591713e81bSScott Long /*
2601713e81bSScott Long  * Chip Flags
2611713e81bSScott Long  */
2621713e81bSScott Long #define CHIP_SUPPORT_ULTRA_66   0x20
2631713e81bSScott Long #define CHIP_SUPPORT_ULTRA_100  0x40
2641713e81bSScott Long #define CHIP_HPT3XX_DPLL_MODE   0x80
2651713e81bSScott Long #define CHIP_SUPPORT_ULTRA_133  0x01
2661713e81bSScott Long #define CHIP_SUPPORT_ULTRA_150  0x02
2671713e81bSScott Long 
2681713e81bSScott Long typedef struct _DRIVER_CAPABILITIES {
2691713e81bSScott Long 	DWORD dwSize;
2701713e81bSScott Long 
2711713e81bSScott Long 	UCHAR MaximumControllers;           /* maximum controllers the driver can support */
2721713e81bSScott Long 	UCHAR SupportCrossControllerRAID;   /* 1-support, 0-not support */
2731713e81bSScott Long 	UCHAR MinimumBlockSizeShift;        /* minimum block size shift */
2741713e81bSScott Long 	UCHAR MaximumBlockSizeShift;        /* maximum block size shift */
2751713e81bSScott Long 
2761713e81bSScott Long 	UCHAR SupportDiskModeSetting;
2771713e81bSScott Long 	UCHAR SupportSparePool;
2781713e81bSScott Long 	UCHAR MaximumArrayNameLength;
2791713e81bSScott Long 	/* only one byte left here! */
2801713e81bSScott Long #ifdef __BIG_ENDIAN_BITFIELD
2811713e81bSScott Long 	UCHAR reserved: 4;
2821713e81bSScott Long 	UCHAR SupportHotSwap: 1;
2831713e81bSScott Long 	UCHAR HighPerformanceRAID1: 1;
2841713e81bSScott Long 	UCHAR RebuildProcessInDriver: 1;
2851713e81bSScott Long 	UCHAR SupportDedicatedSpare: 1;
2861713e81bSScott Long #else
2871713e81bSScott Long 	UCHAR SupportDedicatedSpare: 1; /* call hpt_add_dedicated_spare() for dedicated spare. */
2881713e81bSScott Long 	UCHAR RebuildProcessInDriver: 1; /* Windows only. used by mid layer for rebuild control. */
2891713e81bSScott Long 	UCHAR HighPerformanceRAID1: 1; /* Support RAID1.5 */
2901713e81bSScott Long 	UCHAR SupportHotSwap: 1;
2911713e81bSScott Long 	UCHAR reserved: 4;
2921713e81bSScott Long #endif
2931713e81bSScott Long 
2941713e81bSScott Long 	/* SupportedRAIDTypes is an array of bytes, one of each is an array type.
2951713e81bSScott Long 	 * Only non-zero values is valid. Bit0-3 represents the lower(child) level RAID type;
2961713e81bSScott Long 	 * bit4-7 represents the top level. i.e.
2971713e81bSScott Long 	 *     RAID 0/1 is (AT_RAID1<<4) | AT_RAID0
2981713e81bSScott Long 	 *     RAID 5/0 is (AT_RAID0<<4) | AT_RAID5
2991713e81bSScott Long 	 */
3001713e81bSScott Long 	UCHAR SupportedRAIDTypes[16];
3011713e81bSScott Long 	/* maximum members in an array corresponding to SupportedRAIDTypes */
3021713e81bSScott Long 	UCHAR MaximumArrayMembers[16];
3031713e81bSScott Long }
3041713e81bSScott Long DRIVER_CAPABILITIES, *PDRIVER_CAPABILITIES;
3051713e81bSScott Long 
3061713e81bSScott Long /*
3071713e81bSScott Long  * Controller information.
3081713e81bSScott Long  */
3091713e81bSScott Long typedef struct _CONTROLLER_INFO {
3101713e81bSScott Long 	UCHAR ChipType;                     /* chip type */
3111713e81bSScott Long 	UCHAR InterruptLevel;               /* IRQ level */
3121713e81bSScott Long 	UCHAR NumBuses;                     /* bus count */
3131713e81bSScott Long 	UCHAR ChipFlags;
3141713e81bSScott Long 
3151713e81bSScott Long 	UCHAR szProductID[MAX_NAME_LENGTH]; /* product name */
3161713e81bSScott Long 	UCHAR szVendorID[MAX_NAME_LENGTH];  /* vender name */
3171713e81bSScott Long 
3181713e81bSScott Long } CONTROLLER_INFO, *PCONTROLLER_INFO;
3191713e81bSScott Long 
3201713e81bSScott Long /*
3211713e81bSScott Long  * Channel information.
3221713e81bSScott Long  */
3231713e81bSScott Long typedef struct _CHANNEL_INFO {
3241713e81bSScott Long 	ULONG       IoPort;         /* IDE Base Port Address */
3251713e81bSScott Long 	ULONG       ControlPort;    /* IDE Control Port Address */
3261713e81bSScott Long 
3271713e81bSScott Long 	DEVICEID    Devices[2];     /* device connected to this channel */
3281713e81bSScott Long 
3291713e81bSScott Long } CHANNEL_INFO, *PCHANNEL_INFO;
3301713e81bSScott Long 
3311713e81bSScott Long /*
3321713e81bSScott Long  * time represented in DWORD format
3331713e81bSScott Long  */
3341713e81bSScott Long #ifndef __KERNEL__
3351713e81bSScott Long typedef struct _TIME_RECORD {
3361713e81bSScott Long    UINT        seconds:6;      /* 0 - 59 */
3371713e81bSScott Long    UINT        minutes:6;      /* 0 - 59 */
3381713e81bSScott Long    UINT        month:4;        /* 1 - 12 */
3391713e81bSScott Long    UINT        hours:6;        /* 0 - 59 */
3401713e81bSScott Long    UINT        day:5;          /* 1 - 31 */
3411713e81bSScott Long    UINT        year:5;         /* 0=2000, 31=2031 */
3421713e81bSScott Long } TIME_RECORD;
3431713e81bSScott Long #endif
3441713e81bSScott Long 
3451713e81bSScott Long /*
3461713e81bSScott Long  * Array information.
3471713e81bSScott Long  */
3481713e81bSScott Long typedef struct _HPT_ARRAY_INFO {
3491713e81bSScott Long 	UCHAR       Name[MAX_ARRAYNAME_LEN];/* array name */
3501713e81bSScott Long 	UCHAR       Description[64];        /* array description */
3511713e81bSScott Long 	UCHAR       CreateManager[16];      /* who created it */
3521713e81bSScott Long 	TIME_RECORD CreateTime;             /* when created it */
3531713e81bSScott Long 
3541713e81bSScott Long 	UCHAR       ArrayType;              /* array type */
3551713e81bSScott Long 	UCHAR       BlockSizeShift;         /* stripe size */
3561713e81bSScott Long 	UCHAR       nDisk;                  /* member count: Number of ID in Members[] */
3571713e81bSScott Long 	UCHAR       reserved;
3581713e81bSScott Long 
3591713e81bSScott Long 	DWORD       Flags;                  /* working flags, see ARRAY_FLAG_XXX */
3601713e81bSScott Long 	DWORD       Members[MAX_ARRAY_MEMBERS_V1];  /* member array/disks */
3611713e81bSScott Long 
3621713e81bSScott Long 	/*
3631713e81bSScott Long 	 * rebuilding progress, xx.xx% = sprintf(s, "%.2f%%", RebuildingProgress/100.0);
3641713e81bSScott Long 	 * only valid if rebuilding is done by driver code.
3651713e81bSScott Long 	 * Member Flags will have ARRAY_FLAG_REBUILDING set at this case.
3661713e81bSScott Long 	 * Verify operation use same fields below, the only difference is
3671713e81bSScott Long 	 * ARRAY_FLAG_VERIFYING is set.
3681713e81bSScott Long 	 */
3691713e81bSScott Long 	DWORD       RebuildingProgress;
3701713e81bSScott Long 	DWORD       RebuiltSectors; /* rebuilding point (LBA) for single member */
3711713e81bSScott Long 
3721713e81bSScott Long } HPT_ARRAY_INFO, *PHPT_ARRAY_INFO;  /*LDX modify ARRAY_INFO TO HPT_ARRAY_INFO to avoid compiling error in Windows*/
3731713e81bSScott Long 
3741713e81bSScott Long #if HPT_INTERFACE_VERSION>=0x01010000
3751713e81bSScott Long typedef struct _LBA64 {
37664470755SXin LI #ifdef __BIG_ENDIAN_BITFIELD
37764470755SXin LI 	DWORD hi32;
37864470755SXin LI 	DWORD lo32;
37964470755SXin LI #else
3801713e81bSScott Long 	DWORD lo32;
3811713e81bSScott Long 	DWORD hi32;
38264470755SXin LI #endif
3831713e81bSScott Long }
3841713e81bSScott Long LBA64;
3851713e81bSScott Long typedef struct _HPT_ARRAY_INFO_V2 {
3861713e81bSScott Long 	UCHAR       Name[MAX_ARRAYNAME_LEN];/* array name */
3871713e81bSScott Long 	UCHAR       Description[64];        /* array description */
3881713e81bSScott Long 	UCHAR       CreateManager[16];      /* who created it */
3891713e81bSScott Long 	TIME_RECORD CreateTime;             /* when created it */
3901713e81bSScott Long 
3911713e81bSScott Long 	UCHAR       ArrayType;              /* array type */
3921713e81bSScott Long 	UCHAR       BlockSizeShift;         /* stripe size */
3931713e81bSScott Long 	UCHAR       nDisk;                  /* member count: Number of ID in Members[] */
3941713e81bSScott Long 	UCHAR       reserved;
3951713e81bSScott Long 
3961713e81bSScott Long 	DWORD       Flags;                  /* working flags, see ARRAY_FLAG_XXX */
3971713e81bSScott Long 	DWORD       Members[MAX_ARRAY_MEMBERS_V2];  /* member array/disks */
3981713e81bSScott Long 
3991713e81bSScott Long 	DWORD       RebuildingProgress;
4001713e81bSScott Long 	LBA64       RebuiltSectors; /* rebuilding point (LBA) for single member */
4011713e81bSScott Long 
4021713e81bSScott Long 	DWORD       reserve4[4];
4031713e81bSScott Long 
4041713e81bSScott Long } HPT_ARRAY_INFO_V2, *PHPT_ARRAY_INFO_V2;
4051713e81bSScott Long #endif
4061713e81bSScott Long 
4071713e81bSScott Long /*
4081713e81bSScott Long  * ATA/ATAPI Device identify data without the Reserved4.
4091713e81bSScott Long  */
4101713e81bSScott Long #ifndef __KERNEL__
4111713e81bSScott Long typedef struct _IDENTIFY_DATA2 {
4121713e81bSScott Long 	USHORT GeneralConfiguration;            /* 00 00 */
4131713e81bSScott Long 	USHORT NumberOfCylinders;               /* 02  1 */
4141713e81bSScott Long 	USHORT Reserved1;                       /* 04  2 */
4151713e81bSScott Long 	USHORT NumberOfHeads;                   /* 06  3 */
4161713e81bSScott Long 	USHORT UnformattedBytesPerTrack;        /* 08  4 */
4171713e81bSScott Long 	USHORT UnformattedBytesPerSector;       /* 0A  5 */
4181713e81bSScott Long 	USHORT SectorsPerTrack;                 /* 0C  6 */
4191713e81bSScott Long 	USHORT VendorUnique1[3];                /* 0E  7-9 */
4201713e81bSScott Long 	USHORT SerialNumber[10];                /* 14  10-19 */
4211713e81bSScott Long 	USHORT BufferType;                      /* 28  20 */
4221713e81bSScott Long 	USHORT BufferSectorSize;                /* 2A  21 */
4231713e81bSScott Long 	USHORT NumberOfEccBytes;                /* 2C  22 */
4241713e81bSScott Long 	USHORT FirmwareRevision[4];             /* 2E  23-26 */
4251713e81bSScott Long 	USHORT ModelNumber[20];                 /* 36  27-46 */
4261713e81bSScott Long 	UCHAR  MaximumBlockTransfer;            /* 5E  47 */
4271713e81bSScott Long 	UCHAR  VendorUnique2;                   /* 5F */
4281713e81bSScott Long 	USHORT DoubleWordIo;                    /* 60  48 */
4291713e81bSScott Long 	USHORT Capabilities;                    /* 62  49 */
4301713e81bSScott Long 	USHORT Reserved2;                       /* 64  50 */
4311713e81bSScott Long 	UCHAR  VendorUnique3;                   /* 66  51 */
4321713e81bSScott Long 	UCHAR  PioCycleTimingMode;              /* 67 */
4331713e81bSScott Long 	UCHAR  VendorUnique4;                   /* 68  52 */
4341713e81bSScott Long 	UCHAR  DmaCycleTimingMode;              /* 69 */
4351713e81bSScott Long 	USHORT TranslationFieldsValid:1;        /* 6A  53 */
4361713e81bSScott Long 	USHORT Reserved3:15;
4371713e81bSScott Long 	USHORT NumberOfCurrentCylinders;        /* 6C  54 */
4381713e81bSScott Long 	USHORT NumberOfCurrentHeads;            /* 6E  55 */
4391713e81bSScott Long 	USHORT CurrentSectorsPerTrack;          /* 70  56 */
4401713e81bSScott Long 	ULONG  CurrentSectorCapacity;           /* 72  57-58 */
4411713e81bSScott Long 	USHORT CurrentMultiSectorSetting;       /*     59 */
4421713e81bSScott Long 	ULONG  UserAddressableSectors;          /*     60-61 */
4431713e81bSScott Long 	USHORT SingleWordDMASupport : 8;        /*     62 */
4441713e81bSScott Long 	USHORT SingleWordDMAActive : 8;
4451713e81bSScott Long 	USHORT MultiWordDMASupport : 8;         /*     63 */
4461713e81bSScott Long 	USHORT MultiWordDMAActive : 8;
4471713e81bSScott Long 	USHORT AdvancedPIOModes : 8;            /*     64 */
4481713e81bSScott Long 	USHORT Reserved4 : 8;
4491713e81bSScott Long 	USHORT MinimumMWXferCycleTime;          /*     65 */
4501713e81bSScott Long 	USHORT RecommendedMWXferCycleTime;      /*     66 */
4511713e81bSScott Long 	USHORT MinimumPIOCycleTime;             /*     67 */
4521713e81bSScott Long 	USHORT MinimumPIOCycleTimeIORDY;        /*     68 */
4531713e81bSScott Long 	USHORT Reserved5[2];                    /*     69-70 */
4541713e81bSScott Long 	USHORT ReleaseTimeOverlapped;           /*     71 */
4551713e81bSScott Long 	USHORT ReleaseTimeServiceCommand;       /*     72 */
4561713e81bSScott Long 	USHORT MajorRevision;                   /*     73 */
4571713e81bSScott Long 	USHORT MinorRevision;                   /*     74 */
4581713e81bSScott Long /*    USHORT Reserved6[14];                   //     75-88 */
4591713e81bSScott Long } IDENTIFY_DATA2, *PIDENTIFY_DATA2;
4601713e81bSScott Long #endif
4611713e81bSScott Long 
4621713e81bSScott Long /*
4631713e81bSScott Long  * physical device information.
4641713e81bSScott Long  * IdentifyData.ModelNumber[] is byte-swapped from the original identify data.
4651713e81bSScott Long  */
4661713e81bSScott Long typedef struct _DEVICE_INFO {
4671713e81bSScott Long 	UCHAR   ControllerId;           /* controller id */
4681713e81bSScott Long 	UCHAR   PathId;                 /* bus */
4691713e81bSScott Long 	UCHAR   TargetId;               /* id */
4701713e81bSScott Long 	UCHAR   DeviceModeSetting;      /* Current Data Transfer mode: 0-4 PIO 0-4 */
4711713e81bSScott Long 									/* 5-7 MW DMA0-2, 8-13 UDMA0-5             */
4721713e81bSScott Long 	UCHAR   DeviceType;             /* device type */
4731713e81bSScott Long 	UCHAR   UsableMode;             /* highest usable mode */
4741713e81bSScott Long 
4751713e81bSScott Long 	UCHAR   ReadAheadSupported: 1;
4761713e81bSScott Long 	UCHAR   ReadAheadEnabled: 1;
4771713e81bSScott Long 	UCHAR   WriteCacheSupported: 1;
4781713e81bSScott Long 	UCHAR   WriteCacheEnabled: 1;
4791713e81bSScott Long 	UCHAR   TCQSupported: 1;
4801713e81bSScott Long 	UCHAR   TCQEnabled: 1;
4811713e81bSScott Long 	UCHAR   NCQSupported: 1;
4821713e81bSScott Long 	UCHAR   NCQEnabled: 1;
4831713e81bSScott Long 	UCHAR   reserved;
4841713e81bSScott Long 
4851713e81bSScott Long 	DWORD   Flags;                  /* working flags, see DEVICE_FLAG_XXX */
4861713e81bSScott Long 
4871713e81bSScott Long 	IDENTIFY_DATA2 IdentifyData;    /* Identify Data of this device */
4881713e81bSScott Long 
4891713e81bSScott Long } DEVICE_INFO, *PDEVICE_INFO;
4901713e81bSScott Long 
4911713e81bSScott Long /*
4921713e81bSScott Long  * HPT601 information
4931713e81bSScott Long  */
4941713e81bSScott Long #define HPT601_INFO_DEVICEID      1
4951713e81bSScott Long #define HPT601_INFO_TEMPERATURE   2
4961713e81bSScott Long #define HPT601_INFO_FANSTATUS     4
4971713e81bSScott Long #define HPT601_INFO_BEEPERCONTROL 8
4981713e81bSScott Long #define HPT601_INFO_LED1CONTROL   0x10
4991713e81bSScott Long #define HPT601_INFO_LED2CONTROL   0x20
5001713e81bSScott Long #define HPT601_INFO_POWERSTATUS   0x40
5011713e81bSScott Long 
5021713e81bSScott Long typedef struct _HPT601_INFO {
5031713e81bSScott Long 	WORD ValidFields;       /* mark valid fields below */
5041713e81bSScott Long 	WORD DeviceId;          /* 0x5A3E */
5051713e81bSScott Long 	WORD Temperature;       /* Read: temperature sensor value. Write: temperature limit */
5061713e81bSScott Long 	WORD FanStatus;         /* Fan status */
5071713e81bSScott Long 	WORD BeeperControl;     /* bit4: beeper control bit. bit0-3: frequency bits */
5081713e81bSScott Long 	WORD LED1Control;       /* bit4: twinkling control bit. bit0-3: frequency bits */
5091713e81bSScott Long 	WORD LED2Control;       /* bit4: twinkling control bit. bit0-3: frequency bits */
5101713e81bSScott Long 	WORD PowerStatus;       /* 1: has power 2: no power */
5111713e81bSScott Long } HPT601_INFO, *PHPT601_INFO;
5121713e81bSScott Long 
5131713e81bSScott Long /*
5141713e81bSScott Long  * Logical device information.
5151713e81bSScott Long  * Union of ArrayInfo and DeviceInfo.
5161713e81bSScott Long  * Common properties will be put in logical device information.
5171713e81bSScott Long  */
5181713e81bSScott Long typedef struct _LOGICAL_DEVICE_INFO {
5191713e81bSScott Long 	UCHAR       Type;                   /* LDT_ARRAY or LDT_DEVICE */
5201713e81bSScott Long 	UCHAR       reserved[3];
5211713e81bSScott Long 
5221713e81bSScott Long 	DWORD       Capacity;               /* array capacity */
5231713e81bSScott Long 	DEVICEID    ParentArray;
5241713e81bSScott Long 
5251713e81bSScott Long 	union {
5261713e81bSScott Long 		HPT_ARRAY_INFO array;
5271713e81bSScott Long 		DEVICE_INFO device;
5281713e81bSScott Long 	} u;
5291713e81bSScott Long 
5301713e81bSScott Long } LOGICAL_DEVICE_INFO, *PLOGICAL_DEVICE_INFO;
5311713e81bSScott Long 
5321713e81bSScott Long #if HPT_INTERFACE_VERSION>=0x01010000
5331713e81bSScott Long typedef struct _LOGICAL_DEVICE_INFO_V2 {
5341713e81bSScott Long 	UCHAR       Type;                   /* LDT_ARRAY or LDT_DEVICE */
5351713e81bSScott Long 	UCHAR       reserved[3];
5361713e81bSScott Long 
5371713e81bSScott Long 	LBA64       Capacity;           /* array capacity */
5381713e81bSScott Long 	DEVICEID    ParentArray;
5391713e81bSScott Long 
5401713e81bSScott Long 	union {
5411713e81bSScott Long 		HPT_ARRAY_INFO_V2 array;
5421713e81bSScott Long 		DEVICE_INFO device;
5431713e81bSScott Long 	} u;
5441713e81bSScott Long 
5451713e81bSScott Long } LOGICAL_DEVICE_INFO_V2, *PLOGICAL_DEVICE_INFO_V2;
5461713e81bSScott Long #endif
5471713e81bSScott Long 
5481713e81bSScott Long /*
5491713e81bSScott Long  * ALTERABLE_ARRAY_INFO and ALTERABLE_DEVICE_INFO, used in set_array_info()
5501713e81bSScott Long  * and set_device_info().
5511713e81bSScott Long  * When set_xxx_info() is called, the ValidFields member indicates which
5521713e81bSScott Long  * fields in the structure are valid.
5531713e81bSScott Long  */
5541713e81bSScott Long /* field masks */
5551713e81bSScott Long #define AAIF_NAME           1
5561713e81bSScott Long #define AAIF_DESCRIPTION    2
5571713e81bSScott Long #define ADIF_MODE           1
5581713e81bSScott Long #define ADIF_TCQ            2
5591713e81bSScott Long #define ADIF_NCQ            4
5601713e81bSScott Long #define ADIF_WRITE_CACHE    8
5611713e81bSScott Long #define ADIF_READ_AHEAD     0x10
5621713e81bSScott Long 
5631713e81bSScott Long typedef struct _ALTERABLE_ARRAY_INFO {
5641713e81bSScott Long 	DWORD   ValidFields;                /* mark valid fields below */
5651713e81bSScott Long 	UCHAR   Name[MAX_ARRAYNAME_LEN];    /* array name */
5661713e81bSScott Long 	UCHAR   Description[64];            /* array description */
5671713e81bSScott Long }
5681713e81bSScott Long ALTERABLE_ARRAY_INFO, *PALTERABLE_ARRAY_INFO;
5691713e81bSScott Long 
5701713e81bSScott Long typedef struct _ALTERABLE_DEVICE_INFO {
5711713e81bSScott Long 	DWORD   ValidFields;                /* mark valid fields below */
5721713e81bSScott Long 	UCHAR   DeviceModeSetting;          /* 0-4 PIO 0-4, 5-7 MW DMA0-2, 8-13 UDMA0-5 */
5731713e81bSScott Long }
5741713e81bSScott Long ALTERABLE_DEVICE_INFO, *PALTERABLE_DEVICE_INFO;
5751713e81bSScott Long 
5761713e81bSScott Long typedef struct _ALTERABLE_DEVICE_INFO_V2 {
5771713e81bSScott Long 	DWORD   ValidFields;                /* mark valid fields below */
5781713e81bSScott Long 	UCHAR   DeviceModeSetting;          /* 0-4 PIO 0-4, 5-7 MW DMA0-2, 8-13 UDMA0-5 */
5791713e81bSScott Long 	UCHAR   TCQEnabled;
5801713e81bSScott Long 	UCHAR   NCQEnabled;
5811713e81bSScott Long 	UCHAR   WriteCacheEnabled;
5821713e81bSScott Long 	UCHAR   ReadAheadEnabled;
5831713e81bSScott Long 	UCHAR   reserve[3];
5841713e81bSScott Long 	ULONG   reserve2[13]; /* pad to 64 bytes */
5851713e81bSScott Long }
5861713e81bSScott Long ALTERABLE_DEVICE_INFO_V2, *PALTERABLE_DEVICE_INFO_V2;
5871713e81bSScott Long 
5881713e81bSScott Long /*
5891713e81bSScott Long  * CREATE_ARRAY_PARAMS
5901713e81bSScott Long  *  Param structure used to create an array.
5911713e81bSScott Long  */
5921713e81bSScott Long typedef struct _CREATE_ARRAY_PARAMS {
5931713e81bSScott Long 	UCHAR ArrayType;                    /* 1-level array type */
5941713e81bSScott Long 	UCHAR nDisk;                        /* number of elements in Members[] array */
5951713e81bSScott Long 	UCHAR BlockSizeShift;               /* Stripe size if ArrayType==AT_RAID0 / AT_RAID5 */
5961713e81bSScott Long 	UCHAR CreateFlags;                  /* See CAF_xxx */
5971713e81bSScott Long 
5981713e81bSScott Long 	UCHAR ArrayName[MAX_ARRAYNAME_LEN]; /* Array name */
5991713e81bSScott Long 	UCHAR       Description[64];        /* array description */
6001713e81bSScott Long 	UCHAR       CreateManager[16];      /* who created it */
6011713e81bSScott Long 	TIME_RECORD CreateTime;             /* when created it */
6021713e81bSScott Long 
6031713e81bSScott Long 	DWORD Members[MAX_ARRAY_MEMBERS_V1];/* ID of array members, a member can be an array */
6041713e81bSScott Long 
6051713e81bSScott Long } CREATE_ARRAY_PARAMS, *PCREATE_ARRAY_PARAMS;
6061713e81bSScott Long 
6071713e81bSScott Long #if HPT_INTERFACE_VERSION>=0x01010000
6081713e81bSScott Long typedef struct _CREATE_ARRAY_PARAMS_V2 {
6091713e81bSScott Long 	UCHAR ArrayType;                    /* 1-level array type */
6101713e81bSScott Long 	UCHAR nDisk;                        /* number of elements in Members[] array */
6111713e81bSScott Long 	UCHAR BlockSizeShift;               /* Stripe size if ArrayType==AT_RAID0 / AT_RAID5 */
6121713e81bSScott Long 	UCHAR CreateFlags;                  /* See CAF_xxx */
6131713e81bSScott Long 
6141713e81bSScott Long 	UCHAR ArrayName[MAX_ARRAYNAME_LEN]; /* Array name */
6151713e81bSScott Long 	UCHAR       Description[64];        /* array description */
6161713e81bSScott Long 	UCHAR       CreateManager[16];      /* who created it */
6171713e81bSScott Long 	TIME_RECORD CreateTime;             /* when created it */
6181713e81bSScott Long 	LBA64 Capacity;                     /* specify array capacity (0 for default) */
6191713e81bSScott Long 
6201713e81bSScott Long 	DWORD Members[MAX_ARRAY_MEMBERS_V2];/* ID of array members, a member can be an array */
6211713e81bSScott Long 
6221713e81bSScott Long } CREATE_ARRAY_PARAMS_V2, *PCREATE_ARRAY_PARAMS_V2;
6231713e81bSScott Long #endif
6241713e81bSScott Long 
6251713e81bSScott Long /*
6261713e81bSScott Long  * Flags used for creating an RAID 1 array
6271713e81bSScott Long  *
6281713e81bSScott Long  * CAF_CREATE_AND_DUPLICATE
6291713e81bSScott Long  *    Copy source disk contents to target for RAID 1. If user choose "create and duplicate"
6301713e81bSScott Long  *    to create an array, GUI will call CreateArray() with this flag set. Then GUI should
6311713e81bSScott Long  *    call hpt_get_device_info() with the returned array ID and check returned flags to
6321713e81bSScott Long  *    see if ARRAY_FLAG_REBUILDING is set. If not set, driver does not support rebuilding
6331713e81bSScott Long  *    and GUI must do duplication itself.
6341713e81bSScott Long  * CAF_DUPLICATE_MUST_DONE
6351713e81bSScott Long  *    If the duplication is aborted or fails, do not create the array.
6361713e81bSScott Long  */
6371713e81bSScott Long #define CAF_CREATE_AND_DUPLICATE 1
6381713e81bSScott Long #define CAF_DUPLICATE_MUST_DONE  2
6391713e81bSScott Long #define CAF_CREATE_AS_RAID15     4
6401713e81bSScott Long /*
6411713e81bSScott Long  * Flags used for creating an RAID 5 array
6421713e81bSScott Long  */
6431713e81bSScott Long #define CAF_CREATE_R5_NO_BUILD     1
6441713e81bSScott Long #define CAF_CREATE_R5_ZERO_INIT    2
6451713e81bSScott Long #define CAF_CREATE_R5_BUILD_PARITY 4
6461713e81bSScott Long 
6471713e81bSScott Long /*
6481713e81bSScott Long  * Flags used for deleting an array
6491713e81bSScott Long  *
6501713e81bSScott Long  * DAF_KEEP_DATA_IF_POSSIBLE
6511713e81bSScott Long  *    If this flag is set, deleting a RAID 1 array will not destroy the data on both disks.
6521713e81bSScott Long  *    Deleting a JBOD should keep partitions on first disk ( not implement now ).
6531713e81bSScott Long  *    Deleting a RAID 0/1 should result as two RAID 0 array ( not implement now ).
6541713e81bSScott Long  */
6551713e81bSScott Long #define DAF_KEEP_DATA_IF_POSSIBLE 1
6561713e81bSScott Long 
6571713e81bSScott Long /*
6581713e81bSScott Long  * event types
6591713e81bSScott Long  */
6601713e81bSScott Long #define ET_DEVICE_REMOVED   1   /* device removed */
6611713e81bSScott Long #define ET_DEVICE_PLUGGED   2   /* device plugged */
6621713e81bSScott Long #define ET_DEVICE_ERROR     3   /* device I/O error */
6631713e81bSScott Long #define ET_REBUILD_STARTED  4
6641713e81bSScott Long #define ET_REBUILD_ABORTED  5
6651713e81bSScott Long #define ET_REBUILD_FINISHED 6
6661713e81bSScott Long #define ET_SPARE_TOOK_OVER  7
6671713e81bSScott Long #define ET_REBUILD_FAILED   8
6681713e81bSScott Long #define ET_VERIFY_STARTED   9
6691713e81bSScott Long #define ET_VERIFY_ABORTED   10
6701713e81bSScott Long #define ET_VERIFY_FAILED    11
6711713e81bSScott Long #define ET_VERIFY_FINISHED  12
6721713e81bSScott Long #define ET_INITIALIZE_STARTED   13
6731713e81bSScott Long #define ET_INITIALIZE_ABORTED   14
6741713e81bSScott Long #define ET_INITIALIZE_FAILED    15
6751713e81bSScott Long #define ET_INITIALIZE_FINISHED  16
6761713e81bSScott Long #define ET_VERIFY_DATA_ERROR    17
6771713e81bSScott Long 
6781713e81bSScott Long /*
6791713e81bSScott Long  * event structure
6801713e81bSScott Long  */
6811713e81bSScott Long typedef struct _HPT_EVENT {
6821713e81bSScott Long 	TIME_RECORD Time;
6831713e81bSScott Long 	DEVICEID    DeviceID;
6841713e81bSScott Long 	UCHAR       EventType;
6851713e81bSScott Long 	UCHAR       reserved[3];
6861713e81bSScott Long 
6871713e81bSScott Long 	UCHAR       Data[32]; /* various data depend on EventType */
6881713e81bSScott Long } HPT_EVENT, *PHPT_EVENT;
6891713e81bSScott Long 
6901713e81bSScott Long /*
6911713e81bSScott Long  * IDE pass-through command. Use it at your own risk!
6921713e81bSScott Long  */
6931713e81bSScott Long #ifdef _MSC_VER
6941713e81bSScott Long #pragma warning(disable:4200)
6951713e81bSScott Long #endif
6961713e81bSScott Long typedef struct _IDE_PASS_THROUGH_HEADER {
6971713e81bSScott Long 	DEVICEID idDisk;           /* disk ID */
6981713e81bSScott Long 	BYTE     bFeaturesReg;     /* feature register */
6991713e81bSScott Long 	BYTE     bSectorCountReg;  /* IDE sector count register. */
70064470755SXin LI 	BYTE     bLbaLowReg; /* IDE sector number register. */
70164470755SXin LI 	BYTE     bLbaMidReg;       /* IDE low order cylinder value. */
70264470755SXin LI 	BYTE     bLbaHighReg;      /* IDE high order cylinder value. */
7031713e81bSScott Long 	BYTE     bDriveHeadReg;    /* IDE drive/head register. */
7041713e81bSScott Long 	BYTE     bCommandReg;      /* Actual IDE command. Checked for validity by driver. */
70564470755SXin LI 	BYTE     nSectors;		/* data sze in sectors, if the command has data transfer */
70664470755SXin LI 	BYTE     protocol;            /* IO_COMMAND_(READ,WRITE) or zero for non-DATA */
70764470755SXin LI 	BYTE     reserve[3];
70864470755SXin LI #define IDE_PASS_THROUGH_buffer(p) ((unsigned char *)(p) + sizeof(IDE_PASS_THROUGH_HEADER))
7091713e81bSScott Long }
7101713e81bSScott Long IDE_PASS_THROUGH_HEADER, *PIDE_PASS_THROUGH_HEADER;
7111713e81bSScott Long 
7121713e81bSScott Long /*
7131713e81bSScott Long  * device io packet format
7141713e81bSScott Long  */
7151713e81bSScott Long typedef struct _DEVICE_IO_EX_PARAMS {
7161713e81bSScott Long 	DEVICEID idDisk;
7171713e81bSScott Long 	ULONG    Lba;
7181713e81bSScott Long 	USHORT   nSectors;
7191713e81bSScott Long 	UCHAR    Command; /* IO_COMMAD_xxx */
7201713e81bSScott Long 	UCHAR    BufferType; /* BUFFER_TYPE_xxx, see below */
7211713e81bSScott Long 	ULONG    BufferPtr;
7221713e81bSScott Long }
7231713e81bSScott Long DEVICE_IO_EX_PARAMS, *PDEVICE_IO_EX_PARAMS;
7241713e81bSScott Long 
7251713e81bSScott Long #define BUFFER_TYPE_LOGICAL              1 /* logical pointer to buffer */
7261713e81bSScott Long #define BUFFER_TYPE_PHYSICAL             2 /* physical address of buffer */
7271713e81bSScott Long #define BUFFER_TYPE_LOGICAL_LOGICAL_SG   3 /* logical pointer to logical S/G table */
7281713e81bSScott Long #define BUFFER_TYPE_LOGICAL_PHYSICAL_SG  4 /* logical pointer to physical S/G table */
7291713e81bSScott Long #define BUFFER_TYPE_PHYSICAL_LOGICAL_SG  5 /* physical address to logical S/G table */
7301713e81bSScott Long #define BUFFER_TYPE_PHYSICAL_PHYSICAL_SG 6 /* physical address of physical S/G table */
7311713e81bSScott Long #define BUFFER_TYPE_PHYSICAL_PHYSICAL_SG_PIO 7 /* non DMA capable physical address of physical S/G table */
7321713e81bSScott Long 
7331713e81bSScott Long /*
7341713e81bSScott Long  * all ioctl functions should use far pointers. It's not a problem on
7351713e81bSScott Long  * 32bit platforms, however, BIOS needs care.
7361713e81bSScott Long  */
7371713e81bSScott Long 
7381713e81bSScott Long /*
7391713e81bSScott Long  * ioctl structure
7401713e81bSScott Long  */
74164470755SXin LI #define HPT_IOCTL_MAGIC32 0x1A2B3C4D
74264470755SXin LI #define HPT_IOCTL_MAGIC   0xA1B2C3D4
7431713e81bSScott Long 
7441713e81bSScott Long typedef struct _HPT_IOCTL_PARAM {
7451713e81bSScott Long 	DWORD   Magic;                 /* used to check if it's a valid ioctl packet */
7461713e81bSScott Long 	DWORD   dwIoControlCode;       /* operation control code */
7471713e81bSScott Long 	LPVOID  lpInBuffer;            /* input data buffer */
7481713e81bSScott Long 	DWORD   nInBufferSize;         /* size of input data buffer */
7491713e81bSScott Long 	LPVOID  lpOutBuffer;           /* output data buffer */
7501713e81bSScott Long 	DWORD   nOutBufferSize;        /* size of output data buffer */
7511713e81bSScott Long 	LPDWORD lpBytesReturned;       /* count of bytes returned */
7521713e81bSScott Long }
7531713e81bSScott Long HPT_IOCTL_PARAM, *PHPT_IOCTL_PARAM;
7541713e81bSScott Long 
75564470755SXin LI /* for 32-bit app running on 64-bit system */
7561713e81bSScott Long typedef struct _HPT_IOCTL_PARAM32 {
7571713e81bSScott Long 	DWORD   Magic;
7581713e81bSScott Long 	DWORD   dwIoControlCode;
7591713e81bSScott Long 	DWORD   lpInBuffer;
7601713e81bSScott Long 	DWORD   nInBufferSize;
7611713e81bSScott Long 	DWORD   lpOutBuffer;
7621713e81bSScott Long 	DWORD   nOutBufferSize;
7631713e81bSScott Long 	DWORD   lpBytesReturned;
7641713e81bSScott Long }
7651713e81bSScott Long HPT_IOCTL_PARAM32, *PHPT_IOCTL_PARAM32;
7661713e81bSScott Long 
7671713e81bSScott Long /*
7681713e81bSScott Long  * User-mode ioctl parameter passing conventions:
7691713e81bSScott Long  *   The ioctl function implementation is platform specific, so we don't
7701713e81bSScott Long  * have forced rules for it. However, it's suggested to use a parameter
7711713e81bSScott Long  * passing method as below
7721713e81bSScott Long  *   1) Put all input data continuously in an input buffer.
7731713e81bSScott Long  *   2) Prepare an output buffer with enough size if needed.
7741713e81bSScott Long  *   3) Fill a HPT_IOCTL_PARAM structure.
7751713e81bSScott Long  *   4) Pass the structure to driver through a platform-specific method.
7761713e81bSScott Long  * This is implemented in the mid-layer user-mode library. The UI
7771713e81bSScott Long  * programmer needn't care about it.
7781713e81bSScott Long  */
7791713e81bSScott Long 
7801713e81bSScott Long /************************************************************************
7811713e81bSScott Long  * User mode functions
7821713e81bSScott Long  ************************************************************************/
7831713e81bSScott Long #ifndef __KERNEL__
7841713e81bSScott Long /*
7851713e81bSScott Long  * hpt_get_version
7861713e81bSScott Long  * Version compatibility: all versions
7871713e81bSScott Long  * Parameters:
7881713e81bSScott Long  *  None
7891713e81bSScott Long  * Returns:
7901713e81bSScott Long  *  interface version. 0 when fail.
7911713e81bSScott Long  */
792d2bd3ab9SScott Long DWORD hpt_get_version();
7931713e81bSScott Long 
7941713e81bSScott Long /*-------------------------------------------------------------------------- */
7951713e81bSScott Long 
7961713e81bSScott Long /*
7971713e81bSScott Long  * hpt_get_driver_capabilities
7981713e81bSScott Long  * Version compatibility: v1.0.0.2 or later
7991713e81bSScott Long  * Parameters:
8001713e81bSScott Long  *  Pointer to receive a DRIVE_CAPABILITIES structure. The caller must set
8011713e81bSScott Long  *  dwSize member to sizeof(DRIVER_CAPABILITIES). The callee must check this
8021713e81bSScott Long  *  member to see if it's correct.
8031713e81bSScott Long  * Returns:
8041713e81bSScott Long  *  0 - Success
8051713e81bSScott Long  */
8061713e81bSScott Long int hpt_get_driver_capabilities(PDRIVER_CAPABILITIES cap);
8071713e81bSScott Long 
8081713e81bSScott Long /*-------------------------------------------------------------------------- */
8091713e81bSScott Long 
8101713e81bSScott Long /*
8111713e81bSScott Long  * hpt_get_controller_count
8121713e81bSScott Long  * Version compatibility: v1.0.0.1 or later
8131713e81bSScott Long  * Parameters:
8141713e81bSScott Long  *  None
8151713e81bSScott Long  * Returns:
8161713e81bSScott Long  *  number of controllers
8171713e81bSScott Long  */
818d2bd3ab9SScott Long int hpt_get_controller_count();
8191713e81bSScott Long 
8201713e81bSScott Long /*-------------------------------------------------------------------------- */
8211713e81bSScott Long 
8221713e81bSScott Long /* hpt_get_controller_info
8231713e81bSScott Long  * Version compatibility: v1.0.0.1 or later
8241713e81bSScott Long  * Parameters:
8251713e81bSScott Long  *  id      Controller id
8261713e81bSScott Long  *  pInfo   pointer to CONTROLLER_INFO buffer
8271713e81bSScott Long  * Returns:
8281713e81bSScott Long  *  0       Success, controller info is put into (*pInfo ).
8291713e81bSScott Long  */
8301713e81bSScott Long int hpt_get_controller_info(int id, PCONTROLLER_INFO pInfo);
8311713e81bSScott Long 
8321713e81bSScott Long /*-------------------------------------------------------------------------- */
8331713e81bSScott Long 
8341713e81bSScott Long /* hpt_get_channel_info
8351713e81bSScott Long  * Version compatibility: v1.0.0.1 or later
8361713e81bSScott Long  * Parameters:
8371713e81bSScott Long  *  id      Controller id
8381713e81bSScott Long  *  bus     bus number
8391713e81bSScott Long  *  pInfo   pointer to CHANNEL_INFO buffer
8401713e81bSScott Long  * Returns:
8411713e81bSScott Long  *  0       Success, channel info is put into (*pInfo ).
8421713e81bSScott Long  */
8431713e81bSScott Long int hpt_get_channel_info(int id, int bus, PCHANNEL_INFO pInfo);
8441713e81bSScott Long 
8451713e81bSScott Long /*-------------------------------------------------------------------------- */
8461713e81bSScott Long 
8471713e81bSScott Long /* hpt_get_logical_devices
8481713e81bSScott Long  * Version compatibility: v1.0.0.1 or later
8491713e81bSScott Long  * Parameters:
8501713e81bSScott Long  *  pIds        pointer to a DEVICEID array
8511713e81bSScott Long  *  nMaxCount   array size
8521713e81bSScott Long  * Returns:
8531713e81bSScott Long  *  Number of ID returned. All logical device IDs are put into pIds array.
8541713e81bSScott Long  *  Note: A spare disk is not a logical device.
8551713e81bSScott Long  */
8561713e81bSScott Long int hpt_get_logical_devices(DEVICEID * pIds, int nMaxCount);
8571713e81bSScott Long 
8581713e81bSScott Long /*-------------------------------------------------------------------------- */
8591713e81bSScott Long 
8601713e81bSScott Long /* hpt_get_device_info
8611713e81bSScott Long  * Version compatibility: v1.0.0.1 or later
8621713e81bSScott Long  * Parameters:
8631713e81bSScott Long  *  id      logical device id
8641713e81bSScott Long  *  pInfo   pointer to HPT_ARRAY_INFO structure
8651713e81bSScott Long  * Returns:
8661713e81bSScott Long  *  0 - Success
8671713e81bSScott Long  */
8681713e81bSScott Long int hpt_get_device_info(DEVICEID id, PLOGICAL_DEVICE_INFO pInfo);
8691713e81bSScott Long 
8701713e81bSScott Long #if HPT_INTERFACE_VERSION>=0x01010000
8711713e81bSScott Long int hpt_get_device_info_v2(DEVICEID id, PLOGICAL_DEVICE_INFO_V2 pInfo);
8721713e81bSScott Long #endif
8731713e81bSScott Long 
8741713e81bSScott Long /*-------------------------------------------------------------------------- */
8751713e81bSScott Long 
8761713e81bSScott Long /* hpt_create_array
8771713e81bSScott Long  * Version compatibility: v1.0.0.1 or later
8781713e81bSScott Long  * Parameters:
8791713e81bSScott Long  *  pParam      pointer to CREATE_ARRAY_PARAMS structure
8801713e81bSScott Long  * Returns:
8811713e81bSScott Long  *  0   failed
8821713e81bSScott Long  *  else return array id
8831713e81bSScott Long  */
8841713e81bSScott Long DEVICEID hpt_create_array(PCREATE_ARRAY_PARAMS pParam);
8851713e81bSScott Long 
8861713e81bSScott Long #if HPT_INTERFACE_VERSION>=0x01010000
8871713e81bSScott Long DEVICEID hpt_create_array_v2(PCREATE_ARRAY_PARAMS_V2 pParam);
8881713e81bSScott Long #endif
8891713e81bSScott Long 
8901713e81bSScott Long /*-------------------------------------------------------------------------- */
8911713e81bSScott Long 
8921713e81bSScott Long /* hpt_delete_array
8931713e81bSScott Long  * Version compatibility: v1.0.0.1 or later
8941713e81bSScott Long  * Parameters:
8951713e81bSScott Long  *  id      array id
8961713e81bSScott Long  * Returns:
8971713e81bSScott Long  *  0   Success
8981713e81bSScott Long  */
8991713e81bSScott Long int hpt_delete_array(DEVICEID id, DWORD options);
9001713e81bSScott Long 
9011713e81bSScott Long /*-------------------------------------------------------------------------- */
9021713e81bSScott Long 
9031713e81bSScott Long /* hpt_device_io
9041713e81bSScott Long  *  Read/write data on array and physcal device.
9051713e81bSScott Long  * Version compatibility: v1.0.0.1 or later
9061713e81bSScott Long  * Parameters:
9071713e81bSScott Long  *  id      device id. If it's an array ID, IO will be performed on the array.
9081713e81bSScott Long  *          If it's a physical device ID, IO will be performed on the device.
9091713e81bSScott Long  *  cmd     IO_COMMAND_READ or IO_COMMAND_WRITE
9101713e81bSScott Long  *  buffer  data buffer
9111713e81bSScott Long  *  length  data size
9121713e81bSScott Long  * Returns:
9131713e81bSScott Long  *  0   Success
9141713e81bSScott Long  */
9151713e81bSScott Long int hpt_device_io(DEVICEID id, int cmd, ULONG lba, DWORD nSector, LPVOID buffer);
9161713e81bSScott Long 
9171713e81bSScott Long #if HPT_INTERFACE_VERSION >= 0x01010000
9181713e81bSScott Long int hpt_device_io_v2(DEVICEID id, int cmd, LBA64 lba, DWORD nSector, LPVOID buffer);
9191713e81bSScott Long #endif
9201713e81bSScott Long 
9211713e81bSScott Long /* hpt_add_disk_to_array
9221713e81bSScott Long  *   Used to dynamicly add a disk to an RAID1, RAID0/1, RAID1/0 or RAID5 array.
9231713e81bSScott Long  *   Auto-rebuild will start.
9241713e81bSScott Long  * Version compatibility: v1.0.0.1 or later
9251713e81bSScott Long  * Parameters:
9261713e81bSScott Long  *  idArray     array id
9271713e81bSScott Long  *  idDisk      disk id
9281713e81bSScott Long  * Returns:
9291713e81bSScott Long  *  0   Success
9301713e81bSScott Long  */
9311713e81bSScott Long int hpt_add_disk_to_array(DEVICEID idArray, DEVICEID idDisk);
9321713e81bSScott Long /*-------------------------------------------------------------------------- */
9331713e81bSScott Long 
9341713e81bSScott Long /* hpt_add_spare_disk
9351713e81bSScott Long  * Version compatibility: v1.0.0.1 or later
9361713e81bSScott Long  *   Add a disk to spare pool.
9371713e81bSScott Long  * Parameters:
9381713e81bSScott Long  *  idDisk      disk id
9391713e81bSScott Long  * Returns:
9401713e81bSScott Long  *  0   Success
9411713e81bSScott Long  */
9421713e81bSScott Long int hpt_add_spare_disk(DEVICEID idDisk);
9431713e81bSScott Long /*-------------------------------------------------------------------------- */
9441713e81bSScott Long 
9451713e81bSScott Long /* hpt_add_dedicated_spare
9461713e81bSScott Long  * Version compatibility: v1.0.0.3 or later
9471713e81bSScott Long  *   Add a spare disk to an array
9481713e81bSScott Long  * Parameters:
9491713e81bSScott Long  *  idDisk      disk id
9501713e81bSScott Long  *  idArray     array id
9511713e81bSScott Long  * Returns:
9521713e81bSScott Long  *  0   Success
9531713e81bSScott Long  */
9541713e81bSScott Long int hpt_add_dedicated_spare(DEVICEID idDisk, DEVICEID idArray);
9551713e81bSScott Long /*-------------------------------------------------------------------------- */
9561713e81bSScott Long 
9571713e81bSScott Long /* hpt_remove_spare_disk
9581713e81bSScott Long  *   remove a disk from spare pool.
9591713e81bSScott Long  * Version compatibility: v1.0.0.1 or later
9601713e81bSScott Long  * Parameters:
9611713e81bSScott Long  *  idDisk      disk id
9621713e81bSScott Long  * Returns:
9631713e81bSScott Long  *  0   Success
9641713e81bSScott Long  */
9651713e81bSScott Long int hpt_remove_spare_disk(DEVICEID idDisk);
9661713e81bSScott Long /*-------------------------------------------------------------------------- */
9671713e81bSScott Long 
9681713e81bSScott Long /* hpt_get_event
9691713e81bSScott Long  *   Used to poll events from driver.
9701713e81bSScott Long  * Version compatibility: v1.0.0.1 or later
9711713e81bSScott Long  * Parameters:
9721713e81bSScott Long  *   pEvent    pointer to HPT_EVENT structure
9731713e81bSScott Long  * Returns:
9741713e81bSScott Long  *  0   Success, event info is filled in *pEvent
9751713e81bSScott Long  */
9761713e81bSScott Long int hpt_get_event(PHPT_EVENT pEvent);
9771713e81bSScott Long /*-------------------------------------------------------------------------- */
9781713e81bSScott Long 
9791713e81bSScott Long /* hpt_rebuild_data_block
9801713e81bSScott Long  *   Used to copy data from source disk and mirror disk.
9811713e81bSScott Long  * Version compatibility: v1.0.0.1 or later
9821713e81bSScott Long  * Parameters:
9831713e81bSScott Long  *   idArray        Array ID (RAID1, 0/1 or RAID5)
9841713e81bSScott Long  *   Lba            Start LBA for each array member
9851713e81bSScott Long  *   nSector        Number of sectors for each array member (RAID 5 will ignore this parameter)
9861713e81bSScott Long  *
9871713e81bSScott Long  * Returns:
9881713e81bSScott Long  *  0   Success, event info is filled in *pEvent
9891713e81bSScott Long  */
9901713e81bSScott Long int hpt_rebuild_data_block(DEVICEID idMirror, DWORD Lba, UCHAR nSector);
9911713e81bSScott Long #define hpt_rebuild_mirror(p1, p2, p3) hpt_rebuild_data_block(p1, p2, p3)
9921713e81bSScott Long 
9931713e81bSScott Long #if HPT_INTERFACE_VERSION >= 0x01010000
9941713e81bSScott Long int hpt_rebuild_data_block_v2(DEVICEID idArray, LBA64 Lba, USHORT nSector);
9951713e81bSScott Long #endif
9961713e81bSScott Long /*-------------------------------------------------------------------------- */
9971713e81bSScott Long 
9981713e81bSScott Long /* hpt_set_array_state
9991713e81bSScott Long  *   set array state.
10001713e81bSScott Long  * Version compatibility: v1.0.0.1 or later
10011713e81bSScott Long  * Parameters:
10021713e81bSScott Long  *   idArray        Array ID
10031713e81bSScott Long  *   state          See above 'array states' constants, possible values are:
10041713e81bSScott Long  *     MIRROR_REBUILD_START
10051713e81bSScott Long  *        Indicate that GUI wants to rebuild a mirror array
10061713e81bSScott Long  *     MIRROR_REBUILD_ABORT
10071713e81bSScott Long  *        GUI wants to abort rebuilding an array
10081713e81bSScott Long  *     MIRROR_REBUILD_COMPLETE
10091713e81bSScott Long  *        GUI finished to rebuild an array. If rebuild is done by driver this
10101713e81bSScott Long  *        state has no use
10111713e81bSScott Long  *
10121713e81bSScott Long  * Returns:
10131713e81bSScott Long  *  0   Success
10141713e81bSScott Long  */
10151713e81bSScott Long int hpt_set_array_state(DEVICEID idArray, DWORD state);
10161713e81bSScott Long /*-------------------------------------------------------------------------- */
10171713e81bSScott Long 
10181713e81bSScott Long /* hpt_set_array_info
10191713e81bSScott Long  *   set array info.
10201713e81bSScott Long  * Version compatibility: v1.0.0.1 or later
10211713e81bSScott Long  * Parameters:
10221713e81bSScott Long  *   idArray        Array ID
10231713e81bSScott Long  *   pInfo          pointer to new info
10241713e81bSScott Long  *
10251713e81bSScott Long  * Returns:
10261713e81bSScott Long  *  0   Success
10271713e81bSScott Long  */
10281713e81bSScott Long int hpt_set_array_info(DEVICEID idArray, PALTERABLE_ARRAY_INFO pInfo);
10291713e81bSScott Long /*-------------------------------------------------------------------------- */
10301713e81bSScott Long 
10311713e81bSScott Long /* hpt_set_device_info
10321713e81bSScott Long  *   set device info.
10331713e81bSScott Long  * Version compatibility: v1.0.0.1 or later
10341713e81bSScott Long  * Parameters:
10351713e81bSScott Long  *   idDisk         device ID
10361713e81bSScott Long  *   pInfo          pointer to new info
10371713e81bSScott Long  *
10381713e81bSScott Long  * Returns:
10391713e81bSScott Long  *  0   Success
10401713e81bSScott Long  * Additional notes:
10411713e81bSScott Long  *  If idDisk==0, call to this function will stop buzzer on the adapter
10421713e81bSScott Long  *  (if supported by driver).
10431713e81bSScott Long  */
10441713e81bSScott Long int hpt_set_device_info(DEVICEID idDisk, PALTERABLE_DEVICE_INFO pInfo);
10451713e81bSScott Long 
10461713e81bSScott Long #if HPT_INTERFACE_VERSION >= 0x01000004
10471713e81bSScott Long int hpt_set_device_info_v2(DEVICEID idDisk, PALTERABLE_DEVICE_INFO_V2 pInfo);
10481713e81bSScott Long #endif
10491713e81bSScott Long 
10501713e81bSScott Long /*-------------------------------------------------------------------------- */
10511713e81bSScott Long 
10521713e81bSScott Long /* hpt_rescan_devices
10531713e81bSScott Long  *   rescan devices
10541713e81bSScott Long  * Version compatibility: v1.0.0.1 or later
10551713e81bSScott Long  * Parameters:
10561713e81bSScott Long  *   None
10571713e81bSScott Long  * Returns:
10581713e81bSScott Long  *   0  Success
10591713e81bSScott Long  */
1060d2bd3ab9SScott Long int hpt_rescan_devices();
10611713e81bSScott Long /*-------------------------------------------------------------------------- */
10621713e81bSScott Long 
10631713e81bSScott Long /* hpt_get_601_info
10641713e81bSScott Long  *   Get HPT601 status
10651713e81bSScott Long  * Version compatibiilty: v1.0.0.3 or later
10661713e81bSScott Long  * Parameters:
10671713e81bSScott Long  *   idDisk - Disk handle
10681713e81bSScott Long  *   PHPT601_INFO - pointer to HPT601 info buffer
10691713e81bSScott Long  * Returns:
10701713e81bSScott Long  *   0  Success
10711713e81bSScott Long  */
10721713e81bSScott Long int hpt_get_601_info(DEVICEID idDisk, PHPT601_INFO pInfo);
10731713e81bSScott Long /*-------------------------------------------------------------------------- */
10741713e81bSScott Long 
10751713e81bSScott Long /* hpt_set_601_info
10761713e81bSScott Long  *   HPT601 function control
10771713e81bSScott Long  * Version compatibiilty: v1.0.0.3 or later
10781713e81bSScott Long  * Parameters:
10791713e81bSScott Long  *   idDisk - Disk handle
10801713e81bSScott Long  *   PHPT601_INFO - pointer to HPT601 info buffer
10811713e81bSScott Long  * Returns:
10821713e81bSScott Long  *   0  Success
10831713e81bSScott Long  */
10841713e81bSScott Long int hpt_set_601_info(DEVICEID idDisk, PHPT601_INFO pInfo);
10851713e81bSScott Long /*-------------------------------------------------------------------------- */
10861713e81bSScott Long 
10871713e81bSScott Long /* hpt_lock_device
10881713e81bSScott Long  *   Lock a block on a device (prevent OS accessing it)
10891713e81bSScott Long  * Version compatibiilty: v1.0.0.3 or later
10901713e81bSScott Long  * Parameters:
10911713e81bSScott Long  *   idDisk - Disk handle
10921713e81bSScott Long  *   Lba - Start LBA
10931713e81bSScott Long  *   nSectors - number of sectors
10941713e81bSScott Long  * Returns:
10951713e81bSScott Long  *   0  Success
10961713e81bSScott Long  */
10971713e81bSScott Long int hpt_lock_device(DEVICEID idDisk, ULONG Lba, UCHAR nSectors);
10981713e81bSScott Long 
10991713e81bSScott Long #if HPT_INTERFACE_VERSION >= 0x01010000
11001713e81bSScott Long int hpt_lock_device_v2(DEVICEID idDisk, LBA64 Lba, USHORT nSectors);
11011713e81bSScott Long #endif
11021713e81bSScott Long /*-------------------------------------------------------------------------- */
11031713e81bSScott Long 
11041713e81bSScott Long /* hpt_lock_device
11051713e81bSScott Long  *   Unlock a device
11061713e81bSScott Long  * Version compatibiilty: v1.0.0.3 or later
11071713e81bSScott Long  * Parameters:
11081713e81bSScott Long  *   idDisk - Disk handle
11091713e81bSScott Long  * Returns:
11101713e81bSScott Long  *   0  Success
11111713e81bSScott Long  */
11121713e81bSScott Long int hpt_unlock_device(DEVICEID idDisk);
11131713e81bSScott Long /*-------------------------------------------------------------------------- */
11141713e81bSScott Long 
11151713e81bSScott Long /* hpt_ide_pass_through
11161713e81bSScott Long  *  directly access controller's command and control registers.
11171713e81bSScott Long  *  Can only call it on physical devices.
11181713e81bSScott Long  * Version compatibility: v1.0.0.3 or later
11191713e81bSScott Long  * Parameters:
11201713e81bSScott Long  *   p - IDE_PASS_THROUGH header pointer
11211713e81bSScott Long  * Returns:
11221713e81bSScott Long  *   0  Success
11231713e81bSScott Long  */
11241713e81bSScott Long int hpt_ide_pass_through(PIDE_PASS_THROUGH_HEADER p);
11251713e81bSScott Long /*-------------------------------------------------------------------------- */
11261713e81bSScott Long 
11271713e81bSScott Long /* hpt_verify_data_block
11281713e81bSScott Long  *   verify data block on RAID1 or RAID5.
11291713e81bSScott Long  * Version compatibility: v1.0.0.3 or later
11301713e81bSScott Long  * Parameters:
11311713e81bSScott Long  *   idArray - Array ID
11321713e81bSScott Long  *   Lba - block number (on each array member, not logical block!)
11331713e81bSScott Long  *   nSectors - Sectors for each member (RAID 5 will ignore this parameter)
11341713e81bSScott Long  * Returns:
11351713e81bSScott Long  *   0  Success
11361713e81bSScott Long  *   1  Data compare error
11371713e81bSScott Long  *   2  I/O error
11381713e81bSScott Long  */
11391713e81bSScott Long int hpt_verify_data_block(DEVICEID idArray, ULONG Lba, UCHAR nSectors);
11401713e81bSScott Long 
11411713e81bSScott Long #if HPT_INTERFACE_VERSION >= 0x01010000
11421713e81bSScott Long int hpt_verify_data_block_v2(DEVICEID idArray, LBA64 Lba, USHORT nSectors);
11431713e81bSScott Long #endif
11441713e81bSScott Long /*-------------------------------------------------------------------------- */
11451713e81bSScott Long 
11461713e81bSScott Long /* hpt_initialize_data_block
11471713e81bSScott Long  *   initialize data block (fill with zero) on RAID5
11481713e81bSScott Long  * Version compatibility: v1.0.0.3 or later
11491713e81bSScott Long  * Parameters:
11501713e81bSScott Long  *   idArray - Array ID
11511713e81bSScott Long  *   Lba - block number (on each array member, not logical block!)
11521713e81bSScott Long  *   nSectors - Sectors for each member (RAID 5 will ignore this parameter)
11531713e81bSScott Long  * Returns:
11541713e81bSScott Long  *   0  Success
11551713e81bSScott Long  */
11561713e81bSScott Long int hpt_initialize_data_block(DEVICEID idArray, ULONG Lba, UCHAR nSectors);
11571713e81bSScott Long 
11581713e81bSScott Long #if HPT_INTERFACE_VERSION >= 0x01010000
11591713e81bSScott Long int hpt_initialize_data_block_v2(DEVICEID idArray, LBA64 Lba, USHORT nSectors);
11601713e81bSScott Long #endif
11611713e81bSScott Long /*-------------------------------------------------------------------------- */
11621713e81bSScott Long 
11631713e81bSScott Long /* hpt_device_io_ex
11641713e81bSScott Long  *   extended device I/O function
11651713e81bSScott Long  * Version compatibility: v1.0.0.3 or later
11661713e81bSScott Long  * Parameters:
11671713e81bSScott Long  *   idArray - Array ID
11681713e81bSScott Long  *   Lba - block number (on each array member, not logical block!)
11691713e81bSScott Long  *   nSectors - Sectors for each member
11701713e81bSScott Long  *   buffer - I/O buffer or s/g address
11711713e81bSScott Long  * Returns:
11721713e81bSScott Long  *   0  Success
11731713e81bSScott Long  */
11741713e81bSScott Long int hpt_device_io_ex(PDEVICE_IO_EX_PARAMS param);
11751713e81bSScott Long #if HPT_INTERFACE_VERSION >= 0x01010000
11761713e81bSScott Long int hpt_device_io_ex_v2(void * param); /* NOT IMPLEMENTED */
11771713e81bSScott Long #endif
11781713e81bSScott Long /*-------------------------------------------------------------------------- */
11791713e81bSScott Long 
11801713e81bSScott Long /* hpt_set_boot_mark
11811713e81bSScott Long  *   select boot device
11821713e81bSScott Long  * Version compatibility: v1.0.0.3 or later
11831713e81bSScott Long  * Parameters:
11841713e81bSScott Long  *   id - logical device ID. If id is 0 the boot mark will be removed.
11851713e81bSScott Long  * Returns:
11861713e81bSScott Long  *   0  Success
11871713e81bSScott Long  */
11881713e81bSScott Long int hpt_set_boot_mark(DEVICEID id);
11891713e81bSScott Long /*-------------------------------------------------------------------------- */
11901713e81bSScott Long 
11911713e81bSScott Long /* hpt_query_remove
11921713e81bSScott Long  *  check if device can be removed safely
11931713e81bSScott Long  * Version compatibility: v1.0.0.4 or later
11941713e81bSScott Long  * Parameters:
11951713e81bSScott Long  *  ndev - number of devices
11961713e81bSScott Long  *  pIds - device ID list
11971713e81bSScott Long  * Returns:
11981713e81bSScott Long  *  0  - Success
11991713e81bSScott Long  *  -1 - unknown error
12001713e81bSScott Long  *  n  - the n-th device that can't be removed
12011713e81bSScott Long  */
12021713e81bSScott Long int hpt_query_remove(DWORD ndev, DEVICEID *pIds);
12031713e81bSScott Long /*-------------------------------------------------------------------------- */
12041713e81bSScott Long 
12051713e81bSScott Long /* hpt_remove_devices
12061713e81bSScott Long  *  remove a list of devices
12071713e81bSScott Long  * Version compatibility: v1.0.0.4 or later
12081713e81bSScott Long  * Parameters:
12091713e81bSScott Long  *  ndev - number of devices
12101713e81bSScott Long  *  pIds - device ID list
12111713e81bSScott Long  * Returns:
12121713e81bSScott Long  *  0  - Success
12131713e81bSScott Long  *  -1 - unknown error
12141713e81bSScott Long  *  n  - the n-th device that can't be removed
12151713e81bSScott Long  */
12161713e81bSScott Long int hpt_remove_devices(DWORD ndev, DEVICEID *pIds);
12171713e81bSScott Long /*-------------------------------------------------------------------------- */
12181713e81bSScott Long 
121964470755SXin LI /* hpt_ide_pass_through
122064470755SXin LI  *  directly access controller's command and control registers.
122164470755SXin LI  *  Can only call it on physical devices.
122264470755SXin LI  * Version compatibility: v1.0.0.3 or later
122364470755SXin LI  * Parameters:
122464470755SXin LI  *   p - IDE_PASS_THROUGH header pointer
122564470755SXin LI  * Returns:
122664470755SXin LI  *   0  Success
122764470755SXin LI  */
122864470755SXin LI int hpt_ide_pass_through(PIDE_PASS_THROUGH_HEADER p);
122964470755SXin LI /*-------------------------------------------------------------------------- */
123064470755SXin LI 
12311713e81bSScott Long #endif
12321713e81bSScott Long 
12331713e81bSScott Long #pragma pack()
12341713e81bSScott Long #endif
1235