2 * Copyright (c) 2003-2004 HighPoint Technologies, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * time represented in DWORD format
36 #ifdef __BIG_ENDIAN_BITFIELD
37 typedef DWORD TIME_RECORD;
39 typedef struct _TIME_RECORD {
40 UINT seconds:6; /* 0 - 59 */
41 UINT minutes:6; /* 0 - 59 */
42 UINT month:4; /* 1 - 12 */
43 UINT hours:6; /* 0 - 59 */
44 UINT day:5; /* 1 - 31 */
45 UINT year:5; /* 0=2000, 31=2031 */
50 /***************************************************************************
51 * Description: Virtual Device Table
52 ***************************************************************************/
54 typedef struct _RaidArray
59 UCHAR bArnMember; /* the number of members in array */
60 UCHAR bArRealnMember; /* real member count */
61 UCHAR bArBlockSizeShift; /* the number of shift bit for a block */
64 ULONG dArStamp; /* array ID. all disks in a array has same ID */
65 USHORT bStripeWitch; /* = (1 << BlockSizeShift) */
68 USHORT rf_need_rebuild: 1; /* one member's data are incorrect.
69 for R5, if CriticalMembers==0, it means
70 parity needs to be constructed */
71 USHORT rf_need_sync: 1; /* need write array info to disk */
73 USHORT rf_auto_rebuild: 1;
74 USHORT rf_newly_created: 1;
75 USHORT rf_rebuilding: 1;
76 USHORT rf_verifying: 1;
77 USHORT rf_initializing: 1;
78 USHORT rf_abort_rebuild: 1;
79 USHORT rf_duplicate_and_create: 1;
80 USHORT rf_duplicate_and_created: 1;
81 USHORT rf_duplicate_must_done: 1;
84 USHORT CriticalMembers; /* tell which member is critial */
85 UCHAR last_read; /* for RAID 1 load banlancing */
88 LBA_T RebuildSectors; /* how many sectors is OK (LBA on member disk) */
90 PVDevice pMember[MAX_MEMBERS];
92 * utility working data
94 UCHAR ArrayName[MAX_ARRAY_NAME]; /* The Name of the array */
95 TIME_RECORD CreateTime; /* when created it */
96 UCHAR Description[64]; /* array description */
97 UCHAR CreateManager[16]; /* who created it */
100 /***************************************************************************
101 * Array Descripton on disk
102 ***************************************************************************/
104 typedef struct _ArrayDescript
106 ULONG Signature; /* This block is vaild array info block */
107 ULONG dArStamp; /* array ID. all disks in a array has same ID */
109 UCHAR bCheckSum; /* check sum of ArrayDescript_3_0_size bytes */
111 #ifdef __BIG_ENDIAN_BITFIELD
112 UCHAR df_reservedbits: 6; /* put more flags here */
113 UCHAR df_user_mode_set: 1;/* user select device mode */
114 UCHAR df_bootmark:1; /* user set boot mark on the disk */
116 UCHAR df_bootmark:1; /* user set boot mark on the disk */
117 UCHAR df_user_mode_set: 1;/* user select device mode */
118 UCHAR df_reservedbits: 6; /* put more flags here */
121 UCHAR bUserDeviceMode; /* see device.h */
122 UCHAR ArrayLevel; /* how many level[] is valid */
125 ULONG Capacity; /* capacity for the array */
127 UCHAR VDeviceType; /* see above & arrayType in array.h */
128 UCHAR bMemberCount; /* all disk in the array */
129 UCHAR bSerialNumber; /* Serial Number */
130 UCHAR bArBlockSizeShift; /* the number of shift bit for a block */
132 #ifdef __BIG_ENDIAN_BITFIELD
133 USHORT rf_reserved: 14;
134 USHORT rf_raid15: 1; /* don't remove even you don't use it */
135 USHORT rf_need_rebuild:1; /* array is critical */
137 USHORT rf_need_rebuild:1; /* array is critical */
138 USHORT rf_raid15: 1; /* don't remove even you don't use it */
139 USHORT rf_reserved: 14;
141 USHORT CriticalMembers; /* record critical members */
142 ULONG RebuildSectors; /* how many sectors is OK (LBA on member disk) */
145 UCHAR ArrayName[MAX_ARRAY_NAME]; /* The Name of the array */
146 TIME_RECORD CreateTime; /* when created it */
147 UCHAR Description[64]; /* array description */
148 UCHAR CreateManager[16]; /* who created it */
150 #define ArrayDescript_3_0_size ((unsigned)(ULONG_PTR)&((struct _ArrayDescript *)0)->bCheckSum31)
151 #define ArrayDescript_3_1_size 512
153 UCHAR bCheckSum31; /* new check sum */
155 #ifdef __BIG_ENDIAN_BITFIELD
156 UCHAR df_read_ahead: 1; /* enable read ahead */
157 UCHAR df_read_ahead_set: 1;
158 UCHAR df_write_cache: 1; /* enable write cache */
159 UCHAR df_write_cache_set: 1;
160 UCHAR df_ncq: 1; /* enable NCQ */
162 UCHAR df_tcq: 1; /* enable TCQ */
166 UCHAR df_tcq: 1; /* enable TCQ */
168 UCHAR df_ncq: 1; /* enable NCQ */
169 UCHAR df_write_cache_set: 1;
170 UCHAR df_write_cache: 1; /* enable write cache */
171 UCHAR df_read_ahead_set: 1;
172 UCHAR df_read_ahead: 1; /* enable read ahead */
177 ULONG RebuildSectorsHi32;
186 #define HPT_ARRAY_V3 0x5a7816f3
188 #define SAVE_FOR_RAID_INFO 0
190 #define SAVE_FOR_RAID_INFO 10
193 /***************************************************************************
194 * Function protocol for array layer
195 ***************************************************************************/
200 ULONG FASTCALL GetStamp(void);
201 void HPTLIBAPI SyncArrayInfo(PVDevice pVDev);
202 void HPTLIBAPI fDeleteArray(_VBUS_ARG PVDevice pVArray, BOOLEAN del_block0);
207 void HPTLIBAPI fCheckArray(PDevice pDevice);
208 void HPTLIBAPI CheckArrayCritical(_VBUS_ARG0);
209 PVDevice HPTLIBAPI GetSpareDisk(_VBUS_ARG PVDevice pArray);
210 #ifdef SUPPORT_OLD_ARRAY
211 void HPTLIBAPI fFixRAID01Stripe(_VBUS_ARG PVDevice pStripe);
214 /***************************************************************************
216 ***************************************************************************/
217 #ifndef MAX_ARRAY_PER_VBUS
218 #define MAX_ARRAY_PER_VBUS (MAX_VDEVICE_PER_VBUS*2) /* worst case */
222 #if defined(MAX_ARRAY_DEVICE)
223 #if MAX_ARRAY_DEVICE!=MAX_ARRAY_PER_VBUS
224 #error "remove MAX_ARRAY_DEVICE and use MAX_ARRAY_PER_VBUS instead"
228 #define _SET_ARRAY_BUS_(pArray) pArray->pVBus = _vbus_p;
231 #define _SET_ARRAY_VER_(pArray) pArray->vf_format_v2 = 1;
233 #define _SET_ARRAY_VER_(pArray)
236 #define mArGetArrayTable(pVArray) \
237 if((pVArray = _vbus_(pFreeArrayLink)) != 0) { \
238 _vbus_(pFreeArrayLink) = (PVDevice)_vbus_(pFreeArrayLink)->pVBus; \
239 ZeroMemory(pVArray, ARRAY_VDEV_SIZE); \
240 _SET_ARRAY_BUS_(pVArray) \
241 _SET_ARRAY_VER_(pVArray) \
244 #define mArFreeArrayTable(pVArray) \
246 pVArray->pVBus = (PVBus)_vbus_(pFreeArrayLink);\
247 _vbus_(pFreeArrayLink) = pVArray; \
248 pVArray->u.array.dArStamp = 0; \
251 UCHAR CheckSum(UCHAR *p, int size);
253 void HPTLIBAPI fRAID0SendCommand(_VBUS_ARG PCommand pCmd);
254 void HPTLIBAPI fRAID1SendCommand(_VBUS_ARG PCommand pCmd);
255 void HPTLIBAPI fJBODSendCommand(_VBUS_ARG PCommand pCmd);
256 void HPTLIBAPI fRAID0MemberFailed(_VBUS_ARG PVDevice pVDev);
257 void HPTLIBAPI fRAID1MemberFailed(_VBUS_ARG PVDevice pVDev);
258 void HPTLIBAPI fJBODMemberFailed(_VBUS_ARG PVDevice pVDev);
260 void HPTLIBAPI fRAID5SendCommand(_VBUS_ARG PCommand pCmd);
261 void HPTLIBAPI fRAID5MemberFailed(_VBUS_ARG PVDevice pVDev);
263 #define fRAID5SendCommand 0
264 #define fRAID5MemberFailed 0