home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Headers / mach / vm_param.h < prev    next >
Text File  |  1992-07-29  |  3KB  |  99 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1987 Carnegie-Mellon University
  4.  * All rights reserved.  The CMU software License Agreement specifies
  5.  * the terms and conditions for use and redistribution.
  6.  */
  7. /*
  8.  *    File:    mach/vm_param.h
  9.  *    Author:    Avadi!29vanian, Jr., Michael Wayne Young
  10.  *
  11.  *    Copyright (C) 1985, Avadis Tevanian, Jr., Michael Wayne Young
  12.  *
  13.  *    Machine independent virtual memory parameters.
  14.  *
  15.  * HISTORY
  16.  * 15-May-87  Avadis Tevanian (avie) at Carnegie-Mellon University
  17.  *    Coalesced includes, documented use of PAGE_SIZE and PAGE_SHIFT.
  18.  *
  19.  * 15-Nov-86  Avadis Tevanian (avie) at Carnegie-Mellon University
  20.  *    Removed include of <mach_init.h> before non-kernel definitions
  21.  *    of trunc/round page macros.  When this is included, it makes it
  22.  *    impossible for user programs to include system header files to
  23.  *    retrieve kernel data structures.  (For example, the user level
  24.  *    mach_init will cause a task to be a port, making it impossible
  25.  *    to get the real kernel definition of a task).
  26.  *
  27.  *  7-Nov-86  Michael Young (mwyoung) at Carnegie-Mellon University
  28.  *    Added non-KERNEL definitions of round_page, trunc_page.
  29.  *
  30.  * 21-May-86  David Golub (dbg) at Carnegie-Mellon University
  31.  *    Added page_mask.  Changed types of page_size and page_mask
  32.  *    to vm_size_t.
  33.  *
  34.  *  9-Jun-85  Avadis Tevanian (avie) at Carnegie-Mellon University
  35.  *    Created.
  36.  *
  37.  */
  38.  
  39. #ifndef    _MACH_VM_PARAM_H_
  40. #define    _MACH_VM_PARAM_H_
  41.  
  42. #import <mach/machine/vm_param.h>
  43. #import <mach/machine/vm_types.h>
  44.  
  45. /*
  46.  *    The machine independent pages are refered to as PAGES.  A page
  47.  *    is some number of hardware pages, depending on the target machine.
  48.  */
  49.  
  50. /*
  51.  *    All references to the size of a page should be done with PAGE_SIZE
  52.  *    or PAGE_SHIFT.  The fact they are variables is hidden here so that
  53.  *    we can easily make them constant if we so desire.
  54.  */
  55.  
  56. #define    PAGE_SIZE    page_size    /* size of page in addressible units */
  57. #define PAGE_SHIFT    page_shift    /* number of bits to shift for pages */
  58.  
  59. #ifdef    ASSEMBLER
  60. #else    ASSEMBLER
  61. /*
  62.  *    Convert addresses to pages and vice versa.
  63.  *    No rounding is used.
  64.  */
  65.  
  66. #ifdef    KERNEL
  67. #define    atop(x)        (((unsigned)(x)) >> page_shift)
  68. #define    ptoa(x)        ((vm_offset_t)((x) << page_shift))
  69. #endif    KERNEL
  70.  
  71. /*
  72.  *    Round off or truncate to the nearest page.  These will work
  73.  *    for either addresses or counts.  (i.e. 1 byte rounds to 1 page
  74.  *    bytes.
  75.  */
  76.  
  77. #ifdef    KERNEL
  78. #define    round_page(x)    ((vm_offset_t)((((vm_offset_t)(x)) + page_mask) & ~page_mask))
  79. #define    trunc_page(x)    ((vm_offset_t)(((vm_offset_t)(x)) & ~page_mask))
  80. #else    KERNEL
  81. #define    round_page(x)    ((((vm_offset_t)(x) + (vm_page_si!2@ 1)) / vm_page_size) * vm_page_size)
  82. #define    trunc_page(x)    ((((vm_offset_t)(x)) / vm_page_size) * vm_page_size)
  83. #endif    KERNEL
  84.  
  85. #ifdef    KERNEL
  86. extern vm_size_t    page_size;    /* machine independent page size */
  87. extern vm_size_t    page_mask;    /* page_size - 1; mask for
  88.                            offset within page */
  89. extern int        page_shift;    /* shift to use for page size */
  90.  
  91. extern vm_size_t    mem_size;    /* size of physical memory (bytes) */
  92. extern vm_offset_t    first_addr;    /* first physical page */
  93. extern vm_offset_t    last_addr;    /* last physical page */
  94. #endif    KERNEL
  95.  
  96. #endif    ASSEMBLER
  97.  
  98. #endif    _MACH_VM_PARAM_H_
  99.