-/* $OpenBSD: pmap.c,v 1.12 2010/07/02 22:47:54 jsing Exp $ */
+/* $OpenBSD: pmap.c,v 1.13 2010/07/24 16:25:33 kettenis Exp $ */
/*
* Copyright (c) 2005 Michael Shalayeff
paddr_t *pap;
{
pt_entry_t pte;
+ vaddr_t mask;
DPRINTF(PDB_FOLLOW|PDB_EXTRACT, ("pmap_extract(%p, %lx)\n", pmap, va));
simple_unlock(&pmap->pm_lock);
if (pte) {
- if (pap)
- *pap = PTE_PAGE(pte) | (va & PAGE_MASK);
+ if (pap) {
+ mask = PTE_PAGE_SIZE(pte) - 1;
+ *pap = PTE_PAGE(pte) | (va & mask);
+ }
return (TRUE);
}
-/* $OpenBSD: pte.h,v 1.2 2010/07/24 14:30:04 kettenis Exp $ */
+/* $OpenBSD: pte.h,v 1.3 2010/07/24 16:25:33 kettenis Exp $ */
/*
* Copyright (c) 2005 Michael Shalayeff
#define PTE_PG16M 0x0000000000000006UL
#define PTE_PG64M 0x0000000000000007UL
+#define PTE_PAGE_SHIFT(pte) (12 + (2 * ((pte) & PTE_PG64M)))
+#define PTE_PAGE_SIZE(pte) (1 << PTE_PAGE_SHIFT(pte))
+
#define PTE_GETBITS(pte) ((pte) >> 48)
#define PTE_BITS \
"\020\01H\02P\03O\04UC\05U\010W\11X\12G\014B\015D\016REF\017FD\020FI"