PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
libpwroff.h File Reference

Power-off library. More...

+ 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)
 User defined function for use in poweroffSetCallback()
 

Functions

int poweroffInit (void)
 Initializes the poweroff library.
 
void poweroffSetCallback (poweroff_callback cb, void *arg)
 Set callback function.
 
void poweroffShutdown (void)
 Immidiate console shutdown. Do not call it without closing all stuff.
 
void poweroffChangeThreadPriority (int priority)
 Change thread priority.
 

Detailed Description

Power-off library.

Poweroff is a library that substitutes for the missing poweroff functionality in rom0:CDVDMAN, which is offered by newer CDVDMAN modules (i.e. sceCdPoweroff). Other than allowing the PlayStation 2 to be switched off via software means, this is used to safeguard against the user switching off/resetting the console before data can be completely written to disk.

Definition in file libpwroff.h.

Macro Definition Documentation

◆ POWEROFF_THREAD_PRIORITY

#define POWEROFF_THREAD_PRIORITY   0x70

Definition at line 25 of file libpwroff.h.

Typedef Documentation

◆ poweroff_callback

typedef void(* poweroff_callback) (void *arg)

User defined function for use in poweroffSetCallback()

In fact there can be anything. This function will be called when power button is pressed. In common cases it should end everything and poweroff console. You should close all files (close(fd)) and unmount all partitions. If you use PFS, close all files and unmount all partitions.

fileXioDevctl("pfs:", PDIOC_CLOSEALL, NULL, 0, NULL, 0)

Shut down DEV9 (Network module), if you used it:

while(fileXioDevctl("dev9x:", DDIOC_OFF, NULL, 0, NULL, 0) < 0){};

Last function inside callback should be poweroffShutdown().

Definition at line 49 of file libpwroff.h.

Function Documentation

◆ poweroffInit()

int poweroffInit ( void )
extern

Initializes the poweroff library.

A service thread with a default priority of POWEROFF_THREAD_PRIORITY will be created.

Definition at line 64 of file poweroff.c.

Referenced by poweroffSetCallback(), and poweroffShutdown().

◆ poweroffSetCallback()

void poweroffSetCallback ( poweroff_callback cb,
void * arg )
extern

Set callback function.

Parameters
[in]cbFunction that will be called when power button is pressed.
[in]argArguments that are sent to cb function (can be NULL)

Callback function should be user-defined elsewhere. There are some standart specifications.

Definition at line 103 of file poweroff.c.

References poweroffInit().

◆ poweroffShutdown()

void poweroffShutdown ( void )
extern

Immidiate console shutdown. Do not call it without closing all stuff.

Definition at line 111 of file poweroff.c.

References poweroffInit().

◆ poweroffChangeThreadPriority()

void poweroffChangeThreadPriority ( int priority)
extern

Change thread priority.

The callback thread runs at priority POWEROFF_THREAD_PRIORITY by default. You can change the priority by calling this function after poweroffSetCallback(). You can call this function before poweroffSetCallback() as well (but after poweroffInit() ). In that case poweroffSetCallback() will be registered with the provided priority.

Definition at line 118 of file poweroff.c.