24 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);
68 static int _init_count = -1;
74 while (((res = sceSifBindRpc(&cd0, PWROFF_IRX, 0)) < 0) || (cd0.server == NULL))
78 if (powerOffThreadId >= 0)
80 TerminateThread(powerOffThreadId);
81 DeleteThread(powerOffThreadId);
82 sceSifRemoveRpc(&cb_srv, &cb_queue);
83 sceSifRemoveRpcQueue(&cb_queue);
84 powerOffThreadId = -1;
87 thread.initial_priority = POWEROFF_THREAD_PRIORITY;
88 thread.stack_size =
sizeof(poffThreadStack);
90 thread.func = PowerOffThread;
91 thread.stack = (
void *)poffThreadStack;
94 powerOffThreadId = CreateThread(&
thread);
95 StartThread(powerOffThreadId, NULL);
97 int autoShutdown[4] = {0};
98 sceSifCallRpc(&cd0, PWROFF_ENABLE_AUTO_SHUTOFF, 0, NULL, 0, autoShutdown,
sizeof(autoShutdown), NULL, NULL);
115 sceSifCallRpc(&cd0, PWROFF_SHUTDOWN, 0, NULL, 0, NULL, 0, NULL, NULL);
120 ChangeThreadPriority(powerOffThreadId, priority);