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/vmem.h

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  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 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c)2006 YAMAMOTO Takashi,
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   24  * SUCH DAMAGE.
   25  */
   26 /* From $NetBSD: vmem.h,v 1.20 2013/01/29 21:26:24 para Exp $   */
   27 
   28 /* $FreeBSD: releng/10.3/sys/sys/vmem.h 282361 2015-05-03 07:13:14Z mav $ */
   29 
   30 #ifndef _SYS_VMEM_H_
   31 #define _SYS_VMEM_H_
   32 
   33 #include <sys/types.h>
   34 
   35 #ifdef _KERNEL
   36 
   37 typedef struct vmem vmem_t;
   38 
   39 typedef uintptr_t       vmem_addr_t;
   40 typedef size_t          vmem_size_t;
   41 
   42 #define VMEM_ADDR_MIN   0
   43 #define VMEM_ADDR_MAX   (~(vmem_addr_t)0)
   44 
   45 typedef int (vmem_import_t)(void *, vmem_size_t, int, vmem_addr_t *);
   46 typedef void (vmem_release_t)(void *, vmem_addr_t, vmem_size_t);
   47 typedef void (vmem_reclaim_t)(vmem_t *, int);
   48 
   49 /*
   50  * Create a vmem:
   51  *      name            - Name of the region
   52  *      base            - Initial span start (optional)
   53  *      size            - Initial span size
   54  *      quantum         - Natural unit of allocation (ie PAGE_SIZE, 1, etc)
   55  *      qcache_max      - Maximum size to quantum cache.  This creates a UMA
   56  *                        cache for each multiple of quantum up to qcache_max.
   57  *      flags           - M_* flags
   58  */
   59 vmem_t *vmem_create(const char *name, vmem_addr_t base,
   60     vmem_size_t size, vmem_size_t quantum, vmem_size_t qcache_max, int flags);
   61 vmem_t *vmem_init(vmem_t *vm, const char *name, vmem_addr_t base,
   62     vmem_size_t size, vmem_size_t quantum, vmem_size_t qcache_max, int flags);
   63 void vmem_destroy(vmem_t *);
   64 
   65 /*
   66  * Set callbacks for bringing in dynamic regions:
   67  *      importfn        - Backing store import routine.
   68  *      releasefn       - Backing store release routine.
   69  *      arg             - Backing store argument
   70  *      import_quantum  - Size to import from backing store
   71  */
   72 
   73 void vmem_set_import(vmem_t *vm, vmem_import_t *importfn,
   74     vmem_release_t *releasefn, void *arg, vmem_size_t import_quantum);
   75 
   76 /*
   77  * Set a callback for reclaiming memory when space is exhausted:
   78  */
   79 void vmem_set_reclaim(vmem_t *vm, vmem_reclaim_t *reclaimfn);
   80 
   81 /*
   82  * Allocate and free linear regions from a vmem.  Must specify
   83  * BESTFIT or FIRSTFIT.  Free is non-blocking.  These routines
   84  * respect the quantum caches.
   85  */
   86 int vmem_alloc(vmem_t *vm, vmem_size_t size, int flags, vmem_addr_t *addrp);
   87 void vmem_free(vmem_t *vm, vmem_addr_t addr, vmem_size_t size);
   88 
   89 /*
   90  * Constrained allocate and free routines.  These bypass the quantum cache.
   91  *      size            - Size in units of 1, not quantum.
   92  *      align           - Required alignment of the start of region
   93  *      phase           - Offset from alignment
   94  *      nocross         - Illegal boundary
   95  *      minaddr         - Minimum allowed address for last byte
   96  *      maxaddr         - Maximum allowed address for first byte
   97  *      flags           - M_* flags
   98  *      addrp           - result
   99  */
  100 int vmem_xalloc(vmem_t *vm, vmem_size_t size, vmem_size_t align,
  101     vmem_size_t phase, vmem_size_t nocross, vmem_addr_t minaddr,
  102     vmem_addr_t maxaddr, int flags, vmem_addr_t *addrp);
  103 void vmem_xfree(vmem_t *vm, vmem_addr_t addr, vmem_size_t size);
  104 
  105 /*
  106  * Add a static region to a vmem after create.  This won't be freed
  107  * until the vmem is destroyed.
  108  */
  109 int vmem_add(vmem_t *vm, vmem_addr_t addr, vmem_size_t size, int flags);
  110 
  111 /*
  112  * Given roundup size to the vmem's native quantum size.
  113  */
  114 vmem_size_t vmem_roundup_size(vmem_t *vm, vmem_size_t size);
  115 
  116 /*
  117  * Report vmem utilization according to the requested type.
  118  */
  119 vmem_size_t vmem_size(vmem_t *vm, int typemask);
  120 
  121 void vmem_whatis(vmem_addr_t addr, int (*fn)(const char *, ...)
  122     __printflike(1, 2));
  123 void vmem_print(vmem_addr_t addr, const char *, int (*fn)(const char *, ...)
  124     __printflike(1, 2));
  125 void vmem_printall(const char *, int (*fn)(const char *, ...)
  126     __printflike(1, 2));
  127 void vmem_startup(void);
  128 
  129 /* vmem_size typemask */
  130 #define VMEM_ALLOC      0x01
  131 #define VMEM_FREE       0x02
  132 #define VMEM_MAXFREE    0x10
  133 
  134 #endif /* _KERNEL */
  135 
  136 #endif /* !_SYS_VMEM_H_ */

Cache object: d7feec7492525648a7dc1d52880610cb


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