1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 17:27:35 +00:00

Kernel/VirtIO: Introduce the concept of transport options

The VirtIO specification defines many types of devices with different
purposes, and it also defines 3 possible transport mediums where devices
could be connected to the host machine.

We only care about the PCIe transport, but this commit puts the actual
foundations for supporting the lean MMIO transport too in the future.

To ensure things are kept abstracted but still functional, the VirtIO
transport code is responsible for what is deemed as related to an actual
transport type - allocation of interrupt handlers and tinkering with low
level transport-related registers, etc.
This commit is contained in:
Liav A 2023-06-10 14:46:47 +03:00 committed by Andrew Kaster
parent 68c3f9aa5a
commit d61c23569e
24 changed files with 732 additions and 429 deletions

View file

@ -0,0 +1,40 @@
/*
* Copyright (c) 2021, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Types.h>
#include <Kernel/Bus/PCI/Device.h>
#include <Kernel/Bus/VirtIO/Transport/Entity.h>
#include <Kernel/Interrupts/PCIIRQHandler.h>
namespace Kernel::VirtIO {
class PCIeTransportLink final
: public TransportEntity
, public PCI::Device {
public:
static ErrorOr<NonnullOwnPtr<TransportEntity>> create(PCI::DeviceIdentifier const& pci_identifier);
virtual StringView device_name() const override { return "VirtIOTransportLink"sv; }
virtual StringView determine_device_class_name() const override;
private:
explicit PCIeTransportLink(PCI::DeviceIdentifier const& pci_identifier);
// ^TransportEntity
virtual ErrorOr<void> locate_configurations_and_resources(Badge<VirtIO::Device>, VirtIO::Device&) override;
virtual void disable_interrupts(Badge<VirtIO::Device>) override;
virtual void enable_interrupts(Badge<VirtIO::Device>) override;
ErrorOr<void> create_interrupt_handler(VirtIO::Device&);
// FIXME: There could be multiple IRQ (MSI-X) handlers for a VirtIO device.
// Find a way to use all of them.
OwnPtr<PCI::IRQHandler> m_irq_handler;
};
};