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