The Pedigree Project 0.1
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
Machine Class Referenceabstract

#include <Machine.h>

+ Inheritance diagram for Machine:
+ Collaboration diagram for Machine:

Public Types

enum class  ShutdownType { Restart , Halt , PowerOff }
 
enum class  ShutdownPhase {
  NotStarted , Requested , Userspace , Syscalls ,
  Filesystems , Modules , Firmware , Destructors ,
  Input , Caches , Timers , Devices ,
  Processors , ProcessorCleanup , FinalAction
}
 

Public Member Functions

virtual bool supportsPowerOff () const
 
virtual bool prepareShutdown (ShutdownType type)
 
virtual void finalShutdown (ShutdownType type)
 
void displayShutdownMessage (const char *message)
 
virtual void initialise ()=0
 
virtual void initialise2 ()
 Called after debugger startup.
 
virtual void initialise3 ()
 Called after processor startup - for thread creation etc.
 
virtual void deinitialise ()
 
bool isInitialised ()
 
virtual void initialiseDeviceTree ()
 
virtual Serial * getSerial (size_t n)=0
 
virtual size_t getNumSerial ()=0
 
virtual Vga * getVga (size_t n)=0
 
virtual size_t getNumVga ()=0
 
virtual IrqManager * getIrqManager ()=0
 
virtual SchedulerTimer * getSchedulerTimer ()=0
 
virtual Timer * getTimer ()=0
 
virtual Keyboard * getKeyboard ()=0
 
virtual void setKeyboard (Keyboard *kb)=0
 
virtual MUST_USE_RESULT bool quiesceAllOtherProcessors ()
 
virtual MUST_USE_RESULT bool resumeAllOtherProcessors ()
 
virtual MUST_USE_RESULT bool stopAllOtherProcessors ()
 

Static Public Member Functions

static void setShutdownPhase (ShutdownPhase phase)
 
static const char * shutdownPhaseName ()
 
static Machine & instance ()
 

Protected Attributes

bool m_bInitialised
 

Private Member Functions

 Machine (const Machine &)
 
Machine & operator= (const Machine &)
 

Friends

void system_reset ()
 

Detailed Description

This is an abstraction on a machine, or board. It provides functions to retrieve Timers, Serial controllers, VGA controllers, Ethernet controllers etc, without having to know the exact implementation required or memory map. It also provides a "probe" function, which will attempt to detect if a machine is present.

Definition at line 41 of file include/pedigree/kernel/machine/Machine.h.

Member Enumeration Documentation

◆ ShutdownPhase

enum class Machine::ShutdownPhase
strong

Definition at line 46 of file include/pedigree/kernel/machine/Machine.h.

◆ ShutdownType

enum class Machine::ShutdownType
strong

Definition at line 45 of file include/pedigree/kernel/machine/Machine.h.

Constructor & Destructor Documentation

◆ Machine()

Machine::Machine ( )
inlineprotected

Definition at line 163 of file include/pedigree/kernel/machine/Machine.h.

◆ ~Machine()

Machine::~Machine ( )
protectedvirtual

Definition at line 26 of file Machine.cc.

Member Function Documentation

◆ deinitialise()

virtual void Machine::deinitialise ( )
inlinevirtual

Stops platform services while interrupts and the scheduler are alive. Implementations may synchronously drain callbacks and join workers.

Reimplemented in HostedMachine, Pc, and VirtMachine.

Definition at line 94 of file include/pedigree/kernel/machine/Machine.h.

Referenced by HostedMachine::deinitialise(), and VirtMachine::deinitialise().

+ Here is the caller graph for this function:

◆ displayShutdownMessage()

void Machine::displayShutdownMessage ( const char *  message)

Uses retained console providers after other display writers have stopped.

Definition at line 80 of file Machine.cc.

References Vga::getNumCols(), Vga::getNumRows(), getNumSerial(), getNumVga(), getSerial(), getVga(), Vga::moveCursor(), and Vga::setLargestTextMode().

Referenced by Pc::finalShutdown(), and panic().

+ Here is the caller graph for this function:

◆ finalShutdown()

void Machine::finalShutdown ( ShutdownType  type)
virtual

Runs after all workers, devices and other processors have stopped.

Reimplemented in Pc, and VirtMachine.

Definition at line 75 of file Machine.cc.

References ProcessorBase::reset().

Referenced by ProcessorBase::reset().

+ Here is the caller graph for this function:

◆ getKeyboard()

virtual Keyboard * Machine::getKeyboard ( )
pure virtual

Returns the keyboard device.

Implemented in HostedMachine, Pc, and VirtMachine.

Referenced by Debugger::start().

+ Here is the caller graph for this function:

◆ getNumSerial()

virtual size_t Machine::getNumSerial ( )
pure virtual

Returns the number of Serial device.

Implemented in HostedMachine, Pc, and VirtMachine.

Referenced by displayShutdownMessage().

+ Here is the caller graph for this function:

◆ getNumVga()

virtual size_t Machine::getNumVga ( )
pure virtual

Returns the number of VGA devices.

Implemented in HostedMachine, Pc, and VirtMachine.

Referenced by displayShutdownMessage(), and Debugger::start().

