psx.wiki

PS-X OS: Difference between revisions

Revision as of 01:40, 23 October 2026
RemmyLee
(CONTEXT.md: route images and backups)
Revision as of 02:22, 23 October 2026
RemmyLee
(Hardware and system software pages from the Sony manuals)
Line 1:Line 1:
+---
+title: PS-X OS
+type: component
+summary: Kernel of the PlayStation that provides its services as C functions.
+category: System software
+---
+
+## Overview
+
+The PS-X OS was developed for the R3000. The R3000 is the CPU of the PlayStation.[^os13]
+
+The kernel is a set of services (subroutines) that control the R3000 and the PlayStation hardware. Each service is a C language function.[^os13]
+
+The PS-X OS takes at most 64 kilobytes of RAM.[^os13]
+
+The OS discloses its system tables. Applications can extend the OS and read its internal data.[^os13]
+
+The OS leaves out the checks for prohibited operations that other operating systems perform. The application must perform these checks.[^os13]
+
+The OS has no user interface for operating the hardware directly. The debug monitor in the debugging environment is the exception.[^os23]
+
+## Tasks
+
+The PS-X OS is a multi-tasking operating system. It starts in single task mode.[^os43]
+
+A program that does not start more threads stays in single task mode.[^os43]
+
+## Boot
+
+The OS has two start modes. The DIP switches of the target box select the mode at power on or reset.[^os23]
+
+In hardware mode the OS boots as the PlayStation hardware does.[^os23]
+
+The application boot jumps to a fixed address in ROM. The boot code then checks the CD-ROM drive and the other hardware connected to the PlayStation.[^os23]
+
+The application boot then checks the type of disc.[^os23]
+
+On the right disc the boot code reads the file [SYSTEM.CNF](/system/system-cnf/). The boot code then starts the program named in SYSTEM.CNF.[^os23]
+
+With no disc the application boot runs a looping demonstration.[^os23]
+
+On a development system booted from a PC/AT host, the kernel takes its default configuration and the remote debugger starts. The executable is then loaded by hand.[^os23]
+
+## File System
+
+The file system assumes that files are on CD-ROM. It is based on ISO 9660 level 1.[^os24]
+
+File systems are accessed through device drivers. Several file systems can therefore coexist.[^os14]
+
+A file name is an 8-character base name and a 3-character extension. A period separates the two. This is the MS-DOS name format.[^os24]
+
+Names use 1-byte alphanumeric characters. Katakana and kanji cannot be used.[^os24]
+
+Subdirectories cannot be created. All files are in the root directory, and the number of files there has no limit.[^os24]
+
+## Memory Map
+
+The memory map of the PS-X OS is the [memory map](/hardware/memory-map/) of the CPU.[^os25]
+
+Interface registers of peripheral devices are mapped in logical space as memory mapped I/O.[^os25]
+
+Memory can be accessed in units of 1 to 4 bytes.[^os25]
+
+An interface register must be accessed in its own unit size. Any other size raises a bus error.[^os25]
+
+## System Tables (ToT)
+
+The OS discloses its internal system tables through the ToT (Table of Tables) structure. ToT is at address 0x00000100.[^os26]
+
+ToT has the following entries:
+
+Table: System tables
+
+| Entries | Nature |
+| --- | --- |
+| 0 | Queue header requires interrupt processing[^os26] |
+| 1 | Task state queue header |
+| 2 | Task management block |
+| 3 | System reserved |
+| 4 | Event management block |
+| 5 to 31 | System reserved |
+
+The structure is defined in include/kernel.h. Each entry holds the lead address and the size in bytes of one system table.[^os26]
+
+```
+struct ToT { /*system table table*/
+ unsigned long *head; /*system table lead address*/
+ long size; /*system table size (byte)*/
+};
+```
+
+## Function Calls
+
+A C function receives its first 4 arguments in A0 to A3.[^os28]
+
+Space for those 4 arguments is also reserved on the stack. Further arguments are passed on the stack.[^os28]
+
+A return value of less than 32 bits is in V0. For a 64-bit double the high 32 bits are in V1.[^os28]
+
+An external interrupt or an error other than a debug error saves the program counter to the EPC register of coprocessor 0.[^os28]
+
+The CPU then jumps to 0x00000080.[^os28]
+
+The [CPU](/hardware/cpu/) page lists the register assignments.
+
+## Services
+
+The OS services are called application programmer interfaces (API). A program that calls the OS links their function libraries.[^os33]
+
+The API has the following services:
+
+Table: PS-X OS services
+
+| Service | Content |
+| --- | --- |
+| Module Management Service | Loads and executes user application programs[^os33] |
+| Event Management Service | Controls program execution triggered by asynchronous events |
+| Controller Service | Supports up to 64 controllers of up to 16 buttons each |
+| I/O Management Service | Low-level input and output to files and logical devices |
+| Thread Management Service | Threads of register states, stack areas and CPU states |
+| Other Services | I-cache and R3000 setup, enabling and disabling interrupts |
+| Standard C Library | K&R standard C functions such as string operations and standard I/O |
+| Root Counter Management Service | Counters for timing[^os34] |
+
+All file control on the PlayStation goes through the I/O management service.[^os33]
+
+## Root Counters
+
+The PS-X OS has 4 root counters. Each counts automatically.
+
+Table: Root counters
+
+| Counter | Counts |
+| --- | --- |
+| 1 | Display pixels[^os34] |
+| 2 | Horizontal synchronization |
+| 3 | System clock |
+| 4 | Vertical synchronization |
+
+A counter counts up from zero. At its target value it raises an interrupt, clears to zero and counts again.[^os34]
+
+Every counter except vertical synchronization takes a 16-bit target value. The target value of vertical synchronization is fixed at 1.[^os34]
+
+The root counter and the event management service together detect the start of the vertical blanking period.[^os44]
+
+## Programming Notes
+
+EnterCriticalSection() stops interrupts.[^os43]
+
+An overlay runs as a child process of a resident module. The application must load and start the overlay itself.[^os43]
+
+The PlayStation has no character generator and no fonts. An application draws its own text as graphics.[^os43]
+
+The C library has heap functions. The OS does not initialize the heap.[^os44]
+
+The program passes the start address and size of the heap to the heap initialization function.[^os44]
+
+The entry point of an executable is set by a function name at link time. The default is main(), and the entry function takes no argument.[^os44]
+
+A program needs a stack pointer value as well as a start address. A stack pointer at an address that cannot be accessed causes a bus error.[^os45]
+
+Standard output is file descriptor 0 and standard input is file descriptor 1. Both use RS232C channel 0. Its device name is tty00.[^os45]
+
+The tty00 port uses 8-bit characters, 1 stop bit, no parity and hardware flow control.[^os45]
+
+## References
+
+[^os13]: Sony Computer Entertainment Inc. PlayStation Operating System. August 1998. Page 1-3.
+[^os14]: Sony Computer Entertainment Inc. PlayStation Operating System. August 1998. Page 1-4.
+[^os23]: Sony Computer Entertainment Inc. PlayStation Operating System. August 1998. Page 2-3.
+[^os24]: Sony Computer Entertainment Inc. PlayStation Operating System. August 1998. Page 2-4.
+[^os25]: Sony Computer Entertainment Inc. PlayStation Operating System. August 1998. Page 2-5, Table 2-2.
+[^os26]: Sony Computer Entertainment Inc. PlayStation Operating System. August 1998. Page 2-6, Table 2-3.
+[^os28]: Sony Computer Entertainment Inc. PlayStation Operating System. August 1998. Page 2-8.
+[^os33]: Sony Computer Entertainment Inc. PlayStation Operating System. August 1998. Page 3-3.
+[^os34]: Sony Computer Entertainment Inc. PlayStation Operating System. August 1998. Page 3-4.
+[^os43]: Sony Computer Entertainment Inc. PlayStation Operating System. August 1998. Page 4-3.
+[^os44]: Sony Computer Entertainment Inc. PlayStation Operating System. August 1998. Page 4-4.
+[^os45]: Sony Computer Entertainment Inc. PlayStation Operating System. August 1998. Page 4-5.