Kernel: Implement SharedMemoryObject cloning
This commit is contained in:
parent
939cbf46e4
commit
bd1290706a
|
@ -32,6 +32,7 @@ namespace Kernel
|
|||
{
|
||||
~Object();
|
||||
|
||||
Key key;
|
||||
size_t size;
|
||||
PageTable::flags_t flags;
|
||||
BAN::Vector<paddr_t> paddrs;
|
||||
|
@ -54,7 +55,7 @@ namespace Kernel
|
|||
public:
|
||||
static BAN::ErrorOr<BAN::UniqPtr<SharedMemoryObject>> create(BAN::RefPtr<SharedMemoryObjectManager::Object>, PageTable&, AddressRange);
|
||||
|
||||
virtual BAN::ErrorOr<BAN::UniqPtr<MemoryRegion>> clone(PageTable& new_page_table) override { return BAN::Error::from_errno(ENOTSUP); }
|
||||
virtual BAN::ErrorOr<BAN::UniqPtr<MemoryRegion>> clone(PageTable& new_page_table) override;
|
||||
virtual BAN::ErrorOr<void> msync(vaddr_t, size_t, int) override { return {}; }
|
||||
|
||||
protected:
|
||||
|
|
|
@ -45,6 +45,7 @@ namespace Kernel
|
|||
Key key = generate_key();
|
||||
while (m_objects.contains(key))
|
||||
key = generate_key();
|
||||
object->key = key;
|
||||
|
||||
TRY(m_objects.insert(key, object));
|
||||
return key;
|
||||
|
@ -80,6 +81,12 @@ namespace Kernel
|
|||
return BAN::move(smo);
|
||||
}
|
||||
|
||||
BAN::ErrorOr<BAN::UniqPtr<MemoryRegion>> SharedMemoryObject::clone(PageTable& new_page_table)
|
||||
{
|
||||
auto region = TRY(SharedMemoryObjectManager::get().map_object(m_object->key, new_page_table, { .start = vaddr(), .end = vaddr() + size() }));
|
||||
return BAN::UniqPtr<MemoryRegion>(BAN::move(region));
|
||||
}
|
||||
|
||||
BAN::ErrorOr<bool> SharedMemoryObject::allocate_page_containing_impl(vaddr_t address)
|
||||
{
|
||||
ASSERT(contains(address));
|
||||
|
|
Loading…
Reference in New Issue