### Custom gprof Profiling Interval Source: https://github.com/ps2dev/ps2sdk/blob/master/ee/libprofglue/samples/custom/README.md This example shows how to profile a specific section of code by manually starting and stopping gprof. It discards initial profiling data and saves custom output. ```c gprof_stop(NULL, false); gprof_start(); // Your code to profile here gprof_stop("gmon_custom.out", true); ``` -------------------------------- ### Build PS2SDK from Source Source: https://github.com/ps2dev/ps2sdk/wiki/Home Steps to clone, build, and install the PS2SDK from its source repository. Ensure you have necessary privileges for 'make install'. ```bash git clone https://github.com/ps2dev/ps2sdk cd ps2sdk export PS2SDKSRC=$PWD make clean make make install ``` -------------------------------- ### IOPBTCONF File Syntax Source: https://github.com/ps2dev/ps2sdk/blob/master/iop/system/udnl/README.txt Defines module loading configurations for UDNL. Lines starting with '@', '!', or '#' are directives or comments. Other lines are treated as module filenames. ```plaintext @
!include !addr
# ``` -------------------------------- ### IOPBTCONF Module Filename Source: https://github.com/ps2dev/ps2sdk/blob/master/iop/system/udnl/README.txt Lines not starting with special characters are interpreted as filenames of modules to be loaded. ```plaintext ``` -------------------------------- ### Upgrade PS2SDK from Source Source: https://github.com/ps2dev/ps2sdk/wiki/Home Instructions for updating an existing PS2SDK installation. This involves pulling the latest changes, cleaning, rebuilding, and reinstalling. ```bash cd ps2sdk git pull export PS2SDKSRC=$PWD make clean make make install ``` -------------------------------- ### IOPBTCONF File Syntax Source: https://github.com/ps2dev/ps2sdk/blob/master/iop/system/udnl-t300/README.txt Defines the syntax for IOPBTCONF files, which specify module loading order and addresses. Lines starting with '#' are comments. '@' specifies load address, '!include' includes another file, and '!addr' includes a module at a specific address. ```plaintext @
- The address at which to start loading modules from. !include - Includes the specified file. !addr
- Includes a module that exists at the specified memory address. # - The '#' symbol marks the whole line as a comment. ``` -------------------------------- ### Programmable IR Remote Lirc Format Example Source: https://github.com/ps2dev/ps2sdk/blob/master/ee/rpc/remote/remote.md Provides an example of converting a PS2 IR code into Lirc format, which involves reversing the bit order and translating to hexadecimal. This is useful for custom remote configurations. ```text 11011010110101011111 in reverse 11111010101101011011 in hex 0x00000000000FAB5B ``` -------------------------------- ### IOPBTCONF Comment Line Source: https://github.com/ps2dev/ps2sdk/blob/master/iop/system/udnl/README.txt Lines starting with '#' are treated as comments within an IOPBTCONF file. ```plaintext # ``` -------------------------------- ### SCMD Command 0x1E Example Source: https://github.com/ps2dev/ps2sdk/blob/master/ee/rpc/remote/remote.md Demonstrates the output format for SCMD command 0x1E (ReadSIRc), which returns the pressed button code and status. This is useful for debugging IR input. ```text 0014 DAD1 6000 ``` -------------------------------- ### PS2 IR Code Conversion Example Source: https://github.com/ps2dev/ps2sdk/blob/master/ee/rpc/remote/remote.md Shows how a 20-bit IR code is converted by the PS2, including adding trailing zeros and changing endianness. This conversion is crucial for understanding how button presses are registered. ```text DAD5F -> DAD5F000 -> 00 F0 D5 DA ``` -------------------------------- ### PS2 Remote IR Signal Example Source: https://github.com/ps2dev/ps2sdk/blob/master/ee/rpc/remote/remote.md Illustrates the 20-bit IR signal format for PS2 remotes, broken down into device-specific and button-specific blocks. This format is used for communication with the PS2. ```text 11011010-11010-1011111 ``` -------------------------------- ### Add Device Initialization Failure Handling Source: https://github.com/ps2dev/ps2sdk/blob/master/iop/iLink/IEEE1394_disk/doc/Changelog.txt Ensures device initialization fails if ConfigureSBP2Device() returns an error. ```c Added code to fail device initialization if ConfigureSBP2Device() fails. ``` -------------------------------- ### Initialize NETMAN and Register Protocol Stack Source: https://github.com/ps2dev/ps2sdk/blob/master/NETMAN.txt A custom network protocol stack must first initialize NETMAN using NetManInit() and then register itself. Initialization of the protocol stack itself can occur after NetManInit() if access to the network adaptor is required. ```c NetManInit(); // Register protocol stack here ``` -------------------------------- ### HDSK Module Initialization and Control Source: https://github.com/ps2dev/ps2sdk/blob/master/iop/hdd/hdsk/README.txt Explains how to initialize and control the HDSK module using its devctl functions. ```APIDOC ## HDSK Module Control ### Description The HDD defragmenter (HDSK) module is an IOP module for reducing external fragmentation of a HDD unit. After successful initialization, HDSK creates a `hdsk` device with specific I/O functions. ### Syntax `hdsk` ### Method This section describes the `devctl` function used for controlling the HDSK module. ### Endpoint N/A (This is an IOP module function, not a network endpoint.) ### Parameters #### Devctl Codes - **HDSK_DEVCTL_GET_FREE** (0) - Gets an estimated time remaining for the checking operation to complete. - **HDSK_DEVCTL_GET_HDD_STAT** (1) - Gets (struct hdskStat) the amount of free space and the amount of data (in sectors) that has to be moved. - **HDSK_DEVCTL_START** (2) - Starts the defragmentation process. - **HDSK_DEVCTL_WAIT** (3) - Waits for the defragmentation operation to end. - **HDSK_DEVCTL_POLL** (4) - Polls for whether the defragmentation operation has ended (1 = in progress, 0 = done). - **HDSK_DEVCTL_GET_STATUS** (5) - Gets runtime status (0 = OK, non-zero = error). - **HDSK_DEVCTL_STOP** (6) - Aborts the defragmentation operation. Termination must be confirmed with either codes #2 or #3. - **HDSK_DEVCTL_GET_PROGRESS** (7) - Gets the progress of the defragmentation operation (returns the amount of sectors moved so far). ### Request Example ```c // Example of calling devctl for HDSK_DEVCTL_START int fd = open("/dev/hdsk", O_RDWR); if (fd < 0) { // Handle error } int result = devctl(fd, HDSK_DEVCTL_START, NULL, 0, NULL); close(fd); ``` ### Response #### Success Response (200) - **Return Value** (int) - Typically 0 on success, non-zero on error. Specific return values depend on the `devctl` code used. #### Response Example ```c // Example of checking status after HDSK_DEVCTL_START int fd = open("/dev/hdsk", O_RDWR); if (fd < 0) { // Handle error } int status; devctl(fd, HDSK_DEVCTL_GET_STATUS, NULL, 0, &status); // status will be 0 if OK, non-zero if error close(fd); ``` ``` -------------------------------- ### Initialize EE-side Network Stack Source: https://github.com/ps2dev/ps2sdk/blob/master/NETMAN.txt Invoke ps2ipInit() to fully initialize the NETMAN RPC service for an EE-side LWIP stack. This function initializes basic RPC functions and performs timing based on the HSYNC clock. The default HSYNC ticks per millisecond is 16, suitable for PAL and NTSC modes. ```c ps2ipInit(); ``` -------------------------------- ### Using mips64r5900el-ps2-elf-gprof Source: https://github.com/ps2dev/ps2sdk/blob/master/ee/libprofglue/samples/basic/README.md Analyze the gmon.out file generated by gprof. Ensure you have the binary and the gmon.out file in the current working directory. ```bash mips64r5900el-ps2-elf-gprof -b {binary.elf} gmon.out ``` ```bash mips64r5900el-ps2-elf-gprof -b gprofbasic.elf gmon.out ``` -------------------------------- ### FSSK Device I/O Functions Source: https://github.com/ps2dev/ps2sdk/blob/master/iop/hdd/fssk/README.txt After initialization, FSSK creates a device with specific I/O functions for interacting with partitions. ```APIDOC ## FSSK Device I/O Functions ### Description After successful initialization, FSSK creates a device that provides the following I/O functions for interacting with partitions. ### `open` Opens the partition that will be checked. The path format is typically `fssk:hdd0:__system`. #### Parameters - **mode** (integer) - The mode parameter has the following bit definition: `VVVV0000` where `V` is the Verbosity level (0-15) and `0` is unused (must be set to 0). ### `close` Used to close the partition that was checked. ### `ioctl2` Used for controlling the FSSK module. It accepts various command codes to manage the checking and trimming operations. ``` -------------------------------- ### IOPBTCONF Module Loading Order Source: https://github.com/ps2dev/ps2sdk/blob/master/iop/system/udnl-t300/README.txt Specifies that SYSMEM and LOADCORE must be the first and second modules loaded, respectively, in an IOPBTCONF file. ```plaintext Note: SYSMEM and LOADCORE have to be the first and second modules to be loaded respectively. ``` -------------------------------- ### FSCK Module Usage Source: https://github.com/ps2dev/ps2sdk/blob/master/iop/hdd/fsck/README.txt Information on how to invoke and use the FSCK module from the command line. ```APIDOC ## FSCK Module Usage ### Description This section describes the command-line syntax for invoking the FileSystem ChecKer (FSCK) module. ### Method Command Line ### Endpoint N/A ### Parameters #### Command Line Options - **-n ** (integer) - Specifies the number of buffers that FSCK will use, affecting performance. ### Request Example ```bash fsck -n 1024 ``` ### Response N/A ``` -------------------------------- ### Enable gprof Profiling Source: https://github.com/ps2dev/ps2sdk/blob/master/ee/libprofglue/samples/custom/README.md Add the -g -pg flags to EE_CFLAGS and EE_LDFLAGS to enable gprof profiling for your PS2 SDK project. ```makefile EE_CFLAGS += -g -pg EE_LDFLAGS += -g -pg ``` -------------------------------- ### UDNL Command-Line Syntax Source: https://github.com/ps2dev/ps2sdk/blob/master/iop/system/udnl/README.txt UDNL accepts multiple IOPRP images as arguments, scanning them to find the newest version of modules specified in IOPBTCONF. The '-v' flag is recognized but not implemented. ```bash UDNL ... [-v] ``` -------------------------------- ### Deinitialize NETMAN Source: https://github.com/ps2dev/ps2sdk/blob/master/NETMAN.txt On shutdown, NetManDeinit() should be invoked to deinitialize NETMAN and release any associated resources. ```c NetManDeinit(); ``` -------------------------------- ### Initialize System Functions in PS2SDK Source: https://github.com/ps2dev/ps2sdk/blob/master/ee/kernel/README.MD This function initializes various system functionalities, including timer systems, alarms, threads, execution, and TLB functions. It's called during the application's initialization process. ```c void _InitSys(void) { StartTimerSystemTime(); InitTimerAlarm(); InitAlarm(); InitThread(); InitExecPS2(); InitTLBFunctions(); } ``` -------------------------------- ### Comment Out FULL_UDNL in udnl.c Source: https://github.com/ps2dev/ps2sdk/blob/master/iop/system/udnl-t300/README.txt To build a UDNL module that functions like the Sony DVD player version, comment out the FULL_UDNL macro in udnl.c. This restricts the module to only using its embedded IOPRP images for IOP resets. ```c Comment out FULL_UDNL within udnl.c to build a UDNL module that works like the Sony UDNL module that ships with DVD players. Such a UDNL module will reset the IOP with only their embedded IOPRP images. ``` -------------------------------- ### IOPBTCONF Include Directive Source: https://github.com/ps2dev/ps2sdk/blob/master/iop/system/udnl/README.txt The '!include' directive allows one IOPBTCONF file to incorporate another. Note that includes cannot be placed in the middle of a module list. ```plaintext !include ``` -------------------------------- ### Disable All Optional Initialization Functions Source: https://github.com/ps2dev/ps2sdk/blob/master/ee/kernel/README.MD Combine these macros to disable both patched BIOS functions and extra timer utilities. This approach is effective for creating the smallest possible binaries by omitting non-essential initialization code. ```c #include #include // With this line we disabled the patched functionalities DISABLE_PATCHED_FUNCTIONS(); // With this line we disabled the extra functionalities for timers DISABLE_EXTRA_TIMERS_FUNCTIONS(); int main(int argc, char *argv[]) { printf("Hello world!\n"); return 0; } ``` -------------------------------- ### FSSK ioctl2 Commands Source: https://github.com/ps2dev/ps2sdk/blob/master/iop/hdd/fssk/README.txt A comprehensive list of ioctl2 commands available for controlling the FSSK module's operations. ```APIDOC ## FSSK ioctl2 Commands ### Description This section details the available ioctl2 commands for controlling the FSSK module. ### Commands - **FSSK_IOCTL2_CMD_GET_ESTIMATE** (0) - Gets an estimated time remaining for the checking operation to complete. - **FSSK_IOCTL2_CMD_START** (1) - Starts the checking operation. - **FSSK_IOCTL2_CMD_WAIT** (2) - Waits for the checking operation to end. - **FSSK_IOCTL2_CMD_POLL** (3) - Polls for whether the checking operation has ended. Returns 1 if in progress, 0 if done. - **FSSK_IOCTL2_CMD_GET_STATUS** (4) - Gets runtime data. Returns a `struct fsskStatus` (28 bytes). - **FSSK_IOCTL2_CMD_STOP** (5) - Aborts the checking operation. Termination must be confirmed with either codes #2 or #3. - **FSSK_IOCTL2_CMD_SET_MINFREE** (6) - Sets the minimum free threshold in percentage. The default is 3, but the minimum that can be specified is 4. - **FSSK_IOCTL2_CMD_SIM** (7) - Runs a simulation. The `partsDeleted` status will indicate the number of partitions to be deleted, and the size of the deleted partitions will be returned. ``` -------------------------------- ### UDNL Command Line Syntax Source: https://github.com/ps2dev/ps2sdk/blob/master/iop/system/udnl-t300/README.txt The UDNL module accepts multiple IOPRP images as arguments. It scans these images to find the newest version of each module specified in IOPBTCONF. rom0: is automatically appended to the list. ```bash UDNL ... [-v] [-nobusini] [-nocacheini] ``` -------------------------------- ### UDNL Command Line Options Source: https://github.com/ps2dev/ps2sdk/blob/master/iop/system/udnl-t300/README.txt Optional flags for the UDNL command. -v is recognized but not implemented, likely for verbosity. -nobusini and -nocacheini skip specific initializations. ```bash -v: The -v command is elusive; although recognized by UDNL, no code actually reacts to its presence. (It's most likely a verbosity level control though) -nobusini (or just -nb): SSBUS initialization is skipped. -nocacheini (or just -nc): Cache initialization is skipped. ``` -------------------------------- ### Inspect gprof Output Source: https://github.com/ps2dev/ps2sdk/blob/master/ee/libprofglue/samples/custom/README.md Use the mips64r5900el-ps2-elf-gprof binary to inspect the generated gmon.out file. This command displays a flat profile and call graph. ```bash mips64r5900el-ps2-elf-gprof -b {binary.elf} {gmon_custom.out} ``` ```bash mips64r5900el-ps2-elf-gprof -b gprofcustom.elf gmon_custom.out ``` -------------------------------- ### FSCK Command Line Options Source: https://github.com/ps2dev/ps2sdk/blob/master/iop/hdd/fsck/README.txt Use the -n option to specify the number of buffers FSCK will use, which affects performance. ```bash fsck Options: -n - specifies the number of buffers that FSCK will use, which affects performance. ``` -------------------------------- ### Register Network Interface Driver Source: https://github.com/ps2dev/ps2sdk/blob/master/NETMAN.txt At startup, a custom network adaptor driver should register itself with NETMAN using NetManRegisterNetIF(). This function is essential for integrating a new network interface into the system. ```c NetManRegisterNetIF(driver_info); ``` -------------------------------- ### Fix SBP-2 Device Configuration ROM Parsing Source: https://github.com/ps2dev/ps2sdk/blob/master/iop/iLink/IEEE1394_disk/doc/Changelog.txt Addresses a bug in parsing the configuration ROM of SBP-2 devices. This ensures correct offset calculations when the Unit Directory is not the first entry in the Root Directory. ```c Fixed a bug in the code that parses the configuration ROM of the SBP-2 devices. If the Unit Directory offset was not the first entry within the Root Directory, there was quite a good chance that the offsets will be miscalculated. ``` -------------------------------- ### FSCK Device I/O Functions Source: https://github.com/ps2dev/ps2sdk/blob/master/iop/hdd/fsck/README.txt Details on the I/O functions available for the fsck device after initialization. ```APIDOC ## FSCK Device I/O Functions ### Description After successful initialization, FSCK creates a device with specific I/O functions for interacting with partitions. ### Method I/O Operations on `fsck:` device ### Endpoint `fsck:` ### Parameters #### open Function Parameters - **path** (string) - The path to the partition to be checked, e.g., `fsck:hdd0:__system`. - **mode** (integer) - Bitmask for controlling open behavior: - **W** (bit 0): Write enabled (0 = read-only). - **P** (bit 1): Prompt user before performing each fix. - **V** (bits 2-5): Verbosity level (0-15). - **0** (bits 6-7): Unused, must be set to 0. ### Request Example Opening a partition for read-only check with maximum verbosity: ```c int fd = open("fsck:hdd0:__system", 0x00000000); // Read-only, no prompt, verbosity 0 int fd = open("fsck:hdd0:__system", 0x0000000F); // Read-only, no prompt, verbosity 15 ``` Opening a partition for read-write with prompt: ```c int fd = open("fsck:hdd0:__system", 0x00000003); // Read-write, prompt enabled, verbosity 0 ``` ### Response #### Success Response (open) File descriptor for the opened partition. #### Success Response (close) Indicates successful closure of the partition. #### Success Response (ioctl2) Depends on the specific `FSCK_IOCTL2_CMD` used. ### ioctl2 Commands - **FSCK_IOCTL2_CMD_GET_ESTIMATE** (0): Gets an estimated time remaining for the checking operation. - **FSCK_IOCTL2_CMD_START** (1): Starts the checking operation. - **FSCK_IOCTL2_CMD_WAIT** (2): Waits for the checking operation to end. - **FSCK_IOCTL2_CMD_POLL** (3): Polls for whether the checking operation has ended (returns 1 if in progress, 0 if done). - **FSCK_IOCTL2_CMD_GET_STATUS** (4): Gets runtime data (struct fsckStatus, 28 bytes). - **FSCK_IOCTL2_CMD_STOP** (5): Aborts the checking operation. Termination must be confirmed with codes #2 or #3. ``` -------------------------------- ### Implement Synchronous Transfer with Timeout Source: https://github.com/ps2dev/ps2sdk/blob/master/iop/iLink/IEEE1394_disk/doc/Changelog.txt Introduces ieee1394_Sync_withTimeout() as a wrapper for ieee1394_Sync(). This function accepts a timeout value to prevent the console from freezing if a target device does not respond. ```c Added ieee1394_Sync_withTimeout(). It's a wrapper function to ieee1394_Sync(), and accepts a value that will be used as a timeout. Modified ieee1394_SendManagementORB() to use ieee1394_Sync_withTimeout() instead of ieee1394_Sync(), to prevent freezing up the console if the target device was to not respond. ``` -------------------------------- ### Build UDNL without Embedded IOPRP Source: https://github.com/ps2dev/ps2sdk/blob/master/iop/system/udnl/README.txt Comment out FULL_UDNL in udnl.c to create a UDNL module that functions like the Sony DVD player version. This version resets the IOP using only its embedded IOPRP images. ```c #define FULL_UDNL ``` -------------------------------- ### IOPBTCONF Address Directive Source: https://github.com/ps2dev/ps2sdk/blob/master/iop/system/udnl/README.txt The '!addr' directive specifies a memory address from which to include a module. ```plaintext !addr
``` -------------------------------- ### Set HSYNC Ticks Per Millisecond Source: https://github.com/ps2dev/ps2sdk/blob/master/NETMAN.txt Use ps2ipSetHsyncTicksPerMSec() to specify the number of HSYNC ticks that elapse in one millisecond if using non-default video modes with the EE-side LWIP stack. ```c ps2ipSetHsyncTicksPerMSec(16); ``` -------------------------------- ### Remove Old Testing Code and Optimize Makefile Source: https://github.com/ps2dev/ps2sdk/blob/master/iop/iLink/IEEE1394_disk/doc/Changelog.txt Removes outdated testing code from sbp2_driver.c and declares the device name in main.c as const. The Makefile is updated for default optimization levels and cleaner build processes. ```c Removed old testing code in sbp2_driver.c: The payload size was always that of the S100 transfer mode. Declaration the device name in main.c as const. Edited main.c to make it neater. The Makefile has been edited to use the default level of optimization as specified by the development environment, and to only delete the object files and compiled binary whenever a "make clean" command is invoked. ``` -------------------------------- ### Reduce Bus Reset Delay Source: https://github.com/ps2dev/ps2sdk/blob/master/iop/iLink/IEEE1394_disk/doc/Changelog.txt Decreases the waiting time between bus reset and device initialization from 600,000 usec to 500,000 usec. ```c The waiting time between the bus reset and initialization of all devices on the bus was reduced from 600000 usec to 500000 usec. ``` -------------------------------- ### PS2SDK Project CMake Configuration Source: https://github.com/ps2dev/ps2sdk/blob/master/skeleton/iop/CMakeLists.txt This CMake script configures a PS2SDK project, defining build targets, source files, and linking libraries for the IOP module. ```cmake cmake_minimum_required(VERSION 3.10) project(hello LANGUAGES C) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) SET(IOP_BIN hello.irx) SET(IOP_SRCS hello_exports.c hello_main.c exports.c imports.c) SET(IOP_LIBS) BUILD_IOP_EXPORTS(exports.c ${CMAKE_CURRENT_SOURCE_DIR}/exports.tab) BUILD_IOP_IMPORTS(imports.c ${CMAKE_CURRENT_SOURCE_DIR}/imports.lst) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fno-builtin") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s") ADD_EXECUTABLE(${IOP_BIN} ${IOP_SRCS}) ADD_CUSTOM_COMMAND(TARGET ${IOP_BIN} POST_BUILD COMMAND md5sum ARGS ${IOP_BIN}) ``` -------------------------------- ### Allocate and Enqueue Received Packet Source: https://github.com/ps2dev/ps2sdk/blob/master/NETMAN.txt When a frame is received by a network adaptor driver, it should be allocated using NetManRpcNetProtStackAllocRxPacket() and then enqueued with NetManRpcProtStackEnQRxPacket(). This process is repeated until no more frames can be processed or allocated. ```c frame_buffer = NetManRpcNetProtStackAllocRxPacket(); NetManRpcProtStackEnQRxPacket(frame_buffer); ``` -------------------------------- ### FSSK Module Usage Source: https://github.com/ps2dev/ps2sdk/blob/master/iop/hdd/fssk/README.txt The FSSK module is an IOP module for reducing internal fragmentation of PlayStation FileSystem (PFS) partitions. It can be invoked with various options. ```APIDOC ## FSSK Module Usage ### Description The FileSystem trimmer (FSSK) module is an IOP module for reducing internal fragmentation of PlayStation FileSystem (PFS) partitions. ### Syntax ``` fssk ``` ### Options - **-n <buffers>** (integer) - Specifies the number of buffers that FSSK will use, which affects performance. ``` -------------------------------- ### Send Frame Using NETMAN Source: https://github.com/ps2dev/ps2sdk/blob/master/NETMAN.txt Network protocol stacks can send a single frame out of the network adaptor using the NetManNetIFSendPacket() function provided by NETMAN. ```c NetManNetIFSendPacket(packet_buffer, length); ```