[BACK]Return to extent.h CVS log [TXT][DIR] Up to [local] / sys / sys

Annotation of sys/sys/extent.h, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: extent.h,v 1.8 2006/02/23 19:58:48 miod 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:  * 3. All advertising materials mentioning features or use of this software
                     20:  *    must display the following acknowledgement:
                     21:  *        This product includes software developed by the NetBSD
                     22:  *        Foundation, Inc. and its contributors.
                     23:  * 4. Neither the name of The NetBSD Foundation nor the names of its
                     24:  *    contributors may be used to endorse or promote products derived
                     25:  *    from this software without specific prior written permission.
                     26:  *
                     27:  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
                     28:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
                     29:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     30:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
                     31:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     32:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     33:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     34:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     35:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     36:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     37:  * POSSIBILITY OF SUCH DAMAGE.
                     38:  */
                     39:
                     40: #ifndef _SYS_EXTENT_H_
                     41: #define _SYS_EXTENT_H_
                     42:
                     43: #include <sys/queue.h>
                     44:
                     45: struct extent_region {
                     46:        LIST_ENTRY(extent_region) er_link;      /* link in region list */
                     47:        u_long  er_start;               /* start of region */
                     48:        u_long  er_end;                 /* end of region */
                     49:        int     er_flags;               /* misc. flags */
                     50: };
                     51:
                     52: /* er_flags */
                     53: #define ER_ALLOC       0x01    /* region descriptor dynamically allocated */
                     54:
                     55: struct extent {
                     56:        char    *ex_name;               /* name of extent */
                     57:                                        /* allocated regions in extent */
                     58:        LIST_HEAD(, extent_region) ex_regions;
                     59:        u_long  ex_start;               /* start of extent */
                     60:        u_long  ex_end;                 /* end of extent */
                     61:        int     ex_mtype;               /* memory type */
                     62:        int     ex_flags;               /* misc. information */
                     63:
                     64:        LIST_ENTRY(extent) ex_link;
                     65: };
                     66:
                     67: struct extent_fixed {
                     68:        struct extent   fex_extent;     /* MUST BE FIRST */
                     69:                                        /* freelist of region descriptors */
                     70:        LIST_HEAD(, extent_region) fex_freelist;
                     71:        caddr_t         fex_storage;    /* storage space for descriptors */
                     72:        size_t          fex_storagesize; /* size of storage space */
                     73: };
                     74:
                     75: /* ex_flags; for internal use only */
                     76: #define EXF_FIXED      0x01            /* extent uses fixed storage */
                     77: #define EXF_NOCOALESCE 0x02            /* coalescing of regions not allowed */
                     78: #define EXF_WANTED     0x04            /* someone asleep on extent */
                     79: #define EXF_FLWANTED   0x08            /* someone asleep on freelist */
                     80:
                     81: #define EXF_BITS       "\20\4FLWANTED\3WANTED\2NOCOALESCE\1FIXED"
                     82:
                     83: /* misc. flags passed to extent functions */
                     84: #define EX_NOWAIT      0x00            /* not safe to sleep */
                     85: #define EX_WAITOK      0x01            /* safe to sleep */
                     86: #define EX_FAST                0x02            /* take first fit in extent_alloc() */
                     87: #define EX_CATCH       0x04            /* catch signals while sleeping */
                     88: #define EX_NOCOALESCE  0x08            /* create a non-coalescing extent */
                     89: #define EX_MALLOCOK    0x10            /* safe to call malloc() */
                     90: #define EX_WAITSPACE   0x20            /* wait for space to become free */
                     91: #define EX_BOUNDZERO   0x40            /* boundary lines start at 0 */
                     92:
                     93: /*
                     94:  * Special place holders for "alignment" and "boundary" arguments,
                     95:  * in the event the caller doesn't wish to use those features.
                     96:  */
                     97: #define EX_NOALIGN     1               /* don't do alignment */
                     98: #define EX_NOBOUNDARY  0               /* don't do boundary checking */
                     99:
                    100: #if defined(_KERNEL) || defined(_EXTENT_TESTING)
                    101: #define EXTENT_FIXED_STORAGE_SIZE(_nregions)           \
                    102:        (ALIGN(sizeof(struct extent_fixed)) +           \
                    103:        ((ALIGN(sizeof(struct extent_region))) *        \
                    104:         (_nregions)))
                    105:
                    106: void extent_print_all(void);
                    107:
                    108: struct extent *extent_create(char *, u_long, u_long, int,
                    109:            caddr_t, size_t, int);
                    110: void   extent_destroy(struct extent *);
                    111: int    extent_alloc_subregion(struct extent *, u_long, u_long,
                    112:            u_long, u_long, u_long, u_long, int, u_long *);
                    113: int    extent_alloc_region(struct extent *, u_long, u_long, int);
                    114: int    extent_free(struct extent *, u_long, u_long, int);
                    115: void   extent_print(struct extent *);
                    116:
                    117: /* Simple case of extent_alloc_subregion() */
                    118: #define extent_alloc(_ex, _size, _alignment, _skew, _boundary, \
                    119:                _flags, _result) \
                    120:        extent_alloc_subregion((_ex), (_ex)->ex_start, (_ex)->ex_end,  \
                    121:        (_size), (_alignment), (_skew), (_boundary), (_flags), (_result))
                    122: #endif /* _KERNEL || _EXTENT_TESTING */
                    123:
                    124: #endif /* ! _SYS_EXTENT_H_ */

CVSweb