summaryrefslogtreecommitdiff
path: root/include/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'include/kernel')
-rw-r--r--include/kernel/appmgr.h52
-rw-r--r--include/kernel/audioout.h21
-rw-r--r--include/kernel/display.h25
-rw-r--r--include/kernel/idstorage.h30
-rw-r--r--include/kernel/kernel/cpu.h31
-rw-r--r--include/kernel/kernel/dmac.h6
-rw-r--r--include/kernel/kernel/excpmgr.h2
-rw-r--r--include/kernel/kernel/modulemgr.h476
-rw-r--r--include/kernel/kernel/processmgr.h36
-rw-r--r--include/kernel/kernel/suspend.h15
-rw-r--r--include/kernel/kernel/sysmem.h108
-rw-r--r--include/kernel/kernel/threadmgr.h274
-rw-r--r--include/kernel/kernel/utils.h205
-rw-r--r--include/kernel/lowio/iftu.h94
-rw-r--r--include/kernel/lowio/pervasive.h2
-rw-r--r--include/kernel/net/net.h7
-rw-r--r--include/kernel/power.h56
-rw-r--r--include/kernel/sblacmgr.h1
-rw-r--r--include/kernel/sblaimgr.h1
-rw-r--r--include/kernel/syscon.h14
-rw-r--r--include/kernel/udcd.h164
21 files changed, 1518 insertions, 102 deletions
diff --git a/include/kernel/appmgr.h b/include/kernel/appmgr.h
new file mode 100644
index 0000000..758c339
--- /dev/null
+++ b/include/kernel/appmgr.h
@@ -0,0 +1,52 @@
+#ifndef _PSP2_KERNEL_APPMGR_H_
+#define _PSP2_KERNEL_APPMGR_H_
+
+#include <psp2kern/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Kill a process.
+ * @param[in] pid The process to kill.
+ * @return Zero on success, else < 0.
+ */
+int sceAppMgrKillProcess(SceUID pid);
+
+typedef struct
+{
+ size_t size;
+ unsigned int unk_4; //<! set to 0x80000000 to break on launch
+ unsigned int unk_8;
+ unsigned int unk_C;
+ unsigned int unk_10;
+ unsigned int unk_14;
+ unsigned int unk_18;
+ unsigned int unk_1C;
+ unsigned int unk_20;
+ unsigned int unk_24;
+ unsigned int unk_28;
+ unsigned int unk_2C;
+ unsigned int unk_30;
+} SceAppMgrLaunchParam;
+
+/**
+ * @brief Launch an application for debugging
+ *
+ * @param[in] path Path to the executable to load
+ * @param[in] args Arguments to pass to the executable and to configure appmgr
+ * @param[in] arg_size The size of the args passed in
+ * @param[in] type Set to 0x80000000 for debugging launch
+ * @param[in] param pointer to launch params
+ * @param unk unknown, set to nullptr
+ *
+ * @return pid on success, else < 0.
+ */
+int sceAppMgrLaunchAppByPath(const char *path, const char *args, unsigned arg_size, unsigned int type, const SceAppMgrLaunchParam *param, void *unk);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PSP2_KERNEL_APPMGR_H_ */
diff --git a/include/kernel/audioout.h b/include/kernel/audioout.h
new file mode 100644
index 0000000..c1381ee
--- /dev/null
+++ b/include/kernel/audioout.h
@@ -0,0 +1,21 @@
+#ifndef _PSP2_KERNEL_AUDIOOUT_H_
+#define _PSP2_KERNEL_AUDIOOUT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum SceAudioOutPortType {
+ //! Used for main audio output, freq must be set to 48000 Hz
+ SCE_AUDIO_OUT_PORT_TYPE_MAIN = 0,
+ //! Used for Background Music port
+ SCE_AUDIO_OUT_PORT_TYPE_BGM = 1,
+ //! Used for voice chat port
+ SCE_AUDIO_OUT_PORT_TYPE_VOICE = 2
+} SceAudioOutPortType;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PSP2_KERNEL_AUDIOOUT_H_ */
diff --git a/include/kernel/display.h b/include/kernel/display.h
index 7c6cea4..5cfdc9a 100644
--- a/include/kernel/display.h
+++ b/include/kernel/display.h
@@ -109,7 +109,7 @@ int sceDisplayGetFrameBuf(SceDisplayFrameBuf *pParam, int sync);
*
* @return 0 on success, < 0 on error.
*/
-int sceDisplayGetFrameBufInfoForPid(SceUID pid, int head, int index, SceDisplayFrameBufInfo *info);
+int sceDisplayGetProcFrameBufInternal(SceUID pid, int head, int index, SceDisplayFrameBufInfo *info);
/**
* Get maximum framebuffer resolution
@@ -266,6 +266,29 @@ int sceDisplayRegisterFrameBufCallbackInternal(int display, SceUID uid);
*/
int sceDisplaySetInvertColors(int display, int enable);
+/**
+ * Set display plane owner
+ *
+ * @param[in] head - Use 0 for OLED/LCD and 1 for HDMI
+ * @param[in] index - Can be 0 or 1
+ * @param[in] pid - PID of the new owner
+ *
+ * @return 0 on success, < 0 on error.
+*/
+int sceDisplaySetOwner(int head, int index, SceUID pid);
+
+/**
+ * Set display scaling configuration
+ *
+ * @param[in] scale - Scaling factor between 0.80000001 and 1.20000005
+ * @param[in] head - Use 0 for OLED/LCD and 1 for HDMI
+ * @param[in] index - Can be 0 or 1
+ * @param[in] flags - Returns error if ((flags & 1) && (flags & 0xC0))
+ *
+ * @return 0 on success, < 0 on error.
+*/
+int sceDisplaySetScaleConf(float scale, int head, int index, int flags);
+
#ifdef __cplusplus
}
#endif
diff --git a/include/kernel/idstorage.h b/include/kernel/idstorage.h
new file mode 100644
index 0000000..a28e310
--- /dev/null
+++ b/include/kernel/idstorage.h
@@ -0,0 +1,30 @@
+#ifndef _PSP2_KERNEL_IDSTORAGE_H_
+#define _PSP2_KERNEL_IDSTORAGE_H_
+
+#include <psp2kern/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @param[in] leafnum - 0x0 ~ 0x80 / leafnum > 0x80 = error
+ * @param[out] buf - Leaf data, size is 512 byte
+ *
+ * @return 0 on success, < 0 on error.
+ */
+int sceIdStorageReadLeaf(int leafnum, void *buf);
+
+/**
+ * @param[in] leafnum - 0x0 ~ 0x80 / leafnum > 0x80 = error
+ * @param[in] buf - Leaf data, size is 512 byte
+ *
+ * @return 0 on success, < 0 on error.
+ */
+int sceIdStorageWriteLeaf(int leafnum, const void *buf);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PSP2_KERNEL_IDSTORAGE_H_ */
diff --git a/include/kernel/kernel/cpu.h b/include/kernel/kernel/cpu.h
index d79d416..4765d52 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
@@ -19,7 +20,7 @@ extern "C" {
} while(0)
/**
- * @brief Call this when existing a syscall
+ * @brief Call this when exiting a syscall
*
* @param state The state
*/
@@ -28,6 +29,18 @@ extern "C" {
asm volatile ("mcr p15, 0, %0, c13, c0, 3" :: "r" (state) : "memory"); \
} while (0)
+
+/**
+ * @brief Writeback a range of L1 dcache (without L2)
+ *
+ * @param ptr The pointer
+ * @param[in] len The length
+ *
+ * @return Zero on success
+ */
+int sceKernelCpuDcacheWritebackRange(const void *ptr, size_t len);
+
+
/**
* @brief Save process context
*
@@ -82,8 +95,10 @@ static inline int sceKernelCpuUnrestrictedMemcpy(void *dst, const void *src, siz
asm ("mrc p15, 0, %0, c3, c0, 0" : "=r" (prev_dacr));
asm ("mcr p15, 0, %0, c3, c0, 0" :: "r" (0xFFFF0000));
- memcpy(dst, src, len);
- sceKernelCpuDcacheWritebackRange((uintptr_t)dst & ~0x1F, (len + 0x1F) & ~0x1F);
+ for (size_t i=0; i < len; i++) {
+ ((char *) dst)[i] = ((char *) src)[i];
+ }
+ sceKernelCpuDcacheWritebackRange((void *)((uintptr_t)dst & ~0x1F), (len + 0x1F) & ~0x1F);
asm ("mcr p15, 0, %0, c3, c0, 0" :: "r" (prev_dacr));
return 0;
@@ -113,16 +128,6 @@ int sceKernelCpuDisableInterrupts(void);
int sceKernelCpuEnableInterrupts(int flags);
/**
- * @brief Writeback a range of L1 dcache (without L2)
- *
- * @param ptr The pointer
- * @param[in] len The length
- *
- * @return Zero on success
- */
-int sceKernelCpuDcacheWritebackRange(const void *ptr, size_t len);
-
-/**
* @brief Invalidate a range of L1 dcache (without L2)
*
* @param ptr The pointer
diff --git a/include/kernel/kernel/dmac.h b/include/kernel/kernel/dmac.h
index 60718be..669257e 100644
--- a/include/kernel/kernel/dmac.h
+++ b/include/kernel/kernel/dmac.h
@@ -1,11 +1,13 @@
#ifndef _PSP2_KERNEL_DMAC_H_
#define _PSP2_KERNEL_DMAC_H_
+#include <stddef.h>
+
#ifdef __cplusplus
extern "C" {
#endif
-/***
+/**
* DMA memcpy
*
* @param[in] dst - Destination
@@ -16,7 +18,7 @@ extern "C" {
*/
void *sceDmacMemcpy(void *dst, const void *src, size_t size);
-/***
+/**
* DMA memset
*
* @param[in] dst - Destination
diff --git a/include/kernel/kernel/excpmgr.h b/include/kernel/kernel/excpmgr.h
index d9c83ed..c852da6 100644
--- a/include/kernel/kernel/excpmgr.h
+++ b/include/kernel/kernel/excpmgr.h
@@ -16,7 +16,7 @@ typedef enum SceExcpKind {
SCE_EXCP_FIQ = 7
} SceExcpKind;
-/***
+/**
* Get a pointer to SceExcpmgr's internal data
*
* This is only used by exception handlers.
diff --git a/include/kernel/kernel/modulemgr.h b/include/kernel/kernel/modulemgr.h
index 804eb63..c8e115c 100644
--- a/include/kernel/kernel/modulemgr.h
+++ b/include/kernel/kernel/modulemgr.h
@@ -21,36 +21,39 @@ extern "C" {
#define SCE_KERNEL_STOP_CANCEL SCE_KERNEL_STOP_FAIL
/** @} */
-typedef struct
-{
- SceUInt size; //!< this structure size (0x18)
+typedef struct SceKernelModuleName {
+ char s[0x1C];
+} SceKernelModuleName;
+
+typedef struct SceKernelSegmentInfo {
+ SceSize size; //!< this structure size (0x18)
SceUInt perms; //!< probably rwx in low bits
void *vaddr; //!< address in memory
- SceUInt memsz; //!< size in memory
- SceUInt flags; //!< meaning unknown
- SceUInt res; //!< unused?
+ SceSize memsz; //!< size in memory
+ SceSize filesz; //!< original size of memsz
+ SceUInt res; //!< unused
} SceKernelSegmentInfo;
-typedef struct
-{
- SceUInt size; //!< 0x1B8 for Vita 1.x
- SceUInt handle; //!< kernel module handle?
- SceUInt flags; //!< some bits. could be priority or whatnot
+typedef struct SceKernelModuleInfo {
+ SceSize size; //!< 0x1B8 for Vita 1.x
+ SceUID modid;
+ uint16_t modattr;
+ uint8_t modver[2];
char module_name[28];
SceUInt unk28;
- void *module_start;
- SceUInt unk30;
- void *module_stop;
- void *exidxTop;
- void *exidxBtm;
- SceUInt unk40;
- SceUInt unk44;
+ void *start_entry;
+ void *stop_entry;
+ void *exit_entry;
+ void *exidx_top;
+ void *exidx_btm;
+ void *extab_top;
+ void *extab_btm;
void *tlsInit;
SceSize tlsInitSize;
SceSize tlsAreaSize;
char path[256];
SceKernelSegmentInfo segments[4];
- SceUInt type; //!< 6 = user-mode PRX?
+ SceUInt type; //!< 6 = user-mode PRX?
} SceKernelModuleInfo;
typedef struct {
@@ -64,41 +67,452 @@ typedef struct {
typedef struct
{
SceSize size;
- char versionString[16];
- SceUInt unk_14;
- SceUInt unk_18;
- SceUInt unk_1C;
+ char versionString[0x1C];
SceUInt version;
SceUInt unk_24;
} SceKernelFwInfo;
+typedef struct {
+ SceSize size; //!< sizeof(SceKernelSegmentInfo2) (0x14)
+ int perm;
+ void *vaddr;
+ uint32_t memsz;
+ int unk_10;
+} SceKernelSegmentInfo2;
+
+typedef struct {
+ SceSize size;
+ SceUID modid;
+ uint32_t version;
+ uint32_t module_version;
+ uint32_t unk10;
+ void *unk14;
+ uint32_t unk18;
+ void *unk1C;
+ void *unk20;
+ char module_name[28];
+ uint32_t unk40;
+ uint32_t unk44;
+ uint32_t nid;
+ int segments_num;
+ union {
+ struct {
+ SceKernelSegmentInfo2 SegmentInfo[1];
+ uint32_t addr[4];
+ } seg1;
+ struct {
+ SceKernelSegmentInfo2 SegmentInfo[2];
+ uint32_t addr[4];
+ } seg2;
+ struct {
+ SceKernelSegmentInfo2 SegmentInfo[3];
+ uint32_t addr[4];
+ } seg3;
+ struct {
+ SceKernelSegmentInfo2 SegmentInfo[4];
+ uint32_t addr[4];
+ } seg4;
+ };
+} SceKernelModuleListInfo;
+
+typedef struct SceKernelModuleLibraryInfo {
+ SceSize size; //!< sizeof(SceKernelModuleLibraryInfo) : 0x120
+ SceUID libid;
+ uint32_t libnid;
+ uint16_t libver[2];
+ uint16_t entry_num_function;
+ uint16_t entry_num_variable;
+ uint16_t unk_0x14;
+ uint16_t unk_0x16;
+ char library_name[0x100]; // offset : 0x18
+ uint32_t unk_0x118;
+ SceUID modid2;
+} SceKernelModuleLibraryInfo;
+
+/**
+ * @brief Register syscall function
+ *
+ * @param[in] syscall_id - register syscall id (Must be less than 0x1000)
+ * @param[in] func - syscall function
+ *
+ * @return none
+ */
+void sceKernelRegisterSyscall(int syscall_id, const void *func);
+
+/**
+ * @brief Setup kernel for modulemgr
+ *
+ * @note - allocate and initialize syscall table
+ *
+ * @return none
+ */
+void sceKernelSetupForModulemgr(void);
+
+/**
+ * @brief Get module id list
+ *
+ * @param[in] pid - target pid
+ * @param[in] flags1 - unknown, use 0x7FFFFFFF
+ * @param[in] flags2 - unknown, use 1
+ * @param[out] modids - info output pointer
+ * @param[inout] num - in:list max num, out:get modid num
+ *
+ * @return 0 on success, < 0 on error.
+ */
int sceKernelGetModuleList(SceUID pid, int flags1, int flags2, SceUID *modids, size_t *num);
+
+/**
+ * @par Example1: Get max to 10 kernel module info
+ * @code
+ * SceKernelModuleListInfo infolists[10];
+ * size_t num = 10;// Get max
+ * uint32_t offset = 0;
+ * SceKernelModuleListInfo *info = &infolists[0];
+ *
+ * sceKernelGetModuleList2(0x10005, infolists, &num);
+ *
+ * for(int i=0;i<num;i++){
+ * printf("name : %s\n", info->module_name);
+ *
+ * if(info->segments_num == 1){
+ * printf("vaddr:0x%08X\n", info->seg1.SegmentInfo[0].vaddr);
+ * }else if(info->segments_num == 2){
+ * printf("vaddr:0x%08X\n", info->seg2.SegmentInfo[0].vaddr);
+ * }
+ * info = ((char *)info) + info->size;
+ * }
+ * @endcode
+ *
+ * @param[in] pid - target pid
+ * @param[out] infolists - infolists output
+ * @param[inout] num - Specify the maximum number of modinfolist to retrieve. If the function returns 0, it returns the number of modules loaded in the target pid in num
+ *
+ * @return 0 on success, < 0 on error.
+ */
+int sceKernelGetModuleList2(SceUID pid, SceKernelModuleListInfo *infolists, size_t *num);
+
+/**
+ * @brief Get module info
+ *
+ * @param[in] pid - target pid
+ * @param[in] modid - target module id
+ * @param[out] info - info output pointer
+ *
+ * @return 0 on success, < 0 on error.
+ */
int sceKernelGetModuleInfo(SceUID pid, SceUID modid, SceKernelModuleInfo *info);
-int sceKernelGetModuleInternal(SceUID modid, void **module);
+/**
+ * @brief Get module info mini by module address
+ *
+ * @param[in] pid - target pid
+ * @param[in] module_addr - target module address, Also possible with data segment address
+ * @param[out] module_nid - can also set NULL, module nid output
+ * @param[out] program_text_addr - can also set NULL, program text addr output
+ * @param[out] module_name - can also set NULL, module name output
+ *
+ * @return 0 on success, < 0 on error.
+ */
+int sceKernelGetModuleInfoMinByAddr(SceUID pid, const void *module_addr, uint32_t *module_nid, const void **program_text_addr, SceKernelModuleName *module_name);
+
+/**
+ * @brief Get module info (internal)
+ *
+ * @param[in] modid - target module id
+ * @param[out] module_info - module_info output pointer
+ *
+ * @return 0 on success, < 0 on error.
+ */
+int sceKernelGetModuleInternal(SceUID modid, void **module_info);
+
+/**
+ * @brief Get module id by module address
+ *
+ * @param[in] pid - target pid
+ * @param[in] module_addr - target module address
+ *
+ * @return modid on success, < 0 on error.
+ */
+SceUID sceKernelGetModuleIdByAddr(SceUID pid, const void *module_addr);
+
+/**
+ * @brief search kernel module by module name
+ *
+ * @param[in] module_name - target module name
+ *
+ * @return modid on success, < 0 on error.
+ */
+SceUID sceKernelSearchModuleByName(const char *module_name);
+
+/**
+ * @brief Get fw info
+ *
+ * @param[out] data - fw info output pointer
+ *
+ * @return 0 on success, < 0 on error.
+ */
int sceKernelGetSystemSwVersion(SceKernelFwInfo *data);
-int sceKernelLoadStartModule(const char *path, SceSize args, void *argp, int flags, SceKernelLMOption *option, int *status);
+/**
+ * @brief load module (kernel only)
+ *
+ * @param[in] path - module path
+ * @param[in] flags - unknown, set zero
+ * @param[in] option - unknown
+ *
+ * @return modid on success, < 0 on error.
+ */
SceUID sceKernelLoadModule(const char *path, int flags, SceKernelLMOption *option);
+
+/**
+ * @brief start module (kernel only)
+ *
+ * @param[in] modid - target module id
+ * @param[in] args - module start args
+ * @param[in] argp - module start argp
+ * @param[in] flags - unknown, set zero
+ * @param[in] option - unknown
+ * @param[out] status - module_start res, SCE_KERNEL_START_SUCCESS etc...
+ *
+ * @return 0 on success, < 0 on error.
+ */
int sceKernelStartModule(SceUID modid, SceSize args, void *argp, int flags, SceKernelLMOption *option, int *status);
-int sceKernelUnloadModule(SceUID modid, int flags, SceKernelULMOption *option);
+
+/**
+ * @brief load and start module (kernel only)
+ *
+ * @param[in] path - module path
+ * @param[in] args - module start args
+ * @param[in] argp - module start argp
+ * @param[in] flags - unknown, set zero
+ * @param[in] option - unknown
+ * @param[out] status - module_start res, SCE_KERNEL_START_SUCCESS etc...
+ *
+ * @return modid on success, < 0 on error.
+ */
+SceUID sceKernelLoadStartModule(const char *path, SceSize args, void *argp, int flags, SceKernelLMOption *option, int *status);
+
+/**
+ * @brief stop module (kernel only)
+ *
+ * @param[in] modid - target module id
+ * @param[in] args - module stop args
+ * @param[in] argp - module stop argp
+ * @param[in] flags - unknown, set zero
+ * @param[in] option - unknown
+ * @param[out] status - module_stop res, SCE_KERNEL_STOP_SUCCESS etc...
+ *
+ * @return 0 on success, < 0 on error.
+ */
int sceKernelStopModule(SceUID modid, SceSize args, void *argp, int flags, SceKernelULMOption *option, int *status);
+
+/**
+ * @brief unload module (kernel only)
+ *
+ * @param[in] modid - target module id
+ * @param[in] flags - unknown, set zero
+ * @param[in] option - unknown
+ *
+ * @return 0 on success, < 0 on error.
+ */
+int sceKernelUnloadModule(SceUID modid, int flags, SceKernelULMOption *option);
+
+/**
+ * @brief stop and unload module (kernel only)
+ *
+ * @param[in] modid - target module id
+ * @param[in] args - module stop args
+ * @param[in] argp - module stop argp
+ * @param[in] flags - unknown, set zero
+ * @param[in] option - unknown
+ * @param[out] status - module_stop res, SCE_KERNEL_STOP_SUCCESS etc...
+ *
+ * @return 0 on success, < 0 on error.
+ */
int sceKernelStopUnloadModule(SceUID modid, SceSize args, void *argp, int flags, SceKernelULMOption *option, int *status);
-SceUID sceKernelLoadStartSharedModuleForPid(SceUID pid, const char *path, SceSize args, void *argp, int flags, SceKernelLMOption *option, int *status);
-SceUID sceKernelLoadStartModuleForPid(SceUID pid, const char *path, SceSize args, void *argp, int flags, SceKernelLMOption *option, int *status);
-int sceKernelStartModuleForPid(SceUID pid, SceUID modid, SceSize args, void *argp, int flags, SceKernelLMOption *option, int *status);
+/**
+ * @brief load module
+ *
+ * @param[in] pid - target pid
+ * @param[in] path - module path
+ * @param[in] flags - unknown, set zero
+ * @param[in] option - unknown
+ *
+ * @return modid on success, < 0 on error.
+ */
SceUID sceKernelLoadModuleForPid(SceUID pid, const char *path, int flags, SceKernelLMOption *option);
-SceUID sceKernelUnloadModuleForPid(SceUID pid, SceUID modid, int flags, SceKernelULMOption *option);
+
+/**
+ * @brief start module
+ *
+ * @param[in] pid - target pid
+ * @param[in] modid - target module id
+ * @param[in] args - module start args
+ * @param[in] argp - module start argp
+ * @param[in] flags - unknown, set zero
+ * @param[in] option - unknown
+ * @param[out] status - module_start res, SCE_KERNEL_START_SUCCESS etc...
+ *
+ * @return 0 on success, < 0 on error.
+ */
+int sceKernelStartModuleForPid(SceUID pid, SceUID modid, SceSize args, void *argp, int flags, SceKernelLMOption *option, int *status);
+
+/**
+ * @brief load and start module
+ *
+ * @param[in] pid - target pid
+ * @param[in] path - module path
+ * @param[in] args - module start args
+ * @param[in] argp - module start argp
+ * @param[in] flags - unknown, set zero
+ * @param[in] option - unknown
+ * @param[out] status - module_start res, SCE_KERNEL_START_SUCCESS etc...
+ *
+ * @return modid on success, < 0 on error.
+ */
+SceUID sceKernelLoadStartModuleForPid(SceUID pid, const char *path, SceSize args, void *argp, int flags, SceKernelLMOption *option, int *status);
+
+/**
+ * @brief stop module
+ *
+ * @param[in] pid - target pid
+ * @param[in] modid - target module id
+ * @param[in] args - module stop args
+ * @param[in] argp - module stop argp
+ * @param[in] flags - unknown, set zero
+ * @param[in] option - unknown
+ * @param[out] status - module_stop res, SCE_KERNEL_STOP_SUCCESS etc...
+ *
+ * @return 0 on success, < 0 on error.
+ */
int sceKernelStopModuleForPid(SceUID pid, SceUID modid, SceSize args, void *argp, int flags, SceKernelULMOption *option, int *status);
+
+/**
+ * @brief unload module
+ *
+ * @param[in] pid - target pid
+ * @param[in] modid - target module id
+ * @param[in] flags - unknown, set zero
+ * @param[in] option - unknown
+ *
+ * @return 0 on success, < 0 on error.
+ */
+int sceKernelUnloadModuleForPid(SceUID pid, SceUID modid, int flags, SceKernelULMOption *option);
+
+/**
+ * @brief stop and unload module
+ *
+ * @param[in] pid - target pid
+ * @param[in] modid - target module id
+ * @param[in] args - module stop args
+ * @param[in] argp - module stop argp
+ * @param[in] flags - unknown, set zero
+ * @param[in] option - unknown
+ * @param[out] status - module_stop res, SCE_KERNEL_STOP_SUCCESS etc...
+ *
+ * @return 0 on success, < 0 on error.
+ */
int sceKernelStopUnloadModuleForPid(SceUID pid, SceUID modid, SceSize args, void *argp, int flags, SceKernelULMOption *option, int *status);
+/**
+ * @brief load and start module as shared module
+ *
+ * @param[in] pid - target pid
+ * @param[in] path - module path
+ * @param[in] args - module start args
+ * @param[in] argp - module start argp
+ * @param[in] flags - unknown, set zero
+ * @param[in] option - unknown
+ * @param[out] status - module_start res, SCE_KERNEL_START_SUCCESS etc...
+ *
+ * @return modid on success, < 0 on error.
+ */
+SceUID sceKernelLoadStartSharedModuleForPid(SceUID pid, const char *path, SceSize args, void *argp, int flags, SceKernelLMOption *option, int *status);
+
+/**
+ * @brief stop and unload module as shared module
+ *
+ * @param[in] pid - target pid
+ * @param[in] modid - target module id
+ * @param[in] args - module stop args
+ * @param[in] argp - module stop argp
+ * @param[in] flags - unknown, set zero
+ * @param[in] option - unknown
+ * @param[out] status - module_stop res, SCE_KERNEL_STOP_SUCCESS etc...
+ *
+ * @return 0 on success, < 0 on error.
+ */
+int sceKernelStopUnloadSharedModuleForPid(SceUID pid, SceUID modid, SceSize args, void *argp, int flags, SceKernelULMOption *option, int *status);
+
+/**
+ * @brief mount bootfs (load bootfs module)
+ *
+ * @param[in] bootImagePath - bootfs module path
+ *
+ * @return 0 on success, < 0 on error.
+ */
int sceKernelMountBootfs(const char *bootImagePath);
+
+/**
+ * @brief unmount bootfs (unload bootfs module)
+ *
+ * @return 0 on success, < 0 on error.
+ */
int sceKernelUmountBootfs(void);
+/**
+ * @brief Get the main module for a given process.
+ * @param pid The process to query.
+ * @return the UID of the module else < 0 for an error.
+ */
+SceUID sceKernelGetProcessMainModule(SceUID pid);
+
+/**
+ * @brief Get the module path
+ *
+ * @param[in] pid - target pid
+ * @param[out] path - module path output
+ * @param[in] pathlen - path output max len
+ *
+ * @return 0 on success, < 0 on error.
+ */
+int sceKernelGetModulePath(SceUID modid, char *path, int pathlen);
+
+/**
+ * @brief Get library info
+ *
+ * @param[in] pid - target pid
+ * @param[in] modid - target library id
+ * @param[out] info - info output
+ *
+ * @return 0 on success, < 0 on error.
+ */
+int sceKernelGetModuleLibraryInfo(SceUID pid, SceUID libid, SceKernelModuleLibraryInfo *info);
+
+typedef struct SceKernelModuleExportEntry {
+ uint32_t libnid;
+ const void *entry; // function ptr. or vars?
+} SceKernelModuleExportEntry;
+
+/**
+ * @brief Get module export entry
+ *
+ * @param[in] pid - target pid
+ * @param[in] libid - target library uid
+ * @param[out] list - data output
+ * @param[inout] num - in:list max num, out:get entry num
+ * @param[in] cpy_skip_num - The index at which to start copying
+ *
+ * @return 0 on success, < 0 on error.
+ */
+int sceKernelGetModuleLibExportList(SceUID pid, SceUID libid, SceKernelModuleExportEntry *list, SceSize *num, SceSize cpy_skip_num);
+
+int sceKernelGetModuleUid(SceUID pid, SceUID modid, SceUID *modid_out, const void *unk1, int unk2);
+int sceKernelGetModuleUidList(SceUID pid, SceUID *modids, size_t *num);
+
#ifdef __cplusplus
}
#endif
#endif /* _PSP2_KERNEL_MODULEMGR_H_ */
-
diff --git a/include/kernel/kernel/processmgr.h b/include/kernel/kernel/processmgr.h
index f203eed..819129b 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
@@ -25,6 +28,39 @@ int sceKernelCreateProcessLocalStorage(const char *name, SceSize size);
void *sceKernelGetProcessLocalStorageAddr(int key);
int sceKernelGetProcessLocalStorageAddrForPid(SceUID pid, int key, void **out_addr, int create_if_doesnt_exist);
+/**
+ * @brief Launch an application
+ * @param[in] titleid The TitleId of the app to open.
+ * @param[in] flags Some unknown flags.
+ * @param[in] path Path of the eboot.bin to launch.
+ * @param[in] unk Unknown.
+ * @return PID of the launched app on success, < 0 on error.
+ */
+SceUID sceKernelLaunchApp(char* titleid, uint32_t flags, char *path, uint32_t unk);
+
+/**
+ * @brief Resume a suspended process.
+ * @param[in] pid The process to resume.
+ * @return Zero on success, < 0 on error.
+ */
+int sceKernelResumeProcess(SceUID pid);
+
+/**
+ * @brief Suspend a running process.
+ * @param[in] pid The process to suspend.
+ * @param[in] status The new status for the process.
+ * @return Zero on success, < 0 on error.
+ */
+int sceKernelSuspendProcess(SceUID pid, int status);
+
+/**
+ * @brief Get the status of a given process.
+ * @param[in] pid The process ID to query.
+ * @param[out] status The bit field status of the process.
+ * @return Zero on success, < 0 on error.
+ */
+int sceKernelGetProcessStatus(SceUID pid, int *status);
+
#ifdef __cplusplus
}
#endif
diff --git a/include/kernel/kernel/suspend.h b/include/kernel/kernel/suspend.h
index 712e9b3..a1429c9 100644
--- a/include/kernel/kernel/suspend.h
+++ b/include/kernel/kernel/suspend.h
@@ -7,6 +7,8 @@
extern "C" {
#endif
+typedef int (* SceSysEventHandler)(int resume, int eventid, void *args, void *opt);
+
typedef enum SceKernelPowerTickType {
/** Cancel all timers */
SCE_KERNEL_POWER_TICK_DEFAULT = 0,
@@ -19,7 +21,7 @@ typedef enum SceKernelPowerTickType {
} SceKernelPowerTickType;
-/***
+/**
* Cancel specified idle timers to prevent entering in power save processing.
*
* @param[in] type - One of ::SceKernelPowerTickType
@@ -28,6 +30,17 @@ typedef enum SceKernelPowerTickType {
*/
int sceKernelPowerTick(int type);
+/**
+ * Register system event handler
+ *
+ * @param[in] name - Name of handler
+ * @param[in] handler - The handler
+ * @param[in] args - Handler arguments
+ *
+ * @return 0 on success, < 0 on error.
+*/
+int sceKernelRegisterSysEventHandler(const char *name, SceSysEventHandler handler, void *args);
+
#ifdef __cplusplus
}
#endif
diff --git a/include/kernel/kernel/sysmem.h b/include/kernel/kernel/sysmem.h
index 72d6c06..aa882e3 100644
--- a/include/kernel/kernel/sysmem.h
+++ b/include/kernel/kernel/sysmem.h
@@ -1,13 +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,
@@ -18,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,
@@ -132,7 +133,19 @@ typedef struct SceKernelProcessContext {
SceUInt32 CONTEXTIDR;
} SceKernelProcessContext;
-/***
+typedef enum SceKernelSysrootSelfIndex {
+ SCE_KERNEL_SYSROOT_SELF_INDEX_GCAUTHMGR_SM = 0,
+ SCE_KERNEL_SYSROOT_SELF_INDEX_RMAUTH_SM = 1,
+ SCE_KERNEL_SYSROOT_SELF_INDEX_ENCDEC_W_PORTABILITY_SM = 2
+} SceKernelSysrootSelfIndex;
+
+typedef struct SceKernelSysrootSelfInfo {
+ uint32_t size;
+ void *self_data;
+ uint32_t self_size;
+} SceKernelSysrootSelfInfo;
+
+/**
* Allocates a new memory block
*
* @param[in] name - Name for the memory block
@@ -144,7 +157,7 @@ typedef struct SceKernelProcessContext {
*/
SceUID sceKernelAllocMemBlock(const char *name, SceKernelMemBlockType type, int size, SceKernelAllocMemBlockKernelOpt *optp);
-/***
+/**
* Frees new memory block
*
* @param[in] uid - SceUID of the memory block to free
@@ -153,7 +166,7 @@ SceUID sceKernelAllocMemBlock(const char *name, SceKernelMemBlockType type, int
*/
int sceKernelFreeMemBlock(SceUID uid);
-/***
+/**
* Gets the base address of a memory block
*
* @param[in] uid - SceUID of the memory block
@@ -163,7 +176,7 @@ int sceKernelFreeMemBlock(SceUID uid);
*/
int sceKernelGetMemBlockBase(SceUID uid, void **basep);
-/***
+/**
* Gets the memory block type of a memory block
*
* @param[in] uid - SceUID of the memory block
@@ -173,7 +186,7 @@ int sceKernelGetMemBlockBase(SceUID uid, void **basep);
*/
int sceKernelGetMemBlockType(SceUID uid, unsigned int *type);
-/***
+/**
* Find the SceUID of a memory block
*
* @param[in] addr - Base address of the memory block
@@ -183,7 +196,7 @@ int sceKernelGetMemBlockType(SceUID uid, unsigned int *type);
*/
SceUID sceKernelFindMemBlockByAddr(const void *addr, SceSize size);
-/***
+/**
* Find the SceUID of a memory block for a PID
*
* @param[in] pid - PID of the process
@@ -259,10 +272,13 @@ int sceKernelUidRetain(SceUID uid);
int sceKernelUidRelease(SceUID uid);
SceClass *sceKernelGetUidClass(void);
+SceClass *sceKernelGetUidDLinkClass(void);
+SceClass *sceKernelGetUidHeapClass(void);
+SceClass *sceKernelGetUidMemBlockClass(void);
int sceKernelCreateClass(SceClass *cls, const char *name, void *uidclass, size_t itemsize, SceClassCallback create, SceClassCallback destroy);
int sceKernelDeleteUserUid(SceUID pid, SceUID user_uid);
int sceKernelDeleteUid(SceUID uid);
-int sceKernelFindClassByName(const char name, SceClass **cls);
+int sceKernelFindClassByName(const char *name, SceClass **cls);
int sceKernelSwitchVmaForPid(SceUID pid);
@@ -272,6 +288,17 @@ int sceKernelGetPidContext(SceUID pid, SceKernelProcessContext **ctx);
int sceKernelGetProcessTitleId(SceUID pid, char *titleid, size_t len);
int sceKernelMapBlockUserVisible(SceUID uid);
+int sceKernelMapUserBlock(const char *name, int permission, int type,
+ const void *user_buf, unsigned int size, void **kernel_page,
+ unsigned int *kernel_size, unsigned int *kernel_offset);
+int sceKernelMapUserBlockDefaultType(const char *name, int permission, const void *user_buf,
+ unsigned int size, void **kernel_page,
+ unsigned int *kernel_size, unsigned int *kernel_offset);
+int sceKernelMapUserBlockDefaultTypeForPid(int pid, const char *name, int permission,
+ const void *user_buf, unsigned int size, void **kernel_page,
+ unsigned int *kernel_size, unsigned int *kernel_offset);
+
+int sceSysrootGetSelfInfo(SceKernelSysrootSelfIndex index, SceKernelSysrootSelfInfo *info);
/**
* Get the physical address of a given virtual address
@@ -281,7 +308,7 @@ int sceKernelMapBlockUserVisible(SceUID uid);
*
* @return 0 on success, < 0 on error.
*/
-int sceKernelGetPaddr(void *addr, uintptr_t *paddr);
+int sceKernelGetPaddr(const void *addr, uintptr_t *paddr);
/**
* Get the physical address list of a given virtual address range
@@ -392,11 +419,37 @@ int sceKernelMemRangeReleaseForPid(SceUID pid, void *addr, unsigned int size);
*/
int sceKernelMemRangeReleaseWithPerm(SceKernelMemoryRefPerm perm, void *addr, unsigned int size);
-int sceSysrootIsManufacturingMode(void);
+int sceSysrootUseExternalStorage(void);
+
+#define sceSysrootIsManufacturingMode() sceSysrootUseExternalStorage()
+
+int sceSysrootUseInternalStorage(void);
int sceDebugPrintf(const char *fmt, ...);
-int sceDebugPrintf2(int unk0, int unk1, const char *fmt, ...);
+typedef struct kernel_message_ctx
+{
+ int hex_value0_hi;
+ int hex_value0_lo;
+ int hex_value1;
+ char* msg0;
+ int num;
+ char* msg1;
+} kernel_message_ctx;
+
+// msg_type_flag : 0 or 0xB
+
+int sceDebugPrintf2(int msg_type_flag, kernel_message_ctx *msg_ctx, const char *fmt, ...);
+
+int sceDebugVprintf(const char *fmt, va_list args);
+
+int sceDebugPrintKernelPanic(kernel_message_ctx *msg_ctx, void *some_address);
+
+int sceDebugPrintfKernelPanic(kernel_message_ctx *msg_ctx, void *some_address, char* format, ...);
+
+int sceDebugPrintKernelAssertion(int condition, kernel_message_ctx *msg_ctx, void *some_address);
+
+int sceDebugPrintfKernelAssertion(int unk, int condition, kernel_message_ctx *msg_ctx, int some_address, const char *fmt, ...);
int sceDebugSetHandlers(int (*func)(void *args, char c), void *args);
@@ -406,9 +459,36 @@ void *sceDebugGetPutcharHandler(void);
int sceDebugPutchar(int character);
+int sceDebugDisableInfoDump(int flag);
+
+typedef struct
+{
+ size_t size; //!< sizeof(SceSysrootProcessHandler)
+ int (* unk_4)(void);
+ int (* unk_8)(void);
+ int (* unk_C)(void);
+ int (* unk_10)(void);
+ int (* unk_14)(void);
+ int (* unk_18)(void);
+ int (* on_process_created)(void); //!< called when process is created
+ int (* unk_20)(void);
+ int (* unk_24)(void);
+} SceSysrootProcessHandler;
+
+/**
+ * Set handlers for the process lifecycle.
+ *
+ * This internal function allows a developer to introspect and receive events based
+ * on the process lifecycle.
+ *
+ * @param[in] handlers Pointer to struct containing the handlers. This function does not copy the handlers, so this pointer must remain valid after a successful call.
+ *
+ * @return 0 on success, < 0 on error.
+ */
+int sceKernelSysrootSetProcessHandler(const SceSysrootProcessHandler *handlers);
+
#ifdef __cplusplus
}
#endif
#endif
-
diff --git a/include/kernel/kernel/threadmgr.h b/include/kernel/kernel/threadmgr.h
index 8990a7b..76e2b4c 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. */
@@ -439,18 +432,71 @@ int sceKernelUnlockMutex(SceUID mutexid, int unlockCount);
*/
int sceKernelCancelMutex(SceUID mutexid, int newCount, int *numWaitThreads);
-typedef struct SceKernelLwMutexWork {
- SceInt64 data[4];
-} SceKernelLwMutexWork;
+/**
+ * Retrieve information about a mutex.
+ *
+ * @param mutexid - UID of the mutex to retrieve info for.
+ * @param info - Pointer to a ::SceKernelMutexInfo struct to receive the info.
+ *
+ * @return < 0 on error.
+ */
+int sceKernelGetMutexInfo(SceUID mutexid, SceKernelMutexInfo *info);
+
+/* Fast mutex */
+
+typedef struct SceKernelFastMutexWork {
+ SceInt64 data[8];
+} SceKernelFastMutexWork;
-typedef struct SceKernelLwMutexOptParam {
+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);
+
+SceInt32 sceKernelLockFastMutex(SceKernelFastMutexWork *pWork);
-int sceKernelInitializeFastMutex(void *mutex, const char *name, int unk0, int unk1);
-int sceKernelLockFastMutex(void *mutex);
-int sceKernelUnlockFastMutex(void *mutex);
-int sceKernelDeleteFastMutex(void *mutex);
+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. */
@@ -829,6 +875,200 @@ int sceKernelRunWithStack(int stack_size, int (*to_call)(void *), void *args);
*/
int sceKernelGetFaultingProcess(SceKernelFaultingProcessInfo *info);
+/* Workqueues */
+
+typedef int (*SceKernelWorkQueueWorkFunction)(void *args);
+
+/**
+ * @brief Enqueue work to a workqueue
+ *
+ * @param[in] uid UID of the workqueue (0x10023 for the SceKernelGlobalWorkQueue)
+ * @param[in] name Name of the work to enqueue
+ * @param[in] work Work function to enqueue
+ * @param[in] args Argument to pass to the work function
+ *
+ * @return Zero on success
+ */
+int sceKernelEnqueueWorkQueue(SceUID uid, const char *name, SceKernelWorkQueueWorkFunction work, void *args);
+
+/**
+ * @brief Get the main thread for a given process.
+ * @param[in] pid The process id to query for.
+ * @return The thread UID on success, else < 0 on error.
+ */
+SceUID sceKernelGetProcessMainThread(SceUID pid);
+
+/**
+ * @brief Retrieve a list of all threads belonging to a process.
+ * @param[in] pid The process to query.
+ * @param[out] ids The list of thread ids. Can be NULL if output is not required.
+ * @param[in] n The max number of thread ids to copy out.
+ * @param[out] copy_count The number of thread ids copied.
+ * @return The number of threads within the process, else < 0 on error.
+ */
+int sceKernelGetThreadIdList(SceUID pid, SceUID *ids, int n, int *copy_count);
+
+/** Structure representing all ARM registers */
+typedef struct ArmCpuRegisters
+{
+ uint32_t r0;
+ uint32_t r1;
+ uint32_t r2;
+ uint32_t r3;
+ uint32_t r4;
+ uint32_t r5;
+ uint32_t r6;
+ uint32_t r7;
+ uint32_t r8;
+ uint32_t r9;
+ uint32_t r10;
+ uint32_t r11;
+ uint32_t r12;
+ uint32_t sp;
+ uint32_t lr;
+ uint32_t pc;
+ uint32_t cpsr;
+ uint32_t unk;
+} ArmCpuRegisters;
+
+/** Structure containing a threads register states. */
+typedef struct ThreadCpuRegisters
+{
+ /** Set of registers used for user mode. */
+ ArmCpuRegisters user;
+
+ /** Set of registers used for kernel mode. */
+ ArmCpuRegisters kernel;
+} ThreadCpuRegisters;
+
+/**
+ * @brief Query the state of the registers for a suspended thread.
+ *
+ * The registers returned are the user/kernel set for the requested thread.
+ * It's not certain that user/kernel is correct representation, instead it could be current/exception.
+ * The thread provided must be suspended for this function to succeed.
+ *
+ * @param[in] thid The thread to query.
+ * @param[out] registers The set of registers belonging to the thread.
+ * @return Zero on success, else < 0 on error.
+ */
+int sceKernelGetThreadCpuRegisters(SceUID thid, ThreadCpuRegisters *registers);
+
+
+/**
+ * @brief Change the thread suspension status to another value.
+ *
+ * More research needs to be done to find out exactly what each status actually means. Some examples of useful scenarios:
+ * When handling an exception changing the status to 0x1002 (on a newly suspended thread) will stop the kernel rethrowing the same exception.
+ * When resuming a suspended thread changing the status to 2 will allow it to resume.
+ *
+ * @param[in] thid The thread to change.
+ * @param[in] status The new status for suspension.
+ * @return Zero on success, else < 0 on error.
+ */
+int sceKernelChangeThreadSuspendStatus(SceUID thid, int status);
+
+/* Message pipes */
+
+/**
+ * Create a message pipe
+ *
+ * @param name - Name of the pipe
+ * @param type - The type of memory attribute to use internally (set to 0x40)
+ * @param attr - Set to 12
+ * @param bufSize - The size of the internal buffer in multiples of 0x1000 (4KB)
+ * @param opt - Message pipe options (set to NULL)
+ *
+ * @return The UID of the created pipe, < 0 on error
+ */
+SceUID sceKernelCreateMsgPipe(const char *name, int type, int attr, unsigned int bufSize, void *opt);
+
+/**
+ * Delete a message pipe
+ *
+ * @param uid - The UID of the pipe
+ *
+ * @return 0 on success, < 0 on error
+ */
+int sceKernelDeleteMsgPipe(SceUID uid);
+
+typedef struct
+{
+ const void *message;
+ unsigned int size;
+} MsgPipeSendData;
+
+/**
+ * Send a message to a pipe
+ *
+ * @param uid - The UID of the pipe
+ * @param message - Pointer to the message
+ * @param size - Size of the message
+ * @param unk1 - Unknown - async vs sync? use 0 for sync
+ * @param unk2 - Unknown - use NULL
+ * @param timeout - Timeout for send in us. use NULL to wait indefinitely
+ *
+ * @return 0 on success, < 0 on error
+ */
+int sceKernelSendMsgPipeVector(SceUID uid, const MsgPipeSendData *v, unsigned int n, int unk1, void *unk2, unsigned int *timeout);
+
+/**
+ * Try to send a message to a pipe
+ *
+ * @param uid - The UID of the pipe
+ * @param message - Pointer to the message
+ * @param size - Size of the message
+ * @param unk1 - Unknown - use 0
+ * @param unk2 - Unknown - use NULL
+ *
+ * @return 0 on success, < 0 on error
+ */
+int sceKernelTrySendMsgPipeVector(SceUID uid, const MsgPipeSendData *v, unsigned int size, int unk1, void *unk2);
+
+typedef struct
+{
+ void *message;
+ unsigned int size;
+} MsgPipeRecvData;
+
+/**
+ * Receive a message from a pipe
+ *
+ * @param uid - The UID of the pipe
+ * @param message - Pointer to the message
+ * @param size - Size of the message
+ * @param unk1 - Unknown - async vs sync? use 0 for sync
+ * @param unk2 - Unknown - use NULL
+ * @param timeout - Timeout for receive in us. use NULL to wait indefinitely
+ *
+ * @return 0 on success, < 0 on error
+ */
+int sceKernelReceiveMsgPipeVector(SceUID uid, const MsgPipeRecvData *v, unsigned int n, int unk1, void *unk2, unsigned int *timeout);
+
+/**
+ * Receive a message from a pipe
+ *
+ * @param uid - The UID of the pipe
+ * @param message - Pointer to the message
+ * @param size - Size of the message
+ * @param unk1 - Unknown - use 0
+ * @param unk2 - Unknown - use NULL
+ *
+ * @return 0 on success, < 0 on error
+ */
+int sceKernelTryReceiveMsgPipeVector(SceUID uid, const MsgPipeRecvData *v, unsigned int size, int unk1, void *unk2);
+
+/**
+ * Cancel a message pipe
+ *
+ * @param uid - UID of the pipe to cancel
+ * @param psend - Receive number of sending threads, NULL is valid
+ * @param precv - Receive number of receiving threads, NULL is valid
+ *
+ * @return 0 on success, < 0 on error
+ */
+int sceKernelCancelMsgPipe(SceUID uid, int *psend, int *precv);
+
#ifdef __cplusplus
}
#endif
diff --git a/include/kernel/kernel/utils.h b/include/kernel/kernel/utils.h
new file mode 100644
index 0000000..c7f1c92
--- /dev/null
+++ b/include/kernel/kernel/utils.h
@@ -0,0 +1,205 @@
+#ifndef _PSP2_KERNEL_UTILS_H_
+#define _PSP2_KERNEL_UTILS_H_
+
+#include <psp2kern/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SCE_SHA1_BLOCK_SIZE 64
+#define SCE_SHA1_DIGEST_SIZE 20
+#define SCE_SHA224_BLOCK_SIZE 64
+#define SCE_SHA224_DIGEST_SIZE 28
+#define SCE_SHA256_BLOCK_SIZE 64
+#define SCE_SHA256_DIGEST_SIZE 32
+
+typedef struct SceSha1Context {
+ uint32_t h[5];
+ uint16_t usRemains;
+ uint16_t usComputed;
+ uint64_t ullTotalLen;
+ char buf[SCE_SHA1_BLOCK_SIZE];
+ char result[SCE_SHA1_DIGEST_SIZE];
+ uint32_t pad;
+} SceSha1Context;
+
+typedef struct SceSha224Context {
+ uint32_t h[8];
+ uint32_t pad;
+ uint16_t usRemains;
+ uint16_t usComputed;
+ uint64_t ullTotalLen;
+ char buf[SCE_SHA224_BLOCK_SIZE];
+ char result[SCE_SHA224_DIGEST_SIZE];
+ uint32_t pad2;
+} SceSha224Context;
+
+typedef struct SceSha256Context {
+ uint32_t h[8];
+ uint32_t pad;
+ uint16_t usRemains;
+ uint16_t usComputed;
+ uint64_t ullTotalLen;
+ char buf[SCE_SHA256_BLOCK_SIZE];
+ char result[SCE_SHA256_DIGEST_SIZE];
+} SceSha256Context;
+
+struct SceDeflatePartialInputParam;
+
+typedef struct SceDeflatePartialInputParam {
+ uint32_t size;
+ const void *pBufEnd;
+ void *cookie;
+ const void *(* SceDeflateDecompressPartialInputCallback)(struct SceDeflatePartialInputParam* param, uint32_t outputsize);
+} SceDeflatePartialInputParam;
+
+typedef struct {
+ uint8_t data[976];
+} SceAesContext;
+
+int sceSha1BlockInit(SceSha1Context *pContext);
+int sceSha1BlockUpdate(SceSha1Context *pContext, const void *plain, uint32_t len);
+int sceSha1BlockResult(SceSha1Context *pContext, char *digest);
+int sceSha1Digest(const void *plain, uint32_t len, char *result);
+
+int sceSha224BlockInit(SceSha224Context *pContext);
+int sceSha224BlockUpdate(SceSha224Context *pContext, const void *plain, uint32_t len);
+int sceSha224BlockResult(SceSha224Context *pContext, char *digest);
+int sceSha224Digest(const void *plain, uint32_t len, char *result);
+
+int sceSha256BlockInit(SceSha256Context *pContext);
+int sceSha256BlockUpdate(SceSha256Context *pContext, const void *plain, uint32_t len);
+int sceSha256BlockResult(SceSha256Context *pContext, char *digest);
+int sceSha256Digest(const void *plain, uint32_t len, char *result);
+
+int sceHmacSha1Digest(const unsigned char *key, uint32_t key_len, const void *plain, uint32_t len, char *result);
+int sceHmacSha224Digest(const unsigned char *key, uint32_t key_len, const void *plain, uint32_t len, char *result);
+int sceHmacSha256Digest(const unsigned char *key, uint32_t key_len, const void *plain, uint32_t len, char *result);
+
+/**
+ * @param[out] dst - dst buf
+ * @param[in] dst_size - dst buf size
+ * @param[in] src - Gzip compressed data
+ * @param[out] crc32 - crc32 when decompressed
+ *
+ * @return decompressed size on success, < 0 on error.
+ */
+int sceGzipDecompress(void *dst, uint32_t dst_size, const void *src, uint32_t *crc32);
+
+/**
+ * @brief Check magic of Gzip header
+ *
+ * @param[in] src - Gzip compressed data
+ *
+ * @return 1 on success, 0 is not Gzip data.
+ */
+int sceGzipIsValid(const void *src);
+
+/**
+ * @brief Get filename etc. in Gzip data
+ *
+ * @param[in] src - Gzip compressed data
+ * @param[out] extra - Get information on extra-field
+ * @param[out] name - Get filename information
+ * @param[out] comment - Get comment information
+ * @param[out] crc - Get CRC16 information
+ * @param[out] data - Get compressed data start address
+ *
+ * @return 0 on success, < 0 on error.
+ */
+int sceGzipGetInfo(const void *src, const void **extra, const char **name, const char **comment, unsigned short *crc, const void **data);
+
+/**
+ * @brief Get filename string address
+ *
+ * @param[in] src - Gzip compressed data
+ *
+ * @return string address on success, NULL on error.
+ */
+const char *sceGzipGetName(const void *src);
+
+/**
+ * @brief Get comment string address
+ *
+ * @param[in] src - Gzip compressed data
+ *
+ * @return string address on success, NULL on error.
+ */
+const char *sceGzipGetComment(const void *src);
+
+/**
+ * @brief Get compressed data start address
+ *
+ * @param[in] src - Gzip compressed data
+ *
+ * @return compressed data address on success, NULL on error.
+ */
+const void *sceGzipGetCompressedData(const void *src);
+
+/**
+ * @brief Get filename etc. in Zlib data
+ *
+ * @param[in] src - Zlib compressed data
+ * @param[out] cmf - Get CMF (Compression Method and flags)
+ * @param[out] flg - Get FLG (FLaGs)
+ * @param[out] dictid - Get DictId
+ * @param[out] data - Get compressed data start address
+ *
+ * @return 0 on success, < 0 on error.
+ */
+int sceZlibGetInfo(const void *src, unsigned char *cmf, unsigned char *flg, unsigned int *dictid, const void **data);
+
+/**
+ * @brief Get compressed data start address
+ *
+ * @param[in] src - Gzip compressed data
+ *
+ * @return compressed data address on success, NULL on error.
+ */
+const void *sceZlibGetCompressedData(const void *src);
+
+/**
+ * @param[out] dst - dst buf
+ * @param[in] dst_size - dst buf size
+ * @param[in] src - Zlib compressed data
+ * @param[out] adler32 - adler32 when decompressed
+ *
+ * @return decompressed size on success, < 0 on error.
+ */
+int sceZlibDecompress(void *dst, uint32_t dst_size, const void *src, uint32_t *adler32);
+
+/**
+ * @param[out] dst - dst buf
+ * @param[in] dst_size - dst buf size
+ * @param[in] src - Deflate compressed data
+ * @param[out] next - next data
+ *
+ * @return decompressed size on success, < 0 on error.
+ */
+int sceDeflateDecompress(void *dst, uint32_t dst_size, const void *src, const void **next);
+int sceDeflateDecompressPartial(void *dst, unsigned int dst_size, const void *src, const void **next, SceDeflatePartialInputParam *cbInfo);
+
+/**
+ * @param[out] ctx - out key data, etc...
+ * @param[in] blocksize - 128 or 192 or 256
+ * @param[in] keysize - 128 or 192 or 256
+ * @param[in] key - key data
+ *
+ * @return 0 on success, < 0 on error.
+ */
+int sceAesInit1(SceAesContext *ctx, int blocksize, int keysize, const void *key);
+int sceAesInit2(SceAesContext *ctx, int blocksize, int keysize, const void *key);
+int sceAesInit3(SceAesContext *ctx, int blocksize, int keysize, const void *key);
+
+int sceAesDecrypt1(SceAesContext *ctx, const void *src, void *dst);
+int sceAesDecrypt2(SceAesContext *ctx, const void *src, void *dst);
+
+int sceAesEncrypt1(SceAesContext *ctx, const void *src, void *dst);
+int sceAesEncrypt2(SceAesContext *ctx, const void *src, void *dst);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PSP2_KERNEL_UTILS_H_ */
diff --git a/include/kernel/lowio/iftu.h b/include/kernel/lowio/iftu.h
new file mode 100644
index 0000000..a03d221
--- /dev/null
+++ b/include/kernel/lowio/iftu.h
@@ -0,0 +1,94 @@
+#ifndef _PSP2_KERN_LOWIO_IFTU_H_
+#define _PSP2_KERN_LOWIO_IFTU_H_
+
+#include <psp2kern/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum SceIftuErrorCode {
+ SCE_IFTU_ERROR_INVALID_PLANE = 0x803F0700,
+ SCE_IFTU_ERROR_INVALID_PARAM = 0x803F0701,
+ SCE_IFTU_ERROR_INVALID_PIXELFORMAT = 0x803F0703,
+ SCE_IFTU_ERROR_PLANE_BUSY = 0x803F0704,
+} SceIftuErrorCode;
+
+typedef enum SceIftuPixelformat {
+ SCE_IFTU_PIXELFORMAT_BGR565 = 0x01,
+ SCE_IFTU_PIXELFORMAT_RGB565 = 0x02,
+ SCE_IFTU_PIXELFORMAT_BGRA5551 = 0x04,
+ SCE_IFTU_PIXELFORMAT_RGBA5551 = 0x08,
+ SCE_IFTU_PIXELFORMAT_BGRX8888 = 0x10,
+ SCE_IFTU_PIXELFORMAT_RGBX8888 = 0x20,
+ SCE_IFTU_PIXELFORMAT_BGRA1010102 = 0x40,
+ SCE_IFTU_PIXELFORMAT_RGBA1010102 = 0x80,
+ SCE_IFTU_PIXELFORMAT_BGRP = 0x100, /* 3 planes - R, G, B */
+ SCE_IFTU_PIXELFORMAT_RGBX8888_MULT = 0x1000,
+ SCE_IFTU_PIXELFORMAT_BGRX8888_MULT = 0x2000,
+ SCE_IFTU_PIXELFORMAT_RGBA1010102_MULT = 0x4000,
+ SCE_IFTU_PIXELFORMAT_BGRA1010102_MULT = 0x8000,
+ SCE_IFTU_PIXELFORMAT_NV12 = 0x10000, /* 2 planes - Y, Cb + Cr interleaved */
+ SCE_IFTU_PIXELFORMAT_YUV420 = 0x20000, /* 3 planes - Y, Cb, Cr */
+ SCE_IFTU_PIXELFORMAT_YUV422 = 0x200000, /* 3 planes - Y, Cb, Cr */
+} SceIftuPixelformat;
+
+typedef struct SceIftuCscParams {
+ unsigned int post_add_0; /* 10-bit integer */
+ unsigned int post_add_1_2; /* 10-bit integer */
+ unsigned int post_clamp_max_0; /* 10-bit integer */
+ unsigned int post_clamp_min_0; /* 10-bit integer */
+ unsigned int post_clamp_max_1_2; /* 10-bit integer */
+ unsigned int post_clamp_min_1_2; /* 10-bit integer */
+ unsigned int ctm[3][3]; /* S3.9 fixed point format */
+} SceIftuCscParams;
+
+typedef struct SceIftuConvParams {
+ unsigned int size;
+ unsigned int unk04;
+ SceIftuCscParams *csc_params1;
+ SceIftuCscParams *csc_params2;
+ unsigned int csc_control;
+ unsigned int unk14;
+ unsigned int unk18;
+ unsigned int unk1C;
+ unsigned int alpha;
+ unsigned int unk24;
+} SceIftuConvParams;
+
+typedef struct SceIftuFrameBuf {
+ unsigned int pixelformat;
+ unsigned int width; /* Aligned to 16 */
+ unsigned int height; /* Aligned to 8 */
+ unsigned int leftover_stride; /* (pitch - aligned_w) * bpp */
+ unsigned int leftover_align; /* if YCbCr: (width >> 1) & 0xF [chroma align?] */
+ unsigned int paddr0; /* Physical address of the first plane */
+ unsigned int paddr1; /* Physical address of the second plane */
+ unsigned int paddr2; /* Physical address of the third plane */
+} SceIftuFrameBuf;
+
+typedef struct SceIftuPlaneState {
+ SceIftuFrameBuf fb;
+ unsigned int unk20; /* not observed to be non-zero */
+ unsigned int unk24; /* not observed to be non-zero */
+ unsigned int unk28; /* not observed to be non-zero */
+ unsigned int src_w; /* inverse scaling factor in 16.16 fixed point, greater than or equal to 0.25 */
+ unsigned int src_h; /* inverse scaling factor in 16.16 fixed point, greater than or equal to 0.25 */
+ unsigned int dst_x; /* offset into the destination buffer */
+ unsigned int dst_y; /* offset into the destination buffer */
+ unsigned int src_x; /* offset into the source buffer in 8.8 fixed point, strictly less than 4.0 */
+ unsigned int src_y; /* offset into the source buffer in 8.8 fixed point, strictly less than 4.0 */
+ unsigned int crop_top;
+ unsigned int crop_bot;
+ unsigned int crop_left;
+ unsigned int crop_right;
+} SceIftuPlaneState;
+
+int sceIftuCsc(SceIftuFrameBuf *dst, SceIftuPlaneState *src, SceIftuConvParams *params);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PSP2_KERN_LOWIO_IFTU_H_ */
+
diff --git a/include/kernel/lowio/pervasive.h b/include/kernel/lowio/pervasive.h
index ef91404..51bb72b 100644
--- a/include/kernel/lowio/pervasive.h
+++ b/include/kernel/lowio/pervasive.h
@@ -4,7 +4,7 @@
#include <psp2kern/types.h>
#ifdef __cplusplus
-"C" {
+extern "C" {
#endif
int scePervasiveUartClockDisable(int port);
diff --git a/include/kernel/net/net.h b/include/kernel/net/net.h
index 5670c96..4ec7e56 100644
--- a/include/kernel/net/net.h
+++ b/include/kernel/net/net.h
@@ -539,15 +539,16 @@ typedef struct SceNetIcmpHeader {
int sceNetSocket(const char *name, int domain, int type, int protocol);
int sceNetAccept(int s, SceNetSockaddr *addr, unsigned int *addrlen);
int sceNetBind(int s, const SceNetSockaddr *addr, unsigned int addrlen);
+int sceNetConnect(int s, const SceNetSockaddr *name, unsigned int namelen);
int sceNetListen(int s, int backlog);
int sceNetRecvfrom(int s, void *buf, unsigned int len, int flags, SceNetSockaddr *from, unsigned int *fromlen);
int sceNetSendto(int s, const void *msg, unsigned int len, int flags, const SceNetSockaddr *to, unsigned int tolen);
+int sceNetSetsockopt(int s, int level, int optname, const void *optval, unsigned int optlen);
+int sceNetClose(int s);
#define sceNetRecv(s, buf, len, flags) sceNetRecvfrom(s, buf, len, flags, NULL, 0)
#define sceNetSend(s, msg, len, flags) sceNetSendto(s, msg, len, flags, NULL, 0)
-
-int sceNetSetsockopt(int s, int level, int optname, const void *optval, unsigned int optlen);
-int sceNetSocketClose(int s);
+#define sceNetSocketClose sceNetClose
/* fixme ? */
#define sceNetHtons __builtin_bswap16
diff --git a/include/kernel/power.h b/include/kernel/power.h
index ed797be..b56731b 100644
--- a/include/kernel/power.h
+++ b/include/kernel/power.h
@@ -8,12 +8,24 @@ extern "C" {
#endif
typedef enum ScePowerCallbackType {
- /** indicates the unit is suspending, seems to occur due to inactivity */
- SCE_POWER_CB_SUSPENDING = 0x00010000,
+ /** indicates the power button was pushed, putting the unit into suspend mode */
+ SCE_POWER_CB_POWER_SWITCH = 0x80000000,
+ /** ? screen on after off ? **/
+ SCE_POWER_CB_UNK_1 = 0x00600000,
+ /** ? screen off ? **/
+ SCE_POWER_CB_UNK_2 = 0x00400000,
+ /** indicates the unit has finish resuming from suspend mode */
+ SCE_POWER_CB_RESUME_COMPLETE = 0x00040000,
/** indicates the unit is resuming from suspend mode */
SCE_POWER_CB_RESUMING = 0x00020000,
- /** indicates the unit has finish resuming from suspend mode */
- SCE_POWER_CB_RESUME_COMPLETE = 0x00040000
+ /** indicates the unit is suspending, seems to occur due to inactivity */
+ SCE_POWER_CB_SUSPENDING = 0x00010000,
+ /** indicates the unit is plugged into an AC outlet */
+ SCE_POWER_CB_AC_POWER = 0x00001000,
+ /** indicates the battery is in low state **/
+ SCE_POWER_CB_LOWBATTERY = 0x00000100,
+ /** indicates there is a battery present in the unit **/
+ SCE_POWER_CB_BATTERY_EXIST = 0x00000080
} ScePowerCallbackType;
/* Callbacks */
@@ -154,6 +166,13 @@ int scePowerGetGpuClockFrequency(void);
int scePowerGetGpuXbarClockFrequency(void);
/**
+ * Requests PS Vita to do a soft reset
+ *
+ * @return always 0
+ */
+int scePowerRequestSoftReset(void);
+
+/**
* Requests PS Vita to do a cold reset
*
* @return always 0
@@ -182,6 +201,16 @@ int scePowerRequestSuspend(void);
int scePowerRequestDisplayOff(void);
/**
+ * Set the screen brightness.
+ * @see ::sceAVConfigSetDisplayBrightness for userland counterpart.
+ *
+ * @param brightness Brightness that the screen will be set to (range 21-65536, 0 turns off the screen).
+ *
+ * @return ?
+ */
+int scePowerSetDisplayBrightness(int brightness);
+
+/**
* Sets CPU clock frequency
*
* @param freq - Frequency to set in Mhz
@@ -217,6 +246,25 @@ int scePowerSetGpuClockFrequency(int freq);
*/
int scePowerSetGpuXbarClockFrequency(int freq);
+/**
+ * Sets the time before idle callback is notified.
+ *
+ * @param callback_slot - Callback slot from 0 to 7.
+ * @param time - Time in microseconds.
+ *
+ * @return 0 on success, < 0 on error
+ */
+int scePowerSetIdleTimer(int callback_slot, SceUInt64 time);
+
+/**
+ * Sets the PS button hold time for showing the quick menu.
+ *
+ * @param time - Time in microseconds.
+ *
+ * @return 0 always
+ */
+int scePowerSetPsButtonPushTime(int time);
+
#ifdef __cplusplus
}
#endif
diff --git a/include/kernel/sblacmgr.h b/include/kernel/sblacmgr.h
index 99621dc..04a182c 100644
--- a/include/kernel/sblacmgr.h
+++ b/include/kernel/sblacmgr.h
@@ -8,6 +8,7 @@ extern "C" {
#endif
int sceSblACMgrIsShell(SceUID pid);
+int sceSblACMgrIsPspEmu(SceUID pid);
int sceSblACMgrIsGameProgram(SceUID pid);
int sceSblACMgrIsNonGameProgram(SceUID pid);
int sceSblACMgrIsDevelopmentMode(void);
diff --git a/include/kernel/sblaimgr.h b/include/kernel/sblaimgr.h
index d809f51..36939ee 100644
--- a/include/kernel/sblaimgr.h
+++ b/include/kernel/sblaimgr.h
@@ -8,6 +8,7 @@ extern "C" {
#endif
int sceSblAimgrGetSMI(void);
+int sceSblAimgrGetTargetId(void);
int sceSblAimgrIsTest(void);
int sceSblAimgrIsTool(void);
int sceSblAimgrIsDEX(void);
diff --git a/include/kernel/syscon.h b/include/kernel/syscon.h
index 225f798..c5bae25 100644
--- a/include/kernel/syscon.h
+++ b/include/kernel/syscon.h
@@ -104,7 +104,7 @@ int sceSysconCmdSync(SceSysconPacket *packet, int noWait);
*
* @return 0 on success.
*/
-int sceSysconResetDevice(int type, int mode);
+int sceSysconSetPowerMode(int type, int mode);
int sceSysconReadCommand(unsigned short cmd, void *buffer, unsigned int size);
int sceSysconSendCommand(unsigned short cmd, const void *buffer, unsigned int size);
@@ -133,7 +133,7 @@ int sceSysconCtrlLED(int led, int enable);
*
* @return 0 on success.
*/
-int sceSysconCtrlMsPower(int power);
+int sceSysconCtrlRMRPower(int power);
/**
* Set the SD power.
@@ -200,6 +200,16 @@ int sceSysconLoadConfigstorageScript(unsigned short, const void *buff, unsigned
int sceSysconVerifyConfigstorageScript(unsigned short, const void *buff, unsigned int size);
/**
+ * Set the alarm callback, that will be ran when the alarm timer is passed.
+ *
+ * @param callback The callback function.
+ * @param argp The second argument that will be passed to the callback.
+ *
+ * @return 0.
+ */
+int sceSysconSetAlarmCallback(SceSysconCallback callback, void *argp);
+
+/**
* Set the low battery callback, that will be ran when the battery is low.
*
* @param callback The callback function.
diff --git a/include/kernel/udcd.h b/include/kernel/udcd.h
index 4490559..25d1e2a 100644
--- a/include/kernel/udcd.h
+++ b/include/kernel/udcd.h
@@ -2,6 +2,7 @@
#define _PSP2_KERNEL_UDCD_H_
#include <psp2kern/types.h>
+#include <dolcesdk/align.h>
#ifdef __cplusplus
extern "C" {
@@ -19,6 +20,7 @@ typedef enum SceUdcdUsbClass {
USB_CLASS_MASS_STORAGE = 0x08,
USB_CLASS_HUB = 0x09,
USB_CLASS_DATA = 0x0A,
+ USB_CLASS_VIDEO = 0x0E,
USB_CLASS_VENDOR_SPEC = 0xFF
} SceUdcdUsbClass;
@@ -193,6 +195,12 @@ typedef enum SceUdcdErrorCode {
SCE_UDCD_ERROR_USBDRIVER_INVALID_FUNCS = 0x80243202
} SceUdcdErrorCode;
+/** SceUdcdDeviceRequest Flags
+ */
+typedef enum SceUdcdDeviceRequestAttr {
+ SCE_UDCD_DEVICE_REQUEST_ATTR_PHYCONT = 0x00000001
+} SceUdcdDeviceRequestAttr;
+
/** USB string descriptor
*/
typedef struct SceUdcdStringDescriptor {
@@ -203,7 +211,7 @@ typedef struct SceUdcdStringDescriptor {
/** USB device descriptor
*/
-typedef struct SceUdcdDeviceDescriptor {
+typedef struct SCE_ALIGN(4) SceUdcdDeviceDescriptor {
unsigned char bLength;
unsigned char bDescriptorType;
unsigned short bcdUSB;
@@ -218,11 +226,11 @@ typedef struct SceUdcdDeviceDescriptor {
unsigned char iProduct;
unsigned char iSerialNumber;
unsigned char bNumConfigurations;
-} __attribute__ ((aligned(4))) SceUdcdDeviceDescriptor;
+} SceUdcdDeviceDescriptor;
/** USB device qualifier descriptor
*/
-typedef struct SceUdcdDeviceQualifierDescriptor {
+typedef struct SCE_ALIGN(4) SceUdcdDeviceQualifierDescriptor {
unsigned char bLength;
unsigned char bDescriptorType;
unsigned short bcdUSB;
@@ -232,7 +240,7 @@ typedef struct SceUdcdDeviceQualifierDescriptor {
unsigned char bMaxPacketSize0;
unsigned char bNumConfigurations;
unsigned char bReserved;
-} __attribute__ ((aligned(4))) SceUdcdDeviceQualifierDescriptor;
+} SceUdcdDeviceQualifierDescriptor;
/** USB configuration descriptor
*/
@@ -355,7 +363,7 @@ typedef struct SceUdcdDriver {
typedef struct SceUdcdDeviceRequest {
SceUdcdEndpoint *endpoint; //!< Pointer to the endpoint to queue request on
void *data; //!< Pointer to the data buffer to use in the request
- unsigned int unk; //!< Unknown data
+ unsigned int attributes; //!< Request attributes (See ::SceUdcdDeviceRequestAttr)
int size; //!< Size of the data buffer
int isControlRequest; //!< Is a control request?
void (*onComplete)(struct SceUdcdDeviceRequest *req); //!< Pointer to the function to call on completion
@@ -368,11 +376,11 @@ typedef struct SceUdcdDeviceRequest {
/** USB driver name
*/
-typedef struct SceUdcdDriverName {
+typedef struct SCE_ALIGN(16) SceUdcdDriverName {
int size;
char name[32];
int flags;
-} __attribute__ ((aligned(16))) SceUdcdDriverName;
+} SceUdcdDriverName;
/** USB device information
*/
@@ -380,9 +388,9 @@ typedef struct SceUdcdDeviceInfo {
unsigned char info[64];
} SceUdcdDeviceInfo;
-typedef struct {
+typedef struct SceUdcdWaitParam {
int unk_00;
- int unk_04;
+ int status;
int unk_08;
int unk_0C;
int unk_10;
@@ -411,6 +419,28 @@ int sceUdcdWaitBusInitialized(unsigned int timeout, int bus);
int sceUdcdStart(const char *driverName, int size, void *args);
/**
+ * Start a USB driver for an UDCD bus.
+ *
+ * @param driverName - Name of the USB driver to start
+ * @param size - Size of arguments to pass to USB driver start
+ * @param args - Arguments to pass to USB driver start
+ * @param[in] bus - UDCD bus (default is 2)
+ *
+ * @return 0 on success, < 0 on error.
+ */
+int sceUdcdStartInternal(const char *driverName, int size, void *args, int bus);
+
+/**
+ * Starts the current USB driver for an UDCD bus.
+ *
+ * @param[in] unused - Unused
+ * @param[in] bus - UDCD bus (default is 2)
+ *
+ * @return 0 on success, < 0 on error.
+ */
+int sceUdcdStartCurrentInternal(int unused, int bus);
+
+/**
* Stop a USB driver.
*
* @param driverName - Name of the USB driver to stop
@@ -422,6 +452,27 @@ int sceUdcdStart(const char *driverName, int size, void *args);
int sceUdcdStop(const char *driverName, int size, void *args);
/**
+ * Stop a USB driver for an UDCD bus.
+ *
+ * @param driverName - Name of the USB driver to stop
+ * @param size - Size of arguments to pass to USB driver start
+ * @param args - Arguments to pass to USB driver start
+ * @param[in] bus - UDCD bus (default is 2)
+ *
+ * @return 0 on success, < 0 on error.
+ */
+int sceUdcdStopInternal(const char *driverName, int size, void *args, int bus);
+
+/**
+ * Stops the current USB driver for an UDCD bus.
+ *
+ * @param[in] bus - UDCD bus (default is 2)
+ *
+ * @return 0 on success, < 0 on error.
+ */
+int sceUdcdStopCurrentInternal(int bus);
+
+/**
* Activate a USB driver.
*
* @param pid - Product ID for the default USB Driver
@@ -431,6 +482,17 @@ int sceUdcdStop(const char *driverName, int size, void *args);
int sceUdcdActivate(unsigned int productId);
/**
+ * Activate a USB driver for an UDCD bus.
+ *
+ * @param pid - Product ID for the default USB Driver
+ * @param[in] bus_powered - Enable USB bus power
+ * @param[in] bus - UDCD bus (default is 2)
+ *
+ * @return 0 on success, < 0 on error.
+ */
+int sceUdcdActivateInternal(unsigned int productId, unsigned int bus_powered, int bus);
+
+/**
* Deactivate USB driver.
*
* @return 0 on success, < 0 on error.
@@ -438,6 +500,15 @@ int sceUdcdActivate(unsigned int productId);
int sceUdcdDeactivate(void);
/**
+ * Deactivate USB driver for an UDCD bus.
+ *
+ * @param[in] bus - UDCD bus (default is 2)
+ *
+ * @return 0 on success, < 0 on error.
+ */
+int sceUdcdDeactivateInternal(int bus);
+
+/**
* Get USB state
*
* @return One or more ::SceUdcdStatus.
@@ -445,6 +516,15 @@ int sceUdcdDeactivate(void);
int sceUdcdGetDeviceState(void);
/**
+ * Get USB state for an UDCD bus
+ *
+ * @param[in] bus - UDCD bus (default is 2)
+ *
+ * @return One or more ::SceUdcdStatus.
+ */
+int sceUdcdGetDeviceStateInternal(int bus);
+
+/**
* Get device information
*
* @param[out] devInfo - Device information
@@ -454,6 +534,16 @@ int sceUdcdGetDeviceState(void);
int sceUdcdGetDeviceInfo(SceUdcdDeviceInfo *devInfo);
/**
+ * Get device information for an UDCD bus
+ *
+ * @param[out] devInfo - Device information
+ * @param[in] bus - UDCD bus (default is 2)
+ *
+ * @return 0 on success, < 0 on error.
+*/
+int sceUdcdGetDeviceInfoInternal(SceUdcdDeviceInfo *devInfo, int bus);
+
+/**
* Get state of a specific USB driver
*
* @param driverName - name of USB driver to get status from
@@ -510,7 +600,7 @@ int sceUdcdRegister(SceUdcdDriver *drv);
*
* @return 0 on success, < 0 on error
*/
-int sceUdcdRegisterToBus(SceUdcdDriver *drv, int bus);
+int sceUdcdRegisterInternal(SceUdcdDriver *drv, int bus);
/**
* Unregister a USB driver
@@ -522,6 +612,16 @@ int sceUdcdRegisterToBus(SceUdcdDriver *drv, int bus);
int sceUdcdUnregister(SceUdcdDriver *drv);
/**
+ * Unregister a USB driver for an UDCD bus
+ *
+ * @param drv - Pointer to a filled out USB driver
+ * @param[in] bus - UDCD bus (default is 2)
+ *
+ * @return 0 on success, < 0 on error
+ */
+int sceUdcdUnregisterInternal(SceUdcdDriver *drv, int bus);
+
+/**
* Clear the FIFO on an endpoint
*
* @param endp - The endpoint to clear
@@ -531,6 +631,16 @@ int sceUdcdUnregister(SceUdcdDriver *drv);
int sceUdcdClearFIFO(SceUdcdEndpoint *endp);
/**
+ * Clear the FIFO on an endpoint for an UDCD bus
+ *
+ * @param endp - The endpoint to clear
+ * @param[in] bus - UDCD bus (default is 2)
+ *
+ * @return 0 on success, < 0 on error
+ */
+int sceUdcdClearFIFOInternal(SceUdcdEndpoint *endp, int bus);
+
+/**
* Cancel any pending requests on an endpoint.
*
* @param endp - The endpoint to cancel
@@ -549,7 +659,17 @@ int sceUdcdReqCancelAll(SceUdcdEndpoint *endp);
int sceUdcdStall(SceUdcdEndpoint *endp);
/**
- * Queue a send request(IN from host pov)
+ * Stall an endpoint for an UDCD bus
+ *
+ * @param endp - The endpoint to stall
+ * @param[in] bus - UDCD bus (default is 2)
+ *
+ * @return 0 on success, < 0 on error
+ */
+int sceUdcdStallInternal(SceUdcdEndpoint *endp, int bus);
+
+/**
+ * Queue a send request (IN from host pov)
*
* @param req - Pointer to a filled out ::SceUdcdDeviceRequest structure.
*
@@ -558,7 +678,17 @@ int sceUdcdStall(SceUdcdEndpoint *endp);
int sceUdcdReqSend(SceUdcdDeviceRequest *req);
/**
- * Queue a receive request(OUT from host pov)
+ * Queue a send request (IN from host pov) for an UDCD bus
+ *
+ * @param req - Pointer to a filled out ::SceUdcdDeviceRequest structure.
+ * @param[in] bus - UDCD bus (default is 2)
+ *
+ * @return 0 on success, < 0 on error
+ */
+int sceUdcdReqSendInternal(SceUdcdDeviceRequest *req, int bus);
+
+/**
+ * Queue a receive request (OUT from host pov)
*
* @param req - Pointer to a filled out ::SceUdcdDeviceRequest structure
*
@@ -566,6 +696,16 @@ int sceUdcdReqSend(SceUdcdDeviceRequest *req);
*/
int sceUdcdReqRecv(SceUdcdDeviceRequest *req);
+/**
+ * Queue a receive request (OUT from host pov) for an UDCD bus
+ *
+ * @param req - Pointer to a filled out ::SceUdcdDeviceRequest structure
+ * @param[in] bus - UDCD bus (default is 2)
+ *
+ * @return 0 on success, < 0 on error
+ */
+int sceUdcdReqRecvInternal(SceUdcdDeviceRequest *req, int bus);
+
#ifdef __cplusplus
}
#endif