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

The exception was caused by a hardware task switch. More...

#include <Processor.h>

+ Collaboration diagram for Processor:

Static Public Member Functions

static void initialise1 (const BootstrapStruct_t &Info) INITIALISATION_ONLY
 first stage in the initialisation of the processor-specific interface More...
 
static void initialise2 (const BootstrapStruct_t &Info) INITIALISATION_ONLY
 second/last stage in the initialisation of the processor-specific interface More...
 
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 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 void setSingleStep (bool bEnable, InterruptState &state)
 
static uint64_t readMachineSpecificRegister (uint32_t index)
 
static void writeMachineSpecificRegister (uint32_t index, uint64_t value)
 
static void cpuid (uint32_t inEax, uint32_t inEcx, uint32_t &eax, uint32_t &ebx, uint32_t &ecx, uint32_t &edx)
 
static void invalidate (void *pAddress)
 
static physical_uintptr_t readCr3 ()
 
static void identify (HugeStaticString &str)
 
static ProcessorId id ()
 
static ProcessorInformation & information ()
 
static size_t getCount ()
 
static void setTlsBase (uintptr_t newBase)
 

Static Public Attributes

static size_t m_Initialised = 0
 

Static Private Attributes

static ProcessorInformation m_ProcessorInformation
 
static size_t m_nProcessors = 1
 

Friends

class Multiprocessor
 
class X86GdtManager
 
class X64GdtManager
 
class Scheduler
 

Detailed Description

The exception was caused by a hardware task switch.

Interface to the processor's capabilities

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

Definition at line 80 of file Processor.h.

Member Function Documentation

void Processor::breakpoint ( )
static

Trigger a breakpoint

Definition at line 31 of file arm_common/Processor.h.

Referenced by _assert(), cpuid(), Log::flushEntry(), and jumpUser().

+ Here is the caller graph for this function:

void Processor::cpuid ( uint32_t  inEax,
uint32_t  inEcx,
uint32_t &  eax,
uint32_t &  ebx,
uint32_t &  ecx,
uint32_t &  edx 
)
static

Executes the CPUID machine instruction

Parameters
[in]inEaxeax before the CPUID instruction
[in]inEcxecx before the CPUID instruction
[out]eaxeax afterwards
[out]ebxebx afterwards
[out]ecxecx afterwards
[out]edxedx afterwards

Definition at line 213 of file x86_common/Processor.cc.

References breakpoint(), getCount(), getInterrupts(), halt(), haltUntilInterrupt(), id(), information(), m_Initialised, m_ProcessorInformation, pause(), reset(), and setInterrupts().

Referenced by NMFaultHandler::initialiseProcessor(), and X64VirtualAddressSpace::mapHuge().

+ Here is the caller graph for this function:

void Processor::deinitialise ( )
static

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

Definition at line 54 of file arm_common/Processor.h.

Referenced by initialisationDone().

+ Here is the caller graph for this function:

void Processor::disableDebugBreakpoint ( size_t  nBpNumber)
static

Disable a specific breakpoint

Parameters
[in]nBpNumberthe breakpoint number [0 - (getDebugBreakpointCount()
  • 1)]
Todo:
Implement.

Definition at line 69 of file arm_926e/Processor.cc.

Referenced by BreakpointCommand::execute(), and jumpUser().

+ Here is the caller graph for this function:

void Processor::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
Todo:
Implement.

Definition at line 62 of file arm_926e/Processor.cc.

Referenced by BreakpointCommand::execute(), and jumpUser().

+ Here is the caller graph for this function:

uintptr_t Processor::getBasePointer ( )
static

Get the base-pointer of the calling function

Returns
base-pointer of the calling function

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

Referenced by Backtrace::performBpBacktrace().

+ Here is the caller graph for this function:

size_t Processor::getCount ( )
static

Get the number of CPUs currently available

Definition at line 50 of file Processor.cc.

References getInterrupts(), and setInterrupts().

Referenced by Spinlock::acquire(), and cpuid().

+ Here is the caller graph for this function:

uintptr_t Processor::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?
Todo:
Implement.

Definition at line 54 of file arm_926e/Processor.cc.

Referenced by BreakpointCommand::execute(), and jumpUser().

+ Here is the caller graph for this function:

size_t Processor::getDebugBreakpointCount ( )
static

Return the (total) number of breakpoints

Returns
(total) number of breakpoints

Definition at line 49 of file arm_926e/Processor.cc.

Referenced by BreakpointCommand::execute(), and jumpUser().

+ Here is the caller graph for this function:

static uintptr_t Processor::getDebugStatus ( )
static

Get the debug status

Todo:
is the debug status somehow abtractable?
Returns
the debug status
uintptr_t Processor::getInstructionPointer ( )
static

Get the instruction-pointer of the calling function

Returns
instruction-pointer of the calling function

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

Referenced by Backtrace::performBpBacktrace().

+ Here is the caller graph for this function:

bool Processor::getInterrupts ( )
static
uintptr_t Processor::getStackPointer ( )
static

