Annotation of Net2/sys/mapmem.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1988 University of Utah.
        !             3:  * Copyright (c) 1990 The Regents of the University of California.
        !             4:  * All rights reserved.
        !             5:  *
        !             6:  * This code is derived from software contributed to Berkeley by
        !             7:  * the Systems Programming Group of the University of Utah Computer
        !             8:  * Science Department.
        !             9:  *
        !            10:  * Redistribution and use in source and binary forms, with or without
        !            11:  * modification, are permitted provided that the following conditions
        !            12:  * are met:
        !            13:  * 1. Redistributions of source code must retain the above copyright
        !            14:  *    notice, this list of conditions and the following disclaimer.
        !            15:  * 2. Redistributions in binary form must reproduce the above copyright
        !            16:  *    notice, this list of conditions and the following disclaimer in the
        !            17:  *    documentation and/or other materials provided with the distribution.
        !            18:  * 3. All advertising materials mentioning features or use of this software
        !            19:  *    must display the following acknowledgement:
        !            20:  *     This product includes software developed by the University of
        !            21:  *     California, Berkeley and its contributors.
        !            22:  * 4. Neither the name of the University nor the names of its contributors
        !            23:  *    may be used to endorse or promote products derived from this software
        !            24:  *    without specific prior written permission.
        !            25:  *
        !            26:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
        !            27:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            28:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            29:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
        !            30:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            31:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            32:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            33:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            34:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            35:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            36:  * SUCH DAMAGE.
        !            37:  *
        !            38:  * from: Utah $Hdr: mmap.h 1.4 89/08/14$
        !            39:  *
        !            40:  *     @(#)mapmem.h    7.2 (Berkeley) 6/6/90
        !            41:  */
        !            42: 
        !            43: /*
        !            44:  * Mapped memory descriptors.
        !            45:  *
        !            46:  * A process has one of these for every "mapped" memory region.
        !            47:  * Mapped memory is characterized by:
        !            48:  *     - Corresponding physical memory is neither paged nor swapped.
        !            49:  *     - User PTEs have both pg_v and pg_fod set.
        !            50:  *     - Has no backing swap space unless mapped over existing data.
        !            51:  *     - If mapped over existing data, original data is lost when
        !            52:  *       segment is unmapped. (i.e. pages are reinitialized to ZFOD)
        !            53:  * Operations:
        !            54:  *     (*mm_fork)(mp, ischild) struct mapmem *mp; int ischild;
        !            55:  *             Called during fork in both parent and child.  Parent
        !            56:  *             call can be used for maintaining reference counts and
        !            57:  *             should NEVER destroy the region.  Child call should be
        !            58:  *             used for unmapping regions not inherited across forks.
        !            59:  *     (*mm_vfork)(mp, fup, tup) struct mapmem *mp; struct user *fup, *tup;
        !            60:  *             Called twice during vfork (always in parent context)
        !            61:  *             after exchanging resources (including u_mmap chains).
        !            62:  *             `fup' is the donor and `tup' the recipient of the
        !            63:  *             "parent" (full) context.  Needed for maintaining
        !            64:  *             reference counts or if the underlying object contains
        !            65:  *             references to owning process.  Routine should NEVER
        !            66:  *             destroy the region.
        !            67:  *     (*mm_exec)(mp) struct mapmem *mp;
        !            68:  *             Called during exec before releasing old address space.
        !            69:  *             Used for graceful cleanup of underlying object.  Resources
        !            70:  *             will be freed regardless of what this routine does.
        !            71:  *             Need to add a post-exec call to re-establish mappings
        !            72:  *             in the new address space for regions inherited across execs.
        !            73:  *     (*mm_exit)(mp) struct mapmem *mp;
        !            74:  *             Called during exit just before releasing address space.
        !            75:  *             Used for graceful cleanup of underlying object.  Resources
        !            76:  *             will be freed regardless of what this routine does.
        !            77:  * The default semantics for a region with routine addresses of zero are
        !            78:  * that it is inherited across forks, stays with the "active" process during
        !            79:  * vforks, and is destroyed by execs and exit.
        !            80:  */
        !            81: 
        !            82: struct mapmem {
        !            83:        struct  mapmem *mm_next;        /* next descriptor */
        !            84:        int     mm_id;                  /* identifier (e.g. fd, shmid) */
        !            85:        caddr_t mm_uva;                 /* user VA at which region is mapped */
        !            86:        int     mm_size;                /* size of mapped region */
        !            87:        int     mm_prot;                /* attributes of region */
        !            88:        struct mapmemops {              /* operations */
        !            89:                int     (*mm_fork)();
        !            90:                int     (*mm_vfork)();
        !            91:                int     (*mm_exec)();
        !            92:                int     (*mm_exit)();
        !            93:        } *mm_ops;
        !            94: };
        !            95: 
        !            96: #define MMNIL  ((struct mapmem *)0)
        !            97: 
        !            98: /* attributes */
        !            99: #define MM_RW          0x00    /* region is read-write */
        !           100: #define        MM_RO           0x01    /* region is read-only */
        !           101: #define MM_CI          0x02    /* caching is inhibited on region */
        !           102: #define MM_NOCORE      0x04    /* cannot write region to core file;
        !           103:                                   e.g. mapped framebuffer hardware */
        !           104: 
        !           105: #ifdef KERNEL
        !           106: #define MMALLOC(mp) \
        !           107:        (mp) = (struct mapmem *)malloc((u_long)sizeof(struct mapmem), \
        !           108:            M_MAPMEM, M_WAITOK)
        !           109: 
        !           110: #define MMFREE(mp) \
        !           111:        free((caddr_t)(mp), M_MAPMEM)
        !           112: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.