FreeNOS
CoreClient.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 <ChannelClient.h>
19#include "CoreMessage.h"
20#include "CoreClient.h"
21
23 : m_pid(pid)
24{
25}
26
28{
29 if (ChannelClient::instance()->syncSendReceive(&msg, sizeof(msg), m_pid) == ChannelClient::Success)
30 {
31 return msg.result;
32 }
33 else
34 {
35 return Core::IpcError;
36 }
37}
38
40{
41 CoreMessage msg;
44
45 const Core::Result result = request(msg);
46 if (result == Core::Success)
47 {
48 coreCount = msg.coreNumber;
49 }
50
51 return result;
52}
53
55 const Address programAddr,
56 const Size programSize,
57 const char *programCmd) const
58{
59 CoreMessage msg;
62 msg.coreNumber = coreId;
63 msg.programAddr = programAddr;
64 msg.programSize = programSize;
65 msg.programCmd = programCmd;
66
67 return request(msg);
68}
u8 coreId
Definition IntelACPI.h:1
Type type
Message type is either a request or response.
Core::Result request(CoreMessage &msg) const
Send an IPC request to the CoreServer.
const ProcessID m_pid
ProcessID of the CoreServer.
Definition CoreClient.h:89
Core::Result createProcess(const Size coreId, const Address programAddr, const Size programSize, const char *programCmd) const
Create a new process on a different core.
Core::Result getCoreCount(Size &numCores) const
Get number of processor cores in the system.
CoreClient(const ProcessID pid=CORESRV_PID)
Class constructor function.
static ChannelClient * instance()
Retrieve the instance.
Definition Singleton.h:53
u32 ProcessID
Process Identification Number.
Definition Types.h:140
unsigned long Address
A memory address.
Definition Types.h:131
unsigned int Size
Any sane size indicator cannot go negative.
Definition Types.h:128
@ GetCoreCount
Definition Core.h:38
@ CreateProcess
Definition Core.h:39
Result
Result code for Actions.
Definition Core.h:48
@ Success
Definition Core.h:49
@ IpcError
Definition Core.h:57
Message format for communication with the CoreServer.
Definition CoreMessage.h:39
Size programSize
Contains the size of a loaded program.
Definition CoreMessage.h:44
Size coreNumber
Indicates a number of cores or a specific coreId.
Definition CoreMessage.h:42
Core::Result result
Result code.
Definition CoreMessage.h:41
Core::Action action
Action to perform.
Definition CoreMessage.h:40
const char * programCmd
Command-line string for a loaded program.
Definition CoreMessage.h:45
Address programAddr
Contains the virtual address of a loaded program.
Definition CoreMessage.h:43