diff options
author | GrapheneCt | 2020-07-21 17:39:17 -0400 |
---|---|---|
committer | Reiko Asakura | 2020-07-21 17:39:17 -0400 |
commit | cd9c1ead26ec0c0ab590cc570862e6d5d99195ed (patch) | |
tree | 6861968973333f8c2bfdc6c2278b92b4566fc4ed /include/user/kernel/iofilemgr.h | |
parent | Refactor userland SceIofilemgr headers (diff) | |
download | vds-libraries-cd9c1ead26ec0c0ab590cc570862e6d5d99195ed.tar.gz |
Add async IO functions for userland
All credits go to https://github.com/GrapheneCt/
Diffstat (limited to 'include/user/kernel/iofilemgr.h')
-rw-r--r-- | include/user/kernel/iofilemgr.h | 221 |
1 files changed, 221 insertions, 0 deletions
diff --git a/include/user/kernel/iofilemgr.h b/include/user/kernel/iofilemgr.h index 33f79d0..87ad029 100644 --- a/include/user/kernel/iofilemgr.h +++ b/include/user/kernel/iofilemgr.h @@ -2,6 +2,7 @@ #define _DOLCESDK_PSP2_KERNEL_IOFILEMGR_H_ #include <psp2/kernel/types.h> +#include <psp2/kernel/iofilemgr/async.h> #include <psp2/kernel/iofilemgr/stat.h> #include <psp2/kernel/iofilemgr/dirent.h> @@ -288,6 +289,226 @@ SceSSize sceIoPwrite(SceUID fd, const void *buf, SceSize nbyte, SceOff offset); */ int sceIoSyncByFd(SceUID fd, int flag); +/*--------------------Async IO--------------------*/ + +/** + * Remove directory entry (asynchronous) + * + * @param file - Path to the file to remove + * @param asyncParam - parameters related to async operation. + * + * @return A non-negative integer is a valid op handle, anything else an error + */ +int sceIoRemoveAsync(const char *file, SceIoAsyncParam* asyncParam); + +/** + * Change the name of a file (asynchronous) + * + * @param oldname - The old filename + * @param newname - The new filename + * @param asyncParam - parameters related to async operation. + * + * @return A non-negative integer is a valid op handle, anything else an error + */ +SceUID sceIoRenameAsync(const char *oldname, const char *newname, SceIoAsyncParam* asyncParam); + +/** + * Open or create a file for reading or writing (asynchronous) + * + * @param file - Pointer to a string holding the name of the file to open + * @param flags - Libc styled flags that are or'ed together + * @param mode - File access mode (One or more ::SceIoMode). + * @param asyncParam - parameters related to async operation. + * + * @return A non-negative integer is a valid op handle, anything else an error + */ +SceUID sceIoOpenAsync(const char *file, int flags, SceMode mode, SceIoAsyncParam* asyncParam); + +/** + * Delete a descriptor (asynchronous) + * + * @param fd - File descriptor to close + * @param asyncParam - parameters related to async operation. + * + * @return A non-negative integer is a valid op handle, anything else an error + */ +SceUID sceIoCloseAsync(SceUID fd, SceIoAsyncParam* asyncParam); + +/** + * Read input (asynchronous) + * + * @param fd - Opened file descriptor to read from + * @param data - Pointer to the buffer where the read data will be placed + * @param size - Size of the read in bytes + * @param asyncParam - parameters related to async operation. + * + * @return A non-negative integer is a valid op handle, anything else an error + */ +SceUID sceIoReadAsync(SceUID fd, void *data, SceSize size, SceIoAsyncParam* asyncParam); + +/** + * Read input at offset (asynchronous) + * + * @param fd - Opened file descriptor to read from + * @param data - Pointer to the buffer where the read data will be placed + * @param size - Size of the read in bytes + * @param offset - Offset to read + * @param asyncParam - parameters related to async operation. + * + * @return A non-negative integer is a valid op handle, anything else an error + */ +SceUID sceIoPreadAsync(SceUID fd, void *data, SceSize size, SceOff offset, SceIoAsyncParam* asyncParam); + +/** + * Write output (asynchronous) + * + * @param fd - Opened file descriptor to write to + * @param data - Pointer to the data to write + * @param size - Size of data to write + * @param asyncParam - parameters related to async operation. + * + * @return A non-negative integer is a valid op handle, anything else an error + */ +SceUID sceIoWriteAsync(SceUID fd, const void *data, SceSize size, SceIoAsyncParam* asyncParam); + +/** + * Write output at offset (asynchronous) + * + * @param fd - Opened file descriptor to write to + * @param data - Pointer to the data to write + * @param size - Size of data to write + * @param offset - Offset to write + * @param asyncParam - parameters related to async operation. + * + * @return A non-negative integer is a valid op handle, anything else an error + */ +SceUID sceIoPwriteAsync(SceUID fd, const void *data, SceSize size, SceOff offset, SceIoAsyncParam* asyncParam); + +/** + * Reposition read/write file descriptor offset (asynchronous) + * + * @param fd - Opened file descriptor with which to seek + * @param offset - Relative offset from the start position given by whence + * @param whence - One of ::SceIoSeekMode. + * @param asyncParam - parameters related to async operation. + * + * @return A non-negative integer is a valid op handle, anything else an error + */ +SceUID sceIoLseekAsync(SceUID fd, SceOff offset, int whence, SceIoAsyncParam* asyncParam); + +/** + * Synchronize device state with state of file or directory being opened + * + * @param fd - Opened file descriptor to sync + * @param fd - Device-dependent flag + * @param asyncParam - parameters related to async operation. + * + * @return A non-negative integer is a valid op handle, anything else an error + */ +SceUID sceIoSyncByFdAsync(SceUID fd, int flag, SceIoAsyncParam* asyncParam); + +/** + * Synchronize device state with memory state + * + * @param fd - Device name + * @param fd - Device-dependent flag + * @param asyncParam - parameters related to async operation. + * + * @return A non-negative integer is a valid op handle, anything else an error + */ +SceUID sceIoSyncAsync(const char* device, int flag, SceIoAsyncParam* asyncParam); + +/*--------------------IO Priority--------------------*/ + +/*Valid priority values range: 1 (highest) - 15 (lowest). Default priority value is 14*/ + +/** + * Set IO operations priority for file descriptor + * + * @param fd - File UID + * @param priority - IO operations priority + * + * @return < 0 on error. + */ +int sceIoSetPriority(SceUID fd, int priority); + +/** + * Set IO operations priority for file descriptor for non-game application + * + * @param fd - File UID + * @param priority - IO operations priority + * + * @return < 0 on error. + */ +int sceIoSetPriorityForSystem(SceUID fd, int priority); + +/** + * Get IO operations priority for file descriptor + * + * @param fd - File UID + * + * @return A non-negative integer is a valid priority, anything else an error + */ +int sceIoGetPriority(SceUID fd); + +/** + * Get IO operations priority for file descriptor for non-game application + * + * @param fd - File UID + * + * @return A non-negative integer is a valid priority, anything else an error + */ +int sceIoGetPriorityForSystem(SceUID fd); + +/** + * Set IO operations priority for caller process (will be default for all new IO operations) + * + * @param priority - New default IO operations priority + * + * @return < 0 on error. + */ +int sceIoSetProcessDefaultPriority(int priority); + +/** + * Get IO operations priority for process + * + * @return A non-negative integer is a valid priority, anything else an error + */ +int sceIoGetProcessDefaultPriority(void); + +/** + * Set IO operations priority for caller thread (will be default for all new IO operations) + * + * @param priority - New default IO operations priority + * + * @return < 0 on error. + */ +int sceIoSetThreadDefaultPriority(int priority); + +/** + * Set IO operations priority for caller thread for non-game + * application (will be default for all new IO operations) + * + * @param priority - New default IO operations priority + * + * @return < 0 on error. + */ +int sceIoSetThreadDefaultPriorityForSystem(int priority); + +/** + * Get IO operations priority for thread + * + * @return A non-negative integer is a valid priority, anything else an error + */ +int sceIoGetThreadDefaultPriority(void); + +/** + * Get IO operations priority for thread for non-game application + * + * @return A non-negative integer is a valid priority, anything else an error + */ +int sceIoGetThreadDefaultPriorityForSystem(void); + #ifdef __cplusplus } #endif |