pspsdk-1.0+beta2
pspthreadman.h
Go to the documentation of this file.
1 /*
2  * PSP Software Development Kit - http://www.pspdev.org
3  * -----------------------------------------------------------------------
4  * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
5  *
6  * pspthreadman.h - Library imports for the kernel threading library.
7  *
8  * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
9  * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
10  * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
11  * Copyright (c) 2005 Florin Sasu
12  *
13  * $Id: pspthreadman.h 2433 2008-10-15 10:00:27Z iwn $
14  */
15 #ifndef __THREADMAN_H__
16 #define __THREADMAN_H__
17 
18 #include <psptypes.h>
19 #include <pspkerneltypes.h>
20 /* Include for profile register definitions */
21 #include <pspdebug.h>
22 
23 /* Note: Some of the structures, types, and definitions in this file were
24  extrapolated from symbolic debugging information found in the Japanese
25  version of Puzzle Bobble. */
26 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
38 
40 typedef struct SceKernelSysClock {
44 
47 {
49  PSP_THREAD_ATTR_VFPU = 0x00004000,
52  PSP_THREAD_ATTR_USER = 0x80000000,
56  PSP_THREAD_ATTR_VSH = 0xc0000000,
63 };
64 
65 /* Maintained for compatibility with older versions of PSPSDK. */
66 #define THREAD_ATTR_VFPU PSP_THREAD_ATTR_VFPU
67 #define THREAD_ATTR_USER PSP_THREAD_ATTR_USER
68 
69 
70 /* Threads. */
71 
72 typedef int (*SceKernelThreadEntry)(SceSize args, void *argp);
73 
75 typedef struct SceKernelThreadOptParam {
81 
85 typedef struct SceKernelThreadInfo {
89  char name[32];
93  int status;
97  void * stack;
99  int stackSize;
101  void * gpReg;
107  int waitType;
123 
127 typedef struct SceKernelThreadRunStatus {
129  int status;
131  int waitType;
132  int waitId;
139 
140 /* Sure there must be more than this, but haven't seen them */
142 {
148  PSP_THREAD_KILLED = 32, /* Thread manager has killed the thread (stack overflow) */
149 };
150 
169 SceUID sceKernelCreateThread(const char *name, SceKernelThreadEntry entry, int initPriority,
170  int stackSize, SceUInt attr, SceKernelThreadOptParam *option);
171 
179 int sceKernelDeleteThread(SceUID thid);
180 
188 int sceKernelStartThread(SceUID thid, SceSize arglen, void *argp);
189 
195 int sceKernelExitThread(int status);
196 
202 int sceKernelExitDeleteThread(int status);
203 
212 
221 
228 
237 int sceKernelResumeDispatchThread(int state);
238 
244 int sceKernelSleepThread(void);
245 
255 int sceKernelSleepThreadCB(void);
256 
264 int sceKernelWakeupThread(SceUID thid);
265 
274 
283 
291 int sceKernelResumeThread(SceUID thid);
292 
301 int sceKernelWaitThreadEnd(SceUID thid, SceUInt *timeout);
302 
311 int sceKernelWaitThreadEndCB(SceUID thid, SceUInt *timeout);
312 
323 int sceKernelDelayThread(SceUInt delay);
324 
336 
345 
355 
365 
381 int sceKernelChangeThreadPriority(SceUID thid, int priority);
382 
390 int sceKernelRotateThreadReadyQueue(int priority);
391 
400 
406 int sceKernelGetThreadId(void);
407 
414 
423 
429 int sceKernelCheckThreadStack(void);
430 
440 
459 
469 
470 
471 /* Semaphores. */
472 
474 typedef struct SceKernelSemaOptParam {
478 
482 typedef struct SceKernelSemaInfo {
486  char name[32];
494  int maxCount;
498 
515 SceUID sceKernelCreateSema(const char *name, SceUInt attr, int initVal, int maxVal, SceKernelSemaOptParam *option);
516 
523 int sceKernelDeleteSema(SceUID semaid);
524 
539 int sceKernelSignalSema(SceUID semaid, int signal);
540 
555 int sceKernelWaitSema(SceUID semaid, int signal, SceUInt *timeout);
556 
571 int sceKernelWaitSemaCB(SceUID semaid, int signal, SceUInt *timeout);
572 
581 int sceKernelPollSema(SceUID semaid, int signal);
582 
592 
593 
594 /* Event flags. */
595 
597 typedef struct SceKernelEventFlagInfo {
599  char name[32];
605 
608 };
609 
611 
614 {
617 };
618 
621 {
628 };
629 
645 SceUID sceKernelCreateEventFlag(const char *name, int attr, int bits, SceKernelEventFlagOptParam *opt);
646 
655 int sceKernelSetEventFlag(SceUID evid, u32 bits);
656 
665 int sceKernelClearEventFlag(SceUID evid, u32 bits);
666 
676 int sceKernelPollEventFlag(int evid, u32 bits, u32 wait, u32 *outBits);
677 
688 int sceKernelWaitEventFlag(int evid, u32 bits, u32 wait, u32 *outBits, SceUInt *timeout);
689 
700 int sceKernelWaitEventFlagCB(int evid, u32 bits, u32 wait, u32 *outBits, SceUInt *timeout);
701 
709 int sceKernelDeleteEventFlag(int evid);
710 
720 
721 
722 /* Message boxes. */
723 
725 typedef struct SceKernelMbxOptParam {
729 
733 typedef struct SceKernelMbxInfo {
737  char name[32];
747 
751 typedef struct SceKernelMsgPacket {
759 
775 
782 int sceKernelDeleteMbx(SceUID mbxid);
783 
806 int sceKernelSendMbx(SceUID mbxid, void *message);
807 
824 int sceKernelReceiveMbx(SceUID mbxid, void **pmessage, SceUInt *timeout);
825 
842 int sceKernelReceiveMbxCB(SceUID mbxid, void **pmessage, SceUInt *timeout);
843 
859 int sceKernelPollMbx(SceUID mbxid, void **pmessage);
860 
876 int sceKernelCancelReceiveMbx(SceUID mbxid, int *pnum);
877 
887 
888 
889 /* Alarms. */
890 
892 typedef SceUInt (*SceKernelAlarmHandler)(void *common);
893 
895 typedef struct SceKernelAlarmInfo {
899  /* The current schedule */
904  void * common;
906 
916 
927 
935 int sceKernelCancelAlarm(SceUID alarmid);
936 
946 
947 /* Callbacks. */
948 
950 typedef int (*SceKernelCallbackFunction)(int arg1, int arg2, void *arg);
951 
953 typedef struct SceKernelCallbackInfo {
957  char name[32];
963  void * common;
969 
985 int sceKernelCreateCallback(const char *name, SceKernelCallbackFunction func, void *arg);
986 
997 
1006 
1015 int sceKernelNotifyCallback(SceUID cb, int arg2);
1016 
1025 
1034 
1040 int sceKernelCheckCallback(void);
1041 
1042 /* Misc. */
1043 
1046 {
1062 };
1063 
1075 int sceKernelGetThreadmanIdList(enum SceKernelIdListType type, SceUID *readbuf, int readbufsize, int *idcount);
1076 
1078 typedef struct SceKernelSystemStatus {
1092 
1101 
1102 
1114 SceUID sceKernelCreateMsgPipe(const char *name, int part, int attr, void *unk1, void *opt);
1115 
1124 
1137 int sceKernelSendMsgPipe(SceUID uid, void *message, unsigned int size, int unk1, void *unk2, unsigned int *timeout);
1138 
1151 int sceKernelSendMsgPipeCB(SceUID uid, void *message, unsigned int size, int unk1, void *unk2, unsigned int *timeout);
1152 
1164 int sceKernelTrySendMsgPipe(SceUID uid, void *message, unsigned int size, int unk1, void *unk2);
1165 
1178 int sceKernelReceiveMsgPipe(SceUID uid, void *message, unsigned int size, int unk1, void *unk2, unsigned int *timeout);
1179 
1192 int sceKernelReceiveMsgPipeCB(SceUID uid, void *message, unsigned int size, int unk1, void *unk2, unsigned int *timeout);
1193 
1205 int sceKernelTryReceiveMsgPipe(SceUID uid, void *message, unsigned int size, int unk1, void *unk2);
1206 
1216 int sceKernelCancelMsgPipe(SceUID uid, int *psend, int *precv);
1217 
1219 typedef struct SceKernelMppInfo {
1221  char name[32];
1223  int bufSize;
1228 
1238 
1239 /* VPL Functions */
1240 
1243 };
1244 
1256 SceUID sceKernelCreateVpl(const char *name, int part, int attr, unsigned int size, struct SceKernelVplOptParam *opt);
1257 
1265 int sceKernelDeleteVpl(SceUID uid);
1266 
1277 int sceKernelAllocateVpl(SceUID uid, unsigned int size, void **data, unsigned int *timeout);
1278 
1289 int sceKernelAllocateVplCB(SceUID uid, unsigned int size, void **data, unsigned int *timeout);
1290 
1300 int sceKernelTryAllocateVpl(SceUID uid, unsigned int size, void **data);
1301 
1310 int sceKernelFreeVpl(SceUID uid, void *data);
1311 
1320 int sceKernelCancelVpl(SceUID uid, int *pnum);
1321 
1323 typedef struct SceKernelVplInfo {
1325  char name[32];
1331 
1341 
1342 /* FPL Functions */
1343 
1346 };
1347 
1360 int sceKernelCreateFpl(const char *name, int part, int attr, unsigned int size, unsigned int blocks, struct SceKernelFplOptParam *opt);
1361 
1369 int sceKernelDeleteFpl(SceUID uid);
1370 
1380 int sceKernelAllocateFpl(SceUID uid, void **data, unsigned int *timeout);
1381 
1391 int sceKernelAllocateFplCB(SceUID uid, void **data, unsigned int *timeout);
1392 
1401 int sceKernelTryAllocateFpl(SceUID uid, void **data);
1402 
1411 int sceKernelFreeFpl(SceUID uid, void *data);
1412 
1421 int sceKernelCancelFpl(SceUID uid, int *pnum);
1422 
1424 typedef struct SceKernelFplInfo {
1426  char name[32];
1433 
1443 
1448 
1453 void _sceKernelReturnFromCallback(void);
1454 
1463 int sceKernelUSec2SysClock(unsigned int usec, SceKernelSysClock *clock);
1464 
1472 SceInt64 sceKernelUSec2SysClockWide(unsigned int usec);
1473 
1483 int sceKernelSysClock2USec(SceKernelSysClock *clock, unsigned int *low, unsigned int *high);
1484 
1494 int sceKernelSysClock2USecWide(SceInt64 clock, unsigned *low, unsigned int *high);
1495 
1504 
1511 
1517 unsigned int sceKernelGetSystemTimeLow(void);
1518 
1521 };
1522 
1531 SceUID sceKernelCreateVTimer(const char *name, struct SceKernelVTimerOptParam *opt);
1532 
1540 int sceKernelDeleteVTimer(SceUID uid);
1541 
1551 
1560 
1570 
1579 
1589 
1599 
1607 int sceKernelStartVTimer(SceUID uid);
1608 
1616 int sceKernelStopVTimer(SceUID uid);
1617 
1618 typedef SceUInt (*SceKernelVTimerHandler)(SceUID uid, SceKernelSysClock *, SceKernelSysClock *, void *);
1620 
1631 int sceKernelSetVTimerHandler(SceUID uid, SceKernelSysClock *time, SceKernelVTimerHandler handler, void *common);
1632 
1643 int sceKernelSetVTimerHandlerWide(SceUID uid, SceInt64 time, SceKernelVTimerHandlerWide handler, void *common);
1644 
1653 
1654 typedef struct SceKernelVTimerInfo {
1656  char name[32];
1657  int active;
1658  SceKernelSysClock base;
1659  SceKernelSysClock current;
1660  SceKernelSysClock schedule;
1662  void * common;
1664 
1674 
1679 void _sceKernelExitThread(void);
1680 
1689 
1690 typedef int (*SceKernelThreadEventHandler)(int mask, SceUID thid, void *common);
1691 
1695  char name[32];
1697  int mask;
1699  void * common;
1701 
1703 {
1704  THREADEVENT_ALL = 0xFFFFFFFF,
1705  THREADEVENT_KERN = 0xFFFFFFF8,
1706  THREADEVENT_USER = 0xFFFFFFF0,
1708 };
1709 
1711 {
1716 };
1717 
1729 SceUID sceKernelRegisterThreadEventHandler(const char *name, SceUID threadID, int mask, SceKernelThreadEventHandler handler, void *common);
1730 
1739 
1749 
1755 
1761 
1764 #ifdef __cplusplus
1765 }
1766 #endif
1767 
1768 #endif