ia64/xen-unstable

view tools/libxc/xc_dom.h @ 16187:dc2ff26bbdf6

ia64: Fix ia64 PV domain creation with new vhpt-size parameter.
Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com>
author Keir Fraser <keir@xensource.com>
date Mon Oct 22 14:21:13 2007 +0100 (2007-10-22)
parents 5c7a1e3abd54
children c8d9ade45781
line source
1 #include <xen/libelf.h>
3 #define INVALID_P2M_ENTRY ((xen_pfn_t)-1)
5 /* --- typedefs and structs ---------------------------------------- */
7 typedef uint64_t xen_vaddr_t;
8 typedef uint64_t xen_paddr_t;
10 #define PRIpfn PRI_xen_pfn
12 struct xc_dom_seg {
13 xen_vaddr_t vstart;
14 xen_vaddr_t vend;
15 xen_pfn_t pfn;
16 };
18 struct xc_dom_mem {
19 struct xc_dom_mem *next;
20 void *mmap_ptr;
21 size_t mmap_len;
22 unsigned char memory[0];
23 };
25 struct xc_dom_phys {
26 struct xc_dom_phys *next;
27 void *ptr;
28 xen_pfn_t first;
29 xen_pfn_t count;
30 };
32 struct xc_dom_image {
33 /* files */
34 void *kernel_blob;
35 size_t kernel_size;
36 void *ramdisk_blob;
37 size_t ramdisk_size;
39 /* arguments and parameters */
40 char *cmdline;
41 uint32_t f_requested[XENFEAT_NR_SUBMAPS];
43 /* info from (elf) kernel image */
44 struct elf_dom_parms parms;
45 char *guest_type;
47 /* memory layout */
48 struct xc_dom_seg kernel_seg;
49 struct xc_dom_seg ramdisk_seg;
50 struct xc_dom_seg p2m_seg;
51 struct xc_dom_seg pgtables_seg;
52 struct xc_dom_seg devicetree_seg;
53 xen_pfn_t start_info_pfn;
54 xen_pfn_t console_pfn;
55 xen_pfn_t xenstore_pfn;
56 xen_pfn_t shared_info_pfn;
57 xen_pfn_t bootstack_pfn;
58 xen_vaddr_t virt_alloc_end;
59 xen_vaddr_t bsd_symtab_start;
61 /* initial page tables */
62 unsigned int pgtables;
63 unsigned int pg_l4;
64 unsigned int pg_l3;
65 unsigned int pg_l2;
66 unsigned int pg_l1;
67 unsigned int alloc_bootstack;
68 unsigned int extra_pages;
69 xen_vaddr_t virt_pgtab_end;
71 /* other state info */
72 uint32_t f_active[XENFEAT_NR_SUBMAPS];
73 xen_pfn_t *p2m_host;
74 void *p2m_guest;
76 /* physical memory */
77 xen_pfn_t total_pages;
78 struct xc_dom_phys *phys_pages;
79 int realmodearea_log;
81 /* malloc memory pool */
82 struct xc_dom_mem *memblocks;
84 /* memory footprint stats */
85 size_t alloc_malloc;
86 size_t alloc_mem_map;
87 size_t alloc_file_map;
88 size_t alloc_domU_map;
90 /* misc xen domain config stuff */
91 unsigned long flags;
92 unsigned int console_evtchn;
93 unsigned int xenstore_evtchn;
94 xen_pfn_t shared_info_mfn;
96 int guest_xc;
97 domid_t guest_domid;
98 int8_t vhpt_size_log2; /* for IA64 */
99 int shadow_enabled;
101 int xen_version;
102 xen_capabilities_info_t xen_caps;
104 /* kernel loader, arch hooks */
105 struct xc_dom_loader *kernel_loader;
106 void *private_loader;
108 /* kernel loader */
109 struct xc_dom_arch *arch_hooks;
110 };
112 /* --- pluggable kernel loader ------------------------------------- */
114 struct xc_dom_loader {
115 char *name;
116 int (*probe) (struct xc_dom_image * dom);
117 int (*parser) (struct xc_dom_image * dom);
118 int (*loader) (struct xc_dom_image * dom);
120 struct xc_dom_loader *next;
121 };
123 #define __init __attribute__ ((constructor))
124 void xc_dom_register_loader(struct xc_dom_loader *loader);
126 /* --- arch specific hooks ----------------------------------------- */
128 struct xc_dom_arch {
129 /* pagetable setup */
130 int (*alloc_magic_pages) (struct xc_dom_image * dom);
131 int (*count_pgtables) (struct xc_dom_image * dom);
132 int (*setup_pgtables) (struct xc_dom_image * dom);
134 /* arch-specific data structs setup */
135 int (*start_info) (struct xc_dom_image * dom);
136 int (*shared_info) (struct xc_dom_image * dom, void *shared_info);
137 int (*vcpu) (struct xc_dom_image * dom, void *vcpu_ctxt);
139 char *guest_type;
140 char *native_protocol;
141 int page_shift;
142 int sizeof_pfn;
144 struct xc_dom_arch *next;
145 };
146 void xc_dom_register_arch_hooks(struct xc_dom_arch *hooks);
148 #define XC_DOM_PAGE_SHIFT(dom) ((dom)->arch_hooks->page_shift)
149 #define XC_DOM_PAGE_SIZE(dom) (1 << (dom)->arch_hooks->page_shift)
151 /* --- main functions ---------------------------------------------- */
153 struct xc_dom_image *xc_dom_allocate(const char *cmdline, const char *features);
154 void xc_dom_release_phys(struct xc_dom_image *dom);
155 void xc_dom_release(struct xc_dom_image *dom);
156 int xc_dom_mem_init(struct xc_dom_image *dom, unsigned int mem_mb);
158 size_t xc_dom_check_gzip(void *blob, size_t ziplen);
159 int xc_dom_do_gunzip(void *src, size_t srclen, void *dst, size_t dstlen);
160 int xc_dom_try_gunzip(struct xc_dom_image *dom, void **blob, size_t * size);
162 int xc_dom_kernel_file(struct xc_dom_image *dom, const char *filename);
163 int xc_dom_ramdisk_file(struct xc_dom_image *dom, const char *filename);
164 int xc_dom_kernel_mem(struct xc_dom_image *dom, const void *mem,
165 size_t memsize);
166 int xc_dom_ramdisk_mem(struct xc_dom_image *dom, const void *mem,
167 size_t memsize);
169 int xc_dom_parse_image(struct xc_dom_image *dom);
170 int xc_dom_build_image(struct xc_dom_image *dom);
171 int xc_dom_update_guest_p2m(struct xc_dom_image *dom);
173 int xc_dom_boot_xen_init(struct xc_dom_image *dom, int xc, domid_t domid);
174 int xc_dom_boot_mem_init(struct xc_dom_image *dom);
175 void *xc_dom_boot_domU_map(struct xc_dom_image *dom, xen_pfn_t pfn,
176 xen_pfn_t count);
177 int xc_dom_boot_image(struct xc_dom_image *dom);
178 int xc_dom_compat_check(struct xc_dom_image *dom);
180 /* --- debugging bits ---------------------------------------------- */
182 extern FILE *xc_dom_logfile;
184 void xc_dom_loginit(void);
185 int xc_dom_printf(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
186 int xc_dom_panic_func(const char *file, int line, xc_error_code err,
187 const char *fmt, ...)
188 __attribute__ ((format(printf, 4, 5)));
189 #define xc_dom_panic(err, fmt, args...) \
190 xc_dom_panic_func(__FILE__, __LINE__, err, fmt, ## args)
191 #define xc_dom_trace(mark) \
192 xc_dom_printf("%s:%d: trace %s\n", __FILE__, __LINE__, mark)
194 void xc_dom_log_memory_footprint(struct xc_dom_image *dom);
196 /* --- simple memory pool ------------------------------------------ */
198 void *xc_dom_malloc(struct xc_dom_image *dom, size_t size);
199 void *xc_dom_malloc_page_aligned(struct xc_dom_image *dom, size_t size);
200 void *xc_dom_malloc_filemap(struct xc_dom_image *dom,
201 const char *filename, size_t * size);
202 char *xc_dom_strdup(struct xc_dom_image *dom, const char *str);
204 /* --- alloc memory pool ------------------------------------------- */
206 int xc_dom_alloc_page(struct xc_dom_image *dom, char *name);
207 int xc_dom_alloc_segment(struct xc_dom_image *dom,
208 struct xc_dom_seg *seg, char *name,
209 xen_vaddr_t start, xen_vaddr_t size);
211 /* --- misc bits --------------------------------------------------- */
213 void *xc_dom_pfn_to_ptr(struct xc_dom_image *dom, xen_pfn_t first,
214 xen_pfn_t count);
215 void xc_dom_unmap_one(struct xc_dom_image *dom, xen_pfn_t pfn);
216 void xc_dom_unmap_all(struct xc_dom_image *dom);
218 static inline void *xc_dom_seg_to_ptr(struct xc_dom_image *dom,
219 struct xc_dom_seg *seg)
220 {
221 xen_vaddr_t segsize = seg->vend - seg->vstart;
222 unsigned int page_size = XC_DOM_PAGE_SIZE(dom);
223 xen_pfn_t pages = (segsize + page_size - 1) / page_size;
225 return xc_dom_pfn_to_ptr(dom, seg->pfn, pages);
226 }
228 static inline void *xc_dom_vaddr_to_ptr(struct xc_dom_image *dom,
229 xen_vaddr_t vaddr)
230 {
231 unsigned int page_size = XC_DOM_PAGE_SIZE(dom);
232 xen_pfn_t page = (vaddr - dom->parms.virt_base) / page_size;
233 unsigned int offset = (vaddr - dom->parms.virt_base) % page_size;
234 void *ptr = xc_dom_pfn_to_ptr(dom, page, 0);
235 return (ptr ? (ptr + offset) : NULL);
236 }
238 static inline int xc_dom_feature_translated(struct xc_dom_image *dom)
239 {
240 return elf_xen_feature_get(XENFEAT_auto_translated_physmap, dom->f_active);
241 }
243 static inline xen_pfn_t xc_dom_p2m_host(struct xc_dom_image *dom, xen_pfn_t pfn)
244 {
245 if (dom->shadow_enabled)
246 return pfn;
247 return dom->p2m_host[pfn];
248 }
250 static inline xen_pfn_t xc_dom_p2m_guest(struct xc_dom_image *dom,
251 xen_pfn_t pfn)
252 {
253 if (xc_dom_feature_translated(dom))
254 return pfn;
255 return dom->p2m_host[pfn];
256 }
258 /* --- arch bits --------------------------------------------------- */
260 int arch_setup_meminit(struct xc_dom_image *dom);
261 int arch_setup_bootearly(struct xc_dom_image *dom);
262 int arch_setup_bootlate(struct xc_dom_image *dom);
264 /*
265 * Local variables:
266 * mode: C
267 * c-set-style: "BSD"
268 * c-basic-offset: 4
269 * tab-width: 4
270 * indent-tabs-mode: nil
271 * End:
272 */