summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Anderson2015-08-14 23:27:02 -0400
committerGlenn Anderson2015-08-14 23:27:02 -0400
commit1f6cb4f3cbf7ae615d12c1dd66136347247ab7a6 (patch)
treeca88156373140a2081e64ae091d05555adadad69
downloadvds-libraries-1f6cb4f3cbf7ae615d12c1dd66136347247ab7a6.tar.gz
Initial commit. Added headers from psp2sdk.
-rw-r--r--include/user/appmgr.h92
-rw-r--r--include/user/ctrl.h158
-rw-r--r--include/user/display.h155
-rw-r--r--include/user/io/devctl.h86
-rw-r--r--include/user/kernel/clib.h12
-rw-r--r--include/user/kernel/modulemgr.h43
-rw-r--r--include/user/kernel/processmgr.h80
-rw-r--r--include/user/kernel/sysmem.h63
-rw-r--r--include/user/kernel/threadmgr.h1003
-rw-r--r--include/user/power.h30
-rw-r--r--include/user/pss.h11
-rw-r--r--include/user/sysmodule.h79
12 files changed, 1812 insertions, 0 deletions
diff --git a/include/user/appmgr.h b/include/user/appmgr.h
new file mode 100644
index 0000000..e616b1e
--- /dev/null
+++ b/include/user/appmgr.h
@@ -0,0 +1,92 @@
+#ifndef _PSP2_APPMGR_H_
+#define _PSP2_APPMGR_H_
+
+#include <psp2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+ //! Busy
+ SCE_APPMGR_ERROR_BUSY = 0x80802000,
+
+ //! Invalid state
+ SCE_APPMGR_ERROR_STATE = 0x80802013,
+
+ //! NULL pointer
+ SCE_APPMGR_ERROR_NULL_POINTER = 0x80802016,
+
+ //!< Invalid param
+ SCE_APPMGR_ERROR_INVALID = 0x8080201a,
+
+ //!< Invalid self path
+ SCE_APPMGR_ERROR_INVALID_SELF_PATH = 0x8080201e,
+
+ //!< argv is too long
+ SCE_APPMGR_ERROR_TOO_LONG_ARGV = 0x8080201d
+};
+
+enum {
+ SCE_APPMGR_SYSTEMEVENT_ON_RESUME = 0x10000003,
+ SCE_APPMGR_SYSTEMEVENT_ON_STORE_PURCHASE = 0x10000004,
+ SCE_APPMGR_SYSTEMEVENT_ON_NP_MESSAGE_ARRIVED = 0x10000005,
+ SCE_APPMGR_SYSTEMEVENT_ON_STORE_REDEMPTION = 0x10000006,
+};
+
+enum {
+ SCE_APPMGR_INFOBAR_VISIBILITY_INVISIBLE = 0,
+ SCE_APPMGR_INFOBAR_VISIBILITY_VISIBLE = 1
+};
+
+enum {
+ SCE_APPMGR_INFOBAR_COLOR_BLACK = 0,
+ SCE_APPMGR_INFOBAR_COLOR_WHITE = 1
+};
+
+enum {
+ SCE_APPMGR_INFOBAR_TRANSPARENCY_OPAQUE = 0,
+ SCE_APPMGR_INFOBAR_TRANSPARENCY_TRANSLUCENT = 1
+};
+
+typedef struct SceAppMgrSystemEvent {
+ int systemEvent;
+ uint8_t reserved[60];
+} SceAppMgrSystemEvent;
+
+typedef struct SceAppMgrAppState SceAppMgrAppState; // Missing struct
+typedef struct SceAppMgrExecOptParam SceAppMgrExecOptParam; // Missing struct
+
+#define SCE_APPMGR_MAX_APP_NAME_LENGTH (31)
+
+int _sceAppMgrGetAppState(SceAppMgrAppState *appState, uint32_t len, uint32_t version);
+
+/**
+ * static __inline int sceAppMgrGetAppState(SceAppMgrAppState *appState) {
+ * return _sceAppMgrGetAppState(appState, sizeof(SceAppMgrAppState), version);
+ * };
+ */
+
+int sceAppMgrRecieveSystemEvent(SceAppMgrSystemEvent *systemEvent);
+
+//! Obtains the BGM port, even when it is not in front
+int sceAppMgrAcquireBgmPort(void);
+
+//! Release acquired BGM port
+int sceAppMgrReleaseBgmPort(void);
+
+//! Set infobar state
+int sceAppMgrSetInfobarState(int visibility, int color, int transparency);
+
+typedef struct sceAppMgrLoadExecOptParam {
+ int reserved[256 / 4];
+} sceAppMgrLoadExecOptParam;
+
+int sceAppMgrLoadExec(const char *appPath, char * const argv[],
+ const SceAppMgrExecOptParam *optParam);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PSP2_APPMGR_H_ */
diff --git a/include/user/ctrl.h b/include/user/ctrl.h
new file mode 100644
index 0000000..ca95dd4
--- /dev/null
+++ b/include/user/ctrl.h
@@ -0,0 +1,158 @@
+#ifndef _PSP2_CTRL_H_
+#define _PSP2_CTRL_H_
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+ SCE_CTRL_ERROR_INVALID_ARG = 0x80340001,
+ SCE_CTRL_ERROR_PRIV_REQUIRED = 0x80340002,
+ SCE_CTRL_ERROR_FATAL = 0x803400FF
+};
+
+/** Enumeration for the digital controller buttons. */
+enum {
+ PSP2_CTRL_SELECT = 0x000001, //!< Select button.
+ PSP2_CTRL_START = 0x000008, //!< Start button.
+ PSP2_CTRL_UP = 0x000010, //!< Up D-Pad button.
+ PSP2_CTRL_RIGHT = 0x000020, //!< Right D-Pad button.
+ PSP2_CTRL_DOWN = 0x000040, //!< Down D-Pad button.
+ PSP2_CTRL_LEFT = 0x000080, //!< Left D-Pad button.
+ PSP2_CTRL_LTRIGGER = 0x000100, //!< Left trigger.
+ PSP2_CTRL_RTRIGGER = 0x000200, //!< Right trigger.
+ PSP2_CTRL_TRIANGLE = 0x001000, //!< Triangle button.
+ PSP2_CTRL_CIRCLE = 0x002000, //!< Circle button.
+ PSP2_CTRL_CROSS = 0x004000, //!< Cross button.
+ PSP2_CTRL_SQUARE = 0x008000, //!< Square button.
+ PSP2_CTRL_ANY = 0x010000 //!< Any input intercepted.
+};
+
+/** Controller mode. */
+enum {
+ /** Digitial buttons only. */
+ PSP2_CTRL_MODE_DIGITAL = 0,
+ /** Digital buttons + Analog support. */
+ PSP2_CTRL_MODE_ANALOG,
+ /** Same as ::PSP2_CTRL_MODE_ANALOG, but with larger range for analog sticks. */
+ PSP2_CTRL_MODE_ANALOG_WIDE
+};
+
+/** Returned controller data */
+typedef struct SceCtrlData {
+ /** The current read frame. */
+ uint64_t timeStamp;
+ /** Bit mask containing zero or more of ::CtrlButtons. */
+ unsigned int buttons;
+ /** Left analogue stick, X axis. */
+ unsigned char lx;
+ /** Left analogue stick, Y axis. */
+ unsigned char ly;
+ /** Right analogue stick, X axis. */
+ unsigned char rx;
+ /** Right analogue stick, Y axis. */
+ unsigned char ry;
+ /** Reserved. */
+ uint8_t reserved[16];
+} SceCtrlData;
+
+/** Structure to pass as argument to ::sceCtrlSetRapidFire */
+typedef struct SceCtrlRapidFireRule {
+ unsigned int Mask;
+ unsigned int Trigger;
+ unsigned int Target;
+ unsigned int Delay;
+ unsigned int Make;
+ unsigned int Break;
+} SceCtrlRapidFireRule;
+
+/**
+ * Set the controller mode.
+ *
+ * @param[in] mode - One of ::CtrlMode.
+ *
+ * @return The previous mode, <0 on error.
+ */
+int sceCtrlSetSamplingMode(int mode);
+
+/**
+ * Get the current controller mode.
+ *
+ * @param[out] pMode - Return value, see ::CtrlMode.
+ *
+ * @return The current mode, <0 on error.
+ */
+int sceCtrlGetSamplingMode(int *pMode);
+
+/**
+ * Get the controller state information (polling, positive logic).
+ *
+ * @param[in] port - use 0.
+ * @param[out] *pad_data - see ::SceCtrlData.
+ * @param[in] count - Buffers count.
+ *
+ * @return Buffers count, between 1 and 'count'. <0 on error.
+ */
+int sceCtrlPeekBufferPositive(int port, SceCtrlData *pad_data, int count);
+
+/**
+ * Get the controller state information (polling, negative logic).
+ *
+ * @param[in] port - use 0.
+ * @param[out] *pad_data - see ::SceCtrlData.
+ * @param[in] count - Buffers count.
+ *
+ * @return Buffers count, between 1 and 'count'. <0 on error.
+ */
+int sceCtrlPeekBufferNegative(int port, SceCtrlData *pad_data, int count);
+
+/**
+ * Get the controller state information (blocking, positive logic).
+ *
+ * @param[in] port - use 0.
+ * @param[out] *pad_data - see ::SceCtrlData.
+ * @param[in] count - Buffers count.
+ *
+ * @return Buffers count, between 1 and 'count'. <0 on error.
+ */
+int sceCtrlReadBufferPositive(int port, SceCtrlData *pad_data, int count);
+
+/**
+ * Get the controller state information (blocking, negative logic).
+ *
+ * @param[in] port - use 0.
+ * @param[out] *pad_data - see ::SceCtrlData.
+ * @param[in] count - Buffers count.
+ *
+ * @return Buffers count, between 1 and 'count'. <0 on error.
+ */
+int sceCtrlReadBufferNegative(int port, SceCtrlData *pad_data, int count);
+
+/**
+ * Set rules for button rapid fire
+ *
+ * @param[in] port - use 0.
+ * @param[in] idx - rule index between 0-15
+ * @param[in] pRule - structure ::SceCtrlRapidFireRule.
+ *
+ * @return 0, <0 on error.
+ */
+int sceCtrlSetRapidFire(int port, int idx, const SceCtrlRapidFireRule* pRule);
+
+/**
+ * Clear rules for button rapid fire
+ *
+ * @param[in] port - use 0.
+ * @param[in] idx - rule index between 0-15
+ *
+ * @return 0, <0 on error.
+ */
+int sceCtrlClearRapidFire(int port, int idx);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PSP2CTRL_H_ */
diff --git a/include/user/display.h b/include/user/display.h
new file mode 100644
index 0000000..a0aa1e5
--- /dev/null
+++ b/include/user/display.h
@@ -0,0 +1,155 @@
+#ifndef _PSP2_DISPLAY_H_
+#define _PSP2_DISPLAY_H_
+
+#include <psp2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+ SCE_DISPLAY_ERROR_OK = 0,
+ SCE_DISPLAY_ERROR_INVALID_HEAD = 0x80290000,
+ SCE_DISPLAY_ERROR_INVALID_VALUE = 0x80290001,
+ SCE_DISPLAY_ERROR_INVALID_ADDR = 0x80290002,
+ SCE_DISPLAY_ERROR_INVALID_PIXELFORMAT = 0x80290003,
+ SCE_DISPLAY_ERROR_INVALID_PITCH = 0x80290004,
+ SCE_DISPLAY_ERROR_INVALID_RESOLUTION = 0x80290005,
+ SCE_DISPLAY_ERROR_INVALID_UPDATETIMING = 0x80290006,
+ SCE_DISPLAY_ERROR_NO_FRAME_BUFFER = 0x80290007,
+ SCE_DISPLAY_ERROR_NO_PIXEL_DATA = 0x80290008
+};
+
+#define PSP2_DISPLAY_PIXELFORMAT_A8B8G8R8 0x00000000U
+
+enum {
+ /** Buffer change effective immediately */
+ PSP2_DISPLAY_SETBUF_IMMEDIATE = 0,
+ /** Buffer change effective next frame */
+ PSP2_DISPLAY_SETBUF_NEXTFRAME = 1
+};
+
+/**
+ * Structure used with sceDisplaySetFrameBuf to set/update framebuffer.
+ * Original screen resolution is 960x544, but the following resolutions
+ * can also be supplied as width and height :
+ * 480x272, 640x368, 720x408
+ *
+ * @note - This structure is returned by sceDisplayGetFrameBuf
+*/
+typedef struct SceDisplayFrameBuf {
+ SceSize size; //!< sizeof(SceDisplayFrameBuf)
+ void *base; //!< Pointer to framebuffer
+ unsigned int pitch; //!< pitch pixels
+ unsigned int pixelformat; //!< use PSP2_DISPLAY_PIXELFORMAT_A8B8G8R8
+ unsigned int width; //!< framebuffer width
+ unsigned int height; //!< framebuffer height
+} SceDisplayFrameBuf;
+
+/**
+ * Set/Update framebuffer parameters
+ *
+ * @param[in] pParam - Pointer to a ::SceDisplayFrameBuf structure.
+ * @param[in] sync - One of ::DisplaySetBufSync
+ *
+ * @return 0 on success, < 0 on error.
+ * @note - If NULL is provided as pParam pointer, output is blacked out.
+*/
+int sceDisplaySetFrameBuf(const SceDisplayFrameBuf *pParam, int sync);
+
+/**
+ * Get current framebuffer parameters
+ *
+ * @param[out] pParam - Pointer to a ::SceDisplayFrameBuf structure
+ * which will receive framebuffer parameters.
+ *
+ * @param[in] sync - One of ::DisplaySetBufSync
+ *
+ * @return 0 on success, < 0 on error.
+*/
+int sceDisplayGetFrameBuf(SceDisplayFrameBuf *pParam, int sync);
+
+/**
+ * Get current number of fps for the current screen mode.
+ *
+ * @param[out] pFps - Pointer to a float variable to store current number of fps.
+ *
+ * @return 0 on success, < 0 on error.
+ * @note - This function returns a theoretical value, this might not be the exact frame rate.
+*/
+int sceDisplayGetRefreshRate(float *pFps);
+
+/**
+ * Number of vertical blank pulses up to now
+ */
+int sceDisplayGetVcount(void);
+
+/**
+ * Wait for vertical blank start
+ */
+int sceDisplayWaitVblankStart(void);
+
+/**
+ * Wait for vertical blank start with callback
+ */
+int sceDisplayWaitVblankStartCB(void);
+
+/**
+ * Wait for vertical blank start after specified number of vertical periods
+ *
+ * @param[in] vcount - Number of vertical periods before waiting for vertical blank start
+ */
+int sceDisplayWaitVblankStartMulti(unsigned int vcount);
+
+/**
+ * Wait for vertical blank start with callback after specified number of vertical periods
+ *
+ * @param[in] vcount - Number of vertical periods before waiting for vertical blank start
+ */
+int sceDisplayWaitVblankStartMultiCB(unsigned int vcount);
+
+/**
+ * Wait for vertical blank start since last update of framebuffer
+ */
+int sceDisplayWaitSetFrameBuf(void);
+
+/**
+ * Wait for vertical blank start with callback since last update of framebuffer
+ */
+int sceDisplayWaitSetFrameBufCB(void);
+
+/**
+ * Wait for vertical blank start after specified number of vertical periods
+ * since last update of framebuffer.
+ *
+ * @param[in] vcount - Number of vertical periods before waiting for vertical blank start
+ */
+int sceDisplayWaitSetFrameBufMulti(unsigned int vcount);
+
+/**
+ * Wait for vertical blank start with callback after specified number of vertical periods
+ * since last update of framebuffer.
+ *
+ * @param[in] vcount - Number of vertical periods before waiting for vertical blank start
+ */
+int sceDisplayWaitSetFrameBufMultiCB(unsigned int vcount);
+
+/**
+ * Register callback to be used at each vertical blank start
+ *
+ * @param[in] uid - Callback UID
+ */
+int sceDisplayRegisterVblankStartCallback(SceUID uid);
+
+/**
+ * Unregister callback used at each vertical blank start
+ *
+ * @param[in] uid - Callback UID
+ */
+int sceDisplayUnregisterVblankStartCallback(SceUID uid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PSP2_DISPLAY_H_ */
diff --git a/include/user/io/devctl.h b/include/user/io/devctl.h
new file mode 100644
index 0000000..5237ac9
--- /dev/null
+++ b/include/user/io/devctl.h
@@ -0,0 +1,86 @@
+#ifndef _PSP2_IO_DEVCTRL_H_
+#define _PSP2_IO_DEVCTRL_H_
+
+#include <psp2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Send a devctl command to a device.
+ *
+ * @par Example: Sending a simple command to a device (not a real devctl)
+ * @code
+ * sceIoDevctl("ms0:", 0x200000, indata, 4, NULL, NULL);
+ * @endcode
+ *
+ * @param dev - String for the device to send the devctl to (e.g. "ms0:")
+ * @param cmd - The command to send to the device
+ * @param indata - A data block to send to the device, if NULL sends no data
+ * @param inlen - Length of indata, if 0 sends no data
+ * @param outdata - A data block to receive the result of a command, if NULL receives no data
+ * @param outlen - Length of outdata, if 0 receives no data
+ * @return 0 on success, < 0 on error
+ */
+int sceIoDevctl(const char *dev, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen);
+
+/**
+ * Assigns one IO device to another (I guess)
+ * @param dev1 - The device name to assign.
+ * @param dev2 - The block device to assign from.
+ * @param dev3 - The filesystem device to mape the block device to dev1
+ * @param mode - Read/Write mode. One of IoAssignPerms.
+ * @param unk1 - Unknown, set to NULL.
+ * @param unk2 - Unknown, set to 0.
+ * @return < 0 on error.
+ *
+ * @par Example: Reassign flash0 in read/write mode.
+ * @code
+ * sceIoUnassign("flash0");
+ * sceIoAssign("flash0", "lflash0:0,0", "flashfat0:", IOASSIGN_RDWR, NULL, 0);
+ * @endcode
+ *
+ */
+int sceIoAssign(const char *dev1, const char *dev2, const char *dev3, int mode, void* unk1, long unk2);
+
+/**
+ * Unassign an IO device.
+ * @param dev - The device to unassign.
+ * @return < 0 on error
+ *
+ * @par Example: See ::sceIoAssign
+ */
+int sceIoUnassign(const char *dev);
+
+/**
+ * Perform an ioctl on a device.
+ *
+ * @param fd - Opened file descriptor to ioctl to
+ * @param cmd - The command to send to the device
+ * @param indata - A data block to send to the device, if NULL sends no data
+ * @param inlen - Length of indata, if 0 sends no data
+ * @param outdata - A data block to receive the result of a command, if NULL receives no data
+ * @param outlen - Length of outdata, if 0 receives no data
+ * @return 0 on success, < 0 on error
+ */
+int sceIoIoctl(SceUID fd, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen);
+
+/**
+ * Perform an ioctl on a device. (asynchronous)
+ *
+ * @param fd - Opened file descriptor to ioctl to
+ * @param cmd - The command to send to the device
+ * @param indata - A data block to send to the device, if NULL sends no data
+ * @param inlen - Length of indata, if 0 sends no data
+ * @param outdata - A data block to receive the result of a command, if NULL receives no data
+ * @param outlen - Length of outdata, if 0 receives no data
+ * @return 0 on success, < 0 on error
+ */
+int sceIoIoctlAsync(SceUID fd, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PSP2_IO_DEVCTRL_H_ */
diff --git a/include/user/kernel/clib.h b/include/user/kernel/clib.h
new file mode 100644
index 0000000..7f3ec34
--- /dev/null
+++ b/include/user/kernel/clib.h
@@ -0,0 +1,12 @@
+#ifndef _PSP2_KERNEL_CLIB_H_
+#define _PSP2_KERNEL_CLIB_H_
+
+#include <psp2/types.h>
+#include <stdarg.h>
+
+int sceClibStrcmp(const char *, const char *);
+
+int sceClibSnprintf(char *, SceSize, const char *, ...);
+int sceClibVsnprintf(char *, SceSize, const char *, va_list);
+
+#endif
diff --git a/include/user/kernel/modulemgr.h b/include/user/kernel/modulemgr.h
new file mode 100644
index 0000000..f948b69
--- /dev/null
+++ b/include/user/kernel/modulemgr.h
@@ -0,0 +1,43 @@
+#ifndef _PSP2_KERNEL_MODULEMGR_H_
+#define _PSP2_KERNEL_MODULEMGR_H_
+
+#include <psp2/types.h>
+
+typedef struct
+{
+ SceUInt size; //< this structure size (0x18)
+ SceUInt perms; //< probably rwx in low bits
+ void *vaddr; //< address in memory
+ SceUInt memsz; //< size in memory
+ SceUInt flags; //< meanig unknown
+ SceUInt res; //< unused?
+} Psp2SegmentInfo;
+
+typedef struct
+{
+ SceUInt size; //< 0x1B8 for Vita 1.x
+ SceUInt handle; //< kernel module handle?
+ SceUInt flags; //< some bits. could be priority or whatnot
+ char module_name[28];
+ SceUInt unk28;
+ void *module_start;
+ SceUInt unk30;
+ void *module_stop;
+ void *exidxTop;
+ void *exidxBtm;
+ SceUInt unk40;
+ SceUInt unk44;
+ void *tlsInit;
+ SceSize tlsInitSize;
+ SceSize tlsAreaSize;
+ char path[256];
+ Psp2SegmentInfo segments[4];
+ SceUInt type; //< 6 = user-mode PRX?
+} Psp2LoadedModuleInfo;
+
+int sceKernelGetModuleList(int, SceUID *, unsigned int *);
+int sceKernelGetModuleInfo(SceUID, Psp2LoadedModuleInfo *);
+SceUID sceKernelLoadModule(const char *path, int flags, int *res);
+int sceKernelUnloadModule(SceUID);
+
+#endif
diff --git a/include/user/kernel/processmgr.h b/include/user/kernel/processmgr.h
new file mode 100644
index 0000000..e5e2a12
--- /dev/null
+++ b/include/user/kernel/processmgr.h
@@ -0,0 +1,80 @@
+#ifndef _PSP2_KERNEL_PROCESSMGR_H_
+#define _PSP2_KERNEL_PROCESSMGR_H_
+
+#include <psp2/kernel/threadmgr.h>
+#include <psp2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+ PSP2_KERNEL_PROCESS_PRIORITY_SYSTEM_HIGH = 32,
+ PSP2_KERNEL_PROCESS_PRIORITY_SYSTEM_DEFAULT = 96,
+ PSP2_KERNEL_PROCESS_PRIORITY_SYSTEM_LOW = 159
+};
+
+enum {
+ PSP2_KERNEL_PROCESS_PRIORITY_USER_HIGH = 64,
+ PSP2_KERNEL_PROCESS_PRIORITY_USER_DEFAULT = 96,
+ PSP2_KERNEL_PROCESS_PRIORITY_USER_LOW = 127
+};
+
+enum {
+ /** Cancel all timers */
+ PSP2_KERNEL_POWER_TICK_DEFAULT = 0,
+ /** Cancel automatic suspension timer */
+ PSP2_KERNEL_POWER_TICK_DISABLE_AUTO_SUSPEND = 1,
+ /** Cancel OLED-off timer */
+ PSP2_KERNEL_POWER_TICK_DISABLE_OLED_OFF = 4,
+ /** Cancel OLED dimming timer */
+ PSP2_KERNEL_POWER_TICK_DISABLE_OLED_DIMMING = 6
+};
+
+/***
+ * Exit current Process with specified return code
+ *
+ * @param[in] res - Exit code to return
+ *
+ * @return 0 on success, < 0 on error.
+ * @note - If NULL is provided as FrameBuf pointer, output is blacked out.
+*/
+int sceKernelExitProcess(int res);
+
+/***
+ * Cancel specified idle timers to prevent entering in power save processing.
+ *
+ * @param[in] type - One of ::KernelPowerTickType
+ *
+ * @return 0
+*/
+int sceKernelPowerTick(int type);
+
+/***
+ * Get the process time of the current process.
+ *
+ * @param[out] type - Pointer to a ::SceKernelSysClock structure which will receive the process time.
+ *
+ * @return 0 on success, < 0 on error.
+*/
+int sceKernelGetProcessTime(SceKernelSysClock *pSysClock);
+
+/***
+ * Get the lower 32 bits part of process time of the current process.
+ *
+ * @return process time of the current process
+*/
+SceUInt32 sceKernelGetProcessTimeLow(void);
+
+/***
+ * Get the process time of the current process.
+ *
+ * @return process time of the current process
+*/
+SceUInt64 sceKernelGetProcessTimeWide(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PSP2_KERNEL_PROCESSMGR_H_ */
diff --git a/include/user/kernel/sysmem.h b/include/user/kernel/sysmem.h
new file mode 100644
index 0000000..5c258f0
--- /dev/null
+++ b/include/user/kernel/sysmem.h
@@ -0,0 +1,63 @@
+#ifndef _PSP2_KERNEL_SYSMEM_H_
+#define _PSP2_KERNEL_SYSMEM_H_
+
+#include <psp2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef int SceKernelMemBlockType;
+
+enum {
+ SCE_KERNEL_MEMBLOCK_TYPE_USER_RW = 0x0c20d060,
+ SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE = 0x0c208060,
+ SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_RW = 0x0c80d060,
+ SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_NC_RW = 0x0d808060,
+ SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW = 0x09408060
+};
+
+/***
+ * Allocates a new memoy block
+ *
+ * @param[in] name - Name for the memory block
+ * @param[in] type - Type of the memory to allocate
+ * @param[in] size - Size of the memory to allocate
+ * @param[in] optp - Memory block options?
+ *
+ * @return SceUID of the memory block on success, < 0 on error.
+*/
+SceUID sceKernelAllocMemBlock(const char *name, SceKernelMemBlockType type, int size, void *optp);
+
+SceUID sceKernelAllocMemBlockForVM(const char *, SceSize);
+
+/***
+ * Frees new memoy block
+ *
+ * @param[in] uid - SceUID of the memory block to free
+ *
+ * @return 0 on success, < 0 on error.
+*/
+int sceKernelFreeMemBlock(SceUID uid);
+
+/***
+ * Gets the base address of a memoy block
+ *
+ * @param[in] uid - SceUID of the memory block to free
+ * @param[out] basep - Base address of the memory block identified by SceUID
+ *
+ * @return 0 on success, < 0 on error.
+*/
+int sceKernelGetMemBlockBase(SceUID uid, void **basep);
+
+SceUID sceKernelFindMemBlockByAddr(const void *, int);
+
+void sceKernelSyncVMDomain(SceUID, void *, SceSize);
+void sceKernelOpenVMDomain();
+void sceKernelCloseVMDomain();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/user/kernel/threadmgr.h b/include/user/kernel/threadmgr.h
new file mode 100644
index 0000000..ea2513a
--- /dev/null
+++ b/include/user/kernel/threadmgr.h
@@ -0,0 +1,1003 @@
+#ifndef _PSP2_KERNEL_THREADMGR_H_
+#define _PSP2_KERNEL_THREADMGR_H_
+
+#include <psp2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** 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. */
+ SceSize size;
+ /** Attributes */
+ SceUInt32 attr;
+} SceKernelThreadOptParam;
+
+/** Structure to hold the status information for a thread
+ * @see sceKernelGetThreadInfo
+ */
+typedef struct SceKernelThreadInfo {
+ /** Size of the structure */
+ SceSize size;
+ /** The UID of the process where the thread belongs */
+ SceUID processId; //Needs confirmation
+ /** Nul terminated name of the thread */
+ char name[32];
+ /** Thread attributes */
+ SceUInt attr;
+ /** Thread status */
+ int status;
+ /** Thread entry point */
+ SceKernelThreadEntry entry;
+ /** Thread stack pointer */
+ void *stack;
+ /** Thread stack size */
+ int stackSize;
+ /** Initial priority */
+ int initPriority;
+ /** Current priority */
+ int currentPriority;
+ /** Initial CPU affinity mask */
+ int initCpuAffinityMask;
+ /** Current CPU affinity mask */
+ int currentCpuAffinityMask;
+ /** Current CPU ID */
+ int currentCpuId;
+ /** Last executed CPU ID */
+ int lastExecutedCpuId;
+ /** Wait type */
+ int waitType;
+ /** Wait id */
+ SceUID waitId;
+ /** Exit status of the thread */
+ int exitStatus;
+ /** Number of clock cycles run */
+ SceKernelSysClock runClocks;
+ /** Interrupt preemption count */
+ SceUInt intrPreemptCount;
+ /** Thread preemption count */
+ SceUInt threadPreemptCount;
+ /** Thread release count */
+ SceUInt threadReleaseCount;
+ /** Function notify callback UID */
+ SceUID fNotifyCallback;
+ /** Reserved */
+ int reserved;
+} SceKernelThreadInfo;
+
+/** Statistics about a running thread.
+ * @see sceKernelGetThreadRunStatus.
+ */
+typedef struct SceKernelThreadRunStatus {
+ SceSize size;
+ struct {
+ SceUID processId;
+ SceUID threadId;
+ int priority;
+ } cpuInfo[4];
+} SceKernelThreadRunStatus;
+
+/* Sure there must be more than this, but haven't seen them */
+typedef enum Psp2ThreadStatus
+{
+ PSP2_THREAD_RUNNING = 1,
+ PSP2_THREAD_READY = 2,
+ PSP2_THREAD_WAITING = 4,
+ PSP2_THREAD_SUSPEND = 8,
+ PSP2_THREAD_STOPPED = 16,
+ PSP2_THREAD_KILLED = 32, /* Thread manager has killed the thread (stack overflow) */
+} Psp2ThreadStatus;
+
+/**
+ * Create a thread
+ *
+ * @par Example:
+ * @code
+ * SceUID thid;
+ * thid = sceKernelCreateThread("my_thread", threadFunc, 0x10000100, 0x10000, 0, 0, NULL);
+ * @endcode
+ *
+ * @param name - An arbitrary thread name.
+ * @param entry - The thread function to run when started.
+ * @param initPriority - The initial priority of the thread. Less if higher priority.
+ * @param stackSize - The size of the initial stack.
+ * @param attr - The thread attributes, zero or more of ::Psp2ThreadAttributes.
+ * @param cpuAffinityMask - The CPU affinity mask
+ * @param option - Additional options specified by ::SceKernelThreadOptParam.
+
+ * @return UID of the created thread, or an error code.
+ */
+SceUID sceKernelCreateThread(const char *name, SceKernelThreadEntry entry, int initPriority,
+ int stackSize, SceUInt attr, int cpuAffinityMask,
+ const SceKernelThreadOptParam *option);
+
+/**
+ * Delate a thread
+ *
+ * @param thid - UID of the thread to be deleted.
+ *
+ * @return < 0 on error.
+ */
+int sceKernelDeleteThread(SceUID thid);
+
+/**
+ * Start a created thread
+ *
+ * @param thid - Thread id from sceKernelCreateThread
+ * @param arglen - Length of the data pointed to by argp, in bytes
+ * @param argp - Pointer to the arguments.
+ */
+int sceKernelStartThread(SceUID thid, SceSize arglen, void *argp);
+
+/**
+ * Exit a thread
+ *
+ * @param status - Exit status.
+ */
+int sceKernelExitThread(int status);
+
+/**
+ * Exit a thread and delete itself.
+ *
+ * @param status - Exit status
+ */
+int sceKernelExitDeleteThread(int status);
+
+/**
+ * Wait until a thread has ended.
+ *
+ * @param thid - Id of the thread to wait for.
+ * @param stat - Exit status.
+ * @param timeout - Timeout in microseconds (assumed).
+ *
+ * @return < 0 on error.
+ */
+int sceKernelWaitThreadEnd(SceUID thid, int *stat, SceUInt *timeout);
+
+/**
+ * Wait until a thread has ended and handle callbacks if necessary.
+ *
+ * @param thid - Id of the thread to wait for.
+ * @param stat - Exit status.
+ * @param timeout - Timeout in microseconds (assumed).
+ *
+ * @return < 0 on error.
+ */
+int sceKernelWaitThreadEndCB(SceUID thid, int *stat, SceUInt *timeout);
+
+/**
+ * Delay the current thread by a specified number of microseconds
+ *
+ * @param delay - Delay in microseconds.
+ *
+ * @par Example:
+ * @code
+ * sceKernelDelayThread(1000000); // Delay for a second
+ * @endcode
+ */
+int sceKernelDelayThread(SceUInt delay);
+
+/**
+ * Delay the current thread by a specified number of microseconds and handle any callbacks.
+ *
+ * @param delay - Delay in microseconds.
+ *
+ * @par Example:
+ * @code
+ * sceKernelDelayThread(1000000); // Delay for a second
+ * @endcode
+ */
+int sceKernelDelayThreadCB(SceUInt delay);
+
+/**
+ * Modify the attributes of the current thread.
+ *
+ * @param unknown - Set to 0.
+ * @param attr - The thread attributes to modify. One of ::Psp2ThreadAttributes.
+ *
+ * @return < 0 on error.
+ */
+int sceKernelChangeCurrentThreadAttr(int unknown, SceUInt attr);
+
+/**
+ * Change the threads current priority.
+ *
+ * @param thid - The ID of the thread (from sceKernelCreateThread or sceKernelGetThreadId)
+ * @param priority - The new priority (the lower the number the higher the priority)
+ *
+ * @par Example:
+ * @code
+ * int thid = sceKernelGetThreadId();
+ * // Change priority of current thread to 16
+ * sceKernelChangeThreadPriority(thid, 16);
+ * @endcode
+ *
+ * @return 0 if successful, otherwise the error code.
+ */
+int sceKernelChangeThreadPriority(SceUID thid, int priority);
+
+/**
+ * Rotate thread ready queue at a set priority
+ *
+ * @param priority - The priority of the queue
+ *
+ * @return 0 on success, < 0 on error.
+ */
+int sceKernelRotateThreadReadyQueue(int priority);
+
+/**
+ * Release a thread in the wait state.
+ *
+ * @param thid - The UID of the thread.
+ *
+ * @return 0 on success, < 0 on error
+ */
+int sceKernelReleaseWaitThread(SceUID thid);
+
+/**
+ * Get the current thread Id
+ *
+ * @return The thread id of the calling thread.
+ */
+int sceKernelGetThreadId(void);
+
+/**
+ * Get the current priority of the thread you are in.
+ *
+ * @return The current thread priority
+ */
+int sceKernelGetThreadCurrentPriority(void);
+
+/**
+ * Get the exit status of a thread.
+ *
+ * @param thid - The UID of the thread to check.
+ *
+ * @return The exit status
+ */
+int sceKernelGetThreadExitStatus(SceUID thid);
+
+/**
+ * Check the thread stack?
+ *
+ * @return Unknown.
+ */
+int sceKernelCheckThreadStack(void);
+
+/**
+ * Get the free stack size for a thread.
+ *
+ * @param thid - The thread ID. Seem to take current thread
+ * if set to 0.
+ *
+ * @return The free size.
+ */
+int sceKernelGetThreadStackFreeSize(SceUID thid);
+
+/**
+ * Get the status information for the specified thread.
+ *
+ * @param thid - Id of the thread to get status
+ * @param info - Pointer to the info structure to receive the data.
+ * Note: The structures size field should be set to
+ * sizeof(SceKernelThreadInfo) before calling this function.
+ *
+ * @par Example:
+ * @code
+ * SceKernelThreadInfo status;
+ * status.size = sizeof(SceKernelThreadInfo);
+ * if(sceKernelGetThreadInfo(thid, &status) == 0)
+ * { Do something... }
+ * @endcode
+ * @return 0 if successful, otherwise the error code.
+ */
+int sceKernelGetThreadInfo(SceUID thid, SceKernelThreadInfo *info);
+
+/**
+ * Retrive the runtime status of a thread.
+ *
+ * @param thid - UID of the thread to retrive status.
+ * @param status - Pointer to a ::SceKernelThreadRunStatus struct to receive the runtime status.
+ *
+ * @return 0 if successful, otherwise the error code.
+ */
+int sceKernelGetThreadRunStatus(SceUID thid, SceKernelThreadRunStatus *status);
+
+
+/* Semaphores. */
+
+/** Additional options used when creating semaphores. */
+typedef struct SceKernelSemaOptParam {
+ /** Size of the ::SceKernelSemaOptParam structure. */
+ SceSize size;
+} SceKernelSemaOptParam;
+
+/** Current state of a semaphore.
+ * @see sceKernelGetSemaInfo.
+ */
+typedef struct SceKernelSemaInfo {
+ /** Size of the ::SceKernelSemaInfo structure. */
+ SceSize size;
+ /** The UID of the semaphore */
+ SceUID semaId;
+ /** NUL-terminated name of the semaphore. */
+ char name[32];
+ /** Attributes. */
+ SceUInt attr;
+ /** The initial count the semaphore was created with. */
+ int initCount;
+ /** The current count. */
+ int currentCount;
+ /** The maximum count. */
+ int maxCount;
+ /** The number of threads waiting on the semaphore. */
+ int numWaitThreads;
+} SceKernelSemaInfo;
+
+/**
+ * Creates a new semaphore
+ *
+ * @par Example:
+ * @code
+ * int semaid;
+ * semaid = sceKernelCreateSema("MyMutex", 0, 1, 1, 0);
+ * @endcode
+ *
+ * @param name - Specifies the name of the sema
+ * @param attr - Sema attribute flags (normally set to 0)
+ * @param initVal - Sema initial value
+ * @param maxVal - Sema maximum value
+ * @param option - Sema options (normally set to 0)
+ * @return A semaphore id
+ */
+SceUID sceKernelCreateSema(const char *name, SceUInt attr, int initVal, int maxVal, SceKernelSemaOptParam *option);
+
+/**
+ * Destroy a semaphore
+ *
+ * @param semaid - The semaid returned from a previous create call.
+ * @return Returns the value 0 if its succesful otherwise -1
+ */
+int sceKernelDeleteSema(SceUID semaid);
+
+/**
+ * Send a signal to a semaphore
+ *
+ * @par Example:
+ * @code
+ * // Signal the sema
+ * sceKernelSignalSema(semaid, 1);
+ * @endcode
+ *
+ * @param semaid - The sema id returned from sceKernelCreateSema
+ * @param signal - The amount to signal the sema (i.e. if 2 then increment the sema by 2)
+ *
+ * @return < 0 On error.
+ */
+int sceKernelSignalSema(SceUID semaid, int signal);
+
+/**
+ * Lock a semaphore
+ *
+ * @par Example:
+ * @code
+ * sceKernelWaitSema(semaid, 1, 0);
+ * @endcode
+ *
+ * @param semaid - The sema id returned from sceKernelCreateSema
+ * @param signal - The value to wait for (i.e. if 1 then wait till reaches a signal state of 1)
+ * @param timeout - Timeout in microseconds (assumed).
+ *
+ * @return < 0 on error.
+ */
+int sceKernelWaitSema(SceUID semaid, int signal, SceUInt *timeout);
+
+/**
+ * Lock a semaphore and handle callbacks if necessary.
+ *
+ * @par Example:
+ * @code
+ * sceKernelWaitSemaCB(semaid, 1, 0);
+ * @endcode
+ *
+ * @param semaid - The sema id returned from sceKernelCreateSema
+ * @param signal - The value to wait for (i.e. if 1 then wait till reaches a signal state of 1)
+ * @param timeout - Timeout in microseconds (assumed).
+ *
+ * @return < 0 on error.
+ */
+int sceKernelWaitSemaCB(SceUID semaid, int signal, SceUInt *timeout);
+
+/**
+ * Poll a sempahore.
+ *
+ * @param semaid - UID of the semaphore to poll.
+ * @param signal - The value to test for.
+ *
+ * @return < 0 on error.
+ */
+int sceKernelPollSema(SceUID semaid, int signal);
+
+/**
+ * Cancels a semaphore
+ *
+ * @param semaid - The sema id returned from sceKernelCreateSema
+ * @param setCount - The new lock count of the semaphore
+ * @param numWaitThreads - Number of threads waiting for the semaphore
+ * @return < 0 On error.
+ */
+int sceKernelCancelSema(SceUID semaid, int setCount, int *numWaitThreads);
+
+/**
+ * Retrieve information about a semaphore.
+ *
+ * @param semaid - UID of the semaphore to retrieve info for.
+ * @param info - Pointer to a ::SceKernelSemaInfo struct to receive the info.
+ *
+ * @return < 0 on error.
+ */
+int sceKernelGetSemaInfo(SceUID semaid, SceKernelSemaInfo *info);
+
+
+/* Mutexes. */
+
+/** Additional options used when creating mutexes. */
+typedef struct SceKernelMutexOptParam {
+ /** Size of the ::SceKernelMutexOptParam structure. */
+ SceSize size;
+ int ceilingPriority;
+} SceKernelMutexOptParam;
+
+/** Current state of a mutex.
+ * @see sceKernelGetMutexInfo.
+ */
+typedef struct SceKernelMutexInfo {
+ /** Size of the ::SceKernelMutexInfo structure. */
+ SceSize size;
+ /** The UID of the mutex. */
+ SceUID mutexId;
+ /** NUL-terminated name of the mutex. */
+ char name[32];
+ /** Attributes. */
+ SceUInt attr;
+ /** The initial count the mutex was created with. */
+ int initCount;
+ /** The current count. */
+ int currentCount;
+ /** The UID of the current owner of the mutex. */
+ SceUID currentOwnerId;
+ /** The number of threads waiting on the mutex. */
+ int numWaitThreads;
+} SceKernelMutexInfo;
+
+/**
+ * Creates a new mutex
+ *
+ * @par Example:
+ * @code
+ * int mutexid;
+ * mutexid = sceKernelCreateMutex("MyMutex", 0, 1, 1, 0);
+ * @endcode
+ *
+ * @param name - Specifies the name of the mutex
+ * @param attr - Mutex attribute flags (normally set to 0)
+ * @param initCount - Mutex initial value
+ * @param option - Mutex options (normally set to 0)
+ * @return A mutex id
+ */
+SceUID sceKernelCreateMutex(const char *name, SceUInt attr, int initCount, SceKernelMutexOptParam *option);
+
+/**
+ * Destroy a mutex
+ *
+ * @param mutexid - The mutex id returned from sceKernelCreateMutex
+ * @return Returns the value 0 if its succesful otherwise -1
+ */
+int sceKernelDeleteMutex(SceUID mutexid);
+
+/**
+ * Open a mutex
+ *
+ * @param name - The name of the mutex to open
+ * @return Returns the value 0 if its succesful otherwise -1
+ */
+int sceKernelOpenMutex(const char *name);
+
+/**
+ * Close a mutex
+ *
+ * @param mutexid - The mutex id returned from sceKernelCreateMutex
+ * @return Returns the value 0 if its succesful otherwise -1
+ */
+int sceKernelCloseMutex(SceUID mutexid);
+
+/**
+ * Lock a mutex
+ *
+ * @param mutexid - The mutex id returned from sceKernelCreateMutex
+ * @param lockCount - The value to increment to the lock count of the mutex
+ * @param timeout - Timeout in microseconds (assumed)
+ * @return < 0 On error.
+ */
+int sceKernelLockMutex(SceUID mutexid, int lockCount, unsigned int *timeout);
+
+/**
+ * Lock a mutex and handle callbacks if necessary.
+ *
+ * @param mutexid - The mutex id returned from sceKernelCreateMutex
+ * @param lockCount - The value to increment to the lock count of the mutex
+ * @param timeout - Timeout in microseconds (assumed)
+ * @return < 0 On error.
+ */
+int sceKernelLockMutexCB(SceUID mutexid, int lockCount, unsigned int *timeout);
+
+/**
+ * Try to lock a mutex (non-blocking)
+ *
+ * @param mutexid - The mutex id returned from sceKernelCreateMutex
+ * @param lockCount - The value to increment to the lock count of the mutex
+ * @return < 0 On error.
+ */
+int sceKernelTryLockMutex(SceUID mutexid, int lockCount);
+
+/**
+ * Try to unlock a mutex (non-blocking)
+ *
+ * @param mutexid - The mutex id returned from sceKernelCreateMutex
+ * @param unlockCount - The value to decrement to the lock count of the mutex
+ * @return < 0 On error.
+ */
+int sceKernelUnlockMutex(SceUID mutexid, int unlockCount);
+
+/**
+ * Cancels a mutex
+ *
+ * @param mutexid - The mutex id returned from sceKernelCreateMutex
+ * @param newCount - The new lock count of the mutex
+ * @param numWaitThreads - Number of threads waiting for the mutex
+ * @return < 0 On error.
+ */
+int sceKernelCancelMutex(SceUID mutexid, int newCount, int *numWaitThreads);
+
+/**
+ * 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);
+
+
+/* Event flags. */
+
+/** Structure to hold the event flag information */
+typedef struct SceKernelEventFlagInfo {
+ SceSize size;
+ SceUID evfId; // Needs confirmation
+ char name[32];
+ SceUInt attr;
+ SceUInt initPattern;
+ SceUInt currentPattern;
+ int numWaitThreads;
+} SceKernelEventFlagInfo;
+
+typedef struct SceKernelEventFlagOptParam {
+ SceSize size;
+} SceKernelEventFlagOptParam;
+
+typedef struct SceKernelEventFlagOptParam SceKernelEventFlagOptParam;
+
+/** Event flag creation attributes */
+typedef enum Psp2EventFlagAttributes {
+ /** Allow the event flag to be waited upon by multiple threads */
+ PSP2_EVENT_WAITMULTIPLE = 0x200
+} Psp2EventFlagAttributes;
+
+/** Event flag wait types */
+typedef enum Psp2EventFlagWaitTypes {
+ /** Wait for all bits in the pattern to be set */
+ PSP2_EVENT_WAITAND = 0,
+ /** Wait for one or more bits in the pattern to be set */
+ PSP2_EVENT_WAITOR = 1,
+ /** Clear the wait pattern when it matches */
+ PSP2_EVENT_WAITCLEAR = 0x20
+} Psp2EventFlagWaitTypes;
+
+/**
+ * Create an event flag.
+ *
+ * @param name - The name of the event flag.
+ * @param attr - Attributes from ::Psp2EventFlagAttributes
+ * @param bits - Initial bit pattern.
+ * @param opt - Options, set to NULL
+ * @return < 0 on error. >= 0 event flag id.
+ *
+ * @par Example:
+ * @code
+ * int evid;
+ * evid = sceKernelCreateEventFlag("wait_event", 0, 0, 0);
+ * @endcode
+ */
+SceUID sceKernelCreateEventFlag(const char *name, int attr, int bits, SceKernelEventFlagOptParam *opt);
+
+/**
+ * Set an event flag bit pattern.
+ *
+ * @param evid - The event id returned by sceKernelCreateEventFlag.
+ * @param bits - The bit pattern to set.
+ *
+ * @return < 0 On error
+ */
+int sceKernelSetEventFlag(SceUID evid, unsigned int bits);
+
+/**
+ * Clear a event flag bit pattern
+ *
+ * @param evid - The event id returned by ::sceKernelCreateEventFlag
+ * @param bits - The bits to clean
+ *
+ * @return < 0 on Error
+ */
+int sceKernelClearEventFlag(SceUID evid, unsigned int bits);
+
+/**
+ * Poll an event flag for a given bit pattern.
+ *
+ * @param evid - The event id returned by sceKernelCreateEventFlag.
+ * @param bits - The bit pattern to poll for.
+ * @param wait - Wait type, one or more of ::Psp2EventFlagWaitTypes or'ed together
+ * @param outBits - The bit pattern that was matched.
+ * @return < 0 On error
+ */
+int sceKernelPollEventFlag(int evid, unsigned int bits, unsigned int wait, unsigned int *outBits);
+
+/**
+ * Wait for an event flag for a given bit pattern.
+ *
+ * @param evid - The event id returned by sceKernelCreateEventFlag.
+ * @param bits - The bit pattern to poll for.
+ * @param wait - Wait type, one or more of ::Psp2EventFlagWaitTypes or'ed together
+ * @param outBits - The bit pattern that was matched.
+ * @param timeout - Timeout in microseconds
+ * @return < 0 On error
+ */
+int sceKernelWaitEventFlag(int evid, unsigned int bits, unsigned int wait, unsigned int *outBits, SceUInt *timeout);
+
+/**
+ * Wait for an event flag for a given bit pattern with callback.
+ *
+ * @param evid - The event id returned by sceKernelCreateEventFlag.
+ * @param bits - The bit pattern to poll for.
+ * @param wait - Wait type, one or more of ::Psp2EventFlagWaitTypes or'ed together
+ * @param outBits - The bit pattern that was matched.
+ * @param timeout - Timeout in microseconds
+ * @return < 0 On error
+ */
+int sceKernelWaitEventFlagCB(int evid, unsigned int bits, unsigned int wait, unsigned int *outBits, SceUInt *timeout);
+
+/**
+ * Delete an event flag
+ *
+ * @param evid - The event id returned by sceKernelCreateEventFlag.
+ *
+ * @return < 0 On error
+ */
+int sceKernelDeleteEventFlag(int evid);
+
+/**
+ * Get the status of an event flag.
+ *
+ * @param event - The UID of the event.
+ * @param status - A pointer to a ::SceKernelEventFlagInfo structure.
+ *
+ * @return < 0 on error.
+ */
+int sceKernelGetEventFlagInfo(SceUID event, SceKernelEventFlagInfo *info);
+
+
+/* Callbacks. */
+
+/** Callback function prototype */
+typedef int (*SceKernelCallbackFunction)(int notifyId, int notifyCount, int notifyArg, void *common);
+
+/** Structure to hold the status information for a callback */
+typedef struct SceKernelCallbackInfo {
+ /** Size of the structure (i.e. sizeof(SceKernelCallbackInfo)) */
+ SceSize size;
+ /** The UID of the callback. */
+ SceUID callbackId; // Needs confirmation
+ /** The name given to the callback */
+ char name[32];
+ /** The thread id associated with the callback */
+ SceUID threadId;
+ /** Pointer to the callback function */
+ SceKernelCallbackFunction callback;
+ /** User supplied argument for the callback */
+ void *common;
+ /** Unknown */
+ int notifyCount;
+ /** Unknown */
+ int notifyArg;
+} SceKernelCallbackInfo;
+
+/**
+ * Create callback
+ *
+ * @par Example:
+ * @code
+ * int cbid;
+ * cbid = sceKernelCreateCallback("Exit Callback", exit_cb, NULL);
+ * @endcode
+ *
+ * @param name - A textual name for the callback
+ * @param func - A pointer to a function that will be called as the callback
+ * @param arg - Argument for the callback ?
+ *
+ * @return >= 0 A callback id which can be used in subsequent functions, < 0 an error.
+ */
+int sceKernelCreateCallback(const char *name, unsigned int attr, SceKernelCallbackFunction func, void *arg);
+
+/**
+ * Gets the status of a specified callback.
+ *
+ * @param cb - The UID of the callback to retrieve info for.
+ * @param status - Pointer to a status structure. The size parameter should be
+ * initialised before calling.
+ *
+ * @return < 0 on error.
+ */
+int sceKernelGetCallbackInfo(SceUID cb, SceKernelCallbackInfo *infop);
+
+/**
+ * Delete a callback
+ *
+ * @param cb - The UID of the specified callback
+ *
+ * @return 0 on success, < 0 on error
+ */
+int sceKernelDeleteCallback(SceUID cb);
+
+/**
+ * Notify a callback
+ *
+ * @param cb - The UID of the specified callback
+ * @param arg2 - Passed as arg2 into the callback function
+ *
+ * @return 0 on success, < 0 on error
+ */
+int sceKernelNotifyCallback(SceUID cb, int arg2);
+
+/**
+ * Cancel a callback ?
+ *
+ * @param cb - The UID of the specified callback
+ *
+ * @return 0 on succes, < 0 on error
+ */
+int sceKernelCancelCallback(SceUID cb);
+
+/**
+ * Get the callback count
+ *
+ * @param cb - The UID of the specified callback
+ *
+ * @return The callback count, < 0 on error
+ */
+int sceKernelGetCallbackCount(SceUID cb);
+
+/**
+ * Check callback ?
+ *
+ * @return Something or another
+ */
+int sceKernelCheckCallback(void);
+
+
+/* Message pipes */
+
+/**
+ * Create a message pipe
+ *
+ * @param name - Name of the pipe
+ * @param part - ID of the memory partition
+ * @param attr - Set to 0?
+ * @param unk1 - Unknown
+ * @param opt - Message pipe options (set to NULL)
+ *
+ * @return The UID of the created pipe, < 0 on error
+ */
+SceUID sceKernelCreateMsgPipe(const char *name, int part, int attr, void *unk1, void *opt);
+
+/**
+ * Delete a message pipe
+ *
+ * @param uid - The UID of the pipe
+ *
+ * @return 0 on success, < 0 on error
+ */
+int sceKernelDeleteMsgPipe(SceUID uid);
+
+/**
+ * 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
+ * @param unk2 - Unknown
+ * @param timeout - Timeout for send
+ *
+ * @return 0 on success, < 0 on error
+ */
+int sceKernelSendMsgPipe(SceUID uid, void *message, unsigned int size, int unk1, void *unk2, unsigned int *timeout);
+
+/**
+ * Send a message to a pipe (with callback)
+ *
+ * @param uid - The UID of the pipe
+ * @param message - Pointer to the message
+ * @param size - Size of the message
+ * @param unk1 - Unknown
+ * @param unk2 - Unknown
+ * @param timeout - Timeout for send
+ *
+ * @return 0 on success, < 0 on error
+ */
+int sceKernelSendMsgPipeCB(SceUID uid, void *message, unsigned int size, 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
+ * @param unk2 - Unknown
+ *
+ * @return 0 on success, < 0 on error
+ */
+int sceKernelTrySendMsgPipe(SceUID uid, void *message, unsigned int size, int unk1, void *unk2);
+
+/**
+ * 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
+ * @param unk2 - Unknown
+ * @param timeout - Timeout for receive
+ *
+ * @return 0 on success, < 0 on error
+ */
+int sceKernelReceiveMsgPipe(SceUID uid, void *message, unsigned int size, int unk1, void *unk2, unsigned int *timeout);
+
+/**
+ * Receive a message from a pipe (with callback)
+ *
+ * @param uid - The UID of the pipe
+ * @param message - Pointer to the message
+ * @param size - Size of the message
+ * @param unk1 - Unknown
+ * @param unk2 - Unknown
+ * @param timeout - Timeout for receive
+ *
+ * @return 0 on success, < 0 on error
+ */
+int sceKernelReceiveMsgPipeCB(SceUID uid, void *message, unsigned int size, 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
+ * @param unk2 - Unknown
+ *
+ * @return 0 on success, < 0 on error
+ */
+int sceKernelTryReceiveMsgPipe(SceUID uid, void *message, 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?
+ * @param precv - Receive number of receiving threads?
+ *
+ * @return 0 on success, < 0 on error
+ */
+int sceKernelCancelMsgPipe(SceUID uid, int *psend, int *precv);
+
+/** Message Pipe status info */
+typedef struct SceKernelMppInfo {
+ SceSize size;
+ SceUID mppId; // Needs confirmation
+ char name[32];
+ SceUInt attr;
+ int bufSize;
+ int freeSize;
+ int numSendWaitThreads;
+ int numReceiveWaitThreads;
+} SceKernelMppInfo;
+
+/**
+ * Get the status of a Message Pipe
+ *
+ * @param uid - The uid of the Message Pipe
+ * @param info - Pointer to a ::SceKernelMppInfo structure
+ *
+ * @return 0 on success, < 0 on error
+ */
+int sceKernelGetMsgPipeInfo(SceUID uid, SceKernelMppInfo *info);
+
+
+/* Misc. */
+
+typedef struct SceKernelSystemInfo {
+ SceSize size;
+ SceUInt32 activeCpuMask;
+
+ struct {
+ SceKernelSysClock idleClock;
+ SceUInt32 comesOutOfIdleCount;
+ SceUInt32 threadSwitchCount;
+ } cpuInfo[4];
+} SceKernelSystemInfo;
+
+/**
+ * Get the system information
+ *
+ * @param info - Pointer to a ::SceKernelSystemInfo structure
+ *
+ * @return 0 on success, < 0 on error
+ */
+int sceKernelGetSystemInfo(SceKernelSystemInfo *info);
+
+/* Misc. */
+
+/** Threadmgr types */
+typedef enum SceKernelIdListType {
+ SCE_KERNEL_TMID_Thread = 1,
+ SCE_KERNEL_TMID_Semaphore = 2,
+ SCE_KERNEL_TMID_EventFlag = 3,
+ SCE_KERNEL_TMID_Mbox = 4,
+ SCE_KERNEL_TMID_Vpl = 5,
+ SCE_KERNEL_TMID_Fpl = 6,
+ SCE_KERNEL_TMID_Mpipe = 7,
+ SCE_KERNEL_TMID_Callback = 8,
+ SCE_KERNEL_TMID_ThreadEventHandler = 9,
+ SCE_KERNEL_TMID_Alarm = 10,
+ SCE_KERNEL_TMID_VTimer = 11,
+ SCE_KERNEL_TMID_SleepThread = 64,
+ SCE_KERNEL_TMID_DelayThread = 65,
+ SCE_KERNEL_TMID_SuspendThread = 66,
+ SCE_KERNEL_TMID_DormantThread = 67,
+} SceKernelIdListType;
+
+/**
+ * Get the type of a threadman uid
+ *
+ * @param uid - The uid to get the type from
+ *
+ * @return The type, < 0 on error
+ */
+SceKernelIdListType sceKernelGetThreadmgrUIDClass(SceUID uid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PSP2_KERNEL_THREADMGR_H_ */
diff --git a/include/user/power.h b/include/user/power.h
new file mode 100644
index 0000000..e74afb3
--- /dev/null
+++ b/include/user/power.h
@@ -0,0 +1,30 @@
+#ifndef _PSP2_POWER_H_
+#define _PSP2_POWER_H_
+
+#include <psp2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* callback */
+typedef void (*ScePowerCallback)(int unknown, int powerInfo);
+
+/* prototypes */
+int scePowerRegisterCallback(int slot, SceUID cbid);
+int scePowerIsBatteryCharging();
+int scePowerGetBatteryLifePercent();
+int scePowerSetConfigurationMode(int mode); //?
+SceBool scePowerIsSuspendRequired(); //?
+int scePowerIsPowerOnline();
+int scePowerGetBatteryLifeTime();
+int scePowerGetBatteryRemainCapacity(); //?
+int scePowerIsLowBattery();
+int scePowerUnregisterCallback(int slot);
+int scePowerGetBatteryFullCapacity(); //?
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PSP2_POWER_H_ */
diff --git a/include/user/pss.h b/include/user/pss.h
new file mode 100644
index 0000000..08340e1
--- /dev/null
+++ b/include/user/pss.h
@@ -0,0 +1,11 @@
+#ifndef _PSP2_PSS_H_
+#define _PSP2_PSS_H_
+
+#include <psp2/types.h>
+
+void *pss_code_mem_alloc(SceSize *);
+void pss_code_mem_flush_icache(const void *, SceSize);
+void pss_code_mem_lock(void);
+void pss_code_mem_unlock(void);
+
+#endif
diff --git a/include/user/sysmodule.h b/include/user/sysmodule.h
new file mode 100644
index 0000000..109983d
--- /dev/null
+++ b/include/user/sysmodule.h
@@ -0,0 +1,79 @@
+#ifndef _PSP2_SYSMODULE_H_
+#define _PSP2_SYSMODULE_H_
+
+#include <psp2/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+ SCE_SYSMODULE_LOADED = 0,
+ SCE_SYSMODULE_ERROR_INVALID_VALUE = 0x805A1000,
+ SCE_SYSMODULE_ERROR_UNLOADED = 0x805A1001,
+ SCE_SYSMODULE_ERROR_FATAL = 0x805A10FF,
+};
+
+/* module IDs */
+enum {
+ PSP2_SYSMODULE_INVALID = 0x0000,
+ PSP2_SYSMODULE_NET = 0x0001,
+ PSP2_SYSMODULE_HTTP = 0x0002,
+ PSP2_SYSMODULE_SSL = 0x0003,
+ PSP2_SYSMODULE_HTTPS = 0x0004,
+ PSP2_SYSMODULE_PERF = 0x0005,
+ PSP2_SYSMODULE_FIBER = 0x0006,
+ PSP2_SYSMODULE_ULT = 0x0007,
+ PSP2_SYSMODULE_DBG = 0x0008,
+ PSP2_SYSMODULE_RAZOR_CAPTURE = 0x0009,
+ PSP2_SYSMODULE_RAZOR_HUD = 0x000a,
+ PSP2_SYSMODULE_NGS = 0x000b,
+ PSP2_SYSMODULE_SULPHA = 0x000c,
+ PSP2_SYSMODULE_SAS = 0x000d,
+ PSP2_SYSMODULE_PGF = 0x000e,
+ PSP2_SYSMODULE_APPUTIL = 0x000f,
+ PSP2_SYSMODULE_FIOS2 = 0x0010,
+ PSP2_SYSMODULE_IME = 0x0011,
+ PSP2_SYSMODULE_NP_BASIC = 0x0012,
+ PSP2_SYSMODULE_SYSTEM_GESTURE = 0x0013,
+ PSP2_SYSMODULE_LOCATION = 0x0014,
+ PSP2_SYSMODULE_NP = 0x0015,
+ PSP2_SYSMODULE_PHOTO_EXPORT = 0x0016,
+ PSP2_SYSMODULE_XML = 0x0017,
+ PSP2_SYSMODULE_NP_COMMERCE2 = 0x0018,
+ PSP2_SYSMODULE_NP_UTILITY = 0x0019,
+ PSP2_SYSMODULE_VOICE = 0x001a,
+ PSP2_SYSMODULE_VOICEQOS = 0x001b,
+ PSP2_SYSMODULE_NP_MATCHING2 = 0x001c,
+ PSP2_SYSMODULE_SCREEN_SHOT = 0x001d,
+ PSP2_SYSMODULE_NP_SCORE_RANKING = 0x001e,
+ PSP2_SYSMODULE_SQLITE = 0x001f,
+ PSP2_SYSMODULE_RUDP = 0x0021,
+ PSP2_SYSMODULE_CODECENGINE_PERF = 0x0022,
+ PSP2_SYSMODULE_LIVEAREA = 0x0023,
+ PSP2_SYSMODULE_NP_ACTIVITY = 0x0024,
+ PSP2_SYSMODULE_NP_TROPHY = 0x0025,
+ PSP2_SYSMODULE_NP_MESSAGE = 0x0026,
+ PSP2_SYSMODULE_SHUTTER_SOUND = 0x0027,
+ PSP2_SYSMODULE_CLIPBOARD = 0x0028,
+ PSP2_SYSMODULE_NP_PARTY = 0x0029,
+ PSP2_SYSMODULE_NET_ADHOC_MATCHING = 0x002a,
+ PSP2_SYSMODULE_NEAR_UTIL = 0x002b,
+ PSP2_SYSMODULE_NP_TUS = 0x002c,
+ PSP2_SYSMODULE_MP4 = 0x002d,
+ PSP2_SYSMODULE_HANDWRITING = 0x002f,
+ PSP2_SYSMODULE_ATRAC = 0x0030,
+ PSP2_SYSMODULE_NP_SNS_FACEBOOK = 0x0031,
+ PSP2_SYSMODULE_FACE = 0x0038,
+ PSP2_SYSMODULE_SMART = 0x0039
+};
+
+int sceSysmoduleLoadModule(SceUInt16 id);
+int sceSysmoduleUnloadModule(SceUInt16 id);
+int sceSysmoduleIsLoaded(SceUInt16 id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PSP2_SYSMODULE_H_ */