1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

lib/ip: alias type for memory block name and cache addres space IDs in IP

This commit is contained in:
Daniel Krebs 2018-04-13 15:24:20 +02:00
parent 0adac55ae6
commit ae2bd2a41d
7 changed files with 23 additions and 10 deletions

View file

@ -127,8 +127,11 @@ public:
virtual void dump();
protected:
/// Key-type for accessing maps addressTranslations and slaveAddressSpaces
using MemoryBlockName = std::string;
/// Each IP can declare via this function which memory blocks it requires
virtual std::list<std::string>
virtual std::list<MemoryBlockName>
getMemoryBlocks() const
{ return {}; }
@ -177,11 +180,15 @@ public:
protected:
uintptr_t
getBaseAddr(const std::string& block) const
getBaseAddr(const MemoryBlockName& block) const
{ return getLocalAddr(block, 0); }
uintptr_t
getLocalAddr(const std::string& block, uintptr_t address) const;
getLocalAddr(const MemoryBlockName& block, uintptr_t address) const;
MemoryManager::AddressSpaceId
getAddressSpaceId(const MemoryBlockName& block) const
{ return slaveAddressSpaces.at(block); }
InterruptController*
getInterruptController(const std::string& interruptName) const;
@ -206,7 +213,10 @@ protected:
std::map<std::string, IrqPort> irqs;
/// Cached translations from the process address space to each memory block
std::map<std::string, MemoryTranslation> addressTranslations;
std::map<MemoryBlockName, MemoryTranslation> addressTranslations;
/// Lookup for IP's slave address spaces (= memory blocks)
std::map<MemoryBlockName, MemoryManager::AddressSpaceId> slaveAddressSpaces;
/// AXI bus master interfaces to access memory somewhere
std::map<std::string, MemoryManager::AddressSpaceId> busMasterInterfaces;

View file

@ -84,7 +84,7 @@ private:
// optional Scatter-Gather interface to access descriptors
static constexpr char sgInterface[] = "M_AXI_SG";
std::list<std::string> getMemoryBlocks() const
std::list<MemoryBlockName> getMemoryBlocks() const
{ return { registerMemory }; }
XAxiDma xDma;

View file

@ -54,7 +54,7 @@ private:
static constexpr char axi4Memory[] = "Mem1";
static constexpr char irqName[] = "interrupt";
std::list<std::string> getMemoryBlocks() const
std::list<MemoryBlockName> getMemoryBlocks() const
{ return { registerMemory, axi4Memory }; }
XLlFifo xFifo;

View file

@ -64,7 +64,7 @@ private:
static constexpr char registerMemory[] = "Reg";
std::list<std::string> getMemoryBlocks() const
std::list<MemoryBlockName> getMemoryBlocks() const
{ return { registerMemory }; }

View file

@ -58,7 +58,7 @@ private:
static constexpr char registerMemory[] = "Reg";
std::list<std::string> getMemoryBlocks() const
std::list<MemoryBlockName> getMemoryBlocks() const
{ return { registerMemory }; }
struct Path {

View file

@ -63,7 +63,7 @@ public:
private:
std::list<std::string> getMemoryBlocks() const
std::list<MemoryBlockName> getMemoryBlocks() const
{ return { registerMemory }; }
static constexpr char irqName[] = "generateout0";

View file

@ -281,6 +281,9 @@ IpCoreFactory::make(PCIeCard* card, json_t *json_ips)
const auto addrSpaceId =
MemoryManager::get().findAddressSpace(addrSpaceName);
// ... and save it in IP
ip->slaveAddressSpaces.emplace(memoryBlock, addrSpaceId);
// get the translation to the address space
const auto& translation =
MemoryManager::get().getTranslationFromProcess(addrSpaceId);
@ -341,7 +344,7 @@ IpCoreFactory::lookup(const Vlnv &vlnv)
uintptr_t
IpCore::getLocalAddr(const std::string& block, uintptr_t address) const
IpCore::getLocalAddr(const MemoryBlockName& block, uintptr_t address) const
{
// throws exception if block not present
auto& translation = addressTranslations.at(block);