25 static void *poweroff_data = NULL;
32 static int powerOffThreadId = -1;
34 static void *PowerOff_ee_rpc_handler(
int fnum,
void *buffer,
int len)
41 printf(
"EE: power button pressed\n");
45 poweroff_cb(poweroff_data);
53 static void PowerOffThread(
void *dat)
55 static unsigned char cb_rpc_buffer[64]
__attribute__((__aligned__(64)));
59 sceSifSetRpcQueue(&cb_queue, powerOffThreadId);
60 sceSifRegisterRpc(&cb_srv, PWROFF_IRX, &PowerOff_ee_rpc_handler, cb_rpc_buffer, NULL, NULL, &cb_queue);
61 sceSifRpcLoop(&cb_queue);
70 memset(&cd0, 0,
sizeof(cd0));
75 while (((res = sceSifBindRpc(&cd0, PWROFF_IRX, 0)) < 0) || (cd0.server == NULL))
79 if (powerOffThreadId >= 0)
81 TerminateThread(powerOffThreadId);
82 DeleteThread(powerOffThreadId);
83 sceSifRemoveRpc(&cb_srv, &cb_queue);
84 sceSifRemoveRpcQueue(&cb_queue);
85 powerOffThreadId = -1;
88 thread.initial_priority = POWEROFF_THREAD_PRIORITY;
89 thread.stack_size =
sizeof(poffThreadStack);
91 thread.func = PowerOffThread;
92 thread.stack = (
void *)poffThreadStack;
95 powerOffThreadId = CreateThread(&
thread);
96 StartThread(powerOffThreadId, NULL);
98 int autoShutdown[4] = {0};
99 sceSifCallRpc(&cd0, PWROFF_ENABLE_AUTO_SHUTOFF, 0, NULL, 0, autoShutdown,
sizeof(autoShutdown), NULL, NULL);
116 sceSifCallRpc(&cd0, PWROFF_SHUTDOWN, 0, NULL, 0, NULL, 0, NULL, NULL);
121 ChangeThreadPriority(powerOffThreadId, priority);