15b81b6b3SRodney W. Grimes /*- 25b81b6b3SRodney W. Grimes * Copyright (c) 1990 The Regents of the University of California. 35b81b6b3SRodney W. Grimes * All rights reserved. 47f8cb368SDavid Greenman * Copyright (c) 1994 John S. Dyson 57f8cb368SDavid Greenman * All rights reserved. 65b81b6b3SRodney W. Grimes * 75b81b6b3SRodney W. Grimes * This code is derived from software contributed to Berkeley by 85b81b6b3SRodney W. Grimes * William Jolitz. 95b81b6b3SRodney W. Grimes * 105b81b6b3SRodney W. Grimes * Redistribution and use in source and binary forms, with or without 115b81b6b3SRodney W. Grimes * modification, are permitted provided that the following conditions 125b81b6b3SRodney W. Grimes * are met: 135b81b6b3SRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 145b81b6b3SRodney W. Grimes * notice, this list of conditions and the following disclaimer. 155b81b6b3SRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 165b81b6b3SRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 175b81b6b3SRodney W. Grimes * documentation and/or other materials provided with the distribution. 185b81b6b3SRodney W. Grimes * 3. All advertising materials mentioning features or use of this software 195b81b6b3SRodney W. Grimes * must display the following acknowledgement: 205b81b6b3SRodney W. Grimes * This product includes software developed by the University of 215b81b6b3SRodney W. Grimes * California, Berkeley and its contributors. 225b81b6b3SRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 235b81b6b3SRodney W. Grimes * may be used to endorse or promote products derived from this software 245b81b6b3SRodney W. Grimes * without specific prior written permission. 255b81b6b3SRodney W. Grimes * 265b81b6b3SRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 275b81b6b3SRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 285b81b6b3SRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 295b81b6b3SRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 305b81b6b3SRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 315b81b6b3SRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 325b81b6b3SRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 335b81b6b3SRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 345b81b6b3SRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 355b81b6b3SRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 365b81b6b3SRodney W. Grimes * SUCH DAMAGE. 375b81b6b3SRodney W. Grimes * 38d42d25c4SRodney W. Grimes * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91 3929360eb0SDavid Greenman * $Id: vmparam.h,v 1.11 1994/01/14 16:24:00 davidg Exp $ 405b81b6b3SRodney W. Grimes */ 415b81b6b3SRodney W. Grimes 425b81b6b3SRodney W. Grimes 436e393973SGarrett Wollman #ifndef _MACHINE_VMPARAM_H_ 446e393973SGarrett Wollman #define _MACHINE_VMPARAM_H_ 1 456e393973SGarrett Wollman 465b81b6b3SRodney W. Grimes /* 475b81b6b3SRodney W. Grimes * Machine dependent constants for 386. 485b81b6b3SRodney W. Grimes */ 495b81b6b3SRodney W. Grimes 505b81b6b3SRodney W. Grimes /* 515b81b6b3SRodney W. Grimes * Virtual address space arrangement. On 386, both user and kernel 525b81b6b3SRodney W. Grimes * share the address space, not unlike the vax. 535b81b6b3SRodney W. Grimes * USRTEXT is the start of the user text/data space, while USRSTACK 545b81b6b3SRodney W. Grimes * is the top (end) of the user stack. Immediately above the user stack 555b81b6b3SRodney W. Grimes * resides the user structure, which is UPAGES long and contains the 565b81b6b3SRodney W. Grimes * kernel stack. 575b81b6b3SRodney W. Grimes * 585b81b6b3SRodney W. Grimes * Immediately after the user structure is the page table map, and then 595b81b6b3SRodney W. Grimes * kernal address space. 605b81b6b3SRodney W. Grimes */ 61aaf08d94SGarrett Wollman #define USRTEXT 0UL 627f8cb368SDavid Greenman /* #define USRSTACK 0xFDBFE000UL */ 635b81b6b3SRodney W. Grimes #define BTOPUSRSTACK (0xFDC00-(UPAGES)) /* btop(USRSTACK) */ 64aaf08d94SGarrett Wollman #define LOWPAGES 0UL 655b81b6b3SRodney W. Grimes #define HIGHPAGES UPAGES 665b81b6b3SRodney W. Grimes 675b81b6b3SRodney W. Grimes /* 685b81b6b3SRodney W. Grimes * Virtual memory related constants, all in bytes 695b81b6b3SRodney W. Grimes */ 70e10a6186SDavid Greenman #define MAXTSIZ (16UL*1024*1024) /* max text size */ 715b81b6b3SRodney W. Grimes #ifndef DFLDSIZ 72e10a6186SDavid Greenman #define DFLDSIZ (64UL*1024*1024) /* initial data size limit */ 735b81b6b3SRodney W. Grimes #endif 745b81b6b3SRodney W. Grimes #ifndef MAXDSIZ 75e10a6186SDavid Greenman #define MAXDSIZ (128UL*1024*1024) /* max data size */ 765b81b6b3SRodney W. Grimes #endif 775b81b6b3SRodney W. Grimes #ifndef DFLSSIZ 7829360eb0SDavid Greenman #define DFLSSIZ (8UL*1024*1024) /* initial stack size limit */ 795b81b6b3SRodney W. Grimes #endif 805b81b6b3SRodney W. Grimes #ifndef MAXSSIZ 81e10a6186SDavid Greenman #define MAXSSIZ (64UL*1024*1024) /* max stack size */ 825b81b6b3SRodney W. Grimes #endif 8329360eb0SDavid Greenman #ifndef SGROWSIZ 8429360eb0SDavid Greenman #define SGROWSIZ (128UL*1024) /* amount to grow stack */ 8529360eb0SDavid Greenman #endif 865b81b6b3SRodney W. Grimes 875b81b6b3SRodney W. Grimes /* 885b81b6b3SRodney W. Grimes * Default sizes of swap allocation chunks (see dmap.h). 895b81b6b3SRodney W. Grimes * The actual values may be changed in vminit() based on MAXDSIZ. 905b81b6b3SRodney W. Grimes * With MAXDSIZ of 16Mb and NDMAP of 38, dmmax will be 1024. 915b81b6b3SRodney W. Grimes */ 925b81b6b3SRodney W. Grimes #define DMMIN 32 /* smallest swap allocation */ 935b81b6b3SRodney W. Grimes #define DMMAX 4096 /* largest potential swap allocation */ 945b81b6b3SRodney W. Grimes #define DMTEXT 1024 /* swap allocation for text */ 955b81b6b3SRodney W. Grimes 965b81b6b3SRodney W. Grimes /* 975b81b6b3SRodney W. Grimes * Sizes of the system and user portions of the system page table. 985b81b6b3SRodney W. Grimes */ 995b81b6b3SRodney W. Grimes #define SYSPTSIZE (2*NPTEPG) 1005b81b6b3SRodney W. Grimes #define USRPTSIZE (2*NPTEPG) 1015b81b6b3SRodney W. Grimes 1025b81b6b3SRodney W. Grimes /* 103b6c78fe4SRodney W. Grimes * Size of the Shared Memory Pages page table. 104b6c78fe4SRodney W. Grimes */ 10589ccb410SDavid Greenman #ifndef SHMMAXPGS 106d42d25c4SRodney W. Grimes #define SHMMAXPGS 512 /* XXX until we have more kmap space */ 107b6c78fe4SRodney W. Grimes #endif 108b6c78fe4SRodney W. Grimes 109b6c78fe4SRodney W. Grimes /* 1105b81b6b3SRodney W. Grimes * Size of User Raw I/O map 1115b81b6b3SRodney W. Grimes */ 1127f8cb368SDavid Greenman #define USRIOSIZE 1024 1135b81b6b3SRodney W. Grimes 1145b81b6b3SRodney W. Grimes /* 1155b81b6b3SRodney W. Grimes * The size of the clock loop. 1165b81b6b3SRodney W. Grimes */ 1175b81b6b3SRodney W. Grimes #define LOOPPAGES (maxfree - firstfree) 1185b81b6b3SRodney W. Grimes 1195b81b6b3SRodney W. Grimes /* 1205b81b6b3SRodney W. Grimes * The time for a process to be blocked before being very swappable. 1215b81b6b3SRodney W. Grimes * This is a number of seconds which the system takes as being a non-trivial 1225b81b6b3SRodney W. Grimes * amount of real time. You probably shouldn't change this; 1235b81b6b3SRodney W. Grimes * it is used in subtle ways (fractions and multiples of it are, that is, like 1245b81b6b3SRodney W. Grimes * half of a ``long time'', almost a long time, etc.) 1255b81b6b3SRodney W. Grimes * It is related to human patience and other factors which don't really 1265b81b6b3SRodney W. Grimes * change over time. 1275b81b6b3SRodney W. Grimes */ 1285b81b6b3SRodney W. Grimes #define MAXSLP 20 1295b81b6b3SRodney W. Grimes 1305b81b6b3SRodney W. Grimes /* 1315b81b6b3SRodney W. Grimes * A swapped in process is given a small amount of core without being bothered 1325b81b6b3SRodney W. Grimes * by the page replacement algorithm. Basically this says that if you are 1335b81b6b3SRodney W. Grimes * swapped in you deserve some resources. We protect the last SAFERSS 1345b81b6b3SRodney W. Grimes * pages against paging and will just swap you out rather than paging you. 1355b81b6b3SRodney W. Grimes * Note that each process has at least UPAGES+CLSIZE pages which are not 1365b81b6b3SRodney W. Grimes * paged anyways (this is currently 8+2=10 pages or 5k bytes), so this 1375b81b6b3SRodney W. Grimes * number just means a swapped in process is given around 25k bytes. 1385b81b6b3SRodney W. Grimes * Just for fun: current memory prices are 4600$ a megabyte on VAX (4/22/81), 1395b81b6b3SRodney W. Grimes * so we loan each swapped in process memory worth 100$, or just admit 1405b81b6b3SRodney W. Grimes * that we don't consider it worthwhile and swap it out to disk which costs 1415b81b6b3SRodney W. Grimes * $30/mb or about $0.75. 1425b81b6b3SRodney W. Grimes * { wfj 6/16/89: Retail AT memory expansion $800/megabyte, loan of $17 1435b81b6b3SRodney W. Grimes * on disk costing $7/mb or $0.18 (in memory still 100:1 in cost!) } 1445b81b6b3SRodney W. Grimes */ 1455b81b6b3SRodney W. Grimes #define SAFERSS 8 /* nominal ``small'' resident set size 1465b81b6b3SRodney W. Grimes protected against replacement */ 1475b81b6b3SRodney W. Grimes 1485b81b6b3SRodney W. Grimes /* 1495b81b6b3SRodney W. Grimes * DISKRPM is used to estimate the number of paging i/o operations 1505b81b6b3SRodney W. Grimes * which one can expect from a single disk controller. 1515b81b6b3SRodney W. Grimes */ 1525b81b6b3SRodney W. Grimes #define DISKRPM 60 1535b81b6b3SRodney W. Grimes 1545b81b6b3SRodney W. Grimes /* 1555b81b6b3SRodney W. Grimes * Klustering constants. Klustering is the gathering 1565b81b6b3SRodney W. Grimes * of pages together for pagein/pageout, while clustering 1575b81b6b3SRodney W. Grimes * is the treatment of hardware page size as though it were 1585b81b6b3SRodney W. Grimes * larger than it really is. 1595b81b6b3SRodney W. Grimes * 1605b81b6b3SRodney W. Grimes * KLMAX gives maximum cluster size in CLSIZE page (cluster-page) 1615b81b6b3SRodney W. Grimes * units. Note that KLMAX*CLSIZE must be <= DMMIN in dmap.h. 1625b81b6b3SRodney W. Grimes */ 1635b81b6b3SRodney W. Grimes 1645b81b6b3SRodney W. Grimes #define KLMAX (4/CLSIZE) 1655b81b6b3SRodney W. Grimes #define KLSEQL (2/CLSIZE) /* in klust if vadvise(VA_SEQL) */ 1665b81b6b3SRodney W. Grimes #define KLIN (4/CLSIZE) /* default data/stack in klust */ 1675b81b6b3SRodney W. Grimes #define KLTXT (4/CLSIZE) /* default text in klust */ 1685b81b6b3SRodney W. Grimes #define KLOUT (4/CLSIZE) 1695b81b6b3SRodney W. Grimes 1705b81b6b3SRodney W. Grimes /* 1715b81b6b3SRodney W. Grimes * KLSDIST is the advance or retard of the fifo reclaim for sequential 1725b81b6b3SRodney W. Grimes * processes data space. 1735b81b6b3SRodney W. Grimes */ 1745b81b6b3SRodney W. Grimes #define KLSDIST 3 /* klusters advance/retard for seq. fifo */ 1755b81b6b3SRodney W. Grimes 1765b81b6b3SRodney W. Grimes /* 1775b81b6b3SRodney W. Grimes * Paging thresholds (see vm_sched.c). 1785b81b6b3SRodney W. Grimes * Strategy of 1/19/85: 1795b81b6b3SRodney W. Grimes * lotsfree is 512k bytes, but at most 1/4 of memory 1805b81b6b3SRodney W. Grimes * desfree is 200k bytes, but at most 1/8 of memory 1815b81b6b3SRodney W. Grimes * minfree is 64k bytes, but at most 1/2 of desfree 1825b81b6b3SRodney W. Grimes */ 1835b81b6b3SRodney W. Grimes #define LOTSFREE (512 * 1024) 1845b81b6b3SRodney W. Grimes #define LOTSFREEFRACT 4 1855b81b6b3SRodney W. Grimes #define DESFREE (200 * 1024) 1865b81b6b3SRodney W. Grimes #define DESFREEFRACT 8 1875b81b6b3SRodney W. Grimes #define MINFREE (64 * 1024) 1885b81b6b3SRodney W. Grimes #define MINFREEFRACT 2 1895b81b6b3SRodney W. Grimes 1905b81b6b3SRodney W. Grimes /* 1915b81b6b3SRodney W. Grimes * There are two clock hands, initially separated by HANDSPREAD bytes 1925b81b6b3SRodney W. Grimes * (but at most all of user memory). The amount of time to reclaim 1935b81b6b3SRodney W. Grimes * a page once the pageout process examines it increases with this 1945b81b6b3SRodney W. Grimes * distance and decreases as the scan rate rises. 1955b81b6b3SRodney W. Grimes */ 1965b81b6b3SRodney W. Grimes #define HANDSPREAD (2 * 1024 * 1024) 1975b81b6b3SRodney W. Grimes 1985b81b6b3SRodney W. Grimes /* 1995b81b6b3SRodney W. Grimes * The number of times per second to recompute the desired paging rate 2005b81b6b3SRodney W. Grimes * and poke the pagedaemon. 2015b81b6b3SRodney W. Grimes */ 2025b81b6b3SRodney W. Grimes #define RATETOSCHEDPAGING 4 2035b81b6b3SRodney W. Grimes 2045b81b6b3SRodney W. Grimes /* 2055b81b6b3SRodney W. Grimes * Believed threshold (in megabytes) for which interleaved 2065b81b6b3SRodney W. Grimes * swapping area is desirable. 2075b81b6b3SRodney W. Grimes */ 2085b81b6b3SRodney W. Grimes #define LOTSOFMEM 2 2095b81b6b3SRodney W. Grimes 2105b81b6b3SRodney W. Grimes #define mapin(pte, v, pfnum, prot) \ 2115b81b6b3SRodney W. Grimes {(*(int *)(pte) = ((pfnum)<<PGSHIFT) | (prot)) ; } 2125b81b6b3SRodney W. Grimes 2135b81b6b3SRodney W. Grimes /* 2145b81b6b3SRodney W. Grimes * Mach derived constants 2155b81b6b3SRodney W. Grimes */ 2165b81b6b3SRodney W. Grimes 2175b81b6b3SRodney W. Grimes /* user/kernel map constants */ 2187f8cb368SDavid Greenman #define KERNBASE (0-(NKPDE+1)*(NBPG*NPTEPG)) 2197f8cb368SDavid Greenman #define KERNSIZE (NKPDE*NBPG*NPTEPG) 2207f8cb368SDavid Greenman 2215b81b6b3SRodney W. Grimes #define VM_MIN_ADDRESS ((vm_offset_t)0) 2227f8cb368SDavid Greenman #define VM_MAXUSER_ADDRESS ((vm_offset_t)KERNBASE - (NBPG*(NPTEPG+UPAGES))) 2237f8cb368SDavid Greenman #define USRSTACK VM_MAXUSER_ADDRESS 2247f8cb368SDavid Greenman #define UPT_MIN_ADDRESS ((vm_offset_t)KERNBASE - (NBPG*NPTEPG)) 2257f8cb368SDavid Greenman #define UPT_MAX_ADDRESS ((vm_offset_t)KERNBASE - (NBPG*(NKPDE+2))) 2265b81b6b3SRodney W. Grimes #define VM_MAX_ADDRESS UPT_MAX_ADDRESS 2277f8cb368SDavid Greenman #define VM_MIN_KERNEL_ADDRESS ((vm_offset_t)KERNBASE - (NBPG*(NKPDE+2))) 2285b81b6b3SRodney W. Grimes #define UPDT VM_MIN_KERNEL_ADDRESS 2297f8cb368SDavid Greenman #define KPT_MIN_ADDRESS ((vm_offset_t)(KERNBASE) - (NBPG*(NKPDE+1))) 2307f8cb368SDavid Greenman #define KPT_MAX_ADDRESS ((vm_offset_t)(KERNBASE) - NBPG) 2317f8cb368SDavid Greenman #define VM_MAX_KERNEL_ADDRESS ((vm_offset_t)ALT_MIN_ADDRESS - NBPG) 2327f8cb368SDavid Greenman #define ALT_MIN_ADDRESS ((vm_offset_t)((APTDPTDI) << 22)) 2337f8cb368SDavid Greenman #define HIGHPAGES UPAGES 2347f8cb368SDavid Greenman 2355b81b6b3SRodney W. Grimes 2365b81b6b3SRodney W. Grimes /* virtual sizes (bytes) for various kernel submaps */ 2375b81b6b3SRodney W. Grimes #define VM_MBUF_SIZE (NMBCLUSTERS*MCLBYTES) 238d42d25c4SRodney W. Grimes #define VM_KMEM_SIZE (16 * 1024 * 1024) 2395b81b6b3SRodney W. Grimes #define VM_PHYS_SIZE (USRIOSIZE*CLBYTES) 2405b81b6b3SRodney W. Grimes 2415b81b6b3SRodney W. Grimes /* pcb base */ 2425b81b6b3SRodney W. Grimes #define pcbb(p) ((u_int)(p)->p_addr) 2435b81b6b3SRodney W. Grimes 2445b81b6b3SRodney W. Grimes /* 2455b81b6b3SRodney W. Grimes * Flush MMU TLB 2465b81b6b3SRodney W. Grimes */ 2475b81b6b3SRodney W. Grimes 2485b81b6b3SRodney W. Grimes #ifndef I386_CR3PAT 2495b81b6b3SRodney W. Grimes #define I386_CR3PAT 0x0 2505b81b6b3SRodney W. Grimes #endif 2515b81b6b3SRodney W. Grimes 2525b81b6b3SRodney W. Grimes #ifdef notyet 2535b81b6b3SRodney W. Grimes #define _cr3() ({u_long rtn; \ 2545b81b6b3SRodney W. Grimes asm (" movl %%cr3,%%eax; movl %%eax,%0 " \ 2555b81b6b3SRodney W. Grimes : "=g" (rtn) \ 2565b81b6b3SRodney W. Grimes : \ 2575b81b6b3SRodney W. Grimes : "ax"); \ 2585b81b6b3SRodney W. Grimes rtn; \ 2595b81b6b3SRodney W. Grimes }) 2605b81b6b3SRodney W. Grimes 2615b81b6b3SRodney W. Grimes #define load_cr3(s) ({ u_long val; \ 2625b81b6b3SRodney W. Grimes val = (s) | I386_CR3PAT; \ 2635b81b6b3SRodney W. Grimes asm ("movl %0,%%eax; movl %%eax,%%cr3" \ 2645b81b6b3SRodney W. Grimes : \ 2655b81b6b3SRodney W. Grimes : "g" (val) \ 2665b81b6b3SRodney W. Grimes : "ax"); \ 2675b81b6b3SRodney W. Grimes }) 2685b81b6b3SRodney W. Grimes 2695b81b6b3SRodney W. Grimes #define tlbflush() ({ u_long val; \ 2705b81b6b3SRodney W. Grimes val = u.u_pcb.pcb_ptd | I386_CR3PAT; \ 2715b81b6b3SRodney W. Grimes asm ("movl %0,%%eax; movl %%eax,%%cr3" \ 2725b81b6b3SRodney W. Grimes : \ 2735b81b6b3SRodney W. Grimes : "g" (val) \ 2745b81b6b3SRodney W. Grimes : "ax"); \ 2755b81b6b3SRodney W. Grimes }) 2765b81b6b3SRodney W. Grimes #endif 2776e393973SGarrett Wollman #endif /* _MACHINE_VMPARAM_H_ */ 278