Serial Input/Output Library (libsio)
Provides standard input and output functions for connecting the PlayStation to a PC.
| Library | libsio.lib |
|---|---|
| Header File | libsio.h |
This is an old revision of this page, as edited by RemmyLee at 02:58, 23 October 2026. Edit this revision | Latest revision
Overview
The Serial Input/Output Library (libsio) provides standard input and output functions for connecting the PlayStation to a PC, and it supports the output of debug information to the PC.1
A program that uses libsio links with libsio.lib and includes libsio.h.1
Serial I/O Driver
libsio consists of the serial I/O driver and the serial I/O BIOS. The driver provides standard input and output through the standard C procedures, so standard I/O can be assigned to the communications port without other code. AddSIO() includes the driver and DelSIO() deletes it. For more complex communication, such as with a PC and a modem, the BIOS is used instead.1
Serial I/O BIOS
The serial I/O BIOS provides low-level driver control and information that the standard C functions do not cover. Its interface function is _sio_control(). The libraries normally write debugging data to standard I/O. Data communication with a PC through the driver would therefore receive unexpected data, so such communication uses the BIOS without the driver and with standard I/O in NULL mode. The BIOS also works when the driver is not included.1
_sio_control(cmd, arg, param) issues the SIO commands:2
| cmd | arg | Function |
|---|---|---|
| 0 | 0 | Return the driver status |
| 0 | 1 | Return the control line status |
| 0 | 2 | Return the communications mode |
| 0 | 3 | Return the communications speed in bps |
| 0 | 4 | Read 1 byte |
| 1 | 1 | Set the control line status to param |
| 1 | 2 | Set the communications mode to param |
| 1 | 3 | Set the communications speed to param bps |
| 1 | 4 | Write 1 byte |
| 2 | 0 | Reset the driver |
| 2 | 1 | Clear the error bits of the driver status |
The driver status has the following bits:2
| Bit | Symbol | Contents |
|---|---|---|
| 9 | SR_IRQ | Interrupt on |
| 8 | SR_CTS | CTS is on |
| 7 | SR_DSR | DSR is on |
| 5 | SR_FE | Frame error occurs |
| 4 | SR_OE | Overrun error occurs |
| 3 | SR_PERROR | Parity error occurs |
| 2 | SR_TXU | No communications data |
| 1 | SR_RXRDY | Communications data can be read |
| 0 | SR_TXRDY | Communications data can be written |
In the control line status bit 1 is RTS and bit 0 is DTR. In the communications mode bits 7 and 6 give the stop bit length (MR_SB_01, MR_SB_10 and MR_SB_11 for 1, 1.5 and 2 bits). Bit 5 (MR_P_EVEN) selects odd or even parity, bit 4 (MR_PEN) enables parity and bits 3 and 2 give the character length from 5 to 8 bits.3
Sio1Callback() sets a function called on the interrupts enabled by _sio_control(1, 1, param), which are CR_DSRIEN, CR_RXIEN and CR_TXIEN. The callback must clear the interrupt flag with _sio_control(2, 1, 0) or _sio_control(1, 1, CR_ERRRST), since no further SIO interrupt occurs until the flag is cleared.4
Functions
In the tables below, Introduced is the run-time library version that added the item.5
libsio has the following functions:5
| Function | Introduced | Purpose |
|---|---|---|
AddSIO |
3.6 | Initialize SIO driver. |
DelSIO |
3.6 | Delete SIO driver from kernel. |
Sio1Callback |
4.0 | Set SIO interrupt callback function. |
_sio_control |
3.6 | Issue SIO command. |
References
-
^ a b c d Sony Computer Entertainment Inc. Run-Time Library Overview. Run-Time Library 4.4. January 1999. Page 17-3.
-
^ a b Sony Computer Entertainment Inc. Run-Time Library Reference. Run-Time Library 4.4. January 1999. Page 16-6.
-
^ Sony Computer Entertainment Inc. Run-Time Library Reference. Run-Time Library 4.4. January 1999. Page 16-7.
-
^ Sony Computer Entertainment Inc. Run-Time Library Reference. Run-Time Library 4.4. January 1999. Page 16-5.
-
^ a b Sony Computer Entertainment Inc. Run-Time Library Reference. Run-Time Library 4.4. January 1999. Pages 16-3 to 16-6.