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

FreeBSD/Linux Kernel Cross Reference
sys/sys/rman.h

Version: -  FREEBSD  -  FREEBSD10  -  FREEBSD9  -  FREEBSD92  -  FREEBSD91  -  FREEBSD90  -  FREEBSD8  -  FREEBSD82  -  FREEBSD81  -  FREEBSD80  -  FREEBSD7  -  FREEBSD74  -  FREEBSD73  -  FREEBSD72  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  cheribsd  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1  -  FREEBSD-LIBC  -  FREEBSD8-LIBC  -  FREEBSD7-LIBC  -  FREEBSD6-LIBC  -  GLIBC27 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright 1998 Massachusetts Institute of Technology
    3  *
    4  * Permission to use, copy, modify, and distribute this software and
    5  * its documentation for any purpose and without fee is hereby
    6  * granted, provided that both the above copyright notice and this
    7  * permission notice appear in all copies, that both the above
    8  * copyright notice and this permission notice appear in all
    9  * supporting documentation, and that the name of M.I.T. not be used
   10  * in advertising or publicity pertaining to distribution of the
   11  * software without specific, written prior permission.  M.I.T. makes
   12  * no representations about the suitability of this software for any
   13  * purpose.  It is provided "as is" without express or implied
   14  * warranty.
   15  * 
   16  * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''.  M.I.T. DISCLAIMS
   17  * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
   18  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
   19  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
   20  * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   23  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   25  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   26  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   27  * SUCH DAMAGE.
   28  *
   29  * $FreeBSD: src/sys/sys/rman.h,v 1.27 2005/04/12 06:21:58 imp Exp $
   30  */
   31 
   32 #ifndef _SYS_RMAN_H_
   33 #define _SYS_RMAN_H_    1
   34 
   35 #ifndef _KERNEL
   36 #include <sys/queue.h>
   37 #else
   38 #include <machine/bus.h>
   39 #include <machine/resource.h>
   40 #endif
   41 
   42 #define RF_ALLOCATED    0x0001  /* resource has been reserved */
   43 #define RF_ACTIVE       0x0002  /* resource allocation has been activated */
   44 #define RF_SHAREABLE    0x0004  /* resource permits contemporaneous sharing */
   45 #define RF_TIMESHARE    0x0008  /* resource permits time-division sharing */
   46 #define RF_WANTED       0x0010  /* somebody is waiting for this resource */
   47 #define RF_FIRSTSHARE   0x0020  /* first in sharing list */
   48 #define RF_PREFETCHABLE 0x0040  /* resource is prefetchable */
   49 
   50 #define RF_ALIGNMENT_SHIFT      10 /* alignment size bit starts bit 10 */
   51 #define RF_ALIGNMENT_MASK       (0x003F << RF_ALIGNMENT_SHIFT)
   52                                 /* resource address alignemnt size bit mask */
   53 #define RF_ALIGNMENT_LOG2(x)    ((x) << RF_ALIGNMENT_SHIFT)
   54 #define RF_ALIGNMENT(x)         (((x) & RF_ALIGNMENT_MASK) >> RF_ALIGNMENT_SHIFT)
   55 
   56 enum    rman_type { RMAN_UNINIT = 0, RMAN_GAUGE, RMAN_ARRAY };
   57 
   58 /*
   59  * String length exported to userspace for resource names, etc.
   60  */
   61 #define RM_TEXTLEN      32
   62 
   63 /*
   64  * Userspace-exported structures.
   65  */
   66 struct u_resource {
   67         uintptr_t       r_handle;               /* resource uniquifier */
   68         uintptr_t       r_parent;               /* parent rman */
   69         uintptr_t       r_device;               /* device owning this resource */
   70         char            r_devname[RM_TEXTLEN];  /* device name XXX obsolete */
   71 
   72         u_long          r_start;                /* offset in resource space */
   73         u_long          r_size;                 /* size in resource space */
   74         u_int           r_flags;                /* RF_* flags */
   75 };
   76 
   77 struct u_rman {
   78         uintptr_t       rm_handle;              /* rman uniquifier */
   79         char            rm_descr[RM_TEXTLEN];   /* rman description */
   80 
   81         u_long          rm_start;               /* base of managed region */
   82         u_long          rm_size;                /* size of managed region */
   83         enum rman_type  rm_type;                /* region type */
   84 };
   85 
   86 #ifdef _KERNEL
   87 /*
   88  * We use a linked list rather than a bitmap because we need to be able to
   89  * represent potentially huge objects (like all of a processor's physical
   90  * address space).  That is also why the indices are defined to have type
   91  * `unsigned long' -- that being the largest integral type in ISO C (1990).
   92  * The 1999 version of C allows `long long'; we may need to switch to that
   93  * at some point in the future, particularly if we want to support 36-bit
   94  * addresses on IA32 hardware.
   95  */
   96 TAILQ_HEAD(resource_head, resource);
   97 #ifdef __RMAN_RESOURCE_VISIBLE
   98 struct resource {
   99         TAILQ_ENTRY(resource)   r_link;
  100         LIST_ENTRY(resource)    r_sharelink;
  101         LIST_HEAD(, resource)   *r_sharehead;
  102         u_long  r_start;        /* index of the first entry in this resource */
  103         u_long  r_end;          /* index of the last entry (inclusive) */
  104         u_int   r_flags;
  105         void    *r_virtual;     /* virtual address of this resource */
  106         bus_space_tag_t r_bustag; /* bus_space tag */
  107         bus_space_handle_t r_bushandle; /* bus_space handle */
  108         struct  device *r_dev;  /* device which has allocated this resource */
  109         struct  rman *r_rm;     /* resource manager from whence this came */
  110         void    *r_spare1;      /* Spare pointer 1 */
  111         void    *r_spare2;      /* Spare pointer 2 */
  112         int     r_rid;          /* optional rid for this resource. */
  113 };
  114 #else
  115 struct resource;
  116 struct device;
  117 #endif
  118 
  119 struct rman {
  120         struct  resource_head   rm_list;
  121         struct  mtx *rm_mtx;    /* mutex used to protect rm_list */
  122         TAILQ_ENTRY(rman)       rm_link; /* link in list of all rmans */
  123         u_long  rm_start;       /* index of globally first entry */
  124         u_long  rm_end;         /* index of globally last entry */
  125         enum    rman_type rm_type; /* what type of resource this is */
  126         const   char *rm_descr; /* text descripion of this resource */
  127 };
  128 TAILQ_HEAD(rman_head, rman);
  129 
  130 int     rman_activate_resource(struct resource *r);
  131 int     rman_await_resource(struct resource *r, int pri, int timo);
  132 bus_space_handle_t rman_get_bushandle(struct resource *);
  133 bus_space_tag_t rman_get_bustag(struct resource *);
  134 u_long  rman_get_end(struct resource *);
  135 struct device *rman_get_device(struct resource *);
  136 u_int   rman_get_flags(struct resource *);
  137 int     rman_get_rid(struct resource *);
  138 u_long  rman_get_size(struct resource *);
  139 u_long  rman_get_start(struct resource *);
  140 void   *rman_get_virtual(struct resource *);
  141 int     rman_deactivate_resource(struct resource *r);
  142 int     rman_fini(struct rman *rm);
  143 int     rman_init(struct rman *rm);
  144 uint32_t rman_make_alignment_flags(uint32_t size);
  145 int     rman_manage_region(struct rman *rm, u_long start, u_long end);
  146 int     rman_release_resource(struct resource *r);
  147 struct resource *rman_reserve_resource(struct rman *rm, u_long start,
  148                                         u_long end, u_long count,
  149                                         u_int flags, struct device *dev);
  150 struct resource *rman_reserve_resource_bound(struct rman *rm, u_long start,
  151                                         u_long end, u_long count, u_long bound,
  152                                         u_int flags, struct device *dev);
  153 void    rman_set_bushandle(struct resource *_r, bus_space_handle_t _h);
  154 void    rman_set_bustag(struct resource *_r, bus_space_tag_t _t);
  155 void    rman_set_device(struct resource *_r, struct device *_dev);
  156 void    rman_set_end(struct resource *_r, u_long _end);
  157 void    rman_set_rid(struct resource *_r, int _rid);
  158 void    rman_set_start(struct resource *_r, u_long _start);
  159 void    rman_set_virtual(struct resource *_r, void *_v);
  160 
  161 extern  struct rman_head rman_head;
  162 #endif /* _KERNEL */
  163 
  164 #endif /* !_SYS_RMAN_H_ */

Cache object: 114da91b9ea5526598ced1bb0cca32ea


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