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