diff --git a/common/include/villas/memory.hpp b/common/include/villas/memory.hpp index df61cec70..1acefd3ca 100644 --- a/common/include/villas/memory.hpp +++ b/common/include/villas/memory.hpp @@ -33,13 +33,19 @@ public: offset(offset), size(size), addrSpaceId(addrSpaceId) {} MemoryManager::AddressSpaceId getAddrSpaceId() const - { return addrSpaceId; } + { + return addrSpaceId; + } size_t getSize() const - { return size; } + { + return size; + } size_t getOffset() const - { return offset; } + { + return offset; + } protected: size_t offset; ///< Offset (or address) inside address space @@ -47,7 +53,6 @@ protected: MemoryManager::AddressSpaceId addrSpaceId; ///< Identifier in memory graph }; - /** * @brief Wrapper for a MemoryBlock to access the underlying memory directly * @@ -68,37 +73,43 @@ public: MemoryAccessor(std::unique_ptr mem) : translation(MemoryManager::get().getTranslationFromProcess(mem->getAddrSpaceId())), memoryBlock(std::move(mem)) - {} + { } // just act as an accessor, do not take ownership of MemoryBlock MemoryAccessor(const MemoryBlock &mem) : translation(MemoryManager::get().getTranslationFromProcess(mem.getAddrSpaceId())) - {} + { } MemoryAccessor(const MemoryTranslation &translation) : translation(translation) - {} + { } - T & operator*() const { + T & operator*() const + { return *reinterpret_cast(translation.getLocalAddr(0)); } - T & operator[](size_t idx) const { + T & operator[](size_t idx) const + { const size_t offset = sizeof(T) * idx; return *reinterpret_cast(translation.getLocalAddr(offset)); } - T* operator&() const { + T* operator&() const + { return reinterpret_cast(translation.getLocalAddr(0)); } - T* operator->() const { + T* operator->() const + { return reinterpret_cast(translation.getLocalAddr(0)); } const MemoryBlock& getMemoryBlock() const - { if (not memoryBlock) throw std::bad_alloc(); else return *memoryBlock; } + { + if (not memoryBlock) throw std::bad_alloc(); else return *memoryBlock; + } private: /// cached memory translation for fast access @@ -196,7 +207,9 @@ protected: } MemoryManager::AddressSpaceId getAddrSpaceId() const - { return memoryAddrSpaceId; } + { + return memoryAddrSpaceId; + } MemoryBlock::deallocator_fn free; Logger logger; @@ -209,7 +222,6 @@ private: DerivedAllocator* derivedAlloc; }; - /** * @brief Linear memory allocator * @@ -232,10 +244,14 @@ public: } size_t getAvailableMemory() const - { return memorySize - nextFreeAddress; } + { + return memorySize - nextFreeAddress; + } size_t getSize() const - { return memorySize; } + { + return memorySize; + } std::string getName() const; @@ -247,7 +263,9 @@ private: static constexpr size_t alignMask = alignBytes - 1; size_t getAlignmentPadding(uintptr_t addr) const - { return (alignBytes - (addr & alignMask)) & alignMask; } + { + return (alignBytes - (addr & alignMask)) & alignMask; + } size_t nextFreeAddress; ///< next chunk will be allocated here size_t memorySize; ///< total size of managed memory @@ -269,7 +287,9 @@ public: HostRamAllocator(); std::string getName() const - { return "HostRamAlloc"; } + { + return "HostRamAlloc"; + } std::unique_ptr allocateBlock(size_t size); @@ -277,7 +297,9 @@ public: static HostRamAllocator& getAllocator() - { return allocator; } + { + return allocator; + } private: static HostRamAllocator allocator; @@ -293,7 +315,9 @@ public: virtual ~HostDmaRamAllocator(); std::string getName() const - { return getUdmaBufName(num); } + { + return getUdmaBufName(num); + } private: int num; @@ -303,7 +327,8 @@ public: getAllocator(int num = 0); private: - static std::map> allocators; + static + std::map> allocators; static std::string getUdmaBufName(int num); diff --git a/common/lib/kernel/vfio.cpp b/common/lib/kernel/vfio.cpp index cc4e68d04..f209b506e 100644 --- a/common/lib/kernel/vfio.cpp +++ b/common/lib/kernel/vfio.cpp @@ -541,7 +541,6 @@ Device::pciHotReset() reset_info->argsz = reset_info_len; - if (ioctl(this->fd, VFIO_DEVICE_GET_PCI_HOT_RESET_INFO, reset_info) != 0) { delete[] reset_info_buf; return false; @@ -587,7 +586,6 @@ Device::pciHotReset() return success; } - int Device::pciMsiInit(int efds[]) {