static void
spu_printf_handler_entry(uint64_t arg)
{
	SampleUtilSpursPrintfService *service = (SampleUtilSpursPrintfService *)(uintptr_t)arg;
	int	ret;
	for (;;) {
		sys_spu_thread_t	spu;
		sys_event_t	event;

		ret = sys_event_queue_receive(service->equeue, &event, 0);

		if (event.source == TERMINATING_PORT_NAME) {
			printf ("Finalizing the spu printf handler\n");
			sys_ppu_thread_exit(0);
		}
		spu = event.data1;
		int sret = spu_thread_printf(spu, event.data3);
		ret = sys_spu_thread_write_spu_mb(spu, sret);
		if (ret) {
			printf ("sys_spu_thread_write_spu_mb failed (%d)\n", ret);
			sys_ppu_thread_exit(-1);
		}
	}
	/* never reach here */
	sys_ppu_thread_exit(0);
}
Beispiel #2
0
static void testplugin_thread(uint64_t arg)
{
	DPRINTF("Hello VSH\n");
	
	while (!done)
	{
		CellPadData data;
		
		if (cellPadGetData(0, &data) == CELL_PAD_OK && data.len > 0)
		{
			if ((data.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_L3) && (data.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_R2))
			{
				if (data.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_CROSS)
				{				
					// power off
					vshmain_87BB0001(1);
					break;
				}
				else if (data.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_CIRCLE)
				{				
					// reboot
					vshmain_87BB0001(2);
					break;
				}
			}
		}
		
		sys_timer_usleep(70000);
	}
	
	DPRINTF("Exiting main thread!\n");	
	sys_ppu_thread_exit(0);
}
Beispiel #3
0
void semTrywait(uint64_t arg) {
	if (sys_semaphore_trywait(g_sem)) {
		printf("[!] sys_semaphore_trywait: Something went wrong!\n");
		exit(-1);
	}
	sys_ppu_thread_exit(0);
}
Beispiel #4
0
static void event_loop(uint64_t data)
#endif
{
   float out_tmp[CELL_AUDIO_BLOCK_SAMPLES * AUDIO_CHANNELS]
      __attribute__((aligned(16)));
   sys_event_queue_t id;
   sys_ipc_key_t key;
   sys_event_t event;
   ps3_audio_t *aud = data;

   cellAudioCreateNotifyEventQueue(&id, &key);
   cellAudioSetNotifyEventQueue(key);

   while (!aud->quit_thread)
   {
      sys_event_queue_receive(id, &event, SYS_NO_TIMEOUT);

      sys_lwmutex_lock(&aud->lock, SYS_NO_TIMEOUT);
      if (fifo_read_avail(aud->buffer) >= sizeof(out_tmp))
         fifo_read(aud->buffer, out_tmp, sizeof(out_tmp));
      else
         memset(out_tmp, 0, sizeof(out_tmp));
      sys_lwmutex_unlock(&aud->lock);
      sys_lwcond_signal(&aud->cond);

      cellAudioAddData(aud->audio_port, out_tmp,
            CELL_AUDIO_BLOCK_SAMPLES, 1.0);
   }

   cellAudioRemoveNotifyEventQueue(key);
   sys_ppu_thread_exit(0);
}
Beispiel #5
0
void semPost(uint64_t arg) {
	sys_timer_sleep(1);
	if (sys_semaphore_post(g_sem, arg) & ~0x8001000A) {
		printf("[!] sys_semaphore_post: Something went wrong!\n");
		exit(-1);
	}
	sys_ppu_thread_exit(0);
}
void gsiExitThread(GSIThreadID id)
{
	// This should only be called from the thread that was created with the thread id = id
	sys_ppu_thread_t thisThread;

	sys_ppu_thread_get_id(&thisThread);
	if (thisThread == id)
		sys_ppu_thread_exit(0);
}
Beispiel #7
0
/***********************************************************************
* stop thread
***********************************************************************/
static void vsh_menu_stop_thread(uint64_t arg)
{
    done = 1;

    if(vsh_menu_tid != (sys_ppu_thread_t)-1)
    {
        uint64_t exit_code;
        sys_ppu_thread_join(vsh_menu_tid, &exit_code);
    }

    sys_ppu_thread_exit(0);
}
Beispiel #8
0
static void testplugin_stop_thread(uint64_t arg)
{
	DPRINTF("testplugin_stop_thread\n");
	done = 1;
	
	if (thread_id != (sys_ppu_thread_t)-1)
	{
		uint64_t exit_code;
		sys_ppu_thread_join(thread_id, &exit_code);
	}
	
	DPRINTF("Exiting stop thread!\n");
	sys_ppu_thread_exit(0);
}
Beispiel #9
0
void semWaitCheck(uint64_t arg) {
	uint64_t dt;
	uint64_t t0 = sys_time_get_system_time();
	if (sys_semaphore_wait(g_sem, arg)) {
		printf("[!] sys_semaphore_wait: Something went wrong!\n");
		exit(-1);
	}
	dt = sys_time_get_system_time() - t0;
	if (dt / 1000000 < 1) {
		printf("[!] sys_semaphore_wait: Woke up too early!\n");
		exit(-1);
	}
	printf("sys_semaphore_wait: Thread woke up successfully\n");
	sys_ppu_thread_exit(0);
}
Beispiel #10
0
void thread_FileCopy(uint64_t /*arg*/)
{	
	gamePKG->nStatus = STATUS_COPY_START;

	FILE *filer			= NULL;
	FILE *filew			= NULL;
	uint64_t numr		= 0;	// elements read
	uint64_t numw		= 0;	// elements wrote	
	uint64_t nTotalRead = 0;
	double nCopyPct		= 0.0f;
	double nTotDelta	= 0.0f;
	uint32_t nApproxTotDelta = 0;


	char *buffer = NULL;
	buffer = (char*)malloc(BUFF_SIZE);

	filer = fopen(gamePKG->pkglst[gamePKG->nSelectedPKG].path,"rb");

	char szFileOut[256] ="";
	sprintf(
		szFileOut, 
		"/dev_hdd0/vsh/game_pkg/%d/%s", 
		gamePKG->pkglst[gamePKG->nSelectedPKG].nPKGID, 
		gamePKG->pkglst[gamePKG->nSelectedPKG].title
	);
	filew = fopen(szFileOut, "wb");

	if(filer != NULL && filew != NULL)
	{
		bool bCopyError = false;

		while(feof(filer) == 0)
		{
			// read
			if((numr = fread(buffer, 1, BUFF_SIZE, filer)) != BUFF_SIZE) 
			{
				if(ferror(filer) != 0) 
				{
					bCopyError = true;
					break;
				}
				else if(feof(filer) != 0)
				{
					// ...
				}
			}
			
			// write
			if((numw = fwrite(buffer, 1, numr, filew)) != numr) 
			{
				bCopyError = true;
				break;
			}
			
			nTotalRead += numr;			

			nCopyPct = (double)(((double)numr / (double)gamePKG->pkglst[gamePKG->nSelectedPKG].nSize) * 100.0f);
			double nTotalPct = (double)((double)nTotalRead / (double)gamePKG->pkglst[gamePKG->nSelectedPKG].nSize) * 100.0f;

			nTotDelta += nCopyPct;
			nApproxTotDelta += (uint32_t)round(nCopyPct);

			if((double)nApproxTotDelta < nTotalPct) 
			{
				// Compensate loss of float/double data, as for example: approx 70% vs. precise 95%
				nApproxTotDelta += (uint32_t)(nTotalPct - (double)nApproxTotDelta);
				nCopyPct += (nTotalPct - (double)nApproxTotDelta);				
			}
			cellMsgDialogProgressBarInc(CELL_MSGDIALOG_PROGRESSBAR_INDEX_SINGLE, (uint32_t)nCopyPct);

			char msg[256] = "";
			sprintf(
				msg, 
				//"%.2f %s / %.2f %s (%.1f %%)(delta: %d %%)",
				"%.2f %s / %.2f %s",
				GetByteUnit(nTotalRead),
				GetByteUnitStr(nTotalRead),
				GetByteUnit(gamePKG->pkglst[gamePKG->nSelectedPKG].nSize),
				GetByteUnitStr(gamePKG->pkglst[gamePKG->nSelectedPKG].nSize)	//,
				//nTotalPct,
				//nApproxTotDelta
			);
			cellMsgDialogProgressBarSetMsg(CELL_MSGDIALOG_PROGRESSBAR_INDEX_SINGLE, msg);
		}

		nCopyPct = (double)(((double)numr / (double)gamePKG->pkglst[gamePKG->nSelectedPKG].nSize) * 100.0f);
		double nTotalPct = (double)((double)nTotalRead / (double)gamePKG->pkglst[gamePKG->nSelectedPKG].nSize) * 100.0f;

		nTotDelta += nCopyPct;
		nApproxTotDelta += (uint32_t)round(nCopyPct);

		if((double)nApproxTotDelta < nTotalPct) 
		{
			// Compensate loss of float/double data, as for example: approx 70% vs. precise 95%
			nApproxTotDelta += (uint32_t)(nTotalPct - (double)nApproxTotDelta);
			nCopyPct += (nTotalPct - (double)nApproxTotDelta);
		}
		cellMsgDialogProgressBarInc(CELL_MSGDIALOG_PROGRESSBAR_INDEX_SINGLE, (uint32_t)nCopyPct);

		char msg[256] = "";
		sprintf(
			msg, 
			//"%.2f %s / %.2f %s (%.1f %%)(delta: %d %%)",
			"%.2f %s / %.2f %s",
			GetByteUnit(nTotalRead),
			GetByteUnitStr(nTotalRead),
			GetByteUnit(gamePKG->pkglst[gamePKG->nSelectedPKG].nSize),
			GetByteUnitStr(gamePKG->pkglst[gamePKG->nSelectedPKG].nSize)	//,
			//nTotalPct,
			//nApproxTotDelta
		);
		cellMsgDialogProgressBarSetMsg(CELL_MSGDIALOG_PROGRESSBAR_INDEX_SINGLE, msg);

		if(filer) fclose(filer);
		if(filew) fclose(filew);
		
		if(bCopyError)
		{
			cellFsUnlink(szFileOut); // delete file

			gamePKG->nStatus = STATUS_COPY_ERROR;
			sys_ppu_thread_exit(0);
			return;
		}

	} else {

		if(buffer) free(buffer);
		buffer = NULL;

		if(filer) fclose(filer);
		if(filew) 
		{
			fclose(filew);		
			cellFsUnlink(szFileOut); // delete file
		}

		gamePKG->nStatus = STATUS_COPY_ERROR;
		sys_ppu_thread_exit(0);
		return;
	}
	
	if(buffer) 
	{
		free(buffer);
		buffer = NULL;
	}

	sys_timer_usleep(1000000); // wait 1 second

	gamePKG->nStatus = STATUS_COPY_OK;
	sys_ppu_thread_exit(0);
}
Beispiel #11
0
// (re-wrote) this function will just look for specific ROMs on specific locations,
// that means it will NOT process unnecesary files, ex. there could be 40,000 ZIP
// files, but I'm just checking 5,000, not comparing each of the 40,000.
void _ScanROMs(uint64_t /*arg*/)
{
	uint32_t nTotalBurnDrivers = sizeof(fba_drv) / sizeof(FBA_DRV);
	uint32_t nPaths = sizeof(g_opt_szROMPaths) / 2048;
	
	char* pszFilePath = NULL;
	pszFilePath = (char*)malloc(2048);
	memset(pszFilePath, 0, 2048);

	double fDelta = 0.0f;
	double fDeltaCnt = 0.0f;

	// go through all drivers...
	for(uint32_t nDrv = 0; nDrv < nTotalBurnDrivers; nDrv++)
	{
		fbaRL->games[fbaRL->nTotalGames] = new c_game(fbaRL->nTotalGames);	

		// try every path possible...
		for(uint32_t x = 0; x < nPaths; x++)
		{
			if(fbaRL->DirExist(g_opt_szROMPaths[x]))
			{							
				sprintf(pszFilePath, "%s/%s.zip", g_opt_szROMPaths[x], fba_drv[nDrv].szName);
				
				// Available...
				if(fbaRL->FileExist(pszFilePath)) 
				{	
					// TODO: check if zip has all files			
					// Add found game info...									
					sprintf(fbaRL->games[fbaRL->nTotalGames]->title, "%s", fba_drv[nDrv].szTitle);			// title					
					sprintf(fbaRL->games[fbaRL->nTotalGames]->sysmask, "%s", fba_drv[nDrv].szSystemFilter);	// sys filter					
					strcpy(fbaRL->games[fbaRL->nTotalGames]->path, pszFilePath);							// path					
					sprintf(fbaRL->games[fbaRL->nTotalGames]->zipname, "%s.zip", fba_drv[nDrv].szName);		// zip title					
					fbaRL->games[fbaRL->nTotalGames]->nSize = 0/*fbaRL->GetFileSize(pszFilePath)*/;				// Size in bytes					
					fbaRL->games[fbaRL->nTotalGames]->bAvailable = true;
					break;
				}
			}
		}

		// Missing...
		if(!fbaRL->games[fbaRL->nTotalGames]->bAvailable) 
		{
			sprintf(fbaRL->games[fbaRL->nTotalGames]->title		, "%s"		, fba_drv[nDrv].szTitle);			// title
			sprintf(fbaRL->games[fbaRL->nTotalGames]->sysmask	, "%s"		, fba_drv[nDrv].szSystemFilter);	// sys filter
			sprintf(fbaRL->games[fbaRL->nTotalGames]->zipname	, "%s.zip"	, fba_drv[nDrv].szName);		// zip title				
			fbaRL->games[fbaRL->nTotalGames]->nSize = 0;				// Size in bytes
			fbaRL->games[fbaRL->nTotalGames]->bAvailable = false;

			fbaRL->nMissingGames++;			
		}

		fbaRL->nTotalGames++;

		// Progress bar...
		double fTotalPct = ((double)nDrv / (double)nTotalBurnDrivers) * 100.0f;

		fDeltaCnt += (fTotalPct - fDelta);

		char msg[256] = "";
		sprintf(msg,
			"%d / %d (%.1f %%)",
			nDrv, 
			nTotalBurnDrivers, 
			fTotalPct
		);
		cellMsgDialogProgressBarSetMsg(CELL_MSGDIALOG_PROGRESSBAR_INDEX_SINGLE, msg);
					
		if(fDeltaCnt >= 1.0f)
		{
			fDeltaCnt -= 1.0f;
			cellMsgDialogProgressBarInc(CELL_MSGDIALOG_PROGRESSBAR_INDEX_SINGLE, 1);
		}					
					
		fDelta = fTotalPct;
	}
	fbaRL->bProcessingGames = false;
	fbaRL->nStatus = STATUS_ROMSCAN_END;
	sys_ppu_thread_exit(0);
}
Beispiel #12
0
/***********************************************************************
* plugin main ppu thread
***********************************************************************/
static void vsh_menu_thread(uint64_t arg)
{
    #ifdef DEBUG
    dbg_init();
    dbg_printf("programstart:\n");
    #endif

    uint16_t oldpad = 0, curpad = 0;
    CellPadData pdata;

    // wait for XMB, feedback
    sys_timer_sleep(13);

    //vshtask_notify("sprx running...");

    play_rco_sound("system_plugin", "snd_trophy");

    #ifdef HAVE_STARFIELD
    init_once(/* stars */);
    #endif

    // custom bg_color init
    a = GET_A(bg_color_menu[1]);
    r = GET_R(bg_color_menu[1]);
    g = GET_G(bg_color_menu[1]);
    b = GET_B(bg_color_menu[1]);

    while(1)
    {
        // if VSH Menu is running, we get pad data over our MyPadGetData()
        // else, we use the vsh pad_data struct
        if(menu_running)
            MyPadGetData(0, &pdata);
        else
            VSHPadGetData(&pdata);

        // if pad_data and we are in XMB(vshmain_EB757101() == 0)
        if((pdata.len > 0)
        && (vshmain_EB757101() == 0)
        )
        {
            curpad = (pdata.button[2] | (pdata.button[3] << 8));

            if((curpad & PAD_SELECT) && (curpad != oldpad))
            {
                switch(menu_running)
                {
                    // VSH Menu not running, start VSH Menu
                    case 0:
                      // main view and start on first entry 
                      view = line = 0;

                      //
                      pause_RSX_rendering();

                      // create VSH Menu heap memory from memory container 1("app")
                      create_heap(64);       // 64 MB

                      // initialize VSH Menu graphic (init drawing context, alloc buffers, blah, blah, blah...)
                      init_graphic();

                      // stop vsh pad
                      start_stop_vsh_pad(0);

                      // set menu_running
                      menu_running = 1;

                      break;

                    // VSH Menu is running, stop VSH Menu
                    case 1:
                      stop_VSH_Menu();

                      // restart vsh pad
                      start_stop_vsh_pad(1);

                      break;
                }

                oldpad = 0;
                sys_timer_usleep(300000);
            }


          // VSH Menu is running, draw menu / check pad
          if(menu_running)
          {
                #ifdef DEBUG
                dbg_printf("%p\n", pdata);
                #endif

                draw_frame(&pdata);

                flip_frame();

                if(curpad != oldpad)
                {

                    if(curpad & PAD_UP)
                    {
                        if(line <= 0){
                            line = 0;
                        }else{
                            line--;
                            play_rco_sound("system_plugin", "snd_cursor");
                        }
                    }

                    if(curpad & PAD_DOWN)
                    {
                        if(line >= max_menu[view]-1){
                            line = max_menu[view]-1;
                        }else{
                            line++;
                            play_rco_sound("system_plugin", "snd_cursor");
                        }
                    }

                    if(curpad & PAD_LEFT
                    || curpad & PAD_RIGHT) do_leftright_action(curpad);

                    if(curpad & PAD_CROSS) do_menu_action();

                }

                // ...

                sys_timer_usleep(30);

            } // end VSH Menu is running

            oldpad = curpad;
        }else{
            oldpad = 0;
        }
    }

    #ifdef DEBUG
    dbg_fini();
    #endif
    sys_ppu_thread_exit(0);
}
Beispiel #13
0
void					CellThread::ThreadWrapper		(uint64_t aUserData)
{
	CellThread* thread = (CellThread*)aUserData;
	int32_t result = thread->Function(thread->UserData);
	sys_ppu_thread_exit(result);
}
Beispiel #14
0
/*
 * Function:		art_thread()
 * File:			main.c
 * Project:			ArtemisPS3-PRX
 * Description:		Artemis PRX Thread start
 *					Interprets user input and calls art_process()
 * Arguments:		
 *	arg:			
 * Return:			void
 */
