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

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.
This commit is contained in:
Liav A 2021-05-18 21:34:22 +03:00 committed by Andreas Kling
parent 5f718c6b05
commit 87f8f892d8
9 changed files with 88 additions and 13 deletions

View file

@ -53,11 +53,11 @@ UNMAP_AFTER_INIT BochsGraphicsAdapter::BochsGraphicsAdapter(PCI::Address pci_add
: PCI::DeviceController(pci_address)
, m_mmio_registers(PCI::get_BAR2(pci_address) & 0xfffffff0)
{
set_safe_resolution();
// We assume safe resolutio is 1024x768x32
m_framebuffer_console = Graphics::FramebufferConsole::initialize(PhysicalAddress(PCI::get_BAR0(pci_address) & 0xfffffff0), 1024, 768, 1024 * sizeof(u32));
// FIXME: This is a very wrong way to do this...
GraphicsManagement::the().m_console = m_framebuffer_console;
set_safe_resolution();
}
UNMAP_AFTER_INIT void BochsGraphicsAdapter::initialize_framebuffer_devices()
@ -76,6 +76,7 @@ GraphicsDevice::Type BochsGraphicsAdapter::type() const
void BochsGraphicsAdapter::set_safe_resolution()
{
VERIFY(m_framebuffer_console);
set_resolution(1024, 768);
}
@ -105,6 +106,7 @@ bool BochsGraphicsAdapter::try_to_set_resolution(size_t width, size_t height)
bool BochsGraphicsAdapter::set_resolution(size_t width, size_t height)
{
VERIFY(m_framebuffer_console);
if (Checked<size_t>::multiplication_would_overflow(width, height, sizeof(u32)))
return false;
@ -112,6 +114,7 @@ bool BochsGraphicsAdapter::set_resolution(size_t width, size_t height)
return false;
dbgln("BochsGraphicsAdapter: resolution set to {}x{}", width, height);
m_framebuffer_console->set_resolution(width, height, width * sizeof(u32));
return true;
}