xref: /titanic_50/usr/src/cmd/format/hardware_structs.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1991-2002 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_HARDWARE_STRUCTS_H
28 #define	_HARDWARE_STRUCTS_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <sys/isa_defs.h>
37 
38 #include <sys/dktp/fdisk.h>
39 #include <sys/dklabel.h>
40 #include <sys/efi_partition.h>
41 
42 /*
43  * This file contains definitions of data structures pertaining to disks
44  * and controllers.
45  */
46 
47 /*
48  * This structure describes a specific disk.  These structures are in a
49  * linked list because they are malloc'd as disks are found during the
50  * initial search.
51  */
52 struct disk_info {
53 	int			label_type;	/* EFI or non-EFI disk */
54 	struct dk_cinfo		disk_dkinfo;	/* controller config info */
55 	struct disk_type	*disk_type;	/* ptr to physical info */
56 	struct partition_info	*disk_parts;	/* ptr to partition info */
57 	struct dk_gpt		*efi_parts;	/* ptr to partition info */
58 	struct ctlr_info	*disk_ctlr;	/* ptr to disk's ctlr */
59 	struct disk_info	*disk_next;	/* ptr to next disk */
60 	struct ipart		fdisk_part;	/* fdisk partition info */
61 	int			disk_flags;	/* misc gotchas */
62 	char			*disk_name;	/* name of the disk */
63 	char			*disk_path;	/* pathname to device */
64 	char			*devfs_name;	/* devfs name for device */
65 	char			v_volume[LEN_DKL_VVOL];
66 						/* volume name from label */
67 						/* (no terminating null) */
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 	int	dtype_ncyl;			/* # of data cylinders */
85 	int	dtype_acyl;			/* # of alternate cylinders */
86 	int	dtype_pcyl;			/* # of physical cylinders */
87 	int	dtype_nhead;			/* # of heads */
88 	int	dtype_phead;			/* # of physical heads */
89 	int	dtype_nsect;			/* # of data sectors/track */
90 	int	dtype_psect;			/* # physical sectors/track */
91 	int	dtype_rpm;			/* rotations per minute */
92 	int	dtype_cyl_skew;			/* cylinder skew */
93 	int	dtype_trk_skew;			/* track skew */
94 	int	dtype_trks_zone;		/* # tracks per zone */
95 	int	dtype_atrks;			/* # alt. tracks  */
96 	int	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[9];
116 	char		product[17];
117 	char		revision[5];
118 	uint64_t	capacity;
119 };
120 
121 struct efi_info {
122 	char		vendor[9];
123 	char		product[17];
124 	char		revision[5];
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