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