summaryrefslogtreecommitdiff
path: root/Kernel/Devices/BXVGADevice.cpp
diff options
context:
space:
mode:
authorTom <tomut@yahoo.com>2020-08-24 19:35:19 -0600
committerAndreas Kling <kling@serenityos.org>2020-08-25 09:48:48 +0200
commitd89582880ed81c38df67687eadfc0764b6ce5ddd (patch)
tree3ff52c4e8808c5167ee37d5bf0a6669e9a18dfb4 /Kernel/Devices/BXVGADevice.cpp
parentba6e4fb77f00587d2bd57865a00b1a4526684741 (diff)
downloadserenity-d89582880ed81c38df67687eadfc0764b6ce5ddd.zip
Kernel: Switch singletons to use new Singleton class
MemoryManager cannot use the Singleton class because MemoryManager::initialize is called before the global constructors are run. That caused the Singleton to be re-initialized, causing it to create another MemoryManager instance. Fixes #3226
Diffstat (limited to 'Kernel/Devices/BXVGADevice.cpp')
-rw-r--r--Kernel/Devices/BXVGADevice.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/Kernel/Devices/BXVGADevice.cpp b/Kernel/Devices/BXVGADevice.cpp
index 1e3a4b5168..c9f1732260 100644
--- a/Kernel/Devices/BXVGADevice.cpp
+++ b/Kernel/Devices/BXVGADevice.cpp
@@ -25,6 +25,7 @@
*/
#include <AK/Checked.h>
+#include <AK/Singleton.h>
#include <Kernel/Devices/BXVGADevice.h>
#include <Kernel/IO.h>
#include <Kernel/PCI/Access.h>
@@ -56,7 +57,12 @@ namespace Kernel {
#define VBE_DISPI_ENABLED 0x01
#define VBE_DISPI_LFB_ENABLED 0x40
-static BXVGADevice* s_the;
+static AK::Singleton<BXVGADevice> s_the;
+
+void BXVGADevice::initialize()
+{
+ s_the.ensure_instance();
+}
BXVGADevice& BXVGADevice::the()
{
@@ -67,7 +73,6 @@ BXVGADevice::BXVGADevice()
: BlockDevice(29, 0)
{
- s_the = this;
m_framebuffer_address = PhysicalAddress(find_framebuffer_address());
set_safe_resolution();
}