summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel/thread.h')
-rw-r--r--src/core/hle/kernel/thread.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h
new file mode 100644
index 000000000..9628f165d
--- /dev/null
+++ b/src/core/hle/kernel/thread.h
@@ -0,0 +1,74 @@
1// Copyright 2014 Citra Emulator Project / PPSSPP Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "common/common_types.h"
8#include "core/hle/kernel/kernel.h"
9
10enum ThreadPriority {
11 THREADPRIO_HIGHEST = 0, ///< Highest thread priority
12 THREADPRIO_DEFAULT = 16, ///< Default thread priority for userland apps
13 THREADPRIO_LOW = 31, ///< Low range of thread priority for userland apps
14 THREADPRIO_LOWEST = 63, ///< Thread priority max checked by svcCreateThread
15};
16
17enum ThreadProcessorId {
18 THREADPROCESSORID_0 = 0xFFFFFFFE, ///< Enables core appcode
19 THREADPROCESSORID_1 = 0xFFFFFFFD, ///< Enables core syscore
20 THREADPROCESSORID_ALL = 0xFFFFFFFC, ///< Enables both cores
21};
22
23enum ThreadStatus {
24 THREADSTATUS_RUNNING = 1,
25 THREADSTATUS_READY = 2,
26 THREADSTATUS_WAIT = 4,
27 THREADSTATUS_SUSPEND = 8,
28 THREADSTATUS_DORMANT = 16,
29 THREADSTATUS_DEAD = 32,
30 THREADSTATUS_WAITSUSPEND = THREADSTATUS_WAIT | THREADSTATUS_SUSPEND
31};
32
33enum WaitType {
34 WAITTYPE_NONE,
35 WAITTYPE_SLEEP,
36 WAITTYPE_SEMA,
37 WAITTYPE_EVENTFLAG,
38 WAITTYPE_THREADEND,
39 WAITTYPE_VBLANK,
40 WAITTYPE_MUTEX,
41 WAITTYPE_SYNCH,
42};
43
44namespace Kernel {
45
46/// Creates a new thread - wrapper for external user
47Handle CreateThread(const char* name, u32 entry_point, s32 priority, u32 arg, s32 processor_id,
48 u32 stack_top, int stack_size=Kernel::DEFAULT_STACK_SIZE);
49
50/// Sets up the primary application thread
51Handle SetupMainThread(s32 priority, int stack_size=Kernel::DEFAULT_STACK_SIZE);
52
53/// Reschedules to the next available thread (call after current thread is suspended)
54void Reschedule();
55
56/// Puts the current thread in the wait state for the given type
57void WaitCurrentThread(WaitType wait_type);
58
59/// Resumes a thread from waiting by marking it as "ready"
60void ResumeThreadFromWait(Handle handle);
61
62/// Gets the current thread handle
63Handle GetCurrentThreadHandle();
64
65/// Put current thread in a wait state - on WaitSynchronization
66void WaitThread_Synchronization();
67
68/// Initialize threading
69void ThreadingInit();
70
71/// Shutdown threading
72void ThreadingShutdown();
73
74} // namespace