summaryrefslogtreecommitdiff
path: root/Kernel/Interrupts
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/Interrupts
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/Interrupts')
-rw-r--r--Kernel/Interrupts/APIC.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/Kernel/Interrupts/APIC.cpp b/Kernel/Interrupts/APIC.cpp
index 32fc0045de..23af86d11f 100644
--- a/Kernel/Interrupts/APIC.cpp
+++ b/Kernel/Interrupts/APIC.cpp
@@ -26,6 +26,7 @@
#include <AK/Assertions.h>
#include <AK/Memory.h>
+#include <AK/Singleton.h>
#include <AK/StringView.h>
#include <AK/Types.h>
#include <Kernel/ACPI/Parser.h>
@@ -68,7 +69,7 @@
namespace Kernel {
-static APIC* s_apic;
+static AK::Singleton<APIC> s_apic;
class APICIPIInterruptHandler final : public GenericInterruptHandler {
public:
@@ -132,7 +133,7 @@ private:
bool APIC::initialized()
{
- return (s_apic != nullptr);
+ return s_apic.is_initialized();
}
APIC& APIC::the()
@@ -144,7 +145,7 @@ APIC& APIC::the()
void APIC::initialize()
{
ASSERT(!APIC::initialized());
- s_apic = new APIC();
+ s_apic.ensure_instance();
}
PhysicalAddress APIC::get_base()