The Playstation 2 Linux Kit Handbook

Copyright Notice

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with the Invariant Sections being Copyright, with no Front-Cover Texts and with no Back-Cover Texts.

A copy of the GNU Free Documentation License is available on the World Wide Web at http://www.gnu.org/copyleft/fdl.html. You can also obtain it by writing to the


     Free Software Foundation, Inc.
     59 Temple Place - Suite 330
     Boston 
     MA 
     02111-1307
     USA
    


Table of Contents

1 Introduction to the Playstation 2 Linux kit
What is the Playstation 2 Linux kit?
Why did Sony release this kit?
How hard is it to use the kit?
What could I use the kit for?
Differences from a regular Linux distribution
Where can I get the kit?
2 Hardware and software included with the kit
Ethernet Unit
Hard Disk Drive (HDD)
USB Keyboard, Mouse and VGA cable
Playstation 2 Linux software distribution
Hardware that you must purchase separately
3 Functional overview of the Playstation 2
Layout of the Playstation 2
R5900 Emotion Engine CPU core
Floating Point Unit (FPU)
Cache and Scratchpad RAM (SPR)
DMA, DRAM and Memory Management Unit (MMU)
Interrupt controller and Timers
Vector Processor Unit 0 (VPU0/VU0/COP1)
Vector Processor Unit 1 (VPU1/VU1/COP2)
Graphics Synthesizer (GS)
Image Processing Unit (IPU)
I/O Processor (IOP)
USB 1.0 Controller
Sony i.Link (Firewire) Controller
Sound Processing Unit (SPU2)
System bus controllers
System Interface (SIF) and System bus (SBUS) controllers
VPU Interface (VIF0 and VIF1)
Graphics Interface (GIF)
DMA Controller
RDRAM Controller
4 The PS2 Linux kernel
The MIPS kernel core
PS2 specific device drivers
Sony PS2 DVD drive
Playstation 2 Joypad support
Memory card device
Real-time clock
SPU sound driver
Ethernet driver (smap)
Graphics Synthesizer console
Sony PS2 USB controller
Kernel command line options
5 System Performance
Processors
Emotion Engine Core
Vector Units
Graphics Synthesizer
I/O Processor
System I/O
Memory bandwidth
Ethernet
Harddisk
USB
Firewire
6 Specific software for PS2 Linux
Vector Command Line (VCL)
Memory Card format (mcformat)
PS2 development libraries (libps2dev)
7 Online resources
playstation2-linux.com

Chapter 1. Introduction to the Playstation 2 Linux kit

What is the Playstation 2 Linux kit?

The Sony Playstation 2 Linux kit allows any owner of a consumer Playstation 2 unit to run Linux. The kit consists of an add on hard drive and ethernet combo as well as all of the software needed to install and run a full Linux system. It not only allows you to run all of the familar Linux applications like Apache, X Windows, telnet, mpg123, and the gimp, it also allows you the ability to compile programs directly on the Playstation 2 itself. Full access to the graphics and processing hardware is supported and writing any application is possible.

Why did Sony release this kit?

Several factors played into Sony's release of the Playstation 2 Linux kit:

  • The Playstation 2 is notorious for being hard to program for due to the complexity of the hardware involved in the console. Thus, there are relatively few people in the gaming industry that know how to utilize the full potential of the system.
  • The more people that know how to program for the Playstation 2, the better. It wouldn't be surprising to see surge of students and hobbyists becoming PS3 graphics programmers in the coming years due to the release of the PS2 Linux kit.
  • Graphics and game hobbyists have been reverse engineering and modifying consoles for years with the notion of homebrew game programming in mind. This effort is partially wasted because the end goal for most hobbyists is programming graphics for the console, not piracy.

Sony has also setup a community website for the Playstation 2 Linux kit, which can be found at http://www.playstation2-linux.com/.

How hard is it to use the kit?

If you are a regular Linux user, the kit is very easy to use. Infact, the kit operates just like a regular Linux system. You can login, change directories, run shell scripts, and use all the regular unix commands.

If you are unfamiliar with Linux or Unix in general, the learning curve is going to be steep. However, everybody has to start somewhere and setting up a Linux system on a Playstation 2 is quite easy compared to setting a similar system up on a PC. There are many books on learning Unix and many websites describing how to configure Linux software.

What could I use the kit for?

The kit's purpose is multi-faceted, but is meant primarily for homebrew game and application development. All the software that you need to create a game is included with the system. Other possibilities for the kit exist, some of which are:

  • High performance computing
  • Parallel computing
  • Web Server/Firewall
  • Music Player
  • Linux gaming machine
  • Network file server

If the application has anything to do with graphics or number crunching, the PS2 is usually a good fit.

Differences from a regular Linux distribution

