1 /*++ 2 3 Copyright (c) Microsoft Corporation. All rights reserved. 4 5 Module Name: 6 7 WinHvPlatform.ext 8 9 Abstract: 10 11 ApiSet contract for the Windows Hypervisor User-Mode Platform APIs. 12 13 --*/ 14 15 #ifndef _WINHVAPI_H_ 16 #define _WINHVAPI_H_ 17 18 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 19 #pragma once 20 #endif 21 22 /*#include <apiset.h> 23 #include <apisetcconv.h> 24 #include <minwindef.h> 25 #include <winapifamily.h> 26 27 #pragma region Desktop Family or OneCore Family 28 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)*/ 29 30 typedef signed char INT8, *PINT8; 31 typedef signed short INT16, *PINT16; 32 typedef signed int INT32, *PINT32; 33 typedef signed __int64 INT64, *PINT64; 34 typedef unsigned char UINT8, *PUINT8; 35 typedef unsigned short UINT16, *PUINT16; 36 typedef unsigned int UINT32, *PUINT32; 37 typedef unsigned __int64 UINT64, *PUINT64; 38 39 typedef unsigned long DWORD; 40 typedef int BOOL; 41 typedef unsigned char BYTE; 42 typedef unsigned short WORD; 43 typedef float FLOAT; 44 45 typedef int INT; 46 typedef unsigned int UINT; 47 typedef unsigned int *PUINT; 48 49 #ifndef VOID 50 #define VOID void 51 typedef char CHAR; 52 typedef short SHORT; 53 typedef long LONG; 54 #if !defined(MIDL_PASS) 55 typedef int INT; 56 #endif 57 #endif 58 59 #define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1] 60 #define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) // NOP, C allows these operators. 61 #define DECLSPEC_ALIGN(x) __declspec(align(x)) 62 63 #include "WinHvPlatformDefs.h" 64 65 typedef long HRESULT; 66 typedef void *HANDLE; 67 typedef BYTE BOOLEAN; 68 #define WINAPI __stdcall 69 #define _In_ 70 #define _Out_ 71 #define _Out_opt_ 72 #define _Out_writes_bytes_to_(x, y) 73 #define _In_reads_bytes_(x) 74 #define _Out_writes_bytes_(x) 75 #define _In_reads_(x) 76 #define _Out_writes_(x) 77 #define _Out_writes_bytes_to_opt_(x, y) 78 79 #include "WinHvEmulation.h" 80 81 #ifdef __cplusplus 82 extern "C" { 83 #endif 84 85 // 86 // Platform capabilities 87 // 88 89 HRESULT 90 WINAPI 91 WHvGetCapability( 92 _In_ WHV_CAPABILITY_CODE CapabilityCode, 93 _Out_writes_bytes_to_(CapabilityBufferSizeInBytes,*WrittenSizeInBytes) VOID* CapabilityBuffer, 94 _In_ UINT32 CapabilityBufferSizeInBytes, 95 _Out_opt_ UINT32* WrittenSizeInBytes 96 ); 97 98 99 HRESULT 100 WINAPI 101 WHvCreatePartition( 102 _Out_ WHV_PARTITION_HANDLE* Partition 103 ); 104 105 106 HRESULT 107 WINAPI 108 WHvSetupPartition( 109 _In_ WHV_PARTITION_HANDLE Partition 110 ); 111 112 113 HRESULT 114 WINAPI 115 WHvDeletePartition( 116 _In_ WHV_PARTITION_HANDLE Partition 117 ); 118 119 120 HRESULT 121 WINAPI 122 WHvGetPartitionProperty( 123 _In_ WHV_PARTITION_HANDLE Partition, 124 _In_ WHV_PARTITION_PROPERTY_CODE PropertyCode, 125 _Out_writes_bytes_to_(PropertyBufferSizeInBytes,*WrittenSizeInBytes) VOID* PropertyBuffer, 126 _In_ UINT32 PropertyBufferSizeInBytes, 127 _Out_opt_ UINT32* WrittenSizeInBytes 128 ); 129 130 131 HRESULT 132 WINAPI 133 WHvSetPartitionProperty( 134 _In_ WHV_PARTITION_HANDLE Partition, 135 _In_ WHV_PARTITION_PROPERTY_CODE PropertyCode, 136 _In_reads_bytes_(PropertyBufferSizeInBytes) const VOID* PropertyBuffer, 137 _In_ UINT32 PropertyBufferSizeInBytes 138 ); 139 140 141 HRESULT 142 WINAPI 143 WHvSuspendPartitionTime( 144 _In_ WHV_PARTITION_HANDLE Partition 145 ); 146 147 148 HRESULT 149 WINAPI 150 WHvResumePartitionTime( 151 _In_ WHV_PARTITION_HANDLE Partition 152 ); 153 154 155 // 156 // Memory Management 157 // 158 159 HRESULT 160 WINAPI 161 WHvMapGpaRange( 162 _In_ WHV_PARTITION_HANDLE Partition, 163 _In_ VOID* SourceAddress, 164 _In_ WHV_GUEST_PHYSICAL_ADDRESS GuestAddress, 165 _In_ UINT64 SizeInBytes, 166 _In_ WHV_MAP_GPA_RANGE_FLAGS Flags 167 ); 168 169 170 HRESULT 171 WINAPI 172 WHvUnmapGpaRange( 173 _In_ WHV_PARTITION_HANDLE Partition, 174 _In_ WHV_GUEST_PHYSICAL_ADDRESS GuestAddress, 175 _In_ UINT64 SizeInBytes 176 ); 177 178 179 HRESULT 180 WINAPI 181 WHvTranslateGva( 182 _In_ WHV_PARTITION_HANDLE Partition, 183 _In_ UINT32 VpIndex, 184 _In_ WHV_GUEST_VIRTUAL_ADDRESS Gva, 185 _In_ WHV_TRANSLATE_GVA_FLAGS TranslateFlags, 186 _Out_ WHV_TRANSLATE_GVA_RESULT* TranslationResult, 187 _Out_ WHV_GUEST_PHYSICAL_ADDRESS* Gpa 188 ); 189 190 191 // 192 // Virtual Processors 193 // 194 195 HRESULT 196 WINAPI 197 WHvCreateVirtualProcessor( 198 _In_ WHV_PARTITION_HANDLE Partition, 199 _In_ UINT32 VpIndex, 200 _In_ UINT32 Flags 201 ); 202 203 204 HRESULT 205 WINAPI 206 WHvDeleteVirtualProcessor( 207 _In_ WHV_PARTITION_HANDLE Partition, 208 _In_ UINT32 VpIndex 209 ); 210 211 212 HRESULT 213 WINAPI 214 WHvRunVirtualProcessor( 215 _In_ WHV_PARTITION_HANDLE Partition, 216 _In_ UINT32 VpIndex, 217 _Out_writes_bytes_(ExitContextSizeInBytes) VOID* ExitContext, 218 _In_ UINT32 ExitContextSizeInBytes 219 ); 220 221 222 HRESULT 223 WINAPI 224 WHvCancelRunVirtualProcessor( 225 _In_ WHV_PARTITION_HANDLE Partition, 226 _In_ UINT32 VpIndex, 227 _In_ UINT32 Flags 228 ); 229 230 231 HRESULT 232 WINAPI 233 WHvGetVirtualProcessorRegisters( 234 _In_ WHV_PARTITION_HANDLE Partition, 235 _In_ UINT32 VpIndex, 236 _In_reads_(RegisterCount) const WHV_REGISTER_NAME* RegisterNames, 237 _In_ UINT32 RegisterCount, 238 _Out_writes_(RegisterCount) WHV_REGISTER_VALUE* RegisterValues 239 ); 240 241 242 HRESULT 243 WINAPI 244 WHvSetVirtualProcessorRegisters( 245 _In_ WHV_PARTITION_HANDLE Partition, 246 _In_ UINT32 VpIndex, 247 _In_reads_(RegisterCount) const WHV_REGISTER_NAME* RegisterNames, 248 _In_ UINT32 RegisterCount, 249 _In_reads_(RegisterCount) const WHV_REGISTER_VALUE* RegisterValues 250 ); 251 252 253 #if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_WIN10_VB) 254 #pragma deprecated("WHvGetVirtualProcessorInterruptControllerState is deprecated; use WHvGetVirtualProcessorInterruptControllerState2") 255 #endif 256 HRESULT 257 WINAPI 258 WHvGetVirtualProcessorInterruptControllerState( 259 _In_ WHV_PARTITION_HANDLE Partition, 260 _In_ UINT32 VpIndex, 261 _Out_writes_bytes_to_(StateSize,*WrittenSize) VOID* State, 262 _In_ UINT32 StateSize, 263 _Out_opt_ UINT32* WrittenSize 264 ); 265 266 267 #if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_WIN10_VB) 268 #pragma deprecated("WHvSetVirtualProcessorInterruptControllerState is deprecated; use WHvSetVirtualProcessorInterruptControllerState2") 269 #endif 270 HRESULT 271 WINAPI 272 WHvSetVirtualProcessorInterruptControllerState( 273 _In_ WHV_PARTITION_HANDLE Partition, 274 _In_ UINT32 VpIndex, 275 _In_reads_bytes_(StateSize) const VOID* State, 276 _In_ UINT32 StateSize 277 ); 278 279 280 HRESULT 281 WINAPI 282 WHvRequestInterrupt( 283 _In_ WHV_PARTITION_HANDLE Partition, 284 _In_ const WHV_INTERRUPT_CONTROL* Interrupt, 285 _In_ UINT32 InterruptControlSize 286 ); 287 288 289 HRESULT 290 WINAPI 291 WHvGetVirtualProcessorXsaveState( 292 _In_ WHV_PARTITION_HANDLE Partition, 293 _In_ UINT32 VpIndex, 294 _Out_writes_bytes_to_(BufferSizeInBytes,*BytesWritten) VOID* Buffer, 295 _In_ UINT32 BufferSizeInBytes, 296 _Out_ UINT32* BytesWritten 297 ); 298 299 300 HRESULT 301 WINAPI 302 WHvSetVirtualProcessorXsaveState( 303 _In_ WHV_PARTITION_HANDLE Partition, 304 _In_ UINT32 VpIndex, 305 _In_reads_bytes_(BufferSizeInBytes) const VOID* Buffer, 306 _In_ UINT32 BufferSizeInBytes 307 ); 308 309 310 HRESULT 311 WINAPI 312 WHvQueryGpaRangeDirtyBitmap( 313 _In_ WHV_PARTITION_HANDLE Partition, 314 _In_ WHV_GUEST_PHYSICAL_ADDRESS GuestAddress, 315 _In_ UINT64 RangeSizeInBytes, 316 _Out_writes_bytes_to_opt_(BitmapSizeInBytes,RangeSizeInBytes / 4096 / 64) UINT64* Bitmap, 317 _In_ UINT32 BitmapSizeInBytes 318 ); 319 320 321 HRESULT 322 WINAPI 323 WHvGetPartitionCounters( 324 _In_ WHV_PARTITION_HANDLE Partition, 325 _In_ WHV_PARTITION_COUNTER_SET CounterSet, 326 _Out_writes_bytes_to_(BufferSizeInBytes,*BytesWritten) VOID* Buffer, 327 _In_ UINT32 BufferSizeInBytes, 328 _Out_opt_ UINT32* BytesWritten 329 ); 330 331 332 HRESULT 333 WINAPI 334 WHvGetVirtualProcessorCounters( 335 _In_ WHV_PARTITION_HANDLE Partition, 336 _In_ UINT32 VpIndex, 337 _In_ WHV_PROCESSOR_COUNTER_SET CounterSet, 338 _Out_writes_bytes_to_(BufferSizeInBytes,*BytesWritten) VOID* Buffer, 339 _In_ UINT32 BufferSizeInBytes, 340 _Out_opt_ UINT32* BytesWritten 341 ); 342 343 344 HRESULT 345 WINAPI 346 WHvGetVirtualProcessorInterruptControllerState2( 347 _In_ WHV_PARTITION_HANDLE Partition, 348 _In_ UINT32 VpIndex, 349 _Out_writes_bytes_to_(StateSize,*WrittenSize) VOID* State, 350 _In_ UINT32 StateSize, 351 _Out_opt_ UINT32* WrittenSize 352 ); 353 354 355 HRESULT 356 WINAPI 357 WHvSetVirtualProcessorInterruptControllerState2( 358 _In_ WHV_PARTITION_HANDLE Partition, 359 _In_ UINT32 VpIndex, 360 _In_reads_bytes_(StateSize) const VOID* State, 361 _In_ UINT32 StateSize 362 ); 363 364 365 HRESULT 366 WINAPI 367 WHvRegisterPartitionDoorbellEvent( 368 _In_ WHV_PARTITION_HANDLE Partition, 369 _In_ const WHV_DOORBELL_MATCH_DATA* MatchData, 370 _In_ HANDLE EventHandle 371 ); 372 373 374 HRESULT 375 WINAPI 376 WHvUnregisterPartitionDoorbellEvent( 377 _In_ WHV_PARTITION_HANDLE Partition, 378 _In_ const WHV_DOORBELL_MATCH_DATA* MatchData 379 ); 380 381 382 #ifdef __cplusplus 383 } 384 #endif 385 386 //#endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM) 387 //#pragma endregion 388 389 #endif // _WINHVAPI_H_ 390 391 392 393 394 395 #ifndef ext_ms_win_hyperv_hvplatform_l1_1_3_query_routines 396 #define ext_ms_win_hyperv_hvplatform_l1_1_3_query_routines 397 398 399 400 // 401 //Private Extension API Query Routines 402 // 403 404 #ifdef __cplusplus 405 extern "C" { 406 #endif 407 408 BOOLEAN 409 __stdcall 410 IsWHvGetCapabilityPresent( 411 VOID 412 ); 413 414 BOOLEAN 415 __stdcall 416 IsWHvCreatePartitionPresent( 417 VOID 418 ); 419 420 BOOLEAN 421 __stdcall 422 IsWHvSetupPartitionPresent( 423 VOID 424 ); 425 426 BOOLEAN 427 __stdcall 428 IsWHvDeletePartitionPresent( 429 VOID 430 ); 431 432 BOOLEAN 433 __stdcall 434 IsWHvGetPartitionPropertyPresent( 435 VOID 436 ); 437 438 BOOLEAN 439 __stdcall 440 IsWHvSetPartitionPropertyPresent( 441 VOID 442 ); 443 444 BOOLEAN 445 __stdcall 446 IsWHvSuspendPartitionTimePresent( 447 VOID 448 ); 449 450 BOOLEAN 451 __stdcall 452 IsWHvResumePartitionTimePresent( 453 VOID 454 ); 455 456 BOOLEAN 457 __stdcall 458 IsWHvMapGpaRangePresent( 459 VOID 460 ); 461 462 BOOLEAN 463 __stdcall 464 IsWHvUnmapGpaRangePresent( 465 VOID 466 ); 467 468 BOOLEAN 469 __stdcall 470 IsWHvTranslateGvaPresent( 471 VOID 472 ); 473 474 BOOLEAN 475 __stdcall 476 IsWHvCreateVirtualProcessorPresent( 477 VOID 478 ); 479 480 BOOLEAN 481 __stdcall 482 IsWHvDeleteVirtualProcessorPresent( 483 VOID 484 ); 485 486 BOOLEAN 487 __stdcall 488 IsWHvRunVirtualProcessorPresent( 489 VOID 490 ); 491 492 BOOLEAN 493 __stdcall 494 IsWHvCancelRunVirtualProcessorPresent( 495 VOID 496 ); 497 498 BOOLEAN 499 __stdcall 500 IsWHvGetVirtualProcessorRegistersPresent( 501 VOID 502 ); 503 504 BOOLEAN 505 __stdcall 506 IsWHvSetVirtualProcessorRegistersPresent( 507 VOID 508 ); 509 510 #if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_WIN10_VB) 511 512 513 #endif 514 515 516 BOOLEAN 517 __stdcall 518 IsWHvGetVirtualProcessorInterruptControllerStatePresent( 519 VOID 520 ); 521 522 #if defined(NTDDI_VERSION) && (NTDDI_VERSION >= NTDDI_WIN10_VB) 523 524 525 #endif 526 527 528 BOOLEAN 529 __stdcall 530 IsWHvSetVirtualProcessorInterruptControllerStatePresent( 531 VOID 532 ); 533 534 BOOLEAN 535 __stdcall 536 IsWHvRequestInterruptPresent( 537 VOID 538 ); 539 540 BOOLEAN 541 __stdcall 542 IsWHvGetVirtualProcessorXsaveStatePresent( 543 VOID 544 ); 545 546 BOOLEAN 547 __stdcall 548 IsWHvSetVirtualProcessorXsaveStatePresent( 549 VOID 550 ); 551 552 BOOLEAN 553 __stdcall 554 IsWHvQueryGpaRangeDirtyBitmapPresent( 555 VOID 556 ); 557 558 BOOLEAN 559 __stdcall 560 IsWHvGetPartitionCountersPresent( 561 VOID 562 ); 563 564 BOOLEAN 565 __stdcall 566 IsWHvGetVirtualProcessorCountersPresent( 567 VOID 568 ); 569 570 BOOLEAN 571 __stdcall 572 IsWHvGetVirtualProcessorInterruptControllerState2Present( 573 VOID 574 ); 575 576 BOOLEAN 577 __stdcall 578 IsWHvSetVirtualProcessorInterruptControllerState2Present( 579 VOID 580 ); 581 582 BOOLEAN 583 __stdcall 584 IsWHvRegisterPartitionDoorbellEventPresent( 585 VOID 586 ); 587 588 BOOLEAN 589 __stdcall 590 IsWHvUnregisterPartitionDoorbellEventPresent( 591 VOID 592 ); 593 594 #ifdef __cplusplus 595 } 596 #endif 597 598 #endif // endof guard 599