summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/ACPI/DynamicParser.h2
-rw-r--r--Kernel/ACPI/MultiProcessorParser.cpp6
-rw-r--r--Kernel/ACPI/Parser.cpp42
-rw-r--r--Kernel/Arch/PC/BIOS.cpp28
-rw-r--r--Kernel/Arch/PC/BIOS.h4
-rw-r--r--Kernel/Arch/x86/PageDirectory.h6
-rw-r--r--Kernel/Arch/x86/Processor.h6
-rw-r--r--Kernel/Arch/x86/common/Processor.cpp14
-rw-r--r--Kernel/Bus/PCI/MMIOAccess.cpp8
-rw-r--r--Kernel/Bus/PCI/MMIOAccess.h2
-rw-r--r--Kernel/Bus/PCI/WindowedMMIOAccess.cpp4
-rw-r--r--Kernel/Bus/PCI/WindowedMMIOAccess.h2
-rw-r--r--Kernel/Bus/USB/UHCIController.cpp12
-rw-r--r--Kernel/Bus/USB/UHCIController.h6
-rw-r--r--Kernel/Bus/USB/USBTransfer.cpp6
-rw-r--r--Kernel/Bus/USB/USBTransfer.h14
-rw-r--r--Kernel/Devices/KCOVDevice.cpp2
-rw-r--r--Kernel/Devices/KCOVDevice.h2
-rw-r--r--Kernel/Devices/KCOVInstance.cpp6
-rw-r--r--Kernel/Devices/KCOVInstance.h4
-rw-r--r--Kernel/Devices/MemoryDevice.cpp4
-rw-r--r--Kernel/Devices/MemoryDevice.h4
-rw-r--r--Kernel/Devices/SB16.cpp4
-rw-r--r--Kernel/Devices/SB16.h2
-rw-r--r--Kernel/DoubleBuffer.cpp2
-rw-r--r--Kernel/FileSystem/AnonymousFile.cpp4
-rw-r--r--Kernel/FileSystem/AnonymousFile.h8
-rw-r--r--Kernel/FileSystem/Ext2FileSystem.cpp4
-rw-r--r--Kernel/FileSystem/File.cpp2
-rw-r--r--Kernel/FileSystem/File.h2
-rw-r--r--Kernel/FileSystem/FileDescription.cpp2
-rw-r--r--Kernel/FileSystem/FileDescription.h2
-rw-r--r--Kernel/FileSystem/Inode.cpp4
-rw-r--r--Kernel/FileSystem/Inode.h6
-rw-r--r--Kernel/FileSystem/InodeFile.cpp8
-rw-r--r--Kernel/FileSystem/InodeFile.h2
-rw-r--r--Kernel/FileSystem/Plan9FileSystem.cpp2
-rw-r--r--Kernel/Forward.h28
-rw-r--r--Kernel/FutexQueue.h8
-rw-r--r--Kernel/GlobalProcessExposed.cpp2
-rw-r--r--Kernel/Graphics/Bochs/GraphicsAdapter.cpp2
-rw-r--r--Kernel/Graphics/Bochs/GraphicsAdapter.h2
-rw-r--r--Kernel/Graphics/Console/ContiguousFramebufferConsole.cpp4
-rw-r--r--Kernel/Graphics/Console/ContiguousFramebufferConsole.h2
-rw-r--r--Kernel/Graphics/Console/VGAConsole.cpp2
-rw-r--r--Kernel/Graphics/Console/VGAConsole.h2
-rw-r--r--Kernel/Graphics/FramebufferDevice.cpp28
-rw-r--r--Kernel/Graphics/FramebufferDevice.h14
-rw-r--r--Kernel/Graphics/GraphicsManagement.cpp2
-rw-r--r--Kernel/Graphics/GraphicsManagement.h2
-rw-r--r--Kernel/Graphics/Intel/NativeGraphicsAdapter.cpp2
-rw-r--r--Kernel/Graphics/Intel/NativeGraphicsAdapter.h2
-rw-r--r--Kernel/Graphics/VirtIOGPU/FrameBufferDevice.cpp10
-rw-r--r--Kernel/Graphics/VirtIOGPU/FrameBufferDevice.h10
-rw-r--r--Kernel/Graphics/VirtIOGPU/GPU.cpp4
-rw-r--r--Kernel/Graphics/VirtIOGPU/GPU.h4
-rw-r--r--Kernel/Heap/SlabAllocator.cpp2
-rw-r--r--Kernel/Heap/kmalloc.cpp12
-rw-r--r--Kernel/Interrupts/APIC.cpp10
-rw-r--r--Kernel/Interrupts/APIC.h2
-rw-r--r--Kernel/Interrupts/IOAPIC.cpp2
-rw-r--r--Kernel/Interrupts/IOAPIC.h2
-rw-r--r--Kernel/Interrupts/InterruptManagement.cpp2
-rw-r--r--Kernel/KBuffer.h30
-rw-r--r--Kernel/KBufferBuilder.cpp4
-rw-r--r--Kernel/Memory/AnonymousVMObject.cpp2
-rw-r--r--Kernel/Memory/AnonymousVMObject.h2
-rw-r--r--Kernel/Memory/InodeVMObject.cpp2
-rw-r--r--Kernel/Memory/InodeVMObject.h2
-rw-r--r--Kernel/Memory/MappedROM.h2
-rw-r--r--Kernel/Memory/MemoryManager.cpp4
-rw-r--r--Kernel/Memory/MemoryManager.h4
-rw-r--r--Kernel/Memory/PageDirectory.cpp2
-rw-r--r--Kernel/Memory/PageDirectory.h2
-rw-r--r--Kernel/Memory/PhysicalPage.cpp2
-rw-r--r--Kernel/Memory/PhysicalPage.h2
-rw-r--r--Kernel/Memory/PhysicalRegion.cpp2
-rw-r--r--Kernel/Memory/PhysicalRegion.h2
-rw-r--r--Kernel/Memory/PhysicalZone.cpp2
-rw-r--r--Kernel/Memory/PhysicalZone.h2
-rw-r--r--Kernel/Memory/PrivateInodeVMObject.cpp2
-rw-r--r--Kernel/Memory/PrivateInodeVMObject.h2
-rw-r--r--Kernel/Memory/Range.cpp2
-rw-r--r--Kernel/Memory/Range.h6
-rw-r--r--Kernel/Memory/RangeAllocator.cpp2
-rw-r--r--Kernel/Memory/RangeAllocator.h4
-rw-r--r--Kernel/Memory/Region.cpp2
-rw-r--r--Kernel/Memory/Region.h2
-rw-r--r--Kernel/Memory/RingBuffer.cpp2
-rw-r--r--Kernel/Memory/RingBuffer.h4
-rw-r--r--Kernel/Memory/ScatterGatherList.cpp2
-rw-r--r--Kernel/Memory/ScatterGatherList.h2
-rw-r--r--Kernel/Memory/SharedInodeVMObject.cpp2
-rw-r--r--Kernel/Memory/SharedInodeVMObject.h2
-rw-r--r--Kernel/Memory/Space.cpp2
-rw-r--r--Kernel/Memory/Space.h2
-rw-r--r--Kernel/Memory/TypedMapping.h2
-rw-r--r--Kernel/Memory/VMObject.cpp4
-rw-r--r--Kernel/Memory/VMObject.h4
-rw-r--r--Kernel/Net/E1000ENetworkAdapter.cpp2
-rw-r--r--Kernel/Net/E1000NetworkAdapter.cpp10
-rw-r--r--Kernel/Net/E1000NetworkAdapter.h10
-rw-r--r--Kernel/Net/NetworkAdapter.cpp4
-rw-r--r--Kernel/Net/NetworkTask.cpp2
-rw-r--r--Kernel/Net/RTL8139NetworkAdapter.cpp6
-rw-r--r--Kernel/Net/RTL8139NetworkAdapter.h6
-rw-r--r--Kernel/Net/RTL8168NetworkAdapter.cpp8
-rw-r--r--Kernel/Net/RTL8168NetworkAdapter.h8
-rw-r--r--Kernel/PerformanceEventBuffer.cpp2
-rw-r--r--Kernel/PerformanceManager.h4
-rw-r--r--Kernel/Process.cpp6
-rw-r--r--Kernel/Process.h8
-rw-r--r--Kernel/ProcessSpecificExposed.cpp4
-rw-r--r--Kernel/Scheduler.cpp4
-rw-r--r--Kernel/StdLib.cpp34
-rw-r--r--Kernel/Storage/AHCIController.cpp4
-rw-r--r--Kernel/Storage/AHCIController.h4
-rw-r--r--Kernel/Storage/AHCIPort.cpp16
-rw-r--r--Kernel/Storage/AHCIPort.h12
-rw-r--r--Kernel/Storage/AHCIPortHandler.h2
-rw-r--r--Kernel/Storage/BMIDEChannel.cpp4
-rw-r--r--Kernel/Storage/BMIDEChannel.h8
-rw-r--r--Kernel/Storage/RamdiskController.cpp8
-rw-r--r--Kernel/Storage/RamdiskDevice.cpp4
-rw-r--r--Kernel/Storage/RamdiskDevice.h6
-rw-r--r--Kernel/Syscalls/anon_create.cpp2
-rw-r--r--Kernel/Syscalls/execve.cpp40
-rw-r--r--Kernel/Syscalls/fork.cpp2
-rw-r--r--Kernel/Syscalls/futex.cpp20
-rw-r--r--Kernel/Syscalls/get_stack_bounds.cpp2
-rw-r--r--Kernel/Syscalls/mmap.cpp60
-rw-r--r--Kernel/Syscalls/module.cpp2
-rw-r--r--Kernel/Syscalls/ptrace.cpp8
-rw-r--r--Kernel/Syscalls/purge.cpp6
-rw-r--r--Kernel/TTY/VirtualConsole.cpp4
-rw-r--r--Kernel/TTY/VirtualConsole.h2
-rw-r--r--Kernel/Thread.cpp10
-rw-r--r--Kernel/Thread.h10
-rw-r--r--Kernel/Time/HPET.cpp12
-rw-r--r--Kernel/Time/HPET.h2
-rw-r--r--Kernel/UserOrKernelBuffer.cpp12
-rw-r--r--Kernel/UserOrKernelBuffer.h6
-rw-r--r--Kernel/VirtIO/VirtIO.cpp2
-rw-r--r--Kernel/VirtIO/VirtIO.h2
-rw-r--r--Kernel/VirtIO/VirtIOConsole.cpp4
-rw-r--r--Kernel/VirtIO/VirtIOConsole.h4
-rw-r--r--Kernel/VirtIO/VirtIOConsolePort.cpp4
-rw-r--r--Kernel/VirtIO/VirtIOConsolePort.h4
-rw-r--r--Kernel/VirtIO/VirtIOQueue.cpp6
-rw-r--r--Kernel/VirtIO/VirtIOQueue.h2
-rw-r--r--Kernel/VirtIO/VirtIORNG.cpp2
-rw-r--r--Kernel/VirtIO/VirtIORNG.h2
-rw-r--r--Kernel/init.cpp4
153 files changed, 473 insertions, 467 deletions
diff --git a/Kernel/ACPI/DynamicParser.h b/Kernel/ACPI/DynamicParser.h
index ecbb0829c1..35693c336e 100644
--- a/Kernel/ACPI/DynamicParser.h
+++ b/Kernel/ACPI/DynamicParser.h
@@ -37,7 +37,7 @@ private:
// ^IRQHandler
virtual bool handle_irq(const RegisterState&) override;
- OwnPtr<Region> m_acpi_namespace;
+ OwnPtr<Memory::Region> m_acpi_namespace;
};
}
diff --git a/Kernel/ACPI/MultiProcessorParser.cpp b/Kernel/ACPI/MultiProcessorParser.cpp
index 4e765acb39..bc9df20526 100644
--- a/Kernel/ACPI/MultiProcessorParser.cpp
+++ b/Kernel/ACPI/MultiProcessorParser.cpp
@@ -36,15 +36,15 @@ UNMAP_AFTER_INIT MultiProcessorParser::MultiProcessorParser(PhysicalAddress floa
UNMAP_AFTER_INIT void MultiProcessorParser::parse_floating_pointer_data()
{
- auto floating_pointer = map_typed<MultiProcessor::FloatingPointer>(m_floating_pointer);
+ auto floating_pointer = Memory::map_typed<MultiProcessor::FloatingPointer>(m_floating_pointer);
m_configuration_table = PhysicalAddress(floating_pointer->physical_address_ptr);
dbgln("Features {}, IMCR? {}", floating_pointer->feature_info[0], (floating_pointer->feature_info[0] & (1 << 7)));
}
UNMAP_AFTER_INIT void MultiProcessorParser::parse_configuration_table()
{
- auto configuration_table_length = map_typed<MultiProcessor::ConfigurationTableHeader>(m_configuration_table)->length;
- auto config_table = map_typed<MultiProcessor::ConfigurationTableHeader>(m_configuration_table, configuration_table_length);
+ auto configuration_table_length = Memory::map_typed<MultiProcessor::ConfigurationTableHeader>(m_configuration_table)->length;
+ auto config_table = Memory::map_typed<MultiProcessor::ConfigurationTableHeader>(m_configuration_table, configuration_table_length);
size_t entry_count = config_table->entry_count;
auto* entry = config_table->entries;
diff --git a/Kernel/ACPI/Parser.cpp b/Kernel/ACPI/Parser.cpp
index 5c903df14d..8e1404440d 100644
--- a/Kernel/ACPI/Parser.cpp
+++ b/Kernel/ACPI/Parser.cpp
@@ -48,7 +48,7 @@ KResultOr<size_t> ACPISysFSComponent::read_bytes(off_t offset, size_t count, Use
OwnPtr<KBuffer> ACPISysFSComponent::try_to_generate_buffer() const
{
- auto acpi_blob = map_typed<u8>((m_paddr), m_length);
+ auto acpi_blob = Memory::map_typed<u8>((m_paddr), m_length);
return KBuffer::try_create_with_bytes(Span<u8> { acpi_blob.ptr(), m_length });
}
@@ -80,10 +80,10 @@ UNMAP_AFTER_INIT ACPISysFSDirectory::ACPISysFSDirectory()
});
m_components = components;
- auto rsdp = map_typed<Structures::RSDPDescriptor20>(ACPI::Parser::the()->rsdp());
+ auto rsdp = Memory::map_typed<Structures::RSDPDescriptor20>(ACPI::Parser::the()->rsdp());
m_components.append(ACPISysFSComponent::create("RSDP", ACPI::Parser::the()->rsdp(), rsdp->base.revision == 0 ? sizeof(Structures::RSDPDescriptor) : rsdp->length));
- auto main_system_description_table = map_typed<Structures::SDTHeader>(ACPI::Parser::the()->main_system_description_table());
+ auto main_system_description_table = Memory::map_typed<Structures::SDTHeader>(ACPI::Parser::the()->main_system_description_table());
if (ACPI::Parser::the()->is_xsdt_supported()) {
m_components.append(ACPISysFSComponent::create("XSDT", ACPI::Parser::the()->main_system_description_table(), main_system_description_table->length));
} else {
@@ -94,7 +94,7 @@ UNMAP_AFTER_INIT ACPISysFSDirectory::ACPISysFSDirectory()
void Parser::enumerate_static_tables(Function<void(const StringView&, PhysicalAddress, size_t)> callback)
{
for (auto& p_table : m_sdt_pointers) {
- auto table = map_typed<Structures::SDTHeader>(p_table);
+ auto table = Memory::map_typed<Structures::SDTHeader>(p_table);
callback({ table->sig, 4 }, p_table, table->length);
}
}
@@ -122,7 +122,7 @@ UNMAP_AFTER_INIT PhysicalAddress Parser::find_table(const StringView& signature)
{
dbgln_if(ACPI_DEBUG, "ACPI: Calling Find Table method!");
for (auto p_sdt : m_sdt_pointers) {
- auto sdt = map_typed<Structures::SDTHeader>(p_sdt);
+ auto sdt = Memory::map_typed<Structures::SDTHeader>(p_sdt);
dbgln_if(ACPI_DEBUG, "ACPI: Examining Table @ {}", p_sdt);
if (!strncmp(sdt->sig, signature.characters_without_null_termination(), 4)) {
dbgln_if(ACPI_DEBUG, "ACPI: Found Table @ {}", p_sdt);
@@ -145,7 +145,7 @@ UNMAP_AFTER_INIT void Parser::init_fadt()
m_fadt = find_table("FACP");
VERIFY(!m_fadt.is_null());
- auto sdt = map_typed<const volatile Structures::FADT>(m_fadt);
+ auto sdt = Memory::map_typed<const volatile Structures::FADT>(m_fadt);
dbgln_if(ACPI_DEBUG, "ACPI: FADT @ V{}, {}", &sdt, m_fadt);
@@ -188,7 +188,7 @@ UNMAP_AFTER_INIT void Parser::init_fadt()
bool Parser::can_reboot()
{
- auto fadt = map_typed<Structures::FADT>(m_fadt);
+ auto fadt = Memory::map_typed<Structures::FADT>(m_fadt);
if (fadt->h.revision < 2)
return false;
return m_hardware_flags.reset_register_supported;
@@ -224,16 +224,16 @@ void Parser::access_generic_address(const Structures::GenericAddressStructure& s
dbgln("ACPI: Sending value {:x} to {}", value, PhysicalAddress(structure.address));
switch ((GenericAddressStructure::AccessSize)structure.access_size) {
case GenericAddressStructure::AccessSize::Byte:
- *map_typed<u8>(PhysicalAddress(structure.address)) = value;
+ *Memory::map_typed<u8>(PhysicalAddress(structure.address)) = value;
break;
case GenericAddressStructure::AccessSize::Word:
- *map_typed<u16>(PhysicalAddress(structure.address)) = value;
+ *Memory::map_typed<u16>(PhysicalAddress(structure.address)) = value;
break;
case GenericAddressStructure::AccessSize::DWord:
- *map_typed<u32>(PhysicalAddress(structure.address)) = value;
+ *Memory::map_typed<u32>(PhysicalAddress(structure.address)) = value;
break;
case GenericAddressStructure::AccessSize::QWord: {
- *map_typed<u64>(PhysicalAddress(structure.address)) = value;
+ *Memory::map_typed<u64>(PhysicalAddress(structure.address)) = value;
break;
}
default:
@@ -265,7 +265,7 @@ bool Parser::validate_reset_register()
{
// According to https://uefi.org/specs/ACPI/6.4/04_ACPI_Hardware_Specification/ACPI_Hardware_Specification.html#reset-register,
// the reset register can only be located in I/O bus, PCI bus or memory-mapped.
- auto fadt = map_typed<Structures::FADT>(m_fadt);
+ auto fadt = Memory::map_typed<Structures::FADT>(m_fadt);
return (fadt->reset_reg.address_space == (u8)GenericAddressStructure::AddressSpace::PCIConfigurationSpace || fadt->reset_reg.address_space == (u8)GenericAddressStructure::AddressSpace::SystemMemory || fadt->reset_reg.address_space == (u8)GenericAddressStructure::AddressSpace::SystemIO);
}
@@ -278,7 +278,7 @@ void Parser::try_acpi_reboot()
}
dbgln_if(ACPI_DEBUG, "ACPI: Rebooting, probing FADT ({})", m_fadt);
- auto fadt = map_typed<Structures::FADT>(m_fadt);
+ auto fadt = Memory::map_typed<Structures::FADT>(m_fadt);
VERIFY(validate_reset_register());
access_generic_address(fadt->reset_reg, fadt->reset_value);
Processor::halt();
@@ -293,14 +293,14 @@ size_t Parser::get_table_size(PhysicalAddress table_header)
{
InterruptDisabler disabler;
dbgln_if(ACPI_DEBUG, "ACPI: Checking SDT Length");
- return map_typed<Structures::SDTHeader>(table_header)->length;
+ return Memory::map_typed<Structures::SDTHeader>(table_header)->length;
}
u8 Parser::get_table_revision(PhysicalAddress table_header)
{
InterruptDisabler disabler;
dbgln_if(ACPI_DEBUG, "ACPI: Checking SDT Revision");
- return map_typed<Structures::SDTHeader>(table_header)->revision;
+ return Memory::map_typed<Structures::SDTHeader>(table_header)->revision;
}
UNMAP_AFTER_INIT void Parser::initialize_main_system_description_table()
@@ -310,7 +310,7 @@ UNMAP_AFTER_INIT void Parser::initialize_main_system_description_table()
auto length = get_table_size(m_main_system_description_table);
auto revision = get_table_revision(m_main_system_description_table);
- auto sdt = map_typed<Structures::SDTHeader>(m_main_system_description_table, length);
+ auto sdt = Memory::map_typed<Structures::SDTHeader>(m_main_system_description_table, length);
dmesgln("ACPI: Main Description Table valid? {}", validate_table(*sdt, length));
@@ -337,7 +337,7 @@ UNMAP_AFTER_INIT void Parser::initialize_main_system_description_table()
UNMAP_AFTER_INIT void Parser::locate_main_system_description_table()
{
- auto rsdp = map_typed<Structures::RSDPDescriptor20>(m_rsdp);
+ auto rsdp = Memory::map_typed<Structures::RSDPDescriptor20>(m_rsdp);
if (rsdp->base.revision == 0) {
m_xsdt_supported = false;
} else if (rsdp->base.revision >= 2) {
@@ -387,7 +387,7 @@ UNMAP_AFTER_INIT PhysicalAddress StaticParsing::find_table(PhysicalAddress rsdp_
// FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables.
VERIFY(signature.length() == 4);
- auto rsdp = map_typed<Structures::RSDPDescriptor20>(rsdp_address);
+ auto rsdp = Memory::map_typed<Structures::RSDPDescriptor20>(rsdp_address);
if (rsdp->base.revision == 0)
return search_table_in_rsdt(PhysicalAddress(rsdp->base.rsdt_ptr), signature);
@@ -405,7 +405,7 @@ UNMAP_AFTER_INIT static PhysicalAddress search_table_in_xsdt(PhysicalAddress xsd
// FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables.
VERIFY(signature.length() == 4);
- auto xsdt = map_typed<Structures::XSDT>(xsdt_address);
+ auto xsdt = Memory::map_typed<Structures::XSDT>(xsdt_address);
for (size_t i = 0; i < ((xsdt->h.length - sizeof(Structures::SDTHeader)) / sizeof(u64)); ++i) {
if (match_table_signature(PhysicalAddress((PhysicalPtr)xsdt->table_ptrs[i]), signature))
@@ -419,7 +419,7 @@ static bool match_table_signature(PhysicalAddress table_header, const StringView
// FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables.
VERIFY(signature.length() == 4);
- auto table = map_typed<Structures::RSDT>(table_header);
+ auto table = Memory::map_typed<Structures::RSDT>(table_header);
return !strncmp(table->h.sig, signature.characters_without_null_termination(), 4);
}
@@ -428,7 +428,7 @@ UNMAP_AFTER_INIT static PhysicalAddress search_table_in_rsdt(PhysicalAddress rsd
// FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables.
VERIFY(signature.length() == 4);
- auto rsdt = map_typed<Structures::RSDT>(rsdt_address);
+ auto rsdt = Memory::map_typed<Structures::RSDT>(rsdt_address);
for (u32 i = 0; i < ((rsdt->h.length - sizeof(Structures::SDTHeader)) / sizeof(u32)); i++) {
if (match_table_signature(PhysicalAddress((PhysicalPtr)rsdt->table_ptrs[i]), signature))
diff --git a/Kernel/Arch/PC/BIOS.cpp b/Kernel/Arch/PC/BIOS.cpp
index 784e773df3..2b95be03ad 100644
--- a/Kernel/Arch/PC/BIOS.cpp
+++ b/Kernel/Arch/PC/BIOS.cpp
@@ -53,7 +53,7 @@ UNMAP_AFTER_INIT DMIEntryPointExposedBlob::DMIEntryPointExposedBlob(PhysicalAddr
OwnPtr<KBuffer> DMIEntryPointExposedBlob::try_to_generate_buffer() const
{
- auto dmi_blob = map_typed<u8>((m_dmi_entry_point), m_dmi_entry_point_length);
+ auto dmi_blob = Memory::map_typed<u8>((m_dmi_entry_point), m_dmi_entry_point_length);
return KBuffer::try_create_with_bytes(Span<u8> { dmi_blob.ptr(), m_dmi_entry_point_length });
}
@@ -71,14 +71,14 @@ UNMAP_AFTER_INIT SMBIOSExposedTable::SMBIOSExposedTable(PhysicalAddress smbios_s
OwnPtr<KBuffer> SMBIOSExposedTable::try_to_generate_buffer() const
{
- auto dmi_blob = map_typed<u8>((m_smbios_structure_table), m_smbios_structure_table_length);
+ auto dmi_blob = Memory::map_typed<u8>((m_smbios_structure_table), m_smbios_structure_table_length);
return KBuffer::try_create_with_bytes(Span<u8> { dmi_blob.ptr(), m_smbios_structure_table_length });
}
UNMAP_AFTER_INIT void BIOSSysFSDirectory::set_dmi_64_bit_entry_initialization_values()
{
dbgln("BIOSSysFSDirectory: SMBIOS 64bit Entry point @ {}", m_dmi_entry_point);
- auto smbios_entry = map_typed<SMBIOS::EntryPoint64bit>(m_dmi_entry_point, SMBIOS_SEARCH_AREA_SIZE);
+ auto smbios_entry = Memory::map_typed<SMBIOS::EntryPoint64bit>(m_dmi_entry_point, SMBIOS_SEARCH_AREA_SIZE);
m_smbios_structure_table = PhysicalAddress(smbios_entry.ptr()->table_ptr);
m_dmi_entry_point_length = smbios_entry.ptr()->length;
m_smbios_structure_table_length = smbios_entry.ptr()->table_maximum_size;
@@ -87,7 +87,7 @@ UNMAP_AFTER_INIT void BIOSSysFSDirectory::set_dmi_64_bit_entry_initialization_va
UNMAP_AFTER_INIT void BIOSSysFSDirectory::set_dmi_32_bit_entry_initialization_values()
{
dbgln("BIOSSysFSDirectory: SMBIOS 32bit Entry point @ {}", m_dmi_entry_point);
- auto smbios_entry = map_typed<SMBIOS::EntryPoint32bit>(m_dmi_entry_point, SMBIOS_SEARCH_AREA_SIZE);
+ auto smbios_entry = Memory::map_typed<SMBIOS::EntryPoint32bit>(m_dmi_entry_point, SMBIOS_SEARCH_AREA_SIZE);
m_smbios_structure_table = PhysicalAddress(smbios_entry.ptr()->legacy_structure.smbios_table_ptr);
m_dmi_entry_point_length = smbios_entry.ptr()->length;
m_smbios_structure_table_length = smbios_entry.ptr()->legacy_structure.smboios_table_length;
@@ -130,7 +130,7 @@ UNMAP_AFTER_INIT void BIOSSysFSDirectory::initialize_dmi_exposer()
OwnPtr<KBuffer> BIOSSysFSDirectory::smbios_structure_table() const
{
- auto dmi_blob = map_typed<u8>(m_smbios_structure_table, m_smbios_structure_table_length);
+ auto dmi_blob = Memory::map_typed<u8>(m_smbios_structure_table, m_smbios_structure_table_length);
return KBuffer::try_create_with_bytes(Span<u8> { dmi_blob.ptr(), m_smbios_structure_table_length });
}
@@ -160,26 +160,26 @@ UNMAP_AFTER_INIT Optional<PhysicalAddress> BIOSSysFSDirectory::find_dmi_entry32b
return map_bios().find_chunk_starting_with("_SM_", 16);
}
-MappedROM map_bios()
+Memory::MappedROM map_bios()
{
- MappedROM mapping;
+ Memory::MappedROM mapping;
mapping.size = 128 * KiB;
mapping.paddr = PhysicalAddress(0xe0000);
- mapping.region = MM.allocate_kernel_region(mapping.paddr, page_round_up(mapping.size), {}, Region::Access::Read);
+ mapping.region = MM.allocate_kernel_region(mapping.paddr, Memory::page_round_up(mapping.size), {}, Memory::Region::Access::Read);
return mapping;
}
-MappedROM map_ebda()
+Memory::MappedROM map_ebda()
{
- auto ebda_segment_ptr = map_typed<u16>(PhysicalAddress(0x40e));
- auto ebda_length_ptr_b0 = map_typed<u8>(PhysicalAddress(0x413));
- auto ebda_length_ptr_b1 = map_typed<u8>(PhysicalAddress(0x414));
+ auto ebda_segment_ptr = Memory::map_typed<u16>(PhysicalAddress(0x40e));
+ auto ebda_length_ptr_b0 = Memory::map_typed<u8>(PhysicalAddress(0x413));
+ auto ebda_length_ptr_b1 = Memory::map_typed<u8>(PhysicalAddress(0x414));
PhysicalAddress ebda_paddr(*ebda_segment_ptr << 4);
size_t ebda_size = (*ebda_length_ptr_b1 << 8) | *ebda_length_ptr_b0;
- MappedROM mapping;
- mapping.region = MM.allocate_kernel_region(ebda_paddr.page_base(), page_round_up(ebda_size), {}, Region::Access::Read);
+ Memory::MappedROM mapping;
+ mapping.region = MM.allocate_kernel_region(ebda_paddr.page_base(), Memory::page_round_up(ebda_size), {}, Memory::Region::Access::Read);
mapping.offset = ebda_paddr.offset_in_page();
mapping.size = ebda_size;
mapping.paddr = ebda_paddr;
diff --git a/Kernel/Arch/PC/BIOS.h b/Kernel/Arch/PC/BIOS.h
index 54ad1f1aa0..e251d817a5 100644
--- a/Kernel/Arch/PC/BIOS.h
+++ b/Kernel/Arch/PC/BIOS.h
@@ -55,8 +55,8 @@ struct [[gnu::packed]] EntryPoint64bit {
namespace Kernel {
-MappedROM map_bios();
-MappedROM map_ebda();
+Memory::MappedROM map_bios();
+Memory::MappedROM map_ebda();
class BIOSSysFSComponent : public SysFSComponent {
public:
diff --git a/Kernel/Arch/x86/PageDirectory.h b/Kernel/Arch/x86/PageDirectory.h
index c33c06f93a..f965e600b2 100644
--- a/Kernel/Arch/x86/PageDirectory.h
+++ b/Kernel/Arch/x86/PageDirectory.h
@@ -8,13 +8,11 @@
#include <AK/Badge.h>
#include <AK/Types.h>
+#include <Kernel/Forward.h>
#include <Kernel/PhysicalAddress.h>
namespace Kernel {
-class PageDirectory;
-class PageTableEntry;
-
class PageDirectoryEntry {
public:
PhysicalPtr page_table_base() const { return PhysicalAddress::physical_page_base(m_raw); }
@@ -28,7 +26,7 @@ public:
void clear() { m_raw = 0; }
u64 raw() const { return m_raw; }
- void copy_from(Badge<PageDirectory>, const PageDirectoryEntry& other) { m_raw = other.m_raw; }
+ void copy_from(Badge<Memory::PageDirectory>, const PageDirectoryEntry& other) { m_raw = other.m_raw; }
enum Flags {
Present = 1 << 0,
diff --git a/Kernel/Arch/x86/Processor.h b/Kernel/Arch/x86/Processor.h
index 7a11445649..beaf4ec122 100644
--- a/Kernel/Arch/x86/Processor.h
+++ b/Kernel/Arch/x86/Processor.h
@@ -57,7 +57,7 @@ struct ProcessorMessage {
ProcessorMessage* next; // only valid while in the pool
alignas(CallbackFunction) u8 callback_storage[sizeof(CallbackFunction)];
struct {
- const PageDirectory* page_directory;
+ Memory::PageDirectory const* page_directory;
u8* ptr;
size_t page_count;
} flush_tlb;
@@ -211,7 +211,7 @@ public:
}
static void flush_tlb_local(VirtualAddress vaddr, size_t page_count);
- static void flush_tlb(const PageDirectory*, VirtualAddress, size_t);
+ static void flush_tlb(Memory::PageDirectory const*, VirtualAddress, size_t);
Descriptor& get_gdt_entry(u16 selector);
void flush_gdt();
@@ -391,7 +391,7 @@ public:
bool smp_process_pending_messages();
static void smp_unicast(u32 cpu, Function<void()>, bool async);
- static void smp_broadcast_flush_tlb(const PageDirectory*, VirtualAddress, size_t);
+ static void smp_broadcast_flush_tlb(Memory::PageDirectory const*, VirtualAddress, size_t);
static u32 smp_wake_n_idle_processors(u32 wake_count);
static void deferred_call_queue(Function<void()> callback);
diff --git a/Kernel/Arch/x86/common/Processor.cpp b/Kernel/Arch/x86/common/Processor.cpp
index e626d4d211..a15cfb32a4 100644
--- a/Kernel/Arch/x86/common/Processor.cpp
+++ b/Kernel/Arch/x86/common/Processor.cpp
@@ -469,7 +469,7 @@ Vector<FlatPtr> Processor::capture_stack_trace(Thread& thread, size_t max_frames
if (max_frames != 0 && count > max_frames)
break;
- if (is_user_range(VirtualAddress(stack_ptr), sizeof(FlatPtr) * 2)) {
+ if (Memory::is_user_range(VirtualAddress(stack_ptr), sizeof(FlatPtr) * 2)) {
if (!copy_from_user(&retaddr, &((FlatPtr*)stack_ptr)[1]) || !retaddr)
break;
stack_trace.append(retaddr);
@@ -545,7 +545,7 @@ Vector<FlatPtr> Processor::capture_stack_trace(Thread& thread, size_t max_frames
ProcessPagingScope paging_scope(thread.process());
auto& regs = thread.regs();
FlatPtr* stack_top = reinterpret_cast<FlatPtr*>(regs.sp());
- if (is_user_range(VirtualAddress(stack_top), sizeof(FlatPtr))) {
+ if (Memory::is_user_range(VirtualAddress(stack_top), sizeof(FlatPtr))) {
if (!copy_from_user(&frame_ptr, &((FlatPtr*)stack_top)[0]))
frame_ptr = 0;
} else {
@@ -657,9 +657,9 @@ void Processor::flush_tlb_local(VirtualAddress vaddr, size_t page_count)
}
}
-void Processor::flush_tlb(const PageDirectory* page_directory, VirtualAddress vaddr, size_t page_count)
+void Processor::flush_tlb(Memory::PageDirectory const* page_directory, VirtualAddress vaddr, size_t page_count)
{
- if (s_smp_enabled && (!is_user_address(vaddr) || Process::current()->thread_count() > 1))
+ if (s_smp_enabled && (!Memory::is_user_address(vaddr) || Process::current()->thread_count() > 1))
smp_broadcast_flush_tlb(page_directory, vaddr, page_count);
else
flush_tlb_local(vaddr, page_count);
@@ -818,9 +818,9 @@ bool Processor::smp_process_pending_messages()
msg->invoke_callback();
break;
case ProcessorMessage::FlushTlb:
- if (is_user_address(VirtualAddress(msg->flush_tlb.ptr))) {
+ if (Memory::is_user_address(VirtualAddress(msg->flush_tlb.ptr))) {
// We assume that we don't cross into kernel land!
- VERIFY(is_user_range(VirtualAddress(msg->flush_tlb.ptr), msg->flush_tlb.page_count * PAGE_SIZE));
+ VERIFY(Memory::is_user_range(VirtualAddress(msg->flush_tlb.ptr), msg->flush_tlb.page_count * PAGE_SIZE));
if (read_cr3() != msg->flush_tlb.page_directory->cr3()) {
// This processor isn't using this page directory right now, we can ignore this request
dbgln_if(SMP_DEBUG, "SMP[{}]: No need to flush {} pages at {}", id(), msg->flush_tlb.page_count, VirtualAddress(msg->flush_tlb.ptr));
@@ -949,7 +949,7 @@ void Processor::smp_unicast(u32 cpu, Function<void()> callback, bool async)
smp_unicast_message(cpu, msg, async);
}
-void Processor::smp_broadcast_flush_tlb(const PageDirectory* page_directory, VirtualAddress vaddr, size_t page_count)
+void Processor::smp_broadcast_flush_tlb(Memory::PageDirectory const* page_directory, VirtualAddress vaddr, size_t page_count)
{
auto& msg = smp_get_from_pool();
msg.async = false;
diff --git a/Kernel/Bus/PCI/MMIOAccess.cpp b/Kernel/Bus/PCI/MMIOAccess.cpp
index 6811f4df8c..e5475fafda 100644
--- a/Kernel/Bus/PCI/MMIOAccess.cpp
+++ b/Kernel/Bus/PCI/MMIOAccess.cpp
@@ -57,7 +57,7 @@ UNMAP_AFTER_INIT MMIOAccess::MMIOAccess(PhysicalAddress p_mcfg)
{
dmesgln("PCI: Using MMIO for PCI configuration space access");
- auto checkup_region = MM.allocate_kernel_region(p_mcfg.page_base(), (PAGE_SIZE * 2), "PCI MCFG Checkup", Region::Access::Read | Region::Access::Write);
+ auto checkup_region = MM.allocate_kernel_region(p_mcfg.page_base(), (PAGE_SIZE * 2), "PCI MCFG Checkup", Memory::Region::Access::Read | Memory::Region::Access::Write);
dbgln_if(PCI_DEBUG, "PCI: Checking MCFG Table length to choose the correct mapping size");
auto* sdt = (ACPI::Structures::SDTHeader*)checkup_region->vaddr().offset(p_mcfg.offset_in_page()).as_ptr();
u32 length = sdt->length;
@@ -66,7 +66,7 @@ UNMAP_AFTER_INIT MMIOAccess::MMIOAccess(PhysicalAddress p_mcfg)
dbgln("PCI: MCFG, length: {}, revision: {}", length, revision);
checkup_region->unmap();
- auto mcfg_region = MM.allocate_kernel_region(p_mcfg.page_base(), page_round_up(length) + PAGE_SIZE, "PCI Parsing MCFG", Region::Access::Read | Region::Access::Write);
+ auto mcfg_region = MM.allocate_kernel_region(p_mcfg.page_base(), Memory::page_round_up(length) + PAGE_SIZE, "PCI Parsing MCFG", Memory::Region::Access::Read | Memory::Region::Access::Write);
auto& mcfg = *(ACPI::Structures::MCFG*)mcfg_region->vaddr().offset(p_mcfg.offset_in_page()).as_ptr();
dbgln_if(PCI_DEBUG, "PCI: Checking MCFG @ {}, {}", VirtualAddress(&mcfg), PhysicalAddress(p_mcfg.get()));
@@ -89,7 +89,7 @@ UNMAP_AFTER_INIT MMIOAccess::MMIOAccess(PhysicalAddress p_mcfg)
// PCI::PhysicalID objects to the vector, because get_capabilities calls
// PCI::read16 which will need this region to be mapped.
u8 start_bus = m_segments.get(0).value().get_start_bus();
- m_mapped_region = MM.allocate_kernel_region(determine_memory_mapped_bus_region(0, start_bus), MEMORY_RANGE_PER_BUS, "PCI ECAM", Region::Access::Read | Region::Access::Write);
+ m_mapped_region = MM.allocate_kernel_region(determine_memory_mapped_bus_region(0, start_bus), MEMORY_RANGE_PER_BUS, "PCI ECAM", Memory::Region::Access::Read | Memory::Region::Access::Write);
m_mapped_bus = start_bus;
dbgln_if(PCI_DEBUG, "PCI: First PCI ECAM Mapped region for starting bus {} @ {} {}", start_bus, m_mapped_region->vaddr(), m_mapped_region->physical_page(0)->paddr());
@@ -102,7 +102,7 @@ void MMIOAccess::map_bus_region(u32 segment, u8 bus)
VERIFY(m_access_lock.is_locked());
if (m_mapped_bus == bus)
return;
- m_mapped_region = MM.allocate_kernel_region(determine_memory_mapped_bus_region(segment, bus), MEMORY_RANGE_PER_BUS, "PCI ECAM", Region::Access::Read | Region::Access::Write);
+ m_mapped_region = MM.allocate_kernel_region(determine_memory_mapped_bus_region(segment, bus), MEMORY_RANGE_PER_BUS, "PCI ECAM", Memory::Region::Access::Read | Memory::Region::Access::Write);
m_mapped_bus = bus;
dbgln_if(PCI_DEBUG, "PCI: New PCI ECAM Mapped region for bus {} @ {} {}", bus, m_mapped_region->vaddr(), m_mapped_region->physical_page(0)->paddr());
}
diff --git a/Kernel/Bus/PCI/MMIOAccess.h b/Kernel/Bus/PCI/MMIOAccess.h
index fd94b4b65c..c110161f84 100644
--- a/Kernel/Bus/PCI/MMIOAccess.h
+++ b/Kernel/Bus/PCI/MMIOAccess.h
@@ -46,7 +46,7 @@ private:
VirtualAddress get_device_configuration_space(Address address);
SpinLock<u8> m_access_lock;
u8 m_mapped_bus { 0 };
- OwnPtr<Region> m_mapped_region;
+ OwnPtr<Memory::Region> m_mapped_region;
protected:
explicit MMIOAccess(PhysicalAddress mcfg);
diff --git a/Kernel/Bus/PCI/WindowedMMIOAccess.cpp b/Kernel/Bus/PCI/WindowedMMIOAccess.cpp
index 9f7af0feb5..6b84d18893 100644
--- a/Kernel/Bus/PCI/WindowedMMIOAccess.cpp
+++ b/Kernel/Bus/PCI/WindowedMMIOAccess.cpp
@@ -18,12 +18,12 @@ namespace PCI {
UNMAP_AFTER_INIT DeviceConfigurationSpaceMapping::DeviceConfigurationSpaceMapping(Address device_address, const MMIOAccess::MMIOSegment& mmio_segment)
: m_device_address(device_address)
- , m_mapped_region(MM.allocate_kernel_region(page_round_up(PCI_MMIO_CONFIG_SPACE_SIZE), "PCI MMIO Device Access", Region::Access::Read | Region::Access::Write).release_nonnull())
+ , m_mapped_region(MM.allocate_kernel_region(Memory::page_round_up(PCI_MMIO_CONFIG_SPACE_SIZE), "PCI MMIO Device Access", Memory::Region::Access::Read | Memory::Region::Access::Write).release_nonnull())
{
PhysicalAddress segment_lower_addr = mmio_segment.get_paddr();
PhysicalAddress device_physical_mmio_space = segment_lower_addr.offset(
PCI_MMIO_CONFIG_SPACE_SIZE * m_device_address.function() + (PCI_MMIO_CONFIG_SPACE_SIZE * PCI_MAX_FUNCTIONS_PER_DEVICE) * m_device_address.device() + (PCI_MMIO_CONFIG_SPACE_SIZE * PCI_MAX_FUNCTIONS_PER_DEVICE * PCI_MAX_DEVICES_PER_BUS) * (m_device_address.bus() - mmio_segment.get_start_bus()));
- m_mapped_region->physical_page_slot(0) = PhysicalPage::create(device_physical_mmio_space, MayReturnToFreeList::No);
+ m_mapped_region->physical_page_slot(0) = Memory::PhysicalPage::create(device_physical_mmio_space, Memory::MayReturnToFreeList::No);
m_mapped_region->remap();
}
diff --git a/Kernel/Bus/PCI/WindowedMMIOAccess.h b/Kernel/Bus/PCI/WindowedMMIOAccess.h
index 4c7b2789d4..0f4a51b5b7 100644
--- a/Kernel/Bus/PCI/WindowedMMIOAccess.h
+++ b/Kernel/Bus/PCI/WindowedMMIOAccess.h
@@ -30,7 +30,7 @@ public:
private:
Address m_device_address;
- NonnullOwnPtr<Region> m_mapped_region;
+ NonnullOwnPtr<Memory::Region> m_mapped_region;
};
class WindowedMMIOAccess final : public MMIOAccess {
diff --git a/Kernel/Bus/USB/UHCIController.cpp b/Kernel/Bus/USB/UHCIController.cpp
index e1032254c7..98e544c61f 100644
--- a/Kernel/Bus/USB/UHCIController.cpp
+++ b/Kernel/Bus/USB/UHCIController.cpp
@@ -289,8 +289,8 @@ void UHCIController::reset()
}
// Let's allocate the physical page for the Frame List (which is 4KiB aligned)
- auto framelist_vmobj = AnonymousVMObject::try_create_physically_contiguous_with_size(PAGE_SIZE);
- m_framelist = MemoryManager::the().allocate_kernel_region_with_vmobject(*framelist_vmobj, PAGE_SIZE, "UHCI Framelist", Region::Access::Write);
+ auto framelist_vmobj = Memory::AnonymousVMObject::try_create_physically_contiguous_with_size(PAGE_SIZE);
+ m_framelist = MM.allocate_kernel_region_with_vmobject(*framelist_vmobj, PAGE_SIZE, "UHCI Framelist", Memory::Region::Access::Write);
dbgln("UHCI: Allocated framelist at physical address {}", m_framelist->physical_page(0)->paddr());
dbgln("UHCI: Framelist is at virtual address {}", m_framelist->vaddr());
write_sofmod(64); // 1mS frame time
@@ -311,8 +311,8 @@ UNMAP_AFTER_INIT void UHCIController::create_structures()
{
// Let's allocate memory for both the QH and TD pools
// First the QH pool and all of the Interrupt QH's
- auto qh_pool_vmobject = AnonymousVMObject::try_create_physically_contiguous_with_size(2 * PAGE_SIZE);
- m_qh_pool = MemoryManager::the().allocate_kernel_region_with_vmobject(*qh_pool_vmobject, 2 * PAGE_SIZE, "UHCI Queue Head Pool", Region::Access::Write);
+ auto qh_pool_vmobject = Memory::AnonymousVMObject::try_create_physically_contiguous_with_size(2 * PAGE_SIZE);
+ m_qh_pool = MM.allocate_kernel_region_with_vmobject(*qh_pool_vmobject, 2 * PAGE_SIZE, "UHCI Queue Head Pool", Memory::Region::Access::Write);
memset(m_qh_pool->vaddr().as_ptr(), 0, 2 * PAGE_SIZE); // Zero out both pages
// Let's populate our free qh list (so we have some we can allocate later on)
@@ -331,8 +331,8 @@ UNMAP_AFTER_INIT void UHCIController::create_structures()
m_dummy_qh = allocate_queue_head();
// Now the Transfer Descriptor pool
- auto td_pool_vmobject = AnonymousVMObject::try_create_physically_contiguous_with_size(2 * PAGE_SIZE);
- m_td_pool = MemoryManager::the().allocate_kernel_region_with_vmobject(*td_pool_vmobject, 2 * PAGE_SIZE, "UHCI Transfer Descriptor Pool", Region::Access::Write);
+ auto td_pool_vmobject = Memory::AnonymousVMObject::try_create_physically_contiguous_with_size(2 * PAGE_SIZE);
+ m_td_pool = MM.allocate_kernel_region_with_vmobject(*td_pool_vmobject, 2 * PAGE_SIZE, "UHCI Transfer Descriptor Pool", Memory::Region::Access::Write);
memset(m_td_pool->vaddr().as_ptr(), 0, 2 * PAGE_SIZE);
// Set up the Isochronous Transfer Descriptor list
diff --git a/Kernel/Bus/USB/UHCIController.h b/Kernel/Bus/USB/UHCIController.h
index 7adecd67b4..8594c0f024 100644
--- a/Kernel/Bus/USB/UHCIController.h
+++ b/Kernel/Bus/USB/UHCIController.h
@@ -90,9 +90,9 @@ private:
QueueHead* m_bulk_qh;
QueueHead* m_dummy_qh; // Needed for PIIX4 hack
- OwnPtr<Region> m_framelist;
- OwnPtr<Region> m_qh_pool;
- OwnPtr<Region> m_td_pool;
+ OwnPtr<Memory::Region> m_framelist;
+ OwnPtr<Memory::Region> m_qh_pool;
+ OwnPtr<Memory::Region> m_td_pool;
Array<RefPtr<USB::Device>, 2> m_devices; // Devices connected to the root ports (of which there are two)
};
diff --git a/Kernel/Bus/USB/USBTransfer.cpp b/Kernel/Bus/USB/USBTransfer.cpp
index 51f26c91a8..e3e5f0f035 100644
--- a/Kernel/Bus/USB/USBTransfer.cpp
+++ b/Kernel/Bus/USB/USBTransfer.cpp
@@ -11,20 +11,20 @@ namespace Kernel::USB {
RefPtr<Transfer> Transfer::try_create(Pipe& pipe, u16 len)
{
- auto vmobject = AnonymousVMObject::try_create_physically_contiguous_with_size(PAGE_SIZE);
+ auto vmobject = Memory::AnonymousVMObject::try_create_physically_contiguous_with_size(PAGE_SIZE);
if (!vmobject)
return nullptr;
return AK::try_create<Transfer>(pipe, len, *vmobject);
}
-Transfer::Transfer(Pipe& pipe, u16 len, AnonymousVMObject& vmobject)
+Transfer::Transfer(Pipe& pipe, u16 len, Memory::AnonymousVMObject& vmobject)
: m_pipe(pipe)
, m_transfer_data_size(len)
{
// Initialize data buffer for transfer
// This will definitely need to be refactored in the future, I doubt this will scale well...
- m_data_buffer = MemoryManager::the().allocate_kernel_region_with_vmobject(vmobject, PAGE_SIZE, "USB Transfer Buffer", Region::Access::Read | Region::Access::Write);
+ m_data_buffer = MM.allocate_kernel_region_with_vmobject(vmobject, PAGE_SIZE, "USB Transfer Buffer", Memory::Region::Access::Read | Memory::Region::Access::Write);
}
Transfer::~Transfer()
diff --git a/Kernel/Bus/USB/USBTransfer.h b/Kernel/Bus/USB/USBTransfer.h
index 796407c206..9afead95e9 100644
--- a/Kernel/Bus/USB/USBTransfer.h
+++ b/Kernel/Bus/USB/USBTransfer.h
@@ -23,7 +23,7 @@ public:
public:
Transfer() = delete;
- Transfer(Pipe& pipe, u16 len, AnonymousVMObject&);
+ Transfer(Pipe& pipe, u16 len, Memory::AnonymousVMObject&);
~Transfer();
void set_setup_packet(const USBRequestData& request);
@@ -41,11 +41,11 @@ public:
bool error_occurred() const { return m_error_occurred; }
private:
- Pipe& m_pipe; // Pipe that initiated this transfer
- USBRequestData m_request; // USB request
- OwnPtr<Region> m_data_buffer; // DMA Data buffer for transaction
- u16 m_transfer_data_size { 0 }; // Size of the transfer's data stage
- bool m_complete { false }; // Has this transfer been completed?
- bool m_error_occurred { false }; // Did an error occur during this transfer?
+ Pipe& m_pipe; // Pipe that initiated this transfer
+ USBRequestData m_request; // USB request
+ OwnPtr<Memory::Region> m_data_buffer; // DMA Data buffer for transaction
+ u16 m_transfer_data_size { 0 }; // Size of the transfer's data stage
+ bool m_complete { false }; // Has this transfer been completed?
+ bool m_error_occurred { false }; // Did an error occur during this transfer?
};
}
diff --git a/Kernel/Devices/KCOVDevice.cpp b/Kernel/Devices/KCOVDevice.cpp
index 85e9e97d9a..1b69f02960 100644
--- a/Kernel/Devices/KCOVDevice.cpp
+++ b/Kernel/Devices/KCOVDevice.cpp
@@ -129,7 +129,7 @@ KResult KCOVDevice::ioctl(FileDescription&, unsigned request, Userspace<void*> a
return return_value;
}
-KResultOr<Region*> KCOVDevice::mmap(Process& process, FileDescription&, const Range& range, u64 offset, int prot, bool shared)
+KResultOr<Memory::Region*> KCOVDevice::mmap(Process& process, FileDescription&, Memory::Range const& range, u64 offset, int prot, bool shared)
{
auto pid = process.pid();
auto maybe_kcov_instance = proc_instance->get(pid);
diff --git a/Kernel/Devices/KCOVDevice.h b/Kernel/Devices/KCOVDevice.h
index dcfcfd6968..ba2dd92bec 100644
--- a/Kernel/Devices/KCOVDevice.h
+++ b/Kernel/Devices/KCOVDevice.h
@@ -22,7 +22,7 @@ public:
static void free_process();
// ^File
- KResultOr<Region*> mmap(Process&, FileDescription&, const Range&, u64 offset, int prot, bool shared) override;
+ KResultOr<Memory::Region*> mmap(Process&, FileDescription&, Memory::Range const&, u64 offset, int prot, bool shared) override;
KResultOr<NonnullRefPtr<FileDescription>> open(int options) override;
// ^Device
diff --git a/Kernel/Devices/KCOVInstance.cpp b/Kernel/Devices/KCOVInstance.cpp
index 098504826f..3e734c893e 100644
--- a/Kernel/Devices/KCOVInstance.cpp
+++ b/Kernel/Devices/KCOVInstance.cpp
@@ -22,20 +22,20 @@ KResult KCOVInstance::buffer_allocate(size_t buffer_size_in_entries)
// first entry contains index of last PC
this->m_buffer_size_in_entries = buffer_size_in_entries - 1;
- this->m_buffer_size_in_bytes = page_round_up(buffer_size_in_entries * KCOV_ENTRY_SIZE);
+ this->m_buffer_size_in_bytes = Memory::page_round_up(buffer_size_in_entries * KCOV_ENTRY_SIZE);
// one single vmobject is representing the buffer
// - we allocate one kernel region using that vmobject
// - when an mmap call comes in, we allocate another userspace region,
// backed by the same vmobject
- this->vmobject = AnonymousVMObject::try_create_with_size(
+ this->vmobject = Memory::AnonymousVMObject::try_create_with_size(
this->m_buffer_size_in_bytes, AllocationStrategy::AllocateNow);
if (!this->vmobject)
return ENOMEM;
this->m_kernel_region = MM.allocate_kernel_region_with_vmobject(
*this->vmobject, this->m_buffer_size_in_bytes, String::formatted("kcov_{}", this->m_pid),
- Region::Access::Read | Region::Access::Write);
+ Memory::Region::Access::Read | Memory::Region::Access::Write);
if (!this->m_kernel_region)
return ENOMEM;
diff --git a/Kernel/Devices/KCOVInstance.h b/Kernel/Devices/KCOVInstance.h
index 3a585af192..cb56d1250b 100644
--- a/Kernel/Devices/KCOVInstance.h
+++ b/Kernel/Devices/KCOVInstance.h
@@ -42,7 +42,7 @@ public:
TRACING = 2,
} state;
- RefPtr<AnonymousVMObject> vmobject;
+ RefPtr<Memory::AnonymousVMObject> vmobject;
private:
ProcessID m_pid = { 0 };
@@ -51,7 +51,7 @@ private:
kcov_pc_t* m_buffer = { nullptr };
// Here to ensure it's not garbage collected at the end of open()
- OwnPtr<Region> m_kernel_region;
+ OwnPtr<Memory::Region> m_kernel_region;
};
}
diff --git a/Kernel/Devices/MemoryDevice.cpp b/Kernel/Devices/MemoryDevice.cpp
index 5b03516994..8ce29f1345 100644
--- a/Kernel/Devices/MemoryDevice.cpp
+++ b/Kernel/Devices/MemoryDevice.cpp
@@ -37,7 +37,7 @@ void MemoryDevice::did_seek(FileDescription&, off_t)
TODO();
}
-KResultOr<Region*> MemoryDevice::mmap(Process& process, FileDescription&, const Range& range, u64 offset, int prot, bool shared)
+KResultOr<Memory::Region*> MemoryDevice::mmap(Process& process, FileDescription&, Memory::Range const& range, u64 offset, int prot, bool shared)
{
auto viewed_address = PhysicalAddress(offset);
@@ -47,7 +47,7 @@ KResultOr<Region*> MemoryDevice::mmap(Process& process, FileDescription&, const
return EINVAL;
}
- auto vmobject = AnonymousVMObject::try_create_for_physical_range(viewed_address, range.size());
+ auto vmobject = Memory::AnonymousVMObject::try_create_for_physical_range(viewed_address, range.size());
if (!vmobject)
return ENOMEM;
dbgln("MemoryDevice: Mapped physical memory at {} for range of {} bytes", viewed_address, range.size());
diff --git a/Kernel/Devices/MemoryDevice.h b/Kernel/Devices/MemoryDevice.h
index cf5ff1f472..366453599c 100644
--- a/Kernel/Devices/MemoryDevice.h
+++ b/Kernel/Devices/MemoryDevice.h
@@ -19,7 +19,7 @@ public:
static NonnullRefPtr<MemoryDevice> must_create();
~MemoryDevice();
- virtual KResultOr<Region*> mmap(Process&, FileDescription&, const Range&, u64 offset, int prot, bool shared) override;
+ virtual KResultOr<Memory::Region*> mmap(Process&, FileDescription&, Memory::Range const&, u64 offset, int prot, bool shared) override;
// ^Device
virtual mode_t required_mode() const override { return 0660; }
@@ -36,7 +36,7 @@ private:
virtual void did_seek(FileDescription&, off_t) override;
- bool is_allowed_range(PhysicalAddress, const Range&) const;
+ bool is_allowed_range(PhysicalAddress, Memory::Range const&) const;
};
}
diff --git a/Kernel/Devices/SB16.cpp b/Kernel/Devices/SB16.cpp
index d495dc47ed..c390c19082 100644
--- a/Kernel/Devices/SB16.cpp
+++ b/Kernel/Devices/SB16.cpp
@@ -238,10 +238,10 @@ KResultOr<size_t> SB16::write(FileDescription&, u64, const UserOrKernelBuffer& d
if (!page)
return ENOMEM;
auto nonnull_page = page.release_nonnull();
- auto vmobject = AnonymousVMObject::try_create_with_physical_pages({ &nonnull_page, 1 });
+ auto vmobject = Memory::AnonymousVMObject::try_create_with_physical_pages({ &nonnull_page, 1 });
if (!vmobject)
return ENOMEM;
- m_dma_region = MM.allocate_kernel_region_with_vmobject(*vmobject, PAGE_SIZE, "SB16 DMA buffer", Region::Access::Write);
+ m_dma_region = MM.allocate_kernel_region_with_vmobject(*vmobject, PAGE_SIZE, "SB16 DMA buffer", Memory::Region::Access::Write);
if (!m_dma_region)
return ENOMEM;
}
diff --git a/Kernel/Devices/SB16.h b/Kernel/Devices/SB16.h
index 32b8c7712c..523d2d980a 100644
--- a/Kernel/Devices/SB16.h
+++ b/Kernel/Devices/SB16.h
@@ -55,7 +55,7 @@ private:
void set_irq_register(u8 irq_number);
void set_irq_line(u8 irq_number);
- OwnPtr<Region> m_dma_region;
+ OwnPtr<Memory::Region> m_dma_region;
int m_major_version { 0 };
WaitQueue m_irq_queue;
diff --git a/Kernel/DoubleBuffer.cpp b/Kernel/DoubleBuffer.cpp
index 3fe605713e..b5c11950e5 100644
--- a/Kernel/DoubleBuffer.cpp
+++ b/Kernel/DoubleBuffer.cpp
@@ -19,7 +19,7 @@ inline void DoubleBuffer::compute_lockfree_metadata()
OwnPtr<DoubleBuffer> DoubleBuffer::try_create(size_t capacity)
{
- auto storage = KBuffer::try_create_with_size(capacity * 2, Region::Access::Read | Region::Access::Write, "DoubleBuffer");
+ auto storage = KBuffer::try_create_with_size(capacity * 2, Memory::Region::Access::Read | Memory::Region::Access::Write, "DoubleBuffer");
if (!storage)
return {};
diff --git a/Kernel/FileSystem/AnonymousFile.cpp b/Kernel/FileSystem/AnonymousFile.cpp
index 580a5906f4..e21c329832 100644
--- a/Kernel/FileSystem/AnonymousFile.cpp
+++ b/Kernel/FileSystem/AnonymousFile.cpp
@@ -10,7 +10,7 @@
namespace Kernel {
-AnonymousFile::AnonymousFile(NonnullRefPtr<AnonymousVMObject> vmobject)
+AnonymousFile::AnonymousFile(NonnullRefPtr<Memory::AnonymousVMObject> vmobject)
: m_vmobject(move(vmobject))
{
}
@@ -19,7 +19,7 @@ AnonymousFile::~AnonymousFile()
{
}
-KResultOr<Region*> AnonymousFile::mmap(Process& process, FileDescription&, const Range& range, u64 offset, int prot, bool shared)
+KResultOr<Memory::Region*> AnonymousFile::mmap(Process& process, FileDescription&, Memory::Range const& range, u64 offset, int prot, bool shared)
{
if (offset != 0)
return EINVAL;
diff --git a/Kernel/FileSystem/AnonymousFile.h b/Kernel/FileSystem/AnonymousFile.h
index 361143ba67..e6b25fc15e 100644
--- a/Kernel/FileSystem/AnonymousFile.h
+++ b/Kernel/FileSystem/AnonymousFile.h
@@ -13,14 +13,14 @@ namespace Kernel {
class AnonymousFile final : public File {
public:
- static RefPtr<AnonymousFile> create(NonnullRefPtr<AnonymousVMObject> vmobject)
+ static RefPtr<AnonymousFile> create(NonnullRefPtr<Memory::AnonymousVMObject> vmobject)
{
return adopt_ref_if_nonnull(new (nothrow) AnonymousFile(move(vmobject)));
}
virtual ~AnonymousFile() override;
- virtual KResultOr<Region*> mmap(Process&, FileDescription&, const Range&, u64 offset, int prot, bool shared) override;
+ virtual KResultOr<Memory::Region*> mmap(Process&, FileDescription&, Memory::Range const&, u64 offset, int prot, bool shared) override;
private:
virtual StringView class_name() const override { return "AnonymousFile"; }
@@ -30,9 +30,9 @@ private:
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override { return ENOTSUP; }
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return ENOTSUP; }
- explicit AnonymousFile(NonnullRefPtr<AnonymousVMObject>);
+ explicit AnonymousFile(NonnullRefPtr<Memory::AnonymousVMObject>);
- NonnullRefPtr<AnonymousVMObject> m_vmobject;
+ NonnullRefPtr<Memory::AnonymousVMObject> m_vmobject;
};
}
diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp
index 2bd8ddb7ce..00f20c085b 100644
--- a/Kernel/FileSystem/Ext2FileSystem.cpp
+++ b/Kernel/FileSystem/Ext2FileSystem.cpp
@@ -132,7 +132,7 @@ bool Ext2FS::initialize()
auto blocks_to_read = ceil_div(m_block_group_count * sizeof(ext2_group_desc), block_size());
BlockIndex first_block_of_bgdt = block_size() == 1024 ? 2 : 1;
- m_cached_group_descriptor_table = KBuffer::try_create_with_size(block_size() * blocks_to_read, Region::Access::Read | Region::Access::Write, "Ext2FS: Block group descriptors");
+ m_cached_group_descriptor_table = KBuffer::try_create_with_size(block_size() * blocks_to_read, Memory::Region::Access::Read | Memory::Region::Access::Write, "Ext2FS: Block group descriptors");
if (!m_cached_group_descriptor_table) {
dbgln("Ext2FS: Failed to allocate memory for group descriptor table");
return false;
@@ -1505,7 +1505,7 @@ KResultOr<Ext2FS::CachedBitmap*> Ext2FS::get_bitmap_block(BlockIndex bitmap_bloc
return cached_bitmap;
}
- auto block = KBuffer::try_create_with_size(block_size(), Region::Access::Read | Region::Access::Write, "Ext2FS: Cached bitmap block");
+ auto block = KBuffer::try_create_with_size(block_size(), Memory::Region::Access::Read | Memory::Region::Access::Write, "Ext2FS: Cached bitmap block");
if (!block)
return ENOMEM;
auto buffer = UserOrKernelBuffer::for_kernel_buffer(block->data());
diff --git a/Kernel/FileSystem/File.cpp b/Kernel/FileSystem/File.cpp
index 355b6ed56d..07226edbcf 100644
--- a/Kernel/FileSystem/File.cpp
+++ b/Kernel/FileSystem/File.cpp
@@ -40,7 +40,7 @@ KResult File::ioctl(FileDescription&, unsigned, Userspace<void*>)
return ENOTTY;
}
-KResultOr<Region*> File::mmap(Process&, FileDescription&, const Range&, u64, int, bool)
+KResultOr<Memory::Region*> File::mmap(Process&, FileDescription&, Memory::Range const&, u64, int, bool)
{
return ENODEV;
}
diff --git a/Kernel/FileSystem/File.h b/Kernel/FileSystem/File.h
index 6410d1e1cb..0e719f291f 100644
--- a/Kernel/FileSystem/File.h
+++ b/Kernel/FileSystem/File.h
@@ -88,7 +88,7 @@ public:
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) = 0;
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) = 0;
virtual KResult ioctl(FileDescription&, unsigned request, Userspace<void*> arg);
- virtual KResultOr<Region*> mmap(Process&, FileDescription&, const Range&, u64 offset, int prot, bool shared);
+ virtual KResultOr<Memory::Region*> mmap(Process&, FileDescription&, Memory::Range const&, u64 offset, int prot, bool shared);
virtual KResult stat(::stat&) const { return EBADF; }
virtual String absolute_path(const FileDescription&) const = 0;
diff --git a/Kernel/FileSystem/FileDescription.cpp b/Kernel/FileSystem/FileDescription.cpp
index 6d795f81bc..19822a8309 100644
--- a/Kernel/FileSystem/FileDescription.cpp
+++ b/Kernel/FileSystem/FileDescription.cpp
@@ -380,7 +380,7 @@ InodeMetadata FileDescription::metadata() const
return {};
}
-KResultOr<Region*> FileDescription::mmap(Process& process, const Range& range, u64 offset, int prot, bool shared)
+KResultOr<Memory::Region*> FileDescription::mmap(Process& process, Memory::Range const& range, u64 offset, int prot, bool shared)
{
MutexLocker locker(m_lock);
return m_file->mmap(process, *this, range, offset, prot, shared);
diff --git a/Kernel/FileSystem/FileDescription.h b/Kernel/FileSystem/FileDescription.h
index c22e8a9d22..e1a05d293d 100644
--- a/Kernel/FileSystem/FileDescription.h
+++ b/Kernel/FileSystem/FileDescription.h
@@ -96,7 +96,7 @@ public:
Custody* custody() { return m_custody.ptr(); }
const Custody* custody() const { return m_custody.ptr(); }
- KResultOr<Region*> mmap(Process&, const Range&, u64 offset, int prot, bool shared);
+ KResultOr<Memory::Region*> mmap(Process&, Memory::Range const&, u64 offset, int prot, bool shared);
bool is_blocking() const { return m_is_blocking; }
void set_blocking(bool b) { m_is_blocking = b; }
diff --git a/Kernel/FileSystem/Inode.cpp b/Kernel/FileSystem/Inode.cpp
index 37b20b1c66..9db65ef1dd 100644
--- a/Kernel/FileSystem/Inode.cpp
+++ b/Kernel/FileSystem/Inode.cpp
@@ -141,7 +141,7 @@ KResult Inode::decrement_link_count()
return ENOTIMPL;
}
-void Inode::set_shared_vmobject(SharedInodeVMObject& vmobject)
+void Inode::set_shared_vmobject(Memory::SharedInodeVMObject& vmobject)
{
MutexLocker locker(m_inode_lock);
m_shared_vmobject = vmobject;
@@ -271,7 +271,7 @@ KResult Inode::prepare_to_write_data()
return KSuccess;
}
-RefPtr<SharedInodeVMObject> Inode::shared_vmobject() const
+RefPtr<Memory::SharedInodeVMObject> Inode::shared_vmobject() const
{
MutexLocker locker(m_inode_lock);
return m_shared_vmobject.strong_ref();
diff --git a/Kernel/FileSystem/Inode.h b/Kernel/FileSystem/Inode.h
index f35a27e71b..1b21564ad5 100644
--- a/Kernel/FileSystem/Inode.h
+++ b/Kernel/FileSystem/Inode.h
@@ -84,8 +84,8 @@ public:
void will_be_destroyed();
- void set_shared_vmobject(SharedInodeVMObject&);
- RefPtr<SharedInodeVMObject> shared_vmobject() const;
+ void set_shared_vmobject(Memory::SharedInodeVMObject&);
+ RefPtr<Memory::SharedInodeVMObject> shared_vmobject() const;
static void sync();
@@ -116,7 +116,7 @@ protected:
private:
FileSystem& m_file_system;
InodeIndex m_index { 0 };
- WeakPtr<SharedInodeVMObject> m_shared_vmobject;
+ WeakPtr<Memory::SharedInodeVMObject> m_shared_vmobject;
RefPtr<LocalSocket> m_socket;
HashTable<InodeWatcher*> m_watchers;
bool m_metadata_dirty { false };
diff --git a/Kernel/FileSystem/InodeFile.cpp b/Kernel/FileSystem/InodeFile.cpp
index 876224b165..9b40bc730d 100644
--- a/Kernel/FileSystem/InodeFile.cpp
+++ b/Kernel/FileSystem/InodeFile.cpp
@@ -93,14 +93,14 @@ KResult InodeFile::ioctl(FileDescription& description, unsigned request, Userspa
}
}
-KResultOr<Region*> InodeFile::mmap(Process& process, FileDescription& description, const Range& range, u64 offset, int prot, bool shared)
+KResultOr<Memory::Region*> InodeFile::mmap(Process& process, FileDescription& description, Memory::Range const& range, u64 offset, int prot, bool shared)
{
// FIXME: If PROT_EXEC, check that the underlying file system isn't mounted noexec.
- RefPtr<InodeVMObject> vmobject;
+ RefPtr<Memory::InodeVMObject> vmobject;
if (shared)
- vmobject = SharedInodeVMObject::try_create_with_inode(inode());
+ vmobject = Memory::SharedInodeVMObject::try_create_with_inode(inode());
else
- vmobject = PrivateInodeVMObject::try_create_with_inode(inode());
+ vmobject = Memory::PrivateInodeVMObject::try_create_with_inode(inode());
if (!vmobject)
return ENOMEM;
return process.space().allocate_region_with_vmobject(range, vmobject.release_nonnull(), offset, description.absolute_path(), prot, shared);
diff --git a/Kernel/FileSystem/InodeFile.h b/Kernel/FileSystem/InodeFile.h
index 5fe928a21d..2a20673593 100644
--- a/Kernel/FileSystem/InodeFile.h
+++ b/Kernel/FileSystem/InodeFile.h
@@ -33,7 +33,7 @@ public:
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override;
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
virtual KResult ioctl(FileDescription&, unsigned request, Userspace<void*> arg) override;
- virtual KResultOr<Region*> mmap(Process&, FileDescription&, const Range&, u64 offset, int prot, bool shared) override;
+ virtual KResultOr<Memory::Region*> mmap(Process&, FileDescription&, Memory::Range const&, u64 offset, int prot, bool shared) override;
virtual KResult stat(::stat& buffer) const override { return inode().metadata().stat(buffer); }
virtual String absolute_path(const FileDescription&) const override;
diff --git a/Kernel/FileSystem/Plan9FileSystem.cpp b/Kernel/FileSystem/Plan9FileSystem.cpp
index b21c81143a..6b73dc98c9 100644
--- a/Kernel/FileSystem/Plan9FileSystem.cpp
+++ b/Kernel/FileSystem/Plan9FileSystem.cpp
@@ -560,7 +560,7 @@ KResult Plan9FS::read_and_dispatch_one_message()
if (result.is_error())
return result;
- auto buffer = KBuffer::try_create_with_size(header.size, Region::Access::Read | Region::Access::Write);
+ auto buffer = KBuffer::try_create_with_size(header.size, Memory::Region::Access::Read | Memory::Region::Access::Write);
if (!buffer)
return ENOMEM;
// Copy the already read header into the buffer.
diff --git a/Kernel/Forward.h b/Kernel/Forward.h
index 7d8330ce74..e7047343e8 100644
--- a/Kernel/Forward.h
+++ b/Kernel/Forward.h
@@ -31,15 +31,10 @@ class InodeWatcher;
class KBuffer;
class KResult;
class LocalSocket;
-class MemoryManager;
class Mutex;
-class MappedROM;
class MasterPTY;
class Mount;
-class PageDirectory;
class PerformanceEventBuffer;
-class PhysicalPage;
-class PhysicalRegion;
class ProcFS;
class ProcFSDirectoryInode;
class ProcFSExposedComponent;
@@ -51,15 +46,10 @@ class ProcFSSystemBoolean;
class ProcFSSystemDirectory;
class Process;
class ProcessGroup;
-class Range;
-class RangeAllocator;
class RecursiveSpinLock;
-class Region;
class Scheduler;
class SchedulerData;
-class SharedInodeVMObject;
class Socket;
-class Space;
class SysFS;
class SysFSDirectory;
class SysFSBusDirectory;
@@ -71,11 +61,27 @@ class Thread;
class ThreadTracer;
class UDPSocket;
class UserOrKernelBuffer;
-class VMObject;
class VirtualFileSystem;
class WaitQueue;
class WorkQueue;
+namespace Memory {
+class AnonymousVMObject;
+class InodeVMObject;
+class MappedROM;
+class MemoryManager;
+class PageDirectory;
+class PhysicalPage;
+class PhysicalRegion;
+class PrivateInodeVMObject;
+class Range;
+class RangeAllocator;
+class Region;
+class SharedInodeVMObject;
+class Space;
+class VMObject;
+}
+
template<typename BaseType>
class SpinLock;
template<typename LockType>
diff --git a/Kernel/FutexQueue.h b/Kernel/FutexQueue.h
index cc8a144f99..5cad5e3b18 100644
--- a/Kernel/FutexQueue.h
+++ b/Kernel/FutexQueue.h
@@ -16,9 +16,9 @@ namespace Kernel {
class FutexQueue : public Thread::BlockCondition
, public RefCounted<FutexQueue>
- , public VMObjectDeletedHandler {
+ , public Memory::VMObjectDeletedHandler {
public:
- FutexQueue(FlatPtr user_address_or_offset, VMObject* vmobject = nullptr);
+ FutexQueue(FlatPtr user_address_or_offset, Memory::VMObject* vmobject = nullptr);
virtual ~FutexQueue();
u32 wake_n_requeue(u32, const Function<FutexQueue*()>&, u32, bool&, bool&);
@@ -31,7 +31,7 @@ public:
return Thread::current()->block<Thread::FutexBlocker>(timeout, *this, forward<Args>(args)...);
}
- virtual void vmobject_deleted(VMObject&) override;
+ virtual void vmobject_deleted(Memory::VMObject&) override;
bool queue_imminent_wait();
void did_remove();
@@ -51,7 +51,7 @@ private:
// For private futexes we just use the user space address.
// But for global futexes we use the offset into the VMObject
const FlatPtr m_user_address_or_offset;
- WeakPtr<VMObject> m_vmobject;
+ WeakPtr<Memory::VMObject> m_vmobject;
const bool m_is_global;
size_t m_imminent_waits { 1 }; // We only create this object if we're going to be waiting, so start out with 1
bool m_was_removed { false };
diff --git a/Kernel/GlobalProcessExposed.cpp b/Kernel/GlobalProcessExposed.cpp
index 5fc351509d..87c9e936df 100644
--- a/Kernel/GlobalProcessExposed.cpp
+++ b/Kernel/GlobalProcessExposed.cpp
@@ -376,7 +376,7 @@ private:
kmalloc_stats stats;
get_kmalloc_stats(stats);
- auto system_memory = MemoryManager::the().get_system_memory_info();
+ auto system_memory = MM.get_system_memory_info();
JsonObjectSerializer<KBufferBuilder> json { builder };
json.add("kmalloc_allocated", stats.bytes_allocated);
diff --git a/Kernel/Graphics/Bochs/GraphicsAdapter.cpp b/Kernel/Graphics/Bochs/GraphicsAdapter.cpp
index 0c6df23049..baacaf12cf 100644
--- a/Kernel/Graphics/Bochs/GraphicsAdapter.cpp
+++ b/Kernel/Graphics/Bochs/GraphicsAdapter.cpp
@@ -65,7 +65,7 @@ UNMAP_AFTER_INIT NonnullRefPtr<BochsGraphicsAdapter> BochsGraphicsAdapter::initi
UNMAP_AFTER_INIT BochsGraphicsAdapter::BochsGraphicsAdapter(PCI::Address pci_address)
: PCI::DeviceController(pci_address)
, m_mmio_registers(PCI::get_BAR2(pci_address) & 0xfffffff0)
- , m_registers(map_typed_writable<BochsDisplayMMIORegisters volatile>(m_mmio_registers))
+ , m_registers(Memory::map_typed_writable<BochsDisplayMMIORegisters volatile>(m_mmio_registers))
{
// We assume safe resolutio is 1024x768x32
m_framebuffer_console = Graphics::ContiguousFramebufferConsole::initialize(PhysicalAddress(PCI::get_BAR0(pci_address) & 0xfffffff0), 1024, 768, 1024 * sizeof(u32));
diff --git a/Kernel/Graphics/Bochs/GraphicsAdapter.h b/Kernel/Graphics/Bochs/GraphicsAdapter.h
index a10c3f1fb4..e8fddd3f59 100644
--- a/Kernel/Graphics/Bochs/GraphicsAdapter.h
+++ b/Kernel/Graphics/Bochs/GraphicsAdapter.h
@@ -57,7 +57,7 @@ private:
void set_y_offset(size_t);
PhysicalAddress m_mmio_registers;
- TypedMapping<BochsDisplayMMIORegisters volatile> m_registers;
+ Memory::TypedMapping<BochsDisplayMMIORegisters volatile> m_registers;
RefPtr<FramebufferDevice> m_framebuffer_device;
RefPtr<Graphics::GenericFramebufferConsole> m_framebuffer_console;
SpinLock<u8> m_console_mode_switch_lock;
diff --git a/Kernel/Graphics/Console/ContiguousFramebufferConsole.cpp b/Kernel/Graphics/Console/ContiguousFramebufferConsole.cpp
index 12a7cd45ca..fe74603f72 100644
--- a/Kernel/Graphics/Console/ContiguousFramebufferConsole.cpp
+++ b/Kernel/Graphics/Console/ContiguousFramebufferConsole.cpp
@@ -27,8 +27,8 @@ void ContiguousFramebufferConsole::set_resolution(size_t width, size_t height, s
m_height = height;
m_pitch = pitch;
- dbgln("Framebuffer Console: taking {} bytes", page_round_up(pitch * height));
- m_framebuffer_region = MM.allocate_kernel_region(m_framebuffer_address, page_round_up(pitch * height), "Framebuffer Console", Region::Access::Read | Region::Access::Write, Region::Cacheable::Yes);
+ dbgln("Framebuffer Console: taking {} bytes", Memory::page_round_up(pitch * height));
+ m_framebuffer_region = MM.allocate_kernel_region(m_framebuffer_address, Memory::page_round_up(pitch * height), "Framebuffer Console", Memory::Region::Access::Read | Memory::Region::Access::Write, Memory::Region::Cacheable::Yes);
VERIFY(m_framebuffer_region);
// Just to start cleanly, we clean the entire framebuffer
diff --git a/Kernel/Graphics/Console/ContiguousFramebufferConsole.h b/Kernel/Graphics/Console/ContiguousFramebufferConsole.h
index 6d8159f814..692631635f 100644
--- a/Kernel/Graphics/Console/ContiguousFramebufferConsole.h
+++ b/Kernel/Graphics/Console/ContiguousFramebufferConsole.h
@@ -22,7 +22,7 @@ private:
{
return m_framebuffer_region->vaddr().as_ptr();
}
- OwnPtr<Region> m_framebuffer_region;
+ OwnPtr<Memory::Region> m_framebuffer_region;
ContiguousFramebufferConsole(PhysicalAddress, size_t width, size_t height, size_t pitch);
PhysicalAddress m_framebuffer_address;
};
diff --git a/Kernel/Graphics/Console/VGAConsole.cpp b/Kernel/Graphics/Console/VGAConsole.cpp
index 73bcabb7e2..cdd5e08db3 100644
--- a/Kernel/Graphics/Console/VGAConsole.cpp
+++ b/Kernel/Graphics/Console/VGAConsole.cpp
@@ -11,7 +11,7 @@ namespace Kernel::Graphics {
UNMAP_AFTER_INIT VGAConsole::VGAConsole(const VGACompatibleAdapter& adapter, Mode mode, size_t width, size_t height)
: Console(width, height)
- , m_vga_region(MM.allocate_kernel_region(PhysicalAddress(0xa0000), page_round_up(0xc0000 - 0xa0000), "VGA Display", Region::Access::Read | Region::Access::Write).release_nonnull())
+ , m_vga_region(MM.allocate_kernel_region(PhysicalAddress(0xa0000), Memory::page_round_up(0xc0000 - 0xa0000), "VGA Display", Memory::Region::Access::Read | Memory::Region::Access::Write).release_nonnull())
, m_adapter(adapter)
, m_mode(mode)
{
diff --git a/Kernel/Graphics/Console/VGAConsole.h b/Kernel/Graphics/Console/VGAConsole.h
index b10f5110c8..7c2b4cb49c 100644
--- a/Kernel/Graphics/Console/VGAConsole.h
+++ b/Kernel/Graphics/Console/VGAConsole.h
@@ -33,7 +33,7 @@ public:
protected:
VGAConsole(const VGACompatibleAdapter&, Mode, size_t width, size_t height);
- NonnullOwnPtr<Region> m_vga_region;
+ NonnullOwnPtr<Memory::Region> m_vga_region;
NonnullRefPtr<VGACompatibleAdapter> m_adapter;
const Mode m_mode;
};
diff --git a/Kernel/Graphics/FramebufferDevice.cpp b/Kernel/Graphics/FramebufferDevice.cpp
index e4a1061a43..e9e7def17a 100644
--- a/Kernel/Graphics/FramebufferDevice.cpp
+++ b/Kernel/Graphics/FramebufferDevice.cpp
@@ -25,7 +25,7 @@ NonnullRefPtr<FramebufferDevice> FramebufferDevice::create(const GraphicsDevice&
return adopt_ref(*new FramebufferDevice(adapter, output_port_index, paddr, width, height, pitch));
}
-KResultOr<Region*> FramebufferDevice::mmap(Process& process, FileDescription&, const Range& range, u64 offset, int prot, bool shared)
+KResultOr<Memory::Region*> FramebufferDevice::mmap(Process& process, FileDescription&, Memory::Range const& range, u64 offset, int prot, bool shared)
{
ScopedSpinLock lock(m_activation_lock);
REQUIRE_PROMISE(video);
@@ -33,31 +33,31 @@ KResultOr<Region*> FramebufferDevice::mmap(Process& process, FileDescription&, c
return ENODEV;
if (offset != 0)
return ENXIO;
- if (range.size() != page_round_up(framebuffer_size_in_bytes()))
+ if (range.size() != Memory::page_round_up(framebuffer_size_in_bytes()))
return EOVERFLOW;
- auto vmobject = AnonymousVMObject::try_create_for_physical_range(m_framebuffer_address, page_round_up(framebuffer_size_in_bytes()));
+ auto vmobject = Memory::AnonymousVMObject::try_create_for_physical_range(m_framebuffer_address, Memory::page_round_up(framebuffer_size_in_bytes()));
if (!vmobject)
return ENOMEM;
m_userspace_real_framebuffer_vmobject = vmobject;
- m_real_framebuffer_vmobject = AnonymousVMObject::try_create_for_physical_range(m_framebuffer_address, page_round_up(framebuffer_size_in_bytes()));
+ m_real_framebuffer_vmobject = Memory::AnonymousVMObject::try_create_for_physical_range(m_framebuffer_address, Memory::page_round_up(framebuffer_size_in_bytes()));
if (!m_real_framebuffer_vmobject)
return ENOMEM;
- m_swapped_framebuffer_vmobject = AnonymousVMObject::try_create_with_size(page_round_up(framebuffer_size_in_bytes()), AllocationStrategy::AllocateNow);
+ m_swapped_framebuffer_vmobject = Memory::AnonymousVMObject::try_create_with_size(Memory::page_round_up(framebuffer_size_in_bytes()), AllocationStrategy::AllocateNow);
if (!m_swapped_framebuffer_vmobject)
return ENOMEM;
- m_real_framebuffer_region = MM.allocate_kernel_region_with_vmobject(*m_real_framebuffer_vmobject, page_round_up(framebuffer_size_in_bytes()), "Framebuffer", Region::Access::Read | Region::Access::Write);
+ m_real_framebuffer_region = MM.allocate_kernel_region_with_vmobject(*m_real_framebuffer_vmobject, Memory::page_round_up(framebuffer_size_in_bytes()), "Framebuffer", Memory::Region::Access::Read | Memory::Region::Access::Write);
if (!m_real_framebuffer_region)
return ENOMEM;
- m_swapped_framebuffer_region = MM.allocate_kernel_region_with_vmobject(*m_swapped_framebuffer_vmobject, page_round_up(framebuffer_size_in_bytes()), "Framebuffer Swap (Blank)", Region::Access::Read | Region::Access::Write);
+ m_swapped_framebuffer_region = MM.allocate_kernel_region_with_vmobject(*m_swapped_framebuffer_vmobject, Memory::page_round_up(framebuffer_size_in_bytes()), "Framebuffer Swap (Blank)", Memory::Region::Access::Read | Memory::Region::Access::Write);
if (!m_swapped_framebuffer_region)
return ENOMEM;
- RefPtr<VMObject> chosen_vmobject;
+ RefPtr<Memory::VMObject> chosen_vmobject;
if (m_graphical_writes_enabled) {
chosen_vmobject = m_real_framebuffer_vmobject;
} else {
@@ -81,7 +81,7 @@ void FramebufferDevice::deactivate_writes()
ScopedSpinLock lock(m_activation_lock);
if (!m_userspace_framebuffer_region)
return;
- memcpy(m_swapped_framebuffer_region->vaddr().as_ptr(), m_real_framebuffer_region->vaddr().as_ptr(), page_round_up(framebuffer_size_in_bytes()));
+ memcpy(m_swapped_framebuffer_region->vaddr().as_ptr(), m_real_framebuffer_region->vaddr().as_ptr(), Memory::page_round_up(framebuffer_size_in_bytes()));
auto vmobject = m_swapped_framebuffer_vmobject;
m_userspace_framebuffer_region->set_vmobject(vmobject.release_nonnull());
m_userspace_framebuffer_region->remap();
@@ -95,7 +95,7 @@ void FramebufferDevice::activate_writes()
// restore the image we had in the void area
// FIXME: if we happen to have multiple Framebuffers that are writing to that location
// we will experience glitches...
- memcpy(m_real_framebuffer_region->vaddr().as_ptr(), m_swapped_framebuffer_region->vaddr().as_ptr(), page_round_up(framebuffer_size_in_bytes()));
+ memcpy(m_real_framebuffer_region->vaddr().as_ptr(), m_swapped_framebuffer_region->vaddr().as_ptr(), Memory::page_round_up(framebuffer_size_in_bytes()));
auto vmobject = m_userspace_real_framebuffer_vmobject;
m_userspace_framebuffer_region->set_vmobject(vmobject.release_nonnull());
m_userspace_framebuffer_region->remap();
@@ -109,13 +109,13 @@ String FramebufferDevice::device_name() const
UNMAP_AFTER_INIT void FramebufferDevice::initialize()
{
- m_real_framebuffer_vmobject = AnonymousVMObject::try_create_for_physical_range(m_framebuffer_address, page_round_up(framebuffer_size_in_bytes()));
+ m_real_framebuffer_vmobject = Memory::AnonymousVMObject::try_create_for_physical_range(m_framebuffer_address, Memory::page_round_up(framebuffer_size_in_bytes()));
VERIFY(m_real_framebuffer_vmobject);
- m_real_framebuffer_region = MM.allocate_kernel_region_with_vmobject(*m_real_framebuffer_vmobject, page_round_up(framebuffer_size_in_bytes()), "Framebuffer", Region::Access::Read | Region::Access::Write);
+ m_real_framebuffer_region = MM.allocate_kernel_region_with_vmobject(*m_real_framebuffer_vmobject, Memory::page_round_up(framebuffer_size_in_bytes()), "Framebuffer", Memory::Region::Access::Read | Memory::Region::Access::Write);
VERIFY(m_real_framebuffer_region);
- m_swapped_framebuffer_vmobject = AnonymousVMObject::try_create_with_size(page_round_up(framebuffer_size_in_bytes()), AllocationStrategy::AllocateNow);
+ m_swapped_framebuffer_vmobject = Memory::AnonymousVMObject::try_create_with_size(Memory::page_round_up(framebuffer_size_in_bytes()), AllocationStrategy::AllocateNow);
VERIFY(m_swapped_framebuffer_vmobject);
- m_swapped_framebuffer_region = MM.allocate_kernel_region_with_vmobject(*m_swapped_framebuffer_vmobject, page_round_up(framebuffer_size_in_bytes()), "Framebuffer Swap (Blank)", Region::Access::Read | Region::Access::Write);
+ m_swapped_framebuffer_region = MM.allocate_kernel_region_with_vmobject(*m_swapped_framebuffer_vmobject, Memory::page_round_up(framebuffer_size_in_bytes()), "Framebuffer Swap (Blank)", Memory::Region::Access::Read | Memory::Region::Access::Write);
VERIFY(m_swapped_framebuffer_region);
}
diff --git a/Kernel/Graphics/FramebufferDevice.h b/Kernel/Graphics/FramebufferDevice.h
index e240d10a41..26a39da693 100644
--- a/Kernel/Graphics/FramebufferDevice.h
+++ b/Kernel/Graphics/FramebufferDevice.h
@@ -23,7 +23,7 @@ public:
static NonnullRefPtr<FramebufferDevice> create(const GraphicsDevice&, size_t, PhysicalAddress, size_t, size_t, size_t);
virtual KResult ioctl(FileDescription&, unsigned request, Userspace<void*> arg) override;
- virtual KResultOr<Region*> mmap(Process&, FileDescription&, const Range&, u64 offset, int prot, bool shared) override;
+ virtual KResultOr<Memory::Region*> mmap(Process&, FileDescription&, Memory::Range const&, u64 offset, int prot, bool shared) override;
// ^Device
virtual mode_t required_mode() const override { return 0660; }
@@ -55,15 +55,15 @@ private:
SpinLock<u8> m_activation_lock;
- RefPtr<AnonymousVMObject> m_real_framebuffer_vmobject;
- RefPtr<AnonymousVMObject> m_swapped_framebuffer_vmobject;
- OwnPtr<Region> m_real_framebuffer_region;
- OwnPtr<Region> m_swapped_framebuffer_region;
+ RefPtr<Memory::AnonymousVMObject> m_real_framebuffer_vmobject;
+ RefPtr<Memory::AnonymousVMObject> m_swapped_framebuffer_vmobject;
+ OwnPtr<Memory::Region> m_real_framebuffer_region;
+ OwnPtr<Memory::Region> m_swapped_framebuffer_region;
bool m_graphical_writes_enabled { true };
- RefPtr<AnonymousVMObject> m_userspace_real_framebuffer_vmobject;
- Region* m_userspace_framebuffer_region { nullptr };
+ RefPtr<Memory::AnonymousVMObject> m_userspace_real_framebuffer_vmobject;
+ Memory::Region* m_userspace_framebuffer_region { nullptr };
size_t m_y_offset { 0 };
size_t m_output_port_index;
diff --git a/Kernel/Graphics/GraphicsManagement.cpp b/Kernel/Graphics/GraphicsManagement.cpp
index 5e5b4b63a5..438fc54486 100644
--- a/Kernel/Graphics/GraphicsManagement.cpp
+++ b/Kernel/Graphics/GraphicsManagement.cpp
@@ -32,7 +32,7 @@ bool GraphicsManagement::is_initialized()
}
UNMAP_AFTER_INIT GraphicsManagement::GraphicsManagement()
- : m_vga_font_region(MM.allocate_kernel_region(PAGE_SIZE, "VGA font", Region::Access::Read | Region::Access::Write, AllocationStrategy::AllocateNow).release_nonnull())
+ : m_vga_font_region(MM.allocate_kernel_region(PAGE_SIZE, "VGA font", Memory::Region::Access::Read | Memory::Region::Access::Write, AllocationStrategy::AllocateNow).release_nonnull())
, m_framebuffer_devices_allowed(!kernel_command_line().is_no_framebuffer_devices_mode())
{
}
diff --git a/Kernel/Graphics/GraphicsManagement.h b/Kernel/Graphics/GraphicsManagement.h
index ca39d787b6..ebfda332ee 100644
--- a/Kernel/Graphics/GraphicsManagement.h
+++ b/Kernel/Graphics/GraphicsManagement.h
@@ -49,7 +49,7 @@ public:
private:
bool determine_and_initialize_graphics_device(const PCI::Address& address, PCI::ID id);
NonnullRefPtrVector<GraphicsDevice> m_graphics_devices;
- NonnullOwnPtr<Region> m_vga_font_region;
+ NonnullOwnPtr<Memory::Region> m_vga_font_region;
RefPtr<Graphics::Console> m_console;
// Note: there could be multiple VGA adapters, but only one can operate in VGA mode
diff --git a/Kernel/Graphics/Intel/NativeGraphicsAdapter.cpp b/Kernel/Graphics/Intel/NativeGraphicsAdapter.cpp
index f3a16ecc5a..0d189505e7 100644
--- a/Kernel/Graphics/Intel/NativeGraphicsAdapter.cpp
+++ b/Kernel/Graphics/Intel/NativeGraphicsAdapter.cpp
@@ -189,7 +189,7 @@ IntelNativeGraphicsAdapter::IntelNativeGraphicsAdapter(PCI::Address address)
VERIFY(bar0_space_size == 0x80000);
dmesgln("Intel Native Graphics Adapter @ {}, MMIO @ {}, space size is {:x} bytes", address, PhysicalAddress(PCI::get_BAR0(address)), bar0_space_size);
dmesgln("Intel Native Graphics Adapter @ {}, framebuffer @ {}", address, PhysicalAddress(PCI::get_BAR2(address)));
- m_registers_region = MM.allocate_kernel_region(PhysicalAddress(PCI::get_BAR0(address)).page_base(), bar0_space_size, "Intel Native Graphics Registers", Region::Access::Read | Region::Access::Write);
+ m_registers_region = MM.allocate_kernel_region(PhysicalAddress(PCI::get_BAR0(address)).page_base(), bar0_space_size, "Intel Native Graphics Registers", Memory::Region::Access::Read | Memory::Region::Access::Write);
PCI::enable_bus_mastering(address);
{
ScopedSpinLock control_lock(m_control_lock);
diff --git a/Kernel/Graphics/Intel/NativeGraphicsAdapter.h b/Kernel/Graphics/Intel/NativeGraphicsAdapter.h
index 2cd87ad440..6768d9f9cb 100644
--- a/Kernel/Graphics/Intel/NativeGraphicsAdapter.h
+++ b/Kernel/Graphics/Intel/NativeGraphicsAdapter.h
@@ -168,7 +168,7 @@ private:
Graphics::VideoInfoBlock m_crt_edid;
const PhysicalAddress m_registers;
const PhysicalAddress m_framebuffer_addr;
- OwnPtr<Region> m_registers_region;
+ OwnPtr<Memory::Region> m_registers_region;
};
}
diff --git a/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.cpp b/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.cpp
index eb312811df..df8f8ea94b 100644
--- a/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.cpp
+++ b/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.cpp
@@ -32,15 +32,15 @@ void FrameBufferDevice::create_framebuffer()
// Allocate frame buffer for both front and back
auto& info = display_info();
m_buffer_size = calculate_framebuffer_size(info.rect.width, info.rect.height);
- m_framebuffer = MM.allocate_kernel_region(m_buffer_size * 2, String::formatted("VirtGPU FrameBuffer #{}", m_scanout.value()), Region::Access::Read | Region::Access::Write, AllocationStrategy::AllocateNow);
- auto write_sink_page = MM.allocate_user_physical_page(MemoryManager::ShouldZeroFill::No).release_nonnull();
+ m_framebuffer = MM.allocate_kernel_region(m_buffer_size * 2, String::formatted("VirtGPU FrameBuffer #{}", m_scanout.value()), Memory::Region::Access::Read | Memory::Region::Access::Write, AllocationStrategy::AllocateNow);
+ auto write_sink_page = MM.allocate_user_physical_page(Memory::MemoryManager::ShouldZeroFill::No).release_nonnull();
auto num_needed_pages = m_framebuffer->vmobject().page_count();
- NonnullRefPtrVector<PhysicalPage> pages;
+ NonnullRefPtrVector<Memory::PhysicalPage> pages;
for (auto i = 0u; i < num_needed_pages; ++i) {
pages.append(write_sink_page);
}
- m_framebuffer_sink_vmobject = AnonymousVMObject::try_create_with_physical_pages(pages.span());
+ m_framebuffer_sink_vmobject = Memory::AnonymousVMObject::try_create_with_physical_pages(pages.span());
MutexLocker locker(m_gpu.operation_lock());
m_current_buffer = &buffer_from_index(m_last_set_buffer_index.load());
@@ -241,7 +241,7 @@ KResult FrameBufferDevice::ioctl(FileDescription&, unsigned request, Userspace<v
};
}
-KResultOr<Region*> FrameBufferDevice::mmap(Process& process, FileDescription&, const Range& range, u64 offset, int prot, bool shared)
+KResultOr<Memory::Region*> FrameBufferDevice::mmap(Process& process, FileDescription&, Memory::Range const& range, u64 offset, int prot, bool shared)
{
REQUIRE_PROMISE(video);
if (!shared)
diff --git a/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.h b/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.h
index 54b765a40c..efbc98aff6 100644
--- a/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.h
+++ b/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.h
@@ -39,7 +39,7 @@ public:
static size_t calculate_framebuffer_size(size_t width, size_t height)
{
// VirtIO resources can only map on page boundaries!
- return page_round_up(sizeof(u32) * width * height);
+ return Memory::page_round_up(sizeof(u32) * width * height);
}
void flush_dirty_window(Protocol::Rect const&, Buffer&);
@@ -61,7 +61,7 @@ private:
void set_buffer(int);
virtual KResult ioctl(FileDescription&, unsigned request, Userspace<void*> arg) override;
- virtual KResultOr<Region*> mmap(Process&, FileDescription&, const Range&, u64 offset, int prot, bool shared) override;
+ virtual KResultOr<Memory::Region*> mmap(Process&, FileDescription&, Memory::Range const&, u64 offset, int prot, bool shared) override;
virtual bool can_read(const FileDescription&, size_t) const override { return true; }
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override { return EINVAL; }
virtual bool can_write(const FileDescription&, size_t) const override { return true; }
@@ -88,12 +88,12 @@ private:
Atomic<int, AK::memory_order_relaxed> m_last_set_buffer_index { 0 };
Buffer m_main_buffer;
Buffer m_back_buffer;
- OwnPtr<Region> m_framebuffer;
- RefPtr<VMObject> m_framebuffer_sink_vmobject;
+ OwnPtr<Memory::Region> m_framebuffer;
+ RefPtr<Memory::VMObject> m_framebuffer_sink_vmobject;
size_t m_buffer_size { 0 };
bool m_are_writes_active { true };
// FIXME: This needs to be cleaned up if the WindowServer exits while we are in a tty
- WeakPtr<Region> m_userspace_mmap_region;
+ WeakPtr<Memory::Region> m_userspace_mmap_region;
};
}
diff --git a/Kernel/Graphics/VirtIOGPU/GPU.cpp b/Kernel/Graphics/VirtIOGPU/GPU.cpp
index 15eb5bdafc..1600d01531 100644
--- a/Kernel/Graphics/VirtIOGPU/GPU.cpp
+++ b/Kernel/Graphics/VirtIOGPU/GPU.cpp
@@ -17,7 +17,7 @@ namespace Kernel::Graphics::VirtIOGPU {
GPU::GPU(PCI::Address address)
: VirtIODevice(address, "GPU")
- , m_scratch_space(MM.allocate_contiguous_kernel_region(32 * PAGE_SIZE, "VirtGPU Scratch Space", Region::Access::Read | Region::Access::Write))
+ , m_scratch_space(MM.allocate_contiguous_kernel_region(32 * PAGE_SIZE, "VirtGPU Scratch Space", Memory::Region::Access::Read | Memory::Region::Access::Write))
{
VERIFY(!!m_scratch_space);
if (auto cfg = get_config(ConfigurationType::Device)) {
@@ -138,7 +138,7 @@ ResourceID GPU::create_2d_resource(Protocol::Rect rect)
return resource_id;
}
-void GPU::ensure_backing_storage(Region const& region, size_t buffer_offset, size_t buffer_length, ResourceID resource_id)
+void GPU::ensure_backing_storage(Memory::Region const& region, size_t buffer_offset, size_t buffer_length, ResourceID resource_id)
{
VERIFY(m_operation_lock.is_locked());
diff --git a/Kernel/Graphics/VirtIOGPU/GPU.h b/Kernel/Graphics/VirtIOGPU/GPU.h
index 86c75f02ca..11a55adc67 100644
--- a/Kernel/Graphics/VirtIOGPU/GPU.h
+++ b/Kernel/Graphics/VirtIOGPU/GPU.h
@@ -102,7 +102,7 @@ private:
void query_display_information();
ResourceID create_2d_resource(Protocol::Rect rect);
void delete_resource(ResourceID resource_id);
- void ensure_backing_storage(Region const& region, size_t buffer_offset, size_t buffer_length, ResourceID resource_id);
+ void ensure_backing_storage(Memory::Region const& region, size_t buffer_offset, size_t buffer_length, ResourceID resource_id);
void detach_backing_storage(ResourceID resource_id);
void set_scanout_resource(ScanoutID scanout, ResourceID resource_id, Protocol::Rect rect);
void transfer_framebuffer_data_to_host(ScanoutID scanout, Protocol::Rect const& rect, ResourceID resource_id);
@@ -118,7 +118,7 @@ private:
// Synchronous commands
WaitQueue m_outstanding_request;
Mutex m_operation_lock;
- OwnPtr<Region> m_scratch_space;
+ OwnPtr<Memory::Region> m_scratch_space;
};
}
diff --git a/Kernel/Heap/SlabAllocator.cpp b/Kernel/Heap/SlabAllocator.cpp
index 4057cbafcc..c20f676bad 100644
--- a/Kernel/Heap/SlabAllocator.cpp
+++ b/Kernel/Heap/SlabAllocator.cpp
@@ -112,7 +112,7 @@ static SlabAllocator<128> s_slab_allocator_128;
static SlabAllocator<256> s_slab_allocator_256;
#if ARCH(I386)
-static_assert(sizeof(Region) <= s_slab_allocator_128.slab_size());
+static_assert(sizeof(Memory::Region) <= s_slab_allocator_128.slab_size());
#endif
template<typename Callback>
diff --git a/Kernel/Heap/kmalloc.cpp b/Kernel/Heap/kmalloc.cpp
index 89257ee798..55ee04f7d1 100644
--- a/Kernel/Heap/kmalloc.cpp
+++ b/Kernel/Heap/kmalloc.cpp
@@ -47,7 +47,7 @@ struct KmallocGlobalHeap {
bool m_adding { false };
bool add_memory(size_t allocation_request)
{
- if (!MemoryManager::is_initialized()) {
+ if (!Memory::MemoryManager::is_initialized()) {
if constexpr (KMALLOC_DEBUG) {
dmesgln("kmalloc: Cannot expand heap before MM is initialized!");
}
@@ -94,12 +94,12 @@ struct KmallocGlobalHeap {
// was big enough to likely satisfy the request
if (subheap.free_bytes() < allocation_request) {
// Looks like we probably need more
- size_t memory_size = page_round_up(decltype(m_global_heap.m_heap)::calculate_memory_for_bytes(allocation_request));
+ size_t memory_size = Memory::page_round_up(decltype(m_global_heap.m_heap)::calculate_memory_for_bytes(allocation_request));
// Add some more to the new heap. We're already using it for other
// allocations not including the original allocation_request
// that triggered heap expansion. If we don't allocate
memory_size += 1 * MiB;
- region = MM.allocate_kernel_region(memory_size, "kmalloc subheap", Region::Access::Read | Region::Access::Write, AllocationStrategy::AllocateNow);
+ region = MM.allocate_kernel_region(memory_size, "kmalloc subheap", Memory::Region::Access::Read | Memory::Region::Access::Write, AllocationStrategy::AllocateNow);
if (region) {
dbgln("kmalloc: Adding even more memory to heap at {}, bytes: {}", region->vaddr(), region->size());
@@ -162,8 +162,8 @@ struct KmallocGlobalHeap {
typedef ExpandableHeap<CHUNK_SIZE, KMALLOC_SCRUB_BYTE, KFREE_SCRUB_BYTE, ExpandGlobalHeap> HeapType;
HeapType m_heap;
- NonnullOwnPtrVector<Region> m_subheap_memory;
- OwnPtr<Region> m_backup_memory;
+ NonnullOwnPtrVector<Memory::Region> m_subheap_memory;
+ OwnPtr<Memory::Region> m_backup_memory;
KmallocGlobalHeap(u8* memory, size_t memory_size)
: m_heap(memory, memory_size, ExpandGlobalHeap(*this))
@@ -173,7 +173,7 @@ struct KmallocGlobalHeap {
{
if (m_backup_memory)
return;
- m_backup_memory = MM.allocate_kernel_region(1 * MiB, "kmalloc subheap", Region::Access::Read | Region::Access::Write, AllocationStrategy::AllocateNow);
+ m_backup_memory = MM.allocate_kernel_region(1 * MiB, "kmalloc subheap", Memory::Region::Access::Read | Memory::Region::Access::Write, AllocationStrategy::AllocateNow);
}
size_t backup_memory_bytes() const
diff --git a/Kernel/Interrupts/APIC.cpp b/Kernel/Interrupts/APIC.cpp
index 714c85791e..cd7f04f068 100644
--- a/Kernel/Interrupts/APIC.cpp
+++ b/Kernel/Interrupts/APIC.cpp
@@ -228,7 +228,7 @@ UNMAP_AFTER_INIT bool APIC::init_bsp()
dbgln_if(APIC_DEBUG, "Initializing APIC, base: {}", apic_base);
set_base(apic_base);
- m_apic_base = MM.allocate_kernel_region(apic_base.page_base(), PAGE_SIZE, {}, Region::Access::Read | Region::Access::Write);
+ m_apic_base = MM.allocate_kernel_region(apic_base.page_base(), PAGE_SIZE, {}, Memory::Region::Access::Read | Memory::Region::Access::Write);
if (!m_apic_base) {
dbgln("APIC: Failed to allocate memory for APIC base");
return false;
@@ -245,7 +245,7 @@ UNMAP_AFTER_INIT bool APIC::init_bsp()
return false;
}
- auto madt = map_typed<ACPI::Structures::MADT>(madt_address);
+ auto madt = Memory::map_typed<ACPI::Structures::MADT>(madt_address);
size_t entry_index = 0;
size_t entries_length = madt->h.length - sizeof(ACPI::Structures::MADT);
auto* madt_entry = madt->entries;
@@ -283,13 +283,13 @@ UNMAP_AFTER_INIT void APIC::do_boot_aps()
// Also account for the data appended to:
// * aps_to_enable u32 values for ap_cpu_init_stacks
// * aps_to_enable u32 values for ap_cpu_init_processor_info_array
- auto apic_startup_region = MM.allocate_kernel_region_identity(PhysicalAddress(0x8000), page_round_up(apic_ap_start_size + (2 * aps_to_enable * sizeof(u32))), {}, Region::Access::Read | Region::Access::Write | Region::Access::Execute);
+ auto apic_startup_region = MM.allocate_kernel_region_identity(PhysicalAddress(0x8000), Memory::page_round_up(apic_ap_start_size + (2 * aps_to_enable * sizeof(u32))), {}, Memory::Region::Access::Read | Memory::Region::Access::Write | Memory::Region::Access::Execute);
memcpy(apic_startup_region->vaddr().as_ptr(), reinterpret_cast<const void*>(apic_ap_start), apic_ap_start_size);
// Allocate enough stacks for all APs
- Vector<OwnPtr<Region>> apic_ap_stacks;
+ Vector<OwnPtr<Memory::Region>> apic_ap_stacks;
for (u32 i = 0; i < aps_to_enable; i++) {
- auto stack_region = MM.allocate_kernel_region(Thread::default_kernel_stack_size, {}, Region::Access::Read | Region::Access::Write, AllocationStrategy::AllocateNow);
+ auto stack_region = MM.allocate_kernel_region(Thread::default_kernel_stack_size, {}, Memory::Region::Access::Read | Memory::Region::Access::Write, AllocationStrategy::AllocateNow);
if (!stack_region) {
dbgln("APIC: Failed to allocate stack for AP #{}", i);
return;
diff --git a/Kernel/Interrupts/APIC.h b/Kernel/Interrupts/APIC.h
index 507dd8e0b2..e59ef33564 100644
--- a/Kernel/Interrupts/APIC.h
+++ b/Kernel/Interrupts/APIC.h
@@ -89,7 +89,7 @@ private:
u32 high() const { return m_high; }
};
- OwnPtr<Region> m_apic_base;
+ OwnPtr<Memory::Region> m_apic_base;
Vector<OwnPtr<Processor>> m_ap_processor_info;
Vector<Thread*> m_ap_idle_threads;
Atomic<u8> m_apic_ap_count { 0 };
diff --git a/Kernel/Interrupts/IOAPIC.cpp b/Kernel/Interrupts/IOAPIC.cpp
index 1bdf548515..f90433e068 100644
--- a/Kernel/Interrupts/IOAPIC.cpp
+++ b/Kernel/Interrupts/IOAPIC.cpp
@@ -25,7 +25,7 @@ enum DeliveryMode {
UNMAP_AFTER_INIT IOAPIC::IOAPIC(PhysicalAddress address, u32 gsi_base)
: m_address(address)
- , m_regs(map_typed_writable<ioapic_mmio_regs>(m_address))
+ , m_regs(Memory::map_typed_writable<ioapic_mmio_regs>(m_address))
, m_gsi_base(gsi_base)
, m_id((read_register(0x0) >> 24) & 0xFF)
, m_version(read_register(0x1) & 0xFF)
diff --git a/Kernel/Interrupts/IOAPIC.h b/Kernel/Interrupts/IOAPIC.h
index 1e71e78a32..4977668664 100644
--- a/Kernel/Interrupts/IOAPIC.h
+++ b/Kernel/Interrupts/IOAPIC.h
@@ -78,7 +78,7 @@ private:
void isa_identity_map(int index);
PhysicalAddress m_address;
- mutable TypedMapping<ioapic_mmio_regs> m_regs;
+ mutable Memory::TypedMapping<ioapic_mmio_regs> m_regs;
u32 m_gsi_base;
u8 m_id;
u8 m_version;
diff --git a/Kernel/Interrupts/InterruptManagement.cpp b/Kernel/Interrupts/InterruptManagement.cpp
index 0101e1fd6e..d1bc0e8293 100644
--- a/Kernel/Interrupts/InterruptManagement.cpp
+++ b/Kernel/Interrupts/InterruptManagement.cpp
@@ -183,7 +183,7 @@ UNMAP_AFTER_INIT void InterruptManagement::switch_to_ioapic_mode()
UNMAP_AFTER_INIT void InterruptManagement::locate_apic_data()
{
VERIFY(!m_madt.is_null());
- auto madt = map_typed<ACPI::Structures::MADT>(m_madt);
+ auto madt = Memory::map_typed<ACPI::Structures::MADT>(m_madt);
int irq_controller_count = 0;
if (madt->flags & PCAT_COMPAT_FLAG) {
diff --git a/Kernel/KBuffer.h b/Kernel/KBuffer.h
index 218925f216..a2ce51cfbb 100644
--- a/Kernel/KBuffer.h
+++ b/Kernel/KBuffer.h
@@ -27,17 +27,17 @@ namespace Kernel {
class KBufferImpl : public RefCounted<KBufferImpl> {
public:
- static RefPtr<KBufferImpl> try_create_with_size(size_t size, Region::Access access, StringView name = "KBuffer", AllocationStrategy strategy = AllocationStrategy::Reserve)
+ static RefPtr<KBufferImpl> try_create_with_size(size_t size, Memory::Region::Access access, StringView name = "KBuffer", AllocationStrategy strategy = AllocationStrategy::Reserve)
{
- auto region = MM.allocate_kernel_region(page_round_up(size), name, access, strategy);
+ auto region = MM.allocate_kernel_region(Memory::page_round_up(size), name, access, strategy);
if (!region)
return nullptr;
return adopt_ref_if_nonnull(new (nothrow) KBufferImpl(region.release_nonnull(), size, strategy));
}
- static RefPtr<KBufferImpl> try_create_with_bytes(ReadonlyBytes bytes, Region::Access access, StringView name = "KBuffer", AllocationStrategy strategy = AllocationStrategy::Reserve)
+ static RefPtr<KBufferImpl> try_create_with_bytes(ReadonlyBytes bytes, Memory::Region::Access access, StringView name = "KBuffer", AllocationStrategy strategy = AllocationStrategy::Reserve)
{
- auto region = MM.allocate_kernel_region(page_round_up(bytes.size()), name, access, strategy);
+ auto region = MM.allocate_kernel_region(Memory::page_round_up(bytes.size()), name, access, strategy);
if (!region)
return nullptr;
memcpy(region->vaddr().as_ptr(), bytes.data(), bytes.size());
@@ -45,12 +45,12 @@ public:
return adopt_ref_if_nonnull(new (nothrow) KBufferImpl(region.release_nonnull(), bytes.size(), strategy));
}
- static RefPtr<KBufferImpl> create_with_size(size_t size, Region::Access access, StringView name, AllocationStrategy strategy = AllocationStrategy::Reserve)
+ static RefPtr<KBufferImpl> create_with_size(size_t size, Memory::Region::Access access, StringView name, AllocationStrategy strategy = AllocationStrategy::Reserve)
{
return try_create_with_size(size, access, name, strategy);
}
- static RefPtr<KBufferImpl> copy(const void* data, size_t size, Region::Access access, StringView name)
+ static RefPtr<KBufferImpl> copy(const void* data, size_t size, Memory::Region::Access access, StringView name)
{
auto buffer = create_with_size(size, access, name, AllocationStrategy::AllocateNow);
if (!buffer)
@@ -61,7 +61,7 @@ public:
[[nodiscard]] bool expand(size_t new_capacity)
{
- auto new_region = MM.allocate_kernel_region(page_round_up(new_capacity), m_region->name(), m_region->access(), m_allocation_strategy);
+ auto new_region = MM.allocate_kernel_region(Memory::page_round_up(new_capacity), m_region->name(), m_region->access(), m_allocation_strategy);
if (!new_region)
return false;
if (m_size > 0)
@@ -81,11 +81,11 @@ public:
m_size = size;
}
- [[nodiscard]] const Region& region() const { return *m_region; }
- [[nodiscard]] Region& region() { return *m_region; }
+ [[nodiscard]] Memory::Region const& region() const { return *m_region; }
+ [[nodiscard]] Memory::Region& region() { return *m_region; }
private:
- explicit KBufferImpl(NonnullOwnPtr<Region>&& region, size_t size, AllocationStrategy strategy)
+ explicit KBufferImpl(NonnullOwnPtr<Memory::Region>&& region, size_t size, AllocationStrategy strategy)
: m_size(size)
, m_allocation_strategy(strategy)
, m_region(move(region))
@@ -94,7 +94,7 @@ private:
size_t m_size { 0 };
AllocationStrategy m_allocation_strategy { AllocationStrategy::Reserve };
- NonnullOwnPtr<Region> m_region;
+ NonnullOwnPtr<Memory::Region> m_region;
};
class [[nodiscard]] KBuffer {
@@ -104,7 +104,7 @@ public:
{
}
- [[nodiscard]] static OwnPtr<KBuffer> try_create_with_size(size_t size, Region::Access access = Region::Access::Read | Region::Access::Write, StringView name = "KBuffer", AllocationStrategy strategy = AllocationStrategy::Reserve)
+ [[nodiscard]] static OwnPtr<KBuffer> try_create_with_size(size_t size, Memory::Region::Access access = Memory::Region::Access::Read | Memory::Region::Access::Write, StringView name = "KBuffer", AllocationStrategy strategy = AllocationStrategy::Reserve)
{
auto impl = KBufferImpl::try_create_with_size(size, access, name, strategy);
if (!impl)
@@ -112,7 +112,7 @@ public:
return adopt_own_if_nonnull(new (nothrow) KBuffer(impl.release_nonnull()));
}
- [[nodiscard]] static OwnPtr<KBuffer> try_create_with_bytes(ReadonlyBytes bytes, Region::Access access = Region::Access::Read | Region::Access::Write, StringView name = "KBuffer", AllocationStrategy strategy = AllocationStrategy::Reserve)
+ [[nodiscard]] static OwnPtr<KBuffer> try_create_with_bytes(ReadonlyBytes bytes, Memory::Region::Access access = Memory::Region::Access::Read | Memory::Region::Access::Write, StringView name = "KBuffer", AllocationStrategy strategy = AllocationStrategy::Reserve)
{
auto impl = KBufferImpl::try_create_with_bytes(bytes, access, name, strategy);
if (!impl)
@@ -120,7 +120,7 @@ public:
return adopt_own_if_nonnull(new (nothrow) KBuffer(impl.release_nonnull()));
}
- [[nodiscard]] static KBuffer copy(const void* data, size_t size, Region::Access access = Region::Access::Read | Region::Access::Write, StringView name = "KBuffer")
+ [[nodiscard]] static KBuffer copy(const void* data, size_t size, Memory::Region::Access access = Memory::Region::Access::Read | Memory::Region::Access::Write, StringView name = "KBuffer")
{
return KBuffer(KBufferImpl::copy(data, size, access, name));
}
@@ -141,7 +141,7 @@ public:
[[nodiscard]] const KBufferImpl& impl() const { return *m_impl; }
[[nodiscard]] RefPtr<KBufferImpl> take_impl() { return move(m_impl); }
- KBuffer(const ByteBuffer& buffer, Region::Access access = Region::Access::Read | Region::Access::Write, StringView name = "KBuffer")
+ KBuffer(const ByteBuffer& buffer, Memory::Region::Access access = Memory::Region::Access::Read | Memory::Region::Access::Write, StringView name = "KBuffer")
: m_impl(KBufferImpl::copy(buffer.data(), buffer.size(), access, name))
{
}
diff --git a/Kernel/KBufferBuilder.cpp b/Kernel/KBufferBuilder.cpp
index 2c514b01fe..d8982dda96 100644
--- a/Kernel/KBufferBuilder.cpp
+++ b/Kernel/KBufferBuilder.cpp
@@ -20,7 +20,7 @@ inline bool KBufferBuilder::check_expand(size_t size)
size_t new_buffer_size = m_size + size;
if (Checked<size_t>::addition_would_overflow(new_buffer_size, 1 * MiB))
return false;
- new_buffer_size = page_round_up(new_buffer_size + 1 * MiB);
+ new_buffer_size = Memory::page_round_up(new_buffer_size + 1 * MiB);
return m_buffer->expand(new_buffer_size);
}
@@ -41,7 +41,7 @@ OwnPtr<KBuffer> KBufferBuilder::build()
}
KBufferBuilder::KBufferBuilder()
- : m_buffer(KBufferImpl::try_create_with_size(4 * MiB, Region::Access::Read | Region::Access::Write))
+ : m_buffer(KBufferImpl::try_create_with_size(4 * MiB, Memory::Region::Access::Read | Memory::Region::Access::Write))
{
}
diff --git a/Kernel/Memory/AnonymousVMObject.cpp b/Kernel/Memory/AnonymousVMObject.cpp
index 7c34d57c31..d576be58e3 100644
--- a/Kernel/Memory/AnonymousVMObject.cpp
+++ b/Kernel/Memory/AnonymousVMObject.cpp
@@ -11,7 +11,7 @@
#include <Kernel/Memory/PhysicalPage.h>
#include <Kernel/Process.h>
-namespace Kernel {
+namespace Kernel::Memory {
RefPtr<VMObject> AnonymousVMObject::try_clone()
{
diff --git a/Kernel/Memory/AnonymousVMObject.h b/Kernel/Memory/AnonymousVMObject.h
index a0b4082c7e..358dc3a49c 100644
--- a/Kernel/Memory/AnonymousVMObject.h
+++ b/Kernel/Memory/AnonymousVMObject.h
@@ -12,7 +12,7 @@
#include <Kernel/Memory/VMObject.h>
#include <Kernel/PhysicalAddress.h>
-namespace Kernel {
+namespace Kernel::Memory {
class AnonymousVMObject final : public VMObject {
public:
diff --git a/Kernel/Memory/InodeVMObject.cpp b/Kernel/Memory/InodeVMObject.cpp
index 44392cf616..4f6deefb83 100644
--- a/Kernel/Memory/InodeVMObject.cpp
+++ b/Kernel/Memory/InodeVMObject.cpp
@@ -7,7 +7,7 @@
#include <Kernel/FileSystem/Inode.h>
#include <Kernel/Memory/InodeVMObject.h>
-namespace Kernel {
+namespace Kernel::Memory {
InodeVMObject::InodeVMObject(Inode& inode, size_t size)
: VMObject(size)
diff --git a/Kernel/Memory/InodeVMObject.h b/Kernel/Memory/InodeVMObject.h
index f2f72ce577..d8c46b7a2a 100644
--- a/Kernel/Memory/InodeVMObject.h
+++ b/Kernel/Memory/InodeVMObject.h
@@ -10,7 +10,7 @@
#include <Kernel/Memory/VMObject.h>
#include <Kernel/UnixTypes.h>
-namespace Kernel {
+namespace Kernel::Memory {
class InodeVMObject : public VMObject {
public:
diff --git a/Kernel/Memory/MappedROM.h b/Kernel/Memory/MappedROM.h
index 9f377df1b6..791cf3d43d 100644
--- a/Kernel/Memory/MappedROM.h
+++ b/Kernel/Memory/MappedROM.h
@@ -10,7 +10,7 @@
#include <Kernel/Memory/Region.h>
#include <Kernel/PhysicalAddress.h>
-namespace Kernel {
+namespace Kernel::Memory {
class MappedROM {
public:
diff --git a/Kernel/Memory/MemoryManager.cpp b/Kernel/Memory/MemoryManager.cpp
index 08fde5429b..58fc808b7d 100644
--- a/Kernel/Memory/MemoryManager.cpp
+++ b/Kernel/Memory/MemoryManager.cpp
@@ -40,7 +40,7 @@ extern size_t multiboot_copy_boot_modules_count;
// Treat the super pages as logically separate from .bss
__attribute__((section(".super_pages"))) static u8 super_pages[1 * MiB];
-namespace Kernel {
+namespace Kernel::Memory {
// NOTE: We can NOT use AK::Singleton for this class, because
// MemoryManager::initialize is called *before* global constructors are
@@ -49,7 +49,7 @@ namespace Kernel {
static MemoryManager* s_the;
RecursiveSpinLock s_mm_lock;
-MemoryManager& MM
+MemoryManager& MemoryManager::the()
{
return *s_the;
}
diff --git a/Kernel/Memory/MemoryManager.h b/Kernel/Memory/MemoryManager.h
index 1067e6e2d1..1ac00f5812 100644
--- a/Kernel/Memory/MemoryManager.h
+++ b/Kernel/Memory/MemoryManager.h
@@ -21,7 +21,7 @@
#include <Kernel/Memory/VMObject.h>
#include <Kernel/SpinLock.h>
-namespace Kernel {
+namespace Kernel::Memory {
constexpr bool page_round_up_would_wrap(FlatPtr x)
{
@@ -88,7 +88,7 @@ struct PhysicalMemoryRange {
PhysicalSize length {};
};
-#define MM Kernel::MemoryManager::the()
+#define MM Kernel::Memory::MemoryManager::the()
struct MemoryManagerData {
static ProcessorSpecificDataID processor_specific_data_id() { return ProcessorSpecificDataID::MemoryManager; }
diff --git a/Kernel/Memory/PageDirectory.cpp b/Kernel/Memory/PageDirectory.cpp
index 3b5fb07f08..cf317ac5e0 100644
--- a/Kernel/Memory/PageDirectory.cpp
+++ b/Kernel/Memory/PageDirectory.cpp
@@ -15,7 +15,7 @@
extern u8 end_of_kernel_image[];
-namespace Kernel {
+namespace Kernel::Memory {
static AK::Singleton<HashMap<FlatPtr, PageDirectory*>> s_cr3_map;
diff --git a/Kernel/Memory/PageDirectory.h b/Kernel/Memory/PageDirectory.h
index 2caabdc79e..6963681046 100644
--- a/Kernel/Memory/PageDirectory.h
+++ b/Kernel/Memory/PageDirectory.h
@@ -13,7 +13,7 @@
#include <Kernel/Memory/PhysicalPage.h>
#include <Kernel/Memory/RangeAllocator.h>
-namespace Kernel {
+namespace Kernel::Memory {
class PageDirectory : public RefCounted<PageDirectory> {
friend class MemoryManager;
diff --git a/Kernel/Memory/PhysicalPage.cpp b/Kernel/Memory/PhysicalPage.cpp
index fda876dc0d..b4890b5c4a 100644
--- a/Kernel/Memory/PhysicalPage.cpp
+++ b/Kernel/Memory/PhysicalPage.cpp
@@ -8,7 +8,7 @@
#include <Kernel/Memory/MemoryManager.h>
#include <Kernel/Memory/PhysicalPage.h>
-namespace Kernel {
+namespace Kernel::Memory {
NonnullRefPtr<PhysicalPage> PhysicalPage::create(PhysicalAddress paddr, MayReturnToFreeList may_return_to_freelist)
{
diff --git a/Kernel/Memory/PhysicalPage.h b/Kernel/Memory/PhysicalPage.h
index ab22be3534..fe898c04a8 100644
--- a/Kernel/Memory/PhysicalPage.h
+++ b/Kernel/Memory/PhysicalPage.h
@@ -9,7 +9,7 @@
#include <AK/NonnullRefPtr.h>
#include <Kernel/PhysicalAddress.h>
-namespace Kernel {
+namespace Kernel::Memory {
enum class MayReturnToFreeList : bool {
No,
diff --git a/Kernel/Memory/PhysicalRegion.cpp b/Kernel/Memory/PhysicalRegion.cpp
index f778fdfa39..134e908d20 100644
--- a/Kernel/Memory/PhysicalRegion.cpp
+++ b/Kernel/Memory/PhysicalRegion.cpp
@@ -12,7 +12,7 @@
#include <Kernel/Memory/PhysicalZone.h>
#include <Kernel/Random.h>
-namespace Kernel {
+namespace Kernel::Memory {
static constexpr u32 next_power_of_two(u32 value)
{
diff --git a/Kernel/Memory/PhysicalRegion.h b/Kernel/Memory/PhysicalRegion.h
index ba7b4957b9..ec20e0029c 100644
--- a/Kernel/Memory/PhysicalRegion.h
+++ b/Kernel/Memory/PhysicalRegion.h
@@ -10,7 +10,7 @@
#include <Kernel/Memory/PhysicalPage.h>
#include <Kernel/Memory/PhysicalZone.h>
-namespace Kernel {
+namespace Kernel::Memory {
class PhysicalRegion {
AK_MAKE_ETERNAL;
diff --git a/Kernel/Memory/PhysicalZone.cpp b/Kernel/Memory/PhysicalZone.cpp
index 71cb9624ed..f533a20d17 100644
--- a/Kernel/Memory/PhysicalZone.cpp
+++ b/Kernel/Memory/PhysicalZone.cpp
@@ -9,7 +9,7 @@
#include <Kernel/Memory/PhysicalPage.h>
#include <Kernel/Memory/PhysicalZone.h>
-namespace Kernel {
+namespace Kernel::Memory {
PhysicalPageEntry& PhysicalZone::get_freelist_entry(ChunkIndex index) const
{
diff --git a/Kernel/Memory/PhysicalZone.h b/Kernel/Memory/PhysicalZone.h
index bd3bba924e..c5512f8f24 100644
--- a/Kernel/Memory/PhysicalZone.h
+++ b/Kernel/Memory/PhysicalZone.h
@@ -9,7 +9,7 @@
#include <AK/Bitmap.h>
#include <AK/IntrusiveList.h>
-namespace Kernel {
+namespace Kernel::Memory {
// A PhysicalZone is an allocator that manages a sub-area of a PhysicalRegion.
// Its total size is always a power of two.
diff --git a/Kernel/Memory/PrivateInodeVMObject.cpp b/Kernel/Memory/PrivateInodeVMObject.cpp
index 143b351c00..6c3b3e8258 100644
--- a/Kernel/Memory/PrivateInodeVMObject.cpp
+++ b/Kernel/Memory/PrivateInodeVMObject.cpp
@@ -7,7 +7,7 @@
#include <Kernel/FileSystem/Inode.h>
#include <Kernel/Memory/PrivateInodeVMObject.h>
-namespace Kernel {
+namespace Kernel::Memory {
RefPtr<PrivateInodeVMObject> PrivateInodeVMObject::try_create_with_inode(Inode& inode)
{
diff --git a/Kernel/Memory/PrivateInodeVMObject.h b/Kernel/Memory/PrivateInodeVMObject.h
index 5e8c8f1372..4d8438ac92 100644
--- a/Kernel/Memory/PrivateInodeVMObject.h
+++ b/Kernel/Memory/PrivateInodeVMObject.h
@@ -10,7 +10,7 @@
#include <Kernel/Memory/InodeVMObject.h>
#include <Kernel/UnixTypes.h>
-namespace Kernel {
+namespace Kernel::Memory {
class PrivateInodeVMObject final : public InodeVMObject {
AK_MAKE_NONMOVABLE(PrivateInodeVMObject);
diff --git a/Kernel/Memory/Range.cpp b/Kernel/Memory/Range.cpp
index 4b8ad0912d..ad5ebdc9ea 100644
--- a/Kernel/Memory/Range.cpp
+++ b/Kernel/Memory/Range.cpp
@@ -10,7 +10,7 @@
#include <Kernel/Memory/Range.h>
#include <LibC/limits.h>
-namespace Kernel {
+namespace Kernel::Memory {
Vector<Range, 2> Range::carve(const Range& taken) const
{
diff --git a/Kernel/Memory/Range.h b/Kernel/Memory/Range.h
index c2305acedc..41b206af12 100644
--- a/Kernel/Memory/Range.h
+++ b/Kernel/Memory/Range.h
@@ -10,7 +10,7 @@
#include <Kernel/KResult.h>
#include <Kernel/VirtualAddress.h>
-namespace Kernel {
+namespace Kernel::Memory {
class Range {
friend class RangeAllocator;
@@ -61,8 +61,8 @@ private:
}
template<>
-struct AK::Formatter<Kernel::Range> : Formatter<FormatString> {
- void format(FormatBuilder& builder, Kernel::Range value)
+struct AK::Formatter<Kernel::Memory::Range> : Formatter<FormatString> {
+ void format(FormatBuilder& builder, Kernel::Memory::Range value)
{
return Formatter<FormatString>::format(builder, "{} - {} (size {:p})", value.base().as_ptr(), value.base().offset(value.size() - 1).as_ptr(), value.size());
}
diff --git a/Kernel/Memory/RangeAllocator.cpp b/Kernel/Memory/RangeAllocator.cpp
index 2014c22e34..5f931222b0 100644
--- a/Kernel/Memory/RangeAllocator.cpp
+++ b/Kernel/Memory/RangeAllocator.cpp
@@ -10,7 +10,7 @@
#define VM_GUARD_PAGES
-namespace Kernel {
+namespace Kernel::Memory {
RangeAllocator::RangeAllocator()
: m_total_range({}, 0)
diff --git a/Kernel/Memory/RangeAllocator.h b/Kernel/Memory/RangeAllocator.h
index c299e08ef3..cc6bcf36bb 100644
--- a/Kernel/Memory/RangeAllocator.h
+++ b/Kernel/Memory/RangeAllocator.h
@@ -11,7 +11,7 @@
#include <Kernel/Memory/Range.h>
#include <Kernel/SpinLock.h>
-namespace Kernel {
+namespace Kernel::Memory {
class RangeAllocator {
public:
@@ -42,7 +42,7 @@ private:
namespace AK {
template<>
-struct Traits<Kernel::Range> : public GenericTraits<Kernel::Range> {
+struct Traits<Kernel::Memory::Range> : public GenericTraits<Kernel::Memory::Range> {
static constexpr bool is_trivial() { return true; }
};
}
diff --git a/Kernel/Memory/Region.cpp b/Kernel/Memory/Region.cpp
index 0c63bea8d0..f080d5b30e 100644
--- a/Kernel/Memory/Region.cpp
+++ b/Kernel/Memory/Region.cpp
@@ -17,7 +17,7 @@
#include <Kernel/Process.h>
#include <Kernel/Thread.h>
-namespace Kernel {
+namespace Kernel::Memory {
Region::Region(Range const& range, NonnullRefPtr<VMObject> vmobject, size_t offset_in_vmobject, OwnPtr<KString> name, Region::Access access, Cacheable cacheable, bool shared)
: m_range(range)
diff --git a/Kernel/Memory/Region.h b/Kernel/Memory/Region.h
index 38cecb474c..f4d1c7b300 100644
--- a/Kernel/Memory/Region.h
+++ b/Kernel/Memory/Region.h
@@ -18,7 +18,7 @@
#include <Kernel/Sections.h>
#include <Kernel/UnixTypes.h>
-namespace Kernel {
+namespace Kernel::Memory {
enum class ShouldFlushTLB {
No,
diff --git a/Kernel/Memory/RingBuffer.cpp b/Kernel/Memory/RingBuffer.cpp
index 9c62a53a9d..4f7ea2dddc 100644
--- a/Kernel/Memory/RingBuffer.cpp
+++ b/Kernel/Memory/RingBuffer.cpp
@@ -8,7 +8,7 @@
#include <Kernel/Memory/RingBuffer.h>
#include <Kernel/UserOrKernelBuffer.h>
-namespace Kernel {
+namespace Kernel::Memory {
RingBuffer::RingBuffer(String region_name, size_t capacity)
: m_region(MM.allocate_contiguous_kernel_region(page_round_up(capacity), move(region_name), Region::Access::Read | Region::Access::Write))
diff --git a/Kernel/Memory/RingBuffer.h b/Kernel/Memory/RingBuffer.h
index 8a748e4b65..58e4208a38 100644
--- a/Kernel/Memory/RingBuffer.h
+++ b/Kernel/Memory/RingBuffer.h
@@ -10,7 +10,7 @@
#include <Kernel/PhysicalAddress.h>
#include <Kernel/UserOrKernelBuffer.h>
-namespace Kernel {
+namespace Kernel::Memory {
class RingBuffer {
public:
@@ -30,7 +30,7 @@ public:
size_t bytes_till_end() const { return (m_capacity_in_bytes - ((m_start_of_used + m_num_used_bytes) % m_capacity_in_bytes)) % m_capacity_in_bytes; };
private:
- OwnPtr<Region> m_region;
+ OwnPtr<Memory::Region> m_region;
SpinLock<u8> m_lock;
size_t m_start_of_used {};
size_t m_num_used_bytes {};
diff --git a/Kernel/Memory/ScatterGatherList.cpp b/Kernel/Memory/ScatterGatherList.cpp
index c3b65f31df..3151417607 100644
--- a/Kernel/Memory/ScatterGatherList.cpp
+++ b/Kernel/Memory/ScatterGatherList.cpp
@@ -6,7 +6,7 @@
#include <Kernel/Memory/ScatterGatherList.h>
-namespace Kernel {
+namespace Kernel::Memory {
RefPtr<ScatterGatherList> ScatterGatherList::try_create(AsyncBlockDeviceRequest& request, Span<NonnullRefPtr<PhysicalPage>> allocated_pages, size_t device_block_size)
{
diff --git a/Kernel/Memory/ScatterGatherList.h b/Kernel/Memory/ScatterGatherList.h
index a94ce00b72..f90876957a 100644
--- a/Kernel/Memory/ScatterGatherList.h
+++ b/Kernel/Memory/ScatterGatherList.h
@@ -12,7 +12,7 @@
#include <Kernel/Memory/MemoryManager.h>
#include <Kernel/PhysicalAddress.h>
-namespace Kernel {
+namespace Kernel::Memory {
// A Scatter-Gather List type that owns its buffers
diff --git a/Kernel/Memory/SharedInodeVMObject.cpp b/Kernel/Memory/SharedInodeVMObject.cpp
index 1c8c7b2ae3..dd78f80208 100644
--- a/Kernel/Memory/SharedInodeVMObject.cpp
+++ b/Kernel/Memory/SharedInodeVMObject.cpp
@@ -7,7 +7,7 @@
#include <Kernel/FileSystem/Inode.h>
#include <Kernel/Memory/SharedInodeVMObject.h>
-namespace Kernel {
+namespace Kernel::Memory {
RefPtr<SharedInodeVMObject> SharedInodeVMObject::try_create_with_inode(Inode& inode)
{
diff --git a/Kernel/Memory/SharedInodeVMObject.h b/Kernel/Memory/SharedInodeVMObject.h
index 05fb8968eb..047d335074 100644
--- a/Kernel/Memory/SharedInodeVMObject.h
+++ b/Kernel/Memory/SharedInodeVMObject.h
@@ -10,7 +10,7 @@
#include <Kernel/Memory/InodeVMObject.h>
#include <Kernel/UnixTypes.h>
-namespace Kernel {
+namespace Kernel::Memory {
class SharedInodeVMObject final : public InodeVMObject {
AK_MAKE_NONMOVABLE(SharedInodeVMObject);
diff --git a/Kernel/Memory/Space.cpp b/Kernel/Memory/Space.cpp
index 63fcf1814f..dfb6a56a2a 100644
--- a/Kernel/Memory/Space.cpp
+++ b/Kernel/Memory/Space.cpp
@@ -13,7 +13,7 @@
#include <Kernel/Process.h>
#include <Kernel/SpinLock.h>
-namespace Kernel {
+namespace Kernel::Memory {
OwnPtr<Space> Space::try_create(Process& process, Space const* parent)
{
diff --git a/Kernel/Memory/Space.h b/Kernel/Memory/Space.h
index cdd8d51a01..5cfb7e5530 100644
--- a/Kernel/Memory/Space.h
+++ b/Kernel/Memory/Space.h
@@ -14,7 +14,7 @@
#include <Kernel/Memory/PageDirectory.h>
#include <Kernel/UnixTypes.h>
-namespace Kernel {
+namespace Kernel::Memory {
class Space {
public:
diff --git a/Kernel/Memory/TypedMapping.h b/Kernel/Memory/TypedMapping.h
index ebc9c33770..22ac69992b 100644
--- a/Kernel/Memory/TypedMapping.h
+++ b/Kernel/Memory/TypedMapping.h
@@ -9,7 +9,7 @@
#include <AK/StringView.h>
#include <Kernel/Memory/MemoryManager.h>
-namespace Kernel {
+namespace Kernel::Memory {
template<typename T>
struct TypedMapping {
diff --git a/Kernel/Memory/VMObject.cpp b/Kernel/Memory/VMObject.cpp
index b5e0459d48..0ca76d0e31 100644
--- a/Kernel/Memory/VMObject.cpp
+++ b/Kernel/Memory/VMObject.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -7,7 +7,7 @@
#include <Kernel/Memory/MemoryManager.h>
#include <Kernel/Memory/VMObject.h>
-namespace Kernel {
+namespace Kernel::Memory {
VMObject::VMObject(VMObject const& other)
: m_physical_pages(other.m_physical_pages)
diff --git a/Kernel/Memory/VMObject.h b/Kernel/Memory/VMObject.h
index 0184533325..7cdd29cb2b 100644
--- a/Kernel/Memory/VMObject.h
+++ b/Kernel/Memory/VMObject.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -17,7 +17,7 @@
#include <Kernel/Memory/Region.h>
#include <Kernel/Mutex.h>
-namespace Kernel {
+namespace Kernel::Memory {
class VMObjectDeletedHandler {
public:
diff --git a/Kernel/Net/E1000ENetworkAdapter.cpp b/Kernel/Net/E1000ENetworkAdapter.cpp
index 385ff6cffc..54d1593a47 100644
--- a/Kernel/Net/E1000ENetworkAdapter.cpp
+++ b/Kernel/Net/E1000ENetworkAdapter.cpp
@@ -204,7 +204,7 @@ UNMAP_AFTER_INIT bool E1000ENetworkAdapter::initialize()
enable_bus_mastering(pci_address());
size_t mmio_base_size = PCI::get_BAR_space_size(pci_address(), 0);
- m_mmio_region = MM.allocate_kernel_region(PhysicalAddress(page_base_of(PCI::get_BAR0(pci_address()))), page_round_up(mmio_base_size), "E1000e MMIO", Region::Access::Read | Region::Access::Write, Region::Cacheable::No);
+ m_mmio_region = MM.allocate_kernel_region(PhysicalAddress(page_base_of(PCI::get_BAR0(pci_address()))), Memory::page_round_up(mmio_base_size), "E1000e MMIO", Memory::Region::Access::Read | Memory::Region::Access::Write, Memory::Region::Cacheable::No);
if (!m_mmio_region)
return false;
m_mmio_base = m_mmio_region->vaddr();
diff --git a/Kernel/Net/E1000NetworkAdapter.cpp b/Kernel/Net/E1000NetworkAdapter.cpp
index 568715ecce..f3389aba4b 100644
--- a/Kernel/Net/E1000NetworkAdapter.cpp
+++ b/Kernel/Net/E1000NetworkAdapter.cpp
@@ -195,7 +195,7 @@ UNMAP_AFTER_INIT bool E1000NetworkAdapter::initialize()
m_io_base = IOAddress(PCI::get_BAR1(pci_address()) & ~1);
size_t mmio_base_size = PCI::get_BAR_space_size(pci_address(), 0);
- m_mmio_region = MM.allocate_kernel_region(PhysicalAddress(page_base_of(PCI::get_BAR0(pci_address()))), page_round_up(mmio_base_size), "E1000 MMIO", Region::Access::Read | Region::Access::Write, Region::Cacheable::No);
+ m_mmio_region = MM.allocate_kernel_region(PhysicalAddress(page_base_of(PCI::get_BAR0(pci_address()))), Memory::page_round_up(mmio_base_size), "E1000 MMIO", Memory::Region::Access::Read | Memory::Region::Access::Write, Memory::Region::Cacheable::No);
if (!m_mmio_region)
return false;
m_mmio_base = m_mmio_region->vaddr();
@@ -221,8 +221,8 @@ UNMAP_AFTER_INIT bool E1000NetworkAdapter::initialize()
UNMAP_AFTER_INIT E1000NetworkAdapter::E1000NetworkAdapter(PCI::Address address, u8 irq)
: PCI::Device(address, irq)
- , m_rx_descriptors_region(MM.allocate_contiguous_kernel_region(page_round_up(sizeof(e1000_rx_desc) * number_of_rx_descriptors + 16), "E1000 RX Descriptors", Region::Access::Read | Region::Access::Write))
- , m_tx_descriptors_region(MM.allocate_contiguous_kernel_region(page_round_up(sizeof(e1000_tx_desc) * number_of_tx_descriptors + 16), "E1000 TX Descriptors", Region::Access::Read | Region::Access::Write))
+ , m_rx_descriptors_region(MM.allocate_contiguous_kernel_region(Memory::page_round_up(sizeof(e1000_rx_desc) * number_of_rx_descriptors + 16), "E1000 RX Descriptors", Memory::Region::Access::Read | Memory::Region::Access::Write))
+ , m_tx_descriptors_region(MM.allocate_contiguous_kernel_region(Memory::page_round_up(sizeof(e1000_tx_desc) * number_of_tx_descriptors + 16), "E1000 TX Descriptors", Memory::Region::Access::Read | Memory::Region::Access::Write))
{
set_interface_name(pci_address());
}
@@ -320,7 +320,7 @@ UNMAP_AFTER_INIT void E1000NetworkAdapter::initialize_rx_descriptors()
constexpr auto rx_buffer_size = 8192;
constexpr auto rx_buffer_page_count = rx_buffer_size / PAGE_SIZE;
- m_rx_buffer_region = MM.allocate_contiguous_kernel_region(rx_buffer_size * number_of_rx_descriptors, "E1000 RX buffers", Region::Access::Read | Region::Access::Write);
+ m_rx_buffer_region = MM.allocate_contiguous_kernel_region(rx_buffer_size * number_of_rx_descriptors, "E1000 RX buffers", Memory::Region::Access::Read | Memory::Region::Access::Write);
for (size_t i = 0; i < number_of_rx_descriptors; ++i) {
auto& descriptor = rx_descriptors[i];
m_rx_buffers[i] = m_rx_buffer_region->vaddr().as_ptr() + rx_buffer_size * i;
@@ -343,7 +343,7 @@ UNMAP_AFTER_INIT void E1000NetworkAdapter::initialize_tx_descriptors()
constexpr auto tx_buffer_size = 8192;
constexpr auto tx_buffer_page_count = tx_buffer_size / PAGE_SIZE;
- m_tx_buffer_region = MM.allocate_contiguous_kernel_region(tx_buffer_size * number_of_tx_descriptors, "E1000 TX buffers", Region::Access::Read | Region::Access::Write);
+ m_tx_buffer_region = MM.allocate_contiguous_kernel_region(tx_buffer_size * number_of_tx_descriptors, "E1000 TX buffers", Memory::Region::Access::Read | Memory::Region::Access::Write);
for (size_t i = 0; i < number_of_tx_descriptors; ++i) {
auto& descriptor = tx_descriptors[i];
diff --git a/Kernel/Net/E1000NetworkAdapter.h b/Kernel/Net/E1000NetworkAdapter.h
index 2475d4d144..dad0f45ebf 100644
--- a/Kernel/Net/E1000NetworkAdapter.h
+++ b/Kernel/Net/E1000NetworkAdapter.h
@@ -83,13 +83,13 @@ protected:
IOAddress m_io_base;
VirtualAddress m_mmio_base;
- OwnPtr<Region> m_rx_descriptors_region;
- OwnPtr<Region> m_tx_descriptors_region;
- OwnPtr<Region> m_rx_buffer_region;
- OwnPtr<Region> m_tx_buffer_region;
+ OwnPtr<Memory::Region> m_rx_descriptors_region;
+ OwnPtr<Memory::Region> m_tx_descriptors_region;
+ OwnPtr<Memory::Region> m_rx_buffer_region;
+ OwnPtr<Memory::Region> m_tx_buffer_region;
Array<void*, number_of_rx_descriptors> m_rx_buffers;
Array<void*, number_of_tx_descriptors> m_tx_buffers;
- OwnPtr<Region> m_mmio_region;
+ OwnPtr<Memory::Region> m_mmio_region;
u8 m_interrupt_line { 0 };
bool m_has_eeprom { false };
bool m_use_mmio { false };
diff --git a/Kernel/Net/NetworkAdapter.cpp b/Kernel/Net/NetworkAdapter.cpp
index 194a471c49..8ad76a234a 100644
--- a/Kernel/Net/NetworkAdapter.cpp
+++ b/Kernel/Net/NetworkAdapter.cpp
@@ -112,7 +112,7 @@ RefPtr<PacketWithTimestamp> NetworkAdapter::acquire_packet_buffer(size_t size)
{
InterruptDisabler disabler;
if (m_unused_packets.is_empty()) {
- auto buffer = KBuffer::try_create_with_size(size, Region::Access::Read | Region::Access::Write, "Packet Buffer", AllocationStrategy::AllocateNow);
+ auto buffer = KBuffer::try_create_with_size(size, Memory::Region::Access::Read | Memory::Region::Access::Write, "Packet Buffer", AllocationStrategy::AllocateNow);
if (!buffer)
return {};
auto packet = adopt_ref_if_nonnull(new (nothrow) PacketWithTimestamp { buffer.release_nonnull(), kgettimeofday() });
@@ -129,7 +129,7 @@ RefPtr<PacketWithTimestamp> NetworkAdapter::acquire_packet_buffer(size_t size)
return packet;
}
- auto buffer = KBuffer::try_create_with_size(size, Region::Access::Read | Region::Access::Write, "Packet Buffer", AllocationStrategy::AllocateNow);
+ auto buffer = KBuffer::try_create_with_size(size, Memory::Region::Access::Read | Memory::Region::Access::Write, "Packet Buffer", AllocationStrategy::AllocateNow);
if (!buffer)
return {};
packet = adopt_ref_if_nonnull(new (nothrow) PacketWithTimestamp { buffer.release_nonnull(), kgettimeofday() });
diff --git a/Kernel/Net/NetworkTask.cpp b/Kernel/Net/NetworkTask.cpp
index 04b3d4d71e..143763c3d9 100644
--- a/Kernel/Net/NetworkTask.cpp
+++ b/Kernel/Net/NetworkTask.cpp
@@ -87,7 +87,7 @@ void NetworkTask_main(void*)
};
size_t buffer_size = 64 * KiB;
- auto buffer_region = MM.allocate_kernel_region(buffer_size, "Kernel Packet Buffer", Region::Access::Read | Region::Access::Write);
+ auto buffer_region = MM.allocate_kernel_region(buffer_size, "Kernel Packet Buffer", Memory::Region::Access::Read | Memory::Region::Access::Write);
auto buffer = (u8*)buffer_region->vaddr().get();
Time packet_timestamp;
diff --git a/Kernel/Net/RTL8139NetworkAdapter.cpp b/Kernel/Net/RTL8139NetworkAdapter.cpp
index be85fdf511..6778bf3b24 100644
--- a/Kernel/Net/RTL8139NetworkAdapter.cpp
+++ b/Kernel/Net/RTL8139NetworkAdapter.cpp
@@ -124,8 +124,8 @@ UNMAP_AFTER_INIT RefPtr<RTL8139NetworkAdapter> RTL8139NetworkAdapter::try_to_ini
UNMAP_AFTER_INIT RTL8139NetworkAdapter::RTL8139NetworkAdapter(PCI::Address address, u8 irq)
: PCI::Device(address, irq)
, m_io_base(PCI::get_BAR0(pci_address()) & ~1)
- , m_rx_buffer(MM.allocate_contiguous_kernel_region(page_round_up(RX_BUFFER_SIZE + PACKET_SIZE_MAX), "RTL8139 RX", Region::Access::Read | Region::Access::Write))
- , m_packet_buffer(MM.allocate_contiguous_kernel_region(page_round_up(PACKET_SIZE_MAX), "RTL8139 Packet buffer", Region::Access::Read | Region::Access::Write))
+ , m_rx_buffer(MM.allocate_contiguous_kernel_region(Memory::page_round_up(RX_BUFFER_SIZE + PACKET_SIZE_MAX), "RTL8139 RX", Memory::Region::Access::Read | Memory::Region::Access::Write))
+ , m_packet_buffer(MM.allocate_contiguous_kernel_region(Memory::page_round_up(PACKET_SIZE_MAX), "RTL8139 Packet buffer", Memory::Region::Access::Read | Memory::Region::Access::Write))
{
m_tx_buffers.ensure_capacity(RTL8139_TX_BUFFER_COUNT);
set_interface_name(address);
@@ -144,7 +144,7 @@ UNMAP_AFTER_INIT RTL8139NetworkAdapter::RTL8139NetworkAdapter(PCI::Address addre
dbgln("RTL8139: RX buffer: {}", m_rx_buffer->physical_page(0)->paddr());
for (int i = 0; i < RTL8139_TX_BUFFER_COUNT; i++) {
- m_tx_buffers.append(MM.allocate_contiguous_kernel_region(page_round_up(TX_BUFFER_SIZE), "RTL8139 TX", Region::Access::Write | Region::Access::Read));
+ m_tx_buffers.append(MM.allocate_contiguous_kernel_region(Memory::page_round_up(TX_BUFFER_SIZE), "RTL8139 TX", Memory::Region::Access::Write | Memory::Region::Access::Read));
dbgln("RTL8139: TX buffer {}: {}", i, m_tx_buffers[i]->physical_page(0)->paddr());
}
diff --git a/Kernel/Net/RTL8139NetworkAdapter.h b/Kernel/Net/RTL8139NetworkAdapter.h
index d42e6a505e..988402af84 100644
--- a/Kernel/Net/RTL8139NetworkAdapter.h
+++ b/Kernel/Net/RTL8139NetworkAdapter.h
@@ -50,11 +50,11 @@ private:
IOAddress m_io_base;
u8 m_interrupt_line { 0 };
- OwnPtr<Region> m_rx_buffer;
+ OwnPtr<Memory::Region> m_rx_buffer;
u16 m_rx_buffer_offset { 0 };
- Vector<OwnPtr<Region>> m_tx_buffers;
+ Vector<OwnPtr<Memory::Region>> m_tx_buffers;
u8 m_tx_next_buffer { 0 };
- OwnPtr<Region> m_packet_buffer;
+ OwnPtr<Memory::Region> m_packet_buffer;
bool m_link_up { false };
EntropySource m_entropy_source;
};
diff --git a/Kernel/Net/RTL8168NetworkAdapter.cpp b/Kernel/Net/RTL8168NetworkAdapter.cpp
index 6563e6555f..6020999205 100644
--- a/Kernel/Net/RTL8168NetworkAdapter.cpp
+++ b/Kernel/Net/RTL8168NetworkAdapter.cpp
@@ -194,8 +194,8 @@ UNMAP_AFTER_INIT RefPtr<RTL8168NetworkAdapter> RTL8168NetworkAdapter::try_to_ini
UNMAP_AFTER_INIT RTL8168NetworkAdapter::RTL8168NetworkAdapter(PCI::Address address, u8 irq)
: PCI::Device(address, irq)
, m_io_base(PCI::get_BAR0(pci_address()) & ~1)
- , m_rx_descriptors_region(MM.allocate_contiguous_kernel_region(page_round_up(sizeof(TXDescriptor) * (number_of_rx_descriptors + 1)), "RTL8168 RX", Region::Access::Read | Region::Access::Write))
- , m_tx_descriptors_region(MM.allocate_contiguous_kernel_region(page_round_up(sizeof(RXDescriptor) * (number_of_tx_descriptors + 1)), "RTL8168 TX", Region::Access::Read | Region::Access::Write))
+ , m_rx_descriptors_region(MM.allocate_contiguous_kernel_region(Memory::page_round_up(sizeof(TXDescriptor) * (number_of_rx_descriptors + 1)), "RTL8168 RX", Memory::Region::Access::Read | Memory::Region::Access::Write))
+ , m_tx_descriptors_region(MM.allocate_contiguous_kernel_region(Memory::page_round_up(sizeof(RXDescriptor) * (number_of_tx_descriptors + 1)), "RTL8168 TX", Memory::Region::Access::Read | Memory::Region::Access::Write))
{
set_interface_name(address);
@@ -1042,7 +1042,7 @@ UNMAP_AFTER_INIT void RTL8168NetworkAdapter::initialize_rx_descriptors()
auto* rx_descriptors = (RXDescriptor*)m_rx_descriptors_region->vaddr().as_ptr();
for (size_t i = 0; i < number_of_rx_descriptors; ++i) {
auto& descriptor = rx_descriptors[i];
- auto region = MM.allocate_contiguous_kernel_region(page_round_up(RX_BUFFER_SIZE), "RTL8168 RX buffer", Region::Access::Read | Region::Access::Write);
+ auto region = MM.allocate_contiguous_kernel_region(Memory::page_round_up(RX_BUFFER_SIZE), "RTL8168 RX buffer", Memory::Region::Access::Read | Memory::Region::Access::Write);
VERIFY(region);
memset(region->vaddr().as_ptr(), 0, region->size()); // MM already zeros out newly allocated pages, but we do it again in case that ever changes
m_rx_buffers_regions.append(region.release_nonnull());
@@ -1061,7 +1061,7 @@ UNMAP_AFTER_INIT void RTL8168NetworkAdapter::initialize_tx_descriptors()
auto* tx_descriptors = (TXDescriptor*)m_tx_descriptors_region->vaddr().as_ptr();
for (size_t i = 0; i < number_of_tx_descriptors; ++i) {
auto& descriptor = tx_descriptors[i];
- auto region = MM.allocate_contiguous_kernel_region(page_round_up(TX_BUFFER_SIZE), "RTL8168 TX buffer", Region::Access::Read | Region::Access::Write);
+ auto region = MM.allocate_contiguous_kernel_region(Memory::page_round_up(TX_BUFFER_SIZE), "RTL8168 TX buffer", Memory::Region::Access::Read | Memory::Region::Access::Write);
VERIFY(region);
memset(region->vaddr().as_ptr(), 0, region->size()); // MM already zeros out newly allocated pages, but we do it again in case that ever changes
m_tx_buffers_regions.append(region.release_nonnull());
diff --git a/Kernel/Net/RTL8168NetworkAdapter.h b/Kernel/Net/RTL8168NetworkAdapter.h
index ae71976fc9..cc4d8497dd 100644
--- a/Kernel/Net/RTL8168NetworkAdapter.h
+++ b/Kernel/Net/RTL8168NetworkAdapter.h
@@ -197,11 +197,11 @@ private:
bool m_version_uncertain { true };
IOAddress m_io_base;
u32 m_ocp_base_address { 0 };
- OwnPtr<Region> m_rx_descriptors_region;
- NonnullOwnPtrVector<Region> m_rx_buffers_regions;
+ OwnPtr<Memory::Region> m_rx_descriptors_region;
+ NonnullOwnPtrVector<Memory::Region> m_rx_buffers_regions;
u16 m_rx_free_index { 0 };
- OwnPtr<Region> m_tx_descriptors_region;
- NonnullOwnPtrVector<Region> m_tx_buffers_regions;
+ OwnPtr<Memory::Region> m_tx_descriptors_region;
+ NonnullOwnPtrVector<Memory::Region> m_tx_buffers_regions;
u16 m_tx_free_index { 0 };
bool m_link_up { false };
EntropySource m_entropy_source;
diff --git a/Kernel/PerformanceEventBuffer.cpp b/Kernel/PerformanceEventBuffer.cpp
index 0e329212e7..da5a95be92 100644
--- a/Kernel/PerformanceEventBuffer.cpp
+++ b/Kernel/PerformanceEventBuffer.cpp
@@ -253,7 +253,7 @@ bool PerformanceEventBuffer::to_json(KBufferBuilder& builder) const
OwnPtr<PerformanceEventBuffer> PerformanceEventBuffer::try_create_with_size(size_t buffer_size)
{
- auto buffer = KBuffer::try_create_with_size(buffer_size, Region::Access::Read | Region::Access::Write, "Performance events", AllocationStrategy::AllocateNow);
+ auto buffer = KBuffer::try_create_with_size(buffer_size, Memory::Region::Access::Read | Memory::Region::Access::Write, "Performance events", AllocationStrategy::AllocateNow);
if (!buffer)
return {};
return adopt_own_if_nonnull(new (nothrow) PerformanceEventBuffer(buffer.release_nonnull()));
diff --git a/Kernel/PerformanceManager.h b/Kernel/PerformanceManager.h
index caa7940c0e..dda2dbf75c 100644
--- a/Kernel/PerformanceManager.h
+++ b/Kernel/PerformanceManager.h
@@ -67,14 +67,14 @@ public:
}
}
- inline static void add_mmap_perf_event(Process& current_process, Region const& region)
+ inline static void add_mmap_perf_event(Process& current_process, Memory::Region const& region)
{
if (auto* event_buffer = current_process.current_perf_events_buffer()) {
[[maybe_unused]] auto res = event_buffer->append(PERF_EVENT_MMAP, region.vaddr().get(), region.size(), region.name());
}
}
- inline static void add_unmap_perf_event(Process& current_process, Range const& region)
+ inline static void add_unmap_perf_event(Process& current_process, Memory::Range const& region)
{
if (auto* event_buffer = current_process.current_perf_events_buffer()) {
[[maybe_unused]] auto res = event_buffer->append(PERF_EVENT_MUNMAP, region.base().get(), region.size(), nullptr);
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index e0a4f799a6..f2ebe0ac4a 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -48,7 +48,7 @@ READONLY_AFTER_INIT Process::List* g_processes;
READONLY_AFTER_INIT String* g_hostname;
READONLY_AFTER_INIT Mutex* g_hostname_lock;
READONLY_AFTER_INIT HashMap<String, OwnPtr<Module>>* g_modules;
-READONLY_AFTER_INIT Region* g_signal_trampoline_region;
+READONLY_AFTER_INIT Memory::Region* g_signal_trampoline_region;
ProcessID Process::allocate_pid()
{
@@ -267,7 +267,7 @@ Process::Process(const String& name, uid_t uid, gid_t gid, ProcessID ppid, bool
KResult Process::attach_resources(RefPtr<Thread>& first_thread, Process* fork_parent)
{
- m_space = Space::try_create(*this, fork_parent ? &fork_parent->space() : nullptr);
+ m_space = Memory::Space::try_create(*this, fork_parent ? &fork_parent->space() : nullptr);
if (!m_space)
return ENOMEM;
@@ -361,7 +361,7 @@ extern "C" char const asm_signal_trampoline_end[];
void create_signal_trampoline()
{
// NOTE: We leak this region.
- g_signal_trampoline_region = MM.allocate_kernel_region(PAGE_SIZE, "Signal trampolines", Region::Access::Read | Region::Access::Write).leak_ptr();
+ g_signal_trampoline_region = MM.allocate_kernel_region(PAGE_SIZE, "Signal trampolines", Memory::Region::Access::Read | Memory::Region::Access::Write).leak_ptr();
g_signal_trampoline_region->set_syscall_region(true);
size_t trampoline_size = asm_signal_trampoline_end - asm_signal_trampoline;
diff --git a/Kernel/Process.h b/Kernel/Process.h
index b252fa702b..eef1c5c765 100644
--- a/Kernel/Process.h
+++ b/Kernel/Process.h
@@ -515,8 +515,8 @@ public:
PerformanceEventBuffer* perf_events() { return m_perf_event_buffer; }
- Space& space() { return *m_space; }
- const Space& space() const { return *m_space; }
+ Memory::Space& space() { return *m_space; }
+ Memory::Space const& space() const { return *m_space; }
VirtualAddress signal_trampoline() const { return m_signal_trampoline; }
@@ -582,7 +582,7 @@ private:
String m_name;
- OwnPtr<Space> m_space;
+ OwnPtr<Memory::Space> m_space;
RefPtr<ProcessGroup> m_pg;
@@ -741,7 +741,7 @@ private:
RefPtr<TTY> m_tty;
- WeakPtr<Region> m_master_tls_region;
+ WeakPtr<Memory::Region> m_master_tls_region;
size_t m_master_tls_size { 0 };
size_t m_master_tls_alignment { 0 };
diff --git a/Kernel/ProcessSpecificExposed.cpp b/Kernel/ProcessSpecificExposed.cpp
index 046dd88032..9685cfd33a 100644
--- a/Kernel/ProcessSpecificExposed.cpp
+++ b/Kernel/ProcessSpecificExposed.cpp
@@ -37,7 +37,7 @@ private:
bool show_kernel_addresses = Process::current()->is_superuser();
bool kernel_address_added = false;
for (auto address : Processor::capture_stack_trace(*m_associated_thread, 1024)) {
- if (!show_kernel_addresses && !is_user_address(VirtualAddress { address })) {
+ if (!show_kernel_addresses && !Memory::is_user_address(VirtualAddress { address })) {
if (kernel_address_added)
continue;
address = 0xdeadc0de;
@@ -456,7 +456,7 @@ private:
region_object.add("syscall", region->is_syscall_region());
region_object.add("purgeable", region->vmobject().is_anonymous());
if (region->vmobject().is_anonymous()) {
- region_object.add("volatile", static_cast<AnonymousVMObject const&>(region->vmobject()).is_volatile());
+ region_object.add("volatile", static_cast<Memory::AnonymousVMObject const&>(region->vmobject()).is_volatile());
}
region_object.add("cacheable", region->is_cacheable());
region_object.add("address", region->vaddr().get());
diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp
index f84415d26d..1c833fbc35 100644
--- a/Kernel/Scheduler.cpp
+++ b/Kernel/Scheduler.cpp
@@ -272,8 +272,8 @@ bool Scheduler::yield()
bool Scheduler::context_switch(Thread* thread)
{
- if (s_mm_lock.own_lock()) {
- PANIC("In context switch while holding s_mm_lock");
+ if (Memory::s_mm_lock.own_lock()) {
+ PANIC("In context switch while holding Memory::s_mm_lock");
}
thread->did_schedule();
diff --git a/Kernel/StdLib.cpp b/Kernel/StdLib.cpp
index c4460918d3..838dd01465 100644
--- a/Kernel/StdLib.cpp
+++ b/Kernel/StdLib.cpp
@@ -15,7 +15,7 @@
String copy_string_from_user(const char* user_str, size_t user_str_size)
{
- bool is_user = Kernel::is_user_range(VirtualAddress(user_str), user_str_size);
+ bool is_user = Kernel::Memory::is_user_range(VirtualAddress(user_str), user_str_size);
if (!is_user)
return {};
Kernel::SmapDisabler disabler;
@@ -44,7 +44,7 @@ String copy_string_from_user(Userspace<const char*> user_str, size_t user_str_si
Kernel::KResultOr<NonnullOwnPtr<Kernel::KString>> try_copy_kstring_from_user(const char* user_str, size_t user_str_size)
{
- bool is_user = Kernel::is_user_range(VirtualAddress(user_str), user_str_size);
+ bool is_user = Kernel::Memory::is_user_range(VirtualAddress(user_str), user_str_size);
if (!is_user)
return EFAULT;
Kernel::SmapDisabler disabler;
@@ -106,7 +106,7 @@ Optional<u32> user_atomic_fetch_add_relaxed(volatile u32* var, u32 val)
{
if (FlatPtr(var) & 3)
return {}; // not aligned!
- bool is_user = Kernel::is_user_range(VirtualAddress(FlatPtr(var)), sizeof(*var));
+ bool is_user = Kernel::Memory::is_user_range(VirtualAddress(FlatPtr(var)), sizeof(*var));
if (!is_user)
return {};
Kernel::SmapDisabler disabler;
@@ -117,7 +117,7 @@ Optional<u32> user_atomic_exchange_relaxed(volatile u32* var, u32 val)
{
if (FlatPtr(var) & 3)
return {}; // not aligned!
- bool is_user = Kernel::is_user_range(VirtualAddress(FlatPtr(var)), sizeof(*var));
+ bool is_user = Kernel::Memory::is_user_range(VirtualAddress(FlatPtr(var)), sizeof(*var));
if (!is_user)
return {};
Kernel::SmapDisabler disabler;
@@ -128,7 +128,7 @@ Optional<u32> user_atomic_load_relaxed(volatile u32* var)
{
if (FlatPtr(var) & 3)
return {}; // not aligned!
- bool is_user = Kernel::is_user_range(VirtualAddress(FlatPtr(var)), sizeof(*var));
+ bool is_user = Kernel::Memory::is_user_range(VirtualAddress(FlatPtr(var)), sizeof(*var));
if (!is_user)
return {};
Kernel::SmapDisabler disabler;
@@ -139,7 +139,7 @@ bool user_atomic_store_relaxed(volatile u32* var, u32 val)
{
if (FlatPtr(var) & 3)
return false; // not aligned!
- bool is_user = Kernel::is_user_range(VirtualAddress(FlatPtr(var)), sizeof(*var));
+ bool is_user = Kernel::Memory::is_user_range(VirtualAddress(FlatPtr(var)), sizeof(*var));
if (!is_user)
return false;
Kernel::SmapDisabler disabler;
@@ -150,8 +150,8 @@ Optional<bool> user_atomic_compare_exchange_relaxed(volatile u32* var, u32& expe
{
if (FlatPtr(var) & 3)
return {}; // not aligned!
- VERIFY(!Kernel::is_user_range(VirtualAddress(&expected), sizeof(expected)));
- bool is_user = Kernel::is_user_range(VirtualAddress(FlatPtr(var)), sizeof(*var));
+ VERIFY(!Kernel::Memory::is_user_range(VirtualAddress(&expected), sizeof(expected)));
+ bool is_user = Kernel::Memory::is_user_range(VirtualAddress(FlatPtr(var)), sizeof(*var));
if (!is_user)
return {};
Kernel::SmapDisabler disabler;
@@ -162,7 +162,7 @@ Optional<u32> user_atomic_fetch_and_relaxed(volatile u32* var, u32 val)
{
if (FlatPtr(var) & 3)
return {}; // not aligned!
- bool is_user = Kernel::is_user_range(VirtualAddress(FlatPtr(var)), sizeof(*var));
+ bool is_user = Kernel::Memory::is_user_range(VirtualAddress(FlatPtr(var)), sizeof(*var));
if (!is_user)
return {};
Kernel::SmapDisabler disabler;
@@ -173,7 +173,7 @@ Optional<u32> user_atomic_fetch_and_not_relaxed(volatile u32* var, u32 val)
{
if (FlatPtr(var) & 3)
return {}; // not aligned!
- bool is_user = Kernel::is_user_range(VirtualAddress(FlatPtr(var)), sizeof(*var));
+ bool is_user = Kernel::Memory::is_user_range(VirtualAddress(FlatPtr(var)), sizeof(*var));
if (!is_user)
return {};
Kernel::SmapDisabler disabler;
@@ -184,7 +184,7 @@ Optional<u32> user_atomic_fetch_or_relaxed(volatile u32* var, u32 val)
{
if (FlatPtr(var) & 3)
return {}; // not aligned!
- bool is_user = Kernel::is_user_range(VirtualAddress(FlatPtr(var)), sizeof(*var));
+ bool is_user = Kernel::Memory::is_user_range(VirtualAddress(FlatPtr(var)), sizeof(*var));
if (!is_user)
return {};
Kernel::SmapDisabler disabler;
@@ -195,7 +195,7 @@ Optional<u32> user_atomic_fetch_xor_relaxed(volatile u32* var, u32 val)
{
if (FlatPtr(var) & 3)
return {}; // not aligned!
- bool is_user = Kernel::is_user_range(VirtualAddress(FlatPtr(var)), sizeof(*var));
+ bool is_user = Kernel::Memory::is_user_range(VirtualAddress(FlatPtr(var)), sizeof(*var));
if (!is_user)
return {};
Kernel::SmapDisabler disabler;
@@ -206,10 +206,10 @@ extern "C" {
bool copy_to_user(void* dest_ptr, const void* src_ptr, size_t n)
{
- bool is_user = Kernel::is_user_range(VirtualAddress(dest_ptr), n);
+ bool is_user = Kernel::Memory::is_user_range(VirtualAddress(dest_ptr), n);
if (!is_user)
return false;
- VERIFY(!Kernel::is_user_range(VirtualAddress(src_ptr), n));
+ VERIFY(!Kernel::Memory::is_user_range(VirtualAddress(src_ptr), n));
Kernel::SmapDisabler disabler;
void* fault_at;
if (!Kernel::safe_memcpy(dest_ptr, src_ptr, n, fault_at)) {
@@ -222,10 +222,10 @@ bool copy_to_user(void* dest_ptr, const void* src_ptr, size_t n)
bool copy_from_user(void* dest_ptr, const void* src_ptr, size_t n)
{
- bool is_user = Kernel::is_user_range(VirtualAddress(src_ptr), n);
+ bool is_user = Kernel::Memory::is_user_range(VirtualAddress(src_ptr), n);
if (!is_user)
return false;
- VERIFY(!Kernel::is_user_range(VirtualAddress(dest_ptr), n));
+ VERIFY(!Kernel::Memory::is_user_range(VirtualAddress(dest_ptr), n));
Kernel::SmapDisabler disabler;
void* fault_at;
if (!Kernel::safe_memcpy(dest_ptr, src_ptr, n, fault_at)) {
@@ -243,7 +243,7 @@ const void* memmem(const void* haystack, size_t haystack_length, const void* nee
[[nodiscard]] bool memset_user(void* dest_ptr, int c, size_t n)
{
- bool is_user = Kernel::is_user_range(VirtualAddress(dest_ptr), n);
+ bool is_user = Kernel::Memory::is_user_range(VirtualAddress(dest_ptr), n);
if (!is_user)
return false;
Kernel::SmapDisabler disabler;
diff --git a/Kernel/Storage/AHCIController.cpp b/Kernel/Storage/AHCIController.cpp
index f71172592d..038f178f60 100644
--- a/Kernel/Storage/AHCIController.cpp
+++ b/Kernel/Storage/AHCIController.cpp
@@ -124,9 +124,9 @@ AHCI::HBADefinedCapabilities AHCIController::capabilities() const
};
}
-NonnullOwnPtr<Region> AHCIController::default_hba_region() const
+NonnullOwnPtr<Memory::Region> AHCIController::default_hba_region() const
{
- auto region = MM.allocate_kernel_region(PhysicalAddress(PCI::get_BAR5(pci_address())).page_base(), page_round_up(sizeof(AHCI::HBA)), "AHCI HBA", Region::Access::Read | Region::Access::Write);
+ auto region = MM.allocate_kernel_region(PhysicalAddress(PCI::get_BAR5(pci_address())).page_base(), Memory::page_round_up(sizeof(AHCI::HBA)), "AHCI HBA", Memory::Region::Access::Read | Memory::Region::Access::Write);
return region.release_nonnull();
}
diff --git a/Kernel/Storage/AHCIController.h b/Kernel/Storage/AHCIController.h
index f873ddd15f..a51ad85f38 100644
--- a/Kernel/Storage/AHCIController.h
+++ b/Kernel/Storage/AHCIController.h
@@ -48,10 +48,10 @@ private:
RefPtr<StorageDevice> device_by_port(u32 index) const;
volatile AHCI::PortRegisters& port(size_t port_number) const;
- UNMAP_AFTER_INIT NonnullOwnPtr<Region> default_hba_region() const;
+ UNMAP_AFTER_INIT NonnullOwnPtr<Memory::Region> default_hba_region() const;
volatile AHCI::HBA& hba() const;
- NonnullOwnPtr<Region> m_hba_region;
+ NonnullOwnPtr<Memory::Region> m_hba_region;
AHCI::HBADefinedCapabilities m_capabilities;
NonnullRefPtrVector<AHCIPortHandler> m_handlers;
};
diff --git a/Kernel/Storage/AHCIPort.cpp b/Kernel/Storage/AHCIPort.cpp
index e0fd9fb542..dcfb83a52c 100644
--- a/Kernel/Storage/AHCIPort.cpp
+++ b/Kernel/Storage/AHCIPort.cpp
@@ -50,7 +50,7 @@ AHCIPort::AHCIPort(const AHCIPortHandler& handler, volatile AHCI::PortRegisters&
for (size_t index = 0; index < 1; index++) {
m_command_table_pages.append(MM.allocate_supervisor_physical_page().release_nonnull());
}
- m_command_list_region = MM.allocate_kernel_region(m_command_list_page->paddr(), PAGE_SIZE, "AHCI Port Command List", Region::Access::Read | Region::Access::Write, Region::Cacheable::No);
+ m_command_list_region = MM.allocate_kernel_region(m_command_list_page->paddr(), PAGE_SIZE, "AHCI Port Command List", Memory::Region::Access::Read | Memory::Region::Access::Write, Memory::Region::Cacheable::No);
dbgln_if(AHCI_DEBUG, "AHCI Port {}: Command list region at {}", representative_port_index(), m_command_list_region->vaddr());
}
@@ -159,7 +159,7 @@ void AHCIPort::eject()
// handshake error bit in PxSERR register if CFL is incorrect.
command_list_entries[unused_command_header.value()].attributes = (size_t)FIS::DwordCount::RegisterHostToDevice | AHCI::CommandHeaderAttributes::P | AHCI::CommandHeaderAttributes::C | AHCI::CommandHeaderAttributes::A;
- auto command_table_region = MM.allocate_kernel_region(m_command_table_pages[unused_command_header.value()].paddr().page_base(), page_round_up(sizeof(AHCI::CommandTable)), "AHCI Command Table", Region::Access::Read | Region::Access::Write, Region::Cacheable::No);
+ auto command_table_region = MM.allocate_kernel_region(m_command_table_pages[unused_command_header.value()].paddr().page_base(), Memory::page_round_up(sizeof(AHCI::CommandTable)), "AHCI Command Table", Memory::Region::Access::Read | Memory::Region::Access::Write, Memory::Region::Cacheable::No);
auto& command_table = *(volatile AHCI::CommandTable*)command_table_region->vaddr().as_ptr();
memset(const_cast<u8*>(command_table.command_fis), 0, 64);
auto& fis = *(volatile FIS::HostToDevice::Register*)command_table.command_fis;
@@ -268,7 +268,7 @@ bool AHCIPort::initialize(ScopedSpinLock<SpinLock<u8>>& main_lock)
size_t physical_sector_size = 512;
u64 max_addressable_sector = 0;
if (identify_device(main_lock)) {
- auto identify_block = map_typed<ATAIdentifyBlock>(m_parent_handler->get_identify_metadata_physical_region(m_port_index));
+ auto identify_block = Memory::map_typed<ATAIdentifyBlock>(m_parent_handler->get_identify_metadata_physical_region(m_port_index));
// Check if word 106 is valid before using it!
if ((identify_block->physical_sector_size_to_logical_sector_size >> 14) == 1) {
if (identify_block->physical_sector_size_to_logical_sector_size & (1 << 12)) {
@@ -422,7 +422,7 @@ void AHCIPort::set_sleep_state() const
size_t AHCIPort::calculate_descriptors_count(size_t block_count) const
{
VERIFY(m_connected_device);
- size_t needed_dma_regions_count = page_round_up((block_count * m_connected_device->block_size())) / PAGE_SIZE;
+ size_t needed_dma_regions_count = Memory::page_round_up((block_count * m_connected_device->block_size())) / PAGE_SIZE;
VERIFY(needed_dma_regions_count <= m_dma_buffers.size());
return needed_dma_regions_count;
}
@@ -432,12 +432,12 @@ Optional<AsyncDeviceRequest::RequestResult> AHCIPort::prepare_and_set_scatter_li
VERIFY(m_lock.is_locked());
VERIFY(request.block_count() > 0);
- NonnullRefPtrVector<PhysicalPage> allocated_dma_regions;
+ NonnullRefPtrVector<Memory::PhysicalPage> allocated_dma_regions;
for (size_t index = 0; index < calculate_descriptors_count(request.block_count()); index++) {
allocated_dma_regions.append(m_dma_buffers.at(index));
}
- m_current_scatter_list = ScatterGatherList::try_create(request, allocated_dma_regions.span(), m_connected_device->block_size());
+ m_current_scatter_list = Memory::ScatterGatherList::try_create(request, allocated_dma_regions.span(), m_connected_device->block_size());
if (!m_current_scatter_list)
return AsyncDeviceRequest::Failure;
if (request.request_type() == AsyncBlockDeviceRequest::Write) {
@@ -526,7 +526,7 @@ bool AHCIPort::access_device(AsyncBlockDeviceRequest::RequestType direction, u64
dbgln_if(AHCI_DEBUG, "AHCI Port {}: CLE: ctba={:#08x}, ctbau={:#08x}, prdbc={:#08x}, prdtl={:#04x}, attributes={:#04x}", representative_port_index(), (u32)command_list_entries[unused_command_header.value()].ctba, (u32)command_list_entries[unused_command_header.value()].ctbau, (u32)command_list_entries[unused_command_header.value()].prdbc, (u16)command_list_entries[unused_command_header.value()].prdtl, (u16)command_list_entries[unused_command_header.value()].attributes);
- auto command_table_region = MM.allocate_kernel_region(m_command_table_pages[unused_command_header.value()].paddr().page_base(), page_round_up(sizeof(AHCI::CommandTable)), "AHCI Command Table", Region::Access::Read | Region::Access::Write, Region::Cacheable::No);
+ auto command_table_region = MM.allocate_kernel_region(m_command_table_pages[unused_command_header.value()].paddr().page_base(), Memory::page_round_up(sizeof(AHCI::CommandTable)), "AHCI Command Table", Memory::Region::Access::Read | Memory::Region::Access::Write, Memory::Region::Cacheable::No);
auto& command_table = *(volatile AHCI::CommandTable*)command_table_region->vaddr().as_ptr();
dbgln_if(AHCI_DEBUG, "AHCI Port {}: Allocated command table at {}", representative_port_index(), command_table_region->vaddr());
@@ -610,7 +610,7 @@ bool AHCIPort::identify_device(ScopedSpinLock<SpinLock<u8>>& main_lock)
// QEMU doesn't care if we don't set the correct CFL field in this register, real hardware will set an handshake error bit in PxSERR register.
command_list_entries[unused_command_header.value()].attributes = (size_t)FIS::DwordCount::RegisterHostToDevice | AHCI::CommandHeaderAttributes::P;
- auto command_table_region = MM.allocate_kernel_region(m_command_table_pages[unused_command_header.value()].paddr().page_base(), page_round_up(sizeof(AHCI::CommandTable)), "AHCI Command Table", Region::Access::Read | Region::Access::Write);
+ auto command_table_region = MM.allocate_kernel_region(m_command_table_pages[unused_command_header.value()].paddr().page_base(), Memory::page_round_up(sizeof(AHCI::CommandTable)), "AHCI Command Table", Memory::Region::Access::Read | Memory::Region::Access::Write);
auto& command_table = *(volatile AHCI::CommandTable*)command_table_region->vaddr().as_ptr();
memset(const_cast<u8*>(command_table.command_fis), 0, 64);
command_table.descriptors[0].base_high = 0;
diff --git a/Kernel/Storage/AHCIPort.h b/Kernel/Storage/AHCIPort.h
index 488b095b12..fb7ffdc9b2 100644
--- a/Kernel/Storage/AHCIPort.h
+++ b/Kernel/Storage/AHCIPort.h
@@ -107,11 +107,11 @@ private:
mutable bool m_wait_for_completion { false };
bool m_wait_connect_for_completion { false };
- NonnullRefPtrVector<PhysicalPage> m_dma_buffers;
- NonnullRefPtrVector<PhysicalPage> m_command_table_pages;
- RefPtr<PhysicalPage> m_command_list_page;
- OwnPtr<Region> m_command_list_region;
- RefPtr<PhysicalPage> m_fis_receive_page;
+ NonnullRefPtrVector<Memory::PhysicalPage> m_dma_buffers;
+ NonnullRefPtrVector<Memory::PhysicalPage> m_command_table_pages;
+ RefPtr<Memory::PhysicalPage> m_command_list_page;
+ OwnPtr<Memory::Region> m_command_list_region;
+ RefPtr<Memory::PhysicalPage> m_fis_receive_page;
RefPtr<StorageDevice> m_connected_device;
u32 m_port_index;
@@ -120,7 +120,7 @@ private:
AHCI::PortInterruptStatusBitField m_interrupt_status;
AHCI::PortInterruptEnableBitField m_interrupt_enable;
- RefPtr<ScatterGatherList> m_current_scatter_list;
+ RefPtr<Memory::ScatterGatherList> m_current_scatter_list;
bool m_disabled_by_firmware { false };
};
}
diff --git a/Kernel/Storage/AHCIPortHandler.h b/Kernel/Storage/AHCIPortHandler.h
index d717eb740a..227dc8ae9c 100644
--- a/Kernel/Storage/AHCIPortHandler.h
+++ b/Kernel/Storage/AHCIPortHandler.h
@@ -66,7 +66,7 @@ private:
// Data members
HashMap<u32, NonnullRefPtr<AHCIPort>> m_handled_ports;
NonnullRefPtr<AHCIController> m_parent_controller;
- NonnullRefPtrVector<PhysicalPage> m_identify_metadata_pages;
+ NonnullRefPtrVector<Memory::PhysicalPage> m_identify_metadata_pages;
AHCI::MaskedBitField m_taken_ports;
AHCI::MaskedBitField m_pending_ports_interrupts;
};
diff --git a/Kernel/Storage/BMIDEChannel.cpp b/Kernel/Storage/BMIDEChannel.cpp
index cbbb6ecced..c35151f7fe 100644
--- a/Kernel/Storage/BMIDEChannel.cpp
+++ b/Kernel/Storage/BMIDEChannel.cpp
@@ -43,8 +43,8 @@ UNMAP_AFTER_INIT void BMIDEChannel::initialize()
m_dma_buffer_page = MM.allocate_supervisor_physical_page();
if (m_dma_buffer_page.is_null() || m_prdt_page.is_null())
return;
- m_prdt_region = MM.allocate_kernel_region(m_prdt_page->paddr(), PAGE_SIZE, "IDE PRDT", Region::Access::Read | Region::Access::Write);
- m_dma_buffer_region = MM.allocate_kernel_region(m_dma_buffer_page->paddr(), PAGE_SIZE, "IDE DMA region", Region::Access::Read | Region::Access::Write);
+ m_prdt_region = MM.allocate_kernel_region(m_prdt_page->paddr(), PAGE_SIZE, "IDE PRDT", Memory::Region::Access::Read | Memory::Region::Access::Write);
+ m_dma_buffer_region = MM.allocate_kernel_region(m_dma_buffer_page->paddr(), PAGE_SIZE, "IDE DMA region", Memory::Region::Access::Read | Memory::Region::Access::Write);
prdt().end_of_table = 0x8000;
// clear bus master interrupt status
diff --git a/Kernel/Storage/BMIDEChannel.h b/Kernel/Storage/BMIDEChannel.h
index 7810212d73..c72e0a3da5 100644
--- a/Kernel/Storage/BMIDEChannel.h
+++ b/Kernel/Storage/BMIDEChannel.h
@@ -47,9 +47,9 @@ private:
virtual void ata_write_sectors(bool, u16) override;
PhysicalRegionDescriptor& prdt() { return *reinterpret_cast<PhysicalRegionDescriptor*>(m_prdt_region->vaddr().as_ptr()); }
- OwnPtr<Region> m_prdt_region;
- OwnPtr<Region> m_dma_buffer_region;
- RefPtr<PhysicalPage> m_prdt_page;
- RefPtr<PhysicalPage> m_dma_buffer_page;
+ OwnPtr<Memory::Region> m_prdt_region;
+ OwnPtr<Memory::Region> m_dma_buffer_region;
+ RefPtr<Memory::PhysicalPage> m_prdt_page;
+ RefPtr<Memory::PhysicalPage> m_dma_buffer_page;
};
}
diff --git a/Kernel/Storage/RamdiskController.cpp b/Kernel/Storage/RamdiskController.cpp
index 69e61b31f1..dca4f083d7 100644
--- a/Kernel/Storage/RamdiskController.cpp
+++ b/Kernel/Storage/RamdiskController.cpp
@@ -46,10 +46,10 @@ RamdiskController::RamdiskController()
{
// Populate ramdisk controllers from Multiboot boot modules, if any.
size_t count = 0;
- for (auto& used_memory_range : MemoryManager::the().used_memory_ranges()) {
- if (used_memory_range.type == UsedMemoryRangeType::BootModule) {
- size_t length = page_round_up(used_memory_range.end.get()) - used_memory_range.start.get();
- auto region = MemoryManager::the().allocate_kernel_region(used_memory_range.start, length, "Ramdisk", Region::Access::Read | Region::Access::Write);
+ for (auto& used_memory_range : MM.used_memory_ranges()) {
+ if (used_memory_range.type == Memory::UsedMemoryRangeType::BootModule) {
+ size_t length = Memory::page_round_up(used_memory_range.end.get()) - used_memory_range.start.get();
+ auto region = MM.allocate_kernel_region(used_memory_range.start, length, "Ramdisk", Memory::Region::Access::Read | Memory::Region::Access::Write);
if (!region)
dmesgln("RamdiskController: Failed to allocate kernel region of size {}", length);
else
diff --git a/Kernel/Storage/RamdiskDevice.cpp b/Kernel/Storage/RamdiskDevice.cpp
index 992b0cfece..8b962df4d6 100644
--- a/Kernel/Storage/RamdiskDevice.cpp
+++ b/Kernel/Storage/RamdiskDevice.cpp
@@ -12,12 +12,12 @@
namespace Kernel {
-NonnullRefPtr<RamdiskDevice> RamdiskDevice::create(const RamdiskController& controller, NonnullOwnPtr<Region>&& region, int major, int minor)
+NonnullRefPtr<RamdiskDevice> RamdiskDevice::create(const RamdiskController& controller, NonnullOwnPtr<Memory::Region>&& region, int major, int minor)
{
return adopt_ref(*new RamdiskDevice(controller, move(region), major, minor));
}
-RamdiskDevice::RamdiskDevice(const RamdiskController& controller, NonnullOwnPtr<Region>&& region, int major, int minor)
+RamdiskDevice::RamdiskDevice(const RamdiskController& controller, NonnullOwnPtr<Memory::Region>&& region, int major, int minor)
: StorageDevice(controller, major, minor, 512, region->size() / 512)
, m_region(move(region))
{
diff --git a/Kernel/Storage/RamdiskDevice.h b/Kernel/Storage/RamdiskDevice.h
index 41b5b4f3be..12d3d39b3f 100644
--- a/Kernel/Storage/RamdiskDevice.h
+++ b/Kernel/Storage/RamdiskDevice.h
@@ -17,8 +17,8 @@ class RamdiskDevice final : public StorageDevice {
friend class RamdiskController;
AK_MAKE_ETERNAL
public:
- static NonnullRefPtr<RamdiskDevice> create(const RamdiskController&, NonnullOwnPtr<Region>&& region, int major, int minor);
- RamdiskDevice(const RamdiskController&, NonnullOwnPtr<Region>&&, int major, int minor);
+ static NonnullRefPtr<RamdiskDevice> create(const RamdiskController&, NonnullOwnPtr<Memory::Region>&& region, int major, int minor);
+ RamdiskDevice(const RamdiskController&, NonnullOwnPtr<Memory::Region>&&, int major, int minor);
virtual ~RamdiskDevice() override;
// ^BlockDevice
@@ -32,7 +32,7 @@ public:
Mutex m_lock { "RamdiskDevice" };
- NonnullOwnPtr<Region> m_region;
+ NonnullOwnPtr<Memory::Region> m_region;
};
}
diff --git a/Kernel/Syscalls/anon_create.cpp b/Kernel/Syscalls/anon_create.cpp
index 2308d75aff..6e3e252202 100644
--- a/Kernel/Syscalls/anon_create.cpp
+++ b/Kernel/Syscalls/anon_create.cpp
@@ -29,7 +29,7 @@ KResultOr<FlatPtr> Process::sys$anon_create(size_t size, int options)
if (new_fd_or_error.is_error())
return new_fd_or_error.error();
auto new_fd = new_fd_or_error.release_value();
- auto vmobject = AnonymousVMObject::try_create_purgeable_with_size(size, AllocationStrategy::Reserve);
+ auto vmobject = Memory::AnonymousVMObject::try_create_purgeable_with_size(size, AllocationStrategy::Reserve);
if (!vmobject)
return ENOMEM;
diff --git a/Kernel/Syscalls/execve.cpp b/Kernel/Syscalls/execve.cpp
index 7f401837e9..a8b4b10807 100644
--- a/Kernel/Syscalls/execve.cpp
+++ b/Kernel/Syscalls/execve.cpp
@@ -27,17 +27,17 @@
namespace Kernel {
-extern Region* g_signal_trampoline_region;
+extern Memory::Region* g_signal_trampoline_region;
struct LoadResult {
- OwnPtr<Space> space;
+ OwnPtr<Memory::Space> space;
FlatPtr load_base { 0 };
FlatPtr entry_eip { 0 };
size_t size { 0 };
- WeakPtr<Region> tls_region;
+ WeakPtr<Memory::Region> tls_region;
size_t tls_size { 0 };
size_t tls_alignment { 0 };
- WeakPtr<Region> stack_region;
+ WeakPtr<Memory::Region> stack_region;
};
static Vector<ELF::AuxiliaryValue> generate_auxiliary_vector(FlatPtr load_base, FlatPtr entry_eip, uid_t uid, uid_t euid, gid_t gid, gid_t egid, String executable_path, int main_program_fd);
@@ -68,7 +68,7 @@ static bool validate_stack_size(const Vector<String>& arguments, const Vector<St
return true;
}
-static KResultOr<FlatPtr> make_userspace_context_for_main_thread([[maybe_unused]] ThreadRegisters& regs, Region& region, Vector<String> arguments,
+static KResultOr<FlatPtr> make_userspace_context_for_main_thread([[maybe_unused]] ThreadRegisters& regs, Memory::Region& region, Vector<String> arguments,
Vector<String> environment, Vector<ELF::AuxiliaryValue> auxiliary_values)
{
FlatPtr new_sp = region.range().end().get();
@@ -162,7 +162,7 @@ struct RequiredLoadRange {
static KResultOr<RequiredLoadRange> get_required_load_range(FileDescription& program_description)
{
auto& inode = *(program_description.inode());
- auto vmobject = SharedInodeVMObject::try_create_with_inode(inode);
+ auto vmobject = Memory::SharedInodeVMObject::try_create_with_inode(inode);
if (!vmobject) {
dbgln("get_required_load_range: Unable to allocate SharedInodeVMObject");
return ENOMEM;
@@ -170,7 +170,7 @@ static KResultOr<RequiredLoadRange> get_required_load_range(FileDescription& pro
size_t executable_size = inode.size();
- auto region = MM.allocate_kernel_region_with_vmobject(*vmobject, page_round_up(executable_size), "ELF memory range calculation", Region::Access::Read);
+ auto region = MM.allocate_kernel_region_with_vmobject(*vmobject, Memory::page_round_up(executable_size), "ELF memory range calculation", Memory::Region::Access::Read);
if (!region) {
dbgln("Could not allocate memory for ELF");
return ENOMEM;
@@ -205,7 +205,7 @@ static KResultOr<FlatPtr> get_load_offset(const ElfW(Ehdr) & main_program_header
constexpr FlatPtr minimum_load_offset_randomization_size = 10 * MiB;
auto random_load_offset_in_range([](auto start, auto size) {
- return page_round_down(start + get_good_random<FlatPtr>() % size);
+ return Memory::page_round_down(start + get_good_random<FlatPtr>() % size);
});
if (main_program_header.e_type == ET_DYN) {
@@ -263,11 +263,11 @@ enum class ShouldAllowSyscalls {
Yes,
};
-static KResultOr<LoadResult> load_elf_object(NonnullOwnPtr<Space> new_space, FileDescription& object_description,
+static KResultOr<LoadResult> load_elf_object(NonnullOwnPtr<Memory::Space> new_space, FileDescription& object_description,
FlatPtr load_offset, ShouldAllocateTls should_allocate_tls, ShouldAllowSyscalls should_allow_syscalls)
{
auto& inode = *(object_description.inode());
- auto vmobject = SharedInodeVMObject::try_create_with_inode(inode);
+ auto vmobject = Memory::SharedInodeVMObject::try_create_with_inode(inode);
if (!vmobject) {
dbgln("load_elf_object: Unable to allocate SharedInodeVMObject");
return ENOMEM;
@@ -280,7 +280,7 @@ static KResultOr<LoadResult> load_elf_object(NonnullOwnPtr<Space> new_space, Fil
size_t executable_size = inode.size();
- auto executable_region = MM.allocate_kernel_region_with_vmobject(*vmobject, page_round_up(executable_size), "ELF loading", Region::Access::Read);
+ auto executable_region = MM.allocate_kernel_region_with_vmobject(*vmobject, Memory::page_round_up(executable_size), "ELF loading", Memory::Region::Access::Read);
if (!executable_region) {
dbgln("Could not allocate memory for ELF loading");
return ENOMEM;
@@ -291,7 +291,7 @@ static KResultOr<LoadResult> load_elf_object(NonnullOwnPtr<Space> new_space, Fil
if (!elf_image.is_valid())
return ENOEXEC;
- Region* master_tls_region { nullptr };
+ Memory::Region* master_tls_region { nullptr };
size_t master_tls_size = 0;
size_t master_tls_alignment = 0;
FlatPtr load_base_address = 0;
@@ -299,7 +299,7 @@ static KResultOr<LoadResult> load_elf_object(NonnullOwnPtr<Space> new_space, Fil
String elf_name = object_description.absolute_path();
VERIFY(!Processor::current().in_critical());
- MemoryManager::enter_space(*new_space);
+ Memory::MemoryManager::enter_space(*new_space);
KResult ph_load_result = KSuccess;
elf_image.for_each_program_header([&](const ELF::Image::ProgramHeader& program_header) {
@@ -356,8 +356,8 @@ static KResultOr<LoadResult> load_elf_object(NonnullOwnPtr<Space> new_space, Fil
prot |= PROT_WRITE;
auto region_name = String::formatted("{} (data-{}{})", elf_name, program_header.is_readable() ? "r" : "", program_header.is_writable() ? "w" : "");
- auto range_base = VirtualAddress { page_round_down(program_header.vaddr().offset(load_offset).get()) };
- auto range_end = VirtualAddress { page_round_up(program_header.vaddr().offset(load_offset).offset(program_header.size_in_memory()).get()) };
+ auto range_base = VirtualAddress { Memory::page_round_down(program_header.vaddr().offset(load_offset).get()) };
+ auto range_end = VirtualAddress { Memory::page_round_up(program_header.vaddr().offset(load_offset).offset(program_header.size_in_memory()).get()) };
auto range = new_space->allocate_range(range_base, range_end.get() - range_base.get());
if (!range.has_value()) {
@@ -397,8 +397,8 @@ static KResultOr<LoadResult> load_elf_object(NonnullOwnPtr<Space> new_space, Fil
if (program_header.is_executable())
prot |= PROT_EXEC;
- auto range_base = VirtualAddress { page_round_down(program_header.vaddr().offset(load_offset).get()) };
- auto range_end = VirtualAddress { page_round_up(program_header.vaddr().offset(load_offset).offset(program_header.size_in_memory()).get()) };
+ auto range_base = VirtualAddress { Memory::page_round_down(program_header.vaddr().offset(load_offset).get()) };
+ auto range_end = VirtualAddress { Memory::page_round_up(program_header.vaddr().offset(load_offset).offset(program_header.size_in_memory()).get()) };
auto range = new_space->allocate_range(range_base, range_end.get() - range_base.get());
if (!range.has_value()) {
ph_load_result = ENOMEM;
@@ -453,12 +453,12 @@ static KResultOr<LoadResult> load_elf_object(NonnullOwnPtr<Space> new_space, Fil
KResultOr<LoadResult> Process::load(NonnullRefPtr<FileDescription> main_program_description,
RefPtr<FileDescription> interpreter_description, const ElfW(Ehdr) & main_program_header)
{
- auto new_space = Space::try_create(*this, nullptr);
+ auto new_space = Memory::Space::try_create(*this, nullptr);
if (!new_space)
return ENOMEM;
ScopeGuard space_guard([&]() {
- MemoryManager::enter_process_paging_scope(*this);
+ Memory::MemoryManager::enter_process_paging_scope(*this);
});
auto load_offset = get_load_offset(main_program_header, main_program_description, interpreter_description);
@@ -560,7 +560,7 @@ KResult Process::do_exec(NonnullRefPtr<FileDescription> main_program_description
TemporaryChange global_profiling_disabler(g_profiling_all_threads, false);
m_space = load_result.space.release_nonnull();
}
- MemoryManager::enter_space(*m_space);
+ Memory::MemoryManager::enter_space(*m_space);
auto signal_trampoline_region = m_space->allocate_region_with_vmobject(signal_trampoline_range.value(), g_signal_trampoline_region->vmobject(), 0, "Signal trampoline", PROT_READ | PROT_EXEC, true);
if (signal_trampoline_region.is_error()) {
diff --git a/Kernel/Syscalls/fork.cpp b/Kernel/Syscalls/fork.cpp
index fdb6074230..a36135b776 100644
--- a/Kernel/Syscalls/fork.cpp
+++ b/Kernel/Syscalls/fork.cpp
@@ -108,7 +108,7 @@ KResultOr<FlatPtr> Process::sys$fork(RegisterState& regs)
// TODO: tear down new process?
return ENOMEM;
}
- child_region->map(child->space().page_directory(), ShouldFlushTLB::No);
+ child_region->map(child->space().page_directory(), Memory::ShouldFlushTLB::No);
if (region == m_master_tls_region.unsafe_ptr())
child->m_master_tls_region = child_region;
diff --git a/Kernel/Syscalls/futex.cpp b/Kernel/Syscalls/futex.cpp
index 637cb6742b..2f43ce4f68 100644
--- a/Kernel/Syscalls/futex.cpp
+++ b/Kernel/Syscalls/futex.cpp
@@ -12,9 +12,9 @@
namespace Kernel {
static SpinLock<u8> g_global_futex_lock;
-static AK::Singleton<HashMap<VMObject*, FutexQueues>> g_global_futex_queues;
+static AK::Singleton<HashMap<Memory::VMObject*, FutexQueues>> g_global_futex_queues;
-FutexQueue::FutexQueue(FlatPtr user_address_or_offset, VMObject* vmobject)
+FutexQueue::FutexQueue(FlatPtr user_address_or_offset, Memory::VMObject* vmobject)
: m_user_address_or_offset(user_address_or_offset)
, m_is_global(vmobject != nullptr)
{
@@ -40,7 +40,7 @@ FutexQueue::~FutexQueue()
m_is_global ? " (global)" : " (local)");
}
-void FutexQueue::vmobject_deleted(VMObject& vmobject)
+void FutexQueue::vmobject_deleted(Memory::VMObject& vmobject)
{
VERIFY(m_is_global); // If we got called we must be a global futex
// Because we're taking ourselves out of the global queue, we need
@@ -127,9 +127,9 @@ KResultOr<FlatPtr> Process::sys$futex(Userspace<const Syscall::SC_futex_params*>
// If this is a global lock, look up the underlying VMObject *before*
// acquiring the queue lock
- RefPtr<VMObject> vmobject, vmobject2;
+ RefPtr<Memory::VMObject> vmobject, vmobject2;
if (!is_private) {
- auto region = space().find_region_containing(Range { VirtualAddress { user_address_or_offset }, sizeof(u32) });
+ auto region = space().find_region_containing(Memory::Range { VirtualAddress { user_address_or_offset }, sizeof(u32) });
if (!region)
return EFAULT;
vmobject = region->vmobject();
@@ -139,7 +139,7 @@ KResultOr<FlatPtr> Process::sys$futex(Userspace<const Syscall::SC_futex_params*>
case FUTEX_REQUEUE:
case FUTEX_CMP_REQUEUE:
case FUTEX_WAKE_OP: {
- auto region2 = space().find_region_containing(Range { VirtualAddress { user_address_or_offset2 }, sizeof(u32) });
+ auto region2 = space().find_region_containing(Memory::Range { VirtualAddress { user_address_or_offset2 }, sizeof(u32) });
if (!region2)
return EFAULT;
vmobject2 = region2->vmobject();
@@ -149,7 +149,7 @@ KResultOr<FlatPtr> Process::sys$futex(Userspace<const Syscall::SC_futex_params*>
}
}
- auto find_global_futex_queues = [&](VMObject& vmobject, bool create_if_not_found) -> FutexQueues* {
+ auto find_global_futex_queues = [&](Memory::VMObject& vmobject, bool create_if_not_found) -> FutexQueues* {
auto& global_queues = *g_global_futex_queues;
auto it = global_queues.find(&vmobject);
if (it != global_queues.end())
@@ -165,7 +165,7 @@ KResultOr<FlatPtr> Process::sys$futex(Userspace<const Syscall::SC_futex_params*>
return nullptr;
};
- auto find_futex_queue = [&](VMObject* vmobject, FlatPtr user_address_or_offset, bool create_if_not_found, bool* did_create = nullptr) -> RefPtr<FutexQueue> {
+ auto find_futex_queue = [&](Memory::VMObject* vmobject, FlatPtr user_address_or_offset, bool create_if_not_found, bool* did_create = nullptr) -> RefPtr<FutexQueue> {
VERIFY(is_private || vmobject);
VERIFY(!create_if_not_found || did_create != nullptr);
auto* queues = is_private ? &m_futex_queues : find_global_futex_queues(*vmobject, create_if_not_found);
@@ -184,7 +184,7 @@ KResultOr<FlatPtr> Process::sys$futex(Userspace<const Syscall::SC_futex_params*>
return {};
};
- auto remove_futex_queue = [&](VMObject* vmobject, FlatPtr user_address_or_offset) {
+ auto remove_futex_queue = [&](Memory::VMObject* vmobject, FlatPtr user_address_or_offset) {
auto* queues = is_private ? &m_futex_queues : find_global_futex_queues(*vmobject, false);
if (queues) {
if (auto it = queues->find(user_address_or_offset); it != queues->end()) {
@@ -198,7 +198,7 @@ KResultOr<FlatPtr> Process::sys$futex(Userspace<const Syscall::SC_futex_params*>
}
};
- auto do_wake = [&](VMObject* vmobject, FlatPtr user_address_or_offset, u32 count, Optional<u32> bitmask) -> int {
+ auto do_wake = [&](Memory::VMObject* vmobject, FlatPtr user_address_or_offset, u32 count, Optional<u32> bitmask) -> int {
if (count == 0)
return 0;
ScopedSpinLock lock(queue_lock);
diff --git a/Kernel/Syscalls/get_stack_bounds.cpp b/Kernel/Syscalls/get_stack_bounds.cpp
index f27e041dd9..7c680c008c 100644
--- a/Kernel/Syscalls/get_stack_bounds.cpp
+++ b/Kernel/Syscalls/get_stack_bounds.cpp
@@ -14,7 +14,7 @@ KResultOr<FlatPtr> Process::sys$get_stack_bounds(Userspace<FlatPtr*> user_stack_
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this);
auto& regs = Thread::current()->get_register_dump_from_stack();
FlatPtr stack_pointer = regs.userspace_sp();
- auto* stack_region = space().find_region_containing(Range { VirtualAddress(stack_pointer), 1 });
+ auto* stack_region = space().find_region_containing(Memory::Range { VirtualAddress(stack_pointer), 1 });
// The syscall handler should have killed us if we had an invalid stack pointer.
VERIFY(stack_region);
diff --git a/Kernel/Syscalls/mmap.cpp b/Kernel/Syscalls/mmap.cpp
index 2e85b1a7b3..aeab526447 100644
--- a/Kernel/Syscalls/mmap.cpp
+++ b/Kernel/Syscalls/mmap.cpp
@@ -23,7 +23,7 @@
namespace Kernel {
-static bool should_make_executable_exception_for_dynamic_loader(bool make_readable, bool make_writable, bool make_executable, const Region& region)
+static bool should_make_executable_exception_for_dynamic_loader(bool make_readable, bool make_writable, bool make_executable, Memory::Region const& region)
{
// Normally we don't allow W -> X transitions, but we have to make an exception
// for the dynamic loader, which needs to do this after performing text relocations.
@@ -48,7 +48,7 @@ static bool should_make_executable_exception_for_dynamic_loader(bool make_readab
if (!region.vmobject().is_private_inode())
return false;
- auto& inode_vm = static_cast<const InodeVMObject&>(region.vmobject());
+ auto& inode_vm = static_cast<Memory::InodeVMObject const&>(region.vmobject());
auto& inode = inode_vm.inode();
ElfW(Ehdr) header;
@@ -69,7 +69,7 @@ static bool should_make_executable_exception_for_dynamic_loader(bool make_readab
return true;
}
-static bool validate_mmap_prot(int prot, bool map_stack, bool map_anonymous, const Region* region = nullptr)
+static bool validate_mmap_prot(int prot, bool map_stack, bool map_anonymous, Memory::Region const* region = nullptr)
{
bool make_readable = prot & PROT_READ;
bool make_writable = prot & PROT_WRITE;
@@ -154,10 +154,10 @@ KResultOr<FlatPtr> Process::sys$mmap(Userspace<const Syscall::SC_mmap_params*> u
if (alignment & ~PAGE_MASK)
return EINVAL;
- if (page_round_up_would_wrap(size))
+ if (Memory::page_round_up_would_wrap(size))
return EINVAL;
- if (!is_user_range(VirtualAddress(addr), page_round_up(size)))
+ if (!Memory::is_user_range(VirtualAddress(addr), Memory::page_round_up(size)))
return EFAULT;
OwnPtr<KString> name;
@@ -198,11 +198,11 @@ KResultOr<FlatPtr> Process::sys$mmap(Userspace<const Syscall::SC_mmap_params*> u
if (map_stack && (!map_private || !map_anonymous))
return EINVAL;
- Region* region = nullptr;
- Optional<Range> range;
+ Memory::Region* region = nullptr;
+ Optional<Memory::Range> range;
if (map_randomized) {
- range = space().page_directory().range_allocator().allocate_randomized(page_round_up(size), alignment);
+ range = space().page_directory().range_allocator().allocate_randomized(Memory::page_round_up(size), alignment);
} else {
range = space().allocate_range(VirtualAddress(addr), size, alignment);
if (!range.has_value()) {
@@ -218,11 +218,11 @@ KResultOr<FlatPtr> Process::sys$mmap(Userspace<const Syscall::SC_mmap_params*> u
if (map_anonymous) {
auto strategy = map_noreserve ? AllocationStrategy::None : AllocationStrategy::Reserve;
- RefPtr<AnonymousVMObject> vmobject;
+ RefPtr<Memory::AnonymousVMObject> vmobject;
if (flags & MAP_PURGEABLE)
- vmobject = AnonymousVMObject::try_create_purgeable_with_size(page_round_up(size), strategy);
+ vmobject = Memory::AnonymousVMObject::try_create_purgeable_with_size(Memory::page_round_up(size), strategy);
else
- vmobject = AnonymousVMObject::try_create_with_size(page_round_up(size), strategy);
+ vmobject = Memory::AnonymousVMObject::try_create_with_size(Memory::page_round_up(size), strategy);
if (!vmobject)
return ENOMEM;
auto region_or_error = space().allocate_region_with_vmobject(range.value(), vmobject.release_nonnull(), 0, {}, prot, map_shared);
@@ -272,21 +272,21 @@ KResultOr<FlatPtr> Process::sys$mmap(Userspace<const Syscall::SC_mmap_params*> u
return region->vaddr().get();
}
-static KResultOr<Range> expand_range_to_page_boundaries(FlatPtr address, size_t size)
+static KResultOr<Memory::Range> expand_range_to_page_boundaries(FlatPtr address, size_t size)
{
- if (page_round_up_would_wrap(size))
+ if (Memory::page_round_up_would_wrap(size))
return EINVAL;
if ((address + size) < address)
return EINVAL;
- if (page_round_up_would_wrap(address + size))
+ if (Memory::page_round_up_would_wrap(address + size))
return EINVAL;
auto base = VirtualAddress { address }.page_base();
- auto end = page_round_up(address + size);
+ auto end = Memory::page_round_up(address + size);
- return Range { base, end - base.get() };
+ return Memory::Range { base, end - base.get() };
}
KResultOr<FlatPtr> Process::sys$mprotect(Userspace<void*> addr, size_t size, int prot)
@@ -314,10 +314,10 @@ KResultOr<FlatPtr> Process::sys$mprotect(Userspace<void*> addr, size_t size, int
return EPERM;
if (!validate_mmap_prot(prot, whole_region->is_stack(), whole_region->vmobject().is_anonymous(), whole_region))
return EINVAL;
- if (whole_region->access() == prot_to_region_access_flags(prot))
+ if (whole_region->access() == Memory::prot_to_region_access_flags(prot))
return 0;
if (whole_region->vmobject().is_inode()
- && !validate_inode_mmap_prot(*this, prot, static_cast<const InodeVMObject&>(whole_region->vmobject()).inode(), whole_region->is_shared())) {
+ && !validate_inode_mmap_prot(*this, prot, static_cast<Memory::InodeVMObject const&>(whole_region->vmobject()).inode(), whole_region->is_shared())) {
return EACCES;
}
whole_region->set_readable(prot & PROT_READ);
@@ -334,10 +334,10 @@ KResultOr<FlatPtr> Process::sys$mprotect(Userspace<void*> addr, size_t size, int
return EPERM;
if (!validate_mmap_prot(prot, old_region->is_stack(), old_region->vmobject().is_anonymous(), old_region))
return EINVAL;
- if (old_region->access() == prot_to_region_access_flags(prot))
+ if (old_region->access() == Memory::prot_to_region_access_flags(prot))
return 0;
if (old_region->vmobject().is_inode()
- && !validate_inode_mmap_prot(*this, prot, static_cast<const InodeVMObject&>(old_region->vmobject()).inode(), old_region->is_shared())) {
+ && !validate_inode_mmap_prot(*this, prot, static_cast<Memory::InodeVMObject const&>(old_region->vmobject()).inode(), old_region->is_shared())) {
return EACCES;
}
@@ -346,7 +346,7 @@ KResultOr<FlatPtr> Process::sys$mprotect(Userspace<void*> addr, size_t size, int
auto region = space().take_region(*old_region);
// Unmap the old region here, specifying that we *don't* want the VM deallocated.
- region->unmap(Region::ShouldDeallocateVirtualMemoryRange::No);
+ region->unmap(Memory::Region::ShouldDeallocateVirtualMemoryRange::No);
// This vector is the region(s) adjacent to our range.
// We need to allocate a new region for the range we wanted to change permission bits on.
@@ -380,10 +380,10 @@ KResultOr<FlatPtr> Process::sys$mprotect(Userspace<void*> addr, size_t size, int
return EPERM;
if (!validate_mmap_prot(prot, region->is_stack(), region->vmobject().is_anonymous(), region))
return EINVAL;
- if (region->access() == prot_to_region_access_flags(prot))
+ if (region->access() == Memory::prot_to_region_access_flags(prot))
return 0;
if (region->vmobject().is_inode()
- && !validate_inode_mmap_prot(*this, prot, static_cast<const InodeVMObject&>(region->vmobject()).inode(), region->is_shared())) {
+ && !validate_inode_mmap_prot(*this, prot, static_cast<Memory::InodeVMObject const&>(region->vmobject()).inode(), region->is_shared())) {
return EACCES;
}
full_size_found += region->range().intersect(range_to_mprotect).size();
@@ -409,7 +409,7 @@ KResultOr<FlatPtr> Process::sys$mprotect(Userspace<void*> addr, size_t size, int
auto region = space().take_region(*old_region);
// Unmap the old region here, specifying that we *don't* want the VM deallocated.
- region->unmap(Region::ShouldDeallocateVirtualMemoryRange::No);
+ region->unmap(Memory::Region::ShouldDeallocateVirtualMemoryRange::No);
// This vector is the region(s) adjacent to our range.
// We need to allocate a new region for the range we wanted to change permission bits on.
@@ -473,7 +473,7 @@ KResultOr<FlatPtr> Process::sys$madvise(Userspace<void*> address, size_t size, i
if (set_volatile || set_nonvolatile) {
if (!region->vmobject().is_anonymous())
return EINVAL;
- auto& vmobject = static_cast<AnonymousVMObject&>(region->vmobject());
+ auto& vmobject = static_cast<Memory::AnonymousVMObject&>(region->vmobject());
if (!vmobject.is_purgeable())
return EINVAL;
bool was_purged = false;
@@ -557,16 +557,16 @@ KResultOr<FlatPtr> Process::sys$mremap(Userspace<const Syscall::SC_mremap_params
auto range = old_region->range();
auto old_prot = region_access_flags_to_prot(old_region->access());
auto old_offset = old_region->offset_in_vmobject();
- NonnullRefPtr inode = static_cast<SharedInodeVMObject&>(old_region->vmobject()).inode();
+ NonnullRefPtr inode = static_cast<Memory::SharedInodeVMObject&>(old_region->vmobject()).inode();
- auto new_vmobject = PrivateInodeVMObject::try_create_with_inode(inode);
+ auto new_vmobject = Memory::PrivateInodeVMObject::try_create_with_inode(inode);
if (!new_vmobject)
return ENOMEM;
auto old_name = old_region->take_name();
// Unmap without deallocating the VM range since we're going to reuse it.
- old_region->unmap(Region::ShouldDeallocateVirtualMemoryRange::No);
+ old_region->unmap(Memory::Region::ShouldDeallocateVirtualMemoryRange::No);
space().deallocate_region(*old_region);
auto new_region_or_error = space().allocate_region_with_vmobject(range, new_vmobject.release_nonnull(), old_offset, old_name->view(), old_prot, false);
@@ -654,10 +654,10 @@ KResultOr<FlatPtr> Process::sys$msyscall(Userspace<void*> address)
return 0;
}
- if (!is_user_address(VirtualAddress { address }))
+ if (!Memory::is_user_address(VirtualAddress { address }))
return EFAULT;
- auto* region = space().find_region_containing(Range { VirtualAddress { address }, 1 });
+ auto* region = space().find_region_containing(Memory::Range { VirtualAddress { address }, 1 });
if (!region)
return EINVAL;
diff --git a/Kernel/Syscalls/module.cpp b/Kernel/Syscalls/module.cpp
index ad52c2b539..9a677464d7 100644
--- a/Kernel/Syscalls/module.cpp
+++ b/Kernel/Syscalls/module.cpp
@@ -55,7 +55,7 @@ KResultOr<FlatPtr> Process::sys$module_load(Userspace<const char*> user_path, si
elf_image->for_each_section_of_type(SHT_PROGBITS, [&](const ELF::Image::Section& section) {
if (!section.size())
return;
- auto section_storage = KBuffer::copy(section.raw_data(), section.size(), Region::Access::Read | Region::Access::Write | Region::Access::Execute);
+ auto section_storage = KBuffer::copy(section.raw_data(), section.size(), Memory::Region::Access::Read | Memory::Region::Access::Write | Memory::Region::Access::Execute);
section_storage_by_name.set(section.name(), section_storage.data());
module->sections.append(move(section_storage));
});
diff --git a/Kernel/Syscalls/ptrace.cpp b/Kernel/Syscalls/ptrace.cpp
index 1c98f20c1a..2166fd80d3 100644
--- a/Kernel/Syscalls/ptrace.cpp
+++ b/Kernel/Syscalls/ptrace.cpp
@@ -121,7 +121,7 @@ static KResultOr<u32> handle_ptrace(const Kernel::Syscall::SC_ptrace_params& par
Kernel::Syscall::SC_ptrace_peek_params peek_params {};
if (!copy_from_user(&peek_params, reinterpret_cast<Kernel::Syscall::SC_ptrace_peek_params*>(params.addr)))
return EFAULT;
- if (!is_user_address(VirtualAddress { peek_params.address }))
+ if (!Memory::is_user_address(VirtualAddress { peek_params.address }))
return EFAULT;
auto result = peer->process().peek_user_data(Userspace<const u32*> { (FlatPtr)peek_params.address });
if (result.is_error())
@@ -132,7 +132,7 @@ static KResultOr<u32> handle_ptrace(const Kernel::Syscall::SC_ptrace_params& par
}
case PT_POKE:
- if (!is_user_address(VirtualAddress { params.addr }))
+ if (!Memory::is_user_address(VirtualAddress { params.addr }))
return EFAULT;
return peer->process().poke_user_data(Userspace<u32*> { (FlatPtr)params.addr }, params.data);
@@ -194,7 +194,7 @@ KResultOr<u32> Process::peek_user_data(Userspace<const u32*> address)
KResult Process::poke_user_data(Userspace<u32*> address, u32 data)
{
- Range range = { VirtualAddress(address), sizeof(u32) };
+ Memory::Range range = { VirtualAddress(address), sizeof(u32) };
auto* region = space().find_region_containing(range);
if (!region)
return EFAULT;
@@ -203,7 +203,7 @@ KResult Process::poke_user_data(Userspace<u32*> address, u32 data)
// If the region is shared, we change its vmobject to a PrivateInodeVMObject
// to prevent the write operation from changing any shared inode data
VERIFY(region->vmobject().is_shared_inode());
- auto vmobject = PrivateInodeVMObject::try_create_with_inode(static_cast<SharedInodeVMObject&>(region->vmobject()).inode());
+ auto vmobject = Memory::PrivateInodeVMObject::try_create_with_inode(static_cast<Memory::SharedInodeVMObject&>(region->vmobject()).inode());
if (!vmobject)
return ENOMEM;
region->set_vmobject(vmobject.release_nonnull());
diff --git a/Kernel/Syscalls/purge.cpp b/Kernel/Syscalls/purge.cpp
index ede1413eb7..b13c099f8e 100644
--- a/Kernel/Syscalls/purge.cpp
+++ b/Kernel/Syscalls/purge.cpp
@@ -20,7 +20,7 @@ KResultOr<FlatPtr> Process::sys$purge(int mode)
return EPERM;
size_t purged_page_count = 0;
if (mode & PURGE_ALL_VOLATILE) {
- NonnullRefPtrVector<AnonymousVMObject> vmobjects;
+ NonnullRefPtrVector<Memory::AnonymousVMObject> vmobjects;
{
KResult result(KSuccess);
MM.for_each_vmobject([&](auto& vmobject) {
@@ -43,14 +43,14 @@ KResultOr<FlatPtr> Process::sys$purge(int mode)
}
}
if (mode & PURGE_ALL_CLEAN_INODE) {
- NonnullRefPtrVector<InodeVMObject> vmobjects;
+ NonnullRefPtrVector<Memory::InodeVMObject> vmobjects;
{
KResult result(KSuccess);
MM.for_each_vmobject([&](auto& vmobject) {
if (vmobject.is_inode()) {
// In the event that the append fails, only attempt to continue
// the purge if we have already appended something successfully.
- if (!vmobjects.try_append(static_cast<InodeVMObject&>(vmobject)) && vmobjects.is_empty()) {
+ if (!vmobjects.try_append(static_cast<Memory::InodeVMObject&>(vmobject)) && vmobjects.is_empty()) {
result = ENOMEM;
return IterationDecision::Break;
}
diff --git a/Kernel/TTY/VirtualConsole.cpp b/Kernel/TTY/VirtualConsole.cpp
index f63f5371ea..0b80db0ce2 100644
--- a/Kernel/TTY/VirtualConsole.cpp
+++ b/Kernel/TTY/VirtualConsole.cpp
@@ -120,7 +120,7 @@ UNMAP_AFTER_INIT void VirtualConsole::initialize()
// Allocate twice of the max row * max column * sizeof(Cell) to ensure we can have some sort of history mechanism...
auto size = GraphicsManagement::the().console()->max_column() * GraphicsManagement::the().console()->max_row() * sizeof(Cell) * 2;
- m_cells = MM.allocate_kernel_region(page_round_up(size), "Virtual Console Cells", Region::Access::Read | Region::Access::Write, AllocationStrategy::AllocateNow);
+ m_cells = MM.allocate_kernel_region(Memory::page_round_up(size), "Virtual Console Cells", Memory::Region::Access::Read | Memory::Region::Access::Write, AllocationStrategy::AllocateNow);
// Add the lines, so we also ensure they will be flushed now
for (size_t row = 0; row < rows(); row++) {
@@ -139,7 +139,7 @@ void VirtualConsole::refresh_after_resolution_change()
// Note: From now on, columns() and rows() are updated with the new settings.
auto size = GraphicsManagement::the().console()->max_column() * GraphicsManagement::the().console()->max_row() * sizeof(Cell) * 2;
- auto new_cells = MM.allocate_kernel_region(page_round_up(size), "Virtual Console Cells", Region::Access::Read | Region::Access::Write, AllocationStrategy::AllocateNow);
+ auto new_cells = MM.allocate_kernel_region(Memory::page_round_up(size), "Virtual Console Cells", Memory::Region::Access::Read | Memory::Region::Access::Write, AllocationStrategy::AllocateNow);
if (rows() < old_rows_count) {
m_lines.shrink(rows());
diff --git a/Kernel/TTY/VirtualConsole.h b/Kernel/TTY/VirtualConsole.h
index 4491a17617..872eb99c44 100644
--- a/Kernel/TTY/VirtualConsole.h
+++ b/Kernel/TTY/VirtualConsole.h
@@ -146,7 +146,7 @@ private:
void clear_in_line(u16 row, u16 first_column, u16 last_column);
void put_character_at(unsigned row, unsigned column, u32 ch, const VT::Attribute&);
- OwnPtr<Region> m_cells;
+ OwnPtr<Memory::Region> m_cells;
Vector<VirtualConsole::Line> m_lines;
ConsoleImpl m_console_impl;
};
diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp
index 8841819014..7e2425d9bf 100644
--- a/Kernel/Thread.cpp
+++ b/Kernel/Thread.cpp
@@ -39,7 +39,7 @@ UNMAP_AFTER_INIT void Thread::initialize()
KResultOr<NonnullRefPtr<Thread>> Thread::try_create(NonnullRefPtr<Process> process)
{
- auto kernel_stack_region = MM.allocate_kernel_region(default_kernel_stack_size, {}, Region::Access::Read | Region::Access::Write, AllocationStrategy::AllocateNow);
+ auto kernel_stack_region = MM.allocate_kernel_region(default_kernel_stack_size, {}, Memory::Region::Access::Read | Memory::Region::Access::Write, AllocationStrategy::AllocateNow);
if (!kernel_stack_region)
return ENOMEM;
kernel_stack_region->set_stack(true);
@@ -57,7 +57,7 @@ KResultOr<NonnullRefPtr<Thread>> Thread::try_create(NonnullRefPtr<Process> proce
return thread.release_nonnull();
}
-Thread::Thread(NonnullRefPtr<Process> process, NonnullOwnPtr<Region> kernel_stack_region, NonnullRefPtr<Timer> block_timer, OwnPtr<KString> name)
+Thread::Thread(NonnullRefPtr<Process> process, NonnullOwnPtr<Memory::Region> kernel_stack_region, NonnullRefPtr<Timer> block_timer, OwnPtr<KString> name)
: m_process(move(process))
, m_kernel_stack_region(move(kernel_stack_region))
, m_name(move(name))
@@ -175,7 +175,7 @@ void Thread::block(Kernel::Mutex& lock, ScopedSpinLock<SpinLock<u8>>& lock_lock,
VERIFY(!Processor::current().in_irq());
VERIFY(this == Thread::current());
ScopedCritical critical;
- VERIFY(!s_mm_lock.own_lock());
+ VERIFY(!Memory::s_mm_lock.own_lock());
ScopedSpinLock block_lock(m_block_lock);
@@ -1155,7 +1155,7 @@ static bool symbolicate(RecognizedSymbol const& symbol, Process& process, String
bool mask_kernel_addresses = !process.is_superuser();
if (!symbol.symbol) {
- if (!is_user_address(VirtualAddress(symbol.address))) {
+ if (!Memory::is_user_address(VirtualAddress(symbol.address))) {
builder.append("0xdeadc0de\n");
} else {
if (auto* region = process.space().find_region_containing({ VirtualAddress(symbol.address), sizeof(FlatPtr) })) {
@@ -1188,7 +1188,7 @@ String Thread::backtrace()
VERIFY(!g_scheduler_lock.own_lock());
ProcessPagingScope paging_scope(process);
for (auto& frame : stack_trace) {
- if (is_user_range(VirtualAddress(frame), sizeof(FlatPtr) * 2)) {
+ if (Memory::is_user_range(VirtualAddress(frame), sizeof(FlatPtr) * 2)) {
recognized_symbols.append({ frame });
} else {
recognized_symbols.append({ frame, symbolicate_kernel_address(frame) });
diff --git a/Kernel/Thread.h b/Kernel/Thread.h
index e4d9de0587..a958c855ed 100644
--- a/Kernel/Thread.h
+++ b/Kernel/Thread.h
@@ -37,7 +37,9 @@
namespace Kernel {
+namespace Memory {
extern RecursiveSpinLock s_mm_lock;
+}
enum class DispatchSignalResult {
Deferred = 0,
@@ -847,7 +849,7 @@ public:
VERIFY(!Processor::current().in_irq());
VERIFY(this == Thread::current());
ScopedCritical critical;
- VERIFY(!s_mm_lock.own_lock());
+ VERIFY(!Memory::s_mm_lock.own_lock());
ScopedSpinLock block_lock(m_block_lock);
// We need to hold m_block_lock so that nobody can unblock a blocker as soon
@@ -1215,7 +1217,7 @@ public:
String backtrace();
private:
- Thread(NonnullRefPtr<Process>, NonnullOwnPtr<Region>, NonnullRefPtr<Timer>, OwnPtr<KString>);
+ Thread(NonnullRefPtr<Process>, NonnullOwnPtr<Memory::Region>, NonnullRefPtr<Timer>, OwnPtr<KString>);
IntrusiveListNode<Thread> m_process_thread_list_node;
int m_runnable_priority { -1 };
@@ -1304,9 +1306,9 @@ private:
u32 m_signal_mask { 0 };
FlatPtr m_kernel_stack_base { 0 };
FlatPtr m_kernel_stack_top { 0 };
- OwnPtr<Region> m_kernel_stack_region;
+ OwnPtr<Memory::Region> m_kernel_stack_region;
VirtualAddress m_thread_specific_data;
- Optional<Range> m_thread_specific_range;
+ Optional<Memory::Range> m_thread_specific_range;
Array<SignalActionData, NSIG> m_signal_action_data;
Blocker* m_blocker { nullptr };
Kernel::Mutex* m_blocking_lock { nullptr };
diff --git a/Kernel/Time/HPET.cpp b/Kernel/Time/HPET.cpp
index 0dbb2bb24c..b2d899ce4a 100644
--- a/Kernel/Time/HPET.cpp
+++ b/Kernel/Time/HPET.cpp
@@ -124,7 +124,7 @@ UNMAP_AFTER_INIT bool HPET::test_and_initialize()
return false;
dmesgln("HPET @ {}", hpet);
- auto sdt = map_typed<ACPI::Structures::HPET>(hpet);
+ auto sdt = Memory::map_typed<ACPI::Structures::HPET>(hpet);
// Note: HPET is only usable from System Memory
VERIFY(sdt->event_timer_block.address_space == (u8)ACPI::GenericAddressStructure::AddressSpace::SystemMemory);
@@ -145,9 +145,9 @@ UNMAP_AFTER_INIT bool HPET::check_for_exisiting_periodic_timers()
if (hpet.is_null())
return false;
- auto sdt = map_typed<ACPI::Structures::HPET>(hpet);
+ auto sdt = Memory::map_typed<ACPI::Structures::HPET>(hpet);
VERIFY(sdt->event_timer_block.address_space == 0);
- auto registers = map_typed<HPETRegistersBlock>(PhysicalAddress(sdt->event_timer_block.address));
+ auto registers = Memory::map_typed<HPETRegistersBlock>(PhysicalAddress(sdt->event_timer_block.address));
size_t timers_count = ((registers->capabilities.attributes >> 8) & 0x1f) + 1;
for (size_t index = 0; index < timers_count; index++) {
@@ -384,7 +384,7 @@ void HPET::set_comparators_to_optimal_interrupt_state(size_t)
PhysicalAddress HPET::find_acpi_hpet_registers_block()
{
- auto sdt = map_typed<const volatile ACPI::Structures::HPET>(m_physical_acpi_hpet_table);
+ auto sdt = Memory::map_typed<const volatile ACPI::Structures::HPET>(m_physical_acpi_hpet_table);
VERIFY(sdt->event_timer_block.address_space == (u8)ACPI::GenericAddressStructure::AddressSpace::SystemMemory);
return PhysicalAddress(sdt->event_timer_block.address);
}
@@ -413,11 +413,11 @@ u64 HPET::ns_to_raw_counter_ticks(u64 ns) const
UNMAP_AFTER_INIT HPET::HPET(PhysicalAddress acpi_hpet)
: m_physical_acpi_hpet_table(acpi_hpet)
, m_physical_acpi_hpet_registers(find_acpi_hpet_registers_block())
- , m_hpet_mmio_region(MM.allocate_kernel_region(m_physical_acpi_hpet_registers.page_base(), PAGE_SIZE, "HPET MMIO", Region::Access::Read | Region::Access::Write))
+ , m_hpet_mmio_region(MM.allocate_kernel_region(m_physical_acpi_hpet_registers.page_base(), PAGE_SIZE, "HPET MMIO", Memory::Region::Access::Read | Memory::Region::Access::Write))
{
s_hpet = this; // Make available as soon as possible so that IRQs can use it
- auto sdt = map_typed<const volatile ACPI::Structures::HPET>(m_physical_acpi_hpet_table);
+ auto sdt = Memory::map_typed<const volatile ACPI::Structures::HPET>(m_physical_acpi_hpet_table);
m_vendor_id = sdt->pci_vendor_id;
m_minimum_tick = sdt->mininum_clock_tick;
dmesgln("HPET: Minimum clock tick - {}", m_minimum_tick);
diff --git a/Kernel/Time/HPET.h b/Kernel/Time/HPET.h
index be92d9eb77..620219ec98 100644
--- a/Kernel/Time/HPET.h
+++ b/Kernel/Time/HPET.h
@@ -65,7 +65,7 @@ private:
explicit HPET(PhysicalAddress acpi_hpet);
PhysicalAddress m_physical_acpi_hpet_table;
PhysicalAddress m_physical_acpi_hpet_registers;
- OwnPtr<Region> m_hpet_mmio_region;
+ OwnPtr<Memory::Region> m_hpet_mmio_region;
u64 m_main_counter_last_read { 0 };
u64 m_main_counter_drift { 0 };
diff --git a/Kernel/UserOrKernelBuffer.cpp b/Kernel/UserOrKernelBuffer.cpp
index 55b5abd8b9..6f8116acae 100644
--- a/Kernel/UserOrKernelBuffer.cpp
+++ b/Kernel/UserOrKernelBuffer.cpp
@@ -11,14 +11,14 @@ namespace Kernel {
bool UserOrKernelBuffer::is_kernel_buffer() const
{
- return !is_user_address(VirtualAddress(m_buffer));
+ return !Memory::is_user_address(VirtualAddress(m_buffer));
}
String UserOrKernelBuffer::copy_into_string(size_t size) const
{
if (!m_buffer)
return {};
- if (is_user_address(VirtualAddress(m_buffer))) {
+ if (Memory::is_user_address(VirtualAddress(m_buffer))) {
char* buffer;
auto data_copy = StringImpl::create_uninitialized(size, buffer);
if (!copy_from_user(buffer, m_buffer, size))
@@ -33,7 +33,7 @@ KResultOr<NonnullOwnPtr<KString>> UserOrKernelBuffer::try_copy_into_kstring(size
{
if (!m_buffer)
return EINVAL;
- if (is_user_address(VirtualAddress(m_buffer))) {
+ if (Memory::is_user_address(VirtualAddress(m_buffer))) {
char* buffer;
auto kstring = KString::try_create_uninitialized(size, buffer);
if (!kstring)
@@ -54,7 +54,7 @@ bool UserOrKernelBuffer::write(const void* src, size_t offset, size_t len)
if (!m_buffer)
return false;
- if (is_user_address(VirtualAddress(m_buffer)))
+ if (Memory::is_user_address(VirtualAddress(m_buffer)))
return copy_to_user(m_buffer + offset, src, len);
memcpy(m_buffer + offset, src, len);
@@ -66,7 +66,7 @@ bool UserOrKernelBuffer::read(void* dest, size_t offset, size_t len) const
if (!m_buffer)
return false;
- if (is_user_address(VirtualAddress(m_buffer)))
+ if (Memory::is_user_address(VirtualAddress(m_buffer)))
return copy_from_user(dest, m_buffer + offset, len);
memcpy(dest, m_buffer + offset, len);
@@ -78,7 +78,7 @@ bool UserOrKernelBuffer::memset(int value, size_t offset, size_t len)
if (!m_buffer)
return false;
- if (is_user_address(VirtualAddress(m_buffer)))
+ if (Memory::is_user_address(VirtualAddress(m_buffer)))
return memset_user(m_buffer + offset, value, len);
::memset(m_buffer + offset, value, len);
diff --git a/Kernel/UserOrKernelBuffer.h b/Kernel/UserOrKernelBuffer.h
index 1357be4a9a..799d8df953 100644
--- a/Kernel/UserOrKernelBuffer.h
+++ b/Kernel/UserOrKernelBuffer.h
@@ -22,13 +22,13 @@ public:
static UserOrKernelBuffer for_kernel_buffer(u8* kernel_buffer)
{
- VERIFY(!kernel_buffer || !is_user_address(VirtualAddress(kernel_buffer)));
+ VERIFY(!kernel_buffer || !Memory::is_user_address(VirtualAddress(kernel_buffer)));
return UserOrKernelBuffer(kernel_buffer);
}
static Optional<UserOrKernelBuffer> for_user_buffer(u8* user_buffer, size_t size)
{
- if (user_buffer && !is_user_range(VirtualAddress(user_buffer), size))
+ if (user_buffer && !Memory::is_user_range(VirtualAddress(user_buffer), size))
return {};
return UserOrKernelBuffer(user_buffer);
}
@@ -36,7 +36,7 @@ public:
template<typename UserspaceType>
static Optional<UserOrKernelBuffer> for_user_buffer(UserspaceType userspace, size_t size)
{
- if (!is_user_range(VirtualAddress(userspace.unsafe_userspace_ptr()), size))
+ if (!Memory::is_user_range(VirtualAddress(userspace.unsafe_userspace_ptr()), size))
return {};
return UserOrKernelBuffer(const_cast<u8*>((const u8*)userspace.unsafe_userspace_ptr()));
}
diff --git a/Kernel/VirtIO/VirtIO.cpp b/Kernel/VirtIO/VirtIO.cpp
index d1a20a334a..58553faa3a 100644
--- a/Kernel/VirtIO/VirtIO.cpp
+++ b/Kernel/VirtIO/VirtIO.cpp
@@ -109,7 +109,7 @@ auto VirtIODevice::mapping_for_bar(u8 bar) -> MappedMMIO&
auto& mapping = m_mmio[bar];
if (!mapping.base) {
mapping.size = PCI::get_BAR_space_size(pci_address(), bar);
- mapping.base = MM.allocate_kernel_region(PhysicalAddress(page_base_of(PCI::get_BAR(pci_address(), bar))), page_round_up(mapping.size), "VirtIO MMIO", Region::Access::Read | Region::Access::Write, Region::Cacheable::No);
+ mapping.base = MM.allocate_kernel_region(PhysicalAddress(page_base_of(PCI::get_BAR(pci_address(), bar))), Memory::page_round_up(mapping.size), "VirtIO MMIO", Memory::Region::Access::Read | Memory::Region::Access::Write, Memory::Region::Cacheable::No);
if (!mapping.base)
dbgln("{}: Failed to map bar {}", m_class_name, bar);
}
diff --git a/Kernel/VirtIO/VirtIO.h b/Kernel/VirtIO/VirtIO.h
index c6d5faa320..8d15c6820c 100644
--- a/Kernel/VirtIO/VirtIO.h
+++ b/Kernel/VirtIO/VirtIO.h
@@ -93,7 +93,7 @@ protected:
const String m_class_name;
struct MappedMMIO {
- OwnPtr<Region> base;
+ OwnPtr<Memory::Region> base;
size_t size { 0 };
template<typename T>
diff --git a/Kernel/VirtIO/VirtIOConsole.cpp b/Kernel/VirtIO/VirtIOConsole.cpp
index b1df8def1b..2bf1eef65e 100644
--- a/Kernel/VirtIO/VirtIOConsole.cpp
+++ b/Kernel/VirtIO/VirtIOConsole.cpp
@@ -108,8 +108,8 @@ void VirtIOConsole::handle_queue_update(u16 queue_index)
void VirtIOConsole::setup_multiport()
{
- m_control_receive_buffer = make<RingBuffer>("VirtIOConsole control receive queue", CONTROL_BUFFER_SIZE);
- m_control_transmit_buffer = make<RingBuffer>("VirtIOConsole control transmit queue", CONTROL_BUFFER_SIZE);
+ m_control_receive_buffer = make<Memory::RingBuffer>("VirtIOConsole control receive queue", CONTROL_BUFFER_SIZE);
+ m_control_transmit_buffer = make<Memory::RingBuffer>("VirtIOConsole control transmit queue", CONTROL_BUFFER_SIZE);
auto& queue = get_queue(CONTROL_RECEIVEQ);
ScopedSpinLock queue_lock(queue.lock());
diff --git a/Kernel/VirtIO/VirtIOConsole.h b/Kernel/VirtIO/VirtIOConsole.h
index 3a056b39ad..e22c69372b 100644
--- a/Kernel/VirtIO/VirtIOConsole.h
+++ b/Kernel/VirtIO/VirtIOConsole.h
@@ -68,8 +68,8 @@ private:
unsigned m_device_id;
- OwnPtr<RingBuffer> m_control_transmit_buffer;
- OwnPtr<RingBuffer> m_control_receive_buffer;
+ OwnPtr<Memory::RingBuffer> m_control_transmit_buffer;
+ OwnPtr<Memory::RingBuffer> m_control_receive_buffer;
WaitQueue m_control_wait_queue;
diff --git a/Kernel/VirtIO/VirtIOConsolePort.cpp b/Kernel/VirtIO/VirtIOConsolePort.cpp
index 32c960c74a..791d3ae845 100644
--- a/Kernel/VirtIO/VirtIOConsolePort.cpp
+++ b/Kernel/VirtIO/VirtIOConsolePort.cpp
@@ -17,8 +17,8 @@ VirtIOConsolePort::VirtIOConsolePort(unsigned port, VirtIOConsole& console)
, m_console(console)
, m_port(port)
{
- m_receive_buffer = make<RingBuffer>("VirtIOConsolePort Receive", RINGBUFFER_SIZE);
- m_transmit_buffer = make<RingBuffer>("VirtIOConsolePort Transmit", RINGBUFFER_SIZE);
+ m_receive_buffer = make<Memory::RingBuffer>("VirtIOConsolePort Receive", RINGBUFFER_SIZE);
+ m_transmit_buffer = make<Memory::RingBuffer>("VirtIOConsolePort Transmit", RINGBUFFER_SIZE);
m_receive_queue = m_port == 0 ? 0 : m_port * 2 + 2;
m_transmit_queue = m_port == 0 ? 1 : m_port * 2 + 3;
init_receive_buffer();
diff --git a/Kernel/VirtIO/VirtIOConsolePort.h b/Kernel/VirtIO/VirtIOConsolePort.h
index 9fbfe661ed..c866d3eafd 100644
--- a/Kernel/VirtIO/VirtIOConsolePort.h
+++ b/Kernel/VirtIO/VirtIOConsolePort.h
@@ -50,8 +50,8 @@ private:
u16 m_receive_queue {};
u16 m_transmit_queue {};
- OwnPtr<RingBuffer> m_receive_buffer;
- OwnPtr<RingBuffer> m_transmit_buffer;
+ OwnPtr<Memory::RingBuffer> m_receive_buffer;
+ OwnPtr<Memory::RingBuffer> m_transmit_buffer;
VirtIOConsole& m_console;
unsigned m_port;
diff --git a/Kernel/VirtIO/VirtIOQueue.cpp b/Kernel/VirtIO/VirtIOQueue.cpp
index 4fa2085631..e142f9e85e 100644
--- a/Kernel/VirtIO/VirtIOQueue.cpp
+++ b/Kernel/VirtIO/VirtIOQueue.cpp
@@ -17,11 +17,11 @@ VirtIOQueue::VirtIOQueue(u16 queue_size, u16 notify_offset)
size_t size_of_descriptors = sizeof(VirtIOQueueDescriptor) * queue_size;
size_t size_of_driver = sizeof(VirtIOQueueDriver) + queue_size * sizeof(u16);
size_t size_of_device = sizeof(VirtIOQueueDevice) + queue_size * sizeof(VirtIOQueueDeviceItem);
- auto queue_region_size = page_round_up(size_of_descriptors + size_of_driver + size_of_device);
+ auto queue_region_size = Memory::page_round_up(size_of_descriptors + size_of_driver + size_of_device);
if (queue_region_size <= PAGE_SIZE)
- m_queue_region = MM.allocate_kernel_region(queue_region_size, "VirtIO Queue", Region::Access::Read | Region::Access::Write);
+ m_queue_region = MM.allocate_kernel_region(queue_region_size, "VirtIO Queue", Memory::Region::Access::Read | Memory::Region::Access::Write);
else
- m_queue_region = MM.allocate_contiguous_kernel_region(queue_region_size, "VirtIO Queue", Region::Access::Read | Region::Access::Write);
+ m_queue_region = MM.allocate_contiguous_kernel_region(queue_region_size, "VirtIO Queue", Memory::Region::Access::Read | Memory::Region::Access::Write);
VERIFY(m_queue_region);
// TODO: ensure alignment!!!
u8* ptr = m_queue_region->vaddr().as_ptr();
diff --git a/Kernel/VirtIO/VirtIOQueue.h b/Kernel/VirtIO/VirtIOQueue.h
index 41d742cbc9..b081c531bc 100644
--- a/Kernel/VirtIO/VirtIOQueue.h
+++ b/Kernel/VirtIO/VirtIOQueue.h
@@ -93,7 +93,7 @@ private:
OwnPtr<VirtIOQueueDescriptor> m_descriptors { nullptr };
OwnPtr<VirtIOQueueDriver> m_driver { nullptr };
OwnPtr<VirtIOQueueDevice> m_device { nullptr };
- OwnPtr<Region> m_queue_region;
+ OwnPtr<Memory::Region> m_queue_region;
SpinLock<u8> m_lock;
friend class VirtIOQueueChain;
diff --git a/Kernel/VirtIO/VirtIORNG.cpp b/Kernel/VirtIO/VirtIORNG.cpp
index 87e5df815f..85094745af 100644
--- a/Kernel/VirtIO/VirtIORNG.cpp
+++ b/Kernel/VirtIO/VirtIORNG.cpp
@@ -21,7 +21,7 @@ UNMAP_AFTER_INIT VirtIORNG::VirtIORNG(PCI::Address address)
}
if (success) {
finish_init();
- m_entropy_buffer = MM.allocate_contiguous_kernel_region(PAGE_SIZE, "VirtIORNG", Region::Access::Read | Region::Access::Write);
+ m_entropy_buffer = MM.allocate_contiguous_kernel_region(PAGE_SIZE, "VirtIORNG", Memory::Region::Access::Read | Memory::Region::Access::Write);
if (m_entropy_buffer) {
memset(m_entropy_buffer->vaddr().as_ptr(), 0, m_entropy_buffer->size());
request_entropy_from_host();
diff --git a/Kernel/VirtIO/VirtIORNG.h b/Kernel/VirtIO/VirtIORNG.h
index 74826606db..8a4cd93148 100644
--- a/Kernel/VirtIO/VirtIORNG.h
+++ b/Kernel/VirtIO/VirtIORNG.h
@@ -36,7 +36,7 @@ private:
virtual void handle_queue_update(u16 queue_index) override;
void request_entropy_from_host();
- OwnPtr<Region> m_entropy_buffer;
+ OwnPtr<Memory::Region> m_entropy_buffer;
EntropySource m_entropy_source;
};
diff --git a/Kernel/init.cpp b/Kernel/init.cpp
index 34cf9e82d9..b82540966f 100644
--- a/Kernel/init.cpp
+++ b/Kernel/init.cpp
@@ -186,7 +186,7 @@ extern "C" [[noreturn]] UNMAP_AFTER_INIT void init(BootInfo const& boot_info)
s_bsp_processor.initialize(0);
CommandLine::initialize();
- MemoryManager::initialize(0);
+ Memory::MemoryManager::initialize(0);
// Ensure that the safemem sections are not empty. This could happen if the linker accidentally discards the sections.
VERIFY(start_of_safemem_text != end_of_safemem_text);
@@ -236,7 +236,7 @@ extern "C" [[noreturn]] UNMAP_AFTER_INIT void init_ap(FlatPtr cpu, Processor* pr
processor_info->early_initialize(cpu);
processor_info->initialize(cpu);
- MemoryManager::initialize(cpu);
+ Memory::MemoryManager::initialize(cpu);
Scheduler::set_idle_thread(APIC::the().get_idle_thread(cpu));