direct-io.hg

annotate tools/libxc/xenctrl.h @ 11672:7e79259c2c17

[LINUX] Make evtchn device use a dynamic minor number.

Also update the code in tools to create the device node if udev fails.
The tools now read the sysfs system to find the minor number needed.

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