1 /*- 2 * Copyright (c) 1990 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * William Jolitz. 7 * 8 * %sccs.include.redist.c% 9 * 10 * @(#)vmparam.h 5.7 (Berkeley) 04/15/91 11 */ 12 13 14 /* 15 * Machine dependent constants for 386. 16 */ 17 18 /* 19 * Virtual address space arrangement. On 386, both user and kernel 20 * share the address space, not unlike the vax. 21 * USRTEXT is the start of the user text/data space, while USRSTACK 22 * is the top (end) of the user stack. Immediately above the user stack 23 * resides the user structure, which is UPAGES long and contains the 24 * kernel stack. As such, UPAGES is the number of pages from the beginning 25 * of the P1 region to the beginning of the user stack. Also, the P0 26 * region begins with user text and ends with user data. 27 * Immediately after the user structure is the kernal address space. 28 */ 29 #define USRTEXT 0 30 #define USRSTACK 0xFDBFE000 31 #define BTOPUSRSTACK (0xFDC00-(UPAGES)) /* btop(USRSTACK) */ 32 33 #define P1PAGES 0xFDC00 34 #define LOWPAGES 0 35 #define HIGHPAGES UPAGES 36 37 /* 38 * Virtual memory related constants, all in bytes 39 */ 40 #define MAXTSIZ (6*1024*1024) /* max text size */ 41 #ifndef DFLDSIZ 42 #define DFLDSIZ (6*1024*1024) /* initial data size limit */ 43 #endif 44 #ifndef MAXDSIZ 45 #define MAXDSIZ (32*1024*1024) /* max data size */ 46 #endif 47 #ifndef DFLSSIZ 48 #define DFLSSIZ (512*1024) /* initial stack size limit */ 49 #endif 50 #ifndef MAXSSIZ 51 #define MAXSSIZ MAXDSIZ /* max stack size */ 52 #endif 53 54 /* 55 * Default sizes of swap allocation chunks (see dmap.h). 56 * The actual values may be changed in vminit() based on MAXDSIZ. 57 * With MAXDSIZ of 16Mb and NDMAP of 38, dmmax will be 1024. 58 */ 59 #define DMMIN 32 /* smallest swap allocation */ 60 #define DMMAX 4096 /* largest potential swap allocation */ 61 #define DMTEXT 1024 /* swap allocation for text */ 62 63 /* 64 * Sizes of the system and user portions of the system page table. 65 */ 66 #define SYSPTSIZE (2*NPTEPG) 67 #define USRPTSIZE (2*NPTEPG) 68 69 /* 70 * Size of User Raw I/O map 71 */ 72 #define USRIOSIZE 300 73 74 /* 75 * The size of the clock loop. 76 */ 77 #define LOOPPAGES (maxfree - firstfree) 78 79 /* 80 * The time for a process to be blocked before being very swappable. 81 * This is a number of seconds which the system takes as being a non-trivial 82 * amount of real time. You probably shouldn't change this; 83 * it is used in subtle ways (fractions and multiples of it are, that is, like 84 * half of a ``long time'', almost a long time, etc.) 85 * It is related to human patience and other factors which don't really 86 * change over time. 87 */ 88 #define MAXSLP 20 89 90 /* 91 * A swapped in process is given a small amount of core without being bothered 92 * by the page replacement algorithm. Basically this says that if you are 93 * swapped in you deserve some resources. We protect the last SAFERSS 94 * pages against paging and will just swap you out rather than paging you. 95 * Note that each process has at least UPAGES+CLSIZE pages which are not 96 * paged anyways (this is currently 8+2=10 pages or 5k bytes), so this 97 * number just means a swapped in process is given around 25k bytes. 98 * Just for fun: current memory prices are 4600$ a megabyte on VAX (4/22/81), 99 * so we loan each swapped in process memory worth 100$, or just admit 100 * that we don't consider it worthwhile and swap it out to disk which costs 101 * $30/mb or about $0.75. 102 * { wfj 6/16/89: Retail AT memory expansion $800/megabyte, loan of $17 103 * on disk costing $7/mb or $0.18 (in memory still 100:1 in cost!) } 104 */ 105 #define SAFERSS 8 /* nominal ``small'' resident set size 106 protected against replacement */ 107 108 /* 109 * DISKRPM is used to estimate the number of paging i/o operations 110 * which one can expect from a single disk controller. 111 */ 112 #define DISKRPM 60 113 114 /* 115 * Klustering constants. Klustering is the gathering 116 * of pages together for pagein/pageout, while clustering 117 * is the treatment of hardware page size as though it were 118 * larger than it really is. 119 * 120 * KLMAX gives maximum cluster size in CLSIZE page (cluster-page) 121 * units. Note that KLMAX*CLSIZE must be <= DMMIN in dmap.h. 122 */ 123 124 #define KLMAX (4/CLSIZE) 125 #define KLSEQL (2/CLSIZE) /* in klust if vadvise(VA_SEQL) */ 126 #define KLIN (4/CLSIZE) /* default data/stack in klust */ 127 #define KLTXT (4/CLSIZE) /* default text in klust */ 128 #define KLOUT (4/CLSIZE) 129 130 /* 131 * KLSDIST is the advance or retard of the fifo reclaim for sequential 132 * processes data space. 133 */ 134 #define KLSDIST 3 /* klusters advance/retard for seq. fifo */ 135 136 /* 137 * Paging thresholds (see vm_sched.c). 138 * Strategy of 1/19/85: 139 * lotsfree is 512k bytes, but at most 1/4 of memory 140 * desfree is 200k bytes, but at most 1/8 of memory 141 * minfree is 64k bytes, but at most 1/2 of desfree 142 */ 143 #define LOTSFREE (512 * 1024) 144 #define LOTSFREEFRACT 4 145 #define DESFREE (200 * 1024) 146 #define DESFREEFRACT 8 147 #define MINFREE (64 * 1024) 148 #define MINFREEFRACT 2 149 150 /* 151 * There are two clock hands, initially separated by HANDSPREAD bytes 152 * (but at most all of user memory). The amount of time to reclaim 153 * a page once the pageout process examines it increases with this 154 * distance and decreases as the scan rate rises. 155 */ 156 #define HANDSPREAD (2 * 1024 * 1024) 157 158 /* 159 * The number of times per second to recompute the desired paging rate 160 * and poke the pagedaemon. 161 */ 162 #define RATETOSCHEDPAGING 4 163 164 /* 165 * Believed threshold (in megabytes) for which interleaved 166 * swapping area is desirable. 167 */ 168 #define LOTSOFMEM 2 169 170 #define mapin(pte, v, pfnum, prot) \ 171 {(*(int *)(pte) = ((pfnum)<<PGSHIFT) | (prot)) ; } 172 173 /* 174 * Mach derived constants 175 */ 176 177 /* user/kernel map constants */ 178 #define VM_MIN_ADDRESS ((vm_offset_t)0) 179 #define UPT_MIN_ADDRESS ((vm_offset_t)0xFDC00000) 180 #define UPT_MAX_ADDRESS ((vm_offset_t)0xFDFF7000) 181 #define VM_MAX_ADDRESS UPT_MAX_ADDRESS 182 #define VM_MIN_KERNEL_ADDRESS ((vm_offset_t)0xFDFF7000) 183 #define UPDT VM_MIN_KERNEL_ADDRESS 184 #define KPT_MIN_ADDRESS ((vm_offset_t)0xFDFF8000) 185 #define KPT_MAX_ADDRESS ((vm_offset_t)0xFDFFF000) 186 #define VM_MAX_KERNEL_ADDRESS ((vm_offset_t)0xFF7FF000) 187 188 /* virtual sizes (bytes) for various kernel submaps */ 189 #define VM_MBUF_SIZE (NMBCLUSTERS*MCLBYTES) 190 #define VM_KMEM_SIZE (NKMEMCLUSTERS*CLBYTES) 191 #define VM_PHYS_SIZE (USRIOSIZE*CLBYTES) 192 193 /* # of kernel PT pages (initial only, can grow dynamically) */ 194 #define VM_KERNEL_PT_PAGES ((vm_size_t)2) /* XXX: SYSPTSIZE */ 195 196 /* pcb base */ 197 #define pcbb(p) ((u_int)(p)->p_addr) 198 199 /* 200 * Flush MMU TLB 201 */ 202 203 #ifndef I386_CR3PAT 204 #define I386_CR3PAT 0x0 205 #endif 206 207 #ifdef notyet 208 #define _cr3() ({u_long rtn; \ 209 asm (" movl %%cr3,%%eax; movl %%eax,%0 " \ 210 : "=g" (rtn) \ 211 : \ 212 : "ax"); \ 213 rtn; \ 214 }) 215 216 #define load_cr3(s) ({ u_long val; \ 217 val = (s) | I386_CR3PAT; \ 218 asm ("movl %0,%%eax; movl %%eax,%%cr3" \ 219 : \ 220 : "g" (val) \ 221 : "ax"); \ 222 }) 223 224 #define tlbflush() ({ u_long val; \ 225 val = u.u_pcb.pcb_ptd | I386_CR3PAT; \ 226 asm ("movl %0,%%eax; movl %%eax,%%cr3" \ 227 : \ 228 : "g" (val) \ 229 : "ax"); \ 230 }) 231 #endif 232