debuggers.hg

view xen/include/asm-x86/x86_64/page.h @ 3765:4dfebfdc7933

bitkeeper revision 1.1159.252.1 (4208e2a42Fwe83QQfJdFQI8V302tYg)

Reorganise mm.h to split out 32-bit and 64-bit definitions. Fix x86_64
definitions to mask out the bits that we don't care about.
Signed-off-by: keir.fraser@cl.cam.ac.uk
author kaf24@scramble.cl.cam.ac.uk
date Tue Feb 08 16:02:44 2005 +0000 (2005-02-08)
parents
children 89e86842952a
line source
1 /* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
3 #ifndef __X86_64_PAGE_H__
4 #define __X86_64_PAGE_H__
6 #define L1_PAGETABLE_SHIFT 12
7 #define L2_PAGETABLE_SHIFT 21
8 #define L3_PAGETABLE_SHIFT 30
9 #define L4_PAGETABLE_SHIFT 39
10 #define PAGE_SHIFT L1_PAGETABLE_SHIFT
12 #define ENTRIES_PER_L1_PAGETABLE 512
13 #define ENTRIES_PER_L2_PAGETABLE 512
14 #define ENTRIES_PER_L3_PAGETABLE 512
15 #define ENTRIES_PER_L4_PAGETABLE 512
17 #define __PAGE_OFFSET (0xFFFF830000000000)
19 /* These may increase in future (phys. bits in particular). */
20 #define PADDR_BITS 40
21 #define VADDR_BITS 48
22 #define PADDR_MASK ((1UL << PADDR_BITS)-1)
23 #define VADDR_MASK ((1UL << VADDR_BITS)-1)
25 #ifndef __ASSEMBLY__
26 #include <xen/config.h>
27 typedef struct { unsigned long l1_lo; } l1_pgentry_t;
28 typedef struct { unsigned long l2_lo; } l2_pgentry_t;
29 typedef struct { unsigned long l3_lo; } l3_pgentry_t;
30 typedef struct { unsigned long l4_lo; } l4_pgentry_t;
31 #endif /* !__ASSEMBLY__ */
33 /* Strip type from a table entry. */
34 #define l1_pgentry_val(_x) ((_x).l1_lo)
35 #define l2_pgentry_val(_x) ((_x).l2_lo)
36 #define l3_pgentry_val(_x) ((_x).l3_lo)
37 #define l4_pgentry_val(_x) ((_x).l4_lo)
39 /* Add type to a table entry. */
40 #define mk_l1_pgentry(_x) ( (l1_pgentry_t) { (_x) } )
41 #define mk_l2_pgentry(_x) ( (l2_pgentry_t) { (_x) } )
42 #define mk_l3_pgentry(_x) ( (l3_pgentry_t) { (_x) } )
43 #define mk_l4_pgentry(_x) ( (l4_pgentry_t) { (_x) } )
45 /* Turn a typed table entry into a physical address. */
46 #define l1_pgentry_to_phys(_x) (l1_pgentry_val(_x) & (PADDR_MASK & PAGE_MASK))
47 #define l2_pgentry_to_phys(_x) (l2_pgentry_val(_x) & (PADDR_MASK & PAGE_MASK))
48 #define l3_pgentry_to_phys(_x) (l3_pgentry_val(_x) & (PADDR_MASK & PAGE_MASK))
49 #define l4_pgentry_to_phys(_x) (l4_pgentry_val(_x) & (PADDR_MASK & PAGE_MASK))
51 /* Turn a typed table entry into a page index. */
52 #define l1_pgentry_to_pfn(_x) (l1_pgentry_val(_x) >> PAGE_SHIFT)
53 #define l2_pgentry_to_pfn(_x) (l2_pgentry_val(_x) >> PAGE_SHIFT)
54 #define l3_pgentry_to_pfn(_x) (l3_pgentry_val(_x) >> PAGE_SHIFT)
55 #define l4_pgentry_to_pfn(_x) (l4_pgentry_val(_x) >> PAGE_SHIFT)
57 /* Pagetable walking. */
58 #define l2_pgentry_to_l1(_x) \
59 ((l1_pgentry_t *)__va(l2_pgentry_to_phys(_x)))
60 #define l3_pgentry_to_l2(_x) \
61 ((l2_pgentry_t *)__va(l3_pgentry_to_phys(_x)))
62 #define l4_pgentry_to_l3(_x) \
63 ((l3_pgentry_t *)__va(l4_pgentry_to_phys(_x)))
65 /* Given a virtual address, get an entry offset into a page table. */
66 #define l1_table_offset(_a) \
67 (((_a) >> L1_PAGETABLE_SHIFT) & (ENTRIES_PER_L1_PAGETABLE - 1))
68 #define l2_table_offset(_a) \
69 (((_a) >> L2_PAGETABLE_SHIFT) & (ENTRIES_PER_L2_PAGETABLE - 1))
70 #define l3_table_offset(_a) \
71 (((_a) >> L3_PAGETABLE_SHIFT) & (ENTRIES_PER_L3_PAGETABLE - 1))
72 #define l4_table_offset(_a) \
73 (((_a) >> L4_PAGETABLE_SHIFT) & (ENTRIES_PER_L4_PAGETABLE - 1))
75 /* Given a virtual address, get an entry offset into a linear page table. */
76 #define l1_linear_offset(_a) (((_a) & VADDR_MASK) >> PAGE_SHIFT)
78 /* Root page-table definitions. */
79 #define pagetable_t l4_pgentry_t
80 #define pagetable_val(_x) ((_x).l4_lo)
81 #define mk_pagetable(_x) ( (l4_pgentry_t) { (_x) } )
82 #define ENTRIES_PER_PAGETABLE ENTRIES_PER_L4_PAGETABLE
84 #endif /* __X86_64_PAGE_H__ */