Skip to content

Commit

Permalink
[ESI][Runtime] Add MMIO service to trace backend
Browse files Browse the repository at this point in the history
  • Loading branch information
teqdruid committed Sep 7, 2024
1 parent cb7e9ba commit 6638aaf
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/Dialect/ESI/runtime/cpp/lib/backends/Trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,28 @@ TraceAccelerator::requestChannelsFor(AppIDPath idPath,
return impl->requestChannelsFor(idPath, bundleType);
}

class TraceMMIO : public MMIO {
public:
TraceMMIO(TraceAccelerator::Impl &impl) : impl(impl) {}

virtual uint64_t read(uint32_t addr) const override {
uint64_t data = rand();
if (impl.isWriteable())
impl.write("MMIO") << "[" << std::hex << addr << "] -> " << data
<< std::endl;
return data;
}
virtual void write(uint32_t addr, uint64_t data) override {
if (!impl.isWriteable())
return;
impl.write("MMIO") << "[" << std::hex << addr << "] <- " << data
<< std::endl;
}

private:
TraceAccelerator::Impl &impl;
};

class TraceHostMem : public HostMem {
public:
TraceHostMem(TraceAccelerator::Impl &impl) : impl(impl) {}
Expand Down Expand Up @@ -323,6 +345,8 @@ TraceAccelerator::Impl::createService(Service::Type svcType, AppIDPath idPath,
const HWClientDetails &clients) {
if (svcType == typeid(SysInfo))
return new TraceSysInfo(manifestJson);
if (svcType == typeid(MMIO))
return new TraceMMIO(*this);
if (svcType == typeid(HostMem))
return new TraceHostMem(*this);
if (svcType == typeid(CustomService))
Expand Down

0 comments on commit 6638aaf

Please sign in to comment.