Beispiel #1
0
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;
}
Beispiel #2
0
//OK
int sceUsbAccGetInfo(u64 *lpDst) // at 0x00000068 
{
	int ret = 0;
	int curIntCtrlState = sceKernelCpuSuspendIntr();
	if (!g_bAttached)
	{
		sceKernelCpuResumeIntr(curIntCtrlState);
		return (0x80243007);
	}
	if (sceUsbBus_driver_8A3EB5D2() == 0)
	{
		sceKernelCpuResumeIntr(curIntCtrlState);
		return (0x80243701);
	}

	if (lpDst)
	{
		if (((((u32)lpDst + 8) | (u32)lpDst) & (pspSdkGetK1() << 11)) >= 0)
		{
			*lpDst = g_info;
		}
	}
	else
	{
		ret = 0x80243002;
	}

	sceKernelCpuResumeIntr(curIntCtrlState);
	return (ret);
}
Beispiel #3
0
//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;
}
Beispiel #4
0
s32 sceSTimerStartCount(s32 timerId)
{
    SceSysTimer *timer = &timers[timerId & 3];
    if (timer->curTimer != timerId)
        return 0x80020097;
    s32 oldIntr = sceKernelCpuSuspendIntr();
    if ((timer->hw->unk256 & 0x00800000) != 0) {
        sceKernelCpuResumeIntr(oldIntr);
        return 0x8002009A;
    }
    timer->hw->unk0 = timer->hw->unk256 | 0x00800000;
    sceKernelCpuResumeIntr(oldIntr);
    return 0;
}
Beispiel #5
0
s32 sceSTimerSetHandler(s32 timerId, s32 arg1, SceSysTimerCb arg2, s32 arg3)
{
    SceSysTimer *timer = &timers[timerId & 3];
    if (timer->curTimer != timerId)
        return 0x80020097;
    s32 oldIntr = sceKernelCpuSuspendIntr();
    s32 mask;
    if (arg1 <= 0x3FFFFF)
        mask = arg1;
    else
        mask = 0x3FFFFF;
    if (arg2 == NULL) {
        timer->cb = NULL;
        timer->unk24 = 0;
        timer->unk28 = 0;
        _sceSTimerStopCount(timer);
        sceKernelDisableIntr(timer->s32Num);
    } else {
        timer->cb = arg2;
        timer->unk28 = arg3;
        timer->hw->unk0 = timer->hw->unk256 & 0xFFC00000;
        timer->hw->unk0 |= mask;
        timer->hw->unk0 = timer->hw->unk256 | 0x80400000;
        sceKernelEnableIntr(timer->s32Num);
    }
    sceKernelCpuResumeIntr(oldIntr);
    return 0;
}
Beispiel #6
0
static u32 sub_05F0(void)
{   
    s32 pspModel;
    s32 apiType;
    s32 intrState;
    
    invoke_init_callback(3);
    patchGames();   
    sceKernelSetDNAS(0);
    
    intrState = sceKernelCpuSuspendIntr();
    
    pspModel = sceKernelGetModel();
    if (pspModel >= PSP_4000) {
        apiType = sceKernelApplicationType();
        switch (apiType) {
        case SCE_INIT_APPLICATION_VSH: 
        case SCE_INIT_APPLICATION_UPDATER: 
        case SCE_INIT_APPLICATION_POPS:
            UtilsForKernel_39FFB756(81);
            break;
        default:
            UtilsForKernel_39FFB756(0);
            break;
        }
    }
    sceKernelCpuResumeIntr(intrState);
    PowerUnlock();
    return SCE_ERROR_OK;
}
Beispiel #7
0
int sceKermit_driver_9160841C(int pin_n, int allow_callbacks)
{
	/* lock the power source, no shutdown */
	int res = sceKernelPowerLock(0);
	
	/* check if valid */
	if (res == 0)
	{
		/* wait? */
		sub_00000908();
		
		/* suspend interrupts */
		int intr = sceKernelCpuSuspendIntr();
		
		PIN_HIGH(0xBC300038, pin_n);
		PIN_LOW(0xBC300050, pin_n);
		PIN_HIGH(0xBC300050, pin_n);
		
		/* resume all the interrupts */
		sceKernelCpuResumeIntr(intr);
		
		/* wait on work sema */
		if (allow_callbacks)	sceKernelWaitSemaCB(g_work_sema[pin_n], 1, NULL);
		else					sceKernelWaitSema(g_work_sema[pin_n], 1, NULL);
		
		/* unlock power */
		res = sceKernelPowerUnlock(0);
		
		/* resolve +ve res to 0 */
		if (res > 0) res = 0;
	}
	
	/* return the result */
	return res;
}
int sub_00000588(void)
{
	int intr;
	void (*ptr)(u32) = (void*)g_func_1200;

	(*ptr)(0);
	open_iso();
	intr = sceKernelCpuSuspendIntr();

	/* sceUmdManGetUmdDiscInfo patch */
	_sw(0xE0000800, g_sceNp9660_driver_text_addr + g_offs->Data1);
	_sw(0x00000009, g_sceNp9660_driver_text_addr + g_offs->Data2);
	_sw(g_total_blocks, g_sceNp9660_driver_text_addr + g_offs->Data3);
	_sw(g_total_blocks, g_sceNp9660_driver_text_addr + g_offs->Data4);
	_sw(0x00000000, g_sceNp9660_driver_text_addr + g_offs->Data5);

	sceKernelCpuResumeIntr(intr);

	if(g_data_1204 == 0) {
		g_data_1204 = 1;
		sceKernelDelayThread(800000);
	}

	clear_cache();
	sceKernelSetQTGP3(g_umddata);

	return 0;
}
Beispiel #9
0
s32 sceUmdModuleStart(s32 argc, void *argp)
{   
    s32 intrState;

	(void)argc;
	(void)argp;
    
    memset(&g_mediaMan, 0, sizeof g_mediaMan);
    
    // TODO: Check assignment order; might be :DMU
    g_umdFileSystem[0] = 'U';
    g_umdFileSystem[1] = 'M';
    g_umdFileSystem[2] = 'D';
    g_umdFileSystem[3] = ':';
      
    g_eventId = sceKernelCreateEventFlag("SceMediaManUser", SCE_KERNEL_EA_MULTI | 0x1, 0, NULL);
    if (g_eventId < 0) 
        return SCE_KERNEL_NO_RESIDENT;
    
    g_isAssigned = SCE_UMD_DEVICE_NOT_ASSIGNED;
    intrState = sceKernelCpuSuspendIntr();
        
    g_driveState |= SCE_UMD_MEDIA_OUT;
    sceKernelSetEventFlag(g_eventId, 1);
        
    sceKernelCpuResumeIntr(intrState);
    return SCE_KERNEL_RESIDENT;
}
Beispiel #10
0
void checkDispatchCases(const char *name, void (*testfunc)(int)) {
	int state;

	dispatchCheckpoint("%s without changes:", name);
	testfunc(0);
	flushschedf();
	
	didResched = 0;
	schedf("\n");
	dispatchCheckpoint("%s with short dispatch suspend:", name);
	testfunc(1);
	flushschedf();

	didResched = 0;
	schedf("\n");
	dispatchCheckpoint("%s while dispatch suspended:", name);
	// Starting a thread apparently resumes the dispatch thread.
	++ignoreResched;
	state = sceKernelSuspendDispatchThread();
	dispatchCheckpoint("sceKernelSuspendDispatchThread: %08x", state);
	testfunc(0);
	dispatchCheckpoint("sceKernelResumeDispatchThread: %08x", sceKernelResumeDispatchThread(state));
	--ignoreResched;
	flushschedf();

	didResched = 0;
	schedf("\n");
	dispatchCheckpoint("%s while intr suspended:", name);
	state = sceKernelCpuSuspendIntr();
	dispatchCheckpoint("sceKernelCpuSuspendIntr: %08x", state);
	testfunc(1);
	dispatchCheckpoint("sceKernelCpuResumeIntr: %08x", sceKernelCpuResumeIntr(state));
	flushschedf();
}
Beispiel #11
0
int sub_01B8(int flag, int enable)
{
    int oldIntr = sceKernelCpuSuspendIntr();
    int reg = LW(0xBC10004C);
    *(int*)(0xBC10004C) = enable ? (reg | flag) : (reg ^ (reg & flag));
    sceKernelCpuResumeIntr(intr);
    return (reg & flag) != 0;
}
Beispiel #12
0
s32 sceSTimerSetPrscl(s32 timerId, s32 arg1, s32 arg2)
{
    SceSysTimer *timer = &timers[timerId & 3];
    if (timer->curTimer != timerId)
        return 0x80020097;
    if (arg1 == 0 || arg2 == 0)
        return 0x80020099;
    if (arg2 / arg1 < 12)
        return 0x80020099;
    s32 oldIntr = sceKernelCpuSuspendIntr();
    if ((timer->hw->unk256 & 0x00800000) != 0) {
        sceKernelCpuResumeIntr(oldIntr);
        return 0x8002009A;
    }
    timer->hw->unk8 = arg1;
    timer->hw->unk12 = arg2;
    sceKernelCpuResumeIntr(oldIntr);
    return 0;
}
Beispiel #13
0
s32 sceSTimerStopCount(s32 timerId)
{
    SceSysTimer *timer = &timers[timerId & 3];
    if (timer->curTimer != timerId)
        return 0x80020097;
    s32 oldIntr = sceKernelCpuSuspendIntr();
    _sceSTimerStopCount(timer);
    sceKernelCpuResumeIntr(oldIntr);
    return 0;
}
Beispiel #14
0
//Subroutine sceUmd_060E934D - Address 0x00000CF0
void sceUmdSetDetectUMDCallBackId(SceUID callbackId)
{
    s32 intrState;
    
    intrState = sceKernelCpuSuspendIntr();
    
    g_umdCallbackId = callbackId;
    
    sceKernelCpuResumeIntr(intrState);
}
Beispiel #15
0
//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;
}
Beispiel #16
0
s32 sceSTimerResetCount(s32 timerId)
{
    SceSysTimer *timer = &timers[timerId & 3];
    if (timer->curTimer != timerId)
        return 0x80020097;
    s32 oldIntr = sceKernelCpuSuspendIntr();
    timer->hw->unk0 |= 0x80000000;
    timer->unk24 = 0;
    sceKernelCpuResumeIntr(oldIntr);
    return 0;
}
Beispiel #17
0
s32 module_reboot_before()
{
    s32 oldIntr = sceKernelCpuSuspendIntr();
    s32 i;
    for (i = 0; i < 4; i++) {
        _sceSTimerStopCount(&timers[i]);
        sceKernelReleaseIntrHandler(timers[i].s32Num);
    }
    sceKernelCpuResumeIntr(oldIntr);
    return 0;
}
Beispiel #18
0
//Subroutine sceUmd_982272FE - Address 0x00000444
void sceUmdSetDriveStatus(s32 state)
{
    s32 intrState;
    
    intrState = sceKernelCpuSuspendIntr();
    
    g_driveState |= state;
    sceKernelSetEventFlag(g_eventId, state);
    
    sceKernelCpuResumeIntr(intrState);
}
Beispiel #19
0
//Subroutine sceUmd_6EDF57F1 - Address 0x000003E8
void sceUmdClearDriveStatus(s32 state)
{
    s32 intrState;
    
    intrState = sceKernelCpuSuspendIntr();
    
    sceKernelClearEventFlag(g_eventId, ~state);
    g_driveState &= (~state);
    
    sceKernelCpuResumeIntr(intrState);
}
Beispiel #20
0
//Subroutine sceUmd_07E98AF8 - Address 0x0000049C
u32 sceUmdSetErrorStatus(s32 state) //param state: one of SCE_UMD_errors
{
    s32 intrState;
    
    intrState = sceKernelCpuSuspendIntr();
    
    g_errorState = state;
    
    sceKernelCpuResumeIntr(intrState);
    return SCE_ERROR_OK;
}
Beispiel #21
0
// OK
int sceUsbAccGetAuthStat() // at 0x00000000 
{
	int curIntCtrlState = sceKernelCpuSuspendIntr();
	int ret = 0x80243007;
	if (g_bAttached)
	{
		ret = sceUsbBus_driver_8A3EB5D2() ? 0 : 0x80243701;
	}

	sceKernelCpuResumeIntr(curIntCtrlState);
	return (ret);
}
extern "C" int main(int argc, char *argv[]) {
	checkpointNext("Not suspended:");
	checkpoint("  0: %08x", sceKernelIsCpuIntrSuspended(0));
	checkpoint("  1: %08x", sceKernelIsCpuIntrSuspended(1));
	checkpoint("  2: %08x", sceKernelIsCpuIntrSuspended(2));
	checkpoint("  0xDEADBEEF: %08x", sceKernelIsCpuIntrSuspended(0xDEADBEEF));

	checkpointNext("Suspended:");
	int flags1 = sceKernelCpuSuspendIntr();
	int flags2 = sceKernelCpuSuspendIntr();
	checkpoint("  0: %08x", sceKernelIsCpuIntrSuspended(0));
	checkpoint("  1: %08x", sceKernelIsCpuIntrSuspended(1));
	checkpoint("  2: %08x", sceKernelIsCpuIntrSuspended(2));
	checkpoint("  0xDEADBEEF: %08x", sceKernelIsCpuIntrSuspended(0xDEADBEEF));
	checkpoint("  flags (inner): %08x", sceKernelIsCpuIntrSuspended(flags2));
	checkpoint("  flags (outer): %08x", sceKernelIsCpuIntrSuspended(flags1));
	sceKernelCpuResumeIntr(flags2);
	sceKernelCpuResumeIntr(flags1);

	return 0;
}
Beispiel #23
0
//Subroutine sceUmd_0E3F8ED9 - Address 0x0000087C
u32 sceUmdUnRegisterReplaceCallBack(void)
{
    s32 intrState;
    
    intrState = sceKernelCpuSuspendIntr();
       
    g_mediaMan.umdReplaceCallback = NULL;
    g_mediaMan.umdReplaceCallbackGp = 0;
       
    sceKernelCpuResumeIntr(intrState);       
    return SCE_ERROR_OK;
}
Beispiel #24
0
//Subroutine sceUmd_3748C4DB - Address 0x00000838
u32 sceUmdRegisterReplaceCallBack(s32 (*umdReplaceCallback)(s32))
{
    s32 intrState;
    
    intrState = sceKernelCpuSuspendIntr();
       
    g_mediaMan.umdReplaceCallback = umdReplaceCallback;
    g_mediaMan.umdReplaceCallbackGp = pspGetGp();
       
    sceKernelCpuResumeIntr(intrState);       
    return SCE_ERROR_OK;
}
Beispiel #25
0
//Subroutine sceUmd_76D356F9 - Address 0x000008B4
u32 sceUmd_76D356F9(s32 (*arg0)(void))
{
    s32 intrState;
    
    intrState = sceKernelCpuSuspendIntr();
       
    g_mediaMan.unk60 = arg0;
    g_mediaMan.unk36 = pspGetGp();
       
    sceKernelCpuResumeIntr(intrState);
    return SCE_ERROR_OK;
}
Beispiel #26
0
//Subroutine sceUmd_99CA645A - Address 0x00000694
void sceUmdUnRegisterDeactivateCallBack(void)
{
    s32 intrState;
    
    intrState = sceKernelCpuSuspendIntr();
    
    g_mediaMan.umdDeactivateCallback = NULL;
    g_mediaMan.umdDeactivateCallbackGp = 0;
    g_mediaMan.umdDeactivateCallbackParam = NULL;
    
    sceKernelCpuResumeIntr(intrState);
}
Beispiel #27
0
//6690
int sceKernelRegisterSysEventHandler(SceSysEventHandler *handler)
{
    int intr = sceKernelCpuSuspendIntr();

    if(sceKernelIsRegisterSysEventHandler(handler))
    {
        //66f8
        sceKernelCpuResumeIntr(intr);

        return SCE_KERNEL_ERROR_FOUND_HANDLER;
    }

    handler->busy = 0;
    handler->r28 = gp;
    handler->next = sys_event_handlers;

    sys_event_handlers = handler;

    sceKernelCpuResumeIntr(intr);

    return 0;
}
Beispiel #28
0
//Subroutine sceUmd_1471F63D - Address 0x00000620
u32 sceUmdUnRegisterMediaPresentCallBack(void)
{
    s32 intrState;
    
    intrState = sceKernelCpuSuspendIntr();
    
	g_mediaMan.umdMediaPresentCallbackParam = NULL;
	g_mediaMan.umdMediaPresentCallbackGp = 0;
	g_mediaMan.umdMediaPresentCallback = NULL;
    
    sceKernelCpuResumeIntr(intrState);
    return SCE_ERROR_OK;
}
Beispiel #29
0
//Subroutine sceUmd_63517CBA - Address 0x000005CC 
u32 sceUmdRegisterMediaPresentCallBack(s32(*MediaPresentCallback)(void *), void *param)
{
    s32 intrState;
    
    intrState = sceKernelCpuSuspendIntr();
    
	g_mediaMan.umdMediaPresentCallback = MediaPresentCallback;
	g_mediaMan.umdMediaPresentCallbackParam = param;
	g_mediaMan.umdMediaPresentCallbackGp = pspGetGp();
    
    sceKernelCpuResumeIntr(intrState);
    return SCE_ERROR_OK;
}
Beispiel #30
0
//Subroutine sceUmd_D1C80E51 - Address 0x00000720
u32 sceUmdRegisterDeactivateCallBack(s32 (*deactivateCallback)(s32, void *), void *param)
{
    s32 intrState;
    
    intrState = sceKernelCpuSuspendIntr();
    
    g_mediaMan.umdDeactivateCallback = deactivateCallback;
    g_mediaMan.umdDeactivateCallbackParam = param;
    g_mediaMan.umdDeactivateCallbackGp = pspGetGp();
    
    sceKernelCpuResumeIntr(intrState);
    return SCE_ERROR_OK;
}