Since all Playstation 2 systems are identical, every Playstation 2 Linux install is the exact same. No need to worry about incompatible hardware, or if the Linux kernel supports your particular graphics card or motherboard.

The physical size of the entire Linux system is quite tiny and does not require a large amount of resources or space to use. All you need is a Playstation 2, and the Linux kit (plus a Sync On Green monitor to perform the installation). The total cost for everything should be around $400 USD, which is quite affordable considering what you would pay for a comparable PC setup.

The Playstation 2 Linux distribution is based on Kondara Linux 5.2, which is subsequently based on RedHat Linux 5.2. Although this makes the PS2 Linux distribution quite outdated, there are several efforts to provide updated RPMs for the system.

Where can I get the kit?

The Sony Playstation 2 Linux kit can be purchased from the official Playstation.com websites.

Chapter 2. Hardware and software included with the kit

Ethernet Unit

A 10/100 Mbit ethernet unit ships with the Playstation 2 Linux kit. The unit is compatible with any 10/100 Base-T network/hub. Along with the standard RJ-45 jack on the back of the unit (with link and activity LEDs), the ethernet unit houses three other connections. The Sony PS2 Hard Disk Drive (HDD) power and IDE data connections are kept opposite the RJ-45 jack as well as a proprietary PC card connector which is used to connect the unit to the Playstation 2.

The ethernet unit that ships with the Linux kit resembles the consumer one that will be sold in the US starting in August 2002. The one item that is missing is the 56k modem port.

Hard Disk Drive (HDD)

The hard disk drive (HDD) unit that ships with the Playstation 2 is a standard IDE drive with specialized firmware to make it work in a Playstation 2. It is a 40 GB drive manufactured by Western Digital for Sony.

USB Keyboard, Mouse and VGA cable

A Sony Playstation 2 USB keyboard is included in the Playstation 2 Linux kit. The keyboard is a standard black 104-key keyboard. There is a pass-through port for chaining another USB device off of the keyboard, such as a USB mouse or camera.

The Sony Playstation 2 USB mouse is of the standard two button mechanical variety. It is black in color and has a nice PS2 logo on the top.

