mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:57:45 +00:00
Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace
This commit is contained in:
parent
a1d7ebf85a
commit
93d98d4976
153 changed files with 473 additions and 467 deletions
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue