mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:28:11 +00:00
Kernel: Disable BootFramebufferConsole when drivers create a new one
When GraphicsManagement initializes the drivers we can disable the bootloader framebuffer console. Right now we don't yet fully destroy the no longer needed console as it may be in use by another CPU.
This commit is contained in:
parent
24f2f3ba4e
commit
4c506f91fe
6 changed files with 33 additions and 17 deletions
|
@ -10,6 +10,7 @@
|
|||
#include <Kernel/Bus/PCI/IDs.h>
|
||||
#include <Kernel/CommandLine.h>
|
||||
#include <Kernel/Graphics/Bochs/GraphicsAdapter.h>
|
||||
#include <Kernel/Graphics/Console/BootFramebufferConsole.h>
|
||||
#include <Kernel/Graphics/GraphicsManagement.h>
|
||||
#include <Kernel/Graphics/Intel/NativeGraphicsAdapter.h>
|
||||
#include <Kernel/Graphics/VGACompatibleAdapter.h>
|
||||
|
@ -22,6 +23,8 @@ namespace Kernel {
|
|||
|
||||
static Singleton<GraphicsManagement> s_the;
|
||||
|
||||
extern Atomic<Graphics::BootFramebufferConsole*> boot_framebuffer_console;
|
||||
|
||||
GraphicsManagement& GraphicsManagement::the()
|
||||
{
|
||||
return *s_the;
|
||||
|
@ -215,6 +218,15 @@ UNMAP_AFTER_INIT bool GraphicsManagement::initialize()
|
|||
determine_and_initialize_graphics_device(device_identifier);
|
||||
});
|
||||
|
||||
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 = boot_framebuffer_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;
|
||||
|
@ -230,4 +242,19 @@ bool GraphicsManagement::framebuffer_devices_exist() const
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void GraphicsManagement::set_console(Graphics::Console& console)
|
||||
{
|
||||
m_console = console;
|
||||
|
||||
if (auto* boot_console = boot_framebuffer_console.exchange(nullptr)) {
|
||||
// Disable the initial boot framebuffer console permanently
|
||||
boot_console->disable();
|
||||
// TODO: Even though we swapped the pointer and disabled the console
|
||||
// we technically can't safely destroy it as other CPUs might still
|
||||
// try to use it. Once we solve this problem we can drop the reference
|
||||
// that we intentionally leaked in Kernel::init().
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue