xref: /onnv-gate/usr/src/cmd/format/hardware_structs.h (revision 9889:68d0fe4c716e)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57563SPrasad.Singamsetty@Sun.COM  * Common Development and Distribution License (the "License").
67563SPrasad.Singamsetty@Sun.COM  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*9889SLarry.Liu@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_HARDWARE_STRUCTS_H
270Sstevel@tonic-gate #define	_HARDWARE_STRUCTS_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #ifdef	__cplusplus
300Sstevel@tonic-gate extern "C" {
310Sstevel@tonic-gate #endif
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #include <sys/isa_defs.h>
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #include <sys/dktp/fdisk.h>
360Sstevel@tonic-gate #include <sys/dklabel.h>
370Sstevel@tonic-gate #include <sys/efi_partition.h>
380Sstevel@tonic-gate 
390Sstevel@tonic-gate /*
400Sstevel@tonic-gate  * This file contains definitions of data structures pertaining to disks
410Sstevel@tonic-gate  * and controllers.
420Sstevel@tonic-gate  */
430Sstevel@tonic-gate 
440Sstevel@tonic-gate /*
450Sstevel@tonic-gate  * This structure describes a specific disk.  These structures are in a
460Sstevel@tonic-gate  * linked list because they are malloc'd as disks are found during the
470Sstevel@tonic-gate  * initial search.
480Sstevel@tonic-gate  */
490Sstevel@tonic-gate struct disk_info {
500Sstevel@tonic-gate 	int			label_type;	/* EFI or non-EFI disk */
510Sstevel@tonic-gate 	struct dk_cinfo		disk_dkinfo;	/* controller config info */
520Sstevel@tonic-gate 	struct disk_type	*disk_type;	/* ptr to physical info */
530Sstevel@tonic-gate 	struct partition_info	*disk_parts;	/* ptr to partition info */
540Sstevel@tonic-gate 	struct dk_gpt		*efi_parts;	/* ptr to partition info */
550Sstevel@tonic-gate 	struct ctlr_info	*disk_ctlr;	/* ptr to disk's ctlr */
560Sstevel@tonic-gate 	struct disk_info	*disk_next;	/* ptr to next disk */
570Sstevel@tonic-gate 	struct ipart		fdisk_part;	/* fdisk partition info */
580Sstevel@tonic-gate 	int			disk_flags;	/* misc gotchas */
590Sstevel@tonic-gate 	char			*disk_name;	/* name of the disk */
600Sstevel@tonic-gate 	char			*disk_path;	/* pathname to device */
610Sstevel@tonic-gate 	char			*devfs_name;	/* devfs name for device */
620Sstevel@tonic-gate 	char			v_volume[LEN_DKL_VVOL];
630Sstevel@tonic-gate 						/* volume name from label */
640Sstevel@tonic-gate 						/* (no terminating null) */
65*9889SLarry.Liu@Sun.COM 	uint_t			disk_lbasize;	/* disk block size */
66*9889SLarry.Liu@Sun.COM 
670Sstevel@tonic-gate };
680Sstevel@tonic-gate 
690Sstevel@tonic-gate #define	NSPECIFICS	8
700Sstevel@tonic-gate 
710Sstevel@tonic-gate /*
720Sstevel@tonic-gate  * This structure describes a type (model) of drive.  It is malloc'd
730Sstevel@tonic-gate  * and filled in as the data file is read and when a type 'other' disk
740Sstevel@tonic-gate  * is selected.  The link is used to make a list of all drive types
750Sstevel@tonic-gate  * supported by a ctlr type.
760Sstevel@tonic-gate  */
770Sstevel@tonic-gate struct disk_type {
780Sstevel@tonic-gate 	char	*dtype_asciilabel;		/* drive identifier */
790Sstevel@tonic-gate 	int	dtype_flags;			/* flags for disk type */
800Sstevel@tonic-gate 	ulong_t	dtype_options;			/* flags for options */
810Sstevel@tonic-gate 	uint_t	dtype_fmt_time;			/* format time */
820Sstevel@tonic-gate 	uint_t	dtype_bpt;			/* # bytes per track */
837563SPrasad.Singamsetty@Sun.COM 	uint_t	dtype_ncyl;			/* # of data cylinders */
847563SPrasad.Singamsetty@Sun.COM 	uint_t	dtype_acyl;			/* # of alternate cylinders */
857563SPrasad.Singamsetty@Sun.COM 	uint_t	dtype_pcyl;			/* # of physical cylinders */
867563SPrasad.Singamsetty@Sun.COM 	uint_t	dtype_nhead;			/* # of heads */
877563SPrasad.Singamsetty@Sun.COM 	uint_t	dtype_phead;			/* # of physical heads */
887563SPrasad.Singamsetty@Sun.COM 	uint_t	dtype_nsect;			/* # of data sectors/track */
897563SPrasad.Singamsetty@Sun.COM 	uint_t	dtype_psect;			/* # physical sectors/track */
907563SPrasad.Singamsetty@Sun.COM 	uint_t	dtype_rpm;			/* rotations per minute */
910Sstevel@tonic-gate 	int	dtype_cyl_skew;			/* cylinder skew */
920Sstevel@tonic-gate 	int	dtype_trk_skew;			/* track skew */
937563SPrasad.Singamsetty@Sun.COM 	uint_t	dtype_trks_zone;		/* # tracks per zone */
947563SPrasad.Singamsetty@Sun.COM 	uint_t	dtype_atrks;			/* # alt. tracks  */
957563SPrasad.Singamsetty@Sun.COM 	uint_t	dtype_asect;			/* # alt. sectors */
960Sstevel@tonic-gate 	int	dtype_cache;			/* cache control */
970Sstevel@tonic-gate 	int	dtype_threshold;		/* cache prefetch threshold */
980Sstevel@tonic-gate 	int	dtype_read_retries;		/* read retries */
990Sstevel@tonic-gate 	int	dtype_write_retries;		/* write retries */
1000Sstevel@tonic-gate 	int	dtype_prefetch_min;		/* cache min. prefetch */
1010Sstevel@tonic-gate 	int	dtype_prefetch_max;		/* cache max. prefetch */
1020Sstevel@tonic-gate 	uint_t	dtype_specifics[NSPECIFICS];	/* ctlr specific drive info */
1030Sstevel@tonic-gate 	struct	chg_list	*dtype_chglist;	/* mode sense/select */
1040Sstevel@tonic-gate 						/* change list - scsi */
1050Sstevel@tonic-gate 	struct	partition_info	*dtype_plist;	/* possible partitions */
1060Sstevel@tonic-gate 	struct	disk_type	*dtype_next;	/* ptr to next drive type */
1070Sstevel@tonic-gate 	/*
1080Sstevel@tonic-gate 	 * Added so that we can print a useful diagnostic if
1090Sstevel@tonic-gate 	 * inconsistent definitions found in multiple files.
1100Sstevel@tonic-gate 	 */
1110Sstevel@tonic-gate 	char	*dtype_filename;		/* filename where defined */
1120Sstevel@tonic-gate 	int	dtype_lineno;			/* line number in file */
1130Sstevel@tonic-gate 
1140Sstevel@tonic-gate 	char		vendor[9];
1150Sstevel@tonic-gate 	char		product[17];
1160Sstevel@tonic-gate 	char		revision[5];
1170Sstevel@tonic-gate 	uint64_t	capacity;
1180Sstevel@tonic-gate };
1190Sstevel@tonic-gate 
1200Sstevel@tonic-gate struct efi_info {
1210Sstevel@tonic-gate 	char		vendor[9];
1220Sstevel@tonic-gate 	char		product[17];
1230Sstevel@tonic-gate 	char		revision[5];
1240Sstevel@tonic-gate 	uint64_t	capacity;
1250Sstevel@tonic-gate 	struct dk_gpt	*e_parts;
1260Sstevel@tonic-gate };
1270Sstevel@tonic-gate 
1280Sstevel@tonic-gate /*
1290Sstevel@tonic-gate  * This structure describes a specific ctlr.  These structures are in
1300Sstevel@tonic-gate  * a linked list because they are malloc'd as ctlrs are found during
1310Sstevel@tonic-gate  * the initial search.
1320Sstevel@tonic-gate  */
1330Sstevel@tonic-gate struct ctlr_info {
1340Sstevel@tonic-gate 	char	ctlr_cname[DK_DEVLEN+1];	/* name of ctlr */
1350Sstevel@tonic-gate 	char	ctlr_dname[DK_DEVLEN+1];	/* name of disks */
1360Sstevel@tonic-gate 	ushort_t ctlr_flags;			/* flags for ctlr */
1370Sstevel@tonic-gate 	short	ctlr_num;			/* number of ctlr */
1380Sstevel@tonic-gate 	int	ctlr_addr;			/* address of ctlr */
1390Sstevel@tonic-gate 	uint_t	ctlr_space;			/* bus space it occupies */
1400Sstevel@tonic-gate 	int	ctlr_prio;			/* interrupt priority */
1410Sstevel@tonic-gate 	int	ctlr_vec;			/* interrupt vector */
1420Sstevel@tonic-gate 	struct	ctlr_type *ctlr_ctype;		/* ptr to ctlr type info */
1430Sstevel@tonic-gate 	struct	ctlr_info *ctlr_next;		/* ptr to next ctlr */
1440Sstevel@tonic-gate };
1450Sstevel@tonic-gate 
1460Sstevel@tonic-gate /*
1470Sstevel@tonic-gate  * This structure describes a type (model) of ctlr.  All supported ctlr
1480Sstevel@tonic-gate  * types are built into the program statically, they cannot be added by
1490Sstevel@tonic-gate  * the user.
1500Sstevel@tonic-gate  */
1510Sstevel@tonic-gate struct ctlr_type {
1520Sstevel@tonic-gate 	ushort_t ctype_ctype;			/* type of ctlr */
1530Sstevel@tonic-gate 	char	*ctype_name;			/* name of ctlr type */
1540Sstevel@tonic-gate 	struct	ctlr_ops *ctype_ops;		/* ptr to ops vector */
1550Sstevel@tonic-gate 	int	ctype_flags;			/* flags for gotchas */
1560Sstevel@tonic-gate 	struct	disk_type *ctype_dlist;		/* list of disk types */
1570Sstevel@tonic-gate };
1580Sstevel@tonic-gate 
1590Sstevel@tonic-gate /*
1600Sstevel@tonic-gate  * This structure is the operation vector for a controller type.  It
1610Sstevel@tonic-gate  * contains pointers to all the functions a controller type can support.
1620Sstevel@tonic-gate  */
1630Sstevel@tonic-gate struct ctlr_ops {
1640Sstevel@tonic-gate 	int	(*op_rdwr)();		/* read/write - mandatory */
1650Sstevel@tonic-gate 	int	(*op_ck_format)();	/* check format - mandatory */
1660Sstevel@tonic-gate 	int	(*op_format)();		/* format - mandatory */
1670Sstevel@tonic-gate 	int	(*op_ex_man)();		/* get manufacturer's list - optional */
1680Sstevel@tonic-gate 	int	(*op_ex_cur)();		/* get current list - optional */
1690Sstevel@tonic-gate 	int	(*op_repair)();		/* repair bad sector - optional */
1700Sstevel@tonic-gate 	int	(*op_create)();		/* create original manufacturers */
1710Sstevel@tonic-gate 					/* defect list. - optional */
1720Sstevel@tonic-gate 	int	(*op_wr_cur)();		/* write current list - optional */
1730Sstevel@tonic-gate };
1740Sstevel@tonic-gate 
1750Sstevel@tonic-gate /*
1760Sstevel@tonic-gate  * This structure describes a specific partition layout.  It is malloc'd
1770Sstevel@tonic-gate  * when the data file is read and whenever the user creates his own
1780Sstevel@tonic-gate  * partition layout.  The link is used to make a list of possible
1790Sstevel@tonic-gate  * partition layouts for each drive type.
1800Sstevel@tonic-gate  */
1810Sstevel@tonic-gate struct partition_info {
1820Sstevel@tonic-gate 	char	*pinfo_name;			/* name of layout */
1830Sstevel@tonic-gate 	struct	dk_map32 pinfo_map[NDKMAP];	/* layout info */
1840Sstevel@tonic-gate 	struct	dk_vtoc vtoc;			/* SVr4 vtoc additions */
1850Sstevel@tonic-gate 	struct	partition_info *pinfo_next;	/* ptr to next layout */
1860Sstevel@tonic-gate 	char	*pinfo_filename;		/* filename where defined */
1870Sstevel@tonic-gate 	int	pinfo_lineno;			/* line number in file */
1880Sstevel@tonic-gate 	struct	dk_gpt	*etoc;			/* EFI partition info */
1890Sstevel@tonic-gate };
1900Sstevel@tonic-gate 
1910Sstevel@tonic-gate 
1920Sstevel@tonic-gate /*
1930Sstevel@tonic-gate  * This structure describes a change to be made to a particular
1940Sstevel@tonic-gate  * SCSI mode sense page, before issuing a mode select on that
1950Sstevel@tonic-gate  * page.  This changes are specified in format.dat, and one
1960Sstevel@tonic-gate  * such structure is created for each specification, linked
1970Sstevel@tonic-gate  * into a list, in the order specified.
1980Sstevel@tonic-gate  */
1990Sstevel@tonic-gate struct chg_list {
2000Sstevel@tonic-gate 	int		pageno;		/* mode sense page no. */
2010Sstevel@tonic-gate 	int		byteno;		/* byte within page */
2020Sstevel@tonic-gate 	int		mode;		/* see below */
2030Sstevel@tonic-gate 	int		value;		/* desired value */
2040Sstevel@tonic-gate 	struct chg_list	*next;		/* ptr to next */
2050Sstevel@tonic-gate };
2060Sstevel@tonic-gate 
2070Sstevel@tonic-gate /*
2080Sstevel@tonic-gate  * Change list modes
2090Sstevel@tonic-gate  */
2100Sstevel@tonic-gate #define	CHG_MODE_UNDEFINED	(-1)		/* undefined value */
2110Sstevel@tonic-gate #define	CHG_MODE_SET		0		/* set bits by or'ing */
2120Sstevel@tonic-gate #define	CHG_MODE_CLR		1		/* clr bits by and'ing */
2130Sstevel@tonic-gate #define	CHG_MODE_ABS		2		/* set absolute value */
2140Sstevel@tonic-gate 
2150Sstevel@tonic-gate /*
2160Sstevel@tonic-gate  * This is the structure that creates a dynamic list of controllers
2170Sstevel@tonic-gate  * that we know about.  This structure will point to the items that
2180Sstevel@tonic-gate  * use to be statically created in the format program but will now allow
2190Sstevel@tonic-gate  * dynamic creation of the list so that we can do 3'rd party generic
2200Sstevel@tonic-gate  * disk/controller support.
2210Sstevel@tonic-gate  */
2220Sstevel@tonic-gate 
2230Sstevel@tonic-gate struct mctlr_list {
2240Sstevel@tonic-gate 	struct mctlr_list *next;
2250Sstevel@tonic-gate 	struct ctlr_type  *ctlr_type;
2260Sstevel@tonic-gate };
2270Sstevel@tonic-gate 
2280Sstevel@tonic-gate #ifdef	__cplusplus
2290Sstevel@tonic-gate }
2300Sstevel@tonic-gate #endif
2310Sstevel@tonic-gate 
2320Sstevel@tonic-gate #endif	/* _HARDWARE_STRUCTS_H */
233