mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
Kernel/Graphics: Remove unnecessary derived FramebufferDevice classes
It seems like overly-specific classes were written for no good reason. Instead of making each adapter to have its own unique FramebufferDevice class, let's generalize everything to keep implementation more consistent.
This commit is contained in:
parent
b8fd845885
commit
c1a4dfeffb
|
@ -59,12 +59,10 @@ set(KERNEL_SOURCES
|
|||
Graphics/Console/FramebufferConsole.cpp
|
||||
Graphics/Console/TextModeConsole.cpp
|
||||
Graphics/Console/VGAConsole.cpp
|
||||
Graphics/BochsFramebufferDevice.cpp
|
||||
Graphics/BochsGraphicsAdapter.cpp
|
||||
Graphics/FramebufferDevice.cpp
|
||||
Graphics/GraphicsManagement.cpp
|
||||
Graphics/IntelNativeGraphicsAdapter.cpp
|
||||
Graphics/RawFramebufferDevice.cpp
|
||||
Graphics/VGACompatibleAdapter.cpp
|
||||
Storage/Partition/DiskPartition.cpp
|
||||
Storage/Partition/DiskPartitionMetadata.cpp
|
||||
|
|
|
@ -66,6 +66,10 @@
|
|||
#cmakedefine01 EXT2_DEBUG
|
||||
#endif
|
||||
|
||||
#ifndef FRAMEBUFFER_DEVICE_DEBUG
|
||||
#cmakedefine01 FRAMEBUFFER_DEVICE_DEBUG
|
||||
#endif
|
||||
|
||||
#ifndef EXT2_VERY_DEBUG
|
||||
#cmakedefine01 EXT2_VERY_DEBUG
|
||||
#endif
|
||||
|
|
|
@ -6,9 +6,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#define MAX_RESOLUTION_WIDTH 4096
|
||||
#define MAX_RESOLUTION_HEIGHT 2160
|
||||
|
||||
#define VBE_DISPI_IOPORT_INDEX 0x01CE
|
||||
#define VBE_DISPI_IOPORT_DATA 0x01CF
|
||||
|
||||
|
|
|
@ -1,114 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/Checked.h>
|
||||
#include <AK/Singleton.h>
|
||||
#include <Kernel/Debug.h>
|
||||
#include <Kernel/Graphics/Bochs.h>
|
||||
#include <Kernel/Graphics/BochsFramebufferDevice.h>
|
||||
#include <Kernel/IO.h>
|
||||
#include <Kernel/PCI/Access.h>
|
||||
#include <Kernel/Process.h>
|
||||
#include <LibC/errno_numbers.h>
|
||||
#include <LibC/sys/ioctl_numbers.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<BochsFramebufferDevice> BochsFramebufferDevice::create(const BochsGraphicsAdapter& adapter, PhysicalAddress framebuffer_address, size_t width, size_t height, size_t pitch)
|
||||
{
|
||||
return adopt_ref(*new BochsFramebufferDevice(adapter, framebuffer_address, pitch, width, height));
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT BochsFramebufferDevice::BochsFramebufferDevice(const BochsGraphicsAdapter& adapter, PhysicalAddress framebuffer_address, size_t width, size_t height, size_t pitch)
|
||||
: FramebufferDevice(framebuffer_address, width, height, pitch)
|
||||
, m_bochs_adapter(adapter)
|
||||
{
|
||||
m_bochs_adapter->set_safe_resolution();
|
||||
m_framebuffer_width = 1024;
|
||||
m_framebuffer_height = 768;
|
||||
m_framebuffer_pitch = m_framebuffer_width * sizeof(u32);
|
||||
}
|
||||
|
||||
void BochsFramebufferDevice::set_y_offset(size_t y_offset)
|
||||
{
|
||||
VERIFY(y_offset == 0 || y_offset == m_framebuffer_height);
|
||||
m_y_offset = y_offset;
|
||||
m_bochs_adapter->set_y_offset(y_offset);
|
||||
}
|
||||
|
||||
int BochsFramebufferDevice::ioctl(FileDescription&, unsigned request, FlatPtr arg)
|
||||
{
|
||||
REQUIRE_PROMISE(video);
|
||||
switch (request) {
|
||||
case FB_IOCTL_GET_SIZE_IN_BYTES: {
|
||||
auto* out = (size_t*)arg;
|
||||
size_t value = framebuffer_size_in_bytes();
|
||||
if (!copy_to_user(out, &value))
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
}
|
||||
case FB_IOCTL_GET_BUFFER: {
|
||||
auto* index = (int*)arg;
|
||||
int value = m_y_offset == 0 ? 0 : 1;
|
||||
if (!copy_to_user(index, &value))
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
}
|
||||
case FB_IOCTL_SET_BUFFER: {
|
||||
if (arg != 0 && arg != 1)
|
||||
return -EINVAL;
|
||||
set_y_offset(arg == 0 ? 0 : m_framebuffer_height);
|
||||
return 0;
|
||||
}
|
||||
case FB_IOCTL_GET_RESOLUTION: {
|
||||
auto* user_resolution = (FBResolution*)arg;
|
||||
FBResolution resolution;
|
||||
resolution.pitch = m_framebuffer_pitch;
|
||||
resolution.width = m_framebuffer_width;
|
||||
resolution.height = m_framebuffer_height;
|
||||
if (!copy_to_user(user_resolution, &resolution))
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
}
|
||||
case FB_IOCTL_SET_RESOLUTION: {
|
||||
auto* user_resolution = (FBResolution*)arg;
|
||||
FBResolution resolution;
|
||||
if (!copy_from_user(&resolution, user_resolution))
|
||||
return -EFAULT;
|
||||
if (resolution.width > MAX_RESOLUTION_WIDTH || resolution.height > MAX_RESOLUTION_HEIGHT)
|
||||
return -EINVAL;
|
||||
|
||||
if (!m_bochs_adapter->set_resolution(resolution.width, resolution.height)) {
|
||||
m_framebuffer_pitch = m_framebuffer_width * sizeof(u32);
|
||||
dbgln_if(BXVGA_DEBUG, "Reverting resolution: [{}x{}]", m_framebuffer_width, m_framebuffer_height);
|
||||
// Note: We try to revert everything back, and if it doesn't work, just assert.
|
||||
if (!m_bochs_adapter->set_resolution(m_framebuffer_width, m_framebuffer_height)) {
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
resolution.pitch = m_framebuffer_pitch;
|
||||
resolution.width = m_framebuffer_width;
|
||||
resolution.height = m_framebuffer_height;
|
||||
if (!copy_to_user(user_resolution, &resolution))
|
||||
return -EFAULT;
|
||||
return -EINVAL;
|
||||
}
|
||||
m_framebuffer_width = resolution.width;
|
||||
m_framebuffer_height = resolution.height;
|
||||
m_framebuffer_pitch = m_framebuffer_width * sizeof(u32);
|
||||
|
||||
dbgln_if(BXVGA_DEBUG, "New resolution: [{}x{}]", m_framebuffer_width, m_framebuffer_height);
|
||||
resolution.pitch = m_framebuffer_pitch;
|
||||
resolution.width = m_framebuffer_width;
|
||||
resolution.height = m_framebuffer_height;
|
||||
if (!copy_to_user(user_resolution, &resolution))
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
return -EINVAL;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Graphics/BochsGraphicsAdapter.h>
|
||||
#include <Kernel/Graphics/FramebufferDevice.h>
|
||||
#include <Kernel/PhysicalAddress.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
class BochsFramebufferDevice final : public FramebufferDevice {
|
||||
AK_MAKE_ETERNAL
|
||||
friend class BochsGraphicsAdapter;
|
||||
|
||||
public:
|
||||
static NonnullRefPtr<BochsFramebufferDevice> create(const BochsGraphicsAdapter&, PhysicalAddress, size_t, size_t, size_t);
|
||||
|
||||
virtual size_t framebuffer_size_in_bytes() const override { return m_framebuffer_pitch * m_framebuffer_height * 2; }
|
||||
|
||||
virtual ~BochsFramebufferDevice() = default;
|
||||
|
||||
private:
|
||||
virtual int ioctl(FileDescription&, unsigned request, FlatPtr arg) override;
|
||||
|
||||
BochsFramebufferDevice(const BochsGraphicsAdapter&, PhysicalAddress, size_t, size_t, size_t);
|
||||
virtual const char* class_name() const override { return "BXVGA"; }
|
||||
|
||||
void set_y_offset(size_t);
|
||||
|
||||
size_t m_y_offset { 0 };
|
||||
|
||||
NonnullRefPtr<BochsGraphicsAdapter> m_bochs_adapter;
|
||||
};
|
||||
|
||||
}
|
|
@ -9,7 +9,6 @@
|
|||
#include <AK/Singleton.h>
|
||||
#include <Kernel/Debug.h>
|
||||
#include <Kernel/Graphics/Bochs.h>
|
||||
#include <Kernel/Graphics/BochsFramebufferDevice.h>
|
||||
#include <Kernel/Graphics/BochsGraphicsAdapter.h>
|
||||
#include <Kernel/Graphics/Console/FramebufferConsole.h>
|
||||
#include <Kernel/Graphics/GraphicsManagement.h>
|
||||
|
@ -63,7 +62,7 @@ UNMAP_AFTER_INIT BochsGraphicsAdapter::BochsGraphicsAdapter(PCI::Address pci_add
|
|||
UNMAP_AFTER_INIT void BochsGraphicsAdapter::initialize_framebuffer_devices()
|
||||
{
|
||||
// FIXME: Find a better way to determine default resolution...
|
||||
m_framebuffer_device = BochsFramebufferDevice::create(*this, PhysicalAddress(PCI::get_BAR0(pci_address()) & 0xfffffff0), 1024, 768, 1024 * sizeof(u32));
|
||||
m_framebuffer_device = FramebufferDevice::create(*this, 0, PhysicalAddress(PCI::get_BAR0(pci_address()) & 0xfffffff0), 1024, 768, 1024 * sizeof(u32));
|
||||
m_framebuffer_device->initialize();
|
||||
}
|
||||
|
||||
|
@ -77,7 +76,8 @@ GraphicsDevice::Type BochsGraphicsAdapter::type() const
|
|||
void BochsGraphicsAdapter::set_safe_resolution()
|
||||
{
|
||||
VERIFY(m_framebuffer_console);
|
||||
set_resolution(1024, 768);
|
||||
auto result = try_to_set_resolution(0, 1024, 768);
|
||||
VERIFY(result);
|
||||
}
|
||||
|
||||
void BochsGraphicsAdapter::set_resolution_registers(size_t width, size_t height)
|
||||
|
@ -97,20 +97,17 @@ void BochsGraphicsAdapter::set_resolution_registers(size_t width, size_t height)
|
|||
registers->bochs_regs.bank = 0;
|
||||
}
|
||||
|
||||
bool BochsGraphicsAdapter::try_to_set_resolution(size_t width, size_t height)
|
||||
{
|
||||
dbgln_if(BXVGA_DEBUG, "BochsGraphicsAdapter resolution test - {}x{}", width, height);
|
||||
set_resolution_registers(width, height);
|
||||
return validate_setup_resolution(width, height);
|
||||
}
|
||||
|
||||
bool BochsGraphicsAdapter::set_resolution(size_t width, size_t height)
|
||||
bool BochsGraphicsAdapter::try_to_set_resolution(size_t output_port_index, size_t width, size_t height)
|
||||
{
|
||||
// Note: There's only one output port for this adapter
|
||||
VERIFY(output_port_index == 0);
|
||||
VERIFY(m_framebuffer_console);
|
||||
if (Checked<size_t>::multiplication_would_overflow(width, height, sizeof(u32)))
|
||||
return false;
|
||||
|
||||
if (!try_to_set_resolution(width, height))
|
||||
set_resolution_registers(width, height);
|
||||
dbgln_if(BXVGA_DEBUG, "BochsGraphicsAdapter resolution test - {}x{}", width, height);
|
||||
if (!validate_setup_resolution(width, height))
|
||||
return false;
|
||||
|
||||
dbgln("BochsGraphicsAdapter: resolution set to {}x{}", width, height);
|
||||
|
@ -127,12 +124,14 @@ bool BochsGraphicsAdapter::validate_setup_resolution(size_t width, size_t height
|
|||
return true;
|
||||
}
|
||||
|
||||
void BochsGraphicsAdapter::set_y_offset(size_t y_offset)
|
||||
bool BochsGraphicsAdapter::set_y_offset(size_t output_port_index, size_t y_offset)
|
||||
{
|
||||
VERIFY(output_port_index == 0);
|
||||
if (m_console_enabled)
|
||||
return;
|
||||
return false;
|
||||
auto registers = map_typed_writable<volatile BochsDisplayMMIORegisters>(m_mmio_registers);
|
||||
registers->bochs_regs.y_offset = y_offset;
|
||||
return true;
|
||||
}
|
||||
|
||||
void BochsGraphicsAdapter::enable_consoles()
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <AK/String.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Graphics/Console/FramebufferConsole.h>
|
||||
#include <Kernel/Graphics/FramebufferDevice.h>
|
||||
#include <Kernel/Graphics/GraphicsDevice.h>
|
||||
#include <Kernel/PCI/DeviceController.h>
|
||||
#include <Kernel/PhysicalAddress.h>
|
||||
|
@ -28,8 +29,14 @@ public:
|
|||
virtual ~BochsGraphicsAdapter() = default;
|
||||
virtual bool framebuffer_devices_initialized() const override { return !m_framebuffer_device.is_null(); }
|
||||
|
||||
virtual bool modesetting_capable() const override { return true; }
|
||||
virtual bool double_framebuffering_capable() const override { return true; }
|
||||
|
||||
private:
|
||||
// ^GraphicsDevice
|
||||
virtual bool try_to_set_resolution(size_t output_port_index, size_t width, size_t height) override;
|
||||
virtual bool set_y_offset(size_t output_port_index, size_t y) override;
|
||||
|
||||
virtual void initialize_framebuffer_devices() override;
|
||||
virtual Type type() const override;
|
||||
|
||||
|
@ -42,13 +49,11 @@ private:
|
|||
|
||||
bool validate_setup_resolution(size_t width, size_t height);
|
||||
u32 find_framebuffer_address();
|
||||
bool try_to_set_resolution(size_t width, size_t height);
|
||||
bool set_resolution(size_t width, size_t height);
|
||||
void set_resolution_registers(size_t width, size_t height);
|
||||
void set_y_offset(size_t);
|
||||
|
||||
PhysicalAddress m_mmio_registers;
|
||||
RefPtr<BochsFramebufferDevice> m_framebuffer_device;
|
||||
RefPtr<FramebufferDevice> m_framebuffer_device;
|
||||
RefPtr<Graphics::FramebufferConsole> m_framebuffer_console;
|
||||
SpinLock<u8> m_console_mode_switch_lock;
|
||||
bool m_console_enabled { false };
|
||||
|
|
|
@ -18,8 +18,16 @@
|
|||
|
||||
#include <Kernel/Panic.h>
|
||||
|
||||
#define MAX_RESOLUTION_WIDTH 4096
|
||||
#define MAX_RESOLUTION_HEIGHT 2160
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
NonnullRefPtr<FramebufferDevice> FramebufferDevice::create(const GraphicsDevice& adapter, size_t output_port_index, PhysicalAddress paddr, size_t width, size_t height, size_t pitch)
|
||||
{
|
||||
return adopt_ref(*new FramebufferDevice(adapter, output_port_index, paddr, width, height, pitch));
|
||||
}
|
||||
|
||||
KResultOr<Region*> FramebufferDevice::mmap(Process& process, FileDescription&, const Range& range, u64 offset, int prot, bool shared)
|
||||
{
|
||||
ScopedSpinLock lock(m_activation_lock);
|
||||
|
@ -103,12 +111,14 @@ UNMAP_AFTER_INIT void FramebufferDevice::initialize()
|
|||
VERIFY(m_swapped_framebuffer_region);
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT FramebufferDevice::FramebufferDevice(PhysicalAddress addr, size_t width, size_t height, size_t pitch)
|
||||
UNMAP_AFTER_INIT FramebufferDevice::FramebufferDevice(const GraphicsDevice& adapter, size_t output_port_index, PhysicalAddress addr, size_t width, size_t height, size_t pitch)
|
||||
: BlockDevice(29, GraphicsManagement::the().allocate_minor_device_number())
|
||||
, m_framebuffer_address(addr)
|
||||
, m_framebuffer_pitch(pitch)
|
||||
, m_framebuffer_width(width)
|
||||
, m_framebuffer_height(height)
|
||||
, m_output_port_index(output_port_index)
|
||||
, m_graphics_adapter(adapter)
|
||||
{
|
||||
VERIFY(!m_framebuffer_address.is_null());
|
||||
VERIFY(m_framebuffer_pitch);
|
||||
|
@ -117,9 +127,11 @@ UNMAP_AFTER_INIT FramebufferDevice::FramebufferDevice(PhysicalAddress addr, size
|
|||
dbgln("Framebuffer {}: address={}, pitch={}, width={}, height={}", minor(), addr, pitch, width, height);
|
||||
}
|
||||
|
||||
bool FramebufferDevice::set_resolution(size_t, size_t, size_t)
|
||||
size_t FramebufferDevice::framebuffer_size_in_bytes() const
|
||||
{
|
||||
VERIFY_NOT_REACHED();
|
||||
if (m_graphics_adapter->double_framebuffering_capable())
|
||||
return m_framebuffer_pitch * m_framebuffer_height * 2;
|
||||
return m_framebuffer_pitch * m_framebuffer_height;
|
||||
}
|
||||
|
||||
int FramebufferDevice::ioctl(FileDescription&, unsigned request, FlatPtr arg)
|
||||
|
@ -134,7 +146,21 @@ int FramebufferDevice::ioctl(FileDescription&, unsigned request, FlatPtr arg)
|
|||
return 0;
|
||||
}
|
||||
case FB_IOCTL_GET_BUFFER: {
|
||||
auto* index = (int*)arg;
|
||||
int value = m_y_offset == 0 ? 0 : 1;
|
||||
if (!copy_to_user(index, &value))
|
||||
return -EFAULT;
|
||||
if (!m_graphics_adapter->double_framebuffering_capable())
|
||||
return -ENOTIMPL;
|
||||
return 0;
|
||||
}
|
||||
case FB_IOCTL_SET_BUFFER: {
|
||||
if (arg != 0 && arg != 1)
|
||||
return -EINVAL;
|
||||
if (!m_graphics_adapter->double_framebuffering_capable())
|
||||
return -ENOTIMPL;
|
||||
m_graphics_adapter->set_y_offset(m_output_port_index, arg == 0 ? 0 : m_framebuffer_height);
|
||||
return 0;
|
||||
}
|
||||
case FB_IOCTL_GET_RESOLUTION: {
|
||||
auto* user_resolution = (FBResolution*)arg;
|
||||
|
@ -149,6 +175,39 @@ int FramebufferDevice::ioctl(FileDescription&, unsigned request, FlatPtr arg)
|
|||
case FB_IOCTL_SET_RESOLUTION: {
|
||||
auto* user_resolution = (FBResolution*)arg;
|
||||
FBResolution resolution;
|
||||
if (!copy_from_user(&resolution, user_resolution))
|
||||
return -EFAULT;
|
||||
if (resolution.width > MAX_RESOLUTION_WIDTH || resolution.height > MAX_RESOLUTION_HEIGHT)
|
||||
return -EINVAL;
|
||||
|
||||
if (!m_graphics_adapter->modesetting_capable()) {
|
||||
resolution.pitch = m_framebuffer_pitch;
|
||||
resolution.width = m_framebuffer_width;
|
||||
resolution.height = m_framebuffer_height;
|
||||
if (!copy_to_user(user_resolution, &resolution))
|
||||
return -EFAULT;
|
||||
return -ENOTIMPL;
|
||||
}
|
||||
|
||||
if (!m_graphics_adapter->try_to_set_resolution(m_output_port_index, resolution.width, resolution.height)) {
|
||||
m_framebuffer_pitch = m_framebuffer_width * sizeof(u32);
|
||||
dbgln_if(FRAMEBUFFER_DEVICE_DEBUG, "Reverting resolution: [{}x{}]", m_framebuffer_width, m_framebuffer_height);
|
||||
// Note: We try to revert everything back, and if it doesn't work, just assert.
|
||||
if (!m_graphics_adapter->try_to_set_resolution(m_output_port_index, m_framebuffer_width, m_framebuffer_height)) {
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
resolution.pitch = m_framebuffer_pitch;
|
||||
resolution.width = m_framebuffer_width;
|
||||
resolution.height = m_framebuffer_height;
|
||||
if (!copy_to_user(user_resolution, &resolution))
|
||||
return -EFAULT;
|
||||
return -EINVAL;
|
||||
}
|
||||
m_framebuffer_width = resolution.width;
|
||||
m_framebuffer_height = resolution.height;
|
||||
m_framebuffer_pitch = m_framebuffer_width * sizeof(u32);
|
||||
|
||||
dbgln_if(FRAMEBUFFER_DEVICE_DEBUG, "New resolution: [{}x{}]", m_framebuffer_width, m_framebuffer_height);
|
||||
resolution.pitch = m_framebuffer_pitch;
|
||||
resolution.width = m_framebuffer_width;
|
||||
resolution.height = m_framebuffer_height;
|
||||
|
|
|
@ -20,6 +20,8 @@ namespace Kernel {
|
|||
class FramebufferDevice : public BlockDevice {
|
||||
AK_MAKE_ETERNAL
|
||||
public:
|
||||
static NonnullRefPtr<FramebufferDevice> create(const GraphicsDevice&, size_t, PhysicalAddress, size_t, size_t, size_t);
|
||||
|
||||
virtual int ioctl(FileDescription&, unsigned request, FlatPtr arg) override;
|
||||
virtual KResultOr<Region*> mmap(Process&, FileDescription&, const Range&, u64 offset, int prot, bool shared) override;
|
||||
|
||||
|
@ -29,15 +31,14 @@ public:
|
|||
|
||||
virtual void deactivate_writes();
|
||||
virtual void activate_writes();
|
||||
virtual size_t framebuffer_size_in_bytes() const { return m_framebuffer_pitch * m_framebuffer_height; }
|
||||
size_t framebuffer_size_in_bytes() const;
|
||||
|
||||
virtual ~FramebufferDevice() {};
|
||||
void initialize();
|
||||
|
||||
protected:
|
||||
virtual bool set_resolution(size_t framebuffer_width, size_t framebuffer_height, size_t framebuffer_pitch);
|
||||
|
||||
FramebufferDevice(PhysicalAddress, size_t, size_t, size_t);
|
||||
private:
|
||||
// ^File
|
||||
virtual const char* class_name() const { return "FramebufferDevice"; }
|
||||
|
||||
virtual bool can_read(const FileDescription&, size_t) const override final { return true; }
|
||||
virtual bool can_write(const FileDescription&, size_t) const override final { return true; }
|
||||
|
@ -45,13 +46,13 @@ protected:
|
|||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override { return -EINVAL; }
|
||||
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return -EINVAL; }
|
||||
|
||||
protected:
|
||||
FramebufferDevice(const GraphicsDevice&, size_t, PhysicalAddress, size_t, size_t, size_t);
|
||||
|
||||
PhysicalAddress m_framebuffer_address;
|
||||
size_t m_framebuffer_pitch { 0 };
|
||||
size_t m_framebuffer_width { 0 };
|
||||
size_t m_framebuffer_height { 0 };
|
||||
|
||||
private:
|
||||
SpinLock<u8> m_activation_lock;
|
||||
|
||||
RefPtr<AnonymousVMObject> m_real_framebuffer_vmobject;
|
||||
|
@ -63,6 +64,10 @@ private:
|
|||
|
||||
RefPtr<AnonymousVMObject> m_userspace_real_framebuffer_vmobject;
|
||||
Region* m_userspace_framebuffer_region { nullptr };
|
||||
|
||||
size_t m_y_offset { 0 };
|
||||
size_t m_output_port_index;
|
||||
NonnullRefPtr<GraphicsDevice> m_graphics_adapter;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -9,11 +9,9 @@
|
|||
#include <AK/String.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Devices/BlockDevice.h>
|
||||
#include <Kernel/Graphics/FramebufferDevice.h>
|
||||
#include <Kernel/PhysicalAddress.h>
|
||||
|
||||
namespace Kernel {
|
||||
class FramebufferDevice;
|
||||
class GraphicsDevice : public RefCounted<GraphicsDevice> {
|
||||
public:
|
||||
enum class Type {
|
||||
|
@ -30,6 +28,12 @@ public:
|
|||
bool consoles_enabled() const { return m_consoles_enabled; }
|
||||
virtual bool framebuffer_devices_initialized() const = 0;
|
||||
|
||||
virtual bool modesetting_capable() const = 0;
|
||||
virtual bool double_framebuffering_capable() const = 0;
|
||||
|
||||
virtual bool try_to_set_resolution(size_t output_port_index, size_t width, size_t height) = 0;
|
||||
virtual bool set_y_offset(size_t output_port_index, size_t y) = 0;
|
||||
|
||||
protected:
|
||||
GraphicsDevice() = default;
|
||||
|
||||
|
|
|
@ -625,7 +625,7 @@ void IntelNativeGraphicsAdapter::initialize_framebuffer_devices()
|
|||
VERIFY(m_framebuffer_pitch != 0);
|
||||
VERIFY(m_framebuffer_height != 0);
|
||||
VERIFY(m_framebuffer_width != 0);
|
||||
m_framebuffer_device = RawFramebufferDevice::create(*this, address, m_framebuffer_width, m_framebuffer_height, m_framebuffer_pitch);
|
||||
m_framebuffer_device = FramebufferDevice::create(*this, 0, address, m_framebuffer_width, m_framebuffer_height, m_framebuffer_pitch);
|
||||
m_framebuffer_device->initialize();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <AK/String.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Graphics/Definitions.h>
|
||||
#include <Kernel/Graphics/RawFramebufferDevice.h>
|
||||
#include <Kernel/Graphics/FramebufferDevice.h>
|
||||
#include <Kernel/Graphics/VGACompatibleAdapter.h>
|
||||
#include <Kernel/PCI/DeviceController.h>
|
||||
#include <Kernel/PhysicalAddress.h>
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <Kernel/Graphics/RawFramebufferDevice.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<RawFramebufferDevice> RawFramebufferDevice::create(const GraphicsDevice&, PhysicalAddress framebuffer_address, size_t width, size_t height, size_t pitch)
|
||||
{
|
||||
return adopt_ref(*new RawFramebufferDevice(framebuffer_address, width, height, pitch));
|
||||
}
|
||||
UNMAP_AFTER_INIT RawFramebufferDevice::RawFramebufferDevice(PhysicalAddress framebuffer_address, size_t width, size_t height, size_t pitch)
|
||||
: FramebufferDevice(framebuffer_address, width, height, pitch)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Graphics/FramebufferDevice.h>
|
||||
#include <Kernel/Graphics/GraphicsDevice.h>
|
||||
#include <Kernel/PhysicalAddress.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
class RawFramebufferDevice : public FramebufferDevice {
|
||||
AK_MAKE_ETERNAL
|
||||
friend class GraphicsDevice;
|
||||
|
||||
public:
|
||||
static NonnullRefPtr<RawFramebufferDevice> create(const GraphicsDevice&, PhysicalAddress, size_t width, size_t height, size_t pitch);
|
||||
|
||||
virtual ~RawFramebufferDevice() {};
|
||||
|
||||
private:
|
||||
RawFramebufferDevice(PhysicalAddress, size_t width, size_t height, size_t pitch);
|
||||
virtual const char* class_name() const override { return "RawFramebuffer"; }
|
||||
};
|
||||
|
||||
}
|
|
@ -31,7 +31,7 @@ UNMAP_AFTER_INIT void VGACompatibleAdapter::initialize_framebuffer_devices()
|
|||
VERIFY(m_framebuffer_width != 0);
|
||||
VERIFY(m_framebuffer_height != 0);
|
||||
VERIFY(m_framebuffer_pitch != 0);
|
||||
m_framebuffer_device = RawFramebufferDevice::create(*this, m_framebuffer_address, m_framebuffer_width, m_framebuffer_height, m_framebuffer_pitch);
|
||||
m_framebuffer_device = FramebufferDevice::create(*this, 0, m_framebuffer_address, m_framebuffer_width, m_framebuffer_height, m_framebuffer_pitch);
|
||||
m_framebuffer_device->initialize();
|
||||
}
|
||||
|
||||
|
@ -70,4 +70,13 @@ void VGACompatibleAdapter::disable_consoles()
|
|||
m_framebuffer_device->activate_writes();
|
||||
}
|
||||
|
||||
bool VGACompatibleAdapter::try_to_set_resolution(size_t, size_t, size_t)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool VGACompatibleAdapter::set_y_offset(size_t, size_t)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
#include <AK/String.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Graphics/Console/Console.h>
|
||||
#include <Kernel/Graphics/FramebufferDevice.h>
|
||||
#include <Kernel/Graphics/GraphicsDevice.h>
|
||||
#include <Kernel/Graphics/RawFramebufferDevice.h>
|
||||
#include <Kernel/PCI/DeviceController.h>
|
||||
#include <Kernel/PhysicalAddress.h>
|
||||
|
||||
|
@ -25,6 +25,12 @@ public:
|
|||
|
||||
virtual bool framebuffer_devices_initialized() const override { return !m_framebuffer_device.is_null(); }
|
||||
|
||||
virtual bool modesetting_capable() const override { return false; }
|
||||
virtual bool double_framebuffering_capable() const override { return false; }
|
||||
|
||||
virtual bool try_to_set_resolution(size_t output_port_index, size_t width, size_t height) override;
|
||||
virtual bool set_y_offset(size_t output_port_index, size_t y) override;
|
||||
|
||||
protected:
|
||||
explicit VGACompatibleAdapter(PCI::Address);
|
||||
|
||||
|
@ -44,7 +50,7 @@ protected:
|
|||
size_t m_framebuffer_height { 0 };
|
||||
size_t m_framebuffer_pitch { 0 };
|
||||
|
||||
RefPtr<RawFramebufferDevice> m_framebuffer_device;
|
||||
RefPtr<FramebufferDevice> m_framebuffer_device;
|
||||
RefPtr<Graphics::Console> m_framebuffer_console;
|
||||
};
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ set(PAGE_FAULT_DEBUG ON)
|
|||
set(CONTEXT_SWITCH_DEBUG ON)
|
||||
set(SMP_DEBUG ON)
|
||||
set(BXVGA_DEBUG ON)
|
||||
set(FRAMEBUFFER_DEVICE_DEBUG ON)
|
||||
set(PS2MOUSE_DEBUG ON)
|
||||
set(MOUSE_DEBUG ON)
|
||||
set(VMWARE_BACKDOOR_DEBUG ON)
|
||||
|
|
Loading…
Reference in a new issue