1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-20 02:38:43 +00:00

- Added macros NPGPTD, NBPTD, and NPDEPTD, for dealing with the size of the

page directory.
- Use these instead of the magic constants 1 or PAGE_SIZE where appropriate.
  There are still numerous assumptions that the page directory is exactly
  1 page.

Sponsored by:	DARPA, Network Associates Laboratories
This commit is contained in:
Jake Burkholder 2003-02-23 21:20:00 +00:00
parent 3b63c6c8ea
commit 910548dea7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=111363
12 changed files with 37 additions and 29 deletions

View File

@ -108,6 +108,7 @@ ASSYM(KSTACK_PAGES, KSTACK_PAGES);
ASSYM(PAGE_SIZE, PAGE_SIZE);
ASSYM(NPTEPG, NPTEPG);
ASSYM(NPDEPG, NPDEPG);
ASSYM(NPGPTD, NPGPTD);
ASSYM(PDESIZE, sizeof(pd_entry_t));
ASSYM(PTESIZE, sizeof(pt_entry_t));
ASSYM(PTESHIFT, PTESHIFT);

View File

@ -749,7 +749,7 @@ no_kernend:
movl %esi,R(KPTphys)
/* Allocate Page Table Directory */
ALLOCPAGES(1)
ALLOCPAGES(NPGPTD)
movl %esi,R(IdlePTD)
/* Allocate UPAGES */
@ -805,7 +805,7 @@ no_kernend:
/* Map page directory. */
movl R(IdlePTD), %eax
movl $1, %ecx
movl $NPGPTD, %ecx
fillkptphys($PG_RW)
/* Map proc0's UPAGES in the physical way ... */

View File

@ -749,7 +749,7 @@ no_kernend:
movl %esi,R(KPTphys)
/* Allocate Page Table Directory */
ALLOCPAGES(1)
ALLOCPAGES(NPGPTD)
movl %esi,R(IdlePTD)
/* Allocate UPAGES */
@ -805,7 +805,7 @@ no_kernend:
/* Map page directory. */
movl R(IdlePTD), %eax
movl $1, %ecx
movl $NPGPTD, %ecx
fillkptphys($PG_RW)
/* Map proc0's UPAGES in the physical way ... */

View File

@ -1286,14 +1286,15 @@ pmap_pinit(pmap)
* page directory table.
*/
if (pmap->pm_pdir == NULL)
pmap->pm_pdir =
(pd_entry_t *)kmem_alloc_pageable(kernel_map, PAGE_SIZE);
pmap->pm_pdir = (pd_entry_t *)kmem_alloc_pageable(kernel_map,
NBPTD);
/*
* allocate object for the ptes
*/
if (pmap->pm_pteobj == NULL)
pmap->pm_pteobj = vm_object_allocate(OBJT_DEFAULT, PTDPTDI + 1);
pmap->pm_pteobj = vm_object_allocate(OBJT_DEFAULT, PTDPTDI +
NPGPTD);
/*
* allocate the page directory page
@ -1305,7 +1306,7 @@ pmap_pinit(pmap)
ptdpg->valid = VM_PAGE_BITS_ALL;
vm_page_unlock_queues();
pmap_qenter((vm_offset_t) pmap->pm_pdir, &ptdpg, 1);
pmap_qenter((vm_offset_t)pmap->pm_pdir, &ptdpg, NPGPTD);
if ((ptdpg->flags & PG_ZERO) == 0)
bzero(pmap->pm_pdir, PAGE_SIZE);
@ -3423,7 +3424,7 @@ pmap_pid_dump(int pid)
int i,j;
index = 0;
pmap = vmspace_pmap(p->p_vmspace);
for (i = 0; i < NPDEPG; i++) {
for (i = 0; i < NPDEPTD; i++) {
pd_entry_t *pde;
pt_entry_t *pte;
vm_offset_t base = i << PDRSHIFT;
@ -3483,7 +3484,7 @@ pads(pm)
if (pm == kernel_pmap)
return;
for (i = 0; i < NPDEPG; i++)
for (i = 0; i < NPDEPTD; i++)
if (pm->pm_pdir[i])
for (j = 0; j < NPTEPG; j++) {
va = (i << PDRSHIFT) + (j << PAGE_SHIFT);

View File

@ -514,7 +514,7 @@ cpu_reset_real()
#endif
#endif /* PC98 */
/* force a shutdown by unmapping entire address space ! */
bzero((caddr_t) PTD, PAGE_SIZE);
bzero((caddr_t)PTD, NBPTD);
/* "good night, sweet prince .... <THUNK!>" */
invltlb();

