]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/ata/ata-raid.h
This commit was generated by cvs2svn to compensate for changes in r153200,
[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_VOLUMES     4
34 #define MAX_DISKS       16
35 #define AR_PROXIMITY    2048    /* how many sectors is "close" */
36
37 #define ATA_MAGIC       "FreeBSD ATA driver RAID "
38
39 struct ata_raid_subdisk {
40     struct ar_softc     *raid[MAX_VOLUMES];
41     int                 disk_number[MAX_VOLUMES];
42 };
43
44 /*  ATA PseudoRAID Metadata */
45 struct ar_softc {
46     int                 lun;
47     u_int8_t            name[32];
48     int                 volume;
49     u_int64_t           magic_0;
50     u_int64_t           magic_1;
51     int                 type;
52 #define AR_T_JBOD               0x0001
53 #define AR_T_SPAN               0x0002
54 #define AR_T_RAID0              0x0004
55 #define AR_T_RAID1              0x0008
56 #define AR_T_RAID01             0x0010  
57 #define AR_T_RAID3              0x0020
58 #define AR_T_RAID4              0x0040
59 #define AR_T_RAID5              0x0080
60
61     int                 status;
62 #define AR_S_READY              0x0001
63 #define AR_S_DEGRADED           0x0002
64 #define AR_S_REBUILDING         0x0004
65
66     int                 format;
67 #define AR_F_FREEBSD_RAID       0x0001
68 #define AR_F_ADAPTEC_RAID       0x0002
69 #define AR_F_HPTV2_RAID         0x0004
70 #define AR_F_HPTV3_RAID         0x0008
71 #define AR_F_INTEL_RAID         0x0010
72 #define AR_F_ITE_RAID           0x0020
73 #define AR_F_LSIV2_RAID         0x0040
74 #define AR_F_LSIV3_RAID         0x0080
75 #define AR_F_NVIDIA_RAID        0x0100
76 #define AR_F_PROMISE_RAID       0x0200
77 #define AR_F_SII_RAID           0x0400
78 #define AR_F_SIS_RAID           0x0800
79 #define AR_F_VIA_RAID           0x1000
80 #define AR_F_FORMAT_MASK        0x1fff
81
82     u_int               generation;
83     u_int64_t           total_sectors;
84     u_int64_t           offset_sectors; /* offset from start of disk */
85     u_int16_t           heads;
86     u_int16_t           sectors;
87     u_int32_t           cylinders;
88     u_int               width;          /* array width in disks */
89     u_int               interleave;     /* interleave in sectors */
90     u_int               total_disks;    /* number of disks in this array */
91     struct ar_disk {
92         device_t        dev;
93         u_int8_t        serial[16];     /* serial # of physical disk */
94         u_int64_t       sectors;        /* useable sectors on this disk */
95         off_t           last_lba;       /* last lba used (for performance) */
96         u_int           flags;
97 #define AR_DF_PRESENT           0x0001  /* this HW pos has a disk present */
98 #define AR_DF_ASSIGNED          0x0002  /* this HW pos assigned to an array */
99 #define AR_DF_SPARE             0x0004  /* this HW pos is a spare */
100 #define AR_DF_ONLINE            0x0008  /* this HW pos is online and in use */
101
102     } disks[MAX_DISKS];
103     int                 toggle;         /* performance hack for RAID1's */
104     u_int64_t           rebuild_lba;    /* rebuild progress indicator */
105     struct mtx          lock;           /* metadata lock */
106     struct disk         *disk;          /* disklabel/slice stuff */
107     struct proc         *pid;           /* rebuilder process id */
108 };
109
110 /* Adaptec HostRAID Metadata */
111 #define ADP_LBA(dev) \
112         (((struct ad_softc *)device_get_ivars(dev))->total_secs - 17)
113
114 /* note all entries are big endian */
115 struct adaptec_raid_conf {
116     u_int32_t           magic_0;
117 #define ADP_MAGIC_0             0xc4650790
118
119     u_int32_t           generation;
120     u_int16_t           dummy_0;
121     u_int16_t           total_configs;
122     u_int16_t           dummy_1;
123     u_int16_t           checksum;
124     u_int32_t           dummy_2;
125     u_int32_t           dummy_3;
126     u_int32_t           flags;
127     u_int32_t           timestamp;
128     u_int32_t           dummy_4[4];
129     u_int32_t           dummy_5[4];
130     struct {
131         u_int16_t       total_disks;
132         u_int16_t       generation;
133         u_int32_t       magic_0;
134         u_int8_t        dummy_0;
135         u_int8_t        type;
136 #define ADP_T_RAID0             0x00
137 #define ADP_T_RAID1             0x01
138         u_int8_t        dummy_1;
139         u_int8_t        flags;
140
141         u_int8_t        dummy_2;
142         u_int8_t        dummy_3;
143         u_int8_t        dummy_4;
144         u_int8_t        dummy_5;
145
146         u_int32_t       disk_number;
147         u_int32_t       dummy_6;
148         u_int32_t       sectors;
149         u_int16_t       stripe_shift;
150         u_int16_t       dummy_7;
151
152         u_int32_t       dummy_8[4];
153         u_int8_t        name[16];
154     } configs[127];
155     u_int32_t           dummy_6[13];
156     u_int32_t           magic_1;
157 #define ADP_MAGIC_1             0x9ff85009
158     u_int32_t           dummy_7[3];
159     u_int32_t           magic_2;
160     u_int32_t           dummy_8[46];
161     u_int32_t           magic_3;
162 #define ADP_MAGIC_3             0x4d545044
163     u_int32_t           magic_4;
164 #define ADP_MAGIC_4             0x9ff85009
165     u_int32_t           dummy_9[62];
166 } __packed;
167
168
169 /* Highpoint V2 RocketRAID Metadata */
170 #define HPTV2_LBA(dev)  9
171
172 struct hptv2_raid_conf {
173     int8_t              filler1[32];
174     u_int32_t           magic;
175 #define HPTV2_MAGIC_OK          0x5a7816f0
176 #define HPTV2_MAGIC_BAD         0x5a7816fd
177
178     u_int32_t           magic_0;
179     u_int32_t           magic_1;
180     u_int32_t           order;
181 #define HPTV2_O_RAID0           0x01
182 #define HPTV2_O_RAID1           0x02
183 #define HPTV2_O_OK              0x04
184
185     u_int8_t            array_width;
186     u_int8_t            stripe_shift;
187     u_int8_t            type;
188 #define HPTV2_T_RAID0           0x00
189 #define HPTV2_T_RAID1           0x01
190 #define HPTV2_T_RAID01_RAID0    0x02
191 #define HPTV2_T_SPAN            0x03
192 #define HPTV2_T_RAID_3          0x04
193 #define HPTV2_T_RAID_5          0x05
194 #define HPTV2_T_JBOD            0x06
195 #define HPTV2_T_RAID01_RAID1    0x07
196
197     u_int8_t            disk_number;
198     u_int32_t           total_sectors;
199     u_int32_t           disk_mode;
200     u_int32_t           boot_mode;
201     u_int8_t            boot_disk;
202     u_int8_t            boot_protect;
203     u_int8_t            error_log_entries;
204     u_int8_t            error_log_index;
205     struct {
206         u_int32_t       timestamp;
207         u_int8_t        reason;
208 #define HPTV2_R_REMOVED         0xfe
209 #define HPTV2_R_BROKEN          0xff
210         
211         u_int8_t        disk;
212         u_int8_t        status;
213         u_int8_t        sectors;
214         u_int32_t       lba;
215     } errorlog[32];
216     int8_t              filler2[16];
217     u_int32_t           rebuild_lba;
218     u_int8_t            dummy_1;
219     u_int8_t            name_1[15];
220     u_int8_t            dummy_2;
221     u_int8_t            name_2[15];
222     int8_t              filler3[8];
223 } __packed;
224
225
226 /* Highpoint V3 RocketRAID Metadata */
227 #define HPTV3_LBA(dev) \
228         (((struct ad_softc *)device_get_ivars(dev))->total_secs - 11)
229
230 struct hptv3_raid_conf {
231     u_int32_t           magic;
232 #define HPTV3_MAGIC             0x5a7816f3
233
234     u_int32_t           magic_0;
235     u_int8_t            checksum_0;
236     u_int8_t            mode;
237 #define HPTV3_BOOT_MARK         0x01
238 #define HPTV3_USER_MODE         0x02
239     
240     u_int8_t            user_mode;
241     u_int8_t            config_entries;
242     struct {
243         u_int32_t       total_sectors;
244         u_int8_t        type;
245 #define HPTV3_T_SPARE           0x00
246 #define HPTV3_T_JBOD            0x03
247 #define HPTV3_T_SPAN            0x04
248 #define HPTV3_T_RAID0           0x05
249 #define HPTV3_T_RAID1           0x06
250 #define HPTV3_T_RAID3           0x07
251 #define HPTV3_T_RAID5           0x08
252
253         u_int8_t        total_disks;
254         u_int8_t        disk_number;
255         u_int8_t        stripe_shift;
256         u_int16_t       status;
257 #define HPTV3_T_NEED_REBUILD    0x01
258 #define HPTV3_T_RAID5_FLAG      0x02
259
260         u_int16_t       critical_disks;
261         u_int32_t       rebuild_lba;
262     } __packed configs[2];
263     u_int8_t            name[16];
264     u_int32_t           timestamp;
265     u_int8_t            description[64];
266     u_int8_t            creator[16];
267     u_int8_t            checksum_1;
268     u_int8_t            dummy_0;
269     u_int8_t            dummy_1;
270     u_int8_t            flags;
271 #define HPTV3_T_ENABLE_TCQ      0x01
272 #define HPTV3_T_ENABLE_NCQ      0x02
273 #define HPTV3_T_ENABLE_WCACHE   0x04
274 #define HPTV3_T_ENABLE_RCACHE   0x08
275
276     struct {
277         u_int32_t       total_sectors;
278         u_int32_t       rebuild_lba;
279     } __packed configs_high[2];
280     u_int32_t           filler[87];
281 } __packed;
282
283
284 /* Intel MatrixRAID Metadata */
285 #define INTEL_LBA(dev) \
286         (((struct ad_softc *)device_get_ivars(dev))->total_secs - 3)
287
288 struct intel_raid_conf {
289     u_int8_t            intel_id[24];
290 #define INTEL_MAGIC             "Intel Raid ISM Cfg Sig. "
291
292     u_int8_t            version[6];
293 #define INTEL_VERSION_1100      "1.1.00"
294 #define INTEL_VERSION_1201      "1.2.01"
295 #define INTEL_VERSION_1202      "1.2.02"
296
297     u_int8_t            dummy_0[2];
298     u_int32_t           checksum;
299     u_int32_t           config_size;
300     u_int32_t           config_id;
301     u_int32_t           generation;
302     u_int32_t           dummy_1[2];
303     u_int8_t            total_disks;
304     u_int8_t            total_volumes;
305     u_int8_t            dummy_2[2];
306     u_int32_t           filler_0[39];
307     struct {
308         u_int8_t        serial[16];
309         u_int32_t       sectors;
310         u_int32_t       id;
311         u_int32_t       flags;
312 #define INTEL_F_SPARE           0x01
313 #define INTEL_F_ASSIGNED        0x02
314 #define INTEL_F_DOWN            0x04
315 #define INTEL_F_ONLINE          0x08
316
317         u_int32_t       filler[5];
318     } __packed disk[1];
319     u_int32_t           filler_1[62];
320 } __packed;
321
322 struct intel_raid_mapping {
323     u_int8_t            name[16];
324     u_int64_t           total_sectors __packed;
325     u_int32_t           state;
326     u_int32_t           reserved;
327     u_int32_t           filler_0[20];
328     u_int32_t           offset;
329     u_int32_t           disk_sectors;
330     u_int32_t           stripe_count;
331     u_int16_t           stripe_sectors;
332     u_int8_t            status;
333 #define INTEL_S_READY           0x00
334 #define INTEL_S_DISABLED        0x01
335 #define INTEL_S_DEGRADED        0x02
336 #define INTEL_S_FAILURE         0x03
337
338     u_int8_t            type;
339 #define INTEL_T_RAID0           0x00
340 #define INTEL_T_RAID1           0x01
341 #define INTEL_T_RAID5           0x05
342
343     u_int8_t            total_disks;
344     u_int8_t            magic[3];
345     u_int32_t           filler_1[7];
346     u_int32_t           disk_idx[1];
347 } __packed;
348
349
350 /* Integrated Technology Express Metadata */
351 #define ITE_LBA(dev) \
352         (((struct ad_softc *)device_get_ivars(dev))->total_secs - 2)
353
354 struct ite_raid_conf {
355     u_int32_t           filler_1[5];
356     u_int8_t            timestamp_0[8];
357     u_int32_t           dummy_1;
358     u_int32_t           filler_2[5];
359     u_int16_t           filler_3;
360     u_int8_t            ite_id[40];
361 #define ITE_MAGIC               "Integrated Technology Express Inc      "
362
363     u_int16_t           filler_4;
364     u_int32_t           filler_5[6];
365     u_int32_t           dummy_2;
366     u_int32_t           dummy_3;
367     u_int32_t           filler_6[12];
368     u_int32_t           dummy_4;
369     u_int32_t           filler_7[5];
370     u_int64_t           total_sectors __packed;
371     u_int32_t           filler_8[12];
372     
373     u_int16_t           filler_9;
374     u_int8_t            type;
375 #define ITE_T_RAID0             0x00
376 #define ITE_T_RAID1             0x01
377 #define ITE_T_RAID01            0x02
378 #define ITE_T_SPAN              0x03
379
380     u_int8_t            filler_10;
381     u_int32_t           dummy_5[8];
382     u_int8_t            stripe_1kblocks;
383     u_int8_t            filler_11[3];
384     u_int32_t           filler_12[54];
385
386     u_int32_t           dummy_6[4];
387     u_int8_t            timestamp_1[8];
388     u_int32_t           filler_13[9];
389     u_int8_t            stripe_sectors;
390     u_int8_t            filler_14[3];
391     u_int8_t            array_width;
392     u_int8_t            filler_15[3];
393     u_int32_t           filler_16;
394     u_int8_t            filler_17;
395     u_int8_t            disk_number;
396     u_int32_t           disk_sectors;
397     u_int16_t           filler_18;
398     u_int32_t           dummy_7[4];
399     u_int32_t           filler_20[104];
400 } __packed;
401
402
403 /* LSILogic V2 MegaRAID Metadata */
404 #define LSIV2_LBA(dev) \
405         (((struct ad_softc *)device_get_ivars(dev))->total_secs - 1)
406
407 struct lsiv2_raid_conf {
408     u_int8_t            lsi_id[6];
409 #define LSIV2_MAGIC             "$XIDE$"
410
411     u_int8_t            dummy_0;
412     u_int8_t            flags;
413     u_int16_t           version;
414     u_int8_t            config_entries;
415     u_int8_t            raid_count;
416     u_int8_t            total_disks;
417     u_int8_t            dummy_1;
418     u_int16_t           dummy_2;
419
420     union {
421         struct {
422             u_int8_t    type;
423 #define LSIV2_T_RAID0           0x01
424 #define LSIV2_T_RAID1           0x02
425 #define LSIV2_T_SPARE           0x08
426
427             u_int8_t    dummy_0;
428             u_int16_t   stripe_sectors;
429             u_int8_t    array_width;
430             u_int8_t    disk_count;
431             u_int8_t    config_offset;
432             u_int8_t    dummy_1;
433             u_int8_t    flags;
434 #define LSIV2_R_DEGRADED        0x02
435
436             u_int32_t   total_sectors;
437             u_int8_t    filler[3];
438         } __packed raid;
439         struct {
440             u_int8_t    device;
441 #define LSIV2_D_MASTER          0x00
442 #define LSIV2_D_SLAVE           0x01
443 #define LSIV2_D_CHANNEL0        0x00
444 #define LSIV2_D_CHANNEL1        0x10
445 #define LSIV2_D_NONE            0xff
446
447             u_int8_t    dummy_0;
448             u_int32_t   disk_sectors;
449             u_int8_t    disk_number;
450             u_int8_t    raid_number;
451             u_int8_t    flags;
452 #define LSIV2_D_GONE            0x02
453
454             u_int8_t    filler[7];
455         } __packed disk;
456     } configs[30];
457     u_int8_t            disk_number;
458     u_int8_t            raid_number;
459     u_int32_t           timestamp;
460     u_int8_t            filler[10];
461 } __packed;
462
463
464 /* LSILogic V3 MegaRAID Metadata */
465 #define LSIV3_LBA(dev) \
466         (((struct ad_softc *)device_get_ivars(dev))->total_secs - 4)
467
468 struct lsiv3_raid_conf {
469     u_int32_t           magic_0;        /* 0xa0203200 */
470     u_int32_t           filler_0[3];
471     u_int8_t            magic_1[4];     /* "SATA" */
472     u_int32_t           filler_1[40];
473     u_int32_t           dummy_0;        /* 0x0d000003 */
474     u_int32_t           filler_2[7];
475     u_int32_t           dummy_1;        /* 0x0d000003 */
476     u_int32_t           filler_3[70];
477     u_int8_t            magic_2[8];     /* "$_ENQ$31" */
478     u_int8_t            filler_4[7];
479     u_int8_t            checksum_0;
480     u_int8_t            filler_5[512*2];
481     u_int8_t            lsi_id[6];
482 #define LSIV3_MAGIC             "$_IDE$"
483
484     u_int16_t           dummy_2;        /* 0x33de for OK disk */
485     u_int16_t           version;        /* 0x0131 for this version */
486     u_int16_t           dummy_3;        /* 0x0440 always */
487     u_int32_t           filler_6;
488
489     struct {
490         u_int16_t       stripe_pages;
491         u_int8_t        type;
492 #define LSIV3_T_RAID0           0x00
493 #define LSIV3_T_RAID1           0x01
494
495         u_int8_t        dummy_0;
496         u_int8_t        total_disks;
497         u_int8_t        array_width;
498         u_int8_t        filler_0[10];
499
500         u_int32_t       sectors;
501         u_int16_t       dummy_1;
502         u_int32_t       offset;
503         u_int16_t       dummy_2;
504         u_int8_t        device;
505 #define LSIV3_D_DEVICE          0x01
506 #define LSIV3_D_CHANNEL         0x10
507
508         u_int8_t        dummy_3;
509         u_int8_t        dummy_4;
510         u_int8_t        dummy_5;
511         u_int8_t        filler_1[16];
512     } __packed raid[8];
513     struct {
514         u_int32_t       disk_sectors;
515         u_int32_t       dummy_0;
516         u_int32_t       dummy_1;
517         u_int8_t        dummy_2;
518         u_int8_t        dummy_3;
519         u_int8_t        flags;
520 #define LSIV3_D_MIRROR          0x00
521 #define LSIV3_D_STRIPE          0xff
522         u_int8_t        dummy_4;
523     } __packed disk[6];
524     u_int8_t            filler_7[7];
525     u_int8_t            device;
526     u_int32_t           timestamp;
527     u_int8_t            filler_8[3];
528     u_int8_t            checksum_1;
529 } __packed;
530
531
532 /* nVidia MediaShield Metadata */
533 #define NVIDIA_LBA(dev) \
534         (((struct ad_softc *)device_get_ivars(dev))->total_secs - 2)
535
536 struct nvidia_raid_conf {
537     u_int8_t            nvidia_id[8];
538 #define NV_MAGIC                "NVIDIA  "
539
540     u_int32_t           config_size;
541     u_int32_t           checksum;
542     u_int16_t           version;
543     u_int8_t            disk_number;
544     u_int8_t            dummy_0;
545     u_int32_t           total_sectors;
546     u_int32_t           sector_size;
547     u_int8_t            serial[16];
548     u_int8_t            revision[4];
549     u_int32_t           dummy_1;
550
551     u_int32_t           magic_0;
552 #define NV_MAGIC0               0x00640044
553
554     u_int64_t           magic_1;
555     u_int64_t           magic_2;
556     u_int8_t            flags;
557     u_int8_t            array_width;
558     u_int8_t            total_disks;
559     u_int8_t            dummy_2;
560     u_int16_t           type;
561 #define NV_T_RAID0              0x00000080
562 #define NV_T_RAID1              0x00000081
563 #define NV_T_RAID3              0x00000083
564 #define NV_T_RAID5              0x00000085
565 #define NV_T_RAID01             0x00008180
566 #define NV_T_SPAN               0x000000ff
567
568     u_int16_t           dummy_3;
569     u_int32_t           stripe_sectors;
570     u_int32_t           stripe_bytes;
571     u_int32_t           stripe_shift;
572     u_int32_t           stripe_mask;
573     u_int32_t           stripe_sizesectors;
574     u_int32_t           stripe_sizebytes;
575     u_int32_t           rebuild_lba;
576     u_int32_t           dummy_4;
577     u_int32_t           dummy_5;
578     u_int32_t           status;
579 #define NV_S_BOOTABLE           0x00000001
580 #define NV_S_DEGRADED           0x00000002
581
582     u_int32_t           filler[98];
583 } __packed;
584
585
586 /* Promise FastTrak Metadata */
587 #define PR_LBA(dev) \
588         (((((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)
589
590 struct promise_raid_conf {
591     char                promise_id[24];
592 #define PR_MAGIC                "Promise Technology, Inc."
593
594     u_int32_t           dummy_0;
595     u_int64_t           magic_0;
596 #define PR_MAGIC0(x)            (((u_int64_t)(x.channel) << 48) | \
597                                 ((u_int64_t)(x.device != 0) << 56))
598     u_int16_t           magic_1;
599     u_int32_t           magic_2;
600     u_int8_t            filler1[470];
601     struct {
602         u_int32_t       integrity;
603 #define PR_I_VALID              0x00000080
604
605         u_int8_t        flags;
606 #define PR_F_VALID              0x00000001
607 #define PR_F_ONLINE             0x00000002
608 #define PR_F_ASSIGNED           0x00000004
609 #define PR_F_SPARE              0x00000008
610 #define PR_F_DUPLICATE          0x00000010
611 #define PR_F_REDIR              0x00000020
612 #define PR_F_DOWN               0x00000040
613 #define PR_F_READY              0x00000080
614
615         u_int8_t        disk_number;
616         u_int8_t        channel;
617         u_int8_t        device;
618         u_int64_t       magic_0 __packed;
619         u_int32_t       disk_offset;
620         u_int32_t       disk_sectors;
621         u_int32_t       rebuild_lba;
622         u_int16_t       generation;
623         u_int8_t        status;
624 #define PR_S_VALID              0x01
625 #define PR_S_ONLINE             0x02
626 #define PR_S_INITED             0x04
627 #define PR_S_READY              0x08
628 #define PR_S_DEGRADED           0x10
629 #define PR_S_MARKED             0x20
630 #define PR_S_FUNCTIONAL         0x80
631
632         u_int8_t        type;
633 #define PR_T_RAID0              0x00
634 #define PR_T_RAID1              0x01
635 #define PR_T_RAID3              0x02
636 #define PR_T_RAID5              0x04
637 #define PR_T_SPAN               0x08
638 #define PR_T_JBOD               0x10
639
640         u_int8_t        total_disks;
641         u_int8_t        stripe_shift;
642         u_int8_t        array_width;
643         u_int8_t        array_number;
644         u_int32_t       total_sectors;
645         u_int16_t       cylinders;
646         u_int8_t        heads;
647         u_int8_t        sectors;
648         u_int64_t       magic_1 __packed;
649         struct {
650             u_int8_t    flags;
651             u_int8_t    dummy_0;
652             u_int8_t    channel;
653             u_int8_t    device;
654             u_int64_t   magic_0 __packed;
655         } disk[8];
656     } raid;
657     int32_t             filler2[346];
658     u_int32_t           checksum;
659 } __packed;
660
661
662 /* Silicon Image Medley Metadata */
663 #define SII_LBA(dev) \
664         ( ((struct ad_softc *)device_get_ivars(dev))->total_secs - 1)
665
666 struct sii_raid_conf {
667     u_int16_t           ata_params_00_53[54];
668     u_int64_t           total_sectors;
669     u_int16_t           ata_params_58_79[70];
670     u_int16_t           dummy_0;
671     u_int16_t           dummy_1;
672     u_int32_t           controller_pci_id;
673     u_int16_t           version_minor;
674     u_int16_t           version_major;
675     u_int8_t            timestamp[6];
676     u_int16_t           stripe_sectors;
677     u_int16_t           dummy_2;
678     u_int8_t            disk_number;
679     u_int8_t            type;
680 #define SII_T_RAID0             0x00
681 #define SII_T_RAID1             0x01
682 #define SII_T_RAID01            0x02
683 #define SII_T_SPARE             0x03
684
685     u_int8_t            raid0_disks;
686     u_int8_t            raid0_ident;
687     u_int8_t            raid1_disks;
688     u_int8_t            raid1_ident;
689     u_int64_t           rebuild_lba;
690     u_int32_t           generation;
691     u_int8_t            status;
692 #define SII_S_READY             0x01
693     
694     u_int8_t            base_raid1_position;
695     u_int8_t            base_raid0_position;
696     u_int8_t            position;
697     u_int16_t           dummy_3;
698     u_int8_t            name[16];
699     u_int16_t           checksum_0;
700     int8_t              filler1[190];
701     u_int16_t           checksum_1;
702 } __packed;
703
704
705 /* Silicon Integrated Systems RAID Metadata */
706 #define SIS_LBA(dev) \
707         ( ((struct ad_softc *)device_get_ivars(dev))->total_secs - 16)
708
709 struct sis_raid_conf {
710     u_int16_t           magic;
711 #define SIS_MAGIC               0x0010
712
713     u_int8_t            disks;
714 #define SIS_D_MASTER            0xf0
715 #define SIS_D_MIRROR            0x0f
716
717     u_int8_t            type_total_disks;
718 #define SIS_D_MASK              0x0f
719 #define SIS_T_MASK              0xf0
720 #define SIS_T_JBOD              0x10
721 #define SIS_T_RAID0             0x20
722 #define SIS_T_RAID1             0x30
723
724     u_int32_t           dummy_0;
725     u_int32_t           controller_pci_id;
726     u_int16_t           stripe_sectors;
727     u_int16_t           dummy_1;
728     u_int32_t           timestamp;
729     u_int8_t            model[40];
730     u_int8_t            disk_number;
731     u_int8_t            dummy_2[3];
732     int8_t              filler1[448];
733 } __packed;
734
735
736 /* VIA Tech V-RAID Metadata */
737 #define VIA_LBA(dev) \
738         ( ((struct ad_softc *)device_get_ivars(dev))->total_secs - 1)
739
740 struct via_raid_conf {
741     u_int16_t           magic;
742 #define VIA_MAGIC               0xaa55
743
744     u_int8_t            dummy_0;
745     u_int8_t            type;
746 #define VIA_T_MASK              0xfe
747 #define VIA_T_BOOTABLE          0x01
748 #define VIA_T_RAID0             0x04
749 #define VIA_T_RAID1             0x0c
750 #define VIA_T_SPAN              0x44
751
752     u_int8_t            disk_index;
753 #define VIA_D_MASK              0x0f
754 #define VIA_D_DEGRADED          0x10
755
756     u_int8_t            stripe_layout;
757 #define VIA_L_MASK              0x07
758 #define VIA_L_SHIFT             4
759
760     u_int64_t           total_sectors;
761     u_int32_t           disk_id;
762     u_int32_t           disks[8];
763     u_int8_t            checksum;
764     u_int8_t            filler_1[461];
765 } __packed;