MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / include / asm-i386 / pgtable-2level.h
blob58867b62f47b4e79d42925e4da7d47775d1a397a
1 #ifndef _I386_PGTABLE_2LEVEL_H
2 #define _I386_PGTABLE_2LEVEL_H
4 #define pte_ERROR(e) \
5 printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, (e).pte_low)
6 #define pmd_ERROR(e) \
7 printk("%s:%d: bad pmd %08lx.\n", __FILE__, __LINE__, pmd_val(e))
8 #define pgd_ERROR(e) \
9 printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
12 * The "pgd_xxx()" functions here are trivial for a folded two-level
13 * setup: the pgd is never bad, and a pmd always exists (as it's folded
14 * into the pgd entry)
16 static inline int pgd_none(pgd_t pgd) { return 0; }
17 static inline int pgd_bad(pgd_t pgd) { return 0; }
18 static inline int pgd_present(pgd_t pgd) { return 1; }
19 #define pgd_clear(xp) do { } while (0)
22 * Certain architectures need to do special things when PTEs
23 * within a page table are directly modified. Thus, the following
24 * hook is made available.
26 #define set_pte(pteptr, pteval) (*(pteptr) = pteval)
27 #define set_pte_atomic(pteptr, pteval) set_pte(pteptr,pteval)
29 * (pmds are folded into pgds so this doesn't get actually called,
30 * but the define is needed for a generic inline function.)
32 #define set_pmd(pmdptr, pmdval) (*(pmdptr) = pmdval)
33 #define set_pgd(pgdptr, pgdval) (*(pgdptr) = pgdval)
35 #define pgd_page(pgd) \
36 ((unsigned long) __va(pgd_val(pgd) & PAGE_MASK))
38 static inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address)
40 return (pmd_t *) dir;
42 #define ptep_get_and_clear(xp) __pte(xchg(&(xp)->pte_low, 0))
43 #define pte_same(a, b) ((a).pte_low == (b).pte_low)
44 #define pte_page(x) pfn_to_page(pte_pfn(x))
45 #define pte_none(x) (!(x).pte_low)
46 #define pte_pfn(x) ((unsigned long)(((x).pte_low >> PAGE_SHIFT)))
47 #define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
48 #define pfn_pmd(pfn, prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
51 * All present user pages are user-executable:
53 static inline int pte_exec(pte_t pte)
55 return pte_user(pte);
59 * All present pages are kernel-executable:
61 static inline int pte_exec_kernel(pte_t pte)
63 return 1;
67 * Bits 0, 6 and 7 are taken, split up the 29 bits of offset
68 * into this range:
70 #define PTE_FILE_MAX_BITS 29
72 #define pte_to_pgoff(pte) \
73 ((((pte).pte_low >> 1) & 0x1f ) + (((pte).pte_low >> 8) << 5 ))
75 #define pgoff_to_pte(off) \
76 ((pte_t) { (((off) & 0x1f) << 1) + (((off) >> 5) << 8) + _PAGE_FILE })
78 /* Encode and de-code a swap entry */
79 #define __swp_type(x) (((x).val >> 1) & 0x1f)
80 #define __swp_offset(x) ((x).val >> 8)
81 #define __swp_entry(type, offset) ((swp_entry_t) { ((type) << 1) | ((offset) << 8) })
82 #define __pte_to_swp_entry(pte) ((swp_entry_t) { (pte).pte_low })
83 #define __swp_entry_to_pte(x) ((pte_t) { (x).val })
85 #endif /* _I386_PGTABLE_2LEVEL_H */