direct-io.hg

view tools/libxc/xenctrl.h @ 12005:cf05aabe6e65

[LIBXC][IA64] fix build warning

With warnings becoming errors, this fixes the libxc build on ia64

Signed-off-by: Alex Williamson <alex.williamson@hp.com>
author awilliam@xenbuild.aw
date Wed Oct 25 15:29:00 2006 -0600 (2006-10-25)
parents 5525b18b7224
children 7b5115221dfc
line source
1 /******************************************************************************
2 * xenctrl.h
3 *
4 * A library for low-level access to the Xen control interfaces.
5 *
6 * Copyright (c) 2003-2004, K A Fraser.
7 */
9 #ifndef XENCTRL_H
10 #define XENCTRL_H
12 /* Tell the Xen public headers we are a user-space tools build. */
13 #ifndef __XEN_TOOLS__
14 #define __XEN_TOOLS__ 1
15 #endif
17 #include <stddef.h>
18 #include <stdint.h>
19 #include <xen/xen.h>
20 #include <xen/domctl.h>
21 #include <xen/sysctl.h>
22 #include <xen/version.h>
23 #include <xen/event_channel.h>
24 #include <xen/sched.h>
25 #include <xen/memory.h>
26 #include <xen/acm.h>
27 #include <xen/acm_ops.h>
29 #ifdef __ia64__
30 #define XC_PAGE_SHIFT 14
31 #else
32 #define XC_PAGE_SHIFT 12
33 #endif
34 #define XC_PAGE_SIZE (1UL << XC_PAGE_SHIFT)
35 #define XC_PAGE_MASK (~(XC_PAGE_SIZE-1))
37 /*
38 * DEFINITIONS FOR CPU BARRIERS
39 */
41 #if defined(__i386__)
42 #define mb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
43 #define rmb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
44 #define wmb() __asm__ __volatile__ ( "" : : : "memory")
45 #elif defined(__x86_64__)
46 #define mb() __asm__ __volatile__ ( "mfence" : : : "memory")
47 #define rmb() __asm__ __volatile__ ( "lfence" : : : "memory")
48 #define wmb() __asm__ __volatile__ ( "" : : : "memory")
49 #elif defined(__ia64__)
50 /* FIXME */
51 #define mb()
52 #define rmb()
53 #define wmb()
54 #elif defined(__powerpc__)
55 /* XXX loosen these up later */
56 #define mb() __asm__ __volatile__ ("sync" : : : "memory")
57 #define rmb() __asm__ __volatile__ ("sync" : : : "memory") /* lwsync? */
58 #define wmb() __asm__ __volatile__ ("sync" : : : "memory") /* eieio? */
59 #else
60 #error "Define barriers"
61 #endif
63 /*
64 * INITIALIZATION FUNCTIONS
65 */
67 /**
68 * This function opens a handle to the hypervisor interface. This function can
69 * be called multiple times within a single process. Multiple processes can
70 * have an open hypervisor interface at the same time.
71 *
72 * Each call to this function should have a corresponding call to
73 * xc_interface_close().
74 *
75 * This function can fail if the caller does not have superuser permission or
76 * if a Xen-enabled kernel is not currently running.
77 *
78 * @return a handle to the hypervisor interface or -1 on failure
79 */
80 int xc_interface_open(void);
82 /**
83 * This function closes an open hypervisor interface.
84 *
85 * This function can fail if the handle does not represent an open interface or
86 * if there were problems closing the interface.
87 *
88 * @parm xc_handle a handle to an open hypervisor interface
89 * @return 0 on success, -1 otherwise.
90 */
91 int xc_interface_close(int xc_handle);
93 /*
94 * KERNEL INTERFACES
95 */
97 /*
98 * Resolve a kernel device name (e.g., "evtchn", "blktap0") into a kernel
99 * device number. Returns -1 on error (and sets errno).
100 */
101 int xc_find_device_number(const char *name);
103 /*
104 * DOMAIN DEBUGGING FUNCTIONS
105 */
107 typedef struct xc_core_header {
108 unsigned int xch_magic;
109 unsigned int xch_nr_vcpus;
110 unsigned int xch_nr_pages;
111 unsigned int xch_ctxt_offset;
112 unsigned int xch_index_offset;
113 unsigned int xch_pages_offset;
114 } xc_core_header_t;
116 #define XC_CORE_MAGIC 0xF00FEBED
118 #ifdef __linux__
120 #include <sys/ptrace.h>
121 #include <thread_db.h>
123 void * map_domain_va_core(
124 unsigned long domfd,
125 int cpu,
126 void *guest_va,
127 vcpu_guest_context_t *ctxt);
129 int xc_waitdomain_core(
130 int xc_handle,
131 int domain,
132 int *status,
133 int options,
134 vcpu_guest_context_t *ctxt);
136 typedef void (*thr_ev_handler_t)(long);
138 void xc_register_event_handler(
139 thr_ev_handler_t h,
140 td_event_e e);
142 long xc_ptrace(
143 int xc_handle,
144 enum __ptrace_request request,
145 uint32_t domid,
146 long addr,
147 long data);
149 int xc_waitdomain(
150 int xc_handle,
151 int domain,
152 int *status,
153 int options);
155 #endif /* __linux__ */
157 /*
158 * DOMAIN MANAGEMENT FUNCTIONS
159 */
161 typedef struct {
162 uint32_t domid;
163 uint32_t ssidref;
164 unsigned int dying:1, crashed:1, shutdown:1,
165 paused:1, blocked:1, running:1;
166 unsigned int shutdown_reason; /* only meaningful if shutdown==1 */
167 unsigned long nr_pages;
168 unsigned long shared_info_frame;
169 uint64_t cpu_time;
170 unsigned long max_memkb;
171 unsigned int nr_online_vcpus;
172 unsigned int max_vcpu_id;
173 xen_domain_handle_t handle;
174 } xc_dominfo_t;
176 typedef xen_domctl_getdomaininfo_t xc_domaininfo_t;
177 int xc_domain_create(int xc_handle,
178 uint32_t ssidref,
179 xen_domain_handle_t handle,
180 uint32_t *pdomid);
183 /* Functions to produce a dump of a given domain
184 * xc_domain_dumpcore - produces a dump to a specified file
185 * xc_domain_dumpcore_via_callback - produces a dump, using a specified
186 * callback function
187 */
188 int xc_domain_dumpcore(int xc_handle,
189 uint32_t domid,
190 const char *corename);
192 /* Define the callback function type for xc_domain_dumpcore_via_callback.
193 *
194 * This function is called by the coredump code for every "write",
195 * and passes an opaque object for the use of the function and
196 * created by the caller of xc_domain_dumpcore_via_callback.
197 */
198 typedef int (dumpcore_rtn_t)(void *arg, char *buffer, unsigned int length);
200 int xc_domain_dumpcore_via_callback(int xc_handle,
201 uint32_t domid,
202 void *arg,
203 dumpcore_rtn_t dump_rtn);
205 /*
206 * This function sets the maximum number of vcpus that a domain may create.
207 *
208 * @parm xc_handle a handle to an open hypervisor interface.
209 * @parm domid the domain id in which vcpus are to be created.
210 * @parm max the maximum number of vcpus that the domain may create.
211 * @return 0 on success, -1 on failure.
212 */
213 int xc_domain_max_vcpus(int xc_handle,
214 uint32_t domid,
215 unsigned int max);
217 /**
218 * This function pauses a domain. A paused domain still exists in memory
219 * however it does not receive any timeslices from the hypervisor.
220 *
221 * @parm xc_handle a handle to an open hypervisor interface
222 * @parm domid the domain id to pause
223 * @return 0 on success, -1 on failure.
224 */
225 int xc_domain_pause(int xc_handle,
226 uint32_t domid);
227 /**
228 * This function unpauses a domain. The domain should have been previously
229 * paused.
230 *
231 * @parm xc_handle a handle to an open hypervisor interface
232 * @parm domid the domain id to unpause
233 * return 0 on success, -1 on failure
234 */
235 int xc_domain_unpause(int xc_handle,
236 uint32_t domid);
238 /**
239 * This function will destroy a domain. Destroying a domain removes the domain
240 * completely from memory. This function should be called after sending the
241 * domain a SHUTDOWN control message to free up the domain resources.
242 *
243 * @parm xc_handle a handle to an open hypervisor interface
244 * @parm domid the domain id to destroy
245 * @return 0 on success, -1 on failure
246 */
247 int xc_domain_destroy(int xc_handle,
248 uint32_t domid);
250 /**
251 * This function will shutdown a domain. This is intended for use in
252 * fully-virtualized domains where this operation is analogous to the
253 * sched_op operations in a paravirtualized domain. The caller is
254 * expected to give the reason for the shutdown.
255 *
256 * @parm xc_handle a handle to an open hypervisor interface
257 * @parm domid the domain id to destroy
258 * @parm reason is the reason (SHUTDOWN_xxx) for the shutdown
259 * @return 0 on success, -1 on failure
260 */
261 int xc_domain_shutdown(int xc_handle,
262 uint32_t domid,
263 int reason);
265 int xc_vcpu_setaffinity(int xc_handle,
266 uint32_t domid,
267 int vcpu,
268 uint64_t cpumap);
269 int xc_vcpu_getaffinity(int xc_handle,
270 uint32_t domid,
271 int vcpu,
272 uint64_t *cpumap);
274 /**
275 * This function will return information about one or more domains. It is
276 * designed to iterate over the list of domains. If a single domain is
277 * requested, this function will return the next domain in the list - if
278 * one exists. It is, therefore, important in this case to make sure the
279 * domain requested was the one returned.
280 *
281 * @parm xc_handle a handle to an open hypervisor interface
282 * @parm first_domid the first domain to enumerate information from. Domains
283 * are currently enumerate in order of creation.
284 * @parm max_doms the number of elements in info
285 * @parm info an array of max_doms size that will contain the information for
286 * the enumerated domains.
287 * @return the number of domains enumerated or -1 on error
288 */
289 int xc_domain_getinfo(int xc_handle,
290 uint32_t first_domid,
291 unsigned int max_doms,
292 xc_dominfo_t *info);
295 /**
296 * This function will set the execution context for the specified vcpu.
297 *
298 * @parm xc_handle a handle to an open hypervisor interface
299 * @parm domid the domain to set the vcpu context for
300 * @parm vcpu the vcpu number for the context
301 * @parm ctxt pointer to the the cpu context with the values to set
302 * @return the number of domains enumerated or -1 on error
303 */
304 int xc_vcpu_setcontext(int xc_handle,
305 uint32_t domid,
306 uint32_t vcpu,
307 vcpu_guest_context_t *ctxt);
308 /**
309 * This function will return information about one or more domains, using a
310 * single hypercall. The domain information will be stored into the supplied
311 * array of xc_domaininfo_t structures.
312 *
313 * @parm xc_handle a handle to an open hypervisor interface
314 * @parm first_domain the first domain to enumerate information from.
315 * Domains are currently enumerate in order of creation.
316 * @parm max_domains the number of elements in info
317 * @parm info an array of max_doms size that will contain the information for
318 * the enumerated domains.
319 * @return the number of domains enumerated or -1 on error
320 */
321 int xc_domain_getinfolist(int xc_handle,
322 uint32_t first_domain,
323 unsigned int max_domains,
324 xc_domaininfo_t *info);
326 /**
327 * This function returns information about the execution context of a
328 * particular vcpu of a domain.
329 *
330 * @parm xc_handle a handle to an open hypervisor interface
331 * @parm domid the domain to get information from
332 * @parm vcpu the vcpu number
333 * @parm ctxt a pointer to a structure to store the execution context of the
334 * domain
335 * @return 0 on success, -1 on failure
336 */
337 int xc_vcpu_getcontext(int xc_handle,
338 uint32_t domid,
339 uint32_t vcpu,
340 vcpu_guest_context_t *ctxt);
342 typedef xen_domctl_getvcpuinfo_t xc_vcpuinfo_t;
343 int xc_vcpu_getinfo(int xc_handle,
344 uint32_t domid,
345 uint32_t vcpu,
346 xc_vcpuinfo_t *info);
348 int xc_domain_setcpuweight(int xc_handle,
349 uint32_t domid,
350 float weight);
351 long long xc_domain_get_cpu_usage(int xc_handle,
352 domid_t domid,
353 int vcpu);
355 int xc_domain_sethandle(int xc_handle, uint32_t domid,
356 xen_domain_handle_t handle);
358 typedef xen_domctl_shadow_op_stats_t xc_shadow_op_stats_t;
359 int xc_shadow_control(int xc_handle,
360 uint32_t domid,
361 unsigned int sop,
362 unsigned long *dirty_bitmap,
363 unsigned long pages,
364 unsigned long *mb,
365 uint32_t mode,
366 xc_shadow_op_stats_t *stats);
368 int xc_sedf_domain_set(int xc_handle,
369 uint32_t domid,
370 uint64_t period, uint64_t slice,
371 uint64_t latency, uint16_t extratime,
372 uint16_t weight);
374 int xc_sedf_domain_get(int xc_handle,
375 uint32_t domid,
376 uint64_t* period, uint64_t *slice,
377 uint64_t *latency, uint16_t *extratime,
378 uint16_t *weight);
380 int xc_sched_credit_domain_set(int xc_handle,
381 uint32_t domid,
382 struct xen_domctl_sched_credit *sdom);
384 int xc_sched_credit_domain_get(int xc_handle,
385 uint32_t domid,
386 struct xen_domctl_sched_credit *sdom);
388 /*
389 * EVENT CHANNEL FUNCTIONS
390 */
392 /**
393 * This function allocates an unbound port. Ports are named endpoints used for
394 * interdomain communication. This function is most useful in opening a
395 * well-known port within a domain to receive events on.
396 *
397 * @parm xc_handle a handle to an open hypervisor interface
398 * @parm dom the ID of the local domain (the 'allocatee')
399 * @parm remote_dom the ID of the domain who will later bind
400 * @return allocated port (in @dom) on success, -1 on failure
401 */
402 int xc_evtchn_alloc_unbound(int xc_handle,
403 uint32_t dom,
404 uint32_t remote_dom);
406 int xc_physdev_pci_access_modify(int xc_handle,
407 uint32_t domid,
408 int bus,
409 int dev,
410 int func,
411 int enable);
413 int xc_readconsolering(int xc_handle,
414 char **pbuffer,
415 unsigned int *pnr_chars,
416 int clear);
418 typedef xen_sysctl_physinfo_t xc_physinfo_t;
419 int xc_physinfo(int xc_handle,
420 xc_physinfo_t *info);
422 int xc_sched_id(int xc_handle,
423 int *sched_id);
425 int xc_domain_setmaxmem(int xc_handle,
426 uint32_t domid,
427 unsigned int max_memkb);
429 int xc_domain_set_time_offset(int xc_handle,
430 uint32_t domid,
431 int32_t time_offset_seconds);
433 int xc_domain_memory_increase_reservation(int xc_handle,
434 uint32_t domid,
435 unsigned long nr_extents,
436 unsigned int extent_order,
437 unsigned int address_bits,
438 xen_pfn_t *extent_start);
440 int xc_domain_memory_decrease_reservation(int xc_handle,
441 uint32_t domid,
442 unsigned long nr_extents,
443 unsigned int extent_order,
444 xen_pfn_t *extent_start);
446 int xc_domain_memory_populate_physmap(int xc_handle,
447 uint32_t domid,
448 unsigned long nr_extents,
449 unsigned int extent_order,
450 unsigned int address_bits,
451 xen_pfn_t *extent_start);
453 int xc_domain_translate_gpfn_list(int xc_handle,
454 uint32_t domid,
455 unsigned long nr_gpfns,
456 xen_pfn_t *gpfn_list,
457 xen_pfn_t *mfn_list);
459 int xc_domain_ioport_permission(int xc_handle,
460 uint32_t domid,
461 uint32_t first_port,
462 uint32_t nr_ports,
463 uint32_t allow_access);
465 int xc_domain_irq_permission(int xc_handle,
466 uint32_t domid,
467 uint8_t pirq,
468 uint8_t allow_access);
470 int xc_domain_iomem_permission(int xc_handle,
471 uint32_t domid,
472 unsigned long first_mfn,
473 unsigned long nr_mfns,
474 uint8_t allow_access);
476 unsigned long xc_make_page_below_4G(int xc_handle, uint32_t domid,
477 unsigned long mfn);
479 typedef xen_sysctl_perfc_desc_t xc_perfc_desc_t;
480 typedef xen_sysctl_perfc_val_t xc_perfc_val_t;
481 /* IMPORTANT: The caller is responsible for mlock()'ing the @desc and @val
482 arrays. */
483 int xc_perfc_control(int xc_handle,
484 uint32_t op,
485 xc_perfc_desc_t *desc,
486 xc_perfc_val_t *val,
487 int *nbr_desc,
488 int *nbr_val);
490 /**
491 * Memory maps a range within one domain to a local address range. Mappings
492 * should be unmapped with munmap and should follow the same rules as mmap
493 * regarding page alignment. Returns NULL on failure.
494 *
495 * In Linux, the ring queue for the control channel is accessible by mapping
496 * the shared_info_frame (from xc_domain_getinfo()) + 2048. The structure
497 * stored there is of type control_if_t.
498 *
499 * @parm xc_handle a handle on an open hypervisor interface
500 * @parm dom the domain to map memory from
501 * @parm size the amount of memory to map (in multiples of page size)
502 * @parm prot same flag as in mmap().
503 * @parm mfn the frame address to map.
504 */
505 void *xc_map_foreign_range(int xc_handle, uint32_t dom,
506 int size, int prot,
507 unsigned long mfn );
509 void *xc_map_foreign_batch(int xc_handle, uint32_t dom, int prot,
510 xen_pfn_t *arr, int num );
512 /**
513 * Translates a virtual address in the context of a given domain and
514 * vcpu returning the machine page frame number of the associated
515 * page.
516 *
517 * @parm xc_handle a handle on an open hypervisor interface
518 * @parm dom the domain to perform the translation in
519 * @parm vcpu the vcpu to perform the translation on
520 * @parm virt the virtual address to translate
521 */
522 unsigned long xc_translate_foreign_address(int xc_handle, uint32_t dom,
523 int vcpu, unsigned long long virt);
525 int xc_get_pfn_list(int xc_handle, uint32_t domid, xen_pfn_t *pfn_buf,
526 unsigned long max_pfns);
528 unsigned long xc_ia64_fpsr_default(void);
530 int xc_ia64_get_pfn_list(int xc_handle, uint32_t domid,
531 xen_pfn_t *pfn_buf,
532 unsigned int start_page, unsigned int nr_pages);
534 int xc_copy_to_domain_page(int xc_handle, uint32_t domid,
535 unsigned long dst_pfn, const char *src_page);
537 int xc_clear_domain_page(int xc_handle, uint32_t domid,
538 unsigned long dst_pfn);
540 long xc_get_max_pages(int xc_handle, uint32_t domid);
542 int xc_mmuext_op(int xc_handle, struct mmuext_op *op, unsigned int nr_ops,
543 domid_t dom);
545 int xc_memory_op(int xc_handle, int cmd, void *arg);
547 int xc_get_pfn_type_batch(int xc_handle, uint32_t dom,
548 int num, unsigned long *arr);
551 /* Get current total pages allocated to a domain. */
552 long xc_get_tot_pages(int xc_handle, uint32_t domid);
555 /*
556 * Trace Buffer Operations
557 */
559 /**
560 * xc_tbuf_enable - enable tracing buffers
561 *
562 * @parm xc_handle a handle to an open hypervisor interface
563 * @parm cnt size of tracing buffers to create (in pages)
564 * @parm mfn location to store mfn of the trace buffers to
565 * @parm size location to store the size (in bytes) of a trace buffer to
566 *
567 * Gets the machine address of the trace pointer area and the size of the
568 * per CPU buffers.
569 */
570 int xc_tbuf_enable(int xc_handle, size_t cnt, unsigned long *mfn,
571 unsigned long *size);
573 /*
574 * Disable tracing buffers.
575 */
576 int xc_tbuf_disable(int xc_handle);
578 /**
579 * This function sets the size of the trace buffers. Setting the size
580 * is currently a one-shot operation that may be performed either at boot
581 * time or via this interface, not both. The buffer size must be set before
582 * enabling tracing.
583 *
584 * @parm xc_handle a handle to an open hypervisor interface
585 * @parm size the size in pages per cpu for the trace buffers
586 * @return 0 on success, -1 on failure.
587 */
588 int xc_tbuf_set_size(int xc_handle, unsigned long size);
590 /**
591 * This function retrieves the current size of the trace buffers.
592 * Note that the size returned is in terms of bytes, not pages.
594 * @parm xc_handle a handle to an open hypervisor interface
595 * @parm size will contain the size in bytes for the trace buffers
596 * @return 0 on success, -1 on failure.
597 */
598 int xc_tbuf_get_size(int xc_handle, unsigned long *size);
600 int xc_tbuf_set_cpu_mask(int xc_handle, uint32_t mask);
602 int xc_tbuf_set_evt_mask(int xc_handle, uint32_t mask);
604 int xc_domctl(int xc_handle, struct xen_domctl *domctl);
605 int xc_sysctl(int xc_handle, struct xen_sysctl *sysctl);
607 int xc_version(int xc_handle, int cmd, void *arg);
609 /*
610 * MMU updates.
611 */
612 #define MAX_MMU_UPDATES 1024
613 struct xc_mmu {
614 mmu_update_t updates[MAX_MMU_UPDATES];
615 int idx;
616 domid_t subject;
617 };
618 typedef struct xc_mmu xc_mmu_t;
619 xc_mmu_t *xc_init_mmu_updates(int xc_handle, domid_t dom);
620 int xc_add_mmu_update(int xc_handle, xc_mmu_t *mmu,
621 unsigned long long ptr, unsigned long long val);
622 int xc_finish_mmu_updates(int xc_handle, xc_mmu_t *mmu);
624 int xc_acm_op(int xc_handle, int cmd, void *arg, size_t arg_size);
626 /*
627 * Return a handle to the event channel driver, or -1 on failure, in which case
628 * errno will be set appropriately.
629 */
630 int xc_evtchn_open(void);
632 /*
633 * Close a handle previously allocated with xc_evtchn_open().
634 */
635 int xc_evtchn_close(int xce_handle);
637 /*
638 * Return an fd that can be select()ed on for further calls to
639 * xc_evtchn_pending().
640 */
641 int xc_evtchn_fd(int xce_handle);
643 /*
644 * Notify the given event channel. Returns -1 on failure, in which case
645 * errno will be set appropriately.
646 */
647 int xc_evtchn_notify(int xce_handle, evtchn_port_t port);
649 /*
650 * Returns a new event port bound to the remote port for the given domain ID,
651 * or -1 on failure, in which case errno will be set appropriately.
652 */
653 evtchn_port_t xc_evtchn_bind_interdomain(int xce_handle, int domid,
654 evtchn_port_t remote_port);
656 /*
657 * Unbind the given event channel. Returns -1 on failure, in which case errno
658 * will be set appropriately.
659 */
660 int xc_evtchn_unbind(int xce_handle, evtchn_port_t port);
662 /*
663 * Bind an event channel to the given VIRQ. Returns the event channel bound to
664 * the VIRQ, or -1 on failure, in which case errno will be set appropriately.
665 */
666 evtchn_port_t xc_evtchn_bind_virq(int xce_handle, unsigned int virq);
668 /*
669 * Return the next event channel to become pending, or -1 on failure, in which
670 * case errno will be set appropriately.
671 */
672 evtchn_port_t xc_evtchn_pending(int xce_handle);
674 /*
675 * Unmask the given event channel. Returns -1 on failure, in which case errno
676 * will be set appropriately.
677 */
678 int xc_evtchn_unmask(int xce_handle, evtchn_port_t port);
680 #endif