| 1 |
(* |
| 2 |
* Copyright (C) 2006-2007 XenSource Ltd. |
| 3 |
* Copyright (C) 2008 Citrix Ltd. |
| 4 |
* Author Vincent Hanquez <[email protected]> |
| 5 |
* |
| 6 |
* This program is free software; you can redistribute it and/or modify |
| 7 |
* it under the terms of the GNU Lesser General Public License as published |
| 8 |
* by the Free Software Foundation; version 2.1 only. with the special |
| 9 |
* exception on linking described in file LICENSE. |
| 10 |
* |
| 11 |
* This program is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU Lesser General Public License for more details. |
| 15 |
*) |
| 16 |
|
| 17 |
type domid = int |
| 18 |
type vcpuinfo = { |
| 19 |
online : bool; |
| 20 |
blocked : bool; |
| 21 |
running : bool; |
| 22 |
cputime : int64; |
| 23 |
cpumap : int32; |
| 24 |
} |
| 25 |
|
| 26 |
type xen_arm_arch_domainconfig = { |
| 27 |
gic_version: int; |
| 28 |
nr_spis: int; |
| 29 |
clock_frequency: int32; |
| 30 |
} |
| 31 |
|
| 32 |
type x86_arch_emulation_flags = |
| 33 |
| X86_EMU_LAPIC |
| 34 |
| X86_EMU_HPET |
| 35 |
| X86_EMU_PM |
| 36 |
| X86_EMU_RTC |
| 37 |
| X86_EMU_IOAPIC |
| 38 |
| X86_EMU_PIC |
| 39 |
| X86_EMU_VGA |
| 40 |
| X86_EMU_IOMMU |
| 41 |
| X86_EMU_PIT |
| 42 |
| X86_EMU_USE_PIRQ |
| 43 |
| X86_EMU_VPCI |
| 44 |
|
| 45 |
type x86_arch_misc_flags = |
| 46 |
| X86_MSR_RELAXED |
| 47 |
|
| 48 |
type xen_x86_arch_domainconfig = { |
| 49 |
emulation_flags: x86_arch_emulation_flags list; |
| 50 |
misc_flags: x86_arch_misc_flags list; |
| 51 |
} |
| 52 |
|
| 53 |
type arch_domainconfig = |
| 54 |
| ARM of xen_arm_arch_domainconfig |
| 55 |
| X86 of xen_x86_arch_domainconfig |
| 56 |
|
| 57 |
type domain_create_flag = |
| 58 |
| CDF_HVM |
| 59 |
| CDF_HAP |
| 60 |
| CDF_S3_INTEGRITY |
| 61 |
| CDF_OOS_OFF |
| 62 |
| CDF_XS_DOMAIN |
| 63 |
| CDF_IOMMU |
| 64 |
| CDF_NESTED_VIRT |
| 65 |
| CDF_VPMU |
| 66 |
|
| 67 |
type domain_create_iommu_opts = |
| 68 |
| IOMMU_NO_SHAREPT |
| 69 |
|
| 70 |
type domctl_create_config = { |
| 71 |
ssidref: int32; |
| 72 |
handle: string; |
| 73 |
flags: domain_create_flag list; |
| 74 |
iommu_opts: domain_create_iommu_opts list; |
| 75 |
max_vcpus: int; |
| 76 |
max_evtchn_port: int; |
| 77 |
max_grant_frames: int; |
| 78 |
max_maptrack_frames: int; |
| 79 |
max_grant_version: int; |
| 80 |
altp2m_opts: int32; |
| 81 |
vmtrace_buf_kb: int32; |
| 82 |
cpupool_id: int32; |
| 83 |
arch: arch_domainconfig; |
| 84 |
} |
| 85 |
|
| 86 |
type domaininfo = { |
| 87 |
domid : domid; |
| 88 |
dying : bool; |
| 89 |
shutdown : bool; |
| 90 |
paused : bool; |
| 91 |
blocked : bool; |
| 92 |
running : bool; |
| 93 |
hvm_guest : bool; |
| 94 |
shutdown_code : int; |
| 95 |
total_memory_pages : nativeint; |
| 96 |
max_memory_pages : nativeint; |
| 97 |
shared_info_frame : int64; |
| 98 |
cpu_time : int64; |
| 99 |
nr_online_vcpus : int; |
| 100 |
max_vcpu_id : int; |
| 101 |
ssidref : int32; |
| 102 |
handle : int array; |
| 103 |
arch_config : arch_domainconfig; |
| 104 |
} |
| 105 |
type sched_control = { weight : int; cap : int; } |
| 106 |
type physinfo_cap_flag = |
| 107 |
| CAP_HVM |
| 108 |
| CAP_PV |
| 109 |
| CAP_DirectIO |
| 110 |
| CAP_HAP |
| 111 |
| CAP_Shadow |
| 112 |
| CAP_IOMMU_HAP_PT_SHARE |
| 113 |
| CAP_Vmtrace |
| 114 |
| CAP_Vpmu |
| 115 |
| CAP_Gnttab_v1 |
| 116 |
| CAP_Gnttab_v2 |
| 117 |
|
| 118 |
type arm_physinfo_caps = |
| 119 |
{ |
| 120 |
sve_vl: int; |
| 121 |
} |
| 122 |
|
| 123 |
type x86_physinfo_cap_flag |
| 124 |
|
| 125 |
type arch_physinfo_cap_flags = |
| 126 |
| ARM of arm_physinfo_caps |
| 127 |
| X86 of x86_physinfo_cap_flag list |
| 128 |
|
| 129 |
type physinfo = { |
| 130 |
threads_per_core : int; |
| 131 |
cores_per_socket : int; |
| 132 |
nr_cpus : int; |
| 133 |
max_node_id : int; |
| 134 |
cpu_khz : int; |
| 135 |
total_pages : nativeint; |
| 136 |
free_pages : nativeint; |
| 137 |
scrub_pages : nativeint; |
| 138 |
capabilities : physinfo_cap_flag list; |
| 139 |
max_nr_cpus : int; (** compile-time max possible number of nr_cpus *) |
| 140 |
arch_capabilities : arch_physinfo_cap_flags; |
| 141 |
} |
| 142 |
type version = { major : int; minor : int; extra : string; } |
| 143 |
type compile_info = { |
| 144 |
compiler : string; |
| 145 |
compile_by : string; |
| 146 |
compile_domain : string; |
| 147 |
compile_date : string; |
| 148 |
} |
| 149 |
type shutdown_reason = Poweroff | Reboot | Suspend | Crash | Watchdog | Soft_reset |
| 150 |
|
| 151 |
exception Error of string |
| 152 |
type handle |
| 153 |
external interface_open : unit -> handle = "stub_xc_interface_open" |
| 154 |
|
| 155 |
(** [with_intf f] runs [f] with a global handle that is opened on demand |
| 156 |
* and kept open. Conceptually, a client should use either |
| 157 |
* interface_open and interface_close or with_intf although mixing both |
| 158 |
* is possible *) |
| 159 |
val with_intf : (handle -> 'a) -> 'a |
| 160 |
|
| 161 |
(** [get_handle] returns the global handle used by [with_intf] *) |
| 162 |
val get_handle: unit -> handle option |
| 163 |
|
| 164 |
(** [close handle] closes the handle maintained by [with_intf]. This |
| 165 |
* should only be closed before process exit. It must not be called from |
| 166 |
* a function called directly or indirectly by with_intf as this |
| 167 |
* would invalidate the handle that with_intf passes to its argument. *) |
| 168 |
val close_handle: unit -> unit |
| 169 |
|
| 170 |
val domain_create: handle -> ?domid:int -> domctl_create_config -> domid |
| 171 |
|
| 172 |
external domain_sethandle : handle -> domid -> string -> unit = "stub_xc_domain_sethandle" |
| 173 |
external domain_max_vcpus : handle -> domid -> int -> unit |
| 174 |
= "stub_xc_domain_max_vcpus" |
| 175 |
external domain_pause : handle -> domid -> unit = "stub_xc_domain_pause" |
| 176 |
external domain_unpause : handle -> domid -> unit = "stub_xc_domain_unpause" |
| 177 |
external domain_resume_fast : handle -> domid -> unit |
| 178 |
= "stub_xc_domain_resume_fast" |
| 179 |
external domain_destroy : handle -> domid -> unit = "stub_xc_domain_destroy" |
| 180 |
external domain_shutdown : handle -> domid -> shutdown_reason -> unit |
| 181 |
= "stub_xc_domain_shutdown" |
| 182 |
external _domain_getinfolist : handle -> domid -> int -> domaininfo list |
| 183 |
= "stub_xc_domain_getinfolist" |
| 184 |
val domain_getinfolist : handle -> domid -> domaininfo list |
| 185 |
external domain_getinfo : handle -> domid -> domaininfo |
| 186 |
= "stub_xc_domain_getinfo" |
| 187 |
external domain_get_vcpuinfo : handle -> int -> int -> vcpuinfo |
| 188 |
= "stub_xc_vcpu_getinfo" |
| 189 |
external domain_ioport_permission: handle -> domid -> int -> int -> bool -> unit |
| 190 |
= "stub_xc_domain_ioport_permission" |
| 191 |
external domain_iomem_permission: handle -> domid -> nativeint -> nativeint -> bool -> unit |
| 192 |
= "stub_xc_domain_iomem_permission" |
| 193 |
external domain_irq_permission: handle -> domid -> int -> bool -> unit |
| 194 |
= "stub_xc_domain_irq_permission" |
| 195 |
external vcpu_affinity_set : handle -> domid -> int -> bool array -> unit |
| 196 |
= "stub_xc_vcpu_setaffinity" |
| 197 |
external vcpu_affinity_get : handle -> domid -> int -> bool array |
| 198 |
= "stub_xc_vcpu_getaffinity" |
| 199 |
external vcpu_context_get : handle -> domid -> int -> string |
| 200 |
= "stub_xc_vcpu_context_get" |
| 201 |
external sched_id : handle -> int = "stub_xc_sched_id" |
| 202 |
external sched_credit_domain_set : handle -> domid -> sched_control -> unit |
| 203 |
= "stub_sched_credit_domain_set" |
| 204 |
external sched_credit_domain_get : handle -> domid -> sched_control |
| 205 |
= "stub_sched_credit_domain_get" |
| 206 |
external shadow_allocation_set : handle -> domid -> int -> unit |
| 207 |
= "stub_shadow_allocation_set" |
| 208 |
external shadow_allocation_get : handle -> domid -> int |
| 209 |
= "stub_shadow_allocation_get" |
| 210 |
external evtchn_alloc_unbound : handle -> domid -> domid -> int |
| 211 |
= "stub_xc_evtchn_alloc_unbound" |
| 212 |
external evtchn_reset : handle -> domid -> unit = "stub_xc_evtchn_reset" |
| 213 |
|
| 214 |
type evtchn_interdomain = { dom: domid; port: int } |
| 215 |
|
| 216 |
type evtchn_stat = |
| 217 |
| EVTCHNSTAT_unbound of domid |
| 218 |
| EVTCHNSTAT_interdomain of evtchn_interdomain |
| 219 |
| EVTCHNSTAT_pirq of int |
| 220 |
| EVTCHNSTAT_virq of Xeneventchn.virq_t |
| 221 |
| EVTCHNSTAT_ipi |
| 222 |
|
| 223 |
type evtchn_status = { vcpu: int; status: evtchn_stat } |
| 224 |
|
| 225 |
external evtchn_status: handle -> domid -> int -> evtchn_status option = |
| 226 |
"stub_xc_evtchn_status" |
| 227 |
|
| 228 |
external readconsolering : handle -> string = "stub_xc_readconsolering" |
| 229 |
external send_debug_keys : handle -> string -> unit = "stub_xc_send_debug_keys" |
| 230 |
external physinfo : handle -> physinfo = "stub_xc_physinfo" |
| 231 |
external pcpu_info: handle -> int -> int64 array = "stub_xc_pcpu_info" |
| 232 |
external domain_setmaxmem : handle -> domid -> int64 -> unit |
| 233 |
= "stub_xc_domain_setmaxmem" |
| 234 |
external domain_set_memmap_limit : handle -> domid -> int64 -> unit |
| 235 |
= "stub_xc_domain_set_memmap_limit" |
| 236 |
external domain_memory_increase_reservation : |
| 237 |
handle -> domid -> int64 -> unit |
| 238 |
= "stub_xc_domain_memory_increase_reservation" |
| 239 |
external map_foreign_range : |
| 240 |
handle -> domid -> int -> nativeint -> Xenmmap.mmap_interface |
| 241 |
= "stub_map_foreign_range" |
| 242 |
|
| 243 |
(* needs to be sorted according to its numeric value, watch out for gaps! *) |
| 244 |
type hvm_param = |
| 245 |
| HVM_PARAM_CALLBACK_IRQ |
| 246 |
| HVM_PARAM_STORE_PFN |
| 247 |
| HVM_PARAM_STORE_EVTCHN |
| 248 |
| HVM_PARAM_UNDEF_3 |
| 249 |
| HVM_PARAM_PAE_ENABLED |
| 250 |
| HVM_PARAM_IOREQ_PFN |
| 251 |
| HVM_PARAM_BUFIOREQ_PFN |
| 252 |
| HVM_PARAM_UNDEF_7 |
| 253 |
| HVM_PARAM_UNDEF_8 |
| 254 |
| HVM_PARAM_VIRIDIAN |
| 255 |
| HVM_PARAM_TIMER_MODE |
| 256 |
| HVM_PARAM_HPET_ENABLED |
| 257 |
| HVM_PARAM_IDENT_PT |
| 258 |
| HVM_PARAM_UNDEF_13 |
| 259 |
| HVM_PARAM_ACPI_S_STATE |
| 260 |
| HVM_PARAM_VM86_TSS |
| 261 |
| HVM_PARAM_VPT_ALIGN |
| 262 |
| HVM_PARAM_CONSOLE_PFN |
| 263 |
| HVM_PARAM_CONSOLE_EVTCHN |
| 264 |
| HVM_PARAM_ACPI_IOPORTS_LOCATION |
| 265 |
| HVM_PARAM_MEMORY_EVENT_CR0 |
| 266 |
| HVM_PARAM_MEMORY_EVENT_CR3 |
| 267 |
| HVM_PARAM_MEMORY_EVENT_CR4 |
| 268 |
| HVM_PARAM_MEMORY_EVENT_INT3 |
| 269 |
| HVM_PARAM_NESTEDHVM |
| 270 |
| HVM_PARAM_MEMORY_EVENT_SINGLE_STEP |
| 271 |
| HVM_PARAM_UNDEF_26 |
| 272 |
| HVM_PARAM_PAGING_RING_PFN |
| 273 |
| HVM_PARAM_MONITOR_RING_PFN |
| 274 |
| HVM_PARAM_SHARING_RING_PFN |
| 275 |
| HVM_PARAM_MEMORY_EVENT_MSR |
| 276 |
| HVM_PARAM_TRIPLE_FAULT_REASON |
| 277 |
| HVM_PARAM_IOREQ_SERVER_PFN |
| 278 |
| HVM_PARAM_NR_IOREQ_SERVER_PAGES |
| 279 |
| HVM_PARAM_VM_GENERATION_ID_ADDR |
| 280 |
| HVM_PARAM_ALTP2M |
| 281 |
| HVM_PARAM_X87_FIP_WIDTH |
| 282 |
| HVM_PARAM_VM86_TSS_SIZED |
| 283 |
| HVM_PARAM_MCA_CAP |
| 284 |
|
| 285 |
external hvm_param_get: handle -> domid -> hvm_param -> int64 |
| 286 |
= "stub_xc_hvm_param_get" |
| 287 |
|
| 288 |
external hvm_param_set: handle -> domid -> hvm_param -> int64 -> unit |
| 289 |
= "stub_xc_hvm_param_set" |
| 290 |
|
| 291 |
external domain_assign_device: handle -> domid -> (int * int * int * int) -> unit |
| 292 |
= "stub_xc_domain_assign_device" |
| 293 |
external domain_deassign_device: handle -> domid -> (int * int * int * int) -> unit |
| 294 |
= "stub_xc_domain_deassign_device" |
| 295 |
external domain_test_assign_device: handle -> domid -> (int * int * int * int) -> bool |
| 296 |
= "stub_xc_domain_test_assign_device" |
| 297 |
|
| 298 |
external version : handle -> version = "stub_xc_version_version" |
| 299 |
external version_compile_info : handle -> compile_info |
| 300 |
= "stub_xc_version_compile_info" |
| 301 |
external version_changeset : handle -> string = "stub_xc_version_changeset" |
| 302 |
external version_capabilities : handle -> string |
| 303 |
= "stub_xc_version_capabilities" |
| 304 |
|
| 305 |
type featureset_index = |
| 306 |
| Featureset_raw |
| 307 |
| Featureset_host |
| 308 |
| Featureset_pv |
| 309 |
| Featureset_hvm |
| 310 |
| Featureset_pv_max |
| 311 |
| Featureset_hvm_max |
| 312 |
external get_cpu_featureset : handle -> featureset_index -> int64 array = "stub_xc_get_cpu_featureset" |
| 313 |
|
| 314 |
external pages_to_kib : int64 -> int64 = "stub_pages_to_kib" |
| 315 |
val pages_to_mib : int64 -> int64 |
| 316 |
external watchdog : handle -> int -> int32 -> int |
| 317 |
= "stub_xc_watchdog" |