diff options
author | Liav A <liavalb@gmail.com> | 2021-09-21 09:26:14 +0300 |
---|---|---|
committer | Idan Horowitz <idan.horowitz@gmail.com> | 2021-10-27 07:57:44 +0300 |
commit | fb0ed2ae46504de82702130894c51e81fbab095f (patch) | |
tree | fcf727ee90b81e551439a13e7fc0ee38450464eb /Kernel/Graphics/VirtIOGPU | |
parent | 4815282a5f768b05c9d075fbcff15b46b84aac3b (diff) | |
download | serenity-fb0ed2ae46504de82702130894c51e81fbab095f.zip |
Kernel/Graphics: Force VirtIO Framebuffer to inherit FramebufferDevice
The distinction is not justified because a VirtIO Framebuffer device
acts much more like a regular FramebufferDevice than a pure BlockDevice.
Diffstat (limited to 'Kernel/Graphics/VirtIOGPU')
-rw-r--r-- | Kernel/Graphics/VirtIOGPU/FramebufferDevice.cpp | 4 | ||||
-rw-r--r-- | Kernel/Graphics/VirtIOGPU/FramebufferDevice.h | 12 | ||||
-rw-r--r-- | Kernel/Graphics/VirtIOGPU/GPU.cpp | 5 | ||||
-rw-r--r-- | Kernel/Graphics/VirtIOGPU/GPU.h | 5 | ||||
-rw-r--r-- | Kernel/Graphics/VirtIOGPU/GraphicsAdapter.cpp | 2 |
5 files changed, 14 insertions, 14 deletions
diff --git a/Kernel/Graphics/VirtIOGPU/FramebufferDevice.cpp b/Kernel/Graphics/VirtIOGPU/FramebufferDevice.cpp index f6d99ee074..a61a1678b3 100644 --- a/Kernel/Graphics/VirtIOGPU/FramebufferDevice.cpp +++ b/Kernel/Graphics/VirtIOGPU/FramebufferDevice.cpp @@ -10,8 +10,8 @@ namespace Kernel::Graphics::VirtIOGPU { -FramebufferDevice::FramebufferDevice(GPU& virtio_gpu, ScanoutID scanout) - : BlockDevice(29, GraphicsManagement::the().allocate_minor_device_number()) +FramebufferDevice::FramebufferDevice(GraphicsDevice const& adapter, GPU& virtio_gpu, ScanoutID scanout) + : Kernel::FramebufferDevice(adapter, scanout.value()) , m_gpu(virtio_gpu) , m_scanout(scanout) { diff --git a/Kernel/Graphics/VirtIOGPU/FramebufferDevice.h b/Kernel/Graphics/VirtIOGPU/FramebufferDevice.h index e33f927d52..b4bf08ce81 100644 --- a/Kernel/Graphics/VirtIOGPU/FramebufferDevice.h +++ b/Kernel/Graphics/VirtIOGPU/FramebufferDevice.h @@ -8,12 +8,13 @@ #include <Kernel/Bus/VirtIO/Device.h> #include <Kernel/Bus/VirtIO/Queue.h> -#include <Kernel/Devices/BlockDevice.h> +#include <Kernel/Graphics/FramebufferDevice.h> +#include <Kernel/Graphics/GraphicsDevice.h> #include <Kernel/Graphics/VirtIOGPU/GPU.h> namespace Kernel::Graphics::VirtIOGPU { -class FramebufferDevice final : public BlockDevice { +class FramebufferDevice final : public Kernel::FramebufferDevice { friend class Console; struct Buffer { size_t framebuffer_offset { 0 }; @@ -23,7 +24,7 @@ class FramebufferDevice final : public BlockDevice { }; public: - FramebufferDevice(VirtIOGPU::GPU& virtio_gpu, ScanoutID); + FramebufferDevice(GraphicsDevice const&, VirtIOGPU::GPU& virtio_gpu, ScanoutID); virtual ~FramebufferDevice() override; virtual void deactivate_writes(); @@ -62,11 +63,6 @@ private: virtual KResult ioctl(OpenFileDescription&, unsigned request, Userspace<void*> arg) override; virtual KResultOr<Memory::Region*> mmap(Process&, OpenFileDescription&, Memory::VirtualRange const&, u64 offset, int prot, bool shared) override; - virtual bool can_read(const OpenFileDescription&, size_t) const override { return true; } - virtual KResultOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override { return EINVAL; } - virtual bool can_write(const OpenFileDescription&, size_t) const override { return true; } - virtual KResultOr<size_t> write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return EINVAL; }; - virtual void start_request(AsyncBlockDeviceRequest& request) override { request.complete(AsyncDeviceRequest::Failure); } static bool is_valid_buffer_index(int buffer_index) { diff --git a/Kernel/Graphics/VirtIOGPU/GPU.cpp b/Kernel/Graphics/VirtIOGPU/GPU.cpp index 3483bfac3d..a961ac1dcf 100644 --- a/Kernel/Graphics/VirtIOGPU/GPU.cpp +++ b/Kernel/Graphics/VirtIOGPU/GPU.cpp @@ -46,8 +46,9 @@ void GPU::initialize() } } -GPU::GPU(PCI::DeviceIdentifier const& device_identifier) +GPU::GPU(GraphicsDevice const& adapter, PCI::DeviceIdentifier const& device_identifier) : VirtIO::Device(device_identifier) + , m_adapter(adapter) { auto region_or_error = MM.allocate_contiguous_kernel_region(32 * PAGE_SIZE, "VirtGPU Scratch Space", Memory::Region::Access::ReadWrite); if (region_or_error.is_error()) @@ -63,7 +64,7 @@ void GPU::create_framebuffer_devices() { for (size_t i = 0; i < min(m_num_scanouts, VIRTIO_GPU_MAX_SCANOUTS); i++) { auto& scanout = m_scanouts[i]; - scanout.framebuffer = adopt_ref(*new VirtIOGPU::FramebufferDevice(*this, i)); + scanout.framebuffer = adopt_ref(*new VirtIOGPU::FramebufferDevice(*m_adapter, *this, i)); scanout.framebuffer->after_inserting(); scanout.console = Kernel::Graphics::VirtIOGPU::Console::initialize(scanout.framebuffer); } diff --git a/Kernel/Graphics/VirtIOGPU/GPU.h b/Kernel/Graphics/VirtIOGPU/GPU.h index e1bf527bca..533ad5a66d 100644 --- a/Kernel/Graphics/VirtIOGPU/GPU.h +++ b/Kernel/Graphics/VirtIOGPU/GPU.h @@ -11,6 +11,7 @@ #include <Kernel/Bus/VirtIO/Device.h> #include <Kernel/Bus/VirtIO/Queue.h> #include <Kernel/Devices/BlockDevice.h> +#include <Kernel/Graphics/GraphicsDevice.h> #include <Kernel/Graphics/VirtIOGPU/Protocol.h> #define VIRTIO_GPU_F_VIRGL (1 << 0) @@ -40,7 +41,7 @@ class GPU final friend class FramebufferDevice; public: - GPU(PCI::DeviceIdentifier const&); + GPU(GraphicsDevice const&, PCI::DeviceIdentifier const&); virtual ~GPU() override; void create_framebuffer_devices(); @@ -119,6 +120,8 @@ private: VirtIO::Configuration const* m_device_configuration { nullptr }; ResourceID m_resource_id_counter { 0 }; + NonnullRefPtr<GraphicsDevice> m_adapter; + // Synchronous commands WaitQueue m_outstanding_request; Mutex m_operation_lock; diff --git a/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.cpp b/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.cpp index 507169a4dd..4043f81156 100644 --- a/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.cpp +++ b/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.cpp @@ -22,7 +22,7 @@ NonnullRefPtr<GraphicsAdapter> GraphicsAdapter::initialize(PCI::DeviceIdentifier GraphicsAdapter::GraphicsAdapter(PCI::DeviceIdentifier const& device_identifier) : PCI::Device(device_identifier.address()) { - m_gpu_device = adopt_ref(*new GPU(device_identifier)).leak_ref(); + m_gpu_device = adopt_ref(*new GPU(*this, device_identifier)).leak_ref(); m_gpu_device->initialize(); } |