s32 sceSTimerAlloc() { if (sceKernelIsIntrContext() != 0) return 0x80020064; s32 oldIntr = sceKernelCpuSuspendIntr(); s32 i; for (i = 0; i < 4; i++) { if (timers[i].curTimer == -1) { timers[i].cb = NULL; timers[i].hw->unk0 = 0x80000000; timers[i].hw->unk8 = -1; timers[i].hw->unk12 = -1; (void)timers[i].hw->unk0; timers[i].curTimer = -1; timers[i].unk12 = 0; timers[i].unk16 = 0; timers[i].unk24 = 0; timers[i].unk28 = 0; timers[i].curTimer = ((initVar << 2) | i) & 0x7FFFFFFF; initVar += 7; sceKernelCpuResumeIntr(oldIntr); return timers[i].curTimer; } } sceKernelCpuResumeIntr(oldIntr); return 0x80020096; }
//5d18 int sceKernelCreateMbx(const char *name, unsigned int attr, SceKernelMbxOptParam *opt) { SET_K1_SRL16; if(IS_USER_MODE && (IS_ADDR_KERNEL(name) || IS_ADDR_KERNEL(opt))) { RESET_K1; return SCE_KERNEL_ERROR_ILLEGAL_ADDR; } if(sceKernelIsIntrContext()) { RESET_K1; return SCE_KERNEL_ERROR_ILLEGAL_CONTEXT; } if(attr & ~SCE_MBX_LEGAL_ATTR) { RESET_K1; return SCE_KERNEL_ERROR_ILLEGAL_ATTR; } int intr = sceKernelCpuSuspendIntr(); uidControlBlock *cb; int ret = sceKernelCreateUID(uidMboxType, name, IS_USER_MODE ? 0xFF : (attr & 0xFF), &cb); if(ret != 0) { sceKernelCpuResumeIntr(intr); RESET_K1; return ret; } WaitQInfo *qinfo = t7 = UID_INFO(WaitQInfo, cb, uidWaitQType); qinfo->attr = attr; MboxInfo *mbinfo = s0 = UID_INFO(MboxInfo, cb, uidMboxType); mbinfo->option = opt; THREADMAN_TRACE(0x47, 1, mbinfo); sceKernelCpuResumeIntr(intr); RESET_K1; return 0; }
int sceKernelLoadModule (const char *path, int flags, SceKernelLMOption *option){ //K1>>16 if(sceKernelIsIntrContext())return 0x80020064; if (!(k1 & 0x00000018))return 0x80020149 if (!path)return 0x800200D3 if (((-k1 & 0x18) & path)<0)return 0x800200D3; if (strchr (path, 0x00000025))return 0x8002012F; if (option){ if (((0x0207FFFF < ((SysMemForKernel_2CFF6F90 (0) & 0xFFFF0000) | (0 & 0x0000FFFF)))) == 0){ if (((((option + 0x14) | option) & (- k1 & 0x18)) < 0)) return 0x800200D3 }else{ if (((int *) option)[0] == 0x14) if (((((option + 0x14) | option) & (- k1 & 0x18)) < 0)) return 0x800201BC } }
//5e98 int sceKernelDeleteMbx(SceUID mbxid) { SET_K1_SRL16; if(sceKernelIsIntrContext()) { RESET_K1; return SCE_KERNEL_ERROR_ILLEGAL_CONTEXT; } int intr = sceKernelCpuSuspendIntr(); uidControlBlock *cb; if(sceKernelGetUIDcontrolBlockWithType(mbxid, uidMboxType, &cb) != 0) { sceKernelCpuResumeIntr(intr); RESET_K1; return SCE_KERNEL_ERROR_UNKNOWN_MBXID; } if(IS_USER_MODE && !(cb->attr & 0x10)) { sceKernelCpuResumeIntr(intr); RESET_K1; return SCE_KERNEL_ERROR_ILLEGAL_PERM; } THREADMAN_TRACE(0x48, 1, mbxid); ASSERT(sceKernelDeleteUID(mbxid) <= 0); sceKernelCpuResumeIntr(intr); RESET_K1; return 0; }
s32 sceSTimerFree(s32 timerId) { SceSysTimer *timer = &timers[timerId & 3]; if (sceKernelIsIntrContext() != 0) return 0x80020064; if (timer->curTimer != timerId) return 0x80020097; s32 oldIntr = sceKernelCpuSuspendIntr(); _sceSTimerStopCount(timer); sceKernelDisableIntr(timer->s32Num); timer->hw->unk0 = 0x80000000; timer->hw->unk8 = -1; timer->hw->unk12 = -1; timer->cb = NULL; (void)timer->hw->unk0; timer->unk28 = 0; timer->curTimer = -1; timer->unk12 = 0; timer->unk16 = 0; timer->unk24 = 0; sceKernelCpuResumeIntr(oldIntr); return 0; }
//5ff0 int sceKernelSendMbx(SceUID mbxid, void *message) { SET_K1_SRL16; int intr = sceKernelCpuSuspendIntr(); int isIntr = sceKernelIsIntrContext(); if(IS_USER_MODE && IS_ADDR_KERNEL(message)) { sceKernelCpuResumeIntr(intr); RESET_K1; return SCE_KERNEL_ERROR_ILLEGAL_ADDR; } uidControlBlock *cb; if(sceKernelGetUIDcontrolBlockWithType(mbxid, uidMboxType, &cb) != 0) { sceKernelCpuResumeIntr(intr); RESET_K1; return SCE_KERNEL_ERROR_UNKNOWN_MBXID; } if(IS_USER_MODE && !(cb->attr & 0x2)) { sceKernelCpuResumeIntr(intr); RESET_K1; return SCE_KERNEL_ERROR_ILLEGAL_PERM; } THREADMAN_TRACE(0x49, 2, mbxid, message); WaitQInfo *qinfo = UID_INFO(WaitQInfo, cb, uidWaitQType); MboxInfo *mbxinfo = UID_INFO(MboxInfo, cb, uidMboxType); if(qinfo->numWaitThreads > 0) { if(qinfo->waitThread->unk_24 != 0) { qinfo->waitThread->unk_24->unk_0 = message; } sub_00000480(cb, 0, isIntr, intr); } else { if(sub_00006ADC(mbxinfo, qinfo, message) != 0) { sceKernelCpuResumeIntr(intr); RESET_K1; return SCE_KERNEL_ERROR_ILLEGAL_ADDR; } } sceKernelCpuResumeIntr(intr); RESET_K1; return 0; }
/*---------------------------------------------------------------------------*/ int kmodIsIntrContext() { return sceKernelIsIntrContext(); }