home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 9.ddi / usr / include / vm / seg_u.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  4.5 KB  |  147 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_U_H
  34. #define _VM_SEG_U_H
  35.  
  36. #ident    "@(#)/usr/include/vm/seg_u.h.sl 1.1 4.0 12/08/90 26737 AT&T-USL"
  37.  
  38. /*
  39.  * VM - U-area segment management
  40.  *
  41.  * This file contains definitions related to the u-area segment type.
  42.  *
  43.  * In its most general form, this segment type provides an interface
  44.  * for managing stacks that are protected by red zones, with the size
  45.  * of each stack independently specifiable.  The current implementation
  46.  * is restricted in the following way.
  47.  * 1)    It assumes that all stacks are the same size.  In particular,
  48.  *    it assumes that the stacks it manages are actually traditional
  49.  *    u-areas, each containing a stack at one end.
  50.  *
  51.  * The segment driver manages a contiguous chunk of virtual space,
  52.  * carving it up into individual stack instances as required, and
  53.  * associating physical storage, MMU mappings, and swap space with
  54.  * each individual stack instance.
  55.  *
  56.  * As a matter of nomenclature, the individual allocation units are
  57.  * referred to as "slots".
  58.  */
  59.  
  60. /*
  61.  * The number of pages covered by a single seg_u slot.
  62.  *
  63.  * This value is the number of (software) pages in the u-area
  64.  * (including the stack in the u-area) plus an additional page
  65.  * for a stack red zone.  If the seg_u implementation is ever
  66.  * generalized to allow variable-size stack allocation, this
  67.  * define will have to change.
  68.  */
  69.  
  70. /*
  71.  * On the 386, ublocks are variable length.  Each process can have a maximum of
  72.  * SEGU_PAGES (MAXUSIZE) pages allocated for it.  Since MAXUSIZE is fairly
  73.  * large, this uses up a lot of kernel virtual address space, but as long as
  74.  * no physical memory is wasted this is alright.
  75.  *
  76.  * NOTE: The 386 implementation does not need an extra page for redzone.
  77.  */
  78. #define    SEGU_PAGES    MAXUSIZE
  79.  
  80. #define    segu_stom(v)    (v)
  81. #define    segu_mtos(v)    (v)
  82.  
  83.  
  84. /*
  85.  * Private information per overall segu segment (as opposed
  86.  * to per slot within segment)
  87.  *
  88.  * XXX:    We may wish to modify the free list to handle it as a queue
  89.  *    instead of a stack; this possibly could reduce the frequency
  90.  *    of cache flushes.  If so, we would need a list tail pointer
  91.  *    as well as a list head pointer.
  92.  */
  93. struct segu_segdata {
  94.     /*
  95.      * info needed:
  96.      *    - slot vacancy info
  97.      *    - a way of getting to state info for each slot
  98.      */
  99.     struct    segu_data *usd_slots;    /* array of segu_data structs,
  100.                        one per slot */
  101.     struct    segu_data *usd_free;    /* slot free list head */
  102. };
  103.  
  104. /*
  105.  * Private per-slot information.
  106.  */
  107. struct segu_data {
  108.     struct    segu_data *su_next;        /* free list link */
  109.     struct    anon *su_swaddr[SEGU_PAGES];    /* disk address of u area when
  110.                            swapped */
  111.     u_int    su_flags;            /* state info: see below */
  112.     struct proc *su_proc;            /* owner fo the slot */
  113. };
  114.  
  115. /*
  116.  * Flag bits
  117.  *
  118.  * When the SEGU_LOCKED bit is set, all the resources associated with the
  119.  * corresponding slot are locked in place, so that referencing addresses
  120.  * in the slot's range will not cause a fault.  Clients using this driver
  121.  * to manage a u-area lock down the slot when the corresponding process
  122.  * becomes runnable and unlock it when the process is swapped out.
  123.  */
  124. #define    SEGU_ALLOCATED    0x01        /* slot is in use */
  125. #define    SEGU_LOCKED    0x02        /* slot's resources locked */
  126.  
  127.  
  128. #ifdef    _KERNEL
  129. extern struct seg    *segu;
  130.  
  131. /*
  132.  * Public routine declarations not part of the segment ops vector go here.
  133.  */
  134. #if defined(__STDC__)
  135. extern int segu_create(struct seg *, void *);
  136. extern addr_t segu_get(struct proc *, int);
  137. extern void segu_release(struct proc *);
  138. #else
  139. extern int    segu_create();
  140. extern addr_t    segu_get();
  141. extern void    segu_release();
  142. #endif /* __STDC__ */
  143.  
  144. #endif    /* _KERNEL */
  145.  
  146. #endif    /* _VM_SEG_U_H */
  147.