pmap.c (943a66f3408781554857303901e3021d5fce75ac) | pmap.c (6b4ac811ca8134f128cef476e2703bf9b5373016) |
---|---|
1/* 2 * Copyright (c) 1991 Regents of the University of California. 3 * All rights reserved. 4 * Copyright (c) 1994 John S. Dyson 5 * All rights reserved. 6 * Copyright (c) 1994 David Greenman 7 * All rights reserved. 8 * --- 25 unchanged lines hidden (view full) --- 34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 39 * SUCH DAMAGE. 40 * 41 * from: @(#)pmap.c 7.7 (Berkeley) 5/12/91 | 1/* 2 * Copyright (c) 1991 Regents of the University of California. 3 * All rights reserved. 4 * Copyright (c) 1994 John S. Dyson 5 * All rights reserved. 6 * Copyright (c) 1994 David Greenman 7 * All rights reserved. 8 * --- 25 unchanged lines hidden (view full) --- 34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 39 * SUCH DAMAGE. 40 * 41 * from: @(#)pmap.c 7.7 (Berkeley) 5/12/91 |
42 * $Id: pmap.c,v 1.20 1994/03/07 11:38:34 davidg Exp $ | 42 * $Id: pmap.c,v 1.21 1994/03/14 21:54:01 davidg Exp $ |
43 */ 44 45/* 46 * Derived from hp300 version by Mike Hibler, this version by William 47 * Jolitz uses a recursive map [a pde points to the page directory] to 48 * map the page tables using the pagetables themselves. This is done to 49 * reduce the impact on kernel virtual memory for lots of sparse address 50 * space, and to reduce the cost of memory to each process. --- 495 unchanged lines hidden (view full) --- 546 */ 547 pmap->pm_pdir = (pd_entry_t *) vm_get_pmap(); 548 549 /* wire in kernel global address entries */ 550 bcopy(PTD+KPTDI, pmap->pm_pdir+KPTDI, NKPT*PTESIZE); 551 552 /* install self-referential address mapping entry */ 553 *(int *)(pmap->pm_pdir+PTDPTDI) = | 43 */ 44 45/* 46 * Derived from hp300 version by Mike Hibler, this version by William 47 * Jolitz uses a recursive map [a pde points to the page directory] to 48 * map the page tables using the pagetables themselves. This is done to 49 * reduce the impact on kernel virtual memory for lots of sparse address 50 * space, and to reduce the cost of memory to each process. --- 495 unchanged lines hidden (view full) --- 546 */ 547 pmap->pm_pdir = (pd_entry_t *) vm_get_pmap(); 548 549 /* wire in kernel global address entries */ 550 bcopy(PTD+KPTDI, pmap->pm_pdir+KPTDI, NKPT*PTESIZE); 551 552 /* install self-referential address mapping entry */ 553 *(int *)(pmap->pm_pdir+PTDPTDI) = |
554 ((int)pmap_extract(kernel_pmap, (vm_offset_t)pmap->pm_pdir)) | PG_V | PG_KW; | 554 ((int)pmap_kextract((vm_offset_t)pmap->pm_pdir)) | PG_V | PG_KW; |
555 556 pmap->pm_count = 1; 557 simple_lock_init(&pmap->pm_lock); 558} 559 560/* 561 * Retire the given physical map from service. 562 * Should only be called if the map contains --- 727 unchanged lines hidden (view full) --- 1290 */ 1291 if ((int) npte != (int) *pte) { 1292 *pte = npte; 1293 tlbflush(); 1294 } 1295} 1296 1297/* | 555 556 pmap->pm_count = 1; 557 simple_lock_init(&pmap->pm_lock); 558} 559 560/* 561 * Retire the given physical map from service. 562 * Should only be called if the map contains --- 727 unchanged lines hidden (view full) --- 1290 */ 1291 if ((int) npte != (int) *pte) { 1292 *pte = npte; 1293 tlbflush(); 1294 } 1295} 1296 1297/* |
1298 * add a wired page to the kva 1299 */ 1300void 1301pmap_kenter(va, pa) 1302 vm_offset_t va; 1303 register vm_offset_t pa; 1304{ 1305 register pt_entry_t *pte; 1306 register pv_entry_t pv, npv; 1307 vm_offset_t opa; 1308 int s; 1309 1310 /* 1311 * Enter on the PV list if part of our managed memory 1312 * Note that we raise IPL while manipulating pv_table 1313 * since pmap_enter can be called at interrupt time. 1314 */ 1315 1316 pte = vtopte(va); 1317 1318 opa = pmap_pte_pa(pte); 1319 /* 1320 * Mapping has not changed, must be protection or wiring change. 1321 */ 1322 if (opa == pa) { 1323 /* 1324 * Wiring change, just update stats. 1325 * We don't worry about wiring PT pages as they remain 1326 * resident as long as there are valid mappings in them. 1327 * Hence, if a user page is wired, the PT page will be also. 1328 */ 1329 if (!pmap_pte_w(pte)) { 1330 kernel_pmap->pm_stats.wired_count++; 1331 } 1332 goto validate; 1333 } 1334 1335 if (opa) { 1336 pmap_remove(kernel_pmap, va, va + PAGE_SIZE); 1337 } 1338 1339 pv = pa_to_pvh(pa); 1340 s = splimp(); 1341 /* 1342 * No entries yet, use header as the first entry 1343 */ 1344 if (pv->pv_pmap == NULL) { 1345 pv->pv_va = va; 1346 pv->pv_pmap = kernel_pmap; 1347 pv->pv_next = NULL; 1348 } 1349 /* 1350 * There is at least one other VA mapping this page. 1351 * Place this entry after the header. 1352 */ 1353 else { 1354 npv = get_pv_entry(); 1355 npv->pv_va = va; 1356 npv->pv_pmap = kernel_pmap; 1357 npv->pv_next = pv->pv_next; 1358 pv->pv_next = npv; 1359 } 1360 splx(s); 1361 1362 /* 1363 * Increment counters 1364 */ 1365 kernel_pmap->pm_stats.resident_count++; 1366 1367validate: 1368 1369 /* 1370 * Now validate mapping with desired protection/wiring. 1371 */ 1372 *pte = (pt_entry_t) ( (int) (pa | PG_RW | PG_V | PG_W)); 1373} 1374 1375/* |
|
1298 * this code makes some *MAJOR* assumptions: 1299 * 1. Current pmap & pmap exists. 1300 * 2. Not wired. 1301 * 3. Read access. 1302 * 4. No page table pages. 1303 * 5. Tlbflush is deferred to calling procedure. 1304 * 6. Page IS managed. 1305 * but is *MUCH* faster than pmap_enter... --- 581 unchanged lines hidden --- | 1376 * this code makes some *MAJOR* assumptions: 1377 * 1. Current pmap & pmap exists. 1378 * 2. Not wired. 1379 * 3. Read access. 1380 * 4. No page table pages. 1381 * 5. Tlbflush is deferred to calling procedure. 1382 * 6. Page IS managed. 1383 * but is *MUCH* faster than pmap_enter... --- 581 unchanged lines hidden --- |