]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/x86/include/asm/pgtable.h
x86: add and use pgd/pud/pmd_flags
[linux-2.6-omap-h63xx.git] / arch / x86 / include / asm / pgtable.h
index 49b5cff78c285a14fbd47a44097b8b09a5ac3d60..c811d76d6fd0a30cffd76f9fc40bfe0e65e8f6cc 100644 (file)
@@ -236,7 +236,7 @@ static inline unsigned long pte_pfn(pte_t pte)
 
 static inline int pmd_large(pmd_t pte)
 {
-       return (pmd_val(pte) & (_PAGE_PSE | _PAGE_PRESENT)) ==
+       return (pmd_flags(pte) & (_PAGE_PSE | _PAGE_PRESENT)) ==
                (_PAGE_PSE | _PAGE_PRESENT);
 }
 
@@ -458,7 +458,7 @@ static inline int pte_present(pte_t a)
 
 static inline int pmd_present(pmd_t pmd)
 {
-       return pmd_val(pmd) & _PAGE_PRESENT;
+       return pmd_flags(pmd) & _PAGE_PRESENT;
 }
 
 static inline int pmd_none(pmd_t pmd)
@@ -498,10 +498,44 @@ static inline unsigned pmd_index(unsigned long address)
  */
 #define mk_pte(page, pgprot)   pfn_pte(page_to_pfn(page), (pgprot))
 
+/*
+ * the pte page can be thought of an array like this: pte_t[PTRS_PER_PTE]
+ *
+ * this function returns the index of the entry in the pte page which would
+ * control the given virtual address
+ */
+static inline unsigned pte_index(unsigned long address)
+{
+       return (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1);
+}
+
+static inline pte_t *pte_offset_kernel(pmd_t *pmd, unsigned long address)
+{
+       return (pte_t *)pmd_page_vaddr(*pmd) + pte_index(address);
+}
+
+static inline int pmd_bad(pmd_t pmd)
+{
+       return (pmd_flags(pmd) & ~_PAGE_USER) != _KERNPG_TABLE;
+}
+
+static inline unsigned long pages_to_mb(unsigned long npg)
+{
+       return npg >> (20 - PAGE_SHIFT);
+}
+
+#define io_remap_pfn_range(vma, vaddr, pfn, size, prot)        \
+       remap_pfn_range(vma, vaddr, pfn, size, prot)
+
 #if PAGETABLE_LEVELS > 2
+static inline int pud_none(pud_t pud)
+{
+       return pud_val(pud) == 0;
+}
+
 static inline int pud_present(pud_t pud)
 {
-       return pud_val(pud) & _PAGE_PRESENT;
+       return pud_flags(pud) & _PAGE_PRESENT;
 }
 
 static inline unsigned long pud_page_vaddr(pud_t pud)
@@ -524,12 +558,23 @@ static inline unsigned long pmd_pfn(pmd_t pmd)
 {
        return (pmd_val(pmd) & PTE_PFN_MASK) >> PAGE_SHIFT;
 }
+
+static inline int pud_large(pud_t pud)
+{
+       return (pud_flags(pud) & (_PAGE_PSE | _PAGE_PRESENT)) ==
+               (_PAGE_PSE | _PAGE_PRESENT);
+}
+
+static inline int pud_bad(pud_t pud)
+{
+       return (pud_flags(pud) & ~(_KERNPG_TABLE | _PAGE_USER)) != 0;
+}
 #endif /* PAGETABLE_LEVELS > 2 */
 
 #if PAGETABLE_LEVELS > 3
 static inline int pgd_present(pgd_t pgd)
 {
-       return pgd_val(pgd) & _PAGE_PRESENT;
+       return pgd_flags(pgd) & _PAGE_PRESENT;
 }
 
 static inline unsigned long pgd_page_vaddr(pgd_t pgd)
@@ -552,6 +597,16 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
 {
        return (pud_t *)pgd_page_vaddr(*pgd) + pud_index(address);
 }
+
+static inline int pgd_bad(pgd_t pgd)
+{
+       return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
+}
+
+static inline int pgd_none(pgd_t pgd)
+{
+       return !pgd_val(pgd);
+}
 #endif /* PAGETABLE_LEVELS > 3 */
 
 #endif /* __ASSEMBLY__ */