summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2015-05-04 00:01:16 -0300
committerGravatar Yuri Kunde Schlesner2015-05-08 22:11:02 -0300
commit6d60acf0f1afcae873988da5218f2f1c7bc9d151 (patch)
treecec75198ab74759002dd1da78f6ac2af5e61949f /src/core/hle/kernel
parentCommon: Add StringFromFixedZeroTerminatedBuffer (diff)
downloadyuzu-6d60acf0f1afcae873988da5218f2f1c7bc9d151.tar.gz
yuzu-6d60acf0f1afcae873988da5218f2f1c7bc9d151.tar.xz
yuzu-6d60acf0f1afcae873988da5218f2f1c7bc9d151.zip
Kernel: Introduce skeleton Process class to hold process data
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/kernel.cpp14
-rw-r--r--src/core/hle/kernel/kernel.h10
-rw-r--r--src/core/hle/kernel/process.cpp35
-rw-r--r--src/core/hle/kernel/process.h61
4 files changed, 101 insertions, 19 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index 533fe65fd..9c8d6fa36 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -10,6 +10,7 @@
10#include "core/arm/arm_interface.h" 10#include "core/arm/arm_interface.h"
11#include "core/core.h" 11#include "core/core.h"
12#include "core/hle/kernel/kernel.h" 12#include "core/hle/kernel/kernel.h"
13#include "core/hle/kernel/process.h"
13#include "core/hle/kernel/thread.h" 14#include "core/hle/kernel/thread.h"
14#include "core/hle/kernel/timer.h" 15#include "core/hle/kernel/timer.h"
15 16
@@ -149,18 +150,7 @@ void Shutdown() {
149 Kernel::ThreadingShutdown(); 150 Kernel::ThreadingShutdown();
150 Kernel::TimersShutdown(); 151 Kernel::TimersShutdown();
151 g_handle_table.Clear(); // Free all kernel objects 152 g_handle_table.Clear(); // Free all kernel objects
152} 153 g_current_process = nullptr;
153
154/**
155 * Loads executable stored at specified address
156 * @entry_point Entry point in memory of loaded executable
157 * @return True on success, otherwise false
158 */
159bool LoadExec(u32 entry_point) {
160 // 0x30 is the typical main thread priority I've seen used so far
161 g_main_thread = Kernel::SetupMainThread(Kernel::DEFAULT_STACK_SIZE, entry_point, THREADPRIO_DEFAULT);
162
163 return true;
164} 154}
165 155
166} // namespace 156} // namespace
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h
index a7bc6b71a..d0c69677a 100644
--- a/src/core/hle/kernel/kernel.h
+++ b/src/core/hle/kernel/kernel.h
@@ -7,6 +7,7 @@
7#include <boost/intrusive_ptr.hpp> 7#include <boost/intrusive_ptr.hpp>
8 8
9#include <array> 9#include <array>
10#include <memory>
10#include <string> 11#include <string>
11#include <vector> 12#include <vector>
12 13
@@ -15,6 +16,8 @@
15#include "core/hle/hle.h" 16#include "core/hle/hle.h"
16#include "core/hle/result.h" 17#include "core/hle/result.h"
17 18
19struct ApplicationInfo;
20
18namespace Kernel { 21namespace Kernel {
19 22
20class Thread; 23class Thread;
@@ -282,11 +285,4 @@ void Init();
282/// Shutdown the kernel 285/// Shutdown the kernel
283void Shutdown(); 286void Shutdown();
284 287
285/**
286 * Loads executable stored at specified address
287 * @entry_point Entry point in memory of loaded executable
288 * @return True on success, otherwise false
289 */
290bool LoadExec(u32 entry_point);
291
292} // namespace 288} // namespace
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp
new file mode 100644
index 000000000..734d6f3ef
--- /dev/null
+++ b/src/core/hle/kernel/process.cpp
@@ -0,0 +1,35 @@
1// Copyright 2015 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "common/assert.h"
6
7#include "core/hle/kernel/process.h"
8#include "core/hle/kernel/thread.h"
9
10namespace Kernel {
11
12SharedPtr<Process> Process::Create(std::string name, u64 program_id) {
13 SharedPtr<Process> process(new Process);
14
15 process->svc_access_mask.set();
16 process->name = std::move(name);
17 process->program_id = program_id;
18
19 return process;
20}
21
22void Process::ParseKernelCaps(const u32 * kernel_caps, size_t len) {
23 //UNIMPLEMENTED();
24}
25
26void Process::Run(VAddr entry_point, s32 main_thread_priority, u32 stack_size) {
27 g_main_thread = Kernel::SetupMainThread(stack_size, entry_point, main_thread_priority);
28}
29
30Kernel::Process::Process() {}
31Kernel::Process::~Process() {}
32
33SharedPtr<Process> g_current_process;
34
35}
diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h
new file mode 100644
index 000000000..8abd881e3
--- /dev/null
+++ b/src/core/hle/kernel/process.h
@@ -0,0 +1,61 @@
1// Copyright 2015 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <bitset>
8
9#include <boost/container/static_vector.hpp>
10
11#include "core/hle/kernel/kernel.h"
12#include "core/hle/result.h"
13
14namespace Kernel {
15
16struct StaticAddressMapping {
17 // Address and size must be 4K-aligned
18 VAddr address;
19 u32 size;
20 bool writable;
21};
22
23enum class MemoryRegion {
24 APPLICATION = 1,
25 SYSTEM = 2,
26 BASE = 3,
27};
28
29class Process final : public Object {
30public:
31 static SharedPtr<Process> Create(std::string name, u64 program_id);
32
33 std::string GetTypeName() const override { return "Process"; }
34 std::string GetName() const override { return name; }
35
36 static const HandleType HANDLE_TYPE = HandleType::Process;
37 HandleType GetHandleType() const override { return HANDLE_TYPE; }
38
39 std::string name; ///< Name of the process
40 u64 program_id;
41
42 std::bitset<0x80> svc_access_mask;
43 unsigned int handle_table_size = 0x200;
44 boost::container::static_vector<StaticAddressMapping, 8> static_address_mappings; // TODO: Determine a good upper limit
45
46 bool loaded_high = false; // Application loaded high (not at 0x00100000)
47 bool shared_page_writable = false;
48 bool privileged_priority = false; // Can use priority levels higher than 24
49 MemoryRegion memory_region = MemoryRegion::APPLICATION;
50
51 void ParseKernelCaps(const u32* kernel_caps, size_t len);
52 void Run(VAddr entry_point, s32 main_thread_priority, u32 stack_size);
53
54private:
55 Process();
56 ~Process() override;
57};
58
59extern SharedPtr<Process> g_current_process;
60
61}