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

Annotation of sys/uvm/uvm_map_i.h, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: uvm_map_i.h,v 1.21 2007/04/11 12:10:42 art Exp $      */
        !             2: /*     $NetBSD: uvm_map_i.h,v 1.18 2000/11/27 08:40:04 chs Exp $       */
        !             3:
        !             4: /*
        !             5:  * Copyright (c) 1997 Charles D. Cranor and Washington University.
        !             6:  * Copyright (c) 1991, 1993, The Regents of the University of California.
        !             7:  *
        !             8:  * All rights reserved.
        !             9:  *
        !            10:  * This code is derived from software contributed to Berkeley by
        !            11:  * The Mach Operating System project at Carnegie-Mellon University.
        !            12:  *
        !            13:  * Redistribution and use in source and binary forms, with or without
        !            14:  * modification, are permitted provided that the following conditions
        !            15:  * are met:
        !            16:  * 1. Redistributions of source code must retain the above copyright
        !            17:  *    notice, this list of conditions and the following disclaimer.
        !            18:  * 2. Redistributions in binary form must reproduce the above copyright
        !            19:  *    notice, this list of conditions and the following disclaimer in the
        !            20:  *    documentation and/or other materials provided with the distribution.
        !            21:  * 3. All advertising materials mentioning features or use of this software
        !            22:  *    must display the following acknowledgement:
        !            23:  *     This product includes software developed by Charles D. Cranor,
        !            24:  *      Washington University, the University of California, Berkeley and
        !            25:  *      its contributors.
        !            26:  * 4. Neither the name of the University nor the names of its contributors
        !            27:  *    may be used to endorse or promote products derived from this software
        !            28:  *    without specific prior written permission.
        !            29:  *
        !            30:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
        !            31:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            32:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            33:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
        !            34:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            35:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            36:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            37:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            38:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            39:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            40:  * SUCH DAMAGE.
        !            41:  *
        !            42:  *     @(#)vm_map.c    8.3 (Berkeley) 1/12/94
        !            43:  * from: Id: uvm_map_i.h,v 1.1.2.1 1997/08/14 19:10:50 chuck Exp
        !            44:  *
        !            45:  *
        !            46:  * Copyright (c) 1987, 1990 Carnegie-Mellon University.
        !            47:  * All rights reserved.
        !            48:  *
        !            49:  * Permission to use, copy, modify and distribute this software and
        !            50:  * its documentation is hereby granted, provided that both the copyright
        !            51:  * notice and this permission notice appear in all copies of the
        !            52:  * software, derivative works or modified versions, and any portions
        !            53:  * thereof, and that both notices appear in supporting documentation.
        !            54:  *
        !            55:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
        !            56:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
        !            57:  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
        !            58:  *
        !            59:  * Carnegie Mellon requests users of this software to return to
        !            60:  *
        !            61:  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
        !            62:  *  School of Computer Science
        !            63:  *  Carnegie Mellon University
        !            64:  *  Pittsburgh PA 15213-3890
        !            65:  *
        !            66:  * any improvements or extensions that they make and grant Carnegie the
        !            67:  * rights to redistribute these changes.
        !            68:  */
        !            69:
        !            70: #ifndef _UVM_UVM_MAP_I_H_
        !            71: #define _UVM_UVM_MAP_I_H_
        !            72:
        !            73: /*
        !            74:  * uvm_map_i.h
        !            75:  */
        !            76:
        !            77: /*
        !            78:  * inline functions [maybe]
        !            79:  */
        !            80:
        !            81: #if defined(UVM_MAP_INLINE) || defined(UVM_MAP)
        !            82:
        !            83: /*
        !            84:  * uvm_map_create: create map
        !            85:  */
        !            86:
        !            87: MAP_INLINE vm_map_t
        !            88: uvm_map_create(pmap, min, max, flags)
        !            89:        pmap_t pmap;
        !            90:        vaddr_t min, max;
        !            91:        int flags;
        !            92: {
        !            93:        vm_map_t result;
        !            94:
        !            95:        MALLOC(result, vm_map_t, sizeof(struct vm_map), M_VMMAP, M_WAITOK);
        !            96:        uvm_map_setup(result, min, max, flags);
        !            97:        result->pmap = pmap;
        !            98:        return(result);
        !            99: }
        !           100:
        !           101: /*
        !           102:  * uvm_map_setup: init map
        !           103:  *
        !           104:  * => map must not be in service yet.
        !           105:  */
        !           106:
        !           107: MAP_INLINE void
        !           108: uvm_map_setup(map, min, max, flags)
        !           109:        vm_map_t map;
        !           110:        vaddr_t min, max;
        !           111:        int flags;
        !           112: {
        !           113:
        !           114:        RB_INIT(&map->rbhead);
        !           115:        map->header.next = map->header.prev = &map->header;
        !           116:        map->nentries = 0;
        !           117:        map->size = 0;
        !           118:        map->ref_count = 1;
        !           119:        map->min_offset = min;
        !           120:        map->max_offset = max;
        !           121:        map->flags = flags;
        !           122:        map->first_free = &map->header;
        !           123:        map->hint = &map->header;
        !           124:        map->timestamp = 0;
        !           125:        rw_init(&map->lock, "vmmaplk");
        !           126:        simple_lock_init(&map->ref_lock);
        !           127:        simple_lock_init(&map->hint_lock);
        !           128: }
        !           129:
        !           130:
        !           131: /*
        !           132:  *   U N M A P   -   m a i n   e n t r y   p o i n t
        !           133:  */
        !           134:
        !           135: /*
        !           136:  * uvm_unmap: remove mappings from a vm_map (from "start" up to "stop")
        !           137:  *
        !           138:  * => caller must check alignment and size
        !           139:  * => map must be unlocked (we will lock it)
        !           140:  */
        !           141:
        !           142: MAP_INLINE void
        !           143: uvm_unmap_p(map, start, end, p)
        !           144:        vm_map_t map;
        !           145:        vaddr_t start,end;
        !           146:        struct proc *p;
        !           147: {
        !           148:        vm_map_entry_t dead_entries;
        !           149:        UVMHIST_FUNC("uvm_unmap"); UVMHIST_CALLED(maphist);
        !           150:
        !           151:        UVMHIST_LOG(maphist, "  (map=%p, start=0x%lx, end=0x%lx)",
        !           152:            map, start, end, 0);
        !           153:        /*
        !           154:         * work now done by helper functions.   wipe the pmap's and then
        !           155:         * detach from the dead entries...
        !           156:         */
        !           157:        vm_map_lock(map);
        !           158:        uvm_unmap_remove(map, start, end, &dead_entries, p);
        !           159:        vm_map_unlock(map);
        !           160:
        !           161:        if (dead_entries != NULL)
        !           162:                uvm_unmap_detach(dead_entries, 0);
        !           163:
        !           164:        UVMHIST_LOG(maphist, "<- done", 0,0,0,0);
        !           165: }
        !           166:
        !           167:
        !           168: /*
        !           169:  * uvm_map_reference: add reference to a map
        !           170:  *
        !           171:  * => map need not be locked (we use ref_lock).
        !           172:  */
        !           173:
        !           174: MAP_INLINE void
        !           175: uvm_map_reference(map)
        !           176:        vm_map_t map;
        !           177: {
        !           178:        simple_lock(&map->ref_lock);
        !           179:        map->ref_count++;
        !           180:        simple_unlock(&map->ref_lock);
        !           181: }
        !           182:
        !           183: /*
        !           184:  * uvm_map_deallocate: drop reference to a map
        !           185:  *
        !           186:  * => caller must not lock map
        !           187:  * => we will zap map if ref count goes to zero
        !           188:  */
        !           189:
        !           190: MAP_INLINE void
        !           191: uvm_map_deallocate(map)
        !           192:        vm_map_t map;
        !           193: {
        !           194:        int c;
        !           195:
        !           196:        simple_lock(&map->ref_lock);
        !           197:        c = --map->ref_count;
        !           198:        simple_unlock(&map->ref_lock);
        !           199:        if (c > 0) {
        !           200:                return;
        !           201:        }
        !           202:
        !           203:        /*
        !           204:         * all references gone.   unmap and free.
        !           205:         */
        !           206:
        !           207:        uvm_unmap(map, map->min_offset, map->max_offset);
        !           208:        pmap_destroy(map->pmap);
        !           209:        FREE(map, M_VMMAP);
        !           210: }
        !           211:
        !           212: #endif /* defined(UVM_MAP_INLINE) || defined(UVM_MAP) */
        !           213:
        !           214: #endif /* _UVM_UVM_MAP_I_H_ */

CVSweb