diff options
Diffstat (limited to 'include/kernel/kernel')
-rw-r--r-- | include/kernel/kernel/cpu.h | 1 | ||||
-rw-r--r-- | include/kernel/kernel/iofilemgr.h | 471 | ||||
-rw-r--r-- | include/kernel/kernel/iofilemgr/async.h | 93 | ||||
-rw-r--r-- | include/kernel/kernel/iofilemgr/dirent.h | 82 | ||||
-rw-r--r-- | include/kernel/kernel/iofilemgr/stat.h | 101 | ||||
-rw-r--r-- | include/kernel/kernel/processmgr.h | 3 | ||||
-rw-r--r-- | include/kernel/kernel/sysmem.h | 10 | ||||
-rw-r--r-- | include/kernel/kernel/threadmgr.h | 93 |
8 files changed, 833 insertions, 21 deletions
diff --git a/include/kernel/kernel/cpu.h b/include/kernel/kernel/cpu.h index d0b5d5f..ec2f14e 100644 --- a/include/kernel/kernel/cpu.h +++ b/include/kernel/kernel/cpu.h @@ -1,6 +1,7 @@ #ifndef _PSP2_KERNEL_CPU_H_ #define _PSP2_KERNEL_CPU_H_ +#include <psp2common/kernel/cpu.h> #include <psp2kern/types.h> #ifdef __cplusplus diff --git a/include/kernel/kernel/iofilemgr.h b/include/kernel/kernel/iofilemgr.h new file mode 100644 index 0000000..9c79314 --- /dev/null +++ b/include/kernel/kernel/iofilemgr.h @@ -0,0 +1,471 @@ +#ifndef _DOLCESDK_PSP2KERN_KERNEL_IOFILEMGR_H_ +#define _DOLCESDK_PSP2KERN_KERNEL_IOFILEMGR_H_ + +#include <psp2common/kernel/iofilemgr.h> +#include <psp2kern/kernel/iofilemgr/async.h> +#include <psp2kern/kernel/iofilemgr/stat.h> +#include <psp2kern/kernel/iofilemgr/dirent.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Remove directory entry + * + * @param filename - Path to the file to remove + * @return < 0 on error + */ +int sceIoRemove(const char *filename); + +/** + * Make a directory file + * + * @param dirname - The path to the directory + * @param mode - Access mode bits. + * @return Returns the value 0 if it's successful, otherwise <0 + */ +int sceIoMkdir(const char *dirname, SceIoMode mode); + +/** + * Remove a directory file + * + * @param dirname - Removes a directory file pointed by the string path + * @return Returns the value 0 if it's successful, otherwise <0 + */ +int sceIoRmdir(const char *dirname); + +/** + * Change the name of a file + * + * @param oldname - The old filename + * @param newname - The new filename + * @return < 0 on error. + */ +int sceIoRename(const char *oldname, const char *newname); + +/** + * Send a devctl command to a device. + * + * @par Example: Sending a simple command to a device + * @code + * SceIoDevInfo info; + * sceIoDevctl("ux0:", 0x3001, NULL, 0, &info, sizeof(SceIoDevInfo)); + * @endcode + * + * @param devname - String for the device to send the devctl to (e.g. "ux0:") + * @param cmd - The command to send to the device + * @param arg - A data block to send to the device, if NULL sends no data + * @param arglen - Length of indata, if 0 sends no data + * @param bufp - A data block to receive the result of a command, if NULL receives no data + * @param buflen - Length of outdata, if 0 receives no data + * @return 0 on success, < 0 on error + */ +int sceIoDevctl( + const char *devname, + int cmd, + const void *arg, + SceSize arglen, + void *bufp, + SceSize buflen); + +/** + * Synchronize the file data on the device. + * + * @param devname - The device to synchronize (e.g. msfat0:) + * @param flag - device specific flags + */ +int sceIoSync(const char *devname, int flag); + +/** + * Open or create a file for reading or writing + * + * @par Example1: Open a file for reading + * @code + * if((fd = sceIoOpen("device:/path/to/file", SCE_O_RDONLY, 0777) < 0) { + * // error code in fd, for example no open filehandle left (0x80010018) + * } + * @endcode + * @par Example2: Open a file for writing, creating it if it doesn't exist + * @code + * if((fd = sceIoOpen("device:/path/to/file", SCE_O_WRONLY|SCE_O_CREAT, 0777) < 0) { + * // error code in fd, for example no open filehandle left (0x80010018) + * } + * @endcode + * + * @param filename - Pointer to a string holding the name of the file to open + * @param flag - Libc styled flags that are or'ed together + * @param mode - File access mode (One or more ::SceIoMode). + * @return A non-negative integer is a valid fd, anything else an error + */ +SceUID sceIoOpen(const char *filename, int flag, SceIoMode mode); + +/** + * Delete a descriptor + * + * @code + * sceIoClose(fd); + * @endcode + * + * @param fd - File descriptor to close + * @return < 0 on error + */ +int sceIoClose(SceUID fd); + +/** + * Perform an ioctl on a device. + * + * @param fd - Opened file descriptor to ioctl to + * @param cmd - The command to send to the device + * @param argp - A data block to send to the device, if NULL sends no data + * @param arglen - Length of indata, if 0 sends no data + * @param bufp - A data block to receive the result of a command, if NULL receives no data + * @param buflen - Length of outdata, if 0 receives no data + * @return 0 on success, < 0 on error + */ +int sceIoIoctl( + SceUID fd, + int cmd, + const void *argp, + SceSize arglen, + void *bufp, + SceSize buflen); + +/** + * Reposition read/write file descriptor offset + * + * @par Example: + * @code + * pos = sceIoLseek(fd, -10, SCE_SEEK_END); + * @endcode + * + * @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. + * + * @return The position in the file after the seek. + */ +SceOff sceIoLseek(SceUID fd, SceOff offset, int whence); + +/** + * Read input + * + * @par Example: + * @code + * bytes_read = sceIoRead(fd, data, 100); + * @endcode + * + * @param fd - Opened file descriptor to read from + * @param buf - Pointer to the buffer where the read data will be placed + * @param nbyte - Size of the read in bytes + * + * @return The number of bytes read + */ +SceSSize sceIoRead(SceUID fd, void *buf, SceSize nbyte); + +/** + * Write output + * + * @par Example: + * @code + * bytes_written = sceIoWrite(fd, data, 100); + * @endcode + * + * @param fd - Opened file descriptor to write to + * @param buf - Pointer to the data to write + * @param nbyte - Size of data to write + * + * @return The number of bytes written + */ +SceSSize sceIoWrite(SceUID fd, const void *buf, SceSize nbyte); + +/** + * Read input at offset + * + * @par Example: + * @code + * bytes_read = sceIoPread(fd, data, 100, 0x1000); + * @endcode + * + * @param fd - Opened file descriptor to read from + * @param buf - Pointer to the buffer where the read data will be placed + * @param nbyte - Size of the read in bytes + * @param offset - Offset to read + * + * @return < 0 on error. + */ +SceSSize sceIoPread(SceUID fd, void *buf, SceSize nbyte, SceOff offset); + +/** + * Write output at offset + * + * @par Example: + * @code + * bytes_written = sceIoPwrite(fd, data, 100, 0x1000); + * @endcode + * + * @param fd - Opened file descriptor to write to + * @param buf - Pointer to the data to write + * @param nbyte - Size of data to write + * @param offset - Offset to write + * + * @return The number of bytes written + */ +SceSSize sceIoPwrite(SceUID fd, const void *buf, SceSize nbyte, SceOff offset); + +/** + * Synchronize the file data for one file + * + * @param fd - Opened file descriptor to sync + * @param flag - device specific flags + * + * @return < 0 on error. + */ +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) + */ +int sceIoIoctlAsync( + SceUID fd, + int cmd, + const void *argp, + SceSize arglen, + void *bufp, + SceSize buflen, + SceIoAsyncParam* asyncParam); + +/** + * This function is unimplemented. + * + * @return SCE_KERNEL_ERROR_UNSUP (0x80020004) + */ +int sceIoDevctlAsync( + const char *devname, + int cmd, + const void *arg, + SceSize arglen, + void *bufp, + 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--------------------*/ + +/** + * Mounts a device + * + * @param[in] id Device to mount + * @param[in] path Where to mount to + * @param[in] permission Permission flags + * @param a4 Unknown, set to 0 + * @param a5 Unknown, set to 0 + * @param a6 Unknown, set to 0 + * + * @return < 0 on error. + */ +int sceIoMount(int id, const char *path, int permission, int a4, int a5, int a6); + +/** + * Unmounts a device + * + * @param[in] id Device to unmount + * @param[in] a2 Unknown, set to 0 + * @param[in] a3 Unknown, set to 0 + * @param[in] a4 Unknown, set to 0 + * + * @return < 0 on error. + */ +int sceIoUmount(int id, int a2, int a3, int a4); + +#ifdef __cplusplus +} +#endif + +#endif /* _DOLCESDK_PSP2KERN_KERNEL_IOFILEMGR_H_ */ diff --git a/include/kernel/kernel/iofilemgr/async.h b/include/kernel/kernel/iofilemgr/async.h new file mode 100644 index 0000000..4584bb7 --- /dev/null +++ b/include/kernel/kernel/iofilemgr/async.h @@ -0,0 +1,93 @@ +#ifndef _DOLCESDK_PSP2KERN_KERNEL_IOFILEMGR_ASYNC_H_ +#define _DOLCESDK_PSP2KERN_KERNEL_IOFILEMGR_ASYNC_H_ + +#include <psp2common/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 new file mode 100644 index 0000000..4bfc584 --- /dev/null +++ b/include/kernel/kernel/iofilemgr/dirent.h @@ -0,0 +1,82 @@ +#ifndef _DOLCESDK_PSP2KERN_KERNEL_IOFILEMGR_DIRENT_H_ +#define _DOLCESDK_PSP2KERN_KERNEL_IOFILEMGR_DIRENT_H_ + +#include <psp2common/kernel/iofilemgr/dirent.h> +#include <psp2kern/kernel/iofilemgr/async.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Open a directory + * + * @par Example: + * @code + * int dfd; + * dfd = sceIoDopen("device:/"); + * if(dfd >= 0) + * { Do something with the file descriptor } + * @endcode + * @param dirname - The directory to open for reading. + * @return If >= 0 then a valid file descriptor, otherwise a Sony error code. + */ +SceUID sceIoDopen(const char *dirname); + +/** + * Close an opened directory file descriptor + * + * @param fd - Already opened file descriptor (using ::sceIoDopen) + * @return < 0 on error + */ +int sceIoDclose(SceUID fd); + +/** + * Reads an entry from an opened file descriptor. + * + * @param fd - Already opened file descriptor (using ::sceIoDopen) + * @param buf - Pointer to a ::SceIoDirent structure to hold the file information + * + * @return Read status + * - 0 - No more directory entries left + * - > 0 - More directory entries to go + * - < 0 - Error + */ +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 + +#endif /* _DOLCESDK_PSP2KERN_KERNEL_IOFILEMGR_DIRENT_H_ */ diff --git a/include/kernel/kernel/iofilemgr/stat.h b/include/kernel/kernel/iofilemgr/stat.h new file mode 100644 index 0000000..c9096e2 --- /dev/null +++ b/include/kernel/kernel/iofilemgr/stat.h @@ -0,0 +1,101 @@ +#ifndef _DOLCESDK_PSP2KERN_KERNEL_IOFILEMGR_STAT_H_ +#define _DOLCESDK_PSP2KERN_KERNEL_IOFILEMGR_STAT_H_ + +#include <psp2common/kernel/iofilemgr/stat.h> +#include <psp2kern/kernel/iofilemgr/async.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Change the status of a file. + * + * @param name - The path to the file. + * @param buf - A pointer to a ::SceIoStat structure. + * @param cbit - Bitmask defining which bits to change. + * + * @return < 0 on error. + */ +int sceIoChstat(const char *name, const SceIoStat *buf, unsigned int cbit); + +/** + * Get the status of a file. + * + * @param name - The path to the file. + * @param buf - A pointer to a ::SceIoStat structure. + * + * @return < 0 on error. + */ +int sceIoGetstat(const char *name, SceIoStat *buf); + +/** + * Get the status of a file descriptor. + * + * @param fd - The file descriptor. + * @param buf - A pointer to a ::SceIoStat structure. + * + * @return < 0 on error. + */ +int sceIoGetstatByFd(SceUID fd, SceIoStat *buf); + +/** + * Change the status of a file descriptor. + * + * @param fd - The file descriptor. + * @param buf - A pointer to an io_stat_t structure. + * @param cbit - Bitmask defining which bits to change. + * + * @return < 0 on error. + */ +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 + +#endif /* _DOLCESDK_PSP2KERN_KERNEL_IOFILEMGR_STAT_H_ */ diff --git a/include/kernel/kernel/processmgr.h b/include/kernel/kernel/processmgr.h index 6438113..b176644 100644 --- a/include/kernel/kernel/processmgr.h +++ b/include/kernel/kernel/processmgr.h @@ -7,6 +7,9 @@ extern "C" { #endif +/** UID of the kernel process */ +#define SCE_KERNEL_PROCESS_ID_KERNEL 0x10005 + typedef struct SceKernelProcessInfo { SceSize size; //!< size of this struct, make sure it's 0xE8 SceUID pid; //!< our process ID diff --git a/include/kernel/kernel/sysmem.h b/include/kernel/kernel/sysmem.h index b2fc17f..c39fe43 100644 --- a/include/kernel/kernel/sysmem.h +++ b/include/kernel/kernel/sysmem.h @@ -1,14 +1,14 @@ #ifndef _PSP2_KERNEL_SYSMEM_H_ #define _PSP2_KERNEL_SYSMEM_H_ -#include <psp2kern/types.h> #include <stdarg.h> +#include <psp2kern/kernel/types.h> #ifdef __cplusplus extern "C" { #endif -typedef enum SceKernelMemBlockType { +typedef enum _SceKernelMemBlockType { SCE_KERNEL_MEMBLOCK_TYPE_SHARED_RX = 0x0390D050, SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW = 0x09408060, SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE = 0x0C208060, @@ -19,7 +19,7 @@ typedef enum SceKernelMemBlockType { SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_RX = 0x1020D005, SCE_KERNEL_MEMBLOCK_TYPE_KERNEL_RW = 0x1020D006, SCE_KERNEL_MEMBLOCK_TYPE_RW_UNK0 = 0x6020D006 -} SceKernelMemBlockType; +} _SceKernelMemBlockType; typedef enum SceKernelAllocMemBlockAttr { SCE_KERNEL_ALLOC_MEMBLOCK_ATTR_HAS_PADDR = 0x00000002U, @@ -440,7 +440,9 @@ typedef struct SceKernelDebugMessageContext { // msg_type_flag : 0 or 0xB int sceDebugPrintf2(int msg_type_flag, const SceKernelDebugMessageContext *ctx, const char *fmt, ...); - + +int sceDebugVprintf(const char *fmt, va_list args); + int sceDebugPrintKernelPanic(const SceKernelDebugMessageContext *ctx, void *some_address); int sceDebugPrintfKernelPanic(const SceKernelDebugMessageContext *ctx, void *some_address, const char *fmt, ...); diff --git a/include/kernel/kernel/threadmgr.h b/include/kernel/kernel/threadmgr.h index 3836f70..445c806 100644 --- a/include/kernel/kernel/threadmgr.h +++ b/include/kernel/kernel/threadmgr.h @@ -1,21 +1,14 @@ #ifndef _PSP2_KERNEL_THREADMGR_H_ #define _PSP2_KERNEL_THREADMGR_H_ -#include <psp2kern/types.h> +#include <psp2common/kernel/threadmgr.h> #ifdef __cplusplus extern "C" { #endif -#define SCE_KERNEL_MUTEX_ATTR_RECURSIVE 2 - -/** 64-bit system clock type. */ -typedef SceUInt64 SceKernelSysClock; - /* Threads. */ -typedef int (* SceKernelThreadEntry)(SceSize args, void *argp); - /** Additional options used when creating threads. */ typedef struct SceKernelThreadOptParam { /** Size of the ::SceKernelThreadOptParam structure. */ @@ -449,18 +442,61 @@ int sceKernelCancelMutex(SceUID mutexid, int newCount, int *numWaitThreads); */ int sceKernelGetMutexInfo(SceUID mutexid, SceKernelMutexInfo *info); -typedef struct SceKernelLwMutexWork { - SceInt64 data[4]; -} SceKernelLwMutexWork; +/* Fast mutex */ -typedef struct SceKernelLwMutexOptParam { +typedef struct SceKernelFastMutexWork { + SceInt64 data[8]; +} SceKernelFastMutexWork; + +typedef enum SceKernelFastMutexAttr { + SCE_KERNEL_FAST_MUTEX_ATTR_RECURSIVE = 0x00000002, + SCE_KERNEL_FAST_MUTEX_ATTR_CEILING = 0x00000004, + SCE_KERNEL_FAST_MUTEX_ATTR_UNK_3 = 0x00000008, + SCE_KERNEL_FAST_MUTEX_ATTR_TH_FIFO = 0x00000000, + SCE_KERNEL_FAST_MUTEX_ATTR_TH_PRIO = 0x00002000, + SCE_KERNEL_FAST_MUTEX_ATTR_UNK_15 = 0x00008000, + // All other flags are invalid +} SceKernelFastMutexAttr; + +typedef struct SceKernelFastMutexOptParam { SceSize size; -} SceKernelLwMutexOptParam; + SceInt32 ceilingPriority; +} SceKernelFastMutexOptParam; + +SceInt32 sceKernelInitializeFastMutex( + SceKernelFastMutexWork *pWork, + const char *pName, + SceKernelFastMutexAttr attr, + const SceKernelFastMutexOptParam *pOptParam); -int sceKernelInitializeFastMutex(void *mutex, const char *name, int unk0, int unk1); -int sceKernelLockFastMutex(void *mutex); -int sceKernelUnlockFastMutex(void *mutex); -int sceKernelDeleteFastMutex(void *mutex); +SceInt32 sceKernelLockFastMutex(SceKernelFastMutexWork *pWork); + +SceInt32 sceKernelTryLockFastMutex(SceKernelFastMutexWork *pWork); + +SceInt32 sceKernelUnlockFastMutex(SceKernelFastMutexWork *pWork); + +SceInt32 sceKernelFinalizeFastMutex(SceKernelFastMutexWork *pWork); + +typedef struct SceKernelFastMutexInfo { +// 0x00 + SceSize size; + SceUID uid; + char name[SCE_UID_NAMELEN + 1]; + SceKernelFastMutexAttr attr; + SceKernelFastMutexWork *pWork; +// 0x30 + SceInt32 currentCount; + SceUID currentOwnerId; + SceInt32 ceilingPriority; + SceInt32 unk3C; +// 0x40 + SceUInt32 numWaitThreads; +// 0x44 +} SceKernelFastMutexInfo; + +SceInt32 sceKernelGetFastMutexInfo(SceKernelFastMutexWork *pWork, SceKernelFastMutexInfo *pInfo); + +SceInt32 sceKernelGetFastMutexInfoById(SceUID uid, SceKernelFastMutexInfo *pInfo); /* Event flags. */ @@ -1033,6 +1069,29 @@ int sceKernelTryReceiveMsgPipeVector(SceUID uid, const MsgPipeRecvData *v, SceSi */ int sceKernelCancelMsgPipe(SceUID uid, int *psend, int *precv); +SceInt32 sceKernelWaitEvent( + SceUID eventId, + SceUInt32 waitPattern, + SceUInt32 *pResultPattern, + SceUInt64 *pUserData, + SceUInt32 *pTimeout +); + +SceInt32 sceKernelWaitEventCB( + SceUID eventId, + SceUInt32 waitPattern, + SceUInt32 *pResultPattern, + SceUInt64 *pUserData, + SceUInt32 *pTimeout +); + +SceInt32 sceKernelPollEvent( + SceUID eventId, + SceUInt32 bitPattern, + SceUInt32 *pResultPattern, + SceUInt64 *pUserData +); + #ifdef __cplusplus } #endif |