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 }
ChannelClient.h
StrictSingleton< ChannelClient >::instance
static ChannelClient * instance()
Retrieve the instance.
Definition: Singleton.h:53
CoreMessage::programAddr
Address programAddr
Contains the virtual address of a loaded program.
Definition: CoreMessage.h:43
CoreMessage
Message format for communication with the CoreServer.
Definition: CoreMessage.h:38
CoreClient.h
ChannelMessage::type
Type type
Message type is either a request or response.
Definition: ChannelMessage.h:48
ProcessID
u32 ProcessID
Process Identification Number.
Definition: Types.h:140
ChannelClient::Success
@ Success
Definition: ChannelClient.h:83
Address
unsigned long Address
A memory address.
Definition: Types.h:131
CoreMessage::result
Core::Result result
Result code.
Definition: CoreMessage.h:41
CoreClient::createProcess
Core::Result createProcess(const Size coreId, const Address programAddr, const Size programSize, const char *programCmd) const
Create a new process on a different core.
Definition: CoreClient.cpp:54
CoreMessage::action
Core::Action action
Action to perform.
Definition: CoreMessage.h:40
CoreClient::m_pid
const ProcessID m_pid
ProcessID of the CoreServer.
Definition: CoreClient.h:89
CoreClient::getCoreCount
Core::Result getCoreCount(Size &numCores) const
Get number of processor cores in the system.
Definition: CoreClient.cpp:39
CoreClient::CoreClient
CoreClient(const ProcessID pid=CORESRV_PID)
Class constructor function.
Definition: CoreClient.cpp:22
CoreMessage::programCmd
const char * programCmd
Command-line string for a loaded program.
Definition: CoreMessage.h:45
CoreMessage::coreNumber
Size coreNumber
Indicates a number of cores or a specific coreId.
Definition: CoreMessage.h:42
Core::IpcError
@ IpcError
Definition: Core.h:57
Size
unsigned int Size
Any sane size indicator cannot go negative.
Definition: Types.h:128
CoreMessage::programSize
Size programSize
Contains the size of a loaded program.
Definition: CoreMessage.h:44
CoreMessage.h
Core::Result
Result
Result code for Actions.
Definition: Core.h:47
Core::CreateProcess
@ CreateProcess
Definition: Core.h:39
Core::Success
@ Success
Definition: Core.h:49
coreId
u8 coreId
Definition: IntelACPI.h:64
CoreClient::request
Core::Result request(CoreMessage &msg) const
Send an IPC request to the CoreServer.
Definition: CoreClient.cpp:27
Core::GetCoreCount
@ GetCoreCount
Definition: Core.h:38
ChannelMessage::Request
@ Request
Definition: ChannelMessage.h:43