1/* $NetBSD: ata_raidreg.h,v 1.8 2008/09/11 11:08:50 tron Exp $ */ 2 3/*- 4 * Copyright (c) 2000,2001,2002 S�ren Schmidt <sos@FreeBSD.org> 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer, 12 * without modification, immediately at the beginning of the file. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. The name of the author may not be used to endorse or promote products 17 * derived from this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31#ifndef _DEV_PCI_PCIIDE_PROMISE_RAID_H_ 32#define _DEV_PCI_PCIIDE_PROMISE_RAID_H_ 33 34/* 35 * Macro to compute the LBA of the Promise RAID configuration structure, 36 * using the disk's softc structure. 37 */ 38#define PR_LBA(wd) \ 39 ((((wd)->sc_capacity / \ 40 ((wd)->sc_params.atap_heads * (wd)->sc_params.atap_sectors)) * \ 41 (wd)->sc_params.atap_heads * (wd)->sc_params.atap_sectors) - \ 42 (wd)->sc_params.atap_sectors) 43 44struct promise_raid_conf { 45 char promise_id[24]; 46#define PR_MAGIC "Promise Technology, Inc." 47 48 uint32_t dummy_0; 49 50 uint64_t magic_0; 51 uint16_t magic_1; 52 uint32_t magic_2; 53 uint8_t filler1[470]; 54 struct { /* 0x200 */ 55 uint32_t integrity; 56#define PR_I_VALID 0x00000080 57 58 uint8_t flags; 59#define PR_F_VALID 0x01 60#define PR_F_ONLINE 0x02 61#define PR_F_ASSIGNED 0x04 62#define PR_F_SPARE 0x08 63#define PR_F_DUPLICATE 0x10 64#define PR_F_REDIR 0x20 65#define PR_F_DOWN 0x40 66#define PR_F_READY 0x80 67 68 uint8_t disk_number; 69 uint8_t channel; 70 uint8_t device; 71 uint64_t magic_0 __packed; 72 uint32_t disk_offset; /* 0x210 */ 73 uint32_t disk_sectors; 74 uint32_t rebuild_lba; 75 uint16_t generation; 76 uint8_t status; 77#define PR_S_VALID 0x01 78#define PR_S_ONLINE 0x02 79#define PR_S_INITED 0x04 80#define PR_S_READY 0x08 81#define PR_S_DEGRADED 0x10 82#define PR_S_MARKED 0x20 83#define PR_S_FUNCTIONAL 0x80 84 85 uint8_t type; 86#define PR_T_RAID0 0x00 87#define PR_T_RAID1 0x01 88#define PR_T_RAID3 0x02 89#define PR_T_RAID5 0x04 90#define PR_T_SPAN 0x08 91 92 uint8_t total_disks; /* 0x220 */ 93 uint8_t stripe_shift; 94 uint8_t array_width; 95 uint8_t array_number; 96 uint32_t total_sectors; 97 uint16_t cylinders; 98 uint8_t heads; 99 uint8_t sectors; 100 uint64_t magic_1 __packed; 101 struct { 102 uint8_t flags; 103 uint8_t dummy_0; 104 uint8_t channel; 105 uint8_t device; 106 uint64_t magic_0 __packed; 107 } disk[8]; 108 } raid; 109 uint32_t filler2[346]; 110 uint32_t checksum; 111} __packed; 112 113/* 114 * Macro to compute the LBA of the Adaptec HostRAID configuration structure, 115 * using the disk's softc structure. 116 */ 117#define ADP_LBA(wd) \ 118 ((wd)->sc_capacity - 17) 119 120struct adaptec_raid_conf { 121 uint32_t magic_0; 122#define ADP_MAGIC_0 0x900765c4 123 124 uint32_t generation; 125 uint16_t dummy_0; 126 uint16_t total_configs; 127 uint16_t dummy_1; 128 uint16_t checksum; 129 uint32_t dummy_2; 130 uint32_t dummy_3; 131 uint32_t flags; 132 uint32_t timestamp; 133 uint32_t dummy_4[4]; 134 uint32_t dummy_5[4]; 135 struct { 136 uint16_t total_disks; 137 uint16_t generation; 138 uint32_t magic_0; 139 uint8_t dummy_0; 140 uint8_t type; 141#define ADP_T_RAID0 0x00 142#define ADP_T_RAID1 0x01 143 uint8_t dummy_1; 144 uint8_t flags; 145 146 uint8_t dummy_2; 147 uint8_t dummy_3; 148 uint8_t dummy_4; 149 uint8_t dummy_5; 150 151 uint32_t disk_number; 152 uint32_t dummy_6; 153 uint32_t sectors; 154 uint16_t stripe_sectors; 155 uint16_t dummy_7; 156 157 uint32_t dummy_8[4]; 158 uint8_t name[16]; 159 } configs[127]; 160 uint32_t dummy_6[13]; 161 uint32_t magic_1; 162#define ADP_MAGIC_1 0x0950f89f 163 uint32_t dummy_7[3]; 164 uint32_t magic_2; 165 uint32_t dummy_8[46]; 166 uint32_t magic_3; 167#define ADP_MAGIC_3 0x4450544d 168 uint32_t magic_4; 169#define ADP_MAGIC_4 0x0950f89f 170 uint32_t dummy_9[62]; 171} __packed; 172 173/* VIA Tech V-RAID Metadata */ 174/* Derrived from FreeBSD ata-raid.h 1.46 */ 175#define VIA_LBA(wd) ((wd)->sc_capacity - 1) 176 177struct via_raid_conf { 178 uint16_t magic; 179#define VIA_MAGIC 0xaa55 180 uint8_t dummy_0; 181 uint8_t type; 182#define VIA_T_MASK 0x7e 183#define VIA_T_BOOTABLE 0x01 184#define VIA_T_RAID0 0x04 185#define VIA_T_RAID1 0x0c 186#define VIA_T_RAID01 0x4c 187#define VIA_T_RAID5 0x2c 188#define VIA_T_SPAN 0x44 189#define VIA_T_UNKNOWN 0x80 190 uint8_t disk_index; 191#define VIA_D_MASK 0x0f 192#define VIA_D_DEGRADED 0x10 193#define VIA_D_HIGH_IDX 0x20 194 uint8_t stripe_layout; 195#define VIA_L_DISKS 0x07 196#define VIA_L_MASK 0xf0 197#define VIA_L_SHIFT 4 198 uint64_t disk_sectors; 199 uint32_t disk_id; 200 uint32_t disks[8]; 201 uint8_t checksum; 202 uint8_t pad_0[461]; 203} __packed; 204 205/* nVidia MediaShield Metadata */ 206/* taken from FreeBSD ata-raid.h 1.47 */ 207#define NVIDIA_LBA(wd) ((wd)->sc_capacity - 2) 208 209struct nvidia_raid_conf { 210 uint8_t nvidia_id[8]; 211#define NV_MAGIC "NVIDIA " 212 213 uint32_t config_size; 214 uint32_t checksum; 215 uint16_t version; 216 uint8_t disk_number; 217 uint8_t dummy_0; 218 uint32_t total_sectors; 219 uint32_t sector_size; 220 uint8_t serial[16]; 221 uint8_t revision[4]; 222 uint32_t dummy_1; 223 224 uint32_t magic_0; 225#define NV_MAGIC0 0x00640044 226 227 uint64_t magic_1; 228 uint64_t magic_2; 229 uint8_t flags; 230 uint8_t array_width; 231 uint8_t total_disks; 232 uint8_t dummy_2; 233 uint16_t type; 234#define NV_T_RAID0 0x00000080 235#define NV_T_RAID1 0x00000081 236#define NV_T_RAID3 0x00000083 237#define NV_T_RAID5 0x00000085 238#define NV_T_RAID01 0x00008180 239#define NV_T_SPAN 0x000000ff 240 241 uint16_t dummy_3; 242 uint32_t stripe_sectors; 243 uint32_t stripe_bytes; 244 uint32_t stripe_shift; 245 uint32_t stripe_mask; 246 uint32_t stripe_sizesectors; 247 uint32_t stripe_sizebytes; 248 uint32_t rebuild_lba; 249 uint32_t dummy_4; 250 uint32_t dummy_5; 251 uint32_t status; 252#define NV_S_BOOTABLE 0x00000001 253#define NV_S_DEGRADED 0x00000002 254 255 uint32_t filler[98]; 256} __packed; 257 258/* JMicron Technology Corp Metadata */ 259#define JMICRON_LBA(wd) ((wd)->sc_capacity - 1) 260#define JM_MAX_DISKS 8 261 262struct jmicron_raid_conf { 263 uint8_t signature[2]; 264#define JMICRON_MAGIC "JM" 265 uint16_t version; 266#define JMICRON_VERSION 0x0001 267 uint16_t checksum; 268 uint8_t filler_1[10]; 269 uint32_t disk_id; 270 uint32_t offset; 271 uint32_t disk_sectors_high; 272 uint16_t disk_sectors_low; 273 uint8_t filler_2[2]; 274 uint8_t name[16]; 275 uint8_t type; 276#define JM_T_RAID0 0 277#define JM_T_RAID1 1 278#define JM_T_RAID01 2 279#define JM_T_JBOD 3 280#define JM_T_RAID5 5 281 uint8_t stripe_shift; 282 uint16_t flags; 283#define JM_F_READY 0x0001 284#define JM_F_BOOTABLE 0x0002 285#define JM_F_BAD 0x0004 286#define JM_F_ACTIVE 0x0010 287#define JM_F_UNSYNC 0x0020 288#define JM_F_NEWEST 0x0040 289 uint8_t filler_3[4]; 290 uint32_t spare[2]; 291 uint32_t disks[JM_MAX_DISKS]; 292 uint8_t filler_4[32]; 293 uint8_t filler_5[384]; 294}; 295 296/* Intel MatrixRAID metadata */ 297#define INTEL_LBA(wd) ((wd)->sc_capacity - 3) 298 299struct intel_raid_conf { 300 uint8_t intel_id[24]; 301#define INTEL_MAGIC "Intel Raid ISM Cfg Sig. " 302 303 uint8_t version[6]; 304#define INTEL_VERSION_1100 "1.1.00" 305#define INTEL_VERSION_1201 "1.2.01" 306#define INTEL_VERSION_1202 "1.2.02" 307 308 uint8_t dummy_0[2]; 309 uint32_t checksum; 310 uint32_t config_size; 311 uint32_t config_id; 312 uint32_t generation; 313 uint32_t dummy_1[2]; 314 uint8_t total_disks; 315 uint8_t total_volumes; 316 uint8_t dummy_2[2]; 317 uint32_t filler_0[39]; 318 struct { 319 uint8_t serial[16]; 320 uint32_t sectors; 321 uint32_t id; 322 uint32_t flags; 323#define INTEL_F_SPARE 0x01 324#define INTEL_F_ASSIGNED 0x02 325#define INTEL_F_DOWN 0x04 326#define INTEL_F_ONLINE 0x08 327 uint32_t filler[5]; 328 } __packed disk[1]; 329 uint32_t filler_1[62]; 330} __packed; 331 332struct intel_raid_mapping { 333 uint8_t name[16]; 334 uint64_t total_sectors __packed; 335 uint32_t state; 336 uint32_t reserved; 337 uint32_t filler_0[20]; 338 uint32_t offset; 339 uint32_t disk_sectors; 340 uint32_t stripe_count; 341 uint16_t stripe_sectors; 342 uint8_t status; 343#define INTEL_S_READY 0x00 344#define INTEL_S_DISABLED 0x01 345#define INTEL_S_DEGRADED 0x02 346#define INTEL_S_FAILURE 0x03 347 348 uint8_t type; 349#define INTEL_T_RAID0 0x00 350#define INTEL_T_RAID1 0x01 351#define INTEL_T_RAID5 0x05 352 353 uint8_t total_disks; 354 uint8_t magic[3]; 355 uint32_t filler_1[7]; 356 uint32_t disk_idx[1]; 357} __packed; 358 359#endif /* _DEV_PCI_PCIIDE_PROMISE_RAID_H_ */ 360