Get the stack-pointer of the calling function

Returns
stack-pointer of the calling function

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

void Processor::halt ( )
static
void Processor::haltUntilInterrupt ( )
static

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

Definition at line 41 of file arm_common/Processor.h.

References getInterrupts(), and setInterrupts().

Referenced by cpuid(), Rtc::initialise2(), and jumpUser().

+ Here is the caller graph for this function:

ProcessorId Processor::id ( )
static
void Processor::identify ( HugeStaticString str)
static

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

Definition at line 43 of file arm_926e/Processor.cc.

Referenced by CpuInfoCommand::execute(), and initialisationDone().

+ Here is the caller graph for this function:

ProcessorInformation & Processor::information ( )
static

Get the ProcessorInformation structure of this processor

Returns
the ProcessorInformation structure of this processor

Definition at line 45 of file Processor.cc.

References m_ProcessorInformation.

Referenced by Spinlock::acquire(), PosixSubsystem::acquire(), Semaphore::acquireWithResult(), BusMasterIde::add(), HostedTimer::addAlarm(), Rtc::addAlarm(), GPTimer::addAlarm(), RequestQueue::addRequest(), PerProcessorScheduler::addThread(), Uhci::addTransferToTransaction(), Ehci::addTransferToTransaction(), Ohci::addTransferToTransaction(), Elf::allocate(), SlamAllocator::allocate(), ArmV7PhysicalMemoryManager::allocateRegion(), HostedPhysicalMemoryManager::allocateRegion(), X86CommonPhysicalMemoryManager::allocateRegion(), VFS::checkAccess(), PosixSubsystem::checkAddress(), PerProcessorScheduler::checkEventState(), MemoryMapManager::clone(), MemoryMappedFile::compact(), MemoryMapManager::compact(), MemoryMapManager::contains(), cpuid(), Ext2Filesystem::createNode(), Pipe::decreaseRefCount(), PerProcessorScheduler::eventHandlerReturned(), Cache::evict(), MappingCommand::execute(), MemoryInspector::execute(), AllocationCommand::execute(), ThreadsCommand::execute(), Bios::executeInterrupt(), PciAtaController::executeRequest(), PosixSubsystem::exit(), Elf::finaliseModule(), X86VirtualAddressSpace::fromFlags(), KernelElf::getDependingModule(), LockedFile::getFile(), File::getPhysicalPage(), Filesystem::getTrueRoot(), UserManager::initialise(), Ps2Mouse::initialise(), X86GdtManager::initialise(), X64GdtManager::initialise(), PerProcessorScheduler::initialise(), Scheduler::initialise(), CacheManager::initialise(), InputManager::initialise(), TextIO::initialise(), Dm9601::initialiseDriver(), X86GdtManager::initialiseProcessor(), X64GdtManager::initialiseProcessor(), DynamicLinker::initPlt(), NMFaultHandler::interrupt(), HostedInterruptManager::interrupt(), X64InterruptManager::interrupt(), X86InterruptManager::interrupt(), MemoryMappedFile::invalidate(), PosixSubsystem::invoke(), IoEvent::IoEvent(), Ipc::IpcMessage::IpcMessage(), CdiIrqHandler::irq(), Ehci::irq(), Thread::join(), jumpUser(), Process::kill(), PosixSubsystem::kill(), PerProcessorScheduler::killCurrentThread(), PosixSubsystem::loadElf(), Elf::loadModule(), LockedFile::lock(), ConsoleManager::lockConsole(), User::login(), Cache::map(), MemoryMapManager::mapAnon(), MemoryMapManager::mapFile(), Ne2k::Ne2k(), Nic3C90x::Nic3C90x(), Backtrace::performBpBacktrace(), PerProcessorScheduler::processorAddThread(), SlamCache::recovery(), AnonymousMemoryMap::remove(), MemoryMappedFile::remove(), MemoryMapManager::remove(), DynamicLinker::resolvePlt(), Process::resume(), pocketknife::runConcurrently(), pocketknife::runConcurrentlyAttached(), MemoryMapManager::sanitiseAddress(), PerProcessorScheduler::schedule(), Nic3C90x::send(), PosixSubsystem::sendSignal(), Thread::setKernelStack(), X86Keyboard::setLedState(), AnonymousMemoryMap::setPermissions(), MemoryMappedFile::setPermissions(), MemoryMapManager::setPermissions(), VirtualTerminalManager::setTerminalMode(), X86GdtManager::setTlsBase(), Thread::setTlsBase(), Thread::shutdown(), PerProcessorScheduler::sleep(), Debugger::start(), Process::suspend(), MemoryMappedFile::sync(), PosixSyscallManager::syscall(), HostedSyscallManager::syscall(), X64SyscallManager::syscall(), WaitCleanup::terminated(), Thread::Thread(), Thread::threadExited(), TimeoutGuard::TimeoutGuard(), PerProcessorScheduler::timer(), DynamicLinker::trap(), DLTrapHandler::trap(), AnonymousMemoryMap::trap(), MemoryMappedFile::trap(), MemoryMapManager::trap(), ConsoleFile::triggerEvent(), RamFile::truncate(), KernelElf::unloadModule(), ConsoleManager::unlockConsole(), MemoryMapManager::unmap(), MemoryMapManager::unmapAllUnlocked(), ConditionVariable::wait(), SlamAllocator::wipe(), RequestQueue::work(), UnixSocket::writeBytewise(), X86VirtualAddressSpace::X86VirtualAddressSpace(), Scheduler::yield(), PosixSubsystem::~PosixSubsystem(), Process::~Process(), TimeoutGuard::~TimeoutGuard(), and X86VirtualAddressSpace::~X86VirtualAddressSpace().