View File

@ -101,9 +101,9 @@
#endif
#ifndef NKPDE
#ifdef SMP
#define NKPDE (KVA_PAGES - 2) /* addressable number of page tables/pde's */
#define NKPDE (KVA_PAGES - (NPGPTD + 1)) /* number of page tables/pde's */
#else
#define NKPDE (KVA_PAGES - 1) /* addressable number of page tables/pde's */
#define NKPDE (KVA_PAGES - NPGPTD) /* number of page tables/pde's */
#endif
#endif
@ -115,14 +115,14 @@
*
* SMP_PRIVPAGES: The per-cpu address space is 0xff80000 -> 0xffbfffff
*/
#define APTDPTDI (NPDEPG-1) /* alt ptd entry that points to APTD */
#define APTDPTDI (NPDEPG-NPGPTD) /* alt ptd entry that points to APTD */
#ifdef SMP
#define MPPTDI (APTDPTDI-1) /* per cpu ptd entry */
#define KPTDI (MPPTDI-NKPDE) /* start of kernel virtual pde's */
#else
#define KPTDI (APTDPTDI-NKPDE)/* start of kernel virtual pde's */
#endif /* SMP */
#define PTDPTDI (KPTDI-1) /* ptd entry that points to ptd! */
#define PTDPTDI (KPTDI-NPGPTD) /* ptd entry that points to ptd! */
#define UMAXPTDI (PTDPTDI-1) /* ptd entry for user space end */
#define UMAXPTEOFF (NPTEPG) /* pte entry for user space end */

View File

@ -108,6 +108,7 @@ ASSYM(KSTACK_PAGES, KSTACK_PAGES);
ASSYM(PAGE_SIZE, PAGE_SIZE);
ASSYM(NPTEPG, NPTEPG);
ASSYM(NPDEPG, NPDEPG);
ASSYM(NPGPTD, NPGPTD);
ASSYM(PDESIZE, sizeof(pd_entry_t));
ASSYM(PTESIZE, sizeof(pt_entry_t));
ASSYM(PTESHIFT, PTESHIFT);

View File

@ -749,7 +749,7 @@ no_kernend:
movl %esi,R(KPTphys)
/* Allocate Page Table Directory */
ALLOCPAGES(1)
ALLOCPAGES(NPGPTD)
movl %esi,R(IdlePTD)
/* Allocate UPAGES */
@ -805,7 +805,7 @@ no_kernend:
/* Map page directory. */
movl R(IdlePTD), %eax
movl $1, %ecx
movl $NPGPTD, %ecx
fillkptphys($PG_RW)
/* Map proc0's UPAGES in the physical way ... */

View File

