mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-27 21:21:50 +03:00
Kernel: Add convenience values to the Memory::Region::Access enum
Instead of `Memory::Region::Access::Read | Memory::Region::AccessWrite` you can now say `Memory::Region::Access::ReadWrite`.
This commit is contained in:
parent
47bdd7c3a0
commit
2cd8b21974
Notes:
sideshowbarker
2024-07-18 07:24:14 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/2cd8b219749
@ -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", Memory::Region::Access::Read | Memory::Region::Access::Write);
|
||||
auto checkup_region = MM.allocate_kernel_region(p_mcfg.page_base(), (PAGE_SIZE * 2), "PCI MCFG Checkup", Memory::Region::Access::ReadWrite);
|
||||
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(), Memory::page_round_up(length) + PAGE_SIZE, "PCI Parsing MCFG", Memory::Region::Access::Read | Memory::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::ReadWrite);
|
||||
|
||||
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", Memory::Region::Access::Read | Memory::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::ReadWrite);
|
||||
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", Memory::Region::Access::Read | Memory::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::ReadWrite);
|
||||
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());
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ 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(Memory::page_round_up(PCI_MMIO_CONFIG_SPACE_SIZE), "PCI MMIO Device Access", Memory::Region::Access::Read | Memory::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::ReadWrite).release_nonnull())
|
||||
{
|
||||
PhysicalAddress segment_lower_addr = mmio_segment.get_paddr();
|
||||
PhysicalAddress device_physical_mmio_space = segment_lower_addr.offset(
|
||||
|
@ -24,7 +24,7 @@ Transfer::Transfer(Pipe& pipe, u16 len, Memory::AnonymousVMObject& vmobject)
|
||||
{
|
||||
// Initialize data buffer for transfer
|
||||
// This will definitely need to be refactored in the future, I doubt this will scale well...
|
||||
m_data_buffer = MM.allocate_kernel_region_with_vmobject(vmobject, PAGE_SIZE, "USB Transfer Buffer", Memory::Region::Access::Read | Memory::Region::Access::Write);
|
||||
m_data_buffer = MM.allocate_kernel_region_with_vmobject(vmobject, PAGE_SIZE, "USB Transfer Buffer", Memory::Region::Access::ReadWrite);
|
||||
}
|
||||
|
||||
Transfer::~Transfer()
|
||||
|
@ -35,7 +35,7 @@ KResult KCOVInstance::buffer_allocate(size_t buffer_size_in_entries)
|
||||
|
||||
this->m_kernel_region = MM.allocate_kernel_region_with_vmobject(
|
||||
*this->vmobject, this->m_buffer_size_in_bytes, String::formatted("kcov_{}", this->m_pid),
|
||||
Memory::Region::Access::Read | Memory::Region::Access::Write);
|
||||
Memory::Region::Access::ReadWrite);
|
||||
if (!this->m_kernel_region)
|
||||
return ENOMEM;
|
||||
|
||||
|
@ -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, Memory::Region::Access::Read | Memory::Region::Access::Write, "DoubleBuffer");
|
||||
auto storage = KBuffer::try_create_with_size(capacity * 2, Memory::Region::Access::ReadWrite, "DoubleBuffer");
|
||||
if (!storage)
|
||||
return {};
|
||||
|
||||
|
@ -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, Memory::Region::Access::Read | Memory::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::ReadWrite, "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(), Memory::Region::Access::Read | Memory::Region::Access::Write, "Ext2FS: Cached bitmap block");
|
||||
auto block = KBuffer::try_create_with_size(block_size(), Memory::Region::Access::ReadWrite, "Ext2FS: Cached bitmap block");
|
||||
if (!block)
|
||||
return ENOMEM;
|
||||
auto buffer = UserOrKernelBuffer::for_kernel_buffer(block->data());
|
||||
|
@ -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, Memory::Region::Access::Read | Memory::Region::Access::Write);
|
||||
auto buffer = KBuffer::try_create_with_size(header.size, Memory::Region::Access::ReadWrite);
|
||||
if (!buffer)
|
||||
return ENOMEM;
|
||||
// Copy the already read header into the buffer.
|
||||
|
@ -28,7 +28,7 @@ void ContiguousFramebufferConsole::set_resolution(size_t width, size_t height, s
|
||||
m_pitch = pitch;
|
||||
|
||||
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);
|
||||
m_framebuffer_region = MM.allocate_kernel_region(m_framebuffer_address, Memory::page_round_up(pitch * height), "Framebuffer Console", Memory::Region::Access::ReadWrite, Memory::Region::Cacheable::Yes);
|
||||
VERIFY(m_framebuffer_region);
|
||||
|
||||
// Just to start cleanly, we clean the entire framebuffer
|
||||
|
@ -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), Memory::page_round_up(0xc0000 - 0xa0000), "VGA Display", Memory::Region::Access::Read | Memory::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::ReadWrite).release_nonnull())
|
||||
, m_adapter(adapter)
|
||||
, m_mode(mode)
|
||||
{
|
||||
|
@ -49,11 +49,11 @@ KResultOr<Memory::Region*> FramebufferDevice::mmap(Process& process, FileDescrip
|
||||
if (!m_swapped_framebuffer_vmobject)
|
||||
return ENOMEM;
|
||||
|
||||
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);
|
||||
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::ReadWrite);
|
||||
if (!m_real_framebuffer_region)
|
||||
return ENOMEM;
|
||||
|
||||
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);
|
||||
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::ReadWrite);
|
||||
if (!m_swapped_framebuffer_region)
|
||||
return ENOMEM;
|
||||
|
||||
@ -111,11 +111,11 @@ UNMAP_AFTER_INIT void FramebufferDevice::initialize()
|
||||
{
|
||||
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, Memory::page_round_up(framebuffer_size_in_bytes()), "Framebuffer", Memory::Region::Access::Read | Memory::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::ReadWrite);
|
||||
VERIFY(m_real_framebuffer_region);
|
||||
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, Memory::page_round_up(framebuffer_size_in_bytes()), "Framebuffer Swap (Blank)", Memory::Region::Access::Read | Memory::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::ReadWrite);
|
||||
VERIFY(m_swapped_framebuffer_region);
|
||||
}
|
||||
|
||||
|
@ -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", Memory::Region::Access::Read | Memory::Region::Access::Write, AllocationStrategy::AllocateNow).release_nonnull())
|
||||
: m_vga_font_region(MM.allocate_kernel_region(PAGE_SIZE, "VGA font", Memory::Region::Access::ReadWrite, AllocationStrategy::AllocateNow).release_nonnull())
|
||||
, m_framebuffer_devices_allowed(!kernel_command_line().is_no_framebuffer_devices_mode())
|
||||
{
|
||||
}
|
||||
|
@ -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", Memory::Region::Access::Read | Memory::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::ReadWrite);
|
||||
PCI::enable_bus_mastering(address);
|
||||
{
|
||||
ScopedSpinLock control_lock(m_control_lock);
|
||||
|
@ -32,7 +32,7 @@ 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()), Memory::Region::Access::Read | Memory::Region::Access::Write, AllocationStrategy::AllocateNow);
|
||||
m_framebuffer = MM.allocate_kernel_region(m_buffer_size * 2, String::formatted("VirtGPU FrameBuffer #{}", m_scanout.value()), Memory::Region::Access::ReadWrite, 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();
|
||||
|
||||
|
@ -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", Memory::Region::Access::Read | Memory::Region::Access::Write))
|
||||
, m_scratch_space(MM.allocate_contiguous_kernel_region(32 * PAGE_SIZE, "VirtGPU Scratch Space", Memory::Region::Access::ReadWrite))
|
||||
{
|
||||
VERIFY(!!m_scratch_space);
|
||||
if (auto cfg = get_config(ConfigurationType::Device)) {
|
||||
|
@ -99,7 +99,7 @@ struct KmallocGlobalHeap {
|
||||
// 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", Memory::Region::Access::Read | Memory::Region::Access::Write, AllocationStrategy::AllocateNow);
|
||||
region = MM.allocate_kernel_region(memory_size, "kmalloc subheap", Memory::Region::Access::ReadWrite, AllocationStrategy::AllocateNow);
|
||||
if (region) {
|
||||
dbgln("kmalloc: Adding even more memory to heap at {}, bytes: {}", region->vaddr(), region->size());
|
||||
|
||||
@ -173,7 +173,7 @@ struct KmallocGlobalHeap {
|
||||
{
|
||||
if (m_backup_memory)
|
||||
return;
|
||||
m_backup_memory = MM.allocate_kernel_region(1 * MiB, "kmalloc subheap", Memory::Region::Access::Read | Memory::Region::Access::Write, AllocationStrategy::AllocateNow);
|
||||
m_backup_memory = MM.allocate_kernel_region(1 * MiB, "kmalloc subheap", Memory::Region::Access::ReadWrite, AllocationStrategy::AllocateNow);
|
||||
}
|
||||
|
||||
size_t backup_memory_bytes() const
|
||||
|
@ -229,7 +229,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, {}, Memory::Region::Access::Read | Memory::Region::Access::Write);
|
||||
m_apic_base = MM.allocate_kernel_region(apic_base.page_base(), PAGE_SIZE, {}, Memory::Region::Access::ReadWrite);
|
||||
if (!m_apic_base) {
|
||||
dbgln("APIC: Failed to allocate memory for APIC base");
|
||||
return false;
|
||||
@ -283,7 +283,7 @@ UNMAP_AFTER_INIT static NonnullOwnPtr<Memory::Region> create_identity_mapped_reg
|
||||
Memory::VirtualRange { VirtualAddress { static_cast<FlatPtr>(paddr.get()) }, size },
|
||||
vmobject.release_nonnull(),
|
||||
{},
|
||||
Memory::Region::Access::Read | Memory::Region::Access::Write | Memory::Region::Access::Execute);
|
||||
Memory::Region::Access::ReadWriteExecute);
|
||||
VERIFY(region);
|
||||
return region.release_nonnull();
|
||||
}
|
||||
@ -303,7 +303,7 @@ UNMAP_AFTER_INIT void APIC::do_boot_aps()
|
||||
// Allocate enough stacks for all APs
|
||||
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, {}, Memory::Region::Access::Read | Memory::Region::Access::Write, AllocationStrategy::AllocateNow);
|
||||
auto stack_region = MM.allocate_kernel_region(Thread::default_kernel_stack_size, {}, Memory::Region::Access::ReadWrite, AllocationStrategy::AllocateNow);
|
||||
if (!stack_region) {
|
||||
dbgln("APIC: Failed to allocate stack for AP #{}", i);
|
||||
return;
|
||||
|
@ -104,7 +104,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
[[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)
|
||||
[[nodiscard]] static OwnPtr<KBuffer> try_create_with_size(size_t size, Memory::Region::Access access = Memory::Region::Access::ReadWrite, 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, Memory::Region::Access access = Memory::Region::Access::Read | Memory::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::ReadWrite, 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, Memory::Region::Access access = Memory::Region::Access::Read | Memory::Region::Access::Write, StringView name = "KBuffer")
|
||||
[[nodiscard]] static KBuffer copy(const void* data, size_t size, Memory::Region::Access access = Memory::Region::Access::ReadWrite, 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, Memory::Region::Access access = Memory::Region::Access::Read | Memory::Region::Access::Write, StringView name = "KBuffer")
|
||||
KBuffer(const ByteBuffer& buffer, Memory::Region::Access access = Memory::Region::Access::ReadWrite, StringView name = "KBuffer")
|
||||
: m_impl(KBufferImpl::copy(buffer.data(), buffer.size(), access, name))
|
||||
{
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ OwnPtr<KBuffer> KBufferBuilder::build()
|
||||
}
|
||||
|
||||
KBufferBuilder::KBufferBuilder()
|
||||
: m_buffer(KBufferImpl::try_create_with_size(4 * MiB, Memory::Region::Access::Read | Memory::Region::Access::Write))
|
||||
: m_buffer(KBufferImpl::try_create_with_size(4 * MiB, Memory::Region::Access::ReadWrite))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,9 @@ public:
|
||||
HasBeenReadable = 16,
|
||||
HasBeenWritable = 32,
|
||||
HasBeenExecutable = 64,
|
||||
ReadOnly = Read,
|
||||
ReadWrite = Read | Write,
|
||||
ReadWriteExecute = Read | Write | Execute,
|
||||
};
|
||||
|
||||
enum class Cacheable {
|
||||
|
@ -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()))), Memory::page_round_up(mmio_base_size), "E1000e MMIO", Memory::Region::Access::Read | Memory::Region::Access::Write, Memory::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::ReadWrite, Memory::Region::Cacheable::No);
|
||||
if (!m_mmio_region)
|
||||
return false;
|
||||
m_mmio_base = m_mmio_region->vaddr();
|
||||
|
@ -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()))), Memory::page_round_up(mmio_base_size), "E1000 MMIO", Memory::Region::Access::Read | Memory::Region::Access::Write, Memory::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::ReadWrite, 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(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))
|
||||
, 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::ReadWrite))
|
||||
, 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::ReadWrite))
|
||||
{
|
||||
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", Memory::Region::Access::Read | Memory::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::ReadWrite);
|
||||
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", Memory::Region::Access::Read | Memory::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::ReadWrite);
|
||||
|
||||
for (size_t i = 0; i < number_of_tx_descriptors; ++i) {
|
||||
auto& descriptor = tx_descriptors[i];
|
||||
|
@ -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, Memory::Region::Access::Read | Memory::Region::Access::Write, "Packet Buffer", AllocationStrategy::AllocateNow);
|
||||
auto buffer = KBuffer::try_create_with_size(size, Memory::Region::Access::ReadWrite, "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, Memory::Region::Access::Read | Memory::Region::Access::Write, "Packet Buffer", AllocationStrategy::AllocateNow);
|
||||
auto buffer = KBuffer::try_create_with_size(size, Memory::Region::Access::ReadWrite, "Packet Buffer", AllocationStrategy::AllocateNow);
|
||||
if (!buffer)
|
||||
return {};
|
||||
packet = adopt_ref_if_nonnull(new (nothrow) PacketWithTimestamp { buffer.release_nonnull(), kgettimeofday() });
|
||||
|
@ -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", Memory::Region::Access::Read | Memory::Region::Access::Write);
|
||||
auto buffer_region = MM.allocate_kernel_region(buffer_size, "Kernel Packet Buffer", Memory::Region::Access::ReadWrite);
|
||||
auto buffer = (u8*)buffer_region->vaddr().get();
|
||||
Time packet_timestamp;
|
||||
|
||||
|
@ -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(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_rx_buffer(MM.allocate_contiguous_kernel_region(Memory::page_round_up(RX_BUFFER_SIZE + PACKET_SIZE_MAX), "RTL8139 RX", Memory::Region::Access::ReadWrite))
|
||||
, m_packet_buffer(MM.allocate_contiguous_kernel_region(Memory::page_round_up(PACKET_SIZE_MAX), "RTL8139 Packet buffer", Memory::Region::Access::ReadWrite))
|
||||
{
|
||||
m_tx_buffers.ensure_capacity(RTL8139_TX_BUFFER_COUNT);
|
||||
set_interface_name(address);
|
||||
|
@ -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(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))
|
||||
, 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::ReadWrite))
|
||||
, 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::ReadWrite))
|
||||
{
|
||||
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(Memory::page_round_up(RX_BUFFER_SIZE), "RTL8168 RX buffer", Memory::Region::Access::Read | Memory::Region::Access::Write);
|
||||
auto region = MM.allocate_contiguous_kernel_region(Memory::page_round_up(RX_BUFFER_SIZE), "RTL8168 RX buffer", Memory::Region::Access::ReadWrite);
|
||||
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(Memory::page_round_up(TX_BUFFER_SIZE), "RTL8168 TX buffer", Memory::Region::Access::Read | Memory::Region::Access::Write);
|
||||
auto region = MM.allocate_contiguous_kernel_region(Memory::page_round_up(TX_BUFFER_SIZE), "RTL8168 TX buffer", Memory::Region::Access::ReadWrite);
|
||||
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());
|
||||
|
@ -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, Memory::Region::Access::Read | Memory::Region::Access::Write, "Performance events", AllocationStrategy::AllocateNow);
|
||||
auto buffer = KBuffer::try_create_with_size(buffer_size, Memory::Region::Access::ReadWrite, "Performance events", AllocationStrategy::AllocateNow);
|
||||
if (!buffer)
|
||||
return {};
|
||||
return adopt_own_if_nonnull(new (nothrow) PerformanceEventBuffer(buffer.release_nonnull()));
|
||||
|
@ -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", Memory::Region::Access::Read | Memory::Region::Access::Write).leak_ptr();
|
||||
g_signal_trampoline_region = MM.allocate_kernel_region(PAGE_SIZE, "Signal trampolines", Memory::Region::Access::ReadWrite).leak_ptr();
|
||||
g_signal_trampoline_region->set_syscall_region(true);
|
||||
|
||||
size_t trampoline_size = asm_signal_trampoline_end - asm_signal_trampoline;
|
||||
|
@ -126,7 +126,7 @@ AHCI::HBADefinedCapabilities AHCIController::capabilities() const
|
||||
|
||||
NonnullOwnPtr<Memory::Region> AHCIController::default_hba_region() const
|
||||
{
|
||||
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);
|
||||
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::ReadWrite);
|
||||
return region.release_nonnull();
|
||||
}
|
||||
|
||||
|
@ -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", Memory::Region::Access::Read | Memory::Region::Access::Write, Memory::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::ReadWrite, 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(), 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_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::ReadWrite, 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;
|
||||
@ -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(), 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_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::ReadWrite, 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(), Memory::page_round_up(sizeof(AHCI::CommandTable)), "AHCI Command Table", Memory::Region::Access::Read | Memory::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::ReadWrite);
|
||||
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;
|
||||
|
@ -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", 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);
|
||||
m_prdt_region = MM.allocate_kernel_region(m_prdt_page->paddr(), PAGE_SIZE, "IDE PRDT", Memory::Region::Access::ReadWrite);
|
||||
m_dma_buffer_region = MM.allocate_kernel_region(m_dma_buffer_page->paddr(), PAGE_SIZE, "IDE DMA region", Memory::Region::Access::ReadWrite);
|
||||
prdt().end_of_table = 0x8000;
|
||||
|
||||
// clear bus master interrupt status
|
||||
|
@ -49,7 +49,7 @@ RamdiskController::RamdiskController()
|
||||
for (auto& used_memory_range : MM.used_memory_ranges()) {
|
||||
if (used_memory_range.type == Memory::UsedMemoryVirtualRangeType::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);
|
||||
auto region = MM.allocate_kernel_region(used_memory_range.start, length, "Ramdisk", Memory::Region::Access::ReadWrite);
|
||||
if (!region)
|
||||
dmesgln("RamdiskController: Failed to allocate kernel region of size {}", length);
|
||||
else
|
||||
|
@ -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(), Memory::Region::Access::Read | Memory::Region::Access::Write | Memory::Region::Access::Execute);
|
||||
auto section_storage = KBuffer::copy(section.raw_data(), section.size(), Memory::Region::Access::ReadWriteExecute);
|
||||
section_storage_by_name.set(section.name(), section_storage.data());
|
||||
module->sections.append(move(section_storage));
|
||||
});
|
||||
|
@ -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(Memory::page_round_up(size), "Virtual Console Cells", Memory::Region::Access::Read | Memory::Region::Access::Write, AllocationStrategy::AllocateNow);
|
||||
m_cells = MM.allocate_kernel_region(Memory::page_round_up(size), "Virtual Console Cells", Memory::Region::Access::ReadWrite, 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(Memory::page_round_up(size), "Virtual Console Cells", Memory::Region::Access::Read | Memory::Region::Access::Write, AllocationStrategy::AllocateNow);
|
||||
auto new_cells = MM.allocate_kernel_region(Memory::page_round_up(size), "Virtual Console Cells", Memory::Region::Access::ReadWrite, AllocationStrategy::AllocateNow);
|
||||
|
||||
if (rows() < old_rows_count) {
|
||||
m_lines.shrink(rows());
|
||||
|
@ -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, {}, Memory::Region::Access::Read | Memory::Region::Access::Write, AllocationStrategy::AllocateNow);
|
||||
auto kernel_stack_region = MM.allocate_kernel_region(default_kernel_stack_size, {}, Memory::Region::Access::ReadWrite, AllocationStrategy::AllocateNow);
|
||||
if (!kernel_stack_region)
|
||||
return ENOMEM;
|
||||
kernel_stack_region->set_stack(true);
|
||||
|
@ -413,7 +413,7 @@ 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", Memory::Region::Access::Read | Memory::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::ReadWrite))
|
||||
{
|
||||
s_hpet = this; // Make available as soon as possible so that IRQs can use it
|
||||
|
||||
|
@ -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))), Memory::page_round_up(mapping.size), "VirtIO MMIO", Memory::Region::Access::Read | Memory::Region::Access::Write, Memory::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::ReadWrite, Memory::Region::Cacheable::No);
|
||||
if (!mapping.base)
|
||||
dbgln("{}: Failed to map bar {}", m_class_name, bar);
|
||||
}
|
||||
|
@ -19,9 +19,9 @@ VirtIOQueue::VirtIOQueue(u16 queue_size, u16 notify_offset)
|
||||
size_t size_of_device = sizeof(VirtIOQueueDevice) + queue_size * sizeof(VirtIOQueueDeviceItem);
|
||||
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", Memory::Region::Access::Read | Memory::Region::Access::Write);
|
||||
m_queue_region = MM.allocate_kernel_region(queue_region_size, "VirtIO Queue", Memory::Region::Access::ReadWrite);
|
||||
else
|
||||
m_queue_region = MM.allocate_contiguous_kernel_region(queue_region_size, "VirtIO Queue", Memory::Region::Access::Read | Memory::Region::Access::Write);
|
||||
m_queue_region = MM.allocate_contiguous_kernel_region(queue_region_size, "VirtIO Queue", Memory::Region::Access::ReadWrite);
|
||||
VERIFY(m_queue_region);
|
||||
// TODO: ensure alignment!!!
|
||||
u8* ptr = m_queue_region->vaddr().as_ptr();
|
||||
|
@ -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", Memory::Region::Access::Read | Memory::Region::Access::Write);
|
||||
m_entropy_buffer = MM.allocate_contiguous_kernel_region(PAGE_SIZE, "VirtIORNG", Memory::Region::Access::ReadWrite);
|
||||
if (m_entropy_buffer) {
|
||||
memset(m_entropy_buffer->vaddr().as_ptr(), 0, m_entropy_buffer->size());
|
||||
request_entropy_from_host();
|
||||
|
Loading…
Reference in New Issue
Block a user