Editja

WHvCreateVpciDevice

Creates a virtual PCI (VPCI) device and assigns its resources to a partition.

Syntax

typedef enum WHV_CREATE_VPCI_DEVICE_FLAGS
{
    WHvCreateVpciDeviceFlagNone = 0x00000000,
    WHvCreateVpciDeviceFlagPhysicallyBacked = 0x00000001,
    WHvCreateVpciDeviceFlagUseLogicalInterrupts = 0x00000002
} WHV_CREATE_VPCI_DEVICE_FLAGS;

// Enables bitwise operators on the WHV_CREATE_VPCI_DEVICE_FLAGS enumeration.
DEFINE_ENUM_FLAG_OPERATORS(WHV_CREATE_VPCI_DEVICE_FLAGS);

HRESULT
WINAPI
WHvCreateVpciDevice(
    _In_ WHV_PARTITION_HANDLE Partition,
    _In_ UINT64 LogicalDeviceId,
    _In_ HANDLE VpciResource,
    _In_ WHV_CREATE_VPCI_DEVICE_FLAGS Flags,
    _In_opt_ HANDLE NotificationEventHandle
    );

Parameters

Partition

Handle to the partition object.

LogicalDeviceId

Specifies a unique identifier for the device within the scope of the partition.

VpciResource

Handle to a previously allocated VPCI resource that backs the virtual device. Obtain this handle from WHvAllocateVpciResource.

Flags

Specifies optional characteristics of the device to create, as a combination of WHV_CREATE_VPCI_DEVICE_FLAGS values.

NotificationEventHandle

Specifies an optional handle to an event that is signaled to notify the caller of asynchronous events associated with the VPCI device. When the event is signaled, retrieve the pending notifications with WHvGetVpciDeviceNotification.

Return Value

If the function succeeds, the return value is S_OK.

Remarks

The WHvCreateVpciDevice function creates a virtual PCI device and assigns the physical or virtual resources identified by VpciResource to the partition. After this call completes, the IOMMU is programmed so that the PCI requestor ID of the physical or virtual function backing the device is assigned to the partition domain, remapping any DMA operations that originate from that function to the partition's address space.

Allocate the resource with WHvAllocateVpciResource before calling this function. After the device is created, map its MMIO ranges with WHvMapVpciDeviceMmioRanges and its interrupts with WHvMapVpciDeviceInterrupt. Destroy the device with WHvDeleteVpciDevice.

Requirements

Requirement Value
Minimum supported Windows Windows 10, version 20H2 (x64); Windows 11, version 24H2, build 26100.3915 (Arm64)
Header WinHvPlatform.h
Library WinHvPlatform.lib
DLL WinHvPlatform.dll
Architecture x64, Arm64

See also