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