FreeNOS
Functions
API (kernel handlers)

API handlers contain the kernel side implementation of the Application Programming Interface (API). More...

Functions

API::Result PrivExecHandler (const PrivOperation op, const Address param)
 Prototype for kernel handler. More...
 
API::Result ProcessCtlHandler (const ProcessID proc, const ProcessOperation op, const Address addr, const Address output)
 Kernel handler prototype. More...
 
API::Result SystemInfoHandler (SystemInformation *info)
 Kernel prototype. More...
 
API::Result VMCopyHandler (const ProcessID proc, const API::Operation how, const Address ours, const Address theirs, const Size sz)
 Kernel handler prototype. More...
 
API::Result VMCtlHandler (const ProcessID procID, const MemoryOperation op, Memory::Range *range)
 Kernel handler prototype. More...
 
API::Result VMShareHandler (const ProcessID pid, const API::Operation op, ProcessShares::MemoryShare *share)
 Kernel handler prototype. More...
 

Detailed Description

API handlers contain the kernel side implementation of the Application Programming Interface (API).

Function Documentation

◆ PrivExecHandler()

API::Result PrivExecHandler ( const PrivOperation  op,
const Address  param 
)

Prototype for kernel handler.

Performs various privileged operations.

Parameters
opThe operation to perform.
paramOptional parameter value for the given operation
Returns
API::Success on success and other API::ErrorCode on failure.

Definition at line 23 of file PrivExec.cpp.

References assert, cpu_reboot, cpu_shutdown, ProcessManager::current(), DEBUG, FATAL, Kernel::getProcessManager(), Idle, WeakSingleton< Kernel >::instance(), WeakSingleton< Log >::instance(), API::InvalidArgument, Panic, param(), RebootSystem, ProcessManager::setIdle(), ShutdownSystem, API::Success, WriteConsole, and ZERO.

Referenced by API::API().

◆ ProcessCtlHandler()

API::Result ProcessCtlHandler ( const ProcessID  proc,
const ProcessOperation  op,
const Address  addr,
const Address  output 
)

Kernel handler prototype.

Process management related operations.

Parameters
procTarget Process' ID.
opThe operation to perform.
addrInput argument address, used for program entry point for Spawn, ProcessInfo pointer for Info.
outputOutput argument address (optional).
Returns
API::Success on success and other API::ErrorCode on failure. For WaitPID, the process exit status is stored in the upper 16-bits of this return value on success. For Spawn, the new PID is stored in the upper 16-bits.

Definition at line 27 of file ProcessCtl.cpp.

References ProcessManager::create(), ProcessManager::current(), DEBUG, DisableIRQ, EnableIRQ, Kernel::enableIRQ(), EnterSleep, ERROR, ProcessManager::get(), Timer::getCurrent(), Process::getID(), GetParent, Process::getParent(), GetPID, Kernel::getProcessManager(), Process::getState(), Kernel::getTimer(), Process::getWaitResult(), ProcessInfo::id, InfoPID, InfoTimer, WeakSingleton< Kernel >::instance(), API::IOError, KillPID, API::NotFound, ProcessInfo::parent, ProcessManager::registerInterruptNotify(), ProcessManager::remove(), Reset, ProcessManager::reset(), Resume, ProcessManager::resume(), Schedule, ProcessManager::schedule(), SELF, SendIRQ, Kernel::sendIRQ(), ProcessManager::sleep(), Spawn, ProcessInfo::state, Stop, ProcessManager::stop(), ProcessManager::Success, API::Success, ProcessManager::wait(), WaitPID, WaitTimer, Wakeup, ProcessManager::wakeup(), WatchIRQ, and ZERO.

Referenced by API::API().

◆ SystemInfoHandler()

API::Result SystemInfoHandler ( SystemInformation info)

◆ VMCopyHandler()

API::Result VMCopyHandler ( const ProcessID  proc,
const API::Operation  how,
const Address  ours,
const Address  theirs,
const Size  sz 
)

Kernel handler prototype.

Copies virtual memory between two processes.

Parameters
procRemote process.
howRead or Write.
oursVirtual address of the buffer of this process.
theirsVirtual address of the remote process' buffer.
szAmount of memory to copy.
Returns
API::Success on success and any other value on error.
Bug:
VMCopyHandler assumes the theirs parameter points to memory mapped as a small page (PAGESIZE, 4KiB) When that memory is actually a large mapping (for example 1MiB on ARM), the internal pageOff variable will be zero.

Definition at line 24 of file VMCopy.cpp.

References API::AccessViolation, assert, MemoryBlock::copy(), ProcessManager::current(), DEBUG, ERROR, MemoryContext::findFree(), ProcessManager::get(), Process::getMemoryContext(), Kernel::getProcessManager(), WeakSingleton< Kernel >::instance(), API::IOError, MemoryMap::KernelPrivate, MemoryContext::lookup(), MemoryContext::map(), API::NotFound, PAGEMASK, PAGESIZE, API::RangeError, API::Read, Memory::Readable, API::ReadPhys, SELF, MemoryContext::Success, API::Success, MemoryContext::unmap(), Memory::Writable, and API::Write.

Referenced by API::API().

◆ VMCtlHandler()

API::Result VMCtlHandler ( const ProcessID  procID,
const MemoryOperation  op,
Memory::Range range 
)

◆ VMShareHandler()

API::Result VMShareHandler ( const ProcessID  pid,
const API::Operation  op,
ProcessShares::MemoryShare share 
)

Kernel handler prototype.

Creates and removes shared virtual memory mappings.

Parameters
pidRemote process.
opDetermines which operation to perform.
sharePointer to the MemoryShare to use in the operation
Returns
API::Success on success and other API::ErrorCode on failure.

Definition at line 25 of file VMShare.cpp.

References ProcessShares::AlreadyExists, API::AlreadyExists, API::Create, ProcessShares::createShare(), ProcessManager::current(), DEBUG, API::Delete, ProcessShares::DetachInProgress, ProcessManager::get(), Kernel::getProcessManager(), Process::getShares(), WeakSingleton< Kernel >::instance(), API::InvalidArgument, API::IOError, API::NotFound, API::Read, ProcessShares::readShare(), ProcessShares::removeShares(), SELF, ProcessShares::Success, API::Success, API::TemporaryUnavailable, and ZERO.

Referenced by API::API().