FreeNOS
|
Unidirectional point-to-point channel using shared memory. More...
#include <MemoryChannel.h>
Data Structures | |
struct | RingHead |
Defines in-memory ring header. More... | |
Public Member Functions | |
MemoryChannel (const Mode mode, const Size messageSize) | |
Constructor. More... | |
virtual | ~MemoryChannel () |
Destructor. More... | |
Result | setVirtual (const Address data, const Address feedback, const bool hardReset=true) |
Set memory pages by virtual address. More... | |
Result | setPhysical (const Address data, const Address feedback, const bool hardReset=true) |
Set memory pages by physical address. More... | |
Result | unmap () |
Unmap memory pages from virtual address space. More... | |
virtual Result | read (void *buffer) |
Read a message. More... | |
virtual Result | write (const void *buffer) |
Write a message. More... | |
virtual Result | flush () |
Flush message buffers. More... | |
bool | operator== (const MemoryChannel &ch) const |
bool | operator!= (const MemoryChannel &ch) const |
Public Member Functions inherited from Channel | |
Channel (const Mode mode, const Size messageSize) | |
Constructor. More... | |
virtual | ~Channel () |
Destructor. More... | |
const Size | getMessageSize () const |
Get message size. More... | |
Private Types | |
typedef struct MemoryChannel::RingHead | RingHead |
Defines in-memory ring header. More... | |
Private Member Functions | |
Result | reset (const bool hardReset) |
Reset to initial state. More... | |
Result | flushPage (const Address page) const |
Flush memory page. More... | |
Private Attributes | |
const Size | m_maximumMessages |
Maximum number of messages that can be stored. More... | |
Arch::IO | m_data |
The data page. More... | |
Arch::IO | m_feedback |
The feedback page. More... | |
RingHead | m_head |
Local RingHead. More... | |
Additional Inherited Members | |
Public Types inherited from Channel | |
enum | Result { Success, InvalidArgument, InvalidMode, InvalidSize, IOError, ChannelFull, NotFound, NotSupported } |
Result codes. More... | |
enum | Mode { Producer, Consumer } |
Channel modes. More... | |
Protected Attributes inherited from Channel | |
const Mode | m_mode |
Channel mode. More... | |
const Size | m_messageSize |
Message size. More... | |
Unidirectional point-to-point channel using shared memory.
Implemented by using two separated memory pages. The data page is for the consumer in which it only reads the incoming data payloads. The producer writes payloads to the data page. The feedback page is written only by the consumer, where it stores the feedback information from its consumption.
Definition at line 43 of file MemoryChannel.h.
|
private |
Defines in-memory ring header.
|
virtual |
Destructor.
Definition at line 33 of file MemoryChannel.cpp.
|
virtual |
Flush message buffers.
Ensures that all messages are written through caches.
Reimplemented from Channel.
Definition at line 158 of file MemoryChannel.cpp.
References Channel::Consumer, flushPage(), IO::getBase(), m_data, m_feedback, Channel::m_mode, Channel::Producer, and Channel::Success.
Referenced by Process::raiseEvent(), CoreServer::sendToMaster(), and CoreServer::sendToSlave().
|
private |
Flush memory page.
page | Memory page to flush |
Definition at line 170 of file MemoryChannel.cpp.
References CacheClean, Cache::cleanData(), ERROR, Channel::IOError, isKernel, SELF, Channel::Success, API::Success, Memory::Range::virt, and VMCtl().
Referenced by flush().
|
inline |
Definition at line 147 of file MemoryChannel.h.
|
inline |
Definition at line 142 of file MemoryChannel.h.
|
virtual |
Read a message.
buffer | Output buffer for the message. |
Reimplemented from Channel.
Definition at line 116 of file MemoryChannel.cpp.
References MemoryChannel::RingHead::index, m_data, m_feedback, m_head, m_maximumMessages, Channel::m_messageSize, Channel::NotFound, ARMIO::read(), Channel::Success, and ARMIO::write().
Referenced by ChannelServer< DatastoreServer, DatastoreMessage >::readKernelEvents(), MpiTarget::receive(), CoreServer::receiveFromMaster(), and CoreServer::receiveFromSlave().
|
private |
Reset to initial state.
hardReset | True to always start using the channel from beginning of data/feedback pages. False for soft-reset to read the new value of m_head back from the data page. |
Definition at line 37 of file MemoryChannel.cpp.
References Channel::Consumer, m_data, m_feedback, m_head, Channel::m_mode, Channel::Producer, ARMIO::read(), MemoryBlock::set(), and Channel::Success.
Referenced by MemoryChannel(), setPhysical(), and setVirtual().
MemoryChannel::Result MemoryChannel::setPhysical | ( | const Address | data, |
const Address | feedback, | ||
const bool | hardReset = true |
||
) |
Set memory pages by physical address.
This function maps the given physical addresses into the current address space using IO::map.
data | Physical memory address of the data page. Read/Write for the producer, Read-only for the consumer. |
feedback | Physical memory address of the feedback page. Read/write for the consumer, read-only for the producer. |
hardReset | Perform a hard reset after setting pages. |
Definition at line 64 of file MemoryChannel.cpp.
References Channel::Consumer, ERROR, Channel::IOError, m_data, m_feedback, Channel::m_mode, IO::map(), PAGESIZE, Channel::Producer, Memory::Readable, reset(), IO::Success, Memory::User, and Memory::Writable.
Referenced by MpiProxy::createChannels(), MpiTarget::createReadChannel(), MpiTarget::createWriteChannel(), and CoreServer::setupChannels().
MemoryChannel::Result MemoryChannel::setVirtual | ( | const Address | data, |
const Address | feedback, | ||
const bool | hardReset = true |
||
) |
Set memory pages by virtual address.
This function assumes that the given virtual addresses are already mapped into the associated address space.
data | Virtual memory address of the data page. Read/Write for the producer, Read-only for the consumer. |
feedback | Virtual memory address of the feedback page. Read/write for the consumer, read-only for the producer. |
hardReset | Perform a hard reset after setting pages. |
Definition at line 54 of file MemoryChannel.cpp.
References m_data, m_feedback, reset(), and IO::setBase().
Referenced by ChannelServer< DatastoreServer, DatastoreMessage >::accept(), ChannelServer< DatastoreServer, DatastoreMessage >::ChannelServer(), ChannelClient::connect(), and Process::initialize().
MemoryChannel::Result MemoryChannel::unmap | ( | ) |
Unmap memory pages from virtual address space.
Definition at line 99 of file MemoryChannel.cpp.
References Channel::IOError, m_data, m_feedback, Channel::Success, IO::Success, and IO::unmap().
Referenced by MpiProxy::createChannels().
|
virtual |
Write a message.
buffer | Input buffer for the message. |
Reimplemented from Channel.
Definition at line 138 of file MemoryChannel.cpp.
References Channel::ChannelFull, MemoryChannel::RingHead::index, m_data, m_feedback, m_head, m_maximumMessages, Channel::m_messageSize, ARMIO::read(), Channel::Success, and ARMIO::write().
Referenced by MpiProxy::processSend(), Process::raiseEvent(), MpiTarget::send(), CoreServer::sendToMaster(), and CoreServer::sendToSlave().
|
private |
The data page.
Definition at line 179 of file MemoryChannel.h.
Referenced by flush(), read(), reset(), setPhysical(), setVirtual(), unmap(), and write().
|
private |
The feedback page.
Definition at line 182 of file MemoryChannel.h.
Referenced by flush(), read(), reset(), setPhysical(), setVirtual(), unmap(), and write().
|
private |
|
private |
Maximum number of messages that can be stored.
Definition at line 176 of file MemoryChannel.h.