]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/ata/ata-raid.h
This commit was generated by cvs2svn to compensate for changes in r147001,
[FreeBSD/FreeBSD.git] / sys / dev / ata / ata-raid.h
1 /*-
2  * Copyright (c) 2000 - 2005 Søren Schmidt <sos@FreeBSD.org>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer,
10  *    without modification, immediately at the beginning of the file.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. The name of the author may not be used to endorse or promote products
15  *    derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * $FreeBSD$
29  */
30
31 /* misc defines */
32 #define MAX_ARRAYS      16
33 #define MAX_DISKS       16
34 #define AR_PROXIMITY    2048    /* how many sectors is "close" */
35
36 #define ATA_MAGIC       "FreeBSD ATA driver RAID "
37
38 struct ata_raid_subdisk {
39     struct ar_softc     *raid;
40     int                 disk_number;
41 };
42
43 /*  ATA PseudoRAID Metadata */
44 struct ar_softc {
45     int                 lun;            /* logical unit number of this RAID */
46     u_int8_t            name[32];       /* name of array if any */
47     u_int64_t           magic_0;        /* magic for this array */
48     u_int64_t           magic_1;        /* magic for this array */
49     int                 type;
50 #define AR_T_JBOD               0x0001
51 #define AR_T_SPAN               0x0002
52 #define AR_T_RAID0              0x0004
53 #define AR_T_RAID1              0x0008
54 #define AR_T_RAID01             0x0010  
55 #define AR_T_RAID3              0x0020
56 #define AR_T_RAID4              0x0040
57 #define AR_T_RAID5              0x0080
58
59     int                 status;
60 #define AR_S_READY              0x0001
61 #define AR_S_DEGRADED           0x0002
62 #define AR_S_REBUILDING         0x0004
63
64     int                 format;
65 #define AR_F_FREEBSD_RAID       0x0001
66 #define AR_F_ADAPTEC_RAID       0x0002
67 #define AR_F_HPTV2_RAID         0x0004
68 #define AR_F_HPTV3_RAID         0x0008
69 #define AR_F_INTEL_RAID         0x0010
70 #define AR_F_ITE_RAID           0x0020
71 #define AR_F_LSIV2_RAID         0x0040
72 #define AR_F_LSIV3_RAID         0x0080
73 #define AR_F_PROMISE_RAID       0x0100
74 #define AR_F_SII_RAID           0x0200
75 #define AR_F_VIA_RAID           0x0400
76 #define AR_F_FORMAT_MASK        0x07ff
77
78     u_int               generation;     /* generation of this array */
79     u_int64_t           total_sectors;
80     u_int64_t           offset_sectors; /* offset from start of disk */
81     u_int16_t           heads;
82     u_int16_t           sectors;
83     u_int32_t           cylinders;
84     u_int               width;          /* array width in disks */
85     u_int               interleave;     /* interleave in blocks */
86     u_int               total_disks;    /* number of disks in this array */
87     struct ar_disk {
88         device_t        dev;
89         u_int8_t        serial[16];     /* serial # of physical disk */
90         u_int64_t       sectors;        /* useable sectors on this disk */
91         off_t           last_lba;       /* last lba used (for performance) */
92         u_int           flags;
93 #define AR_DF_PRESENT           0x0001  /* this HW pos has a disk present */
94 #define AR_DF_ASSIGNED          0x0002  /* this HW pos assigned to an array */
95 #define AR_DF_SPARE             0x0004  /* this HW pos is a spare */
96 #define AR_DF_ONLINE            0x0008  /* this HW pos is online and in use */
97
98     } disks[MAX_DISKS];
99     int                 toggle;         /* performance hack for RAID1's */
100     u_int64_t           rebuild_lba;    /* rebuild progress indicator */
101     struct mtx          lock;           /* metadata lock */
102     struct disk         *disk;          /* disklabel/slice stuff */
103     struct proc         *pid;           /* rebuilder process id */
104 };
105
106 /* Adaptec HostRAID Metadata */
107 #define ADP_LBA(dev) \
108         (((struct ad_softc *)device_get_ivars(dev))->total_secs - 17)
109
110 /* note all entries are big endian */
111 struct adaptec_raid_conf {
112     u_int32_t           magic_0;
113 #define ADP_MAGIC_0             0xc4650790
114
115     u_int32_t           generation;
116     u_int16_t           dummy_0;
117     u_int16_t           total_configs;
118     u_int16_t           dummy_1;
119     u_int16_t           checksum;
120     u_int32_t           dummy_2;
121     u_int32_t           dummy_3;
122     u_int32_t           flags;
123     u_int32_t           timestamp;
124     u_int32_t           dummy_4[4];
125     u_int32_t           dummy_5[4];
126     struct {
127         u_int16_t       total_disks;
128         u_int16_t       generation;
129         u_int32_t       magic_0;
130         u_int8_t        dummy_0;
131         u_int8_t        type;
132 #define ADP_T_RAID0             0x00
133 #define ADP_T_RAID1             0x01
134         u_int8_t        dummy_1;
135         u_int8_t        flags;
136
137         u_int8_t        dummy_2;
138         u_int8_t        dummy_3;
139         u_int8_t        dummy_4;
140         u_int8_t        dummy_5;
141
142         u_int32_t       disk_number;
143         u_int32_t       dummy_6;
144         u_int32_t       sectors;
145         u_int16_t       stripe_shift;
146         u_int16_t       dummy_7;
147
148         u_int32_t       dummy_8[4];
149         u_int8_t        name[16];
150     } configs[127];
151     u_int32_t           dummy_6[13];
152     u_int32_t           magic_1;
153 #define ADP_MAGIC_1             0x9ff85009
154     u_int32_t           dummy_7[3];
155     u_int32_t           magic_2;
156     u_int32_t           dummy_8[46];
157     u_int32_t           magic_3;
158 #define ADP_MAGIC_3             0x4d545044
159     u_int32_t           magic_4;
160 #define ADP_MAGIC_4             0x9ff85009
161     u_int32_t           dummy_9[62];
162 } __packed;
163
164
165 /* Highpoint V2 RocketRAID Metadata */
166 #define HPTV2_LBA(dev)  9
167
168 struct hptv2_raid_conf {
169     int8_t              filler1[32];
170     u_int32_t           magic;
171 #define HPTV2_MAGIC_OK          0x5a7816f0
172 #define HPTV2_MAGIC_BAD         0x5a7816fd
173
174     u_int32_t           magic_0;
175     u_int32_t           magic_1;
176     u_int32_t           order;
177 #define HPTV2_O_RAID0           0x01
178 #define HPTV2_O_RAID1           0x02
179 #define HPTV2_O_OK              0x04
180
181     u_int8_t            array_width;
182     u_int8_t            stripe_shift;
183     u_int8_t            type;
184 #define HPTV2_T_RAID0           0x00
185 #define HPTV2_T_RAID1           0x01
186 #define HPTV2_T_RAID01_RAID0    0x02
187 #define HPTV2_T_SPAN            0x03
188 #define HPTV2_T_RAID_3          0x04
189 #define HPTV2_T_RAID_5          0x05
190 #define HPTV2_T_JBOD            0x06
191 #define HPTV2_T_RAID01_RAID1    0x07
192
193     u_int8_t            disk_number;
194     u_int32_t           total_sectors;
195     u_int32_t           disk_mode;
196     u_int32_t           boot_mode;
197     u_int8_t            boot_disk;
198     u_int8_t            boot_protect;
199     u_int8_t            error_log_entries;
200     u_int8_t            error_log_index;
201     struct {
202         u_int32_t       timestamp;
203         u_int8_t        reason;
204 #define HPTV2_R_REMOVED         0xfe
205 #define HPTV2_R_BROKEN          0xff
206         
207         u_int8_t        disk;
208         u_int8_t        status;
209         u_int8_t        sectors;
210         u_int32_t       lba;
211     } errorlog[32];
212     int8_t              filler2[16];
213     u_int32_t           rebuild_lba;
214     u_int8_t            dummy_1;
215     u_int8_t            name_1[15];
216     u_int8_t            dummy_2;
217     u_int8_t            name_2[15];
218     int8_t              filler3[8];
219 } __packed;
220
221
222 /* Highpoint V3 RocketRAID Metadata */
223 #define HPTV3_LBA(dev) \
224         (((struct ad_softc *)device_get_ivars(dev))->total_secs - 11)
225
226 struct hptv3_raid_conf {
227     u_int32_t           magic;
228 #define HPTV3_MAGIC             0x5a7816f3
229
230     u_int32_t           magic_0;
231     u_int8_t            checksum_0;
232     u_int8_t            mode;
233 #define HPTV3_BOOT_MARK         0x01
234 #define HPTV3_USER_MODE         0x02
235     
236     u_int8_t            user_mode;
237     u_int8_t            config_entries;
238     struct {
239         u_int32_t       total_sectors;
240         u_int8_t        type;
241 #define HPTV3_T_SPARE           0x00
242 #define HPTV3_T_JBOD            0x03
243 #define HPTV3_T_SPAN            0x04
244 #define HPTV3_T_RAID0           0x05
245 #define HPTV3_T_RAID1           0x06
246 #define HPTV3_T_RAID3           0x07
247 #define HPTV3_T_RAID5           0x08
248
249         u_int8_t        total_disks;
250         u_int8_t        disk_number;
251         u_int8_t        stripe_shift;
252         u_int16_t       status;
253 #define HPTV3_T_NEED_REBUILD    0x01
254 #define HPTV3_T_RAID5_FLAG      0x02
255
256         u_int16_t       critical_disks;
257         u_int32_t       rebuild_lba;
258     } __packed configs[2];
259     u_int8_t            name[16];
260     u_int32_t           timestamp;
261     u_int8_t            description[64];
262     u_int8_t            creator[16];
263     u_int8_t            checksum_1;
264     u_int8_t            dummy_0;
265     u_int8_t            dummy_1;
266     u_int8_t            flags;
267 #define HPTV3_T_ENABLE_TCQ      0x01
268 #define HPTV3_T_ENABLE_NCQ      0x02
269 #define HPTV3_T_ENABLE_WCACHE   0x04
270 #define HPTV3_T_ENABLE_RCACHE   0x08
271
272     struct {
273         u_int32_t       total_sectors;
274         u_int32_t       rebuild_lba;
275     } __packed configs_high[2];
276     u_int32_t           filler[87];
277 } __packed;
278
279
280 /* Intel MatrixRAID Metadata */
281 #define INTEL_LBA(dev) \
282         (((struct ad_softc *)device_get_ivars(dev))->total_secs - 2)
283
284 struct intel_raid_conf {
285     u_int8_t            intel_id[24];
286 #define INTEL_MAGIC             "Intel Raid ISM Cfg Sig. "
287
288     u_int8_t            version[6];
289     u_int8_t            dummy_0[2];
290     u_int32_t           checksum;
291     u_int32_t           config_size;
292     u_int32_t           config_id;
293     u_int32_t           generation;
294     u_int32_t           dummy_1[2];
295     u_int8_t            total_disks;
296     u_int8_t            total_volumes;
297     u_int8_t            dummy_2[2];
298     u_int32_t           filler_0[39];
299     struct {
300         u_int8_t        serial[16];
301         u_int32_t       sectors;
302         u_int32_t       id;
303         u_int32_t       flags;
304 #define INTEL_F_SPARE           0x01
305 #define INTEL_F_ASSIGNED        0x02
306 #define INTEL_F_DOWN            0x04
307 #define INTEL_F_ONLINE          0x08
308
309         u_int32_t       filler[5];
310     } __packed disk[1];
311     u_int32_t           filler_1[62];
312 } __packed;
313
314 struct intel_raid_mapping {
315     u_int8_t            name[16];
316     u_int64_t           total_sectors __packed;
317     u_int32_t           state;
318     u_int32_t           reserved;
319     u_int32_t           filler_1[20];
320     u_int32_t           offset;
321     u_int32_t           disk_sectors;
322     u_int32_t           stripe_count;
323     u_int16_t           stripe_sectors;
324     u_int8_t            status;
325 #define INTEL_S_READY           0x00
326 #define INTEL_S_DISABLED        0x01
327 #define INTEL_S_DEGRADED        0x02
328 #define INTEL_S_FAILURE         0x03
329
330     u_int8_t            type;
331 #define INTEL_T_RAID0           0x00
332 #define INTEL_T_RAID1           0x01
333
334     u_int8_t            total_disks;
335     u_int8_t            dummy_2[3];
336     u_int32_t           filler_2[7];
337     u_int32_t           disk_idx[1];
338 } __packed;
339
340
341 /* Integrated Technology Express Metadata */
342 #define ITE_LBA(dev) \
343         (((struct ad_softc *)device_get_ivars(dev))->total_secs - 2)
344
345 struct ite_raid_conf {
346     u_int32_t           filler_1[5];
347     u_int8_t            timestamp_0[8];
348     u_int32_t           dummy_1;
349     u_int32_t           filler_2[5];
350     u_int16_t           filler_3;
351     u_int8_t            ite_id[40];
352 #define ITE_MAGIC               "Integrated Technology Express Inc      "
353
354     u_int16_t           filler_4;
355     u_int32_t           filler_5[6];
356     u_int32_t           dummy_2;
357     u_int32_t           dummy_3;
358     u_int32_t           filler_6[12];
359     u_int32_t           dummy_4;
360     u_int32_t           filler_7[5];
361     u_int64_t           total_sectors __packed;
362     u_int32_t           filler_8[12];
363     
364     u_int16_t           filler_9;
365     u_int8_t            type;
366 #define ITE_T_RAID0             0x00
367 #define ITE_T_RAID1             0x01
368 #define ITE_T_RAID01            0x02
369 #define ITE_T_SPAN              0x03
370
371     u_int8_t            filler_10;
372     u_int32_t           dummy_5[8];
373     u_int8_t            stripe_1kblocks;
374     u_int8_t            filler_11[3];
375     u_int32_t           filler_12[54];
376
377     u_int32_t           dummy_6[4];
378     u_int8_t            timestamp_1[8];
379     u_int32_t           filler_13[9];
380     u_int8_t            stripe_sectors;
381     u_int8_t            filler_14[3];
382     u_int8_t            array_width;
383     u_int8_t            filler_15[3];
384     u_int32_t           filler_16;
385     u_int8_t            filler_17;
386     u_int8_t            disk_number;
387     u_int32_t           disk_sectors;
388     u_int16_t           filler_18;
389     u_int32_t           dummy_7[4];
390     u_int32_t           filler_20[104];
391 } __packed;
392
393
394 /* LSILogic V2 MegaRAID Metadata */
395 #define LSIV2_LBA(dev) \
396         (((struct ad_softc *)device_get_ivars(dev))->total_secs - 1)
397
398 struct lsiv2_raid_conf {
399     u_int8_t            lsi_id[6];
400 #define LSIV2_MAGIC             "$XIDE$"
401
402     u_int8_t            dummy_0;
403     u_int8_t            flags;
404     u_int16_t           version;
405     u_int8_t            config_entries;
406     u_int8_t            raid_count;
407     u_int8_t            total_disks;
408     u_int8_t            dummy_1;
409     u_int16_t           dummy_2;
410
411     union {
412         struct {
413             u_int8_t    type;
414 #define LSIV2_T_RAID0           0x01
415 #define LSIV2_T_RAID1           0x02
416 #define LSIV2_T_SPARE           0x08
417
418             u_int8_t    dummy_0;
419             u_int16_t   stripe_sectors;
420             u_int8_t    array_width;
421             u_int8_t    disk_count;
422             u_int8_t    config_offset;
423             u_int8_t    dummy_1;
424             u_int8_t    flags;
425 #define LSIV2_R_DEGRADED        0x02
426
427             u_int32_t   total_sectors;
428             u_int8_t    filler[3];
429         } __packed raid;
430         struct {
431             u_int8_t    device;
432 #define LSIV2_D_MASTER          0x00
433 #define LSIV2_D_SLAVE           0x01
434 #define LSIV2_D_CHANNEL0        0x00
435 #define LSIV2_D_CHANNEL1        0x10
436 #define LSIV2_D_NONE            0xff
437
438             u_int8_t    dummy_0;
439             u_int32_t   disk_sectors;
440             u_int8_t    disk_number;
441             u_int8_t    raid_number;
442             u_int8_t    flags;
443 #define LSIV2_D_GONE            0x02
444
445             u_int8_t    filler[7];
446         } __packed disk;
447     } configs[30];
448     u_int8_t            disk_number;
449     u_int8_t            raid_number;
450     u_int32_t           timestamp;
451     u_int8_t            filler[10];
452 } __packed;
453
454
455 /* LSILogic V3 MegaRAID Metadata */
456 #define LSIV3_LBA(dev) \
457         (((struct ad_softc *)device_get_ivars(dev))->total_secs - 4)
458
459 struct lsiv3_raid_conf {
460     u_int32_t           magic_0;        /* 0xa0203200 */
461     u_int32_t           filler_0[3];
462     u_int8_t            magic_1[4];     /* "SATA" */
463     u_int32_t           filler_1[40];
464     u_int32_t           dummy_0;        /* 0x0d000003 */
465     u_int32_t           filler_2[7];
466     u_int32_t           dummy_1;        /* 0x0d000003 */
467     u_int32_t           filler_3[70];
468     u_int8_t            magic_2[8];     /* "$_ENQ$31" */
469     u_int8_t            filler_4[7];
470     u_int8_t            checksum_0;
471     u_int8_t            filler_5[512*2];
472     u_int8_t            lsi_id[6];
473 #define LSIV3_MAGIC             "$_IDE$"
474
475     u_int16_t           dummy_2;        /* 0x33de for OK disk */
476     u_int16_t           version;        /* 0x0131 for this version */
477     u_int16_t           dummy_3;        /* 0x0440 always */
478     u_int32_t           filler_6;
479
480     struct {
481         u_int16_t       stripe_pages;
482         u_int8_t        type;
483 #define LSIV3_T_RAID0           0x00
484 #define LSIV3_T_RAID1           0x01
485
486         u_int8_t        dummy_0;
487         u_int8_t        total_disks;
488         u_int8_t        array_width;
489         u_int8_t        filler_0[10];
490
491         u_int32_t       sectors;
492         u_int16_t       dummy_1;
493         u_int32_t       offset;
494         u_int16_t       dummy_2;
495         u_int8_t        device;
496 #define LSIV3_D_DEVICE          0x01
497 #define LSIV3_D_CHANNEL         0x10
498
499         u_int8_t        dummy_3;
500         u_int8_t        dummy_4;
501         u_int8_t        dummy_5;
502         u_int8_t        filler_1[16];
503     } __packed raid[8];
504     struct {
505         u_int32_t       disk_sectors;
506         u_int32_t       dummy_0;
507         u_int32_t       dummy_1;
508         u_int8_t        dummy_2;
509         u_int8_t        dummy_3;
510         u_int8_t        flags;
511 #define LSIV3_D_MIRROR          0x00
512 #define LSIV3_D_STRIPE          0xff
513         u_int8_t        dummy_4;
514     } __packed disk[6];
515     u_int8_t            filler_7[7];
516     u_int8_t            device;
517     u_int32_t           timestamp;
518     u_int8_t            filler_8[3];
519     u_int8_t            checksum_1;
520 } __packed;
521
522
523 /* Promise FastTrak Metadata */
524 #define PR_LBA(dev) \
525         (((((struct ad_softc *)device_get_ivars(dev))->total_secs / (((struct ad_softc *)device_get_ivars(dev))->heads * ((struct ad_softc *)device_get_ivars(dev))->sectors)) * ((struct ad_softc *)device_get_ivars(dev))->heads * ((struct ad_softc *)device_get_ivars(dev))->sectors) - ((struct ad_softc *)device_get_ivars(dev))->sectors)
526
527 struct promise_raid_conf {
528     char                promise_id[24];
529 #define PR_MAGIC                "Promise Technology, Inc."
530
531     u_int32_t           dummy_0;
532     u_int64_t           magic_0;
533 #define PR_MAGIC0(x)            (((u_int64_t)(x.channel) << 48) | \
534                                 ((u_int64_t)(x.device != 0) << 56))
535     u_int16_t           magic_1;
536     u_int32_t           magic_2;
537     u_int8_t            filler1[470];
538     struct {
539         u_int32_t       integrity;
540 #define PR_I_VALID              0x00000080
541
542         u_int8_t        flags;
543 #define PR_F_VALID              0x00000001
544 #define PR_F_ONLINE             0x00000002
545 #define PR_F_ASSIGNED           0x00000004
546 #define PR_F_SPARE              0x00000008
547 #define PR_F_DUPLICATE          0x00000010
548 #define PR_F_REDIR              0x00000020
549 #define PR_F_DOWN               0x00000040
550 #define PR_F_READY              0x00000080
551
552         u_int8_t        disk_number;
553         u_int8_t        channel;
554         u_int8_t        device;
555         u_int64_t       magic_0 __packed;
556         u_int32_t       disk_offset;
557         u_int32_t       disk_sectors;
558         u_int32_t       rebuild_lba;
559         u_int16_t       generation;
560         u_int8_t        status;
561 #define PR_S_VALID              0x01
562 #define PR_S_ONLINE             0x02
563 #define PR_S_INITED             0x04
564 #define PR_S_READY              0x08
565 #define PR_S_DEGRADED           0x10
566 #define PR_S_MARKED             0x20
567 #define PR_S_FUNCTIONAL         0x80
568
569         u_int8_t        type;
570 #define PR_T_RAID0              0x00
571 #define PR_T_RAID1              0x01
572 #define PR_T_RAID3              0x02
573 #define PR_T_RAID5              0x04
574 #define PR_T_SPAN               0x08
575 #define PR_T_JBOD               0x10
576
577         u_int8_t        total_disks;
578         u_int8_t        stripe_shift;
579         u_int8_t        array_width;
580         u_int8_t        array_number;
581         u_int32_t       total_sectors;
582         u_int16_t       cylinders;
583         u_int8_t        heads;
584         u_int8_t        sectors;
585         u_int64_t       magic_1 __packed;
586         struct {
587             u_int8_t    flags;
588             u_int8_t    dummy_0;
589             u_int8_t    channel;
590             u_int8_t    device;
591             u_int64_t   magic_0 __packed;
592         } disk[8];
593     } raid;
594     int32_t             filler2[346];
595     u_int32_t           checksum;
596 } __packed;
597
598
599 /* Silicon Image Medley Metadata */
600 #define SII_LBA(dev) \
601         ( ((struct ad_softc *)device_get_ivars(dev))->total_secs - 1)
602
603 struct sii_raid_conf {
604     u_int16_t   ata_params_00_53[54];
605     u_int64_t   total_sectors;
606     u_int16_t   ata_params_58_79[70];
607     u_int16_t   dummy_0;
608     u_int16_t   dummy_1;
609     u_int32_t   controller_pci_id;
610     u_int16_t   version_minor;
611     u_int16_t   version_major;
612     u_int8_t    timestamp[6];
613     u_int16_t   stripe_sectors;
614     u_int16_t   dummy_2;
615     u_int8_t    disk_number;
616     u_int8_t    type;
617 #define SII_T_RAID0             0x00
618 #define SII_T_RAID1             0x01
619 #define SII_T_RAID01            0x02
620 #define SII_T_SPARE             0x03
621
622     u_int8_t    raid0_disks;
623     u_int8_t    raid0_ident;
624     u_int8_t    raid1_disks;
625     u_int8_t    raid1_ident;
626     u_int64_t   rebuild_lba;
627     u_int32_t   generation;
628     u_int8_t    status;
629 #define SII_S_READY             0x01
630     
631     u_int8_t    base_raid1_position;
632     u_int8_t    base_raid0_position;
633     u_int8_t    position;
634     u_int16_t   dummy_3;
635     u_int8_t    name[16];
636     u_int16_t   checksum_0;
637     int8_t      filler1[190];
638     u_int16_t   checksum_1;
639 } __packed;
640
641
642 /* VIA Tech V-RAID Metadata */
643 #define VIA_LBA(dev) \
644         ( ((struct ad_softc *)device_get_ivars(dev))->total_secs - 1)
645
646 struct via_raid_conf {
647     u_int16_t   magic;
648 #define VIA_MAGIC               0xaa55
649
650     u_int8_t    dummy_0;
651     u_int8_t    type;
652 #define VIA_T_MASK              0xfe
653 #define VIA_T_BOOTABLE          0x01
654 #define VIA_T_RAID0             0x04
655 #define VIA_T_RAID1             0x0c
656 #define VIA_T_SPAN              0x44
657
658     u_int8_t    disk_index;
659     u_int8_t    stripe_layout;
660 #define VIA_L_MASK              0x07
661 #define VIA_L_SHIFT             4
662
663     u_int64_t   total_sectors;
664     u_int32_t   disk_id;
665     u_int32_t   disks[8];
666     u_int8_t    checksum;
667     u_int8_t    filler_1[461];
668 } __packed;