direct-io.hg

view tools/libxc/xenctrl.h @ 11241:26b673aeff8b

Remove all traces of the obsolete BVT scheduler.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Wed Aug 23 17:14:38 2006 +0100 (2006-08-23)
parents 61eea55dce65
children 86d26e6ec89b
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 #include <stddef.h>
13 #include <stdint.h>
14 #include <sys/ptrace.h>
15 #include <xen/xen.h>
16 #include <xen/dom0_ops.h>
17 #include <xen/version.h>
18 #include <xen/event_channel.h>
19 #include <xen/sched.h>
20 #include <xen/sched_ctl.h>
21 #include <xen/memory.h>
22 #include <xen/acm.h>
23 #include <xen/acm_ops.h>
25 #ifdef __ia64__
26 #define XC_PAGE_SHIFT 14
27 #else
28 #define XC_PAGE_SHIFT 12
29 #endif
30 #define XC_PAGE_SIZE (1UL << XC_PAGE_SHIFT)
31 #define XC_PAGE_MASK (~(XC_PAGE_SIZE-1))
33 /*
34 * DEFINITIONS FOR CPU BARRIERS
35 */
37 #if defined(__i386__)
38 #define mb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
39 #define rmb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
40 #define wmb() __asm__ __volatile__ ( "" : : : "memory")
41 #elif defined(__x86_64__)
42 #define mb() __asm__ __volatile__ ( "mfence" : : : "memory")
43 #define rmb() __asm__ __volatile__ ( "lfence" : : : "memory")
44 #define wmb() __asm__ __volatile__ ( "" : : : "memory")
45 #elif defined(__ia64__)
46 /* FIXME */
47 #define mb()
48 #define rmb()
49 #define wmb()
50 #elif defined(__powerpc__)
51 /* XXX loosen these up later */
52 #define mb() __asm__ __volatile__ ("sync" : : : "memory")
53 #define rmb() __asm__ __volatile__ ("sync" : : : "memory") /* lwsync? */
54 #define wmb() __asm__ __volatile__ ("sync" : : : "memory") /* eieio? */
55 #else
56 #error "Define barriers"
57 #endif
59 /*
60 * INITIALIZATION FUNCTIONS
61 */
63 /**
64 * This function opens a handle to the hypervisor interface. This function can
65 * be called multiple times within a single process. Multiple processes can
66 * have an open hypervisor interface at the same time.
67 *
68 * Each call to this function should have a corresponding call to
69 * xc_interface_close().
70 *
71 * This function can fail if the caller does not have superuser permission or
72 * if a Xen-enabled kernel is not currently running.
73 *
74 * @return a handle to the hypervisor interface or -1 on failure
75 */
76 int xc_interface_open(void);
78 /**
79 * This function closes an open hypervisor interface.
80 *
81 * This function can fail if the handle does not represent an open interface or
82 * if there were problems closing the interface.
83 *
84 * @parm xc_handle a handle to an open hypervisor interface
85 * @return 0 on success, -1 otherwise.
86 */
87 int xc_interface_close(int xc_handle);
89 /*
90 * DOMAIN DEBUGGING FUNCTIONS
91 */
93 typedef struct xc_core_header {
94 unsigned int xch_magic;
95 unsigned int xch_nr_vcpus;
96 unsigned int xch_nr_pages;
97 unsigned int xch_ctxt_offset;
98 unsigned int xch_index_offset;
99 unsigned int xch_pages_offset;
100 } xc_core_header_t;
102 #define XC_CORE_MAGIC 0xF00FEBED
104 long xc_ptrace_core(
105 int xc_handle,
106 enum __ptrace_request request,
107 uint32_t domid,
108 long addr,
109 long data,
110 vcpu_guest_context_t *ctxt);
111 void * map_domain_va_core(
112 unsigned long domfd,
113 int cpu,
114 void *guest_va,
115 vcpu_guest_context_t *ctxt);
116 int xc_waitdomain_core(
117 int xc_handle,
118 int domain,
119 int *status,
120 int options,
121 vcpu_guest_context_t *ctxt);
123 /*
124 * DOMAIN MANAGEMENT FUNCTIONS
125 */
127 typedef struct {
128 uint32_t domid;
129 uint32_t ssidref;
130 unsigned int dying:1, crashed:1, shutdown:1,
131 paused:1, blocked:1, running:1;
132 unsigned int shutdown_reason; /* only meaningful if shutdown==1 */
133 unsigned long nr_pages;
134 unsigned long shared_info_frame;
135 uint64_t cpu_time;
136 unsigned long max_memkb;
137 unsigned int nr_online_vcpus;
138 unsigned int max_vcpu_id;
139 xen_domain_handle_t handle;
140 } xc_dominfo_t;
142 typedef dom0_getdomaininfo_t xc_domaininfo_t;
143 int xc_domain_create(int xc_handle,
144 uint32_t ssidref,
145 xen_domain_handle_t handle,
146 uint32_t *pdomid);
149 /* Functions to produce a dump of a given domain
150 * xc_domain_dumpcore - produces a dump to a specified file
151 * xc_domain_dumpcore_via_callback - produces a dump, using a specified
152 * callback function
153 */
154 int xc_domain_dumpcore(int xc_handle,
155 uint32_t domid,
156 const char *corename);
158 /* Define the callback function type for xc_domain_dumpcore_via_callback.
159 *
160 * This function is called by the coredump code for every "write",
161 * and passes an opaque object for the use of the function and
162 * created by the caller of xc_domain_dumpcore_via_callback.
163 */
164 typedef int (dumpcore_rtn_t)(void *arg, char *buffer, unsigned int length);
166 int xc_domain_dumpcore_via_callback(int xc_handle,
167 uint32_t domid,
168 void *arg,
169 dumpcore_rtn_t dump_rtn);
171 /*
172 * This function sets the maximum number of vcpus that a domain may create.
173 *
174 * @parm xc_handle a handle to an open hypervisor interface.
175 * @parm domid the domain id in which vcpus are to be created.
176 * @parm max the maximum number of vcpus that the domain may create.
177 * @return 0 on success, -1 on failure.
178 */
179 int xc_domain_max_vcpus(int xc_handle,
180 uint32_t domid,
181 unsigned int max);
183 /**
184 * This function pauses a domain. A paused domain still exists in memory
185 * however it does not receive any timeslices from the hypervisor.
186 *
187 * @parm xc_handle a handle to an open hypervisor interface
188 * @parm domid the domain id to pause
189 * @return 0 on success, -1 on failure.
190 */
191 int xc_domain_pause(int xc_handle,
192 uint32_t domid);
193 /**
194 * This function unpauses a domain. The domain should have been previously
195 * paused.
196 *
197 * @parm xc_handle a handle to an open hypervisor interface
198 * @parm domid the domain id to unpause
199 * return 0 on success, -1 on failure
200 */
201 int xc_domain_unpause(int xc_handle,
202 uint32_t domid);
204 /**
205 * This function will destroy a domain. Destroying a domain removes the domain
206 * completely from memory. This function should be called after sending the
207 * domain a SHUTDOWN control message to free up the domain resources.
208 *
209 * @parm xc_handle a handle to an open hypervisor interface
210 * @parm domid the domain id to destroy
211 * @return 0 on success, -1 on failure
212 */
213 int xc_domain_destroy(int xc_handle,
214 uint32_t domid);
216 /**
217 * This function will shutdown a domain. This is intended for use in
218 * fully-virtualized domains where this operation is analogous to the
219 * sched_op operations in a paravirtualized domain. The caller is
220 * expected to give the reason for the shutdown.
221 *
222 * @parm xc_handle a handle to an open hypervisor interface
223 * @parm domid the domain id to destroy
224 * @parm reason is the reason (SHUTDOWN_xxx) for the shutdown
225 * @return 0 on success, -1 on failure
226 */
227 int xc_domain_shutdown(int xc_handle,
228 uint32_t domid,
229 int reason);
231 int xc_vcpu_setaffinity(int xc_handle,
232 uint32_t domid,
233 int vcpu,
234 cpumap_t cpumap);
236 /**
237 * This function will return information about one or more domains. It is
238 * designed to iterate over the list of domains. If a single domain is
239 * requested, this function will return the next domain in the list - if
240 * one exists. It is, therefore, important in this case to make sure the
241 * domain requested was the one returned.
242 *
243 * @parm xc_handle a handle to an open hypervisor interface
244 * @parm first_domid the first domain to enumerate information from. Domains
245 * are currently enumerate in order of creation.
246 * @parm max_doms the number of elements in info
247 * @parm info an array of max_doms size that will contain the information for
248 * the enumerated domains.
249 * @return the number of domains enumerated or -1 on error
250 */
251 int xc_domain_getinfo(int xc_handle,
252 uint32_t first_domid,
253 unsigned int max_doms,
254 xc_dominfo_t *info);
257 /**
258 * This function will set the execution context for the specified vcpu.
259 *
260 * @parm xc_handle a handle to an open hypervisor interface
261 * @parm domid the domain to set the vcpu context for
262 * @parm vcpu the vcpu number for the context
263 * @parm ctxt pointer to the the cpu context with the values to set
264 * @return the number of domains enumerated or -1 on error
265 */
266 int xc_vcpu_setcontext(int xc_handle,
267 uint32_t domid,
268 uint32_t vcpu,
269 vcpu_guest_context_t *ctxt);
270 /**
271 * This function will return information about one or more domains, using a
272 * single hypercall. The domain information will be stored into the supplied
273 * array of xc_domaininfo_t structures.
274 *
275 * @parm xc_handle a handle to an open hypervisor interface
276 * @parm first_domain the first domain to enumerate information from.
277 * Domains are currently enumerate in order of creation.
278 * @parm max_domains the number of elements in info
279 * @parm info an array of max_doms size that will contain the information for
280 * the enumerated domains.
281 * @return the number of domains enumerated or -1 on error
282 */
283 int xc_domain_getinfolist(int xc_handle,
284 uint32_t first_domain,
285 unsigned int max_domains,
286 xc_domaininfo_t *info);
288 /**
289 * This function returns information about the execution context of a
290 * particular vcpu of a domain.
291 *
292 * @parm xc_handle a handle to an open hypervisor interface
293 * @parm domid the domain to get information from
294 * @parm vcpu the vcpu number
295 * @parm ctxt a pointer to a structure to store the execution context of the
296 * domain
297 * @return 0 on success, -1 on failure
298 */
299 int xc_vcpu_getcontext(int xc_handle,
300 uint32_t domid,
301 uint32_t vcpu,
302 vcpu_guest_context_t *ctxt);
304 typedef dom0_getvcpuinfo_t xc_vcpuinfo_t;
305 int xc_vcpu_getinfo(int xc_handle,
306 uint32_t domid,
307 uint32_t vcpu,
308 xc_vcpuinfo_t *info);
310 int xc_domain_setcpuweight(int xc_handle,
311 uint32_t domid,
312 float weight);
313 long long xc_domain_get_cpu_usage(int xc_handle,
314 domid_t domid,
315 int vcpu);
317 int xc_domain_sethandle(int xc_handle, uint32_t domid,
318 xen_domain_handle_t handle);
320 typedef dom0_shadow_control_stats_t xc_shadow_control_stats_t;
321 int xc_shadow_control(int xc_handle,
322 uint32_t domid,
323 unsigned int sop,
324 unsigned long *dirty_bitmap,
325 unsigned long pages,
326 unsigned long *mb,
327 uint32_t mode,
328 xc_shadow_control_stats_t *stats);
330 int xc_sedf_domain_set(int xc_handle,
331 uint32_t domid,
332 uint64_t period, uint64_t slice,
333 uint64_t latency, uint16_t extratime,
334 uint16_t weight);
336 int xc_sedf_domain_get(int xc_handle,
337 uint32_t domid,
338 uint64_t* period, uint64_t *slice,
339 uint64_t *latency, uint16_t *extratime,
340 uint16_t *weight);
342 int xc_sched_credit_domain_set(int xc_handle,
343 uint32_t domid,
344 struct sched_credit_adjdom *sdom);
346 int xc_sched_credit_domain_get(int xc_handle,
347 uint32_t domid,
348 struct sched_credit_adjdom *sdom);
350 /*
351 * EVENT CHANNEL FUNCTIONS
352 */
354 /**
355 * This function allocates an unbound port. Ports are named endpoints used for
356 * interdomain communication. This function is most useful in opening a
357 * well-known port within a domain to receive events on.
358 *
359 * @parm xc_handle a handle to an open hypervisor interface
360 * @parm dom the ID of the local domain (the 'allocatee')
361 * @parm remote_dom the ID of the domain who will later bind
362 * @return allocated port (in @dom) on success, -1 on failure
363 */
364 int xc_evtchn_alloc_unbound(int xc_handle,
365 uint32_t dom,
366 uint32_t remote_dom);
368 int xc_physdev_pci_access_modify(int xc_handle,
369 uint32_t domid,
370 int bus,
371 int dev,
372 int func,
373 int enable);
375 int xc_readconsolering(int xc_handle,
376 char **pbuffer,
377 unsigned int *pnr_chars,
378 int clear);
380 typedef dom0_physinfo_t xc_physinfo_t;
381 int xc_physinfo(int xc_handle,
382 xc_physinfo_t *info);
384 int xc_sched_id(int xc_handle,
385 int *sched_id);
387 int xc_domain_setmaxmem(int xc_handle,
388 uint32_t domid,
389 unsigned int max_memkb);
391 int xc_domain_set_time_offset(int xc_handle,
392 uint32_t domid,
393 int32_t time_offset_seconds);
395 int xc_domain_memory_increase_reservation(int xc_handle,
396 uint32_t domid,
397 unsigned long nr_extents,
398 unsigned int extent_order,
399 unsigned int address_bits,
400 xen_pfn_t *extent_start);
402 int xc_domain_memory_decrease_reservation(int xc_handle,
403 uint32_t domid,
404 unsigned long nr_extents,
405 unsigned int extent_order,
406 xen_pfn_t *extent_start);
408 int xc_domain_memory_populate_physmap(int xc_handle,
409 uint32_t domid,
410 unsigned long nr_extents,
411 unsigned int extent_order,
412 unsigned int address_bits,
413 xen_pfn_t *extent_start);
415 int xc_domain_translate_gpfn_list(int xc_handle,
416 uint32_t domid,
417 unsigned long nr_gpfns,
418 xen_pfn_t *gpfn_list,
419 xen_pfn_t *mfn_list);
421 int xc_domain_ioport_permission(int xc_handle,
422 uint32_t domid,
423 uint32_t first_port,
424 uint32_t nr_ports,
425 uint32_t allow_access);
427 int xc_domain_irq_permission(int xc_handle,
428 uint32_t domid,
429 uint8_t pirq,
430 uint8_t allow_access);
432 int xc_domain_iomem_permission(int xc_handle,
433 uint32_t domid,
434 unsigned long first_mfn,
435 unsigned long nr_mfns,
436 uint8_t allow_access);
438 unsigned long xc_make_page_below_4G(int xc_handle, uint32_t domid,
439 unsigned long mfn);
441 typedef dom0_perfc_desc_t xc_perfc_desc_t;
442 typedef dom0_perfc_val_t xc_perfc_val_t;
443 /* IMPORTANT: The caller is responsible for mlock()'ing the @desc and @val
444 arrays. */
445 int xc_perfc_control(int xc_handle,
446 uint32_t op,
447 xc_perfc_desc_t *desc,
448 xc_perfc_val_t *val,
449 int *nbr_desc,
450 int *nbr_val);
452 /**
453 * Memory maps a range within one domain to a local address range. Mappings
454 * should be unmapped with munmap and should follow the same rules as mmap
455 * regarding page alignment. Returns NULL on failure.
456 *
457 * In Linux, the ring queue for the control channel is accessible by mapping
458 * the shared_info_frame (from xc_domain_getinfo()) + 2048. The structure
459 * stored there is of type control_if_t.
460 *
461 * @parm xc_handle a handle on an open hypervisor interface
462 * @parm dom the domain to map memory from
463 * @parm size the amount of memory to map (in multiples of page size)
464 * @parm prot same flag as in mmap().
465 * @parm mfn the frame address to map.
466 */
467 void *xc_map_foreign_range(int xc_handle, uint32_t dom,
468 int size, int prot,
469 unsigned long mfn );
471 void *xc_map_foreign_batch(int xc_handle, uint32_t dom, int prot,
472 xen_pfn_t *arr, int num );
474 /**
475 * Translates a virtual address in the context of a given domain and
476 * vcpu returning the machine page frame number of the associated
477 * page.
478 *
479 * @parm xc_handle a handle on an open hypervisor interface
480 * @parm dom the domain to perform the translation in
481 * @parm vcpu the vcpu to perform the translation on
482 * @parm virt the virtual address to translate
483 */
484 unsigned long xc_translate_foreign_address(int xc_handle, uint32_t dom,
485 int vcpu, unsigned long long virt);
487 int xc_get_pfn_list(int xc_handle, uint32_t domid, xen_pfn_t *pfn_buf,
488 unsigned long max_pfns);
490 int xc_ia64_get_pfn_list(int xc_handle, uint32_t domid,
491 xen_pfn_t *pfn_buf,
492 unsigned int start_page, unsigned int nr_pages);
494 int xc_copy_to_domain_page(int xc_handle, uint32_t domid,
495 unsigned long dst_pfn, const char *src_page);
497 int xc_clear_domain_page(int xc_handle, uint32_t domid,
498 unsigned long dst_pfn);
500 long xc_get_max_pages(int xc_handle, uint32_t domid);
502 int xc_mmuext_op(int xc_handle, struct mmuext_op *op, unsigned int nr_ops,
503 domid_t dom);
505 int xc_memory_op(int xc_handle, int cmd, void *arg);
507 int xc_get_pfn_type_batch(int xc_handle, uint32_t dom,
508 int num, unsigned long *arr);
511 /* Get current total pages allocated to a domain. */
512 long xc_get_tot_pages(int xc_handle, uint32_t domid);
515 /*
516 * Trace Buffer Operations
517 */
519 /**
520 * xc_tbuf_enable - enable tracing buffers
521 *
522 * @parm xc_handle a handle to an open hypervisor interface
523 * @parm cnt size of tracing buffers to create (in pages)
524 * @parm mfn location to store mfn of the trace buffers to
525 * @parm size location to store the size (in bytes) of a trace buffer to
526 *
527 * Gets the machine address of the trace pointer area and the size of the
528 * per CPU buffers.
529 */
530 int xc_tbuf_enable(int xc_handle, size_t cnt, unsigned long *mfn,
531 unsigned long *size);
533 /*
534 * Disable tracing buffers.
535 */
536 int xc_tbuf_disable(int xc_handle);
538 /**
539 * This function sets the size of the trace buffers. Setting the size
540 * is currently a one-shot operation that may be performed either at boot
541 * time or via this interface, not both. The buffer size must be set before
542 * enabling tracing.
543 *
544 * @parm xc_handle a handle to an open hypervisor interface
545 * @parm size the size in pages per cpu for the trace buffers
546 * @return 0 on success, -1 on failure.
547 */
548 int xc_tbuf_set_size(int xc_handle, unsigned long size);
550 /**
551 * This function retrieves the current size of the trace buffers.
552 * Note that the size returned is in terms of bytes, not pages.
554 * @parm xc_handle a handle to an open hypervisor interface
555 * @parm size will contain the size in bytes for the trace buffers
556 * @return 0 on success, -1 on failure.
557 */
558 int xc_tbuf_get_size(int xc_handle, unsigned long *size);
560 int xc_tbuf_set_cpu_mask(int xc_handle, uint32_t mask);
562 int xc_tbuf_set_evt_mask(int xc_handle, uint32_t mask);
564 /* Execute a privileged dom0 operation. */
565 int xc_dom0_op(int xc_handle, dom0_op_t *op);
567 int xc_version(int xc_handle, int cmd, void *arg);
569 /*
570 * MMU updates.
571 */
572 #define MAX_MMU_UPDATES 1024
573 struct xc_mmu {
574 mmu_update_t updates[MAX_MMU_UPDATES];
575 int idx;
576 domid_t subject;
577 };
578 typedef struct xc_mmu xc_mmu_t;
579 xc_mmu_t *xc_init_mmu_updates(int xc_handle, domid_t dom);
580 int xc_add_mmu_update(int xc_handle, xc_mmu_t *mmu,
581 unsigned long long ptr, unsigned long long val);
582 int xc_finish_mmu_updates(int xc_handle, xc_mmu_t *mmu);
584 int xc_acm_op(int xc_handle, int cmd, void *arg, size_t arg_size);
586 /*
587 * Return a handle to the event channel driver, or -1 on failure, in which case
588 * errno will be set appropriately.
589 */
590 int xc_evtchn_open(void);
592 /*
593 * Close a handle previously allocated with xc_evtchn_open().
594 */
595 int xc_evtchn_close(int xce_handle);
597 /*
598 * Return an fd that can be select()ed on for further calls to
599 * xc_evtchn_pending().
600 */
601 int xc_evtchn_fd(int xce_handle);
603 /*
604 * Notify the given event channel. Returns -1 on failure, in which case
605 * errno will be set appropriately.
606 */
607 int xc_evtchn_notify(int xce_handle, evtchn_port_t port);
609 /*
610 * Returns a new event port bound to the remote port for the given domain ID,
611 * or -1 on failure, in which case errno will be set appropriately.
612 */
613 evtchn_port_t xc_evtchn_bind_interdomain(int xce_handle, int domid,
614 evtchn_port_t remote_port);
616 /*
617 * Unbind the given event channel. Returns -1 on failure, in which case errno
618 * will be set appropriately.
619 */
620 int xc_evtchn_unbind(int xce_handle, evtchn_port_t port);
622 /*
623 * Bind an event channel to the given VIRQ. Returns the event channel bound to
624 * the VIRQ, or -1 on failure, in which case errno will be set appropriately.
625 */
626 evtchn_port_t xc_evtchn_bind_virq(int xce_handle, unsigned int virq);
628 /*
629 * Return the next event channel to become pending, or -1 on failure, in which
630 * case errno will be set appropriately.
631 */
632 evtchn_port_t xc_evtchn_pending(int xce_handle);
634 /*
635 * Unmask the given event channel. Returns -1 on failure, in which case errno
636 * will be set appropriately.
637 */
638 int xc_evtchn_unmask(int xce_handle, evtchn_port_t port);
640 #endif