static void art_thread(uint64_t arg)
{
	int GameProcessID = 0, lastGameProcessID = 0;

	printf("Artemis PS3 :::: Thread Started!\n");
	
	sys_timer_sleep(10);
	sys_ppu_thread_yield();
	
	CellPadData data;
	CellPadInfo2 info;
	int delay = 0, delay2 = 0, hasDisplayed = 0, fd = 0;

	while (1)
	{
		if (exitThread)
		{
			destroy_heap();
			exitThread = 0;
			{ sys_ppu_thread_exit(0); }
			{ return; }
		}

		GameProcessID = GetGameProcessID();
		if (GameProcessID != 0)
		{
			if (!check_turnoff()) //exit
			{
				printf("Artemis PS3 :::: Process Exited\n");
				destroy_heap();
				attachedPID = 0;
			}
			else
			{
				if (GameProcessID != lastGameProcessID)
				{
					for (int x = 0; x < (10 * 100); x++) //10 second delay
					{
						sys_timer_usleep(10000);
						sys_ppu_thread_yield();
					}


					show_msg((char *)"Artemis PS3\nStart To Attach");
				}

				cellPadGetInfo2(&info);
				if (info.port_status[0] && (cellPadGetData(0, &data) | 1) && data.len > 0)
				{
					uint32_t pad = data.button[2] | (data.button[3] << 8);
					if (attachedPID) // Run codes
					{
						art_process(0);
					}

					if (pad & PAD_START)
					{
						attachedPID = GameProcessID;
						if (attachedPID)
						{
							show_msg((char *)"Artemis PS3\nAttached and Wrote");
							printf("Artemis PS3 :::: Attached to 0x%08X\n", attachedPID);

							if (get_heap() == 0)
								create_heap(1);
							check_syscall_api();
							art_process(1);

							while ((cellPadGetData(0, &data) | 1) && data.len > 0)
							{
								if (!((data.button[2] | (data.button[3] << 8)) & PAD_START))
									break;

								sys_timer_usleep(1000000);
								sys_ppu_thread_yield();
							}
						}
						else
						{
							show_msg((char *)"Artemis PS3\nFailed to Attach");
						}
					}
					else if (pad & PAD_SELECT && attachedPID)
					{
						show_msg((char *)"Artemis PS3\nDetached");
						reset_heap();
						attachedPID = 0;
					}

				}

				sys_timer_usleep(100 * 1000); //0.1 second delay
			}
		}
		else
		{
			if (attachedPID) // Disconnect
			{
				printf("Artemis PS3 :::: Process Exited\n");
				destroy_heap();
				attachedPID = 0;
			}
			else
				sys_timer_usleep(3 * 1000 * 1000); //3 second delay
		}

		lastGameProcessID = GameProcessID;
		sys_timer_usleep(1668);
		sys_ppu_thread_yield();
	}

	destroy_heap();
	sys_ppu_thread_exit(0);

}