Home | History | Annotate | Line # | Download | only in ata
ata_raidreg.h revision 1.4.18.1
      1  1.4.18.1       ad /*	$NetBSD: ata_raidreg.h,v 1.4.18.1 2007/12/26 19:46:03 ad 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.4.18.1       ad 		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.4.18.1       ad 		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.4.18.1       ad 			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.4.18.1       ad } __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.4.18.1       ad } __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.4.18.1       ad } __packed;
    204       1.4  garbled 
    205       1.1  thorpej #endif /* _DEV_PCI_PCIIDE_PROMISE_RAID_H_ */
    206