summaryrefslogtreecommitdiff
path: root/include/user/kernel/threadmgr.h
blob: 48a65fd3c1ae40c532c704a8f35267c60fe6ab38 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
	Vita Development Suite Libraries
*/

#ifndef _VDSUITE_USER_KERNEL_THREADMGR_H
#define _VDSUITE_USER_KERNEL_THREADMGR_H

#include_next <kernel/threadmgr.h>

SCE_CDECL_BEGIN

/* Threads. */

/* Sure there must be more than this, but haven't seen them */
typedef enum SceThreadStatus {
	SCE_THREAD_RUNNING = 1,
	SCE_THREAD_READY   = 2,
	SCE_THREAD_WAITING = 4,
	SCE_THREAD_SUSPEND = 8,
	SCE_THREAD_STOPPED = 16,
	SCE_THREAD_KILLED  = 32, /* Thread manager has killed the thread (stack overflow) */
} SceThreadStatus;

/**
 * Get the free stack size for a thread.
 *
 * @param threadId - The thread ID
 *
 * @return The free size.
 */
SceSize sceKernelGetThreadStackFreeSize(SceUID threadId);

/* Misc. */

typedef struct SceKernelWaitSignalOptParam {
	SceUInt32 unk;
} SceKernelWaitSignalOptParam;

/**
 * @brief Sleep current thread and wait for a signal. After it receives a signal, the thread wakes up.
 *
 * This is like a semphore with limit 1.
 * If signal was sent before and not consumed before, the function will immediately return.
 *
 * @param params - extra parameters
 * @return 0 on success
 */
int sceKernelWaitSignal(SceUInt32 unk0, SceUInt32 unk1, SceKernelWaitSignalOptParam *params);

/**
 * @brief Send a signal to another thread specified by thid.
 *
 * @param thid - the id of the thread to send a signal to
 * @return 0 on success
 * @return SCE_KERNEL_ERROR_ALREADY_SENT if the last signal was not consumed by sceKernelWaitSignal
 */
int sceKernelSendSignal(SceUID thid);

/*
 * Mono thread support functions
 */

typedef SceKernelThreadOptParamInternal SceKernelThreadOptParamForMono;

int sceKernelSuspendThreadForMono(SceUID threadId);

int sceKernelResumeThreadForMono(SceUID threadId);

int sceKernelGetThreadContextForMono(
	SceUID threadId,
	SceKernelThreadCpuRegisterInfo* pCpuRegisterInfo,
	SceKernelThreadVfpRegisterInfo* pVfpRegisterInfo);

int sceKernelSetThreadContextForMono(
	SceUID threadId,
	SceKernelThreadCpuRegisterInfo* pCpuRegisterInfo,
	SceKernelThreadVfpRegisterInfo* pVfpRegisterInfo);

SCE_CDECL_END

#endif /* _VDSUITE_USER_KERNEL_THREADMGR_H */