1f9f848faSopenharmony_ci/* 2f9f848faSopenharmony_ci * Copyright (C) 2022 Huawei Device Co., Ltd. 3f9f848faSopenharmony_ci * Redistribution and use in source and binary forms, with or without 4f9f848faSopenharmony_ci * modification, are permitted provided that the following conditions 5f9f848faSopenharmony_ci * are met: 6f9f848faSopenharmony_ci * 1. Redistributions of source code must retain the above copyright 7f9f848faSopenharmony_ci * notice, this list of conditions and the following disclaimer. 8f9f848faSopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright 9f9f848faSopenharmony_ci * notice, this list of conditions and the following disclaimer in 10f9f848faSopenharmony_ci * the documentation and/or other materials provided with the 11f9f848faSopenharmony_ci * distribution. 12f9f848faSopenharmony_ci * 13f9f848faSopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS 14f9f848faSopenharmony_ci * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15f9f848faSopenharmony_ci * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16f9f848faSopenharmony_ci * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY 17f9f848faSopenharmony_ci * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18f9f848faSopenharmony_ci * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 19f9f848faSopenharmony_ci * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20f9f848faSopenharmony_ci * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 21f9f848faSopenharmony_ci * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 22f9f848faSopenharmony_ci * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 23f9f848faSopenharmony_ci * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24f9f848faSopenharmony_ci */ 25f9f848faSopenharmony_ci 26f9f848faSopenharmony_ci#ifndef MKFS_DEFINE_H 27f9f848faSopenharmony_ci#define MKFS_DEFINE_H 28f9f848faSopenharmony_ci#include <stdint.h> 29f9f848faSopenharmony_ci 30f9f848faSopenharmony_ci/* 31f9f848faSopenharmony_ci * BSD_NPARTS_MIN,BSD_NDRIVEDATA,BSD_NSPARE 32f9f848faSopenharmony_ci * Link: https://github.com/freebsd/freebsd-src/ 33f9f848faSopenharmony_ci * Path: freebsd-src/sys/sys/disk/bsd.h 34f9f848faSopenharmony_ci */ 35f9f848faSopenharmony_ci#define BSD_NPARTS_MIN 8 36f9f848faSopenharmony_ci 37f9f848faSopenharmony_ci/* Drive-type specific data size (in number of 32-bit inegrals) */ 38f9f848faSopenharmony_ci#define BSD_NDRIVEDATA 5 39f9f848faSopenharmony_ci 40f9f848faSopenharmony_ci/* Number of spare 32-bit integrals following drive-type data */ 41f9f848faSopenharmony_ci#define BSD_NSPARE 5 42f9f848faSopenharmony_ci 43f9f848faSopenharmony_ci/* 44f9f848faSopenharmony_ci * MAXPHYS 45f9f848faSopenharmony_ci * Link: https://github.com/freebsd/freebsd-src/ 46f9f848faSopenharmony_ci * Path: freebsd-src/sys/sys/param.h 47f9f848faSopenharmony_ci */ 48f9f848faSopenharmony_ci#ifdef __ILP32__ 49f9f848faSopenharmony_ci#define MAXPHYS (128 * 1024) 50f9f848faSopenharmony_ci#else 51f9f848faSopenharmony_ci#define MAXPHYS (1024 * 1024) 52f9f848faSopenharmony_ci#endif 53f9f848faSopenharmony_ci 54f9f848faSopenharmony_ci/* 55f9f848faSopenharmony_ci * DIOCGMEDIASIZE,DIOCGFWSECTORS,DIOCGSECTORSIZE,DIOCGFWHEADS 56f9f848faSopenharmony_ci * Link: https://github.com/freebsd/freebsd-src/ 57f9f848faSopenharmony_ci * Path: freebsd-src/sys/sys/disk.h 58f9f848faSopenharmony_ci */ 59f9f848faSopenharmony_ci#define DIOCGMEDIASIZE _IOR('d', 129, off_t) /* Get media size in bytes */ 60f9f848faSopenharmony_ci /* 61f9f848faSopenharmony_ci * Get the size of the entire device in bytes. This should be a 62f9f848faSopenharmony_ci * multiple of the sector size. 63f9f848faSopenharmony_ci */ 64f9f848faSopenharmony_ci 65f9f848faSopenharmony_ci#define DIOCGFWSECTORS _IOR('d', 130, u_int) /* Get firmware's sectorcount */ 66f9f848faSopenharmony_ci /* 67f9f848faSopenharmony_ci * Get the firmware's notion of number of sectors per track. This 68f9f848faSopenharmony_ci * value is mostly used for compatibility with various ill designed 69f9f848faSopenharmony_ci * disk label formats. Don't use it unless you have to. 70f9f848faSopenharmony_ci */ 71f9f848faSopenharmony_ci 72f9f848faSopenharmony_ci#define DIOCGSECTORSIZE _IOR('d', 128, u_int) 73f9f848faSopenharmony_ci /* 74f9f848faSopenharmony_ci * Get the sector size of the device in bytes. The sector size is the 75f9f848faSopenharmony_ci * smallest unit of data which can be transferred from this device. 76f9f848faSopenharmony_ci * Usually this is a power of 2 but it might not be (i.e. CDROM audio). 77f9f848faSopenharmony_ci */ 78f9f848faSopenharmony_ci 79f9f848faSopenharmony_ci#define DIOCGFWHEADS _IOR('d', 131, u_int) /* Get firmware's headcount */ 80f9f848faSopenharmony_ci /* 81f9f848faSopenharmony_ci * Get the firmwares notion of number of heads per cylinder. This 82f9f848faSopenharmony_ci * value is mostly used for compatibility with various ill designed 83f9f848faSopenharmony_ci * disk label formats. Don't use it unless you have to. 84f9f848faSopenharmony_ci */ 85f9f848faSopenharmony_ci 86f9f848faSopenharmony_ci/* 87f9f848faSopenharmony_ci * FD_GTYPE 88f9f848faSopenharmony_ci * Link: https://github.com/freebsd/freebsd-src/ 89f9f848faSopenharmony_ci * Path: freebsd-src/sys/sys/fdcio.h 90f9f848faSopenharmony_ci */ 91f9f848faSopenharmony_ci#ifndef _MACHINE_IOCTL_FD_H_ 92f9f848faSopenharmony_ci#define FD_GTYPE _IOR('F', 62, struct fd_type) /* get drive type */ 93f9f848faSopenharmony_ci#endif 94f9f848faSopenharmony_ci 95f9f848faSopenharmony_ci/* 96f9f848faSopenharmony_ci * disklabel 97f9f848faSopenharmony_ci * Link: https://github.com/freebsd/freebsd-src/ 98f9f848faSopenharmony_ci * Path: freebsd-src/sys/sys/disk/bsd.h 99f9f848faSopenharmony_ci */ 100f9f848faSopenharmony_cistruct disklabel { 101f9f848faSopenharmony_ci uint32_t d_magic; /* the magic number */ 102f9f848faSopenharmony_ci uint16_t d_type; /* drive type */ 103f9f848faSopenharmony_ci uint16_t d_subtype; /* controller/d_type specific */ 104f9f848faSopenharmony_ci char d_typename[16]; /* type name, e.g. "eagle" */ 105f9f848faSopenharmony_ci 106f9f848faSopenharmony_ci char d_packname[16]; /* pack identifier */ 107f9f848faSopenharmony_ci 108f9f848faSopenharmony_ci /* disk geometry: */ 109f9f848faSopenharmony_ci uint32_t d_secsize; /* # of bytes per sector */ 110f9f848faSopenharmony_ci uint32_t d_nsectors; /* # of data sectors per track */ 111f9f848faSopenharmony_ci uint32_t d_ntracks; /* # of tracks per cylinder */ 112f9f848faSopenharmony_ci uint32_t d_ncylinders; /* # of data cylinders per unit */ 113f9f848faSopenharmony_ci uint32_t d_secpercyl; /* # of data sectors per cylinder */ 114f9f848faSopenharmony_ci uint32_t d_secperunit; /* # of data sectors per unit */ 115f9f848faSopenharmony_ci 116f9f848faSopenharmony_ci /* 117f9f848faSopenharmony_ci * Spares (bad sector replacements) below are not counted in 118f9f848faSopenharmony_ci * d_nsectors or d_secpercyl. Spare sectors are assumed to 119f9f848faSopenharmony_ci * be physical sectors which occupy space at the end of each 120f9f848faSopenharmony_ci * track and/or cylinder. 121f9f848faSopenharmony_ci */ 122f9f848faSopenharmony_ci uint16_t d_sparespertrack; /* # of spare sectors per track */ 123f9f848faSopenharmony_ci uint16_t d_sparespercyl; /* # of spare sectors per cylinder */ 124f9f848faSopenharmony_ci /* 125f9f848faSopenharmony_ci * Alternate cylinders include maintenance, replacement, configuration 126f9f848faSopenharmony_ci * description areas, etc. 127f9f848faSopenharmony_ci */ 128f9f848faSopenharmony_ci uint32_t d_acylinders; /* # of alt. cylinders per unit */ 129f9f848faSopenharmony_ci 130f9f848faSopenharmony_ci /* hardware characteristics: */ 131f9f848faSopenharmony_ci /* 132f9f848faSopenharmony_ci * d_interleave, d_trackskew and d_cylskew describe perturbations 133f9f848faSopenharmony_ci * in the media format used to compensate for a slow controller. 134f9f848faSopenharmony_ci * Interleave is physical sector interleave, set up by the 135f9f848faSopenharmony_ci * formatter or controller when formatting. When interleaving is 136f9f848faSopenharmony_ci * in use, logically adjacent sectors are not physically 137f9f848faSopenharmony_ci * contiguous, but instead are separated by some number of 138f9f848faSopenharmony_ci * sectors. It is specified as the ratio of physical sectors 139f9f848faSopenharmony_ci * traversed per logical sector. Thus an interleave of 1:1 140f9f848faSopenharmony_ci * implies contiguous layout, while 2:1 implies that logical 141f9f848faSopenharmony_ci * sector 0 is separated by one sector from logical sector 1. 142f9f848faSopenharmony_ci * d_trackskew is the offset of sector 0 on track N relative to 143f9f848faSopenharmony_ci * sector 0 on track N-1 on the same cylinder. Finally, d_cylskew 144f9f848faSopenharmony_ci * is the offset of sector 0 on cylinder N relative to sector 0 145f9f848faSopenharmony_ci * on cylinder N-1. 146f9f848faSopenharmony_ci */ 147f9f848faSopenharmony_ci uint16_t d_rpm; /* rotational speed */ 148f9f848faSopenharmony_ci uint16_t d_interleave; /* hardware sector interleave */ 149f9f848faSopenharmony_ci uint16_t d_trackskew; /* sector 0 skew, per track */ 150f9f848faSopenharmony_ci uint16_t d_cylskew; /* sector 0 skew, per cylinder */ 151f9f848faSopenharmony_ci uint32_t d_headswitch; /* head switch time, usec */ 152f9f848faSopenharmony_ci uint32_t d_trkseek; /* track-to-track seek, usec */ 153f9f848faSopenharmony_ci uint32_t d_flags; /* generic flags */ 154f9f848faSopenharmony_ci uint32_t d_drivedata[BSD_NDRIVEDATA]; /* drive-type specific data */ 155f9f848faSopenharmony_ci uint32_t d_spare[BSD_NSPARE]; /* reserved for future use */ 156f9f848faSopenharmony_ci uint32_t d_magic2; /* the magic number (again) */ 157f9f848faSopenharmony_ci uint16_t d_checksum; /* xor of data incl. partitions */ 158f9f848faSopenharmony_ci 159f9f848faSopenharmony_ci /* filesystem and partition information: */ 160f9f848faSopenharmony_ci uint16_t d_npartitions; /* number of partitions in following */ 161f9f848faSopenharmony_ci uint32_t d_bbsize; /* size of boot area at sn0, bytes */ 162f9f848faSopenharmony_ci uint32_t d_sbsize; /* max size of fs superblock, bytes */ 163f9f848faSopenharmony_ci struct partition { /* the partition table */ 164f9f848faSopenharmony_ci uint32_t p_size; /* number of sectors in partition */ 165f9f848faSopenharmony_ci uint32_t p_offset; /* starting sector */ 166f9f848faSopenharmony_ci uint32_t p_fsize; /* filesystem basic fragment size */ 167f9f848faSopenharmony_ci uint8_t p_fstype; /* filesystem type, see below */ 168f9f848faSopenharmony_ci uint8_t p_frag; /* filesystem fragments per block */ 169f9f848faSopenharmony_ci uint16_t p_cpg; /* filesystem cylinders per group */ 170f9f848faSopenharmony_ci } d_partitions[BSD_NPARTS_MIN]; /* actually may be more */ 171f9f848faSopenharmony_ci}; 172f9f848faSopenharmony_ci 173f9f848faSopenharmony_ci/* 174f9f848faSopenharmony_ci * fd_type 175f9f848faSopenharmony_ci * Link: https://github.com/freebsd/freebsd-src/ 176f9f848faSopenharmony_ci * Path: freebsd-src/sys/sys/fdcio.h 177f9f848faSopenharmony_ci */ 178f9f848faSopenharmony_cistruct fd_type { 179f9f848faSopenharmony_ci int sectrac; /* sectors per track */ 180f9f848faSopenharmony_ci int secsize; /* size code for sectors */ 181f9f848faSopenharmony_ci int datalen; /* data len when secsize = 0 */ 182f9f848faSopenharmony_ci int gap; /* gap len between sectors */ 183f9f848faSopenharmony_ci int tracks; /* total number of cylinders */ 184f9f848faSopenharmony_ci int size; /* size of disk in sectors */ 185f9f848faSopenharmony_ci int trans; /* transfer speed code */ 186f9f848faSopenharmony_ci int heads; /* number of heads */ 187f9f848faSopenharmony_ci int f_gap; /* format gap len */ 188f9f848faSopenharmony_ci int f_inter; /* format interleave factor */ 189f9f848faSopenharmony_ci int offset_side2; /* offset of sectors on side2 */ 190f9f848faSopenharmony_ci int flags; /* misc. features */ 191f9f848faSopenharmony_ci#define FL_MFM 0x0001 /* MFM recording */ 192f9f848faSopenharmony_ci#define FL_2STEP 0x0002 /* 2 steps between cylinders */ 193f9f848faSopenharmony_ci#define FL_PERPND 0x0004 /* perpendicular recording */ 194f9f848faSopenharmony_ci#define FL_AUTO 0x0008 /* autodetect format */ 195f9f848faSopenharmony_ci}; 196f9f848faSopenharmony_ci#endif //MKFS_DEFINE_H