PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
EE LOADFILE: ELF and IRX loader client library.

Functions

int SifLoadFileInit (void)
 
void SifLoadFileExit (void)
 
int SifLoadModule (const char *path, int arg_len, const char *args)
 
int SifLoadStartModule (const char *path, int arg_len, const char *args, int *mod_res)
 
int SifLoadModuleEncrypted (const char *path, int arg_len, const char *args)
 
int SifLoadModuleBuffer (void *ptr, int arg_len, const char *args)
 
int SifLoadStartModuleBuffer (void *ptr, int arg_len, const char *args, int *mod_res)
 
int SifLoadElfPart (const char *path, const char *secname, t_ExecData *data)
 
int SifLoadElf (const char *path, t_ExecData *data)
 
int SifLoadElfEncrypted (const char *path, t_ExecData *data)
 
int SifIopSetVal (u32 iop_addr, int val, int type)
 
int SifIopGetVal (u32 iop_addr, void *val, int type)
 
int SifExecModuleBuffer (void *ptr, u32 size, u32 arg_len, const char *args, int *mod_res)
 
int SifExecModuleFile (const char *path, u32 arg_len, const char *args, int *mod_res)
 
int _SifLoadModule (const char *path, int arg_len, const char *args, int *modres, int fno, int dontwait)
 

Detailed Description

Function Documentation

◆ SifLoadFileInit()

int SifLoadFileInit ( void  )

#include <ee/kernel/include/loadfile.h>

Initialize the LOADFILE library.

Returns
0 on success, E_SIF_RPC_BIND if unable to connect to the server.

Initializes the LOADFILE API and binds to the remote LOADFILE RPC server.

◆ SifLoadFileExit()

void SifLoadFileExit ( void  )

#include <ee/kernel/include/loadfile.h>

Reset the LOADFILE library.

Deinitializes the LOADFILE library in preparation of an IOP reset.

◆ SifLoadModule()

int SifLoadModule ( const char *  path,
int  arg_len,
const char *  args 
)

#include <ee/kernel/include/loadfile.h>

Load and execute an IRX module.

Parameters
pathPath to an IRX module
arg_lenLength, in bytes, of the argument list
argsList of arguments to pass to the IRX on startup
Returns
The ID of the loaded module on success, or an error if the module couldn't be loaded.

Loads an IRX module from the specified path, and executes it. The args parameter specifies a list of arguments that are passed to the loaded module as the argv[] array. Each argument string in args must be seperated by NUL ('\0'). Pass the length of the entire args list, including the NUL seperators in the args_len parameter.

