1#ifndef _LINUX_GENHD_H 2#define _LINUX_GENHD_H 3 4/* 5 * genhd.h Copyright (C) 1992 Drew Eckhardt 6 * Generic hard disk header file by 7 * Drew Eckhardt 8 * 9 * <drew@colorado.edu> 10 */ 11 12#include <linux/config.h> 13#include <linux/types.h> 14#include <linux/major.h> 15 16enum { 17/* These three have identical behaviour; use the second one if DOS fdisk gets 18 confused about extended/logical partitions starting past cylinder 1023. */ 19 DOS_EXTENDED_PARTITION = 5, 20 LINUX_EXTENDED_PARTITION = 0x85, 21 WIN98_EXTENDED_PARTITION = 0x0f, 22 23 LINUX_SWAP_PARTITION = 0x82, 24 LINUX_RAID_PARTITION = 0xfd, /* autodetect RAID partition */ 25 26 SOLARIS_X86_PARTITION = LINUX_SWAP_PARTITION, 27 28 DM6_PARTITION = 0x54, /* has DDO: use xlated geom & offset */ 29 EZD_PARTITION = 0x55, /* EZ-DRIVE */ 30 DM6_AUX1PARTITION = 0x51, /* no DDO: use xlated geom */ 31 DM6_AUX3PARTITION = 0x53, /* no DDO: use xlated geom */ 32 33 FREEBSD_PARTITION = 0xa5, /* FreeBSD Partition ID */ 34 OPENBSD_PARTITION = 0xa6, /* OpenBSD Partition ID */ 35 NETBSD_PARTITION = 0xa9, /* NetBSD Partition ID */ 36 BSDI_PARTITION = 0xb7, /* BSDI Partition ID */ 37/* Ours is not to wonder why.. */ 38 BSD_PARTITION = FREEBSD_PARTITION, 39 MINIX_PARTITION = 0x81, /* Minix Partition ID */ 40 PLAN9_PARTITION = 0x39, /* Plan 9 Partition ID */ 41 UNIXWARE_PARTITION = 0x63, /* Partition ID, same as */ 42 /* GNU_HURD and SCO Unix */ 43}; 44 45struct partition { 46 unsigned char boot_ind; /* 0x80 - active */ 47 unsigned char head; /* starting head */ 48 unsigned char sector; /* starting sector */ 49 unsigned char cyl; /* starting cylinder */ 50 unsigned char sys_ind; /* What partition type */ 51 unsigned char end_head; /* end head */ 52 unsigned char end_sector; /* end sector */ 53 unsigned char end_cyl; /* end cylinder */ 54 unsigned int start_sect; /* starting sector counting from 0 */ 55 unsigned int nr_sects; /* nr of sectors in partition */ 56} __attribute__((packed)); 57 58#ifdef __KERNEL__ 59# include <linux/devfs_fs_kernel.h> 60 61struct hd_struct { 62 unsigned long start_sect; 63 unsigned long nr_sects; 64 devfs_handle_t de; /* primary (master) devfs entry */ 65#ifdef CONFIG_DEVFS_FS 66 int number; 67#endif /* CONFIG_DEVFS_FS */ 68#ifdef CONFIG_BLK_STATS 69 /* Performance stats: */ 70 unsigned int ios_in_flight; 71 unsigned int io_ticks; 72 unsigned int last_idle_time; 73 unsigned int last_queue_change; 74 unsigned int aveq; 75 76 unsigned int rd_ios; 77 unsigned int rd_merges; 78 unsigned int rd_ticks; 79 unsigned int rd_sectors; 80 unsigned int wr_ios; 81 unsigned int wr_merges; 82 unsigned int wr_ticks; 83 unsigned int wr_sectors; 84#endif /* CONFIG_BLK_STATS */ 85}; 86 87#define GENHD_FL_REMOVABLE 1 88 89struct gendisk { 90 int major; /* major number of driver */ 91 const char *major_name; /* name of major driver */ 92 int minor_shift; /* number of times minor is shifted to 93 get real minor */ 94 int max_p; /* maximum partitions per device */ 95 96 struct hd_struct *part; /* [indexed by minor] */ 97 int *sizes; /* [idem], device size in blocks */ 98 int nr_real; /* number of real devices */ 99 100 void *real_devices; /* internal use */ 101 struct gendisk *next; 102 struct block_device_operations *fops; 103 104 devfs_handle_t *de_arr; /* one per physical disc */ 105 char *flags; /* one per physical disc */ 106}; 107 108/* drivers/block/genhd.c */ 109extern struct gendisk *gendisk_head; 110 111extern void add_gendisk(struct gendisk *gp); 112extern void del_gendisk(struct gendisk *gp); 113extern struct gendisk *get_gendisk(kdev_t dev); 114extern int walk_gendisk(int (*walk)(struct gendisk *, void *), void *); 115 116#endif /* __KERNEL__ */ 117 118#ifdef CONFIG_SOLARIS_X86_PARTITION 119 120#define SOLARIS_X86_NUMSLICE 8 121#define SOLARIS_X86_VTOC_SANE (0x600DDEEEUL) 122 123struct solaris_x86_slice { 124 ushort s_tag; /* ID tag of partition */ 125 ushort s_flag; /* permission flags */ 126 unsigned int s_start; /* start sector no of partition */ 127 unsigned int s_size; /* # of blocks in partition */ 128}; 129 130struct solaris_x86_vtoc { 131 unsigned int v_bootinfo[3]; /* info needed by mboot (unsupported) */ 132 unsigned int v_sanity; /* to verify vtoc sanity */ 133 unsigned int v_version; /* layout version */ 134 char v_volume[8]; /* volume name */ 135 ushort v_sectorsz; /* sector size in bytes */ 136 ushort v_nparts; /* number of partitions */ 137 unsigned int v_reserved[10]; /* free space */ 138 struct solaris_x86_slice 139 v_slice[SOLARIS_X86_NUMSLICE]; /* slice headers */ 140 unsigned int timestamp[SOLARIS_X86_NUMSLICE]; /* timestamp (unsupported) */ 141 char v_asciilabel[128]; /* for compatibility */ 142}; 143 144#endif /* CONFIG_SOLARIS_X86_PARTITION */ 145 146#ifdef CONFIG_BSD_DISKLABEL 147/* 148 * BSD disklabel support by Yossi Gottlieb <yogo@math.tau.ac.il> 149 * updated by Marc Espie <Marc.Espie@openbsd.org> 150 */ 151 152/* check against BSD src/sys/sys/disklabel.h for consistency */ 153 154#define BSD_DISKMAGIC (0x82564557UL) /* The disk magic number */ 155#define BSD_MAXPARTITIONS 8 156#define OPENBSD_MAXPARTITIONS 16 157#define BSD_FS_UNUSED 0 /* disklabel unused partition entry ID */ 158struct bsd_disklabel { 159 __u32 d_magic; /* the magic number */ 160 __s16 d_type; /* drive type */ 161 __s16 d_subtype; /* controller/d_type specific */ 162 char d_typename[16]; /* type name, e.g. "eagle" */ 163 char d_packname[16]; /* pack identifier */ 164 __u32 d_secsize; /* # of bytes per sector */ 165 __u32 d_nsectors; /* # of data sectors per track */ 166 __u32 d_ntracks; /* # of tracks per cylinder */ 167 __u32 d_ncylinders; /* # of data cylinders per unit */ 168 __u32 d_secpercyl; /* # of data sectors per cylinder */ 169 __u32 d_secperunit; /* # of data sectors per unit */ 170 __u16 d_sparespertrack; /* # of spare sectors per track */ 171 __u16 d_sparespercyl; /* # of spare sectors per cylinder */ 172 __u32 d_acylinders; /* # of alt. cylinders per unit */ 173 __u16 d_rpm; /* rotational speed */ 174 __u16 d_interleave; /* hardware sector interleave */ 175 __u16 d_trackskew; /* sector 0 skew, per track */ 176 __u16 d_cylskew; /* sector 0 skew, per cylinder */ 177 __u32 d_headswitch; /* head switch time, usec */ 178 __u32 d_trkseek; /* track-to-track seek, usec */ 179 __u32 d_flags; /* generic flags */ 180#define NDDATA 5 181 __u32 d_drivedata[NDDATA]; /* drive-type specific information */ 182#define NSPARE 5 183 __u32 d_spare[NSPARE]; /* reserved for future use */ 184 __u32 d_magic2; /* the magic number (again) */ 185 __u16 d_checksum; /* xor of data incl. partitions */ 186 187 /* filesystem and partition information: */ 188 __u16 d_npartitions; /* number of partitions in following */ 189 __u32 d_bbsize; /* size of boot area at sn0, bytes */ 190 __u32 d_sbsize; /* max size of fs superblock, bytes */ 191 struct bsd_partition { /* the partition table */ 192 __u32 p_size; /* number of sectors in partition */ 193 __u32 p_offset; /* starting sector */ 194 __u32 p_fsize; /* filesystem basic fragment size */ 195 __u8 p_fstype; /* filesystem type, see below */ 196 __u8 p_frag; /* filesystem fragments per block */ 197 __u16 p_cpg; /* filesystem cylinders per group */ 198 } d_partitions[BSD_MAXPARTITIONS]; /* actually may be more */ 199}; 200 201#endif /* CONFIG_BSD_DISKLABEL */ 202 203#ifdef CONFIG_UNIXWARE_DISKLABEL 204/* 205 * Unixware slices support by Andrzej Krzysztofowicz <ankry@mif.pg.gda.pl> 206 * and Krzysztof G. Baranowski <kgb@knm.org.pl> 207 */ 208 209#define UNIXWARE_DISKMAGIC (0xCA5E600DUL) /* The disk magic number */ 210#define UNIXWARE_DISKMAGIC2 (0x600DDEEEUL) /* The slice table magic nr */ 211#define UNIXWARE_NUMSLICE 16 212#define UNIXWARE_FS_UNUSED 0 /* Unused slice entry ID */ 213 214struct unixware_slice { 215 __u16 s_label; /* label */ 216 __u16 s_flags; /* permission flags */ 217 __u32 start_sect; /* starting sector */ 218 __u32 nr_sects; /* number of sectors in slice */ 219}; 220 221struct unixware_disklabel { 222 __u32 d_type; /* drive type */ 223 __u32 d_magic; /* the magic number */ 224 __u32 d_version; /* version number */ 225 char d_serial[12]; /* serial number of the device */ 226 __u32 d_ncylinders; /* # of data cylinders per device */ 227 __u32 d_ntracks; /* # of tracks per cylinder */ 228 __u32 d_nsectors; /* # of data sectors per track */ 229 __u32 d_secsize; /* # of bytes per sector */ 230 __u32 d_part_start; /* # of first sector of this partition */ 231 __u32 d_unknown1[12]; /* ? */ 232 __u32 d_alt_tbl; /* byte offset of alternate table */ 233 __u32 d_alt_len; /* byte length of alternate table */ 234 __u32 d_phys_cyl; /* # of physical cylinders per device */ 235 __u32 d_phys_trk; /* # of physical tracks per cylinder */ 236 __u32 d_phys_sec; /* # of physical sectors per track */ 237 __u32 d_phys_bytes; /* # of physical bytes per sector */ 238 __u32 d_unknown2; /* ? */ 239 __u32 d_unknown3; /* ? */ 240 __u32 d_pad[8]; /* pad */ 241 242 struct unixware_vtoc { 243 __u32 v_magic; /* the magic number */ 244 __u32 v_version; /* version number */ 245 char v_name[8]; /* volume name */ 246 __u16 v_nslices; /* # of slices */ 247 __u16 v_unknown1; /* ? */ 248 __u32 v_reserved[10]; /* reserved */ 249 struct unixware_slice 250 v_slice[UNIXWARE_NUMSLICE]; /* slice headers */ 251 } vtoc; 252 253}; /* 408 */ 254 255#endif /* CONFIG_UNIXWARE_DISKLABEL */ 256 257#ifdef CONFIG_MINIX_SUBPARTITION 258# define MINIX_NR_SUBPARTITIONS 4 259#endif /* CONFIG_MINIX_SUBPARTITION */ 260 261#ifdef __KERNEL__ 262 263char *disk_name (struct gendisk *hd, int minor, char *buf); 264 265/* 266 * Account for the completion of an IO request (used by drivers which 267 * bypass the normal end_request processing) 268 */ 269struct request; 270 271#ifdef CONFIG_BLK_STATS 272extern void disk_round_stats(struct hd_struct *hd); 273extern void req_new_io(struct request *req, int merge, int sectors); 274extern void req_merged_io(struct request *req); 275extern void req_finished_io(struct request *req); 276#else 277static inline void req_new_io(struct request *req, int merge, int sectors) { } 278static inline void req_merged_io(struct request *req) { } 279static inline void req_finished_io(struct request *req) { } 280#endif /* CONFIG_BLK_STATS */ 281 282extern void devfs_register_partitions (struct gendisk *dev, int minor, 283 int unregister); 284 285 286 287static inline unsigned int disk_index (kdev_t dev) 288{ 289 int major = MAJOR(dev); 290 int minor = MINOR(dev); 291 unsigned int index; 292 293 switch (major) { 294 case DAC960_MAJOR+0: 295 index = (minor & 0x00f8) >> 3; 296 break; 297 case SCSI_DISK0_MAJOR: 298 index = (minor & 0x00f0) >> 4; 299 break; 300 case IDE0_MAJOR: /* same as HD_MAJOR */ 301 case XT_DISK_MAJOR: 302 index = (minor & 0x0040) >> 6; 303 break; 304 case IDE1_MAJOR: 305 index = ((minor & 0x0040) >> 6) + 2; 306 break; 307 default: 308 return 0; 309 } 310 return index; 311} 312 313#endif 314 315#endif 316