The Pedigree Project 0.1
Static Public Member Functions | Static Public Attributes | Static Private Member Functions | Static Private Attributes | Friends | List of all members
ProcessorBase Class Reference

#include <Processor.h>

+ Inheritance diagram for ProcessorBase:
+ Collaboration diagram for ProcessorBase:

Static Public Member Functions

static void initialise1 (const BootstrapStruct_t &Info) INITIALISATION_ONLY
 first stage in the initialisation of the processor-specific interface
 
static void initialise2 (const BootstrapStruct_t &Info) INITIALISATION_ONLY
 second/last stage in the initialisation of the processor-specific interface
 
static void initialisationDone ()
 
static void deinitialise ()
 
static size_t isInitialised ()
 
static uintptr_t getBasePointer ()
 
static uintptr_t getStackPointer ()
 
static uintptr_t getInstructionPointer ()
 
static void switchAddressSpace (VirtualAddressSpace &AddressSpace)
 
static bool saveState (SchedulerState &state)
 
static void restoreState (SchedulerState &state, volatile uintptr_t *pLock=0) NORETURN
 
static void restoreState (SyscallState &state, volatile uintptr_t *pLock=0) NORETURN
 
static void contextSwitch (InterruptState *state) NORETURN
 
static void switchState (bool bInterrupts, SchedulerState &a, SchedulerState &b, volatile uintptr_t *pLock=0)
 
static void switchState (bool bInterrupts, SchedulerState &a, SyscallState &b, volatile uintptr_t *pLock=0)
 
static void saveAndJumpKernel (bool bInterrupts, SchedulerState &s, volatile uintptr_t *pLock, uintptr_t address, uintptr_t stack, uintptr_t p1=0, uintptr_t p2=0, uintptr_t p3=0, uintptr_t p4=0)
 
static void saveAndJumpUser (bool bInterrupts, SchedulerState &s, volatile uintptr_t *pLock, uintptr_t address, uintptr_t stack, uintptr_t p1=0, uintptr_t p2=0, uintptr_t p3=0, uintptr_t p4=0)
 
static void jumpKernel (volatile uintptr_t *pLock, uintptr_t address, uintptr_t stack, uintptr_t p1=0, uintptr_t p2=0, uintptr_t p3=0, uintptr_t p4=0) NORETURN
 
static void jumpUser (volatile uintptr_t *pLock, uintptr_t address, uintptr_t stack, uintptr_t p1=0, uintptr_t p2=0, uintptr_t p3=0, uintptr_t p4=0) NORETURN
 
static void breakpoint ()
 
static void halt ()
 
static void reset ()
 
static size_t getDebugBreakpointCount ()
 
static uintptr_t getDebugBreakpoint (size_t nBpNumber, DebugFlags::FaultType &nFaultType, size_t &nLength, bool &bEnabled)
 
static void enableDebugBreakpoint (size_t nBpNumber, uintptr_t nLinearAddress, DebugFlags::FaultType nFaultType, size_t nLength)
 
static void disableDebugBreakpoint (size_t nBpNumber)
 
static uintptr_t getDebugStatus ()
 
static void haltUntilInterrupt ()
 
static void pause ()
 
static void setInterrupts (bool bEnable)
 
static bool getInterrupts ()
 
static bool inDeviceHardIrq ()
 
static ExecutionContext executionContext ()
 
static bool guardDeviceHardIrqOperation (DeviceHardIrqOperation operation)
 
static void setSingleStep (bool bEnable, InterruptState &state)
 
static void invalidate (void *pAddress)
 
static MUST_USE_RESULT TlbInvalidationResult beginTlbInvalidation (TlbInvalidationGuard &guard)
 
static MUST_USE_RESULT TlbInvalidationResult invalidateAll (void *pAddress)
 
static MUST_USE_RESULT TlbInvalidationResult invalidateAll (void *pAddress, TlbInvalidationGuard &guard)
 
static bool tlbInvalidationFailureActive ()
 
static bool tlbInvalidationTerminal ()
 
static void invalidateICache (uintptr_t nAddr)
 
static void invalidateDCache (uintptr_t nAddr)
 
static void flushDCache (uintptr_t nAddr)
 
static void flushDCacheAndInvalidateICache (uintptr_t startAddr, uintptr_t endAddr)
 
static void identify (HugeStaticString &str)
 
static ProcessorId id ()
 
static size_t index ()
 
static ProcessorInformation & information ()
 
static ProcessorInformation * informationAt (size_t cpu)
 
static size_t getCount ()
 
static void setTlsBase (uintptr_t newBase)
 
static uintptr_t getUserGsBase ()
 
static void setUserGsBase (uintptr_t newBase)
 

Static Public Attributes

static size_t m_Initialised = 0
 

Static Private Member Functions

static NEVER_INLINE __attribute__ ((cold)) bool rejectDeviceHardIrqOperation(DeviceHardIrqOperation operation)
 
