Пример #1
0
void checkEventFlag(int doDispatch) {
	SceUID flag = sceKernelCreateEventFlag("eventflag", 0, 0xFFFFFFFF, NULL);
	dispatchCheckpoint("sceKernelCreateEventFlag: %08x", flag >= 0 ? 1 : flag);
	dispatchCheckpoint("sceKernelClearEventFlag: %08x", sceKernelClearEventFlag(flag, 1));
	dispatchCheckpoint("sceKernelWaitEventFlag: %08x", sceKernelWaitEventFlag(flag, 1, PSP_EVENT_WAITAND, NULL, NULL));
	dispatchCheckpoint("sceKernelWaitEventFlag invalid: %08x", sceKernelWaitEventFlag(flag, 0, 0, NULL, NULL));
	dispatchCheckpoint("sceKernelDeleteEventFlag: %08x", sceKernelDeleteEventFlag(flag));
	flag = sceKernelCreateEventFlag("test", 0, 0xFFFFFFFF, NULL);
	dispatchCheckpoint("sceKernelCreateEventFlag: %08x", flag >= 0 ? 1 : flag);
	startLockThreadEventFlag(flag);
	int state;
	if (doDispatch) {
		++ignoreResched;
		state = sceKernelSuspendDispatchThread();
		dispatchCheckpoint("sceKernelSuspendDispatchThread: %08x", state);
	}
	SceUInt timeout = 300;
	dispatchCheckpoint("sceKernelWaitEventFlag: %08x", sceKernelWaitEventFlag(flag, 1, PSP_EVENT_WAITAND, NULL, &timeout));
	dispatchCheckpoint("sceKernelClearEventFlag: %08x", sceKernelClearEventFlag(flag, 1));
	if (doDispatch) {
		dispatchCheckpoint("sceKernelResumeDispatchThread: %08x", sceKernelResumeDispatchThread(state));
		--ignoreResched;
	}
	endLockThreadEventFlag(flag);
	dispatchCheckpoint("sceKernelPollEventFlag: %08x", sceKernelPollEventFlag(flag, 1, PSP_EVENT_WAITAND, NULL));
	dispatchCheckpoint("sceKernelDeleteEventFlag: %08x", sceKernelDeleteEventFlag(flag));
}
Пример #2
0
int sub_0x1000002(int arg)
{
	sceKernelLockMutex(meRpc.mutex, 1, 0);
	int argSr = arg >> 1;
	int val = *(int*)0xbfc00714;
	*(int*)0xbfc00710 = arg;
	int arg0 = 0;
	if (argSr < 133 || val != 1)
	{
		if (argSr >= 148 && val == 3)
			arg0 = 2;
		else
			return 0;
	}
	int* meTable = (int*)0xbfc00600;
	meTable[0] = 7;//sets 0xbfc00714 to arg0 then calls sceSysregMsifClkSelect(0, arg0) same as sceMePowerSelectAvcClock
	meTable[2] = arg0;//if (val==1 && ((arg>>1)>=133)) arg = 0, if (val==3 && ((arg>>1)>=133)) arg0 = 2
	meTable[3] = 0;
	meTable[4] = 0;
	meTable[5] = 0;
	meTable[6] = 0;
	meTable[7] = 0;
	meTable[8] = 0;
	meTable[9] = 0;
	sceDdrFlush(5);
	sceSysregInterruptToOther();
	sceKernelWaitEventFlag(meRpc.event, 1, SCE_EVENT_WAITCLEAR, 0, 0);
	return 0;	
}
Пример #3
0
int clear_thread(SceSize args, void *argp)
{
    int result;
    u32 outBits;
    SceKernelThreadInfo info;
    info.size = sizeof(SceKernelThreadInfo);

    sceKernelReferThreadStatus (0, &info);
    printf("thread '%-12s' sp %p pattern %08x START\n", info.name, info.stack, CLEAR_PATTERN);

    while(!done)
    {
        // 0x00FF00FF initPattern
        // 0x000000FF should work - ok
        // 0x00000FF0 should fail - ok
        // 0x0000FF00 should fail - ok

        outBits = 0xbaadc0de;
        result = sceKernelWaitEventFlag(evid, CLEAR_PATTERN, PSP_EVENT_WAITCLEAR, &outBits, 0);
        printf("thread '%-12s' result %08x outBits %08x\n", info.name, result, (int)outBits);

        sceKernelSleepThreadCB();
    }

    return 0;
}
Пример #4
0
int or_thread(SceSize args, void *argp)
{
    int result;
    u32 outBits;
    SceKernelThreadInfo info;
    info.size = sizeof(SceKernelThreadInfo);

    sceKernelReferThreadStatus (0, &info);
    printf("thread '%-12s' sp %p pattern %08x START\n", info.name, info.stack, OR_PATTERN);

    while(!done)
    {
        // 0x00FF00FF initPattern
        // 0x000000FF should work - ok
        // 0x00000FF0 should work - ok
        // 0x0000FF00 should fail - ok

        outBits = 0xbaadc0de;
        volatile SceUInt timeout = 1000*1000*5;
        //result = sceKernelWaitEventFlag(evid, OR_PATTERN, PSP_EVENT_WAITOR, &outBits, &timeout);
        result = sceKernelWaitEventFlag(evid, OR_PATTERN, PSP_EVENT_WAITOR, &outBits, 0);
        printf("thread '%-12s' result %08x outBits %08x\n", info.name, result, (int)outBits);

        //if (timeout) timeout = *(int*)timeout;
        printf("timeout %d/%08x\n", (int)timeout, (int)timeout);


        sceKernelSleepThreadCB();
    }

    return 0;
}
Пример #5
0
int lockThreadEventFlag(SceSize argc, void *argp) {
	SceUID flag = *(SceUID *)argp;
	dispatchCheckpoint("T sceKernelWaitEventFlag: %08x", sceKernelWaitEventFlag(flag, 3, PSP_EVENT_WAITAND, NULL, NULL));
	dispatchCheckpoint("T sceKernelDelayThread: %08x", sceKernelDelayThread(3000));
	dispatchCheckpoint("T sceKernelClearEventFlag: %08x", sceKernelClearEventFlag(flag, 1));
	return 0;
}
Пример #6
0
int main_thread(SceSize args, void *argp)
{
	SceUID block_id;
	void *vram;

	block_id = sceKernelAllocPartitionMemory(4, "debugmenu", PSP_SMEM_Low, 512*272*2, NULL);
	if(block_id < 0)
	{
		Kprintf("Error could not allocate memory buffer 0x%08X\n", block_id);
		goto error;
	}
	 
	vram = (void*) (0xA0000000 | (unsigned int) sceKernelGetBlockHeadAddr(block_id));
	g_eventflag = sceKernelCreateEventFlag("DebugMenuEvent", 0, 0, NULL);
	if(g_eventflag < 0)
	{
		Kprintf("Could not create event flag %08X\n", g_eventflag);
		goto error;
	}

	//sceCtrlRegisterButtonCallback(0, PSP_CTRL_HOME, button_callback, NULL);
	sceCtrlRegisterButtonCallback(3, TRIGGER, button_callback, NULL);
	while(1)
	{
		unsigned int bits;
		if(sceKernelWaitEventFlag(g_eventflag, START_MENU,
					PSP_EVENT_WAITOR | PSP_EVENT_WAITCLEAR, &bits, NULL) < 0)
		{
			break;
		}
		sceCtrlSetButtonMasks(0xFFFF, 1);  // Mask lower 16bits
		sceCtrlSetButtonMasks(0x10000, 2); // Always return HOME key
		sceDisplaySetFrameBufferInternal(0, vram, 512, 0, 1);
		pspDebugScreenInitEx(vram, 0, 0);
		do_menu();
		sceDisplaySetFrameBufferInternal(0, 0, 512, 0, 1);
		sceCtrlSetButtonMasks(0x10000, 0); // Unset HOME key
		sceCtrlSetButtonMasks(0xFFFF, 0);  // Unset mask
		sceKernelClearEventFlag(g_eventflag, ~START_MENU);
	}

error:
	sceKernelExitDeleteThread(0);

	return 0;
}
Пример #7
0
//Subroutine sceUmd_8EF08FCE - Address 0x00000DD4 - Aliases: sceUmdUser_8EF08FCE
s32 sceUmdWaitDriveStat(s32 umdState)
{
    s32 oldK1;
    SceUID eventId;
    u32 resultBits;
    s32 status;
        
    oldK1 = pspShiftK1();
    eventId = sceUmdGetUserEventFlagId();
        
    if (!(umdState & UMD_SUPPORTED_WAIT_DRIVE_STATES))
        return SCE_ERROR_ERRNO_INVALID_ARGUMENT; 
       
    status = sceKernelWaitEventFlag(eventId, umdState, SCE_KERNEL_EW_OR, &resultBits, NULL);
       
    pspSetK1(oldK1);
    return status;
}
Пример #8
0
int sub_0x1000020(){
	volatile int* address = (int*)0xbfc0070c;
	int first = *address;
	int second = *address;
	int* meTable = (int*)0xbfc00600;
	meTable[0] = 391;//same as sceMePower_driver_E9F69ACF
	meTable[2] = (first & 0x1ff0000)>>16;
	meTable[3] = second & 0x1ff;
	meTable[4] = 0;
	meTable[5] = 0;
	meTable[6] = 0;
	meTable[7] = 0;
	meTable[8] = 0;
	meTable[9] = 0;
	sceDdrFlush(5);
	sceSysregInterruptToOther();
	sceKernelWaitEventFlag(meRpc.event, 1, SCE_EVENT_WAITCLEAR, 0, 0);
	sceKernelUnlockMutex(meRpc.mutex, 1);
	return 0;
}
Пример #9
0
//Subroutine sceUmd_8DCFBA06 - Address 0x00000B50 - Aliases: sceUmdUser_56202973
s32 sceUmdWaitDriveStatWithTimer(u32 umdState, u32 timeout)
{
    s32 oldK1;
    SceUID eventId;
    SceUInt *pTimeout;
    u32 resultBits;
    s32 status;
        
    oldK1 = pspShiftK1();
    eventId = sceUmdGetUserEventFlagId();
        
    if (!(umdState & UMD_SUPPORTED_WAIT_DRIVE_STATES))
        return SCE_ERROR_ERRNO_INVALID_ARGUMENT;
       
    if (timeout != 0)
        pTimeout = &timeout;
    else
        pTimeout = NULL;
       
    status = sceKernelWaitEventFlag(eventId, umdState, SCE_KERNEL_EW_OR, &resultBits, pTimeout);
    
    pspSetK1(oldK1);
    return status;
}
Пример #10
0
void testFirstUndefinedUids() {
	printf("%08X\n", sceKernelWaitEventFlag(1, 1, PSP_EVENT_WAITOR, NULL, NULL));
	printf("%08X\n", sceKernelWaitSema(1, 1, NULL));
}
Пример #11
0
s32 sceKernelWaitEventFlagCB(ARMv7Thread& context, s32 evfId, u32 bitPattern, u32 waitMode, vm::ptr<u32> pResultPat, vm::ptr<u32> pTimeout)
{
	sceLibKernel.Todo("sceKernelWaitEventFlagCB(evfId=0x%x, bitPattern=0x%x, waitMode=0x%x, pResultPat=*0x%x, pTimeout=*0x%x)", evfId, bitPattern, waitMode, pResultPat, pTimeout);

	return sceKernelWaitEventFlag(context, evfId, bitPattern, waitMode, pResultPat, pTimeout);
}
Пример #12
0
int main(int argc, char **argv) {
	SceUID flag = sceKernelCreateEventFlag("wait1", 0, 0xFFFFFFFF, NULL);
	SceKernelEventFlagInfo flaginfo;

	// Something weird is happening: first time status is garbled?
	sceKernelReferEventFlagStatus(flag, &flaginfo);

	WAIT_TEST_SIMPLE("And 0x00000000", flag, 0, PSP_EVENT_WAITAND, 1);
	WAIT_TEST_SIMPLE("Or 0x00000000", flag, 0, PSP_EVENT_WAITOR, 1);
	WAIT_TEST_SIMPLE("Clear 0x00000000", flag, 0, PSP_EVENT_WAITCLEAR, 1);
	WAIT_TEST_SIMPLE("Wrong (0x04) 0x00000000", flag, 0, 0x04, 1);
	WAIT_TEST_SIMPLE("Wrong (0xFF) 0x00000000", flag, 0, 0xFF, 1);

	WAIT_TEST_SIMPLE("And 0x00000001", flag, 1, PSP_EVENT_WAITAND, 1);
	WAIT_TEST_SIMPLE("Or 0x00000001", flag, 1, PSP_EVENT_WAITOR, 1);
	WAIT_TEST_SIMPLE("Clear 0x00000001", flag, 1, PSP_EVENT_WAITCLEAR, 1);
	WAIT_TEST_SIMPLE("Wrong (0x02) 0x00000001", flag, 1, 0x02, 1);
	WAIT_TEST_SIMPLE("Wrong (0x04) 0x00000001", flag, 1, 0x04, 1);
	WAIT_TEST_SIMPLE("Wrong (0x08) 0x00000001", flag, 1, 0x08, 1);
	WAIT_TEST_SIMPLE("Wrong (0x40) 0x00000001", flag, 1, 0x40, 1);
	WAIT_TEST_SIMPLE("Wrong (0x80) 0x00000001", flag, 1, 0x80, 1);
	WAIT_TEST_SIMPLE("Wrong (0xFF) 0x00000001", flag, 1, 0xFF, 1);

	sceKernelSetEventFlag(flag, 0xFFFFFFFF);
	WAIT_TEST_SIMPLE("Clear/Or 0x00000000", flag, 0, PSP_EVENT_WAITCLEAR | PSP_EVENT_WAITOR, 1);

	sceKernelSetEventFlag(flag, 0xFFFFFFFF);
	WAIT_TEST_SIMPLE("Clear/Or 0x00000001", flag, 1, PSP_EVENT_WAITCLEAR | PSP_EVENT_WAITOR, 1);

	sceKernelSetEventFlag(flag, 0xFFFFFFFF);
	WAIT_TEST_SIMPLE("Clear/Or 0x00000001 (no out bits)", flag, 1, PSP_EVENT_WAITCLEAR | PSP_EVENT_WAITOR, 0);

	sceKernelSetEventFlag(flag, 0xFFFFFFFF);
	WAIT_TEST_SIMPLE_TIMEOUT("0xFFFFFFFF & 0x00000000", flag, 0x00000000, PSP_EVENT_WAITAND, 500);
	WAIT_TEST_SIMPLE_TIMEOUT("0xFFFFFFFF & 0xFFFFFFFF", flag, 0xFFFFFFFF, PSP_EVENT_WAITAND, 500);
	WAIT_TEST_SIMPLE_TIMEOUT("0xFFFFFFFF | 0xFFFFFFFF", flag, 0xFFFFFFFF, PSP_EVENT_WAITOR, 500);
	sceKernelClearEventFlag(flag, 0x0000FFFF);
	WAIT_TEST_SIMPLE_TIMEOUT("0x0000FFFF & 0xFFFFFFFF", flag, 0xFFFFFFFF, PSP_EVENT_WAITAND, 500);
	WAIT_TEST_SIMPLE_TIMEOUT("0x0000FFFF | 0xFFFFFFFF", flag, 0xFFFFFFFF, PSP_EVENT_WAITOR, 500);
	WAIT_TEST_SIMPLE_TIMEOUT("0x0000FFFF & 0xFFFFFFFF with clear", flag, 0xFFFFFFFF, PSP_EVENT_WAITAND | PSP_EVENT_WAITCLEAR, 500);
	WAIT_TEST_SIMPLE_TIMEOUT("0x0000FFFF | 0xFFFFFFFF with clear", flag, 0xFFFFFFFF, PSP_EVENT_WAITOR | PSP_EVENT_WAITCLEAR, 500);
	sceKernelClearEventFlag(flag, 0x0000FFFF);
	WAIT_TEST_SIMPLE_TIMEOUT("0x0000FFFF & 0xFFFFFFFF with clear all", flag, 0xFFFFFFFF, PSP_EVENT_WAITAND | PSP_EVENT_WAITCLEARALL, 500);
	WAIT_TEST_SIMPLE_TIMEOUT("0x0000FFFF | 0xFFFFFFFF with clear all", flag, 0xFFFFFFFF, PSP_EVENT_WAITOR | PSP_EVENT_WAITCLEARALL, 500);
	sceKernelClearEventFlag(flag, 0x00000000);
	WAIT_TEST_SIMPLE_TIMEOUT("0x00000000 & 0xFFFFFFFF", flag, 0xFFFFFFFF, PSP_EVENT_WAITAND, 500);
	WAIT_TEST_SIMPLE_TIMEOUT("Zero timeout", flag, 0xFFFFFFFF, PSP_EVENT_WAITAND, 0);
	WAIT_TEST_SIMPLE_TIMEOUT("5ms timeout", flag, 0xFFFFFFFF, PSP_EVENT_WAITAND, 5);

	// Set off thread.
	schedulingLogPos = 0;
	schedulingPlacement = 1;
	SCHED_LOG(A, 1);
	SceUInt timeout = 5000;
	SceUID thread = sceKernelCreateThread("waitTest", (void *)&waitTestFunc, 0x12, 0x10000, 0, NULL);
	sceKernelStartThread(thread, sizeof(flag), &flag);
	SCHED_LOG(B, 1);
	int result = sceKernelWaitEventFlag(flag, 0xFFFFFFFF, PSP_EVENT_WAITAND, NULL, &timeout);
	SCHED_LOG(E, 1);
	printf("Wait timeout: %s (thread=%08X, main=%08X, remaining=%d)\n", schedulingLog, schedulingResult, result, (timeout + 5) / 1000);

	sceKernelDeleteEventFlag(flag);

	SceUID deleteThread = CREATE_SIMPLE_THREAD(deleteMeFunc);
	flag = sceKernelCreateEventFlag("wait1", 0, 0x00000000, NULL);
	sceKernelStartThread(deleteThread, sizeof(int), &flag);
	sceKernelDelayThread(500);
	sceKernelDeleteEventFlag(flag);

	WAIT_TEST_SIMPLE("NULL", 0, 0, PSP_EVENT_WAITAND, 0);
	WAIT_TEST_SIMPLE("Invalid", 0xDEADBEEF, 0, PSP_EVENT_WAITAND, 0);
	WAIT_TEST_SIMPLE("Deleted", flag, 0, PSP_EVENT_WAITAND, 0);

	BASIC_SCHED_TEST("NULL",
		result = sceKernelWaitEventFlag(0, 0xFFFFFFFF, PSP_EVENT_WAITAND, NULL, NULL);
	);
Пример #13
0
static int deleteMeFunc(SceSize argSize, void* argPointer) {
	u32 result_bits = 0xDEADBEEF;
	int result = sceKernelWaitEventFlag(*(int*) argPointer, 0xFFFFFFFF, PSP_EVENT_WAITAND, &result_bits, NULL);
	printf("After delete: %08X (bits=%08X)\n", result, (uint) result_bits);
	return 0;
}
Пример #14
0
int main_thread(SceSize args, void *argp)
{
	int ret;
	int intc;
	unsigned char *plow, *phigh;
	int low, high;

	memset(g_buf, 0, KPRINTF_BUF_SIZE);
	g_writepos = 0;
	g_readpos = 0;
	g_total = 0;
	plow = NULL;
	phigh = NULL;

	g_eventflag = sceKernelCreateEventFlag("UsbKprintfEvent", 0, 0, 0);
	if(g_eventflag < 0)
	{
		printf("Error creating event flag %08X\n", g_eventflag);
	}

	sceKernelRegisterDebugPutchar(PutCharDebug);

	while(1)
	{
		ret = sceKernelWaitEventFlag(g_eventflag, KPRINTF_EVENT, 0x21, 0, 0);
		if(ret < 0)
		{
			sceKernelExitDeleteThread(0);
		}

		low = 0;
		high = 0;

		intc = pspSdkDisableInterrupts();
		if(g_total > 0)
		{
			plow = &g_buf[g_readpos];
			low = (KPRINTF_BUF_SIZE - g_readpos) < g_total ? (KPRINTF_BUF_SIZE - g_readpos) : g_total ;
			if(low < g_total)
			{
				phigh = g_buf;
				high = g_total - low;
			}
		}
		pspSdkEnableInterrupts(intc);

		if((low != 0) && (high == 0))
		{
			printf("%.*s", low, plow);
		}
		else if((low != 0) && (high != 0))
		{
			printf("%.*s%.*s", low, plow, high, phigh);
		}

		intc = pspSdkDisableInterrupts();
		g_total -= (low+high);
		g_readpos += (low+high);
		g_readpos %= KPRINTF_BUF_SIZE;
		pspSdkEnableInterrupts(intc);
	}

	return 0;
}