FreeNOS
MemoryChannel.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __LIBIPC_MEMORYCHANNEL_H
19 #define __LIBIPC_MEMORYCHANNEL_H
20 
21 #include <FreeNOS/System.h>
22 #include <Types.h>
23 #include "Channel.h"
24 
43 class MemoryChannel : public Channel
44 {
45  private:
46 
50  typedef struct RingHead
51  {
54  }
55  RingHead;
56 
57  public:
58 
65  MemoryChannel(const Mode mode, const Size messageSize);
66 
70  virtual ~MemoryChannel();
71 
86  Result setVirtual(const Address data,
87  const Address feedback,
88  const bool hardReset = true);
89 
104  Result setPhysical(const Address data,
105  const Address feedback,
106  const bool hardReset = true);
107 
113  Result unmap();
114 
122  virtual Result read(void *buffer);
123 
131  virtual Result write(const void *buffer);
132 
140  virtual Result flush();
141 
142  bool operator == (const MemoryChannel & ch) const
143  {
144  return false;
145  }
146 
147  bool operator != (const MemoryChannel & ch) const
148  {
149  return false;
150  }
151 
152  private:
153 
162  Result reset(const bool hardReset);
163 
171  Result flushPage(const Address page) const;
172 
173  private:
174 
177 
180 
183 
186 };
187 
193 #endif /* __LIBIPC_MEMORYCHANNEL_H */
Channel
Unidirectional point-to-point messaging channel.
Definition: Channel.h:34
MemoryChannel::m_maximumMessages
const Size m_maximumMessages
Maximum number of messages that can be stored.
Definition: MemoryChannel.h:176
MemoryChannel::RingHead::index
Size index
Index where the ring buffer starts.
Definition: MemoryChannel.h:53
Types.h
MemoryChannel::setVirtual
Result setVirtual(const Address data, const Address feedback, const bool hardReset=true)
Set memory pages by virtual address.
Definition: MemoryChannel.cpp:54
MemoryChannel::setPhysical
Result setPhysical(const Address data, const Address feedback, const bool hardReset=true)
Set memory pages by physical address.
Definition: MemoryChannel.cpp:64
ARMIO
Input/Output operations specific to the ARM architecture.
Definition: ARMIO.h:39
Channel::Mode
Mode
Channel modes.
Definition: Channel.h:56
MemoryChannel::MemoryChannel
MemoryChannel(const Mode mode, const Size messageSize)
Constructor.
Definition: MemoryChannel.cpp:23
Address
unsigned long Address
A memory address.
Definition: Types.h:131
Channel.h
MemoryChannel::m_data
Arch::IO m_data
The data page.
Definition: MemoryChannel.h:179
MemoryChannel::RingHead
Defines in-memory ring header.
Definition: MemoryChannel.h:50
MemoryChannel::~MemoryChannel
virtual ~MemoryChannel()
Destructor.
Definition: MemoryChannel.cpp:33
Size
unsigned int Size
Any sane size indicator cannot go negative.
Definition: Types.h:128
MemoryChannel::write
virtual Result write(const void *buffer)
Write a message.
Definition: MemoryChannel.cpp:138
MemoryChannel::operator!=
bool operator!=(const MemoryChannel &ch) const
Definition: MemoryChannel.h:147
MemoryChannel
Unidirectional point-to-point channel using shared memory.
Definition: MemoryChannel.h:43
MemoryChannel::flush
virtual Result flush()
Flush message buffers.
Definition: MemoryChannel.cpp:158
MemoryChannel::read
virtual Result read(void *buffer)
Read a message.
Definition: MemoryChannel.cpp:116
MemoryChannel::reset
Result reset(const bool hardReset)
Reset to initial state.
Definition: MemoryChannel.cpp:37
Channel::Result
Result
Result codes.
Definition: Channel.h:41
MemoryChannel::m_feedback
Arch::IO m_feedback
The feedback page.
Definition: MemoryChannel.h:182
MemoryChannel::unmap
Result unmap()
Unmap memory pages from virtual address space.
Definition: MemoryChannel.cpp:99
MemoryChannel::flushPage
Result flushPage(const Address page) const
Flush memory page.
Definition: MemoryChannel.cpp:170
MemoryChannel::m_head
RingHead m_head
Local RingHead.
Definition: MemoryChannel.h:185
MemoryChannel::RingHead
struct MemoryChannel::RingHead RingHead
Defines in-memory ring header.
MemoryChannel::operator==
bool operator==(const MemoryChannel &ch) const
Definition: MemoryChannel.h:142