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
49class 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
102
109
113 virtual void waitIPI() const = 0;
114
123
124 private:
125
136
143
150
157
164
171
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 */
u8 coreId
Definition IntelACPI.h:1
Abstract Factory pattern providing a creation function declaration.
Definition Factory.h:51
Template class which serves incoming messages from Channels using MessageHandlers.
Generic Core Manager.
Definition CoreManager.h:37
Represents a single Core in a Central Processing Unit (CPU).
Definition CoreServer.h:51
Core::Result sendToMaster(CoreMessage *msg)
Send message to master.
MemoryChannel * m_toMaster
Definition CoreServer.h:257
Core::Result bootAll()
Boot all processor cores.
Index< MemoryChannel, MaxCores > * m_fromSlave
Definition CoreServer.h:254
virtual Core::Result sendIPI(uint coreId)=0
Send Inter-Processor-Interrupt.
void getCoreCount(CoreMessage *msg)
Get and fill the number of processor cores.
SystemInformation m_info
Definition CoreServer.h:252
void createProcess(CoreMessage *msg)
Create a process on the current processor core.
virtual void waitIPI() const =0
Wait for Inter-Processor-Interrupt.
Memory::Range m_kernelImage
Definition CoreServer.h:245
Core::Result loadKernel()
Load operating system kernel program.
virtual Result initialize()
Initialize the server.
ExecutableFormat * m_kernel
Definition CoreServer.h:244
Index< MemoryChannel, MaxCores > * m_toSlave
Definition CoreServer.h:255
int runCore()
Routine for the slave processor core.
Core::Result receiveFromMaster(CoreMessage *msg)
Receive message from master.
virtual Core::Result bootCore(uint coreId, CoreInfo *info)=0
Boot a processor core.
Core::Result unloadKernel()
Unload operating system kernel program.
static const Size MaxCores
Maximum number of cores currently supported.
Definition CoreServer.h:55
Core::Result prepareCore(uint coreId, CoreInfo *info, ExecutableFormat::Region *regions)
Prepare processor core for booting.
virtual Core::Result discoverCores()=0
Discover processor cores.
Index< CoreInfo, MaxCores > * m_coreInfo
Definition CoreServer.h:251
Core::Result sendToSlave(uint coreId, CoreMessage *msg)
Send message to slave.
Core::Result prepareCoreInfo()
Prepare the CoreInfo array.
CoreManager * m_cores
Definition CoreServer.h:240
Core::Result test()
Run a ping-pong test.
Core::Result receiveFromSlave(uint coreId, CoreMessage *msg)
Receive message from slave.
static const char * kernelPath
The default kernel for starting new cores.
Definition CoreServer.h:61
MemoryChannel * m_fromMaster
Definition CoreServer.h:258
static const Size MaxMessageRetry
Number of times to busy wait on receiving a message.
Definition CoreServer.h:58
Core::Result clearPages(Address addr, Size size)
Clear memory pages with zeroes.
Size m_numRegions
Definition CoreServer.h:249
ExecutableFormat::Region m_regions[16]
Definition CoreServer.h:247
Core::Result setupChannels()
Setup communication channels between CoreServers.
CoreServer()
Class constructor function.
Abstraction class of various executable formats.
Index is a N-sized array of pointers to items of type T.
Definition Index.h:37
Unidirectional point-to-point channel using shared memory.
unsigned long Address
A memory address.
Definition Types.h:131
unsigned int uint
Unsigned integer number.
Definition Types.h:44
unsigned int Size
Any sane size indicator cannot go negative.
Definition Types.h:128
Result
Result code for Actions.
Definition Core.h:48
Per-Core information structure.
Definition CoreInfo.h:61
Message format for communication with the CoreServer.
Definition CoreMessage.h:39
Memory range.
Definition Memory.h:56
System information structure.
Definition SystemInfo.h:80