1112943Sphk/*- 2112943Sphk * Copyright (c) 2003 Poul-Henning Kamp 3112943Sphk * All rights reserved. 4112943Sphk * 5112943Sphk * This software was developed for the FreeBSD Project by Poul-Henning Kamp 6112943Sphk * and NAI Labs, the Security Research Division of Network Associates, Inc. 7112943Sphk * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the 8112943Sphk * DARPA CHATS research program. 9112943Sphk * 10112943Sphk * Redistribution and use in source and binary forms, with or without 11112943Sphk * modification, are permitted provided that the following conditions 12112943Sphk * are met: 13112943Sphk * 1. Redistributions of source code must retain the above copyright 14112943Sphk * notice, this list of conditions and the following disclaimer. 15112943Sphk * 2. Redistributions in binary form must reproduce the above copyright 16112943Sphk * notice, this list of conditions and the following disclaimer in the 17112943Sphk * documentation and/or other materials provided with the distribution. 18112943Sphk * 3. The names of the authors may not be used to endorse or promote 19112943Sphk * products derived from this software without specific prior written 20112943Sphk * permission. 21112943Sphk * 22112943Sphk * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 23112943Sphk * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24112943Sphk * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25112943Sphk * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 26112943Sphk * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27112943Sphk * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28112943Sphk * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29112943Sphk * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30112943Sphk * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31112943Sphk * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32112943Sphk * SUCH DAMAGE. 33112943Sphk * 34112943Sphk * $FreeBSD: stable/10/sys/geom/geom_disk.h 329319 2018-02-15 16:31:35Z avg $ 35112943Sphk */ 36112943Sphk 37112943Sphk#ifndef _GEOM_GEOM_DISK_H_ 38112943Sphk#define _GEOM_GEOM_DISK_H_ 39112943Sphk 40112943Sphk#ifdef _KERNEL 41112943Sphk 42112943Sphk#include <sys/queue.h> 43112988Sphk#include <sys/_lock.h> 44112988Sphk#include <sys/_mutex.h> 45169285Spjd#include <sys/disk.h> 46112943Sphk 47249507Sivoras#define G_DISK_CLASS_NAME "DISK" 48249507Sivoras 49143627Sphkstruct disk; 50143627Sphk 51112943Sphktypedef int disk_open_t(struct disk *); 52112943Sphktypedef int disk_close_t(struct disk *); 53112943Sphktypedef void disk_strategy_t(struct bio *bp); 54223089Sgibbstypedef int disk_getattr_t(struct bio *bp); 55237518Skentypedef void disk_gone_t(struct disk *); 56112943Sphktypedef int disk_ioctl_t(struct disk *, u_long cmd, void *data, 57112943Sphk int fflag, struct thread *td); 58112943Sphk /* NB: disk_ioctl_t SHALL be cast'able to d_ioctl_t */ 59112943Sphk 60112943Sphkstruct g_geom; 61112943Sphkstruct devstat; 62112943Sphk 63112943Sphkstruct disk { 64112943Sphk /* Fields which are private to geom_disk */ 65112943Sphk struct g_geom *d_geom; 66112943Sphk struct devstat *d_devstat; 67125975Sphk int d_destroyed; 68112943Sphk 69112943Sphk /* Shared fields */ 70112943Sphk u_int d_flags; 71112943Sphk const char *d_name; 72112943Sphk u_int d_unit; 73112988Sphk struct bio_queue_head *d_queue; 74112988Sphk struct mtx *d_lock; 75112943Sphk 76112943Sphk /* Disk methods */ 77112943Sphk disk_open_t *d_open; 78112943Sphk disk_close_t *d_close; 79112943Sphk disk_strategy_t *d_strategy; 80112943Sphk disk_ioctl_t *d_ioctl; 81112943Sphk dumper_t *d_dump; 82223089Sgibbs disk_getattr_t *d_getattr; 83237518Sken disk_gone_t *d_gone; 84112943Sphk 85112943Sphk /* Info fields from driver to geom_disk.c. Valid when open */ 86112943Sphk u_int d_sectorsize; 87112943Sphk off_t d_mediasize; 88112943Sphk u_int d_fwsectors; 89112943Sphk u_int d_fwheads; 90112943Sphk u_int d_maxsize; 91249940Ssmh off_t d_delmaxsize; 92112943Sphk u_int d_stripeoffset; 93112943Sphk u_int d_stripesize; 94169285Spjd char d_ident[DISK_IDENT_SIZE]; 95219056Snwhitehorn char d_descr[DISK_IDENT_SIZE]; 96210471Smav uint16_t d_hba_vendor; 97210471Smav uint16_t d_hba_device; 98210471Smav uint16_t d_hba_subvendor; 99210471Smav uint16_t d_hba_subdevice; 100112943Sphk 101112943Sphk /* Fields private to the driver */ 102112943Sphk void *d_drv1; 103271238Ssmh 104271238Ssmh /* New field - don't use if DISKFLAG_LACKS_ROTRATE is set */ 105271238Ssmh uint16_t d_rotation_rate; 106112943Sphk}; 107112943Sphk 108329319Savg#define DISKFLAG_NEEDSGIANT 0x0001 109329319Savg#define DISKFLAG_OPEN 0x0002 110329319Savg#define DISKFLAG_CANDELETE 0x0004 111329319Savg#define DISKFLAG_CANFLUSHCACHE 0x0008 112329319Savg#define DISKFLAG_UNMAPPED_BIO 0x0010 113329319Savg#define DISKFLAG_DIRECT_COMPLETION 0x0020 114329319Savg#define DISKFLAG_LACKS_ROTRATE 0x0040 115329319Savg#define DISKFLAG_WRITE_PROTECT 0x0100 116112943Sphk 117312406Smav#define DISK_RR_UNKNOWN 0 118312406Smav#define DISK_RR_NON_ROTATING 1 119312406Smav#define DISK_RR_MIN 0x0401 120312406Smav#define DISK_RR_MAX 0xfffe 121312406Smav 122125975Sphkstruct disk *disk_alloc(void); 123125975Sphkvoid disk_create(struct disk *disk, int version); 124112943Sphkvoid disk_destroy(struct disk *disk); 125152565Sjdpvoid disk_gone(struct disk *disk); 126223089Sgibbsvoid disk_attr_changed(struct disk *dp, const char *attr, int flag); 127238886Smavvoid disk_media_changed(struct disk *dp, int flag); 128238886Smavvoid disk_media_gone(struct disk *dp, int flag); 129242322Straszint disk_resize(struct disk *dp, int flag); 130112943Sphk 131125975Sphk#define DISK_VERSION_00 0x58561059 132169285Spjd#define DISK_VERSION_01 0x5856105a 133237518Sken#define DISK_VERSION_02 0x5856105b 134252657Ssmh#define DISK_VERSION_03 0x5856105c 135271238Ssmh#define DISK_VERSION_04 0x5856105d 136271238Ssmh#define DISK_VERSION DISK_VERSION_04 137112943Sphk 138112943Sphk#endif /* _KERNEL */ 139112943Sphk#endif /* _GEOM_GEOM_DISK_H_ */ 140