Note
By default, modules cannot be loaded directly from the memory card. If you need to load modules from the memory card, you should use SifExecModuleFile or link with the sbv-lite library (http://www.0xd6.org).
See also
SifExecModuleFile

◆ SifLoadStartModule()

int SifLoadStartModule ( const char *  path,
int  arg_len,
const char *  args,
int *  mod_res 
)

#include <ee/kernel/include/loadfile.h>

Load and execute and IRX module, and retrieve the module's load status.

Parameters
pathPath to an IRX module
arg_lenLength, in bytes, of the argument list
argsList of arguments to pass to the IRX on startup
mod_resPointer to a variable that will store the return value from the IRX's _start() function
Returns
The ID of the loaded module on success, or an error if the module couldn't be loaded.

Loads an IRX module from the specified path, and executes it. See SifLoadModule for details on the arg_len and args parameters. If mod_res is non-NULL, the result code from the module's _start() function is stored here.

See also
SifLoadModule

◆ SifLoadModuleEncrypted()

int SifLoadModuleEncrypted ( const char *  path,
int  arg_len,
const char *  args 
)

#include <ee/kernel/include/loadfile.h>

Load and execute an IRX module encrypted with MagicGate.

Parameters
pathPath to an IRX module
arg_lenLength, in bytes, of the argument list
argsList of arguments to pass to the IRX on startup
Returns
The ID of the loaded module on success, or an error if the module couldn't be loaded.

There is no real use for this function; it is only included in ps2lib for completeness.

See also
SifLoadModule

◆ SifLoadModuleBuffer()

int SifLoadModuleBuffer ( void *  ptr,
int  arg_len,
const char *  args 
)

#include <ee/kernel/include/loadfile.h>

Load and execute an IRX module from a buffer in IOP RAM.

Parameters
ptrPointer to a buffer in IOP RAM where the IRX module will be loaded from
arg_lenLength, in bytes, of the argument list
argsList of arguments to pass to the IRX on startup
Returns
The ID of the loaded module on success, or an error if the module couldn't be loaded.

Loads an IRX module from a buffer located in IOP RAM. See SifLoadModule for details on the arg_len and args parameters.

Note
If you need to load an IRX module onto the IOP directly from a buffer in EE RAM, then use SifExecModuleBuffer.
See also
SifLoadModule, SifExecModuleBuffer

◆ SifLoadStartModuleBuffer()

int SifLoadStartModuleBuffer ( void *  ptr,
int  arg_len,
const char *  args,
int *  mod_res 
)

#include <ee/kernel/include/loadfile.h>

Load and execute an IRX module from a buffer in IOP RAM, and retrieve the module's load status.

Parameters
ptrPointer to a buffer in IOP RAM where the IRX module will be loaded from
arg_lenLength, in bytes, of the argument list
argsList of arguments to pass to the IRX on startup
mod_resPointer to a variable that will store the return value from the IRX's _start() function
Returns
The ID of the loaded module on success, or an error if the module couldn't be loaded.

Loads an IRX module from a buffer located in IOP RAM. See SifLoadModule for details on the arg_len and args parameters. If mod_res is non-NULL, the result code from the module's _start() function is stored here.

Note
If you need to load an IRX module onto the IOP directly from a buffer in EE RAM, then use SifExecModuleBuffer.
See also
SifLoadModule, SifExecModuleBuffer

◆ SifLoadElfPart()

int SifLoadElfPart ( const char *  path,
const char *  secname,
t_ExecData data 
)

#include <ee/kernel/include/loadfile.h>

Load the specified section of an ELF executable into EE RAM.

Parameters
pathPath to an ELF executable
secnameThe name of a single section to load from the ELF, or "all" to load all sections
dataPointer to a variable that will store information about the loaded executable
Returns
0 on success, or an error code if an error occurred.

Loads the section secname from the ELF file specified by path into EE RAM.

data points to a t_ExecData structure where information about the loaded section will be returned.

Warning
Don't ever use this function, it does not work as intended.

◆ SifLoadElf()

int SifLoadElf ( const char *  path,
t_ExecData data 
)

#include <ee/kernel/include/loadfile.h>

Load an ELF executable into EE RAM.

Parameters
pathPath to an ELF executable
dataPointer to a variable that will store information about the loaded executable
Returns
0 on success, or an error code if an error occurred.

Loads the ELF executable specified by path into EE RAM. data points to a t_ExecData structure where information about the loaded executable will be returned.

Warning
It's possible to overwrite your program if the ELF that you're trying to load overlaps your program's memory space. Always ensure that the target ELF will load before or after your program's code and data addresses.

◆ SifLoadElfEncrypted()

int SifLoadElfEncrypted ( const char *  path,
t_ExecData data 
)

#include <ee/kernel/include/loadfile.h>

Load a MagicGate-encrypted ELF executable into EE RAM.

Parameters
pathPath to an ELF executable
dataPointer to a variable that will store information about the loaded executable
Returns
0 on success, or an error code if an error occurred.

There is no real use for this function; it is only included in ps2lib for completeness.

See also
SifLoadElf

◆ SifIopSetVal()

int SifIopSetVal ( u32  iop_addr,
int  val,
int  type 
)

#include <ee/kernel/include/loadfile.h>

Write a value to an address within the IOP's memory space.

Parameters
iop_addrAddress to modify in the IOP's address space
valData to write at iop_addr
typeA type describing the size of the val argument
Returns
Previous value at iop_addr on success (?), or an error code if an error occurred.

Writes the data passed in val to the IOP address specified by iop_addr. Use the following types specify the size of data write:

  • LF_VAL_BYTE to write an 8-bit value
  • LF_VAL_SHORT to write a 16-bit value
  • LF_VAL_LONG to write a 32-bit value
Note
Because iop_addr can be any address within the IOP's address space, it's possible to modify IOP hardware registers. However, in most cases the EE can modify the IOP's hardware registers directly so there is little use for this function.
See also
SifIopGetVal

◆ SifIopGetVal()

int SifIopGetVal ( u32  iop_addr,
void *  val,
int  type 
)

#include <ee/kernel/include/loadfile.h>

Read a value from an address within the IOP's memory space.

Parameters
iop_addrAddress within the IOP's address space to read from
valPointer to a variable that stores the value read
typeA type describing the size of the data to read
Returns
0 on success, or an error code if an error occurred.

Reads data of the size specified by type from the IOP address specified by iop_addr. Use the following types to specify the size of the data to read:

  • LF_VAL_BYTE to write an 8-bit value
  • LF_VAL_SHORT to write a 16-bit value
  • LF_VAL_LONG to write a 32-bit value
Note
Because iop_addr can be any address within the IOP's address space, it's possible to read from IOP hardware registers. However, in most cases the EE can read the IOP's hardware registers directly so there is little use for this function.
See also
SifIopSetVal

◆ SifExecModuleBuffer()

int SifExecModuleBuffer ( void *  ptr,
u32  size,
u32  arg_len,
const char *  args,
int *  mod_res 
)

#include <ee/kernel/include/loadfile.h>

Transfer an IRX module from EE RAM to IOP RAM and execute it.

Parameters
ptrPointer to a buffer in EE RAM where the IRX module will be loaded from
sizeSize of the buffer in EE RAM that contains the IRX module
arg_lenLength, in bytes, of the argument list
argsList of arguments to pass to the IRX on startup
mod_resPointer to a variable that will store the return value from the IRX's _start() function
Returns
The ID of the loaded module on success, or an error if the module couldn't be loaded.

Transfers an IRX module stored in a buffer in EE RAM to the IOP, and calls SifLoadModuleBuffer to load and execute the module. See SifLoadModule for details on the arg_len and args parameters. If mod_res is non-NULL, the result code from the module's _start() function is stored here.

See also
SifLoadModule, SifLoadModuleBuffer

◆ SifExecModuleFile()

int SifExecModuleFile ( const char *  path,
u32  arg_len,
const char *  args,
int *  mod_res 
)

#include <ee/kernel/include/loadfile.h>

Read an IRX module from a file into IOP RAM and execute it.

Parameters
pathPath to an IRX module
arg_lenLength, in bytes, of the argument list
argsList of arguments to pass to the IRX on startup
mod_resPointer to a variable that will store the return value from the IRX's _start() function
Returns
The ID of the loaded module on success, or an error if the module couldn't be loaded.

Loads an IRX module from the specified path into a buffer on the IOP, then calls SifLoadModuleBuffer to load and execute the module. See SifLoadModule for details on the arg_len and args parameters. This function is useful if you need to load an IRX module from a prohibited device, such as the memory card.

See also
SifLoadModule, SifLoadModuleBuffer

◆ _SifLoadModule()

int _SifLoadModule ( const char *  path,
int  arg_len,
const char *  args,
int *  modres,
int  fno,
int  dontwait 
)

#include <ee/kernel/include/loadfile.h>

Low-level function for loading and executing an IRX module.

Parameters
pathPath to an IRX module
arg_lenLength, in bytes, of the argument list
argsList of arguments to pass to the IRX on startup
*modresPointer to a variable that will store the return value from the IRX's _start() function
fnoFunction number of function to execute.
dontwaitWhether to wait for the module's _start function to finish executing.
Returns
The ID of the loaded module on success, or an error if the module couldn't be loaded.

Unless required, use the higher-level functions instead.

See also
SifLoadModule, SifLoadModuleBuffer, SifLoadModuleEncrypted