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

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:  *
1.1.1.2 ! root       40:  *     from: @(#)mapmem.h      7.2 (Berkeley) 6/6/90
        !            41:  *     mapmem.h,v 1.3 1993/05/20 16:22:37 cgd Exp
1.1       root       42:  */
                     43: 
1.1.1.2 ! root       44: #ifndef _SYS_MAPMEM_H_
        !            45: #define _SYS_MAPMEM_H_
        !            46: 
1.1       root       47: /*
                     48:  * Mapped memory descriptors.
                     49:  *
                     50:  * A process has one of these for every "mapped" memory region.
                     51:  * Mapped memory is characterized by:
                     52:  *     - Corresponding physical memory is neither paged nor swapped.
                     53:  *     - User PTEs have both pg_v and pg_fod set.
                     54:  *     - Has no backing swap space unless mapped over existing data.
                     55:  *     - If mapped over existing data, original data is lost when
                     56:  *       segment is unmapped. (i.e. pages are reinitialized to ZFOD)
                     57:  * Operations:
                     58:  *     (*mm_fork)(mp, ischild) struct mapmem *mp; int ischild;
                     59:  *             Called during fork in both parent and child.  Parent
                     60:  *             call can be used for maintaining reference counts and
                     61:  *             should NEVER destroy the region.  Child call should be
                     62:  *             used for unmapping regions not inherited across forks.
                     63:  *     (*mm_vfork)(mp, fup, tup) struct mapmem *mp; struct user *fup, *tup;
                     64:  *             Called twice during vfork (always in parent context)
                     65:  *             after exchanging resources (including u_mmap chains).
                     66:  *             `fup' is the donor and `tup' the recipient of the
                     67:  *             "parent" (full) context.  Needed for maintaining
                     68:  *             reference counts or if the underlying object contains
                     69:  *             references to owning process.  Routine should NEVER
                     70:  *             destroy the region.
                     71:  *     (*mm_exec)(mp) struct mapmem *mp;
                     72:  *             Called during exec before releasing old address space.
                     73:  *             Used for graceful cleanup of underlying object.  Resources
                     74:  *             will be freed regardless of what this routine does.
                     75:  *             Need to add a post-exec call to re-establish mappings
                     76:  *             in the new address space for regions inherited across execs.
                     77:  *     (*mm_exit)(mp) struct mapmem *mp;
                     78:  *             Called during exit just before releasing address space.
                     79:  *             Used for graceful cleanup of underlying object.  Resources
                     80:  *             will be freed regardless of what this routine does.
                     81:  * The default semantics for a region with routine addresses of zero are
                     82:  * that it is inherited across forks, stays with the "active" process during
                     83:  * vforks, and is destroyed by execs and exit.
                     84:  */
                     85: 
                     86: struct mapmem {
                     87:        struct  mapmem *mm_next;        /* next descriptor */
                     88:        int     mm_id;                  /* identifier (e.g. fd, shmid) */
                     89:        caddr_t mm_uva;                 /* user VA at which region is mapped */
                     90:        int     mm_size;                /* size of mapped region */
                     91:        int     mm_prot;                /* attributes of region */
                     92:        struct mapmemops {              /* operations */
                     93:                int     (*mm_fork)();
                     94:                int     (*mm_vfork)();
                     95:                int     (*mm_exec)();
                     96:                int     (*mm_exit)();
                     97:        } *mm_ops;
                     98: };
                     99: 
                    100: #define MMNIL  ((struct mapmem *)0)
                    101: 
                    102: /* attributes */
                    103: #define MM_RW          0x00    /* region is read-write */
                    104: #define        MM_RO           0x01    /* region is read-only */
                    105: #define MM_CI          0x02    /* caching is inhibited on region */
                    106: #define MM_NOCORE      0x04    /* cannot write region to core file;
                    107:                                   e.g. mapped framebuffer hardware */
                    108: 
                    109: #ifdef KERNEL
                    110: #define MMALLOC(mp) \
                    111:        (mp) = (struct mapmem *)malloc((u_long)sizeof(struct mapmem), \
                    112:            M_MAPMEM, M_WAITOK)
                    113: 
                    114: #define MMFREE(mp) \
                    115:        free((caddr_t)(mp), M_MAPMEM)
                    116: #endif
1.1.1.2 ! root      117: 
        !           118: #endif /* !_SYS_MAPMEM_H_ */

unix.superglobalmegacorp.com

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