debuggers.hg

view tools/libxc/xg_private.h @ 16715:c5deb251b9dc

Update version to 3.2.0-rc4
author Keir Fraser <keir.fraser@citrix.com>
date Sat Dec 29 17:57:37 2007 +0000 (2007-12-29)
parents 4c8394e3b011
children 0164d924ceba
line source
1 #ifndef XG_PRIVATE_H
2 #define XG_PRIVATE_H
4 #include <unistd.h>
5 #include <errno.h>
6 #include <fcntl.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <sys/mman.h>
11 #include <sys/types.h>
12 #include <sys/stat.h>
14 #include "xenctrl.h"
15 #include "xenguest.h"
16 #include "xc_private.h"
18 #include <xen/memory.h>
19 #include <xen/elfnote.h>
21 #ifndef ELFSIZE
22 #include <limits.h>
23 #if UINT_MAX == ULONG_MAX
24 #define ELFSIZE 32
25 #else
26 #define ELFSIZE 64
27 #endif
28 #endif
30 char *xc_read_image(const char *filename, unsigned long *size);
31 char *xc_inflate_buffer(const char *in_buf,
32 unsigned long in_size,
33 unsigned long *out_size);
35 unsigned long csum_page (void * page);
37 #define _PAGE_PRESENT 0x001
38 #define _PAGE_RW 0x002
39 #define _PAGE_USER 0x004
40 #define _PAGE_PWT 0x008
41 #define _PAGE_PCD 0x010
42 #define _PAGE_ACCESSED 0x020
43 #define _PAGE_DIRTY 0x040
44 #define _PAGE_PAT 0x080
45 #define _PAGE_PSE 0x080
46 #define _PAGE_GLOBAL 0x100
48 #define L1_PAGETABLE_SHIFT_I386 12
49 #define L2_PAGETABLE_SHIFT_I386 22
50 #define L1_PAGETABLE_ENTRIES_I386 1024
51 #define L2_PAGETABLE_ENTRIES_I386 1024
53 #define L1_PAGETABLE_SHIFT_PAE 12
54 #define L2_PAGETABLE_SHIFT_PAE 21
55 #define L3_PAGETABLE_SHIFT_PAE 30
56 #define L1_PAGETABLE_ENTRIES_PAE 512
57 #define L2_PAGETABLE_ENTRIES_PAE 512
58 #define L3_PAGETABLE_ENTRIES_PAE 4
60 #define L1_PAGETABLE_SHIFT_X86_64 12
61 #define L2_PAGETABLE_SHIFT_X86_64 21
62 #define L3_PAGETABLE_SHIFT_X86_64 30
63 #define L4_PAGETABLE_SHIFT_X86_64 39
64 #define L1_PAGETABLE_ENTRIES_X86_64 512
65 #define L2_PAGETABLE_ENTRIES_X86_64 512
66 #define L3_PAGETABLE_ENTRIES_X86_64 512
67 #define L4_PAGETABLE_ENTRIES_X86_64 512
69 #if defined(__i386__)
70 #define L1_PAGETABLE_SHIFT L1_PAGETABLE_SHIFT_I386
71 #define L2_PAGETABLE_SHIFT L2_PAGETABLE_SHIFT_I386
72 #define L1_PAGETABLE_ENTRIES L1_PAGETABLE_ENTRIES_I386
73 #define L2_PAGETABLE_ENTRIES L2_PAGETABLE_ENTRIES_I386
74 #elif defined(__x86_64__)
75 #define L1_PAGETABLE_SHIFT L1_PAGETABLE_SHIFT_X86_64
76 #define L2_PAGETABLE_SHIFT L2_PAGETABLE_SHIFT_X86_64
77 #define L3_PAGETABLE_SHIFT L3_PAGETABLE_SHIFT_X86_64
78 #define L4_PAGETABLE_SHIFT L4_PAGETABLE_SHIFT_X86_64
79 #define L1_PAGETABLE_ENTRIES L1_PAGETABLE_ENTRIES_X86_64
80 #define L2_PAGETABLE_ENTRIES L2_PAGETABLE_ENTRIES_X86_64
81 #define L3_PAGETABLE_ENTRIES L3_PAGETABLE_ENTRIES_X86_64
82 #define L4_PAGETABLE_ENTRIES L4_PAGETABLE_ENTRIES_X86_64
83 #endif
85 typedef uint32_t l1_pgentry_32_t;
86 typedef uint32_t l2_pgentry_32_t;
87 typedef uint64_t l1_pgentry_64_t;
88 typedef uint64_t l2_pgentry_64_t;
89 typedef uint64_t l3_pgentry_64_t;
90 typedef uint64_t l4_pgentry_64_t;
92 #if defined(__i386__)
93 typedef l1_pgentry_32_t l1_pgentry_t;
94 typedef l2_pgentry_32_t l2_pgentry_t;
95 #elif defined(__x86_64__)
96 typedef l1_pgentry_64_t l1_pgentry_t;
97 typedef l2_pgentry_64_t l2_pgentry_t;
98 typedef l3_pgentry_64_t l3_pgentry_t;
99 typedef l4_pgentry_64_t l4_pgentry_t;
100 #endif
102 #define l1_table_offset_i386(_a) \
103 (((_a) >> L1_PAGETABLE_SHIFT_I386) & (L1_PAGETABLE_ENTRIES_I386 - 1))
104 #define l2_table_offset_i386(_a) \
105 (((_a) >> L2_PAGETABLE_SHIFT_I386) & (L2_PAGETABLE_ENTRIES_I386 - 1))
107 #define l1_table_offset_pae(_a) \
108 (((_a) >> L1_PAGETABLE_SHIFT_PAE) & (L1_PAGETABLE_ENTRIES_PAE - 1))
109 #define l2_table_offset_pae(_a) \
110 (((_a) >> L2_PAGETABLE_SHIFT_PAE) & (L2_PAGETABLE_ENTRIES_PAE - 1))
111 #define l3_table_offset_pae(_a) \
112 (((_a) >> L3_PAGETABLE_SHIFT_PAE) & (L3_PAGETABLE_ENTRIES_PAE - 1))
114 #define l1_table_offset_x86_64(_a) \
115 (((_a) >> L1_PAGETABLE_SHIFT_X86_64) & (L1_PAGETABLE_ENTRIES_X86_64 - 1))
116 #define l2_table_offset_x86_64(_a) \
117 (((_a) >> L2_PAGETABLE_SHIFT_X86_64) & (L2_PAGETABLE_ENTRIES_X86_64 - 1))
118 #define l3_table_offset_x86_64(_a) \
119 (((_a) >> L3_PAGETABLE_SHIFT_X86_64) & (L3_PAGETABLE_ENTRIES_X86_64 - 1))
120 #define l4_table_offset_x86_64(_a) \
121 (((_a) >> L4_PAGETABLE_SHIFT_X86_64) & (L4_PAGETABLE_ENTRIES_X86_64 - 1))
123 #if defined(__i386__)
124 #define l1_table_offset(_a) l1_table_offset_i386(_a)
125 #define l2_table_offset(_a) l2_table_offset_i386(_a)
126 #elif defined(__x86_64__)
127 #define l1_table_offset(_a) l1_table_offset_x86_64(_a)
128 #define l2_table_offset(_a) l2_table_offset_x86_64(_a)
129 #define l3_table_offset(_a) l3_table_offset_x86_64(_a)
130 #define l4_table_offset(_a) l4_table_offset_x86_64(_a)
131 #endif
133 #define PAGE_SHIFT_X86 12
134 #define PAGE_SIZE_X86 (1UL << PAGE_SHIFT_X86)
135 #define PAGE_MASK_X86 (~(PAGE_SIZE_X86-1))
137 #define PAGE_SHIFT_IA64 14
138 #define PAGE_SIZE_IA64 (1UL << PAGE_SHIFT_IA64)
139 #define PAGE_MASK_IA64 (~(PAGE_SIZE_IA64-1))
141 #define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1))
144 /* XXX SMH: following skanky macros rely on variable p2m_size being set */
145 /* XXX TJD: also, "guest_width" should be the guest's sizeof(unsigned long) */
147 /* Number of xen_pfn_t in a page */
149 #define FPP (PAGE_SIZE/(guest_width))
151 /* Number of entries in the pfn_to_mfn_frame_list_list */
152 #define P2M_FLL_ENTRIES (((p2m_size)+(FPP*FPP)-1)/(FPP*FPP))
154 /* Number of entries in the pfn_to_mfn_frame_list */
155 #define P2M_FL_ENTRIES (((p2m_size)+FPP-1)/FPP)
157 /* Size in bytes of the pfn_to_mfn_frame_list */
158 #define P2M_FL_SIZE ((P2M_FL_ENTRIES)*(guest_width))
160 /* Masks for PTE<->PFN conversions */
161 #define MADDR_BITS_X86 ((guest_width == 8) ? 52 : 44)
162 #define MFN_MASK_X86 ((1ULL << (MADDR_BITS_X86 - PAGE_SHIFT_X86)) - 1)
163 #define MADDR_MASK_X86 (MFN_MASK_X86 << PAGE_SHIFT_X86)
166 #define PAEKERN_no 0
167 #define PAEKERN_yes 1
168 #define PAEKERN_extended_cr3 2
169 #define PAEKERN_bimodal 3
171 int xc_copy_to_domain_page(int xc_handle, uint32_t domid,
172 unsigned long dst_pfn, const char *src_page);
174 int pin_table(int xc_handle, unsigned int type, unsigned long mfn,
175 domid_t dom);
177 #endif /* XG_PRIVATE_H */