FreeNOS
Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes
CoreServer Class Referenceabstract

Represents a single Core in a Central Processing Unit (CPU). More...

#include <CoreServer.h>

Inheritance diagram for CoreServer:
ChannelServer< CoreServer, CoreMessage > AbstractFactory< CoreServer > IntelCoreServer SingleCoreServer SunxiCoreServer

Public Member Functions

 CoreServer ()
 Class constructor function. More...
 
Core::Result test ()
 Run a ping-pong test. More...
 
int runCore ()
 Routine for the slave processor core. More...
 
virtual Result initialize ()
 Initialize the server. More...
 
- Public Member Functions inherited from ChannelServer< CoreServer, CoreMessage >
 ChannelServer (CoreServer *inst)
 Constructor function. More...
 
virtual ~ChannelServer ()
 Destructor function. More...
 
int run ()
 Enters an infinite loop, serving incoming requests. More...
 
void setTimeout (const uint msec)
 Set a sleep timeout. More...
 

Protected Attributes

CoreManagerm_cores
 
- Protected Attributes inherited from ChannelServer< CoreServer, CoreMessage >
CoreServerm_instance
 Server object instance. More...
 
ChannelClientm_client
 Client for sending replies. More...
 
ChannelRegistrym_registry
 Contains registered channels. More...
 
MemoryChannel m_kernelEvent
 Kernel event channel. More...
 
Index< MessageHandler< IPCHandlerFunction >, MaximumHandlerCountm_ipcHandlers
 IPC handler functions. More...
 
Index< MessageHandler< IRQHandlerFunction >, MaximumHandlerCountm_irqHandlers
 IRQ handler functions. More...
 
ProcessID m_self
 ProcessID of ourselves. More...
 
Timer::Info m_time
 System timer value. More...
 
Timer::Info m_expiry
 System timer expiration value. More...
 

Private Member Functions

virtual Core::Result bootCore (uint coreId, CoreInfo *info)=0
 Boot a processor core. More...
 
virtual Core::Result discoverCores ()=0
 Discover processor cores. More...
 
virtual void waitIPI () const =0
 Wait for Inter-Processor-Interrupt. More...
 
virtual Core::Result sendIPI (uint coreId)=0
 Send Inter-Processor-Interrupt. More...
 
Core::Result prepareCore (uint coreId, CoreInfo *info, ExecutableFormat::Region *regions)
 Prepare processor core for booting. More...
 
Core::Result prepareCoreInfo ()
 Prepare the CoreInfo array. More...
 
Core::Result loadKernel ()
 Load operating system kernel program. More...
 
Core::Result unloadKernel ()
 Unload operating system kernel program. More...
 
Core::Result bootAll ()
 Boot all processor cores. More...
 
Core::Result setupChannels ()
 Setup communication channels between CoreServers. More...
 
Core::Result clearPages (Address addr, Size size)
 Clear memory pages with zeroes. More...
 
void getCoreCount (CoreMessage *msg)
 Get and fill the number of processor cores. More...
 
void createProcess (CoreMessage *msg)
 Create a process on the current processor core. More...
 
Core::Result receiveFromMaster (CoreMessage *msg)
 Receive message from master. More...
 
Core::Result sendToMaster (CoreMessage *msg)
 Send message to master. More...
 
Core::Result receiveFromSlave (uint coreId, CoreMessage *msg)
 Receive message from slave. More...
 
Core::Result sendToSlave (uint coreId, CoreMessage *msg)
 Send message to slave. More...
 

Private Attributes

ExecutableFormatm_kernel
 
Memory::Range m_kernelImage
 
ExecutableFormat::Region m_regions [16]
 
Size m_numRegions
 
Index< CoreInfo, MaxCores > * m_coreInfo
 
SystemInformation m_info
 
Index< MemoryChannel, MaxCores > * m_fromSlave
 
Index< MemoryChannel, MaxCores > * m_toSlave
 
MemoryChannelm_toMaster
 
MemoryChannelm_fromMaster
 

Static Private Attributes

static const Size MaxCores = 256
 Maximum number of cores currently supported. More...
 
static const Size MaxMessageRetry = 128
 Number of times to busy wait on receiving a message. More...
 
static const char * kernelPath = "/boot/kernel"
 The default kernel for starting new cores. More...
 

Additional Inherited Members

- Public Types inherited from ChannelServer< CoreServer, CoreMessage >
enum  Result
 Result codes. More...
 
- Static Public Member Functions inherited from AbstractFactory< CoreServer >
static CoreServercreate ()
 Abstract function to create an instance of T. More...
 
- Protected Types inherited from ChannelServer< CoreServer, CoreMessage >
typedef void(CoreServer ::* IPCHandlerFunction) (CoreMessage *)
 Member function pointer inside Base, to handle IPC messages. More...
 
typedef void(CoreServer ::* IRQHandlerFunction) (Size)
 Member function pointer inside Base, to handle interrupts. More...
 
- Protected Member Functions inherited from ChannelServer< CoreServer, CoreMessage >
void addIPCHandler (const Size slot, IPCHandlerFunction h, const bool sendReply=true)
 Register a new IPC message action handler. More...
 
void addIRQHandler (const Size slot, IRQHandlerFunction h)
 Register a new IRQ message vector handler. More...
 
virtual void timeout ()
 Called when sleep timeout is reached. More...
 
virtual bool retryRequests ()
 Retry any pending requests. More...
 
virtual void onProcessTerminated (const ProcessID pid)
 Called whenever another Process is terminated. More...
 
void retryAllRequests ()
 Keep retrying requests until all served. More...
 

Detailed Description

Represents a single Core in a Central Processing Unit (CPU).

Each core in a system will run its own instance of CoreServer. CoreServers will communicate and collaborate together to implement functionality.

Definition at line 49 of file CoreServer.h.

Constructor & Destructor Documentation

◆ CoreServer()

CoreServer::CoreServer ( )

Member Function Documentation

◆ bootAll()

Core::Result CoreServer::bootAll ( )
private

◆ bootCore()

virtual Core::Result CoreServer::bootCore ( uint  coreId,
CoreInfo info 
)
privatepure virtual

Boot a processor core.

Parameters
coreIdCore identifier number
infoCoreInfo pointer containing specific core information
Returns
Result code

Implemented in SunxiCoreServer, IntelCoreServer, and SingleCoreServer.

Referenced by bootAll().

◆ clearPages()

Core::Result CoreServer::clearPages ( Address  addr,
Size  size 
)
private

Clear memory pages with zeroes.

Parameters
addrPhysical memory address to clear
sizeNumber of bytes to clear
Returns
Exit code

Definition at line 624 of file CoreServer.cpp.

References Memory::Range::access, DEBUG, MapContiguous, Memory::Range::phys, Memory::Readable, SELF, MemoryBlock::set(), Memory::Range::size, Core::Success, UnMap, Memory::User, Memory::Range::virt, VMCtl(), Memory::Writable, and ZERO.

Referenced by prepareCoreInfo().

◆ createProcess()

void CoreServer::createProcess ( CoreMessage msg)
private

◆ discoverCores()

virtual Core::Result CoreServer::discoverCores ( )
privatepure virtual

Discover processor cores.

Returns
Result code

Implemented in SunxiCoreServer, IntelCoreServer, and SingleCoreServer.

Referenced by initialize().

◆ getCoreCount()

void CoreServer::getCoreCount ( CoreMessage msg)
private

Get and fill the number of processor cores.

Parameters
msgCoreMessage to fill in the core count
Returns
Exit code

Definition at line 207 of file CoreServer.cpp.

References SystemInformation::coreId, CoreMessage::coreNumber, List< T >::count(), DEBUG, CoreManager::getCores(), Core::InvalidArgument, m_cores, m_info, CoreMessage::result, and Core::Success.

Referenced by CoreServer().

◆ initialize()

CoreServer::Result CoreServer::initialize ( )
virtual

◆ loadKernel()

Core::Result CoreServer::loadKernel ( )
private

◆ prepareCore()

Core::Result CoreServer::prepareCore ( uint  coreId,
CoreInfo info,
ExecutableFormat::Region regions 
)
private

◆ prepareCoreInfo()

Core::Result CoreServer::prepareCoreInfo ( )
private

◆ receiveFromMaster()

Core::Result CoreServer::receiveFromMaster ( CoreMessage msg)
private

Receive message from master.

Parameters
msgCoreMessage pointer
Returns
Result code

Definition at line 683 of file CoreServer.cpp.

References m_fromMaster, MaxMessageRetry, Channel::NotFound, MemoryChannel::read(), Channel::Success, Core::Success, and waitIPI().

Referenced by runCore().

◆ receiveFromSlave()

Core::Result CoreServer::receiveFromSlave ( uint  coreId,
CoreMessage msg 
)
private

Receive message from slave.

Parameters
coreIdCore identifier
msgCoreMessage pointer
Returns
Result code

Definition at line 718 of file CoreServer.cpp.

References coreId, Index< T, N >::get(), Core::IOError, m_fromSlave, MemoryChannel::read(), Channel::Success, and Core::Success.

Referenced by createProcess(), and test().

◆ runCore()

int CoreServer::runCore ( )

◆ sendIPI()

virtual Core::Result CoreServer::sendIPI ( uint  coreId)
privatepure virtual

Send Inter-Processor-Interrupt.

Parameters
coreIdCore identifier number
Returns
Result code

