summaryrefslogtreecommitdiff
path: root/include/user/kernel/iofilemgr_async.h
blob: 21190eee47478e8714439d8be6c86f78da9abb23 (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#ifndef _DOLCESDK_PSP2_KERNEL_IOFILEMGR_ASYNC_H_
#define _DOLCESDK_PSP2_KERNEL_IOFILEMGR_ASYNC_H_

#include_next <kernel/iofilemgr_async.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
 * Async IO operations are scheduled automatically, similar to FIOS2.
 * You can make calls to sceIoOpenAsync(), sceIoReadAsync(),
 * sceIoCloseAsync() right after each other, they will be put in a schedule
 * and performed automatically.
 *
 * All async IO functions return UID of operation handle, not file descriptor UID.
 */

/**
  * Cancel an asynchronous operation.
  *
  * @param opHandle - The operation handle to perform cancel on.
  *
  * @return < 0 on error. If operation has been canceled(finished) already, returns 0x80010002
  */
int sceIoCancel(SceUID opHandle);

/**
  * Complete an asynchronous operation.
  *
  * @param opHandle - The operation handle to complete.
  *
  * @return < 0 on error.
  */
int sceIoComplete(SceUID opHandle);

/**
  * Complete multiple asynchronous operations.
  *
  * @param asyncParam - Array of ::SceIoAsyncParam representing IO operations to complete. retVal member must have opHandle value assigned to it.
  * @param numOfParam - Number of ::SceIoAsyncParam structs in asyncParam array
  * @param numOfCompleted - Number of operations that has been completed successfully
  *
  * @return < 0 on last encountered error.
  */
int sceIoCompleteMultiple(SceIoAsyncParam* asyncParam, int numOfParam, int* numOfCompleted);

/**
  * Wait until asynchronous operation has been finished.
  *
  * @param opHandle - The operation handle to wait for.
  *
  * @return < 0 on error.
  */
inline
int sceIoWaitAsync(SceUID opHandle)
{
	int ret = sceKernelWaitEvent(opHandle, 1, NULL, NULL, NULL);
	if (ret == 0)
		return sceIoComplete(opHandle);
	else
		return ret;
}

/**
  * Wait until asynchronous operation has been finished with callbacks.
  *
  * @param opHandle - The operation handle to wait for.
  *
  * @return < 0 on error.
  */
inline
int sceIoWaitAsyncCB(SceUID opHandle)
{
	int ret = sceKernelWaitEventCB(opHandle, 1, NULL, NULL, NULL);
	if (ret == 0)
		return sceIoComplete(opHandle);
	else
		return ret;
}

/**
  * Poll asynchronous operation status.
  *
  * @param opHandle - The operation handle to poll status for.
  *
  * @return < 0 on error or if operation is not finished.
  */
inline
int sceIoPollAsync(SceUID opHandle)
{
	int ret = sceKernelPollEvent(opHandle, 1, NULL, NULL);
	if (ret == 0)
		return sceIoComplete(opHandle);
	else
		return ret;
}

#ifdef __cplusplus
}
#endif

#endif	/* _DOLCESDK_PSP2_KERNEL_IOFILEMGR_ASYNC_H_ */