Commit 8468a16a authored by Christoph Schwick's avatar Christoph Schwick
Browse files

references #296: Change the axi busadapter to take the map name which as key...

references #296: Change the axi busadapter to take the map name which as key since this one is unique
parent 35e8f01b
......@@ -24,7 +24,7 @@ int main() {
HAL::AXIDeviceIdentifier *axidi;
std::string devname = "axi_chip2chip";
std::string devname = "axi_chip2chip@b0000000";
//std::string devname = "M05_AXI_0";
aba->findDevice( devname,
&axidi,
......
......@@ -112,6 +112,7 @@ public:
private:
struct uiostruct {
std::string mapname;
std::string name;
std::string device;
uint64_t address;
......
......@@ -25,6 +25,7 @@ HAL::AXILinuxBusAdapter::AXILinuxBusAdapter()
std::filesystem::path mapadrpath = fpath / "maps" / "map0" / "addr";
std::filesystem::path mapsizpath = fpath / "maps" / "map0" / "size";
std::filesystem::path mapoffpath = fpath / "maps" / "map0" / "offset";
std::filesystem::path mapnampath = fpath / "maps" / "map0" / "name";
auto device = std::filesystem::path("/dev") / fpath.path().filename();
std::ifstream ifs( namepath );
......@@ -44,18 +45,24 @@ HAL::AXILinuxBusAdapter::AXILinuxBusAdapter()
std::string mapoffstr( ( std::istreambuf_iterator<char>(ifs) ), (std::istreambuf_iterator<char>() ) );
uint64_t offset = std::stoul( mapoffstr, nullptr, 16);
ifs.close(); ifs.clear(); ifs.open( mapnampath );
std::string mapnamstr( ( std::istreambuf_iterator<char>(ifs) ), (std::istreambuf_iterator<char>() ) );
mapnamstr = std::regex_replace(mapnamstr, std::regex("\\s+$"), std::string(""));
ifs.close();
/*
std::cout << "Name : " << name << std::endl;
std::cout << "Adr : " << mapadrstr << std::endl;
std::cout << "Size : " << mapsizstr << std::endl;
std::cout << "Offset : " << mapoffstr << std::endl;
std::cout << "Mapname: " << mapnamstr << std::endl;
std::cout << address << std::endl;
std::cout << size << std::endl;
std::cout << offset << std::endl;
*/
struct uiostruct item { .name=name, .device=device, .address=address, .size=size, .offset=offset };
uiomap[name] = item;
struct uiostruct item { .mapname = mapnamstr, .name=name, .device=device, .address=address, .size=size, .offset=offset };
uiomap[mapnamstr] = item;
}
}
......@@ -66,16 +73,16 @@ HAL::AXILinuxBusAdapter::~AXILinuxBusAdapter() {
}
}
void HAL::AXILinuxBusAdapter::findDevice( const std::string& uioname,
void HAL::AXILinuxBusAdapter::findDevice( const std::string& mapname,
//const AXIAddressTable& AXIAddressTable,
AXIDeviceIdentifier** deviceIdentifierPtr,
uint64_t& baseAddress,
bool swapFlag) {
// find the uio device with the name uioname and copy the baseaddress
auto uiodev = uiomap.find( uioname );
// find the uio device with a specific mapname and copy the baseaddress
auto uiodev = uiomap.find( mapname );
if ( uiodev == uiomap.end() ) {
std::stringstream text;
text << "Could not find AXI device with name " << uioname << std::endl;
text << "Could not find AXI device with a map named " << mapname << std::endl;
std::string textStr = text.str();
throw ( NoSuchDeviceException( textStr, __FILE__, __LINE__, __FUNCTION__ ));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment