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