17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5342440ecSPrasad Singamsetty  * Common Development and Distribution License (the "License").
6342440ecSPrasad Singamsetty  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
2265908c77Syu, larry liu - Sun Microsystems - Beijing China  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
24f1bf0656SHans Rosenfeld  * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
25*48bbca81SDaniel Hoffman  * Copyright (c) 2016 by Delphix. All rights reserved.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #ifndef	_HARDWARE_STRUCTS_H
297c478bd9Sstevel@tonic-gate #define	_HARDWARE_STRUCTS_H
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
327c478bd9Sstevel@tonic-gate extern "C" {
337c478bd9Sstevel@tonic-gate #endif
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h>
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #include <sys/dktp/fdisk.h>
387c478bd9Sstevel@tonic-gate #include <sys/dklabel.h>
397c478bd9Sstevel@tonic-gate #include <sys/efi_partition.h>
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate /*
427c478bd9Sstevel@tonic-gate  * This file contains definitions of data structures pertaining to disks
437c478bd9Sstevel@tonic-gate  * and controllers.
447c478bd9Sstevel@tonic-gate  */
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate /*
477c478bd9Sstevel@tonic-gate  * This structure describes a specific disk.  These structures are in a
487c478bd9Sstevel@tonic-gate  * linked list because they are malloc'd as disks are found during the
497c478bd9Sstevel@tonic-gate  * initial search.
507c478bd9Sstevel@tonic-gate  */
517c478bd9Sstevel@tonic-gate struct disk_info {
527c478bd9Sstevel@tonic-gate 	int			label_type;	/* EFI or non-EFI disk */
537c478bd9Sstevel@tonic-gate 	struct dk_cinfo		disk_dkinfo;	/* controller config info */
547c478bd9Sstevel@tonic-gate 	struct disk_type	*disk_type;	/* ptr to physical info */
557c478bd9Sstevel@tonic-gate 	struct partition_info	*disk_parts;	/* ptr to partition info */
567c478bd9Sstevel@tonic-gate 	struct dk_gpt		*efi_parts;	/* ptr to partition info */
577c478bd9Sstevel@tonic-gate 	struct ctlr_info	*disk_ctlr;	/* ptr to disk's ctlr */
587c478bd9Sstevel@tonic-gate 	struct disk_info	*disk_next;	/* ptr to next disk */
597c478bd9Sstevel@tonic-gate 	struct ipart		fdisk_part;	/* fdisk partition info */
607c478bd9Sstevel@tonic-gate 	int			disk_flags;	/* misc gotchas */
617c478bd9Sstevel@tonic-gate 	char			*disk_name;	/* name of the disk */
627c478bd9Sstevel@tonic-gate 	char			*disk_path;	/* pathname to device */
637c478bd9Sstevel@tonic-gate 	char			*devfs_name;	/* devfs name for device */
647c478bd9Sstevel@tonic-gate 	char			v_volume[LEN_DKL_VVOL];
657c478bd9Sstevel@tonic-gate 						/* volume name from label */
667c478bd9Sstevel@tonic-gate 						/* (no terminating null) */
6765908c77Syu, larry liu - Sun Microsystems - Beijing China 	uint_t			disk_lbasize;	/* disk block size */
6865908c77Syu, larry liu - Sun Microsystems - Beijing China 
697c478bd9Sstevel@tonic-gate };
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate #define	NSPECIFICS	8
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate /*
747c478bd9Sstevel@tonic-gate  * This structure describes a type (model) of drive.  It is malloc'd
757c478bd9Sstevel@tonic-gate  * and filled in as the data file is read and when a type 'other' disk
767c478bd9Sstevel@tonic-gate  * is selected.  The link is used to make a list of all drive types
777c478bd9Sstevel@tonic-gate  * supported by a ctlr type.
787c478bd9Sstevel@tonic-gate  */
797c478bd9Sstevel@tonic-gate struct disk_type {
807c478bd9Sstevel@tonic-gate 	char	*dtype_asciilabel;		/* drive identifier */
817c478bd9Sstevel@tonic-gate 	int	dtype_flags;			/* flags for disk type */
827c478bd9Sstevel@tonic-gate 	ulong_t	dtype_options;			/* flags for options */
837c478bd9Sstevel@tonic-gate 	uint_t	dtype_fmt_time;			/* format time */
847c478bd9Sstevel@tonic-gate 	uint_t	dtype_bpt;			/* # bytes per track */
85342440ecSPrasad Singamsetty 	uint_t	dtype_ncyl;			/* # of data cylinders */
86342440ecSPrasad Singamsetty 	uint_t	dtype_acyl;			/* # of alternate cylinders */
87342440ecSPrasad Singamsetty 	uint_t	dtype_pcyl;			/* # of physical cylinders */
88342440ecSPrasad Singamsetty 	uint_t	dtype_nhead;			/* # of heads */
89342440ecSPrasad Singamsetty 	uint_t	dtype_phead;			/* # of physical heads */
90342440ecSPrasad Singamsetty 	uint_t	dtype_nsect;			/* # of data sectors/track */
91342440ecSPrasad Singamsetty 	uint_t	dtype_psect;			/* # physical sectors/track */
92342440ecSPrasad Singamsetty 	uint_t	dtype_rpm;			/* rotations per minute */
937c478bd9Sstevel@tonic-gate 	int	dtype_cyl_skew;			/* cylinder skew */
947c478bd9Sstevel@tonic-gate 	int	dtype_trk_skew;			/* track skew */
95342440ecSPrasad Singamsetty 	uint_t	dtype_trks_zone;		/* # tracks per zone */
96342440ecSPrasad Singamsetty 	uint_t	dtype_atrks;			/* # alt. tracks  */
97342440ecSPrasad Singamsetty 	uint_t	dtype_asect;			/* # alt. sectors */
987c478bd9Sstevel@tonic-gate 	int	dtype_cache;			/* cache control */
997c478bd9Sstevel@tonic-gate 	int	dtype_threshold;		/* cache prefetch threshold */
1007c478bd9Sstevel@tonic-gate 	int	dtype_read_retries;		/* read retries */
1017c478bd9Sstevel@tonic-gate 	int	dtype_write_retries;		/* write retries */
1027c478bd9Sstevel@tonic-gate 	int	dtype_prefetch_min;		/* cache min. prefetch */
1037c478bd9Sstevel@tonic-gate 	int	dtype_prefetch_max;		/* cache max. prefetch */
1047c478bd9Sstevel@tonic-gate 	uint_t	dtype_specifics[NSPECIFICS];	/* ctlr specific drive info */
1057c478bd9Sstevel@tonic-gate 	struct	chg_list	*dtype_chglist;	/* mode sense/select */
1067c478bd9Sstevel@tonic-gate 						/* change list - scsi */
1077c478bd9Sstevel@tonic-gate 	struct	partition_info	*dtype_plist;	/* possible partitions */
1087c478bd9Sstevel@tonic-gate 	struct	disk_type	*dtype_next;	/* ptr to next drive type */
1097c478bd9Sstevel@tonic-gate 	/*
1107c478bd9Sstevel@tonic-gate 	 * Added so that we can print a useful diagnostic if
1117c478bd9Sstevel@tonic-gate 	 * inconsistent definitions found in multiple files.
1127c478bd9Sstevel@tonic-gate 	 */
1137c478bd9Sstevel@tonic-gate 	char	*dtype_filename;		/* filename where defined */
1147c478bd9Sstevel@tonic-gate 	int	dtype_lineno;			/* line number in file */
1157c478bd9Sstevel@tonic-gate 
116f1bf0656SHans Rosenfeld 	char		*vendor;
117f1bf0656SHans Rosenfeld 	char		*product;
118f1bf0656SHans Rosenfeld 	char		*revision;
1197c478bd9Sstevel@tonic-gate 	uint64_t	capacity;
1207c478bd9Sstevel@tonic-gate };
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate struct efi_info {
123f1bf0656SHans Rosenfeld 	char		*vendor;
124f1bf0656SHans Rosenfeld 	char		*product;
125f1bf0656SHans Rosenfeld 	char		*revision;
1267c478bd9Sstevel@tonic-gate 	uint64_t	capacity;
1277c478bd9Sstevel@tonic-gate 	struct dk_gpt	*e_parts;
1287c478bd9Sstevel@tonic-gate };
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate /*
1317c478bd9Sstevel@tonic-gate  * This structure describes a specific ctlr.  These structures are in
1327c478bd9Sstevel@tonic-gate  * a linked list because they are malloc'd as ctlrs are found during
1337c478bd9Sstevel@tonic-gate  * the initial search.
1347c478bd9Sstevel@tonic-gate  */
1357c478bd9Sstevel@tonic-gate struct ctlr_info {
1367c478bd9Sstevel@tonic-gate 	char	ctlr_cname[DK_DEVLEN+1];	/* name of ctlr */
1377c478bd9Sstevel@tonic-gate 	char	ctlr_dname[DK_DEVLEN+1];	/* name of disks */
1387c478bd9Sstevel@tonic-gate 	ushort_t ctlr_flags;			/* flags for ctlr */
1397c478bd9Sstevel@tonic-gate 	short	ctlr_num;			/* number of ctlr */
1407c478bd9Sstevel@tonic-gate 	int	ctlr_addr;			/* address of ctlr */
1417c478bd9Sstevel@tonic-gate 	uint_t	ctlr_space;			/* bus space it occupies */
1427c478bd9Sstevel@tonic-gate 	int	ctlr_prio;			/* interrupt priority */
1437c478bd9Sstevel@tonic-gate 	int	ctlr_vec;			/* interrupt vector */
1447c478bd9Sstevel@tonic-gate 	struct	ctlr_type *ctlr_ctype;		/* ptr to ctlr type info */
1457c478bd9Sstevel@tonic-gate 	struct	ctlr_info *ctlr_next;		/* ptr to next ctlr */
1467c478bd9Sstevel@tonic-gate };
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate /*
1497c478bd9Sstevel@tonic-gate  * This structure describes a type (model) of ctlr.  All supported ctlr
1507c478bd9Sstevel@tonic-gate  * types are built into the program statically, they cannot be added by
1517c478bd9Sstevel@tonic-gate  * the user.
1527c478bd9Sstevel@tonic-gate  */
1537c478bd9Sstevel@tonic-gate struct ctlr_type {
1547c478bd9Sstevel@tonic-gate 	ushort_t ctype_ctype;			/* type of ctlr */
1557c478bd9Sstevel@tonic-gate 	char	*ctype_name;			/* name of ctlr type */
1567c478bd9Sstevel@tonic-gate 	struct	ctlr_ops *ctype_ops;		/* ptr to ops vector */
1577c478bd9Sstevel@tonic-gate 	int	ctype_flags;			/* flags for gotchas */
1587c478bd9Sstevel@tonic-gate 	struct	disk_type *ctype_dlist;		/* list of disk types */
1597c478bd9Sstevel@tonic-gate };
1607c478bd9Sstevel@tonic-gate 
1617c478bd9Sstevel@tonic-gate /*
1627c478bd9Sstevel@tonic-gate  * This structure is the operation vector for a controller type.  It
1637c478bd9Sstevel@tonic-gate  * contains pointers to all the functions a controller type can support.
1647c478bd9Sstevel@tonic-gate  */
1657c478bd9Sstevel@tonic-gate struct ctlr_ops {
1667c478bd9Sstevel@tonic-gate 	int	(*op_rdwr)();		/* read/write - mandatory */
1677c478bd9Sstevel@tonic-gate 	int	(*op_ck_format)();	/* check format - mandatory */
1687c478bd9Sstevel@tonic-gate 	int	(*op_format)();		/* format - mandatory */
1697c478bd9Sstevel@tonic-gate 	int	(*op_ex_man)();		/* get manufacturer's list - optional */
1707c478bd9Sstevel@tonic-gate 	int	(*op_ex_cur)();		/* get current list - optional */
1717c478bd9Sstevel@tonic-gate 	int	(*op_repair)();		/* repair bad sector - optional */
1727c478bd9Sstevel@tonic-gate 	int	(*op_create)();		/* create original manufacturers */
1737c478bd9Sstevel@tonic-gate 					/* defect list. - optional */
1747c478bd9Sstevel@tonic-gate 	int	(*op_wr_cur)();		/* write current list - optional */
1757c478bd9Sstevel@tonic-gate };
1767c478bd9Sstevel@tonic-gate 
1777c478bd9Sstevel@tonic-gate /*
1787c478bd9Sstevel@tonic-gate  * This structure describes a specific partition layout.  It is malloc'd
179*48bbca81SDaniel Hoffman  * when the data file is read and whenever the user creates their own
1807c478bd9Sstevel@tonic-gate  * partition layout.  The link is used to make a list of possible
1817c478bd9Sstevel@tonic-gate  * partition layouts for each drive type.
1827c478bd9Sstevel@tonic-gate  */
1837c478bd9Sstevel@tonic-gate struct partition_info {
1847c478bd9Sstevel@tonic-gate 	char	*pinfo_name;			/* name of layout */
1857c478bd9Sstevel@tonic-gate 	struct	dk_map32 pinfo_map[NDKMAP];	/* layout info */
1867c478bd9Sstevel@tonic-gate 	struct	dk_vtoc vtoc;			/* SVr4 vtoc additions */
1877c478bd9Sstevel@tonic-gate 	struct	partition_info *pinfo_next;	/* ptr to next layout */
1887c478bd9Sstevel@tonic-gate 	char	*pinfo_filename;		/* filename where defined */
1897c478bd9Sstevel@tonic-gate 	int	pinfo_lineno;			/* line number in file */
1907c478bd9Sstevel@tonic-gate 	struct	dk_gpt	*etoc;			/* EFI partition info */
1917c478bd9Sstevel@tonic-gate };
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate 
1947c478bd9Sstevel@tonic-gate /*
1957c478bd9Sstevel@tonic-gate  * This structure describes a change to be made to a particular
1967c478bd9Sstevel@tonic-gate  * SCSI mode sense page, before issuing a mode select on that
1977c478bd9Sstevel@tonic-gate  * page.  This changes are specified in format.dat, and one
1987c478bd9Sstevel@tonic-gate  * such structure is created for each specification, linked
1997c478bd9Sstevel@tonic-gate  * into a list, in the order specified.
2007c478bd9Sstevel@tonic-gate  */
2017c478bd9Sstevel@tonic-gate struct chg_list {
2027c478bd9Sstevel@tonic-gate 	int		pageno;		/* mode sense page no. */
2037c478bd9Sstevel@tonic-gate 	int		byteno;		/* byte within page */
2047c478bd9Sstevel@tonic-gate 	int		mode;		/* see below */
2057c478bd9Sstevel@tonic-gate 	int		value;		/* desired value */
2067c478bd9Sstevel@tonic-gate 	struct chg_list	*next;		/* ptr to next */
2077c478bd9Sstevel@tonic-gate };
2087c478bd9Sstevel@tonic-gate 
2097c478bd9Sstevel@tonic-gate /*
2107c478bd9Sstevel@tonic-gate  * Change list modes
2117c478bd9Sstevel@tonic-gate  */
2127c478bd9Sstevel@tonic-gate #define	CHG_MODE_UNDEFINED	(-1)		/* undefined value */
2137c478bd9Sstevel@tonic-gate #define	CHG_MODE_SET		0		/* set bits by or'ing */
2147c478bd9Sstevel@tonic-gate #define	CHG_MODE_CLR		1		/* clr bits by and'ing */
2157c478bd9Sstevel@tonic-gate #define	CHG_MODE_ABS		2		/* set absolute value */
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate /*
2187c478bd9Sstevel@tonic-gate  * This is the structure that creates a dynamic list of controllers
2197c478bd9Sstevel@tonic-gate  * that we know about.  This structure will point to the items that
2207c478bd9Sstevel@tonic-gate  * use to be statically created in the format program but will now allow
2217c478bd9Sstevel@tonic-gate  * dynamic creation of the list so that we can do 3'rd party generic
2227c478bd9Sstevel@tonic-gate  * disk/controller support.
2237c478bd9Sstevel@tonic-gate  */
2247c478bd9Sstevel@tonic-gate 
2257c478bd9Sstevel@tonic-gate struct mctlr_list {
2267c478bd9Sstevel@tonic-gate 	struct mctlr_list *next;
2277c478bd9Sstevel@tonic-gate 	struct ctlr_type  *ctlr_type;
2287c478bd9Sstevel@tonic-gate };
2297c478bd9Sstevel@tonic-gate 
2307c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2317c478bd9Sstevel@tonic-gate }
2327c478bd9Sstevel@tonic-gate #endif
2337c478bd9Sstevel@tonic-gate 
2347c478bd9Sstevel@tonic-gate #endif	/* _HARDWARE_STRUCTS_H */
235