home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / darwin / darwinx86.iso / usr / include / mach / i386 / vm_param.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-30  |  6.8 KB  |  209 lines

  1. /*
  2.  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  3.  *
  4.  * @APPLE_LICENSE_HEADER_START@
  5.  * 
  6.  * The contents of this file constitute Original Code as defined in and
  7.  * are subject to the Apple Public Source License Version 1.1 (the
  8.  * "License").  You may not use this file except in compliance with the
  9.  * License.  Please obtain a copy of the License at
  10.  * http://www.apple.com/publicsource and read it before using this file.
  11.  * 
  12.  * This Original Code and all software distributed under the License are
  13.  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  14.  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  15.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  16.  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
  17.  * License for the specific language governing rights and limitations
  18.  * under the License.
  19.  * 
  20.  * @APPLE_LICENSE_HEADER_END@
  21.  */
  22. /*
  23.  * @OSF_COPYRIGHT@
  24.  */
  25. /* 
  26.  * Mach Operating System
  27.  * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
  28.  * All Rights Reserved.
  29.  * 
  30.  * Permission to use, copy, modify and distribute this software and its
  31.  * documentation is hereby granted, provided that both the copyright
  32.  * notice and this permission notice appear in all copies of the
  33.  * software, derivative works or modified versions, and any portions
  34.  * thereof, and that both notices appear in supporting documentation.
  35.  * 
  36.  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  37.  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  38.  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  39.  * 
  40.  * Carnegie Mellon requests users of this software to return to
  41.  * 
  42.  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
  43.  *  School of Computer Science
  44.  *  Carnegie Mellon University
  45.  *  Pittsburgh PA 15213-3890
  46.  * 
  47.  * any improvements or extensions that they make and grant Carnegie Mellon
  48.  * the rights to redistribute these changes.
  49.  */
  50.  
  51. /* 
  52.  * Copyright (c) 1994 The University of Utah and
  53.  * the Computer Systems Laboratory at the University of Utah (CSL).
  54.  * All rights reserved.
  55.  *
  56.  * Permission to use, copy, modify and distribute this software is hereby
  57.  * granted provided that (1) source code retains these copyright, permission,
  58.  * and disclaimer notices, and (2) redistributions including binaries
  59.  * reproduce the notices in supporting documentation, and (3) all advertising
  60.  * materials mentioning features or use of this software display the following
  61.  * acknowledgement: ``This product includes software developed by the
  62.  * Computer Systems Laboratory at the University of Utah.''
  63.  *
  64.  * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
  65.  * IS" CONDITION.  THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
  66.  * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  67.  *
  68.  * CSL requests users of this software to return to csl-dist@cs.utah.edu any
  69.  * improvements that they make and grant CSL redistribution rights.
  70.  *
  71.  */
  72.  
  73. /*
  74.  *    File:    vm_param.h
  75.  *    Author:    Avadis Tevanian, Jr.
  76.  *    Date:    1985
  77.  *
  78.  *    I386 machine dependent virtual memory parameters.
  79.  *    Most of the declarations are preceeded by I386_ (or i386_)
  80.  *    which is OK because only I386 specific code will be using
  81.  *    them.
  82.  */
  83.  
  84. #ifndef    _MACH_I386_VM_PARAM_H_
  85. #define _MACH_I386_VM_PARAM_H_
  86.  
  87. #define BYTE_SIZE    8    /* byte size in bits */
  88.  
  89. #define I386_PGBYTES    4096    /* bytes per 80386 page */
  90. #define I386_PGSHIFT    12    /* number of bits to shift for pages */
  91.  
  92. /*
  93.  *    Convert bytes to pages and convert pages to bytes.
  94.  *    No rounding is used.
  95.  */
  96.  
  97. #define i386_btop(x)        (((unsigned)(x)) >> I386_PGSHIFT)
  98. #define machine_btop(x)        i386_btop(x)
  99. #define i386_ptob(x)        (((unsigned)(x)) << I386_PGSHIFT)
  100.  
  101. /*
  102.  *    Round off or truncate to the nearest page.  These will work
  103.  *    for either addresses or counts.  (i.e. 1 byte rounds to 1 page
  104.  *    bytes.
  105.  */
  106.  
  107. #define i386_round_page(x)    ((((unsigned)(x)) + I386_PGBYTES - 1) & \
  108.                     ~(I386_PGBYTES-1))
  109. #define i386_trunc_page(x)    (((unsigned)(x)) & ~(I386_PGBYTES-1))
  110.  
  111. #define VM_MIN_ADDRESS        ((vm_offset_t) 0)
  112. #define VM_MAX_ADDRESS        ((vm_offset_t) 0xc0000000U)
  113.  
  114. #define LINEAR_KERNEL_ADDRESS    ((vm_offset_t) 0xc0000000)
  115.  
  116. #define VM_MIN_KERNEL_ADDRESS    ((vm_offset_t) 0x00000000U)
  117. #define VM_MAX_KERNEL_ADDRESS    ((vm_offset_t) 0x3fffffffU)
  118.  
  119. #define VM_MIN_KERNEL_LOADED_ADDRESS    ((vm_offset_t) 0x0c000000U)
  120. #define VM_MAX_KERNEL_LOADED_ADDRESS    ((vm_offset_t) 0x1fffffffU)
  121.  
  122. /* FIXME  - always leave like this? */
  123. #define    INTSTACK_SIZE    (I386_PGBYTES*4)
  124. #define    KERNEL_STACK_SIZE    (I386_PGBYTES*4)
  125.  
  126. #if 0        /* FIXME */
  127.  
  128. #include <norma_vm.h>
  129. #include <task_swapper.h>
  130. #include <thread_swapper.h>
  131.  
  132. #if defined(AT386)
  133. #include <i386/cpuid.h>
  134. #endif
  135.  
  136. #if !NORMA_VM 
  137. #if !TASK_SWAPPER && !THREAD_SWAPPER
  138. #define KERNEL_STACK_SIZE    (I386_PGBYTES/2)
  139. #else
  140. /* stack needs to be a multiple of page size to get unwired  when swapped */
  141. #define KERNEL_STACK_SIZE    (I386_PGBYTES)
  142. #endif    /* TASK || THREAD SWAPPER */
  143. #define INTSTACK_SIZE        (I386_PGBYTES)    /* interrupt stack size */
  144. #else    /* NORMA_VM */
  145. #define KERNEL_STACK_SIZE    (I386_PGBYTES*2)
  146. #define INTSTACK_SIZE        (I386_PGBYTES*2)    /* interrupt stack size */
  147. #endif    /* NORMA_VM */
  148. #endif    /* MACH_KERNEL */
  149.  
  150. /*
  151.  *    Conversion between 80386 pages and VM pages
  152.  */
  153.  
  154. #define trunc_i386_to_vm(p)    (atop(trunc_page(i386_ptob(p))))
  155. #define round_i386_to_vm(p)    (atop(round_page(i386_ptob(p))))
  156. #define vm_to_i386(p)        (i386_btop(ptoa(p)))
  157.  
  158. /*
  159.  *    Physical memory is mapped 1-1 with virtual memory starting
  160.  *    at VM_MIN_KERNEL_ADDRESS.
  161.  */
  162. #define phystokv(a)    ((vm_offset_t)(a) + VM_MIN_KERNEL_ADDRESS)
  163.  
  164. /*
  165.  *    For 386 only, ensure that pages are installed in the
  166.  *    kernel_pmap with VM_PROT_WRITE enabled.  This avoids
  167.  *    code in pmap_enter that disallows a read-only mapping
  168.  *    in the kernel's pmap.  (See ri-osc CR1387.)
  169.  *
  170.  *    An entry in kernel_pmap is made only by the kernel or
  171.  *    a collocated server -- by definition (;-)), the requester
  172.  *    is trusted code.  If it asked for read-only access,
  173.  *    it won't attempt a write.  We don't have to enforce the
  174.  *    restriction.  (Naturally, this assumes that any collocated
  175.  *    server will _not_ depend on trapping write accesses to pages
  176.  *    mapped read-only; this cannot be made to work in the current
  177.  *    i386-inspired pmap model.)
  178.  */
  179.  
  180. /*#if defined(AT386)
  181.  
  182. #define PMAP_ENTER_386_CHECK \
  183.     if (cpuid_family == CPUID_FAMILY_386)
  184.  
  185. #else -- FIXME? We're only running on Pentiums or better */
  186.  
  187. #define PMAP_ENTER_386_CHECK
  188.  
  189. /*#endif*/
  190.  
  191. #define PMAP_ENTER(pmap, virtual_address, page, protection, wired) \
  192.     MACRO_BEGIN                    \
  193.     vm_prot_t __prot__ =                \
  194.         (protection) & ~(page)->page_lock;    \
  195.                             \
  196.         PMAP_ENTER_386_CHECK                \
  197.     if ((pmap) == kernel_pmap)            \
  198.         __prot__ |= VM_PROT_WRITE;        \
  199.     pmap_enter(                    \
  200.         (pmap),                    \
  201.         (virtual_address),            \
  202.         (page)->phys_addr,            \
  203.         __prot__,                \
  204.         (wired)                    \
  205.      );                        \
  206.     MACRO_END
  207.  
  208. #endif    /* _MACH_I386_VM_PARAM_H_ */
  209.