|
FreeNOS
|
Manages memory shares for a Process. More...
#include <ProcessShares.h>
Data Structures | |
| struct | MemoryShare |
Public Types | |
| enum | Result { Success, InvalidArgument, MemoryMapError, OutOfMemory, AlreadyExists, DetachInProgress, NotFound } |
Public Member Functions | |
| ProcessShares (ProcessID pid) | |
| Constructor. More... | |
| virtual | ~ProcessShares () |
| Destructor function. More... | |
| const ProcessID | getProcessID () const |
| Get process. More... | |
| MemoryContext * | getMemoryContext () |
| Get MemoryContext object. More... | |
| Result | setMemoryContext (MemoryContext *context) |
| Set MemoryContext. More... | |
| Result | createShare (ProcessShares &instance, MemoryShare *share) |
| Result | createShare (ProcessID pid, Size coreId, Size tagId, Address virt, Size size) |
| Create memory share. More... | |
| Result | readShare (MemoryShare *share) |
| Read memory share by Process, Core and Tag IDs. More... | |
| Result | removeShares (ProcessID pid) |
| Remove all shares for the given ProcessID. More... | |
Private Member Functions | |
| Result | releaseShare (MemoryShare *share, Size idx) |
| Release one memory share. More... | |
| MemoryShare * | findShare (const ProcessID pid, const Size coreId, const Size tagId) |
| Retrieve MemoryShare object. More... | |
Private Attributes | |
| ProcessID | m_pid |
| ProcessID associated to these shares. More... | |
| MemoryContext * | m_memory |
| MemoryContext instance. More... | |
| Index< MemoryShare, MaximumMemoryShares > | m_shares |
| Contains all memory shares. More... | |
Static Private Attributes | |
| static const Size | MaximumMemoryShares = 32u |
| Maximum number of memory shares that a single process can have. More... | |
Manages memory shares for a Process.
Definition at line 39 of file ProcessShares.h.
| Enumerator | |
|---|---|
| Success | |
| InvalidArgument | |
| MemoryMapError | |
| OutOfMemory | |
| AlreadyExists | |
| DetachInProgress | |
| NotFound | |
Definition at line 66 of file ProcessShares.h.
| ProcessShares::ProcessShares | ( | ProcessID | pid | ) |
|
virtual |
Destructor function.
Definition at line 33 of file ProcessShares.cpp.
References List< T >::append(), List< T >::contains(), ProcessManager::get(), Kernel::getProcessManager(), ListIterator< T >::hasCurrent(), WeakSingleton< Kernel >::instance(), m_pid, m_shares, ProcessShares::MemoryShare::pid, ProcessTerminated, ProcessManager::raiseEvent(), releaseShare(), and ProcessEvent::type.
| ProcessShares::Result ProcessShares::createShare | ( | ProcessID | pid, |
| Size | coreId, | ||
| Size | tagId, | ||
| Address | virt, | ||
| Size | size | ||
| ) |
Create memory share.
| pid | ProcessID for the share. |
| coreId | CoreID for the share. |
| tagId | TagID for the share. |
| virt | Virtual address of the share. |
| size | Size of the share. |
Definition at line 84 of file ProcessShares.cpp.
References Memory::Range::access, MemoryContext::access(), assert, ProcessShares::MemoryShare::attached, ProcessShares::MemoryShare::coreId, coreId, CoreInfo::coreId, coreInfo, ERROR, InvalidArgument, KERNEL_PID, MemoryContext::lookup(), m_memory, m_shares, MemoryMapError, OutOfMemory, PAGEMASK, PAGESIZE, Memory::Range::phys, ProcessShares::MemoryShare::pid, ProcessShares::MemoryShare::range, Memory::Range::size, MemoryContext::Success, Success, ProcessShares::MemoryShare::tagId, Memory::Range::virt, and ZERO.
| ProcessShares::Result ProcessShares::createShare | ( | ProcessShares & | instance, |
| ProcessShares::MemoryShare * | share | ||
| ) |
Definition at line 142 of file ProcessShares.cpp.
References Memory::Range::access, Allocator::Range::address, Allocator::Range::alignment, AlreadyExists, ProcessShares::MemoryShare::attached, Cache::cleanData(), MemoryBlock::copy(), ProcessShares::MemoryShare::coreId, CoreInfo::coreId, DetachInProgress, ERROR, MemoryContext::findFree(), findShare(), ProcessManager::get(), Kernel::getCoreInfo(), getMemoryContext(), getProcessID(), Kernel::getProcessManager(), WeakSingleton< Kernel >::instance(), InvalidArgument, m_memory, m_pid, m_shares, MemoryContext::mapRangeContiguous(), OutOfMemory, PAGESIZE, Memory::Range::phys, ProcessShares::MemoryShare::pid, ProcessManager::raiseEvent(), ProcessShares::MemoryShare::range, MemoryBlock::set(), ProcessEvent::share, ShareCreated, Memory::Range::size, Allocator::Range::size, MemoryContext::Success, Allocator::Success, Success, ProcessShares::MemoryShare::tagId, ProcessEvent::type, Memory::User, MemoryMap::UserShare, Memory::Range::virt, and ZERO.
Referenced by Process::initialize(), and VMShareHandler().
|
private |
Retrieve MemoryShare object.
| pid | ProcessID value to match |
| coreId | CoreID value to match |
| tagId | TagID value to match |
Definition at line 334 of file ProcessShares.cpp.
References assert, ProcessShares::MemoryShare::coreId, coreId, CoreInfo::coreId, coreInfo, m_shares, ProcessShares::MemoryShare::pid, ProcessShares::MemoryShare::tagId, and ZERO.
Referenced by createShare(), and readShare().
| MemoryContext * ProcessShares::getMemoryContext | ( | ) |
Get MemoryContext object.
Definition at line 73 of file ProcessShares.cpp.
References m_memory.
Referenced by createShare().
| const ProcessID ProcessShares::getProcessID | ( | ) | const |
Get process.
Definition at line 68 of file ProcessShares.cpp.
References m_pid.
Referenced by createShare().
| ProcessShares::Result ProcessShares::readShare | ( | MemoryShare * | share | ) |
Read memory share by Process, Core and Tag IDs.
| share | MemoryShare buffer (input/output). |
Definition at line 358 of file ProcessShares.cpp.
References MemoryBlock::copy(), ProcessShares::MemoryShare::coreId, findShare(), NotFound, ProcessShares::MemoryShare::pid, Success, ProcessShares::MemoryShare::tagId, and ZERO.
Referenced by VMShareHandler().
|
private |
Release one memory share.
| share | MemoryShare object pointer |
| idx | Index position of the object |
Definition at line 272 of file ProcessShares.cpp.
References assert, ProcessShares::MemoryShare::attached, ProcessShares::MemoryShare::coreId, CoreInfo::coreId, coreInfo, ProcessManager::get(), Kernel::getAllocator(), Kernel::getProcessManager(), Process::getShares(), WeakSingleton< Kernel >::instance(), m_memory, m_pid, m_shares, NotFound, PAGESIZE, Memory::Range::phys, ProcessShares::MemoryShare::pid, ProcessShares::MemoryShare::range, Allocator::release(), Memory::Range::size, Success, and MemoryContext::unmapRange().
Referenced by removeShares(), and ~ProcessShares().
| ProcessShares::Result ProcessShares::removeShares | ( | ProcessID | pid | ) |
Remove all shares for the given ProcessID.
| pid | ProcessID to remove all shares for |
Definition at line 254 of file ProcessShares.cpp.
References m_shares, ProcessShares::MemoryShare::pid, releaseShare(), Success, and ZERO.
Referenced by VMShareHandler().
| ProcessShares::Result ProcessShares::setMemoryContext | ( | MemoryContext * | context | ) |
Set MemoryContext.
| context | MemoryContext object |
Definition at line 78 of file ProcessShares.cpp.
References m_memory, and Success.
Referenced by Process::initialize().
|
private |
MemoryContext instance.
Definition at line 180 of file ProcessShares.h.
Referenced by createShare(), getMemoryContext(), ProcessShares(), releaseShare(), and setMemoryContext().
|
private |
ProcessID associated to these shares.
Definition at line 177 of file ProcessShares.h.
Referenced by createShare(), getProcessID(), ProcessShares(), releaseShare(), and ~ProcessShares().
|
private |
Contains all memory shares.
Definition at line 183 of file ProcessShares.h.
Referenced by createShare(), findShare(), releaseShare(), removeShares(), and ~ProcessShares().
|
staticprivate |
Maximum number of memory shares that a single process can have.
Definition at line 44 of file ProcessShares.h.
1.8.17