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
43class MemoryChannel : public Channel
44{
45 private:
46
50 typedef struct RingHead
51 {
54 }
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 */
Input/Output operations specific to the ARM architecture.
Definition ARMIO.h:40
Unidirectional point-to-point messaging channel.
Definition Channel.h:35
Mode
Channel modes.
Definition Channel.h:57
Result
Result codes.
Definition Channel.h:42
Unidirectional point-to-point channel using shared memory.
Result setPhysical(const Address data, const Address feedback, const bool hardReset=true)
Set memory pages by physical address.
virtual Result flush()
Flush message buffers.
Result unmap()
Unmap memory pages from virtual address space.
Result flushPage(const Address page) const
Flush memory page.
Arch::IO m_data
The data page.
const Size m_maximumMessages
Maximum number of messages that can be stored.
virtual Result read(void *buffer)
Read a message.
virtual ~MemoryChannel()
Destructor.
bool operator==(const MemoryChannel &ch) const
virtual Result write(const void *buffer)
Write a message.
RingHead m_head
Local RingHead.
struct MemoryChannel::RingHead RingHead
Defines in-memory ring header.
Result reset(const bool hardReset)
Reset to initial state.
Arch::IO m_feedback
The feedback page.
Result setVirtual(const Address data, const Address feedback, const bool hardReset=true)
Set memory pages by virtual address.
bool operator!=(const MemoryChannel &ch) const
unsigned long Address
A memory address.
Definition Types.h:131
unsigned int Size
Any sane size indicator cannot go negative.
Definition Types.h:128
Defines in-memory ring header.
Size index
Index where the ring buffer starts.