+ Here is the caller graph for this function:

◆ getSchedulerTimer()

virtual SchedulerTimer * Machine::getSchedulerTimer ( )
pure virtual

Returns the SchedulerTimer device.

Implemented in HostedMachine, Pc, and VirtMachine.

Referenced by PerProcessorScheduler::initialise(), and Rtc::initialise3().

+ Here is the caller graph for this function:

◆ getSerial()

virtual Serial * Machine::getSerial ( size_t  n)
pure virtual

Returns the n'th Serial device.

Implemented in HostedMachine, Pc, and VirtMachine.

Referenced by _assert(), Log::addEntry(), displayShutdownMessage(), SlamCommand::execute(), panic(), Rtc::processElapsedTime(), HostedTimer::processTimerBatch(), and Debugger::start().

+ Here is the caller graph for this function:

◆ getTimer()

virtual Timer * Machine::getTimer ( )
pure virtual

Returns the n'th Timer device.

Implemented in HostedMachine, Pc, and VirtMachine.

Referenced by CacheManager::initialise(), IntervalTimer::IntervalTimer(), HidInputManager::keyDown(), RequestQueue::resume(), Uhci::timer(), and PerProcessorScheduler::timer().

+ Here is the caller graph for this function:

◆ getVga()

virtual Vga * Machine::getVga ( size_t  n)
pure virtual

Returns the n'th VGA device.

Implemented in HostedMachine, Pc, and VirtMachine.

Referenced by FramebufferFile::command(), displayShutdownMessage(), BootIO::initialise(), and TextIO::initialise().

+ Here is the caller graph for this function:

◆ initialise()

virtual void Machine::initialise ( )
pure virtual

Initialises the machine.

Implemented in HostedMachine, Pc, and VirtMachine.

◆ initialise2()

virtual void Machine::initialise2 ( )
inlinevirtual

Called after debugger startup.

Definition at line 87 of file include/pedigree/kernel/machine/Machine.h.

◆ initialise3()

virtual void Machine::initialise3 ( )
inlinevirtual

Called after processor startup - for thread creation etc.

Reimplemented in HostedMachine, Pc, and VirtMachine.

Definition at line 89 of file include/pedigree/kernel/machine/Machine.h.

◆ initialiseDeviceTree()

virtual void Machine::initialiseDeviceTree ( )
inlinevirtual

Initialises the machine's base device tree, if one exists, to prefill the tree with those devices that are not otherwise able to be detected via some sort of bus support.

Reimplemented in HostedMachine, Pc, and VirtMachine.

Definition at line 106 of file include/pedigree/kernel/machine/Machine.h.

◆ instance()

Machine & Machine::instance ( )
static

Definition at line 32 of file hosted/Machine.cc.

◆ isInitialised()

bool Machine::isInitialised ( )
inline

Definition at line 97 of file include/pedigree/kernel/machine/Machine.h.

◆ prepareShutdown()

virtual bool Machine::prepareShutdown ( ShutdownType  type)
inlinevirtual

Prepares firmware and drains its workers while scheduling is available.

Reimplemented in Pc.

Definition at line 73 of file include/pedigree/kernel/machine/Machine.h.

◆ quiesceAllOtherProcessors()

bool Machine::quiesceAllOtherProcessors ( )
virtual

Temporarily pauses every other processor for an interactive debugger.

Reimplemented in HostedMachine.

Definition at line 129 of file Machine.cc.

References EMIT_IF.

Referenced by Debugger::start().

+ Here is the caller graph for this function:

◆ resumeAllOtherProcessors()

bool Machine::resumeAllOtherProcessors ( )
virtual

Resumes processors paused by quiesceAllOtherProcessors().

Reimplemented in HostedMachine.

Definition at line 136 of file Machine.cc.

References EMIT_IF.

◆ setKeyboard()

virtual void Machine::setKeyboard ( Keyboard *  kb)
pure virtual

Sets the keyboard device.

Implemented in HostedMachine, Pc, and VirtMachine.

◆ setShutdownPhase()

void Machine::setShutdownPhase ( ShutdownPhase  phase)
static

Definition at line 32 of file Machine.cc.

◆ shutdownPhaseName()

const char * Machine::shutdownPhaseName ( )
static

Definition at line 36 of file Machine.cc.

◆ stopAllOtherProcessors()

bool Machine::stopAllOtherProcessors ( )
virtual

Permanently stops all other cores for panic or terminal shutdown.

Returns
true if every other processor reached its terminal halt path.

Reimplemented in HostedMachine.

Definition at line 143 of file Machine.cc.

References EMIT_IF.

Referenced by panic().

+ Here is the caller graph for this function:

◆ supportsPowerOff()

virtual bool Machine::supportsPowerOff ( ) const
inlinevirtual

Definition at line 69 of file include/pedigree/kernel/machine/Machine.h.

Friends And Related Symbol Documentation

◆ system_reset

void system_reset ( )
friend

Definition at line 638 of file system/kernel/core/main.cc.

Member Data Documentation

◆ m_bInitialised

bool Machine::m_bInitialised
protected

Definition at line 166 of file include/pedigree/kernel/machine/Machine.h.


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