The kit also comes with a VGA break-out cable for hooking the Playstation 2 to a VGA monitor. By default, the linux installer will only work with a Sync on Green VGA monitor. After the installation is complete, you can instruct the bootloader to only use NTSC or PAL for display (so you don't need to have a monitor nearby). The cable also has two RCA jacks for left and right stereo. It plugs directly into the Playstation 2 video port located at the back left of the machine.

Playstation 2 Linux software distribution

The PS2 Linux kit ships with a version of Kondara Linux, which is based on RedHat Linux 5.2. The distribution's installer (anaconda) has been tailored towards the Playstation 2's hardware making installation a relatively straight forward process.

There are two DVD discs in the distribution, the first one is primarily a bootloader and rescue disc, the second is the software distribution. There are 581 binary RPM packages that are included with the system along with 389 source RPM packages.

The distribution is a relatively complete one, including a tailored X-Windows server, most common server packages and user applications.

Hardware that you must purchase separately

You must have purchased a Playstation 2 unit ($199 as of August 2002) and a memory card ($25 as of August 2002) before you are able to use the Playstation 2 Linux kit.

Chapter 3. Functional overview of the Playstation 2

Layout of the Playstation 2

The Playstation 2 is a very complex beast, composed of several different types of specialized processors that are designed to operate in parallel. Most of the processors can access other parts of the system independently and thus a great deal of the work in the PS2 can be performed unattended by the main processor.

Figure 3.1. Block diagram of the Playstation 2

The diagram above shows the functional layout of the Playstation 2. The system can be broken down into three groups; graphics, control, and I/O. Most control and calculations happen in the Emotion Engine (EE), graphics rendering is done mostly in the Graphics Synthesizer (GS), and I/O is handled by the I/O Processor (IOP).

R5900 Emotion Engine CPU core

Figure 3.2. Block diagram of the Playstation 2 - Emotion Engine Core

The main CPU in the Playstation 2 is one developed by Toshiba, exclusively for the console. It is a 128-bit MIPS ISA level III compliant processor. The Emotion Engine (EE) is the chip that manages most of the other processors in the system, performing the role of a traditional CPU.

Some of its more advanced features include:

  • 32 128-bit wide general purpose registers
  • 32 32-bit wide floating point registers
  • 128-bit wide data path connected to a 128-bit wide system bus
  • 2-way superscalar pipeline, capable of processing two 64-bit MIPS III instructions per cycle.
  • MIPS IV parallel multimedia instructions capable of doing one 128, two 64, four 32, eight 16 or sixteen 8-bit operations per instruction.
  • 2 micro-programmable vector processors capable of ~2.8GFlops each.

Floating Point Unit (FPU)

Figure 3.3. Block diagram of the Playstation 2 - Floating Point Unit

The floating point unit included in the EE core is a high performance single-precision floating-point unit. The designers of the FPU decided to not make it IEEE compliant and save some silicon. All this means is that the floating point numbers generated do not comply -exactly- to the IEEE spec, but the numbers should be close enough for most programmers. The FPU contains one multiply-add unit and one floating point divide unit.

Cache and Scratchpad RAM (SPR)

Due to the requirement of low manufacturing cost, the EE contains a very limited on-chip cache. 8KB of data cache and 16KB of instruction cache are included on-chip. There is also another cache specified as the Scratchpad that is used as a low-latency working area.

DMA, DRAM and Memory Management Unit (MMU)

The memory management unit, RDRAM controller and DMA controller handle all memory access within the system. The Playstation 2 is rated at performing a peak theoretical bandwidth of 3.2 GBps.

The DMA controller is a 10 channel controller that can DMA data between main memory and an I/O device (such as the IPU) as well as memory and scratchpad RAM.

The MMU is capable of doing 32-bit physical/logical address space conversion and has a 48-entry TLB to speed lookups.

Interrupt controller and Timers

The PS2 provides an interrupt for every device in the system as well as a special interrupt for the DMA controller. Four 16-bit timers are provided for high precision, processor cycle-level timing.

Vector Processor Unit 0 (VPU0/VU0/COP1)

Figure 3.4. Block diagram of the Playstation 2 - Vector Processing Units

Vector Unit 0 (VU0) is one of the EE co-processors and is used primarily for geometry processing. Both vector units are micro-programmable processors with their own instruction and data space.

The main features of VU0 include:

  • 32 32-bit floating point registers
  • 16 16-bit integer registers
  • 4KB of micro-memory for instructions
  • 4KB of micro-memory for data
  • 4 32-bit single precision floating point multiply-add units
  • 1 32-bit single precision floating point divide unit
  • Macro and micro-mode operation (explained below)

VU0 can run in two modes; macro-mode and micro-mode. In macro-mode, the EE can call VU0 instructions directly and fetch the results. In micro-mode, a small vector unit micro-program is uploaded by the EE and subsequently executed. An example would be the VU0 processing physics effects on particles before they are sent to VU1 for the rendering phase. After the micro-program has run, the EE can then retrieve the results of the micro-program.

Vector Processor Unit 1 (VPU1/VU1/COP2)

Vector Unit 1 (VU1) is one of the EE co-processors and is used primarily for graphics pre-processing for the GS. Both vector units are micro-programmable processors with their own instruction and data space.

The main features of VU1 include:

  • 32 32-bit floating point registers
  • 16 16-bit integer registers
  • 16KB of micro-memory for instructions
  • 16KB of micro-memory for data
  • 4 32-bit single precision floating point multiply-add units
  • 1 32-bit single precision floating point divide unit

The main difference between VU0 and VU1 is the micro-memory available and their purpose. VU1 has 16KB more internal instruction and data space, versus just 4KB for VU0. VU1 is primarily used for pre-processing of geometry, texture and other graphics data before it is sent to the GS. VU0's primary purpose is to pre-process geometry or aid the EE with physics or other heavy floating point calculations. An example of VU1s use would be performing the perspective transform for all verticies before they are sent to the GS.

Graphics Synthesizer (GS)

Figure 3.5. Block diagram of the Playstation 2 - Graphics Synthesizer

The Graphics Synthesizer (GS) is responsible for rendering all graphics primitives to the screen. It is capable of rendering between 25-75 million triangles per second at a fill-rate of about 2.4 Gigapixels per second. The GS can also output images in NTSC, PAL, VESA and DTV formats (either interlaced or non-interlaced). Some of its features include:

  • 32-bit color operation (Red, Green, Blue, and Alpha)
  • Point, Line, Line Strip, Triangle, Triangle Strip, Triangle Fan and Sprite primitives.
  • 4, 8, 16, 24 and 32-bit texture modes
  • 16, 24 and 32-bit Z buffer
  • Alpha blending, edge anti-aliasing (lines and triangles), fogging, scissoring and two context drawing environment.
  • Unified memory with 38.4GB/s of bandwidth to the framebuffer, 9.6GB/s of bandwidth to the texture buffer, and 1.2GB/s of bandwidth to main RAM.

Image Processing Unit (IPU)

Figure 3.6. Block diagram of the Playstation 2 - Image Processing Unit

The Image Processing Unit is part of the Emotion Engine and performs MPEG-2 macro block decoding, color space conversion and vector quantization for 2D graphics data. This graphics data can be frames from an MPEG-2 movie or compressed textures for 3D models.

There really isn't much more to the IPU, it decodes image data very quickly and thats about it.

I/O Processor (IOP)

Figure 3.7. Block diagram of the Playstation 2 - I/O Processor

The I/O Processor on the Playstation 2 is actually the Playstation 1 main processor with several extensions to handle USB, Firewire, sound, and the other new peripherals introduced by the Playstation 2. It is a standard MIPS R3000R processor without a MMU and 2MB of local memory. All external I/O such as memory card access, USB control, Firewire devices and sound playback is handled via the IOP. Some of its features include:

  • MIPS R3000R processor running at 33.86Mhz or 36.86Mhz
  • 2MB of local memory
  • Sound Processing Unit with 48 channels
  • Industry standard USB 1.0, Sony i.Link (IEEE 1394 Firewire) support
  • Serial interface to MagicGate interface (Memory cards and controllers)

Unfortunately, access to the entire IOP is not available to general users due to Sony's need to protect their Intellectual Property from pirates and other nefarious individuals.

USB 1.0 Controller

A relatively gutsy move for Sony at the time was integrating two standard USB ports into the Playstation 2. These are standard USB 1.0 compliant ports and will accept any USB 1.0 compliant device. This includes USB cameras, keyboards, mice, storage devices, speakers, etc.

The USB devices are available to the PS2 Linux kit via the standard Linux USB device filesystem.

Sony i.Link (Firewire) Controller

Another very gutsy move by SCE was to include a i.Link (Firewire) port with the Playstation 2. Sadly, this gamble seems to not have paid off as much as Sony would have liked it to. Only a select few games use the i.Link port. Gran Turismo 3 is probably the most successful PS2 title to use them for networked gameplay.

Unfortunately, the i.Link port is not accessible via the PS2 Linux kit. The IOP controls access via i.Link and the software calls in the closed source SBIOS do not exist for i.Link access.

Sound Processing Unit (SPU2)

The Sound Processing Unit (SPU2) handles all sound mixing and playback. It is a relatively advanced sound processor capable of a variety of sound effects, playback styles and output styles. SPU2 is actually composed of two sound processing cores (CORE0 and CORE1) each with 24-audio channels each. Both SPU cores are identical.

Some SPU2's features include:

  • 48-channels of audio in ADPCM format
  • Software-programmable voices w/ real-time digital effect processing including pitch transformation and modulation, envelope processing and mixing.
  • 2MB of dedicated RAM for sound data
  • 48Khz digital optical output as well as regular analog out

System bus controllers

Due to the parallel nature of the Playstation 2's many processors, communication between components is quite a complicated process. The system must guarantee a certain order of transmission from one part of the system to the other as well as provide a means to decide which transfer is most important. Like the rest of the system, the mechanism for arbitrating what data goes where is well designed and encapsulated in each of the bus interfaces.

System Interface (SIF) and System bus (SBUS) controllers

The System Interface (SIF) and System Bus (SBUS) controllers connect the IOP to the main bus and control all data going to and coming from the IOP.

The SIF is comprised of a 8 quad-word FIFO and is used to transfer data to/from the IOP.

The SBUS is the bus between the SIF and the IOP. (THIS SECTION NEEDS MORE DOCUMENTATION - msporny)

VPU Interface (VIF0 and VIF1)

The Vector Processor Interface (VIF) handles communication between each VU and main memory. Its main purpose is to decompress incoming data to each VPU (such as vertex data).

Graphics Interface (GIF)

The Graphics Interface (GIF) unpacks and formats incoming data from main memory into a form that the GS can understand. An example would be packed vertex and color data that is unpacked into draw commands that will display a triangle on the screen of a specified color.

DMA Controller

The DMA controller for the PS2 is an integral part of the system. All the system processors depend on the DMA controller to handle transferring data around the system. Once one of the main processors such as the EE or VPUs format data in a format that another processor can understand it, the DMA controller handles the monotonous task of physically feeding the data to the targeted processor.

An example of this would be the Emotion Engine creating a list of polygons to be rendered to the screen. The display data is then DMA'ed to the GIF via the DMA Controller, which then sends it to the Graphics Synthesizer to become displayed to the screen.

RDRAM Controller

The RDRAM controller handles all transfer of data to and from main memory. While a programmer does not have access to the controller, it is important to note that it actually is there.

Chapter 4. The PS2 Linux kernel

The MIPS kernel core

PS2 specific device drivers

Sony PS2 DVD drive

Playstation 2 Joypad support

Memory card device

Real-time clock

SPU sound driver

Ethernet driver (smap)

Graphics Synthesizer console

Sony PS2 USB controller

Kernel command line options

Chapter 5. System Performance

Processors

Emotion Engine Core

Vector Units

Graphics Synthesizer

I/O Processor

System I/O

Memory bandwidth

Ethernet

Harddisk

USB

Firewire

Chapter 6. Specific software for PS2 Linux

Vector Command Line (VCL)

Memory Card format (mcformat)

PS2 development libraries (libps2dev)

Chapter 7. Online resources

Table of Contents

playstation2-linux.com

playstation2-linux.com