Home | History | Annotate | Line # | Download | only in ata
ata_raidreg.h revision 1.2
      1 /*	$NetBSD: ata_raidreg.h,v 1.2 2005/06/20 02:11:57 briggs Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2000,2001,2002 Sren Schmidt <sos (at) 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 
     44 struct 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 __attribute__((__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 __attribute__((__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 __attribute__((__packed__));
    107 		} disk[8];
    108 	} raid;
    109 	uint32_t	filler2[346];
    110 	uint32_t	checksum;
    111 } __attribute__((__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 
    120 struct 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 } __attribute__((__packed__));
    172 
    173 #endif /* _DEV_PCI_PCIIDE_PROMISE_RAID_H_ */
    174