mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 17:27:35 +00:00
Kernel: Make self-contained locking smart pointers their own classes
Until now, our kernel has reimplemented a number of AK classes to provide automatic internal locking: - RefPtr - NonnullRefPtr - WeakPtr - Weakable This patch renames the Kernel classes so that they can coexist with the original AK classes: - RefPtr => LockRefPtr - NonnullRefPtr => NonnullLockRefPtr - WeakPtr => LockWeakPtr - Weakable => LockWeakable The goal here is to eventually get rid of the Lock* classes in favor of using external locking.
This commit is contained in:
parent
e475263113
commit
11eee67b85
360 changed files with 1703 additions and 1672 deletions
|
@ -9,12 +9,12 @@
|
|||
#include <AK/Function.h>
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Arch/x86/IRQController.h>
|
||||
#include <Kernel/Firmware/ACPI/Definitions.h>
|
||||
#include <Kernel/Interrupts/GenericInterruptHandler.h>
|
||||
#include <Kernel/Interrupts/IOAPIC.h>
|
||||
#include <Kernel/Library/LockRefPtr.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
|
@ -52,8 +52,8 @@ public:
|
|||
virtual void switch_to_ioapic_mode();
|
||||
|
||||
bool smp_enabled() const { return m_smp_enabled; }
|
||||
RefPtr<IRQController> get_responsible_irq_controller(u8 interrupt_vector);
|
||||
RefPtr<IRQController> get_responsible_irq_controller(IRQControllerType controller_type, u8 interrupt_vector);
|
||||
LockRefPtr<IRQController> get_responsible_irq_controller(u8 interrupt_vector);
|
||||
LockRefPtr<IRQController> get_responsible_irq_controller(IRQControllerType controller_type, u8 interrupt_vector);
|
||||
|
||||
Vector<ISAInterruptOverrideMetadata> const& isa_overrides() const { return m_isa_interrupt_overrides; }
|
||||
|
||||
|
@ -71,7 +71,7 @@ private:
|
|||
PhysicalAddress search_for_madt();
|
||||
void locate_apic_data();
|
||||
bool m_smp_enabled { false };
|
||||
Vector<RefPtr<IRQController>> m_interrupt_controllers;
|
||||
Vector<LockRefPtr<IRQController>> m_interrupt_controllers;
|
||||
Vector<ISAInterruptOverrideMetadata> m_isa_interrupt_overrides;
|
||||
Vector<PCIInterruptOverrideMetadata> m_pci_interrupt_overrides;
|
||||
PhysicalAddress m_madt;
|
||||
|
|
|
@ -98,7 +98,7 @@ u8 InterruptManagement::get_irq_vector(u8 mapped_interrupt_vector)
|
|||
return mapped_interrupt_vector;
|
||||
}
|
||||
|
||||
RefPtr<IRQController> InterruptManagement::get_responsible_irq_controller(IRQControllerType controller_type, u8 interrupt_vector)
|
||||
LockRefPtr<IRQController> InterruptManagement::get_responsible_irq_controller(IRQControllerType controller_type, u8 interrupt_vector)
|
||||
{
|
||||
for (auto& irq_controller : m_interrupt_controllers) {
|
||||
if (irq_controller->gsi_base() <= interrupt_vector && irq_controller->type() == controller_type)
|
||||
|
@ -107,7 +107,7 @@ RefPtr<IRQController> InterruptManagement::get_responsible_irq_controller(IRQCon
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
RefPtr<IRQController> InterruptManagement::get_responsible_irq_controller(u8 interrupt_vector)
|
||||
LockRefPtr<IRQController> InterruptManagement::get_responsible_irq_controller(u8 interrupt_vector)
|
||||
{
|
||||
if (m_interrupt_controllers.size() == 1 && m_interrupt_controllers[0]->type() == IRQControllerType::i8259) {
|
||||
return m_interrupt_controllers[0];
|
||||
|
@ -143,7 +143,7 @@ UNMAP_AFTER_INIT void InterruptManagement::switch_to_pic_mode()
|
|||
dmesgln("Interrupts: Switch to Legacy PIC mode");
|
||||
InterruptDisabler disabler;
|
||||
m_smp_enabled = false;
|
||||
m_interrupt_controllers[0] = adopt_ref(*new PIC());
|
||||
m_interrupt_controllers[0] = adopt_lock_ref(*new PIC());
|
||||
SpuriousInterruptHandler::initialize(7);
|
||||
SpuriousInterruptHandler::initialize(15);
|
||||
for (auto& irq_controller : m_interrupt_controllers) {
|
||||
|
@ -204,7 +204,7 @@ UNMAP_AFTER_INIT void InterruptManagement::locate_apic_data()
|
|||
|
||||
int irq_controller_count = 0;
|
||||
if (madt->flags & PCAT_COMPAT_FLAG) {
|
||||
m_interrupt_controllers[0] = adopt_ref(*new PIC());
|
||||
m_interrupt_controllers[0] = adopt_lock_ref(*new PIC());
|
||||
irq_controller_count++;
|
||||
}
|
||||
size_t entry_index = 0;
|
||||
|
@ -216,7 +216,7 @@ UNMAP_AFTER_INIT void InterruptManagement::locate_apic_data()
|
|||
auto* ioapic_entry = (const ACPI::Structures::MADTEntries::IOAPIC*)madt_entry;
|
||||
dbgln("IOAPIC found @ MADT entry {}, MMIO Registers @ {}", entry_index, PhysicalAddress(ioapic_entry->ioapic_address));
|
||||
m_interrupt_controllers.resize(1 + irq_controller_count);
|
||||
m_interrupt_controllers[irq_controller_count] = adopt_ref(*new IOAPIC(PhysicalAddress(ioapic_entry->ioapic_address), ioapic_entry->gsi_base));
|
||||
m_interrupt_controllers[irq_controller_count] = adopt_lock_ref(*new IOAPIC(PhysicalAddress(ioapic_entry->ioapic_address), ioapic_entry->gsi_base));
|
||||
irq_controller_count++;
|
||||
}
|
||||
if (madt_entry->type == (u8)ACPI::Structures::MADTEntryType::InterruptSourceOverride) {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/Format.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
#include <Kernel/Arch/Interrupts.h>
|
||||
|
@ -349,21 +350,21 @@ void page_fault_handler(TrapFrame* trap)
|
|||
constexpr FlatPtr nonnullrefptr_scrub_pattern = explode_byte(NONNULLREFPTR_SCRUB_BYTE);
|
||||
constexpr FlatPtr ownptr_scrub_pattern = explode_byte(OWNPTR_SCRUB_BYTE);
|
||||
constexpr FlatPtr nonnullownptr_scrub_pattern = explode_byte(NONNULLOWNPTR_SCRUB_BYTE);
|
||||
constexpr FlatPtr threadsaferefptr_scrub_pattern = explode_byte(THREADSAFEREFPTR_SCRUB_BYTE);
|
||||
constexpr FlatPtr threadsafenonnullrefptr_scrub_pattern = explode_byte(THREADSAFENONNULLREFPTR_SCRUB_BYTE);
|
||||
constexpr FlatPtr lockrefptr_scrub_pattern = explode_byte(LOCKREFPTR_SCRUB_BYTE);
|
||||
constexpr FlatPtr nonnulllockrefptr_scrub_pattern = explode_byte(NONNULLLOCKREFPTR_SCRUB_BYTE);
|
||||
|
||||
if ((fault_address & 0xffff0000) == (refptr_scrub_pattern & 0xffff0000)) {
|
||||
dbgln("Note: Address {} looks like it may be a recently destroyed RefPtr", VirtualAddress(fault_address));
|
||||
dbgln("Note: Address {} looks like it may be a recently destroyed LockRefPtr", VirtualAddress(fault_address));
|
||||
} else if ((fault_address & 0xffff0000) == (nonnullrefptr_scrub_pattern & 0xffff0000)) {
|
||||
dbgln("Note: Address {} looks like it may be a recently destroyed NonnullRefPtr", VirtualAddress(fault_address));
|
||||
dbgln("Note: Address {} looks like it may be a recently destroyed NonnullLockRefPtr", VirtualAddress(fault_address));
|
||||
} else if ((fault_address & 0xffff0000) == (ownptr_scrub_pattern & 0xffff0000)) {
|
||||
dbgln("Note: Address {} looks like it may be a recently destroyed OwnPtr", VirtualAddress(fault_address));
|
||||
} else if ((fault_address & 0xffff0000) == (nonnullownptr_scrub_pattern & 0xffff0000)) {
|
||||
dbgln("Note: Address {} looks like it may be a recently destroyed NonnullOwnPtr", VirtualAddress(fault_address));
|
||||
} else if ((fault_address & 0xffff0000) == (threadsaferefptr_scrub_pattern & 0xffff0000)) {
|
||||
dbgln("Note: Address {} looks like it may be a recently destroyed ThreadSafeRefPtr", VirtualAddress(fault_address));
|
||||
} else if ((fault_address & 0xffff0000) == (threadsafenonnullrefptr_scrub_pattern & 0xffff0000)) {
|
||||
dbgln("Note: Address {} looks like it may be a recently destroyed ThreadSafeNonnullRefPtr", VirtualAddress(fault_address));
|
||||
} else if ((fault_address & 0xffff0000) == (lockrefptr_scrub_pattern & 0xffff0000)) {
|
||||
dbgln("Note: Address {} looks like it may be a recently destroyed LockRefPtr", VirtualAddress(fault_address));
|
||||
} else if ((fault_address & 0xffff0000) == (nonnulllockrefptr_scrub_pattern & 0xffff0000)) {
|
||||
dbgln("Note: Address {} looks like it may be a recently destroyed NonnullLockRefPtr", VirtualAddress(fault_address));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ void PageDirectory::deregister_page_directory(PageDirectory* directory)
|
|||
cr3_map().remove(directory->cr3());
|
||||
}
|
||||
|
||||
RefPtr<PageDirectory> PageDirectory::find_current()
|
||||
LockRefPtr<PageDirectory> PageDirectory::find_current()
|
||||
{
|
||||
SpinlockLocker lock(s_mm_lock);
|
||||
return cr3_map().find(read_cr3());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue