Matt J. Gumbley | Website: http://www.gumbley.me.uk
Blog: On The Edge of Occam's Razor

The SIBO-Linux Project

Abstract

This project attempts to port the Linux Kernel to Psion's SIBO (SIxteen Bit Organiser) architecture. Several problems hinder this effort, notably, the scacity of memory on the platform, the segmented architecture of the Intel processor (real mode, an NEC V30H), and the speed of the platforms. Nevertheless, this kind of problem has not stopped us from attempting the blatantly ridiculous in the past. This page also houses Matt's notes on the SIBO Architecture.

Table Of Contents

1 Change Log

This project or information is dead. I cannot release any code or further information on it, other than what you'll find on this page. All communication regarding it will be silently deleted. Apologies.

18/7/99 Started updating page, replaced PENGUIN/EDISASM, added notes on memory layout, etc.

2 Introduction

Psion's SIBO family of computers includes the Series 3, HC and Workabout range of palmtops.

The SIBO architecture is based on an NEC V30H processor, one or two megabytes of RAM, and some custom chips. The custom chips perform bus control, providing memory write and I/O blocking, timers, LCD control, memory decoding, interrupts control, wathdog timer, serial control, keyboard interface, buzzer control.

A SIBO system typically runs the EPOC-16 (Electronic Piece Of Cheese, allegedly) operating system, which is contained in ROM, along with several invaluable applications.

Psion's marketing department have pulled a cunning stunt, and renamed EPOC-16 SIBO, while EPOC-32 is now called EPOC.

This project is an attempt to port the Linux operating system to this platform, taking over the system completely - SIBO and the applications will not be available on a SIBO-Linux system.

This might sound impossible; perhaps it is, however, Simon Wood has managed to port ELKS - the Embeddable Linux Kernel Subset - to this architecture...

2.1 Why run Linux on such a small platform?

Pure hack value. Because we can, or rather, it might be possible to. Linux is a highly portable operating system. It is being ported to the 3Com PalmPilot series of handheld computers, and SIBO owners feel left out :-)

It has been suggested by several members of the Linux-8086 mailing list that the Psion is far better kept as it is, running SIBO. This is probably true, but we're hackers, dammit :-)

2.2 Isn't there a Linux-8086 project already?

Yes. This is the ELKS (Embedded Linux Kernel Subset) project. It is a cut-down (in most parts, rewritten) version of Linux. This project attempts to use the big Linux kernel.

See references for Simon Wood's port of ELKS to SIBO.

3 Problems to be faced

3.1 The Linux kernel is large - it won't fit!

A full Linux kernel is indeed quite large. However, we'll only be using the absolute basics - drivers for the SIBO hardware shouldn't be very large at all - it isn't a huge architecture. It'll be tight, but it might be possible.

3.2 Device Drivers

We will need to produce an architecture subdirectory for EPOC hardware, and write device drivers for:
  • LCD screen as console
  • Keyboard
  • Serial port
  • Timers
Most of this will probably need to be written in assembler. Simon Wood has done much of this for ELKS; we might be able to reuse this...

3.3 Lack of MMU

Linux proper requires a MMU to isolate processes from each other - there is a form of MMU in the SIBO architecture, although it might not be necessary to use it. The Linux Microcontroller Project (need ref) has ported Linux to the PalmPilot, and removed the need for an MMU. Hopefully, this work can be used in this port, in some form.

3.4 Support for the different SIBO systems

There are different custom chips in the different models - and SIBO insulates the programmer against these differences. We'll be exposed to it.

3.5 Development tools

Traditionally, SIBO software is developed using Psion's SIBO C SDK. This comprises Psion's headers and libraries, and builds are performed using the TopSpeed C Compiler.

Linux is built using the GNU C Compiler, gcc.

It would be far too much work to convert Linux to use TopSpeed, so we need a version of gcc which will target the 8086 (V30H). DJ Delorie has made some modifications to gcc 2.7.2.3 which provide this back end. His modifications are not complete, and so one of our goals is to finish them.

Note: There is also another project which I am involved in, the Psion-C project, aiming to provide a free development environment for the EPOC platform. This has been built using bcc, the compiler used by the Linux-8086 team. Several tools used in that project will be added to the gcc we produce, to produce an SIBO gcc.

3.6 Debugging tools: No emulator

