1*76abd28dSriastradh /* $NetBSD: disk.h,v 1.78 2023/05/09 12:04:04 riastradh Exp $ */ 2176a81b2Sthorpej 3176a81b2Sthorpej /*- 4baefaf44Sthorpej * Copyright (c) 1996, 1997, 2004 The NetBSD Foundation, Inc. 5176a81b2Sthorpej * All rights reserved. 6176a81b2Sthorpej * 7176a81b2Sthorpej * This code is derived from software contributed to The NetBSD Foundation 8176a81b2Sthorpej * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 9176a81b2Sthorpej * NASA Ames Research Center. 10176a81b2Sthorpej * 11176a81b2Sthorpej * Redistribution and use in source and binary forms, with or without 12176a81b2Sthorpej * modification, are permitted provided that the following conditions 13176a81b2Sthorpej * are met: 14176a81b2Sthorpej * 1. Redistributions of source code must retain the above copyright 15176a81b2Sthorpej * notice, this list of conditions and the following disclaimer. 16176a81b2Sthorpej * 2. Redistributions in binary form must reproduce the above copyright 17176a81b2Sthorpej * notice, this list of conditions and the following disclaimer in the 18176a81b2Sthorpej * documentation and/or other materials provided with the distribution. 19176a81b2Sthorpej * 20176a81b2Sthorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21176a81b2Sthorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22176a81b2Sthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23176a81b2Sthorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24176a81b2Sthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25176a81b2Sthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26176a81b2Sthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27176a81b2Sthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28176a81b2Sthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29176a81b2Sthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30176a81b2Sthorpej * POSSIBILITY OF SUCH DAMAGE. 31176a81b2Sthorpej */ 32fccfa11aScgd 337318599bSglass /* 341f7c6f84Sglass * Copyright (c) 1992, 1993 351f7c6f84Sglass * The Regents of the University of California. All rights reserved. 367318599bSglass * 377318599bSglass * This software was developed by the Computer Systems Engineering group 387318599bSglass * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 397318599bSglass * contributed to Berkeley. 407318599bSglass * 417318599bSglass * All advertising materials mentioning features or use of this software 427318599bSglass * must display the following acknowledgement: 437318599bSglass * This product includes software developed by the University of 4467dbe5edSchristos * California, Lawrence Berkeley Laboratories. 457318599bSglass * 467318599bSglass * Redistribution and use in source and binary forms, with or without 477318599bSglass * modification, are permitted provided that the following conditions 487318599bSglass * are met: 497318599bSglass * 1. Redistributions of source code must retain the above copyright 507318599bSglass * notice, this list of conditions and the following disclaimer. 517318599bSglass * 2. Redistributions in binary form must reproduce the above copyright 527318599bSglass * notice, this list of conditions and the following disclaimer in the 537318599bSglass * documentation and/or other materials provided with the distribution. 54aad01611Sagc * 3. Neither the name of the University nor the names of its contributors 557318599bSglass * may be used to endorse or promote products derived from this software 567318599bSglass * without specific prior written permission. 577318599bSglass * 587318599bSglass * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 597318599bSglass * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 607318599bSglass * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 617318599bSglass * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 627318599bSglass * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 637318599bSglass * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 647318599bSglass * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 657318599bSglass * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 667318599bSglass * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 677318599bSglass * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 687318599bSglass * SUCH DAMAGE. 697318599bSglass * 701f7c6f84Sglass * from: Header: disk.h,v 1.5 92/11/19 04:33:03 torek Exp (LBL) 71c7c532b7Scgd * 72e5bc90f4Sfvdl * @(#)disk.h 8.2 (Berkeley) 1/9/95 737318599bSglass */ 747318599bSglass 75d39928a2Sperry #ifndef _SYS_DISK_H_ 76d39928a2Sperry #define _SYS_DISK_H_ 77d39928a2Sperry 787318599bSglass /* 797318599bSglass * Disk device structures. 807318599bSglass */ 817318599bSglass 82baefaf44Sthorpej #include <sys/dkio.h> 835b39541eSthorpej #include <sys/time.h> 845b39541eSthorpej #include <sys/queue.h> 8523c01cd2Schs #include <sys/iostat.h> 865b39541eSthorpej 87baefaf44Sthorpej /* 881edb4063Sthorpej * Disk information dictionary. 891edb4063Sthorpej * 907991f5a7Sandvar * This contains general information for disk devices. 911edb4063Sthorpej * 921edb4063Sthorpej * <dict> 931edb4063Sthorpej * <key>type</key> 941edb4063Sthorpej * <string>...</string> 951edb4063Sthorpej * <key>geometry</key> 961edb4063Sthorpej * <dict> 971edb4063Sthorpej * <!-- See below for disk geometry dictionary 981edb4063Sthorpej * contents. --> 991edb4063Sthorpej * </dict> 1001edb4063Sthorpej * 1011edb4063Sthorpej * <!-- optional information --> 1021edb4063Sthorpej * <key>rpm</key> 1031edb4063Sthorpej * <integer>...</integer> 1041edb4063Sthorpej * <key>sector-interleave</key> 1051edb4063Sthorpej * <integer>...</integer> 1061edb4063Sthorpej * <key>track-skew</key> 1071edb4063Sthorpej * <integer>...</integer> 1081edb4063Sthorpej * <key>cylinder-skew</key> 1091edb4063Sthorpej * <integer>...</integer> 1101edb4063Sthorpej * <key>head-switch-usecs</key> 1111edb4063Sthorpej * <integer>...</integer> 1121edb4063Sthorpej * <key>track-seek-usecs</key> 1131edb4063Sthorpej * <integer>...</integer> 1141edb4063Sthorpej * <key>removable</key> 1151edb4063Sthorpej * <false/> 1161edb4063Sthorpej * <key>ecc</key> 1171edb4063Sthorpej * <false/> 1181edb4063Sthorpej * <key>bad-sector-forwarding</key> 1191edb4063Sthorpej * <true/> 1201edb4063Sthorpej * <key>ramdisk</key> 1211edb4063Sthorpej * <false/> 1221edb4063Sthorpej * <key>back-to-back-transfers</key> 1231edb4063Sthorpej * <true/> 1241edb4063Sthorpej * 1251edb4063Sthorpej * <!-- additional information for SMD drives --> 1261edb4063Sthorpej * <key>smd-skip-sectoring</key> 1271edb4063Sthorpej * <false/> 1281edb4063Sthorpej * <!-- XXX better names for these properties --> 1291edb4063Sthorpej * <key>smd-mindist</key> 1301edb4063Sthorpej * <integer>...</integer> 1311edb4063Sthorpej * <key>smd-maxdist</key> 1321edb4063Sthorpej * <integer>...</integer> 1331edb4063Sthorpej * <key>smd-sdist</key> 1341edb4063Sthorpej * <integer>...</integer> 1351edb4063Sthorpej * 1361edb4063Sthorpej * <!-- additional information for ST506 drives --> 1371edb4063Sthorpej * <!-- XXX better names for these properties --> 1381edb4063Sthorpej * <key>st506-precompcyl</key> 1391edb4063Sthorpej * <integer>...</integer> 1401edb4063Sthorpej * <key>st506-gap3</key> 1411edb4063Sthorpej * <integer>...</integer> 1421edb4063Sthorpej * 1431edb4063Sthorpej * <!-- additional information for ATA drives --> 1441edb4063Sthorpej * <!-- XXX --> 1451edb4063Sthorpej * 1461edb4063Sthorpej * <!-- additional information for SCSI drives --> 1471edb4063Sthorpej * <!-- XXX --> 1481edb4063Sthorpej * </dict> 1491edb4063Sthorpej */ 1501edb4063Sthorpej 1511edb4063Sthorpej /* 152baefaf44Sthorpej * dkwedge_info: 153baefaf44Sthorpej * 154baefaf44Sthorpej * Information needed to configure (or query configuration of) a 155baefaf44Sthorpej * disk wedge. 156baefaf44Sthorpej */ 157baefaf44Sthorpej struct dkwedge_info { 158baefaf44Sthorpej char dkw_devname[16];/* device-style name (e.g. "dk0") */ 159baefaf44Sthorpej uint8_t dkw_wname[128]; /* wedge name (Unicode, UTF-8) */ 160baefaf44Sthorpej char dkw_parent[16]; /* parent disk device name */ 161baefaf44Sthorpej daddr_t dkw_offset; /* LBA offset of wedge in parent */ 162baefaf44Sthorpej uint64_t dkw_size; /* size of wedge in blocks */ 163baefaf44Sthorpej char dkw_ptype[32]; /* partition type string */ 164baefaf44Sthorpej }; 165baefaf44Sthorpej 166baefaf44Sthorpej /* 167baefaf44Sthorpej * dkwedge_list: 168baefaf44Sthorpej * 169baefaf44Sthorpej * Structure used to query a list of wedges. 170baefaf44Sthorpej */ 171baefaf44Sthorpej struct dkwedge_list { 172baefaf44Sthorpej void *dkwl_buf; /* storage for dkwedge_info array */ 173baefaf44Sthorpej size_t dkwl_bufsize; /* size of that buffer */ 174baefaf44Sthorpej u_int dkwl_nwedges; /* total number of wedges */ 175baefaf44Sthorpej u_int dkwl_ncopied; /* number actually copied */ 176baefaf44Sthorpej }; 177baefaf44Sthorpej 178baefaf44Sthorpej /* Some common partition types */ 179baefaf44Sthorpej #define DKW_PTYPE_UNKNOWN "" 180baefaf44Sthorpej #define DKW_PTYPE_UNUSED "unused" 181baefaf44Sthorpej #define DKW_PTYPE_SWAP "swap" 182fd091bf3Schristos #define DKW_PTYPE_V6 "v6" 183fd091bf3Schristos #define DKW_PTYPE_V7 "v7" 184fd091bf3Schristos #define DKW_PTYPE_SYSV "sysv" 185fd091bf3Schristos #define DKW_PTYPE_V71K "v71k" 186fd091bf3Schristos #define DKW_PTYPE_V8 "v8" 187baefaf44Sthorpej #define DKW_PTYPE_FFS "ffs" 188baefaf44Sthorpej #define DKW_PTYPE_FAT "msdos" 189fd091bf3Schristos #define DKW_PTYPE_LFS "lfs" 190fd091bf3Schristos #define DKW_PTYPE_OTHER "other" 191fd091bf3Schristos #define DKW_PTYPE_HPFS "hpfs" 192fd091bf3Schristos #define DKW_PTYPE_ISO9660 "cd9660" 193fd091bf3Schristos #define DKW_PTYPE_BOOT "boot" 194fd091bf3Schristos #define DKW_PTYPE_AMIGADOS "ados" 195fd091bf3Schristos #define DKW_PTYPE_HFS "hfs" 196baefaf44Sthorpej #define DKW_PTYPE_FILECORE "filecore" 197fd091bf3Schristos #define DKW_PTYPE_EXT2FS "ext2fs" 198fd091bf3Schristos #define DKW_PTYPE_NTFS "ntfs" 199baefaf44Sthorpej #define DKW_PTYPE_RAIDFRAME "raidframe" 200baefaf44Sthorpej #define DKW_PTYPE_CCD "ccd" 201fd091bf3Schristos #define DKW_PTYPE_JFS2 "jfs2" 202baefaf44Sthorpej #define DKW_PTYPE_APPLEUFS "appleufs" 203fd091bf3Schristos #define DKW_PTYPE_VINUM "vinum" 204fd091bf3Schristos #define DKW_PTYPE_UDF "udf" 205fd091bf3Schristos #define DKW_PTYPE_APPLEHFS "hfs" 206fd091bf3Schristos #define DKW_PTYPE_SYSVBFS "sysvbfs" 207fd091bf3Schristos #define DKW_PTYPE_EFS "efs" 208fd091bf3Schristos #define DKW_PTYPE_NILFS "nilfs" 20942a4e6efSriz #define DKW_PTYPE_CGD "cgd" 210488f0926Schristos #define DKW_PTYPE_MINIXFS3 "minixfs3" 211f5f53dd6Smrg #define DKW_PTYPE_VMKCORE "vmkcore" 212f5f53dd6Smrg #define DKW_PTYPE_VMFS "vmfs" 213f5f53dd6Smrg #define DKW_PTYPE_VMWRESV "vmwresv" 21481e8a3b4Swiz #define DKW_PTYPE_ZFS "zfs" 215baefaf44Sthorpej 216baefaf44Sthorpej /* 217c26d630aSapb * Ensure each symbol used in FSTYPE_DEFN in <sys/disklabel.h> 218c26d630aSapb * has a corresponding DKW_PTYPE_* definition. 219c26d630aSapb */ 220c26d630aSapb #define DKW_PTYPE_MSDOS DKW_PTYPE_FAT 221c26d630aSapb #define DKW_PTYPE_BSDFFS DKW_PTYPE_FFS 222c26d630aSapb #define DKW_PTYPE_BSDLFS DKW_PTYPE_LFS 223c26d630aSapb #define DKW_PTYPE_ADOS DKW_PTYPE_AMIGADOS 224c26d630aSapb #define DKW_PTYPE_EX2FS DKW_PTYPE_EXT2FS 225c26d630aSapb #define DKW_PTYPE_RAID DKW_PTYPE_RAIDFRAME 226c26d630aSapb 227c26d630aSapb /* 2281edb4063Sthorpej * Disk geometry dictionary. 229baefaf44Sthorpej * 230baefaf44Sthorpej * NOTE: Not all geometry information is relevant for every kind of disk. 2311edb4063Sthorpej * 2321edb4063Sthorpej * <dict> 2331edb4063Sthorpej * <key>sectors-per-unit</key> 2341edb4063Sthorpej * <integer>...</integer> 2351edb4063Sthorpej * <key>sector-size</key> 2361edb4063Sthorpej * <integer>...</integer> 2371edb4063Sthorpej * <key>sectors-per-track</key> 2381edb4063Sthorpej * <integer>...</integer> 2391edb4063Sthorpej * <key>tracks-per-cylinder</key> 2401edb4063Sthorpej * <integer>...</integer> 2411edb4063Sthorpej * <key>cylinders-per-unit</key> 2421edb4063Sthorpej * <integer>...</integer> 2431edb4063Sthorpej * <key>physical-cylinders-per-unit</key> 2441edb4063Sthorpej * <integer>...</integer> 2451edb4063Sthorpej * <key>spare-sectors-per-track</key> 2461edb4063Sthorpej * <integer>...</integer> 2471edb4063Sthorpej * <key>spare-sectors-per-cylinder</key> 2481edb4063Sthorpej * <integer>...</integer> 2491edb4063Sthorpej * <key>alternative-cylinders</key> 2501edb4063Sthorpej * <integer>...</integer> 2511edb4063Sthorpej * </dict> 2521edb4063Sthorpej * NOTE: Not all geometry information is relevant for every kind of disk. 253baefaf44Sthorpej */ 2541edb4063Sthorpej 255f815ec90Sthorpej struct disk_geom { 256f815ec90Sthorpej int64_t dg_secperunit; /* # of data sectors per unit */ 257f815ec90Sthorpej uint32_t dg_secsize; /* # of bytes per sector */ 258f815ec90Sthorpej uint32_t dg_nsectors; /* # of data sectors per track */ 259f815ec90Sthorpej uint32_t dg_ntracks; /* # of tracks per cylinder */ 260f815ec90Sthorpej uint32_t dg_ncylinders; /* # of data cylinders per unit */ 261f815ec90Sthorpej uint32_t dg_secpercyl; /* # of data sectors per cylinder */ 262f815ec90Sthorpej uint32_t dg_pcylinders; /* # of physical cylinders per unit */ 263f815ec90Sthorpej 264f815ec90Sthorpej /* 265f815ec90Sthorpej * Spares (bad sector replacements) below are not counted in 266f815ec90Sthorpej * dg_nsectors or dg_secpercyl. Spare sectors are assumed to 267f815ec90Sthorpej * be physical sectors which occupy space at the end of each 268f815ec90Sthorpej * track and/or cylinder. 269f815ec90Sthorpej */ 270f815ec90Sthorpej uint32_t dg_sparespertrack; 271f815ec90Sthorpej uint32_t dg_sparespercyl; 272f815ec90Sthorpej /* 273f815ec90Sthorpej * Alternative cylinders include maintenance, replacement, 274f815ec90Sthorpej * configuration description areas, etc. 275f815ec90Sthorpej */ 276f815ec90Sthorpej uint32_t dg_acylinders; 277f815ec90Sthorpej }; 278f815ec90Sthorpej 2791edb4063Sthorpej /* 2803c0c10dbSchs * Bad sector lists per fixed disk 2813c0c10dbSchs */ 2823c0c10dbSchs struct disk_badsectors { 2833c0c10dbSchs SLIST_ENTRY(disk_badsectors) dbs_next; 2843c0c10dbSchs daddr_t dbs_min; /* min. sector number */ 2853c0c10dbSchs daddr_t dbs_max; /* max. sector number */ 2863c0c10dbSchs struct timeval dbs_failedat; /* first failure at */ 2873c0c10dbSchs }; 2883c0c10dbSchs 2893c0c10dbSchs struct disk_badsecinfo { 2903c0c10dbSchs uint32_t dbsi_bufsize; /* size of region pointed to */ 2913c0c10dbSchs uint32_t dbsi_skip; /* how many to skip past */ 2923c0c10dbSchs uint32_t dbsi_copied; /* how many got copied back */ 2933c0c10dbSchs uint32_t dbsi_left; /* remaining to copy */ 2943c0c10dbSchs void * dbsi_buffer; /* region to copy disk_badsectors to */ 2953c0c10dbSchs }; 2963c0c10dbSchs 2973c0c10dbSchs #define DK_STRATEGYNAMELEN 32 2983c0c10dbSchs struct disk_strategy { 2993c0c10dbSchs char dks_name[DK_STRATEGYNAMELEN]; /* name of strategy */ 3003c0c10dbSchs char *dks_param; /* notyet; should be NULL */ 3013c0c10dbSchs size_t dks_paramlen; /* notyet; should be 0 */ 3023c0c10dbSchs }; 3033c0c10dbSchs 304ffcf681eSriastradh /* Sector alignment */ 305ffcf681eSriastradh struct disk_sectoralign { 306ffcf681eSriastradh uint32_t dsa_firstaligned; /* first aligned sector # */ 307ffcf681eSriastradh uint32_t dsa_alignment; /* sectors per aligned sector */ 308ffcf681eSriastradh }; 309ffcf681eSriastradh 3103c0c10dbSchs #ifdef _KERNEL 3113c0c10dbSchs #include <sys/device.h> 3123c0c10dbSchs #include <sys/mutex.h> 3133c0c10dbSchs 3143c0c10dbSchs #include <prop/proplib.h> 3153c0c10dbSchs 3163c0c10dbSchs struct buf; 3173c0c10dbSchs struct disk; 3183c0c10dbSchs struct disklabel; 3193c0c10dbSchs struct cpu_disklabel; 3203c0c10dbSchs struct lwp; 3213c0c10dbSchs struct vnode; 3223c0c10dbSchs 3233c0c10dbSchs /* 3243c0c10dbSchs * dkwedge_discovery_method: 3253c0c10dbSchs * 3263c0c10dbSchs * Structure used to describe partition map parsing schemes 3273c0c10dbSchs * used for wedge autodiscovery. 3283c0c10dbSchs */ 3293c0c10dbSchs struct dkwedge_discovery_method { 3303c0c10dbSchs /* link in wedge driver's list */ 3313c0c10dbSchs LIST_ENTRY(dkwedge_discovery_method) ddm_list; 3323c0c10dbSchs const char *ddm_name; /* name of this method */ 3333c0c10dbSchs int ddm_priority; /* search priority */ 3343c0c10dbSchs int (*ddm_discover)(struct disk *, struct vnode *); 3353c0c10dbSchs }; 3363c0c10dbSchs 3373c0c10dbSchs #define DKWEDGE_DISCOVERY_METHOD_DECL(name, prio, discover) \ 3383c0c10dbSchs static struct dkwedge_discovery_method name ## _ddm = { \ 3393c0c10dbSchs { NULL, NULL }, \ 3403c0c10dbSchs #name, \ 3413c0c10dbSchs prio, \ 3423c0c10dbSchs discover \ 3433c0c10dbSchs }; \ 3443c0c10dbSchs __link_set_add_data(dkwedge_methods, name ## _ddm) 3453c0c10dbSchs 3463c0c10dbSchs /* 3471edb4063Sthorpej * Disk partition dictionary. 3481edb4063Sthorpej * 3491edb4063Sthorpej * A partition is represented as a dictionary containing generic partition 3501edb4063Sthorpej * properties (such as starting block and block count), as well as information 3511edb4063Sthorpej * that is specific to individual partition map formats. 3521edb4063Sthorpej * 3531edb4063Sthorpej * <dict> 3541edb4063Sthorpej * <key>start-block</key> 3551edb4063Sthorpej * <integer>...</integer> 3561edb4063Sthorpej * <key>block-count</key> 3571edb4063Sthorpej * <integer>...</integer> 3581edb4063Sthorpej * <!-- DKW_PTYPE strings ("" or missing if unknown) --> 3591edb4063Sthorpej * <key>type</type> 3601edb4063Sthorpej * <string>...</string> 3611edb4063Sthorpej * <!-- optional --> 3621edb4063Sthorpej * <key>name</key> 3631edb4063Sthorpej * <string>...</string> 3641edb4063Sthorpej * 3651edb4063Sthorpej * <!-- these are valid for GPT partition maps --> 3661edb4063Sthorpej * <key>gpt-type-guid</key> 3671edb4063Sthorpej * <string>...</string> 3681edb4063Sthorpej * <key>gpt-partition-guid</key> 3691edb4063Sthorpej * <string>...</string> 3701edb4063Sthorpej * <key>gpt-platform-required</key> 3711edb4063Sthorpej * <false/> 3721edb4063Sthorpej * 3731edb4063Sthorpej * <!-- these are valid for 4.4BSD partition maps --> 3741edb4063Sthorpej * <key>bsd44-partition-type</key> 3751edb4063Sthorpej * <integer>...</integer> 3761edb4063Sthorpej * <key>bsd44-fs-fragment-size</key> 3771edb4063Sthorpej * <integer>...</integer> 3781edb4063Sthorpej * <key>bsd44-iso9660-session-offset</key> 3791edb4063Sthorpej * <integer>...</integer> 3801edb4063Sthorpej * <key>bsd44-ffs-cylinders-per-group</key> 3811edb4063Sthorpej * <integer>...</integer> 3821edb4063Sthorpej * <key>bsd44-lfs-segment-shift</key> 3831edb4063Sthorpej * <integer>...</integer> 3841edb4063Sthorpej * 3851edb4063Sthorpej * <!-- these are valid for NeXT partition maps --> 3861edb4063Sthorpej * <key>next-block-size</key> 3871edb4063Sthorpej * <integer>...</integer> 3881edb4063Sthorpej * <key>next-fs-fragment-size</key> 3891edb4063Sthorpej * <integer>...</integer> 3901edb4063Sthorpej * <key>next-fs-optimization</key> 3911edb4063Sthorpej * <string>...</string> <!-- "space" or "time" --> 3921edb4063Sthorpej * <key>next-fs-cylinders-per-group</key> 3931edb4063Sthorpej * <integer>...</integer> 3941edb4063Sthorpej * <key>next-bytes-per-inode-density</key> 3951edb4063Sthorpej * <integer>...</integer> 3961edb4063Sthorpej * <key>next-minfree-percentage</key> 3971edb4063Sthorpej * <integer>...</integer> 3981edb4063Sthorpej * <key>next-run-newfs-during-init</key> 3991edb4063Sthorpej * <false/> 4001edb4063Sthorpej * <key>next-mount-point</key> 4011edb4063Sthorpej * <string>...</string> 4021edb4063Sthorpej * <key>next-automount</key> 4031edb4063Sthorpej * <true/> 4041edb4063Sthorpej * <key>next-partition-type</key> 4051edb4063Sthorpej * <string>...</string> 4061edb4063Sthorpej * 4071edb4063Sthorpej * <!-- these are valid for MBR partition maps --> 4081edb4063Sthorpej * <key>mbr-start-head</key> 4091edb4063Sthorpej * <integer>...</integer> 4101edb4063Sthorpej * <key>mbr-start-sector</key> 4111edb4063Sthorpej * <integer>...</integer> 4121edb4063Sthorpej * <key>mbr-start-cylinder</key> 4131edb4063Sthorpej * <integer>...</integer> 4141edb4063Sthorpej * <key>mbr-partition-type</key> 4151edb4063Sthorpej * <integer>...</integer> 4161edb4063Sthorpej * <key>mbr-end-head</key> 4171edb4063Sthorpej * <integer>...</integer> 4181edb4063Sthorpej * <key>mbr-end-sector</key> 4191edb4063Sthorpej * <integer>...</integer> 4201edb4063Sthorpej * <key>mbr-end-cylinder</key> 4211edb4063Sthorpej * <integer>...</integer> 4221edb4063Sthorpej * <key>mbr-active-partition</key> 4231edb4063Sthorpej * <false/> 4241edb4063Sthorpej * 4251edb4063Sthorpej * <!-- these are valid for Apple partition maps --> 4261edb4063Sthorpej * <key>apple-partition-type</key> 4271edb4063Sthorpej * <string>...</string> 4281edb4063Sthorpej * <!-- XXX What else do we need? wrstuden? --> 4291edb4063Sthorpej * 4301edb4063Sthorpej * <!-- these are valid for RISCiX partition maps --> 4311edb4063Sthorpej * <key>riscix-partition-type</key> 4321edb4063Sthorpej * <integer>...</integer> 4331edb4063Sthorpej * 4341edb4063Sthorpej * <!-- these are valid for MIPS/SGI partition maps --> 4351edb4063Sthorpej * <key>mips-partition-type</key> 4361edb4063Sthorpej * <integer>...</integer> 4371edb4063Sthorpej * 4381edb4063Sthorpej * <!-- SunOS 4 partition maps have no specific 4391edb4063Sthorpej * additional information. Note, however, 4401edb4063Sthorpej * that SunOS 4 partitions must begin on 4411edb4063Sthorpej * cylinder boundaries. --> 4421edb4063Sthorpej * 4431edb4063Sthorpej * <!-- XXX Need Amiga partition map info --> 4441edb4063Sthorpej * 4451edb4063Sthorpej * <!-- these are valid for VTOC partition maps --> 4461edb4063Sthorpej * <key>vtoc-tag</key> 4471edb4063Sthorpej * <integer>...</integer> 4481edb4063Sthorpej * <key>vtoc-unmount</key> 4491edb4063Sthorpej * <false/> 4501edb4063Sthorpej * <key>vtoc-read-only</key> 4511edb4063Sthorpej * <false/> 4521edb4063Sthorpej * <!-- XXX is this really part of the partition info? --> 4531edb4063Sthorpej * <key>vtoc-timestamp</key> 4541edb4063Sthorpej * <integer>...</integer> 4551edb4063Sthorpej * 4561edb4063Sthorpej * <!-- mvme68k partition maps use 4.4BSD partition 4571edb4063Sthorpej * info stuffed into two different areas of the 4581edb4063Sthorpej * disk information label recognized by BUG. --> 4591edb4063Sthorpej * 4601edb4063Sthorpej * <!-- XXX What else? --> 4611edb4063Sthorpej * </dict> 4621edb4063Sthorpej */ 4631edb4063Sthorpej 4645b39541eSthorpej struct disk { 4655b39541eSthorpej TAILQ_ENTRY(disk) dk_link; /* link in global disklist */ 466cb8aa1ffSdyoung const char *dk_name; /* disk name */ 4671edb4063Sthorpej prop_dictionary_t dk_info; /* reference to disk-info dictionary */ 4686c0e3d9eSmartin struct disk_geom dk_geom; /* cooked version of dk_info */ 4697318599bSglass int dk_bopenmask; /* block devices open */ 4707318599bSglass int dk_copenmask; /* character devices open */ 4717318599bSglass int dk_openmask; /* composite (bopen|copen) */ 4727318599bSglass int dk_state; /* label state ### */ 4737318599bSglass int dk_blkshift; /* shift to convert DEV_BSIZE to blks */ 4747318599bSglass int dk_byteshift; /* shift to convert bytes to blks */ 4755b39541eSthorpej 4765b39541eSthorpej /* 4775b39541eSthorpej * Metrics data; note that some metrics may have no meaning 4785b39541eSthorpej * on certain types of disks. 4795b39541eSthorpej */ 4803c0adb7dSblymn struct io_stats *dk_stats; 4815b39541eSthorpej 48249cf9ad7Smatt const struct dkdriver *dk_driver; /* pointer to driver */ 4835b39541eSthorpej 4845b39541eSthorpej /* 485baefaf44Sthorpej * Information required to be the parent of a disk wedge. 486baefaf44Sthorpej */ 487b5a9ff06Sad kmutex_t dk_rawlock; /* lock on these fields */ 488baefaf44Sthorpej u_int dk_rawopens; /* # of openes of rawvp */ 489b5a9ff06Sad struct vnode *dk_rawvp; /* vnode for the RAW_PART bdev */ 490baefaf44Sthorpej 491b5a9ff06Sad kmutex_t dk_openlock; /* lock on these and openmask */ 492baefaf44Sthorpej u_int dk_nwedges; /* # of configured wedges */ 493baefaf44Sthorpej /* all wedges on this disk */ 494baefaf44Sthorpej LIST_HEAD(, dkwedge_softc) dk_wedges; 495baefaf44Sthorpej 496baefaf44Sthorpej /* 4975b39541eSthorpej * Disk label information. Storage for the in-core disk label 4985b39541eSthorpej * must be dynamically allocated, otherwise the size of this 4995b39541eSthorpej * structure becomes machine-dependent. 5005b39541eSthorpej */ 5017318599bSglass daddr_t dk_labelsector; /* sector containing label */ 5025b39541eSthorpej struct disklabel *dk_label; /* label */ 5035b39541eSthorpej struct cpu_disklabel *dk_cpulabel; 5047318599bSglass }; 5057318599bSglass 5067318599bSglass struct dkdriver { 5070e1b702cSperry void (*d_strategy)(struct buf *); 5080e1b702cSperry void (*d_minphys)(struct buf *); 5095f991650Smlelstv int (*d_open)(dev_t, int, int, struct lwp *); 5105f991650Smlelstv int (*d_close)(dev_t, int, int, struct lwp *); 51128e124faSmlelstv int (*d_diskstart)(device_t, struct buf *); 5125f991650Smlelstv void (*d_iosize)(device_t, int *); 5135f991650Smlelstv int (*d_dumpblocks)(device_t, void *, daddr_t, int); 5145f991650Smlelstv int (*d_lastclose)(device_t); 51528e124faSmlelstv int (*d_discard)(device_t, off_t, off_t); 5165773e158Smlelstv int (*d_firstopen)(device_t, dev_t, int, int); 517a80956dfSmlelstv void (*d_label)(device_t, struct disklabel *lp); 5187318599bSglass }; 5197318599bSglass 5207318599bSglass /* states */ 5217318599bSglass #define DK_CLOSED 0 /* drive is closed */ 5227318599bSglass #define DK_WANTOPEN 1 /* drive being opened */ 5237318599bSglass #define DK_WANTOPENRAW 2 /* drive being opened */ 5247318599bSglass #define DK_RDLABEL 3 /* label being read */ 5257318599bSglass #define DK_OPEN 4 /* label read, drive open */ 5267318599bSglass #define DK_OPENRAW 5 /* open without label */ 5277318599bSglass 528e07faf8aSscw #define DK_BSIZE2BLKSHIFT(b) ((ffs((b) / DEV_BSIZE)) - 1) 529e07faf8aSscw #define DK_BSIZE2BYTESHIFT(b) (ffs((b)) - 1) 530ce52e805Schristos #define DK_DEV_BSIZE_OK(b) \ 531ce52e805Schristos ((b) >= DEV_BSIZE && ((b) & ((b) - 1)) == 0 && (b) <= MAXPHYS) 532e07faf8aSscw 5335b39541eSthorpej extern int disk_count; /* number of disks in global disklist */ 5345b39541eSthorpej 535baefaf44Sthorpej struct proc; 536baefaf44Sthorpej 537c54265e6Shannken void disk_rename(struct disk *, const char *); 5380e1b702cSperry void disk_attach(struct disk *); 53985d8d1fcSdyoung int disk_begindetach(struct disk *, int (*)(device_t), device_t, int); 5400e1b702cSperry void disk_detach(struct disk *); 54149cf9ad7Smatt void disk_init(struct disk *, const char *, const struct dkdriver *); 5422af68666Sad void disk_destroy(struct disk *); 543ba576b71Smlelstv void disk_wait(struct disk *); 5440e1b702cSperry void disk_busy(struct disk *); 5450e1b702cSperry void disk_unbusy(struct disk *, long, int); 5464307e10dSad bool disk_isbusy(struct disk *); 547b9eb99f9Syamt struct disk *disk_find(const char *); 548bac2fca3Schristos int disk_ioctl(struct disk *, dev_t, u_long, void *, int, struct lwp *); 5495f9738c5Smartin void disk_set_info(device_t, struct disk *, const char *); 550baefaf44Sthorpej 551b5a9ff06Sad void dkwedge_init(void); 552baefaf44Sthorpej int dkwedge_add(struct dkwedge_info *); 553baefaf44Sthorpej int dkwedge_del(struct dkwedge_info *); 554baefaf44Sthorpej void dkwedge_delall(struct disk *); 555*76abd28dSriastradh void dkwedge_delidle(struct disk *); 55695e1ffb1Schristos int dkwedge_list(struct disk *, struct dkwedge_list *, struct lwp *); 557baefaf44Sthorpej void dkwedge_discover(struct disk *); 55827f01706Sthorpej int dkwedge_read(struct disk *, struct vnode *, daddr_t, void *, size_t); 5591ee8f4a4Sdyoung device_t dkwedge_find_by_wname(const char *); 560f2a7ea83Schristos device_t dkwedge_find_by_parent(const char *, size_t *); 561223a7bd5Schristos const char *dkwedge_get_parent_name(dev_t); 5621ee8f4a4Sdyoung void dkwedge_print_wnames(void); 5635741661fSmlelstv device_t dkwedge_find_partition(device_t, daddr_t, uint64_t); 564f2a7ea83Schristos 5653c0c10dbSchs #endif /* _KERNEL */ 566d39928a2Sperry 567d39928a2Sperry #endif /* _SYS_DISK_H_ */ 568