1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _HARDWARE_STRUCTS_H 27 #define _HARDWARE_STRUCTS_H 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 #include <sys/isa_defs.h> 34 35 #include <sys/dktp/fdisk.h> 36 #include <sys/dklabel.h> 37 #include <sys/efi_partition.h> 38 39 /* 40 * This file contains definitions of data structures pertaining to disks 41 * and controllers. 42 */ 43 44 /* 45 * This structure describes a specific disk. These structures are in a 46 * linked list because they are malloc'd as disks are found during the 47 * initial search. 48 */ 49 struct disk_info { 50 int label_type; /* EFI or non-EFI disk */ 51 struct dk_cinfo disk_dkinfo; /* controller config info */ 52 struct disk_type *disk_type; /* ptr to physical info */ 53 struct partition_info *disk_parts; /* ptr to partition info */ 54 struct dk_gpt *efi_parts; /* ptr to partition info */ 55 struct ctlr_info *disk_ctlr; /* ptr to disk's ctlr */ 56 struct disk_info *disk_next; /* ptr to next disk */ 57 struct ipart fdisk_part; /* fdisk partition info */ 58 int disk_flags; /* misc gotchas */ 59 char *disk_name; /* name of the disk */ 60 char *disk_path; /* pathname to device */ 61 char *devfs_name; /* devfs name for device */ 62 char v_volume[LEN_DKL_VVOL]; 63 /* volume name from label */ 64 /* (no terminating null) */ 65 }; 66 67 #define NSPECIFICS 8 68 69 /* 70 * This structure describes a type (model) of drive. It is malloc'd 71 * and filled in as the data file is read and when a type 'other' disk 72 * is selected. The link is used to make a list of all drive types 73 * supported by a ctlr type. 74 */ 75 struct disk_type { 76 char *dtype_asciilabel; /* drive identifier */ 77 int dtype_flags; /* flags for disk type */ 78 ulong_t dtype_options; /* flags for options */ 79 uint_t dtype_fmt_time; /* format time */ 80 uint_t dtype_bpt; /* # bytes per track */ 81 uint_t dtype_ncyl; /* # of data cylinders */ 82 uint_t dtype_acyl; /* # of alternate cylinders */ 83 uint_t dtype_pcyl; /* # of physical cylinders */ 84 uint_t dtype_nhead; /* # of heads */ 85 uint_t dtype_phead; /* # of physical heads */ 86 uint_t dtype_nsect; /* # of data sectors/track */ 87 uint_t dtype_psect; /* # physical sectors/track */ 88 uint_t dtype_rpm; /* rotations per minute */ 89 int dtype_cyl_skew; /* cylinder skew */ 90 int dtype_trk_skew; /* track skew */ 91 uint_t dtype_trks_zone; /* # tracks per zone */ 92 uint_t dtype_atrks; /* # alt. tracks */ 93 uint_t dtype_asect; /* # alt. sectors */ 94 int dtype_cache; /* cache control */ 95 int dtype_threshold; /* cache prefetch threshold */ 96 int dtype_read_retries; /* read retries */ 97 int dtype_write_retries; /* write retries */ 98 int dtype_prefetch_min; /* cache min. prefetch */ 99 int dtype_prefetch_max; /* cache max. prefetch */ 100 uint_t dtype_specifics[NSPECIFICS]; /* ctlr specific drive info */ 101 struct chg_list *dtype_chglist; /* mode sense/select */ 102 /* change list - scsi */ 103 struct partition_info *dtype_plist; /* possible partitions */ 104 struct disk_type *dtype_next; /* ptr to next drive type */ 105 /* 106 * Added so that we can print a useful diagnostic if 107 * inconsistent definitions found in multiple files. 108 */ 109 char *dtype_filename; /* filename where defined */ 110 int dtype_lineno; /* line number in file */ 111 112 char vendor[9]; 113 char product[17]; 114 char revision[5]; 115 uint64_t capacity; 116 }; 117 118 struct efi_info { 119 char vendor[9]; 120 char product[17]; 121 char revision[5]; 122 uint64_t capacity; 123 struct dk_gpt *e_parts; 124 }; 125 126 /* 127 * This structure describes a specific ctlr. These structures are in 128 * a linked list because they are malloc'd as ctlrs are found during 129 * the initial search. 130 */ 131 struct ctlr_info { 132 char ctlr_cname[DK_DEVLEN+1]; /* name of ctlr */ 133 char ctlr_dname[DK_DEVLEN+1]; /* name of disks */ 134 ushort_t ctlr_flags; /* flags for ctlr */ 135 short ctlr_num; /* number of ctlr */ 136 int ctlr_addr; /* address of ctlr */ 137 uint_t ctlr_space; /* bus space it occupies */ 138 int ctlr_prio; /* interrupt priority */ 139 int ctlr_vec; /* interrupt vector */ 140 struct ctlr_type *ctlr_ctype; /* ptr to ctlr type info */ 141 struct ctlr_info *ctlr_next; /* ptr to next ctlr */ 142 }; 143 144 /* 145 * This structure describes a type (model) of ctlr. All supported ctlr 146 * types are built into the program statically, they cannot be added by 147 * the user. 148 */ 149 struct ctlr_type { 150 ushort_t ctype_ctype; /* type of ctlr */ 151 char *ctype_name; /* name of ctlr type */ 152 struct ctlr_ops *ctype_ops; /* ptr to ops vector */ 153 int ctype_flags; /* flags for gotchas */ 154 struct disk_type *ctype_dlist; /* list of disk types */ 155 }; 156 157 /* 158 * This structure is the operation vector for a controller type. It 159 * contains pointers to all the functions a controller type can support. 160 */ 161 struct ctlr_ops { 162 int (*op_rdwr)(); /* read/write - mandatory */ 163 int (*op_ck_format)(); /* check format - mandatory */ 164 int (*op_format)(); /* format - mandatory */ 165 int (*op_ex_man)(); /* get manufacturer's list - optional */ 166 int (*op_ex_cur)(); /* get current list - optional */ 167 int (*op_repair)(); /* repair bad sector - optional */ 168 int (*op_create)(); /* create original manufacturers */ 169 /* defect list. - optional */ 170 int (*op_wr_cur)(); /* write current list - optional */ 171 }; 172 173 /* 174 * This structure describes a specific partition layout. It is malloc'd 175 * when the data file is read and whenever the user creates his own 176 * partition layout. The link is used to make a list of possible 177 * partition layouts for each drive type. 178 */ 179 struct partition_info { 180 char *pinfo_name; /* name of layout */ 181 struct dk_map32 pinfo_map[NDKMAP]; /* layout info */ 182 struct dk_vtoc vtoc; /* SVr4 vtoc additions */ 183 struct partition_info *pinfo_next; /* ptr to next layout */ 184 char *pinfo_filename; /* filename where defined */ 185 int pinfo_lineno; /* line number in file */ 186 struct dk_gpt *etoc; /* EFI partition info */ 187 }; 188 189 190 /* 191 * This structure describes a change to be made to a particular 192 * SCSI mode sense page, before issuing a mode select on that 193 * page. This changes are specified in format.dat, and one 194 * such structure is created for each specification, linked 195 * into a list, in the order specified. 196 */ 197 struct chg_list { 198 int pageno; /* mode sense page no. */ 199 int byteno; /* byte within page */ 200 int mode; /* see below */ 201 int value; /* desired value */ 202 struct chg_list *next; /* ptr to next */ 203 }; 204 205 /* 206 * Change list modes 207 */ 208 #define CHG_MODE_UNDEFINED (-1) /* undefined value */ 209 #define CHG_MODE_SET 0 /* set bits by or'ing */ 210 #define CHG_MODE_CLR 1 /* clr bits by and'ing */ 211 #define CHG_MODE_ABS 2 /* set absolute value */ 212 213 /* 214 * This is the structure that creates a dynamic list of controllers 215 * that we know about. This structure will point to the items that 216 * use to be statically created in the format program but will now allow 217 * dynamic creation of the list so that we can do 3'rd party generic 218 * disk/controller support. 219 */ 220 221 struct mctlr_list { 222 struct mctlr_list *next; 223 struct ctlr_type *ctlr_type; 224 }; 225 226 #ifdef __cplusplus 227 } 228 #endif 229 230 #endif /* _HARDWARE_STRUCTS_H */ 231