win-pvdrivers

annotate common/include/public/xen.h @ 62:edd4a2ad5b44

Removed old inf files
author James Harper <james.harper@bendigoit.com.au>
date Wed Dec 19 10:22:50 2007 +1100 (2007-12-19)
parents 5712dede5a1b
children b474e898b409
rev   line source
andy@12 1 /******************************************************************************
andy@12 2 * xen.h
andy@12 3 *
andy@12 4 * Guest OS interface to Xen.
andy@12 5 *
andy@12 6 * Permission is hereby granted, free of charge, to any person obtaining a copy
andy@12 7 * of this software and associated documentation files (the "Software"), to
andy@12 8 * deal in the Software without restriction, including without limitation the
andy@12 9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
andy@12 10 * sell copies of the Software, and to permit persons to whom the Software is
andy@12 11 * furnished to do so, subject to the following conditions:
andy@12 12 *
andy@12 13 * The above copyright notice and this permission notice shall be included in
andy@12 14 * all copies or substantial portions of the Software.
andy@12 15 *
andy@12 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
andy@12 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
andy@12 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
andy@12 19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
andy@12 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
andy@12 21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
andy@12 22 * DEALINGS IN THE SOFTWARE.
andy@12 23 *
andy@12 24 * Copyright (c) 2004, K A Fraser
andy@12 25 */
andy@12 26
andy@12 27 #ifndef __XEN_PUBLIC_XEN_H__
andy@12 28 #define __XEN_PUBLIC_XEN_H__
andy@12 29
andy@12 30 #include "xen-compat.h"
andy@12 31
andy@12 32 #if defined(__i386__) || defined(__x86_64__)
andy@12 33 #include "arch-x86/xen.h"
andy@12 34 #elif defined(__ia64__)
andy@12 35 #include "arch-ia64.h"
andy@12 36 #elif defined(__powerpc__)
andy@12 37 #include "arch-powerpc.h"
andy@12 38 #else
andy@12 39 #error "Unsupported architecture"
andy@12 40 #endif
andy@12 41
andy@12 42 /*
andy@12 43 * HYPERCALLS
andy@12 44 */
andy@12 45
andy@12 46 #define __HYPERVISOR_set_trap_table 0
andy@12 47 #define __HYPERVISOR_mmu_update 1
andy@12 48 #define __HYPERVISOR_set_gdt 2
andy@12 49 #define __HYPERVISOR_stack_switch 3
andy@12 50 #define __HYPERVISOR_set_callbacks 4
andy@12 51 #define __HYPERVISOR_fpu_taskswitch 5
andy@12 52 #define __HYPERVISOR_sched_op_compat 6 /* compat since 0x00030101 */
andy@12 53 #define __HYPERVISOR_platform_op 7
andy@12 54 #define __HYPERVISOR_set_debugreg 8
andy@12 55 #define __HYPERVISOR_get_debugreg 9
andy@12 56 #define __HYPERVISOR_update_descriptor 10
andy@12 57 #define __HYPERVISOR_memory_op 12
andy@12 58 #define __HYPERVISOR_multicall 13
andy@12 59 #define __HYPERVISOR_update_va_mapping 14
andy@12 60 #define __HYPERVISOR_set_timer_op 15
andy@12 61 #define __HYPERVISOR_event_channel_op_compat 16 /* compat since 0x00030202 */
andy@12 62 #define __HYPERVISOR_xen_version 17
andy@12 63 #define __HYPERVISOR_console_io 18
andy@12 64 #define __HYPERVISOR_physdev_op_compat 19 /* compat since 0x00030202 */
andy@12 65 #define __HYPERVISOR_grant_table_op 20
andy@12 66 #define __HYPERVISOR_vm_assist 21
andy@12 67 #define __HYPERVISOR_update_va_mapping_otherdomain 22
andy@12 68 #define __HYPERVISOR_iret 23 /* x86 only */
andy@12 69 #define __HYPERVISOR_vcpu_op 24
andy@12 70 #define __HYPERVISOR_set_segment_base 25 /* x86/64 only */
andy@12 71 #define __HYPERVISOR_mmuext_op 26
andy@12 72 #define __HYPERVISOR_acm_op 27
andy@12 73 #define __HYPERVISOR_nmi_op 28
andy@12 74 #define __HYPERVISOR_sched_op 29
andy@12 75 #define __HYPERVISOR_callback_op 30
andy@12 76 #define __HYPERVISOR_xenoprof_op 31
andy@12 77 #define __HYPERVISOR_event_channel_op 32
andy@12 78 #define __HYPERVISOR_physdev_op 33
andy@12 79 #define __HYPERVISOR_hvm_op 34
andy@12 80 #define __HYPERVISOR_sysctl 35
andy@12 81 #define __HYPERVISOR_domctl 36
andy@12 82 #define __HYPERVISOR_kexec_op 37
andy@12 83
andy@12 84 /* Architecture-specific hypercall definitions. */
andy@12 85 #define __HYPERVISOR_arch_0 48
andy@12 86 #define __HYPERVISOR_arch_1 49
andy@12 87 #define __HYPERVISOR_arch_2 50
andy@12 88 #define __HYPERVISOR_arch_3 51
andy@12 89 #define __HYPERVISOR_arch_4 52
andy@12 90 #define __HYPERVISOR_arch_5 53
andy@12 91 #define __HYPERVISOR_arch_6 54
andy@12 92 #define __HYPERVISOR_arch_7 55
andy@12 93
andy@12 94 /*
andy@12 95 * HYPERCALL COMPATIBILITY.
andy@12 96 */
andy@12 97
andy@12 98 /* New sched_op hypercall introduced in 0x00030101. */
andy@12 99 #if __XEN_INTERFACE_VERSION__ < 0x00030101
andy@12 100 #undef __HYPERVISOR_sched_op
andy@12 101 #define __HYPERVISOR_sched_op __HYPERVISOR_sched_op_compat
andy@12 102 #endif
andy@12 103
andy@12 104 /* New event-channel and physdev hypercalls introduced in 0x00030202. */
andy@12 105 #if __XEN_INTERFACE_VERSION__ < 0x00030202
andy@12 106 #undef __HYPERVISOR_event_channel_op
andy@12 107 #define __HYPERVISOR_event_channel_op __HYPERVISOR_event_channel_op_compat
andy@12 108 #undef __HYPERVISOR_physdev_op
andy@12 109 #define __HYPERVISOR_physdev_op __HYPERVISOR_physdev_op_compat
andy@12 110 #endif
andy@12 111
andy@12 112 /* New platform_op hypercall introduced in 0x00030204. */
andy@12 113 #if __XEN_INTERFACE_VERSION__ < 0x00030204
andy@12 114 #define __HYPERVISOR_dom0_op __HYPERVISOR_platform_op
andy@12 115 #endif
andy@12 116
andy@12 117 /*
andy@12 118 * VIRTUAL INTERRUPTS
andy@12 119 *
andy@12 120 * Virtual interrupts that a guest OS may receive from Xen.
andy@12 121 *
andy@12 122 * In the side comments, 'V.' denotes a per-VCPU VIRQ while 'G.' denotes a
andy@12 123 * global VIRQ. The former can be bound once per VCPU and cannot be re-bound.
andy@12 124 * The latter can be allocated only once per guest: they must initially be
andy@12 125 * allocated to VCPU0 but can subsequently be re-bound.
andy@12 126 */
andy@12 127 #define VIRQ_TIMER 0 /* V. Timebase update, and/or requested timeout. */
andy@12 128 #define VIRQ_DEBUG 1 /* V. Request guest to dump debug info. */
andy@12 129 #define VIRQ_CONSOLE 2 /* G. (DOM0) Bytes received on emergency console. */
andy@12 130 #define VIRQ_DOM_EXC 3 /* G. (DOM0) Exceptional event for some domain. */
andy@12 131 #define VIRQ_TBUF 4 /* G. (DOM0) Trace buffer has records available. */
andy@12 132 #define VIRQ_DEBUGGER 6 /* G. (DOM0) A domain has paused for debugging. */
andy@12 133 #define VIRQ_XENOPROF 7 /* V. XenOprofile interrupt: new sample available */
andy@12 134 #define VIRQ_CON_RING 8 /* G. (DOM0) Bytes received on console */
andy@12 135
andy@12 136 /* Architecture-specific VIRQ definitions. */
andy@12 137 #define VIRQ_ARCH_0 16
andy@12 138 #define VIRQ_ARCH_1 17
andy@12 139 #define VIRQ_ARCH_2 18
andy@12 140 #define VIRQ_ARCH_3 19
andy@12 141 #define VIRQ_ARCH_4 20
andy@12 142 #define VIRQ_ARCH_5 21
andy@12 143 #define VIRQ_ARCH_6 22
andy@12 144 #define VIRQ_ARCH_7 23
andy@12 145
andy@12 146 #define NR_VIRQS 24
andy@12 147
andy@12 148 /*
andy@12 149 * MMU-UPDATE REQUESTS
andy@12 150 *
andy@12 151 * HYPERVISOR_mmu_update() accepts a list of (ptr, val) pairs.
andy@12 152 * A foreigndom (FD) can be specified (or DOMID_SELF for none).
andy@12 153 * Where the FD has some effect, it is described below.
andy@12 154 * ptr[1:0] specifies the appropriate MMU_* command.
andy@12 155 *
andy@12 156 * ptr[1:0] == MMU_NORMAL_PT_UPDATE:
andy@12 157 * Updates an entry in a page table. If updating an L1 table, and the new
andy@12 158 * table entry is valid/present, the mapped frame must belong to the FD, if
andy@12 159 * an FD has been specified. If attempting to map an I/O page then the
andy@12 160 * caller assumes the privilege of the FD.
andy@12 161 * FD == DOMID_IO: Permit /only/ I/O mappings, at the priv level of the caller.
andy@12 162 * FD == DOMID_XEN: Map restricted areas of Xen's heap space.
andy@12 163 * ptr[:2] -- Machine address of the page-table entry to modify.
andy@12 164 * val -- Value to write.
andy@12 165 *
andy@12 166 * ptr[1:0] == MMU_MACHPHYS_UPDATE:
andy@12 167 * Updates an entry in the machine->pseudo-physical mapping table.
andy@12 168 * ptr[:2] -- Machine address within the frame whose mapping to modify.
andy@12 169 * The frame must belong to the FD, if one is specified.
andy@12 170 * val -- Value to write into the mapping entry.
andy@12 171 */
andy@12 172 #define MMU_NORMAL_PT_UPDATE 0 /* checked '*ptr = val'. ptr is MA. */
andy@12 173 #define MMU_MACHPHYS_UPDATE 1 /* ptr = MA of frame to modify entry for */
andy@12 174
andy@12 175 /*
andy@12 176 * MMU EXTENDED OPERATIONS
andy@12 177 *
andy@12 178 * HYPERVISOR_mmuext_op() accepts a list of mmuext_op structures.
andy@12 179 * A foreigndom (FD) can be specified (or DOMID_SELF for none).
andy@12 180 * Where the FD has some effect, it is described below.
andy@12 181 *
andy@12 182 * cmd: MMUEXT_(UN)PIN_*_TABLE
andy@12 183 * mfn: Machine frame number to be (un)pinned as a p.t. page.
andy@12 184 * The frame must belong to the FD, if one is specified.
andy@12 185 *
andy@12 186 * cmd: MMUEXT_NEW_BASEPTR
andy@12 187 * mfn: Machine frame number of new page-table base to install in MMU.
andy@12 188 *
andy@12 189 * cmd: MMUEXT_NEW_USER_BASEPTR [x86/64 only]
andy@12 190 * mfn: Machine frame number of new page-table base to install in MMU
andy@12 191 * when in user space.
andy@12 192 *
andy@12 193 * cmd: MMUEXT_TLB_FLUSH_LOCAL
andy@12 194 * No additional arguments. Flushes local TLB.
andy@12 195 *
andy@12 196 * cmd: MMUEXT_INVLPG_LOCAL
andy@12 197 * linear_addr: Linear address to be flushed from the local TLB.
andy@12 198 *
andy@12 199 * cmd: MMUEXT_TLB_FLUSH_MULTI
andy@12 200 * vcpumask: Pointer to bitmap of VCPUs to be flushed.
andy@12 201 *
andy@12 202 * cmd: MMUEXT_INVLPG_MULTI
andy@12 203 * linear_addr: Linear address to be flushed.
andy@12 204 * vcpumask: Pointer to bitmap of VCPUs to be flushed.
andy@12 205 *
andy@12 206 * cmd: MMUEXT_TLB_FLUSH_ALL
andy@12 207 * No additional arguments. Flushes all VCPUs' TLBs.
andy@12 208 *
andy@12 209 * cmd: MMUEXT_INVLPG_ALL
andy@12 210 * linear_addr: Linear address to be flushed from all VCPUs' TLBs.
andy@12 211 *
andy@12 212 * cmd: MMUEXT_FLUSH_CACHE
andy@12 213 * No additional arguments. Writes back and flushes cache contents.
andy@12 214 *
andy@12 215 * cmd: MMUEXT_SET_LDT
andy@12 216 * linear_addr: Linear address of LDT base (NB. must be page-aligned).
andy@12 217 * nr_ents: Number of entries in LDT.
andy@12 218 */
andy@12 219 #define MMUEXT_PIN_L1_TABLE 0
andy@12 220 #define MMUEXT_PIN_L2_TABLE 1
andy@12 221 #define MMUEXT_PIN_L3_TABLE 2
andy@12 222 #define MMUEXT_PIN_L4_TABLE 3
andy@12 223 #define MMUEXT_UNPIN_TABLE 4
andy@12 224 #define MMUEXT_NEW_BASEPTR 5
andy@12 225 #define MMUEXT_TLB_FLUSH_LOCAL 6
andy@12 226 #define MMUEXT_INVLPG_LOCAL 7
andy@12 227 #define MMUEXT_TLB_FLUSH_MULTI 8
andy@12 228 #define MMUEXT_INVLPG_MULTI 9
andy@12 229 #define MMUEXT_TLB_FLUSH_ALL 10
andy@12 230 #define MMUEXT_INVLPG_ALL 11
andy@12 231 #define MMUEXT_FLUSH_CACHE 12
andy@12 232 #define MMUEXT_SET_LDT 13
andy@12 233 #define MMUEXT_NEW_USER_BASEPTR 15
andy@12 234
andy@12 235 #ifndef __ASSEMBLY__
andy@12 236 struct mmuext_op {
andy@12 237 unsigned int cmd;
andy@12 238 union {
andy@12 239 /* [UN]PIN_TABLE, NEW_BASEPTR, NEW_USER_BASEPTR */
andy@12 240 xen_pfn_t mfn;
andy@12 241 /* INVLPG_LOCAL, INVLPG_ALL, SET_LDT */
andy@12 242 unsigned long linear_addr;
andy@12 243 } arg1;
andy@12 244 union {
andy@12 245 /* SET_LDT */
andy@12 246 unsigned int nr_ents;
andy@12 247 /* TLB_FLUSH_MULTI, INVLPG_MULTI */
andy@12 248 XEN_GUEST_HANDLE_00030205(void) vcpumask;
andy@12 249 } arg2;
andy@12 250 };
andy@12 251 typedef struct mmuext_op mmuext_op_t;
andy@12 252 DEFINE_XEN_GUEST_HANDLE(mmuext_op_t);
andy@12 253 #endif
andy@12 254
andy@12 255 /* These are passed as 'flags' to update_va_mapping. They can be ORed. */
andy@12 256 /* When specifying UVMF_MULTI, also OR in a pointer to a CPU bitmap. */
andy@12 257 /* UVMF_LOCAL is merely UVMF_MULTI with a NULL bitmap pointer. */
andy@12 258 #define UVMF_NONE (0UL<<0) /* No flushing at all. */
andy@12 259 #define UVMF_TLB_FLUSH (1UL<<0) /* Flush entire TLB(s). */
andy@12 260 #define UVMF_INVLPG (2UL<<0) /* Flush only one entry. */
andy@12 261 #define UVMF_FLUSHTYPE_MASK (3UL<<0)
andy@12 262 #define UVMF_MULTI (0UL<<2) /* Flush subset of TLBs. */
andy@12 263 #define UVMF_LOCAL (0UL<<2) /* Flush local TLB. */
andy@12 264 #define UVMF_ALL (1UL<<2) /* Flush all TLBs. */
andy@12 265
andy@12 266 /*
andy@12 267 * Commands to HYPERVISOR_console_io().
andy@12 268 */
andy@12 269 #define CONSOLEIO_write 0
andy@12 270 #define CONSOLEIO_read 1
andy@12 271
andy@12 272 /*
andy@12 273 * Commands to HYPERVISOR_vm_assist().
andy@12 274 */
andy@12 275 #define VMASST_CMD_enable 0
andy@12 276 #define VMASST_CMD_disable 1
andy@12 277
andy@12 278 /* x86/32 guests: simulate full 4GB segment limits. */
andy@12 279 #define VMASST_TYPE_4gb_segments 0
andy@12 280
andy@12 281 /* x86/32 guests: trap (vector 15) whenever above vmassist is used. */
andy@12 282 #define VMASST_TYPE_4gb_segments_notify 1
andy@12 283
andy@12 284 /*
andy@12 285 * x86 guests: support writes to bottom-level PTEs.
andy@12 286 * NB1. Page-directory entries cannot be written.
andy@12 287 * NB2. Guest must continue to remove all writable mappings of PTEs.
andy@12 288 */
andy@12 289 #define VMASST_TYPE_writable_pagetables 2
andy@12 290
andy@12 291 /* x86/PAE guests: support PDPTs above 4GB. */
andy@12 292 #define VMASST_TYPE_pae_extended_cr3 3
andy@12 293
andy@12 294 #define MAX_VMASST_TYPE 3
andy@12 295
andy@12 296 #ifndef __ASSEMBLY__
andy@12 297
andy@12 298 typedef uint16_t domid_t;
andy@12 299
andy@12 300 /* Domain ids >= DOMID_FIRST_RESERVED cannot be used for ordinary domains. */
andy@12 301 #define DOMID_FIRST_RESERVED (0x7FF0U)
andy@12 302
andy@12 303 /* DOMID_SELF is used in certain contexts to refer to oneself. */
andy@12 304 #define DOMID_SELF (0x7FF0U)
andy@12 305
andy@12 306 /*
andy@12 307 * DOMID_IO is used to restrict page-table updates to mapping I/O memory.
andy@12 308 * Although no Foreign Domain need be specified to map I/O pages, DOMID_IO
andy@12 309 * is useful to ensure that no mappings to the OS's own heap are accidentally
andy@12 310 * installed. (e.g., in Linux this could cause havoc as reference counts
andy@12 311 * aren't adjusted on the I/O-mapping code path).
andy@12 312 * This only makes sense in MMUEXT_SET_FOREIGNDOM, but in that context can
andy@12 313 * be specified by any calling domain.
andy@12 314 */
andy@12 315 #define DOMID_IO (0x7FF1U)
andy@12 316
andy@12 317 /*
andy@12 318 * DOMID_XEN is used to allow privileged domains to map restricted parts of
andy@12 319 * Xen's heap space (e.g., the machine_to_phys table).
andy@12 320 * This only makes sense in MMUEXT_SET_FOREIGNDOM, and is only permitted if
andy@12 321 * the caller is privileged.
andy@12 322 */
andy@12 323 #define DOMID_XEN (0x7FF2U)
andy@12 324
andy@12 325 /*
andy@12 326 * Send an array of these to HYPERVISOR_mmu_update().
andy@12 327 * NB. The fields are natural pointer/address size for this architecture.
andy@12 328 */
andy@12 329 struct mmu_update {
andy@12 330 uint64_t ptr; /* Machine address of PTE. */
andy@12 331 uint64_t val; /* New contents of PTE. */
andy@12 332 };
andy@12 333 typedef struct mmu_update mmu_update_t;
andy@12 334 DEFINE_XEN_GUEST_HANDLE(mmu_update_t);
andy@12 335
andy@12 336 /*
andy@12 337 * Send an array of these to HYPERVISOR_multicall().
andy@12 338 * NB. The fields are natural register size for this architecture.
andy@12 339 */
andy@12 340 struct multicall_entry {
andy@12 341 unsigned long op, result;
andy@12 342 unsigned long args[6];
andy@12 343 };
andy@12 344 typedef struct multicall_entry multicall_entry_t;
andy@12 345 DEFINE_XEN_GUEST_HANDLE(multicall_entry_t);
andy@12 346
andy@12 347 /*
andy@12 348 * Event channel endpoints per domain:
andy@12 349 * 1024 if a long is 32 bits; 4096 if a long is 64 bits.
andy@12 350 */
andy@12 351 #define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64)
andy@12 352
andy@12 353 struct vcpu_time_info {
andy@12 354 /*
andy@12 355 * Updates to the following values are preceded and followed by an
andy@12 356 * increment of 'version'. The guest can therefore detect updates by
andy@12 357 * looking for changes to 'version'. If the least-significant bit of
andy@12 358 * the version number is set then an update is in progress and the guest
andy@12 359 * must wait to read a consistent set of values.
andy@12 360 * The correct way to interact with the version number is similar to
andy@12 361 * Linux's seqlock: see the implementations of read_seqbegin/read_seqretry.
andy@12 362 */
andy@12 363 uint32_t version;
andy@12 364 uint32_t pad0;
andy@12 365 uint64_t tsc_timestamp; /* TSC at last update of time vals. */
andy@12 366 uint64_t system_time; /* Time, in nanosecs, since boot. */
andy@12 367 /*
andy@12 368 * Current system time:
andy@12 369 * system_time +
andy@12 370 * ((((tsc - tsc_timestamp) << tsc_shift) * tsc_to_system_mul) >> 32)
andy@12 371 * CPU frequency (Hz):
andy@12 372 * ((10^9 << 32) / tsc_to_system_mul) >> tsc_shift
andy@12 373 */
andy@12 374 uint32_t tsc_to_system_mul;
andy@12 375 int8_t tsc_shift;
andy@12 376 int8_t pad1[3];
andy@12 377 }; /* 32 bytes */
andy@12 378 typedef struct vcpu_time_info vcpu_time_info_t;
andy@12 379
andy@12 380 struct vcpu_info {
andy@12 381 /*
andy@12 382 * 'evtchn_upcall_pending' is written non-zero by Xen to indicate
andy@12 383 * a pending notification for a particular VCPU. It is then cleared
andy@12 384 * by the guest OS /before/ checking for pending work, thus avoiding
andy@12 385 * a set-and-check race. Note that the mask is only accessed by Xen
andy@12 386 * on the CPU that is currently hosting the VCPU. This means that the
andy@12 387 * pending and mask flags can be updated by the guest without special
andy@12 388 * synchronisation (i.e., no need for the x86 LOCK prefix).
andy@12 389 * This may seem suboptimal because if the pending flag is set by
andy@12 390 * a different CPU then an IPI may be scheduled even when the mask
andy@12 391 * is set. However, note:
andy@12 392 * 1. The task of 'interrupt holdoff' is covered by the per-event-
andy@12 393 * channel mask bits. A 'noisy' event that is continually being
andy@12 394 * triggered can be masked at source at this very precise
andy@12 395 * granularity.
andy@12 396 * 2. The main purpose of the per-VCPU mask is therefore to restrict
andy@12 397 * reentrant execution: whether for concurrency control, or to
andy@12 398 * prevent unbounded stack usage. Whatever the purpose, we expect
andy@12 399 * that the mask will be asserted only for short periods at a time,
andy@12 400 * and so the likelihood of a 'spurious' IPI is suitably small.
andy@12 401 * The mask is read before making an event upcall to the guest: a
andy@12 402 * non-zero mask therefore guarantees that the VCPU will not receive
andy@12 403 * an upcall activation. The mask is cleared when the VCPU requests
andy@12 404 * to block: this avoids wakeup-waiting races.
andy@12 405 */
andy@12 406 uint8_t evtchn_upcall_pending;
andy@12 407 uint8_t evtchn_upcall_mask;
andy@12 408 unsigned long evtchn_pending_sel;
andy@12 409 struct arch_vcpu_info arch;
andy@12 410 struct vcpu_time_info time;
andy@12 411 }; /* 64 bytes (x86) */
andy@12 412 #ifndef __XEN__
andy@12 413 typedef struct vcpu_info vcpu_info_t;
andy@12 414 #endif
andy@12 415
andy@12 416 /*
andy@12 417 * Xen/kernel shared data -- pointer provided in start_info.
andy@12 418 *
andy@12 419 * This structure is defined to be both smaller than a page, and the
andy@12 420 * only data on the shared page, but may vary in actual size even within
andy@12 421 * compatible Xen versions; guests should not rely on the size
andy@12 422 * of this structure remaining constant.
andy@12 423 */
andy@12 424 struct shared_info {
andy@12 425 struct vcpu_info vcpu_info[MAX_VIRT_CPUS];
andy@12 426
andy@12 427 /*
andy@12 428 * A domain can create "event channels" on which it can send and receive
andy@12 429 * asynchronous event notifications. There are three classes of event that
andy@12 430 * are delivered by this mechanism:
andy@12 431 * 1. Bi-directional inter- and intra-domain connections. Domains must
andy@12 432 * arrange out-of-band to set up a connection (usually by allocating
andy@12 433 * an unbound 'listener' port and avertising that via a storage service
andy@12 434 * such as xenstore).
andy@12 435 * 2. Physical interrupts. A domain with suitable hardware-access
andy@12 436 * privileges can bind an event-channel port to a physical interrupt
andy@12 437 * source.
andy@12 438 * 3. Virtual interrupts ('events'). A domain can bind an event-channel
andy@12 439 * port to a virtual interrupt source, such as the virtual-timer
andy@12 440 * device or the emergency console.
andy@12 441 *
andy@12 442 * Event channels are addressed by a "port index". Each channel is
andy@12 443 * associated with two bits of information:
andy@12 444 * 1. PENDING -- notifies the domain that there is a pending notification
andy@12 445 * to be processed. This bit is cleared by the guest.
andy@12 446 * 2. MASK -- if this bit is clear then a 0->1 transition of PENDING
andy@12 447 * will cause an asynchronous upcall to be scheduled. This bit is only
andy@12 448 * updated by the guest. It is read-only within Xen. If a channel
andy@12 449 * becomes pending while the channel is masked then the 'edge' is lost
andy@12 450 * (i.e., when the channel is unmasked, the guest must manually handle
andy@12 451 * pending notifications as no upcall will be scheduled by Xen).
andy@12 452 *
andy@12 453 * To expedite scanning of pending notifications, any 0->1 pending
andy@12 454 * transition on an unmasked channel causes a corresponding bit in a
andy@12 455 * per-vcpu selector word to be set. Each bit in the selector covers a
andy@12 456 * 'C long' in the PENDING bitfield array.
andy@12 457 */
andy@12 458 unsigned long evtchn_pending[sizeof(unsigned long) * 8];
andy@12 459 unsigned long evtchn_mask[sizeof(unsigned long) * 8];
andy@12 460
andy@12 461 /*
andy@12 462 * Wallclock time: updated only by control software. Guests should base
andy@12 463 * their gettimeofday() syscall on this wallclock-base value.
andy@12 464 */
andy@12 465 uint32_t wc_version; /* Version counter: see vcpu_time_info_t. */
andy@12 466 uint32_t wc_sec; /* Secs 00:00:00 UTC, Jan 1, 1970. */
andy@12 467 uint32_t wc_nsec; /* Nsecs 00:00:00 UTC, Jan 1, 1970. */
andy@12 468
andy@12 469 struct arch_shared_info arch;
andy@12 470
andy@12 471 };
andy@12 472 #ifndef __XEN__
andy@12 473 typedef struct shared_info shared_info_t;
andy@12 474 #endif
andy@12 475
andy@12 476 /*
andy@12 477 * Start-of-day memory layout:
andy@12 478 * 1. The domain is started within contiguous virtual-memory region.
andy@12 479 * 2. The contiguous region ends on an aligned 4MB boundary.
andy@12 480 * 3. This the order of bootstrap elements in the initial virtual region:
andy@12 481 * a. relocated kernel image
andy@12 482 * b. initial ram disk [mod_start, mod_len]
andy@12 483 * c. list of allocated page frames [mfn_list, nr_pages]
andy@12 484 * d. start_info_t structure [register ESI (x86)]
andy@12 485 * e. bootstrap page tables [pt_base, CR3 (x86)]
andy@12 486 * f. bootstrap stack [register ESP (x86)]
andy@12 487 * 4. Bootstrap elements are packed together, but each is 4kB-aligned.
andy@12 488 * 5. The initial ram disk may be omitted.
andy@12 489 * 6. The list of page frames forms a contiguous 'pseudo-physical' memory
andy@12 490 * layout for the domain. In particular, the bootstrap virtual-memory
andy@12 491 * region is a 1:1 mapping to the first section of the pseudo-physical map.
andy@12 492 * 7. All bootstrap elements are mapped read-writable for the guest OS. The
andy@12 493 * only exception is the bootstrap page table, which is mapped read-only.
andy@12 494 * 8. There is guaranteed to be at least 512kB padding after the final
andy@12 495 * bootstrap element. If necessary, the bootstrap virtual region is
andy@12 496 * extended by an extra 4MB to ensure this.
andy@12 497 */
andy@12 498
andy@12 499 #define MAX_GUEST_CMDLINE 1024
andy@12 500 struct start_info {
andy@12 501 /* THE FOLLOWING ARE FILLED IN BOTH ON INITIAL BOOT AND ON RESUME. */
andy@12 502 char magic[32]; /* "xen-<version>-<platform>". */
andy@12 503 unsigned long nr_pages; /* Total pages allocated to this domain. */
andy@12 504 unsigned long shared_info; /* MACHINE address of shared info struct. */
andy@12 505 uint32_t flags; /* SIF_xxx flags. */
andy@12 506 xen_pfn_t store_mfn; /* MACHINE page number of shared page. */
andy@12 507 uint32_t store_evtchn; /* Event channel for store communication. */
andy@12 508 union {
andy@12 509 struct {
andy@12 510 xen_pfn_t mfn; /* MACHINE page number of console page. */
andy@12 511 uint32_t evtchn; /* Event channel for console page. */
andy@12 512 } domU;
andy@12 513 struct {
andy@12 514 uint32_t info_off; /* Offset of console_info struct. */
andy@12 515 uint32_t info_size; /* Size of console_info struct from start.*/
andy@12 516 } dom0;
andy@12 517 } console;
andy@12 518 /* THE FOLLOWING ARE ONLY FILLED IN ON INITIAL BOOT (NOT RESUME). */
andy@12 519 unsigned long pt_base; /* VIRTUAL address of page directory. */
andy@12 520 unsigned long nr_pt_frames; /* Number of bootstrap p.t. frames. */
andy@12 521 unsigned long mfn_list; /* VIRTUAL address of page-frame list. */
andy@12 522 unsigned long mod_start; /* VIRTUAL address of pre-loaded module. */
andy@12 523 unsigned long mod_len; /* Size (bytes) of pre-loaded module. */
andy@12 524 int8_t cmd_line[MAX_GUEST_CMDLINE];
andy@12 525 };
andy@12 526 typedef struct start_info start_info_t;
andy@12 527
andy@12 528 /* New console union for dom0 introduced in 0x00030203. */
andy@12 529 #if __XEN_INTERFACE_VERSION__ < 0x00030203
andy@12 530 #define console_mfn console.domU.mfn
andy@12 531 #define console_evtchn console.domU.evtchn
andy@12 532 #endif
andy@12 533
andy@12 534 /* These flags are passed in the 'flags' field of start_info_t. */
andy@12 535 #define SIF_PRIVILEGED (1<<0) /* Is the domain privileged? */
andy@12 536 #define SIF_INITDOMAIN (1<<1) /* Is this the initial control domain? */
andy@12 537
andy@12 538 typedef struct dom0_vga_console_info {
andy@12 539 uint8_t video_type; /* DOM0_VGA_CONSOLE_??? */
andy@12 540 #define XEN_VGATYPE_TEXT_MODE_3 0x03
andy@12 541 #define XEN_VGATYPE_VESA_LFB 0x23
andy@12 542
andy@12 543 union {
andy@12 544 struct {
andy@12 545 /* Font height, in pixels. */
andy@12 546 uint16_t font_height;
andy@12 547 /* Cursor location (column, row). */
andy@12 548 uint16_t cursor_x, cursor_y;
andy@12 549 /* Number of rows and columns (dimensions in characters). */
andy@12 550 uint16_t rows, columns;
andy@12 551 } text_mode_3;
andy@12 552
andy@12 553 struct {
andy@12 554 /* Width and height, in pixels. */
andy@12 555 uint16_t width, height;
andy@12 556 /* Bytes per scan line. */
andy@12 557 uint16_t bytes_per_line;
andy@12 558 /* Bits per pixel. */
andy@12 559 uint16_t bits_per_pixel;
andy@12 560 /* LFB physical address, and size (in units of 64kB). */
andy@12 561 uint32_t lfb_base;
andy@12 562 uint32_t lfb_size;
andy@12 563 /* RGB mask offsets and sizes, as defined by VBE 1.2+ */
andy@12 564 uint8_t red_pos, red_size;
andy@12 565 uint8_t green_pos, green_size;
andy@12 566 uint8_t blue_pos, blue_size;
andy@12 567 uint8_t rsvd_pos, rsvd_size;
andy@12 568 } vesa_lfb;
andy@12 569 } u;
andy@12 570 } dom0_vga_console_info_t;
andy@12 571 #define xen_vga_console_info dom0_vga_console_info
andy@12 572 #define xen_vga_console_info_t dom0_vga_console_info_t
andy@12 573
andy@12 574 typedef uint8_t xen_domain_handle_t[16];
andy@12 575
andy@12 576 /* Turn a plain number into a C unsigned long constant. */
andy@12 577 #define __mk_unsigned_long(x) x ## UL
andy@12 578 #define mk_unsigned_long(x) __mk_unsigned_long(x)
andy@12 579
andy@12 580 DEFINE_XEN_GUEST_HANDLE(uint8_t);
andy@12 581 DEFINE_XEN_GUEST_HANDLE(uint16_t);
andy@12 582 DEFINE_XEN_GUEST_HANDLE(uint32_t);
andy@12 583 DEFINE_XEN_GUEST_HANDLE(uint64_t);
andy@12 584
andy@12 585 #else /* __ASSEMBLY__ */
andy@12 586
andy@12 587 /* In assembly code we cannot use C numeric constant suffixes. */
andy@12 588 #define mk_unsigned_long(x) x
andy@12 589
andy@12 590 #endif /* !__ASSEMBLY__ */
andy@12 591
andy@12 592 /* Default definitions for macros used by domctl/sysctl. */
andy@12 593 #if defined(__XEN__) || defined(__XEN_TOOLS__)
andy@12 594 #ifndef uint64_aligned_t
andy@12 595 #define uint64_aligned_t uint64_t
andy@12 596 #endif
andy@12 597 #ifndef XEN_GUEST_HANDLE_64
andy@12 598 #define XEN_GUEST_HANDLE_64(name) XEN_GUEST_HANDLE(name)
andy@12 599 #endif
andy@12 600 #endif
andy@12 601
andy@12 602 #endif /* __XEN_PUBLIC_XEN_H__ */
andy@12 603
andy@12 604 /*
andy@12 605 * Local variables:
andy@12 606 * mode: C
andy@12 607 * c-set-style: "BSD"
andy@12 608 * c-basic-offset: 4
andy@12 609 * tab-width: 4
andy@12 610 * indent-tabs-mode: nil
andy@12 611 * End:
andy@12 612 */