@ -1286,14 +1286,15 @@ pmap_pinit(pmap)
* page directory table.
*/
if (pmap->pm_pdir == NULL)
pmap->pm_pdir =
(pd_entry_t *)kmem_alloc_pageable(kernel_map, PAGE_SIZE);
pmap->pm_pdir = (pd_entry_t *)kmem_alloc_pageable(kernel_map,
NBPTD);
/*
* allocate object for the ptes
*/
if (pmap->pm_pteobj == NULL)
pmap->pm_pteobj = vm_object_allocate(OBJT_DEFAULT, PTDPTDI + 1);
pmap->pm_pteobj = vm_object_allocate(OBJT_DEFAULT, PTDPTDI +
NPGPTD);
/*
* allocate the page directory page
@ -1305,7 +1306,7 @@ pmap_pinit(pmap)
ptdpg->valid = VM_PAGE_BITS_ALL;
vm_page_unlock_queues();
pmap_qenter((vm_offset_t) pmap->pm_pdir, &ptdpg, 1);
pmap_qenter((vm_offset_t)pmap->pm_pdir, &ptdpg, NPGPTD);
if ((ptdpg->flags & PG_ZERO) == 0)
bzero(pmap->pm_pdir, PAGE_SIZE);
@ -3423,7 +3424,7 @@ pmap_pid_dump(int pid)
int i,j;
index = 0;
pmap = vmspace_pmap(p->p_vmspace);
for (i = 0; i < NPDEPG; i++) {
for (i = 0; i < NPDEPTD; i++) {
pd_entry_t *pde;
pt_entry_t *pte;
vm_offset_t base = i << PDRSHIFT;
@ -3483,7 +3484,7 @@ pads(pm)
if (pm == kernel_pmap)
return;
for (i = 0; i < NPDEPG; i++)
for (i = 0; i < NPDEPTD; i++)
if (pm->pm_pdir[i])
for (j = 0; j < NPTEPG; j++) {
va = (i << PDRSHIFT) + (j << PAGE_SHIFT);

View File

@ -514,7 +514,7 @@ cpu_reset_real()
#endif
#endif /* PC98 */
/* force a shutdown by unmapping entire address space ! */
bzero((caddr_t) PTD, PAGE_SIZE);
bzero((caddr_t)PTD, NBPTD);
/* "good night, sweet prince .... <THUNK!>" */
invltlb();

View File

@ -87,8 +87,12 @@
#define PAGE_MASK (PAGE_SIZE-1)
#define NPTEPG (PAGE_SIZE/(sizeof (pt_entry_t)))
#define NPDEPG (PAGE_SIZE/(sizeof (pd_entry_t)))
#define NPGPTD 1
#define PDRSHIFT 22 /* LOG2(NBPDR) */
#define NBPTD (NPGPTD<<PAGE_SHIFT)
#define NPDEPTD (NBPTD/(sizeof (pd_entry_t)))
#define NPDEPG (PAGE_SIZE/(sizeof (pd_entry_t)))
#define NBPDR (1<<PDRSHIFT) /* bytes/page dir */
#define PDRMASK (NBPDR-1)

View File

@ -101,9 +101,9 @@
#endif
#ifndef NKPDE
#ifdef SMP
#define NKPDE (KVA_PAGES - 2) /* addressable number of page tables/pde's */
#define NKPDE (KVA_PAGES - (NPGPTD + 1)) /* number of page tables/pde's */
#else
#define NKPDE (KVA_PAGES - 1) /* addressable number of page tables/pde's */
#define NKPDE (KVA_PAGES - NPGPTD) /* number of page tables/pde's */
#endif
#endif
@ -115,14 +115,14 @@
*
* SMP_PRIVPAGES: The per-cpu address space is 0xff80000 -> 0xffbfffff
*/
#define APTDPTDI (NPDEPG-1) /* alt ptd entry that points to APTD */
#define APTDPTDI (NPDEPG-NPGPTD) /* alt ptd entry that points to APTD */
#ifdef SMP
#define MPPTDI (APTDPTDI-1) /* per cpu ptd entry */
#define KPTDI (MPPTDI-NKPDE) /* start of kernel virtual pde's */
#else
#define KPTDI (APTDPTDI-NKPDE)/* start of kernel virtual pde's */
#endif /* SMP */
#define PTDPTDI (KPTDI-1) /* ptd entry that points to ptd! */
#define PTDPTDI (KPTDI-NPGPTD) /* ptd entry that points to ptd! */
#define UMAXPTDI (PTDPTDI-1) /* ptd entry for user space end */
#define UMAXPTEOFF (NPTEPG) /* pte entry for user space end */