[Mammoth] Move all callers of FromCapability to OwnedMemoryObject.

This commit is contained in:
Drew Galbraith 2023-11-19 20:33:15 -08:00
parent 337126cabb
commit 8e827a5dfb
24 changed files with 175 additions and 87 deletions

View file

@ -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) {