direct-io.hg

view linux-2.4.30-xen-sparse/include/asm-xen/pgtable-2level.h @ 5517:10e9028c8e3d

bitkeeper revision 1.1718.1.10 (42b7b19aqOS_1M8I4pIOFjiTPYWV-g)

Merge bk://xenbits.xensource.com/xen-unstable.bk
into spot.cl.cam.ac.uk:C:/Documents and Settings/iap10/xen-unstable.bk
author iap10@spot.cl.cam.ac.uk
date Tue Jun 21 06:20:10 2005 +0000 (2005-06-21)
parents 85fcf3b1b7a5
children 56a63f9f378f
line source
1 #ifndef _I386_PGTABLE_2LEVEL_H
2 #define _I386_PGTABLE_2LEVEL_H
4 /*
5 * traditional i386 two-level paging structure:
6 */
8 #define PGDIR_SHIFT 22
9 #define PTRS_PER_PGD 1024
11 /*
12 * the i386 is two-level, so we don't really have any
13 * PMD directory physically.
14 */
15 #define PMD_SHIFT 22
16 #define PTRS_PER_PMD 1
18 #define PTRS_PER_PTE 1024
20 #define pte_ERROR(e) \
21 printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, (e).pte_low)
22 #define pmd_ERROR(e) \
23 printk("%s:%d: bad pmd %08lx.\n", __FILE__, __LINE__, pmd_val(e))
24 #define pgd_ERROR(e) \
25 printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
27 /*
28 * The "pgd_xxx()" functions here are trivial for a folded two-level
29 * setup: the pgd is never bad, and a pmd always exists (as it's folded
30 * into the pgd entry)
31 */
32 static inline int pgd_none(pgd_t pgd) { return 0; }
33 static inline int pgd_bad(pgd_t pgd) { return 0; }
34 static inline int pgd_present(pgd_t pgd) { return 1; }
35 #define pgd_clear(xp) do { } while (0)
37 /*
38 * Certain architectures need to do special things when PTEs
39 * within a page table are directly modified. Thus, the following
40 * hook is made available.
41 */
42 #define set_pte(pteptr, pteval) (*(pteptr) = pteval)
43 #define set_pte_atomic(pteptr, pteval) (*(pteptr) = pteval)
45 /*
46 * (pmds are folded into pgds so this doesnt get actually called,
47 * but the define is needed for a generic inline function.)
48 */
49 #define set_pmd(pmdptr, pmdval) xen_l2_entry_update((pmdptr), (pmdval))
50 #define set_pgd(pgdptr, pgdval) ((void)0)
52 #define pgd_page(pgd) \
53 ((unsigned long) __va(pgd_val(pgd) & PAGE_MASK))
55 static inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address)
56 {
57 return (pmd_t *) dir;
58 }
60 #define ptep_get_and_clear(xp) __pte_ma(xchg(&(xp)->pte_low, 0))
61 #define pte_same(a, b) ((a).pte_low == (b).pte_low)
63 /*
64 * We detect special mappings in one of two ways:
65 * 1. If the MFN is an I/O page then Xen will set the m2p entry
66 * to be outside our maximum possible pseudophys range.
67 * 2. If the MFN belongs to a different domain then we will certainly
68 * not have MFN in our p2m table. Conversely, if the page is ours,
69 * then we'll have p2m(m2p(MFN))==MFN.
70 * If we detect a special mapping then it doesn't have a 'struct page'.
71 * We force !VALID_PAGE() by returning an out-of-range pointer.
72 *
73 * NB. These checks require that, for any MFN that is not in our reservation,
74 * there is no PFN such that p2m(PFN) == MFN. Otherwise we can get confused if
75 * we are foreign-mapping the MFN, and the other domain as m2p(MFN) == PFN.
76 * Yikes! Various places must poke in INVALID_P2M_ENTRY for safety.
77 *
78 * NB2. When deliberately mapping foreign pages into the p2m table, you *must*
79 * use FOREIGN_FRAME(). This will cause pte_pfn() to choke on it, as we
80 * require. In all the cases we care about, the high bit gets shifted out
81 * (e.g., phys_to_machine()) so behaviour there is correct.
82 */
83 #define INVALID_P2M_ENTRY (~0U)
84 #define FOREIGN_FRAME(_m) ((_m) | (1UL<<((sizeof(unsigned long)*8)-1)))
85 #define pte_page(_pte) \
86 ({ \
87 unsigned long mfn = (_pte).pte_low >> PAGE_SHIFT; \
88 unsigned long pfn = mfn_to_pfn(mfn); \
89 if ( (pfn >= max_mapnr) || (pfn_to_mfn(pfn) != mfn) ) \
90 pfn = max_mapnr; /* specia: force !VALID_PAGE() */ \
91 &mem_map[pfn]; \
92 })
94 #define pte_none(x) (!(x).pte_low)
95 #define __mk_pte(page_nr,pgprot) __pte(((page_nr) << PAGE_SHIFT) | pgprot_val(pgprot))
97 #endif /* _I386_PGTABLE_2LEVEL_H */