CIRCT
19.0.0git
|
#include "cosim/CapnpThreads.h"
#include "dpi.h"
#include <algorithm>
#include <cassert>
#include <cstdlib>
Go to the source code of this file.
Functions | |
static void | log (char *epId, bool toClient, const Endpoint::MessageDataPtr &msg) |
Emit the contents of 'msg' to the log file in hex. More... | |
static int | findPort () |
Get the TCP port on which to listen. More... | |
static int | validateSvOpenArray (const svOpenArrayHandle data, int expectedElemSize) |
Check that an array is an array of bytes and has some size. More... | |
DPI int | sv2cCosimserverEpRegister (char *endpointId, char *fromHostTypeId, int fromHostTypeSize, char *toHostTypeId, int toHostTypeSize) |
Register an endpoint. More... | |
DPI int | sv2cCosimserverEpTryGet (char *endpointId, const svOpenArrayHandle data, unsigned int *dataSize) |
Try to get a message from a client. More... | |
DPI int | sv2cCosimserverEpTryPut (char *endpointId, const svOpenArrayHandle data, int dataSize) |
Send a message to a client. More... | |
DPI void | sv2cCosimserverFinish () |
Shutdown the RPC server. More... | |
DPI int | sv2cCosimserverInit () |
Start the server. More... | |
DPI void | sv2cCosimserverSetManifest (unsigned int esiVersion, const svOpenArrayHandle compressedManifest) |
Set the system zlib-compressed manifest. More... | |
DPI int | sv2cCosimserverMMIORegister () |
Register an MMIO module. Just checks that there is only one instantiated. More... | |
DPI int | sv2cCosimserverMMIOReadTryGet (uint32_t *address) |
Read MMIO function pair. More... | |
DPI void | sv2cCosimserverMMIOReadRespond (uint32_t data, char error) |
DPI void | sv2cCosimserverMMIOWriteRespond (char error) |
DPI int | sv2cCosimserverMMIOWriteTryGet (uint32_t *address, uint32_t *data) |
Write MMIO function pair. More... | |
Variables | |
static FILE * | logFile |
If non-null, log to this file. Protected by 'serverMutex`. More... | |
static RpcServer * | server = nullptr |
static std::mutex | serverMutex |
static bool | mmioRegistered = false |
|
static |
Get the TCP port on which to listen.
If the port isn't specified via an environment variable, return 0 to allow automatic selection.
Definition at line 61 of file DpiEntryPoints.cpp.
Referenced by sv2cCosimserverInit().
|
static |
Emit the contents of 'msg' to the log file in hex.
Definition at line 36 of file DpiEntryPoints.cpp.
References logFile, and serverMutex.
Referenced by sv2cCosimserverEpTryGet(), and sv2cCosimserverEpTryPut().
DPI int sv2cCosimserverEpRegister | ( | char * | endpointId, |
char * | fromHostTypeId, | ||
int | fromHostTypeSize, | ||
char * | toHostTypeId, | ||
int | toHostTypeSize | ||
) |
Register an endpoint.
Definition at line 106 of file DpiEntryPoints.cpp.
References esi::cosim::RpcServer::registerEndpoint(), server, and sv2cCosimserverInit().
DPI int sv2cCosimserverEpTryGet | ( | char * | endpointId, |
const svOpenArrayHandle | data, | ||
unsigned int * | dataSize | ||
) |
Try to get a message from a client.
Definition at line 123 of file DpiEntryPoints.cpp.
References esi::cosim::CapnpCosimThread::getEndpoint(), esi::cosim::Endpoint::getMessageToSim(), log(), server, svGetArrElemPtr1(), svSizeOfArray(), and validateSvOpenArray().
DPI int sv2cCosimserverEpTryPut | ( | char * | endpointId, |
const svOpenArrayHandle | data, | ||
int | dataSize | ||
) |
Send a message to a client.
Definition at line 190 of file DpiEntryPoints.cpp.
References esi::cosim::CapnpCosimThread::getEndpoint(), log(), esi::cosim::Endpoint::pushMessageToClient(), server, svGetArrElemPtr1(), svSizeOfArray(), and validateSvOpenArray().
DPI void sv2cCosimserverFinish | ( | ) |
Shutdown the RPC server.
Definition at line 231 of file DpiEntryPoints.cpp.
References logFile, server, serverMutex, and esi::cosim::CapnpCosimThread::stop().
DPI int sv2cCosimserverInit | ( | ) |
Start the server.
Not required as the first endpoint registration will do this. Provided if one wants to start the server early.
Definition at line 245 of file DpiEntryPoints.cpp.
References findPort(), logFile, esi::cosim::RpcServer::run(), server, and serverMutex.
Referenced by sv2cCosimserverEpRegister(), sv2cCosimserverMMIORegister(), and sv2cCosimserverSetManifest().
DPI void sv2cCosimserverMMIOReadRespond | ( | uint32_t | data, |
char | error | ||
) |
Definition at line 312 of file DpiEntryPoints.cpp.
References assert(), esi::cosim::CapnpCosimThread::getLowLevel(), esi::cosim::TSQueue< T >::push(), esi::cosim::LowLevel::readResps, esi::cosim::LowLevel::readsOutstanding, and server.
DPI int sv2cCosimserverMMIOReadTryGet | ( | uint32_t * | address | ) |
Read MMIO function pair.
Assumes that reads come back in the order in which they were requested.
Definition at line 301 of file DpiEntryPoints.cpp.
References assert(), esi::cosim::CapnpCosimThread::getLowLevel(), esi::cosim::TSQueue< T >::pop(), esi::cosim::LowLevel::readReqs, esi::cosim::LowLevel::readsOutstanding, and server.
DPI int sv2cCosimserverMMIORegister | ( | ) |
Register an MMIO module. Just checks that there is only one instantiated.
Definition at line 291 of file DpiEntryPoints.cpp.
References mmioRegistered, and sv2cCosimserverInit().
DPI void sv2cCosimserverMMIOWriteRespond | ( | char | error | ) |
Definition at line 323 of file DpiEntryPoints.cpp.
References assert(), esi::cosim::CapnpCosimThread::getLowLevel(), esi::cosim::TSQueue< T >::push(), server, esi::cosim::LowLevel::writeResps, and esi::cosim::LowLevel::writesOutstanding.
DPI int sv2cCosimserverMMIOWriteTryGet | ( | uint32_t * | address, |
uint32_t * | data | ||
) |
Write MMIO function pair.
Assumes that write errors come back in the order in which the writes were issued.
Definition at line 335 of file DpiEntryPoints.cpp.
References assert(), esi::cosim::CapnpCosimThread::getLowLevel(), esi::cosim::TSQueue< T >::pop(), server, esi::cosim::LowLevel::writeReqs, and esi::cosim::LowLevel::writesOutstanding.
DPI void sv2cCosimserverSetManifest | ( | unsigned int | esiVersion, |
const svOpenArrayHandle | compressedManifest | ||
) |
Set the system zlib-compressed manifest.
Definition at line 266 of file DpiEntryPoints.cpp.
References server, esi::cosim::RpcServer::setManifest(), sv2cCosimserverInit(), svGetArrElemPtr1(), svSizeOfArray(), and validateSvOpenArray().
|
static |
Check that an array is an array of bytes and has some size.
Definition at line 73 of file DpiEntryPoints.cpp.
References svDimensions(), svGetArrayPtr(), svSize(), and svSizeOfArray().
Referenced by sv2cCosimserverEpTryGet(), sv2cCosimserverEpTryPut(), and sv2cCosimserverSetManifest().
|
static |
If non-null, log to this file. Protected by 'serverMutex`.
Definition at line 29 of file DpiEntryPoints.cpp.
Referenced by log(), sv2cCosimserverFinish(), and sv2cCosimserverInit().
|
static |
Definition at line 290 of file DpiEntryPoints.cpp.
Referenced by sv2cCosimserverMMIORegister().
|
static |
Definition at line 30 of file DpiEntryPoints.cpp.
Referenced by sv2cCosimserverEpRegister(), sv2cCosimserverEpTryGet(), sv2cCosimserverEpTryPut(), sv2cCosimserverFinish(), sv2cCosimserverInit(), sv2cCosimserverMMIOReadRespond(), sv2cCosimserverMMIOReadTryGet(), sv2cCosimserverMMIOWriteRespond(), sv2cCosimserverMMIOWriteTryGet(), and sv2cCosimserverSetManifest().
|
static |
Definition at line 31 of file DpiEntryPoints.cpp.
Referenced by log(), sv2cCosimserverFinish(), and sv2cCosimserverInit().