direct-io.hg

annotate tools/libxc/xenctrl.h @ 14309:7ab04fa25d52

xm: New command 'debug-keys' to inject debug-key events into Xen.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Fri Mar 09 11:11:59 2007 +0000 (2007-03-09)
parents f40b13ed0e05
children 7b77b47a49d1
rev   line source
mjw@1623 1 /******************************************************************************
cl349@6388 2 * xenctrl.h
kaf24@9660 3 *
mjw@1623 4 * A library for low-level access to the Xen control interfaces.
kaf24@9660 5 *
kaf24@2787 6 * Copyright (c) 2003-2004, K A Fraser.
mjw@1623 7 */
mjw@1623 8
cl349@6389 9 #ifndef XENCTRL_H
cl349@6389 10 #define XENCTRL_H
mjw@1623 11
kaf24@11393 12 /* Tell the Xen public headers we are a user-space tools build. */
kaf24@11393 13 #ifndef __XEN_TOOLS__
kaf24@11393 14 #define __XEN_TOOLS__ 1
kaf24@11393 15 #endif
kaf24@11393 16
kaf24@9999 17 #include <stddef.h>
kaf24@3266 18 #include <stdint.h>
kaf24@2821 19 #include <xen/xen.h>
kfraser@11257 20 #include <xen/domctl.h>
kfraser@11257 21 #include <xen/sysctl.h>
vh249@6549 22 #include <xen/version.h>
kaf24@2821 23 #include <xen/event_channel.h>
kaf24@7196 24 #include <xen/sched.h>
smh22@7702 25 #include <xen/memory.h>
kaf24@5541 26 #include <xen/acm.h>
kaf24@9907 27 #include <xen/acm_ops.h>
kaf24@2787 28
kaf24@5914 29 #ifdef __ia64__
kaf24@5914 30 #define XC_PAGE_SHIFT 14
kaf24@5914 31 #else
kaf24@5914 32 #define XC_PAGE_SHIFT 12
kaf24@5914 33 #endif
kaf24@5914 34 #define XC_PAGE_SIZE (1UL << XC_PAGE_SHIFT)
kaf24@5914 35 #define XC_PAGE_MASK (~(XC_PAGE_SIZE-1))
kaf24@5914 36
kaf24@3961 37 /*
kaf24@3961 38 * DEFINITIONS FOR CPU BARRIERS
kaf24@9660 39 */
kaf24@3961 40
kaf24@3961 41 #if defined(__i386__)
kaf24@3966 42 #define mb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
kaf24@3966 43 #define rmb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
kaf24@3966 44 #define wmb() __asm__ __volatile__ ( "" : : : "memory")
kaf24@3961 45 #elif defined(__x86_64__)
kaf24@3966 46 #define mb() __asm__ __volatile__ ( "mfence" : : : "memory")
kaf24@3966 47 #define rmb() __asm__ __volatile__ ( "lfence" : : : "memory")
kaf24@3966 48 #define wmb() __asm__ __volatile__ ( "" : : : "memory")
kaf24@5914 49 #elif defined(__ia64__)
kfraser@12271 50 #define mb() __asm__ __volatile__ ("mf" ::: "memory")
kfraser@12271 51 #define rmb() __asm__ __volatile__ ("mf" ::: "memory")
kfraser@12271 52 #define wmb() __asm__ __volatile__ ("mf" ::: "memory")
kaf24@10687 53 #elif defined(__powerpc__)
kaf24@10687 54 /* XXX loosen these up later */
kaf24@10687 55 #define mb() __asm__ __volatile__ ("sync" : : : "memory")
kaf24@10687 56 #define rmb() __asm__ __volatile__ ("sync" : : : "memory") /* lwsync? */
kaf24@10687 57 #define wmb() __asm__ __volatile__ ("sync" : : : "memory") /* eieio? */
kaf24@3961 58 #else
kaf24@3961 59 #error "Define barriers"
kaf24@3961 60 #endif
kaf24@3961 61
kaf24@3961 62 /*
iap10@3443 63 * INITIALIZATION FUNCTIONS
kaf24@9660 64 */
iap10@3443 65
iap10@3443 66 /**
iap10@3443 67 * This function opens a handle to the hypervisor interface. This function can
iap10@3443 68 * be called multiple times within a single process. Multiple processes can
iap10@3443 69 * have an open hypervisor interface at the same time.
iap10@3443 70 *
iap10@3443 71 * Each call to this function should have a corresponding call to
iap10@3443 72 * xc_interface_close().
iap10@3443 73 *
iap10@3443 74 * This function can fail if the caller does not have superuser permission or
iap10@3443 75 * if a Xen-enabled kernel is not currently running.
iap10@3443 76 *
iap10@3443 77 * @return a handle to the hypervisor interface or -1 on failure
iap10@3443 78 */
mjw@1623 79 int xc_interface_open(void);
iap10@3443 80
iap10@3443 81 /**
iap10@3443 82 * This function closes an open hypervisor interface.
iap10@3443 83 *
iap10@3443 84 * This function can fail if the handle does not represent an open interface or
iap10@3443 85 * if there were problems closing the interface.
iap10@3443 86 *
iap10@3443 87 * @parm xc_handle a handle to an open hypervisor interface
iap10@3443 88 * @return 0 on success, -1 otherwise.
iap10@3443 89 */
mjw@1623 90 int xc_interface_close(int xc_handle);
mjw@1623 91
kaf24@3961 92 /*
kfraser@11672 93 * KERNEL INTERFACES
kfraser@11672 94 */
kfraser@11672 95
kfraser@11672 96 /*
kfraser@11672 97 * Resolve a kernel device name (e.g., "evtchn", "blktap0") into a kernel
kfraser@11672 98 * device number. Returns -1 on error (and sets errno).
kfraser@11672 99 */
kfraser@11672 100 int xc_find_device_number(const char *name);
kfraser@11672 101
kfraser@11672 102 /*
kaf24@4719 103 * DOMAIN DEBUGGING FUNCTIONS
kaf24@4719 104 */
kaf24@4719 105
kaf24@4719 106 typedef struct xc_core_header {
kaf24@4719 107 unsigned int xch_magic;
kaf24@4719 108 unsigned int xch_nr_vcpus;
kaf24@4719 109 unsigned int xch_nr_pages;
kaf24@4719 110 unsigned int xch_ctxt_offset;
kaf24@4719 111 unsigned int xch_index_offset;
kaf24@4719 112 unsigned int xch_pages_offset;
kaf24@4719 113 } xc_core_header_t;
kaf24@4719 114
kfraser@12224 115 #define XC_CORE_MAGIC 0xF00FEBED
kfraser@12224 116 #define XC_CORE_MAGIC_HVM 0xF00FEBEE
kaf24@4719 117
kfraser@11791 118 #ifdef __linux__
kfraser@11791 119
kfraser@11791 120 #include <sys/ptrace.h>
kfraser@11791 121 #include <thread_db.h>
kfraser@11791 122
kfraser@11774 123 typedef void (*thr_ev_handler_t)(long);
kfraser@11774 124
kfraser@11774 125 void xc_register_event_handler(
kfraser@11774 126 thr_ev_handler_t h,
kfraser@11774 127 td_event_e e);
kfraser@11774 128
kfraser@11774 129 long xc_ptrace(
kfraser@11774 130 int xc_handle,
kfraser@11774 131 enum __ptrace_request request,
kfraser@11774 132 uint32_t domid,
kfraser@11774 133 long addr,
kfraser@11774 134 long data);
kfraser@11774 135
kfraser@11774 136 int xc_waitdomain(
kfraser@11774 137 int xc_handle,
kfraser@11774 138 int domain,
kfraser@11774 139 int *status,
kfraser@11774 140 int options);
kfraser@11774 141
kfraser@11774 142 #endif /* __linux__ */
kaf24@4719 143
kaf24@4719 144 /*
iap10@3443 145 * DOMAIN MANAGEMENT FUNCTIONS
kaf24@3961 146 */
iap10@3443 147
kfraser@12224 148 typedef struct xc_dominfo {
kaf24@7378 149 uint32_t domid;
kaf24@7378 150 uint32_t ssidref;
kaf24@9660 151 unsigned int dying:1, crashed:1, shutdown:1,
kfraser@12224 152 paused:1, blocked:1, running:1,
kfraser@12224 153 hvm:1;
mjw@1623 154 unsigned int shutdown_reason; /* only meaningful if shutdown==1 */
mjw@1623 155 unsigned long nr_pages;
mjw@1623 156 unsigned long shared_info_frame;
kaf24@7378 157 uint64_t cpu_time;
mjw@1623 158 unsigned long max_memkb;
kaf24@7397 159 unsigned int nr_online_vcpus;
kaf24@7397 160 unsigned int max_vcpu_id;
kaf24@7378 161 xen_domain_handle_t handle;
mjw@1623 162 } xc_dominfo_t;
mjw@1623 163
kfraser@11257 164 typedef xen_domctl_getdomaininfo_t xc_domaininfo_t;
kaf24@9660 165 int xc_domain_create(int xc_handle,
kaf24@7339 166 uint32_t ssidref,
kaf24@7378 167 xen_domain_handle_t handle,
kfraser@12196 168 uint32_t flags,
kaf24@7339 169 uint32_t *pdomid);
iap10@3443 170
kaf24@4719 171
kaf24@9221 172 /* Functions to produce a dump of a given domain
kaf24@9221 173 * xc_domain_dumpcore - produces a dump to a specified file
kaf24@9221 174 * xc_domain_dumpcore_via_callback - produces a dump, using a specified
kaf24@9221 175 * callback function
kaf24@9221 176 */
kaf24@9660 177 int xc_domain_dumpcore(int xc_handle,
kaf24@7339 178 uint32_t domid,
cl349@4853 179 const char *corename);
kaf24@4719 180
kaf24@9221 181 /* Define the callback function type for xc_domain_dumpcore_via_callback.
kaf24@9221 182 *
kaf24@9221 183 * This function is called by the coredump code for every "write",
kaf24@9221 184 * and passes an opaque object for the use of the function and
kaf24@9221 185 * created by the caller of xc_domain_dumpcore_via_callback.
kaf24@9221 186 */
kaf24@9221 187 typedef int (dumpcore_rtn_t)(void *arg, char *buffer, unsigned int length);
kaf24@9221 188
kaf24@9660 189 int xc_domain_dumpcore_via_callback(int xc_handle,
kaf24@9221 190 uint32_t domid,
kaf24@9221 191 void *arg,
kaf24@9221 192 dumpcore_rtn_t dump_rtn);
kaf24@9221 193
kaf24@7354 194 /*
kaf24@7566 195 * This function sets the maximum number of vcpus that a domain may create.
kaf24@7354 196 *
kaf24@7354 197 * @parm xc_handle a handle to an open hypervisor interface.
kaf24@7354 198 * @parm domid the domain id in which vcpus are to be created.
kaf24@7354 199 * @parm max the maximum number of vcpus that the domain may create.
kaf24@7354 200 * @return 0 on success, -1 on failure.
kaf24@7354 201 */
kaf24@7354 202 int xc_domain_max_vcpus(int xc_handle,
kaf24@9660 203 uint32_t domid,
kaf24@7354 204 unsigned int max);
kaf24@4719 205
iap10@3443 206 /**
iap10@3443 207 * This function pauses a domain. A paused domain still exists in memory
iap10@3443 208 * however it does not receive any timeslices from the hypervisor.
iap10@3443 209 *
iap10@3443 210 * @parm xc_handle a handle to an open hypervisor interface
iap10@3443 211 * @parm domid the domain id to pause
iap10@3443 212 * @return 0 on success, -1 on failure.
iap10@3443 213 */
kaf24@9660 214 int xc_domain_pause(int xc_handle,
kaf24@7339 215 uint32_t domid);
iap10@3443 216 /**
iap10@3443 217 * This function unpauses a domain. The domain should have been previously
iap10@3443 218 * paused.
iap10@3443 219 *
iap10@3443 220 * @parm xc_handle a handle to an open hypervisor interface
iap10@3443 221 * @parm domid the domain id to unpause
iap10@3443 222 * return 0 on success, -1 on failure
iap10@3443 223 */
kaf24@9660 224 int xc_domain_unpause(int xc_handle,
kaf24@7339 225 uint32_t domid);
iap10@3443 226
iap10@3443 227 /**
iap10@3443 228 * This function will destroy a domain. Destroying a domain removes the domain
iap10@3443 229 * completely from memory. This function should be called after sending the
iap10@3443 230 * domain a SHUTDOWN control message to free up the domain resources.
iap10@3443 231 *
iap10@3443 232 * @parm xc_handle a handle to an open hypervisor interface
iap10@3443 233 * @parm domid the domain id to destroy
iap10@3443 234 * @return 0 on success, -1 on failure
iap10@3443 235 */
kaf24@9660 236 int xc_domain_destroy(int xc_handle,
kaf24@7339 237 uint32_t domid);
kaf24@8500 238
kfraser@13516 239
kfraser@13516 240 /**
kfraser@13516 241 * This function resumes a suspended domain. The domain should have
kfraser@13516 242 * been previously suspended.
kfraser@13516 243 *
kfraser@13516 244 * @parm xc_handle a handle to an open hypervisor interface
kfraser@13516 245 * @parm domid the domain id to resume
kfraser@14160 246 * @parm fast use cooperative resume (guest must support this)
kfraser@13516 247 * return 0 on success, -1 on failure
kfraser@13516 248 */
kfraser@13516 249 int xc_domain_resume(int xc_handle,
kfraser@14160 250 uint32_t domid,
kfraser@14160 251 int fast);
kfraser@13516 252
kaf24@9560 253 /**
kaf24@9560 254 * This function will shutdown a domain. This is intended for use in
kaf24@9560 255 * fully-virtualized domains where this operation is analogous to the
kaf24@9560 256 * sched_op operations in a paravirtualized domain. The caller is
kaf24@9560 257 * expected to give the reason for the shutdown.
kaf24@9560 258 *
kaf24@9560 259 * @parm xc_handle a handle to an open hypervisor interface
kaf24@9560 260 * @parm domid the domain id to destroy
kaf24@9560 261 * @parm reason is the reason (SHUTDOWN_xxx) for the shutdown
kaf24@9560 262 * @return 0 on success, -1 on failure
kaf24@9560 263 */
kaf24@9660 264 int xc_domain_shutdown(int xc_handle,
kaf24@9560 265 uint32_t domid,
kaf24@9560 266 int reason);
kaf24@9560 267
kaf24@8500 268 int xc_vcpu_setaffinity(int xc_handle,
kaf24@8500 269 uint32_t domid,
kaf24@8500 270 int vcpu,
kfraser@11257 271 uint64_t cpumap);
kfraser@11257 272 int xc_vcpu_getaffinity(int xc_handle,
kfraser@11257 273 uint32_t domid,
kfraser@11257 274 int vcpu,
kfraser@11257 275 uint64_t *cpumap);
kaf24@7378 276
iap10@3443 277 /**
dsteklof@5498 278 * This function will return information about one or more domains. It is
dsteklof@5498 279 * designed to iterate over the list of domains. If a single domain is
dsteklof@5498 280 * requested, this function will return the next domain in the list - if
dsteklof@5498 281 * one exists. It is, therefore, important in this case to make sure the
dsteklof@5498 282 * domain requested was the one returned.
iap10@3443 283 *
iap10@3443 284 * @parm xc_handle a handle to an open hypervisor interface
iap10@3443 285 * @parm first_domid the first domain to enumerate information from. Domains
iap10@3443 286 * are currently enumerate in order of creation.
iap10@3443 287 * @parm max_doms the number of elements in info
iap10@3443 288 * @parm info an array of max_doms size that will contain the information for
iap10@3443 289 * the enumerated domains.
iap10@3443 290 * @return the number of domains enumerated or -1 on error
iap10@3443 291 */
mjw@1623 292 int xc_domain_getinfo(int xc_handle,
kaf24@9660 293 uint32_t first_domid,
mjw@1623 294 unsigned int max_doms,
mjw@1623 295 xc_dominfo_t *info);
iap10@3443 296
kaf24@8381 297
kaf24@8381 298 /**
kaf24@8500 299 * This function will set the execution context for the specified vcpu.
kaf24@8381 300 *
kaf24@8381 301 * @parm xc_handle a handle to an open hypervisor interface
kaf24@8381 302 * @parm domid the domain to set the vcpu context for
kaf24@8381 303 * @parm vcpu the vcpu number for the context
kaf24@8381 304 * @parm ctxt pointer to the the cpu context with the values to set
kaf24@8381 305 * @return the number of domains enumerated or -1 on error
kaf24@8381 306 */
kaf24@8500 307 int xc_vcpu_setcontext(int xc_handle,
kaf24@8500 308 uint32_t domid,
kaf24@8500 309 uint32_t vcpu,
kaf24@8500 310 vcpu_guest_context_t *ctxt);
iap10@3443 311 /**
kaf24@5699 312 * This function will return information about one or more domains, using a
kaf24@5699 313 * single hypercall. The domain information will be stored into the supplied
kaf24@5699 314 * array of xc_domaininfo_t structures.
kaf24@5699 315 *
kaf24@5699 316 * @parm xc_handle a handle to an open hypervisor interface
kaf24@5699 317 * @parm first_domain the first domain to enumerate information from.
kaf24@5699 318 * Domains are currently enumerate in order of creation.
kaf24@5699 319 * @parm max_domains the number of elements in info
kaf24@5699 320 * @parm info an array of max_doms size that will contain the information for
kaf24@5699 321 * the enumerated domains.
kaf24@5699 322 * @return the number of domains enumerated or -1 on error
kaf24@5699 323 */
kaf24@5699 324 int xc_domain_getinfolist(int xc_handle,
kaf24@7339 325 uint32_t first_domain,
kaf24@5699 326 unsigned int max_domains,
kaf24@5699 327 xc_domaininfo_t *info);
kaf24@5699 328
kaf24@5699 329 /**
Tim@13414 330 * This function returns information about the context of a hvm domain
Tim@13414 331 * @parm xc_handle a handle to an open hypervisor interface
Tim@13414 332 * @parm domid the domain to get information from
Tim@13757 333 * @parm ctxt_buf a pointer to a structure to store the execution context of
Tim@13757 334 * the hvm domain
Tim@13757 335 * @parm size the size of ctxt_buf in bytes
Tim@13414 336 * @return 0 on success, -1 on failure
Tim@13414 337 */
Tim@13414 338 int xc_domain_hvm_getcontext(int xc_handle,
Tim@13414 339 uint32_t domid,
Tim@13757 340 uint8_t *ctxt_buf,
Tim@13757 341 uint32_t size);
Tim@13414 342
Tim@13414 343 /**
Tim@13414 344 * This function will set the context for hvm domain
Tim@13414 345 *
Tim@13414 346 * @parm xc_handle a handle to an open hypervisor interface
Tim@13414 347 * @parm domid the domain to set the hvm domain context for
Tim@13414 348 * @parm hvm_ctxt pointer to the the hvm context with the values to set
Tim@13757 349 * @parm size the size of hvm_ctxt in bytes
Tim@13414 350 * @return 0 on success, -1 on failure
Tim@13414 351 */
Tim@13414 352 int xc_domain_hvm_setcontext(int xc_handle,
Tim@13414 353 uint32_t domid,
Tim@13757 354 uint8_t *hvm_ctxt,
Tim@13757 355 uint32_t size);
Tim@13414 356
Tim@13414 357 /**
emellor@7404 358 * This function returns information about the execution context of a
emellor@7404 359 * particular vcpu of a domain.
iap10@3443 360 *
iap10@3443 361 * @parm xc_handle a handle to an open hypervisor interface
iap10@3443 362 * @parm domid the domain to get information from
emellor@7404 363 * @parm vcpu the vcpu number
iap10@3443 364 * @parm ctxt a pointer to a structure to store the execution context of the
iap10@3443 365 * domain
iap10@3443 366 * @return 0 on success, -1 on failure
iap10@3443 367 */
kaf24@8500 368 int xc_vcpu_getcontext(int xc_handle,
kfraser@13525 369 uint32_t domid,
kfraser@13525 370 uint32_t vcpu,
kfraser@13525 371 vcpu_guest_context_t *ctxt);
cl349@4849 372
kfraser@11257 373 typedef xen_domctl_getvcpuinfo_t xc_vcpuinfo_t;
kaf24@8500 374 int xc_vcpu_getinfo(int xc_handle,
kaf24@8500 375 uint32_t domid,
kaf24@8500 376 uint32_t vcpu,
kaf24@8500 377 xc_vcpuinfo_t *info);
kaf24@7397 378
gm281@2236 379 int xc_domain_setcpuweight(int xc_handle,
kaf24@7339 380 uint32_t domid,
gm281@2236 381 float weight);
kaf24@2787 382 long long xc_domain_get_cpu_usage(int xc_handle,
mafetter@3435 383 domid_t domid,
mafetter@3435 384 int vcpu);
mjw@1623 385
kaf24@9660 386 int xc_domain_sethandle(int xc_handle, uint32_t domid,
kaf24@7379 387 xen_domain_handle_t handle);
kaf24@2787 388
kfraser@11257 389 typedef xen_domctl_shadow_op_stats_t xc_shadow_op_stats_t;
mjw@1623 390 int xc_shadow_control(int xc_handle,
kaf24@9660 391 uint32_t domid,
mjw@1623 392 unsigned int sop,
mjw@1623 393 unsigned long *dirty_bitmap,
mjw@1623 394 unsigned long pages,
tdeegan@11151 395 unsigned long *mb,
tdeegan@11151 396 uint32_t mode,
kfraser@11257 397 xc_shadow_op_stats_t *stats);
mjw@1623 398
sd386@3449 399 int xc_sedf_domain_set(int xc_handle,
kaf24@7339 400 uint32_t domid,
kaf24@7339 401 uint64_t period, uint64_t slice,
kaf24@7339 402 uint64_t latency, uint16_t extratime,
kaf24@7339 403 uint16_t weight);
sd386@3449 404
sd386@3449 405 int xc_sedf_domain_get(int xc_handle,
kaf24@7339 406 uint32_t domid,
kaf24@7339 407 uint64_t* period, uint64_t *slice,
kaf24@7339 408 uint64_t *latency, uint16_t *extratime,
kaf24@7339 409 uint16_t *weight);
sd386@3449 410
kaf24@10174 411 int xc_sched_credit_domain_set(int xc_handle,
kaf24@10174 412 uint32_t domid,
kfraser@11257 413 struct xen_domctl_sched_credit *sdom);
ack@10168 414
kaf24@10174 415 int xc_sched_credit_domain_get(int xc_handle,
kaf24@10174 416 uint32_t domid,
kfraser@11257 417 struct xen_domctl_sched_credit *sdom);
ack@10168 418
keir@14098 419 /**
keir@14098 420 * This function sends a trigger to a domain.
keir@14098 421 *
keir@14098 422 * @parm xc_handle a handle to an open hypervisor interface
keir@14098 423 * @parm domid the domain id to send trigger
keir@14098 424 * @parm trigger the trigger type
keir@14098 425 * @parm vcpu the vcpu number to send trigger
keir@14098 426 * return 0 on success, -1 on failure
keir@14098 427 */
keir@14098 428 int xc_domain_send_trigger(int xc_handle,
keir@14098 429 uint32_t domid,
keir@14098 430 uint32_t trigger,
keir@14098 431 uint32_t vcpu);
keir@14098 432
kaf24@3961 433 /*
iap10@3443 434 * EVENT CHANNEL FUNCTIONS
kaf24@3961 435 */
iap10@3443 436
iap10@3443 437 /**
iap10@3443 438 * This function allocates an unbound port. Ports are named endpoints used for
iap10@3443 439 * interdomain communication. This function is most useful in opening a
iap10@3443 440 * well-known port within a domain to receive events on.
kfraser@12694 441 *
kfraser@12694 442 * NOTE: If you are allocating a *local* unbound port, you probably want to
kfraser@12694 443 * use xc_evtchn_bind_unbound_port(). This function is intended for allocating
kfraser@12694 444 * ports *only* during domain creation.
iap10@3443 445 *
iap10@3443 446 * @parm xc_handle a handle to an open hypervisor interface
kaf24@7223 447 * @parm dom the ID of the local domain (the 'allocatee')
kaf24@7237 448 * @parm remote_dom the ID of the domain who will later bind
kaf24@7237 449 * @return allocated port (in @dom) on success, -1 on failure
iap10@3443 450 */
kaf24@2713 451 int xc_evtchn_alloc_unbound(int xc_handle,
kaf24@7339 452 uint32_t dom,
kaf24@7339 453 uint32_t remote_dom);
iap10@3443 454
kfraser@13521 455 int xc_evtchn_reset(int xc_handle,
kfraser@13521 456 uint32_t dom);
kfraser@13521 457
mjw@1623 458 int xc_physdev_pci_access_modify(int xc_handle,
kaf24@7339 459 uint32_t domid,
mjw@1623 460 int bus,
mjw@1623 461 int dev,
mjw@1623 462 int func,
mjw@1623 463 int enable);
mjw@1623 464
mjw@1623 465 int xc_readconsolering(int xc_handle,
kaf24@5327 466 char **pbuffer,
kaf24@9660 467 unsigned int *pnr_chars,
mjw@1623 468 int clear);
mjw@1623 469
kfraser@14309 470 int xc_send_debug_keys(int xc_handle, char *keys);
kfraser@14309 471
kfraser@11257 472 typedef xen_sysctl_physinfo_t xc_physinfo_t;
mjw@1623 473 int xc_physinfo(int xc_handle,
mjw@1623 474 xc_physinfo_t *info);
mjw@1623 475
gm281@2236 476 int xc_sched_id(int xc_handle,
gm281@2236 477 int *sched_id);
gm281@2236 478
mjw@1623 479 int xc_domain_setmaxmem(int xc_handle,
kaf24@9660 480 uint32_t domid,
kaf24@3231 481 unsigned int max_memkb);
mjw@1623 482
kfraser@12803 483 int xc_domain_set_memmap_limit(int xc_handle,
kfraser@12803 484 uint32_t domid,
kfraser@12803 485 unsigned long map_limitkb);
kfraser@12803 486
kaf24@10474 487 int xc_domain_set_time_offset(int xc_handle,
kaf24@10474 488 uint32_t domid,
kaf24@10474 489 int32_t time_offset_seconds);
kaf24@10474 490
cl349@5045 491 int xc_domain_memory_increase_reservation(int xc_handle,
kaf24@9660 492 uint32_t domid,
iap10@6688 493 unsigned long nr_extents,
iap10@6682 494 unsigned int extent_order,
iap10@6688 495 unsigned int address_bits,
kaf24@10276 496 xen_pfn_t *extent_start);
iap10@6688 497
iap10@6688 498 int xc_domain_memory_decrease_reservation(int xc_handle,
kaf24@9660 499 uint32_t domid,
iap10@6688 500 unsigned long nr_extents,
iap10@6688 501 unsigned int extent_order,
kaf24@10276 502 xen_pfn_t *extent_start);
iap10@6688 503
kaf24@8856 504 int xc_domain_memory_populate_physmap(int xc_handle,
kaf24@8856 505 uint32_t domid,
kaf24@8856 506 unsigned long nr_extents,
kaf24@8856 507 unsigned int extent_order,
kaf24@8856 508 unsigned int address_bits,
kaf24@10276 509 xen_pfn_t *extent_start);
kaf24@8856 510
kaf24@7624 511 int xc_domain_ioport_permission(int xc_handle,
kaf24@7624 512 uint32_t domid,
kaf24@8121 513 uint32_t first_port,
kaf24@8121 514 uint32_t nr_ports,
kaf24@8121 515 uint32_t allow_access);
kaf24@7624 516
kaf24@8460 517 int xc_domain_irq_permission(int xc_handle,
kaf24@8460 518 uint32_t domid,
kaf24@8460 519 uint8_t pirq,
kaf24@8460 520 uint8_t allow_access);
kaf24@8460 521
kaf24@8460 522 int xc_domain_iomem_permission(int xc_handle,
kaf24@8460 523 uint32_t domid,
kaf24@8736 524 unsigned long first_mfn,
kaf24@8736 525 unsigned long nr_mfns,
kaf24@8460 526 uint8_t allow_access);
kaf24@8460 527
kaf24@10266 528 unsigned long xc_make_page_below_4G(int xc_handle, uint32_t domid,
kaf24@10266 529 unsigned long mfn);
kaf24@10266 530
kfraser@11257 531 typedef xen_sysctl_perfc_desc_t xc_perfc_desc_t;
kfraser@11257 532 typedef xen_sysctl_perfc_val_t xc_perfc_val_t;
kaf24@10953 533 /* IMPORTANT: The caller is responsible for mlock()'ing the @desc and @val
kaf24@10953 534 arrays. */
kaf24@3231 535 int xc_perfc_control(int xc_handle,
kaf24@7339 536 uint32_t op,
kaf24@10953 537 xc_perfc_desc_t *desc,
kaf24@10953 538 xc_perfc_val_t *val,
kaf24@10953 539 int *nbr_desc,
kaf24@10953 540 int *nbr_val);
mjw@1623 541
iap10@3443 542 /**
iap10@3443 543 * Memory maps a range within one domain to a local address range. Mappings
iap10@3443 544 * should be unmapped with munmap and should follow the same rules as mmap
rusty@4866 545 * regarding page alignment. Returns NULL on failure.
iap10@3443 546 *
iap10@3443 547 * In Linux, the ring queue for the control channel is accessible by mapping
iap10@3443 548 * the shared_info_frame (from xc_domain_getinfo()) + 2048. The structure
iap10@3443 549 * stored there is of type control_if_t.
iap10@3443 550 *
iap10@3443 551 * @parm xc_handle a handle on an open hypervisor interface
iap10@3443 552 * @parm dom the domain to map memory from
iap10@3443 553 * @parm size the amount of memory to map (in multiples of page size)
iap10@3443 554 * @parm prot same flag as in mmap().
iap10@3443 555 * @parm mfn the frame address to map.
iap10@3443 556 */
kaf24@7339 557 void *xc_map_foreign_range(int xc_handle, uint32_t dom,
iap10@2325 558 int size, int prot,
iap10@2325 559 unsigned long mfn );
iap10@2325 560
kaf24@7339 561 void *xc_map_foreign_batch(int xc_handle, uint32_t dom, int prot,
kaf24@10276 562 xen_pfn_t *arr, int num );
iap10@2325 563
Ian@8435 564 /**
Ian@8435 565 * Translates a virtual address in the context of a given domain and
Ian@8435 566 * vcpu returning the machine page frame number of the associated
Ian@8435 567 * page.
Ian@8435 568 *
Ian@8435 569 * @parm xc_handle a handle on an open hypervisor interface
Ian@8435 570 * @parm dom the domain to perform the translation in
Ian@8435 571 * @parm vcpu the vcpu to perform the translation on
Ian@8435 572 * @parm virt the virtual address to translate
Ian@8435 573 */
Ian@8435 574 unsigned long xc_translate_foreign_address(int xc_handle, uint32_t dom,
kaf24@9221 575 int vcpu, unsigned long long virt);
Ian@8435 576
keir@14101 577
keir@14101 578 /**
keir@14101 579 * DEPRECATED. Avoid using this, as it does not correctly account for PFNs
keir@14101 580 * without a backing MFN.
keir@14101 581 */
kfraser@13594 582 int xc_get_pfn_list(int xc_handle, uint32_t domid, uint64_t *pfn_buf,
cl349@4853 583 unsigned long max_pfns);
iap10@3390 584
awilliam@12005 585 unsigned long xc_ia64_fpsr_default(void);
awilliam@12005 586
kaf24@7339 587 int xc_ia64_get_pfn_list(int xc_handle, uint32_t domid,
kaf24@10276 588 xen_pfn_t *pfn_buf,
kaf24@7339 589 unsigned int start_page, unsigned int nr_pages);
kaf24@5914 590
djm@7536 591 int xc_copy_to_domain_page(int xc_handle, uint32_t domid,
kaf24@9221 592 unsigned long dst_pfn, const char *src_page);
djm@7536 593
kaf24@7786 594 int xc_clear_domain_page(int xc_handle, uint32_t domid,
kaf24@7786 595 unsigned long dst_pfn);
kaf24@7786 596
kaf24@7339 597 long xc_get_max_pages(int xc_handle, uint32_t domid);
djm@6856 598
cl349@6389 599 int xc_mmuext_op(int xc_handle, struct mmuext_op *op, unsigned int nr_ops,
kaf24@9221 600 domid_t dom);
cl349@6389 601
kaf24@6468 602 int xc_memory_op(int xc_handle, int cmd, void *arg);
cl349@6389 603
kaf24@7339 604 int xc_get_pfn_type_batch(int xc_handle, uint32_t dom,
kfraser@13594 605 int num, uint32_t *arr);
cl349@6389 606
cl349@6389 607
kaf24@5318 608 /* Get current total pages allocated to a domain. */
kaf24@7339 609 long xc_get_tot_pages(int xc_handle, uint32_t domid);
kaf24@5318 610
kaf24@7566 611
kaf24@7566 612 /*
kaf24@7566 613 * Trace Buffer Operations
kaf24@7566 614 */
kaf24@7566 615
kaf24@7566 616 /**
kaf24@9996 617 * xc_tbuf_enable - enable tracing buffers
kaf24@7566 618 *
kaf24@7566 619 * @parm xc_handle a handle to an open hypervisor interface
kaf24@9996 620 * @parm cnt size of tracing buffers to create (in pages)
kaf24@9996 621 * @parm mfn location to store mfn of the trace buffers to
kaf24@9996 622 * @parm size location to store the size (in bytes) of a trace buffer to
kaf24@9996 623 *
kaf24@9996 624 * Gets the machine address of the trace pointer area and the size of the
kaf24@9996 625 * per CPU buffers.
kaf24@7566 626 */
kfraser@12485 627 int xc_tbuf_enable(int xc_handle, unsigned long pages,
kfraser@12485 628 unsigned long *mfn, unsigned long *size);
kaf24@9996 629
kaf24@9996 630 /*
kaf24@9996 631 * Disable tracing buffers.
kaf24@9996 632 */
kaf24@9996 633 int xc_tbuf_disable(int xc_handle);
kaf24@7566 634
kaf24@7566 635 /**
kaf24@7571 636 * This function sets the size of the trace buffers. Setting the size
kaf24@7571 637 * is currently a one-shot operation that may be performed either at boot
kaf24@7571 638 * time or via this interface, not both. The buffer size must be set before
kaf24@7571 639 * enabling tracing.
kaf24@7566 640 *
kaf24@7566 641 * @parm xc_handle a handle to an open hypervisor interface
kaf24@7566 642 * @parm size the size in pages per cpu for the trace buffers
kaf24@7566 643 * @return 0 on success, -1 on failure.
kaf24@7566 644 */
kaf24@9996 645 int xc_tbuf_set_size(int xc_handle, unsigned long size);
kaf24@7566 646
kaf24@7566 647 /**
kaf24@9660 648 * This function retrieves the current size of the trace buffers.
kaf24@7566 649 * Note that the size returned is in terms of bytes, not pages.
kaf24@7566 650
kaf24@7566 651 * @parm xc_handle a handle to an open hypervisor interface
kaf24@7566 652 * @parm size will contain the size in bytes for the trace buffers
kaf24@7566 653 * @return 0 on success, -1 on failure.
kaf24@7566 654 */
kaf24@9996 655 int xc_tbuf_get_size(int xc_handle, unsigned long *size);
kaf24@9907 656
kaf24@9907 657 int xc_tbuf_set_cpu_mask(int xc_handle, uint32_t mask);
kaf24@9907 658
kaf24@9907 659 int xc_tbuf_set_evt_mask(int xc_handle, uint32_t mask);
kaf24@7566 660
kfraser@11257 661 int xc_domctl(int xc_handle, struct xen_domctl *domctl);
kfraser@11257 662 int xc_sysctl(int xc_handle, struct xen_sysctl *sysctl);
cwc22@3985 663
vh249@6549 664 int xc_version(int xc_handle, int cmd, void *arg);
vh249@6549 665
cl349@6389 666 /*
cl349@6389 667 * MMU updates.
cl349@6389 668 */
cl349@6389 669 #define MAX_MMU_UPDATES 1024
cl349@6389 670 struct xc_mmu {
cl349@6389 671 mmu_update_t updates[MAX_MMU_UPDATES];
cl349@6389 672 int idx;
cl349@6389 673 domid_t subject;
cl349@6389 674 };
cl349@6389 675 typedef struct xc_mmu xc_mmu_t;
cl349@6389 676 xc_mmu_t *xc_init_mmu_updates(int xc_handle, domid_t dom);
kaf24@9660 677 int xc_add_mmu_update(int xc_handle, xc_mmu_t *mmu,
iap10@6680 678 unsigned long long ptr, unsigned long long val);
cl349@6389 679 int xc_finish_mmu_updates(int xc_handle, xc_mmu_t *mmu);
cl349@6389 680
kfraser@12485 681 int xc_acm_op(int xc_handle, int cmd, void *arg, unsigned long arg_size);
kaf24@9907 682
kaf24@10355 683 /*
kaf24@10355 684 * Return a handle to the event channel driver, or -1 on failure, in which case
kaf24@10355 685 * errno will be set appropriately.
kaf24@10355 686 */
kaf24@10355 687 int xc_evtchn_open(void);
kaf24@10355 688
kaf24@10355 689 /*
kaf24@10355 690 * Close a handle previously allocated with xc_evtchn_open().
kaf24@10355 691 */
kaf24@10355 692 int xc_evtchn_close(int xce_handle);
kaf24@10355 693
kaf24@10355 694 /*
kaf24@10355 695 * Return an fd that can be select()ed on for further calls to
kaf24@10355 696 * xc_evtchn_pending().
kaf24@10355 697 */
kaf24@10355 698 int xc_evtchn_fd(int xce_handle);
kaf24@10355 699
kaf24@10355 700 /*
kaf24@10355 701 * Notify the given event channel. Returns -1 on failure, in which case
kaf24@10355 702 * errno will be set appropriately.
kaf24@10355 703 */
kaf24@10355 704 int xc_evtchn_notify(int xce_handle, evtchn_port_t port);
kaf24@10355 705
kaf24@10355 706 /*
kfraser@12694 707 * Returns a new event port awaiting interdomain connection from the given
kfraser@12694 708 * domain ID, or -1 on failure, in which case errno will be set appropriately.
kfraser@12694 709 */
kfraser@12694 710 evtchn_port_t xc_evtchn_bind_unbound_port(int xce_handle, int domid);
kfraser@12694 711
kfraser@12694 712 /*
kaf24@10355 713 * Returns a new event port bound to the remote port for the given domain ID,
kaf24@10355 714 * or -1 on failure, in which case errno will be set appropriately.
kaf24@10355 715 */
kaf24@10355 716 evtchn_port_t xc_evtchn_bind_interdomain(int xce_handle, int domid,
kaf24@10355 717 evtchn_port_t remote_port);
kaf24@10355 718
kaf24@10355 719 /*
kaf24@10355 720 * Unbind the given event channel. Returns -1 on failure, in which case errno
kaf24@10355 721 * will be set appropriately.
kaf24@10355 722 */
kaf24@10355 723 int xc_evtchn_unbind(int xce_handle, evtchn_port_t port);
kaf24@10355 724
kaf24@10355 725 /*
kaf24@10355 726 * Bind an event channel to the given VIRQ. Returns the event channel bound to
kaf24@10355 727 * the VIRQ, or -1 on failure, in which case errno will be set appropriately.
kaf24@10355 728 */
kaf24@10355 729 evtchn_port_t xc_evtchn_bind_virq(int xce_handle, unsigned int virq);
kaf24@10355 730
kaf24@10355 731 /*
kaf24@10355 732 * Return the next event channel to become pending, or -1 on failure, in which
kaf24@10355 733 * case errno will be set appropriately.
kaf24@10355 734 */
kaf24@10355 735 evtchn_port_t xc_evtchn_pending(int xce_handle);
kaf24@10355 736
kaf24@10355 737 /*
kaf24@10355 738 * Unmask the given event channel. Returns -1 on failure, in which case errno
kaf24@10355 739 * will be set appropriately.
kaf24@10355 740 */
kaf24@10355 741 int xc_evtchn_unmask(int xce_handle, evtchn_port_t port);
kaf24@10355 742
kfraser@12504 743 int xc_hvm_set_pci_intx_level(
kfraser@12694 744 int xc_handle, domid_t dom,
kfraser@12504 745 uint8_t domain, uint8_t bus, uint8_t device, uint8_t intx,
kfraser@12504 746 unsigned int level);
kfraser@12504 747 int xc_hvm_set_isa_irq_level(
kfraser@12694 748 int xc_handle, domid_t dom,
kfraser@12504 749 uint8_t isa_irq,
kfraser@12504 750 unsigned int level);
kfraser@12504 751
kfraser@12504 752 int xc_hvm_set_pci_link_route(
kfraser@12694 753 int xc_handle, domid_t dom, uint8_t link, uint8_t isa_irq);
kfraser@12275 754
kfraser@12765 755
kfraser@12765 756 typedef enum {
kfraser@12765 757 XC_ERROR_NONE = 0,
kfraser@12765 758 XC_INTERNAL_ERROR = 1,
kfraser@12765 759 XC_INVALID_KERNEL = 2,
ack@13623 760 XC_INVALID_PARAM = 3,
ack@13623 761 XC_OUT_OF_MEMORY = 4,
kfraser@12765 762 } xc_error_code;
kfraser@12765 763
kfraser@12765 764 #define XC_MAX_ERROR_MSG_LEN 1024
kfraser@12765 765 typedef struct {
kfraser@12765 766 int code;
kfraser@12765 767 char message[XC_MAX_ERROR_MSG_LEN];
kfraser@12765 768 } xc_error;
kfraser@12765 769
kfraser@12765 770 /*
kfraser@12765 771 * Return a pointer to the last error. This pointer and the
kfraser@12765 772 * data pointed to are only valid until the next call to
kfraser@12765 773 * libxc.
kfraser@12765 774 */
ewan@14296 775 const xc_error *xc_get_last_error(void);
kfraser@12765 776
kfraser@12765 777 /*
kfraser@12765 778 * Clear the last error
kfraser@12765 779 */
kfraser@12765 780 void xc_clear_last_error(void);
kfraser@12765 781
ewan@14296 782 typedef void (*xc_error_handler)(const xc_error * const err);
kfraser@12765 783
kfraser@12765 784 /*
kfraser@12765 785 * The default error handler which prints to stderr
kfraser@12765 786 */
ewan@14296 787 void xc_default_error_handler(const xc_error * const err);
kfraser@12765 788
kfraser@12765 789 /*
kfraser@12765 790 * Convert an error code into a text description
kfraser@12765 791 */
kfraser@12765 792 const char *xc_error_code_to_desc(int code);
kfraser@12765 793
kfraser@12765 794 /*
kfraser@12765 795 * Registers a callback to handle errors
kfraser@12765 796 */
kfraser@12765 797 xc_error_handler xc_set_error_handler(xc_error_handler handler);
kfraser@12765 798
kfraser@12988 799 /* PowerPC specific. */
kfraser@12988 800 int xc_alloc_real_mode_area(int xc_handle,
kfraser@12988 801 uint32_t domid,
kfraser@12988 802 unsigned int log);
cl349@6389 803 #endif