psx.wiki

Serial Input/Output Library (libsio): Difference between revisions

Revision as of 02:47, 23 October 2026
RemmyLee
(Formats: Sony paragraph voice; HMD, RSD extended files, full BS code book; sprite editor formats)
Revision as of 02:58, 23 October 2026
RemmyLee
(Run-time library pages: 20 libraries from the Library Overview and Reference 4.4)
Line 1:Line 1:
+---
+title: Serial Input/Output Library (libsio)
+type: component
+summary: Provides standard input and output functions for connecting the PlayStation to a PC.
+category: Libraries
+info: Library = libsio.lib
+info: Header File = libsio.h
+---
+
+## 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.[^o17-3]
+
+A program that uses libsio links with libsio.lib and includes libsio.h.[^o17-3]
+
+## 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.[^o17-3]
+
+## 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.[^o17-3]
+
+_sio_control(cmd, arg, param) issues the SIO commands:[^r16-6]
+
+Table: _sio_control() commands
+
+| 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:[^r16-6]
+
+Table: Driver status
+
+| 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.[^r16-7]
+
+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.[^r16-5]
+
+## Functions
+
+In the tables below, Introduced is the run-time library version that added the item.[^reff163]
+
+libsio has the following functions:[^reff163]
+
+Table: libsio functions
+
+| 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
+
+[^o17-3]: Sony Computer Entertainment Inc. Run-Time Library Overview. Run-Time Library 4.4. January 1999. Page 17-3.
+[^r16-5]: Sony Computer Entertainment Inc. Run-Time Library Reference. Run-Time Library 4.4. January 1999. Page 16-5.
+[^r16-6]: Sony Computer Entertainment Inc. Run-Time Library Reference. Run-Time Library 4.4. January 1999. Page 16-6.
+[^r16-7]: Sony Computer Entertainment Inc. Run-Time Library Reference. Run-Time Library 4.4. January 1999. Page 16-7.
+[^reff163]: Sony Computer Entertainment Inc. Run-Time Library Reference. Run-Time Library 4.4. January 1999. Pages 16-3 to 16-6.