Move pmap_p*e_index() inline functions from pmap.c to pmap.h.

They are already used in minidump code.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2016-09-20 09:38:07 +00:00
parent eaa797943e
commit 65afaac0c3
3 changed files with 34 additions and 34 deletions
sys/amd64

View File

@ -239,10 +239,10 @@ minidumpsys(struct dumperinfo *di)
* page written corresponds to 1GB of space
*/
pmapsize += PAGE_SIZE;
ii = (va >> PML4SHIFT) & ((1ul << NPML4EPGSHIFT) - 1);
ii = pmap_pml4e_index(va);
pml4 = (uint64_t *)PHYS_TO_DMAP(KPML4phys) + ii;
pdp = (uint64_t *)PHYS_TO_DMAP(*pml4 & PG_FRAME);
i = (va >> PDPSHIFT) & ((1ul << NPDPEPGSHIFT) - 1);
i = pmap_pdpe_index(va);
if ((pdp[i] & PG_V) == 0) {
va += NBPDP;
continue;
@ -264,7 +264,7 @@ minidumpsys(struct dumperinfo *di)
pd = (uint64_t *)PHYS_TO_DMAP(pdp[i] & PG_FRAME);
for (n = 0; n < NPDEPG; n++, va += NBPDR) {
j = (va >> PDRSHIFT) & ((1ul << NPDEPGSHIFT) - 1);
j = pmap_pde_index(va);
if ((pd[j] & PG_V) == 0)
continue;
@ -368,10 +368,10 @@ minidumpsys(struct dumperinfo *di)
bzero(fakepd, sizeof(fakepd));
for (va = VM_MIN_KERNEL_ADDRESS; va < MAX(KERNBASE + nkpt * NBPDR,
kernel_vm_end); va += NBPDP) {
ii = (va >> PML4SHIFT) & ((1ul << NPML4EPGSHIFT) - 1);
ii = pmap_pml4e_index(va);
pml4 = (uint64_t *)PHYS_TO_DMAP(KPML4phys) + ii;
pdp = (uint64_t *)PHYS_TO_DMAP(*pml4 & PG_FRAME);
i = (va >> PDPSHIFT) & ((1ul << NPDPEPGSHIFT) - 1);
i = pmap_pdpe_index(va);
/* We always write a page, even if it is zero */
if ((pdp[i] & PG_V) == 0) {

View File

@ -673,35 +673,6 @@ pmap_pde_pindex(vm_offset_t va)
}
/* Return various clipped indexes for a given VA */
static __inline vm_pindex_t
pmap_pte_index(vm_offset_t va)
{
return ((va >> PAGE_SHIFT) & ((1ul << NPTEPGSHIFT) - 1));
}
static __inline vm_pindex_t
pmap_pde_index(vm_offset_t va)
{
return ((va >> PDRSHIFT) & ((1ul << NPDEPGSHIFT) - 1));
}
static __inline vm_pindex_t
pmap_pdpe_index(vm_offset_t va)
{
return ((va >> PDPSHIFT) & ((1ul << NPDPEPGSHIFT) - 1));
}
static __inline vm_pindex_t
pmap_pml4e_index(vm_offset_t va)
{
return ((va >> PML4SHIFT) & ((1ul << NPML4EPGSHIFT) - 1));
}
/* Return a pointer to the PML4 slot that corresponds to a VA */
static __inline pml4_entry_t *
pmap_pml4e(pmap_t pmap, vm_offset_t va)

View File

@ -416,6 +416,35 @@ boolean_t pmap_map_io_transient(vm_page_t *, vm_offset_t *, int, boolean_t);
void pmap_unmap_io_transient(vm_page_t *, vm_offset_t *, int, boolean_t);
#endif /* _KERNEL */
/* Return various clipped indexes for a given VA */
static __inline vm_pindex_t
pmap_pte_index(vm_offset_t va)
{
return ((va >> PAGE_SHIFT) & ((1ul << NPTEPGSHIFT) - 1));
}
static __inline vm_pindex_t
pmap_pde_index(vm_offset_t va)
{
return ((va >> PDRSHIFT) & ((1ul << NPDEPGSHIFT) - 1));
}
static __inline vm_pindex_t
pmap_pdpe_index(vm_offset_t va)
{
return ((va >> PDPSHIFT) & ((1ul << NPDPEPGSHIFT) - 1));
}
static __inline vm_pindex_t
pmap_pml4e_index(vm_offset_t va)
{
return ((va >> PML4SHIFT) & ((1ul << NPML4EPGSHIFT) - 1));
}
#endif /* !LOCORE */
#endif /* !_MACHINE_PMAP_H_ */