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