1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:07:44 +00:00

Kernel/Graphics: Untie Text mode console from VGACompatibleAdapter class

Instead, we can construct this type of object without having to
instantiate a VGACompatibleAdapter object first.
This can help instantiate such console very early on boot to aid debug
issues on bare metal hardware.
This commit is contained in:
Liav A 2022-02-09 20:53:17 +02:00 committed by Linus Groh
parent c6acf64558
commit 90a194377c
5 changed files with 10 additions and 12 deletions

View file

@ -11,13 +11,13 @@
namespace Kernel::Graphics {
UNMAP_AFTER_INIT NonnullRefPtr<TextModeConsole> TextModeConsole::initialize(const VGACompatibleAdapter& adapter)
UNMAP_AFTER_INIT NonnullRefPtr<TextModeConsole> TextModeConsole::initialize()
{
return adopt_ref(*new TextModeConsole(adapter));
return adopt_ref(*new TextModeConsole());
}
UNMAP_AFTER_INIT TextModeConsole::TextModeConsole(const VGACompatibleAdapter& adapter)
: VGAConsole(adapter, VGAConsole::Mode::TextMode, 80, 25)
UNMAP_AFTER_INIT TextModeConsole::TextModeConsole()
: VGAConsole(VGAConsole::Mode::TextMode, 80, 25)
, m_current_vga_window(m_vga_region->vaddr().offset(0x18000).as_ptr())
{
for (size_t index = 0; index < height(); index++) {

View file

@ -14,7 +14,7 @@
namespace Kernel::Graphics {
class TextModeConsole final : public VGAConsole {
public:
static NonnullRefPtr<TextModeConsole> initialize(const VGACompatibleAdapter& adapter);
static NonnullRefPtr<TextModeConsole> initialize();
virtual size_t chars_per_line() const override { return width(); };
virtual bool has_hardware_cursor() const override { return true; }
@ -36,7 +36,7 @@ public:
private:
void clear_vga_row(u16 row);
explicit TextModeConsole(const VGACompatibleAdapter&);
TextModeConsole();
mutable Spinlock m_vga_lock;

View file

@ -9,10 +9,9 @@
namespace Kernel::Graphics {
UNMAP_AFTER_INIT VGAConsole::VGAConsole(const VGACompatibleAdapter& adapter, Mode mode, size_t width, size_t height)
UNMAP_AFTER_INIT VGAConsole::VGAConsole(Mode mode, size_t width, size_t height)
: Console(width, height)
, m_vga_region(MM.allocate_kernel_region(PhysicalAddress(0xa0000), Memory::page_round_up(0xc0000 - 0xa0000).release_value_but_fixme_should_propagate_errors(), "VGA Display", Memory::Region::Access::ReadWrite).release_value())
, m_adapter(adapter)
, m_mode(mode)
{
}

View file

@ -22,7 +22,7 @@ public:
};
public:
static NonnullRefPtr<VGAConsole> initialize(const VGACompatibleAdapter&, Mode, size_t width, size_t height);
static NonnullRefPtr<VGAConsole> initialize(Mode, size_t width, size_t height);
virtual bool is_hardware_paged_capable() const override { return false; }
virtual bool has_hardware_cursor() const override { return false; }
@ -31,10 +31,9 @@ public:
virtual ~VGAConsole() = default;
protected:
VGAConsole(const VGACompatibleAdapter&, Mode, size_t width, size_t height);
VGAConsole(Mode, size_t width, size_t height);
NonnullOwnPtr<Memory::Region> m_vga_region;
NonnullRefPtr<VGACompatibleAdapter> m_adapter;
const Mode m_mode;
};
}

View file

@ -39,7 +39,7 @@ UNMAP_AFTER_INIT void VGACompatibleAdapter::initialize_framebuffer_devices()
UNMAP_AFTER_INIT VGACompatibleAdapter::VGACompatibleAdapter(PCI::Address address)
: PCI::Device(address)
{
m_framebuffer_console = Graphics::TextModeConsole::initialize(*this);
m_framebuffer_console = Graphics::TextModeConsole::initialize();
GraphicsManagement::the().set_console(*m_framebuffer_console);
}