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