void Processor::initialisationDone ( )
static
void Processor::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:
Unmap.

Definition at line 24 of file arm_926e/Processor.cc.

Referenced by initialisationDone().

+ Here is the caller graph for this function:

void Processor::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 36 of file arm_926e/Processor.cc.

Referenced by initialisationDone().

+ Here is the caller graph for this function:

void Processor::invalidate ( void *  pAddress)
static

Invalidate the TLB entry containing a specific virtual address

Parameters
[in]pAddressthe specific virtual address
Todo:
Figure out if we want to flush the TLB of every processor or if this should be handled by the upper layers

Definition at line 52 of file ppc_common/Processor.h.

Referenced by X64VirtualAddressSpace::clone(), X86VirtualAddressSpace::fromFlags(), jumpUser(), X64VirtualAddressSpace::mapUnlocked(), X86VirtualAddressSpace::revertToKernelAddressSpace(), X64VirtualAddressSpace::revertToKernelAddressSpace(), X64VirtualAddressSpace::setFlags(), X64VirtualAddressSpace::unmapUnlocked(), writeMachineSpecificRegister(), and X86VirtualAddressSpace::X86VirtualAddressSpace().

+ Here is the caller graph for this function:

size_t Processor::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 34 of file Processor.cc.

References m_Initialised.

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

+ Here is the caller graph for this function:

static void Processor::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(), and jumpUser().

+ Here is the caller graph for this function:

void Processor::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.

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

References breakpoint(), disableDebugBreakpoint(), enableDebugBreakpoint(), ERROR, getDebugBreakpoint(), getDebugBreakpointCount(), getInterrupts(), halt(), haltUntilInterrupt(), information(), invalidate(), jumpKernel(), pause(), reset(), restoreState(), setInterrupts(), setSingleStep(), setTlsBase(), switchAddressSpace(), and HostedVirtualAddressSpace::switchAddressSpace().

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

+ Here is the caller graph for this function:

void Processor::pause ( )
static

Pause CPU during a tight polling loop.

Definition at line 49 of file arm_common/Processor.h.

Referenced by Spinlock::acquire(), X86CommonPhysicalMemoryManager::PageStack::allocate(), LocksCommand::checkState(), cpuid(), jumpUser(), and PciAtaController::PciAtaController().

+ Here is the caller graph for this function:

uint64_t Processor::readMachineSpecificRegister ( uint32_t  index)
static

Read a Machine/Model-specific register

Parameters
[in]indexthe register index
Returns
the value of the register

Definition at line 195 of file x86_common/Processor.cc.

Referenced by X64SyscallManager::initialiseProcessor().

+ Here is the caller graph for this function:

void Processor::reset ( )
static

Reset this processor

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

Referenced by cpuid(), HostedInterruptManager::interrupt(), and jumpUser().

+ Here is the caller graph for this function:

void Processor::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 100 of file hosted/Processor.cc.

References NOTICE.

Referenced by PerProcessorScheduler::addThread(), TimeoutGuard::cancel(), PerProcessorScheduler::eventHandlerReturned(), jumpUser(), and PerProcessorScheduler::schedule().

+ Here is the caller graph for this function:

static void Processor::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.
bool Processor::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 88 of file hosted/Processor.cc.

References ERROR.

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

+ Here is the caller graph for this function:

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

Enable/Disable single-stepping

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

Definition at line 84 of file arm_926e/Processor.cc.

References ERROR.

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

+ Here is the caller graph for this function:

void Processor::setTlsBase ( uintptr_t  newBase)
static
void Processor::switchAddressSpace ( VirtualAddressSpace AddressSpace)
static
void Processor::writeMachineSpecificRegister ( uint32_t  index,
uint64_t  value 
)
static

Write a Machine/Model-specific register

Parameters
[in]indexthe register index
[in]valuethe new value of the register

Definition at line 202 of file x86_common/Processor.cc.

References invalidate().

Referenced by X64SyscallManager::initialiseProcessor().

+ Here is the caller graph for this function:

Member Data Documentation

size_t Processor::m_Initialised = 0
static
ProcessorInformation Processor::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 386 of file Processor.h.

Referenced by cpuid(), information(), X86GdtManager::initialise(), X64GdtManager::initialise(), and Scheduler::initialise().


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