μHAL (v2.7.9)
Part of the IPbus software repository
ProtocolMmap.cpp
Go to the documentation of this file.
1 /*
2 ---------------------------------------------------------------------------
3 
4  This file is part of uHAL.
5 
6  uHAL is a hardware access library and programming framework
7  originally developed for upgrades of the Level-1 trigger of the CMS
8  experiment at CERN.
9 
10  uHAL is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  uHAL is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with uHAL. If not, see <http://www.gnu.org/licenses/>.
22 
23 
24  Andrew Rose, Imperial College, London
25  email: awr01 <AT> imperial.ac.uk
26 
27  Marc Magrans de Abril, CERN
28  email: marc.magrans.de.abril <AT> cern.ch
29 
30  Tom Williams, Rutherford Appleton Laboratory, Oxfordshire
31  email: tom.williams <AT> cern.ch
32 
33 ---------------------------------------------------------------------------
34 */
35 
42 #include "uhal/ProtocolMmap.hpp"
43 
44 
45 #include <algorithm> // for min
46 #include <assert.h>
47 #include <cstdlib>
48 #include <fcntl.h>
49 #include <iomanip> // for operator<<
50 #include <iostream> // for operator<<
51 #include <sys/mman.h>
52 #include <sys/stat.h>
53 #include <stdlib.h> // for size_t, free
54 #include <string.h> // for memcpy
55 #include <unistd.h>
56 
57 #include <boost/chrono/duration.hpp> // for operator>
58 #include <boost/chrono/time_point.hpp> // for operator-
59 #include <boost/lexical_cast.hpp>
60 #include <boost/thread/thread.hpp> // for sleep_for
61 #include <boost/date_time/posix_time/posix_time_types.hpp> // for time_dura...
62 
63 #include "uhal/grammars/URI.hpp" // for URI
64 #include "uhal/log/LogLevels.hpp" // for BaseLogLevel
65 #include "uhal/log/log_inserters.integer.hpp" // for Integer
66 #include "uhal/log/log_inserters.quote.hpp" // for Quote
67 #include "uhal/log/log.hpp"
68 #include "uhal/Buffers.hpp"
69 #include "uhal/ClientFactory.hpp"
70 
71 
72 namespace uhal {
73 
74 
75 Mmap::PacketFmt::PacketFmt(const uint8_t* const aPtr, const size_t aNrBytes) :
76  mData(1, std::pair<const uint8_t*, size_t>(aPtr, aNrBytes))
77 {
78 }
79 
80 
81 Mmap::PacketFmt::PacketFmt(const std::vector< std::pair<const uint8_t*, size_t> >& aData) :
82  mData(aData)
83 {}
84 
85 
87 {}
88 
89 
90 std::ostream& operator<<(std::ostream& aStream, const Mmap::PacketFmt& aPacket)
91 {
92  std::ios::fmtflags lOrigFlags( aStream.flags() );
93 
94  size_t lNrBytesWritten = 0;
95  for (size_t i = 0; i < aPacket.mData.size(); i++) {
96  for (const uint8_t* lPtr = aPacket.mData.at(i).first; lPtr != (aPacket.mData.at(i).first + aPacket.mData.at(i).second); lPtr++, lNrBytesWritten++) {
97  if ((lNrBytesWritten & 3) == 0)
98  aStream << std::endl << " @ " << std::setw(3) << std::dec << (lNrBytesWritten >> 2) << " : x";
99  aStream << std::setw(2) << std::hex << uint16_t(*lPtr) << " ";
100  }
101  }
102 
103  aStream.flags( lOrigFlags );
104  return aStream;
105 }
106 
107 
108 
109 
110 Mmap::File::File(const std::string& aPath, int aFlags) :
111  mPath(aPath),
112  mFd(-1),
113  mFlags(aFlags),
114  mOffset(0),
115  mMmapPtr(NULL),
116  mMmapIOPtr(NULL)
117 {
118 }
119 
120 
122 {
123  close();
124 }
125 
126 
127 const std::string& Mmap::File::getPath() const
128 {
129  return mPath;
130 }
131 
132 
133 void Mmap::File::setPath(const std::string& aPath)
134 {
135  mPath = aPath;
136 }
137 
138 
139 void Mmap::File::setOffset(size_t aOffset)
140 {
141  mOffset = aOffset;
142 }
143 
144 
145 #define MAP_SIZE (32*1024UL)
146 #define MAP_MASK (MAP_SIZE - 1)
147 
148 
150 {
151  if (mFd != -1)
152  return;
153 
154  mFd = ::open(mPath.c_str(), mFlags);
155  if ( mFd == -1 ) {
156  exception::MmapInitialisationError lExc;
157  log(lExc, "Failed to open device file ", Quote(mPath), "; errno=", Integer(errno), ", meaning ", Quote (strerror(errno)));
158  throw lExc;
159  }
160 
161  const off_t lPageSize = sysconf(_SC_PAGESIZE);
162  const off_t lPageBaseAddr = (mOffset & ~(lPageSize-1));
163 
164  mMmapPtr = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, mFd, lPageBaseAddr);
165  mMmapIOPtr = static_cast<uint8_t*>(mMmapPtr) + (mOffset - lPageBaseAddr);
166 
167  if (mMmapPtr == (void *)-1) {
168  exception::MmapInitialisationError lExc;
169  log(lExc, "Error occurred when mapping device file '" + mPath + "' to memory; errno=", Integer(errno), ", meaning ", Quote (strerror(errno)));
170  throw lExc;
171  }
172 }
173 
174 
176 {
177  if (mMmapPtr != NULL) {
178  if (munmap(mMmapPtr, MAP_SIZE) == -1)
179  log ( Error() , "mmap client for ", Quote(mPath), " encountered error when unmapping memory" );
180  else {
181  mMmapPtr = NULL;
182  mMmapIOPtr = NULL;
183  }
184  }
185 
186  if (mFd != -1) {
187  int rc = ::close(mFd);
188  mFd = -1;
189  if (rc == -1)
190  log (Error(), "Failed to close file ", Quote(mPath), "; errno=", Integer(errno), ", meaning ", Quote (strerror(errno)));
191  }
192 }
193 
194 
195 void Mmap::File::read(const uint32_t aAddr, const uint32_t aNrWords, std::vector<uint32_t>& aValues)
196 {
197  if (mFd == -1)
198  open();
199 
200  uint8_t* lVirtAddr = static_cast<uint8_t*>(mMmapIOPtr) + off_t(4*aAddr);
201 
202  for (size_t i=0; i<aNrWords; i++) {
203  aValues.push_back(*((uint32_t*) (lVirtAddr + 4 * i)));
204  }
205 }
206 
207 
208 void Mmap::File::write(const uint32_t aAddr, const std::vector<std::pair<const uint8_t*, size_t> >& aData)
209 {
210  if (mFd == -1)
211  open();
212 
213  size_t lNrBytes = 0;
214  for (size_t i = 0; i < aData.size(); i++)
215  lNrBytes += aData.at(i).second;
216 
217  assert((lNrBytes % 4) == 0);
218 
219  char *allocated = NULL;
220  posix_memalign((void **)&allocated, 4096/*alignment*/, lNrBytes + 4096);
221  if (allocated == NULL) {
222  exception::MmapCommunicationError lExc;
223  log(lExc, "Failed to allocate ", Integer(lNrBytes + 4096), " bytes in File::write/2 function");
224  throw lExc;
225  }
226 
227  // data to write to register address
228  char* buffer = allocated;
229  size_t lNrBytesCopied = 0;
230  for (size_t i = 0; i < aData.size(); i++) {
231  memcpy(buffer + lNrBytesCopied, aData.at(i).first, aData.at(i).second);
232  lNrBytesCopied += aData.at(i).second;
233  }
234 
235 // memcpy(aMmapBaseAddress + aAddr, buffer, lNrBytes);
236  lNrBytesCopied = 0;
237  while (lNrBytesCopied < lNrBytes) {
238  char* lSrcPtr = buffer + lNrBytesCopied;
239  char* lVirtAddr = static_cast<char*>(mMmapIOPtr) + aAddr + lNrBytesCopied;
240  if ((lNrBytes - lNrBytesCopied) >= 8) {
241  *((uint64_t*) lVirtAddr) = *(uint64_t*) lSrcPtr;
242  lNrBytesCopied += 8;
243  }
244  else if ((lNrBytes - lNrBytesCopied) >= 4) {
245  *((uint64_t*) lVirtAddr) = uint64_t(*(uint32_t*) lSrcPtr);
246  lNrBytesCopied += 4;
247  }
248  }
249 
250  free(allocated);
251 }
252 
253 
254 
255 
256 Mmap::Mmap ( const std::string& aId, const URI& aUri ) :
257  IPbus< 2 , 0 > ( aId , aUri ),
258  mConnected(false),
259  mDeviceFile(aUri.mHostname, O_RDWR | O_SYNC),
260  mNumberOfPages(0),
261  mPageSize(0),
262  mIndexNextPage(0),
265  mAsynchronousException ( NULL )
266 {
267  if ( getenv("UHAL_ENABLE_IPBUS_MMAP") == NULL ) {
268  exception::ProtocolDoesNotExist lExc;
269  log(lExc, "The IPbus 2.0 mmap client is still an experimental feature, since the software-driver interface could change in the future.");
270  log(lExc, "In order to enable the IPbus 2.0 mmap client, you need to define the environment variable 'UHAL_ENABLE_IPBUS_MMAP'");
271  throw lExc;
272  }
273 
274  mSleepDuration = boost::chrono::microseconds(50);
275 
276  for (NameValuePairVectorType::const_iterator lIt = aUri.mArguments.begin(); lIt != aUri.mArguments.end(); lIt++) {
277  if (lIt->first == "sleep") {
278  mSleepDuration = boost::chrono::microseconds(boost::lexical_cast<size_t>(lIt->second));
279  log (Notice() , "mmap client with URI ", Quote (uri()), " : Inter-poll-/-interrupt sleep duration set to ", boost::lexical_cast<size_t>(lIt->second), " us by URI 'sleep' attribute");
280  }
281  else if (lIt->first == "offset") {
282  const bool lIsHex = (lIt->second.find("0x") == 0) or (lIt->second.find("0X") == 0);
283  const size_t lOffset = (lIsHex ? boost::lexical_cast<HexTo<size_t> >(lIt->second) : boost::lexical_cast<size_t>(lIt->second));
284  mDeviceFile.setOffset(lOffset);
285  log (Notice(), "mmap client with URI ", Quote (uri()), " : Address offset set to ", Integer(lOffset, IntFmt<hex>()));
286  }
287  else {
288  log (Warning() , "Unknown attribute ", Quote (lIt->first), " used in URI ", Quote(uri()));
289  }
290  }
291 }
292 
293 
295 {
296  disconnect();
297 }
298 
299 
301 {
302  log(Debug(), "mmap client (URI: ", Quote(uri()), ") : implementDispatch method called");
303 
304  if ( ! mConnected )
305  connect();
306 
307  if ( mReplyQueue.size() == mNumberOfPages )
308  read();
309  write(aBuffers);
310 }
311 
312 
313 void Mmap::Flush( )
314 {
315  log(Debug(), "mmap client (URI: ", Quote(uri()), ") : Flush method called");
316  while ( !mReplyQueue.empty() )
317  read();
318 
319 }
320 
321 
323 {
324  // FIXME: Adapt to PCIe implementation
325  log(Notice(), "mmap client ", Quote(id()), " (URI: ", Quote(uri()), ") : closing device files since exception detected");
326 
328  disconnect();
329 
330  InnerProtocol::dispatchExceptionHandler();
331 }
332 
333 
335 {
336  if ( ! mConnected )
337  connect();
338 
339  return (mPageSize - 1) * 4;
340 }
341 
342 
344 {
345  if ( ! mConnected )
346  connect();
347 
348  return (mPageSize - 1) * 4;
349 }
350 
351 
353 {
354  log ( Debug() , "mmap client is opening device file " , Quote ( mDeviceFile.getPath() ) );
355  std::vector<uint32_t> lValues;
356  mDeviceFile.read(0x0, 4, lValues);
357  log (Info(), "Read status info from addr 0 (", Integer(lValues.at(0)), ", ", Integer(lValues.at(1)), ", ", Integer(lValues.at(2)), ", ", Integer(lValues.at(3)), "): ", PacketFmt((const uint8_t*)lValues.data(), 4 * lValues.size()));
358 
359  mNumberOfPages = lValues.at(0);
360  mPageSize = std::min(uint32_t(4096), lValues.at(1));
361  mIndexNextPage = lValues.at(2);
362  mPublishedReplyPageCount = lValues.at(3);
364 
365  if (lValues.at(1) > 0xFFFF) {
366  exception::MmapInitialisationError lExc;
367  log (lExc, "Invalid page size, ", Integer(lValues.at(1)), ", reported in device file ", Quote(mDeviceFile.getPath()));
368  throw lExc;
369  }
370 
372  exception::MmapInitialisationError lExc;
373  log (lExc, "Next page index, ", Integer(mIndexNextPage), ", reported in device file ", Quote(mDeviceFile.getPath()), " is inconsistent with number of pages, ", Integer(mNumberOfPages));
374  throw lExc;
375  }
376 
377  mConnected = true;
378  log ( Info() , "mmap client connected to device at ", Quote(mDeviceFile.getPath()), "; FPGA has ", Integer(mNumberOfPages), " pages, each of size ", Integer(mPageSize), " words, index ", Integer(mIndexNextPage), " should be filled next" );
379 }
380 
381 
383 {
384  mDeviceFile.close();
385  mConnected = false;
386 }
387 
388 
390 {
391  log (Info(), "mmap client ", Quote(id()), " (URI: ", Quote(uri()), ") : writing ", Integer(aBuffers->sendCounter() / 4), "-word packet to page ", Integer(mIndexNextPage), " in ", Quote(mDeviceFile.getPath()));
392 
393  const uint32_t lHeaderWord = (0x10000 | (((aBuffers->sendCounter() / 4) - 1) & 0xFFFF));
394  std::vector<std::pair<const uint8_t*, size_t> > lDataToWrite;
395  lDataToWrite.push_back( std::make_pair(reinterpret_cast<const uint8_t*>(&lHeaderWord), sizeof lHeaderWord) );
396  lDataToWrite.push_back( std::make_pair(aBuffers->getSendBuffer(), aBuffers->sendCounter()) );
397  mDeviceFile.write(mIndexNextPage * 4 * mPageSize, lDataToWrite);
398 
399  log (Debug(), "Wrote " , Integer((aBuffers->sendCounter() / 4) + 1), " 32-bit words at address " , Integer(mIndexNextPage * 4 * mPageSize), " ... ", PacketFmt(lDataToWrite));
400 
402  mReplyQueue.push_back(aBuffers);
403 }
404 
405 
407 {
408  const size_t lPageIndexToRead = (mIndexNextPage - mReplyQueue.size() + mNumberOfPages) % mNumberOfPages;
409  SteadyClock_t::time_point lStartTime = SteadyClock_t::now();
410 
412  {
413  uint32_t lHwPublishedPageCount = 0x0;
414 
415  while ( true ) {
416  std::vector<uint32_t> lValues;
417  // FIXME : Improve by simply adding dmaWrite method that takes uint32_t ref as argument (or returns uint32_t)
418  mDeviceFile.read(0, 4, lValues);
419  lHwPublishedPageCount = lValues.at(3);
420  log (Info(), "Read status info from addr 0 (", Integer(lValues.at(0)), ", ", Integer(lValues.at(1)), ", ", Integer(lValues.at(2)), ", ", Integer(lValues.at(3)), "): ", PacketFmt((const uint8_t*)lValues.data(), 4 * lValues.size()));
421 
422  if (lHwPublishedPageCount != mPublishedReplyPageCount) {
423  mPublishedReplyPageCount = lHwPublishedPageCount;
424  break;
425  }
426  // FIXME: Throw if published page count is invalid number
427 
428  if (SteadyClock_t::now() - lStartTime > boost::chrono::microseconds(getBoostTimeoutPeriod().total_microseconds())) {
429  exception::MmapTimeout lExc;
430  log(lExc, "Next page (index ", Integer(lPageIndexToRead), " count ", Integer(mPublishedReplyPageCount+1), ") of mmap device '" + mDeviceFile.getPath() + "' is not ready after timeout period");
431  throw lExc;
432  }
433 
434  log(Debug(), "mmap client ", Quote(id()), " (URI: ", Quote(uri()), ") : Trying to read page index ", Integer(lPageIndexToRead), " = count ", Integer(mReadReplyPageCount+1), "; published page count is ", Integer(lHwPublishedPageCount), "; sleeping for ", mSleepDuration.count(), "us");
435  if (mSleepDuration > boost::chrono::microseconds(0))
436  boost::this_thread::sleep_for( mSleepDuration );
437  }
438 
439  log(Info(), "mmap client ", Quote(id()), " (URI: ", Quote(uri()), ") : Reading page ", Integer(lPageIndexToRead), " (published count ", Integer(lHwPublishedPageCount), ", surpasses required, ", Integer(mReadReplyPageCount + 1), ")");
440  }
442 
443  // PART 1 : Read the page
444  boost::shared_ptr<Buffers> lBuffers = mReplyQueue.front();
445  mReplyQueue.pop_front();
446 
447  uint32_t lNrWordsToRead(lBuffers->replyCounter() >> 2);
448  lNrWordsToRead += 1;
449 
450  std::vector<uint32_t> lPageContents;
451  mDeviceFile.read(4 + lPageIndexToRead * mPageSize, lNrWordsToRead , lPageContents);
452  log (Debug(), "Read " , Integer(lNrWordsToRead), " 32-bit words from address " , Integer(4 + lPageIndexToRead * 4 * mPageSize), " ... ", PacketFmt((const uint8_t*)lPageContents.data(), 4 * lPageContents.size()));
453 
454  // PART 2 : Transfer to reply buffer
455  const std::deque< std::pair< uint8_t* , uint32_t > >& lReplyBuffers ( lBuffers->getReplyBuffer() );
456  size_t lNrWordsInPacket = (lPageContents.at(0) >> 16) + (lPageContents.at(0) & 0xFFFF);
457  if (lNrWordsInPacket != (lBuffers->replyCounter() >> 2))
458  log (Warning(), "Expected reply packet to contain ", Integer(lBuffers->replyCounter() >> 2), " words, but it actually contains ", Integer(lNrWordsInPacket), " words");
459 
460  size_t lNrBytesCopied = 0;
461  for ( std::deque< std::pair< uint8_t* , uint32_t > >::const_iterator lIt = lReplyBuffers.begin() ; lIt != lReplyBuffers.end() ; ++lIt )
462  {
463  // Don't copy more of page than was written to, for cases when less data received than expected
464  if ( lNrBytesCopied >= 4*lNrWordsInPacket)
465  break;
466 
467  size_t lNrBytesToCopy = std::min( lIt->second , uint32_t(4*lNrWordsInPacket - lNrBytesCopied) );
468  memcpy ( lIt->first, &lPageContents.at(1 + (lNrBytesCopied / 4)), lNrBytesToCopy );
469  lNrBytesCopied += lNrBytesToCopy;
470  }
471 
472 
473  // PART 3 : Validate the packet contents
474  try
475  {
476  if ( uhal::exception::exception* lExc = ClientInterface::validate ( lBuffers ) ) //Control of the pointer has been passed back to the client interface
477  {
478  mAsynchronousException = lExc;
479  }
480  }
481  catch ( exception::exception& aExc )
482  {
483  mAsynchronousException = new exception::ValidationError ();
484  log ( *mAsynchronousException , "Exception caught during reply validation for mmap device with URI " , Quote ( this->uri() ) , "; what returned: " , Quote ( aExc.what() ) );
485  }
486 
488  {
490  }
491 }
492 
493 
494 } // end ns uhal
uhal::Mmap::File::open
void open()
Definition: ProtocolMmap.cpp:149
uhal::Mmap::File::write
void write(const uint32_t aAddr, const std::vector< std::pair< const uint8_t *, size_t > > &aData)
Definition: ProtocolMmap.cpp:208
uhal::Mmap::mIndexNextPage
uint32_t mIndexNextPage
Definition: ProtocolMmap.hpp:199
uhal::operator<<
std::ostream & operator<<(std::ostream &aStr, const uhal::HttpResponseType &aHttpResponse)
Definition: HttpResponseGrammar.cpp:41
uhal::exception::exception::what
virtual const char * what() const
Function which returns the error message associated with an exception If no error message has previou...
Definition: exception.cpp:87
uhal::dec
@ dec
Decimal.
Definition: log_inserters.integer.hpp:50
uhal::Mmap::mReplyQueue
std::deque< boost::shared_ptr< Buffers > > mReplyQueue
The list of buffers still awaiting a reply.
Definition: ProtocolMmap.hpp:202
boost::shared_ptr
Definition: DerivedNodeFactory.hpp:52
uhal::Mmap::File::~File
~File()
Definition: ProtocolMmap.cpp:121
uhal::Mmap::PacketFmt::~PacketFmt
~PacketFmt()
Definition: ProtocolMmap.cpp:86
uhal::URI::mArguments
NameValuePairVectorType mArguments
The "key1=val1&key2=val2&key3=val3" part of a URI of the form "protocol://host:port/patha/pathb/blah....
Definition: URI.hpp:62
uhal::Mmap::File::File
File(const std::string &aPath, int aFlags)
Definition: ProtocolMmap.cpp:110
uhal::IPbus
A class which provides the version-specific functionality for IPbus.
Definition: ProtocolIPbus.hpp:69
uhal::Mmap::implementDispatch
void implementDispatch(boost::shared_ptr< Buffers > aBuffers)
Send the IPbus buffer to the target, read back the response and call the packing-protocol's validate ...
Definition: ProtocolMmap.cpp:300
uhal::Mmap::File::read
void read(const uint32_t aAddr, const uint32_t aNrWords, std::vector< uint32_t > &aValues)
Definition: ProtocolMmap.cpp:195
uhal::Mmap::write
void write(const boost::shared_ptr< Buffers > &aBuffers)
Write request packet to next page in host-to-FPGA device file.
Definition: ProtocolMmap.cpp:389
uhal::IntFmt
Empty struct which acts as a dummy variable for passing the formatting information around.
Definition: log_inserters.integer.hpp:68
uhal::Mmap::mDeviceFile
File mDeviceFile
Definition: ProtocolMmap.hpp:195
uhal::min
@ min
minutes past the hour formatted as two digits e.g.
Definition: log_inserters.time.hpp:63
uhal::Mmap::Mmap
Mmap(const Mmap &aMmap)
uhal::Mmap::File::close
void close()
Definition: ProtocolMmap.cpp:175
uhal::Mmap::getMaxSendSize
uint32_t getMaxSendSize()
Return the maximum size to be sent based on the buffer size in the target.
Definition: ProtocolMmap.cpp:334
uhal::exception::exception
An abstract base exception class, including an interface to throw as the derived type (for passing ex...
Definition: exception.hpp:71
uhal::Mmap::Flush
virtual void Flush()
Concrete implementation of the synchronization function to block until all buffers have been sent,...
Definition: ProtocolMmap.cpp:313
uhal
Definition: HttpResponseGrammar.hpp:49
uhal::Mmap::mAsynchronousException
uhal::exception::exception * mAsynchronousException
A pointer to an exception object for passing exceptions from the worker thread to the main thread.
Definition: ProtocolMmap.hpp:208
log_inserters.quote.hpp
uhal::Mmap::File::setOffset
void setOffset(size_t aOffset)
Definition: ProtocolMmap.cpp:139
uhal::Info
InfoLevel Info
Definition: LogLevels.cpp:115
uhal::log
void log(FatalLevel &aFatal, const T0 &aArg0)
Function to add a log entry at Fatal level.
Definition: log.hxx:20
log_inserters.integer.hpp
uhal::Mmap::~Mmap
virtual ~Mmap()
Destructor.
Definition: ProtocolMmap.cpp:294
uhal::Integer
_Integer< T, IntFmt<> > Integer(const T &aT)
Forward declare a function which creates an instance of the ultra-lightweight wrapper from an integer...
Definition: log_inserters.integer.hxx:43
uhal::Mmap::mPublishedReplyPageCount
uint32_t mPublishedReplyPageCount
Definition: ProtocolMmap.hpp:199
uhal::hex
@ hex
Hexadecimal.
Definition: log_inserters.integer.hpp:51
uhal::Mmap::PacketFmt::mData
const std::vector< std::pair< const uint8_t *, size_t > > mData
Definition: ProtocolMmap.hpp:92
uhal::Warning
WarningLevel Warning
Definition: LogLevels.cpp:79
uhal::exception::exception::throwAsDerivedType
virtual void throwAsDerivedType()=0
Function which casts a pointer from the base type of this object to a derived type of this object and...
ProtocolMmap.hpp
uhal::Mmap::PacketFmt::PacketFmt
PacketFmt(const uint8_t *const, const size_t)
Definition: ProtocolMmap.cpp:75
uhal::Mmap::getMaxReplySize
uint32_t getMaxReplySize()
Return the maximum size of reply packet based on the buffer size in the target.
Definition: ProtocolMmap.cpp:343
uhal::Error
ErrorLevel Error
Definition: LogLevels.cpp:61
uhal::Quote
_Quote< T > Quote(const T &aT)
Definition: log_inserters.quote.hxx:49
uhal::Mmap::mNumberOfPages
uint32_t mNumberOfPages
Definition: ProtocolMmap.hpp:199
uhal::tests::uri
std::string uri
Definition: test_single.cpp:89
uhal::Mmap::disconnect
void disconnect()
Close the connection to the device.
Definition: ProtocolMmap.cpp:382
uhal::Debug
DebugLevel Debug
Definition: LogLevels.cpp:133
uhal::Mmap::mPageSize
uint32_t mPageSize
Definition: ProtocolMmap.hpp:199
uhal::Mmap::mSleepDuration
boost::chrono::microseconds mSleepDuration
Definition: ProtocolMmap.hpp:197
uhal::Mmap::mConnected
bool mConnected
Definition: ProtocolMmap.hpp:193
uhal::Notice
NoticeLevel Notice
Definition: LogLevels.cpp:97
log.hpp
uhal::Mmap::connect
void connect()
Set up the connection to the device.
Definition: ProtocolMmap.cpp:352
uhal::Mmap::File::getPath
const std::string & getPath() const
Definition: ProtocolMmap.cpp:127
uhal::Mmap::File::setPath
void setPath(const std::string &aPath)
Definition: ProtocolMmap.cpp:133
uhal::ClientInterface::returnBufferToPool
void returnBufferToPool(boost::shared_ptr< Buffers > &aBuffers)
Function to return a buffer to the buffer pool.
Definition: ClientInterface.cpp:221
uhal::Mmap::PacketFmt
Definition: ProtocolMmap.hpp:86
uhal::Mmap::mReadReplyPageCount
uint32_t mReadReplyPageCount
Definition: ProtocolMmap.hpp:199
LogLevels.hpp
URI.hpp
uhal::URI
Struct to store a URI when parsed by boost spirit.
Definition: URI.hpp:50
uhal::ClientInterface::validate
virtual exception::exception * validate(boost::shared_ptr< Buffers > aBuffers)
Function which dispatch calls when the reply is received to check that the headers are as expected.
Definition: ClientInterface.cpp:188
Buffers.hpp
MAP_SIZE
#define MAP_SIZE
Definition: ProtocolMmap.cpp:145
uhal::Mmap::dispatchExceptionHandler
virtual void dispatchExceptionHandler()
Function which tidies up this protocol layer in the event of an exception.
Definition: ProtocolMmap.cpp:322
uhal::Mmap::read
void read()
Read next pending reply packet from appropriate page of FPGA-to-host device file, and validate conten...
Definition: ProtocolMmap.cpp:406
ClientFactory.hpp