ata-raid.h revision 145760
167071Ssos/*- 2144330Ssos * Copyright (c) 2000 - 2005 S�ren Schmidt <sos@FreeBSD.org> 367071Ssos * All rights reserved. 467071Ssos * 567071Ssos * Redistribution and use in source and binary forms, with or without 667071Ssos * modification, are permitted provided that the following conditions 767071Ssos * are met: 867071Ssos * 1. Redistributions of source code must retain the above copyright 967071Ssos * notice, this list of conditions and the following disclaimer, 1067071Ssos * without modification, immediately at the beginning of the file. 1167071Ssos * 2. Redistributions in binary form must reproduce the above copyright 1267071Ssos * notice, this list of conditions and the following disclaimer in the 1367071Ssos * documentation and/or other materials provided with the distribution. 1467071Ssos * 3. The name of the author may not be used to endorse or promote products 1567071Ssos * derived from this software without specific prior written permission. 1667071Ssos * 1767071Ssos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1867071Ssos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1967071Ssos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2067071Ssos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2167071Ssos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2267071Ssos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2367071Ssos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2467071Ssos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2567071Ssos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2667071Ssos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2767071Ssos * 2867071Ssos * $FreeBSD: head/sys/dev/ata/ata-raid.h 145760 2005-05-01 08:45:12Z sos $ 2967071Ssos */ 3067071Ssos 3191816Ssos/* misc defines */ 32144330Ssos#define MAX_ARRAYS 16 33144330Ssos#define MAX_DISKS 16 34144330Ssos#define AR_PROXIMITY 2048 /* how many sectors is "close" */ 3591816Ssos 36144330Ssos#define ATA_MAGIC "FreeBSD ATA driver RAID " 37144330Ssos 38144330Ssosstruct ata_raid_subdisk { 39144330Ssos struct ar_softc *raid; 40144330Ssos int disk_number; 4190215Ssos}; 4290215Ssos 43144330Ssos/* ATA PseudoRAID Metadata */ 4467071Ssosstruct ar_softc { 45144330Ssos int lun; /* logical unit number of this RAID */ 46144330Ssos u_int8_t name[32]; /* name of array if any */ 47144330Ssos u_int64_t magic_0; /* magic for this array */ 48144330Ssos u_int64_t magic_1; /* magic for this array */ 49144330Ssos int type; 50144330Ssos#define AR_T_JBOD 0x0001 51144330Ssos#define AR_T_SPAN 0x0002 52144330Ssos#define AR_T_RAID0 0x0004 53144330Ssos#define AR_T_RAID1 0x0008 54144330Ssos#define AR_T_RAID01 0x0010 55144330Ssos#define AR_T_RAID3 0x0020 56144330Ssos#define AR_T_RAID4 0x0040 57144330Ssos#define AR_T_RAID5 0x0080 58131113Ssos 59144330Ssos int status; 60144330Ssos#define AR_S_READY 0x0001 61144330Ssos#define AR_S_DEGRADED 0x0002 62144330Ssos#define AR_S_REBUILDING 0x0004 63131113Ssos 64144330Ssos int format; 65144330Ssos#define AR_F_FREEBSD_RAID 0x0001 66144330Ssos#define AR_F_ADAPTEC_RAID 0x0002 67144330Ssos#define AR_F_HPTV2_RAID 0x0004 68144330Ssos#define AR_F_HPTV3_RAID 0x0008 69144330Ssos#define AR_F_INTEL_RAID 0x0010 70144330Ssos#define AR_F_ITE_RAID 0x0020 71144330Ssos#define AR_F_LSIV2_RAID 0x0040 72144330Ssos#define AR_F_LSIV3_RAID 0x0080 73144330Ssos#define AR_F_PROMISE_RAID 0x0100 74144330Ssos#define AR_F_SII_RAID 0x0200 75144936Ssos#define AR_F_VIA_RAID 0x0400 76144936Ssos#define AR_F_FORMAT_MASK 0x07ff 77131113Ssos 78144330Ssos u_int generation; /* generation of this array */ 79144330Ssos u_int64_t total_sectors; 80144330Ssos u_int64_t offset_sectors; /* offset from start of disk */ 81144330Ssos u_int16_t heads; 82144330Ssos u_int16_t sectors; 83144330Ssos u_int32_t cylinders; 84144330Ssos u_int width; /* array width in disks */ 85144330Ssos u_int interleave; /* interleave in blocks */ 86144330Ssos u_int total_disks; /* number of disks in this array */ 87144330Ssos struct ar_disk { 88144330Ssos device_t dev; 89144330Ssos u_int8_t serial[16]; /* serial # of physical disk */ 90144330Ssos u_int64_t sectors; /* useable sectors on this disk */ 91144330Ssos off_t last_lba; /* last lba used (for performance) */ 92144330Ssos u_int flags; 93144330Ssos#define AR_DF_PRESENT 0x0001 /* this HW pos has a disk present */ 94144330Ssos#define AR_DF_ASSIGNED 0x0002 /* this HW pos assigned to an array */ 95144330Ssos#define AR_DF_SPARE 0x0004 /* this HW pos is a spare */ 96144330Ssos#define AR_DF_ONLINE 0x0008 /* this HW pos is online and in use */ 9767071Ssos 98144330Ssos } disks[MAX_DISKS]; 99144330Ssos int toggle; /* performance hack for RAID1's */ 100144330Ssos u_int64_t rebuild_lba; /* rebuild progress indicator */ 101144330Ssos struct mtx lock; /* metadata lock */ 102144330Ssos struct disk *disk; /* disklabel/slice stuff */ 103144330Ssos struct proc *pid; /* rebuilder process id */ 10467071Ssos}; 10567071Ssos 106144330Ssos/* Adaptec HostRAID Metadata */ 107144330Ssos#define ADP_LBA(dev) \ 108144330Ssos (((struct ad_softc *)device_get_ivars(dev))->total_secs - 17) 109131113Ssos 110144330Ssos/* note all entries are big endian */ 111144330Ssosstruct adaptec_raid_conf { 112144936Ssos u_int32_t magic_0; 113144330Ssos#define ADP_MAGIC_0 0xc4650790 11490215Ssos 115144330Ssos u_int32_t generation; 116144330Ssos u_int16_t dummy_0; 117144330Ssos u_int16_t total_configs; 118144330Ssos u_int16_t dummy_1; 119144330Ssos u_int16_t checksum; 120144936Ssos u_int32_t dummy_2; 121144330Ssos u_int32_t dummy_3; 122144330Ssos u_int32_t flags; 123144330Ssos u_int32_t timestamp; 124144936Ssos u_int32_t dummy_4[4]; 125144936Ssos u_int32_t dummy_5[4]; 126144936Ssos struct { 127144330Ssos u_int16_t total_disks; 128144330Ssos u_int16_t generation; 129144330Ssos u_int32_t magic_0; 130144330Ssos u_int8_t dummy_0; 131144330Ssos u_int8_t type; 132144330Ssos#define ADP_T_RAID0 0x00 133144330Ssos#define ADP_T_RAID1 0x01 134144330Ssos u_int8_t dummy_1; 135144330Ssos u_int8_t flags; 13667071Ssos 137144330Ssos u_int8_t dummy_2; 138144330Ssos u_int8_t dummy_3; 139144330Ssos u_int8_t dummy_4; 140144330Ssos u_int8_t dummy_5; 14167071Ssos 142144330Ssos u_int32_t disk_number; 143144330Ssos u_int32_t dummy_6; 144144330Ssos u_int32_t sectors; 145144330Ssos u_int16_t stripe_shift; 146144330Ssos u_int16_t dummy_7; 14767071Ssos 148144330Ssos u_int32_t dummy_8[4]; 149144330Ssos u_int8_t name[16]; 150144936Ssos } configs[127]; 151144936Ssos u_int32_t dummy_6[13]; 152144330Ssos u_int32_t magic_1; 153144330Ssos#define ADP_MAGIC_1 0x9ff85009 154144330Ssos u_int32_t dummy_7[3]; 155144330Ssos u_int32_t magic_2; 156144330Ssos u_int32_t dummy_8[46]; 157144330Ssos u_int32_t magic_3; 158144330Ssos#define ADP_MAGIC_3 0x4d545044 159144330Ssos u_int32_t magic_4; 160144330Ssos#define ADP_MAGIC_4 0x9ff85009 161144330Ssos u_int32_t dummy_9[62]; 162144330Ssos} __packed; 163144330Ssos 164144330Ssos 165144330Ssos/* Highpoint V2 RocketRAID Metadata */ 166144330Ssos#define HPTV2_LBA(dev) 9 167144330Ssos 168144330Ssosstruct hptv2_raid_conf { 169144330Ssos int8_t filler1[32]; 170144330Ssos u_int32_t magic; 171144330Ssos#define HPTV2_MAGIC_OK 0x5a7816f0 172144330Ssos#define HPTV2_MAGIC_BAD 0x5a7816fd 173144330Ssos 174144330Ssos u_int32_t magic_0; 175144330Ssos u_int32_t magic_1; 176144330Ssos u_int32_t order; 177144330Ssos#define HPTV2_O_RAID0 0x01 178144330Ssos#define HPTV2_O_RAID1 0x02 179144330Ssos#define HPTV2_O_OK 0x04 180144330Ssos 181144330Ssos u_int8_t array_width; 182144330Ssos u_int8_t stripe_shift; 183144330Ssos u_int8_t type; 184144330Ssos#define HPTV2_T_RAID0 0x00 185144330Ssos#define HPTV2_T_RAID1 0x01 186144330Ssos#define HPTV2_T_RAID01_RAID0 0x02 187144330Ssos#define HPTV2_T_SPAN 0x03 188144330Ssos#define HPTV2_T_RAID_3 0x04 189144330Ssos#define HPTV2_T_RAID_5 0x05 190144330Ssos#define HPTV2_T_JBOD 0x06 191144330Ssos#define HPTV2_T_RAID01_RAID1 0x07 192144330Ssos 193144330Ssos u_int8_t disk_number; 194144330Ssos u_int32_t total_sectors; 195144330Ssos u_int32_t disk_mode; 196144330Ssos u_int32_t boot_mode; 197144330Ssos u_int8_t boot_disk; 198144330Ssos u_int8_t boot_protect; 199144330Ssos u_int8_t error_log_entries; 200144330Ssos u_int8_t error_log_index; 20167071Ssos struct { 202144330Ssos u_int32_t timestamp; 203144330Ssos u_int8_t reason; 204144330Ssos#define HPTV2_R_REMOVED 0xfe 205144330Ssos#define HPTV2_R_BROKEN 0xff 20667071Ssos 207144330Ssos u_int8_t disk; 208144330Ssos u_int8_t status; 209144330Ssos u_int8_t sectors; 210144330Ssos u_int32_t lba; 21167071Ssos } errorlog[32]; 212144330Ssos int8_t filler2[16]; 213144330Ssos u_int32_t rebuild_lba; 214144330Ssos u_int8_t dummy_1; 215144330Ssos u_int8_t name_1[15]; 216144330Ssos u_int8_t dummy_2; 217144330Ssos u_int8_t name_2[15]; 218144330Ssos int8_t filler3[8]; 219103870Salfred} __packed; 22067071Ssos 22190566Ssos 222144330Ssos/* Highpoint V3 RocketRAID Metadata */ 223144330Ssos#define HPTV3_LBA(dev) \ 224144330Ssos (((struct ad_softc *)device_get_ivars(dev))->total_secs - 11) 225131113Ssos 226144330Ssosstruct hptv3_raid_conf { 227144330Ssos u_int32_t magic; 228144330Ssos#define HPTV3_MAGIC 0x5a7816f3 229131113Ssos 230144330Ssos u_int32_t magic_0; 231144330Ssos u_int8_t checksum_0; 232144330Ssos u_int8_t mode; 233144330Ssos#define HPTV3_BOOT_MARK 0x01 234144330Ssos#define HPTV3_USER_MODE 0x02 235144330Ssos 236144330Ssos u_int8_t user_mode; 237144330Ssos u_int8_t config_entries; 238144330Ssos struct { 239144330Ssos u_int32_t total_sectors; 240144330Ssos u_int8_t type; 241144330Ssos#define HPTV3_T_SPARE 0x00 242144330Ssos#define HPTV3_T_JBOD 0x03 243144330Ssos#define HPTV3_T_SPAN 0x04 244144330Ssos#define HPTV3_T_RAID0 0x05 245144330Ssos#define HPTV3_T_RAID1 0x06 246144330Ssos#define HPTV3_T_RAID3 0x07 247144330Ssos#define HPTV3_T_RAID5 0x08 248131113Ssos 249144330Ssos u_int8_t total_disks; 250144330Ssos u_int8_t disk_number; 251144330Ssos u_int8_t stripe_shift; 252144330Ssos u_int16_t status; 253144330Ssos#define HPTV3_T_NEED_REBUILD 0x01 254144330Ssos#define HPTV3_T_RAID5_FLAG 0x02 255144330Ssos 256144330Ssos u_int16_t critical_disks; 257144330Ssos u_int32_t rebuild_lba; 258144330Ssos } __packed configs[2]; 259144330Ssos u_int8_t name[16]; 260144330Ssos u_int32_t timestamp; 261144330Ssos u_int8_t description[64]; 262144330Ssos u_int8_t creator[16]; 263144330Ssos u_int8_t checksum_1; 264144330Ssos u_int8_t dummy_0; 265144330Ssos u_int8_t dummy_1; 266144330Ssos u_int8_t flags; 267144330Ssos#define HPTV3_T_ENABLE_TCQ 0x01 268144330Ssos#define HPTV3_T_ENABLE_NCQ 0x02 269144330Ssos#define HPTV3_T_ENABLE_WCACHE 0x04 270144330Ssos#define HPTV3_T_ENABLE_RCACHE 0x08 271144330Ssos 272144330Ssos struct { 273144330Ssos u_int32_t total_sectors; 274144330Ssos u_int32_t rebuild_lba; 275144330Ssos } __packed configs_high[2]; 276144330Ssos u_int32_t filler[87]; 277144330Ssos} __packed; 278144330Ssos 279144330Ssos 280144330Ssos/* Intel MatrixRAID Metadata */ 281144330Ssos#define INTEL_LBA(dev) \ 282144330Ssos (((struct ad_softc *)device_get_ivars(dev))->total_secs - 2) 283144330Ssos 284144330Ssosstruct intel_raid_conf { 285144330Ssos u_int8_t intel_id[24]; 286145713Ssos#define INTEL_MAGIC "Intel Raid ISM Cfg Sig. " 287144330Ssos 288144330Ssos u_int8_t version[6]; 289144330Ssos u_int8_t dummy_0[2]; 290144330Ssos u_int32_t checksum; 291144330Ssos u_int32_t config_size; 292144330Ssos u_int32_t config_id; 293144330Ssos u_int32_t generation; 294144330Ssos u_int32_t dummy_1[2]; 295144330Ssos u_int8_t total_disks; 296144330Ssos u_int8_t total_volumes; 297144330Ssos u_int8_t dummy_2[2]; 298144330Ssos u_int32_t filler_0[39]; 299144330Ssos struct { 300144330Ssos u_int8_t serial[16]; 301144330Ssos u_int32_t sectors; 302144330Ssos u_int32_t id; 303144330Ssos u_int32_t flags; 304144330Ssos#define INTEL_F_SPARE 0x01 305144330Ssos#define INTEL_F_ASSIGNED 0x02 306144330Ssos#define INTEL_F_DOWN 0x04 307144330Ssos#define INTEL_F_ONLINE 0x08 308144330Ssos 309144330Ssos u_int32_t filler[5]; 310144330Ssos } __packed disk[1]; 311144330Ssos u_int32_t filler_1[62]; 312144330Ssos} __packed; 313144330Ssos 314144330Ssosstruct intel_raid_mapping { 315144330Ssos u_int8_t name[16]; 316144330Ssos u_int64_t total_sectors __packed; 317144330Ssos u_int32_t state; 318144330Ssos u_int32_t reserved; 319144330Ssos u_int32_t filler_1[20]; 320144330Ssos u_int32_t offset; 321144330Ssos u_int32_t disk_sectors; 322144330Ssos u_int32_t stripe_count; 323144330Ssos u_int16_t stripe_sectors; 324144330Ssos u_int8_t status; 325144330Ssos#define INTEL_S_READY 0x00 326144330Ssos#define INTEL_S_DISABLED 0x01 327144330Ssos#define INTEL_S_DEGRADED 0x02 328144330Ssos#define INTEL_S_FAILURE 0x03 329144330Ssos 330144330Ssos u_int8_t type; 331144330Ssos#define INTEL_T_RAID0 0x00 332144330Ssos#define INTEL_T_RAID1 0x01 333144330Ssos 334144330Ssos u_int8_t total_disks; 335144330Ssos u_int8_t dummy_2[3]; 336144330Ssos u_int32_t filler_2[7]; 337144330Ssos u_int32_t disk_idx[1]; 338144330Ssos} __packed; 339144330Ssos 340144330Ssos 341144330Ssos/* Integrated Technology Express Metadata */ 342144330Ssos#define ITE_LBA(dev) \ 343144330Ssos (((struct ad_softc *)device_get_ivars(dev))->total_secs - 2) 344144330Ssos 345144330Ssosstruct ite_raid_conf { 346144330Ssos u_int32_t filler_1[5]; 347144936Ssos u_int8_t timestamp_0[8]; 348144330Ssos u_int32_t dummy_1; 349144330Ssos u_int32_t filler_2[5]; 350144330Ssos u_int16_t filler_3; 351144936Ssos u_int8_t ite_id[40]; 352145713Ssos#define ITE_MAGIC "Integrated Technology Express Inc " 353144330Ssos 354144330Ssos u_int16_t filler_4; 355144330Ssos u_int32_t filler_5[6]; 356144330Ssos u_int32_t dummy_2; 357144330Ssos u_int32_t dummy_3; 358144330Ssos u_int32_t filler_6[12]; 359144330Ssos u_int32_t dummy_4; 360144330Ssos u_int32_t filler_7[5]; 361144330Ssos u_int64_t total_sectors __packed; 362144330Ssos u_int32_t filler_8[12]; 363144330Ssos 364144936Ssos u_int16_t filler_9; 365144330Ssos u_int8_t type; 366144330Ssos#define ITE_T_RAID0 0x00 367144330Ssos#define ITE_T_RAID1 0x01 368144330Ssos#define ITE_T_RAID01 0x02 369144330Ssos#define ITE_T_SPAN 0x03 370144330Ssos 371144330Ssos u_int8_t filler_10; 372144330Ssos u_int32_t dummy_5[8]; 373144330Ssos u_int8_t stripe_1kblocks; 374144330Ssos u_int8_t filler_11[3]; 375144330Ssos u_int32_t filler_12[54]; 376144330Ssos 377144936Ssos u_int32_t dummy_6[4]; 378144936Ssos u_int8_t timestamp_1[8]; 379144330Ssos u_int32_t filler_13[9]; 380144330Ssos u_int8_t stripe_sectors; 381144330Ssos u_int8_t filler_14[3]; 382144330Ssos u_int8_t array_width; 383144330Ssos u_int8_t filler_15[3]; 384144330Ssos u_int32_t filler_16; 385144330Ssos u_int8_t filler_17; 386144330Ssos u_int8_t disk_number; 387144330Ssos u_int32_t disk_sectors; 388144330Ssos u_int16_t filler_18; 389144330Ssos u_int32_t dummy_7[4]; 390144330Ssos u_int32_t filler_20[104]; 391144330Ssos} __packed; 392144330Ssos 393144330Ssos 394144330Ssos/* LSILogic V2 MegaRAID Metadata */ 395144330Ssos#define LSIV2_LBA(dev) \ 396144330Ssos (((struct ad_softc *)device_get_ivars(dev))->total_secs - 1) 397144330Ssos 398144330Ssosstruct lsiv2_raid_conf { 399144330Ssos u_int8_t lsi_id[6]; 400145713Ssos#define LSIV2_MAGIC "$XIDE$" 401144330Ssos 402144330Ssos u_int8_t dummy_0; 403144330Ssos u_int8_t flags; 404144330Ssos u_int16_t version; 405144330Ssos u_int8_t config_entries; 406144330Ssos u_int8_t raid_count; 407144330Ssos u_int8_t total_disks; 408144330Ssos u_int8_t dummy_1; 409144330Ssos u_int16_t dummy_2; 410144330Ssos 411131113Ssos union { 412131113Ssos struct { 413144330Ssos u_int8_t type; 414144330Ssos#define LSIV2_T_RAID0 0x01 415144330Ssos#define LSIV2_T_RAID1 0x02 416144330Ssos#define LSIV2_T_SPARE 0x08 417131113Ssos 418144330Ssos u_int8_t dummy_0; 419144330Ssos u_int16_t stripe_sectors; 420144330Ssos u_int8_t array_width; 421144330Ssos u_int8_t disk_count; 422144330Ssos u_int8_t config_offset; 423144330Ssos u_int8_t dummy_1; 424144330Ssos u_int8_t flags; 425144330Ssos#define LSIV2_R_DEGRADED 0x02 426131113Ssos 427144330Ssos u_int32_t total_sectors; 428144330Ssos u_int8_t filler[3]; 429131113Ssos } __packed raid; 430131113Ssos struct { 431144330Ssos u_int8_t device; 432144330Ssos#define LSIV2_D_MASTER 0x00 433144330Ssos#define LSIV2_D_SLAVE 0x01 434144330Ssos#define LSIV2_D_CHANNEL0 0x00 435144330Ssos#define LSIV2_D_CHANNEL1 0x10 436144330Ssos#define LSIV2_D_NONE 0xff 437131113Ssos 438144330Ssos u_int8_t dummy_0; 439144330Ssos u_int32_t disk_sectors; 440144330Ssos u_int8_t disk_number; 441144330Ssos u_int8_t raid_number; 442144330Ssos u_int8_t flags; 443144330Ssos#define LSIV2_D_GONE 0x02 444131113Ssos 445144330Ssos u_int8_t filler[7]; 446131113Ssos } __packed disk; 447131113Ssos } configs[30]; 448144330Ssos u_int8_t disk_number; 449144330Ssos u_int8_t raid_number; 450144330Ssos u_int32_t timestamp; 451144330Ssos u_int8_t filler[10]; 452131113Ssos} __packed; 453131113Ssos 454131113Ssos 455144330Ssos/* LSILogic V3 MegaRAID Metadata */ 456144330Ssos#define LSIV3_LBA(dev) \ 457144330Ssos (((struct ad_softc *)device_get_ivars(dev))->total_secs - 4) 45890215Ssos 459144330Ssosstruct lsiv3_raid_conf { 460144330Ssos u_int32_t magic_0; /* 0xa0203200 */ 461144330Ssos u_int32_t filler_0[3]; 462144330Ssos u_int8_t magic_1[4]; /* "SATA" */ 463144330Ssos u_int32_t filler_1[40]; 464144330Ssos u_int32_t dummy_0; /* 0x0d000003 */ 465144330Ssos u_int32_t filler_2[7]; 466144330Ssos u_int32_t dummy_1; /* 0x0d000003 */ 467144330Ssos u_int32_t filler_3[70]; 468144330Ssos u_int8_t magic_2[8]; /* "$_ENQ$31" */ 469144330Ssos u_int8_t filler_4[7]; 470144330Ssos u_int8_t checksum_0; 471144330Ssos u_int8_t filler_5[512*2]; 472144330Ssos u_int8_t lsi_id[6]; 473145713Ssos#define LSIV3_MAGIC "$_IDE$" 474144330Ssos 475144330Ssos u_int16_t dummy_2; /* 0x33de for OK disk */ 476144330Ssos u_int16_t version; /* 0x0131 for this version */ 477144330Ssos u_int16_t dummy_3; /* 0x0440 always */ 478144330Ssos u_int32_t filler_6; 479144330Ssos 480144330Ssos struct { 481144330Ssos u_int16_t stripe_pages; 482144330Ssos u_int8_t type; 483144330Ssos#define LSIV3_T_RAID0 0x00 484144330Ssos#define LSIV3_T_RAID1 0x01 485144330Ssos 486144330Ssos u_int8_t dummy_0; 487144330Ssos u_int8_t total_disks; 488144330Ssos u_int8_t array_width; 489144330Ssos u_int8_t filler_0[10]; 490144330Ssos 491144330Ssos u_int32_t sectors; 492144330Ssos u_int16_t dummy_1; 493144330Ssos u_int32_t offset; 494144330Ssos u_int16_t dummy_2; 495144330Ssos u_int8_t device; 496144330Ssos#define LSIV3_D_DEVICE 0x01 497144330Ssos#define LSIV3_D_CHANNEL 0x10 498144330Ssos 499144330Ssos u_int8_t dummy_3; 500144330Ssos u_int8_t dummy_4; 501144330Ssos u_int8_t dummy_5; 502144330Ssos u_int8_t filler_1[16]; 503144330Ssos } __packed raid[8]; 504144330Ssos struct { 505144330Ssos u_int32_t disk_sectors; 506144330Ssos u_int32_t dummy_0; 507144330Ssos u_int32_t dummy_1; 508144330Ssos u_int8_t dummy_2; 509144330Ssos u_int8_t dummy_3; 510144330Ssos u_int8_t flags; 511144330Ssos#define LSIV3_D_MIRROR 0x00 512144330Ssos#define LSIV3_D_STRIPE 0xff 513144330Ssos u_int8_t dummy_4; 514144330Ssos } __packed disk[6]; 515144330Ssos u_int8_t filler_7[7]; 516144330Ssos u_int8_t device; 517144330Ssos u_int32_t timestamp; 518144330Ssos u_int8_t filler_8[3]; 519144330Ssos u_int8_t checksum_1; 520144330Ssos} __packed; 521144330Ssos 522144330Ssos 523144330Ssos/* Promise FastTrak Metadata */ 524144330Ssos#define PR_LBA(dev) \ 525145760Ssos (((((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) 526144330Ssos 52767071Ssosstruct promise_raid_conf { 528144330Ssos char promise_id[24]; 529145713Ssos#define PR_MAGIC "Promise Technology, Inc." 53067071Ssos 531144330Ssos u_int32_t dummy_0; 532144330Ssos u_int64_t magic_0; 533145713Ssos#define PR_MAGIC0(x) (((u_int64_t)(x.channel) << 48) | \ 534144936Ssos ((u_int64_t)(x.device != 0) << 56)) 535144330Ssos u_int16_t magic_1; 536144330Ssos u_int32_t magic_2; 537144330Ssos u_int8_t filler1[470]; 53867071Ssos struct { 539144330Ssos u_int32_t integrity; 540144330Ssos#define PR_I_VALID 0x00000080 54190215Ssos 542144330Ssos u_int8_t flags; 543144330Ssos#define PR_F_VALID 0x00000001 544144330Ssos#define PR_F_ONLINE 0x00000002 545144330Ssos#define PR_F_ASSIGNED 0x00000004 546144330Ssos#define PR_F_SPARE 0x00000008 547144330Ssos#define PR_F_DUPLICATE 0x00000010 548144330Ssos#define PR_F_REDIR 0x00000020 549144330Ssos#define PR_F_DOWN 0x00000040 550144330Ssos#define PR_F_READY 0x00000080 55167071Ssos 552144330Ssos u_int8_t disk_number; 553144330Ssos u_int8_t channel; 554144330Ssos u_int8_t device; 555144330Ssos u_int64_t magic_0 __packed; 556144330Ssos u_int32_t disk_offset; 557144330Ssos u_int32_t disk_sectors; 558144330Ssos u_int32_t rebuild_lba; 559144330Ssos u_int16_t generation; 560144330Ssos u_int8_t status; 561144330Ssos#define PR_S_VALID 0x01 562144330Ssos#define PR_S_ONLINE 0x02 563144330Ssos#define PR_S_INITED 0x04 564144330Ssos#define PR_S_READY 0x08 565144330Ssos#define PR_S_DEGRADED 0x10 566144330Ssos#define PR_S_MARKED 0x20 567144330Ssos#define PR_S_FUNCTIONAL 0x80 56867071Ssos 569144330Ssos u_int8_t type; 570144330Ssos#define PR_T_RAID0 0x00 571144330Ssos#define PR_T_RAID1 0x01 572144330Ssos#define PR_T_RAID3 0x02 573144330Ssos#define PR_T_RAID5 0x04 574144330Ssos#define PR_T_SPAN 0x08 575144330Ssos#define PR_T_JBOD 0x10 57667071Ssos 577144330Ssos u_int8_t total_disks; 578144330Ssos u_int8_t stripe_shift; 579144330Ssos u_int8_t array_width; 580144330Ssos u_int8_t array_number; 581144330Ssos u_int32_t total_sectors; 582144330Ssos u_int16_t cylinders; 583144330Ssos u_int8_t heads; 584144330Ssos u_int8_t sectors; 585144330Ssos u_int64_t magic_1 __packed; 586131113Ssos struct { 587144330Ssos u_int8_t flags; 588144330Ssos u_int8_t dummy_0; 589144330Ssos u_int8_t channel; 590144330Ssos u_int8_t device; 591144330Ssos u_int64_t magic_0 __packed; 59267071Ssos } disk[8]; 59368183Ssos } raid; 594144330Ssos int32_t filler2[346]; 595144330Ssos u_int32_t checksum; 596103870Salfred} __packed; 59767071Ssos 598144330Ssos 599144330Ssos/* Silicon Image Medley Metadata */ 600144330Ssos#define SII_LBA(dev) \ 601144330Ssos ( ((struct ad_softc *)device_get_ivars(dev))->total_secs - 1) 602144330Ssos 603144330Ssosstruct sii_raid_conf { 604144330Ssos u_int16_t ata_params_00_53[54]; 605144330Ssos u_int64_t total_sectors; 606144330Ssos u_int16_t ata_params_58_79[70]; 607144330Ssos u_int16_t dummy_0; 608144330Ssos u_int16_t dummy_1; 609144330Ssos u_int32_t controller_pci_id; 610144330Ssos u_int16_t version_minor; 611144330Ssos u_int16_t version_major; 612144936Ssos u_int8_t timestamp[6]; 613144330Ssos u_int16_t stripe_sectors; 614144330Ssos u_int16_t dummy_2; 615144330Ssos u_int8_t disk_number; 616144330Ssos u_int8_t type; 617144330Ssos#define SII_T_RAID0 0x00 618144330Ssos#define SII_T_RAID1 0x01 619144330Ssos#define SII_T_RAID01 0x02 620144330Ssos#define SII_T_SPARE 0x03 621144330Ssos 622144330Ssos u_int8_t raid0_disks; 623144330Ssos u_int8_t raid0_ident; 624144330Ssos u_int8_t raid1_disks; 625144330Ssos u_int8_t raid1_ident; 626144330Ssos u_int64_t rebuild_lba; 627144330Ssos u_int32_t generation; 628144330Ssos u_int8_t status; 629144330Ssos#define SII_S_READY 0x01 630144330Ssos 631144330Ssos u_int8_t base_raid1_position; 632144330Ssos u_int8_t base_raid0_position; 633144330Ssos u_int8_t position; 634144330Ssos u_int16_t dummy_3; 635144330Ssos u_int8_t name[16]; 636144330Ssos u_int16_t checksum_0; 637144330Ssos int8_t filler1[190]; 638144936Ssos u_int16_t checksum_1; 639144330Ssos} __packed; 640144936Ssos 641144936Ssos 642144940Ssos/* VIA Tech V-RAID Metadata */ 643144936Ssos#define VIA_LBA(dev) \ 644144936Ssos ( ((struct ad_softc *)device_get_ivars(dev))->total_secs - 1) 645144936Ssos 646144936Ssosstruct via_raid_conf { 647145713Ssos u_int16_t magic; 648145713Ssos#define VIA_MAGIC 0xaa55 649144936Ssos 650145713Ssos u_int8_t dummy_0; 651145713Ssos u_int8_t type; 652145713Ssos#define VIA_T_MASK 0xfe 653145713Ssos#define VIA_T_BOOTABLE 0x01 654145713Ssos#define VIA_T_RAID0 0x04 655145713Ssos#define VIA_T_RAID1 0x0c 656145713Ssos#define VIA_T_SPAN 0x44 657144936Ssos 658145713Ssos u_int8_t disk_index; 659145713Ssos u_int8_t stripe_layout; 660145713Ssos#define VIA_L_MASK 0x07 661145713Ssos#define VIA_L_SHIFT 4 662144936Ssos 663145713Ssos u_int64_t total_sectors; 664145713Ssos u_int32_t disk_id; 665145713Ssos u_int32_t disks[8]; 666145713Ssos u_int8_t checksum; 667145713Ssos u_int8_t filler_1[461]; 668144936Ssos} __packed; 669