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