home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 9.ddi / usr / include / vm / seg.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  4.9 KB  |  170 lines

  1. /*    Copyright (c) 1990 UNIX System Laboratories, Inc.    */
  2. /*    Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T    */
  3. /*      All Rights Reserved      */
  4.  
  5. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF         */
  6. /*    UNIX System Laboratories, Inc.                         */
  7. /*    The copyright notice above does not evidence any       */
  8. /*    actual or intended publication of such source code.    */
  9.  
  10. /*
  11.  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  12.  *         PROPRIETARY NOTICE (Combined)
  13.  * 
  14.  * This source code is unpublished proprietary information
  15.  * constituting, or derived under license from AT&T's UNIX(r) System V.
  16.  * In addition, portions of such source code were derived from Berkeley
  17.  * 4.3 BSD under license from the Regents of the University of
  18.  * California.
  19.  * 
  20.  * 
  21.  * 
  22.  *         Copyright Notice 
  23.  * 
  24.  * Notice of copyright on this source code product does not indicate 
  25.  * publication.
  26.  * 
  27.  *     (c) 1986,1987,1988,1989  Sun Microsystems, Inc
  28.  *     (c) 1983,1984,1985,1986,1987,1988,1989  AT&T.
  29.  *               All rights reserved.
  30.  *  
  31.  */
  32.  
  33. #ifndef _VM_SEG_H
  34. #define _VM_SEG_H
  35.  
  36. #ident    "@(#)/usr/include/vm/seg.h.sl 1.1 4.0 12/08/90 27661 AT&T-USL"
  37.  
  38. #include "vm/faultcode.h"
  39. #include "vm/mp.h"
  40.  
  41. /*
  42.  * VM - Segments.
  43.  */
  44.  
  45. /*
  46.  * An address space contains a set of segments, managed by drivers.
  47.  * Drivers support mapped devices, sharing, copy-on-write, etc.
  48.  *
  49.  * The seg structure contains a lock to prevent races, the base virtual
  50.  * address and size of the segment, a back pointer to the containing
  51.  * address space, pointers to maintain a circularly doubly linked list
  52.  * of segments in the same address space, and procedure and data hooks
  53.  * for the driver.  The seg list on the address space is sorted by
  54.  * ascending base addresses and overlapping segments are not allowed.
  55.  *
  56.  * After a segment is created, faults may occur on pages of the segment.
  57.  * When a fault occurs, the fault handling code must get the desired
  58.  * object and set up the hardware translation to the object.  For some
  59.  * objects, the fault handling code also implements copy-on-write.
  60.  *
  61.  * When the hat wants to unload a translation, it can call the unload
  62.  * routine which is responsible for processing reference and modify bits.
  63.  */
  64.  
  65. /*
  66.  * Fault information passed to the seg fault handling routine.
  67.  * The F_SOFTLOCK and F_SOFTUNLOCK are used by software
  68.  * to lock and unlock pages for physical I/O.
  69.  */
  70. enum fault_type {
  71.     F_INVAL,        /* invalid page */
  72.     F_PROT,            /* protection fault */
  73.     F_SOFTLOCK,        /* software requested locking */
  74.     F_SOFTUNLOCK        /* software requested unlocking */
  75. };
  76.  
  77. /*
  78.  * seg_rw gives the access type for a fault operation
  79.  */
  80. enum seg_rw {
  81.     S_OTHER,        /* unknown or not touched */
  82.     S_READ,            /* read access attempted */
  83.     S_WRITE,        /* write access attempted */
  84.     S_EXEC             /* execution access attempted */
  85. };
  86.  
  87. struct seg {
  88.     mon_t    s_lock;
  89.     addr_t    s_base;            /* base virtual address */
  90.     u_int    s_size;            /* size in bytes */
  91.     struct    as *s_as;        /* containing address space */
  92.     struct    seg *s_next;        /* next seg in this address space */
  93.     struct    seg *s_prev;        /* prev seg in this address space */
  94.     struct    seg_ops {
  95. #if defined(__STDC__)
  96.         int (*dup)(struct seg *, struct seg *);
  97.         int (*unmap)(struct seg *, addr_t, u_int);
  98.         void (*free)(struct seg *);
  99.         faultcode_t (*fault)(struct seg *, addr_t, u_int, 
  100.             enum fault_type, enum seg_rw);
  101.         faultcode_t (*faulta)(struct seg *, addr_t);
  102.         void (*unload)(struct seg *, addr_t, u_int, u_int);
  103.         int (*setprot)(struct seg *, addr_t, u_int, u_int);
  104.         int (*checkprot)(struct seg *, addr_t, u_int, u_int);
  105.         int (*kluster)(struct seg *, addr_t, int);
  106.         u_int (*swapout)(struct seg *);
  107.         int (*sync)(struct seg *, addr_t, u_int, int, u_int);
  108.         int (*incore)(struct seg *, addr_t, u_int, char *);
  109.         int (*lockop)(struct seg *, addr_t, u_int, int, int, 
  110.             ulong *, u_int);
  111.         int (*getprot)(struct seg *, addr_t, u_int, u_int *);
  112.         off_t (*getoffset)(struct seg *, addr_t);
  113.         int (*gettype)(struct seg *, addr_t);
  114.         int (*getvp)(struct seg *, addr_t, struct vnode **);        
  115. #else
  116.         int    (*dup)();
  117.         int    (*unmap)();
  118.         void    (*free)();
  119.         faultcode_t    (*fault)();
  120.         faultcode_t    (*faulta)();
  121.         void    (*unload)();
  122.         int    (*setprot)();
  123.         int    (*checkprot)();
  124.         int    (*kluster)();
  125.         u_int    (*swapout)();
  126.         int    (*sync)();
  127.         int    (*incore)();
  128.         int    (*lockop)();
  129.         int    (*getprot)();
  130.         off_t    (*getoffset)();
  131.         int    (*gettype)();
  132.         int    (*getvp)();        
  133. #endif
  134.     } *s_ops;
  135.     _VOID *s_data;            /* private data for instance */
  136. };
  137.  
  138. #ifdef _KERNEL
  139. /*
  140.  * Generic segment operations
  141.  */
  142. struct    seg *seg_alloc(/* as, base, size */);
  143. int    seg_attach(/* as, base, size, seg */);
  144. void    seg_free(/* seg */);
  145.  
  146. #ifdef DEBUG
  147.  
  148. u_int    seg_page(/* seg, addr */);
  149. u_int    seg_pages(/* seg */);
  150.  
  151. #else
  152.  
  153. #define seg_page(seg, addr) \
  154.      ((u_int)(((addr) - (seg)->s_base) >> PAGESHIFT))
  155.  
  156. #define seg_pages(seg) \
  157.     ((u_int)(((seg)->s_size + PAGEOFFSET) >> PAGESHIFT))
  158.  
  159. #endif
  160.  
  161. #if defined(__STDC__)
  162. extern void seg_unmap(struct seg *);
  163. #else
  164. extern void seg_unmap();
  165. #endif    /* __STDC__ */
  166.  
  167. #endif /* _KERNEL */
  168.  
  169. #endif    /* _VM_SEG_H */
  170.