SIBO programmers build their software on PCs, and test them on a PC-hosted version of SIBO: the Series 3a, Siena and Workabout emulators. Since our code will hit the hardware directly, it won't be possible to boot Linux on the emulator. It may be possible to write suitably small drivers for the PC hardware, and slot them in, so build a PC (real mode) hosted version of the Linux kernel.

It might be possible to write a SIBO emulator, which would run on Linux, DOS, etc. This is covered in a separate section.

3.7 Booting Linux on SIBO

Once we have a kernel, we'll need to boot the SIBO system with it. There are problems with this, which need addressing:

3.7.1 Trashing SIBO

We won't be using any of SIBO, or the usual memory layout of the SIBO OS. So, we need to stop SIBO, turn off memory management and the watchdog timer, load and relocate the kernel, and boot it. Any attempts to write outside the process's data segment will cause it to be terminated, so we need to turn off memory protection. We also need to install our own interrupt vector table, and relocate the kernel (after loading it). If interrupts are disabled for any length of time, the watchdog timer will kick in, and cause the process to be terminated. So, we must either disable the watchdog timer (probably not possible), or point its interrupt vector to the null handler.

This kind of low-level access to the hardware is to be investigated. See Inside SIBO.

3.7.2 Loading the Kernel

The kernel will be downloaded via the serial port.
  • Running SIBO, load an SIBO "Linux Loader" program. This will prompt you, to make sure you really want to nuke EPOC, and if you concur:
  • Turn off SIBO, as mentioned above
  • Relocate the serial port kernel loader into (say) high memory
  • Jump to the serial port loader
  • Initialise the interrupt vector table, and prepare serial port hardware
  • Wait for the kernel image and root filesystem to be sent via the serial port, a byte at a time, and write it into memory
  • When finished, initialise and start the kernel
  • The kernel will then run /bin/init, etc.
The basic framework for this loader, Penguin has been written, although little of the loader is there yet.

Simon's ELKS port loads itself as a standard SIBO executable, which takes over. (Need to investigate this)

It may be possible to load the kernel image into normal EPOC memory, then turn off SIBO, relocate, and run, rather than hitting the hardware to do the serial port stuff.

3.8 Filesystem

Given the tiny memory available, only a small filesystem handler will be possible. The Psion's memory layout (bank-switched) will need special consideration.

3.9 Networking

Sure would be nice... SLIP/CSLIP or PPP. Probably only SLIP at first, since it's relatively tiny, compared to PPP.

4 The Penguin Boot Loader and EDisAsm, Memory Dumper

The boot loader is called Penguin, and its icon is, predictably, a rendition of Larry Ewing's famous penguin. There is also my investigative tools, EDisAsm.

You can download the source and binary of Penguin here - there's no version number attached to this yet, it's very alpha. There is no documentation, but the source code might give you some clues. Sorry about this, I haven't had time to do much work on it recently. Also in that archive, you'll find EDisAsm, an attempt at a disassembler/investigative tool for SIBO. Again, it's unfinished, but it's a start. It'll allow you to dump bytes or words of memory, and to view the Interrupt Vector Table. It'll eventually have a V30 disassembler, but that's some way off. It also allows you to transfer sections of memory (ROM / RAM dumps) to your PC for investigation on a large screen ;-)

Penguin has two functions:

  • Memory Dumper, uses XMODEM, and isn't finished.
  • SIBO-Linux Kernel Boot Loader (currently unfinished)

4.1 EDisAsm the Memory Dumper

Currently, EDisAsm allows you to take a snapshot of your Psion's memory, from address 0x00000 to 0xFFFFF. This will be invaluable for working out what is happening Inside SIBO, and for running the SIBO Emulator.

However, the Psion's memory is bank-switched, like this:
Address RangeDescription
0x00000 - 0x5FFFFMaps to the bottom physical 384KB of the 16MB RAM space
0x60000 - 0x6FFFFBank switched RAM. Maps to a 64KB RAM segment selected by page register PSEL0
0x70000 - 0x7FFFFBank switched RAM. Maps to a 64KB RAM segment selected by page register PSEL1
0x80000 - 0x8FFFFBank switched ROM. Maps to a 64KB ROM segment selected by page register PSEL2
0x90000 - 0x9FFFFBank switched ROM. Maps to a 64KB ROM segment selected by page register PSEL3
0xA0000 - 0xFFFFFMaps to the top physical 384KB of the 16MB ROM space
My investigations have so far been concentrating on the ROM areas, and how to obtain a decent snapshot of them. It appears that on a 1MB RAM 3c, the 0x80000-0x8FFFF area is not used, and is merely a copy of the memory found at 0x90000-0x9FFFF. There are ROM routines for selecting the bank to be switched into the 0x900000 space; no corresponsing routines have been found to switch the 0x80000 range, so direct manipulation of the relevant I/O ports has eben attempted.

