pmap.c (10a1aa05e85fa6f5d8073fa636ba5a2ecce88e1c) | pmap.c (9a3b3e8bce8e8c8bbec663229e16bebb3cfc5d53) |
---|---|
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.158 1997/08/07 05:15:48 dyson Exp $ | 42 * $Id: pmap.c,v 1.159 1997/08/25 21:53:01 bde Exp $ |
43 */ 44 45/* 46 * Manages physical address maps. 47 * 48 * In addition to hardware address maps, this 49 * module is called upon to provide software-use-only 50 * maps which may or may not be stored in the same --- 127 unchanged lines hidden (view full) --- 178pt_entry_t *CMAP1 = 0; 179static pt_entry_t *CMAP2, *ptmmap; 180static pv_table_t *pv_table; 181caddr_t CADDR1 = 0, ptvmmap = 0; 182static caddr_t CADDR2; 183static pt_entry_t *msgbufmap; 184struct msgbuf *msgbufp=0; 185 | 43 */ 44 45/* 46 * Manages physical address maps. 47 * 48 * In addition to hardware address maps, this 49 * module is called upon to provide software-use-only 50 * maps which may or may not be stored in the same --- 127 unchanged lines hidden (view full) --- 178pt_entry_t *CMAP1 = 0; 179static pt_entry_t *CMAP2, *ptmmap; 180static pv_table_t *pv_table; 181caddr_t CADDR1 = 0, ptvmmap = 0; 182static caddr_t CADDR2; 183static pt_entry_t *msgbufmap; 184struct msgbuf *msgbufp=0; 185 |
186#ifdef SMP 187extern char prv_CPAGE1[], prv_CPAGE2[], prv_CPAGE3[]; 188extern pt_entry_t *prv_CMAP1, *prv_CMAP2, *prv_CMAP3; 189extern pd_entry_t *IdlePTDS[]; 190extern pt_entry_t SMP_prvpt[]; 191#endif 192 |
|
186pt_entry_t *PMAP1 = 0; 187unsigned *PADDR1 = 0; 188 189static PMAP_INLINE void free_pv_entry __P((pv_entry_t pv)); 190static unsigned * get_ptbase __P((pmap_t pmap)); 191static pv_entry_t get_pv_entry __P((void)); 192static void i386_protection_init __P((void)); 193static void pmap_changebit __P((vm_offset_t pa, int bit, boolean_t setem)); --- 209 unchanged lines hidden (view full) --- 403#ifdef SMP 404 if (cpu_apic_address == 0) 405 panic("pmap_bootstrap: no local apic!"); 406 407 /* 0 = private page */ 408 /* 1 = page table page */ 409 /* 2 = local apic */ 410 /* 16-31 = io apics */ | 193pt_entry_t *PMAP1 = 0; 194unsigned *PADDR1 = 0; 195 196static PMAP_INLINE void free_pv_entry __P((pv_entry_t pv)); 197static unsigned * get_ptbase __P((pmap_t pmap)); 198static pv_entry_t get_pv_entry __P((void)); 199static void i386_protection_init __P((void)); 200static void pmap_changebit __P((vm_offset_t pa, int bit, boolean_t setem)); --- 209 unchanged lines hidden (view full) --- 410#ifdef SMP 411 if (cpu_apic_address == 0) 412 panic("pmap_bootstrap: no local apic!"); 413 414 /* 0 = private page */ 415 /* 1 = page table page */ 416 /* 2 = local apic */ 417 /* 16-31 = io apics */ |
411 SMP_prvpt[2] = PG_V | PG_RW | pgeflag | ((u_long)cpu_apic_address & PG_FRAME); | 418 SMP_prvpt[2] = (pt_entry_t)(PG_V | PG_RW | pgeflag | ((u_long)cpu_apic_address & PG_FRAME)); |
412 413 for (i = 0; i < mp_napics; i++) { 414 for (j = 0; j < 16; j++) { 415 /* same page frame as a previous IO apic? */ 416 if (((u_long)SMP_prvpt[j + 16] & PG_FRAME) == 417 ((u_long)io_apic_address[0] & PG_FRAME)) { 418 ioapic[i] = (ioapic_t *)&SMP_ioapic[j * PAGE_SIZE]; 419 break; 420 } 421 /* use this slot if available */ 422 if (((u_long)SMP_prvpt[j + 16] & PG_FRAME) == 0) { | 419 420 for (i = 0; i < mp_napics; i++) { 421 for (j = 0; j < 16; j++) { 422 /* same page frame as a previous IO apic? */ 423 if (((u_long)SMP_prvpt[j + 16] & PG_FRAME) == 424 ((u_long)io_apic_address[0] & PG_FRAME)) { 425 ioapic[i] = (ioapic_t *)&SMP_ioapic[j * PAGE_SIZE]; 426 break; 427 } 428 /* use this slot if available */ 429 if (((u_long)SMP_prvpt[j + 16] & PG_FRAME) == 0) { |
423 SMP_prvpt[j + 16] = PG_V | PG_RW | pgeflag | 424 ((u_long)io_apic_address[i] & PG_FRAME); | 430 SMP_prvpt[j + 16] = (pt_entry_t)(PG_V | PG_RW | pgeflag | 431 ((u_long)io_apic_address[i] & PG_FRAME)); |
425 ioapic[i] = (ioapic_t *)&SMP_ioapic[j * PAGE_SIZE]; 426 break; 427 } 428 } 429 if (j == 16) 430 panic("no space to map IO apic %d!", i); 431 } | 432 ioapic[i] = (ioapic_t *)&SMP_ioapic[j * PAGE_SIZE]; 433 break; 434 } 435 } 436 if (j == 16) 437 panic("no space to map IO apic %d!", i); 438 } |
439 440 /* BSP does this itself, AP's get it pre-set */ 441 prv_CMAP1 = (pt_entry_t *)&SMP_prvpt[4]; 442 prv_CMAP2 = (pt_entry_t *)&SMP_prvpt[5]; 443 prv_CMAP3 = (pt_entry_t *)&SMP_prvpt[6]; |
|
432#endif 433 434 invltlb(); 435 436} 437 438/* 439 * Set 4mb pdir for mp startup, and global flags --- 18 unchanged lines hidden (view full) --- 458 } 459 } 460} 461 462/* 463 * Setup the PTD for the boot processor 464 */ 465void | 444#endif 445 446 invltlb(); 447 448} 449 450/* 451 * Set 4mb pdir for mp startup, and global flags --- 18 unchanged lines hidden (view full) --- 470 } 471 } 472} 473 474/* 475 * Setup the PTD for the boot processor 476 */ 477void |
466pmap_set_opt_bsp(void) { | 478pmap_set_opt_bsp(void) 479{ |
467 pmap_set_opt((unsigned *)kernel_pmap->pm_pdir); 468 pmap_set_opt((unsigned *)PTD); 469 invltlb(); 470} 471 472/* 473 * Initialize the pmap module. 474 * Called by vm_init, to initialize any structures that the pmap --- 934 unchanged lines hidden (view full) --- 1409 * grow the number of kernel page table entries, if needed 1410 */ 1411void 1412pmap_growkernel(vm_offset_t addr) 1413{ 1414 struct proc *p; 1415 struct pmap *pmap; 1416 int s; | 480 pmap_set_opt((unsigned *)kernel_pmap->pm_pdir); 481 pmap_set_opt((unsigned *)PTD); 482 invltlb(); 483} 484 485/* 486 * Initialize the pmap module. 487 * Called by vm_init, to initialize any structures that the pmap --- 934 unchanged lines hidden (view full) --- 1422 * grow the number of kernel page table entries, if needed 1423 */ 1424void 1425pmap_growkernel(vm_offset_t addr) 1426{ 1427 struct proc *p; 1428 struct pmap *pmap; 1429 int s; |
1430#ifdef SMP 1431 int i; 1432#endif |
|
1417 1418 s = splhigh(); 1419 if (kernel_vm_end == 0) { 1420 kernel_vm_end = KERNBASE; 1421 nkpt = 0; 1422 while (pdir_pde(PTD, kernel_vm_end)) { 1423 kernel_vm_end = (kernel_vm_end + PAGE_SIZE * NPTEPG) & ~(PAGE_SIZE * NPTEPG - 1); 1424 ++nkpt; --- 16 unchanged lines hidden (view full) --- 1441 ptpidx, VM_ALLOC_SYSTEM); 1442 if (!nkpg) 1443 panic("pmap_growkernel: no memory to grow kernel"); 1444 vm_page_wire(nkpg); 1445 vm_page_remove(nkpg); 1446 pmap_zero_page(VM_PAGE_TO_PHYS(nkpg)); 1447 } 1448 pdir_pde(PTD, kernel_vm_end) = (pd_entry_t) (VM_PAGE_TO_PHYS(nkpg) | PG_V | PG_RW | pgeflag); | 1433 1434 s = splhigh(); 1435 if (kernel_vm_end == 0) { 1436 kernel_vm_end = KERNBASE; 1437 nkpt = 0; 1438 while (pdir_pde(PTD, kernel_vm_end)) { 1439 kernel_vm_end = (kernel_vm_end + PAGE_SIZE * NPTEPG) & ~(PAGE_SIZE * NPTEPG - 1); 1440 ++nkpt; --- 16 unchanged lines hidden (view full) --- 1457 ptpidx, VM_ALLOC_SYSTEM); 1458 if (!nkpg) 1459 panic("pmap_growkernel: no memory to grow kernel"); 1460 vm_page_wire(nkpg); 1461 vm_page_remove(nkpg); 1462 pmap_zero_page(VM_PAGE_TO_PHYS(nkpg)); 1463 } 1464 pdir_pde(PTD, kernel_vm_end) = (pd_entry_t) (VM_PAGE_TO_PHYS(nkpg) | PG_V | PG_RW | pgeflag); |
1465 1466#ifdef SMP 1467 for (i = 0; i < mp_naps; i++) { 1468 if (IdlePTDS[i]) 1469 pdir_pde(IdlePTDS[i], kernel_vm_end) = (pd_entry_t) (VM_PAGE_TO_PHYS(nkpg) | PG_V | PG_RW | pgeflag); 1470 } 1471#endif 1472 |
|
1449 nkpg = NULL; 1450 1451 for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) { 1452 if (p->p_vmspace) { 1453 pmap = &p->p_vmspace->vm_pmap; 1454 *pmap_pde(pmap, kernel_vm_end) = pdir_pde(PTD, kernel_vm_end); 1455 } 1456 } --- 1129 unchanged lines hidden (view full) --- 2586 * page by mapping the page into virtual memory and using 2587 * bzero to clear its contents, one machine dependent page 2588 * at a time. 2589 */ 2590void 2591pmap_zero_page(phys) 2592 vm_offset_t phys; 2593{ | 1473 nkpg = NULL; 1474 1475 for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) { 1476 if (p->p_vmspace) { 1477 pmap = &p->p_vmspace->vm_pmap; 1478 *pmap_pde(pmap, kernel_vm_end) = pdir_pde(PTD, kernel_vm_end); 1479 } 1480 } --- 1129 unchanged lines hidden (view full) --- 2610 * page by mapping the page into virtual memory and using 2611 * bzero to clear its contents, one machine dependent page 2612 * at a time. 2613 */ 2614void 2615pmap_zero_page(phys) 2616 vm_offset_t phys; 2617{ |
2618#ifdef SMP 2619 if (*(int *) prv_CMAP3) 2620 panic("pmap_zero_page: prv_CMAP3 busy"); 2621 2622 *(int *) prv_CMAP3 = PG_V | PG_RW | (phys & PG_FRAME); 2623 invltlb_1pg((vm_offset_t) &prv_CPAGE3); 2624 2625 bzero(&prv_CPAGE3, PAGE_SIZE); 2626 2627 *(int *) prv_CMAP3 = 0; 2628 invltlb_1pg((vm_offset_t) &prv_CPAGE3); 2629#else |
|
2594 if (*(int *) CMAP2) 2595 panic("pmap_zero_page: CMAP busy"); 2596 2597 *(int *) CMAP2 = PG_V | PG_RW | (phys & PG_FRAME); 2598 bzero(CADDR2, PAGE_SIZE); 2599 *(int *) CMAP2 = 0; 2600 invltlb_1pg((vm_offset_t) CADDR2); | 2630 if (*(int *) CMAP2) 2631 panic("pmap_zero_page: CMAP busy"); 2632 2633 *(int *) CMAP2 = PG_V | PG_RW | (phys & PG_FRAME); 2634 bzero(CADDR2, PAGE_SIZE); 2635 *(int *) CMAP2 = 0; 2636 invltlb_1pg((vm_offset_t) CADDR2); |
2637#endif |
|
2601} 2602 2603/* 2604 * pmap_copy_page copies the specified (machine independent) 2605 * page by mapping the page into virtual memory and using 2606 * bcopy to copy the page, one machine dependent page at a 2607 * time. 2608 */ 2609void 2610pmap_copy_page(src, dst) 2611 vm_offset_t src; 2612 vm_offset_t dst; 2613{ | 2638} 2639 2640/* 2641 * pmap_copy_page copies the specified (machine independent) 2642 * page by mapping the page into virtual memory and using 2643 * bcopy to copy the page, one machine dependent page at a 2644 * time. 2645 */ 2646void 2647pmap_copy_page(src, dst) 2648 vm_offset_t src; 2649 vm_offset_t dst; 2650{ |
2651#ifdef SMP 2652 if (*(int *) prv_CMAP1) 2653 panic("pmap_copy_page: prv_CMAP1 busy"); 2654 if (*(int *) prv_CMAP2) 2655 panic("pmap_copy_page: prv_CMAP2 busy"); 2656 2657 *(int *) prv_CMAP1 = PG_V | PG_RW | (src & PG_FRAME); 2658 *(int *) prv_CMAP2 = PG_V | PG_RW | (dst & PG_FRAME); 2659 2660 invltlb_2pg( (vm_offset_t) &prv_CPAGE1, (vm_offset_t) &prv_CPAGE2); 2661 2662 bcopy(&prv_CPAGE1, &prv_CPAGE2, PAGE_SIZE); 2663 2664 *(int *) prv_CMAP1 = 0; 2665 *(int *) prv_CMAP2 = 0; 2666 invltlb_2pg( (vm_offset_t) &prv_CPAGE1, (vm_offset_t) &prv_CPAGE2); 2667#else |
|
2614 if (*(int *) CMAP1 || *(int *) CMAP2) 2615 panic("pmap_copy_page: CMAP busy"); 2616 2617 *(int *) CMAP1 = PG_V | PG_RW | (src & PG_FRAME); 2618 *(int *) CMAP2 = PG_V | PG_RW | (dst & PG_FRAME); 2619 2620 bcopy(CADDR1, CADDR2, PAGE_SIZE); 2621 2622 *(int *) CMAP1 = 0; 2623 *(int *) CMAP2 = 0; 2624 invltlb_2pg( (vm_offset_t) CADDR1, (vm_offset_t) CADDR2); | 2668 if (*(int *) CMAP1 || *(int *) CMAP2) 2669 panic("pmap_copy_page: CMAP busy"); 2670 2671 *(int *) CMAP1 = PG_V | PG_RW | (src & PG_FRAME); 2672 *(int *) CMAP2 = PG_V | PG_RW | (dst & PG_FRAME); 2673 2674 bcopy(CADDR1, CADDR2, PAGE_SIZE); 2675 2676 *(int *) CMAP1 = 0; 2677 *(int *) CMAP2 = 0; 2678 invltlb_2pg( (vm_offset_t) CADDR1, (vm_offset_t) CADDR2); |
2679#endif |
|
2625} 2626 2627 2628/* 2629 * Routine: pmap_pageable 2630 * Function: 2631 * Make the specified pages (by pmap, offset) 2632 * pageable (or not) as requested. --- 612 unchanged lines hidden --- | 2680} 2681 2682 2683/* 2684 * Routine: pmap_pageable 2685 * Function: 2686 * Make the specified pages (by pmap, offset) 2687 * pageable (or not) as requested. --- 612 unchanged lines hidden --- |