home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Headers / mach / vm_param.h < prev    next >
Text File  |  1997-04-27  |  5KB  |  159 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1991,1990,1989,1988,1987 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:    vm_param.h,v $
  29.  * Revision 2.5  93/01/14  17:49:06  danner
  30.  *     Standardized include symbol name.
  31.  *     [92/06/10            pds]
  32.  *     64bit cleanup.
  33.  *     [92/12/01            af]
  34.  * 
  35.  * Revision 2.4  91/05/14  17:02:53  mrt
  36.  *     Correcting copyright
  37.  * 
  38.  * Revision 2.3  91/02/05  17:37:34  mrt
  39.  *     Changed to new Mach copyright
  40.  *     [91/02/01  17:22:32  mrt]
  41.  * 
  42.  * Revision 2.2  90/06/02  15:00:23  rpd
  43.  *     Removed user definitions; added page_aligned.
  44.  *     [90/03/26  22:42:42  rpd]
  45.  * 
  46.  * Revision 2.1  89/08/03  16:06:40  rwd
  47.  * Created.
  48.  * 
  49.  * Revision 2.3  89/02/25  18:42:23  gm0w
  50.  *     Changes for cleanup.
  51.  * 
  52.  * 15-May-87  Avadis Tevanian (avie) at Carnegie-Mellon University
  53.  *    Coalesced includes, documented use of PAGE_SIZE and PAGE_SHIFT.
  54.  *
  55.  * 15-Nov-86  Avadis Tevanian (avie) at Carnegie-Mellon University
  56.  *    Removed include of <mach_init.h> before non-kernel definitions
  57.  *    of trunc/round page macros.  When this is included, it makes it
  58.  *    impossible for user programs to include system header files to
  59.  *    retrieve kernel data structures.  (For example, the user level
  60.  *    mach_init will cause a task to be a port, making it impossible
  61.  *    to get the real kernel definition of a task).
  62.  *
  63.  *  7-Nov-86  Michael Young (mwyoung) at Carnegie-Mellon University
  64.  *    Added non-KERNEL definitions of round_page, trunc_page.
  65.  *
  66.  * 21-May-86  David Golub (dbg) at Carnegie-Mellon University
  67.  *    Added page_mask.  Changed types of page_size and page_mask
  68.  *    to vm_size_t.
  69.  *
  70.  *  9-Jun-85  Avadis Tevanian (avie) at Carnegie-Mellon University
  71.  *    Created.
  72.  *
  73.  */
  74. /*
  75.  *    File:    mach/vm_param.h
  76.  *    Author:    Avadis Tevanian, Jr., Michael Wayne Young
  77.  *    Date:    1985
  78.  *
  79.  *    Machine independent virtual memory parameters.
  80.  *
  81.  */
  82.  
  83. #ifndef    _MACH_VM_PARAM_H_
  84. #define _MACH_VM_PARAM_H_
  85.  
  86. #import <mach/machine/vm_param.h>
  87. #import <mach/machine/vm_types.h>
  88.  
  89. #ifdef    KERNEL
  90. /*
  91.  *    The machine independent pages are refered to as PAGES.  A page
  92.  *    is some number of hardware pages, depending on the target machine.
  93.  */
  94.  
  95. /*
  96.  *    All references to the size of a page should be done with PAGE_SIZE
  97.  *    or PAGE_SHIFT.  The fact they are variables is hidden here so that
  98.  *    we can easily make them constant if we so desire.
  99.  */
  100.  
  101. /*
  102.  *    Regardless whether it is implemented with a constant or a variable,
  103.  *    the PAGE_SIZE is assumed to be a power of two throughout the
  104.  *    virtual memory system implementation.
  105.  */
  106.  
  107. #ifndef    PAGE_SIZE_FIXED
  108. #define PAGE_SIZE    page_size    /* size of page in addressible units */
  109. #define PAGE_SHIFT    page_shift    /* number of bits to shift for pages */
  110. #endif    /* PAGE_SIZE_FIXED */
  111.  
  112. #ifndef    __ASSEMBLER__
  113. /*
  114.  *    Convert addresses to pages and vice versa.
  115.  *    No rounding is used.
  116.  */
  117.  
  118. #define atop(x)        (((vm_size_t)(x)) >> page_shift)
  119. #define ptoa(x)        ((vm_offset_t)((x) << page_shift))
  120.  
  121. /*
  122.  *    Round off or truncate to the nearest page.  These will work
  123.  *    for either addresses or counts.  (i.e. 1 byte rounds to 1 page
  124.  *    bytes.
  125.  */
  126.  
  127. #define round_page(x)    ((vm_offset_t)((((vm_offset_t)(x)) + page_mask) & ~page_mask))
  128. #define trunc_page(x)    ((vm_offset_t)(((vm_offset_t)(x)) & ~page_mask))
  129.  
  130. /*
  131.  *    Determine whether an address is page-aligned, or a count is
  132.  *    an exact page multiple.
  133.  */
  134.  
  135. #define    page_aligned(x)    ((((vm_offset_t) (x)) & page_mask) == 0)
  136.  
  137. #ifndef    PAGE_SIZE_FIXED
  138. extern vm_size_t    page_size;    /* machine independent page size */
  139. extern vm_size_t    page_mask;    /* page_size - 1; mask for
  140.                            offset within page */
  141. extern int        page_shift;    /* shift to use for page size */
  142. #else    /* PAGE_SIZE_FIXED */
  143. #define    page_mask    (PAGE_SIZE-1)
  144. #endif    /* PAGE_SIZE_FIXED */
  145.  
  146. extern vm_size_t    mem_size;    /* size of physical memory (bytes) */
  147. extern vm_offset_t    first_addr;    /* first physical page */
  148. extern vm_offset_t    last_addr;    /* last physical page */
  149.  
  150. #endif    /* __ASSEMBLER__ */
  151.  
  152. #else
  153. #define    round_page(x)    ((((vm_offset_t)(x) + (vm_page_size - 1)) \
  154.                         / vm_page_size) * vm_page_size)
  155. #define    trunc_page(x)    ((((vm_offset_t)(x)) / vm_page_size) * vm_page_size)
  156. #endif
  157.  
  158. #endif    /* _MACH_VM_PARAM_H_ */
  159.