diff options
author | Liav A <liavalb@gmail.com> | 2021-05-18 21:34:22 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-21 08:08:33 +0200 |
commit | 87f8f892d858a14b5c03b7bd7fdc9517a8f4cb84 (patch) | |
tree | 7076b1d1989a9c29fe3d84948faa25af09b9a088 /Kernel/Graphics/Console | |
parent | 5f718c6b05a638d200b9f546cc7f67cc77cf4b66 (diff) | |
download | serenity-87f8f892d858a14b5c03b7bd7fdc9517a8f4cb84.zip |
Kernel: Fix framebuffer resolution modesetting after boot
If we tried to change the resolution before of this patch, we triggered
a kernel crash due to mmaping the framebuffer device again.
Therefore, on mmaping of the framebuffer device, we create an entire new
set of VMObjects and Regions for the new settings.
Then, when we change the resolution, the framebuffersconsole needs to be
updated with the new resolution and also to be refreshed with the new
settings. To ensure we handle both shrinking of the resolution and
growth of it, we only copy the right amount of available data from the
cells Region.
Diffstat (limited to 'Kernel/Graphics/Console')
-rw-r--r-- | Kernel/Graphics/Console/Console.h | 4 | ||||
-rw-r--r-- | Kernel/Graphics/Console/FramebufferConsole.cpp | 20 | ||||
-rw-r--r-- | Kernel/Graphics/Console/FramebufferConsole.h | 2 |
3 files changed, 20 insertions, 6 deletions
diff --git a/Kernel/Graphics/Console/Console.h b/Kernel/Graphics/Console/Console.h index c391dc32fb..448f1c7df6 100644 --- a/Kernel/Graphics/Console/Console.h +++ b/Kernel/Graphics/Console/Console.h @@ -74,8 +74,8 @@ protected: Atomic<bool> m_enabled; Color m_default_foreground_color { Color::White }; Color m_default_background_color { Color::Black }; - const size_t m_width; - const size_t m_height; + size_t m_width; + size_t m_height; mutable size_t m_x { 0 }; mutable size_t m_y { 0 }; }; diff --git a/Kernel/Graphics/Console/FramebufferConsole.cpp b/Kernel/Graphics/Console/FramebufferConsole.cpp index 8ae2e3122e..5c960913c9 100644 --- a/Kernel/Graphics/Console/FramebufferConsole.cpp +++ b/Kernel/Graphics/Console/FramebufferConsole.cpp @@ -5,6 +5,7 @@ */ #include <Kernel/Graphics/Console/FramebufferConsole.h> +#include <Kernel/TTY/ConsoleManagement.h> namespace Kernel::Graphics { @@ -204,17 +205,28 @@ NonnullRefPtr<FramebufferConsole> FramebufferConsole::initialize(PhysicalAddress return adopt_ref(*new FramebufferConsole(framebuffer_address, width, height, pitch)); } -FramebufferConsole::FramebufferConsole(PhysicalAddress framebuffer_address, size_t width, size_t height, size_t pitch) - : Console(width, height) - , m_framebuffer_address(framebuffer_address) - , m_pitch(pitch) +void FramebufferConsole::set_resolution(size_t width, size_t height, size_t pitch) { + m_width = width; + m_height = height; + m_pitch = pitch; + dbgln("Framebuffer Console: taking {} bytes", page_round_up(pitch * height)); m_framebuffer_region = MM.allocate_kernel_region(m_framebuffer_address, page_round_up(pitch * height), "Framebuffer Console", Region::Access::Read | Region::Access::Write, Region::Cacheable::Yes); VERIFY(m_framebuffer_region); // Just to start cleanly, we clean the entire framebuffer memset(m_framebuffer_region->vaddr().as_ptr(), 0, pitch * height); + + ConsoleManagement::the().resolution_was_changed(); +} + +FramebufferConsole::FramebufferConsole(PhysicalAddress framebuffer_address, size_t width, size_t height, size_t pitch) + : Console(width, height) + , m_framebuffer_address(framebuffer_address) + , m_pitch(pitch) +{ + set_resolution(width, height, pitch); } size_t FramebufferConsole::bytes_per_base_glyph() const diff --git a/Kernel/Graphics/Console/FramebufferConsole.h b/Kernel/Graphics/Console/FramebufferConsole.h index 48574768b7..7e141cef9a 100644 --- a/Kernel/Graphics/Console/FramebufferConsole.h +++ b/Kernel/Graphics/Console/FramebufferConsole.h @@ -16,6 +16,8 @@ class FramebufferConsole final : public Console { public: static NonnullRefPtr<FramebufferConsole> initialize(PhysicalAddress, size_t width, size_t height, size_t pitch); + void set_resolution(size_t width, size_t height, size_t pitch); + virtual size_t bytes_per_base_glyph() const override; virtual size_t chars_per_line() const override; |