direct-io.hg

annotate tools/libxc/xenctrl.h @ 11257:86d26e6ec89b

Replace dom0_ops hypercall with three new hypercalls:
1. platform_op -- used by dom0 kernel to perform actions on the
hardware platform (e.g., MTRR access, microcode update, platform
quirks, ...)
2. domctl -- used by management tools to control a specified domain
3. sysctl -- used by management tools for system-wide actions

Benefits include more sensible factoring of actions to
hypercalls. Also allows tool compatibility to be tracked separately
from the dom0 kernel. The assumption is that it will be easier to
replace libxenctrl, libxenguest and Xen as a matched set if the
dom0 kernel does not need to be replaced too (e.g., because that
would require vendor revalidation).

From here on we hope to maintain dom0 kernel compatibility. This
promise is not extended to tool compatibility beyond the existing
guarantee that compatibility will not be broken within a three-level
stable release [3.0.2, 3.0.3, etc.].

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