29 string SysInfo::getServiceSymbol()
const {
return "__builtin_SysInfo"; }
34 string SysInfo::getJsonManifest()
const {
35 vector<uint8_t> compressed = getCompressedManifest();
39 uncompress(dst.data(), &dstSize, compressed.data(), compressed.size());
41 throw runtime_error(
"zlib uncompress failed with rc=" + to_string(rc));
42 return string(
reinterpret_cast<char *
>(dst.data()), dstSize);
45 string MMIO::getServiceSymbol()
const {
return "__builtin_MMIO"; }
47 MMIOSysInfo::MMIOSysInfo(
const MMIO *mmio) : mmio(mmio) {}
52 throw runtime_error(
"Invalid magic number low bits: " +
toHex(
reg));
54 throw runtime_error(
"Invalid magic number high bits: " +
toHex(
reg));
60 uint32_t size =
mmio->
read(manifestPtr);
61 uint32_t numWords = (size + 3) / 4;
62 vector<uint32_t> manifestWords(numWords);
63 for (
size_t i = 0; i < numWords; ++i)
64 manifestWords[i] =
mmio->
read(manifestPtr + 4 + (i * 4));
66 vector<uint8_t> manifest;
67 for (
size_t i = 0; i < size; ++i) {
68 uint32_t word = manifestWords[i / 4];
69 manifest.push_back(word >> (8 * (i % 4)));
78 if (
auto f = details.find(
"service"); f != details.end()) {
88 if (
auto f = details.find(
"service"); f != details.end())
90 symbol = any_cast<string>(f->second).substr(1);
97 const std::map<std::string, ChannelPort &> &channels,
99 return new Function(
id.back(), channels);
103 AppID id,
const std::map<std::string, ChannelPort &> &channels)
108 throw runtime_error(
"FuncService must have exactly two channels");
116 std::future<MessageData>
119 return result.readAsync();
124 std::string implName,
129 return new FuncService(acc,
id, implName, details, clients);
135 if (svcName ==
"esi.service.std.func")
constexpr uint32_t MAX_MANIFEST_SIZE
Abstract class representing a connection to an accelerator.
std::map< std::string, ChannelPort & > channels
Bundles represent a collection of channels.
A logical chunk of data representing serialized data.
A ChannelPort which reads data from the accelerator.
A ChannelPort which sends data to the accelerator.
A service for which there are no standard services registered.
CustomService(AppIDPath idPath, const ServiceImplDetails &details, const HWClientDetails &clients)
std::string serviceSymbol
A function call which gets attached to a service port.
std::future< MessageData > call(const MessageData &arg)
Function(AppID id, const std::map< std::string, ChannelPort & > &channels)
Service for calling functions.
virtual std::string getServiceSymbol() const override
FuncService(AcceleratorConnection *acc, AppIDPath id, std::string implName, ServiceImplDetails details, HWClientDetails clients)
virtual ServicePort * getPort(AppIDPath id, const BundleType *type, const std::map< std::string, ChannelPort & > &, AcceleratorConnection &) const override
Get specialized port for this service to attach to the given appid path.
virtual std::vector< uint8_t > getCompressedManifest() const override
Return the zlib compressed JSON system manifest.
uint32_t getEsiVersion() const override
Get the ESI version number to check version compatibility.
virtual uint32_t read(uint32_t addr) const =0
Add a custom interface to a service client at a particular point in the design hierarchy.
static Service::Type lookupServiceType(const std::string &)
Resolve a service type from a string.
static Service * createService(AcceleratorConnection *acc, Service::Type svcType, AppIDPath id, std::string implName, ServiceImplDetails details, HWClientDetails clients)
Create a service instance from the given details.
Parent class of all APIs modeled as 'services'.
const std::type_info & Type
std::map< std::string, std::any > ServiceImplDetails
std::string toHex(uint32_t val)
constexpr uint32_t MagicNumberLo
constexpr uint32_t MetadataOffset
constexpr uint32_t MagicNumberHi
std::vector< HWClientDetail > HWClientDetails
def reg(value, clock, reset=None, reset_value=None, name=None, sym_name=None)