The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/dkvar.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* $NetBSD: dkvar.h,v 1.13 2008/04/28 20:23:46 martin Exp $ */
    2 
    3 /*-
    4  * Copyright (c) 2002 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Roland C. Dowdeswell.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   29  * POSSIBILITY OF SUCH DAMAGE.
   30  */
   31 
   32 struct dk_geom {
   33         u_int32_t       pdg_secsize;
   34         u_int32_t       pdg_nsectors;
   35         u_int32_t       pdg_ntracks;
   36         u_int32_t       pdg_ncylinders;
   37 };
   38 
   39 /* literally this is not a softc, but is intended to be included in
   40  * the pseudo-disk's softc and passed to calls in dksubr.c.  It
   41  * should include the common elements of the pseudo-disk's softc.
   42  * All elements that are included here should describe the external
   43  * representation of the disk to the higher layers, and flags that
   44  * are common to each of the pseudo-disk drivers.
   45  */
   46 struct dk_softc {
   47         void                    *sc_osc;        /* the softc of the underlying
   48                                                  * driver */
   49         u_int32_t                sc_flags;      /* flags */
   50         size_t                   sc_size;       /* size of disk */
   51         struct dk_geom           sc_geom;       /* geometry info */
   52 #define DK_XNAME_SIZE 8
   53         char                     sc_xname[DK_XNAME_SIZE]; /* external name */
   54         struct disk              sc_dkdev;      /* generic disk info */
   55         struct bufq_state       *sc_bufq;       /* buffer queue */
   56 };
   57 
   58 /* sc_flags:
   59  *   We separate the flags into two varieties, those that dksubr.c
   60  *   understands and manipulates and those that it does not.
   61  */
   62 
   63 #define DKF_INITED      0x00010000 /* unit has been initialised */
   64 #define DKF_WLABEL      0x00020000 /* label area is writable */
   65 #define DKF_LABELLING   0x00040000 /* unit is currently being labeled */
   66 #define DKF_WARNLABEL   0x00080000 /* warn if disklabel not present */
   67 #define DKF_LABELSANITY 0x00100000 /* warn if disklabel not sane */
   68 #define DKF_TAKEDUMP    0x00200000 /* allow dumping */
   69 
   70 /* Mask of flags that dksubr.c understands, other flags are fair game */
   71 #define DK_FLAGMASK     0xffff0000
   72 
   73 /*
   74  * This defines the interface to the routines in dksubr.c.  This
   75  * should be a single static structure per pseudo-disk driver.
   76  * We only define the functions that we currently need.
   77  */
   78 struct dk_intf {
   79         int       di_dtype;                     /* disk type */
   80         const char *di_dkname;                  /* disk type name */
   81         int     (*di_open)(dev_t, int, int, struct lwp *);
   82         int     (*di_close)(dev_t, int, int, struct lwp *);
   83         void    (*di_strategy)(struct buf *);
   84         int     (*di_diskstart)(struct dk_softc *, struct buf *);
   85 };
   86 
   87 #define DK_BUSY(_dksc, _pmask)                          \
   88         ((_dksc)->sc_dkdev.dk_openmask & ~(_pmask)) ||  \
   89         ((_dksc)->sc_dkdev.dk_bopenmask & (_pmask)  &&  \
   90         ((_dksc)->sc_dkdev.dk_copenmask & (_pmask)))
   91 
   92 /*
   93  * Functions that are exported to the pseudo disk implementations:
   94  */
   95 
   96 void    dk_sc_init(struct dk_softc *, void *, const char *);
   97 
   98 int     dk_open(struct dk_intf *, struct dk_softc *, dev_t,
   99                 int, int, struct lwp *);
  100 int     dk_close(struct dk_intf *, struct dk_softc *, dev_t,
  101                  int, int, struct lwp *);
  102 void    dk_strategy(struct dk_intf *, struct dk_softc *, struct buf *);
  103 void    dk_start(struct dk_intf *, struct dk_softc *);
  104 void    dk_iodone(struct dk_intf *, struct dk_softc *);
  105 int     dk_size(struct dk_intf *, struct dk_softc *, dev_t);
  106 int     dk_ioctl(struct dk_intf *, struct dk_softc *, dev_t,
  107                  u_long, void *, int, struct lwp *);
  108 int     dk_dump(struct dk_intf *, struct dk_softc *, dev_t,
  109                 daddr_t, void *, size_t);
  110 void    dk_getdisklabel(struct dk_intf *, struct dk_softc *, dev_t);
  111 void    dk_getdefaultlabel(struct dk_intf *, struct dk_softc *,
  112                            struct disklabel *);
  113 
  114 int     dk_lookup(const char *, struct lwp *, struct vnode **, enum uio_seg);

Cache object: 56a774442b07a13a5e5c70151d51a555


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.