mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-28 07:18:51 +00:00
Kernel/Graphics: Always ensure a console is set when initialization ends
We use a ScopeGuard to ensure we always set a console of some sort if we exit early from the initialization sequence in the GraphicsManagement code. We do so to ensure we can boot into text mode console in an ISA-PC machine type, because earlier we failed with an assertion due to not setting any console for VirtualConsole to use.
This commit is contained in:
parent
48730ff8ec
commit
02a980ee54
Notes:
sideshowbarker
2024-07-17 06:46:57 +09:00
Author: https://github.com/supercomputer7
Commit: 02a980ee54
Pull-request: https://github.com/SerenityOS/serenity/pull/15259
Reviewed-by: https://github.com/linusg
1 changed files with 11 additions and 15 deletions
|
@ -189,15 +189,20 @@ UNMAP_AFTER_INIT bool GraphicsManagement::initialize()
|
|||
* a variant that is suitable for ISA VGA handling, and not PCI adapters.
|
||||
*/
|
||||
|
||||
ScopeGuard assign_console_on_initialization_exit([this] {
|
||||
if (!m_console) {
|
||||
// If no graphics driver was instantiated and we had a bootloader provided
|
||||
// framebuffer console we can simply re-use it.
|
||||
if (auto* boot_console = g_boot_console.load()) {
|
||||
m_console = *boot_console;
|
||||
boot_console->unref(); // Drop the leaked reference from Kernel::init()
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
auto graphics_subsystem_mode = kernel_command_line().graphics_subsystem_mode();
|
||||
if (graphics_subsystem_mode == CommandLine::GraphicsSubsystemMode::Disabled) {
|
||||
VERIFY(!m_console);
|
||||
// If no graphics driver was instantiated and we had a bootloader provided
|
||||
// framebuffer console we can simply re-use it.
|
||||
if (auto* boot_console = g_boot_console.load()) {
|
||||
m_console = *boot_console;
|
||||
boot_console->unref(); // Drop the leaked reference from Kernel::init()
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -232,15 +237,6 @@ UNMAP_AFTER_INIT bool GraphicsManagement::initialize()
|
|||
return true;
|
||||
}
|
||||
|
||||
if (!m_console) {
|
||||
// If no graphics driver was instantiated and we had a bootloader provided
|
||||
// framebuffer console we can simply re-use it.
|
||||
if (auto* boot_console = g_boot_console.load()) {
|
||||
m_console = *boot_console;
|
||||
boot_console->unref(); // Drop the leaked reference from Kernel::init()
|
||||
}
|
||||
}
|
||||
|
||||
if (m_graphics_devices.is_empty()) {
|
||||
dbgln("No graphics adapter was initialized.");
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue