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/sys/extent.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 /*      $OpenBSD: extent.h,v 1.14 2014/02/08 20:29:01 kettenis Exp $    */
    2 /*      $NetBSD: extent.h,v 1.6 1997/10/09 07:43:05 jtc Exp $   */
    3 
    4 /*-
    5  * Copyright (c) 1996 The NetBSD Foundation, Inc.
    6  * All rights reserved.
    7  *
    8  * This code is derived from software contributed to The NetBSD Foundation
    9  * by Jason R. Thorpe.
   10  *
   11  * Redistribution and use in source and binary forms, with or without
   12  * modification, are permitted provided that the following conditions
   13  * are met:
   14  * 1. Redistributions of source code must retain the above copyright
   15  *    notice, this list of conditions and the following disclaimer.
   16  * 2. Redistributions in binary form must reproduce the above copyright
   17  *    notice, this list of conditions and the following disclaimer in the
   18  *    documentation and/or other materials provided with the distribution.
   19  *
   20  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   23  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   24  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   30  * POSSIBILITY OF SUCH DAMAGE.
   31  */
   32 
   33 #ifndef _SYS_EXTENT_H_
   34 #define _SYS_EXTENT_H_
   35 
   36 #include <sys/queue.h>
   37 
   38 struct extent_region {
   39         LIST_ENTRY(extent_region) er_link;      /* link in region list */
   40         u_long  er_start;               /* start of region */
   41         u_long  er_end;                 /* end of region */
   42         int     er_flags;               /* misc. flags */
   43 };
   44 
   45 /* er_flags */
   46 #define ER_ALLOC        0x01    /* region descriptor dynamically allocated */
   47 #define ER_DISCARD      0x02    /* discard region descriptor after use */
   48 
   49 struct extent {
   50         char    *ex_name;               /* name of extent */
   51                                         /* allocated regions in extent */
   52         LIST_HEAD(, extent_region) ex_regions;
   53         u_long  ex_start;               /* start of extent */
   54         u_long  ex_end;                 /* end of extent */
   55         int     ex_mtype;               /* memory type */
   56         int     ex_flags;               /* misc. information */
   57 
   58         LIST_ENTRY(extent) ex_link;
   59 };
   60 
   61 struct extent_fixed {
   62         struct extent   fex_extent;     /* MUST BE FIRST */
   63                                         /* freelist of region descriptors */
   64         LIST_HEAD(, extent_region) fex_freelist;
   65         caddr_t         fex_storage;    /* storage space for descriptors */
   66         size_t          fex_storagesize; /* size of storage space */
   67 };
   68 
   69 /* ex_flags; for internal use only */
   70 #define EXF_FIXED       0x01            /* extent uses fixed storage */
   71 #define EXF_NOCOALESCE  0x02            /* coalescing of regions not allowed */
   72 #define EXF_WANTED      0x04            /* someone asleep on extent */
   73 #define EXF_FLWANTED    0x08            /* someone asleep on freelist */
   74 
   75 #define EXF_BITS        "\2\4FLWANTED\3WANTED\2NOCOALESCE\1FIXED"
   76 
   77 /* misc. flags passed to extent functions */
   78 #define EX_NOWAIT       0x0000          /* not safe to sleep */
   79 #define EX_WAITOK       0x0001          /* safe to sleep */
   80 #define EX_FAST         0x0002          /* take first fit in extent_alloc() */
   81 #define EX_CATCH        0x0004          /* catch signals while sleeping */
   82 #define EX_NOCOALESCE   0x0008          /* create a non-coalescing extent */
   83 #define EX_MALLOCOK     0x0010          /* safe to call malloc() */
   84 #define EX_WAITSPACE    0x0020          /* wait for space to become free */
   85 #define EX_BOUNDZERO    0x0040          /* boundary lines start at 0 */
   86 #define EX_CONFLICTOK   0x0080          /* allow conflicts */
   87 #define EX_FILLED       0x0100          /* create a filled extent */
   88 
   89 /*
   90  * Special place holders for "alignment" and "boundary" arguments,
   91  * in the event the caller doesn't wish to use those features.
   92  */
   93 #define EX_NOALIGN      1               /* don't do alignment */
   94 #define EX_NOBOUNDARY   0               /* don't do boundary checking */
   95 
   96 #if defined(_KERNEL) || defined(_EXTENT_TESTING)
   97 #define EXTENT_FIXED_STORAGE_SIZE(_nregions)            \
   98         (ALIGN(sizeof(struct extent_fixed)) +           \
   99         ((ALIGN(sizeof(struct extent_region))) *        \
  100          (_nregions)))
  101 
  102 void extent_print_all(void);
  103 
  104 struct  extent *extent_create(char *, u_long, u_long, int,
  105             caddr_t, size_t, int);
  106 void    extent_destroy(struct extent *);
  107 int     extent_alloc_subregion(struct extent *, u_long, u_long,
  108             u_long, u_long, u_long, u_long, int, u_long *);
  109 int     extent_alloc_subregion_with_descr(struct extent *, u_long, u_long,
  110             u_long, u_long, u_long, u_long, int, struct extent_region *,
  111             u_long *);
  112 int     extent_alloc_region(struct extent *, u_long, u_long, int);
  113 int     extent_free(struct extent *, u_long, u_long, int);
  114 void    extent_print(struct extent *);
  115 
  116 /* Simple case of extent_alloc_subregion() */
  117 #define extent_alloc(_ex, _size, _alignment, _skew, _boundary, \
  118                 _flags, _result) \
  119         extent_alloc_subregion((_ex), (_ex)->ex_start, (_ex)->ex_end,  \
  120         (_size), (_alignment), (_skew), (_boundary), (_flags), (_result))
  121 
  122 /* Simple case of extent_alloc_subregion_with_descr() */
  123 #define extent_alloc_with_descr(_ex, _size, _alignment, _skew, _boundary, \
  124                 _flags, _region, _result) \
  125         extent_alloc_subregion_with_descr((_ex), (_ex)->ex_start, \
  126         (_ex)->ex_end, (_size), (_alignment), (_skew), (_boundary), \
  127         (_flags), (_region), (_result))
  128 #endif /* _KERNEL || _EXTENT_TESTING */
  129 
  130 #endif /* ! _SYS_EXTENT_H_ */

Cache object: ec696f49aa16f55f602057af3b45b2f8


[ 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.