# pspthreadman.h

Go to the documentation of this file.

    00001 /*
    00002  * PSP Software Development Kit - http://www.pspdev.org
    00003  * -----------------------------------------------------------------------
    00004  * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
    00005  *
    00006  * pspthreadman.h - Library imports for the kernel threading library.
    00007  *
    00008  * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
    00009  * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
    00010  * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
    00011  * Copyright (c) 2005 Florin Sasu
    00012  *
    00013  * $Id: pspthreadman.h 1090 2005-09-27 11:19:31Z warren $
    00014  */
    00015 #ifndef __THREADMAN_H__
    00016 #define __THREADMAN_H__
    00017
    00018 #include <psptypes.h>
    00019 #include <pspkerneltypes.h>
    00020
    00021 /* Note: Some of the structures, types, and definitions in this file were
    00022    extrapolated from symbolic debugging information found in the Japanese
    00023    version of Puzzle Bobble. */
    00024
    00029 #ifdef __cplusplus
    00030 extern "C" {
    00031 #endif
    00032
    00036
    00038 typedef struct SceKernelSysClock {
    00039         SceUInt32   low;
    00040         SceUInt32   hi;
    00041 } SceKernelSysClock;
    00042
    00044 enum PspThreadAttributes
    00045 {
    00047         PSP_THREAD_ATTR_VFPU = 0x00004000,
    00050         PSP_THREAD_ATTR_USER = 0x80000000,
    00052         PSP_THREAD_ATTR_USBWLAN = 0xa0000000,
    00054         PSP_THREAD_ATTR_VSH = 0xc0000000,
    00056         PSP_THREAD_ATTR_SCRATCH_SRAM = 0x00008000,
    00058         PSP_THREAD_ATTR_NO_FILLSTACK = 0x00100000,
    00060         PSP_THREAD_ATTR_CLEAR_STACK = 0x00200000,
    00061 };
    00062
    00063 /* Maintained for compatibility with older versions of PSPSDK. */
    00064 #define THREAD_ATTR_VFPU PSP_THREAD_ATTR_VFPU
    00065 #define THREAD_ATTR_USER PSP_THREAD_ATTR_USER
    00066
    00067 typedef int (*SceKernelThreadEntry)(SceSize args, void *argp);
    00068
    00070 typedef struct SceKernelThreadOptParam {
    00072         SceSize         size;
    00074         SceUID          stackMpid;
    00075 } SceKernelThreadOptParam;
    00076
    00080 typedef struct SceKernelThreadInfo {
    00082         SceSize     size;
    00084         char            name[32];
    00086         SceUInt     attr;
    00088         int             status;
    00090         SceKernelThreadEntry    entry;
    00092         void *          stack;
    00094         int             stackSize;
    00096         void *          gpReg;
    00098         int             initPriority;
    00100         int             currentPriority;
    00102         int             waitType;
    00104         SceUID          waitId;
    00106         int             wakeupCount;
    00108         int             exitStatus;
    00110         SceKernelSysClock   runClocks;
    00112         SceUInt     intrPreemptCount;
    00114         SceUInt     threadPreemptCount;
    00116         SceUInt     releaseCount;
    00117 } SceKernelThreadInfo;
    00118
    00122 typedef struct SceKernelThreadRunStatus {
    00123         SceSize         size;
    00124         int             status;
    00125         int             currentPriority;
    00126         int             waitType;
    00127         int             waitId;
    00128         int             wakeupCount;
    00129         SceKernelSysClock runClocks;
    00130         SceUInt         intrPreemptCount;
    00131         SceUInt         threadPreemptCount;
    00132         SceUInt         releaseCount;
    00133 } SceKernelThreadRunStatus;
    00134
    00153 SceUID sceKernelCreateThread(const char *name, SceKernelThreadEntry entry, int initPriority,
    00154                              int stackSize, SceUInt attr, SceKernelThreadOptParam *option);
    00155
    00163 int sceKernelDeleteThread(SceUID thid);
    00164
    00172 int sceKernelStartThread(SceUID thid, SceSize arglen, void *argp);
    00173
    00179 int sceKernelExitThread(int status);
    00180
    00186 int sceKernelExitDeleteThread(int status);
    00187
    00195 int sceKernelTerminateThread(SceUID thid);
    00196
    00204 int sceKernelTerminateDeleteThread(SceUID thid);
    00205
    00206 //
    00207 // sceKernelSuspendDispatchThread
    00208 // sceKernelResumeDispatchThread
    00209 //
    00210
    00216 int sceKernelSleepThread(void);
    00217
    00227 void sceKernelSleepThreadCB(void);
    00228
    00236 int sceKernelWakeupThread(SceUID thid);
    00237
    00245 int sceKernelCancelWakeupThread(SceUID thid);
    00246
    00254 int sceKernelSuspendThread(SceUID thid);
    00255
    00263 int sceKernelResumeThread(SceUID thid);
    00264
    00273 int sceKernelWaitThreadEnd(SceUID thid, SceUInt *timeout);
    00274
    00283 int sceKernelWaitThreadEndCB(SceUID thid, SceUInt *timeout);
    00284
    00295 void sceKernelDelayThread(SceUInt delay);
    00296
    00307 void sceKernelDelayThreadCB(SceUInt delay);
    00308
    00317 int sceKernelChangeCurrentThreadAttr(int unknown, SceUInt attr);
    00318
    00334 int sceKernelChangeThreadPriority(SceUID thid, int priority);
    00335
    00336 // sceKernelRotateThreadReadyQueue
    00337 //
    00338 // sceKernelReleaseWaitThread
    00339
    00345 int sceKernelGetThreadId(void);
    00346
    00347 // sceKernelGetThreadCurrentPriority
    00348 //
    00349 // sceKernelGetThreadExitStatus
    00350 //
    00351 // sceKernelCheckThreadStack
    00352 // sceKernelGetThreadStackFreeSize
    00353
    00371 int sceKernelReferThreadStatus(SceUID thid, SceKernelThreadInfo *info);
    00372
    00381 int sceKernelReferThreadRunStatus(SceUID thid, SceKernelThreadRunStatus *status);
    00382
    00383
    00385 typedef struct SceKernelSemaOptParam {
    00387         SceSize         size;
    00388 } SceKernelSemaOptParam;
    00389
    00393 typedef struct SceKernelSemaInfo {
    00395         SceSize         size;
    00397         char            name[32];
    00399         SceUInt         attr;
    00401         int             initCount;
    00403         int             currentCount;
    00405         int             maxCount;
    00407         int             numWaitThreads;
    00408 } SceKernelSemaInfo;
    00409
    00426 SceUID sceKernelCreateSema(const char *name, SceUInt attr, int initVal, int maxVal, SceKernelSemaOptParam *option);
    00427
    00434 int sceKernelDeleteSema(SceUID semaid);
    00435
    00450 int sceKernelSignalSema(SceUID semaid, int signal);
    00451
    00466 int sceKernelWaitSema(SceUID semaid, int signal, SceUInt *timeout);
    00467
    00482 int sceKernelWaitSemaCB(SceUID semaid, int signal, SceUInt *timeout);
    00483
    00492 int sceKernelPollSema(SceUID semaid, int signal);
    00493
    00502 int sceKernelReferSemaStatus(SceUID semaid, SceKernelSemaInfo *info);
    00503
    00505 typedef int (*SceKernelCallbackFunction)(int arg1, int arg2, void *arg);
    00506
    00522 int sceKernelCreateCallback(const char *name, SceKernelCallbackFunction func, void *arg);
    00523
    00524
    00540 int sceKernelCreateEventFlag(const char *name, int unk1, int bits, int unk3);
    00541
    00550 int sceKernelSetEventFlag(int evid, u32 bits);
    00551
    00561 int sceKernelPollEventFlag(int evid, u32 bits, u32 wait, u32 *outBits);
    00562
    00570 int sceKernelDeleteEventFlag(int evid);
    00571
    00573 enum SceKernelIdListType
    00574 {
    00575         SCE_KERNEL_TMID_Thread = 1,
    00576         SCE_KERNEL_TMID_Semaphore = 2,
    00577         SCE_KERNEL_TMID_EventFlag = 3,
    00578         SCE_KERNEL_TMID_Mbox = 4,
    00579         SCE_KERNEL_TMID_Vpl = 5,
    00580         SCE_KERNEL_TMID_Fpl = 6,
    00581         SCE_KERNEL_TMID_Mpipe = 7,
    00582         SCE_KERNEL_TMID_Callback = 8,
    00583         SCE_KERNEL_TMID_ThreadEventHandler = 9,
    00584         SCE_KERNEL_TMID_Alarm = 10,
    00585         SCE_KERNEL_TMID_VTimer = 11,
    00586         SCE_KERNEL_TMID_SleepThread = 64,
    00587         SCE_KERNEL_TMID_DelayThread = 65,
    00588         SCE_KERNEL_TMID_SuspendThread = 66,
    00589         SCE_KERNEL_TMID_DormantThread = 67,
    00590 };
    00591
    00603 int sceKernelGetThreadmanIdList(enum SceKernelIdListType type, SceUID *readbuf, int readbufsize, int *idcount);
    00604
    00606 struct _SceKernelCallbackInfo {
    00608         SceSize         size;
    00610         char    name[32];
    00612         SceUID  threadId;
    00614         SceKernelCallbackFunction       callback;
    00616         void *  common;
    00618         int     notifyCount;
    00620         int     notifyArg;
    00621 };
    00622
    00623 typedef struct _SceKernelCallbackInfo SceKernelCallbackInfo;
    00624
    00634 int sceKernelReferCallbackStatus(SceUID cb, SceKernelCallbackInfo *status);
    00635
    00637 struct _SceKernelSystemStatus {
    00639         SceSize         size;
    00641         SceUInt         status;
    00643         SceKernelSysClock       idleClocks;
    00645         SceUInt         comesOutOfIdleCount;
    00647         SceUInt         threadSwitchCount;
    00649         SceUInt         vfpuSwitchCount;
    00650 };
    00651
    00652 typedef struct _SceKernelSystemStatus SceKernelSystemStatus;
    00653
    00661 int sceKernelReferSystemStatus(SceKernelSystemStatus *status);
    00662
    00664 struct _SceKernelEventFlagInfo {
    00665         SceSize         size;
    00666         char    name[32];
    00667         SceUInt         attr;
    00668         SceUInt         initPattern;
    00669         SceUInt         currentPattern;
    00670         int     numWaitThreads;
    00671 };
    00672
    00673 typedef struct _SceKernelEventFlagInfo SceKernelEventFlagInfo;
    00674
    00683 int sceKernelReferEventFlagStatus(SceUID event, SceKernelEventFlagInfo *status);
    00684
    00685
    00687 typedef struct SceKernelMbxOptParam {
    00689         SceSize         size;
    00690 } SceKernelMbxOptParam;
    00691
    00695 typedef struct SceKernelMbxInfo {
    00697         SceSize         size;
    00699         char            name[32];
    00701         SceUInt         attr;
    00703         int             numWaitThreads;
    00705         int             numMessages;
    00707         void            *firstMessage;
    00708 } SceKernelMbxInfo;
    00709
    00724 SceUID sceKernelCreateMbx(const char *name, SceUInt attr, SceKernelMbxOptParam *option);
    00725
    00732 int sceKernelDeleteMbx(SceUID mbxid);
    00733
    00751 int sceKernelSendMbx(SceUID mbxid, void *message);
    00752
    00769 int sceKernelReceiveMbx(SceUID mbxid, void **pmessage, SceUInt *timeout);
    00770
    00787 int sceKernelReceiveMbxCB(SceUID mbxid, void **pmessage, SceUInt *timeout);
    00788
    00804 int sceKernelPollMbx(SceUID mbxid, void **pmessage);
    00805
    00821 int sceKernelCancelReceiveMbx(SceUID mbxid, int *pnum);
    00822
    00831 int sceKernelReferMbxStatus(SceUID mbxid, SceKernelMbxInfo *info);
    00832
    00833
    00836 #ifdef __cplusplus
    00837 }
    00838 #endif
    00839
    00840 #endif