From 7582966e16ce620c8f5227297588ab55c2fc90b9 Mon Sep 17 00:00:00 2001 From: Daniel Krebs Date: Tue, 30 Jan 2018 15:11:29 +0100 Subject: [PATCH] lib: first draft of memory manager --- fpga/include/villas/memory_manager.hpp | 47 ++++++++++++++++++++++++++ fpga/lib/CMakeLists.txt | 1 + fpga/lib/memory_manager.cpp | 19 +++++++++++ 3 files changed, 67 insertions(+) create mode 100644 fpga/include/villas/memory_manager.hpp create mode 100644 fpga/lib/memory_manager.cpp diff --git a/fpga/include/villas/memory_manager.hpp b/fpga/include/villas/memory_manager.hpp new file mode 100644 index 000000000..a992f84a0 --- /dev/null +++ b/fpga/include/villas/memory_manager.hpp @@ -0,0 +1,47 @@ +#pragma once + +#include + +#include "log.hpp" +#include "directed_graph.hpp" + +namespace villas { + + +class Mapping : public graph::Edge { +public: + // create mapping here (if needed) + Mapping() {} + + // destroy mapping here (if needed) + ~Mapping() {} + +private: + uintptr_t src; + uintptr_t dest; + size_t size; +}; + +class AddressSpace : public graph::Vertex { +private: + // do we need any metadata? maybe a name? + int id; +}; + + +// is or has a graph +class MemoryManager { + +// This is a singleton +private: + MemoryManager() = default; + static MemoryManager* instance; +public: + static MemoryManager& get(); + + +private: +// std::list<> +}; + +} // namespace villas diff --git a/fpga/lib/CMakeLists.txt b/fpga/lib/CMakeLists.txt index 62cff3113..2302a32eb 100644 --- a/fpga/lib/CMakeLists.txt +++ b/fpga/lib/CMakeLists.txt @@ -25,6 +25,7 @@ set(SOURCES kernel/pci.c kernel/vfio.c + memory_manager.cpp plugin.c plugin.cpp utils.c diff --git a/fpga/lib/memory_manager.cpp b/fpga/lib/memory_manager.cpp new file mode 100644 index 000000000..d00460219 --- /dev/null +++ b/fpga/lib/memory_manager.cpp @@ -0,0 +1,19 @@ +#include "memory_manager.hpp" + +namespace villas { + +MemoryManager* +MemoryManager::instance = nullptr; + +MemoryManager& +MemoryManager::get() +{ + if(instance == nullptr) { + instance = new MemoryManager; + } + + return *instance; +} + + +} // namespace villas