diff options
author | Reiko Asakura | 2020-07-23 17:04:45 -0400 |
---|---|---|
committer | Reiko Asakura | 2020-07-23 17:04:45 -0400 |
commit | fd07dafa4df78d9bdc8fedbb3a462ac2b69ee3a0 (patch) | |
tree | 55ea58685f6bbb61cce63fb36ff8ef398aae9543 | |
parent | Add thread event functions for kernel (diff) | |
download | vds-libraries-fd07dafa4df78d9bdc8fedbb3a462ac2b69ee3a0.tar.gz |
Add async IO functions for kernel
Diffstat (limited to '')
-rw-r--r-- | include/kernel/kernel/iofilemgr.h | 184 | ||||
-rw-r--r-- | include/kernel/kernel/iofilemgr/async.h | 92 | ||||
-rw-r--r-- | include/kernel/kernel/iofilemgr/dirent.h | 32 | ||||
-rw-r--r-- | include/kernel/kernel/iofilemgr/stat.h | 45 | ||||
-rw-r--r-- | nids/360/SceIofilemgr.yml | 5 |
5 files changed, 358 insertions, 0 deletions
diff --git a/include/kernel/kernel/iofilemgr.h b/include/kernel/kernel/iofilemgr.h index bb3dbac..dce367e 100644 --- a/include/kernel/kernel/iofilemgr.h +++ b/include/kernel/kernel/iofilemgr.h @@ -2,6 +2,7 @@ #define _DOLCESDK_PSP2KERN_KERNEL_IOFILEMGR_H_ #include <psp2kern/kernel/types.h> +#include <psp2kern/kernel/iofilemgr/async.h> #include <psp2kern/kernel/iofilemgr/stat.h> #include <psp2kern/kernel/iofilemgr/dirent.h> @@ -266,6 +267,133 @@ 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); + +/** * This function is unimplemented. * * @return SCE_KERNEL_ERROR_UNSUP (0x80020004) @@ -293,6 +421,62 @@ int sceIoDevctlAsync( SceSize buflen, SceIoAsyncParam* asyncParam); +/*--------------------IO Priority--------------------*/ + +/*Valid priority values range: 1 (highest) - 15 (lowest). Default priority value is 14*/ + +/** + * 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 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 sceIoSetProcessDefaultPriorityForSystem(int priority); + +/** + * Get IO operations priority for process + * + * @return A non-negative integer is a valid priority, anything else an error + */ +int sceIoGetProcessDefaultPriorityForSystem(void); + +/** + * 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 for non-game application + * + * @return A non-negative integer is a valid priority, anything else an error + */ +int sceIoGetThreadDefaultPriorityForSystem(void); + /*--------------------Device mount functions--------------------*/ /** diff --git a/include/kernel/kernel/iofilemgr/async.h b/include/kernel/kernel/iofilemgr/async.h new file mode 100644 index 0000000..828d83d --- /dev/null +++ b/include/kernel/kernel/iofilemgr/async.h @@ -0,0 +1,92 @@ +#ifndef _DOLCESDK_PSP2KERN_KERNEL_IOFILEMGR_ASYNC_H_ +#define _DOLCESDK_PSP2KERN_KERNEL_IOFILEMGR_ASYNC_H_ + +#include <psp2kern/kernel/threadmgr.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); + +/** + * 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_PSP2KERN_KERNEL_IOFILEMGR_ASYNC_H_ */ diff --git a/include/kernel/kernel/iofilemgr/dirent.h b/include/kernel/kernel/iofilemgr/dirent.h index bb9d796..8d9a843 100644 --- a/include/kernel/kernel/iofilemgr/dirent.h +++ b/include/kernel/kernel/iofilemgr/dirent.h @@ -1,6 +1,7 @@ #ifndef _DOLCESDK_PSP2KERN_KERNEL_IOFILEMGR_DIRENT_H_ #define _DOLCESDK_PSP2KERN_KERNEL_IOFILEMGR_DIRENT_H_ +#include <psp2kern/kernel/iofilemgr/async.h> #include <psp2kern/kernel/iofilemgr/stat.h> #ifdef __cplusplus @@ -51,6 +52,37 @@ int sceIoDclose(SceUID fd); */ int sceIoDread(SceUID fd, SceIoDirent *buf); +/** + * Open a directory (asynchronous) + * + * @param dirname - The directory to open for reading. + * @param asyncParam - parameters related to async operation. + * + * @return If >= 0 then a valid op handle, otherwise a Sony error code. + */ +SceUID sceIoDopenAsync(const char *dirname, SceIoAsyncParam* asyncParam); + +/** + * Reads an entry from an opened file descriptor (asynchronous) + * + * @param fd - Already opened file descriptor (using ::sceIoDopen or ::sceIoDopenAsync) + * @param dir - Pointer to a ::SceIoDirent structure to hold the file information + * @param asyncParam - parameters related to async operation. + * + * @return If >= 0 then a valid op handle, otherwise a Sony error code. + */ +SceUID sceIoDreadAsync(SceUID fd, SceIoDirent *dir, SceIoAsyncParam* asyncParam); + +/** + * Close an opened directory file descriptor (asynchronous) + * + * @param fd - Already opened file descriptor (using ::sceIoDopen or ::sceIoDopenAsync) + * @param asyncParam - parameters related to async operation. + * + * @return If >= 0 then a valid op handle, otherwise a Sony error code. + */ +SceUID sceIoDcloseAsync(SceUID fd, SceIoAsyncParam* asyncParam); + #ifdef __cplusplus } #endif diff --git a/include/kernel/kernel/iofilemgr/stat.h b/include/kernel/kernel/iofilemgr/stat.h index 29a27ef..9c5369f 100644 --- a/include/kernel/kernel/iofilemgr/stat.h +++ b/include/kernel/kernel/iofilemgr/stat.h @@ -2,6 +2,7 @@ #define _DOLCESDK_PSP2KERN_KERNEL_IOFILEMGR_STAT_H_ #include <psp2kern/kernel/types.h> +#include <psp2kern/kernel/iofilemgr/async.h> #ifdef __cplusplus extern "C" { @@ -81,6 +82,50 @@ int sceIoGetstatByFd(SceUID fd, SceIoStat *buf); */ int sceIoChstatByFd(SceUID fd, const SceIoStat *buf, unsigned int cbit); +/** + * Make a directory file (asynchronous) + * + * @param dir - The path to the directory + * @param mode - Access mode (One or more ::SceIoAccessMode). + * @param asyncParam - parameters related to async operation. + * + * @return A non-negative integer is a valid op handle, anything else an error + */ +SceUID sceIoMkdirAsync(const char *dir, SceMode mode, SceIoAsyncParam* asyncParam); + +/** + * Remove a directory file (asynchronous) + * + * @param path - Removes a directory file pointed by the string path + * @param asyncParam - parameters related to async operation. + * + * @return A non-negative integer is a valid op handle, anything else an error + */ +SceUID sceIoRmdirAsync(const char *path, SceIoAsyncParam* asyncParam); + +/** + * Get the status of a file (asynchronous) + * + * @param file - The path to the file. + * @param stat - A pointer to a ::SceIoStat structure. + * @param asyncParam - parameters related to async operation. + * + * @return A non-negative integer is a valid op handle, anything else an error + */ +SceUID sceIoGetstatAsync(const char *file, SceIoStat *stat, SceIoAsyncParam* asyncParam); + +/** + * Change the status of a file (asynchronous) + * + * @param file - The path to the file. + * @param stat - A pointer to a ::SceIoStat structure. + * @param bits - Bitmask defining which bits to change. + * @param asyncParam - parameters related to async operation. + * + * @return A non-negative integer is a valid op handle, anything else an error + */ +SceUID sceIoChstatAsync(const char *file, SceIoStat *stat, int bits, SceIoAsyncParam* asyncParam); + #ifdef __cplusplus } #endif diff --git a/nids/360/SceIofilemgr.yml b/nids/360/SceIofilemgr.yml index 590706e..e1364a4 100644 --- a/nids/360/SceIofilemgr.yml +++ b/nids/360/SceIofilemgr.yml @@ -76,6 +76,7 @@ modules: sceIoClearErrorEvent: 0x40B933C7 sceIoClose: 0xF99DD8A3 sceIoCloseAsync: 0x11C57CC6 + sceIoComplete: 0x8F0DE34D sceIoCreateErrorEvent: 0x3C0343DB sceIoCreateMountEvent: 0x2DFA192F sceIoDclose: 0x19C81DD6 @@ -91,7 +92,9 @@ modules: sceIoDreadAsync: 0x5982B0E3 sceIoFlock: 0x16336A0D sceIoGetMediaType: 0x9C220246 + sceIoGetPriorityForSystem: 0x9FCDCE62 sceIoGetProcessDefaultPriorityForSystem: 0xCE397158 + sceIoGetThreadDefaultPriorityForSystem: 0x6D0FEDB6 sceIoGetstat: 0x75C96D25 sceIoGetstat2: 0xD6503624 sceIoGetstatAsync: 0x94A5304A @@ -120,7 +123,9 @@ modules: sceIoRmdir: 0x1CC9C634 sceIoRmdirAsync: 0xF5B0B36C sceIoSetPathMappingFunction: 0xCFAECF18 + sceIoSetPriorityForSystem: 0xCCE94599 sceIoSetProcessDefaultPriorityForSystem: 0xABE65071 + sceIoSetThreadDefaultPriorityForSystem: 0x3F0FF9D5 sceIoSync: 0xDDF78594 sceIoSyncAsync: 0x4F9EA8B0 sceIoSyncByFd: 0x338DCD68 |