static MUST_USE_RESULT bool closeTlbInvalidationAdmissionForTerminalFailure (TlbInvalidationGuard &guard, TlbInvalidationResult result)
 
static void endTlbInvalidation (TlbInvalidationGuard &guard)
 

Static Private Attributes

static ProcessorInformation::KernelGsAnchor m_BootstrapKernelGsAnchor
 
static Vector< ProcessorInformation * > m_ProcessorInformation
 
static ProcessorInformation m_SafeBspProcessorInformation
 
static size_t m_nProcessors = 1
 

Friends

class Multiprocessor
 
class TlbInvalidationGuard
 
class X86GdtManager
 
class X64GdtManager
 
class Scheduler
 

Detailed Description

Interface to the processor's capabilities

Architecture-specific implementations exist, and subclasses are used to add processor-specific methods (don't use the preprocessor for that anymore).

Cast a Processor object to the architecture-specific variant if you need to access architecturally unique features.

Note
static in member function declarations denotes that these functions return/process data on the processor that is executing this code.

Definition at line 128 of file Processor.h.

Member Function Documentation

◆ beginTlbInvalidation()

TlbInvalidationResult ProcessorBase::beginTlbInvalidation ( TlbInvalidationGuard guard)
static

Admit a page-table mutation before its first PTE write.

The guard may cover more than one address and must remain alive through every corresponding invalidateAll call. This operation uses bounded polling and rejects hard-IRQ, scheduler-IRQ, synthetic-IRQ, and debugger contexts before the mapping can change. The guarded region must not sleep or wait for work which itself needs new mapping admission.

Definition at line 573 of file hosted/Processor.cc.

References executionContext().

Referenced by invalidateAll().

+ Here is the caller graph for this function:

◆ breakpoint()

void ProcessorBase::breakpoint ( )
static

Trigger a breakpoint

Definition at line 663 of file hosted/Processor.cc.

Referenced by _assert(), and Log::addEntry().

+ Here is the caller graph for this function:

◆ closeTlbInvalidationAdmissionForTerminalFailure()

bool ProcessorBase::closeTlbInvalidationAdmissionForTerminalFailure ( TlbInvalidationGuard guard,
TlbInvalidationResult  result 
)
staticprivate

Escalate an admitted mutation to terminal failure.

Definition at line 590 of file hosted/Processor.cc.

Referenced by TlbInvalidationGuard::closeAdmissionForTerminalFailure().

+ Here is the caller graph for this function:

◆ contextSwitch()

static void ProcessorBase::contextSwitch ( InterruptState *  state)
static

Restores a complete x64 interrupt frame through iretq.

The pointed-to state must remain valid and contain a fully validated return context. This is declared for future signal-return plumbing.

Referenced by X64SyscallManager::syscall().

+ Here is the caller graph for this function:

◆ deinitialise()

void ProcessorBase::deinitialise ( )
static

Prepare the processor for reset by deinitialising things initialised in initialise2/initialise1.

Definition at line 154 of file hosted/Processor.cc.

◆ disableDebugBreakpoint()

void ProcessorBase::disableDebugBreakpoint ( size_t  nBpNumber)
static

Disable a specific breakpoint

Parameters
[in]nBpNumberthe breakpoint number [0 - (getDebugBreakpointCount()
  • 1)]

Definition at line 454 of file hosted/Processor.cc.

Referenced by BreakpointCommand::execute().

+ Here is the caller graph for this function:

◆ enableDebugBreakpoint()

void ProcessorBase::enableDebugBreakpoint ( size_t  nBpNumber,
uintptr_t  nLinearAddress,
DebugFlags::FaultType  nFaultType,
size_t  nLength 
)
static

Enable a specific breakpoint

Parameters
[in]nBpNumberthe breakpoint number [0 - (getDebugBreakpointCount()
  • 1)]
[in]nLinearAddressthe linear Adress that should trigger a breakpoint exception
[in]nFaultTypethe type of access that should trigger a breakpoint exception
[in]nLengththe size/length of the breakpoint

Definition at line 449 of file hosted/Processor.cc.

Referenced by BreakpointCommand::execute().

+ Here is the caller graph for this function:

◆ endTlbInvalidation()

void ProcessorBase::endTlbInvalidation ( TlbInvalidationGuard guard)
staticprivate

Release an active page-table mutation admission lease.

Definition at line 585 of file hosted/Processor.cc.

Referenced by TlbInvalidationGuard::retire().

+ Here is the caller graph for this function:

◆ executionContext()

ExecutionContext ProcessorBase::executionContext ( )
static

Classifies the current execution boundary without relying on a per-processor IRQ marker that could survive a Thread context switch.

Definition at line 109 of file Processor.cc.

References Thread::executionContext(), getInterrupts(), and information().

Referenced by beginTlbInvalidation(), SchedulerTimer::canRemoveHandlerInCurrentContext(), ThreadedIrqDispatcher::canShutdown(), VFS::removeMountCallback(), VFS::removeProbeCallback(), PerProcessorScheduler::serviceProcessStopAtUserReturn(), and Pic::unregisterHandler().

+ Here is the caller graph for this function:

◆ flushDCache()

void ProcessorBase::flushDCache ( uintptr_t  nAddr)
static

Flush a line in the data cache.

Parameters
[in]nAddrThe address of a memory location to flush from the Dcache.

Definition at line 704 of file hosted/Processor.cc.

◆ flushDCacheAndInvalidateICache()

void ProcessorBase::flushDCacheAndInvalidateICache ( uintptr_t  startAddr,
uintptr_t  endAddr 
)
static

Flush from the data cache and invalidate into the instruction cache. This must be used whenever code is written to memory and needs to be executed.

Parameters
startAddrThe first address to be flushed and invalidated.
endAddrThe last address to be flushed and invalidated.

Definition at line 712 of file hosted/Processor.cc.

Referenced by Elf::load().

+ Here is the caller graph for this function:

◆ getBasePointer()

uintptr_t ProcessorBase::getBasePointer ( )
static

Get the base-pointer of the calling function

Returns
base-pointer of the calling function

Definition at line 169 of file hosted/Processor.cc.

Referenced by Backtrace::performBpBacktrace().

+ Here is the caller graph for this function:

◆ getCount()

size_t ProcessorBase::getCount ( )
static

Get the number of CPUs currently available

Definition at line 633 of file hosted/Processor.cc.

Referenced by Spinlock::acquireContended(), CpuInfoCommand::execute(), informationAt(), Scheduler::initialise(), and PerProcessorScheduler::initialise().

+ Here is the caller graph for this function:

◆ getDebugBreakpoint()

uintptr_t ProcessorBase::getDebugBreakpoint ( size_t  nBpNumber,
DebugFlags::FaultType &  nFaultType,
size_t &  nLength,
bool &  bEnabled 
)
static

Get information for a specific breakpoint

Parameters
[in]nBpNumberthe breakpoint number [0 - (getDebugBreakpointCount()
  • 1)]
[in,out]nFaultTypethe breakpoint type
[in,out]nLengththe breakpoint size/length
[in,out]bEnabledis the breakpoint enabled?

Definition at line 443 of file hosted/Processor.cc.

Referenced by BreakpointCommand::execute().

+ Here is the caller graph for this function:

◆ getDebugBreakpointCount()

size_t ProcessorBase::getDebugBreakpointCount ( )
static

Return the (total) number of breakpoints

Returns
(total) number of breakpoints

Definition at line 439 of file hosted/Processor.cc.

Referenced by BreakpointCommand::execute().

+ Here is the caller graph for this function:

◆ getDebugStatus()

static uintptr_t ProcessorBase::getDebugStatus ( )
static

Get the debug status

Todo:
is the debug status somehow abtractable?
Returns
the debug status

◆ getInstructionPointer()

uintptr_t ProcessorBase::getInstructionPointer ( )
static

Get the instruction-pointer of the calling function

Returns
instruction-pointer of the calling function

Definition at line 161 of file hosted/Processor.cc.

Referenced by Backtrace::performBpBacktrace().

+ Here is the caller graph for this function:

◆ getInterrupts()

bool ProcessorBase::getInterrupts ( )
static

Get the IRQ state

Returns
true, if interrupt requests are enabled, false otherwise

Definition at line 506 of file hosted/Processor.cc.

Referenced by Spinlock::acquire(), PerProcessorScheduler::addThread(), PerProcessorScheduler::addThread(), RequestQueue::canWaitForCompletion(), PerProcessorScheduler::checkEventState(), MemoryPressureManager::compact(), VmwareGraphics::VmwareFramebuffer::copy(), IrqHandlerRegistry::dispatchThreaded(), X64VirtualAddressSpace::doAllocateStack(), AtaDisk::doRead(), Rtc::drainRemoteAlarmDispatch(), Bios::executeInterrupt(), executionContext(), PosixSubsystem::exit(), Thread::TemporarySignalMask::finish(), Rtc::getTickCountNano(), VmwareGraphics::VmwareFramebuffer::hwRedraw(), Rtc::initialiseProcessorClock(), Thread::popState(), Thread::pushState(), Process::releaseVforkAddressSpace(), Log::removeCallback(), MemoryPressureManager::removeHandler(), PosixSubsystem::resolveUserPageFault(), NMFaultHandler::restoreCurrentThreadFpuState(), Thread::retainTemporarySignalWaitInterruptionOrClear(), NMFaultHandler::saveCurrentThreadFpuState(), PerProcessorScheduler::schedule(), GraphicsService::serve(), PerProcessorScheduler::serviceDeferredSubsystemException(), PerProcessorScheduler::serviceProcessStopAtUserReturn(), VmwareGraphics::setScreenMode(), VmwareGraphics::setScreenMode(), SplitIrqHandler::shutdownSplitIrq(), HostedInterruptManager::signalShim(), Spinlock::unlock(), PageFaultHandler::unregisterHandler(), TimerHandlerRegistry::unregisterHandler(), IrqHandlerRegistry::unregisterHandler(), AtaDisk::writePageBuffer(), and Process::~Process().

+ Here is the caller graph for this function:

◆ getStackPointer()

uintptr_t ProcessorBase::getStackPointer ( )
static

Get the stack-pointer of the calling function

Returns
stack-pointer of the calling function

Definition at line 165 of file hosted/Processor.cc.

◆ getUserGsBase()

uintptr_t ProcessorBase::getUserGsBase ( )
static

Definition at line 215 of file x64/Processor.cc.

◆ guardDeviceHardIrqOperation()

ALWAYS_INLINE bool ProcessorBase::guardDeviceHardIrqOperation ( DeviceHardIrqOperation  operation)
inlinestatic

Enforces the device hard-IRQ execution boundary.

Returns true outside device hard-IRQ callbacks. A violation is fatal in production; hosted smoke tests may install a hook which converts the violation into a false return so the rejecting call site can be tested.

Definition at line 563 of file Processor.h.

References inDeviceHardIrq(), and LIKELY.

Referenced by Semaphore::acquireForCompletion(), SlamAllocator::allocate(), Semaphore::release(), PerProcessorScheduler::schedule(), and WaitQueue::wakeAllIfWaiting().

+ Here is the caller graph for this function:

◆ halt()

void ProcessorBase::halt ( )
static

◆ haltUntilInterrupt()

void ProcessorBase::haltUntilInterrupt ( )
static

Wait for an IRQ to fire. Possible HALT or low-power state.

Definition at line 684 of file hosted/Processor.cc.

◆ id()

ProcessorId ProcessorBase::id ( )
static

Get the ProcessorId of this processor

Returns
the ProcessorId of this processor

Definition at line 621 of file hosted/Processor.cc.

Referenced by PerProcessorScheduler::addThread(), PerProcessorScheduler::addThread(), PerProcessorScheduler::initialise(), X64InterruptManager::interrupt(), HostedSchedulerTimer::registerHandler(), HostedSchedulerTimer::removeHandler(), and PosixSubsystem::threadException().

+ Here is the caller graph for this function:

◆ identify()

void ProcessorBase::identify ( HugeStaticString str)
static

Populate 'str' with a string describing the characteristics of this processor.

Definition at line 156 of file hosted/Processor.cc.

Referenced by CpuInfoCommand::execute().

+ Here is the caller graph for this function:

◆ inDeviceHardIrq()

ALWAYS_INLINE bool ProcessorBase::inDeviceHardIrq ( )
inlinestatic

True only while an explicit device hard-IRQ callback is running.

Definition at line 559 of file Processor.h.

References information().

Referenced by PosixSubsystem::exit(), guardDeviceHardIrqOperation(), PerProcessorScheduler::serviceProcessStopAtUserReturn(), TimerFdService::timer(), and RingBuffer< T, preallocatedSize >::tryWrite().

+ Here is the caller graph for this function:

◆ index()

size_t ProcessorBase::index ( )
inlinestatic

Get this processor's dense topology index for per-CPU storage. The bootstrap processor owns slot zero before discovery; each additional processor receives its permanent slot before it enters C++.

Definition at line 36 of file x64/Processor.h.

References index().

Referenced by Thread::accountTimerTick(), Spinlock::acquire(), Spinlock::acquireContended(), Scheduler::addThread(), LocksCommand::checkSchedule(), LocksCommand::checkState(), index(), Pic::initialise(), PerProcessorScheduler::initialise(), Pic::initialiseThreaded(), Pic::interrupt(), LocksCommand::lockReleased(), X86CommonProcessor::readMachineSpecificRegister(), Timer::sampleCpuTime(), Rtc::sampleCpuTime(), Pic::shutdownThreaded(), Debugger::start(), and X86CommonProcessor::writeMachineSpecificRegister().

+ Here is the caller graph for this function:

◆ information()

ProcessorInformation & ProcessorBase::information ( )
inlinestatic

Get the ProcessorInformation structure of this processor

Returns
the ProcessorInformation structure of this processor

Definition at line 30 of file x64/Processor.h.

References information().

Referenced by PerProcessorScheduler::abandonCurrentThreadStack(), PosixSubsystem::acquire(), Spinlock::acquire(), Spinlock::acquireContended(), Semaphore::acquireForCompletion(), BusMasterIde::add(), HostedTimer::addAlarm(), Rtc::addAlarm(), RequestQueue::addRequest(), PerProcessorScheduler::addThread(), PerProcessorScheduler::addThread(), Ohci::addTransferToTransaction(), Uhci::addTransferToTransaction(), SlamAllocator::allocate(), Elf::allocate(), HostedPhysicalMemoryManager::allocateRegion(), X86CommonPhysicalMemoryManager::allocateRegion(), MemoryMapManager::allows(), Process::beginTermination(), UnixSocketSyscalls::bind(), SchedulerTimer::canRemoveHandlerInCurrentContext(), ThreadedIrqDispatcher::canShutdown(), RequestQueue::canWaitForCompletion(), PosixSubsystem::checkAddress(), PerProcessorScheduler::checkEventState(), HostedVirtualAddressSpace::clone(), MemoryMapManager::clone(), RandomFile::command(), X64PreparedPageRemap::commit(), PerProcessorScheduler::commitCurrentThreadExit(), PerProcessorScheduler::commitUserReturnTerminalState(), MemoryMapManager::compact(), MemoryPressureManager::compact(), MemoryMappedFile::compact(), Thread::completeAffinityAtSafePoint(), MemoryMapManager::contains(), Pipe::decreaseRefCount(), LinuxAmd64Signal::AsyncEvent::deliverAtUserReturn(), LinuxAmd64Signal::AsyncEvent::deliverAtUserReturn(), X64VirtualAddressSpace::detachEmptyTables(), HostedVirtualAddressSpace::detachMapping(), Thread::discardUserStackMetadataForExec(), TimerHandlerRegistry::dispatch(), IrqHandlerRegistry::dispatchThreaded(), RequestQueue::drain(), Rtc::drainRemoteAlarmDispatch(), PerProcessorScheduler::eventHandlerReturned(), Cache::evict(), MappingCommand::execute(), Bios::executeInterrupt(), executionContext(), PosixSubsystem::exit(), MemoryMapManager::faultInRange(), NetworkFilter::filter(), Elf::finaliseModule(), MemoryMapManager::findAttachment(), Cache::finishRetirement(), LockedFile::getFile(), File::getPhysicalPage(), Rtc::getTickCountNano(), inDeviceHardIrq(), information(), UserManager::initialise(), InputManager::initialise(), ThreadedIrqDispatcher::initialise(), CacheManager::initialise(), Scheduler::initialise(), X64GdtManager::initialise(), PerProcessorScheduler::initialise(), initialise1(), Rtc::initialise2(), Dm9601::initialiseDriver(), X64GdtManager::initialiseProcessor(), Rtc::initialiseProcessorClock(), DynamicLinker::initPlt(), HostedInterruptManager::interrupt(), X64InterruptManager::interrupt(), NMFaultHandler::interrupt(), PageFaultHandler::interrupt(), X64VirtualAddressSpace::invalidateMapping(), IrqHandlerRegistry::invalidateThreadedLine(), PosixSubsystem::invoke(), Ipc::IpcMessage::IpcMessage(), ThreadedIrqDispatcher::isCurrentWorker(), Thread::joinInternal(), Process::kill(), PosixSubsystem::kill(), PosixSubsystem::loadElf(), Elf::loadModule(), LockedFile::lock(), ConsoleManager::lockConsole(), User::login(), Cache::lookupStable(), InputManager::mainThread(), Cache::map(), VFS::mount(), Ne2k::Ne2k(), Backtrace::performBpBacktrace(), PosixSubsystem::prepareExecutable(), Process::prepareThreadExit(), File::publishEvent(), PosixSubsystem::queueSignalDelivery(), Process::quiesceTermination(), Process::releaseVforkAddressSpace(), Pipe::releaseVfsReference(), AnonymousMemoryMap::remove(), MemoryMappedFile::remove(), MemoryMapManager::removeAndRelease(), MemoryMapManager::removeAttachment(), Log::removeCallback(), NetworkFilter::removeCallback(), MemoryPressureManager::removeHandler(), VFS::removeMountCallback(), VFS::removeProbeCallback(), PerProcessorScheduler::requestCurrentThreadExitToIdle(), Scheduler::requestLoadAverageSample(), DynamicLinker::resolvePlt(), PosixSubsystem::resolveUserPageFault(), NMFaultHandler::restoreCurrentThreadFpuState(), DeviceHardIrqContext::restoreDepth(), Cache::retireWriteback(), X64InterruptManager::returnFromInterrupt(), pocketknife::runConcurrently(), pocketknife::runConcurrentlyAttached(), Rtc::sampleCpuTime(), Scheduler::sampleLoadAverage(), NMFaultHandler::saveCurrentThreadFpuState(), PerProcessorScheduler::schedule(), PosixSubsystem::sendSignal(), SignalEvent::serialize(), PerProcessorScheduler::serviceDeferredSubsystemException(), PerProcessorScheduler::serviceIrqWorkDoorbell(), PerProcessorScheduler::serviceProcessStopAtUserReturn(), PerProcessorScheduler::serviceUserReturnWork(), PerProcessorScheduler::serviceUserReturnWork(), setInterrupts(), Thread::setKernelStack(), AnonymousMemoryMap::setPermissions(), MemoryMappedFile::setPermissions(), VirtualTerminalManager::setTerminalMode(), Process::setTimeAccountingReportInterest(), Thread::setTlsBase(), ThreadedIrqDispatcher::shutdown(), SplitIrqHandler::shutdownSplitIrq(), HostedInterruptManager::signalShim(), Debugger::start(), Process::suspendInternal(), switchAddressSpace(), sys_thread_is_current(), HostedSyscallManager::syscall(), X64SyscallManager::syscall(), Thread::Thread(), Thread::Thread(), Thread::threadExited(), PerProcessorScheduler::timer(), DLTrapHandler::trap(), MemoryMappedFile::trap(), ConsoleManager::unlockConsole(), MemoryMapManager::unmap(), MemoryMapManager::unmapAllUnlocked(), PageFaultHandler::unregisterHandler(), TimerHandlerRegistry::unregisterHandler(), IrqHandlerRegistry::unregisterHandler(), ConditionVariable::wait(), Event::waitForDeliveries(), Process::waitUntilTerminationReapable(), Process::waitUntilTerminationReapableForTerminalCoordinator(), RequestQueue::work(), Cache::PreparedDiscard::writeback(), Cache::writebackPage(), Scheduler::yield(), NetworkFilter::~NetworkFilter(), PosixSubsystem::~PosixSubsystem(), and Process::~Process().

◆ informationAt()

ProcessorInformation * ProcessorBase::informationAt ( size_t  cpu)
static

Resolves a discovered logical slot, including before BSP identity is live.

Definition at line 39 of file Processor.cc.

References Vector< T >::count(), getCount(), m_ProcessorInformation, and m_SafeBspProcessorInformation.

Referenced by PerProcessorScheduler::initialise().

+ Here is the caller graph for this function:

◆ initialisationDone()

void ProcessorBase::initialisationDone ( )
static

End of the kernel core initialisation reached, the initialisation functions and data may now get unmapped/freed.

Definition at line 117 of file hosted/Processor.cc.

References HostedPhysicalMemoryManager::initialisationDone(), and HostedPhysicalMemoryManager::instance().

◆ initialise1()

void ProcessorBase::initialise1 ( const BootstrapStruct_t Info)
static

first stage in the initialisation of the processor-specific interface

Initialises the processor specific interface. After this function call the whole processor-specific interface is initialised. Note though, that only the bootstrap processor is started. Multiprocessor/-core facilities are available after initialiseProcessor2().

Note
This function should only be called once and by main()
Parameters
[in]Inforeference to the multiboot information structure

todo move to a better place

Definition at line 121 of file hosted/Processor.cc.

References Dec, TargetInfo::getPageSize(), Hex, information(), PageFaultHandler::initialise(), HostedPhysicalMemoryManager::initialise(), HostedInterruptManager::initialiseProcessor(), HostedSyscallManager::initialiseProcessor(), PageFaultHandler::instance(), HostedPhysicalMemoryManager::instance(), m_Initialised, panic(), and setInterrupts().

◆ initialise2()

void ProcessorBase::initialise2 ( const BootstrapStruct_t Info)
static

second/last stage in the initialisation of the processor-specific interface

Initialises the Multiprocessor/-core functionality of the processor-specific interface. This function may only be called after initialiseProcessor1 and after the whole machine specific interface has been initialised.

Note
This function should only be called once and by main()

Definition at line 149 of file hosted/Processor.cc.

References m_Initialised.

◆ invalidate()

void ProcessorBase::invalidate ( void *  pAddress)
static

Invalidate the TLB entry containing a specific virtual address

Parameters
[in]pAddressthe specific virtual address
Note
This affects only the executing processor.

Definition at line 569 of file hosted/Processor.cc.

Referenced by invalidateAll().

+ Here is the caller graph for this function:

◆ invalidateAll() [1/2]

TlbInvalidationResult ProcessorBase::invalidateAll ( void *  pAddress)
static

Invalidate one virtual address on every online processor and do not return until each processor has acknowledged the request.

The caller must keep the online-processor set, page-table mutation, and its page-table storage stable until this returns Success. The implementation is allocation-free and uses bounded polling, so it is valid in ordinary thread and atomic thread context. Explicit device, scheduler, synthetic-IRQ, and debugger contexts are rejected: none may wait for another processor's progress. On any failure, the caller must not reclaim or reuse the old mapping's backing storage. Convenience invalidation for callers which have not changed a PTE. Page-table writers must acquire a guard before their mutation and use the overload below, so processor retirement cannot overtake publication.

Definition at line 604 of file hosted/Processor.cc.

References beginTlbInvalidation(), and invalidateAll().

Referenced by invalidateAll().

+ Here is the caller graph for this function:

◆ invalidateAll() [2/2]

TlbInvalidationResult ProcessorBase::invalidateAll ( void *  pAddress,
TlbInvalidationGuard guard 
)
static

Invalidate under an admission lease acquired before the PTE mutation.

Definition at line 613 of file hosted/Processor.cc.

References invalidate().

◆ invalidateDCache()

void ProcessorBase::invalidateDCache ( uintptr_t  nAddr)
static

Invalidate a line in the data cache.

Parameters
[in]nAddrThe address of a memory location to invalidate from the Dcache.

Definition at line 696 of file hosted/Processor.cc.

◆ invalidateICache()

void ProcessorBase::invalidateICache ( uintptr_t  nAddr)
static

Invalidate a line in the instruction cache.

Parameters
[in]nAddrThe address of a memory location to invalidate from the Icache.

Definition at line 688 of file hosted/Processor.cc.

◆ isInitialised()

size_t ProcessorBase::isInitialised ( )
static

Is the processor-specific interface initialised?

Returns
0, if nothing has been initialised, 1, if initialise1() has been executed successfully, 2, if initialise2() has been executed successfully

Definition at line 105 of file Processor.cc.

References m_Initialised.

Referenced by IoPortManager::allocate(), and IoPortManager::free().

+ Here is the caller graph for this function:

◆ jumpKernel()

static void ProcessorBase::jumpKernel ( volatile uintptr_t *  pLock,
uintptr_t  address,
uintptr_t  stack,
uintptr_t  p1 = 0,
uintptr_t  p2 = 0,
uintptr_t  p3 = 0,
uintptr_t  p4 = 0 
)
static

Jumps to an address, in kernel mode, and sets up a calling frame with the given parameters.

Parameters
pLockOptional lock to release.
addressAddress to jump to.
stackStack to use (set to 0 for current stack).
param1First parameter.
param2Second parameter.
param3Third parameter.
param4Fourth parameter.

Referenced by PerProcessorScheduler::addThread().

+ Here is the caller graph for this function:

◆ jumpUser()

static void ProcessorBase::jumpUser ( volatile uintptr_t *  pLock,
uintptr_t  address,
uintptr_t  stack,
uintptr_t  p1 = 0,
uintptr_t  p2 = 0,
uintptr_t  p3 = 0,
uintptr_t  p4 = 0 
)
static

Jumps to an address, in user mode, and sets up a calling frame with the given parameters.

Parameters
pLockOptional lock to release.
addressAddress to jump to.
stackStack to use (set to 0 for current stack).
param1First parameter.
param2Second parameter.
param3Third parameter.
param4Fourth parameter.

Referenced by PerProcessorScheduler::addThread(), PerProcessorScheduler::checkEventState(), and HostedSyscallManager::syscall().

+ Here is the caller graph for this function:

◆ pause()

void ProcessorBase::pause ( )
static

◆ reset()

void ProcessorBase::reset ( )
static

Reset this processor

Definition at line 680 of file hosted/Processor.cc.

Referenced by Machine::finalShutdown(), Pc::finalShutdown(), and HostedInterruptManager::interrupt().

+ Here is the caller graph for this function:

◆ restoreState() [1/2]

void ProcessorBase::restoreState ( SchedulerState &  state,
volatile uintptr_t *  pLock = 0 
)
static

Restore a previous scheduler state.

Parameters
[in]stateThe state to restore.
[out]pLockOptional lock to release.

Definition at line 178 of file hosted/Processor.cc.

Referenced by PerProcessorScheduler::addThread(), PerProcessorScheduler::eventHandlerReturned(), and X64SyscallManager::syscall().

+ Here is the caller graph for this function:

◆ restoreState() [2/2]

static void ProcessorBase::restoreState ( SyscallState &  state,
volatile uintptr_t *  pLock = 0 
)
static

Restore a previous syscall state.

Parameters
[out]pLockOptional lock to release (for none, set as 0)
[in]stateSyscall state to restore.

◆ saveAndJumpKernel()

static void ProcessorBase::saveAndJumpKernel ( bool  bInterrupts,
SchedulerState &  s,
volatile uintptr_t *  pLock,
uintptr_t  address,
uintptr_t  stack,
uintptr_t  p1 = 0,
uintptr_t  p2 = 0,
uintptr_t  p3 = 0,
uintptr_t  p4 = 0 
)
static

Jumps to an address, in kernel mode, and sets up a calling frame with the given parameters. Saves the current state before doing so.

Parameters
bInterruptsInterrupt state to restore in saved context.
pLockOptional lock to release.
addressAddress to jump to.
stackStack to use (set to 0 for current stack).
param1First parameter.
param2Second parameter.
param3Third parameter.
param4Fourth parameter.

Referenced by PerProcessorScheduler::addThread().

+ Here is the caller graph for this function:

◆ saveAndJumpUser()

static void ProcessorBase::saveAndJumpUser ( bool  bInterrupts,
SchedulerState &  s,
volatile uintptr_t *  pLock,
uintptr_t  address,
uintptr_t  stack,
uintptr_t  p1 = 0,
uintptr_t  p2 = 0,
uintptr_t  p3 = 0,
uintptr_t  p4 = 0 
)
static

Jumps to an address, in user mode, and sets up a calling frame with the given parameters. Saves the current state before doing so.

Parameters
bInterruptsInterrupt state to restore in saved context.
pLockOptional lock to release.
addressAddress to jump to.
stackStack to use (set to 0 for current stack).
param1First parameter.
param2Second parameter.
param3Third parameter.
param4Fourth parameter.

Referenced by PerProcessorScheduler::addThread(), and PerProcessorScheduler::checkEventState().

+ Here is the caller graph for this function:

◆ saveState()

bool ProcessorBase::saveState ( SchedulerState &  state)
static

Save the current processor state.

Parameters
[out]stateSchedulerState to save into.
Returns
False if the save saved the state. True if a restoreState occurs.

Definition at line 173 of file hosted/Processor.cc.

Referenced by PerProcessorScheduler::addThread(), PerProcessorScheduler::addThread(), and PerProcessorScheduler::checkEventState().

+ Here is the caller graph for this function:

◆ setInterrupts()

void ProcessorBase::setInterrupts ( bool  bEnable)
static

◆ setSingleStep()

void ProcessorBase::setSingleStep ( bool  bEnable,
InterruptState &  state 
)
static

Enable/Disable single-stepping

Parameters
[in]bEnabletrue to enable single-stepping, false otherwise
[in]statethe interrupt-state

Definition at line 565 of file hosted/Processor.cc.

Referenced by StepCommand::execute(), TraceCommand::execute(), and Debugger::interrupt().

+ Here is the caller graph for this function:

◆ setTlsBase()

void ProcessorBase::setTlsBase ( uintptr_t  newBase)
static

Set a new TLS area base address.

Definition at line 433 of file hosted/Processor.cc.

Referenced by PerProcessorScheduler::addThread(), PerProcessorScheduler::addThread(), PerProcessorScheduler::initialise(), Thread::resetTlsBase(), and Thread::setTlsBase().

+ Here is the caller graph for this function:

◆ setUserGsBase()

void ProcessorBase::setUserGsBase ( uintptr_t  newBase)
static

Definition at line 221 of file x64/Processor.cc.

◆ switchAddressSpace()

void ProcessorBase::switchAddressSpace ( VirtualAddressSpace AddressSpace)
static

◆ switchState() [1/2]

static void ProcessorBase::switchState ( bool  bInterrupts,
SchedulerState &  a,
SchedulerState &  b,
volatile uintptr_t *  pLock = 0 
)
static

Switch between two states, safely.

Referenced by PerProcessorScheduler::addThread().

+ Here is the caller graph for this function:

◆ switchState() [2/2]

static void ProcessorBase::switchState ( bool  bInterrupts,
SchedulerState &  a,
SyscallState &  b,
volatile uintptr_t *  pLock = 0 
)
static

Switch between two states, safely.

◆ tlbInvalidationFailureActive()

bool ProcessorBase::tlbInvalidationFailureActive ( )
static

True after a failed invalidation has permanently closed admission.

Definition at line 596 of file hosted/Processor.cc.

◆ tlbInvalidationTerminal()

bool ProcessorBase::tlbInvalidationTerminal ( )
static

True while page-table mutation admission is permanently closed.

Definition at line 600 of file hosted/Processor.cc.

Referenced by panic().

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ Multiprocessor

friend class Multiprocessor
friend

Definition at line 129 of file Processor.h.

◆ Scheduler

friend class Scheduler
friend

Definition at line 133 of file Processor.h.

◆ TlbInvalidationGuard

friend class TlbInvalidationGuard
friend

Definition at line 130 of file Processor.h.

◆ X64GdtManager

friend class X64GdtManager
friend

Definition at line 132 of file Processor.h.

◆ X86GdtManager

friend class X86GdtManager
friend

Definition at line 131 of file Processor.h.

Member Data Documentation

◆ m_BootstrapKernelGsAnchor

constinit ProcessorInformation::KernelGsAnchor ProcessorBase::m_BootstrapKernelGsAnchor
staticprivate
Initial value:
= {
0, 0, &m_SafeBspProcessorInformation, 0, nullptr}
static ProcessorInformation m_SafeBspProcessorInformation
Definition Processor.h:508

Definition at line 42 of file Processor.h.

◆ m_Initialised

size_t ProcessorBase::m_Initialised = 0
static

◆ m_nProcessors

size_t ProcessorBase::m_nProcessors = 1
staticprivate

Definition at line 510 of file Processor.h.

◆ m_ProcessorInformation

Vector< ProcessorInformation * > ProcessorBase::m_ProcessorInformation
staticprivate

If we have only one processor, we define the ProcessorInformation class here otherwise we use an array of ProcessorInformation structures

Definition at line 504 of file Processor.h.

Referenced by informationAt(), Scheduler::initialise(), and X64GdtManager::initialise().

◆ m_SafeBspProcessorInformation

ProcessorInformation ProcessorBase::m_SafeBspProcessorInformation
staticprivate

Used before multiprocessor stuff is turned on as a "safe" info structure. For stuff like early heap setup and all that.

Definition at line 508 of file Processor.h.

Referenced by informationAt().


The documentation for this class was generated from the following files: