FreeNOS
IntelCoreServer.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2020 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#include <FreeNOS/User.h>
19#include <FreeNOS/API.h>
20#include <Factory.h>
21#include <Log.h>
22#include "IntelCoreServer.h"
23
25{
26 return new IntelCoreServer();
27}
28
30 : CoreServer()
31 , m_mp(m_apic)
32{
33}
34
36{
38
39 if (r != API::Success)
40 {
41 ERROR("failed to register IPI vector: "
42 "ProcessCtl(WatchIRQ) returned: " << (uint)r);
43 return IOError;
44 }
45
47}
48
50{
51 // Signal the core to boot
52 if (m_mp.boot(info) != IntelMP::Success)
53 {
54 ERROR("failed to boot core" << coreId);
55 return Core::BootError;
56 }
57
58 NOTICE("core" << coreId << " started");
59 return Core::Success;
60}
61
63{
65
68 {
69 NOTICE("using ACPI as CoreManager");
70 m_cores = &m_acpi;
71 }
72 else if (m_mp.discover() == IntelMP::Success)
73 {
74 NOTICE("using MPTable as CoreManager");
75 m_cores = &m_mp;
76 }
77 else
78 {
79 ERROR("no CoreManager found (ACPI or MPTable)");
80 return Core::NotFound;
81 }
82
83 return Core::Success;
84}
85
87{
88 // Wait for IPI which will wake us
91}
92
94{
95 // Send IPI to ensure the slave wakes up for the message
97 {
98 ERROR("failed to send IPI to core" << coreId);
99 return Core::IOError;
100 }
101
102 return Core::Success;
103}
u8 coreId
Definition IntelACPI.h:1
Result
Enumeration of generic kernel API result codes.
Definition API.h:69
@ Success
Definition API.h:70
static T * create()
Abstract function to create an instance of T.
Represents a single Core in a Central Processing Unit (CPU).
Definition CoreServer.h:51
virtual Result initialize()
Initialize the server.
CoreManager * m_cores
Definition CoreServer.h:240
virtual Result initialize()
Initialize the ACPI.
Definition IntelACPI.cpp:27
virtual Result discover()
Discover processors.
Definition IntelACPI.cpp:97
IntController::Result sendIPI(uint coreId, uint vector)
Send Intercore-Processor-Interrupt.
Represents a single Core in a Central Processing Unit (CPU).
virtual void waitIPI() const
Wait for Inter-Processor-Interrupt.
static const uint IPIVector
Inter-Processor-Interrupt vector number.
virtual Core::Result bootCore(uint coreId, CoreInfo *info)
Boot a processor core.
virtual Core::Result discoverCores()
Discover processor cores.
virtual Result initialize()
Initialize the server.
virtual Core::Result sendIPI(uint coreId)
Send Inter-Processor-Interrupt.
IntelCoreServer()
Class constructor function.
virtual Result boot(CoreInfo *info)
Boot a processor.
Definition IntelMP.cpp:90
virtual Result initialize()
Perform initialization.
Definition IntelMP.cpp:30
virtual Result discover()
Discover processors.
Definition IntelMP.cpp:56
#define SELF
Definition ProcessID.h:35
API::Result ProcessCtl(const ProcessID proc, const ProcessOperation op, const Address addr=0, const Address output=0)
Prototype for user applications.
Definition ProcessCtl.h:93
@ WatchIRQ
Definition ProcessCtl.h:43
@ EnterSleep
Definition ProcessCtl.h:51
@ EnableIRQ
Definition ProcessCtl.h:44
#define ERROR(msg)
Output an error message.
Definition Log.h:61
#define NOTICE(msg)
Output a notice message.
Definition Log.h:75
unsigned int uint
Unsigned integer number.
Definition Types.h:44
Result
Result code for Actions.
Definition Core.h:48
@ IOError
Definition Core.h:55
@ Success
Definition Core.h:49
@ BootError
Definition Core.h:52
@ NotFound
Definition Core.h:51
Per-Core information structure.
Definition CoreInfo.h:61