FreeNOS
ProcessShares.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 __KERNEL_PROCESSSHARES_H
19 #define __KERNEL_PROCESSSHARES_H
20 
21 #include <Types.h>
22 #include <Macros.h>
23 #include <List.h>
24 #include <MemoryMap.h>
25 #include <Index.h>
26 
27 class MemoryChannel;
28 class MemoryContext;
29 class Process;
30 
40 {
41  private:
42 
44  static const Size MaximumMemoryShares = 32u;
45 
46  public:
47 
48  struct MemoryShare
49  {
52 
55 
58 
61 
63  bool attached;
64  };
65 
66  enum Result
67  {
75  };
76 
81 
85  virtual ~ProcessShares();
86 
90  const ProcessID getProcessID() const;
91 
98 
107 
111  Result createShare(ProcessShares & instance,
112  MemoryShare *share);
113 
126  Size coreId,
127  Size tagId,
128  Address virt,
129  Size size);
130 
138  Result readShare(MemoryShare *share);
139 
148 
149  private:
150 
159  Result releaseShare(MemoryShare *share, Size idx);
160 
170  MemoryShare * findShare(const ProcessID pid,
171  const Size coreId,
172  const Size tagId);
173 
174  private:
175 
178 
181 
184 };
185 
190 #endif /* __KERNEL_PROCESSSHARES_H */
ProcessShares::~ProcessShares
virtual ~ProcessShares()
Destructor function.
Definition: ProcessShares.cpp:33
ProcessShares::MemoryShare::tagId
Size tagId
Share tag id is defined by the application.
Definition: ProcessShares.h:57
Memory::Range
Memory range.
Definition: Memory.h:55
MemoryContext
Virtual memory abstract interface.
Definition: MemoryContext.h:42
ProcessShares::MemoryShare
Definition: ProcessShares.h:48
Macros.h
ProcessShares::MemoryShare::pid
ProcessID pid
Remote process id for this share.
Definition: ProcessShares.h:51
Types.h
Process
Represents a process which may run on the host.
Definition: Process.h:44
Index.h
ProcessShares::OutOfMemory
@ OutOfMemory
Definition: ProcessShares.h:71
Index
Index is a N-sized array of pointers to items of type T.
Definition: Index.h:36
ProcessID
u32 ProcessID
Process Identification Number.
Definition: Types.h:140
Address
unsigned long Address
A memory address.
Definition: Types.h:131
ProcessShares::MaximumMemoryShares
static const Size MaximumMemoryShares
Maximum number of memory shares that a single process can have.
Definition: ProcessShares.h:44
ProcessShares::MemoryShare::range
Memory::Range range
Physical memory address range.
Definition: ProcessShares.h:60
ProcessShares::MemoryShare::coreId
Size coreId
CoreId for the other process.
Definition: ProcessShares.h:54
ProcessShares::MemoryMapError
@ MemoryMapError
Definition: ProcessShares.h:70
ProcessShares::ProcessShares
ProcessShares(ProcessID pid)
Constructor.
Definition: ProcessShares.cpp:27
Size
unsigned int Size
Any sane size indicator cannot go negative.
Definition: Types.h:128
MemoryMap.h
MemoryChannel
Unidirectional point-to-point channel using shared memory.
Definition: MemoryChannel.h:43
ProcessShares::readShare
Result readShare(MemoryShare *share)
Read memory share by Process, Core and Tag IDs.
Definition: ProcessShares.cpp:358
ProcessShares::createShare
Result createShare(ProcessShares &instance, MemoryShare *share)
Definition: ProcessShares.cpp:142
ProcessShares::findShare
MemoryShare * findShare(const ProcessID pid, const Size coreId, const Size tagId)
Retrieve MemoryShare object.
Definition: ProcessShares.cpp:334
ProcessShares::MemoryShare::attached
bool attached
True if the share is attached (used by both processes)
Definition: ProcessShares.h:63
ProcessShares::getMemoryContext
MemoryContext * getMemoryContext()
Get MemoryContext object.
Definition: ProcessShares.cpp:73
ProcessShares::releaseShare
Result releaseShare(MemoryShare *share, Size idx)
Release one memory share.
Definition: ProcessShares.cpp:272
ProcessShares::getProcessID
const ProcessID getProcessID() const
Get process.
Definition: ProcessShares.cpp:68
ProcessShares::m_shares
Index< MemoryShare, MaximumMemoryShares > m_shares
Contains all memory shares.
Definition: ProcessShares.h:183
ProcessShares::NotFound
@ NotFound
Definition: ProcessShares.h:74
ProcessShares::Result
Result
Definition: ProcessShares.h:66
ProcessShares::m_memory
MemoryContext * m_memory
MemoryContext instance.
Definition: ProcessShares.h:180
ProcessShares::removeShares
Result removeShares(ProcessID pid)
Remove all shares for the given ProcessID.
Definition: ProcessShares.cpp:254
ProcessShares::DetachInProgress
@ DetachInProgress
Definition: ProcessShares.h:73
coreId
u8 coreId
Definition: IntelACPI.h:64
ProcessShares::InvalidArgument
@ InvalidArgument
Definition: ProcessShares.h:69
ProcessShares::AlreadyExists
@ AlreadyExists
Definition: ProcessShares.h:72
ProcessShares::setMemoryContext
Result setMemoryContext(MemoryContext *context)
Set MemoryContext.
Definition: ProcessShares.cpp:78
List.h
ProcessShares::m_pid
ProcessID m_pid
ProcessID associated to these shares.
Definition: ProcessShares.h:177
ProcessShares
Manages memory shares for a Process.
Definition: ProcessShares.h:39
ProcessShares::Success
@ Success
Definition: ProcessShares.h:68