[Mammoth] Move all callers of FromCapability to OwnedMemoryObject.
This commit is contained in:
parent
337126cabb
commit
8e827a5dfb
24 changed files with 175 additions and 87 deletions
|
|
@ -1,7 +1,17 @@
|
|||
#include "lib/memory_mapping_tree.h"
|
||||
|
||||
#include <glacier/string/str_format.h>
|
||||
|
||||
#include "debug/debug.h"
|
||||
|
||||
template <>
|
||||
void glcr::StrFormatValue(glcr::StringBuilder& builder,
|
||||
const MemoryMappingTree::MemoryMapping& value,
|
||||
glcr::StringView opts) {
|
||||
builder.PushBack(
|
||||
glcr::StrFormat("Range {x}-{x}", value.vaddr_base, value.vaddr_limit));
|
||||
}
|
||||
|
||||
glcr::ErrorCode MemoryMappingTree::AddInMemoryObject(
|
||||
uint64_t vaddr, const glcr::RefPtr<MemoryObject>& object) {
|
||||
// TODO: This implementation is inefficient as it traverses the tree a lot, we
|
||||
|
|
@ -45,6 +55,9 @@ glcr::ErrorCode MemoryMappingTree::FreeMemoryRange(uint64_t vaddr_base,
|
|||
|
||||
auto find_or = mapping_tree_.Find(vaddr_base);
|
||||
if (find_or) {
|
||||
dbgln("Mem addr {x} refcnt {}",
|
||||
(uint64_t)find_or.value().get().mem_object.get(),
|
||||
find_or.value().get().mem_object->ref_count());
|
||||
mapping_tree_.Delete(vaddr_base);
|
||||
}
|
||||
while (true) {
|
||||
|
|
|
|||
|
|
@ -21,13 +21,13 @@ class MemoryMappingTree {
|
|||
|
||||
glcr::ErrorOr<uint64_t> GetPhysicalPageAtVaddr(uint64_t vaddr);
|
||||
|
||||
private:
|
||||
struct MemoryMapping {
|
||||
uint64_t vaddr_base;
|
||||
uint64_t vaddr_limit;
|
||||
glcr::RefPtr<MemoryObject> mem_object;
|
||||
};
|
||||
|
||||
private:
|
||||
// TODO: Consider adding a red-black tree implementation here.
|
||||
// As is this tree functions about as well as a linked list
|
||||
// because mappings are likely to be added in near-perfect ascedning order.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue