FreeNOS
CoreServer.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __SERVER_CORE_CORESERVER_H
19 #define __SERVER_CORE_CORESERVER_H
20 
21 #include <FreeNOS/User.h>
22 #include <ChannelServer.h>
23 #include <List.h>
24 #include <Types.h>
25 #include <Macros.h>
26 #include <Index.h>
27 #include <ExecutableFormat.h>
28 #include <MemoryChannel.h>
29 #include <CoreInfo.h>
30 #include <Factory.h>
31 #include <CoreManager.h>
32 #include "Core.h"
33 #include "CoreMessage.h"
34 
49 class CoreServer : public ChannelServer<CoreServer, CoreMessage>
50  , public AbstractFactory<CoreServer>
51 {
52  private:
53 
55  static const Size MaxCores = 256;
56 
58  static const Size MaxMessageRetry = 128;
59 
61  static const char *kernelPath;
62 
63  public:
64 
68  CoreServer();
69 
76 
82  int runCore();
83 
89  virtual Result initialize();
90 
91  private:
92 
101  virtual Core::Result bootCore(uint coreId, CoreInfo *info) = 0;
102 
108  virtual Core::Result discoverCores() = 0;
109 
113  virtual void waitIPI() const = 0;
114 
122  virtual Core::Result sendIPI(uint coreId) = 0;
123 
124  private:
125 
136 
143 
150 
157 
164 
171 
180  Core::Result clearPages(Address addr, Size size);
181 
189  void getCoreCount(CoreMessage *msg);
190 
198  void createProcess(CoreMessage *msg);
199 
208 
217 
227 
237 
238  protected:
239 
241 
242  private:
243 
246 
248 
250 
253 
256 
259 };
260 
266 #endif /* __SERVER_CORE_CORESERVER_H */
CoreServer::bootCore
virtual Core::Result bootCore(uint coreId, CoreInfo *info)=0
Boot a processor core.
ExecutableFormat.h
CoreServer::createProcess
void createProcess(CoreMessage *msg)
Create a process on the current processor core.
Definition: CoreServer.cpp:82
Memory::Range
Memory range.
Definition: Memory.h:55
CoreServer::m_fromMaster
MemoryChannel * m_fromMaster
Definition: CoreServer.h:258
Macros.h
CoreServer::unloadKernel
Core::Result unloadKernel()
Unload operating system kernel program.
Definition: CoreServer.cpp:426
CoreServer::m_coreInfo
Index< CoreInfo, MaxCores > * m_coreInfo
Definition: CoreServer.h:251
Types.h
CoreMessage
Message format for communication with the CoreServer.
Definition: CoreMessage.h:38
CoreServer::prepareCoreInfo
Core::Result prepareCoreInfo()
Prepare the CoreInfo array.
Definition: CoreServer.cpp:539
CoreManager.h
CoreServer::m_kernelImage
Memory::Range m_kernelImage
Definition: CoreServer.h:245
Index.h
ExecutableFormat::Region
Memory region.
Definition: ExecutableFormat.h:55
CoreServer::MaxCores
static const Size MaxCores
Maximum number of cores currently supported.
Definition: CoreServer.h:55
CoreServer::initialize
virtual Result initialize()
Initialize the server.
Definition: CoreServer.cpp:260
CoreManager
Generic Core Manager.
Definition: CoreManager.h:36
CoreServer::loadKernel
Core::Result loadKernel()
Load operating system kernel program.
Definition: CoreServer.cpp:315
CoreServer::sendToSlave
Core::Result sendToSlave(uint coreId, CoreMessage *msg)
Send message to slave.
Definition: CoreServer.cpp:730
Index< CoreInfo, MaxCores >
CoreServer::runCore
int runCore()
Routine for the slave processor core.
Definition: CoreServer.cpp:52
Address
unsigned long Address
A memory address.
Definition: Types.h:131
AbstractFactory
Abstract Factory pattern providing a creation function declaration.
Definition: Factory.h:50
uint
unsigned int uint
Unsigned integer number.
Definition: Types.h:44
CoreServer::m_toSlave
Index< MemoryChannel, MaxCores > * m_toSlave
Definition: CoreServer.h:255
CoreServer::waitIPI
virtual void waitIPI() const =0
Wait for Inter-Processor-Interrupt.
CoreServer
Represents a single Core in a Central Processing Unit (CPU).
Definition: CoreServer.h:49
CoreServer::m_kernel
ExecutableFormat * m_kernel
Definition: CoreServer.h:244
CoreServer::CoreServer
CoreServer()
Class constructor function.
Definition: CoreServer.cpp:31
ChannelServer< CoreServer, CoreMessage >::Result
Result
Result codes.
Definition: ChannelServer.h:99
CoreServer::bootAll
Core::Result bootAll()
Boot all processor cores.
Definition: CoreServer.cpp:600
CoreServer::m_info
SystemInformation m_info
Definition: CoreServer.h:252
CoreServer::m_cores
CoreManager * m_cores
Definition: CoreServer.h:240
CoreServer::discoverCores
virtual Core::Result discoverCores()=0
Discover processor cores.
CoreServer::clearPages
Core::Result clearPages(Address addr, Size size)
Clear memory pages with zeroes.
Definition: CoreServer.cpp:624
Size
unsigned int Size
Any sane size indicator cannot go negative.
Definition: Types.h:128
CoreServer::getCoreCount
void getCoreCount(CoreMessage *msg)
Get and fill the number of processor cores.
Definition: CoreServer.cpp:207
MemoryChannel
Unidirectional point-to-point channel using shared memory.
Definition: MemoryChannel.h:43
CoreServer::setupChannels
Core::Result setupChannels()
Setup communication channels between CoreServers.
Definition: CoreServer.cpp:642
CoreMessage.h
CoreInfo
Per-Core information structure.
Definition: CoreInfo.h:60
Core::Result
Result
Result code for Actions.
Definition: Core.h:47
CoreServer::m_fromSlave
Index< MemoryChannel, MaxCores > * m_fromSlave
Definition: CoreServer.h:254
ChannelServer
Template class which serves incoming messages from Channels using MessageHandlers.
Definition: ChannelServer.h:79
SystemInformation
System information structure.
Definition: SystemInfo.h:79
CoreServer::test
Core::Result test()
Run a ping-pong test.
Definition: CoreServer.cpp:224
CoreServer::prepareCore
Core::Result prepareCore(uint coreId, CoreInfo *info, ExecutableFormat::Region *regions)
Prepare processor core for booting.
Definition: CoreServer.cpp:441
CoreServer::sendToMaster
Core::Result sendToMaster(CoreMessage *msg)
Send message to master.
Definition: CoreServer.cpp:702
CoreServer::MaxMessageRetry
static const Size MaxMessageRetry
Number of times to busy wait on receiving a message.
Definition: CoreServer.h:58
MemoryChannel.h
CoreInfo.h
CoreServer::kernelPath
static const char * kernelPath
The default kernel for starting new cores.
Definition: CoreServer.h:61
CoreServer::sendIPI
virtual Core::Result sendIPI(uint coreId)=0
Send Inter-Processor-Interrupt.
Core.h
ChannelServer.h
CoreServer::m_numRegions
Size m_numRegions
Definition: CoreServer.h:249
CoreServer::m_toMaster
MemoryChannel * m_toMaster
Definition: CoreServer.h:257
Factory.h
coreId
u8 coreId
Definition: IntelACPI.h:64
CoreServer::receiveFromSlave
Core::Result receiveFromSlave(uint coreId, CoreMessage *msg)
Receive message from slave.
Definition: CoreServer.cpp:718
ExecutableFormat
Abstraction class of various executable formats.
Definition: ExecutableFormat.h:48
CoreServer::receiveFromMaster
Core::Result receiveFromMaster(CoreMessage *msg)
Receive message from master.
Definition: CoreServer.cpp:683
CoreServer::m_regions
ExecutableFormat::Region m_regions[16]
Definition: CoreServer.h:247
List.h