See I/O Ports for details of the ports PSEL0..3, and how to alter them.

EDisAsm requires your Link connection to be active, and will send several files to the current directory on your PC:

  • RAM384.MEM - 0x00000-0x5FFFF - use the 'sendram384' command
  • RAM1xx.MEM, where xx ranges from 00 to FF - the banks 0x60000-0x6FFFF. Use the 'sendbanks6000' command.
  • RAM2xx.MEM, where xx ranges from 00 to FF - the banks 0x70000-0x7FFFF. Use the 'sendbanks7000' command.
  • 0x80000-0x8FFFF is the same as 0x90000-0x9FFFF, so this isn't dumped. (Although if you're really interested, use the 'sendbanks8000' command)
  • ROM2xx.MEM, where xx ranges from 0x80 to 0x9F (the valid range of the bank switching register PSEL3 - those values for which unique banks of memory are seen in the bank segment 0x90000-0x9FFFF) Use the 'sendbanks9000' command.
  • ROM384.MEM - 0xA0000-0xFFFFF - use the 'sendrom384' command.

RAM-bank switching: This presents a bit of a problem. I use a routine to peek inside the Psion's memory without upsetting the MMU (I disable interrupts while reading). What if I want to read from (say) bank 1 of memory (byte 0x60010, for example) and EDisAsm is loaded into a bank that is currently switched into that bank? When the PSEL0 register is flipped to load bank 1, EDisAsm will disappear!

One solution is to relocate EDisAsm's peek routine in the bottom 384KB of memory. It's only tiny, so we could possibly overwite some of the unused part of the interrupt vector table without causing any problems.

The 'solution' I settled on ('cos I'm lazy!) is to warn you if the EDisAsm code or data is located in the dangerous segment, and forbid the operation. If it's loaded into a safe location (i.e. non bank-switched memory), then allow the dump).

Copyright Notice
The ROM in your Psion is © Psion. Since I like Psion, and have no real desire to get into any trouble with them, I do NOT redistribute the Psion ROM image with Penguin.

If you want a ROM image you'll just have to get one yourself - probably by running Penguin on your own Psion.

REQUESTS FOR ROM IMAGES ON THE SIBO-LINUX MAILING LIST (OR RECEIVED PERSONALLY) WILL BE IMMEDIATELY DELETED. ANYONE OFFERING ROM IMAGES ON NEWSGROUPS AND WAREZ SITES WILL HAVE THEIR DETAILS PASSED ON TO PSION.

4.2 Penguin the Kernel Loader

There's no kernel yet, so Penguin can't load one.

5 EDisAsm

A misnomer; doesn't yet contain a disassembler, but allows me to fool around with the Psion's memory architecture, and dump ROM/RAM to disk... Look in the source for details, or type 'help'.

EDisAsm is included in the PENGUIN archive.

6 The SIBO Emulator

Once we understand the hardware and how it's accessed in more detail, we could write a SIBO emulator, and make it portable to most popular platforms. This shouldn't be massively difficult, just painstaking.

I'm looking at hacking into some existing 8086-emulators, and adding support for the SIBO hardware. Nothing available to play with yet...

7 Inside SIBO

To find out more about how SIBO (the OS) interacts with the SIBO hardware, we could download the ROM, and look in there. That's where Penguin helps.

Disassembling the ROM will be tricky, although there are tools to help with this, and I've got (somewhere) an 8086 disassembler in Perl, which should be customisable to do whatever we need. There's also EDisAsm.

8 Contacting us

A mailing list for this project has been set up.

THIS IS CURRENTLY UNAVAILABLE - My mail server is not fully reconfigured after an upgrade. (Jan 2000) Since I've stopped working on SIBO code, I won't be reactivating this.

You can subscribe: send a message to majordomo [ at ] gumbley [ dot ] demon [ dot ] co [ dot ] uk, with no subject, and the body containing the phrase

subscribe sibo-linux
and nothing else. Please note that this mailing list runs from a dial-up server, so turn-around will be fairly slow.

9 References

Several references to similar projects, etc. (Thanks, Mattias!)
(C) Matt J. Gumbley 1998-2005 - All Tights Reversed