// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#![cfg_attr(not(target_os = "linux"), expect(missing_docs))]
#![cfg(target_os = "linux")]

//! The [`vm_resource`] resources and [`mesh_worker`] workers that are available
//! in OpenVMM-HCL.

#![forbid(unsafe_code)]

// Resources.
vm_resource::register_static_resolvers! {
    // Chipset devices
    #[cfg(guest_arch = "x86_64")]
    chipset::i8042::resolver::I8042Resolver,
    #[cfg(guest_arch = "x86_64")]
    chipset_legacy::piix4_uhci::resolver::Piix4PciUsbUhciStubResolver,
    #[cfg(guest_arch = "x86_64")]
    chipset_legacy::piix4_pci_isa_bridge::resolver::Piix4PciIsaBridgeResolver,
    #[cfg(guest_arch = "x86_64")]
    chipset::dma::resolver::GenericIsaDmaResolver,
    #[cfg(guest_arch = "x86_64")]
    chipset_legacy::piix4_pm::resolver::Piix4PowerManagementResolver,
    #[cfg(guest_arch = "x86_64")]
    chipset_legacy::i440bx_host_pci_bridge::resolver::I440BxHostPciBridgeResolver,
    #[cfg(guest_arch = "x86_64")]
    chipset::pit::resolver::PitResolver,
    #[cfg(guest_arch = "x86_64")]
    chipset::pic::resolver::PicResolver,
    #[cfg(guest_arch = "x86_64")]
    chipset::ioapic::resolver::GenericIoApicResolver,
    #[cfg(guest_arch = "x86_64")]
    chipset::pm::resolver::HyperVPowerManagementResolver,
    chipset_resources::cmos_rtc_time_source::SystemTimeClockResolver,
    firmware_uefi::resolver::UefiDeviceResolver,
    missing_dev::resolver::MissingDevResolver,
    #[cfg(feature = "tpm")]
    tpm_device::resolver::TpmDeviceResolver,
    #[cfg(guest_arch = "x86_64")]
    serial_16550::resolver::Serial16550Resolver,
    #[cfg(guest_arch = "aarch64")]
    serial_pl011::resolver::SerialPl011Resolver,
    chipset::battery::resolver::BatteryResolver,
    guest_watchdog::resolver::HyperVGuestWatchdogResolver,

    // Non-volatile stores
    vmcore::non_volatile_store::resources::EphemeralNonVolatileStoreResolver,
    vmgs_broker::resolver::VmgsFileResolver,

    // Serial ports
    serial_core::disconnected::resolver::DisconnectedSerialBackendResolver,
    vmbus_serial_guest::VmbusSerialGuestResolver,

    // Disks.
    //
    // `BlockDevice` and `NvmeDisk` are registered dynamically since they have
    // runtime dependencies.
    disk_striped::StripedDiskResolver,

    // SCSI
    scsidisk::resolver::SimpleScsiResolver,

    // Vmbus devices
    hyperv_ic::resolver::ShutdownIcResolver,
    storvsp::resolver::StorvspResolver,
    #[cfg(feature = "uidevices")]
    uidevices::resolver::VmbusUiResolver,

    // VPCI devices
    #[cfg(feature = "nvme")]
    nvme::resolver::NvmeControllerResolver,
}

// Mesh workers.
mesh_worker::register_workers! {
    #[cfg(feature = "vnc_worker")]
    vnc_worker::VncWorker<vmsocket::VmListener>,
    #[cfg(feature = "debug_worker")]
    debug_worker::DebuggerWorker<vmsocket::VmListener>,
}
