1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-08 05:57:35 +00:00
serenity/Kernel/Graphics/BochsGraphicsAdapter.h
Sahan Fernando 34e9fa4d3b Kernel: Abstract FramebufferConsole away from contiguous physical range
Currently, Kernel::Graphics::FramebufferConsole is written assuming that
the underlying framebuffer memory exists in physically contiguous
memory. There are a bunch of framebuffer devices that would need to use
the components of FramebufferConsole (in particular access to the kernel
bitmap font rendering logic). To reduce code duplication, framebuffer
console has been split into two parts, the abstract
GenericFramebufferConsole class which does the rendering, and the
ContiguousFramebufferConsole class which contains all logic related to
managing the underling vm object.

Also, a new flush method has been added to the class, to support devices
that require an extra flush step to render.
2021-06-25 19:26:30 +02:00

65 lines
2.1 KiB
C++

/*
* 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/Console/GenericFramebufferConsole.h>
#include <Kernel/Graphics/FramebufferDevice.h>
#include <Kernel/Graphics/GraphicsDevice.h>
#include <Kernel/PCI/DeviceController.h>
#include <Kernel/PhysicalAddress.h>
namespace Kernel {
class BochsFramebufferDevice;
class GraphicsManagement;
class BochsGraphicsAdapter final : public GraphicsDevice
, public PCI::DeviceController {
AK_MAKE_ETERNAL
friend class BochsFramebufferDevice;
friend class GraphicsManagement;
public:
static NonnullRefPtr<BochsGraphicsAdapter> initialize(PCI::Address);
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;
virtual void enable_consoles() override;
virtual void disable_consoles() override;
explicit BochsGraphicsAdapter(PCI::Address);
void set_safe_resolution();
bool validate_setup_resolution(size_t width, size_t height);
u32 find_framebuffer_address();
void set_resolution_registers(size_t width, size_t height);
void set_resolution_registers_via_io(size_t width, size_t height);
bool validate_setup_resolution_with_io(size_t width, size_t height);
void set_y_offset(size_t);
PhysicalAddress m_mmio_registers;
RefPtr<FramebufferDevice> m_framebuffer_device;
RefPtr<Graphics::GenericFramebufferConsole> m_framebuffer_console;
SpinLock<u8> m_console_mode_switch_lock;
bool m_console_enabled { false };
bool m_io_required { false };
};
}