Annotation of XNU/osfmk/mach/i386/vm_param.h, revision 1.1

1.1     ! root        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:  * HISTORY
        !            27:  * 
        !            28:  * Revision 1.2  1998/09/30 21:21:01  wsanchez
        !            29:  * Merged in IntelMerge1 (mburg: Intel support)
        !            30:  *
        !            31:  * Revision 1.1.1.1.6.1  1998/09/30 18:14:00  mburg
        !            32:  * Changes for Intel port
        !            33:  *
        !            34:  * Revision 1.1.1.1  1998/09/22 21:05:31  wsanchez
        !            35:  * Import of Mac OS X kernel (~semeria)
        !            36:  *
        !            37:  * Revision 1.1.1.1  1998/03/07 02:25:47  wsanchez
        !            38:  * Import of OSF Mach kernel (~mburg)
        !            39:  *
        !            40:  * Revision 1.2.45.1  1997/03/27  18:53:17  barbou
        !            41:  *     Replaced reference to cpu_x86_model in PMAP_ENTER_386_CHECK() macro
        !            42:  *     (replaced by cpuid_family).
        !            43:  *     [addis]
        !            44:  *     Remove i386 specific PMAP_ENTER macro.
        !            45:  *     [95/08/29            rwd]
        !            46:  *     [97/02/26            barbou]
        !            47:  *
        !            48:  * Revision 1.2.9.13  1996/07/31  09:57:05  paire
        !            49:  *     Merged with nmk20b7_shared (1.2.39.1)
        !            50:  *     [96/07/24            paire]
        !            51:  * 
        !            52:  * Revision 1.2.39.1  1996/06/13  12:39:45  bernadat
        !            53:  *     Linux drivers support:
        !            54:  *          Arrange so that physical memory is mapped at
        !            55:  *     identical virtual addresses.
        !            56:  *     User segment linear address remains 0
        !            57:  *     kernel segment linear address is now LINEAR_KERNEL_ADDRESS
        !            58:  *     Kernel and user segments linear address now differ.
        !            59:  *     [96/06/04            bernadat]
        !            60:  * 
        !            61:  * Revision 1.2.9.12  1996/02/02  12:19:49  emcmanus
        !            62:  *     Merged with nmk20b5_shared.
        !            63:  *     [1996/02/02  11:57:41  emcmanus]
        !            64:  * 
        !            65:  *     Checked in prior to merge.
        !            66:  *     [1996/02/02  11:40:14  emcmanus]
        !            67:  * 
        !            68:  * Revision 1.2.9.11  1996/01/29  13:15:45  bernadat
        !            69:  *     0xefffffff is much to large for VM_MAX_KERNEL_LOADED_ADDRESS.
        !            70:  *     Page tables overwrite BIOS ! Must find away to dynamically
        !            71:  *     allocate kernel page tables. Set it to 0xdfffffff.
        !            72:  *     [96/01/29            bernadat]
        !            73:  * 
        !            74:  * Revision 1.2.9.10  1996/01/25  12:58:26  bernadat
        !            75:  *     Linux Server Support:
        !            76:  *     increased VM_MAX_KERNEL_LOADED_ADDRESS.
        !            77:  *     [95/12/28            barbou]
        !            78:  * 
        !            79:  * Revision 1.2.34.1  1995/12/30  17:12:54  emcmanus
        !            80:  *     Defined machine_btop here to avoid ugly #ifdefs in drivers.
        !            81:  *     [1995/12/30  17:04:42  emcmanus]
        !            82:  * 
        !            83:  * Revision 1.2.9.9  1995/06/13  18:40:24  bolinger
        !            84:  *     Broader fix for ri-osc CR1387:  for x86 only, change PMAP_ENTER
        !            85:  *     to ensure that VM_PROT_WRITE is always set on calls to change
        !            86:  *     kernel_pmap.
        !            87:  *     [1995/06/12  19:16:51  bolinger]
        !            88:  * 
        !            89:  * Revision 1.2.9.8  1995/05/22  20:26:50  dwm
        !            90:  *     ri-osc CR1340 - turning off TASK_SWAPPER doesn't eliminate
        !            91:  *     thread swapping, so kernel stack size must be congruent with
        !            92:  *     zero mod page_size unless both TASK+THREAD_SWAPPER are off.
        !            93:  *     [1995/05/22  20:26:15  dwm]
        !            94:  * 
        !            95:  * Revision 1.2.9.7  1995/05/14  18:19:59  dwm
        !            96:  *     ri-osc CR1304 - merge (nmk19_latest - nmk19b1) diffs into mainline.
        !            97:  *     fix use of constant in comment, breaks ancient grep script
        !            98:  *     [1995/05/14  17:34:44  dwm]
        !            99:  * 
        !           100:  * Revision 1.2.9.6  1995/04/07  19:05:17  barbou
        !           101:  *     Kernel stack needs to be a multiple of page_size if TASK_SWAPPER is on,
        !           102:  *     or we won't be able to unwire them when swapping out.
        !           103:  *     [95/03/10            barbou]
        !           104:  * 
        !           105:  * Revision 1.2.9.5  1995/03/15  17:19:33  bruel
        !           106:  *     Increased Vm Min Kernel Loaded Address
        !           107:  *     (Corollary kernels are link edited at 0xc4000000)
        !           108:  *     [95/02/27            bernadat]
        !           109:  *     [95/03/06            bruel]
        !           110:  * 
        !           111:  * Revision 1.2.18.1  1995/05/02  21:57:51  travos
        !           112:  *     Use large stacks for XKMACHKERNEL (same as NORMA_VM)
        !           113:  *     [1995/05/02  21:56:52  travos]
        !           114:  * 
        !           115:  * Revision 1.2.9.4  1994/09/23  02:37:53  ezf
        !           116:  *     change marker to not FREE
        !           117:  *     [1994/09/22  21:40:25  ezf]
        !           118:  * 
        !           119:  * Revision 1.2.9.3  1994/08/31  15:55:53  dwm
        !           120:  *     mk6 CR300 - INTSTACK_SIZE needs to be one whole page
        !           121:  *               - bump collo range for larger MP configs
        !           122:  *     [1994/08/31  15:51:37  dwm]
        !           123:  * 
        !           124:  * Revision 1.2.9.2  1994/07/14  20:47:05  bolinger
        !           125:  *     Put use of kernel feature header file under #ifdef MACH_KERNEL.
        !           126:  *     [1994/07/14  20:46:45  bolinger]
        !           127:  * 
        !           128:  * Revision 1.2.9.1  1994/07/14  16:01:49  bolinger
        !           129:  *     If NORMA_VM, make kernel thread and interrupt stack size be 8KB.
        !           130:  *     (NORMA-associated threads seem to need at least 5KB.)
        !           131:  *     [1994/07/14  16:01:01  bolinger]
        !           132:  * 
        !           133:  * Revision 1.2.6.5  1994/02/16  20:27:59  condict
        !           134:  *     Export the range of kernel virtual addresses that are reserved
        !           135:  *     for use by kernel-loaded servers.
        !           136:  *     [1994/02/16  19:42:48  condict]
        !           137:  * 
        !           138:  * Revision 1.2.6.4  1994/02/09  00:40:49  dwm
        !           139:  *     Reduce kernel & interrupt stack size to 1/2 page, in the
        !           140:  *     never-ending quest to reduce wired memory consumption.
        !           141:  *     [1994/02/09  00:34:14  dwm]
        !           142:  * 
        !           143:  * Revision 1.2.6.3  1993/12/10  19:37:00  dwm
        !           144:  *     Re-hack of workaround: KERNEL_STACK_SIZE back to 1 page;
        !           145:  *     lower THREAD_STATE_MAX to 64 ints instead.
        !           146:  *     [1993/12/10  19:36:34  dwm]
        !           147:  * 
        !           148:  * Revision 1.2.6.2  1993/10/26  21:54:01  dwm
        !           149:  *     Coloc: Bump kernel stack size to 2 pages temporarily; mach/exc_user.c
        !           150:  *     builds the exception msg on the stack, mig seemingly ignores -maxonstack,
        !           151:  *     and I don't want to lower THREAD_STATE_MAX and have to rebuild the server
        !           152:  *     and risk breaking some RISC variant for now.  Yuck.
        !           153:  *     (all this in preparation for RPC short-circuiting of exception path).
        !           154:  *     [1993/10/26  20:55:16  dwm]
        !           155:  * 
        !           156:  * Revision 1.2.2.3  1993/07/12  18:07:25  gm
        !           157:  *     CR9339: Added trailing 'U' to VM_*_ADDRESS definitions.
        !           158:  *     [1993/07/12  13:36:47  gm]
        !           159:  * 
        !           160:  * Revision 1.2.2.2  1993/06/09  02:40:56  gm
        !           161:  *     Added to OSF/1 R1.3 from NMK15.0.
        !           162:  *     [1993/06/02  21:16:35  jeffc]
        !           163:  * 
        !           164:  * Revision 1.2  1993/04/19  16:34:29  devrcs
        !           165:  *     ansi C conformance changes
        !           166:  *     [1993/02/02  18:56:25  david]
        !           167:  * 
        !           168:  * Revision 1.1  1992/09/30  02:30:55  robert
        !           169:  *     Initial revision
        !           170:  * 
        !           171:  * $EndLog$
        !           172:  */
        !           173: /* CMU_HIST */
        !           174: /*
        !           175:  * Revision 2.5.2.1  92/03/03  16:21:49  jeffreyh
        !           176:  *     Changes from TRUNK
        !           177:  *     [92/02/26  12:01:03  jeffreyh]
        !           178:  * 
        !           179:  * Revision 2.6  92/01/03  20:20:33  dbg
        !           180:  *     Drop back to 1-page kernel stacks, since emulation_vector calls
        !           181:  *     now pass data out-of-line.
        !           182:  *     [92/01/03            dbg]
        !           183:  * 
        !           184:  * Revision 2.5  91/11/19  08:08:35  rvb
        !           185:  *     NORMA needs a larger stack so we do it for everyone,
        !           186:  *     since stack space usage does not matter anymore.
        !           187:  * 
        !           188:  * Revision 2.4  91/05/14  16:52:50  mrt
        !           189:  *     Correcting copyright
        !           190:  * 
        !           191:  * Revision 2.3  91/02/05  17:32:30  mrt
        !           192:  *     Changed to new Mach copyright
        !           193:  *     [91/02/01  17:10:30  mrt]
        !           194:  * 
        !           195:  * Revision 2.2  90/05/03  15:48:20  dbg
        !           196:  *     Move page-table definitions into i386/pmap.h.
        !           197:  *     [90/04/05            dbg]
        !           198:  * 
        !           199:  *     Remove misleading comment about kernel stack size.
        !           200:  *     [90/02/05            dbg]
        !           201:  * 
        !           202:  * Revision 1.3  89/03/09  20:20:06  rpd
        !           203:  *     More cleanup.
        !           204:  * 
        !           205:  * Revision 1.2  89/02/26  13:01:13  gm0w
        !           206:  *     Changes for cleanup.
        !           207:  * 
        !           208:  * 31-Dec-88  Robert Baron (rvb) at Carnegie-Mellon University
        !           209:  *     Derived from MACH2.0 vax release.
        !           210:  *
        !           211:  * 16-Jan-87  David Golub (dbg) at Carnegie-Mellon University
        !           212:  *     Made vax_ptob return 'unsigned' instead of caddr_t.
        !           213:  *
        !           214:  */
        !           215: /* CMU_ENDHIST */
        !           216: /* 
        !           217:  * Mach Operating System
        !           218:  * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
        !           219:  * All Rights Reserved.
        !           220:  * 
        !           221:  * Permission to use, copy, modify and distribute this software and its
        !           222:  * documentation is hereby granted, provided that both the copyright
        !           223:  * notice and this permission notice appear in all copies of the
        !           224:  * software, derivative works or modified versions, and any portions
        !           225:  * thereof, and that both notices appear in supporting documentation.
        !           226:  * 
        !           227:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
        !           228:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
        !           229:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
        !           230:  * 
        !           231:  * Carnegie Mellon requests users of this software to return to
        !           232:  * 
        !           233:  *  Software Distribution Coordinator  or  [email protected]
        !           234:  *  School of Computer Science
        !           235:  *  Carnegie Mellon University
        !           236:  *  Pittsburgh PA 15213-3890
        !           237:  * 
        !           238:  * any improvements or extensions that they make and grant Carnegie Mellon
        !           239:  * the rights to redistribute these changes.
        !           240:  */
        !           241: 
        !           242: /* 
        !           243:  * Copyright (c) 1994 The University of Utah and
        !           244:  * the Computer Systems Laboratory at the University of Utah (CSL).
        !           245:  * All rights reserved.
        !           246:  *
        !           247:  * Permission to use, copy, modify and distribute this software is hereby
        !           248:  * granted provided that (1) source code retains these copyright, permission,
        !           249:  * and disclaimer notices, and (2) redistributions including binaries
        !           250:  * reproduce the notices in supporting documentation, and (3) all advertising
        !           251:  * materials mentioning features or use of this software display the following
        !           252:  * acknowledgement: ``This product includes software developed by the
        !           253:  * Computer Systems Laboratory at the University of Utah.''
        !           254:  *
        !           255:  * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
        !           256:  * IS" CONDITION.  THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
        !           257:  * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
        !           258:  *
        !           259:  * CSL requests users of this software to return to [email protected] any
        !           260:  * improvements that they make and grant CSL redistribution rights.
        !           261:  *
        !           262:  */
        !           263: 
        !           264: /*
        !           265:  *     File:   vm_param.h
        !           266:  *     Author: Avadis Tevanian, Jr.
        !           267:  *     Date:   1985
        !           268:  *
        !           269:  *     I386 machine dependent virtual memory parameters.
        !           270:  *     Most of the declarations are preceeded by I386_ (or i386_)
        !           271:  *     which is OK because only I386 specific code will be using
        !           272:  *     them.
        !           273:  */
        !           274: 
        !           275: #ifndef        _MACH_I386_VM_PARAM_H_
        !           276: #define _MACH_I386_VM_PARAM_H_
        !           277: 
        !           278: #define BYTE_SIZE      8       /* byte size in bits */
        !           279: 
        !           280: #define I386_PGBYTES   4096    /* bytes per 80386 page */
        !           281: #define I386_PGSHIFT   12      /* number of bits to shift for pages */
        !           282: 
        !           283: /*
        !           284:  *     Convert bytes to pages and convert pages to bytes.
        !           285:  *     No rounding is used.
        !           286:  */
        !           287: 
        !           288: #define i386_btop(x)           (((unsigned)(x)) >> I386_PGSHIFT)
        !           289: #define machine_btop(x)                i386_btop(x)
        !           290: #define i386_ptob(x)           (((unsigned)(x)) << I386_PGSHIFT)
        !           291: 
        !           292: /*
        !           293:  *     Round off or truncate to the nearest page.  These will work
        !           294:  *     for either addresses or counts.  (i.e. 1 byte rounds to 1 page
        !           295:  *     bytes.
        !           296:  */
        !           297: 
        !           298: #define i386_round_page(x)     ((((unsigned)(x)) + I386_PGBYTES - 1) & \
        !           299:                                        ~(I386_PGBYTES-1))
        !           300: #define i386_trunc_page(x)     (((unsigned)(x)) & ~(I386_PGBYTES-1))
        !           301: 
        !           302: #define VM_MIN_ADDRESS         ((vm_offset_t) 0)
        !           303: #define VM_MAX_ADDRESS         ((vm_offset_t) 0xc0000000U)
        !           304: 
        !           305: #define LINEAR_KERNEL_ADDRESS  ((vm_offset_t) 0xc0000000)
        !           306: 
        !           307: #define VM_MIN_KERNEL_ADDRESS  ((vm_offset_t) 0x00000000U)
        !           308: #define VM_MAX_KERNEL_ADDRESS  ((vm_offset_t) 0x3fffffffU)
        !           309: 
        !           310: #define VM_MIN_KERNEL_LOADED_ADDRESS   ((vm_offset_t) 0x0c000000U)
        !           311: #define VM_MAX_KERNEL_LOADED_ADDRESS   ((vm_offset_t) 0x1fffffffU)
        !           312: 
        !           313: /* FIXME  - always leave like this? */
        !           314: #define        INTSTACK_SIZE   (I386_PGBYTES*4)
        !           315: #define        KERNEL_STACK_SIZE       (I386_PGBYTES*4)
        !           316: 
        !           317: #if 0          /* FIXME */
        !           318: 
        !           319: #include <norma_vm.h>
        !           320: #include <xkmachkernel.h>
        !           321: #include <task_swapper.h>
        !           322: #include <thread_swapper.h>
        !           323: 
        !           324: #if defined(AT386)
        !           325: #include <i386/cpuid.h>
        !           326: #endif
        !           327: 
        !           328: #if !NORMA_VM && !XKMACHKERNEL
        !           329: #if !TASK_SWAPPER && !THREAD_SWAPPER
        !           330: #define KERNEL_STACK_SIZE      (I386_PGBYTES/2)
        !           331: #else
        !           332: /* stack needs to be a multiple of page size to get unwired  when swapped */
        !           333: #define KERNEL_STACK_SIZE      (I386_PGBYTES)
        !           334: #endif /* TASK || THREAD SWAPPER */
        !           335: #define INTSTACK_SIZE          (I386_PGBYTES)  /* interrupt stack size */
        !           336: #else  /* NORMA_VM  && !XKMACHKERNEL */
        !           337: #define KERNEL_STACK_SIZE      (I386_PGBYTES*2)
        !           338: #define INTSTACK_SIZE          (I386_PGBYTES*2)        /* interrupt stack size */
        !           339: #endif /* NORMA_VM && !XKMACHKERNEL */
        !           340: #endif /* MACH_KERNEL */
        !           341: 
        !           342: /*
        !           343:  *     Conversion between 80386 pages and VM pages
        !           344:  */
        !           345: 
        !           346: #define trunc_i386_to_vm(p)    (atop(trunc_page(i386_ptob(p))))
        !           347: #define round_i386_to_vm(p)    (atop(round_page(i386_ptob(p))))
        !           348: #define vm_to_i386(p)          (i386_btop(ptoa(p)))
        !           349: 
        !           350: /*
        !           351:  *     Physical memory is mapped 1-1 with virtual memory starting
        !           352:  *     at VM_MIN_KERNEL_ADDRESS.
        !           353:  */
        !           354: #define phystokv(a)    ((vm_offset_t)(a) + VM_MIN_KERNEL_ADDRESS)
        !           355: 
        !           356: /*
        !           357:  *     For 386 only, ensure that pages are installed in the
        !           358:  *     kernel_pmap with VM_PROT_WRITE enabled.  This avoids
        !           359:  *     code in pmap_enter that disallows a read-only mapping
        !           360:  *     in the kernel's pmap.  (See ri-osc CR1387.)
        !           361:  *
        !           362:  *     An entry in kernel_pmap is made only by the kernel or
        !           363:  *     a collocated server -- by definition (;-)), the requester
        !           364:  *     is trusted code.  If it asked for read-only access,
        !           365:  *     it won't attempt a write.  We don't have to enforce the
        !           366:  *     restriction.  (Naturally, this assumes that any collocated
        !           367:  *     server will _not_ depend on trapping write accesses to pages
        !           368:  *     mapped read-only; this cannot be made to work in the current
        !           369:  *     i386-inspired pmap model.)
        !           370:  */
        !           371: 
        !           372: /*#if defined(AT386)
        !           373: 
        !           374: #define PMAP_ENTER_386_CHECK \
        !           375:        if (cpuid_family == CPUID_FAMILY_386)
        !           376: 
        !           377: #else -- FIXME? We're only running on Pentiums or better */
        !           378: 
        !           379: #define PMAP_ENTER_386_CHECK
        !           380: 
        !           381: /*#endif*/
        !           382: 
        !           383: #define PMAP_ENTER(pmap, virtual_address, page, protection, wired) \
        !           384:        MACRO_BEGIN                                     \
        !           385:        vm_prot_t __prot__ =                            \
        !           386:                (protection) & ~(page)->page_lock;      \
        !           387:                                                        \
        !           388:        PMAP_ENTER_386_CHECK                            \
        !           389:        if ((pmap) == kernel_pmap)                      \
        !           390:                __prot__ |= VM_PROT_WRITE;              \
        !           391:        pmap_enter(                                     \
        !           392:                (pmap),                                 \
        !           393:                (virtual_address),                      \
        !           394:                (page)->phys_addr,                      \
        !           395:                __prot__,                               \
        !           396:                (wired)                                 \
        !           397:         );                                             \
        !           398:        MACRO_END
        !           399: 
        !           400: #endif /* _MACH_I386_VM_PARAM_H_ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.