Implemented in SunxiCoreServer, IntelCoreServer, and SingleCoreServer.

Referenced by sendToSlave().

◆ sendToMaster()

Core::Result CoreServer::sendToMaster ( CoreMessage msg)
private

Send message to master.

Parameters
msgCoreMessage pointer
Returns
Result code

Definition at line 702 of file CoreServer.cpp.

References ERROR, MemoryChannel::flush(), Core::IOError, m_toMaster, CoreMessage::result, Channel::Success, Core::Success, and MemoryChannel::write().

Referenced by createProcess(), runCore(), and test().

◆ sendToSlave()

Core::Result CoreServer::sendToSlave ( uint  coreId,
CoreMessage msg 
)
private

Send message to slave.

Parameters
coreIdCore identifier
msgCoreMessage pointer
Returns
Result code

Definition at line 730 of file CoreServer.cpp.

References coreId, ERROR, MemoryChannel::flush(), Index< T, N >::get(), Core::IOError, m_toSlave, Core::NotFound, CoreMessage::result, sendIPI(), Channel::Success, Core::Success, and MemoryChannel::write().

Referenced by createProcess().

◆ setupChannels()

Core::Result CoreServer::setupChannels ( )
private

◆ test()

Core::Result CoreServer::test ( )

◆ unloadKernel()

Core::Result CoreServer::unloadKernel ( )
private

Unload operating system kernel program.

Returns
Result code

Definition at line 426 of file CoreServer.cpp.

References ERROR, Core::IOError, m_kernelImage, m_regions, Release, SELF, MemoryBlock::set(), Core::Success, API::Success, and VMCtl().

Referenced by initialize().

◆ waitIPI()

virtual void CoreServer::waitIPI ( ) const
privatepure virtual

Wait for Inter-Processor-Interrupt.

Implemented in SunxiCoreServer, IntelCoreServer, and SingleCoreServer.

Referenced by receiveFromMaster().

Field Documentation

◆ kernelPath

const char * CoreServer::kernelPath = "/boot/kernel"
staticprivate

The default kernel for starting new cores.

Definition at line 61 of file CoreServer.h.

Referenced by loadKernel(), prepareCore(), and prepareCoreInfo().

◆ m_coreInfo

Index<CoreInfo, MaxCores>* CoreServer::m_coreInfo
private

Definition at line 251 of file CoreServer.h.

Referenced by bootAll(), CoreServer(), prepareCoreInfo(), and setupChannels().

◆ m_cores

CoreManager* CoreServer::m_cores
protected

◆ m_fromMaster

MemoryChannel* CoreServer::m_fromMaster
private

Definition at line 258 of file CoreServer.h.

Referenced by CoreServer(), receiveFromMaster(), and setupChannels().

◆ m_fromSlave

Index<MemoryChannel, MaxCores>* CoreServer::m_fromSlave
private

Definition at line 254 of file CoreServer.h.

Referenced by CoreServer(), receiveFromSlave(), and setupChannels().

◆ m_info

SystemInformation CoreServer::m_info
private

Definition at line 252 of file CoreServer.h.

Referenced by createProcess(), getCoreCount(), initialize(), runCore(), and test().

◆ m_kernel

ExecutableFormat* CoreServer::m_kernel
private

Definition at line 244 of file CoreServer.h.

Referenced by CoreServer(), loadKernel(), and prepareCoreInfo().

◆ m_kernelImage

Memory::Range CoreServer::m_kernelImage
private

Definition at line 245 of file CoreServer.h.

Referenced by CoreServer(), loadKernel(), prepareCore(), and unloadKernel().

◆ m_numRegions

Size CoreServer::m_numRegions
private

Definition at line 249 of file CoreServer.h.

Referenced by CoreServer(), loadKernel(), and prepareCore().

◆ m_regions

ExecutableFormat::Region CoreServer::m_regions[16]
private

Definition at line 247 of file CoreServer.h.

Referenced by bootAll(), loadKernel(), prepareCore(), and unloadKernel().

◆ m_toMaster

MemoryChannel* CoreServer::m_toMaster
private

Definition at line 257 of file CoreServer.h.

Referenced by CoreServer(), sendToMaster(), and setupChannels().

◆ m_toSlave

Index<MemoryChannel, MaxCores>* CoreServer::m_toSlave
private

Definition at line 255 of file CoreServer.h.

Referenced by CoreServer(), sendToSlave(), and setupChannels().

◆ MaxCores

const Size CoreServer::MaxCores = 256
staticprivate

Maximum number of cores currently supported.

Definition at line 55 of file CoreServer.h.

◆ MaxMessageRetry

const Size CoreServer::MaxMessageRetry = 128
staticprivate

Number of times to busy wait on receiving a message.

Definition at line 58 of file CoreServer.h.

Referenced by receiveFromMaster().


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