ps2sdk  1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
libpwroff.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define POWEROFF_THREAD_PRIORITY   0x70
 

Typedefs

typedef void(* poweroff_callback) (void *arg)
 

Functions

int poweroffInit (void)
 
void poweroffSetCallback (poweroff_callback cb, void *arg)
 
void poweroffShutdown (void)
 
void poweroffChangeThreadPriority (int priority)
 

Detailed Description

Power-off library.

Definition in file libpwroff.h.

Macro Definition Documentation

◆ POWEROFF_THREAD_PRIORITY

#define POWEROFF_THREAD_PRIORITY   0x70

Definition at line 19 of file libpwroff.h.

Typedef Documentation

◆ poweroff_callback

typedef void(* poweroff_callback) (void *arg)

Definition at line 25 of file libpwroff.h.

Function Documentation

◆ poweroffChangeThreadPriority()

void poweroffChangeThreadPriority ( int  priority)

Definition at line 110 of file poweroff.c.

111 {
113 }
s32 ChangeThreadPriority(s32 thread_id, s32 priority)
static int powerOffThreadId
Definition: poweroff.c:32

References ChangeThreadPriority(), and powerOffThreadId.

◆ poweroffInit()

int poweroffInit ( void  )

Initializes the poweroff library. A service thread with a default priority of 0x70 will be created.

Definition at line 57 of file poweroff.c.

58 {
59  ee_thread_t thread;
60  int res;
61  static int _init_count = -1;
62 
63  if(_init_count == _iop_reboot_count)
64  return 0;
65  _init_count = _iop_reboot_count;
66 
67  while(((res = SifBindRpc(&cd0, PWROFF_IRX, 0)) < 0) || (cd0.server == NULL))
68  nopdelay();
69 
70  // Terminate and delete any previously created threads
71  if (powerOffThreadId >= 0) {
76  powerOffThreadId = -1;
77  }
78 
80  thread.stack_size = sizeof(poffThreadStack);
81  thread.gp_reg = &_gp;
82  thread.func = PowerOffThread;
83  thread.stack = (void *)poffThreadStack;
84  thread.option = 0;
85  thread.attr = 0;
86  powerOffThreadId = CreateThread(&thread);
88 
89  int autoShutdown[4] = {0};
90  SifCallRpc(&cd0, PWROFF_ENABLE_AUTO_SHUTOFF, 0, NULL, 0, autoShutdown, sizeof(autoShutdown), NULL, NULL);
91 
92  return res;
93 }
static void nopdelay(void)
Definition: kernel.h:141
s32 CreateThread(ee_thread_t *thread)
s32 StartThread(s32 thread_id, void *args)
s32 TerminateThread(s32 thread_id)
s32 DeleteThread(s32 thread_id)
#define POWEROFF_THREAD_PRIORITY
Definition: libpwroff.h:19
#define PWROFF_IRX
Definition: pwroff_rpc.h:19
#define PWROFF_ENABLE_AUTO_SHUTOFF
Definition: pwroff_rpc.h:21
SifRpcServerData_t * SifRemoveRpc(SifRpcServerData_t *sd, SifRpcDataQueue_t *queue)
SifRpcDataQueue_t * SifRemoveRpcQueue(SifRpcDataQueue_t *qd)
int SifBindRpc(SifRpcClientData_t *client, int rpc_number, int mode)
int SifCallRpc(SifRpcClientData_t *client, int rpc_number, int mode, void *send, int ssize, void *receive, int rsize, SifRpcEndFunc_t end_function, void *end_param)
static SifRpcClientData_t cd0
Definition: poweroff.c:29
int _iop_reboot_count
static u8 poffThreadStack[512 *16]
Definition: poweroff.c:26
static struct t_SifRpcServerData cb_srv
Definition: poweroff.c:31
void * _gp
static struct t_SifRpcDataQueue cb_queue
Definition: poweroff.c:30
static void PowerOffThread(void *dat)
Definition: poweroff.c:48
struct t_SifRpcServerData * server
Definition: sifrpc.h:142
void * gp_reg
Definition: kernel.h:230
u32 option
Definition: kernel.h:234
int stack_size
Definition: kernel.h:229
void * func
Definition: kernel.h:227
void * stack
Definition: kernel.h:228
u32 attr
Definition: kernel.h:233
int initial_priority
Definition: kernel.h:231
#define NULL
Definition: tamtypes.h:91

References _gp, _iop_reboot_count, ee_thread_t::attr, cb_queue, cb_srv, cd0, CreateThread(), DeleteThread(), ee_thread_t::func, ee_thread_t::gp_reg, ee_thread_t::initial_priority, nopdelay(), NULL, ee_thread_t::option, poffThreadStack, POWEROFF_THREAD_PRIORITY, PowerOffThread(), powerOffThreadId, PWROFF_ENABLE_AUTO_SHUTOFF, PWROFF_IRX, SifRpcClientData_t::server, SifBindRpc(), SifCallRpc(), SifRemoveRpc(), SifRemoveRpcQueue(), ee_thread_t::stack, ee_thread_t::stack_size, StartThread(), and TerminateThread().

Referenced by main(), poweroffSetCallback(), and poweroffShutdown().

◆ poweroffSetCallback()

void poweroffSetCallback ( poweroff_callback  cb,
void *  arg 
)

Definition at line 95 of file poweroff.c.

96 {
97  poweroffInit();
98 
99  poweroff_cb = cb;
100  poweroff_data = arg;
101 }
static poweroff_callback poweroff_cb
Definition: poweroff.c:23
int poweroffInit(void)
Definition: poweroff.c:57
static void * poweroff_data
Definition: poweroff.c:24

References poweroff_cb, poweroff_data, and poweroffInit().

Referenced by main().

◆ poweroffShutdown()

void poweroffShutdown ( void  )

Definition at line 103 of file poweroff.c.

104 {
105  poweroffInit();
106 
107  SifCallRpc(&cd0, PWROFF_SHUTDOWN, 0, NULL, 0, NULL, 0, NULL, NULL);
108 }
#define PWROFF_SHUTDOWN
Definition: pwroff_rpc.h:20

References cd0, NULL, poweroffInit(), PWROFF_SHUTDOWN, and SifCallRpc().

Referenced by poweroffCallback().