home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / os / bsdss4.tz / bsdss4 / bsdss / server / sys / mapmem.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-22  |  5.9 KB  |  147 lines

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